]> git.sesse.net Git - pistorm/commitdiff
[MEGA-WIP] RTG things
authorbeeanyew <beeanyew@gmail.com>
Thu, 6 May 2021 18:27:30 +0000 (20:27 +0200)
committerbeeanyew <beeanyew@gmail.com>
Thu, 6 May 2021 18:27:30 +0000 (20:27 +0200)
232 files changed:
config_file/config_file.c
config_file/config_file.h
platforms/amiga/pistorm-dev/pistorm-dev-enums.h
platforms/amiga/pistorm-dev/pistorm-dev.c
platforms/amiga/pistorm-dev/pistorm_dev_amiga/pistorm_dev.c
platforms/amiga/pistorm-dev/pistorm_dev_amiga/pistorm_dev.h
platforms/amiga/rtg/rtg.c
platforms/amiga/rtg/rtg.h
raylib/external/cgltf.h [deleted file]
raylib/external/dirent.h [deleted file]
raylib/external/dr_flac.h [deleted file]
raylib/external/dr_mp3.h [deleted file]
raylib/external/dr_wav.h [deleted file]
raylib/external/glad.h [deleted file]
raylib/external/glfw/.mailmap [deleted file]
raylib/external/glfw/CMake/GenerateMappings.cmake [deleted file]
raylib/external/glfw/CMake/Info.plist.in [deleted file]
raylib/external/glfw/CMake/MacOSXBundleInfo.plist.in [deleted file]
raylib/external/glfw/CMake/cmake_uninstall.cmake.in [deleted file]
raylib/external/glfw/CMake/glfw3.pc.in [deleted file]
raylib/external/glfw/CMake/glfw3Config.cmake.in [deleted file]
raylib/external/glfw/CMake/i686-w64-mingw32-clang.cmake [deleted file]
raylib/external/glfw/CMake/i686-w64-mingw32.cmake [deleted file]
raylib/external/glfw/CMake/modules/FindEpollShim.cmake [deleted file]
raylib/external/glfw/CMake/modules/FindOSMesa.cmake [deleted file]
raylib/external/glfw/CMake/modules/FindWaylandProtocols.cmake [deleted file]
raylib/external/glfw/CMake/modules/FindXKBCommon.cmake [deleted file]
raylib/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake [deleted file]
raylib/external/glfw/CMake/x86_64-w64-mingw32.cmake [deleted file]
raylib/external/glfw/CMakeLists.txt [deleted file]
raylib/external/glfw/LICENSE.md [deleted file]
raylib/external/glfw/README.md [deleted file]
raylib/external/glfw/deps/getopt.c [deleted file]
raylib/external/glfw/deps/getopt.h [deleted file]
raylib/external/glfw/deps/glad/gl.h [deleted file]
raylib/external/glfw/deps/glad/khrplatform.h [deleted file]
raylib/external/glfw/deps/glad/vk_platform.h [deleted file]
raylib/external/glfw/deps/glad/vulkan.h [deleted file]
raylib/external/glfw/deps/glad_gl.c [deleted file]
raylib/external/glfw/deps/glad_vulkan.c [deleted file]
raylib/external/glfw/deps/mingw/_mingw_dxhelper.h [deleted file]
raylib/external/glfw/deps/mingw/dinput.h [deleted file]
raylib/external/glfw/deps/mingw/xinput.h [deleted file]
raylib/external/glfw/deps/vs2008/stdint.h [deleted file]
raylib/external/glfw/include/GLFW/glfw3.h [deleted file]
raylib/external/glfw/include/GLFW/glfw3native.h [deleted file]
raylib/external/glfw/src/CMakeLists.txt [deleted file]
raylib/external/glfw/src/cocoa_init.m [deleted file]
raylib/external/glfw/src/cocoa_joystick.h [deleted file]
raylib/external/glfw/src/cocoa_joystick.m [deleted file]
raylib/external/glfw/src/cocoa_monitor.m [deleted file]
raylib/external/glfw/src/cocoa_platform.h [deleted file]
raylib/external/glfw/src/cocoa_time.c [deleted file]
raylib/external/glfw/src/cocoa_window.m [deleted file]
raylib/external/glfw/src/context.c [deleted file]
raylib/external/glfw/src/egl_context.c [deleted file]
raylib/external/glfw/src/egl_context.h [deleted file]
raylib/external/glfw/src/glfw.rc.in [deleted file]
raylib/external/glfw/src/glfw_config.h.in [deleted file]
raylib/external/glfw/src/glx_context.c [deleted file]
raylib/external/glfw/src/glx_context.h [deleted file]
raylib/external/glfw/src/init.c [deleted file]
raylib/external/glfw/src/input.c [deleted file]
raylib/external/glfw/src/internal.h [deleted file]
raylib/external/glfw/src/linux_joystick.c [deleted file]
raylib/external/glfw/src/linux_joystick.h [deleted file]
raylib/external/glfw/src/mappings.h [deleted file]
raylib/external/glfw/src/mappings.h.in [deleted file]
raylib/external/glfw/src/monitor.c [deleted file]
raylib/external/glfw/src/nsgl_context.h [deleted file]
raylib/external/glfw/src/nsgl_context.m [deleted file]
raylib/external/glfw/src/null_init.c [deleted file]
raylib/external/glfw/src/null_joystick.c [deleted file]
raylib/external/glfw/src/null_joystick.h [deleted file]
raylib/external/glfw/src/null_monitor.c [deleted file]
raylib/external/glfw/src/null_platform.h [deleted file]
raylib/external/glfw/src/null_window.c [deleted file]
raylib/external/glfw/src/osmesa_context.c [deleted file]
raylib/external/glfw/src/osmesa_context.h [deleted file]
raylib/external/glfw/src/posix_thread.c [deleted file]
raylib/external/glfw/src/posix_thread.h [deleted file]
raylib/external/glfw/src/posix_time.c [deleted file]
raylib/external/glfw/src/posix_time.h [deleted file]
raylib/external/glfw/src/vulkan.c [deleted file]
raylib/external/glfw/src/wgl_context.c [deleted file]
raylib/external/glfw/src/wgl_context.h [deleted file]
raylib/external/glfw/src/win32_init.c [deleted file]
raylib/external/glfw/src/win32_joystick.c [deleted file]
raylib/external/glfw/src/win32_joystick.h [deleted file]
raylib/external/glfw/src/win32_monitor.c [deleted file]
raylib/external/glfw/src/win32_platform.h [deleted file]
raylib/external/glfw/src/win32_thread.c [deleted file]
raylib/external/glfw/src/win32_time.c [deleted file]
raylib/external/glfw/src/win32_window.c [deleted file]
raylib/external/glfw/src/window.c [deleted file]
raylib/external/glfw/src/wl_init.c [deleted file]
raylib/external/glfw/src/wl_monitor.c [deleted file]
raylib/external/glfw/src/wl_platform.h [deleted file]
raylib/external/glfw/src/wl_window.c [deleted file]
raylib/external/glfw/src/x11_init.c [deleted file]
raylib/external/glfw/src/x11_monitor.c [deleted file]
raylib/external/glfw/src/x11_platform.h [deleted file]
raylib/external/glfw/src/x11_window.c [deleted file]
raylib/external/glfw/src/xkb_unicode.c [deleted file]
raylib/external/glfw/src/xkb_unicode.h [deleted file]
raylib/external/jar_mod.h [deleted file]
raylib/external/jar_xm.h [deleted file]
raylib/external/miniaudio.h [deleted file]
raylib/external/msf_gif.h [deleted file]
raylib/external/par_shapes.h [deleted file]
raylib/external/sdefl.h [deleted file]
raylib/external/sinfl.h [deleted file]
raylib/external/stb_image.h [deleted file]
raylib/external/stb_image_resize.h [deleted file]
raylib/external/stb_image_write.h [deleted file]
raylib/external/stb_perlin.h [deleted file]
raylib/external/stb_rect_pack.h [deleted file]
raylib/external/stb_truetype.h [deleted file]
raylib/external/stb_vorbis.h [deleted file]
raylib/external/tinyobj_loader_c.h [deleted file]
raylib_pi4_test/external/cgltf.h [deleted file]
raylib_pi4_test/external/dirent.h [deleted file]
raylib_pi4_test/external/dr_flac.h [deleted file]
raylib_pi4_test/external/dr_mp3.h [deleted file]
raylib_pi4_test/external/dr_wav.h [deleted file]
raylib_pi4_test/external/glad.h [deleted file]
raylib_pi4_test/external/glfw/.mailmap [deleted file]
raylib_pi4_test/external/glfw/CMake/GenerateMappings.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/Info.plist.in [deleted file]
raylib_pi4_test/external/glfw/CMake/MacOSXBundleInfo.plist.in [deleted file]
raylib_pi4_test/external/glfw/CMake/cmake_uninstall.cmake.in [deleted file]
raylib_pi4_test/external/glfw/CMake/glfw3.pc.in [deleted file]
raylib_pi4_test/external/glfw/CMake/glfw3Config.cmake.in [deleted file]
raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32-clang.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/modules/FindEpollShim.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/modules/FindOSMesa.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/modules/FindWaylandProtocols.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/modules/FindXKBCommon.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake [deleted file]
raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32.cmake [deleted file]
raylib_pi4_test/external/glfw/CMakeLists.txt [deleted file]
raylib_pi4_test/external/glfw/LICENSE.md [deleted file]
raylib_pi4_test/external/glfw/README.md [deleted file]
raylib_pi4_test/external/glfw/deps/getopt.c [deleted file]
raylib_pi4_test/external/glfw/deps/getopt.h [deleted file]
raylib_pi4_test/external/glfw/deps/glad/gl.h [deleted file]
raylib_pi4_test/external/glfw/deps/glad/khrplatform.h [deleted file]
raylib_pi4_test/external/glfw/deps/glad/vk_platform.h [deleted file]
raylib_pi4_test/external/glfw/deps/glad/vulkan.h [deleted file]
raylib_pi4_test/external/glfw/deps/glad_gl.c [deleted file]
raylib_pi4_test/external/glfw/deps/glad_vulkan.c [deleted file]
raylib_pi4_test/external/glfw/deps/mingw/_mingw_dxhelper.h [deleted file]
raylib_pi4_test/external/glfw/deps/mingw/dinput.h [deleted file]
raylib_pi4_test/external/glfw/deps/mingw/xinput.h [deleted file]
raylib_pi4_test/external/glfw/deps/vs2008/stdint.h [deleted file]
raylib_pi4_test/external/glfw/include/GLFW/glfw3.h [deleted file]
raylib_pi4_test/external/glfw/include/GLFW/glfw3native.h [deleted file]
raylib_pi4_test/external/glfw/src/CMakeLists.txt [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_init.m [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_joystick.h [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_joystick.m [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_monitor.m [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_platform.h [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_time.c [deleted file]
raylib_pi4_test/external/glfw/src/cocoa_window.m [deleted file]
raylib_pi4_test/external/glfw/src/context.c [deleted file]
raylib_pi4_test/external/glfw/src/egl_context.c [deleted file]
raylib_pi4_test/external/glfw/src/egl_context.h [deleted file]
raylib_pi4_test/external/glfw/src/glfw.rc.in [deleted file]
raylib_pi4_test/external/glfw/src/glfw_config.h.in [deleted file]
raylib_pi4_test/external/glfw/src/glx_context.c [deleted file]
raylib_pi4_test/external/glfw/src/glx_context.h [deleted file]
raylib_pi4_test/external/glfw/src/init.c [deleted file]
raylib_pi4_test/external/glfw/src/input.c [deleted file]
raylib_pi4_test/external/glfw/src/internal.h [deleted file]
raylib_pi4_test/external/glfw/src/linux_joystick.c [deleted file]
raylib_pi4_test/external/glfw/src/linux_joystick.h [deleted file]
raylib_pi4_test/external/glfw/src/mappings.h [deleted file]
raylib_pi4_test/external/glfw/src/mappings.h.in [deleted file]
raylib_pi4_test/external/glfw/src/monitor.c [deleted file]
raylib_pi4_test/external/glfw/src/nsgl_context.h [deleted file]
raylib_pi4_test/external/glfw/src/nsgl_context.m [deleted file]
raylib_pi4_test/external/glfw/src/null_init.c [deleted file]
raylib_pi4_test/external/glfw/src/null_joystick.c [deleted file]
raylib_pi4_test/external/glfw/src/null_joystick.h [deleted file]
raylib_pi4_test/external/glfw/src/null_monitor.c [deleted file]
raylib_pi4_test/external/glfw/src/null_platform.h [deleted file]
raylib_pi4_test/external/glfw/src/null_window.c [deleted file]
raylib_pi4_test/external/glfw/src/osmesa_context.c [deleted file]
raylib_pi4_test/external/glfw/src/osmesa_context.h [deleted file]
raylib_pi4_test/external/glfw/src/posix_thread.c [deleted file]
raylib_pi4_test/external/glfw/src/posix_thread.h [deleted file]
raylib_pi4_test/external/glfw/src/posix_time.c [deleted file]
raylib_pi4_test/external/glfw/src/posix_time.h [deleted file]
raylib_pi4_test/external/glfw/src/vulkan.c [deleted file]
raylib_pi4_test/external/glfw/src/wgl_context.c [deleted file]
raylib_pi4_test/external/glfw/src/wgl_context.h [deleted file]
raylib_pi4_test/external/glfw/src/win32_init.c [deleted file]
raylib_pi4_test/external/glfw/src/win32_joystick.c [deleted file]
raylib_pi4_test/external/glfw/src/win32_joystick.h [deleted file]
raylib_pi4_test/external/glfw/src/win32_monitor.c [deleted file]
raylib_pi4_test/external/glfw/src/win32_platform.h [deleted file]
raylib_pi4_test/external/glfw/src/win32_thread.c [deleted file]
raylib_pi4_test/external/glfw/src/win32_time.c [deleted file]
raylib_pi4_test/external/glfw/src/win32_window.c [deleted file]
raylib_pi4_test/external/glfw/src/window.c [deleted file]
raylib_pi4_test/external/glfw/src/wl_init.c [deleted file]
raylib_pi4_test/external/glfw/src/wl_monitor.c [deleted file]
raylib_pi4_test/external/glfw/src/wl_platform.h [deleted file]
raylib_pi4_test/external/glfw/src/wl_window.c [deleted file]
raylib_pi4_test/external/glfw/src/x11_init.c [deleted file]
raylib_pi4_test/external/glfw/src/x11_monitor.c [deleted file]
raylib_pi4_test/external/glfw/src/x11_platform.h [deleted file]
raylib_pi4_test/external/glfw/src/x11_window.c [deleted file]
raylib_pi4_test/external/glfw/src/xkb_unicode.c [deleted file]
raylib_pi4_test/external/glfw/src/xkb_unicode.h [deleted file]
raylib_pi4_test/external/jar_mod.h [deleted file]
raylib_pi4_test/external/jar_xm.h [deleted file]
raylib_pi4_test/external/miniaudio.h [deleted file]
raylib_pi4_test/external/msf_gif.h [deleted file]
raylib_pi4_test/external/par_shapes.h [deleted file]
raylib_pi4_test/external/sdefl.h [deleted file]
raylib_pi4_test/external/sinfl.h [deleted file]
raylib_pi4_test/external/stb_image.h [deleted file]
raylib_pi4_test/external/stb_image_resize.h [deleted file]
raylib_pi4_test/external/stb_image_write.h [deleted file]
raylib_pi4_test/external/stb_perlin.h [deleted file]
raylib_pi4_test/external/stb_rect_pack.h [deleted file]
raylib_pi4_test/external/stb_truetype.h [deleted file]
raylib_pi4_test/external/stb_vorbis.h [deleted file]
raylib_pi4_test/external/tinyobj_loader_c.h [deleted file]

index dec1554c31de945a244995b751909558744f273e..775aac5106c53c6f6f788700efdd8e89afc14d27 100644 (file)
@@ -27,6 +27,7 @@ const char *map_type_names[MAPTYPE_NUM] = {
   "rom",
   "ram",
   "register",
+  "ram (no alloc)",
 };
 
 const char *config_item_names[CONFITEM_NUM] = {
@@ -198,6 +199,10 @@ void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int ad
   }
 
   switch(type) {
+    case MAPTYPE_RAM_NOALLOC:
+      printf("[CFG] Adding %d byte (%d MB) RAM mapping %s...\n", size, size / 1024 / 1024, map_id);
+      cfg->map_data[index] = (unsigned char *)filename;
+      break;
     case MAPTYPE_RAM:
       printf("[CFG] Allocating %d bytes for RAM mapping (%d MB)...\n", size, size / 1024 / 1024);
       cfg->map_data[index] = (unsigned char *)malloc(size);
index 0f1625cbeb265acd17c28eb7a90d42a59cedb544..629fdcab292de90e996901475c1e0d80c20aeb9f 100644 (file)
@@ -17,6 +17,7 @@ typedef enum {
   MAPTYPE_ROM,
   MAPTYPE_RAM,
   MAPTYPE_REGISTER,
+  MAPTYPE_RAM_NOALLOC,
   MAPTYPE_NUM,
 } map_types;
 
index c48fe87a7715473fb1fac33dc195d78285183f92..58fba7abbbeef11ee2d38510fcd5b902e763a44a 100644 (file)
@@ -27,6 +27,7 @@ enum pistorm_dev_cmds {
     PI_CMD_TRANSFERFILE     = 0x0104, // [W] Transfer over a file from the Pi to Amiga RAM.
     PI_CMD_MEMCPY           = 0x0108, // [W] Copy written longword of bytes from one area of memory (PTR1)
                                       //     to another (PTR2).
+    PI_CMD_GET_FB           = 0x010C, // [R] Get the current framebuffer address.
 
     PI_CMD_QBASIC           = 0x0FFC, // QBasic
     PI_CMD_NIBBLES          = 0x0FFE, // Nibbles
index be15d1b713e9904d35f7364c371b257160e8aa94..91e631c31e89825e0c867001374249ea55afcf2f 100644 (file)
@@ -187,10 +187,12 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
                 int32_t src = get_mapped_item_by_address(cfg, pi_ptr[0]);
                 int32_t dst = get_mapped_item_by_address(cfg, pi_ptr[1]);
                 if (dst != -1 && src != -1) {
+                    printf("doing super memcpy\n");
                     uint8_t *src_ptr = &cfg->map_data[src][(pi_ptr[0] - cfg->map_offset[src])];
                     uint8_t *dst_ptr = &cfg->map_data[dst][(pi_ptr[1] - cfg->map_offset[dst])];
                     memcpy(dst_ptr, src_ptr, val);
                 } else {
+                    printf("doing manual memcpy\n");
                     uint8_t tmp = 0;
                     for (uint32_t i = 0; i < val; i++) {
                         if (src == -1) tmp = read8(pi_ptr[0] + i);
@@ -491,6 +493,9 @@ uint32_t handle_pistorm_dev_read(uint32_t addr_, uint8_t type) {
             DEBUG("[PISTORM-DEV] %s Read from PISCSI_CTRL\n", op_type_names[type]);
             return piscsi_enabled;
             break;
+        case PI_CMD_GET_FB:
+            DEBUG("[PISTORM-DEV] %s read from GET_FB: %.8X\n", op_type_names[type], rtg_get_fb());
+            return rtg_get_fb();
 
         case PI_DBG_VAL1: case PI_DBG_VAL2: case PI_DBG_VAL3: case PI_DBG_VAL4:
         case PI_DBG_VAL5: case PI_DBG_VAL6: case PI_DBG_VAL7: case PI_DBG_VAL8:
index e21bdcba20cf25f4fc7b3d0e7240dac9a359cbc7..7bdddaeb70acc8f2292ee7e85e4369f9fa88e771 100644 (file)
@@ -39,8 +39,9 @@ unsigned int pistorm_base_addr = 0xFFFFFFFF;
 #define RETURN_CMDRES READSHORT(PI_CMDRESULT, short_val); return short_val;
 
 unsigned short short_val;
+unsigned int long_val;
 
-unsigned int pi_find_pistorm() {
+unsigned int pi_find_pistorm(void) {
     unsigned int board_addr = 0xFFFFFFFF;
     struct ExpansionBase *expansionbase = (struct ExpansionBase *)OpenLibrary((STRPTR)"expansion.library", 0L);
 
@@ -155,11 +156,11 @@ unsigned short pi_load_config(char *filename) {
        RETURN_CMDRES;
 }
 
-void pi_reload_config() {
+void pi_reload_config(void) {
        WRITESHORT(PI_CMD_SWITCHCONFIG, PICFG_RELOAD);
 }
 
-void pi_load_default_config() {
+void pi_load_default_config(void) {
        WRITESHORT(PI_CMD_SWITCHCONFIG, PICFG_DEFAULT);
 }
 
@@ -194,35 +195,40 @@ void pi_set_feature_status(unsigned short cmd, unsigned char value) {
 }
 
 #define SIMPLEREAD_SHORT(a, b) \
-    unsigned short a() { READSHORT(b, short_val); return short_val; }
+    unsigned short a(void) { READSHORT(b, short_val); return short_val; }
+
+unsigned int pi_get_fb(void) {
+       READLONG(PI_CMD_GET_FB, long_val);
+       return long_val;
+}
 
 // Simple feature status read functions
-unsigned short pi_get_hw_rev()
+unsigned short pi_get_hw_rev(void)
 {
     READSHORT(PI_CMD_HWREV, short_val);
     return short_val;
 }
-unsigned short pi_get_sw_rev()
+unsigned short pi_get_sw_rev(void)
 {
     READSHORT(PI_CMD_SWREV, short_val);
     return short_val;
 }
-unsigned short pi_get_rtg_status()
+unsigned short pi_get_rtg_status(void)
 {
     READSHORT(PI_CMD_RTGSTATUS, short_val);
     return short_val;
 }
-unsigned short pi_get_net_status()
+unsigned short pi_get_net_status(void)
 {
     READSHORT(PI_CMD_NETSTATUS, short_val);
     return short_val;
 }
-unsigned short pi_get_piscsi_status()
+unsigned short pi_get_piscsi_status(void)
 {
     READSHORT(PI_CMD_PISCSI_CTRL, short_val);
     return short_val;
 }
-unsigned short pi_get_cmd_result()
+unsigned short pi_get_cmd_result(void)
 {
     READSHORT(PI_CMDRESULT, short_val);
     return short_val;
index b84f24ffd47e5d1c58cd59935242b5f44d7b583c..49d2ff4a6fb4a6217aad6d4fc53a929d4375ae54 100644 (file)
@@ -1,12 +1,12 @@
 // SPDX-License-Identifier: MIT
 
-unsigned int pi_find_pistorm();
+unsigned int pi_find_pistorm(void);
 
-unsigned short pi_get_hw_rev();
-unsigned short pi_get_sw_rev();
-unsigned short pi_get_net_status();
-unsigned short pi_get_rtg_status();
-unsigned short pi_get_piscsi_status();
+unsigned short pi_get_hw_rev(void);
+unsigned short pi_get_sw_rev(void);
+unsigned short pi_get_net_status(void);
+unsigned short pi_get_rtg_status(void);
+unsigned short pi_get_piscsi_status(void);
 
 void pi_enable_rtg(unsigned short val);
 void pi_enable_net(unsigned short val);
@@ -25,10 +25,11 @@ unsigned short pi_piscsi_eject_media(unsigned char index);
 unsigned short pi_get_filesize(char *filename, unsigned int *file_size);
 unsigned short pi_transfer_file(char *filename, unsigned char *dest_ptr);
 unsigned short pi_memcpy(unsigned char *dst, unsigned char *src, unsigned int size);
+unsigned int pi_get_fb(void);
 
 unsigned short pi_load_config(char *filename);
-void pi_reload_config();
-void pi_load_default_config();
+void pi_reload_config(void);
+void pi_load_default_config(void);
 
 unsigned short pi_remap_kickrom(char *filename);
 unsigned short pi_remap_extrom(char *filename);
index e63bcec14e99ba2f239ab1fe0643ce7f2dfec27f..fd80be86f6505de065c0dc389815da1a6a2d6ae2 100644 (file)
@@ -34,6 +34,7 @@ static void handle_rtg_command(uint32_t cmd);
 
 uint8_t realtime_graphics_debug = 0;
 extern int cpu_emulation_running;
+extern struct emulator_config *cfg;
 extern uint8_t rtg_on;
 
 /*
@@ -58,6 +59,8 @@ int init_rtg_data() {
         return 0;
     }
 
+    m68k_add_ram_range(PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, rtg_mem);
+    add_mapping(cfg, MAPTYPE_RAM_NOALLOC, PIGFX_RTG_BASE + PIGFX_REG_SIZE, PIGFX_RTG_SIZE - PIGFX_REG_SIZE, -1, NULL, "rtg_mem");
     return 1;
 }
 
@@ -67,6 +70,7 @@ void shutdown_rtg() {
         rtg_on = 0;
     }
     if (rtg_mem) {
+        
         free(rtg_mem);
         rtg_mem = NULL;
     }
@@ -74,6 +78,10 @@ void shutdown_rtg() {
 
 //void rtg_update_screen();
 
+unsigned int rtg_get_fb() {
+    return PIGFX_RTG_BASE + PIGFX_REG_SIZE + framebuffer_addr_adj;
+}
+
 unsigned int rtg_read(uint32_t address, uint8_t mode) {
     //printf("%s read from RTG: %.8X\n", op_type_names[mode], address);
     if (address == RTG_COMMAND) {
@@ -192,7 +200,7 @@ void rtg_write(uint32_t address, uint32_t value, uint8_t mode) {
 #define gdebug(a) if (realtime_graphics_debug) { printf(a); m68k_end_timeslice(); cpu_emulation_running = 0; }
 
 static void handle_rtg_command(uint32_t cmd) {
-    //printf("Handling RTG command %d (%.8X)\n", cmd, cmd);
+  //printf("Handling RTG command %d (%.8X)\n", cmd, cmd);
     switch (cmd) {
         case RTGCMD_SETGC:
             rtg_display_format = rtg_format;
index dbf7815cefd17514eefad2a49fe5fcdd9f2c8c0f..cc18e6bd114766d084727f10353c5e2c36613f7b 100644 (file)
@@ -17,6 +17,8 @@ void rtg_set_clut_entry(uint8_t index, uint32_t xrgb);
 void rtg_init_display();
 void rtg_shutdown_display();
 
+unsigned int rtg_get_fb();
+
 int init_rtg_data();
 void shutdown_rtg();
 
diff --git a/raylib/external/cgltf.h b/raylib/external/cgltf.h
deleted file mode 100644 (file)
index 4cc2d7e..0000000
+++ /dev/null
@@ -1,6327 +0,0 @@
-/**
- * cgltf - a single-file glTF 2.0 parser written in C99.
- *
- * Version: 1.10
- *
- * Website: https://github.com/jkuhlmann/cgltf
- *
- * Distributed under the MIT License, see notice at the end of this file.
- *
- * Building:
- * Include this file where you need the struct and function
- * declarations. Have exactly one source file where you define
- * `CGLTF_IMPLEMENTATION` before including this file to get the
- * function definitions.
- *
- * Reference:
- * `cgltf_result cgltf_parse(const cgltf_options*, const void*,
- * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If
- * this function returns `cgltf_result_success`, you have to call
- * `cgltf_free()` on the created `cgltf_data*` variable.
- * Note that contents of external files for buffers and images are not
- * automatically loaded. You'll need to read these files yourself using
- * URIs in the `cgltf_data` structure.
- *
- * `cgltf_options` is the struct passed to `cgltf_parse()` to control
- * parts of the parsing process. You can use it to force the file type
- * and provide memory allocation as well as file operation callbacks.
- * Should be zero-initialized to trigger default behavior.
- *
- * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`.
- * It generally mirrors the glTF format as described by the spec (see
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0).
- *
- * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data`
- * variable.
- *
- * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*,
- * const char* gltf_path)` can be optionally called to open and read buffer
- * files using the `FILE*` APIs. The `gltf_path` argument is the path to
- * the original glTF file, which allows the parser to resolve the path to
- * buffer files.
- *
- * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options,
- * cgltf_size size, const char* base64, void** out_data)` decodes
- * base64-encoded data content. Used internally by `cgltf_load_buffers()`.
- * This is useful when decoding data URIs in images.
- *
- * `cgltf_result cgltf_parse_file(const cgltf_options* options, const
- * char* path, cgltf_data** out_data)` can be used to open the given
- * file using `FILE*` APIs and parse the data using `cgltf_parse()`.
- *
- * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional
- * checks to make sure the parsed glTF data is valid.
- *
- * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node
- * into a mat4.
- *
- * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order
- * to compute the root-to-node transformation.
- *
- * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any),
- * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called.
- * By passing null for the output pointer, users can find out how many floats are required in the
- * output buffer.
- *
- * `cgltf_accessor_num_components` is a tiny utility that tells you the dimensionality of
- * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
- * the necessary amount of memory.
- *
- * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
- * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
- * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns
- * false if the passed-in element_size is too small, or if the accessor is sparse.
- *
- * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading
- * vector types and does not support matrix types. The passed-in element size is the number of uints
- * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in 
- * element_size is too small, or if the accessor is sparse.
- *
- * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
- * and only works with single-component data types.
- *
- * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*,
- * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that
- * can be attached to many glTF objects (which can be arbitrary JSON data). The
- * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data
- * as it appears in the complete glTF JSON data. This function copies the extras data
- * into the provided buffer. If `dest` is NULL, the length of the data is written into
- * `dest_size`. You can then parse this data using your own JSON parser
- * or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
- */
-#ifndef CGLTF_H_INCLUDED__
-#define CGLTF_H_INCLUDED__
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef size_t cgltf_size;
-typedef float cgltf_float;
-typedef int cgltf_int;
-typedef unsigned int cgltf_uint;
-typedef int cgltf_bool;
-
-typedef enum cgltf_file_type
-{
-       cgltf_file_type_invalid,
-       cgltf_file_type_gltf,
-       cgltf_file_type_glb,
-} cgltf_file_type;
-
-typedef enum cgltf_result
-{
-       cgltf_result_success,
-       cgltf_result_data_too_short,
-       cgltf_result_unknown_format,
-       cgltf_result_invalid_json,
-       cgltf_result_invalid_gltf,
-       cgltf_result_invalid_options,
-       cgltf_result_file_not_found,
-       cgltf_result_io_error,
-       cgltf_result_out_of_memory,
-       cgltf_result_legacy_gltf,
-} cgltf_result;
-
-typedef struct cgltf_memory_options
-{
-       void* (*alloc)(void* user, cgltf_size size);
-       void (*free) (void* user, void* ptr);
-       void* user_data;
-} cgltf_memory_options;
-
-typedef struct cgltf_file_options
-{
-       cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data);
-       void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data);
-       void* user_data;
-} cgltf_file_options;
-
-typedef struct cgltf_options
-{
-       cgltf_file_type type; /* invalid == auto detect */
-       cgltf_size json_token_count; /* 0 == auto */
-       cgltf_memory_options memory;
-       cgltf_file_options file;
-} cgltf_options;
-
-typedef enum cgltf_buffer_view_type
-{
-       cgltf_buffer_view_type_invalid,
-       cgltf_buffer_view_type_indices,
-       cgltf_buffer_view_type_vertices,
-} cgltf_buffer_view_type;
-
-typedef enum cgltf_attribute_type
-{
-       cgltf_attribute_type_invalid,
-       cgltf_attribute_type_position,
-       cgltf_attribute_type_normal,
-       cgltf_attribute_type_tangent,
-       cgltf_attribute_type_texcoord,
-       cgltf_attribute_type_color,
-       cgltf_attribute_type_joints,
-       cgltf_attribute_type_weights,
-} cgltf_attribute_type;
-
-typedef enum cgltf_component_type
-{
-       cgltf_component_type_invalid,
-       cgltf_component_type_r_8, /* BYTE */
-       cgltf_component_type_r_8u, /* UNSIGNED_BYTE */
-       cgltf_component_type_r_16, /* SHORT */
-       cgltf_component_type_r_16u, /* UNSIGNED_SHORT */
-       cgltf_component_type_r_32u, /* UNSIGNED_INT */
-       cgltf_component_type_r_32f, /* FLOAT */
-} cgltf_component_type;
-
-typedef enum cgltf_type
-{
-       cgltf_type_invalid,
-       cgltf_type_scalar,
-       cgltf_type_vec2,
-       cgltf_type_vec3,
-       cgltf_type_vec4,
-       cgltf_type_mat2,
-       cgltf_type_mat3,
-       cgltf_type_mat4,
-} cgltf_type;
-
-typedef enum cgltf_primitive_type
-{
-       cgltf_primitive_type_points,
-       cgltf_primitive_type_lines,
-       cgltf_primitive_type_line_loop,
-       cgltf_primitive_type_line_strip,
-       cgltf_primitive_type_triangles,
-       cgltf_primitive_type_triangle_strip,
-       cgltf_primitive_type_triangle_fan,
-} cgltf_primitive_type;
-
-typedef enum cgltf_alpha_mode
-{
-       cgltf_alpha_mode_opaque,
-       cgltf_alpha_mode_mask,
-       cgltf_alpha_mode_blend,
-} cgltf_alpha_mode;
-
-typedef enum cgltf_animation_path_type {
-       cgltf_animation_path_type_invalid,
-       cgltf_animation_path_type_translation,
-       cgltf_animation_path_type_rotation,
-       cgltf_animation_path_type_scale,
-       cgltf_animation_path_type_weights,
-} cgltf_animation_path_type;
-
-typedef enum cgltf_interpolation_type {
-       cgltf_interpolation_type_linear,
-       cgltf_interpolation_type_step,
-       cgltf_interpolation_type_cubic_spline,
-} cgltf_interpolation_type;
-
-typedef enum cgltf_camera_type {
-       cgltf_camera_type_invalid,
-       cgltf_camera_type_perspective,
-       cgltf_camera_type_orthographic,
-} cgltf_camera_type;
-
-typedef enum cgltf_light_type {
-       cgltf_light_type_invalid,
-       cgltf_light_type_directional,
-       cgltf_light_type_point,
-       cgltf_light_type_spot,
-} cgltf_light_type;
-
-typedef struct cgltf_extras {
-       cgltf_size start_offset;
-       cgltf_size end_offset;
-} cgltf_extras;
-
-typedef struct cgltf_extension {
-       char* name;
-       char* data;
-} cgltf_extension;
-
-typedef struct cgltf_buffer
-{
-       char* name;
-       cgltf_size size;
-       char* uri;
-       void* data; /* loaded by cgltf_load_buffers */
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_buffer;
-
-typedef enum cgltf_meshopt_compression_mode {
-       cgltf_meshopt_compression_mode_invalid,
-       cgltf_meshopt_compression_mode_attributes,
-       cgltf_meshopt_compression_mode_triangles,
-       cgltf_meshopt_compression_mode_indices,
-} cgltf_meshopt_compression_mode;
-
-typedef enum cgltf_meshopt_compression_filter {
-       cgltf_meshopt_compression_filter_none,
-       cgltf_meshopt_compression_filter_octahedral,
-       cgltf_meshopt_compression_filter_quaternion,
-       cgltf_meshopt_compression_filter_exponential,
-} cgltf_meshopt_compression_filter;
-
-typedef struct cgltf_meshopt_compression
-{
-       cgltf_buffer* buffer;
-       cgltf_size offset;
-       cgltf_size size;
-       cgltf_size stride;
-       cgltf_size count;
-       cgltf_meshopt_compression_mode mode;
-       cgltf_meshopt_compression_filter filter;
-} cgltf_meshopt_compression;
-
-typedef struct cgltf_buffer_view
-{
-       char *name;
-       cgltf_buffer* buffer;
-       cgltf_size offset;
-       cgltf_size size;
-       cgltf_size stride; /* 0 == automatically determined by accessor */
-       cgltf_buffer_view_type type;
-       void* data; /* overrides buffer->data if present, filled by extensions */
-       cgltf_bool has_meshopt_compression;
-       cgltf_meshopt_compression meshopt_compression;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_buffer_view;
-
-typedef struct cgltf_accessor_sparse
-{
-       cgltf_size count;
-       cgltf_buffer_view* indices_buffer_view;
-       cgltf_size indices_byte_offset;
-       cgltf_component_type indices_component_type;
-       cgltf_buffer_view* values_buffer_view;
-       cgltf_size values_byte_offset;
-       cgltf_extras extras;
-       cgltf_extras indices_extras;
-       cgltf_extras values_extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-       cgltf_size indices_extensions_count;
-       cgltf_extension* indices_extensions;
-       cgltf_size values_extensions_count;
-       cgltf_extension* values_extensions;
-} cgltf_accessor_sparse;
-
-typedef struct cgltf_accessor
-{
-       char* name;
-       cgltf_component_type component_type;
-       cgltf_bool normalized;
-       cgltf_type type;
-       cgltf_size offset;
-       cgltf_size count;
-       cgltf_size stride;
-       cgltf_buffer_view* buffer_view;
-       cgltf_bool has_min;
-       cgltf_float min[16];
-       cgltf_bool has_max;
-       cgltf_float max[16];
-       cgltf_bool is_sparse;
-       cgltf_accessor_sparse sparse;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_accessor;
-
-typedef struct cgltf_attribute
-{
-       char* name;
-       cgltf_attribute_type type;
-       cgltf_int index;
-       cgltf_accessor* data;
-} cgltf_attribute;
-
-typedef struct cgltf_image
-{
-       char* name;
-       char* uri;
-       cgltf_buffer_view* buffer_view;
-       char* mime_type;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_image;
-
-typedef struct cgltf_sampler
-{
-       char* name;
-       cgltf_int mag_filter;
-       cgltf_int min_filter;
-       cgltf_int wrap_s;
-       cgltf_int wrap_t;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_sampler;
-
-typedef struct cgltf_texture
-{
-       char* name;
-       cgltf_image* image;
-       cgltf_sampler* sampler;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_texture;
-
-typedef struct cgltf_texture_transform
-{
-       cgltf_float offset[2];
-       cgltf_float rotation;
-       cgltf_float scale[2];
-       cgltf_int texcoord;
-} cgltf_texture_transform;
-
-typedef struct cgltf_texture_view
-{
-       cgltf_texture* texture;
-       cgltf_int texcoord;
-       cgltf_float scale; /* equivalent to strength for occlusion_texture */
-       cgltf_bool has_transform;
-       cgltf_texture_transform transform;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_texture_view;
-
-typedef struct cgltf_pbr_metallic_roughness
-{
-       cgltf_texture_view base_color_texture;
-       cgltf_texture_view metallic_roughness_texture;
-
-       cgltf_float base_color_factor[4];
-       cgltf_float metallic_factor;
-       cgltf_float roughness_factor;
-
-       cgltf_extras extras;
-} cgltf_pbr_metallic_roughness;
-
-typedef struct cgltf_pbr_specular_glossiness
-{
-       cgltf_texture_view diffuse_texture;
-       cgltf_texture_view specular_glossiness_texture;
-
-       cgltf_float diffuse_factor[4];
-       cgltf_float specular_factor[3];
-       cgltf_float glossiness_factor;
-} cgltf_pbr_specular_glossiness;
-
-typedef struct cgltf_clearcoat
-{
-       cgltf_texture_view clearcoat_texture;
-       cgltf_texture_view clearcoat_roughness_texture;
-       cgltf_texture_view clearcoat_normal_texture;
-
-       cgltf_float clearcoat_factor;
-       cgltf_float clearcoat_roughness_factor;
-} cgltf_clearcoat;
-
-typedef struct cgltf_transmission
-{
-       cgltf_texture_view transmission_texture;
-       cgltf_float transmission_factor;
-} cgltf_transmission;
-
-typedef struct cgltf_ior
-{
-       cgltf_float ior;
-} cgltf_ior;
-
-typedef struct cgltf_specular
-{
-       cgltf_texture_view specular_texture;
-       cgltf_texture_view specular_color_texture;
-       cgltf_float specular_color_factor[3];
-       cgltf_float specular_factor;
-} cgltf_specular;
-
-typedef struct cgltf_volume
-{
-       cgltf_texture_view thickness_texture;
-       cgltf_float thickness_factor;
-       cgltf_float attenuation_color[3];
-       cgltf_float attenuation_distance;
-} cgltf_volume;
-
-typedef struct cgltf_sheen
-{
-       cgltf_texture_view sheen_color_texture;
-       cgltf_float sheen_color_factor[3];
-       cgltf_texture_view sheen_roughness_texture;
-       cgltf_float sheen_roughness_factor;
-} cgltf_sheen;
-
-typedef struct cgltf_material
-{
-       char* name;
-       cgltf_bool has_pbr_metallic_roughness;
-       cgltf_bool has_pbr_specular_glossiness;
-       cgltf_bool has_clearcoat;
-       cgltf_bool has_transmission;
-       cgltf_bool has_volume;
-       cgltf_bool has_ior;
-       cgltf_bool has_specular;
-       cgltf_bool has_sheen;
-       cgltf_pbr_metallic_roughness pbr_metallic_roughness;
-       cgltf_pbr_specular_glossiness pbr_specular_glossiness;
-       cgltf_clearcoat clearcoat;
-       cgltf_ior ior;
-       cgltf_specular specular;
-       cgltf_sheen sheen;
-       cgltf_transmission transmission;
-       cgltf_volume volume;
-       cgltf_texture_view normal_texture;
-       cgltf_texture_view occlusion_texture;
-       cgltf_texture_view emissive_texture;
-       cgltf_float emissive_factor[3];
-       cgltf_alpha_mode alpha_mode;
-       cgltf_float alpha_cutoff;
-       cgltf_bool double_sided;
-       cgltf_bool unlit;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_material;
-
-typedef struct cgltf_material_mapping
-{
-       cgltf_size variant;
-       cgltf_material* material;
-       cgltf_extras extras;
-} cgltf_material_mapping;
-
-typedef struct cgltf_morph_target {
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-} cgltf_morph_target;
-
-typedef struct cgltf_draco_mesh_compression {
-       cgltf_buffer_view* buffer_view;
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-} cgltf_draco_mesh_compression;
-
-typedef struct cgltf_primitive {
-       cgltf_primitive_type type;
-       cgltf_accessor* indices;
-       cgltf_material* material;
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-       cgltf_morph_target* targets;
-       cgltf_size targets_count;
-       cgltf_extras extras;
-       cgltf_bool has_draco_mesh_compression;
-       cgltf_draco_mesh_compression draco_mesh_compression;
-       cgltf_material_mapping* mappings;
-       cgltf_size mappings_count;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_primitive;
-
-typedef struct cgltf_mesh {
-       char* name;
-       cgltf_primitive* primitives;
-       cgltf_size primitives_count;
-       cgltf_float* weights;
-       cgltf_size weights_count;
-       char** target_names;
-       cgltf_size target_names_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_mesh;
-
-typedef struct cgltf_node cgltf_node;
-
-typedef struct cgltf_skin {
-       char* name;
-       cgltf_node** joints;
-       cgltf_size joints_count;
-       cgltf_node* skeleton;
-       cgltf_accessor* inverse_bind_matrices;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_skin;
-
-typedef struct cgltf_camera_perspective {
-       cgltf_bool has_aspect_ratio;
-       cgltf_float aspect_ratio;
-       cgltf_float yfov;
-       cgltf_bool has_zfar;
-       cgltf_float zfar;
-       cgltf_float znear;
-       cgltf_extras extras;
-} cgltf_camera_perspective;
-
-typedef struct cgltf_camera_orthographic {
-       cgltf_float xmag;
-       cgltf_float ymag;
-       cgltf_float zfar;
-       cgltf_float znear;
-       cgltf_extras extras;
-} cgltf_camera_orthographic;
-
-typedef struct cgltf_camera {
-       char* name;
-       cgltf_camera_type type;
-       union {
-               cgltf_camera_perspective perspective;
-               cgltf_camera_orthographic orthographic;
-       } data;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_camera;
-
-typedef struct cgltf_light {
-       char* name;
-       cgltf_float color[3];
-       cgltf_float intensity;
-       cgltf_light_type type;
-       cgltf_float range;
-       cgltf_float spot_inner_cone_angle;
-       cgltf_float spot_outer_cone_angle;
-} cgltf_light;
-
-struct cgltf_node {
-       char* name;
-       cgltf_node* parent;
-       cgltf_node** children;
-       cgltf_size children_count;
-       cgltf_skin* skin;
-       cgltf_mesh* mesh;
-       cgltf_camera* camera;
-       cgltf_light* light;
-       cgltf_float* weights;
-       cgltf_size weights_count;
-       cgltf_bool has_translation;
-       cgltf_bool has_rotation;
-       cgltf_bool has_scale;
-       cgltf_bool has_matrix;
-       cgltf_float translation[3];
-       cgltf_float rotation[4];
-       cgltf_float scale[3];
-       cgltf_float matrix[16];
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-};
-
-typedef struct cgltf_scene {
-       char* name;
-       cgltf_node** nodes;
-       cgltf_size nodes_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_scene;
-
-typedef struct cgltf_animation_sampler {
-       cgltf_accessor* input;
-       cgltf_accessor* output;
-       cgltf_interpolation_type interpolation;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation_sampler;
-
-typedef struct cgltf_animation_channel {
-       cgltf_animation_sampler* sampler;
-       cgltf_node* target_node;
-       cgltf_animation_path_type target_path;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation_channel;
-
-typedef struct cgltf_animation {
-       char* name;
-       cgltf_animation_sampler* samplers;
-       cgltf_size samplers_count;
-       cgltf_animation_channel* channels;
-       cgltf_size channels_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation;
-
-typedef struct cgltf_material_variant
-{
-       char* name;
-       cgltf_extras extras;
-} cgltf_material_variant;
-
-typedef struct cgltf_asset {
-       char* copyright;
-       char* generator;
-       char* version;
-       char* min_version;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_asset;
-
-typedef struct cgltf_data
-{
-       cgltf_file_type file_type;
-       void* file_data;
-
-       cgltf_asset asset;
-
-       cgltf_mesh* meshes;
-       cgltf_size meshes_count;
-
-       cgltf_material* materials;
-       cgltf_size materials_count;
-
-       cgltf_accessor* accessors;
-       cgltf_size accessors_count;
-
-       cgltf_buffer_view* buffer_views;
-       cgltf_size buffer_views_count;
-
-       cgltf_buffer* buffers;
-       cgltf_size buffers_count;
-
-       cgltf_image* images;
-       cgltf_size images_count;
-
-       cgltf_texture* textures;
-       cgltf_size textures_count;
-
-       cgltf_sampler* samplers;
-       cgltf_size samplers_count;
-
-       cgltf_skin* skins;
-       cgltf_size skins_count;
-
-       cgltf_camera* cameras;
-       cgltf_size cameras_count;
-
-       cgltf_light* lights;
-       cgltf_size lights_count;
-
-       cgltf_node* nodes;
-       cgltf_size nodes_count;
-
-       cgltf_scene* scenes;
-       cgltf_size scenes_count;
-
-       cgltf_scene* scene;
-
-       cgltf_animation* animations;
-       cgltf_size animations_count;
-
-       cgltf_material_variant* variants;
-       cgltf_size variants_count;
-
-       cgltf_extras extras;
-
-       cgltf_size data_extensions_count;
-       cgltf_extension* data_extensions;
-
-       char** extensions_used;
-       cgltf_size extensions_used_count;
-
-       char** extensions_required;
-       cgltf_size extensions_required_count;
-
-       const char* json;
-       cgltf_size json_size;
-
-       const void* bin;
-       cgltf_size bin_size;
-
-       cgltf_memory_options memory;
-       cgltf_file_options file;
-} cgltf_data;
-
-cgltf_result cgltf_parse(
-               const cgltf_options* options,
-               const void* data,
-               cgltf_size size,
-               cgltf_data** out_data);
-
-cgltf_result cgltf_parse_file(
-               const cgltf_options* options,
-               const char* path,
-               cgltf_data** out_data);
-
-cgltf_result cgltf_load_buffers(
-               const cgltf_options* options,
-               cgltf_data* data,
-               const char* gltf_path);
-
-cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data);
-
-void cgltf_decode_uri(char* uri);
-
-cgltf_result cgltf_validate(cgltf_data* data);
-
-void cgltf_free(cgltf_data* data);
-
-void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
-void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix);
-
-cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
-cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
-cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
-
-cgltf_size cgltf_num_components(cgltf_type type);
-
-cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
-
-cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* #ifndef CGLTF_H_INCLUDED__ */
-
-/*
- *
- * Stop now, if you are only interested in the API.
- * Below, you find the implementation.
- *
- */
-
-#if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__)
-/* This makes MSVC/CLion intellisense work. */
-#define CGLTF_IMPLEMENTATION
-#endif
-
-#ifdef CGLTF_IMPLEMENTATION
-
-#include <stdint.h> /* For uint8_t, uint32_t */
-#include <string.h> /* For strncpy */
-#include <stdio.h>  /* For fopen */
-#include <limits.h> /* For UINT_MAX etc */
-#include <float.h>  /* For FLT_MAX */
-
-#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF)
-#include <stdlib.h> /* For malloc, free, atoi, atof */
-#endif
-
-/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */
-#define JSMN_PARENT_LINKS
-
-/* JSMN_STRICT is necessary to reject invalid JSON documents */
-#define JSMN_STRICT
-
-/*
- * -- jsmn.h start --
- * Source: https://github.com/zserge/jsmn
- * License: MIT
- */
-typedef enum {
-       JSMN_UNDEFINED = 0,
-       JSMN_OBJECT = 1,
-       JSMN_ARRAY = 2,
-       JSMN_STRING = 3,
-       JSMN_PRIMITIVE = 4
-} jsmntype_t;
-enum jsmnerr {
-       /* Not enough tokens were provided */
-       JSMN_ERROR_NOMEM = -1,
-       /* Invalid character inside JSON string */
-       JSMN_ERROR_INVAL = -2,
-       /* The string is not a full JSON packet, more bytes expected */
-       JSMN_ERROR_PART = -3
-};
-typedef struct {
-       jsmntype_t type;
-       int start;
-       int end;
-       int size;
-#ifdef JSMN_PARENT_LINKS
-       int parent;
-#endif
-} jsmntok_t;
-typedef struct {
-       unsigned int pos; /* offset in the JSON string */
-       unsigned int toknext; /* next token to allocate */
-       int toksuper; /* superior token node, e.g parent object or array */
-} jsmn_parser;
-static void jsmn_init(jsmn_parser *parser);
-static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens);
-/*
- * -- jsmn.h end --
- */
-
-
-static const cgltf_size GlbHeaderSize = 12;
-static const cgltf_size GlbChunkHeaderSize = 8;
-static const uint32_t GlbVersion = 2;
-static const uint32_t GlbMagic = 0x46546C67;
-static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
-static const uint32_t GlbMagicBinChunk = 0x004E4942;
-
-#ifndef CGLTF_MALLOC
-#define CGLTF_MALLOC(size) malloc(size)
-#endif
-#ifndef CGLTF_FREE
-#define CGLTF_FREE(ptr) free(ptr)
-#endif
-#ifndef CGLTF_ATOI
-#define CGLTF_ATOI(str) atoi(str)
-#endif
-#ifndef CGLTF_ATOF
-#define CGLTF_ATOF(str) atof(str)
-#endif
-#ifndef CGLTF_VALIDATE_ENABLE_ASSERTS
-#define CGLTF_VALIDATE_ENABLE_ASSERTS 0
-#endif
-
-static void* cgltf_default_alloc(void* user, cgltf_size size)
-{
-       (void)user;
-       return CGLTF_MALLOC(size);
-}
-
-static void cgltf_default_free(void* user, void* ptr)
-{
-       (void)user;
-       CGLTF_FREE(ptr);
-}
-
-static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count)
-{
-       if (SIZE_MAX / element_size < count)
-       {
-               return NULL;
-       }
-       void* result = options->memory.alloc(options->memory.user_data, element_size * count);
-       if (!result)
-       {
-               return NULL;
-       }
-       memset(result, 0, element_size * count);
-       return result;
-}
-
-static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data)
-{
-       (void)file_options;
-       void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc ? memory_options->alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free;
-
-       FILE* file = fopen(path, "rb");
-       if (!file)
-       {
-               return cgltf_result_file_not_found;
-       }
-
-       cgltf_size file_size = size ? *size : 0;
-
-       if (file_size == 0)
-       {
-               fseek(file, 0, SEEK_END);
-
-               long length = ftell(file);
-               if (length < 0)
-               {
-                       fclose(file);
-                       return cgltf_result_io_error;
-               }
-
-               fseek(file, 0, SEEK_SET);
-               file_size = (cgltf_size)length;
-       }
-
-       char* file_data = (char*)memory_alloc(memory_options->user_data, file_size);
-       if (!file_data)
-       {
-               fclose(file);
-               return cgltf_result_out_of_memory;
-       }
-       
-       cgltf_size read_size = fread(file_data, 1, file_size, file);
-
-       fclose(file);
-
-       if (read_size != file_size)
-       {
-               memory_free(memory_options->user_data, file_data);
-               return cgltf_result_io_error;
-       }
-
-       if (size)
-       {
-               *size = file_size;
-       }
-       if (data)
-       {
-               *data = file_data;
-       }
-
-       return cgltf_result_success;
-}
-
-static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data)
-{
-       (void)file_options;
-       void (*memfree)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free;
-       memfree(memory_options->user_data, data);
-}
-
-static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data);
-
-cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data)
-{
-       if (size < GlbHeaderSize)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       cgltf_options fixed_options = *options;
-       if (fixed_options.memory.alloc == NULL)
-       {
-               fixed_options.memory.alloc = &cgltf_default_alloc;
-       }
-       if (fixed_options.memory.free == NULL)
-       {
-               fixed_options.memory.free = &cgltf_default_free;
-       }
-
-       uint32_t tmp;
-       // Magic
-       memcpy(&tmp, data, 4);
-       if (tmp != GlbMagic)
-       {
-               if (fixed_options.type == cgltf_file_type_invalid)
-               {
-                       fixed_options.type = cgltf_file_type_gltf;
-               }
-               else if (fixed_options.type == cgltf_file_type_glb)
-               {
-                       return cgltf_result_unknown_format;
-               }
-       }
-
-       if (fixed_options.type == cgltf_file_type_gltf)
-       {
-               cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data);
-               if (json_result != cgltf_result_success)
-               {
-                       return json_result;
-               }
-
-               (*out_data)->file_type = cgltf_file_type_gltf;
-
-               return cgltf_result_success;
-       }
-
-       const uint8_t* ptr = (const uint8_t*)data;
-       // Version
-       memcpy(&tmp, ptr + 4, 4);
-       uint32_t version = tmp;
-       if (version != GlbVersion)
-       {
-               return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format;
-       }
-
-       // Total length
-       memcpy(&tmp, ptr + 8, 4);
-       if (tmp > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       const uint8_t* json_chunk = ptr + GlbHeaderSize;
-
-       if (GlbHeaderSize + GlbChunkHeaderSize > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       // JSON chunk: length
-       uint32_t json_length;
-       memcpy(&json_length, json_chunk, 4);
-       if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       // JSON chunk: magic
-       memcpy(&tmp, json_chunk + 4, 4);
-       if (tmp != GlbMagicJsonChunk)
-       {
-               return cgltf_result_unknown_format;
-       }
-
-       json_chunk += GlbChunkHeaderSize;
-
-       const void* bin = 0;
-       cgltf_size bin_size = 0;
-
-       if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size)
-       {
-               // We can read another chunk
-               const uint8_t* bin_chunk = json_chunk + json_length;
-
-               // Bin chunk: length
-               uint32_t bin_length;
-               memcpy(&bin_length, bin_chunk, 4);
-               if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size)
-               {
-                       return cgltf_result_data_too_short;
-               }
-
-               // Bin chunk: magic
-               memcpy(&tmp, bin_chunk + 4, 4);
-               if (tmp != GlbMagicBinChunk)
-               {
-                       return cgltf_result_unknown_format;
-               }
-
-               bin_chunk += GlbChunkHeaderSize;
-
-               bin = bin_chunk;
-               bin_size = bin_length;
-       }
-
-       cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data);
-       if (json_result != cgltf_result_success)
-       {
-               return json_result;
-       }
-
-       (*out_data)->file_type = cgltf_file_type_glb;
-       (*out_data)->bin = bin;
-       (*out_data)->bin_size = bin_size;
-
-       return cgltf_result_success;
-}
-
-cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data)
-{
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-       cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
-
-       void* file_data = NULL;
-       cgltf_size file_size = 0;
-       cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data);
-       if (result != cgltf_result_success)
-       {
-               return result;
-       }
-
-       result = cgltf_parse(options, file_data, file_size, out_data);
-
-       if (result != cgltf_result_success)
-       {
-               memory_free(options->memory.user_data, file_data);
-               return result;
-       }
-
-       (*out_data)->file_data = file_data;
-
-       return cgltf_result_success;
-}
-
-static void cgltf_combine_paths(char* path, const char* base, const char* uri)
-{
-       const char* s0 = strrchr(base, '/');
-       const char* s1 = strrchr(base, '\\');
-       const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1;
-
-       if (slash)
-       {
-               size_t prefix = slash - base + 1;
-
-               strncpy(path, base, prefix);
-               strcpy(path + prefix, uri);
-       }
-       else
-       {
-               strcpy(path, uri);
-       }
-}
-
-static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data)
-{
-       void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-       cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
-
-       char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1);
-       if (!path)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       cgltf_combine_paths(path, gltf_path, uri);
-
-       // after combining, the tail of the resulting path is a uri; decode_uri converts it into path
-       cgltf_decode_uri(path + strlen(path) - strlen(uri));
-
-       void* file_data = NULL;
-       cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data);
-
-       memory_free(options->memory.user_data, path);
-
-       *out_data = (result == cgltf_result_success) ? file_data : NULL;
-
-       return result;
-}
-
-cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data)
-{
-       void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-
-       unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size);
-       if (!data)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       unsigned int buffer = 0;
-       unsigned int buffer_bits = 0;
-
-       for (cgltf_size i = 0; i < size; ++i)
-       {
-               while (buffer_bits < 8)
-               {
-                       char ch = *base64++;
-
-                       int index =
-                               (unsigned)(ch - 'A') < 26 ? (ch - 'A') :
-                               (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 :
-                               (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 :
-                               ch == '+' ? 62 :
-                               ch == '/' ? 63 :
-                               -1;
-
-                       if (index < 0)
-                       {
-                               memory_free(options->memory.user_data, data);
-                               return cgltf_result_io_error;
-                       }
-
-                       buffer = (buffer << 6) | index;
-                       buffer_bits += 6;
-               }
-
-               data[i] = (unsigned char)(buffer >> (buffer_bits - 8));
-               buffer_bits -= 8;
-       }
-
-       *out_data = data;
-
-       return cgltf_result_success;
-}
-
-static int cgltf_unhex(char ch)
-{
-       return
-               (unsigned)(ch - '0') < 10 ? (ch - '0') :
-               (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 :
-               (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 :
-               -1;
-}
-
-void cgltf_decode_uri(char* uri)
-{
-       char* write = uri;
-       char* i = uri;
-
-       while (*i)
-       {
-               if (*i == '%')
-               {
-                       int ch1 = cgltf_unhex(i[1]);
-
-                       if (ch1 >= 0)
-                       {
-                               int ch2 = cgltf_unhex(i[2]);
-
-                               if (ch2 >= 0)
-                               {
-                                       *write++ = (char)(ch1 * 16 + ch2);
-                                       i += 3;
-                                       continue;
-                               }
-                       }
-               }
-
-               *write++ = *i++;
-       }
-
-       *write = 0;
-}
-
-cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path)
-{
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin)
-       {
-               if (data->bin_size < data->buffers[0].size)
-               {
-                       return cgltf_result_data_too_short;
-               }
-
-               data->buffers[0].data = (void*)data->bin;
-       }
-
-       for (cgltf_size i = 0; i < data->buffers_count; ++i)
-       {
-               if (data->buffers[i].data)
-               {
-                       continue;
-               }
-
-               const char* uri = data->buffers[i].uri;
-
-               if (uri == NULL)
-               {
-                       continue;
-               }
-
-               if (strncmp(uri, "data:", 5) == 0)
-               {
-                       const char* comma = strchr(uri, ',');
-
-                       if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0)
-                       {
-                               cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data);
-
-                               if (res != cgltf_result_success)
-                               {
-                                       return res;
-                               }
-                       }
-                       else
-                       {
-                               return cgltf_result_unknown_format;
-                       }
-               }
-               else if (strstr(uri, "://") == NULL && gltf_path)
-               {
-                       cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data);
-
-                       if (res != cgltf_result_success)
-                       {
-                               return res;
-                       }
-               }
-               else
-               {
-                       return cgltf_result_unknown_format;
-               }
-       }
-
-       return cgltf_result_success;
-}
-
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
-
-static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
-{
-       char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
-       cgltf_size bound = 0;
-
-       switch (component_type)
-       {
-       case cgltf_component_type_r_8u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned char*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       case cgltf_component_type_r_16u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned short*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       case cgltf_component_type_r_32u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned int*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       default:
-               ;
-       }
-
-       return bound;
-}
-
-#if CGLTF_VALIDATE_ENABLE_ASSERTS
-#define CGLTF_ASSERT_IF(cond, result) assert(!(cond)); if (cond) return result;
-#else
-#define CGLTF_ASSERT_IF(cond, result) if (cond) return result;
-#endif
-
-cgltf_result cgltf_validate(cgltf_data* data)
-{
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               cgltf_accessor* accessor = &data->accessors[i];
-
-               cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type);
-
-               if (accessor->buffer_view)
-               {
-                       cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size;
-
-                       CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, cgltf_result_data_too_short);
-               }
-
-               if (accessor->is_sparse)
-               {
-                       cgltf_accessor_sparse* sparse = &accessor->sparse;
-
-                       cgltf_size indices_component_size = cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type);
-                       cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count;
-                       cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count;
-
-                       CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size ||
-                                                       sparse->values_buffer_view->size < values_req_size, cgltf_result_data_too_short);
-
-                       CGLTF_ASSERT_IF(sparse->indices_component_type != cgltf_component_type_r_8u &&
-                                                       sparse->indices_component_type != cgltf_component_type_r_16u &&
-                                                       sparse->indices_component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
-
-                       if (sparse->indices_buffer_view->buffer->data)
-                       {
-                               cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count);
-
-                               CGLTF_ASSERT_IF(index_bound >= accessor->count, cgltf_result_data_too_short);
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size;
-
-               CGLTF_ASSERT_IF(data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size, cgltf_result_data_too_short);
-
-               if (data->buffer_views[i].has_meshopt_compression)
-               {
-                       cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression;
-
-                       CGLTF_ASSERT_IF(mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size, cgltf_result_data_too_short);
-
-                       CGLTF_ASSERT_IF(data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256), cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               if (data->meshes[i].weights)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count, cgltf_result_invalid_gltf);
-               }
-
-               if (data->meshes[i].target_names)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count, cgltf_result_invalid_gltf);
-               }
-
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count, cgltf_result_invalid_gltf);
-
-                       if (data->meshes[i].primitives[j].attributes_count)
-                       {
-                               cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data;
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                               {
-                                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
-                               }
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                               {
-                                       for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                                       {
-                                               CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count, cgltf_result_invalid_gltf);
-                                       }
-                               }
-
-                               cgltf_accessor* indices = data->meshes[i].primitives[j].indices;
-
-                               CGLTF_ASSERT_IF(indices &&
-                                       indices->component_type != cgltf_component_type_r_8u &&
-                                       indices->component_type != cgltf_component_type_r_16u &&
-                                       indices->component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
-
-                               if (indices && indices->buffer_view && indices->buffer_view->buffer->data)
-                               {
-                                       cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count);
-
-                                       CGLTF_ASSERT_IF(index_bound >= first->count, cgltf_result_data_too_short);
-                               }
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
-                               {
-                                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= data->variants_count, cgltf_result_invalid_gltf);
-                               }
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               if (data->nodes[i].weights && data->nodes[i].mesh)
-               {
-                       CGLTF_ASSERT_IF (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               cgltf_node* p1 = data->nodes[i].parent;
-               cgltf_node* p2 = p1 ? p1->parent : NULL;
-
-               while (p1 && p2)
-               {
-                       CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf);
-
-                       p1 = p1->parent;
-                       p2 = p2->parent ? p2->parent->parent : NULL;
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
-               {
-                       CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
-               {
-                       cgltf_animation_channel* channel = &data->animations[i].channels[j];
-
-                       if (!channel->target_node)
-                       {
-                               continue;
-                       }
-
-                       cgltf_size components = 1;
-
-                       if (channel->target_path == cgltf_animation_path_type_weights)
-                       {
-                               CGLTF_ASSERT_IF(!channel->target_node->mesh || !channel->target_node->mesh->primitives_count, cgltf_result_invalid_gltf);
-
-                               components = channel->target_node->mesh->primitives[0].targets_count;
-                       }
-
-                       cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1;
-
-                       CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != channel->sampler->output->count, cgltf_result_data_too_short);
-               }
-       }
-
-       return cgltf_result_success;
-}
-
-cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size)
-{
-       cgltf_size json_size = extras->end_offset - extras->start_offset;
-
-       if (!dest)
-       {
-               if (dest_size)
-               {
-                       *dest_size = json_size + 1;
-                       return cgltf_result_success;
-               }
-               return cgltf_result_invalid_options;
-       }
-
-       if (*dest_size + 1 < json_size)
-       {
-               strncpy(dest, data->json + extras->start_offset, *dest_size - 1);
-               dest[*dest_size - 1] = 0;
-       }
-       else
-       {
-               strncpy(dest, data->json + extras->start_offset, json_size);
-               dest[json_size] = 0;
-       }
-
-       return cgltf_result_success;
-}
-
-void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
-{
-       for (cgltf_size i = 0; i < extensions_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, extensions[i].name);
-               data->memory.free(data->memory.user_data, extensions[i].data);
-       }
-       data->memory.free(data->memory.user_data, extensions);
-}
-
-void cgltf_free(cgltf_data* data)
-{
-       if (!data)
-       {
-               return;
-       }
-
-       void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release;
-
-       data->memory.free(data->memory.user_data, data->asset.copyright);
-       data->memory.free(data->memory.user_data, data->asset.generator);
-       data->memory.free(data->memory.user_data, data->asset.version);
-       data->memory.free(data->memory.user_data, data->asset.min_version);
-
-       cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
-
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->accessors[i].name);
-
-               if(data->accessors[i].is_sparse)
-               {
-                       cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count);
-                       cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count);
-                       cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count);
-               }
-               cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
-       }
-       data->memory.free(data->memory.user_data, data->accessors);
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->buffer_views[i].name);
-               data->memory.free(data->memory.user_data, data->buffer_views[i].data);
-
-               cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
-       }
-       data->memory.free(data->memory.user_data, data->buffer_views);
-
-       for (cgltf_size i = 0; i < data->buffers_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->buffers[i].name);
-
-               if (data->buffers[i].data != data->bin)
-               {
-                       file_release(&data->memory, &data->file, data->buffers[i].data);
-               }
-               data->memory.free(data->memory.user_data, data->buffers[i].uri);
-
-               cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->buffers);
-
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->meshes[i].name);
-
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                       {
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes);
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                       {
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                               {
-                                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name);
-                               }
-
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets);
-
-                       if (data->meshes[i].primitives[j].has_draco_mesh_compression)
-                       {
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k)
-                               {
-                                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name);
-                               }
-
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].mappings);
-
-                       cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
-               }
-
-               data->memory.free(data->memory.user_data, data->meshes[i].primitives);
-               data->memory.free(data->memory.user_data, data->meshes[i].weights);
-
-               for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j)
-               {
-                       data->memory.free(data->memory.user_data, data->meshes[i].target_names[j]);
-               }
-
-               cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
-
-               data->memory.free(data->memory.user_data, data->meshes[i].target_names);
-       }
-
-       data->memory.free(data->memory.user_data, data->meshes);
-
-       for (cgltf_size i = 0; i < data->materials_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->materials[i].name);
-
-               if(data->materials[i].has_pbr_metallic_roughness)
-               {
-                       cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count);
-               }
-               if(data->materials[i].has_pbr_specular_glossiness)
-               {
-                       cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count);
-               }
-               if(data->materials[i].has_clearcoat)
-               {
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count);
-               }
-               if(data->materials[i].has_specular)
-               {
-                       cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].specular.specular_color_texture.extensions, data->materials[i].specular.specular_color_texture.extensions_count);
-               }
-               if(data->materials[i].has_transmission)
-               {
-                       cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count);
-               }
-               if (data->materials[i].has_volume)
-               {
-                       cgltf_free_extensions(data, data->materials[i].volume.thickness_texture.extensions, data->materials[i].volume.thickness_texture.extensions_count);
-               }
-               if(data->materials[i].has_sheen)
-               {
-                       cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count);
-               }
-
-               cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count);
-               cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count);
-               cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count);
-
-               cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->materials);
-
-       for (cgltf_size i = 0; i < data->images_count; ++i) 
-       {
-               data->memory.free(data->memory.user_data, data->images[i].name);
-               data->memory.free(data->memory.user_data, data->images[i].uri);
-               data->memory.free(data->memory.user_data, data->images[i].mime_type);
-
-               cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->images);
-
-       for (cgltf_size i = 0; i < data->textures_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->textures[i].name);
-               cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->textures);
-
-       for (cgltf_size i = 0; i < data->samplers_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->samplers[i].name);
-               cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->samplers);
-
-       for (cgltf_size i = 0; i < data->skins_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->skins[i].name);
-               data->memory.free(data->memory.user_data, data->skins[i].joints);
-
-               cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->skins);
-
-       for (cgltf_size i = 0; i < data->cameras_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->cameras[i].name);
-               cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->cameras);
-
-       for (cgltf_size i = 0; i < data->lights_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->lights[i].name);
-       }
-
-       data->memory.free(data->memory.user_data, data->lights);
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->nodes[i].name);
-               data->memory.free(data->memory.user_data, data->nodes[i].children);
-               data->memory.free(data->memory.user_data, data->nodes[i].weights);
-               cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->nodes);
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->scenes[i].name);
-               data->memory.free(data->memory.user_data, data->scenes[i].nodes);
-
-               cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->scenes);
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->animations[i].name);
-               for (cgltf_size j = 0; j <  data->animations[i].samplers_count; ++j)
-               {
-                       cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
-               }
-               data->memory.free(data->memory.user_data, data->animations[i].samplers);
-
-               for (cgltf_size j = 0; j <  data->animations[i].channels_count; ++j)
-               {
-                       cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
-               }
-               data->memory.free(data->memory.user_data, data->animations[i].channels);
-
-               cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->animations);
-
-       for (cgltf_size i = 0; i < data->variants_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->variants[i].name);
-       }
-
-       data->memory.free(data->memory.user_data, data->variants);
-
-       cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
-
-       for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->extensions_used[i]);
-       }
-
-       data->memory.free(data->memory.user_data, data->extensions_used);
-
-       for (cgltf_size i = 0; i < data->extensions_required_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->extensions_required[i]);
-       }
-
-       data->memory.free(data->memory.user_data, data->extensions_required);
-
-       file_release(&data->memory, &data->file, data->file_data);
-
-       data->memory.free(data->memory.user_data, data);
-}
-
-void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix)
-{
-       cgltf_float* lm = out_matrix;
-
-       if (node->has_matrix)
-       {
-               memcpy(lm, node->matrix, sizeof(float) * 16);
-       }
-       else
-       {
-               float tx = node->translation[0];
-               float ty = node->translation[1];
-               float tz = node->translation[2];
-
-               float qx = node->rotation[0];
-               float qy = node->rotation[1];
-               float qz = node->rotation[2];
-               float qw = node->rotation[3];
-
-               float sx = node->scale[0];
-               float sy = node->scale[1];
-               float sz = node->scale[2];
-
-               lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx;
-               lm[1] = (2 * qx*qy + 2 * qz*qw) * sx;
-               lm[2] = (2 * qx*qz - 2 * qy*qw) * sx;
-               lm[3] = 0.f;
-
-               lm[4] = (2 * qx*qy - 2 * qz*qw) * sy;
-               lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy;
-               lm[6] = (2 * qy*qz + 2 * qx*qw) * sy;
-               lm[7] = 0.f;
-
-               lm[8] = (2 * qx*qz + 2 * qy*qw) * sz;
-               lm[9] = (2 * qy*qz - 2 * qx*qw) * sz;
-               lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz;
-               lm[11] = 0.f;
-
-               lm[12] = tx;
-               lm[13] = ty;
-               lm[14] = tz;
-               lm[15] = 1.f;
-       }
-}
-
-void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
-{
-       cgltf_float* lm = out_matrix;
-       cgltf_node_transform_local(node, lm);
-
-       const cgltf_node* parent = node->parent;
-
-       while (parent)
-       {
-               float pm[16];
-               cgltf_node_transform_local(parent, pm);
-
-               for (int i = 0; i < 4; ++i)
-               {
-                       float l0 = lm[i * 4 + 0];
-                       float l1 = lm[i * 4 + 1];
-                       float l2 = lm[i * 4 + 2];
-
-                       float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8];
-                       float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9];
-                       float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10];
-
-                       lm[i * 4 + 0] = r0;
-                       lm[i * 4 + 1] = r1;
-                       lm[i * 4 + 2] = r2;
-               }
-
-               lm[12] += pm[12];
-               lm[13] += pm[13];
-               lm[14] += pm[14];
-
-               parent = parent->parent;
-       }
-}
-
-static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type)
-{
-       switch (component_type)
-       {
-               case cgltf_component_type_r_16:
-                       return *((const int16_t*) in);
-               case cgltf_component_type_r_16u:
-                       return *((const uint16_t*) in);
-               case cgltf_component_type_r_32u:
-                       return *((const uint32_t*) in);
-               case cgltf_component_type_r_32f:
-                       return (cgltf_size)*((const float*) in);
-               case cgltf_component_type_r_8:
-                       return *((const int8_t*) in);
-               case cgltf_component_type_r_8u:
-                       return *((const uint8_t*) in);
-               default:
-                       return 0;
-       }
-}
-
-static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized)
-{
-       if (component_type == cgltf_component_type_r_32f)
-       {
-               return *((const float*) in);
-       }
-
-       if (normalized)
-       {
-               switch (component_type)
-               {
-                       // note: glTF spec doesn't currently define normalized conversions for 32-bit integers
-                       case cgltf_component_type_r_16:
-                               return *((const int16_t*) in) / (cgltf_float)32767;
-                       case cgltf_component_type_r_16u:
-                               return *((const uint16_t*) in) / (cgltf_float)65535;
-                       case cgltf_component_type_r_8:
-                               return *((const int8_t*) in) / (cgltf_float)127;
-                       case cgltf_component_type_r_8u:
-                               return *((const uint8_t*) in) / (cgltf_float)255;
-                       default:
-                               return 0;
-               }
-       }
-
-       return (cgltf_float)cgltf_component_read_index(in, component_type);
-}
-
-static cgltf_size cgltf_component_size(cgltf_component_type component_type);
-
-static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
-{
-       cgltf_size num_components = cgltf_num_components(type);
-
-       if (element_size < num_components) {
-               return 0;
-       }
-
-       // There are three special cases for component extraction, see #data-alignment in the 2.0 spec.
-
-       cgltf_size component_size = cgltf_component_size(component_type);
-
-       if (type == cgltf_type_mat2 && component_size == 1)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 5, component_type, normalized);
-               return 1;
-       }
-
-       if (type == cgltf_type_mat3 && component_size == 1)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 2, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[4] = cgltf_component_read_float(element + 5, component_type, normalized);
-               out[5] = cgltf_component_read_float(element + 6, component_type, normalized);
-               out[6] = cgltf_component_read_float(element + 8, component_type, normalized);
-               out[7] = cgltf_component_read_float(element + 9, component_type, normalized);
-               out[8] = cgltf_component_read_float(element + 10, component_type, normalized);
-               return 1;
-       }
-
-       if (type == cgltf_type_mat3 && component_size == 2)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 2, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 8, component_type, normalized);
-               out[4] = cgltf_component_read_float(element + 10, component_type, normalized);
-               out[5] = cgltf_component_read_float(element + 12, component_type, normalized);
-               out[6] = cgltf_component_read_float(element + 16, component_type, normalized);
-               out[7] = cgltf_component_read_float(element + 18, component_type, normalized);
-               out[8] = cgltf_component_read_float(element + 20, component_type, normalized);
-               return 1;
-       }
-
-       for (cgltf_size i = 0; i < num_components; ++i)
-       {
-               out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized);
-       }
-       return 1;
-}
-
-const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
-{
-       if (view->data)
-               return (const uint8_t*)view->data;
-
-       if (!view->buffer->data)
-               return NULL;
-
-       const uint8_t* result = (const uint8_t*)view->buffer->data;
-       result += view->offset;
-       return result;
-}
-
-cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
-{
-       if (accessor->is_sparse)
-       {
-               return 0;
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               memset(out, 0, element_size * sizeof(cgltf_float));
-               return 1;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0;
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size);
-}
-
-cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count)
-{
-       cgltf_size floats_per_element = cgltf_num_components(accessor->type);
-       cgltf_size available_floats = accessor->count * floats_per_element;
-       if (out == NULL)
-       {
-               return available_floats;
-       }
-
-       float_count = available_floats < float_count ? available_floats : float_count;
-       cgltf_size element_count = float_count / floats_per_element;
-
-       // First pass: convert each element in the base accessor.
-       cgltf_float* dest = out;
-       cgltf_accessor dense = *accessor;
-       dense.is_sparse = 0;
-       for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element)
-       {
-               if (!cgltf_accessor_read_float(&dense, index, dest, floats_per_element))
-               {
-                       return 0;
-               }
-       }
-
-       // Second pass: write out each element in the sparse accessor.
-       if (accessor->is_sparse)
-       {
-               const cgltf_accessor_sparse* sparse = &dense.sparse;
-
-               const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view);
-               const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view);
-
-               if (index_data == NULL || reader_head == NULL)
-               {
-                       return 0;
-               }
-
-               index_data += sparse->indices_byte_offset;
-               reader_head += sparse->values_byte_offset;
-
-               cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type);
-               for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride)
-               {
-                       size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type);
-                       float* writer_head = out + writer_index * floats_per_element;
-
-                       if (!cgltf_element_read_float(reader_head, dense.type, dense.component_type, dense.normalized, writer_head, floats_per_element))
-                       {
-                               return 0;
-                       }
-
-                       reader_head += dense.stride;
-               }
-       }
-
-       return element_count * floats_per_element;
-}
-
-static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type)
-{
-       switch (component_type)
-       {
-               case cgltf_component_type_r_8:
-                       return *((const int8_t*) in);
-
-               case cgltf_component_type_r_8u:
-                       return *((const uint8_t*) in);
-
-               case cgltf_component_type_r_16:
-                       return *((const int16_t*) in);
-
-               case cgltf_component_type_r_16u:
-                       return *((const uint16_t*) in);
-
-               case cgltf_component_type_r_32u:
-                       return *((const uint32_t*) in);
-
-               default:
-                       return 0;
-       }
-}
-
-static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size)
-{
-       cgltf_size num_components = cgltf_num_components(type);
-
-       if (element_size < num_components)
-       {
-               return 0;
-       }
-
-       // Reading integer matrices is not a valid use case
-       if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4)
-       {
-               return 0;
-       }
-
-       cgltf_size component_size = cgltf_component_size(component_type);
-
-       for (cgltf_size i = 0; i < num_components; ++i)
-       {
-               out[i] = cgltf_component_read_uint(element + component_size * i, component_type);
-       }
-       return 1;
-}
-
-cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size)
-{
-       if (accessor->is_sparse)
-       {
-               return 0;
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               memset(out, 0, element_size * sizeof( cgltf_uint ));
-               return 1;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0;
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size);
-}
-
-cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index)
-{
-       if (accessor->is_sparse)
-       {
-               return 0; // This is an error case, but we can't communicate the error with existing interface.
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               return 0;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0; // This is an error case, but we can't communicate the error with existing interface.
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_component_read_index(element, accessor->component_type);
-}
-
-#define CGLTF_ERROR_JSON -1
-#define CGLTF_ERROR_NOMEM -2
-#define CGLTF_ERROR_LEGACY -3
-
-#define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; }
-#define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */
-
-#define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1)
-#define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; }
-#define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1];
-
-static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
-       size_t const str_len = strlen(str);
-       size_t const name_length = tok->end - tok->start;
-       return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
-}
-
-static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
-       char tmp[128];
-       int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
-       strncpy(tmp, (const char*)json_chunk + tok->start, size);
-       tmp[size] = 0;
-       return CGLTF_ATOI(tmp);
-}
-
-static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
-       char tmp[128];
-       int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
-       strncpy(tmp, (const char*)json_chunk + tok->start, size);
-       tmp[size] = 0;
-       return (cgltf_float)CGLTF_ATOF(tmp);
-}
-
-static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       int size = tok->end - tok->start;
-       return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
-}
-
-static int cgltf_skip_json(jsmntok_t const* tokens, int i)
-{
-       int end = i + 1;
-
-       while (i < end)
-       {
-               switch (tokens[i].type)
-               {
-               case JSMN_OBJECT:
-                       end += tokens[i].size * 2;
-                       break;
-
-               case JSMN_ARRAY:
-                       end += tokens[i].size;
-                       break;
-
-               case JSMN_PRIMITIVE:
-               case JSMN_STRING:
-                       break;
-
-               default:
-                       return -1;
-               }
-
-               i++;
-       }
-
-       return i;
-}
-
-static void cgltf_fill_float_array(float* out_array, int size, float value)
-{
-       for (int j = 0; j < size; ++j)
-       {
-               out_array[j] = value;
-       }
-}
-
-static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-       if (tokens[i].size != size)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       ++i;
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-               out_array[j] = cgltf_json_to_float(tokens + i, json_chunk);
-               ++i;
-       }
-       return i;
-}
-
-static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
-       if (*out_string)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       int size = tokens[i].end - tokens[i].start;
-       char* result = (char*)options->memory.alloc(options->memory.user_data, size + 1);
-       if (!result)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(result, (const char*)json_chunk + tokens[i].start, size);
-       result[size] = 0;
-       *out_string = result;
-       return i + 1;
-}
-
-static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size)
-{
-       (void)json_chunk;
-       if (tokens[i].type != JSMN_ARRAY)
-       {
-               return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON;
-       }
-       if (*out_array)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       int size = tokens[i].size;
-       void* result = cgltf_calloc(options, element_size, size);
-       if (!result)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       *out_array = result;
-       *out_size = size;
-       return i + 1;
-}
-
-static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < *out_size; ++j)
-       {
-               i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array));
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index)
-{
-       const char* us = strchr(name, '_');
-       size_t len = us ? (size_t)(us - name) : strlen(name);
-
-       if (len == 8 && strncmp(name, "POSITION", 8) == 0)
-       {
-               *out_type = cgltf_attribute_type_position;
-       }
-       else if (len == 6 && strncmp(name, "NORMAL", 6) == 0)
-       {
-               *out_type = cgltf_attribute_type_normal;
-       }
-       else if (len == 7 && strncmp(name, "TANGENT", 7) == 0)
-       {
-               *out_type = cgltf_attribute_type_tangent;
-       }
-       else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0)
-       {
-               *out_type = cgltf_attribute_type_texcoord;
-       }
-       else if (len == 5 && strncmp(name, "COLOR", 5) == 0)
-       {
-               *out_type = cgltf_attribute_type_color;
-       }
-       else if (len == 6 && strncmp(name, "JOINTS", 6) == 0)
-       {
-               *out_type = cgltf_attribute_type_joints;
-       }
-       else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0)
-       {
-               *out_type = cgltf_attribute_type_weights;
-       }
-       else
-       {
-               *out_type = cgltf_attribute_type_invalid;
-       }
-
-       if (us && *out_type != cgltf_attribute_type_invalid)
-       {
-               *out_index = CGLTF_ATOI(us + 1);
-       }
-}
-
-static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       if (*out_attributes)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       *out_attributes_count = tokens[i].size;
-       *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count);
-       ++i;
-
-       if (!*out_attributes)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-
-       for (cgltf_size j = 0; j < *out_attributes_count; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name);
-               if (i < 0)
-               {
-                       return CGLTF_ERROR_JSON;
-               }
-
-               cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index);
-
-               (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-               ++i;
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
-{
-       (void)json_chunk;
-       out_extras->start_offset = tokens[i].start;
-       out_extras->end_offset = tokens[i].end;
-       i = cgltf_skip_json(tokens, i);
-       return i;
-}
-
-static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
-       CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT);
-       if (out_extension->name)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       cgltf_size name_length = tokens[i].end - tokens[i].start;
-       out_extension->name = (char*)options->memory.alloc(options->memory.user_data, name_length + 1);
-       if (!out_extension->name)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length);
-       out_extension->name[name_length] = 0;
-       i++;
-
-       size_t start = tokens[i].start;
-       size_t size = tokens[i].end - start;
-       out_extension->data = (char*)options->memory.alloc(options->memory.user_data, size + 1);
-       if (!out_extension->data)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(out_extension->data, (const char*)json_chunk + start, size);
-       out_extension->data[size] = '\0';
-
-       i = cgltf_skip_json(tokens, i);
-
-       return i;
-}
-
-static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions)
-{
-       ++i;
-
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       if(*out_extensions)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       int extensions_size = tokens[i].size;
-       *out_extensions_count = 0;
-       *out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-       if (!*out_extensions)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-
-       ++i;
-
-       for (int j = 0; j < extensions_size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               cgltf_size extension_index = (*out_extensions_count)++;
-               cgltf_extension* extension = &((*out_extensions)[extension_index]);
-               i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension);
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
-               {
-                       i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-               int obj_size = tokens[i].size;
-               ++i;
-
-               int material = -1;
-               int variants_tok = -1;
-               cgltf_extras extras = {0, 0};
-
-               for (int k = 0; k < obj_size; ++k)
-               {
-                       CGLTF_CHECK_KEY(tokens[i]);
-
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0)
-                       {
-                               ++i;
-                               material = cgltf_json_to_int(tokens + i, json_chunk);
-                               ++i;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
-                       {
-                               variants_tok = i+1;
-                               CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY);
-
-                               i = cgltf_skip_json(tokens, i+1);
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                       {
-                               i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras);
-                       }
-                       else
-                       {
-                               i = cgltf_skip_json(tokens, i+1);
-                       }
-
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-               }
-
-               if (material < 0 || variants_tok < 0)
-               {
-                       return CGLTF_ERROR_JSON;
-               }
-
-               if (out_mappings)
-               {
-                       for (int k = 0; k < tokens[variants_tok].size; ++k)
-                       {
-                               int variant = cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk);
-                               if (variant < 0)
-                                       return variant;
-
-                               out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
-                               out_mappings[*offset].variant = variant;
-                               out_mappings[*offset].extras = extras;
-
-                               (*offset)++;
-                       }
-               }
-               else
-               {
-                       (*offset) += tokens[variants_tok].size;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material_mappings(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0)
-               {
-                       if (out_prim->mappings)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       cgltf_size mappings_offset = 0;
-                       int k = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, NULL, &mappings_offset);
-                       if (k < 0)
-                       {
-                               return k;
-                       }
-
-                       out_prim->mappings_count = mappings_offset;
-                       out_prim->mappings = (cgltf_material_mapping*)cgltf_calloc(options, sizeof(cgltf_material_mapping), out_prim->mappings_count);
-
-                       mappings_offset = 0;
-                       i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, out_prim->mappings, &mappings_offset);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_prim->type = cgltf_primitive_type_triangles;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
-               {
-                       ++i;
-                       out_prim->type
-                                       = (cgltf_primitive_type)
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
-               {
-                       ++i;
-                       out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0)
-               {
-                       ++i;
-                       out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0)
-               {
-                       i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_prim->targets_count; ++k)
-                       {
-                               i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_prim->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_prim->extensions_count = 0;
-                       out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_prim->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0)
-                               {
-                                       out_prim->has_draco_mesh_compression = 1;
-                                       i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
-                               {
-                                       i = cgltf_parse_json_material_mappings(options, tokens, i + 1, json_chunk, out_prim);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index)
-                       {
-                               i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       ++i;
-
-                       out_mesh->extras.start_offset = tokens[i].start;
-                       out_mesh->extras.end_offset = tokens[i].end;
-
-                       if (tokens[i].type == JSMN_OBJECT)
-                       {
-                               int extras_size = tokens[i].size;
-                               ++i;
-
-                               for (int k = 0; k < extras_size; ++k)
-                               {
-                                       CGLTF_CHECK_KEY(tokens[i]);
-
-                                       if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0 && tokens[i+1].type == JSMN_ARRAY)
-                                       {
-                                               i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count);
-                                       }
-                                       else
-                                       {
-                                               i = cgltf_skip_json(tokens, i+1);
-                                       }
-
-                                       if (i < 0)
-                                       {
-                                               return i;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               i = cgltf_skip_json(tokens, i);
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->meshes_count; ++j)
-       {
-               i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       int type = cgltf_json_to_int(tok, json_chunk);
-
-       switch (type)
-       {
-       case 5120:
-               return cgltf_component_type_r_8;
-       case 5121:
-               return cgltf_component_type_r_8u;
-       case 5122:
-               return cgltf_component_type_r_16;
-       case 5123:
-               return cgltf_component_type_r_16u;
-       case 5125:
-               return cgltf_component_type_r_32u;
-       case 5126:
-               return cgltf_component_type_r_32f;
-       default:
-               return cgltf_component_type_invalid;
-       }
-}
-
-static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int indices_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < indices_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_byte_offset = cgltf_json_to_int(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->indices_extensions_count, &out_sparse->indices_extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int values_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < values_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->values_byte_offset = cgltf_json_to_int(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->values_extensions_count, &out_sparse->values_extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->extensions_count, &out_sparse->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_accessor->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_accessor->offset =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
-               {
-                       ++i;
-                       out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0)
-               {
-                       ++i;
-                       out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_accessor->count =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0)
-                       {
-                               out_accessor->type = cgltf_type_scalar;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec2;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec3;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec4;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat2;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat3;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat4;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0)
-               {
-                       ++i;
-                       out_accessor->has_min = 1;
-                       // note: we can't parse the precise number of elements since type may not have been computed yet
-                       int min_size = tokens[i].size > 16 ? 16 : tokens[i].size;
-                       i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0)
-               {
-                       ++i;
-                       out_accessor->has_max = 1;
-                       // note: we can't parse the precise number of elements since type may not have been computed yet
-                       int max_size = tokens[i].size > 16 ? 16 : tokens[i].size;
-                       i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0)
-               {
-                       out_accessor->is_sparse = 1;
-                       i = cgltf_parse_json_accessor_sparse(options, tokens, i + 1, json_chunk, &out_accessor->sparse);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0)
-               {
-                       ++i;
-                       out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
-               {
-                       ++i;
-                       out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_texture_view->scale = 1.0f;
-       cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0)
-               {
-                       ++i;
-                       out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
-               {
-                       ++i;
-                       out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) 
-               {
-                       ++i;
-                       out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0)
-               {
-                       ++i;
-                       out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_texture_view->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_texture_view->extensions_count = 0;
-                       out_texture_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_texture_view->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0)
-                               {
-                                       out_texture_view->has_transform = 1;
-                                       i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture_view->extensions[out_texture_view->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0)
-               {
-                       ++i;
-                       out_pbr->metallic_factor = 
-                               cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0) 
-               {
-                       ++i;
-                       out_pbr->roughness_factor =
-                               cgltf_json_to_float(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_pbr->base_color_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_pbr->metallic_roughness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0)
-               {
-                       ++i;
-                       out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0)
-               {
-                       ++i;
-                       out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0)
-               {
-                       ++i;
-                       out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       // Default values
-       out_ior->ior = 1.5f;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0)
-               {
-                       ++i;
-                       out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       // Default values
-       out_specular->specular_factor = 1.0f;
-       cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f);
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
-               {
-                       ++i;
-                       out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_color_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0)
-               {
-                       ++i;
-                       out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_volume(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_volume* out_volume)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0)
-               {
-                       ++i;
-                       out_volume->thickness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_volume->thickness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_volume->attenuation_color, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationDistance") == 0)
-               {
-                       ++i;
-                       out_volume->attenuation_distance = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0)
-               {
-                       ++i;
-                       out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j) 
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) 
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_sampler->wrap_s = 10497;
-       out_sampler->wrap_t = 10497;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_sampler->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0)
-               {
-                       ++i;
-                       out_sampler->mag_filter
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0)
-               {
-                       ++i;
-                       out_sampler->min_filter
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0)
-               {
-                       ++i;
-                       out_sampler->wrap_s
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) 
-               {
-                       ++i;
-                       out_sampler->wrap_t
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0)
-               {
-                       ++i;
-                       out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) 
-               {
-                       ++i;
-                       out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_texture->extensions_count, &out_texture->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f);
-       out_material->pbr_metallic_roughness.metallic_factor = 1.0f;
-       out_material->pbr_metallic_roughness.roughness_factor = 1.0f;
-
-       cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f);
-       cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f);
-       out_material->pbr_specular_glossiness.glossiness_factor = 1.0f;
-
-       cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f);
-       out_material->volume.attenuation_distance = FLT_MAX;
-
-       out_material->alpha_cutoff = 0.5f;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0)
-               {
-                       out_material->has_pbr_metallic_roughness = 1;
-                       i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->normal_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->occlusion_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->emissive_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_opaque;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_mask;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_blend;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0)
-               {
-                       ++i;
-                       out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0)
-               {
-                       ++i;
-                       out_material->double_sided =
-                               cgltf_json_to_bool(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_material->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       ++i;
-                       out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-                       out_material->extensions_count= 0;
-
-                       if (!out_material->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0)
-                               {
-                                       out_material->has_pbr_specular_glossiness = 1;
-                                       i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0)
-                               {
-                                       out_material->unlit = 1;
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0)
-                               {
-                                       out_material->has_clearcoat = 1;
-                                       i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0)
-                               {
-                                       out_material->has_ior = 1;
-                                       i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0)
-                               {
-                                       out_material->has_specular = 1;
-                                       i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0)
-                               {
-                                       out_material->has_transmission = 1;
-                                       i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_volume") == 0)
-                               {
-                                       out_material->has_volume = 1;
-                                       i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, &out_material->volume);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0)
-                               {
-                                       out_material->has_sheen = 1;
-                                       i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->accessors_count; ++j)
-       {
-               i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->materials_count; ++j)
-       {
-               i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->images_count; ++j)
-       {
-               i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->textures_count; ++j)
-       {
-               i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->samplers_count; ++j)
-       {
-               i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->offset = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->size = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->stride = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->count = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential;
-                       }
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer_view->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
-               {
-                       ++i;
-                       out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_buffer_view->offset =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_buffer_view->size =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
-               {
-                       ++i;
-                       out_buffer_view->stride =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
-               {
-                       ++i;
-                       int type = cgltf_json_to_int(tokens+i, json_chunk);
-                       switch (type)
-                       {
-                       case 34962:
-                               type = cgltf_buffer_view_type_vertices;
-                               break;
-                       case 34963:
-                               type = cgltf_buffer_view_type_indices;
-                               break;
-                       default:
-                               type = cgltf_buffer_view_type_invalid;
-                               break;
-                       }
-                       out_buffer_view->type = (cgltf_buffer_view_type)type;
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_buffer_view->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_buffer_view->extensions_count = 0;
-                       out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_buffer_view->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0)
-                               {
-                                       out_buffer_view->has_meshopt_compression = 1;
-                                       i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j)
-       {
-               i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_buffer->size =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->buffers_count; ++j)
-       {
-               i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_skin->joints_count; ++k)
-                       {
-                               out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->skins_count; ++j)
-       {
-               i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0)
-                       {
-                               out_camera->type = cgltf_camera_type_perspective;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0)
-                       {
-                               out_camera->type = cgltf_camera_type_orthographic;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       out_camera->type = cgltf_camera_type_perspective;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.has_aspect_ratio = 1;
-                                       out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.has_zfar = 1;
-                                       out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       out_camera->type = cgltf_camera_type_orthographic;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->cameras_count; ++j)
-       {
-               i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0)
-               {
-                       ++i;
-                       out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0)
-                       {
-                               out_light->type = cgltf_light_type_directional;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0)
-                       {
-                               out_light->type = cgltf_light_type_point;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0)
-                       {
-                               out_light->type = cgltf_light_type_spot;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0)
-               {
-                       ++i;
-                       out_light->range = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0)
-                               {
-                                       ++i;
-                                       out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0)
-                               {
-                                       ++i;
-                                       out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->lights_count; ++j)
-       {
-               i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_node->rotation[3] = 1.0f;
-       out_node->scale[0] = 1.0f;
-       out_node->scale[1] = 1.0f;
-       out_node->scale[2] = 1.0f;
-       out_node->matrix[0] = 1.0f;
-       out_node->matrix[5] = 1.0f;
-       out_node->matrix[10] = 1.0f;
-       out_node->matrix[15] = 1.0f;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_node->children_count; ++k)
-                       {
-                               out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
-               {
-                       out_node->has_translation = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
-               {
-                       out_node->has_rotation = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
-               {
-                       out_node->has_scale = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0)
-               {
-                       out_node->has_matrix = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_node->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_node->extensions_count= 0;
-                       out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_node->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0)
-                                               {
-                                                       ++i;
-                                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                                                       out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk));
-                                                       ++i;
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->nodes_count; ++j)
-       {
-               i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_scene->nodes_count; ++k)
-                       {
-                               out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->scenes_count; ++j)
-       {
-               i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0)
-               {
-                       ++i;
-                       out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0)
-               {
-                       ++i;
-                       out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_linear;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_step;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_cubic_spline;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0)
-               {
-                       ++i;
-                       out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int target_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < target_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0)
-                               {
-                                       ++i;
-                                       out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0)
-                               {
-                                       ++i;
-                                       if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_translation;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_rotation;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_scale;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_weights;
-                                       }
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_animation->samplers_count; ++k)
-                       {
-                               i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_animation->channels_count; ++k)
-                       {
-                               i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->animations_count; ++j)
-       {
-               i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_variant* out_variant)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_variant->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_variant->extras);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_variants(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material_variant), (void**)&out_data->variants, &out_data->variants_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->variants_count; ++j)
-       {
-               i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data->variants[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2)
-       {
-               return CGLTF_ERROR_LEGACY;
-       }
-
-       return i;
-}
-
-cgltf_size cgltf_num_components(cgltf_type type) {
-       switch (type)
-       {
-       case cgltf_type_vec2:
-               return 2;
-       case cgltf_type_vec3:
-               return 3;
-       case cgltf_type_vec4:
-               return 4;
-       case cgltf_type_mat2:
-               return 4;
-       case cgltf_type_mat3:
-               return 9;
-       case cgltf_type_mat4:
-               return 16;
-       case cgltf_type_invalid:
-       case cgltf_type_scalar:
-       default:
-               return 1;
-       }
-}
-
-static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
-       switch (component_type)
-       {
-       case cgltf_component_type_r_8:
-       case cgltf_component_type_r_8u:
-               return 1;
-       case cgltf_component_type_r_16:
-       case cgltf_component_type_r_16u:
-               return 2;
-       case cgltf_component_type_r_32u:
-       case cgltf_component_type_r_32f:
-               return 4;
-       case cgltf_component_type_invalid:
-       default:
-               return 0;
-       }
-}
-
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
-{
-       cgltf_size component_size = cgltf_component_size(component_type);
-       if (type == cgltf_type_mat2 && component_size == 1)
-       {
-               return 8 * component_size;
-       }
-       else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2))
-       {
-               return 12 * component_size;
-       }
-       return component_size * cgltf_num_components(type);
-}
-
-static int cgltf_fixup_pointers(cgltf_data* out_data);
-
-static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0)
-               {
-                       i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0)
-               {
-                       i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0)
-               {
-                       i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0)
-               {
-                       i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0)
-               {
-                       i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0)
-               {
-                       i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0)
-               {
-                       i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0)
-               {
-                       i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0)
-               {
-                       i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0)
-               {
-                       i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0)
-               {
-                       i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0)
-               {
-                       i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0)
-               {
-                       i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
-               {
-                       ++i;
-                       out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
-               {
-                       i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_data->data_extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_data->data_extensions_count = 0;
-                       out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_data->data_extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0)
-                                               {
-                                                       i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data);
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
-                                               {
-                                                       i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, out_data);
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0)
-               {
-                       i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0)
-               {
-                       i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data)
-{
-       jsmn_parser parser = { 0, 0, 0 };
-
-       if (options->json_token_count == 0)
-       {
-               int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0);
-
-               if (token_count <= 0)
-               {
-                       return cgltf_result_invalid_json;
-               }
-
-               options->json_token_count = token_count;
-       }
-
-       jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1));
-
-       if (!tokens)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       jsmn_init(&parser);
-
-       int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count);
-
-       if (token_count <= 0)
-       {
-               options->memory.free(options->memory.user_data, tokens);
-               return cgltf_result_invalid_json;
-       }
-
-       // this makes sure that we always have an UNDEFINED token at the end of the stream
-       // for invalid JSON inputs this makes sure we don't perform out of bound reads of token data
-       tokens[token_count].type = JSMN_UNDEFINED;
-
-       cgltf_data* data = (cgltf_data*)options->memory.alloc(options->memory.user_data, sizeof(cgltf_data));
-
-       if (!data)
-       {
-               options->memory.free(options->memory.user_data, tokens);
-               return cgltf_result_out_of_memory;
-       }
-
-       memset(data, 0, sizeof(cgltf_data));
-       data->memory = options->memory;
-       data->file = options->file;
-
-       int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data);
-
-       options->memory.free(options->memory.user_data, tokens);
-
-       if (i < 0)
-       {
-               cgltf_free(data);
-
-               switch (i)
-               {
-               case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory;
-               case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf;
-               default: return cgltf_result_invalid_gltf;
-               }
-       }
-
-       if (cgltf_fixup_pointers(data) < 0)
-       {
-               cgltf_free(data);
-               return cgltf_result_invalid_gltf;
-       }
-
-       data->json = (const char*)json_chunk;
-       data->json_size = size;
-
-       *out_data = data;
-
-       return cgltf_result_success;
-}
-
-static int cgltf_fixup_pointers(cgltf_data* data)
-{
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count);
-                       CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count);
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count);
-                       }
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                       {
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                               {
-                                       CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count);
-                               }
-                       }
-
-                       if (data->meshes[i].primitives[j].has_draco_mesh_compression)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count);
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m)
-                               {
-                                       CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count);
-                               }
-                       }
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, data->materials, data->materials_count);
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count);
-
-               if (data->accessors[i].is_sparse)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count);
-                       CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count);
-               }
-
-               if (data->accessors[i].buffer_view)
-               {
-                       data->accessors[i].stride = data->accessors[i].buffer_view->stride;
-               }
-
-               if (data->accessors[i].stride == 0)
-               {
-                       data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->textures_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count);
-               CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count);
-       }
-
-       for (cgltf_size i = 0; i < data->images_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count);
-       }
-
-       for (cgltf_size i = 0; i < data->materials_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count);
-       }
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count);
-
-               if (data->buffer_views[i].has_meshopt_compression)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->skins_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count);
-               }
-
-               CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count);
-               CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count);
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count);
-
-                       if (data->nodes[i].children[j]->parent)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       data->nodes[i].children[j]->parent = &data->nodes[i];
-               }
-
-               CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count);
-               CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count);
-               CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count);
-               CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count);
-       }
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count);
-
-                       if (data->scenes[i].nodes[j]->parent)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-               }
-       }
-
-       CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count);
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count);
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count);
-               }
-
-               for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count);
-                       CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count);
-               }
-       }
-
-       return 0;
-}
-
-/*
- * -- jsmn.c start --
- * Source: https://github.com/zserge/jsmn
- * License: MIT
- *
- * Copyright (c) 2010 Serge A. Zaitsev
-
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
-
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
-
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * Allocates a fresh unused token from the token pull.
- */
-static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
-                                  jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *tok;
-       if (parser->toknext >= num_tokens) {
-               return NULL;
-       }
-       tok = &tokens[parser->toknext++];
-       tok->start = tok->end = -1;
-       tok->size = 0;
-#ifdef JSMN_PARENT_LINKS
-       tok->parent = -1;
-#endif
-       return tok;
-}
-
-/**
- * Fills token type and boundaries.
- */
-static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
-                               int start, int end) {
-       token->type = type;
-       token->start = start;
-       token->end = end;
-       token->size = 0;
-}
-
-/**
- * Fills next available token with JSON primitive.
- */
-static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
-                               size_t len, jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *token;
-       int start;
-
-       start = parser->pos;
-
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               switch (js[parser->pos]) {
-#ifndef JSMN_STRICT
-               /* In strict mode primitive must be followed by "," or "}" or "]" */
-               case ':':
-#endif
-               case '\t' : case '\r' : case '\n' : case ' ' :
-               case ','  : case ']'  : case '}' :
-                       goto found;
-               }
-               if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
-                       parser->pos = start;
-                       return JSMN_ERROR_INVAL;
-               }
-       }
-#ifdef JSMN_STRICT
-       /* In strict mode primitive must be followed by a comma/object/array */
-       parser->pos = start;
-       return JSMN_ERROR_PART;
-#endif
-
-found:
-       if (tokens == NULL) {
-               parser->pos--;
-               return 0;
-       }
-       token = jsmn_alloc_token(parser, tokens, num_tokens);
-       if (token == NULL) {
-               parser->pos = start;
-               return JSMN_ERROR_NOMEM;
-       }
-       jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-       token->parent = parser->toksuper;
-#endif
-       parser->pos--;
-       return 0;
-}
-
-/**
- * Fills next token with JSON string.
- */
-static int jsmn_parse_string(jsmn_parser *parser, const char *js,
-                                size_t len, jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *token;
-
-       int start = parser->pos;
-
-       parser->pos++;
-
-       /* Skip starting quote */
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               char c = js[parser->pos];
-
-               /* Quote: end of string */
-               if (c == '\"') {
-                       if (tokens == NULL) {
-                               return 0;
-                       }
-                       token = jsmn_alloc_token(parser, tokens, num_tokens);
-                       if (token == NULL) {
-                               parser->pos = start;
-                               return JSMN_ERROR_NOMEM;
-                       }
-                       jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-                       token->parent = parser->toksuper;
-#endif
-                       return 0;
-               }
-
-               /* Backslash: Quoted symbol expected */
-               if (c == '\\' && parser->pos + 1 < len) {
-                       int i;
-                       parser->pos++;
-                       switch (js[parser->pos]) {
-                       /* Allowed escaped symbols */
-                       case '\"': case '/' : case '\\' : case 'b' :
-                       case 'f' : case 'r' : case 'n'  : case 't' :
-                               break;
-                               /* Allows escaped symbol \uXXXX */
-                       case 'u':
-                               parser->pos++;
-                               for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
-                                       /* If it isn't a hex character we have an error */
-                                       if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                                                (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                                                (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
-                                               parser->pos = start;
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       parser->pos++;
-                               }
-                               parser->pos--;
-                               break;
-                               /* Unexpected symbol */
-                       default:
-                               parser->pos = start;
-                               return JSMN_ERROR_INVAL;
-                       }
-               }
-       }
-       parser->pos = start;
-       return JSMN_ERROR_PART;
-}
-
-/**
- * Parse JSON string and fill tokens.
- */
-static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
-                  jsmntok_t *tokens, size_t num_tokens) {
-       int r;
-       int i;
-       jsmntok_t *token;
-       int count = parser->toknext;
-
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               char c;
-               jsmntype_t type;
-
-               c = js[parser->pos];
-               switch (c) {
-               case '{': case '[':
-                       count++;
-                       if (tokens == NULL) {
-                               break;
-                       }
-                       token = jsmn_alloc_token(parser, tokens, num_tokens);
-                       if (token == NULL)
-                               return JSMN_ERROR_NOMEM;
-                       if (parser->toksuper != -1) {
-                               tokens[parser->toksuper].size++;
-#ifdef JSMN_PARENT_LINKS
-                               token->parent = parser->toksuper;
-#endif
-                       }
-                       token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
-                       token->start = parser->pos;
-                       parser->toksuper = parser->toknext - 1;
-                       break;
-               case '}': case ']':
-                       if (tokens == NULL)
-                               break;
-                       type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
-#ifdef JSMN_PARENT_LINKS
-                       if (parser->toknext < 1) {
-                               return JSMN_ERROR_INVAL;
-                       }
-                       token = &tokens[parser->toknext - 1];
-                       for (;;) {
-                               if (token->start != -1 && token->end == -1) {
-                                       if (token->type != type) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       token->end = parser->pos + 1;
-                                       parser->toksuper = token->parent;
-                                       break;
-                               }
-                               if (token->parent == -1) {
-                                       if(token->type != type || parser->toksuper == -1) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       break;
-                               }
-                               token = &tokens[token->parent];
-                       }
-#else
-                       for (i = parser->toknext - 1; i >= 0; i--) {
-                               token = &tokens[i];
-                               if (token->start != -1 && token->end == -1) {
-                                       if (token->type != type) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       parser->toksuper = -1;
-                                       token->end = parser->pos + 1;
-                                       break;
-                               }
-                       }
-                       /* Error if unmatched closing bracket */
-                       if (i == -1) return JSMN_ERROR_INVAL;
-                       for (; i >= 0; i--) {
-                               token = &tokens[i];
-                               if (token->start != -1 && token->end == -1) {
-                                       parser->toksuper = i;
-                                       break;
-                               }
-                       }
-#endif
-                       break;
-               case '\"':
-                       r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-                       if (r < 0) return r;
-                       count++;
-                       if (parser->toksuper != -1 && tokens != NULL)
-                               tokens[parser->toksuper].size++;
-                       break;
-               case '\t' : case '\r' : case '\n' : case ' ':
-                       break;
-               case ':':
-                       parser->toksuper = parser->toknext - 1;
-                       break;
-               case ',':
-                       if (tokens != NULL && parser->toksuper != -1 &&
-                                       tokens[parser->toksuper].type != JSMN_ARRAY &&
-                                       tokens[parser->toksuper].type != JSMN_OBJECT) {
-#ifdef JSMN_PARENT_LINKS
-                               parser->toksuper = tokens[parser->toksuper].parent;
-#else
-                               for (i = parser->toknext - 1; i >= 0; i--) {
-                                       if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                                               if (tokens[i].start != -1 && tokens[i].end == -1) {
-                                                       parser->toksuper = i;
-                                                       break;
-                                               }
-                                       }
-                               }
-#endif
-                       }
-                       break;
-#ifdef JSMN_STRICT
-                       /* In strict mode primitives are: numbers and booleans */
-               case '-': case '0': case '1' : case '2': case '3' : case '4':
-               case '5': case '6': case '7' : case '8': case '9':
-               case 't': case 'f': case 'n' :
-                       /* And they must not be keys of the object */
-                       if (tokens != NULL && parser->toksuper != -1) {
-                               jsmntok_t *t = &tokens[parser->toksuper];
-                               if (t->type == JSMN_OBJECT ||
-                                               (t->type == JSMN_STRING && t->size != 0)) {
-                                       return JSMN_ERROR_INVAL;
-                               }
-                       }
-#else
-                       /* In non-strict mode every unquoted value is a primitive */
-               default:
-#endif
-                       r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-                       if (r < 0) return r;
-                       count++;
-                       if (parser->toksuper != -1 && tokens != NULL)
-                               tokens[parser->toksuper].size++;
-                       break;
-
-#ifdef JSMN_STRICT
-                       /* Unexpected char in strict mode */
-               default:
-                       return JSMN_ERROR_INVAL;
-#endif
-               }
-       }
-
-       if (tokens != NULL) {
-               for (i = parser->toknext - 1; i >= 0; i--) {
-                       /* Unmatched opened object or array */
-                       if (tokens[i].start != -1 && tokens[i].end == -1) {
-                               return JSMN_ERROR_PART;
-                       }
-               }
-       }
-
-       return count;
-}
-
-/**
- * Creates a new parser based over a given  buffer with an array of tokens
- * available.
- */
-static void jsmn_init(jsmn_parser *parser) {
-       parser->pos = 0;
-       parser->toknext = 0;
-       parser->toksuper = -1;
-}
-/*
- * -- jsmn.c end --
- */
-
-#endif /* #ifdef CGLTF_IMPLEMENTATION */
-
-/* cgltf is distributed under MIT license:
- *
- * Copyright (c) 2018 Johannes Kuhlmann
-
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
-
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
-
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
diff --git a/raylib/external/dirent.h b/raylib/external/dirent.h
deleted file mode 100644 (file)
index c611376..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-
-    Declaration of POSIX directory browsing functions and types for Win32.
-
-    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
-    History: Created March 1997. Updated June 2003.
-             Reviewed by Ramon Santamaria for raylib on January 2020.
-
-    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives.
-    
-    This software is supplied "as is" without express or implied warranty.
-
-    But that said, if there are any problems please get in touch.
-
-****************************************************************************/
-
-#ifndef DIRENT_H
-#define DIRENT_H
-
-// Allow custom memory allocators
-#ifndef DIRENT_MALLOC
-    #define DIRENT_MALLOC(sz)   malloc(sz)
-#endif
-#ifndef DIRENT_FREE
-    #define DIRENT_FREE(p)      free(p)
-#endif
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-
-// Fordward declaration of DIR, implementation below
-typedef struct DIR DIR;
-
-struct dirent {
-    char *d_name;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------------
-// Functions Declaration
-//------------------------------------------------------------------------------------
-DIR *opendir(const char *name);
-int closedir(DIR *dir);
-struct dirent *readdir(DIR *dir);
-void rewinddir(DIR *dir);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif      // DIRENT_H
-
-/****************************************************************************
-
-    Implementation of POSIX directory browsing functions and types for Win32.
-
-    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
-    History: Created March 1997. Updated June 2003.
-             Reviewed by Ramon Santamaria for raylib on January 2020.
-
-    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives.
-    
-    This software is supplied "as is" without express or implied warranty.
-
-    But that said, if there are any problems please get in touch.
-
-****************************************************************************/
-
-#include <io.h>         // _findfirst and _findnext set errno iff they return -1
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-typedef ptrdiff_t handle_type;  // C99's intptr_t not sufficiently portable
-
-struct DIR {
-    handle_type handle;         // -1 for failed rewind
-    struct _finddata_t info;
-    struct dirent result;       // d_name null iff first time
-    char *name;                 // null-terminated char string
-};
-
-DIR *opendir(const char *name)
-{
-    DIR *dir = 0;
-
-    if (name && name[0])
-    {
-        size_t base_length = strlen(name);
-        
-        // Search pattern must end with suitable wildcard
-        const char *all = strchr("/\\", name[base_length - 1]) ? "*" : "/*";
-
-        if ((dir = (DIR *)DIRENT_MALLOC(sizeof *dir)) != 0 &&
-            (dir->name = (char *)DIRENT_MALLOC(base_length + strlen(all) + 1)) != 0)
-        {
-            strcat(strcpy(dir->name, name), all);
-
-            if ((dir->handle = (handle_type) _findfirst(dir->name, &dir->info)) != -1)
-            {
-                dir->result.d_name = 0;
-            }
-            else  // rollback
-            {
-                DIRENT_FREE(dir->name);
-                DIRENT_FREE(dir);
-                dir = 0;
-            }
-        }
-        else  // rollback
-        {
-            DIRENT_FREE(dir);
-            dir   = 0;
-            errno = ENOMEM;
-        }
-    }
-    else errno = EINVAL;
-
-    return dir;
-}
-
-int closedir(DIR *dir)
-{
-    int result = -1;
-
-    if (dir)
-    {
-        if (dir->handle != -1) result = _findclose(dir->handle);
-
-        DIRENT_FREE(dir->name);
-        DIRENT_FREE(dir);
-    }
-
-    // NOTE: All errors ampped to EBADF
-    if (result == -1) errno = EBADF;
-
-    return result;
-}
-
-struct dirent *readdir(DIR *dir)
-{
-    struct dirent *result = 0;
-
-    if (dir && dir->handle != -1)
-    {
-        if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
-        {
-            result = &dir->result;
-            result->d_name = dir->info.name;
-        }
-    }
-    else errno = EBADF;
-
-    return result;
-}
-
-void rewinddir(DIR *dir)
-{
-    if (dir && dir->handle != -1)
-    {
-        _findclose(dir->handle);
-        dir->handle = (handle_type) _findfirst(dir->name, &dir->info);
-        dir->result.d_name = 0;
-    }
-    else errno = EBADF;
-}
diff --git a/raylib/external/dr_flac.h b/raylib/external/dr_flac.h
deleted file mode 100644 (file)
index a797350..0000000
+++ /dev/null
@@ -1,12263 +0,0 @@
-/*
-FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_flac - v0.12.29 - 2021-04-02
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-*/
-
-/*
-RELEASE NOTES - v0.12.0
-=======================
-Version 0.12.0 has breaking API changes including changes to the existing API and the removal of deprecated APIs.
-
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drflac_allocation_callbacks object to drflac_open() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drflac_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drflac* pFlac = drflac_open_file("my_file.flac", &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_flac to use defaults which is the same as DRFLAC_MALLOC,
-DRFLAC_REALLOC and DRFLAC_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drflac object now takes this extra parameter. These include the following:
-
-    drflac_open()
-    drflac_open_relaxed()
-    drflac_open_with_metadata()
-    drflac_open_with_metadata_relaxed()
-    drflac_open_file()
-    drflac_open_file_with_metadata()
-    drflac_open_memory()
-    drflac_open_memory_with_metadata()
-    drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_read_pcm_frames_f32()
-    drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_memory_and_read_pcm_frames_f32()
-
-
-
-Optimizations
--------------
-Seeking performance has been greatly improved. A new binary search based seeking algorithm has been introduced which significantly
-improves performance over the brute force method which was used when no seek table was present. Seek table based seeking also takes
-advantage of the new binary search seeking system to further improve performance there as well. Note that this depends on CRC which
-means it will be disabled when DR_FLAC_NO_CRC is used.
-
-The SSE4.1 pipeline has been cleaned up and optimized. You should see some improvements with decoding speed of 24-bit files in
-particular. 16-bit streams should also see some improvement.
-
-drflac_read_pcm_frames_s16() has been optimized. Previously this sat on top of drflac_read_pcm_frames_s32() and performed it's s32
-to s16 conversion in a second pass. This is now all done in a single pass. This includes SSE2 and ARM NEON optimized paths.
-
-A minor optimization has been implemented for drflac_read_pcm_frames_s32(). This will now use an SSE2 optimized pipeline for stereo
-channel reconstruction which is the last part of the decoding process.
-
-The ARM build has seen a few improvements. The CLZ (count leading zeroes) and REV (byte swap) instructions are now used when
-compiling with GCC and Clang which is achieved using inline assembly. The CLZ instruction requires ARM architecture version 5 at
-compile time and the REV instruction requires ARM architecture version 6.
-
-An ARM NEON optimized pipeline has been implemented. To enable this you'll need to add -mfpu=neon to the command line when compiling.
-
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.11.0 and have been completely removed in version 0.12.0:
-
-    drflac_read_s32()                   -> drflac_read_pcm_frames_s32()
-    drflac_read_s16()                   -> drflac_read_pcm_frames_s16()
-    drflac_read_f32()                   -> drflac_read_pcm_frames_f32()
-    drflac_seek_to_sample()             -> drflac_seek_to_pcm_frame()
-    drflac_open_and_decode_s32()        -> drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_decode_s16()        -> drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_decode_f32()        -> drflac_open_and_read_pcm_frames_f32()
-    drflac_open_and_decode_file_s32()   -> drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_and_decode_file_s16()   -> drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_and_decode_file_f32()   -> drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_and_decode_memory_s32() -> drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_and_decode_memory_s16() -> drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_and_decode_memory_f32() -> drflac_open_memroy_and_read_pcm_frames_f32()
-
-Prior versions of dr_flac operated on a per-sample basis whereas now it operates on PCM frames. The removed APIs all relate
-to the old per-sample APIs. You now need to use the "pcm_frame" versions.
-*/
-
-
-/*
-Introduction
-============
-dr_flac is a single file library. To use it, do something like the following in one .c file.
-
-    ```c
-    #define DR_FLAC_IMPLEMENTATION
-    #include "dr_flac.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
-
-    ```c
-    drflac* pFlac = drflac_open_file("MySong.flac", NULL);
-    if (pFlac == NULL) {
-        // Failed to open FLAC file
-    }
-
-    drflac_int32* pSamples = malloc(pFlac->totalPCMFrameCount * pFlac->channels * sizeof(drflac_int32));
-    drflac_uint64 numberOfInterleavedSamplesActuallyRead = drflac_read_pcm_frames_s32(pFlac, pFlac->totalPCMFrameCount, pSamples);
-    ```
-
-The drflac object represents the decoder. It is a transparent type so all the information you need, such as the number of channels and the bits per sample,
-should be directly accessible - just make sure you don't change their values. Samples are always output as interleaved signed 32-bit PCM. In the example above
-a native FLAC stream was opened, however dr_flac has seamless support for Ogg encapsulated FLAC streams as well.
-
-You do not need to decode the entire stream in one go - you just specify how many samples you'd like at any given time and the decoder will give you as many
-samples as it can, up to the amount requested. Later on when you need the next batch of samples, just call it again. Example:
-
-    ```c
-    while (drflac_read_pcm_frames_s32(pFlac, chunkSizeInPCMFrames, pChunkSamples) > 0) {
-        do_something();
-    }
-    ```
-
-You can seek to a specific PCM frame with `drflac_seek_to_pcm_frame()`.
-
-If you just want to quickly decode an entire FLAC file in one go you can do something like this:
-
-    ```c
-    unsigned int channels;
-    unsigned int sampleRate;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_int32* pSampleData = drflac_open_file_and_read_pcm_frames_s32("MySong.flac", &channels, &sampleRate, &totalPCMFrameCount, NULL);
-    if (pSampleData == NULL) {
-        // Failed to open and decode FLAC file.
-    }
-
-    ...
-
-    drflac_free(pSampleData, NULL);
-    ```
-
-You can read samples as signed 16-bit integer and 32-bit floating-point PCM with the *_s16() and *_f32() family of APIs respectively, but note that these
-should be considered lossy.
-
-
-If you need access to metadata (album art, etc.), use `drflac_open_with_metadata()`, `drflac_open_file_with_metdata()` or `drflac_open_memory_with_metadata()`.
-The rationale for keeping these APIs separate is that they're slightly slower than the normal versions and also just a little bit harder to use. dr_flac
-reports metadata to the application through the use of a callback, and every metadata block is reported before `drflac_open_with_metdata()` returns.
-
-The main opening APIs (`drflac_open()`, etc.) will fail if the header is not present. The presents a problem in certain scenarios such as broadcast style
-streams or internet radio where the header may not be present because the user has started playback mid-stream. To handle this, use the relaxed APIs:
-    
-    `drflac_open_relaxed()`
-    `drflac_open_with_metadata_relaxed()`
-
-It is not recommended to use these APIs for file based streams because a missing header would usually indicate a corrupt or perverse file. In addition, these
-APIs can take a long time to initialize because they may need to spend a lot of time finding the first frame.
-
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_FLAC_NO_STDIO
-  Disable `drflac_open_file()` and family.
-
-#define DR_FLAC_NO_OGG
-  Disables support for Ogg/FLAC streams.
-
-#define DR_FLAC_BUFFER_SIZE <number>
-  Defines the size of the internal buffer to store data from onRead(). This buffer is used to reduce the number of calls back to the client for more data.
-  Larger values means more memory, but better performance. My tests show diminishing returns after about 4KB (which is the default). Consider reducing this if
-  you have a very efficient implementation of onRead(), or increase it if it's very inefficient. Must be a multiple of 8.
-
-#define DR_FLAC_NO_CRC
-  Disables CRC checks. This will offer a performance boost when CRC is unnecessary. This will disable binary search seeking. When seeking, the seek table will
-  be used if available. Otherwise the seek will be performed using brute force.
-
-#define DR_FLAC_NO_SIMD
-  Disables SIMD optimizations (SSE on x86/x64 architectures, NEON on ARM architectures). Use this if you are having compatibility issues with your compiler.
-
-
-
-Notes
-=====
-- dr_flac does not support changing the sample rate nor channel count mid stream.
-- dr_flac is not thread-safe, but its APIs can be called from any thread so long as you do your own synchronization.
-- When using Ogg encapsulation, a corrupted metadata block will result in `drflac_open_with_metadata()` and `drflac_open()` returning inconsistent samples due
-  to differences in corrupted stream recorvery logic between the two APIs.
-*/
-
-#ifndef dr_flac_h
-#define dr_flac_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRFLAC_STRINGIFY(x)      #x
-#define DRFLAC_XSTRINGIFY(x)     DRFLAC_STRINGIFY(x)
-
-#define DRFLAC_VERSION_MAJOR     0
-#define DRFLAC_VERSION_MINOR     12
-#define DRFLAC_VERSION_REVISION  29
-#define DRFLAC_VERSION_STRING    DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drflac_int8;
-typedef unsigned char           drflac_uint8;
-typedef   signed short          drflac_int16;
-typedef unsigned short          drflac_uint16;
-typedef   signed int            drflac_int32;
-typedef unsigned int            drflac_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drflac_int64;
-    typedef unsigned __int64    drflac_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drflac_int64;
-    typedef unsigned long long  drflac_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drflac_uint64       drflac_uintptr;
-#else
-    typedef drflac_uint32       drflac_uintptr;
-#endif
-typedef drflac_uint8            drflac_bool8;
-typedef drflac_uint32           drflac_bool32;
-#define DRFLAC_TRUE             1
-#define DRFLAC_FALSE            0
-
-#if !defined(DRFLAC_API)
-    #if defined(DRFLAC_DLL)
-        #if defined(_WIN32)
-            #define DRFLAC_DLL_IMPORT  __declspec(dllimport)
-            #define DRFLAC_DLL_EXPORT  __declspec(dllexport)
-            #define DRFLAC_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRFLAC_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRFLAC_DLL_IMPORT
-                #define DRFLAC_DLL_EXPORT
-                #define DRFLAC_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-            #define DRFLAC_API  DRFLAC_DLL_EXPORT
-        #else
-            #define DRFLAC_API  DRFLAC_DLL_IMPORT
-        #endif
-        #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
-    #else
-        #define DRFLAC_API extern
-        #define DRFLAC_PRIVATE static
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1700   /* Visual Studio 2012 */
-    #define DRFLAC_DEPRECATED       __declspec(deprecated)
-#elif (defined(__GNUC__) && __GNUC__ >= 4)  /* GCC 4 */
-    #define DRFLAC_DEPRECATED       __attribute__((deprecated))
-#elif defined(__has_feature)                /* Clang */
-    #if __has_feature(attribute_deprecated)
-        #define DRFLAC_DEPRECATED   __attribute__((deprecated))
-    #else
-        #define DRFLAC_DEPRECATED
-    #endif
-#else
-    #define DRFLAC_DEPRECATED
-#endif
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
-DRFLAC_API const char* drflac_version_string(void);
-
-/*
-As data is read from the client it is placed into an internal buffer for fast access. This controls the size of that buffer. Larger values means more speed,
-but also more memory. In my testing there is diminishing returns after about 4KB, but you can fiddle with this to suit your own needs. Must be a multiple of 8.
-*/
-#ifndef DR_FLAC_BUFFER_SIZE
-#define DR_FLAC_BUFFER_SIZE   4096
-#endif
-
-/* Check if we can enable 64-bit optimizations. */
-#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-#define DRFLAC_64BIT
-#endif
-
-#ifdef DRFLAC_64BIT
-typedef drflac_uint64 drflac_cache_t;
-#else
-typedef drflac_uint32 drflac_cache_t;
-#endif
-
-/* The various metadata block types. */
-#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO       0
-#define DRFLAC_METADATA_BLOCK_TYPE_PADDING          1
-#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION      2
-#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE        3
-#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT   4
-#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET         5
-#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE          6
-#define DRFLAC_METADATA_BLOCK_TYPE_INVALID          127
-
-/* The various picture types specified in the PICTURE block. */
-#define DRFLAC_PICTURE_TYPE_OTHER                   0
-#define DRFLAC_PICTURE_TYPE_FILE_ICON               1
-#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON         2
-#define DRFLAC_PICTURE_TYPE_COVER_FRONT             3
-#define DRFLAC_PICTURE_TYPE_COVER_BACK              4
-#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE            5
-#define DRFLAC_PICTURE_TYPE_MEDIA                   6
-#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST             7
-#define DRFLAC_PICTURE_TYPE_ARTIST                  8
-#define DRFLAC_PICTURE_TYPE_CONDUCTOR               9
-#define DRFLAC_PICTURE_TYPE_BAND                    10
-#define DRFLAC_PICTURE_TYPE_COMPOSER                11
-#define DRFLAC_PICTURE_TYPE_LYRICIST                12
-#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION      13
-#define DRFLAC_PICTURE_TYPE_DURING_RECORDING        14
-#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE      15
-#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE          16
-#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH     17
-#define DRFLAC_PICTURE_TYPE_ILLUSTRATION            18
-#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE           19
-#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE      20
-
-typedef enum
-{
-    drflac_container_native,
-    drflac_container_ogg,
-    drflac_container_unknown
-} drflac_container;
-
-typedef enum
-{
-    drflac_seek_origin_start,
-    drflac_seek_origin_current
-} drflac_seek_origin;
-
-/* Packing is important on this structure because we map this directly to the raw data within the SEEKTABLE metadata block. */
-#pragma pack(2)
-typedef struct
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 flacFrameOffset;   /* The offset from the first byte of the header of the first frame. */
-    drflac_uint16 pcmFrameCount;
-} drflac_seekpoint;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint16 minBlockSizeInPCMFrames;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint32 minFrameSizeInPCMFrames;
-    drflac_uint32 maxFrameSizeInPCMFrames;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint8  md5[16];
-} drflac_streaminfo;
-
-typedef struct
-{
-    /*
-    The metadata type. Use this to know how to interpret the data below. Will be set to one of the
-    DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-    */
-    drflac_uint32 type;
-
-    /*
-    A pointer to the raw data. This points to a temporary buffer so don't hold on to it. It's best to
-    not modify the contents of this buffer. Use the structures below for more meaningful and structured
-    information about the metadata. It's possible for this to be null.
-    */
-    const void* pRawData;
-
-    /* The size in bytes of the block and the buffer pointed to by pRawData if it's non-NULL. */
-    drflac_uint32 rawDataSize;
-
-    union
-    {
-        drflac_streaminfo streaminfo;
-
-        struct
-        {
-            int unused;
-        } padding;
-
-        struct
-        {
-            drflac_uint32 id;
-            const void* pData;
-            drflac_uint32 dataSize;
-        } application;
-
-        struct
-        {
-            drflac_uint32 seekpointCount;
-            const drflac_seekpoint* pSeekpoints;
-        } seektable;
-
-        struct
-        {
-            drflac_uint32 vendorLength;
-            const char* vendor;
-            drflac_uint32 commentCount;
-            const void* pComments;
-        } vorbis_comment;
-
-        struct
-        {
-            char catalog[128];
-            drflac_uint64 leadInSampleCount;
-            drflac_bool32 isCD;
-            drflac_uint8 trackCount;
-            const void* pTrackData;
-        } cuesheet;
-
-        struct
-        {
-            drflac_uint32 type;
-            drflac_uint32 mimeLength;
-            const char* mime;
-            drflac_uint32 descriptionLength;
-            const char* description;
-            drflac_uint32 width;
-            drflac_uint32 height;
-            drflac_uint32 colorDepth;
-            drflac_uint32 indexColorCount;
-            drflac_uint32 pictureDataSize;
-            const drflac_uint8* pPictureData;
-        } picture;
-    } data;
-} drflac_metadata;
-
-
-/*
-Callback for when data needs to be read from the client.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pBufferOut (out)
-    The output buffer.
-
-bytesToRead (in)
-    The number of bytes to read.
-
-
-Return Value
-------------
-The number of bytes actually read.
-
-
-Remarks
--------
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until either the entire bytesToRead is filled or
-you have reached the end of the stream.
-*/
-typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data needs to be seeked.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-offset (in)
-    The number of bytes to move, relative to the origin. Will never be negative.
-
-origin (in)
-    The origin of the seek - the current position or the start of the stream.
-
-
-Return Value
-------------
-Whether or not the seek was successful.
-
-
-Remarks
--------
-The offset will never be negative. Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be
-either drflac_seek_origin_start or drflac_seek_origin_current.
-
-When seeking to a PCM frame using drflac_seek_to_pcm_frame(), dr_flac may call this with an offset beyond the end of the FLAC stream. This needs to be detected
-and handled by returning DRFLAC_FALSE.
-*/
-typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
-
-/*
-Callback for when a metadata block is read.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pMetadata (in)
-    A pointer to a structure containing the data of the metadata block.
-
-
-Remarks
--------
-Use pMetadata->type to determine which metadata block is being handled and how to read the data. This
-will be set to one of the DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-*/
-typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
-
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drflac_allocation_callbacks;
-
-/* Structure for internal use. Only used for decoders opened with drflac_open_memory. */
-typedef struct
-{
-    const drflac_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drflac__memory_stream;
-
-/* Structure for internal use. Used for bit streaming. */
-typedef struct
-{
-    /* The function to call when more data needs to be read. */
-    drflac_read_proc onRead;
-
-    /* The function to call when the current read position needs to be moved. */
-    drflac_seek_proc onSeek;
-
-    /* The user data to pass around to onRead and onSeek. */
-    void* pUserData;
-
-
-    /*
-    The number of unaligned bytes in the L2 cache. This will always be 0 until the end of the stream is hit. At the end of the
-    stream there will be a number of bytes that don't cleanly fit in an L1 cache line, so we use this variable to know whether
-    or not the bistreamer needs to run on a slower path to read those last bytes. This will never be more than sizeof(drflac_cache_t).
-    */
-    size_t unalignedByteCount;
-
-    /* The content of the unaligned bytes. */
-    drflac_cache_t unalignedCache;
-
-    /* The index of the next valid cache line in the "L2" cache. */
-    drflac_uint32 nextL2Line;
-
-    /* The number of bits that have been consumed by the cache. This is used to determine how many valid bits are remaining. */
-    drflac_uint32 consumedBits;
-
-    /*
-    The cached data which was most recently read from the client. There are two levels of cache. Data flows as such:
-    Client -> L2 -> L1. The L2 -> L1 movement is aligned and runs on a fast path in just a few instructions.
-    */
-    drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
-    drflac_cache_t cache;
-
-    /*
-    CRC-16. This is updated whenever bits are read from the bit stream. Manually set this to 0 to reset the CRC. For FLAC, this
-    is reset to 0 at the beginning of each frame.
-    */
-    drflac_uint16 crc16;
-    drflac_cache_t crc16Cache;              /* A cache for optimizing CRC calculations. This is filled when when the L1 cache is reloaded. */
-    drflac_uint32 crc16CacheIgnoredBytes;   /* The number of bytes to ignore when updating the CRC-16 from the CRC-16 cache. */
-} drflac_bs;
-
-typedef struct
-{
-    /* The type of the subframe: SUBFRAME_CONSTANT, SUBFRAME_VERBATIM, SUBFRAME_FIXED or SUBFRAME_LPC. */
-    drflac_uint8 subframeType;
-
-    /* The number of wasted bits per sample as specified by the sub-frame header. */
-    drflac_uint8 wastedBitsPerSample;
-
-    /* The order to use for the prediction stage for SUBFRAME_FIXED and SUBFRAME_LPC. */
-    drflac_uint8 lpcOrder;
-
-    /* A pointer to the buffer containing the decoded samples in the subframe. This pointer is an offset from drflac::pExtraData. */
-    drflac_int32* pSamplesS32;
-} drflac_subframe;
-
-typedef struct
-{
-    /*
-    If the stream uses variable block sizes, this will be set to the index of the first PCM frame. If fixed block sizes are used, this will
-    always be set to 0. This is 64-bit because the decoded PCM frame number will be 36 bits.
-    */
-    drflac_uint64 pcmFrameNumber;
-
-    /*
-    If the stream uses fixed block sizes, this will be set to the frame number. If variable block sizes are used, this will always be 0. This
-    is 32-bit because in fixed block sizes, the maximum frame number will be 31 bits.
-    */
-    drflac_uint32 flacFrameNumber;
-
-    /* The sample rate of this frame. */
-    drflac_uint32 sampleRate;
-
-    /* The number of PCM frames in each sub-frame within this frame. */
-    drflac_uint16 blockSizeInPCMFrames;
-
-    /*
-    The channel assignment of this frame. This is not always set to the channel count. If interchannel decorrelation is being used this
-    will be set to DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE, DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE or DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE.
-    */
-    drflac_uint8 channelAssignment;
-
-    /* The number of bits per sample within this frame. */
-    drflac_uint8 bitsPerSample;
-
-    /* The frame's CRC. */
-    drflac_uint8 crc8;
-} drflac_frame_header;
-
-typedef struct
-{
-    /* The header. */
-    drflac_frame_header header;
-
-    /*
-    The number of PCM frames left to be read in this FLAC frame. This is initially set to the block size. As PCM frames are read,
-    this will be decremented. When it reaches 0, the decoder will see this frame as fully consumed and load the next frame.
-    */
-    drflac_uint32 pcmFramesRemaining;
-
-    /* The list of sub-frames within the frame. There is one sub-frame for each channel, and there's a maximum of 8 channels. */
-    drflac_subframe subframes[8];
-} drflac_frame;
-
-typedef struct
-{
-    /* The function to call when a metadata block is read. */
-    drflac_meta_proc onMeta;
-
-    /* The user data posted to the metadata callback function. */
-    void* pUserDataMD;
-
-    /* Memory allocation callbacks. */
-    drflac_allocation_callbacks allocationCallbacks;
-
-
-    /* The sample rate. Will be set to something like 44100. */
-    drflac_uint32 sampleRate;
-
-    /*
-    The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. Maximum 8. This is set based on the
-    value specified in the STREAMINFO block.
-    */
-    drflac_uint8 channels;
-
-    /* The bits per sample. Will be set to something like 16, 24, etc. */
-    drflac_uint8 bitsPerSample;
-
-    /* The maximum block size, in samples. This number represents the number of samples in each channel (not combined). */
-    drflac_uint16 maxBlockSizeInPCMFrames;
-
-    /*
-    The total number of PCM Frames making up the stream. Can be 0 in which case it's still a valid stream, but just means
-    the total PCM frame count is unknown. Likely the case with streams like internet radio.
-    */
-    drflac_uint64 totalPCMFrameCount;
-
-
-    /* The container type. This is set based on whether or not the decoder was opened from a native or Ogg stream. */
-    drflac_container container;
-
-    /* The number of seekpoints in the seektable. */
-    drflac_uint32 seekpointCount;
-
-
-    /* Information about the frame the decoder is currently sitting on. */
-    drflac_frame currentFLACFrame;
-
-
-    /* The index of the PCM frame the decoder is currently sitting on. This is only used for seeking. */
-    drflac_uint64 currentPCMFrame;
-
-    /* The position of the first FLAC frame in the stream. This is only ever used for seeking. */
-    drflac_uint64 firstFLACFramePosInBytes;
-
-
-    /* A hack to avoid a malloc() when opening a decoder with drflac_open_memory(). */
-    drflac__memory_stream memoryStream;
-
-
-    /* A pointer to the decoded sample data. This is an offset of pExtraData. */
-    drflac_int32* pDecodedSamples;
-
-    /* A pointer to the seek table. This is an offset of pExtraData, or NULL if there is no seek table. */
-    drflac_seekpoint* pSeekpoints;
-
-    /* Internal use only. Only used with Ogg containers. Points to a drflac_oggbs object. This is an offset of pExtraData. */
-    void* _oggbs;
-
-    /* Internal use only. Used for profiling and testing different seeking modes. */
-    drflac_bool32 _noSeekTableSeek    : 1;
-    drflac_bool32 _noBinarySearchSeek : 1;
-    drflac_bool32 _noBruteForceSeek   : 1;
-
-    /* The bit streamer. The raw FLAC data is fed through this object. */
-    drflac_bs bs;
-
-    /* Variable length extra data. We attach this to the end of the object so we can avoid unnecessary mallocs. */
-    drflac_uint8 pExtraData[1];
-} drflac;
-
-
-/*
-Opens a FLAC decoder.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-Returns a pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This function will automatically detect whether or not you are attempting to open a native or Ogg encapsulated FLAC, both of which should work seamlessly
-without any manual intervention. Ogg encapsulation also works with multiplexed streams which basically means it can play FLAC encoded audio tracks in videos.
-
-This is the lowest level function for opening a FLAC stream. You can also use `drflac_open_file()` and `drflac_open_memory()` to open the stream from a file or
-from a block of memory respectively.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_relaxed()` to open a FLAC stream where the header may not be present.
-
-Use `drflac_open_with_metadata()` if you need access to metadata.
-
-
-Seek Also
----------
-drflac_open_file()
-drflac_open_memory()
-drflac_open_with_metadata()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC stream with relaxed validation of the header block.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-container (in)
-    Whether or not the FLAC stream is encapsulated using standard FLAC encapsulation or Ogg encapsulation.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-The same as drflac_open(), except attempts to open the stream even when a header block is not present.
-
-Because the header is not necessarily available, the caller must explicitly define the container (Native or Ogg). Do not set this to `drflac_container_unknown`
-as that is for internal use only.
-
-Opening in relaxed mode will continue reading data from onRead until it finds a valid frame. If a frame is never found it will continue forever. To abort,
-force your `onRead` callback to return 0, which dr_flac will use as an indicator that the end of the stream was found.
-
-Use `drflac_open_with_metadata_relaxed()` if you need access to metadata.
-*/
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder and notifies the caller of the metadata chunks (album art, etc.).
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-onMeta (in)
-    The function to call for every metadata block.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead, onSeek and onMeta.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This is slower than `drflac_open()`, so avoid this one if you don't need metadata. Internally, this will allocate and free memory on the heap for every
-metadata block except for STREAMINFO and PADDING blocks.
-
-The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns. This callback takes a
-pointer to a `drflac_metadata` object which is a union containing the data of all relevant metadata blocks. Use the `type` member to discriminate against
-the different metadata types.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_with_metadata_relaxed()` to open a FLAC stream where the header may not be present.
-
-Note that this will behave inconsistently with `drflac_open()` if the stream is an Ogg encapsulated stream and a metadata block is corrupted. This is due to
-the way the Ogg stream recovers from corrupted pages. When `drflac_open_with_metadata()` is being used, the open routine will try to read the contents of the
-metadata block, whereas `drflac_open()` will simply seek past it (for the sake of efficiency). This inconsistency can result in different samples being
-returned depending on whether or not the stream is being opened with metadata.
-
-
-Seek Also
----------
-drflac_open_file_with_metadata()
-drflac_open_memory_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-The same as drflac_open_with_metadata(), except attempts to open the stream even when a header block is not present.
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open_relaxed()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Closes the given FLAC decoder.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder to close.
-
-
-Remarks
--------
-This will destroy the decoder object.
-
-
-See Also
---------
-drflac_open()
-drflac_open_with_metadata()
-drflac_open_file()
-drflac_open_file_w()
-drflac_open_file_with_metadata()
-drflac_open_file_with_metadata_w()
-drflac_open_memory()
-drflac_open_memory_with_metadata()
-*/
-DRFLAC_API void drflac_close(drflac* pFlac);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 32-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 16-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this is lossy for streams where the bits per sample is larger than 16.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved 32-bit floating point PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this should be considered lossy due to the nature of floating point numbers not being able to exactly represent every possible number.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
-
-/*
-Seeks to the PCM frame at the given index.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-pcmFrameIndex (in)
-    The index of the PCM frame to seek to. See notes below.
-
-
-Return Value
--------------
-`DRFLAC_TRUE` if successful; `DRFLAC_FALSE` otherwise.
-*/
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-/*
-Opens a FLAC decoder from the file at the given path.
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with drflac_close().
-
-
-Remarks
--------
-This will hold a handle to the file until the decoder is closed with drflac_close(). Some platforms will restrict the number of files a process can have open
-at any given time, so keep this mind if you have many decoders open at the same time.
-
-
-See Also
---------
-drflac_open_file_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from the file at the given path and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for the lifetime of the decoder.
-
-
-See Also
---------
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
--------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-
-/* High Level APIs */
-
-/*
-Opens a FLAC stream from the given callbacks and fully decodes it in a single operation. The return value is a
-pointer to the sample data as interleaved signed 32-bit PCM. The returned data must be freed with drflac_free().
-
-You can pass in custom memory allocation callbacks via the pAllocationCallbacks parameter. This can be NULL in which
-case it will use DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-
-Sometimes a FLAC file won't keep track of the total sample count. In this situation the function will continuously
-read samples into a dynamically sized buffer on the heap until no samples are left.
-
-Do not call this function on a broadcast type of stream (like internet radio streams and whatnot).
-*/
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_FLAC_NO_STDIO
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a file. */
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a block of memory. */
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Frees memory that was allocated internally by dr_flac.
-
-Set pAllocationCallbacks to the same object that was passed to drflac_open_*_and_read_pcm_frames_*(). If you originally passed in NULL, pass in NULL for this.
-*/
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-/* Structure representing an iterator for vorbis comments in a VORBIS_COMMENT metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_vorbis_comment_iterator;
-
-/*
-Initializes a vorbis comment iterator. This can be used for iterating over the vorbis comments in a VORBIS_COMMENT
-metadata block.
-*/
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
-
-/*
-Goes to the next vorbis comment in the given iterator. If null is returned it means there are no more comments. The
-returned string is NOT null terminated.
-*/
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
-
-
-/* Structure representing an iterator for cuesheet tracks in a CUESHEET metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_cuesheet_track_iterator;
-
-/* Packing is important on this structure because we map this directly to the raw data within the CUESHEET metadata block. */
-#pragma pack(4)
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 index;
-    drflac_uint8 reserved[3];
-} drflac_cuesheet_track_index;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 trackNumber;
-    char ISRC[12];
-    drflac_bool8 isAudio;
-    drflac_bool8 preEmphasis;
-    drflac_uint8 indexCount;
-    const drflac_cuesheet_track_index* pIndexPoints;
-} drflac_cuesheet_track;
-
-/*
-Initializes a cuesheet track iterator. This can be used for iterating over the cuesheet tracks in a CUESHEET metadata
-block.
-*/
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
-
-/* Goes to the next cuesheet track in the given iterator. If DRFLAC_FALSE is returned it means there are no more comments. */
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_flac_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-#ifndef dr_flac_c
-#define dr_flac_c
-
-/* Disable some annoying warnings. */
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #if __GNUC__ >= 7
-    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-    #endif
-#endif
-
-#ifdef __linux__
-    #ifndef _BSD_SOURCE
-        #define _BSD_SOURCE
-    #endif
-    #ifndef _DEFAULT_SOURCE
-        #define _DEFAULT_SOURCE
-    #endif
-    #ifndef __USE_BSD
-        #define __USE_BSD
-    #endif
-    #include <endian.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _MSC_VER
-    #define DRFLAC_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRFLAC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRFLAC_INLINE __inline
-#else
-    #define DRFLAC_INLINE
-#endif
-
-/* CPU architecture. */
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRFLAC_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
-    #define DRFLAC_ARM
-#endif
-
-/*
-Intrinsics Support
-
-There's a bug in GCC 4.2.x which results in an incorrect compilation error when using _mm_slli_epi32() where it complains with
-
-    "error: shift must be an immediate"
-
-Unfortuantely dr_flac depends on this for a few things so we're just going to disable SSE on GCC 4.2 and below.
-*/
-#if !defined(DR_FLAC_NO_SIMD)
-    #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
-        #if defined(_MSC_VER) && !defined(__clang__)
-            /* MSVC. */
-            #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2)    /* 2005 */
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41)   /* 2010 */
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
-            /* Assume GNUC-style. */
-            #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_SSE41)
-            #include <smmintrin.h>
-        #elif defined(DRFLAC_SUPPORT_SSE2)
-            #include <emmintrin.h>
-        #endif
-    #endif
-
-    #if defined(DRFLAC_ARM)
-        #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            #define DRFLAC_SUPPORT_NEON
-        #endif
-
-        /* Fall back to looking for the #include file. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include(<arm_neon.h>)
-                #define DRFLAC_SUPPORT_NEON
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_NEON)
-            #include <arm_neon.h>
-        #endif
-    #endif
-#endif
-
-/* Compile-time CPU feature support. */
-#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #else
-        #if defined(__GNUC__) || defined(__clang__)
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                /*
-                It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
-                specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
-                supporting different assembly dialects.
-
-                What's basically happening is that we're saving and restoring the ebx register manually.
-                */
-                #if defined(DRFLAC_X86) && defined(__PIC__)
-                    __asm__ __volatile__ (
-                        "xchg{l} {%%}ebx, %k1;"
-                        "cpuid;"
-                        "xchg{l} {%%}ebx, %k1;"
-                        : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #else
-                    __asm__ __volatile__ (
-                        "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #endif
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #endif
-#else
-    #define DRFLAC_NO_CPUID
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE2. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE4.1. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE41 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[2] & (1 << 19)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE41 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
-            #define DRFLAC_HAS_LZCNT_INTRINSIC
-        #endif
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#elif defined(__WATCOMC__) && defined(__386__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
-    extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
-    extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
-#pragma aux _watcom_bswap16 = \
-    "xchg al, ah" \
-    parm   [ax]   \
-    modify [ax];
-#pragma aux _watcom_bswap32 = \
-    "bswap eax"  \
-    parm   [eax] \
-    modify [eax];
-#pragma aux _watcom_bswap64 = \
-    "bswap eax"     \
-    "bswap edx"     \
-    "xchg eax,edx"  \
-    parm [eax edx]  \
-    modify [eax edx];
-#endif
-
-
-/* Standard library stuff. */
-#ifndef DRFLAC_ASSERT
-#include <assert.h>
-#define DRFLAC_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRFLAC_MALLOC
-#define DRFLAC_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRFLAC_REALLOC
-#define DRFLAC_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRFLAC_FREE
-#define DRFLAC_FREE(p)                      free((p))
-#endif
-#ifndef DRFLAC_COPY_MEMORY
-#define DRFLAC_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRFLAC_ZERO_MEMORY
-#define DRFLAC_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRFLAC_ZERO_OBJECT
-#define DRFLAC_ZERO_OBJECT(p)               DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
-#endif
-
-#define DRFLAC_MAX_SIMD_VECTOR_SIZE                     64  /* 64 for AVX-512 in the future. */
-
-typedef drflac_int32 drflac_result;
-#define DRFLAC_SUCCESS                                   0
-#define DRFLAC_ERROR                                    -1   /* A generic error. */
-#define DRFLAC_INVALID_ARGS                             -2
-#define DRFLAC_INVALID_OPERATION                        -3
-#define DRFLAC_OUT_OF_MEMORY                            -4
-#define DRFLAC_OUT_OF_RANGE                             -5
-#define DRFLAC_ACCESS_DENIED                            -6
-#define DRFLAC_DOES_NOT_EXIST                           -7
-#define DRFLAC_ALREADY_EXISTS                           -8
-#define DRFLAC_TOO_MANY_OPEN_FILES                      -9
-#define DRFLAC_INVALID_FILE                             -10
-#define DRFLAC_TOO_BIG                                  -11
-#define DRFLAC_PATH_TOO_LONG                            -12
-#define DRFLAC_NAME_TOO_LONG                            -13
-#define DRFLAC_NOT_DIRECTORY                            -14
-#define DRFLAC_IS_DIRECTORY                             -15
-#define DRFLAC_DIRECTORY_NOT_EMPTY                      -16
-#define DRFLAC_END_OF_FILE                              -17
-#define DRFLAC_NO_SPACE                                 -18
-#define DRFLAC_BUSY                                     -19
-#define DRFLAC_IO_ERROR                                 -20
-#define DRFLAC_INTERRUPT                                -21
-#define DRFLAC_UNAVAILABLE                              -22
-#define DRFLAC_ALREADY_IN_USE                           -23
-#define DRFLAC_BAD_ADDRESS                              -24
-#define DRFLAC_BAD_SEEK                                 -25
-#define DRFLAC_BAD_PIPE                                 -26
-#define DRFLAC_DEADLOCK                                 -27
-#define DRFLAC_TOO_MANY_LINKS                           -28
-#define DRFLAC_NOT_IMPLEMENTED                          -29
-#define DRFLAC_NO_MESSAGE                               -30
-#define DRFLAC_BAD_MESSAGE                              -31
-#define DRFLAC_NO_DATA_AVAILABLE                        -32
-#define DRFLAC_INVALID_DATA                             -33
-#define DRFLAC_TIMEOUT                                  -34
-#define DRFLAC_NO_NETWORK                               -35
-#define DRFLAC_NOT_UNIQUE                               -36
-#define DRFLAC_NOT_SOCKET                               -37
-#define DRFLAC_NO_ADDRESS                               -38
-#define DRFLAC_BAD_PROTOCOL                             -39
-#define DRFLAC_PROTOCOL_UNAVAILABLE                     -40
-#define DRFLAC_PROTOCOL_NOT_SUPPORTED                   -41
-#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED            -42
-#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED             -43
-#define DRFLAC_SOCKET_NOT_SUPPORTED                     -44
-#define DRFLAC_CONNECTION_RESET                         -45
-#define DRFLAC_ALREADY_CONNECTED                        -46
-#define DRFLAC_NOT_CONNECTED                            -47
-#define DRFLAC_CONNECTION_REFUSED                       -48
-#define DRFLAC_NO_HOST                                  -49
-#define DRFLAC_IN_PROGRESS                              -50
-#define DRFLAC_CANCELLED                                -51
-#define DRFLAC_MEMORY_ALREADY_MAPPED                    -52
-#define DRFLAC_AT_END                                   -53
-#define DRFLAC_CRC_MISMATCH                             -128
-
-#define DRFLAC_SUBFRAME_CONSTANT                        0
-#define DRFLAC_SUBFRAME_VERBATIM                        1
-#define DRFLAC_SUBFRAME_FIXED                           8
-#define DRFLAC_SUBFRAME_LPC                             32
-#define DRFLAC_SUBFRAME_RESERVED                        255
-
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE  0
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
-
-#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT           0
-#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE             8
-#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE            9
-#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE              10
-
-#define drflac_align(x, a)                              ((((x) + (a) - 1) / (a)) * (a))
-
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRFLAC_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRFLAC_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRFLAC_VERSION_REVISION;
-    }
-}
-
-DRFLAC_API const char* drflac_version_string(void)
-{
-    return DRFLAC_VERSION_STRING;
-}
-
-
-/* CPU caps. */
-#if defined(__has_feature)
-    #if __has_feature(thread_sanitizer)
-        #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
-    #else
-        #define DRFLAC_NO_THREAD_SANITIZE
-    #endif
-#else
-    #define DRFLAC_NO_THREAD_SANITIZE
-#endif
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
-#endif
-
-#ifndef DRFLAC_NO_CPUID
-static drflac_bool32 drflac__gIsSSE2Supported  = DRFLAC_FALSE;
-static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
-
-/*
-I've had a bug report that Clang's ThreadSanitizer presents a warning in this function. Having reviewed this, this does
-actually make sense. However, since CPU caps should never differ for a running process, I don't think the trade off of
-complicating internal API's by passing around CPU caps versus just disabling the warnings is worthwhile. I'm therefore
-just going to disable these warnings. This is disabled via the DRFLAC_NO_THREAD_SANITIZE attribute.
-*/
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
-
-    if (!isCPUCapsInitialized) {
-        /* LZCNT */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-        int info[4] = {0};
-        drflac__cpuid(info, 0x80000001);
-        drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
-#endif
-
-        /* SSE2 */
-        drflac__gIsSSE2Supported = drflac_has_sse2();
-
-        /* SSE4.1 */
-        drflac__gIsSSE41Supported = drflac_has_sse41();
-
-        /* Initialized. */
-        isCPUCapsInitialized = DRFLAC_TRUE;
-    }
-}
-#else
-static drflac_bool32 drflac__gIsNEONSupported  = DRFLAC_FALSE;
-
-static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
-{
-#if defined(DRFLAC_SUPPORT_NEON)
-    #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate NEON code we can assume support. */
-        #else
-            /* TODO: Runtime check. */
-            return DRFLAC_FALSE;
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* NEON is only supported on ARM architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    drflac__gIsNEONSupported = drflac__has_neon();
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    drflac__gIsLZCNTSupported = DRFLAC_TRUE;
-#endif
-}
-#endif
-
-
-/* Endian Management */
-static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
-{
-#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
-    return DRFLAC_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRFLAC_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRFLAC_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            drflac_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRFLAC_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap32(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-    return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drflac_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drflac_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drflac_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drflac_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drflac_uint64)0x000000FF      )) << 56);
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint16(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint64(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
-{
-    if (!drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
-{
-    drflac_uint32 result = 0;
-    result |= (n & 0x7F000000) >> 3;
-    result |= (n & 0x007F0000) >> 2;
-    result |= (n & 0x00007F00) >> 1;
-    result |= (n & 0x0000007F) >> 0;
-
-    return result;
-}
-
-
-
-/* The CRC code below is based on this document: http://zlib.net/crc_v3.txt */
-static drflac_uint8 drflac__crc8_table[] = {
-    0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
-    0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
-    0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
-    0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
-    0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
-    0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
-    0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
-    0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
-    0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
-    0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
-    0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
-    0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
-    0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
-    0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
-    0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
-    0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-
-static drflac_uint16 drflac__crc16_table[] = {
-    0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
-    0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
-    0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
-    0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
-    0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
-    0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
-    0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
-    0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
-    0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
-    0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
-    0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
-    0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
-    0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
-    0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
-    0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
-    0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
-    0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
-    0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
-    0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
-    0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
-    0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
-    0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
-    0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
-    0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
-    0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
-    0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
-    0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
-    0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
-    0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
-    0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
-    0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
-    0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
-};
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
-{
-    return drflac__crc8_table[crc ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc8(crc, 0, 8);") */
-    drflac_uint8 p = 0x07;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint8 bit = (data & (1 << i)) >> i;
-        if (crc & 0x80) {
-            crc = ((crc << 1) | bit) ^ p;
-        } else {
-            crc = ((crc << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 32);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count - (wholeBytes*8);
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
-{
-    return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
-{
-#ifdef DRFLAC_64BIT
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-
-    return crc;
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
-{
-    switch (byteCount)
-    {
-#ifdef DRFLAC_64BIT
-    case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    }
-
-    return crc;
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc16(crc, 0, 16);") */
-    drflac_uint16 p = 0x8005;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint16 bit = (data & (1ULL << i)) >> i;
-        if (r & 0x8000) {
-            r = ((r << 1) | bit) ^ p;
-        } else {
-            r = ((r << 1) | bit);
-        }
-    }
-
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits)));    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-        case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
-        case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
-        case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000      ) << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000      ) << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00      ) << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF      ) << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
-{
-#ifdef DRFLAC_64BIT
-    return drflac_crc16__64bit(crc, data, count);
-#else
-    return drflac_crc16__32bit(crc, data, count);
-#endif
-}
-#endif
-
-
-#ifdef DRFLAC_64BIT
-#define drflac__be2host__cache_line drflac__be2host_64
-#else
-#define drflac__be2host__cache_line drflac__be2host_32
-#endif
-
-/*
-BIT READING ATTEMPT #2
-
-This uses a 32- or 64-bit bit-shifted cache - as bits are read, the cache is shifted such that the first valid bit is sitting
-on the most significant bit. It uses the notion of an L1 and L2 cache (borrowed from CPU architecture), where the L1 cache
-is a 32- or 64-bit unsigned integer (depending on whether or not a 32- or 64-bit build is being compiled) and the L2 is an
-array of "cache lines", with each cache line being the same size as the L1. The L2 is a buffer of about 4KB and is where data
-from onRead() is read into.
-*/
-#define DRFLAC_CACHE_L1_SIZE_BYTES(bs)                      (sizeof((bs)->cache))
-#define DRFLAC_CACHE_L1_SIZE_BITS(bs)                       (sizeof((bs)->cache)*8)
-#define DRFLAC_CACHE_L1_BITS_REMAINING(bs)                  (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
-#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount)           (~((~(drflac_cache_t)0) >> (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount)      (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
-#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount)               (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount)     (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >>  DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
-#define DRFLAC_CACHE_L2_SIZE_BYTES(bs)                      (sizeof((bs)->cacheL2))
-#define DRFLAC_CACHE_L2_LINE_COUNT(bs)                      (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
-#define DRFLAC_CACHE_L2_LINES_REMAINING(bs)                 (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
-
-
-#ifndef DR_FLAC_NO_CRC
-static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
-{
-    bs->crc16 = 0;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-}
-
-static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
-{
-    if (bs->crc16CacheIgnoredBytes == 0) {
-        bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = 0;
-    }
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
-{
-    /* We should never be flushing in a situation where we are not aligned on a byte boundary. */
-    DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
-
-    /*
-    The bits that were read from the L1 cache need to be accumulated. The number of bytes needing to be accumulated is determined
-    by the number of bits that have been consumed.
-    */
-    if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
-        drflac__update_crc16(bs);
-    } else {
-        /* We only accumulate the consumed bits. */
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
-
-        /*
-        The bits that we just accumulated should never be accumulated again. We need to keep track of how many bytes were accumulated
-        so we can handle that later.
-        */
-        bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-    }
-
-    return bs->crc16;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
-{
-    size_t bytesRead;
-    size_t alignedL1LineCount;
-
-    /* Fast path. Try loading straight from L2. */
-    if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we get here it means we've run out of data in the L2 cache. We'll need to fetch more from the client, if there's
-    any left.
-    */
-    if (bs->unalignedByteCount > 0) {
-        return DRFLAC_FALSE;   /* If we have any unaligned bytes it means there's no more aligned bytes left in the client. */
-    }
-
-    bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
-
-    bs->nextL2Line = 0;
-    if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-
-    /*
-    If we get here it means we were unable to retrieve enough data to fill the entire L2 cache. It probably
-    means we've just reached the end of the file. We need to move the valid data down to the end of the buffer
-    and adjust the index of the next line accordingly. Also keep in mind that the L2 cache must be aligned to
-    the size of the L1 so we'll need to seek backwards by any misaligned bytes.
-    */
-    alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
-
-    /* We need to keep track of any unaligned bytes for later use. */
-    bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    if (bs->unalignedByteCount > 0) {
-        bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
-    }
-
-    if (alignedL1LineCount > 0) {
-        size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
-        size_t i;
-        for (i = alignedL1LineCount; i > 0; --i) {
-            bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
-        }
-
-        bs->nextL2Line = (drflac_uint32)offset;
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    } else {
-        /* If we get into this branch it means we weren't able to load any L1-aligned data. */
-        bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-        return DRFLAC_FALSE;
-    }
-}
-
-static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
-{
-    size_t bytesRead;
-
-#ifndef DR_FLAC_NO_CRC
-    drflac__update_crc16(bs);
-#endif
-
-    /* Fast path. Try just moving the next value in the L2 cache to the L1 cache. */
-    if (drflac__reload_l1_cache_from_l2(bs)) {
-        bs->cache = drflac__be2host__cache_line(bs->cache);
-        bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-        bs->crc16Cache = bs->cache;
-#endif
-        return DRFLAC_TRUE;
-    }
-
-    /* Slow path. */
-
-    /*
-    If we get here it means we have failed to load the L1 cache from the L2. Likely we've just reached the end of the stream and the last
-    few bytes did not meet the alignment requirements for the L2 cache. In this case we need to fall back to a slower path and read the
-    data from the unaligned cache.
-    */
-    bytesRead = bs->unalignedByteCount;
-    if (bytesRead == 0) {
-        bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- The stream has been exhausted, so marked the bits as consumed. */
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
-
-    bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
-    bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs));    /* <-- Make sure the consumed bits are always set to zero. Other parts of the library depend on this property. */
-    bs->unalignedByteCount = 0;     /* <-- At this point the unaligned bytes have been moved into the cache and we thus have no more unaligned bytes. */
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = bs->cache >> bs->consumedBits;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-#endif
-    return DRFLAC_TRUE;
-}
-
-static void drflac__reset_cache(drflac_bs* bs)
-{
-    bs->nextL2Line   = DRFLAC_CACHE_L2_LINE_COUNT(bs);  /* <-- This clears the L2 cache. */
-    bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- This clears the L1 cache. */
-    bs->cache = 0;
-    bs->unalignedByteCount = 0;                         /* <-- This clears the trailing unaligned bytes. */
-    bs->unalignedCache = 0;
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = 0;
-    bs->crc16CacheIgnoredBytes = 0;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResultOut != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        /*
-        If we want to load all 32-bits from a 32-bit cache we need to do it slightly differently because we can't do
-        a 32-bit shift on a 32-bit integer. This will never be the case on 64-bit caches, so we can have a slightly
-        more optimal solution for this.
-        */
-#ifdef DRFLAC_64BIT
-        *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-        bs->consumedBits += bitCount;
-        bs->cache <<= bitCount;
-#else
-        if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-            bs->consumedBits += bitCount;
-            bs->cache <<= bitCount;
-        } else {
-            /* Cannot shift by 32-bits, so need to do it differently. */
-            *pResultOut = (drflac_uint32)bs->cache;
-            bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-            bs->cache = 0;
-        }
-#endif
-
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        drflac_uint32 bitCountLo = bitCount - bitCountHi;
-        drflac_uint32 resultHi;
-
-        DRFLAC_ASSERT(bitCountHi > 0);
-        DRFLAC_ASSERT(bitCountHi < 32);
-        resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
-
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Do not attempt to shift by 32 as it's undefined. */
-    if (bitCount < 32) {
-        drflac_uint32 signbit;
-        signbit = ((result >> (bitCount-1)) & 0x01);
-        result |= (~signbit + 1) << bitCount;
-    }
-
-    *pResult = (drflac_int32)result;
-    return DRFLAC_TRUE;
-}
-
-#ifdef DRFLAC_64BIT
-static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
-{
-    drflac_uint32 resultHi;
-    drflac_uint32 resultLo;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-    DRFLAC_ASSERT(bitCount >  32);
-
-    if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (!drflac__read_uint32(bs, 32, &resultLo)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
-    return DRFLAC_TRUE;
-}
-#endif
-
-/* Function below is unused, but leaving it here in case I need to quickly add it again. */
-#if 0
-static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
-{
-    drflac_uint64 result;
-    drflac_uint64 signbit;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-
-    if (!drflac__read_uint64(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    signbit = ((result >> (bitCount-1)) & 0x01);
-    result |= (~signbit + 1) << bitCount;
-
-    *pResultOut = (drflac_int64)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint16)result;
-    return DRFLAC_TRUE;
-}
-
-#if 0
-static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int16)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint8)result;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int8)result;
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
-{
-    if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        bs->consumedBits += (drflac_uint32)bitsToSeek;
-        bs->cache <<= bitsToSeek;
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. This function isn't called too frequently so I'm favouring simplicity here. */
-        bitsToSeek       -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->cache         = 0;
-
-        /* Simple case. Seek in groups of the same number as bits that fit within a cache line. */
-#ifdef DRFLAC_64BIT
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint64 bin;
-            if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#else
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint32 bin;
-            if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#endif
-
-        /* Whole leftover bytes. */
-        while (bitsToSeek >= 8) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, 8, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= 8;
-        }
-
-        /* Leftover bits. */
-        if (bitsToSeek > 0) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek = 0; /* <-- Necessary for the assert below. */
-        }
-
-        DRFLAC_ASSERT(bitsToSeek == 0);
-        return DRFLAC_TRUE;
-    }
-}
-
-
-/* This function moves the bit streamer to the first bit after the sync code (bit 15 of the of the frame header). It will also update the CRC-16. */
-static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
-{
-    DRFLAC_ASSERT(bs != NULL);
-
-    /*
-    The sync code is always aligned to 8 bits. This is convenient for us because it means we can do byte-aligned movements. The first
-    thing to do is align to the next byte.
-    */
-    if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-        return DRFLAC_FALSE;
-    }
-
-    for (;;) {
-        drflac_uint8 hi;
-
-#ifndef DR_FLAC_NO_CRC
-        drflac__reset_crc16(bs);
-#endif
-
-        if (!drflac__read_uint8(bs, 8, &hi)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (hi == 0xFF) {
-            drflac_uint8 lo;
-            if (!drflac__read_uint8(bs, 6, &lo)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (lo == 0x3E) {
-                return DRFLAC_TRUE;
-            } else {
-                if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-
-    /* Should never get here. */
-    /*return DRFLAC_FALSE;*/
-}
-
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-#define DRFLAC_IMPLEMENT_CLZ_LZCNT
-#endif
-#if  defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
-#define DRFLAC_IMPLEMENT_CLZ_MSVC
-#endif
-#if  defined(__WATCOMC__) && defined(__386__)
-#define DRFLAC_IMPLEMENT_CLZ_WATCOM
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    static drflac_uint32 clz_table_4[] = {
-        0,
-        4,
-        3, 3,
-        2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1
-    };
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-    n = clz_table_4[x >> (sizeof(x)*8 - 4)];
-    if (n == 0) {
-#ifdef DRFLAC_64BIT
-        if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n  = 32; x <<= 32; }
-        if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
-        if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8;  x <<= 8;  }
-        if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4;  x <<= 4;  }
-#else
-        if ((x & 0xFFFF0000) == 0) { n  = 16; x <<= 16; }
-        if ((x & 0xFF000000) == 0) { n += 8;  x <<= 8;  }
-        if ((x & 0xF0000000) == 0) { n += 4;  x <<= 4;  }
-#endif
-        n += clz_table_4[x >> (sizeof(x)*8 - 4)];
-    }
-
-    return n - 1;
-}
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
-{
-    /* Fast compile time check for ARM. */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    return DRFLAC_TRUE;
-#else
-    /* If the compiler itself does not support the intrinsic then we'll need to return false. */
-    #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
-        return drflac__gIsLZCNTSupported;
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
-{
-    /*
-    It's critical for competitive decoding performance that this function be highly optimal. With MSVC we can use the __lzcnt64() and __lzcnt() intrinsics
-    to achieve good performance, however on GCC and Clang it's a little bit more annoying. The __builtin_clzl() and __builtin_clzll() intrinsics leave
-    it undefined as to the return value when `x` is 0. We need this to be well defined as returning 32 or 64, depending on whether or not it's a 32- or
-    64-bit build. To work around this we would need to add a conditional to check for the x = 0 case, but this creates unnecessary inefficiency. To work
-    around this problem I have written some inline assembly to emit the LZCNT (x86) or CLZ (ARM) instruction directly which removes the need to include
-    the conditional. This has worked well in the past, but for some reason Clang's MSVC compatible driver, clang-cl, does not seem to be handling this
-    in the same way as the normal Clang driver. It seems that `clang-cl` is just outputting the wrong results sometimes, maybe due to some register
-    getting clobbered?
-
-    I'm not sure if this is a bug with dr_flac's inlined assembly (most likely), a bug in `clang-cl` or just a misunderstanding on my part with inline
-    assembly rules for `clang-cl`. If somebody can identify an error in dr_flac's inlined assembly I'm happy to get that fixed.
-
-    Fortunately there is an easy workaround for this. Clang implements MSVC-specific intrinsics for compatibility. It also defines _MSC_VER for extra
-    compatibility. We can therefore just check for _MSC_VER and use the MSVC intrinsic which, fortunately for us, Clang supports. It would still be nice
-    to know how to fix the inlined assembly for correctness sake, however.
-    */
-
-#if defined(_MSC_VER) /*&& !defined(__clang__)*/    /* <-- Intentionally wanting Clang to use the MSVC __lzcnt64/__lzcnt intrinsics due to above ^. */
-    #ifdef DRFLAC_64BIT
-        return (drflac_uint32)__lzcnt64(x);
-    #else
-        return (drflac_uint32)__lzcnt(x);
-    #endif
-#else
-    #if defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_X64)
-            {
-                drflac_uint64 r;
-                __asm__ __volatile__ (
-                    "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return (drflac_uint32)r;
-            }
-        #elif defined(DRFLAC_X86)
-            {
-                drflac_uint32 r;
-                __asm__ __volatile__ (
-                    "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return r;
-            }
-        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)   /* <-- I haven't tested 64-bit inline assembly, so only enabling this for the 32-bit build for now. */
-            {
-                unsigned int r;
-                __asm__ __volatile__ (
-                #if defined(DRFLAC_64BIT)
-                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-                #else
-                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
-                #endif
-                );
-
-                return r;
-            }
-        #else
-            if (x == 0) {
-                return sizeof(x)*8;
-            }
-            #ifdef DRFLAC_64BIT
-                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
-            #else
-                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
-            #endif
-        #endif
-    #else
-        /* Unsupported compiler. */
-        #error "This compiler does not support the lzcnt intrinsic."
-    #endif
-#endif
-}
-#endif
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-#include <intrin.h> /* For BitScanReverse(). */
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
-{
-    drflac_uint32 n;
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-#ifdef DRFLAC_64BIT
-    _BitScanReverse64((unsigned long*)&n, x);
-#else
-    _BitScanReverse((unsigned long*)&n, x);
-#endif
-    return sizeof(x)*8 - n - 1;
-}
-#endif
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
-static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
-#pragma aux drflac__clz_watcom = \
-    "bsr eax, eax" \
-    "xor eax, 31" \
-    parm [eax] nomemory \
-    value [eax] \
-    modify exact [eax] nomemory;
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
-{
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-    if (drflac__is_lzcnt_supported()) {
-        return drflac__clz_lzcnt(x);
-    } else
-#endif
-    {
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-        return drflac__clz_msvc(x);
-#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
-        return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
-#else
-        return drflac__clz_software(x);
-#endif
-    }
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 setBitOffsetPlus1;
-
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    setBitOffsetPlus1 += 1;
-
-    bs->consumedBits += setBitOffsetPlus1;
-    bs->cache <<= setBitOffsetPlus1;
-
-    *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
-    return DRFLAC_TRUE;
-}
-
-
-
-static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(offsetFromStart > 0);
-
-    /*
-    Seeking from the start is not quite as trivial as it sounds because the onSeek callback takes a signed 32-bit integer (which
-    is intentional because it simplifies the implementation of the onSeek callbacks), however offsetFromStart is unsigned 64-bit.
-    To resolve we just need to do an initial seek from the start, and then a series of offset seeks to make up the remainder.
-    */
-    if (offsetFromStart > 0x7FFFFFFF) {
-        drflac_uint64 bytesRemaining = offsetFromStart;
-        if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        bytesRemaining -= 0x7FFFFFFF;
-
-        while (bytesRemaining > 0x7FFFFFFF) {
-            if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemaining -= 0x7FFFFFFF;
-        }
-
-        if (bytesRemaining > 0) {
-            if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-    } else {
-        if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The cache should be reset to force a reload of fresh data from the client. */
-    drflac__reset_cache(bs);
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
-{
-    drflac_uint8 crc;
-    drflac_uint64 result;
-    drflac_uint8 utf8[7] = {0};
-    int byteCount;
-    int i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pNumberOut != NULL);
-    DRFLAC_ASSERT(pCRCOut != NULL);
-
-    crc = *pCRCOut;
-
-    if (!drflac__read_uint8(bs, 8, utf8)) {
-        *pNumberOut = 0;
-        return DRFLAC_AT_END;
-    }
-    crc = drflac_crc8(crc, utf8[0], 8);
-
-    if ((utf8[0] & 0x80) == 0) {
-        *pNumberOut = utf8[0];
-        *pCRCOut = crc;
-        return DRFLAC_SUCCESS;
-    }
-
-    /*byteCount = 1;*/
-    if ((utf8[0] & 0xE0) == 0xC0) {
-        byteCount = 2;
-    } else if ((utf8[0] & 0xF0) == 0xE0) {
-        byteCount = 3;
-    } else if ((utf8[0] & 0xF8) == 0xF0) {
-        byteCount = 4;
-    } else if ((utf8[0] & 0xFC) == 0xF8) {
-        byteCount = 5;
-    } else if ((utf8[0] & 0xFE) == 0xFC) {
-        byteCount = 6;
-    } else if ((utf8[0] & 0xFF) == 0xFE) {
-        byteCount = 7;
-    } else {
-        *pNumberOut = 0;
-        return DRFLAC_CRC_MISMATCH;     /* Bad UTF-8 encoding. */
-    }
-
-    /* Read extra bytes. */
-    DRFLAC_ASSERT(byteCount > 1);
-
-    result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
-    for (i = 1; i < byteCount; ++i) {
-        if (!drflac__read_uint8(bs, 8, utf8 + i)) {
-            *pNumberOut = 0;
-            return DRFLAC_AT_END;
-        }
-        crc = drflac_crc8(crc, utf8[i], 8);
-
-        result = (result << 6) | (utf8[i] & 0x3F);
-    }
-
-    *pNumberOut = result;
-    *pCRCOut = crc;
-    return DRFLAC_SUCCESS;
-}
-
-
-
-/*
-The next two functions are responsible for calculating the prediction.
-
-When the bits per sample is >16 we need to use 64-bit integer arithmetic because otherwise we'll run out of precision. It's
-safe to assume this will be slower on 32-bit platforms so we use a more optimal solution when the bits per sample is <=16.
-*/
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int32 prediction = 0;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 32-bit version. */
-
-    /* VC++ optimizes this to a single jmp. I've not yet verified this for other compilers. */
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
-    }
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int64 prediction;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 64-bit version. */
-
-    /* This method is faster on the 32-bit build when compiling with VC++. See note below. */
-#ifndef DRFLAC_64BIT
-    if (order == 8)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
-    }
-    else if (order == 7)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-    }
-    else if (order == 3)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-    }
-    else if (order == 6)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-    }
-    else if (order == 5)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-    }
-    else if (order == 4)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-    }
-    else if (order == 12)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-        prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    }
-    else if (order == 2)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-    }
-    else if (order == 1)
-    {
-        prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-    }
-    else if (order == 10)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-    }
-    else if (order == 9)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-    }
-    else if (order == 11)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    }
-    else
-    {
-        int j;
-
-        prediction = 0;
-        for (j = 0; j < (int)order; ++j) {
-            prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
-        }
-    }
-#endif
-
-    /*
-    VC++ optimizes this to a single jmp instruction, but only the 64-bit build. The 32-bit build generates less efficient code for some
-    reason. The ugly version above is faster so we'll just switch between the two depending on the target platform.
-    */
-#ifdef DRFLAC_64BIT
-    prediction = 0;
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
-    }
-#endif
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-
-#if 0
-/*
-Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
-sake of readability and should only be used as a reference.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        drflac_uint32 zeroCounter = 0;
-        for (;;) {
-            drflac_uint8 bit;
-            if (!drflac__read_uint8(bs, 1, &bit)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (bit == 0) {
-                zeroCounter += 1;
-            } else {
-                break;
-            }
-        }
-
-        drflac_uint32 decodedRice;
-        if (riceParam > 0) {
-            if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            decodedRice = 0;
-        }
-
-        decodedRice |= (zeroCounter << riceParam);
-        if ((decodedRice & 0x01)) {
-            decodedRice = ~(decodedRice >> 1);
-        } else {
-            decodedRice =  (decodedRice >> 1);
-        }
-
-
-        if (bitsPerSample+shift >= 32) {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 decodedRice;
-
-    for (;;) {
-        drflac_uint8 bit;
-        if (!drflac__read_uint8(bs, 1, &bit)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (bit == 0) {
-            zeroCounter += 1;
-        } else {
-            break;
-        }
-    }
-
-    if (riceParam > 0) {
-        if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        decodedRice = 0;
-    }
-
-    *pZeroCounterOut = zeroCounter;
-    *pRiceParamPartOut = decodedRice;
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_cache_t riceParamMask;
-    drflac_uint32 zeroCounter;
-    drflac_uint32 setBitOffsetPlus1;
-    drflac_uint32 riceParamPart;
-    drflac_uint32 riceLength;
-
-    DRFLAC_ASSERT(riceParam > 0);   /* <-- riceParam should never be 0. drflac__read_rice_parts__param_equals_zero() should be used instead for this case. */
-
-    riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
-
-    zeroCounter = 0;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    zeroCounter += setBitOffsetPlus1;
-    setBitOffsetPlus1 += 1;
-
-    riceLength = setBitOffsetPlus1 + riceParam;
-    if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= riceLength;
-    } else {
-        drflac_uint32 bitCountLo;
-        drflac_cache_t resultHi;
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1);    /* <-- Equivalent to "if (setBitOffsetPlus1 < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { bs->cache <<= setBitOffsetPlus1; }" */
-
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam);  /* <-- Use DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE() if ever this function allows riceParam=0. */
-
-        if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-#ifndef DR_FLAC_NO_CRC
-            drflac__update_crc16(bs);
-#endif
-            bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-            bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-            bs->crc16Cache = bs->cache;
-#endif
-        } else {
-            /* Slow path. We need to fetch more data from the client. */
-            if (!drflac__reload_cache(bs)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
-
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-    }
-
-    pZeroCounterOut[0] = zeroCounter;
-    pRiceParamPartOut[0] = riceParamPart;
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    /*drflac_cache_t riceParamPlus1Mask  = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
-    drflac_uint32  riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        pZeroCounterOut[0] = lzcount;
-
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartHi;
-            drflac_uint32 riceParamPartLo;
-            drflac_uint32 riceParamPartLoBitCount;
-
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Grab the high part of the rice parameter part. */
-            riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            /* We should now have enough information to construct the rice parameter part. */
-            riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
-            pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            zeroCounter += lzcount;
-
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        pZeroCounterOut[0] = zeroCounter;
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0;
-    drflac_uint32 riceParamPart0;
-    drflac_uint32 riceParamMask;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    (void)bitsPerSample;
-    (void)order;
-    (void)shift;
-    (void)coefficients;
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-
-    i = 0;
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-
-        pSamplesOut[i] = riceParamPart0;
-
-        i += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0 = 0;
-    drflac_uint32 zeroCountPart1 = 0;
-    drflac_uint32 zeroCountPart2 = 0;
-    drflac_uint32 zeroCountPart3 = 0;
-    drflac_uint32 riceParamPart0 = 0;
-    drflac_uint32 riceParamPart1 = 0;
-    drflac_uint32 riceParamPart2 = 0;
-    drflac_uint32 riceParamPart3 = 0;
-    drflac_uint32 riceParamMask;
-    const drflac_int32* pSamplesOutEnd;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    if (order == 0) {
-        return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    pSamplesOutEnd = pSamplesOut + (count & ~3);
-
-    if (bitsPerSample+shift > 32) {
-        while (pSamplesOut < pSamplesOutEnd) {
-            /*
-            Rice extraction. It's faster to do this one at a time against local variables than it is to use the x4 version
-            against an array. Not sure why, but perhaps it's making more efficient use of registers?
-            */
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    } else {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    }
-
-    i = (count & ~3);
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        /*riceParamPart0  = (riceParamPart0 >> 1) ^ (~(riceParamPart0 & 0x01) + 1);*/
-
-        /* Sample reconstruction. */
-        if (bitsPerSample+shift > 32) {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-        } else {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-        }
-
-        i += 1;
-        pSamplesOut += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
-{
-    __m128i r;
-
-    /* Pack. */
-    r = _mm_packs_epi32(a, b);
-
-    /* a3a2 a1a0 b3b2 b1b0 -> a3a2 b3b2 a1a0 b1b0 */
-    r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    /* a3a2 b3b2 a1a0 b1b0 -> a3b3 a2b2 a1b1 a0b0 */
-    r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    return r;
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_SSE41)
-static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
-{
-    return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
-{
-    __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-    __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
-    return _mm_add_epi32(x64, x32);
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
-{
-    return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
-{
-    /*
-    To simplify this we are assuming count < 32. This restriction allows us to work on a low side and a high side. The low side
-    is shifted with zero bits, whereas the right side is shifted with sign bits.
-    */
-    __m128i lo = _mm_srli_epi64(x, count);
-    __m128i hi = _mm_srai_epi32(x, count);
-
-    hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0));    /* The high part needs to have the low part cleared. */
-
-    return _mm_or_si128(lo, hi);
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    /* Pre-load. */
-    coefficients128_0 = _mm_setzero_si128();
-    coefficients128_4 = _mm_setzero_si128();
-    coefficients128_8 = _mm_setzero_si128();
-
-    samples128_0 = _mm_setzero_si128();
-    samples128_4 = _mm_setzero_si128();
-    samples128_8 = _mm_setzero_si128();
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    /* This causes strict-aliasing warnings with GCC. */
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i prediction128;
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01)));  /* <-- SSE2 compatible */
-        /*riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_mullo_epi32(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01)), _mm_set1_epi32(0xFFFFFFFF)));*/   /* <-- Only supported from SSE4.1 and is slower in my testing... */
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_4, samples128_4);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_8, samples128_8);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i prediction128;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    DRFLAC_ASSERT(order <= 12);
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    prediction128 = _mm_setzero_si128();
-
-    /* Pre-load. */
-    coefficients128_0  = _mm_setzero_si128();
-    coefficients128_4  = _mm_setzero_si128();
-    coefficients128_8  = _mm_setzero_si128();
-
-    samples128_0  = _mm_setzero_si128();
-    samples128_4  = _mm_setzero_si128();
-    samples128_8  = _mm_setzero_si128();
-
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
-
-        for (i = 0; i < 4; i += 1) {
-            prediction128 = _mm_xor_si128(prediction128, prediction128);    /* Reset to 0. */
-
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
-            case 10:
-            case  9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  8:
-            case  7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  6:
-            case  5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  4:
-            case  3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  2:
-            case  1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
-            }
-
-            /* Horizontal add and shift. */
-            prediction128 = drflac__mm_hadd_epi64(prediction128);
-            prediction128 = drflac__mm_srai_epi64(prediction128, shift);
-            prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-            /* Our value should be sitting in prediction128[0]. We need to combine this with our SSE samples. */
-            samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-            samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-            samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
-{
-    vst1q_s32(p+0, x.val[0]);
-    vst1q_s32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
-{
-    vst1q_u32(p+0, x.val[0]);
-    vst1q_u32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
-{
-    vst1q_f32(p+0, x.val[0]);
-    vst1q_f32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
-{
-    vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
-{
-    vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
-{
-    drflac_int32 x[4];
-    x[3] = x3;
-    x[2] = x2;
-    x[1] = x1;
-    x[0] = x0;
-    return vld1q_s32(x);
-}
-
-static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_s32(b, a, 1);
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_u32(b, a, 1);
-}
-
-static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
-{
-    /* The sum must end up in position 0. */
-
-    /* Reference */
-    /*return vdupq_n_s32(
-        vgetq_lane_s32(x, 3) +
-        vgetq_lane_s32(x, 2) +
-        vgetq_lane_s32(x, 1) +
-        vgetq_lane_s32(x, 0)
-    );*/
-
-    int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
-    return vpadd_s32(r, r);
-}
-
-static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
-{
-    return vadd_s64(vget_high_s64(x), vget_low_s64(x));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
-{
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(x, 0),
-        vgetq_lane_s32(x, 1),
-        vgetq_lane_s32(x, 2),
-        vgetq_lane_s32(x, 3)
-    );*/
-
-    return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
-{
-    return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
-{
-    return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int32x2_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s32(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int32x4_t prediction128;
-        int32x2_t prediction64;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = vmulq_s32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_8, samples128_8);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int64x1_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s64(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int64x2_t prediction128;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        for (i = 0; i < 4; i += 1) {
-            int64x1_t prediction64;
-
-            prediction128 = veorq_s64(prediction128, prediction128);    /* Reset to 0. */
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
-            case 10:
-            case  9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
-            case  8:
-            case  7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
-            case  6:
-            case  5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
-            case  4:
-            case  3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
-            case  2:
-            case  1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
-            }
-
-            /* Horizontal add and shift. */
-            prediction64 = drflac__vhaddq_s64(prediction128);
-            prediction64 = vshl_s64(prediction64, shift64);
-            prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
-
-            /* Our value should be sitting in prediction64[0]. We need to combine this with our SSE samples. */
-            samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-            samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-            samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    if (drflac__gIsSSE41Supported) {
-        return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported) {
-        return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-    #if 0
-        return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #else
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #endif
-    }
-}
-
-/* Reads and seeks past a string of residual values as Rice codes. The decoder should be sitting on the first bit of the Rice codes. */
-static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (!drflac__seek_rice_parts(bs, riceParam)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(unencodedBitsPerSample <= 31);    /* <-- unencodedBitsPerSample is a 5 bit number, so cannot exceed 31. */
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (unencodedBitsPerSample > 0) {
-            if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            pSamplesOut[i] = 0;
-        }
-
-        if (bitsPerSample >= 24) {
-            pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-/*
-Reads and decodes the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be ignored. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    DRFLAC_ASSERT(pDecodedSamples != NULL);       /* <-- Should we allow NULL, in which case we just seek past the residual rather than do a full decode? */
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    /* Ignore the first <order> values. */
-    pDecodedSamples += order;
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) < order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;) {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pDecodedSamples += samplesInPartition;
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-
-        if (partitionOrder != 0) {
-            samplesInPartition = blockSize / (1 << partitionOrder);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-/*
-Reads and seeks past the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be set to 0. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;)
-    {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-        samplesInPartition = blockSize / (1 << partitionOrder);
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    /* Only a single sample needs to be decoded here. */
-    drflac_int32 sample;
-    if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    We don't really need to expand this, but it does simplify the process of reading samples. If this becomes a performance issue (unlikely)
-    we'll want to look at a more efficient way.
-    */
-    for (i = 0; i < blockSize; ++i) {
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    for (i = 0; i < blockSize; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    static drflac_int32 lpcCoefficientsTable[5][4] = {
-        {0,  0, 0,  0},
-        {1,  0, 0,  0},
-        {2, -1, 0,  0},
-        {3, -3, 1,  0},
-        {4, -6, 4, -1}
-    };
-
-    /* Warm up samples and coefficients. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 i;
-    drflac_uint8 lpcPrecision;
-    drflac_int8 lpcShift;
-    drflac_int32 coefficients[32];
-
-    /* Warm up samples. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcPrecision == 15) {
-        return DRFLAC_FALSE;    /* Invalid. */
-    }
-    lpcPrecision += 1;
-
-    if (!drflac__read_int8(bs, 5, &lpcShift)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC specification:
-
-        Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement)
-
-    Emphasis on the "signed two's-complement". In practice there does not seem to be any encoders nor decoders supporting negative shifts. For now dr_flac is
-    not going to support negative shifts as I don't have any reference files. However, when a reference file comes through I will consider adding support.
-    */
-    if (lpcShift < 0) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
-    for (i = 0; i < lpcOrder; ++i) {
-        if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
-{
-    const drflac_uint32 sampleRateTable[12]  = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
-    const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1};   /* -1 = reserved. */
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(header != NULL);
-
-    /* Keep looping until we find a valid sync code. */
-    for (;;) {
-        drflac_uint8 crc8 = 0xCE; /* 0xCE = drflac_crc8(0, 0x3FFE, 14); */
-        drflac_uint8 reserved = 0;
-        drflac_uint8 blockingStrategy = 0;
-        drflac_uint8 blockSize = 0;
-        drflac_uint8 sampleRate = 0;
-        drflac_uint8 channelAssignment = 0;
-        drflac_uint8 bitsPerSample = 0;
-        drflac_bool32 isVariableBlockSize;
-
-        if (!drflac__find_and_seek_to_next_sync_code(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-        if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, blockingStrategy, 1);
-
-        if (!drflac__read_uint8(bs, 4, &blockSize)) {
-            return DRFLAC_FALSE;
-        }
-        if (blockSize == 0) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, blockSize, 4);
-
-        if (!drflac__read_uint8(bs, 4, &sampleRate)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, sampleRate, 4);
-
-        if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
-            return DRFLAC_FALSE;
-        }
-        if (channelAssignment > 10) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, channelAssignment, 4);
-
-        if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        if (bitsPerSample == 3 || bitsPerSample == 7) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, bitsPerSample, 3);
-
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-
-        isVariableBlockSize = blockingStrategy == 1;
-        if (isVariableBlockSize) {
-            drflac_uint64 pcmFrameNumber;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = 0;
-            header->pcmFrameNumber = pcmFrameNumber;
-        } else {
-            drflac_uint64 flacFrameNumber = 0;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = (drflac_uint32)flacFrameNumber;   /* <-- Safe cast. */
-            header->pcmFrameNumber = 0;
-        }
-
-
-        DRFLAC_ASSERT(blockSize > 0);
-        if (blockSize == 1) {
-            header->blockSizeInPCMFrames = 192;
-        } else if (blockSize <= 5) {
-            DRFLAC_ASSERT(blockSize >= 2);
-            header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
-        } else if (blockSize == 6) {
-            if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
-            header->blockSizeInPCMFrames += 1;
-        } else if (blockSize == 7) {
-            if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
-            header->blockSizeInPCMFrames += 1;
-        } else {
-            DRFLAC_ASSERT(blockSize >= 8);
-            header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
-        }
-
-
-        if (sampleRate <= 11) {
-            header->sampleRate = sampleRateTable[sampleRate];
-        } else if (sampleRate == 12) {
-            if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 8);
-            header->sampleRate *= 1000;
-        } else if (sampleRate == 13) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-        } else if (sampleRate == 14) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-            header->sampleRate *= 10;
-        } else {
-            continue;  /* Invalid. Assume an invalid block. */
-        }
-
-
-        header->channelAssignment = channelAssignment;
-
-        header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
-        if (header->bitsPerSample == 0) {
-            header->bitsPerSample = streaminfoBitsPerSample;
-        }
-
-        if (!drflac__read_uint8(bs, 8, &header->crc8)) {
-            return DRFLAC_FALSE;
-        }
-
-#ifndef DR_FLAC_NO_CRC
-        if (header->crc8 != crc8) {
-            continue;    /* CRC mismatch. Loop back to the top and find the next sync code. */
-        }
-#endif
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
-{
-    drflac_uint8 header;
-    int type;
-
-    if (!drflac__read_uint8(bs, 8, &header)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* First bit should always be 0. */
-    if ((header & 0x80) != 0) {
-        return DRFLAC_FALSE;
-    }
-
-    type = (header & 0x7E) >> 1;
-    if (type == 0) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
-    } else if (type == 1) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
-    } else {
-        if ((type & 0x20) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
-        } else if ((type & 0x08) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
-            if (pSubframe->lpcOrder > 4) {
-                pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-                pSubframe->lpcOrder = 0;
-            }
-        } else {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-        }
-    }
-
-    if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Wasted bits per sample. */
-    pSubframe->wastedBitsPerSample = 0;
-    if ((header & 0x01) == 1) {
-        unsigned int wastedBitsPerSample;
-        if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = pDecodedSamplesOut;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = NULL;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac_uint8 lpcPrecision;
-
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-                return DRFLAC_FALSE;
-            }
-            if (lpcPrecision == 15) {
-                return DRFLAC_FALSE;    /* Invalid. */
-            }
-            lpcPrecision += 1;
-
-
-            bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5;    /* +5 for shift. */
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
-{
-    drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
-
-    DRFLAC_ASSERT(channelAssignment <= 10);
-    return lookup[channelAssignment];
-}
-
-static drflac_result drflac__decode_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint8 paddingSizeInBits;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    /* This function should be called while the stream is sitting on the first byte after the frame header. */
-    DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
-
-    /* The frame block size must never be larger than the maximum block size defined by the FLAC stream. */
-    if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_ERROR;
-    }
-
-    /* The number of channels in the frame must match the channel count from the STREAMINFO block. */
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    if (channelCount != (int)pFlac->channels) {
-        return DRFLAC_ERROR;
-    }
-
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
-    if (paddingSizeInBits > 0) {
-        drflac_uint8 padding = 0;
-        if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
-            return DRFLAC_AT_END;
-        }
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac__seek_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    /* Padding. */
-    if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
-        return DRFLAC_ERROR;
-    }
-
-    /* CRC. */
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    for (;;) {
-        drflac_result result;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        result = drflac__decode_flac_frame(pFlac);
-        if (result != DRFLAC_SUCCESS) {
-            if (result == DRFLAC_CRC_MISMATCH) {
-                continue;   /* CRC mismatch. Skip to the next frame. */
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 lastPCMFrame;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
-    if (firstPCMFrame == 0) {
-        firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
-    }
-
-    lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    if (lastPCMFrame > 0) {
-        lastPCMFrame -= 1; /* Needs to be zero based. */
-    }
-
-    if (pFirstPCMFrame) {
-        *pFirstPCMFrame = firstPCMFrame;
-    }
-    if (pLastPCMFrame) {
-        *pLastPCMFrame = lastPCMFrame;
-    }
-}
-
-static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
-{
-    drflac_bool32 result;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
-
-    DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-    pFlac->currentPCMFrame = 0;
-
-    return result;
-}
-
-static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
-{
-    /* This function should only ever be called while the decoder is sitting on the first byte past the FRAME_HEADER section. */
-    DRFLAC_ASSERT(pFlac != NULL);
-    return drflac__seek_flac_frame(pFlac);
-}
-
-
-static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
-{
-    drflac_uint64 pcmFramesRead = 0;
-    while (pcmFramesToSeek > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
-                pcmFramesRead   += pcmFramesToSeek;
-                pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek;   /* <-- Safe cast. Will always be < currentFrame.pcmFramesRemaining < 65536. */
-                pcmFramesToSeek  = 0;
-            } else {
-                pcmFramesRead   += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-            }
-        }
-    }
-
-    pFlac->currentPCMFrame += pcmFramesRead;
-    return pcmFramesRead;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    /* If we are seeking forward we start from the current position. Otherwise we need to start all the way from the start of the file. */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame) {
-        /* Seeking forward. Need to seek from the current position. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Seeking backwards. Need to seek from the start of the file. */
-        runningPCMFrameCount = 0;
-
-        /* Move back to the start. */
-        if (!drflac__seek_to_first_frame(pFlac)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Decode the first frame in preparation for sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /*
-    We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect its
-    header. If based on the header we can determine that the frame contains the sample, we do a full decode of that frame.
-    */
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#if !defined(DR_FLAC_NO_CRC)
-/*
-We use an average compression ratio to determine our approximate start location. FLAC files are generally about 50%-70% the size of their
-uncompressed counterparts so we'll use this as a basis. I'm going to split the middle and use a factor of 0.6 to determine the starting
-location.
-*/
-#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
-
-static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
-    DRFLAC_ASSERT(targetByte >= rangeLo);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
-
-    for (;;) {
-        /* After rangeLo == rangeHi == targetByte fails, we need to break out. */
-        drflac_uint64 lastTargetByte = targetByte;
-
-        /* When seeking to a byte, failure probably means we've attempted to seek beyond the end of the stream. To counter this we just halve it each attempt. */
-        if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
-            /* If we couldn't even seek to the first byte in the stream we have a problem. Just abandon the whole thing. */
-            if (targetByte == 0) {
-                drflac__seek_to_first_frame(pFlac); /* Try to recover. */
-                return DRFLAC_FALSE;
-            }
-
-            /* Halve the byte location and continue. */
-            targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-            rangeHi = targetByte;
-        } else {
-            /* Getting here should mean that we have seeked to an appropriate byte. */
-
-            /* Clear the details of the FLAC frame so we don't misreport data. */
-            DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-
-            /*
-            Now seek to the next FLAC frame. We need to decode the entire frame (not just the header) because it's possible for the header to incorrectly pass the
-            CRC check and return bad data. We need to decode the entire frame to be more certain. Although this seems unlikely, this has happened to me in testing
-            so it needs to stay this way for now.
-            */
-#if 1
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#else
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#endif
-        }
-
-        /* We already tried this byte and there are no more to try, break out. */
-        if(targetByte == lastTargetByte) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The current PCM frame needs to be updated based on the frame we just seeked to. */
-    drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = targetByte;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
-{
-    /* This section of code would be used if we were only decoding the FLAC frame header when calling drflac__seek_to_approximate_flac_frame_to_byte(). */
-#if 0
-    if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
-        /* We failed to decode this frame which may be due to it being corrupt. We'll just use the next valid FLAC frame. */
-        if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-    }
-#endif
-
-    return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
-{
-    /* This assumes pFlac->currentPCMFrame is sitting on byteRangeLo upon entry. */
-
-    drflac_uint64 targetByte;
-    drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
-    drflac_uint64 pcmRangeHi = 0;
-    drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
-    drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
-    if (targetByte > byteRangeHi) {
-        targetByte = byteRangeHi;
-    }
-
-    for (;;) {
-        if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
-            /* We found a FLAC frame. We need to check if it contains the sample we're looking for. */
-            drflac_uint64 newPCMRangeLo;
-            drflac_uint64 newPCMRangeHi;
-            drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
-
-            /* If we selected the same frame, it means we should be pretty close. Just decode the rest. */
-            if (pcmRangeLo == newPCMRangeLo) {
-                if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
-                    break;  /* Failed to seek to closest frame. */
-                }
-
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek forward. */
-                }
-            }
-
-            pcmRangeLo = newPCMRangeLo;
-            pcmRangeHi = newPCMRangeHi;
-
-            if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
-                /* The target PCM frame is in this FLAC frame. */
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek to FLAC frame. */
-                }
-            } else {
-                const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-                if (pcmRangeLo > pcmFrameIndex) {
-                    /* We seeked too far forward. We need to move our target byte backward and try again. */
-                    byteRangeHi = lastSuccessfulSeekOffset;
-                    if (byteRangeLo > byteRangeHi) {
-                        byteRangeLo = byteRangeHi;
-                    }
-
-                    targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
-                    if (targetByte < byteRangeLo) {
-                        targetByte = byteRangeLo;
-                    }
-                } else /*if (pcmRangeHi < pcmFrameIndex)*/ {
-                    /* We didn't seek far enough. We need to move our target byte forward and try again. */
-
-                    /* If we're close enough we can just seek forward. */
-                    if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
-                        if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                            return DRFLAC_TRUE;
-                        } else {
-                            break;  /* Failed to seek to FLAC frame. */
-                        }
-                    } else {
-                        byteRangeLo = lastSuccessfulSeekOffset;
-                        if (byteRangeHi < byteRangeLo) {
-                            byteRangeHi = byteRangeLo;
-                        }
-
-                        targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
-                        if (targetByte > byteRangeHi) {
-                            targetByte = byteRangeHi;
-                        }
-
-                        if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
-                            closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
-                        }
-                    }
-                }
-            }
-        } else {
-            /* Getting here is really bad. We just recover as best we can, but moving to the first frame in the stream, and then abort. */
-            break;
-        }
-    }
-
-    drflac__seek_to_first_frame(pFlac); /* <-- Try to recover. */
-    return DRFLAC_FALSE;
-}
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint64 byteRangeLo;
-    drflac_uint64 byteRangeHi;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    /* Our algorithm currently assumes the FLAC stream is currently sitting at the start. */
-    if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
-        return DRFLAC_FALSE;
-    }
-
-    /* If we're close enough to the start, just move to the start and seek forward. */
-    if (pcmFrameIndex < seekForwardThreshold) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
-    }
-
-    /*
-    Our starting byte range is the byte position of the first FLAC frame and the approximate end of the file as if it were completely uncompressed. This ensures
-    the entire file is included, even though most of the time it'll exceed the end of the actual stream. This is OK as the frame searching logic will handle it.
-    */
-    byteRangeLo = pFlac->firstFLACFramePosInBytes;
-    byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-    return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
-}
-#endif  /* !DR_FLAC_NO_CRC */
-
-static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint32 iClosestSeekpoint = 0;
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    drflac_uint32 iSeekpoint;
-
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-        if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
-            break;
-        }
-
-        iClosestSeekpoint = iSeekpoint;
-    }
-
-    /* There's been cases where the seek table contains only zeros. We need to do some basic validation on the closest seekpoint. */
-    if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
-        return DRFLAC_FALSE;
-    }
-
-#if !defined(DR_FLAC_NO_CRC)
-    /* At this point we should know the closest seek point. We can use a binary search for this. We need to know the total sample count for this. */
-    if (pFlac->totalPCMFrameCount > 0) {
-        drflac_uint64 byteRangeLo;
-        drflac_uint64 byteRangeHi;
-
-        byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-        byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
-
-        /*
-        If our closest seek point is not the last one, we only need to search between it and the next one. The section below calculates an appropriate starting
-        value for byteRangeHi which will clamp it appropriately.
-
-        Note that the next seekpoint must have an offset greater than the closest seekpoint because otherwise our binary search algorithm will break down. There
-        have been cases where a seektable consists of seek points where every byte offset is set to 0 which causes problems. If this happens we need to abort.
-        */
-        if (iClosestSeekpoint < pFlac->seekpointCount-1) {
-            drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
-
-            /* Basic validation on the seekpoints to ensure they're usable. */
-            if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
-                return DRFLAC_FALSE;    /* The next seekpoint doesn't look right. The seek table cannot be trusted from here. Abort. */
-            }
-
-            if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) { /* Make sure it's not a placeholder seekpoint. */
-                byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1; /* byteRangeHi must be zero based. */
-            }
-        }
-
-        if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-                if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
-                    return DRFLAC_TRUE;
-                }
-            }
-        }
-    }
-#endif  /* !DR_FLAC_NO_CRC */
-
-    /* Getting here means we need to use a slower algorithm because the binary search method failed or cannot be used. */
-
-    /*
-    If we are seeking forward and the closest seekpoint is _before_ the current sample, we just seek forward from where we are. Otherwise we start seeking
-    from the seekpoint's first sample.
-    */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
-        /* Optimized case. Just seek forward from where we are. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Slower case. Seek to the start of the seekpoint and then seek forward from there. */
-        runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
-
-        if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Grab the frame the seekpoint is sitting on in preparation for the sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, but if it's an invalid frame (a CRC mismatch) we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#ifndef DR_FLAC_NO_OGG
-typedef struct
-{
-    drflac_uint8 capturePattern[4];  /* Should be "OggS" */
-    drflac_uint8 structureVersion;   /* Always 0. */
-    drflac_uint8 headerType;
-    drflac_uint64 granulePosition;
-    drflac_uint32 serialNumber;
-    drflac_uint32 sequenceNumber;
-    drflac_uint32 checksum;
-    drflac_uint8 segmentCount;
-    drflac_uint8 segmentTable[255];
-} drflac_ogg_page_header;
-#endif
-
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    drflac_meta_proc onMeta;
-    drflac_container container;
-    void* pUserData;
-    void* pUserDataMD;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 runningFilePos;
-    drflac_bool32 hasStreamInfoBlock;
-    drflac_bool32 hasMetadataBlocks;
-    drflac_bs bs;                           /* <-- A bit streamer is required for loading data during initialization. */
-    drflac_frame_header firstFrameHeader;   /* <-- The header of the first frame that was read during relaxed initalization. Only set if there is no STREAMINFO block. */
-
-#ifndef DR_FLAC_NO_OGG
-    drflac_uint32 oggSerial;
-    drflac_uint64 oggFirstBytePos;
-    drflac_ogg_page_header oggBosHeader;
-#endif
-} drflac_init_info;
-
-static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    blockHeader = drflac__be2host_32(blockHeader);
-    *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
-    *blockType   = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
-    *blockSize   =                (blockHeader & 0x00FFFFFFUL);
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    drflac_uint32 blockHeader;
-
-    *blockSize = 0;
-    if (onRead(pUserData, &blockHeader, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
-{
-    drflac_uint32 blockSizes;
-    drflac_uint64 frameSizes = 0;
-    drflac_uint64 importantProps;
-    drflac_uint8 md5[16];
-
-    /* min/max block size. */
-    if (onRead(pUserData, &blockSizes, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    /* min/max frame size. */
-    if (onRead(pUserData, &frameSizes, 6) != 6) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Sample rate, channels, bits per sample and total sample count. */
-    if (onRead(pUserData, &importantProps, 8) != 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* MD5 */
-    if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
-        return DRFLAC_FALSE;
-    }
-
-    blockSizes     = drflac__be2host_32(blockSizes);
-    frameSizes     = drflac__be2host_64(frameSizes);
-    importantProps = drflac__be2host_64(importantProps);
-
-    pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
-    pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
-    pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
-    pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) <<  0)) >> 16);
-    pStreamInfo->sampleRate              = (drflac_uint32)((importantProps &  (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
-    pStreamInfo->channels                = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
-    pStreamInfo->bitsPerSample           = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
-    pStreamInfo->totalPCMFrameCount      =                ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
-    DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
-
-    return DRFLAC_TRUE;
-}
-
-
-static void* drflac__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_MALLOC(sz);
-}
-
-static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_REALLOC(p, sz);
-}
-
-static void drflac__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRFLAC_FREE(p);
-}
-
-
-static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRFLAC_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    /*
-    We want to keep track of the byte position in the stream of the seektable. At the time of calling this function we know that
-    we'll be sitting on byte 42.
-    */
-    drflac_uint64 runningFilePos = 42;
-    drflac_uint64 seektablePos   = 0;
-    drflac_uint32 seektableSize  = 0;
-
-    for (;;) {
-        drflac_metadata metadata;
-        drflac_uint8 isLastBlock = 0;
-        drflac_uint8 blockType;
-        drflac_uint32 blockSize;
-        if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-        runningFilePos += 4;
-
-        metadata.type = blockType;
-        metadata.pRawData = NULL;
-        metadata.rawDataSize = 0;
-
-        switch (blockType)
-        {
-            case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
-            {
-                if (blockSize < 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.application.id       = drflac__be2host_32(*(drflac_uint32*)pRawData);
-                    metadata.data.application.pData    = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
-                    metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
-            {
-                seektablePos  = runningFilePos;
-                seektableSize = blockSize;
-
-                if (onMeta) {
-                    drflac_uint32 iSeekpoint;
-                    void* pRawData;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
-                    metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-
-                    /* Endian swap. */
-                    for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
-                        drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
-                        pSeekpoint->firstPCMFrame   = drflac__be2host_64(pSeekpoint->firstPCMFrame);
-                        pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
-                        pSeekpoint->pcmFrameCount   = drflac__be2host_16(pSeekpoint->pcmFrameCount);
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
-            {
-                if (blockSize < 8) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint32 i;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.vendor       = pRunningData;                                            pRunningData += metadata.data.vorbis_comment.vendorLength;
-                    metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for 'commentCount' comments after the block, which at minimum is a drflac_uint32 per comment */
-                    if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.pComments    = pRunningData;
-
-                    /* Check that the comments section is valid before passing it to the callback */
-                    for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
-                        drflac_uint32 commentLength;
-
-                        if (pRunningDataEnd - pRunningData < 4) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += commentLength;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
-            {
-                if (blockSize < 396) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint8 iTrack;
-                    drflac_uint8 iIndex;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128);                              pRunningData += 128;
-                    metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
-                    metadata.data.cuesheet.isCD              = (pRunningData[0] & 0x80) != 0;                           pRunningData += 259;
-                    metadata.data.cuesheet.trackCount        = pRunningData[0];                                         pRunningData += 1;
-                    metadata.data.cuesheet.pTrackData        = pRunningData;
-
-                    /* Check that the cuesheet tracks are valid before passing it to the callback */
-                    for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
-                        drflac_uint8 indexCount;
-                        drflac_uint32 indexPointSize;
-
-                        if (pRunningDataEnd - pRunningData < 36) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Skip to the index point count */
-                        pRunningData += 35;
-                        indexCount = pRunningData[0]; pRunningData += 1;
-                        indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Endian swap. */
-                        for (iIndex = 0; iIndex < indexCount; ++iIndex) {
-                            drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
-                            pRunningData += sizeof(drflac_cuesheet_track_index);
-                            pTrack->offset = drflac__be2host_64(pTrack->offset);
-                        }
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
-            {
-                if (blockSize < 32) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.picture.type       = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.mime              = pRunningData;                                            pRunningData += metadata.data.picture.mimeLength;
-                    metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.description     = pRunningData;                                            pRunningData += metadata.data.picture.descriptionLength;
-                    metadata.data.picture.width           = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.height          = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.colorDepth      = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pPictureData    = (const drflac_uint8*)pRunningData;
-
-                    /* Need space for the picture after the block */
-                    if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
-            {
-                if (onMeta) {
-                    metadata.data.padding.unused = 0;
-
-                    /* Padding doesn't have anything meaningful in it, so just skip over it, but make sure the caller is aware of it by firing the callback. */
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    } else {
-                        onMeta(pUserDataMD, &metadata);
-                    }
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
-            {
-                /* Invalid chunk. Just skip over this one. */
-                if (onMeta) {
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    }
-                }
-            } break;
-
-            default:
-            {
-                /*
-                It's an unknown chunk, but not necessarily invalid. There's a chance more metadata blocks might be defined later on, so we
-                can at the very least report the chunk to the application and let it look at the raw data.
-                */
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-        }
-
-        /* If we're not handling metadata, just skip over the block. If we are, it will have been handled earlier in the switch statement above. */
-        if (onMeta == NULL && blockSize > 0) {
-            if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                isLastBlock = DRFLAC_TRUE;
-            }
-        }
-
-        runningFilePos += blockSize;
-        if (isLastBlock) {
-            break;
-        }
-    }
-
-    *pSeektablePos = seektablePos;
-    *pSeektableSize = seektableSize;
-    *pFirstFramePos = runningFilePos;
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte id header. */
-
-    drflac_uint8 isLastBlock;
-    drflac_uint8 blockType;
-    drflac_uint32 blockSize;
-
-    (void)onSeek;
-
-    pInit->container = drflac_container_native;
-
-    /* The first metadata block should be the STREAMINFO block. */
-    if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-        if (!relaxed) {
-            /* We're opening in strict mode and the first block is not the STREAMINFO block. Error. */
-            return DRFLAC_FALSE;
-        } else {
-            /*
-            Relaxed mode. To open from here we need to just find the first frame and set the sample rate, etc. to whatever is defined
-            for that frame.
-            */
-            pInit->hasStreamInfoBlock = DRFLAC_FALSE;
-            pInit->hasMetadataBlocks  = DRFLAC_FALSE;
-
-            if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
-                return DRFLAC_FALSE;    /* Couldn't find a frame. */
-            }
-
-            if (pInit->firstFrameHeader.bitsPerSample == 0) {
-                return DRFLAC_FALSE;    /* Failed to initialize because the first frame depends on the STREAMINFO block, which does not exist. */
-            }
-
-            pInit->sampleRate              = pInit->firstFrameHeader.sampleRate;
-            pInit->channels                = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
-            pInit->bitsPerSample           = pInit->firstFrameHeader.bitsPerSample;
-            pInit->maxBlockSizeInPCMFrames = 65535;   /* <-- See notes here: https://xiph.org/flac/format.html#metadata_block_streaminfo */
-            return DRFLAC_TRUE;
-        }
-    } else {
-        drflac_streaminfo streaminfo;
-        if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-            return DRFLAC_FALSE;
-        }
-
-        pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-        pInit->sampleRate              = streaminfo.sampleRate;
-        pInit->channels                = streaminfo.channels;
-        pInit->bitsPerSample           = streaminfo.bitsPerSample;
-        pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-        pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;    /* Don't care about the min block size - only the max (used for determining the size of the memory allocation). */
-        pInit->hasMetadataBlocks       = !isLastBlock;
-
-        if (onMeta) {
-            drflac_metadata metadata;
-            metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-            metadata.pRawData = NULL;
-            metadata.rawDataSize = 0;
-            metadata.data.streaminfo = streaminfo;
-            onMeta(pUserDataMD, &metadata);
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-#ifndef DR_FLAC_NO_OGG
-#define DRFLAC_OGG_MAX_PAGE_SIZE            65307
-#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32    1605413199  /* CRC-32 of "OggS". */
-
-typedef enum
-{
-    drflac_ogg_recover_on_crc_mismatch,
-    drflac_ogg_fail_on_crc_mismatch
-} drflac_ogg_crc_mismatch_recovery;
-
-#ifndef DR_FLAC_NO_CRC
-static drflac_uint32 drflac__crc32_table[] = {
-    0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
-    0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
-    0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
-    0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
-    0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
-    0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
-    0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
-    0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
-    0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
-    0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
-    0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
-    0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
-    0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
-    0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
-    0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
-    0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
-    0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
-    0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
-    0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
-    0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
-    0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
-    0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
-    0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
-    0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
-    0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
-    0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
-    0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
-    0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
-    0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
-    0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
-    0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
-    0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
-    0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
-    0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
-    0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
-    0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
-    0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
-    0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
-    0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
-    0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
-    0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
-    0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
-    0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
-    0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
-    0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
-    0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
-    0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
-    0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
-    0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
-    0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
-    0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
-    0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
-    0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
-    0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
-    0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
-    0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
-    0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
-    0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
-    0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
-    0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
-    0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
-    0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
-    0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
-    0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
-};
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
-{
-#ifndef DR_FLAC_NO_CRC
-    return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
-#else
-    (void)data;
-    return crc32;
-#endif
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
-{
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  8) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc32;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
-{
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >>  0) & 0xFFFFFFFF));
-    return crc32;
-}
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
-{
-    /* This can be optimized. */
-    drflac_uint32 i;
-    for (i = 0; i < dataSize; ++i) {
-        crc32 = drflac_crc32_byte(crc32, pData[i]);
-    }
-    return crc32;
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
-{
-    return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
-{
-    return 27 + pHeader->segmentCount;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
-{
-    drflac_uint32 pageBodySize = 0;
-    int i;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        pageBodySize += pHeader->segmentTable[i];
-    }
-
-    return pageBodySize;
-}
-
-static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 data[23];
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
-
-    if (onRead(pUserData, data, 23) != 23) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 23;
-
-    /*
-    It's not actually used, but set the capture pattern to 'OggS' for completeness. Not doing this will cause static analysers to complain about
-    us trying to access uninitialized data. We could alternatively just comment out this member of the drflac_ogg_page_header structure, but I
-    like to have it map to the structure of the underlying data.
-    */
-    pHeader->capturePattern[0] = 'O';
-    pHeader->capturePattern[1] = 'g';
-    pHeader->capturePattern[2] = 'g';
-    pHeader->capturePattern[3] = 'S';
-
-    pHeader->structureVersion = data[0];
-    pHeader->headerType       = data[1];
-    DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
-    DRFLAC_COPY_MEMORY(&pHeader->serialNumber,    &data[10], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber,  &data[14], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->checksum,        &data[18], 4);
-    pHeader->segmentCount     = data[22];
-
-    /* Calculate the CRC. Note that for the calculation the checksum part of the page needs to be set to 0. */
-    data[18] = 0;
-    data[19] = 0;
-    data[20] = 0;
-    data[21] = 0;
-
-    for (i = 0; i < 23; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
-    }
-
-
-    if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += pHeader->segmentCount;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
-    }
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 id[4];
-
-    *pBytesRead = 0;
-
-    if (onRead(pUserData, id, 4) != 4) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 4;
-
-    /* We need to read byte-by-byte until we find the OggS capture pattern. */
-    for (;;) {
-        if (drflac_ogg__is_capture_pattern(id)) {
-            drflac_result result;
-
-            *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-
-            result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
-            if (result == DRFLAC_SUCCESS) {
-                return DRFLAC_SUCCESS;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return result;
-                }
-            }
-        } else {
-            /* The first 4 bytes did not equal the capture pattern. Read the next byte and try again. */
-            id[0] = id[1];
-            id[1] = id[2];
-            id[2] = id[3];
-            if (onRead(pUserData, &id[3], 1) != 1) {
-                return DRFLAC_AT_END;
-            }
-            *pBytesRead += 1;
-        }
-    }
-}
-
-
-/*
-The main part of the Ogg encapsulation is the conversion from the physical Ogg bitstream to the native FLAC bitstream. It works
-in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is designed
-in such a way that the core sections assume everything is delivered in native format. Therefore, for each encapsulation type
-dr_flac is supporting there needs to be a layer sitting on top of the onRead and onSeek callbacks that ensures the bits read from
-the physical Ogg bitstream are converted and delivered in native FLAC format.
-*/
-typedef struct
-{
-    drflac_read_proc onRead;                /* The original onRead callback from drflac_open() and family. */
-    drflac_seek_proc onSeek;                /* The original onSeek callback from drflac_open() and family. */
-    void* pUserData;                        /* The user data passed on onRead and onSeek. This is the user data that was passed on drflac_open() and family. */
-    drflac_uint64 currentBytePos;           /* The position of the byte we are sitting on in the physical byte stream. Used for efficient seeking. */
-    drflac_uint64 firstBytePos;             /* The position of the first byte in the physical bitstream. Points to the start of the "OggS" identifier of the FLAC bos page. */
-    drflac_uint32 serialNumber;             /* The serial number of the FLAC audio pages. This is determined by the initial header page that was read during initialization. */
-    drflac_ogg_page_header bosPageHeader;   /* Used for seeking. */
-    drflac_ogg_page_header currentPageHeader;
-    drflac_uint32 bytesRemainingInPage;
-    drflac_uint32 pageDataSize;
-    drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
-} drflac_oggbs; /* oggbs = Ogg Bitstream */
-
-static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
-{
-    size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
-    oggbs->currentBytePos += bytesActuallyRead;
-
-    return bytesActuallyRead;
-}
-
-static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
-{
-    if (origin == drflac_seek_origin_start) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return DRFLAC_TRUE;
-        } else {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
-        }
-    } else {
-        while (offset > 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos += 0x7FFFFFFF;
-            offset -= 0x7FFFFFFF;
-        }
-
-        if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) {    /* <-- Safe cast thanks to the loop above. */
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += offset;
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
-{
-    drflac_ogg_page_header header;
-    for (;;) {
-        drflac_uint32 crc32 = 0;
-        drflac_uint32 bytesRead;
-        drflac_uint32 pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        drflac_uint32 actualCRC32;
-#endif
-
-        if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += bytesRead;
-
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
-            continue;   /* Invalid page size. Assume it's corrupted and just move to the next page. */
-        }
-
-        if (header.serialNumber != oggbs->serialNumber) {
-            /* It's not a FLAC page. Skip it. */
-            if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            continue;
-        }
-
-
-        /* We need to read the entire page and then do a CRC check on it. If there's a CRC mismatch we need to skip this page. */
-        if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->pageDataSize = pageBodySize;
-
-#ifndef DR_FLAC_NO_CRC
-        actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
-        if (actualCRC32 != header.checksum) {
-            if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
-                continue;   /* CRC mismatch. Skip this page. */
-            } else {
-                /*
-                Even though we are failing on a CRC mismatch, we still want our stream to be in a good state. Therefore we
-                go to the next valid page to ensure we're in a good state, but return false to let the caller know that the
-                seek did not fully complete.
-                */
-                drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
-                return DRFLAC_FALSE;
-            }
-        }
-#else
-        (void)recoveryMethod;   /* <-- Silence a warning. */
-#endif
-
-        oggbs->currentPageHeader = header;
-        oggbs->bytesRemainingInPage = pageBodySize;
-        return DRFLAC_TRUE;
-    }
-}
-
-/* Function below is unused at the moment, but I might be re-adding it later. */
-#if 0
-static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
-{
-    drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
-    drflac_uint8 iSeg = 0;
-    drflac_uint32 iByte = 0;
-    while (iByte < bytesConsumedInPage) {
-        drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-        if (iByte + segmentSize > bytesConsumedInPage) {
-            break;
-        } else {
-            iSeg += 1;
-            iByte += segmentSize;
-        }
-    }
-
-    *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
-    return iSeg;
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
-{
-    /* The current packet ends when we get to the segment with a lacing value of < 255 which is not at the end of a page. */
-    for (;;) {
-        drflac_bool32 atEndOfPage = DRFLAC_FALSE;
-
-        drflac_uint8 bytesRemainingInSeg;
-        drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
-
-        drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
-        for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
-            drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-            if (segmentSize < 255) {
-                if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
-                    atEndOfPage = DRFLAC_TRUE;
-                }
-
-                break;
-            }
-
-            bytesToEndOfPacketOrPage += segmentSize;
-        }
-
-        /*
-        At this point we will have found either the packet or the end of the page. If were at the end of the page we'll
-        want to load the next page and keep searching for the end of the packet.
-        */
-        drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
-        oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
-
-        if (atEndOfPage) {
-            /*
-            We're potentially at the next packet, but we need to check the next page first to be sure because the packet may
-            straddle pages.
-            */
-            if (!drflac_oggbs__goto_next_page(oggbs)) {
-                return DRFLAC_FALSE;
-            }
-
-            /* If it's a fresh packet it most likely means we're at the next packet. */
-            if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* We're at the next packet. */
-            return DRFLAC_TRUE;
-        }
-    }
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
-{
-    /* The bitstream should be sitting on the first byte just after the header of the frame. */
-
-    /* What we're actually doing here is seeking to the start of the next packet. */
-    return drflac_oggbs__seek_to_next_packet(oggbs);
-}
-#endif
-
-static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
-    size_t bytesRead = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(pRunningBufferOut != NULL);
-
-    /* Reading is done page-by-page. If we've run out of bytes in the page we need to move to the next one. */
-    while (bytesRead < bytesToRead) {
-        size_t bytesRemainingToRead = bytesToRead - bytesRead;
-
-        if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
-            bytesRead += bytesRemainingToRead;
-            oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
-            bytesRead += oggbs->bytesRemainingInPage;
-            pRunningBufferOut += oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToRead > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            break;  /* Failed to go to the next page. Might have simply hit the end of the stream. */
-        }
-    }
-
-    return bytesRead;
-}
-
-static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    int bytesSeeked = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    /* Seeking is always forward which makes things a lot simpler. */
-    if (origin == drflac_seek_origin_start) {
-        if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-
-        return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
-    }
-
-    DRFLAC_ASSERT(origin == drflac_seek_origin_current);
-
-    while (bytesSeeked < offset) {
-        int bytesRemainingToSeek = offset - bytesSeeked;
-        DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
-
-        if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
-            bytesSeeked += bytesRemainingToSeek;
-            (void)bytesSeeked;  /* <-- Silence a dead store warning emitted by Clang Static Analyzer. */
-            oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            bytesSeeked += (int)oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToSeek > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            /* Failed to go to the next page. We either hit the end of the stream or had a CRC mismatch. */
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-    drflac_uint64 originalBytePos;
-    drflac_uint64 runningGranulePosition;
-    drflac_uint64 runningFrameBytePos;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-
-    originalBytePos = oggbs->currentBytePos;   /* For recovery. Points to the OggS identifier. */
-
-    /* First seek to the first frame. */
-    if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
-        return DRFLAC_FALSE;
-    }
-    oggbs->bytesRemainingInPage = 0;
-
-    runningGranulePosition = 0;
-    for (;;) {
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
-            return DRFLAC_FALSE;   /* Never did find that sample... */
-        }
-
-        runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
-        if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
-            break; /* The sample is somewhere in the previous page. */
-        }
-
-        /*
-        At this point we know the sample is not in the previous page. It could possibly be in this page. For simplicity we
-        disregard any pages that do not begin a fresh packet.
-        */
-        if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {    /* <-- Is it a fresh page? */
-            if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
-                drflac_uint8 firstBytesInPage[2];
-                firstBytesInPage[0] = oggbs->pageData[0];
-                firstBytesInPage[1] = oggbs->pageData[1];
-
-                if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) {    /* <-- Does the page begin with a frame's sync code? */
-                    runningGranulePosition = oggbs->currentPageHeader.granulePosition;
-                }
-
-                continue;
-            }
-        }
-    }
-
-    /*
-    We found the page that that is closest to the sample, so now we need to find it. The first thing to do is seek to the
-    start of that page. In the loop above we checked that it was a fresh page which means this page is also the start of
-    a new frame. This property means that after we've seeked to the page we can immediately start looping over frames until
-    we find the one containing the target sample.
-    */
-    if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    At this point we'll be sitting on the first byte of the frame header of the first frame in the page. We just keep
-    looping over these frames until we find the one containing the sample we're after.
-    */
-    runningPCMFrameCount = runningGranulePosition;
-    for (;;) {
-        /*
-        There are two ways to find the sample and seek past irrelevant frames:
-          1) Use the native FLAC decoder.
-          2) Use Ogg's framing system.
-
-        Both of these options have their own pros and cons. Using the native FLAC decoder is slower because it needs to
-        do a full decode of the frame. Using Ogg's framing system is faster, but more complicated and involves some code
-        duplication for the decoding of frame headers.
-
-        Another thing to consider is that using the Ogg framing system will perform direct seeking of the physical Ogg
-        bitstream. This is important to consider because it means we cannot read data from the drflac_bs object using the
-        standard drflac__*() APIs because that will read in extra data for its own internal caching which in turn breaks
-        the positioning of the read pointer of the physical Ogg bitstream. Therefore, anything that would normally be read
-        using the native FLAC decoding APIs, such as drflac__read_next_flac_frame_header(), need to be re-implemented so as to
-        avoid the use of the drflac_bs object.
-
-        Considering these issues, I have decided to use the slower native FLAC decoding method for the following reasons:
-          1) Seeking is already partially accelerated using Ogg's paging system in the code block above.
-          2) Seeking in an Ogg encapsulated FLAC stream is probably quite uncommon.
-          3) Simplicity.
-        */
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac_uint64 pcmFrameCountInThisFrame;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-
-        /* If we are seeking to the end of the file and we've just hit it, we're done. */
-        if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                return DRFLAC_TRUE;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
-            /*
-            The sample should be in this FLAC frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount);    /* <-- Safe cast because the maximum number of samples in a frame is 65535. */
-                if (pcmFramesToDecode == 0) {
-                    return DRFLAC_TRUE;
-                }
-
-                pFlac->currentPCMFrame = runningPCMFrameCount;
-
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                runningPCMFrameCount += pcmFrameCountInThisFrame;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-
-
-
-static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_ogg_page_header header;
-    drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-    drflac_uint32 bytesRead = 0;
-
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte OggS capture pattern. */
-    (void)relaxed;
-
-    pInit->container = drflac_container_ogg;
-    pInit->oggFirstBytePos = 0;
-
-    /*
-    We'll get here if the first 4 bytes of the stream were the OggS capture pattern, however it doesn't necessarily mean the
-    stream includes FLAC encoded audio. To check for this we need to scan the beginning-of-stream page markers and check if
-    any match the FLAC specification. Important to keep in mind that the stream may be multiplexed.
-    */
-    if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-        return DRFLAC_FALSE;
-    }
-    pInit->runningFilePos += bytesRead;
-
-    for (;;) {
-        int pageBodySize;
-
-        /* Break if we're past the beginning of stream page. */
-        if ((header.headerType & 0x02) == 0) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Check if it's a FLAC header. */
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize == 51) {   /* 51 = the lacing value of the FLAC header packet. */
-            /* It could be a FLAC page... */
-            drflac_uint32 bytesRemainingInPage = pageBodySize;
-            drflac_uint8 packetType;
-
-            if (onRead(pUserData, &packetType, 1) != 1) {
-                return DRFLAC_FALSE;
-            }
-
-            bytesRemainingInPage -= 1;
-            if (packetType == 0x7F) {
-                /* Increasingly more likely to be a FLAC page... */
-                drflac_uint8 sig[4];
-                if (onRead(pUserData, sig, 4) != 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                bytesRemainingInPage -= 4;
-                if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
-                    /* Almost certainly a FLAC page... */
-                    drflac_uint8 mappingVersion[2];
-                    if (onRead(pUserData, mappingVersion, 2) != 2) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (mappingVersion[0] != 1) {
-                        return DRFLAC_FALSE;   /* Only supporting version 1.x of the Ogg mapping. */
-                    }
-
-                    /*
-                    The next 2 bytes are the non-audio packets, not including this one. We don't care about this because we're going to
-                    be handling it in a generic way based on the serial number and packet types.
-                    */
-                    if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    /* Expecting the native FLAC signature "fLaC". */
-                    if (onRead(pUserData, sig, 4) != 4) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
-                        /* The remaining data in the page should be the STREAMINFO block. */
-                        drflac_streaminfo streaminfo;
-                        drflac_uint8 isLastBlock;
-                        drflac_uint8 blockType;
-                        drflac_uint32 blockSize;
-                        if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-                            return DRFLAC_FALSE;
-                        }
-
-                        if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-                            return DRFLAC_FALSE;    /* Invalid block type. First block must be the STREAMINFO block. */
-                        }
-
-                        if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-                            /* Success! */
-                            pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-                            pInit->sampleRate              = streaminfo.sampleRate;
-                            pInit->channels                = streaminfo.channels;
-                            pInit->bitsPerSample           = streaminfo.bitsPerSample;
-                            pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-                            pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-                            pInit->hasMetadataBlocks       = !isLastBlock;
-
-                            if (onMeta) {
-                                drflac_metadata metadata;
-                                metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-                                metadata.pRawData = NULL;
-                                metadata.rawDataSize = 0;
-                                metadata.data.streaminfo = streaminfo;
-                                onMeta(pUserDataMD, &metadata);
-                            }
-
-                            pInit->runningFilePos  += pageBodySize;
-                            pInit->oggFirstBytePos  = pInit->runningFilePos - 79;   /* Subtracting 79 will place us right on top of the "OggS" identifier of the FLAC bos page. */
-                            pInit->oggSerial        = header.serialNumber;
-                            pInit->oggBosHeader     = header;
-                            break;
-                        } else {
-                            /* Failed to read STREAMINFO block. Aww, so close... */
-                            return DRFLAC_FALSE;
-                        }
-                    } else {
-                        /* Invalid file. */
-                        return DRFLAC_FALSE;
-                    }
-                } else {
-                    /* Not a FLAC header. Skip it. */
-                    if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* Not a FLAC header. Seek past the entire page and move on to the next. */
-                if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pInit->runningFilePos += pageBodySize;
-
-
-        /* Read the header of the next page. */
-        if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += bytesRead;
-    }
-
-    /*
-    If we get here it means we found a FLAC audio stream. We should be sitting on the first byte of the header of the next page. The next
-    packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialization phase for Ogg is to create the
-    Ogg bistream object.
-    */
-    pInit->hasMetadataBlocks = DRFLAC_TRUE;    /* <-- Always have at least VORBIS_COMMENT metadata block. */
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
-{
-    drflac_bool32 relaxed;
-    drflac_uint8 id[4];
-
-    if (pInit == NULL || onRead == NULL || onSeek == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
-    pInit->onRead       = onRead;
-    pInit->onSeek       = onSeek;
-    pInit->onMeta       = onMeta;
-    pInit->container    = container;
-    pInit->pUserData    = pUserData;
-    pInit->pUserDataMD  = pUserDataMD;
-
-    pInit->bs.onRead    = onRead;
-    pInit->bs.onSeek    = onSeek;
-    pInit->bs.pUserData = pUserData;
-    drflac__reset_cache(&pInit->bs);
-
-
-    /* If the container is explicitly defined then we can try opening in relaxed mode. */
-    relaxed = container != drflac_container_unknown;
-
-    /* Skip over any ID3 tags. */
-    for (;;) {
-        if (onRead(pUserData, id, 4) != 4) {
-            return DRFLAC_FALSE;    /* Ran out of data. */
-        }
-        pInit->runningFilePos += 4;
-
-        if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
-            drflac_uint8 header[6];
-            drflac_uint8 flags;
-            drflac_uint32 headerSize;
-
-            if (onRead(pUserData, header, 6) != 6) {
-                return DRFLAC_FALSE;    /* Ran out of data. */
-            }
-            pInit->runningFilePos += 6;
-
-            flags = header[1];
-
-            DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
-            headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
-            if (flags & 0x10) {
-                headerSize += 10;
-            }
-
-            if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;    /* Failed to seek past the tag. */
-            }
-            pInit->runningFilePos += headerSize;
-        } else {
-            break;
-        }
-    }
-
-    if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
-        return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
-        return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#endif
-
-    /* If we get here it means we likely don't have a header. Try opening in relaxed mode, if applicable. */
-    if (relaxed) {
-        if (container == drflac_container_native) {
-            return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (container == drflac_container_ogg) {
-            return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#endif
-    }
-
-    /* Unsupported container. */
-    return DRFLAC_FALSE;
-}
-
-static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pInit != NULL);
-
-    DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
-    pFlac->bs                      = pInit->bs;
-    pFlac->onMeta                  = pInit->onMeta;
-    pFlac->pUserDataMD             = pInit->pUserDataMD;
-    pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
-    pFlac->sampleRate              = pInit->sampleRate;
-    pFlac->channels                = (drflac_uint8)pInit->channels;
-    pFlac->bitsPerSample           = (drflac_uint8)pInit->bitsPerSample;
-    pFlac->totalPCMFrameCount      = pInit->totalPCMFrameCount;
-    pFlac->container               = pInit->container;
-}
-
-
-static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_init_info init;
-    drflac_uint32 allocationSize;
-    drflac_uint32 wholeSIMDVectorCountPerChannel;
-    drflac_uint32 decodedSamplesAllocationSize;
-#ifndef DR_FLAC_NO_OGG
-    drflac_oggbs oggbs;
-#endif
-    drflac_uint64 firstFramePos;
-    drflac_uint64 seektablePos;
-    drflac_uint32 seektableSize;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac* pFlac;
-
-    /* CPU support first. */
-    drflac__init_cpu_caps();
-
-    if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks != NULL) {
-        allocationCallbacks = *pAllocationCallbacks;
-        if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
-            return NULL;    /* Invalid allocation callbacks. */
-        }
-    } else {
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drflac__malloc_default;
-        allocationCallbacks.onRealloc = drflac__realloc_default;
-        allocationCallbacks.onFree    = drflac__free_default;
-    }
-
-
-    /*
-    The size of the allocation for the drflac object needs to be large enough to fit the following:
-      1) The main members of the drflac structure
-      2) A block of memory large enough to store the decoded samples of the largest frame in the stream
-      3) If the container is Ogg, a drflac_oggbs object
-
-    The complicated part of the allocation is making sure there's enough room the decoded samples, taking into consideration
-    the different SIMD instruction sets.
-    */
-    allocationSize = sizeof(drflac);
-
-    /*
-    The allocation size for decoded frames depends on the number of 32-bit integers that fit inside the largest SIMD vector
-    we are supporting.
-    */
-    if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
-    } else {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
-    }
-
-    decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
-
-    allocationSize += decodedSamplesAllocationSize;
-    allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE;  /* Allocate extra bytes to ensure we have enough for alignment. */
-
-#ifndef DR_FLAC_NO_OGG
-    /* There's additional data required for Ogg streams. */
-    if (init.container == drflac_container_ogg) {
-        allocationSize += sizeof(drflac_oggbs);
-    }
-
-    DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
-    if (init.container == drflac_container_ogg) {
-        oggbs.onRead = onRead;
-        oggbs.onSeek = onSeek;
-        oggbs.pUserData = pUserData;
-        oggbs.currentBytePos = init.oggFirstBytePos;
-        oggbs.firstBytePos = init.oggFirstBytePos;
-        oggbs.serialNumber = init.oggSerial;
-        oggbs.bosPageHeader = init.oggBosHeader;
-        oggbs.bytesRemainingInPage = 0;
-    }
-#endif
-
-    /*
-    This part is a bit awkward. We need to load the seektable so that it can be referenced in-memory, but I want the drflac object to
-    consist of only a single heap allocation. To this, the size of the seek table needs to be known, which we determine when reading
-    and decoding the metadata.
-    */
-    firstFramePos = 42;   /* <-- We know we are at byte 42 at this point. */
-    seektablePos  = 0;
-    seektableSize = 0;
-    if (init.hasMetadataBlocks) {
-        drflac_read_proc onReadOverride = onRead;
-        drflac_seek_proc onSeekOverride = onSeek;
-        void* pUserDataOverride = pUserData;
-
-#ifndef DR_FLAC_NO_OGG
-        if (init.container == drflac_container_ogg) {
-            onReadOverride = drflac__on_read_ogg;
-            onSeekOverride = drflac__on_seek_ogg;
-            pUserDataOverride = (void*)&oggbs;
-        }
-#endif
-
-        if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
-            return NULL;
-        }
-
-        allocationSize += seektableSize;
-    }
-
-
-    pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    drflac__init_from_info(pFlac, &init);
-    pFlac->allocationCallbacks = allocationCallbacks;
-    pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
-
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
-        *pInternalOggbs = oggbs;
-
-        /* The Ogg bistream needs to be layered on top of the original bitstream. */
-        pFlac->bs.onRead = drflac__on_read_ogg;
-        pFlac->bs.onSeek = drflac__on_seek_ogg;
-        pFlac->bs.pUserData = (void*)pInternalOggbs;
-        pFlac->_oggbs = (void*)pInternalOggbs;
-    }
-#endif
-
-    pFlac->firstFLACFramePosInBytes = firstFramePos;
-
-    /* NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has its own accelerated seeking system). I may change this later, so I'm leaving this here for now. */
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg)
-    {
-        pFlac->pSeekpoints = NULL;
-        pFlac->seekpointCount = 0;
-    }
-    else
-#endif
-    {
-        /* If we have a seektable we need to load it now, making sure we move back to where we were previously. */
-        if (seektablePos != 0) {
-            pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
-            pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
-
-            DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
-            DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
-
-            /* Seek to the seektable, then just read directly into our seektable buffer. */
-            if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
-                if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
-                    /* Endian swap. */
-                    drflac_uint32 iSeekpoint;
-                    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-                        pFlac->pSeekpoints[iSeekpoint].firstPCMFrame   = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
-                        pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
-                        pFlac->pSeekpoints[iSeekpoint].pcmFrameCount   = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
-                    }
-                } else {
-                    /* Failed to read the seektable. Pretend we don't have one. */
-                    pFlac->pSeekpoints = NULL;
-                    pFlac->seekpointCount = 0;
-                }
-
-                /* We need to seek back to where we were. If this fails it's a critical error. */
-                if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            } else {
-                /* Failed to seek to the seektable. Ominous sign, but for now we can just pretend we don't have one. */
-                pFlac->pSeekpoints = NULL;
-                pFlac->seekpointCount = 0;
-            }
-        }
-    }
-
-
-    /*
-    If we get here, but don't have a STREAMINFO block, it means we've opened the stream in relaxed mode and need to decode
-    the first frame.
-    */
-    if (!init.hasStreamInfoBlock) {
-        pFlac->currentFLACFrame.header = init.firstFrameHeader;
-        for (;;) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                break;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                        drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                        return NULL;
-                    }
-                    continue;
-                } else {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            }
-        }
-    }
-
-    return pFlac;
-}
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>      /* For wcslen(), wcsrtombs() */
-
-/* drflac_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
-#include <errno.h>
-static drflac_result drflac_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRFLAC_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRFLAC_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRFLAC_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRFLAC_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRFLAC_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRFLAC_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRFLAC_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRFLAC_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRFLAC_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRFLAC_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRFLAC_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRFLAC_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRFLAC_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRFLAC_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRFLAC_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRFLAC_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRFLAC_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRFLAC_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRFLAC_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRFLAC_ERROR;
-    #endif
-        default: return DRFLAC_ERROR;
-    }
-}
-
-static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drflac_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drflac_result result = drflac_result_from_errno(errno);
-        if (result == DRFLAC_SUCCESS) {
-            result = DRFLAC_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRFLAC_HAS_WFOPEN
-    #endif
-#endif
-
-static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(DRFLAC_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drflac_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drflac_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRFLAC_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drflac_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRFLAC_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRFLAC_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRFLAC_ERROR;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-#endif  /* DR_FLAC_NO_STDIO */
-
-static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    size_t bytesRemaining;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
-
-    bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
-        memoryStream->currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
-
-    if (offset > (drflac_int64)memoryStream->dataSize) {
-        return DRFLAC_FALSE;
-    }
-
-    if (origin == drflac_seek_origin_current) {
-        if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos += offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    } else {
-        if ((drflac_uint32)offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos = offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-
-
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API void drflac_close(drflac* pFlac)
-{
-    if (pFlac == NULL) {
-        return;
-    }
-
-#ifndef DR_FLAC_NO_STDIO
-    /*
-    If we opened the file with drflac_open_file() we will want to close the file handle. We can know whether or not drflac_open_file()
-    was used by looking at the callbacks.
-    */
-    if (pFlac->bs.onRead == drflac__on_read_stdio) {
-        fclose((FILE*)pFlac->bs.pUserData);
-    }
-
-#ifndef DR_FLAC_NO_OGG
-    /* Need to clean up Ogg streams a bit differently due to the way the bit streaming is chained. */
-    if (pFlac->container == drflac_container_ogg) {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
-
-        if (oggbs->onRead == drflac__on_read_stdio) {
-            fclose((FILE*)oggbs->pUserData);
-        }
-    }
-#endif
-#endif
-
-    drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    int32x4_t  wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t  wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-    uint32x4_t one4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    one4         = vdupq_n_u32(1);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift4_0 = vdupq_n_s32(shift0);
-    int32x4_t shift4_1 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
-
-        drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = ((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = ((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = ((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = ((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = ((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = ((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = ((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = ((drflac_int32)(mid3 - side3) >> 1);
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    int32x4_t wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        tempL0 >>= 16;
-        tempL1 >>= 16;
-        tempL2 >>= 16;
-        tempL3 >>= 16;
-
-        tempR0 >>= 16;
-        tempR1 >>= 16;
-        tempR2 >>= 16;
-        tempR3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int16)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int16)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int16)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int16)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int16)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int16)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int16)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        /* At this point we have results. We can now pack and interleave these into a single __m128i object and then store the in the output buffer. */
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift0_4 = vdupq_n_s32(shift0);
-    int32x4_t shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        left  = vshrq_n_s32(left,  16);
-        right = vshrq_n_s32(right, 16);
-
-        drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        left   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right  = vsubq_u32(left, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        side   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left   = vaddq_u32(right, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    __m128 factor128;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = 1.0f / 8388608.0f;
-    factor128 = _mm_set1_ps(factor);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128  leftf;
-            __m128  rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            tempR  = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128 leftf;
-            __m128 rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            tempR  = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    float32x4_t factor4;
-    int32x4_t shift4;
-    int32x4_t wbps0_4;  /* Wasted Bits Per Sample */
-    int32x4_t wbps1_4;  /* Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor  = 1.0f / 8388608.0f;
-    factor4 = vdupq_n_f32(factor);
-    wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            uint32x4_t mid  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            mid    = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    __m128 factor128 = _mm_set1_ps(factor);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i lefti;
-        __m128i righti;
-        __m128 leftf;
-        __m128 rightf;
-
-        lefti  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        leftf  = _mm_mul_ps(_mm_cvtepi32_ps(lefti),  factor128);
-        rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    float32x4_t factor4 = vdupq_n_f32(factor);
-    int32x4_t shift0_4  = vdupq_n_s32(shift0);
-    int32x4_t shift1_4  = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t lefti;
-        int32x4_t righti;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        lefti  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    if (pFlac == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Don't do anything if we're already on the seek point. */
-    if (pFlac->currentPCMFrame == pcmFrameIndex) {
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we don't know where the first frame begins then we can't seek. This will happen when the STREAMINFO block was not present
-    when the decoder was opened.
-    */
-    if (pFlac->firstFLACFramePosInBytes == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    if (pcmFrameIndex == 0) {
-        pFlac->currentPCMFrame = 0;
-        return drflac__seek_to_first_frame(pFlac);
-    } else {
-        drflac_bool32 wasSuccessful = DRFLAC_FALSE;
-        drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
-
-        /* Clamp the sample to the end. */
-        if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
-            pcmFrameIndex = pFlac->totalPCMFrameCount;
-        }
-
-        /* If the target sample and the current sample are in the same frame we just move the position forward. */
-        if (pcmFrameIndex > pFlac->currentPCMFrame) {
-            /* Forward. */
-            drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
-            if (pFlac->currentFLACFrame.pcmFramesRemaining >  offset) {
-                pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* Backward. */
-            drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
-            drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-            drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
-            if (currentFLACFramePCMFramesConsumed > offsetAbs) {
-                pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        }
-
-        /*
-        Different techniques depending on encapsulation. Using the native FLAC seektable with Ogg encapsulation is a bit awkward so
-        we'll instead use Ogg's natural seeking facility.
-        */
-#ifndef DR_FLAC_NO_OGG
-        if (pFlac->container == drflac_container_ogg)
-        {
-            wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
-        }
-        else
-#endif
-        {
-            /* First try seeking via the seek table. If this fails, fall back to a brute force seek which is much slower. */
-            if (/*!wasSuccessful && */!pFlac->_noSeekTableSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
-            }
-
-#if !defined(DR_FLAC_NO_CRC)
-            /* Fall back to binary search if seek table seeking fails. This requires the length of the stream to be known. */
-            if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
-                wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
-            }
-#endif
-
-            /* Fall back to brute force if all else fails. */
-            if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
-            }
-        }
-
-        if (wasSuccessful) {
-            pFlac->currentPCMFrame = pcmFrameIndex;
-        } else {
-            /* Seek failed. Try putting the decoder back to it's original state. */
-            if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
-                /* Failed to seek back to the original PCM frame. Fall back to 0. */
-                drflac_seek_to_pcm_frame(pFlac, 0);
-            }
-        }
-
-        return wasSuccessful;
-    }
-}
-
-
-
-/* High Level APIs */
-
-#if defined(SIZE_MAX)
-    #define DRFLAC_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(DRFLAC_64BIT)
-        #define DRFLAC_SIZE_MAX  ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRFLAC_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-
-/* Using a macro as the definition of the drflac__full_decode_and_close_*() API family. Sue me. */
-#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
-static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
-{                                                                                                                                                                   \
-    type* pSampleData = NULL;                                                                                                                                       \
-    drflac_uint64 totalPCMFrameCount;                                                                                                                               \
-                                                                                                                                                                    \
-    DRFLAC_ASSERT(pFlac != NULL);                                                                                                                                   \
-                                                                                                                                                                    \
-    totalPCMFrameCount = pFlac->totalPCMFrameCount;                                                                                                                 \
-                                                                                                                                                                    \
-    if (totalPCMFrameCount == 0) {                                                                                                                                  \
-        type buffer[4096];                                                                                                                                          \
-        drflac_uint64 pcmFramesRead;                                                                                                                                \
-        size_t sampleDataBufferSize = sizeof(buffer);                                                                                                               \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks);                                                      \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) {          \
-            if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) {                                                   \
-                type* pNewSampleData;                                                                                                                               \
-                size_t newSampleDataBufferSize;                                                                                                                     \
-                                                                                                                                                                    \
-                newSampleDataBufferSize = sampleDataBufferSize * 2;                                                                                                 \
-                pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks);    \
-                if (pNewSampleData == NULL) {                                                                                                                       \
-                    drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks);                                                                          \
-                    goto on_error;                                                                                                                                  \
-                }                                                                                                                                                   \
-                                                                                                                                                                    \
-                sampleDataBufferSize = newSampleDataBufferSize;                                                                                                     \
-                pSampleData = pNewSampleData;                                                                                                                       \
-            }                                                                                                                                                       \
-                                                                                                                                                                    \
-            DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type)));                   \
-            totalPCMFrameCount += pcmFramesRead;                                                                                                                    \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        /* At this point everything should be decoded, but we just want to fill the unused part buffer with silence - need to                                       \
-           protect those ears from random noise! */                                                                                                                 \
-        DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type)));   \
-    } else {                                                                                                                                                        \
-        drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type);                                                                                   \
-        if (dataSize > DRFLAC_SIZE_MAX) {                                                                                                                           \
-            goto on_error;  /* The decoded data is too big. */                                                                                                      \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks);    /* <-- Safe cast as per the check above. */           \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData);                                                     \
-    }                                                                                                                                                               \
-                                                                                                                                                                    \
-    if (sampleRateOut) *sampleRateOut = pFlac->sampleRate;                                                                                                          \
-    if (channelsOut) *channelsOut = pFlac->channels;                                                                                                                \
-    if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount;                                                                                         \
-                                                                                                                                                                    \
-    drflac_close(pFlac);                                                                                                                                            \
-    return pSampleData;                                                                                                                                             \
-                                                                                                                                                                    \
-on_error:                                                                                                                                                           \
-    drflac_close(pFlac);                                                                                                                                            \
-    return NULL;                                                                                                                                                    \
-}
-
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
-
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-#endif
-
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drflac__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drflac__free_default(p, NULL);
-    }
-}
-
-
-
-
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = commentCount;
-    pIter->pRunningData   = (const char*)pComments;
-}
-
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
-{
-    drflac_int32 length;
-    const char* pComment;
-
-    /* Safety. */
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = 0;
-    }
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return NULL;
-    }
-
-    length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
-    pIter->pRunningData += 4;
-
-    pComment = pIter->pRunningData;
-    pIter->pRunningData += length;
-    pIter->countRemaining -= 1;
-
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = length;
-    }
-
-    return pComment;
-}
-
-
-
-
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = trackCount;
-    pIter->pRunningData   = (const char*)pTrackData;
-}
-
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
-{
-    drflac_cuesheet_track cuesheetTrack;
-    const char* pRunningData;
-    drflac_uint64 offsetHi;
-    drflac_uint64 offsetLo;
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    pRunningData = pIter->pRunningData;
-
-    offsetHi                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    offsetLo                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    cuesheetTrack.offset       = offsetLo | (offsetHi << 32);
-    cuesheetTrack.trackNumber  = pRunningData[0];                                         pRunningData += 1;
-    DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC));     pRunningData += 12;
-    cuesheetTrack.isAudio      = (pRunningData[0] & 0x80) != 0;
-    cuesheetTrack.preEmphasis  = (pRunningData[0] & 0x40) != 0;                           pRunningData += 14;
-    cuesheetTrack.indexCount   = pRunningData[0];                                         pRunningData += 1;
-    cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData;        pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
-
-    pIter->pRunningData = pRunningData;
-    pIter->countRemaining -= 1;
-
-    if (pCuesheetTrack) {
-        *pCuesheetTrack = cuesheetTrack;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-#endif  /* dr_flac_c */
-#endif  /* DR_FLAC_IMPLEMENTATION */
-
-
-/*
-REVISION HISTORY
-================
-v0.12.29 - 2021-04-02
-  - Fix a bug where the running PCM frame index is set to an invalid value when over-seeking.
-  - Fix a decoding error due to an incorrect validation check.
-
-v0.12.28 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-
-v0.12.27 - 2021-01-31
-  - Fix a static analysis warning.
-
-v0.12.26 - 2021-01-17
-  - Fix a compilation warning due to _BSD_SOURCE being deprecated.
-
-v0.12.25 - 2020-12-26
-  - Update documentation.
-
-v0.12.24 - 2020-11-29
-  - Fix ARM64/NEON detection when compiling with MSVC.
-
-v0.12.23 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.12.22 - 2020-11-01
-  - Fix an error with the previous release.
-
-v0.12.21 - 2020-11-01
-  - Fix a possible deadlock when seeking.
-  - Improve compiler support for older versions of GCC.
-
-v0.12.20 - 2020-09-08
-  - Fix a compilation error on older compilers.
-
-v0.12.19 - 2020-08-30
-  - Fix a bug due to an undefined 32-bit shift.
-
-v0.12.18 - 2020-08-14
-  - Fix a crash when compiling with clang-cl.
-
-v0.12.17 - 2020-08-02
-  - Simplify sized types.
-
-v0.12.16 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.12.15 - 2020-07-06
-  - Check for negative LPC shifts and return an error.
-
-v0.12.14 - 2020-06-23
-  - Add include guard for the implementation section.
-
-v0.12.13 - 2020-05-16
-  - Add compile-time and run-time version querying.
-    - DRFLAC_VERSION_MINOR
-    - DRFLAC_VERSION_MAJOR
-    - DRFLAC_VERSION_REVISION
-    - DRFLAC_VERSION_STRING
-    - drflac_version()
-    - drflac_version_string()
-
-v0.12.12 - 2020-04-30
-  - Fix compilation errors with VC6.
-
-v0.12.11 - 2020-04-19
-  - Fix some pedantic warnings.
-  - Fix some undefined behaviour warnings.
-
-v0.12.10 - 2020-04-10
-  - Fix some bugs when trying to seek with an invalid seek table.
-
-v0.12.9 - 2020-04-05
-  - Fix warnings.
-
-v0.12.8 - 2020-04-04
-  - Add drflac_open_file_w() and drflac_open_file_with_metadata_w().
-  - Fix some static analysis warnings.
-  - Minor documentation updates.
-
-v0.12.7 - 2020-03-14
-  - Fix compilation errors with VC6.
-
-v0.12.6 - 2020-03-07
-  - Fix compilation error with Visual Studio .NET 2003.
-
-v0.12.5 - 2020-01-30
-  - Silence some static analysis warnings.
-
-v0.12.4 - 2020-01-29
-  - Silence some static analysis warnings.
-
-v0.12.3 - 2019-12-02
-  - Fix some warnings when compiling with GCC and the -Og flag.
-  - Fix a crash in out-of-memory situations.
-  - Fix potential integer overflow bug.
-  - Fix some static analysis warnings.
-  - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
-  - Fix a bug with binary search seeking where the bits per sample is not a multiple of 8.
-
-v0.12.2 - 2019-10-07
-  - Internal code clean up.
-
-v0.12.1 - 2019-09-29
-  - Fix some Clang Static Analyzer warnings.
-  - Fix an unused variable warning.
-
-v0.12.0 - 2019-09-23
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drflac_open()
-    - drflac_open_relaxed()
-    - drflac_open_with_metadata()
-    - drflac_open_with_metadata_relaxed()
-    - drflac_open_file()
-    - drflac_open_file_with_metadata()
-    - drflac_open_memory()
-    - drflac_open_memory_with_metadata()
-    - drflac_open_and_read_pcm_frames_s32()
-    - drflac_open_and_read_pcm_frames_s16()
-    - drflac_open_and_read_pcm_frames_f32()
-    - drflac_open_file_and_read_pcm_frames_s32()
-    - drflac_open_file_and_read_pcm_frames_s16()
-    - drflac_open_file_and_read_pcm_frames_f32()
-    - drflac_open_memory_and_read_pcm_frames_s32()
-    - drflac_open_memory_and_read_pcm_frames_s16()
-    - drflac_open_memory_and_read_pcm_frames_f32()
-    Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
-    DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-  - Remove deprecated APIs:
-    - drflac_read_s32()
-    - drflac_read_s16()
-    - drflac_read_f32()
-    - drflac_seek_to_sample()
-    - drflac_open_and_decode_s32()
-    - drflac_open_and_decode_s16()
-    - drflac_open_and_decode_f32()
-    - drflac_open_and_decode_file_s32()
-    - drflac_open_and_decode_file_s16()
-    - drflac_open_and_decode_file_f32()
-    - drflac_open_and_decode_memory_s32()
-    - drflac_open_and_decode_memory_s16()
-    - drflac_open_and_decode_memory_f32()
-  - Remove drflac.totalSampleCount which is now replaced with drflac.totalPCMFrameCount. You can emulate drflac.totalSampleCount
-    by doing pFlac->totalPCMFrameCount*pFlac->channels.
-  - Rename drflac.currentFrame to drflac.currentFLACFrame to remove ambiguity with PCM frames.
-  - Fix errors when seeking to the end of a stream.
-  - Optimizations to seeking.
-  - SSE improvements and optimizations.
-  - ARM NEON optimizations.
-  - Optimizations to drflac_read_pcm_frames_s16().
-  - Optimizations to drflac_read_pcm_frames_s32().
-
-v0.11.10 - 2019-06-26
-  - Fix a compiler error.
-
-v0.11.9 - 2019-06-16
-  - Silence some ThreadSanitizer warnings.
-
-v0.11.8 - 2019-05-21
-  - Fix warnings.
-
-v0.11.7 - 2019-05-06
-  - C89 fixes.
-
-v0.11.6 - 2019-05-05
-  - Add support for C89.
-  - Fix a compiler warning when CRC is disabled.
-  - Change license to choice of public domain or MIT-0.
-
-v0.11.5 - 2019-04-19
-  - Fix a compiler error with GCC.
-
-v0.11.4 - 2019-04-17
-  - Fix some warnings with GCC when compiling with -std=c99.
-
-v0.11.3 - 2019-04-07
-  - Silence warnings with GCC.
-
-v0.11.2 - 2019-03-10
-  - Fix a warning.
-
-v0.11.1 - 2019-02-17
-  - Fix a potential bug with seeking.
-
-v0.11.0 - 2018-12-16
-  - API CHANGE: Deprecated drflac_read_s32(), drflac_read_s16() and drflac_read_f32() and replaced them with
-    drflac_read_pcm_frames_s32(), drflac_read_pcm_frames_s16() and drflac_read_pcm_frames_f32(). The new APIs take
-    and return PCM frame counts instead of sample counts. To upgrade you will need to change the input count by
-    dividing it by the channel count, and then do the same with the return value.
-  - API_CHANGE: Deprecated drflac_seek_to_sample() and replaced with drflac_seek_to_pcm_frame(). Same rules as
-    the changes to drflac_read_*() apply.
-  - API CHANGE: Deprecated drflac_open_and_decode_*() and replaced with drflac_open_*_and_read_*(). Same rules as
-    the changes to drflac_read_*() apply.
-  - Optimizations.
-
-v0.10.0 - 2018-09-11
-  - Remove the DR_FLAC_NO_WIN32_IO option and the Win32 file IO functionality. If you need to use Win32 file IO you
-    need to do it yourself via the callback API.
-  - Fix the clang build.
-  - Fix undefined behavior.
-  - Fix errors with CUESHEET metdata blocks.
-  - Add an API for iterating over each cuesheet track in the CUESHEET metadata block. This works the same way as the
-    Vorbis comment API.
-  - Other miscellaneous bug fixes, mostly relating to invalid FLAC streams.
-  - Minor optimizations.
-
-v0.9.11 - 2018-08-29
-  - Fix a bug with sample reconstruction.
-
-v0.9.10 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.9.9 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-
-v0.9.8 - 2018-07-24
-  - Fix compilation errors.
-
-v0.9.7 - 2018-07-05
-  - Fix a warning.
-
-v0.9.6 - 2018-06-29
-  - Fix some typos.
-
-v0.9.5 - 2018-06-23
-  - Fix some warnings.
-
-v0.9.4 - 2018-06-14
-  - Optimizations to seeking.
-  - Clean up.
-
-v0.9.3 - 2018-05-22
-  - Bug fix.
-
-v0.9.2 - 2018-05-12
-  - Fix a compilation error due to a missing break statement.
-
-v0.9.1 - 2018-04-29
-  - Fix compilation error with Clang.
-
-v0.9 - 2018-04-24
-  - Fix Clang build.
-  - Start using major.minor.revision versioning.
-
-v0.8g - 2018-04-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8f - 2018-02-02
-  - Stop pretending to support changing rate/channels mid stream.
-
-v0.8e - 2018-02-01
-  - Fix a crash when the block size of a frame is larger than the maximum block size defined by the FLAC stream.
-  - Fix a crash the the Rice partition order is invalid.
-
-v0.8d - 2017-09-22
-  - Add support for decoding streams with ID3 tags. ID3 tags are just skipped.
-
-v0.8c - 2017-09-07
-  - Fix warning on non-x86/x64 architectures.
-
-v0.8b - 2017-08-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8a - 2017-08-13
-  - A small optimization for the Clang build.
-
-v0.8 - 2017-08-12
-  - API CHANGE: Rename dr_* types to drflac_*.
-  - Optimizations. This brings dr_flac back to about the same class of efficiency as the reference implementation.
-  - Add support for custom implementations of malloc(), realloc(), etc.
-  - Add CRC checking to Ogg encapsulated streams.
-  - Fix VC++ 6 build. This is only for the C++ compiler. The C compiler is not currently supported.
-  - Bug fixes.
-
-v0.7 - 2017-07-23
-  - Add support for opening a stream without a header block. To do this, use drflac_open_relaxed() / drflac_open_with_metadata_relaxed().
-
-v0.6 - 2017-07-22
-  - Add support for recovering from invalid frames. With this change, dr_flac will simply skip over invalid frames as if they
-    never existed. Frames are checked against their sync code, the CRC-8 of the frame header and the CRC-16 of the whole frame.
-
-v0.5 - 2017-07-16
-  - Fix typos.
-  - Change drflac_bool* types to unsigned.
-  - Add CRC checking. This makes dr_flac slower, but can be disabled with #define DR_FLAC_NO_CRC.
-
-v0.4f - 2017-03-10
-  - Fix a couple of bugs with the bitstreaming code.
-
-v0.4e - 2017-02-17
-  - Fix some warnings.
-
-v0.4d - 2016-12-26
-  - Add support for 32-bit floating-point PCM decoding.
-  - Use drflac_int* and drflac_uint* sized types to improve compiler support.
-  - Minor improvements to documentation.
-
-v0.4c - 2016-12-26
-  - Add support for signed 16-bit integer PCM decoding.
-
-v0.4b - 2016-10-23
-  - A minor change to drflac_bool8 and drflac_bool32 types.
-
-v0.4a - 2016-10-11
-  - Rename drBool32 to drflac_bool32 for styling consistency.
-
-v0.4 - 2016-09-29
-  - API/ABI CHANGE: Use fixed size 32-bit booleans instead of the built-in bool type.
-  - API CHANGE: Rename drflac_open_and_decode*() to drflac_open_and_decode*_s32().
-  - API CHANGE: Swap the order of "channels" and "sampleRate" parameters in drflac_open_and_decode*(). Rationale for this is to
-    keep it consistent with drflac_audio.
-
-v0.3f - 2016-09-21
-  - Fix a warning with GCC.
-
-v0.3e - 2016-09-18
-  - Fixed a bug where GCC 4.3+ was not getting properly identified.
-  - Fixed a few typos.
-  - Changed date formats to ISO 8601 (YYYY-MM-DD).
-
-v0.3d - 2016-06-11
-  - Minor clean up.
-
-v0.3c - 2016-05-28
-  - Fixed compilation error.
-
-v0.3b - 2016-05-16
-  - Fixed Linux/GCC build.
-  - Updated documentation.
-
-v0.3a - 2016-05-15
-  - Minor fixes to documentation.
-
-v0.3 - 2016-05-11
-  - Optimizations. Now at about parity with the reference implementation on 32-bit builds.
-  - Lots of clean up.
-
-v0.2b - 2016-05-10
-  - Bug fixes.
-
-v0.2a - 2016-05-10
-  - Made drflac_open_and_decode() more robust.
-  - Removed an unused debugging variable
-
-v0.2 - 2016-05-09
-  - Added support for Ogg encapsulation.
-  - API CHANGE. Have the onSeek callback take a third argument which specifies whether or not the seek
-    should be relative to the start or the current position. Also changes the seeking rules such that
-    seeking offsets will never be negative.
-  - Have drflac_open_and_decode() fail gracefully if the stream has an unknown total sample count.
-
-v0.1b - 2016-05-07
-  - Properly close the file handle in drflac_open_file() and family when the decoder fails to initialize.
-  - Removed a stale comment.
-
-v0.1a - 2016-05-05
-  - Minor formatting changes.
-  - Fixed a warning on the GCC build.
-
-v0.1 - 2016-05-03
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib/external/dr_mp3.h b/raylib/external/dr_mp3.h
deleted file mode 100644 (file)
index e28f318..0000000
+++ /dev/null
@@ -1,4750 +0,0 @@
-/*
-MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_mp3 - v0.6.27 - 2021-02-21
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-
-Based on minimp3 (https://github.com/lieff/minimp3) which is where the real work was done. See the bottom of this file for differences between minimp3 and dr_mp3.
-*/
-
-/*
-RELEASE NOTES - VERSION 0.6
-===========================
-Version 0.6 includes breaking changes with the configuration of decoders. The ability to customize the number of output channels and the sample rate has been
-removed. You must now use the channel count and sample rate reported by the MP3 stream itself, and all channel and sample rate conversion must be done
-yourself.
-
-
-Changes to Initialization
--------------------------
-Previously, `drmp3_init()`, etc. took a pointer to a `drmp3_config` object that allowed you to customize the output channels and sample rate. This has been
-removed. If you need the old behaviour you will need to convert the data yourself or just not upgrade. The following APIs have changed.
-
-    `drmp3_init()`
-    `drmp3_init_memory()`
-    `drmp3_init_file()`
-
-
-Miscellaneous Changes
----------------------
-Support for loading a file from a `wchar_t` string has been added via the `drmp3_init_file_w()` API.
-*/
-
-/*
-Introducation
-=============
-dr_mp3 is a single file library. To use it, do something like the following in one .c file.
-
-    ```c
-    #define DR_MP3_IMPLEMENTATION
-    #include "dr_mp3.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
-
-    ```c
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, "MySong.mp3", NULL)) {
-        // Failed to open file
-    }
-
-    ...
-
-    drmp3_uint64 framesRead = drmp3_read_pcm_frames_f32(pMP3, framesToRead, pFrames);
-    ```
-
-The drmp3 object is transparent so you can get access to the channel count and sample rate like so:
-
-    ```
-    drmp3_uint32 channels = mp3.channels;
-    drmp3_uint32 sampleRate = mp3.sampleRate;
-    ```
-
-The example above initializes a decoder from a file, but you can also initialize it from a block of memory and read and seek callbacks with
-`drmp3_init_memory()` and `drmp3_init()` respectively.
-
-You do not need to do any annoying memory management when reading PCM frames - this is all managed internally. You can request any number of PCM frames in each
-call to `drmp3_read_pcm_frames_f32()` and it will return as many PCM frames as it can, up to the requested amount.
-
-You can also decode an entire file in one go with `drmp3_open_and_read_pcm_frames_f32()`, `drmp3_open_memory_and_read_pcm_frames_f32()` and
-`drmp3_open_file_and_read_pcm_frames_f32()`.
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_MP3_NO_STDIO
-  Disable drmp3_init_file(), etc.
-
-#define DR_MP3_NO_SIMD
-  Disable SIMD optimizations.
-*/
-
-#ifndef dr_mp3_h
-#define dr_mp3_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRMP3_STRINGIFY(x)      #x
-#define DRMP3_XSTRINGIFY(x)     DRMP3_STRINGIFY(x)
-
-#define DRMP3_VERSION_MAJOR     0
-#define DRMP3_VERSION_MINOR     6
-#define DRMP3_VERSION_REVISION  27
-#define DRMP3_VERSION_STRING    DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drmp3_int8;
-typedef unsigned char           drmp3_uint8;
-typedef   signed short          drmp3_int16;
-typedef unsigned short          drmp3_uint16;
-typedef   signed int            drmp3_int32;
-typedef unsigned int            drmp3_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drmp3_int64;
-    typedef unsigned __int64    drmp3_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drmp3_int64;
-    typedef unsigned long long  drmp3_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drmp3_uint64        drmp3_uintptr;
-#else
-    typedef drmp3_uint32        drmp3_uintptr;
-#endif
-typedef drmp3_uint8             drmp3_bool8;
-typedef drmp3_uint32            drmp3_bool32;
-#define DRMP3_TRUE              1
-#define DRMP3_FALSE             0
-
-#if !defined(DRMP3_API)
-    #if defined(DRMP3_DLL)
-        #if defined(_WIN32)
-            #define DRMP3_DLL_IMPORT  __declspec(dllimport)
-            #define DRMP3_DLL_EXPORT  __declspec(dllexport)
-            #define DRMP3_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRMP3_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRMP3_DLL_IMPORT
-                #define DRMP3_DLL_EXPORT
-                #define DRMP3_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-            #define DRMP3_API  DRMP3_DLL_EXPORT
-        #else
-            #define DRMP3_API  DRMP3_DLL_IMPORT
-        #endif
-        #define DRMP3_PRIVATE DRMP3_DLL_PRIVATE
-    #else
-        #define DRMP3_API extern
-        #define DRMP3_PRIVATE static
-    #endif
-#endif
-
-typedef drmp3_int32 drmp3_result;
-#define DRMP3_SUCCESS                        0
-#define DRMP3_ERROR                         -1   /* A generic error. */
-#define DRMP3_INVALID_ARGS                  -2
-#define DRMP3_INVALID_OPERATION             -3
-#define DRMP3_OUT_OF_MEMORY                 -4
-#define DRMP3_OUT_OF_RANGE                  -5
-#define DRMP3_ACCESS_DENIED                 -6
-#define DRMP3_DOES_NOT_EXIST                -7
-#define DRMP3_ALREADY_EXISTS                -8
-#define DRMP3_TOO_MANY_OPEN_FILES           -9
-#define DRMP3_INVALID_FILE                  -10
-#define DRMP3_TOO_BIG                       -11
-#define DRMP3_PATH_TOO_LONG                 -12
-#define DRMP3_NAME_TOO_LONG                 -13
-#define DRMP3_NOT_DIRECTORY                 -14
-#define DRMP3_IS_DIRECTORY                  -15
-#define DRMP3_DIRECTORY_NOT_EMPTY           -16
-#define DRMP3_END_OF_FILE                   -17
-#define DRMP3_NO_SPACE                      -18
-#define DRMP3_BUSY                          -19
-#define DRMP3_IO_ERROR                      -20
-#define DRMP3_INTERRUPT                     -21
-#define DRMP3_UNAVAILABLE                   -22
-#define DRMP3_ALREADY_IN_USE                -23
-#define DRMP3_BAD_ADDRESS                   -24
-#define DRMP3_BAD_SEEK                      -25
-#define DRMP3_BAD_PIPE                      -26
-#define DRMP3_DEADLOCK                      -27
-#define DRMP3_TOO_MANY_LINKS                -28
-#define DRMP3_NOT_IMPLEMENTED               -29
-#define DRMP3_NO_MESSAGE                    -30
-#define DRMP3_BAD_MESSAGE                   -31
-#define DRMP3_NO_DATA_AVAILABLE             -32
-#define DRMP3_INVALID_DATA                  -33
-#define DRMP3_TIMEOUT                       -34
-#define DRMP3_NO_NETWORK                    -35
-#define DRMP3_NOT_UNIQUE                    -36
-#define DRMP3_NOT_SOCKET                    -37
-#define DRMP3_NO_ADDRESS                    -38
-#define DRMP3_BAD_PROTOCOL                  -39
-#define DRMP3_PROTOCOL_UNAVAILABLE          -40
-#define DRMP3_PROTOCOL_NOT_SUPPORTED        -41
-#define DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRMP3_SOCKET_NOT_SUPPORTED          -44
-#define DRMP3_CONNECTION_RESET              -45
-#define DRMP3_ALREADY_CONNECTED             -46
-#define DRMP3_NOT_CONNECTED                 -47
-#define DRMP3_CONNECTION_REFUSED            -48
-#define DRMP3_NO_HOST                       -49
-#define DRMP3_IN_PROGRESS                   -50
-#define DRMP3_CANCELLED                     -51
-#define DRMP3_MEMORY_ALREADY_MAPPED         -52
-#define DRMP3_AT_END                        -53
-
-
-#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME  1152
-#define DRMP3_MAX_SAMPLES_PER_FRAME         (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
-
-#ifdef _MSC_VER
-    #define DRMP3_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRMP3_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRMP3_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRMP3_INLINE __inline
-#else
-    #define DRMP3_INLINE
-#endif
-
-
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision);
-DRMP3_API const char* drmp3_version_string(void);
-
-
-/*
-Low Level Push API
-==================
-*/
-typedef struct
-{
-    int frame_bytes, channels, hz, layer, bitrate_kbps;
-} drmp3dec_frame_info;
-
-typedef struct
-{
-    float mdct_overlap[2][9*32], qmf_state[15*2*32];
-    int reserv, free_format_bytes;
-    drmp3_uint8 header[4], reserv_buf[511];
-} drmp3dec;
-
-/* Initializes a low level decoder. */
-DRMP3_API void drmp3dec_init(drmp3dec *dec);
-
-/* Reads a frame from a low level decoder. */
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info);
-
-/* Helper for converting between f32 and s16. */
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples);
-
-
-
-/*
-Main API (Pull API)
-===================
-*/
-typedef enum
-{
-    drmp3_seek_origin_start,
-    drmp3_seek_origin_current
-} drmp3_seek_origin;
-
-typedef struct
-{
-    drmp3_uint64 seekPosInBytes;        /* Points to the first byte of an MP3 frame. */
-    drmp3_uint64 pcmFrameIndex;         /* The index of the PCM frame this seek point targets. */
-    drmp3_uint16 mp3FramesToDiscard;    /* The number of whole MP3 frames to be discarded before pcmFramesToDiscard. */
-    drmp3_uint16 pcmFramesToDiscard;    /* The number of leading samples to read and discard. These are discarded after mp3FramesToDiscard. */
-} drmp3_seek_point;
-
-/*
-Callback for when data is read. Return value is the number of bytes actually read.
-
-pUserData   [in]  The user data that was passed to drmp3_init(), drmp3_open() and family.
-pBufferOut  [out] The output buffer.
-bytesToRead [in]  The number of bytes to read.
-
-Returns the number of bytes actually read.
-
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
-either the entire bytesToRead is filled or you have reached the end of the stream.
-*/
-typedef size_t (* drmp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data needs to be seeked.
-
-pUserData [in] The user data that was passed to drmp3_init(), drmp3_open() and family.
-offset    [in] The number of bytes to move, relative to the origin. Will never be negative.
-origin    [in] The origin of the seek - the current position or the start of the stream.
-
-Returns whether or not the seek was successful.
-
-Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which
-will be either drmp3_seek_origin_start or drmp3_seek_origin_current.
-*/
-typedef drmp3_bool32 (* drmp3_seek_proc)(void* pUserData, int offset, drmp3_seek_origin origin);
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drmp3_allocation_callbacks;
-
-typedef struct
-{
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-} drmp3_config;
-
-typedef struct
-{
-    drmp3dec decoder;
-    drmp3dec_frame_info frameInfo;
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-    drmp3_read_proc onRead;
-    drmp3_seek_proc onSeek;
-    void* pUserData;
-    drmp3_allocation_callbacks allocationCallbacks;
-    drmp3_uint32 mp3FrameChannels;      /* The number of channels in the currently loaded MP3 frame. Internal use only. */
-    drmp3_uint32 mp3FrameSampleRate;    /* The sample rate of the currently loaded MP3 frame. Internal use only. */
-    drmp3_uint32 pcmFramesConsumedInMP3Frame;
-    drmp3_uint32 pcmFramesRemainingInMP3Frame;
-    drmp3_uint8 pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];  /* <-- Multipled by sizeof(float) to ensure there's enough room for DR_MP3_FLOAT_OUTPUT. */
-    drmp3_uint64 currentPCMFrame;       /* The current PCM frame, globally, based on the output sample rate. Mainly used for seeking. */
-    drmp3_uint64 streamCursor;          /* The current byte the decoder is sitting on in the raw stream. */
-    drmp3_seek_point* pSeekPoints;      /* NULL by default. Set with drmp3_bind_seek_table(). Memory is owned by the client. dr_mp3 will never attempt to free this pointer. */
-    drmp3_uint32 seekPointCount;        /* The number of items in pSeekPoints. When set to 0 assumes to no seek table. Defaults to zero. */
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t dataConsumed;
-    drmp3_uint8* pData;
-    drmp3_bool32 atEnd : 1;
-    struct
-    {
-        const drmp3_uint8* pData;
-        size_t dataSize;
-        size_t currentReadPos;
-    } memory;   /* Only used for decoders that were opened against a block of memory. */
-} drmp3;
-
-/*
-Initializes an MP3 decoder.
-
-onRead    [in]           The function to call when data needs to be read from the client.
-onSeek    [in]           The function to call when the read position of the client data needs to move.
-pUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
-
-Returns true if successful; false otherwise.
-
-Close the loader with drmp3_uninit().
-
-See also: drmp3_init_file(), drmp3_init_memory(), drmp3_uninit()
-*/
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Initializes an MP3 decoder from a block of memory.
-
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
-the lifetime of the drmp3 object.
-
-The buffer should contain the contents of the entire MP3 file.
-*/
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_MP3_NO_STDIO
-/*
-Initializes an MP3 decoder from a file.
-
-This holds the internal FILE object until drmp3_uninit() is called. Keep this in mind if you're caching drmp3
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Uninitializes an MP3 decoder.
-*/
-DRMP3_API void drmp3_uninit(drmp3* pMP3);
-
-/*
-Reads PCM frames as interleaved 32-bit IEEE floating point PCM.
-
-Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
-*/
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut);
-
-/*
-Reads PCM frames as interleaved signed 16-bit integer PCM.
-
-Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
-*/
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut);
-
-/*
-Seeks to a specific frame.
-
-Note that this is _not_ an MP3 frame, but rather a PCM frame.
-*/
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex);
-
-/*
-Calculates the total number of PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-*/
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3);
-
-/*
-Calculates the total number of MP3 frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-*/
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3);
-
-/*
-Calculates the total number of MP3 and PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-
-This is equivalent to calling drmp3_get_mp3_frame_count() and drmp3_get_pcm_frame_count() except that it's more efficient.
-*/
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount);
-
-/*
-Calculates the seekpoints based on PCM frames. This is slow.
-
-pSeekpoint count is a pointer to a uint32 containing the seekpoint count. On input it contains the desired count.
-On output it contains the actual count. The reason for this design is that the client may request too many
-seekpoints, in which case dr_mp3 will return a corrected count.
-
-Note that seektable seeking is not quite sample exact when the MP3 stream contains inconsistent sample rates.
-*/
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints);
-
-/*
-Binds a seek table to the decoder.
-
-This does _not_ make a copy of pSeekPoints - it only references it. It is up to the application to ensure this
-remains valid while it is bound to the decoder.
-
-Use drmp3_calculate_seek_points() to calculate the seek points.
-*/
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints);
-
-
-/*
-Opens an decodes an entire MP3 stream as a single operation.
-
-On output pConfig will receive the channel count and sample rate of the stream.
-
-Free the returned pointer with drmp3_free().
-*/
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Allocates a block of memory on the heap.
-*/
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Frees any memory that was allocated by a public drmp3 API.
-*/
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_mp3_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-#ifndef dr_mp3_c
-#define dr_mp3_c
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h> /* For INT_MAX */
-
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRMP3_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRMP3_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRMP3_VERSION_REVISION;
-    }
-}
-
-DRMP3_API const char* drmp3_version_string(void)
-{
-    return DRMP3_VERSION_STRING;
-}
-
-/* Disable SIMD when compiling with TCC for now. */
-#if defined(__TINYC__)
-#define DR_MP3_NO_SIMD
-#endif
-
-#define DRMP3_OFFSET_PTR(p, offset) ((void*)((drmp3_uint8*)(p) + (offset)))
-
-#define DRMP3_MAX_FREE_FORMAT_FRAME_SIZE  2304    /* more than ISO spec's */
-#ifndef DRMP3_MAX_FRAME_SYNC_MATCHES
-#define DRMP3_MAX_FRAME_SYNC_MATCHES      10
-#endif
-
-#define DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES  DRMP3_MAX_FREE_FORMAT_FRAME_SIZE /* MUST be >= 320000/8/32000*1152 = 1440 */
-
-#define DRMP3_MAX_BITRESERVOIR_BYTES      511
-#define DRMP3_SHORT_BLOCK_TYPE            2
-#define DRMP3_STOP_BLOCK_TYPE             3
-#define DRMP3_MODE_MONO                   3
-#define DRMP3_MODE_JOINT_STEREO           1
-#define DRMP3_HDR_SIZE                    4
-#define DRMP3_HDR_IS_MONO(h)              (((h[3]) & 0xC0) == 0xC0)
-#define DRMP3_HDR_IS_MS_STEREO(h)         (((h[3]) & 0xE0) == 0x60)
-#define DRMP3_HDR_IS_FREE_FORMAT(h)       (((h[2]) & 0xF0) == 0)
-#define DRMP3_HDR_IS_CRC(h)               (!((h[1]) & 1))
-#define DRMP3_HDR_TEST_PADDING(h)         ((h[2]) & 0x2)
-#define DRMP3_HDR_TEST_MPEG1(h)           ((h[1]) & 0x8)
-#define DRMP3_HDR_TEST_NOT_MPEG25(h)      ((h[1]) & 0x10)
-#define DRMP3_HDR_TEST_I_STEREO(h)        ((h[3]) & 0x10)
-#define DRMP3_HDR_TEST_MS_STEREO(h)       ((h[3]) & 0x20)
-#define DRMP3_HDR_GET_STEREO_MODE(h)      (((h[3]) >> 6) & 3)
-#define DRMP3_HDR_GET_STEREO_MODE_EXT(h)  (((h[3]) >> 4) & 3)
-#define DRMP3_HDR_GET_LAYER(h)            (((h[1]) >> 1) & 3)
-#define DRMP3_HDR_GET_BITRATE(h)          ((h[2]) >> 4)
-#define DRMP3_HDR_GET_SAMPLE_RATE(h)      (((h[2]) >> 2) & 3)
-#define DRMP3_HDR_GET_MY_SAMPLE_RATE(h)   (DRMP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3)
-#define DRMP3_HDR_IS_FRAME_576(h)         ((h[1] & 14) == 2)
-#define DRMP3_HDR_IS_LAYER_1(h)           ((h[1] & 6) == 6)
-
-#define DRMP3_BITS_DEQUANTIZER_OUT        -1
-#define DRMP3_MAX_SCF                     (255 + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210)
-#define DRMP3_MAX_SCFI                    ((DRMP3_MAX_SCF + 3) & ~3)
-
-#define DRMP3_MIN(a, b)           ((a) > (b) ? (b) : (a))
-#define DRMP3_MAX(a, b)           ((a) < (b) ? (b) : (a))
-
-#if !defined(DR_MP3_NO_SIMD)
-
-#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
-/* x64 always have SSE2, arm64 always have neon, no need for generic code */
-#define DR_MP3_ONLY_SIMD
-#endif
-
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
-#if defined(_MSC_VER)
-#include <intrin.h>
-#endif
-#include <emmintrin.h>
-#define DRMP3_HAVE_SSE 1
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE _mm_storeu_ps
-#define DRMP3_VLD _mm_loadu_ps
-#define DRMP3_VSET _mm_set1_ps
-#define DRMP3_VADD _mm_add_ps
-#define DRMP3_VSUB _mm_sub_ps
-#define DRMP3_VMUL _mm_mul_ps
-#define DRMP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMUL_S(x, s)  _mm_mul_ps(x, _mm_set1_ps(s))
-#define DRMP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3))
-typedef __m128 drmp3_f4;
-#if defined(_MSC_VER) || defined(DR_MP3_ONLY_SIMD)
-#define drmp3_cpuid __cpuid
-#else
-static __inline__ __attribute__((always_inline)) void drmp3_cpuid(int CPUInfo[], const int InfoType)
-{
-#if defined(__PIC__)
-    __asm__ __volatile__(
-#if defined(__x86_64__)
-        "push %%rbx\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-        "pop  %%rbx\n"
-#else
-        "xchgl %%ebx, %1\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-#endif
-        : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#else
-    __asm__ __volatile__(
-        "cpuid"
-        : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#endif
-}
-#endif
-static int drmp3_have_simd(void)
-{
-#ifdef DR_MP3_ONLY_SIMD
-    return 1;
-#else
-    static int g_have_simd;
-    int CPUInfo[4];
-#ifdef MINIMP3_TEST
-    static int g_counter;
-    if (g_counter++ > 100)
-        return 0;
-#endif
-    if (g_have_simd)
-        goto end;
-    drmp3_cpuid(CPUInfo, 0);
-    if (CPUInfo[0] > 0)
-    {
-        drmp3_cpuid(CPUInfo, 1);
-        g_have_simd = (CPUInfo[3] & (1 << 26)) + 1; /* SSE2 */
-        return g_have_simd - 1;
-    }
-
-end:
-    return g_have_simd - 1;
-#endif
-}
-#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
-#include <arm_neon.h>
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE vst1q_f32
-#define DRMP3_VLD vld1q_f32
-#define DRMP3_VSET vmovq_n_f32
-#define DRMP3_VADD vaddq_f32
-#define DRMP3_VSUB vsubq_f32
-#define DRMP3_VMUL vmulq_f32
-#define DRMP3_VMAC(a, x, y) vmlaq_f32(a, x, y)
-#define DRMP3_VMSB(a, x, y) vmlsq_f32(a, x, y)
-#define DRMP3_VMUL_S(x, s)  vmulq_f32(x, vmovq_n_f32(s))
-#define DRMP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x)))
-typedef float32x4_t drmp3_f4;
-static int drmp3_have_simd(void)
-{   /* TODO: detect neon for !DR_MP3_ONLY_SIMD */
-    return 1;
-}
-#else
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 0
-#ifdef DR_MP3_ONLY_SIMD
-#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
-#endif
-#endif
-
-#else
-
-#define DRMP3_HAVE_SIMD 0
-
-#endif
-
-#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64)
-#define DRMP3_HAVE_ARMV6 1
-static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_arm(int32_t a)
-{
-    drmp3_int32 x = 0;
-    __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
-    return x;
-}
-#else
-#define DRMP3_HAVE_ARMV6 0
-#endif
-
-
-typedef struct
-{
-    const drmp3_uint8 *buf;
-    int pos, limit;
-} drmp3_bs;
-
-typedef struct
-{
-    float scf[3*64];
-    drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64];
-} drmp3_L12_scale_info;
-
-typedef struct
-{
-    drmp3_uint8 tab_offset, code_tab_width, band_count;
-} drmp3_L12_subband_alloc;
-
-typedef struct
-{
-    const drmp3_uint8 *sfbtab;
-    drmp3_uint16 part_23_length, big_values, scalefac_compress;
-    drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb;
-    drmp3_uint8 table_select[3], region_count[3], subblock_gain[3];
-    drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi;
-} drmp3_L3_gr_info;
-
-typedef struct
-{
-    drmp3_bs bs;
-    drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES];
-    drmp3_L3_gr_info gr_info[4];
-    float grbuf[2][576], scf[40], syn[18 + 15][2*32];
-    drmp3_uint8 ist_pos[2][39];
-} drmp3dec_scratch;
-
-static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes)
-{
-    bs->buf   = data;
-    bs->pos   = 0;
-    bs->limit = bytes*8;
-}
-
-static drmp3_uint32 drmp3_bs_get_bits(drmp3_bs *bs, int n)
-{
-    drmp3_uint32 next, cache = 0, s = bs->pos & 7;
-    int shl = n + s;
-    const drmp3_uint8 *p = bs->buf + (bs->pos >> 3);
-    if ((bs->pos += n) > bs->limit)
-        return 0;
-    next = *p++ & (255 >> s);
-    while ((shl -= 8) > 0)
-    {
-        cache |= next << shl;
-        next = *p++;
-    }
-    return cache | (next >> -shl);
-}
-
-static int drmp3_hdr_valid(const drmp3_uint8 *h)
-{
-    return h[0] == 0xff &&
-        ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) &&
-        (DRMP3_HDR_GET_LAYER(h) != 0) &&
-        (DRMP3_HDR_GET_BITRATE(h) != 15) &&
-        (DRMP3_HDR_GET_SAMPLE_RATE(h) != 3);
-}
-
-static int drmp3_hdr_compare(const drmp3_uint8 *h1, const drmp3_uint8 *h2)
-{
-    return drmp3_hdr_valid(h2) &&
-        ((h1[1] ^ h2[1]) & 0xFE) == 0 &&
-        ((h1[2] ^ h2[2]) & 0x0C) == 0 &&
-        !(DRMP3_HDR_IS_FREE_FORMAT(h1) ^ DRMP3_HDR_IS_FREE_FORMAT(h2));
-}
-
-static unsigned drmp3_hdr_bitrate_kbps(const drmp3_uint8 *h)
-{
-    static const drmp3_uint8 halfrate[2][3][15] = {
-        { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } },
-        { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } },
-    };
-    return 2*halfrate[!!DRMP3_HDR_TEST_MPEG1(h)][DRMP3_HDR_GET_LAYER(h) - 1][DRMP3_HDR_GET_BITRATE(h)];
-}
-
-static unsigned drmp3_hdr_sample_rate_hz(const drmp3_uint8 *h)
-{
-    static const unsigned g_hz[3] = { 44100, 48000, 32000 };
-    return g_hz[DRMP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!DRMP3_HDR_TEST_MPEG1(h) >> (int)!DRMP3_HDR_TEST_NOT_MPEG25(h);
-}
-
-static unsigned drmp3_hdr_frame_samples(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)DRMP3_HDR_IS_FRAME_576(h));
-}
-
-static int drmp3_hdr_frame_bytes(const drmp3_uint8 *h, int free_format_size)
-{
-    int frame_bytes = drmp3_hdr_frame_samples(h)*drmp3_hdr_bitrate_kbps(h)*125/drmp3_hdr_sample_rate_hz(h);
-    if (DRMP3_HDR_IS_LAYER_1(h))
-    {
-        frame_bytes &= ~3; /* slot align */
-    }
-    return frame_bytes ? frame_bytes : free_format_size;
-}
-
-static int drmp3_hdr_padding(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_TEST_PADDING(h) ? (DRMP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0;
-}
-
-#ifndef DR_MP3_ONLY_MP3
-static const drmp3_L12_subband_alloc *drmp3_L12_subband_alloc_table(const drmp3_uint8 *hdr, drmp3_L12_scale_info *sci)
-{
-    const drmp3_L12_subband_alloc *alloc;
-    int mode = DRMP3_HDR_GET_STEREO_MODE(hdr);
-    int nbands, stereo_bands = (mode == DRMP3_MODE_MONO) ? 0 : (mode == DRMP3_MODE_JOINT_STEREO) ? (DRMP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32;
-
-    if (DRMP3_HDR_IS_LAYER_1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } };
-        alloc = g_alloc_L1;
-        nbands = 32;
-    } else if (!DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } };
-        alloc = g_alloc_L2M2;
-        nbands = 30;
-    } else
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } };
-        int sample_rate_idx = DRMP3_HDR_GET_SAMPLE_RATE(hdr);
-        unsigned kbps = drmp3_hdr_bitrate_kbps(hdr) >> (int)(mode != DRMP3_MODE_MONO);
-        if (!kbps) /* free-format */
-        {
-            kbps = 192;
-        }
-
-        alloc = g_alloc_L2M1;
-        nbands = 27;
-        if (kbps < 56)
-        {
-            static const drmp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } };
-            alloc = g_alloc_L2M1_lowrate;
-            nbands = sample_rate_idx == 2 ? 12 : 8;
-        } else if (kbps >= 96 && sample_rate_idx != 1)
-        {
-            nbands = 30;
-        }
-    }
-
-    sci->total_bands = (drmp3_uint8)nbands;
-    sci->stereo_bands = (drmp3_uint8)DRMP3_MIN(stereo_bands, nbands);
-
-    return alloc;
-}
-
-static void drmp3_L12_read_scalefactors(drmp3_bs *bs, drmp3_uint8 *pba, drmp3_uint8 *scfcod, int bands, float *scf)
-{
-    static const float g_deq_L12[18*3] = {
-#define DRMP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x
-        DRMP3_DQ(3),DRMP3_DQ(7),DRMP3_DQ(15),DRMP3_DQ(31),DRMP3_DQ(63),DRMP3_DQ(127),DRMP3_DQ(255),DRMP3_DQ(511),DRMP3_DQ(1023),DRMP3_DQ(2047),DRMP3_DQ(4095),DRMP3_DQ(8191),DRMP3_DQ(16383),DRMP3_DQ(32767),DRMP3_DQ(65535),DRMP3_DQ(3),DRMP3_DQ(5),DRMP3_DQ(9)
-    };
-    int i, m;
-    for (i = 0; i < bands; i++)
-    {
-        float s = 0;
-        int ba = *pba++;
-        int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0;
-        for (m = 4; m; m >>= 1)
-        {
-            if (mask & m)
-            {
-                int b = drmp3_bs_get_bits(bs, 6);
-                s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3);
-            }
-            *scf++ = s;
-        }
-    }
-}
-
-static void drmp3_L12_read_scale_info(const drmp3_uint8 *hdr, drmp3_bs *bs, drmp3_L12_scale_info *sci)
-{
-    static const drmp3_uint8 g_bitalloc_code_tab[] = {
-        0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16,
-        0,17,18, 3,19,4,5,16,
-        0,17,18,16,
-        0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14,
-        0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16
-    };
-    const drmp3_L12_subband_alloc *subband_alloc = drmp3_L12_subband_alloc_table(hdr, sci);
-
-    int i, k = 0, ba_bits = 0;
-    const drmp3_uint8 *ba_code_tab = g_bitalloc_code_tab;
-
-    for (i = 0; i < sci->total_bands; i++)
-    {
-        drmp3_uint8 ba;
-        if (i == k)
-        {
-            k += subband_alloc->band_count;
-            ba_bits = subband_alloc->code_tab_width;
-            ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset;
-            subband_alloc++;
-        }
-        ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        sci->bitalloc[2*i] = ba;
-        if (i < sci->stereo_bands)
-        {
-            ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        }
-        sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0;
-    }
-
-    for (i = 0; i < 2*sci->total_bands; i++)
-    {
-        sci->scfcod[i] = (drmp3_uint8)(sci->bitalloc[i] ? DRMP3_HDR_IS_LAYER_1(hdr) ? 2 : drmp3_bs_get_bits(bs, 2) : 6);
-    }
-
-    drmp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf);
-
-    for (i = sci->stereo_bands; i < sci->total_bands; i++)
-    {
-        sci->bitalloc[2*i + 1] = 0;
-    }
-}
-
-static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_scale_info *sci, int group_size)
-{
-    int i, j, k, choff = 576;
-    for (j = 0; j < 4; j++)
-    {
-        float *dst = grbuf + group_size*j;
-        for (i = 0; i < 2*sci->total_bands; i++)
-        {
-            int ba = sci->bitalloc[i];
-            if (ba != 0)
-            {
-                if (ba < 17)
-                {
-                    int half = (1 << (ba - 1)) - 1;
-                    for (k = 0; k < group_size; k++)
-                    {
-                        dst[k] = (float)((int)drmp3_bs_get_bits(bs, ba) - half);
-                    }
-                } else
-                {
-                    unsigned mod = (2 << (ba - 17)) + 1;    /* 3, 5, 9 */
-                    unsigned code = drmp3_bs_get_bits(bs, mod + 2 - (mod >> 3));  /* 5, 7, 10 */
-                    for (k = 0; k < group_size; k++, code /= mod)
-                    {
-                        dst[k] = (float)((int)(code % mod - mod/2));
-                    }
-                }
-            }
-            dst += choff;
-            choff = 18 - choff;
-        }
-    }
-    return group_size*4;
-}
-
-static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
-{
-    int i, k;
-    memcpy(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
-    for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
-    {
-        for (k = 0; k < 12; k++)
-        {
-            dst[k + 0]   *= scf[0];
-            dst[k + 576] *= scf[3];
-        }
-    }
-}
-#endif
-
-static int drmp3_L3_read_side_info(drmp3_bs *bs, drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    static const drmp3_uint8 g_scf_long[8][23] = {
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 },
-        { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 },
-        { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 }
-    };
-    static const drmp3_uint8 g_scf_short[8][40] = {
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    static const drmp3_uint8 g_scf_mixed[8][40] = {
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-
-    unsigned tables, scfsi = 0;
-    int main_data_begin, part_23_sum = 0;
-    int gr_count = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    int sr_idx = DRMP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0);
-
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        gr_count *= 2;
-        main_data_begin = drmp3_bs_get_bits(bs, 9);
-        scfsi = drmp3_bs_get_bits(bs, 7 + gr_count);
-    } else
-    {
-        main_data_begin = drmp3_bs_get_bits(bs, 8 + gr_count) >> gr_count;
-    }
-
-    do
-    {
-        if (DRMP3_HDR_IS_MONO(hdr))
-        {
-            scfsi <<= 4;
-        }
-        gr->part_23_length = (drmp3_uint16)drmp3_bs_get_bits(bs, 12);
-        part_23_sum += gr->part_23_length;
-        gr->big_values = (drmp3_uint16)drmp3_bs_get_bits(bs,  9);
-        if (gr->big_values > 288)
-        {
-            return -1;
-        }
-        gr->global_gain = (drmp3_uint8)drmp3_bs_get_bits(bs, 8);
-        gr->scalefac_compress = (drmp3_uint16)drmp3_bs_get_bits(bs, DRMP3_HDR_TEST_MPEG1(hdr) ? 4 : 9);
-        gr->sfbtab = g_scf_long[sr_idx];
-        gr->n_long_sfb  = 22;
-        gr->n_short_sfb = 0;
-        if (drmp3_bs_get_bits(bs, 1))
-        {
-            gr->block_type = (drmp3_uint8)drmp3_bs_get_bits(bs, 2);
-            if (!gr->block_type)
-            {
-                return -1;
-            }
-            gr->mixed_block_flag = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-            gr->region_count[0] = 7;
-            gr->region_count[1] = 255;
-            if (gr->block_type == DRMP3_SHORT_BLOCK_TYPE)
-            {
-                scfsi &= 0x0F0F;
-                if (!gr->mixed_block_flag)
-                {
-                    gr->region_count[0] = 8;
-                    gr->sfbtab = g_scf_short[sr_idx];
-                    gr->n_long_sfb = 0;
-                    gr->n_short_sfb = 39;
-                } else
-                {
-                    gr->sfbtab = g_scf_mixed[sr_idx];
-                    gr->n_long_sfb = DRMP3_HDR_TEST_MPEG1(hdr) ? 8 : 6;
-                    gr->n_short_sfb = 30;
-                }
-            }
-            tables = drmp3_bs_get_bits(bs, 10);
-            tables <<= 5;
-            gr->subblock_gain[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[2] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-        } else
-        {
-            gr->block_type = 0;
-            gr->mixed_block_flag = 0;
-            tables = drmp3_bs_get_bits(bs, 15);
-            gr->region_count[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 4);
-            gr->region_count[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->region_count[2] = 255;
-        }
-        gr->table_select[0] = (drmp3_uint8)(tables >> 10);
-        gr->table_select[1] = (drmp3_uint8)((tables >> 5) & 31);
-        gr->table_select[2] = (drmp3_uint8)((tables) & 31);
-        gr->preflag = (drmp3_uint8)(DRMP3_HDR_TEST_MPEG1(hdr) ? drmp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500));
-        gr->scalefac_scale = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->count1_table = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->scfsi = (drmp3_uint8)((scfsi >> 12) & 15);
-        scfsi <<= 4;
-        gr++;
-    } while(--gr_count);
-
-    if (part_23_sum + bs->pos > bs->limit + main_data_begin*8)
-    {
-        return -1;
-    }
-
-    return main_data_begin;
-}
-
-static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, const drmp3_uint8 *scf_size, const drmp3_uint8 *scf_count, drmp3_bs *bitbuf, int scfsi)
-{
-    int i, k;
-    for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2)
-    {
-        int cnt = scf_count[i];
-        if (scfsi & 8)
-        {
-            memcpy(scf, ist_pos, cnt);
-        } else
-        {
-            int bits = scf_size[i];
-            if (!bits)
-            {
-                memset(scf, 0, cnt);
-                memset(ist_pos, 0, cnt);
-            } else
-            {
-                int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
-                for (k = 0; k < cnt; k++)
-                {
-                    int s = drmp3_bs_get_bits(bitbuf, bits);
-                    ist_pos[k] = (drmp3_uint8)(s == max_scf ? -1 : s);
-                    scf[k] = (drmp3_uint8)s;
-                }
-            }
-        }
-        ist_pos += cnt;
-        scf += cnt;
-    }
-    scf[0] = scf[1] = scf[2] = 0;
-}
-
-static float drmp3_L3_ldexp_q2(float y, int exp_q2)
-{
-    static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f };
-    int e;
-    do
-    {
-        e = DRMP3_MIN(30*4, exp_q2);
-        y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));
-    } while ((exp_q2 -= e) > 0);
-    return y;
-}
-
-static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *ist_pos, drmp3_bs *bs, const drmp3_L3_gr_info *gr, float *scf, int ch)
-{
-    static const drmp3_uint8 g_scf_partitions[3][28] = {
-        { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 },
-        { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 },
-        { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 }
-    };
-    const drmp3_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb];
-    drmp3_uint8 scf_size[4], iscf[40];
-    int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi;
-    float gain;
-
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 };
-        int part = g_scfc_decode[gr->scalefac_compress];
-        scf_size[1] = scf_size[0] = (drmp3_uint8)(part >> 2);
-        scf_size[3] = scf_size[2] = (drmp3_uint8)(part & 3);
-    } else
-    {
-        static const drmp3_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 };
-        int k, modprod, sfc, ist = DRMP3_HDR_TEST_I_STEREO(hdr) && ch;
-        sfc = gr->scalefac_compress >> ist;
-        for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4)
-        {
-            for (modprod = 1, i = 3; i >= 0; i--)
-            {
-                scf_size[i] = (drmp3_uint8)(sfc / modprod % g_mod[k + i]);
-                modprod *= g_mod[k + i];
-            }
-        }
-        scf_partition += k;
-        scfsi = -16;
-    }
-    drmp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi);
-
-    if (gr->n_short_sfb)
-    {
-        int sh = 3 - scf_shift;
-        for (i = 0; i < gr->n_short_sfb; i += 3)
-        {
-            iscf[gr->n_long_sfb + i + 0] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh));
-            iscf[gr->n_long_sfb + i + 1] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh));
-            iscf[gr->n_long_sfb + i + 2] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh));
-        }
-    } else if (gr->preflag)
-    {
-        static const drmp3_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 };
-        for (i = 0; i < 10; i++)
-        {
-            iscf[11 + i] = (drmp3_uint8)(iscf[11 + i] + g_preamp[i]);
-        }
-    }
-
-    gain_exp = gr->global_gain + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210 - (DRMP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0);
-    gain = drmp3_L3_ldexp_q2(1 << (DRMP3_MAX_SCFI/4),  DRMP3_MAX_SCFI - gain_exp);
-    for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++)
-    {
-        scf[i] = drmp3_L3_ldexp_q2(gain, iscf[i] << scf_shift);
-    }
-}
-
-static const float g_drmp3_pow43[129 + 16] = {
-    0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f,
-    0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f
-};
-
-static float drmp3_L3_pow_43(int x)
-{
-    float frac;
-    int sign, mult = 256;
-
-    if (x < 129)
-    {
-        return g_drmp3_pow43[16 + x];
-    }
-
-    if (x < 1024)
-    {
-        mult = 16;
-        x <<= 3;
-    }
-
-    sign = 2*x & 64;
-    frac = (float)((x & 63) - sign) / ((x & ~63) + sign);
-    return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult;
-}
-
-static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit)
-{
-    static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,
-        -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288,
-        -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288,
-        -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258,
-        -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259,
-        -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258,
-        -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258,
-        -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259,
-        -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258,
-        -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290,
-        -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259,
-        -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258,
-        -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259,
-        -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258,
-        -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 };
-    static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205};
-    static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
-    static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
-    static const drmp3_uint8 g_linbits[] =  { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-
-#define DRMP3_PEEK_BITS(n)    (bs_cache >> (32 - n))
-#define DRMP3_FLUSH_BITS(n)   { bs_cache <<= (n); bs_sh += (n); }
-#define DRMP3_CHECK_BITS      while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
-#define DRMP3_BSPOS           ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
-
-    float one = 0.0f;
-    int ireg = 0, big_val_cnt = gr_info->big_values;
-    const drmp3_uint8 *sfb = gr_info->sfbtab;
-    const drmp3_uint8 *bs_next_ptr = bs->buf + bs->pos/8;
-    drmp3_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7);
-    int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8;
-    bs_next_ptr += 4;
-
-    while (big_val_cnt > 0)
-    {
-        int tab_num = gr_info->table_select[ireg];
-        int sfb_cnt = gr_info->region_count[ireg++];
-        const drmp3_int16 *codebook = tabs + tabindex[tab_num];
-        int linbits = g_linbits[tab_num];
-        if (linbits)
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        if (lsb == 15)
-                        {
-                            lsb += DRMP3_PEEK_BITS(linbits);
-                            DRMP3_FLUSH_BITS(linbits);
-                            DRMP3_CHECK_BITS;
-                            *dst = one*drmp3_L3_pow_43(lsb)*((drmp3_int32)bs_cache < 0 ? -1: 1);
-                        } else
-                        {
-                            *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        }
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        } else
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        }
-    }
-
-    for (np = 1 - big_val_cnt;; dst += 4)
-    {
-        const drmp3_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
-        int leaf = codebook_count1[DRMP3_PEEK_BITS(4)];
-        if (!(leaf & 8))
-        {
-            leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))];
-        }
-        DRMP3_FLUSH_BITS(leaf & 7);
-        if (DRMP3_BSPOS > layer3gr_limit)
-        {
-            break;
-        }
-#define DRMP3_RELOAD_SCALEFACTOR  if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; }
-#define DRMP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((drmp3_int32)bs_cache < 0) ? -one : one; DRMP3_FLUSH_BITS(1) }
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(0);
-        DRMP3_DEQ_COUNT1(1);
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(2);
-        DRMP3_DEQ_COUNT1(3);
-        DRMP3_CHECK_BITS;
-    }
-
-    bs->pos = layer3gr_limit;
-}
-
-static void drmp3_L3_midside_stereo(float *left, int n)
-{
-    int i = 0;
-    float *right = left + 576;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; i < n - 3; i += 4)
-    {
-        drmp3_f4 vl = DRMP3_VLD(left + i);
-        drmp3_f4 vr = DRMP3_VLD(right + i);
-        DRMP3_VSTORE(left + i, DRMP3_VADD(vl, vr));
-        DRMP3_VSTORE(right + i, DRMP3_VSUB(vl, vr));
-    }
-#endif
-    for (; i < n; i++)
-    {
-        float a = left[i];
-        float b = right[i];
-        left[i] = a + b;
-        right[i] = a - b;
-    }
-}
-
-static void drmp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr)
-{
-    int i;
-    for (i = 0; i < n; i++)
-    {
-        left[i + 576] = left[i]*kr;
-        left[i] = left[i]*kl;
-    }
-}
-
-static void drmp3_L3_stereo_top_band(const float *right, const drmp3_uint8 *sfb, int nbands, int max_band[3])
-{
-    int i, k;
-
-    max_band[0] = max_band[1] = max_band[2] = -1;
-
-    for (i = 0; i < nbands; i++)
-    {
-        for (k = 0; k < sfb[i]; k += 2)
-        {
-            if (right[k] != 0 || right[k + 1] != 0)
-            {
-                max_band[i % 3] = i;
-                break;
-            }
-        }
-        right += sfb[i];
-    }
-}
-
-static void drmp3_L3_stereo_process(float *left, const drmp3_uint8 *ist_pos, const drmp3_uint8 *sfb, const drmp3_uint8 *hdr, int max_band[3], int mpeg2_sh)
-{
-    static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 };
-    unsigned i, max_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 7 : 64;
-
-    for (i = 0; sfb[i]; i++)
-    {
-        unsigned ipos = ist_pos[i];
-        if ((int)i > max_band[i % 3] && ipos < max_pos)
-        {
-            float kl, kr, s = DRMP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1;
-            if (DRMP3_HDR_TEST_MPEG1(hdr))
-            {
-                kl = g_pan[2*ipos];
-                kr = g_pan[2*ipos + 1];
-            } else
-            {
-                kl = 1;
-                kr = drmp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh);
-                if (ipos & 1)
-                {
-                    kl = kr;
-                    kr = 1;
-                }
-            }
-            drmp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s);
-        } else if (DRMP3_HDR_TEST_MS_STEREO(hdr))
-        {
-            drmp3_L3_midside_stereo(left, sfb[i]);
-        }
-        left += sfb[i];
-    }
-}
-
-static void drmp3_L3_intensity_stereo(float *left, drmp3_uint8 *ist_pos, const drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb;
-    int i, max_blocks = gr->n_short_sfb ? 3 : 1;
-
-    drmp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band);
-    if (gr->n_long_sfb)
-    {
-        max_band[0] = max_band[1] = max_band[2] = DRMP3_MAX(DRMP3_MAX(max_band[0], max_band[1]), max_band[2]);
-    }
-    for (i = 0; i < max_blocks; i++)
-    {
-        int default_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 3 : 0;
-        int itop = n_sfb - max_blocks + i;
-        int prev = itop - max_blocks;
-        ist_pos[itop] = (drmp3_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]);
-    }
-    drmp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1);
-}
-
-static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sfb)
-{
-    int i, len;
-    float *src = grbuf, *dst = scratch;
-
-    for (;0 != (len = *sfb); sfb += 3, src += 2*len)
-    {
-        for (i = 0; i < len; i++, src++)
-        {
-            *dst++ = src[0*len];
-            *dst++ = src[1*len];
-            *dst++ = src[2*len];
-        }
-    }
-    memcpy(grbuf, scratch, (dst - scratch)*sizeof(float));
-}
-
-static void drmp3_L3_antialias(float *grbuf, int nbands)
-{
-    static const float g_aa[2][8] = {
-        {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f},
-        {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f}
-    };
-
-    for (; nbands > 0; nbands--, grbuf += 18)
-    {
-        int i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vu = DRMP3_VLD(grbuf + 18 + i);
-            drmp3_f4 vd = DRMP3_VLD(grbuf + 14 - i);
-            drmp3_f4 vc0 = DRMP3_VLD(g_aa[0] + i);
-            drmp3_f4 vc1 = DRMP3_VLD(g_aa[1] + i);
-            vd = DRMP3_VREV(vd);
-            DRMP3_VSTORE(grbuf + 18 + i, DRMP3_VSUB(DRMP3_VMUL(vu, vc0), DRMP3_VMUL(vd, vc1)));
-            vd = DRMP3_VADD(DRMP3_VMUL(vu, vc1), DRMP3_VMUL(vd, vc0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vd));
-        }
-#endif
-#ifndef DR_MP3_ONLY_SIMD
-        for(; i < 8; i++)
-        {
-            float u = grbuf[18 + i];
-            float d = grbuf[17 - i];
-            grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i];
-            grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i];
-        }
-#endif
-    }
-}
-
-static void drmp3_L3_dct3_9(float *y)
-{
-    float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4;
-
-    s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8];
-    t0 = s0 + s6*0.5f;
-    s0 -= s6;
-    t4 = (s4 + s2)*0.93969262f;
-    t2 = (s8 + s2)*0.76604444f;
-    s6 = (s4 - s8)*0.17364818f;
-    s4 += s8 - s2;
-
-    s2 = s0 - s4*0.5f;
-    y[4] = s4 + s0;
-    s8 = t0 - t2 + s6;
-    s0 = t0 - t4 + t2;
-    s4 = t0 + t4 - s6;
-
-    s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7];
-
-    s3 *= 0.86602540f;
-    t0 = (s5 + s1)*0.98480775f;
-    t4 = (s5 - s7)*0.34202014f;
-    t2 = (s1 + s7)*0.64278761f;
-    s1 = (s1 - s5 - s7)*0.86602540f;
-
-    s5 = t0 - s3 - t2;
-    s7 = t4 - s3 - t0;
-    s3 = t4 + s3 - t2;
-
-    y[0] = s4 - s7;
-    y[1] = s2 + s1;
-    y[2] = s0 - s3;
-    y[3] = s8 + s5;
-    y[5] = s8 - s5;
-    y[6] = s0 + s3;
-    y[7] = s2 - s1;
-    y[8] = s4 + s7;
-}
-
-static void drmp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands)
-{
-    int i, j;
-    static const float g_twid9[18] = {
-        0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f
-    };
-
-    for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9)
-    {
-        float co[9], si[9];
-        co[0] = -grbuf[0];
-        si[0] = grbuf[17];
-        for (i = 0; i < 4; i++)
-        {
-            si[8 - 2*i] =   grbuf[4*i + 1] - grbuf[4*i + 2];
-            co[1 + 2*i] =   grbuf[4*i + 1] + grbuf[4*i + 2];
-            si[7 - 2*i] =   grbuf[4*i + 4] - grbuf[4*i + 3];
-            co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]);
-        }
-        drmp3_L3_dct3_9(co);
-        drmp3_L3_dct3_9(si);
-
-        si[1] = -si[1];
-        si[3] = -si[3];
-        si[5] = -si[5];
-        si[7] = -si[7];
-
-        i = 0;
-
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vovl = DRMP3_VLD(overlap + i);
-            drmp3_f4 vc = DRMP3_VLD(co + i);
-            drmp3_f4 vs = DRMP3_VLD(si + i);
-            drmp3_f4 vr0 = DRMP3_VLD(g_twid9 + i);
-            drmp3_f4 vr1 = DRMP3_VLD(g_twid9 + 9 + i);
-            drmp3_f4 vw0 = DRMP3_VLD(window + i);
-            drmp3_f4 vw1 = DRMP3_VLD(window + 9 + i);
-            drmp3_f4 vsum = DRMP3_VADD(DRMP3_VMUL(vc, vr1), DRMP3_VMUL(vs, vr0));
-            DRMP3_VSTORE(overlap + i, DRMP3_VSUB(DRMP3_VMUL(vc, vr0), DRMP3_VMUL(vs, vr1)));
-            DRMP3_VSTORE(grbuf + i, DRMP3_VSUB(DRMP3_VMUL(vovl, vw0), DRMP3_VMUL(vsum, vw1)));
-            vsum = DRMP3_VADD(DRMP3_VMUL(vovl, vw1), DRMP3_VMUL(vsum, vw0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vsum));
-        }
-#endif
-        for (; i < 9; i++)
-        {
-            float ovl  = overlap[i];
-            float sum  = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i];
-            overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i];
-            grbuf[i]      = ovl*window[0 + i] - sum*window[9 + i];
-            grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i];
-        }
-    }
-}
-
-static void drmp3_L3_idct3(float x0, float x1, float x2, float *dst)
-{
-    float m1 = x1*0.86602540f;
-    float a1 = x0 - x2*0.5f;
-    dst[1] = x0 + x2;
-    dst[0] = a1 + m1;
-    dst[2] = a1 - m1;
-}
-
-static void drmp3_L3_imdct12(float *x, float *dst, float *overlap)
-{
-    static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f };
-    float co[3], si[3];
-    int i;
-
-    drmp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co);
-    drmp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si);
-    si[1] = -si[1];
-
-    for (i = 0; i < 3; i++)
-    {
-        float ovl  = overlap[i];
-        float sum  = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i];
-        overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i];
-        dst[i]     = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i];
-        dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i];
-    }
-}
-
-static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
-{
-    for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
-    {
-        float tmp[18];
-        memcpy(tmp, grbuf, sizeof(tmp));
-        memcpy(grbuf, overlap, 6*sizeof(float));
-        drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
-        drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
-        drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
-    }
-}
-
-static void drmp3_L3_change_sign(float *grbuf)
-{
-    int b, i;
-    for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36)
-        for (i = 1; i < 18; i += 2)
-            grbuf[i] = -grbuf[i];
-}
-
-static void drmp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands)
-{
-    static const float g_mdct_window[2][18] = {
-        { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f },
-        { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f }
-    };
-    if (n_long_bands)
-    {
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands);
-        grbuf += 18*n_long_bands;
-        overlap += 9*n_long_bands;
-    }
-    if (block_type == DRMP3_SHORT_BLOCK_TYPE)
-        drmp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands);
-    else
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == DRMP3_STOP_BLOCK_TYPE], 32 - n_long_bands);
-}
-
-static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
-{
-    int pos = (s->bs.pos + 7)/8u;
-    int remains = s->bs.limit/8u - pos;
-    if (remains > DRMP3_MAX_BITRESERVOIR_BYTES)
-    {
-        pos += remains - DRMP3_MAX_BITRESERVOIR_BYTES;
-        remains = DRMP3_MAX_BITRESERVOIR_BYTES;
-    }
-    if (remains > 0)
-    {
-        memmove(h->reserv_buf, s->maindata + pos, remains);
-    }
-    h->reserv = remains;
-}
-
-static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratch *s, int main_data_begin)
-{
-    int frame_bytes = (bs->limit - bs->pos)/8;
-    int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
-    memcpy(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
-    memcpy(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
-    drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
-    return h->reserv >= main_data_begin;
-}
-
-static void drmp3_L3_decode(drmp3dec *h, drmp3dec_scratch *s, drmp3_L3_gr_info *gr_info, int nch)
-{
-    int ch;
-
-    for (ch = 0; ch < nch; ch++)
-    {
-        int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length;
-        drmp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch);
-        drmp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit);
-    }
-
-    if (DRMP3_HDR_TEST_I_STEREO(h->header))
-    {
-        drmp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header);
-    } else if (DRMP3_HDR_IS_MS_STEREO(h->header))
-    {
-        drmp3_L3_midside_stereo(s->grbuf[0], 576);
-    }
-
-    for (ch = 0; ch < nch; ch++, gr_info++)
-    {
-        int aa_bands = 31;
-        int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(DRMP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2);
-
-        if (gr_info->n_short_sfb)
-        {
-            aa_bands = n_long_bands - 1;
-            drmp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb);
-        }
-
-        drmp3_L3_antialias(s->grbuf[ch], aa_bands);
-        drmp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands);
-        drmp3_L3_change_sign(s->grbuf[ch]);
-    }
-}
-
-static void drmp3d_DCT_II(float *grbuf, int n)
-{
-    static const float g_sec[24] = {
-        10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f
-    };
-    int i, k = 0;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; k < n; k += 4)
-    {
-        drmp3_f4 t[4][8], *x;
-        float *y = grbuf + k;
-
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            drmp3_f4 x0 = DRMP3_VLD(&y[i*18]);
-            drmp3_f4 x1 = DRMP3_VLD(&y[(15 - i)*18]);
-            drmp3_f4 x2 = DRMP3_VLD(&y[(16 + i)*18]);
-            drmp3_f4 x3 = DRMP3_VLD(&y[(31 - i)*18]);
-            drmp3_f4 t0 = DRMP3_VADD(x0, x3);
-            drmp3_f4 t1 = DRMP3_VADD(x1, x2);
-            drmp3_f4 t2 = DRMP3_VMUL_S(DRMP3_VSUB(x1, x2), g_sec[3*i + 0]);
-            drmp3_f4 t3 = DRMP3_VMUL_S(DRMP3_VSUB(x0, x3), g_sec[3*i + 1]);
-            x[0] = DRMP3_VADD(t0, t1);
-            x[8] = DRMP3_VMUL_S(DRMP3_VSUB(t0, t1), g_sec[3*i + 2]);
-            x[16] = DRMP3_VADD(t3, t2);
-            x[24] = DRMP3_VMUL_S(DRMP3_VSUB(t3, t2), g_sec[3*i + 2]);
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            drmp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = DRMP3_VSUB(x0, x7); x0 = DRMP3_VADD(x0, x7);
-            x7 = DRMP3_VSUB(x1, x6); x1 = DRMP3_VADD(x1, x6);
-            x6 = DRMP3_VSUB(x2, x5); x2 = DRMP3_VADD(x2, x5);
-            x5 = DRMP3_VSUB(x3, x4); x3 = DRMP3_VADD(x3, x4);
-            x4 = DRMP3_VSUB(x0, x3); x0 = DRMP3_VADD(x0, x3);
-            x3 = DRMP3_VSUB(x1, x2); x1 = DRMP3_VADD(x1, x2);
-            x[0] = DRMP3_VADD(x0, x1);
-            x[4] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x1), 0.70710677f);
-            x5 = DRMP3_VADD(x5, x6);
-            x6 = DRMP3_VMUL_S(DRMP3_VADD(x6, x7), 0.70710677f);
-            x7 = DRMP3_VADD(x7, xt);
-            x3 = DRMP3_VMUL_S(DRMP3_VADD(x3, x4), 0.70710677f);
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f)); /* rotate by PI/8 */
-            x7 = DRMP3_VADD(x7, DRMP3_VMUL_S(x5, 0.382683432f));
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x0 = DRMP3_VSUB(xt, x6); xt = DRMP3_VADD(xt, x6);
-            x[1] = DRMP3_VMUL_S(DRMP3_VADD(xt, x7), 0.50979561f);
-            x[2] = DRMP3_VMUL_S(DRMP3_VADD(x4, x3), 0.54119611f);
-            x[3] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x5), 0.60134488f);
-            x[5] = DRMP3_VMUL_S(DRMP3_VADD(x0, x5), 0.89997619f);
-            x[6] = DRMP3_VMUL_S(DRMP3_VSUB(x4, x3), 1.30656302f);
-            x[7] = DRMP3_VMUL_S(DRMP3_VSUB(xt, x7), 2.56291556f);
-        }
-
-        if (k > n - 3)
-        {
-#if DRMP3_HAVE_SSE
-#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
-#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18],  vget_low_f32(v))
-#endif
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE2(0, t[0][i]);
-                DRMP3_VSAVE2(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE2(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE2(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE2(0, t[0][7]);
-            DRMP3_VSAVE2(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE2(2, t[1][7]);
-            DRMP3_VSAVE2(3, t[3][7]);
-        } else
-        {
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE4(0, t[0][i]);
-                DRMP3_VSAVE4(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE4(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE4(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE4(0, t[0][7]);
-            DRMP3_VSAVE4(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE4(2, t[1][7]);
-            DRMP3_VSAVE4(3, t[3][7]);
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
-#else
-    for (; k < n; k++)
-    {
-        float t[4][8], *x, *y = grbuf + k;
-
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            float x0 = y[i*18];
-            float x1 = y[(15 - i)*18];
-            float x2 = y[(16 + i)*18];
-            float x3 = y[(31 - i)*18];
-            float t0 = x0 + x3;
-            float t1 = x1 + x2;
-            float t2 = (x1 - x2)*g_sec[3*i + 0];
-            float t3 = (x0 - x3)*g_sec[3*i + 1];
-            x[0] = t0 + t1;
-            x[8] = (t0 - t1)*g_sec[3*i + 2];
-            x[16] = t3 + t2;
-            x[24] = (t3 - t2)*g_sec[3*i + 2];
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = x0 - x7; x0 += x7;
-            x7 = x1 - x6; x1 += x6;
-            x6 = x2 - x5; x2 += x5;
-            x5 = x3 - x4; x3 += x4;
-            x4 = x0 - x3; x0 += x3;
-            x3 = x1 - x2; x1 += x2;
-            x[0] = x0 + x1;
-            x[4] = (x0 - x1)*0.70710677f;
-            x5 =  x5 + x6;
-            x6 = (x6 + x7)*0.70710677f;
-            x7 =  x7 + xt;
-            x3 = (x3 + x4)*0.70710677f;
-            x5 -= x7*0.198912367f;  /* rotate by PI/8 */
-            x7 += x5*0.382683432f;
-            x5 -= x7*0.198912367f;
-            x0 = xt - x6; xt += x6;
-            x[1] = (xt + x7)*0.50979561f;
-            x[2] = (x4 + x3)*0.54119611f;
-            x[3] = (x0 - x5)*0.60134488f;
-            x[5] = (x0 + x5)*0.89997619f;
-            x[6] = (x4 - x3)*1.30656302f;
-            x[7] = (xt - x7)*2.56291556f;
-
-        }
-        for (i = 0; i < 7; i++, y += 4*18)
-        {
-            y[0*18] = t[0][i];
-            y[1*18] = t[2][i] + t[3][i] + t[3][i + 1];
-            y[2*18] = t[1][i] + t[1][i + 1];
-            y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1];
-        }
-        y[0*18] = t[0][7];
-        y[1*18] = t[2][7] + t[3][7];
-        y[2*18] = t[1][7];
-        y[3*18] = t[3][7];
-    }
-#endif
-}
-
-#ifndef DR_MP3_FLOAT_OUTPUT
-typedef drmp3_int16 drmp3d_sample_t;
-
-static drmp3_int16 drmp3d_scale_pcm(float sample)
-{
-    drmp3_int16 s;
-#if DRMP3_HAVE_ARMV6
-    drmp3_int32 s32 = (drmp3_int32)(sample + .5f);
-    s32 -= (s32 < 0);
-    s = (drmp3_int16)drmp3_clip_int16_arm(s32);
-#else
-    if (sample >=  32766.5) return (drmp3_int16) 32767;
-    if (sample <= -32767.5) return (drmp3_int16)-32768;
-    s = (drmp3_int16)(sample + .5f);
-    s -= (s < 0);   /* away from zero, to be compliant */
-#endif
-    return s;
-}
-#else
-typedef float drmp3d_sample_t;
-
-static float drmp3d_scale_pcm(float sample)
-{
-    return sample*(1.f/32768.f);
-}
-#endif
-
-static void drmp3d_synth_pair(drmp3d_sample_t *pcm, int nch, const float *z)
-{
-    float a;
-    a  = (z[14*64] - z[    0]) * 29;
-    a += (z[ 1*64] + z[13*64]) * 213;
-    a += (z[12*64] - z[ 2*64]) * 459;
-    a += (z[ 3*64] + z[11*64]) * 2037;
-    a += (z[10*64] - z[ 4*64]) * 5153;
-    a += (z[ 5*64] + z[ 9*64]) * 6574;
-    a += (z[ 8*64] - z[ 6*64]) * 37489;
-    a +=  z[ 7*64]             * 75038;
-    pcm[0] = drmp3d_scale_pcm(a);
-
-    z += 2;
-    a  = z[14*64] * 104;
-    a += z[12*64] * 1567;
-    a += z[10*64] * 9727;
-    a += z[ 8*64] * 64019;
-    a += z[ 6*64] * -9975;
-    a += z[ 4*64] * -45;
-    a += z[ 2*64] * 146;
-    a += z[ 0*64] * -5;
-    pcm[16*nch] = drmp3d_scale_pcm(a);
-}
-
-static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
-{
-    int i;
-    float *xr = xl + 576*(nch - 1);
-    drmp3d_sample_t *dstr = dstl + (nch - 1);
-
-    static const float g_win[] = {
-        -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992,
-        -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856,
-        -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630,
-        -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313,
-        -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908,
-        -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415,
-        -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835,
-        -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169,
-        -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420,
-        -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590,
-        -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679,
-        -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692,
-        -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629,
-        -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494,
-        -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290
-    };
-    float *zlin = lins + 15*64;
-    const float *w = g_win;
-
-    zlin[4*15]     = xl[18*16];
-    zlin[4*15 + 1] = xr[18*16];
-    zlin[4*15 + 2] = xl[0];
-    zlin[4*15 + 3] = xr[0];
-
-    zlin[4*31]     = xl[1 + 18*16];
-    zlin[4*31 + 1] = xr[1 + 18*16];
-    zlin[4*31 + 2] = xl[1];
-    zlin[4*31 + 3] = xr[1];
-
-    drmp3d_synth_pair(dstr, nch, lins + 4*15 + 1);
-    drmp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1);
-    drmp3d_synth_pair(dstl, nch, lins + 4*15);
-    drmp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64);
-
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_VLOAD(k) drmp3_f4 w0 = DRMP3_VSET(*w++); drmp3_f4 w1 = DRMP3_VSET(*w++); drmp3_f4 vz = DRMP3_VLD(&zlin[4*i - 64*k]); drmp3_f4 vy = DRMP3_VLD(&zlin[4*i - 64*(15 - k)]);
-#define DRMP3_V0(k) { DRMP3_VLOAD(k) b =               DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0)) ; a =               DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1));  }
-#define DRMP3_V1(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1))); }
-#define DRMP3_V2(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vy, w1), DRMP3_VMUL(vz, w0))); }
-        drmp3_f4 a, b;
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*i + 64] = xl[1 + 18*(1 + i)];
-        zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*i - 64 + 2] = xl[18*(1 + i)];
-        zlin[4*i - 64 + 3] = xr[18*(1 + i)];
-
-        DRMP3_V0(0) DRMP3_V2(1) DRMP3_V1(2) DRMP3_V2(3) DRMP3_V1(4) DRMP3_V2(5) DRMP3_V1(6) DRMP3_V2(7)
-
-        {
-#ifndef DR_MP3_FLOAT_OUTPUT
-#if DRMP3_HAVE_SSE
-            static const drmp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f };
-            static const drmp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f };
-            __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)),
-                                           _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min)));
-            dstr[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-            dstr[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-            dstl[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-            dstl[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-            dstr[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-            dstr[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-            dstl[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-            dstl[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-#else
-            int16x4_t pcma, pcmb;
-            a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-            b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-            pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-            pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-            vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1);
-            vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1);
-            vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0);
-            vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0);
-            vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3);
-            vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3);
-            vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2);
-            vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
-#endif
-#else
-            static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
-            a = DRMP3_VMUL(a, g_scale);
-            b = DRMP3_VMUL(b, g_scale);
-#if DRMP3_HAVE_SSE
-            _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2)));
-            _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2)));
-#else
-            vst1q_lane_f32(dstr + (15 - i)*nch, a, 1);
-            vst1q_lane_f32(dstr + (17 + i)*nch, b, 1);
-            vst1q_lane_f32(dstl + (15 - i)*nch, a, 0);
-            vst1q_lane_f32(dstl + (17 + i)*nch, b, 0);
-            vst1q_lane_f32(dstr + (47 - i)*nch, a, 3);
-            vst1q_lane_f32(dstr + (49 + i)*nch, b, 3);
-            vst1q_lane_f32(dstl + (47 - i)*nch, a, 2);
-            vst1q_lane_f32(dstl + (49 + i)*nch, b, 2);
-#endif
-#endif /* DR_MP3_FLOAT_OUTPUT */
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
-#else
-    for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64];
-#define DRMP3_S0(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j]  = vz[j]*w1 + vy[j]*w0, a[j]  = vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S1(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S2(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; }
-        float a[4], b[4];
-
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*(i + 16)]   = xl[1 + 18*(1 + i)];
-        zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*(i - 16) + 2] = xl[18*(1 + i)];
-        zlin[4*(i - 16) + 3] = xr[18*(1 + i)];
-
-        DRMP3_S0(0) DRMP3_S2(1) DRMP3_S1(2) DRMP3_S2(3) DRMP3_S1(4) DRMP3_S2(5) DRMP3_S1(6) DRMP3_S2(7)
-
-        dstr[(15 - i)*nch] = drmp3d_scale_pcm(a[1]);
-        dstr[(17 + i)*nch] = drmp3d_scale_pcm(b[1]);
-        dstl[(15 - i)*nch] = drmp3d_scale_pcm(a[0]);
-        dstl[(17 + i)*nch] = drmp3d_scale_pcm(b[0]);
-        dstr[(47 - i)*nch] = drmp3d_scale_pcm(a[3]);
-        dstr[(49 + i)*nch] = drmp3d_scale_pcm(b[3]);
-        dstl[(47 - i)*nch] = drmp3d_scale_pcm(a[2]);
-        dstl[(49 + i)*nch] = drmp3d_scale_pcm(b[2]);
-    }
-#endif
-}
-
-static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, drmp3d_sample_t *pcm, float *lins)
-{
-    int i;
-    for (i = 0; i < nch; i++)
-    {
-        drmp3d_DCT_II(grbuf + 576*i, nbands);
-    }
-
-    memcpy(lins, qmf_state, sizeof(float)*15*64);
-
-    for (i = 0; i < nbands; i += 2)
-    {
-        drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
-    }
-#ifndef DR_MP3_NONSTANDARD_BUT_LOGICAL
-    if (nch == 1)
-    {
-        for (i = 0; i < 15*64; i += 2)
-        {
-            qmf_state[i] = lins[nbands*64 + i];
-        }
-    } else
-#endif
-    {
-        memcpy(qmf_state, lins + nbands*64, sizeof(float)*15*64);
-    }
-}
-
-static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
-{
-    int i, nmatch;
-    for (i = 0, nmatch = 0; nmatch < DRMP3_MAX_FRAME_SYNC_MATCHES; nmatch++)
-    {
-        i += drmp3_hdr_frame_bytes(hdr + i, frame_bytes) + drmp3_hdr_padding(hdr + i);
-        if (i + DRMP3_HDR_SIZE > mp3_bytes)
-            return nmatch > 0;
-        if (!drmp3_hdr_compare(hdr, hdr + i))
-            return 0;
-    }
-    return 1;
-}
-
-static int drmp3d_find_frame(const drmp3_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes)
-{
-    int i, k;
-    for (i = 0; i < mp3_bytes - DRMP3_HDR_SIZE; i++, mp3++)
-    {
-        if (drmp3_hdr_valid(mp3))
-        {
-            int frame_bytes = drmp3_hdr_frame_bytes(mp3, *free_format_bytes);
-            int frame_and_padding = frame_bytes + drmp3_hdr_padding(mp3);
-
-            for (k = DRMP3_HDR_SIZE; !frame_bytes && k < DRMP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - DRMP3_HDR_SIZE; k++)
-            {
-                if (drmp3_hdr_compare(mp3, mp3 + k))
-                {
-                    int fb = k - drmp3_hdr_padding(mp3);
-                    int nextfb = fb + drmp3_hdr_padding(mp3 + k);
-                    if (i + k + nextfb + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + k + nextfb))
-                        continue;
-                    frame_and_padding = k;
-                    frame_bytes = fb;
-                    *free_format_bytes = fb;
-                }
-            }
-
-            if ((frame_bytes && i + frame_and_padding <= mp3_bytes &&
-                drmp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) ||
-                (!i && frame_and_padding == mp3_bytes))
-            {
-                *ptr_frame_bytes = frame_and_padding;
-                return i;
-            }
-            *free_format_bytes = 0;
-        }
-    }
-    *ptr_frame_bytes = 0;
-    return mp3_bytes;
-}
-
-DRMP3_API void drmp3dec_init(drmp3dec *dec)
-{
-    dec->header[0] = 0;
-}
-
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
-{
-    int i = 0, igr, frame_size = 0, success = 1;
-    const drmp3_uint8 *hdr;
-    drmp3_bs bs_frame[1];
-    drmp3dec_scratch scratch;
-
-    if (mp3_bytes > 4 && dec->header[0] == 0xff && drmp3_hdr_compare(dec->header, mp3))
-    {
-        frame_size = drmp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + drmp3_hdr_padding(mp3);
-        if (frame_size != mp3_bytes && (frame_size + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + frame_size)))
-        {
-            frame_size = 0;
-        }
-    }
-    if (!frame_size)
-    {
-        memset(dec, 0, sizeof(drmp3dec));
-        i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
-        if (!frame_size || i + frame_size > mp3_bytes)
-        {
-            info->frame_bytes = i;
-            return 0;
-        }
-    }
-
-    hdr = mp3 + i;
-    memcpy(dec->header, hdr, DRMP3_HDR_SIZE);
-    info->frame_bytes = i + frame_size;
-    info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    info->hz = drmp3_hdr_sample_rate_hz(hdr);
-    info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr);
-    info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr);
-
-    drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE);
-    if (DRMP3_HDR_IS_CRC(hdr))
-    {
-        drmp3_bs_get_bits(bs_frame, 16);
-    }
-
-    if (info->layer == 3)
-    {
-        int main_data_begin = drmp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr);
-        if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit)
-        {
-            drmp3dec_init(dec);
-            return 0;
-        }
-        success = drmp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin);
-        if (success && pcm != NULL)
-        {
-            for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
-            {
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-            }
-        }
-        drmp3_L3_save_reservoir(dec, &scratch);
-    } else
-    {
-#ifdef DR_MP3_ONLY_MP3
-        return 0;
-#else
-        drmp3_L12_scale_info sci[1];
-
-        if (pcm == NULL) {
-            return drmp3_hdr_frame_samples(hdr);
-        }
-
-        drmp3_L12_read_scale_info(hdr, bs_frame, sci);
-
-        memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-        for (i = 0, igr = 0; igr < 3; igr++)
-        {
-            if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
-            {
-                i = 0;
-                drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
-            }
-            if (bs_frame->pos > bs_frame->limit)
-            {
-                drmp3dec_init(dec);
-                return 0;
-            }
-        }
-#endif
-    }
-
-    return success*drmp3_hdr_frame_samples(dec->header);
-}
-
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples)
-{
-    size_t i = 0;
-#if DRMP3_HAVE_SIMD
-    size_t aligned_count = num_samples & ~7;
-    for(; i < aligned_count; i+=8)
-    {
-        drmp3_f4 scale = DRMP3_VSET(32768.0f);
-        drmp3_f4 a = DRMP3_VMUL(DRMP3_VLD(&in[i  ]), scale);
-        drmp3_f4 b = DRMP3_VMUL(DRMP3_VLD(&in[i+4]), scale);
-#if DRMP3_HAVE_SSE
-        drmp3_f4 s16max = DRMP3_VSET( 32767.0f);
-        drmp3_f4 s16min = DRMP3_VSET(-32768.0f);
-        __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)),
-                                        _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min)));
-        out[i  ] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-        out[i+1] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-        out[i+2] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-        out[i+3] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-        out[i+4] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-        out[i+5] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-        out[i+6] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-        out[i+7] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-#else
-        int16x4_t pcma, pcmb;
-        a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-        b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-        pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-        pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-        vst1_lane_s16(out+i  , pcma, 0);
-        vst1_lane_s16(out+i+1, pcma, 1);
-        vst1_lane_s16(out+i+2, pcma, 2);
-        vst1_lane_s16(out+i+3, pcma, 3);
-        vst1_lane_s16(out+i+4, pcmb, 0);
-        vst1_lane_s16(out+i+5, pcmb, 1);
-        vst1_lane_s16(out+i+6, pcmb, 2);
-        vst1_lane_s16(out+i+7, pcmb, 3);
-#endif
-    }
-#endif
-    for(; i < num_samples; i++)
-    {
-        float sample = in[i] * 32768.0f;
-        if (sample >=  32766.5)
-            out[i] = (drmp3_int16) 32767;
-        else if (sample <= -32767.5)
-            out[i] = (drmp3_int16)-32768;
-        else
-        {
-            short s = (drmp3_int16)(sample + .5f);
-            s -= (s < 0);   /* away from zero, to be compliant */
-            out[i] = s;
-        }
-    }
-}
-
-
-
-/************************************************************************************************************************************************************
-
- Main Public API
-
- ************************************************************************************************************************************************************/
-#include <math.h>   /* For sin() and exp(). */
-
-#if defined(SIZE_MAX)
-    #define DRMP3_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRMP3_SIZE_MAX  ((drmp3_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRMP3_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-/* Options. */
-#ifndef DRMP3_SEEK_LEADING_MP3_FRAMES
-#define DRMP3_SEEK_LEADING_MP3_FRAMES   2
-#endif
-
-#define DRMP3_MIN_DATA_CHUNK_SIZE   16384
-
-/* The size in bytes of each chunk of data to read from the MP3 stream. minimp3 recommends at least 16K, but in an attempt to reduce data movement I'm making this slightly larger. */
-#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE  DRMP3_MIN_DATA_CHUNK_SIZE*4
-#endif
-
-
-/* Standard library stuff. */
-#ifndef DRMP3_ASSERT
-#include <assert.h>
-#define DRMP3_ASSERT(expression) assert(expression)
-#endif
-#ifndef DRMP3_COPY_MEMORY
-#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#ifndef DRMP3_ZERO_MEMORY
-#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
-#ifndef DRMP3_MALLOC
-#define DRMP3_MALLOC(sz) malloc((sz))
-#endif
-#ifndef DRMP3_REALLOC
-#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#ifndef DRMP3_FREE
-#define DRMP3_FREE(p) free((p))
-#endif
-
-#define DRMP3_COUNTOF(x)        (sizeof(x) / sizeof(x[0]))
-#define DRMP3_CLAMP(x, lo, hi)  (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
-
-#ifndef DRMP3_PI_D
-#define DRMP3_PI_D    3.14159265358979323846264
-#endif
-
-#define DRMP3_DEFAULT_RESAMPLER_LPF_ORDER   2
-
-static DRMP3_INLINE float drmp3_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static DRMP3_INLINE float drmp3_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-    /*return x + (y - x)*a;*/
-}
-
-
-/*
-Greatest common factor using Euclid's algorithm iteratively.
-*/
-static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            drmp3_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-
-    return a;
-}
-
-
-static DRMP3_INLINE double drmp3_sin(double x)
-{
-    /* TODO: Implement custom sin(x). */
-    return sin(x);
-}
-
-static DRMP3_INLINE double drmp3_exp(double x)
-{
-    /* TODO: Implement custom exp(x). */
-    return exp(x);
-}
-
-static DRMP3_INLINE double drmp3_cos(double x)
-{
-    return drmp3_sin((DRMP3_PI_D*0.5) - x);
-}
-
-
-static void* drmp3__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_MALLOC(sz);
-}
-
-static void* drmp3__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_REALLOC(p, sz);
-}
-
-static void drmp3__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRMP3_FREE(p);
-}
-
-
-static void* drmp3__malloc_from_callbacks(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRMP3_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static void drmp3__free_from_callbacks(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-static drmp3_allocation_callbacks drmp3_copy_allocation_callbacks_or_defaults(const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        /* Copy. */
-        return *pAllocationCallbacks;
-    } else {
-        /* Defaults. */
-        drmp3_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drmp3__malloc_default;
-        allocationCallbacks.onRealloc = drmp3__realloc_default;
-        allocationCallbacks.onFree    = drmp3__free_default;
-        return allocationCallbacks;
-    }
-}
-
-
-
-static size_t drmp3__on_read(drmp3* pMP3, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead);
-    pMP3->streamCursor += bytesRead;
-    return bytesRead;
-}
-
-static drmp3_bool32 drmp3__on_seek(drmp3* pMP3, int offset, drmp3_seek_origin origin)
-{
-    DRMP3_ASSERT(offset >= 0);
-
-    if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) {
-        return DRMP3_FALSE;
-    }
-
-    if (origin == drmp3_seek_origin_start) {
-        pMP3->streamCursor = (drmp3_uint64)offset;
-    } else {
-        pMP3->streamCursor += offset;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3__on_seek_64(drmp3* pMP3, drmp3_uint64 offset, drmp3_seek_origin origin)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return drmp3__on_seek(pMP3, (int)offset, origin);
-    }
-
-
-    /* Getting here "offset" is too large for a 32-bit integer. We just keep seeking forward until we hit the offset. */
-    if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-
-    offset -= 0x7FFFFFFF;
-    while (offset > 0) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!drmp3__on_seek(pMP3, (int)offset, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset = 0;
-        } else {
-            if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset -= 0x7FFFFFFF;
-        }
-    }
-
-    return DRMP3_TRUE;
-}
-
-
-static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-
-    if (pMP3->atEnd) {
-        return 0;
-    }
-
-    for (;;) {
-        drmp3dec_frame_info info;
-
-        /* minimp3 recommends doing data submission in chunks of at least 16K. If we don't have at least 16K bytes available, get more. */
-        if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
-            size_t bytesRead;
-
-            /* First we need to move the data down. */
-            if (pMP3->pData != NULL) {
-                memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            }
-
-            pMP3->dataConsumed = 0;
-
-            if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-
-                newDataCap = DRMP3_DATA_CHUNK_SIZE;
-
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0; /* Out of memory. */
-                }
-
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                if (pMP3->dataSize == 0) {
-                    pMP3->atEnd = DRMP3_TRUE;
-                    return 0; /* No data. */
-                }
-            }
-
-            pMP3->dataSize += bytesRead;
-        }
-
-        if (pMP3->dataSize > INT_MAX) {
-            pMP3->atEnd = DRMP3_TRUE;
-            return 0; /* File too big. */
-        }
-
-        DRMP3_ASSERT(pMP3->pData != NULL);
-        DRMP3_ASSERT(pMP3->dataCapacity > 0);
-
-        pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);    /* <-- Safe size_t -> int conversion thanks to the check above. */
-
-        /* Consume the data. */
-        if (info.frame_bytes > 0) {
-            pMP3->dataConsumed += (size_t)info.frame_bytes;
-            pMP3->dataSize     -= (size_t)info.frame_bytes;
-        }
-
-        /* pcmFramesRead will be equal to 0 if decoding failed. If it is zero and info.frame_bytes > 0 then we have successfully decoded the frame. */
-        if (pcmFramesRead > 0) {
-            pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
-            pMP3->pcmFramesConsumedInMP3Frame = 0;
-            pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-            pMP3->mp3FrameChannels = info.channels;
-            pMP3->mp3FrameSampleRate = info.hz;
-            break;
-        } else if (info.frame_bytes == 0) {
-            /* Need more data. minimp3 recommends doing data submission in 16K chunks. */
-            size_t bytesRead;
-
-            /* First we need to move the data down. */
-            memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            pMP3->dataConsumed = 0;
-
-            if (pMP3->dataCapacity == pMP3->dataSize) {
-                /* No room. Expand. */
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-
-                newDataCap = pMP3->dataCapacity + DRMP3_DATA_CHUNK_SIZE;
-
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0; /* Out of memory. */
-                }
-
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-
-            /* Fill in a chunk. */
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                pMP3->atEnd = DRMP3_TRUE;
-                return 0; /* Error reading more data. */
-            }
-
-            pMP3->dataSize += bytesRead;
-        }
-    };
-
-    return pcmFramesRead;
-}
-
-static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    drmp3dec_frame_info info;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.pData != NULL);
-
-    if (pMP3->atEnd) {
-        return 0;
-    }
-
-    pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
-    if (pcmFramesRead > 0) {
-        pMP3->pcmFramesConsumedInMP3Frame  = 0;
-        pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-        pMP3->mp3FrameChannels             = info.channels;
-        pMP3->mp3FrameSampleRate           = info.hz;
-    }
-
-    /* Consume the data. */
-    pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
-
-    return pcmFramesRead;
-}
-
-static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) {
-        return drmp3_decode_next_frame_ex__memory(pMP3, pPCMFrames);
-    } else {
-        return drmp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames);
-    }
-}
-
-static drmp3_uint32 drmp3_decode_next_frame(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    return drmp3_decode_next_frame_ex(pMP3, (drmp3d_sample_t*)pMP3->pcmFrames);
-}
-
-#if 0
-static drmp3_uint32 drmp3_seek_next_frame(drmp3* pMP3)
-{
-    drmp3_uint32 pcmFrameCount;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    pcmFrameCount = drmp3_decode_next_frame_ex(pMP3, NULL);
-    if (pcmFrameCount == 0) {
-        return 0;
-    }
-
-    /* We have essentially just skipped past the frame, so just set the remaining samples to 0. */
-    pMP3->currentPCMFrame             += pcmFrameCount;
-    pMP3->pcmFramesConsumedInMP3Frame  = pcmFrameCount;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-
-    return pcmFrameCount;
-}
-#endif
-
-static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(onRead != NULL);
-
-    /* This function assumes the output object has already been reset to 0. Do not do that here, otherwise things will break. */
-    drmp3dec_init(&pMP3->decoder);
-
-    pMP3->onRead = onRead;
-    pMP3->onSeek = onSeek;
-    pMP3->pUserData = pUserData;
-    pMP3->allocationCallbacks = drmp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
-        return DRMP3_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    /* Decode the first frame to confirm that it is indeed a valid MP3 stream. */
-    if (!drmp3_decode_next_frame(pMP3)) {
-        drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);    /* The call above may have allocated memory. Need to make sure it's freed before aborting. */
-        return DRMP3_FALSE; /* Not a valid MP3 stream. */
-    }
-
-    pMP3->channels   = pMP3->mp3FrameChannels;
-    pMP3->sampleRate = pMP3->mp3FrameSampleRate;
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL || onRead == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    DRMP3_ZERO_OBJECT(pMP3);
-    return drmp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks);
-}
-
-
-static size_t drmp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    size_t bytesRemaining;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos);
-
-    bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRMP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead);
-        pMP3->memory.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static drmp3_bool32 drmp3__on_seek_memory(void* pUserData, int byteOffset, drmp3_seek_origin origin)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    if (origin == drmp3_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) {
-                byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pMP3->memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pMP3->memory.currentReadPos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pMP3->memory.currentReadPos += byteOffset;
-    } else {
-        if ((drmp3_uint32)byteOffset <= pMP3->memory.dataSize) {
-            pMP3->memory.currentReadPos = byteOffset;
-        } else {
-            pMP3->memory.currentReadPos = pMP3->memory.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    DRMP3_ZERO_OBJECT(pMP3);
-
-    if (pData == NULL || dataSize == 0) {
-        return DRMP3_FALSE;
-    }
-
-    pMP3->memory.pData = (const drmp3_uint8*)pData;
-    pMP3->memory.dataSize = dataSize;
-    pMP3->memory.currentReadPos = 0;
-
-    return drmp3_init_internal(pMP3, drmp3__on_read_memory, drmp3__on_seek_memory, pMP3, pAllocationCallbacks);
-}
-
-
-#ifndef DR_MP3_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>      /* For wcslen(), wcsrtombs() */
-
-/* drmp3_result_from_errno() is only used inside DR_MP3_NO_STDIO for now. Move this out if it's ever used elsewhere. */
-#include <errno.h>
-static drmp3_result drmp3_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRMP3_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRMP3_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRMP3_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRMP3_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRMP3_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRMP3_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRMP3_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRMP3_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRMP3_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRMP3_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRMP3_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRMP3_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRMP3_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRMP3_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRMP3_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRMP3_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRMP3_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRMP3_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRMP3_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRMP3_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRMP3_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRMP3_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRMP3_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRMP3_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRMP3_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRMP3_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRMP3_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRMP3_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRMP3_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRMP3_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRMP3_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRMP3_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRMP3_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRMP3_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRMP3_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRMP3_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRMP3_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRMP3_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRMP3_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRMP3_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRMP3_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRMP3_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRMP3_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRMP3_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRMP3_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRMP3_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRMP3_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRMP3_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRMP3_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRMP3_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRMP3_ERROR;
-    #endif
-        default: return DRMP3_ERROR;
-    }
-}
-
-static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drmp3_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drmp3_result result = drmp3_result_from_errno(errno);
-        if (result == DRMP3_SUCCESS) {
-            result = DRMP3_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRMP3_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRMP3_HAS_WFOPEN
-    #endif
-#endif
-
-static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-
-#if defined(DRMP3_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drmp3_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drmp3_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRMP3_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drmp3_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drmp3__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRMP3_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRMP3_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRMP3_ERROR;
-    }
-#endif
-
-    return DRMP3_SUCCESS;
-}
-
-
-
-static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-static drmp3_bool32 drmp3__on_seek_stdio(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drmp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-
-    if (drmp3_fopen(&pFile, pFilePath, "rb") != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-
-    if (drmp3_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRMP3_TRUE;
-}
-#endif
-
-DRMP3_API void drmp3_uninit(drmp3* pMP3)
-{
-    if (pMP3 == NULL) {
-        return;
-    }
-    
-#ifndef DR_MP3_NO_STDIO
-    if (pMP3->onRead == drmp3__on_read_stdio) {
-        FILE* pFile = (FILE*)pMP3->pUserData;
-        if (pFile != NULL) {
-            fclose(pFile);
-            pMP3->pUserData = NULL; /* Make sure the file handle is cleared to NULL to we don't attempt to close it a second time. */
-        }
-    }
-#endif
-
-    drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-}
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_f32_to_s16(drmp3_int16* dst, const float* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    drmp3_uint64 i4;
-    drmp3_uint64 sampleCount4;
-
-    /* Unrolled. */
-    i = 0;
-    sampleCount4 = sampleCount >> 2;
-    for (i4 = 0; i4 < sampleCount4; i4 += 1) {
-        float x0 = src[i+0];
-        float x1 = src[i+1];
-        float x2 = src[i+2];
-        float x3 = src[i+3];
-
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-
-        dst[i+0] = (drmp3_int16)x0;
-        dst[i+1] = (drmp3_int16)x1;
-        dst[i+2] = (drmp3_int16)x2;
-        dst[i+3] = (drmp3_int16)x3;
-
-        i += 4;
-    }
-
-    /* Leftover. */
-    for (; i < sampleCount; i += 1) {
-        float x = src[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst[i] = (drmp3_int16)x;
-    }
-}
-#endif
-
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_s16_to_f32(float* dst, const drmp3_int16* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    for (i = 0; i < sampleCount; i += 1) {
-        float x = (float)src[i];
-        x = x * 0.000030517578125f;         /* -32768..32767 to -1..0.999969482421875 */
-        dst[i] = x;
-    }
-}
-#endif
-
-
-static drmp3_uint64 drmp3_read_pcm_frames_raw(drmp3* pMP3, drmp3_uint64 framesToRead, void* pBufferOut)
-{
-    drmp3_uint64 totalFramesRead = 0;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-
-    while (framesToRead > 0) {
-        drmp3_uint32 framesToConsume = (drmp3_uint32)DRMP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead);
-        if (pBufferOut != NULL) {
-        #if defined(DR_MP3_FLOAT_OUTPUT)
-            /* f32 */
-            float* pFramesOutF32 = (float*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(float) * totalFramesRead                   * pMP3->channels);
-            float* pFramesInF32  = (float*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels);
-        #else
-            /* s16 */
-            drmp3_int16* pFramesOutS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(drmp3_int16) * totalFramesRead                   * pMP3->channels);
-            drmp3_int16* pFramesInS16  = (drmp3_int16*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(drmp3_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(drmp3_int16) * framesToConsume * pMP3->channels);
-        #endif
-        }
-
-        pMP3->currentPCMFrame              += framesToConsume;
-        pMP3->pcmFramesConsumedInMP3Frame  += framesToConsume;
-        pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume;
-        totalFramesRead                    += framesToConsume;
-        framesToRead                       -= framesToConsume;
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-        DRMP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0);
-
-        /*
-        At this point we have exhausted our in-memory buffer so we need to re-fill. Note that the sample rate may have changed
-        at this point which means we'll also need to update our sample rate conversion pipeline.
-        */
-        if (drmp3_decode_next_frame(pMP3) == 0) {
-            break;
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    /* Fast path. No conversion required. */
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    /* Slow path. Convert from s16 to f32. */
-    {
-        drmp3_int16 pTempS16[8192];
-        drmp3_uint64 totalPCMFramesRead = 0;
-
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempS16) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16);
-            if (framesJustRead == 0) {
-                break;
-            }
-
-            drmp3_s16_to_f32((float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-
-        return totalPCMFramesRead;
-    }
-#endif
-}
-
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-    /* Fast path. No conversion required. */
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    /* Slow path. Convert from f32 to s16. */
-    {
-        float pTempF32[4096];
-        drmp3_uint64 totalPCMFramesRead = 0;
-
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempF32) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32);
-            if (framesJustRead == 0) {
-                break;
-            }
-
-            drmp3_f32_to_s16((drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-
-        return totalPCMFramesRead;
-    }
-#endif
-}
-
-static void drmp3_reset(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    pMP3->pcmFramesConsumedInMP3Frame = 0;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    pMP3->currentPCMFrame = 0;
-    pMP3->dataSize = 0;
-    pMP3->atEnd = DRMP3_FALSE;
-    drmp3dec_init(&pMP3->decoder);
-}
-
-static drmp3_bool32 drmp3_seek_to_start_of_stream(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onSeek != NULL);
-
-    /* Seek to the start of the stream to begin with. */
-    if (!drmp3__on_seek(pMP3, 0, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-
-    /* Clear any cached data. */
-    drmp3_reset(pMP3);
-    return DRMP3_TRUE;
-}
-
-
-static drmp3_bool32 drmp3_seek_forward_by_pcm_frames__brute_force(drmp3* pMP3, drmp3_uint64 frameOffset)
-{
-    drmp3_uint64 framesRead;
-
-    /*
-    Just using a dumb read-and-discard for now. What would be nice is to parse only the header of the MP3 frame, and then skip over leading
-    frames without spending the time doing a full decode. I cannot see an easy way to do this in minimp3, however, so it may involve some
-    kind of manual processing.
-    */
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    framesRead = drmp3_read_pcm_frames_f32(pMP3, frameOffset, NULL);
-#else
-    framesRead = drmp3_read_pcm_frames_s16(pMP3, frameOffset, NULL);
-#endif
-    if (framesRead != frameOffset) {
-        return DRMP3_FALSE;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3_seek_to_pcm_frame__brute_force(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    if (frameIndex == pMP3->currentPCMFrame) {
-        return DRMP3_TRUE;
-    }
-
-    /*
-    If we're moving foward we just read from where we're at. Otherwise we need to move back to the start of
-    the stream and read from the beginning.
-    */
-    if (frameIndex < pMP3->currentPCMFrame) {
-        /* Moving backward. Move to the start of the stream and then move forward. */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    DRMP3_ASSERT(frameIndex >= pMP3->currentPCMFrame);
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame));
-}
-
-static drmp3_bool32 drmp3_find_closest_seek_point(drmp3* pMP3, drmp3_uint64 frameIndex, drmp3_uint32* pSeekPointIndex)
-{
-    drmp3_uint32 iSeekPoint;
-
-    DRMP3_ASSERT(pSeekPointIndex != NULL);
-
-    *pSeekPointIndex = 0;
-
-    if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) {
-        return DRMP3_FALSE;
-    }
-
-    /* Linear search for simplicity to begin with while I'm getting this thing working. Once it's all working change this to a binary search. */
-    for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) {
-        if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) {
-            break;  /* Found it. */
-        }
-
-        *pSeekPointIndex = iSeekPoint;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3_seek_to_pcm_frame__seek_table(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    drmp3_seek_point seekPoint;
-    drmp3_uint32 priorSeekPointIndex;
-    drmp3_uint16 iMP3Frame;
-    drmp3_uint64 leftoverFrames;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->pSeekPoints != NULL);
-    DRMP3_ASSERT(pMP3->seekPointCount > 0);
-
-    /* If there is no prior seekpoint it means the target PCM frame comes before the first seek point. Just assume a seekpoint at the start of the file in this case. */
-    if (drmp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) {
-        seekPoint = pMP3->pSeekPoints[priorSeekPointIndex];
-    } else {
-        seekPoint.seekPosInBytes     = 0;
-        seekPoint.pcmFrameIndex      = 0;
-        seekPoint.mp3FramesToDiscard = 0;
-        seekPoint.pcmFramesToDiscard = 0;
-    }
-
-    /* First thing to do is seek to the first byte of the relevant MP3 frame. */
-    if (!drmp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE; /* Failed to seek. */
-    }
-
-    /* Clear any cached data. */
-    drmp3_reset(pMP3);
-
-    /* Whole MP3 frames need to be discarded first. */
-    for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) {
-        drmp3_uint32 pcmFramesRead;
-        drmp3d_sample_t* pPCMFrames;
-
-        /* Pass in non-null for the last frame because we want to ensure the sample rate converter is preloaded correctly. */
-        pPCMFrames = NULL;
-        if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) {
-            pPCMFrames = (drmp3d_sample_t*)pMP3->pcmFrames;
-        }
-
-        /* We first need to decode the next frame. */
-        pcmFramesRead = drmp3_decode_next_frame_ex(pMP3, pPCMFrames);
-        if (pcmFramesRead == 0) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    /* We seeked to an MP3 frame in the raw stream so we need to make sure the current PCM frame is set correctly. */
-    pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard;
-
-    /*
-    Now at this point we can follow the same process as the brute force technique where we just skip over unnecessary MP3 frames and then
-    read-and-discard at least 2 whole MP3 frames.
-    */
-    leftoverFrames = frameIndex - pMP3->currentPCMFrame;
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames);
-}
-
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    if (pMP3 == NULL || pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    if (frameIndex == 0) {
-        return drmp3_seek_to_start_of_stream(pMP3);
-    }
-
-    /* Use the seek table if we have one. */
-    if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) {
-        return drmp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex);
-    } else {
-        return drmp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex);
-    }
-}
-
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount)
-{
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalPCMFrameCount;
-    drmp3_uint64 totalMP3FrameCount;
-
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    /*
-    The way this works is we move back to the start of the stream, iterate over each MP3 frame and calculate the frame count based
-    on our output sample rate, the seek back to the PCM frame we were sitting on before calling this function.
-    */
-
-    /* The stream must support seeking for this to work. */
-    if (pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    /* We'll need to seek back to where we were, so grab the PCM frame we're currently sitting on so we can restore later. */
-    currentPCMFrame = pMP3->currentPCMFrame;
-    
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-
-    totalPCMFrameCount = 0;
-    totalMP3FrameCount = 0;
-
-    for (;;) {
-        drmp3_uint32 pcmFramesInCurrentMP3Frame;
-
-        pcmFramesInCurrentMP3Frame = drmp3_decode_next_frame_ex(pMP3, NULL);
-        if (pcmFramesInCurrentMP3Frame == 0) {
-            break;
-        }
-
-        totalPCMFrameCount += pcmFramesInCurrentMP3Frame;
-        totalMP3FrameCount += 1;
-    }
-
-    /* Finally, we need to seek back to where we were. */
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-
-    if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-        return DRMP3_FALSE;
-    }
-
-    if (pMP3FrameCount != NULL) {
-        *pMP3FrameCount = totalMP3FrameCount;
-    }
-    if (pPCMFrameCount != NULL) {
-        *pPCMFrameCount = totalPCMFrameCount;
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalPCMFrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) {
-        return 0;
-    }
-
-    return totalPCMFrameCount;
-}
-
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalMP3FrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) {
-        return 0;
-    }
-
-    return totalMP3FrameCount;
-}
-
-static void drmp3__accumulate_running_pcm_frame_count(drmp3* pMP3, drmp3_uint32 pcmFrameCountIn, drmp3_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart)
-{
-    float srcRatio;
-    float pcmFrameCountOutF;
-    drmp3_uint32 pcmFrameCountOut;
-
-    srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate;
-    DRMP3_ASSERT(srcRatio > 0);
-
-    pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio);
-    pcmFrameCountOut  = (drmp3_uint32)pcmFrameCountOutF;
-    *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut;
-    *pRunningPCMFrameCount += pcmFrameCountOut;
-}
-
-typedef struct
-{
-    drmp3_uint64 bytePos;
-    drmp3_uint64 pcmFrameIndex; /* <-- After sample rate conversion. */
-} drmp3__seeking_mp3_frame_info;
-
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    drmp3_uint32 seekPointCount;
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalMP3FrameCount;
-    drmp3_uint64 totalPCMFrameCount;
-
-    if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) {
-        return DRMP3_FALSE; /* Invalid args. */
-    }
-
-    seekPointCount = *pSeekPointCount;
-    if (seekPointCount == 0) {
-        return DRMP3_FALSE;  /* The client has requested no seek points. Consider this to be invalid arguments since the client has probably not intended this. */
-    }
-
-    /* We'll need to seek back to the current sample after calculating the seekpoints so we need to go ahead and grab the current location at the top. */
-    currentPCMFrame = pMP3->currentPCMFrame;
-    
-    /* We never do more than the total number of MP3 frames and we limit it to 32-bits. */
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) {
-        return DRMP3_FALSE;
-    }
-
-    /* If there's less than DRMP3_SEEK_LEADING_MP3_FRAMES+1 frames we just report 1 seek point which will be the very start of the stream. */
-    if (totalMP3FrameCount < DRMP3_SEEK_LEADING_MP3_FRAMES+1) {
-        seekPointCount = 1;
-        pSeekPoints[0].seekPosInBytes     = 0;
-        pSeekPoints[0].pcmFrameIndex      = 0;
-        pSeekPoints[0].mp3FramesToDiscard = 0;
-        pSeekPoints[0].pcmFramesToDiscard = 0;
-    } else {
-        drmp3_uint64 pcmFramesBetweenSeekPoints;
-        drmp3__seeking_mp3_frame_info mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES+1];
-        drmp3_uint64 runningPCMFrameCount = 0;
-        float runningPCMFrameCountFractionalPart = 0;
-        drmp3_uint64 nextTargetPCMFrame;
-        drmp3_uint32 iMP3Frame;
-        drmp3_uint32 iSeekPoint;
-
-        if (seekPointCount > totalMP3FrameCount-1) {
-            seekPointCount = (drmp3_uint32)totalMP3FrameCount-1;
-        }
-
-        pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1);
-
-        /*
-        Here is where we actually calculate the seek points. We need to start by moving the start of the stream. We then enumerate over each
-        MP3 frame.
-        */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-
-        /*
-        We need to cache the byte positions of the previous MP3 frames. As a new MP3 frame is iterated, we cycle the byte positions in this
-        array. The value in the first item in this array is the byte position that will be reported in the next seek point.
-        */
-
-        /* We need to initialize the array of MP3 byte positions for the leading MP3 frames. */
-        for (iMP3Frame = 0; iMP3Frame < DRMP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) {
-            drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-
-            /* The byte position of the next frame will be the stream's cursor position, minus whatever is sitting in the buffer. */
-            DRMP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize);
-            mp3FrameInfo[iMP3Frame].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-            mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount;
-
-            /* We need to get information about this frame so we can know how many samples it contained. */
-            pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-            if (pcmFramesInCurrentMP3FrameIn == 0) {
-                return DRMP3_FALSE; /* This should never happen. */
-            }
-
-            drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-        }
-
-        /*
-        At this point we will have extracted the byte positions of the leading MP3 frames. We can now start iterating over each seek point and
-        calculate them.
-        */
-        nextTargetPCMFrame = 0;
-        for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
-            nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
-
-            for (;;) {
-                if (nextTargetPCMFrame < runningPCMFrameCount) {
-                    /* The next seek point is in the current MP3 frame. */
-                    pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                    pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                    pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                    pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                    break;
-                } else {
-                    size_t i;
-                    drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-
-                    /*
-                    The next seek point is not in the current MP3 frame, so continue on to the next one. The first thing to do is cycle the cached
-                    MP3 frame info.
-                    */
-                    for (i = 0; i < DRMP3_COUNTOF(mp3FrameInfo)-1; ++i) {
-                        mp3FrameInfo[i] = mp3FrameInfo[i+1];
-                    }
-
-                    /* Cache previous MP3 frame info. */
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount;
-
-                    /*
-                    Go to the next MP3 frame. This shouldn't ever fail, but just in case it does we just set the seek point and break. If it happens, it
-                    should only ever do it for the last seek point.
-                    */
-                    pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-                    if (pcmFramesInCurrentMP3FrameIn == 0) {
-                        pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                        pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                        pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                        pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                        break;
-                    }
-
-                    drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-                }
-            }
-        }
-
-        /* Finally, we need to seek back to where we were. */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    *pSeekPointCount = seekPointCount;
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    if (seekPointCount == 0 || pSeekPoints == NULL) {
-        /* Unbinding. */
-        pMP3->seekPointCount = 0;
-        pMP3->pSeekPoints = NULL;
-    } else {
-        /* Binding. */
-        pMP3->seekPointCount = seekPointCount;
-        pMP3->pSeekPoints = pSeekPoints;
-    }
-
-    return DRMP3_TRUE;
-}
-
-
-static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    float* pFrames = NULL;
-    float temp[4096];
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-
-        /* Reallocate the output buffer if there's not enough room. */
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            float* pNewFrames;
-
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(float);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-
-            pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float)));
-        totalFramesRead += framesJustRead;
-
-        /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-
-    drmp3_uninit(pMP3);
-
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-
-    return pFrames;
-}
-
-static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    drmp3_int16* pFrames = NULL;
-    drmp3_int16 temp[4096];
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-
-        /* Reallocate the output buffer if there's not enough room. */
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            drmp3_int16* pNewFrames;
-
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(drmp3_int16);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-
-            pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(drmp3_int16)));
-        totalFramesRead += framesJustRead;
-
-        /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-
-    drmp3_uninit(pMP3);
-
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-
-    return pFrames;
-}
-
-
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-
-
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-
-
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#endif
-
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return drmp3__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return drmp3__malloc_default(sz, NULL);
-    }
-}
-
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drmp3__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drmp3__free_default(p, NULL);
-    }
-}
-
-#endif  /* dr_mp3_c */
-#endif  /*DR_MP3_IMPLEMENTATION*/
-
-/*
-DIFFERENCES BETWEEN minimp3 AND dr_mp3
-======================================
-- First, keep in mind that minimp3 (https://github.com/lieff/minimp3) is where all the real work was done. All of the
-  code relating to the actual decoding remains mostly unmodified, apart from some namespacing changes.
-- dr_mp3 adds a pulling style API which allows you to deliver raw data via callbacks. So, rather than pushing data
-  to the decoder, the decoder _pulls_ data from your callbacks.
-- In addition to callbacks, a decoder can be initialized from a block of memory and a file.
-- The dr_mp3 pull API reads PCM frames rather than whole MP3 frames.
-- dr_mp3 adds convenience APIs for opening and decoding entire files in one go.
-- dr_mp3 is fully namespaced, including the implementation section, which is more suitable when compiling projects
-  as a single translation unit (aka unity builds). At the time of writing this, a unity build is not possible when
-  using minimp3 in conjunction with stb_vorbis. dr_mp3 addresses this.
-*/
-
-/*
-RELEASE NOTES - v0.5.0
-=======================
-Version 0.5.0 has breaking API changes.
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRMP3_MALLOC, DRMP3_REALLOC and DRMP3_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drmp3_allocation_callbacks object to drmp3_init() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drmp3_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drmp3_init_file(&mp3, "my_file.mp3", NULL, &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_mp3 to use defaults which is the same as DRMP3_MALLOC,
-DRMP3_REALLOC and DRMP3_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drmp3 object now takes this extra parameter. These include the following:
-
-    drmp3_init()
-    drmp3_init_file()
-    drmp3_init_memory()
-    drmp3_open_and_read_pcm_frames_f32()
-    drmp3_open_and_read_pcm_frames_s16()
-    drmp3_open_memory_and_read_pcm_frames_f32()
-    drmp3_open_memory_and_read_pcm_frames_s16()
-    drmp3_open_file_and_read_pcm_frames_f32()
-    drmp3_open_file_and_read_pcm_frames_s16()
-
-Renamed APIs
-------------
-The following APIs have been renamed for consistency with other dr_* libraries and to make it clear that they return PCM frame
-counts rather than sample counts.
-
-    drmp3_open_and_read_f32()        -> drmp3_open_and_read_pcm_frames_f32()
-    drmp3_open_and_read_s16()        -> drmp3_open_and_read_pcm_frames_s16()
-    drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
-    drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
-    drmp3_open_file_and_read_f32()   -> drmp3_open_file_and_read_pcm_frames_f32()
-    drmp3_open_file_and_read_s16()   -> drmp3_open_file_and_read_pcm_frames_s16()
-*/
-
-/*
-REVISION HISTORY
-================
-v0.6.27 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-
-v0.6.26 - 2021-01-31
-  - Bring up to date with minimp3.
-
-v0.6.25 - 2020-12-26
-  - Remove DRMP3_DEFAULT_CHANNELS and DRMP3_DEFAULT_SAMPLE_RATE which are leftovers from some removed APIs.
-
-v0.6.24 - 2020-12-07
-  - Fix a typo in version date for 0.6.23.
-
-v0.6.23 - 2020-12-03
-  - Fix an error where a file can be closed twice when initialization of the decoder fails.
-
-v0.6.22 - 2020-12-02
-  - Fix an error where it's possible for a file handle to be left open when initialization of the decoder fails.
-
-v0.6.21 - 2020-11-28
-  - Bring up to date with minimp3.
-
-v0.6.20 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.6.19 - 2020-11-13
-  - Minor code clean up.
-
-v0.6.18 - 2020-11-01
-  - Improve compiler support for older versions of GCC.
-
-v0.6.17 - 2020-09-28
-  - Bring up to date with minimp3.
-
-v0.6.16 - 2020-08-02
-  - Simplify sized types.
-
-v0.6.15 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.6.14 - 2020-07-23
-  - Fix undefined behaviour with memmove().
-
-v0.6.13 - 2020-07-06
-  - Fix a bug when converting from s16 to f32 in drmp3_read_pcm_frames_f32().
-
-v0.6.12 - 2020-06-23
-  - Add include guard for the implementation section.
-
-v0.6.11 - 2020-05-26
-  - Fix use of uninitialized variable error.
-
-v0.6.10 - 2020-05-16
-  - Add compile-time and run-time version querying.
-    - DRMP3_VERSION_MINOR
-    - DRMP3_VERSION_MAJOR
-    - DRMP3_VERSION_REVISION
-    - DRMP3_VERSION_STRING
-    - drmp3_version()
-    - drmp3_version_string()
-
-v0.6.9 - 2020-04-30
-  - Change the `pcm` parameter of drmp3dec_decode_frame() to a `const drmp3_uint8*` for consistency with internal APIs.
-
-v0.6.8 - 2020-04-26
-  - Optimizations to decoding when initializing from memory.
-
-v0.6.7 - 2020-04-25
-  - Fix a compilation error with DR_MP3_NO_STDIO
-  - Optimization to decoding by reducing some data movement.
-
-v0.6.6 - 2020-04-23
-  - Fix a minor bug with the running PCM frame counter.
-
-v0.6.5 - 2020-04-19
-  - Fix compilation error on ARM builds.
-
-v0.6.4 - 2020-04-19
-  - Bring up to date with changes to minimp3.
-
-v0.6.3 - 2020-04-13
-  - Fix some pedantic warnings.
-
-v0.6.2 - 2020-04-10
-  - Fix a crash in drmp3_open_*_and_read_pcm_frames_*() if the output config object is NULL.
-
-v0.6.1 - 2020-04-05
-  - Fix warnings.
-
-v0.6.0 - 2020-04-04
-  - API CHANGE: Remove the pConfig parameter from the following APIs:
-    - drmp3_init()
-    - drmp3_init_memory()
-    - drmp3_init_file()
-  - Add drmp3_init_file_w() for opening a file from a wchar_t encoded path.
-
-v0.5.6 - 2020-02-12
-  - Bring up to date with minimp3.
-
-v0.5.5 - 2020-01-29
-  - Fix a memory allocation bug in high level s16 decoding APIs.
-
-v0.5.4 - 2019-12-02
-  - Fix a possible null pointer dereference when using custom memory allocators for realloc().
-
-v0.5.3 - 2019-11-14
-  - Fix typos in documentation.
-
-v0.5.2 - 2019-11-02
-  - Bring up to date with minimp3.
-
-v0.5.1 - 2019-10-08
-  - Fix a warning with GCC.
-
-v0.5.0 - 2019-10-07
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drmp3_init()
-    - drmp3_init_file()
-    - drmp3_init_memory()
-    - drmp3_open_and_read_pcm_frames_f32()
-    - drmp3_open_and_read_pcm_frames_s16()
-    - drmp3_open_memory_and_read_pcm_frames_f32()
-    - drmp3_open_memory_and_read_pcm_frames_s16()
-    - drmp3_open_file_and_read_pcm_frames_f32()
-    - drmp3_open_file_and_read_pcm_frames_s16()
-  - API CHANGE: Renamed the following APIs:
-    - drmp3_open_and_read_f32()        -> drmp3_open_and_read_pcm_frames_f32()
-    - drmp3_open_and_read_s16()        -> drmp3_open_and_read_pcm_frames_s16()
-    - drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
-    - drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
-    - drmp3_open_file_and_read_f32()   -> drmp3_open_file_and_read_pcm_frames_f32()
-    - drmp3_open_file_and_read_s16()   -> drmp3_open_file_and_read_pcm_frames_s16()
-
-v0.4.7 - 2019-07-28
-  - Fix a compiler error.
-
-v0.4.6 - 2019-06-14
-  - Fix a compiler error.
-
-v0.4.5 - 2019-06-06
-  - Bring up to date with minimp3.
-
-v0.4.4 - 2019-05-06
-  - Fixes to the VC6 build.
-
-v0.4.3 - 2019-05-05
-  - Use the channel count and/or sample rate of the first MP3 frame instead of DRMP3_DEFAULT_CHANNELS and
-    DRMP3_DEFAULT_SAMPLE_RATE when they are set to 0. To use the old behaviour, just set the relevant property to
-    DRMP3_DEFAULT_CHANNELS or DRMP3_DEFAULT_SAMPLE_RATE.
-  - Add s16 reading APIs
-    - drmp3_read_pcm_frames_s16
-    - drmp3_open_memory_and_read_pcm_frames_s16
-    - drmp3_open_and_read_pcm_frames_s16
-    - drmp3_open_file_and_read_pcm_frames_s16
-  - Add drmp3_get_mp3_and_pcm_frame_count() to the public header section.
-  - Add support for C89.
-  - Change license to choice of public domain or MIT-0.
-
-v0.4.2 - 2019-02-21
-  - Fix a warning.
-
-v0.4.1 - 2018-12-30
-  - Fix a warning.
-
-v0.4.0 - 2018-12-16
-  - API CHANGE: Rename some APIs:
-    - drmp3_read_f32 -> to drmp3_read_pcm_frames_f32
-    - drmp3_seek_to_frame -> drmp3_seek_to_pcm_frame
-    - drmp3_open_and_decode_f32 -> drmp3_open_and_read_pcm_frames_f32
-    - drmp3_open_and_decode_memory_f32 -> drmp3_open_memory_and_read_pcm_frames_f32
-    - drmp3_open_and_decode_file_f32 -> drmp3_open_file_and_read_pcm_frames_f32
-  - Add drmp3_get_pcm_frame_count().
-  - Add drmp3_get_mp3_frame_count().
-  - Improve seeking performance.
-
-v0.3.2 - 2018-09-11
-  - Fix a couple of memory leaks.
-  - Bring up to date with minimp3.
-
-v0.3.1 - 2018-08-25
-  - Fix C++ build.
-
-v0.3.0 - 2018-08-25
-  - Bring up to date with minimp3. This has a minor API change: the "pcm" parameter of drmp3dec_decode_frame() has
-    been changed from short* to void* because it can now output both s16 and f32 samples, depending on whether or
-    not the DR_MP3_FLOAT_OUTPUT option is set.
-
-v0.2.11 - 2018-08-08
-  - Fix a bug where the last part of a file is not read.
-
-v0.2.10 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.2.9 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-  - Bring up to date with minimp3.
-
-v0.2.8 - 2018-08-02
-  - Fix compilation errors with older versions of GCC.
-
-v0.2.7 - 2018-07-13
-  - Bring up to date with minimp3.
-
-v0.2.6 - 2018-07-12
-  - Bring up to date with minimp3.
-
-v0.2.5 - 2018-06-22
-  - Bring up to date with minimp3.
-
-v0.2.4 - 2018-05-12
-  - Bring up to date with minimp3.
-
-v0.2.3 - 2018-04-29
-  - Fix TCC build.
-
-v0.2.2 - 2018-04-28
-  - Fix bug when opening a decoder from memory.
-
-v0.2.1 - 2018-04-27
-  - Efficiency improvements when the decoder reaches the end of the stream.
-
-v0.2 - 2018-04-21
-  - Bring up to date with minimp3.
-  - Start using major.minor.revision versioning.
-
-v0.1d - 2018-03-30
-  - Bring up to date with minimp3.
-
-v0.1c - 2018-03-11
-  - Fix C++ build error.
-
-v0.1b - 2018-03-07
-  - Bring up to date with minimp3.
-
-v0.1a - 2018-02-28
-  - Fix compilation error on GCC/Clang.
-  - Fix some warnings.
-
-v0.1 - 2018-02-xx
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/*
-    https://github.com/lieff/minimp3
-    To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
-    This software is distributed without any warranty.
-    See <http://creativecommons.org/publicdomain/zero/1.0/>.
-*/
diff --git a/raylib/external/dr_wav.h b/raylib/external/dr_wav.h
deleted file mode 100644 (file)
index be1438b..0000000
+++ /dev/null
@@ -1,6407 +0,0 @@
-/*
-WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_wav - v0.12.19 - 2021-02-21
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-*/
-
-/*
-RELEASE NOTES - VERSION 0.12
-============================
-Version 0.12 includes breaking changes to custom chunk handling.
-
-
-Changes to Chunk Callback
--------------------------
-dr_wav supports the ability to fire a callback when a chunk is encounted (except for WAVE and FMT chunks). The callback has been updated to include both the
-container (RIFF or Wave64) and the FMT chunk which contains information about the format of the data in the wave file.
-
-Previously, there was no direct way to determine the container, and therefore no way to discriminate against the different IDs in the chunk header (RIFF and
-Wave64 containers encode chunk ID's differently). The `container` parameter can be used to know which ID to use.
-
-Sometimes it can be useful to know the data format at the time the chunk callback is fired. A pointer to a `drwav_fmt` object is now passed into the chunk
-callback which will give you information about the data format. To determine the sample format, use `drwav_fmt_get_format()`. This will return one of the
-`DR_WAVE_FORMAT_*` tokens.
-*/
-
-/*
-Introduction
-============
-This is a single file library. To use it, do something like the following in one .c file.
-    
-    ```c
-    #define DR_WAV_IMPLEMENTATION
-    #include "dr_wav.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. Do something like the following to read audio data:
-
-    ```c
-    drwav wav;
-    if (!drwav_init_file(&wav, "my_song.wav", NULL)) {
-        // Error opening WAV file.
-    }
-
-    drwav_int32* pDecodedInterleavedPCMFrames = malloc(wav.totalPCMFrameCount * wav.channels * sizeof(drwav_int32));
-    size_t numberOfSamplesActuallyDecoded = drwav_read_pcm_frames_s32(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
-
-    ...
-
-    drwav_uninit(&wav);
-    ```
-
-If you just want to quickly open and read the audio data in a single operation you can do something like this:
-
-    ```c
-    unsigned int channels;
-    unsigned int sampleRate;
-    drwav_uint64 totalPCMFrameCount;
-    float* pSampleData = drwav_open_file_and_read_pcm_frames_f32("my_song.wav", &channels, &sampleRate, &totalPCMFrameCount, NULL);
-    if (pSampleData == NULL) {
-        // Error opening and reading WAV file.
-    }
-
-    ...
-
-    drwav_free(pSampleData, NULL);
-    ```
-
-The examples above use versions of the API that convert the audio data to a consistent format (32-bit signed PCM, in this case), but you can still output the
-audio data in its internal format (see notes below for supported formats):
-
-    ```c
-    size_t framesRead = drwav_read_pcm_frames(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
-    ```
-
-You can also read the raw bytes of audio data, which could be useful if dr_wav does not have native support for a particular data format:
-
-    ```c
-    size_t bytesRead = drwav_read_raw(&wav, bytesToRead, pRawDataBuffer);
-    ```
-
-dr_wav can also be used to output WAV files. This does not currently support compressed formats. To use this, look at `drwav_init_write()`,
-`drwav_init_file_write()`, etc. Use `drwav_write_pcm_frames()` to write samples, or `drwav_write_raw()` to write raw data in the "data" chunk.
-
-    ```c
-    drwav_data_format format;
-    format.container = drwav_container_riff;     // <-- drwav_container_riff = normal WAV files, drwav_container_w64 = Sony Wave64.
-    format.format = DR_WAVE_FORMAT_PCM;          // <-- Any of the DR_WAVE_FORMAT_* codes.
-    format.channels = 2;
-    format.sampleRate = 44100;
-    format.bitsPerSample = 16;
-    drwav_init_file_write(&wav, "data/recording.wav", &format, NULL);
-
-    ...
-
-    drwav_uint64 framesWritten = drwav_write_pcm_frames(pWav, frameCount, pSamples);
-    ```
-
-dr_wav has seamless support the Sony Wave64 format. The decoder will automatically detect it and it should Just Work without any manual intervention.
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_WAV_NO_CONVERSION_API
-  Disables conversion APIs such as `drwav_read_pcm_frames_f32()` and `drwav_s16_to_f32()`.
-
-#define DR_WAV_NO_STDIO
-  Disables APIs that initialize a decoder from a file such as `drwav_init_file()`, `drwav_init_file_write()`, etc.
-
-
-
-Notes
-=====
-- Samples are always interleaved.
-- The default read function does not do any data conversion. Use `drwav_read_pcm_frames_f32()`, `drwav_read_pcm_frames_s32()` and `drwav_read_pcm_frames_s16()`
-  to read and convert audio data to 32-bit floating point, signed 32-bit integer and signed 16-bit integer samples respectively. Tested and supported internal
-  formats include the following:
-  - Unsigned 8-bit PCM
-  - Signed 12-bit PCM
-  - Signed 16-bit PCM
-  - Signed 24-bit PCM
-  - Signed 32-bit PCM
-  - IEEE 32-bit floating point
-  - IEEE 64-bit floating point
-  - A-law and u-law
-  - Microsoft ADPCM
-  - IMA ADPCM (DVI, format code 0x11)
-- dr_wav will try to read the WAV file as best it can, even if it's not strictly conformant to the WAV format.
-*/
-
-#ifndef dr_wav_h
-#define dr_wav_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRWAV_STRINGIFY(x)      #x
-#define DRWAV_XSTRINGIFY(x)     DRWAV_STRINGIFY(x)
-
-#define DRWAV_VERSION_MAJOR     0
-#define DRWAV_VERSION_MINOR     12
-#define DRWAV_VERSION_REVISION  19
-#define DRWAV_VERSION_STRING    DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drwav_int8;
-typedef unsigned char           drwav_uint8;
-typedef   signed short          drwav_int16;
-typedef unsigned short          drwav_uint16;
-typedef   signed int            drwav_int32;
-typedef unsigned int            drwav_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drwav_int64;
-    typedef unsigned __int64    drwav_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drwav_int64;
-    typedef unsigned long long  drwav_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drwav_uint64        drwav_uintptr;
-#else
-    typedef drwav_uint32        drwav_uintptr;
-#endif
-typedef drwav_uint8             drwav_bool8;
-typedef drwav_uint32            drwav_bool32;
-#define DRWAV_TRUE              1
-#define DRWAV_FALSE             0
-
-#if !defined(DRWAV_API)
-    #if defined(DRWAV_DLL)
-        #if defined(_WIN32)
-            #define DRWAV_DLL_IMPORT  __declspec(dllimport)
-            #define DRWAV_DLL_EXPORT  __declspec(dllexport)
-            #define DRWAV_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRWAV_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRWAV_DLL_IMPORT
-                #define DRWAV_DLL_EXPORT
-                #define DRWAV_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-            #define DRWAV_API  DRWAV_DLL_EXPORT
-        #else
-            #define DRWAV_API  DRWAV_DLL_IMPORT
-        #endif
-        #define DRWAV_PRIVATE DRWAV_DLL_PRIVATE
-    #else
-        #define DRWAV_API extern
-        #define DRWAV_PRIVATE static
-    #endif
-#endif
-
-typedef drwav_int32 drwav_result;
-#define DRWAV_SUCCESS                        0
-#define DRWAV_ERROR                         -1   /* A generic error. */
-#define DRWAV_INVALID_ARGS                  -2
-#define DRWAV_INVALID_OPERATION             -3
-#define DRWAV_OUT_OF_MEMORY                 -4
-#define DRWAV_OUT_OF_RANGE                  -5
-#define DRWAV_ACCESS_DENIED                 -6
-#define DRWAV_DOES_NOT_EXIST                -7
-#define DRWAV_ALREADY_EXISTS                -8
-#define DRWAV_TOO_MANY_OPEN_FILES           -9
-#define DRWAV_INVALID_FILE                  -10
-#define DRWAV_TOO_BIG                       -11
-#define DRWAV_PATH_TOO_LONG                 -12
-#define DRWAV_NAME_TOO_LONG                 -13
-#define DRWAV_NOT_DIRECTORY                 -14
-#define DRWAV_IS_DIRECTORY                  -15
-#define DRWAV_DIRECTORY_NOT_EMPTY           -16
-#define DRWAV_END_OF_FILE                   -17
-#define DRWAV_NO_SPACE                      -18
-#define DRWAV_BUSY                          -19
-#define DRWAV_IO_ERROR                      -20
-#define DRWAV_INTERRUPT                     -21
-#define DRWAV_UNAVAILABLE                   -22
-#define DRWAV_ALREADY_IN_USE                -23
-#define DRWAV_BAD_ADDRESS                   -24
-#define DRWAV_BAD_SEEK                      -25
-#define DRWAV_BAD_PIPE                      -26
-#define DRWAV_DEADLOCK                      -27
-#define DRWAV_TOO_MANY_LINKS                -28
-#define DRWAV_NOT_IMPLEMENTED               -29
-#define DRWAV_NO_MESSAGE                    -30
-#define DRWAV_BAD_MESSAGE                   -31
-#define DRWAV_NO_DATA_AVAILABLE             -32
-#define DRWAV_INVALID_DATA                  -33
-#define DRWAV_TIMEOUT                       -34
-#define DRWAV_NO_NETWORK                    -35
-#define DRWAV_NOT_UNIQUE                    -36
-#define DRWAV_NOT_SOCKET                    -37
-#define DRWAV_NO_ADDRESS                    -38
-#define DRWAV_BAD_PROTOCOL                  -39
-#define DRWAV_PROTOCOL_UNAVAILABLE          -40
-#define DRWAV_PROTOCOL_NOT_SUPPORTED        -41
-#define DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRWAV_SOCKET_NOT_SUPPORTED          -44
-#define DRWAV_CONNECTION_RESET              -45
-#define DRWAV_ALREADY_CONNECTED             -46
-#define DRWAV_NOT_CONNECTED                 -47
-#define DRWAV_CONNECTION_REFUSED            -48
-#define DRWAV_NO_HOST                       -49
-#define DRWAV_IN_PROGRESS                   -50
-#define DRWAV_CANCELLED                     -51
-#define DRWAV_MEMORY_ALREADY_MAPPED         -52
-#define DRWAV_AT_END                        -53
-
-/* Common data formats. */
-#define DR_WAVE_FORMAT_PCM          0x1
-#define DR_WAVE_FORMAT_ADPCM        0x2
-#define DR_WAVE_FORMAT_IEEE_FLOAT   0x3
-#define DR_WAVE_FORMAT_ALAW         0x6
-#define DR_WAVE_FORMAT_MULAW        0x7
-#define DR_WAVE_FORMAT_DVI_ADPCM    0x11
-#define DR_WAVE_FORMAT_EXTENSIBLE   0xFFFE
-
-/* Constants. */
-#ifndef DRWAV_MAX_SMPL_LOOPS
-#define DRWAV_MAX_SMPL_LOOPS        1
-#endif
-
-/* Flags to pass into drwav_init_ex(), etc. */
-#define DRWAV_SEQUENTIAL            0x00000001
-
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision);
-DRWAV_API const char* drwav_version_string(void);
-
-typedef enum
-{
-    drwav_seek_origin_start,
-    drwav_seek_origin_current
-} drwav_seek_origin;
-
-typedef enum
-{
-    drwav_container_riff,
-    drwav_container_w64,
-    drwav_container_rf64
-} drwav_container;
-
-typedef struct
-{
-    union
-    {
-        drwav_uint8 fourcc[4];
-        drwav_uint8 guid[16];
-    } id;
-
-    /* The size in bytes of the chunk. */
-    drwav_uint64 sizeInBytes;
-
-    /*
-    RIFF = 2 byte alignment.
-    W64  = 8 byte alignment.
-    */
-    unsigned int paddingSize;
-} drwav_chunk_header;
-
-typedef struct
-{
-    /*
-    The format tag exactly as specified in the wave file's "fmt" chunk. This can be used by applications
-    that require support for data formats not natively supported by dr_wav.
-    */
-    drwav_uint16 formatTag;
-
-    /* The number of channels making up the audio data. When this is set to 1 it is mono, 2 is stereo, etc. */
-    drwav_uint16 channels;
-
-    /* The sample rate. Usually set to something like 44100. */
-    drwav_uint32 sampleRate;
-
-    /* Average bytes per second. You probably don't need this, but it's left here for informational purposes. */
-    drwav_uint32 avgBytesPerSec;
-
-    /* Block align. This is equal to the number of channels * bytes per sample. */
-    drwav_uint16 blockAlign;
-
-    /* Bits per sample. */
-    drwav_uint16 bitsPerSample;
-
-    /* The size of the extended data. Only used internally for validation, but left here for informational purposes. */
-    drwav_uint16 extendedSize;
-
-    /*
-    The number of valid bits per sample. When <formatTag> is equal to WAVE_FORMAT_EXTENSIBLE, <bitsPerSample>
-    is always rounded up to the nearest multiple of 8. This variable contains information about exactly how
-    many bits are valid per sample. Mainly used for informational purposes.
-    */
-    drwav_uint16 validBitsPerSample;
-
-    /* The channel mask. Not used at the moment. */
-    drwav_uint32 channelMask;
-
-    /* The sub-format, exactly as specified by the wave file. */
-    drwav_uint8 subFormat[16];
-} drwav_fmt;
-
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT);
-
-
-/*
-Callback for when data is read. Return value is the number of bytes actually read.
-
-pUserData   [in]  The user data that was passed to drwav_init() and family.
-pBufferOut  [out] The output buffer.
-bytesToRead [in]  The number of bytes to read.
-
-Returns the number of bytes actually read.
-
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
-either the entire bytesToRead is filled or you have reached the end of the stream.
-*/
-typedef size_t (* drwav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data is written. Returns value is the number of bytes actually written.
-
-pUserData    [in]  The user data that was passed to drwav_init_write() and family.
-pData        [out] A pointer to the data to write.
-bytesToWrite [in]  The number of bytes to write.
-
-Returns the number of bytes actually written.
-
-If the return value differs from bytesToWrite, it indicates an error.
-*/
-typedef size_t (* drwav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite);
-
-/*
-Callback for when data needs to be seeked.
-
-pUserData [in] The user data that was passed to drwav_init() and family.
-offset    [in] The number of bytes to move, relative to the origin. Will never be negative.
-origin    [in] The origin of the seek - the current position or the start of the stream.
-
-Returns whether or not the seek was successful.
-
-Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be either drwav_seek_origin_start or
-drwav_seek_origin_current.
-*/
-typedef drwav_bool32 (* drwav_seek_proc)(void* pUserData, int offset, drwav_seek_origin origin);
-
-/*
-Callback for when drwav_init_ex() finds a chunk.
-
-pChunkUserData    [in] The user data that was passed to the pChunkUserData parameter of drwav_init_ex() and family.
-onRead            [in] A pointer to the function to call when reading.
-onSeek            [in] A pointer to the function to call when seeking.
-pReadSeekUserData [in] The user data that was passed to the pReadSeekUserData parameter of drwav_init_ex() and family.
-pChunkHeader      [in] A pointer to an object containing basic header information about the chunk. Use this to identify the chunk.
-container         [in] Whether or not the WAV file is a RIFF or Wave64 container. If you're unsure of the difference, assume RIFF.
-pFMT              [in] A pointer to the object containing the contents of the "fmt" chunk.
-
-Returns the number of bytes read + seeked.
-
-To read data from the chunk, call onRead(), passing in pReadSeekUserData as the first parameter. Do the same for seeking with onSeek(). The return value must
-be the total number of bytes you have read _plus_ seeked.
-
-Use the `container` argument to discriminate the fields in `pChunkHeader->id`. If the container is `drwav_container_riff` or `drwav_container_rf64` you should
-use `id.fourcc`, otherwise you should use `id.guid`.
-
-The `pFMT` parameter can be used to determine the data format of the wave file. Use `drwav_fmt_get_format()` to get the sample format, which will be one of the
-`DR_WAVE_FORMAT_*` identifiers. 
-
-The read pointer will be sitting on the first byte after the chunk's header. You must not attempt to read beyond the boundary of the chunk.
-*/
-typedef drwav_uint64 (* drwav_chunk_proc)(void* pChunkUserData, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_chunk_header* pChunkHeader, drwav_container container, const drwav_fmt* pFMT);
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drwav_allocation_callbacks;
-
-/* Structure for internal use. Only used for loaders opened with drwav_init_memory(). */
-typedef struct
-{
-    const drwav_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drwav__memory_stream;
-
-/* Structure for internal use. Only used for writers opened with drwav_init_memory_write(). */
-typedef struct
-{
-    void** ppData;
-    size_t* pDataSize;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t currentWritePos;
-} drwav__memory_stream_write;
-
-typedef struct
-{
-    drwav_container container;  /* RIFF, W64. */
-    drwav_uint32 format;        /* DR_WAVE_FORMAT_* */
-    drwav_uint32 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 bitsPerSample;
-} drwav_data_format;
-
-
-/* See the following for details on the 'smpl' chunk: https://sites.google.com/site/musicgapi/technical-documents/wav-file-format#smpl */
-typedef struct
-{
-    drwav_uint32 cuePointId;
-    drwav_uint32 type;
-    drwav_uint32 start;
-    drwav_uint32 end;
-    drwav_uint32 fraction;
-    drwav_uint32 playCount;
-} drwav_smpl_loop;
-
- typedef struct
-{
-    drwav_uint32 manufacturer;
-    drwav_uint32 product;
-    drwav_uint32 samplePeriod;
-    drwav_uint32 midiUnityNotes;
-    drwav_uint32 midiPitchFraction;
-    drwav_uint32 smpteFormat;
-    drwav_uint32 smpteOffset;
-    drwav_uint32 numSampleLoops;
-    drwav_uint32 samplerData;
-    drwav_smpl_loop loops[DRWAV_MAX_SMPL_LOOPS];
-} drwav_smpl;
-
-typedef struct
-{
-    /* A pointer to the function to call when more data is needed. */
-    drwav_read_proc onRead;
-
-    /* A pointer to the function to call when data needs to be written. Only used when the drwav object is opened in write mode. */
-    drwav_write_proc onWrite;
-
-    /* A pointer to the function to call when the wav file needs to be seeked. */
-    drwav_seek_proc onSeek;
-
-    /* The user data to pass to callbacks. */
-    void* pUserData;
-
-    /* Allocation callbacks. */
-    drwav_allocation_callbacks allocationCallbacks;
-
-
-    /* Whether or not the WAV file is formatted as a standard RIFF file or W64. */
-    drwav_container container;
-
-
-    /* Structure containing format information exactly as specified by the wav file. */
-    drwav_fmt fmt;
-
-    /* The sample rate. Will be set to something like 44100. */
-    drwav_uint32 sampleRate;
-
-    /* The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. */
-    drwav_uint16 channels;
-
-    /* The bits per sample. Will be set to something like 16, 24, etc. */
-    drwav_uint16 bitsPerSample;
-
-    /* Equal to fmt.formatTag, or the value specified by fmt.subFormat if fmt.formatTag is equal to 65534 (WAVE_FORMAT_EXTENSIBLE). */
-    drwav_uint16 translatedFormatTag;
-
-    /* The total number of PCM frames making up the audio data. */
-    drwav_uint64 totalPCMFrameCount;
-
-
-    /* The size in bytes of the data chunk. */
-    drwav_uint64 dataChunkDataSize;
-    
-    /* The position in the stream of the first data byte of the data chunk. This is used for seeking. */
-    drwav_uint64 dataChunkDataPos;
-
-    /* The number of bytes remaining in the data chunk. */
-    drwav_uint64 bytesRemaining;
-
-
-    /*
-    Only used in sequential write mode. Keeps track of the desired size of the "data" chunk at the point of initialization time. Always
-    set to 0 for non-sequential writes and when the drwav object is opened in read mode. Used for validation.
-    */
-    drwav_uint64 dataChunkDataSizeTargetWrite;
-
-    /* Keeps track of whether or not the wav writer was initialized in sequential mode. */
-    drwav_bool32 isSequentialWrite;
-
-
-    /* smpl chunk. */
-    drwav_smpl smpl;
-
-
-    /* A hack to avoid a DRWAV_MALLOC() when opening a decoder with drwav_init_memory(). */
-    drwav__memory_stream memoryStream;
-    drwav__memory_stream_write memoryStreamWrite;
-
-    /* Generic data for compressed formats. This data is shared across all block-compressed formats. */
-    struct
-    {
-        drwav_uint64 iCurrentPCMFrame;  /* The index of the next PCM frame that will be read by drwav_read_*(). This is used with "totalPCMFrameCount" to ensure we don't read excess samples at the end of the last block. */
-    } compressed;
-    
-    /* Microsoft ADPCM specific data. */
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_uint16 predictor[2];
-        drwav_int32  delta[2];
-        drwav_int32  cachedFrames[4];  /* Samples are stored in this cache during decoding. */
-        drwav_uint32 cachedFrameCount;
-        drwav_int32  prevFrames[2][2]; /* The previous 2 samples for each channel (2 channels at most). */
-    } msadpcm;
-
-    /* IMA ADPCM specific data. */
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_int32  predictor[2];
-        drwav_int32  stepIndex[2];
-        drwav_int32  cachedFrames[16]; /* Samples are stored in this cache during decoding. */
-        drwav_uint32 cachedFrameCount;
-    } ima;
-} drwav;
-
-
-/*
-Initializes a pre-allocated drwav object for reading.
-
-pWav                         [out]          A pointer to the drwav object being initialized.
-onRead                       [in]           The function to call when data needs to be read from the client.
-onSeek                       [in]           The function to call when the read position of the client data needs to move.
-onChunk                      [in, optional] The function to call when a chunk is enumerated at initialized time.
-pUserData, pReadSeekUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
-pChunkUserData               [in, optional] A pointer to application defined data that will be passed to onChunk.
-flags                        [in, optional] A set of flags for controlling how things are loaded.
-
-Returns true if successful; false otherwise.
-
-Close the loader with drwav_uninit().
-
-This is the lowest level function for initializing a WAV file. You can also use drwav_init_file() and drwav_init_memory()
-to open the stream from a file or from a block of memory respectively.
-
-Possible values for flags:
-  DRWAV_SEQUENTIAL: Never perform a backwards seek while loading. This disables the chunk callback and will cause this function
-                    to return as soon as the data chunk is found. Any chunks after the data chunk will be ignored.
-
-drwav_init() is equivalent to "drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0);".
-
-The onChunk callback is not called for the WAVE or FMT chunks. The contents of the FMT chunk can be read from pWav->fmt
-after the function returns.
-
-See also: drwav_init_file(), drwav_init_memory(), drwav_uninit()
-*/
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Initializes a pre-allocated drwav object for writing.
-
-onWrite   [in]           The function to call when data needs to be written.
-onSeek    [in]           The function to call when the write position needs to move.
-pUserData [in, optional] A pointer to application defined data that will be passed to onWrite and onSeek.
-
-Returns true if successful; false otherwise.
-
-Close the writer with drwav_uninit().
-
-This is the lowest level function for initializing a WAV file. You can also use drwav_init_file_write() and drwav_init_memory_write()
-to open the stream from a file or from a block of memory respectively.
-
-If the total sample count is known, you can use drwav_init_write_sequential(). This avoids the need for dr_wav to perform
-a post-processing step for storing the total sample count and the size of the data chunk which requires a backwards seek.
-
-See also: drwav_init_file_write(), drwav_init_memory_write(), drwav_uninit()
-*/
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Utility function to determine the target size of the entire data to be written (including all headers and chunks).
-
-Returns the target size in bytes.
-
-Useful if the application needs to know the size to allocate.
-
-Only writing to the RIFF chunk and one data chunk is currently supported.
-
-See also: drwav_init_write(), drwav_init_file_write(), drwav_init_memory_write()
-*/
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-
-/*
-Uninitializes the given drwav object.
-
-Use this only for objects initialized with drwav_init*() functions (drwav_init(), drwav_init_ex(), drwav_init_write(), drwav_init_write_sequential()).
-*/
-DRWAV_API drwav_result drwav_uninit(drwav* pWav);
-
-
-/*
-Reads raw audio data.
-
-This is the lowest level function for reading audio data. It simply reads the given number of
-bytes of the raw internal sample data.
-
-Consider using drwav_read_pcm_frames_s16(), drwav_read_pcm_frames_s32() or drwav_read_pcm_frames_f32() for
-reading sample data in a consistent format.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of bytes actually read.
-*/
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut);
-
-/*
-Reads up to the specified number of PCM frames from the WAV file.
-
-The output data will be in the file's internal format, converted to native-endian byte order. Use
-drwav_read_pcm_frames_s16/f32/s32() to read data in a specific format.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached or
-you have requested more PCM frames than can possibly fit in the output buffer.
-
-This function will only work when sample data is of a fixed size and uncompressed. If you are
-using a compressed format consider using drwav_read_raw() or drwav_read_pcm_frames_s16/s32/f32().
-
-pBufferOut can be NULL in which case a seek will be performed.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-
-/*
-Seeks to the given PCM frame.
-
-Returns true if successful; false otherwise.
-*/
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex);
-
-
-/*
-Writes raw audio data.
-
-Returns the number of bytes actually written. If this differs from bytesToWrite, it indicates an error.
-*/
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData);
-
-/*
-Writes PCM frames.
-
-Returns the number of PCM frames written.
-
-Input samples need to be in native-endian byte order. On big-endian architectures the input data will be converted to
-little-endian. Use drwav_write_raw() to write raw audio data without performing any conversion.
-*/
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-
-
-/* Conversion Utilities */
-#ifndef DR_WAV_NO_CONVERSION_API
-
-/*
-Reads a chunk of audio data and converts it to signed 16-bit PCM samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 32-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 32-bit floating point samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-
-/*
-Reads a chunk of audio data and converts it to IEEE 32-bit floating point samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 16-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 32-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-
-/*
-Reads a chunk of audio data and converts it to signed 32-bit PCM samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 16-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 32-bit floating point samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-#endif  /* DR_WAV_NO_CONVERSION_API */
-
-
-/* High-Level Convenience Helpers */
-
-#ifndef DR_WAV_NO_STDIO
-/*
-Helper for initializing a wave file for reading using stdio.
-
-This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Helper for initializing a wave file for writing using stdio.
-
-This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif  /* DR_WAV_NO_STDIO */
-
-/*
-Helper for initializing a loader from a pre-allocated memory buffer.
-
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
-the lifetime of the drwav object.
-
-The buffer should contain the contents of the entire wave file, not just the sample data.
-*/
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Helper for initializing a writer which outputs data to a memory buffer.
-
-dr_wav will manage the memory allocations, however it is up to the caller to free the data with drwav_free().
-
-The buffer will remain allocated even after drwav_uninit() is called. The buffer should not be considered valid
-until after drwav_uninit() has been called.
-*/
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-
-#ifndef DR_WAV_NO_CONVERSION_API
-/*
-Opens and reads an entire wav file in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_STDIO
-/*
-Opens and decodes an entire wav file in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-/*
-Opens and decodes an entire wav file from a block of memory in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/* Frees data that was allocated internally by dr_wav. */
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/* Converts bytes from a wav stream to a sized type of native endian. */
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data);
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data);
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data);
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data);
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data);
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data);
-
-/* Compares a GUID for the purpose of checking the type of a Wave64 chunk. */
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16]);
-
-/* Compares a four-character-code for the purpose of checking the type of a RIFF chunk. */
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_wav_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-#ifndef dr_wav_c
-#define dr_wav_c
-
-#include <stdlib.h>
-#include <string.h> /* For memcpy(), memset() */
-#include <limits.h> /* For INT_MAX */
-
-#ifndef DR_WAV_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#endif
-
-/* Standard library stuff. */
-#ifndef DRWAV_ASSERT
-#include <assert.h>
-#define DRWAV_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRWAV_MALLOC
-#define DRWAV_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRWAV_REALLOC
-#define DRWAV_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRWAV_FREE
-#define DRWAV_FREE(p)                      free((p))
-#endif
-#ifndef DRWAV_COPY_MEMORY
-#define DRWAV_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRWAV_ZERO_MEMORY
-#define DRWAV_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRWAV_ZERO_OBJECT
-#define DRWAV_ZERO_OBJECT(p)               DRWAV_ZERO_MEMORY((p), sizeof(*p))
-#endif
-
-#define drwav_countof(x)                   (sizeof(x) / sizeof(x[0]))
-#define drwav_align(x, a)                  ((((x) + (a) - 1) / (a)) * (a))
-#define drwav_min(a, b)                    (((a) < (b)) ? (a) : (b))
-#define drwav_max(a, b)                    (((a) > (b)) ? (a) : (b))
-#define drwav_clamp(x, lo, hi)             (drwav_max((lo), drwav_min((hi), (x))))
-
-#define DRWAV_MAX_SIMD_VECTOR_SIZE         64  /* 64 for AVX-512 in the future. */
-
-/* CPU architecture. */
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRWAV_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRWAV_X86
-#elif defined(__arm__) || defined(_M_ARM)
-    #define DRWAV_ARM
-#endif
-
-#ifdef _MSC_VER
-    #define DRWAV_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRWAV_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRWAV_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRWAV_INLINE __inline
-#else
-    #define DRWAV_INLINE
-#endif
-
-#if defined(SIZE_MAX)
-    #define DRWAV_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRWAV_SIZE_MAX  ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRWAV_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRWAV_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRWAV_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRWAV_VERSION_REVISION;
-    }
-}
-
-DRWAV_API const char* drwav_version_string(void)
-{
-    return DRWAV_VERSION_STRING;
-}
-
-/*
-These limits are used for basic validation when initializing the decoder. If you exceed these limits, first of all: what on Earth are
-you doing?! (Let me know, I'd be curious!) Second, you can adjust these by #define-ing them before the dr_wav implementation.
-*/
-#ifndef DRWAV_MAX_SAMPLE_RATE
-#define DRWAV_MAX_SAMPLE_RATE       384000
-#endif
-#ifndef DRWAV_MAX_CHANNELS
-#define DRWAV_MAX_CHANNELS          256
-#endif
-#ifndef DRWAV_MAX_BITS_PER_SAMPLE
-#define DRWAV_MAX_BITS_PER_SAMPLE   64
-#endif
-
-static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00};    /* 66666972-912E-11CF-A5D6-28DB04C10000 */
-static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
-/*static const drwav_uint8 drwavGUID_W64_JUNK[16] = {0x6A,0x75,0x6E,0x6B, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};*/    /* 6B6E756A-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 74636166-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 6C706D73-ACF3-11D3-8CD1-00C04F8EDB8A */
-
-
-static DRWAV_INLINE int drwav__is_little_endian(void)
-{
-#if defined(DRWAV_X86) || defined(DRWAV_X64)
-    return DRWAV_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRWAV_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-
-static DRWAV_INLINE void drwav__bytes_to_guid(const drwav_uint8* data, drwav_uint8* guid)
-{
-    int i;
-    for (i = 0; i < 16; ++i) {
-        guid[i] = data[i];
-    }
-}
-
-
-static DRWAV_INLINE drwav_uint16 drwav__bswap16(drwav_uint16 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-
-static DRWAV_INLINE drwav_uint32 drwav__bswap32(drwav_uint32 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            drwav_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRWAV_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-static DRWAV_INLINE drwav_uint64 drwav__bswap64(drwav_uint64 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-    return ((n & ((drwav_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drwav_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drwav_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drwav_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drwav_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drwav_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drwav_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drwav_uint64)0x000000FF      )) << 56);
-#endif
-}
-
-
-static DRWAV_INLINE drwav_int16 drwav__bswap_s16(drwav_int16 n)
-{
-    return (drwav_int16)drwav__bswap16((drwav_uint16)n);
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s16(drwav_int16* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s16(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE void drwav__bswap_s24(drwav_uint8* p)
-{
-    drwav_uint8 t;
-    t = p[0];
-    p[0] = p[2];
-    p[2] = t;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s24(drwav_uint8* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        drwav_uint8* pSample = pSamples + (iSample*3);
-        drwav__bswap_s24(pSample);
-    }
-}
-
-
-static DRWAV_INLINE drwav_int32 drwav__bswap_s32(drwav_int32 n)
-{
-    return (drwav_int32)drwav__bswap32((drwav_uint32)n);
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s32(drwav_int32* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s32(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE float drwav__bswap_f32(float n)
-{
-    union {
-        drwav_uint32 i;
-        float f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap32(x.i);
-
-    return x.f;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_f32(float* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f32(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE double drwav__bswap_f64(double n)
-{
-    union {
-        drwav_uint64 i;
-        double f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap64(x.i);
-
-    return x.f;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_f64(double* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f64(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE void drwav__bswap_samples_pcm(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    /* Assumes integer PCM. Floating point PCM is done in drwav__bswap_samples_ieee(). */
-    switch (bytesPerSample)
-    {
-        case 2: /* s16, s12 (loosely packed) */
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case 3: /* s24 */
-        {
-            drwav__bswap_samples_s24((drwav_uint8*)pSamples, sampleCount);
-        } break;
-        case 4: /* s32 */
-        {
-            drwav__bswap_samples_s32((drwav_int32*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_ieee(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-    #if 0   /* Contributions welcome for f16 support. */
-        case 2: /* f16 */
-        {
-            drwav__bswap_samples_f16((drwav_float16*)pSamples, sampleCount);
-        } break;
-    #endif
-        case 4: /* f32 */
-        {
-            drwav__bswap_samples_f32((float*)pSamples, sampleCount);
-        } break;
-        case 8: /* f64 */
-        {
-            drwav__bswap_samples_f64((double*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-static DRWAV_INLINE void drwav__bswap_samples(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample, drwav_uint16 format)
-{
-    switch (format)
-    {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            drwav__bswap_samples_pcm(pSamples, sampleCount, bytesPerSample);
-        } break;
-
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            drwav__bswap_samples_ieee(pSamples, sampleCount, bytesPerSample);
-        } break;
-
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-
-DRWAV_PRIVATE void* drwav__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_MALLOC(sz);
-}
-
-DRWAV_PRIVATE void* drwav__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_REALLOC(p, sz);
-}
-
-DRWAV_PRIVATE void drwav__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRWAV_FREE(p);
-}
-
-
-DRWAV_PRIVATE void* drwav__malloc_from_callbacks(size_t sz, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-DRWAV_PRIVATE void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRWAV_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-DRWAV_PRIVATE void drwav__free_from_callbacks(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-DRWAV_PRIVATE drwav_allocation_callbacks drwav_copy_allocation_callbacks_or_defaults(const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        /* Copy. */
-        return *pAllocationCallbacks;
-    } else {
-        /* Defaults. */
-        drwav_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drwav__malloc_default;
-        allocationCallbacks.onRealloc = drwav__realloc_default;
-        allocationCallbacks.onFree    = drwav__free_default;
-        return allocationCallbacks;
-    }
-}
-
-
-static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
-{
-    return
-        formatTag == DR_WAVE_FORMAT_ADPCM ||
-        formatTag == DR_WAVE_FORMAT_DVI_ADPCM;
-}
-
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_riff(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 2);
-}
-
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_w64(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 8);
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-
-DRWAV_PRIVATE drwav_result drwav__read_chunk_header(drwav_read_proc onRead, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_chunk_header* pHeaderOut)
-{
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        drwav_uint8 sizeInBytes[4];
-
-        if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) {
-            return DRWAV_AT_END;
-        }
-
-        if (onRead(pUserData, sizeInBytes, 4) != 4) {
-            return DRWAV_INVALID_FILE;
-        }
-
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u32(sizeInBytes);
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_riff(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 8;
-    } else {
-        drwav_uint8 sizeInBytes[8];
-
-        if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) {
-            return DRWAV_AT_END;
-        }
-
-        if (onRead(pUserData, sizeInBytes, 8) != 8) {
-            return DRWAV_INVALID_FILE;
-        }
-
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u64(sizeInBytes) - 24;    /* <-- Subtract 24 because w64 includes the size of the header. */
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_w64(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 24;
-    }
-
-    return DRWAV_SUCCESS;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__seek_forward(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    drwav_uint64 bytesRemainingToSeek = offset;
-    while (bytesRemainingToSeek > 0) {
-        if (bytesRemainingToSeek > 0x7FFFFFFF) {
-            if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek -= 0x7FFFFFFF;
-        } else {
-            if (!onSeek(pUserData, (int)bytesRemainingToSeek, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek = 0;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__seek_from_start(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return onSeek(pUserData, (int)offset, drwav_seek_origin_start);
-    }
-
-    /* Larger than 32-bit seek. */
-    if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-
-    for (;;) {
-        if (offset <= 0x7FFFFFFF) {
-            return onSeek(pUserData, (int)offset, drwav_seek_origin_current);
-        }
-
-        if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        offset -= 0x7FFFFFFF;
-    }
-
-    /* Should never get here. */
-    /*return DRWAV_TRUE; */
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav__read_fmt(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_fmt* fmtOut)
-{
-    drwav_chunk_header header;
-    drwav_uint8 fmt[16];
-
-    if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-
-    /* Skip non-fmt chunks. */
-    while (((container == drwav_container_riff || container == drwav_container_rf64) && !drwav_fourcc_equal(header.id.fourcc, "fmt ")) || (container == drwav_container_w64 && !drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT))) {
-        if (!drwav__seek_forward(onSeek, header.sizeInBytes + header.paddingSize, pUserData)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.sizeInBytes + header.paddingSize;
-
-        /* Try the next header. */
-        if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    /* Validation. */
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        if (!drwav_fourcc_equal(header.id.fourcc, "fmt ")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        if (!drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT)) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    if (onRead(pUserData, fmt, sizeof(fmt)) != sizeof(fmt)) {
-        return DRWAV_FALSE;
-    }
-    *pRunningBytesReadOut += sizeof(fmt);
-
-    fmtOut->formatTag      = drwav_bytes_to_u16(fmt + 0);
-    fmtOut->channels       = drwav_bytes_to_u16(fmt + 2);
-    fmtOut->sampleRate     = drwav_bytes_to_u32(fmt + 4);
-    fmtOut->avgBytesPerSec = drwav_bytes_to_u32(fmt + 8);
-    fmtOut->blockAlign     = drwav_bytes_to_u16(fmt + 12);
-    fmtOut->bitsPerSample  = drwav_bytes_to_u16(fmt + 14);
-
-    fmtOut->extendedSize       = 0;
-    fmtOut->validBitsPerSample = 0;
-    fmtOut->channelMask        = 0;
-    memset(fmtOut->subFormat, 0, sizeof(fmtOut->subFormat));
-
-    if (header.sizeInBytes > 16) {
-        drwav_uint8 fmt_cbSize[2];
-        int bytesReadSoFar = 0;
-
-        if (onRead(pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) {
-            return DRWAV_FALSE;    /* Expecting more data. */
-        }
-        *pRunningBytesReadOut += sizeof(fmt_cbSize);
-
-        bytesReadSoFar = 18;
-
-        fmtOut->extendedSize = drwav_bytes_to_u16(fmt_cbSize);
-        if (fmtOut->extendedSize > 0) {
-            /* Simple validation. */
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                if (fmtOut->extendedSize != 22) {
-                    return DRWAV_FALSE;
-                }
-            }
-
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                drwav_uint8 fmtext[22];
-                if (onRead(pUserData, fmtext, fmtOut->extendedSize) != fmtOut->extendedSize) {
-                    return DRWAV_FALSE;    /* Expecting more data. */
-                }
-
-                fmtOut->validBitsPerSample = drwav_bytes_to_u16(fmtext + 0);
-                fmtOut->channelMask        = drwav_bytes_to_u32(fmtext + 2);
-                drwav__bytes_to_guid(fmtext + 6, fmtOut->subFormat);
-            } else {
-                if (!onSeek(pUserData, fmtOut->extendedSize, drwav_seek_origin_current)) {
-                    return DRWAV_FALSE;
-                }
-            }
-            *pRunningBytesReadOut += fmtOut->extendedSize;
-
-            bytesReadSoFar += fmtOut->extendedSize;
-        }
-
-        /* Seek past any leftover bytes. For w64 the leftover will be defined based on the chunk size. */
-        if (!onSeek(pUserData, (int)(header.sizeInBytes - bytesReadSoFar), drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += (header.sizeInBytes - bytesReadSoFar);
-    }
-
-    if (header.paddingSize > 0) {
-        if (!onSeek(pUserData, header.paddingSize, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.paddingSize;
-    }
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_PRIVATE size_t drwav__on_read(drwav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
-{
-    size_t bytesRead;
-
-    DRWAV_ASSERT(onRead != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-
-    bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
-    *pCursor += bytesRead;
-    return bytesRead;
-}
-
-#if 0
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek(drwav_seek_proc onSeek, void* pUserData, int offset, drwav_seek_origin origin, drwav_uint64* pCursor)
-{
-    DRWAV_ASSERT(onSeek != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-
-    if (!onSeek(pUserData, offset, origin)) {
-        return DRWAV_FALSE;
-    }
-
-    if (origin == drwav_seek_origin_start) {
-        *pCursor = offset;
-    } else {
-        *pCursor += offset;
-    }
-
-    return DRWAV_TRUE;
-}
-#endif
-
-
-
-DRWAV_PRIVATE drwav_uint32 drwav_get_bytes_per_pcm_frame(drwav* pWav)
-{
-    /*
-    The bytes per frame is a bit ambiguous. It can be either be based on the bits per sample, or the block align. The way I'm doing it here
-    is that if the bits per sample is a multiple of 8, use floor(bitsPerSample*channels/8), otherwise fall back to the block align.
-    */
-    if ((pWav->bitsPerSample & 0x7) == 0) {
-        /* Bits per sample is a multiple of 8. */
-        return (pWav->bitsPerSample * pWav->fmt.channels) >> 3;
-    } else {
-        return pWav->fmt.blockAlign;
-    }
-}
-
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT)
-{
-    if (pFMT == NULL) {
-        return 0;
-    }
-
-    if (pFMT->formatTag != DR_WAVE_FORMAT_EXTENSIBLE) {
-        return pFMT->formatTag;
-    } else {
-        return drwav_bytes_to_u16(pFMT->subFormat);    /* Only the first two bytes are required. */
-    }
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_preinit(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onRead == NULL || onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onRead    = onRead;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pReadSeekUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags)
-{
-    /* This function assumes drwav_preinit() has been called beforehand. */
-
-    drwav_uint64 cursor;    /* <-- Keeps track of the byte position so we can seek to specific locations. */
-    drwav_bool32 sequential;
-    drwav_uint8 riff[4];
-    drwav_fmt fmt;
-    unsigned short translatedFormatTag;
-    drwav_bool32 foundDataChunk;
-    drwav_uint64 dataChunkSize = 0; /* <-- Important! Don't explicitly set this to 0 anywhere else. Calculation of the size of the data chunk is performed in different paths depending on the container. */
-    drwav_uint64 sampleCountFromFactChunk = 0;  /* Same as dataChunkSize - make sure this is the only place this is initialized to 0. */
-    drwav_uint64 chunkSize;
-
-    cursor = 0;
-    sequential = (flags & DRWAV_SEQUENTIAL) != 0;
-
-    /* The first 4 bytes should be the RIFF identifier. */
-    if (drwav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) {
-        return DRWAV_FALSE;
-    }
-
-    /*
-    The first 4 bytes can be used to identify the container. For RIFF files it will start with "RIFF" and for
-    w64 it will start with "riff".
-    */
-    if (drwav_fourcc_equal(riff, "RIFF")) {
-        pWav->container = drwav_container_riff;
-    } else if (drwav_fourcc_equal(riff, "riff")) {
-        int i;
-        drwav_uint8 riff2[12];
-
-        pWav->container = drwav_container_w64;
-
-        /* Check the rest of the GUID for validity. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) {
-            return DRWAV_FALSE;
-        }
-
-        for (i = 0; i < 12; ++i) {
-            if (riff2[i] != drwavGUID_W64_RIFF[i+4]) {
-                return DRWAV_FALSE;
-            }
-        }
-    } else if (drwav_fourcc_equal(riff, "RF64")) {
-        pWav->container = drwav_container_rf64;
-    } else {
-        return DRWAV_FALSE;   /* Unknown or unsupported container. */
-    }
-
-
-    if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-        drwav_uint8 chunkSizeBytes[4];
-        drwav_uint8 wave[4];
-
-        /* RIFF/WAVE */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_bytes_to_u32(chunkSizeBytes) < 36) {
-                return DRWAV_FALSE;    /* Chunk size should always be at least 36 bytes. */
-            }
-        } else {
-            if (drwav_bytes_to_u32(chunkSizeBytes) != 0xFFFFFFFF) {
-                return DRWAV_FALSE;    /* Chunk size should always be set to -1/0xFFFFFFFF for RF64. The actual size is retrieved later. */
-            }
-        }
-
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_fourcc_equal(wave, "WAVE")) {
-            return DRWAV_FALSE;    /* Expecting "WAVE". */
-        }
-    } else {
-        drwav_uint8 chunkSizeBytes[8];
-        drwav_uint8 wave[16];
-
-        /* W64 */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-
-        if (drwav_bytes_to_u64(chunkSizeBytes) < 80) {
-            return DRWAV_FALSE;
-        }
-
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_guid_equal(wave, drwavGUID_W64_WAVE)) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    /* For RF64, the "ds64" chunk must come next, before the "fmt " chunk. */
-    if (pWav->container == drwav_container_rf64) {
-        drwav_uint8 sizeBytes[8];
-        drwav_uint64 bytesRemainingInChunk;
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_fourcc_equal(header.id.fourcc, "ds64")) {
-            return DRWAV_FALSE; /* Expecting "ds64". */
-        }
-
-        bytesRemainingInChunk = header.sizeInBytes + header.paddingSize;
-
-        /* We don't care about the size of the RIFF chunk - skip it. */
-        if (!drwav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        cursor += 8;
-
-
-        /* Next 8 bytes is the size of the "data" chunk. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        dataChunkSize = drwav_bytes_to_u64(sizeBytes);
-
-
-        /* Next 8 bytes is the same count which we would usually derived from the FACT chunk if it was available. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        sampleCountFromFactChunk = drwav_bytes_to_u64(sizeBytes);
-
-
-        /* Skip over everything else. */
-        if (!drwav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor += bytesRemainingInChunk;
-    }
-
-
-    /* The next bytes should be the "fmt " chunk. */
-    if (!drwav__read_fmt(pWav->onRead, pWav->onSeek, pWav->pUserData, pWav->container, &cursor, &fmt)) {
-        return DRWAV_FALSE;    /* Failed to read the "fmt " chunk. */
-    }
-
-    /* Basic validation. */
-    if ((fmt.sampleRate    == 0 || fmt.sampleRate    > DRWAV_MAX_SAMPLE_RATE)     ||
-        (fmt.channels      == 0 || fmt.channels      > DRWAV_MAX_CHANNELS)        ||
-        (fmt.bitsPerSample == 0 || fmt.bitsPerSample > DRWAV_MAX_BITS_PER_SAMPLE) ||
-        fmt.blockAlign == 0) {
-        return DRWAV_FALSE; /* Probably an invalid WAV file. */
-    }
-
-
-    /* Translate the internal format. */
-    translatedFormatTag = fmt.formatTag;
-    if (translatedFormatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-        translatedFormatTag = drwav_bytes_to_u16(fmt.subFormat + 0);
-    }
-
-
-    /*
-    We need to enumerate over each chunk for two reasons:
-      1) The "data" chunk may not be the next one
-      2) We may want to report each chunk back to the client
-    
-    In order to correctly report each chunk back to the client we will need to keep looping until the end of the file.
-    */
-    foundDataChunk = DRWAV_FALSE;
-
-    /* The next chunk we care about is the "data" chunk. This is not necessarily the next chunk so we'll need to loop. */
-    for (;;)
-    {
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            if (!foundDataChunk) {
-                return DRWAV_FALSE;
-            } else {
-                break;  /* Probably at the end of the file. Get out of the loop. */
-            }
-        }
-
-        /* Tell the client about this chunk. */
-        if (!sequential && onChunk != NULL) {
-            drwav_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt);
-
-            /*
-            dr_wav may need to read the contents of the chunk, so we now need to seek back to the position before
-            we called the callback.
-            */
-            if (callbackBytesRead > 0) {
-                if (!drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData)) {
-                    return DRWAV_FALSE;
-                }
-            }
-        }
-        
-
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-
-        chunkSize = header.sizeInBytes;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "data")) {
-                foundDataChunk = DRWAV_TRUE;
-                if (pWav->container != drwav_container_rf64) {  /* The data chunk size for RF64 will always be set to 0xFFFFFFFF here. It was set to it's true value earlier. */
-                    dataChunkSize = chunkSize;
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA)) {
-                foundDataChunk = DRWAV_TRUE;
-                dataChunkSize = chunkSize;
-            }
-        }
-
-        /*
-        If at this point we have found the data chunk and we're running in sequential mode, we need to break out of this loop. The reason for
-        this is that we would otherwise require a backwards seek which sequential mode forbids.
-        */
-        if (foundDataChunk && sequential) {
-            break;
-        }
-
-        /* Optional. Get the total sample count from the FACT chunk. This is useful for compressed formats. */
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_fourcc_equal(header.id.fourcc, "fact")) {
-                drwav_uint32 sampleCount;
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 4;
-
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-
-                /*
-                The sample count in the "fact" chunk is either unreliable, or I'm not understanding it properly. For now I am only enabling this
-                for Microsoft ADPCM formats.
-                */
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    sampleCountFromFactChunk = sampleCount;
-                } else {
-                    sampleCountFromFactChunk = 0;
-                }
-            }
-        } else if (pWav->container == drwav_container_w64) {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_FACT)) {
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 8;
-
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-            }
-        } else if (pWav->container == drwav_container_rf64) {
-            /* We retrieved the sample count from the ds64 chunk earlier so no need to do that here. */
-        }
-
-        /* "smpl" chunk. */
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "smpl")) {
-                drwav_uint8 smplHeaderData[36];    /* 36 = size of the smpl header section, not including the loop data. */
-                if (chunkSize >= sizeof(smplHeaderData)) {
-                    drwav_uint64 bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplHeaderData, sizeof(smplHeaderData), &cursor);
-                    chunkSize -= bytesJustRead;
-
-                    if (bytesJustRead == sizeof(smplHeaderData)) {
-                        drwav_uint32 iLoop;
-
-                        pWav->smpl.manufacturer      = drwav_bytes_to_u32(smplHeaderData+0);
-                        pWav->smpl.product           = drwav_bytes_to_u32(smplHeaderData+4);
-                        pWav->smpl.samplePeriod      = drwav_bytes_to_u32(smplHeaderData+8);
-                        pWav->smpl.midiUnityNotes    = drwav_bytes_to_u32(smplHeaderData+12);
-                        pWav->smpl.midiPitchFraction = drwav_bytes_to_u32(smplHeaderData+16);
-                        pWav->smpl.smpteFormat       = drwav_bytes_to_u32(smplHeaderData+20);
-                        pWav->smpl.smpteOffset       = drwav_bytes_to_u32(smplHeaderData+24);
-                        pWav->smpl.numSampleLoops    = drwav_bytes_to_u32(smplHeaderData+28);
-                        pWav->smpl.samplerData       = drwav_bytes_to_u32(smplHeaderData+32);
-
-                        for (iLoop = 0; iLoop < pWav->smpl.numSampleLoops && iLoop < drwav_countof(pWav->smpl.loops); ++iLoop) {
-                            drwav_uint8 smplLoopData[24];  /* 24 = size of a loop section in the smpl chunk. */
-                            bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplLoopData, sizeof(smplLoopData), &cursor);
-                            chunkSize -= bytesJustRead;
-
-                            if (bytesJustRead == sizeof(smplLoopData)) {
-                                pWav->smpl.loops[iLoop].cuePointId = drwav_bytes_to_u32(smplLoopData+0);
-                                pWav->smpl.loops[iLoop].type       = drwav_bytes_to_u32(smplLoopData+4);
-                                pWav->smpl.loops[iLoop].start      = drwav_bytes_to_u32(smplLoopData+8);
-                                pWav->smpl.loops[iLoop].end        = drwav_bytes_to_u32(smplLoopData+12);
-                                pWav->smpl.loops[iLoop].fraction   = drwav_bytes_to_u32(smplLoopData+16);
-                                pWav->smpl.loops[iLoop].playCount  = drwav_bytes_to_u32(smplLoopData+20);
-                            } else {
-                                break;  /* Break from the smpl loop for loop. */
-                            }
-                        }
-                    }
-                } else {
-                    /* Looks like invalid data. Ignore the chunk. */
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_SMPL)) {
-                /*
-                This path will be hit when a W64 WAV file contains a smpl chunk. I don't have a sample file to test this path, so a contribution
-                is welcome to add support for this.
-                */
-            }
-        }
-
-        /* Make sure we seek past the padding. */
-        chunkSize += header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData)) {
-            break;
-        }
-        cursor += chunkSize;
-
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-    }
-
-    /* If we haven't found a data chunk, return an error. */
-    if (!foundDataChunk) {
-        return DRWAV_FALSE;
-    }
-
-    /* We may have moved passed the data chunk. If so we need to move back. If running in sequential mode we can assume we are already sitting on the data chunk. */
-    if (!sequential) {
-        if (!drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor = pWav->dataChunkDataPos;
-    }
-    
-
-    /* At this point we should be sitting on the first byte of the raw audio data. */
-
-    pWav->fmt                 = fmt;
-    pWav->sampleRate          = fmt.sampleRate;
-    pWav->channels            = fmt.channels;
-    pWav->bitsPerSample       = fmt.bitsPerSample;
-    pWav->bytesRemaining      = dataChunkSize;
-    pWav->translatedFormatTag = translatedFormatTag;
-    pWav->dataChunkDataSize   = dataChunkSize;
-
-    if (sampleCountFromFactChunk != 0) {
-        pWav->totalPCMFrameCount = sampleCountFromFactChunk;
-    } else {
-        pWav->totalPCMFrameCount = dataChunkSize / drwav_get_bytes_per_pcm_frame(pWav);
-
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-
-            /* Make sure any trailing partial block is accounted for. */
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-
-            /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
-            totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-        }
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-
-            /* Make sure any trailing partial block is accounted for. */
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-
-            /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
-            totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-
-            /* The header includes a decoded sample for each channel which acts as the initial predictor sample. */
-            pWav->totalPCMFrameCount += blockCount;
-        }
-    }
-
-    /* Some formats only support a certain number of channels. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        if (pWav->channels > 2) {
-            return DRWAV_FALSE;
-        }
-    }
-
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    /*
-    I use libsndfile as a benchmark for testing, however in the version I'm using (from the Windows installer on the libsndfile website),
-    it appears the total sample count libsndfile uses for MS-ADPCM is incorrect. It would seem they are computing the total sample count
-    from the number of blocks, however this results in the inclusion of extra silent samples at the end of the last block. The correct
-    way to know the total sample count is to inspect the "fact" chunk, which should always be present for compressed formats, and should
-    always include the sample count. This little block of code below is only used to emulate the libsndfile logic so I can properly run my
-    correctness tests against libsndfile, and is disabled by default.
-    */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels;  /* x2 because two samples per byte. */
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels;
-    }
-#endif
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-
-
-DRWAV_PRIVATE drwav_uint32 drwav__riff_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 24 = "fmt " chunk. */
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-
-    return (drwav_uint32)chunkSize; /* Safe cast due to the clamp above. */
-}
-
-DRWAV_PRIVATE drwav_uint32 drwav__data_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    if (dataChunkSize <= 0xFFFFFFFFUL) {
-        return (drwav_uint32)dataChunkSize;
-    } else {
-        return 0xFFFFFFFFUL;
-    }
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 dataSubchunkPaddingSize = drwav__chunk_padding_size_w64(dataChunkSize);
-
-    return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize;   /* +24 because W64 includes the size of the GUID and size fields. */
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    return 24 + dataChunkSize;        /* +24 because W64 includes the size of the GUID and size fields. */
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 36 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 36 = "ds64" chunk. 24 = "fmt " chunk. */
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-
-    return chunkSize;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    return dataChunkSize;
-}
-
-
-DRWAV_PRIVATE size_t drwav__write(drwav* pWav, const void* pData, size_t dataSize)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    /* Generic write. Assumes no byte reordering required. */
-    return pWav->onWrite(pWav->pUserData, pData, dataSize);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u16ne_to_le(drwav* pWav, drwav_uint16 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap16(value);
-    }
-
-    return drwav__write(pWav, &value, 2);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u32ne_to_le(drwav* pWav, drwav_uint32 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap32(value);
-    }
-
-    return drwav__write(pWav, &value, 4);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u64ne_to_le(drwav* pWav, drwav_uint64 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap64(value);
-    }
-
-    return drwav__write(pWav, &value, 8);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_preinit_write(drwav* pWav, const drwav_data_format* pFormat, drwav_bool32 isSequential, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onWrite == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    if (!isSequential && onSeek == NULL) {
-        return DRWAV_FALSE; /* <-- onSeek is required when in non-sequential mode. */
-    }
-
-    /* Not currently supporting compressed formats. Will need to add support for the "fact" chunk before we enable this. */
-    if (pFormat->format == DR_WAVE_FORMAT_EXTENSIBLE) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_ADPCM || pFormat->format == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return DRWAV_FALSE;
-    }
-
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onWrite   = onWrite;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    pWav->fmt.formatTag = (drwav_uint16)pFormat->format;
-    pWav->fmt.channels = (drwav_uint16)pFormat->channels;
-    pWav->fmt.sampleRate = pFormat->sampleRate;
-    pWav->fmt.avgBytesPerSec = (drwav_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8);
-    pWav->fmt.blockAlign = (drwav_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8);
-    pWav->fmt.bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->fmt.extendedSize = 0;
-    pWav->isSequentialWrite = isSequential;
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    /* The function assumes drwav_preinit_write() was called beforehand. */
-
-    size_t runningPos = 0;
-    drwav_uint64 initialDataChunkSize = 0;
-    drwav_uint64 chunkSizeFMT;
-
-    /*
-    The initial values for the "RIFF" and "data" chunks depends on whether or not we are initializing in sequential mode or not. In
-    sequential mode we set this to its final values straight away since they can be calculated from the total sample count. In non-
-    sequential mode we initialize it all to zero and fill it out in drwav_uninit() using a backwards seek.
-    */
-    if (pWav->isSequentialWrite) {
-        initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8;
-
-        /*
-        The RIFF container has a limit on the number of samples. drwav is not allowing this. There's no practical limits for Wave64
-        so for the sake of simplicity I'm not doing any validation for that.
-        */
-        if (pFormat->container == drwav_container_riff) {
-            if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
-                return DRWAV_FALSE; /* Not enough room to store every sample. */
-            }
-        }
-    }
-
-    pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize;
-
-
-    /* "RIFF" chunk. */
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeRIFF = 28 + (drwav_uint32)initialDataChunkSize;   /* +28 = "WAVE" + [sizeof "fmt " chunk] */
-        runningPos += drwav__write(pWav, "RIFF", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize;            /* +24 because W64 includes the size of the GUID and size fields. */
-        runningPos += drwav__write(pWav, drwavGUID_W64_RIFF, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, drwavGUID_W64_WAVE, 16);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "RF64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);               /* Always 0xFFFFFFFF for RF64. Set to a proper value in the "ds64" chunk. */
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    }
-
-    
-    /* "ds64" chunk (RF64 only). */
-    if (pFormat->container == drwav_container_rf64) {
-        drwav_uint32 initialds64ChunkSize = 28;                                 /* 28 = [Size of RIFF (8 bytes)] + [Size of DATA (8 bytes)] + [Sample Count (8 bytes)] + [Table Length (4 bytes)]. Table length always set to 0. */
-        drwav_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize;    /* +8 for the ds64 header. */
-
-        runningPos += drwav__write(pWav, "ds64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, initialds64ChunkSize);     /* Size of ds64. */
-        runningPos += drwav__write_u64ne_to_le(pWav, initialRiffChunkSize);     /* Size of RIFF. Set to true value at the end. */
-        runningPos += drwav__write_u64ne_to_le(pWav, initialDataChunkSize);     /* Size of DATA. Set to true value at the end. */
-        runningPos += drwav__write_u64ne_to_le(pWav, totalSampleCount);         /* Sample count. */
-        runningPos += drwav__write_u32ne_to_le(pWav, 0);                        /* Table length. Always set to zero in our case since we're not doing any other chunks than "DATA". */
-    }
-
-
-    /* "fmt " chunk. */
-    if (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64) {
-        chunkSizeFMT = 16;
-        runningPos += drwav__write(pWav, "fmt ", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, (drwav_uint32)chunkSizeFMT);
-    } else if (pFormat->container == drwav_container_w64) {
-        chunkSizeFMT = 40;
-        runningPos += drwav__write(pWav, drwavGUID_W64_FMT, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeFMT);
-    }
-
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.formatTag);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.channels);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
-
-    /* "data" chunk. */
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize;     /* +24 because W64 includes the size of the GUID and size fields. */
-        runningPos += drwav__write(pWav, drwavGUID_W64_DATA, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);   /* Always set to 0xFFFFFFFF for RF64. The true size of the data chunk is specified in the ds64 chunk. */
-    }
-
-    /* Set some properties for the client's convenience. */
-    pWav->container = pFormat->container;
-    pWav->channels = (drwav_uint16)pFormat->channels;
-    pWav->sampleRate = pFormat->sampleRate;
-    pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
-    pWav->dataChunkDataPos = runningPos;
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write__internal(pWav, pFormat, 0);               /* DRWAV_FALSE = Not Sequential */
-}
-
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount); /* DRWAV_TRUE = Sequential */
-}
-
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    /* Casting totalSampleCount to drwav_int64 for VC6 compatibility. No issues in practice because nobody is going to exhaust the whole 63 bits. */
-    drwav_uint64 targetDataSizeBytes = (drwav_uint64)((drwav_int64)totalSampleCount * pFormat->channels * pFormat->bitsPerSample/8.0);
-    drwav_uint64 riffChunkSizeBytes;
-    drwav_uint64 fileSizeBytes = 0;
-
-    if (pFormat->container == drwav_container_riff) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_riff(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);   /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
-    } else if (pFormat->container == drwav_container_w64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_w64(targetDataSizeBytes);
-        fileSizeBytes = riffChunkSizeBytes;
-    } else if (pFormat->container == drwav_container_rf64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_rf64(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);   /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
-    }
-
-    return fileSizeBytes;
-}
-
-
-#ifndef DR_WAV_NO_STDIO
-
-/* drwav_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
-#include <errno.h>
-DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRWAV_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRWAV_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRWAV_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRWAV_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRWAV_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRWAV_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRWAV_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRWAV_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRWAV_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRWAV_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRWAV_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRWAV_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRWAV_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRWAV_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRWAV_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRWAV_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRWAV_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRWAV_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRWAV_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRWAV_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRWAV_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRWAV_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRWAV_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRWAV_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRWAV_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRWAV_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRWAV_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRWAV_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRWAV_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRWAV_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRWAV_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRWAV_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRWAV_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRWAV_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRWAV_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRWAV_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRWAV_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRWAV_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRWAV_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRWAV_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRWAV_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRWAV_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRWAV_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRWAV_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRWAV_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRWAV_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRWAV_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRWAV_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRWAV_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRWAV_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRWAV_ERROR;
-    #endif
-        default: return DRWAV_ERROR;
-    }
-}
-
-DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drwav_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drwav_result result = drwav_result_from_errno(errno);
-        if (result == DRWAV_SUCCESS) {
-            result = DRWAV_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRWAV_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRWAV_HAS_WFOPEN
-    #endif
-#endif
-
-DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-#if defined(DRWAV_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drwav_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drwav_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRWAV_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drwav_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drwav__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRWAV_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRWAV_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRWAV_ERROR;
-    }
-#endif
-
-    return DRWAV_SUCCESS;
-}
-
-
-DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-DRWAV_PRIVATE size_t drwav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_stdio(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drwav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFile, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-
-    result = drwav_preinit(pWav, drwav__on_read_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-
-    result = drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    result = drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "wb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-#endif  /* DR_WAV_NO_STDIO */
-
-
-DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos);
-
-    bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRWAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead);
-        pWav->memoryStream.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) {
-                return DRWAV_FALSE; /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pWav->memoryStream.currentReadPos < (size_t)-offset) {
-                return DRWAV_FALSE; /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pWav->memoryStream.currentReadPos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStream.dataSize) {
-            pWav->memoryStream.currentReadPos = offset;
-        } else {
-            return DRWAV_FALSE; /* Trying to seek too far forward. */
-        }
-    }
-    
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE size_t drwav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos);
-
-    bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos;
-    if (bytesRemaining < bytesToWrite) {
-        /* Need to reallocate. */
-        void* pNewData;
-        size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2;
-
-        /* If doubling wasn't enough, just make it the minimum required size to write the data. */
-        if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) {
-            newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite;
-        }
-
-        pNewData = drwav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks);
-        if (pNewData == NULL) {
-            return 0;
-        }
-
-        *pWav->memoryStreamWrite.ppData = pNewData;
-        pWav->memoryStreamWrite.dataCapacity = newDataCapacity;
-    }
-
-    DRWAV_COPY_MEMORY(((drwav_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite);
-
-    pWav->memoryStreamWrite.currentWritePos += bytesToWrite;
-    if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) {
-        pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos;
-    }
-
-    *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize;
-
-    return bytesToWrite;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory_write(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) {
-                offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) {
-                offset = -(int)pWav->memoryStreamWrite.currentWritePos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pWav->memoryStreamWrite.currentWritePos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStreamWrite.dataSize) {
-            pWav->memoryStreamWrite.currentWritePos = offset;
-        } else {
-            pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-    
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (data == NULL || dataSize == 0) {
-        return DRWAV_FALSE;
-    }
-
-    if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    pWav->memoryStream.data = (const drwav_uint8*)data;
-    pWav->memoryStream.dataSize = dataSize;
-    pWav->memoryStream.currentReadPos = 0;
-
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_memory_write__internal(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppData == NULL || pDataSize == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    *ppData = NULL; /* Important because we're using realloc()! */
-    *pDataSize = 0;
-
-    if (!drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_memory, drwav__on_seek_memory_write, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    pWav->memoryStreamWrite.ppData = ppData;
-    pWav->memoryStreamWrite.pDataSize = pDataSize;
-    pWav->memoryStreamWrite.dataSize = 0;
-    pWav->memoryStreamWrite.dataCapacity = 0;
-    pWav->memoryStreamWrite.currentWritePos = 0;
-
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-
-
-
-DRWAV_API drwav_result drwav_uninit(drwav* pWav)
-{
-    drwav_result result = DRWAV_SUCCESS;
-
-    if (pWav == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-    /*
-    If the drwav object was opened in write mode we'll need to finalize a few things:
-      - Make sure the "data" chunk is aligned to 16-bits for RIFF containers, or 64 bits for W64 containers.
-      - Set the size of the "data" chunk.
-    */
-    if (pWav->onWrite != NULL) {
-        drwav_uint32 paddingSize = 0;
-
-        /* Padding. Do not adjust pWav->dataChunkDataSize - this should not include the padding. */
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            paddingSize = drwav__chunk_padding_size_riff(pWav->dataChunkDataSize);
-        } else {
-            paddingSize = drwav__chunk_padding_size_w64(pWav->dataChunkDataSize);
-        }
-        
-        if (paddingSize > 0) {
-            drwav_uint64 paddingData = 0;
-            drwav__write(pWav, &paddingData, paddingSize);  /* Byte order does not matter for this. */
-        }
-
-        /*
-        Chunk sizes. When using sequential mode, these will have been filled in at initialization time. We only need
-        to do this when using non-sequential mode.
-        */
-        if (pWav->onSeek && !pWav->isSequentialWrite) {
-            if (pWav->container == drwav_container_riff) {
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, 4, drwav_seek_origin_start)) {
-                    drwav_uint32 riffChunkSize = drwav__riff_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
-                    drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_w64) {
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, 16, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_rf64) {
-                /* We only need to update the ds64 chunk. The "RIFF" and "data" chunks always have their sizes set to 0xFFFFFFFF for RF64. */
-                int ds64BodyPos = 12 + 8;
-
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            }
-        }
-
-        /* Validation for sequential mode. */
-        if (pWav->isSequentialWrite) {
-            if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
-                result = DRWAV_INVALID_FILE;
-            }
-        }
-    }
-
-#ifndef DR_WAV_NO_STDIO
-    /*
-    If we opened the file with drwav_open_file() we will want to close the file handle. We can know whether or not drwav_open_file()
-    was used by looking at the onRead and onSeek callbacks.
-    */
-    if (pWav->onRead == drwav__on_read_stdio || pWav->onWrite == drwav__on_write_stdio) {
-        fclose((FILE*)pWav->pUserData);
-    }
-#endif
-
-    return result;
-}
-
-
-
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut)
-{
-    size_t bytesRead;
-
-    if (pWav == NULL || bytesToRead == 0) {
-        return 0;
-    }
-
-    if (bytesToRead > pWav->bytesRemaining) {
-        bytesToRead = (size_t)pWav->bytesRemaining;
-    }
-
-    if (pBufferOut != NULL) {
-        bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead);
-    } else {
-        /* We need to seek. If we fail, we need to read-and-discard to make sure we get a good byte count. */
-        bytesRead = 0;
-        while (bytesRead < bytesToRead) {
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > 0x7FFFFFFF) {
-                bytesToSeek = 0x7FFFFFFF;
-            }
-
-            if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, drwav_seek_origin_current) == DRWAV_FALSE) {
-                break;
-            }
-
-            bytesRead += bytesToSeek;
-        }
-
-        /* When we get here we may need to read-and-discard some data. */
-        while (bytesRead < bytesToRead) {
-            drwav_uint8 buffer[4096];
-            size_t bytesSeeked;
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > sizeof(buffer)) {
-                bytesToSeek = sizeof(buffer);
-            }
-
-            bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek);
-            bytesRead += bytesSeeked;
-
-            if (bytesSeeked < bytesToSeek) {
-                break;  /* Reached the end. */
-            }
-        }
-    }
-
-    pWav->bytesRemaining -= bytesRead;
-    return bytesRead;
-}
-
-
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint32 bytesPerFrame;
-    drwav_uint64 bytesToRead;   /* Intentionally uint64 instead of size_t so we can do a check that we're not reading too much on 32-bit builds. */
-
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    /* Cannot use this function for compressed formats. */
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        return 0;
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    bytesToRead = framesToRead * bytesPerFrame;
-    if (bytesToRead > DRWAV_SIZE_MAX) {
-        bytesToRead = (DRWAV_SIZE_MAX / bytesPerFrame) * bytesPerFrame; /* Round the number of bytes to read to a clean frame boundary. */
-    }
-
-    /*
-    Doing an explicit check here just to make it clear that we don't want to be attempt to read anything if there's no bytes to read. There
-    *could* be a time where it evaluates to 0 due to overflowing.
-    */
-    if (bytesToRead == 0) {
-        return 0;
-    }
-
-    return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-
-    if (pBufferOut != NULL) {
-        drwav__bswap_samples(pBufferOut, framesRead*pWav->channels, drwav_get_bytes_per_pcm_frame(pWav)/pWav->channels, pWav->translatedFormatTag);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    } else {
-        return drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
-    }
-}
-
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_seek_to_first_pcm_frame(drwav* pWav)
-{
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE; /* No seeking in write mode. */
-    }
-
-    if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        pWav->compressed.iCurrentPCMFrame = 0;
-
-        /* Cached data needs to be cleared for compressed formats. */
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->msadpcm);
-        } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->ima);
-        } else {
-            DRWAV_ASSERT(DRWAV_FALSE);  /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
-        }
-    }
-    
-    pWav->bytesRemaining = pWav->dataChunkDataSize;
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
-{
-    /* Seeking should be compatible with wave files > 2GB. */
-
-    if (pWav == NULL || pWav->onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    /* No seeking in write mode. */
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-
-    /* If there are no samples, just return DRWAV_TRUE without doing anything. */
-    if (pWav->totalPCMFrameCount == 0) {
-        return DRWAV_TRUE;
-    }
-
-    /* Make sure the sample is clamped. */
-    if (targetFrameIndex >= pWav->totalPCMFrameCount) {
-        targetFrameIndex  = pWav->totalPCMFrameCount - 1;
-    }
-
-    /*
-    For compressed formats we just use a slow generic seek. If we are seeking forward we just seek forward. If we are going backwards we need
-    to seek back to the start.
-    */
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        /* TODO: This can be optimized. */
-        
-        /*
-        If we're seeking forward it's simple - just keep reading samples until we hit the sample we're requesting. If we're seeking backwards,
-        we first need to seek back to the start and then just do the same thing as a forward seek.
-        */
-        if (targetFrameIndex < pWav->compressed.iCurrentPCMFrame) {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-        }
-
-        if (targetFrameIndex > pWav->compressed.iCurrentPCMFrame) {
-            drwav_uint64 offsetInFrames = targetFrameIndex - pWav->compressed.iCurrentPCMFrame;
-
-            drwav_int16 devnull[2048];
-            while (offsetInFrames > 0) {
-                drwav_uint64 framesRead = 0;
-                drwav_uint64 framesToRead = offsetInFrames;
-                if (framesToRead > drwav_countof(devnull)/pWav->channels) {
-                    framesToRead = drwav_countof(devnull)/pWav->channels;
-                }
-
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull);
-                } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull);
-                } else {
-                    DRWAV_ASSERT(DRWAV_FALSE);  /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
-                }
-
-                if (framesRead != framesToRead) {
-                    return DRWAV_FALSE;
-                }
-
-                offsetInFrames -= framesRead;
-            }
-        }
-    } else {
-        drwav_uint64 totalSizeInBytes;
-        drwav_uint64 currentBytePos;
-        drwav_uint64 targetBytePos;
-        drwav_uint64 offset;
-
-        totalSizeInBytes = pWav->totalPCMFrameCount * drwav_get_bytes_per_pcm_frame(pWav);
-        DRWAV_ASSERT(totalSizeInBytes >= pWav->bytesRemaining);
-
-        currentBytePos = totalSizeInBytes - pWav->bytesRemaining;
-        targetBytePos  = targetFrameIndex * drwav_get_bytes_per_pcm_frame(pWav);
-
-        if (currentBytePos < targetBytePos) {
-            /* Offset forwards. */
-            offset = (targetBytePos - currentBytePos);
-        } else {
-            /* Offset backwards. */
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-            offset = targetBytePos;
-        }
-
-        while (offset > 0) {
-            int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset);
-            if (!pWav->onSeek(pWav->pUserData, offset32, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-
-            pWav->bytesRemaining -= offset32;
-            offset -= offset32;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData)
-{
-    size_t bytesWritten;
-
-    if (pWav == NULL || bytesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
-    pWav->dataChunkDataSize += bytesWritten;
-
-    return bytesWritten;
-}
-
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    const drwav_uint8* pRunningData;
-
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-
-    while (bytesToWrite > 0) {
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);  /* <-- This is checked above. */
-
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    drwav_uint32 bytesPerSample;
-    const drwav_uint8* pRunningData;
-
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-
-    bytesPerSample = drwav_get_bytes_per_pcm_frame(pWav) / pWav->channels;
-    
-    while (bytesToWrite > 0) {
-        drwav_uint8 temp[4096];
-        drwav_uint32 sampleCount;
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);  /* <-- This is checked above. */
-
-        /*
-        WAV files are always little-endian. We need to byte swap on big-endian architectures. Since our input buffer is read-only we need
-        to use an intermediary buffer for the conversion.
-        */
-        sampleCount = sizeof(temp)/bytesPerSample;
-
-        if (bytesToWriteThisIteration > ((drwav_uint64)sampleCount)*bytesPerSample) {
-            bytesToWriteThisIteration = ((drwav_uint64)sampleCount)*bytesPerSample;
-        }
-
-        DRWAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration);
-        drwav__bswap_samples(temp, sampleCount, bytesPerSample, pWav->translatedFormatTag);
-
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_write_pcm_frames_le(pWav, framesToWrite, pData);
-    } else {
-        return drwav_write_pcm_frames_be(pWav, framesToWrite, pData);
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-
-    /* TODO: Lots of room for optimization here. */
-
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
-
-        /* If there are no cached frames we need to load a new block. */
-        if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                /* Mono. */
-                drwav_uint8 header[7];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                pWav->msadpcm.predictor[0]     = header[0];
-                pWav->msadpcm.delta[0]         = drwav_bytes_to_s16(header + 1);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 3);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 5);
-                pWav->msadpcm.cachedFrames[2]  = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[3]  = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            } else {
-                /* Stereo. */
-                drwav_uint8 header[14];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                pWav->msadpcm.predictor[0] = header[0];
-                pWav->msadpcm.predictor[1] = header[1];
-                pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 2);
-                pWav->msadpcm.delta[1] = drwav_bytes_to_s16(header + 4);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 6);
-                pWav->msadpcm.prevFrames[1][1] = (drwav_int32)drwav_bytes_to_s16(header + 8);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 10);
-                pWav->msadpcm.prevFrames[1][0] = (drwav_int32)drwav_bytes_to_s16(header + 12);
-
-                pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0];
-                pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            }
-        }
-
-        /* Output anything that's cached. */
-        while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample = 0;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->msadpcm.cachedFrames[(drwav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample];
-                }
-
-                pBufferOut += pWav->channels;
-            }
-
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->msadpcm.cachedFrameCount -= 1;
-        }
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-
-        /*
-        If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
-        loop iteration which will trigger the loading of a new block.
-        */
-        if (pWav->msadpcm.cachedFrameCount == 0) {
-            if (pWav->msadpcm.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                static drwav_int32 adaptationTable[] = { 
-                    230, 230, 230, 230, 307, 409, 512, 614, 
-                    768, 614, 512, 409, 307, 230, 230, 230 
-                };
-                static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460,  392 };
-                static drwav_int32 coeff2Table[] = { 0,  -256, 0, 64,  0,  -208, -232 };
-
-                drwav_uint8 nibbles;
-                drwav_int32 nibble0;
-                drwav_int32 nibble1;
-
-                if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock -= 1;
-
-                /* TODO: Optimize away these if statements. */
-                nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
-                nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
-
-                if (pWav->channels == 1) {
-                    /* Mono. */
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-
-
-                    newSample1  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[0];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample1;
-
-
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 2;
-                } else {
-                    /* Stereo. */
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-
-                    /* Left. */
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-
-
-                    /* Right. */
-                    newSample1  = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[1];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-
-                    pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8;
-                    if (pWav->msadpcm.delta[1] < 16) {
-                        pWav->msadpcm.delta[1] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1];
-                    pWav->msadpcm.prevFrames[1][1] = newSample1;
-
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 1;
-                }
-            }
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_uint32 iChannel;
-
-    static drwav_int32 indexTable[16] = {
-        -1, -1, -1, -1, 2, 4, 6, 8,
-        -1, -1, -1, -1, 2, 4, 6, 8
-    };
-
-    static drwav_int32 stepTable[89] = {
-        7,     8,     9,     10,    11,    12,    13,    14,    16,    17, 
-        19,    21,    23,    25,    28,    31,    34,    37,    41,    45, 
-        50,    55,    60,    66,    73,    80,    88,    97,    107,   118, 
-        130,   143,   157,   173,   190,   209,   230,   253,   279,   307,
-        337,   371,   408,   449,   494,   544,   598,   658,   724,   796,
-        876,   963,   1060,  1166,  1282,  1411,  1552,  1707,  1878,  2066, 
-        2272,  2499,  2749,  3024,  3327,  3660,  4026,  4428,  4871,  5358,
-        5894,  6484,  7132,  7845,  8630,  9493,  10442, 11487, 12635, 13899, 
-        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 
-    };
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-
-    /* TODO: Lots of room for optimization here. */
-
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
-
-        /* If there are no cached samples we need to load a new block. */
-        if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                /* Mono. */
-                drwav_uint8 header[4];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                if (header[2] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead; /* Invalid data. */
-                }
-
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrameCount = 1;
-            } else {
-                /* Stereo. */
-                drwav_uint8 header[8];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                if (header[2] >= drwav_countof(stepTable) || header[6] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead; /* Invalid data. */
-                }
-
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.predictor[1] = drwav_bytes_to_s16(header + 4);
-                pWav->ima.stepIndex[1] = header[6];
-
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1];
-                pWav->ima.cachedFrameCount = 1;
-            }
-        }
-
-        /* Output anything that's cached. */
-        while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->ima.cachedFrameCount -= 1;
-        }
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-        /*
-        If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
-        loop iteration which will trigger the loading of a new block.
-        */
-        if (pWav->ima.cachedFrameCount == 0) {
-            if (pWav->ima.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                /*
-                From what I can tell with stereo streams, it looks like every 4 bytes (8 samples) is for one channel. So it goes 4 bytes for the
-                left channel, 4 bytes for the right channel.
-                */
-                pWav->ima.cachedFrameCount = 8;
-                for (iChannel = 0; iChannel < pWav->channels; ++iChannel) {
-                    drwav_uint32 iByte;
-                    drwav_uint8 nibbles[4];
-                    if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) {
-                        pWav->ima.cachedFrameCount = 0;
-                        return totalFramesRead;
-                    }
-                    pWav->ima.bytesRemainingInBlock -= 4;
-
-                    for (iByte = 0; iByte < 4; ++iByte) {
-                        drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
-                        drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
-
-                        drwav_int32 step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        drwav_int32 predictor = pWav->ima.predictor[iChannel];
-
-                        drwav_int32      diff  = step >> 3;
-                        if (nibble0 & 1) diff += step >> 2;
-                        if (nibble0 & 2) diff += step >> 1;
-                        if (nibble0 & 4) diff += step;
-                        if (nibble0 & 8) diff  = -diff;
-
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor;
-
-
-                        step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        predictor = pWav->ima.predictor[iChannel];
-
-                                         diff  = step >> 3;
-                        if (nibble1 & 1) diff += step >> 2;
-                        if (nibble1 & 2) diff += step >> 1;
-                        if (nibble1 & 4) diff += step;
-                        if (nibble1 & 8) diff  = -diff;
-
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor;
-                    }
-                }
-            }
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-#ifndef DR_WAV_NO_CONVERSION_API
-static unsigned short g_drwavAlawTable[256] = {
-    0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580, 
-    0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0, 
-    0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600, 
-    0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00, 
-    0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58, 
-    0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58, 
-    0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960, 
-    0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0, 
-    0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80, 
-    0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40, 
-    0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00, 
-    0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500, 
-    0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8, 
-    0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8, 
-    0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0, 
-    0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
-};
-
-static unsigned short g_drwavMulawTable[256] = {
-    0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84, 
-    0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84, 
-    0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004, 
-    0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844, 
-    0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64, 
-    0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74, 
-    0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C, 
-    0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000, 
-    0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C, 
-    0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C, 
-    0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC, 
-    0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC, 
-    0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C, 
-    0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C, 
-    0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084, 
-    0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
-};
-
-static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavAlawTable[sampleIn];
-}
-
-static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavMulawTable[sampleIn];
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int16*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_s16(pOut, (const drwav_int32*)pIn, totalSampleCount);
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (drwav_int16)((drwav_int64)sample >> 48);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if ((pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(drwav_int16) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int16) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x << 8;
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = ((int)(((unsigned int)(((const drwav_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+2])) << 24)) >> 8;
-        r = x >> 8;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x >> 16;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        float c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5f);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        double x = pIn[i];
-        double c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__alaw_to_s16(pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__mulaw_to_s16(pIn[i]);
-    }
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        drwav_s16_to_f32(pOut, (const drwav_int16*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_f32(pOut, (const drwav_int32*)pIn, sampleCount);
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < sampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (float)((drwav_int64)sample / 9223372036854775807.0);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        unsigned int i;
-        for (i = 0; i < sampleCount; ++i) {
-            *pOut++ = ((const float*)pIn)[i];
-        }
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_f32(pOut, (const double*)pIn, sampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__pcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_f32(pBufferOut, sampleData, (size_t)framesRead*pWav->channels, bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ima(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since IMA-ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ieee(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__alaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__mulaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(float) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(float) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_f32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_f32__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    /*
-    It appears libsndfile uses slightly different logic for the u8 -> f32 conversion to dr_wav, which in my opinion is incorrect. It appears
-    libsndfile performs the conversion something like "f32 = (u8 / 256) * 2 - 1", however I think it should be "f32 = (u8 / 255) * 2 - 1" (note
-    the divisor of 256 vs 255). I use libsndfile as a benchmark for testing, so I'm therefore leaving this block here just for my automated
-    correctness testing. This is disabled by default.
-    */
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
-    }
-#else
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        x = x * 0.00784313725490196078f;    /* 0..255 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-
-        *pOut++ = x;
-    }
-#endif
-}
-
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] * 0.000030517578125f;
-    }
-}
-
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        double x;
-        drwav_uint32 a = ((drwav_uint32)(pIn[i*3+0]) <<  8);
-        drwav_uint32 b = ((drwav_uint32)(pIn[i*3+1]) << 16);
-        drwav_uint32 c = ((drwav_uint32)(pIn[i*3+2]) << 24);
-
-        x = (double)((drwav_int32)(a | b | c) >> 8);
-        *pOut++ = (float)(x * 0.00000011920928955078125);
-    }
-}
-
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)(pIn[i] / 2147483648.0);
-    }
-}
-
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)pIn[i];
-    }
-}
-
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__alaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__mulaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        drwav_s16_to_s32(pOut, (const drwav_int16*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int32*)pIn)[i];
-        }
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (drwav_int32)((drwav_int64)sample >> 32);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since IMA-ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(drwav_int32) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int32) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s32__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((int)pIn[i] - 128) << 24;
-    }
-}
-
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] << 16;
-    }
-}
-
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        unsigned int s0 = pIn[i*3 + 0];
-        unsigned int s1 = pIn[i*3 + 1];
-        unsigned int s2 = pIn[i*3 + 2];
-
-        drwav_int32 sample32 = (drwav_int32)((s0 << 8) | (s1 << 16) | (s2 << 24));
-        *pOut++ = sample32;
-    }
-}
-
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__alaw_to_s16(pIn[i])) << 16;
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i= 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__mulaw_to_s16(pIn[i])) << 16;
-    }
-}
-
-
-
-DRWAV_PRIVATE drwav_int16* drwav__read_pcm_frames_and_close_s16(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int16* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int16);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (drwav_int16*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-DRWAV_PRIVATE float* drwav__read_pcm_frames_and_close_f32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    float* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (float*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-DRWAV_PRIVATE drwav_int32* drwav__read_pcm_frames_and_close_s32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int32* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int32);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (drwav_int32*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-
-
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif  /* DR_WAV_NO_CONVERSION_API */
-
-
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drwav__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drwav__free_default(p, NULL);
-    }
-}
-
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8);
-}
-
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data)
-{
-    return (short)drwav_bytes_to_u16(data);
-}
-
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-}
-
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data)
-{
-    return (drwav_int32)drwav_bytes_to_u32(data);
-}
-
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data)
-{
-    return
-        ((drwav_uint64)data[0] <<  0) | ((drwav_uint64)data[1] <<  8) | ((drwav_uint64)data[2] << 16) | ((drwav_uint64)data[3] << 24) |
-        ((drwav_uint64)data[4] << 32) | ((drwav_uint64)data[5] << 40) | ((drwav_uint64)data[6] << 48) | ((drwav_uint64)data[7] << 56);
-}
-
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data)
-{
-    return (drwav_int64)drwav_bytes_to_u64(data);
-}
-
-
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
-{
-    int i;
-    for (i = 0; i < 16; i += 1) {
-        if (a[i] != b[i]) {
-            return DRWAV_FALSE;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
-{
-    return
-        a[0] == b[0] &&
-        a[1] == b[1] &&
-        a[2] == b[2] &&
-        a[3] == b[3];
-}
-
-#endif  /* dr_wav_c */
-#endif  /* DR_WAV_IMPLEMENTATION */
-
-/*
-RELEASE NOTES - v0.11.0
-=======================
-Version 0.11.0 has breaking API changes.
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRWAV_MALLOC, DRWAV_REALLOC and DRWAV_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drwav_allocation_callbacks object to drwav_init() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drwav_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drwav_init_file(&wav, "my_file.wav", &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_wav to use defaults which is the same as DRWAV_MALLOC,
-DRWAV_REALLOC and DRWAV_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drwav object now takes this extra parameter. These include the following:
-
-    drwav_init()
-    drwav_init_ex()
-    drwav_init_file()
-    drwav_init_file_ex()
-    drwav_init_file_w()
-    drwav_init_file_w_ex()
-    drwav_init_memory()
-    drwav_init_memory_ex()
-    drwav_init_write()
-    drwav_init_write_sequential()
-    drwav_init_write_sequential_pcm_frames()
-    drwav_init_file_write()
-    drwav_init_file_write_sequential()
-    drwav_init_file_write_sequential_pcm_frames()
-    drwav_init_file_write_w()
-    drwav_init_file_write_sequential_w()
-    drwav_init_file_write_sequential_pcm_frames_w()
-    drwav_init_memory_write()
-    drwav_init_memory_write_sequential()
-    drwav_init_memory_write_sequential_pcm_frames()
-    drwav_open_and_read_pcm_frames_s16()
-    drwav_open_and_read_pcm_frames_f32()
-    drwav_open_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_s16()
-    drwav_open_file_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_s16_w()
-    drwav_open_file_and_read_pcm_frames_f32_w()
-    drwav_open_file_and_read_pcm_frames_s32_w()
-    drwav_open_memory_and_read_pcm_frames_s16()
-    drwav_open_memory_and_read_pcm_frames_f32()
-    drwav_open_memory_and_read_pcm_frames_s32()
-
-Endian Improvements
--------------------
-Previously, the following APIs returned little-endian audio data. These now return native-endian data. This improves compatibility
-on big-endian architectures.
-
-    drwav_read_pcm_frames()
-    drwav_read_pcm_frames_s16()
-    drwav_read_pcm_frames_s32()
-    drwav_read_pcm_frames_f32()
-    drwav_open_and_read_pcm_frames_s16()
-    drwav_open_and_read_pcm_frames_s32()
-    drwav_open_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s16()
-    drwav_open_file_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s16_w()
-    drwav_open_file_and_read_pcm_frames_s32_w()
-    drwav_open_file_and_read_pcm_frames_f32_w()
-    drwav_open_memory_and_read_pcm_frames_s16()
-    drwav_open_memory_and_read_pcm_frames_s32()
-    drwav_open_memory_and_read_pcm_frames_f32()
-
-APIs have been added to give you explicit control over whether or not audio data is read or written in big- or little-endian byte
-order:
-
-    drwav_read_pcm_frames_le()
-    drwav_read_pcm_frames_be()
-    drwav_read_pcm_frames_s16le()
-    drwav_read_pcm_frames_s16be()
-    drwav_read_pcm_frames_f32le()
-    drwav_read_pcm_frames_f32be()
-    drwav_read_pcm_frames_s32le()
-    drwav_read_pcm_frames_s32be()
-    drwav_write_pcm_frames_le()
-    drwav_write_pcm_frames_be()
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.10.0 and have now been removed:
-
-    drwav_open()
-    drwav_open_ex()
-    drwav_open_write()
-    drwav_open_write_sequential()
-    drwav_open_file()
-    drwav_open_file_ex()
-    drwav_open_file_write()
-    drwav_open_file_write_sequential()
-    drwav_open_memory()
-    drwav_open_memory_ex()
-    drwav_open_memory_write()
-    drwav_open_memory_write_sequential()
-    drwav_close()
-
-
-
-RELEASE NOTES - v0.10.0
-=======================
-Version 0.10.0 has breaking API changes. There are no significant bug fixes in this release, so if you are affected you do
-not need to upgrade.
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.9.0 and have been completely removed in version 0.10.0:
-
-    drwav_read()
-    drwav_read_s16()
-    drwav_read_f32()
-    drwav_read_s32()
-    drwav_seek_to_sample()
-    drwav_write()
-    drwav_open_and_read_s16()
-    drwav_open_and_read_f32()
-    drwav_open_and_read_s32()
-    drwav_open_file_and_read_s16()
-    drwav_open_file_and_read_f32()
-    drwav_open_file_and_read_s32()
-    drwav_open_memory_and_read_s16()
-    drwav_open_memory_and_read_f32()
-    drwav_open_memory_and_read_s32()
-    drwav::totalSampleCount
-
-See release notes for version 0.9.0 at the bottom of this file for replacement APIs.
-
-Deprecated APIs
----------------
-The following APIs have been deprecated. There is a confusing and completely arbitrary difference between drwav_init*() and
-drwav_open*(), where drwav_init*() initializes a pre-allocated drwav object, whereas drwav_open*() will first allocated a
-drwav object on the heap and then initialize it. drwav_open*() has been deprecated which means you must now use a pre-
-allocated drwav object with drwav_init*(). If you need the previous functionality, you can just do a malloc() followed by
-a called to one of the drwav_init*() APIs.
-
-    drwav_open()
-    drwav_open_ex()
-    drwav_open_write()
-    drwav_open_write_sequential()
-    drwav_open_file()
-    drwav_open_file_ex()
-    drwav_open_file_write()
-    drwav_open_file_write_sequential()
-    drwav_open_memory()
-    drwav_open_memory_ex()
-    drwav_open_memory_write()
-    drwav_open_memory_write_sequential()
-    drwav_close()
-
-These APIs will be removed completely in a future version. The rationale for this change is to remove confusion between the
-two different ways to initialize a drwav object.
-*/
-
-/*
-REVISION HISTORY
-================
-v0.12.19 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-  - Minor improvements to the management of some internal state concerning the data chunk cursor.
-
-v0.12.18 - 2021-01-31
-  - Clean up some static analysis warnings.
-
-v0.12.17 - 2021-01-17
-  - Minor fix to sample code in documentation.
-  - Correctly qualify a private API as private rather than public.
-  - Code cleanup.
-
-v0.12.16 - 2020-12-02
-  - Fix a bug when trying to read more bytes than can fit in a size_t.
-
-v0.12.15 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.12.14 - 2020-11-13
-  - Minor code clean up.
-
-v0.12.13 - 2020-11-01
-  - Improve compiler support for older versions of GCC.
-
-v0.12.12 - 2020-09-28
-  - Add support for RF64.
-  - Fix a bug in writing mode where the size of the RIFF chunk incorrectly includes the header section.
-
-v0.12.11 - 2020-09-08
-  - Fix a compilation error on older compilers.
-
-v0.12.10 - 2020-08-24
-  - Fix a bug when seeking with ADPCM formats.
-
-v0.12.9 - 2020-08-02
-  - Simplify sized types.
-
-v0.12.8 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.12.7 - 2020-07-15
-  - Fix some bugs on big-endian architectures.
-  - Fix an error in s24 to f32 conversion.
-
-v0.12.6 - 2020-06-23
-  - Change drwav_read_*() to allow NULL to be passed in as the output buffer which is equivalent to a forward seek.
-  - Fix a buffer overflow when trying to decode invalid IMA-ADPCM files.
-  - Add include guard for the implementation section.
-
-v0.12.5 - 2020-05-27
-  - Minor documentation fix.
-
-v0.12.4 - 2020-05-16
-  - Replace assert() with DRWAV_ASSERT().
-  - Add compile-time and run-time version querying.
-    - DRWAV_VERSION_MINOR
-    - DRWAV_VERSION_MAJOR
-    - DRWAV_VERSION_REVISION
-    - DRWAV_VERSION_STRING
-    - drwav_version()
-    - drwav_version_string()
-
-v0.12.3 - 2020-04-30
-  - Fix compilation errors with VC6.
-
-v0.12.2 - 2020-04-21
-  - Fix a bug where drwav_init_file() does not close the file handle after attempting to load an erroneous file.
-
-v0.12.1 - 2020-04-13
-  - Fix some pedantic warnings.
-
-v0.12.0 - 2020-04-04
-  - API CHANGE: Add container and format parameters to the chunk callback.
-  - Minor documentation updates.
-
-v0.11.5 - 2020-03-07
-  - Fix compilation error with Visual Studio .NET 2003.
-
-v0.11.4 - 2020-01-29
-  - Fix some static analysis warnings.
-  - Fix a bug when reading f32 samples from an A-law encoded stream.
-
-v0.11.3 - 2020-01-12
-  - Minor changes to some f32 format conversion routines.
-  - Minor bug fix for ADPCM conversion when end of file is reached.
-
-v0.11.2 - 2019-12-02
-  - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
-  - Fix an integer overflow bug.
-  - Fix a null pointer dereference bug.
-  - Add limits to sample rate, channels and bits per sample to tighten up some validation.
-
-v0.11.1 - 2019-10-07
-  - Internal code clean up.
-
-v0.11.0 - 2019-10-06
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drwav_init()
-    - drwav_init_ex()
-    - drwav_init_file()
-    - drwav_init_file_ex()
-    - drwav_init_file_w()
-    - drwav_init_file_w_ex()
-    - drwav_init_memory()
-    - drwav_init_memory_ex()
-    - drwav_init_write()
-    - drwav_init_write_sequential()
-    - drwav_init_write_sequential_pcm_frames()
-    - drwav_init_file_write()
-    - drwav_init_file_write_sequential()
-    - drwav_init_file_write_sequential_pcm_frames()
-    - drwav_init_file_write_w()
-    - drwav_init_file_write_sequential_w()
-    - drwav_init_file_write_sequential_pcm_frames_w()
-    - drwav_init_memory_write()
-    - drwav_init_memory_write_sequential()
-    - drwav_init_memory_write_sequential_pcm_frames()
-    - drwav_open_and_read_pcm_frames_s16()
-    - drwav_open_and_read_pcm_frames_f32()
-    - drwav_open_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_s16()
-    - drwav_open_file_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_s16_w()
-    - drwav_open_file_and_read_pcm_frames_f32_w()
-    - drwav_open_file_and_read_pcm_frames_s32_w()
-    - drwav_open_memory_and_read_pcm_frames_s16()
-    - drwav_open_memory_and_read_pcm_frames_f32()
-    - drwav_open_memory_and_read_pcm_frames_s32()
-    Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
-    DRWAV_MALLOC, DRWAV_REALLOC and DRWAV_FREE.
-  - Add support for reading and writing PCM frames in an explicit endianness. New APIs:
-    - drwav_read_pcm_frames_le()
-    - drwav_read_pcm_frames_be()
-    - drwav_read_pcm_frames_s16le()
-    - drwav_read_pcm_frames_s16be()
-    - drwav_read_pcm_frames_f32le()
-    - drwav_read_pcm_frames_f32be()
-    - drwav_read_pcm_frames_s32le()
-    - drwav_read_pcm_frames_s32be()
-    - drwav_write_pcm_frames_le()
-    - drwav_write_pcm_frames_be()
-  - Remove deprecated APIs.
-  - API CHANGE: The following APIs now return native-endian data. Previously they returned little-endian data.
-    - drwav_read_pcm_frames()
-    - drwav_read_pcm_frames_s16()
-    - drwav_read_pcm_frames_s32()
-    - drwav_read_pcm_frames_f32()
-    - drwav_open_and_read_pcm_frames_s16()
-    - drwav_open_and_read_pcm_frames_s32()
-    - drwav_open_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s16()
-    - drwav_open_file_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s16_w()
-    - drwav_open_file_and_read_pcm_frames_s32_w()
-    - drwav_open_file_and_read_pcm_frames_f32_w()
-    - drwav_open_memory_and_read_pcm_frames_s16()
-    - drwav_open_memory_and_read_pcm_frames_s32()
-    - drwav_open_memory_and_read_pcm_frames_f32()
-
-v0.10.1 - 2019-08-31
-  - Correctly handle partial trailing ADPCM blocks.
-
-v0.10.0 - 2019-08-04
-  - Remove deprecated APIs.
-  - Add wchar_t variants for file loading APIs:
-      drwav_init_file_w()
-      drwav_init_file_ex_w()
-      drwav_init_file_write_w()
-      drwav_init_file_write_sequential_w()
-  - Add drwav_target_write_size_bytes() which calculates the total size in bytes of a WAV file given a format and sample count.
-  - Add APIs for specifying the PCM frame count instead of the sample count when opening in sequential write mode:
-      drwav_init_write_sequential_pcm_frames()
-      drwav_init_file_write_sequential_pcm_frames()
-      drwav_init_file_write_sequential_pcm_frames_w()
-      drwav_init_memory_write_sequential_pcm_frames()
-  - Deprecate drwav_open*() and drwav_close():
-      drwav_open()
-      drwav_open_ex()
-      drwav_open_write()
-      drwav_open_write_sequential()
-      drwav_open_file()
-      drwav_open_file_ex()
-      drwav_open_file_write()
-      drwav_open_file_write_sequential()
-      drwav_open_memory()
-      drwav_open_memory_ex()
-      drwav_open_memory_write()
-      drwav_open_memory_write_sequential()
-      drwav_close()
-  - Minor documentation updates.
-
-v0.9.2 - 2019-05-21
-  - Fix warnings.
-
-v0.9.1 - 2019-05-05
-  - Add support for C89.
-  - Change license to choice of public domain or MIT-0.
-
-v0.9.0 - 2018-12-16
-  - API CHANGE: Add new reading APIs for reading by PCM frames instead of samples. Old APIs have been deprecated and
-    will be removed in v0.10.0. Deprecated APIs and their replacements:
-      drwav_read()                     -> drwav_read_pcm_frames()
-      drwav_read_s16()                 -> drwav_read_pcm_frames_s16()
-      drwav_read_f32()                 -> drwav_read_pcm_frames_f32()
-      drwav_read_s32()                 -> drwav_read_pcm_frames_s32()
-      drwav_seek_to_sample()           -> drwav_seek_to_pcm_frame()
-      drwav_write()                    -> drwav_write_pcm_frames()
-      drwav_open_and_read_s16()        -> drwav_open_and_read_pcm_frames_s16()
-      drwav_open_and_read_f32()        -> drwav_open_and_read_pcm_frames_f32()
-      drwav_open_and_read_s32()        -> drwav_open_and_read_pcm_frames_s32()
-      drwav_open_file_and_read_s16()   -> drwav_open_file_and_read_pcm_frames_s16()
-      drwav_open_file_and_read_f32()   -> drwav_open_file_and_read_pcm_frames_f32()
-      drwav_open_file_and_read_s32()   -> drwav_open_file_and_read_pcm_frames_s32()
-      drwav_open_memory_and_read_s16() -> drwav_open_memory_and_read_pcm_frames_s16()
-      drwav_open_memory_and_read_f32() -> drwav_open_memory_and_read_pcm_frames_f32()
-      drwav_open_memory_and_read_s32() -> drwav_open_memory_and_read_pcm_frames_s32()
-      drwav::totalSampleCount          -> drwav::totalPCMFrameCount
-  - API CHANGE: Rename drwav_open_and_read_file_*() to drwav_open_file_and_read_*().
-  - API CHANGE: Rename drwav_open_and_read_memory_*() to drwav_open_memory_and_read_*().
-  - Add built-in support for smpl chunks.
-  - Add support for firing a callback for each chunk in the file at initialization time.
-    - This is enabled through the drwav_init_ex(), etc. family of APIs.
-  - Handle invalid FMT chunks more robustly.
-
-v0.8.5 - 2018-09-11
-  - Const correctness.
-  - Fix a potential stack overflow.
-
-v0.8.4 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.8.3 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-
-v0.8.2 - 2018-08-02
-  - Fix some big-endian bugs.
-
-v0.8.1 - 2018-06-29
-  - Add support for sequential writing APIs.
-  - Disable seeking in write mode.
-  - Fix bugs with Wave64.
-  - Fix typos.
-
-v0.8 - 2018-04-27
-  - Bug fix.
-  - Start using major.minor.revision versioning.
-
-v0.7f - 2018-02-05
-  - Restrict ADPCM formats to a maximum of 2 channels.
-
-v0.7e - 2018-02-02
-  - Fix a crash.
-
-v0.7d - 2018-02-01
-  - Fix a crash.
-
-v0.7c - 2018-02-01
-  - Set drwav.bytesPerSample to 0 for all compressed formats.
-  - Fix a crash when reading 16-bit floating point WAV files. In this case dr_wav will output silence for
-    all format conversion reading APIs (*_s16, *_s32, *_f32 APIs).
-  - Fix some divide-by-zero errors.
-
-v0.7b - 2018-01-22
-  - Fix errors with seeking of compressed formats.
-  - Fix compilation error when DR_WAV_NO_CONVERSION_API
-
-v0.7a - 2017-11-17
-  - Fix some GCC warnings.
-
-v0.7 - 2017-11-04
-  - Add writing APIs.
-
-v0.6 - 2017-08-16
-  - API CHANGE: Rename dr_* types to drwav_*.
-  - Add support for custom implementations of malloc(), realloc(), etc.
-  - Add support for Microsoft ADPCM.
-  - Add support for IMA ADPCM (DVI, format code 0x11).
-  - Optimizations to drwav_read_s16().
-  - Bug fixes.
-
-v0.5g - 2017-07-16
-  - Change underlying type for booleans to unsigned.
-
-v0.5f - 2017-04-04
-  - Fix a minor bug with drwav_open_and_read_s16() and family.
-
-v0.5e - 2016-12-29
-  - Added support for reading samples as signed 16-bit integers. Use the _s16() family of APIs for this.
-  - Minor fixes to documentation.
-
-v0.5d - 2016-12-28
-  - Use drwav_int* and drwav_uint* sized types to improve compiler support.
-
-v0.5c - 2016-11-11
-  - Properly handle JUNK chunks that come before the FMT chunk.
-
-v0.5b - 2016-10-23
-  - A minor change to drwav_bool8 and drwav_bool32 types.
-
-v0.5a - 2016-10-11
-  - Fixed a bug with drwav_open_and_read() and family due to incorrect argument ordering.
-  - Improve A-law and mu-law efficiency.
-
-v0.5 - 2016-09-29
-  - API CHANGE. Swap the order of "channels" and "sampleRate" parameters in drwav_open_and_read*(). Rationale for this is to
-    keep it consistent with dr_audio and dr_flac.
-
-v0.4b - 2016-09-18
-  - Fixed a typo in documentation.
-
-v0.4a - 2016-09-18
-  - Fixed a typo.
-  - Change date format to ISO 8601 (YYYY-MM-DD)
-
-v0.4 - 2016-07-13
-  - API CHANGE. Make onSeek consistent with dr_flac.
-  - API CHANGE. Rename drwav_seek() to drwav_seek_to_sample() for clarity and consistency with dr_flac.
-  - Added support for Sony Wave64.
-
-v0.3a - 2016-05-28
-  - API CHANGE. Return drwav_bool32 instead of int in onSeek callback.
-  - Fixed a memory leak.
-
-v0.3 - 2016-05-22
-  - Lots of API changes for consistency.
-
-v0.2a - 2016-05-16
-  - Fixed Linux/GCC build.
-
-v0.2 - 2016-05-11
-  - Added support for reading data as signed 32-bit PCM for consistency with dr_flac.
-
-v0.1a - 2016-05-07
-  - Fixed a bug in drwav_open_file() where the file handle would not be closed if the loader failed to initialize.
-
-v0.1 - 2016-05-04
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib/external/glad.h b/raylib/external/glad.h
deleted file mode 100644 (file)
index c92e184..0000000
+++ /dev/null
@@ -1,5474 +0,0 @@
-/*
-
-    OpenGL loader generated by glad 0.1.10a0 on Fri Jun 10 12:54:12 2016.
-
-    Language/Generator: C/C++
-    Specification: gl
-    APIs: gl=3.3
-    Profile: core
-    Extensions:
-        GL_AMD_debug_output, GL_AMD_query_buffer_object, GL_ARB_ES2_compatibility, GL_ARB_ES3_compatibility, GL_ARB_buffer_storage, GL_ARB_compatibility, GL_ARB_compressed_texture_pixel_storage, GL_ARB_debug_output, GL_ARB_depth_buffer_float, GL_ARB_depth_clamp, GL_ARB_depth_texture, GL_ARB_draw_buffers, GL_ARB_draw_buffers_blend, GL_ARB_explicit_attrib_location, GL_ARB_explicit_uniform_location, GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_framebuffer_object, GL_ARB_framebuffer_sRGB, GL_ARB_multisample, GL_ARB_sample_locations, GL_ARB_texture_compression, GL_ARB_texture_float, GL_ARB_texture_multisample, GL_ARB_texture_non_power_of_two, GL_ARB_texture_rg, GL_ARB_texture_swizzle, GL_ARB_uniform_buffer_object, GL_ARB_vertex_array_object, GL_ARB_vertex_attrib_binding, GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_element_array, GL_ATI_fragment_shader, GL_ATI_vertex_array_object, GL_EXT_blend_color, GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_multisample_blit_scaled, GL_EXT_framebuffer_object, GL_EXT_framebuffer_sRGB, GL_EXT_index_array_formats, GL_EXT_texture, GL_EXT_texture_compression_s3tc, GL_EXT_texture_sRGB, GL_EXT_texture_swizzle, GL_EXT_vertex_array, GL_EXT_vertex_shader
-    Loader: No
-
-    Commandline:
-        --profile="core" --api="gl=3.3" --generator="c" --spec="gl" --no-loader --extensions="GL_AMD_debug_output,GL_AMD_query_buffer_object,GL_ARB_ES2_compatibility,GL_ARB_ES3_compatibility,GL_ARB_buffer_storage,GL_ARB_compatibility,GL_ARB_compressed_texture_pixel_storage,GL_ARB_debug_output,GL_ARB_depth_buffer_float,GL_ARB_depth_clamp,GL_ARB_depth_texture,GL_ARB_draw_buffers,GL_ARB_draw_buffers_blend,GL_ARB_explicit_attrib_location,GL_ARB_explicit_uniform_location,GL_ARB_fragment_program,GL_ARB_fragment_shader,GL_ARB_framebuffer_object,GL_ARB_framebuffer_sRGB,GL_ARB_multisample,GL_ARB_sample_locations,GL_ARB_texture_compression,GL_ARB_texture_float,GL_ARB_texture_multisample,GL_ARB_texture_non_power_of_two,GL_ARB_texture_rg,GL_ARB_texture_swizzle,GL_ARB_uniform_buffer_object,GL_ARB_vertex_array_object,GL_ARB_vertex_attrib_binding,GL_ARB_vertex_buffer_object,GL_ARB_vertex_program,GL_ARB_vertex_shader,GL_ATI_element_array,GL_ATI_fragment_shader,GL_ATI_vertex_array_object,GL_EXT_blend_color,GL_EXT_blend_equation_separate,GL_EXT_blend_func_separate,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_multisample_blit_scaled,GL_EXT_framebuffer_object,GL_EXT_framebuffer_sRGB,GL_EXT_index_array_formats,GL_EXT_texture,GL_EXT_texture_compression_s3tc,GL_EXT_texture_sRGB,GL_EXT_texture_swizzle,GL_EXT_vertex_array,GL_EXT_vertex_shader"
-    Online:
-        http://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&extensions=GL_AMD_debug_output&extensions=GL_AMD_query_buffer_object&extensions=GL_ARB_ES2_compatibility&extensions=GL_ARB_ES3_compatibility&extensions=GL_ARB_buffer_storage&extensions=GL_ARB_compatibility&extensions=GL_ARB_compressed_texture_pixel_storage&extensions=GL_ARB_debug_output&extensions=GL_ARB_depth_buffer_float&extensions=GL_ARB_depth_clamp&extensions=GL_ARB_depth_texture&extensions=GL_ARB_draw_buffers&extensions=GL_ARB_draw_buffers_blend&extensions=GL_ARB_explicit_attrib_location&extensions=GL_ARB_explicit_uniform_location&extensions=GL_ARB_fragment_program&extensions=GL_ARB_fragment_shader&extensions=GL_ARB_framebuffer_object&extensions=GL_ARB_framebuffer_sRGB&extensions=GL_ARB_multisample&extensions=GL_ARB_sample_locations&extensions=GL_ARB_texture_compression&extensions=GL_ARB_texture_float&extensions=GL_ARB_texture_multisample&extensions=GL_ARB_texture_non_power_of_two&extensions=GL_ARB_texture_rg&extensions=GL_ARB_texture_swizzle&extensions=GL_ARB_uniform_buffer_object&extensions=GL_ARB_vertex_array_object&extensions=GL_ARB_vertex_attrib_binding&extensions=GL_ARB_vertex_buffer_object&extensions=GL_ARB_vertex_program&extensions=GL_ARB_vertex_shader&extensions=GL_ATI_element_array&extensions=GL_ATI_fragment_shader&extensions=GL_ATI_vertex_array_object&extensions=GL_EXT_blend_color&extensions=GL_EXT_blend_equation_separate&extensions=GL_EXT_blend_func_separate&extensions=GL_EXT_framebuffer_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_multisample_blit_scaled&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_framebuffer_sRGB&extensions=GL_EXT_index_array_formats&extensions=GL_EXT_texture&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_sRGB&extensions=GL_EXT_texture_swizzle&extensions=GL_EXT_vertex_array&extensions=GL_EXT_vertex_shader
-*/
-
-
-#ifndef __glad_h_
-#define __glad_h_
-
-#ifdef __gl_h_
-#error OpenGL header already included, remove this include, glad already provides it
-#endif
-#define __gl_h_
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-//#include <windows.h>
-#define APIENTRY __stdcall      // RAY: Added
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-
-// RAY: Added
-#ifndef GLAD_REALLOC
-    #define GLAD_REALLOC(n,sz)  realloc(n,sz)
-#endif
-#ifndef GLAD_FREE
-    #define GLAD_FREE(p)        free(p)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct gladGLversionStruct {
-    int major;
-    int minor;
-};
-
-typedef void* (* GLADloadproc)(const char *name);
-
-#ifndef GLAPI
-# if defined(GLAD_GLAPI_EXPORT)
-#  if defined(WIN32) || defined(__CYGWIN__)
-#   if defined(GLAD_GLAPI_EXPORT_BUILD)
-#    if defined(__GNUC__)
-#     define GLAPI __attribute__ ((dllexport)) extern
-#    else
-#     define GLAPI __declspec(dllexport) extern
-#    endif
-#   else
-#    if defined(__GNUC__)
-#     define GLAPI __attribute__ ((dllimport)) extern
-#    else
-#     define GLAPI __declspec(dllimport) extern
-#    endif
-#   endif
-#  elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)
-#   define GLAPI __attribute__ ((visibility ("default"))) extern
-#  else
-#   define GLAPI extern
-#  endif
-# else
-#  define GLAPI extern
-# endif
-#endif
-
-GLAPI struct gladGLversionStruct GLVersion;
-GLAPI int gladLoadGLLoader(GLADloadproc);
-
-#include <stddef.h>
-//#include <KHR/khrplatform.h>      // RAY: Not required
-#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glxext.h, so must be protected */
-#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GL_EXT_timer_query extension). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#include <inttypes.h>
-#elif defined(__sun__) || defined(__digital__)
-#include <inttypes.h>
-#if defined(__STDC__)
-#if defined(__arch64__) || defined(_LP64)
-typedef long int int64_t;
-typedef unsigned long int uint64_t;
-#else
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
-#elif defined( __VMS ) || defined(__sgi)
-#include <inttypes.h>
-#elif defined(__SCO__) || defined(__USLC__)
-#include <stdint.h>
-#elif defined(__UNIXOS2__) || defined(__SOL64__)
-typedef long int int32_t;
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#elif defined(_WIN32) && defined(__GNUC__)
-#include <stdint.h>
-#elif defined(_WIN32)
-typedef __int32 int32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-/* Fallback if nothing above works */
-#include <inttypes.h>
-#endif
-#endif
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef void GLvoid;
-typedef signed char GLbyte;
-typedef short GLshort;
-typedef int GLint;
-typedef int GLclampx;
-typedef unsigned char GLubyte;
-typedef unsigned short GLushort;
-typedef unsigned int GLuint;
-typedef int GLsizei;
-typedef float GLfloat;
-typedef float GLclampf;
-typedef double GLdouble;
-typedef double GLclampd;
-typedef void *GLeglImageOES;
-typedef char GLchar;
-typedef char GLcharARB;
-#ifdef __APPLE__
-typedef void *GLhandleARB;
-#else
-typedef unsigned int GLhandleARB;
-#endif
-typedef unsigned short GLhalfARB;
-typedef unsigned short GLhalf;
-typedef GLint GLfixed;
-typedef ptrdiff_t GLintptr;
-typedef ptrdiff_t GLsizeiptr;
-typedef int64_t GLint64;
-typedef uint64_t GLuint64;
-typedef ptrdiff_t GLintptrARB;
-typedef ptrdiff_t GLsizeiptrARB;
-typedef int64_t GLint64EXT;
-typedef uint64_t GLuint64EXT;
-typedef struct __GLsync *GLsync;
-struct _cl_context;
-struct _cl_event;
-typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
-typedef unsigned short GLhalfNV;
-typedef GLintptr GLvdpauSurfaceNV;
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_FALSE 0
-#define GL_TRUE 1
-#define GL_POINTS 0x0000
-#define GL_LINES 0x0001
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_STRIP 0x0003
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_NEVER 0x0200
-#define GL_LESS 0x0201
-#define GL_EQUAL 0x0202
-#define GL_LEQUAL 0x0203
-#define GL_GREATER 0x0204
-#define GL_NOTEQUAL 0x0205
-#define GL_GEQUAL 0x0206
-#define GL_ALWAYS 0x0207
-#define GL_ZERO 0
-#define GL_ONE 1
-#define GL_SRC_COLOR 0x0300
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_SRC_ALPHA 0x0302
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_DST_ALPHA 0x0304
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_DST_COLOR 0x0306
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_NONE 0
-#define GL_FRONT_LEFT 0x0400
-#define GL_FRONT_RIGHT 0x0401
-#define GL_BACK_LEFT 0x0402
-#define GL_BACK_RIGHT 0x0403
-#define GL_FRONT 0x0404
-#define GL_BACK 0x0405
-#define GL_LEFT 0x0406
-#define GL_RIGHT 0x0407
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_NO_ERROR 0
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVALID_OPERATION 0x0502
-#define GL_OUT_OF_MEMORY 0x0505
-#define GL_CW 0x0900
-#define GL_CCW 0x0901
-#define GL_POINT_SIZE 0x0B11
-#define GL_POINT_SIZE_RANGE 0x0B12
-#define GL_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_LINE_SMOOTH 0x0B20
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINE_WIDTH_RANGE 0x0B22
-#define GL_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_POLYGON_MODE 0x0B40
-#define GL_POLYGON_SMOOTH 0x0B41
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_FRONT_FACE 0x0B46
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_VIEWPORT 0x0BA2
-#define GL_DITHER 0x0BD0
-#define GL_BLEND_DST 0x0BE0
-#define GL_BLEND_SRC 0x0BE1
-#define GL_BLEND 0x0BE2
-#define GL_LOGIC_OP_MODE 0x0BF0
-#define GL_COLOR_LOGIC_OP 0x0BF2
-#define GL_DRAW_BUFFER 0x0C01
-#define GL_READ_BUFFER 0x0C02
-#define GL_SCISSOR_BOX 0x0C10
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_DOUBLEBUFFER 0x0C32
-#define GL_STEREO 0x0C33
-#define GL_LINE_SMOOTH_HINT 0x0C52
-#define GL_POLYGON_SMOOTH_HINT 0x0C53
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_UNPACK_LSB_FIRST 0x0CF1
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_PACK_LSB_FIRST 0x0D01
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_POLYGON_OFFSET_POINT 0x2A01
-#define GL_POLYGON_OFFSET_LINE 0x2A02
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_TEXTURE_BINDING_1D 0x8068
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_WIDTH 0x1000
-#define GL_TEXTURE_HEIGHT 0x1001
-#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
-#define GL_TEXTURE_BORDER_COLOR 0x1004
-#define GL_TEXTURE_RED_SIZE 0x805C
-#define GL_TEXTURE_GREEN_SIZE 0x805D
-#define GL_TEXTURE_BLUE_SIZE 0x805E
-#define GL_TEXTURE_ALPHA_SIZE 0x805F
-#define GL_DONT_CARE 0x1100
-#define GL_FASTEST 0x1101
-#define GL_NICEST 0x1102
-#define GL_BYTE 0x1400
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_SHORT 0x1402
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_INT 0x1404
-#define GL_UNSIGNED_INT 0x1405
-#define GL_FLOAT 0x1406
-#define GL_DOUBLE 0x140A
-#define GL_CLEAR 0x1500
-#define GL_AND 0x1501
-#define GL_AND_REVERSE 0x1502
-#define GL_COPY 0x1503
-#define GL_AND_INVERTED 0x1504
-#define GL_NOOP 0x1505
-#define GL_XOR 0x1506
-#define GL_OR 0x1507
-#define GL_NOR 0x1508
-#define GL_EQUIV 0x1509
-#define GL_INVERT 0x150A
-#define GL_OR_REVERSE 0x150B
-#define GL_COPY_INVERTED 0x150C
-#define GL_OR_INVERTED 0x150D
-#define GL_NAND 0x150E
-#define GL_SET 0x150F
-#define GL_TEXTURE 0x1702
-#define GL_COLOR 0x1800
-#define GL_DEPTH 0x1801
-#define GL_STENCIL 0x1802
-#define GL_STENCIL_INDEX 0x1901
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_RED 0x1903
-#define GL_GREEN 0x1904
-#define GL_BLUE 0x1905
-#define GL_ALPHA 0x1906
-#define GL_RGB 0x1907
-#define GL_RGBA 0x1908
-#define GL_POINT 0x1B00
-#define GL_LINE 0x1B01
-#define GL_FILL 0x1B02
-#define GL_KEEP 0x1E00
-#define GL_REPLACE 0x1E01
-#define GL_INCR 0x1E02
-#define GL_DECR 0x1E03
-#define GL_VENDOR 0x1F00
-#define GL_RENDERER 0x1F01
-#define GL_VERSION 0x1F02
-#define GL_EXTENSIONS 0x1F03
-#define GL_NEAREST 0x2600
-#define GL_LINEAR 0x2601
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_PROXY_TEXTURE_1D 0x8063
-#define GL_PROXY_TEXTURE_2D 0x8064
-#define GL_REPEAT 0x2901
-#define GL_R3_G3_B2 0x2A10
-#define GL_RGB4 0x804F
-#define GL_RGB5 0x8050
-#define GL_RGB8 0x8051
-#define GL_RGB10 0x8052
-#define GL_RGB12 0x8053
-#define GL_RGB16 0x8054
-#define GL_RGBA2 0x8055
-#define GL_RGBA4 0x8056
-#define GL_RGB5_A1 0x8057
-#define GL_RGBA8 0x8058
-#define GL_RGB10_A2 0x8059
-#define GL_RGBA12 0x805A
-#define GL_RGBA16 0x805B
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_TEXTURE_3D 0x806F
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_MULTISAMPLE 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_COMPRESSED_RGB 0x84ED
-#define GL_COMPRESSED_RGBA 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
-#define GL_TEXTURE_COMPRESSED 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_DEPTH_COMPONENT32 0x81A7
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_TEXTURE_LOD_BIAS 0x8501
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-#define GL_TEXTURE_DEPTH_SIZE 0x884A
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_QUERY_COUNTER_BITS 0x8864
-#define GL_CURRENT_QUERY 0x8865
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_READ_ONLY 0x88B8
-#define GL_WRITE_ONLY 0x88B9
-#define GL_READ_WRITE 0x88BA
-#define GL_BUFFER_ACCESS 0x88BB
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_STREAM_COPY 0x88E2
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STATIC_COPY 0x88E6
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_SAMPLES_PASSED 0x8914
-#define GL_SRC1_ALPHA 0x8589
-#define GL_BLEND_EQUATION_RGB 0x8009
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLER_1D_SHADOW 0x8B61
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_DELETE_STATUS 0x8B80
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
-#define GL_LOWER_LEFT 0x8CA1
-#define GL_UPPER_LEFT 0x8CA2
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
-#define GL_FLOAT_MAT2x3 0x8B65
-#define GL_FLOAT_MAT2x4 0x8B66
-#define GL_FLOAT_MAT3x2 0x8B67
-#define GL_FLOAT_MAT3x4 0x8B68
-#define GL_FLOAT_MAT4x2 0x8B69
-#define GL_FLOAT_MAT4x3 0x8B6A
-#define GL_SRGB 0x8C40
-#define GL_SRGB8 0x8C41
-#define GL_SRGB_ALPHA 0x8C42
-#define GL_SRGB8_ALPHA8 0x8C43
-#define GL_COMPRESSED_SRGB 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
-#define GL_COMPARE_REF_TO_TEXTURE 0x884E
-#define GL_CLIP_DISTANCE0 0x3000
-#define GL_CLIP_DISTANCE1 0x3001
-#define GL_CLIP_DISTANCE2 0x3002
-#define GL_CLIP_DISTANCE3 0x3003
-#define GL_CLIP_DISTANCE4 0x3004
-#define GL_CLIP_DISTANCE5 0x3005
-#define GL_CLIP_DISTANCE6 0x3006
-#define GL_CLIP_DISTANCE7 0x3007
-#define GL_MAX_CLIP_DISTANCES 0x0D32
-#define GL_MAJOR_VERSION 0x821B
-#define GL_MINOR_VERSION 0x821C
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_CONTEXT_FLAGS 0x821E
-#define GL_COMPRESSED_RED 0x8225
-#define GL_COMPRESSED_RG 0x8226
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_RGBA32F 0x8814
-#define GL_RGB32F 0x8815
-#define GL_RGBA16F 0x881A
-#define GL_RGB16F 0x881B
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
-#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
-#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
-#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
-#define GL_CLAMP_READ_COLOR 0x891C
-#define GL_FIXED_ONLY 0x891D
-#define GL_MAX_VARYING_COMPONENTS 0x8B4B
-#define GL_TEXTURE_1D_ARRAY 0x8C18
-#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
-#define GL_TEXTURE_2D_ARRAY 0x8C1A
-#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
-#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
-#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
-#define GL_R11F_G11F_B10F 0x8C3A
-#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
-#define GL_RGB9_E5 0x8C3D
-#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
-#define GL_TEXTURE_SHARED_SIZE 0x8C3F
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_PRIMITIVES_GENERATED 0x8C87
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_RASTERIZER_DISCARD 0x8C89
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_INTERLEAVED_ATTRIBS 0x8C8C
-#define GL_SEPARATE_ATTRIBS 0x8C8D
-#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_RGBA32UI 0x8D70
-#define GL_RGB32UI 0x8D71
-#define GL_RGBA16UI 0x8D76
-#define GL_RGB16UI 0x8D77
-#define GL_RGBA8UI 0x8D7C
-#define GL_RGB8UI 0x8D7D
-#define GL_RGBA32I 0x8D82
-#define GL_RGB32I 0x8D83
-#define GL_RGBA16I 0x8D88
-#define GL_RGB16I 0x8D89
-#define GL_RGBA8I 0x8D8E
-#define GL_RGB8I 0x8D8F
-#define GL_RED_INTEGER 0x8D94
-#define GL_GREEN_INTEGER 0x8D95
-#define GL_BLUE_INTEGER 0x8D96
-#define GL_RGB_INTEGER 0x8D98
-#define GL_RGBA_INTEGER 0x8D99
-#define GL_BGR_INTEGER 0x8D9A
-#define GL_BGRA_INTEGER 0x8D9B
-#define GL_SAMPLER_1D_ARRAY 0x8DC0
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#define GL_INT_SAMPLER_1D 0x8DC9
-#define GL_INT_SAMPLER_2D 0x8DCA
-#define GL_INT_SAMPLER_3D 0x8DCB
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#define GL_QUERY_WAIT 0x8E13
-#define GL_QUERY_NO_WAIT 0x8E14
-#define GL_QUERY_BY_REGION_WAIT 0x8E15
-#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
-#define GL_BUFFER_ACCESS_FLAGS 0x911F
-#define GL_BUFFER_MAP_LENGTH 0x9120
-#define GL_BUFFER_MAP_OFFSET 0x9121
-#define GL_DEPTH_COMPONENT32F 0x8CAC
-#define GL_DEPTH32F_STENCIL8 0x8CAD
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_DEFAULT 0x8218
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#define GL_DEPTH_STENCIL 0x84F9
-#define GL_UNSIGNED_INT_24_8 0x84FA
-#define GL_DEPTH24_STENCIL8 0x88F0
-#define GL_TEXTURE_STENCIL_SIZE 0x88F1
-#define GL_TEXTURE_RED_TYPE 0x8C10
-#define GL_TEXTURE_GREEN_TYPE 0x8C11
-#define GL_TEXTURE_BLUE_TYPE 0x8C12
-#define GL_TEXTURE_ALPHA_TYPE 0x8C13
-#define GL_TEXTURE_DEPTH_TYPE 0x8C16
-#define GL_UNSIGNED_NORMALIZED 0x8C17
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
-#define GL_RENDERBUFFER_SAMPLES 0x8CAB
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#define GL_COLOR_ATTACHMENT3 0x8CE3
-#define GL_COLOR_ATTACHMENT4 0x8CE4
-#define GL_COLOR_ATTACHMENT5 0x8CE5
-#define GL_COLOR_ATTACHMENT6 0x8CE6
-#define GL_COLOR_ATTACHMENT7 0x8CE7
-#define GL_COLOR_ATTACHMENT8 0x8CE8
-#define GL_COLOR_ATTACHMENT9 0x8CE9
-#define GL_COLOR_ATTACHMENT10 0x8CEA
-#define GL_COLOR_ATTACHMENT11 0x8CEB
-#define GL_COLOR_ATTACHMENT12 0x8CEC
-#define GL_COLOR_ATTACHMENT13 0x8CED
-#define GL_COLOR_ATTACHMENT14 0x8CEE
-#define GL_COLOR_ATTACHMENT15 0x8CEF
-#define GL_COLOR_ATTACHMENT16 0x8CF0
-#define GL_COLOR_ATTACHMENT17 0x8CF1
-#define GL_COLOR_ATTACHMENT18 0x8CF2
-#define GL_COLOR_ATTACHMENT19 0x8CF3
-#define GL_COLOR_ATTACHMENT20 0x8CF4
-#define GL_COLOR_ATTACHMENT21 0x8CF5
-#define GL_COLOR_ATTACHMENT22 0x8CF6
-#define GL_COLOR_ATTACHMENT23 0x8CF7
-#define GL_COLOR_ATTACHMENT24 0x8CF8
-#define GL_COLOR_ATTACHMENT25 0x8CF9
-#define GL_COLOR_ATTACHMENT26 0x8CFA
-#define GL_COLOR_ATTACHMENT27 0x8CFB
-#define GL_COLOR_ATTACHMENT28 0x8CFC
-#define GL_COLOR_ATTACHMENT29 0x8CFD
-#define GL_COLOR_ATTACHMENT30 0x8CFE
-#define GL_COLOR_ATTACHMENT31 0x8CFF
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_RENDERBUFFER 0x8D41
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_STENCIL_INDEX1 0x8D46
-#define GL_STENCIL_INDEX4 0x8D47
-#define GL_STENCIL_INDEX8 0x8D48
-#define GL_STENCIL_INDEX16 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_MAX_SAMPLES 0x8D57
-#define GL_INDEX 0x8222
-#define GL_FRAMEBUFFER_SRGB 0x8DB9
-#define GL_HALF_FLOAT 0x140B
-#define GL_MAP_READ_BIT 0x0001
-#define GL_MAP_WRITE_BIT 0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
-#define GL_COMPRESSED_RED_RGTC1 0x8DBB
-#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
-#define GL_COMPRESSED_RG_RGTC2 0x8DBD
-#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
-#define GL_RG 0x8227
-#define GL_RG_INTEGER 0x8228
-#define GL_R8 0x8229
-#define GL_R16 0x822A
-#define GL_RG8 0x822B
-#define GL_RG16 0x822C
-#define GL_R16F 0x822D
-#define GL_R32F 0x822E
-#define GL_RG16F 0x822F
-#define GL_RG32F 0x8230
-#define GL_R8I 0x8231
-#define GL_R8UI 0x8232
-#define GL_R16I 0x8233
-#define GL_R16UI 0x8234
-#define GL_R32I 0x8235
-#define GL_R32UI 0x8236
-#define GL_RG8I 0x8237
-#define GL_RG8UI 0x8238
-#define GL_RG16I 0x8239
-#define GL_RG16UI 0x823A
-#define GL_RG32I 0x823B
-#define GL_RG32UI 0x823C
-#define GL_VERTEX_ARRAY_BINDING 0x85B5
-#define GL_SAMPLER_2D_RECT 0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
-#define GL_SAMPLER_BUFFER 0x8DC2
-#define GL_INT_SAMPLER_2D_RECT 0x8DCD
-#define GL_INT_SAMPLER_BUFFER 0x8DD0
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
-#define GL_TEXTURE_BUFFER 0x8C2A
-#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
-#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
-#define GL_R8_SNORM 0x8F94
-#define GL_RG8_SNORM 0x8F95
-#define GL_RGB8_SNORM 0x8F96
-#define GL_RGBA8_SNORM 0x8F97
-#define GL_R16_SNORM 0x8F98
-#define GL_RG16_SNORM 0x8F99
-#define GL_RGB16_SNORM 0x8F9A
-#define GL_RGBA16_SNORM 0x8F9B
-#define GL_SIGNED_NORMALIZED 0x8F9C
-#define GL_PRIMITIVE_RESTART 0x8F9D
-#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
-#define GL_COPY_READ_BUFFER 0x8F36
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#define GL_UNIFORM_BUFFER 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING 0x8A28
-#define GL_UNIFORM_BUFFER_START 0x8A29
-#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
-#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
-#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#define GL_UNIFORM_TYPE 0x8A37
-#define GL_UNIFORM_SIZE 0x8A38
-#define GL_UNIFORM_NAME_LENGTH 0x8A39
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#define GL_UNIFORM_OFFSET 0x8A3B
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_INVALID_INDEX 0xFFFFFFFF
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_LINES_ADJACENCY 0x000A
-#define GL_LINE_STRIP_ADJACENCY 0x000B
-#define GL_TRIANGLES_ADJACENCY 0x000C
-#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
-#define GL_PROGRAM_POINT_SIZE 0x8642
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
-#define GL_GEOMETRY_SHADER 0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT 0x8916
-#define GL_GEOMETRY_INPUT_TYPE 0x8917
-#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
-#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
-#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_DEPTH_CLAMP 0x864F
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
-#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
-#define GL_LAST_VERTEX_CONVENTION 0x8E4E
-#define GL_PROVOKING_VERTEX 0x8E4F
-#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
-#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
-#define GL_OBJECT_TYPE 0x9112
-#define GL_SYNC_CONDITION 0x9113
-#define GL_SYNC_STATUS 0x9114
-#define GL_SYNC_FLAGS 0x9115
-#define GL_SYNC_FENCE 0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#define GL_UNSIGNALED 0x9118
-#define GL_SIGNALED 0x9119
-#define GL_ALREADY_SIGNALED 0x911A
-#define GL_TIMEOUT_EXPIRED 0x911B
-#define GL_CONDITION_SATISFIED 0x911C
-#define GL_WAIT_FAILED 0x911D
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#define GL_SAMPLE_POSITION 0x8E50
-#define GL_SAMPLE_MASK 0x8E51
-#define GL_SAMPLE_MASK_VALUE 0x8E52
-#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
-#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
-#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
-#define GL_TEXTURE_SAMPLES 0x9106
-#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
-#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
-#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
-#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
-#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
-#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
-#define GL_MAX_INTEGER_SAMPLES 0x9110
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_SRC1_COLOR 0x88F9
-#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
-#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
-#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
-#define GL_ANY_SAMPLES_PASSED 0x8C2F
-#define GL_SAMPLER_BINDING 0x8919
-#define GL_RGB10_A2UI 0x906F
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
-#define GL_TIME_ELAPSED 0x88BF
-#define GL_TIMESTAMP 0x8E28
-#define GL_INT_2_10_10_10_REV 0x8D9F
-#ifndef GL_VERSION_1_0
-#define GL_VERSION_1_0 1
-GLAPI int GLAD_GL_VERSION_1_0;
-typedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum mode);
-GLAPI PFNGLCULLFACEPROC glad_glCullFace;
-#define glCullFace glad_glCullFace
-typedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode);
-GLAPI PFNGLFRONTFACEPROC glad_glFrontFace;
-#define glFrontFace glad_glFrontFace
-typedef void (APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode);
-GLAPI PFNGLHINTPROC glad_glHint;
-#define glHint glad_glHint
-typedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width);
-GLAPI PFNGLLINEWIDTHPROC glad_glLineWidth;
-#define glLineWidth glad_glLineWidth
-typedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size);
-GLAPI PFNGLPOINTSIZEPROC glad_glPointSize;
-#define glPointSize glad_glPointSize
-typedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
-GLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-#define glPolygonMode glad_glPolygonMode
-typedef void (APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLSCISSORPROC glad_glScissor;
-#define glScissor glad_glScissor
-typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
-GLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-#define glTexParameterf glad_glTexParameterf
-typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat* params);
-GLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-#define glTexParameterfv glad_glTexParameterfv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
-GLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-#define glTexParameteri glad_glTexParameteri
-typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint* params);
-GLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-#define glTexParameteriv glad_glTexParameteriv
-typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-#define glTexImage1D glad_glTexImage1D
-typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-#define glTexImage2D glad_glTexImage2D
-typedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf);
-GLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-#define glDrawBuffer glad_glDrawBuffer
-typedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield mask);
-GLAPI PFNGLCLEARPROC glad_glClear;
-#define glClear glad_glClear
-typedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLCLEARCOLORPROC glad_glClearColor;
-#define glClearColor glad_glClearColor
-typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s);
-GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil;
-#define glClearStencil glad_glClearStencil
-typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth);
-GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth;
-#define glClearDepth glad_glClearDepth
-typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask);
-GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;
-#define glStencilMask glad_glStencilMask
-typedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-GLAPI PFNGLCOLORMASKPROC glad_glColorMask;
-#define glColorMask glad_glColorMask
-typedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag);
-GLAPI PFNGLDEPTHMASKPROC glad_glDepthMask;
-#define glDepthMask glad_glDepthMask
-typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap);
-GLAPI PFNGLDISABLEPROC glad_glDisable;
-#define glDisable glad_glDisable
-typedef void (APIENTRYP PFNGLENABLEPROC)(GLenum cap);
-GLAPI PFNGLENABLEPROC glad_glEnable;
-#define glEnable glad_glEnable
-typedef void (APIENTRYP PFNGLFINISHPROC)();
-GLAPI PFNGLFINISHPROC glad_glFinish;
-#define glFinish glad_glFinish
-typedef void (APIENTRYP PFNGLFLUSHPROC)();
-GLAPI PFNGLFLUSHPROC glad_glFlush;
-#define glFlush glad_glFlush
-typedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
-GLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc;
-#define glBlendFunc glad_glBlendFunc
-typedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode);
-GLAPI PFNGLLOGICOPPROC glad_glLogicOp;
-#define glLogicOp glad_glLogicOp
-typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
-GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-#define glStencilFunc glad_glStencilFunc
-typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
-GLAPI PFNGLSTENCILOPPROC glad_glStencilOp;
-#define glStencilOp glad_glStencilOp
-typedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func);
-GLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-#define glDepthFunc glad_glDepthFunc
-typedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
-GLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-#define glPixelStoref glad_glPixelStoref
-typedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
-GLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-#define glPixelStorei glad_glPixelStorei
-typedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum src);
-GLAPI PFNGLREADBUFFERPROC glad_glReadBuffer;
-#define glReadBuffer glad_glReadBuffer
-typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
-GLAPI PFNGLREADPIXELSPROC glad_glReadPixels;
-#define glReadPixels glad_glReadPixels
-typedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data);
-GLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-#define glGetBooleanv glad_glGetBooleanv
-typedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble* data);
-GLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-#define glGetDoublev glad_glGetDoublev
-typedef GLenum (APIENTRYP PFNGLGETERRORPROC)();
-GLAPI PFNGLGETERRORPROC glad_glGetError;
-#define glGetError glad_glGetError
-typedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data);
-GLAPI PFNGLGETFLOATVPROC glad_glGetFloatv;
-#define glGetFloatv glad_glGetFloatv
-typedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data);
-GLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-#define glGetIntegerv glad_glGetIntegerv
-typedef const GLubyte* (APIENTRYP PFNGLGETSTRINGPROC)(GLenum name);
-GLAPI PFNGLGETSTRINGPROC glad_glGetString;
-#define glGetString glad_glGetString
-typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void* pixels);
-GLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-#define glGetTexImage glad_glGetTexImage
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-#define glGetTexParameterfv glad_glGetTexParameterfv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-#define glGetTexParameteriv glad_glGetTexParameteriv
-typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
-typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
-typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap);
-GLAPI PFNGLISENABLEDPROC glad_glIsEnabled;
-#define glIsEnabled glad_glIsEnabled
-typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble near, GLdouble far);
-GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange;
-#define glDepthRange glad_glDepthRange
-typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLVIEWPORTPROC glad_glViewport;
-#define glViewport glad_glViewport
-#endif
-#ifndef GL_VERSION_1_1
-#define GL_VERSION_1_1 1
-GLAPI int GLAD_GL_VERSION_1_1;
-typedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
-GLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-#define glDrawArrays glad_glDrawArrays
-typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices);
-GLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-#define glDrawElements glad_glDrawElements
-typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
-GLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-#define glPolygonOffset glad_glPolygonOffset
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-GLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-#define glCopyTexImage1D glad_glCopyTexImage1D
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-#define glCopyTexImage2D glad_glCopyTexImage2D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-GLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-#define glTexSubImage1D glad_glTexSubImage1D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-#define glTexSubImage2D glad_glTexSubImage2D
-typedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
-GLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture;
-#define glBindTexture glad_glBindTexture
-typedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint* textures);
-GLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-#define glDeleteTextures glad_glDeleteTextures
-typedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures);
-GLAPI PFNGLGENTEXTURESPROC glad_glGenTextures;
-#define glGenTextures glad_glGenTextures
-typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture);
-GLAPI PFNGLISTEXTUREPROC glad_glIsTexture;
-#define glIsTexture glad_glIsTexture
-#endif
-#ifndef GL_VERSION_1_2
-#define GL_VERSION_1_2 1
-GLAPI int GLAD_GL_VERSION_1_2;
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
-GLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-#define glDrawRangeElements glad_glDrawRangeElements
-typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-#define glTexImage3D glad_glTexImage3D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-#define glTexSubImage3D glad_glTexSubImage3D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
-#endif
-#ifndef GL_VERSION_1_3
-#define GL_VERSION_1_3 1
-GLAPI int GLAD_GL_VERSION_1_3;
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture);
-GLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-#define glActiveTexture glad_glActiveTexture
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
-GLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-#define glSampleCoverage glad_glSampleCoverage
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-#define glCompressedTexImage3D glad_glCompressedTexImage3D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-#define glCompressedTexImage2D glad_glCompressedTexImage2D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-#define glCompressedTexImage1D glad_glCompressedTexImage1D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void* img);
-GLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-#define glGetCompressedTexImage glad_glGetCompressedTexImage
-#endif
-#ifndef GL_VERSION_1_4
-#define GL_VERSION_1_4 1
-GLAPI int GLAD_GL_VERSION_1_4;
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-#define glBlendFuncSeparate glad_glBlendFuncSeparate
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount);
-GLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-#define glMultiDrawArrays glad_glMultiDrawArrays
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei* count, GLenum type, const void** indices, GLsizei drawcount);
-GLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-#define glMultiDrawElements glad_glMultiDrawElements
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
-GLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-#define glPointParameterf glad_glPointParameterf
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat* params);
-GLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-#define glPointParameterfv glad_glPointParameterfv
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
-GLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-#define glPointParameteri glad_glPointParameteri
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint* params);
-GLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-#define glPointParameteriv glad_glPointParameteriv
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLBLENDCOLORPROC glad_glBlendColor;
-#define glBlendColor glad_glBlendColor
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode);
-GLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-#define glBlendEquation glad_glBlendEquation
-#endif
-#ifndef GL_VERSION_1_5
-#define GL_VERSION_1_5 1
-GLAPI int GLAD_GL_VERSION_1_5;
-typedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint* ids);
-GLAPI PFNGLGENQUERIESPROC glad_glGenQueries;
-#define glGenQueries glad_glGenQueries
-typedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint* ids);
-GLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-#define glDeleteQueries glad_glDeleteQueries
-typedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint id);
-GLAPI PFNGLISQUERYPROC glad_glIsQuery;
-#define glIsQuery glad_glIsQuery
-typedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
-GLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery;
-#define glBeginQuery glad_glBeginQuery
-typedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum target);
-GLAPI PFNGLENDQUERYPROC glad_glEndQuery;
-#define glEndQuery glad_glEndQuery
-typedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-#define glGetQueryiv glad_glGetQueryiv
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint* params);
-GLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-#define glGetQueryObjectiv glad_glGetQueryObjectiv
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint* params);
-GLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
-typedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
-GLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer;
-#define glBindBuffer glad_glBindBuffer
-typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint* buffers);
-GLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-#define glDeleteBuffers glad_glDeleteBuffers
-typedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers);
-GLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers;
-#define glGenBuffers glad_glGenBuffers
-typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer);
-GLAPI PFNGLISBUFFERPROC glad_glIsBuffer;
-#define glIsBuffer glad_glIsBuffer
-typedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
-GLAPI PFNGLBUFFERDATAPROC glad_glBufferData;
-#define glBufferData glad_glBufferData
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
-GLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-#define glBufferSubData glad_glBufferSubData
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void* data);
-GLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-#define glGetBufferSubData glad_glGetBufferSubData
-typedef void* (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
-GLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer;
-#define glMapBuffer glad_glMapBuffer
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target);
-GLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-#define glUnmapBuffer glad_glUnmapBuffer
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-#define glGetBufferParameteriv glad_glGetBufferParameteriv
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void** params);
-GLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-#define glGetBufferPointerv glad_glGetBufferPointerv
-#endif
-#ifndef GL_VERSION_2_0
-#define GL_VERSION_2_0 1
-GLAPI int GLAD_GL_VERSION_2_0;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-#define glBlendEquationSeparate glad_glBlendEquationSeparate
-typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum* bufs);
-GLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-#define glDrawBuffers glad_glDrawBuffers
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-#define glStencilOpSeparate glad_glStencilOpSeparate
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
-GLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-#define glStencilFuncSeparate glad_glStencilFuncSeparate
-typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
-GLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-#define glStencilMaskSeparate glad_glStencilMaskSeparate
-typedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
-GLAPI PFNGLATTACHSHADERPROC glad_glAttachShader;
-#define glAttachShader glad_glAttachShader
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar* name);
-GLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-#define glBindAttribLocation glad_glBindAttribLocation
-typedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader);
-GLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader;
-#define glCompileShader glad_glCompileShader
-typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)();
-GLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-#define glCreateProgram glad_glCreateProgram
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type);
-GLAPI PFNGLCREATESHADERPROC glad_glCreateShader;
-#define glCreateShader glad_glCreateShader
-typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-#define glDeleteProgram glad_glDeleteProgram
-typedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader);
-GLAPI PFNGLDELETESHADERPROC glad_glDeleteShader;
-#define glDeleteShader glad_glDeleteShader
-typedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
-GLAPI PFNGLDETACHSHADERPROC glad_glDetachShader;
-#define glDetachShader glad_glDetachShader
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
-GLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
-GLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-#define glGetActiveAttrib glad_glGetActiveAttrib
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-#define glGetActiveUniform glad_glGetActiveUniform
-typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
-GLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-#define glGetAttachedShaders glad_glGetAttachedShaders
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-#define glGetAttribLocation glad_glGetAttribLocation
-typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint* params);
-GLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-#define glGetProgramiv glad_glGetProgramiv
-typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
-GLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-#define glGetProgramInfoLog glad_glGetProgramInfoLog
-typedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint* params);
-GLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-#define glGetShaderiv glad_glGetShaderiv
-typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
-GLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-#define glGetShaderInfoLog glad_glGetShaderInfoLog
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source);
-GLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-#define glGetShaderSource glad_glGetShaderSource
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-#define glGetUniformLocation glad_glGetUniformLocation
-typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat* params);
-GLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-#define glGetUniformfv glad_glGetUniformfv
-typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint* params);
-GLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-#define glGetUniformiv glad_glGetUniformiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble* params);
-GLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-#define glGetVertexAttribdv glad_glGetVertexAttribdv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-#define glGetVertexAttribfv glad_glGetVertexAttribfv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-#define glGetVertexAttribiv glad_glGetVertexAttribiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void** pointer);
-GLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint program);
-GLAPI PFNGLISPROGRAMPROC glad_glIsProgram;
-#define glIsProgram glad_glIsProgram
-typedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint shader);
-GLAPI PFNGLISSHADERPROC glad_glIsShader;
-#define glIsShader glad_glIsShader
-typedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program);
-GLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-#define glLinkProgram glad_glLinkProgram
-typedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
-GLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource;
-#define glShaderSource glad_glShaderSource
-typedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram;
-#define glUseProgram glad_glUseProgram
-typedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
-GLAPI PFNGLUNIFORM1FPROC glad_glUniform1f;
-#define glUniform1f glad_glUniform1f
-typedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
-GLAPI PFNGLUNIFORM2FPROC glad_glUniform2f;
-#define glUniform2f glad_glUniform2f
-typedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI PFNGLUNIFORM3FPROC glad_glUniform3f;
-#define glUniform3f glad_glUniform3f
-typedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI PFNGLUNIFORM4FPROC glad_glUniform4f;
-#define glUniform4f glad_glUniform4f
-typedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
-GLAPI PFNGLUNIFORM1IPROC glad_glUniform1i;
-#define glUniform1i glad_glUniform1i
-typedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
-GLAPI PFNGLUNIFORM2IPROC glad_glUniform2i;
-#define glUniform2i glad_glUniform2i
-typedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI PFNGLUNIFORM3IPROC glad_glUniform3i;
-#define glUniform3i glad_glUniform3i
-typedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI PFNGLUNIFORM4IPROC glad_glUniform4i;
-#define glUniform4i glad_glUniform4i
-typedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-#define glUniform1fv glad_glUniform1fv
-typedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-#define glUniform2fv glad_glUniform2fv
-typedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-#define glUniform3fv glad_glUniform3fv
-typedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-#define glUniform4fv glad_glUniform4fv
-typedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-#define glUniform1iv glad_glUniform1iv
-typedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-#define glUniform2iv glad_glUniform2iv
-typedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-#define glUniform3iv glad_glUniform3iv
-typedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-#define glUniform4iv glad_glUniform4iv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-#define glUniformMatrix2fv glad_glUniformMatrix2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-#define glUniformMatrix3fv glad_glUniformMatrix3fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-#define glUniformMatrix4fv glad_glUniformMatrix4fv
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-#define glValidateProgram glad_glValidateProgram
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
-GLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-#define glVertexAttrib1d glad_glVertexAttrib1d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-#define glVertexAttrib1dv glad_glVertexAttrib1dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
-GLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-#define glVertexAttrib1f glad_glVertexAttrib1f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-#define glVertexAttrib1fv glad_glVertexAttrib1fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
-GLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-#define glVertexAttrib1s glad_glVertexAttrib1s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-#define glVertexAttrib1sv glad_glVertexAttrib1sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
-GLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-#define glVertexAttrib2d glad_glVertexAttrib2d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-#define glVertexAttrib2dv glad_glVertexAttrib2dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
-GLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-#define glVertexAttrib2f glad_glVertexAttrib2f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-#define glVertexAttrib2fv glad_glVertexAttrib2fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
-GLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-#define glVertexAttrib2s glad_glVertexAttrib2s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-#define glVertexAttrib2sv glad_glVertexAttrib2sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-#define glVertexAttrib3d glad_glVertexAttrib3d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-#define glVertexAttrib3dv glad_glVertexAttrib3dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-#define glVertexAttrib3f glad_glVertexAttrib3f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-#define glVertexAttrib3fv glad_glVertexAttrib3fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-#define glVertexAttrib3s glad_glVertexAttrib3s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-#define glVertexAttrib3sv glad_glVertexAttrib3sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-#define glVertexAttrib4bv glad_glVertexAttrib4bv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-#define glVertexAttrib4d glad_glVertexAttrib4d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-#define glVertexAttrib4dv glad_glVertexAttrib4dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-#define glVertexAttrib4f glad_glVertexAttrib4f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-#define glVertexAttrib4fv glad_glVertexAttrib4fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-#define glVertexAttrib4iv glad_glVertexAttrib4iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-#define glVertexAttrib4s glad_glVertexAttrib4s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-#define glVertexAttrib4sv glad_glVertexAttrib4sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-#define glVertexAttrib4usv glad_glVertexAttrib4usv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-#define glVertexAttribPointer glad_glVertexAttribPointer
-#endif
-#ifndef GL_VERSION_2_1
-#define GL_VERSION_2_1 1
-GLAPI int GLAD_GL_VERSION_2_1;
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
-#endif
-#ifndef GL_VERSION_3_0
-#define GL_VERSION_3_0 1
-GLAPI int GLAD_GL_VERSION_3_0;
-typedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-GLAPI PFNGLCOLORMASKIPROC glad_glColorMaski;
-#define glColorMaski glad_glColorMaski
-typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean* data);
-GLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-#define glGetBooleani_v glad_glGetBooleani_v
-typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint* data);
-GLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-#define glGetIntegeri_v glad_glGetIntegeri_v
-typedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLENABLEIPROC glad_glEnablei;
-#define glEnablei glad_glEnablei
-typedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLDISABLEIPROC glad_glDisablei;
-#define glDisablei glad_glDisablei
-typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi;
-#define glIsEnabledi glad_glIsEnabledi
-typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
-GLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-#define glBeginTransformFeedback glad_glBeginTransformFeedback
-typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)();
-GLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-#define glEndTransformFeedback glad_glEndTransformFeedback
-typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-#define glBindBufferRange glad_glBindBufferRange
-typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
-GLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-#define glBindBufferBase glad_glBindBufferBase
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar** varyings, GLenum bufferMode);
-GLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
-typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
-typedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
-GLAPI PFNGLCLAMPCOLORPROC glad_glClampColor;
-#define glClampColor glad_glClampColor
-typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
-GLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-#define glBeginConditionalRender glad_glBeginConditionalRender
-typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)();
-GLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-#define glEndConditionalRender glad_glEndConditionalRender
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-#define glVertexAttribIPointer glad_glVertexAttribIPointer
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint* params);
-GLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
-GLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-#define glVertexAttribI1i glad_glVertexAttribI1i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
-GLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-#define glVertexAttribI2i glad_glVertexAttribI2i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
-GLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-#define glVertexAttribI3i glad_glVertexAttribI3i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-#define glVertexAttribI4i glad_glVertexAttribI4i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
-GLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-#define glVertexAttribI1ui glad_glVertexAttribI1ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
-GLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-#define glVertexAttribI2ui glad_glVertexAttribI2ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
-GLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-#define glVertexAttribI3ui glad_glVertexAttribI3ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-#define glVertexAttribI4ui glad_glVertexAttribI4ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-#define glVertexAttribI1iv glad_glVertexAttribI1iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-#define glVertexAttribI2iv glad_glVertexAttribI2iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-#define glVertexAttribI3iv glad_glVertexAttribI3iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-#define glVertexAttribI4iv glad_glVertexAttribI4iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-#define glVertexAttribI4bv glad_glVertexAttribI4bv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-#define glVertexAttribI4sv glad_glVertexAttribI4sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-#define glVertexAttribI4usv glad_glVertexAttribI4usv
-typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint* params);
-GLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-#define glGetUniformuiv glad_glGetUniformuiv
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar* name);
-GLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-#define glBindFragDataLocation glad_glBindFragDataLocation
-typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-#define glGetFragDataLocation glad_glGetFragDataLocation
-typedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
-GLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-#define glUniform1ui glad_glUniform1ui
-typedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
-GLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-#define glUniform2ui glad_glUniform2ui
-typedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-#define glUniform3ui glad_glUniform3ui
-typedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-#define glUniform4ui glad_glUniform4ui
-typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-#define glUniform1uiv glad_glUniform1uiv
-typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-#define glUniform2uiv glad_glUniform2uiv
-typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-#define glUniform3uiv glad_glUniform3uiv
-typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-#define glUniform4uiv glad_glUniform4uiv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint* params);
-GLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-#define glTexParameterIiv glad_glTexParameterIiv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint* params);
-GLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-#define glTexParameterIuiv glad_glTexParameterIuiv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-#define glGetTexParameterIiv glad_glGetTexParameterIiv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint* params);
-GLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint* value);
-GLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-#define glClearBufferiv glad_glClearBufferiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint* value);
-GLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-#define glClearBufferuiv glad_glClearBufferuiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat* value);
-GLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-#define glClearBufferfv glad_glClearBufferfv
-typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-GLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-#define glClearBufferfi glad_glClearBufferfi
-typedef const GLubyte* (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
-GLAPI PFNGLGETSTRINGIPROC glad_glGetStringi;
-#define glGetStringi glad_glGetStringi
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
-GLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-#define glIsRenderbuffer glad_glIsRenderbuffer
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
-GLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-#define glBindRenderbuffer glad_glBindRenderbuffer
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint* renderbuffers);
-GLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint* renderbuffers);
-GLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-#define glGenRenderbuffers glad_glGenRenderbuffers
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-#define glRenderbufferStorage glad_glRenderbufferStorage
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
-GLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-#define glIsFramebuffer glad_glIsFramebuffer
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
-GLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-#define glBindFramebuffer glad_glBindFramebuffer
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint* framebuffers);
-GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-#define glDeleteFramebuffers glad_glDeleteFramebuffers
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint* framebuffers);
-GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-#define glGenFramebuffers glad_glGenFramebuffers
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
-GLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-#define glFramebufferTexture1D glad_glFramebufferTexture1D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-#define glFramebufferTexture2D glad_glFramebufferTexture2D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-#define glFramebufferTexture3D glad_glFramebufferTexture3D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target);
-GLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-#define glGenerateMipmap glad_glGenerateMipmap
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-#define glBlitFramebuffer glad_glBlitFramebuffer
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
-typedef void* (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-#define glMapBufferRange glad_glMapBufferRange
-typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
-GLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
-typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array);
-GLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-#define glBindVertexArray glad_glBindVertexArray
-typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint* arrays);
-GLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-#define glDeleteVertexArrays glad_glDeleteVertexArrays
-typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint* arrays);
-GLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-#define glGenVertexArrays glad_glGenVertexArrays
-typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array);
-GLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-#define glIsVertexArray glad_glIsVertexArray
-#endif
-#ifndef GL_VERSION_3_1
-#define GL_VERSION_3_1 1
-GLAPI int GLAD_GL_VERSION_3_1;
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
-GLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-#define glDrawArraysInstanced glad_glDrawArraysInstanced
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount);
-GLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-#define glDrawElementsInstanced glad_glDrawElementsInstanced
-typedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
-GLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer;
-#define glTexBuffer glad_glTexBuffer
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
-GLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
-typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-GLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-#define glCopyBufferSubData glad_glCopyBufferSubData
-typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar** uniformNames, GLuint* uniformIndices);
-GLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-#define glGetUniformIndices glad_glGetUniformIndices
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
-GLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName);
-GLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-#define glGetActiveUniformName glad_glGetActiveUniformName
-typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar* uniformBlockName);
-GLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
-GLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
-GLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
-typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-GLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-#define glUniformBlockBinding glad_glUniformBlockBinding
-#endif
-#ifndef GL_VERSION_3_2
-#define GL_VERSION_3_2 1
-GLAPI int GLAD_GL_VERSION_3_2;
-typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLint basevertex);
-GLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices, GLint basevertex);
-GLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLint basevertex);
-GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei* count, GLenum type, const void** indices, GLsizei drawcount, const GLint* basevertex);
-GLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
-typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
-GLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-#define glProvokingVertex glad_glProvokingVertex
-typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
-GLAPI PFNGLFENCESYNCPROC glad_glFenceSync;
-#define glFenceSync glad_glFenceSync
-typedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync sync);
-GLAPI PFNGLISSYNCPROC glad_glIsSync;
-#define glIsSync glad_glIsSync
-typedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync);
-GLAPI PFNGLDELETESYNCPROC glad_glDeleteSync;
-#define glDeleteSync glad_glDeleteSync
-typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-#define glClientWaitSync glad_glClientWaitSync
-typedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI PFNGLWAITSYNCPROC glad_glWaitSync;
-#define glWaitSync glad_glWaitSync
-typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64* data);
-GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-#define glGetInteger64v glad_glGetInteger64v
-typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
-GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv;
-#define glGetSynciv glad_glGetSynciv
-typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64* data);
-GLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-#define glGetInteger64i_v glad_glGetInteger64i_v
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64* params);
-GLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-#define glFramebufferTexture glad_glFramebufferTexture
-typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
-GLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-#define glTexImage2DMultisample glad_glTexImage2DMultisample
-typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
-GLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-#define glTexImage3DMultisample glad_glTexImage3DMultisample
-typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat* val);
-GLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-#define glGetMultisamplefv glad_glGetMultisamplefv
-typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
-GLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-#define glSampleMaski glad_glSampleMaski
-#endif
-#ifndef GL_VERSION_3_3
-#define GL_VERSION_3_3 1
-GLAPI int GLAD_GL_VERSION_3_3;
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar* name);
-GLAPI PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
-typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-#define glGetFragDataIndex glad_glGetFragDataIndex
-typedef void (APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint* samplers);
-GLAPI PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-#define glGenSamplers glad_glGenSamplers
-typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint* samplers);
-GLAPI PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-#define glDeleteSamplers glad_glDeleteSamplers
-typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler);
-GLAPI PFNGLISSAMPLERPROC glad_glIsSampler;
-#define glIsSampler glad_glIsSampler
-typedef void (APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
-GLAPI PFNGLBINDSAMPLERPROC glad_glBindSampler;
-#define glBindSampler glad_glBindSampler
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
-GLAPI PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-#define glSamplerParameteri glad_glSamplerParameteri
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint* param);
-GLAPI PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-#define glSamplerParameteriv glad_glSamplerParameteriv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
-GLAPI PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-#define glSamplerParameterf glad_glSamplerParameterf
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat* param);
-GLAPI PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-#define glSamplerParameterfv glad_glSamplerParameterfv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint* param);
-GLAPI PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-#define glSamplerParameterIiv glad_glSamplerParameterIiv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint* param);
-GLAPI PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
-typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
-GLAPI PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-#define glQueryCounter glad_glQueryCounter
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64* params);
-GLAPI PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64* params);
-GLAPI PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
-typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
-GLAPI PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-#define glVertexAttribDivisor glad_glVertexAttribDivisor
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-#define glVertexAttribP1ui glad_glVertexAttribP1ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-#define glVertexAttribP2ui glad_glVertexAttribP2ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-#define glVertexAttribP3ui glad_glVertexAttribP3ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-#define glVertexAttribP4ui glad_glVertexAttribP4ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
-typedef void (APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-#define glVertexP2ui glad_glVertexP2ui
-typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-#define glVertexP2uiv glad_glVertexP2uiv
-typedef void (APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-#define glVertexP3ui glad_glVertexP3ui
-typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-#define glVertexP3uiv glad_glVertexP3uiv
-typedef void (APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-#define glVertexP4ui glad_glVertexP4ui
-typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-#define glVertexP4uiv glad_glVertexP4uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-#define glTexCoordP1ui glad_glTexCoordP1ui
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-#define glTexCoordP1uiv glad_glTexCoordP1uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-#define glTexCoordP2ui glad_glTexCoordP2ui
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-#define glTexCoordP2uiv glad_glTexCoordP2uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-#define glTexCoordP3ui glad_glTexCoordP3ui
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-#define glTexCoordP3uiv glad_glTexCoordP3uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-#define glTexCoordP4ui glad_glTexCoordP4ui
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-#define glTexCoordP4uiv glad_glTexCoordP4uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
-typedef void (APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-#define glNormalP3ui glad_glNormalP3ui
-typedef void (APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-#define glNormalP3uiv glad_glNormalP3uiv
-typedef void (APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLCOLORP3UIPROC glad_glColorP3ui;
-#define glColorP3ui glad_glColorP3ui
-typedef void (APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-#define glColorP3uiv glad_glColorP3uiv
-typedef void (APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLCOLORP4UIPROC glad_glColorP4ui;
-#define glColorP4ui glad_glColorP4ui
-typedef void (APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-#define glColorP4uiv glad_glColorP4uiv
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
-#endif
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145
-#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147
-#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148
-#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149
-#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A
-#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B
-#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C
-#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D
-#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E
-#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F
-#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150
-#define GL_QUERY_BUFFER_AMD 0x9192
-#define GL_QUERY_BUFFER_BINDING_AMD 0x9193
-#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194
-#define GL_FIXED 0x140C
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_LOW_INT 0x8DF3
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_HIGH_INT 0x8DF5
-#define GL_SHADER_COMPILER 0x8DFA
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_RGB565 0x8D62
-#define GL_COMPRESSED_RGB8_ETC2 0x9274
-#define GL_COMPRESSED_SRGB8_ETC2 0x9275
-#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
-#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
-#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
-#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
-#define GL_COMPRESSED_R11_EAC 0x9270
-#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
-#define GL_COMPRESSED_RG11_EAC 0x9272
-#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
-#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
-#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
-#define GL_MAX_ELEMENT_INDEX 0x8D6B
-#define GL_MAP_PERSISTENT_BIT 0x0040
-#define GL_MAP_COHERENT_BIT 0x0080
-#define GL_DYNAMIC_STORAGE_BIT 0x0100
-#define GL_CLIENT_STORAGE_BIT 0x0200
-#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
-#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
-#define GL_BUFFER_STORAGE_FLAGS 0x8220
-#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
-#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
-#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
-#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
-#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
-#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
-#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
-#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
-#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
-#define GL_DEBUG_SOURCE_API_ARB 0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
-#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
-#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
-#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
-#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145
-#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
-#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
-#define GL_DEPTH_COMPONENT16_ARB 0x81A5
-#define GL_DEPTH_COMPONENT24_ARB 0x81A6
-#define GL_DEPTH_COMPONENT32_ARB 0x81A7
-#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
-#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
-#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
-#define GL_DRAW_BUFFER0_ARB 0x8825
-#define GL_DRAW_BUFFER1_ARB 0x8826
-#define GL_DRAW_BUFFER2_ARB 0x8827
-#define GL_DRAW_BUFFER3_ARB 0x8828
-#define GL_DRAW_BUFFER4_ARB 0x8829
-#define GL_DRAW_BUFFER5_ARB 0x882A
-#define GL_DRAW_BUFFER6_ARB 0x882B
-#define GL_DRAW_BUFFER7_ARB 0x882C
-#define GL_DRAW_BUFFER8_ARB 0x882D
-#define GL_DRAW_BUFFER9_ARB 0x882E
-#define GL_DRAW_BUFFER10_ARB 0x882F
-#define GL_DRAW_BUFFER11_ARB 0x8830
-#define GL_DRAW_BUFFER12_ARB 0x8831
-#define GL_DRAW_BUFFER13_ARB 0x8832
-#define GL_DRAW_BUFFER14_ARB 0x8833
-#define GL_DRAW_BUFFER15_ARB 0x8834
-#define GL_MAX_UNIFORM_LOCATIONS 0x826E
-#define GL_FRAGMENT_PROGRAM_ARB 0x8804
-#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
-#define GL_PROGRAM_LENGTH_ARB 0x8627
-#define GL_PROGRAM_FORMAT_ARB 0x8876
-#define GL_PROGRAM_BINDING_ARB 0x8677
-#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
-#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
-#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
-#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
-#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
-#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
-#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
-#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
-#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
-#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
-#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
-#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
-#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
-#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
-#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
-#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
-#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
-#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
-#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
-#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
-#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
-#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
-#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
-#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
-#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
-#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
-#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
-#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
-#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
-#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
-#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
-#define GL_PROGRAM_STRING_ARB 0x8628
-#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
-#define GL_CURRENT_MATRIX_ARB 0x8641
-#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
-#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
-#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
-#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
-#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
-#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
-#define GL_MATRIX0_ARB 0x88C0
-#define GL_MATRIX1_ARB 0x88C1
-#define GL_MATRIX2_ARB 0x88C2
-#define GL_MATRIX3_ARB 0x88C3
-#define GL_MATRIX4_ARB 0x88C4
-#define GL_MATRIX5_ARB 0x88C5
-#define GL_MATRIX6_ARB 0x88C6
-#define GL_MATRIX7_ARB 0x88C7
-#define GL_MATRIX8_ARB 0x88C8
-#define GL_MATRIX9_ARB 0x88C9
-#define GL_MATRIX10_ARB 0x88CA
-#define GL_MATRIX11_ARB 0x88CB
-#define GL_MATRIX12_ARB 0x88CC
-#define GL_MATRIX13_ARB 0x88CD
-#define GL_MATRIX14_ARB 0x88CE
-#define GL_MATRIX15_ARB 0x88CF
-#define GL_MATRIX16_ARB 0x88D0
-#define GL_MATRIX17_ARB 0x88D1
-#define GL_MATRIX18_ARB 0x88D2
-#define GL_MATRIX19_ARB 0x88D3
-#define GL_MATRIX20_ARB 0x88D4
-#define GL_MATRIX21_ARB 0x88D5
-#define GL_MATRIX22_ARB 0x88D6
-#define GL_MATRIX23_ARB 0x88D7
-#define GL_MATRIX24_ARB 0x88D8
-#define GL_MATRIX25_ARB 0x88D9
-#define GL_MATRIX26_ARB 0x88DA
-#define GL_MATRIX27_ARB 0x88DB
-#define GL_MATRIX28_ARB 0x88DC
-#define GL_MATRIX29_ARB 0x88DD
-#define GL_MATRIX30_ARB 0x88DE
-#define GL_MATRIX31_ARB 0x88DF
-#define GL_FRAGMENT_SHADER_ARB 0x8B30
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
-#define GL_MULTISAMPLE_ARB 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
-#define GL_SAMPLE_COVERAGE_ARB 0x80A0
-#define GL_SAMPLE_BUFFERS_ARB 0x80A8
-#define GL_SAMPLES_ARB 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
-#define GL_MULTISAMPLE_BIT_ARB 0x20000000
-#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D
-#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E
-#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F
-#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340
-#define GL_SAMPLE_LOCATION_ARB 0x8E50
-#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341
-#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342
-#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343
-#define GL_COMPRESSED_ALPHA_ARB 0x84E9
-#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
-#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
-#define GL_COMPRESSED_RGB_ARB 0x84ED
-#define GL_COMPRESSED_RGBA_ARB 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
-#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
-#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
-#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
-#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
-#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
-#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
-#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
-#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
-#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
-#define GL_RGBA32F_ARB 0x8814
-#define GL_RGB32F_ARB 0x8815
-#define GL_ALPHA32F_ARB 0x8816
-#define GL_INTENSITY32F_ARB 0x8817
-#define GL_LUMINANCE32F_ARB 0x8818
-#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
-#define GL_RGBA16F_ARB 0x881A
-#define GL_RGB16F_ARB 0x881B
-#define GL_ALPHA16F_ARB 0x881C
-#define GL_INTENSITY16F_ARB 0x881D
-#define GL_LUMINANCE16F_ARB 0x881E
-#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
-#define GL_VERTEX_ATTRIB_BINDING 0x82D4
-#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
-#define GL_VERTEX_BINDING_DIVISOR 0x82D6
-#define GL_VERTEX_BINDING_OFFSET 0x82D7
-#define GL_VERTEX_BINDING_STRIDE 0x82D8
-#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
-#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA
-#define GL_BUFFER_SIZE_ARB 0x8764
-#define GL_BUFFER_USAGE_ARB 0x8765
-#define GL_ARRAY_BUFFER_ARB 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
-#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
-#define GL_READ_ONLY_ARB 0x88B8
-#define GL_WRITE_ONLY_ARB 0x88B9
-#define GL_READ_WRITE_ARB 0x88BA
-#define GL_BUFFER_ACCESS_ARB 0x88BB
-#define GL_BUFFER_MAPPED_ARB 0x88BC
-#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
-#define GL_STREAM_DRAW_ARB 0x88E0
-#define GL_STREAM_READ_ARB 0x88E1
-#define GL_STREAM_COPY_ARB 0x88E2
-#define GL_STATIC_DRAW_ARB 0x88E4
-#define GL_STATIC_READ_ARB 0x88E5
-#define GL_STATIC_COPY_ARB 0x88E6
-#define GL_DYNAMIC_DRAW_ARB 0x88E8
-#define GL_DYNAMIC_READ_ARB 0x88E9
-#define GL_DYNAMIC_COPY_ARB 0x88EA
-#define GL_COLOR_SUM_ARB 0x8458
-#define GL_VERTEX_PROGRAM_ARB 0x8620
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
-#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
-#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
-#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
-#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
-#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
-#define GL_VERTEX_SHADER_ARB 0x8B31
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
-#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
-#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
-#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
-#define GL_FLOAT_VEC2_ARB 0x8B50
-#define GL_FLOAT_VEC3_ARB 0x8B51
-#define GL_FLOAT_VEC4_ARB 0x8B52
-#define GL_FLOAT_MAT2_ARB 0x8B5A
-#define GL_FLOAT_MAT3_ARB 0x8B5B
-#define GL_FLOAT_MAT4_ARB 0x8B5C
-#define GL_ELEMENT_ARRAY_ATI 0x8768
-#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
-#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
-#define GL_FRAGMENT_SHADER_ATI 0x8920
-#define GL_REG_0_ATI 0x8921
-#define GL_REG_1_ATI 0x8922
-#define GL_REG_2_ATI 0x8923
-#define GL_REG_3_ATI 0x8924
-#define GL_REG_4_ATI 0x8925
-#define GL_REG_5_ATI 0x8926
-#define GL_REG_6_ATI 0x8927
-#define GL_REG_7_ATI 0x8928
-#define GL_REG_8_ATI 0x8929
-#define GL_REG_9_ATI 0x892A
-#define GL_REG_10_ATI 0x892B
-#define GL_REG_11_ATI 0x892C
-#define GL_REG_12_ATI 0x892D
-#define GL_REG_13_ATI 0x892E
-#define GL_REG_14_ATI 0x892F
-#define GL_REG_15_ATI 0x8930
-#define GL_REG_16_ATI 0x8931
-#define GL_REG_17_ATI 0x8932
-#define GL_REG_18_ATI 0x8933
-#define GL_REG_19_ATI 0x8934
-#define GL_REG_20_ATI 0x8935
-#define GL_REG_21_ATI 0x8936
-#define GL_REG_22_ATI 0x8937
-#define GL_REG_23_ATI 0x8938
-#define GL_REG_24_ATI 0x8939
-#define GL_REG_25_ATI 0x893A
-#define GL_REG_26_ATI 0x893B
-#define GL_REG_27_ATI 0x893C
-#define GL_REG_28_ATI 0x893D
-#define GL_REG_29_ATI 0x893E
-#define GL_REG_30_ATI 0x893F
-#define GL_REG_31_ATI 0x8940
-#define GL_CON_0_ATI 0x8941
-#define GL_CON_1_ATI 0x8942
-#define GL_CON_2_ATI 0x8943
-#define GL_CON_3_ATI 0x8944
-#define GL_CON_4_ATI 0x8945
-#define GL_CON_5_ATI 0x8946
-#define GL_CON_6_ATI 0x8947
-#define GL_CON_7_ATI 0x8948
-#define GL_CON_8_ATI 0x8949
-#define GL_CON_9_ATI 0x894A
-#define GL_CON_10_ATI 0x894B
-#define GL_CON_11_ATI 0x894C
-#define GL_CON_12_ATI 0x894D
-#define GL_CON_13_ATI 0x894E
-#define GL_CON_14_ATI 0x894F
-#define GL_CON_15_ATI 0x8950
-#define GL_CON_16_ATI 0x8951
-#define GL_CON_17_ATI 0x8952
-#define GL_CON_18_ATI 0x8953
-#define GL_CON_19_ATI 0x8954
-#define GL_CON_20_ATI 0x8955
-#define GL_CON_21_ATI 0x8956
-#define GL_CON_22_ATI 0x8957
-#define GL_CON_23_ATI 0x8958
-#define GL_CON_24_ATI 0x8959
-#define GL_CON_25_ATI 0x895A
-#define GL_CON_26_ATI 0x895B
-#define GL_CON_27_ATI 0x895C
-#define GL_CON_28_ATI 0x895D
-#define GL_CON_29_ATI 0x895E
-#define GL_CON_30_ATI 0x895F
-#define GL_CON_31_ATI 0x8960
-#define GL_MOV_ATI 0x8961
-#define GL_ADD_ATI 0x8963
-#define GL_MUL_ATI 0x8964
-#define GL_SUB_ATI 0x8965
-#define GL_DOT3_ATI 0x8966
-#define GL_DOT4_ATI 0x8967
-#define GL_MAD_ATI 0x8968
-#define GL_LERP_ATI 0x8969
-#define GL_CND_ATI 0x896A
-#define GL_CND0_ATI 0x896B
-#define GL_DOT2_ADD_ATI 0x896C
-#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
-#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
-#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
-#define GL_NUM_PASSES_ATI 0x8970
-#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
-#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
-#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
-#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
-#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
-#define GL_SWIZZLE_STR_ATI 0x8976
-#define GL_SWIZZLE_STQ_ATI 0x8977
-#define GL_SWIZZLE_STR_DR_ATI 0x8978
-#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
-#define GL_SWIZZLE_STRQ_ATI 0x897A
-#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
-#define GL_RED_BIT_ATI 0x00000001
-#define GL_GREEN_BIT_ATI 0x00000002
-#define GL_BLUE_BIT_ATI 0x00000004
-#define GL_2X_BIT_ATI 0x00000001
-#define GL_4X_BIT_ATI 0x00000002
-#define GL_8X_BIT_ATI 0x00000004
-#define GL_HALF_BIT_ATI 0x00000008
-#define GL_QUARTER_BIT_ATI 0x00000010
-#define GL_EIGHTH_BIT_ATI 0x00000020
-#define GL_SATURATE_BIT_ATI 0x00000040
-#define GL_COMP_BIT_ATI 0x00000002
-#define GL_NEGATE_BIT_ATI 0x00000004
-#define GL_BIAS_BIT_ATI 0x00000008
-#define GL_STATIC_ATI 0x8760
-#define GL_DYNAMIC_ATI 0x8761
-#define GL_PRESERVE_ATI 0x8762
-#define GL_DISCARD_ATI 0x8763
-#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
-#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
-#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
-#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
-#define GL_CONSTANT_COLOR_EXT 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
-#define GL_CONSTANT_ALPHA_EXT 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
-#define GL_BLEND_COLOR_EXT 0x8005
-#define GL_BLEND_EQUATION_RGB_EXT 0x8009
-#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
-#define GL_BLEND_DST_RGB_EXT 0x80C8
-#define GL_BLEND_SRC_RGB_EXT 0x80C9
-#define GL_BLEND_DST_ALPHA_EXT 0x80CA
-#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
-#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
-#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#define GL_MAX_SAMPLES_EXT 0x8D57
-#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
-#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB
-#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
-#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
-#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
-#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
-#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
-#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
-#define GL_FRAMEBUFFER_EXT 0x8D40
-#define GL_RENDERBUFFER_EXT 0x8D41
-#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
-#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
-#define GL_STENCIL_INDEX1_EXT 0x8D46
-#define GL_STENCIL_INDEX4_EXT 0x8D47
-#define GL_STENCIL_INDEX8_EXT 0x8D48
-#define GL_STENCIL_INDEX16_EXT 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
-#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
-#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
-#define GL_IUI_V2F_EXT 0x81AD
-#define GL_IUI_V3F_EXT 0x81AE
-#define GL_IUI_N3F_V2F_EXT 0x81AF
-#define GL_IUI_N3F_V3F_EXT 0x81B0
-#define GL_T2F_IUI_V2F_EXT 0x81B1
-#define GL_T2F_IUI_V3F_EXT 0x81B2
-#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
-#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
-#define GL_ALPHA4_EXT 0x803B
-#define GL_ALPHA8_EXT 0x803C
-#define GL_ALPHA12_EXT 0x803D
-#define GL_ALPHA16_EXT 0x803E
-#define GL_LUMINANCE4_EXT 0x803F
-#define GL_LUMINANCE8_EXT 0x8040
-#define GL_LUMINANCE12_EXT 0x8041
-#define GL_LUMINANCE16_EXT 0x8042
-#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
-#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
-#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
-#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
-#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
-#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
-#define GL_INTENSITY_EXT 0x8049
-#define GL_INTENSITY4_EXT 0x804A
-#define GL_INTENSITY8_EXT 0x804B
-#define GL_INTENSITY12_EXT 0x804C
-#define GL_INTENSITY16_EXT 0x804D
-#define GL_RGB2_EXT 0x804E
-#define GL_RGB4_EXT 0x804F
-#define GL_RGB5_EXT 0x8050
-#define GL_RGB8_EXT 0x8051
-#define GL_RGB10_EXT 0x8052
-#define GL_RGB12_EXT 0x8053
-#define GL_RGB16_EXT 0x8054
-#define GL_RGBA2_EXT 0x8055
-#define GL_RGBA4_EXT 0x8056
-#define GL_RGB5_A1_EXT 0x8057
-#define GL_RGBA8_EXT 0x8058
-#define GL_RGB10_A2_EXT 0x8059
-#define GL_RGBA12_EXT 0x805A
-#define GL_RGBA16_EXT 0x805B
-#define GL_TEXTURE_RED_SIZE_EXT 0x805C
-#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
-#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
-#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
-#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
-#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
-#define GL_REPLACE_EXT 0x8062
-#define GL_PROXY_TEXTURE_1D_EXT 0x8063
-#define GL_PROXY_TEXTURE_2D_EXT 0x8064
-#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#define GL_SRGB_EXT 0x8C40
-#define GL_SRGB8_EXT 0x8C41
-#define GL_SRGB_ALPHA_EXT 0x8C42
-#define GL_SRGB8_ALPHA8_EXT 0x8C43
-#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
-#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
-#define GL_SLUMINANCE_EXT 0x8C46
-#define GL_SLUMINANCE8_EXT 0x8C47
-#define GL_COMPRESSED_SRGB_EXT 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
-#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
-#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
-#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42
-#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43
-#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44
-#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46
-#define GL_VERTEX_ARRAY_EXT 0x8074
-#define GL_NORMAL_ARRAY_EXT 0x8075
-#define GL_COLOR_ARRAY_EXT 0x8076
-#define GL_INDEX_ARRAY_EXT 0x8077
-#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
-#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
-#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
-#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
-#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
-#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
-#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
-#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
-#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
-#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
-#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
-#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
-#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
-#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
-#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
-#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
-#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
-#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
-#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
-#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
-#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
-#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
-#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
-#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
-#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
-#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
-#define GL_VERTEX_SHADER_EXT 0x8780
-#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
-#define GL_OP_INDEX_EXT 0x8782
-#define GL_OP_NEGATE_EXT 0x8783
-#define GL_OP_DOT3_EXT 0x8784
-#define GL_OP_DOT4_EXT 0x8785
-#define GL_OP_MUL_EXT 0x8786
-#define GL_OP_ADD_EXT 0x8787
-#define GL_OP_MADD_EXT 0x8788
-#define GL_OP_FRAC_EXT 0x8789
-#define GL_OP_MAX_EXT 0x878A
-#define GL_OP_MIN_EXT 0x878B
-#define GL_OP_SET_GE_EXT 0x878C
-#define GL_OP_SET_LT_EXT 0x878D
-#define GL_OP_CLAMP_EXT 0x878E
-#define GL_OP_FLOOR_EXT 0x878F
-#define GL_OP_ROUND_EXT 0x8790
-#define GL_OP_EXP_BASE_2_EXT 0x8791
-#define GL_OP_LOG_BASE_2_EXT 0x8792
-#define GL_OP_POWER_EXT 0x8793
-#define GL_OP_RECIP_EXT 0x8794
-#define GL_OP_RECIP_SQRT_EXT 0x8795
-#define GL_OP_SUB_EXT 0x8796
-#define GL_OP_CROSS_PRODUCT_EXT 0x8797
-#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
-#define GL_OP_MOV_EXT 0x8799
-#define GL_OUTPUT_VERTEX_EXT 0x879A
-#define GL_OUTPUT_COLOR0_EXT 0x879B
-#define GL_OUTPUT_COLOR1_EXT 0x879C
-#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
-#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
-#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
-#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
-#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
-#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
-#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
-#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
-#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
-#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
-#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
-#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
-#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
-#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
-#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
-#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
-#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
-#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
-#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
-#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
-#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
-#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
-#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
-#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
-#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
-#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
-#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
-#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
-#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
-#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
-#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
-#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
-#define GL_OUTPUT_FOG_EXT 0x87BD
-#define GL_SCALAR_EXT 0x87BE
-#define GL_VECTOR_EXT 0x87BF
-#define GL_MATRIX_EXT 0x87C0
-#define GL_VARIANT_EXT 0x87C1
-#define GL_INVARIANT_EXT 0x87C2
-#define GL_LOCAL_CONSTANT_EXT 0x87C3
-#define GL_LOCAL_EXT 0x87C4
-#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
-#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
-#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
-#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
-#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
-#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
-#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
-#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
-#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
-#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
-#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
-#define GL_X_EXT 0x87D5
-#define GL_Y_EXT 0x87D6
-#define GL_Z_EXT 0x87D7
-#define GL_W_EXT 0x87D8
-#define GL_NEGATIVE_X_EXT 0x87D9
-#define GL_NEGATIVE_Y_EXT 0x87DA
-#define GL_NEGATIVE_Z_EXT 0x87DB
-#define GL_NEGATIVE_W_EXT 0x87DC
-#define GL_ZERO_EXT 0x87DD
-#define GL_ONE_EXT 0x87DE
-#define GL_NEGATIVE_ONE_EXT 0x87DF
-#define GL_NORMALIZED_RANGE_EXT 0x87E0
-#define GL_FULL_RANGE_EXT 0x87E1
-#define GL_CURRENT_VERTEX_EXT 0x87E2
-#define GL_MVP_MATRIX_EXT 0x87E3
-#define GL_VARIANT_VALUE_EXT 0x87E4
-#define GL_VARIANT_DATATYPE_EXT 0x87E5
-#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
-#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
-#define GL_VARIANT_ARRAY_EXT 0x87E8
-#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
-#define GL_INVARIANT_VALUE_EXT 0x87EA
-#define GL_INVARIANT_DATATYPE_EXT 0x87EB
-#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
-#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
-#ifndef GL_AMD_debug_output
-#define GL_AMD_debug_output 1
-GLAPI int GLAD_GL_AMD_debug_output;
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC)(GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
-GLAPI PFNGLDEBUGMESSAGEENABLEAMDPROC glad_glDebugMessageEnableAMD;
-#define glDebugMessageEnableAMD glad_glDebugMessageEnableAMD
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC)(GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf);
-GLAPI PFNGLDEBUGMESSAGEINSERTAMDPROC glad_glDebugMessageInsertAMD;
-#define glDebugMessageInsertAMD glad_glDebugMessageInsertAMD
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC)(GLDEBUGPROCAMD callback, void* userParam);
-GLAPI PFNGLDEBUGMESSAGECALLBACKAMDPROC glad_glDebugMessageCallbackAMD;
-#define glDebugMessageCallbackAMD glad_glDebugMessageCallbackAMD
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC)(GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message);
-GLAPI PFNGLGETDEBUGMESSAGELOGAMDPROC glad_glGetDebugMessageLogAMD;
-#define glGetDebugMessageLogAMD glad_glGetDebugMessageLogAMD
-#endif
-#ifndef GL_AMD_query_buffer_object
-#define GL_AMD_query_buffer_object 1
-GLAPI int GLAD_GL_AMD_query_buffer_object;
-#endif
-#ifndef GL_ARB_ES2_compatibility
-#define GL_ARB_ES2_compatibility 1
-GLAPI int GLAD_GL_ARB_ES2_compatibility;
-typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)();
-GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
-#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
-typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length);
-GLAPI PFNGLSHADERBINARYPROC glad_glShaderBinary;
-#define glShaderBinary glad_glShaderBinary
-typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-GLAPI PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
-#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
-typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
-GLAPI PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
-#define glDepthRangef glad_glDepthRangef
-typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d);
-GLAPI PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
-#define glClearDepthf glad_glClearDepthf
-#endif
-#ifndef GL_ARB_ES3_compatibility
-#define GL_ARB_ES3_compatibility 1
-GLAPI int GLAD_GL_ARB_ES3_compatibility;
-#endif
-#ifndef GL_ARB_buffer_storage
-#define GL_ARB_buffer_storage 1
-GLAPI int GLAD_GL_ARB_buffer_storage;
-typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void* data, GLbitfield flags);
-GLAPI PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
-#define glBufferStorage glad_glBufferStorage
-#endif
-#ifndef GL_ARB_compatibility
-#define GL_ARB_compatibility 1
-GLAPI int GLAD_GL_ARB_compatibility;
-#endif
-#ifndef GL_ARB_compressed_texture_pixel_storage
-#define GL_ARB_compressed_texture_pixel_storage 1
-GLAPI int GLAD_GL_ARB_compressed_texture_pixel_storage;
-#endif
-#ifndef GL_ARB_debug_output
-#define GL_ARB_debug_output 1
-GLAPI int GLAD_GL_ARB_debug_output;
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
-GLAPI PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
-#define glDebugMessageControlARB glad_glDebugMessageControlARB
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);
-GLAPI PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
-#define glDebugMessageInsertARB glad_glDebugMessageInsertARB
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC)(GLDEBUGPROCARB callback, const void* userParam);
-GLAPI PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
-#define glDebugMessageCallbackARB glad_glDebugMessageCallbackARB
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC)(GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);
-GLAPI PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
-#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
-#endif
-#ifndef GL_ARB_depth_buffer_float
-#define GL_ARB_depth_buffer_float 1
-GLAPI int GLAD_GL_ARB_depth_buffer_float;
-#endif
-#ifndef GL_ARB_depth_clamp
-#define GL_ARB_depth_clamp 1
-GLAPI int GLAD_GL_ARB_depth_clamp;
-#endif
-#ifndef GL_ARB_depth_texture
-#define GL_ARB_depth_texture 1
-GLAPI int GLAD_GL_ARB_depth_texture;
-#endif
-#ifndef GL_ARB_draw_buffers
-#define GL_ARB_draw_buffers 1
-GLAPI int GLAD_GL_ARB_draw_buffers;
-typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC)(GLsizei n, const GLenum* bufs);
-GLAPI PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB;
-#define glDrawBuffersARB glad_glDrawBuffersARB
-#endif
-#ifndef GL_ARB_draw_buffers_blend
-#define GL_ARB_draw_buffers_blend 1
-GLAPI int GLAD_GL_ARB_draw_buffers_blend;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC)(GLuint buf, GLenum mode);
-GLAPI PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB;
-#define glBlendEquationiARB glad_glBlendEquationiARB
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB;
-#define glBlendEquationSeparateiARB glad_glBlendEquationSeparateiARB
-typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC)(GLuint buf, GLenum src, GLenum dst);
-GLAPI PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB;
-#define glBlendFunciARB glad_glBlendFunciARB
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB;
-#define glBlendFuncSeparateiARB glad_glBlendFuncSeparateiARB
-#endif
-#ifndef GL_ARB_explicit_attrib_location
-#define GL_ARB_explicit_attrib_location 1
-GLAPI int GLAD_GL_ARB_explicit_attrib_location;
-#endif
-#ifndef GL_ARB_explicit_uniform_location
-#define GL_ARB_explicit_uniform_location 1
-GLAPI int GLAD_GL_ARB_explicit_uniform_location;
-#endif
-#ifndef GL_ARB_fragment_program
-#define GL_ARB_fragment_program 1
-GLAPI int GLAD_GL_ARB_fragment_program;
-typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const void* string);
-GLAPI PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB;
-#define glProgramStringARB glad_glProgramStringARB
-typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC)(GLenum target, GLuint program);
-GLAPI PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB;
-#define glBindProgramARB glad_glBindProgramARB
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint* programs);
-GLAPI PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB;
-#define glDeleteProgramsARB glad_glDeleteProgramsARB
-typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC)(GLsizei n, GLuint* programs);
-GLAPI PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB;
-#define glGenProgramsARB glad_glGenProgramsARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB;
-#define glProgramEnvParameter4dARB glad_glProgramEnvParameter4dARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble* params);
-GLAPI PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB;
-#define glProgramEnvParameter4dvARB glad_glProgramEnvParameter4dvARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB;
-#define glProgramEnvParameter4fARB glad_glProgramEnvParameter4fARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat* params);
-GLAPI PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB;
-#define glProgramEnvParameter4fvARB glad_glProgramEnvParameter4fvARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB;
-#define glProgramLocalParameter4dARB glad_glProgramLocalParameter4dARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble* params);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB;
-#define glProgramLocalParameter4dvARB glad_glProgramLocalParameter4dvARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB;
-#define glProgramLocalParameter4fARB glad_glProgramLocalParameter4fARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat* params);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB;
-#define glProgramLocalParameter4fvARB glad_glProgramLocalParameter4fvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble* params);
-GLAPI PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB;
-#define glGetProgramEnvParameterdvARB glad_glGetProgramEnvParameterdvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat* params);
-GLAPI PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB;
-#define glGetProgramEnvParameterfvARB glad_glGetProgramEnvParameterfvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble* params);
-GLAPI PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB;
-#define glGetProgramLocalParameterdvARB glad_glGetProgramLocalParameterdvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat* params);
-GLAPI PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB;
-#define glGetProgramLocalParameterfvARB glad_glGetProgramLocalParameterfvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB;
-#define glGetProgramivARB glad_glGetProgramivARB
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, void* string);
-GLAPI PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB;
-#define glGetProgramStringARB glad_glGetProgramStringARB
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC)(GLuint program);
-GLAPI PFNGLISPROGRAMARBPROC glad_glIsProgramARB;
-#define glIsProgramARB glad_glIsProgramARB
-#endif
-#ifndef GL_ARB_fragment_shader
-#define GL_ARB_fragment_shader 1
-GLAPI int GLAD_GL_ARB_fragment_shader;
-#endif
-#ifndef GL_ARB_framebuffer_object
-#define GL_ARB_framebuffer_object 1
-GLAPI int GLAD_GL_ARB_framebuffer_object;
-#endif
-#ifndef GL_ARB_framebuffer_sRGB
-#define GL_ARB_framebuffer_sRGB 1
-GLAPI int GLAD_GL_ARB_framebuffer_sRGB;
-#endif
-#ifndef GL_ARB_multisample
-#define GL_ARB_multisample 1
-GLAPI int GLAD_GL_ARB_multisample;
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert);
-GLAPI PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-#define glSampleCoverageARB glad_glSampleCoverageARB
-#endif
-#ifndef GL_ARB_sample_locations
-#define GL_ARB_sample_locations 1
-GLAPI int GLAD_GL_ARB_sample_locations;
-typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLenum target, GLuint start, GLsizei count, const GLfloat* v);
-GLAPI PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB;
-#define glFramebufferSampleLocationsfvARB glad_glFramebufferSampleLocationsfvARB
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v);
-GLAPI PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB;
-#define glNamedFramebufferSampleLocationsfvARB glad_glNamedFramebufferSampleLocationsfvARB
-typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC)();
-GLAPI PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB;
-#define glEvaluateDepthValuesARB glad_glEvaluateDepthValuesARB
-#endif
-#ifndef GL_ARB_texture_compression
-#define GL_ARB_texture_compression 1
-GLAPI int GLAD_GL_ARB_texture_compression;
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB;
-#define glCompressedTexImage3DARB glad_glCompressedTexImage3DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB;
-#define glCompressedTexImage2DARB glad_glCompressedTexImage2DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB;
-#define glCompressedTexImage1DARB glad_glCompressedTexImage1DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB;
-#define glCompressedTexSubImage3DARB glad_glCompressedTexSubImage3DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB;
-#define glCompressedTexSubImage2DARB glad_glCompressedTexSubImage2DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB;
-#define glCompressedTexSubImage1DARB glad_glCompressedTexSubImage1DARB
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint level, void* img);
-GLAPI PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB;
-#define glGetCompressedTexImageARB glad_glGetCompressedTexImageARB
-#endif
-#ifndef GL_ARB_texture_float
-#define GL_ARB_texture_float 1
-GLAPI int GLAD_GL_ARB_texture_float;
-#endif
-#ifndef GL_ARB_texture_multisample
-#define GL_ARB_texture_multisample 1
-GLAPI int GLAD_GL_ARB_texture_multisample;
-#endif
-#ifndef GL_ARB_texture_non_power_of_two
-#define GL_ARB_texture_non_power_of_two 1
-GLAPI int GLAD_GL_ARB_texture_non_power_of_two;
-#endif
-#ifndef GL_ARB_texture_rg
-#define GL_ARB_texture_rg 1
-GLAPI int GLAD_GL_ARB_texture_rg;
-#endif
-#ifndef GL_ARB_texture_swizzle
-#define GL_ARB_texture_swizzle 1
-GLAPI int GLAD_GL_ARB_texture_swizzle;
-#endif
-#ifndef GL_ARB_uniform_buffer_object
-#define GL_ARB_uniform_buffer_object 1
-GLAPI int GLAD_GL_ARB_uniform_buffer_object;
-#endif
-#ifndef GL_ARB_vertex_array_object
-#define GL_ARB_vertex_array_object 1
-GLAPI int GLAD_GL_ARB_vertex_array_object;
-#endif
-#ifndef GL_ARB_vertex_attrib_binding
-#define GL_ARB_vertex_attrib_binding 1
-GLAPI int GLAD_GL_ARB_vertex_attrib_binding;
-typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
-GLAPI PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
-#define glBindVertexBuffer glad_glBindVertexBuffer
-typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
-#define glVertexAttribFormat glad_glVertexAttribFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
-#define glVertexAttribIFormat glad_glVertexAttribIFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
-#define glVertexAttribLFormat glad_glVertexAttribLFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex);
-GLAPI PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
-#define glVertexAttribBinding glad_glVertexAttribBinding
-typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor);
-GLAPI PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
-#define glVertexBindingDivisor glad_glVertexBindingDivisor
-#endif
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_ARB_vertex_buffer_object 1
-GLAPI int GLAD_GL_ARB_vertex_buffer_object;
-typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC)(GLenum target, GLuint buffer);
-GLAPI PFNGLBINDBUFFERARBPROC glad_glBindBufferARB;
-#define glBindBufferARB glad_glBindBufferARB
-typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC)(GLsizei n, const GLuint* buffers);
-GLAPI PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB;
-#define glDeleteBuffersARB glad_glDeleteBuffersARB
-typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC)(GLsizei n, GLuint* buffers);
-GLAPI PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB;
-#define glGenBuffersARB glad_glGenBuffersARB
-typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC)(GLuint buffer);
-GLAPI PFNGLISBUFFERARBPROC glad_glIsBufferARB;
-#define glIsBufferARB glad_glIsBufferARB
-typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC)(GLenum target, GLsizeiptrARB size, const void* data, GLenum usage);
-GLAPI PFNGLBUFFERDATAARBPROC glad_glBufferDataARB;
-#define glBufferDataARB glad_glBufferDataARB
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void* data);
-GLAPI PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB;
-#define glBufferSubDataARB glad_glBufferSubDataARB
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void* data);
-GLAPI PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB;
-#define glGetBufferSubDataARB glad_glGetBufferSubDataARB
-typedef void* (APIENTRYP PFNGLMAPBUFFERARBPROC)(GLenum target, GLenum access);
-GLAPI PFNGLMAPBUFFERARBPROC glad_glMapBufferARB;
-#define glMapBufferARB glad_glMapBufferARB
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC)(GLenum target);
-GLAPI PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB;
-#define glUnmapBufferARB glad_glUnmapBufferARB
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB;
-#define glGetBufferParameterivARB glad_glGetBufferParameterivARB
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, void** params);
-GLAPI PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB;
-#define glGetBufferPointervARB glad_glGetBufferPointervARB
-#endif
-#ifndef GL_ARB_vertex_program
-#define GL_ARB_vertex_program 1
-GLAPI int GLAD_GL_ARB_vertex_program;
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x);
-GLAPI PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB;
-#define glVertexAttrib1dARB glad_glVertexAttrib1dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB;
-#define glVertexAttrib1dvARB glad_glVertexAttrib1dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x);
-GLAPI PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB;
-#define glVertexAttrib1fARB glad_glVertexAttrib1fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB;
-#define glVertexAttrib1fvARB glad_glVertexAttrib1fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x);
-GLAPI PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB;
-#define glVertexAttrib1sARB glad_glVertexAttrib1sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB;
-#define glVertexAttrib1svARB glad_glVertexAttrib1svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y);
-GLAPI PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB;
-#define glVertexAttrib2dARB glad_glVertexAttrib2dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB;
-#define glVertexAttrib2dvARB glad_glVertexAttrib2dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y);
-GLAPI PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB;
-#define glVertexAttrib2fARB glad_glVertexAttrib2fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB;
-#define glVertexAttrib2fvARB glad_glVertexAttrib2fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y);
-GLAPI PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB;
-#define glVertexAttrib2sARB glad_glVertexAttrib2sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB;
-#define glVertexAttrib2svARB glad_glVertexAttrib2svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB;
-#define glVertexAttrib3dARB glad_glVertexAttrib3dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB;
-#define glVertexAttrib3dvARB glad_glVertexAttrib3dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB;
-#define glVertexAttrib3fARB glad_glVertexAttrib3fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB;
-#define glVertexAttrib3fvARB glad_glVertexAttrib3fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB;
-#define glVertexAttrib3sARB glad_glVertexAttrib3sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB;
-#define glVertexAttrib3svARB glad_glVertexAttrib3svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB;
-#define glVertexAttrib4NbvARB glad_glVertexAttrib4NbvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB;
-#define glVertexAttrib4NivARB glad_glVertexAttrib4NivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB;
-#define glVertexAttrib4NsvARB glad_glVertexAttrib4NsvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB;
-#define glVertexAttrib4NubARB glad_glVertexAttrib4NubARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB;
-#define glVertexAttrib4NubvARB glad_glVertexAttrib4NubvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB;
-#define glVertexAttrib4NuivARB glad_glVertexAttrib4NuivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB;
-#define glVertexAttrib4NusvARB glad_glVertexAttrib4NusvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB;
-#define glVertexAttrib4bvARB glad_glVertexAttrib4bvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB;
-#define glVertexAttrib4dARB glad_glVertexAttrib4dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB;
-#define glVertexAttrib4dvARB glad_glVertexAttrib4dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB;
-#define glVertexAttrib4fARB glad_glVertexAttrib4fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB;
-#define glVertexAttrib4fvARB glad_glVertexAttrib4fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB;
-#define glVertexAttrib4ivARB glad_glVertexAttrib4ivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB;
-#define glVertexAttrib4sARB glad_glVertexAttrib4sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB;
-#define glVertexAttrib4svARB glad_glVertexAttrib4svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB;
-#define glVertexAttrib4ubvARB glad_glVertexAttrib4ubvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB;
-#define glVertexAttrib4uivARB glad_glVertexAttrib4uivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB;
-#define glVertexAttrib4usvARB glad_glVertexAttrib4usvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB;
-#define glVertexAttribPointerARB glad_glVertexAttribPointerARB
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
-GLAPI PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB;
-#define glEnableVertexAttribArrayARB glad_glEnableVertexAttribArrayARB
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
-GLAPI PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB;
-#define glDisableVertexAttribArrayARB glad_glDisableVertexAttribArrayARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble* params);
-GLAPI PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB;
-#define glGetVertexAttribdvARB glad_glGetVertexAttribdvARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB;
-#define glGetVertexAttribfvARB glad_glGetVertexAttribfvARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB;
-#define glGetVertexAttribivARB glad_glGetVertexAttribivARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, void** pointer);
-GLAPI PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB;
-#define glGetVertexAttribPointervARB glad_glGetVertexAttribPointervARB
-#endif
-#ifndef GL_ARB_vertex_shader
-#define GL_ARB_vertex_shader 1
-GLAPI int GLAD_GL_ARB_vertex_shader;
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj, GLuint index, const GLcharARB* name);
-GLAPI PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB;
-#define glBindAttribLocationARB glad_glBindAttribLocationARB
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLcharARB* name);
-GLAPI PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB;
-#define glGetActiveAttribARB glad_glGetActiveAttribARB
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB* name);
-GLAPI PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB;
-#define glGetAttribLocationARB glad_glGetAttribLocationARB
-#endif
-#ifndef GL_ATI_element_array
-#define GL_ATI_element_array 1
-GLAPI int GLAD_GL_ATI_element_array;
-typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC)(GLenum type, const void* pointer);
-GLAPI PFNGLELEMENTPOINTERATIPROC glad_glElementPointerATI;
-#define glElementPointerATI glad_glElementPointerATI
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC)(GLenum mode, GLsizei count);
-GLAPI PFNGLDRAWELEMENTARRAYATIPROC glad_glDrawElementArrayATI;
-#define glDrawElementArrayATI glad_glDrawElementArrayATI
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count);
-GLAPI PFNGLDRAWRANGEELEMENTARRAYATIPROC glad_glDrawRangeElementArrayATI;
-#define glDrawRangeElementArrayATI glad_glDrawRangeElementArrayATI
-#endif
-#ifndef GL_ATI_fragment_shader
-#define GL_ATI_fragment_shader 1
-GLAPI int GLAD_GL_ATI_fragment_shader;
-typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC)(GLuint range);
-GLAPI PFNGLGENFRAGMENTSHADERSATIPROC glad_glGenFragmentShadersATI;
-#define glGenFragmentShadersATI glad_glGenFragmentShadersATI
-typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC)(GLuint id);
-GLAPI PFNGLBINDFRAGMENTSHADERATIPROC glad_glBindFragmentShaderATI;
-#define glBindFragmentShaderATI glad_glBindFragmentShaderATI
-typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC)(GLuint id);
-GLAPI PFNGLDELETEFRAGMENTSHADERATIPROC glad_glDeleteFragmentShaderATI;
-#define glDeleteFragmentShaderATI glad_glDeleteFragmentShaderATI
-typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC)();
-GLAPI PFNGLBEGINFRAGMENTSHADERATIPROC glad_glBeginFragmentShaderATI;
-#define glBeginFragmentShaderATI glad_glBeginFragmentShaderATI
-typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC)();
-GLAPI PFNGLENDFRAGMENTSHADERATIPROC glad_glEndFragmentShaderATI;
-#define glEndFragmentShaderATI glad_glEndFragmentShaderATI
-typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC)(GLuint dst, GLuint coord, GLenum swizzle);
-GLAPI PFNGLPASSTEXCOORDATIPROC glad_glPassTexCoordATI;
-#define glPassTexCoordATI glad_glPassTexCoordATI
-typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC)(GLuint dst, GLuint interp, GLenum swizzle);
-GLAPI PFNGLSAMPLEMAPATIPROC glad_glSampleMapATI;
-#define glSampleMapATI glad_glSampleMapATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI PFNGLCOLORFRAGMENTOP1ATIPROC glad_glColorFragmentOp1ATI;
-#define glColorFragmentOp1ATI glad_glColorFragmentOp1ATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI PFNGLCOLORFRAGMENTOP2ATIPROC glad_glColorFragmentOp2ATI;
-#define glColorFragmentOp2ATI glad_glColorFragmentOp2ATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI PFNGLCOLORFRAGMENTOP3ATIPROC glad_glColorFragmentOp3ATI;
-#define glColorFragmentOp3ATI glad_glColorFragmentOp3ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI PFNGLALPHAFRAGMENTOP1ATIPROC glad_glAlphaFragmentOp1ATI;
-#define glAlphaFragmentOp1ATI glad_glAlphaFragmentOp1ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI PFNGLALPHAFRAGMENTOP2ATIPROC glad_glAlphaFragmentOp2ATI;
-#define glAlphaFragmentOp2ATI glad_glAlphaFragmentOp2ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI PFNGLALPHAFRAGMENTOP3ATIPROC glad_glAlphaFragmentOp3ATI;
-#define glAlphaFragmentOp3ATI glad_glAlphaFragmentOp3ATI
-typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)(GLuint dst, const GLfloat* value);
-GLAPI PFNGLSETFRAGMENTSHADERCONSTANTATIPROC glad_glSetFragmentShaderConstantATI;
-#define glSetFragmentShaderConstantATI glad_glSetFragmentShaderConstantATI
-#endif
-#ifndef GL_ATI_vertex_array_object
-#define GL_ATI_vertex_array_object 1
-GLAPI int GLAD_GL_ATI_vertex_array_object;
-typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC)(GLsizei size, const void* pointer, GLenum usage);
-GLAPI PFNGLNEWOBJECTBUFFERATIPROC glad_glNewObjectBufferATI;
-#define glNewObjectBufferATI glad_glNewObjectBufferATI
-typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC)(GLuint buffer);
-GLAPI PFNGLISOBJECTBUFFERATIPROC glad_glIsObjectBufferATI;
-#define glIsObjectBufferATI glad_glIsObjectBufferATI
-typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC)(GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve);
-GLAPI PFNGLUPDATEOBJECTBUFFERATIPROC glad_glUpdateObjectBufferATI;
-#define glUpdateObjectBufferATI glad_glUpdateObjectBufferATI
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC)(GLuint buffer, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETOBJECTBUFFERFVATIPROC glad_glGetObjectBufferfvATI;
-#define glGetObjectBufferfvATI glad_glGetObjectBufferfvATI
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC)(GLuint buffer, GLenum pname, GLint* params);
-GLAPI PFNGLGETOBJECTBUFFERIVATIPROC glad_glGetObjectBufferivATI;
-#define glGetObjectBufferivATI glad_glGetObjectBufferivATI
-typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC)(GLuint buffer);
-GLAPI PFNGLFREEOBJECTBUFFERATIPROC glad_glFreeObjectBufferATI;
-#define glFreeObjectBufferATI glad_glFreeObjectBufferATI
-typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC)(GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI PFNGLARRAYOBJECTATIPROC glad_glArrayObjectATI;
-#define glArrayObjectATI glad_glArrayObjectATI
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC)(GLenum array, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETARRAYOBJECTFVATIPROC glad_glGetArrayObjectfvATI;
-#define glGetArrayObjectfvATI glad_glGetArrayObjectfvATI
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC)(GLenum array, GLenum pname, GLint* params);
-GLAPI PFNGLGETARRAYOBJECTIVATIPROC glad_glGetArrayObjectivATI;
-#define glGetArrayObjectivATI glad_glGetArrayObjectivATI
-typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC)(GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI PFNGLVARIANTARRAYOBJECTATIPROC glad_glVariantArrayObjectATI;
-#define glVariantArrayObjectATI glad_glVariantArrayObjectATI
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC)(GLuint id, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVARIANTARRAYOBJECTFVATIPROC glad_glGetVariantArrayObjectfvATI;
-#define glGetVariantArrayObjectfvATI glad_glGetVariantArrayObjectfvATI
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC)(GLuint id, GLenum pname, GLint* params);
-GLAPI PFNGLGETVARIANTARRAYOBJECTIVATIPROC glad_glGetVariantArrayObjectivATI;
-#define glGetVariantArrayObjectivATI glad_glGetVariantArrayObjectivATI
-#endif
-#ifndef GL_EXT_blend_color
-#define GL_EXT_blend_color 1
-GLAPI int GLAD_GL_EXT_blend_color;
-typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
-#define glBlendColorEXT glad_glBlendColorEXT
-#endif
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 1
-GLAPI int GLAD_GL_EXT_blend_equation_separate;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
-#define glBlendEquationSeparateEXT glad_glBlendEquationSeparateEXT
-#endif
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 1
-GLAPI int GLAD_GL_EXT_blend_func_separate;
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
-#define glBlendFuncSeparateEXT glad_glBlendFuncSeparateEXT
-#endif
-#ifndef GL_EXT_debug_marker
-#define GL_EXT_debug_marker 1
-GLAPI int GLAD_GL_EXT_debug_marker;
-typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar *marker);
-GLAPI PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
-#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
-typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar *marker);
-GLAPI PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
-#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
-typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC)(void);
-GLAPI PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
-#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
-#endif
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 1
-GLAPI int GLAD_GL_EXT_framebuffer_blit;
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GLAPI PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
-#define glBlitFramebufferEXT glad_glBlitFramebufferEXT
-#endif
-#ifndef GL_EXT_framebuffer_multisample
-#define GL_EXT_framebuffer_multisample 1
-GLAPI int GLAD_GL_EXT_framebuffer_multisample;
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
-#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
-#endif
-#ifndef GL_EXT_framebuffer_multisample_blit_scaled
-#define GL_EXT_framebuffer_multisample_blit_scaled 1
-GLAPI int GLAD_GL_EXT_framebuffer_multisample_blit_scaled;
-#endif
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 1
-GLAPI int GLAD_GL_EXT_framebuffer_object;
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
-GLAPI PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
-#define glIsRenderbufferEXT glad_glIsRenderbufferEXT
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
-GLAPI PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT;
-#define glBindRenderbufferEXT glad_glBindRenderbufferEXT
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint* renderbuffers);
-GLAPI PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT;
-#define glDeleteRenderbuffersEXT glad_glDeleteRenderbuffersEXT
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint* renderbuffers);
-GLAPI PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT;
-#define glGenRenderbuffersEXT glad_glGenRenderbuffersEXT
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
-#define glRenderbufferStorageEXT glad_glRenderbufferStorageEXT
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT;
-#define glGetRenderbufferParameterivEXT glad_glGetRenderbufferParameterivEXT
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
-GLAPI PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT;
-#define glIsFramebufferEXT glad_glIsFramebufferEXT
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
-GLAPI PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT;
-#define glBindFramebufferEXT glad_glBindFramebufferEXT
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint* framebuffers);
-GLAPI PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT;
-#define glDeleteFramebuffersEXT glad_glDeleteFramebuffersEXT
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint* framebuffers);
-GLAPI PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT;
-#define glGenFramebuffersEXT glad_glGenFramebuffersEXT
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
-GLAPI PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT;
-#define glCheckFramebufferStatusEXT glad_glCheckFramebufferStatusEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT;
-#define glFramebufferTexture1DEXT glad_glFramebufferTexture1DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT;
-#define glFramebufferTexture2DEXT glad_glFramebufferTexture2DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT;
-#define glFramebufferTexture3DEXT glad_glFramebufferTexture3DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT;
-#define glFramebufferRenderbufferEXT glad_glFramebufferRenderbufferEXT
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT;
-#define glGetFramebufferAttachmentParameterivEXT glad_glGetFramebufferAttachmentParameterivEXT
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
-GLAPI PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT;
-#define glGenerateMipmapEXT glad_glGenerateMipmapEXT
-#endif
-#ifndef GL_EXT_framebuffer_sRGB
-#define GL_EXT_framebuffer_sRGB 1
-GLAPI int GLAD_GL_EXT_framebuffer_sRGB;
-#endif
-#ifndef GL_EXT_index_array_formats
-#define GL_EXT_index_array_formats 1
-GLAPI int GLAD_GL_EXT_index_array_formats;
-#endif
-#ifndef GL_EXT_texture
-#define GL_EXT_texture 1
-GLAPI int GLAD_GL_EXT_texture;
-#endif
-#ifndef GL_EXT_texture_compression_s3tc
-#define GL_EXT_texture_compression_s3tc 1
-GLAPI int GLAD_GL_EXT_texture_compression_s3tc;
-#endif
-#ifndef GL_EXT_texture_sRGB
-#define GL_EXT_texture_sRGB 1
-GLAPI int GLAD_GL_EXT_texture_sRGB;
-#endif
-#ifndef GL_EXT_texture_swizzle
-#define GL_EXT_texture_swizzle 1
-GLAPI int GLAD_GL_EXT_texture_swizzle;
-#endif
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 1
-GLAPI int GLAD_GL_EXT_vertex_array;
-typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC)(GLint i);
-GLAPI PFNGLARRAYELEMENTEXTPROC glad_glArrayElementEXT;
-#define glArrayElementEXT glad_glArrayElementEXT
-typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLCOLORPOINTEREXTPROC glad_glColorPointerEXT;
-#define glColorPointerEXT glad_glColorPointerEXT
-typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC)(GLenum mode, GLint first, GLsizei count);
-GLAPI PFNGLDRAWARRAYSEXTPROC glad_glDrawArraysEXT;
-#define glDrawArraysEXT glad_glDrawArraysEXT
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC)(GLsizei stride, GLsizei count, const GLboolean* pointer);
-GLAPI PFNGLEDGEFLAGPOINTEREXTPROC glad_glEdgeFlagPointerEXT;
-#define glEdgeFlagPointerEXT glad_glEdgeFlagPointerEXT
-typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC)(GLenum pname, void** params);
-GLAPI PFNGLGETPOINTERVEXTPROC glad_glGetPointervEXT;
-#define glGetPointervEXT glad_glGetPointervEXT
-typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC)(GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLINDEXPOINTEREXTPROC glad_glIndexPointerEXT;
-#define glIndexPointerEXT glad_glIndexPointerEXT
-typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC)(GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLNORMALPOINTEREXTPROC glad_glNormalPointerEXT;
-#define glNormalPointerEXT glad_glNormalPointerEXT
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLTEXCOORDPOINTEREXTPROC glad_glTexCoordPointerEXT;
-#define glTexCoordPointerEXT glad_glTexCoordPointerEXT
-typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLVERTEXPOINTEREXTPROC glad_glVertexPointerEXT;
-#define glVertexPointerEXT glad_glVertexPointerEXT
-#endif
-#ifndef GL_EXT_vertex_shader
-#define GL_EXT_vertex_shader 1
-GLAPI int GLAD_GL_EXT_vertex_shader;
-typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC)();
-GLAPI PFNGLBEGINVERTEXSHADEREXTPROC glad_glBeginVertexShaderEXT;
-#define glBeginVertexShaderEXT glad_glBeginVertexShaderEXT
-typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC)();
-GLAPI PFNGLENDVERTEXSHADEREXTPROC glad_glEndVertexShaderEXT;
-#define glEndVertexShaderEXT glad_glEndVertexShaderEXT
-typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC)(GLuint id);
-GLAPI PFNGLBINDVERTEXSHADEREXTPROC glad_glBindVertexShaderEXT;
-#define glBindVertexShaderEXT glad_glBindVertexShaderEXT
-typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC)(GLuint range);
-GLAPI PFNGLGENVERTEXSHADERSEXTPROC glad_glGenVertexShadersEXT;
-#define glGenVertexShadersEXT glad_glGenVertexShadersEXT
-typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC)(GLuint id);
-GLAPI PFNGLDELETEVERTEXSHADEREXTPROC glad_glDeleteVertexShaderEXT;
-#define glDeleteVertexShaderEXT glad_glDeleteVertexShaderEXT
-typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC)(GLenum op, GLuint res, GLuint arg1);
-GLAPI PFNGLSHADEROP1EXTPROC glad_glShaderOp1EXT;
-#define glShaderOp1EXT glad_glShaderOp1EXT
-typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC)(GLenum op, GLuint res, GLuint arg1, GLuint arg2);
-GLAPI PFNGLSHADEROP2EXTPROC glad_glShaderOp2EXT;
-#define glShaderOp2EXT glad_glShaderOp2EXT
-typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC)(GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
-GLAPI PFNGLSHADEROP3EXTPROC glad_glShaderOp3EXT;
-#define glShaderOp3EXT glad_glShaderOp3EXT
-typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC)(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI PFNGLSWIZZLEEXTPROC glad_glSwizzleEXT;
-#define glSwizzleEXT glad_glSwizzleEXT
-typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC)(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI PFNGLWRITEMASKEXTPROC glad_glWriteMaskEXT;
-#define glWriteMaskEXT glad_glWriteMaskEXT
-typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC)(GLuint res, GLuint src, GLuint num);
-GLAPI PFNGLINSERTCOMPONENTEXTPROC glad_glInsertComponentEXT;
-#define glInsertComponentEXT glad_glInsertComponentEXT
-typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC)(GLuint res, GLuint src, GLuint num);
-GLAPI PFNGLEXTRACTCOMPONENTEXTPROC glad_glExtractComponentEXT;
-#define glExtractComponentEXT glad_glExtractComponentEXT
-typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC)(GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
-GLAPI PFNGLGENSYMBOLSEXTPROC glad_glGenSymbolsEXT;
-#define glGenSymbolsEXT glad_glGenSymbolsEXT
-typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC)(GLuint id, GLenum type, const void* addr);
-GLAPI PFNGLSETINVARIANTEXTPROC glad_glSetInvariantEXT;
-#define glSetInvariantEXT glad_glSetInvariantEXT
-typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC)(GLuint id, GLenum type, const void* addr);
-GLAPI PFNGLSETLOCALCONSTANTEXTPROC glad_glSetLocalConstantEXT;
-#define glSetLocalConstantEXT glad_glSetLocalConstantEXT
-typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC)(GLuint id, const GLbyte* addr);
-GLAPI PFNGLVARIANTBVEXTPROC glad_glVariantbvEXT;
-#define glVariantbvEXT glad_glVariantbvEXT
-typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC)(GLuint id, const GLshort* addr);
-GLAPI PFNGLVARIANTSVEXTPROC glad_glVariantsvEXT;
-#define glVariantsvEXT glad_glVariantsvEXT
-typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC)(GLuint id, const GLint* addr);
-GLAPI PFNGLVARIANTIVEXTPROC glad_glVariantivEXT;
-#define glVariantivEXT glad_glVariantivEXT
-typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC)(GLuint id, const GLfloat* addr);
-GLAPI PFNGLVARIANTFVEXTPROC glad_glVariantfvEXT;
-#define glVariantfvEXT glad_glVariantfvEXT
-typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC)(GLuint id, const GLdouble* addr);
-GLAPI PFNGLVARIANTDVEXTPROC glad_glVariantdvEXT;
-#define glVariantdvEXT glad_glVariantdvEXT
-typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC)(GLuint id, const GLubyte* addr);
-GLAPI PFNGLVARIANTUBVEXTPROC glad_glVariantubvEXT;
-#define glVariantubvEXT glad_glVariantubvEXT
-typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC)(GLuint id, const GLushort* addr);
-GLAPI PFNGLVARIANTUSVEXTPROC glad_glVariantusvEXT;
-#define glVariantusvEXT glad_glVariantusvEXT
-typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC)(GLuint id, const GLuint* addr);
-GLAPI PFNGLVARIANTUIVEXTPROC glad_glVariantuivEXT;
-#define glVariantuivEXT glad_glVariantuivEXT
-typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC)(GLuint id, GLenum type, GLuint stride, const void* addr);
-GLAPI PFNGLVARIANTPOINTEREXTPROC glad_glVariantPointerEXT;
-#define glVariantPointerEXT glad_glVariantPointerEXT
-typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)(GLuint id);
-GLAPI PFNGLENABLEVARIANTCLIENTSTATEEXTPROC glad_glEnableVariantClientStateEXT;
-#define glEnableVariantClientStateEXT glad_glEnableVariantClientStateEXT
-typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)(GLuint id);
-GLAPI PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC glad_glDisableVariantClientStateEXT;
-#define glDisableVariantClientStateEXT glad_glDisableVariantClientStateEXT
-typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC)(GLenum light, GLenum value);
-GLAPI PFNGLBINDLIGHTPARAMETEREXTPROC glad_glBindLightParameterEXT;
-#define glBindLightParameterEXT glad_glBindLightParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC)(GLenum face, GLenum value);
-GLAPI PFNGLBINDMATERIALPARAMETEREXTPROC glad_glBindMaterialParameterEXT;
-#define glBindMaterialParameterEXT glad_glBindMaterialParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC)(GLenum unit, GLenum coord, GLenum value);
-GLAPI PFNGLBINDTEXGENPARAMETEREXTPROC glad_glBindTexGenParameterEXT;
-#define glBindTexGenParameterEXT glad_glBindTexGenParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)(GLenum unit, GLenum value);
-GLAPI PFNGLBINDTEXTUREUNITPARAMETEREXTPROC glad_glBindTextureUnitParameterEXT;
-#define glBindTextureUnitParameterEXT glad_glBindTextureUnitParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC)(GLenum value);
-GLAPI PFNGLBINDPARAMETEREXTPROC glad_glBindParameterEXT;
-#define glBindParameterEXT glad_glBindParameterEXT
-typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC)(GLuint id, GLenum cap);
-GLAPI PFNGLISVARIANTENABLEDEXTPROC glad_glIsVariantEnabledEXT;
-#define glIsVariantEnabledEXT glad_glIsVariantEnabledEXT
-typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETVARIANTBOOLEANVEXTPROC glad_glGetVariantBooleanvEXT;
-#define glGetVariantBooleanvEXT glad_glGetVariantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETVARIANTINTEGERVEXTPROC glad_glGetVariantIntegervEXT;
-#define glGetVariantIntegervEXT glad_glGetVariantIntegervEXT
-typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETVARIANTFLOATVEXTPROC glad_glGetVariantFloatvEXT;
-#define glGetVariantFloatvEXT glad_glGetVariantFloatvEXT
-typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC)(GLuint id, GLenum value, void** data);
-GLAPI PFNGLGETVARIANTPOINTERVEXTPROC glad_glGetVariantPointervEXT;
-#define glGetVariantPointervEXT glad_glGetVariantPointervEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETINVARIANTBOOLEANVEXTPROC glad_glGetInvariantBooleanvEXT;
-#define glGetInvariantBooleanvEXT glad_glGetInvariantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETINVARIANTINTEGERVEXTPROC glad_glGetInvariantIntegervEXT;
-#define glGetInvariantIntegervEXT glad_glGetInvariantIntegervEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETINVARIANTFLOATVEXTPROC glad_glGetInvariantFloatvEXT;
-#define glGetInvariantFloatvEXT glad_glGetInvariantFloatvEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC glad_glGetLocalConstantBooleanvEXT;
-#define glGetLocalConstantBooleanvEXT glad_glGetLocalConstantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETLOCALCONSTANTINTEGERVEXTPROC glad_glGetLocalConstantIntegervEXT;
-#define glGetLocalConstantIntegervEXT glad_glGetLocalConstantIntegervEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETLOCALCONSTANTFLOATVEXTPROC glad_glGetLocalConstantFloatvEXT;
-#define glGetLocalConstantFloatvEXT glad_glGetLocalConstantFloatvEXT
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//     IMPLEMENTATION SECTION
-//
-
-#ifdef GLAD_IMPLEMENTATION
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct gladGLversionStruct GLVersion;
-
-#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
-#define _GLAD_IS_SOME_NEW_VERSION 1
-#endif
-
-static int max_loaded_major;
-static int max_loaded_minor;
-
-static const char *exts = NULL;
-static int num_exts_i = 0;
-static const char **exts_i = NULL;
-
-static int get_exts(void) {
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    if(max_loaded_major < 3) {
-#endif
-        exts = (const char *)glGetString(GL_EXTENSIONS);
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    } else {
-        int index;
-
-        num_exts_i = 0;
-        glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
-        if (num_exts_i > 0) {
-            exts_i = (const char **)GLAD_REALLOC((void *)exts_i, num_exts_i * sizeof *exts_i);
-        }
-
-        if (exts_i == NULL) {
-            return 0;
-        }
-
-        for(index = 0; index < num_exts_i; index++) {
-            exts_i[index] = (const char*)glGetStringi(GL_EXTENSIONS, index);
-        }
-    }
-#endif
-    return 1;
-}
-
-static void free_exts(void) {
-    if (exts_i != NULL) {
-        GLAD_FREE((char **)exts_i);
-        exts_i = NULL;
-    }
-}
-
-static int has_ext(const char *ext) {
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    if(max_loaded_major < 3) {
-#endif
-        const char *extensions;
-        const char *loc;
-        const char *terminator;
-        extensions = exts;
-        if(extensions == NULL || ext == NULL) {
-            return 0;
-        }
-
-        while(1) {
-            loc = strstr(extensions, ext);
-            if(loc == NULL) {
-                return 0;
-            }
-
-            terminator = loc + strlen(ext);
-            if((loc == extensions || *(loc - 1) == ' ') &&
-                (*terminator == ' ' || *terminator == '\0')) {
-                return 1;
-            }
-            extensions = terminator;
-        }
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    } else {
-        int index;
-
-        for(index = 0; index < num_exts_i; index++) {
-            const char *e = exts_i[index];
-
-            if(strcmp(e, ext) == 0) {
-                return 1;
-            }
-        }
-    }
-#endif
-
-    return 0;
-}
-int GLAD_GL_VERSION_1_0;
-int GLAD_GL_VERSION_1_1;
-int GLAD_GL_VERSION_1_2;
-int GLAD_GL_VERSION_1_3;
-int GLAD_GL_VERSION_1_4;
-int GLAD_GL_VERSION_1_5;
-int GLAD_GL_VERSION_2_0;
-int GLAD_GL_VERSION_2_1;
-int GLAD_GL_VERSION_3_0;
-int GLAD_GL_VERSION_3_1;
-int GLAD_GL_VERSION_3_2;
-int GLAD_GL_VERSION_3_3;
-PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-PFNGLBINDSAMPLERPROC glad_glBindSampler;
-PFNGLLINEWIDTHPROC glad_glLineWidth;
-PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-PFNGLCOMPILESHADERPROC glad_glCompileShader;
-PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-PFNGLENABLEIPROC glad_glEnablei;
-PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-PFNGLCREATESHADERPROC glad_glCreateShader;
-PFNGLISBUFFERPROC glad_glIsBuffer;
-PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-PFNGLHINTPROC glad_glHint;
-PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-PFNGLPOINTSIZEPROC glad_glPointSize;
-PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-PFNGLWAITSYNCPROC glad_glWaitSync;
-PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-PFNGLUNIFORM3IPROC glad_glUniform3i;
-PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-PFNGLUNIFORM3FPROC glad_glUniform3f;
-PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-PFNGLCOLORMASKIPROC glad_glColorMaski;
-PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-PFNGLCLEARPROC glad_glClear;
-PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-PFNGLISENABLEDPROC glad_glIsEnabled;
-PFNGLSTENCILOPPROC glad_glStencilOp;
-PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-PFNGLISSHADERPROC glad_glIsShader;
-PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-PFNGLENABLEPROC glad_glEnable;
-PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-PFNGLFLUSHPROC glad_glFlush;
-PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-PFNGLFENCESYNCPROC glad_glFenceSync;
-PFNGLCOLORP3UIPROC glad_glColorP3ui;
-PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-PFNGLCLAMPCOLORPROC glad_glClampColor;
-PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-PFNGLCLEARSTENCILPROC glad_glClearStencil;
-PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-PFNGLGENTEXTURESPROC glad_glGenTextures;
-PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-PFNGLISSYNCPROC glad_glIsSync;
-PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-PFNGLUNIFORM2IPROC glad_glUniform2i;
-PFNGLUNIFORM2FPROC glad_glUniform2f;
-PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-PFNGLGENQUERIESPROC glad_glGenQueries;
-PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-PFNGLISENABLEDIPROC glad_glIsEnabledi;
-PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-PFNGLDEPTHRANGEPROC glad_glDepthRange;
-PFNGLMAPBUFFERPROC glad_glMapBuffer;
-PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-PFNGLDELETESYNCPROC glad_glDeleteSync;
-PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-PFNGLUSEPROGRAMPROC glad_glUseProgram;
-PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-PFNGLFINISHPROC glad_glFinish;
-PFNGLDELETESHADERPROC glad_glDeleteShader;
-PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-PFNGLVIEWPORTPROC glad_glViewport;
-PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-PFNGLCLEARDEPTHPROC glad_glClearDepth;
-PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-PFNGLTEXBUFFERPROC glad_glTexBuffer;
-PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-PFNGLBINDTEXTUREPROC glad_glBindTexture;
-PFNGLGETSTRINGPROC glad_glGetString;
-PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-PFNGLDETACHSHADERPROC glad_glDetachShader;
-PFNGLENDQUERYPROC glad_glEndQuery;
-PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-PFNGLUNIFORM1FPROC glad_glUniform1f;
-PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-PFNGLUNIFORM1IPROC glad_glUniform1i;
-PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-PFNGLDISABLEPROC glad_glDisable;
-PFNGLLOGICOPPROC glad_glLogicOp;
-PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-PFNGLCULLFACEPROC glad_glCullFace;
-PFNGLGETSTRINGIPROC glad_glGetStringi;
-PFNGLATTACHSHADERPROC glad_glAttachShader;
-PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-PFNGLREADBUFFERPROC glad_glReadBuffer;
-PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-PFNGLBLENDCOLORPROC glad_glBlendColor;
-PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-PFNGLISPROGRAMPROC glad_glIsProgram;
-PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-PFNGLUNIFORM4IPROC glad_glUniform4i;
-PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-PFNGLREADPIXELSPROC glad_glReadPixels;
-PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-PFNGLUNIFORM4FPROC glad_glUniform4f;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-PFNGLCOLORP4UIPROC glad_glColorP4ui;
-PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-PFNGLGENBUFFERSPROC glad_glGenBuffers;
-PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-PFNGLBLENDFUNCPROC glad_glBlendFunc;
-PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-PFNGLSCISSORPROC glad_glScissor;
-PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-PFNGLCLEARCOLORPROC glad_glClearColor;
-PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-PFNGLCOLORMASKPROC glad_glColorMask;
-PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-PFNGLISSAMPLERPROC glad_glIsSampler;
-PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-PFNGLDISABLEIPROC glad_glDisablei;
-PFNGLSHADERSOURCEPROC glad_glShaderSource;
-PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-PFNGLGETSYNCIVPROC glad_glGetSynciv;
-PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-PFNGLBEGINQUERYPROC glad_glBeginQuery;
-PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-PFNGLBINDBUFFERPROC glad_glBindBuffer;
-PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-PFNGLBUFFERDATAPROC glad_glBufferData;
-PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-PFNGLGETERRORPROC glad_glGetError;
-PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-PFNGLGETFLOATVPROC glad_glGetFloatv;
-PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-PFNGLISQUERYPROC glad_glIsQuery;
-PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-PFNGLSTENCILMASKPROC glad_glStencilMask;
-PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-PFNGLISTEXTUREPROC glad_glIsTexture;
-PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-PFNGLDEPTHMASKPROC glad_glDepthMask;
-PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-PFNGLFRONTFACEPROC glad_glFrontFace;
-int GLAD_GL_ARB_texture_compression;
-int GLAD_GL_ARB_texture_swizzle;
-int GLAD_GL_ATI_fragment_shader;
-int GLAD_GL_EXT_texture_sRGB;
-int GLAD_GL_ARB_explicit_attrib_location;
-int GLAD_GL_ARB_ES3_compatibility;
-int GLAD_GL_EXT_blend_color;
-int GLAD_GL_EXT_framebuffer_sRGB;
-int GLAD_GL_EXT_index_array_formats;
-int GLAD_GL_ARB_vertex_shader;
-int GLAD_GL_ARB_vertex_attrib_binding;
-int GLAD_GL_ARB_vertex_program;
-int GLAD_GL_EXT_texture_compression_s3tc;
-int GLAD_GL_EXT_debug_marker;
-int GLAD_GL_EXT_texture_swizzle;
-int GLAD_GL_ARB_texture_multisample;
-int GLAD_GL_ARB_texture_rg;
-int GLAD_GL_ARB_texture_float;
-int GLAD_GL_ARB_compressed_texture_pixel_storage;
-int GLAD_GL_ARB_framebuffer_sRGB;
-int GLAD_GL_ARB_vertex_array_object;
-int GLAD_GL_ARB_depth_clamp;
-int GLAD_GL_ARB_fragment_shader;
-int GLAD_GL_ATI_vertex_array_object;
-int GLAD_GL_ARB_vertex_buffer_object;
-int GLAD_GL_ARB_fragment_program;
-int GLAD_GL_EXT_framebuffer_multisample;
-int GLAD_GL_ARB_framebuffer_object;
-int GLAD_GL_ARB_draw_buffers_blend;
-int GLAD_GL_EXT_vertex_shader;
-int GLAD_GL_EXT_blend_func_separate;
-int GLAD_GL_ARB_texture_non_power_of_two;
-int GLAD_GL_EXT_texture;
-int GLAD_GL_ARB_buffer_storage;
-int GLAD_GL_ARB_explicit_uniform_location;
-int GLAD_GL_EXT_framebuffer_object;
-int GLAD_GL_EXT_framebuffer_multisample_blit_scaled;
-int GLAD_GL_AMD_debug_output;
-int GLAD_GL_ARB_depth_buffer_float;
-int GLAD_GL_ARB_multisample;
-int GLAD_GL_ARB_compatibility;
-int GLAD_GL_ARB_depth_texture;
-int GLAD_GL_ARB_sample_locations;
-int GLAD_GL_ARB_ES2_compatibility;
-int GLAD_GL_AMD_query_buffer_object;
-int GLAD_GL_EXT_framebuffer_blit;
-int GLAD_GL_EXT_vertex_array;
-int GLAD_GL_ARB_draw_buffers;
-int GLAD_GL_EXT_blend_equation_separate;
-int GLAD_GL_ATI_element_array;
-int GLAD_GL_ARB_debug_output;
-int GLAD_GL_ARB_uniform_buffer_object;
-PFNGLDEBUGMESSAGEENABLEAMDPROC glad_glDebugMessageEnableAMD;
-PFNGLDEBUGMESSAGEINSERTAMDPROC glad_glDebugMessageInsertAMD;
-PFNGLDEBUGMESSAGECALLBACKAMDPROC glad_glDebugMessageCallbackAMD;
-PFNGLGETDEBUGMESSAGELOGAMDPROC glad_glGetDebugMessageLogAMD;
-PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
-PFNGLSHADERBINARYPROC glad_glShaderBinary;
-PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
-PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
-PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
-PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
-PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
-PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
-PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
-PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
-PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB;
-PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB;
-PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB;
-PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB;
-PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB;
-PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB;
-PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB;
-PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB;
-PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB;
-PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB;
-PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB;
-PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB;
-PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB;
-PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB;
-PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB;
-PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB;
-PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB;
-PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB;
-PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB;
-PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB;
-PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB;
-PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB;
-PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB;
-PFNGLISPROGRAMARBPROC glad_glIsProgramARB;
-PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB;
-PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB;
-PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB;
-PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB;
-PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB;
-PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB;
-PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB;
-PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
-PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
-PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
-PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
-PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
-PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
-PFNGLBINDBUFFERARBPROC glad_glBindBufferARB;
-PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB;
-PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB;
-PFNGLISBUFFERARBPROC glad_glIsBufferARB;
-PFNGLBUFFERDATAARBPROC glad_glBufferDataARB;
-PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB;
-PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB;
-PFNGLMAPBUFFERARBPROC glad_glMapBufferARB;
-PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB;
-PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB;
-PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB;
-PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB;
-PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB;
-PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB;
-PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB;
-PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB;
-PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB;
-PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB;
-PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB;
-PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB;
-PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB;
-PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB;
-PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB;
-PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB;
-PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB;
-PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB;
-PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB;
-PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB;
-PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB;
-PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB;
-PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB;
-PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB;
-PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB;
-PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB;
-PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB;
-PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB;
-PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB;
-PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB;
-PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB;
-PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB;
-PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB;
-PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB;
-PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB;
-PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB;
-PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB;
-PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB;
-PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB;
-PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB;
-PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB;
-PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB;
-PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB;
-PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB;
-PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB;
-PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB;
-PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB;
-PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB;
-PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB;
-PFNGLELEMENTPOINTERATIPROC glad_glElementPointerATI;
-PFNGLDRAWELEMENTARRAYATIPROC glad_glDrawElementArrayATI;
-PFNGLDRAWRANGEELEMENTARRAYATIPROC glad_glDrawRangeElementArrayATI;
-PFNGLGENFRAGMENTSHADERSATIPROC glad_glGenFragmentShadersATI;
-PFNGLBINDFRAGMENTSHADERATIPROC glad_glBindFragmentShaderATI;
-PFNGLDELETEFRAGMENTSHADERATIPROC glad_glDeleteFragmentShaderATI;
-PFNGLBEGINFRAGMENTSHADERATIPROC glad_glBeginFragmentShaderATI;
-PFNGLENDFRAGMENTSHADERATIPROC glad_glEndFragmentShaderATI;
-PFNGLPASSTEXCOORDATIPROC glad_glPassTexCoordATI;
-PFNGLSAMPLEMAPATIPROC glad_glSampleMapATI;
-PFNGLCOLORFRAGMENTOP1ATIPROC glad_glColorFragmentOp1ATI;
-PFNGLCOLORFRAGMENTOP2ATIPROC glad_glColorFragmentOp2ATI;
-PFNGLCOLORFRAGMENTOP3ATIPROC glad_glColorFragmentOp3ATI;
-PFNGLALPHAFRAGMENTOP1ATIPROC glad_glAlphaFragmentOp1ATI;
-PFNGLALPHAFRAGMENTOP2ATIPROC glad_glAlphaFragmentOp2ATI;
-PFNGLALPHAFRAGMENTOP3ATIPROC glad_glAlphaFragmentOp3ATI;
-PFNGLSETFRAGMENTSHADERCONSTANTATIPROC glad_glSetFragmentShaderConstantATI;
-PFNGLNEWOBJECTBUFFERATIPROC glad_glNewObjectBufferATI;
-PFNGLISOBJECTBUFFERATIPROC glad_glIsObjectBufferATI;
-PFNGLUPDATEOBJECTBUFFERATIPROC glad_glUpdateObjectBufferATI;
-PFNGLGETOBJECTBUFFERFVATIPROC glad_glGetObjectBufferfvATI;
-PFNGLGETOBJECTBUFFERIVATIPROC glad_glGetObjectBufferivATI;
-PFNGLFREEOBJECTBUFFERATIPROC glad_glFreeObjectBufferATI;
-PFNGLARRAYOBJECTATIPROC glad_glArrayObjectATI;
-PFNGLGETARRAYOBJECTFVATIPROC glad_glGetArrayObjectfvATI;
-PFNGLGETARRAYOBJECTIVATIPROC glad_glGetArrayObjectivATI;
-PFNGLVARIANTARRAYOBJECTATIPROC glad_glVariantArrayObjectATI;
-PFNGLGETVARIANTARRAYOBJECTFVATIPROC glad_glGetVariantArrayObjectfvATI;
-PFNGLGETVARIANTARRAYOBJECTIVATIPROC glad_glGetVariantArrayObjectivATI;
-PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
-PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
-PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
-PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
-PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
-PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
-PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
-PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
-PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT;
-PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT;
-PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT;
-PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
-PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT;
-PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT;
-PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT;
-PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT;
-PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT;
-PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT;
-PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT;
-PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT;
-PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT;
-PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT;
-PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT;
-PFNGLARRAYELEMENTEXTPROC glad_glArrayElementEXT;
-PFNGLCOLORPOINTEREXTPROC glad_glColorPointerEXT;
-PFNGLDRAWARRAYSEXTPROC glad_glDrawArraysEXT;
-PFNGLEDGEFLAGPOINTEREXTPROC glad_glEdgeFlagPointerEXT;
-PFNGLGETPOINTERVEXTPROC glad_glGetPointervEXT;
-PFNGLINDEXPOINTEREXTPROC glad_glIndexPointerEXT;
-PFNGLNORMALPOINTEREXTPROC glad_glNormalPointerEXT;
-PFNGLTEXCOORDPOINTEREXTPROC glad_glTexCoordPointerEXT;
-PFNGLVERTEXPOINTEREXTPROC glad_glVertexPointerEXT;
-PFNGLBEGINVERTEXSHADEREXTPROC glad_glBeginVertexShaderEXT;
-PFNGLENDVERTEXSHADEREXTPROC glad_glEndVertexShaderEXT;
-PFNGLBINDVERTEXSHADEREXTPROC glad_glBindVertexShaderEXT;
-PFNGLGENVERTEXSHADERSEXTPROC glad_glGenVertexShadersEXT;
-PFNGLDELETEVERTEXSHADEREXTPROC glad_glDeleteVertexShaderEXT;
-PFNGLSHADEROP1EXTPROC glad_glShaderOp1EXT;
-PFNGLSHADEROP2EXTPROC glad_glShaderOp2EXT;
-PFNGLSHADEROP3EXTPROC glad_glShaderOp3EXT;
-PFNGLSWIZZLEEXTPROC glad_glSwizzleEXT;
-PFNGLWRITEMASKEXTPROC glad_glWriteMaskEXT;
-PFNGLINSERTCOMPONENTEXTPROC glad_glInsertComponentEXT;
-PFNGLEXTRACTCOMPONENTEXTPROC glad_glExtractComponentEXT;
-PFNGLGENSYMBOLSEXTPROC glad_glGenSymbolsEXT;
-PFNGLSETINVARIANTEXTPROC glad_glSetInvariantEXT;
-PFNGLSETLOCALCONSTANTEXTPROC glad_glSetLocalConstantEXT;
-PFNGLVARIANTBVEXTPROC glad_glVariantbvEXT;
-PFNGLVARIANTSVEXTPROC glad_glVariantsvEXT;
-PFNGLVARIANTIVEXTPROC glad_glVariantivEXT;
-PFNGLVARIANTFVEXTPROC glad_glVariantfvEXT;
-PFNGLVARIANTDVEXTPROC glad_glVariantdvEXT;
-PFNGLVARIANTUBVEXTPROC glad_glVariantubvEXT;
-PFNGLVARIANTUSVEXTPROC glad_glVariantusvEXT;
-PFNGLVARIANTUIVEXTPROC glad_glVariantuivEXT;
-PFNGLVARIANTPOINTEREXTPROC glad_glVariantPointerEXT;
-PFNGLENABLEVARIANTCLIENTSTATEEXTPROC glad_glEnableVariantClientStateEXT;
-PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC glad_glDisableVariantClientStateEXT;
-PFNGLBINDLIGHTPARAMETEREXTPROC glad_glBindLightParameterEXT;
-PFNGLBINDMATERIALPARAMETEREXTPROC glad_glBindMaterialParameterEXT;
-PFNGLBINDTEXGENPARAMETEREXTPROC glad_glBindTexGenParameterEXT;
-PFNGLBINDTEXTUREUNITPARAMETEREXTPROC glad_glBindTextureUnitParameterEXT;
-PFNGLBINDPARAMETEREXTPROC glad_glBindParameterEXT;
-PFNGLISVARIANTENABLEDEXTPROC glad_glIsVariantEnabledEXT;
-PFNGLGETVARIANTBOOLEANVEXTPROC glad_glGetVariantBooleanvEXT;
-PFNGLGETVARIANTINTEGERVEXTPROC glad_glGetVariantIntegervEXT;
-PFNGLGETVARIANTFLOATVEXTPROC glad_glGetVariantFloatvEXT;
-PFNGLGETVARIANTPOINTERVEXTPROC glad_glGetVariantPointervEXT;
-PFNGLGETINVARIANTBOOLEANVEXTPROC glad_glGetInvariantBooleanvEXT;
-PFNGLGETINVARIANTINTEGERVEXTPROC glad_glGetInvariantIntegervEXT;
-PFNGLGETINVARIANTFLOATVEXTPROC glad_glGetInvariantFloatvEXT;
-PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC glad_glGetLocalConstantBooleanvEXT;
-PFNGLGETLOCALCONSTANTINTEGERVEXTPROC glad_glGetLocalConstantIntegervEXT;
-PFNGLGETLOCALCONSTANTFLOATVEXTPROC glad_glGetLocalConstantFloatvEXT;
-static void load_GL_VERSION_1_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_0) return;
-       glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace");
-       glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace");
-       glad_glHint = (PFNGLHINTPROC)load("glHint");
-       glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth");
-       glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize");
-       glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode");
-       glad_glScissor = (PFNGLSCISSORPROC)load("glScissor");
-       glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf");
-       glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv");
-       glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri");
-       glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv");
-       glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D");
-       glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D");
-       glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer");
-       glad_glClear = (PFNGLCLEARPROC)load("glClear");
-       glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor");
-       glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil");
-       glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth");
-       glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
-       glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask");
-       glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask");
-       glad_glDisable = (PFNGLDISABLEPROC)load("glDisable");
-       glad_glEnable = (PFNGLENABLEPROC)load("glEnable");
-       glad_glFinish = (PFNGLFINISHPROC)load("glFinish");
-       glad_glFlush = (PFNGLFLUSHPROC)load("glFlush");
-       glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc");
-       glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp");
-       glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
-       glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
-       glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc");
-       glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref");
-       glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei");
-       glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer");
-       glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels");
-       glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv");
-       glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev");
-       glad_glGetError = (PFNGLGETERRORPROC)load("glGetError");
-       glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv");
-       glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv");
-       glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
-       glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage");
-       glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv");
-       glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv");
-       glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv");
-       glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv");
-       glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled");
-       glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange");
-       glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport");
-}
-static void load_GL_VERSION_1_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_1) return;
-       glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays");
-       glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements");
-       glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset");
-       glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D");
-       glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D");
-       glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D");
-       glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D");
-       glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D");
-       glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D");
-       glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture");
-       glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures");
-       glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures");
-       glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture");
-}
-static void load_GL_VERSION_1_2(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_2) return;
-       glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements");
-       glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D");
-       glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D");
-       glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D");
-}
-static void load_GL_VERSION_1_3(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_3) return;
-       glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture");
-       glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage");
-       glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D");
-       glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D");
-       glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D");
-       glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D");
-       glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D");
-       glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D");
-       glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage");
-}
-static void load_GL_VERSION_1_4(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_4) return;
-       glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate");
-       glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays");
-       glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements");
-       glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf");
-       glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv");
-       glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri");
-       glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv");
-       glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor");
-       glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation");
-}
-static void load_GL_VERSION_1_5(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_5) return;
-       glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries");
-       glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries");
-       glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery");
-       glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery");
-       glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery");
-       glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv");
-       glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv");
-       glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv");
-       glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer");
-       glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers");
-       glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers");
-       glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer");
-       glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData");
-       glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData");
-       glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData");
-       glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer");
-       glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer");
-       glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv");
-       glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv");
-}
-static void load_GL_VERSION_2_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_2_0) return;
-       glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate");
-       glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers");
-       glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate");
-       glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate");
-       glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate");
-       glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader");
-       glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation");
-       glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader");
-       glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram");
-       glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader");
-       glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram");
-       glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader");
-       glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader");
-       glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray");
-       glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray");
-       glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib");
-       glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform");
-       glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders");
-       glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation");
-       glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv");
-       glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog");
-       glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv");
-       glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog");
-       glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource");
-       glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation");
-       glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv");
-       glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv");
-       glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv");
-       glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv");
-       glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv");
-       glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv");
-       glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram");
-       glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader");
-       glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram");
-       glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource");
-       glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram");
-       glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f");
-       glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f");
-       glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f");
-       glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f");
-       glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i");
-       glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i");
-       glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i");
-       glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i");
-       glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv");
-       glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv");
-       glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv");
-       glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv");
-       glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv");
-       glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv");
-       glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv");
-       glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv");
-       glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv");
-       glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv");
-       glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv");
-       glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram");
-       glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d");
-       glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv");
-       glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f");
-       glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv");
-       glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s");
-       glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv");
-       glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d");
-       glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv");
-       glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f");
-       glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv");
-       glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s");
-       glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv");
-       glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d");
-       glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv");
-       glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f");
-       glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv");
-       glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s");
-       glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv");
-       glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv");
-       glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv");
-       glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv");
-       glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub");
-       glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv");
-       glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv");
-       glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv");
-       glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv");
-       glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d");
-       glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv");
-       glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f");
-       glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv");
-       glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv");
-       glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s");
-       glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv");
-       glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv");
-       glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv");
-       glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv");
-       glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer");
-}
-static void load_GL_VERSION_2_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_2_1) return;
-       glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv");
-       glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv");
-       glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv");
-       glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv");
-       glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv");
-       glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv");
-}
-static void load_GL_VERSION_3_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_0) return;
-       glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski");
-       glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-       glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei");
-       glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei");
-       glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi");
-       glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback");
-       glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings");
-       glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying");
-       glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor");
-       glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender");
-       glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender");
-       glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer");
-       glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv");
-       glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv");
-       glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i");
-       glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i");
-       glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i");
-       glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i");
-       glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui");
-       glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui");
-       glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui");
-       glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui");
-       glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv");
-       glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv");
-       glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv");
-       glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv");
-       glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv");
-       glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv");
-       glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv");
-       glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv");
-       glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv");
-       glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv");
-       glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv");
-       glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv");
-       glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv");
-       glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation");
-       glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation");
-       glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui");
-       glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui");
-       glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui");
-       glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui");
-       glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv");
-       glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv");
-       glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv");
-       glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv");
-       glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv");
-       glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv");
-       glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv");
-       glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv");
-       glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv");
-       glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv");
-       glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv");
-       glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi");
-       glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi");
-       glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
-       glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
-       glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
-       glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
-       glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
-       glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
-       glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
-       glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
-       glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
-       glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
-       glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
-       glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
-       glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
-       glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
-       glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
-       glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
-       glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
-       glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
-       glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
-       glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
-       glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange");
-       glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange");
-       glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
-       glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
-       glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
-       glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
-}
-static void load_GL_VERSION_3_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_1) return;
-       glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced");
-       glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced");
-       glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer");
-       glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex");
-       glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData");
-       glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
-       glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
-       glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
-       glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
-       glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
-       glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
-       glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-}
-static void load_GL_VERSION_3_2(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_2) return;
-       glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex");
-       glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex");
-       glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex");
-       glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex");
-       glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex");
-       glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync");
-       glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync");
-       glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync");
-       glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync");
-       glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync");
-       glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v");
-       glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv");
-       glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v");
-       glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v");
-       glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture");
-       glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
-       glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
-       glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
-       glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
-}
-static void load_GL_VERSION_3_3(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_3) return;
-       glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed");
-       glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
-       glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
-       glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers");
-       glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler");
-       glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler");
-       glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri");
-       glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv");
-       glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf");
-       glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv");
-       glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv");
-       glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv");
-       glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv");
-       glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv");
-       glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv");
-       glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv");
-       glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter");
-       glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v");
-       glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v");
-       glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor");
-       glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui");
-       glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv");
-       glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui");
-       glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv");
-       glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui");
-       glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv");
-       glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui");
-       glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv");
-       glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui");
-       glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv");
-       glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui");
-       glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv");
-       glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui");
-       glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv");
-       glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui");
-       glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv");
-       glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui");
-       glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv");
-       glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui");
-       glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv");
-       glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui");
-       glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv");
-       glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui");
-       glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv");
-       glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui");
-       glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv");
-       glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui");
-       glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv");
-       glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui");
-       glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv");
-       glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui");
-       glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv");
-       glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui");
-       glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv");
-       glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui");
-       glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv");
-       glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui");
-       glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv");
-}
-static void load_GL_AMD_debug_output(GLADloadproc load) {
-       if(!GLAD_GL_AMD_debug_output) return;
-       glad_glDebugMessageEnableAMD = (PFNGLDEBUGMESSAGEENABLEAMDPROC)load("glDebugMessageEnableAMD");
-       glad_glDebugMessageInsertAMD = (PFNGLDEBUGMESSAGEINSERTAMDPROC)load("glDebugMessageInsertAMD");
-       glad_glDebugMessageCallbackAMD = (PFNGLDEBUGMESSAGECALLBACKAMDPROC)load("glDebugMessageCallbackAMD");
-       glad_glGetDebugMessageLogAMD = (PFNGLGETDEBUGMESSAGELOGAMDPROC)load("glGetDebugMessageLogAMD");
-}
-static void load_GL_ARB_ES2_compatibility(GLADloadproc load) {
-       if(!GLAD_GL_ARB_ES2_compatibility) return;
-       glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load("glReleaseShaderCompiler");
-       glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load("glShaderBinary");
-       glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load("glGetShaderPrecisionFormat");
-       glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load("glDepthRangef");
-       glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf");
-}
-static void load_GL_ARB_buffer_storage(GLADloadproc load) {
-       if(!GLAD_GL_ARB_buffer_storage) return;
-       glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC)load("glBufferStorage");
-}
-static void load_GL_ARB_debug_output(GLADloadproc load) {
-       if(!GLAD_GL_ARB_debug_output) return;
-       glad_glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)load("glDebugMessageControlARB");
-       glad_glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)load("glDebugMessageInsertARB");
-       glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
-       glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)load("glGetDebugMessageLogARB");
-}
-static void load_GL_ARB_draw_buffers(GLADloadproc load) {
-       if(!GLAD_GL_ARB_draw_buffers) return;
-       glad_glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)load("glDrawBuffersARB");
-}
-static void load_GL_ARB_draw_buffers_blend(GLADloadproc load) {
-       if(!GLAD_GL_ARB_draw_buffers_blend) return;
-       glad_glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC)load("glBlendEquationiARB");
-       glad_glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC)load("glBlendEquationSeparateiARB");
-       glad_glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC)load("glBlendFunciARB");
-       glad_glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC)load("glBlendFuncSeparateiARB");
-}
-static void load_GL_ARB_fragment_program(GLADloadproc load) {
-       if(!GLAD_GL_ARB_fragment_program) return;
-       glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)load("glProgramStringARB");
-       glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)load("glBindProgramARB");
-       glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)load("glDeleteProgramsARB");
-       glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)load("glGenProgramsARB");
-       glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)load("glProgramEnvParameter4dARB");
-       glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)load("glProgramEnvParameter4dvARB");
-       glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)load("glProgramEnvParameter4fARB");
-       glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)load("glProgramEnvParameter4fvARB");
-       glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)load("glProgramLocalParameter4dARB");
-       glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)load("glProgramLocalParameter4dvARB");
-       glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)load("glProgramLocalParameter4fARB");
-       glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)load("glProgramLocalParameter4fvARB");
-       glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)load("glGetProgramEnvParameterdvARB");
-       glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)load("glGetProgramEnvParameterfvARB");
-       glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)load("glGetProgramLocalParameterdvARB");
-       glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)load("glGetProgramLocalParameterfvARB");
-       glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)load("glGetProgramivARB");
-       glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)load("glGetProgramStringARB");
-       glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC)load("glIsProgramARB");
-}
-static void load_GL_ARB_framebuffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_framebuffer_object) return;
-       glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
-       glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
-       glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
-       glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
-       glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
-       glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
-       glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
-       glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
-       glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
-       glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
-       glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
-       glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
-       glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
-       glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
-       glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
-       glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
-       glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
-       glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
-       glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
-       glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
-}
-static void load_GL_ARB_multisample(GLADloadproc load) {
-       if(!GLAD_GL_ARB_multisample) return;
-       glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)load("glSampleCoverageARB");
-}
-static void load_GL_ARB_sample_locations(GLADloadproc load) {
-       if(!GLAD_GL_ARB_sample_locations) return;
-       glad_glFramebufferSampleLocationsfvARB = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)load("glFramebufferSampleLocationsfvARB");
-       glad_glNamedFramebufferSampleLocationsfvARB = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)load("glNamedFramebufferSampleLocationsfvARB");
-       glad_glEvaluateDepthValuesARB = (PFNGLEVALUATEDEPTHVALUESARBPROC)load("glEvaluateDepthValuesARB");
-}
-static void load_GL_ARB_texture_compression(GLADloadproc load) {
-       if(!GLAD_GL_ARB_texture_compression) return;
-       glad_glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)load("glCompressedTexImage3DARB");
-       glad_glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)load("glCompressedTexImage2DARB");
-       glad_glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)load("glCompressedTexImage1DARB");
-       glad_glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)load("glCompressedTexSubImage3DARB");
-       glad_glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)load("glCompressedTexSubImage2DARB");
-       glad_glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)load("glCompressedTexSubImage1DARB");
-       glad_glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)load("glGetCompressedTexImageARB");
-}
-static void load_GL_ARB_texture_multisample(GLADloadproc load) {
-       if(!GLAD_GL_ARB_texture_multisample) return;
-       glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
-       glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
-       glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
-       glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
-}
-static void load_GL_ARB_uniform_buffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_uniform_buffer_object) return;
-       glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
-       glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
-       glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
-       glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
-       glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
-       glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
-       glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-}
-static void load_GL_ARB_vertex_array_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_array_object) return;
-       glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
-       glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
-       glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
-       glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
-}
-static void load_GL_ARB_vertex_attrib_binding(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_attrib_binding) return;
-       glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load("glBindVertexBuffer");
-       glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load("glVertexAttribFormat");
-       glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load("glVertexAttribIFormat");
-       glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load("glVertexAttribLFormat");
-       glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load("glVertexAttribBinding");
-       glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load("glVertexBindingDivisor");
-}
-static void load_GL_ARB_vertex_buffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_buffer_object) return;
-       glad_glBindBufferARB = (PFNGLBINDBUFFERARBPROC)load("glBindBufferARB");
-       glad_glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)load("glDeleteBuffersARB");
-       glad_glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)load("glGenBuffersARB");
-       glad_glIsBufferARB = (PFNGLISBUFFERARBPROC)load("glIsBufferARB");
-       glad_glBufferDataARB = (PFNGLBUFFERDATAARBPROC)load("glBufferDataARB");
-       glad_glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)load("glBufferSubDataARB");
-       glad_glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)load("glGetBufferSubDataARB");
-       glad_glMapBufferARB = (PFNGLMAPBUFFERARBPROC)load("glMapBufferARB");
-       glad_glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)load("glUnmapBufferARB");
-       glad_glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)load("glGetBufferParameterivARB");
-       glad_glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)load("glGetBufferPointervARB");
-}
-static void load_GL_ARB_vertex_program(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_program) return;
-       glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)load("glVertexAttrib1dARB");
-       glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)load("glVertexAttrib1dvARB");
-       glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)load("glVertexAttrib1fARB");
-       glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)load("glVertexAttrib1fvARB");
-       glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)load("glVertexAttrib1sARB");
-       glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)load("glVertexAttrib1svARB");
-       glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)load("glVertexAttrib2dARB");
-       glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)load("glVertexAttrib2dvARB");
-       glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)load("glVertexAttrib2fARB");
-       glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)load("glVertexAttrib2fvARB");
-       glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)load("glVertexAttrib2sARB");
-       glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)load("glVertexAttrib2svARB");
-       glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)load("glVertexAttrib3dARB");
-       glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)load("glVertexAttrib3dvARB");
-       glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)load("glVertexAttrib3fARB");
-       glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)load("glVertexAttrib3fvARB");
-       glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)load("glVertexAttrib3sARB");
-       glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)load("glVertexAttrib3svARB");
-       glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)load("glVertexAttrib4NbvARB");
-       glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)load("glVertexAttrib4NivARB");
-       glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)load("glVertexAttrib4NsvARB");
-       glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)load("glVertexAttrib4NubARB");
-       glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)load("glVertexAttrib4NubvARB");
-       glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)load("glVertexAttrib4NuivARB");
-       glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)load("glVertexAttrib4NusvARB");
-       glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)load("glVertexAttrib4bvARB");
-       glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)load("glVertexAttrib4dARB");
-       glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)load("glVertexAttrib4dvARB");
-       glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)load("glVertexAttrib4fARB");
-       glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)load("glVertexAttrib4fvARB");
-       glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)load("glVertexAttrib4ivARB");
-       glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)load("glVertexAttrib4sARB");
-       glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)load("glVertexAttrib4svARB");
-       glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)load("glVertexAttrib4ubvARB");
-       glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)load("glVertexAttrib4uivARB");
-       glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)load("glVertexAttrib4usvARB");
-       glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)load("glVertexAttribPointerARB");
-       glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)load("glEnableVertexAttribArrayARB");
-       glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)load("glDisableVertexAttribArrayARB");
-       glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)load("glProgramStringARB");
-       glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)load("glBindProgramARB");
-       glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)load("glDeleteProgramsARB");
-       glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)load("glGenProgramsARB");
-       glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)load("glProgramEnvParameter4dARB");
-       glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)load("glProgramEnvParameter4dvARB");
-       glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)load("glProgramEnvParameter4fARB");
-       glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)load("glProgramEnvParameter4fvARB");
-       glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)load("glProgramLocalParameter4dARB");
-       glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)load("glProgramLocalParameter4dvARB");
-       glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)load("glProgramLocalParameter4fARB");
-       glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)load("glProgramLocalParameter4fvARB");
-       glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)load("glGetProgramEnvParameterdvARB");
-       glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)load("glGetProgramEnvParameterfvARB");
-       glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)load("glGetProgramLocalParameterdvARB");
-       glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)load("glGetProgramLocalParameterfvARB");
-       glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)load("glGetProgramivARB");
-       glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)load("glGetProgramStringARB");
-       glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)load("glGetVertexAttribdvARB");
-       glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)load("glGetVertexAttribfvARB");
-       glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)load("glGetVertexAttribivARB");
-       glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)load("glGetVertexAttribPointervARB");
-       glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC)load("glIsProgramARB");
-}
-static void load_GL_ARB_vertex_shader(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_shader) return;
-       glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)load("glVertexAttrib1fARB");
-       glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)load("glVertexAttrib1sARB");
-       glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)load("glVertexAttrib1dARB");
-       glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)load("glVertexAttrib2fARB");
-       glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)load("glVertexAttrib2sARB");
-       glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)load("glVertexAttrib2dARB");
-       glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)load("glVertexAttrib3fARB");
-       glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)load("glVertexAttrib3sARB");
-       glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)load("glVertexAttrib3dARB");
-       glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)load("glVertexAttrib4fARB");
-       glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)load("glVertexAttrib4sARB");
-       glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)load("glVertexAttrib4dARB");
-       glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)load("glVertexAttrib4NubARB");
-       glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)load("glVertexAttrib1fvARB");
-       glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)load("glVertexAttrib1svARB");
-       glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)load("glVertexAttrib1dvARB");
-       glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)load("glVertexAttrib2fvARB");
-       glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)load("glVertexAttrib2svARB");
-       glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)load("glVertexAttrib2dvARB");
-       glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)load("glVertexAttrib3fvARB");
-       glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)load("glVertexAttrib3svARB");
-       glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)load("glVertexAttrib3dvARB");
-       glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)load("glVertexAttrib4fvARB");
-       glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)load("glVertexAttrib4svARB");
-       glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)load("glVertexAttrib4dvARB");
-       glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)load("glVertexAttrib4ivARB");
-       glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)load("glVertexAttrib4bvARB");
-       glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)load("glVertexAttrib4ubvARB");
-       glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)load("glVertexAttrib4usvARB");
-       glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)load("glVertexAttrib4uivARB");
-       glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)load("glVertexAttrib4NbvARB");
-       glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)load("glVertexAttrib4NsvARB");
-       glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)load("glVertexAttrib4NivARB");
-       glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)load("glVertexAttrib4NubvARB");
-       glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)load("glVertexAttrib4NusvARB");
-       glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)load("glVertexAttrib4NuivARB");
-       glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)load("glVertexAttribPointerARB");
-       glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)load("glEnableVertexAttribArrayARB");
-       glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)load("glDisableVertexAttribArrayARB");
-       glad_glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)load("glBindAttribLocationARB");
-       glad_glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)load("glGetActiveAttribARB");
-       glad_glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)load("glGetAttribLocationARB");
-       glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)load("glGetVertexAttribdvARB");
-       glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)load("glGetVertexAttribfvARB");
-       glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)load("glGetVertexAttribivARB");
-       glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)load("glGetVertexAttribPointervARB");
-}
-static void load_GL_ATI_element_array(GLADloadproc load) {
-       if(!GLAD_GL_ATI_element_array) return;
-       glad_glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)load("glElementPointerATI");
-       glad_glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)load("glDrawElementArrayATI");
-       glad_glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)load("glDrawRangeElementArrayATI");
-}
-static void load_GL_ATI_fragment_shader(GLADloadproc load) {
-       if(!GLAD_GL_ATI_fragment_shader) return;
-       glad_glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)load("glGenFragmentShadersATI");
-       glad_glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)load("glBindFragmentShaderATI");
-       glad_glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)load("glDeleteFragmentShaderATI");
-       glad_glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)load("glBeginFragmentShaderATI");
-       glad_glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)load("glEndFragmentShaderATI");
-       glad_glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)load("glPassTexCoordATI");
-       glad_glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)load("glSampleMapATI");
-       glad_glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)load("glColorFragmentOp1ATI");
-       glad_glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)load("glColorFragmentOp2ATI");
-       glad_glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)load("glColorFragmentOp3ATI");
-       glad_glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)load("glAlphaFragmentOp1ATI");
-       glad_glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)load("glAlphaFragmentOp2ATI");
-       glad_glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)load("glAlphaFragmentOp3ATI");
-       glad_glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)load("glSetFragmentShaderConstantATI");
-}
-static void load_GL_ATI_vertex_array_object(GLADloadproc load) {
-       if(!GLAD_GL_ATI_vertex_array_object) return;
-       glad_glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)load("glNewObjectBufferATI");
-       glad_glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)load("glIsObjectBufferATI");
-       glad_glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)load("glUpdateObjectBufferATI");
-       glad_glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)load("glGetObjectBufferfvATI");
-       glad_glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)load("glGetObjectBufferivATI");
-       glad_glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)load("glFreeObjectBufferATI");
-       glad_glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)load("glArrayObjectATI");
-       glad_glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)load("glGetArrayObjectfvATI");
-       glad_glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)load("glGetArrayObjectivATI");
-       glad_glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)load("glVariantArrayObjectATI");
-       glad_glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)load("glGetVariantArrayObjectfvATI");
-       glad_glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)load("glGetVariantArrayObjectivATI");
-}
-static void load_GL_EXT_blend_color(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_color) return;
-       glad_glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)load("glBlendColorEXT");
-}
-static void load_GL_EXT_blend_equation_separate(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_equation_separate) return;
-       glad_glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)load("glBlendEquationSeparateEXT");
-}
-static void load_GL_EXT_blend_func_separate(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_func_separate) return;
-       glad_glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)load("glBlendFuncSeparateEXT");
-}
-static void load_GL_EXT_debug_marker(GLADloadproc load) {
-       if(!GLAD_GL_EXT_debug_marker) return;
-       glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC)load("glInsertEventMarkerEXT");
-       glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC)load("glPushGroupMarkerEXT");
-       glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC)load("glPopGroupMarkerEXT");
-}
-static void load_GL_EXT_framebuffer_blit(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_blit) return;
-       glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)load("glBlitFramebufferEXT");
-}
-static void load_GL_EXT_framebuffer_multisample(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_multisample) return;
-       glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)load("glRenderbufferStorageMultisampleEXT");
-}
-static void load_GL_EXT_framebuffer_object(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_object) return;
-       glad_glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)load("glIsRenderbufferEXT");
-       glad_glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)load("glBindRenderbufferEXT");
-       glad_glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)load("glDeleteRenderbuffersEXT");
-       glad_glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)load("glGenRenderbuffersEXT");
-       glad_glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)load("glRenderbufferStorageEXT");
-       glad_glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)load("glGetRenderbufferParameterivEXT");
-       glad_glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)load("glIsFramebufferEXT");
-       glad_glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)load("glBindFramebufferEXT");
-       glad_glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)load("glDeleteFramebuffersEXT");
-       glad_glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)load("glGenFramebuffersEXT");
-       glad_glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)load("glCheckFramebufferStatusEXT");
-       glad_glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)load("glFramebufferTexture1DEXT");
-       glad_glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)load("glFramebufferTexture2DEXT");
-       glad_glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)load("glFramebufferTexture3DEXT");
-       glad_glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)load("glFramebufferRenderbufferEXT");
-       glad_glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)load("glGetFramebufferAttachmentParameterivEXT");
-       glad_glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)load("glGenerateMipmapEXT");
-}
-static void load_GL_EXT_vertex_array(GLADloadproc load) {
-       if(!GLAD_GL_EXT_vertex_array) return;
-       glad_glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)load("glArrayElementEXT");
-       glad_glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)load("glColorPointerEXT");
-       glad_glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)load("glDrawArraysEXT");
-       glad_glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)load("glEdgeFlagPointerEXT");
-       glad_glGetPointervEXT = (PFNGLGETPOINTERVEXTPROC)load("glGetPointervEXT");
-       glad_glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)load("glIndexPointerEXT");
-       glad_glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)load("glNormalPointerEXT");
-       glad_glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)load("glTexCoordPointerEXT");
-       glad_glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)load("glVertexPointerEXT");
-}
-static void load_GL_EXT_vertex_shader(GLADloadproc load) {
-       if(!GLAD_GL_EXT_vertex_shader) return;
-       glad_glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)load("glBeginVertexShaderEXT");
-       glad_glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)load("glEndVertexShaderEXT");
-       glad_glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)load("glBindVertexShaderEXT");
-       glad_glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)load("glGenVertexShadersEXT");
-       glad_glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)load("glDeleteVertexShaderEXT");
-       glad_glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)load("glShaderOp1EXT");
-       glad_glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)load("glShaderOp2EXT");
-       glad_glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)load("glShaderOp3EXT");
-       glad_glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)load("glSwizzleEXT");
-       glad_glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)load("glWriteMaskEXT");
-       glad_glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)load("glInsertComponentEXT");
-       glad_glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)load("glExtractComponentEXT");
-       glad_glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)load("glGenSymbolsEXT");
-       glad_glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)load("glSetInvariantEXT");
-       glad_glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)load("glSetLocalConstantEXT");
-       glad_glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)load("glVariantbvEXT");
-       glad_glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)load("glVariantsvEXT");
-       glad_glVariantivEXT = (PFNGLVARIANTIVEXTPROC)load("glVariantivEXT");
-       glad_glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)load("glVariantfvEXT");
-       glad_glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)load("glVariantdvEXT");
-       glad_glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)load("glVariantubvEXT");
-       glad_glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)load("glVariantusvEXT");
-       glad_glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)load("glVariantuivEXT");
-       glad_glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)load("glVariantPointerEXT");
-       glad_glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)load("glEnableVariantClientStateEXT");
-       glad_glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)load("glDisableVariantClientStateEXT");
-       glad_glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)load("glBindLightParameterEXT");
-       glad_glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)load("glBindMaterialParameterEXT");
-       glad_glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)load("glBindTexGenParameterEXT");
-       glad_glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)load("glBindTextureUnitParameterEXT");
-       glad_glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)load("glBindParameterEXT");
-       glad_glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)load("glIsVariantEnabledEXT");
-       glad_glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)load("glGetVariantBooleanvEXT");
-       glad_glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)load("glGetVariantIntegervEXT");
-       glad_glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)load("glGetVariantFloatvEXT");
-       glad_glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)load("glGetVariantPointervEXT");
-       glad_glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)load("glGetInvariantBooleanvEXT");
-       glad_glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)load("glGetInvariantIntegervEXT");
-       glad_glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)load("glGetInvariantFloatvEXT");
-       glad_glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)load("glGetLocalConstantBooleanvEXT");
-       glad_glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)load("glGetLocalConstantIntegervEXT");
-       glad_glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)load("glGetLocalConstantFloatvEXT");
-}
-static int find_extensionsGL(void) {
-       if (!get_exts()) return 0;
-       GLAD_GL_AMD_debug_output = has_ext("GL_AMD_debug_output");
-       GLAD_GL_AMD_query_buffer_object = has_ext("GL_AMD_query_buffer_object");
-       GLAD_GL_ARB_ES2_compatibility = has_ext("GL_ARB_ES2_compatibility");
-       GLAD_GL_ARB_ES3_compatibility = has_ext("GL_ARB_ES3_compatibility");
-       GLAD_GL_ARB_buffer_storage = has_ext("GL_ARB_buffer_storage");
-       GLAD_GL_ARB_compatibility = has_ext("GL_ARB_compatibility");
-       GLAD_GL_ARB_compressed_texture_pixel_storage = has_ext("GL_ARB_compressed_texture_pixel_storage");
-       GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
-       GLAD_GL_ARB_depth_buffer_float = has_ext("GL_ARB_depth_buffer_float");
-       GLAD_GL_ARB_depth_clamp = has_ext("GL_ARB_depth_clamp");
-       GLAD_GL_ARB_depth_texture = has_ext("GL_ARB_depth_texture");
-       GLAD_GL_ARB_draw_buffers = has_ext("GL_ARB_draw_buffers");
-       GLAD_GL_ARB_draw_buffers_blend = has_ext("GL_ARB_draw_buffers_blend");
-       GLAD_GL_ARB_explicit_attrib_location = has_ext("GL_ARB_explicit_attrib_location");
-       GLAD_GL_ARB_explicit_uniform_location = has_ext("GL_ARB_explicit_uniform_location");
-       GLAD_GL_ARB_fragment_program = has_ext("GL_ARB_fragment_program");
-       GLAD_GL_ARB_fragment_shader = has_ext("GL_ARB_fragment_shader");
-       GLAD_GL_ARB_framebuffer_object = has_ext("GL_ARB_framebuffer_object");
-       GLAD_GL_ARB_framebuffer_sRGB = has_ext("GL_ARB_framebuffer_sRGB");
-       GLAD_GL_ARB_multisample = has_ext("GL_ARB_multisample");
-       GLAD_GL_ARB_sample_locations = has_ext("GL_ARB_sample_locations");
-       GLAD_GL_ARB_texture_compression = has_ext("GL_ARB_texture_compression");
-       GLAD_GL_ARB_texture_float = has_ext("GL_ARB_texture_float");
-       GLAD_GL_ARB_texture_multisample = has_ext("GL_ARB_texture_multisample");
-       GLAD_GL_ARB_texture_non_power_of_two = has_ext("GL_ARB_texture_non_power_of_two");
-       GLAD_GL_ARB_texture_rg = has_ext("GL_ARB_texture_rg");
-       GLAD_GL_ARB_texture_swizzle = has_ext("GL_ARB_texture_swizzle");
-       GLAD_GL_ARB_uniform_buffer_object = has_ext("GL_ARB_uniform_buffer_object");
-       GLAD_GL_ARB_vertex_array_object = has_ext("GL_ARB_vertex_array_object");
-       GLAD_GL_ARB_vertex_attrib_binding = has_ext("GL_ARB_vertex_attrib_binding");
-       GLAD_GL_ARB_vertex_buffer_object = has_ext("GL_ARB_vertex_buffer_object");
-       GLAD_GL_ARB_vertex_program = has_ext("GL_ARB_vertex_program");
-       GLAD_GL_ARB_vertex_shader = has_ext("GL_ARB_vertex_shader");
-       GLAD_GL_ATI_element_array = has_ext("GL_ATI_element_array");
-       GLAD_GL_ATI_fragment_shader = has_ext("GL_ATI_fragment_shader");
-       GLAD_GL_ATI_vertex_array_object = has_ext("GL_ATI_vertex_array_object");
-       GLAD_GL_EXT_blend_color = has_ext("GL_EXT_blend_color");
-       GLAD_GL_EXT_blend_equation_separate = has_ext("GL_EXT_blend_equation_separate");
-       GLAD_GL_EXT_blend_func_separate = has_ext("GL_EXT_blend_func_separate");
-       GLAD_GL_EXT_debug_marker = has_ext("GL_EXT_debug_marker");
-       GLAD_GL_EXT_framebuffer_blit = has_ext("GL_EXT_framebuffer_blit");
-       GLAD_GL_EXT_framebuffer_multisample = has_ext("GL_EXT_framebuffer_multisample");
-       GLAD_GL_EXT_framebuffer_multisample_blit_scaled = has_ext("GL_EXT_framebuffer_multisample_blit_scaled");
-       GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object");
-       GLAD_GL_EXT_framebuffer_sRGB = has_ext("GL_EXT_framebuffer_sRGB");
-       GLAD_GL_EXT_index_array_formats = has_ext("GL_EXT_index_array_formats");
-       GLAD_GL_EXT_texture = has_ext("GL_EXT_texture");
-       GLAD_GL_EXT_texture_compression_s3tc = has_ext("GL_EXT_texture_compression_s3tc");
-       GLAD_GL_EXT_texture_sRGB = has_ext("GL_EXT_texture_sRGB");
-       GLAD_GL_EXT_texture_swizzle = has_ext("GL_EXT_texture_swizzle");
-       GLAD_GL_EXT_vertex_array = has_ext("GL_EXT_vertex_array");
-       GLAD_GL_EXT_vertex_shader = has_ext("GL_EXT_vertex_shader");
-       free_exts();
-       return 1;
-}
-
-static void find_coreGL(void) {
-
-    /* Thank you @elmindreda
-     * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176
-     * https://github.com/glfw/glfw/blob/master/src/context.c#L36
-     */
-    int i, major, minor;
-
-    const char* version;
-    const char* prefixes[] = {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-
-    version = (const char*) glGetString(GL_VERSION);
-    if (!version) return;
-
-    for (i = 0;  prefixes[i];  i++) {
-        const size_t length = strlen(prefixes[i]);
-        if (strncmp(version, prefixes[i], length) == 0) {
-            version += length;
-            break;
-        }
-    }
-
-/* PR #18 */
-#ifdef _MSC_VER
-    sscanf_s(version, "%d.%d", &major, &minor);
-#else
-    sscanf(version, "%d.%d", &major, &minor);
-#endif
-
-    GLVersion.major = major; GLVersion.minor = minor;
-    max_loaded_major = major; max_loaded_minor = minor;
-       GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-       GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-       GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
-       GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
-       GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
-       GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
-       GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
-       GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
-       GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
-       GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
-       GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
-       GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
-       if (GLVersion.major > 3 || (GLVersion.major >= 3 && GLVersion.minor >= 3)) {
-               max_loaded_major = 3;
-               max_loaded_minor = 3;
-       }
-}
-
-int gladLoadGLLoader(GLADloadproc load) {
-       GLVersion.major = 0; GLVersion.minor = 0;
-       glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
-       if(glGetString == NULL) return 0;
-       if(glGetString(GL_VERSION) == NULL) return 0;
-       find_coreGL();
-       load_GL_VERSION_1_0(load);
-       load_GL_VERSION_1_1(load);
-       load_GL_VERSION_1_2(load);
-       load_GL_VERSION_1_3(load);
-       load_GL_VERSION_1_4(load);
-       load_GL_VERSION_1_5(load);
-       load_GL_VERSION_2_0(load);
-       load_GL_VERSION_2_1(load);
-       load_GL_VERSION_3_0(load);
-       load_GL_VERSION_3_1(load);
-       load_GL_VERSION_3_2(load);
-       load_GL_VERSION_3_3(load);
-
-       if (!find_extensionsGL()) return 0;
-       load_GL_AMD_debug_output(load);
-       load_GL_ARB_ES2_compatibility(load);
-       load_GL_ARB_buffer_storage(load);
-       load_GL_ARB_debug_output(load);
-       load_GL_ARB_draw_buffers(load);
-       load_GL_ARB_draw_buffers_blend(load);
-       load_GL_ARB_fragment_program(load);
-       load_GL_ARB_framebuffer_object(load);
-       load_GL_ARB_multisample(load);
-       load_GL_ARB_sample_locations(load);
-       load_GL_ARB_texture_compression(load);
-       load_GL_ARB_texture_multisample(load);
-       load_GL_ARB_uniform_buffer_object(load);
-       load_GL_ARB_vertex_array_object(load);
-       load_GL_ARB_vertex_attrib_binding(load);
-       load_GL_ARB_vertex_buffer_object(load);
-       load_GL_ARB_vertex_program(load);
-       load_GL_ARB_vertex_shader(load);
-       load_GL_ATI_element_array(load);
-       load_GL_ATI_fragment_shader(load);
-       load_GL_ATI_vertex_array_object(load);
-       load_GL_EXT_blend_color(load);
-       load_GL_EXT_blend_equation_separate(load);
-       load_GL_EXT_blend_func_separate(load);
-       load_GL_EXT_debug_marker(load);
-       load_GL_EXT_framebuffer_blit(load);
-       load_GL_EXT_framebuffer_multisample(load);
-       load_GL_EXT_framebuffer_object(load);
-       load_GL_EXT_vertex_array(load);
-       load_GL_EXT_vertex_shader(load);
-       return GLVersion.major != 0 || GLVersion.minor != 0;
-}
-
-#endif  // GLAD_IMPLEMENTATION
diff --git a/raylib/external/glfw/.mailmap b/raylib/external/glfw/.mailmap
deleted file mode 100644 (file)
index 96d8a9b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Camilla Löwy <elmindreda@glfw.org> <elmindreda@users.sourceforge.net>
-Camilla Löwy <elmindreda@glfw.org> <elmindreda@elmindreda.org>
-Camilla Löwy <elmindreda@glfw.org>
-
-Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
-
-Marcus Geelnard <m@bitsnbites.eu> <marcus256@users.sourceforge.net>
-Marcus Geelnard <m@bitsnbites.eu> <marcus@geelnards-pc.(none)>
-Marcus Geelnard <m@bitsnbites.eu>
-
diff --git a/raylib/external/glfw/CMake/GenerateMappings.cmake b/raylib/external/glfw/CMake/GenerateMappings.cmake
deleted file mode 100644 (file)
index 7a88e3d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# Usage:
-# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
-
-set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
-set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
-set(template_path "${CMAKE_ARGV3}")
-set(target_path "${CMAKE_ARGV4}")
-
-if (NOT EXISTS "${template_path}")
-    message(FATAL_ERROR "Failed to find template file ${template_path}")
-endif()
-
-file(DOWNLOAD "${source_url}" "${source_path}"
-     STATUS download_status
-     TLS_VERIFY on)
-
-list(GET download_status 0 status_code)
-list(GET download_status 1 status_message)
-
-if (status_code)
-    message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
-endif()
-
-file(STRINGS "${source_path}" lines)
-foreach(line ${lines})
-    if ("${line}" MATCHES "^[0-9a-fA-F].*$")
-        set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n")
-    endif()
-endforeach()
-
-configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
-file(REMOVE "${source_path}")
-
diff --git a/raylib/external/glfw/CMake/Info.plist.in b/raylib/external/glfw/CMake/Info.plist.in
deleted file mode 100644 (file)
index 684ad79..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
-       <key>CFBundleGetInfoString</key>
-       <string>${MACOSX_BUNDLE_INFO_STRING}</string>
-       <key>CFBundleIconFile</key>
-       <string>${MACOSX_BUNDLE_ICON_FILE}</string>
-       <key>CFBundleIdentifier</key>
-       <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundleLongVersionString</key>
-       <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
-       <key>CFBundleName</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
-       <key>CFBundlePackageType</key>
-       <string>APPL</string>
-       <key>CFBundleShortVersionString</key>
-       <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
-       <key>CSResourcesFileMapped</key>
-       <true/>
-       <key>LSRequiresCarbon</key>
-       <true/>
-       <key>NSHumanReadableCopyright</key>
-       <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
-       <key>NSHighResolutionCapable</key>
-       <true/>
-</dict>
-</plist>
diff --git a/raylib/external/glfw/CMake/MacOSXBundleInfo.plist.in b/raylib/external/glfw/CMake/MacOSXBundleInfo.plist.in
deleted file mode 100644 (file)
index 684ad79..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
-       <key>CFBundleGetInfoString</key>
-       <string>${MACOSX_BUNDLE_INFO_STRING}</string>
-       <key>CFBundleIconFile</key>
-       <string>${MACOSX_BUNDLE_ICON_FILE}</string>
-       <key>CFBundleIdentifier</key>
-       <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundleLongVersionString</key>
-       <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
-       <key>CFBundleName</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
-       <key>CFBundlePackageType</key>
-       <string>APPL</string>
-       <key>CFBundleShortVersionString</key>
-       <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
-       <key>CSResourcesFileMapped</key>
-       <true/>
-       <key>LSRequiresCarbon</key>
-       <true/>
-       <key>NSHumanReadableCopyright</key>
-       <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
-       <key>NSHighResolutionCapable</key>
-       <true/>
-</dict>
-</plist>
diff --git a/raylib/external/glfw/CMake/cmake_uninstall.cmake.in b/raylib/external/glfw/CMake/cmake_uninstall.cmake.in
deleted file mode 100644 (file)
index 5ecc476..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt")
-    message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"")
-endif()
-
-file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
-
-foreach (file ${files})
-  message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
-  if (EXISTS "$ENV{DESTDIR}${file}")
-    exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
-                 OUTPUT_VARIABLE rm_out
-                 RETURN_VALUE rm_retval)
-    if (NOT "${rm_retval}" STREQUAL 0)
-      MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
-    endif()
-  elseif (IS_SYMLINK "$ENV{DESTDIR}${file}")
-    EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
-                 OUTPUT_VARIABLE rm_out
-                 RETURN_VALUE rm_retval)
-    if (NOT "${rm_retval}" STREQUAL 0)
-      message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"")
-    endif()
-  else()
-    message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
-  endif()
-endforeach()
-
diff --git a/raylib/external/glfw/CMake/glfw3.pc.in b/raylib/external/glfw/CMake/glfw3.pc.in
deleted file mode 100644 (file)
index f74298d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
-libdir=@CMAKE_INSTALL_FULL_LIBDIR@
-
-Name: GLFW
-Description: A multi-platform library for OpenGL, window and input
-Version: @GLFW_VERSION@
-URL: https://www.glfw.org/
-Requires.private: @GLFW_PKG_DEPS@
-Libs: -L${libdir} -l@GLFW_LIB_NAME@
-Libs.private: @GLFW_PKG_LIBS@
-Cflags: -I${includedir}
diff --git a/raylib/external/glfw/CMake/glfw3Config.cmake.in b/raylib/external/glfw/CMake/glfw3Config.cmake.in
deleted file mode 100644 (file)
index 4a13a88..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-include(CMakeFindDependencyMacro)
-find_dependency(Threads)
-include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")
diff --git a/raylib/external/glfw/CMake/i686-w64-mingw32-clang.cmake b/raylib/external/glfw/CMake/i686-w64-mingw32-clang.cmake
deleted file mode 100644 (file)
index 8726b23..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 32-bit MinGW-w64 Clang
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "i686-w64-mingw32-clang")
-SET(CMAKE_CXX_COMPILER   "i686-w64-mingw32-clang++")
-SET(CMAKE_RC_COMPILER    "i686-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "i686-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/external/glfw/CMake/i686-w64-mingw32.cmake b/raylib/external/glfw/CMake/i686-w64-mingw32.cmake
deleted file mode 100644 (file)
index 2ca4dcd..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 32-bit MinGW-w64 GCC
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "i686-w64-mingw32-gcc")
-SET(CMAKE_CXX_COMPILER   "i686-w64-mingw32-g++")
-SET(CMAKE_RC_COMPILER    "i686-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "i686-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/external/glfw/CMake/modules/FindEpollShim.cmake b/raylib/external/glfw/CMake/modules/FindEpollShim.cmake
deleted file mode 100644 (file)
index 2facb41..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Find EpollShim
-# Once done, this will define
-#
-#   EPOLLSHIM_FOUND - System has EpollShim
-#   EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories
-#   EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim
-
-find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
-find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
-
-if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
-       set(EPOLLSHIM_FOUND TRUE)
-endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
-mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
diff --git a/raylib/external/glfw/CMake/modules/FindOSMesa.cmake b/raylib/external/glfw/CMake/modules/FindOSMesa.cmake
deleted file mode 100644 (file)
index 3194bd9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# Try to find OSMesa on a Unix system
-#
-# This will define:
-#
-#   OSMESA_LIBRARIES   - Link these to use OSMesa
-#   OSMESA_INCLUDE_DIR - Include directory for OSMesa
-#
-# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
-
-if (NOT WIN32)
-
-  find_package (PkgConfig)
-  pkg_check_modules (PKG_OSMESA QUIET osmesa)
-
-  set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
-  set (OSMESA_LIBRARIES   ${PKG_OSMESA_LIBRARIES})
-
-endif ()
diff --git a/raylib/external/glfw/CMake/modules/FindWaylandProtocols.cmake b/raylib/external/glfw/CMake/modules/FindWaylandProtocols.cmake
deleted file mode 100644 (file)
index 8eb83f2..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-find_package(PkgConfig)
-
-pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION})
-
-execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
-                OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR
-                RESULT_VARIABLE _pkgconfig_failed)
-if (_pkgconfig_failed)
-    message(FATAL_ERROR "Missing wayland-protocols pkgdatadir")
-endif()
-
-string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}")
-
-find_package_handle_standard_args(WaylandProtocols
-    FOUND_VAR
-        WaylandProtocols_FOUND
-    REQUIRED_VARS
-        WaylandProtocols_PKGDATADIR
-    VERSION_VAR
-        WaylandProtocols_VERSION
-    HANDLE_COMPONENTS
-)
-
-set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND})
-set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR})
-set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION})
diff --git a/raylib/external/glfw/CMake/modules/FindXKBCommon.cmake b/raylib/external/glfw/CMake/modules/FindXKBCommon.cmake
deleted file mode 100644 (file)
index 0f571ee..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-# - Try to find XKBCommon
-# Once done, this will define
-#
-#   XKBCOMMON_FOUND - System has XKBCommon
-#   XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
-#   XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
-#   XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon
-
-find_package(PkgConfig)
-pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
-set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})
-
-find_path(XKBCOMMON_INCLUDE_DIR
-    NAMES xkbcommon/xkbcommon.h
-    HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
-)
-
-find_library(XKBCOMMON_LIBRARY
-    NAMES xkbcommon
-    HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS}
-)
-
-set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY})
-set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS})
-set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(XKBCommon DEFAULT_MSG
-    XKBCOMMON_LIBRARY
-    XKBCOMMON_INCLUDE_DIR
-)
-
-mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)
-
diff --git a/raylib/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake b/raylib/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
deleted file mode 100644 (file)
index 60f7914..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 64-bit MinGW-w64 Clang
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "x86_64-w64-mingw32-clang")
-SET(CMAKE_CXX_COMPILER   "x86_64-w64-mingw32-clang++")
-SET(CMAKE_RC_COMPILER    "x86_64-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "x86_64-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/external/glfw/CMake/x86_64-w64-mingw32.cmake b/raylib/external/glfw/CMake/x86_64-w64-mingw32.cmake
deleted file mode 100644 (file)
index 063e845..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 64-bit MinGW-w64 GCC
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "x86_64-w64-mingw32-gcc")
-SET(CMAKE_CXX_COMPILER   "x86_64-w64-mingw32-g++")
-SET(CMAKE_RC_COMPILER    "x86_64-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "x86_64-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib/external/glfw/CMakeLists.txt b/raylib/external/glfw/CMakeLists.txt
deleted file mode 100644 (file)
index 59ba5a6..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR)
-
-project(GLFW VERSION 3.4.0 LANGUAGES C)
-
-set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
-
-if (POLICY CMP0054)
-    cmake_policy(SET CMP0054 NEW)
-endif()
-
-if (POLICY CMP0069)
-    cmake_policy(SET CMP0069 NEW)
-endif()
-
-if (POLICY CMP0077)
-    cmake_policy(SET CMP0077 NEW)
-endif()
-
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-
-if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
-    set(GLFW_STANDALONE TRUE)
-endif()
-
-option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
-option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
-option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
-option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
-option(GLFW_INSTALL "Generate installation target" ON)
-option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
-
-include(GNUInstallDirs)
-include(CMakeDependentOption)
-
-cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
-                       "UNIX" OFF)
-cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
-                       "WIN32" OFF)
-cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
-                       "UNIX;NOT APPLE" OFF)
-cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
-                       "MSVC" OFF)
-
-if (BUILD_SHARED_LIBS)
-    set(_GLFW_BUILD_DLL 1)
-endif()
-
-if (BUILD_SHARED_LIBS AND UNIX)
-    # On Unix-like systems, shared libraries can use the soname system.
-    set(GLFW_LIB_NAME glfw)
-else()
-    set(GLFW_LIB_NAME glfw3)
-endif()
-
-if (GLFW_VULKAN_STATIC)
-    if (BUILD_SHARED_LIBS)
-        # If you absolutely must do this, remove this line and add the Vulkan
-        # loader static library via the CMAKE_SHARED_LINKER_FLAGS
-        message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
-    endif()
-    set(_GLFW_VULKAN_STATIC 1)
-endif()
-
-list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
-
-find_package(Threads REQUIRED)
-
-if (GLFW_BUILD_DOCS)
-    set(DOXYGEN_SKIP_DOT TRUE)
-    find_package(Doxygen)
-endif()
-
-#--------------------------------------------------------------------
-# Set compiler specific flags
-#--------------------------------------------------------------------
-if (MSVC)
-    if (MSVC90)
-        # Workaround for VS 2008 not shipping with the DirectX 9 SDK
-        include(CheckIncludeFile)
-        check_include_file(dinput.h DINPUT_H_FOUND)
-        if (NOT DINPUT_H_FOUND)
-            message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
-        endif()
-        # Workaround for VS 2008 not shipping with stdint.h
-        list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
-    endif()
-
-    if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
-        foreach (flag CMAKE_C_FLAGS
-                      CMAKE_C_FLAGS_DEBUG
-                      CMAKE_C_FLAGS_RELEASE
-                      CMAKE_C_FLAGS_MINSIZEREL
-                      CMAKE_C_FLAGS_RELWITHDEBINFO)
-
-            if (${flag} MATCHES "/MD")
-                string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
-            endif()
-            if (${flag} MATCHES "/MDd")
-                string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
-            endif()
-
-        endforeach()
-    endif()
-endif()
-
-if (MINGW)
-    # Workaround for legacy MinGW not providing XInput and DirectInput
-    include(CheckIncludeFile)
-
-    check_include_file(dinput.h DINPUT_H_FOUND)
-    check_include_file(xinput.h XINPUT_H_FOUND)
-    if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
-        list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
-    endif()
-
-    # Enable link-time exploit mitigation features enabled by default on MSVC
-    include(CheckCCompilerFlag)
-
-    # Compatibility with data execution prevention (DEP)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
-    check_c_compiler_flag("" _GLFW_HAS_DEP)
-    if (_GLFW_HAS_DEP)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-
-    # Compatibility with address space layout randomization (ASLR)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
-    check_c_compiler_flag("" _GLFW_HAS_ASLR)
-    if (_GLFW_HAS_ASLR)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-
-    # Compatibility with 64-bit address space layout randomization (ASLR)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
-    check_c_compiler_flag("" _GLFW_HAS_64ASLR)
-    if (_GLFW_HAS_64ASLR)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Detect and select backend APIs
-#--------------------------------------------------------------------
-if (GLFW_USE_WAYLAND)
-    set(_GLFW_WAYLAND 1)
-    message(STATUS "Using Wayland for window creation")
-elseif (GLFW_USE_OSMESA)
-    set(_GLFW_OSMESA 1)
-    message(STATUS "Using OSMesa for headless context creation")
-elseif (WIN32)
-    set(_GLFW_WIN32 1)
-    message(STATUS "Using Win32 for window creation")
-elseif (APPLE)
-    set(_GLFW_COCOA 1)
-    message(STATUS "Using Cocoa for window creation")
-elseif (UNIX)
-    set(_GLFW_X11 1)
-    message(STATUS "Using X11 for window creation")
-else()
-    message(FATAL_ERROR "No supported platform was detected")
-endif()
-
-#--------------------------------------------------------------------
-# Find and add Unix math and time libraries
-#--------------------------------------------------------------------
-if (UNIX AND NOT APPLE)
-    find_library(RT_LIBRARY rt)
-    mark_as_advanced(RT_LIBRARY)
-    if (RT_LIBRARY)
-        list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
-        list(APPEND glfw_PKG_LIBS "-lrt")
-    endif()
-
-    find_library(MATH_LIBRARY m)
-    mark_as_advanced(MATH_LIBRARY)
-    if (MATH_LIBRARY)
-        list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
-        list(APPEND glfw_PKG_LIBS "-lm")
-    endif()
-
-    if (CMAKE_DL_LIBS)
-        list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
-        list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use Win32 for window creation
-#--------------------------------------------------------------------
-if (_GLFW_WIN32)
-
-    list(APPEND glfw_PKG_LIBS "-lgdi32")
-
-    if (GLFW_USE_HYBRID_HPG)
-        set(_GLFW_USE_HYBRID_HPG 1)
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use X11 for window creation
-#--------------------------------------------------------------------
-if (_GLFW_X11)
-
-    find_package(X11 REQUIRED)
-
-    list(APPEND glfw_PKG_DEPS "x11")
-
-    # Set up library and include paths
-    list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
-    list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
-
-    # Check for XRandR (modern resolution switching and gamma control)
-    if (NOT X11_Xrandr_INCLUDE_PATH)
-        message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
-    endif()
-
-    # Check for Xinerama (legacy multi-monitor support)
-    if (NOT X11_Xinerama_INCLUDE_PATH)
-        message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
-    endif()
-
-    # Check for Xkb (X keyboard extension)
-    if (NOT X11_Xkb_INCLUDE_PATH)
-        message(FATAL_ERROR "XKB headers not found; install X11 development package")
-    endif()
-
-    # Check for Xcursor (cursor creation from RGBA images)
-    if (NOT X11_Xcursor_INCLUDE_PATH)
-        message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
-    endif()
-
-    # Check for XInput (modern HID input)
-    if (NOT X11_Xi_INCLUDE_PATH)
-        message(FATAL_ERROR "XInput headers not found; install libxi development package")
-    endif()
-    
-    # Check for X Shape (custom window input shape)
-    if (NOT X11_Xshape_INCLUDE_PATH)
-        message(FATAL_ERROR "X Shape headers not found; install libxext development package")
-    endif()
-
-    list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
-                                  "${X11_Xinerama_INCLUDE_PATH}"
-                                  "${X11_Xkb_INCLUDE_PATH}"
-                                  "${X11_Xcursor_INCLUDE_PATH}"
-                                  "${X11_Xi_INCLUDE_PATH}")
-endif()
-
-#--------------------------------------------------------------------
-# Use Wayland for window creation
-#--------------------------------------------------------------------
-if (_GLFW_WAYLAND)
-    find_package(ECM REQUIRED NO_MODULE)
-    list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
-
-    find_package(Wayland REQUIRED Client Cursor Egl)
-    find_package(WaylandScanner REQUIRED)
-    find_package(WaylandProtocols 1.15 REQUIRED)
-
-    list(APPEND glfw_PKG_DEPS "wayland-egl")
-
-    list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
-    list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
-
-    find_package(XKBCommon REQUIRED)
-    list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
-
-    include(CheckIncludeFiles)
-    include(CheckFunctionExists)
-    check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
-    check_function_exists(memfd_create HAVE_MEMFD_CREATE)
-
-    if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
-        find_package(EpollShim)
-        if (EPOLLSHIM_FOUND)
-            list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
-            list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}")
-        endif()
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use OSMesa for offscreen context creation
-#--------------------------------------------------------------------
-if (_GLFW_OSMESA)
-    find_package(OSMesa REQUIRED)
-    list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
-endif()
-
-#--------------------------------------------------------------------
-# Use Cocoa for window creation and NSOpenGL for context creation
-#--------------------------------------------------------------------
-if (_GLFW_COCOA)
-
-    list(APPEND glfw_LIBRARIES
-        "-framework Cocoa"
-        "-framework IOKit"
-        "-framework CoreFoundation")
-
-    set(glfw_PKG_DEPS "")
-    set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
-endif()
-
-#--------------------------------------------------------------------
-# Add the Vulkan loader as a dependency if necessary
-#--------------------------------------------------------------------
-if (GLFW_VULKAN_STATIC)
-    list(APPEND glfw_PKG_DEPS "vulkan")
-endif()
-
-#--------------------------------------------------------------------
-# Export GLFW library dependencies
-#--------------------------------------------------------------------
-foreach(arg ${glfw_PKG_DEPS})
-    set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL
-        "GLFW pkg-config Requires.private")
-endforeach()
-foreach(arg ${glfw_PKG_LIBS})
-    set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL
-        "GLFW pkg-config Libs.private")
-endforeach()
-
-#--------------------------------------------------------------------
-# Create generated files
-#--------------------------------------------------------------------
-include(CMakePackageConfigHelpers)
-
-set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
-
-configure_package_config_file(CMake/glfw3Config.cmake.in
-                              src/glfw3Config.cmake
-                              INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
-                              NO_CHECK_REQUIRED_COMPONENTS_MACRO)
-
-write_basic_package_version_file(src/glfw3ConfigVersion.cmake
-                                 VERSION ${GLFW_VERSION}
-                                 COMPATIBILITY SameMajorVersion)
-
-configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
-
-configure_file(CMake/glfw3.pc.in CMake/glfw3.pc @ONLY)
-
-#--------------------------------------------------------------------
-# Add subdirectories
-#--------------------------------------------------------------------
-add_subdirectory(src)
-
-if (GLFW_BUILD_EXAMPLES)
-    add_subdirectory(examples)
-endif()
-
-if (GLFW_BUILD_TESTS)
-    add_subdirectory(tests)
-endif()
-
-if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
-    add_subdirectory(docs)
-endif()
-
-#--------------------------------------------------------------------
-# Install files other than the library
-# The library is installed by src/CMakeLists.txt
-#--------------------------------------------------------------------
-if (GLFW_INSTALL)
-    install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-            FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
-
-    install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
-                  "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
-            DESTINATION "${GLFW_CONFIG_PATH}")
-
-    install(EXPORT glfwTargets FILE glfw3Targets.cmake
-            EXPORT_LINK_INTERFACE_LIBRARIES
-            DESTINATION "${GLFW_CONFIG_PATH}")
-    install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
-            DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-
-    if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
-        install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
-                DESTINATION "${CMAKE_INSTALL_DOCDIR}")
-    endif()
-
-    # Only generate this target if no higher-level project already has
-    if (NOT TARGET uninstall)
-        configure_file(CMake/cmake_uninstall.cmake.in
-                       cmake_uninstall.cmake IMMEDIATE @ONLY)
-
-        add_custom_target(uninstall
-                          "${CMAKE_COMMAND}" -P
-                          "${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
-        set_target_properties(uninstall PROPERTIES FOLDER "GLFW3")
-    endif()
-endif()
-
diff --git a/raylib/external/glfw/LICENSE.md b/raylib/external/glfw/LICENSE.md
deleted file mode 100644 (file)
index 7494a3f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-Copyright (c) 2002-2006 Marcus Geelnard
-
-Copyright (c) 2006-2019 Camilla Löwy
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-   claim that you wrote the original software. If you use this software
-   in a product, an acknowledgment in the product documentation would
-   be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not
-   be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-   distribution.
-
diff --git a/raylib/external/glfw/README.md b/raylib/external/glfw/README.md
deleted file mode 100644 (file)
index 7488e6d..0000000
+++ /dev/null
@@ -1,441 +0,0 @@
-# GLFW
-
-[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw)
-[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
-[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
-
-## Introduction
-
-GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan
-application development.  It provides a simple, platform-independent API for
-creating windows, contexts and surfaces, reading input, handling events, etc.
-
-GLFW natively supports Windows, macOS and Linux and other Unix-like systems.  On
-Linux both X11 and Wayland are supported.
-
-GLFW is licensed under the [zlib/libpng
-license](http://www.glfw.org/license.html).
-
-You can [download](http://www.glfw.org/download.html) the latest stable release
-as source or Windows binaries, or fetch the `latest` branch from GitHub.  Each
-release starting with 3.0 also has a corresponding [annotated
-tag](https://github.com/glfw/glfw/releases) with source and binary archives.
-
-The [documentation](http://www.glfw.org/docs/latest/) is available online and is
-included in all source and binary archives.  See the [release
-notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
-deprecations in the latest release.  For more details see the [version
-history](http://www.glfw.org/changelog.html).
-
-The `master` branch is the stable integration branch and _should_ always compile
-and run on all supported platforms, although details of newly added features may
-change until they have been included in a release.  New features and many bug
-fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until
-they are stable enough to merge.
-
-If you are new to GLFW, you may find the
-[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful.  If
-you have used GLFW 2 in the past, there is a [transition
-guide](http://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
-3 API.
-
-
-## Compiling GLFW
-
-GLFW itself requires only the headers and libraries for your OS and window
-system.  It does not need the headers for any context creation API (WGL, GLX,
-EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable
-support for them.
-
-GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and
-MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
-and Clang.  It will likely compile in other environments as well, but this is
-not regularly tested.
-
-There are [pre-compiled Windows binaries](http://www.glfw.org/download.html)
-available for all supported compilers.
-
-See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) for
-more information about how to compile GLFW yourself.
-
-
-## Using GLFW
-
-See the [documentation](http://www.glfw.org/docs/latest/) for tutorials, guides
-and the API reference.
-
-
-## Contributing to GLFW
-
-See the [contribution
-guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
-more information.
-
-
-## System requirements
-
-GLFW supports Windows XP and later and macOS 10.8 and later.  Linux and other
-Unix-like systems running the X Window System are supported even without
-a desktop environment or modern extensions, although some features require
-a running window or clipboard manager.  The OSMesa backend requires Mesa 6.3.
-
-See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html)
-in the documentation for more information.
-
-
-## Dependencies
-
-GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
-OS and window system.
-
-The examples and test programs depend on a number of tiny libraries.  These are
-located in the `deps/` directory.
-
- - [getopt\_port](https://github.com/kimgr/getopt_port/) for examples
-   with command-line options
- - [TinyCThread](https://github.com/tinycthread/tinycthread) for threaded
-   examples
- - [glad2](https://github.com/Dav1dde/glad) for loading OpenGL and Vulkan
-   functions
- - [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
-   examples
- - [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
- - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
-
-The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
-find that tool.
-
-
-## Reporting bugs
-
-Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
-Please check the [contribution
-guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
-information on what to include when reporting a bug.
-
-
-## Changelog
-
- - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
-   `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
- - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
- - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
- - Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
-   through the window (#1236,#1568)
- - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
- - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
-   values to select ANGLE backend (#1380)
- - Made joystick subsystem initialize at first use (#1284,#1646)
- - Updated the minimum required CMake version to 3.1
- - Disabled tests and examples by default when built as a CMake subdirectory
- - Bugfix: The CMake config-file package used an absolute path and was not
-   relocatable (#1470)
- - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
- - Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
- - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- - Bugfix: Some extension loader headers did not prevent default OpenGL header
-   inclusion (#1695)
- - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
-           to the window menu
- - [Win32] Added a version info resource to the GLFW DLL
- - [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
-   opaque (#1512)
- - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
-   symbol redefinition (#1524)
- - [Win32] Bugfix: The cursor position event was emitted before its cursor enter
-   event (#1490)
- - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the
-   window (#1499)
- - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions
- - [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622)
- - [Win32] Bugfix: `glfwGetKeyName` could access out of bounds and return an
-   invalid pointer
- - [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
-   (#1623)
- - [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
- - [Win32] Bugfix: Monitor functions could return invalid values after
-   configuration change (#1761)
- - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- - [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- - [Cocoa] Removed dependency on the CoreVideo framework
- - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- - [Cocoa] Bugfix: Window remained on screen after destruction until event poll
-   (#1412)
- - [Cocoa] Bugfix: Event processing before window creation would assert (#1543)
- - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
- - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
-   would abort (#1649)
- - [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
-   (#1635)
- - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
-   could leak memory
- - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- - [X11] Bugfix: Key names were not updated when the keyboard layout changed
-   (#1462,#1528)
- - [X11] Bugfix: Decorations could not be enabled after window creation (#1566)
- - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
- - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows
- - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read
- - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail
- - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows
- - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm
- - [X11] Bugfix: Window position events were not emitted during resizing (#1613)
- - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM
- - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602)
- - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- - [X11] Bugfix: Termination would segfault if the IM had been destroyed
- - [X11] Bugfix: Any IM started after initialization would not be detected
- - [X11] Bugfix: Xlib errors caused by other parts of the application could be
-   reported as GLFW errors
- - [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633)
- - [X11] Bugfix: XKB path used keysyms instead of physical locations for
-   non-printable keys (#1598)
- - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
-   combinaitons (#1598)
- - [X11] Bugfix: Keys pressed simultaneously with others were not always
-   reported (#1112,#1415,#1472,#1616)
- - [Wayland] Removed support for `wl_shell` (#1443)
- - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
- - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
-   (#1463)
- - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- - [NSGL] Removed enforcement of forward-compatible flag for core contexts
- - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
-   macOS versions (#1442)
- - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
- - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
-   (#442)
- - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
-   (#1380)
-
-
-## Contact
-
-On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
-well as news, documentation and other information about the project.
-
-If you have questions related to the use of GLFW, we have a
-[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
-[Freenode](http://freenode.net/).
-
-If you have a bug to report, a patch to submit or a feature you'd like to
-request, please file it in the
-[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
-
-Finally, if you're interested in helping out with the development of GLFW or
-porting it to your favorite platform, join us on the forum, GitHub or IRC.
-
-
-## Acknowledgements
-
-GLFW exists because people around the world donated their time and lent their
-skills.
-
- - Bobyshev Alexander
- - Matt Arsenault
- - David Avedissian
- - Keith Bauer
- - John Bartholomew
- - CoÅŸku BaÅŸ
- - Niklas Behrens
- - Andrew Belt
- - Niklas Bergström
- - Denis Bernard
- - Doug Binks
- - blanco
- - Kyle Brenneman
- - Rok Breulj
- - Kai Burjack
- - Martin Capitanio
- - Nicolas Caramelli
- - David Carlier
- - Arturo Castro
- - Chi-kwan Chan
- - Ian Clarkson
- - MichaÅ‚ CichoÅ„
- - Lambert Clara
- - Anna Clarke
- - Yaron Cohen-Tal
- - Omar Cornut
- - Andrew Corrigan
- - Bailey Cosier
- - Noel Cower
- - Jason Daly
- - Jarrod Davis
- - Olivier Delannoy
- - Paul R. Deppe
- - Michael Dickens
- - Ð Ð¾Ð¼Ð°Ð½ Ð”онченко
- - Mario Dorn
- - Wolfgang Draxinger
- - Jonathan Dummer
- - Ralph Eastwood
- - Fredrik Ehnbom
- - Robin Eklind
- - Siavash Eliasi
- - Felipe Ferreira
- - Michael Fogleman
- - Gerald Franz
- - Mário Freitas
- - GeO4d
- - Marcus Geelnard
- - Charles Giessen
- - Ryan C. Gordon
- - Stephen Gowen
- - Kovid Goyal
- - Eloi Marín Gratacós
- - Stefan Gustavson
- - Jonathan Hale
- - Sylvain Hellegouarch
- - Matthew Henry
- - heromyth
- - Lucas Hinderberger
- - Paul Holden
- - Warren Hu
- - Charles Huber
- - IntellectualKitty
- - Aaron Jacobs
- - Erik S. V. Jansson
- - Toni Jovanoski
- - Arseny Kapoulkine
- - Cem Karan
- - Osman Keskin
- - Josh Kilmer
- - Byunghoon Kim
- - Cameron King
- - Peter Knut
- - Christoph Kubisch
- - Yuri Kunde Schlesner
- - Rokas Kupstys
- - Konstantin Käfer
- - Eric Larson
- - Francis Lecavalier
- - Robin Leffmann
- - Glenn Lewis
- - Shane Liesegang
- - Anders Lindqvist
- - Leon Linhart
- - Eyal Lotem
- - Aaron Loucks
- - Luflosi
- - lukect
- - Tristam MacDonald
- - Hans Mackowiak
- - Ð”митри ÐœÐ°Ð»Ñ‹ÑˆÐµÐ²
- - Zbigniew Mandziejewicz
- - Adam Marcus
- - Célestin Marot
- - Kyle McDonald
- - David Medlock
- - Bryce Mehring
- - Jonathan Mercier
- - Marcel Metz
- - Liam Middlebrook
- - Ave Milia
- - Jonathan Miller
- - Kenneth Miller
- - Bruce Mitchener
- - Jack Moffitt
- - Jeff Molofee
- - Alexander Monakov
- - Pierre Morel
- - Jon Morton
- - Pierre Moulon
- - Martins Mozeiko
- - Julian Møller
- - ndogxj
- - Kristian Nielsen
- - Kamil Nowakowski
- - onox
- - Denis Ovod
- - Ozzy
- - Andri Pálsson
- - Peoro
- - Braden Pellett
- - Christopher Pelloux
- - Arturo J. Pérez
- - Vladimir Perminov
- - Anthony Pesch
- - Orson Peters
- - Emmanuel Gil Peyrot
- - Cyril Pichard
- - Keith Pitt
- - Stanislav Podgorskiy
- - Konstantin Podsvirov
- - Nathan Poirier
- - Alexandre Pretyman
- - Pablo Prietz
- - przemekmirek
- - pthom
- - Guillaume Racicot
- - Philip Rideout
- - Eddie Ringle
- - Max Risuhin
- - Jorge Rodriguez
- - Luca Rood
- - Ed Ropple
- - Aleksey Rybalkin
- - Mikko Rytkönen
- - Riku Salminen
- - Brandon Schaefer
- - Sebastian Schuberth
- - Christian Sdunek
- - Matt Sealey
- - Steve Sexton
- - Arkady Shapkin
- - Ali Sherief
- - Yoshiki Shibukawa
- - Dmitri Shuralyov
- - Daniel Skorupski
- - Bradley Smith
- - Cliff Smolinsky
- - Patrick Snape
- - Erlend Sogge Heggen
- - Julian Squires
- - Johannes Stein
- - Pontus Stenetorp
- - Michael Stocker
- - Justin Stoecker
- - Elviss Strazdins
- - Paul Sultana
- - Nathan Sweet
- - TTK-Bandit
- - Jared Tiala
- - Sergey Tikhomirov
- - Arthur Tombs
- - Ioannis Tsakpinis
- - Samuli Tuomola
- - Matthew Turner
- - urraka
- - Elias Vanderstuyft
- - Stef Velzel
- - Jari Vetoniemi
- - Ricardo Vieira
- - Nicholas Vitovitch
- - Simon Voordouw
- - Corentin Wallez
- - Torsten Walluhn
- - Patrick Walton
- - Xo Wang
- - Waris
- - Jay Weisskopf
- - Frank Wille
- - Tatsuya Yatagawa
- - Ryogo Yoshimura
- - Lukas Zanner
- - Andrey Zholos
- - Aihui Zhu
- - Santi Zupancic
- - Jonas Ã…dahl
- - Lasse Ã–örni
- - All the unmentioned and anonymous contributors in the GLFW community, for bug
-   reports, patches, feedback, testing and encouragement
-
diff --git a/raylib/external/glfw/deps/getopt.c b/raylib/external/glfw/deps/getopt.c
deleted file mode 100644 (file)
index 9743046..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/* Copyright (c) 2012, Kim Gräsman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of Kim Gräsman nor the names of contributors may be used
- *    to endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "getopt.h"
-
-#include <stddef.h>
-#include <string.h>
-
-const int no_argument = 0;
-const int required_argument = 1;
-const int optional_argument = 2;
-
-char* optarg;
-int optopt;
-/* The variable optind [...] shall be initialized to 1 by the system. */
-int optind = 1;
-int opterr;
-
-static char* optcursor = NULL;
-
-/* Implemented based on [1] and [2] for optional arguments.
-   optopt is handled FreeBSD-style, per [3].
-   Other GNU and FreeBSD extensions are purely accidental.
-
-[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
-[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
-[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
-*/
-int getopt(int argc, char* const argv[], const char* optstring) {
-  int optchar = -1;
-  const char* optdecl = NULL;
-
-  optarg = NULL;
-  opterr = 0;
-  optopt = 0;
-
-  /* Unspecified, but we need it to avoid overrunning the argv bounds. */
-  if (optind >= argc)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] is a null pointer, getopt()
-     shall return -1 without changing optind. */
-  if (argv[optind] == NULL)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called *argv[optind]  is not the character '-',
-     getopt() shall return -1 without changing optind. */
-  if (*argv[optind] != '-')
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] points to the string "-",
-     getopt() shall return -1 without changing optind. */
-  if (strcmp(argv[optind], "-") == 0)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] points to the string "--",
-     getopt() shall return -1 after incrementing optind. */
-  if (strcmp(argv[optind], "--") == 0) {
-    ++optind;
-    goto no_more_optchars;
-  }
-
-  if (optcursor == NULL || *optcursor == '\0')
-    optcursor = argv[optind] + 1;
-
-  optchar = *optcursor;
-
-  /* FreeBSD: The variable optopt saves the last known option character
-     returned by getopt(). */
-  optopt = optchar;
-
-  /* The getopt() function shall return the next option character (if one is
-     found) from argv that matches a character in optstring, if there is
-     one that matches. */
-  optdecl = strchr(optstring, optchar);
-  if (optdecl) {
-    /* [I]f a character is followed by a colon, the option takes an
-       argument. */
-    if (optdecl[1] == ':') {
-      optarg = ++optcursor;
-      if (*optarg == '\0') {
-        /* GNU extension: Two colons mean an option takes an
-           optional arg; if there is text in the current argv-element
-           (i.e., in the same word as the option name itself, for example,
-           "-oarg"), then it is returned in optarg, otherwise optarg is set
-           to zero. */
-        if (optdecl[2] != ':') {
-          /* If the option was the last character in the string pointed to by
-             an element of argv, then optarg shall contain the next element
-             of argv, and optind shall be incremented by 2. If the resulting
-             value of optind is greater than argc, this indicates a missing
-             option-argument, and getopt() shall return an error indication.
-
-             Otherwise, optarg shall point to the string following the
-             option character in that element of argv, and optind shall be
-             incremented by 1.
-          */
-          if (++optind < argc) {
-            optarg = argv[optind];
-          } else {
-            /* If it detects a missing option-argument, it shall return the
-               colon character ( ':' ) if the first character of optstring
-               was a colon, or a question-mark character ( '?' ) otherwise.
-            */
-            optarg = NULL;
-            optchar = (optstring[0] == ':') ? ':' : '?';
-          }
-        } else {
-          optarg = NULL;
-        }
-      }
-
-      optcursor = NULL;
-    }
-  } else {
-    /* If getopt() encounters an option character that is not contained in
-       optstring, it shall return the question-mark ( '?' ) character. */
-    optchar = '?';
-  }
-
-  if (optcursor == NULL || *++optcursor == '\0')
-    ++optind;
-
-  return optchar;
-
-no_more_optchars:
-  optcursor = NULL;
-  return -1;
-}
-
-/* Implementation based on [1].
-
-[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
-*/
-int getopt_long(int argc, char* const argv[], const char* optstring,
-  const struct option* longopts, int* longindex) {
-  const struct option* o = longopts;
-  const struct option* match = NULL;
-  int num_matches = 0;
-  size_t argument_name_length = 0;
-  const char* current_argument = NULL;
-  int retval = -1;
-
-  optarg = NULL;
-  optopt = 0;
-
-  if (optind >= argc)
-    return -1;
-
-  if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
-    return getopt(argc, argv, optstring);
-
-  /* It's an option; starts with -- and is longer than two chars. */
-  current_argument = argv[optind] + 2;
-  argument_name_length = strcspn(current_argument, "=");
-  for (; o->name; ++o) {
-    if (strncmp(o->name, current_argument, argument_name_length) == 0) {
-      match = o;
-      ++num_matches;
-    }
-  }
-
-  if (num_matches == 1) {
-    /* If longindex is not NULL, it points to a variable which is set to the
-       index of the long option relative to longopts. */
-    if (longindex)
-      *longindex = (int) (match - longopts);
-
-    /* If flag is NULL, then getopt_long() shall return val.
-       Otherwise, getopt_long() returns 0, and flag shall point to a variable
-       which shall be set to val if the option is found, but left unchanged if
-       the option is not found. */
-    if (match->flag)
-      *(match->flag) = match->val;
-
-    retval = match->flag ? 0 : match->val;
-
-    if (match->has_arg != no_argument) {
-      optarg = strchr(argv[optind], '=');
-      if (optarg != NULL)
-        ++optarg;
-
-      if (match->has_arg == required_argument) {
-        /* Only scan the next argv for required arguments. Behavior is not
-           specified, but has been observed with Ubuntu and Mac OSX. */
-        if (optarg == NULL && ++optind < argc) {
-          optarg = argv[optind];
-        }
-
-        if (optarg == NULL)
-          retval = ':';
-      }
-    } else if (strchr(argv[optind], '=')) {
-      /* An argument was provided to a non-argument option.
-         I haven't seen this specified explicitly, but both GNU and BSD-based
-         implementations show this behavior.
-      */
-      retval = '?';
-    }
-  } else {
-    /* Unknown option or ambiguous match. */
-    retval = '?';
-  }
-
-  ++optind;
-  return retval;
-}
diff --git a/raylib/external/glfw/deps/getopt.h b/raylib/external/glfw/deps/getopt.h
deleted file mode 100644 (file)
index e1eb540..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2012, Kim Gräsman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of Kim Gräsman nor the names of contributors may be used
- *    to endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INCLUDED_GETOPT_PORT_H
-#define INCLUDED_GETOPT_PORT_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-extern const int no_argument;
-extern const int required_argument;
-extern const int optional_argument;
-
-extern char* optarg;
-extern int optind, opterr, optopt;
-
-struct option {
-  const char* name;
-  int has_arg;
-  int* flag;
-  int val;
-};
-
-int getopt(int argc, char* const argv[], const char* optstring);
-
-int getopt_long(int argc, char* const argv[],
-  const char* optstring, const struct option* longopts, int* longindex);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif // INCLUDED_GETOPT_PORT_H
diff --git a/raylib/external/glfw/deps/glad/gl.h b/raylib/external/glfw/deps/glad/gl.h
deleted file mode 100644 (file)
index 5c7879f..0000000
+++ /dev/null
@@ -1,3840 +0,0 @@
-/**
- * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:32 2019
- *
- * Generator: C/C++
- * Specification: gl
- * Extensions: 3
- *
- * APIs:
- *  - gl:compatibility=3.3
- *
- * Options:
- *  - MX_GLOBAL = False
- *  - LOADER = False
- *  - ALIAS = False
- *  - HEADER_ONLY = False
- *  - DEBUG = False
- *  - MX = False
- *
- * Commandline:
- *    --api='gl:compatibility=3.3' --extensions='GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug' c
- *
- * Online:
- *    http://glad.sh/#api=gl%3Acompatibility%3D3.3&extensions=GL_ARB_multisample%2CGL_ARB_robustness%2CGL_KHR_debug&generator=c&options=
- *
- */
-
-#ifndef GLAD_GL_H_
-#define GLAD_GL_H_
-
-#ifdef __gl_h_
-    #error OpenGL header already included (API: gl), remove previous include!
-#endif
-#define __gl_h_ 1
-
-
-#define GLAD_GL
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GLAD_PLATFORM_H_
-#define GLAD_PLATFORM_H_
-
-#ifndef GLAD_PLATFORM_WIN32
-  #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
-    #define GLAD_PLATFORM_WIN32 1
-  #else
-    #define GLAD_PLATFORM_WIN32 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_APPLE
-  #ifdef __APPLE__
-    #define GLAD_PLATFORM_APPLE 1
-  #else
-    #define GLAD_PLATFORM_APPLE 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_EMSCRIPTEN
-  #ifdef __EMSCRIPTEN__
-    #define GLAD_PLATFORM_EMSCRIPTEN 1
-  #else
-    #define GLAD_PLATFORM_EMSCRIPTEN 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_UWP
-  #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
-    #ifdef __has_include
-      #if __has_include(<winapifamily.h>)
-        #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-      #endif
-    #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
-      #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-    #endif
-  #endif
-
-  #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
-    #include <winapifamily.h>
-    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
-      #define GLAD_PLATFORM_UWP 1
-    #endif
-  #endif
-
-  #ifndef GLAD_PLATFORM_UWP
-    #define GLAD_PLATFORM_UWP 0
-  #endif
-#endif
-
-#ifdef __GNUC__
-  #define GLAD_GNUC_EXTENSION __extension__
-#else
-  #define GLAD_GNUC_EXTENSION
-#endif
-
-#ifndef GLAD_API_CALL
-  #if defined(GLAD_API_CALL_EXPORT)
-    #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
-      #if defined(GLAD_API_CALL_EXPORT_BUILD)
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllexport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllexport) extern
-        #endif
-      #else
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllimport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllimport) extern
-        #endif
-      #endif
-    #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
-      #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
-    #else
-      #define GLAD_API_CALL extern
-    #endif
-  #else
-    #define GLAD_API_CALL extern
-  #endif
-#endif
-
-#ifdef APIENTRY
-  #define GLAD_API_PTR APIENTRY
-#elif GLAD_PLATFORM_WIN32
-  #define GLAD_API_PTR __stdcall
-#else
-  #define GLAD_API_PTR
-#endif
-
-#ifndef GLAPI
-#define GLAPI GLAD_API_CALL
-#endif
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY GLAD_API_PTR
-#endif
-
-
-#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
-#define GLAD_VERSION_MAJOR(version) (version / 10000)
-#define GLAD_VERSION_MINOR(version) (version % 10000)
-
-typedef void (*GLADapiproc)(void);
-
-typedef GLADapiproc (*GLADloadfunc)(const char *name);
-typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr);
-
-typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
-typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
-
-#endif /* GLAD_PLATFORM_H_ */
-
-#define GL_2D 0x0600
-#define GL_2_BYTES 0x1407
-#define GL_3D 0x0601
-#define GL_3D_COLOR 0x0602
-#define GL_3D_COLOR_TEXTURE 0x0603
-#define GL_3_BYTES 0x1408
-#define GL_4D_COLOR_TEXTURE 0x0604
-#define GL_4_BYTES 0x1409
-#define GL_ACCUM 0x0100
-#define GL_ACCUM_ALPHA_BITS 0x0D5B
-#define GL_ACCUM_BLUE_BITS 0x0D5A
-#define GL_ACCUM_BUFFER_BIT 0x00000200
-#define GL_ACCUM_CLEAR_VALUE 0x0B80
-#define GL_ACCUM_GREEN_BITS 0x0D59
-#define GL_ACCUM_RED_BITS 0x0D58
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ADD 0x0104
-#define GL_ADD_SIGNED 0x8574
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF
-#define GL_ALPHA 0x1906
-#define GL_ALPHA12 0x803D
-#define GL_ALPHA16 0x803E
-#define GL_ALPHA4 0x803B
-#define GL_ALPHA8 0x803C
-#define GL_ALPHA_BIAS 0x0D1D
-#define GL_ALPHA_BITS 0x0D55
-#define GL_ALPHA_INTEGER 0x8D97
-#define GL_ALPHA_SCALE 0x0D1C
-#define GL_ALPHA_TEST 0x0BC0
-#define GL_ALPHA_TEST_FUNC 0x0BC1
-#define GL_ALPHA_TEST_REF 0x0BC2
-#define GL_ALREADY_SIGNALED 0x911A
-#define GL_ALWAYS 0x0207
-#define GL_AMBIENT 0x1200
-#define GL_AMBIENT_AND_DIFFUSE 0x1602
-#define GL_AND 0x1501
-#define GL_AND_INVERTED 0x1504
-#define GL_AND_REVERSE 0x1502
-#define GL_ANY_SAMPLES_PASSED 0x8C2F
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ATTRIB_STACK_DEPTH 0x0BB0
-#define GL_AUTO_NORMAL 0x0D80
-#define GL_AUX0 0x0409
-#define GL_AUX1 0x040A
-#define GL_AUX2 0x040B
-#define GL_AUX3 0x040C
-#define GL_AUX_BUFFERS 0x0C00
-#define GL_BACK 0x0405
-#define GL_BACK_LEFT 0x0402
-#define GL_BACK_RIGHT 0x0403
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_BGRA_INTEGER 0x8D9B
-#define GL_BGR_INTEGER 0x8D9A
-#define GL_BITMAP 0x1A00
-#define GL_BITMAP_TOKEN 0x0704
-#define GL_BLEND 0x0BE2
-#define GL_BLEND_COLOR 0x8005
-#define GL_BLEND_DST 0x0BE0
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_BLEND_EQUATION_RGB 0x8009
-#define GL_BLEND_SRC 0x0BE1
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLUE 0x1905
-#define GL_BLUE_BIAS 0x0D1B
-#define GL_BLUE_BITS 0x0D54
-#define GL_BLUE_INTEGER 0x8D96
-#define GL_BLUE_SCALE 0x0D1A
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_BUFFER 0x82E0
-#define GL_BUFFER_ACCESS 0x88BB
-#define GL_BUFFER_ACCESS_FLAGS 0x911F
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_LENGTH 0x9120
-#define GL_BUFFER_MAP_OFFSET 0x9121
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_BYTE 0x1400
-#define GL_C3F_V3F 0x2A24
-#define GL_C4F_N3F_V3F 0x2A26
-#define GL_C4UB_V2F 0x2A22
-#define GL_C4UB_V3F 0x2A23
-#define GL_CCW 0x0901
-#define GL_CLAMP 0x2900
-#define GL_CLAMP_FRAGMENT_COLOR 0x891B
-#define GL_CLAMP_READ_COLOR 0x891C
-#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_CLAMP_VERTEX_COLOR 0x891A
-#define GL_CLEAR 0x1500
-#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
-#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
-#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
-#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
-#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
-#define GL_CLIP_DISTANCE0 0x3000
-#define GL_CLIP_DISTANCE1 0x3001
-#define GL_CLIP_DISTANCE2 0x3002
-#define GL_CLIP_DISTANCE3 0x3003
-#define GL_CLIP_DISTANCE4 0x3004
-#define GL_CLIP_DISTANCE5 0x3005
-#define GL_CLIP_DISTANCE6 0x3006
-#define GL_CLIP_DISTANCE7 0x3007
-#define GL_CLIP_PLANE0 0x3000
-#define GL_CLIP_PLANE1 0x3001
-#define GL_CLIP_PLANE2 0x3002
-#define GL_CLIP_PLANE3 0x3003
-#define GL_CLIP_PLANE4 0x3004
-#define GL_CLIP_PLANE5 0x3005
-#define GL_COEFF 0x0A00
-#define GL_COLOR 0x1800
-#define GL_COLOR_ARRAY 0x8076
-#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
-#define GL_COLOR_ARRAY_POINTER 0x8090
-#define GL_COLOR_ARRAY_SIZE 0x8081
-#define GL_COLOR_ARRAY_STRIDE 0x8083
-#define GL_COLOR_ARRAY_TYPE 0x8082
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#define GL_COLOR_ATTACHMENT10 0x8CEA
-#define GL_COLOR_ATTACHMENT11 0x8CEB
-#define GL_COLOR_ATTACHMENT12 0x8CEC
-#define GL_COLOR_ATTACHMENT13 0x8CED
-#define GL_COLOR_ATTACHMENT14 0x8CEE
-#define GL_COLOR_ATTACHMENT15 0x8CEF
-#define GL_COLOR_ATTACHMENT16 0x8CF0
-#define GL_COLOR_ATTACHMENT17 0x8CF1
-#define GL_COLOR_ATTACHMENT18 0x8CF2
-#define GL_COLOR_ATTACHMENT19 0x8CF3
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#define GL_COLOR_ATTACHMENT20 0x8CF4
-#define GL_COLOR_ATTACHMENT21 0x8CF5
-#define GL_COLOR_ATTACHMENT22 0x8CF6
-#define GL_COLOR_ATTACHMENT23 0x8CF7
-#define GL_COLOR_ATTACHMENT24 0x8CF8
-#define GL_COLOR_ATTACHMENT25 0x8CF9
-#define GL_COLOR_ATTACHMENT26 0x8CFA
-#define GL_COLOR_ATTACHMENT27 0x8CFB
-#define GL_COLOR_ATTACHMENT28 0x8CFC
-#define GL_COLOR_ATTACHMENT29 0x8CFD
-#define GL_COLOR_ATTACHMENT3 0x8CE3
-#define GL_COLOR_ATTACHMENT30 0x8CFE
-#define GL_COLOR_ATTACHMENT31 0x8CFF
-#define GL_COLOR_ATTACHMENT4 0x8CE4
-#define GL_COLOR_ATTACHMENT5 0x8CE5
-#define GL_COLOR_ATTACHMENT6 0x8CE6
-#define GL_COLOR_ATTACHMENT7 0x8CE7
-#define GL_COLOR_ATTACHMENT8 0x8CE8
-#define GL_COLOR_ATTACHMENT9 0x8CE9
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_INDEX 0x1900
-#define GL_COLOR_INDEXES 0x1603
-#define GL_COLOR_LOGIC_OP 0x0BF2
-#define GL_COLOR_MATERIAL 0x0B57
-#define GL_COLOR_MATERIAL_FACE 0x0B55
-#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
-#define GL_COLOR_SUM 0x8458
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_COMBINE 0x8570
-#define GL_COMBINE_ALPHA 0x8572
-#define GL_COMBINE_RGB 0x8571
-#define GL_COMPARE_REF_TO_TEXTURE 0x884E
-#define GL_COMPARE_R_TO_TEXTURE 0x884E
-#define GL_COMPILE 0x1300
-#define GL_COMPILE_AND_EXECUTE 0x1301
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_COMPRESSED_ALPHA 0x84E9
-#define GL_COMPRESSED_INTENSITY 0x84EC
-#define GL_COMPRESSED_LUMINANCE 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
-#define GL_COMPRESSED_RED 0x8225
-#define GL_COMPRESSED_RED_RGTC1 0x8DBB
-#define GL_COMPRESSED_RG 0x8226
-#define GL_COMPRESSED_RGB 0x84ED
-#define GL_COMPRESSED_RGBA 0x84EE
-#define GL_COMPRESSED_RG_RGTC2 0x8DBD
-#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
-#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
-#define GL_COMPRESSED_SLUMINANCE 0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B
-#define GL_COMPRESSED_SRGB 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CONDITION_SATISFIED 0x911C
-#define GL_CONSTANT 0x8576
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_CONSTANT_ATTENUATION 0x1207
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_CONTEXT_FLAGS 0x821E
-#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_COORD_REPLACE 0x8862
-#define GL_COPY 0x1503
-#define GL_COPY_INVERTED 0x150C
-#define GL_COPY_PIXEL_TOKEN 0x0706
-#define GL_COPY_READ_BUFFER 0x8F36
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_CURRENT_BIT 0x00000001
-#define GL_CURRENT_COLOR 0x0B00
-#define GL_CURRENT_FOG_COORD 0x8453
-#define GL_CURRENT_FOG_COORDINATE 0x8453
-#define GL_CURRENT_INDEX 0x0B01
-#define GL_CURRENT_NORMAL 0x0B02
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_CURRENT_QUERY 0x8865
-#define GL_CURRENT_RASTER_COLOR 0x0B04
-#define GL_CURRENT_RASTER_DISTANCE 0x0B09
-#define GL_CURRENT_RASTER_INDEX 0x0B05
-#define GL_CURRENT_RASTER_POSITION 0x0B07
-#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
-#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
-#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
-#define GL_CURRENT_SECONDARY_COLOR 0x8459
-#define GL_CURRENT_TEXTURE_COORDS 0x0B03
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_CW 0x0900
-#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
-#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
-#define GL_DEBUG_LOGGED_MESSAGES 0x9145
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
-#define GL_DEBUG_OUTPUT 0x92E0
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
-#define GL_DEBUG_SEVERITY_HIGH 0x9146
-#define GL_DEBUG_SEVERITY_LOW 0x9148
-#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
-#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
-#define GL_DEBUG_SOURCE_API 0x8246
-#define GL_DEBUG_SOURCE_APPLICATION 0x824A
-#define GL_DEBUG_SOURCE_OTHER 0x824B
-#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
-#define GL_DEBUG_TYPE_ERROR 0x824C
-#define GL_DEBUG_TYPE_MARKER 0x8268
-#define GL_DEBUG_TYPE_OTHER 0x8251
-#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
-#define GL_DEBUG_TYPE_POP_GROUP 0x826A
-#define GL_DEBUG_TYPE_PORTABILITY 0x824F
-#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
-#define GL_DECAL 0x2101
-#define GL_DECR 0x1E03
-#define GL_DECR_WRAP 0x8508
-#define GL_DELETE_STATUS 0x8B80
-#define GL_DEPTH 0x1801
-#define GL_DEPTH24_STENCIL8 0x88F0
-#define GL_DEPTH32F_STENCIL8 0x8CAD
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_DEPTH_BIAS 0x0D1F
-#define GL_DEPTH_BITS 0x0D56
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_DEPTH_CLAMP 0x864F
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_DEPTH_COMPONENT32 0x81A7
-#define GL_DEPTH_COMPONENT32F 0x8CAC
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_SCALE 0x0D1E
-#define GL_DEPTH_STENCIL 0x84F9
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_TEXTURE_MODE 0x884B
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DIFFUSE 0x1201
-#define GL_DISPLAY_LIST 0x82E7
-#define GL_DITHER 0x0BD0
-#define GL_DOMAIN 0x0A02
-#define GL_DONT_CARE 0x1100
-#define GL_DOT3_RGB 0x86AE
-#define GL_DOT3_RGBA 0x86AF
-#define GL_DOUBLE 0x140A
-#define GL_DOUBLEBUFFER 0x0C32
-#define GL_DRAW_BUFFER 0x0C01
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_DRAW_PIXEL_TOKEN 0x0705
-#define GL_DST_ALPHA 0x0304
-#define GL_DST_COLOR 0x0306
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_EDGE_FLAG 0x0B43
-#define GL_EDGE_FLAG_ARRAY 0x8079
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
-#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
-#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_EMISSION 0x1600
-#define GL_ENABLE_BIT 0x00002000
-#define GL_EQUAL 0x0202
-#define GL_EQUIV 0x1509
-#define GL_EVAL_BIT 0x00010000
-#define GL_EXP 0x0800
-#define GL_EXP2 0x0801
-#define GL_EXTENSIONS 0x1F03
-#define GL_EYE_LINEAR 0x2400
-#define GL_EYE_PLANE 0x2502
-#define GL_FALSE 0
-#define GL_FASTEST 0x1101
-#define GL_FEEDBACK 0x1C01
-#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
-#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
-#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
-#define GL_FILL 0x1B02
-#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
-#define GL_FIXED_ONLY 0x891D
-#define GL_FLAT 0x1D00
-#define GL_FLOAT 0x1406
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT2x3 0x8B65
-#define GL_FLOAT_MAT2x4 0x8B66
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT3x2 0x8B67
-#define GL_FLOAT_MAT3x4 0x8B68
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_FLOAT_MAT4x2 0x8B69
-#define GL_FLOAT_MAT4x3 0x8B6A
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_FOG 0x0B60
-#define GL_FOG_BIT 0x00000080
-#define GL_FOG_COLOR 0x0B66
-#define GL_FOG_COORD 0x8451
-#define GL_FOG_COORDINATE 0x8451
-#define GL_FOG_COORDINATE_ARRAY 0x8457
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
-#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
-#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
-#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
-#define GL_FOG_COORDINATE_SOURCE 0x8450
-#define GL_FOG_COORD_ARRAY 0x8457
-#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
-#define GL_FOG_COORD_ARRAY_POINTER 0x8456
-#define GL_FOG_COORD_ARRAY_STRIDE 0x8455
-#define GL_FOG_COORD_ARRAY_TYPE 0x8454
-#define GL_FOG_COORD_SRC 0x8450
-#define GL_FOG_DENSITY 0x0B62
-#define GL_FOG_END 0x0B64
-#define GL_FOG_HINT 0x0C54
-#define GL_FOG_INDEX 0x0B61
-#define GL_FOG_MODE 0x0B65
-#define GL_FOG_START 0x0B63
-#define GL_FRAGMENT_DEPTH 0x8452
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_DEFAULT 0x8218
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_SRGB 0x8DB9
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#define GL_FRONT 0x0404
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_FRONT_FACE 0x0B46
-#define GL_FRONT_LEFT 0x0400
-#define GL_FRONT_RIGHT 0x0401
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_GENERATE_MIPMAP 0x8191
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-#define GL_GEOMETRY_INPUT_TYPE 0x8917
-#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
-#define GL_GEOMETRY_SHADER 0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT 0x8916
-#define GL_GEQUAL 0x0206
-#define GL_GREATER 0x0204
-#define GL_GREEN 0x1904
-#define GL_GREEN_BIAS 0x0D19
-#define GL_GREEN_BITS 0x0D53
-#define GL_GREEN_INTEGER 0x8D95
-#define GL_GREEN_SCALE 0x0D18
-#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
-#define GL_HALF_FLOAT 0x140B
-#define GL_HINT_BIT 0x00008000
-#define GL_INCR 0x1E02
-#define GL_INCR_WRAP 0x8507
-#define GL_INDEX 0x8222
-#define GL_INDEX_ARRAY 0x8077
-#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
-#define GL_INDEX_ARRAY_POINTER 0x8091
-#define GL_INDEX_ARRAY_STRIDE 0x8086
-#define GL_INDEX_ARRAY_TYPE 0x8085
-#define GL_INDEX_BITS 0x0D51
-#define GL_INDEX_CLEAR_VALUE 0x0C20
-#define GL_INDEX_LOGIC_OP 0x0BF1
-#define GL_INDEX_MODE 0x0C30
-#define GL_INDEX_OFFSET 0x0D13
-#define GL_INDEX_SHIFT 0x0D12
-#define GL_INDEX_WRITEMASK 0x0C21
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
-#define GL_INT 0x1404
-#define GL_INTENSITY 0x8049
-#define GL_INTENSITY12 0x804C
-#define GL_INTENSITY16 0x804D
-#define GL_INTENSITY4 0x804A
-#define GL_INTENSITY8 0x804B
-#define GL_INTERLEAVED_ATTRIBS 0x8C8C
-#define GL_INTERPOLATE 0x8575
-#define GL_INT_2_10_10_10_REV 0x8D9F
-#define GL_INT_SAMPLER_1D 0x8DC9
-#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
-#define GL_INT_SAMPLER_2D 0x8DCA
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
-#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
-#define GL_INT_SAMPLER_2D_RECT 0x8DCD
-#define GL_INT_SAMPLER_3D 0x8DCB
-#define GL_INT_SAMPLER_BUFFER 0x8DD0
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#define GL_INVALID_INDEX 0xFFFFFFFF
-#define GL_INVALID_OPERATION 0x0502
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVERT 0x150A
-#define GL_KEEP 0x1E00
-#define GL_LAST_VERTEX_CONVENTION 0x8E4E
-#define GL_LEFT 0x0406
-#define GL_LEQUAL 0x0203
-#define GL_LESS 0x0201
-#define GL_LIGHT0 0x4000
-#define GL_LIGHT1 0x4001
-#define GL_LIGHT2 0x4002
-#define GL_LIGHT3 0x4003
-#define GL_LIGHT4 0x4004
-#define GL_LIGHT5 0x4005
-#define GL_LIGHT6 0x4006
-#define GL_LIGHT7 0x4007
-#define GL_LIGHTING 0x0B50
-#define GL_LIGHTING_BIT 0x00000040
-#define GL_LIGHT_MODEL_AMBIENT 0x0B53
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
-#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
-#define GL_LINE 0x1B01
-#define GL_LINEAR 0x2601
-#define GL_LINEAR_ATTENUATION 0x1208
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_LINES 0x0001
-#define GL_LINES_ADJACENCY 0x000A
-#define GL_LINE_BIT 0x00000004
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_RESET_TOKEN 0x0707
-#define GL_LINE_SMOOTH 0x0B20
-#define GL_LINE_SMOOTH_HINT 0x0C52
-#define GL_LINE_STIPPLE 0x0B24
-#define GL_LINE_STIPPLE_PATTERN 0x0B25
-#define GL_LINE_STIPPLE_REPEAT 0x0B26
-#define GL_LINE_STRIP 0x0003
-#define GL_LINE_STRIP_ADJACENCY 0x000B
-#define GL_LINE_TOKEN 0x0702
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_LINE_WIDTH_RANGE 0x0B22
-#define GL_LINK_STATUS 0x8B82
-#define GL_LIST_BASE 0x0B32
-#define GL_LIST_BIT 0x00020000
-#define GL_LIST_INDEX 0x0B33
-#define GL_LIST_MODE 0x0B30
-#define GL_LOAD 0x0101
-#define GL_LOGIC_OP 0x0BF1
-#define GL_LOGIC_OP_MODE 0x0BF0
-#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GL_LOWER_LEFT 0x8CA1
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE12 0x8041
-#define GL_LUMINANCE12_ALPHA12 0x8047
-#define GL_LUMINANCE12_ALPHA4 0x8046
-#define GL_LUMINANCE16 0x8042
-#define GL_LUMINANCE16_ALPHA16 0x8048
-#define GL_LUMINANCE4 0x803F
-#define GL_LUMINANCE4_ALPHA4 0x8043
-#define GL_LUMINANCE6_ALPHA2 0x8044
-#define GL_LUMINANCE8 0x8040
-#define GL_LUMINANCE8_ALPHA8 0x8045
-#define GL_LUMINANCE_ALPHA 0x190A
-#define GL_MAJOR_VERSION 0x821B
-#define GL_MAP1_COLOR_4 0x0D90
-#define GL_MAP1_GRID_DOMAIN 0x0DD0
-#define GL_MAP1_GRID_SEGMENTS 0x0DD1
-#define GL_MAP1_INDEX 0x0D91
-#define GL_MAP1_NORMAL 0x0D92
-#define GL_MAP1_TEXTURE_COORD_1 0x0D93
-#define GL_MAP1_TEXTURE_COORD_2 0x0D94
-#define GL_MAP1_TEXTURE_COORD_3 0x0D95
-#define GL_MAP1_TEXTURE_COORD_4 0x0D96
-#define GL_MAP1_VERTEX_3 0x0D97
-#define GL_MAP1_VERTEX_4 0x0D98
-#define GL_MAP2_COLOR_4 0x0DB0
-#define GL_MAP2_GRID_DOMAIN 0x0DD2
-#define GL_MAP2_GRID_SEGMENTS 0x0DD3
-#define GL_MAP2_INDEX 0x0DB1
-#define GL_MAP2_NORMAL 0x0DB2
-#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
-#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
-#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
-#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
-#define GL_MAP2_VERTEX_3 0x0DB7
-#define GL_MAP2_VERTEX_4 0x0DB8
-#define GL_MAP_COLOR 0x0D10
-#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
-#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
-#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
-#define GL_MAP_READ_BIT 0x0001
-#define GL_MAP_STENCIL 0x0D11
-#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
-#define GL_MAP_WRITE_BIT 0x0002
-#define GL_MATRIX_MODE 0x0BA0
-#define GL_MAX 0x8008
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
-#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
-#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
-#define GL_MAX_CLIP_DISTANCES 0x0D32
-#define GL_MAX_CLIP_PLANES 0x0D32
-#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
-#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
-#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
-#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
-#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_EVAL_ORDER 0x0D30
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
-#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
-#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
-#define GL_MAX_INTEGER_SAMPLES 0x9110
-#define GL_MAX_LABEL_LENGTH 0x82E8
-#define GL_MAX_LIGHTS 0x0D31
-#define GL_MAX_LIST_NESTING 0x0B31
-#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
-#define GL_MAX_NAME_STACK_DEPTH 0x0D37
-#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
-#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
-#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#define GL_MAX_SAMPLES 0x8D57
-#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
-#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
-#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
-#define GL_MAX_TEXTURE_COORDS 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
-#define GL_MAX_TEXTURE_UNITS 0x84E2
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
-#define GL_MAX_VARYING_COMPONENTS 0x8B4B
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_MIN 0x8007
-#define GL_MINOR_VERSION 0x821C
-#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_MODELVIEW 0x1700
-#define GL_MODELVIEW_MATRIX 0x0BA6
-#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
-#define GL_MODULATE 0x2100
-#define GL_MULT 0x0103
-#define GL_MULTISAMPLE 0x809D
-#define GL_MULTISAMPLE_ARB 0x809D
-#define GL_MULTISAMPLE_BIT 0x20000000
-#define GL_MULTISAMPLE_BIT_ARB 0x20000000
-#define GL_N3F_V3F 0x2A25
-#define GL_NAME_STACK_DEPTH 0x0D70
-#define GL_NAND 0x150E
-#define GL_NEAREST 0x2600
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_NEVER 0x0200
-#define GL_NICEST 0x1102
-#define GL_NONE 0
-#define GL_NOOP 0x1505
-#define GL_NOR 0x1508
-#define GL_NORMALIZE 0x0BA1
-#define GL_NORMAL_ARRAY 0x8075
-#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
-#define GL_NORMAL_ARRAY_POINTER 0x808F
-#define GL_NORMAL_ARRAY_STRIDE 0x807F
-#define GL_NORMAL_ARRAY_TYPE 0x807E
-#define GL_NORMAL_MAP 0x8511
-#define GL_NOTEQUAL 0x0205
-#define GL_NO_ERROR 0
-#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_OBJECT_LINEAR 0x2401
-#define GL_OBJECT_PLANE 0x2501
-#define GL_OBJECT_TYPE 0x9112
-#define GL_ONE 1
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
-#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_OPERAND0_ALPHA 0x8598
-#define GL_OPERAND0_RGB 0x8590
-#define GL_OPERAND1_ALPHA 0x8599
-#define GL_OPERAND1_RGB 0x8591
-#define GL_OPERAND2_ALPHA 0x859A
-#define GL_OPERAND2_RGB 0x8592
-#define GL_OR 0x1507
-#define GL_ORDER 0x0A01
-#define GL_OR_INVERTED 0x150D
-#define GL_OR_REVERSE 0x150B
-#define GL_OUT_OF_MEMORY 0x0505
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_PACK_LSB_FIRST 0x0D01
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_PASS_THROUGH_TOKEN 0x0700
-#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
-#define GL_PIXEL_MAP_A_TO_A 0x0C79
-#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
-#define GL_PIXEL_MAP_B_TO_B 0x0C78
-#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
-#define GL_PIXEL_MAP_G_TO_G 0x0C77
-#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
-#define GL_PIXEL_MAP_I_TO_A 0x0C75
-#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
-#define GL_PIXEL_MAP_I_TO_B 0x0C74
-#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
-#define GL_PIXEL_MAP_I_TO_G 0x0C73
-#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
-#define GL_PIXEL_MAP_I_TO_I 0x0C70
-#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
-#define GL_PIXEL_MAP_I_TO_R 0x0C72
-#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
-#define GL_PIXEL_MAP_R_TO_R 0x0C76
-#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
-#define GL_PIXEL_MAP_S_TO_S 0x0C71
-#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
-#define GL_PIXEL_MODE_BIT 0x00000020
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
-#define GL_POINT 0x1B00
-#define GL_POINTS 0x0000
-#define GL_POINT_BIT 0x00000002
-#define GL_POINT_DISTANCE_ATTENUATION 0x8129
-#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
-#define GL_POINT_SIZE 0x0B11
-#define GL_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_POINT_SIZE_MAX 0x8127
-#define GL_POINT_SIZE_MIN 0x8126
-#define GL_POINT_SIZE_RANGE 0x0B12
-#define GL_POINT_SMOOTH 0x0B10
-#define GL_POINT_SMOOTH_HINT 0x0C51
-#define GL_POINT_SPRITE 0x8861
-#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
-#define GL_POINT_TOKEN 0x0701
-#define GL_POLYGON 0x0009
-#define GL_POLYGON_BIT 0x00000008
-#define GL_POLYGON_MODE 0x0B40
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_POLYGON_OFFSET_LINE 0x2A02
-#define GL_POLYGON_OFFSET_POINT 0x2A01
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_POLYGON_SMOOTH 0x0B41
-#define GL_POLYGON_SMOOTH_HINT 0x0C53
-#define GL_POLYGON_STIPPLE 0x0B42
-#define GL_POLYGON_STIPPLE_BIT 0x00000010
-#define GL_POLYGON_TOKEN 0x0703
-#define GL_POSITION 0x1203
-#define GL_PREVIOUS 0x8578
-#define GL_PRIMARY_COLOR 0x8577
-#define GL_PRIMITIVES_GENERATED 0x8C87
-#define GL_PRIMITIVE_RESTART 0x8F9D
-#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
-#define GL_PROGRAM 0x82E2
-#define GL_PROGRAM_PIPELINE 0x82E4
-#define GL_PROGRAM_POINT_SIZE 0x8642
-#define GL_PROJECTION 0x1701
-#define GL_PROJECTION_MATRIX 0x0BA7
-#define GL_PROJECTION_STACK_DEPTH 0x0BA4
-#define GL_PROVOKING_VERTEX 0x8E4F
-#define GL_PROXY_TEXTURE_1D 0x8063
-#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
-#define GL_PROXY_TEXTURE_2D 0x8064
-#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
-#define GL_Q 0x2003
-#define GL_QUADRATIC_ATTENUATION 0x1209
-#define GL_QUADS 0x0007
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
-#define GL_QUAD_STRIP 0x0008
-#define GL_QUERY 0x82E3
-#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
-#define GL_QUERY_BY_REGION_WAIT 0x8E15
-#define GL_QUERY_COUNTER_BITS 0x8864
-#define GL_QUERY_NO_WAIT 0x8E14
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_QUERY_WAIT 0x8E13
-#define GL_R 0x2002
-#define GL_R11F_G11F_B10F 0x8C3A
-#define GL_R16 0x822A
-#define GL_R16F 0x822D
-#define GL_R16I 0x8233
-#define GL_R16UI 0x8234
-#define GL_R16_SNORM 0x8F98
-#define GL_R32F 0x822E
-#define GL_R32I 0x8235
-#define GL_R32UI 0x8236
-#define GL_R3_G3_B2 0x2A10
-#define GL_R8 0x8229
-#define GL_R8I 0x8231
-#define GL_R8UI 0x8232
-#define GL_R8_SNORM 0x8F94
-#define GL_RASTERIZER_DISCARD 0x8C89
-#define GL_READ_BUFFER 0x0C02
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
-#define GL_READ_ONLY 0x88B8
-#define GL_READ_WRITE 0x88BA
-#define GL_RED 0x1903
-#define GL_RED_BIAS 0x0D15
-#define GL_RED_BITS 0x0D52
-#define GL_RED_INTEGER 0x8D94
-#define GL_RED_SCALE 0x0D14
-#define GL_REFLECTION_MAP 0x8512
-#define GL_RENDER 0x1C00
-#define GL_RENDERBUFFER 0x8D41
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_SAMPLES 0x8CAB
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERER 0x1F01
-#define GL_RENDER_MODE 0x0C40
-#define GL_REPEAT 0x2901
-#define GL_REPLACE 0x1E01
-#define GL_RESCALE_NORMAL 0x803A
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_RETURN 0x0102
-#define GL_RG 0x8227
-#define GL_RG16 0x822C
-#define GL_RG16F 0x822F
-#define GL_RG16I 0x8239
-#define GL_RG16UI 0x823A
-#define GL_RG16_SNORM 0x8F99
-#define GL_RG32F 0x8230
-#define GL_RG32I 0x823B
-#define GL_RG32UI 0x823C
-#define GL_RG8 0x822B
-#define GL_RG8I 0x8237
-#define GL_RG8UI 0x8238
-#define GL_RG8_SNORM 0x8F95
-#define GL_RGB 0x1907
-#define GL_RGB10 0x8052
-#define GL_RGB10_A2 0x8059
-#define GL_RGB10_A2UI 0x906F
-#define GL_RGB12 0x8053
-#define GL_RGB16 0x8054
-#define GL_RGB16F 0x881B
-#define GL_RGB16I 0x8D89
-#define GL_RGB16UI 0x8D77
-#define GL_RGB16_SNORM 0x8F9A
-#define GL_RGB32F 0x8815
-#define GL_RGB32I 0x8D83
-#define GL_RGB32UI 0x8D71
-#define GL_RGB4 0x804F
-#define GL_RGB5 0x8050
-#define GL_RGB5_A1 0x8057
-#define GL_RGB8 0x8051
-#define GL_RGB8I 0x8D8F
-#define GL_RGB8UI 0x8D7D
-#define GL_RGB8_SNORM 0x8F96
-#define GL_RGB9_E5 0x8C3D
-#define GL_RGBA 0x1908
-#define GL_RGBA12 0x805A
-#define GL_RGBA16 0x805B
-#define GL_RGBA16F 0x881A
-#define GL_RGBA16I 0x8D88
-#define GL_RGBA16UI 0x8D76
-#define GL_RGBA16_SNORM 0x8F9B
-#define GL_RGBA2 0x8055
-#define GL_RGBA32F 0x8814
-#define GL_RGBA32I 0x8D82
-#define GL_RGBA32UI 0x8D70
-#define GL_RGBA4 0x8056
-#define GL_RGBA8 0x8058
-#define GL_RGBA8I 0x8D8E
-#define GL_RGBA8UI 0x8D7C
-#define GL_RGBA8_SNORM 0x8F97
-#define GL_RGBA_INTEGER 0x8D99
-#define GL_RGBA_MODE 0x0C31
-#define GL_RGB_INTEGER 0x8D98
-#define GL_RGB_SCALE 0x8573
-#define GL_RG_INTEGER 0x8228
-#define GL_RIGHT 0x0407
-#define GL_S 0x2000
-#define GL_SAMPLER 0x82E6
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_1D_ARRAY 0x8DC0
-#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
-#define GL_SAMPLER_1D_SHADOW 0x8B61
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
-#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
-#define GL_SAMPLER_2D_RECT 0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_BINDING 0x8919
-#define GL_SAMPLER_BUFFER 0x8DC2
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLES_ARB 0x80A9
-#define GL_SAMPLES_PASSED 0x8914
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLE_BUFFERS_ARB 0x80A8
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_COVERAGE_ARB 0x80A0
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
-#define GL_SAMPLE_MASK 0x8E51
-#define GL_SAMPLE_MASK_VALUE 0x8E52
-#define GL_SAMPLE_POSITION 0x8E50
-#define GL_SCISSOR_BIT 0x00080000
-#define GL_SCISSOR_BOX 0x0C10
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_SECONDARY_COLOR_ARRAY 0x845E
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
-#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
-#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
-#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
-#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
-#define GL_SELECT 0x1C02
-#define GL_SELECTION_BUFFER_POINTER 0x0DF3
-#define GL_SELECTION_BUFFER_SIZE 0x0DF4
-#define GL_SEPARATE_ATTRIBS 0x8C8D
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-#define GL_SET 0x150F
-#define GL_SHADER 0x82E1
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_SHADE_MODEL 0x0B54
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_SHININESS 0x1601
-#define GL_SHORT 0x1402
-#define GL_SIGNALED 0x9119
-#define GL_SIGNED_NORMALIZED 0x8F9C
-#define GL_SINGLE_COLOR 0x81F9
-#define GL_SLUMINANCE 0x8C46
-#define GL_SLUMINANCE8 0x8C47
-#define GL_SLUMINANCE8_ALPHA8 0x8C45
-#define GL_SLUMINANCE_ALPHA 0x8C44
-#define GL_SMOOTH 0x1D01
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SOURCE0_ALPHA 0x8588
-#define GL_SOURCE0_RGB 0x8580
-#define GL_SOURCE1_ALPHA 0x8589
-#define GL_SOURCE1_RGB 0x8581
-#define GL_SOURCE2_ALPHA 0x858A
-#define GL_SOURCE2_RGB 0x8582
-#define GL_SPECULAR 0x1202
-#define GL_SPHERE_MAP 0x2402
-#define GL_SPOT_CUTOFF 0x1206
-#define GL_SPOT_DIRECTION 0x1204
-#define GL_SPOT_EXPONENT 0x1205
-#define GL_SRC0_ALPHA 0x8588
-#define GL_SRC0_RGB 0x8580
-#define GL_SRC1_ALPHA 0x8589
-#define GL_SRC1_COLOR 0x88F9
-#define GL_SRC1_RGB 0x8581
-#define GL_SRC2_ALPHA 0x858A
-#define GL_SRC2_RGB 0x8582
-#define GL_SRC_ALPHA 0x0302
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_SRC_COLOR 0x0300
-#define GL_SRGB 0x8C40
-#define GL_SRGB8 0x8C41
-#define GL_SRGB8_ALPHA8 0x8C43
-#define GL_SRGB_ALPHA 0x8C42
-#define GL_STACK_OVERFLOW 0x0503
-#define GL_STACK_UNDERFLOW 0x0504
-#define GL_STATIC_COPY 0x88E6
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STENCIL 0x1802
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_STENCIL_BITS 0x0D57
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_INDEX 0x1901
-#define GL_STENCIL_INDEX1 0x8D46
-#define GL_STENCIL_INDEX16 0x8D49
-#define GL_STENCIL_INDEX4 0x8D47
-#define GL_STENCIL_INDEX8 0x8D48
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STEREO 0x0C33
-#define GL_STREAM_COPY 0x88E2
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_SUBTRACT 0x84E7
-#define GL_SYNC_CONDITION 0x9113
-#define GL_SYNC_FENCE 0x9116
-#define GL_SYNC_FLAGS 0x9115
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#define GL_SYNC_STATUS 0x9114
-#define GL_T 0x2001
-#define GL_T2F_C3F_V3F 0x2A2A
-#define GL_T2F_C4F_N3F_V3F 0x2A2C
-#define GL_T2F_C4UB_V3F 0x2A29
-#define GL_T2F_N3F_V3F 0x2A2B
-#define GL_T2F_V3F 0x2A27
-#define GL_T4F_C4F_N3F_V4F 0x2A2D
-#define GL_T4F_V4F 0x2A28
-#define GL_TEXTURE 0x1702
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_1D_ARRAY 0x8C18
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_TEXTURE_2D_ARRAY 0x8C1A
-#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
-#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
-#define GL_TEXTURE_3D 0x806F
-#define GL_TEXTURE_ALPHA_SIZE 0x805F
-#define GL_TEXTURE_ALPHA_TYPE 0x8C13
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_BINDING_1D 0x8068
-#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
-#define GL_TEXTURE_BIT 0x00040000
-#define GL_TEXTURE_BLUE_SIZE 0x805E
-#define GL_TEXTURE_BLUE_TYPE 0x8C12
-#define GL_TEXTURE_BORDER 0x1005
-#define GL_TEXTURE_BORDER_COLOR 0x1004
-#define GL_TEXTURE_BUFFER 0x8C2A
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPONENTS 0x1003
-#define GL_TEXTURE_COMPRESSED 0x86A1
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
-#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
-#define GL_TEXTURE_COORD_ARRAY 0x8078
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
-#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
-#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
-#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
-#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_DEPTH_SIZE 0x884A
-#define GL_TEXTURE_DEPTH_TYPE 0x8C16
-#define GL_TEXTURE_ENV 0x2300
-#define GL_TEXTURE_ENV_COLOR 0x2201
-#define GL_TEXTURE_ENV_MODE 0x2200
-#define GL_TEXTURE_FILTER_CONTROL 0x8500
-#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
-#define GL_TEXTURE_GEN_MODE 0x2500
-#define GL_TEXTURE_GEN_Q 0x0C63
-#define GL_TEXTURE_GEN_R 0x0C62
-#define GL_TEXTURE_GEN_S 0x0C60
-#define GL_TEXTURE_GEN_T 0x0C61
-#define GL_TEXTURE_GREEN_SIZE 0x805D
-#define GL_TEXTURE_GREEN_TYPE 0x8C11
-#define GL_TEXTURE_HEIGHT 0x1001
-#define GL_TEXTURE_INTENSITY_SIZE 0x8061
-#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
-#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
-#define GL_TEXTURE_LOD_BIAS 0x8501
-#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
-#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MATRIX 0x0BA8
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_PRIORITY 0x8066
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#define GL_TEXTURE_RED_SIZE 0x805C
-#define GL_TEXTURE_RED_TYPE 0x8C10
-#define GL_TEXTURE_RESIDENT 0x8067
-#define GL_TEXTURE_SAMPLES 0x9106
-#define GL_TEXTURE_SHARED_SIZE 0x8C3F
-#define GL_TEXTURE_STACK_DEPTH 0x0BA5
-#define GL_TEXTURE_STENCIL_SIZE 0x88F1
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
-#define GL_TEXTURE_WIDTH 0x1000
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_TIMEOUT_EXPIRED 0x911B
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
-#define GL_TIMESTAMP 0x8E28
-#define GL_TIME_ELAPSED 0x88BF
-#define GL_TRANSFORM_BIT 0x00001000
-#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
-#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
-#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
-#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLES_ADJACENCY 0x000C
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
-#define GL_TRUE 1
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BUFFER 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING 0x8A28
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
-#define GL_UNIFORM_BUFFER_START 0x8A29
-#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#define GL_UNIFORM_NAME_LENGTH 0x8A39
-#define GL_UNIFORM_OFFSET 0x8A3B
-#define GL_UNIFORM_SIZE 0x8A38
-#define GL_UNIFORM_TYPE 0x8A37
-#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_UNPACK_LSB_FIRST 0x0CF1
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_UNSIGNALED 0x9118
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_INT 0x1405
-#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_UNSIGNED_INT_24_8 0x84FA
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#define GL_UNSIGNED_NORMALIZED 0x8C17
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UPPER_LEFT 0x8CA2
-#define GL_V2F 0x2A20
-#define GL_V3F 0x2A21
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_VENDOR 0x1F00
-#define GL_VERSION 0x1F02
-#define GL_VERTEX_ARRAY 0x8074
-#define GL_VERTEX_ARRAY_BINDING 0x85B5
-#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
-#define GL_VERTEX_ARRAY_POINTER 0x808E
-#define GL_VERTEX_ARRAY_SIZE 0x807A
-#define GL_VERTEX_ARRAY_STRIDE 0x807C
-#define GL_VERTEX_ARRAY_TYPE 0x807B
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_VIEWPORT 0x0BA2
-#define GL_VIEWPORT_BIT 0x00000800
-#define GL_WAIT_FAILED 0x911D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
-#define GL_WRITE_ONLY 0x88B9
-#define GL_XOR 0x1506
-#define GL_ZERO 0
-#define GL_ZOOM_X 0x0D16
-#define GL_ZOOM_Y 0x0D17
-
-
-#include <glad/khrplatform.h>
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef void GLvoid;
-typedef khronos_int8_t GLbyte;
-typedef khronos_uint8_t GLubyte;
-typedef khronos_int16_t GLshort;
-typedef khronos_uint16_t GLushort;
-typedef int GLint;
-typedef unsigned int GLuint;
-typedef khronos_int32_t GLclampx;
-typedef int GLsizei;
-typedef khronos_float_t GLfloat;
-typedef khronos_float_t GLclampf;
-typedef double GLdouble;
-typedef double GLclampd;
-typedef void *GLeglClientBufferEXT;
-typedef void *GLeglImageOES;
-typedef char GLchar;
-typedef char GLcharARB;
-#ifdef __APPLE__
-typedef void *GLhandleARB;
-#else
-typedef unsigned int GLhandleARB;
-#endif
-typedef khronos_uint16_t GLhalf;
-typedef khronos_uint16_t GLhalfARB;
-typedef khronos_int32_t GLfixed;
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_intptr_t GLintptr;
-#else
-typedef khronos_intptr_t GLintptr;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_intptr_t GLintptrARB;
-#else
-typedef khronos_intptr_t GLintptrARB;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_ssize_t GLsizeiptr;
-#else
-typedef khronos_ssize_t GLsizeiptr;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_ssize_t GLsizeiptrARB;
-#else
-typedef khronos_ssize_t GLsizeiptrARB;
-#endif
-typedef khronos_int64_t GLint64;
-typedef khronos_int64_t GLint64EXT;
-typedef khronos_uint64_t GLuint64;
-typedef khronos_uint64_t GLuint64EXT;
-typedef struct __GLsync *GLsync;
-struct _cl_context;
-struct _cl_event;
-typedef void ( *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
-typedef unsigned short GLhalfNV;
-typedef GLintptr GLvdpauSurfaceNV;
-typedef void ( *GLVULKANPROCNV)(void);
-
-
-#define GL_VERSION_1_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_0;
-#define GL_VERSION_1_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_1;
-#define GL_VERSION_1_2 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_2;
-#define GL_VERSION_1_3 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_3;
-#define GL_VERSION_1_4 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_4;
-#define GL_VERSION_1_5 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_5;
-#define GL_VERSION_2_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_2_0;
-#define GL_VERSION_2_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_2_1;
-#define GL_VERSION_3_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_0;
-#define GL_VERSION_3_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_1;
-#define GL_VERSION_3_2 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_2;
-#define GL_VERSION_3_3 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_3;
-#define GL_ARB_multisample 1
-GLAD_API_CALL int GLAD_GL_ARB_multisample;
-#define GL_ARB_robustness 1
-GLAD_API_CALL int GLAD_GL_ARB_robustness;
-#define GL_KHR_debug 1
-GLAD_API_CALL int GLAD_GL_KHR_debug;
-
-
-typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum   op, GLfloat   value);
-typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum   texture);
-typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum   func, GLfloat   ref);
-typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei   n, const  GLuint  * textures, GLboolean  * residences);
-typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint   i);
-typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint   program, GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint   id, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum   target, GLuint   id);
-typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum   primitiveMode);
-typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint   program, GLuint   index, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum   target, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum   target, GLuint   index, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum   target, GLuint   index, GLuint   buffer, GLintptr   offset, GLsizeiptr   size);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint   program, GLuint   color, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint   program, GLuint   colorNumber, GLuint   index, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum   target, GLuint   framebuffer);
-typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum   target, GLuint   renderbuffer);
-typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint   unit, GLuint   sampler);
-typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum   target, GLuint   texture);
-typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint   array);
-typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei   width, GLsizei   height, GLfloat   xorig, GLfloat   yorig, GLfloat   xmove, GLfloat   ymove, const  GLubyte  * bitmap);
-typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum   modeRGB, GLenum   modeAlpha);
-typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum   sfactor, GLenum   dfactor);
-typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum   sfactorRGB, GLenum   dfactorRGB, GLenum   sfactorAlpha, GLenum   dfactorAlpha);
-typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint   srcX0, GLint   srcY0, GLint   srcX1, GLint   srcY1, GLint   dstX0, GLint   dstY0, GLint   dstX1, GLint   dstY1, GLbitfield   mask, GLenum   filter);
-typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum   target, GLsizeiptr   size, const void * data, GLenum   usage);
-typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   size, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint   list);
-typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei   n, GLenum   type, const void * lists);
-typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum   target, GLenum   clamp);
-typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum   buffer, GLint   drawbuffer, GLfloat   depth, GLint   stencil);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble   depth);
-typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat   c);
-typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint   s);
-typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum   texture);
-typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync   sync, GLbitfield   flags, GLuint64   timeout);
-typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum   plane, const  GLdouble  * equation);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint   red, GLint   green, GLint   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort   red, GLshort   green, GLshort   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint   red, GLuint   green, GLuint   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort   red, GLushort   green, GLushort   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue, GLbyte   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue, GLdouble   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint   red, GLint   green, GLint   blue, GLint   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort   red, GLshort   green, GLshort   blue, GLshort   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue, GLubyte   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint   red, GLuint   green, GLuint   blue, GLuint   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort   red, GLushort   green, GLushort   blue, GLushort   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean   red, GLboolean   green, GLboolean   blue, GLboolean   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint   index, GLboolean   r, GLboolean   g, GLboolean   b, GLboolean   a);
-typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum   face, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLsizei   height, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLsizei   width, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLsizei   width, GLsizei   height, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLsizei   width, GLsizei   height, GLsizei   depth, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum   readTarget, GLenum   writeTarget, GLintptr   readOffset, GLintptr   writeOffset, GLsizeiptr   size);
-typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   type);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLint   x, GLint   y, GLsizei   width, GLint   border);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLint   border);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   x, GLint   y, GLsizei   width);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
-typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum   type);
-typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC   callback, const void * userParam);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum   source, GLenum   type, GLenum   severity, GLsizei   count, const  GLuint  * ids, GLboolean   enabled);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum   source, GLenum   type, GLuint   id, GLenum   severity, GLsizei   length, const  GLchar  * buf);
-typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei   n, const  GLuint  * buffers);
-typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei   n, const  GLuint  * framebuffers);
-typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint   list, GLsizei   range);
-typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei   n, const  GLuint  * ids);
-typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei   n, const  GLuint  * renderbuffers);
-typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei   count, const  GLuint  * samplers);
-typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync   sync);
-typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei   n, const  GLuint  * textures);
-typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei   n, const  GLuint  * arrays);
-typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum   func);
-typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean   flag);
-typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble   n, GLdouble   f);
-typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint   program, GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum   cap);
-typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum   array);
-typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum   target, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum   mode, GLint   first, GLsizei   count);
-typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum   mode, GLint   first, GLsizei   count, GLsizei   instancecount);
-typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum   buf);
-typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei   n, const  GLenum  * bufs);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLsizei   instancecount);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLsizei   instancecount, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum   mode, GLuint   start, GLuint   end, GLsizei   count, GLenum   type, const void * indices);
-typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum   mode, GLuint   start, GLuint   end, GLsizei   count, GLenum   type, const void * indices, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean   flag);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const  GLboolean  * flag);
-typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum   cap);
-typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum   array);
-typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum   target, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLENDPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDLISTPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble   u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const  GLdouble  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat   u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const  GLfloat  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble   u, GLdouble   v);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const  GLdouble  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat   u, GLfloat   v);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const  GLfloat  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum   mode, GLint   i1, GLint   i2);
-typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum   mode, GLint   i1, GLint   i2, GLint   j1, GLint   j2);
-typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint   i);
-typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint   i, GLint   j);
-typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei   size, GLenum   type, GLfloat  * buffer);
-typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum   condition, GLbitfield   flags);
-typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   length);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble   coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const  GLdouble  * coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat   coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const  GLfloat  * coord);
-typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum   target, GLenum   attachment, GLenum   renderbuffertarget, GLuint   renderbuffer);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum   target, GLenum   attachment, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level, GLint   zoffset);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum   target, GLenum   attachment, GLuint   texture, GLint   level, GLint   layer);
-typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble   left, GLdouble   right, GLdouble   bottom, GLdouble   top, GLdouble   zNear, GLdouble   zFar);
-typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei   n, GLuint  * buffers);
-typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei   n, GLuint  * framebuffers);
-typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei   range);
-typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei   n, GLuint  * ids);
-typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei   n, GLuint  * renderbuffers);
-typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei   count, GLuint  * samplers);
-typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei   n, GLuint  * textures);
-typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei   n, GLuint  * arrays);
-typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLint  * size, GLenum  * type, GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLint  * size, GLenum  * type, GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint   program, GLuint   uniformBlockIndex, GLsizei   bufSize, GLsizei  * length, GLchar  * uniformBlockName);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint   program, GLuint   uniformBlockIndex, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint   program, GLuint   uniformIndex, GLsizei   bufSize, GLsizei  * length, GLchar  * uniformName);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint   program, GLsizei   uniformCount, const  GLuint  * uniformIndices, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint   program, GLsizei   maxCount, GLsizei  * count, GLuint  * shaders);
-typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum   target, GLuint   index, GLboolean  * data);
-typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum   pname, GLboolean  * data);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum   target, GLenum   pname, GLint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum   target, GLenum   pname, void ** params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   size, void * data);
-typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum   plane, GLdouble  * equation);
-typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum   target, GLint   level, void * img);
-typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint   count, GLsizei   bufSize, GLenum  * sources, GLenum  * types, GLuint  * ids, GLenum  * severities, GLsizei  * lengths, GLchar  * messageLog);
-typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum   pname, GLdouble  * data);
-typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum   pname, GLfloat  * data);
-typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint   program, const  GLchar  * name);
-typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum   target, GLenum   attachment, GLenum   pname, GLint  * params);
-typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSARBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum   target, GLuint   index, GLint64  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum   pname, GLint64  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum   target, GLuint   index, GLint  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum   pname, GLint  * data);
-typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum   light, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum   light, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum   target, GLenum   query, GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum   target, GLenum   query, GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum   target, GLenum   query, GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum   face, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum   face, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum   pname, GLuint   index, GLfloat  * val);
-typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum   identifier, GLuint   name, GLsizei   bufSize, GLsizei  * length, GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei   bufSize, GLsizei  * length, GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum   map, GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum   map, GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum   map, GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum   pname, void ** params);
-typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte  * mask);
-typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint   program, GLsizei   bufSize, GLsizei  * length, GLchar  * infoLog);
-typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint   program, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint   id, GLenum   pname, GLint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint   id, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint   id, GLenum   pname, GLuint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint   id, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint   sampler, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint   sampler, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint   sampler, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint   sampler, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint   shader, GLsizei   bufSize, GLsizei  * length, GLchar  * infoLog);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint   shader, GLsizei   bufSize, GLsizei  * length, GLchar  * source);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint   shader, GLenum   pname, GLint  * params);
-typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum   name);
-typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum   name, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync   sync, GLenum   pname, GLsizei   bufSize, GLsizei  * length, GLint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum   target, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum   coord, GLenum   pname, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum   coord, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum   coord, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum   target, GLint   level, GLenum   format, GLenum   type, void * pixels);
-typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum   target, GLint   level, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum   target, GLint   level, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum   target, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum   target, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLsizei  * size, GLenum  * type, GLchar  * name);
-typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint   program, const  GLchar  * uniformBlockName);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint   program, GLsizei   uniformCount, const  GLchar  *const* uniformNames, GLuint  * uniformIndices);
-typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint   program, GLint   location, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint   program, GLint   location, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint   program, GLint   location, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint   index, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint   index, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint   index, GLenum   pname, void ** pointer);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint   index, GLenum   pname, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint   index, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint   index, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNCOLORTABLEARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   bufSize, void * table);
-typedef void (GLAD_API_PTR *PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)(GLenum   target, GLint   lod, GLsizei   bufSize, void * img);
-typedef void (GLAD_API_PTR *PFNGLGETNCONVOLUTIONFILTERARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   bufSize, void * image);
-typedef void (GLAD_API_PTR *PFNGLGETNHISTOGRAMARBPROC)(GLenum   target, GLboolean   reset, GLenum   format, GLenum   type, GLsizei   bufSize, void * values);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPDVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPFVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPIVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMINMAXARBPROC)(GLenum   target, GLboolean   reset, GLenum   format, GLenum   type, GLsizei   bufSize, void * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPFVARBPROC)(GLenum   map, GLsizei   bufSize, GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUIVARBPROC)(GLenum   map, GLsizei   bufSize, GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUSVARBPROC)(GLenum   map, GLsizei   bufSize, GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPOLYGONSTIPPLEARBPROC)(GLsizei   bufSize, GLubyte  * pattern);
-typedef void (GLAD_API_PTR *PFNGLGETNSEPARABLEFILTERARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   rowBufSize, void * row, GLsizei   columnBufSize, void * column, void * span);
-typedef void (GLAD_API_PTR *PFNGLGETNTEXIMAGEARBPROC)(GLenum   target, GLint   level, GLenum   format, GLenum   type, GLsizei   bufSize, void * img);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMDVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum   target, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const  GLdouble  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const  GLfloat  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const  GLint  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const  GLshort  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const  GLubyte  * c);
-typedef void (GLAD_API_PTR *PFNGLINITNAMESPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum   format, GLsizei   stride, const void * pointer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint   buffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum   cap);
-typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum   target, GLuint   index);
-typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint   framebuffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint   list);
-typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint   program);
-typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint   id);
-typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint   renderbuffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint   sampler);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint   shader);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync   sync);
-typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint   texture);
-typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint   array);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum   light, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum   light, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum   light, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum   light, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint   factor, GLushort   pattern);
-typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat   width);
-typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint   base);
-typedef void (GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint   name);
-typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum   opcode);
-typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum   target, GLdouble   u1, GLdouble   u2, GLint   stride, GLint   order, const  GLdouble  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum   target, GLfloat   u1, GLfloat   u2, GLint   stride, GLint   order, const  GLfloat  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum   target, GLdouble   u1, GLdouble   u2, GLint   ustride, GLint   uorder, GLdouble   v1, GLdouble   v2, GLint   vstride, GLint   vorder, const  GLdouble  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum   target, GLfloat   u1, GLfloat   u2, GLint   ustride, GLint   uorder, GLfloat   v1, GLfloat   v2, GLint   vstride, GLint   vorder, const  GLfloat  * points);
-typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum   target, GLenum   access);
-typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   length, GLbitfield   access);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint   un, GLdouble   u1, GLdouble   u2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint   un, GLfloat   u1, GLfloat   u2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint   un, GLdouble   u1, GLdouble   u2, GLint   vn, GLdouble   v1, GLdouble   v2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint   un, GLfloat   u1, GLfloat   u2, GLint   vn, GLfloat   v1, GLfloat   v2);
-typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum   face, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum   face, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum   face, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum   face, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum   mode, const  GLint  * first, const  GLsizei  * count, GLsizei   drawcount);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum   mode, const  GLsizei  * count, GLenum   type, const void *const* indices, GLsizei   drawcount);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum   mode, const  GLsizei  * count, GLenum   type, const void *const* indices, GLsizei   drawcount, const  GLint  * basevertex);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum   target, GLdouble   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum   target, GLfloat   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum   target, GLint   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum   target, GLshort   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum   target, GLdouble   s, GLdouble   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum   target, GLfloat   s, GLfloat   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum   target, GLint   s, GLint   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum   target, GLshort   s, GLshort   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum   target, GLdouble   s, GLdouble   t, GLdouble   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum   target, GLfloat   s, GLfloat   t, GLfloat   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum   target, GLint   s, GLint   t, GLint   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum   target, GLshort   s, GLshort   t, GLshort   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum   target, GLdouble   s, GLdouble   t, GLdouble   r, GLdouble   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum   target, GLfloat   s, GLfloat   t, GLfloat   r, GLfloat   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum   target, GLint   s, GLint   t, GLint   r, GLint   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum   target, GLshort   s, GLshort   t, GLshort   r, GLshort   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint   list, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte   nx, GLbyte   ny, GLbyte   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble   nx, GLdouble   ny, GLdouble   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat   nx, GLfloat   ny, GLfloat   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint   nx, GLint   ny, GLint   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort   nx, GLshort   ny, GLshort   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum   identifier, GLuint   name, GLsizei   length, const  GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei   length, const  GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble   left, GLdouble   right, GLdouble   bottom, GLdouble   top, GLdouble   zNear, GLdouble   zFar);
-typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat   token);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum   map, GLsizei   mapsize, const  GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum   map, GLsizei   mapsize, const  GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum   map, GLsizei   mapsize, const  GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat   xfactor, GLfloat   yfactor);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat   size);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum   face, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat   factor, GLfloat   units);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const  GLubyte  * mask);
-typedef void (GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPNAMEPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei   n, const  GLuint  * textures, const  GLfloat  * priorities);
-typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum   source, GLuint   id, GLsizei   length, const  GLchar  * message);
-typedef void (GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint   name);
-typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint   id, GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum   src);
-typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, void * pixels);
-typedef void (GLAD_API_PTR *PFNGLREADNPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, GLsizei   bufSize, void * data);
-typedef void (GLAD_API_PTR *PFNGLREADNPIXELSARBPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, GLsizei   bufSize, void * data);
-typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble   x1, GLdouble   y1, GLdouble   x2, GLdouble   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const  GLdouble  * v1, const  GLdouble  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat   x1, GLfloat   y1, GLfloat   x2, GLfloat   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const  GLfloat  * v1, const  GLfloat  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint   x1, GLint   y1, GLint   x2, GLint   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const  GLint  * v1, const  GLint  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort   x1, GLshort   y1, GLshort   x2, GLshort   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const  GLshort  * v1, const  GLshort  * v2);
-typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum   target, GLenum   internalformat, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble   angle, GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat   angle, GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat   value, GLboolean   invert);
-typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat   value, GLboolean   invert);
-typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint   maskNumber, GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint   sampler, GLenum   pname, const  GLint  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint   sampler, GLenum   pname, const  GLuint  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint   sampler, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint   sampler, GLenum   pname, const  GLfloat  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint   sampler, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint   sampler, GLenum   pname, const  GLint  * param);
-typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint   red, GLint   green, GLint   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort   red, GLshort   green, GLshort   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint   red, GLuint   green, GLuint   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort   red, GLushort   green, GLushort   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei   size, GLuint  * buffer);
-typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint   shader, GLsizei   count, const  GLchar  *const* string, const  GLint  * length);
-typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum   func, GLint   ref, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum   face, GLenum   func, GLint   ref, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum   face, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum   fail, GLenum   zfail, GLenum   zpass);
-typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum   face, GLenum   sfail, GLenum   dpfail, GLenum   dppass);
-typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum   target, GLenum   internalformat, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble   s, GLdouble   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat   s, GLfloat   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint   s, GLint   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort   s, GLshort   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble   s, GLdouble   t, GLdouble   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat   s, GLfloat   t, GLfloat   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint   s, GLint   t, GLint   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort   s, GLshort   t, GLshort   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble   s, GLdouble   t, GLdouble   r, GLdouble   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat   s, GLfloat   t, GLfloat   r, GLfloat   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint   s, GLint   t, GLint   r, GLint   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort   s, GLshort   t, GLshort   r, GLshort   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum   target, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum   target, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum   target, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum   coord, GLenum   pname, GLdouble   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum   coord, GLenum   pname, const  GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum   coord, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum   coord, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum   coord, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum   coord, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLsizei   height, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height, GLboolean   fixedsamplelocations);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLboolean   fixedsamplelocations);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum   target, GLenum   pname, const  GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum   target, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum   target, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum   target, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLsizei   width, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLsizei   width, GLsizei   height, GLsizei   depth, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint   program, GLsizei   count, const  GLchar  *const* varyings, GLenum   bufferMode);
-typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint   location, GLfloat   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint   location, GLint   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint   location, GLuint   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint   location, GLfloat   v0, GLfloat   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint   location, GLint   v0, GLint   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint   location, GLuint   v0, GLuint   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint   location, GLfloat   v0, GLfloat   v1, GLfloat   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint   location, GLint   v0, GLint   v1, GLint   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint   location, GLuint   v0, GLuint   v1, GLuint   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint   location, GLfloat   v0, GLfloat   v1, GLfloat   v2, GLfloat   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint   location, GLint   v0, GLint   v1, GLint   v2, GLint   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint   location, GLuint   v0, GLuint   v1, GLuint   v2, GLuint   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint   program, GLuint   uniformBlockIndex, GLuint   uniformBlockBinding);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint   index, GLdouble   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint   index, GLfloat   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint   index, GLshort   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint   index, GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint   index, GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint   index, GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint   index, GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint   index, GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint   index, GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint   index, GLubyte   x, GLubyte   y, GLubyte   z, GLubyte   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint   index, GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint   index, GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint   index, GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint   index, GLuint   divisor);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint   index, GLint   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint   index, GLuint   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint   index, GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint   index, GLuint   x, GLuint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint   index, GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint   index, GLuint   x, GLuint   y, GLuint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint   index, GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint   index, GLuint   x, GLuint   y, GLuint   z, GLuint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint   index, GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint   index, GLint   size, GLenum   type, GLboolean   normalized, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync   sync, GLbitfield   flags, GLuint64   timeout);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const  GLshort  * v);
-
-GLAD_API_CALL PFNGLACCUMPROC glad_glAccum;
-#define glAccum glad_glAccum
-GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-#define glActiveTexture glad_glActiveTexture
-GLAD_API_CALL PFNGLALPHAFUNCPROC glad_glAlphaFunc;
-#define glAlphaFunc glad_glAlphaFunc
-GLAD_API_CALL PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident;
-#define glAreTexturesResident glad_glAreTexturesResident
-GLAD_API_CALL PFNGLARRAYELEMENTPROC glad_glArrayElement;
-#define glArrayElement glad_glArrayElement
-GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
-#define glAttachShader glad_glAttachShader
-GLAD_API_CALL PFNGLBEGINPROC glad_glBegin;
-#define glBegin glad_glBegin
-GLAD_API_CALL PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-#define glBeginConditionalRender glad_glBeginConditionalRender
-GLAD_API_CALL PFNGLBEGINQUERYPROC glad_glBeginQuery;
-#define glBeginQuery glad_glBeginQuery
-GLAD_API_CALL PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-#define glBeginTransformFeedback glad_glBeginTransformFeedback
-GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-#define glBindAttribLocation glad_glBindAttribLocation
-GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
-#define glBindBuffer glad_glBindBuffer
-GLAD_API_CALL PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-#define glBindBufferBase glad_glBindBufferBase
-GLAD_API_CALL PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-#define glBindBufferRange glad_glBindBufferRange
-GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-#define glBindFragDataLocation glad_glBindFragDataLocation
-GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
-GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-#define glBindFramebuffer glad_glBindFramebuffer
-GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-#define glBindRenderbuffer glad_glBindRenderbuffer
-GLAD_API_CALL PFNGLBINDSAMPLERPROC glad_glBindSampler;
-#define glBindSampler glad_glBindSampler
-GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
-#define glBindTexture glad_glBindTexture
-GLAD_API_CALL PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-#define glBindVertexArray glad_glBindVertexArray
-GLAD_API_CALL PFNGLBITMAPPROC glad_glBitmap;
-#define glBitmap glad_glBitmap
-GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
-#define glBlendColor glad_glBlendColor
-GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-#define glBlendEquation glad_glBlendEquation
-GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-#define glBlendEquationSeparate glad_glBlendEquationSeparate
-GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
-#define glBlendFunc glad_glBlendFunc
-GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-#define glBlendFuncSeparate glad_glBlendFuncSeparate
-GLAD_API_CALL PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-#define glBlitFramebuffer glad_glBlitFramebuffer
-GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
-#define glBufferData glad_glBufferData
-GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-#define glBufferSubData glad_glBufferSubData
-GLAD_API_CALL PFNGLCALLLISTPROC glad_glCallList;
-#define glCallList glad_glCallList
-GLAD_API_CALL PFNGLCALLLISTSPROC glad_glCallLists;
-#define glCallLists glad_glCallLists
-GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
-GLAD_API_CALL PFNGLCLAMPCOLORPROC glad_glClampColor;
-#define glClampColor glad_glClampColor
-GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
-#define glClear glad_glClear
-GLAD_API_CALL PFNGLCLEARACCUMPROC glad_glClearAccum;
-#define glClearAccum glad_glClearAccum
-GLAD_API_CALL PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-#define glClearBufferfi glad_glClearBufferfi
-GLAD_API_CALL PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-#define glClearBufferfv glad_glClearBufferfv
-GLAD_API_CALL PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-#define glClearBufferiv glad_glClearBufferiv
-GLAD_API_CALL PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-#define glClearBufferuiv glad_glClearBufferuiv
-GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
-#define glClearColor glad_glClearColor
-GLAD_API_CALL PFNGLCLEARDEPTHPROC glad_glClearDepth;
-#define glClearDepth glad_glClearDepth
-GLAD_API_CALL PFNGLCLEARINDEXPROC glad_glClearIndex;
-#define glClearIndex glad_glClearIndex
-GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
-#define glClearStencil glad_glClearStencil
-GLAD_API_CALL PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture;
-#define glClientActiveTexture glad_glClientActiveTexture
-GLAD_API_CALL PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-#define glClientWaitSync glad_glClientWaitSync
-GLAD_API_CALL PFNGLCLIPPLANEPROC glad_glClipPlane;
-#define glClipPlane glad_glClipPlane
-GLAD_API_CALL PFNGLCOLOR3BPROC glad_glColor3b;
-#define glColor3b glad_glColor3b
-GLAD_API_CALL PFNGLCOLOR3BVPROC glad_glColor3bv;
-#define glColor3bv glad_glColor3bv
-GLAD_API_CALL PFNGLCOLOR3DPROC glad_glColor3d;
-#define glColor3d glad_glColor3d
-GLAD_API_CALL PFNGLCOLOR3DVPROC glad_glColor3dv;
-#define glColor3dv glad_glColor3dv
-GLAD_API_CALL PFNGLCOLOR3FPROC glad_glColor3f;
-#define glColor3f glad_glColor3f
-GLAD_API_CALL PFNGLCOLOR3FVPROC glad_glColor3fv;
-#define glColor3fv glad_glColor3fv
-GLAD_API_CALL PFNGLCOLOR3IPROC glad_glColor3i;
-#define glColor3i glad_glColor3i
-GLAD_API_CALL PFNGLCOLOR3IVPROC glad_glColor3iv;
-#define glColor3iv glad_glColor3iv
-GLAD_API_CALL PFNGLCOLOR3SPROC glad_glColor3s;
-#define glColor3s glad_glColor3s
-GLAD_API_CALL PFNGLCOLOR3SVPROC glad_glColor3sv;
-#define glColor3sv glad_glColor3sv
-GLAD_API_CALL PFNGLCOLOR3UBPROC glad_glColor3ub;
-#define glColor3ub glad_glColor3ub
-GLAD_API_CALL PFNGLCOLOR3UBVPROC glad_glColor3ubv;
-#define glColor3ubv glad_glColor3ubv
-GLAD_API_CALL PFNGLCOLOR3UIPROC glad_glColor3ui;
-#define glColor3ui glad_glColor3ui
-GLAD_API_CALL PFNGLCOLOR3UIVPROC glad_glColor3uiv;
-#define glColor3uiv glad_glColor3uiv
-GLAD_API_CALL PFNGLCOLOR3USPROC glad_glColor3us;
-#define glColor3us glad_glColor3us
-GLAD_API_CALL PFNGLCOLOR3USVPROC glad_glColor3usv;
-#define glColor3usv glad_glColor3usv
-GLAD_API_CALL PFNGLCOLOR4BPROC glad_glColor4b;
-#define glColor4b glad_glColor4b
-GLAD_API_CALL PFNGLCOLOR4BVPROC glad_glColor4bv;
-#define glColor4bv glad_glColor4bv
-GLAD_API_CALL PFNGLCOLOR4DPROC glad_glColor4d;
-#define glColor4d glad_glColor4d
-GLAD_API_CALL PFNGLCOLOR4DVPROC glad_glColor4dv;
-#define glColor4dv glad_glColor4dv
-GLAD_API_CALL PFNGLCOLOR4FPROC glad_glColor4f;
-#define glColor4f glad_glColor4f
-GLAD_API_CALL PFNGLCOLOR4FVPROC glad_glColor4fv;
-#define glColor4fv glad_glColor4fv
-GLAD_API_CALL PFNGLCOLOR4IPROC glad_glColor4i;
-#define glColor4i glad_glColor4i
-GLAD_API_CALL PFNGLCOLOR4IVPROC glad_glColor4iv;
-#define glColor4iv glad_glColor4iv
-GLAD_API_CALL PFNGLCOLOR4SPROC glad_glColor4s;
-#define glColor4s glad_glColor4s
-GLAD_API_CALL PFNGLCOLOR4SVPROC glad_glColor4sv;
-#define glColor4sv glad_glColor4sv
-GLAD_API_CALL PFNGLCOLOR4UBPROC glad_glColor4ub;
-#define glColor4ub glad_glColor4ub
-GLAD_API_CALL PFNGLCOLOR4UBVPROC glad_glColor4ubv;
-#define glColor4ubv glad_glColor4ubv
-GLAD_API_CALL PFNGLCOLOR4UIPROC glad_glColor4ui;
-#define glColor4ui glad_glColor4ui
-GLAD_API_CALL PFNGLCOLOR4UIVPROC glad_glColor4uiv;
-#define glColor4uiv glad_glColor4uiv
-GLAD_API_CALL PFNGLCOLOR4USPROC glad_glColor4us;
-#define glColor4us glad_glColor4us
-GLAD_API_CALL PFNGLCOLOR4USVPROC glad_glColor4usv;
-#define glColor4usv glad_glColor4usv
-GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
-#define glColorMask glad_glColorMask
-GLAD_API_CALL PFNGLCOLORMASKIPROC glad_glColorMaski;
-#define glColorMaski glad_glColorMaski
-GLAD_API_CALL PFNGLCOLORMATERIALPROC glad_glColorMaterial;
-#define glColorMaterial glad_glColorMaterial
-GLAD_API_CALL PFNGLCOLORP3UIPROC glad_glColorP3ui;
-#define glColorP3ui glad_glColorP3ui
-GLAD_API_CALL PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-#define glColorP3uiv glad_glColorP3uiv
-GLAD_API_CALL PFNGLCOLORP4UIPROC glad_glColorP4ui;
-#define glColorP4ui glad_glColorP4ui
-GLAD_API_CALL PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-#define glColorP4uiv glad_glColorP4uiv
-GLAD_API_CALL PFNGLCOLORPOINTERPROC glad_glColorPointer;
-#define glColorPointer glad_glColorPointer
-GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
-#define glCompileShader glad_glCompileShader
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-#define glCompressedTexImage1D glad_glCompressedTexImage1D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-#define glCompressedTexImage2D glad_glCompressedTexImage2D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-#define glCompressedTexImage3D glad_glCompressedTexImage3D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
-GLAD_API_CALL PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-#define glCopyBufferSubData glad_glCopyBufferSubData
-GLAD_API_CALL PFNGLCOPYPIXELSPROC glad_glCopyPixels;
-#define glCopyPixels glad_glCopyPixels
-GLAD_API_CALL PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-#define glCopyTexImage1D glad_glCopyTexImage1D
-GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-#define glCopyTexImage2D glad_glCopyTexImage2D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
-GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-#define glCreateProgram glad_glCreateProgram
-GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
-#define glCreateShader glad_glCreateShader
-GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
-#define glCullFace glad_glCullFace
-GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
-#define glDebugMessageCallback glad_glDebugMessageCallback
-GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
-#define glDebugMessageControl glad_glDebugMessageControl
-GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
-#define glDebugMessageInsert glad_glDebugMessageInsert
-GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-#define glDeleteBuffers glad_glDeleteBuffers
-GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-#define glDeleteFramebuffers glad_glDeleteFramebuffers
-GLAD_API_CALL PFNGLDELETELISTSPROC glad_glDeleteLists;
-#define glDeleteLists glad_glDeleteLists
-GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-#define glDeleteProgram glad_glDeleteProgram
-GLAD_API_CALL PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-#define glDeleteQueries glad_glDeleteQueries
-GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
-GLAD_API_CALL PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-#define glDeleteSamplers glad_glDeleteSamplers
-GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
-#define glDeleteShader glad_glDeleteShader
-GLAD_API_CALL PFNGLDELETESYNCPROC glad_glDeleteSync;
-#define glDeleteSync glad_glDeleteSync
-GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-#define glDeleteTextures glad_glDeleteTextures
-GLAD_API_CALL PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-#define glDeleteVertexArrays glad_glDeleteVertexArrays
-GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-#define glDepthFunc glad_glDepthFunc
-GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
-#define glDepthMask glad_glDepthMask
-GLAD_API_CALL PFNGLDEPTHRANGEPROC glad_glDepthRange;
-#define glDepthRange glad_glDepthRange
-GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
-#define glDetachShader glad_glDetachShader
-GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
-#define glDisable glad_glDisable
-GLAD_API_CALL PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState;
-#define glDisableClientState glad_glDisableClientState
-GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
-GLAD_API_CALL PFNGLDISABLEIPROC glad_glDisablei;
-#define glDisablei glad_glDisablei
-GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-#define glDrawArrays glad_glDrawArrays
-GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-#define glDrawArraysInstanced glad_glDrawArraysInstanced
-GLAD_API_CALL PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-#define glDrawBuffer glad_glDrawBuffer
-GLAD_API_CALL PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-#define glDrawBuffers glad_glDrawBuffers
-GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-#define glDrawElements glad_glDrawElements
-GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
-GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-#define glDrawElementsInstanced glad_glDrawElementsInstanced
-GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
-GLAD_API_CALL PFNGLDRAWPIXELSPROC glad_glDrawPixels;
-#define glDrawPixels glad_glDrawPixels
-GLAD_API_CALL PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-#define glDrawRangeElements glad_glDrawRangeElements
-GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
-GLAD_API_CALL PFNGLEDGEFLAGPROC glad_glEdgeFlag;
-#define glEdgeFlag glad_glEdgeFlag
-GLAD_API_CALL PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer;
-#define glEdgeFlagPointer glad_glEdgeFlagPointer
-GLAD_API_CALL PFNGLEDGEFLAGVPROC glad_glEdgeFlagv;
-#define glEdgeFlagv glad_glEdgeFlagv
-GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
-#define glEnable glad_glEnable
-GLAD_API_CALL PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState;
-#define glEnableClientState glad_glEnableClientState
-GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
-GLAD_API_CALL PFNGLENABLEIPROC glad_glEnablei;
-#define glEnablei glad_glEnablei
-GLAD_API_CALL PFNGLENDPROC glad_glEnd;
-#define glEnd glad_glEnd
-GLAD_API_CALL PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-#define glEndConditionalRender glad_glEndConditionalRender
-GLAD_API_CALL PFNGLENDLISTPROC glad_glEndList;
-#define glEndList glad_glEndList
-GLAD_API_CALL PFNGLENDQUERYPROC glad_glEndQuery;
-#define glEndQuery glad_glEndQuery
-GLAD_API_CALL PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-#define glEndTransformFeedback glad_glEndTransformFeedback
-GLAD_API_CALL PFNGLEVALCOORD1DPROC glad_glEvalCoord1d;
-#define glEvalCoord1d glad_glEvalCoord1d
-GLAD_API_CALL PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv;
-#define glEvalCoord1dv glad_glEvalCoord1dv
-GLAD_API_CALL PFNGLEVALCOORD1FPROC glad_glEvalCoord1f;
-#define glEvalCoord1f glad_glEvalCoord1f
-GLAD_API_CALL PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv;
-#define glEvalCoord1fv glad_glEvalCoord1fv
-GLAD_API_CALL PFNGLEVALCOORD2DPROC glad_glEvalCoord2d;
-#define glEvalCoord2d glad_glEvalCoord2d
-GLAD_API_CALL PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv;
-#define glEvalCoord2dv glad_glEvalCoord2dv
-GLAD_API_CALL PFNGLEVALCOORD2FPROC glad_glEvalCoord2f;
-#define glEvalCoord2f glad_glEvalCoord2f
-GLAD_API_CALL PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv;
-#define glEvalCoord2fv glad_glEvalCoord2fv
-GLAD_API_CALL PFNGLEVALMESH1PROC glad_glEvalMesh1;
-#define glEvalMesh1 glad_glEvalMesh1
-GLAD_API_CALL PFNGLEVALMESH2PROC glad_glEvalMesh2;
-#define glEvalMesh2 glad_glEvalMesh2
-GLAD_API_CALL PFNGLEVALPOINT1PROC glad_glEvalPoint1;
-#define glEvalPoint1 glad_glEvalPoint1
-GLAD_API_CALL PFNGLEVALPOINT2PROC glad_glEvalPoint2;
-#define glEvalPoint2 glad_glEvalPoint2
-GLAD_API_CALL PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer;
-#define glFeedbackBuffer glad_glFeedbackBuffer
-GLAD_API_CALL PFNGLFENCESYNCPROC glad_glFenceSync;
-#define glFenceSync glad_glFenceSync
-GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
-#define glFinish glad_glFinish
-GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
-#define glFlush glad_glFlush
-GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
-GLAD_API_CALL PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer;
-#define glFogCoordPointer glad_glFogCoordPointer
-GLAD_API_CALL PFNGLFOGCOORDDPROC glad_glFogCoordd;
-#define glFogCoordd glad_glFogCoordd
-GLAD_API_CALL PFNGLFOGCOORDDVPROC glad_glFogCoorddv;
-#define glFogCoorddv glad_glFogCoorddv
-GLAD_API_CALL PFNGLFOGCOORDFPROC glad_glFogCoordf;
-#define glFogCoordf glad_glFogCoordf
-GLAD_API_CALL PFNGLFOGCOORDFVPROC glad_glFogCoordfv;
-#define glFogCoordfv glad_glFogCoordfv
-GLAD_API_CALL PFNGLFOGFPROC glad_glFogf;
-#define glFogf glad_glFogf
-GLAD_API_CALL PFNGLFOGFVPROC glad_glFogfv;
-#define glFogfv glad_glFogfv
-GLAD_API_CALL PFNGLFOGIPROC glad_glFogi;
-#define glFogi glad_glFogi
-GLAD_API_CALL PFNGLFOGIVPROC glad_glFogiv;
-#define glFogiv glad_glFogiv
-GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-#define glFramebufferTexture glad_glFramebufferTexture
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-#define glFramebufferTexture1D glad_glFramebufferTexture1D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-#define glFramebufferTexture2D glad_glFramebufferTexture2D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-#define glFramebufferTexture3D glad_glFramebufferTexture3D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
-GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
-#define glFrontFace glad_glFrontFace
-GLAD_API_CALL PFNGLFRUSTUMPROC glad_glFrustum;
-#define glFrustum glad_glFrustum
-GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
-#define glGenBuffers glad_glGenBuffers
-GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-#define glGenFramebuffers glad_glGenFramebuffers
-GLAD_API_CALL PFNGLGENLISTSPROC glad_glGenLists;
-#define glGenLists glad_glGenLists
-GLAD_API_CALL PFNGLGENQUERIESPROC glad_glGenQueries;
-#define glGenQueries glad_glGenQueries
-GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-#define glGenRenderbuffers glad_glGenRenderbuffers
-GLAD_API_CALL PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-#define glGenSamplers glad_glGenSamplers
-GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
-#define glGenTextures glad_glGenTextures
-GLAD_API_CALL PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-#define glGenVertexArrays glad_glGenVertexArrays
-GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-#define glGenerateMipmap glad_glGenerateMipmap
-GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-#define glGetActiveAttrib glad_glGetActiveAttrib
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-#define glGetActiveUniform glad_glGetActiveUniform
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-#define glGetActiveUniformName glad_glGetActiveUniformName
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
-GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-#define glGetAttachedShaders glad_glGetAttachedShaders
-GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-#define glGetAttribLocation glad_glGetAttribLocation
-GLAD_API_CALL PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-#define glGetBooleani_v glad_glGetBooleani_v
-GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-#define glGetBooleanv glad_glGetBooleanv
-GLAD_API_CALL PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
-GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-#define glGetBufferParameteriv glad_glGetBufferParameteriv
-GLAD_API_CALL PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-#define glGetBufferPointerv glad_glGetBufferPointerv
-GLAD_API_CALL PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-#define glGetBufferSubData glad_glGetBufferSubData
-GLAD_API_CALL PFNGLGETCLIPPLANEPROC glad_glGetClipPlane;
-#define glGetClipPlane glad_glGetClipPlane
-GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-#define glGetCompressedTexImage glad_glGetCompressedTexImage
-GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
-#define glGetDebugMessageLog glad_glGetDebugMessageLog
-GLAD_API_CALL PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-#define glGetDoublev glad_glGetDoublev
-GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
-#define glGetError glad_glGetError
-GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
-#define glGetFloatv glad_glGetFloatv
-GLAD_API_CALL PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-#define glGetFragDataIndex glad_glGetFragDataIndex
-GLAD_API_CALL PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-#define glGetFragDataLocation glad_glGetFragDataLocation
-GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
-GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB;
-#define glGetGraphicsResetStatusARB glad_glGetGraphicsResetStatusARB
-GLAD_API_CALL PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-#define glGetInteger64i_v glad_glGetInteger64i_v
-GLAD_API_CALL PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-#define glGetInteger64v glad_glGetInteger64v
-GLAD_API_CALL PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-#define glGetIntegeri_v glad_glGetIntegeri_v
-GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-#define glGetIntegerv glad_glGetIntegerv
-GLAD_API_CALL PFNGLGETLIGHTFVPROC glad_glGetLightfv;
-#define glGetLightfv glad_glGetLightfv
-GLAD_API_CALL PFNGLGETLIGHTIVPROC glad_glGetLightiv;
-#define glGetLightiv glad_glGetLightiv
-GLAD_API_CALL PFNGLGETMAPDVPROC glad_glGetMapdv;
-#define glGetMapdv glad_glGetMapdv
-GLAD_API_CALL PFNGLGETMAPFVPROC glad_glGetMapfv;
-#define glGetMapfv glad_glGetMapfv
-GLAD_API_CALL PFNGLGETMAPIVPROC glad_glGetMapiv;
-#define glGetMapiv glad_glGetMapiv
-GLAD_API_CALL PFNGLGETMATERIALFVPROC glad_glGetMaterialfv;
-#define glGetMaterialfv glad_glGetMaterialfv
-GLAD_API_CALL PFNGLGETMATERIALIVPROC glad_glGetMaterialiv;
-#define glGetMaterialiv glad_glGetMaterialiv
-GLAD_API_CALL PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-#define glGetMultisamplefv glad_glGetMultisamplefv
-GLAD_API_CALL PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
-#define glGetObjectLabel glad_glGetObjectLabel
-GLAD_API_CALL PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
-#define glGetObjectPtrLabel glad_glGetObjectPtrLabel
-GLAD_API_CALL PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv;
-#define glGetPixelMapfv glad_glGetPixelMapfv
-GLAD_API_CALL PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv;
-#define glGetPixelMapuiv glad_glGetPixelMapuiv
-GLAD_API_CALL PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv;
-#define glGetPixelMapusv glad_glGetPixelMapusv
-GLAD_API_CALL PFNGLGETPOINTERVPROC glad_glGetPointerv;
-#define glGetPointerv glad_glGetPointerv
-GLAD_API_CALL PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple;
-#define glGetPolygonStipple glad_glGetPolygonStipple
-GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-#define glGetProgramInfoLog glad_glGetProgramInfoLog
-GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-#define glGetProgramiv glad_glGetProgramiv
-GLAD_API_CALL PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
-GLAD_API_CALL PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-#define glGetQueryObjectiv glad_glGetQueryObjectiv
-GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
-GLAD_API_CALL PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
-GLAD_API_CALL PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-#define glGetQueryiv glad_glGetQueryiv
-GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
-GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-#define glGetShaderInfoLog glad_glGetShaderInfoLog
-GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-#define glGetShaderSource glad_glGetShaderSource
-GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-#define glGetShaderiv glad_glGetShaderiv
-GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
-#define glGetString glad_glGetString
-GLAD_API_CALL PFNGLGETSTRINGIPROC glad_glGetStringi;
-#define glGetStringi glad_glGetStringi
-GLAD_API_CALL PFNGLGETSYNCIVPROC glad_glGetSynciv;
-#define glGetSynciv glad_glGetSynciv
-GLAD_API_CALL PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv;
-#define glGetTexEnvfv glad_glGetTexEnvfv
-GLAD_API_CALL PFNGLGETTEXENVIVPROC glad_glGetTexEnviv;
-#define glGetTexEnviv glad_glGetTexEnviv
-GLAD_API_CALL PFNGLGETTEXGENDVPROC glad_glGetTexGendv;
-#define glGetTexGendv glad_glGetTexGendv
-GLAD_API_CALL PFNGLGETTEXGENFVPROC glad_glGetTexGenfv;
-#define glGetTexGenfv glad_glGetTexGenfv
-GLAD_API_CALL PFNGLGETTEXGENIVPROC glad_glGetTexGeniv;
-#define glGetTexGeniv glad_glGetTexGeniv
-GLAD_API_CALL PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-#define glGetTexImage glad_glGetTexImage
-GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
-GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-#define glGetTexParameterIiv glad_glGetTexParameterIiv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
-GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-#define glGetTexParameterfv glad_glGetTexParameterfv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-#define glGetTexParameteriv glad_glGetTexParameteriv
-GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
-GLAD_API_CALL PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
-GLAD_API_CALL PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-#define glGetUniformIndices glad_glGetUniformIndices
-GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-#define glGetUniformLocation glad_glGetUniformLocation
-GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-#define glGetUniformfv glad_glGetUniformfv
-GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-#define glGetUniformiv glad_glGetUniformiv
-GLAD_API_CALL PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-#define glGetUniformuiv glad_glGetUniformuiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-#define glGetVertexAttribdv glad_glGetVertexAttribdv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-#define glGetVertexAttribfv glad_glGetVertexAttribfv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-#define glGetVertexAttribiv glad_glGetVertexAttribiv
-GLAD_API_CALL PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB;
-#define glGetnColorTableARB glad_glGetnColorTableARB
-GLAD_API_CALL PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB;
-#define glGetnCompressedTexImageARB glad_glGetnCompressedTexImageARB
-GLAD_API_CALL PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB;
-#define glGetnConvolutionFilterARB glad_glGetnConvolutionFilterARB
-GLAD_API_CALL PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB;
-#define glGetnHistogramARB glad_glGetnHistogramARB
-GLAD_API_CALL PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB;
-#define glGetnMapdvARB glad_glGetnMapdvARB
-GLAD_API_CALL PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB;
-#define glGetnMapfvARB glad_glGetnMapfvARB
-GLAD_API_CALL PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB;
-#define glGetnMapivARB glad_glGetnMapivARB
-GLAD_API_CALL PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB;
-#define glGetnMinmaxARB glad_glGetnMinmaxARB
-GLAD_API_CALL PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB;
-#define glGetnPixelMapfvARB glad_glGetnPixelMapfvARB
-GLAD_API_CALL PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB;
-#define glGetnPixelMapuivARB glad_glGetnPixelMapuivARB
-GLAD_API_CALL PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB;
-#define glGetnPixelMapusvARB glad_glGetnPixelMapusvARB
-GLAD_API_CALL PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB;
-#define glGetnPolygonStippleARB glad_glGetnPolygonStippleARB
-GLAD_API_CALL PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB;
-#define glGetnSeparableFilterARB glad_glGetnSeparableFilterARB
-GLAD_API_CALL PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB;
-#define glGetnTexImageARB glad_glGetnTexImageARB
-GLAD_API_CALL PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB;
-#define glGetnUniformdvARB glad_glGetnUniformdvARB
-GLAD_API_CALL PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB;
-#define glGetnUniformfvARB glad_glGetnUniformfvARB
-GLAD_API_CALL PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB;
-#define glGetnUniformivARB glad_glGetnUniformivARB
-GLAD_API_CALL PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB;
-#define glGetnUniformuivARB glad_glGetnUniformuivARB
-GLAD_API_CALL PFNGLHINTPROC glad_glHint;
-#define glHint glad_glHint
-GLAD_API_CALL PFNGLINDEXMASKPROC glad_glIndexMask;
-#define glIndexMask glad_glIndexMask
-GLAD_API_CALL PFNGLINDEXPOINTERPROC glad_glIndexPointer;
-#define glIndexPointer glad_glIndexPointer
-GLAD_API_CALL PFNGLINDEXDPROC glad_glIndexd;
-#define glIndexd glad_glIndexd
-GLAD_API_CALL PFNGLINDEXDVPROC glad_glIndexdv;
-#define glIndexdv glad_glIndexdv
-GLAD_API_CALL PFNGLINDEXFPROC glad_glIndexf;
-#define glIndexf glad_glIndexf
-GLAD_API_CALL PFNGLINDEXFVPROC glad_glIndexfv;
-#define glIndexfv glad_glIndexfv
-GLAD_API_CALL PFNGLINDEXIPROC glad_glIndexi;
-#define glIndexi glad_glIndexi
-GLAD_API_CALL PFNGLINDEXIVPROC glad_glIndexiv;
-#define glIndexiv glad_glIndexiv
-GLAD_API_CALL PFNGLINDEXSPROC glad_glIndexs;
-#define glIndexs glad_glIndexs
-GLAD_API_CALL PFNGLINDEXSVPROC glad_glIndexsv;
-#define glIndexsv glad_glIndexsv
-GLAD_API_CALL PFNGLINDEXUBPROC glad_glIndexub;
-#define glIndexub glad_glIndexub
-GLAD_API_CALL PFNGLINDEXUBVPROC glad_glIndexubv;
-#define glIndexubv glad_glIndexubv
-GLAD_API_CALL PFNGLINITNAMESPROC glad_glInitNames;
-#define glInitNames glad_glInitNames
-GLAD_API_CALL PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays;
-#define glInterleavedArrays glad_glInterleavedArrays
-GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
-#define glIsBuffer glad_glIsBuffer
-GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
-#define glIsEnabled glad_glIsEnabled
-GLAD_API_CALL PFNGLISENABLEDIPROC glad_glIsEnabledi;
-#define glIsEnabledi glad_glIsEnabledi
-GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-#define glIsFramebuffer glad_glIsFramebuffer
-GLAD_API_CALL PFNGLISLISTPROC glad_glIsList;
-#define glIsList glad_glIsList
-GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
-#define glIsProgram glad_glIsProgram
-GLAD_API_CALL PFNGLISQUERYPROC glad_glIsQuery;
-#define glIsQuery glad_glIsQuery
-GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-#define glIsRenderbuffer glad_glIsRenderbuffer
-GLAD_API_CALL PFNGLISSAMPLERPROC glad_glIsSampler;
-#define glIsSampler glad_glIsSampler
-GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
-#define glIsShader glad_glIsShader
-GLAD_API_CALL PFNGLISSYNCPROC glad_glIsSync;
-#define glIsSync glad_glIsSync
-GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
-#define glIsTexture glad_glIsTexture
-GLAD_API_CALL PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-#define glIsVertexArray glad_glIsVertexArray
-GLAD_API_CALL PFNGLLIGHTMODELFPROC glad_glLightModelf;
-#define glLightModelf glad_glLightModelf
-GLAD_API_CALL PFNGLLIGHTMODELFVPROC glad_glLightModelfv;
-#define glLightModelfv glad_glLightModelfv
-GLAD_API_CALL PFNGLLIGHTMODELIPROC glad_glLightModeli;
-#define glLightModeli glad_glLightModeli
-GLAD_API_CALL PFNGLLIGHTMODELIVPROC glad_glLightModeliv;
-#define glLightModeliv glad_glLightModeliv
-GLAD_API_CALL PFNGLLIGHTFPROC glad_glLightf;
-#define glLightf glad_glLightf
-GLAD_API_CALL PFNGLLIGHTFVPROC glad_glLightfv;
-#define glLightfv glad_glLightfv
-GLAD_API_CALL PFNGLLIGHTIPROC glad_glLighti;
-#define glLighti glad_glLighti
-GLAD_API_CALL PFNGLLIGHTIVPROC glad_glLightiv;
-#define glLightiv glad_glLightiv
-GLAD_API_CALL PFNGLLINESTIPPLEPROC glad_glLineStipple;
-#define glLineStipple glad_glLineStipple
-GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
-#define glLineWidth glad_glLineWidth
-GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-#define glLinkProgram glad_glLinkProgram
-GLAD_API_CALL PFNGLLISTBASEPROC glad_glListBase;
-#define glListBase glad_glListBase
-GLAD_API_CALL PFNGLLOADIDENTITYPROC glad_glLoadIdentity;
-#define glLoadIdentity glad_glLoadIdentity
-GLAD_API_CALL PFNGLLOADMATRIXDPROC glad_glLoadMatrixd;
-#define glLoadMatrixd glad_glLoadMatrixd
-GLAD_API_CALL PFNGLLOADMATRIXFPROC glad_glLoadMatrixf;
-#define glLoadMatrixf glad_glLoadMatrixf
-GLAD_API_CALL PFNGLLOADNAMEPROC glad_glLoadName;
-#define glLoadName glad_glLoadName
-GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd;
-#define glLoadTransposeMatrixd glad_glLoadTransposeMatrixd
-GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf;
-#define glLoadTransposeMatrixf glad_glLoadTransposeMatrixf
-GLAD_API_CALL PFNGLLOGICOPPROC glad_glLogicOp;
-#define glLogicOp glad_glLogicOp
-GLAD_API_CALL PFNGLMAP1DPROC glad_glMap1d;
-#define glMap1d glad_glMap1d
-GLAD_API_CALL PFNGLMAP1FPROC glad_glMap1f;
-#define glMap1f glad_glMap1f
-GLAD_API_CALL PFNGLMAP2DPROC glad_glMap2d;
-#define glMap2d glad_glMap2d
-GLAD_API_CALL PFNGLMAP2FPROC glad_glMap2f;
-#define glMap2f glad_glMap2f
-GLAD_API_CALL PFNGLMAPBUFFERPROC glad_glMapBuffer;
-#define glMapBuffer glad_glMapBuffer
-GLAD_API_CALL PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-#define glMapBufferRange glad_glMapBufferRange
-GLAD_API_CALL PFNGLMAPGRID1DPROC glad_glMapGrid1d;
-#define glMapGrid1d glad_glMapGrid1d
-GLAD_API_CALL PFNGLMAPGRID1FPROC glad_glMapGrid1f;
-#define glMapGrid1f glad_glMapGrid1f
-GLAD_API_CALL PFNGLMAPGRID2DPROC glad_glMapGrid2d;
-#define glMapGrid2d glad_glMapGrid2d
-GLAD_API_CALL PFNGLMAPGRID2FPROC glad_glMapGrid2f;
-#define glMapGrid2f glad_glMapGrid2f
-GLAD_API_CALL PFNGLMATERIALFPROC glad_glMaterialf;
-#define glMaterialf glad_glMaterialf
-GLAD_API_CALL PFNGLMATERIALFVPROC glad_glMaterialfv;
-#define glMaterialfv glad_glMaterialfv
-GLAD_API_CALL PFNGLMATERIALIPROC glad_glMateriali;
-#define glMateriali glad_glMateriali
-GLAD_API_CALL PFNGLMATERIALIVPROC glad_glMaterialiv;
-#define glMaterialiv glad_glMaterialiv
-GLAD_API_CALL PFNGLMATRIXMODEPROC glad_glMatrixMode;
-#define glMatrixMode glad_glMatrixMode
-GLAD_API_CALL PFNGLMULTMATRIXDPROC glad_glMultMatrixd;
-#define glMultMatrixd glad_glMultMatrixd
-GLAD_API_CALL PFNGLMULTMATRIXFPROC glad_glMultMatrixf;
-#define glMultMatrixf glad_glMultMatrixf
-GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd;
-#define glMultTransposeMatrixd glad_glMultTransposeMatrixd
-GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf;
-#define glMultTransposeMatrixf glad_glMultTransposeMatrixf
-GLAD_API_CALL PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-#define glMultiDrawArrays glad_glMultiDrawArrays
-GLAD_API_CALL PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-#define glMultiDrawElements glad_glMultiDrawElements
-GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
-GLAD_API_CALL PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d;
-#define glMultiTexCoord1d glad_glMultiTexCoord1d
-GLAD_API_CALL PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv;
-#define glMultiTexCoord1dv glad_glMultiTexCoord1dv
-GLAD_API_CALL PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f;
-#define glMultiTexCoord1f glad_glMultiTexCoord1f
-GLAD_API_CALL PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv;
-#define glMultiTexCoord1fv glad_glMultiTexCoord1fv
-GLAD_API_CALL PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i;
-#define glMultiTexCoord1i glad_glMultiTexCoord1i
-GLAD_API_CALL PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv;
-#define glMultiTexCoord1iv glad_glMultiTexCoord1iv
-GLAD_API_CALL PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s;
-#define glMultiTexCoord1s glad_glMultiTexCoord1s
-GLAD_API_CALL PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv;
-#define glMultiTexCoord1sv glad_glMultiTexCoord1sv
-GLAD_API_CALL PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d;
-#define glMultiTexCoord2d glad_glMultiTexCoord2d
-GLAD_API_CALL PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv;
-#define glMultiTexCoord2dv glad_glMultiTexCoord2dv
-GLAD_API_CALL PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f;
-#define glMultiTexCoord2f glad_glMultiTexCoord2f
-GLAD_API_CALL PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv;
-#define glMultiTexCoord2fv glad_glMultiTexCoord2fv
-GLAD_API_CALL PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i;
-#define glMultiTexCoord2i glad_glMultiTexCoord2i
-GLAD_API_CALL PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv;
-#define glMultiTexCoord2iv glad_glMultiTexCoord2iv
-GLAD_API_CALL PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s;
-#define glMultiTexCoord2s glad_glMultiTexCoord2s
-GLAD_API_CALL PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv;
-#define glMultiTexCoord2sv glad_glMultiTexCoord2sv
-GLAD_API_CALL PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d;
-#define glMultiTexCoord3d glad_glMultiTexCoord3d
-GLAD_API_CALL PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv;
-#define glMultiTexCoord3dv glad_glMultiTexCoord3dv
-GLAD_API_CALL PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f;
-#define glMultiTexCoord3f glad_glMultiTexCoord3f
-GLAD_API_CALL PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv;
-#define glMultiTexCoord3fv glad_glMultiTexCoord3fv
-GLAD_API_CALL PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i;
-#define glMultiTexCoord3i glad_glMultiTexCoord3i
-GLAD_API_CALL PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv;
-#define glMultiTexCoord3iv glad_glMultiTexCoord3iv
-GLAD_API_CALL PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s;
-#define glMultiTexCoord3s glad_glMultiTexCoord3s
-GLAD_API_CALL PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv;
-#define glMultiTexCoord3sv glad_glMultiTexCoord3sv
-GLAD_API_CALL PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d;
-#define glMultiTexCoord4d glad_glMultiTexCoord4d
-GLAD_API_CALL PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv;
-#define glMultiTexCoord4dv glad_glMultiTexCoord4dv
-GLAD_API_CALL PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f;
-#define glMultiTexCoord4f glad_glMultiTexCoord4f
-GLAD_API_CALL PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv;
-#define glMultiTexCoord4fv glad_glMultiTexCoord4fv
-GLAD_API_CALL PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i;
-#define glMultiTexCoord4i glad_glMultiTexCoord4i
-GLAD_API_CALL PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv;
-#define glMultiTexCoord4iv glad_glMultiTexCoord4iv
-GLAD_API_CALL PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s;
-#define glMultiTexCoord4s glad_glMultiTexCoord4s
-GLAD_API_CALL PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv;
-#define glMultiTexCoord4sv glad_glMultiTexCoord4sv
-GLAD_API_CALL PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
-GLAD_API_CALL PFNGLNEWLISTPROC glad_glNewList;
-#define glNewList glad_glNewList
-GLAD_API_CALL PFNGLNORMAL3BPROC glad_glNormal3b;
-#define glNormal3b glad_glNormal3b
-GLAD_API_CALL PFNGLNORMAL3BVPROC glad_glNormal3bv;
-#define glNormal3bv glad_glNormal3bv
-GLAD_API_CALL PFNGLNORMAL3DPROC glad_glNormal3d;
-#define glNormal3d glad_glNormal3d
-GLAD_API_CALL PFNGLNORMAL3DVPROC glad_glNormal3dv;
-#define glNormal3dv glad_glNormal3dv
-GLAD_API_CALL PFNGLNORMAL3FPROC glad_glNormal3f;
-#define glNormal3f glad_glNormal3f
-GLAD_API_CALL PFNGLNORMAL3FVPROC glad_glNormal3fv;
-#define glNormal3fv glad_glNormal3fv
-GLAD_API_CALL PFNGLNORMAL3IPROC glad_glNormal3i;
-#define glNormal3i glad_glNormal3i
-GLAD_API_CALL PFNGLNORMAL3IVPROC glad_glNormal3iv;
-#define glNormal3iv glad_glNormal3iv
-GLAD_API_CALL PFNGLNORMAL3SPROC glad_glNormal3s;
-#define glNormal3s glad_glNormal3s
-GLAD_API_CALL PFNGLNORMAL3SVPROC glad_glNormal3sv;
-#define glNormal3sv glad_glNormal3sv
-GLAD_API_CALL PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-#define glNormalP3ui glad_glNormalP3ui
-GLAD_API_CALL PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-#define glNormalP3uiv glad_glNormalP3uiv
-GLAD_API_CALL PFNGLNORMALPOINTERPROC glad_glNormalPointer;
-#define glNormalPointer glad_glNormalPointer
-GLAD_API_CALL PFNGLOBJECTLABELPROC glad_glObjectLabel;
-#define glObjectLabel glad_glObjectLabel
-GLAD_API_CALL PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
-#define glObjectPtrLabel glad_glObjectPtrLabel
-GLAD_API_CALL PFNGLORTHOPROC glad_glOrtho;
-#define glOrtho glad_glOrtho
-GLAD_API_CALL PFNGLPASSTHROUGHPROC glad_glPassThrough;
-#define glPassThrough glad_glPassThrough
-GLAD_API_CALL PFNGLPIXELMAPFVPROC glad_glPixelMapfv;
-#define glPixelMapfv glad_glPixelMapfv
-GLAD_API_CALL PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv;
-#define glPixelMapuiv glad_glPixelMapuiv
-GLAD_API_CALL PFNGLPIXELMAPUSVPROC glad_glPixelMapusv;
-#define glPixelMapusv glad_glPixelMapusv
-GLAD_API_CALL PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-#define glPixelStoref glad_glPixelStoref
-GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-#define glPixelStorei glad_glPixelStorei
-GLAD_API_CALL PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf;
-#define glPixelTransferf glad_glPixelTransferf
-GLAD_API_CALL PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi;
-#define glPixelTransferi glad_glPixelTransferi
-GLAD_API_CALL PFNGLPIXELZOOMPROC glad_glPixelZoom;
-#define glPixelZoom glad_glPixelZoom
-GLAD_API_CALL PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-#define glPointParameterf glad_glPointParameterf
-GLAD_API_CALL PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-#define glPointParameterfv glad_glPointParameterfv
-GLAD_API_CALL PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-#define glPointParameteri glad_glPointParameteri
-GLAD_API_CALL PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-#define glPointParameteriv glad_glPointParameteriv
-GLAD_API_CALL PFNGLPOINTSIZEPROC glad_glPointSize;
-#define glPointSize glad_glPointSize
-GLAD_API_CALL PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-#define glPolygonMode glad_glPolygonMode
-GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-#define glPolygonOffset glad_glPolygonOffset
-GLAD_API_CALL PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple;
-#define glPolygonStipple glad_glPolygonStipple
-GLAD_API_CALL PFNGLPOPATTRIBPROC glad_glPopAttrib;
-#define glPopAttrib glad_glPopAttrib
-GLAD_API_CALL PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib;
-#define glPopClientAttrib glad_glPopClientAttrib
-GLAD_API_CALL PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
-#define glPopDebugGroup glad_glPopDebugGroup
-GLAD_API_CALL PFNGLPOPMATRIXPROC glad_glPopMatrix;
-#define glPopMatrix glad_glPopMatrix
-GLAD_API_CALL PFNGLPOPNAMEPROC glad_glPopName;
-#define glPopName glad_glPopName
-GLAD_API_CALL PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
-GLAD_API_CALL PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures;
-#define glPrioritizeTextures glad_glPrioritizeTextures
-GLAD_API_CALL PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-#define glProvokingVertex glad_glProvokingVertex
-GLAD_API_CALL PFNGLPUSHATTRIBPROC glad_glPushAttrib;
-#define glPushAttrib glad_glPushAttrib
-GLAD_API_CALL PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib;
-#define glPushClientAttrib glad_glPushClientAttrib
-GLAD_API_CALL PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
-#define glPushDebugGroup glad_glPushDebugGroup
-GLAD_API_CALL PFNGLPUSHMATRIXPROC glad_glPushMatrix;
-#define glPushMatrix glad_glPushMatrix
-GLAD_API_CALL PFNGLPUSHNAMEPROC glad_glPushName;
-#define glPushName glad_glPushName
-GLAD_API_CALL PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-#define glQueryCounter glad_glQueryCounter
-GLAD_API_CALL PFNGLRASTERPOS2DPROC glad_glRasterPos2d;
-#define glRasterPos2d glad_glRasterPos2d
-GLAD_API_CALL PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv;
-#define glRasterPos2dv glad_glRasterPos2dv
-GLAD_API_CALL PFNGLRASTERPOS2FPROC glad_glRasterPos2f;
-#define glRasterPos2f glad_glRasterPos2f
-GLAD_API_CALL PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv;
-#define glRasterPos2fv glad_glRasterPos2fv
-GLAD_API_CALL PFNGLRASTERPOS2IPROC glad_glRasterPos2i;
-#define glRasterPos2i glad_glRasterPos2i
-GLAD_API_CALL PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv;
-#define glRasterPos2iv glad_glRasterPos2iv
-GLAD_API_CALL PFNGLRASTERPOS2SPROC glad_glRasterPos2s;
-#define glRasterPos2s glad_glRasterPos2s
-GLAD_API_CALL PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv;
-#define glRasterPos2sv glad_glRasterPos2sv
-GLAD_API_CALL PFNGLRASTERPOS3DPROC glad_glRasterPos3d;
-#define glRasterPos3d glad_glRasterPos3d
-GLAD_API_CALL PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv;
-#define glRasterPos3dv glad_glRasterPos3dv
-GLAD_API_CALL PFNGLRASTERPOS3FPROC glad_glRasterPos3f;
-#define glRasterPos3f glad_glRasterPos3f
-GLAD_API_CALL PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv;
-#define glRasterPos3fv glad_glRasterPos3fv
-GLAD_API_CALL PFNGLRASTERPOS3IPROC glad_glRasterPos3i;
-#define glRasterPos3i glad_glRasterPos3i
-GLAD_API_CALL PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv;
-#define glRasterPos3iv glad_glRasterPos3iv
-GLAD_API_CALL PFNGLRASTERPOS3SPROC glad_glRasterPos3s;
-#define glRasterPos3s glad_glRasterPos3s
-GLAD_API_CALL PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv;
-#define glRasterPos3sv glad_glRasterPos3sv
-GLAD_API_CALL PFNGLRASTERPOS4DPROC glad_glRasterPos4d;
-#define glRasterPos4d glad_glRasterPos4d
-GLAD_API_CALL PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv;
-#define glRasterPos4dv glad_glRasterPos4dv
-GLAD_API_CALL PFNGLRASTERPOS4FPROC glad_glRasterPos4f;
-#define glRasterPos4f glad_glRasterPos4f
-GLAD_API_CALL PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv;
-#define glRasterPos4fv glad_glRasterPos4fv
-GLAD_API_CALL PFNGLRASTERPOS4IPROC glad_glRasterPos4i;
-#define glRasterPos4i glad_glRasterPos4i
-GLAD_API_CALL PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv;
-#define glRasterPos4iv glad_glRasterPos4iv
-GLAD_API_CALL PFNGLRASTERPOS4SPROC glad_glRasterPos4s;
-#define glRasterPos4s glad_glRasterPos4s
-GLAD_API_CALL PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv;
-#define glRasterPos4sv glad_glRasterPos4sv
-GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer;
-#define glReadBuffer glad_glReadBuffer
-GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
-#define glReadPixels glad_glReadPixels
-GLAD_API_CALL PFNGLREADNPIXELSPROC glad_glReadnPixels;
-#define glReadnPixels glad_glReadnPixels
-GLAD_API_CALL PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB;
-#define glReadnPixelsARB glad_glReadnPixelsARB
-GLAD_API_CALL PFNGLRECTDPROC glad_glRectd;
-#define glRectd glad_glRectd
-GLAD_API_CALL PFNGLRECTDVPROC glad_glRectdv;
-#define glRectdv glad_glRectdv
-GLAD_API_CALL PFNGLRECTFPROC glad_glRectf;
-#define glRectf glad_glRectf
-GLAD_API_CALL PFNGLRECTFVPROC glad_glRectfv;
-#define glRectfv glad_glRectfv
-GLAD_API_CALL PFNGLRECTIPROC glad_glRecti;
-#define glRecti glad_glRecti
-GLAD_API_CALL PFNGLRECTIVPROC glad_glRectiv;
-#define glRectiv glad_glRectiv
-GLAD_API_CALL PFNGLRECTSPROC glad_glRects;
-#define glRects glad_glRects
-GLAD_API_CALL PFNGLRECTSVPROC glad_glRectsv;
-#define glRectsv glad_glRectsv
-GLAD_API_CALL PFNGLRENDERMODEPROC glad_glRenderMode;
-#define glRenderMode glad_glRenderMode
-GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-#define glRenderbufferStorage glad_glRenderbufferStorage
-GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
-GLAD_API_CALL PFNGLROTATEDPROC glad_glRotated;
-#define glRotated glad_glRotated
-GLAD_API_CALL PFNGLROTATEFPROC glad_glRotatef;
-#define glRotatef glad_glRotatef
-GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-#define glSampleCoverage glad_glSampleCoverage
-GLAD_API_CALL PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-#define glSampleCoverageARB glad_glSampleCoverageARB
-GLAD_API_CALL PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-#define glSampleMaski glad_glSampleMaski
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-#define glSamplerParameterIiv glad_glSamplerParameterIiv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-#define glSamplerParameterf glad_glSamplerParameterf
-GLAD_API_CALL PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-#define glSamplerParameterfv glad_glSamplerParameterfv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-#define glSamplerParameteri glad_glSamplerParameteri
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-#define glSamplerParameteriv glad_glSamplerParameteriv
-GLAD_API_CALL PFNGLSCALEDPROC glad_glScaled;
-#define glScaled glad_glScaled
-GLAD_API_CALL PFNGLSCALEFPROC glad_glScalef;
-#define glScalef glad_glScalef
-GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
-#define glScissor glad_glScissor
-GLAD_API_CALL PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b;
-#define glSecondaryColor3b glad_glSecondaryColor3b
-GLAD_API_CALL PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv;
-#define glSecondaryColor3bv glad_glSecondaryColor3bv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d;
-#define glSecondaryColor3d glad_glSecondaryColor3d
-GLAD_API_CALL PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv;
-#define glSecondaryColor3dv glad_glSecondaryColor3dv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f;
-#define glSecondaryColor3f glad_glSecondaryColor3f
-GLAD_API_CALL PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv;
-#define glSecondaryColor3fv glad_glSecondaryColor3fv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i;
-#define glSecondaryColor3i glad_glSecondaryColor3i
-GLAD_API_CALL PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv;
-#define glSecondaryColor3iv glad_glSecondaryColor3iv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s;
-#define glSecondaryColor3s glad_glSecondaryColor3s
-GLAD_API_CALL PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv;
-#define glSecondaryColor3sv glad_glSecondaryColor3sv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub;
-#define glSecondaryColor3ub glad_glSecondaryColor3ub
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv;
-#define glSecondaryColor3ubv glad_glSecondaryColor3ubv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui;
-#define glSecondaryColor3ui glad_glSecondaryColor3ui
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv;
-#define glSecondaryColor3uiv glad_glSecondaryColor3uiv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us;
-#define glSecondaryColor3us glad_glSecondaryColor3us
-GLAD_API_CALL PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv;
-#define glSecondaryColor3usv glad_glSecondaryColor3usv
-GLAD_API_CALL PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
-GLAD_API_CALL PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
-GLAD_API_CALL PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer;
-#define glSecondaryColorPointer glad_glSecondaryColorPointer
-GLAD_API_CALL PFNGLSELECTBUFFERPROC glad_glSelectBuffer;
-#define glSelectBuffer glad_glSelectBuffer
-GLAD_API_CALL PFNGLSHADEMODELPROC glad_glShadeModel;
-#define glShadeModel glad_glShadeModel
-GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
-#define glShaderSource glad_glShaderSource
-GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-#define glStencilFunc glad_glStencilFunc
-GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-#define glStencilFuncSeparate glad_glStencilFuncSeparate
-GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
-#define glStencilMask glad_glStencilMask
-GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-#define glStencilMaskSeparate glad_glStencilMaskSeparate
-GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
-#define glStencilOp glad_glStencilOp
-GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-#define glStencilOpSeparate glad_glStencilOpSeparate
-GLAD_API_CALL PFNGLTEXBUFFERPROC glad_glTexBuffer;
-#define glTexBuffer glad_glTexBuffer
-GLAD_API_CALL PFNGLTEXCOORD1DPROC glad_glTexCoord1d;
-#define glTexCoord1d glad_glTexCoord1d
-GLAD_API_CALL PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv;
-#define glTexCoord1dv glad_glTexCoord1dv
-GLAD_API_CALL PFNGLTEXCOORD1FPROC glad_glTexCoord1f;
-#define glTexCoord1f glad_glTexCoord1f
-GLAD_API_CALL PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv;
-#define glTexCoord1fv glad_glTexCoord1fv
-GLAD_API_CALL PFNGLTEXCOORD1IPROC glad_glTexCoord1i;
-#define glTexCoord1i glad_glTexCoord1i
-GLAD_API_CALL PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv;
-#define glTexCoord1iv glad_glTexCoord1iv
-GLAD_API_CALL PFNGLTEXCOORD1SPROC glad_glTexCoord1s;
-#define glTexCoord1s glad_glTexCoord1s
-GLAD_API_CALL PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv;
-#define glTexCoord1sv glad_glTexCoord1sv
-GLAD_API_CALL PFNGLTEXCOORD2DPROC glad_glTexCoord2d;
-#define glTexCoord2d glad_glTexCoord2d
-GLAD_API_CALL PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv;
-#define glTexCoord2dv glad_glTexCoord2dv
-GLAD_API_CALL PFNGLTEXCOORD2FPROC glad_glTexCoord2f;
-#define glTexCoord2f glad_glTexCoord2f
-GLAD_API_CALL PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv;
-#define glTexCoord2fv glad_glTexCoord2fv
-GLAD_API_CALL PFNGLTEXCOORD2IPROC glad_glTexCoord2i;
-#define glTexCoord2i glad_glTexCoord2i
-GLAD_API_CALL PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv;
-#define glTexCoord2iv glad_glTexCoord2iv
-GLAD_API_CALL PFNGLTEXCOORD2SPROC glad_glTexCoord2s;
-#define glTexCoord2s glad_glTexCoord2s
-GLAD_API_CALL PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv;
-#define glTexCoord2sv glad_glTexCoord2sv
-GLAD_API_CALL PFNGLTEXCOORD3DPROC glad_glTexCoord3d;
-#define glTexCoord3d glad_glTexCoord3d
-GLAD_API_CALL PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv;
-#define glTexCoord3dv glad_glTexCoord3dv
-GLAD_API_CALL PFNGLTEXCOORD3FPROC glad_glTexCoord3f;
-#define glTexCoord3f glad_glTexCoord3f
-GLAD_API_CALL PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv;
-#define glTexCoord3fv glad_glTexCoord3fv
-GLAD_API_CALL PFNGLTEXCOORD3IPROC glad_glTexCoord3i;
-#define glTexCoord3i glad_glTexCoord3i
-GLAD_API_CALL PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv;
-#define glTexCoord3iv glad_glTexCoord3iv
-GLAD_API_CALL PFNGLTEXCOORD3SPROC glad_glTexCoord3s;
-#define glTexCoord3s glad_glTexCoord3s
-GLAD_API_CALL PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv;
-#define glTexCoord3sv glad_glTexCoord3sv
-GLAD_API_CALL PFNGLTEXCOORD4DPROC glad_glTexCoord4d;
-#define glTexCoord4d glad_glTexCoord4d
-GLAD_API_CALL PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv;
-#define glTexCoord4dv glad_glTexCoord4dv
-GLAD_API_CALL PFNGLTEXCOORD4FPROC glad_glTexCoord4f;
-#define glTexCoord4f glad_glTexCoord4f
-GLAD_API_CALL PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv;
-#define glTexCoord4fv glad_glTexCoord4fv
-GLAD_API_CALL PFNGLTEXCOORD4IPROC glad_glTexCoord4i;
-#define glTexCoord4i glad_glTexCoord4i
-GLAD_API_CALL PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv;
-#define glTexCoord4iv glad_glTexCoord4iv
-GLAD_API_CALL PFNGLTEXCOORD4SPROC glad_glTexCoord4s;
-#define glTexCoord4s glad_glTexCoord4s
-GLAD_API_CALL PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv;
-#define glTexCoord4sv glad_glTexCoord4sv
-GLAD_API_CALL PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-#define glTexCoordP1ui glad_glTexCoordP1ui
-GLAD_API_CALL PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-#define glTexCoordP1uiv glad_glTexCoordP1uiv
-GLAD_API_CALL PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-#define glTexCoordP2ui glad_glTexCoordP2ui
-GLAD_API_CALL PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-#define glTexCoordP2uiv glad_glTexCoordP2uiv
-GLAD_API_CALL PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-#define glTexCoordP3ui glad_glTexCoordP3ui
-GLAD_API_CALL PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-#define glTexCoordP3uiv glad_glTexCoordP3uiv
-GLAD_API_CALL PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-#define glTexCoordP4ui glad_glTexCoordP4ui
-GLAD_API_CALL PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-#define glTexCoordP4uiv glad_glTexCoordP4uiv
-GLAD_API_CALL PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer;
-#define glTexCoordPointer glad_glTexCoordPointer
-GLAD_API_CALL PFNGLTEXENVFPROC glad_glTexEnvf;
-#define glTexEnvf glad_glTexEnvf
-GLAD_API_CALL PFNGLTEXENVFVPROC glad_glTexEnvfv;
-#define glTexEnvfv glad_glTexEnvfv
-GLAD_API_CALL PFNGLTEXENVIPROC glad_glTexEnvi;
-#define glTexEnvi glad_glTexEnvi
-GLAD_API_CALL PFNGLTEXENVIVPROC glad_glTexEnviv;
-#define glTexEnviv glad_glTexEnviv
-GLAD_API_CALL PFNGLTEXGENDPROC glad_glTexGend;
-#define glTexGend glad_glTexGend
-GLAD_API_CALL PFNGLTEXGENDVPROC glad_glTexGendv;
-#define glTexGendv glad_glTexGendv
-GLAD_API_CALL PFNGLTEXGENFPROC glad_glTexGenf;
-#define glTexGenf glad_glTexGenf
-GLAD_API_CALL PFNGLTEXGENFVPROC glad_glTexGenfv;
-#define glTexGenfv glad_glTexGenfv
-GLAD_API_CALL PFNGLTEXGENIPROC glad_glTexGeni;
-#define glTexGeni glad_glTexGeni
-GLAD_API_CALL PFNGLTEXGENIVPROC glad_glTexGeniv;
-#define glTexGeniv glad_glTexGeniv
-GLAD_API_CALL PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-#define glTexImage1D glad_glTexImage1D
-GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-#define glTexImage2D glad_glTexImage2D
-GLAD_API_CALL PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-#define glTexImage2DMultisample glad_glTexImage2DMultisample
-GLAD_API_CALL PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-#define glTexImage3D glad_glTexImage3D
-GLAD_API_CALL PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-#define glTexImage3DMultisample glad_glTexImage3DMultisample
-GLAD_API_CALL PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-#define glTexParameterIiv glad_glTexParameterIiv
-GLAD_API_CALL PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-#define glTexParameterIuiv glad_glTexParameterIuiv
-GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-#define glTexParameterf glad_glTexParameterf
-GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-#define glTexParameterfv glad_glTexParameterfv
-GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-#define glTexParameteri glad_glTexParameteri
-GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-#define glTexParameteriv glad_glTexParameteriv
-GLAD_API_CALL PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-#define glTexSubImage1D glad_glTexSubImage1D
-GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-#define glTexSubImage2D glad_glTexSubImage2D
-GLAD_API_CALL PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-#define glTexSubImage3D glad_glTexSubImage3D
-GLAD_API_CALL PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
-GLAD_API_CALL PFNGLTRANSLATEDPROC glad_glTranslated;
-#define glTranslated glad_glTranslated
-GLAD_API_CALL PFNGLTRANSLATEFPROC glad_glTranslatef;
-#define glTranslatef glad_glTranslatef
-GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
-#define glUniform1f glad_glUniform1f
-GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-#define glUniform1fv glad_glUniform1fv
-GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
-#define glUniform1i glad_glUniform1i
-GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-#define glUniform1iv glad_glUniform1iv
-GLAD_API_CALL PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-#define glUniform1ui glad_glUniform1ui
-GLAD_API_CALL PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-#define glUniform1uiv glad_glUniform1uiv
-GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
-#define glUniform2f glad_glUniform2f
-GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-#define glUniform2fv glad_glUniform2fv
-GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
-#define glUniform2i glad_glUniform2i
-GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-#define glUniform2iv glad_glUniform2iv
-GLAD_API_CALL PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-#define glUniform2ui glad_glUniform2ui
-GLAD_API_CALL PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-#define glUniform2uiv glad_glUniform2uiv
-GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
-#define glUniform3f glad_glUniform3f
-GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-#define glUniform3fv glad_glUniform3fv
-GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
-#define glUniform3i glad_glUniform3i
-GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-#define glUniform3iv glad_glUniform3iv
-GLAD_API_CALL PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-#define glUniform3ui glad_glUniform3ui
-GLAD_API_CALL PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-#define glUniform3uiv glad_glUniform3uiv
-GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
-#define glUniform4f glad_glUniform4f
-GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-#define glUniform4fv glad_glUniform4fv
-GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
-#define glUniform4i glad_glUniform4i
-GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-#define glUniform4iv glad_glUniform4iv
-GLAD_API_CALL PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-#define glUniform4ui glad_glUniform4ui
-GLAD_API_CALL PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-#define glUniform4uiv glad_glUniform4uiv
-GLAD_API_CALL PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-#define glUniformBlockBinding glad_glUniformBlockBinding
-GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-#define glUniformMatrix2fv glad_glUniformMatrix2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-#define glUniformMatrix3fv glad_glUniformMatrix3fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-#define glUniformMatrix4fv glad_glUniformMatrix4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
-GLAD_API_CALL PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-#define glUnmapBuffer glad_glUnmapBuffer
-GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
-#define glUseProgram glad_glUseProgram
-GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-#define glValidateProgram glad_glValidateProgram
-GLAD_API_CALL PFNGLVERTEX2DPROC glad_glVertex2d;
-#define glVertex2d glad_glVertex2d
-GLAD_API_CALL PFNGLVERTEX2DVPROC glad_glVertex2dv;
-#define glVertex2dv glad_glVertex2dv
-GLAD_API_CALL PFNGLVERTEX2FPROC glad_glVertex2f;
-#define glVertex2f glad_glVertex2f
-GLAD_API_CALL PFNGLVERTEX2FVPROC glad_glVertex2fv;
-#define glVertex2fv glad_glVertex2fv
-GLAD_API_CALL PFNGLVERTEX2IPROC glad_glVertex2i;
-#define glVertex2i glad_glVertex2i
-GLAD_API_CALL PFNGLVERTEX2IVPROC glad_glVertex2iv;
-#define glVertex2iv glad_glVertex2iv
-GLAD_API_CALL PFNGLVERTEX2SPROC glad_glVertex2s;
-#define glVertex2s glad_glVertex2s
-GLAD_API_CALL PFNGLVERTEX2SVPROC glad_glVertex2sv;
-#define glVertex2sv glad_glVertex2sv
-GLAD_API_CALL PFNGLVERTEX3DPROC glad_glVertex3d;
-#define glVertex3d glad_glVertex3d
-GLAD_API_CALL PFNGLVERTEX3DVPROC glad_glVertex3dv;
-#define glVertex3dv glad_glVertex3dv
-GLAD_API_CALL PFNGLVERTEX3FPROC glad_glVertex3f;
-#define glVertex3f glad_glVertex3f
-GLAD_API_CALL PFNGLVERTEX3FVPROC glad_glVertex3fv;
-#define glVertex3fv glad_glVertex3fv
-GLAD_API_CALL PFNGLVERTEX3IPROC glad_glVertex3i;
-#define glVertex3i glad_glVertex3i
-GLAD_API_CALL PFNGLVERTEX3IVPROC glad_glVertex3iv;
-#define glVertex3iv glad_glVertex3iv
-GLAD_API_CALL PFNGLVERTEX3SPROC glad_glVertex3s;
-#define glVertex3s glad_glVertex3s
-GLAD_API_CALL PFNGLVERTEX3SVPROC glad_glVertex3sv;
-#define glVertex3sv glad_glVertex3sv
-GLAD_API_CALL PFNGLVERTEX4DPROC glad_glVertex4d;
-#define glVertex4d glad_glVertex4d
-GLAD_API_CALL PFNGLVERTEX4DVPROC glad_glVertex4dv;
-#define glVertex4dv glad_glVertex4dv
-GLAD_API_CALL PFNGLVERTEX4FPROC glad_glVertex4f;
-#define glVertex4f glad_glVertex4f
-GLAD_API_CALL PFNGLVERTEX4FVPROC glad_glVertex4fv;
-#define glVertex4fv glad_glVertex4fv
-GLAD_API_CALL PFNGLVERTEX4IPROC glad_glVertex4i;
-#define glVertex4i glad_glVertex4i
-GLAD_API_CALL PFNGLVERTEX4IVPROC glad_glVertex4iv;
-#define glVertex4iv glad_glVertex4iv
-GLAD_API_CALL PFNGLVERTEX4SPROC glad_glVertex4s;
-#define glVertex4s glad_glVertex4s
-GLAD_API_CALL PFNGLVERTEX4SVPROC glad_glVertex4sv;
-#define glVertex4sv glad_glVertex4sv
-GLAD_API_CALL PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-#define glVertexAttrib1d glad_glVertexAttrib1d
-GLAD_API_CALL PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-#define glVertexAttrib1dv glad_glVertexAttrib1dv
-GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-#define glVertexAttrib1f glad_glVertexAttrib1f
-GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-#define glVertexAttrib1fv glad_glVertexAttrib1fv
-GLAD_API_CALL PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-#define glVertexAttrib1s glad_glVertexAttrib1s
-GLAD_API_CALL PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-#define glVertexAttrib1sv glad_glVertexAttrib1sv
-GLAD_API_CALL PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-#define glVertexAttrib2d glad_glVertexAttrib2d
-GLAD_API_CALL PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-#define glVertexAttrib2dv glad_glVertexAttrib2dv
-GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-#define glVertexAttrib2f glad_glVertexAttrib2f
-GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-#define glVertexAttrib2fv glad_glVertexAttrib2fv
-GLAD_API_CALL PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-#define glVertexAttrib2s glad_glVertexAttrib2s
-GLAD_API_CALL PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-#define glVertexAttrib2sv glad_glVertexAttrib2sv
-GLAD_API_CALL PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-#define glVertexAttrib3d glad_glVertexAttrib3d
-GLAD_API_CALL PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-#define glVertexAttrib3dv glad_glVertexAttrib3dv
-GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-#define glVertexAttrib3f glad_glVertexAttrib3f
-GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-#define glVertexAttrib3fv glad_glVertexAttrib3fv
-GLAD_API_CALL PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-#define glVertexAttrib3s glad_glVertexAttrib3s
-GLAD_API_CALL PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-#define glVertexAttrib3sv glad_glVertexAttrib3sv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
-GLAD_API_CALL PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-#define glVertexAttrib4bv glad_glVertexAttrib4bv
-GLAD_API_CALL PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-#define glVertexAttrib4d glad_glVertexAttrib4d
-GLAD_API_CALL PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-#define glVertexAttrib4dv glad_glVertexAttrib4dv
-GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-#define glVertexAttrib4f glad_glVertexAttrib4f
-GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-#define glVertexAttrib4fv glad_glVertexAttrib4fv
-GLAD_API_CALL PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-#define glVertexAttrib4iv glad_glVertexAttrib4iv
-GLAD_API_CALL PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-#define glVertexAttrib4s glad_glVertexAttrib4s
-GLAD_API_CALL PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-#define glVertexAttrib4sv glad_glVertexAttrib4sv
-GLAD_API_CALL PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
-GLAD_API_CALL PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-#define glVertexAttrib4usv glad_glVertexAttrib4usv
-GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-#define glVertexAttribDivisor glad_glVertexAttribDivisor
-GLAD_API_CALL PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-#define glVertexAttribI1i glad_glVertexAttribI1i
-GLAD_API_CALL PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-#define glVertexAttribI1iv glad_glVertexAttribI1iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-#define glVertexAttribI1ui glad_glVertexAttribI1ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-#define glVertexAttribI2i glad_glVertexAttribI2i
-GLAD_API_CALL PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-#define glVertexAttribI2iv glad_glVertexAttribI2iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-#define glVertexAttribI2ui glad_glVertexAttribI2ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-#define glVertexAttribI3i glad_glVertexAttribI3i
-GLAD_API_CALL PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-#define glVertexAttribI3iv glad_glVertexAttribI3iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-#define glVertexAttribI3ui glad_glVertexAttribI3ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-#define glVertexAttribI4bv glad_glVertexAttribI4bv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-#define glVertexAttribI4i glad_glVertexAttribI4i
-GLAD_API_CALL PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-#define glVertexAttribI4iv glad_glVertexAttribI4iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-#define glVertexAttribI4sv glad_glVertexAttribI4sv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-#define glVertexAttribI4ui glad_glVertexAttribI4ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-#define glVertexAttribI4usv glad_glVertexAttribI4usv
-GLAD_API_CALL PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-#define glVertexAttribIPointer glad_glVertexAttribIPointer
-GLAD_API_CALL PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-#define glVertexAttribP1ui glad_glVertexAttribP1ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-#define glVertexAttribP2ui glad_glVertexAttribP2ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-#define glVertexAttribP3ui glad_glVertexAttribP3ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-#define glVertexAttribP4ui glad_glVertexAttribP4ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-#define glVertexAttribPointer glad_glVertexAttribPointer
-GLAD_API_CALL PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-#define glVertexP2ui glad_glVertexP2ui
-GLAD_API_CALL PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-#define glVertexP2uiv glad_glVertexP2uiv
-GLAD_API_CALL PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-#define glVertexP3ui glad_glVertexP3ui
-GLAD_API_CALL PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-#define glVertexP3uiv glad_glVertexP3uiv
-GLAD_API_CALL PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-#define glVertexP4ui glad_glVertexP4ui
-GLAD_API_CALL PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-#define glVertexP4uiv glad_glVertexP4uiv
-GLAD_API_CALL PFNGLVERTEXPOINTERPROC glad_glVertexPointer;
-#define glVertexPointer glad_glVertexPointer
-GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
-#define glViewport glad_glViewport
-GLAD_API_CALL PFNGLWAITSYNCPROC glad_glWaitSync;
-#define glWaitSync glad_glWaitSync
-GLAD_API_CALL PFNGLWINDOWPOS2DPROC glad_glWindowPos2d;
-#define glWindowPos2d glad_glWindowPos2d
-GLAD_API_CALL PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv;
-#define glWindowPos2dv glad_glWindowPos2dv
-GLAD_API_CALL PFNGLWINDOWPOS2FPROC glad_glWindowPos2f;
-#define glWindowPos2f glad_glWindowPos2f
-GLAD_API_CALL PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv;
-#define glWindowPos2fv glad_glWindowPos2fv
-GLAD_API_CALL PFNGLWINDOWPOS2IPROC glad_glWindowPos2i;
-#define glWindowPos2i glad_glWindowPos2i
-GLAD_API_CALL PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv;
-#define glWindowPos2iv glad_glWindowPos2iv
-GLAD_API_CALL PFNGLWINDOWPOS2SPROC glad_glWindowPos2s;
-#define glWindowPos2s glad_glWindowPos2s
-GLAD_API_CALL PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv;
-#define glWindowPos2sv glad_glWindowPos2sv
-GLAD_API_CALL PFNGLWINDOWPOS3DPROC glad_glWindowPos3d;
-#define glWindowPos3d glad_glWindowPos3d
-GLAD_API_CALL PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv;
-#define glWindowPos3dv glad_glWindowPos3dv
-GLAD_API_CALL PFNGLWINDOWPOS3FPROC glad_glWindowPos3f;
-#define glWindowPos3f glad_glWindowPos3f
-GLAD_API_CALL PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv;
-#define glWindowPos3fv glad_glWindowPos3fv
-GLAD_API_CALL PFNGLWINDOWPOS3IPROC glad_glWindowPos3i;
-#define glWindowPos3i glad_glWindowPos3i
-GLAD_API_CALL PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv;
-#define glWindowPos3iv glad_glWindowPos3iv
-GLAD_API_CALL PFNGLWINDOWPOS3SPROC glad_glWindowPos3s;
-#define glWindowPos3s glad_glWindowPos3s
-GLAD_API_CALL PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv;
-#define glWindowPos3sv glad_glWindowPos3sv
-
-
-GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr);
-GLAD_API_CALL int gladLoadGL( GLADloadfunc load);
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/raylib/external/glfw/deps/glad/khrplatform.h b/raylib/external/glfw/deps/glad/khrplatform.h
deleted file mode 100644 (file)
index 975bbff..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-#ifndef __khrplatform_h_
-#define __khrplatform_h_
-
-/*
-** Copyright (c) 2008-2018 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-/* Khronos platform-specific types and definitions.
- *
- * The master copy of khrplatform.h is maintained in the Khronos EGL
- * Registry repository at https://github.com/KhronosGroup/EGL-Registry
- * The last semantic modification to khrplatform.h was at commit ID:
- *      67a3e0864c2d75ea5287b9f3d2eb74a745936692
- *
- * Adopters may modify this file to suit their platform. Adopters are
- * encouraged to submit platform specific modifications to the Khronos
- * group so that they can be included in future versions of this file.
- * Please submit changes by filing pull requests or issues on
- * the EGL Registry repository linked above.
- *
- *
- * See the Implementer's Guidelines for information about where this file
- * should be located on your system and for more details of its use:
- *    http://www.khronos.org/registry/implementers_guide.pdf
- *
- * This file should be included as
- *        #include <KHR/khrplatform.h>
- * by Khronos client API header files that use its types and defines.
- *
- * The types in khrplatform.h should only be used to define API-specific types.
- *
- * Types defined in khrplatform.h:
- *    khronos_int8_t              signed   8  bit
- *    khronos_uint8_t             unsigned 8  bit
- *    khronos_int16_t             signed   16 bit
- *    khronos_uint16_t            unsigned 16 bit
- *    khronos_int32_t             signed   32 bit
- *    khronos_uint32_t            unsigned 32 bit
- *    khronos_int64_t             signed   64 bit
- *    khronos_uint64_t            unsigned 64 bit
- *    khronos_intptr_t            signed   same number of bits as a pointer
- *    khronos_uintptr_t           unsigned same number of bits as a pointer
- *    khronos_ssize_t             signed   size
- *    khronos_usize_t             unsigned size
- *    khronos_float_t             signed   32 bit floating point
- *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
- *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
- *                                         nanoseconds
- *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
- *    khronos_boolean_enum_t      enumerated boolean type. This should
- *      only be used as a base type when a client API's boolean type is
- *      an enum. Client APIs which use an integer or other type for
- *      booleans cannot use this as the base type for their boolean.
- *
- * Tokens defined in khrplatform.h:
- *
- *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
- *
- *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
- *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
- *
- * Calling convention macros defined in this file:
- *    KHRONOS_APICALL
- *    KHRONOS_APIENTRY
- *    KHRONOS_APIATTRIBUTES
- *
- * These may be used in function prototypes as:
- *
- *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
- *                                  int arg1,
- *                                  int arg2) KHRONOS_APIATTRIBUTES;
- */
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APICALL
- *-------------------------------------------------------------------------
- * This precedes the return type of the function in the function prototype.
- */
-#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
-#   define KHRONOS_APICALL __declspec(dllimport)
-#elif defined (__SYMBIAN32__)
-#   define KHRONOS_APICALL IMPORT_C
-#elif defined(__ANDROID__)
-#   define KHRONOS_APICALL __attribute__((visibility("default")))
-#else
-#   define KHRONOS_APICALL
-#endif
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APIENTRY
- *-------------------------------------------------------------------------
- * This follows the return type of the function  and precedes the function
- * name in the function prototype.
- */
-#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
-    /* Win32 but not WinCE */
-#   define KHRONOS_APIENTRY __stdcall
-#else
-#   define KHRONOS_APIENTRY
-#endif
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APIATTRIBUTES
- *-------------------------------------------------------------------------
- * This follows the closing parenthesis of the function prototype arguments.
- */
-#if defined (__ARMCC_2__)
-#define KHRONOS_APIATTRIBUTES __softfp
-#else
-#define KHRONOS_APIATTRIBUTES
-#endif
-
-/*-------------------------------------------------------------------------
- * basic type definitions
- *-----------------------------------------------------------------------*/
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
-
-
-/*
- * Using <stdint.h>
- */
-#include <stdint.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(__VMS ) || defined(__sgi)
-
-/*
- * Using <inttypes.h>
- */
-#include <inttypes.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
-
-/*
- * Win32
- */
-typedef __int32                 khronos_int32_t;
-typedef unsigned __int32        khronos_uint32_t;
-typedef __int64                 khronos_int64_t;
-typedef unsigned __int64        khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(__sun__) || defined(__digital__)
-
-/*
- * Sun or Digital
- */
-typedef int                     khronos_int32_t;
-typedef unsigned int            khronos_uint32_t;
-#if defined(__arch64__) || defined(_LP64)
-typedef long int                khronos_int64_t;
-typedef unsigned long int       khronos_uint64_t;
-#else
-typedef long long int           khronos_int64_t;
-typedef unsigned long long int  khronos_uint64_t;
-#endif /* __arch64__ */
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif 0
-
-/*
- * Hypothetical platform with no float or int64 support
- */
-typedef int                     khronos_int32_t;
-typedef unsigned int            khronos_uint32_t;
-#define KHRONOS_SUPPORT_INT64   0
-#define KHRONOS_SUPPORT_FLOAT   0
-
-#else
-
-/*
- * Generic fallback
- */
-#include <stdint.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#endif
-
-
-/*
- * Types that are (so far) the same on all platforms
- */
-typedef signed   char          khronos_int8_t;
-typedef unsigned char          khronos_uint8_t;
-typedef signed   short int     khronos_int16_t;
-typedef unsigned short int     khronos_uint16_t;
-
-/*
- * Types that differ between LLP64 and LP64 architectures - in LLP64,
- * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
- * to be the only LLP64 architecture in current use.
- */
-#ifdef _WIN64
-typedef signed   long long int khronos_intptr_t;
-typedef unsigned long long int khronos_uintptr_t;
-typedef signed   long long int khronos_ssize_t;
-typedef unsigned long long int khronos_usize_t;
-#else
-typedef signed   long  int     khronos_intptr_t;
-typedef unsigned long  int     khronos_uintptr_t;
-typedef signed   long  int     khronos_ssize_t;
-typedef unsigned long  int     khronos_usize_t;
-#endif
-
-#if KHRONOS_SUPPORT_FLOAT
-/*
- * Float type
- */
-typedef          float         khronos_float_t;
-#endif
-
-#if KHRONOS_SUPPORT_INT64
-/* Time types
- *
- * These types can be used to represent a time interval in nanoseconds or
- * an absolute Unadjusted System Time.  Unadjusted System Time is the number
- * of nanoseconds since some arbitrary system event (e.g. since the last
- * time the system booted).  The Unadjusted System Time is an unsigned
- * 64 bit value that wraps back to 0 every 584 years.  Time intervals
- * may be either signed or unsigned.
- */
-typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
-typedef khronos_int64_t        khronos_stime_nanoseconds_t;
-#endif
-
-/*
- * Dummy value used to pad enum types to 32 bits.
- */
-#ifndef KHRONOS_MAX_ENUM
-#define KHRONOS_MAX_ENUM 0x7FFFFFFF
-#endif
-
-/*
- * Enumerated boolean type
- *
- * Values other than zero should be considered to be true.  Therefore
- * comparisons should not be made against KHRONOS_TRUE.
- */
-typedef enum {
-    KHRONOS_FALSE = 0,
-    KHRONOS_TRUE  = 1,
-    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
-} khronos_boolean_enum_t;
-
-#endif /* __khrplatform_h_ */
diff --git a/raylib/external/glfw/deps/glad/vk_platform.h b/raylib/external/glfw/deps/glad/vk_platform.h
deleted file mode 100644 (file)
index d7d22e1..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* */
-/* File: vk_platform.h */
-/* */
-/*
-** Copyright (c) 2014-2017 The Khronos Group Inc.
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-
-#ifndef VK_PLATFORM_H_
-#define VK_PLATFORM_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
-***************************************************************************************************
-*   Platform-specific directives and type declarations
-***************************************************************************************************
-*/
-
-/* Platform-specific calling convention macros.
- *
- * Platforms should define these so that Vulkan clients call Vulkan commands
- * with the same calling conventions that the Vulkan implementation expects.
- *
- * VKAPI_ATTR - Placed before the return type in function declarations.
- *              Useful for C++11 and GCC/Clang-style function attribute syntax.
- * VKAPI_CALL - Placed after the return type in function declarations.
- *              Useful for MSVC-style calling convention syntax.
- * VKAPI_PTR  - Placed between the '(' and '*' in function pointer types.
- *
- * Function declaration:  VKAPI_ATTR void VKAPI_CALL vkCommand(void);
- * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
- */
-#if defined(_WIN32)
-    /* On Windows, Vulkan commands use the stdcall convention */
-    #define VKAPI_ATTR
-    #define VKAPI_CALL __stdcall
-    #define VKAPI_PTR  VKAPI_CALL
-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
-    #error "Vulkan isn't supported for the 'armeabi' NDK ABI"
-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
-    /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */
-    /* calling convention, i.e. float parameters are passed in registers. This */
-    /* is true even if the rest of the application passes floats on the stack, */
-    /* as it does by default when compiling for the armeabi-v7a NDK ABI. */
-    #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
-    #define VKAPI_CALL
-    #define VKAPI_PTR  VKAPI_ATTR
-#else
-    /* On other platforms, use the default calling convention */
-    #define VKAPI_ATTR
-    #define VKAPI_CALL
-    #define VKAPI_PTR
-#endif
-
-#include <stddef.h>
-
-#if !defined(VK_NO_STDINT_H)
-    #if defined(_MSC_VER) && (_MSC_VER < 1600)
-        typedef signed   __int8  int8_t;
-        typedef unsigned __int8  uint8_t;
-        typedef signed   __int16 int16_t;
-        typedef unsigned __int16 uint16_t;
-        typedef signed   __int32 int32_t;
-        typedef unsigned __int32 uint32_t;
-        typedef signed   __int64 int64_t;
-        typedef unsigned __int64 uint64_t;
-    #else
-        #include <stdint.h>
-    #endif
-#endif /* !defined(VK_NO_STDINT_H) */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* __cplusplus */
-
-#endif
diff --git a/raylib/external/glfw/deps/glad/vulkan.h b/raylib/external/glfw/deps/glad/vulkan.h
deleted file mode 100644 (file)
index 6bace71..0000000
+++ /dev/null
@@ -1,3480 +0,0 @@
-/**
- * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:38 2019
- *
- * Generator: C/C++
- * Specification: vk
- * Extensions: 3
- *
- * APIs:
- *  - vulkan=1.1
- *
- * Options:
- *  - MX_GLOBAL = False
- *  - LOADER = False
- *  - ALIAS = False
- *  - HEADER_ONLY = False
- *  - DEBUG = False
- *  - MX = False
- *
- * Commandline:
- *    --api='vulkan=1.1' --extensions='VK_EXT_debug_report,VK_KHR_surface,VK_KHR_swapchain' c
- *
- * Online:
- *    http://glad.sh/#api=vulkan%3D1.1&extensions=VK_EXT_debug_report%2CVK_KHR_surface%2CVK_KHR_swapchain&generator=c&options=
- *
- */
-
-#ifndef GLAD_VULKAN_H_
-#define GLAD_VULKAN_H_
-
-#ifdef VULKAN_H_
-    #error  header already included (API: vulkan), remove previous include!
-#endif
-#define VULKAN_H_ 1
-
-#ifdef VULKAN_CORE_H_
-    #error  header already included (API: vulkan), remove previous include!
-#endif
-#define VULKAN_CORE_H_ 1
-
-
-#define GLAD_VULKAN
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GLAD_PLATFORM_H_
-#define GLAD_PLATFORM_H_
-
-#ifndef GLAD_PLATFORM_WIN32
-  #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
-    #define GLAD_PLATFORM_WIN32 1
-  #else
-    #define GLAD_PLATFORM_WIN32 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_APPLE
-  #ifdef __APPLE__
-    #define GLAD_PLATFORM_APPLE 1
-  #else
-    #define GLAD_PLATFORM_APPLE 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_EMSCRIPTEN
-  #ifdef __EMSCRIPTEN__
-    #define GLAD_PLATFORM_EMSCRIPTEN 1
-  #else
-    #define GLAD_PLATFORM_EMSCRIPTEN 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_UWP
-  #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
-    #ifdef __has_include
-      #if __has_include(<winapifamily.h>)
-        #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-      #endif
-    #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
-      #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-    #endif
-  #endif
-
-  #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
-    #include <winapifamily.h>
-    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
-      #define GLAD_PLATFORM_UWP 1
-    #endif
-  #endif
-
-  #ifndef GLAD_PLATFORM_UWP
-    #define GLAD_PLATFORM_UWP 0
-  #endif
-#endif
-
-#ifdef __GNUC__
-  #define GLAD_GNUC_EXTENSION __extension__
-#else
-  #define GLAD_GNUC_EXTENSION
-#endif
-
-#ifndef GLAD_API_CALL
-  #if defined(GLAD_API_CALL_EXPORT)
-    #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
-      #if defined(GLAD_API_CALL_EXPORT_BUILD)
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllexport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllexport) extern
-        #endif
-      #else
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllimport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllimport) extern
-        #endif
-      #endif
-    #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
-      #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
-    #else
-      #define GLAD_API_CALL extern
-    #endif
-  #else
-    #define GLAD_API_CALL extern
-  #endif
-#endif
-
-#ifdef APIENTRY
-  #define GLAD_API_PTR APIENTRY
-#elif GLAD_PLATFORM_WIN32
-  #define GLAD_API_PTR __stdcall
-#else
-  #define GLAD_API_PTR
-#endif
-
-#ifndef GLAPI
-#define GLAPI GLAD_API_CALL
-#endif
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY GLAD_API_PTR
-#endif
-
-
-#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
-#define GLAD_VERSION_MAJOR(version) (version / 10000)
-#define GLAD_VERSION_MINOR(version) (version % 10000)
-
-typedef void (*GLADapiproc)(void);
-
-typedef GLADapiproc (*GLADloadfunc)(const char *name);
-typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr);
-
-typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
-typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
-
-#endif /* GLAD_PLATFORM_H_ */
-
-#define VK_ATTACHMENT_UNUSED (~0U)
-#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report"
-#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 9
-#define VK_FALSE 0
-#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
-#define VK_KHR_SURFACE_SPEC_VERSION 25
-#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain"
-#define VK_KHR_SWAPCHAIN_SPEC_VERSION 70
-#define VK_LOD_CLAMP_NONE 1000.0f
-#define VK_LUID_SIZE 8
-#define VK_MAX_DESCRIPTION_SIZE 256
-#define VK_MAX_DEVICE_GROUP_SIZE 32
-#define VK_MAX_EXTENSION_NAME_SIZE 256
-#define VK_MAX_MEMORY_HEAPS 16
-#define VK_MAX_MEMORY_TYPES 32
-#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256
-#define VK_QUEUE_FAMILY_EXTERNAL (~0U-1)
-#define VK_QUEUE_FAMILY_IGNORED (~0U)
-#define VK_REMAINING_ARRAY_LAYERS (~0U)
-#define VK_REMAINING_MIP_LEVELS (~0U)
-#define VK_SUBPASS_EXTERNAL (~0U)
-#define VK_TRUE 1
-#define VK_UUID_SIZE 16
-#define VK_WHOLE_SIZE (~0ULL)
-
-
-#include <glad/vk_platform.h>
-#define VK_MAKE_VERSION(major, minor, patch) \
-    (((major) << 22) | ((minor) << 12) | (patch))
-#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
-#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
-#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
-/* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */
-/*#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 */
-/* Vulkan 1.0 version number */
-#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)/* Patch version should always be set to 0 */
-/* Vulkan 1.1 version number */
-#define VK_API_VERSION_1_1 VK_MAKE_VERSION(1, 1, 0)/* Patch version should always be set to 0 */
-/* Version of this file */
-#define VK_HEADER_VERSION 106
-#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
-#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE)
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
-#else
-        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
-#endif
-#endif
-#define VK_NULL_HANDLE 0
-
-
-
-
-
-
-
-
-VK_DEFINE_HANDLE(VkInstance)
-VK_DEFINE_HANDLE(VkPhysicalDevice)
-VK_DEFINE_HANDLE(VkDevice)
-VK_DEFINE_HANDLE(VkQueue)
-VK_DEFINE_HANDLE(VkCommandBuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT)
-typedef enum VkAttachmentLoadOp {
-    VK_ATTACHMENT_LOAD_OP_LOAD = 0,
-    VK_ATTACHMENT_LOAD_OP_CLEAR = 1,
-    VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2
-} VkAttachmentLoadOp;
-typedef enum VkAttachmentStoreOp {
-    VK_ATTACHMENT_STORE_OP_STORE = 0,
-    VK_ATTACHMENT_STORE_OP_DONT_CARE = 1
-} VkAttachmentStoreOp;
-typedef enum VkBlendFactor {
-    VK_BLEND_FACTOR_ZERO = 0,
-    VK_BLEND_FACTOR_ONE = 1,
-    VK_BLEND_FACTOR_SRC_COLOR = 2,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3,
-    VK_BLEND_FACTOR_DST_COLOR = 4,
-    VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5,
-    VK_BLEND_FACTOR_SRC_ALPHA = 6,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7,
-    VK_BLEND_FACTOR_DST_ALPHA = 8,
-    VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9,
-    VK_BLEND_FACTOR_CONSTANT_COLOR = 10,
-    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
-    VK_BLEND_FACTOR_CONSTANT_ALPHA = 12,
-    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
-    VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14,
-    VK_BLEND_FACTOR_SRC1_COLOR = 15,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16,
-    VK_BLEND_FACTOR_SRC1_ALPHA = 17,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18
-} VkBlendFactor;
-typedef enum VkBlendOp {
-    VK_BLEND_OP_ADD = 0,
-    VK_BLEND_OP_SUBTRACT = 1,
-    VK_BLEND_OP_REVERSE_SUBTRACT = 2,
-    VK_BLEND_OP_MIN = 3,
-    VK_BLEND_OP_MAX = 4
-} VkBlendOp;
-typedef enum VkBorderColor {
-    VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0,
-    VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1,
-    VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2,
-    VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3,
-    VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4,
-    VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5
-} VkBorderColor;
-
-typedef enum VkPipelineCacheHeaderVersion {
-    VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1
-} VkPipelineCacheHeaderVersion;
-
-typedef enum VkDeviceQueueCreateFlagBits {
-    VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 1
-} VkDeviceQueueCreateFlagBits;
-typedef enum VkBufferCreateFlagBits {
-    VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 1,
-    VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 2,
-    VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 4,
-    VK_BUFFER_CREATE_PROTECTED_BIT = 8
-} VkBufferCreateFlagBits;
-typedef enum VkBufferUsageFlagBits {
-    VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 1,
-    VK_BUFFER_USAGE_TRANSFER_DST_BIT = 2,
-    VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 4,
-    VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 8,
-    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 16,
-    VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 32,
-    VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 64,
-    VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 128,
-    VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 256
-} VkBufferUsageFlagBits;
-typedef enum VkColorComponentFlagBits {
-    VK_COLOR_COMPONENT_R_BIT = 1,
-    VK_COLOR_COMPONENT_G_BIT = 2,
-    VK_COLOR_COMPONENT_B_BIT = 4,
-    VK_COLOR_COMPONENT_A_BIT = 8
-} VkColorComponentFlagBits;
-typedef enum VkComponentSwizzle {
-    VK_COMPONENT_SWIZZLE_IDENTITY = 0,
-    VK_COMPONENT_SWIZZLE_ZERO = 1,
-    VK_COMPONENT_SWIZZLE_ONE = 2,
-    VK_COMPONENT_SWIZZLE_R = 3,
-    VK_COMPONENT_SWIZZLE_G = 4,
-    VK_COMPONENT_SWIZZLE_B = 5,
-    VK_COMPONENT_SWIZZLE_A = 6
-} VkComponentSwizzle;
-typedef enum VkCommandPoolCreateFlagBits {
-    VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 1,
-    VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 2,
-    VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 4
-} VkCommandPoolCreateFlagBits;
-typedef enum VkCommandPoolResetFlagBits {
-    VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 1
-} VkCommandPoolResetFlagBits;
-typedef enum VkCommandBufferResetFlagBits {
-    VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 1
-} VkCommandBufferResetFlagBits;
-typedef enum VkCommandBufferLevel {
-    VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0,
-    VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1
-} VkCommandBufferLevel;
-typedef enum VkCommandBufferUsageFlagBits {
-    VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 1,
-    VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 2,
-    VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 4
-} VkCommandBufferUsageFlagBits;
-typedef enum VkCompareOp {
-    VK_COMPARE_OP_NEVER = 0,
-    VK_COMPARE_OP_LESS = 1,
-    VK_COMPARE_OP_EQUAL = 2,
-    VK_COMPARE_OP_LESS_OR_EQUAL = 3,
-    VK_COMPARE_OP_GREATER = 4,
-    VK_COMPARE_OP_NOT_EQUAL = 5,
-    VK_COMPARE_OP_GREATER_OR_EQUAL = 6,
-    VK_COMPARE_OP_ALWAYS = 7
-} VkCompareOp;
-typedef enum VkCullModeFlagBits {
-    VK_CULL_MODE_NONE = 0,
-    VK_CULL_MODE_FRONT_BIT = 1,
-    VK_CULL_MODE_BACK_BIT = 2,
-    VK_CULL_MODE_FRONT_AND_BACK = 0x00000003
-} VkCullModeFlagBits;
-typedef enum VkDescriptorType {
-    VK_DESCRIPTOR_TYPE_SAMPLER = 0,
-    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
-    VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2,
-    VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3,
-    VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4,
-    VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5,
-    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6,
-    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7,
-    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8,
-    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9,
-    VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10
-} VkDescriptorType;
-typedef enum VkDynamicState {
-    VK_DYNAMIC_STATE_VIEWPORT = 0,
-    VK_DYNAMIC_STATE_SCISSOR = 1,
-    VK_DYNAMIC_STATE_LINE_WIDTH = 2,
-    VK_DYNAMIC_STATE_DEPTH_BIAS = 3,
-    VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
-    VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
-    VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
-    VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
-    VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
-    VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1)
-} VkDynamicState;
-typedef enum VkFenceCreateFlagBits {
-    VK_FENCE_CREATE_SIGNALED_BIT = 1
-} VkFenceCreateFlagBits;
-typedef enum VkPolygonMode {
-    VK_POLYGON_MODE_FILL = 0,
-    VK_POLYGON_MODE_LINE = 1,
-    VK_POLYGON_MODE_POINT = 2
-} VkPolygonMode;
-typedef enum VkFormat {
-    VK_FORMAT_UNDEFINED = 0,
-    VK_FORMAT_R4G4_UNORM_PACK8 = 1,
-    VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
-    VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3,
-    VK_FORMAT_R5G6B5_UNORM_PACK16 = 4,
-    VK_FORMAT_B5G6R5_UNORM_PACK16 = 5,
-    VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6,
-    VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7,
-    VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8,
-    VK_FORMAT_R8_UNORM = 9,
-    VK_FORMAT_R8_SNORM = 10,
-    VK_FORMAT_R8_USCALED = 11,
-    VK_FORMAT_R8_SSCALED = 12,
-    VK_FORMAT_R8_UINT = 13,
-    VK_FORMAT_R8_SINT = 14,
-    VK_FORMAT_R8_SRGB = 15,
-    VK_FORMAT_R8G8_UNORM = 16,
-    VK_FORMAT_R8G8_SNORM = 17,
-    VK_FORMAT_R8G8_USCALED = 18,
-    VK_FORMAT_R8G8_SSCALED = 19,
-    VK_FORMAT_R8G8_UINT = 20,
-    VK_FORMAT_R8G8_SINT = 21,
-    VK_FORMAT_R8G8_SRGB = 22,
-    VK_FORMAT_R8G8B8_UNORM = 23,
-    VK_FORMAT_R8G8B8_SNORM = 24,
-    VK_FORMAT_R8G8B8_USCALED = 25,
-    VK_FORMAT_R8G8B8_SSCALED = 26,
-    VK_FORMAT_R8G8B8_UINT = 27,
-    VK_FORMAT_R8G8B8_SINT = 28,
-    VK_FORMAT_R8G8B8_SRGB = 29,
-    VK_FORMAT_B8G8R8_UNORM = 30,
-    VK_FORMAT_B8G8R8_SNORM = 31,
-    VK_FORMAT_B8G8R8_USCALED = 32,
-    VK_FORMAT_B8G8R8_SSCALED = 33,
-    VK_FORMAT_B8G8R8_UINT = 34,
-    VK_FORMAT_B8G8R8_SINT = 35,
-    VK_FORMAT_B8G8R8_SRGB = 36,
-    VK_FORMAT_R8G8B8A8_UNORM = 37,
-    VK_FORMAT_R8G8B8A8_SNORM = 38,
-    VK_FORMAT_R8G8B8A8_USCALED = 39,
-    VK_FORMAT_R8G8B8A8_SSCALED = 40,
-    VK_FORMAT_R8G8B8A8_UINT = 41,
-    VK_FORMAT_R8G8B8A8_SINT = 42,
-    VK_FORMAT_R8G8B8A8_SRGB = 43,
-    VK_FORMAT_B8G8R8A8_UNORM = 44,
-    VK_FORMAT_B8G8R8A8_SNORM = 45,
-    VK_FORMAT_B8G8R8A8_USCALED = 46,
-    VK_FORMAT_B8G8R8A8_SSCALED = 47,
-    VK_FORMAT_B8G8R8A8_UINT = 48,
-    VK_FORMAT_B8G8R8A8_SINT = 49,
-    VK_FORMAT_B8G8R8A8_SRGB = 50,
-    VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51,
-    VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52,
-    VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53,
-    VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54,
-    VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55,
-    VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56,
-    VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57,
-    VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58,
-    VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59,
-    VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60,
-    VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61,
-    VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62,
-    VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63,
-    VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64,
-    VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65,
-    VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66,
-    VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67,
-    VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68,
-    VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69,
-    VK_FORMAT_R16_UNORM = 70,
-    VK_FORMAT_R16_SNORM = 71,
-    VK_FORMAT_R16_USCALED = 72,
-    VK_FORMAT_R16_SSCALED = 73,
-    VK_FORMAT_R16_UINT = 74,
-    VK_FORMAT_R16_SINT = 75,
-    VK_FORMAT_R16_SFLOAT = 76,
-    VK_FORMAT_R16G16_UNORM = 77,
-    VK_FORMAT_R16G16_SNORM = 78,
-    VK_FORMAT_R16G16_USCALED = 79,
-    VK_FORMAT_R16G16_SSCALED = 80,
-    VK_FORMAT_R16G16_UINT = 81,
-    VK_FORMAT_R16G16_SINT = 82,
-    VK_FORMAT_R16G16_SFLOAT = 83,
-    VK_FORMAT_R16G16B16_UNORM = 84,
-    VK_FORMAT_R16G16B16_SNORM = 85,
-    VK_FORMAT_R16G16B16_USCALED = 86,
-    VK_FORMAT_R16G16B16_SSCALED = 87,
-    VK_FORMAT_R16G16B16_UINT = 88,
-    VK_FORMAT_R16G16B16_SINT = 89,
-    VK_FORMAT_R16G16B16_SFLOAT = 90,
-    VK_FORMAT_R16G16B16A16_UNORM = 91,
-    VK_FORMAT_R16G16B16A16_SNORM = 92,
-    VK_FORMAT_R16G16B16A16_USCALED = 93,
-    VK_FORMAT_R16G16B16A16_SSCALED = 94,
-    VK_FORMAT_R16G16B16A16_UINT = 95,
-    VK_FORMAT_R16G16B16A16_SINT = 96,
-    VK_FORMAT_R16G16B16A16_SFLOAT = 97,
-    VK_FORMAT_R32_UINT = 98,
-    VK_FORMAT_R32_SINT = 99,
-    VK_FORMAT_R32_SFLOAT = 100,
-    VK_FORMAT_R32G32_UINT = 101,
-    VK_FORMAT_R32G32_SINT = 102,
-    VK_FORMAT_R32G32_SFLOAT = 103,
-    VK_FORMAT_R32G32B32_UINT = 104,
-    VK_FORMAT_R32G32B32_SINT = 105,
-    VK_FORMAT_R32G32B32_SFLOAT = 106,
-    VK_FORMAT_R32G32B32A32_UINT = 107,
-    VK_FORMAT_R32G32B32A32_SINT = 108,
-    VK_FORMAT_R32G32B32A32_SFLOAT = 109,
-    VK_FORMAT_R64_UINT = 110,
-    VK_FORMAT_R64_SINT = 111,
-    VK_FORMAT_R64_SFLOAT = 112,
-    VK_FORMAT_R64G64_UINT = 113,
-    VK_FORMAT_R64G64_SINT = 114,
-    VK_FORMAT_R64G64_SFLOAT = 115,
-    VK_FORMAT_R64G64B64_UINT = 116,
-    VK_FORMAT_R64G64B64_SINT = 117,
-    VK_FORMAT_R64G64B64_SFLOAT = 118,
-    VK_FORMAT_R64G64B64A64_UINT = 119,
-    VK_FORMAT_R64G64B64A64_SINT = 120,
-    VK_FORMAT_R64G64B64A64_SFLOAT = 121,
-    VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122,
-    VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123,
-    VK_FORMAT_D16_UNORM = 124,
-    VK_FORMAT_X8_D24_UNORM_PACK32 = 125,
-    VK_FORMAT_D32_SFLOAT = 126,
-    VK_FORMAT_S8_UINT = 127,
-    VK_FORMAT_D16_UNORM_S8_UINT = 128,
-    VK_FORMAT_D24_UNORM_S8_UINT = 129,
-    VK_FORMAT_D32_SFLOAT_S8_UINT = 130,
-    VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131,
-    VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132,
-    VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133,
-    VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134,
-    VK_FORMAT_BC2_UNORM_BLOCK = 135,
-    VK_FORMAT_BC2_SRGB_BLOCK = 136,
-    VK_FORMAT_BC3_UNORM_BLOCK = 137,
-    VK_FORMAT_BC3_SRGB_BLOCK = 138,
-    VK_FORMAT_BC4_UNORM_BLOCK = 139,
-    VK_FORMAT_BC4_SNORM_BLOCK = 140,
-    VK_FORMAT_BC5_UNORM_BLOCK = 141,
-    VK_FORMAT_BC5_SNORM_BLOCK = 142,
-    VK_FORMAT_BC6H_UFLOAT_BLOCK = 143,
-    VK_FORMAT_BC6H_SFLOAT_BLOCK = 144,
-    VK_FORMAT_BC7_UNORM_BLOCK = 145,
-    VK_FORMAT_BC7_SRGB_BLOCK = 146,
-    VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147,
-    VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148,
-    VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149,
-    VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150,
-    VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151,
-    VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152,
-    VK_FORMAT_EAC_R11_UNORM_BLOCK = 153,
-    VK_FORMAT_EAC_R11_SNORM_BLOCK = 154,
-    VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155,
-    VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156,
-    VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157,
-    VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158,
-    VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159,
-    VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160,
-    VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161,
-    VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162,
-    VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163,
-    VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164,
-    VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165,
-    VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166,
-    VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167,
-    VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168,
-    VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169,
-    VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170,
-    VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171,
-    VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172,
-    VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173,
-    VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174,
-    VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175,
-    VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176,
-    VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177,
-    VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178,
-    VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179,
-    VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180,
-    VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181,
-    VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182,
-    VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183,
-    VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184,
-    VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000,
-    VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001,
-    VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002,
-    VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003,
-    VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004,
-    VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005,
-    VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006,
-    VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007,
-    VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008,
-    VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009,
-    VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010,
-    VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012,
-    VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014,
-    VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016,
-    VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017,
-    VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018,
-    VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019,
-    VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020,
-    VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022,
-    VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024,
-    VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026,
-    VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027,
-    VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028,
-    VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029,
-    VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030,
-    VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031,
-    VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032,
-    VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033
-} VkFormat;
-typedef enum VkFormatFeatureFlagBits {
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 1,
-    VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 2,
-    VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 4,
-    VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 8,
-    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 16,
-    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 32,
-    VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 64,
-    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 128,
-    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 256,
-    VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 512,
-    VK_FORMAT_FEATURE_BLIT_SRC_BIT = 1024,
-    VK_FORMAT_FEATURE_BLIT_DST_BIT = 2048,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 4096,
-    VK_FORMAT_FEATURE_TRANSFER_SRC_BIT = 16384,
-    VK_FORMAT_FEATURE_TRANSFER_DST_BIT = 32768,
-    VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT = 131072,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 262144,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 524288,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 1048576,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 2097152,
-    VK_FORMAT_FEATURE_DISJOINT_BIT = 4194304,
-    VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 8388608
-} VkFormatFeatureFlagBits;
-typedef enum VkFrontFace {
-    VK_FRONT_FACE_COUNTER_CLOCKWISE = 0,
-    VK_FRONT_FACE_CLOCKWISE = 1
-} VkFrontFace;
-typedef enum VkImageAspectFlagBits {
-    VK_IMAGE_ASPECT_COLOR_BIT = 1,
-    VK_IMAGE_ASPECT_DEPTH_BIT = 2,
-    VK_IMAGE_ASPECT_STENCIL_BIT = 4,
-    VK_IMAGE_ASPECT_METADATA_BIT = 8,
-    VK_IMAGE_ASPECT_PLANE_0_BIT = 16,
-    VK_IMAGE_ASPECT_PLANE_1_BIT = 32,
-    VK_IMAGE_ASPECT_PLANE_2_BIT = 64
-} VkImageAspectFlagBits;
-typedef enum VkImageCreateFlagBits {
-    VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 1,
-    VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 2,
-    VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 4,
-    VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 8,
-    VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 16,
-    VK_IMAGE_CREATE_ALIAS_BIT = 1024,
-    VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 64,
-    VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT = 32,
-    VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT = 128,
-    VK_IMAGE_CREATE_EXTENDED_USAGE_BIT = 256,
-    VK_IMAGE_CREATE_PROTECTED_BIT = 2048,
-    VK_IMAGE_CREATE_DISJOINT_BIT = 512
-} VkImageCreateFlagBits;
-typedef enum VkImageLayout {
-    VK_IMAGE_LAYOUT_UNDEFINED = 0,
-    VK_IMAGE_LAYOUT_GENERAL = 1,
-    VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2,
-    VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3,
-    VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4,
-    VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5,
-    VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6,
-    VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7,
-    VK_IMAGE_LAYOUT_PREINITIALIZED = 8,
-    VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000,
-    VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001,
-    VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002
-} VkImageLayout;
-typedef enum VkImageTiling {
-    VK_IMAGE_TILING_OPTIMAL = 0,
-    VK_IMAGE_TILING_LINEAR = 1
-} VkImageTiling;
-typedef enum VkImageType {
-    VK_IMAGE_TYPE_1D = 0,
-    VK_IMAGE_TYPE_2D = 1,
-    VK_IMAGE_TYPE_3D = 2
-} VkImageType;
-typedef enum VkImageUsageFlagBits {
-    VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 1,
-    VK_IMAGE_USAGE_TRANSFER_DST_BIT = 2,
-    VK_IMAGE_USAGE_SAMPLED_BIT = 4,
-    VK_IMAGE_USAGE_STORAGE_BIT = 8,
-    VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 16,
-    VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 32,
-    VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 64,
-    VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 128
-} VkImageUsageFlagBits;
-
-typedef enum VkImageViewType {
-    VK_IMAGE_VIEW_TYPE_1D = 0,
-    VK_IMAGE_VIEW_TYPE_2D = 1,
-    VK_IMAGE_VIEW_TYPE_3D = 2,
-    VK_IMAGE_VIEW_TYPE_CUBE = 3,
-    VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4,
-    VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5,
-    VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6
-} VkImageViewType;
-typedef enum VkSharingMode {
-    VK_SHARING_MODE_EXCLUSIVE = 0,
-    VK_SHARING_MODE_CONCURRENT = 1
-} VkSharingMode;
-typedef enum VkIndexType {
-    VK_INDEX_TYPE_UINT16 = 0,
-    VK_INDEX_TYPE_UINT32 = 1
-} VkIndexType;
-typedef enum VkLogicOp {
-    VK_LOGIC_OP_CLEAR = 0,
-    VK_LOGIC_OP_AND = 1,
-    VK_LOGIC_OP_AND_REVERSE = 2,
-    VK_LOGIC_OP_COPY = 3,
-    VK_LOGIC_OP_AND_INVERTED = 4,
-    VK_LOGIC_OP_NO_OP = 5,
-    VK_LOGIC_OP_XOR = 6,
-    VK_LOGIC_OP_OR = 7,
-    VK_LOGIC_OP_NOR = 8,
-    VK_LOGIC_OP_EQUIVALENT = 9,
-    VK_LOGIC_OP_INVERT = 10,
-    VK_LOGIC_OP_OR_REVERSE = 11,
-    VK_LOGIC_OP_COPY_INVERTED = 12,
-    VK_LOGIC_OP_OR_INVERTED = 13,
-    VK_LOGIC_OP_NAND = 14,
-    VK_LOGIC_OP_SET = 15
-} VkLogicOp;
-typedef enum VkMemoryHeapFlagBits {
-    VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 1,
-    VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 2
-} VkMemoryHeapFlagBits;
-typedef enum VkAccessFlagBits {
-    VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 1,
-    VK_ACCESS_INDEX_READ_BIT = 2,
-    VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 4,
-    VK_ACCESS_UNIFORM_READ_BIT = 8,
-    VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 16,
-    VK_ACCESS_SHADER_READ_BIT = 32,
-    VK_ACCESS_SHADER_WRITE_BIT = 64,
-    VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 128,
-    VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 256,
-    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 512,
-    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 1024,
-    VK_ACCESS_TRANSFER_READ_BIT = 2048,
-    VK_ACCESS_TRANSFER_WRITE_BIT = 4096,
-    VK_ACCESS_HOST_READ_BIT = 8192,
-    VK_ACCESS_HOST_WRITE_BIT = 16384,
-    VK_ACCESS_MEMORY_READ_BIT = 32768,
-    VK_ACCESS_MEMORY_WRITE_BIT = 65536
-} VkAccessFlagBits;
-typedef enum VkMemoryPropertyFlagBits {
-    VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 1,
-    VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 2,
-    VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 4,
-    VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 8,
-    VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 16,
-    VK_MEMORY_PROPERTY_PROTECTED_BIT = 32
-} VkMemoryPropertyFlagBits;
-typedef enum VkPhysicalDeviceType {
-    VK_PHYSICAL_DEVICE_TYPE_OTHER = 0,
-    VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
-    VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2,
-    VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3,
-    VK_PHYSICAL_DEVICE_TYPE_CPU = 4
-} VkPhysicalDeviceType;
-typedef enum VkPipelineBindPoint {
-    VK_PIPELINE_BIND_POINT_GRAPHICS = 0,
-    VK_PIPELINE_BIND_POINT_COMPUTE = 1
-} VkPipelineBindPoint;
-typedef enum VkPipelineCreateFlagBits {
-    VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 1,
-    VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 2,
-    VK_PIPELINE_CREATE_DERIVATIVE_BIT = 4,
-    VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 8,
-    VK_PIPELINE_CREATE_DISPATCH_BASE = 16
-} VkPipelineCreateFlagBits;
-typedef enum VkPrimitiveTopology {
-    VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
-    VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
-    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5,
-    VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6,
-    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9,
-    VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10
-} VkPrimitiveTopology;
-typedef enum VkQueryControlFlagBits {
-    VK_QUERY_CONTROL_PRECISE_BIT = 1
-} VkQueryControlFlagBits;
-typedef enum VkQueryPipelineStatisticFlagBits {
-    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 1,
-    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 2,
-    VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 4,
-    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 8,
-    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 16,
-    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 32,
-    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 64,
-    VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 128,
-    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 256,
-    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 512,
-    VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 1024
-} VkQueryPipelineStatisticFlagBits;
-typedef enum VkQueryResultFlagBits {
-    VK_QUERY_RESULT_64_BIT = 1,
-    VK_QUERY_RESULT_WAIT_BIT = 2,
-    VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 4,
-    VK_QUERY_RESULT_PARTIAL_BIT = 8
-} VkQueryResultFlagBits;
-typedef enum VkQueryType {
-    VK_QUERY_TYPE_OCCLUSION = 0,
-    VK_QUERY_TYPE_PIPELINE_STATISTICS = 1,
-    VK_QUERY_TYPE_TIMESTAMP = 2
-} VkQueryType;
-typedef enum VkQueueFlagBits {
-    VK_QUEUE_GRAPHICS_BIT = 1,
-    VK_QUEUE_COMPUTE_BIT = 2,
-    VK_QUEUE_TRANSFER_BIT = 4,
-    VK_QUEUE_SPARSE_BINDING_BIT = 8,
-    VK_QUEUE_PROTECTED_BIT = 16
-} VkQueueFlagBits;
-typedef enum VkSubpassContents {
-    VK_SUBPASS_CONTENTS_INLINE = 0,
-    VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1
-} VkSubpassContents;
-typedef enum VkResult {
-    VK_SUCCESS = 0,
-    VK_NOT_READY = 1,
-    VK_TIMEOUT = 2,
-    VK_EVENT_SET = 3,
-    VK_EVENT_RESET = 4,
-    VK_INCOMPLETE = 5,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
-    VK_ERROR_INITIALIZATION_FAILED = -3,
-    VK_ERROR_DEVICE_LOST = -4,
-    VK_ERROR_MEMORY_MAP_FAILED = -5,
-    VK_ERROR_LAYER_NOT_PRESENT = -6,
-    VK_ERROR_EXTENSION_NOT_PRESENT = -7,
-    VK_ERROR_FEATURE_NOT_PRESENT = -8,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -9,
-    VK_ERROR_TOO_MANY_OBJECTS = -10,
-    VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
-    VK_ERROR_FRAGMENTED_POOL = -12,
-    VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000,
-    VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003,
-    VK_ERROR_SURFACE_LOST_KHR = -1000000000,
-    VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
-    VK_SUBOPTIMAL_KHR = 1000001003,
-    VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
-    VK_ERROR_VALIDATION_FAILED_EXT = -1000011001
-} VkResult;
-typedef enum VkShaderStageFlagBits {
-    VK_SHADER_STAGE_VERTEX_BIT = 1,
-    VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 2,
-    VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 4,
-    VK_SHADER_STAGE_GEOMETRY_BIT = 8,
-    VK_SHADER_STAGE_FRAGMENT_BIT = 16,
-    VK_SHADER_STAGE_COMPUTE_BIT = 32,
-    VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
-    VK_SHADER_STAGE_ALL = 0x7FFFFFFF
-} VkShaderStageFlagBits;
-typedef enum VkSparseMemoryBindFlagBits {
-    VK_SPARSE_MEMORY_BIND_METADATA_BIT = 1
-} VkSparseMemoryBindFlagBits;
-typedef enum VkStencilFaceFlagBits {
-    VK_STENCIL_FACE_FRONT_BIT = 1,
-    VK_STENCIL_FACE_BACK_BIT = 2,
-    VK_STENCIL_FRONT_AND_BACK = 0x00000003
-} VkStencilFaceFlagBits;
-typedef enum VkStencilOp {
-    VK_STENCIL_OP_KEEP = 0,
-    VK_STENCIL_OP_ZERO = 1,
-    VK_STENCIL_OP_REPLACE = 2,
-    VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3,
-    VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4,
-    VK_STENCIL_OP_INVERT = 5,
-    VK_STENCIL_OP_INCREMENT_AND_WRAP = 6,
-    VK_STENCIL_OP_DECREMENT_AND_WRAP = 7
-} VkStencilOp;
-typedef enum VkStructureType {
-    VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
-    VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
-    VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2,
-    VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3,
-    VK_STRUCTURE_TYPE_SUBMIT_INFO = 4,
-    VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5,
-    VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6,
-    VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7,
-    VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8,
-    VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9,
-    VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10,
-    VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11,
-    VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12,
-    VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13,
-    VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14,
-    VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15,
-    VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16,
-    VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17,
-    VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18,
-    VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19,
-    VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
-    VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21,
-    VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22,
-    VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23,
-    VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24,
-    VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25,
-    VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26,
-    VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27,
-    VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28,
-    VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29,
-    VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30,
-    VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34,
-    VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35,
-    VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36,
-    VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37,
-    VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38,
-    VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42,
-    VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43,
-    VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44,
-    VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45,
-    VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46,
-    VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47,
-    VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000,
-    VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO = 1000157001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000,
-    VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS = 1000127000,
-    VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001,
-    VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO = 1000060000,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO = 1000060005,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006,
-    VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001,
-    VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000,
-    VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001,
-    VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002,
-    VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 = 1000146003,
-    VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 = 1000059000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001,
-    VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 = 1000059002,
-    VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 = 1000059003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004,
-    VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2 = 1000059005,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006,
-    VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000,
-    VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001,
-    VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002,
-    VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003,
-    VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES,
-    VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO = 1000145000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002,
-    VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2 = 1000145003,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO = 1000156001,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002,
-    VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000,
-    VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002,
-    VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES = 1000071003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004,
-    VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000,
-    VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001,
-    VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO = 1000072002,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000,
-    VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES = 1000112001,
-    VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO = 1000113000,
-    VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO = 1000077000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000,
-    VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES,
-    VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000,
-    VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007,
-    VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009,
-    VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012,
-    VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
-    VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
-} VkStructureType;
-typedef enum VkSystemAllocationScope {
-    VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
-    VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
-    VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
-    VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
-    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4
-} VkSystemAllocationScope;
-typedef enum VkInternalAllocationType {
-    VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0
-} VkInternalAllocationType;
-typedef enum VkSamplerAddressMode {
-    VK_SAMPLER_ADDRESS_MODE_REPEAT = 0,
-    VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1,
-    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2,
-    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3
-} VkSamplerAddressMode;
-typedef enum VkFilter {
-    VK_FILTER_NEAREST = 0,
-    VK_FILTER_LINEAR = 1
-} VkFilter;
-typedef enum VkSamplerMipmapMode {
-    VK_SAMPLER_MIPMAP_MODE_NEAREST = 0,
-    VK_SAMPLER_MIPMAP_MODE_LINEAR = 1
-} VkSamplerMipmapMode;
-typedef enum VkVertexInputRate {
-    VK_VERTEX_INPUT_RATE_VERTEX = 0,
-    VK_VERTEX_INPUT_RATE_INSTANCE = 1
-} VkVertexInputRate;
-typedef enum VkPipelineStageFlagBits {
-    VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 1,
-    VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 2,
-    VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 4,
-    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 8,
-    VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 16,
-    VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 32,
-    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 64,
-    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 128,
-    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 256,
-    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 512,
-    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 1024,
-    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 2048,
-    VK_PIPELINE_STAGE_TRANSFER_BIT = 4096,
-    VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 8192,
-    VK_PIPELINE_STAGE_HOST_BIT = 16384,
-    VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 32768,
-    VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 65536
-} VkPipelineStageFlagBits;
-typedef enum VkSparseImageFormatFlagBits {
-    VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 1,
-    VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 2,
-    VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 4
-} VkSparseImageFormatFlagBits;
-typedef enum VkSampleCountFlagBits {
-    VK_SAMPLE_COUNT_1_BIT = 1,
-    VK_SAMPLE_COUNT_2_BIT = 2,
-    VK_SAMPLE_COUNT_4_BIT = 4,
-    VK_SAMPLE_COUNT_8_BIT = 8,
-    VK_SAMPLE_COUNT_16_BIT = 16,
-    VK_SAMPLE_COUNT_32_BIT = 32,
-    VK_SAMPLE_COUNT_64_BIT = 64
-} VkSampleCountFlagBits;
-typedef enum VkAttachmentDescriptionFlagBits {
-    VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 1
-} VkAttachmentDescriptionFlagBits;
-typedef enum VkDescriptorPoolCreateFlagBits {
-    VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 1
-} VkDescriptorPoolCreateFlagBits;
-typedef enum VkDependencyFlagBits {
-    VK_DEPENDENCY_BY_REGION_BIT = 1,
-    VK_DEPENDENCY_DEVICE_GROUP_BIT = 4,
-    VK_DEPENDENCY_VIEW_LOCAL_BIT = 2
-} VkDependencyFlagBits;
-typedef enum VkObjectType {
-    VK_OBJECT_TYPE_UNKNOWN = 0,
-    VK_OBJECT_TYPE_INSTANCE = 1,
-    VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2,
-    VK_OBJECT_TYPE_DEVICE = 3,
-    VK_OBJECT_TYPE_QUEUE = 4,
-    VK_OBJECT_TYPE_SEMAPHORE = 5,
-    VK_OBJECT_TYPE_COMMAND_BUFFER = 6,
-    VK_OBJECT_TYPE_FENCE = 7,
-    VK_OBJECT_TYPE_DEVICE_MEMORY = 8,
-    VK_OBJECT_TYPE_BUFFER = 9,
-    VK_OBJECT_TYPE_IMAGE = 10,
-    VK_OBJECT_TYPE_EVENT = 11,
-    VK_OBJECT_TYPE_QUERY_POOL = 12,
-    VK_OBJECT_TYPE_BUFFER_VIEW = 13,
-    VK_OBJECT_TYPE_IMAGE_VIEW = 14,
-    VK_OBJECT_TYPE_SHADER_MODULE = 15,
-    VK_OBJECT_TYPE_PIPELINE_CACHE = 16,
-    VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17,
-    VK_OBJECT_TYPE_RENDER_PASS = 18,
-    VK_OBJECT_TYPE_PIPELINE = 19,
-    VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20,
-    VK_OBJECT_TYPE_SAMPLER = 21,
-    VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22,
-    VK_OBJECT_TYPE_DESCRIPTOR_SET = 23,
-    VK_OBJECT_TYPE_FRAMEBUFFER = 24,
-    VK_OBJECT_TYPE_COMMAND_POOL = 25,
-    VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION = 1000156000,
-    VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE = 1000085000,
-    VK_OBJECT_TYPE_SURFACE_KHR = 1000000000,
-    VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000,
-    VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000
-} VkObjectType;
-typedef enum VkDescriptorUpdateTemplateType {
-    VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0
-} VkDescriptorUpdateTemplateType;
-
-typedef enum VkPointClippingBehavior {
-    VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0,
-    VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1
-} VkPointClippingBehavior;
-typedef enum VkColorSpaceKHR {
-    VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
-    VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
-} VkColorSpaceKHR;
-typedef enum VkCompositeAlphaFlagBitsKHR {
-    VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 1,
-    VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 2,
-    VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 4,
-    VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 8
-} VkCompositeAlphaFlagBitsKHR;
-typedef enum VkPresentModeKHR {
-    VK_PRESENT_MODE_IMMEDIATE_KHR = 0,
-    VK_PRESENT_MODE_MAILBOX_KHR = 1,
-    VK_PRESENT_MODE_FIFO_KHR = 2,
-    VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3
-} VkPresentModeKHR;
-typedef enum VkSurfaceTransformFlagBitsKHR {
-    VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 1,
-    VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 2,
-    VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 4,
-    VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 8,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 16,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 32,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 64,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 128,
-    VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 256
-} VkSurfaceTransformFlagBitsKHR;
-typedef enum VkDebugReportFlagBitsEXT {
-    VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 1,
-    VK_DEBUG_REPORT_WARNING_BIT_EXT = 2,
-    VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 4,
-    VK_DEBUG_REPORT_ERROR_BIT_EXT = 8,
-    VK_DEBUG_REPORT_DEBUG_BIT_EXT = 16
-} VkDebugReportFlagBitsEXT;
-typedef enum VkDebugReportObjectTypeEXT {
-    VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0,
-    VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3,
-    VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5,
-    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6,
-    VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8,
-    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9,
-    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10,
-    VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11,
-    VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12,
-    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13,
-    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17,
-    VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23,
-    VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24,
-    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30,
-    VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31,
-    VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32,
-    VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33,
-    VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000
-} VkDebugReportObjectTypeEXT;
-typedef enum VkExternalMemoryHandleTypeFlagBits {
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT = 8,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT = 16,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 32,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 64
-} VkExternalMemoryHandleTypeFlagBits;
-typedef enum VkExternalMemoryFeatureFlagBits {
-    VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 1,
-    VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 2,
-    VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 4
-} VkExternalMemoryFeatureFlagBits;
-typedef enum VkExternalSemaphoreHandleTypeFlagBits {
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 8,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 16
-} VkExternalSemaphoreHandleTypeFlagBits;
-typedef enum VkExternalSemaphoreFeatureFlagBits {
-    VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 1,
-    VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 2
-} VkExternalSemaphoreFeatureFlagBits;
-typedef enum VkSemaphoreImportFlagBits {
-    VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 1
-} VkSemaphoreImportFlagBits;
-typedef enum VkExternalFenceHandleTypeFlagBits {
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 8
-} VkExternalFenceHandleTypeFlagBits;
-typedef enum VkExternalFenceFeatureFlagBits {
-    VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 1,
-    VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 2
-} VkExternalFenceFeatureFlagBits;
-typedef enum VkFenceImportFlagBits {
-    VK_FENCE_IMPORT_TEMPORARY_BIT = 1
-} VkFenceImportFlagBits;
-typedef enum VkPeerMemoryFeatureFlagBits {
-    VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 1,
-    VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 2,
-    VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 4,
-    VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 8
-} VkPeerMemoryFeatureFlagBits;
-typedef enum VkMemoryAllocateFlagBits {
-    VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 1
-} VkMemoryAllocateFlagBits;
-typedef enum VkDeviceGroupPresentModeFlagBitsKHR {
-    VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 1,
-    VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 2,
-    VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 4,
-    VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 8
-} VkDeviceGroupPresentModeFlagBitsKHR;
-typedef enum VkSwapchainCreateFlagBitsKHR {
-    VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 1,
-    VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 2
-} VkSwapchainCreateFlagBitsKHR;
-typedef enum VkSubgroupFeatureFlagBits {
-    VK_SUBGROUP_FEATURE_BASIC_BIT = 1,
-    VK_SUBGROUP_FEATURE_VOTE_BIT = 2,
-    VK_SUBGROUP_FEATURE_ARITHMETIC_BIT = 4,
-    VK_SUBGROUP_FEATURE_BALLOT_BIT = 8,
-    VK_SUBGROUP_FEATURE_SHUFFLE_BIT = 16,
-    VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 32,
-    VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 64,
-    VK_SUBGROUP_FEATURE_QUAD_BIT = 128
-} VkSubgroupFeatureFlagBits;
-typedef enum VkTessellationDomainOrigin {
-    VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0,
-    VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1
-} VkTessellationDomainOrigin;
-typedef enum VkSamplerYcbcrModelConversion {
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 = 2,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4
-} VkSamplerYcbcrModelConversion;
-typedef enum VkSamplerYcbcrRange {
-    VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0,
-    VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1
-} VkSamplerYcbcrRange;
-typedef enum VkChromaLocation {
-    VK_CHROMA_LOCATION_COSITED_EVEN = 0,
-    VK_CHROMA_LOCATION_MIDPOINT = 1
-} VkChromaLocation;
-typedef enum VkVendorId {
-    VK_VENDOR_ID_VIV = 0x10001,
-    VK_VENDOR_ID_VSI = 0x10002,
-    VK_VENDOR_ID_KAZAN = 0x10003
-} VkVendorId;
-typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)(
-    void*                                       pUserData,
-    size_t                                      size,
-    VkInternalAllocationType                    allocationType,
-    VkSystemAllocationScope                     allocationScope);
-typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)(
-    void*                                       pUserData,
-    size_t                                      size,
-    VkInternalAllocationType                    allocationType,
-    VkSystemAllocationScope                     allocationScope);
-typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
-    void*                                       pUserData,
-    void*                                       pOriginal,
-    size_t                                      size,
-    size_t                                      alignment,
-    VkSystemAllocationScope                     allocationScope);
-typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
-    void*                                       pUserData,
-    size_t                                      size,
-    size_t                                      alignment,
-    VkSystemAllocationScope                     allocationScope);
-typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
-    void*                                       pUserData,
-    void*                                       pMemory);
-typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);
-typedef struct VkBaseOutStructure {
-    VkStructureType   sType;
-    struct  VkBaseOutStructure *  pNext;
-} VkBaseOutStructure;
-typedef struct VkBaseInStructure {
-    VkStructureType   sType;
-    const struct  VkBaseInStructure *  pNext;
-} VkBaseInStructure;
-typedef struct VkOffset2D {
-    int32_t          x;
-    int32_t          y;
-} VkOffset2D;
-typedef struct VkOffset3D {
-    int32_t          x;
-    int32_t          y;
-    int32_t          z;
-} VkOffset3D;
-typedef struct VkExtent2D {
-    uint32_t          width;
-    uint32_t          height;
-} VkExtent2D;
-typedef struct VkExtent3D {
-    uint32_t          width;
-    uint32_t          height;
-    uint32_t          depth;
-} VkExtent3D;
-typedef struct VkViewport {
-    float   x;
-    float   y;
-    float   width;
-    float   height;
-    float                         minDepth;
-    float                         maxDepth;
-} VkViewport;
-typedef struct VkRect2D {
-    VkOffset2D       offset;
-    VkExtent2D       extent;
-} VkRect2D;
-typedef struct VkClearRect {
-    VkRect2D         rect;
-    uint32_t         baseArrayLayer;
-    uint32_t         layerCount;
-} VkClearRect;
-typedef struct VkComponentMapping {
-    VkComponentSwizzle   r;
-    VkComponentSwizzle   g;
-    VkComponentSwizzle   b;
-    VkComponentSwizzle   a;
-} VkComponentMapping;
-typedef struct VkExtensionProperties {
-    char              extensionName [ VK_MAX_EXTENSION_NAME_SIZE ];
-    uint32_t          specVersion;
-} VkExtensionProperties;
-typedef struct VkLayerProperties {
-    char              layerName [ VK_MAX_EXTENSION_NAME_SIZE ];
-    uint32_t          specVersion;
-    uint32_t          implementationVersion;
-    char              description [ VK_MAX_DESCRIPTION_SIZE ];
-} VkLayerProperties;
-typedef struct VkApplicationInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    const  char *      pApplicationName;
-    uint32_t          applicationVersion;
-    const  char *      pEngineName;
-    uint32_t          engineVersion;
-    uint32_t          apiVersion;
-} VkApplicationInfo;
-typedef struct VkAllocationCallbacks {
-    void *            pUserData;
-    PFN_vkAllocationFunction     pfnAllocation;
-    PFN_vkReallocationFunction   pfnReallocation;
-    PFN_vkFreeFunction      pfnFree;
-    PFN_vkInternalAllocationNotification   pfnInternalAllocation;
-    PFN_vkInternalFreeNotification   pfnInternalFree;
-} VkAllocationCallbacks;
-typedef struct VkDescriptorImageInfo {
-    VkSampler         sampler;
-    VkImageView       imageView;
-    VkImageLayout     imageLayout;
-} VkDescriptorImageInfo;
-typedef struct VkCopyDescriptorSet {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSet          srcSet;
-    uint32_t                 srcBinding;
-    uint32_t                 srcArrayElement;
-    VkDescriptorSet          dstSet;
-    uint32_t                 dstBinding;
-    uint32_t                 dstArrayElement;
-    uint32_t                 descriptorCount;
-} VkCopyDescriptorSet;
-typedef struct VkDescriptorPoolSize {
-    VkDescriptorType         type;
-    uint32_t                 descriptorCount;
-} VkDescriptorPoolSize;
-typedef struct VkDescriptorSetAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorPool         descriptorPool;
-    uint32_t                 descriptorSetCount;
-    const  VkDescriptorSetLayout *  pSetLayouts;
-} VkDescriptorSetAllocateInfo;
-typedef struct VkSpecializationMapEntry {
-    uint32_t                       constantID;
-    uint32_t                       offset;
-    size_t   size;
-} VkSpecializationMapEntry;
-typedef struct VkSpecializationInfo {
-    uint32_t                 mapEntryCount;
-    const  VkSpecializationMapEntry *  pMapEntries;
-    size_t                   dataSize;
-    const  void *             pData;
-} VkSpecializationInfo;
-typedef struct VkVertexInputBindingDescription {
-    uint32_t                 binding;
-    uint32_t                 stride;
-    VkVertexInputRate        inputRate;
-} VkVertexInputBindingDescription;
-typedef struct VkVertexInputAttributeDescription {
-    uint32_t                 location;
-    uint32_t                 binding;
-    VkFormat                 format;
-    uint32_t                 offset;
-} VkVertexInputAttributeDescription;
-typedef struct VkStencilOpState {
-    VkStencilOp              failOp;
-    VkStencilOp              passOp;
-    VkStencilOp              depthFailOp;
-    VkCompareOp              compareOp;
-    uint32_t                 compareMask;
-    uint32_t                 writeMask;
-    uint32_t                 reference;
-} VkStencilOpState;
-typedef struct VkCommandBufferAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandPool            commandPool;
-    VkCommandBufferLevel     level;
-    uint32_t                 commandBufferCount;
-} VkCommandBufferAllocateInfo;
-typedef union VkClearColorValue {
-    float                    float32 [4];
-    int32_t                  int32 [4];
-    uint32_t                 uint32 [4];
-} VkClearColorValue;
-typedef struct VkClearDepthStencilValue {
-    float                    depth;
-    uint32_t                 stencil;
-} VkClearDepthStencilValue;
-typedef union VkClearValue {
-    VkClearColorValue        color;
-    VkClearDepthStencilValue   depthStencil;
-} VkClearValue;
-typedef struct VkAttachmentReference {
-    uint32_t                 attachment;
-    VkImageLayout            layout;
-} VkAttachmentReference;
-typedef struct VkDrawIndirectCommand {
-    uint32_t                         vertexCount;
-    uint32_t                         instanceCount;
-    uint32_t                         firstVertex;
-    uint32_t   firstInstance;
-} VkDrawIndirectCommand;
-typedef struct VkDrawIndexedIndirectCommand {
-    uint32_t                         indexCount;
-    uint32_t                         instanceCount;
-    uint32_t                         firstIndex;
-    int32_t                          vertexOffset;
-    uint32_t   firstInstance;
-} VkDrawIndexedIndirectCommand;
-typedef struct VkDispatchIndirectCommand {
-    uint32_t   x;
-    uint32_t   y;
-    uint32_t   z;
-} VkDispatchIndirectCommand;
-typedef struct VkSurfaceFormatKHR {
-    VkFormat                           format;
-    VkColorSpaceKHR                    colorSpace;
-} VkSurfaceFormatKHR;
-typedef struct VkPresentInfoKHR {
-    VkStructureType   sType;
-    const  void *   pNext;
-    uint32_t           waitSemaphoreCount;
-    const  VkSemaphore *  pWaitSemaphores;
-    uint32_t                           swapchainCount;
-    const  VkSwapchainKHR *  pSwapchains;
-    const  uint32_t *  pImageIndices;
-    VkResult *  pResults;
-} VkPresentInfoKHR;
-typedef struct VkPhysicalDeviceExternalImageFormatInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalImageFormatInfo;
-typedef struct VkPhysicalDeviceExternalSemaphoreInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalSemaphoreHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalSemaphoreInfo;
-typedef struct VkPhysicalDeviceExternalFenceInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalFenceHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalFenceInfo;
-typedef struct VkPhysicalDeviceMultiviewProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           maxMultiviewViewCount;
-    uint32_t                           maxMultiviewInstanceIndex;
-} VkPhysicalDeviceMultiviewProperties;
-typedef struct VkRenderPassMultiviewCreateInfo {
-    VkStructureType          sType;
-    const  void *             pNext;
-    uint32_t                 subpassCount;
-    const  uint32_t *      pViewMasks;
-    uint32_t                 dependencyCount;
-    const  int32_t *    pViewOffsets;
-    uint32_t                 correlationMaskCount;
-    const  uint32_t *  pCorrelationMasks;
-} VkRenderPassMultiviewCreateInfo;
-typedef struct VkBindBufferMemoryDeviceGroupInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           deviceIndexCount;
-    const  uint32_t *   pDeviceIndices;
-} VkBindBufferMemoryDeviceGroupInfo;
-typedef struct VkBindImageMemoryDeviceGroupInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           deviceIndexCount;
-    const  uint32_t *   pDeviceIndices;
-    uint32_t           splitInstanceBindRegionCount;
-    const  VkRect2D *   pSplitInstanceBindRegions;
-} VkBindImageMemoryDeviceGroupInfo;
-typedef struct VkDeviceGroupRenderPassBeginInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           deviceMask;
-    uint32_t           deviceRenderAreaCount;
-    const  VkRect2D *   pDeviceRenderAreas;
-} VkDeviceGroupRenderPassBeginInfo;
-typedef struct VkDeviceGroupCommandBufferBeginInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           deviceMask;
-} VkDeviceGroupCommandBufferBeginInfo;
-typedef struct VkDeviceGroupSubmitInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           waitSemaphoreCount;
-    const  uint32_t *     pWaitSemaphoreDeviceIndices;
-    uint32_t           commandBufferCount;
-    const  uint32_t *     pCommandBufferDeviceMasks;
-    uint32_t           signalSemaphoreCount;
-    const  uint32_t *   pSignalSemaphoreDeviceIndices;
-} VkDeviceGroupSubmitInfo;
-typedef struct VkDeviceGroupBindSparseInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           resourceDeviceIndex;
-    uint32_t                           memoryDeviceIndex;
-} VkDeviceGroupBindSparseInfo;
-typedef struct VkImageSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR     swapchain;
-} VkImageSwapchainCreateInfoKHR;
-typedef struct VkBindImageMemorySwapchainInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR   swapchain;
-    uint32_t                           imageIndex;
-} VkBindImageMemorySwapchainInfoKHR;
-typedef struct VkAcquireNextImageInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR   swapchain;
-    uint64_t                           timeout;
-    VkSemaphore   semaphore;
-    VkFence   fence;
-    uint32_t                           deviceMask;
-} VkAcquireNextImageInfoKHR;
-typedef struct VkDeviceGroupPresentInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           swapchainCount;
-    const  uint32_t *  pDeviceMasks;
-    VkDeviceGroupPresentModeFlagBitsKHR   mode;
-} VkDeviceGroupPresentInfoKHR;
-typedef struct VkDeviceGroupDeviceCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           physicalDeviceCount;
-    const  VkPhysicalDevice *   pPhysicalDevices;
-} VkDeviceGroupDeviceCreateInfo;
-typedef struct VkDescriptorUpdateTemplateEntry {
-    uint32_t                           dstBinding;
-    uint32_t                           dstArrayElement;
-    uint32_t                           descriptorCount;
-    VkDescriptorType                   descriptorType;
-    size_t                             offset;
-    size_t                             stride;
-} VkDescriptorUpdateTemplateEntry;
-typedef struct VkBufferMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkBuffer                                                               buffer;
-} VkBufferMemoryRequirementsInfo2;
-typedef struct VkImageMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkImage                                                                image;
-} VkImageMemoryRequirementsInfo2;
-typedef struct VkImageSparseMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkImage                                                                image;
-} VkImageSparseMemoryRequirementsInfo2;
-typedef struct VkPhysicalDevicePointClippingProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPointClippingBehavior        pointClippingBehavior;
-} VkPhysicalDevicePointClippingProperties;
-typedef struct VkMemoryDedicatedAllocateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImage            image;
-    VkBuffer           buffer;
-} VkMemoryDedicatedAllocateInfo;
-typedef struct VkPipelineTessellationDomainOriginStateCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkTessellationDomainOrigin      domainOrigin;
-} VkPipelineTessellationDomainOriginStateCreateInfo;
-typedef struct VkSamplerYcbcrConversionInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSamplerYcbcrConversion        conversion;
-} VkSamplerYcbcrConversionInfo;
-typedef struct VkBindImagePlaneMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImageAspectFlagBits              planeAspect;
-} VkBindImagePlaneMemoryInfo;
-typedef struct VkImagePlaneMemoryRequirementsInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImageAspectFlagBits              planeAspect;
-} VkImagePlaneMemoryRequirementsInfo;
-typedef struct VkSamplerYcbcrConversionImageFormatProperties {
-    VkStructureType   sType;
-    void *       pNext;
-    uint32_t                           combinedImageSamplerDescriptorCount;
-} VkSamplerYcbcrConversionImageFormatProperties;
-typedef uint32_t VkSampleMask;
-typedef uint32_t VkBool32;
-typedef uint32_t VkFlags;
-typedef uint64_t VkDeviceSize;
-typedef VkFlags VkFramebufferCreateFlags;
-typedef VkFlags VkQueryPoolCreateFlags;
-typedef VkFlags VkRenderPassCreateFlags;
-typedef VkFlags VkSamplerCreateFlags;
-typedef VkFlags VkPipelineLayoutCreateFlags;
-typedef VkFlags VkPipelineCacheCreateFlags;
-typedef VkFlags VkPipelineDepthStencilStateCreateFlags;
-typedef VkFlags VkPipelineDynamicStateCreateFlags;
-typedef VkFlags VkPipelineColorBlendStateCreateFlags;
-typedef VkFlags VkPipelineMultisampleStateCreateFlags;
-typedef VkFlags VkPipelineRasterizationStateCreateFlags;
-typedef VkFlags VkPipelineViewportStateCreateFlags;
-typedef VkFlags VkPipelineTessellationStateCreateFlags;
-typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;
-typedef VkFlags VkPipelineVertexInputStateCreateFlags;
-typedef VkFlags VkPipelineShaderStageCreateFlags;
-typedef VkFlags VkDescriptorSetLayoutCreateFlags;
-typedef VkFlags VkBufferViewCreateFlags;
-typedef VkFlags VkInstanceCreateFlags;
-typedef VkFlags VkDeviceCreateFlags;
-typedef VkFlags VkDeviceQueueCreateFlags;
-typedef VkFlags VkQueueFlags;
-typedef VkFlags VkMemoryPropertyFlags;
-typedef VkFlags VkMemoryHeapFlags;
-typedef VkFlags VkAccessFlags;
-typedef VkFlags VkBufferUsageFlags;
-typedef VkFlags VkBufferCreateFlags;
-typedef VkFlags VkShaderStageFlags;
-typedef VkFlags VkImageUsageFlags;
-typedef VkFlags VkImageCreateFlags;
-typedef VkFlags VkImageViewCreateFlags;
-typedef VkFlags VkPipelineCreateFlags;
-typedef VkFlags VkColorComponentFlags;
-typedef VkFlags VkFenceCreateFlags;
-typedef VkFlags VkSemaphoreCreateFlags;
-typedef VkFlags VkFormatFeatureFlags;
-typedef VkFlags VkQueryControlFlags;
-typedef VkFlags VkQueryResultFlags;
-typedef VkFlags VkShaderModuleCreateFlags;
-typedef VkFlags VkEventCreateFlags;
-typedef VkFlags VkCommandPoolCreateFlags;
-typedef VkFlags VkCommandPoolResetFlags;
-typedef VkFlags VkCommandBufferResetFlags;
-typedef VkFlags VkCommandBufferUsageFlags;
-typedef VkFlags VkQueryPipelineStatisticFlags;
-typedef VkFlags VkMemoryMapFlags;
-typedef VkFlags VkImageAspectFlags;
-typedef VkFlags VkSparseMemoryBindFlags;
-typedef VkFlags VkSparseImageFormatFlags;
-typedef VkFlags VkSubpassDescriptionFlags;
-typedef VkFlags VkPipelineStageFlags;
-typedef VkFlags VkSampleCountFlags;
-typedef VkFlags VkAttachmentDescriptionFlags;
-typedef VkFlags VkStencilFaceFlags;
-typedef VkFlags VkCullModeFlags;
-typedef VkFlags VkDescriptorPoolCreateFlags;
-typedef VkFlags VkDescriptorPoolResetFlags;
-typedef VkFlags VkDependencyFlags;
-typedef VkFlags VkSubgroupFeatureFlags;
-typedef VkFlags VkDescriptorUpdateTemplateCreateFlags;
-typedef VkFlags VkCompositeAlphaFlagsKHR;
-typedef VkFlags VkSurfaceTransformFlagsKHR;
-typedef VkFlags VkSwapchainCreateFlagsKHR;
-typedef VkFlags VkPeerMemoryFeatureFlags;
-typedef VkFlags VkMemoryAllocateFlags;
-typedef VkFlags VkDeviceGroupPresentModeFlagsKHR;
-typedef VkFlags VkDebugReportFlagsEXT;
-typedef VkFlags VkCommandPoolTrimFlags;
-typedef VkFlags VkExternalMemoryHandleTypeFlags;
-typedef VkFlags VkExternalMemoryFeatureFlags;
-typedef VkFlags VkExternalSemaphoreHandleTypeFlags;
-typedef VkFlags VkExternalSemaphoreFeatureFlags;
-typedef VkFlags VkSemaphoreImportFlags;
-typedef VkFlags VkExternalFenceHandleTypeFlags;
-typedef VkFlags VkExternalFenceFeatureFlags;
-typedef VkFlags VkFenceImportFlags;
-typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)(
-    VkDebugReportFlagsEXT                       flags,
-    VkDebugReportObjectTypeEXT                  objectType,
-    uint64_t                                    object,
-    size_t                                      location,
-    int32_t                                     messageCode,
-    const char*                                 pLayerPrefix,
-    const char*                                 pMessage,
-    void*                                       pUserData);
-typedef struct VkDeviceQueueCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkDeviceQueueCreateFlags      flags;
-    uint32_t          queueFamilyIndex;
-    uint32_t          queueCount;
-    const  float *     pQueuePriorities;
-} VkDeviceQueueCreateInfo;
-typedef struct VkInstanceCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkInstanceCreateFlags    flags;
-    const  VkApplicationInfo *  pApplicationInfo;
-    uint32_t                 enabledLayerCount;
-    const  char * const*       ppEnabledLayerNames;
-    uint32_t                 enabledExtensionCount;
-    const  char * const*       ppEnabledExtensionNames;
-} VkInstanceCreateInfo;
-typedef struct VkQueueFamilyProperties {
-    VkQueueFlags             queueFlags;
-    uint32_t                 queueCount;
-    uint32_t                 timestampValidBits;
-    VkExtent3D               minImageTransferGranularity;
-} VkQueueFamilyProperties;
-typedef struct VkMemoryAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDeviceSize             allocationSize;
-    uint32_t                 memoryTypeIndex;
-} VkMemoryAllocateInfo;
-typedef struct VkMemoryRequirements {
-    VkDeviceSize             size;
-    VkDeviceSize             alignment;
-    uint32_t                 memoryTypeBits;
-} VkMemoryRequirements;
-typedef struct VkSparseImageFormatProperties {
-    VkImageAspectFlags       aspectMask;
-    VkExtent3D               imageGranularity;
-    VkSparseImageFormatFlags   flags;
-} VkSparseImageFormatProperties;
-typedef struct VkSparseImageMemoryRequirements {
-    VkSparseImageFormatProperties   formatProperties;
-    uint32_t                 imageMipTailFirstLod;
-    VkDeviceSize             imageMipTailSize;
-    VkDeviceSize             imageMipTailOffset;
-    VkDeviceSize             imageMipTailStride;
-} VkSparseImageMemoryRequirements;
-typedef struct VkMemoryType {
-    VkMemoryPropertyFlags    propertyFlags;
-    uint32_t                 heapIndex;
-} VkMemoryType;
-typedef struct VkMemoryHeap {
-    VkDeviceSize             size;
-    VkMemoryHeapFlags        flags;
-} VkMemoryHeap;
-typedef struct VkMappedMemoryRange {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDeviceMemory           memory;
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-} VkMappedMemoryRange;
-typedef struct VkFormatProperties {
-    VkFormatFeatureFlags     linearTilingFeatures;
-    VkFormatFeatureFlags     optimalTilingFeatures;
-    VkFormatFeatureFlags     bufferFeatures;
-} VkFormatProperties;
-typedef struct VkImageFormatProperties {
-    VkExtent3D               maxExtent;
-    uint32_t                 maxMipLevels;
-    uint32_t                 maxArrayLayers;
-    VkSampleCountFlags       sampleCounts;
-    VkDeviceSize             maxResourceSize;
-} VkImageFormatProperties;
-typedef struct VkDescriptorBufferInfo {
-    VkBuffer                 buffer;
-    VkDeviceSize             offset;
-    VkDeviceSize             range;
-} VkDescriptorBufferInfo;
-typedef struct VkWriteDescriptorSet {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSet          dstSet;
-    uint32_t                 dstBinding;
-    uint32_t                 dstArrayElement;
-    uint32_t                 descriptorCount;
-    VkDescriptorType         descriptorType;
-    const  VkDescriptorImageInfo *  pImageInfo;
-    const  VkDescriptorBufferInfo *  pBufferInfo;
-    const  VkBufferView *     pTexelBufferView;
-} VkWriteDescriptorSet;
-typedef struct VkBufferCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkBufferCreateFlags      flags;
-    VkDeviceSize             size;
-    VkBufferUsageFlags       usage;
-    VkSharingMode            sharingMode;
-    uint32_t                 queueFamilyIndexCount;
-    const  uint32_t *         pQueueFamilyIndices;
-} VkBufferCreateInfo;
-typedef struct VkBufferViewCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkBufferViewCreateFlags flags;
-    VkBuffer                 buffer;
-    VkFormat                 format;
-    VkDeviceSize             offset;
-    VkDeviceSize             range;
-} VkBufferViewCreateInfo;
-typedef struct VkImageSubresource {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 mipLevel;
-    uint32_t                 arrayLayer;
-} VkImageSubresource;
-typedef struct VkImageSubresourceLayers {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 mipLevel;
-    uint32_t                 baseArrayLayer;
-    uint32_t                 layerCount;
-} VkImageSubresourceLayers;
-typedef struct VkImageSubresourceRange {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 baseMipLevel;
-    uint32_t                 levelCount;
-    uint32_t                 baseArrayLayer;
-    uint32_t                 layerCount;
-} VkImageSubresourceRange;
-typedef struct VkMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-} VkMemoryBarrier;
-typedef struct VkBufferMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    uint32_t                 srcQueueFamilyIndex;
-    uint32_t                 dstQueueFamilyIndex;
-    VkBuffer                 buffer;
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-} VkBufferMemoryBarrier;
-typedef struct VkImageMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    VkImageLayout            oldLayout;
-    VkImageLayout            newLayout;
-    uint32_t                 srcQueueFamilyIndex;
-    uint32_t                 dstQueueFamilyIndex;
-    VkImage                  image;
-    VkImageSubresourceRange   subresourceRange;
-} VkImageMemoryBarrier;
-typedef struct VkImageCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkImageCreateFlags       flags;
-    VkImageType              imageType;
-    VkFormat                 format;
-    VkExtent3D               extent;
-    uint32_t                 mipLevels;
-    uint32_t                 arrayLayers;
-    VkSampleCountFlagBits    samples;
-    VkImageTiling            tiling;
-    VkImageUsageFlags        usage;
-    VkSharingMode            sharingMode;
-    uint32_t                 queueFamilyIndexCount;
-    const  uint32_t *         pQueueFamilyIndices;
-    VkImageLayout            initialLayout;
-} VkImageCreateInfo;
-typedef struct VkSubresourceLayout {
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-    VkDeviceSize             rowPitch;
-    VkDeviceSize             arrayPitch;
-    VkDeviceSize             depthPitch;
-} VkSubresourceLayout;
-typedef struct VkImageViewCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkImageViewCreateFlags   flags;
-    VkImage                  image;
-    VkImageViewType          viewType;
-    VkFormat                 format;
-    VkComponentMapping       components;
-    VkImageSubresourceRange   subresourceRange;
-} VkImageViewCreateInfo;
-typedef struct VkBufferCopy {
-    VkDeviceSize                         srcOffset;
-    VkDeviceSize                         dstOffset;
-    VkDeviceSize   size;
-} VkBufferCopy;
-typedef struct VkSparseMemoryBind {
-    VkDeviceSize             resourceOffset;
-    VkDeviceSize             size;
-    VkDeviceMemory           memory;
-    VkDeviceSize             memoryOffset;
-    VkSparseMemoryBindFlags flags;
-} VkSparseMemoryBind;
-typedef struct VkSparseImageMemoryBind {
-    VkImageSubresource       subresource;
-    VkOffset3D               offset;
-    VkExtent3D               extent;
-    VkDeviceMemory           memory;
-    VkDeviceSize             memoryOffset;
-    VkSparseMemoryBindFlags flags;
-} VkSparseImageMemoryBind;
-typedef struct VkSparseBufferMemoryBindInfo {
-    VkBuffer   buffer;
-    uint32_t                 bindCount;
-    const  VkSparseMemoryBind *  pBinds;
-} VkSparseBufferMemoryBindInfo;
-typedef struct VkSparseImageOpaqueMemoryBindInfo {
-    VkImage   image;
-    uint32_t                 bindCount;
-    const  VkSparseMemoryBind *  pBinds;
-} VkSparseImageOpaqueMemoryBindInfo;
-typedef struct VkSparseImageMemoryBindInfo {
-    VkImage   image;
-    uint32_t                 bindCount;
-    const  VkSparseImageMemoryBind *  pBinds;
-} VkSparseImageMemoryBindInfo;
-typedef struct VkBindSparseInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    uint32_t                 waitSemaphoreCount;
-    const  VkSemaphore *      pWaitSemaphores;
-    uint32_t                 bufferBindCount;
-    const  VkSparseBufferMemoryBindInfo *  pBufferBinds;
-    uint32_t                 imageOpaqueBindCount;
-    const  VkSparseImageOpaqueMemoryBindInfo *  pImageOpaqueBinds;
-    uint32_t                 imageBindCount;
-    const  VkSparseImageMemoryBindInfo *  pImageBinds;
-    uint32_t                 signalSemaphoreCount;
-    const  VkSemaphore *      pSignalSemaphores;
-} VkBindSparseInfo;
-typedef struct VkImageCopy {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffset;
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffset;
-    VkExtent3D               extent;
-} VkImageCopy;
-typedef struct VkImageBlit {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffsets [2];
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffsets [2];
-} VkImageBlit;
-typedef struct VkBufferImageCopy {
-    VkDeviceSize             bufferOffset;
-    uint32_t                 bufferRowLength;
-    uint32_t                 bufferImageHeight;
-    VkImageSubresourceLayers   imageSubresource;
-    VkOffset3D               imageOffset;
-    VkExtent3D               imageExtent;
-} VkBufferImageCopy;
-typedef struct VkImageResolve {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffset;
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffset;
-    VkExtent3D               extent;
-} VkImageResolve;
-typedef struct VkShaderModuleCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkShaderModuleCreateFlags   flags;
-    size_t                   codeSize;
-    const  uint32_t *             pCode;
-} VkShaderModuleCreateInfo;
-typedef struct VkDescriptorSetLayoutBinding {
-    uint32_t                 binding;
-    VkDescriptorType         descriptorType;
-    uint32_t   descriptorCount;
-    VkShaderStageFlags       stageFlags;
-    const  VkSampler *        pImmutableSamplers;
-} VkDescriptorSetLayoutBinding;
-typedef struct VkDescriptorSetLayoutCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSetLayoutCreateFlags      flags;
-    uint32_t                 bindingCount;
-    const  VkDescriptorSetLayoutBinding *  pBindings;
-} VkDescriptorSetLayoutCreateInfo;
-typedef struct VkDescriptorPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorPoolCreateFlags    flags;
-    uint32_t                 maxSets;
-    uint32_t                 poolSizeCount;
-    const  VkDescriptorPoolSize *  pPoolSizes;
-} VkDescriptorPoolCreateInfo;
-typedef struct VkPipelineShaderStageCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineShaderStageCreateFlags      flags;
-    VkShaderStageFlagBits    stage;
-    VkShaderModule           module;
-    const  char *             pName;
-    const  VkSpecializationInfo *  pSpecializationInfo;
-} VkPipelineShaderStageCreateInfo;
-typedef struct VkComputePipelineCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCreateFlags    flags;
-    VkPipelineShaderStageCreateInfo   stage;
-    VkPipelineLayout         layout;
-    VkPipeline        basePipelineHandle;
-    int32_t                  basePipelineIndex;
-} VkComputePipelineCreateInfo;
-typedef struct VkPipelineVertexInputStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineVertexInputStateCreateFlags      flags;
-    uint32_t                 vertexBindingDescriptionCount;
-    const  VkVertexInputBindingDescription *  pVertexBindingDescriptions;
-    uint32_t                 vertexAttributeDescriptionCount;
-    const  VkVertexInputAttributeDescription *  pVertexAttributeDescriptions;
-} VkPipelineVertexInputStateCreateInfo;
-typedef struct VkPipelineInputAssemblyStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineInputAssemblyStateCreateFlags      flags;
-    VkPrimitiveTopology      topology;
-    VkBool32                 primitiveRestartEnable;
-} VkPipelineInputAssemblyStateCreateInfo;
-typedef struct VkPipelineTessellationStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineTessellationStateCreateFlags      flags;
-    uint32_t                 patchControlPoints;
-} VkPipelineTessellationStateCreateInfo;
-typedef struct VkPipelineViewportStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineViewportStateCreateFlags      flags;
-    uint32_t                 viewportCount;
-    const  VkViewport *       pViewports;
-    uint32_t                 scissorCount;
-    const  VkRect2D *         pScissors;
-} VkPipelineViewportStateCreateInfo;
-typedef struct VkPipelineRasterizationStateCreateInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkPipelineRasterizationStateCreateFlags      flags;
-    VkBool32                 depthClampEnable;
-    VkBool32                 rasterizerDiscardEnable;
-    VkPolygonMode            polygonMode;
-    VkCullModeFlags          cullMode;
-    VkFrontFace              frontFace;
-    VkBool32                 depthBiasEnable;
-    float                    depthBiasConstantFactor;
-    float                    depthBiasClamp;
-    float                    depthBiasSlopeFactor;
-    float                    lineWidth;
-} VkPipelineRasterizationStateCreateInfo;
-typedef struct VkPipelineMultisampleStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineMultisampleStateCreateFlags      flags;
-    VkSampleCountFlagBits    rasterizationSamples;
-    VkBool32                 sampleShadingEnable;
-    float                    minSampleShading;
-    const  VkSampleMask *     pSampleMask;
-    VkBool32                 alphaToCoverageEnable;
-    VkBool32                 alphaToOneEnable;
-} VkPipelineMultisampleStateCreateInfo;
-typedef struct VkPipelineColorBlendAttachmentState {
-    VkBool32                 blendEnable;
-    VkBlendFactor            srcColorBlendFactor;
-    VkBlendFactor            dstColorBlendFactor;
-    VkBlendOp                colorBlendOp;
-    VkBlendFactor            srcAlphaBlendFactor;
-    VkBlendFactor            dstAlphaBlendFactor;
-    VkBlendOp                alphaBlendOp;
-    VkColorComponentFlags    colorWriteMask;
-} VkPipelineColorBlendAttachmentState;
-typedef struct VkPipelineColorBlendStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineColorBlendStateCreateFlags      flags;
-    VkBool32                 logicOpEnable;
-    VkLogicOp                logicOp;
-    uint32_t                 attachmentCount;
-    const  VkPipelineColorBlendAttachmentState *  pAttachments;
-    float                    blendConstants [4];
-} VkPipelineColorBlendStateCreateInfo;
-typedef struct VkPipelineDynamicStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineDynamicStateCreateFlags      flags;
-    uint32_t                 dynamicStateCount;
-    const  VkDynamicState *   pDynamicStates;
-} VkPipelineDynamicStateCreateInfo;
-typedef struct VkPipelineDepthStencilStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineDepthStencilStateCreateFlags      flags;
-    VkBool32                 depthTestEnable;
-    VkBool32                 depthWriteEnable;
-    VkCompareOp              depthCompareOp;
-    VkBool32                 depthBoundsTestEnable;
-    VkBool32                 stencilTestEnable;
-    VkStencilOpState         front;
-    VkStencilOpState         back;
-    float                    minDepthBounds;
-    float                    maxDepthBounds;
-} VkPipelineDepthStencilStateCreateInfo;
-typedef struct VkGraphicsPipelineCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCreateFlags    flags;
-    uint32_t                 stageCount;
-    const  VkPipelineShaderStageCreateInfo *  pStages;
-    const  VkPipelineVertexInputStateCreateInfo *  pVertexInputState;
-    const  VkPipelineInputAssemblyStateCreateInfo *  pInputAssemblyState;
-    const  VkPipelineTessellationStateCreateInfo *  pTessellationState;
-    const  VkPipelineViewportStateCreateInfo *  pViewportState;
-    const  VkPipelineRasterizationStateCreateInfo *  pRasterizationState;
-    const  VkPipelineMultisampleStateCreateInfo *  pMultisampleState;
-    const  VkPipelineDepthStencilStateCreateInfo *  pDepthStencilState;
-    const  VkPipelineColorBlendStateCreateInfo *  pColorBlendState;
-    const  VkPipelineDynamicStateCreateInfo *  pDynamicState;
-    VkPipelineLayout         layout;
-    VkRenderPass             renderPass;
-    uint32_t                 subpass;
-    VkPipeline        basePipelineHandle;
-    int32_t                  basePipelineIndex;
-} VkGraphicsPipelineCreateInfo;
-typedef struct VkPipelineCacheCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCacheCreateFlags      flags;
-    size_t                   initialDataSize;
-    const  void *             pInitialData;
-} VkPipelineCacheCreateInfo;
-typedef struct VkPushConstantRange {
-    VkShaderStageFlags       stageFlags;
-    uint32_t                 offset;
-    uint32_t                 size;
-} VkPushConstantRange;
-typedef struct VkPipelineLayoutCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineLayoutCreateFlags      flags;
-    uint32_t                 setLayoutCount;
-    const  VkDescriptorSetLayout *  pSetLayouts;
-    uint32_t                 pushConstantRangeCount;
-    const  VkPushConstantRange *  pPushConstantRanges;
-} VkPipelineLayoutCreateInfo;
-typedef struct VkSamplerCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkSamplerCreateFlags     flags;
-    VkFilter                 magFilter;
-    VkFilter                 minFilter;
-    VkSamplerMipmapMode      mipmapMode;
-    VkSamplerAddressMode     addressModeU;
-    VkSamplerAddressMode     addressModeV;
-    VkSamplerAddressMode     addressModeW;
-    float                    mipLodBias;
-    VkBool32                 anisotropyEnable;
-    float                    maxAnisotropy;
-    VkBool32                 compareEnable;
-    VkCompareOp              compareOp;
-    float                    minLod;
-    float                    maxLod;
-    VkBorderColor            borderColor;
-    VkBool32                 unnormalizedCoordinates;
-} VkSamplerCreateInfo;
-typedef struct VkCommandPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandPoolCreateFlags     flags;
-    uint32_t                 queueFamilyIndex;
-} VkCommandPoolCreateInfo;
-typedef struct VkCommandBufferInheritanceInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPass      renderPass;
-    uint32_t                 subpass;
-    VkFramebuffer     framebuffer;
-    VkBool32                 occlusionQueryEnable;
-    VkQueryControlFlags      queryFlags;
-    VkQueryPipelineStatisticFlags   pipelineStatistics;
-} VkCommandBufferInheritanceInfo;
-typedef struct VkCommandBufferBeginInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandBufferUsageFlags    flags;
-    const  VkCommandBufferInheritanceInfo *        pInheritanceInfo;
-} VkCommandBufferBeginInfo;
-typedef struct VkRenderPassBeginInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPass             renderPass;
-    VkFramebuffer            framebuffer;
-    VkRect2D                 renderArea;
-    uint32_t                 clearValueCount;
-    const  VkClearValue *     pClearValues;
-} VkRenderPassBeginInfo;
-typedef struct VkClearAttachment {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 colorAttachment;
-    VkClearValue             clearValue;
-} VkClearAttachment;
-typedef struct VkAttachmentDescription {
-    VkAttachmentDescriptionFlags   flags;
-    VkFormat                 format;
-    VkSampleCountFlagBits    samples;
-    VkAttachmentLoadOp       loadOp;
-    VkAttachmentStoreOp      storeOp;
-    VkAttachmentLoadOp       stencilLoadOp;
-    VkAttachmentStoreOp      stencilStoreOp;
-    VkImageLayout            initialLayout;
-    VkImageLayout            finalLayout;
-} VkAttachmentDescription;
-typedef struct VkSubpassDescription {
-    VkSubpassDescriptionFlags   flags;
-    VkPipelineBindPoint      pipelineBindPoint;
-    uint32_t                 inputAttachmentCount;
-    const  VkAttachmentReference *  pInputAttachments;
-    uint32_t                 colorAttachmentCount;
-    const  VkAttachmentReference *  pColorAttachments;
-    const  VkAttachmentReference *  pResolveAttachments;
-    const  VkAttachmentReference *  pDepthStencilAttachment;
-    uint32_t                 preserveAttachmentCount;
-    const  uint32_t *  pPreserveAttachments;
-} VkSubpassDescription;
-typedef struct VkSubpassDependency {
-    uint32_t                 srcSubpass;
-    uint32_t                 dstSubpass;
-    VkPipelineStageFlags     srcStageMask;
-    VkPipelineStageFlags     dstStageMask;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    VkDependencyFlags        dependencyFlags;
-} VkSubpassDependency;
-typedef struct VkRenderPassCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPassCreateFlags      flags;
-    uint32_t     attachmentCount;
-    const  VkAttachmentDescription *  pAttachments;
-    uint32_t                 subpassCount;
-    const  VkSubpassDescription *  pSubpasses;
-    uint32_t         dependencyCount;
-    const  VkSubpassDependency *  pDependencies;
-} VkRenderPassCreateInfo;
-typedef struct VkEventCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkEventCreateFlags       flags;
-} VkEventCreateInfo;
-typedef struct VkFenceCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkFenceCreateFlags       flags;
-} VkFenceCreateInfo;
-typedef struct VkPhysicalDeviceFeatures {
-    VkBool32                 robustBufferAccess;
-    VkBool32                 fullDrawIndexUint32;
-    VkBool32                 imageCubeArray;
-    VkBool32                 independentBlend;
-    VkBool32                 geometryShader;
-    VkBool32                 tessellationShader;
-    VkBool32                 sampleRateShading;
-    VkBool32                 dualSrcBlend;
-    VkBool32                 logicOp;
-    VkBool32                 multiDrawIndirect;
-    VkBool32                 drawIndirectFirstInstance;
-    VkBool32                 depthClamp;
-    VkBool32                 depthBiasClamp;
-    VkBool32                 fillModeNonSolid;
-    VkBool32                 depthBounds;
-    VkBool32                 wideLines;
-    VkBool32                 largePoints;
-    VkBool32                 alphaToOne;
-    VkBool32                 multiViewport;
-    VkBool32                 samplerAnisotropy;
-    VkBool32                 textureCompressionETC2;
-    VkBool32                 textureCompressionASTC_LDR;
-    VkBool32                 textureCompressionBC;
-    VkBool32                 occlusionQueryPrecise;
-    VkBool32                 pipelineStatisticsQuery;
-    VkBool32                 vertexPipelineStoresAndAtomics;
-    VkBool32                 fragmentStoresAndAtomics;
-    VkBool32                 shaderTessellationAndGeometryPointSize;
-    VkBool32                 shaderImageGatherExtended;
-    VkBool32                 shaderStorageImageExtendedFormats;
-    VkBool32                 shaderStorageImageMultisample;
-    VkBool32                 shaderStorageImageReadWithoutFormat;
-    VkBool32                 shaderStorageImageWriteWithoutFormat;
-    VkBool32                 shaderUniformBufferArrayDynamicIndexing;
-    VkBool32                 shaderSampledImageArrayDynamicIndexing;
-    VkBool32                 shaderStorageBufferArrayDynamicIndexing;
-    VkBool32                 shaderStorageImageArrayDynamicIndexing;
-    VkBool32                 shaderClipDistance;
-    VkBool32                 shaderCullDistance;
-    VkBool32                 shaderFloat64;
-    VkBool32                 shaderInt64;
-    VkBool32                 shaderInt16;
-    VkBool32                 shaderResourceResidency;
-    VkBool32                 shaderResourceMinLod;
-    VkBool32                 sparseBinding;
-    VkBool32                 sparseResidencyBuffer;
-    VkBool32                 sparseResidencyImage2D;
-    VkBool32                 sparseResidencyImage3D;
-    VkBool32                 sparseResidency2Samples;
-    VkBool32                 sparseResidency4Samples;
-    VkBool32                 sparseResidency8Samples;
-    VkBool32                 sparseResidency16Samples;
-    VkBool32                 sparseResidencyAliased;
-    VkBool32                 variableMultisampleRate;
-    VkBool32                 inheritedQueries;
-} VkPhysicalDeviceFeatures;
-typedef struct VkPhysicalDeviceSparseProperties {
-    VkBool32                 residencyStandard2DBlockShape;
-    VkBool32                 residencyStandard2DMultisampleBlockShape;
-    VkBool32                 residencyStandard3DBlockShape;
-    VkBool32                 residencyAlignedMipSize;
-    VkBool32                 residencyNonResidentStrict;
-} VkPhysicalDeviceSparseProperties;
-typedef struct VkPhysicalDeviceLimits {
-    uint32_t                 maxImageDimension1D;
-    uint32_t                 maxImageDimension2D;
-    uint32_t                 maxImageDimension3D;
-    uint32_t                 maxImageDimensionCube;
-    uint32_t                 maxImageArrayLayers;
-    uint32_t                 maxTexelBufferElements;
-    uint32_t                 maxUniformBufferRange;
-    uint32_t                 maxStorageBufferRange;
-    uint32_t                 maxPushConstantsSize;
-    uint32_t                 maxMemoryAllocationCount;
-    uint32_t                 maxSamplerAllocationCount;
-    VkDeviceSize             bufferImageGranularity;
-    VkDeviceSize             sparseAddressSpaceSize;
-    uint32_t                 maxBoundDescriptorSets;
-    uint32_t                 maxPerStageDescriptorSamplers;
-    uint32_t                 maxPerStageDescriptorUniformBuffers;
-    uint32_t                 maxPerStageDescriptorStorageBuffers;
-    uint32_t                 maxPerStageDescriptorSampledImages;
-    uint32_t                 maxPerStageDescriptorStorageImages;
-    uint32_t                 maxPerStageDescriptorInputAttachments;
-    uint32_t                 maxPerStageResources;
-    uint32_t                 maxDescriptorSetSamplers;
-    uint32_t                 maxDescriptorSetUniformBuffers;
-    uint32_t                 maxDescriptorSetUniformBuffersDynamic;
-    uint32_t                 maxDescriptorSetStorageBuffers;
-    uint32_t                 maxDescriptorSetStorageBuffersDynamic;
-    uint32_t                 maxDescriptorSetSampledImages;
-    uint32_t                 maxDescriptorSetStorageImages;
-    uint32_t                 maxDescriptorSetInputAttachments;
-    uint32_t                 maxVertexInputAttributes;
-    uint32_t                 maxVertexInputBindings;
-    uint32_t                 maxVertexInputAttributeOffset;
-    uint32_t                 maxVertexInputBindingStride;
-    uint32_t                 maxVertexOutputComponents;
-    uint32_t                 maxTessellationGenerationLevel;
-    uint32_t                 maxTessellationPatchSize;
-    uint32_t                 maxTessellationControlPerVertexInputComponents;
-    uint32_t                 maxTessellationControlPerVertexOutputComponents;
-    uint32_t                 maxTessellationControlPerPatchOutputComponents;
-    uint32_t                 maxTessellationControlTotalOutputComponents;
-    uint32_t                 maxTessellationEvaluationInputComponents;
-    uint32_t                 maxTessellationEvaluationOutputComponents;
-    uint32_t                 maxGeometryShaderInvocations;
-    uint32_t                 maxGeometryInputComponents;
-    uint32_t                 maxGeometryOutputComponents;
-    uint32_t                 maxGeometryOutputVertices;
-    uint32_t                 maxGeometryTotalOutputComponents;
-    uint32_t                 maxFragmentInputComponents;
-    uint32_t                 maxFragmentOutputAttachments;
-    uint32_t                 maxFragmentDualSrcAttachments;
-    uint32_t                 maxFragmentCombinedOutputResources;
-    uint32_t                 maxComputeSharedMemorySize;
-    uint32_t                 maxComputeWorkGroupCount [3];
-    uint32_t                 maxComputeWorkGroupInvocations;
-    uint32_t                 maxComputeWorkGroupSize [3];
-    uint32_t                 subPixelPrecisionBits;
-    uint32_t                 subTexelPrecisionBits;
-    uint32_t                 mipmapPrecisionBits;
-    uint32_t                 maxDrawIndexedIndexValue;
-    uint32_t                 maxDrawIndirectCount;
-    float                    maxSamplerLodBias;
-    float                    maxSamplerAnisotropy;
-    uint32_t                 maxViewports;
-    uint32_t                 maxViewportDimensions [2];
-    float                    viewportBoundsRange [2];
-    uint32_t                 viewportSubPixelBits;
-    size_t                   minMemoryMapAlignment;
-    VkDeviceSize             minTexelBufferOffsetAlignment;
-    VkDeviceSize             minUniformBufferOffsetAlignment;
-    VkDeviceSize             minStorageBufferOffsetAlignment;
-    int32_t                  minTexelOffset;
-    uint32_t                 maxTexelOffset;
-    int32_t                  minTexelGatherOffset;
-    uint32_t                 maxTexelGatherOffset;
-    float                    minInterpolationOffset;
-    float                    maxInterpolationOffset;
-    uint32_t                 subPixelInterpolationOffsetBits;
-    uint32_t                 maxFramebufferWidth;
-    uint32_t                 maxFramebufferHeight;
-    uint32_t                 maxFramebufferLayers;
-    VkSampleCountFlags       framebufferColorSampleCounts;
-    VkSampleCountFlags       framebufferDepthSampleCounts;
-    VkSampleCountFlags       framebufferStencilSampleCounts;
-    VkSampleCountFlags       framebufferNoAttachmentsSampleCounts;
-    uint32_t                 maxColorAttachments;
-    VkSampleCountFlags       sampledImageColorSampleCounts;
-    VkSampleCountFlags       sampledImageIntegerSampleCounts;
-    VkSampleCountFlags       sampledImageDepthSampleCounts;
-    VkSampleCountFlags       sampledImageStencilSampleCounts;
-    VkSampleCountFlags       storageImageSampleCounts;
-    uint32_t                 maxSampleMaskWords;
-    VkBool32                 timestampComputeAndGraphics;
-    float                    timestampPeriod;
-    uint32_t                 maxClipDistances;
-    uint32_t                 maxCullDistances;
-    uint32_t                 maxCombinedClipAndCullDistances;
-    uint32_t                 discreteQueuePriorities;
-    float                    pointSizeRange [2];
-    float                    lineWidthRange [2];
-    float                    pointSizeGranularity;
-    float                    lineWidthGranularity;
-    VkBool32                 strictLines;
-    VkBool32                 standardSampleLocations;
-    VkDeviceSize             optimalBufferCopyOffsetAlignment;
-    VkDeviceSize             optimalBufferCopyRowPitchAlignment;
-    VkDeviceSize             nonCoherentAtomSize;
-} VkPhysicalDeviceLimits;
-typedef struct VkSemaphoreCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkSemaphoreCreateFlags   flags;
-} VkSemaphoreCreateInfo;
-typedef struct VkQueryPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkQueryPoolCreateFlags   flags;
-    VkQueryType              queryType;
-    uint32_t                 queryCount;
-    VkQueryPipelineStatisticFlags   pipelineStatistics;
-} VkQueryPoolCreateInfo;
-typedef struct VkFramebufferCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkFramebufferCreateFlags      flags;
-    VkRenderPass             renderPass;
-    uint32_t                 attachmentCount;
-    const  VkImageView *      pAttachments;
-    uint32_t                 width;
-    uint32_t                 height;
-    uint32_t                 layers;
-} VkFramebufferCreateInfo;
-typedef struct VkSubmitInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    uint32_t         waitSemaphoreCount;
-    const  VkSemaphore *      pWaitSemaphores;
-    const  VkPipelineStageFlags *            pWaitDstStageMask;
-    uint32_t         commandBufferCount;
-    const  VkCommandBuffer *      pCommandBuffers;
-    uint32_t         signalSemaphoreCount;
-    const  VkSemaphore *      pSignalSemaphores;
-} VkSubmitInfo;
-typedef struct VkSurfaceCapabilitiesKHR {
-    uint32_t                           minImageCount;
-    uint32_t                           maxImageCount;
-    VkExtent2D                         currentExtent;
-    VkExtent2D                         minImageExtent;
-    VkExtent2D                         maxImageExtent;
-    uint32_t                           maxImageArrayLayers;
-    VkSurfaceTransformFlagsKHR         supportedTransforms;
-    VkSurfaceTransformFlagBitsKHR      currentTransform;
-    VkCompositeAlphaFlagsKHR           supportedCompositeAlpha;
-    VkImageUsageFlags                  supportedUsageFlags;
-} VkSurfaceCapabilitiesKHR;
-typedef struct VkSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainCreateFlagsKHR          flags;
-    VkSurfaceKHR                       surface;
-    uint32_t                           minImageCount;
-    VkFormat                           imageFormat;
-    VkColorSpaceKHR                    imageColorSpace;
-    VkExtent2D                         imageExtent;
-    uint32_t                           imageArrayLayers;
-    VkImageUsageFlags                  imageUsage;
-    VkSharingMode                      imageSharingMode;
-    uint32_t           queueFamilyIndexCount;
-    const  uint32_t *                   pQueueFamilyIndices;
-    VkSurfaceTransformFlagBitsKHR      preTransform;
-    VkCompositeAlphaFlagBitsKHR        compositeAlpha;
-    VkPresentModeKHR                   presentMode;
-    VkBool32                           clipped;
-    VkSwapchainKHR     oldSwapchain;
-} VkSwapchainCreateInfoKHR;
-typedef struct VkDebugReportCallbackCreateInfoEXT {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkDebugReportFlagsEXT              flags;
-    PFN_vkDebugReportCallbackEXT       pfnCallback;
-    void *             pUserData;
-} VkDebugReportCallbackCreateInfoEXT;
-typedef struct VkPhysicalDeviceFeatures2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceFeatures           features;
-} VkPhysicalDeviceFeatures2;
-typedef struct VkFormatProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkFormatProperties                 formatProperties;
-} VkFormatProperties2;
-typedef struct VkImageFormatProperties2 {
-    VkStructureType   sType;
-    void *  pNext;
-    VkImageFormatProperties            imageFormatProperties;
-} VkImageFormatProperties2;
-typedef struct VkPhysicalDeviceImageFormatInfo2 {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkFormat                           format;
-    VkImageType                        type;
-    VkImageTiling                      tiling;
-    VkImageUsageFlags                  usage;
-    VkImageCreateFlags   flags;
-} VkPhysicalDeviceImageFormatInfo2;
-typedef struct VkQueueFamilyProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkQueueFamilyProperties            queueFamilyProperties;
-} VkQueueFamilyProperties2;
-typedef struct VkSparseImageFormatProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkSparseImageFormatProperties      properties;
-} VkSparseImageFormatProperties2;
-typedef struct VkPhysicalDeviceSparseImageFormatInfo2 {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkFormat                           format;
-    VkImageType                        type;
-    VkSampleCountFlagBits              samples;
-    VkImageUsageFlags                  usage;
-    VkImageTiling                      tiling;
-} VkPhysicalDeviceSparseImageFormatInfo2;
-typedef struct VkPhysicalDeviceVariablePointersFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           variablePointersStorageBuffer;
-    VkBool32                           variablePointers;
-} VkPhysicalDeviceVariablePointersFeatures;
-typedef struct VkPhysicalDeviceVariablePointerFeatures  VkPhysicalDeviceVariablePointerFeatures;
-typedef struct VkExternalMemoryProperties {
-    VkExternalMemoryFeatureFlags    externalMemoryFeatures;
-    VkExternalMemoryHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalMemoryHandleTypeFlags   compatibleHandleTypes;
-} VkExternalMemoryProperties;
-typedef struct VkExternalImageFormatProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalMemoryProperties   externalMemoryProperties;
-} VkExternalImageFormatProperties;
-typedef struct VkPhysicalDeviceExternalBufferInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkBufferCreateFlags   flags;
-    VkBufferUsageFlags                 usage;
-    VkExternalMemoryHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalBufferInfo;
-typedef struct VkExternalBufferProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalMemoryProperties      externalMemoryProperties;
-} VkExternalBufferProperties;
-typedef struct VkPhysicalDeviceIDProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint8_t                            deviceUUID [ VK_UUID_SIZE ];
-    uint8_t                            driverUUID [ VK_UUID_SIZE ];
-    uint8_t                            deviceLUID [ VK_LUID_SIZE ];
-    uint32_t                           deviceNodeMask;
-    VkBool32                           deviceLUIDValid;
-} VkPhysicalDeviceIDProperties;
-typedef struct VkExternalMemoryImageCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExternalMemoryImageCreateInfo;
-typedef struct VkExternalMemoryBufferCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExternalMemoryBufferCreateInfo;
-typedef struct VkExportMemoryAllocateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExportMemoryAllocateInfo;
-typedef struct VkExternalSemaphoreProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalSemaphoreHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalSemaphoreHandleTypeFlags   compatibleHandleTypes;
-    VkExternalSemaphoreFeatureFlags   externalSemaphoreFeatures;
-} VkExternalSemaphoreProperties;
-typedef struct VkExportSemaphoreCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalSemaphoreHandleTypeFlags   handleTypes;
-} VkExportSemaphoreCreateInfo;
-typedef struct VkExternalFenceProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalFenceHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalFenceHandleTypeFlags   compatibleHandleTypes;
-    VkExternalFenceFeatureFlags   externalFenceFeatures;
-} VkExternalFenceProperties;
-typedef struct VkExportFenceCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalFenceHandleTypeFlags   handleTypes;
-} VkExportFenceCreateInfo;
-typedef struct VkPhysicalDeviceMultiviewFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           multiview;
-    VkBool32                           multiviewGeometryShader;
-    VkBool32                           multiviewTessellationShader;
-} VkPhysicalDeviceMultiviewFeatures;
-typedef struct VkPhysicalDeviceGroupProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           physicalDeviceCount;
-    VkPhysicalDevice                   physicalDevices [ VK_MAX_DEVICE_GROUP_SIZE ];
-    VkBool32                           subsetAllocation;
-} VkPhysicalDeviceGroupProperties;
-typedef struct VkMemoryAllocateFlagsInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkMemoryAllocateFlags   flags;
-    uint32_t                           deviceMask;
-} VkMemoryAllocateFlagsInfo;
-typedef struct VkBindBufferMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkBuffer                           buffer;
-    VkDeviceMemory                     memory;
-    VkDeviceSize                       memoryOffset;
-} VkBindBufferMemoryInfo;
-typedef struct VkBindImageMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImage                            image;
-    VkDeviceMemory                     memory;
-    VkDeviceSize                       memoryOffset;
-} VkBindImageMemoryInfo;
-typedef struct VkDeviceGroupPresentCapabilitiesKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           presentMask [ VK_MAX_DEVICE_GROUP_SIZE ];
-    VkDeviceGroupPresentModeFlagsKHR   modes;
-} VkDeviceGroupPresentCapabilitiesKHR;
-typedef struct VkDeviceGroupSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkDeviceGroupPresentModeFlagsKHR                           modes;
-} VkDeviceGroupSwapchainCreateInfoKHR;
-typedef struct VkDescriptorUpdateTemplateCreateInfo {
-    VkStructureType   sType;
-    const  void *                                pNext;
-    VkDescriptorUpdateTemplateCreateFlags      flags;
-    uint32_t                   descriptorUpdateEntryCount;
-    const  VkDescriptorUpdateTemplateEntry *  pDescriptorUpdateEntries;
-    VkDescriptorUpdateTemplateType   templateType;
-    VkDescriptorSetLayout   descriptorSetLayout;
-    VkPipelineBindPoint   pipelineBindPoint;
-    VkPipelineLayout pipelineLayout;
-    uint32_t   set;
-} VkDescriptorUpdateTemplateCreateInfo;
-typedef struct VkInputAttachmentAspectReference {
-    uint32_t                          subpass;
-    uint32_t                          inputAttachmentIndex;
-    VkImageAspectFlags                aspectMask;
-} VkInputAttachmentAspectReference;
-typedef struct VkRenderPassInputAttachmentAspectCreateInfo {
-    VkStructureType   sType;
-    const  void *                      pNext;
-    uint32_t                          aspectReferenceCount;
-    const  VkInputAttachmentAspectReference *  pAspectReferences;
-} VkRenderPassInputAttachmentAspectCreateInfo;
-typedef struct VkPhysicalDevice16BitStorageFeatures {
-    VkStructureType   sType;
-    void *       pNext;
-    VkBool32                           storageBuffer16BitAccess;
-    VkBool32                           uniformAndStorageBuffer16BitAccess;
-    VkBool32                           storagePushConstant16;
-    VkBool32                           storageInputOutput16;
-} VkPhysicalDevice16BitStorageFeatures;
-typedef struct VkPhysicalDeviceSubgroupProperties {
-    VkStructureType   sType;
-    void *                    pNext;
-    uint32_t                        subgroupSize;
-    VkShaderStageFlags              supportedStages;
-    VkSubgroupFeatureFlags          supportedOperations;
-    VkBool32   quadOperationsInAllStages;
-} VkPhysicalDeviceSubgroupProperties;
-typedef struct VkMemoryRequirements2 {
-    VkStructureType   sType;
-    void *  pNext;
-    VkMemoryRequirements                                                   memoryRequirements;
-} VkMemoryRequirements2;
-typedef struct VkMemoryRequirements2KHR  VkMemoryRequirements2KHR;
-typedef struct VkSparseImageMemoryRequirements2 {
-    VkStructureType   sType;
-    void *                                        pNext;
-    VkSparseImageMemoryRequirements                                        memoryRequirements;
-} VkSparseImageMemoryRequirements2;
-typedef struct VkMemoryDedicatedRequirements {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           prefersDedicatedAllocation;
-    VkBool32                           requiresDedicatedAllocation;
-} VkMemoryDedicatedRequirements;
-typedef struct VkImageViewUsageCreateInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkImageUsageFlags   usage;
-} VkImageViewUsageCreateInfo;
-typedef struct VkSamplerYcbcrConversionCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkFormat                           format;
-    VkSamplerYcbcrModelConversion   ycbcrModel;
-    VkSamplerYcbcrRange             ycbcrRange;
-    VkComponentMapping                 components;
-    VkChromaLocation                xChromaOffset;
-    VkChromaLocation                yChromaOffset;
-    VkFilter                           chromaFilter;
-    VkBool32                           forceExplicitReconstruction;
-} VkSamplerYcbcrConversionCreateInfo;
-typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures {
-    VkStructureType   sType;
-    void *       pNext;
-    VkBool32                           samplerYcbcrConversion;
-} VkPhysicalDeviceSamplerYcbcrConversionFeatures;
-typedef struct VkProtectedSubmitInfo {
-    VkStructureType   sType;
-    const  void *                      pNext;
-    VkBool32                          protectedSubmit;
-} VkProtectedSubmitInfo;
-typedef struct VkPhysicalDeviceProtectedMemoryFeatures {
-    VkStructureType   sType;
-    void *                                pNext;
-    VkBool32                              protectedMemory;
-} VkPhysicalDeviceProtectedMemoryFeatures;
-typedef struct VkPhysicalDeviceProtectedMemoryProperties {
-    VkStructureType   sType;
-    void *                                pNext;
-    VkBool32                              protectedNoFault;
-} VkPhysicalDeviceProtectedMemoryProperties;
-typedef struct VkDeviceQueueInfo2 {
-    VkStructureType   sType;
-    const  void *                          pNext;
-    VkDeviceQueueCreateFlags              flags;
-    uint32_t                              queueFamilyIndex;
-    uint32_t                              queueIndex;
-} VkDeviceQueueInfo2;
-typedef struct VkPhysicalDeviceMaintenance3Properties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           maxPerSetDescriptors;
-    VkDeviceSize                       maxMemoryAllocationSize;
-} VkPhysicalDeviceMaintenance3Properties;
-typedef struct VkDescriptorSetLayoutSupport {
-    VkStructureType   sType;
-    void *             pNext;
-    VkBool32           supported;
-} VkDescriptorSetLayoutSupport;
-typedef struct VkPhysicalDeviceShaderDrawParametersFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           shaderDrawParameters;
-} VkPhysicalDeviceShaderDrawParametersFeatures;
-typedef struct VkPhysicalDeviceShaderDrawParameterFeatures  VkPhysicalDeviceShaderDrawParameterFeatures;
-typedef struct VkPhysicalDeviceProperties {
-    uint32_t         apiVersion;
-    uint32_t         driverVersion;
-    uint32_t         vendorID;
-    uint32_t         deviceID;
-    VkPhysicalDeviceType   deviceType;
-    char             deviceName [ VK_MAX_PHYSICAL_DEVICE_NAME_SIZE ];
-    uint8_t          pipelineCacheUUID [ VK_UUID_SIZE ];
-    VkPhysicalDeviceLimits   limits;
-    VkPhysicalDeviceSparseProperties   sparseProperties;
-} VkPhysicalDeviceProperties;
-typedef struct VkDeviceCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkDeviceCreateFlags      flags;
-    uint32_t          queueCreateInfoCount;
-    const  VkDeviceQueueCreateInfo *  pQueueCreateInfos;
-    uint32_t                 enabledLayerCount;
-    const  char * const*       ppEnabledLayerNames;
-    uint32_t                 enabledExtensionCount;
-    const  char * const*       ppEnabledExtensionNames;
-    const  VkPhysicalDeviceFeatures *  pEnabledFeatures;
-} VkDeviceCreateInfo;
-typedef struct VkPhysicalDeviceMemoryProperties {
-    uint32_t                 memoryTypeCount;
-    VkMemoryType             memoryTypes [ VK_MAX_MEMORY_TYPES ];
-    uint32_t                 memoryHeapCount;
-    VkMemoryHeap             memoryHeaps [ VK_MAX_MEMORY_HEAPS ];
-} VkPhysicalDeviceMemoryProperties;
-typedef struct VkPhysicalDeviceProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceProperties         properties;
-} VkPhysicalDeviceProperties2;
-typedef struct VkPhysicalDeviceMemoryProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceMemoryProperties   memoryProperties;
-} VkPhysicalDeviceMemoryProperties2;
-
-
-#define VK_VERSION_1_0 1
-GLAD_API_CALL int GLAD_VK_VERSION_1_0;
-#define VK_VERSION_1_1 1
-GLAD_API_CALL int GLAD_VK_VERSION_1_1;
-#define VK_EXT_debug_report 1
-GLAD_API_CALL int GLAD_VK_EXT_debug_report;
-#define VK_KHR_surface 1
-GLAD_API_CALL int GLAD_VK_KHR_surface;
-#define VK_KHR_swapchain 1
-GLAD_API_CALL int GLAD_VK_KHR_swapchain;
-
-
-typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice   device, const  VkAcquireNextImageInfoKHR *  pAcquireInfo, uint32_t *  pImageIndex);
-typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImageKHR)(VkDevice   device, VkSwapchainKHR   swapchain, uint64_t   timeout, VkSemaphore   semaphore, VkFence   fence, uint32_t *  pImageIndex);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateCommandBuffers)(VkDevice   device, const  VkCommandBufferAllocateInfo *  pAllocateInfo, VkCommandBuffer *  pCommandBuffers);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateDescriptorSets)(VkDevice   device, const  VkDescriptorSetAllocateInfo *  pAllocateInfo, VkDescriptorSet *  pDescriptorSets);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateMemory)(VkDevice   device, const  VkMemoryAllocateInfo *  pAllocateInfo, const  VkAllocationCallbacks *  pAllocator, VkDeviceMemory *  pMemory);
-typedef VkResult (GLAD_API_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer   commandBuffer, const  VkCommandBufferBeginInfo *  pBeginInfo);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory)(VkDevice   device, VkBuffer   buffer, VkDeviceMemory   memory, VkDeviceSize   memoryOffset);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory2)(VkDevice   device, uint32_t   bindInfoCount, const  VkBindBufferMemoryInfo *  pBindInfos);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory)(VkDevice   device, VkImage   image, VkDeviceMemory   memory, VkDeviceSize   memoryOffset);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory2)(VkDevice   device, uint32_t   bindInfoCount, const  VkBindImageMemoryInfo *  pBindInfos);
-typedef void (GLAD_API_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   query, VkQueryControlFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer   commandBuffer, const  VkRenderPassBeginInfo *  pRenderPassBegin, VkSubpassContents   contents);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer   commandBuffer, VkPipelineBindPoint   pipelineBindPoint, VkPipelineLayout   layout, uint32_t   firstSet, uint32_t   descriptorSetCount, const  VkDescriptorSet *  pDescriptorSets, uint32_t   dynamicOffsetCount, const  uint32_t *  pDynamicOffsets);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, VkIndexType   indexType);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer   commandBuffer, VkPipelineBindPoint   pipelineBindPoint, VkPipeline   pipeline);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer   commandBuffer, uint32_t   firstBinding, uint32_t   bindingCount, const  VkBuffer *  pBuffers, const  VkDeviceSize *  pOffsets);
-typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageBlit *  pRegions, VkFilter   filter);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer   commandBuffer, uint32_t   attachmentCount, const  VkClearAttachment *  pAttachments, uint32_t   rectCount, const  VkClearRect *  pRects);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer   commandBuffer, VkImage   image, VkImageLayout   imageLayout, const  VkClearColorValue *  pColor, uint32_t   rangeCount, const  VkImageSubresourceRange *  pRanges);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer   commandBuffer, VkImage   image, VkImageLayout   imageLayout, const  VkClearDepthStencilValue *  pDepthStencil, uint32_t   rangeCount, const  VkImageSubresourceRange *  pRanges);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   srcBuffer, VkBuffer   dstBuffer, uint32_t   regionCount, const  VkBufferCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer   commandBuffer, VkBuffer   srcBuffer, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkBufferImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkBuffer   dstBuffer, uint32_t   regionCount, const  VkBufferImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   stride, VkQueryResultFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatch)(VkCommandBuffer   commandBuffer, uint32_t   groupCountX, uint32_t   groupCountY, uint32_t   groupCountZ);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer   commandBuffer, uint32_t   baseGroupX, uint32_t   baseGroupY, uint32_t   baseGroupZ, uint32_t   groupCountX, uint32_t   groupCountY, uint32_t   groupCountZ);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset);
-typedef void (GLAD_API_PTR *PFN_vkCmdDraw)(VkCommandBuffer   commandBuffer, uint32_t   vertexCount, uint32_t   instanceCount, uint32_t   firstVertex, uint32_t   firstInstance);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer   commandBuffer, uint32_t   indexCount, uint32_t   instanceCount, uint32_t   firstIndex, int32_t   vertexOffset, uint32_t   firstInstance);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, uint32_t   drawCount, uint32_t   stride);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, uint32_t   drawCount, uint32_t   stride);
-typedef void (GLAD_API_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   query);
-typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer   commandBuffer);
-typedef void (GLAD_API_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer   commandBuffer, uint32_t   commandBufferCount, const  VkCommandBuffer *  pCommandBuffers);
-typedef void (GLAD_API_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   size, uint32_t   data);
-typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer   commandBuffer, VkSubpassContents   contents);
-typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer   commandBuffer, VkPipelineStageFlags   srcStageMask, VkPipelineStageFlags   dstStageMask, VkDependencyFlags   dependencyFlags, uint32_t   memoryBarrierCount, const  VkMemoryBarrier *  pMemoryBarriers, uint32_t   bufferMemoryBarrierCount, const  VkBufferMemoryBarrier *  pBufferMemoryBarriers, uint32_t   imageMemoryBarrierCount, const  VkImageMemoryBarrier *  pImageMemoryBarriers);
-typedef void (GLAD_API_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer   commandBuffer, VkPipelineLayout   layout, VkShaderStageFlags   stageFlags, uint32_t   offset, uint32_t   size, const  void *  pValues);
-typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer   commandBuffer, VkEvent   event, VkPipelineStageFlags   stageMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount);
-typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageResolve *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer   commandBuffer, const  float   blendConstants [4]);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer   commandBuffer, float   depthBiasConstantFactor, float   depthBiasClamp, float   depthBiasSlopeFactor);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer   commandBuffer, float   minDepthBounds, float   maxDepthBounds);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer   commandBuffer, uint32_t   deviceMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer   commandBuffer, VkEvent   event, VkPipelineStageFlags   stageMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer   commandBuffer, float   lineWidth);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer   commandBuffer, uint32_t   firstScissor, uint32_t   scissorCount, const  VkRect2D *  pScissors);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   compareMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   reference);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   writeMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer   commandBuffer, uint32_t   firstViewport, uint32_t   viewportCount, const  VkViewport *  pViewports);
-typedef void (GLAD_API_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   dataSize, const  void *  pData);
-typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer   commandBuffer, uint32_t   eventCount, const  VkEvent *  pEvents, VkPipelineStageFlags   srcStageMask, VkPipelineStageFlags   dstStageMask, uint32_t   memoryBarrierCount, const  VkMemoryBarrier *  pMemoryBarriers, uint32_t   bufferMemoryBarrierCount, const  VkBufferMemoryBarrier *  pBufferMemoryBarriers, uint32_t   imageMemoryBarrierCount, const  VkImageMemoryBarrier *  pImageMemoryBarriers);
-typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer   commandBuffer, VkPipelineStageFlagBits   pipelineStage, VkQueryPool   queryPool, uint32_t   query);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateBuffer)(VkDevice   device, const  VkBufferCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkBuffer *  pBuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateBufferView)(VkDevice   device, const  VkBufferViewCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkBufferView *  pView);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateCommandPool)(VkDevice   device, const  VkCommandPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkCommandPool *  pCommandPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateComputePipelines)(VkDevice   device, VkPipelineCache   pipelineCache, uint32_t   createInfoCount, const  VkComputePipelineCreateInfo *  pCreateInfos, const  VkAllocationCallbacks *  pAllocator, VkPipeline *  pPipelines);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance   instance, const  VkDebugReportCallbackCreateInfoEXT *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDebugReportCallbackEXT *  pCallback);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorPool)(VkDevice   device, const  VkDescriptorPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorPool *  pDescriptorPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice   device, const  VkDescriptorSetLayoutCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorSetLayout *  pSetLayout);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice   device, const  VkDescriptorUpdateTemplateCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorUpdateTemplate *  pDescriptorUpdateTemplate);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDevice)(VkPhysicalDevice   physicalDevice, const  VkDeviceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDevice *  pDevice);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateEvent)(VkDevice   device, const  VkEventCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkEvent *  pEvent);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateFence)(VkDevice   device, const  VkFenceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkFence *  pFence);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateFramebuffer)(VkDevice   device, const  VkFramebufferCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkFramebuffer *  pFramebuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice   device, VkPipelineCache   pipelineCache, uint32_t   createInfoCount, const  VkGraphicsPipelineCreateInfo *  pCreateInfos, const  VkAllocationCallbacks *  pAllocator, VkPipeline *  pPipelines);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateImage)(VkDevice   device, const  VkImageCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkImage *  pImage);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateImageView)(VkDevice   device, const  VkImageViewCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkImageView *  pView);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateInstance)(const  VkInstanceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkInstance *  pInstance);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineCache)(VkDevice   device, const  VkPipelineCacheCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkPipelineCache *  pPipelineCache);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineLayout)(VkDevice   device, const  VkPipelineLayoutCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkPipelineLayout *  pPipelineLayout);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateQueryPool)(VkDevice   device, const  VkQueryPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkQueryPool *  pQueryPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass)(VkDevice   device, const  VkRenderPassCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkRenderPass *  pRenderPass);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSampler)(VkDevice   device, const  VkSamplerCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSampler *  pSampler);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice   device, const  VkSamplerYcbcrConversionCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSamplerYcbcrConversion *  pYcbcrConversion);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSemaphore)(VkDevice   device, const  VkSemaphoreCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSemaphore *  pSemaphore);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateShaderModule)(VkDevice   device, const  VkShaderModuleCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkShaderModule *  pShaderModule);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSwapchainKHR)(VkDevice   device, const  VkSwapchainCreateInfoKHR *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSwapchainKHR *  pSwapchain);
-typedef void (GLAD_API_PTR *PFN_vkDebugReportMessageEXT)(VkInstance   instance, VkDebugReportFlagsEXT   flags, VkDebugReportObjectTypeEXT   objectType, uint64_t   object, size_t   location, int32_t   messageCode, const  char *  pLayerPrefix, const  char *  pMessage);
-typedef void (GLAD_API_PTR *PFN_vkDestroyBuffer)(VkDevice   device, VkBuffer   buffer, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyBufferView)(VkDevice   device, VkBufferView   bufferView, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyCommandPool)(VkDevice   device, VkCommandPool   commandPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance   instance, VkDebugReportCallbackEXT   callback, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorPool)(VkDevice   device, VkDescriptorPool   descriptorPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice   device, VkDescriptorSetLayout   descriptorSetLayout, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice   device, VkDescriptorUpdateTemplate   descriptorUpdateTemplate, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDevice)(VkDevice   device, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyEvent)(VkDevice   device, VkEvent   event, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyFence)(VkDevice   device, VkFence   fence, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyFramebuffer)(VkDevice   device, VkFramebuffer   framebuffer, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyImage)(VkDevice   device, VkImage   image, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyImageView)(VkDevice   device, VkImageView   imageView, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyInstance)(VkInstance   instance, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipeline)(VkDevice   device, VkPipeline   pipeline, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineCache)(VkDevice   device, VkPipelineCache   pipelineCache, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineLayout)(VkDevice   device, VkPipelineLayout   pipelineLayout, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyQueryPool)(VkDevice   device, VkQueryPool   queryPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyRenderPass)(VkDevice   device, VkRenderPass   renderPass, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySampler)(VkDevice   device, VkSampler   sampler, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice   device, VkSamplerYcbcrConversion   ycbcrConversion, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySemaphore)(VkDevice   device, VkSemaphore   semaphore, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyShaderModule)(VkDevice   device, VkShaderModule   shaderModule, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySurfaceKHR)(VkInstance   instance, VkSurfaceKHR   surface, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySwapchainKHR)(VkDevice   device, VkSwapchainKHR   swapchain, const  VkAllocationCallbacks *  pAllocator);
-typedef VkResult (GLAD_API_PTR *PFN_vkDeviceWaitIdle)(VkDevice   device);
-typedef VkResult (GLAD_API_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer   commandBuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice   physicalDevice, const  char *  pLayerName, uint32_t *  pPropertyCount, VkExtensionProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice   physicalDevice, uint32_t *  pPropertyCount, VkLayerProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const  char *  pLayerName, uint32_t *  pPropertyCount, VkExtensionProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t *  pPropertyCount, VkLayerProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t *  pApiVersion);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance   instance, uint32_t *  pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *  pPhysicalDeviceGroupProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance   instance, uint32_t *  pPhysicalDeviceCount, VkPhysicalDevice *  pPhysicalDevices);
-typedef VkResult (GLAD_API_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice   device, uint32_t   memoryRangeCount, const  VkMappedMemoryRange *  pMemoryRanges);
-typedef void (GLAD_API_PTR *PFN_vkFreeCommandBuffers)(VkDevice   device, VkCommandPool   commandPool, uint32_t   commandBufferCount, const  VkCommandBuffer *  pCommandBuffers);
-typedef VkResult (GLAD_API_PTR *PFN_vkFreeDescriptorSets)(VkDevice   device, VkDescriptorPool   descriptorPool, uint32_t   descriptorSetCount, const  VkDescriptorSet *  pDescriptorSets);
-typedef void (GLAD_API_PTR *PFN_vkFreeMemory)(VkDevice   device, VkDeviceMemory   memory, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice   device, VkBuffer   buffer, VkMemoryRequirements *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice   device, const  VkBufferMemoryRequirementsInfo2 *  pInfo, VkMemoryRequirements2 *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice   device, const  VkDescriptorSetLayoutCreateInfo *  pCreateInfo, VkDescriptorSetLayoutSupport *  pSupport);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice   device, uint32_t   heapIndex, uint32_t   localDeviceIndex, uint32_t   remoteDeviceIndex, VkPeerMemoryFeatureFlags *  pPeerMemoryFeatures);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice   device, VkDeviceGroupPresentCapabilitiesKHR *  pDeviceGroupPresentCapabilities);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice   device, VkSurfaceKHR   surface, VkDeviceGroupPresentModeFlagsKHR *  pModes);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice   device, VkDeviceMemory   memory, VkDeviceSize *  pCommittedMemoryInBytes);
-typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetDeviceProcAddr)(VkDevice   device, const  char *  pName);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue)(VkDevice   device, uint32_t   queueFamilyIndex, uint32_t   queueIndex, VkQueue *  pQueue);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue2)(VkDevice   device, const  VkDeviceQueueInfo2 *  pQueueInfo, VkQueue *  pQueue);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetEventStatus)(VkDevice   device, VkEvent   event);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetFenceStatus)(VkDevice   device, VkFence   fence);
-typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice   device, VkImage   image, VkMemoryRequirements *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice   device, const  VkImageMemoryRequirementsInfo2 *  pInfo, VkMemoryRequirements2 *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice   device, VkImage   image, uint32_t *  pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *  pSparseMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice   device, const  VkImageSparseMemoryRequirementsInfo2 *  pInfo, uint32_t *  pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 *  pSparseMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice   device, VkImage   image, const  VkImageSubresource *  pSubresource, VkSubresourceLayout *  pLayout);
-typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetInstanceProcAddr)(VkInstance   instance, const  char *  pName);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalBufferInfo *  pExternalBufferInfo, VkExternalBufferProperties *  pExternalBufferProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalFenceInfo *  pExternalFenceInfo, VkExternalFenceProperties *  pExternalFenceProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalSemaphoreInfo *  pExternalSemaphoreInfo, VkExternalSemaphoreProperties *  pExternalSemaphoreProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceFeatures *  pFeatures);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceFeatures2 *  pFeatures);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkFormatProperties *  pFormatProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkFormatProperties2 *  pFormatProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkImageType   type, VkImageTiling   tiling, VkImageUsageFlags   usage, VkImageCreateFlags   flags, VkImageFormatProperties *  pImageFormatProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceImageFormatInfo2 *  pImageFormatInfo, VkImageFormatProperties2 *  pImageFormatProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceMemoryProperties *  pMemoryProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceMemoryProperties2 *  pMemoryProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pRectCount, VkRect2D *  pRects);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceProperties *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceProperties2 *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice   physicalDevice, uint32_t *  pQueueFamilyPropertyCount, VkQueueFamilyProperties *  pQueueFamilyProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice   physicalDevice, uint32_t *  pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *  pQueueFamilyProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkImageType   type, VkSampleCountFlagBits   samples, VkImageUsageFlags   usage, VkImageTiling   tiling, uint32_t *  pPropertyCount, VkSparseImageFormatProperties *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceSparseImageFormatInfo2 *  pFormatInfo, uint32_t *  pPropertyCount, VkSparseImageFormatProperties2 *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, VkSurfaceCapabilitiesKHR *  pSurfaceCapabilities);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pSurfaceFormatCount, VkSurfaceFormatKHR *  pSurfaceFormats);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pPresentModeCount, VkPresentModeKHR *  pPresentModes);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice   physicalDevice, uint32_t   queueFamilyIndex, VkSurfaceKHR   surface, VkBool32 *  pSupported);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPipelineCacheData)(VkDevice   device, VkPipelineCache   pipelineCache, size_t *  pDataSize, void *  pData);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetQueryPoolResults)(VkDevice   device, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount, size_t   dataSize, void *  pData, VkDeviceSize   stride, VkQueryResultFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice   device, VkRenderPass   renderPass, VkExtent2D *  pGranularity);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice   device, VkSwapchainKHR   swapchain, uint32_t *  pSwapchainImageCount, VkImage *  pSwapchainImages);
-typedef VkResult (GLAD_API_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice   device, uint32_t   memoryRangeCount, const  VkMappedMemoryRange *  pMemoryRanges);
-typedef VkResult (GLAD_API_PTR *PFN_vkMapMemory)(VkDevice   device, VkDeviceMemory   memory, VkDeviceSize   offset, VkDeviceSize   size, VkMemoryMapFlags   flags, void **  ppData);
-typedef VkResult (GLAD_API_PTR *PFN_vkMergePipelineCaches)(VkDevice   device, VkPipelineCache   dstCache, uint32_t   srcCacheCount, const  VkPipelineCache *  pSrcCaches);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueBindSparse)(VkQueue   queue, uint32_t   bindInfoCount, const  VkBindSparseInfo *  pBindInfo, VkFence   fence);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueuePresentKHR)(VkQueue   queue, const  VkPresentInfoKHR *  pPresentInfo);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit)(VkQueue   queue, uint32_t   submitCount, const  VkSubmitInfo *  pSubmits, VkFence   fence);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueWaitIdle)(VkQueue   queue);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer   commandBuffer, VkCommandBufferResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandPool)(VkDevice   device, VkCommandPool   commandPool, VkCommandPoolResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetDescriptorPool)(VkDevice   device, VkDescriptorPool   descriptorPool, VkDescriptorPoolResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetEvent)(VkDevice   device, VkEvent   event);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetFences)(VkDevice   device, uint32_t   fenceCount, const  VkFence *  pFences);
-typedef VkResult (GLAD_API_PTR *PFN_vkSetEvent)(VkDevice   device, VkEvent   event);
-typedef void (GLAD_API_PTR *PFN_vkTrimCommandPool)(VkDevice   device, VkCommandPool   commandPool, VkCommandPoolTrimFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkUnmapMemory)(VkDevice   device, VkDeviceMemory   memory);
-typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice   device, VkDescriptorSet   descriptorSet, VkDescriptorUpdateTemplate   descriptorUpdateTemplate, const  void *  pData);
-typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSets)(VkDevice   device, uint32_t   descriptorWriteCount, const  VkWriteDescriptorSet *  pDescriptorWrites, uint32_t   descriptorCopyCount, const  VkCopyDescriptorSet *  pDescriptorCopies);
-typedef VkResult (GLAD_API_PTR *PFN_vkWaitForFences)(VkDevice   device, uint32_t   fenceCount, const  VkFence *  pFences, VkBool32   waitAll, uint64_t   timeout);
-
-GLAD_API_CALL PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR;
-#define vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR
-GLAD_API_CALL PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR;
-#define vkAcquireNextImageKHR glad_vkAcquireNextImageKHR
-GLAD_API_CALL PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers;
-#define vkAllocateCommandBuffers glad_vkAllocateCommandBuffers
-GLAD_API_CALL PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets;
-#define vkAllocateDescriptorSets glad_vkAllocateDescriptorSets
-GLAD_API_CALL PFN_vkAllocateMemory glad_vkAllocateMemory;
-#define vkAllocateMemory glad_vkAllocateMemory
-GLAD_API_CALL PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer;
-#define vkBeginCommandBuffer glad_vkBeginCommandBuffer
-GLAD_API_CALL PFN_vkBindBufferMemory glad_vkBindBufferMemory;
-#define vkBindBufferMemory glad_vkBindBufferMemory
-GLAD_API_CALL PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2;
-#define vkBindBufferMemory2 glad_vkBindBufferMemory2
-GLAD_API_CALL PFN_vkBindImageMemory glad_vkBindImageMemory;
-#define vkBindImageMemory glad_vkBindImageMemory
-GLAD_API_CALL PFN_vkBindImageMemory2 glad_vkBindImageMemory2;
-#define vkBindImageMemory2 glad_vkBindImageMemory2
-GLAD_API_CALL PFN_vkCmdBeginQuery glad_vkCmdBeginQuery;
-#define vkCmdBeginQuery glad_vkCmdBeginQuery
-GLAD_API_CALL PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass;
-#define vkCmdBeginRenderPass glad_vkCmdBeginRenderPass
-GLAD_API_CALL PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets;
-#define vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets
-GLAD_API_CALL PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer;
-#define vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer
-GLAD_API_CALL PFN_vkCmdBindPipeline glad_vkCmdBindPipeline;
-#define vkCmdBindPipeline glad_vkCmdBindPipeline
-GLAD_API_CALL PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers;
-#define vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers
-GLAD_API_CALL PFN_vkCmdBlitImage glad_vkCmdBlitImage;
-#define vkCmdBlitImage glad_vkCmdBlitImage
-GLAD_API_CALL PFN_vkCmdClearAttachments glad_vkCmdClearAttachments;
-#define vkCmdClearAttachments glad_vkCmdClearAttachments
-GLAD_API_CALL PFN_vkCmdClearColorImage glad_vkCmdClearColorImage;
-#define vkCmdClearColorImage glad_vkCmdClearColorImage
-GLAD_API_CALL PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage;
-#define vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage
-GLAD_API_CALL PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer;
-#define vkCmdCopyBuffer glad_vkCmdCopyBuffer
-GLAD_API_CALL PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage;
-#define vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage
-GLAD_API_CALL PFN_vkCmdCopyImage glad_vkCmdCopyImage;
-#define vkCmdCopyImage glad_vkCmdCopyImage
-GLAD_API_CALL PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer;
-#define vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer
-GLAD_API_CALL PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults;
-#define vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults
-GLAD_API_CALL PFN_vkCmdDispatch glad_vkCmdDispatch;
-#define vkCmdDispatch glad_vkCmdDispatch
-GLAD_API_CALL PFN_vkCmdDispatchBase glad_vkCmdDispatchBase;
-#define vkCmdDispatchBase glad_vkCmdDispatchBase
-GLAD_API_CALL PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect;
-#define vkCmdDispatchIndirect glad_vkCmdDispatchIndirect
-GLAD_API_CALL PFN_vkCmdDraw glad_vkCmdDraw;
-#define vkCmdDraw glad_vkCmdDraw
-GLAD_API_CALL PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed;
-#define vkCmdDrawIndexed glad_vkCmdDrawIndexed
-GLAD_API_CALL PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect;
-#define vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect
-GLAD_API_CALL PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect;
-#define vkCmdDrawIndirect glad_vkCmdDrawIndirect
-GLAD_API_CALL PFN_vkCmdEndQuery glad_vkCmdEndQuery;
-#define vkCmdEndQuery glad_vkCmdEndQuery
-GLAD_API_CALL PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass;
-#define vkCmdEndRenderPass glad_vkCmdEndRenderPass
-GLAD_API_CALL PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands;
-#define vkCmdExecuteCommands glad_vkCmdExecuteCommands
-GLAD_API_CALL PFN_vkCmdFillBuffer glad_vkCmdFillBuffer;
-#define vkCmdFillBuffer glad_vkCmdFillBuffer
-GLAD_API_CALL PFN_vkCmdNextSubpass glad_vkCmdNextSubpass;
-#define vkCmdNextSubpass glad_vkCmdNextSubpass
-GLAD_API_CALL PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier;
-#define vkCmdPipelineBarrier glad_vkCmdPipelineBarrier
-GLAD_API_CALL PFN_vkCmdPushConstants glad_vkCmdPushConstants;
-#define vkCmdPushConstants glad_vkCmdPushConstants
-GLAD_API_CALL PFN_vkCmdResetEvent glad_vkCmdResetEvent;
-#define vkCmdResetEvent glad_vkCmdResetEvent
-GLAD_API_CALL PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool;
-#define vkCmdResetQueryPool glad_vkCmdResetQueryPool
-GLAD_API_CALL PFN_vkCmdResolveImage glad_vkCmdResolveImage;
-#define vkCmdResolveImage glad_vkCmdResolveImage
-GLAD_API_CALL PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants;
-#define vkCmdSetBlendConstants glad_vkCmdSetBlendConstants
-GLAD_API_CALL PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias;
-#define vkCmdSetDepthBias glad_vkCmdSetDepthBias
-GLAD_API_CALL PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds;
-#define vkCmdSetDepthBounds glad_vkCmdSetDepthBounds
-GLAD_API_CALL PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask;
-#define vkCmdSetDeviceMask glad_vkCmdSetDeviceMask
-GLAD_API_CALL PFN_vkCmdSetEvent glad_vkCmdSetEvent;
-#define vkCmdSetEvent glad_vkCmdSetEvent
-GLAD_API_CALL PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth;
-#define vkCmdSetLineWidth glad_vkCmdSetLineWidth
-GLAD_API_CALL PFN_vkCmdSetScissor glad_vkCmdSetScissor;
-#define vkCmdSetScissor glad_vkCmdSetScissor
-GLAD_API_CALL PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask;
-#define vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask
-GLAD_API_CALL PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference;
-#define vkCmdSetStencilReference glad_vkCmdSetStencilReference
-GLAD_API_CALL PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask;
-#define vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask
-GLAD_API_CALL PFN_vkCmdSetViewport glad_vkCmdSetViewport;
-#define vkCmdSetViewport glad_vkCmdSetViewport
-GLAD_API_CALL PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer;
-#define vkCmdUpdateBuffer glad_vkCmdUpdateBuffer
-GLAD_API_CALL PFN_vkCmdWaitEvents glad_vkCmdWaitEvents;
-#define vkCmdWaitEvents glad_vkCmdWaitEvents
-GLAD_API_CALL PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp;
-#define vkCmdWriteTimestamp glad_vkCmdWriteTimestamp
-GLAD_API_CALL PFN_vkCreateBuffer glad_vkCreateBuffer;
-#define vkCreateBuffer glad_vkCreateBuffer
-GLAD_API_CALL PFN_vkCreateBufferView glad_vkCreateBufferView;
-#define vkCreateBufferView glad_vkCreateBufferView
-GLAD_API_CALL PFN_vkCreateCommandPool glad_vkCreateCommandPool;
-#define vkCreateCommandPool glad_vkCreateCommandPool
-GLAD_API_CALL PFN_vkCreateComputePipelines glad_vkCreateComputePipelines;
-#define vkCreateComputePipelines glad_vkCreateComputePipelines
-GLAD_API_CALL PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT;
-#define vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT
-GLAD_API_CALL PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool;
-#define vkCreateDescriptorPool glad_vkCreateDescriptorPool
-GLAD_API_CALL PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout;
-#define vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout
-GLAD_API_CALL PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate;
-#define vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate
-GLAD_API_CALL PFN_vkCreateDevice glad_vkCreateDevice;
-#define vkCreateDevice glad_vkCreateDevice
-GLAD_API_CALL PFN_vkCreateEvent glad_vkCreateEvent;
-#define vkCreateEvent glad_vkCreateEvent
-GLAD_API_CALL PFN_vkCreateFence glad_vkCreateFence;
-#define vkCreateFence glad_vkCreateFence
-GLAD_API_CALL PFN_vkCreateFramebuffer glad_vkCreateFramebuffer;
-#define vkCreateFramebuffer glad_vkCreateFramebuffer
-GLAD_API_CALL PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines;
-#define vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines
-GLAD_API_CALL PFN_vkCreateImage glad_vkCreateImage;
-#define vkCreateImage glad_vkCreateImage
-GLAD_API_CALL PFN_vkCreateImageView glad_vkCreateImageView;
-#define vkCreateImageView glad_vkCreateImageView
-GLAD_API_CALL PFN_vkCreateInstance glad_vkCreateInstance;
-#define vkCreateInstance glad_vkCreateInstance
-GLAD_API_CALL PFN_vkCreatePipelineCache glad_vkCreatePipelineCache;
-#define vkCreatePipelineCache glad_vkCreatePipelineCache
-GLAD_API_CALL PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout;
-#define vkCreatePipelineLayout glad_vkCreatePipelineLayout
-GLAD_API_CALL PFN_vkCreateQueryPool glad_vkCreateQueryPool;
-#define vkCreateQueryPool glad_vkCreateQueryPool
-GLAD_API_CALL PFN_vkCreateRenderPass glad_vkCreateRenderPass;
-#define vkCreateRenderPass glad_vkCreateRenderPass
-GLAD_API_CALL PFN_vkCreateSampler glad_vkCreateSampler;
-#define vkCreateSampler glad_vkCreateSampler
-GLAD_API_CALL PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion;
-#define vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion
-GLAD_API_CALL PFN_vkCreateSemaphore glad_vkCreateSemaphore;
-#define vkCreateSemaphore glad_vkCreateSemaphore
-GLAD_API_CALL PFN_vkCreateShaderModule glad_vkCreateShaderModule;
-#define vkCreateShaderModule glad_vkCreateShaderModule
-GLAD_API_CALL PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR;
-#define vkCreateSwapchainKHR glad_vkCreateSwapchainKHR
-GLAD_API_CALL PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT;
-#define vkDebugReportMessageEXT glad_vkDebugReportMessageEXT
-GLAD_API_CALL PFN_vkDestroyBuffer glad_vkDestroyBuffer;
-#define vkDestroyBuffer glad_vkDestroyBuffer
-GLAD_API_CALL PFN_vkDestroyBufferView glad_vkDestroyBufferView;
-#define vkDestroyBufferView glad_vkDestroyBufferView
-GLAD_API_CALL PFN_vkDestroyCommandPool glad_vkDestroyCommandPool;
-#define vkDestroyCommandPool glad_vkDestroyCommandPool
-GLAD_API_CALL PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT;
-#define vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT
-GLAD_API_CALL PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool;
-#define vkDestroyDescriptorPool glad_vkDestroyDescriptorPool
-GLAD_API_CALL PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout;
-#define vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout
-GLAD_API_CALL PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate;
-#define vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate
-GLAD_API_CALL PFN_vkDestroyDevice glad_vkDestroyDevice;
-#define vkDestroyDevice glad_vkDestroyDevice
-GLAD_API_CALL PFN_vkDestroyEvent glad_vkDestroyEvent;
-#define vkDestroyEvent glad_vkDestroyEvent
-GLAD_API_CALL PFN_vkDestroyFence glad_vkDestroyFence;
-#define vkDestroyFence glad_vkDestroyFence
-GLAD_API_CALL PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer;
-#define vkDestroyFramebuffer glad_vkDestroyFramebuffer
-GLAD_API_CALL PFN_vkDestroyImage glad_vkDestroyImage;
-#define vkDestroyImage glad_vkDestroyImage
-GLAD_API_CALL PFN_vkDestroyImageView glad_vkDestroyImageView;
-#define vkDestroyImageView glad_vkDestroyImageView
-GLAD_API_CALL PFN_vkDestroyInstance glad_vkDestroyInstance;
-#define vkDestroyInstance glad_vkDestroyInstance
-GLAD_API_CALL PFN_vkDestroyPipeline glad_vkDestroyPipeline;
-#define vkDestroyPipeline glad_vkDestroyPipeline
-GLAD_API_CALL PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache;
-#define vkDestroyPipelineCache glad_vkDestroyPipelineCache
-GLAD_API_CALL PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout;
-#define vkDestroyPipelineLayout glad_vkDestroyPipelineLayout
-GLAD_API_CALL PFN_vkDestroyQueryPool glad_vkDestroyQueryPool;
-#define vkDestroyQueryPool glad_vkDestroyQueryPool
-GLAD_API_CALL PFN_vkDestroyRenderPass glad_vkDestroyRenderPass;
-#define vkDestroyRenderPass glad_vkDestroyRenderPass
-GLAD_API_CALL PFN_vkDestroySampler glad_vkDestroySampler;
-#define vkDestroySampler glad_vkDestroySampler
-GLAD_API_CALL PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion;
-#define vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion
-GLAD_API_CALL PFN_vkDestroySemaphore glad_vkDestroySemaphore;
-#define vkDestroySemaphore glad_vkDestroySemaphore
-GLAD_API_CALL PFN_vkDestroyShaderModule glad_vkDestroyShaderModule;
-#define vkDestroyShaderModule glad_vkDestroyShaderModule
-GLAD_API_CALL PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR;
-#define vkDestroySurfaceKHR glad_vkDestroySurfaceKHR
-GLAD_API_CALL PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR;
-#define vkDestroySwapchainKHR glad_vkDestroySwapchainKHR
-GLAD_API_CALL PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle;
-#define vkDeviceWaitIdle glad_vkDeviceWaitIdle
-GLAD_API_CALL PFN_vkEndCommandBuffer glad_vkEndCommandBuffer;
-#define vkEndCommandBuffer glad_vkEndCommandBuffer
-GLAD_API_CALL PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties;
-#define vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties
-GLAD_API_CALL PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties;
-#define vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties;
-#define vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties;
-#define vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion;
-#define vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion
-GLAD_API_CALL PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups;
-#define vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups
-GLAD_API_CALL PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices;
-#define vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices
-GLAD_API_CALL PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges;
-#define vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges
-GLAD_API_CALL PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers;
-#define vkFreeCommandBuffers glad_vkFreeCommandBuffers
-GLAD_API_CALL PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets;
-#define vkFreeDescriptorSets glad_vkFreeDescriptorSets
-GLAD_API_CALL PFN_vkFreeMemory glad_vkFreeMemory;
-#define vkFreeMemory glad_vkFreeMemory
-GLAD_API_CALL PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements;
-#define vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements
-GLAD_API_CALL PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2;
-#define vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2
-GLAD_API_CALL PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport;
-#define vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport
-GLAD_API_CALL PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures;
-#define vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures
-GLAD_API_CALL PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR;
-#define vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR
-GLAD_API_CALL PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR;
-#define vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR
-GLAD_API_CALL PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment;
-#define vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment
-GLAD_API_CALL PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr;
-#define vkGetDeviceProcAddr glad_vkGetDeviceProcAddr
-GLAD_API_CALL PFN_vkGetDeviceQueue glad_vkGetDeviceQueue;
-#define vkGetDeviceQueue glad_vkGetDeviceQueue
-GLAD_API_CALL PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2;
-#define vkGetDeviceQueue2 glad_vkGetDeviceQueue2
-GLAD_API_CALL PFN_vkGetEventStatus glad_vkGetEventStatus;
-#define vkGetEventStatus glad_vkGetEventStatus
-GLAD_API_CALL PFN_vkGetFenceStatus glad_vkGetFenceStatus;
-#define vkGetFenceStatus glad_vkGetFenceStatus
-GLAD_API_CALL PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements;
-#define vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements
-GLAD_API_CALL PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2;
-#define vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2
-GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements;
-#define vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements
-GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2;
-#define vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2
-GLAD_API_CALL PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout;
-#define vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout
-GLAD_API_CALL PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr;
-#define vkGetInstanceProcAddr glad_vkGetInstanceProcAddr
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties;
-#define vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties;
-#define vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties;
-#define vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures;
-#define vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2;
-#define vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties;
-#define vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2;
-#define vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties;
-#define vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2;
-#define vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties;
-#define vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2;
-#define vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR;
-#define vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties;
-#define vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2;
-#define vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties;
-#define vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2;
-#define vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties;
-#define vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2;
-#define vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
-#define vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR;
-#define vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR;
-#define vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR;
-#define vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR
-GLAD_API_CALL PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData;
-#define vkGetPipelineCacheData glad_vkGetPipelineCacheData
-GLAD_API_CALL PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults;
-#define vkGetQueryPoolResults glad_vkGetQueryPoolResults
-GLAD_API_CALL PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity;
-#define vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity
-GLAD_API_CALL PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR;
-#define vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR
-GLAD_API_CALL PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges;
-#define vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges
-GLAD_API_CALL PFN_vkMapMemory glad_vkMapMemory;
-#define vkMapMemory glad_vkMapMemory
-GLAD_API_CALL PFN_vkMergePipelineCaches glad_vkMergePipelineCaches;
-#define vkMergePipelineCaches glad_vkMergePipelineCaches
-GLAD_API_CALL PFN_vkQueueBindSparse glad_vkQueueBindSparse;
-#define vkQueueBindSparse glad_vkQueueBindSparse
-GLAD_API_CALL PFN_vkQueuePresentKHR glad_vkQueuePresentKHR;
-#define vkQueuePresentKHR glad_vkQueuePresentKHR
-GLAD_API_CALL PFN_vkQueueSubmit glad_vkQueueSubmit;
-#define vkQueueSubmit glad_vkQueueSubmit
-GLAD_API_CALL PFN_vkQueueWaitIdle glad_vkQueueWaitIdle;
-#define vkQueueWaitIdle glad_vkQueueWaitIdle
-GLAD_API_CALL PFN_vkResetCommandBuffer glad_vkResetCommandBuffer;
-#define vkResetCommandBuffer glad_vkResetCommandBuffer
-GLAD_API_CALL PFN_vkResetCommandPool glad_vkResetCommandPool;
-#define vkResetCommandPool glad_vkResetCommandPool
-GLAD_API_CALL PFN_vkResetDescriptorPool glad_vkResetDescriptorPool;
-#define vkResetDescriptorPool glad_vkResetDescriptorPool
-GLAD_API_CALL PFN_vkResetEvent glad_vkResetEvent;
-#define vkResetEvent glad_vkResetEvent
-GLAD_API_CALL PFN_vkResetFences glad_vkResetFences;
-#define vkResetFences glad_vkResetFences
-GLAD_API_CALL PFN_vkSetEvent glad_vkSetEvent;
-#define vkSetEvent glad_vkSetEvent
-GLAD_API_CALL PFN_vkTrimCommandPool glad_vkTrimCommandPool;
-#define vkTrimCommandPool glad_vkTrimCommandPool
-GLAD_API_CALL PFN_vkUnmapMemory glad_vkUnmapMemory;
-#define vkUnmapMemory glad_vkUnmapMemory
-GLAD_API_CALL PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate;
-#define vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate
-GLAD_API_CALL PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets;
-#define vkUpdateDescriptorSets glad_vkUpdateDescriptorSets
-GLAD_API_CALL PFN_vkWaitForFences glad_vkWaitForFences;
-#define vkWaitForFences glad_vkWaitForFences
-
-
-GLAD_API_CALL int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr);
-GLAD_API_CALL int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load);
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/raylib/external/glfw/deps/glad_gl.c b/raylib/external/glfw/deps/glad_gl.c
deleted file mode 100644 (file)
index 2d4c87f..0000000
+++ /dev/null
@@ -1,1791 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glad/gl.h>
-
-#ifndef GLAD_IMPL_UTIL_C_
-#define GLAD_IMPL_UTIL_C_
-
-#ifdef _MSC_VER
-#define GLAD_IMPL_UTIL_SSCANF sscanf_s
-#else
-#define GLAD_IMPL_UTIL_SSCANF sscanf
-#endif
-
-#endif /* GLAD_IMPL_UTIL_C_ */
-
-
-int GLAD_GL_VERSION_1_0 = 0;
-int GLAD_GL_VERSION_1_1 = 0;
-int GLAD_GL_VERSION_1_2 = 0;
-int GLAD_GL_VERSION_1_3 = 0;
-int GLAD_GL_VERSION_1_4 = 0;
-int GLAD_GL_VERSION_1_5 = 0;
-int GLAD_GL_VERSION_2_0 = 0;
-int GLAD_GL_VERSION_2_1 = 0;
-int GLAD_GL_VERSION_3_0 = 0;
-int GLAD_GL_VERSION_3_1 = 0;
-int GLAD_GL_VERSION_3_2 = 0;
-int GLAD_GL_VERSION_3_3 = 0;
-int GLAD_GL_ARB_multisample = 0;
-int GLAD_GL_ARB_robustness = 0;
-int GLAD_GL_KHR_debug = 0;
-
-
-
-PFNGLACCUMPROC glad_glAccum = NULL;
-PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
-PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL;
-PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL;
-PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL;
-PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
-PFNGLBEGINPROC glad_glBegin = NULL;
-PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
-PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
-PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
-PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
-PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
-PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
-PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
-PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
-PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
-PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
-PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
-PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
-PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
-PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
-PFNGLBITMAPPROC glad_glBitmap = NULL;
-PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
-PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
-PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
-PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
-PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
-PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
-PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
-PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
-PFNGLCALLLISTPROC glad_glCallList = NULL;
-PFNGLCALLLISTSPROC glad_glCallLists = NULL;
-PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
-PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
-PFNGLCLEARPROC glad_glClear = NULL;
-PFNGLCLEARACCUMPROC glad_glClearAccum = NULL;
-PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
-PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
-PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
-PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
-PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
-PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
-PFNGLCLEARINDEXPROC glad_glClearIndex = NULL;
-PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
-PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL;
-PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
-PFNGLCLIPPLANEPROC glad_glClipPlane = NULL;
-PFNGLCOLOR3BPROC glad_glColor3b = NULL;
-PFNGLCOLOR3BVPROC glad_glColor3bv = NULL;
-PFNGLCOLOR3DPROC glad_glColor3d = NULL;
-PFNGLCOLOR3DVPROC glad_glColor3dv = NULL;
-PFNGLCOLOR3FPROC glad_glColor3f = NULL;
-PFNGLCOLOR3FVPROC glad_glColor3fv = NULL;
-PFNGLCOLOR3IPROC glad_glColor3i = NULL;
-PFNGLCOLOR3IVPROC glad_glColor3iv = NULL;
-PFNGLCOLOR3SPROC glad_glColor3s = NULL;
-PFNGLCOLOR3SVPROC glad_glColor3sv = NULL;
-PFNGLCOLOR3UBPROC glad_glColor3ub = NULL;
-PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL;
-PFNGLCOLOR3UIPROC glad_glColor3ui = NULL;
-PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL;
-PFNGLCOLOR3USPROC glad_glColor3us = NULL;
-PFNGLCOLOR3USVPROC glad_glColor3usv = NULL;
-PFNGLCOLOR4BPROC glad_glColor4b = NULL;
-PFNGLCOLOR4BVPROC glad_glColor4bv = NULL;
-PFNGLCOLOR4DPROC glad_glColor4d = NULL;
-PFNGLCOLOR4DVPROC glad_glColor4dv = NULL;
-PFNGLCOLOR4FPROC glad_glColor4f = NULL;
-PFNGLCOLOR4FVPROC glad_glColor4fv = NULL;
-PFNGLCOLOR4IPROC glad_glColor4i = NULL;
-PFNGLCOLOR4IVPROC glad_glColor4iv = NULL;
-PFNGLCOLOR4SPROC glad_glColor4s = NULL;
-PFNGLCOLOR4SVPROC glad_glColor4sv = NULL;
-PFNGLCOLOR4UBPROC glad_glColor4ub = NULL;
-PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL;
-PFNGLCOLOR4UIPROC glad_glColor4ui = NULL;
-PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL;
-PFNGLCOLOR4USPROC glad_glColor4us = NULL;
-PFNGLCOLOR4USVPROC glad_glColor4usv = NULL;
-PFNGLCOLORMASKPROC glad_glColorMask = NULL;
-PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
-PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL;
-PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL;
-PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL;
-PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL;
-PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL;
-PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL;
-PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
-PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
-PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
-PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
-PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL;
-PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
-PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
-PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
-PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
-PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
-PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
-PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
-PFNGLCULLFACEPROC glad_glCullFace = NULL;
-PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL;
-PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL;
-PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL;
-PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
-PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
-PFNGLDELETELISTSPROC glad_glDeleteLists = NULL;
-PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
-PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
-PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
-PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
-PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
-PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
-PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
-PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
-PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
-PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
-PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
-PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
-PFNGLDISABLEPROC glad_glDisable = NULL;
-PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL;
-PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
-PFNGLDISABLEIPROC glad_glDisablei = NULL;
-PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
-PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
-PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
-PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
-PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
-PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
-PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
-PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
-PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL;
-PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
-PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
-PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL;
-PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL;
-PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL;
-PFNGLENABLEPROC glad_glEnable = NULL;
-PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL;
-PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
-PFNGLENABLEIPROC glad_glEnablei = NULL;
-PFNGLENDPROC glad_glEnd = NULL;
-PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
-PFNGLENDLISTPROC glad_glEndList = NULL;
-PFNGLENDQUERYPROC glad_glEndQuery = NULL;
-PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
-PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL;
-PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL;
-PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL;
-PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL;
-PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL;
-PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL;
-PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL;
-PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL;
-PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL;
-PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL;
-PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL;
-PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL;
-PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL;
-PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
-PFNGLFINISHPROC glad_glFinish = NULL;
-PFNGLFLUSHPROC glad_glFlush = NULL;
-PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
-PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL;
-PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL;
-PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL;
-PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL;
-PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL;
-PFNGLFOGFPROC glad_glFogf = NULL;
-PFNGLFOGFVPROC glad_glFogfv = NULL;
-PFNGLFOGIPROC glad_glFogi = NULL;
-PFNGLFOGIVPROC glad_glFogiv = NULL;
-PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
-PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
-PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
-PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
-PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
-PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
-PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
-PFNGLFRUSTUMPROC glad_glFrustum = NULL;
-PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
-PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
-PFNGLGENLISTSPROC glad_glGenLists = NULL;
-PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
-PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
-PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
-PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
-PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
-PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
-PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
-PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
-PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
-PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
-PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
-PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
-PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
-PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
-PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
-PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
-PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
-PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
-PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
-PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
-PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL;
-PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
-PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL;
-PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
-PFNGLGETERRORPROC glad_glGetError = NULL;
-PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
-PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
-PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
-PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB = NULL;
-PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
-PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
-PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
-PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
-PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL;
-PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL;
-PFNGLGETMAPDVPROC glad_glGetMapdv = NULL;
-PFNGLGETMAPFVPROC glad_glGetMapfv = NULL;
-PFNGLGETMAPIVPROC glad_glGetMapiv = NULL;
-PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL;
-PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL;
-PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
-PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL;
-PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL;
-PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL;
-PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL;
-PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL;
-PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL;
-PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL;
-PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
-PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
-PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
-PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
-PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
-PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
-PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
-PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
-PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
-PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
-PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
-PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
-PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
-PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
-PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
-PFNGLGETSTRINGPROC glad_glGetString = NULL;
-PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
-PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
-PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL;
-PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL;
-PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL;
-PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL;
-PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL;
-PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
-PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
-PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
-PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
-PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
-PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
-PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
-PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
-PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
-PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
-PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
-PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
-PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
-PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
-PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
-PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
-PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
-PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
-PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
-PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
-PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB = NULL;
-PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB = NULL;
-PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB = NULL;
-PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB = NULL;
-PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB = NULL;
-PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB = NULL;
-PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB = NULL;
-PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB = NULL;
-PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB = NULL;
-PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB = NULL;
-PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB = NULL;
-PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB = NULL;
-PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB = NULL;
-PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB = NULL;
-PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB = NULL;
-PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB = NULL;
-PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB = NULL;
-PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB = NULL;
-PFNGLHINTPROC glad_glHint = NULL;
-PFNGLINDEXMASKPROC glad_glIndexMask = NULL;
-PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL;
-PFNGLINDEXDPROC glad_glIndexd = NULL;
-PFNGLINDEXDVPROC glad_glIndexdv = NULL;
-PFNGLINDEXFPROC glad_glIndexf = NULL;
-PFNGLINDEXFVPROC glad_glIndexfv = NULL;
-PFNGLINDEXIPROC glad_glIndexi = NULL;
-PFNGLINDEXIVPROC glad_glIndexiv = NULL;
-PFNGLINDEXSPROC glad_glIndexs = NULL;
-PFNGLINDEXSVPROC glad_glIndexsv = NULL;
-PFNGLINDEXUBPROC glad_glIndexub = NULL;
-PFNGLINDEXUBVPROC glad_glIndexubv = NULL;
-PFNGLINITNAMESPROC glad_glInitNames = NULL;
-PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL;
-PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
-PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
-PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
-PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
-PFNGLISLISTPROC glad_glIsList = NULL;
-PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
-PFNGLISQUERYPROC glad_glIsQuery = NULL;
-PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
-PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
-PFNGLISSHADERPROC glad_glIsShader = NULL;
-PFNGLISSYNCPROC glad_glIsSync = NULL;
-PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
-PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
-PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL;
-PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL;
-PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL;
-PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL;
-PFNGLLIGHTFPROC glad_glLightf = NULL;
-PFNGLLIGHTFVPROC glad_glLightfv = NULL;
-PFNGLLIGHTIPROC glad_glLighti = NULL;
-PFNGLLIGHTIVPROC glad_glLightiv = NULL;
-PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL;
-PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
-PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
-PFNGLLISTBASEPROC glad_glListBase = NULL;
-PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL;
-PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL;
-PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL;
-PFNGLLOADNAMEPROC glad_glLoadName = NULL;
-PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL;
-PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL;
-PFNGLLOGICOPPROC glad_glLogicOp = NULL;
-PFNGLMAP1DPROC glad_glMap1d = NULL;
-PFNGLMAP1FPROC glad_glMap1f = NULL;
-PFNGLMAP2DPROC glad_glMap2d = NULL;
-PFNGLMAP2FPROC glad_glMap2f = NULL;
-PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
-PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
-PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL;
-PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL;
-PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL;
-PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL;
-PFNGLMATERIALFPROC glad_glMaterialf = NULL;
-PFNGLMATERIALFVPROC glad_glMaterialfv = NULL;
-PFNGLMATERIALIPROC glad_glMateriali = NULL;
-PFNGLMATERIALIVPROC glad_glMaterialiv = NULL;
-PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL;
-PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL;
-PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL;
-PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL;
-PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL;
-PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
-PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
-PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
-PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL;
-PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL;
-PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL;
-PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL;
-PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL;
-PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL;
-PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL;
-PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL;
-PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL;
-PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL;
-PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL;
-PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL;
-PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL;
-PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL;
-PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL;
-PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL;
-PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL;
-PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL;
-PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL;
-PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL;
-PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL;
-PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL;
-PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL;
-PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL;
-PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL;
-PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL;
-PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL;
-PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL;
-PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL;
-PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL;
-PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL;
-PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL;
-PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL;
-PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL;
-PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL;
-PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL;
-PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL;
-PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL;
-PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL;
-PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL;
-PFNGLNEWLISTPROC glad_glNewList = NULL;
-PFNGLNORMAL3BPROC glad_glNormal3b = NULL;
-PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL;
-PFNGLNORMAL3DPROC glad_glNormal3d = NULL;
-PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL;
-PFNGLNORMAL3FPROC glad_glNormal3f = NULL;
-PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL;
-PFNGLNORMAL3IPROC glad_glNormal3i = NULL;
-PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL;
-PFNGLNORMAL3SPROC glad_glNormal3s = NULL;
-PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL;
-PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL;
-PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL;
-PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL;
-PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL;
-PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL;
-PFNGLORTHOPROC glad_glOrtho = NULL;
-PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL;
-PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL;
-PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL;
-PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL;
-PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
-PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
-PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL;
-PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL;
-PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL;
-PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
-PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
-PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
-PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
-PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
-PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
-PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
-PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL;
-PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL;
-PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL;
-PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL;
-PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL;
-PFNGLPOPNAMEPROC glad_glPopName = NULL;
-PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
-PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL;
-PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
-PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL;
-PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL;
-PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL;
-PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL;
-PFNGLPUSHNAMEPROC glad_glPushName = NULL;
-PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
-PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL;
-PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL;
-PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL;
-PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL;
-PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL;
-PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL;
-PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL;
-PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL;
-PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL;
-PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL;
-PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL;
-PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL;
-PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL;
-PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL;
-PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL;
-PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL;
-PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL;
-PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL;
-PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL;
-PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL;
-PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL;
-PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL;
-PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL;
-PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL;
-PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
-PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
-PFNGLREADNPIXELSPROC glad_glReadnPixels = NULL;
-PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB = NULL;
-PFNGLRECTDPROC glad_glRectd = NULL;
-PFNGLRECTDVPROC glad_glRectdv = NULL;
-PFNGLRECTFPROC glad_glRectf = NULL;
-PFNGLRECTFVPROC glad_glRectfv = NULL;
-PFNGLRECTIPROC glad_glRecti = NULL;
-PFNGLRECTIVPROC glad_glRectiv = NULL;
-PFNGLRECTSPROC glad_glRects = NULL;
-PFNGLRECTSVPROC glad_glRectsv = NULL;
-PFNGLRENDERMODEPROC glad_glRenderMode = NULL;
-PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
-PFNGLROTATEDPROC glad_glRotated = NULL;
-PFNGLROTATEFPROC glad_glRotatef = NULL;
-PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
-PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL;
-PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
-PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
-PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
-PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
-PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
-PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
-PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
-PFNGLSCALEDPROC glad_glScaled = NULL;
-PFNGLSCALEFPROC glad_glScalef = NULL;
-PFNGLSCISSORPROC glad_glScissor = NULL;
-PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL;
-PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL;
-PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL;
-PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL;
-PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL;
-PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL;
-PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL;
-PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL;
-PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL;
-PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL;
-PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL;
-PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL;
-PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL;
-PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL;
-PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL;
-PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL;
-PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL;
-PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL;
-PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL;
-PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL;
-PFNGLSHADEMODELPROC glad_glShadeModel = NULL;
-PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
-PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
-PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
-PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
-PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
-PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
-PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
-PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
-PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL;
-PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL;
-PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL;
-PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL;
-PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL;
-PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL;
-PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL;
-PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL;
-PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL;
-PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL;
-PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL;
-PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL;
-PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL;
-PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL;
-PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL;
-PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL;
-PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL;
-PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL;
-PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL;
-PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL;
-PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL;
-PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL;
-PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL;
-PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL;
-PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL;
-PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL;
-PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL;
-PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL;
-PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL;
-PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL;
-PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL;
-PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL;
-PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL;
-PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL;
-PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL;
-PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL;
-PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL;
-PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL;
-PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL;
-PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL;
-PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL;
-PFNGLTEXENVFPROC glad_glTexEnvf = NULL;
-PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL;
-PFNGLTEXENVIPROC glad_glTexEnvi = NULL;
-PFNGLTEXENVIVPROC glad_glTexEnviv = NULL;
-PFNGLTEXGENDPROC glad_glTexGend = NULL;
-PFNGLTEXGENDVPROC glad_glTexGendv = NULL;
-PFNGLTEXGENFPROC glad_glTexGenf = NULL;
-PFNGLTEXGENFVPROC glad_glTexGenfv = NULL;
-PFNGLTEXGENIPROC glad_glTexGeni = NULL;
-PFNGLTEXGENIVPROC glad_glTexGeniv = NULL;
-PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
-PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
-PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
-PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
-PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
-PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
-PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
-PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
-PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
-PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
-PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
-PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
-PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
-PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
-PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
-PFNGLTRANSLATEDPROC glad_glTranslated = NULL;
-PFNGLTRANSLATEFPROC glad_glTranslatef = NULL;
-PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
-PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
-PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
-PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
-PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
-PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
-PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
-PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
-PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
-PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
-PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
-PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
-PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
-PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
-PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
-PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
-PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
-PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
-PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
-PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
-PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
-PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
-PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
-PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
-PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
-PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
-PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
-PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
-PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
-PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
-PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
-PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
-PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
-PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
-PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
-PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
-PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
-PFNGLVERTEX2DPROC glad_glVertex2d = NULL;
-PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL;
-PFNGLVERTEX2FPROC glad_glVertex2f = NULL;
-PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL;
-PFNGLVERTEX2IPROC glad_glVertex2i = NULL;
-PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL;
-PFNGLVERTEX2SPROC glad_glVertex2s = NULL;
-PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL;
-PFNGLVERTEX3DPROC glad_glVertex3d = NULL;
-PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL;
-PFNGLVERTEX3FPROC glad_glVertex3f = NULL;
-PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL;
-PFNGLVERTEX3IPROC glad_glVertex3i = NULL;
-PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL;
-PFNGLVERTEX3SPROC glad_glVertex3s = NULL;
-PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL;
-PFNGLVERTEX4DPROC glad_glVertex4d = NULL;
-PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL;
-PFNGLVERTEX4FPROC glad_glVertex4f = NULL;
-PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL;
-PFNGLVERTEX4IPROC glad_glVertex4i = NULL;
-PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL;
-PFNGLVERTEX4SPROC glad_glVertex4s = NULL;
-PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL;
-PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
-PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
-PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
-PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
-PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
-PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
-PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
-PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
-PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
-PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
-PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
-PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
-PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
-PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
-PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
-PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
-PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
-PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
-PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
-PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
-PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
-PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
-PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
-PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
-PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
-PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
-PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
-PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
-PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
-PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
-PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
-PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
-PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
-PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
-PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
-PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
-PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
-PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
-PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
-PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
-PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
-PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
-PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
-PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
-PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
-PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
-PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
-PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
-PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
-PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
-PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
-PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
-PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
-PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
-PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
-PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
-PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
-PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
-PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
-PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
-PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
-PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
-PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
-PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
-PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
-PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
-PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
-PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL;
-PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL;
-PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL;
-PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL;
-PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL;
-PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL;
-PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL;
-PFNGLVIEWPORTPROC glad_glViewport = NULL;
-PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
-PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL;
-PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL;
-PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL;
-PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL;
-PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL;
-PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL;
-PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL;
-PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL;
-PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL;
-PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL;
-PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL;
-PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL;
-PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL;
-PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL;
-PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL;
-PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL;
-
-
-static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_0) return;
-    glAccum = (PFNGLACCUMPROC) load("glAccum", userptr);
-    glAlphaFunc = (PFNGLALPHAFUNCPROC) load("glAlphaFunc", userptr);
-    glBegin = (PFNGLBEGINPROC) load("glBegin", userptr);
-    glBitmap = (PFNGLBITMAPPROC) load("glBitmap", userptr);
-    glBlendFunc = (PFNGLBLENDFUNCPROC) load("glBlendFunc", userptr);
-    glCallList = (PFNGLCALLLISTPROC) load("glCallList", userptr);
-    glCallLists = (PFNGLCALLLISTSPROC) load("glCallLists", userptr);
-    glClear = (PFNGLCLEARPROC) load("glClear", userptr);
-    glClearAccum = (PFNGLCLEARACCUMPROC) load("glClearAccum", userptr);
-    glClearColor = (PFNGLCLEARCOLORPROC) load("glClearColor", userptr);
-    glClearDepth = (PFNGLCLEARDEPTHPROC) load("glClearDepth", userptr);
-    glClearIndex = (PFNGLCLEARINDEXPROC) load("glClearIndex", userptr);
-    glClearStencil = (PFNGLCLEARSTENCILPROC) load("glClearStencil", userptr);
-    glClipPlane = (PFNGLCLIPPLANEPROC) load("glClipPlane", userptr);
-    glColor3b = (PFNGLCOLOR3BPROC) load("glColor3b", userptr);
-    glColor3bv = (PFNGLCOLOR3BVPROC) load("glColor3bv", userptr);
-    glColor3d = (PFNGLCOLOR3DPROC) load("glColor3d", userptr);
-    glColor3dv = (PFNGLCOLOR3DVPROC) load("glColor3dv", userptr);
-    glColor3f = (PFNGLCOLOR3FPROC) load("glColor3f", userptr);
-    glColor3fv = (PFNGLCOLOR3FVPROC) load("glColor3fv", userptr);
-    glColor3i = (PFNGLCOLOR3IPROC) load("glColor3i", userptr);
-    glColor3iv = (PFNGLCOLOR3IVPROC) load("glColor3iv", userptr);
-    glColor3s = (PFNGLCOLOR3SPROC) load("glColor3s", userptr);
-    glColor3sv = (PFNGLCOLOR3SVPROC) load("glColor3sv", userptr);
-    glColor3ub = (PFNGLCOLOR3UBPROC) load("glColor3ub", userptr);
-    glColor3ubv = (PFNGLCOLOR3UBVPROC) load("glColor3ubv", userptr);
-    glColor3ui = (PFNGLCOLOR3UIPROC) load("glColor3ui", userptr);
-    glColor3uiv = (PFNGLCOLOR3UIVPROC) load("glColor3uiv", userptr);
-    glColor3us = (PFNGLCOLOR3USPROC) load("glColor3us", userptr);
-    glColor3usv = (PFNGLCOLOR3USVPROC) load("glColor3usv", userptr);
-    glColor4b = (PFNGLCOLOR4BPROC) load("glColor4b", userptr);
-    glColor4bv = (PFNGLCOLOR4BVPROC) load("glColor4bv", userptr);
-    glColor4d = (PFNGLCOLOR4DPROC) load("glColor4d", userptr);
-    glColor4dv = (PFNGLCOLOR4DVPROC) load("glColor4dv", userptr);
-    glColor4f = (PFNGLCOLOR4FPROC) load("glColor4f", userptr);
-    glColor4fv = (PFNGLCOLOR4FVPROC) load("glColor4fv", userptr);
-    glColor4i = (PFNGLCOLOR4IPROC) load("glColor4i", userptr);
-    glColor4iv = (PFNGLCOLOR4IVPROC) load("glColor4iv", userptr);
-    glColor4s = (PFNGLCOLOR4SPROC) load("glColor4s", userptr);
-    glColor4sv = (PFNGLCOLOR4SVPROC) load("glColor4sv", userptr);
-    glColor4ub = (PFNGLCOLOR4UBPROC) load("glColor4ub", userptr);
-    glColor4ubv = (PFNGLCOLOR4UBVPROC) load("glColor4ubv", userptr);
-    glColor4ui = (PFNGLCOLOR4UIPROC) load("glColor4ui", userptr);
-    glColor4uiv = (PFNGLCOLOR4UIVPROC) load("glColor4uiv", userptr);
-    glColor4us = (PFNGLCOLOR4USPROC) load("glColor4us", userptr);
-    glColor4usv = (PFNGLCOLOR4USVPROC) load("glColor4usv", userptr);
-    glColorMask = (PFNGLCOLORMASKPROC) load("glColorMask", userptr);
-    glColorMaterial = (PFNGLCOLORMATERIALPROC) load("glColorMaterial", userptr);
-    glCopyPixels = (PFNGLCOPYPIXELSPROC) load("glCopyPixels", userptr);
-    glCullFace = (PFNGLCULLFACEPROC) load("glCullFace", userptr);
-    glDeleteLists = (PFNGLDELETELISTSPROC) load("glDeleteLists", userptr);
-    glDepthFunc = (PFNGLDEPTHFUNCPROC) load("glDepthFunc", userptr);
-    glDepthMask = (PFNGLDEPTHMASKPROC) load("glDepthMask", userptr);
-    glDepthRange = (PFNGLDEPTHRANGEPROC) load("glDepthRange", userptr);
-    glDisable = (PFNGLDISABLEPROC) load("glDisable", userptr);
-    glDrawBuffer = (PFNGLDRAWBUFFERPROC) load("glDrawBuffer", userptr);
-    glDrawPixels = (PFNGLDRAWPIXELSPROC) load("glDrawPixels", userptr);
-    glEdgeFlag = (PFNGLEDGEFLAGPROC) load("glEdgeFlag", userptr);
-    glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load("glEdgeFlagv", userptr);
-    glEnable = (PFNGLENABLEPROC) load("glEnable", userptr);
-    glEnd = (PFNGLENDPROC) load("glEnd", userptr);
-    glEndList = (PFNGLENDLISTPROC) load("glEndList", userptr);
-    glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load("glEvalCoord1d", userptr);
-    glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load("glEvalCoord1dv", userptr);
-    glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load("glEvalCoord1f", userptr);
-    glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load("glEvalCoord1fv", userptr);
-    glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load("glEvalCoord2d", userptr);
-    glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load("glEvalCoord2dv", userptr);
-    glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load("glEvalCoord2f", userptr);
-    glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load("glEvalCoord2fv", userptr);
-    glEvalMesh1 = (PFNGLEVALMESH1PROC) load("glEvalMesh1", userptr);
-    glEvalMesh2 = (PFNGLEVALMESH2PROC) load("glEvalMesh2", userptr);
-    glEvalPoint1 = (PFNGLEVALPOINT1PROC) load("glEvalPoint1", userptr);
-    glEvalPoint2 = (PFNGLEVALPOINT2PROC) load("glEvalPoint2", userptr);
-    glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load("glFeedbackBuffer", userptr);
-    glFinish = (PFNGLFINISHPROC) load("glFinish", userptr);
-    glFlush = (PFNGLFLUSHPROC) load("glFlush", userptr);
-    glFogf = (PFNGLFOGFPROC) load("glFogf", userptr);
-    glFogfv = (PFNGLFOGFVPROC) load("glFogfv", userptr);
-    glFogi = (PFNGLFOGIPROC) load("glFogi", userptr);
-    glFogiv = (PFNGLFOGIVPROC) load("glFogiv", userptr);
-    glFrontFace = (PFNGLFRONTFACEPROC) load("glFrontFace", userptr);
-    glFrustum = (PFNGLFRUSTUMPROC) load("glFrustum", userptr);
-    glGenLists = (PFNGLGENLISTSPROC) load("glGenLists", userptr);
-    glGetBooleanv = (PFNGLGETBOOLEANVPROC) load("glGetBooleanv", userptr);
-    glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load("glGetClipPlane", userptr);
-    glGetDoublev = (PFNGLGETDOUBLEVPROC) load("glGetDoublev", userptr);
-    glGetError = (PFNGLGETERRORPROC) load("glGetError", userptr);
-    glGetFloatv = (PFNGLGETFLOATVPROC) load("glGetFloatv", userptr);
-    glGetIntegerv = (PFNGLGETINTEGERVPROC) load("glGetIntegerv", userptr);
-    glGetLightfv = (PFNGLGETLIGHTFVPROC) load("glGetLightfv", userptr);
-    glGetLightiv = (PFNGLGETLIGHTIVPROC) load("glGetLightiv", userptr);
-    glGetMapdv = (PFNGLGETMAPDVPROC) load("glGetMapdv", userptr);
-    glGetMapfv = (PFNGLGETMAPFVPROC) load("glGetMapfv", userptr);
-    glGetMapiv = (PFNGLGETMAPIVPROC) load("glGetMapiv", userptr);
-    glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load("glGetMaterialfv", userptr);
-    glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load("glGetMaterialiv", userptr);
-    glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load("glGetPixelMapfv", userptr);
-    glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load("glGetPixelMapuiv", userptr);
-    glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load("glGetPixelMapusv", userptr);
-    glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load("glGetPolygonStipple", userptr);
-    glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr);
-    glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load("glGetTexEnvfv", userptr);
-    glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load("glGetTexEnviv", userptr);
-    glGetTexGendv = (PFNGLGETTEXGENDVPROC) load("glGetTexGendv", userptr);
-    glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load("glGetTexGenfv", userptr);
-    glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load("glGetTexGeniv", userptr);
-    glGetTexImage = (PFNGLGETTEXIMAGEPROC) load("glGetTexImage", userptr);
-    glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load("glGetTexLevelParameterfv", userptr);
-    glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load("glGetTexLevelParameteriv", userptr);
-    glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load("glGetTexParameterfv", userptr);
-    glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load("glGetTexParameteriv", userptr);
-    glHint = (PFNGLHINTPROC) load("glHint", userptr);
-    glIndexMask = (PFNGLINDEXMASKPROC) load("glIndexMask", userptr);
-    glIndexd = (PFNGLINDEXDPROC) load("glIndexd", userptr);
-    glIndexdv = (PFNGLINDEXDVPROC) load("glIndexdv", userptr);
-    glIndexf = (PFNGLINDEXFPROC) load("glIndexf", userptr);
-    glIndexfv = (PFNGLINDEXFVPROC) load("glIndexfv", userptr);
-    glIndexi = (PFNGLINDEXIPROC) load("glIndexi", userptr);
-    glIndexiv = (PFNGLINDEXIVPROC) load("glIndexiv", userptr);
-    glIndexs = (PFNGLINDEXSPROC) load("glIndexs", userptr);
-    glIndexsv = (PFNGLINDEXSVPROC) load("glIndexsv", userptr);
-    glInitNames = (PFNGLINITNAMESPROC) load("glInitNames", userptr);
-    glIsEnabled = (PFNGLISENABLEDPROC) load("glIsEnabled", userptr);
-    glIsList = (PFNGLISLISTPROC) load("glIsList", userptr);
-    glLightModelf = (PFNGLLIGHTMODELFPROC) load("glLightModelf", userptr);
-    glLightModelfv = (PFNGLLIGHTMODELFVPROC) load("glLightModelfv", userptr);
-    glLightModeli = (PFNGLLIGHTMODELIPROC) load("glLightModeli", userptr);
-    glLightModeliv = (PFNGLLIGHTMODELIVPROC) load("glLightModeliv", userptr);
-    glLightf = (PFNGLLIGHTFPROC) load("glLightf", userptr);
-    glLightfv = (PFNGLLIGHTFVPROC) load("glLightfv", userptr);
-    glLighti = (PFNGLLIGHTIPROC) load("glLighti", userptr);
-    glLightiv = (PFNGLLIGHTIVPROC) load("glLightiv", userptr);
-    glLineStipple = (PFNGLLINESTIPPLEPROC) load("glLineStipple", userptr);
-    glLineWidth = (PFNGLLINEWIDTHPROC) load("glLineWidth", userptr);
-    glListBase = (PFNGLLISTBASEPROC) load("glListBase", userptr);
-    glLoadIdentity = (PFNGLLOADIDENTITYPROC) load("glLoadIdentity", userptr);
-    glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load("glLoadMatrixd", userptr);
-    glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load("glLoadMatrixf", userptr);
-    glLoadName = (PFNGLLOADNAMEPROC) load("glLoadName", userptr);
-    glLogicOp = (PFNGLLOGICOPPROC) load("glLogicOp", userptr);
-    glMap1d = (PFNGLMAP1DPROC) load("glMap1d", userptr);
-    glMap1f = (PFNGLMAP1FPROC) load("glMap1f", userptr);
-    glMap2d = (PFNGLMAP2DPROC) load("glMap2d", userptr);
-    glMap2f = (PFNGLMAP2FPROC) load("glMap2f", userptr);
-    glMapGrid1d = (PFNGLMAPGRID1DPROC) load("glMapGrid1d", userptr);
-    glMapGrid1f = (PFNGLMAPGRID1FPROC) load("glMapGrid1f", userptr);
-    glMapGrid2d = (PFNGLMAPGRID2DPROC) load("glMapGrid2d", userptr);
-    glMapGrid2f = (PFNGLMAPGRID2FPROC) load("glMapGrid2f", userptr);
-    glMaterialf = (PFNGLMATERIALFPROC) load("glMaterialf", userptr);
-    glMaterialfv = (PFNGLMATERIALFVPROC) load("glMaterialfv", userptr);
-    glMateriali = (PFNGLMATERIALIPROC) load("glMateriali", userptr);
-    glMaterialiv = (PFNGLMATERIALIVPROC) load("glMaterialiv", userptr);
-    glMatrixMode = (PFNGLMATRIXMODEPROC) load("glMatrixMode", userptr);
-    glMultMatrixd = (PFNGLMULTMATRIXDPROC) load("glMultMatrixd", userptr);
-    glMultMatrixf = (PFNGLMULTMATRIXFPROC) load("glMultMatrixf", userptr);
-    glNewList = (PFNGLNEWLISTPROC) load("glNewList", userptr);
-    glNormal3b = (PFNGLNORMAL3BPROC) load("glNormal3b", userptr);
-    glNormal3bv = (PFNGLNORMAL3BVPROC) load("glNormal3bv", userptr);
-    glNormal3d = (PFNGLNORMAL3DPROC) load("glNormal3d", userptr);
-    glNormal3dv = (PFNGLNORMAL3DVPROC) load("glNormal3dv", userptr);
-    glNormal3f = (PFNGLNORMAL3FPROC) load("glNormal3f", userptr);
-    glNormal3fv = (PFNGLNORMAL3FVPROC) load("glNormal3fv", userptr);
-    glNormal3i = (PFNGLNORMAL3IPROC) load("glNormal3i", userptr);
-    glNormal3iv = (PFNGLNORMAL3IVPROC) load("glNormal3iv", userptr);
-    glNormal3s = (PFNGLNORMAL3SPROC) load("glNormal3s", userptr);
-    glNormal3sv = (PFNGLNORMAL3SVPROC) load("glNormal3sv", userptr);
-    glOrtho = (PFNGLORTHOPROC) load("glOrtho", userptr);
-    glPassThrough = (PFNGLPASSTHROUGHPROC) load("glPassThrough", userptr);
-    glPixelMapfv = (PFNGLPIXELMAPFVPROC) load("glPixelMapfv", userptr);
-    glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load("glPixelMapuiv", userptr);
-    glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load("glPixelMapusv", userptr);
-    glPixelStoref = (PFNGLPIXELSTOREFPROC) load("glPixelStoref", userptr);
-    glPixelStorei = (PFNGLPIXELSTOREIPROC) load("glPixelStorei", userptr);
-    glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load("glPixelTransferf", userptr);
-    glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load("glPixelTransferi", userptr);
-    glPixelZoom = (PFNGLPIXELZOOMPROC) load("glPixelZoom", userptr);
-    glPointSize = (PFNGLPOINTSIZEPROC) load("glPointSize", userptr);
-    glPolygonMode = (PFNGLPOLYGONMODEPROC) load("glPolygonMode", userptr);
-    glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load("glPolygonStipple", userptr);
-    glPopAttrib = (PFNGLPOPATTRIBPROC) load("glPopAttrib", userptr);
-    glPopMatrix = (PFNGLPOPMATRIXPROC) load("glPopMatrix", userptr);
-    glPopName = (PFNGLPOPNAMEPROC) load("glPopName", userptr);
-    glPushAttrib = (PFNGLPUSHATTRIBPROC) load("glPushAttrib", userptr);
-    glPushMatrix = (PFNGLPUSHMATRIXPROC) load("glPushMatrix", userptr);
-    glPushName = (PFNGLPUSHNAMEPROC) load("glPushName", userptr);
-    glRasterPos2d = (PFNGLRASTERPOS2DPROC) load("glRasterPos2d", userptr);
-    glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load("glRasterPos2dv", userptr);
-    glRasterPos2f = (PFNGLRASTERPOS2FPROC) load("glRasterPos2f", userptr);
-    glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load("glRasterPos2fv", userptr);
-    glRasterPos2i = (PFNGLRASTERPOS2IPROC) load("glRasterPos2i", userptr);
-    glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load("glRasterPos2iv", userptr);
-    glRasterPos2s = (PFNGLRASTERPOS2SPROC) load("glRasterPos2s", userptr);
-    glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load("glRasterPos2sv", userptr);
-    glRasterPos3d = (PFNGLRASTERPOS3DPROC) load("glRasterPos3d", userptr);
-    glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load("glRasterPos3dv", userptr);
-    glRasterPos3f = (PFNGLRASTERPOS3FPROC) load("glRasterPos3f", userptr);
-    glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load("glRasterPos3fv", userptr);
-    glRasterPos3i = (PFNGLRASTERPOS3IPROC) load("glRasterPos3i", userptr);
-    glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load("glRasterPos3iv", userptr);
-    glRasterPos3s = (PFNGLRASTERPOS3SPROC) load("glRasterPos3s", userptr);
-    glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load("glRasterPos3sv", userptr);
-    glRasterPos4d = (PFNGLRASTERPOS4DPROC) load("glRasterPos4d", userptr);
-    glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load("glRasterPos4dv", userptr);
-    glRasterPos4f = (PFNGLRASTERPOS4FPROC) load("glRasterPos4f", userptr);
-    glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load("glRasterPos4fv", userptr);
-    glRasterPos4i = (PFNGLRASTERPOS4IPROC) load("glRasterPos4i", userptr);
-    glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load("glRasterPos4iv", userptr);
-    glRasterPos4s = (PFNGLRASTERPOS4SPROC) load("glRasterPos4s", userptr);
-    glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load("glRasterPos4sv", userptr);
-    glReadBuffer = (PFNGLREADBUFFERPROC) load("glReadBuffer", userptr);
-    glReadPixels = (PFNGLREADPIXELSPROC) load("glReadPixels", userptr);
-    glRectd = (PFNGLRECTDPROC) load("glRectd", userptr);
-    glRectdv = (PFNGLRECTDVPROC) load("glRectdv", userptr);
-    glRectf = (PFNGLRECTFPROC) load("glRectf", userptr);
-    glRectfv = (PFNGLRECTFVPROC) load("glRectfv", userptr);
-    glRecti = (PFNGLRECTIPROC) load("glRecti", userptr);
-    glRectiv = (PFNGLRECTIVPROC) load("glRectiv", userptr);
-    glRects = (PFNGLRECTSPROC) load("glRects", userptr);
-    glRectsv = (PFNGLRECTSVPROC) load("glRectsv", userptr);
-    glRenderMode = (PFNGLRENDERMODEPROC) load("glRenderMode", userptr);
-    glRotated = (PFNGLROTATEDPROC) load("glRotated", userptr);
-    glRotatef = (PFNGLROTATEFPROC) load("glRotatef", userptr);
-    glScaled = (PFNGLSCALEDPROC) load("glScaled", userptr);
-    glScalef = (PFNGLSCALEFPROC) load("glScalef", userptr);
-    glScissor = (PFNGLSCISSORPROC) load("glScissor", userptr);
-    glSelectBuffer = (PFNGLSELECTBUFFERPROC) load("glSelectBuffer", userptr);
-    glShadeModel = (PFNGLSHADEMODELPROC) load("glShadeModel", userptr);
-    glStencilFunc = (PFNGLSTENCILFUNCPROC) load("glStencilFunc", userptr);
-    glStencilMask = (PFNGLSTENCILMASKPROC) load("glStencilMask", userptr);
-    glStencilOp = (PFNGLSTENCILOPPROC) load("glStencilOp", userptr);
-    glTexCoord1d = (PFNGLTEXCOORD1DPROC) load("glTexCoord1d", userptr);
-    glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load("glTexCoord1dv", userptr);
-    glTexCoord1f = (PFNGLTEXCOORD1FPROC) load("glTexCoord1f", userptr);
-    glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load("glTexCoord1fv", userptr);
-    glTexCoord1i = (PFNGLTEXCOORD1IPROC) load("glTexCoord1i", userptr);
-    glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load("glTexCoord1iv", userptr);
-    glTexCoord1s = (PFNGLTEXCOORD1SPROC) load("glTexCoord1s", userptr);
-    glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load("glTexCoord1sv", userptr);
-    glTexCoord2d = (PFNGLTEXCOORD2DPROC) load("glTexCoord2d", userptr);
-    glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load("glTexCoord2dv", userptr);
-    glTexCoord2f = (PFNGLTEXCOORD2FPROC) load("glTexCoord2f", userptr);
-    glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load("glTexCoord2fv", userptr);
-    glTexCoord2i = (PFNGLTEXCOORD2IPROC) load("glTexCoord2i", userptr);
-    glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load("glTexCoord2iv", userptr);
-    glTexCoord2s = (PFNGLTEXCOORD2SPROC) load("glTexCoord2s", userptr);
-    glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load("glTexCoord2sv", userptr);
-    glTexCoord3d = (PFNGLTEXCOORD3DPROC) load("glTexCoord3d", userptr);
-    glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load("glTexCoord3dv", userptr);
-    glTexCoord3f = (PFNGLTEXCOORD3FPROC) load("glTexCoord3f", userptr);
-    glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load("glTexCoord3fv", userptr);
-    glTexCoord3i = (PFNGLTEXCOORD3IPROC) load("glTexCoord3i", userptr);
-    glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load("glTexCoord3iv", userptr);
-    glTexCoord3s = (PFNGLTEXCOORD3SPROC) load("glTexCoord3s", userptr);
-    glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load("glTexCoord3sv", userptr);
-    glTexCoord4d = (PFNGLTEXCOORD4DPROC) load("glTexCoord4d", userptr);
-    glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load("glTexCoord4dv", userptr);
-    glTexCoord4f = (PFNGLTEXCOORD4FPROC) load("glTexCoord4f", userptr);
-    glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load("glTexCoord4fv", userptr);
-    glTexCoord4i = (PFNGLTEXCOORD4IPROC) load("glTexCoord4i", userptr);
-    glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load("glTexCoord4iv", userptr);
-    glTexCoord4s = (PFNGLTEXCOORD4SPROC) load("glTexCoord4s", userptr);
-    glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load("glTexCoord4sv", userptr);
-    glTexEnvf = (PFNGLTEXENVFPROC) load("glTexEnvf", userptr);
-    glTexEnvfv = (PFNGLTEXENVFVPROC) load("glTexEnvfv", userptr);
-    glTexEnvi = (PFNGLTEXENVIPROC) load("glTexEnvi", userptr);
-    glTexEnviv = (PFNGLTEXENVIVPROC) load("glTexEnviv", userptr);
-    glTexGend = (PFNGLTEXGENDPROC) load("glTexGend", userptr);
-    glTexGendv = (PFNGLTEXGENDVPROC) load("glTexGendv", userptr);
-    glTexGenf = (PFNGLTEXGENFPROC) load("glTexGenf", userptr);
-    glTexGenfv = (PFNGLTEXGENFVPROC) load("glTexGenfv", userptr);
-    glTexGeni = (PFNGLTEXGENIPROC) load("glTexGeni", userptr);
-    glTexGeniv = (PFNGLTEXGENIVPROC) load("glTexGeniv", userptr);
-    glTexImage1D = (PFNGLTEXIMAGE1DPROC) load("glTexImage1D", userptr);
-    glTexImage2D = (PFNGLTEXIMAGE2DPROC) load("glTexImage2D", userptr);
-    glTexParameterf = (PFNGLTEXPARAMETERFPROC) load("glTexParameterf", userptr);
-    glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load("glTexParameterfv", userptr);
-    glTexParameteri = (PFNGLTEXPARAMETERIPROC) load("glTexParameteri", userptr);
-    glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load("glTexParameteriv", userptr);
-    glTranslated = (PFNGLTRANSLATEDPROC) load("glTranslated", userptr);
-    glTranslatef = (PFNGLTRANSLATEFPROC) load("glTranslatef", userptr);
-    glVertex2d = (PFNGLVERTEX2DPROC) load("glVertex2d", userptr);
-    glVertex2dv = (PFNGLVERTEX2DVPROC) load("glVertex2dv", userptr);
-    glVertex2f = (PFNGLVERTEX2FPROC) load("glVertex2f", userptr);
-    glVertex2fv = (PFNGLVERTEX2FVPROC) load("glVertex2fv", userptr);
-    glVertex2i = (PFNGLVERTEX2IPROC) load("glVertex2i", userptr);
-    glVertex2iv = (PFNGLVERTEX2IVPROC) load("glVertex2iv", userptr);
-    glVertex2s = (PFNGLVERTEX2SPROC) load("glVertex2s", userptr);
-    glVertex2sv = (PFNGLVERTEX2SVPROC) load("glVertex2sv", userptr);
-    glVertex3d = (PFNGLVERTEX3DPROC) load("glVertex3d", userptr);
-    glVertex3dv = (PFNGLVERTEX3DVPROC) load("glVertex3dv", userptr);
-    glVertex3f = (PFNGLVERTEX3FPROC) load("glVertex3f", userptr);
-    glVertex3fv = (PFNGLVERTEX3FVPROC) load("glVertex3fv", userptr);
-    glVertex3i = (PFNGLVERTEX3IPROC) load("glVertex3i", userptr);
-    glVertex3iv = (PFNGLVERTEX3IVPROC) load("glVertex3iv", userptr);
-    glVertex3s = (PFNGLVERTEX3SPROC) load("glVertex3s", userptr);
-    glVertex3sv = (PFNGLVERTEX3SVPROC) load("glVertex3sv", userptr);
-    glVertex4d = (PFNGLVERTEX4DPROC) load("glVertex4d", userptr);
-    glVertex4dv = (PFNGLVERTEX4DVPROC) load("glVertex4dv", userptr);
-    glVertex4f = (PFNGLVERTEX4FPROC) load("glVertex4f", userptr);
-    glVertex4fv = (PFNGLVERTEX4FVPROC) load("glVertex4fv", userptr);
-    glVertex4i = (PFNGLVERTEX4IPROC) load("glVertex4i", userptr);
-    glVertex4iv = (PFNGLVERTEX4IVPROC) load("glVertex4iv", userptr);
-    glVertex4s = (PFNGLVERTEX4SPROC) load("glVertex4s", userptr);
-    glVertex4sv = (PFNGLVERTEX4SVPROC) load("glVertex4sv", userptr);
-    glViewport = (PFNGLVIEWPORTPROC) load("glViewport", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_1) return;
-    glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load("glAreTexturesResident", userptr);
-    glArrayElement = (PFNGLARRAYELEMENTPROC) load("glArrayElement", userptr);
-    glBindTexture = (PFNGLBINDTEXTUREPROC) load("glBindTexture", userptr);
-    glColorPointer = (PFNGLCOLORPOINTERPROC) load("glColorPointer", userptr);
-    glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load("glCopyTexImage1D", userptr);
-    glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load("glCopyTexImage2D", userptr);
-    glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load("glCopyTexSubImage1D", userptr);
-    glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load("glCopyTexSubImage2D", userptr);
-    glDeleteTextures = (PFNGLDELETETEXTURESPROC) load("glDeleteTextures", userptr);
-    glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load("glDisableClientState", userptr);
-    glDrawArrays = (PFNGLDRAWARRAYSPROC) load("glDrawArrays", userptr);
-    glDrawElements = (PFNGLDRAWELEMENTSPROC) load("glDrawElements", userptr);
-    glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load("glEdgeFlagPointer", userptr);
-    glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load("glEnableClientState", userptr);
-    glGenTextures = (PFNGLGENTEXTURESPROC) load("glGenTextures", userptr);
-    glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr);
-    glIndexPointer = (PFNGLINDEXPOINTERPROC) load("glIndexPointer", userptr);
-    glIndexub = (PFNGLINDEXUBPROC) load("glIndexub", userptr);
-    glIndexubv = (PFNGLINDEXUBVPROC) load("glIndexubv", userptr);
-    glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load("glInterleavedArrays", userptr);
-    glIsTexture = (PFNGLISTEXTUREPROC) load("glIsTexture", userptr);
-    glNormalPointer = (PFNGLNORMALPOINTERPROC) load("glNormalPointer", userptr);
-    glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load("glPolygonOffset", userptr);
-    glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load("glPopClientAttrib", userptr);
-    glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load("glPrioritizeTextures", userptr);
-    glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load("glPushClientAttrib", userptr);
-    glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load("glTexCoordPointer", userptr);
-    glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load("glTexSubImage1D", userptr);
-    glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load("glTexSubImage2D", userptr);
-    glVertexPointer = (PFNGLVERTEXPOINTERPROC) load("glVertexPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_2) return;
-    glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load("glCopyTexSubImage3D", userptr);
-    glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load("glDrawRangeElements", userptr);
-    glTexImage3D = (PFNGLTEXIMAGE3DPROC) load("glTexImage3D", userptr);
-    glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load("glTexSubImage3D", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_3) return;
-    glActiveTexture = (PFNGLACTIVETEXTUREPROC) load("glActiveTexture", userptr);
-    glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load("glClientActiveTexture", userptr);
-    glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load("glCompressedTexImage1D", userptr);
-    glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load("glCompressedTexImage2D", userptr);
-    glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load("glCompressedTexImage3D", userptr);
-    glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load("glCompressedTexSubImage1D", userptr);
-    glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load("glCompressedTexSubImage2D", userptr);
-    glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load("glCompressedTexSubImage3D", userptr);
-    glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load("glGetCompressedTexImage", userptr);
-    glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load("glLoadTransposeMatrixd", userptr);
-    glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load("glLoadTransposeMatrixf", userptr);
-    glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load("glMultTransposeMatrixd", userptr);
-    glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load("glMultTransposeMatrixf", userptr);
-    glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load("glMultiTexCoord1d", userptr);
-    glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load("glMultiTexCoord1dv", userptr);
-    glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load("glMultiTexCoord1f", userptr);
-    glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load("glMultiTexCoord1fv", userptr);
-    glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load("glMultiTexCoord1i", userptr);
-    glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load("glMultiTexCoord1iv", userptr);
-    glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load("glMultiTexCoord1s", userptr);
-    glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load("glMultiTexCoord1sv", userptr);
-    glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load("glMultiTexCoord2d", userptr);
-    glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load("glMultiTexCoord2dv", userptr);
-    glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load("glMultiTexCoord2f", userptr);
-    glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load("glMultiTexCoord2fv", userptr);
-    glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load("glMultiTexCoord2i", userptr);
-    glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load("glMultiTexCoord2iv", userptr);
-    glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load("glMultiTexCoord2s", userptr);
-    glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load("glMultiTexCoord2sv", userptr);
-    glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load("glMultiTexCoord3d", userptr);
-    glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load("glMultiTexCoord3dv", userptr);
-    glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load("glMultiTexCoord3f", userptr);
-    glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load("glMultiTexCoord3fv", userptr);
-    glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load("glMultiTexCoord3i", userptr);
-    glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load("glMultiTexCoord3iv", userptr);
-    glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load("glMultiTexCoord3s", userptr);
-    glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load("glMultiTexCoord3sv", userptr);
-    glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load("glMultiTexCoord4d", userptr);
-    glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load("glMultiTexCoord4dv", userptr);
-    glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load("glMultiTexCoord4f", userptr);
-    glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load("glMultiTexCoord4fv", userptr);
-    glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load("glMultiTexCoord4i", userptr);
-    glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load("glMultiTexCoord4iv", userptr);
-    glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load("glMultiTexCoord4s", userptr);
-    glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load("glMultiTexCoord4sv", userptr);
-    glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_4) return;
-    glBlendColor = (PFNGLBLENDCOLORPROC) load("glBlendColor", userptr);
-    glBlendEquation = (PFNGLBLENDEQUATIONPROC) load("glBlendEquation", userptr);
-    glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load("glBlendFuncSeparate", userptr);
-    glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load("glFogCoordPointer", userptr);
-    glFogCoordd = (PFNGLFOGCOORDDPROC) load("glFogCoordd", userptr);
-    glFogCoorddv = (PFNGLFOGCOORDDVPROC) load("glFogCoorddv", userptr);
-    glFogCoordf = (PFNGLFOGCOORDFPROC) load("glFogCoordf", userptr);
-    glFogCoordfv = (PFNGLFOGCOORDFVPROC) load("glFogCoordfv", userptr);
-    glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load("glMultiDrawArrays", userptr);
-    glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load("glMultiDrawElements", userptr);
-    glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load("glPointParameterf", userptr);
-    glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load("glPointParameterfv", userptr);
-    glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load("glPointParameteri", userptr);
-    glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load("glPointParameteriv", userptr);
-    glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load("glSecondaryColor3b", userptr);
-    glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load("glSecondaryColor3bv", userptr);
-    glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load("glSecondaryColor3d", userptr);
-    glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load("glSecondaryColor3dv", userptr);
-    glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load("glSecondaryColor3f", userptr);
-    glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load("glSecondaryColor3fv", userptr);
-    glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load("glSecondaryColor3i", userptr);
-    glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load("glSecondaryColor3iv", userptr);
-    glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load("glSecondaryColor3s", userptr);
-    glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load("glSecondaryColor3sv", userptr);
-    glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load("glSecondaryColor3ub", userptr);
-    glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load("glSecondaryColor3ubv", userptr);
-    glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load("glSecondaryColor3ui", userptr);
-    glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load("glSecondaryColor3uiv", userptr);
-    glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load("glSecondaryColor3us", userptr);
-    glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load("glSecondaryColor3usv", userptr);
-    glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load("glSecondaryColorPointer", userptr);
-    glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load("glWindowPos2d", userptr);
-    glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load("glWindowPos2dv", userptr);
-    glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load("glWindowPos2f", userptr);
-    glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load("glWindowPos2fv", userptr);
-    glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load("glWindowPos2i", userptr);
-    glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load("glWindowPos2iv", userptr);
-    glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load("glWindowPos2s", userptr);
-    glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load("glWindowPos2sv", userptr);
-    glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load("glWindowPos3d", userptr);
-    glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load("glWindowPos3dv", userptr);
-    glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load("glWindowPos3f", userptr);
-    glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load("glWindowPos3fv", userptr);
-    glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load("glWindowPos3i", userptr);
-    glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load("glWindowPos3iv", userptr);
-    glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load("glWindowPos3s", userptr);
-    glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load("glWindowPos3sv", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_5) return;
-    glBeginQuery = (PFNGLBEGINQUERYPROC) load("glBeginQuery", userptr);
-    glBindBuffer = (PFNGLBINDBUFFERPROC) load("glBindBuffer", userptr);
-    glBufferData = (PFNGLBUFFERDATAPROC) load("glBufferData", userptr);
-    glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load("glBufferSubData", userptr);
-    glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load("glDeleteBuffers", userptr);
-    glDeleteQueries = (PFNGLDELETEQUERIESPROC) load("glDeleteQueries", userptr);
-    glEndQuery = (PFNGLENDQUERYPROC) load("glEndQuery", userptr);
-    glGenBuffers = (PFNGLGENBUFFERSPROC) load("glGenBuffers", userptr);
-    glGenQueries = (PFNGLGENQUERIESPROC) load("glGenQueries", userptr);
-    glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load("glGetBufferParameteriv", userptr);
-    glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load("glGetBufferPointerv", userptr);
-    glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load("glGetBufferSubData", userptr);
-    glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load("glGetQueryObjectiv", userptr);
-    glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load("glGetQueryObjectuiv", userptr);
-    glGetQueryiv = (PFNGLGETQUERYIVPROC) load("glGetQueryiv", userptr);
-    glIsBuffer = (PFNGLISBUFFERPROC) load("glIsBuffer", userptr);
-    glIsQuery = (PFNGLISQUERYPROC) load("glIsQuery", userptr);
-    glMapBuffer = (PFNGLMAPBUFFERPROC) load("glMapBuffer", userptr);
-    glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load("glUnmapBuffer", userptr);
-}
-static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_2_0) return;
-    glAttachShader = (PFNGLATTACHSHADERPROC) load("glAttachShader", userptr);
-    glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load("glBindAttribLocation", userptr);
-    glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load("glBlendEquationSeparate", userptr);
-    glCompileShader = (PFNGLCOMPILESHADERPROC) load("glCompileShader", userptr);
-    glCreateProgram = (PFNGLCREATEPROGRAMPROC) load("glCreateProgram", userptr);
-    glCreateShader = (PFNGLCREATESHADERPROC) load("glCreateShader", userptr);
-    glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load("glDeleteProgram", userptr);
-    glDeleteShader = (PFNGLDELETESHADERPROC) load("glDeleteShader", userptr);
-    glDetachShader = (PFNGLDETACHSHADERPROC) load("glDetachShader", userptr);
-    glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load("glDisableVertexAttribArray", userptr);
-    glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load("glDrawBuffers", userptr);
-    glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load("glEnableVertexAttribArray", userptr);
-    glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load("glGetActiveAttrib", userptr);
-    glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load("glGetActiveUniform", userptr);
-    glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load("glGetAttachedShaders", userptr);
-    glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load("glGetAttribLocation", userptr);
-    glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load("glGetProgramInfoLog", userptr);
-    glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load("glGetProgramiv", userptr);
-    glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load("glGetShaderInfoLog", userptr);
-    glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load("glGetShaderSource", userptr);
-    glGetShaderiv = (PFNGLGETSHADERIVPROC) load("glGetShaderiv", userptr);
-    glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load("glGetUniformLocation", userptr);
-    glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load("glGetUniformfv", userptr);
-    glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load("glGetUniformiv", userptr);
-    glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load("glGetVertexAttribPointerv", userptr);
-    glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load("glGetVertexAttribdv", userptr);
-    glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load("glGetVertexAttribfv", userptr);
-    glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load("glGetVertexAttribiv", userptr);
-    glIsProgram = (PFNGLISPROGRAMPROC) load("glIsProgram", userptr);
-    glIsShader = (PFNGLISSHADERPROC) load("glIsShader", userptr);
-    glLinkProgram = (PFNGLLINKPROGRAMPROC) load("glLinkProgram", userptr);
-    glShaderSource = (PFNGLSHADERSOURCEPROC) load("glShaderSource", userptr);
-    glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load("glStencilFuncSeparate", userptr);
-    glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load("glStencilMaskSeparate", userptr);
-    glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load("glStencilOpSeparate", userptr);
-    glUniform1f = (PFNGLUNIFORM1FPROC) load("glUniform1f", userptr);
-    glUniform1fv = (PFNGLUNIFORM1FVPROC) load("glUniform1fv", userptr);
-    glUniform1i = (PFNGLUNIFORM1IPROC) load("glUniform1i", userptr);
-    glUniform1iv = (PFNGLUNIFORM1IVPROC) load("glUniform1iv", userptr);
-    glUniform2f = (PFNGLUNIFORM2FPROC) load("glUniform2f", userptr);
-    glUniform2fv = (PFNGLUNIFORM2FVPROC) load("glUniform2fv", userptr);
-    glUniform2i = (PFNGLUNIFORM2IPROC) load("glUniform2i", userptr);
-    glUniform2iv = (PFNGLUNIFORM2IVPROC) load("glUniform2iv", userptr);
-    glUniform3f = (PFNGLUNIFORM3FPROC) load("glUniform3f", userptr);
-    glUniform3fv = (PFNGLUNIFORM3FVPROC) load("glUniform3fv", userptr);
-    glUniform3i = (PFNGLUNIFORM3IPROC) load("glUniform3i", userptr);
-    glUniform3iv = (PFNGLUNIFORM3IVPROC) load("glUniform3iv", userptr);
-    glUniform4f = (PFNGLUNIFORM4FPROC) load("glUniform4f", userptr);
-    glUniform4fv = (PFNGLUNIFORM4FVPROC) load("glUniform4fv", userptr);
-    glUniform4i = (PFNGLUNIFORM4IPROC) load("glUniform4i", userptr);
-    glUniform4iv = (PFNGLUNIFORM4IVPROC) load("glUniform4iv", userptr);
-    glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load("glUniformMatrix2fv", userptr);
-    glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load("glUniformMatrix3fv", userptr);
-    glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load("glUniformMatrix4fv", userptr);
-    glUseProgram = (PFNGLUSEPROGRAMPROC) load("glUseProgram", userptr);
-    glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load("glValidateProgram", userptr);
-    glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load("glVertexAttrib1d", userptr);
-    glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load("glVertexAttrib1dv", userptr);
-    glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load("glVertexAttrib1f", userptr);
-    glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load("glVertexAttrib1fv", userptr);
-    glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load("glVertexAttrib1s", userptr);
-    glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load("glVertexAttrib1sv", userptr);
-    glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load("glVertexAttrib2d", userptr);
-    glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load("glVertexAttrib2dv", userptr);
-    glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load("glVertexAttrib2f", userptr);
-    glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load("glVertexAttrib2fv", userptr);
-    glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load("glVertexAttrib2s", userptr);
-    glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load("glVertexAttrib2sv", userptr);
-    glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load("glVertexAttrib3d", userptr);
-    glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load("glVertexAttrib3dv", userptr);
-    glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load("glVertexAttrib3f", userptr);
-    glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load("glVertexAttrib3fv", userptr);
-    glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load("glVertexAttrib3s", userptr);
-    glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load("glVertexAttrib3sv", userptr);
-    glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load("glVertexAttrib4Nbv", userptr);
-    glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load("glVertexAttrib4Niv", userptr);
-    glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load("glVertexAttrib4Nsv", userptr);
-    glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load("glVertexAttrib4Nub", userptr);
-    glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load("glVertexAttrib4Nubv", userptr);
-    glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load("glVertexAttrib4Nuiv", userptr);
-    glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load("glVertexAttrib4Nusv", userptr);
-    glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load("glVertexAttrib4bv", userptr);
-    glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load("glVertexAttrib4d", userptr);
-    glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load("glVertexAttrib4dv", userptr);
-    glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load("glVertexAttrib4f", userptr);
-    glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load("glVertexAttrib4fv", userptr);
-    glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load("glVertexAttrib4iv", userptr);
-    glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load("glVertexAttrib4s", userptr);
-    glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load("glVertexAttrib4sv", userptr);
-    glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load("glVertexAttrib4ubv", userptr);
-    glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load("glVertexAttrib4uiv", userptr);
-    glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load("glVertexAttrib4usv", userptr);
-    glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load("glVertexAttribPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_2_1) return;
-    glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load("glUniformMatrix2x3fv", userptr);
-    glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load("glUniformMatrix2x4fv", userptr);
-    glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load("glUniformMatrix3x2fv", userptr);
-    glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load("glUniformMatrix3x4fv", userptr);
-    glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load("glUniformMatrix4x2fv", userptr);
-    glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load("glUniformMatrix4x3fv", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_0) return;
-    glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load("glBeginConditionalRender", userptr);
-    glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load("glBeginTransformFeedback", userptr);
-    glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr);
-    glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr);
-    glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load("glBindFragDataLocation", userptr);
-    glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load("glBindFramebuffer", userptr);
-    glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load("glBindRenderbuffer", userptr);
-    glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load("glBindVertexArray", userptr);
-    glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load("glBlitFramebuffer", userptr);
-    glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load("glCheckFramebufferStatus", userptr);
-    glClampColor = (PFNGLCLAMPCOLORPROC) load("glClampColor", userptr);
-    glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load("glClearBufferfi", userptr);
-    glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load("glClearBufferfv", userptr);
-    glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load("glClearBufferiv", userptr);
-    glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load("glClearBufferuiv", userptr);
-    glColorMaski = (PFNGLCOLORMASKIPROC) load("glColorMaski", userptr);
-    glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load("glDeleteFramebuffers", userptr);
-    glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load("glDeleteRenderbuffers", userptr);
-    glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load("glDeleteVertexArrays", userptr);
-    glDisablei = (PFNGLDISABLEIPROC) load("glDisablei", userptr);
-    glEnablei = (PFNGLENABLEIPROC) load("glEnablei", userptr);
-    glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load("glEndConditionalRender", userptr);
-    glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load("glEndTransformFeedback", userptr);
-    glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load("glFlushMappedBufferRange", userptr);
-    glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load("glFramebufferRenderbuffer", userptr);
-    glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load("glFramebufferTexture1D", userptr);
-    glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load("glFramebufferTexture2D", userptr);
-    glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load("glFramebufferTexture3D", userptr);
-    glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load("glFramebufferTextureLayer", userptr);
-    glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load("glGenFramebuffers", userptr);
-    glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load("glGenRenderbuffers", userptr);
-    glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load("glGenVertexArrays", userptr);
-    glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load("glGenerateMipmap", userptr);
-    glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load("glGetBooleani_v", userptr);
-    glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load("glGetFragDataLocation", userptr);
-    glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load("glGetFramebufferAttachmentParameteriv", userptr);
-    glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr);
-    glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load("glGetRenderbufferParameteriv", userptr);
-    glGetStringi = (PFNGLGETSTRINGIPROC) load("glGetStringi", userptr);
-    glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load("glGetTexParameterIiv", userptr);
-    glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load("glGetTexParameterIuiv", userptr);
-    glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load("glGetTransformFeedbackVarying", userptr);
-    glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load("glGetUniformuiv", userptr);
-    glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load("glGetVertexAttribIiv", userptr);
-    glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load("glGetVertexAttribIuiv", userptr);
-    glIsEnabledi = (PFNGLISENABLEDIPROC) load("glIsEnabledi", userptr);
-    glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load("glIsFramebuffer", userptr);
-    glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load("glIsRenderbuffer", userptr);
-    glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load("glIsVertexArray", userptr);
-    glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load("glMapBufferRange", userptr);
-    glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load("glRenderbufferStorage", userptr);
-    glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load("glRenderbufferStorageMultisample", userptr);
-    glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load("glTexParameterIiv", userptr);
-    glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load("glTexParameterIuiv", userptr);
-    glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load("glTransformFeedbackVaryings", userptr);
-    glUniform1ui = (PFNGLUNIFORM1UIPROC) load("glUniform1ui", userptr);
-    glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load("glUniform1uiv", userptr);
-    glUniform2ui = (PFNGLUNIFORM2UIPROC) load("glUniform2ui", userptr);
-    glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load("glUniform2uiv", userptr);
-    glUniform3ui = (PFNGLUNIFORM3UIPROC) load("glUniform3ui", userptr);
-    glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load("glUniform3uiv", userptr);
-    glUniform4ui = (PFNGLUNIFORM4UIPROC) load("glUniform4ui", userptr);
-    glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load("glUniform4uiv", userptr);
-    glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load("glVertexAttribI1i", userptr);
-    glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load("glVertexAttribI1iv", userptr);
-    glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load("glVertexAttribI1ui", userptr);
-    glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load("glVertexAttribI1uiv", userptr);
-    glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load("glVertexAttribI2i", userptr);
-    glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load("glVertexAttribI2iv", userptr);
-    glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load("glVertexAttribI2ui", userptr);
-    glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load("glVertexAttribI2uiv", userptr);
-    glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load("glVertexAttribI3i", userptr);
-    glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load("glVertexAttribI3iv", userptr);
-    glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load("glVertexAttribI3ui", userptr);
-    glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load("glVertexAttribI3uiv", userptr);
-    glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load("glVertexAttribI4bv", userptr);
-    glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load("glVertexAttribI4i", userptr);
-    glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load("glVertexAttribI4iv", userptr);
-    glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load("glVertexAttribI4sv", userptr);
-    glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load("glVertexAttribI4ubv", userptr);
-    glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load("glVertexAttribI4ui", userptr);
-    glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load("glVertexAttribI4uiv", userptr);
-    glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load("glVertexAttribI4usv", userptr);
-    glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load("glVertexAttribIPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_1) return;
-    glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr);
-    glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr);
-    glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load("glCopyBufferSubData", userptr);
-    glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load("glDrawArraysInstanced", userptr);
-    glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load("glDrawElementsInstanced", userptr);
-    glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load("glGetActiveUniformBlockName", userptr);
-    glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load("glGetActiveUniformBlockiv", userptr);
-    glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load("glGetActiveUniformName", userptr);
-    glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load("glGetActiveUniformsiv", userptr);
-    glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr);
-    glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load("glGetUniformBlockIndex", userptr);
-    glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load("glGetUniformIndices", userptr);
-    glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load("glPrimitiveRestartIndex", userptr);
-    glTexBuffer = (PFNGLTEXBUFFERPROC) load("glTexBuffer", userptr);
-    glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load("glUniformBlockBinding", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_2) return;
-    glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load("glClientWaitSync", userptr);
-    glDeleteSync = (PFNGLDELETESYNCPROC) load("glDeleteSync", userptr);
-    glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load("glDrawElementsBaseVertex", userptr);
-    glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load("glDrawElementsInstancedBaseVertex", userptr);
-    glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load("glDrawRangeElementsBaseVertex", userptr);
-    glFenceSync = (PFNGLFENCESYNCPROC) load("glFenceSync", userptr);
-    glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load("glFramebufferTexture", userptr);
-    glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load("glGetBufferParameteri64v", userptr);
-    glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load("glGetInteger64i_v", userptr);
-    glGetInteger64v = (PFNGLGETINTEGER64VPROC) load("glGetInteger64v", userptr);
-    glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load("glGetMultisamplefv", userptr);
-    glGetSynciv = (PFNGLGETSYNCIVPROC) load("glGetSynciv", userptr);
-    glIsSync = (PFNGLISSYNCPROC) load("glIsSync", userptr);
-    glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load("glMultiDrawElementsBaseVertex", userptr);
-    glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load("glProvokingVertex", userptr);
-    glSampleMaski = (PFNGLSAMPLEMASKIPROC) load("glSampleMaski", userptr);
-    glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load("glTexImage2DMultisample", userptr);
-    glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load("glTexImage3DMultisample", userptr);
-    glWaitSync = (PFNGLWAITSYNCPROC) load("glWaitSync", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_3) return;
-    glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load("glBindFragDataLocationIndexed", userptr);
-    glBindSampler = (PFNGLBINDSAMPLERPROC) load("glBindSampler", userptr);
-    glColorP3ui = (PFNGLCOLORP3UIPROC) load("glColorP3ui", userptr);
-    glColorP3uiv = (PFNGLCOLORP3UIVPROC) load("glColorP3uiv", userptr);
-    glColorP4ui = (PFNGLCOLORP4UIPROC) load("glColorP4ui", userptr);
-    glColorP4uiv = (PFNGLCOLORP4UIVPROC) load("glColorP4uiv", userptr);
-    glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load("glDeleteSamplers", userptr);
-    glGenSamplers = (PFNGLGENSAMPLERSPROC) load("glGenSamplers", userptr);
-    glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load("glGetFragDataIndex", userptr);
-    glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load("glGetQueryObjecti64v", userptr);
-    glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load("glGetQueryObjectui64v", userptr);
-    glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load("glGetSamplerParameterIiv", userptr);
-    glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load("glGetSamplerParameterIuiv", userptr);
-    glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load("glGetSamplerParameterfv", userptr);
-    glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load("glGetSamplerParameteriv", userptr);
-    glIsSampler = (PFNGLISSAMPLERPROC) load("glIsSampler", userptr);
-    glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load("glMultiTexCoordP1ui", userptr);
-    glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load("glMultiTexCoordP1uiv", userptr);
-    glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load("glMultiTexCoordP2ui", userptr);
-    glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load("glMultiTexCoordP2uiv", userptr);
-    glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load("glMultiTexCoordP3ui", userptr);
-    glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load("glMultiTexCoordP3uiv", userptr);
-    glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load("glMultiTexCoordP4ui", userptr);
-    glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load("glMultiTexCoordP4uiv", userptr);
-    glNormalP3ui = (PFNGLNORMALP3UIPROC) load("glNormalP3ui", userptr);
-    glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load("glNormalP3uiv", userptr);
-    glQueryCounter = (PFNGLQUERYCOUNTERPROC) load("glQueryCounter", userptr);
-    glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load("glSamplerParameterIiv", userptr);
-    glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load("glSamplerParameterIuiv", userptr);
-    glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load("glSamplerParameterf", userptr);
-    glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load("glSamplerParameterfv", userptr);
-    glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load("glSamplerParameteri", userptr);
-    glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load("glSamplerParameteriv", userptr);
-    glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load("glSecondaryColorP3ui", userptr);
-    glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load("glSecondaryColorP3uiv", userptr);
-    glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load("glTexCoordP1ui", userptr);
-    glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load("glTexCoordP1uiv", userptr);
-    glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load("glTexCoordP2ui", userptr);
-    glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load("glTexCoordP2uiv", userptr);
-    glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load("glTexCoordP3ui", userptr);
-    glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load("glTexCoordP3uiv", userptr);
-    glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load("glTexCoordP4ui", userptr);
-    glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load("glTexCoordP4uiv", userptr);
-    glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load("glVertexAttribDivisor", userptr);
-    glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load("glVertexAttribP1ui", userptr);
-    glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load("glVertexAttribP1uiv", userptr);
-    glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load("glVertexAttribP2ui", userptr);
-    glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load("glVertexAttribP2uiv", userptr);
-    glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load("glVertexAttribP3ui", userptr);
-    glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load("glVertexAttribP3uiv", userptr);
-    glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load("glVertexAttribP4ui", userptr);
-    glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load("glVertexAttribP4uiv", userptr);
-    glVertexP2ui = (PFNGLVERTEXP2UIPROC) load("glVertexP2ui", userptr);
-    glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load("glVertexP2uiv", userptr);
-    glVertexP3ui = (PFNGLVERTEXP3UIPROC) load("glVertexP3ui", userptr);
-    glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load("glVertexP3uiv", userptr);
-    glVertexP4ui = (PFNGLVERTEXP4UIPROC) load("glVertexP4ui", userptr);
-    glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load("glVertexP4uiv", userptr);
-}
-static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_ARB_multisample) return;
-    glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr);
-    glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load("glSampleCoverageARB", userptr);
-}
-static void glad_gl_load_GL_ARB_robustness( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_ARB_robustness) return;
-    glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC) load("glGetGraphicsResetStatusARB", userptr);
-    glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC) load("glGetnColorTableARB", userptr);
-    glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) load("glGetnCompressedTexImageARB", userptr);
-    glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC) load("glGetnConvolutionFilterARB", userptr);
-    glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC) load("glGetnHistogramARB", userptr);
-    glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC) load("glGetnMapdvARB", userptr);
-    glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC) load("glGetnMapfvARB", userptr);
-    glGetnMapivARB = (PFNGLGETNMAPIVARBPROC) load("glGetnMapivARB", userptr);
-    glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC) load("glGetnMinmaxARB", userptr);
-    glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC) load("glGetnPixelMapfvARB", userptr);
-    glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC) load("glGetnPixelMapuivARB", userptr);
-    glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC) load("glGetnPixelMapusvARB", userptr);
-    glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC) load("glGetnPolygonStippleARB", userptr);
-    glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC) load("glGetnSeparableFilterARB", userptr);
-    glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC) load("glGetnTexImageARB", userptr);
-    glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC) load("glGetnUniformdvARB", userptr);
-    glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC) load("glGetnUniformfvARB", userptr);
-    glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC) load("glGetnUniformivARB", userptr);
-    glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC) load("glGetnUniformuivARB", userptr);
-    glReadnPixels = (PFNGLREADNPIXELSPROC) load("glReadnPixels", userptr);
-    glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC) load("glReadnPixelsARB", userptr);
-}
-static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_KHR_debug) return;
-    glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load("glDebugMessageCallback", userptr);
-    glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load("glDebugMessageControl", userptr);
-    glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load("glDebugMessageInsert", userptr);
-    glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load("glGetDebugMessageLog", userptr);
-    glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load("glGetObjectLabel", userptr);
-    glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load("glGetObjectPtrLabel", userptr);
-    glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr);
-    glObjectLabel = (PFNGLOBJECTLABELPROC) load("glObjectLabel", userptr);
-    glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load("glObjectPtrLabel", userptr);
-    glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load("glPopDebugGroup", userptr);
-    glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load("glPushDebugGroup", userptr);
-}
-
-
-
-#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
-#define GLAD_GL_IS_SOME_NEW_VERSION 1
-#else
-#define GLAD_GL_IS_SOME_NEW_VERSION 0
-#endif
-
-static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
-#if GLAD_GL_IS_SOME_NEW_VERSION
-    if(GLAD_VERSION_MAJOR(version) < 3) {
-#else
-    (void) version;
-    (void) out_num_exts_i;
-    (void) out_exts_i;
-#endif
-        if (glGetString == NULL) {
-            return 0;
-        }
-        *out_exts = (const char *)glGetString(GL_EXTENSIONS);
-#if GLAD_GL_IS_SOME_NEW_VERSION
-    } else {
-        unsigned int index = 0;
-        unsigned int num_exts_i = 0;
-        char **exts_i = NULL;
-        if (glGetStringi == NULL || glGetIntegerv == NULL) {
-            return 0;
-        }
-        glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
-        if (num_exts_i > 0) {
-            exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
-        }
-        if (exts_i == NULL) {
-            return 0;
-        }
-        for(index = 0; index < num_exts_i; index++) {
-            const char *gl_str_tmp = (const char*) glGetStringi(GL_EXTENSIONS, index);
-            size_t len = strlen(gl_str_tmp) + 1;
-
-            char *local_str = (char*) malloc(len * sizeof(char));
-            if(local_str != NULL) {
-                memcpy(local_str, gl_str_tmp, len * sizeof(char));
-            }
-
-            exts_i[index] = local_str;
-        }
-
-        *out_num_exts_i = num_exts_i;
-        *out_exts_i = exts_i;
-    }
-#endif
-    return 1;
-}
-static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
-    if (exts_i != NULL) {
-        unsigned int index;
-        for(index = 0; index < num_exts_i; index++) {
-            free((void *) (exts_i[index]));
-        }
-        free((void *)exts_i);
-        exts_i = NULL;
-    }
-}
-static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
-    if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
-        const char *extensions;
-        const char *loc;
-        const char *terminator;
-        extensions = exts;
-        if(extensions == NULL || ext == NULL) {
-            return 0;
-        }
-        while(1) {
-            loc = strstr(extensions, ext);
-            if(loc == NULL) {
-                return 0;
-            }
-            terminator = loc + strlen(ext);
-            if((loc == extensions || *(loc - 1) == ' ') &&
-                (*terminator == ' ' || *terminator == '\0')) {
-                return 1;
-            }
-            extensions = terminator;
-        }
-    } else {
-        unsigned int index;
-        for(index = 0; index < num_exts_i; index++) {
-            const char *e = exts_i[index];
-            if(strcmp(e, ext) == 0) {
-                return 1;
-            }
-        }
-    }
-    return 0;
-}
-
-static GLADapiproc glad_gl_get_proc_from_userptr(const char* name, void *userptr) {
-    return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
-}
-
-static int glad_gl_find_extensions_gl( int version) {
-    const char *exts = NULL;
-    unsigned int num_exts_i = 0;
-    char **exts_i = NULL;
-    if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
-
-    GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample");
-    GLAD_GL_ARB_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_robustness");
-    GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
-
-    glad_gl_free_extensions(exts_i, num_exts_i);
-
-    return 1;
-}
-
-static int glad_gl_find_core_gl(void) {
-    int i, major, minor;
-    const char* version;
-    const char* prefixes[] = {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-    version = (const char*) glGetString(GL_VERSION);
-    if (!version) return 0;
-    for (i = 0;  prefixes[i];  i++) {
-        const size_t length = strlen(prefixes[i]);
-        if (strncmp(version, prefixes[i], length) == 0) {
-            version += length;
-            break;
-        }
-    }
-
-    GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
-
-    GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-    GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-    GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
-    GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
-    GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
-    GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
-    GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
-    GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
-    GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
-    GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
-    GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
-    GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
-
-    return GLAD_MAKE_VERSION(major, minor);
-}
-
-int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
-    int version;
-
-    glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr);
-    if(glGetString == NULL) return 0;
-    if(glGetString(GL_VERSION) == NULL) return 0;
-    version = glad_gl_find_core_gl();
-
-    glad_gl_load_GL_VERSION_1_0(load, userptr);
-    glad_gl_load_GL_VERSION_1_1(load, userptr);
-    glad_gl_load_GL_VERSION_1_2(load, userptr);
-    glad_gl_load_GL_VERSION_1_3(load, userptr);
-    glad_gl_load_GL_VERSION_1_4(load, userptr);
-    glad_gl_load_GL_VERSION_1_5(load, userptr);
-    glad_gl_load_GL_VERSION_2_0(load, userptr);
-    glad_gl_load_GL_VERSION_2_1(load, userptr);
-    glad_gl_load_GL_VERSION_3_0(load, userptr);
-    glad_gl_load_GL_VERSION_3_1(load, userptr);
-    glad_gl_load_GL_VERSION_3_2(load, userptr);
-    glad_gl_load_GL_VERSION_3_3(load, userptr);
-
-    if (!glad_gl_find_extensions_gl(version)) return 0;
-    glad_gl_load_GL_ARB_multisample(load, userptr);
-    glad_gl_load_GL_ARB_robustness(load, userptr);
-    glad_gl_load_GL_KHR_debug(load, userptr);
-
-
-
-    return version;
-}
-
-
-int gladLoadGL( GLADloadfunc load) {
-    return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
-}
-
-
-
-
diff --git a/raylib/external/glfw/deps/glad_vulkan.c b/raylib/external/glfw/deps/glad_vulkan.c
deleted file mode 100644 (file)
index 5adfbbb..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glad/vulkan.h>
-
-#ifndef GLAD_IMPL_UTIL_C_
-#define GLAD_IMPL_UTIL_C_
-
-#ifdef _MSC_VER
-#define GLAD_IMPL_UTIL_SSCANF sscanf_s
-#else
-#define GLAD_IMPL_UTIL_SSCANF sscanf
-#endif
-
-#endif /* GLAD_IMPL_UTIL_C_ */
-
-
-int GLAD_VK_VERSION_1_0 = 0;
-int GLAD_VK_VERSION_1_1 = 0;
-int GLAD_VK_EXT_debug_report = 0;
-int GLAD_VK_KHR_surface = 0;
-int GLAD_VK_KHR_swapchain = 0;
-
-
-
-PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL;
-PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL;
-PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL;
-PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL;
-PFN_vkAllocateMemory glad_vkAllocateMemory = NULL;
-PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL;
-PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL;
-PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL;
-PFN_vkBindImageMemory glad_vkBindImageMemory = NULL;
-PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL;
-PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL;
-PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL;
-PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL;
-PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL;
-PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL;
-PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL;
-PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL;
-PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL;
-PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL;
-PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL;
-PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL;
-PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL;
-PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL;
-PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL;
-PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL;
-PFN_vkCmdDispatch glad_vkCmdDispatch = NULL;
-PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL;
-PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL;
-PFN_vkCmdDraw glad_vkCmdDraw = NULL;
-PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL;
-PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL;
-PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL;
-PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL;
-PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL;
-PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL;
-PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL;
-PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL;
-PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL;
-PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL;
-PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL;
-PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL;
-PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL;
-PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL;
-PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL;
-PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL;
-PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL;
-PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL;
-PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL;
-PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL;
-PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL;
-PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL;
-PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL;
-PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL;
-PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL;
-PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL;
-PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL;
-PFN_vkCreateBuffer glad_vkCreateBuffer = NULL;
-PFN_vkCreateBufferView glad_vkCreateBufferView = NULL;
-PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL;
-PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL;
-PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL;
-PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL;
-PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL;
-PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL;
-PFN_vkCreateDevice glad_vkCreateDevice = NULL;
-PFN_vkCreateEvent glad_vkCreateEvent = NULL;
-PFN_vkCreateFence glad_vkCreateFence = NULL;
-PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL;
-PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL;
-PFN_vkCreateImage glad_vkCreateImage = NULL;
-PFN_vkCreateImageView glad_vkCreateImageView = NULL;
-PFN_vkCreateInstance glad_vkCreateInstance = NULL;
-PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL;
-PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL;
-PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL;
-PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL;
-PFN_vkCreateSampler glad_vkCreateSampler = NULL;
-PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL;
-PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL;
-PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL;
-PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL;
-PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL;
-PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL;
-PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL;
-PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL;
-PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL;
-PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL;
-PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL;
-PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL;
-PFN_vkDestroyDevice glad_vkDestroyDevice = NULL;
-PFN_vkDestroyEvent glad_vkDestroyEvent = NULL;
-PFN_vkDestroyFence glad_vkDestroyFence = NULL;
-PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL;
-PFN_vkDestroyImage glad_vkDestroyImage = NULL;
-PFN_vkDestroyImageView glad_vkDestroyImageView = NULL;
-PFN_vkDestroyInstance glad_vkDestroyInstance = NULL;
-PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL;
-PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL;
-PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL;
-PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL;
-PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL;
-PFN_vkDestroySampler glad_vkDestroySampler = NULL;
-PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL;
-PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL;
-PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL;
-PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL;
-PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL;
-PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL;
-PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL;
-PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL;
-PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL;
-PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL;
-PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL;
-PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL;
-PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL;
-PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL;
-PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL;
-PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL;
-PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL;
-PFN_vkFreeMemory glad_vkFreeMemory = NULL;
-PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL;
-PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL;
-PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL;
-PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL;
-PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL;
-PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL;
-PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL;
-PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL;
-PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL;
-PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL;
-PFN_vkGetEventStatus glad_vkGetEventStatus = NULL;
-PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL;
-PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL;
-PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL;
-PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL;
-PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL;
-PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL;
-PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL;
-PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL;
-PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL;
-PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL;
-PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL;
-PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL;
-PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL;
-PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL;
-PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL;
-PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL;
-PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL;
-PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL;
-PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL;
-PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL;
-PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL;
-PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL;
-PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL;
-PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL;
-PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL;
-PFN_vkMapMemory glad_vkMapMemory = NULL;
-PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL;
-PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL;
-PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL;
-PFN_vkQueueSubmit glad_vkQueueSubmit = NULL;
-PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL;
-PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL;
-PFN_vkResetCommandPool glad_vkResetCommandPool = NULL;
-PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL;
-PFN_vkResetEvent glad_vkResetEvent = NULL;
-PFN_vkResetFences glad_vkResetFences = NULL;
-PFN_vkSetEvent glad_vkSetEvent = NULL;
-PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL;
-PFN_vkUnmapMemory glad_vkUnmapMemory = NULL;
-PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL;
-PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL;
-PFN_vkWaitForFences glad_vkWaitForFences = NULL;
-
-
-static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_VERSION_1_0) return;
-    vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load("vkAllocateCommandBuffers", userptr);
-    vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load("vkAllocateDescriptorSets", userptr);
-    vkAllocateMemory = (PFN_vkAllocateMemory) load("vkAllocateMemory", userptr);
-    vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load("vkBeginCommandBuffer", userptr);
-    vkBindBufferMemory = (PFN_vkBindBufferMemory) load("vkBindBufferMemory", userptr);
-    vkBindImageMemory = (PFN_vkBindImageMemory) load("vkBindImageMemory", userptr);
-    vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load("vkCmdBeginQuery", userptr);
-    vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load("vkCmdBeginRenderPass", userptr);
-    vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load("vkCmdBindDescriptorSets", userptr);
-    vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load("vkCmdBindIndexBuffer", userptr);
-    vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load("vkCmdBindPipeline", userptr);
-    vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load("vkCmdBindVertexBuffers", userptr);
-    vkCmdBlitImage = (PFN_vkCmdBlitImage) load("vkCmdBlitImage", userptr);
-    vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load("vkCmdClearAttachments", userptr);
-    vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load("vkCmdClearColorImage", userptr);
-    vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load("vkCmdClearDepthStencilImage", userptr);
-    vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load("vkCmdCopyBuffer", userptr);
-    vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load("vkCmdCopyBufferToImage", userptr);
-    vkCmdCopyImage = (PFN_vkCmdCopyImage) load("vkCmdCopyImage", userptr);
-    vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load("vkCmdCopyImageToBuffer", userptr);
-    vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load("vkCmdCopyQueryPoolResults", userptr);
-    vkCmdDispatch = (PFN_vkCmdDispatch) load("vkCmdDispatch", userptr);
-    vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load("vkCmdDispatchIndirect", userptr);
-    vkCmdDraw = (PFN_vkCmdDraw) load("vkCmdDraw", userptr);
-    vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load("vkCmdDrawIndexed", userptr);
-    vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load("vkCmdDrawIndexedIndirect", userptr);
-    vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load("vkCmdDrawIndirect", userptr);
-    vkCmdEndQuery = (PFN_vkCmdEndQuery) load("vkCmdEndQuery", userptr);
-    vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load("vkCmdEndRenderPass", userptr);
-    vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load("vkCmdExecuteCommands", userptr);
-    vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load("vkCmdFillBuffer", userptr);
-    vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load("vkCmdNextSubpass", userptr);
-    vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load("vkCmdPipelineBarrier", userptr);
-    vkCmdPushConstants = (PFN_vkCmdPushConstants) load("vkCmdPushConstants", userptr);
-    vkCmdResetEvent = (PFN_vkCmdResetEvent) load("vkCmdResetEvent", userptr);
-    vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load("vkCmdResetQueryPool", userptr);
-    vkCmdResolveImage = (PFN_vkCmdResolveImage) load("vkCmdResolveImage", userptr);
-    vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load("vkCmdSetBlendConstants", userptr);
-    vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load("vkCmdSetDepthBias", userptr);
-    vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load("vkCmdSetDepthBounds", userptr);
-    vkCmdSetEvent = (PFN_vkCmdSetEvent) load("vkCmdSetEvent", userptr);
-    vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load("vkCmdSetLineWidth", userptr);
-    vkCmdSetScissor = (PFN_vkCmdSetScissor) load("vkCmdSetScissor", userptr);
-    vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load("vkCmdSetStencilCompareMask", userptr);
-    vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load("vkCmdSetStencilReference", userptr);
-    vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load("vkCmdSetStencilWriteMask", userptr);
-    vkCmdSetViewport = (PFN_vkCmdSetViewport) load("vkCmdSetViewport", userptr);
-    vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load("vkCmdUpdateBuffer", userptr);
-    vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load("vkCmdWaitEvents", userptr);
-    vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load("vkCmdWriteTimestamp", userptr);
-    vkCreateBuffer = (PFN_vkCreateBuffer) load("vkCreateBuffer", userptr);
-    vkCreateBufferView = (PFN_vkCreateBufferView) load("vkCreateBufferView", userptr);
-    vkCreateCommandPool = (PFN_vkCreateCommandPool) load("vkCreateCommandPool", userptr);
-    vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load("vkCreateComputePipelines", userptr);
-    vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load("vkCreateDescriptorPool", userptr);
-    vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load("vkCreateDescriptorSetLayout", userptr);
-    vkCreateDevice = (PFN_vkCreateDevice) load("vkCreateDevice", userptr);
-    vkCreateEvent = (PFN_vkCreateEvent) load("vkCreateEvent", userptr);
-    vkCreateFence = (PFN_vkCreateFence) load("vkCreateFence", userptr);
-    vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load("vkCreateFramebuffer", userptr);
-    vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load("vkCreateGraphicsPipelines", userptr);
-    vkCreateImage = (PFN_vkCreateImage) load("vkCreateImage", userptr);
-    vkCreateImageView = (PFN_vkCreateImageView) load("vkCreateImageView", userptr);
-    vkCreateInstance = (PFN_vkCreateInstance) load("vkCreateInstance", userptr);
-    vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load("vkCreatePipelineCache", userptr);
-    vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load("vkCreatePipelineLayout", userptr);
-    vkCreateQueryPool = (PFN_vkCreateQueryPool) load("vkCreateQueryPool", userptr);
-    vkCreateRenderPass = (PFN_vkCreateRenderPass) load("vkCreateRenderPass", userptr);
-    vkCreateSampler = (PFN_vkCreateSampler) load("vkCreateSampler", userptr);
-    vkCreateSemaphore = (PFN_vkCreateSemaphore) load("vkCreateSemaphore", userptr);
-    vkCreateShaderModule = (PFN_vkCreateShaderModule) load("vkCreateShaderModule", userptr);
-    vkDestroyBuffer = (PFN_vkDestroyBuffer) load("vkDestroyBuffer", userptr);
-    vkDestroyBufferView = (PFN_vkDestroyBufferView) load("vkDestroyBufferView", userptr);
-    vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load("vkDestroyCommandPool", userptr);
-    vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load("vkDestroyDescriptorPool", userptr);
-    vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load("vkDestroyDescriptorSetLayout", userptr);
-    vkDestroyDevice = (PFN_vkDestroyDevice) load("vkDestroyDevice", userptr);
-    vkDestroyEvent = (PFN_vkDestroyEvent) load("vkDestroyEvent", userptr);
-    vkDestroyFence = (PFN_vkDestroyFence) load("vkDestroyFence", userptr);
-    vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load("vkDestroyFramebuffer", userptr);
-    vkDestroyImage = (PFN_vkDestroyImage) load("vkDestroyImage", userptr);
-    vkDestroyImageView = (PFN_vkDestroyImageView) load("vkDestroyImageView", userptr);
-    vkDestroyInstance = (PFN_vkDestroyInstance) load("vkDestroyInstance", userptr);
-    vkDestroyPipeline = (PFN_vkDestroyPipeline) load("vkDestroyPipeline", userptr);
-    vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load("vkDestroyPipelineCache", userptr);
-    vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load("vkDestroyPipelineLayout", userptr);
-    vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load("vkDestroyQueryPool", userptr);
-    vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load("vkDestroyRenderPass", userptr);
-    vkDestroySampler = (PFN_vkDestroySampler) load("vkDestroySampler", userptr);
-    vkDestroySemaphore = (PFN_vkDestroySemaphore) load("vkDestroySemaphore", userptr);
-    vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load("vkDestroyShaderModule", userptr);
-    vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load("vkDeviceWaitIdle", userptr);
-    vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load("vkEndCommandBuffer", userptr);
-    vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load("vkEnumerateDeviceExtensionProperties", userptr);
-    vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load("vkEnumerateDeviceLayerProperties", userptr);
-    vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load("vkEnumerateInstanceExtensionProperties", userptr);
-    vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load("vkEnumerateInstanceLayerProperties", userptr);
-    vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load("vkEnumeratePhysicalDevices", userptr);
-    vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load("vkFlushMappedMemoryRanges", userptr);
-    vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load("vkFreeCommandBuffers", userptr);
-    vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load("vkFreeDescriptorSets", userptr);
-    vkFreeMemory = (PFN_vkFreeMemory) load("vkFreeMemory", userptr);
-    vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load("vkGetBufferMemoryRequirements", userptr);
-    vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load("vkGetDeviceMemoryCommitment", userptr);
-    vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load("vkGetDeviceProcAddr", userptr);
-    vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load("vkGetDeviceQueue", userptr);
-    vkGetEventStatus = (PFN_vkGetEventStatus) load("vkGetEventStatus", userptr);
-    vkGetFenceStatus = (PFN_vkGetFenceStatus) load("vkGetFenceStatus", userptr);
-    vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load("vkGetImageMemoryRequirements", userptr);
-    vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load("vkGetImageSparseMemoryRequirements", userptr);
-    vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load("vkGetImageSubresourceLayout", userptr);
-    vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load("vkGetInstanceProcAddr", userptr);
-    vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load("vkGetPhysicalDeviceFeatures", userptr);
-    vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load("vkGetPhysicalDeviceFormatProperties", userptr);
-    vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load("vkGetPhysicalDeviceImageFormatProperties", userptr);
-    vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load("vkGetPhysicalDeviceMemoryProperties", userptr);
-    vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load("vkGetPhysicalDeviceProperties", userptr);
-    vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load("vkGetPhysicalDeviceQueueFamilyProperties", userptr);
-    vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load("vkGetPhysicalDeviceSparseImageFormatProperties", userptr);
-    vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load("vkGetPipelineCacheData", userptr);
-    vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load("vkGetQueryPoolResults", userptr);
-    vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load("vkGetRenderAreaGranularity", userptr);
-    vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load("vkInvalidateMappedMemoryRanges", userptr);
-    vkMapMemory = (PFN_vkMapMemory) load("vkMapMemory", userptr);
-    vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load("vkMergePipelineCaches", userptr);
-    vkQueueBindSparse = (PFN_vkQueueBindSparse) load("vkQueueBindSparse", userptr);
-    vkQueueSubmit = (PFN_vkQueueSubmit) load("vkQueueSubmit", userptr);
-    vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load("vkQueueWaitIdle", userptr);
-    vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load("vkResetCommandBuffer", userptr);
-    vkResetCommandPool = (PFN_vkResetCommandPool) load("vkResetCommandPool", userptr);
-    vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load("vkResetDescriptorPool", userptr);
-    vkResetEvent = (PFN_vkResetEvent) load("vkResetEvent", userptr);
-    vkResetFences = (PFN_vkResetFences) load("vkResetFences", userptr);
-    vkSetEvent = (PFN_vkSetEvent) load("vkSetEvent", userptr);
-    vkUnmapMemory = (PFN_vkUnmapMemory) load("vkUnmapMemory", userptr);
-    vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load("vkUpdateDescriptorSets", userptr);
-    vkWaitForFences = (PFN_vkWaitForFences) load("vkWaitForFences", userptr);
-}
-static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_VERSION_1_1) return;
-    vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load("vkBindBufferMemory2", userptr);
-    vkBindImageMemory2 = (PFN_vkBindImageMemory2) load("vkBindImageMemory2", userptr);
-    vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load("vkCmdDispatchBase", userptr);
-    vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load("vkCmdSetDeviceMask", userptr);
-    vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load("vkCreateDescriptorUpdateTemplate", userptr);
-    vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load("vkCreateSamplerYcbcrConversion", userptr);
-    vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load("vkDestroyDescriptorUpdateTemplate", userptr);
-    vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load("vkDestroySamplerYcbcrConversion", userptr);
-    vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
-    vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load("vkEnumeratePhysicalDeviceGroups", userptr);
-    vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load("vkGetBufferMemoryRequirements2", userptr);
-    vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load("vkGetDescriptorSetLayoutSupport", userptr);
-    vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load("vkGetDeviceGroupPeerMemoryFeatures", userptr);
-    vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load("vkGetDeviceQueue2", userptr);
-    vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load("vkGetImageMemoryRequirements2", userptr);
-    vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load("vkGetImageSparseMemoryRequirements2", userptr);
-    vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load("vkGetPhysicalDeviceExternalBufferProperties", userptr);
-    vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load("vkGetPhysicalDeviceExternalFenceProperties", userptr);
-    vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load("vkGetPhysicalDeviceExternalSemaphoreProperties", userptr);
-    vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load("vkGetPhysicalDeviceFeatures2", userptr);
-    vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load("vkGetPhysicalDeviceFormatProperties2", userptr);
-    vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load("vkGetPhysicalDeviceImageFormatProperties2", userptr);
-    vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load("vkGetPhysicalDeviceMemoryProperties2", userptr);
-    vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load("vkGetPhysicalDeviceProperties2", userptr);
-    vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load("vkGetPhysicalDeviceQueueFamilyProperties2", userptr);
-    vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load("vkGetPhysicalDeviceSparseImageFormatProperties2", userptr);
-    vkTrimCommandPool = (PFN_vkTrimCommandPool) load("vkTrimCommandPool", userptr);
-    vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load("vkUpdateDescriptorSetWithTemplate", userptr);
-}
-static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_EXT_debug_report) return;
-    vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load("vkCreateDebugReportCallbackEXT", userptr);
-    vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load("vkDebugReportMessageEXT", userptr);
-    vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load("vkDestroyDebugReportCallbackEXT", userptr);
-}
-static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_KHR_surface) return;
-    vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load("vkDestroySurfaceKHR", userptr);
-    vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", userptr);
-    vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load("vkGetPhysicalDeviceSurfaceFormatsKHR", userptr);
-    vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load("vkGetPhysicalDeviceSurfacePresentModesKHR", userptr);
-    vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load("vkGetPhysicalDeviceSurfaceSupportKHR", userptr);
-}
-static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_KHR_swapchain) return;
-    vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load("vkAcquireNextImage2KHR", userptr);
-    vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load("vkAcquireNextImageKHR", userptr);
-    vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load("vkCreateSwapchainKHR", userptr);
-    vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load("vkDestroySwapchainKHR", userptr);
-    vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load("vkGetDeviceGroupPresentCapabilitiesKHR", userptr);
-    vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load("vkGetDeviceGroupSurfacePresentModesKHR", userptr);
-    vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load("vkGetPhysicalDevicePresentRectanglesKHR", userptr);
-    vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load("vkGetSwapchainImagesKHR", userptr);
-    vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load("vkQueuePresentKHR", userptr);
-}
-
-
-
-static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
-    uint32_t i;
-    uint32_t instance_extension_count = 0;
-    uint32_t device_extension_count = 0;
-    uint32_t max_extension_count;
-    uint32_t total_extension_count;
-    char **extensions;
-    VkExtensionProperties *ext_properties;
-    VkResult result;
-
-    if (vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && vkEnumerateDeviceExtensionProperties == NULL)) {
-        return 0;
-    }
-
-    result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
-    if (result != VK_SUCCESS) {
-        return 0;
-    }
-
-    if (physical_device != NULL) {
-        result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL);
-        if (result != VK_SUCCESS) {
-            return 0;
-        }
-    }
-
-    total_extension_count = instance_extension_count + device_extension_count;
-    max_extension_count = instance_extension_count > device_extension_count
-        ? instance_extension_count : device_extension_count;
-
-    ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
-    if (ext_properties == NULL) {
-        return 0;
-    }
-
-    result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties);
-    if (result != VK_SUCCESS) {
-        free((void*) ext_properties);
-        return 0;
-    }
-
-    extensions = (char**) calloc(total_extension_count, sizeof(char*));
-    if (extensions == NULL) {
-        free((void*) ext_properties);
-        return 0;
-    }
-
-    for (i = 0; i < instance_extension_count; ++i) {
-        VkExtensionProperties ext = ext_properties[i];
-
-        size_t extension_name_length = strlen(ext.extensionName) + 1;
-        extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
-        memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
-    }
-
-    if (physical_device != NULL) {
-        result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties);
-        if (result != VK_SUCCESS) {
-            for (i = 0; i < instance_extension_count; ++i) {
-                free((void*) extensions[i]);
-            }
-            free(extensions);
-            return 0;
-        }
-
-        for (i = 0; i < device_extension_count; ++i) {
-            VkExtensionProperties ext = ext_properties[i];
-
-            size_t extension_name_length = strlen(ext.extensionName) + 1;
-            extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
-            memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
-        }
-    }
-
-    free((void*) ext_properties);
-
-    *out_extension_count = total_extension_count;
-    *out_extensions = extensions;
-
-    return 1;
-}
-
-static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
-    uint32_t i;
-
-    for(i = 0; i < extension_count ; ++i) {
-        free((void*) (extensions[i]));
-    }
-
-    free((void*) extensions);
-}
-
-static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
-    uint32_t i;
-
-    for (i = 0; i < extension_count; ++i) {
-        if(strcmp(name, extensions[i]) == 0) {
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-static GLADapiproc glad_vk_get_proc_from_userptr(const char* name, void *userptr) {
-    return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
-}
-
-static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) {
-    uint32_t extension_count = 0;
-    char **extensions = NULL;
-    if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0;
-
-    GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions);
-    GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions);
-    GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions);
-
-    glad_vk_free_extensions(extension_count, extensions);
-
-    return 1;
-}
-
-static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) {
-    int major = 1;
-    int minor = 0;
-
-#ifdef VK_VERSION_1_1
-    if (vkEnumerateInstanceVersion  != NULL) {
-        uint32_t version;
-        VkResult result;
-
-        result = vkEnumerateInstanceVersion(&version);
-        if (result == VK_SUCCESS) {
-            major = (int) VK_VERSION_MAJOR(version);
-            minor = (int) VK_VERSION_MINOR(version);
-        }
-    }
-#endif
-
-    if (physical_device != NULL && vkGetPhysicalDeviceProperties  != NULL) {
-        VkPhysicalDeviceProperties properties;
-        vkGetPhysicalDeviceProperties(physical_device, &properties);
-
-        major = (int) VK_VERSION_MAJOR(properties.apiVersion);
-        minor = (int) VK_VERSION_MINOR(properties.apiVersion);
-    }
-
-    GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-    GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-
-    return GLAD_MAKE_VERSION(major, minor);
-}
-
-int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
-    int version;
-
-#ifdef VK_VERSION_1_1
-    vkEnumerateInstanceVersion  = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
-#endif
-    version = glad_vk_find_core_vulkan( physical_device);
-    if (!version) {
-        return 0;
-    }
-
-    glad_vk_load_VK_VERSION_1_0(load, userptr);
-    glad_vk_load_VK_VERSION_1_1(load, userptr);
-
-    if (!glad_vk_find_extensions_vulkan( physical_device)) return 0;
-    glad_vk_load_VK_EXT_debug_report(load, userptr);
-    glad_vk_load_VK_KHR_surface(load, userptr);
-    glad_vk_load_VK_KHR_swapchain(load, userptr);
-
-
-    return version;
-}
-
-
-int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) {
-    return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
-}
-
-
-
-
diff --git a/raylib/external/glfw/deps/mingw/_mingw_dxhelper.h b/raylib/external/glfw/deps/mingw/_mingw_dxhelper.h
deleted file mode 100644 (file)
index 849e291..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
- */
-
-#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
-#define NONAMELESSUNION                1
-#endif
-#if defined(NONAMELESSSTRUCT) && \
-   !defined(NONAMELESSUNION)
-#define NONAMELESSUNION                1
-#endif
-#if defined(NONAMELESSUNION)  && \
-   !defined(NONAMELESSSTRUCT)
-#define NONAMELESSSTRUCT       1
-#endif
-#if !defined(__GNU_EXTENSION)
-#if defined(__GNUC__) || defined(__GNUG__)
-#define __GNU_EXTENSION                __extension__
-#else
-#define __GNU_EXTENSION
-#endif
-#endif /* __extension__ */
-
-#ifndef __ANONYMOUS_DEFINED
-#define __ANONYMOUS_DEFINED
-#if defined(__GNUC__) || defined(__GNUG__)
-#define _ANONYMOUS_UNION       __extension__
-#define _ANONYMOUS_STRUCT      __extension__
-#else
-#define _ANONYMOUS_UNION
-#define _ANONYMOUS_STRUCT
-#endif
-#ifndef NONAMELESSUNION
-#define _UNION_NAME(x)
-#define _STRUCT_NAME(x)
-#else /* NONAMELESSUNION */
-#define _UNION_NAME(x)  x
-#define _STRUCT_NAME(x) x
-#endif
-#endif /* __ANONYMOUS_DEFINED */
-
-#ifndef DUMMYUNIONNAME
-# ifdef NONAMELESSUNION
-#  define DUMMYUNIONNAME  u
-#  define DUMMYUNIONNAME1 u1   /* Wine uses this variant */
-#  define DUMMYUNIONNAME2 u2
-#  define DUMMYUNIONNAME3 u3
-#  define DUMMYUNIONNAME4 u4
-#  define DUMMYUNIONNAME5 u5
-#  define DUMMYUNIONNAME6 u6
-#  define DUMMYUNIONNAME7 u7
-#  define DUMMYUNIONNAME8 u8
-#  define DUMMYUNIONNAME9 u9
-# else /* NONAMELESSUNION */
-#  define DUMMYUNIONNAME
-#  define DUMMYUNIONNAME1      /* Wine uses this variant */
-#  define DUMMYUNIONNAME2
-#  define DUMMYUNIONNAME3
-#  define DUMMYUNIONNAME4
-#  define DUMMYUNIONNAME5
-#  define DUMMYUNIONNAME6
-#  define DUMMYUNIONNAME7
-#  define DUMMYUNIONNAME8
-#  define DUMMYUNIONNAME9
-# endif
-#endif /* DUMMYUNIONNAME */
-
-#if !defined(DUMMYUNIONNAME1)  /* MinGW does not define this one */
-# ifdef NONAMELESSUNION
-#  define DUMMYUNIONNAME1 u1   /* Wine uses this variant */
-# else
-#  define DUMMYUNIONNAME1      /* Wine uses this variant */
-# endif
-#endif /* DUMMYUNIONNAME1 */
-
-#ifndef DUMMYSTRUCTNAME
-# ifdef NONAMELESSUNION
-#  define DUMMYSTRUCTNAME  s
-#  define DUMMYSTRUCTNAME1 s1  /* Wine uses this variant */
-#  define DUMMYSTRUCTNAME2 s2
-#  define DUMMYSTRUCTNAME3 s3
-#  define DUMMYSTRUCTNAME4 s4
-#  define DUMMYSTRUCTNAME5 s5
-# else
-#  define DUMMYSTRUCTNAME
-#  define DUMMYSTRUCTNAME1     /* Wine uses this variant */
-#  define DUMMYSTRUCTNAME2
-#  define DUMMYSTRUCTNAME3
-#  define DUMMYSTRUCTNAME4
-#  define DUMMYSTRUCTNAME5
-# endif
-#endif /* DUMMYSTRUCTNAME */
-
-/* These are for compatibility with the Wine source tree */
-
-#ifndef WINELIB_NAME_AW
-# ifdef __MINGW_NAME_AW
-#   define WINELIB_NAME_AW  __MINGW_NAME_AW
-# else
-#  ifdef UNICODE
-#   define WINELIB_NAME_AW(func) func##W
-#  else
-#   define WINELIB_NAME_AW(func) func##A
-#  endif
-# endif
-#endif /* WINELIB_NAME_AW */
-
-#ifndef DECL_WINELIB_TYPE_AW
-# ifdef __MINGW_TYPEDEF_AW
-#  define DECL_WINELIB_TYPE_AW  __MINGW_TYPEDEF_AW
-# else
-#  define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
-# endif
-#endif /* DECL_WINELIB_TYPE_AW */
-
diff --git a/raylib/external/glfw/deps/mingw/dinput.h b/raylib/external/glfw/deps/mingw/dinput.h
deleted file mode 100644 (file)
index b575480..0000000
+++ /dev/null
@@ -1,2467 +0,0 @@
-/*
- * Copyright (C) the Wine project
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __DINPUT_INCLUDED__
-#define __DINPUT_INCLUDED__
-
-#define COM_NO_WINDOWS_H
-#include <objbase.h>
-#include <_mingw_dxhelper.h>
-
-#ifndef DIRECTINPUT_VERSION
-#define DIRECTINPUT_VERSION    0x0800
-#endif
-
-/* Classes */
-DEFINE_GUID(CLSID_DirectInput,         0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(CLSID_DirectInputDevice,   0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-DEFINE_GUID(CLSID_DirectInput8,                0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(CLSID_DirectInputDevice8,  0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* Interfaces */
-DEFINE_GUID(IID_IDirectInputA,         0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputW,         0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput2A,                0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput2W,                0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput7A,                0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInput7W,                0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInput8A,                0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
-DEFINE_GUID(IID_IDirectInput8W,                0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
-DEFINE_GUID(IID_IDirectInputDeviceA,   0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDeviceW,   0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice2A,  0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice2W,  0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice7A,  0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInputDevice7W,  0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInputDevice8A,  0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
-DEFINE_GUID(IID_IDirectInputDevice8W,  0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
-DEFINE_GUID(IID_IDirectInputEffect,    0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-
-/* Predefined object types */
-DEFINE_GUID(GUID_XAxis,        0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_YAxis,        0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_ZAxis,        0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Key,  0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_POV,  0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* Predefined product GUIDs */
-DEFINE_GUID(GUID_SysMouse,     0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboard,  0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Joystick,     0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysMouseEm,   0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysMouseEm2,  0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboardEm,        0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* predefined forcefeedback effects */
-DEFINE_GUID(GUID_ConstantForce,        0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_RampForce,    0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Square,       0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Sine,         0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Triangle,     0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_SawtoothUp,   0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Spring,       0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Damper,       0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Inertia,      0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Friction,     0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_CustomForce,  0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-
-typedef struct IDirectInputA *LPDIRECTINPUTA;
-typedef struct IDirectInputW *LPDIRECTINPUTW;
-typedef struct IDirectInput2A *LPDIRECTINPUT2A;
-typedef struct IDirectInput2W *LPDIRECTINPUT2W;
-typedef struct IDirectInput7A *LPDIRECTINPUT7A;
-typedef struct IDirectInput7W *LPDIRECTINPUT7W;
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct IDirectInput8A *LPDIRECTINPUT8A;
-typedef struct IDirectInput8W *LPDIRECTINPUT8W;
-#endif /* DI8 */
-typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA;
-typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW;
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A;
-typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W;
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x0700
-typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A;
-typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W;
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A;
-typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W;
-#endif /* DI8 */
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT;
-#endif /* DI5 */
-typedef struct SysKeyboardA *LPSYSKEYBOARDA;
-typedef struct SysMouseA *LPSYSMOUSEA;
-
-#define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput)
-#define IDirectInput WINELIB_NAME_AW(IDirectInput)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT)
-#define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2)
-#define IDirectInput2 WINELIB_NAME_AW(IDirectInput2)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2)
-#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7)
-#define IDirectInput7 WINELIB_NAME_AW(IDirectInput7)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7)
-#if DIRECTINPUT_VERSION >= 0x0800
-#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8)
-#define IDirectInput8 WINELIB_NAME_AW(IDirectInput8)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8)
-#endif /* DI8 */
-#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice)
-#define IDirectInputDevice WINELIB_NAME_AW(IDirectInputDevice)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE)
-#if DIRECTINPUT_VERSION >= 0x0500
-#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2)
-#define IDirectInputDevice2 WINELIB_NAME_AW(IDirectInputDevice2)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2)
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x0700
-#define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7)
-#define IDirectInputDevice7 WINELIB_NAME_AW(IDirectInputDevice7)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7)
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
-#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8)
-#define IDirectInputDevice8 WINELIB_NAME_AW(IDirectInputDevice8)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8)
-#endif /* DI8 */
-
-#define DI_OK                           S_OK
-#define DI_NOTATTACHED                  S_FALSE
-#define DI_BUFFEROVERFLOW               S_FALSE
-#define DI_PROPNOEFFECT                 S_FALSE
-#define DI_NOEFFECT                     S_FALSE
-#define DI_POLLEDDEVICE                 ((HRESULT)0x00000002L)
-#define DI_DOWNLOADSKIPPED              ((HRESULT)0x00000003L)
-#define DI_EFFECTRESTARTED              ((HRESULT)0x00000004L)
-#define DI_TRUNCATED                    ((HRESULT)0x00000008L)
-#define DI_SETTINGSNOTSAVED             ((HRESULT)0x0000000BL)
-#define DI_TRUNCATEDANDRESTARTED        ((HRESULT)0x0000000CL)
-#define DI_WRITEPROTECT                 ((HRESULT)0x00000013L)
-
-#define DIERR_OLDDIRECTINPUTVERSION     \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
-#define DIERR_BETADIRECTINPUTVERSION    \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP)
-#define DIERR_BADDRIVERVER              \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL)
-#define DIERR_DEVICENOTREG              REGDB_E_CLASSNOTREG
-#define DIERR_NOTFOUND                  \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
-#define DIERR_OBJECTNOTFOUND            \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
-#define DIERR_INVALIDPARAM              E_INVALIDARG
-#define DIERR_NOINTERFACE               E_NOINTERFACE
-#define DIERR_GENERIC                   E_FAIL
-#define DIERR_OUTOFMEMORY               E_OUTOFMEMORY
-#define DIERR_UNSUPPORTED               E_NOTIMPL
-#define DIERR_NOTINITIALIZED            \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY)
-#define DIERR_ALREADYINITIALIZED        \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED)
-#define DIERR_NOAGGREGATION             CLASS_E_NOAGGREGATION
-#define DIERR_OTHERAPPHASPRIO           E_ACCESSDENIED
-#define DIERR_INPUTLOST                 \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT)
-#define DIERR_ACQUIRED                  \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY)
-#define DIERR_NOTACQUIRED               \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS)
-#define DIERR_READONLY                  E_ACCESSDENIED
-#define DIERR_HANDLEEXISTS              E_ACCESSDENIED
-#ifndef E_PENDING
-#define E_PENDING                       0x8000000AL
-#endif
-#define DIERR_INSUFFICIENTPRIVS         0x80040200L
-#define DIERR_DEVICEFULL                0x80040201L
-#define DIERR_MOREDATA                  0x80040202L
-#define DIERR_NOTDOWNLOADED             0x80040203L
-#define DIERR_HASEFFECTS                0x80040204L
-#define DIERR_NOTEXCLUSIVEACQUIRED      0x80040205L
-#define DIERR_INCOMPLETEEFFECT          0x80040206L
-#define DIERR_NOTBUFFERED               0x80040207L
-#define DIERR_EFFECTPLAYING             0x80040208L
-#define DIERR_UNPLUGGED                 0x80040209L
-#define DIERR_REPORTFULL                0x8004020AL
-#define DIERR_MAPFILEFAIL               0x8004020BL
-
-#define DIENUM_STOP                     0
-#define DIENUM_CONTINUE                 1
-
-#define DIEDFL_ALLDEVICES               0x00000000
-#define DIEDFL_ATTACHEDONLY             0x00000001
-#define DIEDFL_FORCEFEEDBACK            0x00000100
-#define DIEDFL_INCLUDEALIASES           0x00010000
-#define DIEDFL_INCLUDEPHANTOMS          0x00020000
-#define DIEDFL_INCLUDEHIDDEN           0x00040000
-
-#define DIDEVTYPE_DEVICE                1
-#define DIDEVTYPE_MOUSE                 2
-#define DIDEVTYPE_KEYBOARD              3
-#define DIDEVTYPE_JOYSTICK              4
-#define DIDEVTYPE_HID                   0x00010000
-
-#define DI8DEVCLASS_ALL             0
-#define DI8DEVCLASS_DEVICE          1
-#define DI8DEVCLASS_POINTER         2
-#define DI8DEVCLASS_KEYBOARD        3
-#define DI8DEVCLASS_GAMECTRL        4
-
-#define DI8DEVTYPE_DEVICE           0x11
-#define DI8DEVTYPE_MOUSE            0x12
-#define DI8DEVTYPE_KEYBOARD         0x13
-#define DI8DEVTYPE_JOYSTICK         0x14
-#define DI8DEVTYPE_GAMEPAD          0x15
-#define DI8DEVTYPE_DRIVING          0x16
-#define DI8DEVTYPE_FLIGHT           0x17
-#define DI8DEVTYPE_1STPERSON        0x18
-#define DI8DEVTYPE_DEVICECTRL       0x19
-#define DI8DEVTYPE_SCREENPOINTER    0x1A
-#define DI8DEVTYPE_REMOTE           0x1B
-#define DI8DEVTYPE_SUPPLEMENTAL     0x1C
-       
-#define DIDEVTYPEMOUSE_UNKNOWN          1
-#define DIDEVTYPEMOUSE_TRADITIONAL      2
-#define DIDEVTYPEMOUSE_FINGERSTICK      3
-#define DIDEVTYPEMOUSE_TOUCHPAD         4
-#define DIDEVTYPEMOUSE_TRACKBALL        5
-
-#define DIDEVTYPEKEYBOARD_UNKNOWN       0
-#define DIDEVTYPEKEYBOARD_PCXT          1
-#define DIDEVTYPEKEYBOARD_OLIVETTI      2
-#define DIDEVTYPEKEYBOARD_PCAT          3
-#define DIDEVTYPEKEYBOARD_PCENH         4
-#define DIDEVTYPEKEYBOARD_NOKIA1050     5
-#define DIDEVTYPEKEYBOARD_NOKIA9140     6
-#define DIDEVTYPEKEYBOARD_NEC98         7
-#define DIDEVTYPEKEYBOARD_NEC98LAPTOP   8
-#define DIDEVTYPEKEYBOARD_NEC98106      9
-#define DIDEVTYPEKEYBOARD_JAPAN106     10
-#define DIDEVTYPEKEYBOARD_JAPANAX      11
-#define DIDEVTYPEKEYBOARD_J3100        12
-
-#define DIDEVTYPEJOYSTICK_UNKNOWN       1
-#define DIDEVTYPEJOYSTICK_TRADITIONAL   2
-#define DIDEVTYPEJOYSTICK_FLIGHTSTICK   3
-#define DIDEVTYPEJOYSTICK_GAMEPAD       4
-#define DIDEVTYPEJOYSTICK_RUDDER        5
-#define DIDEVTYPEJOYSTICK_WHEEL         6
-#define DIDEVTYPEJOYSTICK_HEADTRACKER   7
-
-#define DI8DEVTYPEMOUSE_UNKNOWN                     1
-#define DI8DEVTYPEMOUSE_TRADITIONAL                 2
-#define DI8DEVTYPEMOUSE_FINGERSTICK                 3
-#define DI8DEVTYPEMOUSE_TOUCHPAD                    4
-#define DI8DEVTYPEMOUSE_TRACKBALL                   5
-#define DI8DEVTYPEMOUSE_ABSOLUTE                    6
-
-#define DI8DEVTYPEKEYBOARD_UNKNOWN                  0
-#define DI8DEVTYPEKEYBOARD_PCXT                     1
-#define DI8DEVTYPEKEYBOARD_OLIVETTI                 2
-#define DI8DEVTYPEKEYBOARD_PCAT                     3
-#define DI8DEVTYPEKEYBOARD_PCENH                    4
-#define DI8DEVTYPEKEYBOARD_NOKIA1050                5
-#define DI8DEVTYPEKEYBOARD_NOKIA9140                6
-#define DI8DEVTYPEKEYBOARD_NEC98                    7
-#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP              8
-#define DI8DEVTYPEKEYBOARD_NEC98106                 9
-#define DI8DEVTYPEKEYBOARD_JAPAN106                10
-#define DI8DEVTYPEKEYBOARD_JAPANAX                 11
-#define DI8DEVTYPEKEYBOARD_J3100                   12
-
-#define DI8DEVTYPE_LIMITEDGAMESUBTYPE               1
-
-#define DI8DEVTYPEJOYSTICK_LIMITED                  DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEJOYSTICK_STANDARD                 2
-
-#define DI8DEVTYPEGAMEPAD_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEGAMEPAD_STANDARD                  2
-#define DI8DEVTYPEGAMEPAD_TILT                      3
-
-#define DI8DEVTYPEDRIVING_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEDRIVING_COMBINEDPEDALS            2
-#define DI8DEVTYPEDRIVING_DUALPEDALS                3
-#define DI8DEVTYPEDRIVING_THREEPEDALS               4
-#define DI8DEVTYPEDRIVING_HANDHELD                  5
-
-#define DI8DEVTYPEFLIGHT_LIMITED                    DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEFLIGHT_STICK                      2
-#define DI8DEVTYPEFLIGHT_YOKE                       3
-#define DI8DEVTYPEFLIGHT_RC                         4
-
-#define DI8DEVTYPE1STPERSON_LIMITED                 DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPE1STPERSON_UNKNOWN                 2
-#define DI8DEVTYPE1STPERSON_SIXDOF                  3
-#define DI8DEVTYPE1STPERSON_SHOOTER                 4
-
-#define DI8DEVTYPESCREENPTR_UNKNOWN                 2
-#define DI8DEVTYPESCREENPTR_LIGHTGUN                3
-#define DI8DEVTYPESCREENPTR_LIGHTPEN                4
-#define DI8DEVTYPESCREENPTR_TOUCH                   5
-
-#define DI8DEVTYPEREMOTE_UNKNOWN                    2
-
-#define DI8DEVTYPEDEVICECTRL_UNKNOWN                2
-#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION         3
-#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4
-
-#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN              2
-#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER    3
-#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER          4
-#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER          5
-#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE       6
-#define DI8DEVTYPESUPPLEMENTAL_SHIFTER              7
-#define DI8DEVTYPESUPPLEMENTAL_THROTTLE             8
-#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE        9
-#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS      10
-#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS          11
-#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS         12
-#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS        13
-       
-#define GET_DIDEVICE_TYPE(dwDevType)     LOBYTE(dwDevType)
-#define GET_DIDEVICE_SUBTYPE(dwDevType)  HIBYTE(dwDevType)
-
-typedef struct DIDEVICEOBJECTINSTANCE_DX3A {
-    DWORD   dwSize;
-    GUID    guidType;
-    DWORD   dwOfs;
-    DWORD   dwType;
-    DWORD   dwFlags;
-    CHAR    tszName[MAX_PATH];
-} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A;
-typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A;
-typedef struct DIDEVICEOBJECTINSTANCE_DX3W {
-    DWORD   dwSize;
-    GUID    guidType;
-    DWORD   dwOfs;
-    DWORD   dwType;
-    DWORD   dwFlags;
-    WCHAR   tszName[MAX_PATH];
-} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W;
-typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3)
-
-typedef struct DIDEVICEOBJECTINSTANCEA {
-    DWORD      dwSize;
-    GUID       guidType;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-    CHAR       tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFMaxForce;
-    DWORD      dwFFForceResolution;
-    WORD       wCollectionNumber;
-    WORD       wDesignatorIndex;
-    WORD       wUsagePage;
-    WORD       wUsage;
-    DWORD      dwDimension;
-    WORD       wExponent;
-    WORD       wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
-typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
-
-typedef struct DIDEVICEOBJECTINSTANCEW {
-    DWORD      dwSize;
-    GUID       guidType;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-    WCHAR      tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFMaxForce;
-    DWORD      dwFFForceResolution;
-    WORD       wCollectionNumber;
-    WORD       wDesignatorIndex;
-    WORD       wUsagePage;
-    WORD       wUsage;
-    DWORD      dwDimension;
-    WORD       wExponent;
-    WORD       wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
-typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE)
-
-typedef struct DIDEVICEINSTANCE_DX3A {
-    DWORD   dwSize;
-    GUID    guidInstance;
-    GUID    guidProduct;
-    DWORD   dwDevType;
-    CHAR    tszInstanceName[MAX_PATH];
-    CHAR    tszProductName[MAX_PATH];
-} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A;
-typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A;
-typedef struct DIDEVICEINSTANCE_DX3W {
-    DWORD   dwSize;
-    GUID    guidInstance;
-    GUID    guidProduct;
-    DWORD   dwDevType;
-    WCHAR   tszInstanceName[MAX_PATH];
-    WCHAR   tszProductName[MAX_PATH];
-} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W;
-typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3)
-
-typedef struct DIDEVICEINSTANCEA {
-    DWORD      dwSize;
-    GUID       guidInstance;
-    GUID       guidProduct;
-    DWORD      dwDevType;
-    CHAR       tszInstanceName[MAX_PATH];
-    CHAR       tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    GUID       guidFFDriver;
-    WORD       wUsagePage;
-    WORD       wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
-typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
-
-typedef struct DIDEVICEINSTANCEW {
-    DWORD      dwSize;
-    GUID       guidInstance;
-    GUID       guidProduct;
-    DWORD      dwDevType;
-    WCHAR      tszInstanceName[MAX_PATH];
-    WCHAR      tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    GUID       guidFFDriver;
-    WORD       wUsagePage;
-    WORD       wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
-typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE)
-
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
-
-#define DIEDBS_MAPPEDPRI1              0x00000001
-#define DIEDBS_MAPPEDPRI2              0x00000002
-#define DIEDBS_RECENTDEVICE            0x00000010
-#define DIEDBS_NEWDEVICE               0x00000020
-
-#define DIEDBSFL_ATTACHEDONLY          0x00000000
-#define DIEDBSFL_THISUSER              0x00000010
-#define DIEDBSFL_FORCEFEEDBACK         DIEDFL_FORCEFEEDBACK
-#define DIEDBSFL_AVAILABLEDEVICES      0x00001000
-#define DIEDBSFL_MULTIMICEKEYBOARDS    0x00002000
-#define DIEDBSFL_NONGAMINGDEVICES      0x00004000
-#define DIEDBSFL_VALID                 0x00007110
-
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB)
-#endif
-
-typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID);
-
-typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK)
-
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID);
-#endif
-
-#define DIK_ESCAPE          0x01
-#define DIK_1               0x02
-#define DIK_2               0x03
-#define DIK_3               0x04
-#define DIK_4               0x05
-#define DIK_5               0x06
-#define DIK_6               0x07
-#define DIK_7               0x08
-#define DIK_8               0x09
-#define DIK_9               0x0A
-#define DIK_0               0x0B
-#define DIK_MINUS           0x0C    /* - on main keyboard */
-#define DIK_EQUALS          0x0D
-#define DIK_BACK            0x0E    /* backspace */
-#define DIK_TAB             0x0F
-#define DIK_Q               0x10
-#define DIK_W               0x11
-#define DIK_E               0x12
-#define DIK_R               0x13
-#define DIK_T               0x14
-#define DIK_Y               0x15
-#define DIK_U               0x16
-#define DIK_I               0x17
-#define DIK_O               0x18
-#define DIK_P               0x19
-#define DIK_LBRACKET        0x1A
-#define DIK_RBRACKET        0x1B
-#define DIK_RETURN          0x1C    /* Enter on main keyboard */
-#define DIK_LCONTROL        0x1D
-#define DIK_A               0x1E
-#define DIK_S               0x1F
-#define DIK_D               0x20
-#define DIK_F               0x21
-#define DIK_G               0x22
-#define DIK_H               0x23
-#define DIK_J               0x24
-#define DIK_K               0x25
-#define DIK_L               0x26
-#define DIK_SEMICOLON       0x27
-#define DIK_APOSTROPHE      0x28
-#define DIK_GRAVE           0x29    /* accent grave */
-#define DIK_LSHIFT          0x2A
-#define DIK_BACKSLASH       0x2B
-#define DIK_Z               0x2C
-#define DIK_X               0x2D
-#define DIK_C               0x2E
-#define DIK_V               0x2F
-#define DIK_B               0x30
-#define DIK_N               0x31
-#define DIK_M               0x32
-#define DIK_COMMA           0x33
-#define DIK_PERIOD          0x34    /* . on main keyboard */
-#define DIK_SLASH           0x35    /* / on main keyboard */
-#define DIK_RSHIFT          0x36
-#define DIK_MULTIPLY        0x37    /* * on numeric keypad */
-#define DIK_LMENU           0x38    /* left Alt */
-#define DIK_SPACE           0x39
-#define DIK_CAPITAL         0x3A
-#define DIK_F1              0x3B
-#define DIK_F2              0x3C
-#define DIK_F3              0x3D
-#define DIK_F4              0x3E
-#define DIK_F5              0x3F
-#define DIK_F6              0x40
-#define DIK_F7              0x41
-#define DIK_F8              0x42
-#define DIK_F9              0x43
-#define DIK_F10             0x44
-#define DIK_NUMLOCK         0x45
-#define DIK_SCROLL          0x46    /* Scroll Lock */
-#define DIK_NUMPAD7         0x47
-#define DIK_NUMPAD8         0x48
-#define DIK_NUMPAD9         0x49
-#define DIK_SUBTRACT        0x4A    /* - on numeric keypad */
-#define DIK_NUMPAD4         0x4B
-#define DIK_NUMPAD5         0x4C
-#define DIK_NUMPAD6         0x4D
-#define DIK_ADD             0x4E    /* + on numeric keypad */
-#define DIK_NUMPAD1         0x4F
-#define DIK_NUMPAD2         0x50
-#define DIK_NUMPAD3         0x51
-#define DIK_NUMPAD0         0x52
-#define DIK_DECIMAL         0x53    /* . on numeric keypad */
-#define DIK_OEM_102         0x56    /* < > | on UK/Germany keyboards */
-#define DIK_F11             0x57
-#define DIK_F12             0x58
-#define DIK_F13             0x64    /*                     (NEC PC98) */
-#define DIK_F14             0x65    /*                     (NEC PC98) */
-#define DIK_F15             0x66    /*                     (NEC PC98) */
-#define DIK_KANA            0x70    /* (Japanese keyboard)            */
-#define DIK_ABNT_C1         0x73    /* / ? on Portugese (Brazilian) keyboards */
-#define DIK_CONVERT         0x79    /* (Japanese keyboard)            */
-#define DIK_NOCONVERT       0x7B    /* (Japanese keyboard)            */
-#define DIK_YEN             0x7D    /* (Japanese keyboard)            */
-#define DIK_ABNT_C2         0x7E    /* Numpad . on Portugese (Brazilian) keyboards */
-#define DIK_NUMPADEQUALS    0x8D    /* = on numeric keypad (NEC PC98) */
-#define DIK_CIRCUMFLEX      0x90    /* (Japanese keyboard)            */
-#define DIK_AT              0x91    /*                     (NEC PC98) */
-#define DIK_COLON           0x92    /*                     (NEC PC98) */
-#define DIK_UNDERLINE       0x93    /*                     (NEC PC98) */
-#define DIK_KANJI           0x94    /* (Japanese keyboard)            */
-#define DIK_STOP            0x95    /*                     (NEC PC98) */
-#define DIK_AX              0x96    /*                     (Japan AX) */
-#define DIK_UNLABELED       0x97    /*                        (J3100) */
-#define DIK_NEXTTRACK       0x99    /* Next Track */
-#define DIK_NUMPADENTER     0x9C    /* Enter on numeric keypad */
-#define DIK_RCONTROL        0x9D
-#define DIK_MUTE           0xA0    /* Mute */
-#define DIK_CALCULATOR      0xA1    /* Calculator */
-#define DIK_PLAYPAUSE       0xA2    /* Play / Pause */
-#define DIK_MEDIASTOP       0xA4    /* Media Stop */
-#define DIK_VOLUMEDOWN      0xAE    /* Volume - */
-#define DIK_VOLUMEUP        0xB0    /* Volume + */
-#define DIK_WEBHOME         0xB2    /* Web home */
-#define DIK_NUMPADCOMMA     0xB3    /* , on numeric keypad (NEC PC98) */
-#define DIK_DIVIDE          0xB5    /* / on numeric keypad */
-#define DIK_SYSRQ           0xB7
-#define DIK_RMENU           0xB8    /* right Alt */
-#define DIK_PAUSE           0xC5    /* Pause */
-#define DIK_HOME            0xC7    /* Home on arrow keypad */
-#define DIK_UP              0xC8    /* UpArrow on arrow keypad */
-#define DIK_PRIOR           0xC9    /* PgUp on arrow keypad */
-#define DIK_LEFT            0xCB    /* LeftArrow on arrow keypad */
-#define DIK_RIGHT           0xCD    /* RightArrow on arrow keypad */
-#define DIK_END             0xCF    /* End on arrow keypad */
-#define DIK_DOWN            0xD0    /* DownArrow on arrow keypad */
-#define DIK_NEXT            0xD1    /* PgDn on arrow keypad */
-#define DIK_INSERT          0xD2    /* Insert on arrow keypad */
-#define DIK_DELETE          0xD3    /* Delete on arrow keypad */
-#define DIK_LWIN            0xDB    /* Left Windows key */
-#define DIK_RWIN            0xDC    /* Right Windows key */
-#define DIK_APPS            0xDD    /* AppMenu key */
-#define DIK_POWER           0xDE
-#define DIK_SLEEP           0xDF
-#define DIK_WAKE            0xE3    /* System Wake */
-#define DIK_WEBSEARCH       0xE5    /* Web Search */
-#define DIK_WEBFAVORITES    0xE6    /* Web Favorites */
-#define DIK_WEBREFRESH      0xE7    /* Web Refresh */
-#define DIK_WEBSTOP         0xE8    /* Web Stop */
-#define DIK_WEBFORWARD      0xE9    /* Web Forward */
-#define DIK_WEBBACK         0xEA    /* Web Back */
-#define DIK_MYCOMPUTER      0xEB    /* My Computer */
-#define DIK_MAIL            0xEC    /* Mail */
-#define DIK_MEDIASELECT     0xED    /* Media Select */
-
-#define DIK_BACKSPACE       DIK_BACK            /* backspace */
-#define DIK_NUMPADSTAR      DIK_MULTIPLY        /* * on numeric keypad */
-#define DIK_LALT            DIK_LMENU           /* left Alt */
-#define DIK_CAPSLOCK        DIK_CAPITAL         /* CapsLock */
-#define DIK_NUMPADMINUS     DIK_SUBTRACT        /* - on numeric keypad */
-#define DIK_NUMPADPLUS      DIK_ADD             /* + on numeric keypad */
-#define DIK_NUMPADPERIOD    DIK_DECIMAL         /* . on numeric keypad */
-#define DIK_NUMPADSLASH     DIK_DIVIDE          /* / on numeric keypad */
-#define DIK_RALT            DIK_RMENU           /* right Alt */
-#define DIK_UPARROW         DIK_UP              /* UpArrow on arrow keypad */
-#define DIK_PGUP            DIK_PRIOR           /* PgUp on arrow keypad */
-#define DIK_LEFTARROW       DIK_LEFT            /* LeftArrow on arrow keypad */
-#define DIK_RIGHTARROW      DIK_RIGHT           /* RightArrow on arrow keypad */
-#define DIK_DOWNARROW       DIK_DOWN            /* DownArrow on arrow keypad */
-#define DIK_PGDN            DIK_NEXT            /* PgDn on arrow keypad */
-
-#define DIDFT_ALL              0x00000000
-#define DIDFT_RELAXIS          0x00000001
-#define DIDFT_ABSAXIS          0x00000002
-#define DIDFT_AXIS             0x00000003
-#define DIDFT_PSHBUTTON                0x00000004
-#define DIDFT_TGLBUTTON                0x00000008
-#define DIDFT_BUTTON           0x0000000C
-#define DIDFT_POV              0x00000010
-#define DIDFT_COLLECTION       0x00000040
-#define DIDFT_NODATA           0x00000080
-#define DIDFT_ANYINSTANCE      0x00FFFF00
-#define DIDFT_INSTANCEMASK     DIDFT_ANYINSTANCE
-#define DIDFT_MAKEINSTANCE(n)  ((WORD)(n) << 8)
-#define DIDFT_GETTYPE(n)       LOBYTE(n)
-#define DIDFT_GETINSTANCE(n)   LOWORD((n) >> 8)
-#define DIDFT_FFACTUATOR       0x01000000
-#define DIDFT_FFEFFECTTRIGGER  0x02000000
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIDFT_OUTPUT           0x10000000
-#define DIDFT_VENDORDEFINED    0x04000000
-#define DIDFT_ALIAS            0x08000000
-#endif /* DI5a */
-#ifndef DIDFT_OPTIONAL
-#define DIDFT_OPTIONAL         0x80000000
-#endif
-#define DIDFT_ENUMCOLLECTION(n)        ((WORD)(n) << 8)
-#define DIDFT_NOCOLLECTION     0x00FFFF00
-
-#define DIDF_ABSAXIS           0x00000001
-#define DIDF_RELAXIS           0x00000002
-
-#define DIGDD_PEEK             0x00000001
-
-#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0)
-
-typedef struct DIDEVICEOBJECTDATA_DX3 {
-    DWORD      dwOfs;
-    DWORD      dwData;
-    DWORD      dwTimeStamp;
-    DWORD      dwSequence;
-} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3;
-typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3;
-
-typedef struct DIDEVICEOBJECTDATA {
-    DWORD      dwOfs;
-    DWORD      dwData;
-    DWORD      dwTimeStamp;
-    DWORD      dwSequence;
-#if(DIRECTINPUT_VERSION >= 0x0800)
-    UINT_PTR   uAppData;
-#endif /* DIRECTINPUT_VERSION >= 0x0800 */
-} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA;
-typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA;
-
-typedef struct _DIOBJECTDATAFORMAT {
-    const GUID *pguid;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT;
-typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
-
-typedef struct _DIDATAFORMAT {
-    DWORD                      dwSize;
-    DWORD                      dwObjSize;
-    DWORD                      dwFlags;
-    DWORD                      dwDataSize;
-    DWORD                      dwNumObjs;
-    LPDIOBJECTDATAFORMAT       rgodf;
-} DIDATAFORMAT, *LPDIDATAFORMAT;
-typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
-
-#if DIRECTINPUT_VERSION >= 0x0500
-#define DIDOI_FFACTUATOR       0x00000001
-#define DIDOI_FFEFFECTTRIGGER  0x00000002
-#define DIDOI_POLLED           0x00008000
-#define DIDOI_ASPECTPOSITION   0x00000100
-#define DIDOI_ASPECTVELOCITY   0x00000200
-#define DIDOI_ASPECTACCEL      0x00000300
-#define DIDOI_ASPECTFORCE      0x00000400
-#define DIDOI_ASPECTMASK       0x00000F00
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIDOI_GUIDISUSAGE      0x00010000
-#endif /* DI5a */
-
-typedef struct DIPROPHEADER {
-    DWORD      dwSize;
-    DWORD      dwHeaderSize;
-    DWORD      dwObj;
-    DWORD      dwHow;
-} DIPROPHEADER,*LPDIPROPHEADER;
-typedef const DIPROPHEADER *LPCDIPROPHEADER;
-
-#define DIPH_DEVICE    0
-#define DIPH_BYOFFSET  1
-#define DIPH_BYID      2
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIPH_BYUSAGE   3
-
-#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage)
-#endif /* DI5a */
-
-typedef struct DIPROPDWORD {
-       DIPROPHEADER    diph;
-       DWORD           dwData;
-} DIPROPDWORD, *LPDIPROPDWORD;
-typedef const DIPROPDWORD *LPCDIPROPDWORD;
-
-typedef struct DIPROPRANGE {
-       DIPROPHEADER    diph;
-       LONG            lMin;
-       LONG            lMax;
-} DIPROPRANGE, *LPDIPROPRANGE;
-typedef const DIPROPRANGE *LPCDIPROPRANGE;
-
-#define DIPROPRANGE_NOMIN      ((LONG)0x80000000)
-#define DIPROPRANGE_NOMAX      ((LONG)0x7FFFFFFF)
-
-#if DIRECTINPUT_VERSION >= 0x050a
-typedef struct DIPROPCAL {
-       DIPROPHEADER diph;
-       LONG    lMin;
-       LONG    lCenter;
-       LONG    lMax;
-} DIPROPCAL, *LPDIPROPCAL;
-typedef const DIPROPCAL *LPCDIPROPCAL;
-
-typedef struct DIPROPCALPOV {
-       DIPROPHEADER    diph;
-       LONG            lMin[5];
-       LONG            lMax[5];
-} DIPROPCALPOV, *LPDIPROPCALPOV;
-typedef const DIPROPCALPOV *LPCDIPROPCALPOV;
-
-typedef struct DIPROPGUIDANDPATH {
-       DIPROPHEADER diph;
-       GUID    guidClass;
-       WCHAR   wszPath[MAX_PATH];
-} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH;
-typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
-
-typedef struct DIPROPSTRING {
-        DIPROPHEADER diph;
-        WCHAR        wsz[MAX_PATH];
-} DIPROPSTRING, *LPDIPROPSTRING;
-typedef const DIPROPSTRING *LPCDIPROPSTRING;
-#endif /* DI5a */
-
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct DIPROPPOINTER {
-       DIPROPHEADER diph;
-       UINT_PTR     uData;
-} DIPROPPOINTER, *LPDIPROPPOINTER;
-typedef const DIPROPPOINTER *LPCDIPROPPOINTER;
-#endif /* DI8 */
-
-/* special property GUIDs */
-#ifdef __cplusplus
-#define MAKEDIPROP(prop)       (*(const GUID *)(prop))
-#else
-#define MAKEDIPROP(prop)       ((REFGUID)(prop))
-#endif
-#define DIPROP_BUFFERSIZE      MAKEDIPROP(1)
-#define DIPROP_AXISMODE                MAKEDIPROP(2)
-
-#define DIPROPAXISMODE_ABS     0
-#define DIPROPAXISMODE_REL     1
-
-#define DIPROP_GRANULARITY     MAKEDIPROP(3)
-#define DIPROP_RANGE           MAKEDIPROP(4)
-#define DIPROP_DEADZONE                MAKEDIPROP(5)
-#define DIPROP_SATURATION      MAKEDIPROP(6)
-#define DIPROP_FFGAIN          MAKEDIPROP(7)
-#define DIPROP_FFLOAD          MAKEDIPROP(8)
-#define DIPROP_AUTOCENTER      MAKEDIPROP(9)
-
-#define DIPROPAUTOCENTER_OFF   0
-#define DIPROPAUTOCENTER_ON    1
-
-#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10)
-
-#define DIPROPCALIBRATIONMODE_COOKED   0
-#define DIPROPCALIBRATIONMODE_RAW      1
-
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIPROP_CALIBRATION     MAKEDIPROP(11)
-#define DIPROP_GUIDANDPATH     MAKEDIPROP(12)
-#define DIPROP_INSTANCENAME    MAKEDIPROP(13)
-#define DIPROP_PRODUCTNAME     MAKEDIPROP(14)
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x5B2
-#define DIPROP_JOYSTICKID      MAKEDIPROP(15)
-#define DIPROP_GETPORTDISPLAYNAME      MAKEDIPROP(16)
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x0700
-#define DIPROP_PHYSICALRANGE   MAKEDIPROP(18)
-#define DIPROP_LOGICALRANGE    MAKEDIPROP(19)
-#endif
-
-#if(DIRECTINPUT_VERSION >= 0x0800)
-#define DIPROP_KEYNAME         MAKEDIPROP(20)
-#define DIPROP_CPOINTS         MAKEDIPROP(21)
-#define DIPROP_APPDATA         MAKEDIPROP(22)
-#define DIPROP_SCANCODE                MAKEDIPROP(23)
-#define DIPROP_VIDPID          MAKEDIPROP(24)
-#define DIPROP_USERNAME                MAKEDIPROP(25)
-#define DIPROP_TYPENAME                MAKEDIPROP(26)
-
-#define MAXCPOINTSNUM          8
-
-typedef struct _CPOINT {
-    LONG       lP;
-    DWORD      dwLog;
-} CPOINT, *PCPOINT;
-
-typedef struct DIPROPCPOINTS {
-    DIPROPHEADER diph;
-    DWORD      dwCPointsNum;
-    CPOINT     cp[MAXCPOINTSNUM];
-} DIPROPCPOINTS, *LPDIPROPCPOINTS;
-typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS;
-#endif /* DI8 */
-
-
-typedef struct DIDEVCAPS_DX3 {
-    DWORD      dwSize;
-    DWORD      dwFlags;
-    DWORD      dwDevType;
-    DWORD      dwAxes;
-    DWORD      dwButtons;
-    DWORD      dwPOVs;
-} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3;
-
-typedef struct DIDEVCAPS {
-    DWORD      dwSize;
-    DWORD      dwFlags;
-    DWORD      dwDevType;
-    DWORD      dwAxes;
-    DWORD      dwButtons;
-    DWORD      dwPOVs;
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFSamplePeriod;
-    DWORD      dwFFMinTimeResolution;
-    DWORD      dwFirmwareRevision;
-    DWORD      dwHardwareRevision;
-    DWORD      dwFFDriverVersion;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVCAPS,*LPDIDEVCAPS;
-
-#define DIDC_ATTACHED          0x00000001
-#define DIDC_POLLEDDEVICE      0x00000002
-#define DIDC_EMULATED          0x00000004
-#define DIDC_POLLEDDATAFORMAT  0x00000008
-#define DIDC_FORCEFEEDBACK     0x00000100
-#define DIDC_FFATTACK          0x00000200
-#define DIDC_FFFADE            0x00000400
-#define DIDC_SATURATION                0x00000800
-#define DIDC_POSNEGCOEFFICIENTS        0x00001000
-#define DIDC_POSNEGSATURATION  0x00002000
-#define DIDC_DEADBAND          0x00004000
-#define DIDC_STARTDELAY                0x00008000
-#define DIDC_ALIAS             0x00010000
-#define DIDC_PHANTOM           0x00020000
-#define DIDC_HIDDEN            0x00040000
-
-
-/* SetCooperativeLevel dwFlags */
-#define DISCL_EXCLUSIVE                0x00000001
-#define DISCL_NONEXCLUSIVE     0x00000002
-#define DISCL_FOREGROUND       0x00000004
-#define DISCL_BACKGROUND       0x00000008
-#define DISCL_NOWINKEY          0x00000010
-
-#if (DIRECTINPUT_VERSION >= 0x0500)
-/* Device FF flags */
-#define DISFFC_RESET            0x00000001
-#define DISFFC_STOPALL          0x00000002
-#define DISFFC_PAUSE            0x00000004
-#define DISFFC_CONTINUE         0x00000008
-#define DISFFC_SETACTUATORSON   0x00000010
-#define DISFFC_SETACTUATORSOFF  0x00000020
-
-#define DIGFFS_EMPTY            0x00000001
-#define DIGFFS_STOPPED          0x00000002
-#define DIGFFS_PAUSED           0x00000004
-#define DIGFFS_ACTUATORSON      0x00000010
-#define DIGFFS_ACTUATORSOFF     0x00000020
-#define DIGFFS_POWERON          0x00000040
-#define DIGFFS_POWEROFF         0x00000080
-#define DIGFFS_SAFETYSWITCHON   0x00000100
-#define DIGFFS_SAFETYSWITCHOFF  0x00000200
-#define DIGFFS_USERFFSWITCHON   0x00000400
-#define DIGFFS_USERFFSWITCHOFF  0x00000800
-#define DIGFFS_DEVICELOST       0x80000000
-
-/* Effect flags */
-#define DIEFT_ALL              0x00000000
-
-#define DIEFT_CONSTANTFORCE    0x00000001
-#define DIEFT_RAMPFORCE                0x00000002
-#define DIEFT_PERIODIC         0x00000003
-#define DIEFT_CONDITION                0x00000004
-#define DIEFT_CUSTOMFORCE      0x00000005
-#define DIEFT_HARDWARE         0x000000FF
-#define DIEFT_FFATTACK         0x00000200
-#define DIEFT_FFFADE           0x00000400
-#define DIEFT_SATURATION       0x00000800
-#define DIEFT_POSNEGCOEFFICIENTS 0x00001000
-#define DIEFT_POSNEGSATURATION 0x00002000
-#define DIEFT_DEADBAND         0x00004000
-#define DIEFT_STARTDELAY       0x00008000
-#define DIEFT_GETTYPE(n)       LOBYTE(n)
-
-#define DIEFF_OBJECTIDS         0x00000001
-#define DIEFF_OBJECTOFFSETS     0x00000002
-#define DIEFF_CARTESIAN         0x00000010
-#define DIEFF_POLAR             0x00000020
-#define DIEFF_SPHERICAL         0x00000040
-
-#define DIEP_DURATION           0x00000001
-#define DIEP_SAMPLEPERIOD       0x00000002
-#define DIEP_GAIN               0x00000004
-#define DIEP_TRIGGERBUTTON      0x00000008
-#define DIEP_TRIGGERREPEATINTERVAL 0x00000010
-#define DIEP_AXES               0x00000020
-#define DIEP_DIRECTION          0x00000040
-#define DIEP_ENVELOPE           0x00000080
-#define DIEP_TYPESPECIFICPARAMS 0x00000100
-#if(DIRECTINPUT_VERSION >= 0x0600)
-#define DIEP_STARTDELAY         0x00000200
-#define DIEP_ALLPARAMS_DX5      0x000001FF
-#define DIEP_ALLPARAMS          0x000003FF
-#else
-#define DIEP_ALLPARAMS          0x000001FF
-#endif /* DIRECTINPUT_VERSION >= 0x0600 */
-#define DIEP_START              0x20000000
-#define DIEP_NORESTART          0x40000000
-#define DIEP_NODOWNLOAD         0x80000000
-#define DIEB_NOTRIGGER          0xFFFFFFFF
-
-#define DIES_SOLO               0x00000001
-#define DIES_NODOWNLOAD         0x80000000
-
-#define DIEGES_PLAYING          0x00000001
-#define DIEGES_EMULATED         0x00000002
-
-#define DI_DEGREES             100
-#define DI_FFNOMINALMAX                10000
-#define DI_SECONDS             1000000
-
-typedef struct DICONSTANTFORCE {
-       LONG                    lMagnitude;
-} DICONSTANTFORCE, *LPDICONSTANTFORCE;
-typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE;
-
-typedef struct DIRAMPFORCE {
-       LONG                    lStart;
-       LONG                    lEnd;
-} DIRAMPFORCE, *LPDIRAMPFORCE;
-typedef const DIRAMPFORCE *LPCDIRAMPFORCE;
-
-typedef struct DIPERIODIC {
-       DWORD                   dwMagnitude;
-       LONG                    lOffset;
-       DWORD                   dwPhase;
-       DWORD                   dwPeriod;
-} DIPERIODIC, *LPDIPERIODIC;
-typedef const DIPERIODIC *LPCDIPERIODIC;
-
-typedef struct DICONDITION {
-       LONG                    lOffset;
-       LONG                    lPositiveCoefficient;
-       LONG                    lNegativeCoefficient;
-       DWORD                   dwPositiveSaturation;
-       DWORD                   dwNegativeSaturation;
-       LONG                    lDeadBand;
-} DICONDITION, *LPDICONDITION;
-typedef const DICONDITION *LPCDICONDITION;
-
-typedef struct DICUSTOMFORCE {
-       DWORD                   cChannels;
-       DWORD                   dwSamplePeriod;
-       DWORD                   cSamples;
-       LPLONG                  rglForceData;
-} DICUSTOMFORCE, *LPDICUSTOMFORCE;
-typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE;
-
-typedef struct DIENVELOPE {
-       DWORD                   dwSize;
-       DWORD                   dwAttackLevel;
-       DWORD                   dwAttackTime;
-       DWORD                   dwFadeLevel;
-       DWORD                   dwFadeTime;
-} DIENVELOPE, *LPDIENVELOPE;
-typedef const DIENVELOPE *LPCDIENVELOPE;
-
-typedef struct DIEFFECT_DX5 {
-       DWORD                   dwSize;
-       DWORD                   dwFlags;
-       DWORD                   dwDuration;
-       DWORD                   dwSamplePeriod;
-       DWORD                   dwGain;
-       DWORD                   dwTriggerButton;
-       DWORD                   dwTriggerRepeatInterval;
-       DWORD                   cAxes;
-       LPDWORD                 rgdwAxes;
-       LPLONG                  rglDirection;
-       LPDIENVELOPE            lpEnvelope;
-       DWORD                   cbTypeSpecificParams;
-       LPVOID                  lpvTypeSpecificParams;
-} DIEFFECT_DX5, *LPDIEFFECT_DX5;
-typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5;
-
-typedef struct DIEFFECT {
-       DWORD                   dwSize;
-       DWORD                   dwFlags;
-       DWORD                   dwDuration;
-       DWORD                   dwSamplePeriod;
-       DWORD                   dwGain;
-       DWORD                   dwTriggerButton;
-       DWORD                   dwTriggerRepeatInterval;
-       DWORD                   cAxes;
-       LPDWORD                 rgdwAxes;
-       LPLONG                  rglDirection;
-       LPDIENVELOPE            lpEnvelope;
-       DWORD                   cbTypeSpecificParams;
-       LPVOID                  lpvTypeSpecificParams;
-#if(DIRECTINPUT_VERSION >= 0x0600)
-       DWORD                   dwStartDelay;
-#endif /* DIRECTINPUT_VERSION >= 0x0600 */
-} DIEFFECT, *LPDIEFFECT;
-typedef const DIEFFECT *LPCDIEFFECT;
-typedef DIEFFECT DIEFFECT_DX6;
-typedef LPDIEFFECT LPDIEFFECT_DX6;
-
-typedef struct DIEFFECTINFOA {
-       DWORD                   dwSize;
-       GUID                    guid;
-       DWORD                   dwEffType;
-       DWORD                   dwStaticParams;
-       DWORD                   dwDynamicParams;
-       CHAR                    tszName[MAX_PATH];
-} DIEFFECTINFOA, *LPDIEFFECTINFOA;
-typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA;
-
-typedef struct DIEFFECTINFOW {
-       DWORD                   dwSize;
-       GUID                    guid;
-       DWORD                   dwEffType;
-       DWORD                   dwStaticParams;
-       DWORD                   dwDynamicParams;
-       WCHAR                   tszName[MAX_PATH];
-} DIEFFECTINFOW, *LPDIEFFECTINFOW;
-typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW;
-
-DECL_WINELIB_TYPE_AW(DIEFFECTINFO)
-DECL_WINELIB_TYPE_AW(LPDIEFFECTINFO)
-DECL_WINELIB_TYPE_AW(LPCDIEFFECTINFO)
-
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID);
-
-typedef struct DIEFFESCAPE {
-       DWORD   dwSize;
-       DWORD   dwCommand;
-       LPVOID  lpvInBuffer;
-       DWORD   cbInBuffer;
-       LPVOID  lpvOutBuffer;
-       DWORD   cbOutBuffer;
-} DIEFFESCAPE, *LPDIEFFESCAPE;
-
-typedef struct DIJOYSTATE {
-       LONG    lX;
-       LONG    lY;
-       LONG    lZ;
-       LONG    lRx;
-       LONG    lRy;
-       LONG    lRz;
-       LONG    rglSlider[2];
-       DWORD   rgdwPOV[4];
-       BYTE    rgbButtons[32];
-} DIJOYSTATE, *LPDIJOYSTATE;
-
-typedef struct DIJOYSTATE2 {
-       LONG    lX;
-       LONG    lY;
-       LONG    lZ;
-       LONG    lRx;
-       LONG    lRy;
-       LONG    lRz;
-       LONG    rglSlider[2];
-       DWORD   rgdwPOV[4];
-       BYTE    rgbButtons[128];
-       LONG    lVX;            /* 'v' as in velocity */
-       LONG    lVY;
-       LONG    lVZ;
-       LONG    lVRx;
-       LONG    lVRy;
-       LONG    lVRz;
-       LONG    rglVSlider[2];
-       LONG    lAX;            /* 'a' as in acceleration */
-       LONG    lAY;
-       LONG    lAZ;
-       LONG    lARx;
-       LONG    lARy;
-       LONG    lARz;
-       LONG    rglASlider[2];
-       LONG    lFX;            /* 'f' as in force */
-       LONG    lFY;
-       LONG    lFZ;
-       LONG    lFRx;           /* 'fr' as in rotational force aka torque */
-       LONG    lFRy;
-       LONG    lFRz;
-       LONG    rglFSlider[2];
-} DIJOYSTATE2, *LPDIJOYSTATE2;
-
-#define DIJOFS_X               FIELD_OFFSET(DIJOYSTATE, lX)
-#define DIJOFS_Y               FIELD_OFFSET(DIJOYSTATE, lY)
-#define DIJOFS_Z               FIELD_OFFSET(DIJOYSTATE, lZ)
-#define DIJOFS_RX              FIELD_OFFSET(DIJOYSTATE, lRx)
-#define DIJOFS_RY              FIELD_OFFSET(DIJOYSTATE, lRy)
-#define DIJOFS_RZ              FIELD_OFFSET(DIJOYSTATE, lRz)
-#define DIJOFS_SLIDER(n)       (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \
-                                                        (n) * sizeof(LONG))
-#define DIJOFS_POV(n)          (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \
-                                                        (n) * sizeof(DWORD))
-#define DIJOFS_BUTTON(n)       (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n))
-#define DIJOFS_BUTTON0         DIJOFS_BUTTON(0)
-#define DIJOFS_BUTTON1         DIJOFS_BUTTON(1)
-#define DIJOFS_BUTTON2         DIJOFS_BUTTON(2)
-#define DIJOFS_BUTTON3         DIJOFS_BUTTON(3)
-#define DIJOFS_BUTTON4         DIJOFS_BUTTON(4)
-#define DIJOFS_BUTTON5         DIJOFS_BUTTON(5)
-#define DIJOFS_BUTTON6         DIJOFS_BUTTON(6)
-#define DIJOFS_BUTTON7         DIJOFS_BUTTON(7)
-#define DIJOFS_BUTTON8         DIJOFS_BUTTON(8)
-#define DIJOFS_BUTTON9         DIJOFS_BUTTON(9)
-#define DIJOFS_BUTTON10                DIJOFS_BUTTON(10)
-#define DIJOFS_BUTTON11                DIJOFS_BUTTON(11)
-#define DIJOFS_BUTTON12                DIJOFS_BUTTON(12)
-#define DIJOFS_BUTTON13                DIJOFS_BUTTON(13)
-#define DIJOFS_BUTTON14                DIJOFS_BUTTON(14)
-#define DIJOFS_BUTTON15                DIJOFS_BUTTON(15)
-#define DIJOFS_BUTTON16                DIJOFS_BUTTON(16)
-#define DIJOFS_BUTTON17                DIJOFS_BUTTON(17)
-#define DIJOFS_BUTTON18                DIJOFS_BUTTON(18)
-#define DIJOFS_BUTTON19                DIJOFS_BUTTON(19)
-#define DIJOFS_BUTTON20                DIJOFS_BUTTON(20)
-#define DIJOFS_BUTTON21                DIJOFS_BUTTON(21)
-#define DIJOFS_BUTTON22                DIJOFS_BUTTON(22)
-#define DIJOFS_BUTTON23                DIJOFS_BUTTON(23)
-#define DIJOFS_BUTTON24                DIJOFS_BUTTON(24)
-#define DIJOFS_BUTTON25                DIJOFS_BUTTON(25)
-#define DIJOFS_BUTTON26                DIJOFS_BUTTON(26)
-#define DIJOFS_BUTTON27                DIJOFS_BUTTON(27)
-#define DIJOFS_BUTTON28                DIJOFS_BUTTON(28)
-#define DIJOFS_BUTTON29                DIJOFS_BUTTON(29)
-#define DIJOFS_BUTTON30                DIJOFS_BUTTON(30)
-#define DIJOFS_BUTTON31                DIJOFS_BUTTON(31)
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-
-/* DInput 7 structures, types */
-#if(DIRECTINPUT_VERSION >= 0x0700)
-typedef struct DIFILEEFFECT {
-  DWORD       dwSize;
-  GUID        GuidEffect;
-  LPCDIEFFECT lpDiEffect;
-  CHAR        szFriendlyName[MAX_PATH];
-} DIFILEEFFECT, *LPDIFILEEFFECT;
-
-typedef const DIFILEEFFECT *LPCDIFILEEFFECT;
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID);
-#endif /* DIRECTINPUT_VERSION >= 0x0700 */
-
-/* DInput 8 structures and types */
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct _DIACTIONA {
-       UINT_PTR        uAppData;
-       DWORD           dwSemantic;
-       DWORD           dwFlags;
-       __GNU_EXTENSION union {
-               LPCSTR  lptszActionName;
-               UINT    uResIdString;
-       } DUMMYUNIONNAME;
-       GUID            guidInstance;
-       DWORD           dwObjID;
-       DWORD           dwHow;
-} DIACTIONA, *LPDIACTIONA;
-typedef const DIACTIONA *LPCDIACTIONA;
-
-typedef struct _DIACTIONW {
-       UINT_PTR        uAppData;
-       DWORD           dwSemantic;
-       DWORD           dwFlags;
-       __GNU_EXTENSION union {
-               LPCWSTR lptszActionName;
-               UINT    uResIdString;
-       } DUMMYUNIONNAME;
-       GUID            guidInstance;
-       DWORD           dwObjID;
-       DWORD           dwHow;
-} DIACTIONW, *LPDIACTIONW;
-typedef const DIACTIONW *LPCDIACTIONW;
-
-DECL_WINELIB_TYPE_AW(DIACTION)
-DECL_WINELIB_TYPE_AW(LPDIACTION)
-DECL_WINELIB_TYPE_AW(LPCDIACTION)
-
-#define DIA_FORCEFEEDBACK      0x00000001
-#define DIA_APPMAPPED          0x00000002
-#define DIA_APPNOMAP           0x00000004
-#define DIA_NORANGE            0x00000008
-#define DIA_APPFIXED           0x00000010
-
-#define DIAH_UNMAPPED          0x00000000
-#define DIAH_USERCONFIG                0x00000001
-#define DIAH_APPREQUESTED      0x00000002
-#define DIAH_HWAPP             0x00000004
-#define DIAH_HWDEFAULT         0x00000008
-#define DIAH_DEFAULT           0x00000020
-#define DIAH_ERROR             0x80000000
-
-typedef struct _DIACTIONFORMATA {
-       DWORD           dwSize;
-       DWORD           dwActionSize;
-       DWORD           dwDataSize;
-       DWORD           dwNumActions;
-       LPDIACTIONA     rgoAction;
-       GUID            guidActionMap;
-       DWORD           dwGenre;
-       DWORD           dwBufferSize;
-       LONG            lAxisMin;
-       LONG            lAxisMax;
-       HINSTANCE       hInstString;
-       FILETIME        ftTimeStamp;
-       DWORD           dwCRC;
-       CHAR            tszActionMap[MAX_PATH];
-} DIACTIONFORMATA, *LPDIACTIONFORMATA;
-typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA;
-
-typedef struct _DIACTIONFORMATW {
-       DWORD           dwSize;
-       DWORD           dwActionSize;
-       DWORD           dwDataSize;
-       DWORD           dwNumActions;
-       LPDIACTIONW     rgoAction;
-       GUID            guidActionMap;
-       DWORD           dwGenre;
-       DWORD           dwBufferSize;
-       LONG            lAxisMin;
-       LONG            lAxisMax;
-       HINSTANCE       hInstString;
-       FILETIME        ftTimeStamp;
-       DWORD           dwCRC;
-       WCHAR           tszActionMap[MAX_PATH];
-} DIACTIONFORMATW, *LPDIACTIONFORMATW;
-typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW;
-
-DECL_WINELIB_TYPE_AW(DIACTIONFORMAT)
-DECL_WINELIB_TYPE_AW(LPDIACTIONFORMAT)
-DECL_WINELIB_TYPE_AW(LPCDIACTIONFORMAT)
-
-#define DIAFTS_NEWDEVICELOW    0xFFFFFFFF
-#define DIAFTS_NEWDEVICEHIGH   0xFFFFFFFF
-#define DIAFTS_UNUSEDDEVICELOW 0x00000000
-#define DIAFTS_UNUSEDDEVICEHIGH        0x00000000
-
-#define DIDBAM_DEFAULT         0x00000000
-#define DIDBAM_PRESERVE                0x00000001
-#define DIDBAM_INITIALIZE      0x00000002
-#define DIDBAM_HWDEFAULTS      0x00000004
-
-#define DIDSAM_DEFAULT         0x00000000
-#define DIDSAM_NOUSER          0x00000001
-#define DIDSAM_FORCESAVE       0x00000002
-
-#define DICD_DEFAULT           0x00000000
-#define DICD_EDIT              0x00000001
-
-#ifndef D3DCOLOR_DEFINED
-typedef DWORD D3DCOLOR;
-#define D3DCOLOR_DEFINED
-#endif
-
-typedef struct _DICOLORSET {
-       DWORD           dwSize;
-       D3DCOLOR        cTextFore;
-       D3DCOLOR        cTextHighlight;
-       D3DCOLOR        cCalloutLine;
-       D3DCOLOR        cCalloutHighlight;
-       D3DCOLOR        cBorder;
-       D3DCOLOR        cControlFill;
-       D3DCOLOR        cHighlightFill;
-       D3DCOLOR        cAreaFill;
-} DICOLORSET, *LPDICOLORSET;
-typedef const DICOLORSET *LPCDICOLORSET;
-
-typedef struct _DICONFIGUREDEVICESPARAMSA {
-       DWORD                   dwSize;
-       DWORD                   dwcUsers;
-       LPSTR                   lptszUserNames;
-       DWORD                   dwcFormats;
-       LPDIACTIONFORMATA       lprgFormats;
-       HWND                    hwnd;
-       DICOLORSET              dics;
-       LPUNKNOWN               lpUnkDDSTarget;
-} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA;
-typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA;
-
-typedef struct _DICONFIGUREDEVICESPARAMSW {
-       DWORD                   dwSize;
-       DWORD                   dwcUsers;
-       LPWSTR                  lptszUserNames;
-       DWORD                   dwcFormats;
-       LPDIACTIONFORMATW       lprgFormats;
-       HWND                    hwnd;
-       DICOLORSET              dics;
-       LPUNKNOWN               lpUnkDDSTarget;
-} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW;
-typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW;
-
-DECL_WINELIB_TYPE_AW(DICONFIGUREDEVICESPARAMS)
-DECL_WINELIB_TYPE_AW(LPDICONFIGUREDEVICESPARAMS)
-DECL_WINELIB_TYPE_AW(LPCDICONFIGUREDEVICESPARAMS)
-
-#define DIDIFT_CONFIGURATION   0x00000001
-#define DIDIFT_OVERLAY         0x00000002
-
-#define DIDAL_CENTERED         0x00000000
-#define DIDAL_LEFTALIGNED      0x00000001
-#define DIDAL_RIGHTALIGNED     0x00000002
-#define DIDAL_MIDDLE           0x00000000
-#define DIDAL_TOPALIGNED       0x00000004
-#define DIDAL_BOTTOMALIGNED    0x00000008
-
-typedef struct _DIDEVICEIMAGEINFOA {
-       CHAR    tszImagePath[MAX_PATH];
-       DWORD   dwFlags;
-       DWORD   dwViewID;
-       RECT    rcOverlay;
-       DWORD   dwObjID;
-       DWORD   dwcValidPts;
-       POINT   rgptCalloutLine[5];
-       RECT    rcCalloutRect;
-       DWORD   dwTextAlign;
-} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA;
-typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA;
-
-typedef struct _DIDEVICEIMAGEINFOW {
-       WCHAR   tszImagePath[MAX_PATH];
-       DWORD   dwFlags;
-       DWORD   dwViewID;
-       RECT    rcOverlay;
-       DWORD   dwObjID;
-       DWORD   dwcValidPts;
-       POINT   rgptCalloutLine[5];
-       RECT    rcCalloutRect;
-       DWORD   dwTextAlign;
-} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW;
-typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFO)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFO)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFO)
-
-typedef struct _DIDEVICEIMAGEINFOHEADERA {
-       DWORD   dwSize;
-       DWORD   dwSizeImageInfo;
-       DWORD   dwcViews;
-       DWORD   dwcButtons;
-       DWORD   dwcAxes;
-       DWORD   dwcPOVs;
-       DWORD   dwBufferSize;
-       DWORD   dwBufferUsed;
-       LPDIDEVICEIMAGEINFOA    lprgImageInfoArray;
-} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA;
-typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA;
-
-typedef struct _DIDEVICEIMAGEINFOHEADERW {
-       DWORD   dwSize;
-       DWORD   dwSizeImageInfo;
-       DWORD   dwcViews;
-       DWORD   dwcButtons;
-       DWORD   dwcAxes;
-       DWORD   dwcPOVs;
-       DWORD   dwBufferSize;
-       DWORD   dwBufferUsed;
-       LPDIDEVICEIMAGEINFOW    lprgImageInfoArray;
-} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW;
-typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFOHEADER)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER)
-
-#endif /* DI8 */
-
-
-/*****************************************************************************
- * IDirectInputEffect interface
- */
-#if (DIRECTINPUT_VERSION >= 0x0500)
-#undef INTERFACE
-#define INTERFACE IDirectInputEffect
-DECLARE_INTERFACE_(IDirectInputEffect,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputEffect methods ***/
-    STDMETHOD(Initialize)(THIS_ HINSTANCE, DWORD, REFGUID) PURE;
-    STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE;
-    STDMETHOD(GetParameters)(THIS_ LPDIEFFECT, DWORD) PURE;
-    STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT, DWORD) PURE;
-    STDMETHOD(Start)(THIS_ DWORD, DWORD) PURE;
-    STDMETHOD(Stop)(THIS) PURE;
-    STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE;
-    STDMETHOD(Download)(THIS) PURE;
-    STDMETHOD(Unload)(THIS) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputEffect_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputEffect_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputEffect methods ***/
-#define IDirectInputEffect_Initialize(p,a,b,c)    (p)->lpVtbl->Initialize(p,a,b,c)
-#define IDirectInputEffect_GetEffectGuid(p,a)     (p)->lpVtbl->GetEffectGuid(p,a)
-#define IDirectInputEffect_GetParameters(p,a,b)   (p)->lpVtbl->GetParameters(p,a,b)
-#define IDirectInputEffect_SetParameters(p,a,b)   (p)->lpVtbl->SetParameters(p,a,b)
-#define IDirectInputEffect_Start(p,a,b)           (p)->lpVtbl->Start(p,a,b)
-#define IDirectInputEffect_Stop(p)                (p)->lpVtbl->Stop(p)
-#define IDirectInputEffect_GetEffectStatus(p,a)   (p)->lpVtbl->GetEffectStatus(p,a)
-#define IDirectInputEffect_Download(p)            (p)->lpVtbl->Download(p)
-#define IDirectInputEffect_Unload(p)              (p)->lpVtbl->Unload(p)
-#define IDirectInputEffect_Escape(p,a)            (p)->lpVtbl->Escape(p,a)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputEffect_AddRef(p)             (p)->AddRef()
-#define IDirectInputEffect_Release(p)            (p)->Release()
-/*** IDirectInputEffect methods ***/
-#define IDirectInputEffect_Initialize(p,a,b,c)    (p)->Initialize(a,b,c)
-#define IDirectInputEffect_GetEffectGuid(p,a)     (p)->GetEffectGuid(a)
-#define IDirectInputEffect_GetParameters(p,a,b)   (p)->GetParameters(a,b)
-#define IDirectInputEffect_SetParameters(p,a,b)   (p)->SetParameters(a,b)
-#define IDirectInputEffect_Start(p,a,b)           (p)->Start(a,b)
-#define IDirectInputEffect_Stop(p)                (p)->Stop()
-#define IDirectInputEffect_GetEffectStatus(p,a)   (p)->GetEffectStatus(a)
-#define IDirectInputEffect_Download(p)            (p)->Download()
-#define IDirectInputEffect_Unload(p)              (p)->Unload()
-#define IDirectInputEffect_Escape(p,a)            (p)->Escape(a)
-#endif
-
-#endif /* DI5 */
-
-
-/*****************************************************************************
- * IDirectInputDeviceA interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDeviceA
-DECLARE_INTERFACE_(IDirectInputDeviceA,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDeviceW interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDeviceW
-DECLARE_INTERFACE_(IDirectInputDeviceW,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-#endif
-
-
-#if (DIRECTINPUT_VERSION >= 0x0500)
-/*****************************************************************************
- * IDirectInputDevice2A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice2A
-DECLARE_INTERFACE_(IDirectInputDevice2A,IDirectInputDeviceA)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice2W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice2W
-DECLARE_INTERFACE_(IDirectInputDevice2W,IDirectInputDeviceW)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice2_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice2_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice2_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice2_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice2_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice2_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice2_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice2_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice2_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice2_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice2_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice2_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice2_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice2_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice2_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice2_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice2_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice2_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice2_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice2_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice2_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice2_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice2_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice2_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice2_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice2_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice2_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice2_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice2_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice2_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice2_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice2_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice2_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice2_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice2_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice2_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice2_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice2_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice2_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice2_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice2_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice2_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice2_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice2_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-#endif
-#endif /* DI5 */
-
-#if DIRECTINPUT_VERSION >= 0x0700
-/*****************************************************************************
- * IDirectInputDevice7A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice7A
-DECLARE_INTERFACE_(IDirectInputDevice7A,IDirectInputDevice2A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7A methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice7W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice7W
-DECLARE_INTERFACE_(IDirectInputDevice7W,IDirectInputDevice2W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7W methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice7_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice7_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice7_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice7_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice7_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice7_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice7_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice7_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice7_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice7_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice7_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice7_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice7_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice7_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice7_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice7_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice7_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice7_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice7_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice7_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice7_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice7_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
-#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice7_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice7_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice7_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice7_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice7_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice7_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice7_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice7_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice7_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice7_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice7_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice7_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice7_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice7_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice7_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice7_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice7_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice7_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice7_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice7_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice7_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice7_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
-#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
-#endif
-
-#endif /* DI7 */
-
-#if DIRECTINPUT_VERSION >= 0x0800
-/*****************************************************************************
- * IDirectInputDevice8A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice8A
-DECLARE_INTERFACE_(IDirectInputDevice8A,IDirectInputDevice7A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7A methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-    /*** IDirectInputDevice8A methods ***/
-    STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice8W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice8W
-DECLARE_INTERFACE_(IDirectInputDevice8W,IDirectInputDevice7W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7W methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-    /*** IDirectInputDevice8W methods ***/
-    STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice8_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice8_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice8_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice8_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice8_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice8_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice8_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice8_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice8_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice8_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice8_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice8_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice8_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice8_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice8_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice8_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice8_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice8_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice8_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice8_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice8_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice8_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
-#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
-/*** IDirectInputDevice8 methods ***/
-#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c)
-#define IDirectInputDevice8_SetActionMap(p,a,b,c)   (p)->lpVtbl->SetActionMap(p,a,b,c)
-#define IDirectInputDevice8_GetImageInfo(p,a)       (p)->lpVtbl->GetImageInfo(p,a)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice8_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice8_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice8_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice8_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice8_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice8_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice8_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice8_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice8_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice8_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice8_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice8_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice8_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice8_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice8_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice8_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice8_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice8_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice8_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice8_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice8_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice8_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
-#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
-/*** IDirectInputDevice8 methods ***/
-#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c)
-#define IDirectInputDevice8_SetActionMap(p,a,b,c)   (p)->SetActionMap(a,b,c)
-#define IDirectInputDevice8_GetImageInfo(p,a)       (p)->GetImageInfo(a)
-#endif
-
-#endif /* DI8 */
-
-/* "Standard" Mouse report... */
-typedef struct DIMOUSESTATE {
-  LONG lX;
-  LONG lY;
-  LONG lZ;
-  BYTE rgbButtons[4];
-} DIMOUSESTATE;
-
-#if DIRECTINPUT_VERSION >= 0x0700
-/* "Standard" Mouse report for DInput 7... */
-typedef struct DIMOUSESTATE2 {
-  LONG lX;
-  LONG lY;
-  LONG lZ;
-  BYTE rgbButtons[8];
-} DIMOUSESTATE2;
-#endif /* DI7 */
-
-#define DIMOFS_X        FIELD_OFFSET(DIMOUSESTATE, lX)
-#define DIMOFS_Y        FIELD_OFFSET(DIMOUSESTATE, lY)
-#define DIMOFS_Z        FIELD_OFFSET(DIMOUSESTATE, lZ)
-#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0)
-#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1)
-#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2)
-#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3)
-#if DIRECTINPUT_VERSION >= 0x0700
-#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4)
-#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5)
-#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6)
-#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7)
-#endif /* DI7 */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern const DIDATAFORMAT c_dfDIMouse;
-#if DIRECTINPUT_VERSION >= 0x0700
-extern const DIDATAFORMAT c_dfDIMouse2; /* DX 7 */
-#endif /* DI7 */
-extern const DIDATAFORMAT c_dfDIKeyboard;
-#if DIRECTINPUT_VERSION >= 0x0500
-extern const DIDATAFORMAT c_dfDIJoystick;
-extern const DIDATAFORMAT c_dfDIJoystick2;
-#endif /* DI5 */
-#ifdef __cplusplus
-};
-#endif
-
-/*****************************************************************************
- * IDirectInputA interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputA
-DECLARE_INTERFACE_(IDirectInputA,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputW interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputW
-DECLARE_INTERFACE_(IDirectInputW,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput_AddRef(p)             (p)->AddRef()
-#define IDirectInput_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput_Initialize(p,a,b)      (p)->Initialize(a,b)
-#endif
-
-/*****************************************************************************
- * IDirectInput2A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput2A
-DECLARE_INTERFACE_(IDirectInput2A,IDirectInputA)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2A methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput2W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput2W
-DECLARE_INTERFACE_(IDirectInput2W,IDirectInputW)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2W methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput2_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput2_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput2_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput2_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput2_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput2_FindDevice(p,a,b,c)    (p)->lpVtbl->FindDevice(p,a,b,c)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput2_AddRef(p)             (p)->AddRef()
-#define IDirectInput2_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput2_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput2_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput2_Initialize(p,a,b)      (p)->Initialize(a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput2_FindDevice(p,a,b,c)    (p)->FindDevice(a,b,c)
-#endif
-
-/*****************************************************************************
- * IDirectInput7A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput7A
-DECLARE_INTERFACE_(IDirectInput7A,IDirectInput2A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2A methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-    /*** IDirectInput7A methods ***/
-    STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput7W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput7W
-DECLARE_INTERFACE_(IDirectInput7W,IDirectInput2W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2W methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-    /*** IDirectInput7W methods ***/
-    STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput7_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput7_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput7_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput7_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput7_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput7_FindDevice(p,a,b,c)    (p)->lpVtbl->FindDevice(p,a,b,c)
-/*** IDirectInput7 methods ***/
-#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput7_AddRef(p)             (p)->AddRef()
-#define IDirectInput7_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput7_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput7_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput7_Initialize(p,a,b)      (p)->Initialize(a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput7_FindDevice(p,a,b,c)    (p)->FindDevice(a,b,c)
-/*** IDirectInput7 methods ***/
-#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d)
-#endif
-
-
-#if DIRECTINPUT_VERSION >= 0x0800
-/*****************************************************************************
- * IDirectInput8A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput8A
-DECLARE_INTERFACE_(IDirectInput8A,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInput8A methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8A *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-    STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput8W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput8W
-DECLARE_INTERFACE_(IDirectInput8W,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInput8W methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-    STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
-};
-#undef INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput8_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput8_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput8 methods ***/
-#define IDirectInput8_CreateDevice(p,a,b,c)       (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput8_EnumDevices(p,a,b,c,d)      (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput8_GetDeviceStatus(p,a)        (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput8_RunControlPanel(p,a,b)      (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput8_Initialize(p,a,b)           (p)->lpVtbl->Initialize(p,a,b)
-#define IDirectInput8_FindDevice(p,a,b,c)         (p)->lpVtbl->FindDevice(p,a,b,c)
-#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
-#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput8_AddRef(p)             (p)->AddRef()
-#define IDirectInput8_Release(p)            (p)->Release()
-/*** IDirectInput8 methods ***/
-#define IDirectInput8_CreateDevice(p,a,b,c)       (p)->CreateDevice(a,b,c)
-#define IDirectInput8_EnumDevices(p,a,b,c,d)      (p)->EnumDevices(a,b,c,d)
-#define IDirectInput8_GetDeviceStatus(p,a)        (p)->GetDeviceStatus(a)
-#define IDirectInput8_RunControlPanel(p,a,b)      (p)->RunControlPanel(a,b)
-#define IDirectInput8_Initialize(p,a,b)           (p)->Initialize(a,b)
-#define IDirectInput8_FindDevice(p,a,b,c)         (p)->FindDevice(a,b,c)
-#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e)
-#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d)
-#endif
-
-#endif /* DI8 */
-
-/* Export functions */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x0800
-HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
-#else /* DI < 8 */
-HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
-HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN);
-#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate)
-
-HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
-#endif /* DI8 */
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* __DINPUT_INCLUDED__ */
diff --git a/raylib/external/glfw/deps/mingw/xinput.h b/raylib/external/glfw/deps/mingw/xinput.h
deleted file mode 100644 (file)
index d3ca726..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * The Wine project - Xinput Joystick Library
- * Copyright 2008 Andrew Fenn
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __WINE_XINPUT_H
-#define __WINE_XINPUT_H
-
-#include <windef.h>
-
-/*
- * Bitmasks for the joysticks buttons, determines what has
- * been pressed on the joystick, these need to be mapped
- * to whatever device you're using instead of an xbox 360
- * joystick
- */
-
-#define XINPUT_GAMEPAD_DPAD_UP          0x0001
-#define XINPUT_GAMEPAD_DPAD_DOWN        0x0002
-#define XINPUT_GAMEPAD_DPAD_LEFT        0x0004
-#define XINPUT_GAMEPAD_DPAD_RIGHT       0x0008
-#define XINPUT_GAMEPAD_START            0x0010
-#define XINPUT_GAMEPAD_BACK             0x0020
-#define XINPUT_GAMEPAD_LEFT_THUMB       0x0040
-#define XINPUT_GAMEPAD_RIGHT_THUMB      0x0080
-#define XINPUT_GAMEPAD_LEFT_SHOULDER    0x0100
-#define XINPUT_GAMEPAD_RIGHT_SHOULDER   0x0200
-#define XINPUT_GAMEPAD_A                0x1000
-#define XINPUT_GAMEPAD_B                0x2000
-#define XINPUT_GAMEPAD_X                0x4000
-#define XINPUT_GAMEPAD_Y                0x8000
-
-/*
- * Defines the flags used to determine if the user is pushing
- * down on a button, not holding a button, etc
- */
-
-#define XINPUT_KEYSTROKE_KEYDOWN        0x0001
-#define XINPUT_KEYSTROKE_KEYUP          0x0002
-#define XINPUT_KEYSTROKE_REPEAT         0x0004
-
-/*
- * Defines the codes which are returned by XInputGetKeystroke
- */
-
-#define VK_PAD_A                        0x5800
-#define VK_PAD_B                        0x5801
-#define VK_PAD_X                        0x5802
-#define VK_PAD_Y                        0x5803
-#define VK_PAD_RSHOULDER                0x5804
-#define VK_PAD_LSHOULDER                0x5805
-#define VK_PAD_LTRIGGER                 0x5806
-#define VK_PAD_RTRIGGER                 0x5807
-#define VK_PAD_DPAD_UP                  0x5810
-#define VK_PAD_DPAD_DOWN                0x5811
-#define VK_PAD_DPAD_LEFT                0x5812
-#define VK_PAD_DPAD_RIGHT               0x5813
-#define VK_PAD_START                    0x5814
-#define VK_PAD_BACK                     0x5815
-#define VK_PAD_LTHUMB_PRESS             0x5816
-#define VK_PAD_RTHUMB_PRESS             0x5817
-#define VK_PAD_LTHUMB_UP                0x5820
-#define VK_PAD_LTHUMB_DOWN              0x5821
-#define VK_PAD_LTHUMB_RIGHT             0x5822
-#define VK_PAD_LTHUMB_LEFT              0x5823
-#define VK_PAD_LTHUMB_UPLEFT            0x5824
-#define VK_PAD_LTHUMB_UPRIGHT           0x5825
-#define VK_PAD_LTHUMB_DOWNRIGHT         0x5826
-#define VK_PAD_LTHUMB_DOWNLEFT          0x5827
-#define VK_PAD_RTHUMB_UP                0x5830
-#define VK_PAD_RTHUMB_DOWN              0x5831
-#define VK_PAD_RTHUMB_RIGHT             0x5832
-#define VK_PAD_RTHUMB_LEFT              0x5833
-#define VK_PAD_RTHUMB_UPLEFT            0x5834
-#define VK_PAD_RTHUMB_UPRIGHT           0x5835
-#define VK_PAD_RTHUMB_DOWNRIGHT         0x5836
-#define VK_PAD_RTHUMB_DOWNLEFT          0x5837
-
-/*
- * Deadzones are for analogue joystick controls on the joypad
- * which determine when input should be assumed to be in the
- * middle of the pad. This is a threshold to stop a joypad
- * controlling the game when the player isn't touching the
- * controls.
- */
-
-#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  7849
-#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
-#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD    30
-
-
-/*
- * Defines what type of abilities the type of joystick has
- * DEVTYPE_GAMEPAD is available for all joysticks, however
- * there may be more specific identifiers for other joysticks
- * which are being used.
- */
-
-#define XINPUT_DEVTYPE_GAMEPAD          0x01
-#define XINPUT_DEVSUBTYPE_GAMEPAD       0x01
-#define XINPUT_DEVSUBTYPE_WHEEL         0x02
-#define XINPUT_DEVSUBTYPE_ARCADE_STICK  0x03
-#define XINPUT_DEVSUBTYPE_FLIGHT_SICK   0x04
-#define XINPUT_DEVSUBTYPE_DANCE_PAD     0x05
-#define XINPUT_DEVSUBTYPE_GUITAR        0x06
-#define XINPUT_DEVSUBTYPE_DRUM_KIT      0x08
-
-/*
- * These are used with the XInputGetCapabilities function to
- * determine the abilities to the joystick which has been
- * plugged in.
- */
-
-#define XINPUT_CAPS_VOICE_SUPPORTED     0x0004
-#define XINPUT_FLAG_GAMEPAD             0x00000001
-
-/*
- * Defines the status of the battery if one is used in the
- * attached joystick. The first two define if the joystick
- * supports a battery. Disconnected means that the joystick
- * isn't connected. Wired shows that the joystick is a wired
- * joystick.
- */
-
-#define BATTERY_DEVTYPE_GAMEPAD         0x00
-#define BATTERY_DEVTYPE_HEADSET         0x01
-#define BATTERY_TYPE_DISCONNECTED       0x00
-#define BATTERY_TYPE_WIRED              0x01
-#define BATTERY_TYPE_ALKALINE           0x02
-#define BATTERY_TYPE_NIMH               0x03
-#define BATTERY_TYPE_UNKNOWN            0xFF
-#define BATTERY_LEVEL_EMPTY             0x00
-#define BATTERY_LEVEL_LOW               0x01
-#define BATTERY_LEVEL_MEDIUM            0x02
-#define BATTERY_LEVEL_FULL              0x03
-
-/*
- * How many joysticks can be used with this library. Games that
- * use the xinput library will not go over this number.
- */
-
-#define XUSER_MAX_COUNT                 4
-#define XUSER_INDEX_ANY                 0x000000FF
-
-/*
- * Defines the structure of an xbox 360 joystick.
- */
-
-typedef struct _XINPUT_GAMEPAD {
-    WORD wButtons;
-    BYTE bLeftTrigger;
-    BYTE bRightTrigger;
-    SHORT sThumbLX;
-    SHORT sThumbLY;
-    SHORT sThumbRX;
-    SHORT sThumbRY;
-} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
-
-typedef struct _XINPUT_STATE {
-    DWORD dwPacketNumber;
-    XINPUT_GAMEPAD Gamepad;
-} XINPUT_STATE, *PXINPUT_STATE;
-
-/*
- * Defines the structure of how much vibration is set on both the
- * right and left motors in a joystick. If you're not using a 360
- * joystick you will have to map these to your device.
- */
-
-typedef struct _XINPUT_VIBRATION {
-    WORD wLeftMotorSpeed;
-    WORD wRightMotorSpeed;
-} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
-
-/*
- * Defines the structure for what kind of abilities the joystick has
- * such abilities are things such as if the joystick has the ability
- * to send and receive audio, if the joystick is in fact a driving
- * wheel or perhaps if the joystick is some kind of dance pad or
- * guitar.
- */
-
-typedef struct _XINPUT_CAPABILITIES {
-    BYTE Type;
-    BYTE SubType;
-    WORD Flags;
-    XINPUT_GAMEPAD Gamepad;
-    XINPUT_VIBRATION Vibration;
-} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
-
-/*
- * Defines the structure for a joystick input event which is
- * retrieved using the function XInputGetKeystroke
- */
-typedef struct _XINPUT_KEYSTROKE {
-    WORD VirtualKey;
-    WCHAR Unicode;
-    WORD Flags;
-    BYTE UserIndex;
-    BYTE HidCode;
-} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
-
-typedef struct _XINPUT_BATTERY_INFORMATION
-{
-    BYTE BatteryType;
-    BYTE BatteryLevel;
-} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void WINAPI XInputEnable(WINBOOL);
-DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
-DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
-DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
-DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
-DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
-DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __WINE_XINPUT_H */
diff --git a/raylib/external/glfw/deps/vs2008/stdint.h b/raylib/external/glfw/deps/vs2008/stdint.h
deleted file mode 100644 (file)
index d02608a..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-// ISO C9x  compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
-// 
-//  Copyright (c) 2006-2008 Alexander Chemeris
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// 
-//   1. Redistributions of source code must retain the above copyright notice,
-//      this list of conditions and the following disclaimer.
-// 
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-// 
-//   3. The name of the author may be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_STDINT_H_ // [
-#define _MSC_STDINT_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include <limits.h>
-
-// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
-// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
-// or compiler give many errors like this:
-//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
-#ifdef __cplusplus
-extern "C" {
-#endif
-#  include <wchar.h>
-#ifdef __cplusplus
-}
-#endif
-
-// Define _W64 macros to mark types changing their size, like intptr_t.
-#ifndef _W64
-#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
-#     define _W64 __w64
-#  else
-#     define _W64
-#  endif
-#endif
-
-
-// 7.18.1 Integer types
-
-// 7.18.1.1 Exact-width integer types
-
-// Visual Studio 6 and Embedded Visual C++ 4 doesn't
-// realize that, e.g. char has the same size as __int8
-// so we give up on __intX for them.
-#if (_MSC_VER < 1300)
-   typedef signed char       int8_t;
-   typedef signed short      int16_t;
-   typedef signed int        int32_t;
-   typedef unsigned char     uint8_t;
-   typedef unsigned short    uint16_t;
-   typedef unsigned int      uint32_t;
-#else
-   typedef signed __int8     int8_t;
-   typedef signed __int16    int16_t;
-   typedef signed __int32    int32_t;
-   typedef unsigned __int8   uint8_t;
-   typedef unsigned __int16  uint16_t;
-   typedef unsigned __int32  uint32_t;
-#endif
-typedef signed __int64       int64_t;
-typedef unsigned __int64     uint64_t;
-
-
-// 7.18.1.2 Minimum-width integer types
-typedef int8_t    int_least8_t;
-typedef int16_t   int_least16_t;
-typedef int32_t   int_least32_t;
-typedef int64_t   int_least64_t;
-typedef uint8_t   uint_least8_t;
-typedef uint16_t  uint_least16_t;
-typedef uint32_t  uint_least32_t;
-typedef uint64_t  uint_least64_t;
-
-// 7.18.1.3 Fastest minimum-width integer types
-typedef int8_t    int_fast8_t;
-typedef int16_t   int_fast16_t;
-typedef int32_t   int_fast32_t;
-typedef int64_t   int_fast64_t;
-typedef uint8_t   uint_fast8_t;
-typedef uint16_t  uint_fast16_t;
-typedef uint32_t  uint_fast32_t;
-typedef uint64_t  uint_fast64_t;
-
-// 7.18.1.4 Integer types capable of holding object pointers
-#ifdef _WIN64 // [
-   typedef signed __int64    intptr_t;
-   typedef unsigned __int64  uintptr_t;
-#else // _WIN64 ][
-   typedef _W64 signed int   intptr_t;
-   typedef _W64 unsigned int uintptr_t;
-#endif // _WIN64 ]
-
-// 7.18.1.5 Greatest-width integer types
-typedef int64_t   intmax_t;
-typedef uint64_t  uintmax_t;
-
-
-// 7.18.2 Limits of specified-width integer types
-
-#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259
-
-// 7.18.2.1 Limits of exact-width integer types
-#define INT8_MIN     ((int8_t)_I8_MIN)
-#define INT8_MAX     _I8_MAX
-#define INT16_MIN    ((int16_t)_I16_MIN)
-#define INT16_MAX    _I16_MAX
-#define INT32_MIN    ((int32_t)_I32_MIN)
-#define INT32_MAX    _I32_MAX
-#define INT64_MIN    ((int64_t)_I64_MIN)
-#define INT64_MAX    _I64_MAX
-#define UINT8_MAX    _UI8_MAX
-#define UINT16_MAX   _UI16_MAX
-#define UINT32_MAX   _UI32_MAX
-#define UINT64_MAX   _UI64_MAX
-
-// 7.18.2.2 Limits of minimum-width integer types
-#define INT_LEAST8_MIN    INT8_MIN
-#define INT_LEAST8_MAX    INT8_MAX
-#define INT_LEAST16_MIN   INT16_MIN
-#define INT_LEAST16_MAX   INT16_MAX
-#define INT_LEAST32_MIN   INT32_MIN
-#define INT_LEAST32_MAX   INT32_MAX
-#define INT_LEAST64_MIN   INT64_MIN
-#define INT_LEAST64_MAX   INT64_MAX
-#define UINT_LEAST8_MAX   UINT8_MAX
-#define UINT_LEAST16_MAX  UINT16_MAX
-#define UINT_LEAST32_MAX  UINT32_MAX
-#define UINT_LEAST64_MAX  UINT64_MAX
-
-// 7.18.2.3 Limits of fastest minimum-width integer types
-#define INT_FAST8_MIN    INT8_MIN
-#define INT_FAST8_MAX    INT8_MAX
-#define INT_FAST16_MIN   INT16_MIN
-#define INT_FAST16_MAX   INT16_MAX
-#define INT_FAST32_MIN   INT32_MIN
-#define INT_FAST32_MAX   INT32_MAX
-#define INT_FAST64_MIN   INT64_MIN
-#define INT_FAST64_MAX   INT64_MAX
-#define UINT_FAST8_MAX   UINT8_MAX
-#define UINT_FAST16_MAX  UINT16_MAX
-#define UINT_FAST32_MAX  UINT32_MAX
-#define UINT_FAST64_MAX  UINT64_MAX
-
-// 7.18.2.4 Limits of integer types capable of holding object pointers
-#ifdef _WIN64 // [
-#  define INTPTR_MIN   INT64_MIN
-#  define INTPTR_MAX   INT64_MAX
-#  define UINTPTR_MAX  UINT64_MAX
-#else // _WIN64 ][
-#  define INTPTR_MIN   INT32_MIN
-#  define INTPTR_MAX   INT32_MAX
-#  define UINTPTR_MAX  UINT32_MAX
-#endif // _WIN64 ]
-
-// 7.18.2.5 Limits of greatest-width integer types
-#define INTMAX_MIN   INT64_MIN
-#define INTMAX_MAX   INT64_MAX
-#define UINTMAX_MAX  UINT64_MAX
-
-// 7.18.3 Limits of other integer types
-
-#ifdef _WIN64 // [
-#  define PTRDIFF_MIN  _I64_MIN
-#  define PTRDIFF_MAX  _I64_MAX
-#else  // _WIN64 ][
-#  define PTRDIFF_MIN  _I32_MIN
-#  define PTRDIFF_MAX  _I32_MAX
-#endif  // _WIN64 ]
-
-#define SIG_ATOMIC_MIN  INT_MIN
-#define SIG_ATOMIC_MAX  INT_MAX
-
-#ifndef SIZE_MAX // [
-#  ifdef _WIN64 // [
-#     define SIZE_MAX  _UI64_MAX
-#  else // _WIN64 ][
-#     define SIZE_MAX  _UI32_MAX
-#  endif // _WIN64 ]
-#endif // SIZE_MAX ]
-
-// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
-#ifndef WCHAR_MIN // [
-#  define WCHAR_MIN  0
-#endif  // WCHAR_MIN ]
-#ifndef WCHAR_MAX // [
-#  define WCHAR_MAX  _UI16_MAX
-#endif  // WCHAR_MAX ]
-
-#define WINT_MIN  0
-#define WINT_MAX  _UI16_MAX
-
-#endif // __STDC_LIMIT_MACROS ]
-
-
-// 7.18.4 Limits of other integer types
-
-#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260
-
-// 7.18.4.1 Macros for minimum-width integer constants
-
-#define INT8_C(val)  val##i8
-#define INT16_C(val) val##i16
-#define INT32_C(val) val##i32
-#define INT64_C(val) val##i64
-
-#define UINT8_C(val)  val##ui8
-#define UINT16_C(val) val##ui16
-#define UINT32_C(val) val##ui32
-#define UINT64_C(val) val##ui64
-
-// 7.18.4.2 Macros for greatest-width integer constants
-#define INTMAX_C   INT64_C
-#define UINTMAX_C  UINT64_C
-
-#endif // __STDC_CONSTANT_MACROS ]
-
-
-#endif // _MSC_STDINT_H_ ]
diff --git a/raylib/external/glfw/include/GLFW/glfw3.h b/raylib/external/glfw/include/GLFW/glfw3.h
deleted file mode 100644 (file)
index 7d9dee0..0000000
+++ /dev/null
@@ -1,6062 +0,0 @@
-/*************************************************************************
- * GLFW 3.4 - www.glfw.org
- * A library for OpenGL, window and input
- *------------------------------------------------------------------------
- * Copyright (c) 2002-2006 Marcus Geelnard
- * Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would
- *    be appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- *    be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- *    distribution.
- *
- *************************************************************************/
-
-#ifndef _glfw3_h_
-#define _glfw3_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*************************************************************************
- * Doxygen documentation
- *************************************************************************/
-
-/*! @file glfw3.h
- *  @brief The header of the GLFW 3 API.
- *
- *  This is the header file of the GLFW 3 API.  It defines all its types and
- *  declares all its functions.
- *
- *  For more information about how to use this file, see @ref build_include.
- */
-/*! @defgroup context Context reference
- *  @brief Functions and types related to OpenGL and OpenGL ES contexts.
- *
- *  This is the reference documentation for OpenGL and OpenGL ES context related
- *  functions.  For more task-oriented information, see the @ref context_guide.
- */
-/*! @defgroup vulkan Vulkan support reference
- *  @brief Functions and types related to Vulkan.
- *
- *  This is the reference documentation for Vulkan related functions and types.
- *  For more task-oriented information, see the @ref vulkan_guide.
- */
-/*! @defgroup init Initialization, version and error reference
- *  @brief Functions and types related to initialization and error handling.
- *
- *  This is the reference documentation for initialization and termination of
- *  the library, version management and error handling.  For more task-oriented
- *  information, see the @ref intro_guide.
- */
-/*! @defgroup input Input reference
- *  @brief Functions and types related to input handling.
- *
- *  This is the reference documentation for input related functions and types.
- *  For more task-oriented information, see the @ref input_guide.
- */
-/*! @defgroup monitor Monitor reference
- *  @brief Functions and types related to monitors.
- *
- *  This is the reference documentation for monitor related functions and types.
- *  For more task-oriented information, see the @ref monitor_guide.
- */
-/*! @defgroup window Window reference
- *  @brief Functions and types related to windows.
- *
- *  This is the reference documentation for window related functions and types,
- *  including creation, deletion and event polling.  For more task-oriented
- *  information, see the @ref window_guide.
- */
-
-
-/*************************************************************************
- * Compiler- and platform-specific preprocessor work
- *************************************************************************/
-
-/* If we are we on Windows, we want a single define for it.
- */
-#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
- #define _WIN32
-#endif /* _WIN32 */
-
-/* Include because most Windows GLU headers need wchar_t and
- * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
- * Include it unconditionally to avoid surprising side-effects.
- */
-#include <stddef.h>
-
-/* Include because it is needed by Vulkan and related functions.
- * Include it unconditionally to avoid surprising side-effects.
- */
-#include <stdint.h>
-
-#if defined(GLFW_INCLUDE_VULKAN)
-  #include <vulkan/vulkan.h>
-#endif /* Vulkan header */
-
-/* The Vulkan header may have indirectly included windows.h (because of
- * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
- */
-
-/* It is customary to use APIENTRY for OpenGL function pointer declarations on
- * all platforms.  Additionally, the Windows OpenGL header needs APIENTRY.
- */
-#if !defined(APIENTRY)
- #if defined(_WIN32)
-  #define APIENTRY __stdcall
- #else
-  #define APIENTRY
- #endif
- #define GLFW_APIENTRY_DEFINED
-#endif /* APIENTRY */
-
-/* Some Windows OpenGL headers need this.
- */
-#if !defined(WINGDIAPI) && defined(_WIN32)
- #define WINGDIAPI __declspec(dllimport)
- #define GLFW_WINGDIAPI_DEFINED
-#endif /* WINGDIAPI */
-
-/* Some Windows GLU headers need this.
- */
-#if !defined(CALLBACK) && defined(_WIN32)
- #define CALLBACK __stdcall
- #define GLFW_CALLBACK_DEFINED
-#endif /* CALLBACK */
-
-/* Include the chosen OpenGL or OpenGL ES headers.
- */
-#if defined(GLFW_INCLUDE_ES1)
-
- #include <GLES/gl.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES/glext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES2)
-
- #include <GLES2/gl2.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES3)
-
- #include <GLES3/gl3.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES31)
-
- #include <GLES3/gl31.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES32)
-
- #include <GLES3/gl32.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_GLCOREARB)
-
- #if defined(__APPLE__)
-
-  #include <OpenGL/gl3.h>
-  #if defined(GLFW_INCLUDE_GLEXT)
-   #include <OpenGL/gl3ext.h>
-  #endif /*GLFW_INCLUDE_GLEXT*/
-
- #else /*__APPLE__*/
-
-  #include <GL/glcorearb.h>
-
- #endif /*__APPLE__*/
-
-#elif defined(GLFW_INCLUDE_GLU)
-
- #if defined(__APPLE__)
-
-  #if defined(GLFW_INCLUDE_GLU)
-   #include <OpenGL/glu.h>
-  #endif
-
- #else /*__APPLE__*/
-
-  #if defined(GLFW_INCLUDE_GLU)
-   #include <GL/glu.h>
-  #endif
-
- #endif /*__APPLE__*/
-
-#elif !defined(GLFW_INCLUDE_NONE) && \
-      !defined(__gl_h_) && \
-      !defined(__gles1_gl_h_) && \
-      !defined(__gles2_gl2_h_) && \
-      !defined(__gles2_gl3_h_) && \
-      !defined(__gles2_gl31_h_) && \
-      !defined(__gles2_gl32_h_) && \
-      !defined(__gl_glcorearb_h_) && \
-      !defined(__gl2_h_) /*legacy*/ && \
-      !defined(__gl3_h_) /*legacy*/ && \
-      !defined(__gl31_h_) /*legacy*/ && \
-      !defined(__gl32_h_) /*legacy*/ && \
-      !defined(__glcorearb_h_) /*legacy*/ && \
-      !defined(__GL_H__) /*non-standard*/ && \
-      !defined(__gltypes_h_) /*non-standard*/ && \
-      !defined(__glee_h_) /*non-standard*/
-
- #if defined(__APPLE__)
-
-  #if !defined(GLFW_INCLUDE_GLEXT)
-   #define GL_GLEXT_LEGACY
-  #endif
-  #include <OpenGL/gl.h>
-
- #else /*__APPLE__*/
-
-  #include <GL/gl.h>
-  #if defined(GLFW_INCLUDE_GLEXT)
-   #include <GL/glext.h>
-  #endif
-
- #endif /*__APPLE__*/
-
-#endif /* OpenGL and OpenGL ES headers */
-
-#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
- /* GLFW_DLL must be defined by applications that are linking against the DLL
-  * version of the GLFW library.  _GLFW_BUILD_DLL is defined by the GLFW
-  * configuration header when compiling the DLL version of the library.
-  */
- #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
-#endif
-
-/* GLFWAPI is used to declare public API functions for export
- * from the DLL / shared library / dynamic library.
- */
-#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
- /* We are building GLFW as a Win32 DLL */
- #define GLFWAPI __declspec(dllexport)
-#elif defined(_WIN32) && defined(GLFW_DLL)
- /* We are calling GLFW as a Win32 DLL */
- #define GLFWAPI __declspec(dllimport)
-#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
- /* We are building GLFW as a shared / dynamic library */
- #define GLFWAPI __attribute__((visibility("default")))
-#else
- /* We are building or calling GLFW as a static library */
- #define GLFWAPI
-#endif
-
-
-/*************************************************************************
- * GLFW API tokens
- *************************************************************************/
-
-/*! @name GLFW version macros
- *  @{ */
-/*! @brief The major version number of the GLFW library.
- *
- *  This is incremented when the API is changed in non-compatible ways.
- *  @ingroup init
- */
-#define GLFW_VERSION_MAJOR          3
-/*! @brief The minor version number of the GLFW library.
- *
- *  This is incremented when features are added to the API but it remains
- *  backward-compatible.
- *  @ingroup init
- */
-#define GLFW_VERSION_MINOR          4
-/*! @brief The revision number of the GLFW library.
- *
- *  This is incremented when a bug fix release is made that does not contain any
- *  API changes.
- *  @ingroup init
- */
-#define GLFW_VERSION_REVISION       0
-/*! @} */
-
-/*! @brief One.
- *
- *  This is only semantic sugar for the number 1.  You can instead use `1` or
- *  `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
- *  to one.
- *
- *  @ingroup init
- */
-#define GLFW_TRUE                   1
-/*! @brief Zero.
- *
- *  This is only semantic sugar for the number 0.  You can instead use `0` or
- *  `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
- *  equal to zero.
- *
- *  @ingroup init
- */
-#define GLFW_FALSE                  0
-
-/*! @name Key and button actions
- *  @{ */
-/*! @brief The key or mouse button was released.
- *
- *  The key or mouse button was released.
- *
- *  @ingroup input
- */
-#define GLFW_RELEASE                0
-/*! @brief The key or mouse button was pressed.
- *
- *  The key or mouse button was pressed.
- *
- *  @ingroup input
- */
-#define GLFW_PRESS                  1
-/*! @brief The key was held down until it repeated.
- *
- *  The key was held down until it repeated.
- *
- *  @ingroup input
- */
-#define GLFW_REPEAT                 2
-/*! @} */
-
-/*! @defgroup hat_state Joystick hat states
- *  @brief Joystick hat states.
- *
- *  See [joystick hat input](@ref joystick_hat) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_HAT_CENTERED           0
-#define GLFW_HAT_UP                 1
-#define GLFW_HAT_RIGHT              2
-#define GLFW_HAT_DOWN               4
-#define GLFW_HAT_LEFT               8
-#define GLFW_HAT_RIGHT_UP           (GLFW_HAT_RIGHT | GLFW_HAT_UP)
-#define GLFW_HAT_RIGHT_DOWN         (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
-#define GLFW_HAT_LEFT_UP            (GLFW_HAT_LEFT  | GLFW_HAT_UP)
-#define GLFW_HAT_LEFT_DOWN          (GLFW_HAT_LEFT  | GLFW_HAT_DOWN)
-/*! @} */
-
-/*! @defgroup keys Keyboard keys
- *  @brief Keyboard key IDs.
- *
- *  See [key input](@ref input_key) for how these are used.
- *
- *  These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
- *  but re-arranged to map to 7-bit ASCII for printable keys (function keys are
- *  put in the 256+ range).
- *
- *  The naming of the key codes follow these rules:
- *   - The US keyboard layout is used
- *   - Names of printable alpha-numeric characters are used (e.g. "A", "R",
- *     "3", etc.)
- *   - For non-alphanumeric characters, Unicode:ish names are used (e.g.
- *     "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
- *     correspond to the Unicode standard (usually for brevity)
- *   - Keys that lack a clear US mapping are named "WORLD_x"
- *   - For non-printable keys, custom names are used (e.g. "F4",
- *     "BACKSPACE", etc.)
- *
- *  @ingroup input
- *  @{
- */
-
-/* The unknown key */
-#define GLFW_KEY_UNKNOWN            -1
-
-/* Printable keys */
-#define GLFW_KEY_SPACE              32
-#define GLFW_KEY_APOSTROPHE         39  /* ' */
-#define GLFW_KEY_COMMA              44  /* , */
-#define GLFW_KEY_MINUS              45  /* - */
-#define GLFW_KEY_PERIOD             46  /* . */
-#define GLFW_KEY_SLASH              47  /* / */
-#define GLFW_KEY_0                  48
-#define GLFW_KEY_1                  49
-#define GLFW_KEY_2                  50
-#define GLFW_KEY_3                  51
-#define GLFW_KEY_4                  52
-#define GLFW_KEY_5                  53
-#define GLFW_KEY_6                  54
-#define GLFW_KEY_7                  55
-#define GLFW_KEY_8                  56
-#define GLFW_KEY_9                  57
-#define GLFW_KEY_SEMICOLON          59  /* ; */
-#define GLFW_KEY_EQUAL              61  /* = */
-#define GLFW_KEY_A                  65
-#define GLFW_KEY_B                  66
-#define GLFW_KEY_C                  67
-#define GLFW_KEY_D                  68
-#define GLFW_KEY_E                  69
-#define GLFW_KEY_F                  70
-#define GLFW_KEY_G                  71
-#define GLFW_KEY_H                  72
-#define GLFW_KEY_I                  73
-#define GLFW_KEY_J                  74
-#define GLFW_KEY_K                  75
-#define GLFW_KEY_L                  76
-#define GLFW_KEY_M                  77
-#define GLFW_KEY_N                  78
-#define GLFW_KEY_O                  79
-#define GLFW_KEY_P                  80
-#define GLFW_KEY_Q                  81
-#define GLFW_KEY_R                  82
-#define GLFW_KEY_S                  83
-#define GLFW_KEY_T                  84
-#define GLFW_KEY_U                  85
-#define GLFW_KEY_V                  86
-#define GLFW_KEY_W                  87
-#define GLFW_KEY_X                  88
-#define GLFW_KEY_Y                  89
-#define GLFW_KEY_Z                  90
-#define GLFW_KEY_LEFT_BRACKET       91  /* [ */
-#define GLFW_KEY_BACKSLASH          92  /* \ */
-#define GLFW_KEY_RIGHT_BRACKET      93  /* ] */
-#define GLFW_KEY_GRAVE_ACCENT       96  /* ` */
-#define GLFW_KEY_WORLD_1            161 /* non-US #1 */
-#define GLFW_KEY_WORLD_2            162 /* non-US #2 */
-
-/* Function keys */
-#define GLFW_KEY_ESCAPE             256
-#define GLFW_KEY_ENTER              257
-#define GLFW_KEY_TAB                258
-#define GLFW_KEY_BACKSPACE          259
-#define GLFW_KEY_INSERT             260
-#define GLFW_KEY_DELETE             261
-#define GLFW_KEY_RIGHT              262
-#define GLFW_KEY_LEFT               263
-#define GLFW_KEY_DOWN               264
-#define GLFW_KEY_UP                 265
-#define GLFW_KEY_PAGE_UP            266
-#define GLFW_KEY_PAGE_DOWN          267
-#define GLFW_KEY_HOME               268
-#define GLFW_KEY_END                269
-#define GLFW_KEY_CAPS_LOCK          280
-#define GLFW_KEY_SCROLL_LOCK        281
-#define GLFW_KEY_NUM_LOCK           282
-#define GLFW_KEY_PRINT_SCREEN       283
-#define GLFW_KEY_PAUSE              284
-#define GLFW_KEY_F1                 290
-#define GLFW_KEY_F2                 291
-#define GLFW_KEY_F3                 292
-#define GLFW_KEY_F4                 293
-#define GLFW_KEY_F5                 294
-#define GLFW_KEY_F6                 295
-#define GLFW_KEY_F7                 296
-#define GLFW_KEY_F8                 297
-#define GLFW_KEY_F9                 298
-#define GLFW_KEY_F10                299
-#define GLFW_KEY_F11                300
-#define GLFW_KEY_F12                301
-#define GLFW_KEY_F13                302
-#define GLFW_KEY_F14                303
-#define GLFW_KEY_F15                304
-#define GLFW_KEY_F16                305
-#define GLFW_KEY_F17                306
-#define GLFW_KEY_F18                307
-#define GLFW_KEY_F19                308
-#define GLFW_KEY_F20                309
-#define GLFW_KEY_F21                310
-#define GLFW_KEY_F22                311
-#define GLFW_KEY_F23                312
-#define GLFW_KEY_F24                313
-#define GLFW_KEY_F25                314
-#define GLFW_KEY_KP_0               320
-#define GLFW_KEY_KP_1               321
-#define GLFW_KEY_KP_2               322
-#define GLFW_KEY_KP_3               323
-#define GLFW_KEY_KP_4               324
-#define GLFW_KEY_KP_5               325
-#define GLFW_KEY_KP_6               326
-#define GLFW_KEY_KP_7               327
-#define GLFW_KEY_KP_8               328
-#define GLFW_KEY_KP_9               329
-#define GLFW_KEY_KP_DECIMAL         330
-#define GLFW_KEY_KP_DIVIDE          331
-#define GLFW_KEY_KP_MULTIPLY        332
-#define GLFW_KEY_KP_SUBTRACT        333
-#define GLFW_KEY_KP_ADD             334
-#define GLFW_KEY_KP_ENTER           335
-#define GLFW_KEY_KP_EQUAL           336
-#define GLFW_KEY_LEFT_SHIFT         340
-#define GLFW_KEY_LEFT_CONTROL       341
-#define GLFW_KEY_LEFT_ALT           342
-#define GLFW_KEY_LEFT_SUPER         343
-#define GLFW_KEY_RIGHT_SHIFT        344
-#define GLFW_KEY_RIGHT_CONTROL      345
-#define GLFW_KEY_RIGHT_ALT          346
-#define GLFW_KEY_RIGHT_SUPER        347
-#define GLFW_KEY_MENU               348
-
-#define GLFW_KEY_LAST               GLFW_KEY_MENU
-
-/*! @} */
-
-/*! @defgroup mods Modifier key flags
- *  @brief Modifier key flags.
- *
- *  See [key input](@ref input_key) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-
-/*! @brief If this bit is set one or more Shift keys were held down.
- *
- *  If this bit is set one or more Shift keys were held down.
- */
-#define GLFW_MOD_SHIFT           0x0001
-/*! @brief If this bit is set one or more Control keys were held down.
- *
- *  If this bit is set one or more Control keys were held down.
- */
-#define GLFW_MOD_CONTROL         0x0002
-/*! @brief If this bit is set one or more Alt keys were held down.
- *
- *  If this bit is set one or more Alt keys were held down.
- */
-#define GLFW_MOD_ALT             0x0004
-/*! @brief If this bit is set one or more Super keys were held down.
- *
- *  If this bit is set one or more Super keys were held down.
- */
-#define GLFW_MOD_SUPER           0x0008
-/*! @brief If this bit is set the Caps Lock key is enabled.
- *
- *  If this bit is set the Caps Lock key is enabled and the @ref
- *  GLFW_LOCK_KEY_MODS input mode is set.
- */
-#define GLFW_MOD_CAPS_LOCK       0x0010
-/*! @brief If this bit is set the Num Lock key is enabled.
- *
- *  If this bit is set the Num Lock key is enabled and the @ref
- *  GLFW_LOCK_KEY_MODS input mode is set.
- */
-#define GLFW_MOD_NUM_LOCK        0x0020
-
-/*! @} */
-
-/*! @defgroup buttons Mouse buttons
- *  @brief Mouse button IDs.
- *
- *  See [mouse button input](@ref input_mouse_button) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_MOUSE_BUTTON_1         0
-#define GLFW_MOUSE_BUTTON_2         1
-#define GLFW_MOUSE_BUTTON_3         2
-#define GLFW_MOUSE_BUTTON_4         3
-#define GLFW_MOUSE_BUTTON_5         4
-#define GLFW_MOUSE_BUTTON_6         5
-#define GLFW_MOUSE_BUTTON_7         6
-#define GLFW_MOUSE_BUTTON_8         7
-#define GLFW_MOUSE_BUTTON_LAST      GLFW_MOUSE_BUTTON_8
-#define GLFW_MOUSE_BUTTON_LEFT      GLFW_MOUSE_BUTTON_1
-#define GLFW_MOUSE_BUTTON_RIGHT     GLFW_MOUSE_BUTTON_2
-#define GLFW_MOUSE_BUTTON_MIDDLE    GLFW_MOUSE_BUTTON_3
-/*! @} */
-
-/*! @defgroup joysticks Joysticks
- *  @brief Joystick IDs.
- *
- *  See [joystick input](@ref joystick) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_JOYSTICK_1             0
-#define GLFW_JOYSTICK_2             1
-#define GLFW_JOYSTICK_3             2
-#define GLFW_JOYSTICK_4             3
-#define GLFW_JOYSTICK_5             4
-#define GLFW_JOYSTICK_6             5
-#define GLFW_JOYSTICK_7             6
-#define GLFW_JOYSTICK_8             7
-#define GLFW_JOYSTICK_9             8
-#define GLFW_JOYSTICK_10            9
-#define GLFW_JOYSTICK_11            10
-#define GLFW_JOYSTICK_12            11
-#define GLFW_JOYSTICK_13            12
-#define GLFW_JOYSTICK_14            13
-#define GLFW_JOYSTICK_15            14
-#define GLFW_JOYSTICK_16            15
-#define GLFW_JOYSTICK_LAST          GLFW_JOYSTICK_16
-/*! @} */
-
-/*! @defgroup gamepad_buttons Gamepad buttons
- *  @brief Gamepad buttons.
- *
- *  See @ref gamepad for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_GAMEPAD_BUTTON_A               0
-#define GLFW_GAMEPAD_BUTTON_B               1
-#define GLFW_GAMEPAD_BUTTON_X               2
-#define GLFW_GAMEPAD_BUTTON_Y               3
-#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER     4
-#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER    5
-#define GLFW_GAMEPAD_BUTTON_BACK            6
-#define GLFW_GAMEPAD_BUTTON_START           7
-#define GLFW_GAMEPAD_BUTTON_GUIDE           8
-#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB      9
-#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB     10
-#define GLFW_GAMEPAD_BUTTON_DPAD_UP         11
-#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT      12
-#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN       13
-#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT       14
-#define GLFW_GAMEPAD_BUTTON_LAST            GLFW_GAMEPAD_BUTTON_DPAD_LEFT
-
-#define GLFW_GAMEPAD_BUTTON_CROSS       GLFW_GAMEPAD_BUTTON_A
-#define GLFW_GAMEPAD_BUTTON_CIRCLE      GLFW_GAMEPAD_BUTTON_B
-#define GLFW_GAMEPAD_BUTTON_SQUARE      GLFW_GAMEPAD_BUTTON_X
-#define GLFW_GAMEPAD_BUTTON_TRIANGLE    GLFW_GAMEPAD_BUTTON_Y
-/*! @} */
-
-/*! @defgroup gamepad_axes Gamepad axes
- *  @brief Gamepad axes.
- *
- *  See @ref gamepad for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_GAMEPAD_AXIS_LEFT_X        0
-#define GLFW_GAMEPAD_AXIS_LEFT_Y        1
-#define GLFW_GAMEPAD_AXIS_RIGHT_X       2
-#define GLFW_GAMEPAD_AXIS_RIGHT_Y       3
-#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER  4
-#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
-#define GLFW_GAMEPAD_AXIS_LAST          GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
-/*! @} */
-
-/*! @defgroup errors Error codes
- *  @brief Error codes.
- *
- *  See [error handling](@ref error_handling) for how these are used.
- *
- *  @ingroup init
- *  @{ */
-/*! @brief No error has occurred.
- *
- *  No error has occurred.
- *
- *  @analysis Yay.
- */
-#define GLFW_NO_ERROR               0
-/*! @brief GLFW has not been initialized.
- *
- *  This occurs if a GLFW function was called that must not be called unless the
- *  library is [initialized](@ref intro_init).
- *
- *  @analysis Application programmer error.  Initialize GLFW before calling any
- *  function that requires initialization.
- */
-#define GLFW_NOT_INITIALIZED        0x00010001
-/*! @brief No context is current for this thread.
- *
- *  This occurs if a GLFW function was called that needs and operates on the
- *  current OpenGL or OpenGL ES context but no context is current on the calling
- *  thread.  One such function is @ref glfwSwapInterval.
- *
- *  @analysis Application programmer error.  Ensure a context is current before
- *  calling functions that require a current context.
- */
-#define GLFW_NO_CURRENT_CONTEXT     0x00010002
-/*! @brief One of the arguments to the function was an invalid enum value.
- *
- *  One of the arguments to the function was an invalid enum value, for example
- *  requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_INVALID_ENUM           0x00010003
-/*! @brief One of the arguments to the function was an invalid value.
- *
- *  One of the arguments to the function was an invalid value, for example
- *  requesting a non-existent OpenGL or OpenGL ES version like 2.7.
- *
- *  Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
- *  result in a @ref GLFW_VERSION_UNAVAILABLE error.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_INVALID_VALUE          0x00010004
-/*! @brief A memory allocation failed.
- *
- *  A memory allocation failed.
- *
- *  @analysis A bug in GLFW or the underlying operating system.  Report the bug
- *  to our [issue tracker](https://github.com/glfw/glfw/issues).
- */
-#define GLFW_OUT_OF_MEMORY          0x00010005
-/*! @brief GLFW could not find support for the requested API on the system.
- *
- *  GLFW could not find support for the requested API on the system.
- *
- *  @analysis The installed graphics driver does not support the requested
- *  API, or does not support it via the chosen context creation backend.
- *  Below are a few examples.
- *
- *  @par
- *  Some pre-installed Windows graphics drivers do not support OpenGL.  AMD only
- *  supports OpenGL ES via EGL, while Nvidia and Intel only support it via
- *  a WGL or GLX extension.  macOS does not provide OpenGL ES at all.  The Mesa
- *  EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
- *  driver.  Older graphics drivers do not support Vulkan.
- */
-#define GLFW_API_UNAVAILABLE        0x00010006
-/*! @brief The requested OpenGL or OpenGL ES version is not available.
- *
- *  The requested OpenGL or OpenGL ES version (including any requested context
- *  or framebuffer hints) is not available on this machine.
- *
- *  @analysis The machine does not support your requirements.  If your
- *  application is sufficiently flexible, downgrade your requirements and try
- *  again.  Otherwise, inform the user that their machine does not match your
- *  requirements.
- *
- *  @par
- *  Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
- *  comes out before the 4.x series gets that far, also fail with this error and
- *  not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
- *  will exist.
- */
-#define GLFW_VERSION_UNAVAILABLE    0x00010007
-/*! @brief A platform-specific error occurred that does not match any of the
- *  more specific categories.
- *
- *  A platform-specific error occurred that does not match any of the more
- *  specific categories.
- *
- *  @analysis A bug or configuration error in GLFW, the underlying operating
- *  system or its drivers, or a lack of required resources.  Report the issue to
- *  our [issue tracker](https://github.com/glfw/glfw/issues).
- */
-#define GLFW_PLATFORM_ERROR         0x00010008
-/*! @brief The requested format is not supported or available.
- *
- *  If emitted during window creation, the requested pixel format is not
- *  supported.
- *
- *  If emitted when querying the clipboard, the contents of the clipboard could
- *  not be converted to the requested format.
- *
- *  @analysis If emitted during window creation, one or more
- *  [hard constraints](@ref window_hints_hard) did not match any of the
- *  available pixel formats.  If your application is sufficiently flexible,
- *  downgrade your requirements and try again.  Otherwise, inform the user that
- *  their machine does not match your requirements.
- *
- *  @par
- *  If emitted when querying the clipboard, ignore the error or report it to
- *  the user, as appropriate.
- */
-#define GLFW_FORMAT_UNAVAILABLE     0x00010009
-/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
- *
- *  A window that does not have an OpenGL or OpenGL ES context was passed to
- *  a function that requires it to have one.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_NO_WINDOW_CONTEXT      0x0001000A
-/*! @brief The specified cursor shape is not available.
- *
- *  The specified standard cursor shape is not available, either because the
- *  current system cursor theme does not provide it or because it is not
- *  available on the platform.
- *
- *  @analysis Platform or system settings limitation.  Pick another
- *  [standard cursor shape](@ref shapes) or create a
- *  [custom cursor](@ref cursor_custom).
- */
-#define GLFW_CURSOR_UNAVAILABLE     0x0001000B
-/*! @brief The requested feature is not provided by the platform.
- *
- *  The requested feature is not provided by the platform, so GLFW is unable to
- *  implement it.  The documentation for each function notes if it could emit
- *  this error.
- *
- *  @analysis Platform or platform version limitation.  The error can be ignored
- *  unless the feature is critical to the application.
- *
- *  @par
- *  A function call that emits this error has no effect other than the error and
- *  updating any existing out parameters.
- */
-#define GLFW_FEATURE_UNAVAILABLE    0x0001000C
-/*! @brief The requested feature is not implemented for the platform.
- *
- *  The requested feature has not yet been implemented in GLFW for this platform.
- *
- *  @analysis An incomplete implementation of GLFW for this platform, hopefully
- *  fixed in a future release.  The error can be ignored unless the feature is
- *  critical to the application.
- *
- *  @par
- *  A function call that emits this error has no effect other than the error and
- *  updating any existing out parameters.
- */
-#define GLFW_FEATURE_UNIMPLEMENTED  0x0001000D
-/*! @} */
-
-/*! @addtogroup window
- *  @{ */
-/*! @brief Input focus window hint and attribute
- *
- *  Input focus [window hint](@ref GLFW_FOCUSED_hint) or
- *  [window attribute](@ref GLFW_FOCUSED_attrib).
- */
-#define GLFW_FOCUSED                0x00020001
-/*! @brief Window iconification window attribute
- *
- *  Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
- */
-#define GLFW_ICONIFIED              0x00020002
-/*! @brief Window resize-ability window hint and attribute
- *
- *  Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
- *  [window attribute](@ref GLFW_RESIZABLE_attrib).
- */
-#define GLFW_RESIZABLE              0x00020003
-/*! @brief Window visibility window hint and attribute
- *
- *  Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
- *  [window attribute](@ref GLFW_VISIBLE_attrib).
- */
-#define GLFW_VISIBLE                0x00020004
-/*! @brief Window decoration window hint and attribute
- *
- *  Window decoration [window hint](@ref GLFW_DECORATED_hint) and
- *  [window attribute](@ref GLFW_DECORATED_attrib).
- */
-#define GLFW_DECORATED              0x00020005
-/*! @brief Window auto-iconification window hint and attribute
- *
- *  Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
- *  [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
- */
-#define GLFW_AUTO_ICONIFY           0x00020006
-/*! @brief Window decoration window hint and attribute
- *
- *  Window decoration [window hint](@ref GLFW_FLOATING_hint) and
- *  [window attribute](@ref GLFW_FLOATING_attrib).
- */
-#define GLFW_FLOATING               0x00020007
-/*! @brief Window maximization window hint and attribute
- *
- *  Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
- *  [window attribute](@ref GLFW_MAXIMIZED_attrib).
- */
-#define GLFW_MAXIMIZED              0x00020008
-/*! @brief Cursor centering window hint
- *
- *  Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
- */
-#define GLFW_CENTER_CURSOR          0x00020009
-/*! @brief Window framebuffer transparency hint and attribute
- *
- *  Window framebuffer transparency
- *  [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
- *  [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
- */
-#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
-/*! @brief Mouse cursor hover window attribute.
- *
- *  Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
- */
-#define GLFW_HOVERED                0x0002000B
-/*! @brief Input focus on calling show window hint and attribute
- *
- *  Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
- *  [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
- */
-#define GLFW_FOCUS_ON_SHOW          0x0002000C
-
-/*! @brief Mouse input transparency window hint and attribute
- *
- *  Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
- *  [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
- */
-#define GLFW_MOUSE_PASSTHROUGH      0x0002000D
-
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
- */
-#define GLFW_RED_BITS               0x00021001
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
- */
-#define GLFW_GREEN_BITS             0x00021002
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
- */
-#define GLFW_BLUE_BITS              0x00021003
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
- */
-#define GLFW_ALPHA_BITS             0x00021004
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
- */
-#define GLFW_DEPTH_BITS             0x00021005
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
- */
-#define GLFW_STENCIL_BITS           0x00021006
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
- */
-#define GLFW_ACCUM_RED_BITS         0x00021007
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
- */
-#define GLFW_ACCUM_GREEN_BITS       0x00021008
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
- */
-#define GLFW_ACCUM_BLUE_BITS        0x00021009
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
- */
-#define GLFW_ACCUM_ALPHA_BITS       0x0002100A
-/*! @brief Framebuffer auxiliary buffer hint.
- *
- *  Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
- */
-#define GLFW_AUX_BUFFERS            0x0002100B
-/*! @brief OpenGL stereoscopic rendering hint.
- *
- *  OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
- */
-#define GLFW_STEREO                 0x0002100C
-/*! @brief Framebuffer MSAA samples hint.
- *
- *  Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
- */
-#define GLFW_SAMPLES                0x0002100D
-/*! @brief Framebuffer sRGB hint.
- *
- *  Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
- */
-#define GLFW_SRGB_CAPABLE           0x0002100E
-/*! @brief Monitor refresh rate hint.
- *
- *  Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
- */
-#define GLFW_REFRESH_RATE           0x0002100F
-/*! @brief Framebuffer double buffering hint.
- *
- *  Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
- */
-#define GLFW_DOUBLEBUFFER           0x00021010
-
-/*! @brief Context client API hint and attribute.
- *
- *  Context client API [hint](@ref GLFW_CLIENT_API_hint) and
- *  [attribute](@ref GLFW_CLIENT_API_attrib).
- */
-#define GLFW_CLIENT_API             0x00022001
-/*! @brief Context client API major version hint and attribute.
- *
- *  Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
- *  and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
- */
-#define GLFW_CONTEXT_VERSION_MAJOR  0x00022002
-/*! @brief Context client API minor version hint and attribute.
- *
- *  Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
- *  and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
- */
-#define GLFW_CONTEXT_VERSION_MINOR  0x00022003
-/*! @brief Context client API revision number hint and attribute.
- *
- *  Context client API revision number
- *  [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
- */
-#define GLFW_CONTEXT_REVISION       0x00022004
-/*! @brief Context robustness hint and attribute.
- *
- *  Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
- *  and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
- */
-#define GLFW_CONTEXT_ROBUSTNESS     0x00022005
-/*! @brief OpenGL forward-compatibility hint and attribute.
- *
- *  OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
- *  and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
- */
-#define GLFW_OPENGL_FORWARD_COMPAT  0x00022006
-/*! @brief Debug mode context hint and attribute.
- *
- *  Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
- *  [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
- */
-#define GLFW_CONTEXT_DEBUG          0x00022007
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_OPENGL_DEBUG_CONTEXT   GLFW_CONTEXT_DEBUG
-/*! @brief OpenGL profile hint and attribute.
- *
- *  OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
- *  [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
- */
-#define GLFW_OPENGL_PROFILE         0x00022008
-/*! @brief Context flush-on-release hint and attribute.
- *
- *  Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
- *  [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
- */
-#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
-/*! @brief Context error suppression hint and attribute.
- *
- *  Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
- *  [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
- */
-#define GLFW_CONTEXT_NO_ERROR       0x0002200A
-/*! @brief Context creation API hint and attribute.
- *
- *  Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
- *  [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
- */
-#define GLFW_CONTEXT_CREATION_API   0x0002200B
-/*! @brief Window content area scaling window
- *  [window hint](@ref GLFW_SCALE_TO_MONITOR).
- */
-#define GLFW_SCALE_TO_MONITOR       0x0002200C
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
- */
-#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
- */
-#define GLFW_COCOA_FRAME_NAME         0x00023002
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
- */
-#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
-/*! @brief X11 specific
- *  [window hint](@ref GLFW_X11_CLASS_NAME_hint).
- */
-#define GLFW_X11_CLASS_NAME         0x00024001
-/*! @brief X11 specific
- *  [window hint](@ref GLFW_X11_CLASS_NAME_hint).
- */
-#define GLFW_X11_INSTANCE_NAME      0x00024002
-#define GLFW_WIN32_KEYBOARD_MENU    0x00025001
-/*! @} */
-
-#define GLFW_NO_API                          0
-#define GLFW_OPENGL_API             0x00030001
-#define GLFW_OPENGL_ES_API          0x00030002
-
-#define GLFW_NO_ROBUSTNESS                   0
-#define GLFW_NO_RESET_NOTIFICATION  0x00031001
-#define GLFW_LOSE_CONTEXT_ON_RESET  0x00031002
-
-#define GLFW_OPENGL_ANY_PROFILE              0
-#define GLFW_OPENGL_CORE_PROFILE    0x00032001
-#define GLFW_OPENGL_COMPAT_PROFILE  0x00032002
-
-#define GLFW_CURSOR                 0x00033001
-#define GLFW_STICKY_KEYS            0x00033002
-#define GLFW_STICKY_MOUSE_BUTTONS   0x00033003
-#define GLFW_LOCK_KEY_MODS          0x00033004
-#define GLFW_RAW_MOUSE_MOTION       0x00033005
-
-#define GLFW_CURSOR_NORMAL          0x00034001
-#define GLFW_CURSOR_HIDDEN          0x00034002
-#define GLFW_CURSOR_DISABLED        0x00034003
-
-#define GLFW_ANY_RELEASE_BEHAVIOR            0
-#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
-#define GLFW_RELEASE_BEHAVIOR_NONE  0x00035002
-
-#define GLFW_NATIVE_CONTEXT_API     0x00036001
-#define GLFW_EGL_CONTEXT_API        0x00036002
-#define GLFW_OSMESA_CONTEXT_API     0x00036003
-
-#define GLFW_ANGLE_PLATFORM_TYPE_NONE    0x00037001
-#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL  0x00037002
-#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
-#define GLFW_ANGLE_PLATFORM_TYPE_D3D9    0x00037004
-#define GLFW_ANGLE_PLATFORM_TYPE_D3D11   0x00037005
-#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN  0x00037007
-#define GLFW_ANGLE_PLATFORM_TYPE_METAL   0x00037008
-
-/*! @defgroup shapes Standard cursor shapes
- *  @brief Standard system cursor shapes.
- *
- *  These are the [standard cursor shapes](@ref cursor_standard) that can be
- *  requested from the window system.
- *
- *  @ingroup input
- *  @{ */
-
-/*! @brief The regular arrow cursor shape.
- *
- *  The regular arrow cursor shape.
- */
-#define GLFW_ARROW_CURSOR           0x00036001
-/*! @brief The text input I-beam cursor shape.
- *
- *  The text input I-beam cursor shape.
- */
-#define GLFW_IBEAM_CURSOR           0x00036002
-/*! @brief The crosshair cursor shape.
- *
- *  The crosshair cursor shape.
- */
-#define GLFW_CROSSHAIR_CURSOR       0x00036003
-/*! @brief The pointing hand cursor shape.
- *
- *  The pointing hand cursor shape.
- */
-#define GLFW_POINTING_HAND_CURSOR   0x00036004
-/*! @brief The horizontal resize/move arrow shape.
- *
- *  The horizontal resize/move arrow shape.  This is usually a horizontal
- *  double-headed arrow.
- */
-#define GLFW_RESIZE_EW_CURSOR       0x00036005
-/*! @brief The vertical resize/move arrow shape.
- *
- *  The vertical resize/move shape.  This is usually a vertical double-headed
- *  arrow.
- */
-#define GLFW_RESIZE_NS_CURSOR       0x00036006
-/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
- *
- *  The top-left to bottom-right diagonal resize/move shape.  This is usually
- *  a diagonal double-headed arrow.
- *
- *  @note @macos This shape is provided by a private system API and may fail
- *  with @ref GLFW_CURSOR_UNAVAILABLE in the future.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_RESIZE_NWSE_CURSOR     0x00036007
-/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
- *
- *  The top-right to bottom-left diagonal resize/move shape.  This is usually
- *  a diagonal double-headed arrow.
- *
- *  @note @macos This shape is provided by a private system API and may fail
- *  with @ref GLFW_CURSOR_UNAVAILABLE in the future.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_RESIZE_NESW_CURSOR     0x00036008
-/*! @brief The omni-directional resize/move cursor shape.
- *
- *  The omni-directional resize cursor/move shape.  This is usually either
- *  a combined horizontal and vertical double-headed arrow or a grabbing hand.
- */
-#define GLFW_RESIZE_ALL_CURSOR      0x00036009
-/*! @brief The operation-not-allowed shape.
- *
- *  The operation-not-allowed shape.  This is usually a circle with a diagonal
- *  line through it.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_NOT_ALLOWED_CURSOR     0x0003600A
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_HRESIZE_CURSOR         GLFW_RESIZE_EW_CURSOR
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_VRESIZE_CURSOR         GLFW_RESIZE_NS_CURSOR
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_HAND_CURSOR            GLFW_POINTING_HAND_CURSOR
-/*! @} */
-
-#define GLFW_CONNECTED              0x00040001
-#define GLFW_DISCONNECTED           0x00040002
-
-/*! @addtogroup init
- *  @{ */
-/*! @brief Joystick hat buttons init hint.
- *
- *  Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
- */
-#define GLFW_JOYSTICK_HAT_BUTTONS   0x00050001
-/*! @brief ANGLE rendering backend init hint.
- *
- *  ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
- */
-#define GLFW_ANGLE_PLATFORM_TYPE    0x00050002
-/*! @brief macOS specific init hint.
- *
- *  macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
- */
-#define GLFW_COCOA_CHDIR_RESOURCES  0x00051001
-/*! @brief macOS specific init hint.
- *
- *  macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
- */
-#define GLFW_COCOA_MENUBAR          0x00051002
-/*! @} */
-
-#define GLFW_DONT_CARE              -1
-
-
-/*************************************************************************
- * GLFW API types
- *************************************************************************/
-
-/*! @brief Client API function pointer type.
- *
- *  Generic function pointer used for returning client API function pointers
- *  without forcing a cast from a regular pointer.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwGetProcAddress
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-typedef void (*GLFWglproc)(void);
-
-/*! @brief Vulkan API function pointer type.
- *
- *  Generic function pointer used for returning Vulkan API function pointers
- *  without forcing a cast from a regular pointer.
- *
- *  @sa @ref vulkan_proc
- *  @sa @ref glfwGetInstanceProcAddress
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-typedef void (*GLFWvkproc)(void);
-
-/*! @brief Opaque monitor object.
- *
- *  Opaque monitor object.
- *
- *  @see @ref monitor_object
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWmonitor GLFWmonitor;
-
-/*! @brief Opaque window object.
- *
- *  Opaque window object.
- *
- *  @see @ref window_object
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef struct GLFWwindow GLFWwindow;
-
-/*! @brief Opaque cursor object.
- *
- *  Opaque cursor object.
- *
- *  @see @ref cursor_object
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef struct GLFWcursor GLFWcursor;
-
-/*! @brief The function pointer type for error callbacks.
- *
- *  This is the function pointer type for error callbacks.  An error callback
- *  function has the following signature:
- *  @code
- *  void callback_name(int error_code, const char* description)
- *  @endcode
- *
- *  @param[in] error_code An [error code](@ref errors).  Future releases may add
- *  more error codes.
- *  @param[in] description A UTF-8 encoded string describing the error.
- *
- *  @pointer_lifetime The error description string is valid until the callback
- *  function returns.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwSetErrorCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-typedef void (* GLFWerrorfun)(int,const char*);
-
-/*! @brief The function pointer type for window position callbacks.
- *
- *  This is the function pointer type for window position callbacks.  A window
- *  position callback function has the following signature:
- *  @code
- *  void callback_name(GLFWwindow* window, int xpos, int ypos)
- *  @endcode
- *
- *  @param[in] window The window that was moved.
- *  @param[in] xpos The new x-coordinate, in screen coordinates, of the
- *  upper-left corner of the content area of the window.
- *  @param[in] ypos The new y-coordinate, in screen coordinates, of the
- *  upper-left corner of the content area of the window.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwSetWindowPosCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window size callbacks.
- *
- *  This is the function pointer type for window size callbacks.  A window size
- *  callback function has the following signature:
- *  @code
- *  void callback_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *
- *  @param[in] window The window that was resized.
- *  @param[in] width The new width, in screen coordinates, of the window.
- *  @param[in] height The new height, in screen coordinates, of the window.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwSetWindowSizeCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window close callbacks.
- *
- *  This is the function pointer type for window close callbacks.  A window
- *  close callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window)
- *  @endcode
- *
- *  @param[in] window The window that the user attempted to close.
- *
- *  @sa @ref window_close
- *  @sa @ref glfwSetWindowCloseCallback
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowclosefun)(GLFWwindow*);
-
-/*! @brief The function pointer type for window content refresh callbacks.
- *
- *  This is the function pointer type for window content refresh callbacks.
- *  A window content refresh callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window);
- *  @endcode
- *
- *  @param[in] window The window whose content needs to be refreshed.
- *
- *  @sa @ref window_refresh
- *  @sa @ref glfwSetWindowRefreshCallback
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
-
-/*! @brief The function pointer type for window focus callbacks.
- *
- *  This is the function pointer type for window focus callbacks.  A window
- *  focus callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int focused)
- *  @endcode
- *
- *  @param[in] window The window that gained or lost input focus.
- *  @param[in] focused `GLFW_TRUE` if the window was given input focus, or
- *  `GLFW_FALSE` if it lost it.
- *
- *  @sa @ref window_focus
- *  @sa @ref glfwSetWindowFocusCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for window iconify callbacks.
- *
- *  This is the function pointer type for window iconify callbacks.  A window
- *  iconify callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int iconified)
- *  @endcode
- *
- *  @param[in] window The window that was iconified or restored.
- *  @param[in] iconified `GLFW_TRUE` if the window was iconified, or
- *  `GLFW_FALSE` if it was restored.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwSetWindowIconifyCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for window maximize callbacks.
- *
- *  This is the function pointer type for window maximize callbacks.  A window
- *  maximize callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int maximized)
- *  @endcode
- *
- *  @param[in] window The window that was maximized or restored.
- *  @param[in] maximized `GLFW_TRUE` if the window was maximized, or
- *  `GLFW_FALSE` if it was restored.
- *
- *  @sa @ref window_maximize
- *  @sa glfwSetWindowMaximizeCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for framebuffer size callbacks.
- *
- *  This is the function pointer type for framebuffer size callbacks.
- *  A framebuffer size callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *
- *  @param[in] window The window whose framebuffer was resized.
- *  @param[in] width The new width, in pixels, of the framebuffer.
- *  @param[in] height The new height, in pixels, of the framebuffer.
- *
- *  @sa @ref window_fbsize
- *  @sa @ref glfwSetFramebufferSizeCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window content scale callbacks.
- *
- *  This is the function pointer type for window content scale callbacks.
- *  A window content scale callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, float xscale, float yscale)
- *  @endcode
- *
- *  @param[in] window The window whose content scale changed.
- *  @param[in] xscale The new x-axis content scale of the window.
- *  @param[in] yscale The new y-axis content scale of the window.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwSetWindowContentScaleCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
-
-/*! @brief The function pointer type for mouse button callbacks.
- *
- *  This is the function pointer type for mouse button callback functions.
- *  A mouse button callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int button, int action, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] button The [mouse button](@ref buttons) that was pressed or
- *  released.
- *  @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.  Future releases
- *  may add more actions.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_mouse_button
- *  @sa @ref glfwSetMouseButtonCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle and modifier mask parameters.
- *
- *  @ingroup input
- */
-typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
-
-/*! @brief The function pointer type for cursor position callbacks.
- *
- *  This is the function pointer type for cursor position callbacks.  A cursor
- *  position callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, double xpos, double ypos);
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] xpos The new cursor x-coordinate, relative to the left edge of
- *  the content area.
- *  @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
- *  content area.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwSetCursorPosCallback
- *
- *  @since Added in version 3.0.  Replaces `GLFWmouseposfun`.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
-
-/*! @brief The function pointer type for cursor enter/leave callbacks.
- *
- *  This is the function pointer type for cursor enter/leave callbacks.
- *  A cursor enter/leave callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int entered)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
- *  area, or `GLFW_FALSE` if it left it.
- *
- *  @sa @ref cursor_enter
- *  @sa @ref glfwSetCursorEnterCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for scroll callbacks.
- *
- *  This is the function pointer type for scroll callbacks.  A scroll callback
- *  function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, double xoffset, double yoffset)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] xoffset The scroll offset along the x-axis.
- *  @param[in] yoffset The scroll offset along the y-axis.
- *
- *  @sa @ref scrolling
- *  @sa @ref glfwSetScrollCallback
- *
- *  @since Added in version 3.0.  Replaces `GLFWmousewheelfun`.
- *
- *  @ingroup input
- */
-typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
-
-/*! @brief The function pointer type for keyboard key callbacks.
- *
- *  This is the function pointer type for keyboard key callbacks.  A keyboard
- *  key callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] key The [keyboard key](@ref keys) that was pressed or released.
- *  @param[in] scancode The system-specific scancode of the key.
- *  @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.  Future
- *  releases may add more actions.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_key
- *  @sa @ref glfwSetKeyCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle, scancode and modifier mask parameters.
- *
- *  @ingroup input
- */
-typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
-
-/*! @brief The function pointer type for Unicode character callbacks.
- *
- *  This is the function pointer type for Unicode character callbacks.
- *  A Unicode character callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] codepoint The Unicode code point of the character.
- *
- *  @sa @ref input_char
- *  @sa @ref glfwSetCharCallback
- *
- *  @since Added in version 2.4.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
-
-/*! @brief The function pointer type for Unicode character with modifiers
- *  callbacks.
- *
- *  This is the function pointer type for Unicode character with modifiers
- *  callbacks.  It is called for each input character, regardless of what
- *  modifier keys are held down.  A Unicode character with modifiers callback
- *  function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] codepoint The Unicode code point of the character.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_char
- *  @sa @ref glfwSetCharModsCallback
- *
- *  @deprecated Scheduled for removal in version 4.0.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
-
-/*! @brief The function pointer type for path drop callbacks.
- *
- *  This is the function pointer type for path drop callbacks.  A path drop
- *  callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int path_count, const char* paths[])
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] path_count The number of dropped paths.
- *  @param[in] paths The UTF-8 encoded file and/or directory path names.
- *
- *  @pointer_lifetime The path array and its strings are valid until the
- *  callback function returns.
- *
- *  @sa @ref path_drop
- *  @sa @ref glfwSetDropCallback
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
-
-/*! @brief The function pointer type for monitor configuration callbacks.
- *
- *  This is the function pointer type for monitor configuration callbacks.
- *  A monitor callback function has the following signature:
- *  @code
- *  void function_name(GLFWmonitor* monitor, int event)
- *  @endcode
- *
- *  @param[in] monitor The monitor that was connected or disconnected.
- *  @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.  Future
- *  releases may add more events.
- *
- *  @sa @ref monitor_event
- *  @sa @ref glfwSetMonitorCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
-
-/*! @brief The function pointer type for joystick configuration callbacks.
- *
- *  This is the function pointer type for joystick configuration callbacks.
- *  A joystick configuration callback function has the following signature:
- *  @code
- *  void function_name(int jid, int event)
- *  @endcode
- *
- *  @param[in] jid The joystick that was connected or disconnected.
- *  @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.  Future
- *  releases may add more events.
- *
- *  @sa @ref joystick_event
- *  @sa @ref glfwSetJoystickCallback
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-typedef void (* GLFWjoystickfun)(int,int);
-
-/*! @brief Video mode type.
- *
- *  This describes a single video mode.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoMode
- *  @sa @ref glfwGetVideoModes
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added refresh rate member.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWvidmode
-{
-    /*! The width, in screen coordinates, of the video mode.
-     */
-    int width;
-    /*! The height, in screen coordinates, of the video mode.
-     */
-    int height;
-    /*! The bit depth of the red channel of the video mode.
-     */
-    int redBits;
-    /*! The bit depth of the green channel of the video mode.
-     */
-    int greenBits;
-    /*! The bit depth of the blue channel of the video mode.
-     */
-    int blueBits;
-    /*! The refresh rate, in Hz, of the video mode.
-     */
-    int refreshRate;
-} GLFWvidmode;
-
-/*! @brief Gamma ramp.
- *
- *  This describes the gamma ramp for a monitor.
- *
- *  @sa @ref monitor_gamma
- *  @sa @ref glfwGetGammaRamp
- *  @sa @ref glfwSetGammaRamp
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWgammaramp
-{
-    /*! An array of value describing the response of the red channel.
-     */
-    unsigned short* red;
-    /*! An array of value describing the response of the green channel.
-     */
-    unsigned short* green;
-    /*! An array of value describing the response of the blue channel.
-     */
-    unsigned short* blue;
-    /*! The number of elements in each array.
-     */
-    unsigned int size;
-} GLFWgammaramp;
-
-/*! @brief Image data.
- *
- *  This describes a single 2D image.  See the documentation for each related
- *  function what the expected pixel format is.
- *
- *  @sa @ref cursor_custom
- *  @sa @ref window_icon
- *
- *  @since Added in version 2.1.
- *  @glfw3 Removed format and bytes-per-pixel members.
- *
- *  @ingroup window
- */
-typedef struct GLFWimage
-{
-    /*! The width, in pixels, of this image.
-     */
-    int width;
-    /*! The height, in pixels, of this image.
-     */
-    int height;
-    /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
-     */
-    unsigned char* pixels;
-} GLFWimage;
-
-/*! @brief Gamepad input state
- *
- *  This describes the input state of a gamepad.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwGetGamepadState
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-typedef struct GLFWgamepadstate
-{
-    /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
-     *  or `GLFW_RELEASE`.
-     */
-    unsigned char buttons[15];
-    /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
-     *  to 1.0 inclusive.
-     */
-    float axes[6];
-} GLFWgamepadstate;
-
-
-/*************************************************************************
- * GLFW API functions
- *************************************************************************/
-
-/*! @brief Initializes the GLFW library.
- *
- *  This function initializes the GLFW library.  Before most GLFW functions can
- *  be used, GLFW must be initialized, and before an application terminates GLFW
- *  should be terminated in order to free any resources allocated during or
- *  after initialization.
- *
- *  If this function fails, it calls @ref glfwTerminate before returning.  If it
- *  succeeds, you should call @ref glfwTerminate before the application exits.
- *
- *  Additional calls to this function after successful initialization but before
- *  termination will return `GLFW_TRUE` immediately.
- *
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos This function will change the current directory of the
- *  application to the `Contents/Resources` subdirectory of the application's
- *  bundle, if present.  This can be disabled with the @ref
- *  GLFW_COCOA_CHDIR_RESOURCES init hint.
- *
- *  @remark @macos This function will create the main menu and dock icon for the
- *  application.  If GLFW finds a `MainMenu.nib` it is loaded and assumed to
- *  contain a menu bar.  Otherwise a minimal menu bar is created manually with
- *  common commands like Hide, Quit and About.  The About entry opens a minimal
- *  about dialog with information from the application's bundle.  The menu bar
- *  and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
- *  hint.
- *
- *  @remark @x11 This function will set the `LC_CTYPE` category of the
- *  application locale according to the current environment if that category is
- *  still "C".  This is because the "C" locale breaks Unicode text input.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref intro_init
- *  @sa @ref glfwTerminate
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI int glfwInit(void);
-
-/*! @brief Terminates the GLFW library.
- *
- *  This function destroys all remaining windows and cursors, restores any
- *  modified gamma ramps and frees any other allocated resources.  Once this
- *  function is called, you must again call @ref glfwInit successfully before
- *  you will be able to use most GLFW functions.
- *
- *  If GLFW has been successfully initialized, this function should be called
- *  before the application exits.  If initialization fails, there is no need to
- *  call this function, as it is called by @ref glfwInit before it returns
- *  failure.
- *
- *  This function has no effect if GLFW is not initialized.
- *
- *  @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @warning The contexts of any remaining windows must not be current on any
- *  other thread when this function is called.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref intro_init
- *  @sa @ref glfwInit
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwTerminate(void);
-
-/*! @brief Sets the specified init hint to the desired value.
- *
- *  This function sets hints for the next initialization of GLFW.
- *
- *  The values you set hints to are never reset by GLFW, but they only take
- *  effect during initialization.  Once GLFW has been initialized, any values
- *  you set will be ignored until the library is terminated and initialized
- *  again.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [init hint](@ref init_hints) to set.
- *  @param[in] value The new value of the init hint.
- *
- *  @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @remarks This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa init_hints
- *  @sa glfwInit
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwInitHint(int hint, int value);
-
-/*! @brief Retrieves the version of the GLFW library.
- *
- *  This function retrieves the major, minor and revision numbers of the GLFW
- *  library.  It is intended for when you are using GLFW as a shared library and
- *  want to ensure that you are using the minimum required version.
- *
- *  Any or all of the version arguments may be `NULL`.
- *
- *  @param[out] major Where to store the major version number, or `NULL`.
- *  @param[out] minor Where to store the minor version number, or `NULL`.
- *  @param[out] rev Where to store the revision number, or `NULL`.
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref intro_version
- *  @sa @ref glfwGetVersionString
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
-
-/*! @brief Returns a string describing the compile-time configuration.
- *
- *  This function returns the compile-time generated
- *  [version string](@ref intro_version_string) of the GLFW library binary.  It
- *  describes the version, platform, compiler and any platform-specific
- *  compile-time options.  It should not be confused with the OpenGL or OpenGL
- *  ES version string, queried with `glGetString`.
- *
- *  __Do not use the version string__ to parse the GLFW library version.  The
- *  @ref glfwGetVersion function provides the version of the running library
- *  binary in numerical format.
- *
- *  @return The ASCII encoded GLFW version string.
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @pointer_lifetime The returned string is static and compile-time generated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref intro_version
- *  @sa @ref glfwGetVersion
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-GLFWAPI const char* glfwGetVersionString(void);
-
-/*! @brief Returns and clears the last error for the calling thread.
- *
- *  This function returns and clears the [error code](@ref errors) of the last
- *  error that occurred on the calling thread, and optionally a UTF-8 encoded
- *  human-readable description of it.  If no error has occurred since the last
- *  call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
- *  set to `NULL`.
- *
- *  @param[in] description Where to store the error description pointer, or `NULL`.
- *  @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
- *  (zero).
- *
- *  @errors None.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  next error occurs or the library is terminated.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwSetErrorCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup init
- */
-GLFWAPI int glfwGetError(const char** description);
-
-/*! @brief Sets the error callback.
- *
- *  This function sets the error callback, which is called with an error code
- *  and a human-readable description each time a GLFW error occurs.
- *
- *  The error code is set before the callback is called.  Calling @ref
- *  glfwGetError from the error callback will return the same value as the error
- *  code argument.
- *
- *  The error callback is called on the thread where the error occurred.  If you
- *  are using GLFW from multiple threads, your error callback needs to be
- *  written accordingly.
- *
- *  Because the description string may have been generated specifically for that
- *  error, it is not guaranteed to be valid after the callback has returned.  If
- *  you wish to use it after the callback returns, you need to make a copy.
- *
- *  Once set, the error callback remains set even after the library has been
- *  terminated.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set.
- *
- *  @callback_signature
- *  @code
- *  void callback_name(int error_code, const char* description)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [callback pointer type](@ref GLFWerrorfun).
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwGetError
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
-
-/*! @brief Returns the currently connected monitors.
- *
- *  This function returns an array of handles for all currently connected
- *  monitors.  The primary monitor is always first in the returned array.  If no
- *  monitors were found, this function returns `NULL`.
- *
- *  @param[out] count Where to store the number of monitors in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of monitor handles, or `NULL` if no monitors were found or
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  monitor configuration changes or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_monitors
- *  @sa @ref monitor_event
- *  @sa @ref glfwGetPrimaryMonitor
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
-
-/*! @brief Returns the primary monitor.
- *
- *  This function returns the primary monitor.  This is usually the monitor
- *  where elements like the task bar or global menu bar are located.
- *
- *  @return The primary monitor, or `NULL` if no monitors were found or if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @remark The primary monitor is always first in the array returned by @ref
- *  glfwGetMonitors.
- *
- *  @sa @ref monitor_monitors
- *  @sa @ref glfwGetMonitors
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
-
-/*! @brief Returns the position of the monitor's viewport on the virtual screen.
- *
- *  This function returns the position, in screen coordinates, of the upper-left
- *  corner of the specified monitor.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
- *  @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
-
-/*! @brief Retrieves the work area of the monitor.
- *
- *  This function returns the position, in screen coordinates, of the upper-left
- *  corner of the work area of the specified monitor along with the work area
- *  size in screen coordinates. The work area is defined as the area of the
- *  monitor not occluded by the operating system task bar where present. If no
- *  task bar exists then the work area is the monitor resolution in screen
- *  coordinates.
- *
- *  Any or all of the position and size arguments may be `NULL`.  If an error
- *  occurs, all non-`NULL` position and size arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
- *  @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
- *  @param[out] width Where to store the monitor width, or `NULL`.
- *  @param[out] height Where to store the monitor height, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_workarea
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
-
-/*! @brief Returns the physical size of the monitor.
- *
- *  This function returns the size, in millimetres, of the display area of the
- *  specified monitor.
- *
- *  Some systems do not provide accurate monitor size information, either
- *  because the monitor
- *  [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
- *  data is incorrect or because the driver does not report it accurately.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] widthMM Where to store the width, in millimetres, of the
- *  monitor's display area, or `NULL`.
- *  @param[out] heightMM Where to store the height, in millimetres, of the
- *  monitor's display area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @win32 calculates the returned physical size from the
- *  current resolution and system DPI instead of querying the monitor EDID data.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
-
-/*! @brief Retrieves the content scale for the specified monitor.
- *
- *  This function retrieves the content scale for the specified monitor.  The
- *  content scale is the ratio between the current DPI and the platform's
- *  default DPI.  This is especially important for text and any UI elements.  If
- *  the pixel dimensions of your UI scaled by this look appropriate on your
- *  machine then it should appear at a reasonable size on other machines
- *  regardless of their DPI and scaling settings.  This relies on the system DPI
- *  and scaling settings being somewhat correct.
- *
- *  The content scale may depend on both the monitor resolution and pixel
- *  density and on user settings.  It may be very different from the raw DPI
- *  calculated from the physical size and current resolution.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xscale Where to store the x-axis content scale, or `NULL`.
- *  @param[out] yscale Where to store the y-axis content scale, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_scale
- *  @sa @ref glfwGetWindowContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
-
-/*! @brief Returns the name of the specified monitor.
- *
- *  This function returns a human-readable name, encoded as UTF-8, of the
- *  specified monitor.  The name typically reflects the make and model of the
- *  monitor and is not guaranteed to be unique among the connected monitors.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The UTF-8 encoded name of the monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
-
-/*! @brief Sets the user pointer of the specified monitor.
- *
- *  This function sets the user-defined pointer of the specified monitor.  The
- *  current value is retained until the monitor is disconnected.  The initial
- *  value is `NULL`.
- *
- *  This function may be called from the monitor callback, even for a monitor
- *  that is being disconnected.
- *
- *  @param[in] monitor The monitor whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref monitor_userptr
- *  @sa @ref glfwGetMonitorUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
-
-/*! @brief Returns the user pointer of the specified monitor.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified monitor.  The initial value is `NULL`.
- *
- *  This function may be called from the monitor callback, even for a monitor
- *  that is being disconnected.
- *
- *  @param[in] monitor The monitor whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref monitor_userptr
- *  @sa @ref glfwSetMonitorUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
-
-/*! @brief Sets the monitor configuration callback.
- *
- *  This function sets the monitor configuration callback, or removes the
- *  currently set callback.  This is called when a monitor is connected to or
- *  disconnected from the system.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWmonitor* monitor, int event)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWmonitorfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_event
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
-
-/*! @brief Returns the available video modes for the specified monitor.
- *
- *  This function returns an array of all video modes supported by the specified
- *  monitor.  The returned array is sorted in ascending order, first by color
- *  bit depth (the sum of all channel depths) and then by resolution area (the
- *  product of width and height).
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] count Where to store the number of video modes in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of video modes, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected, this function is called again for that monitor or the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoMode
- *
- *  @since Added in version 1.0.
- *  @glfw3 Changed to return an array of modes for a specific monitor.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
-
-/*! @brief Returns the current mode of the specified monitor.
- *
- *  This function returns the current video mode of the specified monitor.  If
- *  you have created a full screen window for that monitor, the return value
- *  will depend on whether that window is iconified.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The current mode of the monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoModes
- *
- *  @since Added in version 3.0.  Replaces `glfwGetDesktopMode`.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
-
-/*! @brief Generates a gamma ramp and sets it for the specified monitor.
- *
- *  This function generates an appropriately sized gamma ramp from the specified
- *  exponent and then calls @ref glfwSetGammaRamp with it.  The value must be
- *  a finite number greater than zero.
- *
- *  The software controlled gamma ramp is applied _in addition_ to the hardware
- *  gamma correction, which today is usually an approximation of sRGB gamma.
- *  This means that setting a perfectly linear ramp, or gamma 1.0, will produce
- *  the default (usually sRGB-like) behavior.
- *
- *  For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
- *  GLFW_SRGB_CAPABLE hint.
- *
- *  @param[in] monitor The monitor whose gamma ramp to set.
- *  @param[in] gamma The desired exponent.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
-
-/*! @brief Returns the current gamma ramp for the specified monitor.
- *
- *  This function returns the current gamma ramp of the specified monitor.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The current gamma ramp, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
- *  returning `NULL`.
- *
- *  @pointer_lifetime The returned structure and its arrays are allocated and
- *  freed by GLFW.  You should not free them yourself.  They are valid until the
- *  specified monitor is disconnected, this function is called again for that
- *  monitor or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
-
-/*! @brief Sets the current gamma ramp for the specified monitor.
- *
- *  This function sets the current gamma ramp for the specified monitor.  The
- *  original gamma ramp for that monitor is saved by GLFW the first time this
- *  function is called and is restored by @ref glfwTerminate.
- *
- *  The software controlled gamma ramp is applied _in addition_ to the hardware
- *  gamma correction, which today is usually an approximation of sRGB gamma.
- *  This means that setting a perfectly linear ramp, or gamma 1.0, will produce
- *  the default (usually sRGB-like) behavior.
- *
- *  For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
- *  GLFW_SRGB_CAPABLE hint.
- *
- *  @param[in] monitor The monitor whose gamma ramp to set.
- *  @param[in] ramp The gamma ramp to use.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The size of the specified gamma ramp should match the size of the
- *  current ramp for that monitor.
- *
- *  @remark @win32 The gamma ramp size must be 256.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified gamma ramp is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
-
-/*! @brief Resets all window hints to their default values.
- *
- *  This function resets all window hints to their
- *  [default values](@ref window_hints_values).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHint
- *  @sa @ref glfwWindowHintString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwDefaultWindowHints(void);
-
-/*! @brief Sets the specified window hint to the desired value.
- *
- *  This function sets hints for the next call to @ref glfwCreateWindow.  The
- *  hints, once set, retain their values until changed by a call to this
- *  function or @ref glfwDefaultWindowHints, or until the library is terminated.
- *
- *  Only integer value hints can be set with this function.  String value hints
- *  are set with @ref glfwWindowHintString.
- *
- *  This function does not check whether the specified hint values are valid.
- *  If you set hints to invalid values this will instead be reported by the next
- *  call to @ref glfwCreateWindow.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [window hint](@ref window_hints) to set.
- *  @param[in] value The new value of the window hint.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHintString
- *  @sa @ref glfwDefaultWindowHints
- *
- *  @since Added in version 3.0.  Replaces `glfwOpenWindowHint`.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWindowHint(int hint, int value);
-
-/*! @brief Sets the specified window hint to the desired value.
- *
- *  This function sets hints for the next call to @ref glfwCreateWindow.  The
- *  hints, once set, retain their values until changed by a call to this
- *  function or @ref glfwDefaultWindowHints, or until the library is terminated.
- *
- *  Only string type hints can be set with this function.  Integer value hints
- *  are set with @ref glfwWindowHint.
- *
- *  This function does not check whether the specified hint values are valid.
- *  If you set hints to invalid values this will instead be reported by the next
- *  call to @ref glfwCreateWindow.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [window hint](@ref window_hints) to set.
- *  @param[in] value The new value of the window hint.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHint
- *  @sa @ref glfwDefaultWindowHints
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWindowHintString(int hint, const char* value);
-
-/*! @brief Creates a window and its associated context.
- *
- *  This function creates a window and its associated OpenGL or OpenGL ES
- *  context.  Most of the options controlling how the window and its context
- *  should be created are specified with [window hints](@ref window_hints).
- *
- *  Successful creation does not change which context is current.  Before you
- *  can use the newly created context, you need to
- *  [make it current](@ref context_current).  For information about the `share`
- *  parameter, see @ref context_sharing.
- *
- *  The created window, framebuffer and context may differ from what you
- *  requested, as not all parameters and hints are
- *  [hard constraints](@ref window_hints_hard).  This includes the size of the
- *  window, especially for full screen windows.  To query the actual attributes
- *  of the created window, framebuffer and context, see @ref
- *  glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
- *
- *  To create a full screen window, you need to specify the monitor the window
- *  will cover.  If no monitor is specified, the window will be windowed mode.
- *  Unless you have a way for the user to choose a specific monitor, it is
- *  recommended that you pick the primary monitor.  For more information on how
- *  to query connected monitors, see @ref monitor_monitors.
- *
- *  For full screen windows, the specified size becomes the resolution of the
- *  window's _desired video mode_.  As long as a full screen window is not
- *  iconified, the supported video mode most closely matching the desired video
- *  mode is set for the specified monitor.  For more information about full
- *  screen windows, including the creation of so called _windowed full screen_
- *  or _borderless full screen_ windows, see @ref window_windowed_full_screen.
- *
- *  Once you have created the window, you can switch it between windowed and
- *  full screen mode with @ref glfwSetWindowMonitor.  This will not affect its
- *  OpenGL or OpenGL ES context.
- *
- *  By default, newly created windows use the placement recommended by the
- *  window system.  To create the window at a specific position, make it
- *  initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
- *  hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
- *  it.
- *
- *  As long as at least one full screen window is not iconified, the screensaver
- *  is prohibited from starting.
- *
- *  Window systems put limits on window sizes.  Very large or very small window
- *  dimensions may be overridden by the window system on creation.  Check the
- *  actual [size](@ref window_size) after creation.
- *
- *  The [swap interval](@ref buffer_swap) is not set during window creation and
- *  the initial value may vary depending on driver settings and defaults.
- *
- *  @param[in] width The desired width, in screen coordinates, of the window.
- *  This must be greater than zero.
- *  @param[in] height The desired height, in screen coordinates, of the window.
- *  This must be greater than zero.
- *  @param[in] title The initial, UTF-8 encoded window title.
- *  @param[in] monitor The monitor to use for full screen mode, or `NULL` for
- *  windowed mode.
- *  @param[in] share The window whose context to share resources with, or `NULL`
- *  to not share resources.
- *  @return The handle of the created window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
- *  GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @win32 Window creation will fail if the Microsoft GDI software
- *  OpenGL implementation is the only one available.
- *
- *  @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
- *  will be set as the initial icon for the window.  If no such icon is present,
- *  the `IDI_APPLICATION` icon will be used instead.  To set a different icon,
- *  see @ref glfwSetWindowIcon.
- *
- *  @remark @win32 The context to share resources with must not be current on
- *  any other thread.
- *
- *  @remark @macos The OS only supports core profile contexts for OpenGL
- *  versions 3.2 and later.  Before creating an OpenGL context of version 3.2 or
- *  later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
- *  hint accordingly.  OpenGL 3.0 and 3.1 contexts are not supported at all
- *  on macOS.
- *
- *  @remark @macos The GLFW window has no icon, as it is not a document
- *  window, but the dock icon will be the same as the application bundle's icon.
- *  For more information on bundles, see the
- *  [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
- *  in the Mac Developer Library.
- *
- *  @remark @macos On OS X 10.10 and later the window frame will not be rendered
- *  at full resolution on Retina displays unless the
- *  [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
- *  hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
- *  application bundle's `Info.plist`.  For more information, see
- *  [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
- *  in the Mac Developer Library.  The GLFW test and example programs use
- *  a custom `Info.plist` template for this, which can be found as
- *  `CMake/Info.plist.in` in the source tree.
- *
- *  @remark @macos When activating frame autosaving with
- *  [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
- *  window size and position may be overridden by previously saved values.
- *
- *  @remark @x11 Some window managers will not respect the placement of
- *  initially hidden windows.
- *
- *  @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
- *  a window to reach its requested state.  This means you may not be able to
- *  query the final size, position or other attributes directly after window
- *  creation.
- *
- *  @remark @x11 The class part of the `WM_CLASS` window property will by
- *  default be set to the window title passed to this function.  The instance
- *  part will use the contents of the `RESOURCE_NAME` environment variable, if
- *  present and not empty, or fall back to the window title.  Set the
- *  [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
- *  [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
- *  override this.
- *
- *  @remark @wayland Compositors should implement the xdg-decoration protocol
- *  for GLFW to decorate the window properly.  If this protocol isn't
- *  supported, or if the compositor prefers client-side decorations, a very
- *  simple fallback frame will be drawn using the wp_viewporter protocol.  A
- *  compositor can still emit close, maximize or fullscreen events, using for
- *  instance a keybind mechanism.  If neither of these protocols is supported,
- *  the window won't be decorated.
- *
- *  @remark @wayland A full screen window will not attempt to change the mode,
- *  no matter what the requested size or refresh rate.
- *
- *  @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
- *  to be implemented in the user's compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_creation
- *  @sa @ref glfwDestroyWindow
- *
- *  @since Added in version 3.0.  Replaces `glfwOpenWindow`.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
-
-/*! @brief Destroys the specified window and its context.
- *
- *  This function destroys the specified window and its context.  On calling
- *  this function, no further callbacks will be called for that window.
- *
- *  If the context of the specified window is current on the main thread, it is
- *  detached before being destroyed.
- *
- *  @param[in] window The window to destroy.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @note The context of the specified window must not be current on any other
- *  thread when this function is called.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_creation
- *  @sa @ref glfwCreateWindow
- *
- *  @since Added in version 3.0.  Replaces `glfwCloseWindow`.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
-
-/*! @brief Checks the close flag of the specified window.
- *
- *  This function returns the value of the close flag of the specified window.
- *
- *  @param[in] window The window to query.
- *  @return The value of the close flag.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
-
-/*! @brief Sets the close flag of the specified window.
- *
- *  This function sets the value of the close flag of the specified window.
- *  This can be used to override the user's attempt to close the window, or
- *  to signal that it should be closed.
- *
- *  @param[in] window The window whose flag to change.
- *  @param[in] value The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
-
-/*! @brief Sets the title of the specified window.
- *
- *  This function sets the window title, encoded as UTF-8, of the specified
- *  window.
- *
- *  @param[in] window The window whose title to change.
- *  @param[in] title The UTF-8 encoded window title.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos The window title will not be updated until the next time you
- *  process events.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_title
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
-
-/*! @brief Sets the icon for the specified window.
- *
- *  This function sets the icon of the specified window.  If passed an array of
- *  candidate images, those of or closest to the sizes desired by the system are
- *  selected.  If no images are specified, the window reverts to its default
- *  icon.
- *
- *  The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
- *  bits per channel with the red channel first.  They are arranged canonically
- *  as packed sequential rows, starting from the top-left corner.
- *
- *  The desired image sizes varies depending on platform and system settings.
- *  The selected images will be rescaled as needed.  Good sizes include 16x16,
- *  32x32 and 48x48.
- *
- *  @param[in] window The window whose icon to set.
- *  @param[in] count The number of images in the specified array, or zero to
- *  revert to the default window icon.
- *  @param[in] images The images to create the icon from.  This is ignored if
- *  count is zero.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @pointer_lifetime The specified image data is copied before this function
- *  returns.
- *
- *  @remark @macos Regular windows do not have icons on macOS.  This function
- *  will emit @ref GLFW_FEATURE_UNAVAILABLE.  The dock icon will be the same as
- *  the application bundle's icon.  For more information on bundles, see the
- *  [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
- *  in the Mac Developer Library.
- *
- *  @remark @wayland There is no existing protocol to change an icon, the
- *  window will thus inherit the one defined in the application's desktop file.
- *  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_icon
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
-
-/*! @brief Retrieves the position of the content area of the specified window.
- *
- *  This function retrieves the position, in screen coordinates, of the
- *  upper-left corner of the content area of the specified window.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] window The window to query.
- *  @param[out] xpos Where to store the x-coordinate of the upper-left corner of
- *  the content area, or `NULL`.
- *  @param[out] ypos Where to store the y-coordinate of the upper-left corner of
- *  the content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way for an application to retrieve the global
- *  position of its windows.  This function will emit @ref
- *  GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwSetWindowPos
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
-
-/*! @brief Sets the position of the content area of the specified window.
- *
- *  This function sets the position, in screen coordinates, of the upper-left
- *  corner of the content area of the specified windowed mode window.  If the
- *  window is a full screen window, this function does nothing.
- *
- *  __Do not use this function__ to move an already visible window unless you
- *  have very good reasons for doing so, as it will confuse and annoy the user.
- *
- *  The window manager may put limits on what positions are allowed.  GLFW
- *  cannot and should not override these limits.
- *
- *  @param[in] window The window to query.
- *  @param[in] xpos The x-coordinate of the upper-left corner of the content area.
- *  @param[in] ypos The y-coordinate of the upper-left corner of the content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way for an application to set the global
- *  position of its windows.  This function will emit @ref
- *  GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwGetWindowPos
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
-
-/*! @brief Retrieves the size of the content area of the specified window.
- *
- *  This function retrieves the size, in screen coordinates, of the content area
- *  of the specified window.  If you wish to retrieve the size of the
- *  framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose size to retrieve.
- *  @param[out] width Where to store the width, in screen coordinates, of the
- *  content area, or `NULL`.
- *  @param[out] height Where to store the height, in screen coordinates, of the
- *  content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwSetWindowSize
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
-
-/*! @brief Sets the size limits of the specified window.
- *
- *  This function sets the size limits of the content area of the specified
- *  window.  If the window is full screen, the size limits only take effect
- *  once it is made windowed.  If the window is not resizable, this function
- *  does nothing.
- *
- *  The size limits are applied immediately to a windowed mode window and may
- *  cause it to be resized.
- *
- *  The maximum dimensions must be greater than or equal to the minimum
- *  dimensions and all must be greater than or equal to zero.
- *
- *  @param[in] window The window to set limits for.
- *  @param[in] minwidth The minimum width, in screen coordinates, of the content
- *  area, or `GLFW_DONT_CARE`.
- *  @param[in] minheight The minimum height, in screen coordinates, of the
- *  content area, or `GLFW_DONT_CARE`.
- *  @param[in] maxwidth The maximum width, in screen coordinates, of the content
- *  area, or `GLFW_DONT_CARE`.
- *  @param[in] maxheight The maximum height, in screen coordinates, of the
- *  content area, or `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark If you set size limits and an aspect ratio that conflict, the
- *  results are undefined.
- *
- *  @remark @wayland The size limits will not be applied until the window is
- *  actually resized, either by the user or by the compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_sizelimits
- *  @sa @ref glfwSetWindowAspectRatio
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
-
-/*! @brief Sets the aspect ratio of the specified window.
- *
- *  This function sets the required aspect ratio of the content area of the
- *  specified window.  If the window is full screen, the aspect ratio only takes
- *  effect once it is made windowed.  If the window is not resizable, this
- *  function does nothing.
- *
- *  The aspect ratio is specified as a numerator and a denominator and both
- *  values must be greater than zero.  For example, the common 16:9 aspect ratio
- *  is specified as 16 and 9, respectively.
- *
- *  If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
- *  ratio limit is disabled.
- *
- *  The aspect ratio is applied immediately to a windowed mode window and may
- *  cause it to be resized.
- *
- *  @param[in] window The window to set limits for.
- *  @param[in] numer The numerator of the desired aspect ratio, or
- *  `GLFW_DONT_CARE`.
- *  @param[in] denom The denominator of the desired aspect ratio, or
- *  `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark If you set size limits and an aspect ratio that conflict, the
- *  results are undefined.
- *
- *  @remark @wayland The aspect ratio will not be applied until the window is
- *  actually resized, either by the user or by the compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_sizelimits
- *  @sa @ref glfwSetWindowSizeLimits
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
-
-/*! @brief Sets the size of the content area of the specified window.
- *
- *  This function sets the size, in screen coordinates, of the content area of
- *  the specified window.
- *
- *  For full screen windows, this function updates the resolution of its desired
- *  video mode and switches to the video mode closest to it, without affecting
- *  the window's context.  As the context is unaffected, the bit depths of the
- *  framebuffer remain unchanged.
- *
- *  If you wish to update the refresh rate of the desired video mode in addition
- *  to its resolution, see @ref glfwSetWindowMonitor.
- *
- *  The window manager may put limits on what sizes are allowed.  GLFW cannot
- *  and should not override these limits.
- *
- *  @param[in] window The window to resize.
- *  @param[in] width The desired width, in screen coordinates, of the window
- *  content area.
- *  @param[in] height The desired height, in screen coordinates, of the window
- *  content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland A full screen window will not attempt to change the mode,
- *  no matter what the requested size.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwGetWindowSize
- *  @sa @ref glfwSetWindowMonitor
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
-
-/*! @brief Retrieves the size of the framebuffer of the specified window.
- *
- *  This function retrieves the size, in pixels, of the framebuffer of the
- *  specified window.  If you wish to retrieve the size of the window in screen
- *  coordinates, see @ref glfwGetWindowSize.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose framebuffer to query.
- *  @param[out] width Where to store the width, in pixels, of the framebuffer,
- *  or `NULL`.
- *  @param[out] height Where to store the height, in pixels, of the framebuffer,
- *  or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_fbsize
- *  @sa @ref glfwSetFramebufferSizeCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
-
-/*! @brief Retrieves the size of the frame of the window.
- *
- *  This function retrieves the size, in screen coordinates, of each edge of the
- *  frame of the specified window.  This size includes the title bar, if the
- *  window has one.  The size of the frame may vary depending on the
- *  [window-related hints](@ref window_hints_wnd) used to create it.
- *
- *  Because this function retrieves the size of each window frame edge and not
- *  the offset along a particular coordinate axis, the retrieved values will
- *  always be zero or positive.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose frame size to query.
- *  @param[out] left Where to store the size, in screen coordinates, of the left
- *  edge of the window frame, or `NULL`.
- *  @param[out] top Where to store the size, in screen coordinates, of the top
- *  edge of the window frame, or `NULL`.
- *  @param[out] right Where to store the size, in screen coordinates, of the
- *  right edge of the window frame, or `NULL`.
- *  @param[out] bottom Where to store the size, in screen coordinates, of the
- *  bottom edge of the window frame, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
-
-/*! @brief Retrieves the content scale for the specified window.
- *
- *  This function retrieves the content scale for the specified window.  The
- *  content scale is the ratio between the current DPI and the platform's
- *  default DPI.  This is especially important for text and any UI elements.  If
- *  the pixel dimensions of your UI scaled by this look appropriate on your
- *  machine then it should appear at a reasonable size on other machines
- *  regardless of their DPI and scaling settings.  This relies on the system DPI
- *  and scaling settings being somewhat correct.
- *
- *  On systems where each monitors can have its own content scale, the window
- *  content scale will depend on which monitor the system considers the window
- *  to be on.
- *
- *  @param[in] window The window to query.
- *  @param[out] xscale Where to store the x-axis content scale, or `NULL`.
- *  @param[out] yscale Where to store the y-axis content scale, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwSetWindowContentScaleCallback
- *  @sa @ref glfwGetMonitorContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
-
-/*! @brief Returns the opacity of the whole window.
- *
- *  This function returns the opacity of the window, including any decorations.
- *
- *  The opacity (or alpha) value is a positive finite number between zero and
- *  one, where zero is fully transparent and one is fully opaque.  If the system
- *  does not support whole window transparency, this function always returns one.
- *
- *  The initial opacity value for newly created windows is one.
- *
- *  @param[in] window The window to query.
- *  @return The opacity value of the specified window.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_transparency
- *  @sa @ref glfwSetWindowOpacity
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
-
-/*! @brief Sets the opacity of the whole window.
- *
- *  This function sets the opacity of the window, including any decorations.
- *
- *  The opacity (or alpha) value is a positive finite number between zero and
- *  one, where zero is fully transparent and one is fully opaque.
- *
- *  The initial opacity value for newly created windows is one.
- *
- *  A window created with framebuffer transparency may not use whole window
- *  transparency.  The results of doing this are undefined.
- *
- *  @param[in] window The window to set the opacity for.
- *  @param[in] opacity The desired opacity of the specified window.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way to set an opacity factor for a window.
- *  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_transparency
- *  @sa @ref glfwGetWindowOpacity
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
-
-/*! @brief Iconifies the specified window.
- *
- *  This function iconifies (minimizes) the specified window if it was
- *  previously restored.  If the window is already iconified, this function does
- *  nothing.
- *
- *  If the specified window is a full screen window, the original monitor
- *  resolution is restored until the window is restored.
- *
- *  @param[in] window The window to iconify.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
- *  be able to restore it.  This is a design decision of the xdg-shell
- *  protocol.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwRestoreWindow
- *  @sa @ref glfwMaximizeWindow
- *
- *  @since Added in version 2.1.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
-
-/*! @brief Restores the specified window.
- *
- *  This function restores the specified window if it was previously iconified
- *  (minimized) or maximized.  If the window is already restored, this function
- *  does nothing.
- *
- *  If the specified window is a full screen window, the resolution chosen for
- *  the window is restored on the selected monitor.
- *
- *  @param[in] window The window to restore.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwIconifyWindow
- *  @sa @ref glfwMaximizeWindow
- *
- *  @since Added in version 2.1.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
-
-/*! @brief Maximizes the specified window.
- *
- *  This function maximizes the specified window if it was previously not
- *  maximized.  If the window is already maximized, this function does nothing.
- *
- *  If the specified window is a full screen window, this function does nothing.
- *
- *  @param[in] window The window to maximize.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @par Thread Safety
- *  This function may only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwIconifyWindow
- *  @sa @ref glfwRestoreWindow
- *
- *  @since Added in GLFW 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
-
-/*! @brief Makes the specified window visible.
- *
- *  This function makes the specified window visible if it was previously
- *  hidden.  If the window is already visible or is in full screen mode, this
- *  function does nothing.
- *
- *  By default, windowed mode windows are focused when shown
- *  Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
- *  to change this behavior for all newly created windows, or change the
- *  behavior for an existing window with @ref glfwSetWindowAttrib.
- *
- *  @param[in] window The window to make visible.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hide
- *  @sa @ref glfwHideWindow
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwShowWindow(GLFWwindow* window);
-
-/*! @brief Hides the specified window.
- *
- *  This function hides the specified window if it was previously visible.  If
- *  the window is already hidden or is in full screen mode, this function does
- *  nothing.
- *
- *  @param[in] window The window to hide.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hide
- *  @sa @ref glfwShowWindow
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwHideWindow(GLFWwindow* window);
-
-/*! @brief Brings the specified window to front and sets input focus.
- *
- *  This function brings the specified window to front and sets input focus.
- *  The window should already be visible and not iconified.
- *
- *  By default, both windowed and full screen mode windows are focused when
- *  initially created.  Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
- *  disable this behavior.
- *
- *  Also by default, windowed mode windows are focused when shown
- *  with @ref glfwShowWindow. Set the
- *  [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
- *
- *  __Do not use this function__ to steal focus from other applications unless
- *  you are certain that is what the user wants.  Focus stealing can be
- *  extremely disruptive.
- *
- *  For a less disruptive way of getting the user's attention, see
- *  [attention requests](@ref window_attention).
- *
- *  @param[in] window The window to give input focus.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland It is not possible for an application to set the input
- *  focus.  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_focus
- *  @sa @ref window_attention
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwFocusWindow(GLFWwindow* window);
-
-/*! @brief Requests user attention to the specified window.
- *
- *  This function requests user attention to the specified window.  On
- *  platforms where this is not supported, attention is requested to the
- *  application as a whole.
- *
- *  Once the user has given attention, usually by focusing the window or
- *  application, the system will end the request automatically.
- *
- *  @param[in] window The window to request attention to.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos Attention is requested to the application as a whole, not the
- *  specific window.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attention
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
-
-/*! @brief Returns the monitor that the window uses for full screen mode.
- *
- *  This function returns the handle of the monitor that the specified window is
- *  in full screen on.
- *
- *  @param[in] window The window to query.
- *  @return The monitor, or `NULL` if the window is in windowed mode or an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_monitor
- *  @sa @ref glfwSetWindowMonitor
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
-
-/*! @brief Sets the mode, monitor, video mode and placement of a window.
- *
- *  This function sets the monitor that the window uses for full screen mode or,
- *  if the monitor is `NULL`, makes it windowed mode.
- *
- *  When setting a monitor, this function updates the width, height and refresh
- *  rate of the desired video mode and switches to the video mode closest to it.
- *  The window position is ignored when setting a monitor.
- *
- *  When the monitor is `NULL`, the position, width and height are used to
- *  place the window content area.  The refresh rate is ignored when no monitor
- *  is specified.
- *
- *  If you only wish to update the resolution of a full screen window or the
- *  size of a windowed mode window, see @ref glfwSetWindowSize.
- *
- *  When a window transitions from full screen to windowed mode, this function
- *  restores any previous window settings such as whether it is decorated,
- *  floating, resizable, has size or aspect ratio limits, etc.
- *
- *  @param[in] window The window whose monitor, size or video mode to set.
- *  @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
- *  @param[in] xpos The desired x-coordinate of the upper-left corner of the
- *  content area.
- *  @param[in] ypos The desired y-coordinate of the upper-left corner of the
- *  content area.
- *  @param[in] width The desired with, in screen coordinates, of the content
- *  area or video mode.
- *  @param[in] height The desired height, in screen coordinates, of the content
- *  area or video mode.
- *  @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
- *  or `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
- *  affected by any resizing or mode switching, although you may need to update
- *  your viewport if the framebuffer size has changed.
- *
- *  @remark @wayland The desired window position is ignored, as there is no way
- *  for an application to set this property.
- *
- *  @remark @wayland Setting the window to full screen will not attempt to
- *  change the mode, no matter what the requested size or refresh rate.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_monitor
- *  @sa @ref window_full_screen
- *  @sa @ref glfwGetWindowMonitor
- *  @sa @ref glfwSetWindowSize
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
-
-/*! @brief Returns an attribute of the specified window.
- *
- *  This function returns the value of an attribute of the specified window or
- *  its OpenGL or OpenGL ES context.
- *
- *  @param[in] window The window to query.
- *  @param[in] attrib The [window attribute](@ref window_attribs) whose value to
- *  return.
- *  @return The value of the attribute, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark Framebuffer related hints are not window attributes.  See @ref
- *  window_attribs_fb for more information.
- *
- *  @remark Zero is a valid value for many window and context related
- *  attributes so you cannot use a return value of zero as an indication of
- *  errors.  However, this function should not fail as long as it is passed
- *  valid arguments and the library has been [initialized](@ref intro_init).
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attribs
- *  @sa @ref glfwSetWindowAttrib
- *
- *  @since Added in version 3.0.  Replaces `glfwGetWindowParam` and
- *  `glfwGetGLVersion`.
- *
- *  @ingroup window
- */
-GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
-
-/*! @brief Sets an attribute of the specified window.
- *
- *  This function sets the value of an attribute of the specified window.
- *
- *  The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
- *  [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
- *  [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
- *  [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
- *  [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
- *  [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
- *
- *  Some of these attributes are ignored for full screen windows.  The new
- *  value will take effect if the window is later made windowed.
- *
- *  Some of these attributes are ignored for windowed mode windows.  The new
- *  value will take effect if the window is later made full screen.
- *
- *  @param[in] window The window to set the attribute for.
- *  @param[in] attrib A supported window attribute.
- *  @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark Calling @ref glfwGetWindowAttrib will always return the latest
- *  value, even if that value is ignored by the current mode of the window.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attribs
- *  @sa @ref glfwGetWindowAttrib
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
-
-/*! @brief Sets the user pointer of the specified window.
- *
- *  This function sets the user-defined pointer of the specified window.  The
- *  current value is retained until the window is destroyed.  The initial value
- *  is `NULL`.
- *
- *  @param[in] window The window whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_userptr
- *  @sa @ref glfwGetWindowUserPointer
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
-
-/*! @brief Returns the user pointer of the specified window.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified window.  The initial value is `NULL`.
- *
- *  @param[in] window The window whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_userptr
- *  @sa @ref glfwSetWindowUserPointer
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
-
-/*! @brief Sets the position callback for the specified window.
- *
- *  This function sets the position callback of the specified window, which is
- *  called when the window is moved.  The callback is provided with the
- *  position, in screen coordinates, of the upper-left corner of the content
- *  area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int xpos, int ypos)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowposfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @wayland This callback will never be called, as there is no way for
- *  an application to know its global position.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
-
-/*! @brief Sets the size callback for the specified window.
- *
- *  This function sets the size callback of the specified window, which is
- *  called when the window is resized.  The callback is provided with the size,
- *  in screen coordinates, of the content area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowsizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
-
-/*! @brief Sets the close callback for the specified window.
- *
- *  This function sets the close callback of the specified window, which is
- *  called when the user attempts to close the window, for example by clicking
- *  the close widget in the title bar.
- *
- *  The close flag is set before this callback is called, but you can modify it
- *  at any time with @ref glfwSetWindowShouldClose.
- *
- *  The close callback is not triggered by @ref glfwDestroyWindow.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowclosefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @macos Selecting Quit from the application menu will trigger the
- *  close callback for all windows.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
-
-/*! @brief Sets the refresh callback for the specified window.
- *
- *  This function sets the refresh callback of the specified window, which is
- *  called when the content area of the window needs to be redrawn, for example
- *  if the window has been exposed after having been covered by another window.
- *
- *  On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
- *  the window contents are saved off-screen, this callback may be called only
- *  very infrequently or never at all.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window);
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowrefreshfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_refresh
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
-
-/*! @brief Sets the focus callback for the specified window.
- *
- *  This function sets the focus callback of the specified window, which is
- *  called when the window gains or loses input focus.
- *
- *  After the focus callback is called for a window that lost input focus,
- *  synthetic key and mouse button release events will be generated for all such
- *  that had been pressed.  For more information, see @ref glfwSetKeyCallback
- *  and @ref glfwSetMouseButtonCallback.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int focused)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowfocusfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_focus
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
-
-/*! @brief Sets the iconify callback for the specified window.
- *
- *  This function sets the iconification callback of the specified window, which
- *  is called when the window is iconified or restored.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int iconified)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowiconifyfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
-
-/*! @brief Sets the maximize callback for the specified window.
- *
- *  This function sets the maximization callback of the specified window, which
- *  is called when the window is maximized or restored.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int maximized)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowmaximizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_maximize
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
-
-/*! @brief Sets the framebuffer resize callback for the specified window.
- *
- *  This function sets the framebuffer resize callback of the specified window,
- *  which is called when the framebuffer of the specified window is resized.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWframebuffersizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_fbsize
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
-
-/*! @brief Sets the window content scale callback for the specified window.
- *
- *  This function sets the window content scale callback of the specified window,
- *  which is called when the content scale of the specified window changes.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, float xscale, float yscale)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowcontentscalefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwGetWindowContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
-
-/*! @brief Processes all pending events.
- *
- *  This function processes only those events that are already in the event
- *  queue and then returns immediately.  Processing events will cause the window
- *  and input callbacks associated with those events to be called.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwWaitEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwPollEvents(void);
-
-/*! @brief Waits until events are queued and processes them.
- *
- *  This function puts the calling thread to sleep until at least one event is
- *  available in the event queue.  Once one or more events are available,
- *  it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
- *  are processed and the function then returns immediately.  Processing events
- *  will cause the window and input callbacks associated with those events to be
- *  called.
- *
- *  Since not all events are associated with callbacks, this function may return
- *  without a callback having been called even if you are monitoring all
- *  callbacks.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwPollEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 2.5.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWaitEvents(void);
-
-/*! @brief Waits with timeout until events are queued and processes them.
- *
- *  This function puts the calling thread to sleep until at least one event is
- *  available in the event queue, or until the specified timeout is reached.  If
- *  one or more events are available, it behaves exactly like @ref
- *  glfwPollEvents, i.e. the events in the queue are processed and the function
- *  then returns immediately.  Processing events will cause the window and input
- *  callbacks associated with those events to be called.
- *
- *  The timeout value must be a positive finite number.
- *
- *  Since not all events are associated with callbacks, this function may return
- *  without a callback having been called even if you are monitoring all
- *  callbacks.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @param[in] timeout The maximum amount of time, in seconds, to wait.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwPollEvents
- *  @sa @ref glfwWaitEvents
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWaitEventsTimeout(double timeout);
-
-/*! @brief Posts an empty event to the event queue.
- *
- *  This function posts an empty event from the current thread to the event
- *  queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwWaitEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwPostEmptyEvent(void);
-
-/*! @brief Returns the value of an input option for the specified window.
- *
- *  This function returns the value of an input option for the specified window.
- *  The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
- *  @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
- *  @ref GLFW_RAW_MOUSE_MOTION.
- *
- *  @param[in] window The window to query.
- *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
- *  `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
- *  `GLFW_RAW_MOUSE_MOTION`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref glfwSetInputMode
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
-
-/*! @brief Sets an input option for the specified window.
- *
- *  This function sets an input mode option for the specified window.  The mode
- *  must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
- *  @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
- *  @ref GLFW_RAW_MOUSE_MOTION.
- *
- *  If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
- *  modes:
- *  - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
- *  - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
- *    content area of the window but does not restrict the cursor from leaving.
- *  - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
- *    and unlimited cursor movement.  This is useful for implementing for
- *    example 3D camera controls.
- *
- *  If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
- *  enable sticky keys, or `GLFW_FALSE` to disable it.  If sticky keys are
- *  enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
- *  the next time it is called even if the key had been released before the
- *  call.  This is useful when you are only interested in whether keys have been
- *  pressed but not when or in which order.
- *
- *  If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
- *  `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
- *  If sticky mouse buttons are enabled, a mouse button press will ensure that
- *  @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
- *  if the mouse button had been released before the call.  This is useful when
- *  you are only interested in whether mouse buttons have been pressed but not
- *  when or in which order.
- *
- *  If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
- *  enable lock key modifier bits, or `GLFW_FALSE` to disable them.  If enabled,
- *  callbacks that receive modifier bits will also have the @ref
- *  GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
- *  and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
- *
- *  If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
- *  to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
- *  disabled, or `GLFW_FALSE` to disable it.  If raw motion is not supported,
- *  attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE.  Call @ref
- *  glfwRawMouseMotionSupported to check for support.
- *
- *  @param[in] window The window whose input mode to set.
- *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
- *  `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
- *  `GLFW_RAW_MOUSE_MOTION`.
- *  @param[in] value The new value of the specified input mode.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
- *  GLFW_FEATURE_UNAVAILABLE (see above).
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref glfwGetInputMode
- *
- *  @since Added in version 3.0.  Replaces `glfwEnable` and `glfwDisable`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
-
-/*! @brief Returns whether raw mouse motion is supported.
- *
- *  This function returns whether raw mouse motion is supported on the current
- *  system.  This status does not change after GLFW has been initialized so you
- *  only need to check this once.  If you attempt to enable raw motion on
- *  a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
- *
- *  Raw mouse motion is closer to the actual motion of the mouse across
- *  a surface.  It is not affected by the scaling and acceleration applied to
- *  the motion of the desktop cursor.  That processing is suitable for a cursor
- *  while raw motion is better for controlling for example a 3D camera.  Because
- *  of this, raw mouse motion is only provided when the cursor is disabled.
- *
- *  @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
- *  or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref raw_mouse_motion
- *  @sa @ref glfwSetInputMode
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwRawMouseMotionSupported(void);
-
-/*! @brief Returns the layout-specific name of the specified printable key.
- *
- *  This function returns the name of the specified printable key, encoded as
- *  UTF-8.  This is typically the character that key would produce without any
- *  modifier keys, intended for displaying key bindings to the user.  For dead
- *  keys, it is typically the diacritic it would add to a character.
- *
- *  __Do not use this function__ for [text input](@ref input_char).  You will
- *  break text input for many languages even if it happens to work for yours.
- *
- *  If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
- *  otherwise the scancode is ignored.  If you specify a non-printable key, or
- *  `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
- *  function returns `NULL` but does not emit an error.
- *
- *  This behavior allows you to always pass in the arguments in the
- *  [key callback](@ref input_key) without modification.
- *
- *  The printable keys are:
- *  - `GLFW_KEY_APOSTROPHE`
- *  - `GLFW_KEY_COMMA`
- *  - `GLFW_KEY_MINUS`
- *  - `GLFW_KEY_PERIOD`
- *  - `GLFW_KEY_SLASH`
- *  - `GLFW_KEY_SEMICOLON`
- *  - `GLFW_KEY_EQUAL`
- *  - `GLFW_KEY_LEFT_BRACKET`
- *  - `GLFW_KEY_RIGHT_BRACKET`
- *  - `GLFW_KEY_BACKSLASH`
- *  - `GLFW_KEY_WORLD_1`
- *  - `GLFW_KEY_WORLD_2`
- *  - `GLFW_KEY_0` to `GLFW_KEY_9`
- *  - `GLFW_KEY_A` to `GLFW_KEY_Z`
- *  - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
- *  - `GLFW_KEY_KP_DECIMAL`
- *  - `GLFW_KEY_KP_DIVIDE`
- *  - `GLFW_KEY_KP_MULTIPLY`
- *  - `GLFW_KEY_KP_SUBTRACT`
- *  - `GLFW_KEY_KP_ADD`
- *  - `GLFW_KEY_KP_EQUAL`
- *
- *  Names for printable keys depend on keyboard layout, while names for
- *  non-printable keys are the same across layouts but depend on the application
- *  language and should be localized along with other user interface text.
- *
- *  @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
- *  @param[in] scancode The scancode of the key to query.
- *  @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The contents of the returned string may change when a keyboard
- *  layout change event is received.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key_name
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetKeyName(int key, int scancode);
-
-/*! @brief Returns the platform-specific scancode of the specified key.
- *
- *  This function returns the platform-specific scancode of the specified key.
- *
- *  If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
- *  method will return `-1`.
- *
- *  @param[in] key Any [named key](@ref keys).
- *  @return The platform-specific scancode for the key, or `-1` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetKeyScancode(int key);
-
-/*! @brief Returns the last reported state of a keyboard key for the specified
- *  window.
- *
- *  This function returns the last state reported for the specified key to the
- *  specified window.  The returned state is one of `GLFW_PRESS` or
- *  `GLFW_RELEASE`.  The higher-level action `GLFW_REPEAT` is only reported to
- *  the key callback.
- *
- *  If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
- *  `GLFW_PRESS` the first time you call it for a key that was pressed, even if
- *  that key has already been released.
- *
- *  The key functions deal with physical keys, with [key tokens](@ref keys)
- *  named after their use on the standard US keyboard layout.  If you want to
- *  input text, use the Unicode character callback instead.
- *
- *  The [modifier key bit masks](@ref mods) are not key tokens and cannot be
- *  used with this function.
- *
- *  __Do not use this function__ to implement [text input](@ref input_char).
- *
- *  @param[in] window The desired window.
- *  @param[in] key The desired [keyboard key](@ref keys).  `GLFW_KEY_UNKNOWN` is
- *  not a valid key for this function.
- *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
-
-/*! @brief Returns the last reported state of a mouse button for the specified
- *  window.
- *
- *  This function returns the last state reported for the specified mouse button
- *  to the specified window.  The returned state is one of `GLFW_PRESS` or
- *  `GLFW_RELEASE`.
- *
- *  If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
- *  returns `GLFW_PRESS` the first time you call it for a mouse button that was
- *  pressed, even if that mouse button has already been released.
- *
- *  @param[in] window The desired window.
- *  @param[in] button The desired [mouse button](@ref buttons).
- *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_mouse_button
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
-
-/*! @brief Retrieves the position of the cursor relative to the content area of
- *  the window.
- *
- *  This function returns the position of the cursor, in screen coordinates,
- *  relative to the upper-left corner of the content area of the specified
- *  window.
- *
- *  If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
- *  position is unbounded and limited only by the minimum and maximum values of
- *  a `double`.
- *
- *  The coordinate can be converted to their integer equivalents with the
- *  `floor` function.  Casting directly to an integer type works for positive
- *  coordinates, but fails for negative ones.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] window The desired window.
- *  @param[out] xpos Where to store the cursor x-coordinate, relative to the
- *  left edge of the content area, or `NULL`.
- *  @param[out] ypos Where to store the cursor y-coordinate, relative to the to
- *  top edge of the content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwSetCursorPos
- *
- *  @since Added in version 3.0.  Replaces `glfwGetMousePos`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
-
-/*! @brief Sets the position of the cursor, relative to the content area of the
- *  window.
- *
- *  This function sets the position, in screen coordinates, of the cursor
- *  relative to the upper-left corner of the content area of the specified
- *  window.  The window must have input focus.  If the window does not have
- *  input focus when this function is called, it fails silently.
- *
- *  __Do not use this function__ to implement things like camera controls.  GLFW
- *  already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
- *  cursor, transparently re-centers it and provides unconstrained cursor
- *  motion.  See @ref glfwSetInputMode for more information.
- *
- *  If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
- *  unconstrained and limited only by the minimum and maximum values of
- *  a `double`.
- *
- *  @param[in] window The desired window.
- *  @param[in] xpos The desired x-coordinate, relative to the left edge of the
- *  content area.
- *  @param[in] ypos The desired y-coordinate, relative to the top edge of the
- *  content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland This function will only work when the cursor mode is
- *  `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwGetCursorPos
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMousePos`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
-
-/*! @brief Creates a custom cursor.
- *
- *  Creates a new custom cursor image that can be set for a window with @ref
- *  glfwSetCursor.  The cursor can be destroyed with @ref glfwDestroyCursor.
- *  Any remaining cursors are destroyed by @ref glfwTerminate.
- *
- *  The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
- *  bits per channel with the red channel first.  They are arranged canonically
- *  as packed sequential rows, starting from the top-left corner.
- *
- *  The cursor hotspot is specified in pixels, relative to the upper-left corner
- *  of the cursor image.  Like all other coordinate systems in GLFW, the X-axis
- *  points to the right and the Y-axis points down.
- *
- *  @param[in] image The desired cursor image.
- *  @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
- *  @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
- *  @return The handle of the created cursor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified image data is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *  @sa @ref glfwDestroyCursor
- *  @sa @ref glfwCreateStandardCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
-
-/*! @brief Creates a cursor with a standard shape.
- *
- *  Returns a cursor with a standard shape, that can be set for a window with
- *  @ref glfwSetCursor.  The images for these cursors come from the system
- *  cursor theme and their exact appearance will vary between platforms.
- *
- *  Most of these shapes are guaranteed to exist on every supported platform but
- *  a few may not be present.  See the table below for details.
- *
- *  Cursor shape                   | Windows | macOS | X11    | Wayland
- *  ------------------------------ | ------- | ----- | ------ | -------
- *  @ref GLFW_ARROW_CURSOR         | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_IBEAM_CURSOR         | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_CROSSHAIR_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_POINTING_HAND_CURSOR | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_EW_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_NS_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_NWSE_CURSOR   | Yes     | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *  @ref GLFW_RESIZE_NESW_CURSOR   | Yes     | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *  @ref GLFW_RESIZE_ALL_CURSOR    | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_NOT_ALLOWED_CURSOR   | Yes     | Yes   | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *
- *  1) This uses a private system API and may fail in the future.
- *
- *  2) This uses a newer standard that not all cursor themes support.
- *
- *  If the requested shape is not available, this function emits a @ref
- *  GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
- *
- *  @param[in] shape One of the [standard shapes](@ref shapes).
- *  @return A new cursor ready to use or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_standard
- *  @sa @ref glfwCreateCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
-
-/*! @brief Destroys a cursor.
- *
- *  This function destroys a cursor previously created with @ref
- *  glfwCreateCursor.  Any remaining cursors will be destroyed by @ref
- *  glfwTerminate.
- *
- *  If the specified cursor is current for any window, that window will be
- *  reverted to the default cursor.  This does not affect the cursor mode.
- *
- *  @param[in] cursor The cursor object to destroy.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *  @sa @ref glfwCreateCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
-
-/*! @brief Sets the cursor for the window.
- *
- *  This function sets the cursor image to be used when the cursor is over the
- *  content area of the specified window.  The set cursor will only be visible
- *  when the [cursor mode](@ref cursor_mode) of the window is
- *  `GLFW_CURSOR_NORMAL`.
- *
- *  On some platforms, the set cursor may not be visible unless the window also
- *  has input focus.
- *
- *  @param[in] window The window to set the cursor for.
- *  @param[in] cursor The cursor to set, or `NULL` to switch back to the default
- *  arrow cursor.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
-
-/*! @brief Sets the key callback.
- *
- *  This function sets the key callback of the specified window, which is called
- *  when a key is pressed, repeated or released.
- *
- *  The key functions deal with physical keys, with layout independent
- *  [key tokens](@ref keys) named after their values in the standard US keyboard
- *  layout.  If you want to input text, use the
- *  [character callback](@ref glfwSetCharCallback) instead.
- *
- *  When a window loses input focus, it will generate synthetic key release
- *  events for all pressed keys.  You can tell these events from user-generated
- *  events by the fact that the synthetic ones are generated after the focus
- *  loss event has been processed, i.e. after the
- *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
- *
- *  The scancode of a key is specific to that platform or sometimes even to that
- *  machine.  Scancodes are intended to allow users to bind keys that don't have
- *  a GLFW key token.  Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
- *  state is not saved and so it cannot be queried with @ref glfwGetKey.
- *
- *  Sometimes GLFW needs to generate synthetic key events, in which case the
- *  scancode may be zero.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new key callback, or `NULL` to remove the currently
- *  set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWkeyfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
-
-/*! @brief Sets the Unicode character callback.
- *
- *  This function sets the character callback of the specified window, which is
- *  called when a Unicode character is input.
- *
- *  The character callback is intended for Unicode text input.  As it deals with
- *  characters, it is keyboard layout dependent, whereas the
- *  [key callback](@ref glfwSetKeyCallback) is not.  Characters do not map 1:1
- *  to physical keys, as a key may produce zero, one or more characters.  If you
- *  want to know whether a specific physical key was pressed or released, see
- *  the key callback instead.
- *
- *  The character callback behaves as system text input normally does and will
- *  not be called if modifier keys are held down that would prevent normal text
- *  input on that platform, for example a Super (Command) key on macOS or Alt key
- *  on Windows.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcharfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_char
- *
- *  @since Added in version 2.4.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
-
-/*! @brief Sets the Unicode character with modifiers callback.
- *
- *  This function sets the character with modifiers callback of the specified
- *  window, which is called when a Unicode character is input regardless of what
- *  modifier keys are used.
- *
- *  The character with modifiers callback is intended for implementing custom
- *  Unicode character input.  For regular Unicode text input, see the
- *  [character callback](@ref glfwSetCharCallback).  Like the character
- *  callback, the character with modifiers callback deals with characters and is
- *  keyboard layout dependent.  Characters do not map 1:1 to physical keys, as
- *  a key may produce zero, one or more characters.  If you want to know whether
- *  a specific physical key was pressed or released, see the
- *  [key callback](@ref glfwSetKeyCallback) instead.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or an
- *  [error](@ref error_handling) occurred.
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcharmodsfun).
- *
- *  @deprecated Scheduled for removal in version 4.0.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_char
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
-
-/*! @brief Sets the mouse button callback.
- *
- *  This function sets the mouse button callback of the specified window, which
- *  is called when a mouse button is pressed or released.
- *
- *  When a window loses input focus, it will generate synthetic mouse button
- *  release events for all pressed mouse buttons.  You can tell these events
- *  from user-generated events by the fact that the synthetic ones are generated
- *  after the focus loss event has been processed, i.e. after the
- *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int button, int action, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWmousebuttonfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_mouse_button
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
-
-/*! @brief Sets the cursor position callback.
- *
- *  This function sets the cursor position callback of the specified window,
- *  which is called when the cursor is moved.  The callback is provided with the
- *  position, in screen coordinates, relative to the upper-left corner of the
- *  content area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, double xpos, double ypos);
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcursorposfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMousePosCallback`.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
-
-/*! @brief Sets the cursor enter/leave callback.
- *
- *  This function sets the cursor boundary crossing callback of the specified
- *  window, which is called when the cursor enters or leaves the content area of
- *  the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int entered)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcursorenterfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_enter
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
-
-/*! @brief Sets the scroll callback.
- *
- *  This function sets the scroll callback of the specified window, which is
- *  called when a scrolling device is used, such as a mouse wheel or scrolling
- *  area of a touchpad.
- *
- *  The scroll callback receives all scrolling input, like that from a mouse
- *  wheel or a touchpad scrolling area.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new scroll callback, or `NULL` to remove the
- *  currently set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, double xoffset, double yoffset)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWscrollfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref scrolling
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMouseWheelCallback`.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
-
-/*! @brief Sets the path drop callback.
- *
- *  This function sets the path drop callback of the specified window, which is
- *  called when one or more dragged paths are dropped on the window.
- *
- *  Because the path array and its strings may have been generated specifically
- *  for that event, they are not guaranteed to be valid after the callback has
- *  returned.  If you wish to use them after the callback returns, you need to
- *  make a deep copy.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new file drop callback, or `NULL` to remove the
- *  currently set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int path_count, const char* paths[])
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWdropfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @wayland File drop is currently unimplemented.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref path_drop
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
-
-/*! @brief Returns whether the specified joystick is present.
- *
- *  This function returns whether the specified joystick is present.
- *
- *  There is no need to call this function before other functions that accept
- *  a joystick ID, as they all check for presence before performing any other
- *  work.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick
- *
- *  @since Added in version 3.0.  Replaces `glfwGetJoystickParam`.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwJoystickPresent(int jid);
-
-/*! @brief Returns the values of all axes of the specified joystick.
- *
- *  This function returns the values of all axes of the specified joystick.
- *  Each element in the array is a value between -1.0 and 1.0.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of axis values in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of axis values, or `NULL` if the joystick is not present or
- *  an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_axis
- *
- *  @since Added in version 3.0.  Replaces `glfwGetJoystickPos`.
- *
- *  @ingroup input
- */
-GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
-
-/*! @brief Returns the state of all buttons of the specified joystick.
- *
- *  This function returns the state of all buttons of the specified joystick.
- *  Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  For backward compatibility with earlier versions that did not have @ref
- *  glfwGetJoystickHats, the button array also includes all hats, each
- *  represented as four buttons.  The hats are in the same order as returned by
- *  __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
- *  _left_.  To disable these extra buttons, set the @ref
- *  GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of button states in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of button states, or `NULL` if the joystick is not present
- *  or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_button
- *
- *  @since Added in version 2.2.
- *  @glfw3 Changed to return a dynamic array.
- *
- *  @ingroup input
- */
-GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
-
-/*! @brief Returns the state of all hats of the specified joystick.
- *
- *  This function returns the state of all hats of the specified joystick.
- *  Each element in the array is one of the following values:
- *
- *  Name                  | Value
- *  ----                  | -----
- *  `GLFW_HAT_CENTERED`   | 0
- *  `GLFW_HAT_UP`         | 1
- *  `GLFW_HAT_RIGHT`      | 2
- *  `GLFW_HAT_DOWN`       | 4
- *  `GLFW_HAT_LEFT`       | 8
- *  `GLFW_HAT_RIGHT_UP`   | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
- *  `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
- *  `GLFW_HAT_LEFT_UP`    | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
- *  `GLFW_HAT_LEFT_DOWN`  | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
- *
- *  The diagonal directions are bitwise combinations of the primary (up, right,
- *  down and left) directions and you can test for these individually by ANDing
- *  it with the corresponding direction.
- *
- *  @code
- *  if (hats[2] & GLFW_HAT_RIGHT)
- *  {
- *      // State of hat 2 could be right-up, right or right-down
- *  }
- *  @endcode
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of hat states in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of hat states, or `NULL` if the joystick is not present
- *  or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected, this function is called again for that joystick or the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_hat
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
-
-/*! @brief Returns the name of the specified joystick.
- *
- *  This function returns the name, encoded as UTF-8, of the specified joystick.
- *  The returned string is allocated and freed by GLFW.  You should not free it
- *  yourself.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
- *  is not present or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_name
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetJoystickName(int jid);
-
-/*! @brief Returns the SDL compatible GUID of the specified joystick.
- *
- *  This function returns the SDL compatible GUID, as a UTF-8 encoded
- *  hexadecimal string, of the specified joystick.  The returned string is
- *  allocated and freed by GLFW.  You should not free it yourself.
- *
- *  The GUID is what connects a joystick to a gamepad mapping.  A connected
- *  joystick will always have a GUID even if there is no gamepad mapping
- *  assigned to it.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  The GUID uses the format introduced in SDL 2.0.5.  This GUID tries to
- *  uniquely identify the make and model of a joystick but does not identify
- *  a specific unit, e.g. all wired Xbox 360 controllers will have the same
- *  GUID on that platform.  The GUID for a unit may vary between platforms
- *  depending on what hardware information the platform specific APIs provide.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
- *  is not present or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetJoystickGUID(int jid);
-
-/*! @brief Sets the user pointer of the specified joystick.
- *
- *  This function sets the user-defined pointer of the specified joystick.  The
- *  current value is retained until the joystick is disconnected.  The initial
- *  value is `NULL`.
- *
- *  This function may be called from the joystick callback, even for a joystick
- *  that is being disconnected.
- *
- *  @param[in] jid The joystick whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref joystick_userptr
- *  @sa @ref glfwGetJoystickUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
-
-/*! @brief Returns the user pointer of the specified joystick.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified joystick.  The initial value is `NULL`.
- *
- *  This function may be called from the joystick callback, even for a joystick
- *  that is being disconnected.
- *
- *  @param[in] jid The joystick whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref joystick_userptr
- *  @sa @ref glfwSetJoystickUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI void* glfwGetJoystickUserPointer(int jid);
-
-/*! @brief Returns whether the specified joystick has a gamepad mapping.
- *
- *  This function returns whether the specified joystick is both present and has
- *  a gamepad mapping.
- *
- *  If the specified joystick is present but does not have a gamepad mapping
- *  this function will return `GLFW_FALSE` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check if a joystick is present regardless of
- *  whether it has a mapping.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
- *  or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwGetGamepadState
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwJoystickIsGamepad(int jid);
-
-/*! @brief Sets the joystick configuration callback.
- *
- *  This function sets the joystick configuration callback, or removes the
- *  currently set callback.  This is called when a joystick is connected to or
- *  disconnected from the system.
- *
- *  For joystick connection and disconnection events to be delivered on all
- *  platforms, you need to call one of the [event processing](@ref events)
- *  functions.  Joystick disconnection may also be detected and the callback
- *  called by joystick functions.  The function will then return whatever it
- *  returns if the joystick is not present.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(int jid, int event)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWjoystickfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_event
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
-
-/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
- *
- *  This function parses the specified ASCII encoded string and updates the
- *  internal list with any gamepad mappings it finds.  This string may
- *  contain either a single gamepad mapping or many mappings separated by
- *  newlines.  The parser supports the full format of the `gamecontrollerdb.txt`
- *  source file including empty lines and comments.
- *
- *  See @ref gamepad_mapping for a description of the format.
- *
- *  If there is already a gamepad mapping for a given GUID in the internal list,
- *  it will be replaced by the one passed to this function.  If the library is
- *  terminated and re-initialized the internal list will revert to the built-in
- *  default.
- *
- *  @param[in] string The string containing the gamepad mappings.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwJoystickIsGamepad
- *  @sa @ref glfwGetGamepadName
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwUpdateGamepadMappings(const char* string);
-
-/*! @brief Returns the human-readable gamepad name for the specified joystick.
- *
- *  This function returns the human-readable name of the gamepad from the
- *  gamepad mapping assigned to the specified joystick.
- *
- *  If the specified joystick is not present or does not have a gamepad mapping
- *  this function will return `NULL` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check whether it is present regardless of
- *  whether it has a mapping.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded name of the gamepad, or `NULL` if the
- *  joystick is not present, does not have a mapping or an
- *  [error](@ref error_handling) occurred.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected, the gamepad mappings are updated or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwJoystickIsGamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetGamepadName(int jid);
-
-/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
- *
- *  This function retrieves the state of the specified joystick remapped to
- *  an Xbox-like gamepad.
- *
- *  If the specified joystick is not present or does not have a gamepad mapping
- *  this function will return `GLFW_FALSE` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check whether it is present regardless of
- *  whether it has a mapping.
- *
- *  The Guide button may not be available for input as it is often hooked by the
- *  system or the Steam client.
- *
- *  Not all devices have all the buttons or axes provided by @ref
- *  GLFWgamepadstate.  Unavailable buttons and axes will always report
- *  `GLFW_RELEASE` and 0.0 respectively.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] state The gamepad input state of the joystick.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
- *  connected, it has no gamepad mapping or an [error](@ref error_handling)
- *  occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwUpdateGamepadMappings
- *  @sa @ref glfwJoystickIsGamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
-
-/*! @brief Sets the clipboard to the specified string.
- *
- *  This function sets the system clipboard to the specified, UTF-8 encoded
- *  string.
- *
- *  @param[in] window Deprecated.  Any valid window or `NULL`.
- *  @param[in] string A UTF-8 encoded string.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa @ref glfwGetClipboardString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
-
-/*! @brief Returns the contents of the clipboard as a string.
- *
- *  This function returns the contents of the system clipboard, if it contains
- *  or is convertible to a UTF-8 encoded string.  If the clipboard is empty or
- *  if its contents cannot be converted, `NULL` is returned and a @ref
- *  GLFW_FORMAT_UNAVAILABLE error is generated.
- *
- *  @param[in] window Deprecated.  Any valid window or `NULL`.
- *  @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the next call to @ref
- *  glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa @ref glfwSetClipboardString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
-
-/*! @brief Returns the GLFW time.
- *
- *  This function returns the current GLFW time, in seconds.  Unless the time
- *  has been set using @ref glfwSetTime it measures time elapsed since GLFW was
- *  initialized.
- *
- *  This function and @ref glfwSetTime are helper functions on top of @ref
- *  glfwGetTimerFrequency and @ref glfwGetTimerValue.
- *
- *  The resolution of the timer is system dependent, but is usually on the order
- *  of a few micro- or nanoseconds.  It uses the highest-resolution monotonic
- *  time source on each supported platform.
- *
- *  @return The current time, in seconds, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Reading and
- *  writing of the internal base time is not atomic, so it needs to be
- *  externally synchronized with calls to @ref glfwSetTime.
- *
- *  @sa @ref time
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup input
- */
-GLFWAPI double glfwGetTime(void);
-
-/*! @brief Sets the GLFW time.
- *
- *  This function sets the current GLFW time, in seconds.  The value must be
- *  a positive finite number less than or equal to 18446744073.0, which is
- *  approximately 584.5 years.
- *
- *  This function and @ref glfwGetTime are helper functions on top of @ref
- *  glfwGetTimerFrequency and @ref glfwGetTimerValue.
- *
- *  @param[in] time The new value, in seconds.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @remark The upper limit of GLFW time is calculated as
- *  floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
- *  storing nanoseconds in 64 bits.  The limit may be increased in the future.
- *
- *  @thread_safety This function may be called from any thread.  Reading and
- *  writing of the internal base time is not atomic, so it needs to be
- *  externally synchronized with calls to @ref glfwGetTime.
- *
- *  @sa @ref time
- *
- *  @since Added in version 2.2.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetTime(double time);
-
-/*! @brief Returns the current value of the raw timer.
- *
- *  This function returns the current value of the raw timer, measured in
- *  1&nbsp;/&nbsp;frequency seconds.  To get the frequency, call @ref
- *  glfwGetTimerFrequency.
- *
- *  @return The value of the timer, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref time
- *  @sa @ref glfwGetTimerFrequency
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI uint64_t glfwGetTimerValue(void);
-
-/*! @brief Returns the frequency, in Hz, of the raw timer.
- *
- *  This function returns the frequency, in Hz, of the raw timer.
- *
- *  @return The frequency of the timer, in Hz, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref time
- *  @sa @ref glfwGetTimerValue
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI uint64_t glfwGetTimerFrequency(void);
-
-/*! @brief Makes the context of the specified window current for the calling
- *  thread.
- *
- *  This function makes the OpenGL or OpenGL ES context of the specified window
- *  current on the calling thread.  A context must only be made current on
- *  a single thread at a time and each thread can have only a single current
- *  context at a time.
- *
- *  When moving a context between threads, you must make it non-current on the
- *  old thread before making it current on the new one.
- *
- *  By default, making a context non-current implicitly forces a pipeline flush.
- *  On machines that support `GL_KHR_context_flush_control`, you can control
- *  whether a context performs this flush by setting the
- *  [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
- *  hint.
- *
- *  The specified window must have an OpenGL or OpenGL ES context.  Specifying
- *  a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
- *  error.
- *
- *  @param[in] window The window whose context to make current, or `NULL` to
- *  detach the current context.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_current
- *  @sa @ref glfwGetCurrentContext
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
-
-/*! @brief Returns the window whose context is current on the calling thread.
- *
- *  This function returns the window whose OpenGL or OpenGL ES context is
- *  current on the calling thread.
- *
- *  @return The window whose context is current, or `NULL` if no window's
- *  context is current.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_current
- *  @sa @ref glfwMakeContextCurrent
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
-
-/*! @brief Swaps the front and back buffers of the specified window.
- *
- *  This function swaps the front and back buffers of the specified window when
- *  rendering with OpenGL or OpenGL ES.  If the swap interval is greater than
- *  zero, the GPU driver waits the specified number of screen updates before
- *  swapping the buffers.
- *
- *  The specified window must have an OpenGL or OpenGL ES context.  Specifying
- *  a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
- *  error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see `vkQueuePresentKHR` instead.
- *
- *  @param[in] window The window whose buffers to swap.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark __EGL:__ The context of the specified window must be current on the
- *  calling thread.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref buffer_swap
- *  @sa @ref glfwSwapInterval
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
-
-/*! @brief Sets the swap interval for the current context.
- *
- *  This function sets the swap interval for the current OpenGL or OpenGL ES
- *  context, i.e. the number of screen updates to wait from the time @ref
- *  glfwSwapBuffers was called before swapping the buffers and returning.  This
- *  is sometimes called _vertical synchronization_, _vertical retrace
- *  synchronization_ or just _vsync_.
- *
- *  A context that supports either of the `WGL_EXT_swap_control_tear` and
- *  `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
- *  intervals, which allows the driver to swap immediately even if a frame
- *  arrives a little bit late.  You can check for these extensions with @ref
- *  glfwExtensionSupported.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see the present mode of your swapchain instead.
- *
- *  @param[in] interval The minimum number of screen updates to wait for
- *  until the buffers are swapped by @ref glfwSwapBuffers.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark This function is not called during context creation, leaving the
- *  swap interval set to whatever is the default on that platform.  This is done
- *  because some swap interval extensions used by GLFW do not allow the swap
- *  interval to be reset to zero once it has been set to a non-zero value.
- *
- *  @remark Some GPU drivers do not honor the requested swap interval, either
- *  because of a user setting that overrides the application's request or due to
- *  bugs in the driver.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref buffer_swap
- *  @sa @ref glfwSwapBuffers
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI void glfwSwapInterval(int interval);
-
-/*! @brief Returns whether the specified extension is available.
- *
- *  This function returns whether the specified
- *  [API extension](@ref context_glext) is supported by the current OpenGL or
- *  OpenGL ES context.  It searches both for client API extension and context
- *  creation API extensions.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  As this functions retrieves and searches one or more extension strings each
- *  call, it is recommended that you cache its results if it is going to be used
- *  frequently.  The extension strings will not change during the lifetime of
- *  a context, so there is no danger in doing this.
- *
- *  This function does not apply to Vulkan.  If you are using Vulkan, see @ref
- *  glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
- *  and `vkEnumerateDeviceExtensionProperties` instead.
- *
- *  @param[in] extension The ASCII encoded name of the extension.
- *  @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
- *  otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwGetProcAddress
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI int glfwExtensionSupported(const char* extension);
-
-/*! @brief Returns the address of the specified function for the current
- *  context.
- *
- *  This function returns the address of the specified OpenGL or OpenGL ES
- *  [core or extension function](@ref context_glext), if it is supported
- *  by the current context.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
- *  `vkGetDeviceProcAddr` instead.
- *
- *  @param[in] procname The ASCII encoded name of the function.
- *  @return The address of the function, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark The address of a given function is not guaranteed to be the same
- *  between contexts.
- *
- *  @remark This function may return a non-`NULL` address despite the
- *  associated version or extension not being available.  Always check the
- *  context version or extension string first.
- *
- *  @pointer_lifetime The returned function pointer is valid until the context
- *  is destroyed or the library is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwExtensionSupported
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
-
-/*! @brief Returns whether the Vulkan loader and an ICD have been found.
- *
- *  This function returns whether the Vulkan loader and any minimally functional
- *  ICD have been found.
- *
- *  The availability of a Vulkan loader and even an ICD does not by itself
- *  guarantee that surface creation or even instance creation is possible.
- *  For example, on Fermi systems Nvidia will install an ICD that provides no
- *  actual Vulkan support.  Call @ref glfwGetRequiredInstanceExtensions to check
- *  whether the extensions necessary for Vulkan surface creation are available
- *  and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
- *  family of a physical device supports image presentation.
- *
- *  @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
- *  otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_support
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI int glfwVulkanSupported(void);
-
-/*! @brief Returns the Vulkan instance extensions required by GLFW.
- *
- *  This function returns an array of names of Vulkan instance extensions required
- *  by GLFW for creating Vulkan surfaces for GLFW windows.  If successful, the
- *  list will always contain `VK_KHR_surface`, so if you don't require any
- *  additional extensions you can pass this list directly to the
- *  `VkInstanceCreateInfo` struct.
- *
- *  If Vulkan is not available on the machine, this function returns `NULL` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available.
- *
- *  If Vulkan is available but no set of extensions allowing window surface
- *  creation was found, this function returns `NULL`.  You may still use Vulkan
- *  for off-screen rendering and compute work.
- *
- *  @param[out] count Where to store the number of extensions in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of ASCII encoded extension names, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_API_UNAVAILABLE.
- *
- *  @remark Additional extensions may be required by future versions of GLFW.
- *  You should check if any extensions you wish to enable are already in the
- *  returned array, as it is an error to specify an extension more than once in
- *  the `VkInstanceCreateInfo` struct.
- *
- *  @remark @macos This function currently supports either the
- *  `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
- *  extension.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  library is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_ext
- *  @sa @ref glfwCreateWindowSurface
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
-
-#if defined(VK_VERSION_1_0)
-
-/*! @brief Returns the address of the specified Vulkan instance function.
- *
- *  This function returns the address of the specified Vulkan core or extension
- *  function for the specified instance.  If instance is set to `NULL` it can
- *  return any function exported from the Vulkan loader, including at least the
- *  following functions:
- *
- *  - `vkEnumerateInstanceExtensionProperties`
- *  - `vkEnumerateInstanceLayerProperties`
- *  - `vkCreateInstance`
- *  - `vkGetInstanceProcAddr`
- *
- *  If Vulkan is not available on the machine, this function returns `NULL` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available.
- *
- *  This function is equivalent to calling `vkGetInstanceProcAddr` with
- *  a platform-specific query of the Vulkan loader as a fallback.
- *
- *  @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
- *  functions related to instance creation.
- *  @param[in] procname The ASCII encoded name of the function.
- *  @return The address of the function, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_API_UNAVAILABLE.
- *
- *  @pointer_lifetime The returned function pointer is valid until the library
- *  is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_proc
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
-
-/*! @brief Returns whether the specified queue family can present images.
- *
- *  This function returns whether the specified queue family of the specified
- *  physical device supports presentation to the platform GLFW was built for.
- *
- *  If Vulkan or the required window surface creation instance extensions are
- *  not available on the machine, or if the specified instance was not created
- *  with the required extensions, this function returns `GLFW_FALSE` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available and @ref
- *  glfwGetRequiredInstanceExtensions to check what instance extensions are
- *  required.
- *
- *  @param[in] instance The instance that the physical device belongs to.
- *  @param[in] device The physical device that the queue family belongs to.
- *  @param[in] queuefamily The index of the queue family to query.
- *  @return `GLFW_TRUE` if the queue family supports presentation, or
- *  `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos This function currently always returns `GLFW_TRUE`, as the
- *  `VK_MVK_macos_surface` extension does not provide
- *  a `vkGetPhysicalDevice*PresentationSupport` type function.
- *
- *  @thread_safety This function may be called from any thread.  For
- *  synchronization details of Vulkan objects, see the Vulkan specification.
- *
- *  @sa @ref vulkan_present
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
-
-/*! @brief Creates a Vulkan surface for the specified window.
- *
- *  This function creates a Vulkan surface for the specified window.
- *
- *  If the Vulkan loader or at least one minimally functional ICD were not found,
- *  this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
- *  GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported to check whether
- *  Vulkan is at least minimally available.
- *
- *  If the required window surface creation instance extensions are not
- *  available or if the specified instance was not created with these extensions
- *  enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref
- *  glfwGetRequiredInstanceExtensions to check what instance extensions are
- *  required.
- *
- *  The window surface cannot be shared with another API so the window must
- *  have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
- *  set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
- *  and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
- *
- *  The window surface must be destroyed before the specified Vulkan instance.
- *  It is the responsibility of the caller to destroy the window surface.  GLFW
- *  does not destroy it for you.  Call `vkDestroySurfaceKHR` to destroy the
- *  surface.
- *
- *  @param[in] instance The Vulkan instance to create the surface in.
- *  @param[in] window The window to create the surface for.
- *  @param[in] allocator The allocator to use, or `NULL` to use the default
- *  allocator.
- *  @param[out] surface Where to store the handle of the surface.  This is set
- *  to `VK_NULL_HANDLE` if an error occurred.
- *  @return `VK_SUCCESS` if successful, or a Vulkan error code if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
- *
- *  @remark If an error occurs before the creation call is made, GLFW returns
- *  the Vulkan error code most appropriate for the error.  Appropriate use of
- *  @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
- *  eliminate almost all occurrences of these errors.
- *
- *  @remark @macos This function currently only supports the
- *  `VK_MVK_macos_surface` extension from MoltenVK.
- *
- *  @remark @macos This function creates and sets a `CAMetalLayer` instance for
- *  the window content view, which is required for MoltenVK to function.
- *
- *  @thread_safety This function may be called from any thread.  For
- *  synchronization details of Vulkan objects, see the Vulkan specification.
- *
- *  @sa @ref vulkan_surface
- *  @sa @ref glfwGetRequiredInstanceExtensions
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
-
-#endif /*VK_VERSION_1_0*/
-
-
-/*************************************************************************
- * Global definition cleanup
- *************************************************************************/
-
-/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
-
-#ifdef GLFW_WINGDIAPI_DEFINED
- #undef WINGDIAPI
- #undef GLFW_WINGDIAPI_DEFINED
-#endif
-
-#ifdef GLFW_CALLBACK_DEFINED
- #undef CALLBACK
- #undef GLFW_CALLBACK_DEFINED
-#endif
-
-/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
- * defined by some gl.h variants (OpenBSD) so define it after if needed.
- */
-#ifndef GLAPIENTRY
- #define GLAPIENTRY APIENTRY
-#endif
-
-/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _glfw3_h_ */
-
diff --git a/raylib/external/glfw/include/GLFW/glfw3native.h b/raylib/external/glfw/include/GLFW/glfw3native.h
deleted file mode 100644 (file)
index ba6a16b..0000000
+++ /dev/null
@@ -1,531 +0,0 @@
-/*************************************************************************
- * GLFW 3.4 - www.glfw.org
- * A library for OpenGL, window and input
- *------------------------------------------------------------------------
- * Copyright (c) 2002-2006 Marcus Geelnard
- * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would
- *    be appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- *    be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- *    distribution.
- *
- *************************************************************************/
-
-#ifndef _glfw3_native_h_
-#define _glfw3_native_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*************************************************************************
- * Doxygen documentation
- *************************************************************************/
-
-/*! @file glfw3native.h
- *  @brief The header of the native access functions.
- *
- *  This is the header file of the native access functions.  See @ref native for
- *  more information.
- */
-/*! @defgroup native Native access
- *  @brief Functions related to accessing native handles.
- *
- *  **By using the native access functions you assert that you know what you're
- *  doing and how to fix problems caused by using them.  If you don't, you
- *  shouldn't be using them.**
- *
- *  Before the inclusion of @ref glfw3native.h, you may define zero or more
- *  window system API macro and zero or more context creation API macros.
- *
- *  The chosen backends must match those the library was compiled for.  Failure
- *  to do this will cause a link-time error.
- *
- *  The available window API macros are:
- *  * `GLFW_EXPOSE_NATIVE_WIN32`
- *  * `GLFW_EXPOSE_NATIVE_COCOA`
- *  * `GLFW_EXPOSE_NATIVE_X11`
- *  * `GLFW_EXPOSE_NATIVE_WAYLAND`
- *
- *  The available context API macros are:
- *  * `GLFW_EXPOSE_NATIVE_WGL`
- *  * `GLFW_EXPOSE_NATIVE_NSGL`
- *  * `GLFW_EXPOSE_NATIVE_GLX`
- *  * `GLFW_EXPOSE_NATIVE_EGL`
- *  * `GLFW_EXPOSE_NATIVE_OSMESA`
- *
- *  These macros select which of the native access functions that are declared
- *  and which platform-specific headers to include.  It is then up your (by
- *  definition platform-specific) code to handle which of these should be
- *  defined.
- */
-
-
-/*************************************************************************
- * System headers and types
- *************************************************************************/
-
-#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
- // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
- // example to allow applications to correctly declare a GL_ARB_debug_output
- // callback) but windows.h assumes no one will define APIENTRY before it does
- #if defined(GLFW_APIENTRY_DEFINED)
-  #undef APIENTRY
-  #undef GLFW_APIENTRY_DEFINED
- #endif
-// @raysan5: Actually, only HWND handler needs to be defined
-// Including windows.h could suppose symbols re-definition issues (i.e Rectangle type)
-//#include <windows.h>
- typedef void *PVOID;
- typedef PVOID HANDLE;
- typedef HANDLE HWND;
-#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
- #include <ApplicationServices/ApplicationServices.h>
- #if defined(__OBJC__)
-  #import <Cocoa/Cocoa.h>
- #else
-  #include <ApplicationServices/ApplicationServices.h>
-  typedef void* id;
- #endif
-#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
- #include <X11/Xlib.h>
- #include <X11/extensions/Xrandr.h>
-#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
- #include <wayland-client.h>
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WGL)
- /* WGL is declared by windows.h */
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_NSGL)
- /* NSGL is declared by Cocoa.h */
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_GLX)
- #include <GL/glx.h>
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_EGL)
- #include <EGL/egl.h>
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
- #include <GL/osmesa.h>
-#endif
-
-
-/*************************************************************************
- * Functions
- *************************************************************************/
-
-#if defined(GLFW_EXPOSE_NATIVE_WIN32)
-/*! @brief Returns the adapter device name of the specified monitor.
- *
- *  @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
- *  of the specified monitor, or `NULL` if an [error](@ref error_handling)
- *  occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
-
-/*! @brief Returns the display device name of the specified monitor.
- *
- *  @return The UTF-8 encoded display device name (for example
- *  `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `HWND` of the specified window.
- *
- *  @return The `HWND` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WGL)
-/*! @brief Returns the `HGLRC` of the specified window.
- *
- *  @return The `HGLRC` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_COCOA)
-/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
- *
- *  @return The `CGDirectDisplayID` of the specified monitor, or
- *  `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `NSWindow` of the specified window.
- *
- *  @return The `NSWindow` of the specified window, or `nil` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_NSGL)
-/*! @brief Returns the `NSOpenGLContext` of the specified window.
- *
- *  @return The `NSOpenGLContext` of the specified window, or `nil` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_X11)
-/*! @brief Returns the `Display` used by GLFW.
- *
- *  @return The `Display` used by GLFW, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI Display* glfwGetX11Display(void);
-
-/*! @brief Returns the `RRCrtc` of the specified monitor.
- *
- *  @return The `RRCrtc` of the specified monitor, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
-
-/*! @brief Returns the `RROutput` of the specified monitor.
- *
- *  @return The `RROutput` of the specified monitor, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `Window` of the specified window.
- *
- *  @return The `Window` of the specified window, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
-
-/*! @brief Sets the current primary selection to the specified string.
- *
- *  @param[in] string A UTF-8 encoded string.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa glfwGetX11SelectionString
- *  @sa glfwSetClipboardString
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI void glfwSetX11SelectionString(const char* string);
-
-/*! @brief Returns the contents of the current primary selection as a string.
- *
- *  If the selection is empty or if its contents cannot be converted, `NULL`
- *  is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
- *
- *  @return The contents of the selection as a UTF-8 encoded string, or `NULL`
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW. You
- *  should not free it yourself. It is valid until the next call to @ref
- *  glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
- *  library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa glfwSetX11SelectionString
- *  @sa glfwGetClipboardString
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetX11SelectionString(void);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_GLX)
-/*! @brief Returns the `GLXContext` of the specified window.
- *
- *  @return The `GLXContext` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
-
-/*! @brief Returns the `GLXWindow` of the specified window.
- *
- *  @return The `GLXWindow` of the specified window, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
-/*! @brief Returns the `struct wl_display*` used by GLFW.
- *
- *  @return The `struct wl_display*` used by GLFW, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
-
-/*! @brief Returns the `struct wl_output*` of the specified monitor.
- *
- *  @return The `struct wl_output*` of the specified monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the main `struct wl_surface*` of the specified window.
- *
- *  @return The main `struct wl_surface*` of the specified window, or `NULL` if
- *  an [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_EGL)
-/*! @brief Returns the `EGLDisplay` used by GLFW.
- *
- *  @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
-
-/*! @brief Returns the `EGLContext` of the specified window.
- *
- *  @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
-
-/*! @brief Returns the `EGLSurface` of the specified window.
- *
- *  @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
-/*! @brief Retrieves the color buffer associated with the specified window.
- *
- *  @param[in] window The window whose color buffer to retrieve.
- *  @param[out] width Where to store the width of the color buffer, or `NULL`.
- *  @param[out] height Where to store the height of the color buffer, or `NULL`.
- *  @param[out] format Where to store the OSMesa pixel format of the color
- *  buffer, or `NULL`.
- *  @param[out] buffer Where to store the address of the color buffer, or
- *  `NULL`.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
-
-/*! @brief Retrieves the depth buffer associated with the specified window.
- *
- *  @param[in] window The window whose depth buffer to retrieve.
- *  @param[out] width Where to store the width of the depth buffer, or `NULL`.
- *  @param[out] height Where to store the height of the depth buffer, or `NULL`.
- *  @param[out] bytesPerValue Where to store the number of bytes per depth
- *  buffer element, or `NULL`.
- *  @param[out] buffer Where to store the address of the depth buffer, or
- *  `NULL`.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
-
-/*! @brief Returns the `OSMesaContext` of the specified window.
- *
- *  @return The `OSMesaContext` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _glfw3_native_h_ */
-
diff --git a/raylib/external/glfw/src/CMakeLists.txt b/raylib/external/glfw/src/CMakeLists.txt
deleted file mode 100644 (file)
index 8db786e..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-
-set(common_HEADERS internal.h mappings.h
-                   "${GLFW_BINARY_DIR}/src/glfw_config.h"
-                   "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
-                   "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
-set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
-
-if (_GLFW_COCOA)
-    set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
-                     posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m
-                     cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c
-                     nsgl_context.m egl_context.c osmesa_context.c)
-elseif (_GLFW_WIN32)
-    set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h
-                     wgl_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_joystick.c
-                     win32_monitor.c win32_time.c win32_thread.c win32_window.c
-                     wgl_context.c egl_context.c osmesa_context.c)
-elseif (_GLFW_X11)
-    set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h
-                     posix_thread.h glx_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c
-                     xkb_unicode.c posix_time.c posix_thread.c glx_context.c
-                     egl_context.c osmesa_context.c)
-elseif (_GLFW_WAYLAND)
-    set(glfw_HEADERS ${common_HEADERS} wl_platform.h
-                     posix_time.h posix_thread.h xkb_unicode.h egl_context.h
-                     osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c
-                     posix_time.c posix_thread.c xkb_unicode.c
-                     egl_context.c osmesa_context.c)
-
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
-        BASENAME xdg-shell)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
-        BASENAME xdg-decoration)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
-        BASENAME viewporter)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
-        BASENAME relative-pointer-unstable-v1)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
-        BASENAME pointer-constraints-unstable-v1)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
-        BASENAME idle-inhibit-unstable-v1)
-elseif (_GLFW_OSMESA)
-    set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h
-                     posix_time.h posix_thread.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c
-                     null_joystick.c posix_time.c posix_thread.c osmesa_context.c)
-endif()
-
-if (_GLFW_X11 OR _GLFW_WAYLAND)
-    if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-        set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
-        set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
-    else()
-        set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h)
-        set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c)
-    endif()
-endif()
-
-if (APPLE)
-    # For some reason, CMake doesn't know about .m
-    set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
-endif()
-
-# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
-# for all source files that VS will build
-if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
-    "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
-    "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
-
-    if (WIN32)
-        set(windows_SOURCES ${glfw_SOURCES})
-    else()
-        set(windows_SOURCES ${common_SOURCES})
-    endif()
-    set_source_files_properties(${windows_SOURCES} PROPERTIES
-        COMPILE_FLAGS -Wdeclaration-after-statement)
-endif()
-
-add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS})
-add_library(glfw $<TARGET_OBJECTS:glfw_objlib>)
-set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
-set_target_properties(glfw PROPERTIES
-                      OUTPUT_NAME ${GLFW_LIB_NAME}
-                      VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
-                      SOVERSION ${GLFW_VERSION_MAJOR}
-                      FOLDER "GLFW3")
-
-if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
-    ${CMAKE_VERSION} VERSION_GREATER "3.1.0")
-
-    set_target_properties(glfw_objlib PROPERTIES C_STANDARD 99)
-else()
-    # Remove this fallback when removing support for CMake version less than 3.1
-    target_compile_options(glfw_objlib PRIVATE
-                           "$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
-                           "$<$<C_COMPILER_ID:Clang>:-std=c99>"
-                           "$<$<C_COMPILER_ID:GNU>:-std=c99>")
-endif()
-
-target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H)
-target_include_directories(glfw_objlib PUBLIC
-                           "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
-                           "$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
-target_include_directories(glfw PUBLIC
-                           "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
-                           "$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
-target_include_directories(glfw_objlib PRIVATE
-                           "${GLFW_SOURCE_DIR}/src"
-                           "${GLFW_BINARY_DIR}/src"
-                           ${glfw_INCLUDE_DIRS})
-
-# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
-# the inclusion of stddef.h (by glfw3.h), which is itself included before
-# win32_platform.h.  We define them here until a saner solution can be found
-# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
-target_compile_definitions(glfw_objlib PRIVATE
-                           "$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>")
-
-# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
-target_compile_options(glfw_objlib PRIVATE
-                       "$<$<C_COMPILER_ID:AppleClang>:-Wall>"
-                       "$<$<C_COMPILER_ID:Clang>:-Wall>"
-                       "$<$<C_COMPILER_ID:GNU>:-Wall>")
-
-if (BUILD_SHARED_LIBS)
-    if (WIN32)
-        if (MINGW)
-            # Remove the dependency on the shared version of libgcc
-            # NOTE: MinGW-w64 has the correct default but MinGW needs this
-            target_link_options(glfw PRIVATE "-static-libgcc")
-
-            # Remove the lib prefix on the DLL (but not the import library)
-            set_target_properties(glfw PROPERTIES PREFIX "")
-
-            # Add a suffix to the import library to avoid naming conflicts
-            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a")
-        else()
-            # Add a suffix to the import library to avoid naming conflicts
-            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
-        endif()
-
-        target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL)
-    elseif (APPLE)
-        # Add -fno-common to work around a bug in Apple's GCC
-        target_compile_options(glfw_objlib PRIVATE "-fno-common")
-
-        set_target_properties(glfw PROPERTIES
-                              INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
-    endif()
-
-    if (UNIX)
-        # Hide symbols not explicitly tagged for export from the shared library
-        target_compile_options(glfw_objlib PRIVATE "-fvisibility=hidden")
-    endif()
-
-    target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
-else()
-    target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
-endif()
-
-if (MSVC)
-    target_compile_definitions(glfw_objlib PRIVATE _CRT_SECURE_NO_WARNINGS)
-endif()
-
-if (GLFW_INSTALL)
-    install(TARGETS glfw
-            EXPORT glfwTargets
-            RUNTIME DESTINATION "bin"
-            ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-endif()
-
diff --git a/raylib/external/glfw/src/cocoa_init.m b/raylib/external/glfw/src/cocoa_init.m
deleted file mode 100644 (file)
index 7cad8b8..0000000
+++ /dev/null
@@ -1,619 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-#include <sys/param.h> // For MAXPATHLEN
-
-// Needed for _NSGetProgname
-#include <crt_externs.h>
-
-// Change to our application bundle's resources directory, if present
-//
-static void changeToResourcesDirectory(void)
-{
-    char resourcesPath[MAXPATHLEN];
-
-    CFBundleRef bundle = CFBundleGetMainBundle();
-    if (!bundle)
-        return;
-
-    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
-
-    CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
-    if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
-    {
-        CFRelease(last);
-        CFRelease(resourcesURL);
-        return;
-    }
-
-    CFRelease(last);
-
-    if (!CFURLGetFileSystemRepresentation(resourcesURL,
-                                          true,
-                                          (UInt8*) resourcesPath,
-                                          MAXPATHLEN))
-    {
-        CFRelease(resourcesURL);
-        return;
-    }
-
-    CFRelease(resourcesURL);
-
-    chdir(resourcesPath);
-}
-
-// Set up the menu bar (manually)
-// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
-// could go away at any moment, lots of stuff that really should be
-// localize(d|able), etc.  Add a nib to save us this horror.
-//
-static void createMenuBar(void)
-{
-    size_t i;
-    NSString* appName = nil;
-    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
-    NSString* nameKeys[] =
-    {
-        @"CFBundleDisplayName",
-        @"CFBundleName",
-        @"CFBundleExecutable",
-    };
-
-    // Try to figure out what the calling application is called
-
-    for (i = 0;  i < sizeof(nameKeys) / sizeof(nameKeys[0]);  i++)
-    {
-        id name = bundleInfo[nameKeys[i]];
-        if (name &&
-            [name isKindOfClass:[NSString class]] &&
-            ![name isEqualToString:@""])
-        {
-            appName = name;
-            break;
-        }
-    }
-
-    if (!appName)
-    {
-        char** progname = _NSGetProgname();
-        if (progname && *progname)
-            appName = @(*progname);
-        else
-            appName = @"GLFW Application";
-    }
-
-    NSMenu* bar = [[NSMenu alloc] init];
-    [NSApp setMainMenu:bar];
-
-    NSMenuItem* appMenuItem =
-        [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
-    NSMenu* appMenu = [[NSMenu alloc] init];
-    [appMenuItem setSubmenu:appMenu];
-
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
-                       action:@selector(orderFrontStandardAboutPanel:)
-                keyEquivalent:@""];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    NSMenu* servicesMenu = [[NSMenu alloc] init];
-    [NSApp setServicesMenu:servicesMenu];
-    [[appMenu addItemWithTitle:@"Services"
-                       action:NULL
-                keyEquivalent:@""] setSubmenu:servicesMenu];
-    [servicesMenu release];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
-                       action:@selector(hide:)
-                keyEquivalent:@"h"];
-    [[appMenu addItemWithTitle:@"Hide Others"
-                       action:@selector(hideOtherApplications:)
-                keyEquivalent:@"h"]
-        setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
-    [appMenu addItemWithTitle:@"Show All"
-                       action:@selector(unhideAllApplications:)
-                keyEquivalent:@""];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
-                       action:@selector(terminate:)
-                keyEquivalent:@"q"];
-
-    NSMenuItem* windowMenuItem =
-        [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
-    [bar release];
-    NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-    [NSApp setWindowsMenu:windowMenu];
-    [windowMenuItem setSubmenu:windowMenu];
-
-    [windowMenu addItemWithTitle:@"Minimize"
-                          action:@selector(performMiniaturize:)
-                   keyEquivalent:@"m"];
-    [windowMenu addItemWithTitle:@"Zoom"
-                          action:@selector(performZoom:)
-                   keyEquivalent:@""];
-    [windowMenu addItem:[NSMenuItem separatorItem]];
-    [windowMenu addItemWithTitle:@"Bring All to Front"
-                          action:@selector(arrangeInFront:)
-                   keyEquivalent:@""];
-
-    // TODO: Make this appear at the bottom of the menu (for consistency)
-    [windowMenu addItem:[NSMenuItem separatorItem]];
-    [[windowMenu addItemWithTitle:@"Enter Full Screen"
-                           action:@selector(toggleFullScreen:)
-                    keyEquivalent:@"f"]
-     setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
-
-    // Prior to Snow Leopard, we need to use this oddly-named semi-private API
-    // to get the application menu working properly.
-    SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
-    [NSApp performSelector:setAppleMenuSelector withObject:appMenu];
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
-    memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
-
-    _glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
-    _glfw.ns.keycodes[0x12] = GLFW_KEY_1;
-    _glfw.ns.keycodes[0x13] = GLFW_KEY_2;
-    _glfw.ns.keycodes[0x14] = GLFW_KEY_3;
-    _glfw.ns.keycodes[0x15] = GLFW_KEY_4;
-    _glfw.ns.keycodes[0x17] = GLFW_KEY_5;
-    _glfw.ns.keycodes[0x16] = GLFW_KEY_6;
-    _glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
-    _glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
-    _glfw.ns.keycodes[0x19] = GLFW_KEY_9;
-    _glfw.ns.keycodes[0x00] = GLFW_KEY_A;
-    _glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
-    _glfw.ns.keycodes[0x08] = GLFW_KEY_C;
-    _glfw.ns.keycodes[0x02] = GLFW_KEY_D;
-    _glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
-    _glfw.ns.keycodes[0x03] = GLFW_KEY_F;
-    _glfw.ns.keycodes[0x05] = GLFW_KEY_G;
-    _glfw.ns.keycodes[0x04] = GLFW_KEY_H;
-    _glfw.ns.keycodes[0x22] = GLFW_KEY_I;
-    _glfw.ns.keycodes[0x26] = GLFW_KEY_J;
-    _glfw.ns.keycodes[0x28] = GLFW_KEY_K;
-    _glfw.ns.keycodes[0x25] = GLFW_KEY_L;
-    _glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
-    _glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
-    _glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
-    _glfw.ns.keycodes[0x23] = GLFW_KEY_P;
-    _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
-    _glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
-    _glfw.ns.keycodes[0x01] = GLFW_KEY_S;
-    _glfw.ns.keycodes[0x11] = GLFW_KEY_T;
-    _glfw.ns.keycodes[0x20] = GLFW_KEY_U;
-    _glfw.ns.keycodes[0x09] = GLFW_KEY_V;
-    _glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
-    _glfw.ns.keycodes[0x07] = GLFW_KEY_X;
-    _glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
-    _glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
-
-    _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
-    _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
-    _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
-    _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
-    _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
-    _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
-    _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
-    _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
-    _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
-    _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
-
-    _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
-    _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
-    _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
-    _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
-    _glfw.ns.keycodes[0x77] = GLFW_KEY_END;
-    _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
-    _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
-    _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
-    _glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
-    _glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
-    _glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
-    _glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
-    _glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
-    _glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
-    _glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
-    _glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
-    _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
-    _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
-    _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
-    _glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
-    _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
-    _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
-    _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
-    _glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
-    _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
-    _glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
-    _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
-    _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
-    _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
-    _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
-    _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
-    _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
-    _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
-    _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
-    _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
-    _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
-    _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
-    _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
-    _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
-    _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
-    _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
-    _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
-    _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
-    _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
-
-    _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
-    _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
-    _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
-    _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
-    _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
-    _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
-    _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
-    _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
-    _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
-    _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
-    _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
-    _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
-    _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
-    _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
-    _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
-    _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
-    _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
-
-    for (scancode = 0;  scancode < 256;  scancode++)
-    {
-        // Store the reverse translation for faster key name lookup
-        if (_glfw.ns.keycodes[scancode] >= 0)
-            _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
-    }
-}
-
-// Retrieve Unicode data for the current keyboard layout
-//
-static GLFWbool updateUnicodeDataNS(void)
-{
-    if (_glfw.ns.inputSource)
-    {
-        CFRelease(_glfw.ns.inputSource);
-        _glfw.ns.inputSource = NULL;
-        _glfw.ns.unicodeData = nil;
-    }
-
-    _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
-    if (!_glfw.ns.inputSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve keyboard layout input source");
-        return GLFW_FALSE;
-    }
-
-    _glfw.ns.unicodeData =
-        TISGetInputSourceProperty(_glfw.ns.inputSource,
-                                  kTISPropertyUnicodeKeyLayoutData);
-    if (!_glfw.ns.unicodeData)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve keyboard layout Unicode data");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Load HIToolbox.framework and the TIS symbols we need from it
-//
-static GLFWbool initializeTIS(void)
-{
-    // This works only because Cocoa has already loaded it properly
-    _glfw.ns.tis.bundle =
-        CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
-    if (!_glfw.ns.tis.bundle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to load HIToolbox.framework");
-        return GLFW_FALSE;
-    }
-
-    CFStringRef* kPropertyUnicodeKeyLayoutData =
-        CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
-                                      CFSTR("kTISPropertyUnicodeKeyLayoutData"));
-    _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
-    _glfw.ns.tis.GetInputSourceProperty =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("TISGetInputSourceProperty"));
-    _glfw.ns.tis.GetKbdType =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("LMGetKbdType"));
-
-    if (!kPropertyUnicodeKeyLayoutData ||
-        !TISCopyCurrentKeyboardLayoutInputSource ||
-        !TISGetInputSourceProperty ||
-        !LMGetKbdType)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to load TIS API symbols");
-        return GLFW_FALSE;
-    }
-
-    _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
-        *kPropertyUnicodeKeyLayoutData;
-
-    return updateUnicodeDataNS();
-}
-
-@interface GLFWHelper : NSObject
-@end
-
-@implementation GLFWHelper
-
-- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
-{
-    updateUnicodeDataNS();
-}
-
-- (void)doNothing:(id)object
-{
-}
-
-@end // GLFWHelper
-
-@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
-@end
-
-@implementation GLFWApplicationDelegate
-
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
-{
-    _GLFWwindow* window;
-
-    for (window = _glfw.windowListHead;  window;  window = window->next)
-        _glfwInputWindowCloseRequest(window);
-
-    return NSTerminateCancel;
-}
-
-- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
-{
-    _GLFWwindow* window;
-
-    for (window = _glfw.windowListHead;  window;  window = window->next)
-    {
-        if (window->context.client != GLFW_NO_API)
-            [window->context.nsgl.object update];
-    }
-
-    _glfwPollMonitorsNS();
-}
-
-- (void)applicationWillFinishLaunching:(NSNotification *)notification
-{
-    if (_glfw.hints.init.ns.menubar)
-    {
-        // In case we are unbundled, make us a proper UI application
-        [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-
-        // Menu bar setup must go between sharedApplication and finishLaunching
-        // in order to properly emulate the behavior of NSApplicationMain
-
-        if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
-        {
-            [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
-                                          owner:NSApp
-                                topLevelObjects:&_glfw.ns.nibObjects];
-        }
-        else
-            createMenuBar();
-    }
-}
-
-- (void)applicationDidFinishLaunching:(NSNotification *)notification
-{
-    _glfwPlatformPostEmptyEvent();
-    [NSApp stop:nil];
-}
-
-- (void)applicationDidHide:(NSNotification *)notification
-{
-    int i;
-
-    for (i = 0;  i < _glfw.monitorCount;  i++)
-        _glfwRestoreVideoModeNS(_glfw.monitors[i]);
-}
-
-@end // GLFWApplicationDelegate
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void* _glfwLoadLocalVulkanLoaderNS(void)
-{
-    CFBundleRef bundle = CFBundleGetMainBundle();
-    if (!bundle)
-        return NULL;
-
-    CFURLRef url =
-        CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib"));
-    if (!url)
-        return NULL;
-
-    char path[PATH_MAX];
-    void* handle = NULL;
-
-    if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
-        handle = _glfw_dlopen(path);
-
-    CFRelease(url);
-    return handle;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    @autoreleasepool {
-
-    _glfw.ns.helper = [[GLFWHelper alloc] init];
-
-    [NSThread detachNewThreadSelector:@selector(doNothing:)
-                             toTarget:_glfw.ns.helper
-                           withObject:nil];
-
-    [NSApplication sharedApplication];
-
-    _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
-    if (_glfw.ns.delegate == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create application delegate");
-        return GLFW_FALSE;
-    }
-
-    [NSApp setDelegate:_glfw.ns.delegate];
-
-    NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
-    {
-        if ([event modifierFlags] & NSEventModifierFlagCommand)
-            [[NSApp keyWindow] sendEvent:event];
-
-        return event;
-    };
-
-    _glfw.ns.keyUpMonitor =
-        [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
-                                              handler:block];
-
-    if (_glfw.hints.init.ns.chdir)
-        changeToResourcesDirectory();
-
-    // Press and Hold prevents some keys from emitting repeated characters
-    NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
-    [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
-
-    [[NSNotificationCenter defaultCenter]
-        addObserver:_glfw.ns.helper
-           selector:@selector(selectedKeyboardInputSourceChanged:)
-               name:NSTextInputContextKeyboardSelectionDidChangeNotification
-             object:nil];
-
-    createKeyTables();
-
-    _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
-    if (!_glfw.ns.eventSource)
-        return GLFW_FALSE;
-
-    CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
-
-    if (!initializeTIS())
-        return GLFW_FALSE;
-
-    _glfwInitTimerNS();
-
-    _glfwPollMonitorsNS();
-
-    if (![[NSRunningApplication currentApplication] isFinishedLaunching])
-        [NSApp run];
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformTerminate(void)
-{
-    @autoreleasepool {
-
-    if (_glfw.ns.inputSource)
-    {
-        CFRelease(_glfw.ns.inputSource);
-        _glfw.ns.inputSource = NULL;
-        _glfw.ns.unicodeData = nil;
-    }
-
-    if (_glfw.ns.eventSource)
-    {
-        CFRelease(_glfw.ns.eventSource);
-        _glfw.ns.eventSource = NULL;
-    }
-
-    if (_glfw.ns.delegate)
-    {
-        [NSApp setDelegate:nil];
-        [_glfw.ns.delegate release];
-        _glfw.ns.delegate = nil;
-    }
-
-    if (_glfw.ns.helper)
-    {
-        [[NSNotificationCenter defaultCenter]
-            removeObserver:_glfw.ns.helper
-                      name:NSTextInputContextKeyboardSelectionDidChangeNotification
-                    object:nil];
-        [[NSNotificationCenter defaultCenter]
-            removeObserver:_glfw.ns.helper];
-        [_glfw.ns.helper release];
-        _glfw.ns.helper = nil;
-    }
-
-    if (_glfw.ns.keyUpMonitor)
-        [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
-
-    free(_glfw.ns.clipboardString);
-
-    _glfwTerminateNSGL();
-
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
-#if defined(_GLFW_BUILD_DLL)
-        " dynamic"
-#endif
-        ;
-}
-
diff --git a/raylib/external/glfw/src/cocoa_joystick.h b/raylib/external/glfw/src/cocoa_joystick.h
deleted file mode 100644 (file)
index 23d2b86..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//========================================================================
-// GLFW 3.4 Cocoa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <IOKit/IOKitLib.h>
-#include <IOKit/IOCFPlugIn.h>
-#include <IOKit/hid/IOHIDLib.h>
-#include <IOKit/hid/IOHIDKeys.h>
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickNS ns
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
-
-// Cocoa-specific per-joystick data
-//
-typedef struct _GLFWjoystickNS
-{
-    IOHIDDeviceRef      device;
-    CFMutableArrayRef   axes;
-    CFMutableArrayRef   buttons;
-    CFMutableArrayRef   hats;
-} _GLFWjoystickNS;
-
diff --git a/raylib/external/glfw/src/cocoa_joystick.m b/raylib/external/glfw/src/cocoa_joystick.m
deleted file mode 100644 (file)
index 4a64fb0..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-//========================================================================
-// GLFW 3.4 Cocoa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
-
-
-// Joystick element information
-//
-typedef struct _GLFWjoyelementNS
-{
-    IOHIDElementRef native;
-    uint32_t        usage;
-    int             index;
-    long            minimum;
-    long            maximum;
-
-} _GLFWjoyelementNS;
-
-
-// Returns the value of the specified element of the specified joystick
-//
-static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
-{
-    IOHIDValueRef valueRef;
-    long value = 0;
-
-    if (js->ns.device)
-    {
-        if (IOHIDDeviceGetValue(js->ns.device,
-                                element->native,
-                                &valueRef) == kIOReturnSuccess)
-        {
-            value = IOHIDValueGetIntegerValue(valueRef);
-        }
-    }
-
-    return value;
-}
-
-// Comparison function for matching the SDL element order
-//
-static CFComparisonResult compareElements(const void* fp,
-                                          const void* sp,
-                                          void* user)
-{
-    const _GLFWjoyelementNS* fe = fp;
-    const _GLFWjoyelementNS* se = sp;
-    if (fe->usage < se->usage)
-        return kCFCompareLessThan;
-    if (fe->usage > se->usage)
-        return kCFCompareGreaterThan;
-    if (fe->index < se->index)
-        return kCFCompareLessThan;
-    if (fe->index > se->index)
-        return kCFCompareGreaterThan;
-    return kCFCompareEqualTo;
-}
-
-// Removes the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    int i;
-
-    if (!js->present)
-        return;
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.axes);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
-    CFRelease(js->ns.axes);
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.buttons);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
-    CFRelease(js->ns.buttons);
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.hats);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
-    CFRelease(js->ns.hats);
-
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// Callback for user-initiated joystick addition
-//
-static void matchCallback(void* context,
-                          IOReturn result,
-                          void* sender,
-                          IOHIDDeviceRef device)
-{
-    int jid;
-    char name[256];
-    char guid[33];
-    CFIndex i;
-    CFTypeRef property;
-    uint32_t vendor = 0, product = 0, version = 0;
-    _GLFWjoystick* js;
-    CFMutableArrayRef axes, buttons, hats;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (_glfw.joysticks[jid].ns.device == device)
-            return;
-    }
-
-    axes    = CFArrayCreateMutable(NULL, 0, NULL);
-    buttons = CFArrayCreateMutable(NULL, 0, NULL);
-    hats    = CFArrayCreateMutable(NULL, 0, NULL);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
-    if (property)
-    {
-        CFStringGetCString(property,
-                           name,
-                           sizeof(name),
-                           kCFStringEncodingUTF8);
-    }
-    else
-        strncpy(name, "Unknown", sizeof(name));
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &vendor);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &product);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &version);
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (vendor && product)
-    {
-        sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
-                (uint8_t) vendor, (uint8_t) (vendor >> 8),
-                (uint8_t) product, (uint8_t) (product >> 8),
-                (uint8_t) version, (uint8_t) (version >> 8));
-    }
-    else
-    {
-        sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    CFArrayRef elements =
-        IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
-
-    for (i = 0;  i < CFArrayGetCount(elements);  i++)
-    {
-        IOHIDElementRef native = (IOHIDElementRef)
-            CFArrayGetValueAtIndex(elements, i);
-        if (CFGetTypeID(native) != IOHIDElementGetTypeID())
-            continue;
-
-        const IOHIDElementType type = IOHIDElementGetType(native);
-        if ((type != kIOHIDElementTypeInput_Axis) &&
-            (type != kIOHIDElementTypeInput_Button) &&
-            (type != kIOHIDElementTypeInput_Misc))
-        {
-            continue;
-        }
-
-        CFMutableArrayRef target = NULL;
-
-        const uint32_t usage = IOHIDElementGetUsage(native);
-        const uint32_t page = IOHIDElementGetUsagePage(native);
-        if (page == kHIDPage_GenericDesktop)
-        {
-            switch (usage)
-            {
-                case kHIDUsage_GD_X:
-                case kHIDUsage_GD_Y:
-                case kHIDUsage_GD_Z:
-                case kHIDUsage_GD_Rx:
-                case kHIDUsage_GD_Ry:
-                case kHIDUsage_GD_Rz:
-                case kHIDUsage_GD_Slider:
-                case kHIDUsage_GD_Dial:
-                case kHIDUsage_GD_Wheel:
-                    target = axes;
-                    break;
-                case kHIDUsage_GD_Hatswitch:
-                    target = hats;
-                    break;
-                case kHIDUsage_GD_DPadUp:
-                case kHIDUsage_GD_DPadRight:
-                case kHIDUsage_GD_DPadDown:
-                case kHIDUsage_GD_DPadLeft:
-                case kHIDUsage_GD_SystemMainMenu:
-                case kHIDUsage_GD_Select:
-                case kHIDUsage_GD_Start:
-                    target = buttons;
-                    break;
-            }
-        }
-        else if (page == kHIDPage_Simulation)
-        {
-            switch (usage)
-            {
-                case kHIDUsage_Sim_Accelerator:
-                case kHIDUsage_Sim_Brake:
-                case kHIDUsage_Sim_Throttle:
-                case kHIDUsage_Sim_Rudder:
-                case kHIDUsage_Sim_Steering:
-                    target = axes;
-                    break;
-            }
-        }
-        else if (page == kHIDPage_Button || page == kHIDPage_Consumer)
-            target = buttons;
-
-        if (target)
-        {
-            _GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS));
-            element->native  = native;
-            element->usage   = usage;
-            element->index   = (int) CFArrayGetCount(target);
-            element->minimum = IOHIDElementGetLogicalMin(native);
-            element->maximum = IOHIDElementGetLogicalMax(native);
-            CFArrayAppendValue(target, element);
-        }
-    }
-
-    CFRelease(elements);
-
-    CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)),
-                      compareElements, NULL);
-    CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)),
-                      compareElements, NULL);
-    CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)),
-                      compareElements, NULL);
-
-    js = _glfwAllocJoystick(name, guid,
-                            (int) CFArrayGetCount(axes),
-                            (int) CFArrayGetCount(buttons),
-                            (int) CFArrayGetCount(hats));
-
-    js->ns.device  = device;
-    js->ns.axes    = axes;
-    js->ns.buttons = buttons;
-    js->ns.hats    = hats;
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-}
-
-// Callback for user-initiated joystick removal
-//
-static void removeCallback(void* context,
-                           IOReturn result,
-                           void* sender,
-                           IOHIDDeviceRef device)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (_glfw.joysticks[jid].ns.device == device)
-        {
-            closeJoystick(_glfw.joysticks + jid);
-            break;
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    CFMutableArrayRef matching;
-    const long usages[] =
-    {
-        kHIDUsage_GD_Joystick,
-        kHIDUsage_GD_GamePad,
-        kHIDUsage_GD_MultiAxisController
-    };
-
-    _glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
-                                             kIOHIDOptionsTypeNone);
-
-    matching = CFArrayCreateMutable(kCFAllocatorDefault,
-                                    0,
-                                    &kCFTypeArrayCallBacks);
-    if (!matching)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
-        return GLFW_FALSE;
-    }
-
-    for (size_t i = 0;  i < sizeof(usages) / sizeof(long);  i++)
-    {
-        const long page = kHIDPage_GenericDesktop;
-
-        CFMutableDictionaryRef dict =
-            CFDictionaryCreateMutable(kCFAllocatorDefault,
-                                      0,
-                                      &kCFTypeDictionaryKeyCallBacks,
-                                      &kCFTypeDictionaryValueCallBacks);
-        if (!dict)
-            continue;
-
-        CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,
-                                             kCFNumberLongType,
-                                             &page);
-        CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,
-                                              kCFNumberLongType,
-                                              &usages[i]);
-        if (pageRef && usageRef)
-        {
-            CFDictionarySetValue(dict,
-                                 CFSTR(kIOHIDDeviceUsagePageKey),
-                                 pageRef);
-            CFDictionarySetValue(dict,
-                                 CFSTR(kIOHIDDeviceUsageKey),
-                                 usageRef);
-            CFArrayAppendValue(matching, dict);
-        }
-
-        if (pageRef)
-            CFRelease(pageRef);
-        if (usageRef)
-            CFRelease(usageRef);
-
-        CFRelease(dict);
-    }
-
-    IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager, matching);
-    CFRelease(matching);
-
-    IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
-                                               &matchCallback, NULL);
-    IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
-                                              &removeCallback, NULL);
-    IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
-                                    CFRunLoopGetMain(),
-                                    kCFRunLoopDefaultMode);
-    IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
-
-    // Execute the run loop once in order to register any initially-attached
-    // joysticks
-    CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-        closeJoystick(_glfw.joysticks + jid);
-
-    if (_glfw.ns.hidManager)
-    {
-        CFRelease(_glfw.ns.hidManager);
-        _glfw.ns.hidManager = NULL;
-    }
-}
-
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    if (mode & _GLFW_POLL_AXES)
-    {
-        CFIndex i;
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.axes);  i++)
-        {
-            _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.axes, i);
-
-            const long raw = getElementValue(js, axis);
-            // Perform auto calibration
-            if (raw < axis->minimum)
-                axis->minimum = raw;
-            if (raw > axis->maximum)
-                axis->maximum = raw;
-
-            const long size = axis->maximum - axis->minimum;
-            if (size == 0)
-                _glfwInputJoystickAxis(js, (int) i, 0.f);
-            else
-            {
-                const float value = (2.f * (raw - axis->minimum) / size) - 1.f;
-                _glfwInputJoystickAxis(js, (int) i, value);
-            }
-        }
-    }
-
-    if (mode & _GLFW_POLL_BUTTONS)
-    {
-        CFIndex i;
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.buttons);  i++)
-        {
-            _GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.buttons, i);
-            const char value = getElementValue(js, button) - button->minimum;
-            const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE;
-            _glfwInputJoystickButton(js, (int) i, state);
-        }
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.hats);  i++)
-        {
-            const int states[9] =
-            {
-                GLFW_HAT_UP,
-                GLFW_HAT_RIGHT_UP,
-                GLFW_HAT_RIGHT,
-                GLFW_HAT_RIGHT_DOWN,
-                GLFW_HAT_DOWN,
-                GLFW_HAT_LEFT_DOWN,
-                GLFW_HAT_LEFT,
-                GLFW_HAT_LEFT_UP,
-                GLFW_HAT_CENTERED
-            };
-
-            _GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.hats, i);
-            long state = getElementValue(js, hat) - hat->minimum;
-            if (state < 0 || state > 8)
-                state = 8;
-
-            _glfwInputJoystickHat(js, (int) i, states[state]);
-        }
-    }
-
-    return js->present;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-    if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
-        (strncmp(guid + 20, "000000000000", 12) == 0))
-    {
-        char original[33];
-        strncpy(original, guid, sizeof(original) - 1);
-        sprintf(guid, "03000000%.4s0000%.4s000000000000",
-                original, original + 16);
-    }
-}
-
diff --git a/raylib/external/glfw/src/cocoa_monitor.m b/raylib/external/glfw/src/cocoa_monitor.m
deleted file mode 100644 (file)
index 2bb8373..0000000
+++ /dev/null
@@ -1,618 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <limits.h>
-#include <math.h>
-
-#include <IOKit/graphics/IOGraphicsLib.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-
-// Get the name of the specified display, or NULL
-//
-static char* getDisplayName(CGDirectDisplayID displayID)
-{
-    io_iterator_t it;
-    io_service_t service;
-    CFDictionaryRef info;
-
-    if (IOServiceGetMatchingServices(kIOMasterPortDefault,
-                                     IOServiceMatching("IODisplayConnect"),
-                                     &it) != 0)
-    {
-        // This may happen if a desktop Mac is running headless
-        return NULL;
-    }
-
-    while ((service = IOIteratorNext(it)) != 0)
-    {
-        info = IODisplayCreateInfoDictionary(service,
-                                             kIODisplayOnlyPreferredName);
-
-        CFNumberRef vendorIDRef =
-            CFDictionaryGetValue(info, CFSTR(kDisplayVendorID));
-        CFNumberRef productIDRef =
-            CFDictionaryGetValue(info, CFSTR(kDisplayProductID));
-        if (!vendorIDRef || !productIDRef)
-        {
-            CFRelease(info);
-            continue;
-        }
-
-        unsigned int vendorID, productID;
-        CFNumberGetValue(vendorIDRef, kCFNumberIntType, &vendorID);
-        CFNumberGetValue(productIDRef, kCFNumberIntType, &productID);
-
-        if (CGDisplayVendorNumber(displayID) == vendorID &&
-            CGDisplayModelNumber(displayID) == productID)
-        {
-            // Info dictionary is used and freed below
-            break;
-        }
-
-        CFRelease(info);
-    }
-
-    IOObjectRelease(it);
-
-    if (!service)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to find service port for display");
-        return NULL;
-    }
-
-    CFDictionaryRef names =
-        CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
-
-    CFStringRef nameRef;
-
-    if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
-                                                 (const void**) &nameRef))
-    {
-        // This may happen if a desktop Mac is running headless
-        CFRelease(info);
-        return NULL;
-    }
-
-    const CFIndex size =
-        CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
-                                          kCFStringEncodingUTF8);
-    char* name = calloc(size + 1, 1);
-    CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
-
-    CFRelease(info);
-    return name;
-}
-
-// Check whether the display mode should be included in enumeration
-//
-static GLFWbool modeIsGood(CGDisplayModeRef mode)
-{
-    uint32_t flags = CGDisplayModeGetIOFlags(mode);
-
-    if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
-        return GLFW_FALSE;
-    if (flags & kDisplayModeInterlacedFlag)
-        return GLFW_FALSE;
-    if (flags & kDisplayModeStretchedFlag)
-        return GLFW_FALSE;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
-    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
-        CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
-    {
-        CFRelease(format);
-        return GLFW_FALSE;
-    }
-
-    CFRelease(format);
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    return GLFW_TRUE;
-}
-
-// Convert Core Graphics display mode to GLFW video mode
-//
-static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
-                                            double fallbackRefreshRate)
-{
-    GLFWvidmode result;
-    result.width = (int) CGDisplayModeGetWidth(mode);
-    result.height = (int) CGDisplayModeGetHeight(mode);
-    result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
-
-    if (result.refreshRate == 0)
-        result.refreshRate = (int) round(fallbackRefreshRate);
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
-    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
-    {
-        result.redBits = 5;
-        result.greenBits = 5;
-        result.blueBits = 5;
-    }
-    else
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    {
-        result.redBits = 8;
-        result.greenBits = 8;
-        result.blueBits = 8;
-    }
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFRelease(format);
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    return result;
-}
-
-// Starts reservation for display fading
-//
-static CGDisplayFadeReservationToken beginFadeReservation(void)
-{
-    CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
-
-    if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
-    {
-        CGDisplayFade(token, 0.3,
-                      kCGDisplayBlendNormal,
-                      kCGDisplayBlendSolidColor,
-                      0.0, 0.0, 0.0,
-                      TRUE);
-    }
-
-    return token;
-}
-
-// Ends reservation for display fading
-//
-static void endFadeReservation(CGDisplayFadeReservationToken token)
-{
-    if (token != kCGDisplayFadeReservationInvalidToken)
-    {
-        CGDisplayFade(token, 0.5,
-                      kCGDisplayBlendSolidColor,
-                      kCGDisplayBlendNormal,
-                      0.0, 0.0, 0.0,
-                      FALSE);
-        CGReleaseDisplayFadeReservation(token);
-    }
-}
-
-// Finds and caches the NSScreen corresponding to the specified monitor
-//
-static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
-{
-    if (monitor->ns.screen)
-        return GLFW_TRUE;
-
-    for (NSScreen* screen in [NSScreen screens])
-    {
-        NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
-
-        // HACK: Compare unit numbers instead of display IDs to work around
-        //       display replacement on machines with automatic graphics
-        //       switching
-        if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
-        {
-            monitor->ns.screen = screen;
-            return GLFW_TRUE;
-        }
-    }
-
-    _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
-    return GLFW_FALSE;
-}
-
-// Returns the display refresh rate queried from the I/O registry
-//
-static double getFallbackRefreshRate(CGDirectDisplayID displayID)
-{
-    double refreshRate = 60.0;
-
-    io_iterator_t it;
-    io_service_t service;
-
-    if (IOServiceGetMatchingServices(kIOMasterPortDefault,
-                                     IOServiceMatching("IOFramebuffer"),
-                                     &it) != 0)
-    {
-        return refreshRate;
-    }
-
-    while ((service = IOIteratorNext(it)) != 0)
-    {
-        const CFNumberRef indexRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFramebufferOpenGLIndex"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-        if (!indexRef)
-            continue;
-
-        uint32_t index = 0;
-        CFNumberGetValue(indexRef, kCFNumberIntType, &index);
-        CFRelease(indexRef);
-
-        if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
-            continue;
-
-        const CFNumberRef clockRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFBCurrentPixelClock"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-        const CFNumberRef countRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFBCurrentPixelCount"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-
-        uint32_t clock = 0, count = 0;
-
-        if (clockRef)
-        {
-            CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
-            CFRelease(clockRef);
-        }
-
-        if (countRef)
-        {
-            CFNumberGetValue(countRef, kCFNumberIntType, &count);
-            CFRelease(countRef);
-        }
-
-        if (clock > 0 && count > 0)
-            refreshRate = clock / (double) count;
-
-        break;
-    }
-
-    IOObjectRelease(it);
-    return refreshRate;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsNS(void)
-{
-    uint32_t displayCount;
-    CGGetOnlineDisplayList(0, NULL, &displayCount);
-    CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
-    CGGetOnlineDisplayList(displayCount, displays, &displayCount);
-
-    for (int i = 0;  i < _glfw.monitorCount;  i++)
-        _glfw.monitors[i]->ns.screen = nil;
-
-    _GLFWmonitor** disconnected = NULL;
-    uint32_t disconnectedCount = _glfw.monitorCount;
-    if (disconnectedCount)
-    {
-        disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-        memcpy(disconnected,
-               _glfw.monitors,
-               _glfw.monitorCount * sizeof(_GLFWmonitor*));
-    }
-
-    for (uint32_t i = 0;  i < displayCount;  i++)
-    {
-        if (CGDisplayIsAsleep(displays[i]))
-            continue;
-
-        // HACK: Compare unit numbers instead of display IDs to work around
-        //       display replacement on machines with automatic graphics
-        //       switching
-        const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
-        for (uint32_t j = 0;  j < disconnectedCount;  j++)
-        {
-            if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
-            {
-                disconnected[j] = NULL;
-                break;
-            }
-        }
-
-        const CGSize size = CGDisplayScreenSize(displays[i]);
-        char* name = getDisplayName(displays[i]);
-        if (!name)
-            name = _glfw_strdup("Unknown");
-
-        _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
-        monitor->ns.displayID  = displays[i];
-        monitor->ns.unitNumber = unitNumber;
-
-        free(name);
-
-        CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
-        if (CGDisplayModeGetRefreshRate(mode) == 0.0)
-            monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
-        CGDisplayModeRelease(mode);
-
-        _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
-    }
-
-    for (uint32_t i = 0;  i < disconnectedCount;  i++)
-    {
-        if (disconnected[i])
-            _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-    }
-
-    free(disconnected);
-    free(displays);
-}
-
-// Change the current video mode
-//
-void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    GLFWvidmode current;
-    _glfwPlatformGetVideoMode(monitor, &current);
-
-    const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
-    if (_glfwCompareVideoModes(&current, best) == 0)
-        return;
-
-    CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
-    const CFIndex count = CFArrayGetCount(modes);
-    CGDisplayModeRef native = NULL;
-
-    for (CFIndex i = 0;  i < count;  i++)
-    {
-        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-        if (!modeIsGood(dm))
-            continue;
-
-        const GLFWvidmode mode =
-            vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
-        if (_glfwCompareVideoModes(best, &mode) == 0)
-        {
-            native = dm;
-            break;
-        }
-    }
-
-    if (native)
-    {
-        if (monitor->ns.previousMode == NULL)
-            monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
-
-        CGDisplayFadeReservationToken token = beginFadeReservation();
-        CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
-        endFadeReservation(token);
-    }
-
-    CFRelease(modes);
-}
-
-// Restore the previously saved (original) video mode
-//
-void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
-{
-    if (monitor->ns.previousMode)
-    {
-        CGDisplayFadeReservationToken token = beginFadeReservation();
-        CGDisplaySetDisplayMode(monitor->ns.displayID,
-                                monitor->ns.previousMode, NULL);
-        endFadeReservation(token);
-
-        CGDisplayModeRelease(monitor->ns.previousMode);
-        monitor->ns.previousMode = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    @autoreleasepool {
-
-    const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
-
-    if (xpos)
-        *xpos = (int) bounds.origin.x;
-    if (ypos)
-        *ypos = (int) bounds.origin.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    @autoreleasepool {
-
-    if (!refreshMonitorScreen(monitor))
-        return;
-
-    const NSRect points = [monitor->ns.screen frame];
-    const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
-
-    if (xscale)
-        *xscale = (float) (pixels.size.width / points.size.width);
-    if (yscale)
-        *yscale = (float) (pixels.size.height / points.size.height);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    @autoreleasepool {
-
-    if (!refreshMonitorScreen(monitor))
-        return;
-
-    const NSRect frameRect = [monitor->ns.screen visibleFrame];
-
-    if (xpos)
-        *xpos = frameRect.origin.x;
-    if (ypos)
-        *ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
-    if (width)
-        *width = frameRect.size.width;
-    if (height)
-        *height = frameRect.size.height;
-
-    } // autoreleasepool
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    @autoreleasepool {
-
-    *count = 0;
-
-    CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
-    const CFIndex found = CFArrayGetCount(modes);
-    GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
-
-    for (CFIndex i = 0;  i < found;  i++)
-    {
-        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-        if (!modeIsGood(dm))
-            continue;
-
-        const GLFWvidmode mode =
-            vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
-        CFIndex j;
-
-        for (j = 0;  j < *count;  j++)
-        {
-            if (_glfwCompareVideoModes(result + j, &mode) == 0)
-                break;
-        }
-
-        // Skip duplicate modes
-        if (i < *count)
-            continue;
-
-        (*count)++;
-        result[*count - 1] = mode;
-    }
-
-    CFRelease(modes);
-    return result;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
-{
-    @autoreleasepool {
-
-    CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
-    *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
-    CGDisplayModeRelease(native);
-
-    } // autoreleasepool
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    @autoreleasepool {
-
-    uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
-    CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
-
-    CGGetDisplayTransferByTable(monitor->ns.displayID,
-                                size,
-                                values,
-                                values + size,
-                                values + size * 2,
-                                &size);
-
-    _glfwAllocGammaArrays(ramp, size);
-
-    for (uint32_t i = 0; i < size; i++)
-    {
-        ramp->red[i]   = (unsigned short) (values[i] * 65535);
-        ramp->green[i] = (unsigned short) (values[i + size] * 65535);
-        ramp->blue[i]  = (unsigned short) (values[i + size * 2] * 65535);
-    }
-
-    free(values);
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    @autoreleasepool {
-
-    CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
-
-    for (unsigned int i = 0;  i < ramp->size;  i++)
-    {
-        values[i]                  = ramp->red[i] / 65535.f;
-        values[i + ramp->size]     = ramp->green[i] / 65535.f;
-        values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
-    }
-
-    CGSetDisplayTransferByTable(monitor->ns.displayID,
-                                ramp->size,
-                                values,
-                                values + ramp->size,
-                                values + ramp->size * 2);
-
-    free(values);
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
-    return monitor->ns.displayID;
-}
-
diff --git a/raylib/external/glfw/src/cocoa_platform.h b/raylib/external/glfw/src/cocoa_platform.h
deleted file mode 100644 (file)
index 01dcd87..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <stdint.h>
-#include <dlfcn.h>
-
-#include <Carbon/Carbon.h>
-
-// NOTE: All of NSGL was deprecated in the 10.14 SDK
-//       This disables the pointless warnings for every symbol we use
-#define GL_SILENCE_DEPRECATION
-
-#if defined(__OBJC__)
-#import <Cocoa/Cocoa.h>
-#else
-typedef void* id;
-#endif
-
-// NOTE: Many Cocoa enum values have been renamed and we need to build across
-//       SDK versions where one is unavailable or the other deprecated
-//       We use the newer names in code and these macros to handle compatibility
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
- #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
- #define NSEventMaskAny NSAnyEventMask
- #define NSEventMaskKeyUp NSKeyUpMask
- #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
- #define NSEventModifierFlagCommand NSCommandKeyMask
- #define NSEventModifierFlagControl NSControlKeyMask
- #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
- #define NSEventModifierFlagOption NSAlternateKeyMask
- #define NSEventModifierFlagShift NSShiftKeyMask
- #define NSEventTypeApplicationDefined NSApplicationDefined
- #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
- #define NSWindowStyleMaskClosable NSClosableWindowMask
- #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
- #define NSWindowStyleMaskResizable NSResizableWindowMask
- #define NSWindowStyleMaskTitled NSTitledWindowMask
-#endif
-
-typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
-typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
-
-typedef struct VkMacOSSurfaceCreateInfoMVK
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkMacOSSurfaceCreateFlagsMVK    flags;
-    const void*                     pView;
-} VkMacOSSurfaceCreateInfoMVK;
-
-typedef struct VkMetalSurfaceCreateInfoEXT
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkMetalSurfaceCreateFlagsEXT    flags;
-    const void*                     pLayer;
-} VkMetalSurfaceCreateInfoEXT;
-
-typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-
-#include "posix_thread.h"
-#include "cocoa_joystick.h"
-#include "nsgl_context.h"
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowNS  ns
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE  _GLFWtimerNS   ns
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorNS ns
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorNS  ns
-
-// HIToolbox.framework pointer typedefs
-#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
-typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
-#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
-typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
-#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
-typedef UInt8 (*PFN_LMGetKbdType)(void);
-#define LMGetKbdType _glfw.ns.tis.GetKbdType
-
-
-// Cocoa-specific per-window data
-//
-typedef struct _GLFWwindowNS
-{
-    id              object;
-    id              delegate;
-    id              view;
-    id              layer;
-
-    GLFWbool        maximized;
-    GLFWbool        occluded;
-    GLFWbool        retina;
-
-    // Cached window properties to filter out duplicate events
-    int             width, height;
-    int             fbWidth, fbHeight;
-    float           xscale, yscale;
-
-    // The total sum of the distances the cursor has been warped
-    // since the last cursor motion event was processed
-    // This is kept to counteract Cocoa doing the same internally
-    double          cursorWarpDeltaX, cursorWarpDeltaY;
-
-} _GLFWwindowNS;
-
-// Cocoa-specific global data
-//
-typedef struct _GLFWlibraryNS
-{
-    CGEventSourceRef    eventSource;
-    id                  delegate;
-    GLFWbool            cursorHidden;
-    TISInputSourceRef   inputSource;
-    IOHIDManagerRef     hidManager;
-    id                  unicodeData;
-    id                  helper;
-    id                  keyUpMonitor;
-    id                  nibObjects;
-
-    char                keynames[GLFW_KEY_LAST + 1][17];
-    short int           keycodes[256];
-    short int           scancodes[GLFW_KEY_LAST + 1];
-    char*               clipboardString;
-    CGPoint             cascadePoint;
-    // Where to place the cursor when re-enabled
-    double              restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*        disabledCursorWindow;
-
-    struct {
-        CFBundleRef     bundle;
-        PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
-        PFN_TISGetInputSourceProperty GetInputSourceProperty;
-        PFN_LMGetKbdType GetKbdType;
-        CFStringRef     kPropertyUnicodeKeyLayoutData;
-    } tis;
-
-} _GLFWlibraryNS;
-
-// Cocoa-specific per-monitor data
-//
-typedef struct _GLFWmonitorNS
-{
-    CGDirectDisplayID   displayID;
-    CGDisplayModeRef    previousMode;
-    uint32_t            unitNumber;
-    id                  screen;
-    double              fallbackRefreshRate;
-
-} _GLFWmonitorNS;
-
-// Cocoa-specific per-cursor data
-//
-typedef struct _GLFWcursorNS
-{
-    id              object;
-
-} _GLFWcursorNS;
-
-// Cocoa-specific global timer data
-//
-typedef struct _GLFWtimerNS
-{
-    uint64_t        frequency;
-
-} _GLFWtimerNS;
-
-
-void _glfwInitTimerNS(void);
-
-void _glfwPollMonitorsNS(void);
-void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
-
-float _glfwTransformYNS(float y);
-
-void* _glfwLoadLocalVulkanLoaderNS(void);
-
diff --git a/raylib/external/glfw/src/cocoa_time.c b/raylib/external/glfw/src/cocoa_time.c
deleted file mode 100644 (file)
index 4bf646c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <mach/mach_time.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerNS(void)
-{
-    mach_timebase_info_data_t info;
-    mach_timebase_info(&info);
-
-    _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-    return mach_absolute_time();
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.ns.frequency;
-}
-
diff --git a/raylib/external/glfw/src/cocoa_window.m b/raylib/external/glfw/src/cocoa_window.m
deleted file mode 100644 (file)
index 81b22e2..0000000
+++ /dev/null
@@ -1,1905 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <float.h>
-#include <string.h>
-
-// Returns the style mask corresponding to the window settings
-//
-static NSUInteger getStyleMask(_GLFWwindow* window)
-{
-    NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
-
-    if (window->monitor || !window->decorated)
-        styleMask |= NSWindowStyleMaskBorderless;
-    else
-    {
-        styleMask |= NSWindowStyleMaskTitled |
-                     NSWindowStyleMaskClosable;
-
-        if (window->resizable)
-            styleMask |= NSWindowStyleMaskResizable;
-    }
-
-    return styleMask;
-}
-
-// Returns whether the cursor is in the content area of the specified window
-//
-static GLFWbool cursorInContentArea(_GLFWwindow* window)
-{
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-    return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
-}
-
-// Hides the cursor if not already hidden
-//
-static void hideCursor(_GLFWwindow* window)
-{
-    if (!_glfw.ns.cursorHidden)
-    {
-        [NSCursor hide];
-        _glfw.ns.cursorHidden = GLFW_TRUE;
-    }
-}
-
-// Shows the cursor if not already shown
-//
-static void showCursor(_GLFWwindow* window)
-{
-    if (_glfw.ns.cursorHidden)
-    {
-        [NSCursor unhide];
-        _glfw.ns.cursorHidden = GLFW_FALSE;
-    }
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        showCursor(window);
-
-        if (window->cursor)
-            [(NSCursor*) window->cursor->ns.object set];
-        else
-            [[NSCursor arrowCursor] set];
-    }
-    else
-        hideCursor(window);
-}
-
-// Apply chosen cursor mode to a focused window
-//
-static void updateCursorMode(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        _glfw.ns.disabledCursorWindow = window;
-        _glfwPlatformGetCursorPos(window,
-                                  &_glfw.ns.restoreCursorPosX,
-                                  &_glfw.ns.restoreCursorPosY);
-        _glfwCenterCursorInContentArea(window);
-        CGAssociateMouseAndMouseCursorPosition(false);
-    }
-    else if (_glfw.ns.disabledCursorWindow == window)
-    {
-        _glfw.ns.disabledCursorWindow = NULL;
-        CGAssociateMouseAndMouseCursorPosition(true);
-        _glfwPlatformSetCursorPos(window,
-                                  _glfw.ns.restoreCursorPosX,
-                                  _glfw.ns.restoreCursorPosY);
-    }
-
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    _glfwSetVideoModeNS(window->monitor, &window->videoMode);
-    const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
-    const NSRect frame = NSMakeRect(bounds.origin.x,
-                                    _glfwTransformYNS(bounds.origin.y + bounds.size.height - 1),
-                                    bounds.size.width,
-                                    bounds.size.height);
-
-    [window->ns.object setFrame:frame display:YES];
-
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeNS(window->monitor);
-}
-
-// Translates macOS key modifiers into GLFW ones
-//
-static int translateFlags(NSUInteger flags)
-{
-    int mods = 0;
-
-    if (flags & NSEventModifierFlagShift)
-        mods |= GLFW_MOD_SHIFT;
-    if (flags & NSEventModifierFlagControl)
-        mods |= GLFW_MOD_CONTROL;
-    if (flags & NSEventModifierFlagOption)
-        mods |= GLFW_MOD_ALT;
-    if (flags & NSEventModifierFlagCommand)
-        mods |= GLFW_MOD_SUPER;
-    if (flags & NSEventModifierFlagCapsLock)
-        mods |= GLFW_MOD_CAPS_LOCK;
-
-    return mods;
-}
-
-// Translates a macOS keycode to a GLFW keycode
-//
-static int translateKey(unsigned int key)
-{
-    if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0]))
-        return GLFW_KEY_UNKNOWN;
-
-    return _glfw.ns.keycodes[key];
-}
-
-// Translate a GLFW keycode to a Cocoa modifier flag
-//
-static NSUInteger translateKeyToModifierFlag(int key)
-{
-    switch (key)
-    {
-        case GLFW_KEY_LEFT_SHIFT:
-        case GLFW_KEY_RIGHT_SHIFT:
-            return NSEventModifierFlagShift;
-        case GLFW_KEY_LEFT_CONTROL:
-        case GLFW_KEY_RIGHT_CONTROL:
-            return NSEventModifierFlagControl;
-        case GLFW_KEY_LEFT_ALT:
-        case GLFW_KEY_RIGHT_ALT:
-            return NSEventModifierFlagOption;
-        case GLFW_KEY_LEFT_SUPER:
-        case GLFW_KEY_RIGHT_SUPER:
-            return NSEventModifierFlagCommand;
-        case GLFW_KEY_CAPS_LOCK:
-            return NSEventModifierFlagCapsLock;
-    }
-
-    return 0;
-}
-
-// Defines a constant for empty ranges in NSTextInputClient
-//
-static const NSRange kEmptyRange = { NSNotFound, 0 };
-
-
-//------------------------------------------------------------------------
-// Delegate for window related notifications
-//------------------------------------------------------------------------
-
-@interface GLFWWindowDelegate : NSObject
-{
-    _GLFWwindow* window;
-}
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
-
-@end
-
-@implementation GLFWWindowDelegate
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
-{
-    self = [super init];
-    if (self != nil)
-        window = initWindow;
-
-    return self;
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
-    _glfwInputWindowCloseRequest(window);
-    return NO;
-}
-
-- (void)windowDidResize:(NSNotification *)notification
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    const int maximized = [window->ns.object isZoomed];
-    if (window->ns.maximized != maximized)
-    {
-        window->ns.maximized = maximized;
-        _glfwInputWindowMaximize(window, maximized);
-    }
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (fbRect.size.width != window->ns.fbWidth ||
-        fbRect.size.height != window->ns.fbHeight)
-    {
-        window->ns.fbWidth  = fbRect.size.width;
-        window->ns.fbHeight = fbRect.size.height;
-        _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
-    }
-
-    if (contentRect.size.width != window->ns.width ||
-        contentRect.size.height != window->ns.height)
-    {
-        window->ns.width  = contentRect.size.width;
-        window->ns.height = contentRect.size.height;
-        _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
-    }
-}
-
-- (void)windowDidMove:(NSNotification *)notification
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    int x, y;
-    _glfwPlatformGetWindowPos(window, &x, &y);
-    _glfwInputWindowPos(window, x, y);
-}
-
-- (void)windowDidMiniaturize:(NSNotification *)notification
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowIconify(window, GLFW_TRUE);
-}
-
-- (void)windowDidDeminiaturize:(NSNotification *)notification
-{
-    if (window->monitor)
-        acquireMonitor(window);
-
-    _glfwInputWindowIconify(window, GLFW_FALSE);
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-    updateCursorMode(window);
-}
-
-- (void)windowDidResignKey:(NSNotification *)notification
-{
-    if (window->monitor && window->autoIconify)
-        _glfwPlatformIconifyWindow(window);
-
-    _glfwInputWindowFocus(window, GLFW_FALSE);
-}
-
-- (void)windowDidChangeOcclusionState:(NSNotification* )notification
-{
-    if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
-        window->ns.occluded = GLFW_FALSE;
-    else
-        window->ns.occluded = GLFW_TRUE;
-}
-
-@end
-
-
-//------------------------------------------------------------------------
-// Content view class for the GLFW window
-//------------------------------------------------------------------------
-
-@interface GLFWContentView : NSView <NSTextInputClient>
-{
-    _GLFWwindow* window;
-    NSTrackingArea* trackingArea;
-    NSMutableAttributedString* markedText;
-}
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
-
-@end
-
-@implementation GLFWContentView
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
-{
-    self = [super init];
-    if (self != nil)
-    {
-        window = initWindow;
-        trackingArea = nil;
-        markedText = [[NSMutableAttributedString alloc] init];
-
-        [self updateTrackingAreas];
-        // NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
-        //       on 10.7 without having been deprecated yet
-        [self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
-    }
-
-    return self;
-}
-
-- (void)dealloc
-{
-    [trackingArea release];
-    [markedText release];
-    [super dealloc];
-}
-
-- (BOOL)isOpaque
-{
-    return [window->ns.object isOpaque];
-}
-
-- (BOOL)canBecomeKeyView
-{
-    return YES;
-}
-
-- (BOOL)acceptsFirstResponder
-{
-    return YES;
-}
-
-- (BOOL)wantsUpdateLayer
-{
-    return YES;
-}
-
-- (void)updateLayer
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    _glfwInputWindowDamage(window);
-}
-
-- (void)cursorUpdate:(NSEvent *)event
-{
-    updateCursorImage(window);
-}
-
-- (BOOL)acceptsFirstMouse:(NSEvent *)event
-{
-    return YES;
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_LEFT,
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)mouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_LEFT,
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseMoved:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        const double dx = [event deltaX] - window->ns.cursorWarpDeltaX;
-        const double dy = [event deltaY] - window->ns.cursorWarpDeltaY;
-
-        _glfwInputCursorPos(window,
-                            window->virtualCursorPosX + dx,
-                            window->virtualCursorPosY + dy);
-    }
-    else
-    {
-        const NSRect contentRect = [window->ns.view frame];
-        // NOTE: The returned location uses base 0,1 not 0,0
-        const NSPoint pos = [event locationInWindow];
-
-        _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
-    }
-
-    window->ns.cursorWarpDeltaX = 0;
-    window->ns.cursorWarpDeltaY = 0;
-}
-
-- (void)rightMouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_RIGHT,
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)rightMouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)rightMouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_RIGHT,
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)otherMouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         (int) [event buttonNumber],
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)otherMouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)otherMouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         (int) [event buttonNumber],
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseExited:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-        showCursor(window);
-
-    _glfwInputCursorEnter(window, GLFW_FALSE);
-}
-
-- (void)mouseEntered:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-        hideCursor(window);
-
-    _glfwInputCursorEnter(window, GLFW_TRUE);
-}
-
-- (void)viewDidChangeBackingProperties
-{
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (fbRect.size.width != window->ns.fbWidth ||
-        fbRect.size.height != window->ns.fbHeight)
-    {
-        window->ns.fbWidth  = fbRect.size.width;
-        window->ns.fbHeight = fbRect.size.height;
-        _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
-    }
-
-    const float xscale = fbRect.size.width / contentRect.size.width;
-    const float yscale = fbRect.size.height / contentRect.size.height;
-
-    if (xscale != window->ns.xscale || yscale != window->ns.yscale)
-    {
-        window->ns.xscale = xscale;
-        window->ns.yscale = yscale;
-        _glfwInputWindowContentScale(window, xscale, yscale);
-
-        if (window->ns.retina && window->ns.layer)
-            [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
-    }
-}
-
-- (void)drawRect:(NSRect)rect
-{
-    _glfwInputWindowDamage(window);
-}
-
-- (void)updateTrackingAreas
-{
-    if (trackingArea != nil)
-    {
-        [self removeTrackingArea:trackingArea];
-        [trackingArea release];
-    }
-
-    const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
-                                          NSTrackingActiveInKeyWindow |
-                                          NSTrackingEnabledDuringMouseDrag |
-                                          NSTrackingCursorUpdate |
-                                          NSTrackingInVisibleRect |
-                                          NSTrackingAssumeInside;
-
-    trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
-                                                options:options
-                                                  owner:self
-                                               userInfo:nil];
-
-    [self addTrackingArea:trackingArea];
-    [super updateTrackingAreas];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags([event modifierFlags]);
-
-    _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
-
-    [self interpretKeyEvents:@[event]];
-}
-
-- (void)flagsChanged:(NSEvent *)event
-{
-    int action;
-    const unsigned int modifierFlags =
-        [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags(modifierFlags);
-    const NSUInteger keyFlag = translateKeyToModifierFlag(key);
-
-    if (keyFlag & modifierFlags)
-    {
-        if (window->keys[key] == GLFW_PRESS)
-            action = GLFW_RELEASE;
-        else
-            action = GLFW_PRESS;
-    }
-    else
-        action = GLFW_RELEASE;
-
-    _glfwInputKey(window, key, [event keyCode], action, mods);
-}
-
-- (void)keyUp:(NSEvent *)event
-{
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags([event modifierFlags]);
-    _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
-    double deltaX = [event scrollingDeltaX];
-    double deltaY = [event scrollingDeltaY];
-
-    if ([event hasPreciseScrollingDeltas])
-    {
-        deltaX *= 0.1;
-        deltaY *= 0.1;
-    }
-
-    if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
-        _glfwInputScroll(window, deltaX, deltaY);
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
-    // HACK: We don't know what to say here because we don't know what the
-    //       application wants to do with the paths
-    return NSDragOperationGeneric;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [sender draggingLocation];
-    _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
-
-    NSPasteboard* pasteboard = [sender draggingPasteboard];
-    NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
-    NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
-                                              options:options];
-    const NSUInteger count = [urls count];
-    if (count)
-    {
-        char** paths = calloc(count, sizeof(char*));
-
-        for (NSUInteger i = 0;  i < count;  i++)
-            paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
-
-        _glfwInputDrop(window, (int) count, (const char**) paths);
-
-        for (NSUInteger i = 0;  i < count;  i++)
-            free(paths[i]);
-        free(paths);
-    }
-
-    return YES;
-}
-
-- (BOOL)hasMarkedText
-{
-    return [markedText length] > 0;
-}
-
-- (NSRange)markedRange
-{
-    if ([markedText length] > 0)
-        return NSMakeRange(0, [markedText length] - 1);
-    else
-        return kEmptyRange;
-}
-
-- (NSRange)selectedRange
-{
-    return kEmptyRange;
-}
-
-- (void)setMarkedText:(id)string
-        selectedRange:(NSRange)selectedRange
-     replacementRange:(NSRange)replacementRange
-{
-    [markedText release];
-    if ([string isKindOfClass:[NSAttributedString class]])
-        markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
-    else
-        markedText = [[NSMutableAttributedString alloc] initWithString:string];
-}
-
-- (void)unmarkText
-{
-    [[markedText mutableString] setString:@""];
-}
-
-- (NSArray*)validAttributesForMarkedText
-{
-    return [NSArray array];
-}
-
-- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
-                                               actualRange:(NSRangePointer)actualRange
-{
-    return nil;
-}
-
-- (NSUInteger)characterIndexForPoint:(NSPoint)point
-{
-    return 0;
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)range
-                         actualRange:(NSRangePointer)actualRange
-{
-    const NSRect frame = [window->ns.view frame];
-    return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0);
-}
-
-- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
-{
-    NSString* characters;
-    NSEvent* event = [NSApp currentEvent];
-    const int mods = translateFlags([event modifierFlags]);
-    const int plain = !(mods & GLFW_MOD_SUPER);
-
-    if ([string isKindOfClass:[NSAttributedString class]])
-        characters = [string string];
-    else
-        characters = (NSString*) string;
-
-    NSRange range = NSMakeRange(0, [characters length]);
-    while (range.length)
-    {
-        uint32_t codepoint = 0;
-
-        if ([characters getBytes:&codepoint
-                       maxLength:sizeof(codepoint)
-                      usedLength:NULL
-                        encoding:NSUTF32StringEncoding
-                         options:0
-                           range:range
-                  remainingRange:&range])
-        {
-            if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
-                continue;
-
-            _glfwInputChar(window, codepoint, mods, plain);
-        }
-    }
-}
-
-- (void)doCommandBySelector:(SEL)selector
-{
-}
-
-@end
-
-
-//------------------------------------------------------------------------
-// GLFW window class
-//------------------------------------------------------------------------
-
-@interface GLFWWindow : NSWindow {}
-@end
-
-@implementation GLFWWindow
-
-- (BOOL)canBecomeKeyWindow
-{
-    // Required for NSWindowStyleMaskBorderless windows
-    return YES;
-}
-
-- (BOOL)canBecomeMainWindow
-{
-    return YES;
-}
-
-@end
-
-
-// Create the Cocoa window
-//
-static GLFWbool createNativeWindow(_GLFWwindow* window,
-                                   const _GLFWwndconfig* wndconfig,
-                                   const _GLFWfbconfig* fbconfig)
-{
-    window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
-    if (window->ns.delegate == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create window delegate");
-        return GLFW_FALSE;
-    }
-
-    NSRect contentRect;
-
-    if (window->monitor)
-    {
-        GLFWvidmode mode;
-        int xpos, ypos;
-
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-
-        contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
-    }
-    else
-        contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
-
-    window->ns.object = [[GLFWWindow alloc]
-        initWithContentRect:contentRect
-                  styleMask:getStyleMask(window)
-                    backing:NSBackingStoreBuffered
-                      defer:NO];
-
-    if (window->ns.object == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    if (window->monitor)
-        [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
-    else
-    {
-        [(NSWindow*) window->ns.object center];
-        _glfw.ns.cascadePoint =
-            NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
-                              NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
-
-        if (wndconfig->resizable)
-        {
-            const NSWindowCollectionBehavior behavior =
-                NSWindowCollectionBehaviorFullScreenPrimary |
-                NSWindowCollectionBehaviorManaged;
-            [window->ns.object setCollectionBehavior:behavior];
-        }
-
-        if (wndconfig->floating)
-            [window->ns.object setLevel:NSFloatingWindowLevel];
-
-        if (wndconfig->maximized)
-            [window->ns.object zoom:nil];
-    }
-
-    if (strlen(wndconfig->ns.frameName))
-        [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
-
-    window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
-    window->ns.retina = wndconfig->ns.retina;
-
-    if (fbconfig->transparent)
-    {
-        [window->ns.object setOpaque:NO];
-        [window->ns.object setHasShadow:NO];
-        [window->ns.object setBackgroundColor:[NSColor clearColor]];
-    }
-
-    [window->ns.object setContentView:window->ns.view];
-    [window->ns.object makeFirstResponder:window->ns.view];
-    [window->ns.object setTitle:@(wndconfig->title)];
-    [window->ns.object setDelegate:window->ns.delegate];
-    [window->ns.object setAcceptsMouseMovedEvents:YES];
-    [window->ns.object setRestorable:NO];
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-    if ([window->ns.object respondsToSelector:@selector(setTabbingMode:)])
-        [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
-#endif
-
-    _glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height);
-    _glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight);
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Transforms a y-coordinate between the CG display and NS screen spaces
-//
-float _glfwTransformYNS(float y)
-{
-    return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    @autoreleasepool {
-
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitNSGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            // EGL implementation on macOS use CALayer* EGLNativeWindowType so we
-            // need to get the layer for EGL window surface creation.
-            [window->ns.view setWantsLayer:YES];
-            window->ns.layer = [window->ns.view layer];
-
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-    }
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfw.ns.disabledCursorWindow = NULL;
-
-    [window->ns.object orderOut:nil];
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    [window->ns.object setDelegate:nil];
-    [window->ns.delegate release];
-    window->ns.delegate = nil;
-
-    [window->ns.view release];
-    window->ns.view = nil;
-
-    [window->ns.object close];
-    window->ns.object = nil;
-
-    // HACK: Allow Cocoa to catch up before returning
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    @autoreleasepool {
-    NSString* string = @(title);
-    [window->ns.object setTitle:string];
-    // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
-    //       if the window lacks NSWindowStyleMaskTitled
-    [window->ns.object setMiniwindowTitle:string];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Cocoa: Regular windows do not have icons on macOS");
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect =
-        [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
-
-    if (xpos)
-        *xpos = contentRect.origin.x;
-    if (ypos)
-        *ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 0, 0);
-    const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
-    [window->ns.object setFrameOrigin:frameRect.origin];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-
-    if (width)
-        *width = contentRect.size.width;
-    if (height)
-        *height = contentRect.size.height;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    @autoreleasepool {
-
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-            acquireMonitor(window);
-    }
-    else
-    {
-        NSRect contentRect =
-            [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
-        contentRect.origin.y += contentRect.size.height - height;
-        contentRect.size = NSMakeSize(width, height);
-        [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
-                            display:YES];
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    @autoreleasepool {
-
-    if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
-        [window->ns.object setContentMinSize:NSMakeSize(0, 0)];
-    else
-        [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)];
-
-    if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
-        [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)];
-    else
-        [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    @autoreleasepool {
-    if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
-        [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)];
-    else
-        [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)];
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (width)
-        *width = (int) fbRect.size.width;
-    if (height)
-        *height = (int) fbRect.size.height;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
-
-    if (left)
-        *left = contentRect.origin.x - frameRect.origin.x;
-    if (top)
-        *top = frameRect.origin.y + frameRect.size.height -
-               contentRect.origin.y - contentRect.size.height;
-    if (right)
-        *right = frameRect.origin.x + frameRect.size.width -
-                 contentRect.origin.x - contentRect.size.width;
-    if (bottom)
-        *bottom = contentRect.origin.y - frameRect.origin.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    @autoreleasepool {
-
-    const NSRect points = [window->ns.view frame];
-    const NSRect pixels = [window->ns.view convertRectToBacking:points];
-
-    if (xscale)
-        *xscale = (float) (pixels.size.width / points.size.width);
-    if (yscale)
-        *yscale = (float) (pixels.size.height / points.size.height);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object miniaturize:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    if ([window->ns.object isMiniaturized])
-        [window->ns.object deminiaturize:nil];
-    else if ([window->ns.object isZoomed])
-        [window->ns.object zoom:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    if (![window->ns.object isZoomed])
-        [window->ns.object zoom:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object orderFront:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object orderOut:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [NSApp requestUserAttention:NSInformationalRequest];
-    } // autoreleasepool
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    // Make us the active application
-    // HACK: This is here to prevent applications using only hidden windows from
-    //       being activated, but should probably not be done every time any
-    //       window is shown
-    [NSApp activateIgnoringOtherApps:YES];
-    [window->ns.object makeKeyAndOrderFront:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    @autoreleasepool {
-
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-                acquireMonitor(window);
-        }
-        else
-        {
-            const NSRect contentRect =
-                NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
-            const NSRect frameRect =
-                [window->ns.object frameRectForContentRect:contentRect
-                                                 styleMask:getStyleMask(window)];
-
-            [window->ns.object setFrame:frameRect display:YES];
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    // HACK: Allow the state cached in Cocoa to catch up to reality
-    // TODO: Solve this in a less terrible way
-    _glfwPlatformPollEvents();
-
-    const NSUInteger styleMask = getStyleMask(window);
-    [window->ns.object setStyleMask:styleMask];
-    // HACK: Changing the style mask can cause the first responder to be cleared
-    [window->ns.object makeFirstResponder:window->ns.view];
-
-    if (window->monitor)
-    {
-        [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
-        [window->ns.object setHasShadow:NO];
-
-        acquireMonitor(window);
-    }
-    else
-    {
-        NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
-                                        width, height);
-        NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
-                                                            styleMask:styleMask];
-        [window->ns.object setFrame:frameRect display:YES];
-
-        if (window->numer != GLFW_DONT_CARE &&
-            window->denom != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentAspectRatio:NSMakeSize(window->numer,
-                                                                window->denom)];
-        }
-
-        if (window->minwidth != GLFW_DONT_CARE &&
-            window->minheight != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentMinSize:NSMakeSize(window->minwidth,
-                                                            window->minheight)];
-        }
-
-        if (window->maxwidth != GLFW_DONT_CARE &&
-            window->maxheight != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth,
-                                                            window->maxheight)];
-        }
-
-        if (window->floating)
-            [window->ns.object setLevel:NSFloatingWindowLevel];
-        else
-            [window->ns.object setLevel:NSNormalWindowLevel];
-
-        [window->ns.object setHasShadow:YES];
-        // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
-        //       title property but the miniwindow title property is unaffected
-        [window->ns.object setTitle:[window->ns.object miniwindowTitle]];
-    }
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isKeyWindow];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isMiniaturized];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isVisible];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isZoomed];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    const NSPoint point = [NSEvent mouseLocation];
-
-    if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
-        [window->ns.object windowNumber])
-    {
-        return GLFW_FALSE;
-    }
-
-    return NSMouseInRect(point,
-        [window->ns.object convertRectToScreen:[window->ns.view frame]], NO);
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setStyleMask:getStyleMask(window)];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setStyleMask:getStyleMask(window)];
-    [window->ns.object makeFirstResponder:window->ns.view];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    if (enabled)
-        [window->ns.object setLevel:NSFloatingWindowLevel];
-    else
-        [window->ns.object setLevel:NSNormalWindowLevel];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setIgnoresMouseEvents:enabled];
-    }
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return (float) [window->ns.object alphaValue];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    @autoreleasepool {
-    [window->ns.object setAlphaValue:opacity];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Cocoa: Raw mouse motion not yet implemented");
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    @autoreleasepool {
-
-    for (;;)
-    {
-        NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                            untilDate:[NSDate distantPast]
-                                               inMode:NSDefaultRunLoopMode
-                                              dequeue:YES];
-        if (event == nil)
-            break;
-
-        [NSApp sendEvent:event];
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    @autoreleasepool {
-
-    // I wanted to pass NO to dequeue:, and rely on PollEvents to
-    // dequeue and send.  For reasons not at all clear to me, passing
-    // NO to dequeue: causes this method never to return.
-    NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                        untilDate:[NSDate distantFuture]
-                                           inMode:NSDefaultRunLoopMode
-                                          dequeue:YES];
-    [NSApp sendEvent:event];
-
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    @autoreleasepool {
-
-    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
-    NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                        untilDate:date
-                                           inMode:NSDefaultRunLoopMode
-                                          dequeue:YES];
-    if (event)
-        [NSApp sendEvent:event];
-
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    @autoreleasepool {
-
-    NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
-                                        location:NSMakePoint(0, 0)
-                                   modifierFlags:0
-                                       timestamp:0
-                                    windowNumber:0
-                                         context:nil
-                                         subtype:0
-                                           data1:0
-                                           data2:0];
-    [NSApp postEvent:event atStart:YES];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-
-    if (xpos)
-        *xpos = pos.x;
-    if (ypos)
-        *ypos = contentRect.size.height - pos.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    @autoreleasepool {
-
-    updateCursorImage(window);
-
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-
-    window->ns.cursorWarpDeltaX += x - pos.x;
-    window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y;
-
-    if (window->monitor)
-    {
-        CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
-                                   CGPointMake(x, y));
-    }
-    else
-    {
-        const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);
-        const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];
-        const NSPoint globalPoint = globalRect.origin;
-
-        CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
-                                              _glfwTransformYNS(globalPoint.y)));
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    @autoreleasepool {
-    if (_glfwPlatformWindowFocused(window))
-        updateCursorMode(window);
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    @autoreleasepool {
-
-    if (scancode < 0 || scancode > 0xff ||
-        _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    const int key = _glfw.ns.keycodes[scancode];
-
-    UInt32 deadKeyState = 0;
-    UniChar characters[4];
-    UniCharCount characterCount = 0;
-
-    if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
-                       scancode,
-                       kUCKeyActionDisplay,
-                       0,
-                       LMGetKbdType(),
-                       kUCKeyTranslateNoDeadKeysBit,
-                       &deadKeyState,
-                       sizeof(characters) / sizeof(characters[0]),
-                       &characterCount,
-                       characters) != noErr)
-    {
-        return NULL;
-    }
-
-    if (!characterCount)
-        return NULL;
-
-    CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
-                                                            characters,
-                                                            characterCount,
-                                                            kCFAllocatorNull);
-    CFStringGetCString(string,
-                       _glfw.ns.keynames[key],
-                       sizeof(_glfw.ns.keynames[key]),
-                       kCFStringEncodingUTF8);
-    CFRelease(string);
-
-    return _glfw.ns.keynames[key];
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.ns.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    @autoreleasepool {
-
-    NSImage* native;
-    NSBitmapImageRep* rep;
-
-    rep = [[NSBitmapImageRep alloc]
-        initWithBitmapDataPlanes:NULL
-                      pixelsWide:image->width
-                      pixelsHigh:image->height
-                   bitsPerSample:8
-                 samplesPerPixel:4
-                        hasAlpha:YES
-                        isPlanar:NO
-                  colorSpaceName:NSCalibratedRGBColorSpace
-                    bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
-                     bytesPerRow:image->width * 4
-                    bitsPerPixel:32];
-
-    if (rep == nil)
-        return GLFW_FALSE;
-
-    memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
-
-    native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
-    [native addRepresentation:rep];
-
-    cursor->ns.object = [[NSCursor alloc] initWithImage:native
-                                                hotSpot:NSMakePoint(xhot, yhot)];
-
-    [native release];
-    [rep release];
-
-    if (cursor->ns.object == nil)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    @autoreleasepool {
-
-    SEL cursorSelector = NULL;
-
-    // HACK: Try to use a private message
-    if (shape == GLFW_RESIZE_EW_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
-
-    if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
-    {
-        id object = [NSCursor performSelector:cursorSelector];
-        if ([object isKindOfClass:[NSCursor class]])
-            cursor->ns.object = object;
-    }
-
-    if (!cursor->ns.object)
-    {
-        if (shape == GLFW_ARROW_CURSOR)
-            cursor->ns.object = [NSCursor arrowCursor];
-        else if (shape == GLFW_IBEAM_CURSOR)
-            cursor->ns.object = [NSCursor IBeamCursor];
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            cursor->ns.object = [NSCursor crosshairCursor];
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            cursor->ns.object = [NSCursor pointingHandCursor];
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            cursor->ns.object = [NSCursor resizeLeftRightCursor];
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            cursor->ns.object = [NSCursor resizeUpDownCursor];
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            cursor->ns.object = [NSCursor closedHandCursor];
-        else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-            cursor->ns.object = [NSCursor operationNotAllowedCursor];
-    }
-
-    if (!cursor->ns.object)
-    {
-        _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                        "Cocoa: Standard cursor shape unavailable");
-        return GLFW_FALSE;
-    }
-
-    [cursor->ns.object retain];
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    @autoreleasepool {
-    if (cursor->ns.object)
-        [(NSCursor*) cursor->ns.object release];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    @autoreleasepool {
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    @autoreleasepool {
-    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
-    [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
-    [pasteboard setString:@(string) forType:NSPasteboardTypeString];
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    @autoreleasepool {
-
-    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
-
-    if (![[pasteboard types] containsObject:NSPasteboardTypeString])
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "Cocoa: Failed to retrieve string from pasteboard");
-        return NULL;
-    }
-
-    NSString* object = [pasteboard stringForType:NSPasteboardTypeString];
-    if (!object)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve object from pasteboard");
-        return NULL;
-    }
-
-    free(_glfw.ns.clipboardString);
-    _glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
-
-    return _glfw.ns.clipboardString;
-
-    } // autoreleasepool
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_metal)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL)
-                type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(3, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return EGL_DEFAULT_DISPLAY;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->ns.layer;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
-    {
-        extensions[0] = "VK_KHR_surface";
-        extensions[1] = "VK_EXT_metal_surface";
-    }
-    else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface)
-    {
-        extensions[0] = "VK_KHR_surface";
-        extensions[1] = "VK_MVK_macos_surface";
-    }
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    return GLFW_TRUE;
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    @autoreleasepool {
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
-    // HACK: Dynamically load Core Animation to avoid adding an extra
-    //       dependency for the majority who don't use MoltenVK
-    NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
-    if (!bundle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to find QuartzCore.framework");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    // NOTE: Create the layer here as makeBackingLayer should not return nil
-    window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
-    if (!window->ns.layer)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create layer for view");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    if (window->ns.retina)
-        [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
-
-    [window->ns.view setLayer:window->ns.layer];
-    [window->ns.view setWantsLayer:YES];
-
-    VkResult err;
-
-    if (_glfw.vk.EXT_metal_surface)
-    {
-        VkMetalSurfaceCreateInfoEXT sci;
-
-        PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
-        vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)
-            vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT");
-        if (!vkCreateMetalSurfaceEXT)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
-        sci.pLayer = window->ns.layer;
-
-        err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface);
-    }
-    else
-    {
-        VkMacOSSurfaceCreateInfoMVK sci;
-
-        PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
-        vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)
-            vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK");
-        if (!vkCreateMacOSSurfaceMVK)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
-        sci.pView = window->ns.view;
-
-        err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface);
-    }
-
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-#else
-    return VK_ERROR_EXTENSION_NOT_PRESENT;
-#endif
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(nil);
-    return window->ns.object;
-}
-
diff --git a/raylib/external/glfw/src/context.c b/raylib/external/glfw/src/context.c
deleted file mode 100644 (file)
index 48311e5..0000000
+++ /dev/null
@@ -1,760 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Checks whether the desired context attributes are valid
-//
-// This function checks things like whether the specified client API version
-// exists and whether all relevant options have supported and non-conflicting
-// values
-//
-GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
-{
-    if (ctxconfig->share)
-    {
-        if (ctxconfig->client == GLFW_NO_API ||
-            ctxconfig->share->context.client == GLFW_NO_API)
-        {
-            _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
-        ctxconfig->source != GLFW_EGL_CONTEXT_API &&
-        ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM,
-                        "Invalid context creation API 0x%08X",
-                        ctxconfig->source);
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client != GLFW_NO_API &&
-        ctxconfig->client != GLFW_OPENGL_API &&
-        ctxconfig->client != GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM,
-                        "Invalid client API 0x%08X",
-                        ctxconfig->client);
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_API)
-    {
-        if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
-            (ctxconfig->major == 1 && ctxconfig->minor > 5) ||
-            (ctxconfig->major == 2 && ctxconfig->minor > 1) ||
-            (ctxconfig->major == 3 && ctxconfig->minor > 3))
-        {
-            // OpenGL 1.0 is the smallest valid version
-            // OpenGL 1.x series ended with version 1.5
-            // OpenGL 2.x series ended with version 2.1
-            // OpenGL 3.x series ended with version 3.3
-            // For now, let everything else through
-
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid OpenGL version %i.%i",
-                            ctxconfig->major, ctxconfig->minor);
-            return GLFW_FALSE;
-        }
-
-        if (ctxconfig->profile)
-        {
-            if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
-                ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
-            {
-                _glfwInputError(GLFW_INVALID_ENUM,
-                                "Invalid OpenGL profile 0x%08X",
-                                ctxconfig->profile);
-                return GLFW_FALSE;
-            }
-
-            if (ctxconfig->major <= 2 ||
-                (ctxconfig->major == 3 && ctxconfig->minor < 2))
-            {
-                // Desktop OpenGL context profiles are only defined for version 3.2
-                // and above
-
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Context profiles are only defined for OpenGL version 3.2 and above");
-                return GLFW_FALSE;
-            }
-        }
-
-        if (ctxconfig->forward && ctxconfig->major <= 2)
-        {
-            // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Forward-compatibility is only defined for OpenGL version 3.0 and above");
-            return GLFW_FALSE;
-        }
-    }
-    else if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
-            (ctxconfig->major == 1 && ctxconfig->minor > 1) ||
-            (ctxconfig->major == 2 && ctxconfig->minor > 0))
-        {
-            // OpenGL ES 1.0 is the smallest valid version
-            // OpenGL ES 1.x series ended with version 1.1
-            // OpenGL ES 2.x series ended with version 2.0
-            // For now, let everything else through
-
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid OpenGL ES version %i.%i",
-                            ctxconfig->major, ctxconfig->minor);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->robustness)
-    {
-        if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
-            ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid context robustness mode 0x%08X",
-                            ctxconfig->robustness);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->release)
-    {
-        if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
-            ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid context release behavior 0x%08X",
-                            ctxconfig->release);
-            return GLFW_FALSE;
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-// Chooses the framebuffer config that best matches the desired one
-//
-const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
-                                         const _GLFWfbconfig* alternatives,
-                                         unsigned int count)
-{
-    unsigned int i;
-    unsigned int missing, leastMissing = UINT_MAX;
-    unsigned int colorDiff, leastColorDiff = UINT_MAX;
-    unsigned int extraDiff, leastExtraDiff = UINT_MAX;
-    const _GLFWfbconfig* current;
-    const _GLFWfbconfig* closest = NULL;
-
-    for (i = 0;  i < count;  i++)
-    {
-        current = alternatives + i;
-
-        if (desired->stereo > 0 && current->stereo == 0)
-        {
-            // Stereo is a hard constraint
-            continue;
-        }
-
-        if (desired->doublebuffer != current->doublebuffer)
-        {
-            // Double buffering is a hard constraint
-            continue;
-        }
-
-        // Count number of missing buffers
-        {
-            missing = 0;
-
-            if (desired->alphaBits > 0 && current->alphaBits == 0)
-                missing++;
-
-            if (desired->depthBits > 0 && current->depthBits == 0)
-                missing++;
-
-            if (desired->stencilBits > 0 && current->stencilBits == 0)
-                missing++;
-
-            if (desired->auxBuffers > 0 &&
-                current->auxBuffers < desired->auxBuffers)
-            {
-                missing += desired->auxBuffers - current->auxBuffers;
-            }
-
-            if (desired->samples > 0 && current->samples == 0)
-            {
-                // Technically, several multisampling buffers could be
-                // involved, but that's a lower level implementation detail and
-                // not important to us here, so we count them as one
-                missing++;
-            }
-
-            if (desired->transparent != current->transparent)
-                missing++;
-        }
-
-        // These polynomials make many small channel size differences matter
-        // less than one large channel size difference
-
-        // Calculate color channel size difference value
-        {
-            colorDiff = 0;
-
-            if (desired->redBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->redBits - current->redBits) *
-                             (desired->redBits - current->redBits);
-            }
-
-            if (desired->greenBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->greenBits - current->greenBits) *
-                             (desired->greenBits - current->greenBits);
-            }
-
-            if (desired->blueBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->blueBits - current->blueBits) *
-                             (desired->blueBits - current->blueBits);
-            }
-        }
-
-        // Calculate non-color channel size difference value
-        {
-            extraDiff = 0;
-
-            if (desired->alphaBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->alphaBits - current->alphaBits) *
-                             (desired->alphaBits - current->alphaBits);
-            }
-
-            if (desired->depthBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->depthBits - current->depthBits) *
-                             (desired->depthBits - current->depthBits);
-            }
-
-            if (desired->stencilBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->stencilBits - current->stencilBits) *
-                             (desired->stencilBits - current->stencilBits);
-            }
-
-            if (desired->accumRedBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumRedBits - current->accumRedBits) *
-                             (desired->accumRedBits - current->accumRedBits);
-            }
-
-            if (desired->accumGreenBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
-                             (desired->accumGreenBits - current->accumGreenBits);
-            }
-
-            if (desired->accumBlueBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
-                             (desired->accumBlueBits - current->accumBlueBits);
-            }
-
-            if (desired->accumAlphaBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
-                             (desired->accumAlphaBits - current->accumAlphaBits);
-            }
-
-            if (desired->samples != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->samples - current->samples) *
-                             (desired->samples - current->samples);
-            }
-
-            if (desired->sRGB && !current->sRGB)
-                extraDiff++;
-        }
-
-        // Figure out if the current one is better than the best one found so far
-        // Least number of missing buffers is the most important heuristic,
-        // then color buffer size match and lastly size match for other buffers
-
-        if (missing < leastMissing)
-            closest = current;
-        else if (missing == leastMissing)
-        {
-            if ((colorDiff < leastColorDiff) ||
-                (colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
-            {
-                closest = current;
-            }
-        }
-
-        if (current == closest)
-        {
-            leastMissing = missing;
-            leastColorDiff = colorDiff;
-            leastExtraDiff = extraDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Retrieves the attributes of the current context
-//
-GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
-                                    const _GLFWctxconfig* ctxconfig)
-{
-    int i;
-    _GLFWwindow* previous;
-    const char* version;
-    const char* prefixes[] =
-    {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-
-    window->context.source = ctxconfig->source;
-    window->context.client = GLFW_OPENGL_API;
-
-    previous = _glfwPlatformGetTls(&_glfw.contextSlot);
-    glfwMakeContextCurrent((GLFWwindow*) window);
-
-    window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
-        window->context.getProcAddress("glGetIntegerv");
-    window->context.GetString = (PFNGLGETSTRINGPROC)
-        window->context.getProcAddress("glGetString");
-    if (!window->context.GetIntegerv || !window->context.GetString)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    version = (const char*) window->context.GetString(GL_VERSION);
-    if (!version)
-    {
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OpenGL version string retrieval is broken");
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OpenGL ES version string retrieval is broken");
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  prefixes[i];  i++)
-    {
-        const size_t length = strlen(prefixes[i]);
-
-        if (strncmp(version, prefixes[i], length) == 0)
-        {
-            version += length;
-            window->context.client = GLFW_OPENGL_ES_API;
-            break;
-        }
-    }
-
-    if (!sscanf(version, "%d.%d.%d",
-                &window->context.major,
-                &window->context.minor,
-                &window->context.revision))
-    {
-        if (window->context.client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "No version found in OpenGL version string");
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "No version found in OpenGL ES version string");
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major < ctxconfig->major ||
-        (window->context.major == ctxconfig->major &&
-         window->context.minor < ctxconfig->minor))
-    {
-        // The desired OpenGL version is greater than the actual version
-        // This only happens if the machine lacks {GLX|WGL}_ARB_create_context
-        // /and/ the user has requested an OpenGL version greater than 1.0
-
-        // For API consistency, we emulate the behavior of the
-        // {GLX|WGL}_ARB_create_context extension and fail here
-
-        if (window->context.client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "Requested OpenGL version %i.%i, got version %i.%i",
-                            ctxconfig->major, ctxconfig->minor,
-                            window->context.major, window->context.minor);
-        }
-        else
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "Requested OpenGL ES version %i.%i, got version %i.%i",
-                            ctxconfig->major, ctxconfig->minor,
-                            window->context.major, window->context.minor);
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major >= 3)
-    {
-        // OpenGL 3.0+ uses a different function for extension string retrieval
-        // We cache it here instead of in glfwExtensionSupported mostly to alert
-        // users as early as possible that their build may be broken
-
-        window->context.GetStringi = (PFNGLGETSTRINGIPROC)
-            window->context.getProcAddress("glGetStringi");
-        if (!window->context.GetStringi)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Entry point retrieval is broken");
-            glfwMakeContextCurrent((GLFWwindow*) previous);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (window->context.client == GLFW_OPENGL_API)
-    {
-        // Read back context flags (OpenGL 3.0 and above)
-        if (window->context.major >= 3)
-        {
-            GLint flags;
-            window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
-
-            if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
-                window->context.forward = GLFW_TRUE;
-
-            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
-                window->context.debug = GLFW_TRUE;
-            else if (glfwExtensionSupported("GL_ARB_debug_output") &&
-                     ctxconfig->debug)
-            {
-                // HACK: This is a workaround for older drivers (pre KHR_debug)
-                //       not setting the debug bit in the context flags for
-                //       debug contexts
-                window->context.debug = GLFW_TRUE;
-            }
-
-            if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
-                window->context.noerror = GLFW_TRUE;
-        }
-
-        // Read back OpenGL context profile (OpenGL 3.2 and above)
-        if (window->context.major >= 4 ||
-            (window->context.major == 3 && window->context.minor >= 2))
-        {
-            GLint mask;
-            window->context.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
-
-            if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
-                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
-            else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
-                window->context.profile = GLFW_OPENGL_CORE_PROFILE;
-            else if (glfwExtensionSupported("GL_ARB_compatibility"))
-            {
-                // HACK: This is a workaround for the compatibility profile bit
-                //       not being set in the context flags if an OpenGL 3.2+
-                //       context was created without having requested a specific
-                //       version
-                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
-            }
-        }
-
-        // Read back robustness strategy
-        if (glfwExtensionSupported("GL_ARB_robustness"))
-        {
-            // NOTE: We avoid using the context flags for detection, as they are
-            //       only present from 3.0 while the extension applies from 1.1
-
-            GLint strategy;
-            window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
-                                        &strategy);
-
-            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
-                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
-            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
-                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
-        }
-    }
-    else
-    {
-        // Read back robustness strategy
-        if (glfwExtensionSupported("GL_EXT_robustness"))
-        {
-            // NOTE: The values of these constants match those of the OpenGL ARB
-            //       one, so we can reuse them here
-
-            GLint strategy;
-            window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
-                                        &strategy);
-
-            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
-                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
-            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
-                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
-        }
-    }
-
-    if (glfwExtensionSupported("GL_KHR_context_flush_control"))
-    {
-        GLint behavior;
-        window->context.GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
-
-        if (behavior == GL_NONE)
-            window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
-        else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
-            window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
-    }
-
-    // Clearing the front buffer to black to avoid garbage pixels left over from
-    // previous uses of our bit of VRAM
-    {
-        PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
-            window->context.getProcAddress("glClear");
-        glClear(GL_COLOR_BUFFER_BIT);
-        window->context.swapBuffers(window);
-    }
-
-    glfwMakeContextCurrent((GLFWwindow*) previous);
-    return GLFW_TRUE;
-}
-
-// Searches an extension string for the specified extension
-//
-GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
-{
-    const char* start = extensions;
-
-    for (;;)
-    {
-        const char* where;
-        const char* terminator;
-
-        where = strstr(start, string);
-        if (!where)
-            return GLFW_FALSE;
-
-        terminator = where + strlen(string);
-        if (where == start || *(where - 1) == ' ')
-        {
-            if (*terminator == ' ' || *terminator == '\0')
-                break;
-        }
-
-        start = terminator;
-    }
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window && window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
-                        "Cannot make current with a window that has no OpenGL or OpenGL ES context");
-        return;
-    }
-
-    if (previous)
-    {
-        if (!window || window->context.source != previous->context.source)
-            previous->context.makeCurrent(NULL);
-    }
-
-    if (window)
-        window->context.makeCurrent(window);
-}
-
-GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfwPlatformGetTls(&_glfw.contextSlot);
-}
-
-GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
-                        "Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
-        return;
-    }
-
-    window->context.swapBuffers(window);
-}
-
-GLFWAPI void glfwSwapInterval(int interval)
-{
-    _GLFWwindow* window;
-
-    _GLFW_REQUIRE_INIT();
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot set swap interval without a current OpenGL or OpenGL ES context");
-        return;
-    }
-
-    window->context.swapInterval(interval);
-}
-
-GLFWAPI int glfwExtensionSupported(const char* extension)
-{
-    _GLFWwindow* window;
-    assert(extension != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot query extension without a current OpenGL or OpenGL ES context");
-        return GLFW_FALSE;
-    }
-
-    if (*extension == '\0')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major >= 3)
-    {
-        int i;
-        GLint count;
-
-        // Check if extension is in the modern OpenGL extensions string list
-
-        window->context.GetIntegerv(GL_NUM_EXTENSIONS, &count);
-
-        for (i = 0;  i < count;  i++)
-        {
-            const char* en = (const char*)
-                window->context.GetStringi(GL_EXTENSIONS, i);
-            if (!en)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Extension string retrieval is broken");
-                return GLFW_FALSE;
-            }
-
-            if (strcmp(en, extension) == 0)
-                return GLFW_TRUE;
-        }
-    }
-    else
-    {
-        // Check if extension is in the old style OpenGL extensions string
-
-        const char* extensions = (const char*)
-            window->context.GetString(GL_EXTENSIONS);
-        if (!extensions)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Extension string retrieval is broken");
-            return GLFW_FALSE;
-        }
-
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    // Check if extension is in the platform-specific string
-    return window->context.extensionSupported(extension);
-}
-
-GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
-{
-    _GLFWwindow* window;
-    assert(procname != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot query entry point without a current OpenGL or OpenGL ES context");
-        return NULL;
-    }
-
-    return window->context.getProcAddress(procname);
-}
-
diff --git a/raylib/external/glfw/src/egl_context.c b/raylib/external/glfw/src/egl_context.c
deleted file mode 100644 (file)
index 533ed8e..0000000
+++ /dev/null
@@ -1,843 +0,0 @@
-//========================================================================
-// GLFW 3.4 EGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-// Return a description of the specified EGL error
-//
-static const char* getEGLErrorString(EGLint error)
-{
-    switch (error)
-    {
-        case EGL_SUCCESS:
-            return "Success";
-        case EGL_NOT_INITIALIZED:
-            return "EGL is not or could not be initialized";
-        case EGL_BAD_ACCESS:
-            return "EGL cannot access a requested resource";
-        case EGL_BAD_ALLOC:
-            return "EGL failed to allocate resources for the requested operation";
-        case EGL_BAD_ATTRIBUTE:
-            return "An unrecognized attribute or attribute value was passed in the attribute list";
-        case EGL_BAD_CONTEXT:
-            return "An EGLContext argument does not name a valid EGL rendering context";
-        case EGL_BAD_CONFIG:
-            return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
-        case EGL_BAD_CURRENT_SURFACE:
-            return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
-        case EGL_BAD_DISPLAY:
-            return "An EGLDisplay argument does not name a valid EGL display connection";
-        case EGL_BAD_SURFACE:
-            return "An EGLSurface argument does not name a valid surface configured for GL rendering";
-        case EGL_BAD_MATCH:
-            return "Arguments are inconsistent";
-        case EGL_BAD_PARAMETER:
-            return "One or more argument values are invalid";
-        case EGL_BAD_NATIVE_PIXMAP:
-            return "A NativePixmapType argument does not refer to a valid native pixmap";
-        case EGL_BAD_NATIVE_WINDOW:
-            return "A NativeWindowType argument does not refer to a valid native window";
-        case EGL_CONTEXT_LOST:
-            return "The application must destroy all contexts and reinitialise";
-        default:
-            return "ERROR: UNKNOWN EGL ERROR";
-    }
-}
-
-// Returns the specified attribute of the specified EGLConfig
-//
-static int getEGLConfigAttrib(EGLConfig config, int attrib)
-{
-    int value;
-    eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
-    return value;
-}
-
-// Return the EGLConfig most closely matching the specified hints
-//
-static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* desired,
-                                EGLConfig* result)
-{
-    EGLConfig* nativeConfigs;
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, nativeCount, usableCount;
-
-    eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
-    if (!nativeCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
-        return GLFW_FALSE;
-    }
-
-    nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));
-    eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-    usableCount = 0;
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        const EGLConfig n = nativeConfigs[i];
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-
-        // Only consider RGB(A) EGLConfigs
-        if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
-            continue;
-
-        // Only consider window EGLConfigs
-        if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
-            continue;
-
-#if defined(_GLFW_X11)
-        {
-            XVisualInfo vi = {0};
-
-            // Only consider EGLConfigs with associated Visuals
-            vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
-            if (!vi.visualid)
-                continue;
-
-            if (desired->transparent)
-            {
-                int count;
-                XVisualInfo* vis =
-                    XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
-                if (vis)
-                {
-                    u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
-                    XFree(vis);
-                }
-            }
-        }
-#endif // _GLFW_X11
-
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-        {
-            if (ctxconfig->major == 1)
-            {
-                if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
-                    continue;
-            }
-            else
-            {
-                if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
-                    continue;
-            }
-        }
-        else if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
-                continue;
-        }
-
-        u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
-        u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
-        u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
-
-        u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
-        u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
-        u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
-
-        u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
-        u->doublebuffer = GLFW_TRUE;
-
-        u->handle = (uintptr_t) n;
-        usableCount++;
-    }
-
-    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
-    if (closest)
-        *result = (EGLConfig) closest->handle;
-
-    free(nativeConfigs);
-    free(usableConfigs);
-
-    return closest != NULL;
-}
-
-static void makeContextCurrentEGL(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (!eglMakeCurrent(_glfw.egl.display,
-                            window->context.egl.surface,
-                            window->context.egl.surface,
-                            window->context.egl.handle))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "EGL: Failed to make context current: %s",
-                            getEGLErrorString(eglGetError()));
-            return;
-        }
-    }
-    else
-    {
-        if (!eglMakeCurrent(_glfw.egl.display,
-                            EGL_NO_SURFACE,
-                            EGL_NO_SURFACE,
-                            EGL_NO_CONTEXT))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "EGL: Failed to clear current context: %s",
-                            getEGLErrorString(eglGetError()));
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static void swapBuffersEGL(_GLFWwindow* window)
-{
-    if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: The context must be current on the calling thread when swapping buffers");
-        return;
-    }
-
-    eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
-}
-
-static void swapIntervalEGL(int interval)
-{
-    eglSwapInterval(_glfw.egl.display, interval);
-}
-
-static int extensionSupportedEGL(const char* extension)
-{
-    const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
-    if (extensions)
-    {
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressEGL(const char* procname)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    if (window->context.egl.client)
-    {
-        GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
-                                                   procname);
-        if (proc)
-            return proc;
-    }
-
-    return eglGetProcAddress(procname);
-}
-
-static void destroyContextEGL(_GLFWwindow* window)
-{
-#if defined(_GLFW_X11)
-    // NOTE: Do not unload libGL.so.1 while the X11 display is still open,
-    //       as it will make XCloseDisplay segfault
-    if (window->context.client != GLFW_OPENGL_API)
-#endif // _GLFW_X11
-    {
-        if (window->context.egl.client)
-        {
-            _glfw_dlclose(window->context.egl.client);
-            window->context.egl.client = NULL;
-        }
-    }
-
-    if (window->context.egl.surface)
-    {
-        eglDestroySurface(_glfw.egl.display, window->context.egl.surface);
-        window->context.egl.surface = EGL_NO_SURFACE;
-    }
-
-    if (window->context.egl.handle)
-    {
-        eglDestroyContext(_glfw.egl.display, window->context.egl.handle);
-        window->context.egl.handle = EGL_NO_CONTEXT;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize EGL
-//
-GLFWbool _glfwInitEGL(void)
-{
-    int i;
-    EGLint* attribs = NULL;
-    const char* extensions;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_EGL_LIBRARY)
-        _GLFW_EGL_LIBRARY,
-#elif defined(_GLFW_WIN32)
-        "libEGL.dll",
-        "EGL.dll",
-#elif defined(_GLFW_COCOA)
-        "libEGL.dylib",
-#elif defined(__CYGWIN__)
-        "libEGL-1.so",
-#else
-        "libEGL.so.1",
-#endif
-        NULL
-    };
-
-    if (_glfw.egl.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.egl.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.egl.handle)
-            break;
-    }
-
-    if (!_glfw.egl.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
-        return GLFW_FALSE;
-    }
-
-    _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
-
-    _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
-    _glfw.egl.GetConfigs = (PFN_eglGetConfigs)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
-    _glfw.egl.GetDisplay = (PFN_eglGetDisplay)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
-    _glfw.egl.GetError = (PFN_eglGetError)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetError");
-    _glfw.egl.Initialize = (PFN_eglInitialize)
-        _glfw_dlsym(_glfw.egl.handle, "eglInitialize");
-    _glfw.egl.Terminate = (PFN_eglTerminate)
-        _glfw_dlsym(_glfw.egl.handle, "eglTerminate");
-    _glfw.egl.BindAPI = (PFN_eglBindAPI)
-        _glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
-    _glfw.egl.CreateContext = (PFN_eglCreateContext)
-        _glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
-    _glfw.egl.DestroySurface = (PFN_eglDestroySurface)
-        _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
-    _glfw.egl.DestroyContext = (PFN_eglDestroyContext)
-        _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
-    _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
-        _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
-    _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
-        _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
-    _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
-        _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
-    _glfw.egl.SwapInterval = (PFN_eglSwapInterval)
-        _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
-    _glfw.egl.QueryString = (PFN_eglQueryString)
-        _glfw_dlsym(_glfw.egl.handle, "eglQueryString");
-    _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
-
-    if (!_glfw.egl.GetConfigAttrib ||
-        !_glfw.egl.GetConfigs ||
-        !_glfw.egl.GetDisplay ||
-        !_glfw.egl.GetError ||
-        !_glfw.egl.Initialize ||
-        !_glfw.egl.Terminate ||
-        !_glfw.egl.BindAPI ||
-        !_glfw.egl.CreateContext ||
-        !_glfw.egl.DestroySurface ||
-        !_glfw.egl.DestroyContext ||
-        !_glfw.egl.CreateWindowSurface ||
-        !_glfw.egl.MakeCurrent ||
-        !_glfw.egl.SwapBuffers ||
-        !_glfw.egl.SwapInterval ||
-        !_glfw.egl.QueryString ||
-        !_glfw.egl.GetProcAddress)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to load required entry points");
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
-    if (extensions && eglGetError() == EGL_SUCCESS)
-        _glfw.egl.EXT_client_extensions = GLFW_TRUE;
-
-    if (_glfw.egl.EXT_client_extensions)
-    {
-        _glfw.egl.EXT_platform_base =
-            _glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
-        _glfw.egl.EXT_platform_x11 =
-            _glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
-        _glfw.egl.EXT_platform_wayland =
-            _glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
-        _glfw.egl.ANGLE_platform_angle =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
-        _glfw.egl.ANGLE_platform_angle_opengl =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
-        _glfw.egl.ANGLE_platform_angle_d3d =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
-        _glfw.egl.ANGLE_platform_angle_vulkan =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
-        _glfw.egl.ANGLE_platform_angle_metal =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
-    }
-
-    if (_glfw.egl.EXT_platform_base)
-    {
-        _glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
-            eglGetProcAddress("eglGetPlatformDisplayEXT");
-        _glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
-            eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
-    }
-
-    _glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
-    if (_glfw.egl.platform)
-    {
-        _glfw.egl.display =
-            eglGetPlatformDisplayEXT(_glfw.egl.platform,
-                                     _glfwPlatformGetEGLNativeDisplay(),
-                                     attribs);
-    }
-    else
-        _glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
-
-    free(attribs);
-
-    if (_glfw.egl.display == EGL_NO_DISPLAY)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "EGL: Failed to get EGL display: %s",
-                        getEGLErrorString(eglGetError()));
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "EGL: Failed to initialize EGL: %s",
-                        getEGLErrorString(eglGetError()));
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    _glfw.egl.KHR_create_context =
-        extensionSupportedEGL("EGL_KHR_create_context");
-    _glfw.egl.KHR_create_context_no_error =
-        extensionSupportedEGL("EGL_KHR_create_context_no_error");
-    _glfw.egl.KHR_gl_colorspace =
-        extensionSupportedEGL("EGL_KHR_gl_colorspace");
-    _glfw.egl.KHR_get_all_proc_addresses =
-        extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
-    _glfw.egl.KHR_context_flush_control =
-        extensionSupportedEGL("EGL_KHR_context_flush_control");
-
-    return GLFW_TRUE;
-}
-
-// Terminate EGL
-//
-void _glfwTerminateEGL(void)
-{
-    if (_glfw.egl.display)
-    {
-        eglTerminate(_glfw.egl.display);
-        _glfw.egl.display = EGL_NO_DISPLAY;
-    }
-
-    if (_glfw.egl.handle)
-    {
-        _glfw_dlclose(_glfw.egl.handle);
-        _glfw.egl.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    EGLint attribs[40];
-    EGLConfig config;
-    EGLContext share = NULL;
-    EGLNativeWindowType native;
-    int index = 0;
-
-    if (!_glfw.egl.display)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.egl.handle;
-
-    if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "EGL: Failed to find a suitable EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (!eglBindAPI(EGL_OPENGL_ES_API))
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to bind OpenGL ES: %s",
-                            getEGLErrorString(eglGetError()));
-            return GLFW_FALSE;
-        }
-    }
-    else
-    {
-        if (!eglBindAPI(EGL_OPENGL_API))
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to bind OpenGL: %s",
-                            getEGLErrorString(eglGetError()));
-            return GLFW_FALSE;
-        }
-    }
-
-    if (_glfw.egl.KHR_create_context)
-    {
-        int mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
-        }
-
-        if (ctxconfig->debug)
-            flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
-        if (ctxconfig->robustness)
-        {
-            if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-            {
-                setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
-                          EGL_NO_RESET_NOTIFICATION_KHR);
-            }
-            else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-            {
-                setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
-                          EGL_LOSE_CONTEXT_ON_RESET_KHR);
-            }
-
-            flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.egl.KHR_create_context_no_error)
-                setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
-        }
-
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
-            setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
-        }
-
-        if (mask)
-            setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
-
-        if (flags)
-            setAttrib(EGL_CONTEXT_FLAGS_KHR, flags);
-    }
-    else
-    {
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-            setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
-    }
-
-    if (_glfw.egl.KHR_context_flush_control)
-    {
-        if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-        {
-            setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
-                      EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
-        }
-        else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-        {
-            setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
-                      EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
-        }
-    }
-
-    setAttrib(EGL_NONE, EGL_NONE);
-
-    window->context.egl.handle = eglCreateContext(_glfw.egl.display,
-                                                  config, share, attribs);
-
-    if (window->context.egl.handle == EGL_NO_CONTEXT)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "EGL: Failed to create context: %s",
-                        getEGLErrorString(eglGetError()));
-        return GLFW_FALSE;
-    }
-
-    // Set up attributes for surface creation
-    index = 0;
-
-    if (fbconfig->sRGB)
-    {
-        if (_glfw.egl.KHR_gl_colorspace)
-            setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
-    }
-
-    setAttrib(EGL_NONE, EGL_NONE);
-
-    native = _glfwPlatformGetEGLNativeWindow(window);
-    // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
-    //       despite reporting EGL_EXT_platform_base
-    if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
-    {
-        window->context.egl.surface =
-            eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
-    }
-    else
-    {
-        window->context.egl.surface =
-            eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
-    }
-
-    if (window->context.egl.surface == EGL_NO_SURFACE)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to create window surface: %s",
-                        getEGLErrorString(eglGetError()));
-        return GLFW_FALSE;
-    }
-
-    window->context.egl.config = config;
-
-    // Load the appropriate client library
-    if (!_glfw.egl.KHR_get_all_proc_addresses)
-    {
-        int i;
-        const char** sonames;
-        const char* es1sonames[] =
-        {
-#if defined(_GLFW_GLESV1_LIBRARY)
-            _GLFW_GLESV1_LIBRARY,
-#elif defined(_GLFW_WIN32)
-            "GLESv1_CM.dll",
-            "libGLES_CM.dll",
-#elif defined(_GLFW_COCOA)
-            "libGLESv1_CM.dylib",
-#else
-            "libGLESv1_CM.so.1",
-            "libGLES_CM.so.1",
-#endif
-            NULL
-        };
-        const char* es2sonames[] =
-        {
-#if defined(_GLFW_GLESV2_LIBRARY)
-            _GLFW_GLESV2_LIBRARY,
-#elif defined(_GLFW_WIN32)
-            "GLESv2.dll",
-            "libGLESv2.dll",
-#elif defined(_GLFW_COCOA)
-            "libGLESv2.dylib",
-#elif defined(__CYGWIN__)
-            "libGLESv2-2.so",
-#else
-            "libGLESv2.so.2",
-#endif
-            NULL
-        };
-        const char* glsonames[] =
-        {
-#if defined(_GLFW_OPENGL_LIBRARY)
-            _GLFW_OPENGL_LIBRARY,
-#elif defined(_GLFW_WIN32)
-#elif defined(_GLFW_COCOA)
-#else
-            "libGL.so.1",
-#endif
-            NULL
-        };
-
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-        {
-            if (ctxconfig->major == 1)
-                sonames = es1sonames;
-            else
-                sonames = es2sonames;
-        }
-        else
-            sonames = glsonames;
-
-        for (i = 0;  sonames[i];  i++)
-        {
-            // HACK: Match presence of lib prefix to increase chance of finding
-            //       a matching pair in the jungle that is Win32 EGL/GLES
-            if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
-                continue;
-
-            window->context.egl.client = _glfw_dlopen(sonames[i]);
-            if (window->context.egl.client)
-                break;
-        }
-
-        if (!window->context.egl.client)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to load client library");
-            return GLFW_FALSE;
-        }
-    }
-
-    window->context.makeCurrent = makeContextCurrentEGL;
-    window->context.swapBuffers = swapBuffersEGL;
-    window->context.swapInterval = swapIntervalEGL;
-    window->context.extensionSupported = extensionSupportedEGL;
-    window->context.getProcAddress = getProcAddressEGL;
-    window->context.destroy = destroyContextEGL;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-// Returns the Visual and depth of the chosen EGLConfig
-//
-#if defined(_GLFW_X11)
-GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth)
-{
-    XVisualInfo* result;
-    XVisualInfo desired;
-    EGLConfig native;
-    EGLint visualID = 0, count = 0;
-    const long vimask = VisualScreenMask | VisualIDMask;
-
-    if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "EGL: Failed to find a suitable EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    eglGetConfigAttrib(_glfw.egl.display, native,
-                       EGL_NATIVE_VISUAL_ID, &visualID);
-
-    desired.screen = _glfw.x11.screen;
-    desired.visualid = visualID;
-
-    result = XGetVisualInfo(_glfw.x11.display, vimask, &desired, &count);
-    if (!result)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to retrieve Visual for EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    *visual = result->visual;
-    *depth = result->depth;
-
-    XFree(result);
-    return GLFW_TRUE;
-}
-#endif // _GLFW_X11
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
-    return _glfw.egl.display;
-}
-
-GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return EGL_NO_CONTEXT;
-    }
-
-    return window->context.egl.handle;
-}
-
-GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return EGL_NO_SURFACE;
-    }
-
-    return window->context.egl.surface;
-}
-
diff --git a/raylib/external/glfw/src/egl_context.h b/raylib/external/glfw/src/egl_context.h
deleted file mode 100644 (file)
index 9de424c..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-//========================================================================
-// GLFW 3.4 EGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#if defined(_GLFW_WIN32)
- #define EGLAPIENTRY __stdcall
-#else
- #define EGLAPIENTRY
-#endif
-
-#define EGL_SUCCESS 0x3000
-#define EGL_NOT_INITIALIZED 0x3001
-#define EGL_BAD_ACCESS 0x3002
-#define EGL_BAD_ALLOC 0x3003
-#define EGL_BAD_ATTRIBUTE 0x3004
-#define EGL_BAD_CONFIG 0x3005
-#define EGL_BAD_CONTEXT 0x3006
-#define EGL_BAD_CURRENT_SURFACE 0x3007
-#define EGL_BAD_DISPLAY 0x3008
-#define EGL_BAD_MATCH 0x3009
-#define EGL_BAD_NATIVE_PIXMAP 0x300a
-#define EGL_BAD_NATIVE_WINDOW 0x300b
-#define EGL_BAD_PARAMETER 0x300c
-#define EGL_BAD_SURFACE 0x300d
-#define EGL_CONTEXT_LOST 0x300e
-#define EGL_COLOR_BUFFER_TYPE 0x303f
-#define EGL_RGB_BUFFER 0x308e
-#define EGL_SURFACE_TYPE 0x3033
-#define EGL_WINDOW_BIT 0x0004
-#define EGL_RENDERABLE_TYPE 0x3040
-#define EGL_OPENGL_ES_BIT 0x0001
-#define EGL_OPENGL_ES2_BIT 0x0004
-#define EGL_OPENGL_BIT 0x0008
-#define EGL_ALPHA_SIZE 0x3021
-#define EGL_BLUE_SIZE 0x3022
-#define EGL_GREEN_SIZE 0x3023
-#define EGL_RED_SIZE 0x3024
-#define EGL_DEPTH_SIZE 0x3025
-#define EGL_STENCIL_SIZE 0x3026
-#define EGL_SAMPLES 0x3031
-#define EGL_OPENGL_ES_API 0x30a0
-#define EGL_OPENGL_API 0x30a2
-#define EGL_NONE 0x3038
-#define EGL_EXTENSIONS 0x3055
-#define EGL_CONTEXT_CLIENT_VERSION 0x3098
-#define EGL_NATIVE_VISUAL_ID 0x302e
-#define EGL_NO_SURFACE ((EGLSurface) 0)
-#define EGL_NO_DISPLAY ((EGLDisplay) 0)
-#define EGL_NO_CONTEXT ((EGLContext) 0)
-#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
-
-#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
-#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
-#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
-#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
-#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
-#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
-#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
-#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
-#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
-#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
-#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
-#define EGL_CONTEXT_FLAGS_KHR 0x30fc
-#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
-#define EGL_GL_COLORSPACE_KHR 0x309d
-#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
-#define EGL_PLATFORM_X11_EXT 0x31d5
-#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
-#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
-#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
-#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
-#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
-#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
-#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
-#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
-#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
-#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
-
-typedef int EGLint;
-typedef unsigned int EGLBoolean;
-typedef unsigned int EGLenum;
-typedef void* EGLConfig;
-typedef void* EGLContext;
-typedef void* EGLDisplay;
-typedef void* EGLSurface;
-
-typedef void* EGLNativeDisplayType;
-typedef void* EGLNativeWindowType;
-
-// EGL function pointer typedefs
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
-typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
-typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
-typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
-typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
-typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
-typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
-#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
-#define eglGetConfigs _glfw.egl.GetConfigs
-#define eglGetDisplay _glfw.egl.GetDisplay
-#define eglGetError _glfw.egl.GetError
-#define eglInitialize _glfw.egl.Initialize
-#define eglTerminate _glfw.egl.Terminate
-#define eglBindAPI _glfw.egl.BindAPI
-#define eglCreateContext _glfw.egl.CreateContext
-#define eglDestroySurface _glfw.egl.DestroySurface
-#define eglDestroyContext _glfw.egl.DestroyContext
-#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
-#define eglMakeCurrent _glfw.egl.MakeCurrent
-#define eglSwapBuffers _glfw.egl.SwapBuffers
-#define eglSwapInterval _glfw.egl.SwapInterval
-#define eglQueryString _glfw.egl.QueryString
-#define eglGetProcAddress _glfw.egl.GetProcAddress
-
-typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
-typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
-#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
-#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
-
-// EGL-specific per-context data
-//
-typedef struct _GLFWcontextEGL
-{
-   EGLConfig        config;
-   EGLContext       handle;
-   EGLSurface       surface;
-
-   void*            client;
-
-} _GLFWcontextEGL;
-
-// EGL-specific global data
-//
-typedef struct _GLFWlibraryEGL
-{
-    EGLenum         platform;
-    EGLDisplay      display;
-    EGLint          major, minor;
-    GLFWbool        prefix;
-
-    GLFWbool        KHR_create_context;
-    GLFWbool        KHR_create_context_no_error;
-    GLFWbool        KHR_gl_colorspace;
-    GLFWbool        KHR_get_all_proc_addresses;
-    GLFWbool        KHR_context_flush_control;
-    GLFWbool        EXT_client_extensions;
-    GLFWbool        EXT_platform_base;
-    GLFWbool        EXT_platform_x11;
-    GLFWbool        EXT_platform_wayland;
-    GLFWbool        ANGLE_platform_angle;
-    GLFWbool        ANGLE_platform_angle_opengl;
-    GLFWbool        ANGLE_platform_angle_d3d;
-    GLFWbool        ANGLE_platform_angle_vulkan;
-    GLFWbool        ANGLE_platform_angle_metal;
-
-    void*           handle;
-
-    PFN_eglGetConfigAttrib      GetConfigAttrib;
-    PFN_eglGetConfigs           GetConfigs;
-    PFN_eglGetDisplay           GetDisplay;
-    PFN_eglGetError             GetError;
-    PFN_eglInitialize           Initialize;
-    PFN_eglTerminate            Terminate;
-    PFN_eglBindAPI              BindAPI;
-    PFN_eglCreateContext        CreateContext;
-    PFN_eglDestroySurface       DestroySurface;
-    PFN_eglDestroyContext       DestroyContext;
-    PFN_eglCreateWindowSurface  CreateWindowSurface;
-    PFN_eglMakeCurrent          MakeCurrent;
-    PFN_eglSwapBuffers          SwapBuffers;
-    PFN_eglSwapInterval         SwapInterval;
-    PFN_eglQueryString          QueryString;
-    PFN_eglGetProcAddress       GetProcAddress;
-
-    PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
-    PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
-
-} _GLFWlibraryEGL;
-
-
-GLFWbool _glfwInitEGL(void);
-void _glfwTerminateEGL(void);
-GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-#if defined(_GLFW_X11)
-GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth);
-#endif /*_GLFW_X11*/
-
diff --git a/raylib/external/glfw/src/glfw.rc.in b/raylib/external/glfw/src/glfw.rc.in
deleted file mode 100644 (file)
index ac3460a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-
-#include <winver.h>
-
-VS_VERSION_INFO VERSIONINFO
-FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
-PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
-FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-FILEFLAGS 0
-FILEOS VOS_NT_WINDOWS32
-FILETYPE VFT_DLL
-FILESUBTYPE 0
-{
-    BLOCK "StringFileInfo"
-    {
-        BLOCK "040904B0"
-        {
-            VALUE "CompanyName", "GLFW"
-            VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL"
-            VALUE "FileVersion", "@GLFW_VERSION@"
-            VALUE "OriginalFilename", "glfw3.dll"
-            VALUE "ProductName", "GLFW"
-            VALUE "ProductVersion", "@GLFW_VERSION@"
-        }
-    }
-    BLOCK "VarFileInfo"
-    {
-        VALUE "Translation", 0x409, 1200
-    }
-}
-
diff --git a/raylib/external/glfw/src/glfw_config.h.in b/raylib/external/glfw/src/glfw_config.h.in
deleted file mode 100644 (file)
index f4876da..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As glfw_config.h.in, this file is used by CMake to produce the
-// glfw_config.h configuration header file.  If you are adding a feature
-// requiring conditional compilation, this is where to add the macro.
-//========================================================================
-// As glfw_config.h, this file defines compile-time option macros for a
-// specific platform and development environment.  If you are using the
-// GLFW CMake files, modify glfw_config.h.in instead of this file.  If you
-// are using your own build system, make this file define the appropriate
-// macros in whatever way is suitable.
-//========================================================================
-
-// Define this to 1 if building GLFW for X11
-#cmakedefine _GLFW_X11
-// Define this to 1 if building GLFW for Win32
-#cmakedefine _GLFW_WIN32
-// Define this to 1 if building GLFW for Cocoa
-#cmakedefine _GLFW_COCOA
-// Define this to 1 if building GLFW for Wayland
-#cmakedefine _GLFW_WAYLAND
-// Define this to 1 if building GLFW for OSMesa
-#cmakedefine _GLFW_OSMESA
-
-// Define this to 1 to use Vulkan loader linked statically into application
-#cmakedefine _GLFW_VULKAN_STATIC
-
-// Define this to 1 to force use of high-performance GPU on hybrid systems
-#cmakedefine _GLFW_USE_HYBRID_HPG
-
-// Define this to 1 if xkbcommon supports the compose key
-#cmakedefine HAVE_XKBCOMMON_COMPOSE_H
-// Define this to 1 if the libc supports memfd_create()
-#cmakedefine HAVE_MEMFD_CREATE
-
diff --git a/raylib/external/glfw/src/glx_context.c b/raylib/external/glfw/src/glx_context.c
deleted file mode 100644 (file)
index 7ccd137..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-//========================================================================
-// GLFW 3.4 GLX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#ifndef GLXBadProfileARB
- #define GLXBadProfileARB 13
-#endif
-
-
-// Returns the specified attribute of the specified GLXFBConfig
-//
-static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
-{
-    int value;
-    glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
-    return value;
-}
-
-// Return the GLXFBConfig most closely matching the specified hints
-//
-static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
-                                  GLXFBConfig* result)
-{
-    GLXFBConfig* nativeConfigs;
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, nativeCount, usableCount;
-    const char* vendor;
-    GLFWbool trustWindowBit = GLFW_TRUE;
-
-    // HACK: This is a (hopefully temporary) workaround for Chromium
-    //       (VirtualBox GL) not setting the window bit on any GLXFBConfigs
-    vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
-    if (vendor && strcmp(vendor, "Chromium") == 0)
-        trustWindowBit = GLFW_FALSE;
-
-    nativeConfigs =
-        glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
-    if (!nativeConfigs || !nativeCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
-        return GLFW_FALSE;
-    }
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-    usableCount = 0;
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        const GLXFBConfig n = nativeConfigs[i];
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-
-        // Only consider RGBA GLXFBConfigs
-        if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
-            continue;
-
-        // Only consider window GLXFBConfigs
-        if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
-        {
-            if (trustWindowBit)
-                continue;
-        }
-
-        if (desired->transparent)
-        {
-            XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
-            if (vi)
-            {
-                u->transparent = _glfwIsVisualTransparentX11(vi->visual);
-                XFree(vi);
-            }
-        }
-
-        u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
-        u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
-        u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
-
-        u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
-        u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
-        u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
-
-        u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
-        u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
-        u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
-        u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
-
-        u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
-
-        if (getGLXFBConfigAttrib(n, GLX_STEREO))
-            u->stereo = GLFW_TRUE;
-        if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
-            u->doublebuffer = GLFW_TRUE;
-
-        if (_glfw.glx.ARB_multisample)
-            u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
-
-        if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
-            u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
-
-        u->handle = (uintptr_t) n;
-        usableCount++;
-    }
-
-    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
-    if (closest)
-        *result = (GLXFBConfig) closest->handle;
-
-    XFree(nativeConfigs);
-    free(usableConfigs);
-
-    return closest != NULL;
-}
-
-// Create the OpenGL context using legacy API
-//
-static GLXContext createLegacyContextGLX(_GLFWwindow* window,
-                                         GLXFBConfig fbconfig,
-                                         GLXContext share)
-{
-    return glXCreateNewContext(_glfw.x11.display,
-                               fbconfig,
-                               GLX_RGBA_TYPE,
-                               share,
-                               True);
-}
-
-static void makeContextCurrentGLX(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (!glXMakeCurrent(_glfw.x11.display,
-                            window->context.glx.window,
-                            window->context.glx.handle))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "GLX: Failed to make context current");
-            return;
-        }
-    }
-    else
-    {
-        if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "GLX: Failed to clear current context");
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static void swapBuffersGLX(_GLFWwindow* window)
-{
-    glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
-}
-
-static void swapIntervalGLX(int interval)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    if (_glfw.glx.EXT_swap_control)
-    {
-        _glfw.glx.SwapIntervalEXT(_glfw.x11.display,
-                                  window->context.glx.window,
-                                  interval);
-    }
-    else if (_glfw.glx.MESA_swap_control)
-        _glfw.glx.SwapIntervalMESA(interval);
-    else if (_glfw.glx.SGI_swap_control)
-    {
-        if (interval > 0)
-            _glfw.glx.SwapIntervalSGI(interval);
-    }
-}
-
-static int extensionSupportedGLX(const char* extension)
-{
-    const char* extensions =
-        glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
-    if (extensions)
-    {
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressGLX(const char* procname)
-{
-    if (_glfw.glx.GetProcAddress)
-        return _glfw.glx.GetProcAddress((const GLubyte*) procname);
-    else if (_glfw.glx.GetProcAddressARB)
-        return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
-    else
-        return _glfw_dlsym(_glfw.glx.handle, procname);
-}
-
-static void destroyContextGLX(_GLFWwindow* window)
-{
-    if (window->context.glx.window)
-    {
-        glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
-        window->context.glx.window = None;
-    }
-
-    if (window->context.glx.handle)
-    {
-        glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
-        window->context.glx.handle = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize GLX
-//
-GLFWbool _glfwInitGLX(void)
-{
-    int i;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_GLX_LIBRARY)
-        _GLFW_GLX_LIBRARY,
-#elif defined(__CYGWIN__)
-        "libGL-1.so",
-#else
-        "libGL.so.1",
-        "libGL.so",
-#endif
-        NULL
-    };
-
-    if (_glfw.glx.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.glx.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.glx.handle)
-            break;
-    }
-
-    if (!_glfw.glx.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
-        return GLFW_FALSE;
-    }
-
-    _glfw.glx.GetFBConfigs =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
-    _glfw.glx.GetFBConfigAttrib =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
-    _glfw.glx.GetClientString =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
-    _glfw.glx.QueryExtension =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
-    _glfw.glx.QueryVersion =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
-    _glfw.glx.DestroyContext =
-        _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
-    _glfw.glx.MakeCurrent =
-        _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
-    _glfw.glx.SwapBuffers =
-        _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
-    _glfw.glx.QueryExtensionsString =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
-    _glfw.glx.CreateNewContext =
-        _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
-    _glfw.glx.CreateWindow =
-        _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
-    _glfw.glx.DestroyWindow =
-        _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
-    _glfw.glx.GetProcAddress =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
-    _glfw.glx.GetProcAddressARB =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
-    _glfw.glx.GetVisualFromFBConfig =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
-
-    if (!_glfw.glx.GetFBConfigs ||
-        !_glfw.glx.GetFBConfigAttrib ||
-        !_glfw.glx.GetClientString ||
-        !_glfw.glx.QueryExtension ||
-        !_glfw.glx.QueryVersion ||
-        !_glfw.glx.DestroyContext ||
-        !_glfw.glx.MakeCurrent ||
-        !_glfw.glx.SwapBuffers ||
-        !_glfw.glx.QueryExtensionsString ||
-        !_glfw.glx.CreateNewContext ||
-        !_glfw.glx.CreateWindow ||
-        !_glfw.glx.DestroyWindow ||
-        !_glfw.glx.GetProcAddress ||
-        !_glfw.glx.GetProcAddressARB ||
-        !_glfw.glx.GetVisualFromFBConfig)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "GLX: Failed to load required entry points");
-        return GLFW_FALSE;
-    }
-
-    if (!glXQueryExtension(_glfw.x11.display,
-                           &_glfw.glx.errorBase,
-                           &_glfw.glx.eventBase))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
-        return GLFW_FALSE;
-    }
-
-    if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "GLX: Failed to query GLX version");
-        return GLFW_FALSE;
-    }
-
-    if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "GLX: GLX version 1.3 is required");
-        return GLFW_FALSE;
-    }
-
-    if (extensionSupportedGLX("GLX_EXT_swap_control"))
-    {
-        _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
-            getProcAddressGLX("glXSwapIntervalEXT");
-
-        if (_glfw.glx.SwapIntervalEXT)
-            _glfw.glx.EXT_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_SGI_swap_control"))
-    {
-        _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
-            getProcAddressGLX("glXSwapIntervalSGI");
-
-        if (_glfw.glx.SwapIntervalSGI)
-            _glfw.glx.SGI_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_MESA_swap_control"))
-    {
-        _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
-            getProcAddressGLX("glXSwapIntervalMESA");
-
-        if (_glfw.glx.SwapIntervalMESA)
-            _glfw.glx.MESA_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_ARB_multisample"))
-        _glfw.glx.ARB_multisample = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
-        _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
-        _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context"))
-    {
-        _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
-            getProcAddressGLX("glXCreateContextAttribsARB");
-
-        if (_glfw.glx.CreateContextAttribsARB)
-            _glfw.glx.ARB_create_context = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
-        _glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
-        _glfw.glx.ARB_create_context_profile = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
-        _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
-        _glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
-        _glfw.glx.ARB_context_flush_control = GLFW_TRUE;
-
-    return GLFW_TRUE;
-}
-
-// Terminate GLX
-//
-void _glfwTerminateGLX(void)
-{
-    // NOTE: This function must not call any X11 functions, as it is called
-    //       after XCloseDisplay (see _glfwPlatformTerminate for details)
-
-    if (_glfw.glx.handle)
-    {
-        _glfw_dlclose(_glfw.glx.handle);
-        _glfw.glx.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    int attribs[40];
-    GLXFBConfig native = NULL;
-    GLXContext share = NULL;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.glx.handle;
-
-    if (!chooseGLXFBConfig(fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "GLX: Failed to find a suitable GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (!_glfw.glx.ARB_create_context ||
-            !_glfw.glx.ARB_create_context_profile ||
-            !_glfw.glx.EXT_create_context_es2_profile)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->forward)
-    {
-        if (!_glfw.glx.ARB_create_context)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->profile)
-    {
-        if (!_glfw.glx.ARB_create_context ||
-            !_glfw.glx.ARB_create_context_profile)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    _glfwGrabErrorHandlerX11();
-
-    if (_glfw.glx.ARB_create_context)
-    {
-        int index = 0, mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-        }
-        else
-            mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
-
-        if (ctxconfig->debug)
-            flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
-
-        if (ctxconfig->robustness)
-        {
-            if (_glfw.glx.ARB_create_context_robustness)
-            {
-                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-                {
-                    setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              GLX_NO_RESET_NOTIFICATION_ARB);
-                }
-                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                {
-                    setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              GLX_LOSE_CONTEXT_ON_RESET_ARB);
-                }
-
-                flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-            }
-        }
-
-        if (ctxconfig->release)
-        {
-            if (_glfw.glx.ARB_context_flush_control)
-            {
-                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-                {
-                    setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
-                }
-                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-                {
-                    setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
-                }
-            }
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.glx.ARB_create_context_no_error)
-                setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
-        }
-
-        // NOTE: Only request an explicitly versioned context when necessary, as
-        //       explicitly requesting version 1.0 does not always return the
-        //       highest version supported by the driver
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
-            setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
-        }
-
-        if (mask)
-            setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
-
-        if (flags)
-            setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
-
-        setAttrib(None, None);
-
-        window->context.glx.handle =
-            _glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
-                                              native,
-                                              share,
-                                              True,
-                                              attribs);
-
-        // HACK: This is a fallback for broken versions of the Mesa
-        //       implementation of GLX_ARB_create_context_profile that fail
-        //       default 1.0 context creation with a GLXBadProfileARB error in
-        //       violation of the extension spec
-        if (!window->context.glx.handle)
-        {
-            if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
-                ctxconfig->client == GLFW_OPENGL_API &&
-                ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
-                ctxconfig->forward == GLFW_FALSE)
-            {
-                window->context.glx.handle =
-                    createLegacyContextGLX(window, native, share);
-            }
-        }
-    }
-    else
-    {
-        window->context.glx.handle =
-            createLegacyContextGLX(window, native, share);
-    }
-
-    _glfwReleaseErrorHandlerX11();
-
-    if (!window->context.glx.handle)
-    {
-        _glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
-        return GLFW_FALSE;
-    }
-
-    window->context.glx.window =
-        glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
-    if (!window->context.glx.window)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    window->context.makeCurrent = makeContextCurrentGLX;
-    window->context.swapBuffers = swapBuffersGLX;
-    window->context.swapInterval = swapIntervalGLX;
-    window->context.extensionSupported = extensionSupportedGLX;
-    window->context.getProcAddress = getProcAddressGLX;
-    window->context.destroy = destroyContextGLX;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-// Returns the Visual and depth of the chosen GLXFBConfig
-//
-GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth)
-{
-    GLXFBConfig native;
-    XVisualInfo* result;
-
-    if (!chooseGLXFBConfig(fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "GLX: Failed to find a suitable GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
-    if (!result)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "GLX: Failed to retrieve Visual for GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    *visual = result->visual;
-    *depth  = result->depth;
-
-    XFree(result);
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.glx.handle;
-}
-
-GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return None;
-    }
-
-    return window->context.glx.window;
-}
-
diff --git a/raylib/external/glfw/src/glx_context.h b/raylib/external/glfw/src/glx_context.h
deleted file mode 100644 (file)
index 94f07e2..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-//========================================================================
-// GLFW 3.4 GLX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define GLX_VENDOR 1
-#define GLX_RGBA_BIT 0x00000001
-#define GLX_WINDOW_BIT 0x00000001
-#define GLX_DRAWABLE_TYPE 0x8010
-#define GLX_RENDER_TYPE 0x8011
-#define GLX_RGBA_TYPE 0x8014
-#define GLX_DOUBLEBUFFER 5
-#define GLX_STEREO 6
-#define GLX_AUX_BUFFERS 7
-#define GLX_RED_SIZE 8
-#define GLX_GREEN_SIZE 9
-#define GLX_BLUE_SIZE 10
-#define GLX_ALPHA_SIZE 11
-#define GLX_DEPTH_SIZE 12
-#define GLX_STENCIL_SIZE 13
-#define GLX_ACCUM_RED_SIZE 14
-#define GLX_ACCUM_GREEN_SIZE 15
-#define GLX_ACCUM_BLUE_SIZE 16
-#define GLX_ACCUM_ALPHA_SIZE 17
-#define GLX_SAMPLES 0x186a1
-#define GLX_VISUAL_ID 0x800b
-
-#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
-#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
-#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
-#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define GLX_CONTEXT_FLAGS_ARB 0x2094
-#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
-#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
-#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
-
-typedef XID GLXWindow;
-typedef XID GLXDrawable;
-typedef struct __GLXFBConfig* GLXFBConfig;
-typedef struct __GLXcontext* GLXContext;
-typedef void (*__GLXextproc)(void);
-
-typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
-typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
-typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
-typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
-typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
-typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
-typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
-typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
-typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
-typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
-typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
-typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
-typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
-typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
-typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
-
-typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
-typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
-typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
-
-// libGL.so function pointer typedefs
-#define glXGetFBConfigs _glfw.glx.GetFBConfigs
-#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
-#define glXGetClientString _glfw.glx.GetClientString
-#define glXQueryExtension _glfw.glx.QueryExtension
-#define glXQueryVersion _glfw.glx.QueryVersion
-#define glXDestroyContext _glfw.glx.DestroyContext
-#define glXMakeCurrent _glfw.glx.MakeCurrent
-#define glXSwapBuffers _glfw.glx.SwapBuffers
-#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
-#define glXCreateNewContext _glfw.glx.CreateNewContext
-#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
-#define glXCreateWindow _glfw.glx.CreateWindow
-#define glXDestroyWindow _glfw.glx.DestroyWindow
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextGLX glx
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryGLX glx
-
-
-// GLX-specific per-context data
-//
-typedef struct _GLFWcontextGLX
-{
-    GLXContext      handle;
-    GLXWindow       window;
-
-} _GLFWcontextGLX;
-
-// GLX-specific global data
-//
-typedef struct _GLFWlibraryGLX
-{
-    int             major, minor;
-    int             eventBase;
-    int             errorBase;
-
-    // dlopen handle for libGL.so.1
-    void*           handle;
-
-    // GLX 1.3 functions
-    PFNGLXGETFBCONFIGSPROC              GetFBConfigs;
-    PFNGLXGETFBCONFIGATTRIBPROC         GetFBConfigAttrib;
-    PFNGLXGETCLIENTSTRINGPROC           GetClientString;
-    PFNGLXQUERYEXTENSIONPROC            QueryExtension;
-    PFNGLXQUERYVERSIONPROC              QueryVersion;
-    PFNGLXDESTROYCONTEXTPROC            DestroyContext;
-    PFNGLXMAKECURRENTPROC               MakeCurrent;
-    PFNGLXSWAPBUFFERSPROC               SwapBuffers;
-    PFNGLXQUERYEXTENSIONSSTRINGPROC     QueryExtensionsString;
-    PFNGLXCREATENEWCONTEXTPROC          CreateNewContext;
-    PFNGLXGETVISUALFROMFBCONFIGPROC     GetVisualFromFBConfig;
-    PFNGLXCREATEWINDOWPROC              CreateWindow;
-    PFNGLXDESTROYWINDOWPROC             DestroyWindow;
-
-    // GLX 1.4 and extension functions
-    PFNGLXGETPROCADDRESSPROC            GetProcAddress;
-    PFNGLXGETPROCADDRESSPROC            GetProcAddressARB;
-    PFNGLXSWAPINTERVALSGIPROC           SwapIntervalSGI;
-    PFNGLXSWAPINTERVALEXTPROC           SwapIntervalEXT;
-    PFNGLXSWAPINTERVALMESAPROC          SwapIntervalMESA;
-    PFNGLXCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;
-    GLFWbool        SGI_swap_control;
-    GLFWbool        EXT_swap_control;
-    GLFWbool        MESA_swap_control;
-    GLFWbool        ARB_multisample;
-    GLFWbool        ARB_framebuffer_sRGB;
-    GLFWbool        EXT_framebuffer_sRGB;
-    GLFWbool        ARB_create_context;
-    GLFWbool        ARB_create_context_profile;
-    GLFWbool        ARB_create_context_robustness;
-    GLFWbool        EXT_create_context_es2_profile;
-    GLFWbool        ARB_create_context_no_error;
-    GLFWbool        ARB_context_flush_control;
-
-} _GLFWlibraryGLX;
-
-GLFWbool _glfwInitGLX(void);
-void _glfwTerminateGLX(void);
-GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-void _glfwDestroyContextGLX(_GLFWwindow* window);
-GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth);
-
diff --git a/raylib/external/glfw/src/init.c b/raylib/external/glfw/src/init.c
deleted file mode 100644 (file)
index a7b5af6..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-#include "mappings.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-
-
-// The global variables below comprise all mutable global data in GLFW
-//
-// Any other global variable is a bug
-
-// Global state shared between compilation units of GLFW
-//
-_GLFWlibrary _glfw = { GLFW_FALSE };
-
-// These are outside of _glfw so they can be used before initialization and
-// after termination
-//
-static _GLFWerror _glfwMainThreadError;
-static GLFWerrorfun _glfwErrorCallback;
-static _GLFWinitconfig _glfwInitHints =
-{
-    GLFW_TRUE,      // hat buttons
-    GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
-    {
-        GLFW_TRUE,  // macOS menu bar
-        GLFW_TRUE   // macOS bundle chdir
-    }
-};
-
-// Terminate the library
-//
-static void terminate(void)
-{
-    int i;
-
-    memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
-
-    while (_glfw.windowListHead)
-        glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
-
-    while (_glfw.cursorListHead)
-        glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
-
-    for (i = 0;  i < _glfw.monitorCount;  i++)
-    {
-        _GLFWmonitor* monitor = _glfw.monitors[i];
-        if (monitor->originalRamp.size)
-            _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
-        _glfwFreeMonitor(monitor);
-    }
-
-    free(_glfw.monitors);
-    _glfw.monitors = NULL;
-    _glfw.monitorCount = 0;
-
-    free(_glfw.mappings);
-    _glfw.mappings = NULL;
-    _glfw.mappingCount = 0;
-
-    _glfwTerminateVulkan();
-    _glfwPlatformTerminateJoysticks();
-    _glfwPlatformTerminate();
-
-    _glfw.initialized = GLFW_FALSE;
-
-    while (_glfw.errorListHead)
-    {
-        _GLFWerror* error = _glfw.errorListHead;
-        _glfw.errorListHead = error->next;
-        free(error);
-    }
-
-    _glfwPlatformDestroyTls(&_glfw.contextSlot);
-    _glfwPlatformDestroyTls(&_glfw.errorSlot);
-    _glfwPlatformDestroyMutex(&_glfw.errorLock);
-
-    memset(&_glfw, 0, sizeof(_glfw));
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-char* _glfw_strdup(const char* source)
-{
-    const size_t length = strlen(source);
-    char* result = calloc(length + 1, 1);
-    strcpy(result, source);
-    return result;
-}
-
-float _glfw_fminf(float a, float b)
-{
-    if (a != a)
-        return b;
-    else if (b != b)
-        return a;
-    else if (a < b)
-        return a;
-    else
-        return b;
-}
-
-float _glfw_fmaxf(float a, float b)
-{
-    if (a != a)
-        return b;
-    else if (b != b)
-        return a;
-    else if (a > b)
-        return a;
-    else
-        return b;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of an error
-//
-void _glfwInputError(int code, const char* format, ...)
-{
-    _GLFWerror* error;
-    char description[_GLFW_MESSAGE_SIZE];
-
-    if (format)
-    {
-        va_list vl;
-
-        va_start(vl, format);
-        vsnprintf(description, sizeof(description), format, vl);
-        va_end(vl);
-
-        description[sizeof(description) - 1] = '\0';
-    }
-    else
-    {
-        if (code == GLFW_NOT_INITIALIZED)
-            strcpy(description, "The GLFW library is not initialized");
-        else if (code == GLFW_NO_CURRENT_CONTEXT)
-            strcpy(description, "There is no current context");
-        else if (code == GLFW_INVALID_ENUM)
-            strcpy(description, "Invalid argument for enum parameter");
-        else if (code == GLFW_INVALID_VALUE)
-            strcpy(description, "Invalid value for parameter");
-        else if (code == GLFW_OUT_OF_MEMORY)
-            strcpy(description, "Out of memory");
-        else if (code == GLFW_API_UNAVAILABLE)
-            strcpy(description, "The requested API is unavailable");
-        else if (code == GLFW_VERSION_UNAVAILABLE)
-            strcpy(description, "The requested API version is unavailable");
-        else if (code == GLFW_PLATFORM_ERROR)
-            strcpy(description, "A platform-specific error occurred");
-        else if (code == GLFW_FORMAT_UNAVAILABLE)
-            strcpy(description, "The requested format is unavailable");
-        else if (code == GLFW_NO_WINDOW_CONTEXT)
-            strcpy(description, "The specified window has no context");
-        else if (code == GLFW_CURSOR_UNAVAILABLE)
-            strcpy(description, "The specified cursor shape is unavailable");
-        else if (code == GLFW_FEATURE_UNAVAILABLE)
-            strcpy(description, "The requested feature cannot be implemented for this platform");
-        else if (code == GLFW_FEATURE_UNIMPLEMENTED)
-            strcpy(description, "The requested feature has not yet been implemented for this platform");
-        else
-            strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
-    }
-
-    if (_glfw.initialized)
-    {
-        error = _glfwPlatformGetTls(&_glfw.errorSlot);
-        if (!error)
-        {
-            error = calloc(1, sizeof(_GLFWerror));
-            _glfwPlatformSetTls(&_glfw.errorSlot, error);
-            _glfwPlatformLockMutex(&_glfw.errorLock);
-            error->next = _glfw.errorListHead;
-            _glfw.errorListHead = error;
-            _glfwPlatformUnlockMutex(&_glfw.errorLock);
-        }
-    }
-    else
-        error = &_glfwMainThreadError;
-
-    error->code = code;
-    strcpy(error->description, description);
-
-    if (_glfwErrorCallback)
-        _glfwErrorCallback(code, description);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwInit(void)
-{
-    if (_glfw.initialized)
-        return GLFW_TRUE;
-
-    memset(&_glfw, 0, sizeof(_glfw));
-    _glfw.hints.init = _glfwInitHints;
-
-    if (!_glfwPlatformInit())
-    {
-        terminate();
-        return GLFW_FALSE;
-    }
-
-    if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
-        !_glfwPlatformCreateTls(&_glfw.errorSlot) ||
-        !_glfwPlatformCreateTls(&_glfw.contextSlot))
-    {
-        terminate();
-        return GLFW_FALSE;
-    }
-
-    _glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
-
-    _glfw.initialized = GLFW_TRUE;
-    _glfw.timer.offset = _glfwPlatformGetTimerValue();
-
-    glfwDefaultWindowHints();
-
-    {
-        int i;
-
-        for (i = 0;  _glfwDefaultMappings[i];  i++)
-        {
-            if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
-            {
-                terminate();
-                return GLFW_FALSE;
-            }
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI void glfwTerminate(void)
-{
-    if (!_glfw.initialized)
-        return;
-
-    terminate();
-}
-
-GLFWAPI void glfwInitHint(int hint, int value)
-{
-    switch (hint)
-    {
-        case GLFW_JOYSTICK_HAT_BUTTONS:
-            _glfwInitHints.hatButtons = value;
-            return;
-        case GLFW_ANGLE_PLATFORM_TYPE:
-            _glfwInitHints.angleType = value;
-            return;
-        case GLFW_COCOA_CHDIR_RESOURCES:
-            _glfwInitHints.ns.chdir = value;
-            return;
-        case GLFW_COCOA_MENUBAR:
-            _glfwInitHints.ns.menubar = value;
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM,
-                    "Invalid init hint 0x%08X", hint);
-}
-
-GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
-{
-    if (major != NULL)
-        *major = GLFW_VERSION_MAJOR;
-    if (minor != NULL)
-        *minor = GLFW_VERSION_MINOR;
-    if (rev != NULL)
-        *rev = GLFW_VERSION_REVISION;
-}
-
-GLFWAPI const char* glfwGetVersionString(void)
-{
-    return _glfwPlatformGetVersionString();
-}
-
-GLFWAPI int glfwGetError(const char** description)
-{
-    _GLFWerror* error;
-    int code = GLFW_NO_ERROR;
-
-    if (description)
-        *description = NULL;
-
-    if (_glfw.initialized)
-        error = _glfwPlatformGetTls(&_glfw.errorSlot);
-    else
-        error = &_glfwMainThreadError;
-
-    if (error)
-    {
-        code = error->code;
-        error->code = GLFW_NO_ERROR;
-        if (description && code)
-            *description = error->description;
-    }
-
-    return code;
-}
-
-GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
-{
-    _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
-    return cbfun;
-}
-
diff --git a/raylib/external/glfw/src/input.c b/raylib/external/glfw/src/input.c
deleted file mode 100644 (file)
index 226f835..0000000
+++ /dev/null
@@ -1,1407 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <float.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-// Internal key state used for sticky keys
-#define _GLFW_STICK 3
-
-// Internal constants for gamepad mapping source types
-#define _GLFW_JOYSTICK_AXIS     1
-#define _GLFW_JOYSTICK_BUTTON   2
-#define _GLFW_JOYSTICK_HATBIT   3
-
-// Initializes the platform joystick API if it has not been already
-//
-static GLFWbool initJoysticks(void)
-{
-    if (!_glfw.joysticksInitialized)
-    {
-        if (!_glfwPlatformInitJoysticks())
-        {
-            _glfwPlatformTerminateJoysticks();
-            return GLFW_FALSE;
-        }
-    }
-
-    return _glfw.joysticksInitialized = GLFW_TRUE;
-}
-
-// Finds a mapping based on joystick GUID
-//
-static _GLFWmapping* findMapping(const char* guid)
-{
-    int i;
-
-    for (i = 0;  i < _glfw.mappingCount;  i++)
-    {
-        if (strcmp(_glfw.mappings[i].guid, guid) == 0)
-            return _glfw.mappings + i;
-    }
-
-    return NULL;
-}
-
-// Checks whether a gamepad mapping element is present in the hardware
-//
-static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
-                                          const _GLFWjoystick* js)
-{
-    if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
-        return GLFW_FALSE;
-    else if (e->type == _GLFW_JOYSTICK_BUTTON && e->index >= js->buttonCount)
-        return GLFW_FALSE;
-    else if (e->type == _GLFW_JOYSTICK_AXIS && e->index >= js->axisCount)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-// Finds a mapping based on joystick GUID and verifies element indices
-//
-static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
-{
-    _GLFWmapping* mapping = findMapping(js->guid);
-    if (mapping)
-    {
-        int i;
-
-        for (i = 0;  i <= GLFW_GAMEPAD_BUTTON_LAST;  i++)
-        {
-            if (!isValidElementForJoystick(mapping->buttons + i, js))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Invalid button in gamepad mapping %s (%s)",
-                                mapping->guid,
-                                mapping->name);
-                return NULL;
-            }
-        }
-
-        for (i = 0;  i <= GLFW_GAMEPAD_AXIS_LAST;  i++)
-        {
-            if (!isValidElementForJoystick(mapping->axes + i, js))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Invalid axis in gamepad mapping %s (%s)",
-                                mapping->guid,
-                                mapping->name);
-                return NULL;
-            }
-        }
-    }
-
-    return mapping;
-}
-
-// Parses an SDL_GameControllerDB line and adds it to the mapping list
-//
-static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
-{
-    const char* c = string;
-    size_t i, length;
-    struct
-    {
-        const char* name;
-        _GLFWmapelement* element;
-    } fields[] =
-    {
-        { "platform",      NULL },
-        { "a",             mapping->buttons + GLFW_GAMEPAD_BUTTON_A },
-        { "b",             mapping->buttons + GLFW_GAMEPAD_BUTTON_B },
-        { "x",             mapping->buttons + GLFW_GAMEPAD_BUTTON_X },
-        { "y",             mapping->buttons + GLFW_GAMEPAD_BUTTON_Y },
-        { "back",          mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK },
-        { "start",         mapping->buttons + GLFW_GAMEPAD_BUTTON_START },
-        { "guide",         mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE },
-        { "leftshoulder",  mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
-        { "rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER },
-        { "leftstick",     mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB },
-        { "rightstick",    mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB },
-        { "dpup",          mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP },
-        { "dpright",       mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT },
-        { "dpdown",        mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN },
-        { "dpleft",        mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT },
-        { "lefttrigger",   mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
-        { "righttrigger",  mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
-        { "leftx",         mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X },
-        { "lefty",         mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y },
-        { "rightx",        mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X },
-        { "righty",        mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y }
-    };
-
-    length = strcspn(c, ",");
-    if (length != 32 || c[length] != ',')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, NULL);
-        return GLFW_FALSE;
-    }
-
-    memcpy(mapping->guid, c, length);
-    c += length + 1;
-
-    length = strcspn(c, ",");
-    if (length >= sizeof(mapping->name) || c[length] != ',')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, NULL);
-        return GLFW_FALSE;
-    }
-
-    memcpy(mapping->name, c, length);
-    c += length + 1;
-
-    while (*c)
-    {
-        // TODO: Implement output modifiers
-        if (*c == '+' || *c == '-')
-            return GLFW_FALSE;
-
-        for (i = 0;  i < sizeof(fields) / sizeof(fields[0]);  i++)
-        {
-            length = strlen(fields[i].name);
-            if (strncmp(c, fields[i].name, length) != 0 || c[length] != ':')
-                continue;
-
-            c += length + 1;
-
-            if (fields[i].element)
-            {
-                _GLFWmapelement* e = fields[i].element;
-                int8_t minimum = -1;
-                int8_t maximum = 1;
-
-                if (*c == '+')
-                {
-                    minimum = 0;
-                    c += 1;
-                }
-                else if (*c == '-')
-                {
-                    maximum = 0;
-                    c += 1;
-                }
-
-                if (*c == 'a')
-                    e->type = _GLFW_JOYSTICK_AXIS;
-                else if (*c == 'b')
-                    e->type = _GLFW_JOYSTICK_BUTTON;
-                else if (*c == 'h')
-                    e->type = _GLFW_JOYSTICK_HATBIT;
-                else
-                    break;
-
-                if (e->type == _GLFW_JOYSTICK_HATBIT)
-                {
-                    const unsigned long hat = strtoul(c + 1, (char**) &c, 10);
-                    const unsigned long bit = strtoul(c + 1, (char**) &c, 10);
-                    e->index = (uint8_t) ((hat << 4) | bit);
-                }
-                else
-                    e->index = (uint8_t) strtoul(c + 1, (char**) &c, 10);
-
-                if (e->type == _GLFW_JOYSTICK_AXIS)
-                {
-                    e->axisScale = 2 / (maximum - minimum);
-                    e->axisOffset = -(maximum + minimum);
-
-                    if (*c == '~')
-                    {
-                        e->axisScale = -e->axisScale;
-                        e->axisOffset = -e->axisOffset;
-                    }
-                }
-            }
-            else
-            {
-                length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
-                if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
-                    return GLFW_FALSE;
-            }
-
-            break;
-        }
-
-        c += strcspn(c, ",");
-        c += strspn(c, ",");
-    }
-
-    for (i = 0;  i < 32;  i++)
-    {
-        if (mapping->guid[i] >= 'A' && mapping->guid[i] <= 'F')
-            mapping->guid[i] += 'a' - 'A';
-    }
-
-    _glfwPlatformUpdateGamepadGUID(mapping->guid);
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of a physical key event
-//
-void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
-{
-    if (key >= 0 && key <= GLFW_KEY_LAST)
-    {
-        GLFWbool repeated = GLFW_FALSE;
-
-        if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
-            return;
-
-        if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
-            repeated = GLFW_TRUE;
-
-        if (action == GLFW_RELEASE && window->stickyKeys)
-            window->keys[key] = _GLFW_STICK;
-        else
-            window->keys[key] = (char) action;
-
-        if (repeated)
-            action = GLFW_REPEAT;
-    }
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (window->callbacks.key)
-        window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
-}
-
-// Notifies shared code of a Unicode codepoint input event
-// The 'plain' parameter determines whether to emit a regular character event
-//
-void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain)
-{
-    if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
-        return;
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (window->callbacks.charmods)
-        window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
-
-    if (plain)
-    {
-        if (window->callbacks.character)
-            window->callbacks.character((GLFWwindow*) window, codepoint);
-    }
-}
-
-// Notifies shared code of a scroll event
-//
-void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
-{
-    if (window->callbacks.scroll)
-        window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
-}
-
-// Notifies shared code of a mouse button click event
-//
-void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
-{
-    if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
-        return;
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (action == GLFW_RELEASE && window->stickyMouseButtons)
-        window->mouseButtons[button] = _GLFW_STICK;
-    else
-        window->mouseButtons[button] = (char) action;
-
-    if (window->callbacks.mouseButton)
-        window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
-}
-
-// Notifies shared code of a cursor motion event
-// The position is specified in content area relative screen coordinates
-//
-void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
-{
-    if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
-        return;
-
-    window->virtualCursorPosX = xpos;
-    window->virtualCursorPosY = ypos;
-
-    if (window->callbacks.cursorPos)
-        window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
-}
-
-// Notifies shared code of a cursor enter/leave event
-//
-void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
-{
-    if (window->callbacks.cursorEnter)
-        window->callbacks.cursorEnter((GLFWwindow*) window, entered);
-}
-
-// Notifies shared code of files or directories dropped on a window
-//
-void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
-{
-    if (window->callbacks.drop)
-        window->callbacks.drop((GLFWwindow*) window, count, paths);
-}
-
-// Notifies shared code of a joystick connection or disconnection
-//
-void _glfwInputJoystick(_GLFWjoystick* js, int event)
-{
-    const int jid = (int) (js - _glfw.joysticks);
-
-    if (_glfw.callbacks.joystick)
-        _glfw.callbacks.joystick(jid, event);
-}
-
-// Notifies shared code of the new value of a joystick axis
-//
-void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
-{
-    js->axes[axis] = value;
-}
-
-// Notifies shared code of the new value of a joystick button
-//
-void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
-{
-    js->buttons[button] = value;
-}
-
-// Notifies shared code of the new value of a joystick hat
-//
-void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
-{
-    const int base = js->buttonCount + hat * 4;
-
-    js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
-
-    js->hats[hat] = value;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Returns an available joystick object with arrays and name allocated
-//
-_GLFWjoystick* _glfwAllocJoystick(const char* name,
-                                  const char* guid,
-                                  int axisCount,
-                                  int buttonCount,
-                                  int hatCount)
-{
-    int jid;
-    _GLFWjoystick* js;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (!_glfw.joysticks[jid].present)
-            break;
-    }
-
-    if (jid > GLFW_JOYSTICK_LAST)
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    js->present     = GLFW_TRUE;
-    js->name        = _glfw_strdup(name);
-    js->axes        = calloc(axisCount, sizeof(float));
-    js->buttons     = calloc(buttonCount + (size_t) hatCount * 4, 1);
-    js->hats        = calloc(hatCount, 1);
-    js->axisCount   = axisCount;
-    js->buttonCount = buttonCount;
-    js->hatCount    = hatCount;
-
-    strncpy(js->guid, guid, sizeof(js->guid) - 1);
-    js->mapping = findValidMapping(js);
-
-    return js;
-}
-
-// Frees arrays and name and flags the joystick object as unused
-//
-void _glfwFreeJoystick(_GLFWjoystick* js)
-{
-    free(js->name);
-    free(js->axes);
-    free(js->buttons);
-    free(js->hats);
-    memset(js, 0, sizeof(_GLFWjoystick));
-}
-
-// Center the cursor in the content area of the specified window
-//
-void _glfwCenterCursorInContentArea(_GLFWwindow* window)
-{
-    int width, height;
-
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-
-    switch (mode)
-    {
-        case GLFW_CURSOR:
-            return window->cursorMode;
-        case GLFW_STICKY_KEYS:
-            return window->stickyKeys;
-        case GLFW_STICKY_MOUSE_BUTTONS:
-            return window->stickyMouseButtons;
-        case GLFW_LOCK_KEY_MODS:
-            return window->lockKeyMods;
-        case GLFW_RAW_MOUSE_MOTION:
-            return window->rawMouseMotion;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
-    return 0;
-}
-
-GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (mode == GLFW_CURSOR)
-    {
-        if (value != GLFW_CURSOR_NORMAL &&
-            value != GLFW_CURSOR_HIDDEN &&
-            value != GLFW_CURSOR_DISABLED)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid cursor mode 0x%08X",
-                            value);
-            return;
-        }
-
-        if (window->cursorMode == value)
-            return;
-
-        window->cursorMode = value;
-
-        _glfwPlatformGetCursorPos(window,
-                                  &window->virtualCursorPosX,
-                                  &window->virtualCursorPosY);
-        _glfwPlatformSetCursorMode(window, value);
-    }
-    else if (mode == GLFW_STICKY_KEYS)
-    {
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->stickyKeys == value)
-            return;
-
-        if (!value)
-        {
-            int i;
-
-            // Release all sticky keys
-            for (i = 0;  i <= GLFW_KEY_LAST;  i++)
-            {
-                if (window->keys[i] == _GLFW_STICK)
-                    window->keys[i] = GLFW_RELEASE;
-            }
-        }
-
-        window->stickyKeys = value;
-    }
-    else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
-    {
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->stickyMouseButtons == value)
-            return;
-
-        if (!value)
-        {
-            int i;
-
-            // Release all sticky mouse buttons
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == _GLFW_STICK)
-                    window->mouseButtons[i] = GLFW_RELEASE;
-            }
-        }
-
-        window->stickyMouseButtons = value;
-    }
-    else if (mode == GLFW_LOCK_KEY_MODS)
-    {
-        window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
-    }
-    else if (mode == GLFW_RAW_MOUSE_MOTION)
-    {
-        if (!_glfwPlatformRawMouseMotionSupported())
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Raw mouse motion is not supported on this system");
-            return;
-        }
-
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->rawMouseMotion == value)
-            return;
-
-        window->rawMouseMotion = value;
-        _glfwPlatformSetRawMouseMotion(window, value);
-    }
-    else
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
-}
-
-GLFWAPI int glfwRawMouseMotionSupported(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-    return _glfwPlatformRawMouseMotionSupported();
-}
-
-GLFWAPI const char* glfwGetKeyName(int key, int scancode)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (key != GLFW_KEY_UNKNOWN)
-    {
-        if (key != GLFW_KEY_KP_EQUAL &&
-            (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
-            (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
-        {
-            return NULL;
-        }
-
-        scancode = _glfwPlatformGetKeyScancode(key);
-    }
-
-    return _glfwPlatformGetScancodeName(scancode);
-}
-
-GLFWAPI int glfwGetKeyScancode(int key)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(-1);
-
-    if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
-        return GLFW_RELEASE;
-    }
-
-    return _glfwPlatformGetKeyScancode(key);
-}
-
-GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
-
-    if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
-        return GLFW_RELEASE;
-    }
-
-    if (window->keys[key] == _GLFW_STICK)
-    {
-        // Sticky mode: release key now
-        window->keys[key] = GLFW_RELEASE;
-        return GLFW_PRESS;
-    }
-
-    return (int) window->keys[key];
-}
-
-GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
-
-    if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
-        return GLFW_RELEASE;
-    }
-
-    if (window->mouseButtons[button] == _GLFW_STICK)
-    {
-        // Sticky mode: release mouse button now
-        window->mouseButtons[button] = GLFW_RELEASE;
-        return GLFW_PRESS;
-    }
-
-    return (int) window->mouseButtons[button];
-}
-
-GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        if (xpos)
-            *xpos = window->virtualCursorPosX;
-        if (ypos)
-            *ypos = window->virtualCursorPosY;
-    }
-    else
-        _glfwPlatformGetCursorPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
-        ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid cursor position %f %f",
-                        xpos, ypos);
-        return;
-    }
-
-    if (!_glfwPlatformWindowFocused(window))
-        return;
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        // Only update the accumulated position if the cursor is disabled
-        window->virtualCursorPosX = xpos;
-        window->virtualCursorPosY = ypos;
-    }
-    else
-    {
-        // Update system cursor position
-        _glfwPlatformSetCursorPos(window, xpos, ypos);
-    }
-}
-
-GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
-{
-    _GLFWcursor* cursor;
-
-    assert(image != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    cursor = calloc(1, sizeof(_GLFWcursor));
-    cursor->next = _glfw.cursorListHead;
-    _glfw.cursorListHead = cursor;
-
-    if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
-    {
-        glfwDestroyCursor((GLFWcursor*) cursor);
-        return NULL;
-    }
-
-    return (GLFWcursor*) cursor;
-}
-
-GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
-{
-    _GLFWcursor* cursor;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (shape != GLFW_ARROW_CURSOR &&
-        shape != GLFW_IBEAM_CURSOR &&
-        shape != GLFW_CROSSHAIR_CURSOR &&
-        shape != GLFW_POINTING_HAND_CURSOR &&
-        shape != GLFW_RESIZE_EW_CURSOR &&
-        shape != GLFW_RESIZE_NS_CURSOR &&
-        shape != GLFW_RESIZE_NWSE_CURSOR &&
-        shape != GLFW_RESIZE_NESW_CURSOR &&
-        shape != GLFW_RESIZE_ALL_CURSOR &&
-        shape != GLFW_NOT_ALLOWED_CURSOR)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape);
-        return NULL;
-    }
-
-    cursor = calloc(1, sizeof(_GLFWcursor));
-    cursor->next = _glfw.cursorListHead;
-    _glfw.cursorListHead = cursor;
-
-    if (!_glfwPlatformCreateStandardCursor(cursor, shape))
-    {
-        glfwDestroyCursor((GLFWcursor*) cursor);
-        return NULL;
-    }
-
-    return (GLFWcursor*) cursor;
-}
-
-GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
-{
-    _GLFWcursor* cursor = (_GLFWcursor*) handle;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (cursor == NULL)
-        return;
-
-    // Make sure the cursor is not being used by any window
-    {
-        _GLFWwindow* window;
-
-        for (window = _glfw.windowListHead;  window;  window = window->next)
-        {
-            if (window->cursor == cursor)
-                glfwSetCursor((GLFWwindow*) window, NULL);
-        }
-    }
-
-    _glfwPlatformDestroyCursor(cursor);
-
-    // Unlink cursor from global linked list
-    {
-        _GLFWcursor** prev = &_glfw.cursorListHead;
-
-        while (*prev != cursor)
-            prev = &((*prev)->next);
-
-        *prev = cursor->next;
-    }
-
-    free(cursor);
-}
-
-GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) windowHandle;
-    _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    window->cursor = cursor;
-
-    _glfwPlatformSetCursor(window, cursor);
-}
-
-GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
-                                                      GLFWmousebuttonfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
-                                                  GLFWcursorposfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
-                                                      GLFWcursorenterfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
-                                            GLFWscrollfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);
-    return cbfun;
-}
-
-GLFWAPI int glfwJoystickPresent(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
-}
-
-GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES))
-        return NULL;
-
-    *count = js->axisCount;
-    return js->axes;
-}
-
-GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
-        return NULL;
-
-    if (_glfw.hints.init.hatButtons)
-        *count = js->buttonCount + js->hatCount * 4;
-    else
-        *count = js->buttonCount;
-
-    return js->buttons;
-}
-
-GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
-        return NULL;
-
-    *count = js->hatCount;
-    return js->hats;
-}
-
-GLFWAPI const char* glfwGetJoystickName(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    return js->name;
-}
-
-GLFWAPI const char* glfwGetJoystickGUID(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    return js->guid;
-}
-
-GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT();
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return;
-
-    js->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetJoystickUserPointer(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    return js->userPointer;
-}
-
-GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!initJoysticks())
-        return NULL;
-
-    _GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
-    return cbfun;
-}
-
-GLFWAPI int glfwUpdateGamepadMappings(const char* string)
-{
-    int jid;
-    const char* c = string;
-
-    assert(string != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    while (*c)
-    {
-        if ((*c >= '0' && *c <= '9') ||
-            (*c >= 'a' && *c <= 'f') ||
-            (*c >= 'A' && *c <= 'F'))
-        {
-            char line[1024];
-
-            const size_t length = strcspn(c, "\r\n");
-            if (length < sizeof(line))
-            {
-                _GLFWmapping mapping = {{0}};
-
-                memcpy(line, c, length);
-                line[length] = '\0';
-
-                if (parseMapping(&mapping, line))
-                {
-                    _GLFWmapping* previous = findMapping(mapping.guid);
-                    if (previous)
-                        *previous = mapping;
-                    else
-                    {
-                        _glfw.mappingCount++;
-                        _glfw.mappings =
-                            realloc(_glfw.mappings,
-                                    sizeof(_GLFWmapping) * _glfw.mappingCount);
-                        _glfw.mappings[_glfw.mappingCount - 1] = mapping;
-                    }
-                }
-            }
-
-            c += length;
-        }
-        else
-        {
-            c += strcspn(c, "\r\n");
-            c += strspn(c, "\r\n");
-        }
-    }
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            js->mapping = findValidMapping(js);
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI int glfwJoystickIsGamepad(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return GLFW_FALSE;
-
-    return js->mapping != NULL;
-}
-
-GLFWAPI const char* glfwGetGamepadName(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    if (!js->mapping)
-        return NULL;
-
-    return js->mapping->name;
-}
-
-GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
-{
-    int i;
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(state != NULL);
-
-    memset(state, 0, sizeof(GLFWgamepadstate));
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
-        return GLFW_FALSE;
-
-    if (!js->mapping)
-        return GLFW_FALSE;
-
-    for (i = 0;  i <= GLFW_GAMEPAD_BUTTON_LAST;  i++)
-    {
-        const _GLFWmapelement* e = js->mapping->buttons + i;
-        if (e->type == _GLFW_JOYSTICK_AXIS)
-        {
-            const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
-            // HACK: This should be baked into the value transform
-            // TODO: Bake into transform when implementing output modifiers
-            if (e->axisOffset < 0 || (e->axisOffset == 0 && e->axisScale > 0))
-            {
-                if (value >= 0.f)
-                    state->buttons[i] = GLFW_PRESS;
-            }
-            else
-            {
-                if (value <= 0.f)
-                    state->buttons[i] = GLFW_PRESS;
-            }
-        }
-        else if (e->type == _GLFW_JOYSTICK_HATBIT)
-        {
-            const unsigned int hat = e->index >> 4;
-            const unsigned int bit = e->index & 0xf;
-            if (js->hats[hat] & bit)
-                state->buttons[i] = GLFW_PRESS;
-        }
-        else if (e->type == _GLFW_JOYSTICK_BUTTON)
-            state->buttons[i] = js->buttons[e->index];
-    }
-
-    for (i = 0;  i <= GLFW_GAMEPAD_AXIS_LAST;  i++)
-    {
-        const _GLFWmapelement* e = js->mapping->axes + i;
-        if (e->type == _GLFW_JOYSTICK_AXIS)
-        {
-            const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
-            state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
-        }
-        else if (e->type == _GLFW_JOYSTICK_HATBIT)
-        {
-            const unsigned int hat = e->index >> 4;
-            const unsigned int bit = e->index & 0xf;
-            if (js->hats[hat] & bit)
-                state->axes[i] = 1.f;
-            else
-                state->axes[i] = -1.f;
-        }
-        else if (e->type == _GLFW_JOYSTICK_BUTTON)
-            state->axes[i] = js->buttons[e->index] * 2.f - 1.f;
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
-{
-    assert(string != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetClipboardString(string);
-}
-
-GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfwPlatformGetClipboardString();
-}
-
-GLFWAPI double glfwGetTime(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0.0);
-    return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
-        _glfwPlatformGetTimerFrequency();
-}
-
-GLFWAPI void glfwSetTime(double time)
-{
-    _GLFW_REQUIRE_INIT();
-
-    if (time != time || time < 0.0 || time > 18446744073.0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
-        return;
-    }
-
-    _glfw.timer.offset = _glfwPlatformGetTimerValue() -
-        (uint64_t) (time * _glfwPlatformGetTimerFrequency());
-}
-
-GLFWAPI uint64_t glfwGetTimerValue(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return _glfwPlatformGetTimerValue();
-}
-
-GLFWAPI uint64_t glfwGetTimerFrequency(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return _glfwPlatformGetTimerFrequency();
-}
diff --git a/raylib/external/glfw/src/internal.h b/raylib/external/glfw/src/internal.h
deleted file mode 100644 (file)
index 48053cd..0000000
+++ /dev/null
@@ -1,795 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#pragma once
-
-#if defined(_GLFW_USE_CONFIG_H)
- #include "glfw_config.h"
-#endif
-
-#if defined(GLFW_INCLUDE_GLCOREARB) || \
-    defined(GLFW_INCLUDE_ES1)       || \
-    defined(GLFW_INCLUDE_ES2)       || \
-    defined(GLFW_INCLUDE_ES3)       || \
-    defined(GLFW_INCLUDE_ES31)      || \
-    defined(GLFW_INCLUDE_ES32)      || \
-    defined(GLFW_INCLUDE_NONE)      || \
-    defined(GLFW_INCLUDE_GLEXT)     || \
-    defined(GLFW_INCLUDE_GLU)       || \
-    defined(GLFW_INCLUDE_VULKAN)    || \
-    defined(GLFW_DLL)
- #error "You must not define any header option macros when compiling GLFW"
-#endif
-
-#define GLFW_INCLUDE_NONE
-#include "../include/GLFW/glfw3.h"
-
-#define _GLFW_INSERT_FIRST      0
-#define _GLFW_INSERT_LAST       1
-
-#define _GLFW_POLL_PRESENCE     0
-#define _GLFW_POLL_AXES         1
-#define _GLFW_POLL_BUTTONS      2
-#define _GLFW_POLL_ALL          (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS)
-
-#define _GLFW_MESSAGE_SIZE      1024
-
-typedef int GLFWbool;
-
-typedef struct _GLFWerror       _GLFWerror;
-typedef struct _GLFWinitconfig  _GLFWinitconfig;
-typedef struct _GLFWwndconfig   _GLFWwndconfig;
-typedef struct _GLFWctxconfig   _GLFWctxconfig;
-typedef struct _GLFWfbconfig    _GLFWfbconfig;
-typedef struct _GLFWcontext     _GLFWcontext;
-typedef struct _GLFWwindow      _GLFWwindow;
-typedef struct _GLFWlibrary     _GLFWlibrary;
-typedef struct _GLFWmonitor     _GLFWmonitor;
-typedef struct _GLFWcursor      _GLFWcursor;
-typedef struct _GLFWmapelement  _GLFWmapelement;
-typedef struct _GLFWmapping     _GLFWmapping;
-typedef struct _GLFWjoystick    _GLFWjoystick;
-typedef struct _GLFWtls         _GLFWtls;
-typedef struct _GLFWmutex       _GLFWmutex;
-
-typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
-typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
-typedef void (* _GLFWswapintervalfun)(int);
-typedef int (* _GLFWextensionsupportedfun)(const char*);
-typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
-typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
-
-#define GL_VERSION 0x1f02
-#define GL_NONE 0
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_EXTENSIONS 0x1f03
-#define GL_NUM_EXTENSIONS 0x821d
-#define GL_CONTEXT_FLAGS 0x821e
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb
-#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
-#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
-
-typedef int GLint;
-typedef unsigned int GLuint;
-typedef unsigned int GLenum;
-typedef unsigned int GLbitfield;
-typedef unsigned char GLubyte;
-
-typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
-typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
-typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
-typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
-
-#define VK_NULL_HANDLE 0
-
-typedef void* VkInstance;
-typedef void* VkPhysicalDevice;
-typedef uint64_t VkSurfaceKHR;
-typedef uint32_t VkFlags;
-typedef uint32_t VkBool32;
-
-typedef enum VkStructureType
-{
-    VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
-    VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
-    VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
-    VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
-    VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
-    VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
-    VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
-} VkStructureType;
-
-typedef enum VkResult
-{
-    VK_SUCCESS = 0,
-    VK_NOT_READY = 1,
-    VK_TIMEOUT = 2,
-    VK_EVENT_SET = 3,
-    VK_EVENT_RESET = 4,
-    VK_INCOMPLETE = 5,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
-    VK_ERROR_INITIALIZATION_FAILED = -3,
-    VK_ERROR_DEVICE_LOST = -4,
-    VK_ERROR_MEMORY_MAP_FAILED = -5,
-    VK_ERROR_LAYER_NOT_PRESENT = -6,
-    VK_ERROR_EXTENSION_NOT_PRESENT = -7,
-    VK_ERROR_FEATURE_NOT_PRESENT = -8,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -9,
-    VK_ERROR_TOO_MANY_OBJECTS = -10,
-    VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
-    VK_ERROR_SURFACE_LOST_KHR = -1000000000,
-    VK_SUBOPTIMAL_KHR = 1000001003,
-    VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
-    VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
-    VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
-    VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
-    VK_RESULT_MAX_ENUM = 0x7FFFFFFF
-} VkResult;
-
-typedef struct VkAllocationCallbacks VkAllocationCallbacks;
-
-typedef struct VkExtensionProperties
-{
-    char            extensionName[256];
-    uint32_t        specVersion;
-} VkExtensionProperties;
-
-typedef void (APIENTRY * PFN_vkVoidFunction)(void);
-
-#if defined(_GLFW_VULKAN_STATIC)
-  PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
-  VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
-#else
-  typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
-  typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
-  #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
-  #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
-#endif
-
-#if defined(_GLFW_COCOA)
- #include "cocoa_platform.h"
-#elif defined(_GLFW_WIN32)
- #include "win32_platform.h"
-#elif defined(_GLFW_X11)
- #include "x11_platform.h"
-#elif defined(_GLFW_WAYLAND)
- #include "wl_platform.h"
-#elif defined(_GLFW_OSMESA)
- #include "null_platform.h"
-#else
- #error "No supported window creation API selected"
-#endif
-
-#include "egl_context.h"
-#include "osmesa_context.h"
-
-// Constructs a version number string from the public header macros
-#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
-#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
-#define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \
-                                                GLFW_VERSION_MINOR, \
-                                                GLFW_VERSION_REVISION)
-
-// Checks for whether the library has been initialized
-#define _GLFW_REQUIRE_INIT()                         \
-    if (!_glfw.initialized)                          \
-    {                                                \
-        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
-        return;                                      \
-    }
-#define _GLFW_REQUIRE_INIT_OR_RETURN(x)              \
-    if (!_glfw.initialized)                          \
-    {                                                \
-        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
-        return x;                                    \
-    }
-
-// Swaps the provided pointers
-#define _GLFW_SWAP_POINTERS(x, y) \
-    {                             \
-        void* t;                  \
-        t = x;                    \
-        x = y;                    \
-        y = t;                    \
-    }
-
-// Per-thread error structure
-//
-struct _GLFWerror
-{
-    _GLFWerror*     next;
-    int             code;
-    char            description[_GLFW_MESSAGE_SIZE];
-};
-
-// Initialization configuration
-//
-// Parameters relating to the initialization of the library
-//
-struct _GLFWinitconfig
-{
-    GLFWbool      hatButtons;
-    int           angleType;
-    struct {
-        GLFWbool  menubar;
-        GLFWbool  chdir;
-    } ns;
-};
-
-// Window configuration
-//
-// Parameters relating to the creation of the window but not directly related
-// to the framebuffer.  This is used to pass window creation parameters from
-// shared code to the platform API.
-//
-struct _GLFWwndconfig
-{
-    int           width;
-    int           height;
-    const char*   title;
-    GLFWbool      resizable;
-    GLFWbool      visible;
-    GLFWbool      decorated;
-    GLFWbool      focused;
-    GLFWbool      autoIconify;
-    GLFWbool      floating;
-    GLFWbool      maximized;
-    GLFWbool      centerCursor;
-    GLFWbool      focusOnShow;
-    GLFWbool      mousePassthrough;
-    GLFWbool      scaleToMonitor;
-    struct {
-        GLFWbool  retina;
-        char      frameName[256];
-    } ns;
-    struct {
-        char      className[256];
-        char      instanceName[256];
-    } x11;
-    struct {
-        GLFWbool  keymenu;
-    } win32;
-};
-
-// Context configuration
-//
-// Parameters relating to the creation of the context but not directly related
-// to the framebuffer.  This is used to pass context creation parameters from
-// shared code to the platform API.
-//
-struct _GLFWctxconfig
-{
-    int           client;
-    int           source;
-    int           major;
-    int           minor;
-    GLFWbool      forward;
-    GLFWbool      debug;
-    GLFWbool      noerror;
-    int           profile;
-    int           robustness;
-    int           release;
-    _GLFWwindow*  share;
-    struct {
-        GLFWbool  offline;
-    } nsgl;
-};
-
-// Framebuffer configuration
-//
-// This describes buffers and their sizes.  It also contains
-// a platform-specific ID used to map back to the backend API object.
-//
-// It is used to pass framebuffer parameters from shared code to the platform
-// API and also to enumerate and select available framebuffer configs.
-//
-struct _GLFWfbconfig
-{
-    int         redBits;
-    int         greenBits;
-    int         blueBits;
-    int         alphaBits;
-    int         depthBits;
-    int         stencilBits;
-    int         accumRedBits;
-    int         accumGreenBits;
-    int         accumBlueBits;
-    int         accumAlphaBits;
-    int         auxBuffers;
-    GLFWbool    stereo;
-    int         samples;
-    GLFWbool    sRGB;
-    GLFWbool    doublebuffer;
-    GLFWbool    transparent;
-    uintptr_t   handle;
-};
-
-// Context structure
-//
-struct _GLFWcontext
-{
-    int                 client;
-    int                 source;
-    int                 major, minor, revision;
-    GLFWbool            forward, debug, noerror;
-    int                 profile;
-    int                 robustness;
-    int                 release;
-
-    PFNGLGETSTRINGIPROC GetStringi;
-    PFNGLGETINTEGERVPROC GetIntegerv;
-    PFNGLGETSTRINGPROC  GetString;
-
-    _GLFWmakecontextcurrentfun  makeCurrent;
-    _GLFWswapbuffersfun         swapBuffers;
-    _GLFWswapintervalfun        swapInterval;
-    _GLFWextensionsupportedfun  extensionSupported;
-    _GLFWgetprocaddressfun      getProcAddress;
-    _GLFWdestroycontextfun      destroy;
-
-    // This is defined in the context API's context.h
-    _GLFW_PLATFORM_CONTEXT_STATE;
-    // This is defined in egl_context.h
-    _GLFWcontextEGL egl;
-    // This is defined in osmesa_context.h
-    _GLFWcontextOSMesa osmesa;
-};
-
-// Window and context structure
-//
-struct _GLFWwindow
-{
-    struct _GLFWwindow* next;
-
-    // Window settings and state
-    GLFWbool            resizable;
-    GLFWbool            decorated;
-    GLFWbool            autoIconify;
-    GLFWbool            floating;
-    GLFWbool            focusOnShow;
-    GLFWbool            mousePassthrough;
-    GLFWbool            shouldClose;
-    void*               userPointer;
-    GLFWvidmode         videoMode;
-    _GLFWmonitor*       monitor;
-    _GLFWcursor*        cursor;
-
-    int                 minwidth, minheight;
-    int                 maxwidth, maxheight;
-    int                 numer, denom;
-
-    GLFWbool            stickyKeys;
-    GLFWbool            stickyMouseButtons;
-    GLFWbool            lockKeyMods;
-    int                 cursorMode;
-    char                mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
-    char                keys[GLFW_KEY_LAST + 1];
-    // Virtual cursor position when cursor is disabled
-    double              virtualCursorPosX, virtualCursorPosY;
-    GLFWbool            rawMouseMotion;
-
-    _GLFWcontext        context;
-
-    struct {
-        GLFWwindowposfun        pos;
-        GLFWwindowsizefun       size;
-        GLFWwindowclosefun      close;
-        GLFWwindowrefreshfun    refresh;
-        GLFWwindowfocusfun      focus;
-        GLFWwindowiconifyfun    iconify;
-        GLFWwindowmaximizefun   maximize;
-        GLFWframebuffersizefun  fbsize;
-        GLFWwindowcontentscalefun scale;
-        GLFWmousebuttonfun      mouseButton;
-        GLFWcursorposfun        cursorPos;
-        GLFWcursorenterfun      cursorEnter;
-        GLFWscrollfun           scroll;
-        GLFWkeyfun              key;
-        GLFWcharfun             character;
-        GLFWcharmodsfun         charmods;
-        GLFWdropfun             drop;
-    } callbacks;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_WINDOW_STATE;
-};
-
-// Monitor structure
-//
-struct _GLFWmonitor
-{
-    char*           name;
-    void*           userPointer;
-
-    // Physical dimensions in millimeters.
-    int             widthMM, heightMM;
-
-    // The window whose video mode is current on this monitor
-    _GLFWwindow*    window;
-
-    GLFWvidmode*    modes;
-    int             modeCount;
-    GLFWvidmode     currentMode;
-
-    GLFWgammaramp   originalRamp;
-    GLFWgammaramp   currentRamp;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_MONITOR_STATE;
-};
-
-// Cursor structure
-//
-struct _GLFWcursor
-{
-    _GLFWcursor*    next;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_CURSOR_STATE;
-};
-
-// Gamepad mapping element structure
-//
-struct _GLFWmapelement
-{
-    uint8_t         type;
-    uint8_t         index;
-    int8_t          axisScale;
-    int8_t          axisOffset;
-};
-
-// Gamepad mapping structure
-//
-struct _GLFWmapping
-{
-    char            name[128];
-    char            guid[33];
-    _GLFWmapelement buttons[15];
-    _GLFWmapelement axes[6];
-};
-
-// Joystick structure
-//
-struct _GLFWjoystick
-{
-    GLFWbool        present;
-    float*          axes;
-    int             axisCount;
-    unsigned char*  buttons;
-    int             buttonCount;
-    unsigned char*  hats;
-    int             hatCount;
-    char*           name;
-    void*           userPointer;
-    char            guid[33];
-    _GLFWmapping*   mapping;
-
-    // This is defined in the joystick API's joystick.h
-    _GLFW_PLATFORM_JOYSTICK_STATE;
-};
-
-// Thread local storage structure
-//
-struct _GLFWtls
-{
-    // This is defined in the platform's thread.h
-    _GLFW_PLATFORM_TLS_STATE;
-};
-
-// Mutex structure
-//
-struct _GLFWmutex
-{
-    // This is defined in the platform's thread.h
-    _GLFW_PLATFORM_MUTEX_STATE;
-};
-
-// Library global data
-//
-struct _GLFWlibrary
-{
-    GLFWbool            initialized;
-
-    struct {
-        _GLFWinitconfig init;
-        _GLFWfbconfig   framebuffer;
-        _GLFWwndconfig  window;
-        _GLFWctxconfig  context;
-        int             refreshRate;
-    } hints;
-
-    _GLFWerror*         errorListHead;
-    _GLFWcursor*        cursorListHead;
-    _GLFWwindow*        windowListHead;
-
-    _GLFWmonitor**      monitors;
-    int                 monitorCount;
-
-    GLFWbool            joysticksInitialized;
-    _GLFWjoystick       joysticks[GLFW_JOYSTICK_LAST + 1];
-    _GLFWmapping*       mappings;
-    int                 mappingCount;
-
-    _GLFWtls            errorSlot;
-    _GLFWtls            contextSlot;
-    _GLFWmutex          errorLock;
-
-    struct {
-        uint64_t        offset;
-        // This is defined in the platform's time.h
-        _GLFW_PLATFORM_LIBRARY_TIMER_STATE;
-    } timer;
-
-    struct {
-        GLFWbool        available;
-        void*           handle;
-        char*           extensions[2];
-#if !defined(_GLFW_VULKAN_STATIC)
-        PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
-        PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
-#endif
-        GLFWbool        KHR_surface;
-#if defined(_GLFW_WIN32)
-        GLFWbool        KHR_win32_surface;
-#elif defined(_GLFW_COCOA)
-        GLFWbool        MVK_macos_surface;
-        GLFWbool        EXT_metal_surface;
-#elif defined(_GLFW_X11)
-        GLFWbool        KHR_xlib_surface;
-        GLFWbool        KHR_xcb_surface;
-#elif defined(_GLFW_WAYLAND)
-        GLFWbool        KHR_wayland_surface;
-#endif
-    } vk;
-
-    struct {
-        GLFWmonitorfun  monitor;
-        GLFWjoystickfun joystick;
-    } callbacks;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
-    // This is defined in the context API's context.h
-    _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
-    // This is defined in the platform's joystick.h
-    _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
-    // This is defined in egl_context.h
-    _GLFWlibraryEGL egl;
-    // This is defined in osmesa_context.h
-    _GLFWlibraryOSMesa osmesa;
-};
-
-// Global state shared between compilation units of GLFW
-//
-extern _GLFWlibrary _glfw;
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void);
-void _glfwPlatformTerminate(void);
-const char* _glfwPlatformGetVersionString(void);
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled);
-GLFWbool _glfwPlatformRawMouseMotionSupported(void);
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image, int xhot, int yhot);
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
-
-const char* _glfwPlatformGetScancodeName(int scancode);
-int _glfwPlatformGetKeyScancode(int key);
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale);
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
-
-void _glfwPlatformSetClipboardString(const char* string);
-const char* _glfwPlatformGetClipboardString(void);
-
-GLFWbool _glfwPlatformInitJoysticks(void);
-void _glfwPlatformTerminateJoysticks(void);
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
-void _glfwPlatformUpdateGamepadGUID(char* guid);
-
-uint64_t _glfwPlatformGetTimerValue(void);
-uint64_t _glfwPlatformGetTimerFrequency(void);
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig);
-void _glfwPlatformDestroyWindow(_GLFWwindow* window);
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images);
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight);
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom);
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale);
-void _glfwPlatformIconifyWindow(_GLFWwindow* window);
-void _glfwPlatformRestoreWindow(_GLFWwindow* window);
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
-void _glfwPlatformShowWindow(_GLFWwindow* window);
-void _glfwPlatformHideWindow(_GLFWwindow* window);
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
-void _glfwPlatformFocusWindow(_GLFWwindow* window);
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
-                                   int xpos, int ypos, int width, int height,
-                                   int refreshRate);
-int _glfwPlatformWindowFocused(_GLFWwindow* window);
-int _glfwPlatformWindowIconified(_GLFWwindow* window);
-int _glfwPlatformWindowVisible(_GLFWwindow* window);
-int _glfwPlatformWindowMaximized(_GLFWwindow* window);
-int _glfwPlatformWindowHovered(_GLFWwindow* window);
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
-
-void _glfwPlatformPollEvents(void);
-void _glfwPlatformWaitEvents(void);
-void _glfwPlatformWaitEventsTimeout(double timeout);
-void _glfwPlatformPostEmptyEvent(void);
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily);
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface);
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
-void _glfwPlatformDestroyTls(_GLFWtls* tls);
-void* _glfwPlatformGetTls(_GLFWtls* tls);
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
-void _glfwPlatformLockMutex(_GLFWmutex* mutex);
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
-void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
-void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
-void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
-void _glfwInputWindowContentScale(_GLFWwindow* window,
-                                  float xscale, float yscale);
-void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
-void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
-void _glfwInputWindowDamage(_GLFWwindow* window);
-void _glfwInputWindowCloseRequest(_GLFWwindow* window);
-void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
-
-void _glfwInputKey(_GLFWwindow* window,
-                   int key, int scancode, int action, int mods);
-void _glfwInputChar(_GLFWwindow* window,
-                    unsigned int codepoint, int mods, GLFWbool plain);
-void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
-void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
-void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
-void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
-void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
-void _glfwInputJoystick(_GLFWjoystick* js, int event);
-void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
-void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
-void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);
-
-void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
-void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);
-
-#if defined(__GNUC__)
-void _glfwInputError(int code, const char* format, ...)
-    __attribute__((format(printf, 2, 3)));
-#else
-void _glfwInputError(int code, const char* format, ...);
-#endif
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
-const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
-                                         const _GLFWfbconfig* alternatives,
-                                         unsigned int count);
-GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
-                                    const _GLFWctxconfig* ctxconfig);
-GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
-
-const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
-                                        const GLFWvidmode* desired);
-int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
-_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
-void _glfwFreeMonitor(_GLFWmonitor* monitor);
-void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
-void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
-void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
-
-_GLFWjoystick* _glfwAllocJoystick(const char* name,
-                                  const char* guid,
-                                  int axisCount,
-                                  int buttonCount,
-                                  int hatCount);
-void _glfwFreeJoystick(_GLFWjoystick* js);
-void _glfwCenterCursorInContentArea(_GLFWwindow* window);
-
-GLFWbool _glfwInitVulkan(int mode);
-void _glfwTerminateVulkan(void);
-const char* _glfwGetVulkanResultString(VkResult result);
-
-char* _glfw_strdup(const char* source);
-float _glfw_fminf(float a, float b);
-float _glfw_fmaxf(float a, float b);
-
diff --git a/raylib/external/glfw/src/linux_joystick.c b/raylib/external/glfw/src/linux_joystick.c
deleted file mode 100644 (file)
index 122bc66..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/inotify.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifndef SYN_DROPPED // < v2.6.39 kernel headers
-// Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32
-#define SYN_DROPPED 3
-#endif
-
-// Apply an EV_KEY event to the specified joystick
-//
-static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
-{
-    _glfwInputJoystickButton(js,
-                             js->linjs.keyMap[code - BTN_MISC],
-                             value ? GLFW_PRESS : GLFW_RELEASE);
-}
-
-// Apply an EV_ABS event to the specified joystick
-//
-static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
-{
-    const int index = js->linjs.absMap[code];
-
-    if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
-    {
-        static const char stateMap[3][3] =
-        {
-            { GLFW_HAT_CENTERED, GLFW_HAT_UP,       GLFW_HAT_DOWN },
-            { GLFW_HAT_LEFT,     GLFW_HAT_LEFT_UP,  GLFW_HAT_LEFT_DOWN },
-            { GLFW_HAT_RIGHT,    GLFW_HAT_RIGHT_UP, GLFW_HAT_RIGHT_DOWN },
-        };
-
-        const int hat = (code - ABS_HAT0X) / 2;
-        const int axis = (code - ABS_HAT0X) % 2;
-        int* state = js->linjs.hats[hat];
-
-        // NOTE: Looking at several input drivers, it seems all hat events use
-        //       -1 for left / up, 0 for centered and 1 for right / down
-        if (value == 0)
-            state[axis] = 0;
-        else if (value < 0)
-            state[axis] = 1;
-        else if (value > 0)
-            state[axis] = 2;
-
-        _glfwInputJoystickHat(js, index, stateMap[state[0]][state[1]]);
-    }
-    else
-    {
-        const struct input_absinfo* info = &js->linjs.absInfo[code];
-        float normalized = value;
-
-        const int range = info->maximum - info->minimum;
-        if (range)
-        {
-            // Normalize to 0.0 -> 1.0
-            normalized = (normalized - info->minimum) / range;
-            // Normalize to -1.0 -> 1.0
-            normalized = normalized * 2.0f - 1.0f;
-        }
-
-        _glfwInputJoystickAxis(js, index, normalized);
-    }
-}
-
-// Poll state of absolute axes
-//
-static void pollAbsState(_GLFWjoystick* js)
-{
-    for (int code = 0;  code < ABS_CNT;  code++)
-    {
-        if (js->linjs.absMap[code] < 0)
-            continue;
-
-        struct input_absinfo* info = &js->linjs.absInfo[code];
-
-        if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0)
-            continue;
-
-        handleAbsEvent(js, code, info->value);
-    }
-}
-
-#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8)))
-
-// Attempt to open the specified joystick device
-//
-static GLFWbool openJoystickDevice(const char* path)
-{
-    for (int jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (!_glfw.joysticks[jid].present)
-            continue;
-        if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
-            return GLFW_FALSE;
-    }
-
-    _GLFWjoystickLinux linjs = {0};
-    linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
-    if (linjs.fd == -1)
-        return GLFW_FALSE;
-
-    char evBits[(EV_CNT + 7) / 8] = {0};
-    char keyBits[(KEY_CNT + 7) / 8] = {0};
-    char absBits[(ABS_CNT + 7) / 8] = {0};
-    struct input_id id;
-
-    if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGID, &id) < 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Linux: Failed to query input device: %s",
-                        strerror(errno));
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    // Ensure this device supports the events expected of a joystick
-    if (!isBitSet(EV_KEY, evBits) || !isBitSet(EV_ABS, evBits))
-    {
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    char name[256] = "";
-
-    if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
-        strncpy(name, "Unknown", sizeof(name));
-
-    char guid[33] = "";
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (id.vendor && id.product && id.version)
-    {
-        sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000",
-                id.bustype & 0xff, id.bustype >> 8,
-                id.vendor & 0xff,  id.vendor >> 8,
-                id.product & 0xff, id.product >> 8,
-                id.version & 0xff, id.version >> 8);
-    }
-    else
-    {
-        sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                id.bustype & 0xff, id.bustype >> 8,
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    int axisCount = 0, buttonCount = 0, hatCount = 0;
-
-    for (int code = BTN_MISC;  code < KEY_CNT;  code++)
-    {
-        if (!isBitSet(code, keyBits))
-            continue;
-
-        linjs.keyMap[code - BTN_MISC] = buttonCount;
-        buttonCount++;
-    }
-
-    for (int code = 0;  code < ABS_CNT;  code++)
-    {
-        linjs.absMap[code] = -1;
-        if (!isBitSet(code, absBits))
-            continue;
-
-        if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
-        {
-            linjs.absMap[code] = hatCount;
-            hatCount++;
-            // Skip the Y axis
-            code++;
-        }
-        else
-        {
-            if (ioctl(linjs.fd, EVIOCGABS(code), &linjs.absInfo[code]) < 0)
-                continue;
-
-            linjs.absMap[code] = axisCount;
-            axisCount++;
-        }
-    }
-
-    _GLFWjoystick* js =
-        _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
-    if (!js)
-    {
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    strncpy(linjs.path, path, sizeof(linjs.path) - 1);
-    memcpy(&js->linjs, &linjs, sizeof(linjs));
-
-    pollAbsState(js);
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-    return GLFW_TRUE;
-}
-
-#undef isBitSet
-
-// Frees all resources associated with the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    close(js->linjs.fd);
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// Lexically compare joysticks by name; used by qsort
-//
-static int compareJoysticks(const void* fp, const void* sp)
-{
-    const _GLFWjoystick* fj = fp;
-    const _GLFWjoystick* sj = sp;
-    return strcmp(fj->linjs.path, sj->linjs.path);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwDetectJoystickConnectionLinux(void)
-{
-    if (_glfw.linjs.inotify <= 0)
-        return;
-
-    ssize_t offset = 0;
-    char buffer[16384];
-    const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
-
-    while (size > offset)
-    {
-        regmatch_t match;
-        const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
-
-        offset += sizeof(struct inotify_event) + e->len;
-
-        if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
-            continue;
-
-        char path[PATH_MAX];
-        snprintf(path, sizeof(path), "/dev/input/%s", e->name);
-
-        if (e->mask & (IN_CREATE | IN_ATTRIB))
-            openJoystickDevice(path);
-        else if (e->mask & IN_DELETE)
-        {
-            for (int jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-            {
-                if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
-                {
-                    closeJoystick(_glfw.joysticks + jid);
-                    break;
-                }
-            }
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    const char* dirname = "/dev/input";
-
-    _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
-    if (_glfw.linjs.inotify > 0)
-    {
-        // HACK: Register for IN_ATTRIB to get notified when udev is done
-        //       This works well in practice but the true way is libudev
-
-        _glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
-                                              dirname,
-                                              IN_CREATE | IN_ATTRIB | IN_DELETE);
-    }
-
-    // Continue without device connection notifications if inotify fails
-
-    if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
-        return GLFW_FALSE;
-    }
-
-    int count = 0;
-
-    DIR* dir = opendir(dirname);
-    if (dir)
-    {
-        struct dirent* entry;
-
-        while ((entry = readdir(dir)))
-        {
-            regmatch_t match;
-
-            if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
-                continue;
-
-            char path[PATH_MAX];
-
-            snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
-
-            if (openJoystickDevice(path))
-                count++;
-        }
-
-        closedir(dir);
-    }
-
-    // Continue with no joysticks if enumeration fails
-
-    qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            closeJoystick(js);
-    }
-
-    if (_glfw.linjs.inotify > 0)
-    {
-        if (_glfw.linjs.watch > 0)
-            inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
-
-        close(_glfw.linjs.inotify);
-        regfree(&_glfw.linjs.regex);
-    }
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    // Read all queued events (non-blocking)
-    for (;;)
-    {
-        struct input_event e;
-
-        errno = 0;
-        if (read(js->linjs.fd, &e, sizeof(e)) < 0)
-        {
-            // Reset the joystick slot if the device was disconnected
-            if (errno == ENODEV)
-                closeJoystick(js);
-
-            break;
-        }
-
-        if (e.type == EV_SYN)
-        {
-            if (e.code == SYN_DROPPED)
-                _glfw.linjs.dropped = GLFW_TRUE;
-            else if (e.code == SYN_REPORT)
-            {
-                _glfw.linjs.dropped = GLFW_FALSE;
-                pollAbsState(js);
-            }
-        }
-
-        if (_glfw.linjs.dropped)
-            continue;
-
-        if (e.type == EV_KEY)
-            handleKeyEvent(js, e.code, e.value);
-        else if (e.type == EV_ABS)
-            handleAbsEvent(js, e.code, e.value);
-    }
-
-    return js->present;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-}
-
diff --git a/raylib/external/glfw/src/linux_joystick.h b/raylib/external/glfw/src/linux_joystick.h
deleted file mode 100644 (file)
index 05d5488..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <linux/input.h>
-#include <linux/limits.h>
-#include <regex.h>
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickLinux linjs
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux  linjs
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
-
-// Linux-specific joystick data
-//
-typedef struct _GLFWjoystickLinux
-{
-    int                     fd;
-    char                    path[PATH_MAX];
-    int                     keyMap[KEY_CNT - BTN_MISC];
-    int                     absMap[ABS_CNT];
-    struct input_absinfo    absInfo[ABS_CNT];
-    int                     hats[4][2];
-} _GLFWjoystickLinux;
-
-// Linux-specific joystick API data
-//
-typedef struct _GLFWlibraryLinux
-{
-    int                     inotify;
-    int                     watch;
-    regex_t                 regex;
-    GLFWbool                dropped;
-} _GLFWlibraryLinux;
-
-void _glfwDetectJoystickConnectionLinux(void);
-
diff --git a/raylib/external/glfw/src/mappings.h b/raylib/external/glfw/src/mappings.h
deleted file mode 100644 (file)
index 4c3f02f..0000000
+++ /dev/null
@@ -1,998 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As mappings.h.in, this file is used by CMake to produce the mappings.h
-// header file.  If you are adding a GLFW specific gamepad mapping, this is
-// where to put it.
-//========================================================================
-// As mappings.h, this provides all pre-defined gamepad mappings, including
-// all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
-// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
-// This file can be re-generated from mappings.h.in and the upstream
-// gamecontrollerdb.txt with the GenerateMappings.cmake script.
-//========================================================================
-
-// All gamepad mappings not labeled GLFW are copied from the
-// SDL_GameControllerDB project under the following license:
-//
-// Simple DirectMedia Layer
-// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the
-// use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-//    misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-
-const char* _glfwDefaultMappings[] =
-{
-"03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,",
-"03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00005106000000000000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00015900000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00065280000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00006228000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001890000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006f0e00001413000000000000,Afterglow,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000869800002400000000007801,Astro C40 TR,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows,",
-"030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000002a79000000000000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000006321000000000000,BETOP CONTROLLER,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows,",
-"03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000457500000401000000000000,Cobra,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000a102000000000000,Controller (Xbox 360 Wireless Receiver for Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ff02000000000000,Controller (Xbox One For Windows) - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ea02000000000000,Controller (Xbox One For Windows) - Wireless,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000007d0400000840000000000000,Destroyer Tiltpad,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b1,b:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,x:b0,y:b3,platform:Windows,",
-"03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
-"030000008f0e00000910000000000000,DualShock 2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
-"030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000120c0000f61c000000000000,Elite,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000006f0e00008401000000000000,Faceoff Deluxe+ Audio Wired Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00008001000000000000,Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
-"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,",
-"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000004618000000000000,GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000c01100000140000000000000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000009b2800003200000000000000,GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
-"030000009b2800006000000000000000,GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
-"030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000007d0400000540000000000000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000001008000001e1000000000000,Havit HV-G60,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"030000000d0f00002d00000000000000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00001600000000007803,HORI Real Arcade Pro EX-SE (Xbox 360),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
-"030000000d0f00009c00000000000000,Hori TAC Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005500000000000000,Horipad 4 FPS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows,",
-"030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows,",
-"03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000491900000304000000000000,Ipega PG-9087 - Bluetooth Gamepad,+righty:+a5,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"030000006e0500000a20000000000000,JC-DUX60 ELECOM MMO Gamepad,a:b2,b:b3,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b14,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b15,righttrigger:b13,rightx:a3,righty:a4,start:b20,x:b0,y:b1,platform:Windows,",
-"030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
-"030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
-"030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"030000007e0500000620000000000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
-"030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows,",
-"03000000242f00002d00000000000000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000242f00008a00000000000000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows,",
-"030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d0400001ac2000000000000,Logitech Precision Gamepad,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d0400000ac2000000000000,Logitech WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Windows,",
-"03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows,",
-"03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000242f00007300000000000000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"0300000079000000d218000000000000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d620000010a7000000000000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows,",
-"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000002418000000000000,Mega Drive,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b2,start:b9,x:b3,y:b4,platform:Windows,",
-"03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000c62400002a89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400002b89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400001a89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400001b89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"030000006b140000010c000000000000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Windows,",
-"03000000550900001472000000000000,NVIDIA Controller v01.04,a:b11,b:b10,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b5,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b4,righttrigger:a5,rightx:a3,righty:a6,start:b3,x:b9,y:b8,platform:Windows,",
-"030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,platform:Windows,",
-"03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows,",
-"03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000901000000000000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,",
-"030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,",
-"030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000e60c000000000000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows,",
-"03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
-"03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows,",
-"03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000507000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000321500000707000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000321500000011000000000000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000009000000000000,Razer Serval,+lefty:+a2,-lefty:-a1,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,leftx:a0,rightshoulder:b5,rightstick:b9,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000013d0000000000000,Retrolink USB SEGA Saturn Classic,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,lefttrigger:b6,rightshoulder:b2,righttrigger:b7,start:b8,x:b3,y:b4,platform:Windows,",
-"0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
-"0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
-"030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b140000020d000000000000,Revolution Pro Controller 2(1/2),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b140000130d000000000000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000a30600000701000000000000,Saitek P220,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b5,x:b0,y:b1,platform:Windows,",
-"03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b0,y:b1,platform:Windows,",
-"03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows,",
-"03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000730700000401000000000000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Windows,",
-"0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005e0400008e02000000007801,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d11800000094000000000000,Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000381000001214000000000000,SteelSeries Free,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000110100003114000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows,",
-"03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000457500002211000000000000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f0400000ab1000000000000,T.16000M,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b10,x:b2,y:b3,platform:Windows,",
-"03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
-"030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f0400000ed0000000000000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows,",
-"030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
-"03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000004f04000087b6000000000000,TWCS Throttle,dpdown:b8,dpleft:b9,dpright:b7,dpup:b6,leftstick:b5,lefttrigger:-a5,leftx:a0,lefty:a1,righttrigger:+a5,platform:Windows,",
-"03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006e0500001320000000000000,U4113,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,platform:Windows,",
-"030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000702000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"0300000034120000adbe000000000000,vJoy Device,a:b0,b:b1,back:b15,dpdown:b6,dpleft:b7,dpright:b8,dpup:b5,guide:b16,leftshoulder:b9,leftstick:b13,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b14,righttrigger:b12,rightx:+a3,righty:+a4,start:b4,x:b2,y:b3,platform:Windows,",
-"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ff02000000007801,Xbox One Elite Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000130b000000000000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000ac0500005b05000000000000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000120c0000101e000000000000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000300000009010000,2In1 USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000c82d00005106000000010000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001590000001000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"030000003512000012ab000001000000,8BitDo NES30 Gamepad,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001290000001000000,8BitDo SN30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000160000001000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000031000001000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001890000001000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a31,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,platform:Mac OS X,",
-"03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000c01100000140000000010000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00009200000000010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f0000ee00000000010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X,",
-"03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
-"03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000242f00002d00000007010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000006d04000018c2000000010000,Logitech RumblePad 2 USB,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X,",
-"0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X,",
-"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,",
-"03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000005e0400002700000001010000,Microsoft SideWinder Plug & Play Game Pad,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b4,leftx:a0,lefty:a1,righttrigger:b5,x:b2,y:b3,platform:Mac OS X,",
-"03000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,",
-"03000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000c62400002b89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d620000011a7000000020000,Nintendo Switch Core (Plus) Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000550900001472000025050000,NVIDIA Controller v01.04,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Mac OS X,",
-"030000006f0e00000901000002010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
-"030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
-"030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000507000001010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000321500000011000000010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000009000000020000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006b140000130d000000010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000c6240000fefa000000000000,Rock Candy Gamepad for PS3,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000730700000401000000010000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Mac OS X,",
-"03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X,",
-"03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X,",
-"030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,",
-"30000004c050000e60c0000000100000,Sony DualSense,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000d11800000094000000010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
-"03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000457500002211000000010000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X,",
-"030000004f0400000ed0000000020000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X,",
-"03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X,",
-"030000006f0e00000302000025040000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006f0e00000702000003060000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000791d00000103000009010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X,",
-"050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X,",
-"030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000050b000003090000,Xbox Elite Wireless Controller Series 2,a:b0,b:b1,back:b31,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b53,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000120c0000101e000000010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000c82d00001590000011010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000310000011010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c82d00008010000000010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000060000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d000021ab000010010000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"030000003512000012ab000010010000,8Bitdo SFC30 GamePad,a:b2,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux,",
-"05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000202800000900000000010000,8BitDo SNES30 Gamepad,a:b1,b:b0,back:b10,dpdown:b122,dpleft:b119,dpright:b120,dpup:b117,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"030000005e0400008e02000020010000,8BitDo Wireless Adapter,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c82d00000031000011010000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00001890000011010000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000013020000,Afterglow Prismatic Wired Controller 048-007-NA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000007c1800000006000010010000,Alienware Dual Compatible Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
-"05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
-"03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux,",
-"03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000c21100000791000011010000,Be1 GC101 Controller 1.03 mode,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000c31100000791000011010000,Be1 GC101 GAMEPAD 1.03 mode,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000003030000,Be1 GC101 Xbox 360 Controller mode,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,",
-"03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux,",
-"03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
-"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
-"030000004f04000004b3000010010000,Dual Power 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008f0e00000800000010010000,Gasia Co. Ltd PS(R) Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000007d0400000540000000010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux,",
-"030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000f0250000c383000010010000,GT VX2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,",
-"03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000632500002605000010010000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,",
-"030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000c100000011010000,HORI CO. LTD. HORIPAD S,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00008500000010010000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00008600000002010000,Hori Fighting Commander,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000000d0f00009200000011010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000aa00000011010000,HORI Real Arcade Pro,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000000d0f0000d800000072056800,HORI Real Arcade Pro S,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"030000000d0f00001600000000010000,Hori Real Arcade Pro.EX-SE (Xbox 360),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000ee00000011010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000242e00008816000001010000,Hyperkin X91,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
-"050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,platform:Linux,",
-"03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux,",
-"0500000049190000020400001b010000,Ipega PG-9069 - Bluetooth Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b161,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000632500007505000011010000,Ipega PG-9099 - Bluetooth Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux,",
-"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
-"050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
-"050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000242f00002d00000011010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000242f00008a00000011010000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
-"030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400001ec2000019200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400000ac2000010010000,Logitech Inc. WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Linux,",
-"030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux,",
-"05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
-"0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000d620000010a7000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"0300000025090000e803000001010000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:a5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
-"03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000050b000003090000,Microsoft X-Box One Elite 2 pad,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000e302000003020000,Microsoft X-Box One Elite pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000dd02000003020000,Microsoft X-Box One pad (Firmware 2015),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"030000005e040000000b000008040000,Microsoft Xbox One Elite 2 pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000ea02000008040000,Microsoft Xbox One S pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c62400001a53000000010000,Mini PE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
-"05000000d6200000e589000001000000,Moga 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"03000000c62400002b89000011010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b22,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c62400001a89000000010000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux,",
-"060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux,",
-"03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b0,y:b3,platform:Linux,",
-"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"050000007e0500000920000001800000,Nintendo Switch Pro Controller (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"030000007e0500000920000011810000,Nintendo Switch Pro Controller Wired (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
-"05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux,",
-"03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
-"03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"19000000010000000100000001010000,odroidgo2_joypad,a:b1,b:b0,dpdown:b7,dpleft:b8,dpright:b9,dpup:b6,guide:b10,leftshoulder:b4,leftstick:b12,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b13,righttrigger:b14,start:b15,x:b2,y:b3,platform:Linux,",
-"19000000010000000200000011000000,odroidgo2_joypad_v11,a:b1,b:b0,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b12,leftshoulder:b4,leftstick:b14,lefttrigger:b13,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:b16,start:b17,x:b2,y:b3,platform:Linux,",
-"030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
-"05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
-"03000000830500005020000010010000,Padix Co. Ltd. Rockfire PSX/USB Bridge,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b2,y:b3,platform:Linux,",
-"03000000790000001c18000011010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e0000b802000001010000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e0000b802000013020000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008001000011010000,PDP CO. LTD. Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00003101000000010000,PDP EA Sports Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e0000c802000012010000,PDP Kingdom Hearts Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008701000011010000,PDP Rock Candy Wired Controller for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e00000901000011010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008501000011010000,PDP Wired Fight Pad Pro for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"05000000491900000204000000000000,PG-9118,x:b76,a:b73,b:b74,y:b77,back:b83,start:b84,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b79,lefttrigger:b81,rightshoulder:b80,righttrigger:b82,leftstick:b86,rightstick:b87,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Linux,",
-"0500000049190000030400001b010000,PG-9099,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000c62400001a58000001010000,PowerA Xbox One Cabled,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"03000000c01100000140000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000c405000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,",
-"030000009b2800003200000001010000,Raphnet Technologies GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
-"030000009b2800006000000001010000,Raphnet Technologies GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
-"030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,",
-"030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000810000011010000,Razer Panthera Evo Arcade Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000507000000010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000321500000011000011010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux,",
-"0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
-"030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006b140000130d000011010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b0,y:b1,platform:Linux,",
-"03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,",
-"03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,",
-"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,",
-"03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a306000020f6000011010000,Saitek PS2700 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a30600001005000000010000,Saitek Saitek P150,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b2,righttrigger:b5,x:b3,y:b4,platform:Linux,",
-"03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux,",
-"03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux,",
-"03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
-"03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
-"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000003b07000004a1000000010000,Suncom SFX Plus for USB,a:b0,b:b2,back:b7,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:b5,start:b8,x:b1,y:b3,platform:Linux,",
-"03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
-"03000000457500002211000010010000,SZMY-POWER CO. LTD. GAMEPAD,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000008f0e00000d31000010010000,SZMY-POWER CO. LTD. GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f0400000ed0000011010000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b50700000399000000010000,Thrustmaster Firestorm Digital 2,a:b2,b:b4,back:b11,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b0,righttrigger:b9,start:b1,x:b3,y:b5,platform:Linux,",
-"030000004f04000003b3000010010000,Thrustmaster Firestorm Dual Analog 2,a:b0,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b9,rightx:a2,righty:a3,x:b1,y:b3,platform:Linux,",
-"030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,",
-"030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000007d0000000010000,Thrustmaster T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,",
-"030000005e0400008e02000070050000,Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c01100000591000011010000,Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux,",
-"030000006f0e00000302000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00000702000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000791d00000103000010010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"050000000d0f0000f600000001000000,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000fd02000030110000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000050b000002090000,Xbox One Elite Series 2,a:b0,b:b1,back:b136,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000ea02000000000000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000ea02000001030000,Xbox One Wireless Controller (Model 1708),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000120b000001050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"050000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"050000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000000010000,xbox360 Wireless EasySMX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000ac0500005b05000010010000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,",
-"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000051060000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000015900000ffff3f00,8BitDo N30 Pro 2,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000065280000ffff3f00,8BitDo N30 Pro 2,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b17,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000000220000000900000ffff3f00,8BitDo NES30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000002038000009000000ffff3f00,8BitDo NES30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000000600000ffff3f00,8BitDo SF30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000000610000ffff3f00,8BitDo SF30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000012900000ffff3f00,8BitDo SN30 Gamepad,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000062280000ffff3f00,8BitDo SN30 Gamepad,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000001600000ffff3f00,8BitDo SN30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000002600000ffff0f00,8BitDo SN30 Pro+,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b17,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000002028000009000000ffff3f00,8BitDo SNES30 Gamepad,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000003512000020ab000000780f00,8BitDo SNES30 Gamepad,a:b21,b:b20,back:b30,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b26,rightshoulder:b27,start:b31,x:b24,y:b23,platform:Android,",
-"05000000c82d000018900000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"0500000031366332860c44aadfff0f00,GS Gamepad,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"0500000083050000602000000ffe0000,iBuffalo SNES Controller,a:b1,b:b0,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b15,rightshoulder:b16,start:b10,x:b3,y:b2,platform:Android,",
-"64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,",
-"7573622067616d657061642020202020,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Android,",
-"050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,platform:Android,",
-"37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000014720000df7f3f00,NVIDIA Controller v01.04,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"030000004c050000cc09000000006800,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000cc090000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000e60c0000fffe3f00,PS5 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"62653861643333663663383332396665,Razer Kishi,a:b0,b:b1,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,",
-"32633532643734376632656664383733,Sony DualSense,a:b1,b:b19,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a5,start:b18,x:b0,y:b2,platform:Android,",
-"61303162353165316365336436343139,Sony DualSense,a:b1,b:b19,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a5,start:b18,x:b0,y:b2,platform:Android,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,",
-"050000004f0400000ed00000fffe3f00,ThrustMaster eSwap PRO Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android,",
-"30306539356238653637313730656134,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b18,x:b19,y:b2,platform:Android,",
-"050000005e040000fd020000ff7f3f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,platform:Android,",
-"050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e040000130b0000ffff3f00,Xbox Series Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"65633038363832353634653836396239,Xbox Series Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android,",
-"34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,",
-"050000001727000044310000ffff3f00,XiaoMi Game Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a6,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac050000010000004f066d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000cf076d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000df076d01,*,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000ff076d01,*,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"05000000ac0500000200000000006d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,",
-"05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,",
-"4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS,",
-"4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000ff870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,platform:iOS,",
-"05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,",
-"05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,",
-"050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-
-"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-NULL
-};
-
diff --git a/raylib/external/glfw/src/mappings.h.in b/raylib/external/glfw/src/mappings.h.in
deleted file mode 100644 (file)
index 583e98b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As mappings.h.in, this file is used by CMake to produce the mappings.h
-// header file.  If you are adding a GLFW specific gamepad mapping, this is
-// where to put it.
-//========================================================================
-// As mappings.h, this provides all pre-defined gamepad mappings, including
-// all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
-// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
-// This file can be re-generated from mappings.h.in and the upstream
-// gamecontrollerdb.txt with the GenerateMappings.cmake script.
-//========================================================================
-
-// All gamepad mappings not labeled GLFW are copied from the
-// SDL_GameControllerDB project under the following license:
-//
-// Simple DirectMedia Layer
-// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the
-// use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-//    misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-
-const char* _glfwDefaultMappings[] =
-{
-@GLFW_GAMEPAD_MAPPINGS@
-"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-NULL
-};
-
diff --git a/raylib/external/glfw/src/monitor.c b/raylib/external/glfw/src/monitor.c
deleted file mode 100644 (file)
index 394026f..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <math.h>
-#include <float.h>
-#include <string.h>
-#include <stdlib.h>
-#include <limits.h>
-
-
-// Lexically compare video modes, used by qsort
-//
-static int compareVideoModes(const void* fp, const void* sp)
-{
-    const GLFWvidmode* fm = fp;
-    const GLFWvidmode* sm = sp;
-    const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
-    const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
-    const int farea = fm->width * fm->height;
-    const int sarea = sm->width * sm->height;
-
-    // First sort on color bits per pixel
-    if (fbpp != sbpp)
-        return fbpp - sbpp;
-
-    // Then sort on screen area
-    if (farea != sarea)
-        return farea - sarea;
-
-    // Then sort on width
-    if (fm->width != sm->width)
-        return fm->width - sm->width;
-
-    // Lastly sort on refresh rate
-    return fm->refreshRate - sm->refreshRate;
-}
-
-// Retrieves the available modes for the specified monitor
-//
-static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
-{
-    int modeCount;
-    GLFWvidmode* modes;
-
-    if (monitor->modes)
-        return GLFW_TRUE;
-
-    modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
-    if (!modes)
-        return GLFW_FALSE;
-
-    qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
-
-    free(monitor->modes);
-    monitor->modes = modes;
-    monitor->modeCount = modeCount;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of a monitor connection or disconnection
-//
-void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
-{
-    if (action == GLFW_CONNECTED)
-    {
-        _glfw.monitorCount++;
-        _glfw.monitors =
-            realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount);
-
-        if (placement == _GLFW_INSERT_FIRST)
-        {
-            memmove(_glfw.monitors + 1,
-                    _glfw.monitors,
-                    ((size_t) _glfw.monitorCount - 1) * sizeof(_GLFWmonitor*));
-            _glfw.monitors[0] = monitor;
-        }
-        else
-            _glfw.monitors[_glfw.monitorCount - 1] = monitor;
-    }
-    else if (action == GLFW_DISCONNECTED)
-    {
-        int i;
-        _GLFWwindow* window;
-
-        for (window = _glfw.windowListHead;  window;  window = window->next)
-        {
-            if (window->monitor == monitor)
-            {
-                int width, height, xoff, yoff;
-                _glfwPlatformGetWindowSize(window, &width, &height);
-                _glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0);
-                _glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
-                _glfwPlatformSetWindowPos(window, xoff, yoff);
-            }
-        }
-
-        for (i = 0;  i < _glfw.monitorCount;  i++)
-        {
-            if (_glfw.monitors[i] == monitor)
-            {
-                _glfw.monitorCount--;
-                memmove(_glfw.monitors + i,
-                        _glfw.monitors + i + 1,
-                        ((size_t) _glfw.monitorCount - i) * sizeof(_GLFWmonitor*));
-                break;
-            }
-        }
-    }
-
-    if (_glfw.callbacks.monitor)
-        _glfw.callbacks.monitor((GLFWmonitor*) monitor, action);
-
-    if (action == GLFW_DISCONNECTED)
-        _glfwFreeMonitor(monitor);
-}
-
-// Notifies shared code that a full screen window has acquired or released
-// a monitor
-//
-void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
-{
-    monitor->window = window;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Allocates and returns a monitor object with the specified name and dimensions
-//
-_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
-{
-    _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
-    monitor->widthMM = widthMM;
-    monitor->heightMM = heightMM;
-
-    if (name)
-        monitor->name = _glfw_strdup(name);
-
-    return monitor;
-}
-
-// Frees a monitor object and any data associated with it
-//
-void _glfwFreeMonitor(_GLFWmonitor* monitor)
-{
-    if (monitor == NULL)
-        return;
-
-    _glfwPlatformFreeMonitor(monitor);
-
-    _glfwFreeGammaArrays(&monitor->originalRamp);
-    _glfwFreeGammaArrays(&monitor->currentRamp);
-
-    free(monitor->modes);
-    free(monitor->name);
-    free(monitor);
-}
-
-// Allocates red, green and blue value arrays of the specified size
-//
-void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
-{
-    ramp->red = calloc(size, sizeof(unsigned short));
-    ramp->green = calloc(size, sizeof(unsigned short));
-    ramp->blue = calloc(size, sizeof(unsigned short));
-    ramp->size = size;
-}
-
-// Frees the red, green and blue value arrays and clears the struct
-//
-void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
-{
-    free(ramp->red);
-    free(ramp->green);
-    free(ramp->blue);
-
-    memset(ramp, 0, sizeof(GLFWgammaramp));
-}
-
-// Chooses the video mode most closely matching the desired one
-//
-const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
-                                        const GLFWvidmode* desired)
-{
-    int i;
-    unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
-    unsigned int rateDiff, leastRateDiff = UINT_MAX;
-    unsigned int colorDiff, leastColorDiff = UINT_MAX;
-    const GLFWvidmode* current;
-    const GLFWvidmode* closest = NULL;
-
-    if (!refreshVideoModes(monitor))
-        return NULL;
-
-    for (i = 0;  i < monitor->modeCount;  i++)
-    {
-        current = monitor->modes + i;
-
-        colorDiff = 0;
-
-        if (desired->redBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->redBits - desired->redBits);
-        if (desired->greenBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->greenBits - desired->greenBits);
-        if (desired->blueBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->blueBits - desired->blueBits);
-
-        sizeDiff = abs((current->width - desired->width) *
-                       (current->width - desired->width) +
-                       (current->height - desired->height) *
-                       (current->height - desired->height));
-
-        if (desired->refreshRate != GLFW_DONT_CARE)
-            rateDiff = abs(current->refreshRate - desired->refreshRate);
-        else
-            rateDiff = UINT_MAX - current->refreshRate;
-
-        if ((colorDiff < leastColorDiff) ||
-            (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
-            (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
-        {
-            closest = current;
-            leastSizeDiff = sizeDiff;
-            leastRateDiff = rateDiff;
-            leastColorDiff = colorDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Performs lexical comparison between two @ref GLFWvidmode structures
-//
-int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
-{
-    return compareVideoModes(fm, sm);
-}
-
-// Splits a color depth into red, green and blue bit depths
-//
-void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
-{
-    int delta;
-
-    // We assume that by 32 the user really meant 24
-    if (bpp == 32)
-        bpp = 24;
-
-    // Convert "bits per pixel" to red, green & blue sizes
-
-    *red = *green = *blue = bpp / 3;
-    delta = bpp - (*red * 3);
-    if (delta >= 1)
-        *green = *green + 1;
-
-    if (delta == 2)
-        *red = *red + 1;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
-{
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    *count = _glfw.monitorCount;
-    return (GLFWmonitor**) _glfw.monitors;
-}
-
-GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfw.monitorCount)
-        return NULL;
-
-    return (GLFWmonitor*) _glfw.monitors[0];
-}
-
-GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformGetMonitorPos(monitor, xpos, ypos);
-}
-
-GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
-                                    int* xpos, int* ypos,
-                                    int* width, int* height)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformGetMonitorWorkarea(monitor, xpos, ypos, width, height);
-}
-
-GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (widthMM)
-        *widthMM = 0;
-    if (heightMM)
-        *heightMM = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (widthMM)
-        *widthMM = monitor->widthMM;
-    if (heightMM)
-        *heightMM = monitor->heightMM;
-}
-
-GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
-                                        float* xscale, float* yscale)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xscale)
-        *xscale = 0.f;
-    if (yscale)
-        *yscale = 0.f;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetMonitorContentScale(monitor, xscale, yscale);
-}
-
-GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->name;
-}
-
-GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    monitor->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->userPointer;
-}
-
-GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
-    return cbfun;
-}
-
-GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!refreshVideoModes(monitor))
-        return NULL;
-
-    *count = monitor->modeCount;
-    return monitor->modes;
-}
-
-GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    _glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
-    return &monitor->currentMode;
-}
-
-GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
-{
-    unsigned int i;
-    unsigned short* values;
-    GLFWgammaramp ramp;
-    const GLFWgammaramp* original;
-    assert(handle != NULL);
-    assert(gamma > 0.f);
-    assert(gamma <= FLT_MAX);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
-        return;
-    }
-
-    original = glfwGetGammaRamp(handle);
-    if (!original)
-        return;
-
-    values = calloc(original->size, sizeof(unsigned short));
-
-    for (i = 0;  i < original->size;  i++)
-    {
-        float value;
-
-        // Calculate intensity
-        value = i / (float) (original->size - 1);
-        // Apply gamma curve
-        value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
-        // Clamp to value range
-        value = _glfw_fminf(value, 65535.f);
-
-        values[i] = (unsigned short) value;
-    }
-
-    ramp.red = values;
-    ramp.green = values;
-    ramp.blue = values;
-    ramp.size = original->size;
-
-    glfwSetGammaRamp(handle, &ramp);
-    free(values);
-}
-
-GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    _glfwFreeGammaArrays(&monitor->currentRamp);
-    if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp))
-        return NULL;
-
-    return &monitor->currentRamp;
-}
-
-GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-    assert(ramp != NULL);
-    assert(ramp->size > 0);
-    assert(ramp->red != NULL);
-    assert(ramp->green != NULL);
-    assert(ramp->blue != NULL);
-
-    if (ramp->size <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid gamma ramp size %i",
-                        ramp->size);
-        return;
-    }
-
-    _GLFW_REQUIRE_INIT();
-
-    if (!monitor->originalRamp.size)
-    {
-        if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp))
-            return;
-    }
-
-    _glfwPlatformSetGammaRamp(monitor, ramp);
-}
-
diff --git a/raylib/external/glfw/src/nsgl_context.h b/raylib/external/glfw/src/nsgl_context.h
deleted file mode 100644 (file)
index 9c31436..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-// NOTE: Many Cocoa enum values have been renamed and we need to build across
-//       SDK versions where one is unavailable or the other deprecated
-//       We use the newer names in code and these macros to handle compatibility
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
- #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
- #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
-#endif
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextNSGL nsgl
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryNSGL nsgl
-
-#include <stdatomic.h>
-
-
-// NSGL-specific per-context data
-//
-typedef struct _GLFWcontextNSGL
-{
-    id                pixelFormat;
-    id                object;
-
-} _GLFWcontextNSGL;
-
-// NSGL-specific global data
-//
-typedef struct _GLFWlibraryNSGL
-{
-    // dlopen handle for OpenGL.framework (for glfwGetProcAddress)
-    CFBundleRef     framework;
-
-} _GLFWlibraryNSGL;
-
-
-GLFWbool _glfwInitNSGL(void);
-void _glfwTerminateNSGL(void);
-GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
-                                const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* fbconfig);
-void _glfwDestroyContextNSGL(_GLFWwindow* window);
-
diff --git a/raylib/external/glfw/src/nsgl_context.m b/raylib/external/glfw/src/nsgl_context.m
deleted file mode 100644 (file)
index 3f73f7a..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <math.h>
-
-static void makeContextCurrentNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    if (window)
-        [window->context.nsgl.object makeCurrentContext];
-    else
-        [NSOpenGLContext clearCurrentContext];
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-
-    } // autoreleasepool
-}
-
-static void swapBuffersNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    // HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
-    //       windows with a non-visible occlusion state
-    if (window->ns.occluded)
-    {
-        int interval = 0;
-        [window->context.nsgl.object getValues:&interval
-                                  forParameter:NSOpenGLContextParameterSwapInterval];
-
-        if (interval > 0)
-        {
-            const double framerate = 60.0;
-            const uint64_t frequency = _glfwPlatformGetTimerFrequency();
-            const uint64_t value = _glfwPlatformGetTimerValue();
-
-            const double elapsed = value / (double) frequency;
-            const double period = 1.0 / framerate;
-            const double delay = period - fmod(elapsed, period);
-
-            usleep(floorl(delay * 1e6));
-        }
-    }
-
-    [window->context.nsgl.object flushBuffer];
-
-    } // autoreleasepool
-}
-
-static void swapIntervalNSGL(int interval)
-{
-    @autoreleasepool {
-
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (window)
-    {
-        [window->context.nsgl.object setValues:&interval
-                                  forParameter:NSOpenGLContextParameterSwapInterval];
-    }
-
-    } // autoreleasepool
-}
-
-static int extensionSupportedNSGL(const char* extension)
-{
-    // There are no NSGL extensions
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressNSGL(const char* procname)
-{
-    CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
-                                                       procname,
-                                                       kCFStringEncodingASCII);
-
-    GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
-                                                          symbolName);
-
-    CFRelease(symbolName);
-
-    return symbol;
-}
-
-static void destroyContextNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    [window->context.nsgl.pixelFormat release];
-    window->context.nsgl.pixelFormat = nil;
-
-    [window->context.nsgl.object release];
-    window->context.nsgl.object = nil;
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize OpenGL support
-//
-GLFWbool _glfwInitNSGL(void)
-{
-    if (_glfw.nsgl.framework)
-        return GLFW_TRUE;
-
-    _glfw.nsgl.framework =
-        CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
-    if (_glfw.nsgl.framework == NULL)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "NSGL: Failed to locate OpenGL framework");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Terminate OpenGL support
-//
-void _glfwTerminateNSGL(void)
-{
-}
-
-// Create the OpenGL context
-//
-GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
-                                const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* fbconfig)
-{
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "NSGL: OpenGL ES is not available on macOS");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->major > 2)
-    {
-        if (ctxconfig->major == 3 && ctxconfig->minor < 2)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
-            return GLFW_FALSE;
-        }
-    }
-
-    // Context robustness modes (GL_KHR_robustness) are not yet supported by
-    // macOS but are not a hard constraint, so ignore and continue
-
-    // Context release behaviors (GL_KHR_context_flush_control) are not yet
-    // supported by macOS but are not a hard constraint, so ignore and continue
-
-    // Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
-    // a hard constraint, so ignore and continue
-
-    // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
-    // are not a hard constraint, so ignore and continue
-
-#define addAttrib(a) \
-{ \
-    assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-}
-#define setAttrib(a, v) { addAttrib(a); addAttrib(v); }
-
-    NSOpenGLPixelFormatAttribute attribs[40];
-    int index = 0;
-
-    addAttrib(NSOpenGLPFAAccelerated);
-    addAttrib(NSOpenGLPFAClosestPolicy);
-
-    if (ctxconfig->nsgl.offline)
-    {
-        addAttrib(NSOpenGLPFAAllowOfflineRenderers);
-        // NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
-        //       Info.plist for unbundled applications
-        // HACK: This assumes that NSOpenGLPixelFormat will remain
-        //       a straightforward wrapper of its CGL counterpart
-        addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching);
-    }
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
-    if (ctxconfig->major >= 4)
-    {
-        setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
-    }
-    else
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
-    if (ctxconfig->major >= 3)
-    {
-        setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
-    }
-
-    if (ctxconfig->major <= 2)
-    {
-        if (fbconfig->auxBuffers != GLFW_DONT_CARE)
-            setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
-
-        if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
-            fbconfig->accumGreenBits != GLFW_DONT_CARE &&
-            fbconfig->accumBlueBits != GLFW_DONT_CARE &&
-            fbconfig->accumAlphaBits != GLFW_DONT_CARE)
-        {
-            const int accumBits = fbconfig->accumRedBits +
-                                  fbconfig->accumGreenBits +
-                                  fbconfig->accumBlueBits +
-                                  fbconfig->accumAlphaBits;
-
-            setAttrib(NSOpenGLPFAAccumSize, accumBits);
-        }
-    }
-
-    if (fbconfig->redBits != GLFW_DONT_CARE &&
-        fbconfig->greenBits != GLFW_DONT_CARE &&
-        fbconfig->blueBits != GLFW_DONT_CARE)
-    {
-        int colorBits = fbconfig->redBits +
-                        fbconfig->greenBits +
-                        fbconfig->blueBits;
-
-        // macOS needs non-zero color size, so set reasonable values
-        if (colorBits == 0)
-            colorBits = 24;
-        else if (colorBits < 15)
-            colorBits = 15;
-
-        setAttrib(NSOpenGLPFAColorSize, colorBits);
-    }
-
-    if (fbconfig->alphaBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
-
-    if (fbconfig->depthBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits);
-
-    if (fbconfig->stencilBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
-
-    if (fbconfig->stereo)
-    {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "NSGL: Stereo rendering is deprecated");
-        return GLFW_FALSE;
-#else
-        addAttrib(NSOpenGLPFAStereo);
-#endif
-    }
-
-    if (fbconfig->doublebuffer)
-        addAttrib(NSOpenGLPFADoubleBuffer);
-
-    if (fbconfig->samples != GLFW_DONT_CARE)
-    {
-        if (fbconfig->samples == 0)
-        {
-            setAttrib(NSOpenGLPFASampleBuffers, 0);
-        }
-        else
-        {
-            setAttrib(NSOpenGLPFASampleBuffers, 1);
-            setAttrib(NSOpenGLPFASamples, fbconfig->samples);
-        }
-    }
-
-    // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
-    //       framebuffer, so there's no need (and no way) to request it
-
-    addAttrib(0);
-
-#undef addAttrib
-#undef setAttrib
-
-    window->context.nsgl.pixelFormat =
-        [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
-    if (window->context.nsgl.pixelFormat == nil)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "NSGL: Failed to find a suitable pixel format");
-        return GLFW_FALSE;
-    }
-
-    NSOpenGLContext* share = nil;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.nsgl.object;
-
-    window->context.nsgl.object =
-        [[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
-                                   shareContext:share];
-    if (window->context.nsgl.object == nil)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "NSGL: Failed to create OpenGL context");
-        return GLFW_FALSE;
-    }
-
-    if (fbconfig->transparent)
-    {
-        GLint opaque = 0;
-        [window->context.nsgl.object setValues:&opaque
-                                  forParameter:NSOpenGLContextParameterSurfaceOpacity];
-    }
-
-    [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
-
-    [window->context.nsgl.object setView:window->ns.view];
-
-    window->context.makeCurrent = makeContextCurrentNSGL;
-    window->context.swapBuffers = swapBuffersNSGL;
-    window->context.swapInterval = swapIntervalNSGL;
-    window->context.extensionSupported = extensionSupportedNSGL;
-    window->context.getProcAddress = getProcAddressNSGL;
-    window->context.destroy = destroyContextNSGL;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(nil);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return nil;
-    }
-
-    return window->context.nsgl.object;
-}
-
diff --git a/raylib/external/glfw/src/null_init.c b/raylib/external/glfw/src/null_init.c
deleted file mode 100644 (file)
index 57aafd5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    _glfwInitTimerPOSIX();
-    _glfwPollMonitorsNull();
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    free(_glfw.null.clipboardString);
-    _glfwTerminateOSMesa();
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " null OSMesa";
-}
-
diff --git a/raylib/external/glfw/src/null_joystick.c b/raylib/external/glfw/src/null_joystick.c
deleted file mode 100644 (file)
index 27756a6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-}
-
diff --git a/raylib/external/glfw/src/null_joystick.h b/raylib/external/glfw/src/null_joystick.h
deleted file mode 100644 (file)
index 5d19a45..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         struct { int dummyJoystick; }
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME ""
-
diff --git a/raylib/external/glfw/src/null_monitor.c b/raylib/external/glfw/src/null_monitor.c
deleted file mode 100644 (file)
index 8301eb3..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-// The the sole (fake) video mode of our (sole) fake monitor
-//
-static GLFWvidmode getVideoMode(void)
-{
-    GLFWvidmode mode;
-    mode.width = 1920;
-    mode.height = 1080;
-    mode.redBits = 8;
-    mode.greenBits = 8;
-    mode.blueBits = 8;
-    mode.refreshRate = 60;
-    return mode;
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPollMonitorsNull(void)
-{
-    const float dpi = 141.f;
-    const GLFWvidmode mode = getVideoMode();
-    _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
-                                              (int) (mode.width * 25.4f / dpi),
-                                              (int) (mode.height * 25.4f / dpi));
-    _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-    _glfwFreeGammaArrays(&monitor->null.ramp);
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = 1.f;
-    if (yscale)
-        *yscale = 1.f;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    const GLFWvidmode mode = getVideoMode();
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 10;
-    if (width)
-        *width = mode.width;
-    if (height)
-        *height = mode.height - 10;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
-{
-    GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode));
-    *mode = getVideoMode();
-    *found = 1;
-    return mode;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    *mode = getVideoMode();
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    if (!monitor->null.ramp.size)
-    {
-        _glfwAllocGammaArrays(&monitor->null.ramp, 256);
-
-        for (unsigned int i = 0;  i < monitor->null.ramp.size;  i++)
-        {
-            const float gamma = 2.2f;
-            float value;
-            value = i / (float) (monitor->null.ramp.size - 1);
-            value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
-            value = _glfw_fminf(value, 65535.f);
-
-            monitor->null.ramp.red[i]   = (unsigned short) value;
-            monitor->null.ramp.green[i] = (unsigned short) value;
-            monitor->null.ramp.blue[i]  = (unsigned short) value;
-        }
-    }
-
-    _glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
-    memcpy(ramp->red,   monitor->null.ramp.red,   sizeof(short) * ramp->size);
-    memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
-    memcpy(ramp->blue,  monitor->null.ramp.blue,  sizeof(short) * ramp->size);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    if (monitor->null.ramp.size != ramp->size)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Null: Gamma ramp size must match current ramp size");
-        return;
-    }
-
-    memcpy(monitor->null.ramp.red,   ramp->red,   sizeof(short) * ramp->size);
-    memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
-    memcpy(monitor->null.ramp.blue,  ramp->blue,  sizeof(short) * ramp->size);
-}
-
diff --git a/raylib/external/glfw/src/null_platform.h b/raylib/external/glfw/src/null_platform.h
deleted file mode 100644 (file)
index 49436dc..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <dlfcn.h>
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowNull null
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorNull null
-
-#define _GLFW_PLATFORM_CONTEXT_STATE         struct { int dummyContext; }
-#define _GLFW_PLATFORM_CURSOR_STATE          struct { int dummyCursor; }
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
-
-#include "posix_time.h"
-#include "posix_thread.h"
-#include "null_joystick.h"
-
-#if defined(_GLFW_WIN32)
- #define _glfw_dlopen(name) LoadLibraryA(name)
- #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
- #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
-#else
- #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
- #define _glfw_dlclose(handle) dlclose(handle)
- #define _glfw_dlsym(handle, name) dlsym(handle, name)
-#endif
-
-// Null-specific per-window data
-//
-typedef struct _GLFWwindowNull
-{
-    int             xpos;
-    int             ypos;
-    int             width;
-    int             height;
-    char*           title;
-    GLFWbool        visible;
-    GLFWbool        iconified;
-    GLFWbool        maximized;
-    GLFWbool        resizable;
-    GLFWbool        decorated;
-    GLFWbool        floating;
-    GLFWbool        transparent;
-    float           opacity;
-} _GLFWwindowNull;
-
-// Null-specific per-monitor data
-//
-typedef struct _GLFWmonitorNull
-{
-    GLFWgammaramp   ramp;
-} _GLFWmonitorNull;
-
-// Null-specific global data
-//
-typedef struct _GLFWlibraryNull
-{
-    int             xcursor;
-    int             ycursor;
-    char*           clipboardString;
-    _GLFWwindow*    focusedWindow;
-} _GLFWlibraryNull;
-
-void _glfwPollMonitorsNull(void);
-
diff --git a/raylib/external/glfw/src/null_window.c b/raylib/external/glfw/src/null_window.c
deleted file mode 100644 (file)
index 3e44664..0000000
+++ /dev/null
@@ -1,670 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-
-static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
-{
-    if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
-    {
-        const float ratio = (float) window->numer / (float) window->denom;
-        *height = (int) (*width / ratio);
-    }
-
-    if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth)
-        *width = window->minwidth;
-    else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth)
-        *width = window->maxwidth;
-
-    if (window->minheight != GLFW_DONT_CARE && *height < window->minheight)
-        *height = window->minheight;
-    else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
-        *height = window->maxheight;
-}
-
-static void fitToMonitor(_GLFWwindow* window)
-{
-    GLFWvidmode mode;
-    _glfwPlatformGetVideoMode(window->monitor, &mode);
-    _glfwPlatformGetMonitorPos(window->monitor,
-                               &window->null.xpos,
-                               &window->null.ypos);
-    window->null.width = mode.width;
-    window->null.height = mode.height;
-}
-
-static void acquireMonitor(_GLFWwindow* window)
-{
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-}
-
-static int createNativeWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (window->monitor)
-        fitToMonitor(window);
-    else
-    {
-        window->null.xpos = 17;
-        window->null.ypos = 17;
-        window->null.width = wndconfig->width;
-        window->null.height = wndconfig->height;
-    }
-
-    window->null.visible = wndconfig->visible;
-    window->null.decorated = wndconfig->decorated;
-    window->null.maximized = wndconfig->maximized;
-    window->null.floating = wndconfig->floating;
-    window->null.transparent = fbconfig->transparent;
-    window->null.opacity = 1.f;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
-            ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (_glfw.null.focusedWindow == window)
-        _glfw.null.focusedWindow = NULL;
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
-                                const GLFWimage* images)
-{
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (!monitor)
-        {
-            _glfwPlatformSetWindowPos(window, xpos, ypos);
-            _glfwPlatformSetWindowSize(window, width, height);
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    if (window->monitor)
-    {
-        window->null.visible = GLFW_TRUE;
-        acquireMonitor(window);
-        fitToMonitor(window);
-    }
-    else
-    {
-        _glfwPlatformSetWindowPos(window, xpos, ypos);
-        _glfwPlatformSetWindowSize(window, width, height);
-    }
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = window->null.xpos;
-    if (ypos)
-        *ypos = window->null.ypos;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    if (window->monitor)
-        return;
-
-    if (window->null.xpos != xpos || window->null.ypos != ypos)
-    {
-        window->null.xpos = xpos;
-        window->null.ypos = ypos;
-        _glfwInputWindowPos(window, xpos, ypos);
-    }
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->null.width;
-    if (height)
-        *height = window->null.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-        return;
-
-    if (window->null.width != width || window->null.height != height)
-    {
-        window->null.width = width;
-        window->null.height = height;
-        _glfwInputWindowSize(window, width, height);
-        _glfwInputFramebufferSize(window, width, height);
-    }
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    int width = window->null.width;
-    int height = window->null.height;
-    applySizeLimits(window, &width, &height);
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
-{
-    int width = window->null.width;
-    int height = window->null.height;
-    applySizeLimits(window, &width, &height);
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->null.width;
-    if (height)
-        *height = window->null.height;
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    if (window->null.decorated && !window->monitor)
-    {
-        if (left)
-            *left = 1;
-        if (top)
-            *top = 10;
-        if (right)
-            *right = 1;
-        if (bottom)
-            *bottom = 1;
-    }
-    else
-    {
-        if (left)
-            *left = 0;
-        if (top)
-            *top = 0;
-        if (right)
-            *right = 0;
-        if (bottom)
-            *bottom = 0;
-    }
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = 1.f;
-    if (yscale)
-        *yscale = 1.f;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-    {
-        _glfw.null.focusedWindow = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    if (!window->null.iconified)
-    {
-        window->null.iconified = GLFW_TRUE;
-        _glfwInputWindowIconify(window, GLFW_TRUE);
-
-        if (window->monitor)
-            releaseMonitor(window);
-    }
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->null.iconified)
-    {
-        window->null.iconified = GLFW_FALSE;
-        _glfwInputWindowIconify(window, GLFW_FALSE);
-
-        if (window->monitor)
-            acquireMonitor(window);
-    }
-    else if (window->null.maximized)
-    {
-        window->null.maximized = GLFW_FALSE;
-        _glfwInputWindowMaximize(window, GLFW_FALSE);
-    }
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (!window->null.maximized)
-    {
-        window->null.maximized = GLFW_TRUE;
-        _glfwInputWindowMaximize(window, GLFW_TRUE);
-    }
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return window->null.maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return _glfw.null.xcursor >= window->null.xpos &&
-           _glfw.null.ycursor >= window->null.ypos &&
-           _glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
-           _glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    return window->null.transparent;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.resizable = enabled;
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.decorated = enabled;
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.floating = enabled;
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    return window->null.opacity;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    window->null.opacity = opacity;
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    window->null.visible = GLFW_TRUE;
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-    {
-        _glfw.null.focusedWindow = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    window->null.visible = GLFW_FALSE;
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-        return;
-
-    if (!window->null.visible)
-        return;
-
-    _GLFWwindow* previous = _glfw.null.focusedWindow;
-    _glfw.null.focusedWindow = window;
-
-    if (previous)
-    {
-        _glfwInputWindowFocus(previous, GLFW_FALSE);
-        if (previous->monitor && previous->autoIconify)
-            _glfwPlatformIconifyWindow(previous);
-    }
-
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return _glfw.null.focusedWindow == window;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return window->null.iconified;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return window->null.visible;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    if (xpos)
-        *xpos = _glfw.null.xcursor - window->null.xpos;
-    if (ypos)
-        *ypos = _glfw.null.ycursor - window->null.ypos;
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    _glfw.null.xcursor = window->null.xpos + (int) x;
-    _glfw.null.ycursor = window->null.ypos + (int) y;
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    char* copy = _glfw_strdup(string);
-    free(_glfw.null.clipboardString);
-    _glfw.null.clipboardString = copy;
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    return _glfw.null.clipboardString;
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    switch (scancode)
-    {
-        case GLFW_KEY_APOSTROPHE:
-            return "'";
-        case GLFW_KEY_COMMA:
-            return ",";
-        case GLFW_KEY_MINUS:
-        case GLFW_KEY_KP_SUBTRACT:
-            return "-";
-        case GLFW_KEY_PERIOD:
-        case GLFW_KEY_KP_DECIMAL:
-            return ".";
-        case GLFW_KEY_SLASH:
-        case GLFW_KEY_KP_DIVIDE:
-            return "/";
-        case GLFW_KEY_SEMICOLON:
-            return ";";
-        case GLFW_KEY_EQUAL:
-        case GLFW_KEY_KP_EQUAL:
-            return "=";
-        case GLFW_KEY_LEFT_BRACKET:
-            return "[";
-        case GLFW_KEY_RIGHT_BRACKET:
-            return "]";
-        case GLFW_KEY_KP_MULTIPLY:
-            return "*";
-        case GLFW_KEY_KP_ADD:
-            return "+";
-        case GLFW_KEY_BACKSLASH:
-        case GLFW_KEY_WORLD_1:
-        case GLFW_KEY_WORLD_2:
-            return "\\";
-        case GLFW_KEY_0:
-        case GLFW_KEY_KP_0:
-            return "0";
-        case GLFW_KEY_1:
-        case GLFW_KEY_KP_1:
-            return "1";
-        case GLFW_KEY_2:
-        case GLFW_KEY_KP_2:
-            return "2";
-        case GLFW_KEY_3:
-        case GLFW_KEY_KP_3:
-            return "3";
-        case GLFW_KEY_4:
-        case GLFW_KEY_KP_4:
-            return "4";
-        case GLFW_KEY_5:
-        case GLFW_KEY_KP_5:
-            return "5";
-        case GLFW_KEY_6:
-        case GLFW_KEY_KP_6:
-            return "6";
-        case GLFW_KEY_7:
-        case GLFW_KEY_KP_7:
-            return "7";
-        case GLFW_KEY_8:
-        case GLFW_KEY_KP_8:
-            return "8";
-        case GLFW_KEY_9:
-        case GLFW_KEY_KP_9:
-            return "9";
-        case GLFW_KEY_A:
-            return "a";
-        case GLFW_KEY_B:
-            return "b";
-        case GLFW_KEY_C:
-            return "c";
-        case GLFW_KEY_D:
-            return "d";
-        case GLFW_KEY_E:
-            return "e";
-        case GLFW_KEY_F:
-            return "f";
-        case GLFW_KEY_G:
-            return "g";
-        case GLFW_KEY_H:
-            return "h";
-        case GLFW_KEY_I:
-            return "i";
-        case GLFW_KEY_J:
-            return "j";
-        case GLFW_KEY_K:
-            return "k";
-        case GLFW_KEY_L:
-            return "l";
-        case GLFW_KEY_M:
-            return "m";
-        case GLFW_KEY_N:
-            return "n";
-        case GLFW_KEY_O:
-            return "o";
-        case GLFW_KEY_P:
-            return "p";
-        case GLFW_KEY_Q:
-            return "q";
-        case GLFW_KEY_R:
-            return "r";
-        case GLFW_KEY_S:
-            return "s";
-        case GLFW_KEY_T:
-            return "t";
-        case GLFW_KEY_U:
-            return "u";
-        case GLFW_KEY_V:
-            return "v";
-        case GLFW_KEY_W:
-            return "w";
-        case GLFW_KEY_X:
-            return "x";
-        case GLFW_KEY_Y:
-            return "y";
-        case GLFW_KEY_Z:
-            return "z";
-    }
-
-    return NULL;
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return key;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    return GLFW_FALSE;
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    // This seems like the most appropriate error to return here
-    return VK_ERROR_EXTENSION_NOT_PRESENT;
-}
-
diff --git a/raylib/external/glfw/src/osmesa_context.c b/raylib/external/glfw/src/osmesa_context.c
deleted file mode 100644 (file)
index 70e8675..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-//========================================================================
-// GLFW 3.4 OSMesa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "internal.h"
-
-
-static void makeContextCurrentOSMesa(_GLFWwindow* window)
-{
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetFramebufferSize(window, &width, &height);
-
-        // Check to see if we need to allocate a new buffer
-        if ((window->context.osmesa.buffer == NULL) ||
-            (width != window->context.osmesa.width) ||
-            (height != window->context.osmesa.height))
-        {
-            free(window->context.osmesa.buffer);
-
-            // Allocate the new buffer (width * height * 8-bit RGBA)
-            window->context.osmesa.buffer = calloc(4, (size_t) width * height);
-            window->context.osmesa.width  = width;
-            window->context.osmesa.height = height;
-        }
-
-        if (!OSMesaMakeCurrent(window->context.osmesa.handle,
-                               window->context.osmesa.buffer,
-                               GL_UNSIGNED_BYTE,
-                               width, height))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OSMesa: Failed to make context current");
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static GLFWglproc getProcAddressOSMesa(const char* procname)
-{
-    return (GLFWglproc) OSMesaGetProcAddress(procname);
-}
-
-static void destroyContextOSMesa(_GLFWwindow* window)
-{
-    if (window->context.osmesa.handle)
-    {
-        OSMesaDestroyContext(window->context.osmesa.handle);
-        window->context.osmesa.handle = NULL;
-    }
-
-    if (window->context.osmesa.buffer)
-    {
-        free(window->context.osmesa.buffer);
-        window->context.osmesa.width = 0;
-        window->context.osmesa.height = 0;
-    }
-}
-
-static void swapBuffersOSMesa(_GLFWwindow* window)
-{
-    // No double buffering on OSMesa
-}
-
-static void swapIntervalOSMesa(int interval)
-{
-    // No swap interval on OSMesa
-}
-
-static int extensionSupportedOSMesa(const char* extension)
-{
-    // OSMesa does not have extensions
-    return GLFW_FALSE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwInitOSMesa(void)
-{
-    int i;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_OSMESA_LIBRARY)
-        _GLFW_OSMESA_LIBRARY,
-#elif defined(_WIN32)
-        "libOSMesa.dll",
-        "OSMesa.dll",
-#elif defined(__APPLE__)
-        "libOSMesa.8.dylib",
-#elif defined(__CYGWIN__)
-        "libOSMesa-8.so",
-#else
-        "libOSMesa.so.8",
-        "libOSMesa.so.6",
-#endif
-        NULL
-    };
-
-    if (_glfw.osmesa.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.osmesa.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.osmesa.handle)
-            break;
-    }
-
-    if (!_glfw.osmesa.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
-        return GLFW_FALSE;
-    }
-
-    _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt");
-    _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
-    _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
-    _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
-    _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
-    _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
-    _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
-
-    if (!_glfw.osmesa.CreateContextExt ||
-        !_glfw.osmesa.DestroyContext ||
-        !_glfw.osmesa.MakeCurrent ||
-        !_glfw.osmesa.GetColorBuffer ||
-        !_glfw.osmesa.GetDepthBuffer ||
-        !_glfw.osmesa.GetProcAddress)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to load required entry points");
-
-        _glfwTerminateOSMesa();
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwTerminateOSMesa(void)
-{
-    if (_glfw.osmesa.handle)
-    {
-        _glfw_dlclose(_glfw.osmesa.handle);
-        _glfw.osmesa.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
-                                  const _GLFWctxconfig* ctxconfig,
-                                  const _GLFWfbconfig* fbconfig)
-{
-    OSMesaContext share = NULL;
-    const int accumBits = fbconfig->accumRedBits +
-                          fbconfig->accumGreenBits +
-                          fbconfig->accumBlueBits +
-                          fbconfig->accumAlphaBits;
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "OSMesa: OpenGL ES is not available on OSMesa");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.osmesa.handle;
-
-    if (OSMesaCreateContextAttribs)
-    {
-        int index = 0, attribs[40];
-
-        setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
-        setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
-        setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
-        setAttrib(OSMESA_ACCUM_BITS, accumBits);
-
-        if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-        {
-            setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
-        }
-        else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-        {
-            setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
-        }
-
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
-            setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
-        }
-
-        if (ctxconfig->forward)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "OSMesa: Forward-compatible contexts not supported");
-            return GLFW_FALSE;
-        }
-
-        setAttrib(0, 0);
-
-        window->context.osmesa.handle =
-            OSMesaCreateContextAttribs(attribs, share);
-    }
-    else
-    {
-        if (ctxconfig->profile)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "OSMesa: OpenGL profiles unavailable");
-            return GLFW_FALSE;
-        }
-
-        window->context.osmesa.handle =
-            OSMesaCreateContextExt(OSMESA_RGBA,
-                                   fbconfig->depthBits,
-                                   fbconfig->stencilBits,
-                                   accumBits,
-                                   share);
-    }
-
-    if (window->context.osmesa.handle == NULL)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "OSMesa: Failed to create context");
-        return GLFW_FALSE;
-    }
-
-    window->context.makeCurrent = makeContextCurrentOSMesa;
-    window->context.swapBuffers = swapBuffersOSMesa;
-    window->context.swapInterval = swapIntervalOSMesa;
-    window->context.extensionSupported = extensionSupportedOSMesa;
-    window->context.getProcAddress = getProcAddressOSMesa;
-    window->context.destroy = destroyContextOSMesa;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
-                                     int* height, int* format, void** buffer)
-{
-    void* mesaBuffer;
-    GLint mesaWidth, mesaHeight, mesaFormat;
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
-                              &mesaWidth, &mesaHeight,
-                              &mesaFormat, &mesaBuffer))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to retrieve color buffer");
-        return GLFW_FALSE;
-    }
-
-    if (width)
-        *width = mesaWidth;
-    if (height)
-        *height = mesaHeight;
-    if (format)
-        *format = mesaFormat;
-    if (buffer)
-        *buffer = mesaBuffer;
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
-                                     int* width, int* height,
-                                     int* bytesPerValue,
-                                     void** buffer)
-{
-    void* mesaBuffer;
-    GLint mesaWidth, mesaHeight, mesaBytes;
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
-                              &mesaWidth, &mesaHeight,
-                              &mesaBytes, &mesaBuffer))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to retrieve depth buffer");
-        return GLFW_FALSE;
-    }
-
-    if (width)
-        *width = mesaWidth;
-    if (height)
-        *height = mesaHeight;
-    if (bytesPerValue)
-        *bytesPerValue = mesaBytes;
-    if (buffer)
-        *buffer = mesaBuffer;
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.osmesa.handle;
-}
-
diff --git a/raylib/external/glfw/src/osmesa_context.h b/raylib/external/glfw/src/osmesa_context.h
deleted file mode 100644 (file)
index ce1f1a2..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//========================================================================
-// GLFW 3.4 OSMesa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define OSMESA_RGBA 0x1908
-#define OSMESA_FORMAT 0x22
-#define OSMESA_DEPTH_BITS 0x30
-#define OSMESA_STENCIL_BITS 0x31
-#define OSMESA_ACCUM_BITS 0x32
-#define OSMESA_PROFILE 0x33
-#define OSMESA_CORE_PROFILE 0x34
-#define OSMESA_COMPAT_PROFILE 0x35
-#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
-#define OSMESA_CONTEXT_MINOR_VERSION 0x37
-
-typedef void* OSMesaContext;
-typedef void (*OSMESAproc)(void);
-
-typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
-typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
-typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
-typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
-typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
-typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
-typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
-#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
-#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
-#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
-#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
-#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
-#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
-#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
-
-// OSMesa-specific per-context data
-//
-typedef struct _GLFWcontextOSMesa
-{
-    OSMesaContext       handle;
-    int                 width;
-    int                 height;
-    void*               buffer;
-
-} _GLFWcontextOSMesa;
-
-// OSMesa-specific global data
-//
-typedef struct _GLFWlibraryOSMesa
-{
-    void*           handle;
-
-    PFN_OSMesaCreateContextExt      CreateContextExt;
-    PFN_OSMesaCreateContextAttribs  CreateContextAttribs;
-    PFN_OSMesaDestroyContext        DestroyContext;
-    PFN_OSMesaMakeCurrent           MakeCurrent;
-    PFN_OSMesaGetColorBuffer        GetColorBuffer;
-    PFN_OSMesaGetDepthBuffer        GetDepthBuffer;
-    PFN_OSMesaGetProcAddress        GetProcAddress;
-
-} _GLFWlibraryOSMesa;
-
-
-GLFWbool _glfwInitOSMesa(void);
-void _glfwTerminateOSMesa(void);
-GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
-                                  const _GLFWctxconfig* ctxconfig,
-                                  const _GLFWfbconfig* fbconfig);
-
diff --git a/raylib/external/glfw/src/posix_thread.c b/raylib/external/glfw/src/posix_thread.c
deleted file mode 100644 (file)
index 0236145..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
-{
-    assert(tls->posix.allocated == GLFW_FALSE);
-
-    if (pthread_key_create(&tls->posix.key, NULL) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "POSIX: Failed to create context TLS");
-        return GLFW_FALSE;
-    }
-
-    tls->posix.allocated = GLFW_TRUE;
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyTls(_GLFWtls* tls)
-{
-    if (tls->posix.allocated)
-        pthread_key_delete(tls->posix.key);
-    memset(tls, 0, sizeof(_GLFWtls));
-}
-
-void* _glfwPlatformGetTls(_GLFWtls* tls)
-{
-    assert(tls->posix.allocated == GLFW_TRUE);
-    return pthread_getspecific(tls->posix.key);
-}
-
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
-{
-    assert(tls->posix.allocated == GLFW_TRUE);
-    pthread_setspecific(tls->posix.key, value);
-}
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_FALSE);
-
-    if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex");
-        return GLFW_FALSE;
-    }
-
-    return mutex->posix.allocated = GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
-{
-    if (mutex->posix.allocated)
-        pthread_mutex_destroy(&mutex->posix.handle);
-    memset(mutex, 0, sizeof(_GLFWmutex));
-}
-
-void _glfwPlatformLockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_TRUE);
-    pthread_mutex_lock(&mutex->posix.handle);
-}
-
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_TRUE);
-    pthread_mutex_unlock(&mutex->posix.handle);
-}
-
diff --git a/raylib/external/glfw/src/posix_thread.h b/raylib/external/glfw/src/posix_thread.h
deleted file mode 100644 (file)
index 85ce596..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <pthread.h>
-
-#define _GLFW_PLATFORM_TLS_STATE    _GLFWtlsPOSIX   posix
-#define _GLFW_PLATFORM_MUTEX_STATE  _GLFWmutexPOSIX posix
-
-
-// POSIX-specific thread local storage data
-//
-typedef struct _GLFWtlsPOSIX
-{
-    GLFWbool        allocated;
-    pthread_key_t   key;
-
-} _GLFWtlsPOSIX;
-
-// POSIX-specific mutex data
-//
-typedef struct _GLFWmutexPOSIX
-{
-    GLFWbool        allocated;
-    pthread_mutex_t handle;
-
-} _GLFWmutexPOSIX;
-
diff --git a/raylib/external/glfw/src/posix_time.c b/raylib/external/glfw/src/posix_time.c
deleted file mode 100644 (file)
index ae3d5c7..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _POSIX_C_SOURCE 199309L
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <time.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerPOSIX(void)
-{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-    struct timespec ts;
-
-    if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
-    {
-        _glfw.timer.posix.monotonic = GLFW_TRUE;
-        _glfw.timer.posix.frequency = 1000000000;
-    }
-    else
-#endif
-    {
-        _glfw.timer.posix.monotonic = GLFW_FALSE;
-        _glfw.timer.posix.frequency = 1000000;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-    if (_glfw.timer.posix.monotonic)
-    {
-        struct timespec ts;
-        clock_gettime(CLOCK_MONOTONIC, &ts);
-        return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
-    }
-    else
-#endif
-    {
-        struct timeval tv;
-        gettimeofday(&tv, NULL);
-        return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
-    }
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.posix.frequency;
-}
-
diff --git a/raylib/external/glfw/src/posix_time.h b/raylib/external/glfw/src/posix_time.h
deleted file mode 100644 (file)
index 9b59a18..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
-
-#include <stdint.h>
-
-
-// POSIX-specific global timer data
-//
-typedef struct _GLFWtimerPOSIX
-{
-    GLFWbool    monotonic;
-    uint64_t    frequency;
-
-} _GLFWtimerPOSIX;
-
-
-void _glfwInitTimerPOSIX(void);
-
diff --git a/raylib/external/glfw/src/vulkan.c b/raylib/external/glfw/src/vulkan.c
deleted file mode 100644 (file)
index b534052..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define _GLFW_FIND_LOADER    1
-#define _GLFW_REQUIRE_LOADER 2
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwInitVulkan(int mode)
-{
-    VkResult err;
-    VkExtensionProperties* ep;
-    uint32_t i, count;
-
-    if (_glfw.vk.available)
-        return GLFW_TRUE;
-
-#if !defined(_GLFW_VULKAN_STATIC)
-#if defined(_GLFW_VULKAN_LIBRARY)
-    _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY);
-#elif defined(_GLFW_WIN32)
-    _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
-#elif defined(_GLFW_COCOA)
-    _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
-    if (!_glfw.vk.handle)
-        _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
-#else
-    _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
-#endif
-    if (!_glfw.vk.handle)
-    {
-        if (mode == _GLFW_REQUIRE_LOADER)
-            _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
-
-        return GLFW_FALSE;
-    }
-
-    _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
-        _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
-    if (!_glfw.vk.GetInstanceProcAddr)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Loader does not export vkGetInstanceProcAddr");
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
-        vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
-    if (!_glfw.vk.EnumerateInstanceExtensionProperties)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-#endif // _GLFW_VULKAN_STATIC
-
-    err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
-    if (err)
-    {
-        // NOTE: This happens on systems with a loader but without any Vulkan ICD
-        if (mode == _GLFW_REQUIRE_LOADER)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Vulkan: Failed to query instance extension count: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    ep = calloc(count, sizeof(VkExtensionProperties));
-
-    err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
-    if (err)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Failed to query instance extensions: %s",
-                        _glfwGetVulkanResultString(err));
-
-        free(ep);
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  i < count;  i++)
-    {
-        if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
-            _glfw.vk.KHR_surface = GLFW_TRUE;
-#if defined(_GLFW_WIN32)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
-            _glfw.vk.KHR_win32_surface = GLFW_TRUE;
-#elif defined(_GLFW_COCOA)
-        else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
-            _glfw.vk.MVK_macos_surface = GLFW_TRUE;
-        else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
-            _glfw.vk.EXT_metal_surface = GLFW_TRUE;
-#elif defined(_GLFW_X11)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
-            _glfw.vk.KHR_xlib_surface = GLFW_TRUE;
-        else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
-            _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
-#elif defined(_GLFW_WAYLAND)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
-            _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
-#endif
-    }
-
-    free(ep);
-
-    _glfw.vk.available = GLFW_TRUE;
-
-    _glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
-
-    return GLFW_TRUE;
-}
-
-void _glfwTerminateVulkan(void)
-{
-#if !defined(_GLFW_VULKAN_STATIC)
-    if (_glfw.vk.handle)
-        _glfw_dlclose(_glfw.vk.handle);
-#endif
-}
-
-const char* _glfwGetVulkanResultString(VkResult result)
-{
-    switch (result)
-    {
-        case VK_SUCCESS:
-            return "Success";
-        case VK_NOT_READY:
-            return "A fence or query has not yet completed";
-        case VK_TIMEOUT:
-            return "A wait operation has not completed in the specified time";
-        case VK_EVENT_SET:
-            return "An event is signaled";
-        case VK_EVENT_RESET:
-            return "An event is unsignaled";
-        case VK_INCOMPLETE:
-            return "A return array was too small for the result";
-        case VK_ERROR_OUT_OF_HOST_MEMORY:
-            return "A host memory allocation has failed";
-        case VK_ERROR_OUT_OF_DEVICE_MEMORY:
-            return "A device memory allocation has failed";
-        case VK_ERROR_INITIALIZATION_FAILED:
-            return "Initialization of an object could not be completed for implementation-specific reasons";
-        case VK_ERROR_DEVICE_LOST:
-            return "The logical or physical device has been lost";
-        case VK_ERROR_MEMORY_MAP_FAILED:
-            return "Mapping of a memory object has failed";
-        case VK_ERROR_LAYER_NOT_PRESENT:
-            return "A requested layer is not present or could not be loaded";
-        case VK_ERROR_EXTENSION_NOT_PRESENT:
-            return "A requested extension is not supported";
-        case VK_ERROR_FEATURE_NOT_PRESENT:
-            return "A requested feature is not supported";
-        case VK_ERROR_INCOMPATIBLE_DRIVER:
-            return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
-        case VK_ERROR_TOO_MANY_OBJECTS:
-            return "Too many objects of the type have already been created";
-        case VK_ERROR_FORMAT_NOT_SUPPORTED:
-            return "A requested format is not supported on this device";
-        case VK_ERROR_SURFACE_LOST_KHR:
-            return "A surface is no longer available";
-        case VK_SUBOPTIMAL_KHR:
-            return "A swapchain no longer matches the surface properties exactly, but can still be used";
-        case VK_ERROR_OUT_OF_DATE_KHR:
-            return "A surface has changed in such a way that it is no longer compatible with the swapchain";
-        case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
-            return "The display used by a swapchain does not use the same presentable image layout";
-        case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
-            return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
-        case VK_ERROR_VALIDATION_FAILED_EXT:
-            return "A validation layer found an error";
-        default:
-            return "ERROR: UNKNOWN VULKAN ERROR";
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwVulkanSupported(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-    return _glfwInitVulkan(_GLFW_FIND_LOADER);
-}
-
-GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
-{
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return NULL;
-
-    if (!_glfw.vk.extensions[0])
-        return NULL;
-
-    *count = 2;
-    return (const char**) _glfw.vk.extensions;
-}
-
-GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
-                                              const char* procname)
-{
-    GLFWvkproc proc;
-    assert(procname != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return NULL;
-
-    proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
-#if defined(_GLFW_VULKAN_STATIC)
-    if (!proc)
-    {
-        if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
-            return (GLFWvkproc) vkGetInstanceProcAddr;
-    }
-#else
-    if (!proc)
-        proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
-#endif
-
-    return proc;
-}
-
-GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                     VkPhysicalDevice device,
-                                                     uint32_t queuefamily)
-{
-    assert(instance != VK_NULL_HANDLE);
-    assert(device != VK_NULL_HANDLE);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return GLFW_FALSE;
-
-    if (!_glfw.vk.extensions[0])
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Window surface creation extensions not found");
-        return GLFW_FALSE;
-    }
-
-    return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
-                                                             device,
-                                                             queuefamily);
-}
-
-GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
-                                         GLFWwindow* handle,
-                                         const VkAllocationCallbacks* allocator,
-                                         VkSurfaceKHR* surface)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(instance != VK_NULL_HANDLE);
-    assert(window != NULL);
-    assert(surface != NULL);
-
-    *surface = VK_NULL_HANDLE;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return VK_ERROR_INITIALIZATION_FAILED;
-
-    if (!_glfw.vk.extensions[0])
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Window surface creation extensions not found");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    if (window->context.client != GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
-        return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
-    }
-
-    return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
-}
-
diff --git a/raylib/external/glfw/src/wgl_context.c b/raylib/external/glfw/src/wgl_context.c
deleted file mode 100644 (file)
index 4f9a6ff..0000000
+++ /dev/null
@@ -1,796 +0,0 @@
-//========================================================================
-// GLFW 3.4 WGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <malloc.h>
-#include <assert.h>
-
-// Return the value corresponding to the specified attribute
-//
-static int findPixelFormatAttribValue(const int* attribs,
-                                      int attribCount,
-                                      const int* values,
-                                      int attrib)
-{
-    int i;
-
-    for (i = 0;  i < attribCount;  i++)
-    {
-        if (attribs[i] == attrib)
-            return values[i];
-    }
-
-    _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                         "WGL: Unknown pixel format attribute requested");
-    return 0;
-}
-
-#define addAttrib(a) \
-{ \
-    assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[attribCount++] = a; \
-}
-#define findAttribValue(a) \
-    findPixelFormatAttribValue(attribs, attribCount, values, a)
-
-// Return a list of available and usable framebuffer configs
-//
-static int choosePixelFormat(_GLFWwindow* window,
-                             const _GLFWctxconfig* ctxconfig,
-                             const _GLFWfbconfig* fbconfig)
-{
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, pixelFormat, nativeCount, usableCount = 0, attribCount = 0;
-    int attribs[40];
-    int values[sizeof(attribs) / sizeof(attribs[0])];
-
-    if (_glfw.wgl.ARB_pixel_format)
-    {
-        const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
-
-        if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
-                                          1, 0, 1, &attrib, &nativeCount))
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to retrieve pixel format attribute");
-            return 0;
-        }
-
-        addAttrib(WGL_SUPPORT_OPENGL_ARB);
-        addAttrib(WGL_DRAW_TO_WINDOW_ARB);
-        addAttrib(WGL_PIXEL_TYPE_ARB);
-        addAttrib(WGL_ACCELERATION_ARB);
-        addAttrib(WGL_RED_BITS_ARB);
-        addAttrib(WGL_RED_SHIFT_ARB);
-        addAttrib(WGL_GREEN_BITS_ARB);
-        addAttrib(WGL_GREEN_SHIFT_ARB);
-        addAttrib(WGL_BLUE_BITS_ARB);
-        addAttrib(WGL_BLUE_SHIFT_ARB);
-        addAttrib(WGL_ALPHA_BITS_ARB);
-        addAttrib(WGL_ALPHA_SHIFT_ARB);
-        addAttrib(WGL_DEPTH_BITS_ARB);
-        addAttrib(WGL_STENCIL_BITS_ARB);
-        addAttrib(WGL_ACCUM_BITS_ARB);
-        addAttrib(WGL_ACCUM_RED_BITS_ARB);
-        addAttrib(WGL_ACCUM_GREEN_BITS_ARB);
-        addAttrib(WGL_ACCUM_BLUE_BITS_ARB);
-        addAttrib(WGL_ACCUM_ALPHA_BITS_ARB);
-        addAttrib(WGL_AUX_BUFFERS_ARB);
-        addAttrib(WGL_STEREO_ARB);
-        addAttrib(WGL_DOUBLE_BUFFER_ARB);
-
-        if (_glfw.wgl.ARB_multisample)
-            addAttrib(WGL_SAMPLES_ARB);
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
-                addAttrib(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
-        }
-        else
-        {
-            if (_glfw.wgl.EXT_colorspace)
-                addAttrib(WGL_COLORSPACE_EXT);
-        }
-    }
-    else
-    {
-        nativeCount = DescribePixelFormat(window->context.wgl.dc,
-                                          1,
-                                          sizeof(PIXELFORMATDESCRIPTOR),
-                                          NULL);
-    }
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-        pixelFormat = i + 1;
-
-        if (_glfw.wgl.ARB_pixel_format)
-        {
-            // Get pixel format attributes through "modern" extension
-
-            if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
-                                              pixelFormat, 0,
-                                              attribCount,
-                                              attribs, values))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                    "WGL: Failed to retrieve pixel format attributes");
-
-                free(usableConfigs);
-                return 0;
-            }
-
-            if (!findAttribValue(WGL_SUPPORT_OPENGL_ARB) ||
-                !findAttribValue(WGL_DRAW_TO_WINDOW_ARB))
-            {
-                continue;
-            }
-
-            if (findAttribValue(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
-                continue;
-
-            if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
-                continue;
-
-            u->redBits = findAttribValue(WGL_RED_BITS_ARB);
-            u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
-            u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
-            u->alphaBits = findAttribValue(WGL_ALPHA_BITS_ARB);
-
-            u->depthBits = findAttribValue(WGL_DEPTH_BITS_ARB);
-            u->stencilBits = findAttribValue(WGL_STENCIL_BITS_ARB);
-
-            u->accumRedBits = findAttribValue(WGL_ACCUM_RED_BITS_ARB);
-            u->accumGreenBits = findAttribValue(WGL_ACCUM_GREEN_BITS_ARB);
-            u->accumBlueBits = findAttribValue(WGL_ACCUM_BLUE_BITS_ARB);
-            u->accumAlphaBits = findAttribValue(WGL_ACCUM_ALPHA_BITS_ARB);
-
-            u->auxBuffers = findAttribValue(WGL_AUX_BUFFERS_ARB);
-
-            if (findAttribValue(WGL_STEREO_ARB))
-                u->stereo = GLFW_TRUE;
-            if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
-                u->doublebuffer = GLFW_TRUE;
-
-            if (_glfw.wgl.ARB_multisample)
-                u->samples = findAttribValue(WGL_SAMPLES_ARB);
-
-            if (ctxconfig->client == GLFW_OPENGL_API)
-            {
-                if (_glfw.wgl.ARB_framebuffer_sRGB ||
-                    _glfw.wgl.EXT_framebuffer_sRGB)
-                {
-                    if (findAttribValue(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
-                        u->sRGB = GLFW_TRUE;
-                }
-            }
-            else
-            {
-                if (_glfw.wgl.EXT_colorspace)
-                {
-                    if (findAttribValue(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
-                        u->sRGB = GLFW_TRUE;
-                }
-            }
-        }
-        else
-        {
-            // Get pixel format attributes through legacy PFDs
-
-            PIXELFORMATDESCRIPTOR pfd;
-
-            if (!DescribePixelFormat(window->context.wgl.dc,
-                                     pixelFormat,
-                                     sizeof(PIXELFORMATDESCRIPTOR),
-                                     &pfd))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                    "WGL: Failed to describe pixel format");
-
-                free(usableConfigs);
-                return 0;
-            }
-
-            if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
-                !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
-            {
-                continue;
-            }
-
-            if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
-                (pfd.dwFlags & PFD_GENERIC_FORMAT))
-            {
-                continue;
-            }
-
-            if (pfd.iPixelType != PFD_TYPE_RGBA)
-                continue;
-
-            u->redBits = pfd.cRedBits;
-            u->greenBits = pfd.cGreenBits;
-            u->blueBits = pfd.cBlueBits;
-            u->alphaBits = pfd.cAlphaBits;
-
-            u->depthBits = pfd.cDepthBits;
-            u->stencilBits = pfd.cStencilBits;
-
-            u->accumRedBits = pfd.cAccumRedBits;
-            u->accumGreenBits = pfd.cAccumGreenBits;
-            u->accumBlueBits = pfd.cAccumBlueBits;
-            u->accumAlphaBits = pfd.cAccumAlphaBits;
-
-            u->auxBuffers = pfd.cAuxBuffers;
-
-            if (pfd.dwFlags & PFD_STEREO)
-                u->stereo = GLFW_TRUE;
-            if (pfd.dwFlags & PFD_DOUBLEBUFFER)
-                u->doublebuffer = GLFW_TRUE;
-        }
-
-        u->handle = pixelFormat;
-        usableCount++;
-    }
-
-    if (!usableCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "WGL: The driver does not appear to support OpenGL");
-
-        free(usableConfigs);
-        return 0;
-    }
-
-    closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
-    if (!closest)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "WGL: Failed to find a suitable pixel format");
-
-        free(usableConfigs);
-        return 0;
-    }
-
-    pixelFormat = (int) closest->handle;
-    free(usableConfigs);
-
-    return pixelFormat;
-}
-
-#undef addAttrib
-#undef findAttribValue
-
-static void makeContextCurrentWGL(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
-            _glfwPlatformSetTls(&_glfw.contextSlot, window);
-        else
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to make context current");
-            _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
-        }
-    }
-    else
-    {
-        if (!wglMakeCurrent(NULL, NULL))
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to clear current context");
-        }
-
-        _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
-    }
-}
-
-static void swapBuffersWGL(_GLFWwindow* window)
-{
-    if (!window->monitor)
-    {
-        if (IsWindowsVistaOrGreater())
-        {
-            // DWM Composition is always enabled on Win8+
-            BOOL enabled = IsWindows8OrGreater();
-
-            // HACK: Use DwmFlush when desktop composition is enabled
-            if (enabled ||
-                (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
-            {
-                int count = abs(window->context.wgl.interval);
-                while (count--)
-                    DwmFlush();
-            }
-        }
-    }
-
-    SwapBuffers(window->context.wgl.dc);
-}
-
-static void swapIntervalWGL(int interval)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    window->context.wgl.interval = interval;
-
-    if (!window->monitor)
-    {
-        if (IsWindowsVistaOrGreater())
-        {
-            // DWM Composition is always enabled on Win8+
-            BOOL enabled = IsWindows8OrGreater();
-
-            // HACK: Disable WGL swap interval when desktop composition is enabled to
-            //       avoid interfering with DWM vsync
-            if (enabled ||
-                (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
-                interval = 0;
-        }
-    }
-
-    if (_glfw.wgl.EXT_swap_control)
-        wglSwapIntervalEXT(interval);
-}
-
-static int extensionSupportedWGL(const char* extension)
-{
-    const char* extensions = NULL;
-
-    if (_glfw.wgl.GetExtensionsStringARB)
-        extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
-    else if (_glfw.wgl.GetExtensionsStringEXT)
-        extensions = wglGetExtensionsStringEXT();
-
-    if (!extensions)
-        return GLFW_FALSE;
-
-    return _glfwStringInExtensionString(extension, extensions);
-}
-
-static GLFWglproc getProcAddressWGL(const char* procname)
-{
-    const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
-    if (proc)
-        return proc;
-
-    return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
-}
-
-static void destroyContextWGL(_GLFWwindow* window)
-{
-    if (window->context.wgl.handle)
-    {
-        wglDeleteContext(window->context.wgl.handle);
-        window->context.wgl.handle = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize WGL
-//
-GLFWbool _glfwInitWGL(void)
-{
-    PIXELFORMATDESCRIPTOR pfd;
-    HGLRC prc, rc;
-    HDC pdc, dc;
-
-    if (_glfw.wgl.instance)
-        return GLFW_TRUE;
-
-    _glfw.wgl.instance = LoadLibraryA("opengl32.dll");
-    if (!_glfw.wgl.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to load opengl32.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wgl.CreateContext = (PFN_wglCreateContext)
-        GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
-    _glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
-        GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
-    _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
-        GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
-    _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
-        GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
-    _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
-        GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
-    _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
-        GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
-    _glfw.wgl.ShareLists = (PFN_wglShareLists)
-        GetProcAddress(_glfw.wgl.instance, "wglShareLists");
-
-    // NOTE: A dummy context has to be created for opengl32.dll to load the
-    //       OpenGL ICD, from which we can then query WGL extensions
-    // NOTE: This code will accept the Microsoft GDI ICD; accelerated context
-    //       creation failure occurs during manual pixel format enumeration
-
-    dc = GetDC(_glfw.win32.helperWindowHandle);
-
-    ZeroMemory(&pfd, sizeof(pfd));
-    pfd.nSize = sizeof(pfd);
-    pfd.nVersion = 1;
-    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
-    pfd.iPixelType = PFD_TYPE_RGBA;
-    pfd.cColorBits = 24;
-
-    if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to set pixel format for dummy context");
-        return GLFW_FALSE;
-    }
-
-    rc = wglCreateContext(dc);
-    if (!rc)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to create dummy context");
-        return GLFW_FALSE;
-    }
-
-    pdc = wglGetCurrentDC();
-    prc = wglGetCurrentContext();
-
-    if (!wglMakeCurrent(dc, rc))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to make dummy context current");
-        wglMakeCurrent(pdc, prc);
-        wglDeleteContext(rc);
-        return GLFW_FALSE;
-    }
-
-    // NOTE: Functions must be loaded first as they're needed to retrieve the
-    //       extension string that tells us whether the functions are supported
-    _glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
-        wglGetProcAddress("wglGetExtensionsStringEXT");
-    _glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
-        wglGetProcAddress("wglGetExtensionsStringARB");
-    _glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
-        wglGetProcAddress("wglCreateContextAttribsARB");
-    _glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
-        wglGetProcAddress("wglSwapIntervalEXT");
-    _glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
-        wglGetProcAddress("wglGetPixelFormatAttribivARB");
-
-    // NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
-    //       checked below as we are already using them
-    _glfw.wgl.ARB_multisample =
-        extensionSupportedWGL("WGL_ARB_multisample");
-    _glfw.wgl.ARB_framebuffer_sRGB =
-        extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
-    _glfw.wgl.EXT_framebuffer_sRGB =
-        extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
-    _glfw.wgl.ARB_create_context =
-        extensionSupportedWGL("WGL_ARB_create_context");
-    _glfw.wgl.ARB_create_context_profile =
-        extensionSupportedWGL("WGL_ARB_create_context_profile");
-    _glfw.wgl.EXT_create_context_es2_profile =
-        extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
-    _glfw.wgl.ARB_create_context_robustness =
-        extensionSupportedWGL("WGL_ARB_create_context_robustness");
-    _glfw.wgl.ARB_create_context_no_error =
-        extensionSupportedWGL("WGL_ARB_create_context_no_error");
-    _glfw.wgl.EXT_swap_control =
-        extensionSupportedWGL("WGL_EXT_swap_control");
-    _glfw.wgl.EXT_colorspace =
-        extensionSupportedWGL("WGL_EXT_colorspace");
-    _glfw.wgl.ARB_pixel_format =
-        extensionSupportedWGL("WGL_ARB_pixel_format");
-    _glfw.wgl.ARB_context_flush_control =
-        extensionSupportedWGL("WGL_ARB_context_flush_control");
-
-    wglMakeCurrent(pdc, prc);
-    wglDeleteContext(rc);
-    return GLFW_TRUE;
-}
-
-// Terminate WGL
-//
-void _glfwTerminateWGL(void)
-{
-    if (_glfw.wgl.instance)
-        FreeLibrary(_glfw.wgl.instance);
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    int attribs[40];
-    int pixelFormat;
-    PIXELFORMATDESCRIPTOR pfd;
-    HGLRC share = NULL;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.wgl.handle;
-
-    window->context.wgl.dc = GetDC(window->win32.handle);
-    if (!window->context.wgl.dc)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "WGL: Failed to retrieve DC for window");
-        return GLFW_FALSE;
-    }
-
-    pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig);
-    if (!pixelFormat)
-        return GLFW_FALSE;
-
-    if (!DescribePixelFormat(window->context.wgl.dc,
-                             pixelFormat, sizeof(pfd), &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to retrieve PFD for selected pixel format");
-        return GLFW_FALSE;
-    }
-
-    if (!SetPixelFormat(window->context.wgl.dc, pixelFormat, &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to set selected pixel format");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_API)
-    {
-        if (ctxconfig->forward)
-        {
-            if (!_glfw.wgl.ARB_create_context)
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
-                return GLFW_FALSE;
-            }
-        }
-
-        if (ctxconfig->profile)
-        {
-            if (!_glfw.wgl.ARB_create_context_profile)
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
-                return GLFW_FALSE;
-            }
-        }
-    }
-    else
-    {
-        if (!_glfw.wgl.ARB_create_context ||
-            !_glfw.wgl.ARB_create_context_profile ||
-            !_glfw.wgl.EXT_create_context_es2_profile)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (_glfw.wgl.ARB_create_context)
-    {
-        int index = 0, mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-        }
-        else
-            mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
-
-        if (ctxconfig->debug)
-            flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
-
-        if (ctxconfig->robustness)
-        {
-            if (_glfw.wgl.ARB_create_context_robustness)
-            {
-                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-                {
-                    setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              WGL_NO_RESET_NOTIFICATION_ARB);
-                }
-                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                {
-                    setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              WGL_LOSE_CONTEXT_ON_RESET_ARB);
-                }
-
-                flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-            }
-        }
-
-        if (ctxconfig->release)
-        {
-            if (_glfw.wgl.ARB_context_flush_control)
-            {
-                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-                {
-                    setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
-                }
-                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-                {
-                    setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
-                }
-            }
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.wgl.ARB_create_context_no_error)
-                setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
-        }
-
-        // NOTE: Only request an explicitly versioned context when necessary, as
-        //       explicitly requesting version 1.0 does not always return the
-        //       highest version supported by the driver
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
-            setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
-        }
-
-        if (flags)
-            setAttrib(WGL_CONTEXT_FLAGS_ARB, flags);
-
-        if (mask)
-            setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
-
-        setAttrib(0, 0);
-
-        window->context.wgl.handle =
-            wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
-        if (!window->context.wgl.handle)
-        {
-            const DWORD error = GetLastError();
-
-            if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
-            {
-                if (ctxconfig->client == GLFW_OPENGL_API)
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Driver does not support OpenGL version %i.%i",
-                                    ctxconfig->major,
-                                    ctxconfig->minor);
-                }
-                else
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Driver does not support OpenGL ES version %i.%i",
-                                    ctxconfig->major,
-                                    ctxconfig->minor);
-                }
-            }
-            else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: Driver does not support the requested OpenGL profile");
-            }
-            else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "WGL: The share context is not compatible with the requested context");
-            }
-            else
-            {
-                if (ctxconfig->client == GLFW_OPENGL_API)
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Failed to create OpenGL context");
-                }
-                else
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Failed to create OpenGL ES context");
-                }
-            }
-
-            return GLFW_FALSE;
-        }
-    }
-    else
-    {
-        window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
-        if (!window->context.wgl.handle)
-        {
-            _glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
-                                 "WGL: Failed to create OpenGL context");
-            return GLFW_FALSE;
-        }
-
-        if (share)
-        {
-            if (!wglShareLists(share, window->context.wgl.handle))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                     "WGL: Failed to enable sharing with specified OpenGL context");
-                return GLFW_FALSE;
-            }
-        }
-    }
-
-    window->context.makeCurrent = makeContextCurrentWGL;
-    window->context.swapBuffers = swapBuffersWGL;
-    window->context.swapInterval = swapIntervalWGL;
-    window->context.extensionSupported = extensionSupportedWGL;
-    window->context.getProcAddress = getProcAddressWGL;
-    window->context.destroy = destroyContextWGL;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.wgl.handle;
-}
-
diff --git a/raylib/external/glfw/src/wgl_context.h b/raylib/external/glfw/src/wgl_context.h
deleted file mode 100644 (file)
index 2cf7e4e..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-//========================================================================
-// GLFW 3.4 WGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
-#define WGL_SUPPORT_OPENGL_ARB 0x2010
-#define WGL_DRAW_TO_WINDOW_ARB 0x2001
-#define WGL_PIXEL_TYPE_ARB 0x2013
-#define WGL_TYPE_RGBA_ARB 0x202b
-#define WGL_ACCELERATION_ARB 0x2003
-#define WGL_NO_ACCELERATION_ARB 0x2025
-#define WGL_RED_BITS_ARB 0x2015
-#define WGL_RED_SHIFT_ARB 0x2016
-#define WGL_GREEN_BITS_ARB 0x2017
-#define WGL_GREEN_SHIFT_ARB 0x2018
-#define WGL_BLUE_BITS_ARB 0x2019
-#define WGL_BLUE_SHIFT_ARB 0x201a
-#define WGL_ALPHA_BITS_ARB 0x201b
-#define WGL_ALPHA_SHIFT_ARB 0x201c
-#define WGL_ACCUM_BITS_ARB 0x201d
-#define WGL_ACCUM_RED_BITS_ARB 0x201e
-#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
-#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
-#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
-#define WGL_DEPTH_BITS_ARB 0x2022
-#define WGL_STENCIL_BITS_ARB 0x2023
-#define WGL_AUX_BUFFERS_ARB 0x2024
-#define WGL_STEREO_ARB 0x2012
-#define WGL_DOUBLE_BUFFER_ARB 0x2011
-#define WGL_SAMPLES_ARB 0x2042
-#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
-#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
-#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
-#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define WGL_CONTEXT_FLAGS_ARB 0x2094
-#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
-#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
-#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
-#define WGL_COLORSPACE_EXT 0x309d
-#define WGL_COLORSPACE_SRGB_EXT 0x3089
-
-#define ERROR_INVALID_VERSION_ARB 0x2095
-#define ERROR_INVALID_PROFILE_ARB 0x2096
-#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
-
-// WGL extension pointer typedefs
-typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
-typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
-typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
-typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
-#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
-#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
-#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
-#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
-#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
-
-// opengl32.dll function pointer typedefs
-typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
-typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
-typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
-typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
-typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
-typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
-typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
-#define wglCreateContext _glfw.wgl.CreateContext
-#define wglDeleteContext _glfw.wgl.DeleteContext
-#define wglGetProcAddress _glfw.wgl.GetProcAddress
-#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
-#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
-#define wglMakeCurrent _glfw.wgl.MakeCurrent
-#define wglShareLists _glfw.wgl.ShareLists
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextWGL wgl
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryWGL wgl
-
-
-// WGL-specific per-context data
-//
-typedef struct _GLFWcontextWGL
-{
-    HDC       dc;
-    HGLRC     handle;
-    int       interval;
-
-} _GLFWcontextWGL;
-
-// WGL-specific global data
-//
-typedef struct _GLFWlibraryWGL
-{
-    HINSTANCE                           instance;
-    PFN_wglCreateContext                CreateContext;
-    PFN_wglDeleteContext                DeleteContext;
-    PFN_wglGetProcAddress               GetProcAddress;
-    PFN_wglGetCurrentDC                 GetCurrentDC;
-    PFN_wglGetCurrentContext            GetCurrentContext;
-    PFN_wglMakeCurrent                  MakeCurrent;
-    PFN_wglShareLists                   ShareLists;
-
-    PFNWGLSWAPINTERVALEXTPROC           SwapIntervalEXT;
-    PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
-    PFNWGLGETEXTENSIONSSTRINGEXTPROC    GetExtensionsStringEXT;
-    PFNWGLGETEXTENSIONSSTRINGARBPROC    GetExtensionsStringARB;
-    PFNWGLCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;
-    GLFWbool                            EXT_swap_control;
-    GLFWbool                            EXT_colorspace;
-    GLFWbool                            ARB_multisample;
-    GLFWbool                            ARB_framebuffer_sRGB;
-    GLFWbool                            EXT_framebuffer_sRGB;
-    GLFWbool                            ARB_pixel_format;
-    GLFWbool                            ARB_create_context;
-    GLFWbool                            ARB_create_context_profile;
-    GLFWbool                            EXT_create_context_es2_profile;
-    GLFWbool                            ARB_create_context_robustness;
-    GLFWbool                            ARB_create_context_no_error;
-    GLFWbool                            ARB_context_flush_control;
-
-} _GLFWlibraryWGL;
-
-
-GLFWbool _glfwInitWGL(void);
-void _glfwTerminateWGL(void);
-GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-
diff --git a/raylib/external/glfw/src/win32_init.c b/raylib/external/glfw/src/win32_init.c
deleted file mode 100644 (file)
index f6995e5..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <malloc.h>
-
-static const GUID _glfw_GUID_DEVINTERFACE_HID =
-    {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
-
-#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID
-
-#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
-
-// Executables (but not DLLs) exporting this symbol with this value will be
-// automatically directed to the high-performance GPU on Nvidia Optimus systems
-// with up-to-date drivers
-//
-__declspec(dllexport) DWORD NvOptimusEnablement = 1;
-
-// Executables (but not DLLs) exporting this symbol with this value will be
-// automatically directed to the high-performance GPU on AMD PowerXpress systems
-// with up-to-date drivers
-//
-__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
-
-#endif // _GLFW_USE_HYBRID_HPG
-
-#if defined(_GLFW_BUILD_DLL)
-
-// GLFW DLL entry point
-//
-BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
-{
-    return TRUE;
-}
-
-#endif // _GLFW_BUILD_DLL
-
-// Load necessary libraries (DLLs)
-//
-static GLFWbool loadLibraries(void)
-{
-    _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
-    if (!_glfw.win32.winmm.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to load winmm.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.win32.winmm.GetTime = (PFN_timeGetTime)
-        GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
-
-    _glfw.win32.user32.instance = LoadLibraryA("user32.dll");
-    if (!_glfw.win32.user32.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to load user32.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
-        GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
-    _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
-        GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
-    _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
-        GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
-    _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
-        GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
-    _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
-        GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow");
-    _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
-        GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
-
-    _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
-    if (_glfw.win32.dinput8.instance)
-    {
-        _glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
-            GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create");
-    }
-
-    {
-        int i;
-        const char* names[] =
-        {
-            "xinput1_4.dll",
-            "xinput1_3.dll",
-            "xinput9_1_0.dll",
-            "xinput1_2.dll",
-            "xinput1_1.dll",
-            NULL
-        };
-
-        for (i = 0;  names[i];  i++)
-        {
-            _glfw.win32.xinput.instance = LoadLibraryA(names[i]);
-            if (_glfw.win32.xinput.instance)
-            {
-                _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
-                    GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities");
-                _glfw.win32.xinput.GetState = (PFN_XInputGetState)
-                    GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState");
-
-                break;
-            }
-        }
-    }
-
-    _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll");
-    if (_glfw.win32.dwmapi.instance)
-    {
-        _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
-        _glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
-        _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
-        _glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
-    }
-
-    _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
-    if (_glfw.win32.shcore.instance)
-    {
-        _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
-            GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
-        _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
-            GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor");
-    }
-
-    _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll");
-    if (_glfw.win32.ntdll.instance)
-    {
-        _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
-            GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
-    }
-
-    return GLFW_TRUE;
-}
-
-// Unload used libraries (DLLs)
-//
-static void freeLibraries(void)
-{
-    if (_glfw.win32.xinput.instance)
-        FreeLibrary(_glfw.win32.xinput.instance);
-
-    if (_glfw.win32.dinput8.instance)
-        FreeLibrary(_glfw.win32.dinput8.instance);
-
-    if (_glfw.win32.winmm.instance)
-        FreeLibrary(_glfw.win32.winmm.instance);
-
-    if (_glfw.win32.user32.instance)
-        FreeLibrary(_glfw.win32.user32.instance);
-
-    if (_glfw.win32.dwmapi.instance)
-        FreeLibrary(_glfw.win32.dwmapi.instance);
-
-    if (_glfw.win32.shcore.instance)
-        FreeLibrary(_glfw.win32.shcore.instance);
-
-    if (_glfw.win32.ntdll.instance)
-        FreeLibrary(_glfw.win32.ntdll.instance);
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.win32.keycodes, -1, sizeof(_glfw.win32.keycodes));
-    memset(_glfw.win32.scancodes, -1, sizeof(_glfw.win32.scancodes));
-
-    _glfw.win32.keycodes[0x00B] = GLFW_KEY_0;
-    _glfw.win32.keycodes[0x002] = GLFW_KEY_1;
-    _glfw.win32.keycodes[0x003] = GLFW_KEY_2;
-    _glfw.win32.keycodes[0x004] = GLFW_KEY_3;
-    _glfw.win32.keycodes[0x005] = GLFW_KEY_4;
-    _glfw.win32.keycodes[0x006] = GLFW_KEY_5;
-    _glfw.win32.keycodes[0x007] = GLFW_KEY_6;
-    _glfw.win32.keycodes[0x008] = GLFW_KEY_7;
-    _glfw.win32.keycodes[0x009] = GLFW_KEY_8;
-    _glfw.win32.keycodes[0x00A] = GLFW_KEY_9;
-    _glfw.win32.keycodes[0x01E] = GLFW_KEY_A;
-    _glfw.win32.keycodes[0x030] = GLFW_KEY_B;
-    _glfw.win32.keycodes[0x02E] = GLFW_KEY_C;
-    _glfw.win32.keycodes[0x020] = GLFW_KEY_D;
-    _glfw.win32.keycodes[0x012] = GLFW_KEY_E;
-    _glfw.win32.keycodes[0x021] = GLFW_KEY_F;
-    _glfw.win32.keycodes[0x022] = GLFW_KEY_G;
-    _glfw.win32.keycodes[0x023] = GLFW_KEY_H;
-    _glfw.win32.keycodes[0x017] = GLFW_KEY_I;
-    _glfw.win32.keycodes[0x024] = GLFW_KEY_J;
-    _glfw.win32.keycodes[0x025] = GLFW_KEY_K;
-    _glfw.win32.keycodes[0x026] = GLFW_KEY_L;
-    _glfw.win32.keycodes[0x032] = GLFW_KEY_M;
-    _glfw.win32.keycodes[0x031] = GLFW_KEY_N;
-    _glfw.win32.keycodes[0x018] = GLFW_KEY_O;
-    _glfw.win32.keycodes[0x019] = GLFW_KEY_P;
-    _glfw.win32.keycodes[0x010] = GLFW_KEY_Q;
-    _glfw.win32.keycodes[0x013] = GLFW_KEY_R;
-    _glfw.win32.keycodes[0x01F] = GLFW_KEY_S;
-    _glfw.win32.keycodes[0x014] = GLFW_KEY_T;
-    _glfw.win32.keycodes[0x016] = GLFW_KEY_U;
-    _glfw.win32.keycodes[0x02F] = GLFW_KEY_V;
-    _glfw.win32.keycodes[0x011] = GLFW_KEY_W;
-    _glfw.win32.keycodes[0x02D] = GLFW_KEY_X;
-    _glfw.win32.keycodes[0x015] = GLFW_KEY_Y;
-    _glfw.win32.keycodes[0x02C] = GLFW_KEY_Z;
-
-    _glfw.win32.keycodes[0x028] = GLFW_KEY_APOSTROPHE;
-    _glfw.win32.keycodes[0x02B] = GLFW_KEY_BACKSLASH;
-    _glfw.win32.keycodes[0x033] = GLFW_KEY_COMMA;
-    _glfw.win32.keycodes[0x00D] = GLFW_KEY_EQUAL;
-    _glfw.win32.keycodes[0x029] = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.win32.keycodes[0x01A] = GLFW_KEY_LEFT_BRACKET;
-    _glfw.win32.keycodes[0x00C] = GLFW_KEY_MINUS;
-    _glfw.win32.keycodes[0x034] = GLFW_KEY_PERIOD;
-    _glfw.win32.keycodes[0x01B] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.win32.keycodes[0x027] = GLFW_KEY_SEMICOLON;
-    _glfw.win32.keycodes[0x035] = GLFW_KEY_SLASH;
-    _glfw.win32.keycodes[0x056] = GLFW_KEY_WORLD_2;
-
-    _glfw.win32.keycodes[0x00E] = GLFW_KEY_BACKSPACE;
-    _glfw.win32.keycodes[0x153] = GLFW_KEY_DELETE;
-    _glfw.win32.keycodes[0x14F] = GLFW_KEY_END;
-    _glfw.win32.keycodes[0x01C] = GLFW_KEY_ENTER;
-    _glfw.win32.keycodes[0x001] = GLFW_KEY_ESCAPE;
-    _glfw.win32.keycodes[0x147] = GLFW_KEY_HOME;
-    _glfw.win32.keycodes[0x152] = GLFW_KEY_INSERT;
-    _glfw.win32.keycodes[0x15D] = GLFW_KEY_MENU;
-    _glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
-    _glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
-    _glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
-    _glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE;
-    _glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
-    _glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
-    _glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
-    _glfw.win32.keycodes[0x145] = GLFW_KEY_NUM_LOCK;
-    _glfw.win32.keycodes[0x046] = GLFW_KEY_SCROLL_LOCK;
-    _glfw.win32.keycodes[0x03B] = GLFW_KEY_F1;
-    _glfw.win32.keycodes[0x03C] = GLFW_KEY_F2;
-    _glfw.win32.keycodes[0x03D] = GLFW_KEY_F3;
-    _glfw.win32.keycodes[0x03E] = GLFW_KEY_F4;
-    _glfw.win32.keycodes[0x03F] = GLFW_KEY_F5;
-    _glfw.win32.keycodes[0x040] = GLFW_KEY_F6;
-    _glfw.win32.keycodes[0x041] = GLFW_KEY_F7;
-    _glfw.win32.keycodes[0x042] = GLFW_KEY_F8;
-    _glfw.win32.keycodes[0x043] = GLFW_KEY_F9;
-    _glfw.win32.keycodes[0x044] = GLFW_KEY_F10;
-    _glfw.win32.keycodes[0x057] = GLFW_KEY_F11;
-    _glfw.win32.keycodes[0x058] = GLFW_KEY_F12;
-    _glfw.win32.keycodes[0x064] = GLFW_KEY_F13;
-    _glfw.win32.keycodes[0x065] = GLFW_KEY_F14;
-    _glfw.win32.keycodes[0x066] = GLFW_KEY_F15;
-    _glfw.win32.keycodes[0x067] = GLFW_KEY_F16;
-    _glfw.win32.keycodes[0x068] = GLFW_KEY_F17;
-    _glfw.win32.keycodes[0x069] = GLFW_KEY_F18;
-    _glfw.win32.keycodes[0x06A] = GLFW_KEY_F19;
-    _glfw.win32.keycodes[0x06B] = GLFW_KEY_F20;
-    _glfw.win32.keycodes[0x06C] = GLFW_KEY_F21;
-    _glfw.win32.keycodes[0x06D] = GLFW_KEY_F22;
-    _glfw.win32.keycodes[0x06E] = GLFW_KEY_F23;
-    _glfw.win32.keycodes[0x076] = GLFW_KEY_F24;
-    _glfw.win32.keycodes[0x038] = GLFW_KEY_LEFT_ALT;
-    _glfw.win32.keycodes[0x01D] = GLFW_KEY_LEFT_CONTROL;
-    _glfw.win32.keycodes[0x02A] = GLFW_KEY_LEFT_SHIFT;
-    _glfw.win32.keycodes[0x15B] = GLFW_KEY_LEFT_SUPER;
-    _glfw.win32.keycodes[0x137] = GLFW_KEY_PRINT_SCREEN;
-    _glfw.win32.keycodes[0x138] = GLFW_KEY_RIGHT_ALT;
-    _glfw.win32.keycodes[0x11D] = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.win32.keycodes[0x036] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.win32.keycodes[0x15C] = GLFW_KEY_RIGHT_SUPER;
-    _glfw.win32.keycodes[0x150] = GLFW_KEY_DOWN;
-    _glfw.win32.keycodes[0x14B] = GLFW_KEY_LEFT;
-    _glfw.win32.keycodes[0x14D] = GLFW_KEY_RIGHT;
-    _glfw.win32.keycodes[0x148] = GLFW_KEY_UP;
-
-    _glfw.win32.keycodes[0x052] = GLFW_KEY_KP_0;
-    _glfw.win32.keycodes[0x04F] = GLFW_KEY_KP_1;
-    _glfw.win32.keycodes[0x050] = GLFW_KEY_KP_2;
-    _glfw.win32.keycodes[0x051] = GLFW_KEY_KP_3;
-    _glfw.win32.keycodes[0x04B] = GLFW_KEY_KP_4;
-    _glfw.win32.keycodes[0x04C] = GLFW_KEY_KP_5;
-    _glfw.win32.keycodes[0x04D] = GLFW_KEY_KP_6;
-    _glfw.win32.keycodes[0x047] = GLFW_KEY_KP_7;
-    _glfw.win32.keycodes[0x048] = GLFW_KEY_KP_8;
-    _glfw.win32.keycodes[0x049] = GLFW_KEY_KP_9;
-    _glfw.win32.keycodes[0x04E] = GLFW_KEY_KP_ADD;
-    _glfw.win32.keycodes[0x053] = GLFW_KEY_KP_DECIMAL;
-    _glfw.win32.keycodes[0x135] = GLFW_KEY_KP_DIVIDE;
-    _glfw.win32.keycodes[0x11C] = GLFW_KEY_KP_ENTER;
-    _glfw.win32.keycodes[0x059] = GLFW_KEY_KP_EQUAL;
-    _glfw.win32.keycodes[0x037] = GLFW_KEY_KP_MULTIPLY;
-    _glfw.win32.keycodes[0x04A] = GLFW_KEY_KP_SUBTRACT;
-
-    for (scancode = 0;  scancode < 512;  scancode++)
-    {
-        if (_glfw.win32.keycodes[scancode] > 0)
-            _glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode;
-    }
-}
-
-// Creates a dummy window for behind-the-scenes work
-//
-static GLFWbool createHelperWindow(void)
-{
-    MSG msg;
-
-    _glfw.win32.helperWindowHandle =
-        CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
-                        _GLFW_WNDCLASSNAME,
-                        L"GLFW message window",
-                        WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
-                        0, 0, 1, 1,
-                        NULL, NULL,
-                        GetModuleHandleW(NULL),
-                        NULL);
-
-    if (!_glfw.win32.helperWindowHandle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create helper window");
-        return GLFW_FALSE;
-    }
-
-    // HACK: The command to the first ShowWindow call is ignored if the parent
-    //       process passed along a STARTUPINFO, so clear that with a no-op call
-    ShowWindow(_glfw.win32.helperWindowHandle, SW_HIDE);
-
-    // Register for HID device notifications
-    {
-        DEV_BROADCAST_DEVICEINTERFACE_W dbi;
-        ZeroMemory(&dbi, sizeof(dbi));
-        dbi.dbcc_size = sizeof(dbi);
-        dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
-        dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
-
-        _glfw.win32.deviceNotificationHandle =
-            RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle,
-                                        (DEV_BROADCAST_HDR*) &dbi,
-                                        DEVICE_NOTIFY_WINDOW_HANDLE);
-    }
-
-    while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
-    {
-        TranslateMessage(&msg);
-        DispatchMessageW(&msg);
-    }
-
-   return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Returns a wide string version of the specified UTF-8 string
-//
-WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
-{
-    WCHAR* target;
-    int count;
-
-    count = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
-    if (!count)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string from UTF-8");
-        return NULL;
-    }
-
-    target = calloc(count, sizeof(WCHAR));
-
-    if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string from UTF-8");
-        free(target);
-        return NULL;
-    }
-
-    return target;
-}
-
-// Returns a UTF-8 string version of the specified wide string
-//
-char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
-{
-    char* target;
-    int size;
-
-    size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
-    if (!size)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string to UTF-8");
-        return NULL;
-    }
-
-    target = calloc(size, 1);
-
-    if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string to UTF-8");
-        free(target);
-        return NULL;
-    }
-
-    return target;
-}
-
-// Reports the specified error, appending information about the last Win32 error
-//
-void _glfwInputErrorWin32(int error, const char* description)
-{
-    WCHAR buffer[_GLFW_MESSAGE_SIZE] = L"";
-    char message[_GLFW_MESSAGE_SIZE] = "";
-
-    FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
-                       FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_MAX_WIDTH_MASK,
-                   NULL,
-                   GetLastError() & 0xffff,
-                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                   buffer,
-                   sizeof(buffer) / sizeof(WCHAR),
-                   NULL);
-    WideCharToMultiByte(CP_UTF8, 0, buffer, -1, message, sizeof(message), NULL, NULL);
-
-    _glfwInputError(error, "%s: %s", description, message);
-}
-
-// Updates key names according to the current keyboard layout
-//
-void _glfwUpdateKeyNamesWin32(void)
-{
-    int key;
-    BYTE state[256] = {0};
-
-    memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames));
-
-    for (key = GLFW_KEY_SPACE;  key <= GLFW_KEY_LAST;  key++)
-    {
-        UINT vk;
-        int scancode, length;
-        WCHAR chars[16];
-
-        scancode = _glfw.win32.scancodes[key];
-        if (scancode == -1)
-            continue;
-
-        if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
-        {
-            const UINT vks[] = {
-                VK_NUMPAD0,  VK_NUMPAD1,  VK_NUMPAD2, VK_NUMPAD3,
-                VK_NUMPAD4,  VK_NUMPAD5,  VK_NUMPAD6, VK_NUMPAD7,
-                VK_NUMPAD8,  VK_NUMPAD9,  VK_DECIMAL, VK_DIVIDE,
-                VK_MULTIPLY, VK_SUBTRACT, VK_ADD
-            };
-
-            vk = vks[key - GLFW_KEY_KP_0];
-        }
-        else
-            vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
-
-        length = ToUnicode(vk, scancode, state,
-                           chars, sizeof(chars) / sizeof(WCHAR),
-                           0);
-
-        if (length == -1)
-        {
-            length = ToUnicode(vk, scancode, state,
-                               chars, sizeof(chars) / sizeof(WCHAR),
-                               0);
-        }
-
-        if (length < 1)
-            continue;
-
-        WideCharToMultiByte(CP_UTF8, 0, chars, 1,
-                            _glfw.win32.keynames[key],
-                            sizeof(_glfw.win32.keynames[key]),
-                            NULL, NULL);
-    }
-}
-
-// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h
-//
-BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
-{
-    OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, {0}, sp };
-    DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
-    ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
-    // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
-    //       latter lies unless the user knew to embed a non-default manifest
-    //       announcing support for Windows 10 via supportedOS GUID
-    return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
-}
-
-// Checks whether we are on at least the specified build of Windows 10
-//
-BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
-{
-    OSVERSIONINFOEXW osvi = { sizeof(osvi), 10, 0, build };
-    DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
-    ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
-    // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
-    //       latter lies unless the user knew to embed a non-default manifest
-    //       announcing support for Windows 10 via supportedOS GUID
-    return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    // To make SetForegroundWindow work as we want, we need to fiddle
-    // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
-    // as possible in the hope of still being the foreground process)
-    SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
-                          &_glfw.win32.foregroundLockTimeout, 0);
-    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
-                          SPIF_SENDCHANGE);
-
-    if (!loadLibraries())
-        return GLFW_FALSE;
-
-    createKeyTables();
-    _glfwUpdateKeyNamesWin32();
-
-    if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-        SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
-    else if (IsWindows8Point1OrGreater())
-        SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
-    else if (IsWindowsVistaOrGreater())
-        SetProcessDPIAware();
-
-    if (!_glfwRegisterWindowClassWin32())
-        return GLFW_FALSE;
-
-    if (!createHelperWindow())
-        return GLFW_FALSE;
-
-    _glfwInitTimerWin32();
-
-    _glfwPollMonitorsWin32();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    if (_glfw.win32.deviceNotificationHandle)
-        UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
-
-    if (_glfw.win32.helperWindowHandle)
-        DestroyWindow(_glfw.win32.helperWindowHandle);
-
-    _glfwUnregisterWindowClassWin32();
-
-    // Restore previous foreground lock timeout system setting
-    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
-                          UIntToPtr(_glfw.win32.foregroundLockTimeout),
-                          SPIF_SENDCHANGE);
-
-    free(_glfw.win32.clipboardString);
-    free(_glfw.win32.rawInput);
-
-    _glfwTerminateWGL();
-    _glfwTerminateEGL();
-
-    freeLibraries();
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
-#if defined(__MINGW32__)
-        " MinGW"
-#elif defined(_MSC_VER)
-        " VisualC"
-#endif
-#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
-        " hybrid-GPU"
-#endif
-#if defined(_GLFW_BUILD_DLL)
-        " DLL"
-#endif
-        ;
-}
-
diff --git a/raylib/external/glfw/src/win32_joystick.c b/raylib/external/glfw/src/win32_joystick.c
deleted file mode 100644 (file)
index 9c71d11..0000000
+++ /dev/null
@@ -1,753 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <math.h>
-
-#define _GLFW_TYPE_AXIS     0
-#define _GLFW_TYPE_SLIDER   1
-#define _GLFW_TYPE_BUTTON   2
-#define _GLFW_TYPE_POV      3
-
-// Data produced with DirectInput device object enumeration
-//
-typedef struct _GLFWobjenumWin32
-{
-    IDirectInputDevice8W*   device;
-    _GLFWjoyobjectWin32*    objects;
-    int                     objectCount;
-    int                     axisCount;
-    int                     sliderCount;
-    int                     buttonCount;
-    int                     povCount;
-} _GLFWobjenumWin32;
-
-// Define local copies of the necessary GUIDs
-//
-static const GUID _glfw_IID_IDirectInput8W =
-    {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
-static const GUID _glfw_GUID_XAxis =
-    {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_YAxis =
-    {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_ZAxis =
-    {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RxAxis =
-    {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RyAxis =
-    {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RzAxis =
-    {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_Slider =
-    {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_POV =
-    {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-
-#define IID_IDirectInput8W _glfw_IID_IDirectInput8W
-#define GUID_XAxis _glfw_GUID_XAxis
-#define GUID_YAxis _glfw_GUID_YAxis
-#define GUID_ZAxis _glfw_GUID_ZAxis
-#define GUID_RxAxis _glfw_GUID_RxAxis
-#define GUID_RyAxis _glfw_GUID_RyAxis
-#define GUID_RzAxis _glfw_GUID_RzAxis
-#define GUID_Slider _glfw_GUID_Slider
-#define GUID_POV _glfw_GUID_POV
-
-// Object data array for our clone of c_dfDIJoystick
-// Generated with https://github.com/elmindreda/c_dfDIJoystick2
-//
-static DIOBJECTDATAFORMAT _glfwObjectDataFormats[] =
-{
-    { &GUID_XAxis,DIJOFS_X,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_YAxis,DIJOFS_Y,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_ZAxis,DIJOFS_Z,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RxAxis,DIJOFS_RX,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RyAxis,DIJOFS_RY,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RzAxis,DIJOFS_RZ,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_POV,DIJOFS_POV(0),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(1),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(2),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(3),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(0),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(1),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(2),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(3),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(4),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(5),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(6),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(7),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(8),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(9),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(10),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(11),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(12),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(13),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(14),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(15),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(16),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(17),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(18),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(19),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(20),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(21),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(22),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(23),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(24),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(25),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(26),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(27),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(28),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(29),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(30),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(31),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-};
-
-// Our clone of c_dfDIJoystick
-//
-static const DIDATAFORMAT _glfwDataFormat =
-{
-    sizeof(DIDATAFORMAT),
-    sizeof(DIOBJECTDATAFORMAT),
-    DIDFT_ABSAXIS,
-    sizeof(DIJOYSTATE),
-    sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
-    _glfwObjectDataFormats
-};
-
-// Returns a description fitting the specified XInput capabilities
-//
-static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
-{
-    switch (xic->SubType)
-    {
-        case XINPUT_DEVSUBTYPE_WHEEL:
-            return "XInput Wheel";
-        case XINPUT_DEVSUBTYPE_ARCADE_STICK:
-            return "XInput Arcade Stick";
-        case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
-            return "XInput Flight Stick";
-        case XINPUT_DEVSUBTYPE_DANCE_PAD:
-            return "XInput Dance Pad";
-        case XINPUT_DEVSUBTYPE_GUITAR:
-            return "XInput Guitar";
-        case XINPUT_DEVSUBTYPE_DRUM_KIT:
-            return "XInput Drum Kit";
-        case XINPUT_DEVSUBTYPE_GAMEPAD:
-        {
-            if (xic->Flags & XINPUT_CAPS_WIRELESS)
-                return "Wireless Xbox Controller";
-            else
-                return "Xbox Controller";
-        }
-    }
-
-    return "Unknown XInput Device";
-}
-
-// Lexically compare device objects
-//
-static int compareJoystickObjects(const void* first, const void* second)
-{
-    const _GLFWjoyobjectWin32* fo = first;
-    const _GLFWjoyobjectWin32* so = second;
-
-    if (fo->type != so->type)
-        return fo->type - so->type;
-
-    return fo->offset - so->offset;
-}
-
-// Checks whether the specified device supports XInput
-// Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
-//
-static GLFWbool supportsXInput(const GUID* guid)
-{
-    UINT i, count = 0;
-    RAWINPUTDEVICELIST* ridl;
-    GLFWbool result = GLFW_FALSE;
-
-    if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
-        return GLFW_FALSE;
-
-    ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
-
-    if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
-    {
-        free(ridl);
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  i < count;  i++)
-    {
-        RID_DEVICE_INFO rdi;
-        char name[256];
-        UINT size;
-
-        if (ridl[i].dwType != RIM_TYPEHID)
-            continue;
-
-        ZeroMemory(&rdi, sizeof(rdi));
-        rdi.cbSize = sizeof(rdi);
-        size = sizeof(rdi);
-
-        if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
-                                         RIDI_DEVICEINFO,
-                                         &rdi, &size) == -1)
-        {
-            continue;
-        }
-
-        if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
-            continue;
-
-        memset(name, 0, sizeof(name));
-        size = sizeof(name);
-
-        if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
-                                         RIDI_DEVICENAME,
-                                         name, &size) == -1)
-        {
-            break;
-        }
-
-        name[sizeof(name) - 1] = '\0';
-        if (strstr(name, "IG_"))
-        {
-            result = GLFW_TRUE;
-            break;
-        }
-    }
-
-    free(ridl);
-    return result;
-}
-
-// Frees all resources associated with the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    if (js->win32.device)
-    {
-        IDirectInputDevice8_Unacquire(js->win32.device);
-        IDirectInputDevice8_Release(js->win32.device);
-    }
-
-    free(js->win32.objects);
-
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// DirectInput device object enumeration callback
-// Insights gleaned from SDL
-//
-static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
-                                          void* user)
-{
-    _GLFWobjenumWin32* data = user;
-    _GLFWjoyobjectWin32* object = data->objects + data->objectCount;
-
-    if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
-    {
-        DIPROPRANGE dipr;
-
-        if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_SLIDER(data->sliderCount);
-        else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_X;
-        else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_Y;
-        else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_Z;
-        else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RX;
-        else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RY;
-        else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RZ;
-        else
-            return DIENUM_CONTINUE;
-
-        ZeroMemory(&dipr, sizeof(dipr));
-        dipr.diph.dwSize = sizeof(dipr);
-        dipr.diph.dwHeaderSize = sizeof(dipr.diph);
-        dipr.diph.dwObj = doi->dwType;
-        dipr.diph.dwHow = DIPH_BYID;
-        dipr.lMin = -32768;
-        dipr.lMax =  32767;
-
-        if (FAILED(IDirectInputDevice8_SetProperty(data->device,
-                                                   DIPROP_RANGE,
-                                                   &dipr.diph)))
-        {
-            return DIENUM_CONTINUE;
-        }
-
-        if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
-        {
-            object->type = _GLFW_TYPE_SLIDER;
-            data->sliderCount++;
-        }
-        else
-        {
-            object->type = _GLFW_TYPE_AXIS;
-            data->axisCount++;
-        }
-    }
-    else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
-    {
-        object->offset = DIJOFS_BUTTON(data->buttonCount);
-        object->type = _GLFW_TYPE_BUTTON;
-        data->buttonCount++;
-    }
-    else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
-    {
-        object->offset = DIJOFS_POV(data->povCount);
-        object->type = _GLFW_TYPE_POV;
-        data->povCount++;
-    }
-
-    data->objectCount++;
-    return DIENUM_CONTINUE;
-}
-
-// DirectInput device enumeration callback
-//
-static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
-{
-    int jid = 0;
-    DIDEVCAPS dc;
-    DIPROPDWORD dipd;
-    IDirectInputDevice8* device;
-    _GLFWobjenumWin32 data;
-    _GLFWjoystick* js;
-    char guid[33];
-    char name[256];
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        js = _glfw.joysticks + jid;
-        if (js->present)
-        {
-            if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
-                return DIENUM_CONTINUE;
-        }
-    }
-
-    if (supportsXInput(&di->guidProduct))
-        return DIENUM_CONTINUE;
-
-    if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
-                                          &di->guidInstance,
-                                          &device,
-                                          NULL)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
-        return DIENUM_CONTINUE;
-    }
-
-    if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set device data format");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    ZeroMemory(&dc, sizeof(dc));
-    dc.dwSize = sizeof(dc);
-
-    if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to query device capabilities");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    ZeroMemory(&dipd, sizeof(dipd));
-    dipd.diph.dwSize = sizeof(dipd);
-    dipd.diph.dwHeaderSize = sizeof(dipd.diph);
-    dipd.diph.dwHow = DIPH_DEVICE;
-    dipd.dwData = DIPROPAXISMODE_ABS;
-
-    if (FAILED(IDirectInputDevice8_SetProperty(device,
-                                               DIPROP_AXISMODE,
-                                               &dipd.diph)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set device axis mode");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    memset(&data, 0, sizeof(data));
-    data.device = device;
-    data.objects = calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
-                          sizeof(_GLFWjoyobjectWin32));
-
-    if (FAILED(IDirectInputDevice8_EnumObjects(device,
-                                               deviceObjectCallback,
-                                               &data,
-                                               DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to enumerate device objects");
-
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_CONTINUE;
-    }
-
-    qsort(data.objects, data.objectCount,
-          sizeof(_GLFWjoyobjectWin32),
-          compareJoystickObjects);
-
-    if (!WideCharToMultiByte(CP_UTF8, 0,
-                             di->tszInstanceName, -1,
-                             name, sizeof(name),
-                             NULL, NULL))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to convert joystick name to UTF-8");
-
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_STOP;
-    }
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
-    {
-        sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
-                (uint8_t) di->guidProduct.Data1,
-                (uint8_t) (di->guidProduct.Data1 >> 8),
-                (uint8_t) (di->guidProduct.Data1 >> 16),
-                (uint8_t) (di->guidProduct.Data1 >> 24));
-    }
-    else
-    {
-        sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    js = _glfwAllocJoystick(name, guid,
-                            data.axisCount + data.sliderCount,
-                            data.buttonCount,
-                            data.povCount);
-    if (!js)
-    {
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_STOP;
-    }
-
-    js->win32.device = device;
-    js->win32.guid = di->guidInstance;
-    js->win32.objects = data.objects;
-    js->win32.objectCount = data.objectCount;
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-    return DIENUM_CONTINUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Checks for new joysticks after DBT_DEVICEARRIVAL
-//
-void _glfwDetectJoystickConnectionWin32(void)
-{
-    if (_glfw.win32.xinput.instance)
-    {
-        DWORD index;
-
-        for (index = 0;  index < XUSER_MAX_COUNT;  index++)
-        {
-            int jid;
-            char guid[33];
-            XINPUT_CAPABILITIES xic;
-            _GLFWjoystick* js;
-
-            for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-            {
-                if (_glfw.joysticks[jid].present &&
-                    _glfw.joysticks[jid].win32.device == NULL &&
-                    _glfw.joysticks[jid].win32.index == index)
-                {
-                    break;
-                }
-            }
-
-            if (jid <= GLFW_JOYSTICK_LAST)
-                continue;
-
-            if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
-                continue;
-
-            // Generate a joystick GUID that matches the SDL 2.0.5+ one
-            sprintf(guid, "78696e707574%02x000000000000000000",
-                    xic.SubType & 0xff);
-
-            js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
-            if (!js)
-                continue;
-
-            js->win32.index = index;
-
-            _glfwInputJoystick(js, GLFW_CONNECTED);
-        }
-    }
-
-    if (_glfw.win32.dinput8.api)
-    {
-        if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
-                                             DI8DEVCLASS_GAMECTRL,
-                                             deviceCallback,
-                                             NULL,
-                                             DIEDFL_ALLDEVICES)))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Failed to enumerate DirectInput8 devices");
-            return;
-        }
-    }
-}
-
-// Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
-//
-void _glfwDetectJoystickDisconnectionWin32(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    if (_glfw.win32.dinput8.instance)
-    {
-        if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
-                                      DIRECTINPUT_VERSION,
-                                      &IID_IDirectInput8W,
-                                      (void**) &_glfw.win32.dinput8.api,
-                                      NULL)))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Win32: Failed to create interface");
-            return GLFW_FALSE;
-        }
-    }
-
-    _glfwDetectJoystickConnectionWin32();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = GLFW_JOYSTICK_1;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-        closeJoystick(_glfw.joysticks + jid);
-
-    if (_glfw.win32.dinput8.api)
-        IDirectInput8_Release(_glfw.win32.dinput8.api);
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    if (js->win32.device)
-    {
-        int i, ai = 0, bi = 0, pi = 0;
-        HRESULT result;
-        DIJOYSTATE state;
-
-        IDirectInputDevice8_Poll(js->win32.device);
-        result = IDirectInputDevice8_GetDeviceState(js->win32.device,
-                                                    sizeof(state),
-                                                    &state);
-        if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
-        {
-            IDirectInputDevice8_Acquire(js->win32.device);
-            IDirectInputDevice8_Poll(js->win32.device);
-            result = IDirectInputDevice8_GetDeviceState(js->win32.device,
-                                                        sizeof(state),
-                                                        &state);
-        }
-
-        if (FAILED(result))
-        {
-            closeJoystick(js);
-            return GLFW_FALSE;
-        }
-
-        if (mode == _GLFW_POLL_PRESENCE)
-            return GLFW_TRUE;
-
-        for (i = 0;  i < js->win32.objectCount;  i++)
-        {
-            const void* data = (char*) &state + js->win32.objects[i].offset;
-
-            switch (js->win32.objects[i].type)
-            {
-                case _GLFW_TYPE_AXIS:
-                case _GLFW_TYPE_SLIDER:
-                {
-                    const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
-                    _glfwInputJoystickAxis(js, ai, value);
-                    ai++;
-                    break;
-                }
-
-                case _GLFW_TYPE_BUTTON:
-                {
-                    const char value = (*((BYTE*) data) & 0x80) != 0;
-                    _glfwInputJoystickButton(js, bi, value);
-                    bi++;
-                    break;
-                }
-
-                case _GLFW_TYPE_POV:
-                {
-                    const int states[9] =
-                    {
-                        GLFW_HAT_UP,
-                        GLFW_HAT_RIGHT_UP,
-                        GLFW_HAT_RIGHT,
-                        GLFW_HAT_RIGHT_DOWN,
-                        GLFW_HAT_DOWN,
-                        GLFW_HAT_LEFT_DOWN,
-                        GLFW_HAT_LEFT,
-                        GLFW_HAT_LEFT_UP,
-                        GLFW_HAT_CENTERED
-                    };
-
-                    // Screams of horror are appropriate at this point
-                    int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
-                    if (stateIndex < 0 || stateIndex > 8)
-                        stateIndex = 8;
-
-                    _glfwInputJoystickHat(js, pi, states[stateIndex]);
-                    pi++;
-                    break;
-                }
-            }
-        }
-    }
-    else
-    {
-        int i, dpad = 0;
-        DWORD result;
-        XINPUT_STATE xis;
-        const WORD buttons[10] =
-        {
-            XINPUT_GAMEPAD_A,
-            XINPUT_GAMEPAD_B,
-            XINPUT_GAMEPAD_X,
-            XINPUT_GAMEPAD_Y,
-            XINPUT_GAMEPAD_LEFT_SHOULDER,
-            XINPUT_GAMEPAD_RIGHT_SHOULDER,
-            XINPUT_GAMEPAD_BACK,
-            XINPUT_GAMEPAD_START,
-            XINPUT_GAMEPAD_LEFT_THUMB,
-            XINPUT_GAMEPAD_RIGHT_THUMB
-        };
-
-        result = XInputGetState(js->win32.index, &xis);
-        if (result != ERROR_SUCCESS)
-        {
-            if (result == ERROR_DEVICE_NOT_CONNECTED)
-                closeJoystick(js);
-
-            return GLFW_FALSE;
-        }
-
-        if (mode == _GLFW_POLL_PRESENCE)
-            return GLFW_TRUE;
-
-        _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
-        _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
-
-        for (i = 0;  i < 10;  i++)
-        {
-            const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
-            _glfwInputJoystickButton(js, i, value);
-        }
-
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
-            dpad |= GLFW_HAT_UP;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
-            dpad |= GLFW_HAT_RIGHT;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
-            dpad |= GLFW_HAT_DOWN;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
-            dpad |= GLFW_HAT_LEFT;
-
-        _glfwInputJoystickHat(js, 0, dpad);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-    if (strcmp(guid + 20, "504944564944") == 0)
-    {
-        char original[33];
-        strncpy(original, guid, sizeof(original) - 1);
-        sprintf(guid, "03000000%.4s0000%.4s000000000000",
-                original, original + 4);
-    }
-}
-
diff --git a/raylib/external/glfw/src/win32_joystick.h b/raylib/external/glfw/src/win32_joystick.h
deleted file mode 100644 (file)
index b6a7adc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickWin32 win32
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
-
-// Joystick element (axis, button or slider)
-//
-typedef struct _GLFWjoyobjectWin32
-{
-    int                     offset;
-    int                     type;
-} _GLFWjoyobjectWin32;
-
-// Win32-specific per-joystick data
-//
-typedef struct _GLFWjoystickWin32
-{
-    _GLFWjoyobjectWin32*    objects;
-    int                     objectCount;
-    IDirectInputDevice8W*   device;
-    DWORD                   index;
-    GUID                    guid;
-} _GLFWjoystickWin32;
-
-void _glfwDetectJoystickConnectionWin32(void);
-void _glfwDetectJoystickDisconnectionWin32(void);
-
diff --git a/raylib/external/glfw/src/win32_monitor.c b/raylib/external/glfw/src/win32_monitor.c
deleted file mode 100644 (file)
index b4c53e4..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <malloc.h>
-#include <wchar.h>
-
-
-// Callback for EnumDisplayMonitors in createMonitor
-//
-static BOOL CALLBACK monitorCallback(HMONITOR handle,
-                                     HDC dc,
-                                     RECT* rect,
-                                     LPARAM data)
-{
-    MONITORINFOEXW mi;
-    ZeroMemory(&mi, sizeof(mi));
-    mi.cbSize = sizeof(mi);
-
-    if (GetMonitorInfoW(handle, (MONITORINFO*) &mi))
-    {
-        _GLFWmonitor* monitor = (_GLFWmonitor*) data;
-        if (wcscmp(mi.szDevice, monitor->win32.adapterName) == 0)
-            monitor->win32.handle = handle;
-    }
-
-    return TRUE;
-}
-
-// Create monitor from an adapter and (optionally) a display
-//
-static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter,
-                                   DISPLAY_DEVICEW* display)
-{
-    _GLFWmonitor* monitor;
-    int widthMM, heightMM;
-    char* name;
-    HDC dc;
-    DEVMODEW dm;
-    RECT rect;
-
-    if (display)
-        name = _glfwCreateUTF8FromWideStringWin32(display->DeviceString);
-    else
-        name = _glfwCreateUTF8FromWideStringWin32(adapter->DeviceString);
-    if (!name)
-        return NULL;
-
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-    EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &dm);
-
-    dc = CreateDCW(L"DISPLAY", adapter->DeviceName, NULL, NULL);
-
-    if (IsWindows8Point1OrGreater())
-    {
-        widthMM  = GetDeviceCaps(dc, HORZSIZE);
-        heightMM = GetDeviceCaps(dc, VERTSIZE);
-    }
-    else
-    {
-        widthMM  = (int) (dm.dmPelsWidth * 25.4f / GetDeviceCaps(dc, LOGPIXELSX));
-        heightMM = (int) (dm.dmPelsHeight * 25.4f / GetDeviceCaps(dc, LOGPIXELSY));
-    }
-
-    DeleteDC(dc);
-
-    monitor = _glfwAllocMonitor(name, widthMM, heightMM);
-    free(name);
-
-    if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
-        monitor->win32.modesPruned = GLFW_TRUE;
-
-    wcscpy(monitor->win32.adapterName, adapter->DeviceName);
-    WideCharToMultiByte(CP_UTF8, 0,
-                        adapter->DeviceName, -1,
-                        monitor->win32.publicAdapterName,
-                        sizeof(monitor->win32.publicAdapterName),
-                        NULL, NULL);
-
-    if (display)
-    {
-        wcscpy(monitor->win32.displayName, display->DeviceName);
-        WideCharToMultiByte(CP_UTF8, 0,
-                            display->DeviceName, -1,
-                            monitor->win32.publicDisplayName,
-                            sizeof(monitor->win32.publicDisplayName),
-                            NULL, NULL);
-    }
-
-    rect.left   = dm.dmPosition.x;
-    rect.top    = dm.dmPosition.y;
-    rect.right  = dm.dmPosition.x + dm.dmPelsWidth;
-    rect.bottom = dm.dmPosition.y + dm.dmPelsHeight;
-
-    EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor);
-    return monitor;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsWin32(void)
-{
-    int i, disconnectedCount;
-    _GLFWmonitor** disconnected = NULL;
-    DWORD adapterIndex, displayIndex;
-    DISPLAY_DEVICEW adapter, display;
-    _GLFWmonitor* monitor;
-
-    disconnectedCount = _glfw.monitorCount;
-    if (disconnectedCount)
-    {
-        disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-        memcpy(disconnected,
-               _glfw.monitors,
-               _glfw.monitorCount * sizeof(_GLFWmonitor*));
-    }
-
-    for (adapterIndex = 0;  ;  adapterIndex++)
-    {
-        int type = _GLFW_INSERT_LAST;
-
-        ZeroMemory(&adapter, sizeof(adapter));
-        adapter.cb = sizeof(adapter);
-
-        if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
-            break;
-
-        if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
-            continue;
-
-        if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
-            type = _GLFW_INSERT_FIRST;
-
-        for (displayIndex = 0;  ;  displayIndex++)
-        {
-            ZeroMemory(&display, sizeof(display));
-            display.cb = sizeof(display);
-
-            if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
-                break;
-
-            if (!(display.StateFlags & DISPLAY_DEVICE_ACTIVE))
-                continue;
-
-            for (i = 0;  i < disconnectedCount;  i++)
-            {
-                if (disconnected[i] &&
-                    wcscmp(disconnected[i]->win32.displayName,
-                           display.DeviceName) == 0)
-                {
-                    disconnected[i] = NULL;
-                    // handle may have changed, update
-                    EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]);
-                    break;
-                }
-            }
-
-            if (i < disconnectedCount)
-                continue;
-
-            monitor = createMonitor(&adapter, &display);
-            if (!monitor)
-            {
-                free(disconnected);
-                return;
-            }
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-
-            type = _GLFW_INSERT_LAST;
-        }
-
-        // HACK: If an active adapter does not have any display devices
-        //       (as sometimes happens), add it directly as a monitor
-        if (displayIndex == 0)
-        {
-            for (i = 0;  i < disconnectedCount;  i++)
-            {
-                if (disconnected[i] &&
-                    wcscmp(disconnected[i]->win32.adapterName,
-                           adapter.DeviceName) == 0)
-                {
-                    disconnected[i] = NULL;
-                    break;
-                }
-            }
-
-            if (i < disconnectedCount)
-                continue;
-
-            monitor = createMonitor(&adapter, NULL);
-            if (!monitor)
-            {
-                free(disconnected);
-                return;
-            }
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-        }
-    }
-
-    for (i = 0;  i < disconnectedCount;  i++)
-    {
-        if (disconnected[i])
-            _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-    }
-
-    free(disconnected);
-}
-
-// Change the current video mode
-//
-void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    GLFWvidmode current;
-    const GLFWvidmode* best;
-    DEVMODEW dm;
-    LONG result;
-
-    best = _glfwChooseVideoMode(monitor, desired);
-    _glfwPlatformGetVideoMode(monitor, &current);
-    if (_glfwCompareVideoModes(&current, best) == 0)
-        return;
-
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-    dm.dmFields           = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
-                            DM_DISPLAYFREQUENCY;
-    dm.dmPelsWidth        = best->width;
-    dm.dmPelsHeight       = best->height;
-    dm.dmBitsPerPel       = best->redBits + best->greenBits + best->blueBits;
-    dm.dmDisplayFrequency = best->refreshRate;
-
-    if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
-        dm.dmBitsPerPel = 32;
-
-    result = ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                      &dm,
-                                      NULL,
-                                      CDS_FULLSCREEN,
-                                      NULL);
-    if (result == DISP_CHANGE_SUCCESSFUL)
-        monitor->win32.modeChanged = GLFW_TRUE;
-    else
-    {
-        const char* description = "Unknown error";
-
-        if (result == DISP_CHANGE_BADDUALVIEW)
-            description = "The system uses DualView";
-        else if (result == DISP_CHANGE_BADFLAGS)
-            description = "Invalid flags";
-        else if (result == DISP_CHANGE_BADMODE)
-            description = "Graphics mode not supported";
-        else if (result == DISP_CHANGE_BADPARAM)
-            description = "Invalid parameter";
-        else if (result == DISP_CHANGE_FAILED)
-            description = "Graphics mode failed";
-        else if (result == DISP_CHANGE_NOTUPDATED)
-            description = "Failed to write to registry";
-        else if (result == DISP_CHANGE_RESTART)
-            description = "Computer restart required";
-
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set video mode: %s",
-                        description);
-    }
-}
-
-// Restore the previously saved (original) video mode
-//
-void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
-{
-    if (monitor->win32.modeChanged)
-    {
-        ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                 NULL, NULL, CDS_FULLSCREEN, NULL);
-        monitor->win32.modeChanged = GLFW_FALSE;
-    }
-}
-
-void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
-{
-    UINT xdpi, ydpi;
-
-    if (IsWindows8Point1OrGreater())
-        GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
-    else
-    {
-        const HDC dc = GetDC(NULL);
-        xdpi = GetDeviceCaps(dc, LOGPIXELSX);
-        ydpi = GetDeviceCaps(dc, LOGPIXELSY);
-        ReleaseDC(NULL, dc);
-    }
-
-    if (xscale)
-        *xscale = xdpi / (float) USER_DEFAULT_SCREEN_DPI;
-    if (yscale)
-        *yscale = ydpi / (float) USER_DEFAULT_SCREEN_DPI;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    DEVMODEW dm;
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-
-    EnumDisplaySettingsExW(monitor->win32.adapterName,
-                           ENUM_CURRENT_SETTINGS,
-                           &dm,
-                           EDS_ROTATEDMODE);
-
-    if (xpos)
-        *xpos = dm.dmPosition.x;
-    if (ypos)
-        *ypos = dm.dmPosition.y;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    _glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale);
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    MONITORINFO mi = { sizeof(mi) };
-    GetMonitorInfo(monitor->win32.handle, &mi);
-
-    if (xpos)
-        *xpos = mi.rcWork.left;
-    if (ypos)
-        *ypos = mi.rcWork.top;
-    if (width)
-        *width = mi.rcWork.right - mi.rcWork.left;
-    if (height)
-        *height = mi.rcWork.bottom - mi.rcWork.top;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    int modeIndex = 0, size = 0;
-    GLFWvidmode* result = NULL;
-
-    *count = 0;
-
-    for (;;)
-    {
-        int i;
-        GLFWvidmode mode;
-        DEVMODEW dm;
-
-        ZeroMemory(&dm, sizeof(dm));
-        dm.dmSize = sizeof(dm);
-
-        if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))
-            break;
-
-        modeIndex++;
-
-        // Skip modes with less than 15 BPP
-        if (dm.dmBitsPerPel < 15)
-            continue;
-
-        mode.width  = dm.dmPelsWidth;
-        mode.height = dm.dmPelsHeight;
-        mode.refreshRate = dm.dmDisplayFrequency;
-        _glfwSplitBPP(dm.dmBitsPerPel,
-                      &mode.redBits,
-                      &mode.greenBits,
-                      &mode.blueBits);
-
-        for (i = 0;  i < *count;  i++)
-        {
-            if (_glfwCompareVideoModes(result + i, &mode) == 0)
-                break;
-        }
-
-        // Skip duplicate modes
-        if (i < *count)
-            continue;
-
-        if (monitor->win32.modesPruned)
-        {
-            // Skip modes not supported by the connected displays
-            if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                         &dm,
-                                         NULL,
-                                         CDS_TEST,
-                                         NULL) != DISP_CHANGE_SUCCESSFUL)
-            {
-                continue;
-            }
-        }
-
-        if (*count == size)
-        {
-            size += 128;
-            result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode));
-        }
-
-        (*count)++;
-        result[*count - 1] = mode;
-    }
-
-    if (!*count)
-    {
-        // HACK: Report the current mode if no valid modes were found
-        result = calloc(1, sizeof(GLFWvidmode));
-        _glfwPlatformGetVideoMode(monitor, result);
-        *count = 1;
-    }
-
-    return result;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    DEVMODEW dm;
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-
-    EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);
-
-    mode->width  = dm.dmPelsWidth;
-    mode->height = dm.dmPelsHeight;
-    mode->refreshRate = dm.dmDisplayFrequency;
-    _glfwSplitBPP(dm.dmBitsPerPel,
-                  &mode->redBits,
-                  &mode->greenBits,
-                  &mode->blueBits);
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    HDC dc;
-    WORD values[3][256];
-
-    dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
-    GetDeviceGammaRamp(dc, values);
-    DeleteDC(dc);
-
-    _glfwAllocGammaArrays(ramp, 256);
-
-    memcpy(ramp->red,   values[0], sizeof(values[0]));
-    memcpy(ramp->green, values[1], sizeof(values[1]));
-    memcpy(ramp->blue,  values[2], sizeof(values[2]));
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    HDC dc;
-    WORD values[3][256];
-
-    if (ramp->size != 256)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Gamma ramp size must be 256");
-        return;
-    }
-
-    memcpy(values[0], ramp->red,   sizeof(values[0]));
-    memcpy(values[1], ramp->green, sizeof(values[1]));
-    memcpy(values[2], ramp->blue,  sizeof(values[2]));
-
-    dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
-    SetDeviceGammaRamp(dc, values);
-    DeleteDC(dc);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->win32.publicAdapterName;
-}
-
-GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->win32.publicDisplayName;
-}
-
diff --git a/raylib/external/glfw/src/win32_platform.h b/raylib/external/glfw/src/win32_platform.h
deleted file mode 100644 (file)
index 4f52051..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-// We don't need all the fancy stuff
-#ifndef NOMINMAX
- #define NOMINMAX
-#endif
-
-#ifndef VC_EXTRALEAN
- #define VC_EXTRALEAN
-#endif
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif
-
-// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
-// example to allow applications to correctly declare a GL_ARB_debug_output
-// callback) but windows.h assumes no one will define APIENTRY before it does
-#undef APIENTRY
-
-// GLFW on Windows is Unicode only and does not work in MBCS mode
-#ifndef UNICODE
- #define UNICODE
-#endif
-
-// GLFW requires Windows XP or later
-#if WINVER < 0x0501
- #undef WINVER
- #define WINVER 0x0501
-#endif
-#if _WIN32_WINNT < 0x0501
- #undef _WIN32_WINNT
- #define _WIN32_WINNT 0x0501
-#endif
-
-// GLFW uses DirectInput8 interfaces
-#define DIRECTINPUT_VERSION 0x0800
-
-// GLFW uses OEM cursor resources
-#define OEMRESOURCE
-
-#include <wctype.h>
-#include <windows.h>
-#include <dinput.h>
-#include <xinput.h>
-#include <dbt.h>
-
-// HACK: Define macros that some windows.h variants don't
-#ifndef WM_MOUSEHWHEEL
- #define WM_MOUSEHWHEEL 0x020E
-#endif
-#ifndef WM_DWMCOMPOSITIONCHANGED
- #define WM_DWMCOMPOSITIONCHANGED 0x031E
-#endif
-#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
- #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
-#endif
-#ifndef WM_COPYGLOBALDATA
- #define WM_COPYGLOBALDATA 0x0049
-#endif
-#ifndef WM_UNICHAR
- #define WM_UNICHAR 0x0109
-#endif
-#ifndef UNICODE_NOCHAR
- #define UNICODE_NOCHAR 0xFFFF
-#endif
-#ifndef WM_DPICHANGED
- #define WM_DPICHANGED 0x02E0
-#endif
-#ifndef GET_XBUTTON_WPARAM
- #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
-#endif
-#ifndef EDS_ROTATEDMODE
- #define EDS_ROTATEDMODE 0x00000004
-#endif
-#ifndef DISPLAY_DEVICE_ACTIVE
- #define DISPLAY_DEVICE_ACTIVE 0x00000001
-#endif
-#ifndef _WIN32_WINNT_WINBLUE
- #define _WIN32_WINNT_WINBLUE 0x0603
-#endif
-#ifndef _WIN32_WINNT_WIN8
- #define _WIN32_WINNT_WIN8 0x0602
-#endif
-#ifndef WM_GETDPISCALEDSIZE
- #define WM_GETDPISCALEDSIZE 0x02e4
-#endif
-#ifndef USER_DEFAULT_SCREEN_DPI
- #define USER_DEFAULT_SCREEN_DPI 96
-#endif
-#ifndef OCR_HAND
- #define OCR_HAND 32649
-#endif
-
-#if WINVER < 0x0601
-typedef struct
-{
-    DWORD cbSize;
-    DWORD ExtStatus;
-} CHANGEFILTERSTRUCT;
-#ifndef MSGFLT_ALLOW
- #define MSGFLT_ALLOW 1
-#endif
-#endif /*Windows 7*/
-
-#if WINVER < 0x0600
-#define DWM_BB_ENABLE 0x00000001
-#define DWM_BB_BLURREGION 0x00000002
-typedef struct
-{
-    DWORD dwFlags;
-    BOOL fEnable;
-    HRGN hRgnBlur;
-    BOOL fTransitionOnMaximized;
-} DWM_BLURBEHIND;
-#else
- #include <dwmapi.h>
-#endif /*Windows Vista*/
-
-#ifndef DPI_ENUMS_DECLARED
-typedef enum
-{
-    PROCESS_DPI_UNAWARE = 0,
-    PROCESS_SYSTEM_DPI_AWARE = 1,
-    PROCESS_PER_MONITOR_DPI_AWARE = 2
-} PROCESS_DPI_AWARENESS;
-typedef enum
-{
-    MDT_EFFECTIVE_DPI = 0,
-    MDT_ANGULAR_DPI = 1,
-    MDT_RAW_DPI = 2,
-    MDT_DEFAULT = MDT_EFFECTIVE_DPI
-} MONITOR_DPI_TYPE;
-#endif /*DPI_ENUMS_DECLARED*/
-
-#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
-#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
-#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
-
-// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
-#define IsWindowsVistaOrGreater()                                     \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA),   \
-                                        LOBYTE(_WIN32_WINNT_VISTA), 0)
-#define IsWindows7OrGreater()                                         \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7),    \
-                                        LOBYTE(_WIN32_WINNT_WIN7), 0)
-#define IsWindows8OrGreater()                                         \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8),    \
-                                        LOBYTE(_WIN32_WINNT_WIN8), 0)
-#define IsWindows8Point1OrGreater()                                   \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
-                                        LOBYTE(_WIN32_WINNT_WINBLUE), 0)
-
-#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
-    _glfwIsWindows10BuildOrGreaterWin32(14393)
-#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
-    _glfwIsWindows10BuildOrGreaterWin32(15063)
-
-// HACK: Define macros that some xinput.h variants don't
-#ifndef XINPUT_CAPS_WIRELESS
- #define XINPUT_CAPS_WIRELESS 0x0002
-#endif
-#ifndef XINPUT_DEVSUBTYPE_WHEEL
- #define XINPUT_DEVSUBTYPE_WHEEL 0x02
-#endif
-#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
- #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
-#endif
-#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
- #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
-#endif
-#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
- #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
-#endif
-#ifndef XINPUT_DEVSUBTYPE_GUITAR
- #define XINPUT_DEVSUBTYPE_GUITAR 0x06
-#endif
-#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
- #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
-#endif
-#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
- #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
-#endif
-#ifndef XUSER_MAX_COUNT
- #define XUSER_MAX_COUNT 4
-#endif
-
-// HACK: Define macros that some dinput.h variants don't
-#ifndef DIDFT_OPTIONAL
- #define DIDFT_OPTIONAL 0x80000000
-#endif
-
-// winmm.dll function pointer typedefs
-typedef DWORD (WINAPI * PFN_timeGetTime)(void);
-#define timeGetTime _glfw.win32.winmm.GetTime
-
-// xinput.dll function pointer typedefs
-typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
-typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
-#define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
-#define XInputGetState _glfw.win32.xinput.GetState
-
-// dinput8.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
-#define DirectInput8Create _glfw.win32.dinput8.Create
-
-// user32.dll function pointer typedefs
-typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
-typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
-typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
-typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
-typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
-typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
-#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
-#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
-#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
-#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
-#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
-#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
-
-// dwmapi.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
-typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
-typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
-typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
-#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
-#define DwmFlush _glfw.win32.dwmapi.Flush
-#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
-#define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
-
-// shcore.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
-typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
-#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
-#define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
-
-// ntdll.dll function pointer typedefs
-typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
-#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
-
-typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
-
-typedef struct VkWin32SurfaceCreateInfoKHR
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkWin32SurfaceCreateFlagsKHR    flags;
-    HINSTANCE                       hinstance;
-    HWND                            hwnd;
-} VkWin32SurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
-
-#include "win32_joystick.h"
-#include "wgl_context.h"
-
-#if !defined(_GLFW_WNDCLASSNAME)
- #define _GLFW_WNDCLASSNAME L"GLFW30"
-#endif
-
-#define _glfw_dlopen(name) LoadLibraryA(name)
-#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
-#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWin32  win32
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE  _GLFWtimerWin32   win32
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWin32 win32
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWin32  win32
-#define _GLFW_PLATFORM_TLS_STATE            _GLFWtlsWin32     win32
-#define _GLFW_PLATFORM_MUTEX_STATE          _GLFWmutexWin32   win32
-
-
-// Win32-specific per-window data
-//
-typedef struct _GLFWwindowWin32
-{
-    HWND                handle;
-    HICON               bigIcon;
-    HICON               smallIcon;
-
-    GLFWbool            cursorTracked;
-    GLFWbool            frameAction;
-    GLFWbool            iconified;
-    GLFWbool            maximized;
-    // Whether to enable framebuffer transparency on DWM
-    GLFWbool            transparent;
-    GLFWbool            scaleToMonitor;
-    GLFWbool            keymenu;
-
-    // The last received cursor position, regardless of source
-    int                 lastCursorPosX, lastCursorPosY;
-    // The last recevied high surrogate when decoding pairs of UTF-16 messages
-    WCHAR               highSurrogate;
-
-} _GLFWwindowWin32;
-
-// Win32-specific global data
-//
-typedef struct _GLFWlibraryWin32
-{
-    HWND                helperWindowHandle;
-    HDEVNOTIFY          deviceNotificationHandle;
-    DWORD               foregroundLockTimeout;
-    int                 acquiredMonitorCount;
-    char*               clipboardString;
-    short int           keycodes[512];
-    short int           scancodes[GLFW_KEY_LAST + 1];
-    char                keynames[GLFW_KEY_LAST + 1][5];
-    // Where to place the cursor when re-enabled
-    double              restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*        disabledCursorWindow;
-    RAWINPUT*           rawInput;
-    int                 rawInputSize;
-    UINT                mouseTrailSize;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_timeGetTime                 GetTime;
-    } winmm;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_DirectInput8Create          Create;
-        IDirectInput8W*                 api;
-    } dinput8;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_XInputGetCapabilities       GetCapabilities;
-        PFN_XInputGetState              GetState;
-    } xinput;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_SetProcessDPIAware          SetProcessDPIAware_;
-        PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
-        PFN_EnableNonClientDpiScaling   EnableNonClientDpiScaling_;
-        PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
-        PFN_GetDpiForWindow             GetDpiForWindow_;
-        PFN_AdjustWindowRectExForDpi    AdjustWindowRectExForDpi_;
-    } user32;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_DwmIsCompositionEnabled     IsCompositionEnabled;
-        PFN_DwmFlush                    Flush;
-        PFN_DwmEnableBlurBehindWindow   EnableBlurBehindWindow;
-        PFN_DwmGetColorizationColor     GetColorizationColor;
-    } dwmapi;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_SetProcessDpiAwareness      SetProcessDpiAwareness_;
-        PFN_GetDpiForMonitor            GetDpiForMonitor_;
-    } shcore;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_RtlVerifyVersionInfo        RtlVerifyVersionInfo_;
-    } ntdll;
-
-} _GLFWlibraryWin32;
-
-// Win32-specific per-monitor data
-//
-typedef struct _GLFWmonitorWin32
-{
-    HMONITOR            handle;
-    // This size matches the static size of DISPLAY_DEVICE.DeviceName
-    WCHAR               adapterName[32];
-    WCHAR               displayName[32];
-    char                publicAdapterName[32];
-    char                publicDisplayName[32];
-    GLFWbool            modesPruned;
-    GLFWbool            modeChanged;
-
-} _GLFWmonitorWin32;
-
-// Win32-specific per-cursor data
-//
-typedef struct _GLFWcursorWin32
-{
-    HCURSOR             handle;
-
-} _GLFWcursorWin32;
-
-// Win32-specific global timer data
-//
-typedef struct _GLFWtimerWin32
-{
-    GLFWbool            hasPC;
-    uint64_t            frequency;
-
-} _GLFWtimerWin32;
-
-// Win32-specific thread local storage data
-//
-typedef struct _GLFWtlsWin32
-{
-    GLFWbool            allocated;
-    DWORD               index;
-
-} _GLFWtlsWin32;
-
-// Win32-specific mutex data
-//
-typedef struct _GLFWmutexWin32
-{
-    GLFWbool            allocated;
-    CRITICAL_SECTION    section;
-
-} _GLFWmutexWin32;
-
-
-GLFWbool _glfwRegisterWindowClassWin32(void);
-void _glfwUnregisterWindowClassWin32(void);
-
-WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
-char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
-BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
-BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
-void _glfwInputErrorWin32(int error, const char* description);
-void _glfwUpdateKeyNamesWin32(void);
-
-void _glfwInitTimerWin32(void);
-
-void _glfwPollMonitorsWin32(void);
-void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
-void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
-
diff --git a/raylib/external/glfw/src/win32_thread.c b/raylib/external/glfw/src/win32_thread.c
deleted file mode 100644 (file)
index 53b34af..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
-{
-    assert(tls->win32.allocated == GLFW_FALSE);
-
-    tls->win32.index = TlsAlloc();
-    if (tls->win32.index == TLS_OUT_OF_INDEXES)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to allocate TLS index");
-        return GLFW_FALSE;
-    }
-
-    tls->win32.allocated = GLFW_TRUE;
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyTls(_GLFWtls* tls)
-{
-    if (tls->win32.allocated)
-        TlsFree(tls->win32.index);
-    memset(tls, 0, sizeof(_GLFWtls));
-}
-
-void* _glfwPlatformGetTls(_GLFWtls* tls)
-{
-    assert(tls->win32.allocated == GLFW_TRUE);
-    return TlsGetValue(tls->win32.index);
-}
-
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
-{
-    assert(tls->win32.allocated == GLFW_TRUE);
-    TlsSetValue(tls->win32.index, value);
-}
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_FALSE);
-    InitializeCriticalSection(&mutex->win32.section);
-    return mutex->win32.allocated = GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
-{
-    if (mutex->win32.allocated)
-        DeleteCriticalSection(&mutex->win32.section);
-    memset(mutex, 0, sizeof(_GLFWmutex));
-}
-
-void _glfwPlatformLockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_TRUE);
-    EnterCriticalSection(&mutex->win32.section);
-}
-
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_TRUE);
-    LeaveCriticalSection(&mutex->win32.section);
-}
-
diff --git a/raylib/external/glfw/src/win32_time.c b/raylib/external/glfw/src/win32_time.c
deleted file mode 100644 (file)
index 721b0d0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerWin32(void)
-{
-    uint64_t frequency;
-
-    if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
-    {
-        _glfw.timer.win32.hasPC = GLFW_TRUE;
-        _glfw.timer.win32.frequency = frequency;
-    }
-    else
-    {
-        _glfw.timer.win32.hasPC = GLFW_FALSE;
-        _glfw.timer.win32.frequency = 1000;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-    if (_glfw.timer.win32.hasPC)
-    {
-        uint64_t value;
-        QueryPerformanceCounter((LARGE_INTEGER*) &value);
-        return value;
-    }
-    else
-        return (uint64_t) timeGetTime();
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.win32.frequency;
-}
-
diff --git a/raylib/external/glfw/src/win32_window.c b/raylib/external/glfw/src/win32_window.c
deleted file mode 100644 (file)
index 8cb5050..0000000
+++ /dev/null
@@ -1,2372 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <string.h>
-#include <windowsx.h>
-#include <shellapi.h>
-
-// Returns the window style for the specified window
-//
-static DWORD getWindowStyle(const _GLFWwindow* window)
-{
-    DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
-
-    if (window->monitor)
-        style |= WS_POPUP;
-    else
-    {
-        style |= WS_SYSMENU | WS_MINIMIZEBOX;
-
-        if (window->decorated)
-        {
-            style |= WS_CAPTION;
-
-            if (window->resizable)
-                style |= WS_MAXIMIZEBOX | WS_THICKFRAME;
-        }
-        else
-            style |= WS_POPUP;
-    }
-
-    return style;
-}
-
-// Returns the extended window style for the specified window
-//
-static DWORD getWindowExStyle(const _GLFWwindow* window)
-{
-    DWORD style = WS_EX_APPWINDOW;
-
-    if (window->monitor || window->floating)
-        style |= WS_EX_TOPMOST;
-
-    return style;
-}
-
-// Returns the image whose area most closely matches the desired one
-//
-static const GLFWimage* chooseImage(int count, const GLFWimage* images,
-                                    int width, int height)
-{
-    int i, leastDiff = INT_MAX;
-    const GLFWimage* closest = NULL;
-
-    for (i = 0;  i < count;  i++)
-    {
-        const int currDiff = abs(images[i].width * images[i].height -
-                                 width * height);
-        if (currDiff < leastDiff)
-        {
-            closest = images + i;
-            leastDiff = currDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Creates an RGBA icon or cursor
-//
-static HICON createIcon(const GLFWimage* image,
-                        int xhot, int yhot, GLFWbool icon)
-{
-    int i;
-    HDC dc;
-    HICON handle;
-    HBITMAP color, mask;
-    BITMAPV5HEADER bi;
-    ICONINFO ii;
-    unsigned char* target = NULL;
-    unsigned char* source = image->pixels;
-
-    ZeroMemory(&bi, sizeof(bi));
-    bi.bV5Size        = sizeof(bi);
-    bi.bV5Width       = image->width;
-    bi.bV5Height      = -image->height;
-    bi.bV5Planes      = 1;
-    bi.bV5BitCount    = 32;
-    bi.bV5Compression = BI_BITFIELDS;
-    bi.bV5RedMask     = 0x00ff0000;
-    bi.bV5GreenMask   = 0x0000ff00;
-    bi.bV5BlueMask    = 0x000000ff;
-    bi.bV5AlphaMask   = 0xff000000;
-
-    dc = GetDC(NULL);
-    color = CreateDIBSection(dc,
-                             (BITMAPINFO*) &bi,
-                             DIB_RGB_COLORS,
-                             (void**) &target,
-                             NULL,
-                             (DWORD) 0);
-    ReleaseDC(NULL, dc);
-
-    if (!color)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create RGBA bitmap");
-        return NULL;
-    }
-
-    mask = CreateBitmap(image->width, image->height, 1, 1, NULL);
-    if (!mask)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create mask bitmap");
-        DeleteObject(color);
-        return NULL;
-    }
-
-    for (i = 0;  i < image->width * image->height;  i++)
-    {
-        target[0] = source[2];
-        target[1] = source[1];
-        target[2] = source[0];
-        target[3] = source[3];
-        target += 4;
-        source += 4;
-    }
-
-    ZeroMemory(&ii, sizeof(ii));
-    ii.fIcon    = icon;
-    ii.xHotspot = xhot;
-    ii.yHotspot = yhot;
-    ii.hbmMask  = mask;
-    ii.hbmColor = color;
-
-    handle = CreateIconIndirect(&ii);
-
-    DeleteObject(color);
-    DeleteObject(mask);
-
-    if (!handle)
-    {
-        if (icon)
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "Win32: Failed to create icon");
-        }
-        else
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "Win32: Failed to create cursor");
-        }
-    }
-
-    return handle;
-}
-
-// Translate content area size to full window size according to styles and DPI
-//
-static void getFullWindowSize(DWORD style, DWORD exStyle,
-                              int contentWidth, int contentHeight,
-                              int* fullWidth, int* fullHeight,
-                              UINT dpi)
-{
-    RECT rect = { 0, 0, contentWidth, contentHeight };
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
-    else
-        AdjustWindowRectEx(&rect, style, FALSE, exStyle);
-
-    *fullWidth = rect.right - rect.left;
-    *fullHeight = rect.bottom - rect.top;
-}
-
-// Enforce the content area aspect ratio based on which edge is being dragged
-//
-static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
-{
-    int xoff, yoff;
-    UINT dpi = USER_DEFAULT_SCREEN_DPI;
-    const float ratio = (float) window->numer / (float) window->denom;
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        dpi = GetDpiForWindow(window->win32.handle);
-
-    getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
-                      0, 0, &xoff, &yoff, dpi);
-
-    if (edge == WMSZ_LEFT  || edge == WMSZ_BOTTOMLEFT ||
-        edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
-    {
-        area->bottom = area->top + yoff +
-            (int) ((area->right - area->left - xoff) / ratio);
-    }
-    else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
-    {
-        area->top = area->bottom - yoff -
-            (int) ((area->right - area->left - xoff) / ratio);
-    }
-    else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
-    {
-        area->right = area->left + xoff +
-            (int) ((area->bottom - area->top - yoff) * ratio);
-    }
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (window->cursor)
-            SetCursor(window->cursor->win32.handle);
-        else
-            SetCursor(LoadCursorW(NULL, IDC_ARROW));
-    }
-    else
-        SetCursor(NULL);
-}
-
-// Updates the cursor clip rect
-//
-static void updateClipRect(_GLFWwindow* window)
-{
-    if (window)
-    {
-        RECT clipRect;
-        GetClientRect(window->win32.handle, &clipRect);
-        ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
-        ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
-        ClipCursor(&clipRect);
-    }
-    else
-        ClipCursor(NULL);
-}
-
-// Enables WM_INPUT messages for the mouse for the specified window
-//
-static void enableRawMouseMotion(_GLFWwindow* window)
-{
-    const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle };
-
-    if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to register raw input device");
-    }
-}
-
-// Disables WM_INPUT messages for the mouse
-//
-static void disableRawMouseMotion(_GLFWwindow* window)
-{
-    const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE, NULL };
-
-    if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to remove raw input device");
-    }
-}
-
-// Apply disabled cursor mode to a focused window
-//
-static void disableCursor(_GLFWwindow* window)
-{
-    _glfw.win32.disabledCursorWindow = window;
-    _glfwPlatformGetCursorPos(window,
-                              &_glfw.win32.restoreCursorPosX,
-                              &_glfw.win32.restoreCursorPosY);
-    updateCursorImage(window);
-    _glfwCenterCursorInContentArea(window);
-    updateClipRect(window);
-
-    if (window->rawMouseMotion)
-        enableRawMouseMotion(window);
-}
-
-// Exit disabled cursor mode for the specified window
-//
-static void enableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        disableRawMouseMotion(window);
-
-    _glfw.win32.disabledCursorWindow = NULL;
-    updateClipRect(NULL);
-    _glfwPlatformSetCursorPos(window,
-                              _glfw.win32.restoreCursorPosX,
-                              _glfw.win32.restoreCursorPosY);
-    updateCursorImage(window);
-}
-
-// Returns whether the cursor is in the content area of the specified window
-//
-static GLFWbool cursorInContentArea(_GLFWwindow* window)
-{
-    RECT area;
-    POINT pos;
-
-    if (!GetCursorPos(&pos))
-        return GLFW_FALSE;
-
-    if (WindowFromPoint(pos) != window->win32.handle)
-        return GLFW_FALSE;
-
-    GetClientRect(window->win32.handle, &area);
-    ClientToScreen(window->win32.handle, (POINT*) &area.left);
-    ClientToScreen(window->win32.handle, (POINT*) &area.right);
-
-    return PtInRect(&area, pos);
-}
-
-// Update native window styles to match attributes
-//
-static void updateWindowStyles(const _GLFWwindow* window)
-{
-    RECT rect;
-    DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-    style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP);
-    style |= getWindowStyle(window);
-
-    GetClientRect(window->win32.handle, &rect);
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, style, FALSE,
-                                 getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-        AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
-
-    ClientToScreen(window->win32.handle, (POINT*) &rect.left);
-    ClientToScreen(window->win32.handle, (POINT*) &rect.right);
-    SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-    SetWindowPos(window->win32.handle, HWND_TOP,
-                 rect.left, rect.top,
-                 rect.right - rect.left, rect.bottom - rect.top,
-                 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER);
-}
-
-// Update window framebuffer transparency
-//
-static void updateFramebufferTransparency(const _GLFWwindow* window)
-{
-    BOOL composition, opaque;
-    DWORD color;
-
-    if (!IsWindowsVistaOrGreater())
-        return;
-
-    if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
-       return;
-
-    if (IsWindows8OrGreater() ||
-        (SUCCEEDED(DwmGetColorizationColor(&color, &opaque)) && !opaque))
-    {
-        HRGN region = CreateRectRgn(0, 0, -1, -1);
-        DWM_BLURBEHIND bb = {0};
-        bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
-        bb.hRgnBlur = region;
-        bb.fEnable = TRUE;
-
-        DwmEnableBlurBehindWindow(window->win32.handle, &bb);
-        DeleteObject(region);
-    }
-    else
-    {
-        // HACK: Disable framebuffer transparency on Windows 7 when the
-        //       colorization color is opaque, because otherwise the window
-        //       contents is blended additively with the previous frame instead
-        //       of replacing it
-        DWM_BLURBEHIND bb = {0};
-        bb.dwFlags = DWM_BB_ENABLE;
-        DwmEnableBlurBehindWindow(window->win32.handle, &bb);
-    }
-}
-
-// Retrieves and translates modifier keys
-//
-static int getKeyMods(void)
-{
-    int mods = 0;
-
-    if (GetKeyState(VK_SHIFT) & 0x8000)
-        mods |= GLFW_MOD_SHIFT;
-    if (GetKeyState(VK_CONTROL) & 0x8000)
-        mods |= GLFW_MOD_CONTROL;
-    if (GetKeyState(VK_MENU) & 0x8000)
-        mods |= GLFW_MOD_ALT;
-    if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
-        mods |= GLFW_MOD_SUPER;
-    if (GetKeyState(VK_CAPITAL) & 1)
-        mods |= GLFW_MOD_CAPS_LOCK;
-    if (GetKeyState(VK_NUMLOCK) & 1)
-        mods |= GLFW_MOD_NUM_LOCK;
-
-    return mods;
-}
-
-static void fitToMonitor(_GLFWwindow* window)
-{
-    MONITORINFO mi = { sizeof(mi) };
-    GetMonitorInfo(window->monitor->win32.handle, &mi);
-    SetWindowPos(window->win32.handle, HWND_TOPMOST,
-                 mi.rcMonitor.left,
-                 mi.rcMonitor.top,
-                 mi.rcMonitor.right - mi.rcMonitor.left,
-                 mi.rcMonitor.bottom - mi.rcMonitor.top,
-                 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    if (!_glfw.win32.acquiredMonitorCount)
-    {
-        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
-
-        // HACK: When mouse trails are enabled the cursor becomes invisible when
-        //       the OpenGL ICD switches to page flipping
-        SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
-        SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
-    }
-
-    if (!window->monitor->window)
-        _glfw.win32.acquiredMonitorCount++;
-
-    _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfw.win32.acquiredMonitorCount--;
-    if (!_glfw.win32.acquiredMonitorCount)
-    {
-        SetThreadExecutionState(ES_CONTINUOUS);
-
-        // HACK: Restore mouse trail length saved in acquireMonitor
-        SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
-    }
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeWin32(window->monitor);
-}
-
-// Window callback function (handles window messages)
-//
-static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
-                                   WPARAM wParam, LPARAM lParam)
-{
-    _GLFWwindow* window = GetPropW(hWnd, L"GLFW");
-    if (!window)
-    {
-        // This is the message handling for the hidden helper window
-        // and for a regular window during its initial creation
-
-        switch (uMsg)
-        {
-            case WM_NCCREATE:
-            {
-                if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-                    EnableNonClientDpiScaling(hWnd);
-
-                break;
-            }
-
-            case WM_DISPLAYCHANGE:
-                _glfwPollMonitorsWin32();
-                break;
-
-            case WM_DEVICECHANGE:
-            {
-                if (!_glfw.joysticksInitialized)
-                    break;
-
-                if (wParam == DBT_DEVICEARRIVAL)
-                {
-                    DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
-                    if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
-                        _glfwDetectJoystickConnectionWin32();
-                }
-                else if (wParam == DBT_DEVICEREMOVECOMPLETE)
-                {
-                    DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
-                    if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
-                        _glfwDetectJoystickDisconnectionWin32();
-                }
-
-                break;
-            }
-        }
-
-        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-    }
-
-    switch (uMsg)
-    {
-        case WM_MOUSEACTIVATE:
-        {
-            // HACK: Postpone cursor disabling when the window was activated by
-            //       clicking a caption button
-            if (HIWORD(lParam) == WM_LBUTTONDOWN)
-            {
-                if (LOWORD(lParam) != HTCLIENT)
-                    window->win32.frameAction = GLFW_TRUE;
-            }
-
-            break;
-        }
-
-        case WM_CAPTURECHANGED:
-        {
-            // HACK: Disable the cursor once the caption button action has been
-            //       completed or cancelled
-            if (lParam == 0 && window->win32.frameAction)
-            {
-                if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                    disableCursor(window);
-
-                window->win32.frameAction = GLFW_FALSE;
-            }
-
-            break;
-        }
-
-        case WM_SETFOCUS:
-        {
-            _glfwInputWindowFocus(window, GLFW_TRUE);
-
-            // HACK: Do not disable cursor while the user is interacting with
-            //       a caption button
-            if (window->win32.frameAction)
-                break;
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            return 0;
-        }
-
-        case WM_KILLFOCUS:
-        {
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            if (window->monitor && window->autoIconify)
-                _glfwPlatformIconifyWindow(window);
-
-            _glfwInputWindowFocus(window, GLFW_FALSE);
-            return 0;
-        }
-
-        case WM_SYSCOMMAND:
-        {
-            switch (wParam & 0xfff0)
-            {
-                case SC_SCREENSAVE:
-                case SC_MONITORPOWER:
-                {
-                    if (window->monitor)
-                    {
-                        // We are running in full screen mode, so disallow
-                        // screen saver and screen blanking
-                        return 0;
-                    }
-                    else
-                        break;
-                }
-
-                // User trying to access application menu using ALT?
-                case SC_KEYMENU:
-                {
-                    if (!window->win32.keymenu)
-                        return 0;
-
-                    break;
-                }
-            }
-            break;
-        }
-
-        case WM_CLOSE:
-        {
-            _glfwInputWindowCloseRequest(window);
-            return 0;
-        }
-
-        case WM_INPUTLANGCHANGE:
-        {
-            _glfwUpdateKeyNamesWin32();
-            break;
-        }
-
-        case WM_CHAR:
-        case WM_SYSCHAR:
-        {
-            if (wParam >= 0xd800 && wParam <= 0xdbff)
-                window->win32.highSurrogate = (WCHAR) wParam;
-            else
-            {
-                unsigned int codepoint = 0;
-
-                if (wParam >= 0xdc00 && wParam <= 0xdfff)
-                {
-                    if (window->win32.highSurrogate)
-                    {
-                        codepoint += (window->win32.highSurrogate - 0xd800) << 10;
-                        codepoint += (WCHAR) wParam - 0xdc00;
-                        codepoint += 0x10000;
-                    }
-                }
-                else
-                    codepoint = (WCHAR) wParam;
-
-                window->win32.highSurrogate = 0;
-                _glfwInputChar(window, codepoint, getKeyMods(), uMsg != WM_SYSCHAR);
-            }
-
-            if (uMsg == WM_SYSCHAR && window->win32.keymenu)
-                break;
-
-            return 0;
-        }
-
-        case WM_UNICHAR:
-        {
-            if (wParam == UNICODE_NOCHAR)
-            {
-                // WM_UNICHAR is not sent by Windows, but is sent by some
-                // third-party input method engine
-                // Returning TRUE here announces support for this message
-                return TRUE;
-            }
-
-            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE);
-            return 0;
-        }
-
-        case WM_KEYDOWN:
-        case WM_SYSKEYDOWN:
-        case WM_KEYUP:
-        case WM_SYSKEYUP:
-        {
-            int key, scancode;
-            const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS;
-            const int mods = getKeyMods();
-
-            scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff));
-            if (!scancode)
-            {
-                // NOTE: Some synthetic key messages have a scancode of zero
-                // HACK: Map the virtual key back to a usable scancode
-                scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
-            }
-
-            key = _glfw.win32.keycodes[scancode];
-
-            // The Ctrl keys require special handling
-            if (wParam == VK_CONTROL)
-            {
-                if (HIWORD(lParam) & KF_EXTENDED)
-                {
-                    // Right side keys have the extended key bit set
-                    key = GLFW_KEY_RIGHT_CONTROL;
-                }
-                else
-                {
-                    // NOTE: Alt Gr sends Left Ctrl followed by Right Alt
-                    // HACK: We only want one event for Alt Gr, so if we detect
-                    //       this sequence we discard this Left Ctrl message now
-                    //       and later report Right Alt normally
-                    MSG next;
-                    const DWORD time = GetMessageTime();
-
-                    if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
-                    {
-                        if (next.message == WM_KEYDOWN ||
-                            next.message == WM_SYSKEYDOWN ||
-                            next.message == WM_KEYUP ||
-                            next.message == WM_SYSKEYUP)
-                        {
-                            if (next.wParam == VK_MENU &&
-                                (HIWORD(next.lParam) & KF_EXTENDED) &&
-                                next.time == time)
-                            {
-                                // Next message is Right Alt down so discard this
-                                break;
-                            }
-                        }
-                    }
-
-                    // This is a regular Left Ctrl message
-                    key = GLFW_KEY_LEFT_CONTROL;
-                }
-            }
-            else if (wParam == VK_PROCESSKEY)
-            {
-                // IME notifies that keys have been filtered by setting the
-                // virtual key-code to VK_PROCESSKEY
-                break;
-            }
-
-            if (action == GLFW_RELEASE && wParam == VK_SHIFT)
-            {
-                // HACK: Release both Shift keys on Shift up event, as when both
-                //       are pressed the first release does not emit any event
-                // NOTE: The other half of this is in _glfwPlatformPollEvents
-                _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
-                _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
-            }
-            else if (wParam == VK_SNAPSHOT)
-            {
-                // HACK: Key down is not reported for the Print Screen key
-                _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
-            }
-            else
-                _glfwInputKey(window, key, scancode, action, mods);
-
-            break;
-        }
-
-        case WM_LBUTTONDOWN:
-        case WM_RBUTTONDOWN:
-        case WM_MBUTTONDOWN:
-        case WM_XBUTTONDOWN:
-        case WM_LBUTTONUP:
-        case WM_RBUTTONUP:
-        case WM_MBUTTONUP:
-        case WM_XBUTTONUP:
-        {
-            int i, button, action;
-
-            if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_LEFT;
-            else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_RIGHT;
-            else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_MIDDLE;
-            else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
-                button = GLFW_MOUSE_BUTTON_4;
-            else
-                button = GLFW_MOUSE_BUTTON_5;
-
-            if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN ||
-                uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
-            {
-                action = GLFW_PRESS;
-            }
-            else
-                action = GLFW_RELEASE;
-
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == GLFW_PRESS)
-                    break;
-            }
-
-            if (i > GLFW_MOUSE_BUTTON_LAST)
-                SetCapture(hWnd);
-
-            _glfwInputMouseClick(window, button, action, getKeyMods());
-
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == GLFW_PRESS)
-                    break;
-            }
-
-            if (i > GLFW_MOUSE_BUTTON_LAST)
-                ReleaseCapture();
-
-            if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
-                return TRUE;
-
-            return 0;
-        }
-
-        case WM_MOUSEMOVE:
-        {
-            const int x = GET_X_LPARAM(lParam);
-            const int y = GET_Y_LPARAM(lParam);
-
-            if (!window->win32.cursorTracked)
-            {
-                TRACKMOUSEEVENT tme;
-                ZeroMemory(&tme, sizeof(tme));
-                tme.cbSize = sizeof(tme);
-                tme.dwFlags = TME_LEAVE;
-                tme.hwndTrack = window->win32.handle;
-                TrackMouseEvent(&tme);
-
-                window->win32.cursorTracked = GLFW_TRUE;
-                _glfwInputCursorEnter(window, GLFW_TRUE);
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-            {
-                const int dx = x - window->win32.lastCursorPosX;
-                const int dy = y - window->win32.lastCursorPosY;
-
-                if (_glfw.win32.disabledCursorWindow != window)
-                    break;
-                if (window->rawMouseMotion)
-                    break;
-
-                _glfwInputCursorPos(window,
-                                    window->virtualCursorPosX + dx,
-                                    window->virtualCursorPosY + dy);
-            }
-            else
-                _glfwInputCursorPos(window, x, y);
-
-            window->win32.lastCursorPosX = x;
-            window->win32.lastCursorPosY = y;
-
-            return 0;
-        }
-
-        case WM_INPUT:
-        {
-            UINT size = 0;
-            HRAWINPUT ri = (HRAWINPUT) lParam;
-            RAWINPUT* data = NULL;
-            int dx, dy;
-
-            if (_glfw.win32.disabledCursorWindow != window)
-                break;
-            if (!window->rawMouseMotion)
-                break;
-
-            GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
-            if (size > (UINT) _glfw.win32.rawInputSize)
-            {
-                free(_glfw.win32.rawInput);
-                _glfw.win32.rawInput = calloc(size, 1);
-                _glfw.win32.rawInputSize = size;
-            }
-
-            size = _glfw.win32.rawInputSize;
-            if (GetRawInputData(ri, RID_INPUT,
-                                _glfw.win32.rawInput, &size,
-                                sizeof(RAWINPUTHEADER)) == (UINT) -1)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Win32: Failed to retrieve raw input data");
-                break;
-            }
-
-            data = _glfw.win32.rawInput;
-            if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
-            {
-                dx = data->data.mouse.lLastX - window->win32.lastCursorPosX;
-                dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
-            }
-            else
-            {
-                dx = data->data.mouse.lLastX;
-                dy = data->data.mouse.lLastY;
-            }
-
-            _glfwInputCursorPos(window,
-                                window->virtualCursorPosX + dx,
-                                window->virtualCursorPosY + dy);
-
-            window->win32.lastCursorPosX += dx;
-            window->win32.lastCursorPosY += dy;
-            break;
-        }
-
-        case WM_MOUSELEAVE:
-        {
-            window->win32.cursorTracked = GLFW_FALSE;
-            _glfwInputCursorEnter(window, GLFW_FALSE);
-            return 0;
-        }
-
-        case WM_MOUSEWHEEL:
-        {
-            _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
-            return 0;
-        }
-
-        case WM_MOUSEHWHEEL:
-        {
-            // This message is only sent on Windows Vista and later
-            // NOTE: The X-axis is inverted for consistency with macOS and X11
-            _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
-            return 0;
-        }
-
-        case WM_ENTERSIZEMOVE:
-        case WM_ENTERMENULOOP:
-        {
-            if (window->win32.frameAction)
-                break;
-
-            // HACK: Enable the cursor while the user is moving or
-            //       resizing the window or using the window menu
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            break;
-        }
-
-        case WM_EXITSIZEMOVE:
-        case WM_EXITMENULOOP:
-        {
-            if (window->win32.frameAction)
-                break;
-
-            // HACK: Disable the cursor once the user is done moving or
-            //       resizing the window or using the menu
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            break;
-        }
-
-        case WM_SIZE:
-        {
-            const GLFWbool iconified = wParam == SIZE_MINIMIZED;
-            const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
-                                       (window->win32.maximized &&
-                                        wParam != SIZE_RESTORED);
-
-            if (_glfw.win32.disabledCursorWindow == window)
-                updateClipRect(window);
-
-            if (window->win32.iconified != iconified)
-                _glfwInputWindowIconify(window, iconified);
-
-            if (window->win32.maximized != maximized)
-                _glfwInputWindowMaximize(window, maximized);
-
-            _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
-            _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
-
-            if (window->monitor && window->win32.iconified != iconified)
-            {
-                if (iconified)
-                    releaseMonitor(window);
-                else
-                {
-                    acquireMonitor(window);
-                    fitToMonitor(window);
-                }
-            }
-
-            window->win32.iconified = iconified;
-            window->win32.maximized = maximized;
-            return 0;
-        }
-
-        case WM_MOVE:
-        {
-            if (_glfw.win32.disabledCursorWindow == window)
-                updateClipRect(window);
-
-            // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
-            // those macros do not handle negative window positions correctly
-            _glfwInputWindowPos(window,
-                                GET_X_LPARAM(lParam),
-                                GET_Y_LPARAM(lParam));
-            return 0;
-        }
-
-        case WM_SIZING:
-        {
-            if (window->numer == GLFW_DONT_CARE ||
-                window->denom == GLFW_DONT_CARE)
-            {
-                break;
-            }
-
-            applyAspectRatio(window, (int) wParam, (RECT*) lParam);
-            return TRUE;
-        }
-
-        case WM_GETMINMAXINFO:
-        {
-            int xoff, yoff;
-            UINT dpi = USER_DEFAULT_SCREEN_DPI;
-            MINMAXINFO* mmi = (MINMAXINFO*) lParam;
-
-            if (window->monitor)
-                break;
-
-            if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-                dpi = GetDpiForWindow(window->win32.handle);
-
-            getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
-                              0, 0, &xoff, &yoff, dpi);
-
-            if (window->minwidth != GLFW_DONT_CARE &&
-                window->minheight != GLFW_DONT_CARE)
-            {
-                mmi->ptMinTrackSize.x = window->minwidth + xoff;
-                mmi->ptMinTrackSize.y = window->minheight + yoff;
-            }
-
-            if (window->maxwidth != GLFW_DONT_CARE &&
-                window->maxheight != GLFW_DONT_CARE)
-            {
-                mmi->ptMaxTrackSize.x = window->maxwidth + xoff;
-                mmi->ptMaxTrackSize.y = window->maxheight + yoff;
-            }
-
-            if (!window->decorated)
-            {
-                MONITORINFO mi;
-                const HMONITOR mh = MonitorFromWindow(window->win32.handle,
-                                                      MONITOR_DEFAULTTONEAREST);
-
-                ZeroMemory(&mi, sizeof(mi));
-                mi.cbSize = sizeof(mi);
-                GetMonitorInfo(mh, &mi);
-
-                mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
-                mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
-                mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
-                mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
-            }
-
-            return 0;
-        }
-
-        case WM_PAINT:
-        {
-            _glfwInputWindowDamage(window);
-            break;
-        }
-
-        case WM_ERASEBKGND:
-        {
-            return TRUE;
-        }
-
-        case WM_NCACTIVATE:
-        case WM_NCPAINT:
-        {
-            // Prevent title bar from being drawn after restoring a minimized
-            // undecorated window
-            if (!window->decorated)
-                return TRUE;
-
-            break;
-        }
-
-        case WM_DWMCOMPOSITIONCHANGED:
-        case WM_DWMCOLORIZATIONCOLORCHANGED:
-        {
-            if (window->win32.transparent)
-                updateFramebufferTransparency(window);
-            return 0;
-        }
-
-        case WM_GETDPISCALEDSIZE:
-        {
-            if (window->win32.scaleToMonitor)
-                break;
-
-            // Adjust the window size to keep the content area size constant
-            if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-            {
-                RECT source = {0}, target = {0};
-                SIZE* size = (SIZE*) lParam;
-
-                AdjustWindowRectExForDpi(&source, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         GetDpiForWindow(window->win32.handle));
-                AdjustWindowRectExForDpi(&target, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         LOWORD(wParam));
-
-                size->cx += (target.right - target.left) -
-                            (source.right - source.left);
-                size->cy += (target.bottom - target.top) -
-                            (source.bottom - source.top);
-                return TRUE;
-            }
-
-            break;
-        }
-
-        case WM_DPICHANGED:
-        {
-            const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
-            const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
-
-            // Only apply the suggested size if the OS is new enough to have
-            // sent a WM_GETDPISCALEDSIZE before this
-            if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-            {
-                RECT* suggested = (RECT*) lParam;
-                SetWindowPos(window->win32.handle, HWND_TOP,
-                             suggested->left,
-                             suggested->top,
-                             suggested->right - suggested->left,
-                             suggested->bottom - suggested->top,
-                             SWP_NOACTIVATE | SWP_NOZORDER);
-            }
-
-            _glfwInputWindowContentScale(window, xscale, yscale);
-            break;
-        }
-
-        case WM_SETCURSOR:
-        {
-            if (LOWORD(lParam) == HTCLIENT)
-            {
-                updateCursorImage(window);
-                return TRUE;
-            }
-
-            break;
-        }
-
-        case WM_DROPFILES:
-        {
-            HDROP drop = (HDROP) wParam;
-            POINT pt;
-            int i;
-
-            const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
-            char** paths = calloc(count, sizeof(char*));
-
-            // Move the mouse to the position of the drop
-            DragQueryPoint(drop, &pt);
-            _glfwInputCursorPos(window, pt.x, pt.y);
-
-            for (i = 0;  i < count;  i++)
-            {
-                const UINT length = DragQueryFileW(drop, i, NULL, 0);
-                WCHAR* buffer = calloc((size_t) length + 1, sizeof(WCHAR));
-
-                DragQueryFileW(drop, i, buffer, length + 1);
-                paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
-
-                free(buffer);
-            }
-
-            _glfwInputDrop(window, count, (const char**) paths);
-
-            for (i = 0;  i < count;  i++)
-                free(paths[i]);
-            free(paths);
-
-            DragFinish(drop);
-            return 0;
-        }
-    }
-
-    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-}
-
-// Creates the GLFW window
-//
-static int createNativeWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    int xpos, ypos, fullWidth, fullHeight;
-    WCHAR* wideTitle;
-    DWORD style = getWindowStyle(window);
-    DWORD exStyle = getWindowExStyle(window);
-
-    if (window->monitor)
-    {
-        GLFWvidmode mode;
-
-        // NOTE: This window placement is temporary and approximate, as the
-        //       correct position and size cannot be known until the monitor
-        //       video mode has been picked in _glfwSetVideoModeWin32
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-        fullWidth  = mode.width;
-        fullHeight = mode.height;
-    }
-    else
-    {
-        xpos = CW_USEDEFAULT;
-        ypos = CW_USEDEFAULT;
-
-        window->win32.maximized = wndconfig->maximized;
-        if (wndconfig->maximized)
-            style |= WS_MAXIMIZE;
-
-        getFullWindowSize(style, exStyle,
-                          wndconfig->width, wndconfig->height,
-                          &fullWidth, &fullHeight,
-                          USER_DEFAULT_SCREEN_DPI);
-    }
-
-    wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
-    if (!wideTitle)
-        return GLFW_FALSE;
-
-    window->win32.handle = CreateWindowExW(exStyle,
-                                           _GLFW_WNDCLASSNAME,
-                                           wideTitle,
-                                           style,
-                                           xpos, ypos,
-                                           fullWidth, fullHeight,
-                                           NULL, // No parent window
-                                           NULL, // No window menu
-                                           GetModuleHandleW(NULL),
-                                           NULL);
-
-    free(wideTitle);
-
-    if (!window->win32.handle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    SetPropW(window->win32.handle, L"GLFW", window);
-
-    if (IsWindows7OrGreater())
-    {
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_DROPFILES, MSGFLT_ALLOW, NULL);
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_COPYDATA, MSGFLT_ALLOW, NULL);
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
-    }
-
-    window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
-    window->win32.keymenu = wndconfig->win32.keymenu;
-
-    // Adjust window rect to account for DPI scaling of the window frame and
-    // (if enabled) DPI scaling of the content area
-    // This cannot be done until we know what monitor the window was placed on
-    if (!window->monitor)
-    {
-        RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
-        WINDOWPLACEMENT wp = { sizeof(wp) };
-
-        if (wndconfig->scaleToMonitor)
-        {
-            float xscale, yscale;
-            _glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
-            rect.right = (int) (rect.right * xscale);
-            rect.bottom = (int) (rect.bottom * yscale);
-        }
-
-        ClientToScreen(window->win32.handle, (POINT*) &rect.left);
-        ClientToScreen(window->win32.handle, (POINT*) &rect.right);
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle,
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-            AdjustWindowRectEx(&rect, style, FALSE, exStyle);
-
-        // Only update the restored window rect as the window may be maximized
-        GetWindowPlacement(window->win32.handle, &wp);
-        wp.rcNormalPosition = rect;
-        wp.showCmd = SW_HIDE;
-        SetWindowPlacement(window->win32.handle, &wp);
-    }
-
-    DragAcceptFiles(window->win32.handle, TRUE);
-
-    if (fbconfig->transparent)
-    {
-        updateFramebufferTransparency(window);
-        window->win32.transparent = GLFW_TRUE;
-    }
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Registers the GLFW window class
-//
-GLFWbool _glfwRegisterWindowClassWin32(void)
-{
-    WNDCLASSEXW wc;
-
-    ZeroMemory(&wc, sizeof(wc));
-    wc.cbSize        = sizeof(wc);
-    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-    wc.lpfnWndProc   = (WNDPROC) windowProc;
-    wc.hInstance     = GetModuleHandleW(NULL);
-    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
-    wc.lpszClassName = _GLFW_WNDCLASSNAME;
-
-    // Load user-provided icon if available
-    wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
-                          L"GLFW_ICON", IMAGE_ICON,
-                          0, 0, LR_DEFAULTSIZE | LR_SHARED);
-    if (!wc.hIcon)
-    {
-        // No user-provided icon found, load default icon
-        wc.hIcon = LoadImageW(NULL,
-                              IDI_APPLICATION, IMAGE_ICON,
-                              0, 0, LR_DEFAULTSIZE | LR_SHARED);
-    }
-
-    if (!RegisterClassExW(&wc))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to register window class");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Unregisters the GLFW window class
-//
-void _glfwUnregisterWindowClassWin32(void)
-{
-    UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitWGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-        fitToMonitor(window);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    if (_glfw.win32.disabledCursorWindow == window)
-        _glfw.win32.disabledCursorWindow = NULL;
-
-    if (window->win32.handle)
-    {
-        RemovePropW(window->win32.handle, L"GLFW");
-        DestroyWindow(window->win32.handle);
-        window->win32.handle = NULL;
-    }
-
-    if (window->win32.bigIcon)
-        DestroyIcon(window->win32.bigIcon);
-
-    if (window->win32.smallIcon)
-        DestroyIcon(window->win32.smallIcon);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
-    if (!wideTitle)
-        return;
-
-    SetWindowTextW(window->win32.handle, wideTitle);
-    free(wideTitle);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    HICON bigIcon = NULL, smallIcon = NULL;
-
-    if (count)
-    {
-        const GLFWimage* bigImage = chooseImage(count, images,
-                                                GetSystemMetrics(SM_CXICON),
-                                                GetSystemMetrics(SM_CYICON));
-        const GLFWimage* smallImage = chooseImage(count, images,
-                                                  GetSystemMetrics(SM_CXSMICON),
-                                                  GetSystemMetrics(SM_CYSMICON));
-
-        bigIcon = createIcon(bigImage, 0, 0, GLFW_TRUE);
-        smallIcon = createIcon(smallImage, 0, 0, GLFW_TRUE);
-    }
-    else
-    {
-        bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
-        smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
-    }
-
-    SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
-    SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
-
-    if (window->win32.bigIcon)
-        DestroyIcon(window->win32.bigIcon);
-
-    if (window->win32.smallIcon)
-        DestroyIcon(window->win32.smallIcon);
-
-    if (count)
-    {
-        window->win32.bigIcon = bigIcon;
-        window->win32.smallIcon = smallIcon;
-    }
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    POINT pos = { 0, 0 };
-    ClientToScreen(window->win32.handle, &pos);
-
-    if (xpos)
-        *xpos = pos.x;
-    if (ypos)
-        *ypos = pos.y;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    RECT rect = { xpos, ypos, xpos, ypos };
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                 FALSE, getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-    {
-        AdjustWindowRectEx(&rect, getWindowStyle(window),
-                           FALSE, getWindowExStyle(window));
-    }
-
-    SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
-                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    RECT area;
-    GetClientRect(window->win32.handle, &area);
-
-    if (width)
-        *width = area.right;
-    if (height)
-        *height = area.bottom;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-        {
-            acquireMonitor(window);
-            fitToMonitor(window);
-        }
-    }
-    else
-    {
-        RECT rect = { 0, 0, width, height };
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                     FALSE, getWindowExStyle(window),
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-        {
-            AdjustWindowRectEx(&rect, getWindowStyle(window),
-                               FALSE, getWindowExStyle(window));
-        }
-
-        SetWindowPos(window->win32.handle, HWND_TOP,
-                     0, 0, rect.right - rect.left, rect.bottom - rect.top,
-                     SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
-    }
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    RECT area;
-
-    if ((minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) &&
-        (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE))
-    {
-        return;
-    }
-
-    GetWindowRect(window->win32.handle, &area);
-    MoveWindow(window->win32.handle,
-               area.left, area.top,
-               area.right - area.left,
-               area.bottom - area.top, TRUE);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    RECT area;
-
-    if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
-        return;
-
-    GetWindowRect(window->win32.handle, &area);
-    applyAspectRatio(window, WMSZ_BOTTOMRIGHT, &area);
-    MoveWindow(window->win32.handle,
-               area.left, area.top,
-               area.right - area.left,
-               area.bottom - area.top, TRUE);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    RECT rect;
-    int width, height;
-
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    SetRect(&rect, 0, 0, width, height);
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                 FALSE, getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-    {
-        AdjustWindowRectEx(&rect, getWindowStyle(window),
-                           FALSE, getWindowExStyle(window));
-    }
-
-    if (left)
-        *left = -rect.left;
-    if (top)
-        *top = -rect.top;
-    if (right)
-        *right = rect.right - width;
-    if (bottom)
-        *bottom = rect.bottom - height;
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    const HANDLE handle = MonitorFromWindow(window->win32.handle,
-                                            MONITOR_DEFAULTTONEAREST);
-    _glfwGetMonitorContentScaleWin32(handle, xscale, yscale);
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_MINIMIZE);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_RESTORE);
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_MAXIMIZE);
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_SHOWNA);
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_HIDE);
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    FlashWindow(window->win32.handle, TRUE);
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    BringWindowToTop(window->win32.handle);
-    SetForegroundWindow(window->win32.handle);
-    SetFocus(window->win32.handle);
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-            {
-                acquireMonitor(window);
-                fitToMonitor(window);
-            }
-        }
-        else
-        {
-            RECT rect = { xpos, ypos, xpos + width, ypos + height };
-
-            if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-            {
-                AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         GetDpiForWindow(window->win32.handle));
-            }
-            else
-            {
-                AdjustWindowRectEx(&rect, getWindowStyle(window),
-                                   FALSE, getWindowExStyle(window));
-            }
-
-            SetWindowPos(window->win32.handle, HWND_TOP,
-                         rect.left, rect.top,
-                         rect.right - rect.left, rect.bottom - rect.top,
-                         SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOZORDER);
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    if (window->monitor)
-    {
-        MONITORINFO mi = { sizeof(mi) };
-        UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
-
-        if (window->decorated)
-        {
-            DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-            style &= ~WS_OVERLAPPEDWINDOW;
-            style |= getWindowStyle(window);
-            SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-            flags |= SWP_FRAMECHANGED;
-        }
-
-        acquireMonitor(window);
-
-        GetMonitorInfo(window->monitor->win32.handle, &mi);
-        SetWindowPos(window->win32.handle, HWND_TOPMOST,
-                     mi.rcMonitor.left,
-                     mi.rcMonitor.top,
-                     mi.rcMonitor.right - mi.rcMonitor.left,
-                     mi.rcMonitor.bottom - mi.rcMonitor.top,
-                     flags);
-    }
-    else
-    {
-        HWND after;
-        RECT rect = { xpos, ypos, xpos + width, ypos + height };
-        DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-        UINT flags = SWP_NOACTIVATE | SWP_NOCOPYBITS;
-
-        if (window->decorated)
-        {
-            style &= ~WS_POPUP;
-            style |= getWindowStyle(window);
-            SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-
-            flags |= SWP_FRAMECHANGED;
-        }
-
-        if (window->floating)
-            after = HWND_TOPMOST;
-        else
-            after = HWND_NOTOPMOST;
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                     FALSE, getWindowExStyle(window),
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-        {
-            AdjustWindowRectEx(&rect, getWindowStyle(window),
-                               FALSE, getWindowExStyle(window));
-        }
-
-        SetWindowPos(window->win32.handle, after,
-                     rect.left, rect.top,
-                     rect.right - rect.left, rect.bottom - rect.top,
-                     flags);
-    }
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return window->win32.handle == GetActiveWindow();
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return IsIconic(window->win32.handle);
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return IsWindowVisible(window->win32.handle);
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return IsZoomed(window->win32.handle);
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return cursorInContentArea(window);
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    BOOL composition, opaque;
-    DWORD color;
-
-    if (!window->win32.transparent)
-        return GLFW_FALSE;
-
-    if (!IsWindowsVistaOrGreater())
-        return GLFW_FALSE;
-
-    if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
-        return GLFW_FALSE;
-
-    if (!IsWindows8OrGreater())
-    {
-        // HACK: Disable framebuffer transparency on Windows 7 when the
-        //       colorization color is opaque, because otherwise the window
-        //       contents is blended additively with the previous frame instead
-        //       of replacing it
-        if (FAILED(DwmGetColorizationColor(&color, &opaque)) || opaque)
-            return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    updateWindowStyles(window);
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    updateWindowStyles(window);
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
-    SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
-                 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    COLORREF key = 0;
-    BYTE alpha = 0;
-    DWORD flags = 0;
-    DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
-
-    if (exStyle & WS_EX_LAYERED)
-        GetLayeredWindowAttributes(window->win32.handle, &key, &alpha, &flags);
-
-    if (enabled)
-        exStyle |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
-    else
-    {
-        exStyle &= ~WS_EX_TRANSPARENT;
-        // NOTE: Window opacity also needs the layered window style so do not
-        //       remove it if the window is alpha blended
-        if (exStyle & WS_EX_LAYERED)
-        {
-            if (!(flags & LWA_ALPHA))
-                exStyle &= ~WS_EX_LAYERED;
-        }
-    }
-
-    SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-
-    if (enabled)
-        SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    BYTE alpha;
-    DWORD flags;
-
-    if ((GetWindowLongW(window->win32.handle, GWL_EXSTYLE) & WS_EX_LAYERED) &&
-        GetLayeredWindowAttributes(window->win32.handle, NULL, &alpha, &flags))
-    {
-        if (flags & LWA_ALPHA)
-            return alpha / 255.f;
-    }
-
-    return 1.f;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
-    if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
-    {
-        const BYTE alpha = (BYTE) (255 * opacity);
-        exStyle |= WS_EX_LAYERED;
-        SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-        SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
-    }
-    else if (exStyle & WS_EX_TRANSPARENT)
-    {
-        SetLayeredWindowAttributes(window->win32.handle, 0, 0, 0);
-    }
-    else
-    {
-        exStyle &= ~WS_EX_LAYERED;
-        SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-    }
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    if (_glfw.win32.disabledCursorWindow != window)
-        return;
-
-    if (enabled)
-        enableRawMouseMotion(window);
-    else
-        disableRawMouseMotion(window);
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    MSG msg;
-    HWND handle;
-    _GLFWwindow* window;
-
-    while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
-    {
-        if (msg.message == WM_QUIT)
-        {
-            // NOTE: While GLFW does not itself post WM_QUIT, other processes
-            //       may post it to this one, for example Task Manager
-            // HACK: Treat WM_QUIT as a close on all windows
-
-            window = _glfw.windowListHead;
-            while (window)
-            {
-                _glfwInputWindowCloseRequest(window);
-                window = window->next;
-            }
-        }
-        else
-        {
-            TranslateMessage(&msg);
-            DispatchMessageW(&msg);
-        }
-    }
-
-    // HACK: Release modifier keys that the system did not emit KEYUP for
-    // NOTE: Shift keys on Windows tend to "stick" when both are pressed as
-    //       no key up message is generated by the first key release
-    // NOTE: Windows key is not reported as released by the Win+V hotkey
-    //       Other Win hotkeys are handled implicitly by _glfwInputWindowFocus
-    //       because they change the input focus
-    // NOTE: The other half of this is in the WM_*KEY* handler in windowProc
-    handle = GetActiveWindow();
-    if (handle)
-    {
-        window = GetPropW(handle, L"GLFW");
-        if (window)
-        {
-            int i;
-            const int keys[4][2] =
-            {
-                { VK_LSHIFT, GLFW_KEY_LEFT_SHIFT },
-                { VK_RSHIFT, GLFW_KEY_RIGHT_SHIFT },
-                { VK_LWIN, GLFW_KEY_LEFT_SUPER },
-                { VK_RWIN, GLFW_KEY_RIGHT_SUPER }
-            };
-
-            for (i = 0;  i < 4;  i++)
-            {
-                const int vk = keys[i][0];
-                const int key = keys[i][1];
-                const int scancode = _glfw.win32.scancodes[key];
-
-                if ((GetKeyState(vk) & 0x8000))
-                    continue;
-                if (window->keys[key] != GLFW_PRESS)
-                    continue;
-
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods());
-            }
-        }
-    }
-
-    window = _glfw.win32.disabledCursorWindow;
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetWindowSize(window, &width, &height);
-
-        // NOTE: Re-center the cursor only if it has moved since the last call,
-        //       to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
-        if (window->win32.lastCursorPosX != width / 2 ||
-            window->win32.lastCursorPosY != height / 2)
-        {
-            _glfwPlatformSetCursorPos(window, width / 2, height / 2);
-        }
-    }
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    WaitMessage();
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    POINT pos;
-
-    if (GetCursorPos(&pos))
-    {
-        ScreenToClient(window->win32.handle, &pos);
-
-        if (xpos)
-            *xpos = pos.x;
-        if (ypos)
-            *ypos = pos.y;
-    }
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
-{
-    POINT pos = { (int) xpos, (int) ypos };
-
-    // Store the new position so it can be recognized later
-    window->win32.lastCursorPosX = pos.x;
-    window->win32.lastCursorPosY = pos.y;
-
-    ClientToScreen(window->win32.handle, &pos);
-    SetCursorPos(pos.x, pos.y);
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    if (mode == GLFW_CURSOR_DISABLED)
-    {
-        if (_glfwPlatformWindowFocused(window))
-            disableCursor(window);
-    }
-    else if (_glfw.win32.disabledCursorWindow == window)
-        enableCursor(window);
-    else if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
-        _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.win32.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
-    if (!cursor->win32.handle)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    int id = 0;
-
-    if (shape == GLFW_ARROW_CURSOR)
-        id = OCR_NORMAL;
-    else if (shape == GLFW_IBEAM_CURSOR)
-        id = OCR_IBEAM;
-    else if (shape == GLFW_CROSSHAIR_CURSOR)
-        id = OCR_CROSS;
-    else if (shape == GLFW_POINTING_HAND_CURSOR)
-        id = OCR_HAND;
-    else if (shape == GLFW_RESIZE_EW_CURSOR)
-        id = OCR_SIZEWE;
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        id = OCR_SIZENS;
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        id = OCR_SIZENWSE;
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        id = OCR_SIZENESW;
-    else if (shape == GLFW_RESIZE_ALL_CURSOR)
-        id = OCR_SIZEALL;
-    else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-        id = OCR_NO;
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
-        return GLFW_FALSE;
-    }
-
-    cursor->win32.handle = LoadImageW(NULL,
-                                      MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
-                                      LR_DEFAULTSIZE | LR_SHARED);
-    if (!cursor->win32.handle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create standard cursor");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    if (cursor->win32.handle)
-        DestroyIcon((HICON) cursor->win32.handle);
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    int characterCount;
-    HANDLE object;
-    WCHAR* buffer;
-
-    characterCount = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
-    if (!characterCount)
-        return;
-
-    object = GlobalAlloc(GMEM_MOVEABLE, characterCount * sizeof(WCHAR));
-    if (!object)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to allocate global handle for clipboard");
-        return;
-    }
-
-    buffer = GlobalLock(object);
-    if (!buffer)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to lock global handle");
-        GlobalFree(object);
-        return;
-    }
-
-    MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
-    GlobalUnlock(object);
-
-    if (!OpenClipboard(_glfw.win32.helperWindowHandle))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to open clipboard");
-        GlobalFree(object);
-        return;
-    }
-
-    EmptyClipboard();
-    SetClipboardData(CF_UNICODETEXT, object);
-    CloseClipboard();
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    HANDLE object;
-    WCHAR* buffer;
-
-    if (!OpenClipboard(_glfw.win32.helperWindowHandle))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to open clipboard");
-        return NULL;
-    }
-
-    object = GetClipboardData(CF_UNICODETEXT);
-    if (!object)
-    {
-        _glfwInputErrorWin32(GLFW_FORMAT_UNAVAILABLE,
-                             "Win32: Failed to convert clipboard to string");
-        CloseClipboard();
-        return NULL;
-    }
-
-    buffer = GlobalLock(object);
-    if (!buffer)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to lock global handle");
-        CloseClipboard();
-        return NULL;
-    }
-
-    free(_glfw.win32.clipboardString);
-    _glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
-
-    GlobalUnlock(object);
-    CloseClipboard();
-
-    return _glfw.win32.clipboardString;
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-            else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGLES)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_d3d)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D9)
-                type = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE;
-            else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11)
-                type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_vulkan)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
-                type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(3, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return GetDC(_glfw.win32.helperWindowHandle);
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->win32.handle;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
-        return;
-
-    extensions[0] = "VK_KHR_surface";
-    extensions[1] = "VK_KHR_win32_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
-        vkGetPhysicalDeviceWin32PresentationSupportKHR =
-        (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)
-        vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-    if (!vkGetPhysicalDeviceWin32PresentationSupportKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
-        return GLFW_FALSE;
-    }
-
-    return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    VkResult err;
-    VkWin32SurfaceCreateInfoKHR sci;
-    PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
-
-    vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
-        vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR");
-    if (!vkCreateWin32SurfaceKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    memset(&sci, 0, sizeof(sci));
-    sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
-    sci.hinstance = GetModuleHandle(NULL);
-    sci.hwnd = window->win32.handle;
-
-    err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->win32.handle;
-}
-
diff --git a/raylib/external/glfw/src/window.c b/raylib/external/glfw/src/window.c
deleted file mode 100644 (file)
index efcb412..0000000
+++ /dev/null
@@ -1,1122 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <float.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code that a window has lost or received input focus
-//
-void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
-{
-    if (window->callbacks.focus)
-        window->callbacks.focus((GLFWwindow*) window, focused);
-
-    if (!focused)
-    {
-        int key, button;
-
-        for (key = 0;  key <= GLFW_KEY_LAST;  key++)
-        {
-            if (window->keys[key] == GLFW_PRESS)
-            {
-                const int scancode = _glfwPlatformGetKeyScancode(key);
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
-            }
-        }
-
-        for (button = 0;  button <= GLFW_MOUSE_BUTTON_LAST;  button++)
-        {
-            if (window->mouseButtons[button] == GLFW_PRESS)
-                _glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
-        }
-    }
-}
-
-// Notifies shared code that a window has moved
-// The position is specified in content area relative screen coordinates
-//
-void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
-{
-    if (window->callbacks.pos)
-        window->callbacks.pos((GLFWwindow*) window, x, y);
-}
-
-// Notifies shared code that a window has been resized
-// The size is specified in screen coordinates
-//
-void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->callbacks.size)
-        window->callbacks.size((GLFWwindow*) window, width, height);
-}
-
-// Notifies shared code that a window has been iconified or restored
-//
-void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
-{
-    if (window->callbacks.iconify)
-        window->callbacks.iconify((GLFWwindow*) window, iconified);
-}
-
-// Notifies shared code that a window has been maximized or restored
-//
-void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
-{
-    if (window->callbacks.maximize)
-        window->callbacks.maximize((GLFWwindow*) window, maximized);
-}
-
-// Notifies shared code that a window framebuffer has been resized
-// The size is specified in pixels
-//
-void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->callbacks.fbsize)
-        window->callbacks.fbsize((GLFWwindow*) window, width, height);
-}
-
-// Notifies shared code that a window content scale has changed
-// The scale is specified as the ratio between the current and default DPI
-//
-void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
-{
-    if (window->callbacks.scale)
-        window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
-}
-
-// Notifies shared code that the window contents needs updating
-//
-void _glfwInputWindowDamage(_GLFWwindow* window)
-{
-    if (window->callbacks.refresh)
-        window->callbacks.refresh((GLFWwindow*) window);
-}
-
-// Notifies shared code that the user wishes to close a window
-//
-void _glfwInputWindowCloseRequest(_GLFWwindow* window)
-{
-    window->shouldClose = GLFW_TRUE;
-
-    if (window->callbacks.close)
-        window->callbacks.close((GLFWwindow*) window);
-}
-
-// Notifies shared code that a window has changed its desired monitor
-//
-void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
-{
-    window->monitor = monitor;
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
-                                     const char* title,
-                                     GLFWmonitor* monitor,
-                                     GLFWwindow* share)
-{
-    _GLFWfbconfig fbconfig;
-    _GLFWctxconfig ctxconfig;
-    _GLFWwndconfig wndconfig;
-    _GLFWwindow* window;
-
-    assert(title != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (width <= 0 || height <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid window size %ix%i",
-                        width, height);
-
-        return NULL;
-    }
-
-    fbconfig  = _glfw.hints.framebuffer;
-    ctxconfig = _glfw.hints.context;
-    wndconfig = _glfw.hints.window;
-
-    wndconfig.width   = width;
-    wndconfig.height  = height;
-    wndconfig.title   = title;
-    ctxconfig.share   = (_GLFWwindow*) share;
-
-    if (!_glfwIsValidContextConfig(&ctxconfig))
-        return NULL;
-
-    window = calloc(1, sizeof(_GLFWwindow));
-    window->next = _glfw.windowListHead;
-    _glfw.windowListHead = window;
-
-    window->videoMode.width       = width;
-    window->videoMode.height      = height;
-    window->videoMode.redBits     = fbconfig.redBits;
-    window->videoMode.greenBits   = fbconfig.greenBits;
-    window->videoMode.blueBits    = fbconfig.blueBits;
-    window->videoMode.refreshRate = _glfw.hints.refreshRate;
-
-    window->monitor          = (_GLFWmonitor*) monitor;
-    window->resizable        = wndconfig.resizable;
-    window->decorated        = wndconfig.decorated;
-    window->autoIconify      = wndconfig.autoIconify;
-    window->floating         = wndconfig.floating;
-    window->focusOnShow      = wndconfig.focusOnShow;
-    window->mousePassthrough = wndconfig.mousePassthrough;
-    window->cursorMode       = GLFW_CURSOR_NORMAL;
-
-    window->minwidth    = GLFW_DONT_CARE;
-    window->minheight   = GLFW_DONT_CARE;
-    window->maxwidth    = GLFW_DONT_CARE;
-    window->maxheight   = GLFW_DONT_CARE;
-    window->numer       = GLFW_DONT_CARE;
-    window->denom       = GLFW_DONT_CARE;
-
-    // Open the actual window and create its context
-    if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
-    {
-        glfwDestroyWindow((GLFWwindow*) window);
-        return NULL;
-    }
-
-    if (ctxconfig.client != GLFW_NO_API)
-    {
-        if (!_glfwRefreshContextAttribs(window, &ctxconfig))
-        {
-            glfwDestroyWindow((GLFWwindow*) window);
-            return NULL;
-        }
-    }
-
-    if (wndconfig.mousePassthrough)
-        _glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE);
-
-    if (window->monitor)
-    {
-        if (wndconfig.centerCursor)
-            _glfwCenterCursorInContentArea(window);
-    }
-    else
-    {
-        if (wndconfig.visible)
-        {
-            _glfwPlatformShowWindow(window);
-            if (wndconfig.focused)
-                _glfwPlatformFocusWindow(window);
-        }
-    }
-
-    return (GLFWwindow*) window;
-}
-
-void glfwDefaultWindowHints(void)
-{
-    _GLFW_REQUIRE_INIT();
-
-    // The default is OpenGL with minimum version 1.0
-    memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
-    _glfw.hints.context.client = GLFW_OPENGL_API;
-    _glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
-    _glfw.hints.context.major  = 1;
-    _glfw.hints.context.minor  = 0;
-
-    // The default is a focused, visible, resizable window with decorations
-    memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
-    _glfw.hints.window.resizable    = GLFW_TRUE;
-    _glfw.hints.window.visible      = GLFW_TRUE;
-    _glfw.hints.window.decorated    = GLFW_TRUE;
-    _glfw.hints.window.focused      = GLFW_TRUE;
-    _glfw.hints.window.autoIconify  = GLFW_TRUE;
-    _glfw.hints.window.centerCursor = GLFW_TRUE;
-    _glfw.hints.window.focusOnShow  = GLFW_TRUE;
-
-    // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
-    // double buffered
-    memset(&_glfw.hints.framebuffer, 0, sizeof(_glfw.hints.framebuffer));
-    _glfw.hints.framebuffer.redBits      = 8;
-    _glfw.hints.framebuffer.greenBits    = 8;
-    _glfw.hints.framebuffer.blueBits     = 8;
-    _glfw.hints.framebuffer.alphaBits    = 8;
-    _glfw.hints.framebuffer.depthBits    = 24;
-    _glfw.hints.framebuffer.stencilBits  = 8;
-    _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
-
-    // The default is to select the highest available refresh rate
-    _glfw.hints.refreshRate = GLFW_DONT_CARE;
-
-    // The default is to use full Retina resolution framebuffers
-    _glfw.hints.window.ns.retina = GLFW_TRUE;
-}
-
-GLFWAPI void glfwWindowHint(int hint, int value)
-{
-    _GLFW_REQUIRE_INIT();
-
-    switch (hint)
-    {
-        case GLFW_RED_BITS:
-            _glfw.hints.framebuffer.redBits = value;
-            return;
-        case GLFW_GREEN_BITS:
-            _glfw.hints.framebuffer.greenBits = value;
-            return;
-        case GLFW_BLUE_BITS:
-            _glfw.hints.framebuffer.blueBits = value;
-            return;
-        case GLFW_ALPHA_BITS:
-            _glfw.hints.framebuffer.alphaBits = value;
-            return;
-        case GLFW_DEPTH_BITS:
-            _glfw.hints.framebuffer.depthBits = value;
-            return;
-        case GLFW_STENCIL_BITS:
-            _glfw.hints.framebuffer.stencilBits = value;
-            return;
-        case GLFW_ACCUM_RED_BITS:
-            _glfw.hints.framebuffer.accumRedBits = value;
-            return;
-        case GLFW_ACCUM_GREEN_BITS:
-            _glfw.hints.framebuffer.accumGreenBits = value;
-            return;
-        case GLFW_ACCUM_BLUE_BITS:
-            _glfw.hints.framebuffer.accumBlueBits = value;
-            return;
-        case GLFW_ACCUM_ALPHA_BITS:
-            _glfw.hints.framebuffer.accumAlphaBits = value;
-            return;
-        case GLFW_AUX_BUFFERS:
-            _glfw.hints.framebuffer.auxBuffers = value;
-            return;
-        case GLFW_STEREO:
-            _glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_DOUBLEBUFFER:
-            _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_TRANSPARENT_FRAMEBUFFER:
-            _glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_SAMPLES:
-            _glfw.hints.framebuffer.samples = value;
-            return;
-        case GLFW_SRGB_CAPABLE:
-            _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_RESIZABLE:
-            _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_DECORATED:
-            _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FOCUSED:
-            _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_AUTO_ICONIFY:
-            _glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FLOATING:
-            _glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_MAXIMIZED:
-            _glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_VISIBLE:
-            _glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_COCOA_RETINA_FRAMEBUFFER:
-            _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_WIN32_KEYBOARD_MENU:
-            _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_COCOA_GRAPHICS_SWITCHING:
-            _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_SCALE_TO_MONITOR:
-            _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CENTER_CURSOR:
-            _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FOCUS_ON_SHOW:
-            _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_MOUSE_PASSTHROUGH:
-            _glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CLIENT_API:
-            _glfw.hints.context.client = value;
-            return;
-        case GLFW_CONTEXT_CREATION_API:
-            _glfw.hints.context.source = value;
-            return;
-        case GLFW_CONTEXT_VERSION_MAJOR:
-            _glfw.hints.context.major = value;
-            return;
-        case GLFW_CONTEXT_VERSION_MINOR:
-            _glfw.hints.context.minor = value;
-            return;
-        case GLFW_CONTEXT_ROBUSTNESS:
-            _glfw.hints.context.robustness = value;
-            return;
-        case GLFW_OPENGL_FORWARD_COMPAT:
-            _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CONTEXT_DEBUG:
-            _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CONTEXT_NO_ERROR:
-            _glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_OPENGL_PROFILE:
-            _glfw.hints.context.profile = value;
-            return;
-        case GLFW_CONTEXT_RELEASE_BEHAVIOR:
-            _glfw.hints.context.release = value;
-            return;
-        case GLFW_REFRESH_RATE:
-            _glfw.hints.refreshRate = value;
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
-}
-
-GLFWAPI void glfwWindowHintString(int hint, const char* value)
-{
-    assert(value != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    switch (hint)
-    {
-        case GLFW_COCOA_FRAME_NAME:
-            strncpy(_glfw.hints.window.ns.frameName, value,
-                    sizeof(_glfw.hints.window.ns.frameName) - 1);
-            return;
-        case GLFW_X11_CLASS_NAME:
-            strncpy(_glfw.hints.window.x11.className, value,
-                    sizeof(_glfw.hints.window.x11.className) - 1);
-            return;
-        case GLFW_X11_INSTANCE_NAME:
-            strncpy(_glfw.hints.window.x11.instanceName, value,
-                    sizeof(_glfw.hints.window.x11.instanceName) - 1);
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
-}
-
-GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-
-    _GLFW_REQUIRE_INIT();
-
-    // Allow closing of NULL (to match the behavior of free)
-    if (window == NULL)
-        return;
-
-    // Clear all callbacks to avoid exposing a half torn-down window object
-    memset(&window->callbacks, 0, sizeof(window->callbacks));
-
-    // The window's context must not be current on another thread when the
-    // window is destroyed
-    if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
-        glfwMakeContextCurrent(NULL);
-
-    _glfwPlatformDestroyWindow(window);
-
-    // Unlink window from global linked list
-    {
-        _GLFWwindow** prev = &_glfw.windowListHead;
-
-        while (*prev != window)
-            prev = &((*prev)->next);
-
-        *prev = window->next;
-    }
-
-    free(window);
-}
-
-GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return window->shouldClose;
-}
-
-GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    window->shouldClose = value;
-}
-
-GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(title != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetWindowTitle(window, title);
-}
-
-GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
-                               int count, const GLFWimage* images)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(count >= 0);
-    assert(count == 0 || images != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetWindowIcon(window, count, images);
-}
-
-GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformSetWindowPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    window->videoMode.width  = width;
-    window->videoMode.height = height;
-
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
-                                     int minwidth, int minheight,
-                                     int maxwidth, int maxheight)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
-    {
-        if (minwidth < 0 || minheight < 0)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window minimum size %ix%i",
-                            minwidth, minheight);
-            return;
-        }
-    }
-
-    if (maxwidth != GLFW_DONT_CARE && maxheight != GLFW_DONT_CARE)
-    {
-        if (maxwidth < 0 || maxheight < 0 ||
-            maxwidth < minwidth || maxheight < minheight)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window maximum size %ix%i",
-                            maxwidth, maxheight);
-            return;
-        }
-    }
-
-    window->minwidth  = minwidth;
-    window->minheight = minheight;
-    window->maxwidth  = maxwidth;
-    window->maxheight = maxheight;
-
-    if (window->monitor || !window->resizable)
-        return;
-
-    _glfwPlatformSetWindowSizeLimits(window,
-                                     minwidth, minheight,
-                                     maxwidth, maxheight);
-}
-
-GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(numer != 0);
-    assert(denom != 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
-    {
-        if (numer <= 0 || denom <= 0)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window aspect ratio %i:%i",
-                            numer, denom);
-            return;
-        }
-    }
-
-    window->numer = numer;
-    window->denom = denom;
-
-    if (window->monitor || !window->resizable)
-        return;
-
-    _glfwPlatformSetWindowAspectRatio(window, numer, denom);
-}
-
-GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetFramebufferSize(window, width, height);
-}
-
-GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
-                                    int* left, int* top,
-                                    int* right, int* bottom)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (left)
-        *left = 0;
-    if (top)
-        *top = 0;
-    if (right)
-        *right = 0;
-    if (bottom)
-        *bottom = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
-}
-
-GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
-                                       float* xscale, float* yscale)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xscale)
-        *xscale = 0.f;
-    if (yscale)
-        *yscale = 0.f;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowContentScale(window, xscale, yscale);
-}
-
-GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(1.f);
-    return _glfwPlatformGetWindowOpacity(window);
-}
-
-GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(opacity == opacity);
-    assert(opacity >= 0.f);
-    assert(opacity <= 1.f);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (opacity != opacity || opacity < 0.f || opacity > 1.f)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity);
-        return;
-    }
-
-    _glfwPlatformSetWindowOpacity(window, opacity);
-}
-
-GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformIconifyWindow(window);
-}
-
-GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformRestoreWindow(window);
-}
-
-GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformMaximizeWindow(window);
-}
-
-GLFWAPI void glfwShowWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformShowWindow(window);
-
-    if (window->focusOnShow)
-        _glfwPlatformFocusWindow(window);
-}
-
-GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformRequestWindowAttention(window);
-}
-
-GLFWAPI void glfwHideWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformHideWindow(window);
-}
-
-GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformFocusWindow(window);
-}
-
-GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-
-    switch (attrib)
-    {
-        case GLFW_FOCUSED:
-            return _glfwPlatformWindowFocused(window);
-        case GLFW_ICONIFIED:
-            return _glfwPlatformWindowIconified(window);
-        case GLFW_VISIBLE:
-            return _glfwPlatformWindowVisible(window);
-        case GLFW_MAXIMIZED:
-            return _glfwPlatformWindowMaximized(window);
-        case GLFW_HOVERED:
-            return _glfwPlatformWindowHovered(window);
-        case GLFW_FOCUS_ON_SHOW:
-            return window->focusOnShow;
-        case GLFW_MOUSE_PASSTHROUGH:
-            return window->mousePassthrough;
-        case GLFW_TRANSPARENT_FRAMEBUFFER:
-            return _glfwPlatformFramebufferTransparent(window);
-        case GLFW_RESIZABLE:
-            return window->resizable;
-        case GLFW_DECORATED:
-            return window->decorated;
-        case GLFW_FLOATING:
-            return window->floating;
-        case GLFW_AUTO_ICONIFY:
-            return window->autoIconify;
-        case GLFW_CLIENT_API:
-            return window->context.client;
-        case GLFW_CONTEXT_CREATION_API:
-            return window->context.source;
-        case GLFW_CONTEXT_VERSION_MAJOR:
-            return window->context.major;
-        case GLFW_CONTEXT_VERSION_MINOR:
-            return window->context.minor;
-        case GLFW_CONTEXT_REVISION:
-            return window->context.revision;
-        case GLFW_CONTEXT_ROBUSTNESS:
-            return window->context.robustness;
-        case GLFW_OPENGL_FORWARD_COMPAT:
-            return window->context.forward;
-        case GLFW_CONTEXT_DEBUG:
-            return window->context.debug;
-        case GLFW_OPENGL_PROFILE:
-            return window->context.profile;
-        case GLFW_CONTEXT_RELEASE_BEHAVIOR:
-            return window->context.release;
-        case GLFW_CONTEXT_NO_ERROR:
-            return window->context.noerror;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
-    return 0;
-}
-
-GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    value = value ? GLFW_TRUE : GLFW_FALSE;
-
-    if (attrib == GLFW_AUTO_ICONIFY)
-        window->autoIconify = value;
-    else if (attrib == GLFW_RESIZABLE)
-    {
-        if (window->resizable == value)
-            return;
-
-        window->resizable = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowResizable(window, value);
-    }
-    else if (attrib == GLFW_DECORATED)
-    {
-        if (window->decorated == value)
-            return;
-
-        window->decorated = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowDecorated(window, value);
-    }
-    else if (attrib == GLFW_FLOATING)
-    {
-        if (window->floating == value)
-            return;
-
-        window->floating = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowFloating(window, value);
-    }
-    else if (attrib == GLFW_FOCUS_ON_SHOW)
-        window->focusOnShow = value;
-    else if (attrib == GLFW_MOUSE_PASSTHROUGH)
-    {
-        if (window->mousePassthrough == value)
-            return;
-
-        window->mousePassthrough = value;
-        _glfwPlatformSetWindowMousePassthrough(window, value);
-    }
-    else
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
-}
-
-GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return (GLFWmonitor*) window->monitor;
-}
-
-GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
-                                  GLFWmonitor* mh,
-                                  int xpos, int ypos,
-                                  int width, int height,
-                                  int refreshRate)
-{
-    _GLFWwindow* window = (_GLFWwindow*) wh;
-    _GLFWmonitor* monitor = (_GLFWmonitor*) mh;
-    assert(window != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (width <= 0 || height <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid window size %ix%i",
-                        width, height);
-        return;
-    }
-
-    if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid refresh rate %i",
-                        refreshRate);
-        return;
-    }
-
-    window->videoMode.width       = width;
-    window->videoMode.height      = height;
-    window->videoMode.refreshRate = refreshRate;
-
-    _glfwPlatformSetWindowMonitor(window, monitor,
-                                  xpos, ypos, width, height,
-                                  refreshRate);
-}
-
-GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    window->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->userPointer;
-}
-
-GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
-                                                  GLFWwindowposfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
-                                                    GLFWwindowsizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
-                                                      GLFWwindowclosefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
-                                                          GLFWwindowrefreshfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
-                                                      GLFWwindowfocusfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
-                                                          GLFWwindowiconifyfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
-                                                            GLFWwindowmaximizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
-                                                              GLFWframebuffersizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
-                                                                    GLFWwindowcontentscalefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
-    return cbfun;
-}
-
-GLFWAPI void glfwPollEvents(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformPollEvents();
-}
-
-GLFWAPI void glfwWaitEvents(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformWaitEvents();
-}
-
-GLFWAPI void glfwWaitEventsTimeout(double timeout)
-{
-    _GLFW_REQUIRE_INIT();
-    assert(timeout == timeout);
-    assert(timeout >= 0.0);
-    assert(timeout <= DBL_MAX);
-
-    if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
-        return;
-    }
-
-    _glfwPlatformWaitEventsTimeout(timeout);
-}
-
-GLFWAPI void glfwPostEmptyEvent(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformPostEmptyEvent();
-}
-
diff --git a/raylib/external/glfw/src/wl_init.c b/raylib/external/glfw/src/wl_init.c
deleted file mode 100644 (file)
index d3e777d..0000000
+++ /dev/null
@@ -1,1323 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _POSIX_C_SOURCE 199309L
-
-#include "internal.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <limits.h>
-#include <linux/input.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/timerfd.h>
-#include <unistd.h>
-#include <time.h>
-#include <wayland-client.h>
-
-
-static inline int min(int n1, int n2)
-{
-    return n1 < n2 ? n1 : n2;
-}
-
-static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
-                                                    int* which)
-{
-    int focus;
-    _GLFWwindow* window = _glfw.windowListHead;
-    if (!which)
-        which = &focus;
-    while (window)
-    {
-        if (surface == window->wl.decorations.top.surface)
-        {
-            *which = topDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.left.surface)
-        {
-            *which = leftDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.right.surface)
-        {
-            *which = rightDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.bottom.surface)
-        {
-            *which = bottomDecoration;
-            break;
-        }
-        window = window->next;
-    }
-    return window;
-}
-
-static void pointerHandleEnter(void* data,
-                               struct wl_pointer* pointer,
-                               uint32_t serial,
-                               struct wl_surface* surface,
-                               wl_fixed_t sx,
-                               wl_fixed_t sy)
-{
-    // Happens in the case we just destroyed the surface.
-    if (!surface)
-        return;
-
-    int focus = 0;
-    _GLFWwindow* window = wl_surface_get_user_data(surface);
-    if (!window)
-    {
-        window = findWindowFromDecorationSurface(surface, &focus);
-        if (!window)
-            return;
-    }
-
-    window->wl.decorations.focus = focus;
-    _glfw.wl.serial = serial;
-    _glfw.wl.pointerFocus = window;
-
-    window->wl.hovered = GLFW_TRUE;
-
-    _glfwPlatformSetCursor(window, window->wl.currentCursor);
-    _glfwInputCursorEnter(window, GLFW_TRUE);
-}
-
-static void pointerHandleLeave(void* data,
-                               struct wl_pointer* pointer,
-                               uint32_t serial,
-                               struct wl_surface* surface)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-
-    if (!window)
-        return;
-
-    window->wl.hovered = GLFW_FALSE;
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.pointerFocus = NULL;
-    _glfwInputCursorEnter(window, GLFW_FALSE);
-    _glfw.wl.cursorPreviousName = NULL;
-}
-
-static void setCursor(_GLFWwindow* window, const char* name)
-{
-    struct wl_buffer* buffer;
-    struct wl_cursor* cursor;
-    struct wl_cursor_image* image;
-    struct wl_surface* surface = _glfw.wl.cursorSurface;
-    struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
-    int scale = 1;
-
-    if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI)
-    {
-        // We only support up to scale=2 for now, since libwayland-cursor
-        // requires us to load a different theme for each size.
-        scale = 2;
-        theme = _glfw.wl.cursorThemeHiDPI;
-    }
-
-    cursor = wl_cursor_theme_get_cursor(theme, name);
-    if (!cursor)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Standard cursor not found");
-        return;
-    }
-    // TODO: handle animated cursors too.
-    image = cursor->images[0];
-
-    if (!image)
-        return;
-
-    buffer = wl_cursor_image_get_buffer(image);
-    if (!buffer)
-        return;
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          surface,
-                          image->hotspot_x / scale,
-                          image->hotspot_y / scale);
-    wl_surface_set_buffer_scale(surface, scale);
-    wl_surface_attach(surface, buffer, 0, 0);
-    wl_surface_damage(surface, 0, 0,
-                      image->width, image->height);
-    wl_surface_commit(surface);
-    _glfw.wl.cursorPreviousName = name;
-}
-
-static void pointerHandleMotion(void* data,
-                                struct wl_pointer* pointer,
-                                uint32_t time,
-                                wl_fixed_t sx,
-                                wl_fixed_t sy)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    const char* cursorName = NULL;
-    double x, y;
-
-    if (!window)
-        return;
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-        return;
-    x = wl_fixed_to_double(sx);
-    y = wl_fixed_to_double(sy);
-
-    switch (window->wl.decorations.focus)
-    {
-        case mainWindow:
-            window->wl.cursorPosX = x;
-            window->wl.cursorPosY = y;
-            _glfwInputCursorPos(window, x, y);
-            _glfw.wl.cursorPreviousName = NULL;
-            return;
-        case topDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "n-resize";
-            else
-                cursorName = "left_ptr";
-            break;
-        case leftDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "nw-resize";
-            else
-                cursorName = "w-resize";
-            break;
-        case rightDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "ne-resize";
-            else
-                cursorName = "e-resize";
-            break;
-        case bottomDecoration:
-            if (x < _GLFW_DECORATION_WIDTH)
-                cursorName = "sw-resize";
-            else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
-                cursorName = "se-resize";
-            else
-                cursorName = "s-resize";
-            break;
-        default:
-            assert(0);
-    }
-    if (_glfw.wl.cursorPreviousName != cursorName)
-        setCursor(window, cursorName);
-}
-
-static void pointerHandleButton(void* data,
-                                struct wl_pointer* pointer,
-                                uint32_t serial,
-                                uint32_t time,
-                                uint32_t button,
-                                uint32_t state)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    int glfwButton;
-    uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
-
-    if (!window)
-        return;
-    if (button == BTN_LEFT)
-    {
-        switch (window->wl.decorations.focus)
-        {
-            case mainWindow:
-                break;
-            case topDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
-                else
-                {
-                    xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
-                }
-                break;
-            case leftDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
-                break;
-            case rightDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
-                break;
-            case bottomDecoration:
-                if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
-                else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
-                break;
-            default:
-                assert(0);
-        }
-        if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
-        {
-            xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
-                                serial, edges);
-        }
-    }
-    else if (button == BTN_RIGHT)
-    {
-        if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
-        {
-            xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
-                                          _glfw.wl.seat, serial,
-                                          window->wl.cursorPosX,
-                                          window->wl.cursorPosY);
-            return;
-        }
-    }
-
-    // Don’t pass the button to the user if it was related to a decoration.
-    if (window->wl.decorations.focus != mainWindow)
-        return;
-
-    _glfw.wl.serial = serial;
-
-    /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
-     * codes. */
-    glfwButton = button - BTN_LEFT;
-
-    _glfwInputMouseClick(window,
-                         glfwButton,
-                         state == WL_POINTER_BUTTON_STATE_PRESSED
-                                ? GLFW_PRESS
-                                : GLFW_RELEASE,
-                         _glfw.wl.xkb.modifiers);
-}
-
-static void pointerHandleAxis(void* data,
-                              struct wl_pointer* pointer,
-                              uint32_t time,
-                              uint32_t axis,
-                              wl_fixed_t value)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    double x = 0.0, y = 0.0;
-    // Wayland scroll events are in pointer motion coordinate space (think two
-    // finger scroll).  The factor 10 is commonly used to convert to "scroll
-    // step means 1.0.
-    const double scrollFactor = 1.0 / 10.0;
-
-    if (!window)
-        return;
-
-    assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
-           axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
-
-    if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
-        x = -wl_fixed_to_double(value) * scrollFactor;
-    else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
-        y = -wl_fixed_to_double(value) * scrollFactor;
-
-    _glfwInputScroll(window, x, y);
-}
-
-static const struct wl_pointer_listener pointerListener = {
-    pointerHandleEnter,
-    pointerHandleLeave,
-    pointerHandleMotion,
-    pointerHandleButton,
-    pointerHandleAxis,
-};
-
-static void keyboardHandleKeymap(void* data,
-                                 struct wl_keyboard* keyboard,
-                                 uint32_t format,
-                                 int fd,
-                                 uint32_t size)
-{
-    struct xkb_keymap* keymap;
-    struct xkb_state* state;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    struct xkb_compose_table* composeTable;
-    struct xkb_compose_state* composeState;
-#endif
-
-    char* mapStr;
-    const char* locale;
-
-    if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
-    {
-        close(fd);
-        return;
-    }
-
-    mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
-    if (mapStr == MAP_FAILED) {
-        close(fd);
-        return;
-    }
-
-    keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
-                                        mapStr,
-                                        XKB_KEYMAP_FORMAT_TEXT_V1,
-                                        0);
-    munmap(mapStr, size);
-    close(fd);
-
-    if (!keymap)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to compile keymap");
-        return;
-    }
-
-    state = xkb_state_new(keymap);
-    if (!state)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create XKB state");
-        xkb_keymap_unref(keymap);
-        return;
-    }
-
-    // Look up the preferred locale, falling back to "C" as default.
-    locale = getenv("LC_ALL");
-    if (!locale)
-        locale = getenv("LC_CTYPE");
-    if (!locale)
-        locale = getenv("LANG");
-    if (!locale)
-        locale = "C";
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    composeTable =
-        xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
-                                          XKB_COMPOSE_COMPILE_NO_FLAGS);
-    if (composeTable)
-    {
-        composeState =
-            xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
-        xkb_compose_table_unref(composeTable);
-        if (composeState)
-            _glfw.wl.xkb.composeState = composeState;
-        else
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Failed to create XKB compose state");
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create XKB compose table");
-    }
-#endif
-
-    xkb_keymap_unref(_glfw.wl.xkb.keymap);
-    xkb_state_unref(_glfw.wl.xkb.state);
-    _glfw.wl.xkb.keymap = keymap;
-    _glfw.wl.xkb.state = state;
-
-    _glfw.wl.xkb.controlMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
-    _glfw.wl.xkb.altMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
-    _glfw.wl.xkb.shiftMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
-    _glfw.wl.xkb.superMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
-    _glfw.wl.xkb.capsLockMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
-    _glfw.wl.xkb.numLockMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
-}
-
-static void keyboardHandleEnter(void* data,
-                                struct wl_keyboard* keyboard,
-                                uint32_t serial,
-                                struct wl_surface* surface,
-                                struct wl_array* keys)
-{
-    // Happens in the case we just destroyed the surface.
-    if (!surface)
-        return;
-
-    _GLFWwindow* window = wl_surface_get_user_data(surface);
-    if (!window)
-    {
-        window = findWindowFromDecorationSurface(surface, NULL);
-        if (!window)
-            return;
-    }
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.keyboardFocus = window;
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-}
-
-static void keyboardHandleLeave(void* data,
-                                struct wl_keyboard* keyboard,
-                                uint32_t serial,
-                                struct wl_surface* surface)
-{
-    _GLFWwindow* window = _glfw.wl.keyboardFocus;
-
-    if (!window)
-        return;
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.keyboardFocus = NULL;
-    _glfwInputWindowFocus(window, GLFW_FALSE);
-}
-
-static int toGLFWKeyCode(uint32_t key)
-{
-    if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
-        return _glfw.wl.keycodes[key];
-
-    return GLFW_KEY_UNKNOWN;
-}
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
-{
-    if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
-        return sym;
-    if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
-            != XKB_COMPOSE_FEED_ACCEPTED)
-        return sym;
-    switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
-    {
-        case XKB_COMPOSE_COMPOSED:
-            return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
-        case XKB_COMPOSE_COMPOSING:
-        case XKB_COMPOSE_CANCELLED:
-            return XKB_KEY_NoSymbol;
-        case XKB_COMPOSE_NOTHING:
-        default:
-            return sym;
-    }
-}
-#endif
-
-static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
-{
-    uint32_t code, numSyms;
-    long cp;
-    const xkb_keysym_t *syms;
-    xkb_keysym_t sym;
-
-    code = key + 8;
-    numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
-
-    if (numSyms == 1)
-    {
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        sym = composeSymbol(syms[0]);
-#else
-        sym = syms[0];
-#endif
-        cp = _glfwKeySym2Unicode(sym);
-        if (cp != -1)
-        {
-            const int mods = _glfw.wl.xkb.modifiers;
-            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
-            _glfwInputChar(window, cp, mods, plain);
-        }
-    }
-
-    return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
-}
-
-static void keyboardHandleKey(void* data,
-                              struct wl_keyboard* keyboard,
-                              uint32_t serial,
-                              uint32_t time,
-                              uint32_t key,
-                              uint32_t state)
-{
-    int keyCode;
-    int action;
-    _GLFWwindow* window = _glfw.wl.keyboardFocus;
-    GLFWbool shouldRepeat;
-    struct itimerspec timer = {};
-
-    if (!window)
-        return;
-
-    keyCode = toGLFWKeyCode(key);
-    action = state == WL_KEYBOARD_KEY_STATE_PRESSED
-            ? GLFW_PRESS : GLFW_RELEASE;
-
-    _glfw.wl.serial = serial;
-    _glfwInputKey(window, keyCode, key, action,
-                  _glfw.wl.xkb.modifiers);
-
-    if (action == GLFW_PRESS)
-    {
-        shouldRepeat = inputChar(window, key);
-
-        if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
-        {
-            _glfw.wl.keyboardLastKey = keyCode;
-            _glfw.wl.keyboardLastScancode = key;
-            if (_glfw.wl.keyboardRepeatRate > 1)
-                timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate;
-            else
-                timer.it_interval.tv_sec = 1;
-            timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
-            timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
-        }
-    }
-    timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
-}
-
-static void keyboardHandleModifiers(void* data,
-                                    struct wl_keyboard* keyboard,
-                                    uint32_t serial,
-                                    uint32_t modsDepressed,
-                                    uint32_t modsLatched,
-                                    uint32_t modsLocked,
-                                    uint32_t group)
-{
-    xkb_mod_mask_t mask;
-    unsigned int modifiers = 0;
-
-    _glfw.wl.serial = serial;
-
-    if (!_glfw.wl.xkb.keymap)
-        return;
-
-    xkb_state_update_mask(_glfw.wl.xkb.state,
-                          modsDepressed,
-                          modsLatched,
-                          modsLocked,
-                          0,
-                          0,
-                          group);
-
-    mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
-                                    XKB_STATE_MODS_DEPRESSED |
-                                    XKB_STATE_LAYOUT_DEPRESSED |
-                                    XKB_STATE_MODS_LATCHED |
-                                    XKB_STATE_LAYOUT_LATCHED);
-    if (mask & _glfw.wl.xkb.controlMask)
-        modifiers |= GLFW_MOD_CONTROL;
-    if (mask & _glfw.wl.xkb.altMask)
-        modifiers |= GLFW_MOD_ALT;
-    if (mask & _glfw.wl.xkb.shiftMask)
-        modifiers |= GLFW_MOD_SHIFT;
-    if (mask & _glfw.wl.xkb.superMask)
-        modifiers |= GLFW_MOD_SUPER;
-    if (mask & _glfw.wl.xkb.capsLockMask)
-        modifiers |= GLFW_MOD_CAPS_LOCK;
-    if (mask & _glfw.wl.xkb.numLockMask)
-        modifiers |= GLFW_MOD_NUM_LOCK;
-    _glfw.wl.xkb.modifiers = modifiers;
-}
-
-#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
-static void keyboardHandleRepeatInfo(void* data,
-                                     struct wl_keyboard* keyboard,
-                                     int32_t rate,
-                                     int32_t delay)
-{
-    if (keyboard != _glfw.wl.keyboard)
-        return;
-
-    _glfw.wl.keyboardRepeatRate = rate;
-    _glfw.wl.keyboardRepeatDelay = delay;
-}
-#endif
-
-static const struct wl_keyboard_listener keyboardListener = {
-    keyboardHandleKeymap,
-    keyboardHandleEnter,
-    keyboardHandleLeave,
-    keyboardHandleKey,
-    keyboardHandleModifiers,
-#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
-    keyboardHandleRepeatInfo,
-#endif
-};
-
-static void seatHandleCapabilities(void* data,
-                                   struct wl_seat* seat,
-                                   enum wl_seat_capability caps)
-{
-    if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
-    {
-        _glfw.wl.pointer = wl_seat_get_pointer(seat);
-        wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
-    }
-    else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
-    {
-        wl_pointer_destroy(_glfw.wl.pointer);
-        _glfw.wl.pointer = NULL;
-    }
-
-    if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
-    {
-        _glfw.wl.keyboard = wl_seat_get_keyboard(seat);
-        wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
-    }
-    else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
-    {
-        wl_keyboard_destroy(_glfw.wl.keyboard);
-        _glfw.wl.keyboard = NULL;
-    }
-}
-
-static void seatHandleName(void* data,
-                           struct wl_seat* seat,
-                           const char* name)
-{
-}
-
-static const struct wl_seat_listener seatListener = {
-    seatHandleCapabilities,
-    seatHandleName,
-};
-
-static void dataOfferHandleOffer(void* data,
-                                 struct wl_data_offer* dataOffer,
-                                 const char* mimeType)
-{
-}
-
-static const struct wl_data_offer_listener dataOfferListener = {
-    dataOfferHandleOffer,
-};
-
-static void dataDeviceHandleDataOffer(void* data,
-                                      struct wl_data_device* dataDevice,
-                                      struct wl_data_offer* id)
-{
-    if (_glfw.wl.dataOffer)
-        wl_data_offer_destroy(_glfw.wl.dataOffer);
-
-    _glfw.wl.dataOffer = id;
-    wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL);
-}
-
-static void dataDeviceHandleEnter(void* data,
-                                  struct wl_data_device* dataDevice,
-                                  uint32_t serial,
-                                  struct wl_surface *surface,
-                                  wl_fixed_t x,
-                                  wl_fixed_t y,
-                                  struct wl_data_offer *id)
-{
-}
-
-static void dataDeviceHandleLeave(void* data,
-                                  struct wl_data_device* dataDevice)
-{
-}
-
-static void dataDeviceHandleMotion(void* data,
-                                   struct wl_data_device* dataDevice,
-                                   uint32_t time,
-                                   wl_fixed_t x,
-                                   wl_fixed_t y)
-{
-}
-
-static void dataDeviceHandleDrop(void* data,
-                                 struct wl_data_device* dataDevice)
-{
-}
-
-static void dataDeviceHandleSelection(void* data,
-                                      struct wl_data_device* dataDevice,
-                                      struct wl_data_offer* id)
-{
-}
-
-static const struct wl_data_device_listener dataDeviceListener = {
-    dataDeviceHandleDataOffer,
-    dataDeviceHandleEnter,
-    dataDeviceHandleLeave,
-    dataDeviceHandleMotion,
-    dataDeviceHandleDrop,
-    dataDeviceHandleSelection,
-};
-
-static void wmBaseHandlePing(void* data,
-                             struct xdg_wm_base* wmBase,
-                             uint32_t serial)
-{
-    xdg_wm_base_pong(wmBase, serial);
-}
-
-static const struct xdg_wm_base_listener wmBaseListener = {
-    wmBaseHandlePing
-};
-
-static void registryHandleGlobal(void* data,
-                                 struct wl_registry* registry,
-                                 uint32_t name,
-                                 const char* interface,
-                                 uint32_t version)
-{
-    if (strcmp(interface, "wl_compositor") == 0)
-    {
-        _glfw.wl.compositorVersion = min(3, version);
-        _glfw.wl.compositor =
-            wl_registry_bind(registry, name, &wl_compositor_interface,
-                             _glfw.wl.compositorVersion);
-    }
-    else if (strcmp(interface, "wl_subcompositor") == 0)
-    {
-        _glfw.wl.subcompositor =
-            wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
-    }
-    else if (strcmp(interface, "wl_shm") == 0)
-    {
-        _glfw.wl.shm =
-            wl_registry_bind(registry, name, &wl_shm_interface, 1);
-    }
-    else if (strcmp(interface, "wl_output") == 0)
-    {
-        _glfwAddOutputWayland(name, version);
-    }
-    else if (strcmp(interface, "wl_seat") == 0)
-    {
-        if (!_glfw.wl.seat)
-        {
-            _glfw.wl.seatVersion = min(4, version);
-            _glfw.wl.seat =
-                wl_registry_bind(registry, name, &wl_seat_interface,
-                                 _glfw.wl.seatVersion);
-            wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);
-        }
-    }
-    else if (strcmp(interface, "wl_data_device_manager") == 0)
-    {
-        if (!_glfw.wl.dataDeviceManager)
-        {
-            _glfw.wl.dataDeviceManager =
-                wl_registry_bind(registry, name,
-                                 &wl_data_device_manager_interface, 1);
-        }
-    }
-    else if (strcmp(interface, "xdg_wm_base") == 0)
-    {
-        _glfw.wl.wmBase =
-            wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
-        xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
-    }
-    else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
-    {
-        _glfw.wl.decorationManager =
-            wl_registry_bind(registry, name,
-                             &zxdg_decoration_manager_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "wp_viewporter") == 0)
-    {
-        _glfw.wl.viewporter =
-            wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
-    }
-    else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
-    {
-        _glfw.wl.relativePointerManager =
-            wl_registry_bind(registry, name,
-                             &zwp_relative_pointer_manager_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
-    {
-        _glfw.wl.pointerConstraints =
-            wl_registry_bind(registry, name,
-                             &zwp_pointer_constraints_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
-    {
-        _glfw.wl.idleInhibitManager =
-            wl_registry_bind(registry, name,
-                             &zwp_idle_inhibit_manager_v1_interface,
-                             1);
-    }
-}
-
-static void registryHandleGlobalRemove(void *data,
-                                       struct wl_registry *registry,
-                                       uint32_t name)
-{
-    int i;
-    _GLFWmonitor* monitor;
-
-    for (i = 0; i < _glfw.monitorCount; ++i)
-    {
-        monitor = _glfw.monitors[i];
-        if (monitor->wl.name == name)
-        {
-            _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
-            return;
-        }
-    }
-}
-
-
-static const struct wl_registry_listener registryListener = {
-    registryHandleGlobal,
-    registryHandleGlobalRemove
-};
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
-    memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
-
-    _glfw.wl.keycodes[KEY_GRAVE]      = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.wl.keycodes[KEY_1]          = GLFW_KEY_1;
-    _glfw.wl.keycodes[KEY_2]          = GLFW_KEY_2;
-    _glfw.wl.keycodes[KEY_3]          = GLFW_KEY_3;
-    _glfw.wl.keycodes[KEY_4]          = GLFW_KEY_4;
-    _glfw.wl.keycodes[KEY_5]          = GLFW_KEY_5;
-    _glfw.wl.keycodes[KEY_6]          = GLFW_KEY_6;
-    _glfw.wl.keycodes[KEY_7]          = GLFW_KEY_7;
-    _glfw.wl.keycodes[KEY_8]          = GLFW_KEY_8;
-    _glfw.wl.keycodes[KEY_9]          = GLFW_KEY_9;
-    _glfw.wl.keycodes[KEY_0]          = GLFW_KEY_0;
-    _glfw.wl.keycodes[KEY_SPACE]      = GLFW_KEY_SPACE;
-    _glfw.wl.keycodes[KEY_MINUS]      = GLFW_KEY_MINUS;
-    _glfw.wl.keycodes[KEY_EQUAL]      = GLFW_KEY_EQUAL;
-    _glfw.wl.keycodes[KEY_Q]          = GLFW_KEY_Q;
-    _glfw.wl.keycodes[KEY_W]          = GLFW_KEY_W;
-    _glfw.wl.keycodes[KEY_E]          = GLFW_KEY_E;
-    _glfw.wl.keycodes[KEY_R]          = GLFW_KEY_R;
-    _glfw.wl.keycodes[KEY_T]          = GLFW_KEY_T;
-    _glfw.wl.keycodes[KEY_Y]          = GLFW_KEY_Y;
-    _glfw.wl.keycodes[KEY_U]          = GLFW_KEY_U;
-    _glfw.wl.keycodes[KEY_I]          = GLFW_KEY_I;
-    _glfw.wl.keycodes[KEY_O]          = GLFW_KEY_O;
-    _glfw.wl.keycodes[KEY_P]          = GLFW_KEY_P;
-    _glfw.wl.keycodes[KEY_LEFTBRACE]  = GLFW_KEY_LEFT_BRACKET;
-    _glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.wl.keycodes[KEY_A]          = GLFW_KEY_A;
-    _glfw.wl.keycodes[KEY_S]          = GLFW_KEY_S;
-    _glfw.wl.keycodes[KEY_D]          = GLFW_KEY_D;
-    _glfw.wl.keycodes[KEY_F]          = GLFW_KEY_F;
-    _glfw.wl.keycodes[KEY_G]          = GLFW_KEY_G;
-    _glfw.wl.keycodes[KEY_H]          = GLFW_KEY_H;
-    _glfw.wl.keycodes[KEY_J]          = GLFW_KEY_J;
-    _glfw.wl.keycodes[KEY_K]          = GLFW_KEY_K;
-    _glfw.wl.keycodes[KEY_L]          = GLFW_KEY_L;
-    _glfw.wl.keycodes[KEY_SEMICOLON]  = GLFW_KEY_SEMICOLON;
-    _glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
-    _glfw.wl.keycodes[KEY_Z]          = GLFW_KEY_Z;
-    _glfw.wl.keycodes[KEY_X]          = GLFW_KEY_X;
-    _glfw.wl.keycodes[KEY_C]          = GLFW_KEY_C;
-    _glfw.wl.keycodes[KEY_V]          = GLFW_KEY_V;
-    _glfw.wl.keycodes[KEY_B]          = GLFW_KEY_B;
-    _glfw.wl.keycodes[KEY_N]          = GLFW_KEY_N;
-    _glfw.wl.keycodes[KEY_M]          = GLFW_KEY_M;
-    _glfw.wl.keycodes[KEY_COMMA]      = GLFW_KEY_COMMA;
-    _glfw.wl.keycodes[KEY_DOT]        = GLFW_KEY_PERIOD;
-    _glfw.wl.keycodes[KEY_SLASH]      = GLFW_KEY_SLASH;
-    _glfw.wl.keycodes[KEY_BACKSLASH]  = GLFW_KEY_BACKSLASH;
-    _glfw.wl.keycodes[KEY_ESC]        = GLFW_KEY_ESCAPE;
-    _glfw.wl.keycodes[KEY_TAB]        = GLFW_KEY_TAB;
-    _glfw.wl.keycodes[KEY_LEFTSHIFT]  = GLFW_KEY_LEFT_SHIFT;
-    _glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.wl.keycodes[KEY_LEFTCTRL]   = GLFW_KEY_LEFT_CONTROL;
-    _glfw.wl.keycodes[KEY_RIGHTCTRL]  = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.wl.keycodes[KEY_LEFTALT]    = GLFW_KEY_LEFT_ALT;
-    _glfw.wl.keycodes[KEY_RIGHTALT]   = GLFW_KEY_RIGHT_ALT;
-    _glfw.wl.keycodes[KEY_LEFTMETA]   = GLFW_KEY_LEFT_SUPER;
-    _glfw.wl.keycodes[KEY_RIGHTMETA]  = GLFW_KEY_RIGHT_SUPER;
-    _glfw.wl.keycodes[KEY_MENU]       = GLFW_KEY_MENU;
-    _glfw.wl.keycodes[KEY_NUMLOCK]    = GLFW_KEY_NUM_LOCK;
-    _glfw.wl.keycodes[KEY_CAPSLOCK]   = GLFW_KEY_CAPS_LOCK;
-    _glfw.wl.keycodes[KEY_PRINT]      = GLFW_KEY_PRINT_SCREEN;
-    _glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
-    _glfw.wl.keycodes[KEY_PAUSE]      = GLFW_KEY_PAUSE;
-    _glfw.wl.keycodes[KEY_DELETE]     = GLFW_KEY_DELETE;
-    _glfw.wl.keycodes[KEY_BACKSPACE]  = GLFW_KEY_BACKSPACE;
-    _glfw.wl.keycodes[KEY_ENTER]      = GLFW_KEY_ENTER;
-    _glfw.wl.keycodes[KEY_HOME]       = GLFW_KEY_HOME;
-    _glfw.wl.keycodes[KEY_END]        = GLFW_KEY_END;
-    _glfw.wl.keycodes[KEY_PAGEUP]     = GLFW_KEY_PAGE_UP;
-    _glfw.wl.keycodes[KEY_PAGEDOWN]   = GLFW_KEY_PAGE_DOWN;
-    _glfw.wl.keycodes[KEY_INSERT]     = GLFW_KEY_INSERT;
-    _glfw.wl.keycodes[KEY_LEFT]       = GLFW_KEY_LEFT;
-    _glfw.wl.keycodes[KEY_RIGHT]      = GLFW_KEY_RIGHT;
-    _glfw.wl.keycodes[KEY_DOWN]       = GLFW_KEY_DOWN;
-    _glfw.wl.keycodes[KEY_UP]         = GLFW_KEY_UP;
-    _glfw.wl.keycodes[KEY_F1]         = GLFW_KEY_F1;
-    _glfw.wl.keycodes[KEY_F2]         = GLFW_KEY_F2;
-    _glfw.wl.keycodes[KEY_F3]         = GLFW_KEY_F3;
-    _glfw.wl.keycodes[KEY_F4]         = GLFW_KEY_F4;
-    _glfw.wl.keycodes[KEY_F5]         = GLFW_KEY_F5;
-    _glfw.wl.keycodes[KEY_F6]         = GLFW_KEY_F6;
-    _glfw.wl.keycodes[KEY_F7]         = GLFW_KEY_F7;
-    _glfw.wl.keycodes[KEY_F8]         = GLFW_KEY_F8;
-    _glfw.wl.keycodes[KEY_F9]         = GLFW_KEY_F9;
-    _glfw.wl.keycodes[KEY_F10]        = GLFW_KEY_F10;
-    _glfw.wl.keycodes[KEY_F11]        = GLFW_KEY_F11;
-    _glfw.wl.keycodes[KEY_F12]        = GLFW_KEY_F12;
-    _glfw.wl.keycodes[KEY_F13]        = GLFW_KEY_F13;
-    _glfw.wl.keycodes[KEY_F14]        = GLFW_KEY_F14;
-    _glfw.wl.keycodes[KEY_F15]        = GLFW_KEY_F15;
-    _glfw.wl.keycodes[KEY_F16]        = GLFW_KEY_F16;
-    _glfw.wl.keycodes[KEY_F17]        = GLFW_KEY_F17;
-    _glfw.wl.keycodes[KEY_F18]        = GLFW_KEY_F18;
-    _glfw.wl.keycodes[KEY_F19]        = GLFW_KEY_F19;
-    _glfw.wl.keycodes[KEY_F20]        = GLFW_KEY_F20;
-    _glfw.wl.keycodes[KEY_F21]        = GLFW_KEY_F21;
-    _glfw.wl.keycodes[KEY_F22]        = GLFW_KEY_F22;
-    _glfw.wl.keycodes[KEY_F23]        = GLFW_KEY_F23;
-    _glfw.wl.keycodes[KEY_F24]        = GLFW_KEY_F24;
-    _glfw.wl.keycodes[KEY_KPSLASH]    = GLFW_KEY_KP_DIVIDE;
-    _glfw.wl.keycodes[KEY_KPDOT]      = GLFW_KEY_KP_MULTIPLY;
-    _glfw.wl.keycodes[KEY_KPMINUS]    = GLFW_KEY_KP_SUBTRACT;
-    _glfw.wl.keycodes[KEY_KPPLUS]     = GLFW_KEY_KP_ADD;
-    _glfw.wl.keycodes[KEY_KP0]        = GLFW_KEY_KP_0;
-    _glfw.wl.keycodes[KEY_KP1]        = GLFW_KEY_KP_1;
-    _glfw.wl.keycodes[KEY_KP2]        = GLFW_KEY_KP_2;
-    _glfw.wl.keycodes[KEY_KP3]        = GLFW_KEY_KP_3;
-    _glfw.wl.keycodes[KEY_KP4]        = GLFW_KEY_KP_4;
-    _glfw.wl.keycodes[KEY_KP5]        = GLFW_KEY_KP_5;
-    _glfw.wl.keycodes[KEY_KP6]        = GLFW_KEY_KP_6;
-    _glfw.wl.keycodes[KEY_KP7]        = GLFW_KEY_KP_7;
-    _glfw.wl.keycodes[KEY_KP8]        = GLFW_KEY_KP_8;
-    _glfw.wl.keycodes[KEY_KP9]        = GLFW_KEY_KP_9;
-    _glfw.wl.keycodes[KEY_KPCOMMA]    = GLFW_KEY_KP_DECIMAL;
-    _glfw.wl.keycodes[KEY_KPEQUAL]    = GLFW_KEY_KP_EQUAL;
-    _glfw.wl.keycodes[KEY_KPENTER]    = GLFW_KEY_KP_ENTER;
-
-    for (scancode = 0;  scancode < 256;  scancode++)
-    {
-        if (_glfw.wl.keycodes[scancode] > 0)
-            _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    const char *cursorTheme;
-    const char *cursorSizeStr;
-    char *cursorSizeEnd;
-    long cursorSizeLong;
-    int cursorSize;
-    int i;
-    _GLFWmonitor* monitor;
-
-    _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
-    if (!_glfw.wl.cursor.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libwayland-cursor");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
-    _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
-    _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
-    _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
-
-    _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
-    if (!_glfw.wl.egl.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libwayland-egl");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
-    _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
-    _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
-
-    _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
-    if (!_glfw.wl.xkb.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libxkbcommon");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.xkb.context_new = (PFN_xkb_context_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
-    _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
-    _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
-    _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
-    _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
-    _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
-    _glfw.wl.xkb.state_new = (PFN_xkb_state_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
-    _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
-    _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
-    _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
-    _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
-    _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
-    _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
-    _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
-    _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
-    _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
-    _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
-#endif
-
-    _glfw.wl.display = wl_display_connect(NULL);
-    if (!_glfw.wl.display)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to connect to display");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
-    wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
-
-    createKeyTables();
-
-    _glfw.wl.xkb.context = xkb_context_new(0);
-    if (!_glfw.wl.xkb.context)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to initialize xkb context");
-        return GLFW_FALSE;
-    }
-
-    // Sync so we got all registry objects
-    wl_display_roundtrip(_glfw.wl.display);
-
-    // Sync so we got all initial output events
-    wl_display_roundtrip(_glfw.wl.display);
-
-    for (i = 0; i < _glfw.monitorCount; ++i)
-    {
-        monitor = _glfw.monitors[i];
-        if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
-        {
-            // If Wayland does not provide a physical size, assume the default 96 DPI
-            monitor->widthMM  = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f);
-            monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f);
-        }
-    }
-
-    _glfwInitTimerPOSIX();
-
-    _glfw.wl.timerfd = -1;
-    if (_glfw.wl.seatVersion >= 4)
-        _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
-
-    if (!_glfw.wl.wmBase)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to find xdg-shell in your compositor");
-        return GLFW_FALSE;
-    }
-
-    if (_glfw.wl.pointer && _glfw.wl.shm)
-    {
-        cursorTheme = getenv("XCURSOR_THEME");
-        cursorSizeStr = getenv("XCURSOR_SIZE");
-        cursorSize = 32;
-        if (cursorSizeStr)
-        {
-            errno = 0;
-            cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
-            if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
-                cursorSize = (int)cursorSizeLong;
-        }
-        _glfw.wl.cursorTheme =
-            wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
-        if (!_glfw.wl.cursorTheme)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Unable to load default cursor theme");
-            return GLFW_FALSE;
-        }
-        // If this happens to be NULL, we just fallback to the scale=1 version.
-        _glfw.wl.cursorThemeHiDPI =
-            wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
-        _glfw.wl.cursorSurface =
-            wl_compositor_create_surface(_glfw.wl.compositor);
-        _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
-    }
-
-    if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
-    {
-        _glfw.wl.dataDevice =
-            wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
-                                                   _glfw.wl.seat);
-        wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
-        _glfw.wl.clipboardString = malloc(4096);
-        if (!_glfw.wl.clipboardString)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Unable to allocate clipboard memory");
-            return GLFW_FALSE;
-        }
-        _glfw.wl.clipboardSize = 4096;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    _glfwTerminateEGL();
-    if (_glfw.wl.egl.handle)
-    {
-        _glfw_dlclose(_glfw.wl.egl.handle);
-        _glfw.wl.egl.handle = NULL;
-    }
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    if (_glfw.wl.xkb.composeState)
-        xkb_compose_state_unref(_glfw.wl.xkb.composeState);
-#endif
-    if (_glfw.wl.xkb.keymap)
-        xkb_keymap_unref(_glfw.wl.xkb.keymap);
-    if (_glfw.wl.xkb.state)
-        xkb_state_unref(_glfw.wl.xkb.state);
-    if (_glfw.wl.xkb.context)
-        xkb_context_unref(_glfw.wl.xkb.context);
-    if (_glfw.wl.xkb.handle)
-    {
-        _glfw_dlclose(_glfw.wl.xkb.handle);
-        _glfw.wl.xkb.handle = NULL;
-    }
-
-    if (_glfw.wl.cursorTheme)
-        wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
-    if (_glfw.wl.cursorThemeHiDPI)
-        wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
-    if (_glfw.wl.cursor.handle)
-    {
-        _glfw_dlclose(_glfw.wl.cursor.handle);
-        _glfw.wl.cursor.handle = NULL;
-    }
-
-    if (_glfw.wl.cursorSurface)
-        wl_surface_destroy(_glfw.wl.cursorSurface);
-    if (_glfw.wl.subcompositor)
-        wl_subcompositor_destroy(_glfw.wl.subcompositor);
-    if (_glfw.wl.compositor)
-        wl_compositor_destroy(_glfw.wl.compositor);
-    if (_glfw.wl.shm)
-        wl_shm_destroy(_glfw.wl.shm);
-    if (_glfw.wl.viewporter)
-        wp_viewporter_destroy(_glfw.wl.viewporter);
-    if (_glfw.wl.decorationManager)
-        zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
-    if (_glfw.wl.wmBase)
-        xdg_wm_base_destroy(_glfw.wl.wmBase);
-    if (_glfw.wl.dataSource)
-        wl_data_source_destroy(_glfw.wl.dataSource);
-    if (_glfw.wl.dataDevice)
-        wl_data_device_destroy(_glfw.wl.dataDevice);
-    if (_glfw.wl.dataOffer)
-        wl_data_offer_destroy(_glfw.wl.dataOffer);
-    if (_glfw.wl.dataDeviceManager)
-        wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
-    if (_glfw.wl.pointer)
-        wl_pointer_destroy(_glfw.wl.pointer);
-    if (_glfw.wl.keyboard)
-        wl_keyboard_destroy(_glfw.wl.keyboard);
-    if (_glfw.wl.seat)
-        wl_seat_destroy(_glfw.wl.seat);
-    if (_glfw.wl.relativePointerManager)
-        zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
-    if (_glfw.wl.pointerConstraints)
-        zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
-    if (_glfw.wl.idleInhibitManager)
-        zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
-    if (_glfw.wl.registry)
-        wl_registry_destroy(_glfw.wl.registry);
-    if (_glfw.wl.display)
-    {
-        wl_display_flush(_glfw.wl.display);
-        wl_display_disconnect(_glfw.wl.display);
-    }
-
-    if (_glfw.wl.timerfd >= 0)
-        close(_glfw.wl.timerfd);
-    if (_glfw.wl.cursorTimerfd >= 0)
-        close(_glfw.wl.cursorTimerfd);
-
-    if (_glfw.wl.clipboardString)
-        free(_glfw.wl.clipboardString);
-    if (_glfw.wl.clipboardSendString)
-        free(_glfw.wl.clipboardSendString);
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-        " clock_gettime"
-#else
-        " gettimeofday"
-#endif
-        " evdev"
-#if defined(_GLFW_BUILD_DLL)
-        " shared"
-#endif
-        ;
-}
diff --git a/raylib/external/glfw/src/wl_monitor.c b/raylib/external/glfw/src/wl_monitor.c
deleted file mode 100644 (file)
index a6356de..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-
-
-static void outputHandleGeometry(void* data,
-                                 struct wl_output* output,
-                                 int32_t x,
-                                 int32_t y,
-                                 int32_t physicalWidth,
-                                 int32_t physicalHeight,
-                                 int32_t subpixel,
-                                 const char* make,
-                                 const char* model,
-                                 int32_t transform)
-{
-    struct _GLFWmonitor *monitor = data;
-    char name[1024];
-
-    monitor->wl.x = x;
-    monitor->wl.y = y;
-    monitor->widthMM = physicalWidth;
-    monitor->heightMM = physicalHeight;
-
-    snprintf(name, sizeof(name), "%s %s", make, model);
-    monitor->name = _glfw_strdup(name);
-}
-
-static void outputHandleMode(void* data,
-                             struct wl_output* output,
-                             uint32_t flags,
-                             int32_t width,
-                             int32_t height,
-                             int32_t refresh)
-{
-    struct _GLFWmonitor *monitor = data;
-    GLFWvidmode mode;
-
-    mode.width = width;
-    mode.height = height;
-    mode.redBits = 8;
-    mode.greenBits = 8;
-    mode.blueBits = 8;
-    mode.refreshRate = (int) round(refresh / 1000.0);
-
-    monitor->modeCount++;
-    monitor->modes =
-        realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
-    monitor->modes[monitor->modeCount - 1] = mode;
-
-    if (flags & WL_OUTPUT_MODE_CURRENT)
-        monitor->wl.currentMode = monitor->modeCount - 1;
-}
-
-static void outputHandleDone(void* data, struct wl_output* output)
-{
-    struct _GLFWmonitor *monitor = data;
-
-    _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
-}
-
-static void outputHandleScale(void* data,
-                              struct wl_output* output,
-                              int32_t factor)
-{
-    struct _GLFWmonitor *monitor = data;
-
-    monitor->wl.scale = factor;
-}
-
-static const struct wl_output_listener outputListener = {
-    outputHandleGeometry,
-    outputHandleMode,
-    outputHandleDone,
-    outputHandleScale,
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwAddOutputWayland(uint32_t name, uint32_t version)
-{
-    _GLFWmonitor *monitor;
-    struct wl_output *output;
-
-    if (version < 2)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unsupported output interface version");
-        return;
-    }
-
-    // The actual name of this output will be set in the geometry handler.
-    monitor = _glfwAllocMonitor(NULL, 0, 0);
-
-    output = wl_registry_bind(_glfw.wl.registry,
-                              name,
-                              &wl_output_interface,
-                              2);
-    if (!output)
-    {
-        _glfwFreeMonitor(monitor);
-        return;
-    }
-
-    monitor->wl.scale = 1;
-    monitor->wl.output = output;
-    monitor->wl.name = name;
-
-    wl_output_add_listener(output, &outputListener, monitor);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-    if (monitor->wl.output)
-        wl_output_destroy(monitor->wl.output);
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = monitor->wl.x;
-    if (ypos)
-        *ypos = monitor->wl.y;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = (float) monitor->wl.scale;
-    if (yscale)
-        *yscale = (float) monitor->wl.scale;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    if (xpos)
-        *xpos = monitor->wl.x;
-    if (ypos)
-        *ypos = monitor->wl.y;
-    if (width)
-        *width = monitor->modes[monitor->wl.currentMode].width;
-    if (height)
-        *height = monitor->modes[monitor->wl.currentMode].height;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
-{
-    *found = monitor->modeCount;
-    return monitor->modes;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    *mode = monitor->modes[monitor->wl.currentMode];
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: Gamma ramp access is not available");
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
-                               const GLFWgammaramp* ramp)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: Gamma ramp access is not available");
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->wl.output;
-}
-
diff --git a/raylib/external/glfw/src/wl_platform.h b/raylib/external/glfw/src/wl_platform.h
deleted file mode 100644 (file)
index 966155f..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <wayland-client.h>
-#include <xkbcommon/xkbcommon.h>
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-#include <xkbcommon/xkbcommon-compose.h>
-#endif
-#include <dlfcn.h>
-
-typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
-
-typedef struct VkWaylandSurfaceCreateInfoKHR
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkWaylandSurfaceCreateFlagsKHR  flags;
-    struct wl_display*              display;
-    struct wl_surface*              surface;
-} VkWaylandSurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
-
-#include "posix_thread.h"
-#include "posix_time.h"
-#ifdef __linux__
-#include "linux_joystick.h"
-#else
-#include "null_joystick.h"
-#endif
-#include "xkb_unicode.h"
-
-#include "wayland-xdg-shell-client-protocol.h"
-#include "wayland-xdg-decoration-client-protocol.h"
-#include "wayland-viewporter-client-protocol.h"
-#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
-#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
-#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWayland  wl
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWayland wl
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWayland  wl
-
-#define _GLFW_PLATFORM_CONTEXT_STATE         struct { int dummyContext; }
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
-
-struct wl_cursor_image {
-    uint32_t width;
-    uint32_t height;
-    uint32_t hotspot_x;
-    uint32_t hotspot_y;
-    uint32_t delay;
-};
-struct wl_cursor {
-    unsigned int image_count;
-    struct wl_cursor_image** images;
-    char* name;
-};
-typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
-typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
-typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);
-typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*);
-#define wl_cursor_theme_load _glfw.wl.cursor.theme_load
-#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy
-#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor
-#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer
-
-typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int);
-typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*);
-typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int);
-#define wl_egl_window_create _glfw.wl.egl.window_create
-#define wl_egl_window_destroy _glfw.wl.egl.window_destroy
-#define wl_egl_window_resize _glfw.wl.egl.window_resize
-
-typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags);
-typedef void (* PFN_xkb_context_unref)(struct xkb_context*);
-typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
-typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
-typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
-typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
-typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
-typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
-typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
-typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
-typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
-#define xkb_context_new _glfw.wl.xkb.context_new
-#define xkb_context_unref _glfw.wl.xkb.context_unref
-#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
-#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
-#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
-#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
-#define xkb_state_new _glfw.wl.xkb.state_new
-#define xkb_state_unref _glfw.wl.xkb.state_unref
-#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
-#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
-#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
-typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
-typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
-typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*);
-typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t);
-typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*);
-typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*);
-#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale
-#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref
-#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new
-#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref
-#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
-#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
-#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
-#endif
-
-#define _GLFW_DECORATION_WIDTH 4
-#define _GLFW_DECORATION_TOP 24
-#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH)
-#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH)
-
-typedef enum _GLFWdecorationSideWayland
-{
-    mainWindow,
-    topDecoration,
-    leftDecoration,
-    rightDecoration,
-    bottomDecoration,
-
-} _GLFWdecorationSideWayland;
-
-typedef struct _GLFWdecorationWayland
-{
-    struct wl_surface*          surface;
-    struct wl_subsurface*       subsurface;
-    struct wp_viewport*         viewport;
-
-} _GLFWdecorationWayland;
-
-// Wayland-specific per-window data
-//
-typedef struct _GLFWwindowWayland
-{
-    int                         width, height;
-    GLFWbool                    visible;
-    GLFWbool                    maximized;
-    GLFWbool                    hovered;
-    GLFWbool                    transparent;
-    struct wl_surface*          surface;
-    struct wl_egl_window*       native;
-    struct wl_callback*         callback;
-
-    struct {
-        struct xdg_surface*     surface;
-        struct xdg_toplevel*    toplevel;
-        struct zxdg_toplevel_decoration_v1* decoration;
-    } xdg;
-
-    _GLFWcursor*                currentCursor;
-    double                      cursorPosX, cursorPosY;
-
-    char*                       title;
-
-    // We need to track the monitors the window spans on to calculate the
-    // optimal scaling factor.
-    int                         scale;
-    _GLFWmonitor**              monitors;
-    int                         monitorsCount;
-    int                         monitorsSize;
-
-    struct {
-        struct zwp_relative_pointer_v1*    relativePointer;
-        struct zwp_locked_pointer_v1*      lockedPointer;
-    } pointerLock;
-
-    struct zwp_idle_inhibitor_v1*          idleInhibitor;
-
-    GLFWbool                    wasFullscreen;
-
-    struct {
-        GLFWbool                           serverSide;
-        struct wl_buffer*                  buffer;
-        _GLFWdecorationWayland             top, left, right, bottom;
-        int                                focus;
-    } decorations;
-
-} _GLFWwindowWayland;
-
-// Wayland-specific global data
-//
-typedef struct _GLFWlibraryWayland
-{
-    struct wl_display*          display;
-    struct wl_registry*         registry;
-    struct wl_compositor*       compositor;
-    struct wl_subcompositor*    subcompositor;
-    struct wl_shm*              shm;
-    struct wl_seat*             seat;
-    struct wl_pointer*          pointer;
-    struct wl_keyboard*         keyboard;
-    struct wl_data_device_manager*          dataDeviceManager;
-    struct wl_data_device*      dataDevice;
-    struct wl_data_offer*       dataOffer;
-    struct wl_data_source*      dataSource;
-    struct xdg_wm_base*         wmBase;
-    struct zxdg_decoration_manager_v1*      decorationManager;
-    struct wp_viewporter*       viewporter;
-    struct zwp_relative_pointer_manager_v1* relativePointerManager;
-    struct zwp_pointer_constraints_v1*      pointerConstraints;
-    struct zwp_idle_inhibit_manager_v1*     idleInhibitManager;
-
-    int                         compositorVersion;
-    int                         seatVersion;
-
-    struct wl_cursor_theme*     cursorTheme;
-    struct wl_cursor_theme*     cursorThemeHiDPI;
-    struct wl_surface*          cursorSurface;
-    const char*                 cursorPreviousName;
-    int                         cursorTimerfd;
-    uint32_t                    serial;
-
-    int32_t                     keyboardRepeatRate;
-    int32_t                     keyboardRepeatDelay;
-    int                         keyboardLastKey;
-    int                         keyboardLastScancode;
-    char*                       clipboardString;
-    size_t                      clipboardSize;
-    char*                       clipboardSendString;
-    size_t                      clipboardSendSize;
-    int                         timerfd;
-    short int                   keycodes[256];
-    short int                   scancodes[GLFW_KEY_LAST + 1];
-
-    struct {
-        void*                   handle;
-        struct xkb_context*     context;
-        struct xkb_keymap*      keymap;
-        struct xkb_state*       state;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        struct xkb_compose_state* composeState;
-#endif
-
-        xkb_mod_mask_t          controlMask;
-        xkb_mod_mask_t          altMask;
-        xkb_mod_mask_t          shiftMask;
-        xkb_mod_mask_t          superMask;
-        xkb_mod_mask_t          capsLockMask;
-        xkb_mod_mask_t          numLockMask;
-        unsigned int            modifiers;
-
-        PFN_xkb_context_new context_new;
-        PFN_xkb_context_unref context_unref;
-        PFN_xkb_keymap_new_from_string keymap_new_from_string;
-        PFN_xkb_keymap_unref keymap_unref;
-        PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
-        PFN_xkb_keymap_key_repeats keymap_key_repeats;
-        PFN_xkb_state_new state_new;
-        PFN_xkb_state_unref state_unref;
-        PFN_xkb_state_key_get_syms state_key_get_syms;
-        PFN_xkb_state_update_mask state_update_mask;
-        PFN_xkb_state_serialize_mods state_serialize_mods;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
-        PFN_xkb_compose_table_unref compose_table_unref;
-        PFN_xkb_compose_state_new compose_state_new;
-        PFN_xkb_compose_state_unref compose_state_unref;
-        PFN_xkb_compose_state_feed compose_state_feed;
-        PFN_xkb_compose_state_get_status compose_state_get_status;
-        PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
-#endif
-    } xkb;
-
-    _GLFWwindow*                pointerFocus;
-    _GLFWwindow*                keyboardFocus;
-
-    struct {
-        void*                   handle;
-
-        PFN_wl_cursor_theme_load theme_load;
-        PFN_wl_cursor_theme_destroy theme_destroy;
-        PFN_wl_cursor_theme_get_cursor theme_get_cursor;
-        PFN_wl_cursor_image_get_buffer image_get_buffer;
-    } cursor;
-
-    struct {
-        void*                   handle;
-
-        PFN_wl_egl_window_create window_create;
-        PFN_wl_egl_window_destroy window_destroy;
-        PFN_wl_egl_window_resize window_resize;
-    } egl;
-
-} _GLFWlibraryWayland;
-
-// Wayland-specific per-monitor data
-//
-typedef struct _GLFWmonitorWayland
-{
-    struct wl_output*           output;
-    uint32_t                    name;
-    int                         currentMode;
-
-    int                         x;
-    int                         y;
-    int                         scale;
-
-} _GLFWmonitorWayland;
-
-// Wayland-specific per-cursor data
-//
-typedef struct _GLFWcursorWayland
-{
-    struct wl_cursor*           cursor;
-    struct wl_cursor*           cursorHiDPI;
-    struct wl_buffer*           buffer;
-    int                         width, height;
-    int                         xhot, yhot;
-    int                         currentImage;
-} _GLFWcursorWayland;
-
-
-void _glfwAddOutputWayland(uint32_t name, uint32_t version);
-
diff --git a/raylib/external/glfw/src/wl_window.c b/raylib/external/glfw/src/wl_window.c
deleted file mode 100644 (file)
index 7b315d7..0000000
+++ /dev/null
@@ -1,1800 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _GNU_SOURCE
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/timerfd.h>
-#include <poll.h>
-
-
-static int createTmpfileCloexec(char* tmpname)
-{
-    int fd;
-
-    fd = mkostemp(tmpname, O_CLOEXEC);
-    if (fd >= 0)
-        unlink(tmpname);
-
-    return fd;
-}
-
-/*
- * Create a new, unique, anonymous file of the given size, and
- * return the file descriptor for it. The file descriptor is set
- * CLOEXEC. The file is immediately suitable for mmap()'ing
- * the given size at offset zero.
- *
- * The file should not have a permanent backing store like a disk,
- * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
- *
- * The file name is deleted from the file system.
- *
- * The file is suitable for buffer sharing between processes by
- * transmitting the file descriptor over Unix sockets using the
- * SCM_RIGHTS methods.
- *
- * posix_fallocate() is used to guarantee that disk space is available
- * for the file at the given size. If disk space is insufficient, errno
- * is set to ENOSPC. If posix_fallocate() is not supported, program may
- * receive SIGBUS on accessing mmap()'ed file contents instead.
- */
-static int createAnonymousFile(off_t size)
-{
-    static const char template[] = "/glfw-shared-XXXXXX";
-    const char* path;
-    char* name;
-    int fd;
-    int ret;
-
-#ifdef HAVE_MEMFD_CREATE
-    fd = memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
-    if (fd >= 0)
-    {
-        // We can add this seal before calling posix_fallocate(), as the file
-        // is currently zero-sized anyway.
-        //
-        // There is also no need to check for the return value, we couldn’t do
-        // anything with it anyway.
-        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
-    }
-    else
-#elif defined(SHM_ANON)
-    fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
-    if (fd < 0)
-#endif
-    {
-        path = getenv("XDG_RUNTIME_DIR");
-        if (!path)
-        {
-            errno = ENOENT;
-            return -1;
-        }
-
-        name = calloc(strlen(path) + sizeof(template), 1);
-        strcpy(name, path);
-        strcat(name, template);
-
-        fd = createTmpfileCloexec(name);
-        free(name);
-        if (fd < 0)
-            return -1;
-    }
-
-#if defined(SHM_ANON)
-    // posix_fallocate does not work on SHM descriptors
-    ret = ftruncate(fd, size);
-#else
-    ret = posix_fallocate(fd, 0, size);
-#endif
-    if (ret != 0)
-    {
-        close(fd);
-        errno = ret;
-        return -1;
-    }
-    return fd;
-}
-
-static struct wl_buffer* createShmBuffer(const GLFWimage* image)
-{
-    struct wl_shm_pool* pool;
-    struct wl_buffer* buffer;
-    int stride = image->width * 4;
-    int length = image->width * image->height * 4;
-    void* data;
-    int fd, i;
-
-    fd = createAnonymousFile(length);
-    if (fd < 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Creating a buffer file for %d B failed: %s",
-                        length, strerror(errno));
-        return NULL;
-    }
-
-    data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-    if (data == MAP_FAILED)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: mmap failed: %s", strerror(errno));
-        close(fd);
-        return NULL;
-    }
-
-    pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
-
-    close(fd);
-    unsigned char* source = (unsigned char*) image->pixels;
-    unsigned char* target = data;
-    for (i = 0;  i < image->width * image->height;  i++, source += 4)
-    {
-        unsigned int alpha = source[3];
-
-        *target++ = (unsigned char) ((source[2] * alpha) / 255);
-        *target++ = (unsigned char) ((source[1] * alpha) / 255);
-        *target++ = (unsigned char) ((source[0] * alpha) / 255);
-        *target++ = (unsigned char) alpha;
-    }
-
-    buffer =
-        wl_shm_pool_create_buffer(pool, 0,
-                                  image->width,
-                                  image->height,
-                                  stride, WL_SHM_FORMAT_ARGB8888);
-    munmap(data, length);
-    wl_shm_pool_destroy(pool);
-
-    return buffer;
-}
-
-static void createDecoration(_GLFWdecorationWayland* decoration,
-                             struct wl_surface* parent,
-                             struct wl_buffer* buffer, GLFWbool opaque,
-                             int x, int y,
-                             int width, int height)
-{
-    struct wl_region* region;
-
-    decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
-    decoration->subsurface =
-        wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
-                                        decoration->surface, parent);
-    wl_subsurface_set_position(decoration->subsurface, x, y);
-    decoration->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter,
-                                                      decoration->surface);
-    wp_viewport_set_destination(decoration->viewport, width, height);
-    wl_surface_attach(decoration->surface, buffer, 0, 0);
-
-    if (opaque)
-    {
-        region = wl_compositor_create_region(_glfw.wl.compositor);
-        wl_region_add(region, 0, 0, width, height);
-        wl_surface_set_opaque_region(decoration->surface, region);
-        wl_surface_commit(decoration->surface);
-        wl_region_destroy(region);
-    }
-    else
-        wl_surface_commit(decoration->surface);
-}
-
-static void createDecorations(_GLFWwindow* window)
-{
-    unsigned char data[] = { 224, 224, 224, 255 };
-    const GLFWimage image = { 1, 1, data };
-    GLFWbool opaque = (data[3] == 255);
-
-    if (!_glfw.wl.viewporter || !window->decorated || window->wl.decorations.serverSide)
-        return;
-
-    if (!window->wl.decorations.buffer)
-        window->wl.decorations.buffer = createShmBuffer(&image);
-    if (!window->wl.decorations.buffer)
-        return;
-
-    createDecoration(&window->wl.decorations.top, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     0, -_GLFW_DECORATION_TOP,
-                     window->wl.width, _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.left, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     -_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
-                     _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.right, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     window->wl.width, -_GLFW_DECORATION_TOP,
-                     _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.bottom, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     -_GLFW_DECORATION_WIDTH, window->wl.height,
-                     window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
-}
-
-static void destroyDecoration(_GLFWdecorationWayland* decoration)
-{
-    if (decoration->surface)
-        wl_surface_destroy(decoration->surface);
-    if (decoration->subsurface)
-        wl_subsurface_destroy(decoration->subsurface);
-    if (decoration->viewport)
-        wp_viewport_destroy(decoration->viewport);
-    decoration->surface = NULL;
-    decoration->subsurface = NULL;
-    decoration->viewport = NULL;
-}
-
-static void destroyDecorations(_GLFWwindow* window)
-{
-    destroyDecoration(&window->wl.decorations.top);
-    destroyDecoration(&window->wl.decorations.left);
-    destroyDecoration(&window->wl.decorations.right);
-    destroyDecoration(&window->wl.decorations.bottom);
-}
-
-static void xdgDecorationHandleConfigure(void* data,
-                                         struct zxdg_toplevel_decoration_v1* decoration,
-                                         uint32_t mode)
-{
-    _GLFWwindow* window = data;
-
-    window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
-
-    if (!window->wl.decorations.serverSide)
-        createDecorations(window);
-}
-
-static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
-    xdgDecorationHandleConfigure,
-};
-
-// Makes the surface considered as XRGB instead of ARGB.
-static void setOpaqueRegion(_GLFWwindow* window)
-{
-    struct wl_region* region;
-
-    region = wl_compositor_create_region(_glfw.wl.compositor);
-    if (!region)
-        return;
-
-    wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
-    wl_surface_set_opaque_region(window->wl.surface, region);
-    wl_surface_commit(window->wl.surface);
-    wl_region_destroy(region);
-}
-
-
-static void resizeWindow(_GLFWwindow* window)
-{
-    int scale = window->wl.scale;
-    int scaledWidth = window->wl.width * scale;
-    int scaledHeight = window->wl.height * scale;
-    wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
-    if (!window->wl.transparent)
-        setOpaqueRegion(window);
-    _glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
-    _glfwInputWindowContentScale(window, scale, scale);
-
-    if (!window->wl.decorations.top.surface)
-        return;
-
-    // Top decoration.
-    wp_viewport_set_destination(window->wl.decorations.top.viewport,
-                                window->wl.width, _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.top.surface);
-
-    // Left decoration.
-    wp_viewport_set_destination(window->wl.decorations.left.viewport,
-                                _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.left.surface);
-
-    // Right decoration.
-    wl_subsurface_set_position(window->wl.decorations.right.subsurface,
-                               window->wl.width, -_GLFW_DECORATION_TOP);
-    wp_viewport_set_destination(window->wl.decorations.right.viewport,
-                                _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.right.surface);
-
-    // Bottom decoration.
-    wl_subsurface_set_position(window->wl.decorations.bottom.subsurface,
-                               -_GLFW_DECORATION_WIDTH, window->wl.height);
-    wp_viewport_set_destination(window->wl.decorations.bottom.viewport,
-                                window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
-    wl_surface_commit(window->wl.decorations.bottom.surface);
-}
-
-static void checkScaleChange(_GLFWwindow* window)
-{
-    int scale = 1;
-    int i;
-    int monitorScale;
-
-    // Check if we will be able to set the buffer scale or not.
-    if (_glfw.wl.compositorVersion < 3)
-        return;
-
-    // Get the scale factor from the highest scale monitor.
-    for (i = 0; i < window->wl.monitorsCount; ++i)
-    {
-        monitorScale = window->wl.monitors[i]->wl.scale;
-        if (scale < monitorScale)
-            scale = monitorScale;
-    }
-
-    // Only change the framebuffer size if the scale changed.
-    if (scale != window->wl.scale)
-    {
-        window->wl.scale = scale;
-        wl_surface_set_buffer_scale(window->wl.surface, scale);
-        resizeWindow(window);
-    }
-}
-
-static void surfaceHandleEnter(void *data,
-                               struct wl_surface *surface,
-                               struct wl_output *output)
-{
-    _GLFWwindow* window = data;
-    _GLFWmonitor* monitor = wl_output_get_user_data(output);
-
-    if (window->wl.monitorsCount + 1 > window->wl.monitorsSize)
-    {
-        ++window->wl.monitorsSize;
-        window->wl.monitors =
-            realloc(window->wl.monitors,
-                    window->wl.monitorsSize * sizeof(_GLFWmonitor*));
-    }
-
-    window->wl.monitors[window->wl.monitorsCount++] = monitor;
-
-    checkScaleChange(window);
-}
-
-static void surfaceHandleLeave(void *data,
-                               struct wl_surface *surface,
-                               struct wl_output *output)
-{
-    _GLFWwindow* window = data;
-    _GLFWmonitor* monitor = wl_output_get_user_data(output);
-    GLFWbool found;
-    int i;
-
-    for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
-    {
-        if (monitor == window->wl.monitors[i])
-            found = GLFW_TRUE;
-        if (found)
-            window->wl.monitors[i] = window->wl.monitors[i + 1];
-    }
-    window->wl.monitors[--window->wl.monitorsCount] = NULL;
-
-    checkScaleChange(window);
-}
-
-static const struct wl_surface_listener surfaceListener = {
-    surfaceHandleEnter,
-    surfaceHandleLeave
-};
-
-static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
-{
-    if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
-    {
-        window->wl.idleInhibitor =
-            zwp_idle_inhibit_manager_v1_create_inhibitor(
-                _glfw.wl.idleInhibitManager, window->wl.surface);
-        if (!window->wl.idleInhibitor)
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Idle inhibitor creation failed");
-    }
-    else if (!enable && window->wl.idleInhibitor)
-    {
-        zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
-        window->wl.idleInhibitor = NULL;
-    }
-}
-
-static GLFWbool createSurface(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig)
-{
-    window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
-    if (!window->wl.surface)
-        return GLFW_FALSE;
-
-    wl_surface_add_listener(window->wl.surface,
-                            &surfaceListener,
-                            window);
-
-    wl_surface_set_user_data(window->wl.surface, window);
-
-    window->wl.native = wl_egl_window_create(window->wl.surface,
-                                             wndconfig->width,
-                                             wndconfig->height);
-    if (!window->wl.native)
-        return GLFW_FALSE;
-
-    window->wl.width = wndconfig->width;
-    window->wl.height = wndconfig->height;
-    window->wl.scale = 1;
-
-    if (!window->wl.transparent)
-        setOpaqueRegion(window);
-
-    return GLFW_TRUE;
-}
-
-static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor,
-                          int refreshRate)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_set_fullscreen(
-            window->wl.xdg.toplevel,
-            monitor->wl.output);
-    }
-    setIdleInhibitor(window, GLFW_TRUE);
-    if (!window->wl.decorations.serverSide)
-        destroyDecorations(window);
-}
-
-static void xdgToplevelHandleConfigure(void* data,
-                                       struct xdg_toplevel* toplevel,
-                                       int32_t width,
-                                       int32_t height,
-                                       struct wl_array* states)
-{
-    _GLFWwindow* window = data;
-    float aspectRatio;
-    float targetRatio;
-    uint32_t* state;
-    GLFWbool maximized = GLFW_FALSE;
-    GLFWbool fullscreen = GLFW_FALSE;
-    GLFWbool activated = GLFW_FALSE;
-
-    wl_array_for_each(state, states)
-    {
-        switch (*state)
-        {
-            case XDG_TOPLEVEL_STATE_MAXIMIZED:
-                maximized = GLFW_TRUE;
-                break;
-            case XDG_TOPLEVEL_STATE_FULLSCREEN:
-                fullscreen = GLFW_TRUE;
-                break;
-            case XDG_TOPLEVEL_STATE_RESIZING:
-                break;
-            case XDG_TOPLEVEL_STATE_ACTIVATED:
-                activated = GLFW_TRUE;
-                break;
-        }
-    }
-
-    if (width != 0 && height != 0)
-    {
-        if (!maximized && !fullscreen)
-        {
-            if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
-            {
-                aspectRatio = (float)width / (float)height;
-                targetRatio = (float)window->numer / (float)window->denom;
-                if (aspectRatio < targetRatio)
-                    height = width / targetRatio;
-                else if (aspectRatio > targetRatio)
-                    width = height * targetRatio;
-            }
-        }
-
-        _glfwInputWindowSize(window, width, height);
-        _glfwPlatformSetWindowSize(window, width, height);
-        _glfwInputWindowDamage(window);
-    }
-
-    if (window->wl.wasFullscreen && window->autoIconify)
-    {
-        if (!activated || !fullscreen)
-        {
-            _glfwPlatformIconifyWindow(window);
-            window->wl.wasFullscreen = GLFW_FALSE;
-        }
-    }
-    if (fullscreen && activated)
-        window->wl.wasFullscreen = GLFW_TRUE;
-    _glfwInputWindowFocus(window, activated);
-}
-
-static void xdgToplevelHandleClose(void* data,
-                                   struct xdg_toplevel* toplevel)
-{
-    _GLFWwindow* window = data;
-    _glfwInputWindowCloseRequest(window);
-}
-
-static const struct xdg_toplevel_listener xdgToplevelListener = {
-    xdgToplevelHandleConfigure,
-    xdgToplevelHandleClose
-};
-
-static void xdgSurfaceHandleConfigure(void* data,
-                                      struct xdg_surface* surface,
-                                      uint32_t serial)
-{
-    xdg_surface_ack_configure(surface, serial);
-}
-
-static const struct xdg_surface_listener xdgSurfaceListener = {
-    xdgSurfaceHandleConfigure
-};
-
-static void setXdgDecorations(_GLFWwindow* window)
-{
-    if (_glfw.wl.decorationManager)
-    {
-        window->wl.xdg.decoration =
-            zxdg_decoration_manager_v1_get_toplevel_decoration(
-                _glfw.wl.decorationManager, window->wl.xdg.toplevel);
-        zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration,
-                                                 &xdgDecorationListener,
-                                                 window);
-        zxdg_toplevel_decoration_v1_set_mode(
-            window->wl.xdg.decoration,
-            ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
-    }
-    else
-    {
-        window->wl.decorations.serverSide = GLFW_FALSE;
-        createDecorations(window);
-    }
-}
-
-static GLFWbool createXdgSurface(_GLFWwindow* window)
-{
-    window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase,
-                                                         window->wl.surface);
-    if (!window->wl.xdg.surface)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: xdg-surface creation failed");
-        return GLFW_FALSE;
-    }
-
-    xdg_surface_add_listener(window->wl.xdg.surface,
-                             &xdgSurfaceListener,
-                             window);
-
-    window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface);
-    if (!window->wl.xdg.toplevel)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: xdg-toplevel creation failed");
-        return GLFW_FALSE;
-    }
-
-    xdg_toplevel_add_listener(window->wl.xdg.toplevel,
-                              &xdgToplevelListener,
-                              window);
-
-    if (window->wl.title)
-        xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
-
-    if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE)
-        xdg_toplevel_set_min_size(window->wl.xdg.toplevel,
-                                  window->minwidth, window->minheight);
-    if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE)
-        xdg_toplevel_set_max_size(window->wl.xdg.toplevel,
-                                  window->maxwidth, window->maxheight);
-
-    if (window->monitor)
-    {
-        xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
-                                    window->monitor->wl.output);
-        setIdleInhibitor(window, GLFW_TRUE);
-    }
-    else if (window->wl.maximized)
-    {
-        xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
-        setIdleInhibitor(window, GLFW_FALSE);
-        setXdgDecorations(window);
-    }
-    else
-    {
-        setIdleInhibitor(window, GLFW_FALSE);
-        setXdgDecorations(window);
-    }
-
-    wl_surface_commit(window->wl.surface);
-    wl_display_roundtrip(_glfw.wl.display);
-
-    return GLFW_TRUE;
-}
-
-static void setCursorImage(_GLFWwindow* window,
-                           _GLFWcursorWayland* cursorWayland)
-{
-    struct itimerspec timer = {};
-    struct wl_cursor* wlCursor = cursorWayland->cursor;
-    struct wl_cursor_image* image;
-    struct wl_buffer* buffer;
-    struct wl_surface* surface = _glfw.wl.cursorSurface;
-    int scale = 1;
-
-    if (!wlCursor)
-        buffer = cursorWayland->buffer;
-    else
-    {
-        if (window->wl.scale > 1 && cursorWayland->cursorHiDPI)
-        {
-            wlCursor = cursorWayland->cursorHiDPI;
-            scale = 2;
-        }
-
-        image = wlCursor->images[cursorWayland->currentImage];
-        buffer = wl_cursor_image_get_buffer(image);
-        if (!buffer)
-            return;
-
-        timer.it_value.tv_sec = image->delay / 1000;
-        timer.it_value.tv_nsec = (image->delay % 1000) * 1000000;
-        timerfd_settime(_glfw.wl.cursorTimerfd, 0, &timer, NULL);
-
-        cursorWayland->width = image->width;
-        cursorWayland->height = image->height;
-        cursorWayland->xhot = image->hotspot_x;
-        cursorWayland->yhot = image->hotspot_y;
-    }
-
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          surface,
-                          cursorWayland->xhot / scale,
-                          cursorWayland->yhot / scale);
-    wl_surface_set_buffer_scale(surface, scale);
-    wl_surface_attach(surface, buffer, 0, 0);
-    wl_surface_damage(surface, 0, 0,
-                      cursorWayland->width, cursorWayland->height);
-    wl_surface_commit(surface);
-}
-
-static void incrementCursorImage(_GLFWwindow* window)
-{
-    _GLFWcursor* cursor;
-
-    if (!window || window->wl.decorations.focus != mainWindow)
-        return;
-
-    cursor = window->wl.currentCursor;
-    if (cursor && cursor->wl.cursor)
-    {
-        cursor->wl.currentImage += 1;
-        cursor->wl.currentImage %= cursor->wl.cursor->image_count;
-        setCursorImage(window, &cursor->wl);
-    }
-}
-
-static void handleEvents(int timeout)
-{
-    struct wl_display* display = _glfw.wl.display;
-    struct pollfd fds[] = {
-        { wl_display_get_fd(display), POLLIN },
-        { _glfw.wl.timerfd, POLLIN },
-        { _glfw.wl.cursorTimerfd, POLLIN },
-    };
-    ssize_t read_ret;
-    uint64_t repeats, i;
-
-    while (wl_display_prepare_read(display) != 0)
-        wl_display_dispatch_pending(display);
-
-    // If an error different from EAGAIN happens, we have likely been
-    // disconnected from the Wayland session, try to handle that the best we
-    // can.
-    if (wl_display_flush(display) < 0 && errno != EAGAIN)
-    {
-        _GLFWwindow* window = _glfw.windowListHead;
-        while (window)
-        {
-            _glfwInputWindowCloseRequest(window);
-            window = window->next;
-        }
-        wl_display_cancel_read(display);
-        return;
-    }
-
-    if (poll(fds, 3, timeout) > 0)
-    {
-        if (fds[0].revents & POLLIN)
-        {
-            wl_display_read_events(display);
-            wl_display_dispatch_pending(display);
-        }
-        else
-        {
-            wl_display_cancel_read(display);
-        }
-
-        if (fds[1].revents & POLLIN)
-        {
-            read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats));
-            if (read_ret != 8)
-                return;
-
-            if (_glfw.wl.keyboardFocus)
-            {
-                for (i = 0; i < repeats; ++i)
-                {
-                    _glfwInputKey(_glfw.wl.keyboardFocus,
-                                  _glfw.wl.keyboardLastKey,
-                                  _glfw.wl.keyboardLastScancode,
-                                  GLFW_REPEAT,
-                                  _glfw.wl.xkb.modifiers);
-                }
-            }
-        }
-
-        if (fds[2].revents & POLLIN)
-        {
-            read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats));
-            if (read_ret != 8)
-                return;
-
-            incrementCursorImage(_glfw.wl.pointerFocus);
-        }
-    }
-    else
-    {
-        wl_display_cancel_read(display);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    window->wl.transparent = fbconfig->transparent;
-
-    if (!createSurface(window, wndconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
-            ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (wndconfig->title)
-        window->wl.title = _glfw_strdup(wndconfig->title);
-
-    if (wndconfig->visible)
-    {
-        if (!createXdgSurface(window))
-            return GLFW_FALSE;
-
-        window->wl.visible = GLFW_TRUE;
-    }
-    else
-    {
-        window->wl.xdg.surface = NULL;
-        window->wl.xdg.toplevel = NULL;
-        window->wl.visible = GLFW_FALSE;
-    }
-
-    window->wl.currentCursor = NULL;
-
-    window->wl.monitors = calloc(1, sizeof(_GLFWmonitor*));
-    window->wl.monitorsCount = 0;
-    window->wl.monitorsSize = 1;
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window == _glfw.wl.pointerFocus)
-    {
-        _glfw.wl.pointerFocus = NULL;
-        _glfwInputCursorEnter(window, GLFW_FALSE);
-    }
-    if (window == _glfw.wl.keyboardFocus)
-    {
-        _glfw.wl.keyboardFocus = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    if (window->wl.idleInhibitor)
-        zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    destroyDecorations(window);
-    if (window->wl.xdg.decoration)
-        zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
-
-    if (window->wl.decorations.buffer)
-        wl_buffer_destroy(window->wl.decorations.buffer);
-
-    if (window->wl.native)
-        wl_egl_window_destroy(window->wl.native);
-
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_destroy(window->wl.xdg.toplevel);
-
-    if (window->wl.xdg.surface)
-        xdg_surface_destroy(window->wl.xdg.surface);
-
-    if (window->wl.surface)
-        wl_surface_destroy(window->wl.surface);
-
-    free(window->wl.title);
-    free(window->wl.monitors);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    if (window->wl.title)
-        free(window->wl.title);
-    window->wl.title = _glfw_strdup(title);
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window icon");
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    // A Wayland client is not aware of its position, so just warn and leave it
-    // as (0, 0)
-
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not provide the window position");
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    // A Wayland client can not set its position, so just warn
-
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window position");
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->wl.width;
-    if (height)
-        *height = window->wl.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    window->wl.width = width;
-    window->wl.height = height;
-    resizeWindow(window);
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
-            minwidth = minheight = 0;
-        if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
-            maxwidth = maxheight = 0;
-        xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight);
-        xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight);
-        wl_surface_commit(window->wl.surface);
-    }
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
-                                       int numer, int denom)
-{
-    // TODO: find out how to trigger a resize.
-    // The actual limits are checked in the xdg_toplevel::configure handler.
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window aspect ratio not yet implemented");
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
-                                     int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-    if (width)
-        *width *= window->wl.scale;
-    if (height)
-        *height *= window->wl.scale;
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    if (window->decorated && !window->monitor && !window->wl.decorations.serverSide)
-    {
-        if (top)
-            *top = _GLFW_DECORATION_TOP;
-        if (left)
-            *left = _GLFW_DECORATION_WIDTH;
-        if (right)
-            *right = _GLFW_DECORATION_WIDTH;
-        if (bottom)
-            *bottom = _GLFW_DECORATION_WIDTH;
-    }
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = (float) window->wl.scale;
-    if (yscale)
-        *yscale = (float) window->wl.scale;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        if (window->monitor)
-            xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
-        if (window->wl.maximized)
-            xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
-        // There is no way to unset minimized, or even to know if we are
-        // minimized, so there is nothing to do in this case.
-    }
-    _glfwInputWindowMonitor(window, NULL);
-    window->wl.maximized = GLFW_FALSE;
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
-    }
-    window->wl.maximized = GLFW_TRUE;
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    if (!window->wl.visible)
-    {
-        createXdgSurface(window);
-        window->wl.visible = GLFW_TRUE;
-    }
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_destroy(window->wl.xdg.toplevel);
-        xdg_surface_destroy(window->wl.xdg.surface);
-        window->wl.xdg.toplevel = NULL;
-        window->wl.xdg.surface = NULL;
-    }
-    window->wl.visible = GLFW_FALSE;
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attention request not implemented yet");
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the input focus");
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (monitor)
-    {
-        setFullscreen(window, monitor, refreshRate);
-    }
-    else
-    {
-        if (window->wl.xdg.toplevel)
-            xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
-        setIdleInhibitor(window, GLFW_FALSE);
-        if (!_glfw.wl.decorationManager)
-            createDecorations(window);
-    }
-    _glfwInputWindowMonitor(window, monitor);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return _glfw.wl.keyboardFocus == window;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    // xdg-shell doesn’t give any way to request whether a surface is
-    // iconified.
-    return GLFW_FALSE;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return window->wl.visible;
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return window->wl.maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return window->wl.hovered;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    return window->wl.transparent;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attribute setting not implemented yet");
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!window->monitor)
-    {
-        if (enabled)
-            createDecorations(window);
-        else
-            destroyDecorations(window);
-    }
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attribute setting not implemented yet");
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (enabled)
-    {
-        struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
-        wl_surface_set_input_region(window->wl.surface, region);
-        wl_region_destroy(region);
-    }
-    else
-        wl_surface_set_input_region(window->wl.surface, 0);
-    wl_surface_commit(window->wl.surface);
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    return 1.f;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window opacity");
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    // This is handled in relativePointerHandleRelativeMotion
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    handleEvents(0);
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    handleEvents(-1);
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    handleEvents((int) (timeout * 1e3));
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    wl_display_sync(_glfw.wl.display);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    if (xpos)
-        *xpos = window->wl.cursorPosX;
-    if (ypos)
-        *ypos = window->wl.cursorPosY;
-}
-
-static GLFWbool isPointerLocked(_GLFWwindow* window);
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    if (isPointerLocked(window))
-    {
-        zwp_locked_pointer_v1_set_cursor_position_hint(
-            window->wl.pointerLock.lockedPointer,
-            wl_fixed_from_double(x), wl_fixed_from_double(y));
-        wl_surface_commit(window->wl.surface);
-    }
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    _glfwPlatformSetCursor(window, window->wl.currentCursor);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Key names not yet implemented");
-    return NULL;
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.wl.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->wl.buffer = createShmBuffer(image);
-    if (!cursor->wl.buffer)
-        return GLFW_FALSE;
-
-    cursor->wl.width = image->width;
-    cursor->wl.height = image->height;
-    cursor->wl.xhot = xhot;
-    cursor->wl.yhot = yhot;
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    const char* name = NULL;
-
-    // Try the XDG names first
-    if (shape == GLFW_ARROW_CURSOR)
-        name = "default";
-    else if (shape == GLFW_IBEAM_CURSOR)
-        name = "text";
-    else if (shape == GLFW_CROSSHAIR_CURSOR)
-        name = "crosshair";
-    else if (shape == GLFW_POINTING_HAND_CURSOR)
-        name = "pointer";
-    else if (shape == GLFW_RESIZE_EW_CURSOR)
-        name = "ew-resize";
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        name = "ns-resize";
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        name = "nwse-resize";
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        name = "nesw-resize";
-    else if (shape == GLFW_RESIZE_ALL_CURSOR)
-        name = "all-scroll";
-    else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-        name = "not-allowed";
-
-    cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
-
-    if (_glfw.wl.cursorThemeHiDPI)
-    {
-        cursor->wl.cursorHiDPI =
-            wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
-    }
-
-    if (!cursor->wl.cursor)
-    {
-        // Fall back to the core X11 names
-        if (shape == GLFW_ARROW_CURSOR)
-            name = "left_ptr";
-        else if (shape == GLFW_IBEAM_CURSOR)
-            name = "xterm";
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            name = "crosshair";
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            name = "hand2";
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            name = "sb_h_double_arrow";
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            name = "sb_v_double_arrow";
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            name = "fleur";
-        else
-        {
-            _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                            "Wayland: Standard cursor shape unavailable");
-            return GLFW_FALSE;
-        }
-
-        cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
-        if (!cursor->wl.cursor)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Failed to create standard cursor \"%s\"",
-                            name);
-            return GLFW_FALSE;
-        }
-
-        if (_glfw.wl.cursorThemeHiDPI)
-        {
-            if (!cursor->wl.cursorHiDPI)
-            {
-                cursor->wl.cursorHiDPI =
-                    wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
-            }
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    // If it's a standard cursor we don't need to do anything here
-    if (cursor->wl.cursor)
-        return;
-
-    if (cursor->wl.buffer)
-        wl_buffer_destroy(cursor->wl.buffer);
-}
-
-static void relativePointerHandleRelativeMotion(void* data,
-                                                struct zwp_relative_pointer_v1* pointer,
-                                                uint32_t timeHi,
-                                                uint32_t timeLo,
-                                                wl_fixed_t dx,
-                                                wl_fixed_t dy,
-                                                wl_fixed_t dxUnaccel,
-                                                wl_fixed_t dyUnaccel)
-{
-    _GLFWwindow* window = data;
-    double xpos = window->virtualCursorPosX;
-    double ypos = window->virtualCursorPosY;
-
-    if (window->cursorMode != GLFW_CURSOR_DISABLED)
-        return;
-
-    if (window->rawMouseMotion)
-    {
-        xpos += wl_fixed_to_double(dxUnaccel);
-        ypos += wl_fixed_to_double(dyUnaccel);
-    }
-    else
-    {
-        xpos += wl_fixed_to_double(dx);
-        ypos += wl_fixed_to_double(dy);
-    }
-
-    _glfwInputCursorPos(window, xpos, ypos);
-}
-
-static const struct zwp_relative_pointer_v1_listener relativePointerListener = {
-    relativePointerHandleRelativeMotion
-};
-
-static void lockedPointerHandleLocked(void* data,
-                                      struct zwp_locked_pointer_v1* lockedPointer)
-{
-}
-
-static void unlockPointer(_GLFWwindow* window)
-{
-    struct zwp_relative_pointer_v1* relativePointer =
-        window->wl.pointerLock.relativePointer;
-    struct zwp_locked_pointer_v1* lockedPointer =
-        window->wl.pointerLock.lockedPointer;
-
-    zwp_relative_pointer_v1_destroy(relativePointer);
-    zwp_locked_pointer_v1_destroy(lockedPointer);
-
-    window->wl.pointerLock.relativePointer = NULL;
-    window->wl.pointerLock.lockedPointer = NULL;
-}
-
-static void lockPointer(_GLFWwindow* window);
-
-static void lockedPointerHandleUnlocked(void* data,
-                                        struct zwp_locked_pointer_v1* lockedPointer)
-{
-}
-
-static const struct zwp_locked_pointer_v1_listener lockedPointerListener = {
-    lockedPointerHandleLocked,
-    lockedPointerHandleUnlocked
-};
-
-static void lockPointer(_GLFWwindow* window)
-{
-    struct zwp_relative_pointer_v1* relativePointer;
-    struct zwp_locked_pointer_v1* lockedPointer;
-
-    if (!_glfw.wl.relativePointerManager)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: no relative pointer manager");
-        return;
-    }
-
-    relativePointer =
-        zwp_relative_pointer_manager_v1_get_relative_pointer(
-            _glfw.wl.relativePointerManager,
-            _glfw.wl.pointer);
-    zwp_relative_pointer_v1_add_listener(relativePointer,
-                                         &relativePointerListener,
-                                         window);
-
-    lockedPointer =
-        zwp_pointer_constraints_v1_lock_pointer(
-            _glfw.wl.pointerConstraints,
-            window->wl.surface,
-            _glfw.wl.pointer,
-            NULL,
-            ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
-    zwp_locked_pointer_v1_add_listener(lockedPointer,
-                                       &lockedPointerListener,
-                                       window);
-
-    window->wl.pointerLock.relativePointer = relativePointer;
-    window->wl.pointerLock.lockedPointer = lockedPointer;
-
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          NULL, 0, 0);
-}
-
-static GLFWbool isPointerLocked(_GLFWwindow* window)
-{
-    return window->wl.pointerLock.lockedPointer != NULL;
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    struct wl_cursor* defaultCursor;
-    struct wl_cursor* defaultCursorHiDPI = NULL;
-
-    if (!_glfw.wl.pointer)
-        return;
-
-    window->wl.currentCursor = cursor;
-
-    // If we're not in the correct window just save the cursor
-    // the next time the pointer enters the window the cursor will change
-    if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow)
-        return;
-
-    // Unlock possible pointer lock if no longer disabled.
-    if (window->cursorMode != GLFW_CURSOR_DISABLED && isPointerLocked(window))
-        unlockPointer(window);
-
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (cursor)
-            setCursorImage(window, &cursor->wl);
-        else
-        {
-            defaultCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme,
-                                                       "left_ptr");
-            if (!defaultCursor)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Wayland: Standard cursor not found");
-                return;
-            }
-            if (_glfw.wl.cursorThemeHiDPI)
-                defaultCursorHiDPI =
-                    wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI,
-                                               "left_ptr");
-            _GLFWcursorWayland cursorWayland = {
-                defaultCursor,
-                defaultCursorHiDPI,
-                NULL,
-                0, 0,
-                0, 0,
-                0
-            };
-            setCursorImage(window, &cursorWayland);
-        }
-    }
-    else if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        if (!isPointerLocked(window))
-            lockPointer(window);
-    }
-    else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-    {
-        wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0);
-    }
-}
-
-static void dataSourceHandleTarget(void* data,
-                                   struct wl_data_source* dataSource,
-                                   const char* mimeType)
-{
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-}
-
-static void dataSourceHandleSend(void* data,
-                                 struct wl_data_source* dataSource,
-                                 const char* mimeType,
-                                 int fd)
-{
-    const char* string = _glfw.wl.clipboardSendString;
-    size_t len = _glfw.wl.clipboardSendSize;
-    int ret;
-
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-
-    if (!string)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Copy requested from an invalid string");
-        return;
-    }
-
-    if (strcmp(mimeType, "text/plain;charset=utf-8") != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Wrong MIME type asked from clipboard");
-        close(fd);
-        return;
-    }
-
-    while (len > 0)
-    {
-        ret = write(fd, string, len);
-        if (ret == -1 && errno == EINTR)
-            continue;
-        if (ret == -1)
-        {
-            // TODO: also report errno maybe.
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Error while writing the clipboard");
-            close(fd);
-            return;
-        }
-        len -= ret;
-    }
-    close(fd);
-}
-
-static void dataSourceHandleCancelled(void* data,
-                                      struct wl_data_source* dataSource)
-{
-    wl_data_source_destroy(dataSource);
-
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-
-    _glfw.wl.dataSource = NULL;
-}
-
-static const struct wl_data_source_listener dataSourceListener = {
-    dataSourceHandleTarget,
-    dataSourceHandleSend,
-    dataSourceHandleCancelled,
-};
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    if (_glfw.wl.dataSource)
-    {
-        wl_data_source_destroy(_glfw.wl.dataSource);
-        _glfw.wl.dataSource = NULL;
-    }
-
-    if (_glfw.wl.clipboardSendString)
-    {
-        free(_glfw.wl.clipboardSendString);
-        _glfw.wl.clipboardSendString = NULL;
-    }
-
-    _glfw.wl.clipboardSendString = strdup(string);
-    if (!_glfw.wl.clipboardSendString)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to allocate clipboard string");
-        return;
-    }
-    _glfw.wl.clipboardSendSize = strlen(string);
-    _glfw.wl.dataSource =
-        wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
-    if (!_glfw.wl.dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to create clipboard source");
-        free(_glfw.wl.clipboardSendString);
-        return;
-    }
-    wl_data_source_add_listener(_glfw.wl.dataSource,
-                                &dataSourceListener,
-                                NULL);
-    wl_data_source_offer(_glfw.wl.dataSource, "text/plain;charset=utf-8");
-    wl_data_device_set_selection(_glfw.wl.dataDevice,
-                                 _glfw.wl.dataSource,
-                                 _glfw.wl.serial);
-}
-
-static GLFWbool growClipboardString(void)
-{
-    char* clipboard = _glfw.wl.clipboardString;
-
-    clipboard = realloc(clipboard, _glfw.wl.clipboardSize * 2);
-    if (!clipboard)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to grow clipboard string");
-        return GLFW_FALSE;
-    }
-    _glfw.wl.clipboardString = clipboard;
-    _glfw.wl.clipboardSize = _glfw.wl.clipboardSize * 2;
-    return GLFW_TRUE;
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    int fds[2];
-    int ret;
-    size_t len = 0;
-
-    if (!_glfw.wl.dataOffer)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "No clipboard data has been sent yet");
-        return NULL;
-    }
-
-    ret = pipe2(fds, O_CLOEXEC);
-    if (ret < 0)
-    {
-        // TODO: also report errno maybe?
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to create clipboard pipe fds");
-        return NULL;
-    }
-
-    wl_data_offer_receive(_glfw.wl.dataOffer, "text/plain;charset=utf-8", fds[1]);
-    close(fds[1]);
-
-    // XXX: this is a huge hack, this function shouldn’t be synchronous!
-    handleEvents(-1);
-
-    while (1)
-    {
-        // Grow the clipboard if we need to paste something bigger, there is no
-        // shrink operation yet.
-        if (len + 4096 > _glfw.wl.clipboardSize)
-        {
-            if (!growClipboardString())
-            {
-                close(fds[0]);
-                return NULL;
-            }
-        }
-
-        // Then read from the fd to the clipboard, handling all known errors.
-        ret = read(fds[0], _glfw.wl.clipboardString + len, 4096);
-        if (ret == 0)
-            break;
-        if (ret == -1 && errno == EINTR)
-            continue;
-        if (ret == -1)
-        {
-            // TODO: also report errno maybe.
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Impossible to read from clipboard fd");
-            close(fds[0]);
-            return NULL;
-        }
-        len += ret;
-    }
-    close(fds[0]);
-    if (len + 1 > _glfw.wl.clipboardSize)
-    {
-        if (!growClipboardString())
-            return NULL;
-    }
-    _glfw.wl.clipboardString[len] = '\0';
-    return _glfw.wl.clipboardString;
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland)
-        return EGL_PLATFORM_WAYLAND_EXT;
-    else
-        return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return _glfw.wl.display;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->wl.native;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
-        return;
-
-    extensions[0] = "VK_KHR_surface";
-    extensions[1] = "VK_KHR_wayland_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
-        vkGetPhysicalDeviceWaylandPresentationSupportKHR =
-        (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
-        vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
-    if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
-        return VK_NULL_HANDLE;
-    }
-
-    return vkGetPhysicalDeviceWaylandPresentationSupportKHR(device,
-                                                            queuefamily,
-                                                            _glfw.wl.display);
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    VkResult err;
-    VkWaylandSurfaceCreateInfoKHR sci;
-    PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
-
-    vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)
-        vkGetInstanceProcAddr(instance, "vkCreateWaylandSurfaceKHR");
-    if (!vkCreateWaylandSurfaceKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    memset(&sci, 0, sizeof(sci));
-    sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
-    sci.display = _glfw.wl.display;
-    sci.surface = window->wl.surface;
-
-    err = vkCreateWaylandSurfaceKHR(instance, &sci, allocator, surface);
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfw.wl.display;
-}
-
-GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->wl.surface;
-}
-
diff --git a/raylib/external/glfw/src/x11_init.c b/raylib/external/glfw/src/x11_init.c
deleted file mode 100644 (file)
index dd24f11..0000000
+++ /dev/null
@@ -1,1496 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-#include <locale.h>
-#include <unistd.h>
-
-
-// Translate the X11 KeySyms for a key to a GLFW key code
-// NOTE: This is only used as a fallback, in case the XKB method fails
-//       It is layout-dependent and will fail partially on most non-US layouts
-//
-static int translateKeySyms(const KeySym* keysyms, int width)
-{
-    if (width > 1)
-    {
-        switch (keysyms[1])
-        {
-            case XK_KP_0:           return GLFW_KEY_KP_0;
-            case XK_KP_1:           return GLFW_KEY_KP_1;
-            case XK_KP_2:           return GLFW_KEY_KP_2;
-            case XK_KP_3:           return GLFW_KEY_KP_3;
-            case XK_KP_4:           return GLFW_KEY_KP_4;
-            case XK_KP_5:           return GLFW_KEY_KP_5;
-            case XK_KP_6:           return GLFW_KEY_KP_6;
-            case XK_KP_7:           return GLFW_KEY_KP_7;
-            case XK_KP_8:           return GLFW_KEY_KP_8;
-            case XK_KP_9:           return GLFW_KEY_KP_9;
-            case XK_KP_Separator:
-            case XK_KP_Decimal:     return GLFW_KEY_KP_DECIMAL;
-            case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;
-            case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;
-            default:                break;
-        }
-    }
-
-    switch (keysyms[0])
-    {
-        case XK_Escape:         return GLFW_KEY_ESCAPE;
-        case XK_Tab:            return GLFW_KEY_TAB;
-        case XK_Shift_L:        return GLFW_KEY_LEFT_SHIFT;
-        case XK_Shift_R:        return GLFW_KEY_RIGHT_SHIFT;
-        case XK_Control_L:      return GLFW_KEY_LEFT_CONTROL;
-        case XK_Control_R:      return GLFW_KEY_RIGHT_CONTROL;
-        case XK_Meta_L:
-        case XK_Alt_L:          return GLFW_KEY_LEFT_ALT;
-        case XK_Mode_switch: // Mapped to Alt_R on many keyboards
-        case XK_ISO_Level3_Shift: // AltGr on at least some machines
-        case XK_Meta_R:
-        case XK_Alt_R:          return GLFW_KEY_RIGHT_ALT;
-        case XK_Super_L:        return GLFW_KEY_LEFT_SUPER;
-        case XK_Super_R:        return GLFW_KEY_RIGHT_SUPER;
-        case XK_Menu:           return GLFW_KEY_MENU;
-        case XK_Num_Lock:       return GLFW_KEY_NUM_LOCK;
-        case XK_Caps_Lock:      return GLFW_KEY_CAPS_LOCK;
-        case XK_Print:          return GLFW_KEY_PRINT_SCREEN;
-        case XK_Scroll_Lock:    return GLFW_KEY_SCROLL_LOCK;
-        case XK_Pause:          return GLFW_KEY_PAUSE;
-        case XK_Delete:         return GLFW_KEY_DELETE;
-        case XK_BackSpace:      return GLFW_KEY_BACKSPACE;
-        case XK_Return:         return GLFW_KEY_ENTER;
-        case XK_Home:           return GLFW_KEY_HOME;
-        case XK_End:            return GLFW_KEY_END;
-        case XK_Page_Up:        return GLFW_KEY_PAGE_UP;
-        case XK_Page_Down:      return GLFW_KEY_PAGE_DOWN;
-        case XK_Insert:         return GLFW_KEY_INSERT;
-        case XK_Left:           return GLFW_KEY_LEFT;
-        case XK_Right:          return GLFW_KEY_RIGHT;
-        case XK_Down:           return GLFW_KEY_DOWN;
-        case XK_Up:             return GLFW_KEY_UP;
-        case XK_F1:             return GLFW_KEY_F1;
-        case XK_F2:             return GLFW_KEY_F2;
-        case XK_F3:             return GLFW_KEY_F3;
-        case XK_F4:             return GLFW_KEY_F4;
-        case XK_F5:             return GLFW_KEY_F5;
-        case XK_F6:             return GLFW_KEY_F6;
-        case XK_F7:             return GLFW_KEY_F7;
-        case XK_F8:             return GLFW_KEY_F8;
-        case XK_F9:             return GLFW_KEY_F9;
-        case XK_F10:            return GLFW_KEY_F10;
-        case XK_F11:            return GLFW_KEY_F11;
-        case XK_F12:            return GLFW_KEY_F12;
-        case XK_F13:            return GLFW_KEY_F13;
-        case XK_F14:            return GLFW_KEY_F14;
-        case XK_F15:            return GLFW_KEY_F15;
-        case XK_F16:            return GLFW_KEY_F16;
-        case XK_F17:            return GLFW_KEY_F17;
-        case XK_F18:            return GLFW_KEY_F18;
-        case XK_F19:            return GLFW_KEY_F19;
-        case XK_F20:            return GLFW_KEY_F20;
-        case XK_F21:            return GLFW_KEY_F21;
-        case XK_F22:            return GLFW_KEY_F22;
-        case XK_F23:            return GLFW_KEY_F23;
-        case XK_F24:            return GLFW_KEY_F24;
-        case XK_F25:            return GLFW_KEY_F25;
-
-        // Numeric keypad
-        case XK_KP_Divide:      return GLFW_KEY_KP_DIVIDE;
-        case XK_KP_Multiply:    return GLFW_KEY_KP_MULTIPLY;
-        case XK_KP_Subtract:    return GLFW_KEY_KP_SUBTRACT;
-        case XK_KP_Add:         return GLFW_KEY_KP_ADD;
-
-        // These should have been detected in secondary keysym test above!
-        case XK_KP_Insert:      return GLFW_KEY_KP_0;
-        case XK_KP_End:         return GLFW_KEY_KP_1;
-        case XK_KP_Down:        return GLFW_KEY_KP_2;
-        case XK_KP_Page_Down:   return GLFW_KEY_KP_3;
-        case XK_KP_Left:        return GLFW_KEY_KP_4;
-        case XK_KP_Right:       return GLFW_KEY_KP_6;
-        case XK_KP_Home:        return GLFW_KEY_KP_7;
-        case XK_KP_Up:          return GLFW_KEY_KP_8;
-        case XK_KP_Page_Up:     return GLFW_KEY_KP_9;
-        case XK_KP_Delete:      return GLFW_KEY_KP_DECIMAL;
-        case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;
-        case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;
-
-        // Last resort: Check for printable keys (should not happen if the XKB
-        // extension is available). This will give a layout dependent mapping
-        // (which is wrong, and we may miss some keys, especially on non-US
-        // keyboards), but it's better than nothing...
-        case XK_a:              return GLFW_KEY_A;
-        case XK_b:              return GLFW_KEY_B;
-        case XK_c:              return GLFW_KEY_C;
-        case XK_d:              return GLFW_KEY_D;
-        case XK_e:              return GLFW_KEY_E;
-        case XK_f:              return GLFW_KEY_F;
-        case XK_g:              return GLFW_KEY_G;
-        case XK_h:              return GLFW_KEY_H;
-        case XK_i:              return GLFW_KEY_I;
-        case XK_j:              return GLFW_KEY_J;
-        case XK_k:              return GLFW_KEY_K;
-        case XK_l:              return GLFW_KEY_L;
-        case XK_m:              return GLFW_KEY_M;
-        case XK_n:              return GLFW_KEY_N;
-        case XK_o:              return GLFW_KEY_O;
-        case XK_p:              return GLFW_KEY_P;
-        case XK_q:              return GLFW_KEY_Q;
-        case XK_r:              return GLFW_KEY_R;
-        case XK_s:              return GLFW_KEY_S;
-        case XK_t:              return GLFW_KEY_T;
-        case XK_u:              return GLFW_KEY_U;
-        case XK_v:              return GLFW_KEY_V;
-        case XK_w:              return GLFW_KEY_W;
-        case XK_x:              return GLFW_KEY_X;
-        case XK_y:              return GLFW_KEY_Y;
-        case XK_z:              return GLFW_KEY_Z;
-        case XK_1:              return GLFW_KEY_1;
-        case XK_2:              return GLFW_KEY_2;
-        case XK_3:              return GLFW_KEY_3;
-        case XK_4:              return GLFW_KEY_4;
-        case XK_5:              return GLFW_KEY_5;
-        case XK_6:              return GLFW_KEY_6;
-        case XK_7:              return GLFW_KEY_7;
-        case XK_8:              return GLFW_KEY_8;
-        case XK_9:              return GLFW_KEY_9;
-        case XK_0:              return GLFW_KEY_0;
-        case XK_space:          return GLFW_KEY_SPACE;
-        case XK_minus:          return GLFW_KEY_MINUS;
-        case XK_equal:          return GLFW_KEY_EQUAL;
-        case XK_bracketleft:    return GLFW_KEY_LEFT_BRACKET;
-        case XK_bracketright:   return GLFW_KEY_RIGHT_BRACKET;
-        case XK_backslash:      return GLFW_KEY_BACKSLASH;
-        case XK_semicolon:      return GLFW_KEY_SEMICOLON;
-        case XK_apostrophe:     return GLFW_KEY_APOSTROPHE;
-        case XK_grave:          return GLFW_KEY_GRAVE_ACCENT;
-        case XK_comma:          return GLFW_KEY_COMMA;
-        case XK_period:         return GLFW_KEY_PERIOD;
-        case XK_slash:          return GLFW_KEY_SLASH;
-        case XK_less:           return GLFW_KEY_WORLD_1; // At least in some layouts...
-        default:                break;
-    }
-
-    // No matching translation was found
-    return GLFW_KEY_UNKNOWN;
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode, scancodeMin, scancodeMax;
-
-    memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
-    memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
-
-    if (_glfw.x11.xkb.available)
-    {
-        // Use XKB to determine physical key locations independently of the
-        // current keyboard layout
-
-        XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
-        XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc);
-
-        scancodeMin = desc->min_key_code;
-        scancodeMax = desc->max_key_code;
-
-        const struct
-        {
-            int key;
-            char* name;
-        } keymap[] =
-        {
-            { GLFW_KEY_GRAVE_ACCENT, "TLDE" },
-            { GLFW_KEY_1, "AE01" },
-            { GLFW_KEY_2, "AE02" },
-            { GLFW_KEY_3, "AE03" },
-            { GLFW_KEY_4, "AE04" },
-            { GLFW_KEY_5, "AE05" },
-            { GLFW_KEY_6, "AE06" },
-            { GLFW_KEY_7, "AE07" },
-            { GLFW_KEY_8, "AE08" },
-            { GLFW_KEY_9, "AE09" },
-            { GLFW_KEY_0, "AE10" },
-            { GLFW_KEY_MINUS, "AE11" },
-            { GLFW_KEY_EQUAL, "AE12" },
-            { GLFW_KEY_Q, "AD01" },
-            { GLFW_KEY_W, "AD02" },
-            { GLFW_KEY_E, "AD03" },
-            { GLFW_KEY_R, "AD04" },
-            { GLFW_KEY_T, "AD05" },
-            { GLFW_KEY_Y, "AD06" },
-            { GLFW_KEY_U, "AD07" },
-            { GLFW_KEY_I, "AD08" },
-            { GLFW_KEY_O, "AD09" },
-            { GLFW_KEY_P, "AD10" },
-            { GLFW_KEY_LEFT_BRACKET, "AD11" },
-            { GLFW_KEY_RIGHT_BRACKET, "AD12" },
-            { GLFW_KEY_A, "AC01" },
-            { GLFW_KEY_S, "AC02" },
-            { GLFW_KEY_D, "AC03" },
-            { GLFW_KEY_F, "AC04" },
-            { GLFW_KEY_G, "AC05" },
-            { GLFW_KEY_H, "AC06" },
-            { GLFW_KEY_J, "AC07" },
-            { GLFW_KEY_K, "AC08" },
-            { GLFW_KEY_L, "AC09" },
-            { GLFW_KEY_SEMICOLON, "AC10" },
-            { GLFW_KEY_APOSTROPHE, "AC11" },
-            { GLFW_KEY_Z, "AB01" },
-            { GLFW_KEY_X, "AB02" },
-            { GLFW_KEY_C, "AB03" },
-            { GLFW_KEY_V, "AB04" },
-            { GLFW_KEY_B, "AB05" },
-            { GLFW_KEY_N, "AB06" },
-            { GLFW_KEY_M, "AB07" },
-            { GLFW_KEY_COMMA, "AB08" },
-            { GLFW_KEY_PERIOD, "AB09" },
-            { GLFW_KEY_SLASH, "AB10" },
-            { GLFW_KEY_BACKSLASH, "BKSL" },
-            { GLFW_KEY_WORLD_1, "LSGT" },
-            { GLFW_KEY_SPACE, "SPCE" },
-            { GLFW_KEY_ESCAPE, "ESC" },
-            { GLFW_KEY_ENTER, "RTRN" },
-            { GLFW_KEY_TAB, "TAB" },
-            { GLFW_KEY_BACKSPACE, "BKSP" },
-            { GLFW_KEY_INSERT, "INS" },
-            { GLFW_KEY_DELETE, "DELE" },
-            { GLFW_KEY_RIGHT, "RGHT" },
-            { GLFW_KEY_LEFT, "LEFT" },
-            { GLFW_KEY_DOWN, "DOWN" },
-            { GLFW_KEY_UP, "UP" },
-            { GLFW_KEY_PAGE_UP, "PGUP" },
-            { GLFW_KEY_PAGE_DOWN, "PGDN" },
-            { GLFW_KEY_HOME, "HOME" },
-            { GLFW_KEY_END, "END" },
-            { GLFW_KEY_CAPS_LOCK, "CAPS" },
-            { GLFW_KEY_SCROLL_LOCK, "SCLK" },
-            { GLFW_KEY_NUM_LOCK, "NMLK" },
-            { GLFW_KEY_PRINT_SCREEN, "PRSC" },
-            { GLFW_KEY_PAUSE, "PAUS" },
-            { GLFW_KEY_F1, "FK01" },
-            { GLFW_KEY_F2, "FK02" },
-            { GLFW_KEY_F3, "FK03" },
-            { GLFW_KEY_F4, "FK04" },
-            { GLFW_KEY_F5, "FK05" },
-            { GLFW_KEY_F6, "FK06" },
-            { GLFW_KEY_F7, "FK07" },
-            { GLFW_KEY_F8, "FK08" },
-            { GLFW_KEY_F9, "FK09" },
-            { GLFW_KEY_F10, "FK10" },
-            { GLFW_KEY_F11, "FK11" },
-            { GLFW_KEY_F12, "FK12" },
-            { GLFW_KEY_F13, "FK13" },
-            { GLFW_KEY_F14, "FK14" },
-            { GLFW_KEY_F15, "FK15" },
-            { GLFW_KEY_F16, "FK16" },
-            { GLFW_KEY_F17, "FK17" },
-            { GLFW_KEY_F18, "FK18" },
-            { GLFW_KEY_F19, "FK19" },
-            { GLFW_KEY_F20, "FK20" },
-            { GLFW_KEY_F21, "FK21" },
-            { GLFW_KEY_F22, "FK22" },
-            { GLFW_KEY_F23, "FK23" },
-            { GLFW_KEY_F24, "FK24" },
-            { GLFW_KEY_F25, "FK25" },
-            { GLFW_KEY_KP_0, "KP0" },
-            { GLFW_KEY_KP_1, "KP1" },
-            { GLFW_KEY_KP_2, "KP2" },
-            { GLFW_KEY_KP_3, "KP3" },
-            { GLFW_KEY_KP_4, "KP4" },
-            { GLFW_KEY_KP_5, "KP5" },
-            { GLFW_KEY_KP_6, "KP6" },
-            { GLFW_KEY_KP_7, "KP7" },
-            { GLFW_KEY_KP_8, "KP8" },
-            { GLFW_KEY_KP_9, "KP9" },
-            { GLFW_KEY_KP_DECIMAL, "KPDL" },
-            { GLFW_KEY_KP_DIVIDE, "KPDV" },
-            { GLFW_KEY_KP_MULTIPLY, "KPMU" },
-            { GLFW_KEY_KP_SUBTRACT, "KPSU" },
-            { GLFW_KEY_KP_ADD, "KPAD" },
-            { GLFW_KEY_KP_ENTER, "KPEN" },
-            { GLFW_KEY_KP_EQUAL, "KPEQ" },
-            { GLFW_KEY_LEFT_SHIFT, "LFSH" },
-            { GLFW_KEY_LEFT_CONTROL, "LCTL" },
-            { GLFW_KEY_LEFT_ALT, "LALT" },
-            { GLFW_KEY_LEFT_SUPER, "LWIN" },
-            { GLFW_KEY_RIGHT_SHIFT, "RTSH" },
-            { GLFW_KEY_RIGHT_CONTROL, "RCTL" },
-            { GLFW_KEY_RIGHT_ALT, "RALT" },
-            { GLFW_KEY_RIGHT_ALT, "LVL3" },
-            { GLFW_KEY_RIGHT_ALT, "MDSW" },
-            { GLFW_KEY_RIGHT_SUPER, "RWIN" },
-            { GLFW_KEY_MENU, "MENU" }
-        };
-
-        // Find the X11 key code -> GLFW key code mapping
-        for (scancode = scancodeMin;  scancode <= scancodeMax;  scancode++)
-        {
-            int key = GLFW_KEY_UNKNOWN;
-
-            // Map the key name to a GLFW key code. Note: We use the US
-            // keyboard layout. Because function keys aren't mapped correctly
-            // when using traditional KeySym translations, they are mapped
-            // here instead.
-            for (int i = 0;  i < sizeof(keymap) / sizeof(keymap[0]);  i++)
-            {
-                if (strncmp(desc->names->keys[scancode].name,
-                            keymap[i].name,
-                            XkbKeyNameLength) == 0)
-                {
-                    key = keymap[i].key;
-                    break;
-                }
-            }
-
-            // Fall back to key aliases in case the key name did not match
-            for (int i = 0;  i < desc->names->num_key_aliases;  i++)
-            {
-                if (key != GLFW_KEY_UNKNOWN)
-                    break;
-
-                if (strncmp(desc->names->key_aliases[i].real,
-                            desc->names->keys[scancode].name,
-                            XkbKeyNameLength) != 0)
-                {
-                    continue;
-                }
-
-                for (int j = 0;  j < sizeof(keymap) / sizeof(keymap[0]);  j++)
-                {
-                    if (strncmp(desc->names->key_aliases[i].alias,
-                                keymap[j].name,
-                                XkbKeyNameLength) == 0)
-                    {
-                        key = keymap[j].key;
-                        break;
-                    }
-                }
-            }
-
-            _glfw.x11.keycodes[scancode] = key;
-        }
-
-        XkbFreeNames(desc, XkbKeyNamesMask, True);
-        XkbFreeKeyboard(desc, 0, True);
-    }
-    else
-        XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax);
-
-    int width;
-    KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display,
-                                          scancodeMin,
-                                          scancodeMax - scancodeMin + 1,
-                                          &width);
-
-    for (scancode = scancodeMin;  scancode <= scancodeMax;  scancode++)
-    {
-        // Translate the un-translated key codes using traditional X11 KeySym
-        // lookups
-        if (_glfw.x11.keycodes[scancode] < 0)
-        {
-            const size_t base = (scancode - scancodeMin) * width;
-            _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width);
-        }
-
-        // Store the reverse translation for faster key name lookup
-        if (_glfw.x11.keycodes[scancode] > 0)
-            _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
-    }
-
-    XFree(keysyms);
-}
-
-// Check whether the IM has a usable style
-//
-static GLFWbool hasUsableInputMethodStyle(void)
-{
-    GLFWbool found = GLFW_FALSE;
-    XIMStyles* styles = NULL;
-
-    if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
-        return GLFW_FALSE;
-
-    for (unsigned int i = 0;  i < styles->count_styles;  i++)
-    {
-        if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
-        {
-            found = GLFW_TRUE;
-            break;
-        }
-    }
-
-    XFree(styles);
-    return found;
-}
-
-static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData)
-{
-    _glfw.x11.im = NULL;
-}
-
-static void inputMethodInstantiateCallback(Display* display,
-                                           XPointer clientData,
-                                           XPointer callData)
-{
-    if (_glfw.x11.im)
-        return;
-
-    _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
-    if (_glfw.x11.im)
-    {
-        if (!hasUsableInputMethodStyle())
-        {
-            XCloseIM(_glfw.x11.im);
-            _glfw.x11.im = NULL;
-        }
-    }
-
-    if (_glfw.x11.im)
-    {
-        XIMCallback callback;
-        callback.callback = (XIMProc) inputMethodDestroyCallback;
-        callback.client_data = NULL;
-        XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL);
-
-        for (_GLFWwindow* window = _glfw.windowListHead;  window;  window = window->next)
-            _glfwCreateInputContextX11(window);
-    }
-}
-
-// Return the atom ID only if it is listed in the specified array
-//
-static Atom getAtomIfSupported(Atom* supportedAtoms,
-                               unsigned long atomCount,
-                               const char* atomName)
-{
-    const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
-
-    for (unsigned long i = 0;  i < atomCount;  i++)
-    {
-        if (supportedAtoms[i] == atom)
-            return atom;
-    }
-
-    return None;
-}
-
-// Check whether the running window manager is EWMH-compliant
-//
-static void detectEWMH(void)
-{
-    // First we read the _NET_SUPPORTING_WM_CHECK property on the root window
-
-    Window* windowFromRoot = NULL;
-    if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
-                                   _glfw.x11.NET_SUPPORTING_WM_CHECK,
-                                   XA_WINDOW,
-                                   (unsigned char**) &windowFromRoot))
-    {
-        return;
-    }
-
-    _glfwGrabErrorHandlerX11();
-
-    // If it exists, it should be the XID of a top-level window
-    // Then we look for the same property on that window
-
-    Window* windowFromChild = NULL;
-    if (!_glfwGetWindowPropertyX11(*windowFromRoot,
-                                   _glfw.x11.NET_SUPPORTING_WM_CHECK,
-                                   XA_WINDOW,
-                                   (unsigned char**) &windowFromChild))
-    {
-        XFree(windowFromRoot);
-        return;
-    }
-
-    _glfwReleaseErrorHandlerX11();
-
-    // If the property exists, it should contain the XID of the window
-
-    if (*windowFromRoot != *windowFromChild)
-    {
-        XFree(windowFromRoot);
-        XFree(windowFromChild);
-        return;
-    }
-
-    XFree(windowFromRoot);
-    XFree(windowFromChild);
-
-    // We are now fairly sure that an EWMH-compliant WM is currently running
-    // We can now start querying the WM about what features it supports by
-    // looking in the _NET_SUPPORTED property on the root window
-    // It should contain a list of supported EWMH protocol and state atoms
-
-    Atom* supportedAtoms = NULL;
-    const unsigned long atomCount =
-        _glfwGetWindowPropertyX11(_glfw.x11.root,
-                                  _glfw.x11.NET_SUPPORTED,
-                                  XA_ATOM,
-                                  (unsigned char**) &supportedAtoms);
-
-    // See which of the atoms we support that are supported by the WM
-
-    _glfw.x11.NET_WM_STATE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
-    _glfw.x11.NET_WM_STATE_ABOVE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
-    _glfw.x11.NET_WM_STATE_FULLSCREEN =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
-    _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
-    _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
-    _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
-    _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
-    _glfw.x11.NET_WM_WINDOW_TYPE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
-    _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
-    _glfw.x11.NET_WORKAREA =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
-    _glfw.x11.NET_CURRENT_DESKTOP =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
-    _glfw.x11.NET_ACTIVE_WINDOW =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
-    _glfw.x11.NET_FRAME_EXTENTS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
-    _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
-
-    if (supportedAtoms)
-        XFree(supportedAtoms);
-}
-
-// Look for and initialize supported X11 extensions
-//
-static GLFWbool initExtensions(void)
-{
-    _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
-    if (_glfw.x11.vidmode.handle)
-    {
-        _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
-        _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
-        _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
-        _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
-
-        _glfw.x11.vidmode.available =
-            XF86VidModeQueryExtension(_glfw.x11.display,
-                                      &_glfw.x11.vidmode.eventBase,
-                                      &_glfw.x11.vidmode.errorBase);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
-#else
-    _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
-#endif
-    if (_glfw.x11.xi.handle)
-    {
-        _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
-            _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion");
-        _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
-            _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents");
-
-        if (XQueryExtension(_glfw.x11.display,
-                            "XInputExtension",
-                            &_glfw.x11.xi.majorOpcode,
-                            &_glfw.x11.xi.eventBase,
-                            &_glfw.x11.xi.errorBase))
-        {
-            _glfw.x11.xi.major = 2;
-            _glfw.x11.xi.minor = 0;
-
-            if (XIQueryVersion(_glfw.x11.display,
-                               &_glfw.x11.xi.major,
-                               &_glfw.x11.xi.minor) == Success)
-            {
-                _glfw.x11.xi.available = GLFW_TRUE;
-            }
-        }
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
-#else
-    _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
-#endif
-    if (_glfw.x11.randr.handle)
-    {
-        _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma");
-        _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
-        _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
-        _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
-        _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
-        _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources");
-        _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
-        _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
-        _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
-        _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo");
-        _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
-        _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
-        _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension");
-        _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion");
-        _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput");
-        _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
-        _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
-        _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
-
-        if (XRRQueryExtension(_glfw.x11.display,
-                              &_glfw.x11.randr.eventBase,
-                              &_glfw.x11.randr.errorBase))
-        {
-            if (XRRQueryVersion(_glfw.x11.display,
-                                &_glfw.x11.randr.major,
-                                &_glfw.x11.randr.minor))
-            {
-                // The GLFW RandR path requires at least version 1.3
-                if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
-                    _glfw.x11.randr.available = GLFW_TRUE;
-            }
-            else
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "X11: Failed to query RandR version");
-            }
-        }
-    }
-
-    if (_glfw.x11.randr.available)
-    {
-        XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
-                                                              _glfw.x11.root);
-
-        if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
-        {
-            // This is likely an older Nvidia driver with broken gamma support
-            // Flag it as useless and fall back to xf86vm gamma, if available
-            _glfw.x11.randr.gammaBroken = GLFW_TRUE;
-        }
-
-        if (!sr->ncrtc)
-        {
-            // A system without CRTCs is likely a system with broken RandR
-            // Disable the RandR monitor path and fall back to core functions
-            _glfw.x11.randr.monitorBroken = GLFW_TRUE;
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
-                       RROutputChangeNotifyMask);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
-#else
-    _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
-#endif
-    if (_glfw.x11.xcursor.handle)
-    {
-        _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate");
-        _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
-        _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
-        _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme");
-        _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
-        _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
-#else
-    _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
-#endif
-    if (_glfw.x11.xinerama.handle)
-    {
-        _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive");
-        _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
-        _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
-
-        if (XineramaQueryExtension(_glfw.x11.display,
-                                   &_glfw.x11.xinerama.major,
-                                   &_glfw.x11.xinerama.minor))
-        {
-            if (XineramaIsActive(_glfw.x11.display))
-                _glfw.x11.xinerama.available = GLFW_TRUE;
-        }
-    }
-
-    _glfw.x11.xkb.major = 1;
-    _glfw.x11.xkb.minor = 0;
-    _glfw.x11.xkb.available =
-        XkbQueryExtension(_glfw.x11.display,
-                          &_glfw.x11.xkb.majorOpcode,
-                          &_glfw.x11.xkb.eventBase,
-                          &_glfw.x11.xkb.errorBase,
-                          &_glfw.x11.xkb.major,
-                          &_glfw.x11.xkb.minor);
-
-    if (_glfw.x11.xkb.available)
-    {
-        Bool supported;
-
-        if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
-        {
-            if (supported)
-                _glfw.x11.xkb.detectable = GLFW_TRUE;
-        }
-
-        XkbStateRec state;
-        if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
-            _glfw.x11.xkb.group = (unsigned int)state.group;
-
-        XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
-                              XkbGroupStateMask, XkbGroupStateMask);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
-#else
-    _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
-#endif
-    if (_glfw.x11.x11xcb.handle)
-    {
-        _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
-            _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
-#else
-    _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
-#endif
-    if (_glfw.x11.xrender.handle)
-    {
-        _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension");
-        _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion");
-        _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
-
-        if (XRenderQueryExtension(_glfw.x11.display,
-                                  &_glfw.x11.xrender.errorBase,
-                                  &_glfw.x11.xrender.eventBase))
-        {
-            if (XRenderQueryVersion(_glfw.x11.display,
-                                    &_glfw.x11.xrender.major,
-                                    &_glfw.x11.xrender.minor))
-            {
-                _glfw.x11.xrender.available = GLFW_TRUE;
-            }
-        }
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so");
-#else
-    _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6");
-#endif
-    if (_glfw.x11.xshape.handle)
-    {
-        _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension");
-        _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion");
-        _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion");
-        _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask");
-
-        if (XShapeQueryExtension(_glfw.x11.display,
-            &_glfw.x11.xshape.errorBase,
-            &_glfw.x11.xshape.eventBase))
-        {
-            if (XShapeQueryVersion(_glfw.x11.display,
-                &_glfw.x11.xshape.major,
-                &_glfw.x11.xshape.minor))
-            {
-                _glfw.x11.xshape.available = GLFW_TRUE;
-            }
-        }
-    }
-
-    // Update the key code LUT
-    // FIXME: We should listen to XkbMapNotify events to track changes to
-    // the keyboard mapping.
-    createKeyTables();
-
-    // String format atoms
-    _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
-    _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
-    _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
-
-    // Custom selection property atom
-    _glfw.x11.GLFW_SELECTION =
-        XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
-
-    // ICCCM standard clipboard atoms
-    _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
-    _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
-    _glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
-    _glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
-    _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
-
-    // Clipboard manager atoms
-    _glfw.x11.CLIPBOARD_MANAGER =
-        XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
-    _glfw.x11.SAVE_TARGETS =
-        XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
-
-    // Xdnd (drag and drop) atoms
-    _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
-    _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
-    _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
-    _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
-    _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
-    _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
-    _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
-    _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
-    _glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
-    _glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
-
-    // ICCCM, EWMH and Motif window property atoms
-    // These can be set safely even without WM support
-    // The EWMH atoms that require WM support are handled in detectEWMH
-    _glfw.x11.WM_PROTOCOLS =
-        XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
-    _glfw.x11.WM_STATE =
-        XInternAtom(_glfw.x11.display, "WM_STATE", False);
-    _glfw.x11.WM_DELETE_WINDOW =
-        XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
-    _glfw.x11.NET_SUPPORTED =
-        XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
-    _glfw.x11.NET_SUPPORTING_WM_CHECK =
-        XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
-    _glfw.x11.NET_WM_ICON =
-        XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
-    _glfw.x11.NET_WM_PING =
-        XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
-    _glfw.x11.NET_WM_PID =
-        XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
-    _glfw.x11.NET_WM_NAME =
-        XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
-    _glfw.x11.NET_WM_ICON_NAME =
-        XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
-    _glfw.x11.NET_WM_BYPASS_COMPOSITOR =
-        XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
-    _glfw.x11.NET_WM_WINDOW_OPACITY =
-        XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
-    _glfw.x11.MOTIF_WM_HINTS =
-        XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
-
-    // The compositing manager selection name contains the screen number
-    {
-        char name[32];
-        snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
-        _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
-    }
-
-    // Detect whether an EWMH-conformant window manager is running
-    detectEWMH();
-
-    return GLFW_TRUE;
-}
-
-// Retrieve system content scale via folklore heuristics
-//
-static void getSystemContentScale(float* xscale, float* yscale)
-{
-    // Start by assuming the default X11 DPI
-    // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
-    //       would be set to 96, so assume that is the case if we cannot find it
-    float xdpi = 96.f, ydpi = 96.f;
-
-    // NOTE: Basing the scale on Xft.dpi where available should provide the most
-    //       consistent user experience (matches Qt, Gtk, etc), although not
-    //       always the most accurate one
-    char* rms = XResourceManagerString(_glfw.x11.display);
-    if (rms)
-    {
-        XrmDatabase db = XrmGetStringDatabase(rms);
-        if (db)
-        {
-            XrmValue value;
-            char* type = NULL;
-
-            if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
-            {
-                if (type && strcmp(type, "String") == 0)
-                    xdpi = ydpi = atof(value.addr);
-            }
-
-            XrmDestroyDatabase(db);
-        }
-    }
-
-    *xscale = xdpi / 96.f;
-    *yscale = ydpi / 96.f;
-}
-
-// Create a blank cursor for hidden and disabled cursor modes
-//
-static Cursor createHiddenCursor(void)
-{
-    unsigned char pixels[16 * 16 * 4] = { 0 };
-    GLFWimage image = { 16, 16, pixels };
-    return _glfwCreateCursorX11(&image, 0, 0);
-}
-
-// Create a helper window for IPC
-//
-static Window createHelperWindow(void)
-{
-    XSetWindowAttributes wa;
-    wa.event_mask = PropertyChangeMask;
-
-    return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
-                         0, 0, 1, 1, 0, 0,
-                         InputOnly,
-                         DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
-                         CWEventMask, &wa);
-}
-
-// X error handler
-//
-static int errorHandler(Display *display, XErrorEvent* event)
-{
-    if (_glfw.x11.display != display)
-        return 0;
-
-    _glfw.x11.errorCode = event->error_code;
-    return 0;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Sets the X error handler callback
-//
-void _glfwGrabErrorHandlerX11(void)
-{
-    _glfw.x11.errorCode = Success;
-    XSetErrorHandler(errorHandler);
-}
-
-// Clears the X error handler callback
-//
-void _glfwReleaseErrorHandlerX11(void)
-{
-    // Synchronize to make sure all commands are processed
-    XSync(_glfw.x11.display, False);
-    XSetErrorHandler(NULL);
-}
-
-// Reports the specified error, appending information about the last X error
-//
-void _glfwInputErrorX11(int error, const char* message)
-{
-    char buffer[_GLFW_MESSAGE_SIZE];
-    XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
-                  buffer, sizeof(buffer));
-
-    _glfwInputError(error, "%s: %s", message, buffer);
-}
-
-// Creates a native cursor object from the specified image and hotspot
-//
-Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
-{
-    int i;
-    Cursor cursor;
-
-    if (!_glfw.x11.xcursor.handle)
-        return None;
-
-    XcursorImage* native = XcursorImageCreate(image->width, image->height);
-    if (native == NULL)
-        return None;
-
-    native->xhot = xhot;
-    native->yhot = yhot;
-
-    unsigned char* source = (unsigned char*) image->pixels;
-    XcursorPixel* target = native->pixels;
-
-    for (i = 0;  i < image->width * image->height;  i++, target++, source += 4)
-    {
-        unsigned int alpha = source[3];
-
-        *target = (alpha << 24) |
-                  ((unsigned char) ((source[0] * alpha) / 255) << 16) |
-                  ((unsigned char) ((source[1] * alpha) / 255) <<  8) |
-                  ((unsigned char) ((source[2] * alpha) / 255) <<  0);
-    }
-
-    cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
-    XcursorImageDestroy(native);
-
-    return cursor;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    // HACK: If the application has left the locale as "C" then both wide
-    //       character text input and explicit UTF-8 input via XIM will break
-    //       This sets the CTYPE part of the current locale from the environment
-    //       in the hope that it is set to something more sane than "C"
-    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
-        setlocale(LC_CTYPE, "");
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so");
-#else
-    _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6");
-#endif
-    if (!_glfw.x11.xlib.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib");
-        return GLFW_FALSE;
-    }
-
-    _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint");
-    _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints");
-    _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints");
-    _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty");
-    _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes");
-    _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent");
-    _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent");
-    _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay");
-    _glfw.x11.xlib.CloseIM = (PFN_XCloseIM)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM");
-    _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection");
-    _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap");
-    _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor");
-    _glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC");
-    _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion");
-    _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow");
-    _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor");
-    _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext");
-    _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty");
-    _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC");
-    _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion");
-    _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow");
-    _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes");
-    _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued");
-    _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent");
-    _glfw.x11.xlib.FindContext = (PFN_XFindContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext");
-    _glfw.x11.xlib.Flush = (PFN_XFlush)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush");
-    _glfw.x11.xlib.Free = (PFN_XFree)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFree");
-    _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap");
-    _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor");
-    _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData");
-    _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText");
-    _glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData");
-    _glfw.x11.xlib.GetICValues = (PFN_XGetICValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues");
-    _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues");
-    _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus");
-    _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping");
-    _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver");
-    _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner");
-    _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo");
-    _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints");
-    _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes");
-    _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty");
-    _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer");
-    _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow");
-    _glfw.x11.xlib.InitThreads = (PFN_XInitThreads)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads");
-    _glfw.x11.xlib.InternAtom = (PFN_XInternAtom)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom");
-    _glfw.x11.xlib.LookupString = (PFN_XLookupString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString");
-    _glfw.x11.xlib.MapRaised = (PFN_XMapRaised)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised");
-    _glfw.x11.xlib.MapWindow = (PFN_XMapWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow");
-    _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow");
-    _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow");
-    _glfw.x11.xlib.NextEvent = (PFN_XNextEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent");
-    _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay");
-    _glfw.x11.xlib.OpenIM = (PFN_XOpenIM)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM");
-    _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent");
-    _glfw.x11.xlib.Pending = (PFN_XPending)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XPending");
-    _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension");
-    _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer");
-    _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow");
-    _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback");
-    _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow");
-    _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString");
-    _glfw.x11.xlib.SaveContext = (PFN_XSaveContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext");
-    _glfw.x11.xlib.SelectInput = (PFN_XSelectInput)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput");
-    _glfw.x11.xlib.SendEvent = (PFN_XSendEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent");
-    _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint");
-    _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler");
-    _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus");
-    _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues");
-    _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus");
-    _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers");
-    _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver");
-    _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner");
-    _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints");
-    _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints");
-    _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols");
-    _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale");
-    _glfw.x11.xlib.Sync = (PFN_XSync)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSync");
-    _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates");
-    _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor");
-    _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer");
-    _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow");
-    _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus");
-    _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
-    _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer");
-    _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
-    _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames");
-    _glfw.x11.xkb.GetMap = (PFN_XkbGetMap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap");
-    _glfw.x11.xkb.GetNames = (PFN_XkbGetNames)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames");
-    _glfw.x11.xkb.GetState = (PFN_XkbGetState)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState");
-    _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym");
-    _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension");
-    _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails");
-    _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat");
-    _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase");
-    _glfw.x11.xrm.GetResource = (PFN_XrmGetResource)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource");
-    _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase");
-    _glfw.x11.xrm.Initialize = (PFN_XrmInitialize)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize");
-    _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark");
-    _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback");
-    _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString");
-    _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
-
-    if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
-        _glfw.x11.xlib.utf8 = GLFW_TRUE;
-
-    XInitThreads();
-    XrmInitialize();
-
-    _glfw.x11.display = XOpenDisplay(NULL);
-    if (!_glfw.x11.display)
-    {
-        const char* display = getenv("DISPLAY");
-        if (display)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to open display %s", display);
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: The DISPLAY environment variable is missing");
-        }
-
-        return GLFW_FALSE;
-    }
-
-    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
-    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
-    _glfw.x11.context = XUniqueContext();
-
-    getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
-
-    if (!initExtensions())
-        return GLFW_FALSE;
-
-    _glfw.x11.helperWindowHandle = createHelperWindow();
-    _glfw.x11.hiddenCursorHandle = createHiddenCursor();
-
-    if (XSupportsLocale() && _glfw.x11.xlib.utf8)
-    {
-        XSetLocaleModifiers("");
-
-        // If an IM is already present our callback will be called right away
-        XRegisterIMInstantiateCallback(_glfw.x11.display,
-                                       NULL, NULL, NULL,
-                                       inputMethodInstantiateCallback,
-                                       NULL);
-    }
-
-    _glfwInitTimerPOSIX();
-
-    _glfwPollMonitorsX11();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    if (_glfw.x11.helperWindowHandle)
-    {
-        if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
-            _glfw.x11.helperWindowHandle)
-        {
-            _glfwPushSelectionToManagerX11();
-        }
-
-        XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
-        _glfw.x11.helperWindowHandle = None;
-    }
-
-    if (_glfw.x11.hiddenCursorHandle)
-    {
-        XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
-        _glfw.x11.hiddenCursorHandle = (Cursor) 0;
-    }
-
-    free(_glfw.x11.primarySelectionString);
-    free(_glfw.x11.clipboardString);
-
-    XUnregisterIMInstantiateCallback(_glfw.x11.display,
-                                     NULL, NULL, NULL,
-                                     inputMethodInstantiateCallback,
-                                     NULL);
-
-    if (_glfw.x11.im)
-    {
-        XCloseIM(_glfw.x11.im);
-        _glfw.x11.im = NULL;
-    }
-
-    if (_glfw.x11.display)
-    {
-        XCloseDisplay(_glfw.x11.display);
-        _glfw.x11.display = NULL;
-    }
-
-    if (_glfw.x11.x11xcb.handle)
-    {
-        _glfw_dlclose(_glfw.x11.x11xcb.handle);
-        _glfw.x11.x11xcb.handle = NULL;
-    }
-
-    if (_glfw.x11.xcursor.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xcursor.handle);
-        _glfw.x11.xcursor.handle = NULL;
-    }
-
-    if (_glfw.x11.randr.handle)
-    {
-        _glfw_dlclose(_glfw.x11.randr.handle);
-        _glfw.x11.randr.handle = NULL;
-    }
-
-    if (_glfw.x11.xinerama.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xinerama.handle);
-        _glfw.x11.xinerama.handle = NULL;
-    }
-
-    if (_glfw.x11.xrender.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xrender.handle);
-        _glfw.x11.xrender.handle = NULL;
-    }
-
-    if (_glfw.x11.vidmode.handle)
-    {
-        _glfw_dlclose(_glfw.x11.vidmode.handle);
-        _glfw.x11.vidmode.handle = NULL;
-    }
-
-    if (_glfw.x11.xi.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xi.handle);
-        _glfw.x11.xi.handle = NULL;
-    }
-
-    // NOTE: These need to be unloaded after XCloseDisplay, as they register
-    //       cleanup callbacks that get called by that function
-    _glfwTerminateEGL();
-    _glfwTerminateGLX();
-
-    if (_glfw.x11.xlib.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xlib.handle);
-        _glfw.x11.xlib.handle = NULL;
-    }
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa"
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-        " clock_gettime"
-#else
-        " gettimeofday"
-#endif
-#if defined(__linux__)
-        " evdev"
-#endif
-#if defined(_GLFW_BUILD_DLL)
-        " shared"
-#endif
-        ;
-}
-
diff --git a/raylib/external/glfw/src/x11_monitor.c b/raylib/external/glfw/src/x11_monitor.c
deleted file mode 100644 (file)
index 8de8659..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-
-// Check whether the display mode should be included in enumeration
-//
-static GLFWbool modeIsGood(const XRRModeInfo* mi)
-{
-    return (mi->modeFlags & RR_Interlace) == 0;
-}
-
-// Calculates the refresh rate, in Hz, from the specified RandR mode info
-//
-static int calculateRefreshRate(const XRRModeInfo* mi)
-{
-    if (mi->hTotal && mi->vTotal)
-        return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
-    else
-        return 0;
-}
-
-// Returns the mode info for a RandR mode XID
-//
-static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
-{
-    for (int i = 0;  i < sr->nmode;  i++)
-    {
-        if (sr->modes[i].id == id)
-            return sr->modes + i;
-    }
-
-    return NULL;
-}
-
-// Convert RandR mode info to GLFW video mode
-//
-static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
-                                       const XRRCrtcInfo* ci)
-{
-    GLFWvidmode mode;
-
-    if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-    {
-        mode.width  = mi->height;
-        mode.height = mi->width;
-    }
-    else
-    {
-        mode.width  = mi->width;
-        mode.height = mi->height;
-    }
-
-    mode.refreshRate = calculateRefreshRate(mi);
-
-    _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
-                  &mode.redBits, &mode.greenBits, &mode.blueBits);
-
-    return mode;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsX11(void)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        int disconnectedCount, screenCount = 0;
-        _GLFWmonitor** disconnected = NULL;
-        XineramaScreenInfo* screens = NULL;
-        XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
-                                                              _glfw.x11.root);
-        RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
-                                               _glfw.x11.root);
-
-        if (_glfw.x11.xinerama.available)
-            screens = XineramaQueryScreens(_glfw.x11.display, &screenCount);
-
-        disconnectedCount = _glfw.monitorCount;
-        if (disconnectedCount)
-        {
-            disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-            memcpy(disconnected,
-                   _glfw.monitors,
-                   _glfw.monitorCount * sizeof(_GLFWmonitor*));
-        }
-
-        for (int i = 0;  i < sr->noutput;  i++)
-        {
-            int j, type, widthMM, heightMM;
-
-            XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
-            if (oi->connection != RR_Connected || oi->crtc == None)
-            {
-                XRRFreeOutputInfo(oi);
-                continue;
-            }
-
-            for (j = 0;  j < disconnectedCount;  j++)
-            {
-                if (disconnected[j] &&
-                    disconnected[j]->x11.output == sr->outputs[i])
-                {
-                    disconnected[j] = NULL;
-                    break;
-                }
-            }
-
-            if (j < disconnectedCount)
-            {
-                XRRFreeOutputInfo(oi);
-                continue;
-            }
-
-            XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
-            if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-            {
-                widthMM  = oi->mm_height;
-                heightMM = oi->mm_width;
-            }
-            else
-            {
-                widthMM  = oi->mm_width;
-                heightMM = oi->mm_height;
-            }
-
-            if (widthMM <= 0 || heightMM <= 0)
-            {
-                // HACK: If RandR does not provide a physical size, assume the
-                //       X11 default 96 DPI and calculate from the CRTC viewport
-                // NOTE: These members are affected by rotation, unlike the mode
-                //       info and output info members
-                widthMM  = (int) (ci->width * 25.4f / 96.f);
-                heightMM = (int) (ci->height * 25.4f / 96.f);
-            }
-
-            _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
-            monitor->x11.output = sr->outputs[i];
-            monitor->x11.crtc   = oi->crtc;
-
-            for (j = 0;  j < screenCount;  j++)
-            {
-                if (screens[j].x_org == ci->x &&
-                    screens[j].y_org == ci->y &&
-                    screens[j].width == ci->width &&
-                    screens[j].height == ci->height)
-                {
-                    monitor->x11.index = j;
-                    break;
-                }
-            }
-
-            if (monitor->x11.output == primary)
-                type = _GLFW_INSERT_FIRST;
-            else
-                type = _GLFW_INSERT_LAST;
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-
-            XRRFreeOutputInfo(oi);
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-
-        if (screens)
-            XFree(screens);
-
-        for (int i = 0;  i < disconnectedCount;  i++)
-        {
-            if (disconnected[i])
-                _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-        }
-
-        free(disconnected);
-    }
-    else
-    {
-        const int widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
-        const int heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
-
-        _glfwInputMonitor(_glfwAllocMonitor("Display", widthMM, heightMM),
-                          GLFW_CONNECTED,
-                          _GLFW_INSERT_FIRST);
-    }
-}
-
-// Set the current video mode for the specified monitor
-//
-void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        GLFWvidmode current;
-        RRMode native = None;
-
-        const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
-        _glfwPlatformGetVideoMode(monitor, &current);
-        if (_glfwCompareVideoModes(&current, best) == 0)
-            return;
-
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-        XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
-
-        for (int i = 0;  i < oi->nmode;  i++)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
-            if (!modeIsGood(mi))
-                continue;
-
-            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
-            if (_glfwCompareVideoModes(best, &mode) == 0)
-            {
-                native = mi->id;
-                break;
-            }
-        }
-
-        if (native)
-        {
-            if (monitor->x11.oldMode == None)
-                monitor->x11.oldMode = ci->mode;
-
-            XRRSetCrtcConfig(_glfw.x11.display,
-                             sr, monitor->x11.crtc,
-                             CurrentTime,
-                             ci->x, ci->y,
-                             native,
-                             ci->rotation,
-                             ci->outputs,
-                             ci->noutput);
-        }
-
-        XRRFreeOutputInfo(oi);
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-}
-
-// Restore the saved (original) video mode for the specified monitor
-//
-void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        if (monitor->x11.oldMode == None)
-            return;
-
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        XRRSetCrtcConfig(_glfw.x11.display,
-                         sr, monitor->x11.crtc,
-                         CurrentTime,
-                         ci->x, ci->y,
-                         monitor->x11.oldMode,
-                         ci->rotation,
-                         ci->outputs,
-                         ci->noutput);
-
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-
-        monitor->x11.oldMode = None;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        if (ci)
-        {
-            if (xpos)
-                *xpos = ci->x;
-            if (ypos)
-                *ypos = ci->y;
-
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = _glfw.x11.contentScaleX;
-    if (yscale)
-        *yscale = _glfw.x11.contentScaleY;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height)
-{
-    int areaX = 0, areaY = 0, areaWidth = 0, areaHeight = 0;
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        areaX = ci->x;
-        areaY = ci->y;
-
-        const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
-
-        if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-        {
-            areaWidth  = mi->height;
-            areaHeight = mi->width;
-        }
-        else
-        {
-            areaWidth  = mi->width;
-            areaHeight = mi->height;
-        }
-
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        areaWidth  = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
-        areaHeight = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
-    }
-
-    if (_glfw.x11.NET_WORKAREA && _glfw.x11.NET_CURRENT_DESKTOP)
-    {
-        Atom* extents = NULL;
-        Atom* desktop = NULL;
-        const unsigned long extentCount =
-            _glfwGetWindowPropertyX11(_glfw.x11.root,
-                                      _glfw.x11.NET_WORKAREA,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &extents);
-
-        if (_glfwGetWindowPropertyX11(_glfw.x11.root,
-                                      _glfw.x11.NET_CURRENT_DESKTOP,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &desktop) > 0)
-        {
-            if (extentCount >= 4 && *desktop < extentCount / 4)
-            {
-                const int globalX = extents[*desktop * 4 + 0];
-                const int globalY = extents[*desktop * 4 + 1];
-                const int globalWidth  = extents[*desktop * 4 + 2];
-                const int globalHeight = extents[*desktop * 4 + 3];
-
-                if (areaX < globalX)
-                {
-                    areaWidth -= globalX - areaX;
-                    areaX = globalX;
-                }
-
-                if (areaY < globalY)
-                {
-                    areaHeight -= globalY - areaY;
-                    areaY = globalY;
-                }
-
-                if (areaX + areaWidth > globalX + globalWidth)
-                    areaWidth = globalX - areaX + globalWidth;
-                if (areaY + areaHeight > globalY + globalHeight)
-                    areaHeight = globalY - areaY + globalHeight;
-            }
-        }
-
-        if (extents)
-            XFree(extents);
-        if (desktop)
-            XFree(desktop);
-    }
-
-    if (xpos)
-        *xpos = areaX;
-    if (ypos)
-        *ypos = areaY;
-    if (width)
-        *width = areaWidth;
-    if (height)
-        *height = areaHeight;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    GLFWvidmode* result;
-
-    *count = 0;
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-        XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
-
-        result = calloc(oi->nmode, sizeof(GLFWvidmode));
-
-        for (int i = 0;  i < oi->nmode;  i++)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
-            if (!modeIsGood(mi))
-                continue;
-
-            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
-            int j;
-
-            for (j = 0;  j < *count;  j++)
-            {
-                if (_glfwCompareVideoModes(result + j, &mode) == 0)
-                    break;
-            }
-
-            // Skip duplicate modes
-            if (j < *count)
-                continue;
-
-            (*count)++;
-            result[*count - 1] = mode;
-        }
-
-        XRRFreeOutputInfo(oi);
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        *count = 1;
-        result = calloc(1, sizeof(GLFWvidmode));
-        _glfwPlatformGetVideoMode(monitor, result);
-    }
-
-    return result;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        if (ci)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
-            if (mi)  // mi can be NULL if the monitor has been disconnected
-                *mode = vidmodeFromModeInfo(mi, ci);
-
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
-        mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
-        mode->refreshRate = 0;
-
-        _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
-                      &mode->redBits, &mode->greenBits, &mode->blueBits);
-    }
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
-    {
-        const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,
-                                                monitor->x11.crtc);
-        XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
-                                              monitor->x11.crtc);
-
-        _glfwAllocGammaArrays(ramp, size);
-
-        memcpy(ramp->red,   gamma->red,   size * sizeof(unsigned short));
-        memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));
-        memcpy(ramp->blue,  gamma->blue,  size * sizeof(unsigned short));
-
-        XRRFreeGamma(gamma);
-        return GLFW_TRUE;
-    }
-    else if (_glfw.x11.vidmode.available)
-    {
-        int size;
-        XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
-
-        _glfwAllocGammaArrays(ramp, size);
-
-        XF86VidModeGetGammaRamp(_glfw.x11.display,
-                                _glfw.x11.screen,
-                                ramp->size, ramp->red, ramp->green, ramp->blue);
-        return GLFW_TRUE;
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Gamma ramp access not supported by server");
-        return GLFW_FALSE;
-    }
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
-    {
-        if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Gamma ramp size must match current ramp size");
-            return;
-        }
-
-        XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size);
-
-        memcpy(gamma->red,   ramp->red,   ramp->size * sizeof(unsigned short));
-        memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short));
-        memcpy(gamma->blue,  ramp->blue,  ramp->size * sizeof(unsigned short));
-
-        XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
-        XRRFreeGamma(gamma);
-    }
-    else if (_glfw.x11.vidmode.available)
-    {
-        XF86VidModeSetGammaRamp(_glfw.x11.display,
-                                _glfw.x11.screen,
-                                ramp->size,
-                                (unsigned short*) ramp->red,
-                                (unsigned short*) ramp->green,
-                                (unsigned short*) ramp->blue);
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Gamma ramp access not supported by server");
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return monitor->x11.crtc;
-}
-
-GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return monitor->x11.output;
-}
-
diff --git a/raylib/external/glfw/src/x11_platform.h b/raylib/external/glfw/src/x11_platform.h
deleted file mode 100644 (file)
index c5137bc..0000000
+++ /dev/null
@@ -1,798 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <unistd.h>
-#include <signal.h>
-#include <stdint.h>
-#include <dlfcn.h>
-
-#include <X11/Xlib.h>
-#include <X11/keysym.h>
-#include <X11/Xatom.h>
-#include <X11/Xresource.h>
-#include <X11/Xcursor/Xcursor.h>
-
-// The XRandR extension provides mode setting and gamma control
-#include <X11/extensions/Xrandr.h>
-
-// The Xkb extension provides improved keyboard support
-#include <X11/XKBlib.h>
-
-// The Xinerama extension provides legacy monitor indices
-#include <X11/extensions/Xinerama.h>
-
-// The XInput extension provides raw mouse motion input
-#include <X11/extensions/XInput2.h>
-
-// The Shape extension provides custom window shapes
-#include <X11/extensions/shape.h>
-
-typedef XClassHint* (* PFN_XAllocClassHint)(void);
-typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
-typedef XWMHints* (* PFN_XAllocWMHints)(void);
-typedef int (* PFN_XChangeProperty)(Display*,Window,Atom,Atom,int,int,const unsigned char*,int);
-typedef int (* PFN_XChangeWindowAttributes)(Display*,Window,unsigned long,XSetWindowAttributes*);
-typedef Bool (* PFN_XCheckIfEvent)(Display*,XEvent*,Bool(*)(Display*,XEvent*,XPointer),XPointer);
-typedef Bool (* PFN_XCheckTypedWindowEvent)(Display*,Window,int,XEvent*);
-typedef int (* PFN_XCloseDisplay)(Display*);
-typedef Status (* PFN_XCloseIM)(XIM);
-typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time);
-typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int);
-typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int);
-typedef XIC (* PFN_XCreateIC)(XIM,...);
-typedef Region (* PFN_XCreateRegion)(void);
-typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*);
-typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor);
-typedef int (* PFN_XDeleteContext)(Display*,XID,XContext);
-typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom);
-typedef void (* PFN_XDestroyIC)(XIC);
-typedef int (* PFN_XDestroyRegion)(Region);
-typedef int (* PFN_XDestroyWindow)(Display*,Window);
-typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*);
-typedef int (* PFN_XEventsQueued)(Display*,int);
-typedef Bool (* PFN_XFilterEvent)(XEvent*,Window);
-typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*);
-typedef int (* PFN_XFlush)(Display*);
-typedef int (* PFN_XFree)(void*);
-typedef int (* PFN_XFreeColormap)(Display*,Colormap);
-typedef int (* PFN_XFreeCursor)(Display*,Cursor);
-typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*);
-typedef int (* PFN_XGetErrorText)(Display*,int,char*,int);
-typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*);
-typedef char* (* PFN_XGetICValues)(XIC,...);
-typedef char* (* PFN_XGetIMValues)(XIM,...);
-typedef int (* PFN_XGetInputFocus)(Display*,Window*,int*);
-typedef KeySym* (* PFN_XGetKeyboardMapping)(Display*,KeyCode,int,int*);
-typedef int (* PFN_XGetScreenSaver)(Display*,int*,int*,int*,int*);
-typedef Window (* PFN_XGetSelectionOwner)(Display*,Atom);
-typedef XVisualInfo* (* PFN_XGetVisualInfo)(Display*,long,XVisualInfo*,int*);
-typedef Status (* PFN_XGetWMNormalHints)(Display*,Window,XSizeHints*,long*);
-typedef Status (* PFN_XGetWindowAttributes)(Display*,Window,XWindowAttributes*);
-typedef int (* PFN_XGetWindowProperty)(Display*,Window,Atom,long,long,Bool,Atom,Atom*,int*,unsigned long*,unsigned long*,unsigned char**);
-typedef int (* PFN_XGrabPointer)(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time);
-typedef Status (* PFN_XIconifyWindow)(Display*,Window,int);
-typedef Status (* PFN_XInitThreads)(void);
-typedef Atom (* PFN_XInternAtom)(Display*,const char*,Bool);
-typedef int (* PFN_XLookupString)(XKeyEvent*,char*,int,KeySym*,XComposeStatus*);
-typedef int (* PFN_XMapRaised)(Display*,Window);
-typedef int (* PFN_XMapWindow)(Display*,Window);
-typedef int (* PFN_XMoveResizeWindow)(Display*,Window,int,int,unsigned int,unsigned int);
-typedef int (* PFN_XMoveWindow)(Display*,Window,int,int);
-typedef int (* PFN_XNextEvent)(Display*,XEvent*);
-typedef Display* (* PFN_XOpenDisplay)(const char*);
-typedef XIM (* PFN_XOpenIM)(Display*,XrmDatabase*,char*,char*);
-typedef int (* PFN_XPeekEvent)(Display*,XEvent*);
-typedef int (* PFN_XPending)(Display*);
-typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*);
-typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*);
-typedef int (* PFN_XRaiseWindow)(Display*,Window);
-typedef Bool (* PFN_XRegisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
-typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int);
-typedef char* (* PFN_XResourceManagerString)(Display*);
-typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*);
-typedef int (* PFN_XSelectInput)(Display*,Window,long);
-typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*);
-typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*);
-typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler);
-typedef void (* PFN_XSetICFocus)(XIC);
-typedef char* (* PFN_XSetIMValues)(XIM,...);
-typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time);
-typedef char* (* PFN_XSetLocaleModifiers)(const char*);
-typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int);
-typedef int (* PFN_XSetSelectionOwner)(Display*,Atom,Window,Time);
-typedef int (* PFN_XSetWMHints)(Display*,Window,XWMHints*);
-typedef void (* PFN_XSetWMNormalHints)(Display*,Window,XSizeHints*);
-typedef Status (* PFN_XSetWMProtocols)(Display*,Window,Atom*,int);
-typedef Bool (* PFN_XSupportsLocale)(void);
-typedef int (* PFN_XSync)(Display*,Bool);
-typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*);
-typedef int (* PFN_XUndefineCursor)(Display*,Window);
-typedef int (* PFN_XUngrabPointer)(Display*,Time);
-typedef int (* PFN_XUnmapWindow)(Display*,Window);
-typedef void (* PFN_XUnsetICFocus)(XIC);
-typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
-typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int);
-typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool);
-typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool);
-typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int);
-typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr);
-typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr);
-typedef KeySym (* PFN_XkbKeycodeToKeysym)(Display*,KeyCode,int,int);
-typedef Bool (* PFN_XkbQueryExtension)(Display*,int*,int*,int*,int*,int*);
-typedef Bool (* PFN_XkbSelectEventDetails)(Display*,unsigned int,unsigned int,unsigned long,unsigned long);
-typedef Bool (* PFN_XkbSetDetectableAutoRepeat)(Display*,Bool,Bool*);
-typedef void (* PFN_XrmDestroyDatabase)(XrmDatabase);
-typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,XrmValue*);
-typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*);
-typedef void (* PFN_XrmInitialize)(void);
-typedef XrmQuark (* PFN_XrmUniqueQuark)(void);
-typedef Bool (* PFN_XUnregisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
-typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*);
-typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*);
-#define XAllocClassHint _glfw.x11.xlib.AllocClassHint
-#define XAllocSizeHints _glfw.x11.xlib.AllocSizeHints
-#define XAllocWMHints _glfw.x11.xlib.AllocWMHints
-#define XChangeProperty _glfw.x11.xlib.ChangeProperty
-#define XChangeWindowAttributes _glfw.x11.xlib.ChangeWindowAttributes
-#define XCheckIfEvent _glfw.x11.xlib.CheckIfEvent
-#define XCheckTypedWindowEvent _glfw.x11.xlib.CheckTypedWindowEvent
-#define XCloseDisplay _glfw.x11.xlib.CloseDisplay
-#define XCloseIM _glfw.x11.xlib.CloseIM
-#define XConvertSelection _glfw.x11.xlib.ConvertSelection
-#define XCreateColormap _glfw.x11.xlib.CreateColormap
-#define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor
-#define XCreateIC _glfw.x11.xlib.CreateIC
-#define XCreateRegion _glfw.x11.xlib.CreateRegion
-#define XCreateWindow _glfw.x11.xlib.CreateWindow
-#define XDefineCursor _glfw.x11.xlib.DefineCursor
-#define XDeleteContext _glfw.x11.xlib.DeleteContext
-#define XDeleteProperty _glfw.x11.xlib.DeleteProperty
-#define XDestroyIC _glfw.x11.xlib.DestroyIC
-#define XDestroyRegion _glfw.x11.xlib.DestroyRegion
-#define XDestroyWindow _glfw.x11.xlib.DestroyWindow
-#define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes
-#define XEventsQueued _glfw.x11.xlib.EventsQueued
-#define XFilterEvent _glfw.x11.xlib.FilterEvent
-#define XFindContext _glfw.x11.xlib.FindContext
-#define XFlush _glfw.x11.xlib.Flush
-#define XFree _glfw.x11.xlib.Free
-#define XFreeColormap _glfw.x11.xlib.FreeColormap
-#define XFreeCursor _glfw.x11.xlib.FreeCursor
-#define XFreeEventData _glfw.x11.xlib.FreeEventData
-#define XGetErrorText _glfw.x11.xlib.GetErrorText
-#define XGetEventData _glfw.x11.xlib.GetEventData
-#define XGetICValues _glfw.x11.xlib.GetICValues
-#define XGetIMValues _glfw.x11.xlib.GetIMValues
-#define XGetInputFocus _glfw.x11.xlib.GetInputFocus
-#define XGetKeyboardMapping _glfw.x11.xlib.GetKeyboardMapping
-#define XGetScreenSaver _glfw.x11.xlib.GetScreenSaver
-#define XGetSelectionOwner _glfw.x11.xlib.GetSelectionOwner
-#define XGetVisualInfo _glfw.x11.xlib.GetVisualInfo
-#define XGetWMNormalHints _glfw.x11.xlib.GetWMNormalHints
-#define XGetWindowAttributes _glfw.x11.xlib.GetWindowAttributes
-#define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty
-#define XGrabPointer _glfw.x11.xlib.GrabPointer
-#define XIconifyWindow _glfw.x11.xlib.IconifyWindow
-#define XInitThreads _glfw.x11.xlib.InitThreads
-#define XInternAtom _glfw.x11.xlib.InternAtom
-#define XLookupString _glfw.x11.xlib.LookupString
-#define XMapRaised _glfw.x11.xlib.MapRaised
-#define XMapWindow _glfw.x11.xlib.MapWindow
-#define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow
-#define XMoveWindow _glfw.x11.xlib.MoveWindow
-#define XNextEvent _glfw.x11.xlib.NextEvent
-#define XOpenDisplay _glfw.x11.xlib.OpenDisplay
-#define XOpenIM _glfw.x11.xlib.OpenIM
-#define XPeekEvent _glfw.x11.xlib.PeekEvent
-#define XPending _glfw.x11.xlib.Pending
-#define XQueryExtension _glfw.x11.xlib.QueryExtension
-#define XQueryPointer _glfw.x11.xlib.QueryPointer
-#define XRaiseWindow _glfw.x11.xlib.RaiseWindow
-#define XRegisterIMInstantiateCallback _glfw.x11.xlib.RegisterIMInstantiateCallback
-#define XResizeWindow _glfw.x11.xlib.ResizeWindow
-#define XResourceManagerString _glfw.x11.xlib.ResourceManagerString
-#define XSaveContext _glfw.x11.xlib.SaveContext
-#define XSelectInput _glfw.x11.xlib.SelectInput
-#define XSendEvent _glfw.x11.xlib.SendEvent
-#define XSetClassHint _glfw.x11.xlib.SetClassHint
-#define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler
-#define XSetICFocus _glfw.x11.xlib.SetICFocus
-#define XSetIMValues _glfw.x11.xlib.SetIMValues
-#define XSetInputFocus _glfw.x11.xlib.SetInputFocus
-#define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers
-#define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver
-#define XSetSelectionOwner _glfw.x11.xlib.SetSelectionOwner
-#define XSetWMHints _glfw.x11.xlib.SetWMHints
-#define XSetWMNormalHints _glfw.x11.xlib.SetWMNormalHints
-#define XSetWMProtocols _glfw.x11.xlib.SetWMProtocols
-#define XSupportsLocale _glfw.x11.xlib.SupportsLocale
-#define XSync _glfw.x11.xlib.Sync
-#define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates
-#define XUndefineCursor _glfw.x11.xlib.UndefineCursor
-#define XUngrabPointer _glfw.x11.xlib.UngrabPointer
-#define XUnmapWindow _glfw.x11.xlib.UnmapWindow
-#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
-#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
-#define XWarpPointer _glfw.x11.xlib.WarpPointer
-#define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard
-#define XkbFreeNames _glfw.x11.xkb.FreeNames
-#define XkbGetMap _glfw.x11.xkb.GetMap
-#define XkbGetNames _glfw.x11.xkb.GetNames
-#define XkbGetState _glfw.x11.xkb.GetState
-#define XkbKeycodeToKeysym _glfw.x11.xkb.KeycodeToKeysym
-#define XkbQueryExtension _glfw.x11.xkb.QueryExtension
-#define XkbSelectEventDetails _glfw.x11.xkb.SelectEventDetails
-#define XkbSetDetectableAutoRepeat _glfw.x11.xkb.SetDetectableAutoRepeat
-#define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase
-#define XrmGetResource _glfw.x11.xrm.GetResource
-#define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase
-#define XrmInitialize _glfw.x11.xrm.Initialize
-#define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark
-#define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback
-#define Xutf8LookupString _glfw.x11.xlib.utf8LookupString
-#define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties
-
-typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int);
-typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*);
-typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*);
-typedef void (* PFN_XRRFreeOutputInfo)(XRROutputInfo*);
-typedef void (* PFN_XRRFreeScreenResources)(XRRScreenResources*);
-typedef XRRCrtcGamma* (* PFN_XRRGetCrtcGamma)(Display*,RRCrtc);
-typedef int (* PFN_XRRGetCrtcGammaSize)(Display*,RRCrtc);
-typedef XRRCrtcInfo* (* PFN_XRRGetCrtcInfo) (Display*,XRRScreenResources*,RRCrtc);
-typedef XRROutputInfo* (* PFN_XRRGetOutputInfo)(Display*,XRRScreenResources*,RROutput);
-typedef RROutput (* PFN_XRRGetOutputPrimary)(Display*,Window);
-typedef XRRScreenResources* (* PFN_XRRGetScreenResourcesCurrent)(Display*,Window);
-typedef Bool (* PFN_XRRQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XRRQueryVersion)(Display*,int*,int*);
-typedef void (* PFN_XRRSelectInput)(Display*,Window,int);
-typedef Status (* PFN_XRRSetCrtcConfig)(Display*,XRRScreenResources*,RRCrtc,Time,int,int,RRMode,Rotation,RROutput*,int);
-typedef void (* PFN_XRRSetCrtcGamma)(Display*,RRCrtc,XRRCrtcGamma*);
-typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
-#define XRRAllocGamma _glfw.x11.randr.AllocGamma
-#define XRRFreeCrtcInfo _glfw.x11.randr.FreeCrtcInfo
-#define XRRFreeGamma _glfw.x11.randr.FreeGamma
-#define XRRFreeOutputInfo _glfw.x11.randr.FreeOutputInfo
-#define XRRFreeScreenResources _glfw.x11.randr.FreeScreenResources
-#define XRRGetCrtcGamma _glfw.x11.randr.GetCrtcGamma
-#define XRRGetCrtcGammaSize _glfw.x11.randr.GetCrtcGammaSize
-#define XRRGetCrtcInfo _glfw.x11.randr.GetCrtcInfo
-#define XRRGetOutputInfo _glfw.x11.randr.GetOutputInfo
-#define XRRGetOutputPrimary _glfw.x11.randr.GetOutputPrimary
-#define XRRGetScreenResourcesCurrent _glfw.x11.randr.GetScreenResourcesCurrent
-#define XRRQueryExtension _glfw.x11.randr.QueryExtension
-#define XRRQueryVersion _glfw.x11.randr.QueryVersion
-#define XRRSelectInput _glfw.x11.randr.SelectInput
-#define XRRSetCrtcConfig _glfw.x11.randr.SetCrtcConfig
-#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
-#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
-
-typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
-typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
-typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
-typedef char* (* PFN_XcursorGetTheme)(Display*);
-typedef int (* PFN_XcursorGetDefaultSize)(Display*);
-typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int);
-#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
-#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
-#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
-#define XcursorGetTheme _glfw.x11.xcursor.GetTheme
-#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize
-#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage
-
-typedef Bool (* PFN_XineramaIsActive)(Display*);
-typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
-typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
-#define XineramaIsActive _glfw.x11.xinerama.IsActive
-#define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension
-#define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens
-
-typedef XID xcb_window_t;
-typedef XID xcb_visualid_t;
-typedef struct xcb_connection_t xcb_connection_t;
-typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
-#define XGetXCBConnection _glfw.x11.x11xcb.GetXCBConnection
-
-typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
-typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
-typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
-typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
-#define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
-#define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
-#define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
-#define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
-
-typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*);
-typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
-#define XIQueryVersion _glfw.x11.xi.QueryVersion
-#define XISelectEvents _glfw.x11.xi.SelectEvents
-
-typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*);
-typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const*);
-#define XRenderQueryExtension _glfw.x11.xrender.QueryExtension
-#define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
-#define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
-
-typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
-typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
-typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
-
-#define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
-#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
-#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
-#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
-
-typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
-typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
-
-typedef struct VkXlibSurfaceCreateInfoKHR
-{
-    VkStructureType             sType;
-    const void*                 pNext;
-    VkXlibSurfaceCreateFlagsKHR flags;
-    Display*                    dpy;
-    Window                      window;
-} VkXlibSurfaceCreateInfoKHR;
-
-typedef struct VkXcbSurfaceCreateInfoKHR
-{
-    VkStructureType             sType;
-    const void*                 pNext;
-    VkXcbSurfaceCreateFlagsKHR  flags;
-    xcb_connection_t*           connection;
-    xcb_window_t                window;
-} VkXcbSurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateXlibSurfaceKHR)(VkInstance,const VkXlibSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice,uint32_t,Display*,VisualID);
-typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
-
-#include "posix_thread.h"
-#include "posix_time.h"
-#include "xkb_unicode.h"
-#include "glx_context.h"
-#if defined(__linux__)
-#include "linux_joystick.h"
-#else
-#include "null_joystick.h"
-#endif
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowX11  x11
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorX11 x11
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorX11  x11
-
-
-// X11-specific per-window data
-//
-typedef struct _GLFWwindowX11
-{
-    Colormap        colormap;
-    Window          handle;
-    Window          parent;
-    XIC             ic;
-
-    GLFWbool        overrideRedirect;
-    GLFWbool        iconified;
-    GLFWbool        maximized;
-
-    // Whether the visual supports framebuffer transparency
-    GLFWbool        transparent;
-
-    // Cached position and size used to filter out duplicate events
-    int             width, height;
-    int             xpos, ypos;
-
-    // The last received cursor position, regardless of source
-    int             lastCursorPosX, lastCursorPosY;
-    // The last position the cursor was warped to by GLFW
-    int             warpCursorPosX, warpCursorPosY;
-
-    // The time of the last KeyPress event per keycode, for discarding
-    // duplicate key events generated for some keys by ibus
-    Time            keyPressTimes[256];
-
-} _GLFWwindowX11;
-
-// X11-specific global data
-//
-typedef struct _GLFWlibraryX11
-{
-    Display*        display;
-    int             screen;
-    Window          root;
-
-    // System content scale
-    float           contentScaleX, contentScaleY;
-    // Helper window for IPC
-    Window          helperWindowHandle;
-    // Invisible cursor for hidden cursor mode
-    Cursor          hiddenCursorHandle;
-    // Context for mapping window XIDs to _GLFWwindow pointers
-    XContext        context;
-    // XIM input method
-    XIM             im;
-    // Most recent error code received by X error handler
-    int             errorCode;
-    // Primary selection string (while the primary selection is owned)
-    char*           primarySelectionString;
-    // Clipboard string (while the selection is owned)
-    char*           clipboardString;
-    // Key name string
-    char            keynames[GLFW_KEY_LAST + 1][5];
-    // X11 keycode to GLFW key LUT
-    short int       keycodes[256];
-    // GLFW key to X11 keycode LUT
-    short int       scancodes[GLFW_KEY_LAST + 1];
-    // Where to place the cursor when re-enabled
-    double          restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*    disabledCursorWindow;
-
-    // Window manager atoms
-    Atom            NET_SUPPORTED;
-    Atom            NET_SUPPORTING_WM_CHECK;
-    Atom            WM_PROTOCOLS;
-    Atom            WM_STATE;
-    Atom            WM_DELETE_WINDOW;
-    Atom            NET_WM_NAME;
-    Atom            NET_WM_ICON_NAME;
-    Atom            NET_WM_ICON;
-    Atom            NET_WM_PID;
-    Atom            NET_WM_PING;
-    Atom            NET_WM_WINDOW_TYPE;
-    Atom            NET_WM_WINDOW_TYPE_NORMAL;
-    Atom            NET_WM_STATE;
-    Atom            NET_WM_STATE_ABOVE;
-    Atom            NET_WM_STATE_FULLSCREEN;
-    Atom            NET_WM_STATE_MAXIMIZED_VERT;
-    Atom            NET_WM_STATE_MAXIMIZED_HORZ;
-    Atom            NET_WM_STATE_DEMANDS_ATTENTION;
-    Atom            NET_WM_BYPASS_COMPOSITOR;
-    Atom            NET_WM_FULLSCREEN_MONITORS;
-    Atom            NET_WM_WINDOW_OPACITY;
-    Atom            NET_WM_CM_Sx;
-    Atom            NET_WORKAREA;
-    Atom            NET_CURRENT_DESKTOP;
-    Atom            NET_ACTIVE_WINDOW;
-    Atom            NET_FRAME_EXTENTS;
-    Atom            NET_REQUEST_FRAME_EXTENTS;
-    Atom            MOTIF_WM_HINTS;
-
-    // Xdnd (drag and drop) atoms
-    Atom            XdndAware;
-    Atom            XdndEnter;
-    Atom            XdndPosition;
-    Atom            XdndStatus;
-    Atom            XdndActionCopy;
-    Atom            XdndDrop;
-    Atom            XdndFinished;
-    Atom            XdndSelection;
-    Atom            XdndTypeList;
-    Atom            text_uri_list;
-
-    // Selection (clipboard) atoms
-    Atom            TARGETS;
-    Atom            MULTIPLE;
-    Atom            INCR;
-    Atom            CLIPBOARD;
-    Atom            PRIMARY;
-    Atom            CLIPBOARD_MANAGER;
-    Atom            SAVE_TARGETS;
-    Atom            NULL_;
-    Atom            UTF8_STRING;
-    Atom            COMPOUND_STRING;
-    Atom            ATOM_PAIR;
-    Atom            GLFW_SELECTION;
-
-    struct {
-        void*       handle;
-        GLFWbool    utf8;
-        PFN_XAllocClassHint AllocClassHint;
-        PFN_XAllocSizeHints AllocSizeHints;
-        PFN_XAllocWMHints AllocWMHints;
-        PFN_XChangeProperty ChangeProperty;
-        PFN_XChangeWindowAttributes ChangeWindowAttributes;
-        PFN_XCheckIfEvent CheckIfEvent;
-        PFN_XCheckTypedWindowEvent CheckTypedWindowEvent;
-        PFN_XCloseDisplay CloseDisplay;
-        PFN_XCloseIM CloseIM;
-        PFN_XConvertSelection ConvertSelection;
-        PFN_XCreateColormap CreateColormap;
-        PFN_XCreateFontCursor CreateFontCursor;
-        PFN_XCreateIC CreateIC;
-        PFN_XCreateRegion CreateRegion;
-        PFN_XCreateWindow CreateWindow;
-        PFN_XDefineCursor DefineCursor;
-        PFN_XDeleteContext DeleteContext;
-        PFN_XDeleteProperty DeleteProperty;
-        PFN_XDestroyIC DestroyIC;
-        PFN_XDestroyRegion DestroyRegion;
-        PFN_XDestroyWindow DestroyWindow;
-        PFN_XDisplayKeycodes DisplayKeycodes;
-        PFN_XEventsQueued EventsQueued;
-        PFN_XFilterEvent FilterEvent;
-        PFN_XFindContext FindContext;
-        PFN_XFlush Flush;
-        PFN_XFree Free;
-        PFN_XFreeColormap FreeColormap;
-        PFN_XFreeCursor FreeCursor;
-        PFN_XFreeEventData FreeEventData;
-        PFN_XGetErrorText GetErrorText;
-        PFN_XGetEventData GetEventData;
-        PFN_XGetICValues GetICValues;
-        PFN_XGetIMValues GetIMValues;
-        PFN_XGetInputFocus GetInputFocus;
-        PFN_XGetKeyboardMapping GetKeyboardMapping;
-        PFN_XGetScreenSaver GetScreenSaver;
-        PFN_XGetSelectionOwner GetSelectionOwner;
-        PFN_XGetVisualInfo GetVisualInfo;
-        PFN_XGetWMNormalHints GetWMNormalHints;
-        PFN_XGetWindowAttributes GetWindowAttributes;
-        PFN_XGetWindowProperty GetWindowProperty;
-        PFN_XGrabPointer GrabPointer;
-        PFN_XIconifyWindow IconifyWindow;
-        PFN_XInitThreads InitThreads;
-        PFN_XInternAtom InternAtom;
-        PFN_XLookupString LookupString;
-        PFN_XMapRaised MapRaised;
-        PFN_XMapWindow MapWindow;
-        PFN_XMoveResizeWindow MoveResizeWindow;
-        PFN_XMoveWindow MoveWindow;
-        PFN_XNextEvent NextEvent;
-        PFN_XOpenDisplay OpenDisplay;
-        PFN_XOpenIM OpenIM;
-        PFN_XPeekEvent PeekEvent;
-        PFN_XPending Pending;
-        PFN_XQueryExtension QueryExtension;
-        PFN_XQueryPointer QueryPointer;
-        PFN_XRaiseWindow RaiseWindow;
-        PFN_XRegisterIMInstantiateCallback RegisterIMInstantiateCallback;
-        PFN_XResizeWindow ResizeWindow;
-        PFN_XResourceManagerString ResourceManagerString;
-        PFN_XSaveContext SaveContext;
-        PFN_XSelectInput SelectInput;
-        PFN_XSendEvent SendEvent;
-        PFN_XSetClassHint SetClassHint;
-        PFN_XSetErrorHandler SetErrorHandler;
-        PFN_XSetICFocus SetICFocus;
-        PFN_XSetIMValues SetIMValues;
-        PFN_XSetInputFocus SetInputFocus;
-        PFN_XSetLocaleModifiers SetLocaleModifiers;
-        PFN_XSetScreenSaver SetScreenSaver;
-        PFN_XSetSelectionOwner SetSelectionOwner;
-        PFN_XSetWMHints SetWMHints;
-        PFN_XSetWMNormalHints SetWMNormalHints;
-        PFN_XSetWMProtocols SetWMProtocols;
-        PFN_XSupportsLocale SupportsLocale;
-        PFN_XSync Sync;
-        PFN_XTranslateCoordinates TranslateCoordinates;
-        PFN_XUndefineCursor UndefineCursor;
-        PFN_XUngrabPointer UngrabPointer;
-        PFN_XUnmapWindow UnmapWindow;
-        PFN_XUnsetICFocus UnsetICFocus;
-        PFN_XVisualIDFromVisual VisualIDFromVisual;
-        PFN_XWarpPointer WarpPointer;
-        PFN_XUnregisterIMInstantiateCallback UnregisterIMInstantiateCallback;
-        PFN_Xutf8LookupString utf8LookupString;
-        PFN_Xutf8SetWMProperties utf8SetWMProperties;
-    } xlib;
-
-    struct {
-        PFN_XrmDestroyDatabase DestroyDatabase;
-        PFN_XrmGetResource GetResource;
-        PFN_XrmGetStringDatabase GetStringDatabase;
-        PFN_XrmInitialize Initialize;
-        PFN_XrmUniqueQuark UniqueQuark;
-    } xrm;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         eventBase;
-        int         errorBase;
-        int         major;
-        int         minor;
-        GLFWbool    gammaBroken;
-        GLFWbool    monitorBroken;
-        PFN_XRRAllocGamma AllocGamma;
-        PFN_XRRFreeCrtcInfo FreeCrtcInfo;
-        PFN_XRRFreeGamma FreeGamma;
-        PFN_XRRFreeOutputInfo FreeOutputInfo;
-        PFN_XRRFreeScreenResources FreeScreenResources;
-        PFN_XRRGetCrtcGamma GetCrtcGamma;
-        PFN_XRRGetCrtcGammaSize GetCrtcGammaSize;
-        PFN_XRRGetCrtcInfo GetCrtcInfo;
-        PFN_XRRGetOutputInfo GetOutputInfo;
-        PFN_XRRGetOutputPrimary GetOutputPrimary;
-        PFN_XRRGetScreenResourcesCurrent GetScreenResourcesCurrent;
-        PFN_XRRQueryExtension QueryExtension;
-        PFN_XRRQueryVersion QueryVersion;
-        PFN_XRRSelectInput SelectInput;
-        PFN_XRRSetCrtcConfig SetCrtcConfig;
-        PFN_XRRSetCrtcGamma SetCrtcGamma;
-        PFN_XRRUpdateConfiguration UpdateConfiguration;
-    } randr;
-
-    struct {
-        GLFWbool     available;
-        GLFWbool     detectable;
-        int          majorOpcode;
-        int          eventBase;
-        int          errorBase;
-        int          major;
-        int          minor;
-        unsigned int group;
-        PFN_XkbFreeKeyboard FreeKeyboard;
-        PFN_XkbFreeNames FreeNames;
-        PFN_XkbGetMap GetMap;
-        PFN_XkbGetNames GetNames;
-        PFN_XkbGetState GetState;
-        PFN_XkbKeycodeToKeysym KeycodeToKeysym;
-        PFN_XkbQueryExtension QueryExtension;
-        PFN_XkbSelectEventDetails SelectEventDetails;
-        PFN_XkbSetDetectableAutoRepeat SetDetectableAutoRepeat;
-    } xkb;
-
-    struct {
-        int         count;
-        int         timeout;
-        int         interval;
-        int         blanking;
-        int         exposure;
-    } saver;
-
-    struct {
-        int         version;
-        Window      source;
-        Atom        format;
-    } xdnd;
-
-    struct {
-        void*       handle;
-        PFN_XcursorImageCreate ImageCreate;
-        PFN_XcursorImageDestroy ImageDestroy;
-        PFN_XcursorImageLoadCursor ImageLoadCursor;
-        PFN_XcursorGetTheme GetTheme;
-        PFN_XcursorGetDefaultSize GetDefaultSize;
-        PFN_XcursorLibraryLoadImage LibraryLoadImage;
-    } xcursor;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        PFN_XineramaIsActive IsActive;
-        PFN_XineramaQueryExtension QueryExtension;
-        PFN_XineramaQueryScreens QueryScreens;
-    } xinerama;
-
-    struct {
-        void*       handle;
-        PFN_XGetXCBConnection GetXCBConnection;
-    } x11xcb;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         eventBase;
-        int         errorBase;
-        PFN_XF86VidModeQueryExtension QueryExtension;
-        PFN_XF86VidModeGetGammaRamp GetGammaRamp;
-        PFN_XF86VidModeSetGammaRamp SetGammaRamp;
-        PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
-    } vidmode;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         majorOpcode;
-        int         eventBase;
-        int         errorBase;
-        int         major;
-        int         minor;
-        PFN_XIQueryVersion QueryVersion;
-        PFN_XISelectEvents SelectEvents;
-    } xi;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        int         eventBase;
-        int         errorBase;
-        PFN_XRenderQueryExtension QueryExtension;
-        PFN_XRenderQueryVersion QueryVersion;
-        PFN_XRenderFindVisualFormat FindVisualFormat;
-    } xrender;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        int         eventBase;
-        int         errorBase;
-        PFN_XShapeQueryExtension QueryExtension;
-        PFN_XShapeCombineRegion ShapeCombineRegion;
-        PFN_XShapeQueryVersion QueryVersion;
-        PFN_XShapeCombineMask ShapeCombineMask;
-    } xshape;
-
-} _GLFWlibraryX11;
-
-// X11-specific per-monitor data
-//
-typedef struct _GLFWmonitorX11
-{
-    RROutput        output;
-    RRCrtc          crtc;
-    RRMode          oldMode;
-
-    // Index of corresponding Xinerama screen,
-    // for EWMH full screen window placement
-    int             index;
-
-} _GLFWmonitorX11;
-
-// X11-specific per-cursor data
-//
-typedef struct _GLFWcursorX11
-{
-    Cursor handle;
-
-} _GLFWcursorX11;
-
-
-void _glfwPollMonitorsX11(void);
-void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
-
-Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
-
-unsigned long _glfwGetWindowPropertyX11(Window window,
-                                        Atom property,
-                                        Atom type,
-                                        unsigned char** value);
-GLFWbool _glfwIsVisualTransparentX11(Visual* visual);
-
-void _glfwGrabErrorHandlerX11(void);
-void _glfwReleaseErrorHandlerX11(void);
-void _glfwInputErrorX11(int error, const char* message);
-
-void _glfwPushSelectionToManagerX11(void);
-void _glfwCreateInputContextX11(_GLFWwindow* window);
-
diff --git a/raylib/external/glfw/src/x11_window.c b/raylib/external/glfw/src/x11_window.c
deleted file mode 100644 (file)
index 4cd3294..0000000
+++ /dev/null
@@ -1,3285 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <X11/cursorfont.h>
-#include <X11/Xmd.h>
-
-#include <sys/select.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <assert.h>
-
-// Action for EWMH client messages
-#define _NET_WM_STATE_REMOVE        0
-#define _NET_WM_STATE_ADD           1
-#define _NET_WM_STATE_TOGGLE        2
-
-// Additional mouse button names for XButtonEvent
-#define Button6            6
-#define Button7            7
-
-// Motif WM hints flags
-#define MWM_HINTS_DECORATIONS   2
-#define MWM_DECOR_ALL           1
-
-#define _GLFW_XDND_VERSION 5
-
-
-// Wait for data to arrive using select
-// This avoids blocking other threads via the per-display Xlib lock that also
-// covers GLX functions
-//
-static GLFWbool waitForEvent(double* timeout)
-{
-    fd_set fds;
-    const int fd = ConnectionNumber(_glfw.x11.display);
-    int count = fd + 1;
-
-#if defined(__linux__)
-    if (_glfw.linjs.inotify > fd)
-        count = _glfw.linjs.inotify + 1;
-#endif
-    for (;;)
-    {
-        FD_ZERO(&fds);
-        FD_SET(fd, &fds);
-#if defined(__linux__)
-        if (_glfw.linjs.inotify > 0)
-            FD_SET(_glfw.linjs.inotify, &fds);
-#endif
-
-        if (timeout)
-        {
-            const long seconds = (long) *timeout;
-            const long microseconds = (long) ((*timeout - seconds) * 1e6);
-            struct timeval tv = { seconds, microseconds };
-            const uint64_t base = _glfwPlatformGetTimerValue();
-
-            const int result = select(count, &fds, NULL, NULL, &tv);
-            const int error = errno;
-
-            *timeout -= (_glfwPlatformGetTimerValue() - base) /
-                (double) _glfwPlatformGetTimerFrequency();
-
-            if (result > 0)
-                return GLFW_TRUE;
-            if ((result == -1 && error == EINTR) || *timeout <= 0.0)
-                return GLFW_FALSE;
-        }
-        else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR)
-            return GLFW_TRUE;
-    }
-}
-
-// Waits until a VisibilityNotify event arrives for the specified window or the
-// timeout period elapses (ICCCM section 4.2.2)
-//
-static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
-{
-    XEvent dummy;
-    double timeout = 0.1;
-
-    while (!XCheckTypedWindowEvent(_glfw.x11.display,
-                                   window->x11.handle,
-                                   VisibilityNotify,
-                                   &dummy))
-    {
-        if (!waitForEvent(&timeout))
-            return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Returns whether the window is iconified
-//
-static int getWindowState(_GLFWwindow* window)
-{
-    int result = WithdrawnState;
-    struct {
-        CARD32 state;
-        Window icon;
-    } *state = NULL;
-
-    if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.WM_STATE,
-                                  _glfw.x11.WM_STATE,
-                                  (unsigned char**) &state) >= 2)
-    {
-        result = state->state;
-    }
-
-    if (state)
-        XFree(state);
-
-    return result;
-}
-
-// Returns whether the event is a selection event
-//
-static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
-{
-    if (event->xany.window != _glfw.x11.helperWindowHandle)
-        return False;
-
-    return event->type == SelectionRequest ||
-           event->type == SelectionNotify ||
-           event->type == SelectionClear;
-}
-
-// Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
-//
-static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
-{
-    _GLFWwindow* window = (_GLFWwindow*) pointer;
-    return event->type == PropertyNotify &&
-           event->xproperty.state == PropertyNewValue &&
-           event->xproperty.window == window->x11.handle &&
-           event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;
-}
-
-// Returns whether it is a property event for the specified selection transfer
-//
-static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer)
-{
-    XEvent* notification = (XEvent*) pointer;
-    return event->type == PropertyNotify &&
-           event->xproperty.state == PropertyNewValue &&
-           event->xproperty.window == notification->xselection.requestor &&
-           event->xproperty.atom == notification->xselection.property;
-}
-
-// Translates an X event modifier state mask
-//
-static int translateState(int state)
-{
-    int mods = 0;
-
-    if (state & ShiftMask)
-        mods |= GLFW_MOD_SHIFT;
-    if (state & ControlMask)
-        mods |= GLFW_MOD_CONTROL;
-    if (state & Mod1Mask)
-        mods |= GLFW_MOD_ALT;
-    if (state & Mod4Mask)
-        mods |= GLFW_MOD_SUPER;
-    if (state & LockMask)
-        mods |= GLFW_MOD_CAPS_LOCK;
-    if (state & Mod2Mask)
-        mods |= GLFW_MOD_NUM_LOCK;
-
-    return mods;
-}
-
-// Translates an X11 key code to a GLFW key token
-//
-static int translateKey(int scancode)
-{
-    // Use the pre-filled LUT (see createKeyTables() in x11_init.c)
-    if (scancode < 0 || scancode > 255)
-        return GLFW_KEY_UNKNOWN;
-
-    return _glfw.x11.keycodes[scancode];
-}
-
-// Sends an EWMH or ICCCM event to the window manager
-//
-static void sendEventToWM(_GLFWwindow* window, Atom type,
-                          long a, long b, long c, long d, long e)
-{
-    XEvent event = { ClientMessage };
-    event.xclient.window = window->x11.handle;
-    event.xclient.format = 32; // Data is 32-bit longs
-    event.xclient.message_type = type;
-    event.xclient.data.l[0] = a;
-    event.xclient.data.l[1] = b;
-    event.xclient.data.l[2] = c;
-    event.xclient.data.l[3] = d;
-    event.xclient.data.l[4] = e;
-
-    XSendEvent(_glfw.x11.display, _glfw.x11.root,
-               False,
-               SubstructureNotifyMask | SubstructureRedirectMask,
-               &event);
-}
-
-// Updates the normal hints according to the window settings
-//
-static void updateNormalHints(_GLFWwindow* window, int width, int height)
-{
-    XSizeHints* hints = XAllocSizeHints();
-
-    if (!window->monitor)
-    {
-        if (window->resizable)
-        {
-            if (window->minwidth != GLFW_DONT_CARE &&
-                window->minheight != GLFW_DONT_CARE)
-            {
-                hints->flags |= PMinSize;
-                hints->min_width = window->minwidth;
-                hints->min_height = window->minheight;
-            }
-
-            if (window->maxwidth != GLFW_DONT_CARE &&
-                window->maxheight != GLFW_DONT_CARE)
-            {
-                hints->flags |= PMaxSize;
-                hints->max_width = window->maxwidth;
-                hints->max_height = window->maxheight;
-            }
-
-            if (window->numer != GLFW_DONT_CARE &&
-                window->denom != GLFW_DONT_CARE)
-            {
-                hints->flags |= PAspect;
-                hints->min_aspect.x = hints->max_aspect.x = window->numer;
-                hints->min_aspect.y = hints->max_aspect.y = window->denom;
-            }
-        }
-        else
-        {
-            hints->flags |= (PMinSize | PMaxSize);
-            hints->min_width  = hints->max_width  = width;
-            hints->min_height = hints->max_height = height;
-        }
-    }
-
-    hints->flags |= PWinGravity;
-    hints->win_gravity = StaticGravity;
-
-    XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
-    XFree(hints);
-}
-
-// Updates the full screen status of the window
-//
-static void updateWindowMode(_GLFWwindow* window)
-{
-    if (window->monitor)
-    {
-        if (_glfw.x11.xinerama.available &&
-            _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_FULLSCREEN_MONITORS,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          0);
-        }
-
-        if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_ADD,
-                          _glfw.x11.NET_WM_STATE_FULLSCREEN,
-                          0, 1, 0);
-        }
-        else
-        {
-            // This is the butcher's way of removing window decorations
-            // Setting the override-redirect attribute on a window makes the
-            // window manager ignore the window completely (ICCCM, section 4)
-            // The good thing is that this makes undecorated full screen windows
-            // easy to do; the bad thing is that we have to do everything
-            // manually and some things (like iconify/restore) won't work at
-            // all, as those are tasks usually performed by the window manager
-
-            XSetWindowAttributes attributes;
-            attributes.override_redirect = True;
-            XChangeWindowAttributes(_glfw.x11.display,
-                                    window->x11.handle,
-                                    CWOverrideRedirect,
-                                    &attributes);
-
-            window->x11.overrideRedirect = GLFW_TRUE;
-        }
-
-        // Enable compositor bypass
-        if (!window->x11.transparent)
-        {
-            const unsigned long value = 1;
-
-            XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                            _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
-                            PropModeReplace, (unsigned char*) &value, 1);
-        }
-    }
-    else
-    {
-        if (_glfw.x11.xinerama.available &&
-            _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
-        {
-            XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_FULLSCREEN_MONITORS);
-        }
-
-        if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_REMOVE,
-                          _glfw.x11.NET_WM_STATE_FULLSCREEN,
-                          0, 1, 0);
-        }
-        else
-        {
-            XSetWindowAttributes attributes;
-            attributes.override_redirect = False;
-            XChangeWindowAttributes(_glfw.x11.display,
-                                    window->x11.handle,
-                                    CWOverrideRedirect,
-                                    &attributes);
-
-            window->x11.overrideRedirect = GLFW_FALSE;
-        }
-
-        // Disable compositor bypass
-        if (!window->x11.transparent)
-        {
-            XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_BYPASS_COMPOSITOR);
-        }
-    }
-}
-
-// Splits and translates a text/uri-list into separate file paths
-// NOTE: This function destroys the provided string
-//
-static char** parseUriList(char* text, int* count)
-{
-    const char* prefix = "file://";
-    char** paths = NULL;
-    char* line;
-
-    *count = 0;
-
-    while ((line = strtok(text, "\r\n")))
-    {
-        text = NULL;
-
-        if (line[0] == '#')
-            continue;
-
-        if (strncmp(line, prefix, strlen(prefix)) == 0)
-        {
-            line += strlen(prefix);
-            // TODO: Validate hostname
-            while (*line != '/')
-                line++;
-        }
-
-        (*count)++;
-
-        char* path = calloc(strlen(line) + 1, 1);
-        paths = realloc(paths, *count * sizeof(char*));
-        paths[*count - 1] = path;
-
-        while (*line)
-        {
-            if (line[0] == '%' && line[1] && line[2])
-            {
-                const char digits[3] = { line[1], line[2], '\0' };
-                *path = strtol(digits, NULL, 16);
-                line += 2;
-            }
-            else
-                *path = *line;
-
-            path++;
-            line++;
-        }
-    }
-
-    return paths;
-}
-
-// Encode a Unicode code point to a UTF-8 stream
-// Based on cutef8 by Jeff Bezanson (Public Domain)
-//
-static size_t encodeUTF8(char* s, unsigned int ch)
-{
-    size_t count = 0;
-
-    if (ch < 0x80)
-        s[count++] = (char) ch;
-    else if (ch < 0x800)
-    {
-        s[count++] = (ch >> 6) | 0xc0;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-    else if (ch < 0x10000)
-    {
-        s[count++] = (ch >> 12) | 0xe0;
-        s[count++] = ((ch >> 6) & 0x3f) | 0x80;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-    else if (ch < 0x110000)
-    {
-        s[count++] = (ch >> 18) | 0xf0;
-        s[count++] = ((ch >> 12) & 0x3f) | 0x80;
-        s[count++] = ((ch >> 6) & 0x3f) | 0x80;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-
-    return count;
-}
-
-// Decode a Unicode code point from a UTF-8 stream
-// Based on cutef8 by Jeff Bezanson (Public Domain)
-//
-static unsigned int decodeUTF8(const char** s)
-{
-    unsigned int ch = 0, count = 0;
-    static const unsigned int offsets[] =
-    {
-        0x00000000u, 0x00003080u, 0x000e2080u,
-        0x03c82080u, 0xfa082080u, 0x82082080u
-    };
-
-    do
-    {
-        ch = (ch << 6) + (unsigned char) **s;
-        (*s)++;
-        count++;
-    } while ((**s & 0xc0) == 0x80);
-
-    assert(count <= 6);
-    return ch - offsets[count - 1];
-}
-
-// Convert the specified Latin-1 string to UTF-8
-//
-static char* convertLatin1toUTF8(const char* source)
-{
-    size_t size = 1;
-    const char* sp;
-
-    for (sp = source;  *sp;  sp++)
-        size += (*sp & 0x80) ? 2 : 1;
-
-    char* target = calloc(size, 1);
-    char* tp = target;
-
-    for (sp = source;  *sp;  sp++)
-        tp += encodeUTF8(tp, *sp);
-
-    return target;
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (window->cursor)
-        {
-            XDefineCursor(_glfw.x11.display, window->x11.handle,
-                          window->cursor->x11.handle);
-        }
-        else
-            XUndefineCursor(_glfw.x11.display, window->x11.handle);
-    }
-    else
-    {
-        XDefineCursor(_glfw.x11.display, window->x11.handle,
-                      _glfw.x11.hiddenCursorHandle);
-    }
-}
-
-// Enable XI2 raw mouse motion events
-//
-static void enableRawMouseMotion(_GLFWwindow* window)
-{
-    XIEventMask em;
-    unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
-
-    em.deviceid = XIAllMasterDevices;
-    em.mask_len = sizeof(mask);
-    em.mask = mask;
-    XISetMask(mask, XI_RawMotion);
-
-    XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
-}
-
-// Disable XI2 raw mouse motion events
-//
-static void disableRawMouseMotion(_GLFWwindow* window)
-{
-    XIEventMask em;
-    unsigned char mask[] = { 0 };
-
-    em.deviceid = XIAllMasterDevices;
-    em.mask_len = sizeof(mask);
-    em.mask = mask;
-
-    XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
-}
-
-// Apply disabled cursor mode to a focused window
-//
-static void disableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        enableRawMouseMotion(window);
-
-    _glfw.x11.disabledCursorWindow = window;
-    _glfwPlatformGetCursorPos(window,
-                              &_glfw.x11.restoreCursorPosX,
-                              &_glfw.x11.restoreCursorPosY);
-    updateCursorImage(window);
-    _glfwCenterCursorInContentArea(window);
-    XGrabPointer(_glfw.x11.display, window->x11.handle, True,
-                 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
-                 GrabModeAsync, GrabModeAsync,
-                 window->x11.handle,
-                 _glfw.x11.hiddenCursorHandle,
-                 CurrentTime);
-}
-
-// Exit disabled cursor mode for the specified window
-//
-static void enableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        disableRawMouseMotion(window);
-
-    _glfw.x11.disabledCursorWindow = NULL;
-    XUngrabPointer(_glfw.x11.display, CurrentTime);
-    _glfwPlatformSetCursorPos(window,
-                              _glfw.x11.restoreCursorPosX,
-                              _glfw.x11.restoreCursorPosY);
-    updateCursorImage(window);
-}
-
-// Clear its handle when the input context has been destroyed
-//
-static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData)
-{
-    _GLFWwindow* window = (_GLFWwindow*) clientData;
-    window->x11.ic = NULL;
-}
-
-// Create the X11 window (and its colormap)
-//
-static GLFWbool createNativeWindow(_GLFWwindow* window,
-                                   const _GLFWwndconfig* wndconfig,
-                                   Visual* visual, int depth)
-{
-    int width = wndconfig->width;
-    int height = wndconfig->height;
-
-    if (wndconfig->scaleToMonitor)
-    {
-        width *= _glfw.x11.contentScaleX;
-        height *= _glfw.x11.contentScaleY;
-    }
-
-    // Create a colormap based on the visual used by the current context
-    window->x11.colormap = XCreateColormap(_glfw.x11.display,
-                                           _glfw.x11.root,
-                                           visual,
-                                           AllocNone);
-
-    window->x11.transparent = _glfwIsVisualTransparentX11(visual);
-
-    XSetWindowAttributes wa = { 0 };
-    wa.colormap = window->x11.colormap;
-    wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
-                    PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
-                    ExposureMask | FocusChangeMask | VisibilityChangeMask |
-                    EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
-
-    _glfwGrabErrorHandlerX11();
-
-    window->x11.parent = _glfw.x11.root;
-    window->x11.handle = XCreateWindow(_glfw.x11.display,
-                                       _glfw.x11.root,
-                                       0, 0,   // Position
-                                       width, height,
-                                       0,      // Border width
-                                       depth,  // Color depth
-                                       InputOutput,
-                                       visual,
-                                       CWBorderPixel | CWColormap | CWEventMask,
-                                       &wa);
-
-    _glfwReleaseErrorHandlerX11();
-
-    if (!window->x11.handle)
-    {
-        _glfwInputErrorX11(GLFW_PLATFORM_ERROR,
-                           "X11: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    XSaveContext(_glfw.x11.display,
-                 window->x11.handle,
-                 _glfw.x11.context,
-                 (XPointer) window);
-
-    if (!wndconfig->decorated)
-        _glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
-
-    if (_glfw.x11.NET_WM_STATE && !window->monitor)
-    {
-        Atom states[3];
-        int count = 0;
-
-        if (wndconfig->floating)
-        {
-            if (_glfw.x11.NET_WM_STATE_ABOVE)
-                states[count++] = _glfw.x11.NET_WM_STATE_ABOVE;
-        }
-
-        if (wndconfig->maximized)
-        {
-            if (_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
-                _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-            {
-                states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
-                states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
-                window->x11.maximized = GLFW_TRUE;
-            }
-        }
-
-        if (count)
-        {
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeReplace, (unsigned char*) states, count);
-        }
-    }
-
-    // Declare the WM protocols supported by GLFW
-    {
-        Atom protocols[] =
-        {
-            _glfw.x11.WM_DELETE_WINDOW,
-            _glfw.x11.NET_WM_PING
-        };
-
-        XSetWMProtocols(_glfw.x11.display, window->x11.handle,
-                        protocols, sizeof(protocols) / sizeof(Atom));
-    }
-
-    // Declare our PID
-    {
-        const long pid = getpid();
-
-        XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                        _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,
-                        PropModeReplace,
-                        (unsigned char*) &pid, 1);
-    }
-
-    if (_glfw.x11.NET_WM_WINDOW_TYPE && _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL)
-    {
-        Atom type = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL;
-        XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                        _glfw.x11.NET_WM_WINDOW_TYPE, XA_ATOM, 32,
-                        PropModeReplace, (unsigned char*) &type, 1);
-    }
-
-    // Set ICCCM WM_HINTS property
-    {
-        XWMHints* hints = XAllocWMHints();
-        if (!hints)
-        {
-            _glfwInputError(GLFW_OUT_OF_MEMORY,
-                            "X11: Failed to allocate WM hints");
-            return GLFW_FALSE;
-        }
-
-        hints->flags = StateHint;
-        hints->initial_state = NormalState;
-
-        XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
-        XFree(hints);
-    }
-
-    updateNormalHints(window, width, height);
-
-    // Set ICCCM WM_CLASS property
-    {
-        XClassHint* hint = XAllocClassHint();
-
-        if (strlen(wndconfig->x11.instanceName) &&
-            strlen(wndconfig->x11.className))
-        {
-            hint->res_name = (char*) wndconfig->x11.instanceName;
-            hint->res_class = (char*) wndconfig->x11.className;
-        }
-        else
-        {
-            const char* resourceName = getenv("RESOURCE_NAME");
-            if (resourceName && strlen(resourceName))
-                hint->res_name = (char*) resourceName;
-            else if (strlen(wndconfig->title))
-                hint->res_name = (char*) wndconfig->title;
-            else
-                hint->res_name = (char*) "glfw-application";
-
-            if (strlen(wndconfig->title))
-                hint->res_class = (char*) wndconfig->title;
-            else
-                hint->res_class = (char*) "GLFW-Application";
-        }
-
-        XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
-        XFree(hint);
-    }
-
-    // Announce support for Xdnd (drag and drop)
-    {
-        const Atom version = _GLFW_XDND_VERSION;
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.XdndAware, XA_ATOM, 32,
-                        PropModeReplace, (unsigned char*) &version, 1);
-    }
-
-    if (_glfw.x11.im)
-        _glfwCreateInputContextX11(window);
-
-    _glfwPlatformSetWindowTitle(window, wndconfig->title);
-    _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
-    _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
-
-    return GLFW_TRUE;
-}
-
-// Set the specified property to the selection converted to the requested target
-//
-static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
-{
-    int i;
-    char* selectionString = NULL;
-    const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
-    const int formatCount = sizeof(formats) / sizeof(formats[0]);
-
-    if (request->selection == _glfw.x11.PRIMARY)
-        selectionString = _glfw.x11.primarySelectionString;
-    else
-        selectionString = _glfw.x11.clipboardString;
-
-    if (request->property == None)
-    {
-        // The requester is a legacy client (ICCCM section 2.2)
-        // We don't support legacy clients, so fail here
-        return None;
-    }
-
-    if (request->target == _glfw.x11.TARGETS)
-    {
-        // The list of supported targets was requested
-
-        const Atom targets[] = { _glfw.x11.TARGETS,
-                                 _glfw.x11.MULTIPLE,
-                                 _glfw.x11.UTF8_STRING,
-                                 XA_STRING };
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        XA_ATOM,
-                        32,
-                        PropModeReplace,
-                        (unsigned char*) targets,
-                        sizeof(targets) / sizeof(targets[0]));
-
-        return request->property;
-    }
-
-    if (request->target == _glfw.x11.MULTIPLE)
-    {
-        // Multiple conversions were requested
-
-        Atom* targets;
-        unsigned long i, count;
-
-        count = _glfwGetWindowPropertyX11(request->requestor,
-                                          request->property,
-                                          _glfw.x11.ATOM_PAIR,
-                                          (unsigned char**) &targets);
-
-        for (i = 0;  i < count;  i += 2)
-        {
-            int j;
-
-            for (j = 0;  j < formatCount;  j++)
-            {
-                if (targets[i] == formats[j])
-                    break;
-            }
-
-            if (j < formatCount)
-            {
-                XChangeProperty(_glfw.x11.display,
-                                request->requestor,
-                                targets[i + 1],
-                                targets[i],
-                                8,
-                                PropModeReplace,
-                                (unsigned char *) selectionString,
-                                strlen(selectionString));
-            }
-            else
-                targets[i + 1] = None;
-        }
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        _glfw.x11.ATOM_PAIR,
-                        32,
-                        PropModeReplace,
-                        (unsigned char*) targets,
-                        count);
-
-        XFree(targets);
-
-        return request->property;
-    }
-
-    if (request->target == _glfw.x11.SAVE_TARGETS)
-    {
-        // The request is a check whether we support SAVE_TARGETS
-        // It should be handled as a no-op side effect target
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        _glfw.x11.NULL_,
-                        32,
-                        PropModeReplace,
-                        NULL,
-                        0);
-
-        return request->property;
-    }
-
-    // Conversion to a data target was requested
-
-    for (i = 0;  i < formatCount;  i++)
-    {
-        if (request->target == formats[i])
-        {
-            // The requested target is one we support
-
-            XChangeProperty(_glfw.x11.display,
-                            request->requestor,
-                            request->property,
-                            request->target,
-                            8,
-                            PropModeReplace,
-                            (unsigned char *) selectionString,
-                            strlen(selectionString));
-
-            return request->property;
-        }
-    }
-
-    // The requested target is not supported
-
-    return None;
-}
-
-static void handleSelectionClear(XEvent* event)
-{
-    if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
-    {
-        free(_glfw.x11.primarySelectionString);
-        _glfw.x11.primarySelectionString = NULL;
-    }
-    else
-    {
-        free(_glfw.x11.clipboardString);
-        _glfw.x11.clipboardString = NULL;
-    }
-}
-
-static void handleSelectionRequest(XEvent* event)
-{
-    const XSelectionRequestEvent* request = &event->xselectionrequest;
-
-    XEvent reply = { SelectionNotify };
-    reply.xselection.property = writeTargetToProperty(request);
-    reply.xselection.display = request->display;
-    reply.xselection.requestor = request->requestor;
-    reply.xselection.selection = request->selection;
-    reply.xselection.target = request->target;
-    reply.xselection.time = request->time;
-
-    XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
-}
-
-static const char* getSelectionString(Atom selection)
-{
-    char** selectionString = NULL;
-    const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
-    const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
-
-    if (selection == _glfw.x11.PRIMARY)
-        selectionString = &_glfw.x11.primarySelectionString;
-    else
-        selectionString = &_glfw.x11.clipboardString;
-
-    if (XGetSelectionOwner(_glfw.x11.display, selection) ==
-        _glfw.x11.helperWindowHandle)
-    {
-        // Instead of doing a large number of X round-trips just to put this
-        // string into a window property and then read it back, just return it
-        return *selectionString;
-    }
-
-    free(*selectionString);
-    *selectionString = NULL;
-
-    for (size_t i = 0;  i < targetCount;  i++)
-    {
-        char* data;
-        Atom actualType;
-        int actualFormat;
-        unsigned long itemCount, bytesAfter;
-        XEvent notification, dummy;
-
-        XConvertSelection(_glfw.x11.display,
-                          selection,
-                          targets[i],
-                          _glfw.x11.GLFW_SELECTION,
-                          _glfw.x11.helperWindowHandle,
-                          CurrentTime);
-
-        while (!XCheckTypedWindowEvent(_glfw.x11.display,
-                                       _glfw.x11.helperWindowHandle,
-                                       SelectionNotify,
-                                       &notification))
-        {
-            waitForEvent(NULL);
-        }
-
-        if (notification.xselection.property == None)
-            continue;
-
-        XCheckIfEvent(_glfw.x11.display,
-                      &dummy,
-                      isSelPropNewValueNotify,
-                      (XPointer) &notification);
-
-        XGetWindowProperty(_glfw.x11.display,
-                           notification.xselection.requestor,
-                           notification.xselection.property,
-                           0,
-                           LONG_MAX,
-                           True,
-                           AnyPropertyType,
-                           &actualType,
-                           &actualFormat,
-                           &itemCount,
-                           &bytesAfter,
-                           (unsigned char**) &data);
-
-        if (actualType == _glfw.x11.INCR)
-        {
-            size_t size = 1;
-            char* string = NULL;
-
-            for (;;)
-            {
-                while (!XCheckIfEvent(_glfw.x11.display,
-                                      &dummy,
-                                      isSelPropNewValueNotify,
-                                      (XPointer) &notification))
-                {
-                    waitForEvent(NULL);
-                }
-
-                XFree(data);
-                XGetWindowProperty(_glfw.x11.display,
-                                   notification.xselection.requestor,
-                                   notification.xselection.property,
-                                   0,
-                                   LONG_MAX,
-                                   True,
-                                   AnyPropertyType,
-                                   &actualType,
-                                   &actualFormat,
-                                   &itemCount,
-                                   &bytesAfter,
-                                   (unsigned char**) &data);
-
-                if (itemCount)
-                {
-                    size += itemCount;
-                    string = realloc(string, size);
-                    string[size - itemCount - 1] = '\0';
-                    strcat(string, data);
-                }
-
-                if (!itemCount)
-                {
-                    if (targets[i] == XA_STRING)
-                    {
-                        *selectionString = convertLatin1toUTF8(string);
-                        free(string);
-                    }
-                    else
-                        *selectionString = string;
-
-                    break;
-                }
-            }
-        }
-        else if (actualType == targets[i])
-        {
-            if (targets[i] == XA_STRING)
-                *selectionString = convertLatin1toUTF8(data);
-            else
-                *selectionString = _glfw_strdup(data);
-        }
-
-        XFree(data);
-
-        if (*selectionString)
-            break;
-    }
-
-    if (!*selectionString)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "X11: Failed to convert selection to string");
-    }
-
-    return *selectionString;
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    if (_glfw.x11.saver.count == 0)
-    {
-        // Remember old screen saver settings
-        XGetScreenSaver(_glfw.x11.display,
-                        &_glfw.x11.saver.timeout,
-                        &_glfw.x11.saver.interval,
-                        &_glfw.x11.saver.blanking,
-                        &_glfw.x11.saver.exposure);
-
-        // Disable screen saver
-        XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
-                        DefaultExposures);
-    }
-
-    if (!window->monitor->window)
-        _glfw.x11.saver.count++;
-
-    _glfwSetVideoModeX11(window->monitor, &window->videoMode);
-
-    if (window->x11.overrideRedirect)
-    {
-        int xpos, ypos;
-        GLFWvidmode mode;
-
-        // Manually position the window over its monitor
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-
-        XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                          xpos, ypos, mode.width, mode.height);
-    }
-
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeX11(window->monitor);
-
-    _glfw.x11.saver.count--;
-
-    if (_glfw.x11.saver.count == 0)
-    {
-        // Restore old screen saver settings
-        XSetScreenSaver(_glfw.x11.display,
-                        _glfw.x11.saver.timeout,
-                        _glfw.x11.saver.interval,
-                        _glfw.x11.saver.blanking,
-                        _glfw.x11.saver.exposure);
-    }
-}
-
-// Process the specified X event
-//
-static void processEvent(XEvent *event)
-{
-    int keycode = 0;
-    Bool filtered = False;
-
-    // HACK: Save scancode as some IMs clear the field in XFilterEvent
-    if (event->type == KeyPress || event->type == KeyRelease)
-        keycode = event->xkey.keycode;
-
-    filtered = XFilterEvent(event, None);
-
-    if (_glfw.x11.randr.available)
-    {
-        if (event->type == _glfw.x11.randr.eventBase + RRNotify)
-        {
-            XRRUpdateConfiguration(event);
-            _glfwPollMonitorsX11();
-            return;
-        }
-    }
-
-    if (_glfw.x11.xkb.available)
-    {
-        if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
-        {
-            if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
-                (((XkbEvent*) event)->state.changed & XkbGroupStateMask))
-            {
-                _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
-            }
-
-            return;
-        }
-    }
-
-    if (event->type == GenericEvent)
-    {
-        if (_glfw.x11.xi.available)
-        {
-            _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
-
-            if (window &&
-                window->rawMouseMotion &&
-                event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
-                XGetEventData(_glfw.x11.display, &event->xcookie) &&
-                event->xcookie.evtype == XI_RawMotion)
-            {
-                XIRawEvent* re = event->xcookie.data;
-                if (re->valuators.mask_len)
-                {
-                    const double* values = re->raw_values;
-                    double xpos = window->virtualCursorPosX;
-                    double ypos = window->virtualCursorPosY;
-
-                    if (XIMaskIsSet(re->valuators.mask, 0))
-                    {
-                        xpos += *values;
-                        values++;
-                    }
-
-                    if (XIMaskIsSet(re->valuators.mask, 1))
-                        ypos += *values;
-
-                    _glfwInputCursorPos(window, xpos, ypos);
-                }
-            }
-
-            XFreeEventData(_glfw.x11.display, &event->xcookie);
-        }
-
-        return;
-    }
-
-    if (event->type == SelectionClear)
-    {
-        handleSelectionClear(event);
-        return;
-    }
-    else if (event->type == SelectionRequest)
-    {
-        handleSelectionRequest(event);
-        return;
-    }
-
-    _GLFWwindow* window = NULL;
-    if (XFindContext(_glfw.x11.display,
-                     event->xany.window,
-                     _glfw.x11.context,
-                     (XPointer*) &window) != 0)
-    {
-        // This is an event for a window that has already been destroyed
-        return;
-    }
-
-    switch (event->type)
-    {
-        case ReparentNotify:
-        {
-            window->x11.parent = event->xreparent.parent;
-            return;
-        }
-
-        case KeyPress:
-        {
-            const int key = translateKey(keycode);
-            const int mods = translateState(event->xkey.state);
-            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
-
-            if (window->x11.ic)
-            {
-                // HACK: Do not report the key press events duplicated by XIM
-                //       Duplicate key releases are filtered out implicitly by
-                //       the GLFW key repeat logic in _glfwInputKey
-                //       A timestamp per key is used to handle simultaneous keys
-                // NOTE: Always allow the first event for each key through
-                //       (the server never sends a timestamp of zero)
-                // NOTE: Timestamp difference is compared to handle wrap-around
-                Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
-                if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31)))
-                {
-                    if (keycode)
-                        _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
-
-                    window->x11.keyPressTimes[keycode] = event->xkey.time;
-                }
-
-                if (!filtered)
-                {
-                    int count;
-                    Status status;
-                    char buffer[100];
-                    char* chars = buffer;
-
-                    count = Xutf8LookupString(window->x11.ic,
-                                              &event->xkey,
-                                              buffer, sizeof(buffer) - 1,
-                                              NULL, &status);
-
-                    if (status == XBufferOverflow)
-                    {
-                        chars = calloc(count + 1, 1);
-                        count = Xutf8LookupString(window->x11.ic,
-                                                  &event->xkey,
-                                                  chars, count,
-                                                  NULL, &status);
-                    }
-
-                    if (status == XLookupChars || status == XLookupBoth)
-                    {
-                        const char* c = chars;
-                        chars[count] = '\0';
-                        while (c - chars < count)
-                            _glfwInputChar(window, decodeUTF8(&c), mods, plain);
-                    }
-
-                    if (chars != buffer)
-                        free(chars);
-                }
-            }
-            else
-            {
-                KeySym keysym;
-                XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
-
-                _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
-
-                const long character = _glfwKeySym2Unicode(keysym);
-                if (character != -1)
-                    _glfwInputChar(window, character, mods, plain);
-            }
-
-            return;
-        }
-
-        case KeyRelease:
-        {
-            const int key = translateKey(keycode);
-            const int mods = translateState(event->xkey.state);
-
-            if (!_glfw.x11.xkb.detectable)
-            {
-                // HACK: Key repeat events will arrive as KeyRelease/KeyPress
-                //       pairs with similar or identical time stamps
-                //       The key repeat logic in _glfwInputKey expects only key
-                //       presses to repeat, so detect and discard release events
-                if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
-                {
-                    XEvent next;
-                    XPeekEvent(_glfw.x11.display, &next);
-
-                    if (next.type == KeyPress &&
-                        next.xkey.window == event->xkey.window &&
-                        next.xkey.keycode == keycode)
-                    {
-                        // HACK: The time of repeat events sometimes doesn't
-                        //       match that of the press event, so add an
-                        //       epsilon
-                        //       Toshiyuki Takahashi can press a button
-                        //       16 times per second so it's fairly safe to
-                        //       assume that no human is pressing the key 50
-                        //       times per second (value is ms)
-                        if ((next.xkey.time - event->xkey.time) < 20)
-                        {
-                            // This is very likely a server-generated key repeat
-                            // event, so ignore it
-                            return;
-                        }
-                    }
-                }
-            }
-
-            _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);
-            return;
-        }
-
-        case ButtonPress:
-        {
-            const int mods = translateState(event->xbutton.state);
-
-            if (event->xbutton.button == Button1)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
-            else if (event->xbutton.button == Button2)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
-            else if (event->xbutton.button == Button3)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
-
-            // Modern X provides scroll events as mouse button presses
-            else if (event->xbutton.button == Button4)
-                _glfwInputScroll(window, 0.0, 1.0);
-            else if (event->xbutton.button == Button5)
-                _glfwInputScroll(window, 0.0, -1.0);
-            else if (event->xbutton.button == Button6)
-                _glfwInputScroll(window, 1.0, 0.0);
-            else if (event->xbutton.button == Button7)
-                _glfwInputScroll(window, -1.0, 0.0);
-
-            else
-            {
-                // Additional buttons after 7 are treated as regular buttons
-                // We subtract 4 to fill the gap left by scroll input above
-                _glfwInputMouseClick(window,
-                                     event->xbutton.button - Button1 - 4,
-                                     GLFW_PRESS,
-                                     mods);
-            }
-
-            return;
-        }
-
-        case ButtonRelease:
-        {
-            const int mods = translateState(event->xbutton.state);
-
-            if (event->xbutton.button == Button1)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_LEFT,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button == Button2)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_MIDDLE,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button == Button3)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_RIGHT,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button > Button7)
-            {
-                // Additional buttons after 7 are treated as regular buttons
-                // We subtract 4 to fill the gap left by scroll input above
-                _glfwInputMouseClick(window,
-                                     event->xbutton.button - Button1 - 4,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-
-            return;
-        }
-
-        case EnterNotify:
-        {
-            // XEnterWindowEvent is XCrossingEvent
-            const int x = event->xcrossing.x;
-            const int y = event->xcrossing.y;
-
-            // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
-            //       ignore the defined cursor for hidden cursor mode
-            if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-                updateCursorImage(window);
-
-            _glfwInputCursorEnter(window, GLFW_TRUE);
-            _glfwInputCursorPos(window, x, y);
-
-            window->x11.lastCursorPosX = x;
-            window->x11.lastCursorPosY = y;
-            return;
-        }
-
-        case LeaveNotify:
-        {
-            _glfwInputCursorEnter(window, GLFW_FALSE);
-            return;
-        }
-
-        case MotionNotify:
-        {
-            const int x = event->xmotion.x;
-            const int y = event->xmotion.y;
-
-            if (x != window->x11.warpCursorPosX ||
-                y != window->x11.warpCursorPosY)
-            {
-                // The cursor was moved by something other than GLFW
-
-                if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                {
-                    if (_glfw.x11.disabledCursorWindow != window)
-                        return;
-                    if (window->rawMouseMotion)
-                        return;
-
-                    const int dx = x - window->x11.lastCursorPosX;
-                    const int dy = y - window->x11.lastCursorPosY;
-
-                    _glfwInputCursorPos(window,
-                                        window->virtualCursorPosX + dx,
-                                        window->virtualCursorPosY + dy);
-                }
-                else
-                    _glfwInputCursorPos(window, x, y);
-            }
-
-            window->x11.lastCursorPosX = x;
-            window->x11.lastCursorPosY = y;
-            return;
-        }
-
-        case ConfigureNotify:
-        {
-            if (event->xconfigure.width != window->x11.width ||
-                event->xconfigure.height != window->x11.height)
-            {
-                _glfwInputFramebufferSize(window,
-                                          event->xconfigure.width,
-                                          event->xconfigure.height);
-
-                _glfwInputWindowSize(window,
-                                     event->xconfigure.width,
-                                     event->xconfigure.height);
-
-                window->x11.width = event->xconfigure.width;
-                window->x11.height = event->xconfigure.height;
-            }
-
-            int xpos = event->xconfigure.x;
-            int ypos = event->xconfigure.y;
-
-            // NOTE: ConfigureNotify events from the server are in local
-            //       coordinates, so if we are reparented we need to translate
-            //       the position into root (screen) coordinates
-            if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
-            {
-                _glfwGrabErrorHandlerX11();
-
-                Window dummy;
-                XTranslateCoordinates(_glfw.x11.display,
-                                      window->x11.parent,
-                                      _glfw.x11.root,
-                                      xpos, ypos,
-                                      &xpos, &ypos,
-                                      &dummy);
-
-                _glfwReleaseErrorHandlerX11();
-                if (_glfw.x11.errorCode == BadWindow)
-                    return;
-            }
-
-            if (xpos != window->x11.xpos || ypos != window->x11.ypos)
-            {
-                _glfwInputWindowPos(window, xpos, ypos);
-                window->x11.xpos = xpos;
-                window->x11.ypos = ypos;
-            }
-
-            return;
-        }
-
-        case ClientMessage:
-        {
-            // Custom client message, probably from the window manager
-
-            if (filtered)
-                return;
-
-            if (event->xclient.message_type == None)
-                return;
-
-            if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)
-            {
-                const Atom protocol = event->xclient.data.l[0];
-                if (protocol == None)
-                    return;
-
-                if (protocol == _glfw.x11.WM_DELETE_WINDOW)
-                {
-                    // The window manager was asked to close the window, for
-                    // example by the user pressing a 'close' window decoration
-                    // button
-                    _glfwInputWindowCloseRequest(window);
-                }
-                else if (protocol == _glfw.x11.NET_WM_PING)
-                {
-                    // The window manager is pinging the application to ensure
-                    // it's still responding to events
-
-                    XEvent reply = *event;
-                    reply.xclient.window = _glfw.x11.root;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.root,
-                               False,
-                               SubstructureNotifyMask | SubstructureRedirectMask,
-                               &reply);
-                }
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndEnter)
-            {
-                // A drag operation has entered the window
-                unsigned long i, count;
-                Atom* formats = NULL;
-                const GLFWbool list = event->xclient.data.l[1] & 1;
-
-                _glfw.x11.xdnd.source  = event->xclient.data.l[0];
-                _glfw.x11.xdnd.version = event->xclient.data.l[1] >> 24;
-                _glfw.x11.xdnd.format  = None;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                if (list)
-                {
-                    count = _glfwGetWindowPropertyX11(_glfw.x11.xdnd.source,
-                                                      _glfw.x11.XdndTypeList,
-                                                      XA_ATOM,
-                                                      (unsigned char**) &formats);
-                }
-                else
-                {
-                    count = 3;
-                    formats = (Atom*) event->xclient.data.l + 2;
-                }
-
-                for (i = 0;  i < count;  i++)
-                {
-                    if (formats[i] == _glfw.x11.text_uri_list)
-                    {
-                        _glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
-                        break;
-                    }
-                }
-
-                if (list && formats)
-                    XFree(formats);
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndDrop)
-            {
-                // The drag operation has finished by dropping on the window
-                Time time = CurrentTime;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                if (_glfw.x11.xdnd.format)
-                {
-                    if (_glfw.x11.xdnd.version >= 1)
-                        time = event->xclient.data.l[2];
-
-                    // Request the chosen format from the source window
-                    XConvertSelection(_glfw.x11.display,
-                                      _glfw.x11.XdndSelection,
-                                      _glfw.x11.xdnd.format,
-                                      _glfw.x11.XdndSelection,
-                                      window->x11.handle,
-                                      time);
-                }
-                else if (_glfw.x11.xdnd.version >= 2)
-                {
-                    XEvent reply = { ClientMessage };
-                    reply.xclient.window = _glfw.x11.xdnd.source;
-                    reply.xclient.message_type = _glfw.x11.XdndFinished;
-                    reply.xclient.format = 32;
-                    reply.xclient.data.l[0] = window->x11.handle;
-                    reply.xclient.data.l[1] = 0; // The drag was rejected
-                    reply.xclient.data.l[2] = None;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                               False, NoEventMask, &reply);
-                    XFlush(_glfw.x11.display);
-                }
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndPosition)
-            {
-                // The drag operation has moved over the window
-                const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff;
-                const int yabs = (event->xclient.data.l[2]) & 0xffff;
-                Window dummy;
-                int xpos, ypos;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                XTranslateCoordinates(_glfw.x11.display,
-                                      _glfw.x11.root,
-                                      window->x11.handle,
-                                      xabs, yabs,
-                                      &xpos, &ypos,
-                                      &dummy);
-
-                _glfwInputCursorPos(window, xpos, ypos);
-
-                XEvent reply = { ClientMessage };
-                reply.xclient.window = _glfw.x11.xdnd.source;
-                reply.xclient.message_type = _glfw.x11.XdndStatus;
-                reply.xclient.format = 32;
-                reply.xclient.data.l[0] = window->x11.handle;
-                reply.xclient.data.l[2] = 0; // Specify an empty rectangle
-                reply.xclient.data.l[3] = 0;
-
-                if (_glfw.x11.xdnd.format)
-                {
-                    // Reply that we are ready to copy the dragged data
-                    reply.xclient.data.l[1] = 1; // Accept with no rectangle
-                    if (_glfw.x11.xdnd.version >= 2)
-                        reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;
-                }
-
-                XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                           False, NoEventMask, &reply);
-                XFlush(_glfw.x11.display);
-            }
-
-            return;
-        }
-
-        case SelectionNotify:
-        {
-            if (event->xselection.property == _glfw.x11.XdndSelection)
-            {
-                // The converted data from the drag operation has arrived
-                char* data;
-                const unsigned long result =
-                    _glfwGetWindowPropertyX11(event->xselection.requestor,
-                                              event->xselection.property,
-                                              event->xselection.target,
-                                              (unsigned char**) &data);
-
-                if (result)
-                {
-                    int i, count;
-                    char** paths = parseUriList(data, &count);
-
-                    _glfwInputDrop(window, count, (const char**) paths);
-
-                    for (i = 0;  i < count;  i++)
-                        free(paths[i]);
-                    free(paths);
-                }
-
-                if (data)
-                    XFree(data);
-
-                if (_glfw.x11.xdnd.version >= 2)
-                {
-                    XEvent reply = { ClientMessage };
-                    reply.xclient.window = _glfw.x11.xdnd.source;
-                    reply.xclient.message_type = _glfw.x11.XdndFinished;
-                    reply.xclient.format = 32;
-                    reply.xclient.data.l[0] = window->x11.handle;
-                    reply.xclient.data.l[1] = result;
-                    reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                               False, NoEventMask, &reply);
-                    XFlush(_glfw.x11.display);
-                }
-            }
-
-            return;
-        }
-
-        case FocusIn:
-        {
-            if (event->xfocus.mode == NotifyGrab ||
-                event->xfocus.mode == NotifyUngrab)
-            {
-                // Ignore focus events from popup indicator windows, window menu
-                // key chords and window dragging
-                return;
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            if (window->x11.ic)
-                XSetICFocus(window->x11.ic);
-
-            _glfwInputWindowFocus(window, GLFW_TRUE);
-            return;
-        }
-
-        case FocusOut:
-        {
-            if (event->xfocus.mode == NotifyGrab ||
-                event->xfocus.mode == NotifyUngrab)
-            {
-                // Ignore focus events from popup indicator windows, window menu
-                // key chords and window dragging
-                return;
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            if (window->x11.ic)
-                XUnsetICFocus(window->x11.ic);
-
-            if (window->monitor && window->autoIconify)
-                _glfwPlatformIconifyWindow(window);
-
-            _glfwInputWindowFocus(window, GLFW_FALSE);
-            return;
-        }
-
-        case Expose:
-        {
-            _glfwInputWindowDamage(window);
-            return;
-        }
-
-        case PropertyNotify:
-        {
-            if (event->xproperty.state != PropertyNewValue)
-                return;
-
-            if (event->xproperty.atom == _glfw.x11.WM_STATE)
-            {
-                const int state = getWindowState(window);
-                if (state != IconicState && state != NormalState)
-                    return;
-
-                const GLFWbool iconified = (state == IconicState);
-                if (window->x11.iconified != iconified)
-                {
-                    if (window->monitor)
-                    {
-                        if (iconified)
-                            releaseMonitor(window);
-                        else
-                            acquireMonitor(window);
-                    }
-
-                    window->x11.iconified = iconified;
-                    _glfwInputWindowIconify(window, iconified);
-                }
-            }
-            else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
-            {
-                const GLFWbool maximized = _glfwPlatformWindowMaximized(window);
-                if (window->x11.maximized != maximized)
-                {
-                    window->x11.maximized = maximized;
-                    _glfwInputWindowMaximize(window, maximized);
-                }
-            }
-
-            return;
-        }
-
-        case DestroyNotify:
-            return;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Retrieve a single window property of the specified type
-// Inspired by fghGetWindowProperty from freeglut
-//
-unsigned long _glfwGetWindowPropertyX11(Window window,
-                                        Atom property,
-                                        Atom type,
-                                        unsigned char** value)
-{
-    Atom actualType;
-    int actualFormat;
-    unsigned long itemCount, bytesAfter;
-
-    XGetWindowProperty(_glfw.x11.display,
-                       window,
-                       property,
-                       0,
-                       LONG_MAX,
-                       False,
-                       type,
-                       &actualType,
-                       &actualFormat,
-                       &itemCount,
-                       &bytesAfter,
-                       value);
-
-    return itemCount;
-}
-
-GLFWbool _glfwIsVisualTransparentX11(Visual* visual)
-{
-    if (!_glfw.x11.xrender.available)
-        return GLFW_FALSE;
-
-    XRenderPictFormat* pf = XRenderFindVisualFormat(_glfw.x11.display, visual);
-    return pf && pf->direct.alphaMask;
-}
-
-// Push contents of our selection to clipboard manager
-//
-void _glfwPushSelectionToManagerX11(void)
-{
-    XConvertSelection(_glfw.x11.display,
-                      _glfw.x11.CLIPBOARD_MANAGER,
-                      _glfw.x11.SAVE_TARGETS,
-                      None,
-                      _glfw.x11.helperWindowHandle,
-                      CurrentTime);
-
-    for (;;)
-    {
-        XEvent event;
-
-        while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
-        {
-            switch (event.type)
-            {
-                case SelectionRequest:
-                    handleSelectionRequest(&event);
-                    break;
-
-                case SelectionClear:
-                    handleSelectionClear(&event);
-                    break;
-
-                case SelectionNotify:
-                {
-                    if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
-                    {
-                        // This means one of two things; either the selection
-                        // was not owned, which means there is no clipboard
-                        // manager, or the transfer to the clipboard manager has
-                        // completed
-                        // In either case, it means we are done here
-                        return;
-                    }
-
-                    break;
-                }
-            }
-        }
-
-        waitForEvent(NULL);
-    }
-}
-
-void _glfwCreateInputContextX11(_GLFWwindow* window)
-{
-    XIMCallback callback;
-    callback.callback = (XIMProc) inputContextDestroyCallback;
-    callback.client_data = (XPointer) window;
-
-    window->x11.ic = XCreateIC(_glfw.x11.im,
-                               XNInputStyle,
-                               XIMPreeditNothing | XIMStatusNothing,
-                               XNClientWindow,
-                               window->x11.handle,
-                               XNFocusWindow,
-                               window->x11.handle,
-                               XNDestroyCallback,
-                               &callback,
-                               NULL);
-
-    if (window->x11.ic)
-    {
-        XWindowAttributes attribs;
-        XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
-
-        unsigned long filter = 0;
-        if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL)
-        {
-            XSelectInput(_glfw.x11.display,
-                         window->x11.handle,
-                         attribs.your_event_mask | filter);
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    Visual* visual = NULL;
-    int depth;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitGLX())
-                return GLFW_FALSE;
-            if (!_glfwChooseVisualGLX(wndconfig, ctxconfig, fbconfig, &visual, &depth))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-        }
-    }
-
-    if (!visual)
-    {
-        visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
-        depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
-    }
-
-    if (!createNativeWindow(window, wndconfig, visual, depth))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        updateWindowMode(window);
-        acquireMonitor(window);
-    }
-
-    XFlush(_glfw.x11.display);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (_glfw.x11.disabledCursorWindow == window)
-        _glfw.x11.disabledCursorWindow = NULL;
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->x11.ic)
-    {
-        XDestroyIC(window->x11.ic);
-        window->x11.ic = NULL;
-    }
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    if (window->x11.handle)
-    {
-        XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
-        XUnmapWindow(_glfw.x11.display, window->x11.handle);
-        XDestroyWindow(_glfw.x11.display, window->x11.handle);
-        window->x11.handle = (Window) 0;
-    }
-
-    if (window->x11.colormap)
-    {
-        XFreeColormap(_glfw.x11.display, window->x11.colormap);
-        window->x11.colormap = (Colormap) 0;
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    if (_glfw.x11.xlib.utf8)
-    {
-        Xutf8SetWMProperties(_glfw.x11.display,
-                             window->x11.handle,
-                             title, title,
-                             NULL, 0,
-                             NULL, NULL, NULL);
-    }
-
-    XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                    _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
-                    PropModeReplace,
-                    (unsigned char*) title, strlen(title));
-
-    XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                    _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
-                    PropModeReplace,
-                    (unsigned char*) title, strlen(title));
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    if (count)
-    {
-        int i, j, longCount = 0;
-
-        for (i = 0;  i < count;  i++)
-            longCount += 2 + images[i].width * images[i].height;
-
-        long* icon = calloc(longCount, sizeof(long));
-        long* target = icon;
-
-        for (i = 0;  i < count;  i++)
-        {
-            *target++ = images[i].width;
-            *target++ = images[i].height;
-
-            for (j = 0;  j < images[i].width * images[i].height;  j++)
-            {
-                *target++ = (images[i].pixels[j * 4 + 0] << 16) |
-                            (images[i].pixels[j * 4 + 1] <<  8) |
-                            (images[i].pixels[j * 4 + 2] <<  0) |
-                            (images[i].pixels[j * 4 + 3] << 24);
-            }
-        }
-
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_ICON,
-                        XA_CARDINAL, 32,
-                        PropModeReplace,
-                        (unsigned char*) icon,
-                        longCount);
-
-        free(icon);
-    }
-    else
-    {
-        XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_ICON);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    Window dummy;
-    int x, y;
-
-    XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
-                          0, 0, &x, &y, &dummy);
-
-    if (xpos)
-        *xpos = x;
-    if (ypos)
-        *ypos = y;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    // HACK: Explicitly setting PPosition to any value causes some WMs, notably
-    //       Compiz and Metacity, to honor the position of unmapped windows
-    if (!_glfwPlatformWindowVisible(window))
-    {
-        long supplied;
-        XSizeHints* hints = XAllocSizeHints();
-
-        if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied))
-        {
-            hints->flags |= PPosition;
-            hints->x = hints->y = 0;
-
-            XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
-        }
-
-        XFree(hints);
-    }
-
-    XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    XWindowAttributes attribs;
-    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
-
-    if (width)
-        *width = attribs.width;
-    if (height)
-        *height = attribs.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-            acquireMonitor(window);
-    }
-    else
-    {
-        if (!window->resizable)
-            updateNormalHints(window, width, height);
-
-        XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    long* extents = NULL;
-
-    if (window->monitor || !window->decorated)
-        return;
-
-    if (_glfw.x11.NET_FRAME_EXTENTS == None)
-        return;
-
-    if (!_glfwPlatformWindowVisible(window) &&
-        _glfw.x11.NET_REQUEST_FRAME_EXTENTS)
-    {
-        XEvent event;
-        double timeout = 0.5;
-
-        // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
-        // function before the window is mapped
-        sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
-                      0, 0, 0, 0, 0);
-
-        // HACK: Use a timeout because earlier versions of some window managers
-        //       (at least Unity, Fluxbox and Xfwm) failed to send the reply
-        //       They have been fixed but broken versions are still in the wild
-        //       If you are affected by this and your window manager is NOT
-        //       listed above, PLEASE report it to their and our issue trackers
-        while (!XCheckIfEvent(_glfw.x11.display,
-                              &event,
-                              isFrameExtentsEvent,
-                              (XPointer) window))
-        {
-            if (!waitForEvent(&timeout))
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
-                return;
-            }
-        }
-    }
-
-    if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.NET_FRAME_EXTENTS,
-                                  XA_CARDINAL,
-                                  (unsigned char**) &extents) == 4)
-    {
-        if (left)
-            *left = extents[0];
-        if (top)
-            *top = extents[2];
-        if (right)
-            *right = extents[1];
-        if (bottom)
-            *bottom = extents[3];
-    }
-
-    if (extents)
-        XFree(extents);
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = _glfw.x11.contentScaleX;
-    if (yscale)
-        *yscale = _glfw.x11.contentScaleY;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (window->x11.overrideRedirect)
-    {
-        // Override-redirect windows cannot be iconified or restored, as those
-        // tasks are performed by the window manager
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
-        return;
-    }
-
-    XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->x11.overrideRedirect)
-    {
-        // Override-redirect windows cannot be iconified or restored, as those
-        // tasks are performed by the window manager
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
-        return;
-    }
-
-    if (_glfwPlatformWindowIconified(window))
-    {
-        XMapWindow(_glfw.x11.display, window->x11.handle);
-        waitForVisibilityNotify(window);
-    }
-    else if (_glfwPlatformWindowVisible(window))
-    {
-        if (_glfw.x11.NET_WM_STATE &&
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_REMOVE,
-                          _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-                          _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
-                          1, 0);
-        }
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (!_glfw.x11.NET_WM_STATE ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-    {
-        return;
-    }
-
-    if (_glfwPlatformWindowVisible(window))
-    {
-        sendEventToWM(window,
-                    _glfw.x11.NET_WM_STATE,
-                    _NET_WM_STATE_ADD,
-                    _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-                    _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
-                    1, 0);
-    }
-    else
-    {
-        Atom* states = NULL;
-        unsigned long count =
-            _glfwGetWindowPropertyX11(window->x11.handle,
-                                      _glfw.x11.NET_WM_STATE,
-                                      XA_ATOM,
-                                      (unsigned char**) &states);
-
-        // NOTE: We don't check for failure as this property may not exist yet
-        //       and that's fine (and we'll create it implicitly with append)
-
-        Atom missing[2] =
-        {
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
-        };
-        unsigned long missingCount = 2;
-
-        for (unsigned long i = 0;  i < count;  i++)
-        {
-            for (unsigned long j = 0;  j < missingCount;  j++)
-            {
-                if (states[i] == missing[j])
-                {
-                    missing[j] = missing[missingCount - 1];
-                    missingCount--;
-                }
-            }
-        }
-
-        if (states)
-            XFree(states);
-
-        if (!missingCount)
-            return;
-
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                        PropModeAppend,
-                        (unsigned char*) missing,
-                        missingCount);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    if (_glfwPlatformWindowVisible(window))
-        return;
-
-    XMapWindow(_glfw.x11.display, window->x11.handle);
-    waitForVisibilityNotify(window);
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    XUnmapWindow(_glfw.x11.display, window->x11.handle);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION)
-        return;
-
-    sendEventToWM(window,
-                  _glfw.x11.NET_WM_STATE,
-                  _NET_WM_STATE_ADD,
-                  _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION,
-                  0, 1, 0);
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    if (_glfw.x11.NET_ACTIVE_WINDOW)
-        sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);
-    else if (_glfwPlatformWindowVisible(window))
-    {
-        XRaiseWindow(_glfw.x11.display, window->x11.handle);
-        XSetInputFocus(_glfw.x11.display, window->x11.handle,
-                       RevertToParent, CurrentTime);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-                acquireMonitor(window);
-        }
-        else
-        {
-            if (!window->resizable)
-                updateNormalHints(window, width, height);
-
-            XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                              xpos, ypos, width, height);
-        }
-
-        XFlush(_glfw.x11.display);
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-    updateNormalHints(window, width, height);
-
-    if (window->monitor)
-    {
-        if (!_glfwPlatformWindowVisible(window))
-        {
-            XMapRaised(_glfw.x11.display, window->x11.handle);
-            waitForVisibilityNotify(window);
-        }
-
-        updateWindowMode(window);
-        acquireMonitor(window);
-    }
-    else
-    {
-        updateWindowMode(window);
-        XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                          xpos, ypos, width, height);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    Window focused;
-    int state;
-
-    XGetInputFocus(_glfw.x11.display, &focused, &state);
-    return window->x11.handle == focused;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return getWindowState(window) == IconicState;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    XWindowAttributes wa;
-    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
-    return wa.map_state == IsViewable;
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    Atom* states;
-    unsigned long i;
-    GLFWbool maximized = GLFW_FALSE;
-
-    if (!_glfw.x11.NET_WM_STATE ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-    {
-        return maximized;
-    }
-
-    const unsigned long count =
-        _glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.NET_WM_STATE,
-                                  XA_ATOM,
-                                  (unsigned char**) &states);
-
-    for (i = 0;  i < count;  i++)
-    {
-        if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-            states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-        {
-            maximized = GLFW_TRUE;
-            break;
-        }
-    }
-
-    if (states)
-        XFree(states);
-
-    return maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    Window w = _glfw.x11.root;
-    while (w)
-    {
-        Window root;
-        int rootX, rootY, childX, childY;
-        unsigned int mask;
-
-        _glfwGrabErrorHandlerX11();
-
-        const Bool result = XQueryPointer(_glfw.x11.display, w,
-                                          &root, &w, &rootX, &rootY,
-                                          &childX, &childY, &mask);
-
-        _glfwReleaseErrorHandlerX11();
-
-        if (_glfw.x11.errorCode == BadWindow)
-            w = _glfw.x11.root;
-        else if (!result)
-            return GLFW_FALSE;
-        else if (w == window->x11.handle)
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    if (!window->x11.transparent)
-        return GLFW_FALSE;
-
-    return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    struct
-    {
-        unsigned long flags;
-        unsigned long functions;
-        unsigned long decorations;
-        long input_mode;
-        unsigned long status;
-    } hints = {0};
-
-    hints.flags = MWM_HINTS_DECORATIONS;
-    hints.decorations = enabled ? MWM_DECOR_ALL : 0;
-
-    XChangeProperty(_glfw.x11.display, window->x11.handle,
-                    _glfw.x11.MOTIF_WM_HINTS,
-                    _glfw.x11.MOTIF_WM_HINTS, 32,
-                    PropModeReplace,
-                    (unsigned char*) &hints,
-                    sizeof(hints) / sizeof(long));
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE)
-        return;
-
-    if (_glfwPlatformWindowVisible(window))
-    {
-        const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
-        sendEventToWM(window,
-                      _glfw.x11.NET_WM_STATE,
-                      action,
-                      _glfw.x11.NET_WM_STATE_ABOVE,
-                      0, 1, 0);
-    }
-    else
-    {
-        Atom* states = NULL;
-        unsigned long i, count;
-
-        count = _glfwGetWindowPropertyX11(window->x11.handle,
-                                          _glfw.x11.NET_WM_STATE,
-                                          XA_ATOM,
-                                          (unsigned char**) &states);
-
-        // NOTE: We don't check for failure as this property may not exist yet
-        //       and that's fine (and we'll create it implicitly with append)
-
-        if (enabled)
-        {
-            for (i = 0;  i < count;  i++)
-            {
-                if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
-                    break;
-            }
-
-            if (i < count)
-                return;
-
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeAppend,
-                            (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
-                            1);
-        }
-        else if (states)
-        {
-            for (i = 0;  i < count;  i++)
-            {
-                if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
-                    break;
-            }
-
-            if (i == count)
-                return;
-
-            states[i] = states[count - 1];
-            count--;
-
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeReplace, (unsigned char*) states, count);
-        }
-
-        if (states)
-            XFree(states);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!_glfw.x11.xshape.available)
-        return;
-
-    if (enabled)
-    {
-        Region region = XCreateRegion();
-        XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
-                            ShapeInput, 0, 0, region, ShapeSet);
-        XDestroyRegion(region);
-    }
-    else
-    {
-        XShapeCombineMask(_glfw.x11.display, window->x11.handle,
-                          ShapeInput, 0, 0, None, ShapeSet);
-    }
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    float opacity = 1.f;
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx))
-    {
-        CARD32* value = NULL;
-
-        if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                      _glfw.x11.NET_WM_WINDOW_OPACITY,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &value))
-        {
-            opacity = (float) (*value / (double) 0xffffffffu);
-        }
-
-        if (value)
-            XFree(value);
-    }
-
-    return opacity;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    const CARD32 value = (CARD32) (0xffffffffu * (double) opacity);
-    XChangeProperty(_glfw.x11.display, window->x11.handle,
-                    _glfw.x11.NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
-                    PropModeReplace, (unsigned char*) &value, 1);
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    if (!_glfw.x11.xi.available)
-        return;
-
-    if (_glfw.x11.disabledCursorWindow != window)
-        return;
-
-    if (enabled)
-        enableRawMouseMotion(window);
-    else
-        disableRawMouseMotion(window);
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return _glfw.x11.xi.available;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    _GLFWwindow* window;
-
-#if defined(__linux__)
-    if (_glfw.joysticksInitialized)
-        _glfwDetectJoystickConnectionLinux();
-#endif
-    XPending(_glfw.x11.display);
-
-    while (QLength(_glfw.x11.display))
-    {
-        XEvent event;
-        XNextEvent(_glfw.x11.display, &event);
-        processEvent(&event);
-    }
-
-    window = _glfw.x11.disabledCursorWindow;
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetWindowSize(window, &width, &height);
-
-        // NOTE: Re-center the cursor only if it has moved since the last call,
-        //       to avoid breaking glfwWaitEvents with MotionNotify
-        if (window->x11.lastCursorPosX != width / 2 ||
-            window->x11.lastCursorPosY != height / 2)
-        {
-            _glfwPlatformSetCursorPos(window, width / 2, height / 2);
-        }
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    while (!XPending(_glfw.x11.display))
-        waitForEvent(NULL);
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    while (!XPending(_glfw.x11.display))
-    {
-        if (!waitForEvent(&timeout))
-            break;
-    }
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    XEvent event = { ClientMessage };
-    event.xclient.window = _glfw.x11.helperWindowHandle;
-    event.xclient.format = 32; // Data is 32-bit longs
-    event.xclient.message_type = _glfw.x11.NULL_;
-
-    XSendEvent(_glfw.x11.display, _glfw.x11.helperWindowHandle, False, 0, &event);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    Window root, child;
-    int rootX, rootY, childX, childY;
-    unsigned int mask;
-
-    XQueryPointer(_glfw.x11.display, window->x11.handle,
-                  &root, &child,
-                  &rootX, &rootY, &childX, &childY,
-                  &mask);
-
-    if (xpos)
-        *xpos = childX;
-    if (ypos)
-        *ypos = childY;
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    // Store the new position so it can be recognized later
-    window->x11.warpCursorPosX = (int) x;
-    window->x11.warpCursorPosY = (int) y;
-
-    XWarpPointer(_glfw.x11.display, None, window->x11.handle,
-                 0,0,0,0, (int) x, (int) y);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    if (mode == GLFW_CURSOR_DISABLED)
-    {
-        if (_glfwPlatformWindowFocused(window))
-            disableCursor(window);
-    }
-    else if (_glfw.x11.disabledCursorWindow == window)
-        enableCursor(window);
-    else
-        updateCursorImage(window);
-
-    XFlush(_glfw.x11.display);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    if (!_glfw.x11.xkb.available)
-        return NULL;
-
-    if (scancode < 0 || scancode > 0xff ||
-        _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    const int key = _glfw.x11.keycodes[scancode];
-    const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
-                                             scancode, _glfw.x11.xkb.group, 0);
-    if (keysym == NoSymbol)
-        return NULL;
-
-    const long ch = _glfwKeySym2Unicode(keysym);
-    if (ch == -1)
-        return NULL;
-
-    const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch);
-    if (count == 0)
-        return NULL;
-
-    _glfw.x11.keynames[key][count] = '\0';
-    return _glfw.x11.keynames[key];
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.x11.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
-    if (!cursor->x11.handle)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    if (_glfw.x11.xcursor.handle)
-    {
-        char* theme = XcursorGetTheme(_glfw.x11.display);
-        if (theme)
-        {
-            const int size = XcursorGetDefaultSize(_glfw.x11.display);
-            const char* name = NULL;
-
-            if (shape == GLFW_ARROW_CURSOR)
-                name = "default";
-            else if (shape == GLFW_IBEAM_CURSOR)
-                name = "text";
-            else if (shape == GLFW_CROSSHAIR_CURSOR)
-                name = "crosshair";
-            else if (shape == GLFW_POINTING_HAND_CURSOR)
-                name = "pointer";
-            else if (shape == GLFW_RESIZE_EW_CURSOR)
-                name = "ew-resize";
-            else if (shape == GLFW_RESIZE_NS_CURSOR)
-                name = "ns-resize";
-            else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-                name = "nwse-resize";
-            else if (shape == GLFW_RESIZE_NESW_CURSOR)
-                name = "nesw-resize";
-            else if (shape == GLFW_RESIZE_ALL_CURSOR)
-                name = "all-scroll";
-            else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-                name = "not-allowed";
-
-            XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
-            if (image)
-            {
-                cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image);
-                XcursorImageDestroy(image);
-            }
-        }
-    }
-
-    if (!cursor->x11.handle)
-    {
-        unsigned int native = 0;
-
-        if (shape == GLFW_ARROW_CURSOR)
-            native = XC_left_ptr;
-        else if (shape == GLFW_IBEAM_CURSOR)
-            native = XC_xterm;
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            native = XC_crosshair;
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            native = XC_hand2;
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            native = XC_sb_h_double_arrow;
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            native = XC_sb_v_double_arrow;
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            native = XC_fleur;
-        else
-        {
-            _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                            "X11: Standard cursor shape unavailable");
-            return GLFW_FALSE;
-        }
-
-        cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
-        if (!cursor->x11.handle)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create standard cursor");
-            return GLFW_FALSE;
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    if (cursor->x11.handle)
-        XFreeCursor(_glfw.x11.display, cursor->x11.handle);
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        updateCursorImage(window);
-        XFlush(_glfw.x11.display);
-    }
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    char* copy = _glfw_strdup(string);
-    free(_glfw.x11.clipboardString);
-    _glfw.x11.clipboardString = copy;
-
-    XSetSelectionOwner(_glfw.x11.display,
-                       _glfw.x11.CLIPBOARD,
-                       _glfw.x11.helperWindowHandle,
-                       CurrentTime);
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
-        _glfw.x11.helperWindowHandle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Failed to become owner of clipboard selection");
-    }
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    return getSelectionString(_glfw.x11.CLIPBOARD);
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_vulkan)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
-                type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(5, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
-            (*attribs)[3] = EGL_PLATFORM_X11_EXT;
-            (*attribs)[4] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_x11)
-        return EGL_PLATFORM_X11_EXT;
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return _glfw.x11.display;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    if (_glfw.egl.platform)
-        return &window->x11.handle;
-    else
-        return (EGLNativeWindowType) window->x11.handle;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface)
-        return;
-
-    if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
-    {
-        if (!_glfw.vk.KHR_xlib_surface)
-            return;
-    }
-
-    extensions[0] = "VK_KHR_surface";
-
-    // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but
-    //       not correctly implementing VK_KHR_xlib_surface
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-        extensions[1] = "VK_KHR_xcb_surface";
-    else
-        extensions[1] = "VK_KHR_xlib_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
-                                                          _glfw.x11.screen));
-
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-    {
-        PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
-            vkGetPhysicalDeviceXcbPresentationSupportKHR =
-            (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
-            vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-        if (!vkGetPhysicalDeviceXcbPresentationSupportKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
-            return GLFW_FALSE;
-        }
-
-        xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
-        if (!connection)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to retrieve XCB connection");
-            return GLFW_FALSE;
-        }
-
-        return vkGetPhysicalDeviceXcbPresentationSupportKHR(device,
-                                                            queuefamily,
-                                                            connection,
-                                                            visualID);
-    }
-    else
-    {
-        PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
-            vkGetPhysicalDeviceXlibPresentationSupportKHR =
-            (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
-            vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
-        if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
-            return GLFW_FALSE;
-        }
-
-        return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
-                                                             queuefamily,
-                                                             _glfw.x11.display,
-                                                             visualID);
-    }
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-    {
-        VkResult err;
-        VkXcbSurfaceCreateInfoKHR sci;
-        PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
-
-        xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
-        if (!connection)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to retrieve XCB connection");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
-            vkGetInstanceProcAddr(instance, "vkCreateXcbSurfaceKHR");
-        if (!vkCreateXcbSurfaceKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
-        sci.connection = connection;
-        sci.window = window->x11.handle;
-
-        err = vkCreateXcbSurfaceKHR(instance, &sci, allocator, surface);
-        if (err)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create Vulkan XCB surface: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        return err;
-    }
-    else
-    {
-        VkResult err;
-        VkXlibSurfaceCreateInfoKHR sci;
-        PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
-
-        vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
-            vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
-        if (!vkCreateXlibSurfaceKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
-        sci.dpy = _glfw.x11.display;
-        sci.window = window->x11.handle;
-
-        err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
-        if (err)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create Vulkan X11 surface: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        return err;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI Display* glfwGetX11Display(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfw.x11.display;
-}
-
-GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return window->x11.handle;
-}
-
-GLFWAPI void glfwSetX11SelectionString(const char* string)
-{
-    _GLFW_REQUIRE_INIT();
-
-    free(_glfw.x11.primarySelectionString);
-    _glfw.x11.primarySelectionString = _glfw_strdup(string);
-
-    XSetSelectionOwner(_glfw.x11.display,
-                       _glfw.x11.PRIMARY,
-                       _glfw.x11.helperWindowHandle,
-                       CurrentTime);
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.PRIMARY) !=
-        _glfw.x11.helperWindowHandle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Failed to become owner of primary selection");
-    }
-}
-
-GLFWAPI const char* glfwGetX11SelectionString(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return getSelectionString(_glfw.x11.PRIMARY);
-}
-
diff --git a/raylib/external/glfw/src/xkb_unicode.c b/raylib/external/glfw/src/xkb_unicode.c
deleted file mode 100644 (file)
index 2772ea0..0000000
+++ /dev/null
@@ -1,942 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-
-/*
- * Marcus: This code was originally written by Markus G. Kuhn.
- * I have made some slight changes (trimmed it down a bit from >60 KB to
- * 20 KB), but the functionality is the same.
- */
-
-/*
- * This module converts keysym values into the corresponding ISO 10646
- * (UCS, Unicode) values.
- *
- * The array keysymtab[] contains pairs of X11 keysym values for graphical
- * characters and the corresponding Unicode value. The function
- * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
- * search, therefore keysymtab[] must remain SORTED by keysym value.
- *
- * We allow to represent any UCS character in the range U-00000000 to
- * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
- * This admittedly does not cover the entire 31-bit space of UCS, but
- * it does cover all of the characters up to U-10FFFF, which can be
- * represented by UTF-16, and more, and it is very unlikely that higher
- * UCS codes will ever be assigned by ISO. So to get Unicode character
- * U+ABCD you can directly use keysym 0x0100abcd.
- *
- * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
- *                  Cambridge, April 2001
- *
- * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
- * an initial draft of the mapping table.
- *
- */
-
-
-//************************************************************************
-//****                KeySym to Unicode mapping table                 ****
-//************************************************************************
-
-static const struct codepair {
-  unsigned short keysym;
-  unsigned short ucs;
-} keysymtab[] = {
-  { 0x01a1, 0x0104 },
-  { 0x01a2, 0x02d8 },
-  { 0x01a3, 0x0141 },
-  { 0x01a5, 0x013d },
-  { 0x01a6, 0x015a },
-  { 0x01a9, 0x0160 },
-  { 0x01aa, 0x015e },
-  { 0x01ab, 0x0164 },
-  { 0x01ac, 0x0179 },
-  { 0x01ae, 0x017d },
-  { 0x01af, 0x017b },
-  { 0x01b1, 0x0105 },
-  { 0x01b2, 0x02db },
-  { 0x01b3, 0x0142 },
-  { 0x01b5, 0x013e },
-  { 0x01b6, 0x015b },
-  { 0x01b7, 0x02c7 },
-  { 0x01b9, 0x0161 },
-  { 0x01ba, 0x015f },
-  { 0x01bb, 0x0165 },
-  { 0x01bc, 0x017a },
-  { 0x01bd, 0x02dd },
-  { 0x01be, 0x017e },
-  { 0x01bf, 0x017c },
-  { 0x01c0, 0x0154 },
-  { 0x01c3, 0x0102 },
-  { 0x01c5, 0x0139 },
-  { 0x01c6, 0x0106 },
-  { 0x01c8, 0x010c },
-  { 0x01ca, 0x0118 },
-  { 0x01cc, 0x011a },
-  { 0x01cf, 0x010e },
-  { 0x01d0, 0x0110 },
-  { 0x01d1, 0x0143 },
-  { 0x01d2, 0x0147 },
-  { 0x01d5, 0x0150 },
-  { 0x01d8, 0x0158 },
-  { 0x01d9, 0x016e },
-  { 0x01db, 0x0170 },
-  { 0x01de, 0x0162 },
-  { 0x01e0, 0x0155 },
-  { 0x01e3, 0x0103 },
-  { 0x01e5, 0x013a },
-  { 0x01e6, 0x0107 },
-  { 0x01e8, 0x010d },
-  { 0x01ea, 0x0119 },
-  { 0x01ec, 0x011b },
-  { 0x01ef, 0x010f },
-  { 0x01f0, 0x0111 },
-  { 0x01f1, 0x0144 },
-  { 0x01f2, 0x0148 },
-  { 0x01f5, 0x0151 },
-  { 0x01f8, 0x0159 },
-  { 0x01f9, 0x016f },
-  { 0x01fb, 0x0171 },
-  { 0x01fe, 0x0163 },
-  { 0x01ff, 0x02d9 },
-  { 0x02a1, 0x0126 },
-  { 0x02a6, 0x0124 },
-  { 0x02a9, 0x0130 },
-  { 0x02ab, 0x011e },
-  { 0x02ac, 0x0134 },
-  { 0x02b1, 0x0127 },
-  { 0x02b6, 0x0125 },
-  { 0x02b9, 0x0131 },
-  { 0x02bb, 0x011f },
-  { 0x02bc, 0x0135 },
-  { 0x02c5, 0x010a },
-  { 0x02c6, 0x0108 },
-  { 0x02d5, 0x0120 },
-  { 0x02d8, 0x011c },
-  { 0x02dd, 0x016c },
-  { 0x02de, 0x015c },
-  { 0x02e5, 0x010b },
-  { 0x02e6, 0x0109 },
-  { 0x02f5, 0x0121 },
-  { 0x02f8, 0x011d },
-  { 0x02fd, 0x016d },
-  { 0x02fe, 0x015d },
-  { 0x03a2, 0x0138 },
-  { 0x03a3, 0x0156 },
-  { 0x03a5, 0x0128 },
-  { 0x03a6, 0x013b },
-  { 0x03aa, 0x0112 },
-  { 0x03ab, 0x0122 },
-  { 0x03ac, 0x0166 },
-  { 0x03b3, 0x0157 },
-  { 0x03b5, 0x0129 },
-  { 0x03b6, 0x013c },
-  { 0x03ba, 0x0113 },
-  { 0x03bb, 0x0123 },
-  { 0x03bc, 0x0167 },
-  { 0x03bd, 0x014a },
-  { 0x03bf, 0x014b },
-  { 0x03c0, 0x0100 },
-  { 0x03c7, 0x012e },
-  { 0x03cc, 0x0116 },
-  { 0x03cf, 0x012a },
-  { 0x03d1, 0x0145 },
-  { 0x03d2, 0x014c },
-  { 0x03d3, 0x0136 },
-  { 0x03d9, 0x0172 },
-  { 0x03dd, 0x0168 },
-  { 0x03de, 0x016a },
-  { 0x03e0, 0x0101 },
-  { 0x03e7, 0x012f },
-  { 0x03ec, 0x0117 },
-  { 0x03ef, 0x012b },
-  { 0x03f1, 0x0146 },
-  { 0x03f2, 0x014d },
-  { 0x03f3, 0x0137 },
-  { 0x03f9, 0x0173 },
-  { 0x03fd, 0x0169 },
-  { 0x03fe, 0x016b },
-  { 0x047e, 0x203e },
-  { 0x04a1, 0x3002 },
-  { 0x04a2, 0x300c },
-  { 0x04a3, 0x300d },
-  { 0x04a4, 0x3001 },
-  { 0x04a5, 0x30fb },
-  { 0x04a6, 0x30f2 },
-  { 0x04a7, 0x30a1 },
-  { 0x04a8, 0x30a3 },
-  { 0x04a9, 0x30a5 },
-  { 0x04aa, 0x30a7 },
-  { 0x04ab, 0x30a9 },
-  { 0x04ac, 0x30e3 },
-  { 0x04ad, 0x30e5 },
-  { 0x04ae, 0x30e7 },
-  { 0x04af, 0x30c3 },
-  { 0x04b0, 0x30fc },
-  { 0x04b1, 0x30a2 },
-  { 0x04b2, 0x30a4 },
-  { 0x04b3, 0x30a6 },
-  { 0x04b4, 0x30a8 },
-  { 0x04b5, 0x30aa },
-  { 0x04b6, 0x30ab },
-  { 0x04b7, 0x30ad },
-  { 0x04b8, 0x30af },
-  { 0x04b9, 0x30b1 },
-  { 0x04ba, 0x30b3 },
-  { 0x04bb, 0x30b5 },
-  { 0x04bc, 0x30b7 },
-  { 0x04bd, 0x30b9 },
-  { 0x04be, 0x30bb },
-  { 0x04bf, 0x30bd },
-  { 0x04c0, 0x30bf },
-  { 0x04c1, 0x30c1 },
-  { 0x04c2, 0x30c4 },
-  { 0x04c3, 0x30c6 },
-  { 0x04c4, 0x30c8 },
-  { 0x04c5, 0x30ca },
-  { 0x04c6, 0x30cb },
-  { 0x04c7, 0x30cc },
-  { 0x04c8, 0x30cd },
-  { 0x04c9, 0x30ce },
-  { 0x04ca, 0x30cf },
-  { 0x04cb, 0x30d2 },
-  { 0x04cc, 0x30d5 },
-  { 0x04cd, 0x30d8 },
-  { 0x04ce, 0x30db },
-  { 0x04cf, 0x30de },
-  { 0x04d0, 0x30df },
-  { 0x04d1, 0x30e0 },
-  { 0x04d2, 0x30e1 },
-  { 0x04d3, 0x30e2 },
-  { 0x04d4, 0x30e4 },
-  { 0x04d5, 0x30e6 },
-  { 0x04d6, 0x30e8 },
-  { 0x04d7, 0x30e9 },
-  { 0x04d8, 0x30ea },
-  { 0x04d9, 0x30eb },
-  { 0x04da, 0x30ec },
-  { 0x04db, 0x30ed },
-  { 0x04dc, 0x30ef },
-  { 0x04dd, 0x30f3 },
-  { 0x04de, 0x309b },
-  { 0x04df, 0x309c },
-  { 0x05ac, 0x060c },
-  { 0x05bb, 0x061b },
-  { 0x05bf, 0x061f },
-  { 0x05c1, 0x0621 },
-  { 0x05c2, 0x0622 },
-  { 0x05c3, 0x0623 },
-  { 0x05c4, 0x0624 },
-  { 0x05c5, 0x0625 },
-  { 0x05c6, 0x0626 },
-  { 0x05c7, 0x0627 },
-  { 0x05c8, 0x0628 },
-  { 0x05c9, 0x0629 },
-  { 0x05ca, 0x062a },
-  { 0x05cb, 0x062b },
-  { 0x05cc, 0x062c },
-  { 0x05cd, 0x062d },
-  { 0x05ce, 0x062e },
-  { 0x05cf, 0x062f },
-  { 0x05d0, 0x0630 },
-  { 0x05d1, 0x0631 },
-  { 0x05d2, 0x0632 },
-  { 0x05d3, 0x0633 },
-  { 0x05d4, 0x0634 },
-  { 0x05d5, 0x0635 },
-  { 0x05d6, 0x0636 },
-  { 0x05d7, 0x0637 },
-  { 0x05d8, 0x0638 },
-  { 0x05d9, 0x0639 },
-  { 0x05da, 0x063a },
-  { 0x05e0, 0x0640 },
-  { 0x05e1, 0x0641 },
-  { 0x05e2, 0x0642 },
-  { 0x05e3, 0x0643 },
-  { 0x05e4, 0x0644 },
-  { 0x05e5, 0x0645 },
-  { 0x05e6, 0x0646 },
-  { 0x05e7, 0x0647 },
-  { 0x05e8, 0x0648 },
-  { 0x05e9, 0x0649 },
-  { 0x05ea, 0x064a },
-  { 0x05eb, 0x064b },
-  { 0x05ec, 0x064c },
-  { 0x05ed, 0x064d },
-  { 0x05ee, 0x064e },
-  { 0x05ef, 0x064f },
-  { 0x05f0, 0x0650 },
-  { 0x05f1, 0x0651 },
-  { 0x05f2, 0x0652 },
-  { 0x06a1, 0x0452 },
-  { 0x06a2, 0x0453 },
-  { 0x06a3, 0x0451 },
-  { 0x06a4, 0x0454 },
-  { 0x06a5, 0x0455 },
-  { 0x06a6, 0x0456 },
-  { 0x06a7, 0x0457 },
-  { 0x06a8, 0x0458 },
-  { 0x06a9, 0x0459 },
-  { 0x06aa, 0x045a },
-  { 0x06ab, 0x045b },
-  { 0x06ac, 0x045c },
-  { 0x06ae, 0x045e },
-  { 0x06af, 0x045f },
-  { 0x06b0, 0x2116 },
-  { 0x06b1, 0x0402 },
-  { 0x06b2, 0x0403 },
-  { 0x06b3, 0x0401 },
-  { 0x06b4, 0x0404 },
-  { 0x06b5, 0x0405 },
-  { 0x06b6, 0x0406 },
-  { 0x06b7, 0x0407 },
-  { 0x06b8, 0x0408 },
-  { 0x06b9, 0x0409 },
-  { 0x06ba, 0x040a },
-  { 0x06bb, 0x040b },
-  { 0x06bc, 0x040c },
-  { 0x06be, 0x040e },
-  { 0x06bf, 0x040f },
-  { 0x06c0, 0x044e },
-  { 0x06c1, 0x0430 },
-  { 0x06c2, 0x0431 },
-  { 0x06c3, 0x0446 },
-  { 0x06c4, 0x0434 },
-  { 0x06c5, 0x0435 },
-  { 0x06c6, 0x0444 },
-  { 0x06c7, 0x0433 },
-  { 0x06c8, 0x0445 },
-  { 0x06c9, 0x0438 },
-  { 0x06ca, 0x0439 },
-  { 0x06cb, 0x043a },
-  { 0x06cc, 0x043b },
-  { 0x06cd, 0x043c },
-  { 0x06ce, 0x043d },
-  { 0x06cf, 0x043e },
-  { 0x06d0, 0x043f },
-  { 0x06d1, 0x044f },
-  { 0x06d2, 0x0440 },
-  { 0x06d3, 0x0441 },
-  { 0x06d4, 0x0442 },
-  { 0x06d5, 0x0443 },
-  { 0x06d6, 0x0436 },
-  { 0x06d7, 0x0432 },
-  { 0x06d8, 0x044c },
-  { 0x06d9, 0x044b },
-  { 0x06da, 0x0437 },
-  { 0x06db, 0x0448 },
-  { 0x06dc, 0x044d },
-  { 0x06dd, 0x0449 },
-  { 0x06de, 0x0447 },
-  { 0x06df, 0x044a },
-  { 0x06e0, 0x042e },
-  { 0x06e1, 0x0410 },
-  { 0x06e2, 0x0411 },
-  { 0x06e3, 0x0426 },
-  { 0x06e4, 0x0414 },
-  { 0x06e5, 0x0415 },
-  { 0x06e6, 0x0424 },
-  { 0x06e7, 0x0413 },
-  { 0x06e8, 0x0425 },
-  { 0x06e9, 0x0418 },
-  { 0x06ea, 0x0419 },
-  { 0x06eb, 0x041a },
-  { 0x06ec, 0x041b },
-  { 0x06ed, 0x041c },
-  { 0x06ee, 0x041d },
-  { 0x06ef, 0x041e },
-  { 0x06f0, 0x041f },
-  { 0x06f1, 0x042f },
-  { 0x06f2, 0x0420 },
-  { 0x06f3, 0x0421 },
-  { 0x06f4, 0x0422 },
-  { 0x06f5, 0x0423 },
-  { 0x06f6, 0x0416 },
-  { 0x06f7, 0x0412 },
-  { 0x06f8, 0x042c },
-  { 0x06f9, 0x042b },
-  { 0x06fa, 0x0417 },
-  { 0x06fb, 0x0428 },
-  { 0x06fc, 0x042d },
-  { 0x06fd, 0x0429 },
-  { 0x06fe, 0x0427 },
-  { 0x06ff, 0x042a },
-  { 0x07a1, 0x0386 },
-  { 0x07a2, 0x0388 },
-  { 0x07a3, 0x0389 },
-  { 0x07a4, 0x038a },
-  { 0x07a5, 0x03aa },
-  { 0x07a7, 0x038c },
-  { 0x07a8, 0x038e },
-  { 0x07a9, 0x03ab },
-  { 0x07ab, 0x038f },
-  { 0x07ae, 0x0385 },
-  { 0x07af, 0x2015 },
-  { 0x07b1, 0x03ac },
-  { 0x07b2, 0x03ad },
-  { 0x07b3, 0x03ae },
-  { 0x07b4, 0x03af },
-  { 0x07b5, 0x03ca },
-  { 0x07b6, 0x0390 },
-  { 0x07b7, 0x03cc },
-  { 0x07b8, 0x03cd },
-  { 0x07b9, 0x03cb },
-  { 0x07ba, 0x03b0 },
-  { 0x07bb, 0x03ce },
-  { 0x07c1, 0x0391 },
-  { 0x07c2, 0x0392 },
-  { 0x07c3, 0x0393 },
-  { 0x07c4, 0x0394 },
-  { 0x07c5, 0x0395 },
-  { 0x07c6, 0x0396 },
-  { 0x07c7, 0x0397 },
-  { 0x07c8, 0x0398 },
-  { 0x07c9, 0x0399 },
-  { 0x07ca, 0x039a },
-  { 0x07cb, 0x039b },
-  { 0x07cc, 0x039c },
-  { 0x07cd, 0x039d },
-  { 0x07ce, 0x039e },
-  { 0x07cf, 0x039f },
-  { 0x07d0, 0x03a0 },
-  { 0x07d1, 0x03a1 },
-  { 0x07d2, 0x03a3 },
-  { 0x07d4, 0x03a4 },
-  { 0x07d5, 0x03a5 },
-  { 0x07d6, 0x03a6 },
-  { 0x07d7, 0x03a7 },
-  { 0x07d8, 0x03a8 },
-  { 0x07d9, 0x03a9 },
-  { 0x07e1, 0x03b1 },
-  { 0x07e2, 0x03b2 },
-  { 0x07e3, 0x03b3 },
-  { 0x07e4, 0x03b4 },
-  { 0x07e5, 0x03b5 },
-  { 0x07e6, 0x03b6 },
-  { 0x07e7, 0x03b7 },
-  { 0x07e8, 0x03b8 },
-  { 0x07e9, 0x03b9 },
-  { 0x07ea, 0x03ba },
-  { 0x07eb, 0x03bb },
-  { 0x07ec, 0x03bc },
-  { 0x07ed, 0x03bd },
-  { 0x07ee, 0x03be },
-  { 0x07ef, 0x03bf },
-  { 0x07f0, 0x03c0 },
-  { 0x07f1, 0x03c1 },
-  { 0x07f2, 0x03c3 },
-  { 0x07f3, 0x03c2 },
-  { 0x07f4, 0x03c4 },
-  { 0x07f5, 0x03c5 },
-  { 0x07f6, 0x03c6 },
-  { 0x07f7, 0x03c7 },
-  { 0x07f8, 0x03c8 },
-  { 0x07f9, 0x03c9 },
-  { 0x08a1, 0x23b7 },
-  { 0x08a2, 0x250c },
-  { 0x08a3, 0x2500 },
-  { 0x08a4, 0x2320 },
-  { 0x08a5, 0x2321 },
-  { 0x08a6, 0x2502 },
-  { 0x08a7, 0x23a1 },
-  { 0x08a8, 0x23a3 },
-  { 0x08a9, 0x23a4 },
-  { 0x08aa, 0x23a6 },
-  { 0x08ab, 0x239b },
-  { 0x08ac, 0x239d },
-  { 0x08ad, 0x239e },
-  { 0x08ae, 0x23a0 },
-  { 0x08af, 0x23a8 },
-  { 0x08b0, 0x23ac },
-  { 0x08bc, 0x2264 },
-  { 0x08bd, 0x2260 },
-  { 0x08be, 0x2265 },
-  { 0x08bf, 0x222b },
-  { 0x08c0, 0x2234 },
-  { 0x08c1, 0x221d },
-  { 0x08c2, 0x221e },
-  { 0x08c5, 0x2207 },
-  { 0x08c8, 0x223c },
-  { 0x08c9, 0x2243 },
-  { 0x08cd, 0x21d4 },
-  { 0x08ce, 0x21d2 },
-  { 0x08cf, 0x2261 },
-  { 0x08d6, 0x221a },
-  { 0x08da, 0x2282 },
-  { 0x08db, 0x2283 },
-  { 0x08dc, 0x2229 },
-  { 0x08dd, 0x222a },
-  { 0x08de, 0x2227 },
-  { 0x08df, 0x2228 },
-  { 0x08ef, 0x2202 },
-  { 0x08f6, 0x0192 },
-  { 0x08fb, 0x2190 },
-  { 0x08fc, 0x2191 },
-  { 0x08fd, 0x2192 },
-  { 0x08fe, 0x2193 },
-  { 0x09e0, 0x25c6 },
-  { 0x09e1, 0x2592 },
-  { 0x09e2, 0x2409 },
-  { 0x09e3, 0x240c },
-  { 0x09e4, 0x240d },
-  { 0x09e5, 0x240a },
-  { 0x09e8, 0x2424 },
-  { 0x09e9, 0x240b },
-  { 0x09ea, 0x2518 },
-  { 0x09eb, 0x2510 },
-  { 0x09ec, 0x250c },
-  { 0x09ed, 0x2514 },
-  { 0x09ee, 0x253c },
-  { 0x09ef, 0x23ba },
-  { 0x09f0, 0x23bb },
-  { 0x09f1, 0x2500 },
-  { 0x09f2, 0x23bc },
-  { 0x09f3, 0x23bd },
-  { 0x09f4, 0x251c },
-  { 0x09f5, 0x2524 },
-  { 0x09f6, 0x2534 },
-  { 0x09f7, 0x252c },
-  { 0x09f8, 0x2502 },
-  { 0x0aa1, 0x2003 },
-  { 0x0aa2, 0x2002 },
-  { 0x0aa3, 0x2004 },
-  { 0x0aa4, 0x2005 },
-  { 0x0aa5, 0x2007 },
-  { 0x0aa6, 0x2008 },
-  { 0x0aa7, 0x2009 },
-  { 0x0aa8, 0x200a },
-  { 0x0aa9, 0x2014 },
-  { 0x0aaa, 0x2013 },
-  { 0x0aae, 0x2026 },
-  { 0x0aaf, 0x2025 },
-  { 0x0ab0, 0x2153 },
-  { 0x0ab1, 0x2154 },
-  { 0x0ab2, 0x2155 },
-  { 0x0ab3, 0x2156 },
-  { 0x0ab4, 0x2157 },
-  { 0x0ab5, 0x2158 },
-  { 0x0ab6, 0x2159 },
-  { 0x0ab7, 0x215a },
-  { 0x0ab8, 0x2105 },
-  { 0x0abb, 0x2012 },
-  { 0x0abc, 0x2329 },
-  { 0x0abe, 0x232a },
-  { 0x0ac3, 0x215b },
-  { 0x0ac4, 0x215c },
-  { 0x0ac5, 0x215d },
-  { 0x0ac6, 0x215e },
-  { 0x0ac9, 0x2122 },
-  { 0x0aca, 0x2613 },
-  { 0x0acc, 0x25c1 },
-  { 0x0acd, 0x25b7 },
-  { 0x0ace, 0x25cb },
-  { 0x0acf, 0x25af },
-  { 0x0ad0, 0x2018 },
-  { 0x0ad1, 0x2019 },
-  { 0x0ad2, 0x201c },
-  { 0x0ad3, 0x201d },
-  { 0x0ad4, 0x211e },
-  { 0x0ad6, 0x2032 },
-  { 0x0ad7, 0x2033 },
-  { 0x0ad9, 0x271d },
-  { 0x0adb, 0x25ac },
-  { 0x0adc, 0x25c0 },
-  { 0x0add, 0x25b6 },
-  { 0x0ade, 0x25cf },
-  { 0x0adf, 0x25ae },
-  { 0x0ae0, 0x25e6 },
-  { 0x0ae1, 0x25ab },
-  { 0x0ae2, 0x25ad },
-  { 0x0ae3, 0x25b3 },
-  { 0x0ae4, 0x25bd },
-  { 0x0ae5, 0x2606 },
-  { 0x0ae6, 0x2022 },
-  { 0x0ae7, 0x25aa },
-  { 0x0ae8, 0x25b2 },
-  { 0x0ae9, 0x25bc },
-  { 0x0aea, 0x261c },
-  { 0x0aeb, 0x261e },
-  { 0x0aec, 0x2663 },
-  { 0x0aed, 0x2666 },
-  { 0x0aee, 0x2665 },
-  { 0x0af0, 0x2720 },
-  { 0x0af1, 0x2020 },
-  { 0x0af2, 0x2021 },
-  { 0x0af3, 0x2713 },
-  { 0x0af4, 0x2717 },
-  { 0x0af5, 0x266f },
-  { 0x0af6, 0x266d },
-  { 0x0af7, 0x2642 },
-  { 0x0af8, 0x2640 },
-  { 0x0af9, 0x260e },
-  { 0x0afa, 0x2315 },
-  { 0x0afb, 0x2117 },
-  { 0x0afc, 0x2038 },
-  { 0x0afd, 0x201a },
-  { 0x0afe, 0x201e },
-  { 0x0ba3, 0x003c },
-  { 0x0ba6, 0x003e },
-  { 0x0ba8, 0x2228 },
-  { 0x0ba9, 0x2227 },
-  { 0x0bc0, 0x00af },
-  { 0x0bc2, 0x22a5 },
-  { 0x0bc3, 0x2229 },
-  { 0x0bc4, 0x230a },
-  { 0x0bc6, 0x005f },
-  { 0x0bca, 0x2218 },
-  { 0x0bcc, 0x2395 },
-  { 0x0bce, 0x22a4 },
-  { 0x0bcf, 0x25cb },
-  { 0x0bd3, 0x2308 },
-  { 0x0bd6, 0x222a },
-  { 0x0bd8, 0x2283 },
-  { 0x0bda, 0x2282 },
-  { 0x0bdc, 0x22a2 },
-  { 0x0bfc, 0x22a3 },
-  { 0x0cdf, 0x2017 },
-  { 0x0ce0, 0x05d0 },
-  { 0x0ce1, 0x05d1 },
-  { 0x0ce2, 0x05d2 },
-  { 0x0ce3, 0x05d3 },
-  { 0x0ce4, 0x05d4 },
-  { 0x0ce5, 0x05d5 },
-  { 0x0ce6, 0x05d6 },
-  { 0x0ce7, 0x05d7 },
-  { 0x0ce8, 0x05d8 },
-  { 0x0ce9, 0x05d9 },
-  { 0x0cea, 0x05da },
-  { 0x0ceb, 0x05db },
-  { 0x0cec, 0x05dc },
-  { 0x0ced, 0x05dd },
-  { 0x0cee, 0x05de },
-  { 0x0cef, 0x05df },
-  { 0x0cf0, 0x05e0 },
-  { 0x0cf1, 0x05e1 },
-  { 0x0cf2, 0x05e2 },
-  { 0x0cf3, 0x05e3 },
-  { 0x0cf4, 0x05e4 },
-  { 0x0cf5, 0x05e5 },
-  { 0x0cf6, 0x05e6 },
-  { 0x0cf7, 0x05e7 },
-  { 0x0cf8, 0x05e8 },
-  { 0x0cf9, 0x05e9 },
-  { 0x0cfa, 0x05ea },
-  { 0x0da1, 0x0e01 },
-  { 0x0da2, 0x0e02 },
-  { 0x0da3, 0x0e03 },
-  { 0x0da4, 0x0e04 },
-  { 0x0da5, 0x0e05 },
-  { 0x0da6, 0x0e06 },
-  { 0x0da7, 0x0e07 },
-  { 0x0da8, 0x0e08 },
-  { 0x0da9, 0x0e09 },
-  { 0x0daa, 0x0e0a },
-  { 0x0dab, 0x0e0b },
-  { 0x0dac, 0x0e0c },
-  { 0x0dad, 0x0e0d },
-  { 0x0dae, 0x0e0e },
-  { 0x0daf, 0x0e0f },
-  { 0x0db0, 0x0e10 },
-  { 0x0db1, 0x0e11 },
-  { 0x0db2, 0x0e12 },
-  { 0x0db3, 0x0e13 },
-  { 0x0db4, 0x0e14 },
-  { 0x0db5, 0x0e15 },
-  { 0x0db6, 0x0e16 },
-  { 0x0db7, 0x0e17 },
-  { 0x0db8, 0x0e18 },
-  { 0x0db9, 0x0e19 },
-  { 0x0dba, 0x0e1a },
-  { 0x0dbb, 0x0e1b },
-  { 0x0dbc, 0x0e1c },
-  { 0x0dbd, 0x0e1d },
-  { 0x0dbe, 0x0e1e },
-  { 0x0dbf, 0x0e1f },
-  { 0x0dc0, 0x0e20 },
-  { 0x0dc1, 0x0e21 },
-  { 0x0dc2, 0x0e22 },
-  { 0x0dc3, 0x0e23 },
-  { 0x0dc4, 0x0e24 },
-  { 0x0dc5, 0x0e25 },
-  { 0x0dc6, 0x0e26 },
-  { 0x0dc7, 0x0e27 },
-  { 0x0dc8, 0x0e28 },
-  { 0x0dc9, 0x0e29 },
-  { 0x0dca, 0x0e2a },
-  { 0x0dcb, 0x0e2b },
-  { 0x0dcc, 0x0e2c },
-  { 0x0dcd, 0x0e2d },
-  { 0x0dce, 0x0e2e },
-  { 0x0dcf, 0x0e2f },
-  { 0x0dd0, 0x0e30 },
-  { 0x0dd1, 0x0e31 },
-  { 0x0dd2, 0x0e32 },
-  { 0x0dd3, 0x0e33 },
-  { 0x0dd4, 0x0e34 },
-  { 0x0dd5, 0x0e35 },
-  { 0x0dd6, 0x0e36 },
-  { 0x0dd7, 0x0e37 },
-  { 0x0dd8, 0x0e38 },
-  { 0x0dd9, 0x0e39 },
-  { 0x0dda, 0x0e3a },
-  { 0x0ddf, 0x0e3f },
-  { 0x0de0, 0x0e40 },
-  { 0x0de1, 0x0e41 },
-  { 0x0de2, 0x0e42 },
-  { 0x0de3, 0x0e43 },
-  { 0x0de4, 0x0e44 },
-  { 0x0de5, 0x0e45 },
-  { 0x0de6, 0x0e46 },
-  { 0x0de7, 0x0e47 },
-  { 0x0de8, 0x0e48 },
-  { 0x0de9, 0x0e49 },
-  { 0x0dea, 0x0e4a },
-  { 0x0deb, 0x0e4b },
-  { 0x0dec, 0x0e4c },
-  { 0x0ded, 0x0e4d },
-  { 0x0df0, 0x0e50 },
-  { 0x0df1, 0x0e51 },
-  { 0x0df2, 0x0e52 },
-  { 0x0df3, 0x0e53 },
-  { 0x0df4, 0x0e54 },
-  { 0x0df5, 0x0e55 },
-  { 0x0df6, 0x0e56 },
-  { 0x0df7, 0x0e57 },
-  { 0x0df8, 0x0e58 },
-  { 0x0df9, 0x0e59 },
-  { 0x0ea1, 0x3131 },
-  { 0x0ea2, 0x3132 },
-  { 0x0ea3, 0x3133 },
-  { 0x0ea4, 0x3134 },
-  { 0x0ea5, 0x3135 },
-  { 0x0ea6, 0x3136 },
-  { 0x0ea7, 0x3137 },
-  { 0x0ea8, 0x3138 },
-  { 0x0ea9, 0x3139 },
-  { 0x0eaa, 0x313a },
-  { 0x0eab, 0x313b },
-  { 0x0eac, 0x313c },
-  { 0x0ead, 0x313d },
-  { 0x0eae, 0x313e },
-  { 0x0eaf, 0x313f },
-  { 0x0eb0, 0x3140 },
-  { 0x0eb1, 0x3141 },
-  { 0x0eb2, 0x3142 },
-  { 0x0eb3, 0x3143 },
-  { 0x0eb4, 0x3144 },
-  { 0x0eb5, 0x3145 },
-  { 0x0eb6, 0x3146 },
-  { 0x0eb7, 0x3147 },
-  { 0x0eb8, 0x3148 },
-  { 0x0eb9, 0x3149 },
-  { 0x0eba, 0x314a },
-  { 0x0ebb, 0x314b },
-  { 0x0ebc, 0x314c },
-  { 0x0ebd, 0x314d },
-  { 0x0ebe, 0x314e },
-  { 0x0ebf, 0x314f },
-  { 0x0ec0, 0x3150 },
-  { 0x0ec1, 0x3151 },
-  { 0x0ec2, 0x3152 },
-  { 0x0ec3, 0x3153 },
-  { 0x0ec4, 0x3154 },
-  { 0x0ec5, 0x3155 },
-  { 0x0ec6, 0x3156 },
-  { 0x0ec7, 0x3157 },
-  { 0x0ec8, 0x3158 },
-  { 0x0ec9, 0x3159 },
-  { 0x0eca, 0x315a },
-  { 0x0ecb, 0x315b },
-  { 0x0ecc, 0x315c },
-  { 0x0ecd, 0x315d },
-  { 0x0ece, 0x315e },
-  { 0x0ecf, 0x315f },
-  { 0x0ed0, 0x3160 },
-  { 0x0ed1, 0x3161 },
-  { 0x0ed2, 0x3162 },
-  { 0x0ed3, 0x3163 },
-  { 0x0ed4, 0x11a8 },
-  { 0x0ed5, 0x11a9 },
-  { 0x0ed6, 0x11aa },
-  { 0x0ed7, 0x11ab },
-  { 0x0ed8, 0x11ac },
-  { 0x0ed9, 0x11ad },
-  { 0x0eda, 0x11ae },
-  { 0x0edb, 0x11af },
-  { 0x0edc, 0x11b0 },
-  { 0x0edd, 0x11b1 },
-  { 0x0ede, 0x11b2 },
-  { 0x0edf, 0x11b3 },
-  { 0x0ee0, 0x11b4 },
-  { 0x0ee1, 0x11b5 },
-  { 0x0ee2, 0x11b6 },
-  { 0x0ee3, 0x11b7 },
-  { 0x0ee4, 0x11b8 },
-  { 0x0ee5, 0x11b9 },
-  { 0x0ee6, 0x11ba },
-  { 0x0ee7, 0x11bb },
-  { 0x0ee8, 0x11bc },
-  { 0x0ee9, 0x11bd },
-  { 0x0eea, 0x11be },
-  { 0x0eeb, 0x11bf },
-  { 0x0eec, 0x11c0 },
-  { 0x0eed, 0x11c1 },
-  { 0x0eee, 0x11c2 },
-  { 0x0eef, 0x316d },
-  { 0x0ef0, 0x3171 },
-  { 0x0ef1, 0x3178 },
-  { 0x0ef2, 0x317f },
-  { 0x0ef3, 0x3181 },
-  { 0x0ef4, 0x3184 },
-  { 0x0ef5, 0x3186 },
-  { 0x0ef6, 0x318d },
-  { 0x0ef7, 0x318e },
-  { 0x0ef8, 0x11eb },
-  { 0x0ef9, 0x11f0 },
-  { 0x0efa, 0x11f9 },
-  { 0x0eff, 0x20a9 },
-  { 0x13a4, 0x20ac },
-  { 0x13bc, 0x0152 },
-  { 0x13bd, 0x0153 },
-  { 0x13be, 0x0178 },
-  { 0x20ac, 0x20ac },
-  { 0xfe50,    '`' },
-  { 0xfe51, 0x00b4 },
-  { 0xfe52,    '^' },
-  { 0xfe53,    '~' },
-  { 0xfe54, 0x00af },
-  { 0xfe55, 0x02d8 },
-  { 0xfe56, 0x02d9 },
-  { 0xfe57, 0x00a8 },
-  { 0xfe58, 0x02da },
-  { 0xfe59, 0x02dd },
-  { 0xfe5a, 0x02c7 },
-  { 0xfe5b, 0x00b8 },
-  { 0xfe5c, 0x02db },
-  { 0xfe5d, 0x037a },
-  { 0xfe5e, 0x309b },
-  { 0xfe5f, 0x309c },
-  { 0xfe63,    '/' },
-  { 0xfe64, 0x02bc },
-  { 0xfe65, 0x02bd },
-  { 0xfe66, 0x02f5 },
-  { 0xfe67, 0x02f3 },
-  { 0xfe68, 0x02cd },
-  { 0xfe69, 0xa788 },
-  { 0xfe6a, 0x02f7 },
-  { 0xfe6e,    ',' },
-  { 0xfe6f, 0x00a4 },
-  { 0xfe80,    'a' }, // XK_dead_a
-  { 0xfe81,    'A' }, // XK_dead_A
-  { 0xfe82,    'e' }, // XK_dead_e
-  { 0xfe83,    'E' }, // XK_dead_E
-  { 0xfe84,    'i' }, // XK_dead_i
-  { 0xfe85,    'I' }, // XK_dead_I
-  { 0xfe86,    'o' }, // XK_dead_o
-  { 0xfe87,    'O' }, // XK_dead_O
-  { 0xfe88,    'u' }, // XK_dead_u
-  { 0xfe89,    'U' }, // XK_dead_U
-  { 0xfe8a, 0x0259 },
-  { 0xfe8b, 0x018f },
-  { 0xfe8c, 0x00b5 },
-  { 0xfe90,    '_' },
-  { 0xfe91, 0x02c8 },
-  { 0xfe92, 0x02cc },
-  { 0xff80 /*XKB_KEY_KP_Space*/,     ' ' },
-  { 0xff95 /*XKB_KEY_KP_7*/, 0x0037 },
-  { 0xff96 /*XKB_KEY_KP_4*/, 0x0034 },
-  { 0xff97 /*XKB_KEY_KP_8*/, 0x0038 },
-  { 0xff98 /*XKB_KEY_KP_6*/, 0x0036 },
-  { 0xff99 /*XKB_KEY_KP_2*/, 0x0032 },
-  { 0xff9a /*XKB_KEY_KP_9*/, 0x0039 },
-  { 0xff9b /*XKB_KEY_KP_3*/, 0x0033 },
-  { 0xff9c /*XKB_KEY_KP_1*/, 0x0031 },
-  { 0xff9d /*XKB_KEY_KP_5*/, 0x0035 },
-  { 0xff9e /*XKB_KEY_KP_0*/, 0x0030 },
-  { 0xffaa /*XKB_KEY_KP_Multiply*/,  '*' },
-  { 0xffab /*XKB_KEY_KP_Add*/,       '+' },
-  { 0xffac /*XKB_KEY_KP_Separator*/, ',' },
-  { 0xffad /*XKB_KEY_KP_Subtract*/,  '-' },
-  { 0xffae /*XKB_KEY_KP_Decimal*/,   '.' },
-  { 0xffaf /*XKB_KEY_KP_Divide*/,    '/' },
-  { 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 },
-  { 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 },
-  { 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 },
-  { 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 },
-  { 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 },
-  { 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 },
-  { 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 },
-  { 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 },
-  { 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 },
-  { 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 },
-  { 0xffbd /*XKB_KEY_KP_Equal*/,     '=' }
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Convert XKB KeySym to Unicode
-//
-long _glfwKeySym2Unicode(unsigned int keysym)
-{
-    int min = 0;
-    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
-    int mid;
-
-    // First check for Latin-1 characters (1:1 mapping)
-    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
-        (keysym >= 0x00a0 && keysym <= 0x00ff))
-    {
-        return keysym;
-    }
-
-    // Also check for directly encoded 24-bit UCS characters
-    if ((keysym & 0xff000000) == 0x01000000)
-        return keysym & 0x00ffffff;
-
-    // Binary search in table
-    while (max >= min)
-    {
-        mid = (min + max) / 2;
-        if (keysymtab[mid].keysym < keysym)
-            min = mid + 1;
-        else if (keysymtab[mid].keysym > keysym)
-            max = mid - 1;
-        else
-            return keysymtab[mid].ucs;
-    }
-
-    // No matching Unicode value found
-    return -1;
-}
-
diff --git a/raylib/external/glfw/src/xkb_unicode.h b/raylib/external/glfw/src/xkb_unicode.h
deleted file mode 100644 (file)
index 76d83ff..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-long _glfwKeySym2Unicode(unsigned int keysym);
-
diff --git a/raylib/external/jar_mod.h b/raylib/external/jar_mod.h
deleted file mode 100644 (file)
index eacd3b7..0000000
+++ /dev/null
@@ -1,1596 +0,0 @@
-// jar_mod.h - v0.01 - public domain C0 - Joshua Reisenauer
-//
-// HISTORY:
-//
-//   v0.01  2016-03-12  Setup
-//
-//
-// USAGE:
-//
-// In ONE source file, put:
-//
-//    #define JAR_MOD_IMPLEMENTATION
-//    #include "jar_mod.h"
-//
-// Other source files should just include jar_mod.h
-//
-// SAMPLE CODE:
-// jar_mod_context_t modctx;
-// short samplebuff[4096];
-// bool bufferFull = false;
-// int intro_load(void)
-// {
-//     jar_mod_init(&modctx);
-//     jar_mod_load_file(&modctx, "file.mod");
-//     return 1;
-// }
-// int intro_unload(void)
-// {
-//     jar_mod_unload(&modctx);
-//     return 1;
-// }
-// int intro_tick(long counter)
-// {
-//     if(!bufferFull)
-//     {
-//         jar_mod_fillbuffer(&modctx, samplebuff, 4096, 0);
-//         bufferFull=true;
-//     }
-//     if(IsKeyDown(KEY_ENTER))
-//         return 1;
-//     return 0;
-// }
-//
-//
-// LISCENSE:
-//
-// Written by: Jean-François DEL NERO (http://hxc2001.com/) <Email : jeanfrancoisdelnero <> free.fr>
-// Adapted to jar_mod by: Joshua Adam Reisenauer <kd7tck@gmail.com>
-// This program is free software. It comes without any warranty, to the
-// extent permitted by applicable law. You can redistribute it and/or
-// modify it under the terms of the Do What The Fuck You Want To Public
-// License, Version 2, as published by Sam Hocevar. See
-// http://sam.zoy.org/wtfpl/COPYING for more details.
-///////////////////////////////////////////////////////////////////////////////////
-// HxCMOD Core API:
-// -------------------------------------------
-// int  jar_mod_init(jar_mod_context_t * modctx)
-//
-// - Initialize the jar_mod_context_t buffer. Must be called before doing anything else.
-//   Return 1 if success. 0 in case of error.
-// -------------------------------------------
-// mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
-//
-// - "Load" a MOD from file, context must already be initialized.
-//   Return size of file in bytes.
-// -------------------------------------------
-// void jar_mod_fillbuffer( jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf )
-//
-// - Generate and return the next samples chunk to outbuffer.
-//   nbsample specify the number of stereo 16bits samples you want.
-//   The output format is by default signed 48000Hz 16-bit Stereo PCM samples, otherwise it is changed with jar_mod_setcfg().
-//   The output buffer size in bytes must be equal to ( nbsample * 2 * channels ).
-//   The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 is unused.
-// -------------------------------------------
-// void jar_mod_unload( jar_mod_context_t * modctx )
-// - "Unload" / clear the player status.
-// -------------------------------------------
-///////////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef INCLUDE_JAR_MOD_H
-#define INCLUDE_JAR_MOD_H
-
-// Allow custom memory allocators
-#ifndef JARMOD_MALLOC
-    #define JARMOD_MALLOC(sz)    malloc(sz)
-#endif
-#ifndef JARMOD_FREE
-    #define JARMOD_FREE(p)       free(p)
-#endif
-
-
-// Basic type
-typedef unsigned char muchar;
-typedef unsigned short muint;
-typedef short mint;
-typedef unsigned long mulong;
-
-#define NUMMAXCHANNELS 32
-#define MAXNOTES 12*12
-#define DEFAULT_SAMPLE_RATE 48000
-//
-// MOD file structures
-//
-
-#pragma pack(1)
-
-typedef struct {
-    muchar  name[22];
-    muint   length;
-    muchar  finetune;
-    muchar  volume;
-    muint   reppnt;
-    muint   replen;
-} sample;
-
-typedef struct {
-    muchar  sampperiod;
-    muchar  period;
-    muchar  sampeffect;
-    muchar  effect;
-} note;
-
-typedef struct {
-    muchar  title[20];
-    sample  samples[31];
-    muchar  length; // length of tablepos
-    muchar  protracker;
-    muchar  patterntable[128];
-    muchar  signature[4];
-    muchar  speed;
-} module;
-
-#pragma pack()
-
-//
-// HxCMod Internal structures
-//
-typedef struct {
-    char*   sampdata;
-    muint   sampnum;
-    muint   length;
-    muint   reppnt;
-    muint   replen;
-    mulong  samppos;
-    muint   period;
-    muchar  volume;
-    mulong  ticks;
-    muchar  effect;
-    muchar  parameffect;
-    muint   effect_code;
-    mint    decalperiod;
-    mint    portaspeed;
-    mint    portaperiod;
-    mint    vibraperiod;
-    mint    Arpperiods[3];
-    muchar  ArpIndex;
-    mint    oldk;
-    muchar  volumeslide;
-    muchar  vibraparam;
-    muchar  vibrapointeur;
-    muchar  finetune;
-    muchar  cut_param;
-    muint   patternloopcnt;
-    muint   patternloopstartpoint;
-} channel;
-
-typedef struct {
-    module  song;
-    char*   sampledata[31];
-    note*   patterndata[128];
-
-    mulong  playrate;
-    muint   tablepos;
-    muint   patternpos;
-    muint   patterndelay;
-    muint   jump_loop_effect;
-    muchar  bpm;
-    mulong  patternticks;
-    mulong  patterntickse;
-    mulong  patternticksaim;
-    mulong  sampleticksconst;
-    mulong  samplenb;
-    channel channels[NUMMAXCHANNELS];
-    muint   number_of_channels;
-    muint   fullperiod[MAXNOTES * 8];
-    muint   mod_loaded;
-    mint    last_r_sample;
-    mint    last_l_sample;
-    mint    stereo;
-    mint    stereo_separation;
-    mint    bits;
-    mint    filter;
-    
-    muchar *modfile; // the raw mod file
-    mulong  modfilesize;
-    muint   loopcount;
-} jar_mod_context_t;
-
-//
-// Player states structures
-//
-typedef struct track_state_
-{
-    unsigned char instrument_number;
-    unsigned short cur_period;
-    unsigned char  cur_volume;
-    unsigned short cur_effect;
-    unsigned short cur_parameffect;
-}track_state;
-
-typedef struct tracker_state_
-{
-    int number_of_tracks;
-    int bpm;
-    int speed;
-    int cur_pattern;
-    int cur_pattern_pos;
-    int cur_pattern_table_pos;
-    unsigned int buf_index;
-    track_state tracks[32];
-}tracker_state;
-
-typedef struct tracker_state_instrument_
-{
-    char name[22];
-    int  active;
-}tracker_state_instrument;
-
-typedef struct jar_mod_tracker_buffer_state_
-{
-    int  nb_max_of_state;
-    int  nb_of_state;
-    int  cur_rd_index;
-    int  sample_step;
-    char name[64];
-    tracker_state_instrument instruments[31];
-    tracker_state * track_state_buf;
-}jar_mod_tracker_buffer_state;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-bool   jar_mod_init(jar_mod_context_t * modctx);
-bool   jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
-void   jar_mod_fillbuffer(jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf);
-void   jar_mod_unload(jar_mod_context_t * modctx);
-mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename);
-mulong jar_mod_current_samples(jar_mod_context_t * modctx);
-mulong jar_mod_max_samples(jar_mod_context_t * modctx);
-void   jar_mod_seek_start(jar_mod_context_t * ctx);
-
-#ifdef __cplusplus
-}
-#endif
-//--------------------------------------------------------------------
-
-
-
-//-------------------------------------------------------------------------------
-#ifdef JAR_MOD_IMPLEMENTATION
-
-#include <stdio.h>
-#include <stdlib.h>
-//#include <stdbool.h>
-
-// Effects list
-#define EFFECT_ARPEGGIO              0x0 // Supported
-#define EFFECT_PORTAMENTO_UP         0x1 // Supported
-#define EFFECT_PORTAMENTO_DOWN       0x2 // Supported
-#define EFFECT_TONE_PORTAMENTO       0x3 // Supported
-#define EFFECT_VIBRATO               0x4 // Supported
-#define EFFECT_VOLSLIDE_TONEPORTA    0x5 // Supported
-#define EFFECT_VOLSLIDE_VIBRATO      0x6 // Supported
-#define EFFECT_VOLSLIDE_TREMOLO      0x7 // - TO BE DONE -
-#define EFFECT_SET_PANNING           0x8 // - TO BE DONE -
-#define EFFECT_SET_OFFSET            0x9 // Supported
-#define EFFECT_VOLUME_SLIDE          0xA // Supported
-#define EFFECT_JUMP_POSITION         0xB // Supported
-#define EFFECT_SET_VOLUME            0xC // Supported
-#define EFFECT_PATTERN_BREAK         0xD // Supported
-
-#define EFFECT_EXTENDED              0xE
-#define EFFECT_E_FINE_PORTA_UP       0x1 // Supported
-#define EFFECT_E_FINE_PORTA_DOWN     0x2 // Supported
-#define EFFECT_E_GLISSANDO_CTRL      0x3 // - TO BE DONE -
-#define EFFECT_E_VIBRATO_WAVEFORM    0x4 // - TO BE DONE -
-#define EFFECT_E_SET_FINETUNE        0x5 // - TO BE DONE -
-#define EFFECT_E_PATTERN_LOOP        0x6 // Supported
-#define EFFECT_E_TREMOLO_WAVEFORM    0x7 // - TO BE DONE -
-#define EFFECT_E_SET_PANNING_2       0x8 // - TO BE DONE -
-#define EFFECT_E_RETRIGGER_NOTE      0x9 // - TO BE DONE -
-#define EFFECT_E_FINE_VOLSLIDE_UP    0xA // Supported
-#define EFFECT_E_FINE_VOLSLIDE_DOWN  0xB // Supported
-#define EFFECT_E_NOTE_CUT            0xC // Supported
-#define EFFECT_E_NOTE_DELAY          0xD // - TO BE DONE -
-#define EFFECT_E_PATTERN_DELAY       0xE // Supported
-#define EFFECT_E_INVERT_LOOP         0xF // - TO BE DONE -
-#define EFFECT_SET_SPEED             0xF0 // Supported
-#define EFFECT_SET_TEMPO             0xF2 // Supported
-
-#define PERIOD_TABLE_LENGTH  MAXNOTES
-#define FULL_PERIOD_TABLE_LENGTH  ( PERIOD_TABLE_LENGTH * 8 )
-
-static const short periodtable[]=
-{
-    27392, 25856, 24384, 23040, 21696, 20480, 19328, 18240, 17216, 16256, 15360, 14496,
-    13696, 12928, 12192, 11520, 10848, 10240,  9664,  9120,  8606,  8128,  7680,  7248,
-     6848,  6464,  6096,  5760,  5424,  5120,  4832,  4560,  4304,  4064,  3840,  3624,
-     3424,  3232,  3048,  2880,  2712,  2560,  2416,  2280,  2152,  2032,  1920,  1812,
-     1712,  1616,  1524,  1440,  1356,  1280,  1208,  1140,  1076,  1016,   960,   906,
-      856,   808,   762,   720,   678,   640,   604,   570,   538,   508,   480,   453,
-      428,   404,   381,   360,   339,   320,   302,   285,   269,   254,   240,   226,
-      214,   202,   190,   180,   170,   160,   151,   143,   135,   127,   120,   113,
-      107,   101,    95,    90,    85,    80,    75,    71,    67,    63,    60,    56,
-       53,    50,    47,    45,    42,    40,    37,    35,    33,    31,    30,    28,
-       27,    25,    24,    22,    21,    20,    19,    18,    17,    16,    15,    14,
-       13,    13,    12,    11,    11,    10,     9,     9,     8,     8,     7,     7
-};
-
-static const short sintable[]={
-      0,  24,  49,  74,  97, 120, 141,161,
-    180, 197, 212, 224, 235, 244, 250,253,
-    255, 253, 250, 244, 235, 224, 212,197,
-    180, 161, 141, 120,  97,  74,  49, 24
-};
-
-typedef struct modtype_
-{
-    unsigned char signature[5];
-    int numberofchannels;
-}modtype;
-
-modtype modlist[]=
-{
-    { "M!K!",4},
-    { "M.K.",4},
-    { "FLT4",4},
-    { "FLT8",8},
-    { "4CHN",4},
-    { "6CHN",6},
-    { "8CHN",8},
-    { "10CH",10},
-    { "12CH",12},
-    { "14CH",14},
-    { "16CH",16},
-    { "18CH",18},
-    { "20CH",20},
-    { "22CH",22},
-    { "24CH",24},
-    { "26CH",26},
-    { "28CH",28},
-    { "30CH",30},
-    { "32CH",32},
-    { "",0}
-};
-
-///////////////////////////////////////////////////////////////////////////////////
-
-static void memcopy( void * dest, void *source, unsigned long size )
-{
-    unsigned long i;
-    unsigned char * d,*s;
-
-    d=(unsigned char*)dest;
-    s=(unsigned char*)source;
-    for(i=0;i<size;i++)
-    {
-        d[i]=s[i];
-    }
-}
-
-static void memclear( void * dest, unsigned char value, unsigned long size )
-{
-    unsigned long i;
-    unsigned char * d;
-
-    d=(unsigned char*)dest;
-    for(i=0;i<size;i++)
-    {
-        d[i]=value;
-    }
-}
-
-static int memcompare( unsigned char * buf1, unsigned char * buf2, unsigned int size )
-{
-    unsigned int i;
-
-    i = 0;
-
-    while(i<size)
-    {
-        if(buf1[i] != buf2[i])
-        {
-            return 0;
-        }
-        i++;
-    }
-
-    return 1;
-}
-
-static int getnote( jar_mod_context_t * mod, unsigned short period, int finetune )
-{
-    int i;
-
-    for(i = 0; i < FULL_PERIOD_TABLE_LENGTH; i++)
-    {
-        if(period >= mod->fullperiod[i])
-        {
-            return i;
-        }
-    }
-
-    return MAXNOTES;
-}
-
-static void worknote( note * nptr, channel * cptr, char t, jar_mod_context_t * mod )
-{
-    muint sample, period, effect, operiod;
-    muint curnote, arpnote;
-
-    sample = (nptr->sampperiod & 0xF0) | (nptr->sampeffect >> 4);
-    period = ((nptr->sampperiod & 0xF) << 8) | nptr->period;
-    effect = ((nptr->sampeffect & 0xF) << 8) | nptr->effect;
-
-    operiod = cptr->period;
-
-    if ( period || sample )
-    {
-        if( sample && sample < 32 )
-        {
-            cptr->sampnum = sample - 1;
-        }
-
-        if( period || sample )
-        {
-            cptr->sampdata = (char *) mod->sampledata[cptr->sampnum];
-            cptr->length = mod->song.samples[cptr->sampnum].length;
-            cptr->reppnt = mod->song.samples[cptr->sampnum].reppnt;
-            cptr->replen = mod->song.samples[cptr->sampnum].replen;
-
-            cptr->finetune = (mod->song.samples[cptr->sampnum].finetune)&0xF;
-
-            if(effect>>8!=4 && effect>>8!=6)
-            {
-                cptr->vibraperiod=0;
-                cptr->vibrapointeur=0;
-            }
-        }
-
-        if( (sample != 0) && ( (effect>>8) != EFFECT_VOLSLIDE_TONEPORTA ) )
-        {
-            cptr->volume = mod->song.samples[cptr->sampnum].volume;
-            cptr->volumeslide = 0;
-        }
-
-        if( ( (effect>>8) != EFFECT_TONE_PORTAMENTO && (effect>>8)!=EFFECT_VOLSLIDE_TONEPORTA) )
-        {
-            if (period!=0)
-                cptr->samppos = 0;
-        }
-
-        cptr->decalperiod = 0;
-        if( period )
-        {
-            if(cptr->finetune)
-            {
-                if( cptr->finetune <= 7 )
-                {
-                    period = mod->fullperiod[getnote(mod,period,0) + cptr->finetune];
-                }
-                else
-                {
-                    period = mod->fullperiod[getnote(mod,period,0) - (16 - (cptr->finetune)) ];
-                }
-            }
-
-            cptr->period = period;
-        }
-
-    }
-
-    cptr->effect = 0;
-    cptr->parameffect = 0;
-    cptr->effect_code = effect;
-
-    switch (effect >> 8)
-    {
-        case EFFECT_ARPEGGIO:
-            /*
-            [0]: Arpeggio
-            Where [0][x][y] means "play note, note+x semitones, note+y
-            semitones, then return to original note". The fluctuations are
-            carried out evenly spaced in one pattern division. They are usually
-            used to simulate chords, but this doesn't work too well. They are
-            also used to produce heavy vibrato. A major chord is when x=4, y=7.
-            A minor chord is when x=3, y=7.
-            */
-
-            if(effect&0xff)
-            {
-                cptr->effect = EFFECT_ARPEGGIO;
-                cptr->parameffect = effect&0xff;
-
-                cptr->ArpIndex = 0;
-
-                curnote = getnote(mod,cptr->period,cptr->finetune);
-
-                cptr->Arpperiods[0] = cptr->period;
-
-                arpnote = curnote + (((cptr->parameffect>>4)&0xF)*8);
-                if( arpnote >= FULL_PERIOD_TABLE_LENGTH )
-                    arpnote = FULL_PERIOD_TABLE_LENGTH - 1;
-
-                cptr->Arpperiods[1] = mod->fullperiod[arpnote];
-
-                arpnote = curnote + (((cptr->parameffect)&0xF)*8);
-                if( arpnote >= FULL_PERIOD_TABLE_LENGTH )
-                    arpnote = FULL_PERIOD_TABLE_LENGTH - 1;
-
-                cptr->Arpperiods[2] = mod->fullperiod[arpnote];
-            }
-        break;
-
-        case EFFECT_PORTAMENTO_UP:
-            /*
-            [1]: Slide up
-            Where [1][x][y] means "smoothly decrease the period of current
-            sample by x*16+y after each tick in the division". The
-            ticks/division are set with the 'set speed' effect (see below). If
-            the period of the note being played is z, then the final period
-            will be z - (x*16 + y)*(ticks - 1). As the slide rate depends on
-            the speed, changing the speed will change the slide. You cannot
-            slide beyond the note B3 (period 113).
-            */
-
-            cptr->effect = EFFECT_PORTAMENTO_UP;
-            cptr->parameffect = effect&0xff;
-        break;
-
-        case EFFECT_PORTAMENTO_DOWN:
-            /*
-            [2]: Slide down
-            Where [2][x][y] means "smoothly increase the period of current
-            sample by x*16+y after each tick in the division". Similar to [1],
-            but lowers the pitch. You cannot slide beyond the note C1 (period
-            856).
-            */
-
-            cptr->effect = EFFECT_PORTAMENTO_DOWN;
-            cptr->parameffect = effect&0xff;
-        break;
-
-        case EFFECT_TONE_PORTAMENTO:
-            /*
-            [3]: Slide to note
-            Where [3][x][y] means "smoothly change the period of current sample
-            by x*16+y after each tick in the division, never sliding beyond
-            current period". The period-length in this channel's division is a
-            parameter to this effect, and hence is not played. Sliding to a
-            note is similar to effects [1] and [2], but the slide will not go
-            beyond the given period, and the direction is implied by that
-            period. If x and y are both 0, then the old slide will continue.
-            */
-
-            cptr->effect = EFFECT_TONE_PORTAMENTO;
-            if( (effect&0xff) != 0 )
-            {
-                cptr->portaspeed = (short)(effect&0xff);
-            }
-
-            if(period!=0)
-            {
-                cptr->portaperiod = period;
-                cptr->period = operiod;
-            }
-        break;
-
-        case EFFECT_VIBRATO:
-            /*
-            [4]: Vibrato
-            Where [4][x][y] means "oscillate the sample pitch using a
-            particular waveform with amplitude y/16 semitones, such that (x *
-            ticks)/64 cycles occur in the division". The waveform is set using
-            effect [14][4]. By placing vibrato effects on consecutive
-            divisions, the vibrato effect can be maintained. If either x or y
-            are 0, then the old vibrato values will be used.
-            */
-
-            cptr->effect = EFFECT_VIBRATO;
-            if( ( effect & 0x0F ) != 0 ) // Depth continue or change ?
-                cptr->vibraparam = (cptr->vibraparam & 0xF0) | ( effect & 0x0F );
-            if( ( effect & 0xF0 ) != 0 ) // Speed continue or change ?
-                cptr->vibraparam = (cptr->vibraparam & 0x0F) | ( effect & 0xF0 );
-
-        break;
-
-        case EFFECT_VOLSLIDE_TONEPORTA:
-            /*
-            [5]: Continue 'Slide to note', but also do Volume slide
-            Where [5][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1), at the same time as continuing
-            the last 'Slide to note'". It is illegal for both x and y to be
-            non-zero. You cannot slide outside the volume range 0..64. The
-            period-length in this channel's division is a parameter to this
-            effect, and hence is not played.
-            */
-
-            if( period != 0 )
-            {
-                cptr->portaperiod = period;
-                cptr->period = operiod;
-            }
-
-            cptr->effect = EFFECT_VOLSLIDE_TONEPORTA;
-            if( ( effect & 0xFF ) != 0 )
-                cptr->volumeslide = ( effect & 0xFF );
-
-        break;
-
-        case EFFECT_VOLSLIDE_VIBRATO:
-            /*
-            [6]: Continue 'Vibrato', but also do Volume slide
-            Where [6][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1), at the same time as continuing
-            the last 'Vibrato'". It is illegal for both x and y to be non-zero.
-            You cannot slide outside the volume range 0..64.
-            */
-
-            cptr->effect = EFFECT_VOLSLIDE_VIBRATO;
-            if( (effect & 0xFF) != 0 )
-                cptr->volumeslide = (effect & 0xFF);
-        break;
-
-        case EFFECT_SET_OFFSET:
-            /*
-            [9]: Set sample offset
-            Where [9][x][y] means "play the sample from offset x*4096 + y*256".
-            The offset is measured in words. If no sample is given, yet one is
-            still playing on this channel, it should be retriggered to the new
-            offset using the current volume.
-            */
-
-            cptr->samppos = ((effect>>4) * 4096) + ((effect&0xF)*256);
-
-        break;
-
-        case EFFECT_VOLUME_SLIDE:
-            /*
-            [10]: Volume slide
-            Where [10][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1)". If both x and y are non-zero,
-            then the y value is ignored (assumed to be 0). You cannot slide
-            outside the volume range 0..64.
-            */
-
-            cptr->effect = EFFECT_VOLUME_SLIDE;
-            cptr->volumeslide = (effect & 0xFF);
-        break;
-
-        case EFFECT_JUMP_POSITION:
-            /*
-            [11]: Position Jump
-            Where [11][x][y] means "stop the pattern after this division, and
-            continue the song at song-position x*16+y". This shifts the
-            'pattern-cursor' in the pattern table (see above). Legal values for
-            x*16+y are from 0 to 127.
-            */
-
-            mod->tablepos = (effect & 0xFF);
-            if(mod->tablepos >= mod->song.length)
-            {
-                mod->tablepos = 0;
-            }
-            mod->patternpos = 0;
-            mod->jump_loop_effect = 1;
-
-        break;
-
-        case EFFECT_SET_VOLUME:
-            /*
-            [12]: Set volume
-            Where [12][x][y] means "set current sample's volume to x*16+y".
-            Legal volumes are 0..64.
-            */
-
-            cptr->volume = (effect & 0xFF);
-        break;
-
-        case EFFECT_PATTERN_BREAK:
-            /*
-            [13]: Pattern Break
-            Where [13][x][y] means "stop the pattern after this division, and
-            continue the song at the next pattern at division x*10+y" (the 10
-            is not a typo). Legal divisions are from 0 to 63 (note Protracker
-            exception above).
-            */
-
-            mod->patternpos = ( ((effect>>4)&0xF)*10 + (effect&0xF) ) * mod->number_of_channels;
-            mod->jump_loop_effect = 1;
-            mod->tablepos++;
-            if(mod->tablepos >= mod->song.length)
-            {
-                mod->tablepos = 0;
-            }
-
-        break;
-
-        case EFFECT_EXTENDED:
-            switch( (effect>>4) & 0xF )
-            {
-                case EFFECT_E_FINE_PORTA_UP:
-                    /*
-                    [14][1]: Fineslide up
-                    Where [14][1][x] means "decrement the period of the current sample
-                    by x". The incrementing takes place at the beginning of the
-                    division, and hence there is no actual sliding. You cannot slide
-                    beyond the note B3 (period 113).
-                    */
-
-                    cptr->period -= (effect & 0xF);
-                    if( cptr->period < 113 )
-                        cptr->period = 113;
-                break;
-
-                case EFFECT_E_FINE_PORTA_DOWN:
-                    /*
-                    [14][2]: Fineslide down
-                    Where [14][2][x] means "increment the period of the current sample
-                    by x". Similar to [14][1] but shifts the pitch down. You cannot
-                    slide beyond the note C1 (period 856).
-                    */
-
-                    cptr->period += (effect & 0xF);
-                    if( cptr->period > 856 )
-                        cptr->period = 856;
-                break;
-
-                case EFFECT_E_FINE_VOLSLIDE_UP:
-                    /*
-                    [14][10]: Fine volume slide up
-                    Where [14][10][x] means "increment the volume of the current sample
-                    by x". The incrementing takes place at the beginning of the
-                    division, and hence there is no sliding. You cannot slide beyond
-                    volume 64.
-                    */
-
-                    cptr->volume += (effect & 0xF);
-                    if( cptr->volume>64 )
-                        cptr->volume = 64;
-                break;
-
-                case EFFECT_E_FINE_VOLSLIDE_DOWN:
-                    /*
-                    [14][11]: Fine volume slide down
-                    Where [14][11][x] means "decrement the volume of the current sample
-                    by x". Similar to [14][10] but lowers volume. You cannot slide
-                    beyond volume 0.
-                    */
-
-                    cptr->volume -= (effect & 0xF);
-                    if( cptr->volume > 200 )
-                        cptr->volume = 0;
-                break;
-
-                case EFFECT_E_PATTERN_LOOP:
-                    /*
-                    [14][6]: Loop pattern
-                    Where [14][6][x] means "set the start of a loop to this division if
-                    x is 0, otherwise after this division, jump back to the start of a
-                    loop and play it another x times before continuing". If the start
-                    of the loop was not set, it will default to the start of the
-                    current pattern. Hence 'loop pattern' cannot be performed across
-                    multiple patterns. Note that loops do not support nesting, and you
-                    may generate an infinite loop if you try to nest 'loop pattern's.
-                    */
-
-                    if( effect & 0xF )
-                    {
-                        if( cptr->patternloopcnt )
-                        {
-                            cptr->patternloopcnt--;
-                            if( cptr->patternloopcnt )
-                            {
-                                mod->patternpos = cptr->patternloopstartpoint;
-                                mod->jump_loop_effect = 1;
-                            }
-                            else
-                            {
-                                cptr->patternloopstartpoint = mod->patternpos ;
-                            }
-                        }
-                        else
-                        {
-                            cptr->patternloopcnt = (effect & 0xF);
-                            mod->patternpos = cptr->patternloopstartpoint;
-                            mod->jump_loop_effect = 1;
-                        }
-                    }
-                    else // Start point
-                    {
-                        cptr->patternloopstartpoint = mod->patternpos;
-                    }
-
-                break;
-
-                case EFFECT_E_PATTERN_DELAY:
-                    /*
-                    [14][14]: Delay pattern
-                    Where [14][14][x] means "after this division there will be a delay
-                    equivalent to the time taken to play x divisions after which the
-                    pattern will be resumed". The delay only relates to the
-                    interpreting of new divisions, and all effects and previous notes
-                    continue during delay.
-                    */
-
-                    mod->patterndelay = (effect & 0xF);
-                break;
-
-                case EFFECT_E_NOTE_CUT:
-                    /*
-                    [14][12]: Cut sample
-                    Where [14][12][x] means "after the current sample has been played
-                    for x ticks in this division, its volume will be set to 0". This
-                    implies that if x is 0, then you will not hear any of the sample.
-                    If you wish to insert "silence" in a pattern, it is better to use a
-                    "silence"-sample (see above) due to the lack of proper support for
-                    this effect.
-                    */
-                    cptr->effect = EFFECT_E_NOTE_CUT;
-                    cptr->cut_param = (effect & 0xF);
-                    if(!cptr->cut_param)
-                        cptr->volume = 0;
-                break;
-
-                default:
-
-                break;
-            }
-        break;
-
-        case 0xF:
-            /*
-            [15]: Set speed
-            Where [15][x][y] means "set speed to x*16+y". Though it is nowhere
-            near that simple. Let z = x*16+y. Depending on what values z takes,
-            different units of speed are set, there being two: ticks/division
-            and beats/minute (though this one is only a label and not strictly
-            true). If z=0, then what should technically happen is that the
-            module stops, but in practice it is treated as if z=1, because
-            there is already a method for stopping the module (running out of
-            patterns). If z<=32, then it means "set ticks/division to z"
-            otherwise it means "set beats/minute to z" (convention says that
-            this should read "If z<32.." but there are some composers out there
-            that defy conventions). Default values are 6 ticks/division, and
-            125 beats/minute (4 divisions = 1 beat). The beats/minute tag is
-            only meaningful for 6 ticks/division. To get a more accurate view
-            of how things work, use the following formula:
-                                     24 * beats/minute
-                  divisions/minute = -----------------
-                                      ticks/division
-            Hence divisions/minute range from 24.75 to 6120, eg. to get a value
-            of 2000 divisions/minute use 3 ticks/division and 250 beats/minute.
-            If multiple "set speed" effects are performed in a single division,
-            the ones on higher-numbered channels take precedence over the ones
-            on lower-numbered channels. This effect has a large number of
-            different implementations, but the one described here has the
-            widest usage.
-            */
-
-            if( (effect&0xFF) < 0x21 )
-            {
-                if( effect&0xFF )
-                {
-                    mod->song.speed = effect&0xFF;
-                    mod->patternticksaim = (long)mod->song.speed * ((mod->playrate * 5 ) / (((long)2 * (long)mod->bpm)));
-                }
-            }
-
-            if( (effect&0xFF) >= 0x21 )
-            {
-                ///  HZ = 2 * BPM / 5
-                mod->bpm = effect&0xFF;
-                mod->patternticksaim = (long)mod->song.speed * ((mod->playrate * 5 ) / (((long)2 * (long)mod->bpm)));
-            }
-
-        break;
-
-        default:
-        // Unsupported effect
-        break;
-
-    }
-
-}
-
-static void workeffect( note * nptr, channel * cptr )
-{
-    switch(cptr->effect)
-    {
-        case EFFECT_ARPEGGIO:
-
-            if( cptr->parameffect )
-            {
-                cptr->decalperiod = cptr->period - cptr->Arpperiods[cptr->ArpIndex];
-
-                cptr->ArpIndex++;
-                if( cptr->ArpIndex>2 )
-                    cptr->ArpIndex = 0;
-            }
-        break;
-
-        case EFFECT_PORTAMENTO_UP:
-
-            if(cptr->period)
-            {
-                cptr->period -= cptr->parameffect;
-
-                if( cptr->period < 113 || cptr->period > 20000 )
-                    cptr->period = 113;
-            }
-
-        break;
-
-        case EFFECT_PORTAMENTO_DOWN:
-
-            if(cptr->period)
-            {
-                cptr->period += cptr->parameffect;
-
-                if( cptr->period > 20000 )
-                    cptr->period = 20000;
-            }
-
-        break;
-
-        case EFFECT_VOLSLIDE_TONEPORTA:
-        case EFFECT_TONE_PORTAMENTO:
-
-            if( cptr->period && ( cptr->period != cptr->portaperiod ) && cptr->portaperiod )
-            {
-                if( cptr->period > cptr->portaperiod )
-                {
-                    if( cptr->period - cptr->portaperiod >= cptr->portaspeed )
-                    {
-                        cptr->period -= cptr->portaspeed;
-                    }
-                    else
-                    {
-                        cptr->period = cptr->portaperiod;
-                    }
-                }
-                else
-                {
-                    if( cptr->portaperiod - cptr->period >= cptr->portaspeed )
-                    {
-                        cptr->period += cptr->portaspeed;
-                    }
-                    else
-                    {
-                        cptr->period = cptr->portaperiod;
-                    }
-                }
-
-                if( cptr->period == cptr->portaperiod )
-                {
-                    // If the slide is over, don't let it to be retriggered.
-                    cptr->portaperiod = 0;
-                }
-            }
-
-            if( cptr->effect == EFFECT_VOLSLIDE_TONEPORTA )
-            {
-                if( cptr->volumeslide > 0x0F )
-                {
-                    cptr->volume = cptr->volume + (cptr->volumeslide>>4);
-
-                    if(cptr->volume>63)
-                        cptr->volume = 63;
-                }
-                else
-                {
-                    cptr->volume = cptr->volume - (cptr->volumeslide);
-
-                    if(cptr->volume>63)
-                        cptr->volume=0;
-                }
-            }
-        break;
-
-        case EFFECT_VOLSLIDE_VIBRATO:
-        case EFFECT_VIBRATO:
-
-            cptr->vibraperiod = ( (cptr->vibraparam&0xF) * sintable[cptr->vibrapointeur&0x1F] )>>7;
-
-            if( cptr->vibrapointeur > 31 )
-                cptr->vibraperiod = -cptr->vibraperiod;
-
-            cptr->vibrapointeur = (cptr->vibrapointeur+(((cptr->vibraparam>>4))&0xf)) & 0x3F;
-
-            if( cptr->effect == EFFECT_VOLSLIDE_VIBRATO )
-            {
-                if( cptr->volumeslide > 0xF )
-                {
-                    cptr->volume = cptr->volume+(cptr->volumeslide>>4);
-
-                    if( cptr->volume > 64 )
-                        cptr->volume = 64;
-                }
-                else
-                {
-                    cptr->volume = cptr->volume - cptr->volumeslide;
-
-                    if( cptr->volume > 64 )
-                        cptr->volume = 0;
-                }
-            }
-
-        break;
-
-        case EFFECT_VOLUME_SLIDE:
-
-            if( cptr->volumeslide > 0xF )
-            {
-                cptr->volume += (cptr->volumeslide>>4);
-
-                if( cptr->volume > 64 )
-                    cptr->volume = 64;
-            }
-            else
-            {
-                cptr->volume -= (cptr->volumeslide&0xf);
-
-                if( cptr->volume > 64 )
-                    cptr->volume = 0;
-            }
-        break;
-
-        case EFFECT_E_NOTE_CUT:
-            if(cptr->cut_param)
-                cptr->cut_param--;
-
-            if(!cptr->cut_param)
-                cptr->volume = 0;
-        break;
-
-        default:
-        break;
-
-    }
-
-}
-
-///////////////////////////////////////////////////////////////////////////////////
-bool jar_mod_init(jar_mod_context_t * modctx)
-{
-    muint i,j;
-
-    if( modctx )
-    {
-        memclear(modctx, 0, sizeof(jar_mod_context_t));
-        modctx->playrate = DEFAULT_SAMPLE_RATE;
-        modctx->stereo = 1;
-        modctx->stereo_separation = 1;
-        modctx->bits = 16;
-        modctx->filter = 1;
-
-        for(i=0; i < PERIOD_TABLE_LENGTH - 1; i++)
-        {
-            for(j=0; j < 8; j++)
-            {
-                modctx->fullperiod[(i*8) + j] = periodtable[i] - ((( periodtable[i] - periodtable[i+1] ) / 8) * j);
-            }
-        }
-
-        return 1;
-    }
-
-    return 0;
-}
-
-bool jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter)
-{
-    if( modctx )
-    {
-        modctx->playrate = samplerate;
-
-        if( stereo )
-            modctx->stereo = 1;
-        else
-            modctx->stereo = 0;
-            
-        if(stereo_separation < 4)
-        {
-            modctx->stereo_separation = stereo_separation;
-        }
-
-        if( bits == 8 || bits == 16 )
-            modctx->bits = bits;
-        else
-            modctx->bits = 16;
-
-        if( filter )
-            modctx->filter = 1;
-        else
-            modctx->filter = 0;
-
-        return 1;
-    }
-
-    return 0;
-}
-
-// make certain that mod_data stays in memory while playing
-static bool jar_mod_load( jar_mod_context_t * modctx, void * mod_data, int mod_data_size )
-{
-    muint i, max;
-    unsigned short t;
-    sample *sptr;
-    unsigned char * modmemory,* endmodmemory;
-
-    modmemory = (unsigned char *)mod_data;
-    endmodmemory = modmemory + mod_data_size;
-    
-    
-
-    if(modmemory)
-    {
-        if( modctx )
-        {
-            memcopy(&(modctx->song.title),modmemory,1084);
-
-            i = 0;
-            modctx->number_of_channels = 0;
-            while(modlist[i].numberofchannels)
-            {
-                if(memcompare(modctx->song.signature,modlist[i].signature,4))
-                {
-                    modctx->number_of_channels = modlist[i].numberofchannels;
-                }
-
-                i++;
-            }
-
-            if( !modctx->number_of_channels )
-            {
-                // 15 Samples modules support
-                // Shift the whole datas to make it look likes a standard 4 channels mod.
-                memcopy(&(modctx->song.signature), "M.K.", 4);
-                memcopy(&(modctx->song.length), &(modctx->song.samples[15]), 130);
-                memclear(&(modctx->song.samples[15]), 0, 480);
-                modmemory += 600;
-                modctx->number_of_channels = 4;
-            }
-            else
-            {
-                modmemory += 1084;
-            }
-
-            if( modmemory >= endmodmemory )
-                return 0; // End passed ? - Probably a bad file !
-
-            // Patterns loading
-            for (i = max = 0; i < 128; i++)
-            {
-                while (max <= modctx->song.patterntable[i])
-                {
-                    modctx->patterndata[max] = (note*)modmemory;
-                    modmemory += (256*modctx->number_of_channels);
-                    max++;
-
-                    if( modmemory >= endmodmemory )
-                        return 0; // End passed ? - Probably a bad file !
-                }
-            }
-
-            for (i = 0; i < 31; i++)
-                modctx->sampledata[i]=0;
-
-            // Samples loading
-            for (i = 0, sptr = modctx->song.samples; i <31; i++, sptr++)
-            {
-                t= (sptr->length &0xFF00)>>8 | (sptr->length &0xFF)<<8;
-                sptr->length = t*2;
-
-                t= (sptr->reppnt &0xFF00)>>8 | (sptr->reppnt &0xFF)<<8;
-                sptr->reppnt = t*2;
-
-                t= (sptr->replen &0xFF00)>>8 | (sptr->replen &0xFF)<<8;
-                sptr->replen = t*2;
-
-
-                if (sptr->length == 0) continue;
-
-                modctx->sampledata[i] = (char*)modmemory;
-                modmemory += sptr->length;
-
-                if (sptr->replen + sptr->reppnt > sptr->length)
-                    sptr->replen = sptr->length - sptr->reppnt;
-
-                if( modmemory > endmodmemory )
-                    return 0; // End passed ? - Probably a bad file !
-            }
-
-            // States init
-
-            modctx->tablepos = 0;
-            modctx->patternpos = 0;
-            modctx->song.speed = 6;
-            modctx->bpm = 125;
-            modctx->samplenb = 0;
-
-            modctx->patternticks = (((long)modctx->song.speed * modctx->playrate * 5)/ (2 * modctx->bpm)) + 1;
-            modctx->patternticksaim = ((long)modctx->song.speed * modctx->playrate * 5) / (2 * modctx->bpm);
-
-            modctx->sampleticksconst = 3546894UL / modctx->playrate; //8448*428/playrate;
-
-            for(i=0; i < modctx->number_of_channels; i++)
-            {
-                modctx->channels[i].volume = 0;
-                modctx->channels[i].period = 0;
-            }
-
-            modctx->mod_loaded = 1;
-
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-void jar_mod_fillbuffer( jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf )
-{
-    unsigned long i, j;
-    unsigned long k;
-    unsigned char c;
-    unsigned int state_remaining_steps;
-    int l,r;
-    int ll,lr;
-    int tl,tr;
-    short finalperiod;
-    note    *nptr;
-    channel *cptr;
-
-    if( modctx && outbuffer )
-    {
-        if(modctx->mod_loaded)
-        {
-            state_remaining_steps = 0;
-
-            if( trkbuf )
-            {
-                trkbuf->cur_rd_index = 0;
-
-                memcopy(trkbuf->name,modctx->song.title,sizeof(modctx->song.title));
-
-                for(i=0;i<31;i++)
-                {
-                    memcopy(trkbuf->instruments[i].name,modctx->song.samples[i].name,sizeof(trkbuf->instruments[i].name));
-                }
-            }
-
-            ll = modctx->last_l_sample;
-            lr = modctx->last_r_sample;
-
-            for (i = 0; i < nbsample; i++)
-            {
-                //---------------------------------------
-                if( modctx->patternticks++ > modctx->patternticksaim )
-                {
-                    if( !modctx->patterndelay )
-                    {
-                        nptr = modctx->patterndata[modctx->song.patterntable[modctx->tablepos]];
-                        nptr = nptr + modctx->patternpos;
-                        cptr = modctx->channels;
-
-                        modctx->patternticks = 0;
-                        modctx->patterntickse = 0;
-
-                        for(c=0;c<modctx->number_of_channels;c++)
-                        {
-                            worknote((note*)(nptr+c), (channel*)(cptr+c),(char)(c+1),modctx);
-                        }
-
-                        if( !modctx->jump_loop_effect )
-                            modctx->patternpos += modctx->number_of_channels;
-                        else
-                            modctx->jump_loop_effect = 0;
-
-                        if( modctx->patternpos == 64*modctx->number_of_channels )
-                        {
-                            modctx->tablepos++;
-                            modctx->patternpos = 0;
-                            if(modctx->tablepos >= modctx->song.length)
-                            {
-                                modctx->tablepos = 0;
-                                modctx->loopcount++; // count next loop
-                            }
-                        }
-                    }
-                    else
-                    {
-                        modctx->patterndelay--;
-                        modctx->patternticks = 0;
-                        modctx->patterntickse = 0;
-                    }
-
-                }
-
-                if( modctx->patterntickse++ > (modctx->patternticksaim/modctx->song.speed) )
-                {
-                    nptr = modctx->patterndata[modctx->song.patterntable[modctx->tablepos]];
-                    nptr = nptr + modctx->patternpos;
-                    cptr = modctx->channels;
-
-                    for(c=0;c<modctx->number_of_channels;c++)
-                    {
-                        workeffect(nptr+c, cptr+c);
-                    }
-
-                    modctx->patterntickse = 0;
-                }
-
-                //---------------------------------------
-
-                if( trkbuf && !state_remaining_steps )
-                {
-                    if( trkbuf->nb_of_state < trkbuf->nb_max_of_state )
-                    {
-                        memclear(&trkbuf->track_state_buf[trkbuf->nb_of_state], 0, sizeof(tracker_state));
-                    }
-                }
-
-                l=0;
-                r=0;
-
-                for(j =0, cptr = modctx->channels; j < modctx->number_of_channels ; j++, cptr++)
-                {
-                    if( cptr->period != 0 )
-                    {
-                        finalperiod = cptr->period - cptr->decalperiod - cptr->vibraperiod;
-                        if( finalperiod )
-                        {
-                            cptr->samppos += ( (modctx->sampleticksconst<<10) / finalperiod );
-                        }
-
-                        cptr->ticks++;
-
-                        if( cptr->replen<=2 )
-                        {
-                            if( (cptr->samppos>>10) >= (cptr->length) )
-                            {
-                                cptr->length = 0;
-                                cptr->reppnt = 0;
-
-                                if( cptr->length )
-                                    cptr->samppos = cptr->samppos % (((unsigned long)cptr->length)<<10);
-                                else
-                                    cptr->samppos = 0;
-                            }
-                        }
-                        else
-                        {
-                            if( (cptr->samppos>>10) >= (unsigned long)(cptr->replen+cptr->reppnt) )
-                            {
-                                cptr->samppos = ((unsigned long)(cptr->reppnt)<<10) + (cptr->samppos % ((unsigned long)(cptr->replen+cptr->reppnt)<<10));
-                            }
-                        }
-
-                        k = cptr->samppos >> 10;
-
-                        if( cptr->sampdata!=0 && ( ((j&3)==1) || ((j&3)==2) ) )
-                        {
-                            r += ( cptr->sampdata[k] *  cptr->volume );
-                        }
-
-                        if( cptr->sampdata!=0 && ( ((j&3)==0) || ((j&3)==3) ) )
-                        {
-                            l += ( cptr->sampdata[k] *  cptr->volume );
-                        }
-
-                        if( trkbuf && !state_remaining_steps )
-                        {
-                            if( trkbuf->nb_of_state < trkbuf->nb_max_of_state )
-                            {
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].number_of_tracks = modctx->number_of_channels;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].buf_index = i;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern = modctx->song.patterntable[modctx->tablepos];
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern_pos = modctx->patternpos / modctx->number_of_channels;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern_table_pos = modctx->tablepos;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].bpm = modctx->bpm;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].speed = modctx->song.speed;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_effect = cptr->effect_code;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_parameffect = cptr->parameffect;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_period = finalperiod;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_volume = cptr->volume;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].instrument_number = (unsigned char)cptr->sampnum;
-                            }
-                        }
-                    }
-                }
-
-                if( trkbuf && !state_remaining_steps )
-                {
-                    state_remaining_steps = trkbuf->sample_step;
-
-                    if(trkbuf->nb_of_state < trkbuf->nb_max_of_state)
-                        trkbuf->nb_of_state++;
-                }
-                else
-                {
-                    state_remaining_steps--;
-                }
-
-                tl = (short)l;
-                tr = (short)r;
-
-                if ( modctx->filter )
-                {
-                    // Filter
-                    l = (l+ll)>>1;
-                    r = (r+lr)>>1;
-                }
-
-                if ( modctx->stereo_separation == 1 )
-                {
-                    // Left & Right Stereo panning
-                    l = (l+(r>>1));
-                    r = (r+(l>>1));
-                }
-
-                // Level limitation
-                if( l > 32767 ) l = 32767;
-                if( l < -32768 ) l = -32768;
-                if( r > 32767 ) r = 32767;
-                if( r < -32768 ) r = -32768;
-
-                // Store the final sample.
-                outbuffer[(i*2)]   = l;
-                outbuffer[(i*2)+1] = r;
-
-                ll = tl;
-                lr = tr;
-
-            }
-
-            modctx->last_l_sample = ll;
-            modctx->last_r_sample = lr;
-
-            modctx->samplenb = modctx->samplenb+nbsample;
-        }
-        else
-        {
-            for (i = 0; i < nbsample; i++)
-            {
-                // Mod not loaded. Return blank buffer.
-                outbuffer[(i*2)]   = 0;
-                outbuffer[(i*2)+1] = 0;
-            }
-
-            if(trkbuf)
-            {
-                trkbuf->nb_of_state = 0;
-                trkbuf->cur_rd_index = 0;
-                trkbuf->name[0] = 0;
-                memclear(trkbuf->track_state_buf, 0, sizeof(tracker_state) * trkbuf->nb_max_of_state);
-                memclear(trkbuf->instruments, 0, sizeof(trkbuf->instruments));
-            }
-        }
-    }
-}
-
-//resets internals for mod context
-static bool jar_mod_reset( jar_mod_context_t * modctx)
-{
-    if(modctx)
-    {
-        memclear(&modctx->song, 0, sizeof(modctx->song));
-        memclear(&modctx->sampledata, 0, sizeof(modctx->sampledata));
-        memclear(&modctx->patterndata, 0, sizeof(modctx->patterndata));
-        modctx->tablepos = 0;
-        modctx->patternpos = 0;
-        modctx->patterndelay  = 0;
-        modctx->jump_loop_effect = 0;
-        modctx->bpm = 0;
-        modctx->patternticks = 0;
-        modctx->patterntickse = 0;
-        modctx->patternticksaim = 0;
-        modctx->sampleticksconst = 0;
-        modctx->samplenb = 0;
-        memclear(modctx->channels, 0, sizeof(modctx->channels));
-        modctx->number_of_channels = 0;
-        modctx->mod_loaded = 0;
-        modctx->last_r_sample = 0;
-        modctx->last_l_sample = 0;
-        
-        return jar_mod_init(modctx);
-    }
-    return 0;
-}
-
-void jar_mod_unload( jar_mod_context_t * modctx)
-{
-    if(modctx)
-    {
-        if(modctx->modfile)
-        {
-            JARMOD_FREE(modctx->modfile);
-            modctx->modfile = 0;
-            modctx->modfilesize = 0;
-            modctx->loopcount = 0;
-        }
-        jar_mod_reset(modctx);
-    }
-}
-
-mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
-{
-    mulong fsize = 0;
-    if(modctx->modfile)
-    {
-        JARMOD_FREE(modctx->modfile);
-        modctx->modfile = 0;
-    }
-    
-    FILE *f = fopen(filename, "rb");
-    if(f)
-    {
-        fseek(f,0,SEEK_END);
-        fsize = ftell(f);
-        fseek(f,0,SEEK_SET);
-        
-        if(fsize && fsize < 32*1024*1024)
-        {
-            modctx->modfile = JARMOD_MALLOC(fsize);
-            modctx->modfilesize = fsize;
-            memset(modctx->modfile, 0, fsize);
-            fread(modctx->modfile, fsize, 1, f);
-            fclose(f);
-            
-            if(!jar_mod_load(modctx, (void*)modctx->modfile, fsize)) fsize = 0;
-        } else fsize = 0;
-    }
-    return fsize;
-}
-
-mulong jar_mod_current_samples(jar_mod_context_t * modctx)
-{
-    if(modctx)
-        return modctx->samplenb;
-    
-    return 0;
-}
-
-// Works, however it is very slow, this data should be cached to ensure it is run only once per file
-mulong jar_mod_max_samples(jar_mod_context_t * ctx)
-{
-    mint buff[2];
-    mulong len;
-    mulong lastcount = ctx->loopcount;
-    
-    while(ctx->loopcount <= lastcount)
-        jar_mod_fillbuffer(ctx, buff, 1, 0);
-    
-    len = ctx->samplenb;
-    jar_mod_seek_start(ctx);
-    
-    return len;
-}
-
-// move seek_val to sample index, 0 -> jar_mod_max_samples is the range
-void jar_mod_seek_start(jar_mod_context_t * ctx)
-{
-    if(ctx && ctx->modfile)
-    {
-        muchar* ftmp = ctx->modfile;
-        mulong stmp = ctx->modfilesize;
-        muint lcnt = ctx->loopcount;
-        
-        if(jar_mod_reset(ctx)){
-            jar_mod_load(ctx, ftmp, stmp);
-            ctx->modfile = ftmp;
-            ctx->modfilesize = stmp;
-            ctx->loopcount = lcnt;
-        }
-    }
-}
-
-#endif // end of JAR_MOD_IMPLEMENTATION
-//-------------------------------------------------------------------------------
-
-
-#endif //end of header file
\ No newline at end of file
diff --git a/raylib/external/jar_xm.h b/raylib/external/jar_xm.h
deleted file mode 100644 (file)
index ea7a328..0000000
+++ /dev/null
@@ -1,2470 +0,0 @@
-// jar_xm.h
-//
-// ORIGINAL LICENSE - FOR LIBXM:
-//
-// Author: Romain "Artefact2" Dalmaso <artefact2@gmail.com>
-// Contributor: Dan Spencer <dan@atomicpotato.net>
-// Repackaged into jar_xm.h By: Joshua Adam Reisenauer <kd7tck@gmail.com>
-// This program is free software. It comes without any warranty, to the
-// extent permitted by applicable law. You can redistribute it and/or
-// modify it under the terms of the Do What The Fuck You Want To Public
-// License, Version 2, as published by Sam Hocevar. See
-// http://sam.zoy.org/wtfpl/COPYING for more details.
-//
-// HISTORY:
-//   v0.1.0 2016-02-22  jar_xm.h - development by Joshua Reisenauer, MAR 2016
-//   v0.2.1 2021-03-07  m4ntr0n1c: Fix clipping noise for "bad" xm's (they will always clip), avoid clip noise and just put a ceiling)
-//   v0.2.2 2021-03-09  m4ntr0n1c: Add complete debug solution (raylib.h must be included)
-//   v0.2.3 2021-03-11  m4ntr0n1c: Fix tempo, bpm and volume on song stop / start / restart / loop
-//   v0.2.4 2021-03-17  m4ntr0n1c: Sanitize code for readability
-//   v0.2.5 2021-03-22  m4ntr0n1c: Minor adjustments
-//   v0.2.6 2021-04-01  m4ntr0n1c: Minor fixes and optimisation
-//   v0.3.0 2021-04-03  m4ntr0n1c: Addition of Stereo sample support, Linear Interpolation and Ramping now addressable options in code
-//   v0.3.1 2021-04-04  m4ntr0n1c: Volume effects column adjustments, sample offset handling adjustments
-//
-// USAGE:
-//
-// In ONE source file, put:
-//
-//    #define JAR_XM_IMPLEMENTATION
-//    #include "jar_xm.h"
-//
-// Other source files should just include jar_xm.h
-//
-// SAMPLE CODE:
-//
-// jar_xm_context_t *musicptr;
-// float musicBuffer[48000 / 60];
-// int intro_load(void)
-// {
-//     jar_xm_create_context_from_file(&musicptr, 48000, "Song.XM");
-//     return 1;
-// }
-// int intro_unload(void)
-// {
-//     jar_xm_free_context(musicptr);
-//     return 1;
-// }
-// int intro_tick(long counter)
-// {
-//     jar_xm_generate_samples(musicptr, musicBuffer, (48000 / 60) / 2);
-//     if(IsKeyDown(KEY_ENTER))
-//         return 1;
-//     return 0;
-// }
-//
-#ifndef INCLUDE_JAR_XM_H
-#define INCLUDE_JAR_XM_H
-
-#include <stdint.h>
-
-#define JAR_XM_DEBUG 0
-#define JAR_XM_DEFENSIVE 1
-//#define JAR_XM_RAYLIB 0 // set to 0 to disable the RayLib visualizer extension
-
-// Allow custom memory allocators
-#ifndef JARXM_MALLOC
-    #define JARXM_MALLOC(sz)    malloc(sz)
-#endif
-#ifndef JARXM_FREE
-    #define JARXM_FREE(p)       free(p)
-#endif
-
-//-------------------------------------------------------------------------------
-struct jar_xm_context_s;
-typedef struct jar_xm_context_s jar_xm_context_t;
-
-#ifdef __cplusplus
-extern "C" { 
-#endif
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-// * @returns 3 unable to open input file
-// * @returns 4 fseek() failed
-// * @returns 5 fread() failed
-// * @returns 6 unkown error
-// * @deprecated This function is unsafe!
-// * @see jar_xm_create_context_safe()
-int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const char* filename);
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-// * @deprecated This function is unsafe!
-// * @see jar_xm_create_context_safe()
-int jar_xm_create_context(jar_xm_context_t** ctx, const char* moddata, uint32_t rate);
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param moddata_length the length of the contents of the module, in bytes
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-int jar_xm_create_context_safe(jar_xm_context_t** ctx, const char* moddata, size_t moddata_length, uint32_t rate);
-
-//** Free a XM context created by jar_xm_create_context(). */
-void jar_xm_free_context(jar_xm_context_t* ctx);
-
-//** Play the module and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsamples);
-
-//** Play the module, resample from float to 16 bit, and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples_16bit(jar_xm_context_t* ctx, short* output, size_t numsamples) {
-    float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float));
-    jar_xm_generate_samples(ctx, musicBuffer, numsamples);
-
-    if(output){
-        for(int x=0;x<2*numsamples;x++) output[x] = (musicBuffer[x] * 32767.0f); // scale sample to signed small int
-    }
-    JARXM_FREE(musicBuffer);
-}
-
-//** Play the module, resample from float to 8 bit, and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples_8bit(jar_xm_context_t* ctx, char* output, size_t numsamples) {
-    float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float));
-    jar_xm_generate_samples(ctx, musicBuffer, numsamples);
-
-    if(output){
-        for(int x=0;x<2*numsamples;x++) output[x] = (musicBuffer[x] * 127.0f); // scale sample to signed 8 bit
-    }
-    JARXM_FREE(musicBuffer);
-}
-
-//** Set the maximum number of times a module can loop. After the specified number of loops, calls to jar_xm_generate_samples will only generate silence. You can control the current number of loops with jar_xm_get_loop_count().
-// * @param loopcnt maximum number of loops. Use 0 to loop indefinitely.
-void jar_xm_set_max_loop_count(jar_xm_context_t* ctx, uint8_t loopcnt);
-
-//** Get the loop count of the currently playing module. This value is 0 when the module is still playing, 1 when the module has looped once, etc.
-uint8_t jar_xm_get_loop_count(jar_xm_context_t* ctx);
-
-//** Mute or unmute a channel.
-// * @note Channel numbers go from 1 to jar_xm_get_number_of_channels(...).
-// * @return whether the channel was muted.
-bool jar_xm_mute_channel(jar_xm_context_t* ctx, uint16_t, bool);
-
-//** Mute or unmute an instrument.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-// * @return whether the instrument was muted.
-bool jar_xm_mute_instrument(jar_xm_context_t* ctx, uint16_t, bool);
-
-//** Get the module name as a NUL-terminated string.
-const char* jar_xm_get_module_name(jar_xm_context_t* ctx);
-
-//** Get the tracker name as a NUL-terminated string.
-const char* jar_xm_get_tracker_name(jar_xm_context_t* ctx);
-
-//** Get the number of channels.
-uint16_t jar_xm_get_number_of_channels(jar_xm_context_t* ctx);
-
-//** Get the module length (in patterns).
-uint16_t jar_xm_get_module_length(jar_xm_context_t*);
-
-//** Get the number of patterns.
-uint16_t jar_xm_get_number_of_patterns(jar_xm_context_t* ctx);
-
-//** Get the number of rows of a pattern.
-// * @note Pattern numbers go from 0 to jar_xm_get_number_of_patterns(...)-1.
-uint16_t jar_xm_get_number_of_rows(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the number of instruments.
-uint16_t jar_xm_get_number_of_instruments(jar_xm_context_t* ctx);
-
-//** Get the number of samples of an instrument.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-uint16_t jar_xm_get_number_of_samples(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the current module speed.
-// * @param bpm will receive the current BPM
-// * @param tempo will receive the current tempo (ticks per line)
-void jar_xm_get_playing_speed(jar_xm_context_t* ctx, uint16_t* bpm, uint16_t* tempo);
-
-//** Get the current position in the module being played.
-// * @param pattern_index if not NULL, will receive the current pattern index in the POT (pattern order table)
-// * @param pattern if not NULL, will receive the current pattern number
-// * @param row if not NULL, will receive the current row
-// * @param samples if not NULL, will receive the total number of
-// * generated samples (divide by sample rate to get seconds of generated audio)
-void jar_xm_get_position(jar_xm_context_t* ctx, uint8_t* pattern_index, uint8_t* pattern, uint8_t* row, uint64_t* samples);
-
-//** Get the latest time (in number of generated samples) when a particular instrument was triggered in any channel.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-uint64_t jar_xm_get_latest_trigger_of_instrument(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the latest time (in number of generated samples) when a particular sample was triggered in any channel.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-// * @note Sample numbers go from 0 to jar_xm_get_nubmer_of_samples(...,instr)-1.
-uint64_t jar_xm_get_latest_trigger_of_sample(jar_xm_context_t* ctx, uint16_t instr, uint16_t sample);
-
-//** Get the latest time (in number of generated samples) when any instrument was triggered in a given channel.
-// * @note Channel numbers go from 1 to jar_xm_get_number_of_channels(...).
-uint64_t jar_xm_get_latest_trigger_of_channel(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the number of remaining samples. Divide by 2 to get the number of individual LR data samples.
-// * @note This is the remaining number of samples before the loop starts module again, or halts if on last pass.
-// * @note This function is very slow and should only be run once, if at all.
-uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx);
-
-#ifdef __cplusplus
-}
-#endif
-//-------------------------------------------------------------------------------
-
-#ifdef JAR_XM_IMPLEMENTATION
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-
-#if JAR_XM_DEBUG            //JAR_XM_DEBUG defined as 0
-#include <stdio.h>
-#define DEBUG(fmt, ...) do {                                        \
-        fprintf(stderr, "%s(): " fmt "\n", __func__, __VA_ARGS__);    \
-        fflush(stderr);                                                \
-    } while(0)
-#else
-#define DEBUG(...)
-#endif
-
-#if jar_xm_BIG_ENDIAN
-#error "Big endian platforms are not yet supported, sorry"
-/* Make sure the compiler stops, even if #error is ignored */
-extern int __fail[-1];
-#endif
-
-/* ----- XM constants ----- */
-#define SAMPLE_NAME_LENGTH 22
-#define INSTRUMENT_NAME_LENGTH 22
-#define MODULE_NAME_LENGTH 20
-#define TRACKER_NAME_LENGTH 20
-#define PATTERN_ORDER_TABLE_LENGTH 256
-#define NUM_NOTES 96 // from 1 to 96, where 1 = C-0
-#define NUM_ENVELOPE_POINTS 12 // to be verified if 12 is the max
-#define MAX_NUM_ROWS 256
-
-#define jar_xm_SAMPLE_RAMPING_POINTS 8
-
-/* ----- Data types ----- */
-
-enum jar_xm_waveform_type_e {
-    jar_xm_SINE_WAVEFORM = 0,
-    jar_xm_RAMP_DOWN_WAVEFORM = 1,
-    jar_xm_SQUARE_WAVEFORM = 2,
-    jar_xm_RANDOM_WAVEFORM = 3,
-    jar_xm_RAMP_UP_WAVEFORM = 4,
-};
-typedef enum jar_xm_waveform_type_e jar_xm_waveform_type_t;
-
-enum jar_xm_loop_type_e {
-    jar_xm_NO_LOOP,
-    jar_xm_FORWARD_LOOP,
-    jar_xm_PING_PONG_LOOP,
-};
-typedef enum jar_xm_loop_type_e jar_xm_loop_type_t;
-
-enum jar_xm_frequency_type_e {
-    jar_xm_LINEAR_FREQUENCIES,
-    jar_xm_AMIGA_FREQUENCIES,
-};
-typedef enum jar_xm_frequency_type_e jar_xm_frequency_type_t;
-
-struct jar_xm_envelope_point_s {
-    uint16_t frame;
-    uint16_t value;
-};
-typedef struct jar_xm_envelope_point_s jar_xm_envelope_point_t;
-
-struct jar_xm_envelope_s {
-    jar_xm_envelope_point_t points[NUM_ENVELOPE_POINTS];
-    uint8_t num_points;
-    uint8_t sustain_point;
-    uint8_t loop_start_point;
-    uint8_t loop_end_point;
-    bool enabled;
-    bool sustain_enabled;
-    bool loop_enabled;
-};
-typedef struct jar_xm_envelope_s jar_xm_envelope_t;
-
-struct jar_xm_sample_s {
-    char name[SAMPLE_NAME_LENGTH + 1];
-    int8_t bits; /* Either 8 or 16 */
-    int8_t stereo;
-    uint32_t length;
-    uint32_t loop_start;
-    uint32_t loop_length;
-    uint32_t loop_end;
-    float volume;
-    int8_t finetune;
-    jar_xm_loop_type_t loop_type;
-    float panning;
-    int8_t relative_note;
-    uint64_t latest_trigger;
-
-    float* data;
- };
- typedef struct jar_xm_sample_s jar_xm_sample_t;
-
- struct jar_xm_instrument_s {
-     char name[INSTRUMENT_NAME_LENGTH + 1];
-     uint16_t num_samples;
-     uint8_t sample_of_notes[NUM_NOTES];
-     jar_xm_envelope_t volume_envelope;
-     jar_xm_envelope_t panning_envelope;
-     jar_xm_waveform_type_t vibrato_type;
-     uint8_t vibrato_sweep;
-     uint8_t vibrato_depth;
-     uint8_t vibrato_rate;
-     uint16_t volume_fadeout;
-     uint64_t latest_trigger;
-     bool muted;
-
-     jar_xm_sample_t* samples;
- };
- typedef struct jar_xm_instrument_s jar_xm_instrument_t;
-
- struct jar_xm_pattern_slot_s {
-     uint8_t note; /* 1-96, 97 = Key Off note */
-     uint8_t instrument; /* 1-128 */
-     uint8_t volume_column;
-     uint8_t effect_type;
-     uint8_t effect_param;
- };
- typedef struct jar_xm_pattern_slot_s jar_xm_pattern_slot_t;
-
- struct jar_xm_pattern_s {
-     uint16_t num_rows;
-     jar_xm_pattern_slot_t* slots; /* Array of size num_rows * num_channels */
- };
- typedef struct jar_xm_pattern_s jar_xm_pattern_t;
-
- struct jar_xm_module_s {
-     char name[MODULE_NAME_LENGTH + 1];
-     char trackername[TRACKER_NAME_LENGTH + 1];
-     uint16_t length;
-     uint16_t restart_position;
-     uint16_t num_channels;
-     uint16_t num_patterns;
-     uint16_t num_instruments;
-     uint16_t linear_interpolation;
-     uint16_t ramping;     
-     jar_xm_frequency_type_t frequency_type;
-     uint8_t pattern_table[PATTERN_ORDER_TABLE_LENGTH];
-
-     jar_xm_pattern_t* patterns;
-     jar_xm_instrument_t* instruments; /* Instrument 1 has index 0, instrument 2 has index 1, etc. */
- };
- typedef struct jar_xm_module_s jar_xm_module_t;
-
- struct jar_xm_channel_context_s {
-     float note;
-     float orig_note; /* The original note before effect modifications, as read in the pattern. */
-     jar_xm_instrument_t* instrument; /* Could be NULL */
-     jar_xm_sample_t* sample; /* Could be NULL */
-     jar_xm_pattern_slot_t* current;
-
-     float sample_position;
-     float period;
-     float frequency;
-     float step;
-     bool ping; /* For ping-pong samples: true is -->, false is <-- */
-
-     float volume; /* Ideally between 0 (muted) and 1 (loudest) */
-     float panning; /* Between 0 (left) and 1 (right); 0.5 is centered */
-
-     uint16_t autovibrato_ticks;
-
-     bool sustained;
-     float fadeout_volume;
-     float volume_envelope_volume;
-     float panning_envelope_panning;
-     uint16_t volume_envelope_frame_count;
-     uint16_t panning_envelope_frame_count;
-
-     float autovibrato_note_offset;
-
-     bool arp_in_progress;
-     uint8_t arp_note_offset;
-     uint8_t volume_slide_param;
-     uint8_t fine_volume_slide_param;
-     uint8_t global_volume_slide_param;
-     uint8_t panning_slide_param;
-     uint8_t portamento_up_param;
-     uint8_t portamento_down_param;
-     uint8_t fine_portamento_up_param;
-     uint8_t fine_portamento_down_param;
-     uint8_t extra_fine_portamento_up_param;
-     uint8_t extra_fine_portamento_down_param;
-     uint8_t tone_portamento_param;
-     float tone_portamento_target_period;
-     uint8_t multi_retrig_param;
-     uint8_t note_delay_param;
-     uint8_t pattern_loop_origin; /* Where to restart a E6y loop */
-     uint8_t pattern_loop_count; /* How many loop passes have been done */
-     bool vibrato_in_progress;
-     jar_xm_waveform_type_t vibrato_waveform;
-     bool vibrato_waveform_retrigger; /* True if a new note retriggers the waveform */
-     uint8_t vibrato_param;
-     uint16_t vibrato_ticks; /* Position in the waveform */
-     float vibrato_note_offset;
-     jar_xm_waveform_type_t tremolo_waveform;
-     bool tremolo_waveform_retrigger;
-     uint8_t tremolo_param;
-     uint8_t tremolo_ticks;
-     float tremolo_volume;
-     uint8_t tremor_param;
-     bool tremor_on;
-
-     uint64_t latest_trigger;
-     bool muted;
-
-     //* These values are updated at the end of each tick, to save a couple of float operations on every generated sample.
-     float target_panning;
-     float target_volume;
-
-     unsigned long frame_count;
-     float end_of_previous_sample_left[jar_xm_SAMPLE_RAMPING_POINTS];
-     float end_of_previous_sample_right[jar_xm_SAMPLE_RAMPING_POINTS];
-     float curr_left;
-     float curr_right;
-
-     float actual_panning;
-     float actual_volume;
- };
- typedef struct jar_xm_channel_context_s jar_xm_channel_context_t;
-
- struct jar_xm_context_s {
-     void* allocated_memory;
-     jar_xm_module_t module;
-     uint32_t rate;
-
-     uint16_t default_tempo; // Number of ticks per row
-     uint16_t default_bpm;
-     float default_global_volume;
-     
-     uint16_t tempo; // Number of ticks per row
-     uint16_t bpm;
-     float global_volume;
-
-     float volume_ramp; /* How much is a channel final volume allowed to change per sample; this is used to avoid abrubt volume changes which manifest as "clicks" in the generated sound. */
-     float panning_ramp; /* Same for panning. */
-
-     uint8_t current_table_index;
-     uint8_t current_row;
-     uint16_t current_tick; /* Can go below 255, with high tempo and a pattern delay */
-     float remaining_samples_in_tick;
-     uint64_t generated_samples;
-
-     bool position_jump;
-     bool pattern_break;
-     uint8_t jump_dest;
-     uint8_t jump_row;
-
-     uint16_t extra_ticks; /* Extra ticks to be played before going to the next row - Used for EEy effect */
-
-     uint8_t* row_loop_count; /* Array of size MAX_NUM_ROWS * module_length */
-     uint8_t loop_count;
-     uint8_t max_loop_count;
-
-     jar_xm_channel_context_t* channels;
-};
-
-#if JAR_XM_DEFENSIVE
-
-//** Check the module data for errors/inconsistencies.
-// * @returns 0 if everything looks OK. Module should be safe to load.
-int jar_xm_check_sanity_preload(const char*, size_t);
-
-//** Check a loaded module for errors/inconsistencies.
-// * @returns 0 if everything looks OK.
-int jar_xm_check_sanity_postload(jar_xm_context_t*);
-
-#endif
-
-//** Get the number of bytes needed to store the module data in a dynamically allocated blank context.
-// * Things that are dynamically allocated:
-// * - sample data
-// * - sample structures in instruments
-// * - pattern data
-// * - row loop count arrays
-// * - pattern structures in module
-// * - instrument structures in module
-// * - channel contexts
-// * - context structure itself
-// * @returns 0 if everything looks OK.
-size_t jar_xm_get_memory_needed_for_context(const char*, size_t);
-
-//** Populate the context from module data.
-// * @returns pointer to the memory pool
-char* jar_xm_load_module(jar_xm_context_t*, const char*, size_t, char*);
-
-int jar_xm_create_context(jar_xm_context_t** ctxp, const char* moddata, uint32_t rate) {
-    return jar_xm_create_context_safe(ctxp, moddata, SIZE_MAX, rate);
-}
-
-#define ALIGN(x, b) (((x) + ((b) - 1)) & ~((b) - 1))
-#define ALIGN_PTR(x, b) (void*)(((uintptr_t)(x) + ((b) - 1)) & ~((b) - 1))
-int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, size_t moddata_length, uint32_t rate) {
-#if JAR_XM_DEFENSIVE
-    int ret;
-#endif
-    size_t bytes_needed;
-    char* mempool;
-    jar_xm_context_t* ctx;
-
-#if JAR_XM_DEFENSIVE
-    if((ret = jar_xm_check_sanity_preload(moddata, moddata_length))) {
-        DEBUG("jar_xm_check_sanity_preload() returned %i, module is not safe to load", ret);
-        return 1;
-    }
-#endif
-
-    bytes_needed = jar_xm_get_memory_needed_for_context(moddata, moddata_length);
-    mempool = JARXM_MALLOC(bytes_needed);
-    if(mempool == NULL && bytes_needed > 0) { /* JARXM_MALLOC() failed, trouble ahead */
-        DEBUG("call to JARXM_MALLOC() failed, returned %p", (void*)mempool);
-        return 2;
-    }
-
-    /* Initialize most of the fields to 0, 0.f, NULL or false depending on type */
-    memset(mempool, 0, bytes_needed);
-
-    ctx = (*ctxp = (jar_xm_context_t *)mempool);
-    ctx->allocated_memory = mempool; /* Keep original pointer for JARXM_FREE() */
-    mempool += sizeof(jar_xm_context_t);
-
-    ctx->rate = rate;
-    mempool = jar_xm_load_module(ctx, moddata, moddata_length, mempool);
-    mempool = ALIGN_PTR(mempool, 16);
-
-    ctx->channels = (jar_xm_channel_context_t*)mempool;
-    mempool += ctx->module.num_channels * sizeof(jar_xm_channel_context_t);
-    mempool = ALIGN_PTR(mempool, 16);
-
-    ctx->default_global_volume = 1.f;
-    ctx->global_volume = ctx->default_global_volume;
-
-    ctx->volume_ramp = (1.f / 128.f);
-    ctx->panning_ramp = (1.f / 128.f);
-
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t *ch = ctx->channels + i;
-        ch->ping = true;
-        ch->vibrato_waveform = jar_xm_SINE_WAVEFORM;
-        ch->vibrato_waveform_retrigger = true;
-        ch->tremolo_waveform = jar_xm_SINE_WAVEFORM;
-        ch->tremolo_waveform_retrigger = true;
-        ch->volume = ch->volume_envelope_volume = ch->fadeout_volume = 1.0f;
-        ch->panning = ch->panning_envelope_panning = .5f;
-        ch->actual_volume = .0f;
-        ch->actual_panning = .5f;
-    }
-
-    mempool = ALIGN_PTR(mempool, 16);
-    ctx->row_loop_count = (uint8_t *)mempool;
-    mempool += MAX_NUM_ROWS * sizeof(uint8_t);
-
-#if JAR_XM_DEFENSIVE
-    if((ret = jar_xm_check_sanity_postload(ctx))) {   DEBUG("jar_xm_check_sanity_postload() returned %i, module is not safe to play", ret);
-        jar_xm_free_context(ctx);
-        return 1;
-    }
-#endif
-
-    return 0;
-}
-
-void jar_xm_free_context(jar_xm_context_t *ctx) {
-    if (ctx != NULL) {   JARXM_FREE(ctx->allocated_memory); }
-}
-
-void jar_xm_set_max_loop_count(jar_xm_context_t *ctx, uint8_t loopcnt) {
-    ctx->max_loop_count = loopcnt;
-}
-
-uint8_t jar_xm_get_loop_count(jar_xm_context_t *ctx) {
-    return ctx->loop_count;
-}
-
-bool jar_xm_mute_channel(jar_xm_context_t *ctx, uint16_t channel, bool mute) {
-    bool old = ctx->channels[channel - 1].muted;
-    ctx->channels[channel - 1].muted = mute;
-    return old;
-}
-
-bool jar_xm_mute_instrument(jar_xm_context_t *ctx, uint16_t instr, bool mute) {
-    bool old = ctx->module.instruments[instr - 1].muted;
-    ctx->module.instruments[instr - 1].muted = mute;
-    return old;
-}
-
-const char* jar_xm_get_module_name(jar_xm_context_t *ctx) {
-    return ctx->module.name;
-}
-
-const char* jar_xm_get_tracker_name(jar_xm_context_t *ctx) {
-    return ctx->module.trackername;
-}
-
-uint16_t jar_xm_get_number_of_channels(jar_xm_context_t *ctx) {
-    return ctx->module.num_channels;
-}
-
-uint16_t jar_xm_get_module_length(jar_xm_context_t *ctx) {
-    return ctx->module.length;
-}
-
-uint16_t jar_xm_get_number_of_patterns(jar_xm_context_t *ctx) {
-    return ctx->module.num_patterns;
-}
-
-uint16_t jar_xm_get_number_of_rows(jar_xm_context_t *ctx, uint16_t pattern) {
-    return ctx->module.patterns[pattern].num_rows;
-}
-
-uint16_t jar_xm_get_number_of_instruments(jar_xm_context_t *ctx) {
-    return ctx->module.num_instruments;
-}
-
-uint16_t jar_xm_get_number_of_samples(jar_xm_context_t *ctx, uint16_t instrument) {
-    return ctx->module.instruments[instrument - 1].num_samples;
-}
-
-void jar_xm_get_playing_speed(jar_xm_context_t *ctx, uint16_t *bpm, uint16_t *tempo) {
-    if(bpm) *bpm = ctx->bpm;
-    if(tempo) *tempo = ctx->tempo;
-}
-
-void jar_xm_get_position(jar_xm_context_t *ctx, uint8_t *pattern_index, uint8_t *pattern, uint8_t *row, uint64_t *samples) {
-    if(pattern_index) *pattern_index = ctx->current_table_index;
-    if(pattern) *pattern = ctx->module.pattern_table[ctx->current_table_index];
-    if(row) *row = ctx->current_row;
-    if(samples) *samples = ctx->generated_samples;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_instrument(jar_xm_context_t *ctx, uint16_t instr) {
-    return ctx->module.instruments[instr - 1].latest_trigger;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_sample(jar_xm_context_t *ctx, uint16_t instr, uint16_t sample) {
-    return ctx->module.instruments[instr - 1].samples[sample].latest_trigger;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_channel(jar_xm_context_t *ctx, uint16_t chn) {
-    return ctx->channels[chn - 1].latest_trigger;
-}
-
-//* .xm files are little-endian. (XXX: Are they really?)
-
-//* Bound reader macros.
-//* If we attempt to read the buffer out-of-bounds, pretend that the buffer is infinitely padded with zeroes.
-#define READ_U8(offset) (((offset) < moddata_length) ? (*(uint8_t*)(moddata + (offset))) : 0)
-#define READ_U16(offset) ((uint16_t)READ_U8(offset) | ((uint16_t)READ_U8((offset) + 1) << 8))
-#define READ_U32(offset) ((uint32_t)READ_U16(offset) | ((uint32_t)READ_U16((offset) + 2) << 16))
-#define READ_MEMCPY(ptr, offset, length) memcpy_pad(ptr, length, moddata, moddata_length, offset)
-
-static void memcpy_pad(void *dst, size_t dst_len, const void *src, size_t src_len, size_t offset) {
-    uint8_t *dst_c = dst;
-    const uint8_t *src_c = src;
-
-    /* how many bytes can be copied without overrunning `src` */
-    size_t copy_bytes = (src_len >= offset) ? (src_len - offset) : 0;
-    copy_bytes = copy_bytes > dst_len ? dst_len : copy_bytes;
-
-    memcpy(dst_c, src_c + offset, copy_bytes);
-    /* padded bytes */
-    memset(dst_c + copy_bytes, 0, dst_len - copy_bytes);
-}
-
-#if JAR_XM_DEFENSIVE
-
-int jar_xm_check_sanity_preload(const char* module, size_t module_length) {
-    if(module_length < 60) { return 4; }
-    if(memcmp("Extended Module: ", module, 17) != 0) { return 1; }
-    if(module[37] != 0x1A) { return 2; }
-    if(module[59] != 0x01 || module[58] != 0x04) { return 3; }  /* Not XM 1.04 */
-    return 0;
-}
-
-int jar_xm_check_sanity_postload(jar_xm_context_t* ctx) {
-    /* Check the POT */
-    for(uint8_t i = 0; i < ctx->module.length; ++i) {
-        if(ctx->module.pattern_table[i] >= ctx->module.num_patterns) {
-            if(i+1 == ctx->module.length && ctx->module.length > 1) {
-                DEBUG("trimming invalid POT at pos %X", i);
-                --ctx->module.length;             
-            } else {
-                DEBUG("module has invalid POT, pos %X references nonexistent pattern %X", i, ctx->module.pattern_table[i]);
-                return 1;
-            }
-        }
-    }
-
-    return 0;
-}
-
-#endif
-
-size_t jar_xm_get_memory_needed_for_context(const char* moddata, size_t moddata_length) {
-    size_t memory_needed = 0;
-    size_t offset = 60; /* 60 = Skip the first header */
-    uint16_t num_channels;
-    uint16_t num_patterns;
-    uint16_t num_instruments;
-
-    /* Read the module header */
-    num_channels = READ_U16(offset + 8);
-    num_patterns = READ_U16(offset + 10);
-    memory_needed += num_patterns * sizeof(jar_xm_pattern_t);
-    memory_needed  = ALIGN(memory_needed, 16);
-    num_instruments = READ_U16(offset + 12);
-    memory_needed += num_instruments * sizeof(jar_xm_instrument_t);
-    memory_needed  = ALIGN(memory_needed, 16);
-    memory_needed += MAX_NUM_ROWS * READ_U16(offset + 4) * sizeof(uint8_t); /* Module length */
-
-    offset += READ_U32(offset); /* Header size */
-
-    /* Read pattern headers */
-    for(uint16_t i = 0; i < num_patterns; ++i) {
-        uint16_t num_rows;
-        num_rows = READ_U16(offset + 5);
-        memory_needed += num_rows * num_channels * sizeof(jar_xm_pattern_slot_t);
-        offset += READ_U32(offset) + READ_U16(offset + 7); /* Pattern header length + packed pattern data size */
-    }
-    memory_needed  = ALIGN(memory_needed, 16);
-
-    /* Read instrument headers */
-    for(uint16_t i = 0; i < num_instruments; ++i) {
-        uint16_t num_samples;
-        uint32_t sample_header_size = 0;
-        uint32_t sample_size_aggregate = 0;
-        num_samples = READ_U16(offset + 27);
-        memory_needed += num_samples * sizeof(jar_xm_sample_t);
-        if(num_samples > 0) { sample_header_size = READ_U32(offset + 29); }
-
-        offset += READ_U32(offset);  /* Instrument header size */
-        for(uint16_t j = 0; j < num_samples; ++j) {
-            uint32_t sample_size;
-            uint8_t flags;
-            sample_size = READ_U32(offset);
-            flags = READ_U8(offset + 14);
-            sample_size_aggregate += sample_size;
-
-            if(flags & (1 << 4)) {  /* 16 bit sample */
-                memory_needed += sample_size * (sizeof(float) >> 1);
-            } else {  /* 8 bit sample */
-                memory_needed += sample_size * sizeof(float);
-            }
-            offset += sample_header_size;
-        }
-        offset += sample_size_aggregate;
-    }
-
-    memory_needed += num_channels * sizeof(jar_xm_channel_context_t);
-    memory_needed += sizeof(jar_xm_context_t);
-    return memory_needed;
-}
-
-char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t moddata_length, char* mempool) {
-    size_t offset = 0;
-    jar_xm_module_t* mod = &(ctx->module);
-
-    /* Read XM header */
-    READ_MEMCPY(mod->name, offset + 17, MODULE_NAME_LENGTH);
-    READ_MEMCPY(mod->trackername, offset + 38, TRACKER_NAME_LENGTH);
-    offset += 60;
-
-    /* Read module header */
-    uint32_t header_size = READ_U32(offset);
-    mod->length = READ_U16(offset + 4);
-    mod->restart_position = READ_U16(offset + 6);
-    mod->num_channels = READ_U16(offset + 8);
-    mod->num_patterns = READ_U16(offset + 10);
-    mod->num_instruments = READ_U16(offset + 12);
-    mod->patterns = (jar_xm_pattern_t*)mempool;
-    mod->linear_interpolation = 0; // Linear interpolation can be set after loading
-    mod->ramping = 1; // ramping can be set after loading
-    mempool += mod->num_patterns * sizeof(jar_xm_pattern_t);
-    mempool = ALIGN_PTR(mempool, 16);
-    mod->instruments = (jar_xm_instrument_t*)mempool;
-    mempool += mod->num_instruments * sizeof(jar_xm_instrument_t);
-    mempool = ALIGN_PTR(mempool, 16);
-    uint16_t flags = READ_U32(offset + 14);
-    mod->frequency_type = (flags & (1 << 0)) ? jar_xm_LINEAR_FREQUENCIES : jar_xm_AMIGA_FREQUENCIES;
-    ctx->default_tempo = READ_U16(offset + 16);
-    ctx->default_bpm = READ_U16(offset + 18);
-    ctx->tempo =ctx->default_tempo;
-    ctx->bpm = ctx->default_bpm;
-
-    READ_MEMCPY(mod->pattern_table, offset + 20, PATTERN_ORDER_TABLE_LENGTH);
-    offset += header_size;
-
-    /* Read patterns */
-    for(uint16_t i = 0; i < mod->num_patterns; ++i) {
-        uint16_t packed_patterndata_size = READ_U16(offset + 7);
-        jar_xm_pattern_t* pat = mod->patterns + i;
-        pat->num_rows = READ_U16(offset + 5);
-        pat->slots = (jar_xm_pattern_slot_t*)mempool;
-        mempool += mod->num_channels * pat->num_rows * sizeof(jar_xm_pattern_slot_t);
-        offset += READ_U32(offset); /* Pattern header length */
-        
-        if(packed_patterndata_size == 0) {    /* No pattern data is present */
-            memset(pat->slots, 0, sizeof(jar_xm_pattern_slot_t) * pat->num_rows * mod->num_channels);
-        } else {
-            /* This isn't your typical for loop */
-            for(uint16_t j = 0, k = 0; j < packed_patterndata_size; ++k) {
-                uint8_t note = READ_U8(offset + j);
-                jar_xm_pattern_slot_t* slot = pat->slots + k;
-                if(note & (1 << 7)) {
-                    /* MSB is set, this is a compressed packet */
-                    ++j;
-                    if(note & (1 << 0)) {    /* Note follows */
-                        slot->note = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->note = 0;
-                    }
-                    if(note & (1 << 1)) {    /* Instrument follows */
-                        slot->instrument = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->instrument = 0;
-                    }
-                    if(note & (1 << 2)) {    /* Volume column follows */
-                        slot->volume_column = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->volume_column = 0;
-                    }
-                    if(note & (1 << 3)) {    /* Effect follows */
-                        slot->effect_type = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->effect_type = 0;
-                    }
-                    if(note & (1 << 4)) {    /* Effect parameter follows */
-                        slot->effect_param = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->effect_param = 0;
-                    }
-                } else {    /* Uncompressed packet */
-                    slot->note = note;
-                    slot->instrument = READ_U8(offset + j + 1);
-                    slot->volume_column = READ_U8(offset + j + 2);
-                    slot->effect_type = READ_U8(offset + j + 3);
-                    slot->effect_param = READ_U8(offset + j + 4);
-                    j += 5;
-                }
-            }
-        }
-
-        offset += packed_patterndata_size;
-    }
-    mempool = ALIGN_PTR(mempool, 16);
-
-    /* Read instruments */
-    for(uint16_t i = 0; i < ctx->module.num_instruments; ++i) {
-        uint32_t sample_header_size = 0;
-        jar_xm_instrument_t* instr = mod->instruments + i;
-
-        READ_MEMCPY(instr->name, offset + 4, INSTRUMENT_NAME_LENGTH);
-        instr->num_samples = READ_U16(offset + 27);
-
-        if(instr->num_samples > 0) {
-            /* Read extra header properties */
-            sample_header_size = READ_U32(offset + 29);
-            READ_MEMCPY(instr->sample_of_notes, offset + 33, NUM_NOTES);
-
-            instr->volume_envelope.num_points = READ_U8(offset + 225);
-            instr->panning_envelope.num_points = READ_U8(offset + 226);
-
-            for(uint8_t j = 0; j < instr->volume_envelope.num_points; ++j) {
-                instr->volume_envelope.points[j].frame = READ_U16(offset + 129 + 4 * j);
-                instr->volume_envelope.points[j].value = READ_U16(offset + 129 + 4 * j + 2);
-            }
-
-            for(uint8_t j = 0; j < instr->panning_envelope.num_points; ++j) {
-                instr->panning_envelope.points[j].frame = READ_U16(offset + 177 + 4 * j);
-                instr->panning_envelope.points[j].value = READ_U16(offset + 177 + 4 * j + 2);
-            }
-
-            instr->volume_envelope.sustain_point = READ_U8(offset + 227);
-            instr->volume_envelope.loop_start_point = READ_U8(offset + 228);
-            instr->volume_envelope.loop_end_point = READ_U8(offset + 229);
-            instr->panning_envelope.sustain_point = READ_U8(offset + 230);
-            instr->panning_envelope.loop_start_point = READ_U8(offset + 231);
-            instr->panning_envelope.loop_end_point = READ_U8(offset + 232);
-
-            uint8_t flags = READ_U8(offset + 233);
-            instr->volume_envelope.enabled = flags & (1 << 0);
-            instr->volume_envelope.sustain_enabled = flags & (1 << 1);
-            instr->volume_envelope.loop_enabled = flags & (1 << 2);
-
-            flags = READ_U8(offset + 234);
-            instr->panning_envelope.enabled = flags & (1 << 0);
-            instr->panning_envelope.sustain_enabled = flags & (1 << 1);
-            instr->panning_envelope.loop_enabled = flags & (1 << 2);
-            instr->vibrato_type = READ_U8(offset + 235);
-            if(instr->vibrato_type == 2) {
-                instr->vibrato_type = 1;
-            } else if(instr->vibrato_type == 1) {
-                instr->vibrato_type = 2;
-            }
-            instr->vibrato_sweep = READ_U8(offset + 236);
-            instr->vibrato_depth = READ_U8(offset + 237);
-            instr->vibrato_rate = READ_U8(offset + 238);
-            instr->volume_fadeout = READ_U16(offset + 239);
-            instr->samples = (jar_xm_sample_t*)mempool;
-            mempool += instr->num_samples * sizeof(jar_xm_sample_t);
-        } else {
-            instr->samples = NULL;
-        }
-
-        /* Instrument header size */
-        offset += READ_U32(offset);
-
-        for(int j = 0; j < instr->num_samples; ++j) {
-            /* Read sample header */
-            jar_xm_sample_t* sample = instr->samples + j;
-
-            sample->length = READ_U32(offset);
-            sample->loop_start = READ_U32(offset + 4);
-            sample->loop_length = READ_U32(offset + 8);
-            sample->loop_end = sample->loop_start + sample->loop_length;
-            sample->volume = (float)(READ_U8(offset + 12) << 2) / 256.f;
-            if (sample->volume > 1.0f) {sample->volume = 1.f;};
-            sample->finetune = (int8_t)READ_U8(offset + 13);
-
-            uint8_t flags = READ_U8(offset + 14);
-            switch (flags & 3) {
-            case 2:
-            case 3:
-                sample->loop_type = jar_xm_PING_PONG_LOOP;
-            case 1:
-                sample->loop_type = jar_xm_FORWARD_LOOP;
-                break;
-            default:
-                sample->loop_type = jar_xm_NO_LOOP;
-                break;
-            };
-            sample->bits = (flags & 0x10) ? 16 : 8;
-            sample->stereo = (flags & 0x20) ? 1 : 0;
-            sample->panning = (float)READ_U8(offset + 15) / 255.f;
-            sample->relative_note = (int8_t)READ_U8(offset + 16);
-            READ_MEMCPY(sample->name, 18, SAMPLE_NAME_LENGTH);
-            sample->data = (float*)mempool;
-            if(sample->bits == 16) {
-                /* 16 bit sample */
-                mempool += sample->length * (sizeof(float) >> 1);
-                sample->loop_start >>= 1;
-                sample->loop_length >>= 1;
-                sample->loop_end >>= 1;
-                sample->length >>= 1;
-            } else {
-                /* 8 bit sample */
-                mempool += sample->length * sizeof(float);
-            }
-            // Adjust loop points to reflect half of the reported length (stereo)
-            if (sample->stereo && sample->loop_type != jar_xm_NO_LOOP) {
-                div_t lstart = div(READ_U32(offset + 4), 2);
-                sample->loop_start = lstart.quot;
-                div_t llength = div(READ_U32(offset + 8), 2);
-                sample->loop_length = llength.quot;
-                sample->loop_end = sample->loop_start + sample->loop_length;
-            };
-
-            offset += sample_header_size;
-        }
-
-        // Read all samples and convert them to float values
-        for(int j = 0; j < instr->num_samples; ++j) {
-            /* Read sample data */
-            jar_xm_sample_t* sample = instr->samples + j;
-            int length = sample->length;
-            if (sample->stereo) {
-                // Since it is stereo, we cut the sample in half (treated as single channel)
-                div_t result = div(sample->length, 2);
-                if(sample->bits == 16) {
-                    int16_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        if (k == result.quot) { v = 0;};
-                        v = v + (int16_t)READ_U16(offset + (k << 1));
-                        sample->data[k] = (float) v / 32768.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length << 1;
-                } else {
-                    int8_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        if (k == result.quot) { v = 0;};
-                        v = v + (int8_t)READ_U8(offset + k);
-                        sample->data[k] = (float)v  / 128.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length;
-                };
-                sample->length = result.quot;
-            } else {
-                if(sample->bits == 16) {
-                    int16_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        v = v + (int16_t)READ_U16(offset + (k << 1));
-                        sample->data[k] = (float) v / 32768.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length << 1;
-                } else {
-                    int8_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        v = v + (int8_t)READ_U8(offset + k);
-                        sample->data[k] = (float)v  / 128.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length;
-                }
-            }
-        };
-    };
-    return mempool;
-};
-
-//-------------------------------------------------------------------------------
-//THE FOLLOWING IS FOR PLAYING
-static float jar_xm_waveform(jar_xm_waveform_type_t, uint8_t);
-static void jar_xm_autovibrato(jar_xm_context_t*, jar_xm_channel_context_t*);
-static void jar_xm_vibrato(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_tremolo(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_arpeggio(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_tone_portamento(jar_xm_context_t*, jar_xm_channel_context_t*);
-static void jar_xm_pitch_slide(jar_xm_context_t*, jar_xm_channel_context_t*, float);
-static void jar_xm_panning_slide(jar_xm_channel_context_t*, uint8_t);
-static void jar_xm_volume_slide(jar_xm_channel_context_t*, uint8_t);
-
-static float jar_xm_envelope_lerp(jar_xm_envelope_point_t*, jar_xm_envelope_point_t*, uint16_t);
-static void jar_xm_envelope_tick(jar_xm_channel_context_t*, jar_xm_envelope_t*, uint16_t*, float*);
-static void jar_xm_envelopes(jar_xm_channel_context_t*);
-
-static float jar_xm_linear_period(float);
-static float jar_xm_linear_frequency(float);
-static float jar_xm_amiga_period(float);
-static float jar_xm_amiga_frequency(float);
-static float jar_xm_period(jar_xm_context_t*, float);
-static float jar_xm_frequency(jar_xm_context_t*, float, float);
-static void jar_xm_update_frequency(jar_xm_context_t*, jar_xm_channel_context_t*);
-
-static void jar_xm_handle_note_and_instrument(jar_xm_context_t*, jar_xm_channel_context_t*, jar_xm_pattern_slot_t*);
-static void jar_xm_trigger_note(jar_xm_context_t*, jar_xm_channel_context_t*, unsigned int flags);
-static void jar_xm_cut_note(jar_xm_channel_context_t*);
-static void jar_xm_key_off(jar_xm_channel_context_t*);
-
-static void jar_xm_post_pattern_change(jar_xm_context_t*);
-static void jar_xm_row(jar_xm_context_t*);
-static void jar_xm_tick(jar_xm_context_t*);
-
-static void jar_xm_next_of_sample(jar_xm_context_t*, jar_xm_channel_context_t*, int);
-static void jar_xm_mixdown(jar_xm_context_t*, float*, float*);
-
-#define jar_xm_TRIGGER_KEEP_VOLUME (1 << 0)
-#define jar_xm_TRIGGER_KEEP_PERIOD (1 << 1)
-#define jar_xm_TRIGGER_KEEP_SAMPLE_POSITION (1 << 2)
-
-                                            // C-2, C#2, D-2, D#2, E-2, F-2, F#2, G-2, G#2, A-2, A#2, B-2, C-3
-static const uint16_t amiga_frequencies[] = { 1712, 1616, 1525, 1440, 1357, 1281, 1209, 1141, 1077, 1017,  961,  907, 856 };
-
-                                            // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
-static const float multi_retrig_add[] = { 0.f, -1.f, -2.f, -4.f, -8.f, -16.f, 0.f, 0.f, 0.f, 1.f, 2.f, 4.f, 8.f, 16.f, 0.f, 0.f };
-
-                                            // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
-static const float multi_retrig_multiply[] = { 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, .6666667f, .5f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.5f, 2.f };
-
-#define jar_xm_CLAMP_UP1F(vol, limit) do {            \
-        if((vol) > (limit)) (vol) = (limit);    \
-    } while(0)
-#define jar_xm_CLAMP_UP(vol) jar_xm_CLAMP_UP1F((vol), 1.f)
-
-#define jar_xm_CLAMP_DOWN1F(vol, limit) do {        \
-        if((vol) < (limit)) (vol) = (limit);    \
-    } while(0)
-#define jar_xm_CLAMP_DOWN(vol) jar_xm_CLAMP_DOWN1F((vol), .0f)
-
-#define jar_xm_CLAMP2F(vol, up, down) do {            \
-        if((vol) > (up)) (vol) = (up);            \
-        else if((vol) < (down)) (vol) = (down); \
-    } while(0)
-#define jar_xm_CLAMP(vol) jar_xm_CLAMP2F((vol), 1.f, .0f)
-
-#define jar_xm_SLIDE_TOWARDS(val, goal, incr) do {        \
-        if((val) > (goal)) {                        \
-            (val) -= (incr);                        \
-            jar_xm_CLAMP_DOWN1F((val), (goal));            \
-        } else if((val) < (goal)) {                    \
-            (val) += (incr);                        \
-            jar_xm_CLAMP_UP1F((val), (goal));            \
-        }                                            \
-    } while(0)
-
-#define jar_xm_LERP(u, v, t) ((u) + (t) * ((v) - (u)))
-#define jar_xm_INVERSE_LERP(u, v, lerp) (((lerp) - (u)) / ((v) - (u)))
-
-#define HAS_TONE_PORTAMENTO(s) ((s)->effect_type == 3 \
-                                 || (s)->effect_type == 5 \
-                                 || ((s)->volume_column >> 4) == 0xF)
-#define HAS_ARPEGGIO(s) ((s)->effect_type == 0 \
-                          && (s)->effect_param != 0)
-#define HAS_VIBRATO(s) ((s)->effect_type == 4 \
-                         || (s)->effect_param == 6 \
-                         || ((s)->volume_column >> 4) == 0xB)
-#define NOTE_IS_VALID(n) ((n) > 0 && (n) < 97)
-#define NOTE_OFF 97
-
-static float jar_xm_waveform(jar_xm_waveform_type_t waveform, uint8_t step) {
-    static unsigned int next_rand = 24492;
-    step %= 0x40;
-    switch(waveform) {
-    case jar_xm_SINE_WAVEFORM: /* No SIN() table used, direct calculation. */
-        return -sinf(2.f * 3.141592f * (float)step / (float)0x40);
-    case jar_xm_RAMP_DOWN_WAVEFORM: /* Ramp down: 1.0f when step = 0; -1.0f when step = 0x40 */
-        return (float)(0x20 - step) / 0x20;
-    case jar_xm_SQUARE_WAVEFORM: /* Square with a 50% duty */
-        return (step >= 0x20) ? 1.f : -1.f;
-    case jar_xm_RANDOM_WAVEFORM: /* Use the POSIX.1-2001 example, just to be deterministic across different machines */
-        next_rand = next_rand * 1103515245 + 12345;
-        return (float)((next_rand >> 16) & 0x7FFF) / (float)0x4000 - 1.f;
-    case jar_xm_RAMP_UP_WAVEFORM: /* Ramp up: -1.f when step = 0; 1.f when step = 0x40 */
-        return (float)(step - 0x20) / 0x20;
-    default:
-        break;
-    }
-    return .0f;
-}
-
-static void jar_xm_autovibrato(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    if(ch->instrument == NULL || ch->instrument->vibrato_depth == 0) return;
-    jar_xm_instrument_t* instr = ch->instrument;
-    float sweep = 1.f;
-    if(ch->autovibrato_ticks < instr->vibrato_sweep) { sweep = jar_xm_LERP(0.f, 1.f, (float)ch->autovibrato_ticks / (float)instr->vibrato_sweep); }
-    unsigned int step = ((ch->autovibrato_ticks++) * instr->vibrato_rate) >> 2;
-    ch->autovibrato_note_offset = .25f * jar_xm_waveform(instr->vibrato_type, step) * (float)instr->vibrato_depth / (float)0xF * sweep;
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_vibrato(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t pos) {
-    unsigned int step = pos * (param >> 4);
-    ch->vibrato_note_offset = 2.f * jar_xm_waveform(ch->vibrato_waveform, step) * (float)(param & 0x0F) / (float)0xF;
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_tremolo(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t pos) {
-    unsigned int step = pos * (param >> 4);
-    ch->tremolo_volume = -1.f * jar_xm_waveform(ch->tremolo_waveform, step) * (float)(param & 0x0F) / (float)0xF;
-}
-
-static void jar_xm_arpeggio(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t tick) {
-    switch(tick % 3) {
-    case 0:
-        ch->arp_in_progress = false;
-        ch->arp_note_offset = 0;
-        break;
-    case 2:
-        ch->arp_in_progress = true;
-        ch->arp_note_offset = param >> 4;
-        break;
-    case 1:
-        ch->arp_in_progress = true;
-        ch->arp_note_offset = param & 0x0F;
-        break;
-    }
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_tone_portamento(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    /* 3xx called without a note, wait until we get an actual target note. */
-    if(ch->tone_portamento_target_period == 0.f) return;  /* no value, exit */
-    if(ch->period != ch->tone_portamento_target_period) {
-        jar_xm_SLIDE_TOWARDS(ch->period, ch->tone_portamento_target_period, (ctx->module.frequency_type == jar_xm_LINEAR_FREQUENCIES ? 4.f : 1.f) * ch->tone_portamento_param);
-        jar_xm_update_frequency(ctx, ch);
-    }
-}
-
-static void jar_xm_pitch_slide(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, float period_offset) {
-    /* Don't ask about the 4.f coefficient. I found mention of it nowhere. Found by earâ„¢. */
-    if(ctx->module.frequency_type == jar_xm_LINEAR_FREQUENCIES) {period_offset *= 4.f; }
-    ch->period += period_offset;
-    jar_xm_CLAMP_DOWN(ch->period);
-    /* XXX: upper bound of period ? */
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_panning_slide(jar_xm_channel_context_t* ch, uint8_t rawval) {
-    if (rawval & 0xF0) {ch->panning += (float)((rawval & 0xF0 )>> 4) / (float)0xFF;};
-    if (rawval & 0x0F) {ch->panning -= (float)(rawval & 0x0F) / (float)0xFF;};
-};
-
-static void jar_xm_volume_slide(jar_xm_channel_context_t* ch, uint8_t rawval) {
-    if (rawval & 0xF0) {ch->volume += (float)((rawval & 0xF0) >> 4) / (float)0x40;};
-    if (rawval & 0x0F) {ch->volume -= (float)(rawval & 0x0F) / (float)0x40;};
-};
-
-static float jar_xm_envelope_lerp(jar_xm_envelope_point_t* a, jar_xm_envelope_point_t* b, uint16_t pos) {
-    /* Linear interpolation between two envelope points */
-    if(pos <= a->frame) return a->value;
-    else if(pos >= b->frame) return b->value;
-    else {
-        float p = (float)(pos - a->frame) / (float)(b->frame - a->frame);
-        return a->value * (1 - p) + b->value * p;
-    }
-}
-
-static void jar_xm_post_pattern_change(jar_xm_context_t* ctx) {
-    /* Loop if necessary */
-    if(ctx->current_table_index >= ctx->module.length) {
-        ctx->current_table_index = ctx->module.restart_position;
-        ctx->tempo =ctx->default_tempo; // reset to file default value 
-        ctx->bpm = ctx->default_bpm; // reset to file default value
-        ctx->global_volume = ctx->default_global_volume; // reset to file default value
-    }
-}
-
-static float jar_xm_linear_period(float note) {
-    return 7680.f - note * 64.f;
-}
-
-static float jar_xm_linear_frequency(float period) {
-    return 8363.f * powf(2.f, (4608.f - period) / 768.f);
-}
-
-static float jar_xm_amiga_period(float note) {
-    unsigned int intnote = note;
-    uint8_t a = intnote % 12;
-    int8_t octave = note / 12.f - 2;
-    uint16_t p1 = amiga_frequencies[a], p2 = amiga_frequencies[a + 1];
-    if(octave > 0) {
-        p1 >>= octave;
-        p2 >>= octave;
-    } else if(octave < 0) {
-        p1 <<= -octave;
-        p2 <<= -octave;
-    }
-    return jar_xm_LERP(p1, p2, note - intnote);
-}
-
-static float jar_xm_amiga_frequency(float period) {
-    if(period == .0f) return .0f;
-    return 7093789.2f / (period * 2.f); /* This is the PAL value. (we could use the NTSC value also) */
-}
-
-static float jar_xm_period(jar_xm_context_t* ctx, float note) {
-    switch(ctx->module.frequency_type) {
-    case jar_xm_LINEAR_FREQUENCIES:
-        return jar_xm_linear_period(note);
-    case jar_xm_AMIGA_FREQUENCIES:
-        return jar_xm_amiga_period(note);
-    }
-    return .0f;
-}
-
-static float jar_xm_frequency(jar_xm_context_t* ctx, float period, float note_offset) {
-    switch(ctx->module.frequency_type) {
-    case jar_xm_LINEAR_FREQUENCIES:
-        return jar_xm_linear_frequency(period - 64.f * note_offset);
-    case jar_xm_AMIGA_FREQUENCIES:
-        if(note_offset == 0) { return jar_xm_amiga_frequency(period); };
-        int8_t octave;
-        float  note;
-        uint16_t p1, p2;
-        uint8_t a = octave = 0;
-
-        /* Find the octave of the current period */
-        if(period > amiga_frequencies[0]) {
-            --octave;
-            while(period > (amiga_frequencies[0] << -octave)) --octave;
-        } else if(period < amiga_frequencies[12]) {
-            ++octave;
-            while(period < (amiga_frequencies[12] >> octave)) ++octave;
-        }
-
-        /* Find the smallest note closest to the current period */
-        for(uint8_t i = 0; i < 12; ++i) {
-            p1 = amiga_frequencies[i], p2 = amiga_frequencies[i + 1];
-            if(octave > 0) {
-                p1 >>= octave;
-                p2 >>= octave;
-            } else if(octave < 0) {
-                p1 <<= (-octave);
-                p2 <<= (-octave);
-            }
-            if(p2 <= period && period <= p1) {
-                a = i;
-                break;
-            }
-        }
-        if(JAR_XM_DEBUG && (p1 < period || p2 > period)) { DEBUG("%i <= %f <= %i should hold but doesn't, this is a bug", p2, period, p1); }
-        note = 12.f * (octave + 2) + a + jar_xm_INVERSE_LERP(p1, p2, period);
-        return jar_xm_amiga_frequency(jar_xm_amiga_period(note + note_offset));
-    }
-
-    return .0f;
-}
-
-static void jar_xm_update_frequency(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    ch->frequency = jar_xm_frequency( ctx, ch->period, (ch->arp_note_offset > 0 ? ch->arp_note_offset : (  ch->vibrato_note_offset + ch->autovibrato_note_offset ))  );
-    ch->step = ch->frequency / ctx->rate;
-}
-
-static void jar_xm_handle_note_and_instrument(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, jar_xm_pattern_slot_t* s) {
-    jar_xm_module_t* mod = &(ctx->module);
-    if(s->instrument > 0) {
-        if(HAS_TONE_PORTAMENTO(ch->current) && ch->instrument != NULL && ch->sample != NULL) {  /* Tone portamento in effect */
-            jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_PERIOD | jar_xm_TRIGGER_KEEP_SAMPLE_POSITION);
-        } else if(s->instrument > ctx->module.num_instruments) {    /* Invalid instrument, Cut current note */
-            jar_xm_cut_note(ch);
-            ch->instrument = NULL;
-            ch->sample = NULL;
-        } else {
-            ch->instrument = ctx->module.instruments + (s->instrument - 1);
-            if(s->note == 0 && ch->sample != NULL) {  /* Ghost instrument, trigger note */
-                /* Sample position is kept, but envelopes are reset */
-                jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_SAMPLE_POSITION);
-            }
-        }
-    }
-
-    if(NOTE_IS_VALID(s->note)) {
-        // note value is s->note -1
-        jar_xm_instrument_t* instr = ch->instrument;
-        if(HAS_TONE_PORTAMENTO(ch->current) && instr != NULL && ch->sample != NULL) {
-            /* Tone portamento in effect */
-            ch->note = s->note + ch->sample->relative_note + ch->sample->finetune / 128.f - 1.f;
-            ch->tone_portamento_target_period = jar_xm_period(ctx, ch->note);
-        } else if(instr == NULL || ch->instrument->num_samples == 0) {   /* Issue on instrument */
-            jar_xm_cut_note(ch);
-        } else {
-            if(instr->sample_of_notes[s->note - 1] < instr->num_samples) {
-                if (mod->ramping) {
-                    for(int i = 0; i < jar_xm_SAMPLE_RAMPING_POINTS; ++i) {
-                        jar_xm_next_of_sample(ctx, ch, i);
-                    }
-                    ch->frame_count = 0;
-                };
-                ch->sample = instr->samples + instr->sample_of_notes[s->note - 1];
-                ch->orig_note = ch->note = s->note + ch->sample->relative_note + ch->sample->finetune / 128.f - 1.f;
-                if(s->instrument > 0) {
-                    jar_xm_trigger_note(ctx, ch, 0);
-                } else {  /* Ghost note: keep old volume */
-                    jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_VOLUME);
-                }
-            } else {
-                jar_xm_cut_note(ch);
-            }
-        }
-    } else if(s->note == NOTE_OFF) {
-        jar_xm_key_off(ch);
-    }
-
-    // Interpret Effect column
-    switch(s->effect_type) {
-    case 1: /* 1xx: Portamento up */
-        if(s->effect_param > 0) {    ch->portamento_up_param = s->effect_param; }
-        break;
-    case 2: /* 2xx: Portamento down */
-        if(s->effect_param > 0) {    ch->portamento_down_param = s->effect_param; }
-        break;
-    case 3: /* 3xx: Tone portamento */
-        if(s->effect_param > 0) {    ch->tone_portamento_param = s->effect_param; }
-        break;
-    case 4: /* 4xy: Vibrato */
-        if(s->effect_param & 0x0F) { ch->vibrato_param = (ch->vibrato_param & 0xF0) | (s->effect_param & 0x0F); }  /* Set vibrato depth */
-        if(s->effect_param >> 4) { ch->vibrato_param = (s->effect_param & 0xF0) | (ch->vibrato_param & 0x0F); }   /* Set vibrato speed */
-        break;
-    case 5: /* 5xy: Tone portamento + Volume slide */
-        if(s->effect_param > 0) {  ch->volume_slide_param = s->effect_param; }
-        break;
-    case 6: /* 6xy: Vibrato + Volume slide */
-        if(s->effect_param > 0) {    ch->volume_slide_param = s->effect_param; }
-        break;
-    case 7: /* 7xy: Tremolo */
-        if(s->effect_param & 0x0F) { ch->tremolo_param = (ch->tremolo_param & 0xF0) | (s->effect_param & 0x0F); } /* Set tremolo depth */
-        if(s->effect_param >> 4) { ch->tremolo_param = (s->effect_param & 0xF0) | (ch->tremolo_param & 0x0F); }  /* Set tremolo speed */
-        break;
-    case 8: /* 8xx: Set panning */
-        ch->panning = (float)s->effect_param / 255.f;
-        break;
-    case 9: /* 9xx: Sample offset */
-        if(ch->sample != 0) { //&& NOTE_IS_VALID(s->note)) {
-            uint32_t final_offset = s->effect_param << (ch->sample->bits == 16 ? 7 : 8);
-            switch (ch->sample->loop_type) {
-            case jar_xm_NO_LOOP:
-                if(final_offset >= ch->sample->length) { /* Pretend the sample dosen't loop and is done playing */
-                    ch->sample_position = -1;
-                } else {
-                    ch->sample_position = final_offset;
-                }
-                break;
-            case jar_xm_FORWARD_LOOP:
-                if (final_offset >= ch->sample->loop_end) {
-                    ch->sample_position -= ch->sample->loop_length;
-                } else if(final_offset >= ch->sample->length) {
-                    ch->sample_position = ch->sample->loop_start;
-                } else {
-                    ch->sample_position = final_offset;
-                }
-                break;
-            case jar_xm_PING_PONG_LOOP:
-                if(final_offset >= ch->sample->loop_end) {
-                    ch->ping = false;
-                    ch->sample_position = (ch->sample->loop_end << 1) - ch->sample_position;
-                } else if(final_offset >= ch->sample->length) {
-                    ch->ping = false;
-                    ch->sample_position -= ch->sample->length - 1;
-                } else {
-                    ch->sample_position = final_offset;
-                };
-                break;
-            }
-        }
-        break;
-    case 0xA: /* Axy: Volume slide */
-        if(s->effect_param > 0) {    ch->volume_slide_param = s->effect_param; }
-        break;
-    case 0xB: /* Bxx: Position jump */
-        if(s->effect_param < ctx->module.length) {
-            ctx->position_jump = true;
-            ctx->jump_dest = s->effect_param;
-        }
-        break;
-    case 0xC: /* Cxx: Set volume */
-        ch->volume = (float)((s->effect_param > 0x40) ? 0x40 : s->effect_param) / (float)0x40;
-        break;
-    case 0xD: /* Dxx: Pattern break */
-        /* Jump after playing this line */
-        ctx->pattern_break = true;
-        ctx->jump_row = (s->effect_param >> 4) * 10 + (s->effect_param & 0x0F);
-        break;
-    case 0xE: /* EXy: Extended command */
-        switch(s->effect_param >> 4) {
-        case 1: /* E1y: Fine portamento up */
-            if(s->effect_param & 0x0F) {    ch->fine_portamento_up_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, -ch->fine_portamento_up_param);
-            break;
-        case 2: /* E2y: Fine portamento down */
-            if(s->effect_param & 0x0F) {    ch->fine_portamento_down_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, ch->fine_portamento_down_param);
-            break;
-        case 4: /* E4y: Set vibrato control */
-            ch->vibrato_waveform = s->effect_param & 3;
-            ch->vibrato_waveform_retrigger = !((s->effect_param >> 2) & 1);
-            break;
-        case 5: /* E5y: Set finetune */
-            if(NOTE_IS_VALID(ch->current->note) && ch->sample != NULL) {
-                ch->note = ch->current->note + ch->sample->relative_note + (float)(((s->effect_param & 0x0F) - 8) << 4) / 128.f - 1.f;
-                ch->period = jar_xm_period(ctx, ch->note);
-                jar_xm_update_frequency(ctx, ch);
-            }
-            break;
-        case 6: /* E6y: Pattern loop */
-            if(s->effect_param & 0x0F) {
-                if((s->effect_param & 0x0F) == ch->pattern_loop_count) {   /* Loop is over */
-                    ch->pattern_loop_count = 0;
-                    ctx->position_jump = false;
-                } else {    /* Jump to the beginning of the loop */
-                    ch->pattern_loop_count++;
-                    ctx->position_jump = true;
-                    ctx->jump_row = ch->pattern_loop_origin;
-                    ctx->jump_dest = ctx->current_table_index;
-                }
-            } else {
-                ch->pattern_loop_origin = ctx->current_row; /* Set loop start point */
-                ctx->jump_row = ch->pattern_loop_origin;    /* Replicate FT2 E60 bug */
-            }
-            break;
-        case 7: /* E7y: Set tremolo control */
-            ch->tremolo_waveform = s->effect_param & 3;
-            ch->tremolo_waveform_retrigger = !((s->effect_param >> 2) & 1);
-            break;
-        case 0xA: /* EAy: Fine volume slide up */
-            if(s->effect_param & 0x0F) {   ch->fine_volume_slide_param = s->effect_param & 0x0F; }
-            jar_xm_volume_slide(ch, ch->fine_volume_slide_param << 4);
-            break;
-        case 0xB: /* EBy: Fine volume slide down */
-            if(s->effect_param & 0x0F) {   ch->fine_volume_slide_param = s->effect_param & 0x0F; }
-            jar_xm_volume_slide(ch, ch->fine_volume_slide_param);
-            break;
-        case 0xD: /* EDy: Note delay */
-            /* XXX: figure this out better. EDx triggers the note even when there no note and no instrument. But ED0 acts like like a ghost note, EDx (x â‰  0) does not. */
-            if(s->note == 0 && s->instrument == 0) {
-                unsigned int flags = jar_xm_TRIGGER_KEEP_VOLUME;
-                if(ch->current->effect_param & 0x0F) {
-                    ch->note = ch->orig_note;
-                    jar_xm_trigger_note(ctx, ch, flags);
-                } else {
-                    jar_xm_trigger_note(ctx, ch, flags | jar_xm_TRIGGER_KEEP_PERIOD | jar_xm_TRIGGER_KEEP_SAMPLE_POSITION );
-                }
-            }
-            break;
-
-        case 0xE: /* EEy: Pattern delay */
-            ctx->extra_ticks = (ch->current->effect_param & 0x0F) * ctx->tempo;
-            break;
-        default:
-            break;
-        }
-        break;
-
-    case 0xF: /* Fxx: Set tempo/BPM */
-        if(s->effect_param > 0) {
-            if(s->effect_param <= 0x1F) {  // First 32 possible values adjust the ticks (goes into tempo)
-                ctx->tempo = s->effect_param;
-            } else {                       //32 and greater values adjust the BPM
-                ctx->bpm = s->effect_param;
-            }
-        }
-        break;
-
-    case 16: /* Gxx: Set global volume */
-        ctx->global_volume = (float)((s->effect_param > 0x40) ? 0x40 : s->effect_param) / (float)0x40;
-        break;
-    case 17: /* Hxy: Global volume slide */
-        if(s->effect_param > 0) {    ch->global_volume_slide_param = s->effect_param; }
-        break;
-    case 21: /* Lxx: Set envelope position */
-        ch->volume_envelope_frame_count = s->effect_param;
-        ch->panning_envelope_frame_count = s->effect_param;
-        break;
-    case 25: /* Pxy: Panning slide */
-        if(s->effect_param > 0) {   ch->panning_slide_param = s->effect_param; }
-        break;
-    case 27: /* Rxy: Multi retrig note */
-        if(s->effect_param > 0) {
-            if((s->effect_param >> 4) == 0) {    /* Keep previous x value */
-                ch->multi_retrig_param = (ch->multi_retrig_param & 0xF0) | (s->effect_param & 0x0F);
-            } else {
-                ch->multi_retrig_param = s->effect_param;
-            }
-        }
-        break;
-    case 29: /* Txy: Tremor */
-        if(s->effect_param > 0) { ch->tremor_param = s->effect_param; }  /* Tremor x and y params are not separately kept in memory, unlike Rxy */
-        break;
-    case 33: /* Xxy: Extra stuff */
-        switch(s->effect_param >> 4) {
-        case 1: /* X1y: Extra fine portamento up */
-            if(s->effect_param & 0x0F) {    ch->extra_fine_portamento_up_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, -1.0f * ch->extra_fine_portamento_up_param);
-            break;
-        case 2: /* X2y: Extra fine portamento down */
-            if(s->effect_param & 0x0F) {   ch->extra_fine_portamento_down_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, ch->extra_fine_portamento_down_param);
-            break;
-        default:
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-}
-
-static void jar_xm_trigger_note(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, unsigned int flags) {
-    if (!(flags & jar_xm_TRIGGER_KEEP_SAMPLE_POSITION)) {
-        ch->sample_position = 0.f;
-        ch->ping = true;
-    };
-    
-    if (!(flags & jar_xm_TRIGGER_KEEP_VOLUME)) {
-       if(ch->sample != NULL) {
-        ch->volume = ch->sample->volume;
-        };
-    };
-    ch->panning = ch->sample->panning;
-    ch->sustained = true;
-    ch->fadeout_volume = ch->volume_envelope_volume = 1.0f;
-    ch->panning_envelope_panning = .5f;
-    ch->volume_envelope_frame_count = ch->panning_envelope_frame_count = 0;
-    ch->vibrato_note_offset = 0.f;
-    ch->tremolo_volume = 0.f;
-    ch->tremor_on = false;
-    ch->autovibrato_ticks = 0;
-
-    if(ch->vibrato_waveform_retrigger) { ch->vibrato_ticks = 0; } /* XXX: should the waveform itself also be reset to sine? */
-    if(ch->tremolo_waveform_retrigger) { ch->tremolo_ticks = 0; }
-    if(!(flags & jar_xm_TRIGGER_KEEP_PERIOD)) {
-        ch->period = jar_xm_period(ctx, ch->note);
-        jar_xm_update_frequency(ctx, ch);
-    }
-    ch->latest_trigger = ctx->generated_samples;
-    if(ch->instrument != NULL) { ch->instrument->latest_trigger = ctx->generated_samples; }
-    if(ch->sample != NULL) {     ch->sample->latest_trigger = ctx->generated_samples; }
-}
-
-static void jar_xm_cut_note(jar_xm_channel_context_t* ch) {
-    ch->volume = .0f; /* NB: this is not the same as Key Off */
-//    ch->curr_left = .0f;
-//    ch->curr_right = .0f;
-}
-
-static void jar_xm_key_off(jar_xm_channel_context_t* ch) {
-    ch->sustained = false; /* Key Off */
-    if(ch->instrument == NULL || !ch->instrument->volume_envelope.enabled) { jar_xm_cut_note(ch); } /* If no volume envelope is used, also cut the note */
-}
-
-static void jar_xm_row(jar_xm_context_t* ctx) {
-    if(ctx->position_jump) {
-        ctx->current_table_index = ctx->jump_dest;
-        ctx->current_row = ctx->jump_row;
-        ctx->position_jump = false;
-        ctx->pattern_break = false;
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    } else if(ctx->pattern_break) {
-        ctx->current_table_index++;
-        ctx->current_row = ctx->jump_row;
-        ctx->pattern_break = false;
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    }
-    jar_xm_pattern_t* cur = ctx->module.patterns + ctx->module.pattern_table[ctx->current_table_index];
-    bool in_a_loop = false;
-
-    /* Read notes information for all channels into temporary pattern slot */
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_pattern_slot_t* s = cur->slots + ctx->current_row * ctx->module.num_channels + i;
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        ch->current = s;
-        // If there is no note delay effect (0xED) then...
-        if(s->effect_type != 0xE || s->effect_param >> 4 != 0xD) {
-            //********** Process the channel slot information **********
-            jar_xm_handle_note_and_instrument(ctx, ch, s);
-        } else {
-            // read the note delay information
-            ch->note_delay_param = s->effect_param & 0x0F;
-        }
-        if(!in_a_loop && ch->pattern_loop_count > 0) {
-            // clarify if in a loop or not
-            in_a_loop = true;
-        }
-    }
-
-    if(!in_a_loop) {
-        /* No E6y loop is in effect (or we are in the first pass) */
-        ctx->loop_count = (ctx->row_loop_count[MAX_NUM_ROWS * ctx->current_table_index + ctx->current_row]++);
-    }
-    
-    /// Move to next row
-    ctx->current_row++; /* uint8 warning: can increment from 255 to 0, in which case it is still necessary to go the next pattern. */
-    if (!ctx->position_jump && !ctx->pattern_break && (ctx->current_row >= cur->num_rows || ctx->current_row == 0)) {
-        ctx->current_table_index++;
-        ctx->current_row = ctx->jump_row; /* This will be 0 most of the time, except when E60 is used */
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    }
-}
-
-static void jar_xm_envelope_tick(jar_xm_channel_context_t *ch, jar_xm_envelope_t *env, uint16_t *counter, float *outval) {
-    if(env->num_points < 2) {
-        if(env->num_points == 1) {
-            *outval = (float)env->points[0].value / (float)0x40;
-            if(*outval > 1) { *outval = 1; };
-        } else {;
-            return;
-        };
-    } else {
-        if(env->loop_enabled) {
-            uint16_t loop_start = env->points[env->loop_start_point].frame;
-            uint16_t loop_end = env->points[env->loop_end_point].frame;
-            uint16_t loop_length = loop_end - loop_start;
-            if(*counter >= loop_end) { *counter -= loop_length; };
-        };
-        for(uint8_t j = 0; j < (env->num_points - 1); ++j) {
-            if(env->points[j].frame <= *counter && env->points[j+1].frame >= *counter) {
-                *outval = jar_xm_envelope_lerp(env->points + j, env->points + j + 1, *counter) / (float)0x40;
-                break;
-            };
-        };
-        /* Make sure it is safe to increment frame count */
-        if(!ch->sustained || !env->sustain_enabled || *counter != env->points[env->sustain_point].frame) { (*counter)++; };
-    };
-};
-
-static void jar_xm_envelopes(jar_xm_channel_context_t *ch) {
-    if(ch->instrument != NULL) {
-        if(ch->instrument->volume_envelope.enabled) {
-            if(!ch->sustained) {
-                ch->fadeout_volume -= (float)ch->instrument->volume_fadeout / 65536.f;
-                jar_xm_CLAMP_DOWN(ch->fadeout_volume);
-            };
-            jar_xm_envelope_tick(ch, &(ch->instrument->volume_envelope), &(ch->volume_envelope_frame_count), &(ch->volume_envelope_volume));
-        };
-        if(ch->instrument->panning_envelope.enabled) {
-            jar_xm_envelope_tick(ch, &(ch->instrument->panning_envelope), &(ch->panning_envelope_frame_count), &(ch->panning_envelope_panning));
-        };
-    };
-};
-
-static void jar_xm_tick(jar_xm_context_t* ctx) {
-    if(ctx->current_tick == 0) {
-        jar_xm_row(ctx);        // We have processed all ticks and we run the row
-    }
-    
-    jar_xm_module_t* mod = &(ctx->module);
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        jar_xm_envelopes(ch);
-        jar_xm_autovibrato(ctx, ch);
-        if(ch->arp_in_progress && !HAS_ARPEGGIO(ch->current)) {
-            ch->arp_in_progress = false;
-            ch->arp_note_offset = 0;
-            jar_xm_update_frequency(ctx, ch);
-        }
-        if(ch->vibrato_in_progress && !HAS_VIBRATO(ch->current)) {
-            ch->vibrato_in_progress = false;
-            ch->vibrato_note_offset = 0.f;
-            jar_xm_update_frequency(ctx, ch);
-        }
-
-        // Effects in volumne column mostly handled on a per tick basis
-        switch(ch->current->volume_column & 0xF0) {
-        case 0x50: // Checks for volume = 64
-            if(ch->current->volume_column != 0x50) break;
-        case 0x10: // Set volume 0-15
-        case 0x20: // Set volume 16-32
-        case 0x30: // Set volume 32-48
-        case 0x40: // Set volume 48-64
-            ch->volume = (float)(ch->current->volume_column - 16) / 64.0f;
-            break;
-        case 0x60: // Volume slide down
-            jar_xm_volume_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0x70: // Volume slide up
-            jar_xm_volume_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0x80: // Fine volume slide down
-            jar_xm_volume_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0x90: // Fine volume slide up
-            jar_xm_volume_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0xA0: // Set vibrato speed
-            ch->vibrato_param = (ch->vibrato_param & 0x0F) | ((ch->current->volume_column & 0x0F) << 4);
-            break;
-        case 0xB0: // Vibrato
-            ch->vibrato_in_progress = false;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            break;
-        case 0xC0: // Set panning
-            if(!ctx->current_tick ) {
-                ch->panning = (float)(ch->current->volume_column & 0x0F) / 15.0f;
-            }
-            break;
-        case 0xD0: // Panning slide left
-            jar_xm_panning_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0xE0: // Panning slide right
-            jar_xm_panning_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0xF0: // Tone portamento
-            if(!ctx->current_tick ) {
-                if(ch->current->volume_column & 0x0F) { ch->tone_portamento_param = ((ch->current->volume_column & 0x0F) << 4) | (ch->current->volume_column & 0x0F); }
-            };
-            jar_xm_tone_portamento(ctx, ch);
-            break;
-        default:
-            break;
-        }
-
-        // Only some standard effects handled on a per tick basis
-        // see jar_xm_handle_note_and_instrument for all effects handling on a per row basis
-        switch(ch->current->effect_type) {
-        case 0: /* 0xy: Arpeggio */
-            if(ch->current->effect_param > 0) {
-                char arp_offset = ctx->tempo % 3;
-                switch(arp_offset) {
-                case 2: /* 0 -> x -> 0 -> y -> x -> â€¦ */
-                    if(ctx->current_tick == 1) {
-                        ch->arp_in_progress = true;
-                        ch->arp_note_offset = ch->current->effect_param >> 4;
-                        jar_xm_update_frequency(ctx, ch);
-                        break;
-                    }
-                    /* No break here, this is intended */
-                case 1: /* 0 -> 0 -> y -> x -> â€¦ */
-                    if(ctx->current_tick == 0) {
-                        ch->arp_in_progress = false;
-                        ch->arp_note_offset = 0;
-                        jar_xm_update_frequency(ctx, ch);
-                        break;
-                    }
-                    /* No break here, this is intended */
-                case 0: /* 0 -> y -> x -> â€¦ */
-                    jar_xm_arpeggio(ctx, ch, ch->current->effect_param, ctx->current_tick - arp_offset);
-                default:
-                    break;
-                }
-            }
-            break;
-
-        case 1: /* 1xx: Portamento up */
-            if(ctx->current_tick == 0) break;
-            jar_xm_pitch_slide(ctx, ch, -ch->portamento_up_param);
-            break;
-        case 2: /* 2xx: Portamento down */
-            if(ctx->current_tick == 0) break;
-            jar_xm_pitch_slide(ctx, ch, ch->portamento_down_param);
-            break;
-        case 3: /* 3xx: Tone portamento */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tone_portamento(ctx, ch);
-            break;
-        case 4: /* 4xy: Vibrato */
-            if(ctx->current_tick == 0) break;
-            ch->vibrato_in_progress = true;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            break;
-        case 5: /* 5xy: Tone portamento + Volume slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tone_portamento(ctx, ch);
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 6: /* 6xy: Vibrato + Volume slide */
-            if(ctx->current_tick == 0) break;
-            ch->vibrato_in_progress = true;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 7: /* 7xy: Tremolo */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tremolo(ctx, ch, ch->tremolo_param, ch->tremolo_ticks++);
-            break;
-        case 8: /* 8xy: Set panning */
-            break;
-        case 9: /* 9xy: Sample offset */
-            break;
-        case 0xA: /* Axy: Volume slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 0xE: /* EXy: Extended command */
-            switch(ch->current->effect_param >> 4) {
-            case 0x9: /* E9y: Retrigger note */
-                if(ctx->current_tick != 0 && ch->current->effect_param & 0x0F) {
-                    if(!(ctx->current_tick % (ch->current->effect_param & 0x0F))) {
-                        jar_xm_trigger_note(ctx, ch, 0);
-                        jar_xm_envelopes(ch);
-                    }
-                }
-                break;
-            case 0xC: /* ECy: Note cut */
-                if((ch->current->effect_param & 0x0F) == ctx->current_tick) {
-                    jar_xm_cut_note(ch);
-                }
-                break;
-            case 0xD: /* EDy: Note delay */
-                if(ch->note_delay_param == ctx->current_tick) {
-                    jar_xm_handle_note_and_instrument(ctx, ch, ch->current);
-                    jar_xm_envelopes(ch);
-                }
-                break;
-            default:
-                break;
-            }
-            break;
-        case 16: /* Fxy: Set tempo/BPM */
-            break;        
-        case 17: /* Hxy: Global volume slide */
-            if(ctx->current_tick == 0) break;
-            if((ch->global_volume_slide_param & 0xF0) && (ch->global_volume_slide_param & 0x0F)) { break; }; /* Invalid state */
-            if(ch->global_volume_slide_param & 0xF0) {    /* Global slide up */
-                float f = (float)(ch->global_volume_slide_param >> 4) / (float)0x40;
-                ctx->global_volume += f;
-                jar_xm_CLAMP_UP(ctx->global_volume);
-            } else {                                      /* Global slide down */
-                float f = (float)(ch->global_volume_slide_param & 0x0F) / (float)0x40;
-                ctx->global_volume -= f;
-                jar_xm_CLAMP_DOWN(ctx->global_volume);
-            };
-            break;
-
-        case 20: /* Kxx: Key off */
-            if(ctx->current_tick == ch->current->effect_param) {     jar_xm_key_off(ch); };
-            break;
-        case 21: /* Lxx: Set envelope position */
-            break;        
-        case 25: /* Pxy: Panning slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_panning_slide(ch, ch->panning_slide_param);
-            break;
-        case 27: /* Rxy: Multi retrig note */
-            if(ctx->current_tick == 0) break;
-            if(((ch->multi_retrig_param) & 0x0F) == 0) break;
-            if((ctx->current_tick % (ch->multi_retrig_param & 0x0F)) == 0) {
-                float v = ch->volume * multi_retrig_multiply[ch->multi_retrig_param >> 4]
-                    + multi_retrig_add[ch->multi_retrig_param >> 4];
-                jar_xm_CLAMP(v);
-                jar_xm_trigger_note(ctx, ch, 0);
-                ch->volume = v;
-            };
-            break;
-
-        case 29: /* Txy: Tremor */
-            if(ctx->current_tick == 0) break;
-            ch->tremor_on = ( (ctx->current_tick - 1) % ((ch->tremor_param >> 4) + (ch->tremor_param & 0x0F) + 2) > (ch->tremor_param >> 4)  );
-            break;
-        default:
-            break;
-        };
-
-        float panning, volume;
-        panning = ch->panning + (ch->panning_envelope_panning - .5f) * (.5f - fabs(ch->panning - .5f)) * 2.0f;
-        if(ch->tremor_on) {
-            volume = .0f;
-        } else {
-            volume = ch->volume + ch->tremolo_volume;
-            jar_xm_CLAMP(volume);
-            volume *= ch->fadeout_volume * ch->volume_envelope_volume;
-        };
-
-        if (mod->ramping) {
-            ch->target_panning = panning;
-            ch->target_volume = volume;
-        } else {
-            ch->actual_panning = panning;
-            ch->actual_volume = volume;
-        };
-    };
-
-    ctx->current_tick++; // ok so we understand that ticks increment within the row
-    if(ctx->current_tick >= ctx->tempo + ctx->extra_ticks) {
-        // This means it reached the end of the row and we reset
-        ctx->current_tick = 0;
-        ctx->extra_ticks = 0;
-    };
-
-    // Number of ticks / second = BPM * 0.4
-    ctx->remaining_samples_in_tick += (float)ctx->rate / ((float)ctx->bpm * 0.4f);
-};
-
-static void jar_xm_next_of_sample(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, int previous) {
-    jar_xm_module_t* mod = &(ctx->module);
-
-//    ch->curr_left = 0.f;
-//    ch->curr_right = 0.f;
-    if(ch->instrument == NULL || ch->sample == NULL || ch->sample_position < 0) {
-        ch->curr_left = 0.f;
-        ch->curr_right = 0.f;
-        if (mod->ramping) {
-            if (ch->frame_count < jar_xm_SAMPLE_RAMPING_POINTS) {
-                if (previous > -1) {
-                    ch->end_of_previous_sample_left[previous] = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], ch->curr_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                    ch->end_of_previous_sample_right[previous] = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], ch->curr_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                } else {
-                    ch->curr_left = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], ch->curr_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                    ch->curr_right = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], ch->curr_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                };
-            };
-        };
-        return;
-    };
-    if(ch->sample->length == 0) {
-        return;
-    };
-
-    float t = 0.f;
-    uint32_t b = 0;
-    if(mod->linear_interpolation) {
-        b = ch->sample_position + 1;
-        t = ch->sample_position - (uint32_t)ch->sample_position; /* Cheaper than fmodf(., 1.f) */
-    };
-
-    float u_left, u_right;
-    u_left = ch->sample->data[(uint32_t)ch->sample_position];
-    if (ch->sample->stereo) {
-        u_right = ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length];
-    } else {
-        u_right = u_left;
-    };
-    float v_left = 0.f, v_right = 0.f;
-    switch(ch->sample->loop_type) {
-    case jar_xm_NO_LOOP:
-        if(mod->linear_interpolation) {
-            v_left = (b < ch->sample->length) ? ch->sample->data[b] : .0f;
-            if (ch->sample->stereo) {
-                v_right = (b < ch->sample->length) ? ch->sample->data[b + ch->sample->length] : .0f;
-            } else {
-                v_right = v_left;
-            };
-        };
-        ch->sample_position += ch->step;
-        if(ch->sample_position >= ch->sample->length) { ch->sample_position = -1; } // stop playing this sample
-        break;
-    case jar_xm_FORWARD_LOOP:
-        if(mod->linear_interpolation) {
-            v_left = ch->sample->data[ (b == ch->sample->loop_end) ? ch->sample->loop_start : b ];
-            if (ch->sample->stereo) {
-                v_right = ch->sample->data[ (b == ch->sample->loop_end) ? ch->sample->loop_start + ch->sample->length : b + ch->sample->length];
-            } else {
-                v_right = v_left;
-            };
-        };
-        ch->sample_position += ch->step;
-        if (ch->sample_position >= ch->sample->loop_end) {
-            ch->sample_position -= ch->sample->loop_length;
-        };
-        if(ch->sample_position >= ch->sample->length) {
-            ch->sample_position = ch->sample->loop_start;
-        };
-        break;
-    case jar_xm_PING_PONG_LOOP:
-        if(ch->ping) {
-            if(mod->linear_interpolation) {
-                v_left = (b >= ch->sample->loop_end) ? ch->sample->data[(uint32_t)ch->sample_position] : ch->sample->data[b];
-                if (ch->sample->stereo) {
-                    v_right = (b >= ch->sample->loop_end) ? ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length] : ch->sample->data[b + ch->sample->length];
-                } else {
-                    v_right = v_left;
-                };
-            };
-            ch->sample_position += ch->step;
-            if(ch->sample_position >= ch->sample->loop_end) {
-                ch->ping = false;
-                ch->sample_position = (ch->sample->loop_end << 1) - ch->sample_position;
-            };
-            if(ch->sample_position >= ch->sample->length) {
-                ch->ping = false;
-                ch->sample_position -= ch->sample->length - 1;
-            };
-        } else {
-            if(mod->linear_interpolation) {
-                v_left = u_left;
-                v_right = u_right;
-                u_left = (b == 1 || b - 2 <= ch->sample->loop_start) ? ch->sample->data[(uint32_t)ch->sample_position] : ch->sample->data[b - 2];
-                if (ch->sample->stereo) {
-                    u_right = (b == 1 || b - 2 <= ch->sample->loop_start) ? ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length] : ch->sample->data[b + ch->sample->length - 2];
-                } else {
-                    u_right = u_left;
-                };
-            };
-            ch->sample_position -= ch->step;
-            if(ch->sample_position <= ch->sample->loop_start) {
-                ch->ping = true;
-                ch->sample_position = (ch->sample->loop_start << 1) - ch->sample_position;
-            };
-            if (ch->sample_position <= .0f) {
-                ch->ping = true;
-                ch->sample_position = .0f;
-            };
-        };
-        break;
-
-    default:
-        v_left = .0f;
-        v_right = .0f;
-        break;
-    };
-
-    float endval_left = mod->linear_interpolation ? jar_xm_LERP(u_left, v_left, t) : u_left;
-    float endval_right = mod->linear_interpolation ? jar_xm_LERP(u_right, v_right, t) : u_right;
-
-    if (mod->ramping) {
-        if(ch->frame_count < jar_xm_SAMPLE_RAMPING_POINTS) {
-            /* Smoothly transition between old and new sample. */
-            if (previous > -1) {
-                ch->end_of_previous_sample_left[previous] = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], endval_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                ch->end_of_previous_sample_right[previous] = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], endval_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-            } else {
-                ch->curr_left = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], endval_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                ch->curr_right = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], endval_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-            };
-        };
-    };
-
-    if (previous > -1) {
-        ch->end_of_previous_sample_left[previous] = endval_left;
-        ch->end_of_previous_sample_right[previous] = endval_right;
-    } else {
-        ch->curr_left = endval_left;
-        ch->curr_right = endval_right;
-    };
-};
-
-// gather all channel audio into stereo float
-static void jar_xm_mixdown(jar_xm_context_t* ctx, float* left, float* right) {
-    jar_xm_module_t* mod = &(ctx->module);
-    
-    if(ctx->remaining_samples_in_tick <= 0) {
-        jar_xm_tick(ctx);
-    };
-    ctx->remaining_samples_in_tick--;
-    *left = 0.f;
-    *right = 0.f;
-    if(ctx->max_loop_count > 0 && ctx->loop_count > ctx->max_loop_count) { return; }
-
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        if(ch->instrument != NULL && ch->sample != NULL && ch->sample_position >= 0) {
-            jar_xm_next_of_sample(ctx, ch, -1);
-            if(!ch->muted && !ch->instrument->muted) {
-                *left  += ch->curr_left * ch->actual_volume * (1.f - ch->actual_panning);
-                *right += ch->curr_right * ch->actual_volume * ch->actual_panning;
-            };
-
-            if (mod->ramping) {
-                ch->frame_count++;
-                jar_xm_SLIDE_TOWARDS(ch->actual_volume, ch->target_volume, ctx->volume_ramp);
-                jar_xm_SLIDE_TOWARDS(ch->actual_panning, ch->target_panning, ctx->panning_ramp);
-            };
-        };
-    };
-    if (ctx->global_volume != 1.0f) {
-        *left *= ctx->global_volume;
-        *right *= ctx->global_volume;
-    };
-
-    // experimental
-//    float counter = (float)ctx->generated_samples * 0.0001f
-//    *left = tan(&left + sin(counter));
-//    *right = tan(&right + cos(counter));
-
-    // apply brick wall limiter when audio goes beyond bounderies
-    if(*left < -1.0)  {*left = -1.0;}  else if(*left > 1.0)  {*left = 1.0;};
-    if(*right < -1.0) {*right = -1.0;} else if(*right > 1.0) {*right = 1.0;};   
-};
-
-void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsamples) {
-    if(ctx && output) {
-        ctx->generated_samples += numsamples;
-        for(size_t i = 0; i < numsamples; i++) {
-            jar_xm_mixdown(ctx, output + (2 * i), output + (2 * i + 1));
-        };
-    };
-};
-
-uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx) {
-    uint64_t total = 0;
-    uint8_t currentLoopCount = jar_xm_get_loop_count(ctx);
-    jar_xm_set_max_loop_count(ctx, 0);
-    while(jar_xm_get_loop_count(ctx) == currentLoopCount) {
-        total += ctx->remaining_samples_in_tick;
-        ctx->remaining_samples_in_tick = 0;
-        jar_xm_tick(ctx);
-    }
-    ctx->loop_count = currentLoopCount;
-    return total;
-}
-
-//--------------------------------------------
-//FILE LOADER - TODO - NEEDS TO BE CLEANED UP
-//--------------------------------------------
-#undef DEBUG
-#define DEBUG(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-    } while(0)
-
-#define DEBUG_ERR(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-    } while(0)
-
-#define FATAL(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-        exit(1); \
-    } while(0)
-
-#define FATAL_ERR(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-        exit(1); \
-    } while(0)
-
-
-int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const char* filename) {
-    FILE* xmf;
-    int size;
-    int ret;
-
-    xmf = fopen(filename, "rb");
-    if(xmf == NULL) {
-        DEBUG_ERR("Could not open input file");
-        *ctx = NULL;
-        return 3;
-    }
-
-    fseek(xmf, 0, SEEK_END);
-    size = ftell(xmf);
-    rewind(xmf);
-    if(size == -1) {
-        fclose(xmf);
-        DEBUG_ERR("fseek() failed");
-        *ctx = NULL;
-        return 4;
-    }
-
-    char* data = JARXM_MALLOC(size + 1);
-    if(!data || fread(data, 1, size, xmf) < size) {
-        fclose(xmf);
-        DEBUG_ERR(data ? "fread() failed" : "JARXM_MALLOC() failed");
-        JARXM_FREE(data);
-        *ctx = NULL;
-        return 5;
-    }
-
-    fclose(xmf);
-
-    ret = jar_xm_create_context_safe(ctx, data, size, rate);
-    JARXM_FREE(data);
-
-    switch(ret) {
-    case 0:
-        break;
-    case 1:        DEBUG("could not create context: module is not sane\n");
-        *ctx = NULL;
-        return 1;
-        break;
-    case 2:        FATAL("could not create context: malloc failed\n");
-        return 2;
-        break;
-    default:       FATAL("could not create context: unknown error\n");
-        return 6;
-        break;
-    }
-    
-    return 0;
-}
-
-// not part of the original library
-void jar_xm_reset(jar_xm_context_t* ctx) {
-    for (uint16_t i = 0; i < jar_xm_get_number_of_channels(ctx); i++) {
-        jar_xm_cut_note(&ctx->channels[i]);
-    }
-    ctx->current_row = 0;
-    ctx->current_table_index = 0;
-    ctx->current_tick = 0;
-    ctx->tempo =ctx->default_tempo; // reset to file default value 
-    ctx->bpm = ctx->default_bpm; // reset to file default value
-    ctx->global_volume = ctx->default_global_volume; // reset to file default value
-}
-
-
-void jar_xm_flip_linear_interpolation(jar_xm_context_t* ctx) {
-    if (ctx->module.linear_interpolation) {
-        ctx->module.linear_interpolation = 0;
-    } else {
-        ctx->module.linear_interpolation = 1;
-    }
-}
-
-void jar_xm_table_jump(jar_xm_context_t* ctx, int table_ptr) {
-    for (uint16_t i = 0; i < jar_xm_get_number_of_channels(ctx); i++) {
-        jar_xm_cut_note(&ctx->channels[i]);
-    }
-    ctx->current_row = 0;
-    ctx->current_tick = 0;
-    if(table_ptr > 0 && table_ptr < ctx->module.length) {
-        ctx->current_table_index = table_ptr;
-        ctx->module.restart_position = table_ptr; // The reason to jump is to start a new loop or track
-    } else {
-        ctx->current_table_index = 0;
-        ctx->module.restart_position = 0; // The reason to jump is to start a new loop or track
-        ctx->tempo =ctx->default_tempo; // reset to file default value 
-        ctx->bpm = ctx->default_bpm; // reset to file default value
-        ctx->global_volume = ctx->default_global_volume; // reset to file default value
-    };
-}
-
-
-// TRANSLATE NOTE NUMBER INTO USER VALUE (ie. 1 = C-1, 2 = C#1, 3 = D-1 ... )
-const char* xm_note_chr(int number) {
-    if (number == NOTE_OFF) {
-        return "==";
-    };
-    number = number % 12;
-    switch(number) {
-    case 1: return "C-";
-    case 2: return "C#";
-    case 3: return "D-";
-    case 4: return "D#";
-    case 5: return "E-";
-    case 6: return "F-";
-    case 7: return "F#";
-    case 8: return "G-";
-    case 9: return "G#";
-    case 10: return "A-";
-    case 11: return "A#";
-    case 12: return "B-";
-    };
-    return "??";
-};
-
-const char* xm_octave_chr(int number) {
-    if (number == NOTE_OFF) {
-        return "=";
-    };
-
-    int number2 = number - number % 12;
-    int result = floor(number2 / 12) + 1;
-    switch(result) {
-    case 1: return "1";
-    case 2: return "2";
-    case 3: return "3";
-    case 4: return "4";
-    case 5: return "5";
-    case 6: return "6";
-    case 7: return "7";
-    case 8: return "8";
-    default: return "?"; /* UNKNOWN */
-    };
-
-};
-
-// TRANSLATE NOTE EFFECT CODE INTO USER VALUE
-const char* xm_effect_chr(int fx) {
-    switch(fx) {
-    case 0: return "0";  /* ZERO = NO EFFECT */
-    case 1: return "1";  /* 1xx: Portamento up */
-    case 2: return "2";  /* 2xx: Portamento down */
-    case 3: return "3";  /* 3xx: Tone portamento */
-    case 4: return "4";  /* 4xy: Vibrato */
-    case 5: return "5";  /* 5xy: Tone portamento + Volume slide */
-    case 6: return "6";  /* 6xy: Vibrato + Volume slide */
-    case 7: return "7";  /* 7xy: Tremolo */
-    case 8: return "8";  /* 8xx: Set panning */
-    case 9: return "9";  /* 9xx: Sample offset */
-    case 0xA: return "A";/* Axy: Volume slide */
-    case 0xB: return "B";/* Bxx: Position jump */
-    case 0xC: return "C";/* Cxx: Set volume */
-    case 0xD: return "D";/* Dxx: Pattern break */
-    case 0xE: return "E";/* EXy: Extended command */
-    case 0xF: return "F";/* Fxx: Set tempo/BPM */
-    case 16: return "G"; /* Gxx: Set global volume */
-    case 17: return "H"; /* Hxy: Global volume slide */
-    case 21: return "L"; /* Lxx: Set envelope position */
-    case 25: return "P"; /* Pxy: Panning slide */
-    case 27: return "R"; /* Rxy: Multi retrig note */
-    case 29: return "T"; /* Txy: Tremor */
-    case 33: return "X"; /* Xxy: Extra stuff */
-    default: return "?"; /* UNKNOWN */
-    };
-}
-
-#ifdef JAR_XM_RAYLIB
-
-#include "raylib.h" // Need RayLib API calls for the DEBUG display
-
-void jar_xm_debug(jar_xm_context_t *ctx) {
-    int size=40;
-    int x = 0, y = 0;
-
-    // DEBUG VARIABLES
-    y += size; DrawText(TextFormat("CUR TBL = %i", ctx->current_table_index),       x, y, size, WHITE);
-    y += size; DrawText(TextFormat("CUR PAT = %i", ctx->module.pattern_table[ctx->current_table_index]),   x, y, size, WHITE);
-    y += size; DrawText(TextFormat("POS JMP = %d", ctx->position_jump),             x, y, size, WHITE);
-    y += size; DrawText(TextFormat("JMP DST = %i", ctx->jump_dest),                 x, y, size, WHITE);
-    y += size; DrawText(TextFormat("PTN BRK = %d", ctx->pattern_break),             x, y, size, WHITE);
-    y += size; DrawText(TextFormat("CUR ROW = %i", ctx->current_row),               x, y, size, WHITE);
-    y += size; DrawText(TextFormat("JMP ROW = %i", ctx->jump_row),                  x, y, size, WHITE);
-    y += size; DrawText(TextFormat("ROW LCT = %i", ctx->row_loop_count),            x, y, size, WHITE);
-    y += size; DrawText(TextFormat("LCT     = %i", ctx->loop_count),                x, y, size, WHITE);
-    y += size; DrawText(TextFormat("MAX LCT = %i", ctx->max_loop_count),            x, y, size, WHITE);
-    x = size * 12; y = 0;
-    
-    y += size; DrawText(TextFormat("CUR TCK = %i", ctx->current_tick),              x, y, size, WHITE);
-    y += size; DrawText(TextFormat("XTR TCK = %i", ctx->extra_ticks),               x, y, size, WHITE);
-    y += size; DrawText(TextFormat("TCK/ROW = %i", ctx->tempo),                     x, y, size, ORANGE);
-    y += size; DrawText(TextFormat("SPL TCK = %f", ctx->remaining_samples_in_tick), x, y, size, WHITE);
-    y += size; DrawText(TextFormat("GEN SPL = %i", ctx->generated_samples),         x, y, size, WHITE);
-    y += size * 7;
-    
-    x = 0;
-    size=16;
-    // TIMELINE OF MODULE
-    for (int i=0; i < ctx->module.length; i++) {
-        if (i == ctx->jump_dest) {
-            if (ctx->position_jump) {
-                DrawRectangle(i * size * 2, y - size, size * 2, size, GOLD); 
-            } else {
-                DrawRectangle(i * size * 2, y - size, size * 2, size, BROWN);                 
-            };
-        };
-        if (i == ctx->current_table_index) {
-//            DrawText(TextFormat("%02X", ctx->current_tick), i * size * 2, y - size, size, WHITE);
-            DrawRectangle(i * size * 2, y, size * 2, size, RED); 
-            DrawText(TextFormat("%02X", ctx->current_row), i * size * 2, y - size, size, YELLOW);
-        } else {
-            DrawRectangle(i * size * 2, y, size * 2, size, ORANGE); 
-        };
-        DrawText(TextFormat("%02X", ctx->module.pattern_table[i]), i * size * 2, y, size, WHITE);
-    };
-    y += size;
-
-    jar_xm_pattern_t* cur = ctx->module.patterns + ctx->module.pattern_table[ctx->current_table_index];
-
-    /* DISPLAY CURRENTLY PLAYING PATTERN */
-
-    x += 2 * size;
-    for(uint8_t i = 0; i < ctx->module.num_channels; i++) {
-        DrawRectangle(x, y, 8 * size, size, PURPLE);
-        DrawText("N", x, y, size, YELLOW);
-        DrawText("I", x + size * 2, y, size, YELLOW);
-        DrawText("V", x + size * 4, y, size, YELLOW);
-        DrawText("FX", x + size * 6, y, size, YELLOW);
-        x += 9 * size;
-    };
-    x += size;   
-    for (int j=(ctx->current_row - 14); j<(ctx->current_row + 15); j++) {
-        y += size;
-        x = 0;
-        if (j >=0 && j < (cur->num_rows)) {
-            DrawRectangle(x, y, size * 2, size, BROWN); 
-            DrawText(TextFormat("%02X",j), x, y, size, WHITE);
-            x += 2 * size;
-            for(uint8_t i = 0; i < ctx->module.num_channels; i++) {
-                if (j==(ctx->current_row)) {
-                    DrawRectangle(x, y, 8 * size, size, DARKGREEN); 
-                } else {
-                    DrawRectangle(x, y, 8 * size, size, DARKGRAY); 
-                };
-                jar_xm_pattern_slot_t *s = cur->slots + j * ctx->module.num_channels + i;
-           //     jar_xm_channel_context_t *ch = ctx->channels + i;
-                if (s->note > 0) {DrawText(TextFormat("%s%s", xm_note_chr(s->note), xm_octave_chr(s->note) ), x, y, size, WHITE);} else {DrawText("...", x, y, size, GRAY);};
-                if (s->instrument > 0) {
-                    DrawText(TextFormat("%02X", s->instrument), x + size * 2, y, size, WHITE);
-                    if (s->volume_column == 0) {
-                        DrawText(TextFormat("%02X", 64), x + size * 4, y, size, YELLOW);
-                    };
-                } else {
-                    DrawText("..", x + size * 2, y, size, GRAY);
-                    if (s->volume_column == 0) {
-                        DrawText("..", x + size * 4, y, size, GRAY);
-                    };
-                };
-                if (s->volume_column > 0) {DrawText(TextFormat("%02X", (s->volume_column - 16)), x + size * 4, y, size, WHITE);};
-                if (s->effect_type > 0 || s->effect_param > 0) {DrawText(TextFormat("%s%02X", xm_effect_chr(s->effect_type), s->effect_param), x + size * 6, y, size, WHITE);};
-                x += 9 * size;
-            };
-        };
-    };
-
-}
-#endif // RayLib extension
-
-#endif//end of JAR_XM_IMPLEMENTATION
-//-------------------------------------------------------------------------------
-
-#endif//end of INCLUDE_JAR_XM_H
diff --git a/raylib/external/miniaudio.h b/raylib/external/miniaudio.h
deleted file mode 100644 (file)
index 60522da..0000000
+++ /dev/null
@@ -1,65345 +0,0 @@
-/*
-Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
-miniaudio - v0.10.33 - 2021-04-04
-
-David Reid - mackron@gmail.com
-
-Website:       https://miniaud.io
-Documentation: https://miniaud.io/docs
-GitHub:        https://github.com/mackron/miniaudio
-*/
-
-/*
-1. Introduction
-===============
-miniaudio is a single file library for audio playback and capture. To use it, do the following in one .c file:
-
-    ```c
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-    ```
-
-You can do `#include "miniaudio.h"` in other parts of the program just like any other header.
-
-miniaudio uses the concept of a "device" as the abstraction for physical devices. The idea is that you choose a physical device to emit or capture audio from,
-and then move data to/from the device when miniaudio tells you to. Data is delivered to and from devices asynchronously via a callback which you specify when
-initializing the device.
-
-When initializing the device you first need to configure it. The device configuration allows you to specify things like the format of the data delivered via
-the callback, the size of the internal buffer and the ID of the device you want to emit or capture audio from.
-
-Once you have the device configuration set up you can initialize the device. When initializing a device you need to allocate memory for the device object
-beforehand. This gives the application complete control over how the memory is allocated. In the example below we initialize a playback device on the stack,
-but you could allocate it on the heap if that suits your situation better.
-
-    ```c
-    void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
-    {
-        // In playback mode copy data to pOutput. In capture mode read data from pInput. In full-duplex mode, both
-        // pOutput and pInput will be valid and you can move data from pInput into pOutput. Never process more than
-        // frameCount frames.
-    }
-
-    int main()
-    {
-        ma_device_config config = ma_device_config_init(ma_device_type_playback);
-        config.playback.format   = ma_format_f32;   // Set to ma_format_unknown to use the device's native format.
-        config.playback.channels = 2;               // Set to 0 to use the device's native channel count.
-        config.sampleRate        = 48000;           // Set to 0 to use the device's native sample rate.
-        config.dataCallback      = data_callback;   // This function will be called when miniaudio needs more data.
-        config.pUserData         = pMyCustomData;   // Can be accessed from the device object (device.pUserData).
-
-        ma_device device;
-        if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) {
-            return -1;  // Failed to initialize the device.
-        }
-
-        ma_device_start(&device);     // The device is sleeping by default so you'll need to start it manually.
-
-        // Do something here. Probably your program's main loop.
-
-        ma_device_uninit(&device);    // This will stop the device so no need to do that manually.
-        return 0;
-    }
-    ```
-
-In the example above, `data_callback()` is where audio data is written and read from the device. The idea is in playback mode you cause sound to be emitted
-from the speakers by writing audio data to the output buffer (`pOutput` in the example). In capture mode you read data from the input buffer (`pInput`) to
-extract sound captured by the microphone. The `frameCount` parameter tells you how many frames can be written to the output buffer and read from the input
-buffer. A "frame" is one sample for each channel. For example, in a stereo stream (2 channels), one frame is 2 samples: one for the left, one for the right.
-The channel count is defined by the device config. The size in bytes of an individual sample is defined by the sample format which is also specified in the
-device config. Multi-channel audio data is always interleaved, which means the samples for each frame are stored next to each other in memory. For example, in
-a stereo stream the first pair of samples will be the left and right samples for the first frame, the second pair of samples will be the left and right samples
-for the second frame, etc.
-
-The configuration of the device is defined by the `ma_device_config` structure. The config object is always initialized with `ma_device_config_init()`. It's
-important to always initialize the config with this function as it initializes it with logical defaults and ensures your program doesn't break when new members
-are added to the `ma_device_config` structure. The example above uses a fairly simple and standard device configuration. The call to `ma_device_config_init()`
-takes a single parameter, which is whether or not the device is a playback, capture, duplex or loopback device (loopback devices are not supported on all
-backends). The `config.playback.format` member sets the sample format which can be one of the following (all formats are native-endian):
-
-    +---------------+----------------------------------------+---------------------------+
-    | Symbol        | Description                            | Range                     |
-    +---------------+----------------------------------------+---------------------------+
-    | ma_format_f32 | 32-bit floating point                  | [-1, 1]                   |
-    | ma_format_s16 | 16-bit signed integer                  | [-32768, 32767]           |
-    | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607]       |
-    | ma_format_s32 | 32-bit signed integer                  | [-2147483648, 2147483647] |
-    | ma_format_u8  | 8-bit unsigned integer                 | [0, 255]                  |
-    +---------------+----------------------------------------+---------------------------+
-
-The `config.playback.channels` member sets the number of channels to use with the device. The channel count cannot exceed MA_MAX_CHANNELS. The
-`config.sampleRate` member sets the sample rate (which must be the same for both playback and capture in full-duplex configurations). This is usually set to
-44100 or 48000, but can be set to anything. It's recommended to keep this between 8000 and 384000, however.
-
-Note that leaving the format, channel count and/or sample rate at their default values will result in the internal device's native configuration being used
-which is useful if you want to avoid the overhead of miniaudio's automatic data conversion.
-
-In addition to the sample format, channel count and sample rate, the data callback and user data pointer are also set via the config. The user data pointer is
-not passed into the callback as a parameter, but is instead set to the `pUserData` member of `ma_device` which you can access directly since all miniaudio
-structures are transparent.
-
-Initializing the device is done with `ma_device_init()`. This will return a result code telling you what went wrong, if anything. On success it will return
-`MA_SUCCESS`. After initialization is complete the device will be in a stopped state. To start it, use `ma_device_start()`. Uninitializing the device will stop
-it, which is what the example above does, but you can also stop the device with `ma_device_stop()`. To resume the device simply call `ma_device_start()` again.
-Note that it's important to never stop or start the device from inside the callback. This will result in a deadlock. Instead you set a variable or signal an
-event indicating that the device needs to stop and handle it in a different thread. The following APIs must never be called inside the callback:
-
-    ```c
-    ma_device_init()
-    ma_device_init_ex()
-    ma_device_uninit()
-    ma_device_start()
-    ma_device_stop()
-    ```
-
-You must never try uninitializing and reinitializing a device inside the callback. You must also never try to stop and start it from inside the callback. There
-are a few other things you shouldn't do in the callback depending on your requirements, however this isn't so much a thread-safety thing, but rather a
-real-time processing thing which is beyond the scope of this introduction.
-
-The example above demonstrates the initialization of a playback device, but it works exactly the same for capture. All you need to do is change the device type
-from `ma_device_type_playback` to `ma_device_type_capture` when setting up the config, like so:
-
-    ```c
-    ma_device_config config = ma_device_config_init(ma_device_type_capture);
-    config.capture.format   = MY_FORMAT;
-    config.capture.channels = MY_CHANNEL_COUNT;
-    ```
-
-In the data callback you just read from the input buffer (`pInput` in the example above) and leave the output buffer alone (it will be set to NULL when the
-device type is set to `ma_device_type_capture`).
-
-These are the available device types and how you should handle the buffers in the callback:
-
-    +-------------------------+--------------------------------------------------------+
-    | Device Type             | Callback Behavior                                      |
-    +-------------------------+--------------------------------------------------------+
-    | ma_device_type_playback | Write to output buffer, leave input buffer untouched.  |
-    | ma_device_type_capture  | Read from input buffer, leave output buffer untouched. |
-    | ma_device_type_duplex   | Read from input buffer, write to output buffer.        |
-    | ma_device_type_loopback | Read from input buffer, leave output buffer untouched. |
-    +-------------------------+--------------------------------------------------------+
-
-You will notice in the example above that the sample format and channel count is specified separately for playback and capture. This is to support different
-data formats between the playback and capture devices in a full-duplex system. An example may be that you want to capture audio data as a monaural stream (one
-channel), but output sound to a stereo speaker system. Note that if you use different formats between playback and capture in a full-duplex configuration you
-will need to convert the data yourself. There are functions available to help you do this which will be explained later.
-
-The example above did not specify a physical device to connect to which means it will use the operating system's default device. If you have multiple physical
-devices connected and you want to use a specific one you will need to specify the device ID in the configuration, like so:
-
-    ```c
-    config.playback.pDeviceID = pMyPlaybackDeviceID;    // Only if requesting a playback or duplex device.
-    config.capture.pDeviceID = pMyCaptureDeviceID;      // Only if requesting a capture, duplex or loopback device.
-    ```
-
-To retrieve the device ID you will need to perform device enumeration, however this requires the use of a new concept called the "context". Conceptually
-speaking the context sits above the device. There is one context to many devices. The purpose of the context is to represent the backend at a more global level
-and to perform operations outside the scope of an individual device. Mainly it is used for performing run-time linking against backend libraries, initializing
-backends and enumerating devices. The example below shows how to enumerate devices.
-
-    ```c
-    ma_context context;
-    if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
-        // Error.
-    }
-
-    ma_device_info* pPlaybackInfos;
-    ma_uint32 playbackCount;
-    ma_device_info* pCaptureInfos;
-    ma_uint32 captureCount;
-    if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) {
-        // Error.
-    }
-
-    // Loop over each device info and do something with it. Here we just print the name with their index. You may want
-    // to give the user the opportunity to choose which device they'd prefer.
-    for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) {
-        printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name);
-    }
-
-    ma_device_config config = ma_device_config_init(ma_device_type_playback);
-    config.playback.pDeviceID = &pPlaybackInfos[chosenPlaybackDeviceIndex].id;
-    config.playback.format    = MY_FORMAT;
-    config.playback.channels  = MY_CHANNEL_COUNT;
-    config.sampleRate         = MY_SAMPLE_RATE;
-    config.dataCallback       = data_callback;
-    config.pUserData          = pMyCustomData;
-
-    ma_device device;
-    if (ma_device_init(&context, &config, &device) != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_device_uninit(&device);
-    ma_context_uninit(&context);
-    ```
-
-The first thing we do in this example is initialize a `ma_context` object with `ma_context_init()`. The first parameter is a pointer to a list of `ma_backend`
-values which are used to override the default backend priorities. When this is NULL, as in this example, miniaudio's default priorities are used. The second
-parameter is the number of backends listed in the array pointed to by the first parameter. The third parameter is a pointer to a `ma_context_config` object
-which can be NULL, in which case defaults are used. The context configuration is used for setting the logging callback, custom memory allocation callbacks,
-user-defined data and some backend-specific configurations.
-
-Once the context has been initialized you can enumerate devices. In the example above we use the simpler `ma_context_get_devices()`, however you can also use a
-callback for handling devices by using `ma_context_enumerate_devices()`. When using `ma_context_get_devices()` you provide a pointer to a pointer that will,
-upon output, be set to a pointer to a buffer containing a list of `ma_device_info` structures. You also provide a pointer to an unsigned integer that will
-receive the number of items in the returned buffer. Do not free the returned buffers as their memory is managed internally by miniaudio.
-
-The `ma_device_info` structure contains an `id` member which is the ID you pass to the device config. It also contains the name of the device which is useful
-for presenting a list of devices to the user via the UI.
-
-When creating your own context you will want to pass it to `ma_device_init()` when initializing the device. Passing in NULL, like we do in the first example,
-will result in miniaudio creating the context for you, which you don't want to do since you've already created a context. Note that internally the context is
-only tracked by it's pointer which means you must not change the location of the `ma_context` object. If this is an issue, consider using `malloc()` to
-allocate memory for the context.
-
-
-
-2. Building
-===========
-miniaudio should work cleanly out of the box without the need to download or install any dependencies. See below for platform-specific details.
-
-
-2.1. Windows
-------------
-The Windows build should compile cleanly on all popular compilers without the need to configure any include paths nor link to any libraries.
-
-2.2. macOS and iOS
-------------------
-The macOS build should compile cleanly without the need to download any dependencies nor link to any libraries or frameworks. The iOS build needs to be
-compiled as Objective-C and will need to link the relevant frameworks but should compile cleanly out of the box with Xcode. Compiling through the command line
-requires linking to `-lpthread` and `-lm`.
-
-Due to the way miniaudio links to frameworks at runtime, your application may not pass Apple's notarization process. To fix this there are two options. The
-first is to use the `MA_NO_RUNTIME_LINKING` option, like so:
-
-    ```c
-    #ifdef __APPLE__
-        #define MA_NO_RUNTIME_LINKING
-    #endif
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-    ```
-
-This will require linking with `-framework CoreFoundation -framework CoreAudio -framework AudioUnit`. Alternatively, if you would rather keep using runtime
-linking you can add the following to your entitlements.xcent file:
-
-    ```
-    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
-    <true/>
-    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
-    <true/>
-    ```
-
-
-2.3. Linux
-----------
-The Linux build only requires linking to `-ldl`, `-lpthread` and `-lm`. You do not need any development packages.
-
-2.4. BSD
---------
-The BSD build only requires linking to `-lpthread` and `-lm`. NetBSD uses audio(4), OpenBSD uses sndio and FreeBSD uses OSS.
-
-2.5. Android
-------------
-AAudio is the highest priority backend on Android. This should work out of the box without needing any kind of compiler configuration. Support for AAudio
-starts with Android 8 which means older versions will fall back to OpenSL|ES which requires API level 16+.
-
-There have been reports that the OpenSL|ES backend fails to initialize on some Android based devices due to `dlopen()` failing to open "libOpenSLES.so". If
-this happens on your platform you'll need to disable run-time linking with `MA_NO_RUNTIME_LINKING` and link with -lOpenSLES.
-
-2.6. Emscripten
----------------
-The Emscripten build emits Web Audio JavaScript directly and should compile cleanly out of the box. You cannot use -std=c* compiler flags, nor -ansi.
-
-
-2.7. Build Options
-------------------
-`#define` these options before including miniaudio.h.
-
-    +----------------------------------+--------------------------------------------------------------------+
-    | Option                           | Description                                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WASAPI                     | Disables the WASAPI backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DSOUND                     | Disables the DirectSound backend.                                  |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WINMM                      | Disables the WinMM backend.                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_ALSA                       | Disables the ALSA backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_PULSEAUDIO                 | Disables the PulseAudio backend.                                   |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_JACK                       | Disables the JACK backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_COREAUDIO                  | Disables the Core Audio backend.                                   |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_SNDIO                      | Disables the sndio backend.                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AUDIO4                     | Disables the audio(4) backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_OSS                        | Disables the OSS backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AAUDIO                     | Disables the AAudio backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_OPENSL                     | Disables the OpenSL|ES backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WEBAUDIO                   | Disables the Web Audio backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_NULL                       | Disables the null backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_ONLY_SPECIFIC_BACKENDS | Disables all backends by default and requires `MA_ENABLE_*` to     |
-    |                                  | enable specific backends.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WASAPI                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the WASAPI backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_DSOUND                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the DirectSound backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WINMM                  | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the WinMM backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_ALSA                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the ALSA backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_PULSEAUDIO             | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the PulseAudio backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_JACK                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the JACK backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_COREAUDIO              | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the Core Audio backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_SNDIO                  | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the sndio backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_AUDIO4                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the audio(4) backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_OSS                    | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the OSS backend.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_AAUDIO                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the AAudio backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_OPENSL                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the OpenSL|ES backend.                                      |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WEBAUDIO               | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the Web Audio backend.                                      |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_NULL                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the null backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DECODING                   | Disables decoding APIs.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_ENCODING                   | Disables encoding APIs.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WAV                        | Disables the built-in WAV decoder and encoder.                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_FLAC                       | Disables the built-in FLAC decoder.                                |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_MP3                        | Disables the built-in MP3 decoder.                                 |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DEVICE_IO                  | Disables playback and recording. This will disable ma_context and  |
-    |                                  | ma_device APIs. This is useful if you only want to use miniaudio's |
-    |                                  | data conversion and/or decoding APIs.                              |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_THREADING                  | Disables the ma_thread, ma_mutex, ma_semaphore and ma_event APIs.  |
-    |                                  | This option is useful if you only need to use miniaudio for data   |
-    |                                  | conversion, decoding and/or encoding. Some families of APIs        |
-    |                                  | require threading which means the following options must also be   |
-    |                                  | set:                                                               |
-    |                                  |                                                                    |
-    |                                  |     ```                                                            |
-    |                                  |     MA_NO_DEVICE_IO                                                |
-    |                                  |     ```                                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_GENERATION                 | Disables generation APIs such a ma_waveform and ma_noise.          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_SSE2                       | Disables SSE2 optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AVX2                       | Disables AVX2 optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AVX512                     | Disables AVX-512 optimizations.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_NEON                       | Disables NEON optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_RUNTIME_LINKING            | Disables runtime linking. This is useful for passing Apple's       |
-    |                                  | notarization process. When enabling this, you may need to avoid    |
-    |                                  | using `-std=c89` or `-std=c99` on Linux builds or else you may end |
-    |                                  | up with compilation errors due to conflicts with `timespec` and    |
-    |                                  | `timeval` data types.                                              |
-    |                                  |                                                                    |
-    |                                  | You may need to enable this if your target platform does not allow |
-    |                                  | runtime linking via `dlopen()`.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_LOG_LEVEL [level]             | Sets the logging level. Set `level` to one of the following:       |
-    |                                  |                                                                    |
-    |                                  |     ```                                                            |
-    |                                  |     MA_LOG_LEVEL_VERBOSE                                           |
-    |                                  |     MA_LOG_LEVEL_INFO                                              |
-    |                                  |     MA_LOG_LEVEL_WARNING                                           |
-    |                                  |     MA_LOG_LEVEL_ERROR                                             |
-    |                                  |     ```                                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_DEBUG_OUTPUT                  | Enable `printf()` debug output.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_COINIT_VALUE                  | Windows only. The value to pass to internal calls to               |
-    |                                  | `CoInitializeEx()`. Defaults to `COINIT_MULTITHREADED`.            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_API                           | Controls how public APIs should be decorated. Default is `extern`. |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_DLL                           | If set, configures MA_API to either import or export APIs          |
-    |                                  | depending on whether or not the implementation is being defined.   |
-    |                                  | If defining the implementation, MA_API will be configured to       |
-    |                                  | export. Otherwise it will be configured to import. This has no     |
-    |                                  | effect if MA_API is defined externally.                            |
-    +----------------------------------+--------------------------------------------------------------------+
-
-
-3. Definitions
-==============
-This section defines common terms used throughout miniaudio. Unfortunately there is often ambiguity in the use of terms throughout the audio space, so this
-section is intended to clarify how miniaudio uses each term.
-
-3.1. Sample
------------
-A sample is a single unit of audio data. If the sample format is f32, then one sample is one 32-bit floating point number.
-
-3.2. Frame / PCM Frame
-----------------------
-A frame is a group of samples equal to the number of channels. For a stereo stream a frame is 2 samples, a mono frame is 1 sample, a 5.1 surround sound frame
-is 6 samples, etc. The terms "frame" and "PCM frame" are the same thing in miniaudio. Note that this is different to a compressed frame. If ever miniaudio
-needs to refer to a compressed frame, such as a FLAC frame, it will always clarify what it's referring to with something like "FLAC frame".
-
-3.3. Channel
-------------
-A stream of monaural audio that is emitted from an individual speaker in a speaker system, or received from an individual microphone in a microphone system. A
-stereo stream has two channels (a left channel, and a right channel), a 5.1 surround sound system has 6 channels, etc. Some audio systems refer to a channel as
-a complex audio stream that's mixed with other channels to produce the final mix - this is completely different to miniaudio's use of the term "channel" and
-should not be confused.
-
-3.4. Sample Rate
-----------------
-The sample rate in miniaudio is always expressed in Hz, such as 44100, 48000, etc. It's the number of PCM frames that are processed per second.
-
-3.5. Formats
-------------
-Throughout miniaudio you will see references to different sample formats:
-
-    +---------------+----------------------------------------+---------------------------+
-    | Symbol        | Description                            | Range                     |
-    +---------------+----------------------------------------+---------------------------+
-    | ma_format_f32 | 32-bit floating point                  | [-1, 1]                   |
-    | ma_format_s16 | 16-bit signed integer                  | [-32768, 32767]           |
-    | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607]       |
-    | ma_format_s32 | 32-bit signed integer                  | [-2147483648, 2147483647] |
-    | ma_format_u8  | 8-bit unsigned integer                 | [0, 255]                  |
-    +---------------+----------------------------------------+---------------------------+
-
-All formats are native-endian.
-
-
-
-4. Decoding
-===========
-The `ma_decoder` API is used for reading audio files. Decoders are completely decoupled from devices and can be used independently. The following formats are
-supported:
-
-    +---------+------------------+----------+
-    | Format  | Decoding Backend | Built-In |
-    +---------+------------------+----------+
-    | WAV     | dr_wav           | Yes      |
-    | MP3     | dr_mp3           | Yes      |
-    | FLAC    | dr_flac          | Yes      |
-    | Vorbis  | stb_vorbis       | No       |
-    +---------+------------------+----------+
-
-Vorbis is supported via stb_vorbis which can be enabled by including the header section before the implementation of miniaudio, like the following:
-
-    ```c
-    #define STB_VORBIS_HEADER_ONLY
-    #include "extras/stb_vorbis.c"    // Enables Vorbis decoding.
-
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-
-    // The stb_vorbis implementation must come after the implementation of miniaudio.
-    #undef STB_VORBIS_HEADER_ONLY
-    #include "extras/stb_vorbis.c"
-    ```
-
-A copy of stb_vorbis is included in the "extras" folder in the miniaudio repository (https://github.com/mackron/miniaudio).
-
-Built-in decoders are amalgamated into the implementation section of miniaudio. You can disable the built-in decoders by specifying one or more of the
-following options before the miniaudio implementation:
-
-    ```c
-    #define MA_NO_WAV
-    #define MA_NO_MP3
-    #define MA_NO_FLAC
-    ```
-
-Disabling built-in decoding libraries is useful if you use these libraries independantly of the `ma_decoder` API.
-
-A decoder can be initialized from a file with `ma_decoder_init_file()`, a block of memory with `ma_decoder_init_memory()`, or from data delivered via callbacks
-with `ma_decoder_init()`. Here is an example for loading a decoder from a file:
-
-    ```c
-    ma_decoder decoder;
-    ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder);
-    if (result != MA_SUCCESS) {
-        return false;   // An error occurred.
-    }
-
-    ...
-
-    ma_decoder_uninit(&decoder);
-    ```
-
-When initializing a decoder, you can optionally pass in a pointer to a `ma_decoder_config` object (the `NULL` argument in the example above) which allows you
-to configure the output format, channel count, sample rate and channel map:
-
-    ```c
-    ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000);
-    ```
-
-When passing in `NULL` for decoder config in `ma_decoder_init*()`, the output format will be the same as that defined by the decoding backend.
-
-Data is read from the decoder as PCM frames. This will return the number of PCM frames actually read. If the return value is less than the requested number of
-PCM frames it means you've reached the end:
-
-    ```c
-    ma_uint64 framesRead = ma_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead);
-    if (framesRead < framesToRead) {
-        // Reached the end.
-    }
-    ```
-
-You can also seek to a specific frame like so:
-
-    ```c
-    ma_result result = ma_decoder_seek_to_pcm_frame(pDecoder, targetFrame);
-    if (result != MA_SUCCESS) {
-        return false;   // An error occurred.
-    }
-    ```
-
-If you want to loop back to the start, you can simply seek back to the first PCM frame:
-
-    ```c
-    ma_decoder_seek_to_pcm_frame(pDecoder, 0);
-    ```
-
-When loading a decoder, miniaudio uses a trial and error technique to find the appropriate decoding backend. This can be unnecessarily inefficient if the type
-is already known. In this case you can use the `_wav`, `_mp3`, etc. varients of the aforementioned initialization APIs:
-
-    ```c
-    ma_decoder_init_wav()
-    ma_decoder_init_mp3()
-    ma_decoder_init_memory_wav()
-    ma_decoder_init_memory_mp3()
-    ma_decoder_init_file_wav()
-    ma_decoder_init_file_mp3()
-    etc.
-    ```
-
-The `ma_decoder_init_file()` API will try using the file extension to determine which decoding backend to prefer.
-
-
-
-5. Encoding
-===========
-The `ma_encoding` API is used for writing audio files. The only supported output format is WAV which is achieved via dr_wav which is amalgamated into the
-implementation section of miniaudio. This can be disabled by specifying the following option before the implementation of miniaudio:
-
-    ```c
-    #define MA_NO_WAV
-    ```
-
-An encoder can be initialized to write to a file with `ma_encoder_init_file()` or from data delivered via callbacks with `ma_encoder_init()`. Below is an
-example for initializing an encoder to output to a file.
-
-    ```c
-    ma_encoder_config config = ma_encoder_config_init(ma_resource_format_wav, FORMAT, CHANNELS, SAMPLE_RATE);
-    ma_encoder encoder;
-    ma_result result = ma_encoder_init_file("my_file.wav", &config, &encoder);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_encoder_uninit(&encoder);
-    ```
-
-When initializing an encoder you must specify a config which is initialized with `ma_encoder_config_init()`. Here you must specify the file type, the output
-sample format, output channel count and output sample rate. The following file types are supported:
-
-    +------------------------+-------------+
-    | Enum                   | Description |
-    +------------------------+-------------+
-    | ma_resource_format_wav | WAV         |
-    +------------------------+-------------+
-
-If the format, channel count or sample rate is not supported by the output file type an error will be returned. The encoder will not perform data conversion so
-you will need to convert it before outputting any audio data. To output audio data, use `ma_encoder_write_pcm_frames()`, like in the example below:
-
-    ```c
-    framesWritten = ma_encoder_write_pcm_frames(&encoder, pPCMFramesToWrite, framesToWrite);
-    ```
-
-Encoders must be uninitialized with `ma_encoder_uninit()`.
-
-
-6. Data Conversion
-==================
-A data conversion API is included with miniaudio which supports the majority of data conversion requirements. This supports conversion between sample formats,
-channel counts (with channel mapping) and sample rates.
-
-
-6.1. Sample Format Conversion
------------------------------
-Conversion between sample formats is achieved with the `ma_pcm_*_to_*()`, `ma_pcm_convert()` and `ma_convert_pcm_frames_format()` APIs. Use `ma_pcm_*_to_*()`
-to convert between two specific formats. Use `ma_pcm_convert()` to convert based on a `ma_format` variable. Use `ma_convert_pcm_frames_format()` to convert
-PCM frames where you want to specify the frame count and channel count as a variable instead of the total sample count.
-
-
-6.1.1. Dithering
-----------------
-Dithering can be set using the ditherMode parameter.
-
-The different dithering modes include the following, in order of efficiency:
-
-    +-----------+--------------------------+
-    | Type      | Enum Token               |
-    +-----------+--------------------------+
-    | None      | ma_dither_mode_none      |
-    | Rectangle | ma_dither_mode_rectangle |
-    | Triangle  | ma_dither_mode_triangle  |
-    +-----------+--------------------------+
-
-Note that even if the dither mode is set to something other than `ma_dither_mode_none`, it will be ignored for conversions where dithering is not needed.
-Dithering is available for the following conversions:
-
-    ```
-    s16 -> u8
-    s24 -> u8
-    s32 -> u8
-    f32 -> u8
-    s24 -> s16
-    s32 -> s16
-    f32 -> s16
-    ```
-
-Note that it is not an error to pass something other than ma_dither_mode_none for conversions where dither is not used. It will just be ignored.
-
-
-
-6.2. Channel Conversion
------------------------
-Channel conversion is used for channel rearrangement and conversion from one channel count to another. The `ma_channel_converter` API is used for channel
-conversion. Below is an example of initializing a simple channel converter which converts from mono to stereo.
-
-    ```c
-    ma_channel_converter_config config = ma_channel_converter_config_init(
-        ma_format,                      // Sample format
-        1,                              // Input channels
-        NULL,                           // Input channel map
-        2,                              // Output channels
-        NULL,                           // Output channel map
-        ma_channel_mix_mode_default);   // The mixing algorithm to use when combining channels.
-
-    result = ma_channel_converter_init(&config, &converter);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-    ```
-
-To perform the conversion simply call `ma_channel_converter_process_pcm_frames()` like so:
-
-    ```c
-    ma_result result = ma_channel_converter_process_pcm_frames(&converter, pFramesOut, pFramesIn, frameCount);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-    ```
-
-It is up to the caller to ensure the output buffer is large enough to accomodate the new PCM frames.
-
-Input and output PCM frames are always interleaved. Deinterleaved layouts are not supported.
-
-
-6.2.1. Channel Mapping
-----------------------
-In addition to converting from one channel count to another, like the example above, the channel converter can also be used to rearrange channels. When
-initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, and each
-channel map contains the same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If,
-however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is
-specified when initializing the `ma_channel_converter_config` object.
-
-When converting from mono to multi-channel, the mono channel is simply copied to each output channel. When going the other way around, the audio of each output
-channel is simply averaged and copied to the mono channel.
-
-In more complicated cases blending is used. The `ma_channel_mix_mode_simple` mode will drop excess channels and silence extra channels. For example, converting
-from 4 to 2 channels, the 3rd and 4th channels will be dropped, whereas converting from 2 to 4 channels will put silence into the 3rd and 4th channels.
-
-The `ma_channel_mix_mode_rectangle` mode uses spacial locality based on a rectangle to compute a simple distribution between input and output. Imagine sitting
-in the middle of a room, with speakers on the walls representing channel positions. The MA_CHANNEL_FRONT_LEFT position can be thought of as being in the corner
-of the front and left walls.
-
-Finally, the `ma_channel_mix_mode_custom_weights` mode can be used to use custom user-defined weights. Custom weights can be passed in as the last parameter of
-`ma_channel_converter_config_init()`.
-
-Predefined channel maps can be retrieved with `ma_get_standard_channel_map()`. This takes a `ma_standard_channel_map` enum as it's first parameter, which can
-be one of the following:
-
-    +-----------------------------------+-----------------------------------------------------------+
-    | Name                              | Description                                               |
-    +-----------------------------------+-----------------------------------------------------------+
-    | ma_standard_channel_map_default   | Default channel map used by miniaudio. See below.         |
-    | ma_standard_channel_map_microsoft | Channel map used by Microsoft's bitfield channel maps.    |
-    | ma_standard_channel_map_alsa      | Default ALSA channel map.                                 |
-    | ma_standard_channel_map_rfc3551   | RFC 3551. Based on AIFF.                                  |
-    | ma_standard_channel_map_flac      | FLAC channel map.                                         |
-    | ma_standard_channel_map_vorbis    | Vorbis channel map.                                       |
-    | ma_standard_channel_map_sound4    | FreeBSD's sound(4).                                       |
-    | ma_standard_channel_map_sndio     | sndio channel map. http://www.sndio.org/tips.html.        |
-    | ma_standard_channel_map_webaudio  | https://webaudio.github.io/web-audio-api/#ChannelOrdering |
-    +-----------------------------------+-----------------------------------------------------------+
-
-Below are the channel maps used by default in miniaudio (`ma_standard_channel_map_default`):
-
-    +---------------+---------------------------------+
-    | Channel Count | Mapping                         |
-    +---------------+---------------------------------+
-    | 1 (Mono)      | 0: MA_CHANNEL_MONO              |
-    +---------------+---------------------------------+
-    | 2 (Stereo)    | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT       |
-    +---------------+---------------------------------+
-    | 3             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER      |
-    +---------------+---------------------------------+
-    | 4 (Surround)  | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_BACK_CENTER       |
-    +---------------+---------------------------------+
-    | 5             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_BACK_LEFT    <br> |
-    |               | 4: MA_CHANNEL_BACK_RIGHT        |
-    +---------------+---------------------------------+
-    | 6 (5.1)       | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 5: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | 7             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_BACK_CENTER  <br> |
-    |               | 4: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 5: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | 8 (7.1)       | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_BACK_LEFT    <br> |
-    |               | 5: MA_CHANNEL_BACK_RIGHT   <br> |
-    |               | 6: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 7: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | Other         | All channels set to 0. This     |
-    |               | is equivalent to the same       |
-    |               | mapping as the device.          |
-    +---------------+---------------------------------+
-
-
-
-6.3. Resampling
----------------
-Resampling is achieved with the `ma_resampler` object. To create a resampler object, do something like the following:
-
-    ```c
-    ma_resampler_config config = ma_resampler_config_init(
-        ma_format_s16,
-        channels,
-        sampleRateIn,
-        sampleRateOut,
-        ma_resample_algorithm_linear);
-
-    ma_resampler resampler;
-    ma_result result = ma_resampler_init(&config, &resampler);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-    ```
-
-Do the following to uninitialize the resampler:
-
-    ```c
-    ma_resampler_uninit(&resampler);
-    ```
-
-The following example shows how data can be processed
-
-    ```c
-    ma_uint64 frameCountIn  = 1000;
-    ma_uint64 frameCountOut = 2000;
-    ma_result result = ma_resampler_process_pcm_frames(&resampler, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-
-    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the
-    // number of output frames written.
-    ```
-
-To initialize the resampler you first need to set up a config (`ma_resampler_config`) with `ma_resampler_config_init()`. You need to specify the sample format
-you want to use, the number of channels, the input and output sample rate, and the algorithm.
-
-The sample format can be either `ma_format_s16` or `ma_format_f32`. If you need a different format you will need to perform pre- and post-conversions yourself
-where necessary. Note that the format is the same for both input and output. The format cannot be changed after initialization.
-
-The resampler supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.
-
-The sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the
-only configuration property that can be changed after initialization.
-
-The miniaudio resampler supports multiple algorithms:
-
-    +-----------+------------------------------+
-    | Algorithm | Enum Token                   |
-    +-----------+------------------------------+
-    | Linear    | ma_resample_algorithm_linear |
-    | Speex     | ma_resample_algorithm_speex  |
-    +-----------+------------------------------+
-
-Because Speex is not public domain it is strictly opt-in and the code is stored in separate files. if you opt-in to the Speex backend you will need to consider
-it's license, the text of which can be found in it's source files in "extras/speex_resampler". Details on how to opt-in to the Speex resampler is explained in
-the Speex Resampler section below.
-
-The algorithm cannot be changed after initialization.
-
-Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process
-frames, use `ma_resampler_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of
-input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the
-number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large
-buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.
-
-The sample rate can be changed dynamically on the fly. You can change this with explicit sample rates with `ma_resampler_set_rate()` and also with a decimal
-ratio with `ma_resampler_set_rate_ratio()`. The ratio is in/out.
-
-Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with
-`ma_resampler_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of
-input frames. You can do this with `ma_resampler_get_expected_output_frame_count()`.
-
-Due to the nature of how resampling works, the resampler introduces some latency. This can be retrieved in terms of both the input rate and the output rate
-with `ma_resampler_get_input_latency()` and `ma_resampler_get_output_latency()`.
-
-
-6.3.1. Resampling Algorithms
-----------------------------
-The choice of resampling algorithm depends on your situation and requirements. The linear resampler is the most efficient and has the least amount of latency,
-but at the expense of poorer quality. The Speex resampler is higher quality, but slower with more latency. It also performs several heap allocations internally
-for memory management.
-
-
-6.3.1.1. Linear Resampling
---------------------------
-The linear resampler is the fastest, but comes at the expense of poorer quality. There is, however, some control over the quality of the linear resampler which
-may make it a suitable option depending on your requirements.
-
-The linear resampler performs low-pass filtering before or after downsampling or upsampling, depending on the sample rates you're converting between. When
-decreasing the sample rate, the low-pass filter will be applied before downsampling. When increasing the rate it will be performed after upsampling. By default
-a fourth order low-pass filter will be applied. This can be configured via the `lpfOrder` configuration variable. Setting this to 0 will disable filtering.
-
-The low-pass filter has a cutoff frequency which defaults to half the sample rate of the lowest of the input and output sample rates (Nyquist Frequency). This
-can be controlled with the `lpfNyquistFactor` config variable. This defaults to 1, and should be in the range of 0..1, although a value of 0 does not make
-sense and should be avoided. A value of 1 will use the Nyquist Frequency as the cutoff. A value of 0.5 will use half the Nyquist Frequency as the cutoff, etc.
-Values less than 1 will result in more washed out sound due to more of the higher frequencies being removed. This config variable has no impact on performance
-and is a purely perceptual configuration.
-
-The API for the linear resampler is the same as the main resampler API, only it's called `ma_linear_resampler`.
-
-
-6.3.1.2. Speex Resampling
--------------------------
-The Speex resampler is made up of third party code which is released under the BSD license. Because it is licensed differently to miniaudio, which is public
-domain, it is strictly opt-in and all of it's code is stored in separate files. If you opt-in to the Speex resampler you must consider the license text in it's
-source files. To opt-in, you must first `#include` the following file before the implementation of miniaudio.h:
-
-    ```c
-    #include "extras/speex_resampler/ma_speex_resampler.h"
-    ```
-
-Both the header and implementation is contained within the same file. The implementation can be included in your program like so:
-
-    ```c
-    #define MINIAUDIO_SPEEX_RESAMPLER_IMPLEMENTATION
-    #include "extras/speex_resampler/ma_speex_resampler.h"
-    ```
-
-Note that even if you opt-in to the Speex backend, miniaudio won't use it unless you explicitly ask for it in the respective config of the object you are
-initializing. If you try to use the Speex resampler without opting in, initialization of the `ma_resampler` object will fail with `MA_NO_BACKEND`.
-
-The only configuration option to consider with the Speex resampler is the `speex.quality` config variable. This is a value between 0 and 10, with 0 being
-the fastest with the poorest quality and 10 being the slowest with the highest quality. The default value is 3.
-
-
-
-6.4. General Data Conversion
-----------------------------
-The `ma_data_converter` API can be used to wrap sample format conversion, channel conversion and resampling into one operation. This is what miniaudio uses
-internally to convert between the format requested when the device was initialized and the format of the backend's native device. The API for general data
-conversion is very similar to the resampling API. Create a `ma_data_converter` object like this:
-
-    ```c
-    ma_data_converter_config config = ma_data_converter_config_init(
-        inputFormat,
-        outputFormat,
-        inputChannels,
-        outputChannels,
-        inputSampleRate,
-        outputSampleRate
-    );
-
-    ma_data_converter converter;
-    ma_result result = ma_data_converter_init(&config, &converter);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-    ```
-
-In the example above we use `ma_data_converter_config_init()` to initialize the config, however there's many more properties that can be configured, such as
-channel maps and resampling quality. Something like the following may be more suitable depending on your requirements:
-
-    ```c
-    ma_data_converter_config config = ma_data_converter_config_init_default();
-    config.formatIn = inputFormat;
-    config.formatOut = outputFormat;
-    config.channelsIn = inputChannels;
-    config.channelsOut = outputChannels;
-    config.sampleRateIn = inputSampleRate;
-    config.sampleRateOut = outputSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_flac, config.channelCountIn, config.channelMapIn);
-    config.resampling.linear.lpfOrder = MA_MAX_FILTER_ORDER;
-    ```
-
-Do the following to uninitialize the data converter:
-
-    ```c
-    ma_data_converter_uninit(&converter);
-    ```
-
-The following example shows how data can be processed
-
-    ```c
-    ma_uint64 frameCountIn  = 1000;
-    ma_uint64 frameCountOut = 2000;
-    ma_result result = ma_data_converter_process_pcm_frames(&converter, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-
-    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the number
-    // of output frames written.
-    ```
-
-The data converter supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.
-
-Sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only
-configuration property that can be changed after initialization, but only if the `resampling.allowDynamicSampleRate` member of `ma_data_converter_config` is
-set to `MA_TRUE`. To change the sample rate, use `ma_data_converter_set_rate()` or `ma_data_converter_set_rate_ratio()`. The ratio must be in/out. The
-resampling algorithm cannot be changed after initialization.
-
-Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process
-frames, use `ma_data_converter_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number
-of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the
-number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large
-buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.
-
-Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with
-`ma_data_converter_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of
-input frames. You can do this with `ma_data_converter_get_expected_output_frame_count()`.
-
-Due to the nature of how resampling works, the data converter introduces some latency if resampling is required. This can be retrieved in terms of both the
-input rate and the output rate with `ma_data_converter_get_input_latency()` and `ma_data_converter_get_output_latency()`.
-
-
-
-7. Filtering
-============
-
-7.1. Biquad Filtering
----------------------
-Biquad filtering is achieved with the `ma_biquad` API. Example:
-
-    ```c
-    ma_biquad_config config = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2);
-    ma_result result = ma_biquad_init(&config, &biquad);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_biquad_process_pcm_frames(&biquad, pFramesOut, pFramesIn, frameCount);
-    ```
-
-Biquad filtering is implemented using transposed direct form 2. The numerator coefficients are b0, b1 and b2, and the denominator coefficients are a0, a1 and
-a2. The a0 coefficient is required and coefficients must not be pre-normalized.
-
-Supported formats are `ma_format_s16` and `ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. When using
-`ma_format_s16` the biquad filter will use fixed point arithmetic. When using `ma_format_f32`, floating point arithmetic will be used.
-
-Input and output frames are always interleaved.
-
-Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:
-
-    ```c
-    ma_biquad_process_pcm_frames(&biquad, pMyData, pMyData, frameCount);
-    ```
-
-If you need to change the values of the coefficients, but maintain the values in the registers you can do so with `ma_biquad_reinit()`. This is useful if you
-need to change the properties of the filter while keeping the values of registers valid to avoid glitching. Do not use `ma_biquad_init()` for this as it will
-do a full initialization which involves clearing the registers to 0. Note that changing the format or channel count after initialization is invalid and will
-result in an error.
-
-
-7.2. Low-Pass Filtering
------------------------
-Low-pass filtering is achieved with the following APIs:
-
-    +---------+------------------------------------------+
-    | API     | Description                              |
-    +---------+------------------------------------------+
-    | ma_lpf1 | First order low-pass filter              |
-    | ma_lpf2 | Second order low-pass filter             |
-    | ma_lpf  | High order low-pass filter (Butterworth) |
-    +---------+------------------------------------------+
-
-Low-pass filter example:
-
-    ```c
-    ma_lpf_config config = ma_lpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order);
-    ma_result result = ma_lpf_init(&config, &lpf);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_lpf_process_pcm_frames(&lpf, pFramesOut, pFramesIn, frameCount);
-    ```
-
-Supported formats are `ma_format_s16` and` ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. Input and output
-frames are always interleaved.
-
-Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:
-
-    ```c
-    ma_lpf_process_pcm_frames(&lpf, pMyData, pMyData, frameCount);
-    ```
-
-The maximum filter order is limited to `MA_MAX_FILTER_ORDER` which is set to 8. If you need more, you can chain first and second order filters together.
-
-    ```c
-    for (iFilter = 0; iFilter < filterCount; iFilter += 1) {
-        ma_lpf2_process_pcm_frames(&lpf2[iFilter], pMyData, pMyData, frameCount);
-    }
-    ```
-
-If you need to change the configuration of the filter, but need to maintain the state of internal registers you can do so with `ma_lpf_reinit()`. This may be
-useful if you need to change the sample rate and/or cutoff frequency dynamically while maintaing smooth transitions. Note that changing the format or channel
-count after initialization is invalid and will result in an error.
-
-The `ma_lpf` object supports a configurable order, but if you only need a first order filter you may want to consider using `ma_lpf1`. Likewise, if you only
-need a second order filter you can use `ma_lpf2`. The advantage of this is that they're lighter weight and a bit more efficient.
-
-If an even filter order is specified, a series of second order filters will be processed in a chain. If an odd filter order is specified, a first order filter
-will be applied, followed by a series of second order filters in a chain.
-
-
-7.3. High-Pass Filtering
-------------------------
-High-pass filtering is achieved with the following APIs:
-
-    +---------+-------------------------------------------+
-    | API     | Description                               |
-    +---------+-------------------------------------------+
-    | ma_hpf1 | First order high-pass filter              |
-    | ma_hpf2 | Second order high-pass filter             |
-    | ma_hpf  | High order high-pass filter (Butterworth) |
-    +---------+-------------------------------------------+
-
-High-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_hpf1`, `ma_hpf2` and `ma_hpf`. See example code for low-pass filters
-for example usage.
-
-
-7.4. Band-Pass Filtering
-------------------------
-Band-pass filtering is achieved with the following APIs:
-
-    +---------+-------------------------------+
-    | API     | Description                   |
-    +---------+-------------------------------+
-    | ma_bpf2 | Second order band-pass filter |
-    | ma_bpf  | High order band-pass filter   |
-    +---------+-------------------------------+
-
-Band-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_bpf2` and `ma_hpf`. See example code for low-pass filters for example
-usage. Note that the order for band-pass filters must be an even number which means there is no first order band-pass filter, unlike low-pass and high-pass
-filters.
-
-
-7.5. Notch Filtering
---------------------
-Notch filtering is achieved with the following APIs:
-
-    +-----------+------------------------------------------+
-    | API       | Description                              |
-    +-----------+------------------------------------------+
-    | ma_notch2 | Second order notching filter             |
-    +-----------+------------------------------------------+
-
-
-7.6. Peaking EQ Filtering
--------------------------
-Peaking filtering is achieved with the following APIs:
-
-    +----------+------------------------------------------+
-    | API      | Description                              |
-    +----------+------------------------------------------+
-    | ma_peak2 | Second order peaking filter              |
-    +----------+------------------------------------------+
-
-
-7.7. Low Shelf Filtering
-------------------------
-Low shelf filtering is achieved with the following APIs:
-
-    +-------------+------------------------------------------+
-    | API         | Description                              |
-    +-------------+------------------------------------------+
-    | ma_loshelf2 | Second order low shelf filter            |
-    +-------------+------------------------------------------+
-
-Where a high-pass filter is used to eliminate lower frequencies, a low shelf filter can be used to just turn them down rather than eliminate them entirely.
-
-
-7.8. High Shelf Filtering
--------------------------
-High shelf filtering is achieved with the following APIs:
-
-    +-------------+------------------------------------------+
-    | API         | Description                              |
-    +-------------+------------------------------------------+
-    | ma_hishelf2 | Second order high shelf filter           |
-    +-------------+------------------------------------------+
-
-The high shelf filter has the same API as the low shelf filter, only you would use `ma_hishelf` instead of `ma_loshelf`. Where a low shelf filter is used to
-adjust the volume of low frequencies, the high shelf filter does the same thing for high frequencies.
-
-
-
-
-8. Waveform and Noise Generation
-================================
-
-8.1. Waveforms
---------------
-miniaudio supports generation of sine, square, triangle and sawtooth waveforms. This is achieved with the `ma_waveform` API. Example:
-
-    ```c
-    ma_waveform_config config = ma_waveform_config_init(
-        FORMAT,
-        CHANNELS,
-        SAMPLE_RATE,
-        ma_waveform_type_sine,
-        amplitude,
-        frequency);
-
-    ma_waveform waveform;
-    ma_result result = ma_waveform_init(&config, &waveform);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_waveform_read_pcm_frames(&waveform, pOutput, frameCount);
-    ```
-
-The amplitude, frequency, type, and sample rate can be changed dynamically with `ma_waveform_set_amplitude()`, `ma_waveform_set_frequency()`,
-`ma_waveform_set_type()`, and `ma_waveform_set_sample_rate()` respectively.
-
-You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative
-ramp, for example.
-
-Below are the supported waveform types:
-
-    +---------------------------+
-    | Enum Name                 |
-    +---------------------------+
-    | ma_waveform_type_sine     |
-    | ma_waveform_type_square   |
-    | ma_waveform_type_triangle |
-    | ma_waveform_type_sawtooth |
-    +---------------------------+
-
-
-
-8.2. Noise
-----------
-miniaudio supports generation of white, pink and Brownian noise via the `ma_noise` API. Example:
-
-    ```c
-    ma_noise_config config = ma_noise_config_init(
-        FORMAT,
-        CHANNELS,
-        ma_noise_type_white,
-        SEED,
-        amplitude);
-
-    ma_noise noise;
-    ma_result result = ma_noise_init(&config, &noise);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_noise_read_pcm_frames(&noise, pOutput, frameCount);
-    ```
-
-The noise API uses simple LCG random number generation. It supports a custom seed which is useful for things like automated testing requiring reproducibility.
-Setting the seed to zero will default to `MA_DEFAULT_LCG_SEED`.
-
-The amplitude, seed, and type can be changed dynamically with `ma_noise_set_amplitude()`, `ma_noise_set_seed()`, and `ma_noise_set_type()` respectively.
-
-By default, the noise API will use different values for different channels. So, for example, the left side in a stereo stream will be different to the right
-side. To instead have each channel use the same random value, set the `duplicateChannels` member of the noise config to true, like so:
-
-    ```c
-    config.duplicateChannels = MA_TRUE;
-    ```
-
-Below are the supported noise types.
-
-    +------------------------+
-    | Enum Name              |
-    +------------------------+
-    | ma_noise_type_white    |
-    | ma_noise_type_pink     |
-    | ma_noise_type_brownian |
-    +------------------------+
-
-
-
-9. Audio Buffers
-================
-miniaudio supports reading from a buffer of raw audio data via the `ma_audio_buffer` API. This can read from memory that's managed by the application, but
-can also handle the memory management for you internally. Memory management is flexible and should support most use cases.
-
-Audio buffers are initialised using the standard configuration system used everywhere in miniaudio:
-
-    ```c
-    ma_audio_buffer_config config = ma_audio_buffer_config_init(
-        format,
-        channels,
-        sizeInFrames,
-        pExistingData,
-        &allocationCallbacks);
-
-    ma_audio_buffer buffer;
-    result = ma_audio_buffer_init(&config, &buffer);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_audio_buffer_uninit(&buffer);
-    ```
-
-In the example above, the memory pointed to by `pExistingData` will *not* be copied and is how an application can do self-managed memory allocation. If you
-would rather make a copy of the data, use `ma_audio_buffer_init_copy()`. To uninitialize the buffer, use `ma_audio_buffer_uninit()`.
-
-Sometimes it can be convenient to allocate the memory for the `ma_audio_buffer` structure and the raw audio data in a contiguous block of memory. That is,
-the raw audio data will be located immediately after the `ma_audio_buffer` structure. To do this, use `ma_audio_buffer_alloc_and_init()`:
-
-    ```c
-    ma_audio_buffer_config config = ma_audio_buffer_config_init(
-        format,
-        channels,
-        sizeInFrames,
-        pExistingData,
-        &allocationCallbacks);
-
-    ma_audio_buffer* pBuffer
-    result = ma_audio_buffer_alloc_and_init(&config, &pBuffer);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_audio_buffer_uninit_and_free(&buffer);
-    ```
-
-If you initialize the buffer with `ma_audio_buffer_alloc_and_init()` you should uninitialize it with `ma_audio_buffer_uninit_and_free()`. In the example above,
-the memory pointed to by `pExistingData` will be copied into the buffer, which is contrary to the behavior of `ma_audio_buffer_init()`.
-
-An audio buffer has a playback cursor just like a decoder. As you read frames from the buffer, the cursor moves forward. The last parameter (`loop`) can be
-used to determine if the buffer should loop. The return value is the number of frames actually read. If this is less than the number of frames requested it
-means the end has been reached. This should never happen if the `loop` parameter is set to true. If you want to manually loop back to the start, you can do so
-with with `ma_audio_buffer_seek_to_pcm_frame(pAudioBuffer, 0)`. Below is an example for reading data from an audio buffer.
-
-    ```c
-    ma_uint64 framesRead = ma_audio_buffer_read_pcm_frames(pAudioBuffer, pFramesOut, desiredFrameCount, isLooping);
-    if (framesRead < desiredFrameCount) {
-        // If not looping, this means the end has been reached. This should never happen in looping mode with valid input.
-    }
-    ```
-
-Sometimes you may want to avoid the cost of data movement between the internal buffer and the output buffer. Instead you can use memory mapping to retrieve a
-pointer to a segment of data:
-
-    ```c
-    void* pMappedFrames;
-    ma_uint64 frameCount = frameCountToTryMapping;
-    ma_result result = ma_audio_buffer_map(pAudioBuffer, &pMappedFrames, &frameCount);
-    if (result == MA_SUCCESS) {
-        // Map was successful. The value in frameCount will be how many frames were _actually_ mapped, which may be
-        // less due to the end of the buffer being reached.
-        ma_copy_pcm_frames(pFramesOut, pMappedFrames, frameCount, pAudioBuffer->format, pAudioBuffer->channels);
-
-        // You must unmap the buffer.
-        ma_audio_buffer_unmap(pAudioBuffer, frameCount);
-    }
-    ```
-
-When you use memory mapping, the read cursor is increment by the frame count passed in to `ma_audio_buffer_unmap()`. If you decide not to process every frame
-you can pass in a value smaller than the value returned by `ma_audio_buffer_map()`. The disadvantage to using memory mapping is that it does not handle looping
-for you. You can determine if the buffer is at the end for the purpose of looping with `ma_audio_buffer_at_end()` or by inspecting the return value of
-`ma_audio_buffer_unmap()` and checking if it equals `MA_AT_END`. You should not treat `MA_AT_END` as an error when returned by `ma_audio_buffer_unmap()`.
-
-
-
-10. Ring Buffers
-================
-miniaudio supports lock free (single producer, single consumer) ring buffers which are exposed via the `ma_rb` and `ma_pcm_rb` APIs. The `ma_rb` API operates
-on bytes, whereas the `ma_pcm_rb` operates on PCM frames. They are otherwise identical as `ma_pcm_rb` is just a wrapper around `ma_rb`.
-
-Unlike most other APIs in miniaudio, ring buffers support both interleaved and deinterleaved streams. The caller can also allocate their own backing memory for
-the ring buffer to use internally for added flexibility. Otherwise the ring buffer will manage it's internal memory for you.
-
-The examples below use the PCM frame variant of the ring buffer since that's most likely the one you will want to use. To initialize a ring buffer, do
-something like the following:
-
-    ```c
-    ma_pcm_rb rb;
-    ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, NULL, NULL, &rb);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-    ```
-
-The `ma_pcm_rb_init()` function takes the sample format and channel count as parameters because it's the PCM varient of the ring buffer API. For the regular
-ring buffer that operates on bytes you would call `ma_rb_init()` which leaves these out and just takes the size of the buffer in bytes instead of frames. The
-fourth parameter is an optional pre-allocated buffer and the fifth parameter is a pointer to a `ma_allocation_callbacks` structure for custom memory allocation
-routines. Passing in `NULL` for this results in `MA_MALLOC()` and `MA_FREE()` being used.
-
-Use `ma_pcm_rb_init_ex()` if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your
-sub-buffers you can use `ma_pcm_rb_get_subbuffer_stride()`, `ma_pcm_rb_get_subbuffer_offset()` and `ma_pcm_rb_get_subbuffer_ptr()`.
-
-Use `ma_pcm_rb_acquire_read()` and `ma_pcm_rb_acquire_write()` to retrieve a pointer to a section of the ring buffer. You specify the number of frames you
-need, and on output it will set to what was actually acquired. If the read or write pointer is positioned such that the number of frames requested will require
-a loop, it will be clamped to the end of the buffer. Therefore, the number of frames you're given may be less than the number you requested.
-
-After calling `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()`, you do your work on the buffer and then "commit" it with `ma_pcm_rb_commit_read()` or
-`ma_pcm_rb_commit_write()`. This is where the read/write pointers are updated. When you commit you need to pass in the buffer that was returned by the earlier
-call to `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()` and is only used for validation. The number of frames passed to `ma_pcm_rb_commit_read()` and
-`ma_pcm_rb_commit_write()` is what's used to increment the pointers, and can be less that what was originally requested.
-
-If you want to correct for drift between the write pointer and the read pointer you can use a combination of `ma_pcm_rb_pointer_distance()`,
-`ma_pcm_rb_seek_read()` and `ma_pcm_rb_seek_write()`. Note that you can only move the pointers forward, and you should only move the read pointer forward via
-the consumer thread, and the write pointer forward by the producer thread. If there is too much space between the pointers, move the read pointer forward. If
-there is too little space between the pointers, move the write pointer forward.
-
-You can use a ring buffer at the byte level instead of the PCM frame level by using the `ma_rb` API. This is exactly the same, only you will use the `ma_rb`
-functions instead of `ma_pcm_rb` and instead of frame counts you will pass around byte counts.
-
-The maximum size of the buffer in bytes is `0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1)` due to the most significant bit being used to encode a loop flag and the internally
-managed buffers always being aligned to MA_SIMD_ALIGNMENT.
-
-Note that the ring buffer is only thread safe when used by a single consumer thread and single producer thread.
-
-
-
-11. Backends
-============
-The following backends are supported by miniaudio.
-
-    +-------------+-----------------------+--------------------------------------------------------+
-    | Name        | Enum Name             | Supported Operating Systems                            |
-    +-------------+-----------------------+--------------------------------------------------------+
-    | WASAPI      | ma_backend_wasapi     | Windows Vista+                                         |
-    | DirectSound | ma_backend_dsound     | Windows XP+                                            |
-    | WinMM       | ma_backend_winmm      | Windows XP+ (may work on older versions, but untested) |
-    | Core Audio  | ma_backend_coreaudio  | macOS, iOS                                             |
-    | ALSA        | ma_backend_alsa       | Linux                                                  |
-    | PulseAudio  | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android)  |
-    | JACK        | ma_backend_jack       | Cross Platform (disabled on BSD and Android)           |
-    | sndio       | ma_backend_sndio      | OpenBSD                                                |
-    | audio(4)    | ma_backend_audio4     | NetBSD, OpenBSD                                        |
-    | OSS         | ma_backend_oss        | FreeBSD                                                |
-    | AAudio      | ma_backend_aaudio     | Android 8+                                             |
-    | OpenSL ES   | ma_backend_opensl     | Android (API level 16+)                                |
-    | Web Audio   | ma_backend_webaudio   | Web (via Emscripten)                                   |
-    | Custom      | ma_backend_custom     | Cross Platform                                         |
-    | Null        | ma_backend_null       | Cross Platform (not used on Web)                       |
-    +-------------+-----------------------+--------------------------------------------------------+
-
-Some backends have some nuance details you may want to be aware of.
-
-11.1. WASAPI
-------------
-- Low-latency shared mode will be disabled when using an application-defined sample rate which is different to the device's native sample rate. To work around
-  this, set `wasapi.noAutoConvertSRC` to true in the device config. This is due to IAudioClient3_InitializeSharedAudioStream() failing when the
-  `AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM` flag is specified. Setting wasapi.noAutoConvertSRC will result in miniaudio's internal resampler being used instead
-  which will in turn enable the use of low-latency shared mode.
-
-11.2. PulseAudio
-----------------
-- If you experience bad glitching/noise on Arch Linux, consider this fix from the Arch wiki:
-  https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling. Alternatively, consider using a different backend such as ALSA.
-
-11.3. Android
--------------
-- To capture audio on Android, remember to add the RECORD_AUDIO permission to your manifest: `<uses-permission android:name="android.permission.RECORD_AUDIO" />`
-- With OpenSL|ES, only a single ma_context can be active at any given time. This is due to a limitation with OpenSL|ES.
-- With AAudio, only default devices are enumerated. This is due to AAudio not having an enumeration API (devices are enumerated through Java). You can however
-  perform your own device enumeration through Java and then set the ID in the ma_device_id structure (ma_device_id.aaudio) and pass it to ma_device_init().
-- The backend API will perform resampling where possible. The reason for this as opposed to using miniaudio's built-in resampler is to take advantage of any
-  potential device-specific optimizations the driver may implement.
-
-11.4. UWP
----------
-- UWP only supports default playback and capture devices.
-- UWP requires the Microphone capability to be enabled in the application's manifest (Package.appxmanifest):
-
-    ```
-    <Package ...>
-        ...
-        <Capabilities>
-            <DeviceCapability Name="microphone" />
-        </Capabilities>
-    </Package>
-    ```
-
-11.5. Web Audio / Emscripten
-----------------------------
-- You cannot use `-std=c*` compiler flags, nor `-ansi`. This only applies to the Emscripten build.
-- The first time a context is initialized it will create a global object called "miniaudio" whose primary purpose is to act as a factory for device objects.
-- Currently the Web Audio backend uses ScriptProcessorNode's, but this may need to change later as they've been deprecated.
-- Google has implemented a policy in their browsers that prevent automatic media output without first receiving some kind of user input. The following web page
-  has additional details: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes. Starting the device may fail if you try to start playback
-  without first handling some kind of user input.
-
-
-
-12. Miscellaneous Notes
-=======================
-- Automatic stream routing is enabled on a per-backend basis. Support is explicitly enabled for WASAPI and Core Audio, however other backends such as
-  PulseAudio may naturally support it, though not all have been tested.
-- The contents of the output buffer passed into the data callback will always be pre-initialized to silence unless the `noPreZeroedOutputBuffer` config variable
-  in `ma_device_config` is set to true, in which case it'll be undefined which will require you to write something to the entire buffer.
-- By default miniaudio will automatically clip samples. This only applies when the playback sample format is configured as `ma_format_f32`. If you are doing
-  clipping yourself, you can disable this overhead by setting `noClip` to true in the device config.
-- The sndio backend is currently only enabled on OpenBSD builds.
-- The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can use it.
-- Note that GCC and Clang requires `-msse2`, `-mavx2`, etc. for SIMD optimizations.
-- When compiling with VC6 and earlier, decoding is restricted to files less than 2GB in size. This is due to 64-bit file APIs not being available.
-*/
-
-#ifndef miniaudio_h
-#define miniaudio_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MA_STRINGIFY(x)     #x
-#define MA_XSTRINGIFY(x)    MA_STRINGIFY(x)
-
-#define MA_VERSION_MAJOR    0
-#define MA_VERSION_MINOR    10
-#define MA_VERSION_REVISION 33
-#define MA_VERSION_STRING   MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
-
-#if defined(_MSC_VER) && !defined(__clang__)
-    #pragma warning(push)
-    #pragma warning(disable:4201)   /* nonstandard extension used: nameless struct/union */
-    #pragma warning(disable:4214)   /* nonstandard extension used: bit field types other than int */
-    #pragma warning(disable:4324)   /* structure was padded due to alignment specifier */
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
-    #if defined(__clang__)
-        #pragma GCC diagnostic ignored "-Wc11-extensions"   /* anonymous unions are a C11 extension */
-    #endif
-#endif
-
-/* Platform/backend detection. */
-#ifdef _WIN32
-    #define MA_WIN32
-    #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
-        #define MA_WIN32_UWP
-    #else
-        #define MA_WIN32_DESKTOP
-    #endif
-#else
-    #define MA_POSIX
-    #include <pthread.h>    /* Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. */
-
-    #ifdef __unix__
-        #define MA_UNIX
-        #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-            #define MA_BSD
-        #endif
-    #endif
-    #ifdef __linux__
-        #define MA_LINUX
-    #endif
-    #ifdef __APPLE__
-        #define MA_APPLE
-    #endif
-    #ifdef __ANDROID__
-        #define MA_ANDROID
-    #endif
-    #ifdef __EMSCRIPTEN__
-        #define MA_EMSCRIPTEN
-    #endif
-#endif
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           ma_int8;
-typedef unsigned char           ma_uint8;
-typedef   signed short          ma_int16;
-typedef unsigned short          ma_uint16;
-typedef   signed int            ma_int32;
-typedef unsigned int            ma_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    ma_int64;
-    typedef unsigned __int64    ma_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  ma_int64;
-    typedef unsigned long long  ma_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef ma_uint64           ma_uintptr;
-#else
-    typedef ma_uint32           ma_uintptr;
-#endif
-
-typedef ma_uint8    ma_bool8;
-typedef ma_uint32   ma_bool32;
-#define MA_TRUE     1
-#define MA_FALSE    0
-
-typedef void* ma_handle;
-typedef void* ma_ptr;
-typedef void (* ma_proc)(void);
-
-#if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED)
-typedef ma_uint16 wchar_t;
-#endif
-
-/* Define NULL for some compilers. */
-#ifndef NULL
-#define NULL 0
-#endif
-
-#if defined(SIZE_MAX)
-    #define MA_SIZE_MAX    SIZE_MAX
-#else
-    #define MA_SIZE_MAX    0xFFFFFFFF  /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */
-#endif
-
-
-#ifdef _MSC_VER
-    #define MA_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define MA_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define MA_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define MA_INLINE __inline
-#else
-    #define MA_INLINE
-#endif
-
-#if !defined(MA_API)
-    #if defined(MA_DLL)
-        #if defined(_WIN32)
-            #define MA_DLL_IMPORT  __declspec(dllimport)
-            #define MA_DLL_EXPORT  __declspec(dllexport)
-            #define MA_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define MA_DLL_IMPORT  __attribute__((visibility("default")))
-                #define MA_DLL_EXPORT  __attribute__((visibility("default")))
-                #define MA_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define MA_DLL_IMPORT
-                #define MA_DLL_EXPORT
-                #define MA_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION)
-            #define MA_API  MA_DLL_EXPORT
-        #else
-            #define MA_API  MA_DLL_IMPORT
-        #endif
-        #define MA_PRIVATE MA_DLL_PRIVATE
-    #else
-        #define MA_API extern
-        #define MA_PRIVATE static
-    #endif
-#endif
-
-/* SIMD alignment in bytes. Currently set to 64 bytes in preparation for future AVX-512 optimizations. */
-#define MA_SIMD_ALIGNMENT  64
-
-
-/*
-Logging Levels
-==============
-A log level will automatically include the lower levels. For example, verbose logging will enable everything. The warning log level will only include warnings
-and errors, but will ignore informational and verbose logging. If you only want to handle a specific log level, implement a custom log callback (see
-ma_context_init() for details) and interrogate the `logLevel` parameter.
-
-By default the log level will be set to MA_LOG_LEVEL_ERROR, but you can change this by defining MA_LOG_LEVEL before the implementation of miniaudio.
-
-MA_LOG_LEVEL_VERBOSE
-    Mainly intended for debugging. This will enable all log levels and can be triggered from within the data callback so care must be taken when enabling this
-    in production environments.
-
-MA_LOG_LEVEL_INFO
-    Informational logging. Useful for debugging. This will also enable warning and error logs. This will never be called from within the data callback.
-
-MA_LOG_LEVEL_WARNING
-    Warnings. You should enable this in you development builds and action them when encounted. This will also enable error logs. These logs usually indicate a
-    potential problem or misconfiguration, but still allow you to keep running. This will never be called from within the data callback.
-
-MA_LOG_LEVEL_ERROR
-    Error logging. This will be fired when an operation fails and is subsequently aborted. This can be fired from within the data callback, in which case the
-    device will be stopped. You should always have this log level enabled.
-*/
-#define MA_LOG_LEVEL_VERBOSE   4
-#define MA_LOG_LEVEL_INFO      3
-#define MA_LOG_LEVEL_WARNING   2
-#define MA_LOG_LEVEL_ERROR     1
-
-#ifndef MA_LOG_LEVEL
-#define MA_LOG_LEVEL           MA_LOG_LEVEL_ERROR
-#endif
-
-/*
-An annotation for variables which must be used atomically. This doesn't actually do anything - it's
-just used as a way for humans to identify variables that should be used atomically.
-*/
-#define MA_ATOMIC
-
-typedef struct ma_context ma_context;
-typedef struct ma_device ma_device;
-
-typedef ma_uint8 ma_channel;
-#define MA_CHANNEL_NONE                                0
-#define MA_CHANNEL_MONO                                1
-#define MA_CHANNEL_FRONT_LEFT                          2
-#define MA_CHANNEL_FRONT_RIGHT                         3
-#define MA_CHANNEL_FRONT_CENTER                        4
-#define MA_CHANNEL_LFE                                 5
-#define MA_CHANNEL_BACK_LEFT                           6
-#define MA_CHANNEL_BACK_RIGHT                          7
-#define MA_CHANNEL_FRONT_LEFT_CENTER                   8
-#define MA_CHANNEL_FRONT_RIGHT_CENTER                  9
-#define MA_CHANNEL_BACK_CENTER                         10
-#define MA_CHANNEL_SIDE_LEFT                           11
-#define MA_CHANNEL_SIDE_RIGHT                          12
-#define MA_CHANNEL_TOP_CENTER                          13
-#define MA_CHANNEL_TOP_FRONT_LEFT                      14
-#define MA_CHANNEL_TOP_FRONT_CENTER                    15
-#define MA_CHANNEL_TOP_FRONT_RIGHT                     16
-#define MA_CHANNEL_TOP_BACK_LEFT                       17
-#define MA_CHANNEL_TOP_BACK_CENTER                     18
-#define MA_CHANNEL_TOP_BACK_RIGHT                      19
-#define MA_CHANNEL_AUX_0                               20
-#define MA_CHANNEL_AUX_1                               21
-#define MA_CHANNEL_AUX_2                               22
-#define MA_CHANNEL_AUX_3                               23
-#define MA_CHANNEL_AUX_4                               24
-#define MA_CHANNEL_AUX_5                               25
-#define MA_CHANNEL_AUX_6                               26
-#define MA_CHANNEL_AUX_7                               27
-#define MA_CHANNEL_AUX_8                               28
-#define MA_CHANNEL_AUX_9                               29
-#define MA_CHANNEL_AUX_10                              30
-#define MA_CHANNEL_AUX_11                              31
-#define MA_CHANNEL_AUX_12                              32
-#define MA_CHANNEL_AUX_13                              33
-#define MA_CHANNEL_AUX_14                              34
-#define MA_CHANNEL_AUX_15                              35
-#define MA_CHANNEL_AUX_16                              36
-#define MA_CHANNEL_AUX_17                              37
-#define MA_CHANNEL_AUX_18                              38
-#define MA_CHANNEL_AUX_19                              39
-#define MA_CHANNEL_AUX_20                              40
-#define MA_CHANNEL_AUX_21                              41
-#define MA_CHANNEL_AUX_22                              42
-#define MA_CHANNEL_AUX_23                              43
-#define MA_CHANNEL_AUX_24                              44
-#define MA_CHANNEL_AUX_25                              45
-#define MA_CHANNEL_AUX_26                              46
-#define MA_CHANNEL_AUX_27                              47
-#define MA_CHANNEL_AUX_28                              48
-#define MA_CHANNEL_AUX_29                              49
-#define MA_CHANNEL_AUX_30                              50
-#define MA_CHANNEL_AUX_31                              51
-#define MA_CHANNEL_LEFT                                MA_CHANNEL_FRONT_LEFT
-#define MA_CHANNEL_RIGHT                               MA_CHANNEL_FRONT_RIGHT
-#define MA_CHANNEL_POSITION_COUNT                      (MA_CHANNEL_AUX_31 + 1)
-
-
-typedef int ma_result;
-#define MA_SUCCESS                                      0
-#define MA_ERROR                                       -1   /* A generic error. */
-#define MA_INVALID_ARGS                                -2
-#define MA_INVALID_OPERATION                           -3
-#define MA_OUT_OF_MEMORY                               -4
-#define MA_OUT_OF_RANGE                                -5
-#define MA_ACCESS_DENIED                               -6
-#define MA_DOES_NOT_EXIST                              -7
-#define MA_ALREADY_EXISTS                              -8
-#define MA_TOO_MANY_OPEN_FILES                         -9
-#define MA_INVALID_FILE                                -10
-#define MA_TOO_BIG                                     -11
-#define MA_PATH_TOO_LONG                               -12
-#define MA_NAME_TOO_LONG                               -13
-#define MA_NOT_DIRECTORY                               -14
-#define MA_IS_DIRECTORY                                -15
-#define MA_DIRECTORY_NOT_EMPTY                         -16
-#define MA_END_OF_FILE                                 -17
-#define MA_NO_SPACE                                    -18
-#define MA_BUSY                                        -19
-#define MA_IO_ERROR                                    -20
-#define MA_INTERRUPT                                   -21
-#define MA_UNAVAILABLE                                 -22
-#define MA_ALREADY_IN_USE                              -23
-#define MA_BAD_ADDRESS                                 -24
-#define MA_BAD_SEEK                                    -25
-#define MA_BAD_PIPE                                    -26
-#define MA_DEADLOCK                                    -27
-#define MA_TOO_MANY_LINKS                              -28
-#define MA_NOT_IMPLEMENTED                             -29
-#define MA_NO_MESSAGE                                  -30
-#define MA_BAD_MESSAGE                                 -31
-#define MA_NO_DATA_AVAILABLE                           -32
-#define MA_INVALID_DATA                                -33
-#define MA_TIMEOUT                                     -34
-#define MA_NO_NETWORK                                  -35
-#define MA_NOT_UNIQUE                                  -36
-#define MA_NOT_SOCKET                                  -37
-#define MA_NO_ADDRESS                                  -38
-#define MA_BAD_PROTOCOL                                -39
-#define MA_PROTOCOL_UNAVAILABLE                        -40
-#define MA_PROTOCOL_NOT_SUPPORTED                      -41
-#define MA_PROTOCOL_FAMILY_NOT_SUPPORTED               -42
-#define MA_ADDRESS_FAMILY_NOT_SUPPORTED                -43
-#define MA_SOCKET_NOT_SUPPORTED                        -44
-#define MA_CONNECTION_RESET                            -45
-#define MA_ALREADY_CONNECTED                           -46
-#define MA_NOT_CONNECTED                               -47
-#define MA_CONNECTION_REFUSED                          -48
-#define MA_NO_HOST                                     -49
-#define MA_IN_PROGRESS                                 -50
-#define MA_CANCELLED                                   -51
-#define MA_MEMORY_ALREADY_MAPPED                       -52
-#define MA_AT_END                                      -53
-
-/* General miniaudio-specific errors. */
-#define MA_FORMAT_NOT_SUPPORTED                        -100
-#define MA_DEVICE_TYPE_NOT_SUPPORTED                   -101
-#define MA_SHARE_MODE_NOT_SUPPORTED                    -102
-#define MA_NO_BACKEND                                  -103
-#define MA_NO_DEVICE                                   -104
-#define MA_API_NOT_FOUND                               -105
-#define MA_INVALID_DEVICE_CONFIG                       -106
-#define MA_LOOP                                        -107
-
-/* State errors. */
-#define MA_DEVICE_NOT_INITIALIZED                      -200
-#define MA_DEVICE_ALREADY_INITIALIZED                  -201
-#define MA_DEVICE_NOT_STARTED                          -202
-#define MA_DEVICE_NOT_STOPPED                          -203
-
-/* Operation errors. */
-#define MA_FAILED_TO_INIT_BACKEND                      -300
-#define MA_FAILED_TO_OPEN_BACKEND_DEVICE               -301
-#define MA_FAILED_TO_START_BACKEND_DEVICE              -302
-#define MA_FAILED_TO_STOP_BACKEND_DEVICE               -303
-
-
-#define MA_MIN_CHANNELS                                1
-#ifndef MA_MAX_CHANNELS
-#define MA_MAX_CHANNELS                                32
-#endif
-
-
-#ifndef MA_MAX_FILTER_ORDER
-#define MA_MAX_FILTER_ORDER                            8
-#endif
-
-typedef enum
-{
-    ma_stream_format_pcm = 0
-} ma_stream_format;
-
-typedef enum
-{
-    ma_stream_layout_interleaved = 0,
-    ma_stream_layout_deinterleaved
-} ma_stream_layout;
-
-typedef enum
-{
-    ma_dither_mode_none = 0,
-    ma_dither_mode_rectangle,
-    ma_dither_mode_triangle
-} ma_dither_mode;
-
-typedef enum
-{
-    /*
-    I like to keep these explicitly defined because they're used as a key into a lookup table. When items are
-    added to this, make sure there are no gaps and that they're added to the lookup table in ma_get_bytes_per_sample().
-    */
-    ma_format_unknown = 0,     /* Mainly used for indicating an error, but also used as the default for the output format for decoders. */
-    ma_format_u8      = 1,
-    ma_format_s16     = 2,     /* Seems to be the most widely supported format. */
-    ma_format_s24     = 3,     /* Tightly packed. 3 bytes per sample. */
-    ma_format_s32     = 4,
-    ma_format_f32     = 5,
-    ma_format_count
-} ma_format;
-
-typedef enum
-{
-    /* Standard rates need to be in priority order. */
-    ma_standard_sample_rate_48000  = 48000,     /* Most common */
-    ma_standard_sample_rate_44100  = 44100,
-
-    ma_standard_sample_rate_32000  = 32000,     /* Lows */
-    ma_standard_sample_rate_24000  = 24000,
-    ma_standard_sample_rate_22050  = 22050,
-    
-    ma_standard_sample_rate_88200  = 88200,     /* Highs */
-    ma_standard_sample_rate_96000  = 96000,
-    ma_standard_sample_rate_176400 = 176400,
-    ma_standard_sample_rate_192000 = 192000,
-
-    ma_standard_sample_rate_16000  = 16000,     /* Extreme lows */
-    ma_standard_sample_rate_11025  = 11250,
-    ma_standard_sample_rate_8000   = 8000,
-
-    ma_standard_sample_rate_352800 = 352800,    /* Extreme highs */
-    ma_standard_sample_rate_384000 = 384000,
-
-    ma_standard_sample_rate_min    = ma_standard_sample_rate_8000,
-    ma_standard_sample_rate_max    = ma_standard_sample_rate_384000,
-    ma_standard_sample_rate_count  = 14         /* Need to maintain the count manually. Make sure this is updated if items are added to enum. */
-} ma_standard_sample_rate;
-
-/* These are deprecated. Use ma_standard_sample_rate_min and ma_standard_sample_rate_max. */
-#define MA_MIN_SAMPLE_RATE  (ma_uint32)ma_standard_sample_rate_min
-#define MA_MAX_SAMPLE_RATE  (ma_uint32)ma_standard_sample_rate_max
-
-
-typedef enum
-{
-    ma_channel_mix_mode_rectangular = 0,   /* Simple averaging based on the plane(s) the channel is sitting on. */
-    ma_channel_mix_mode_simple,            /* Drop excess channels; zeroed out extra channels. */
-    ma_channel_mix_mode_custom_weights,    /* Use custom weights specified in ma_channel_router_config. */
-    ma_channel_mix_mode_planar_blend = ma_channel_mix_mode_rectangular,
-    ma_channel_mix_mode_default = ma_channel_mix_mode_planar_blend
-} ma_channel_mix_mode;
-
-typedef enum
-{
-    ma_standard_channel_map_microsoft,
-    ma_standard_channel_map_alsa,
-    ma_standard_channel_map_rfc3551,   /* Based off AIFF. */
-    ma_standard_channel_map_flac,
-    ma_standard_channel_map_vorbis,
-    ma_standard_channel_map_sound4,    /* FreeBSD's sound(4). */
-    ma_standard_channel_map_sndio,     /* www.sndio.org/tips.html */
-    ma_standard_channel_map_webaudio = ma_standard_channel_map_flac, /* https://webaudio.github.io/web-audio-api/#ChannelOrdering. Only 1, 2, 4 and 6 channels are defined, but can fill in the gaps with logical assumptions. */
-    ma_standard_channel_map_default = ma_standard_channel_map_microsoft
-} ma_standard_channel_map;
-
-typedef enum
-{
-    ma_performance_profile_low_latency = 0,
-    ma_performance_profile_conservative
-} ma_performance_profile;
-
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} ma_allocation_callbacks;
-
-typedef struct
-{
-    ma_int32 state;
-} ma_lcg;
-
-
-#ifndef MA_NO_THREADING
-/* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
-typedef enum
-{
-    ma_thread_priority_idle     = -5,
-    ma_thread_priority_lowest   = -4,
-    ma_thread_priority_low      = -3,
-    ma_thread_priority_normal   = -2,
-    ma_thread_priority_high     = -1,
-    ma_thread_priority_highest  =  0,
-    ma_thread_priority_realtime =  1,
-    ma_thread_priority_default  =  0
-} ma_thread_priority;
-
-/* Spinlocks are 32-bit for compatibility reasons. */
-typedef ma_uint32 ma_spinlock;
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_thread;
-#endif
-#if defined(MA_POSIX)
-typedef pthread_t ma_thread;
-#endif
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_mutex;
-#endif
-#if defined(MA_POSIX)
-typedef pthread_mutex_t ma_mutex;
-#endif
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_event;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
-    ma_uint32 value;
-    pthread_mutex_t lock;
-    pthread_cond_t cond;
-} ma_event;
-#endif  /* MA_POSIX */
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_semaphore;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
-    int value;
-    pthread_mutex_t lock;
-    pthread_cond_t cond;
-} ma_semaphore;
-#endif  /* MA_POSIX */
-#else
-/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
-#ifndef MA_NO_DEVICE_IO
-#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
-#endif
-#endif  /* MA_NO_THREADING */
-
-
-/*
-Retrieves the version of miniaudio as separated integers. Each component can be NULL if it's not required.
-*/
-MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision);
-
-/*
-Retrieves the version of miniaudio as a string which can be useful for logging purposes.
-*/
-MA_API const char* ma_version_string(void);
-
-
-/**************************************************************************************************************************************************************
-
-Biquad Filtering
-
-**************************************************************************************************************************************************************/
-typedef union
-{
-    float    f32;
-    ma_int32 s32;
-} ma_biquad_coefficient;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    double b0;
-    double b1;
-    double b2;
-    double a0;
-    double a1;
-    double a2;
-} ma_biquad_config;
-
-MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient b0;
-    ma_biquad_coefficient b1;
-    ma_biquad_coefficient b2;
-    ma_biquad_coefficient a1;
-    ma_biquad_coefficient a2;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-    ma_biquad_coefficient r2[MA_MAX_CHANNELS];
-} ma_biquad;
-
-MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, ma_biquad* pBQ);
-MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ);
-MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ);
-
-
-/**************************************************************************************************************************************************************
-
-Low-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_lpf1_config, ma_lpf2_config;
-
-MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency);
-MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient a;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-} ma_lpf1;
-
-MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, ma_lpf1* pLPF);
-MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF);
-MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order low-pass filter is implemented as a biquad filter. */
-} ma_lpf2;
-
-MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, ma_lpf2* pLPF);
-MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF);
-MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_lpf_config;
-
-MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 lpf1Count;
-    ma_uint32 lpf2Count;
-    ma_lpf1 lpf1[1];
-    ma_lpf2 lpf2[MA_MAX_FILTER_ORDER/2];
-} ma_lpf;
-
-MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, ma_lpf* pLPF);
-MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF);
-MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF);
-
-
-/**************************************************************************************************************************************************************
-
-High-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_hpf1_config, ma_hpf2_config;
-
-MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency);
-MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient a;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-} ma_hpf1;
-
-MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, ma_hpf1* pHPF);
-MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF);
-MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order high-pass filter is implemented as a biquad filter. */
-} ma_hpf2;
-
-MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, ma_hpf2* pHPF);
-MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF);
-MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_hpf_config;
-
-MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 hpf1Count;
-    ma_uint32 hpf2Count;
-    ma_hpf1 hpf1[1];
-    ma_hpf2 hpf2[MA_MAX_FILTER_ORDER/2];
-} ma_hpf;
-
-MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, ma_hpf* pHPF);
-MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF);
-MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF);
-
-
-/**************************************************************************************************************************************************************
-
-Band-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_bpf2_config;
-
-MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order band-pass filter is implemented as a biquad filter. */
-} ma_bpf2;
-
-MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, ma_bpf2* pBPF);
-MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF);
-MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_bpf_config;
-
-MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 bpf2Count;
-    ma_bpf2 bpf2[MA_MAX_FILTER_ORDER/2];
-} ma_bpf;
-
-MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, ma_bpf* pBPF);
-MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF);
-MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF);
-
-
-/**************************************************************************************************************************************************************
-
-Notching Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double q;
-    double frequency;
-} ma_notch2_config;
-
-MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_notch2;
-
-MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter);
-MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter);
-MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-Peaking EQ Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double q;
-    double frequency;
-} ma_peak2_config;
-
-MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_peak2;
-
-MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter);
-MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter);
-MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-Low Shelf Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double shelfSlope;
-    double frequency;
-} ma_loshelf2_config;
-
-MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_loshelf2;
-
-MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter);
-MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter);
-MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-High Shelf Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double shelfSlope;
-    double frequency;
-} ma_hishelf2_config;
-
-MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_hishelf2;
-
-MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter);
-MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter);
-MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter);
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DATA CONVERSION
-===============
-
-This section contains the APIs for data conversion. You will find everything here for channel mapping, sample format conversion, resampling, etc.
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-
-/**************************************************************************************************************************************************************
-
-Resampling
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_uint32 lpfOrder;         /* The low-pass filter order. Setting this to 0 will disable low-pass filtering. */
-    double    lpfNyquistFactor; /* 0..1. Defaults to 1. 1 = Half the sampling frequency (Nyquist Frequency), 0.5 = Quarter the sampling frequency (half Nyquest Frequency), etc. */
-} ma_linear_resampler_config;
-
-MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-typedef struct
-{
-    ma_linear_resampler_config config;
-    ma_uint32 inAdvanceInt;
-    ma_uint32 inAdvanceFrac;
-    ma_uint32 inTimeInt;
-    ma_uint32 inTimeFrac;
-    union
-    {
-        float    f32[MA_MAX_CHANNELS];
-        ma_int16 s16[MA_MAX_CHANNELS];
-    } x0; /* The previous input frame. */
-    union
-    {
-        float    f32[MA_MAX_CHANNELS];
-        ma_int16 s16[MA_MAX_CHANNELS];
-    } x1; /* The next input frame. */
-    ma_lpf lpf;
-} ma_linear_resampler;
-
-MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, ma_linear_resampler* pResampler);
-MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler);
-MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut);
-MA_API ma_uint64 ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount);
-MA_API ma_uint64 ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount);
-MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler);
-MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler);
-
-typedef enum
-{
-    ma_resample_algorithm_linear = 0,   /* Fastest, lowest quality. Optional low-pass filtering. Default. */
-    ma_resample_algorithm_speex
-} ma_resample_algorithm;
-
-typedef struct
-{
-    ma_format format;   /* Must be either ma_format_f32 or ma_format_s16. */
-    ma_uint32 channels;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_resample_algorithm algorithm;
-    struct
-    {
-        ma_uint32 lpfOrder;
-        double lpfNyquistFactor;
-    } linear;
-    struct
-    {
-        int quality;    /* 0 to 10. Defaults to 3. */
-    } speex;
-} ma_resampler_config;
-
-MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm);
-
-typedef struct
-{
-    ma_resampler_config config;
-    union
-    {
-        ma_linear_resampler linear;
-        struct
-        {
-            void* pSpeexResamplerState;   /* SpeexResamplerState* */
-        } speex;
-    } state;
-} ma_resampler;
-
-/*
-Initializes a new resampler object from a config.
-*/
-MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, ma_resampler* pResampler);
-
-/*
-Uninitializes a resampler.
-*/
-MA_API void ma_resampler_uninit(ma_resampler* pResampler);
-
-/*
-Converts the given input data.
-
-Both the input and output frames must be in the format specified in the config when the resampler was initilized.
-
-On input, [pFrameCountOut] contains the number of output frames to process. On output it contains the number of output frames that
-were actually processed, which may be less than the requested amount which will happen if there's not enough input data. You can use
-ma_resampler_get_expected_output_frame_count() to know how many output frames will be processed for a given number of input frames.
-
-On input, [pFrameCountIn] contains the number of input frames contained in [pFramesIn]. On output it contains the number of whole
-input frames that were actually processed. You can use ma_resampler_get_required_input_frame_count() to know how many input frames
-you should provide for a given number of output frames. [pFramesIn] can be NULL, in which case zeroes will be used instead.
-
-If [pFramesOut] is NULL, a seek is performed. In this case, if [pFrameCountOut] is not NULL it will seek by the specified number of
-output frames. Otherwise, if [pFramesCountOut] is NULL and [pFrameCountIn] is not NULL, it will seek by the specified number of input
-frames. When seeking, [pFramesIn] is allowed to NULL, in which case the internal timing state will be updated, but no input will be
-processed. In this case, any internal filter state will be updated as if zeroes were passed in.
-
-It is an error for [pFramesOut] to be non-NULL and [pFrameCountOut] to be NULL.
-
-It is an error for both [pFrameCountOut] and [pFrameCountIn] to be NULL.
-*/
-MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-
-
-/*
-Sets the input and output sample sample rate.
-*/
-MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-/*
-Sets the input and output sample rate as a ratio.
-
-The ration is in/out.
-*/
-MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio);
-
-
-/*
-Calculates the number of whole input frames that would need to be read from the client in order to output the specified
-number of output frames.
-
-The returned value does not include cached input frames. It only returns the number of extra frames that would need to be
-read from the input buffer in order to output the specified number of output frames.
-*/
-MA_API ma_uint64 ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount);
-
-/*
-Calculates the number of whole output frames that would be output after fully reading and consuming the specified number of
-input frames.
-*/
-MA_API ma_uint64 ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount);
-
-
-/*
-Retrieves the latency introduced by the resampler in input frames.
-*/
-MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler);
-
-/*
-Retrieves the latency introduced by the resampler in output frames.
-*/
-MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler);
-
-
-
-/**************************************************************************************************************************************************************
-
-Channel Conversion
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_channel_mix_mode mixingMode;
-    float weights[MA_MAX_CHANNELS][MA_MAX_CHANNELS];  /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */
-} ma_channel_converter_config;
-
-MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_channel_mix_mode mixingMode;
-    union
-    {
-        float    f32[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
-        ma_int32 s16[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
-    } weights;
-    ma_bool8 isPassthrough;
-    ma_bool8 isSimpleShuffle;
-    ma_bool8 isSimpleMonoExpansion;
-    ma_bool8 isStereoToMono;
-    ma_uint8 shuffleTable[MA_MAX_CHANNELS];
-} ma_channel_converter;
-
-MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter);
-MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter);
-MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-
-
-/**************************************************************************************************************************************************************
-
-Data Conversion
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format formatIn;
-    ma_format formatOut;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_dither_mode ditherMode;
-    ma_channel_mix_mode channelMixMode;
-    float channelWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS];  /* [in][out]. Only used when channelMixMode is set to ma_channel_mix_mode_custom_weights. */
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        ma_bool32 allowDynamicSampleRate;
-        struct
-        {
-            ma_uint32 lpfOrder;
-            double lpfNyquistFactor;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-} ma_data_converter_config;
-
-MA_API ma_data_converter_config ma_data_converter_config_init_default(void);
-MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-typedef struct
-{
-    ma_data_converter_config config;
-    ma_channel_converter channelConverter;
-    ma_resampler resampler;
-    ma_bool8 hasPreFormatConversion;
-    ma_bool8 hasPostFormatConversion;
-    ma_bool8 hasChannelConverter;
-    ma_bool8 hasResampler;
-    ma_bool8 isPassthrough;
-} ma_data_converter;
-
-MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter);
-MA_API void ma_data_converter_uninit(ma_data_converter* pConverter);
-MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut);
-MA_API ma_uint64 ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount);
-MA_API ma_uint64 ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount);
-MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter);
-MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter);
-
-
-/************************************************************************************************************************************************************
-
-Format Conversion
-
-************************************************************************************************************************************************************/
-MA_API void ma_pcm_u8_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode);
-MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode);
-
-/*
-Deinterleaves an interleaved buffer.
-*/
-MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames);
-
-/*
-Interleaves a group of deinterleaved buffers.
-*/
-MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames);
-
-
-/************************************************************************************************************************************************************
-
-Channel Maps
-
-************************************************************************************************************************************************************/
-
-/*
-Initializes a blank channel map.
-
-When a blank channel map is specified anywhere it indicates that the native channel map should be used.
-*/
-MA_API void ma_channel_map_init_blank(ma_uint32 channels, ma_channel* pChannelMap);
-
-/*
-Helper for retrieving a standard channel map.
-
-The output channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API void ma_get_standard_channel_map(ma_standard_channel_map standardChannelMap, ma_uint32 channels, ma_channel* pChannelMap);
-
-/*
-Copies a channel map.
-
-Both input and output channel map buffers must have a capacity of at at least `channels`.
-*/
-MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels);
-
-/*
-Copies a channel map if one is specified, otherwise copies the default channel map.
-
-The output buffer must have a capacity of at least `channels`. If not NULL, the input channel map must also have a capacity of at least `channels`.
-*/
-MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels);
-
-
-/*
-Determines whether or not a channel map is valid.
-
-A blank channel map is valid (all channels set to MA_CHANNEL_NONE). The way a blank channel map is handled is context specific, but
-is usually treated as a passthrough.
-
-Invalid channel maps:
-  - A channel map with no channels
-  - A channel map with more than one channel and a mono channel
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_valid(ma_uint32 channels, const ma_channel* pChannelMap);
-
-/*
-Helper for comparing two channel maps for equality.
-
-This assumes the channel count is the same between the two.
-
-Both channels map buffers must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_equal(ma_uint32 channels, const ma_channel* pChannelMapA, const ma_channel* pChannelMapB);
-
-/*
-Helper for determining if a channel map is blank (all channels set to MA_CHANNEL_NONE).
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_blank(ma_uint32 channels, const ma_channel* pChannelMap);
-
-/*
-Helper for determining whether or not a channel is present in the given channel map.
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition);
-
-
-/************************************************************************************************************************************************************
-
-Conversion Helpers
-
-************************************************************************************************************************************************************/
-
-/*
-High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to
-determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is NULL, frameCountOut is
-ignored.
-
-A return value of 0 indicates an error.
-
-This function is useful for one-off bulk conversions, but if you're streaming data you should use the ma_data_converter APIs instead.
-*/
-MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn);
-MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig);
-
-
-/************************************************************************************************************************************************************
-
-Ring Buffer
-
-************************************************************************************************************************************************************/
-typedef struct
-{
-    void* pBuffer;
-    ma_uint32 subbufferSizeInBytes;
-    ma_uint32 subbufferCount;
-    ma_uint32 subbufferStrideInBytes;
-    MA_ATOMIC ma_uint32 encodedReadOffset;  /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */
-    MA_ATOMIC ma_uint32 encodedWriteOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */
-    ma_bool8 ownsBuffer;                    /* Used to know whether or not miniaudio is responsible for free()-ing the buffer. */
-    ma_bool8 clearOnWriteAcquire;           /* When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). */
-    ma_allocation_callbacks allocationCallbacks;
-} ma_rb;
-
-MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB);
-MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB);
-MA_API void ma_rb_uninit(ma_rb* pRB);
-MA_API void ma_rb_reset(ma_rb* pRB);
-MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut);
-MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut);
-MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut);
-MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut);
-MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes);
-MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes);
-MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB);    /* Returns the distance between the write pointer and the read pointer. Should never be negative for a correct program. Will return the number of bytes that can be read before the read pointer hits the write pointer. */
-MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB);
-MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex);
-MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer);
-
-
-typedef struct
-{
-    ma_rb rb;
-    ma_format format;
-    ma_uint32 channels;
-} ma_pcm_rb;
-
-MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB);
-MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB);
-MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB);
-MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB);
-MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut);
-MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut);
-MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut);
-MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut);
-MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames);
-MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames);
-MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB); /* Return value is in frames. */
-MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex);
-MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer);
-
-
-/*
-The idea of the duplex ring buffer is to act as the intermediary buffer when running two asynchronous devices in a duplex set up. The
-capture device writes to it, and then a playback device reads from it.
-
-At the moment this is just a simple naive implementation, but in the future I want to implement some dynamic resampling to seamlessly
-handle desyncs. Note that the API is work in progress and may change at any time in any version.
-
-The size of the buffer is based on the capture side since that's what'll be written to the buffer. It is based on the capture period size
-in frames. The internal sample rate of the capture device is also needed in order to calculate the size.
-*/
-typedef struct
-{
-    ma_pcm_rb rb;
-} ma_duplex_rb;
-
-MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB);
-MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB);
-
-
-/************************************************************************************************************************************************************
-
-Miscellaneous Helpers
-
-************************************************************************************************************************************************************/
-/*
-Retrieves a human readable description of the given result code.
-*/
-MA_API const char* ma_result_description(ma_result result);
-
-/*
-malloc(). Calls MA_MALLOC().
-*/
-MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-realloc(). Calls MA_REALLOC().
-*/
-MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-free(). Calls MA_FREE().
-*/
-MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Performs an aligned malloc, with the assumption that the alignment is a power of 2.
-*/
-MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Free's an aligned malloc'd buffer.
-*/
-MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Retrieves a friendly name for a format.
-*/
-MA_API const char* ma_get_format_name(ma_format format);
-
-/*
-Blends two frames in floating point format.
-*/
-MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels);
-
-/*
-Retrieves the size of a sample in bytes for the given format.
-
-This API is efficient and is implemented using a lookup table.
-
-Thread Safety: SAFE
-  This API is pure.
-*/
-MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format);
-static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels) { return ma_get_bytes_per_sample(format) * channels; }
-
-/*
-Converts a log level to a string.
-*/
-MA_API const char* ma_log_level_to_string(ma_uint32 logLevel);
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DEVICE I/O
-==========
-
-This section contains the APIs for device playback and capture. Here is where you'll find ma_device_init(), etc.
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DEVICE_IO
-/* Some backends are only supported on certain platforms. */
-#if defined(MA_WIN32)
-    #define MA_SUPPORT_WASAPI
-    #if defined(MA_WIN32_DESKTOP)  /* DirectSound and WinMM backends are only supported on desktops. */
-        #define MA_SUPPORT_DSOUND
-        #define MA_SUPPORT_WINMM
-        #define MA_SUPPORT_JACK    /* JACK is technically supported on Windows, but I don't know how many people use it in practice... */
-    #endif
-#endif
-#if defined(MA_UNIX)
-    #if defined(MA_LINUX)
-        #if !defined(MA_ANDROID)   /* ALSA is not supported on Android. */
-            #define MA_SUPPORT_ALSA
-        #endif
-    #endif
-    #if !defined(MA_BSD) && !defined(MA_ANDROID) && !defined(MA_EMSCRIPTEN)
-        #define MA_SUPPORT_PULSEAUDIO
-        #define MA_SUPPORT_JACK
-    #endif
-    #if defined(MA_ANDROID)
-        #define MA_SUPPORT_AAUDIO
-        #define MA_SUPPORT_OPENSL
-    #endif
-    #if defined(__OpenBSD__)        /* <-- Change this to "#if defined(MA_BSD)" to enable sndio on all BSD flavors. */
-        #define MA_SUPPORT_SNDIO    /* sndio is only supported on OpenBSD for now. May be expanded later if there's demand. */
-    #endif
-    #if defined(__NetBSD__) || defined(__OpenBSD__)
-        #define MA_SUPPORT_AUDIO4   /* Only support audio(4) on platforms with known support. */
-    #endif
-    #if defined(__FreeBSD__) || defined(__DragonFly__)
-        #define MA_SUPPORT_OSS      /* Only support OSS on specific platforms with known support. */
-    #endif
-#endif
-#if defined(MA_APPLE)
-    #define MA_SUPPORT_COREAUDIO
-#endif
-#if defined(MA_EMSCRIPTEN)
-    #define MA_SUPPORT_WEBAUDIO
-#endif
-
-/* All platforms should support custom backends. */
-#define MA_SUPPORT_CUSTOM
-
-/* Explicitly disable the Null backend for Emscripten because it uses a background thread which is not properly supported right now. */
-#if !defined(MA_EMSCRIPTEN)
-#define MA_SUPPORT_NULL
-#endif
-
-
-#if defined(MA_SUPPORT_WASAPI) && !defined(MA_NO_WASAPI) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WASAPI))
-    #define MA_HAS_WASAPI
-#endif
-#if defined(MA_SUPPORT_DSOUND) && !defined(MA_NO_DSOUND) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_DSOUND))
-    #define MA_HAS_DSOUND
-#endif
-#if defined(MA_SUPPORT_WINMM) && !defined(MA_NO_WINMM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WINMM))
-    #define MA_HAS_WINMM
-#endif
-#if defined(MA_SUPPORT_ALSA) && !defined(MA_NO_ALSA) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_ALSA))
-    #define MA_HAS_ALSA
-#endif
-#if defined(MA_SUPPORT_PULSEAUDIO) && !defined(MA_NO_PULSEAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_PULSEAUDIO))
-    #define MA_HAS_PULSEAUDIO
-#endif
-#if defined(MA_SUPPORT_JACK) && !defined(MA_NO_JACK) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_JACK))
-    #define MA_HAS_JACK
-#endif
-#if defined(MA_SUPPORT_COREAUDIO) && !defined(MA_NO_COREAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_COREAUDIO))
-    #define MA_HAS_COREAUDIO
-#endif
-#if defined(MA_SUPPORT_SNDIO) && !defined(MA_NO_SNDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_SNDIO))
-    #define MA_HAS_SNDIO
-#endif
-#if defined(MA_SUPPORT_AUDIO4) && !defined(MA_NO_AUDIO4) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AUDIO4))
-    #define MA_HAS_AUDIO4
-#endif
-#if defined(MA_SUPPORT_OSS) && !defined(MA_NO_OSS) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OSS))
-    #define MA_HAS_OSS
-#endif
-#if defined(MA_SUPPORT_AAUDIO) && !defined(MA_NO_AAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AAUDIO))
-    #define MA_HAS_AAUDIO
-#endif
-#if defined(MA_SUPPORT_OPENSL) && !defined(MA_NO_OPENSL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OPENSL))
-    #define MA_HAS_OPENSL
-#endif
-#if defined(MA_SUPPORT_WEBAUDIO) && !defined(MA_NO_WEBAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WEBAUDIO))
-    #define MA_HAS_WEBAUDIO
-#endif
-#if defined(MA_SUPPORT_CUSTOM) && !defined(MA_NO_CUSTOM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_CUSTOM))
-    #define MA_HAS_CUSTOM
-#endif
-#if defined(MA_SUPPORT_NULL) && !defined(MA_NO_NULL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_NULL))
-    #define MA_HAS_NULL
-#endif
-
-#define MA_STATE_UNINITIALIZED     0
-#define MA_STATE_STOPPED           1   /* The device's default state after initialization. */
-#define MA_STATE_STARTED           2   /* The device is started and is requesting and/or delivering audio data. */
-#define MA_STATE_STARTING          3   /* Transitioning from a stopped state to started. */
-#define MA_STATE_STOPPING          4   /* Transitioning from a started state to stopped. */
-
-#ifdef MA_SUPPORT_WASAPI
-/* We need a IMMNotificationClient object for WASAPI. */
-typedef struct
-{
-    void* lpVtbl;
-    ma_uint32 counter;
-    ma_device* pDevice;
-} ma_IMMNotificationClient;
-#endif
-
-/* Backend enums must be in priority order. */
-typedef enum
-{
-    ma_backend_wasapi,
-    ma_backend_dsound,
-    ma_backend_winmm,
-    ma_backend_coreaudio,
-    ma_backend_sndio,
-    ma_backend_audio4,
-    ma_backend_oss,
-    ma_backend_pulseaudio,
-    ma_backend_alsa,
-    ma_backend_jack,
-    ma_backend_aaudio,
-    ma_backend_opensl,
-    ma_backend_webaudio,
-    ma_backend_custom,  /* <-- Custom backend, with callbacks defined by the context config. */
-    ma_backend_null     /* <-- Must always be the last item. Lowest priority, and used as the terminator for backend enumeration. */
-} ma_backend;
-
-#define MA_BACKEND_COUNT (ma_backend_null+1)
-
-
-/*
-The callback for processing audio data from the device.
-
-The data callback is fired by miniaudio whenever the device needs to have more data delivered to a playback device, or when a capture device has some data
-available. This is called as soon as the backend asks for more data which means it may be called with inconsistent frame counts. You cannot assume the
-callback will be fired with a consistent frame count.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the relevant device.
-
-pOutput (out)
-    A pointer to the output buffer that will receive audio data that will later be played back through the speakers. This will be non-null for a playback or
-    full-duplex device and null for a capture and loopback device.
-
-pInput (in)
-    A pointer to the buffer containing input data from a recording device. This will be non-null for a capture, full-duplex or loopback device and null for a
-    playback device.
-
-frameCount (in)
-    The number of PCM frames to process. Note that this will not necessarily be equal to what you requested when you initialized the device. The
-    `periodSizeInFrames` and `periodSizeInMilliseconds` members of the device config are just hints, and are not necessarily exactly what you'll get. You must
-    not assume this will always be the same value each time the callback is fired.
-
-
-Remarks
--------
-You cannot stop and start the device from inside the callback or else you'll get a deadlock. You must also not uninitialize the device from inside the
-callback. The following APIs cannot be called from inside the callback:
-
-    ma_device_init()
-    ma_device_init_ex()
-    ma_device_uninit()
-    ma_device_start()
-    ma_device_stop()
-
-The proper way to stop the device is to call `ma_device_stop()` from a different thread, normally the main application thread.
-*/
-typedef void (* ma_device_callback_proc)(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-/*
-The callback for when the device has been stopped.
-
-This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
-such as being unplugged or an internal error occuring.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device that has just stopped.
-
-
-Remarks
--------
-Do not restart or uninitialize the device from the callback.
-*/
-typedef void (* ma_stop_proc)(ma_device* pDevice);
-
-/*
-The callback for handling log messages.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context the log message originated from.
-
-pDevice (in)
-    A pointer to the device the log message originate from, if any. This can be null, in which case the message came from the context.
-
-logLevel (in)
-    The log level. This can be one of the following:
-
-    +----------------------+
-    | Log Level            |
-    +----------------------+
-    | MA_LOG_LEVEL_VERBOSE |
-    | MA_LOG_LEVEL_INFO    |
-    | MA_LOG_LEVEL_WARNING |
-    | MA_LOG_LEVEL_ERROR   |
-    +----------------------+
-
-message (in)
-    The log message.
-
-
-Remarks
--------
-Do not modify the state of the device from inside the callback.
-*/
-typedef void (* ma_log_proc)(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message);
-
-typedef enum
-{
-    ma_device_type_playback = 1,
-    ma_device_type_capture  = 2,
-    ma_device_type_duplex   = ma_device_type_playback | ma_device_type_capture, /* 3 */
-    ma_device_type_loopback = 4
-} ma_device_type;
-
-typedef enum
-{
-    ma_share_mode_shared = 0,
-    ma_share_mode_exclusive
-} ma_share_mode;
-
-/* iOS/tvOS/watchOS session categories. */
-typedef enum
-{
-    ma_ios_session_category_default = 0,        /* AVAudioSessionCategoryPlayAndRecord with AVAudioSessionCategoryOptionDefaultToSpeaker. */
-    ma_ios_session_category_none,               /* Leave the session category unchanged. */
-    ma_ios_session_category_ambient,            /* AVAudioSessionCategoryAmbient */
-    ma_ios_session_category_solo_ambient,       /* AVAudioSessionCategorySoloAmbient */
-    ma_ios_session_category_playback,           /* AVAudioSessionCategoryPlayback */
-    ma_ios_session_category_record,             /* AVAudioSessionCategoryRecord */
-    ma_ios_session_category_play_and_record,    /* AVAudioSessionCategoryPlayAndRecord */
-    ma_ios_session_category_multi_route         /* AVAudioSessionCategoryMultiRoute */
-} ma_ios_session_category;
-
-/* iOS/tvOS/watchOS session category options */
-typedef enum
-{
-    ma_ios_session_category_option_mix_with_others                            = 0x01,   /* AVAudioSessionCategoryOptionMixWithOthers */
-    ma_ios_session_category_option_duck_others                                = 0x02,   /* AVAudioSessionCategoryOptionDuckOthers */
-    ma_ios_session_category_option_allow_bluetooth                            = 0x04,   /* AVAudioSessionCategoryOptionAllowBluetooth */
-    ma_ios_session_category_option_default_to_speaker                         = 0x08,   /* AVAudioSessionCategoryOptionDefaultToSpeaker */
-    ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others = 0x11,   /* AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers */
-    ma_ios_session_category_option_allow_bluetooth_a2dp                       = 0x20,   /* AVAudioSessionCategoryOptionAllowBluetoothA2DP */
-    ma_ios_session_category_option_allow_air_play                             = 0x40,   /* AVAudioSessionCategoryOptionAllowAirPlay */
-} ma_ios_session_category_option;
-
-/* OpenSL stream types. */
-typedef enum
-{
-    ma_opensl_stream_type_default = 0,              /* Leaves the stream type unset. */
-    ma_opensl_stream_type_voice,                    /* SL_ANDROID_STREAM_VOICE */
-    ma_opensl_stream_type_system,                   /* SL_ANDROID_STREAM_SYSTEM */
-    ma_opensl_stream_type_ring,                     /* SL_ANDROID_STREAM_RING */
-    ma_opensl_stream_type_media,                    /* SL_ANDROID_STREAM_MEDIA */
-    ma_opensl_stream_type_alarm,                    /* SL_ANDROID_STREAM_ALARM */
-    ma_opensl_stream_type_notification              /* SL_ANDROID_STREAM_NOTIFICATION */
-} ma_opensl_stream_type;
-
-/* OpenSL recording presets. */
-typedef enum
-{
-    ma_opensl_recording_preset_default = 0,         /* Leaves the input preset unset. */
-    ma_opensl_recording_preset_generic,             /* SL_ANDROID_RECORDING_PRESET_GENERIC */
-    ma_opensl_recording_preset_camcorder,           /* SL_ANDROID_RECORDING_PRESET_CAMCORDER */
-    ma_opensl_recording_preset_voice_recognition,   /* SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION */
-    ma_opensl_recording_preset_voice_communication, /* SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION */
-    ma_opensl_recording_preset_voice_unprocessed    /* SL_ANDROID_RECORDING_PRESET_UNPROCESSED */
-} ma_opensl_recording_preset;
-
-/* AAudio usage types. */
-typedef enum
-{
-    ma_aaudio_usage_default = 0,                    /* Leaves the usage type unset. */
-    ma_aaudio_usage_announcement,                   /* AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT */
-    ma_aaudio_usage_emergency,                      /* AAUDIO_SYSTEM_USAGE_EMERGENCY */
-    ma_aaudio_usage_safety,                         /* AAUDIO_SYSTEM_USAGE_SAFETY */
-    ma_aaudio_usage_vehicle_status,                 /* AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS */
-    ma_aaudio_usage_alarm,                          /* AAUDIO_USAGE_ALARM */
-    ma_aaudio_usage_assistance_accessibility,       /* AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY */
-    ma_aaudio_usage_assistance_navigation_guidance, /* AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE */
-    ma_aaudio_usage_assistance_sonification,        /* AAUDIO_USAGE_ASSISTANCE_SONIFICATION */
-    ma_aaudio_usage_assitant,                       /* AAUDIO_USAGE_ASSISTANT */
-    ma_aaudio_usage_game,                           /* AAUDIO_USAGE_GAME */
-    ma_aaudio_usage_media,                          /* AAUDIO_USAGE_MEDIA */
-    ma_aaudio_usage_notification,                   /* AAUDIO_USAGE_NOTIFICATION */
-    ma_aaudio_usage_notification_event,             /* AAUDIO_USAGE_NOTIFICATION_EVENT */
-    ma_aaudio_usage_notification_ringtone,          /* AAUDIO_USAGE_NOTIFICATION_RINGTONE */
-    ma_aaudio_usage_voice_communication,            /* AAUDIO_USAGE_VOICE_COMMUNICATION */
-    ma_aaudio_usage_voice_communication_signalling  /* AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING */
-} ma_aaudio_usage;
-
-/* AAudio content types. */
-typedef enum
-{
-    ma_aaudio_content_type_default = 0,             /* Leaves the content type unset. */
-    ma_aaudio_content_type_movie,                   /* AAUDIO_CONTENT_TYPE_MOVIE */
-    ma_aaudio_content_type_music,                   /* AAUDIO_CONTENT_TYPE_MUSIC */
-    ma_aaudio_content_type_sonification,            /* AAUDIO_CONTENT_TYPE_SONIFICATION */
-    ma_aaudio_content_type_speech                   /* AAUDIO_CONTENT_TYPE_SPEECH */
-} ma_aaudio_content_type;
-
-/* AAudio input presets. */
-typedef enum
-{
-    ma_aaudio_input_preset_default = 0,             /* Leaves the input preset unset. */
-    ma_aaudio_input_preset_generic,                 /* AAUDIO_INPUT_PRESET_GENERIC */
-    ma_aaudio_input_preset_camcorder,               /* AAUDIO_INPUT_PRESET_CAMCORDER */
-    ma_aaudio_input_preset_unprocessed,             /* AAUDIO_INPUT_PRESET_UNPROCESSED */
-    ma_aaudio_input_preset_voice_recognition,       /* AAUDIO_INPUT_PRESET_VOICE_RECOGNITION */
-    ma_aaudio_input_preset_voice_communication,     /* AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION */
-    ma_aaudio_input_preset_voice_performance        /* AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE */
-} ma_aaudio_input_preset;
-
-
-typedef union
-{
-    ma_int64 counter;
-    double counterD;
-} ma_timer;
-
-typedef union
-{
-    wchar_t wasapi[64];             /* WASAPI uses a wchar_t string for identification. */
-    ma_uint8 dsound[16];            /* DirectSound uses a GUID for identification. */
-    /*UINT_PTR*/ ma_uint32 winmm;   /* When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. */
-    char alsa[256];                 /* ALSA uses a name string for identification. */
-    char pulse[256];                /* PulseAudio uses a name string for identification. */
-    int jack;                       /* JACK always uses default devices. */
-    char coreaudio[256];            /* Core Audio uses a string for identification. */
-    char sndio[256];                /* "snd/0", etc. */
-    char audio4[256];               /* "/dev/audio", etc. */
-    char oss[64];                   /* "dev/dsp0", etc. "dev/dsp" for the default device. */
-    ma_int32 aaudio;                /* AAudio uses a 32-bit integer for identification. */
-    ma_uint32 opensl;               /* OpenSL|ES uses a 32-bit unsigned integer for identification. */
-    char webaudio[32];              /* Web Audio always uses default devices for now, but if this changes it'll be a GUID. */
-    union
-    {
-        int i;
-        char s[256];
-        void* p;
-    } custom;                       /* The custom backend could be anything. Give them a few options. */
-    int nullbackend;                /* The null backend uses an integer for device IDs. */
-} ma_device_id;
-
-
-typedef struct ma_context_config    ma_context_config;
-typedef struct ma_device_config     ma_device_config;
-typedef struct ma_backend_callbacks ma_backend_callbacks;
-
-#define MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE (1U << 1)    /* If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode. */
-
-typedef struct
-{
-    /* Basic info. This is the only information guaranteed to be filled in during device enumeration. */
-    ma_device_id id;
-    char name[256];
-    ma_bool32 isDefault;
-
-    /*
-    Detailed info. As much of this is filled as possible with ma_context_get_device_info(). Note that you are allowed to initialize
-    a device with settings outside of this range, but it just means the data will be converted using miniaudio's data conversion
-    pipeline before sending the data to/from the device. Most programs will need to not worry about these values, but it's provided
-    here mainly for informational purposes or in the rare case that someone might find it useful.
-
-    These will be set to 0 when returned by ma_context_enumerate_devices() or ma_context_get_devices().
-    */
-    ma_uint32 formatCount;
-    ma_format formats[ma_format_count];
-    ma_uint32 minChannels;
-    ma_uint32 maxChannels;
-    ma_uint32 minSampleRate;
-    ma_uint32 maxSampleRate;
-
-
-    /* Experimental. Don't use these right now. */
-    ma_uint32 nativeDataFormatCount;
-    struct
-    {
-        ma_format format;       /* Sample format. If set to ma_format_unknown, all sample formats are supported. */
-        ma_uint32 channels;     /* If set to 0, all channels are supported. */
-        ma_uint32 sampleRate;   /* If set to 0, all sample rates are supported. */
-        ma_uint32 flags;        /* A combination of MA_DATA_FORMAT_FLAG_* flags. */
-    } nativeDataFormats[/*ma_format_count * ma_standard_sample_rate_count * MA_MAX_CHANNELS*/ 64];  /* Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. */
-} ma_device_info;
-
-struct ma_device_config
-{
-    ma_device_type deviceType;
-    ma_uint32 sampleRate;
-    ma_uint32 periodSizeInFrames;
-    ma_uint32 periodSizeInMilliseconds;
-    ma_uint32 periods;
-    ma_performance_profile performanceProfile;
-    ma_bool8 noPreZeroedOutputBuffer;   /* When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to zero. */
-    ma_bool8 noClip;                    /* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */
-    ma_device_callback_proc dataCallback;
-    ma_stop_proc stopCallback;
-    void* pUserData;
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    struct
-    {
-        const ma_device_id* pDeviceID;
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_channel_mix_mode channelMixMode;
-        ma_share_mode shareMode;
-    } playback;
-    struct
-    {
-        const ma_device_id* pDeviceID;
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_channel_mix_mode channelMixMode;
-        ma_share_mode shareMode;
-    } capture;
-
-    struct
-    {
-        ma_bool8 noAutoConvertSRC;     /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
-        ma_bool8 noDefaultQualitySRC;  /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
-        ma_bool8 noAutoStreamRouting;  /* Disables automatic stream routing. */
-        ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */
-    } wasapi;
-    struct
-    {
-        ma_bool32 noMMap;           /* Disables MMap mode. */
-        ma_bool32 noAutoFormat;     /* Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. */
-        ma_bool32 noAutoChannels;   /* Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. */
-        ma_bool32 noAutoResample;   /* Opens the ALSA device with SND_PCM_NO_AUTO_RESAMPLE. */
-    } alsa;
-    struct
-    {
-        const char* pStreamNamePlayback;
-        const char* pStreamNameCapture;
-    } pulse;
-    struct
-    {
-        ma_bool32 allowNominalSampleRateChange; /* Desktop only. When enabled, allows changing of the sample rate at the operating system level. */
-    } coreaudio;
-    struct
-    {
-        ma_opensl_stream_type streamType;
-        ma_opensl_recording_preset recordingPreset;
-    } opensl;
-    struct
-    {
-        ma_aaudio_usage usage;
-        ma_aaudio_content_type contentType;
-        ma_aaudio_input_preset inputPreset;
-    } aaudio;
-};
-
-
-/*
-The callback for handling device enumeration. This is fired from `ma_context_enumerated_devices()`.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-deviceType (in)
-    The type of the device being enumerated. This will always be either `ma_device_type_playback` or `ma_device_type_capture`.
-
-pInfo (in)
-    A pointer to a `ma_device_info` containing the ID and name of the enumerated device. Note that this will not include detailed information about the device,
-    only basic information (ID and name). The reason for this is that it would otherwise require opening the backend device to probe for the information which
-    is too inefficient.
-
-pUserData (in)
-    The user data pointer passed into `ma_context_enumerate_devices()`.
-*/
-typedef ma_bool32 (* ma_enum_devices_callback_proc)(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData);
-
-
-/*
-Describes some basic details about a playback or capture device.
-*/
-typedef struct
-{
-    const ma_device_id* pDeviceID;
-    ma_share_mode shareMode;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_channel channelMap[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFrames;
-    ma_uint32 periodSizeInMilliseconds;
-    ma_uint32 periodCount;
-} ma_device_descriptor;
-
-/*
-These are the callbacks required to be implemented for a backend. These callbacks are grouped into two parts: context and device. There is one context
-to many devices. A device is created from a context.
-
-The general flow goes like this:
-
-  1) A context is created with `onContextInit()`
-     1a) Available devices can be enumerated with `onContextEnumerateDevices()` if required.
-     1b) Detailed information about a device can be queried with `onContextGetDeviceInfo()` if required.
-  2) A device is created from the context that was created in the first step using `onDeviceInit()`, and optionally a device ID that was
-     selected from device enumeration via `onContextEnumerateDevices()`.
-  3) A device is started or stopped with `onDeviceStart()` / `onDeviceStop()`
-  4) Data is delivered to and from the device by the backend. This is always done based on the native format returned by the prior call
-     to `onDeviceInit()`. Conversion between the device's native format and the format requested by the application will be handled by
-     miniaudio internally.
-
-Initialization of the context is quite simple. You need to do any necessary initialization of internal objects and then output the
-callbacks defined in this structure.
-
-Once the context has been initialized you can initialize a device. Before doing so, however, the application may want to know which
-physical devices are available. This is where `onContextEnumerateDevices()` comes in. This is fairly simple. For each device, fire the
-given callback with, at a minimum, the basic information filled out in `ma_device_info`. When the callback returns `MA_FALSE`, enumeration
-needs to stop and the `onContextEnumerateDevices()` function return with a success code.
-
-Detailed device information can be retrieved from a device ID using `onContextGetDeviceInfo()`. This takes as input the device type and ID,
-and on output returns detailed information about the device in `ma_device_info`. The `onContextGetDeviceInfo()` callback must handle the
-case when the device ID is NULL, in which case information about the default device needs to be retrieved.
-
-Once the context has been created and the device ID retrieved (if using anything other than the default device), the device can be created.
-This is a little bit more complicated than initialization of the context due to it's more complicated configuration. When initializing a
-device, a duplex device may be requested. This means a separate data format needs to be specified for both playback and capture. On input,
-the data format is set to what the application wants. On output it's set to the native format which should match as closely as possible to
-the requested format. The conversion between the format requested by the application and the device's native format will be handled
-internally by miniaudio.
-
-On input, if the sample format is set to `ma_format_unknown`, the backend is free to use whatever sample format it desires, so long as it's
-supported by miniaudio. When the channel count is set to 0, the backend should use the device's native channel count. The same applies for
-sample rate. For the channel map, the default should be used when `ma_channel_map_blank()` returns true (all channels set to
-`MA_CHANNEL_NONE`). On input, the `periodSizeInFrames` or `periodSizeInMilliseconds` option should always be set. The backend should
-inspect both of these variables. If `periodSizeInFrames` is set, it should take priority, otherwise it needs to be derived from the period
-size in milliseconds (`periodSizeInMilliseconds`) and the sample rate, keeping in mind that the sample rate may be 0, in which case the
-sample rate will need to be determined before calculating the period size in frames. On output, all members of the `ma_device_data_format`
-object should be set to a valid value, except for `periodSizeInMilliseconds` which is optional (`periodSizeInFrames` *must* be set).
-
-Starting and stopping of the device is done with `onDeviceStart()` and `onDeviceStop()` and should be self-explanatory. If the backend uses
-asynchronous reading and writing, `onDeviceStart()` and `onDeviceStop()` should always be implemented.
-
-The handling of data delivery between the application and the device is the most complicated part of the process. To make this a bit
-easier, some helper callbacks are available. If the backend uses a blocking read/write style of API, the `onDeviceRead()` and
-`onDeviceWrite()` callbacks can optionally be implemented. These are blocking and work just like reading and writing from a file. If the
-backend uses a callback for data delivery, that callback must call `ma_device_handle_backend_data_callback()` from within it's callback.
-This allows miniaudio to then process any necessary data conversion and then pass it to the miniaudio data callback.
-
-If the backend requires absolute flexibility with it's data delivery, it can optionally implement the `onDeviceWorkerThread()` callback
-which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional.
-
-The audio thread should run data delivery logic in a loop while `ma_device_get_state() == MA_STATE_STARTED` and no errors have been
-encounted. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback.
-
-The invocation of the `onDeviceDataLoop()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this
-callback. When the device is stopped, the `ma_device_get_state() == MA_STATE_STARTED` condition will fail and the loop will be terminated
-which will then fall through to the part that stops the device. For an example on how to implement the `onDeviceDataLoop()` callback,
-look at `ma_device_audio_thread__default_read_write()`. Implement the `onDeviceDataLoopWakeup()` callback if you need a mechanism to
-wake up the audio thread.
-*/
-struct ma_backend_callbacks
-{
-    ma_result (* onContextInit)(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks);
-    ma_result (* onContextUninit)(ma_context* pContext);
-    ma_result (* onContextEnumerateDevices)(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData);
-    ma_result (* onContextGetDeviceInfo)(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo);
-    ma_result (* onDeviceInit)(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture);
-    ma_result (* onDeviceUninit)(ma_device* pDevice);
-    ma_result (* onDeviceStart)(ma_device* pDevice);
-    ma_result (* onDeviceStop)(ma_device* pDevice);
-    ma_result (* onDeviceRead)(ma_device* pDevice, void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesRead);
-    ma_result (* onDeviceWrite)(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten);
-    ma_result (* onDeviceDataLoop)(ma_device* pDevice);
-    ma_result (* onDeviceDataLoopWakeup)(ma_device* pDevice);
-};
-
-struct ma_context_config
-{
-    ma_log_proc logCallback;
-    ma_thread_priority threadPriority;
-    size_t threadStackSize;
-    void* pUserData;
-    ma_allocation_callbacks allocationCallbacks;
-    struct
-    {
-        ma_bool32 useVerboseDeviceEnumeration;
-    } alsa;
-    struct
-    {
-        const char* pApplicationName;
-        const char* pServerName;
-        ma_bool32 tryAutoSpawn; /* Enables autospawning of the PulseAudio daemon if necessary. */
-    } pulse;
-    struct
-    {
-        ma_ios_session_category sessionCategory;
-        ma_uint32 sessionCategoryOptions;
-        ma_bool32 noAudioSessionActivate;   /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization. */
-        ma_bool32 noAudioSessionDeactivate; /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:false] on uninitialization. */
-    } coreaudio;
-    struct
-    {
-        const char* pClientName;
-        ma_bool32 tryStartServer;
-    } jack;
-    ma_backend_callbacks custom;
-};
-
-/* WASAPI specific structure for some commands which must run on a common thread due to bugs in WASAPI. */
-typedef struct
-{
-    int code;
-    ma_event* pEvent;   /* This will be signalled when the event is complete. */
-    union
-    {
-        struct
-        {
-            int _unused;
-        } quit;
-        struct
-        {
-            ma_device_type deviceType;
-            void* pAudioClient;
-            void** ppAudioClientService;
-            ma_result result;   /* The result from creating the audio client service. */
-        } createAudioClient;
-        struct
-        {
-            ma_device* pDevice;
-            ma_device_type deviceType;
-        } releaseAudioClient;
-    } data;
-} ma_context_command__wasapi;
-
-struct ma_context
-{
-    ma_backend_callbacks callbacks;
-    ma_backend backend;                 /* DirectSound, ALSA, etc. */
-    ma_log_proc logCallback;
-    ma_thread_priority threadPriority;
-    size_t threadStackSize;
-    void* pUserData;
-    ma_allocation_callbacks allocationCallbacks;
-    ma_mutex deviceEnumLock;            /* Used to make ma_context_get_devices() thread safe. */
-    ma_mutex deviceInfoLock;            /* Used to make ma_context_get_device_info() thread safe. */
-    ma_uint32 deviceInfoCapacity;       /* Total capacity of pDeviceInfos. */
-    ma_uint32 playbackDeviceInfoCount;
-    ma_uint32 captureDeviceInfoCount;
-    ma_device_info* pDeviceInfos;       /* Playback devices first, then capture. */
-
-    union
-    {
-#ifdef MA_SUPPORT_WASAPI
-        struct
-        {
-            ma_thread commandThread;
-            ma_mutex commandLock;
-            ma_semaphore commandSem;
-            ma_uint32 commandIndex;
-            ma_uint32 commandCount;
-            ma_context_command__wasapi commands[4];
-        } wasapi;
-#endif
-#ifdef MA_SUPPORT_DSOUND
-        struct
-        {
-            ma_handle hDSoundDLL;
-            ma_proc DirectSoundCreate;
-            ma_proc DirectSoundEnumerateA;
-            ma_proc DirectSoundCaptureCreate;
-            ma_proc DirectSoundCaptureEnumerateA;
-        } dsound;
-#endif
-#ifdef MA_SUPPORT_WINMM
-        struct
-        {
-            ma_handle hWinMM;
-            ma_proc waveOutGetNumDevs;
-            ma_proc waveOutGetDevCapsA;
-            ma_proc waveOutOpen;
-            ma_proc waveOutClose;
-            ma_proc waveOutPrepareHeader;
-            ma_proc waveOutUnprepareHeader;
-            ma_proc waveOutWrite;
-            ma_proc waveOutReset;
-            ma_proc waveInGetNumDevs;
-            ma_proc waveInGetDevCapsA;
-            ma_proc waveInOpen;
-            ma_proc waveInClose;
-            ma_proc waveInPrepareHeader;
-            ma_proc waveInUnprepareHeader;
-            ma_proc waveInAddBuffer;
-            ma_proc waveInStart;
-            ma_proc waveInReset;
-        } winmm;
-#endif
-#ifdef MA_SUPPORT_ALSA
-        struct
-        {
-            ma_handle asoundSO;
-            ma_proc snd_pcm_open;
-            ma_proc snd_pcm_close;
-            ma_proc snd_pcm_hw_params_sizeof;
-            ma_proc snd_pcm_hw_params_any;
-            ma_proc snd_pcm_hw_params_set_format;
-            ma_proc snd_pcm_hw_params_set_format_first;
-            ma_proc snd_pcm_hw_params_get_format_mask;
-            ma_proc snd_pcm_hw_params_set_channels;
-            ma_proc snd_pcm_hw_params_set_channels_near;
-            ma_proc snd_pcm_hw_params_set_channels_minmax;
-            ma_proc snd_pcm_hw_params_set_rate_resample;
-            ma_proc snd_pcm_hw_params_set_rate;
-            ma_proc snd_pcm_hw_params_set_rate_near;
-            ma_proc snd_pcm_hw_params_set_buffer_size_near;
-            ma_proc snd_pcm_hw_params_set_periods_near;
-            ma_proc snd_pcm_hw_params_set_access;
-            ma_proc snd_pcm_hw_params_get_format;
-            ma_proc snd_pcm_hw_params_get_channels;
-            ma_proc snd_pcm_hw_params_get_channels_min;
-            ma_proc snd_pcm_hw_params_get_channels_max;
-            ma_proc snd_pcm_hw_params_get_rate;
-            ma_proc snd_pcm_hw_params_get_rate_min;
-            ma_proc snd_pcm_hw_params_get_rate_max;
-            ma_proc snd_pcm_hw_params_get_buffer_size;
-            ma_proc snd_pcm_hw_params_get_periods;
-            ma_proc snd_pcm_hw_params_get_access;
-            ma_proc snd_pcm_hw_params_test_format;
-            ma_proc snd_pcm_hw_params_test_channels;
-            ma_proc snd_pcm_hw_params_test_rate;
-            ma_proc snd_pcm_hw_params;
-            ma_proc snd_pcm_sw_params_sizeof;
-            ma_proc snd_pcm_sw_params_current;
-            ma_proc snd_pcm_sw_params_get_boundary;
-            ma_proc snd_pcm_sw_params_set_avail_min;
-            ma_proc snd_pcm_sw_params_set_start_threshold;
-            ma_proc snd_pcm_sw_params_set_stop_threshold;
-            ma_proc snd_pcm_sw_params;
-            ma_proc snd_pcm_format_mask_sizeof;
-            ma_proc snd_pcm_format_mask_test;
-            ma_proc snd_pcm_get_chmap;
-            ma_proc snd_pcm_state;
-            ma_proc snd_pcm_prepare;
-            ma_proc snd_pcm_start;
-            ma_proc snd_pcm_drop;
-            ma_proc snd_pcm_drain;
-            ma_proc snd_device_name_hint;
-            ma_proc snd_device_name_get_hint;
-            ma_proc snd_card_get_index;
-            ma_proc snd_device_name_free_hint;
-            ma_proc snd_pcm_mmap_begin;
-            ma_proc snd_pcm_mmap_commit;
-            ma_proc snd_pcm_recover;
-            ma_proc snd_pcm_readi;
-            ma_proc snd_pcm_writei;
-            ma_proc snd_pcm_avail;
-            ma_proc snd_pcm_avail_update;
-            ma_proc snd_pcm_wait;
-            ma_proc snd_pcm_info;
-            ma_proc snd_pcm_info_sizeof;
-            ma_proc snd_pcm_info_get_name;
-            ma_proc snd_config_update_free_global;
-
-            ma_mutex internalDeviceEnumLock;
-            ma_bool32 useVerboseDeviceEnumeration;
-        } alsa;
-#endif
-#ifdef MA_SUPPORT_PULSEAUDIO
-        struct
-        {
-            ma_handle pulseSO;
-            ma_proc pa_mainloop_new;
-            ma_proc pa_mainloop_free;
-            ma_proc pa_mainloop_quit;
-            ma_proc pa_mainloop_get_api;
-            ma_proc pa_mainloop_iterate;
-            ma_proc pa_mainloop_wakeup;
-            ma_proc pa_threaded_mainloop_new;
-            ma_proc pa_threaded_mainloop_free;
-            ma_proc pa_threaded_mainloop_start;
-            ma_proc pa_threaded_mainloop_stop;
-            ma_proc pa_threaded_mainloop_lock;
-            ma_proc pa_threaded_mainloop_unlock;
-            ma_proc pa_threaded_mainloop_wait;
-            ma_proc pa_threaded_mainloop_signal;
-            ma_proc pa_threaded_mainloop_accept;
-            ma_proc pa_threaded_mainloop_get_retval;
-            ma_proc pa_threaded_mainloop_get_api;
-            ma_proc pa_threaded_mainloop_in_thread;
-            ma_proc pa_threaded_mainloop_set_name;
-            ma_proc pa_context_new;
-            ma_proc pa_context_unref;
-            ma_proc pa_context_connect;
-            ma_proc pa_context_disconnect;
-            ma_proc pa_context_set_state_callback;
-            ma_proc pa_context_get_state;
-            ma_proc pa_context_get_sink_info_list;
-            ma_proc pa_context_get_source_info_list;
-            ma_proc pa_context_get_sink_info_by_name;
-            ma_proc pa_context_get_source_info_by_name;
-            ma_proc pa_operation_unref;
-            ma_proc pa_operation_get_state;
-            ma_proc pa_channel_map_init_extend;
-            ma_proc pa_channel_map_valid;
-            ma_proc pa_channel_map_compatible;
-            ma_proc pa_stream_new;
-            ma_proc pa_stream_unref;
-            ma_proc pa_stream_connect_playback;
-            ma_proc pa_stream_connect_record;
-            ma_proc pa_stream_disconnect;
-            ma_proc pa_stream_get_state;
-            ma_proc pa_stream_get_sample_spec;
-            ma_proc pa_stream_get_channel_map;
-            ma_proc pa_stream_get_buffer_attr;
-            ma_proc pa_stream_set_buffer_attr;
-            ma_proc pa_stream_get_device_name;
-            ma_proc pa_stream_set_write_callback;
-            ma_proc pa_stream_set_read_callback;
-            ma_proc pa_stream_flush;
-            ma_proc pa_stream_drain;
-            ma_proc pa_stream_is_corked;
-            ma_proc pa_stream_cork;
-            ma_proc pa_stream_trigger;
-            ma_proc pa_stream_begin_write;
-            ma_proc pa_stream_write;
-            ma_proc pa_stream_peek;
-            ma_proc pa_stream_drop;
-            ma_proc pa_stream_writable_size;
-            ma_proc pa_stream_readable_size;
-
-            /*pa_mainloop**/ ma_ptr pMainLoop;
-            /*pa_context**/ ma_ptr pPulseContext;
-        } pulse;
-#endif
-#ifdef MA_SUPPORT_JACK
-        struct
-        {
-            ma_handle jackSO;
-            ma_proc jack_client_open;
-            ma_proc jack_client_close;
-            ma_proc jack_client_name_size;
-            ma_proc jack_set_process_callback;
-            ma_proc jack_set_buffer_size_callback;
-            ma_proc jack_on_shutdown;
-            ma_proc jack_get_sample_rate;
-            ma_proc jack_get_buffer_size;
-            ma_proc jack_get_ports;
-            ma_proc jack_activate;
-            ma_proc jack_deactivate;
-            ma_proc jack_connect;
-            ma_proc jack_port_register;
-            ma_proc jack_port_name;
-            ma_proc jack_port_get_buffer;
-            ma_proc jack_free;
-
-            char* pClientName;
-            ma_bool32 tryStartServer;
-        } jack;
-#endif
-#ifdef MA_SUPPORT_COREAUDIO
-        struct
-        {
-            ma_handle hCoreFoundation;
-            ma_proc CFStringGetCString;
-            ma_proc CFRelease;
-
-            ma_handle hCoreAudio;
-            ma_proc AudioObjectGetPropertyData;
-            ma_proc AudioObjectGetPropertyDataSize;
-            ma_proc AudioObjectSetPropertyData;
-            ma_proc AudioObjectAddPropertyListener;
-            ma_proc AudioObjectRemovePropertyListener;
-
-            ma_handle hAudioUnit;  /* Could possibly be set to AudioToolbox on later versions of macOS. */
-            ma_proc AudioComponentFindNext;
-            ma_proc AudioComponentInstanceDispose;
-            ma_proc AudioComponentInstanceNew;
-            ma_proc AudioOutputUnitStart;
-            ma_proc AudioOutputUnitStop;
-            ma_proc AudioUnitAddPropertyListener;
-            ma_proc AudioUnitGetPropertyInfo;
-            ma_proc AudioUnitGetProperty;
-            ma_proc AudioUnitSetProperty;
-            ma_proc AudioUnitInitialize;
-            ma_proc AudioUnitRender;
-
-            /*AudioComponent*/ ma_ptr component;
-            ma_bool32 noAudioSessionDeactivate; /* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */
-        } coreaudio;
-#endif
-#ifdef MA_SUPPORT_SNDIO
-        struct
-        {
-            ma_handle sndioSO;
-            ma_proc sio_open;
-            ma_proc sio_close;
-            ma_proc sio_setpar;
-            ma_proc sio_getpar;
-            ma_proc sio_getcap;
-            ma_proc sio_start;
-            ma_proc sio_stop;
-            ma_proc sio_read;
-            ma_proc sio_write;
-            ma_proc sio_onmove;
-            ma_proc sio_nfds;
-            ma_proc sio_pollfd;
-            ma_proc sio_revents;
-            ma_proc sio_eof;
-            ma_proc sio_setvol;
-            ma_proc sio_onvol;
-            ma_proc sio_initpar;
-        } sndio;
-#endif
-#ifdef MA_SUPPORT_AUDIO4
-        struct
-        {
-            int _unused;
-        } audio4;
-#endif
-#ifdef MA_SUPPORT_OSS
-        struct
-        {
-            int versionMajor;
-            int versionMinor;
-        } oss;
-#endif
-#ifdef MA_SUPPORT_AAUDIO
-        struct
-        {
-            ma_handle hAAudio; /* libaaudio.so */
-            ma_proc AAudio_createStreamBuilder;
-            ma_proc AAudioStreamBuilder_delete;
-            ma_proc AAudioStreamBuilder_setDeviceId;
-            ma_proc AAudioStreamBuilder_setDirection;
-            ma_proc AAudioStreamBuilder_setSharingMode;
-            ma_proc AAudioStreamBuilder_setFormat;
-            ma_proc AAudioStreamBuilder_setChannelCount;
-            ma_proc AAudioStreamBuilder_setSampleRate;
-            ma_proc AAudioStreamBuilder_setBufferCapacityInFrames;
-            ma_proc AAudioStreamBuilder_setFramesPerDataCallback;
-            ma_proc AAudioStreamBuilder_setDataCallback;
-            ma_proc AAudioStreamBuilder_setErrorCallback;
-            ma_proc AAudioStreamBuilder_setPerformanceMode;
-            ma_proc AAudioStreamBuilder_setUsage;
-            ma_proc AAudioStreamBuilder_setContentType;
-            ma_proc AAudioStreamBuilder_setInputPreset;
-            ma_proc AAudioStreamBuilder_openStream;
-            ma_proc AAudioStream_close;
-            ma_proc AAudioStream_getState;
-            ma_proc AAudioStream_waitForStateChange;
-            ma_proc AAudioStream_getFormat;
-            ma_proc AAudioStream_getChannelCount;
-            ma_proc AAudioStream_getSampleRate;
-            ma_proc AAudioStream_getBufferCapacityInFrames;
-            ma_proc AAudioStream_getFramesPerDataCallback;
-            ma_proc AAudioStream_getFramesPerBurst;
-            ma_proc AAudioStream_requestStart;
-            ma_proc AAudioStream_requestStop;
-        } aaudio;
-#endif
-#ifdef MA_SUPPORT_OPENSL
-        struct
-        {
-            ma_handle libOpenSLES;
-            ma_handle SL_IID_ENGINE;
-            ma_handle SL_IID_AUDIOIODEVICECAPABILITIES;
-            ma_handle SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-            ma_handle SL_IID_RECORD;
-            ma_handle SL_IID_PLAY;
-            ma_handle SL_IID_OUTPUTMIX;
-            ma_handle SL_IID_ANDROIDCONFIGURATION;
-            ma_proc   slCreateEngine;
-        } opensl;
-#endif
-#ifdef MA_SUPPORT_WEBAUDIO
-        struct
-        {
-            int _unused;
-        } webaudio;
-#endif
-#ifdef MA_SUPPORT_NULL
-        struct
-        {
-            int _unused;
-        } null_backend;
-#endif
-    };
-
-    union
-    {
-#ifdef MA_WIN32
-        struct
-        {
-            /*HMODULE*/ ma_handle hOle32DLL;
-            ma_proc CoInitializeEx;
-            ma_proc CoUninitialize;
-            ma_proc CoCreateInstance;
-            ma_proc CoTaskMemFree;
-            ma_proc PropVariantClear;
-            ma_proc StringFromGUID2;
-
-            /*HMODULE*/ ma_handle hUser32DLL;
-            ma_proc GetForegroundWindow;
-            ma_proc GetDesktopWindow;
-
-            /*HMODULE*/ ma_handle hAdvapi32DLL;
-            ma_proc RegOpenKeyExA;
-            ma_proc RegCloseKey;
-            ma_proc RegQueryValueExA;
-        } win32;
-#endif
-#ifdef MA_POSIX
-        struct
-        {
-            ma_handle pthreadSO;
-            ma_proc pthread_create;
-            ma_proc pthread_join;
-            ma_proc pthread_mutex_init;
-            ma_proc pthread_mutex_destroy;
-            ma_proc pthread_mutex_lock;
-            ma_proc pthread_mutex_unlock;
-            ma_proc pthread_cond_init;
-            ma_proc pthread_cond_destroy;
-            ma_proc pthread_cond_wait;
-            ma_proc pthread_cond_signal;
-            ma_proc pthread_attr_init;
-            ma_proc pthread_attr_destroy;
-            ma_proc pthread_attr_setschedpolicy;
-            ma_proc pthread_attr_getschedparam;
-            ma_proc pthread_attr_setschedparam;
-        } posix;
-#endif
-        int _unused;
-    };
-};
-
-struct ma_device
-{
-    ma_context* pContext;
-    ma_device_type type;
-    ma_uint32 sampleRate;
-    MA_ATOMIC ma_uint32 state;              /* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
-    ma_device_callback_proc onData;         /* Set once at initialization time and should not be changed after. */
-    ma_stop_proc onStop;                    /* Set once at initialization time and should not be changed after. */
-    void* pUserData;                        /* Application defined data. */
-    ma_mutex startStopLock;
-    ma_event wakeupEvent;
-    ma_event startEvent;
-    ma_event stopEvent;
-    ma_thread thread;
-    ma_result workResult;                   /* This is set by the worker thread after it's finished doing a job. */
-    ma_bool8 isOwnerOfContext;              /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
-    ma_bool8 noPreZeroedOutputBuffer;
-    ma_bool8 noClip;
-    MA_ATOMIC float masterVolumeFactor;     /* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
-    ma_duplex_rb duplexRB;                  /* Intermediary buffer for duplex device on asynchronous backends. */
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    struct
-    {
-        ma_device_id id;                    /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
-        char name[256];                     /* Maybe temporary. Likely to be replaced with a query API. */
-        ma_share_mode shareMode;            /* Set to whatever was passed in when the device was initialized. */
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_format internalFormat;
-        ma_uint32 internalChannels;
-        ma_uint32 internalSampleRate;
-        ma_channel internalChannelMap[MA_MAX_CHANNELS];
-        ma_uint32 internalPeriodSizeInFrames;
-        ma_uint32 internalPeriods;
-        ma_channel_mix_mode channelMixMode;
-        ma_data_converter converter;
-    } playback;
-    struct
-    {
-        ma_device_id id;                    /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
-        char name[256];                     /* Maybe temporary. Likely to be replaced with a query API. */
-        ma_share_mode shareMode;            /* Set to whatever was passed in when the device was initialized. */
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_format internalFormat;
-        ma_uint32 internalChannels;
-        ma_uint32 internalSampleRate;
-        ma_channel internalChannelMap[MA_MAX_CHANNELS];
-        ma_uint32 internalPeriodSizeInFrames;
-        ma_uint32 internalPeriods;
-        ma_channel_mix_mode channelMixMode;
-        ma_data_converter converter;
-    } capture;
-
-    union
-    {
-#ifdef MA_SUPPORT_WASAPI
-        struct
-        {
-            /*IAudioClient**/ ma_ptr pAudioClientPlayback;
-            /*IAudioClient**/ ma_ptr pAudioClientCapture;
-            /*IAudioRenderClient**/ ma_ptr pRenderClient;
-            /*IAudioCaptureClient**/ ma_ptr pCaptureClient;
-            /*IMMDeviceEnumerator**/ ma_ptr pDeviceEnumerator;      /* Used for IMMNotificationClient notifications. Required for detecting default device changes. */
-            ma_IMMNotificationClient notificationClient;
-            /*HANDLE*/ ma_handle hEventPlayback;                    /* Auto reset. Initialized to signaled. */
-            /*HANDLE*/ ma_handle hEventCapture;                     /* Auto reset. Initialized to unsignaled. */
-            ma_uint32 actualPeriodSizeInFramesPlayback;             /* Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. */
-            ma_uint32 actualPeriodSizeInFramesCapture;
-            ma_uint32 originalPeriodSizeInFrames;
-            ma_uint32 originalPeriodSizeInMilliseconds;
-            ma_uint32 originalPeriods;
-            ma_performance_profile originalPerformanceProfile;
-            ma_uint32 periodSizeInFramesPlayback;
-            ma_uint32 periodSizeInFramesCapture;
-            MA_ATOMIC ma_bool32 isStartedCapture;                   /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
-            MA_ATOMIC ma_bool32 isStartedPlayback;                  /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
-            ma_bool8 noAutoConvertSRC;                              /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
-            ma_bool8 noDefaultQualitySRC;                           /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
-            ma_bool8 noHardwareOffloading;
-            ma_bool8 allowCaptureAutoStreamRouting;
-            ma_bool8 allowPlaybackAutoStreamRouting;
-            ma_bool8 isDetachedPlayback;
-            ma_bool8 isDetachedCapture;
-        } wasapi;
-#endif
-#ifdef MA_SUPPORT_DSOUND
-        struct
-        {
-            /*LPDIRECTSOUND*/ ma_ptr pPlayback;
-            /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackPrimaryBuffer;
-            /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackBuffer;
-            /*LPDIRECTSOUNDCAPTURE*/ ma_ptr pCapture;
-            /*LPDIRECTSOUNDCAPTUREBUFFER*/ ma_ptr pCaptureBuffer;
-        } dsound;
-#endif
-#ifdef MA_SUPPORT_WINMM
-        struct
-        {
-            /*HWAVEOUT*/ ma_handle hDevicePlayback;
-            /*HWAVEIN*/ ma_handle hDeviceCapture;
-            /*HANDLE*/ ma_handle hEventPlayback;
-            /*HANDLE*/ ma_handle hEventCapture;
-            ma_uint32 fragmentSizeInFrames;
-            ma_uint32 iNextHeaderPlayback;             /* [0,periods). Used as an index into pWAVEHDRPlayback. */
-            ma_uint32 iNextHeaderCapture;              /* [0,periods). Used as an index into pWAVEHDRCapture. */
-            ma_uint32 headerFramesConsumedPlayback;    /* The number of PCM frames consumed in the buffer in pWAVEHEADER[iNextHeader]. */
-            ma_uint32 headerFramesConsumedCapture;     /* ^^^ */
-            /*WAVEHDR**/ ma_uint8* pWAVEHDRPlayback;   /* One instantiation for each period. */
-            /*WAVEHDR**/ ma_uint8* pWAVEHDRCapture;    /* One instantiation for each period. */
-            ma_uint8* pIntermediaryBufferPlayback;
-            ma_uint8* pIntermediaryBufferCapture;
-            ma_uint8* _pHeapData;                      /* Used internally and is used for the heap allocated data for the intermediary buffer and the WAVEHDR structures. */
-        } winmm;
-#endif
-#ifdef MA_SUPPORT_ALSA
-        struct
-        {
-            /*snd_pcm_t**/ ma_ptr pPCMPlayback;
-            /*snd_pcm_t**/ ma_ptr pPCMCapture;
-            ma_bool8 isUsingMMapPlayback;
-            ma_bool8 isUsingMMapCapture;
-        } alsa;
-#endif
-#ifdef MA_SUPPORT_PULSEAUDIO
-        struct
-        {
-            /*pa_stream**/ ma_ptr pStreamPlayback;
-            /*pa_stream**/ ma_ptr pStreamCapture;
-        } pulse;
-#endif
-#ifdef MA_SUPPORT_JACK
-        struct
-        {
-            /*jack_client_t**/ ma_ptr pClient;
-            /*jack_port_t**/ ma_ptr pPortsPlayback[MA_MAX_CHANNELS];
-            /*jack_port_t**/ ma_ptr pPortsCapture[MA_MAX_CHANNELS];
-            float* pIntermediaryBufferPlayback; /* Typed as a float because JACK is always floating point. */
-            float* pIntermediaryBufferCapture;
-        } jack;
-#endif
-#ifdef MA_SUPPORT_COREAUDIO
-        struct
-        {
-            ma_uint32 deviceObjectIDPlayback;
-            ma_uint32 deviceObjectIDCapture;
-            /*AudioUnit*/ ma_ptr audioUnitPlayback;
-            /*AudioUnit*/ ma_ptr audioUnitCapture;
-            /*AudioBufferList**/ ma_ptr pAudioBufferList;   /* Only used for input devices. */
-            ma_uint32 audioBufferCapInFrames;               /* Only used for input devices. The capacity in frames of each buffer in pAudioBufferList. */
-            ma_event stopEvent;
-            ma_uint32 originalPeriodSizeInFrames;
-            ma_uint32 originalPeriodSizeInMilliseconds;
-            ma_uint32 originalPeriods;
-            ma_performance_profile originalPerformanceProfile;
-            ma_bool32 isDefaultPlaybackDevice;
-            ma_bool32 isDefaultCaptureDevice;
-            ma_bool32 isSwitchingPlaybackDevice;   /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
-            ma_bool32 isSwitchingCaptureDevice;    /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
-            void* pRouteChangeHandler;             /* Only used on mobile platforms. Obj-C object for handling route changes. */
-        } coreaudio;
-#endif
-#ifdef MA_SUPPORT_SNDIO
-        struct
-        {
-            ma_ptr handlePlayback;
-            ma_ptr handleCapture;
-            ma_bool32 isStartedPlayback;
-            ma_bool32 isStartedCapture;
-        } sndio;
-#endif
-#ifdef MA_SUPPORT_AUDIO4
-        struct
-        {
-            int fdPlayback;
-            int fdCapture;
-        } audio4;
-#endif
-#ifdef MA_SUPPORT_OSS
-        struct
-        {
-            int fdPlayback;
-            int fdCapture;
-        } oss;
-#endif
-#ifdef MA_SUPPORT_AAUDIO
-        struct
-        {
-            /*AAudioStream**/ ma_ptr pStreamPlayback;
-            /*AAudioStream**/ ma_ptr pStreamCapture;
-        } aaudio;
-#endif
-#ifdef MA_SUPPORT_OPENSL
-        struct
-        {
-            /*SLObjectItf*/ ma_ptr pOutputMixObj;
-            /*SLOutputMixItf*/ ma_ptr pOutputMix;
-            /*SLObjectItf*/ ma_ptr pAudioPlayerObj;
-            /*SLPlayItf*/ ma_ptr pAudioPlayer;
-            /*SLObjectItf*/ ma_ptr pAudioRecorderObj;
-            /*SLRecordItf*/ ma_ptr pAudioRecorder;
-            /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueuePlayback;
-            /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueueCapture;
-            ma_bool32 isDrainingCapture;
-            ma_bool32 isDrainingPlayback;
-            ma_uint32 currentBufferIndexPlayback;
-            ma_uint32 currentBufferIndexCapture;
-            ma_uint8* pBufferPlayback;      /* This is malloc()'d and is used for storing audio data. Typed as ma_uint8 for easy offsetting. */
-            ma_uint8* pBufferCapture;
-        } opensl;
-#endif
-#ifdef MA_SUPPORT_WEBAUDIO
-        struct
-        {
-            int indexPlayback;              /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */
-            int indexCapture;
-        } webaudio;
-#endif
-#ifdef MA_SUPPORT_NULL
-        struct
-        {
-            ma_thread deviceThread;
-            ma_event operationEvent;
-            ma_event operationCompletionEvent;
-            ma_semaphore operationSemaphore;
-            ma_uint32 operation;
-            ma_result operationResult;
-            ma_timer timer;
-            double priorRunTime;
-            ma_uint32 currentPeriodFramesRemainingPlayback;
-            ma_uint32 currentPeriodFramesRemainingCapture;
-            ma_uint64 lastProcessedFramePlayback;
-            ma_uint64 lastProcessedFrameCapture;
-            MA_ATOMIC ma_bool32 isStarted;   /* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */
-        } null_device;
-#endif
-    };
-};
-#if defined(_MSC_VER) && !defined(__clang__)
-    #pragma warning(pop)
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
-    #pragma GCC diagnostic pop  /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
-#endif
-
-/*
-Initializes a `ma_context_config` object.
-
-
-Return Value
-------------
-A `ma_context_config` initialized to defaults.
-
-
-Remarks
--------
-You must always use this to initialize the default state of the `ma_context_config` object. Not using this will result in your program breaking when miniaudio
-is updated and new members are added to `ma_context_config`. It also sets logical defaults.
-
-You can override members of the returned object by changing it's members directly.
-
-
-See Also
---------
-ma_context_init()
-*/
-MA_API ma_context_config ma_context_config_init(void);
-
-/*
-Initializes a context.
-
-The context is used for selecting and initializing an appropriate backend and to represent the backend at a more global level than that of an individual
-device. There is one context to many devices, and a device is created from a context. A context is required to enumerate devices.
-
-
-Parameters
-----------
-backends (in, optional)
-    A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
-
-backendCount (in, optional)
-    The number of items in `backend`. Ignored if `backend` is NULL.
-
-pConfig (in, optional)
-    The context configuration.
-
-pContext (in)
-    A pointer to the context object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Do not call this function across multiple threads as some backends read and write to global state.
-
-
-Remarks
--------
-When `backends` is NULL, the default priority order will be used. Below is a list of backends in priority order:
-
-    |-------------|-----------------------|--------------------------------------------------------|
-    | Name        | Enum Name             | Supported Operating Systems                            |
-    |-------------|-----------------------|--------------------------------------------------------|
-    | WASAPI      | ma_backend_wasapi     | Windows Vista+                                         |
-    | DirectSound | ma_backend_dsound     | Windows XP+                                            |
-    | WinMM       | ma_backend_winmm      | Windows XP+ (may work on older versions, but untested) |
-    | Core Audio  | ma_backend_coreaudio  | macOS, iOS                                             |
-    | ALSA        | ma_backend_alsa       | Linux                                                  |
-    | PulseAudio  | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android)  |
-    | JACK        | ma_backend_jack       | Cross Platform (disabled on BSD and Android)           |
-    | sndio       | ma_backend_sndio      | OpenBSD                                                |
-    | audio(4)    | ma_backend_audio4     | NetBSD, OpenBSD                                        |
-    | OSS         | ma_backend_oss        | FreeBSD                                                |
-    | AAudio      | ma_backend_aaudio     | Android 8+                                             |
-    | OpenSL|ES   | ma_backend_opensl     | Android (API level 16+)                                |
-    | Web Audio   | ma_backend_webaudio   | Web (via Emscripten)                                   |
-    | Null        | ma_backend_null       | Cross Platform (not used on Web)                       |
-    |-------------|-----------------------|--------------------------------------------------------|
-
-The context can be configured via the `pConfig` argument. The config object is initialized with `ma_context_config_init()`. Individual configuration settings
-can then be set directly on the structure. Below are the members of the `ma_context_config` object.
-
-    logCallback
-        Callback for handling log messages from miniaudio.
-
-    threadPriority
-        The desired priority to use for the audio thread. Allowable values include the following:
-
-        |--------------------------------------|
-        | Thread Priority                      |
-        |--------------------------------------|
-        | ma_thread_priority_idle              |
-        | ma_thread_priority_lowest            |
-        | ma_thread_priority_low               |
-        | ma_thread_priority_normal            |
-        | ma_thread_priority_high              |
-        | ma_thread_priority_highest (default) |
-        | ma_thread_priority_realtime          |
-        | ma_thread_priority_default           |
-        |--------------------------------------|
-
-    pUserData
-        A pointer to application-defined data. This can be accessed from the context object directly such as `context.pUserData`.
-
-    allocationCallbacks
-        Structure containing custom allocation callbacks. Leaving this at defaults will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. These allocation
-        callbacks will be used for anything tied to the context, including devices.
-
-    alsa.useVerboseDeviceEnumeration
-        ALSA will typically enumerate many different devices which can be intrusive and not user-friendly. To combat this, miniaudio will enumerate only unique
-        card/device pairs by default. The problem with this is that you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes
-        it so the ALSA backend includes all devices. Defaults to false.
-
-    pulse.pApplicationName
-        PulseAudio only. The application name to use when initializing the PulseAudio context with `pa_context_new()`.
-
-    pulse.pServerName
-        PulseAudio only. The name of the server to connect to with `pa_context_connect()`.
-
-    pulse.tryAutoSpawn
-        PulseAudio only. Whether or not to try automatically starting the PulseAudio daemon. Defaults to false. If you set this to true, keep in mind that
-        miniaudio uses a trial and error method to find the most appropriate backend, and this will result in the PulseAudio daemon starting which may be
-        intrusive for the end user.
-
-    coreaudio.sessionCategory
-        iOS only. The session category to use for the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
-
-        |-----------------------------------------|-------------------------------------|
-        | miniaudio Token                         | Core Audio Token                    |
-        |-----------------------------------------|-------------------------------------|
-        | ma_ios_session_category_ambient         | AVAudioSessionCategoryAmbient       |
-        | ma_ios_session_category_solo_ambient    | AVAudioSessionCategorySoloAmbient   |
-        | ma_ios_session_category_playback        | AVAudioSessionCategoryPlayback      |
-        | ma_ios_session_category_record          | AVAudioSessionCategoryRecord        |
-        | ma_ios_session_category_play_and_record | AVAudioSessionCategoryPlayAndRecord |
-        | ma_ios_session_category_multi_route     | AVAudioSessionCategoryMultiRoute    |
-        | ma_ios_session_category_none            | AVAudioSessionCategoryAmbient       |
-        | ma_ios_session_category_default         | AVAudioSessionCategoryAmbient       |
-        |-----------------------------------------|-------------------------------------|
-
-    coreaudio.sessionCategoryOptions
-        iOS only. Session category options to use with the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
-
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-        | miniaudio Token                                                           | Core Audio Token                                                 |
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-        | ma_ios_session_category_option_mix_with_others                            | AVAudioSessionCategoryOptionMixWithOthers                        |
-        | ma_ios_session_category_option_duck_others                                | AVAudioSessionCategoryOptionDuckOthers                           |
-        | ma_ios_session_category_option_allow_bluetooth                            | AVAudioSessionCategoryOptionAllowBluetooth                       |
-        | ma_ios_session_category_option_default_to_speaker                         | AVAudioSessionCategoryOptionDefaultToSpeaker                     |
-        | ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers |
-        | ma_ios_session_category_option_allow_bluetooth_a2dp                       | AVAudioSessionCategoryOptionAllowBluetoothA2DP                   |
-        | ma_ios_session_category_option_allow_air_play                             | AVAudioSessionCategoryOptionAllowAirPlay                         |
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-
-    jack.pClientName
-        The name of the client to pass to `jack_client_open()`.
-
-    jack.tryStartServer
-        Whether or not to try auto-starting the JACK server. Defaults to false.
-
-
-It is recommended that only a single context is active at any given time because it's a bulky data structure which performs run-time linking for the
-relevant backends every time it's initialized.
-
-The location of the context cannot change throughout it's lifetime. Consider allocating the `ma_context` object with `malloc()` if this is an issue. The
-reason for this is that a pointer to the context is stored in the `ma_device` structure.
-
-
-Example 1 - Default Initialization
-----------------------------------
-The example below shows how to initialize the context using the default configuration.
-
-```c
-ma_context context;
-ma_result result = ma_context_init(NULL, 0, NULL, &context);
-if (result != MA_SUCCESS) {
-    // Error.
-}
-```
-
-
-Example 2 - Custom Configuration
---------------------------------
-The example below shows how to initialize the context using custom backend priorities and a custom configuration. In this hypothetical example, the program
-wants to prioritize ALSA over PulseAudio on Linux. They also want to avoid using the WinMM backend on Windows because it's latency is too high. They also
-want an error to be returned if no valid backend is available which they achieve by excluding the Null backend.
-
-For the configuration, the program wants to capture any log messages so they can, for example, route it to a log file and user interface.
-
-```c
-ma_backend backends[] = {
-    ma_backend_alsa,
-    ma_backend_pulseaudio,
-    ma_backend_wasapi,
-    ma_backend_dsound
-};
-
-ma_context_config config = ma_context_config_init();
-config.logCallback = my_log_callback;
-config.pUserData   = pMyUserData;
-
-ma_context context;
-ma_result result = ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &config, &context);
-if (result != MA_SUCCESS) {
-    // Error.
-    if (result == MA_NO_BACKEND) {
-        // Couldn't find an appropriate backend.
-    }
-}
-```
-
-
-See Also
---------
-ma_context_config_init()
-ma_context_uninit()
-*/
-MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext);
-
-/*
-Uninitializes a context.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Do not call this function across multiple threads as some backends read and write to global state.
-
-
-Remarks
--------
-Results are undefined if you call this while any device created by this context is still active.
-
-
-See Also
---------
-ma_context_init()
-*/
-MA_API ma_result ma_context_uninit(ma_context* pContext);
-
-/*
-Retrieves the size of the ma_context object.
-
-This is mainly for the purpose of bindings to know how much memory to allocate.
-*/
-MA_API size_t ma_context_sizeof(void);
-
-/*
-Enumerates over every device (both playback and capture).
-
-This is a lower-level enumeration function to the easier to use `ma_context_get_devices()`. Use `ma_context_enumerate_devices()` if you would rather not incur
-an internal heap allocation, or it simply suits your code better.
-
-Note that this only retrieves the ID and name/description of the device. The reason for only retrieving basic information is that it would otherwise require
-opening the backend device in order to probe it for more detailed information which can be inefficient. Consider using `ma_context_get_device_info()` for this,
-but don't call it from within the enumeration callback.
-
-Returning false from the callback will stop enumeration. Returning true will continue enumeration.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-callback (in)
-    The callback to fire for each enumerated device.
-
-pUserData (in)
-    A pointer to application-defined data passed to the callback.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. This is guarded using a simple mutex lock.
-
-
-Remarks
--------
-Do _not_ assume the first enumerated device of a given type is the default device.
-
-Some backends and platforms may only support default playback and capture devices.
-
-In general, you should not do anything complicated from within the callback. In particular, do not try initializing a device from within the callback. Also,
-do not try to call `ma_context_get_device_info()` from within the callback.
-
-Consider using `ma_context_get_devices()` for a simpler and safer API, albeit at the expense of an internal heap allocation.
-
-
-Example 1 - Simple Enumeration
-------------------------------
-ma_bool32 ma_device_enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData)
-{
-    printf("Device Name: %s\n", pInfo->name);
-    return MA_TRUE;
-}
-
-ma_result result = ma_context_enumerate_devices(&context, my_device_enum_callback, pMyUserData);
-if (result != MA_SUCCESS) {
-    // Error.
-}
-
-
-See Also
---------
-ma_context_get_devices()
-*/
-MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData);
-
-/*
-Retrieves basic information about every active playback and/or capture device.
-
-This function will allocate memory internally for the device lists and return a pointer to them through the `ppPlaybackDeviceInfos` and `ppCaptureDeviceInfos`
-parameters. If you do not want to incur the overhead of these allocations consider using `ma_context_enumerate_devices()` which will instead use a callback.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-ppPlaybackDeviceInfos (out)
-    A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for playback devices.
-
-pPlaybackDeviceCount (out)
-    A pointer to an unsigned integer that will receive the number of playback devices.
-
-ppCaptureDeviceInfos (out)
-    A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for capture devices.
-
-pCaptureDeviceCount (out)
-    A pointer to an unsigned integer that will receive the number of capture devices.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Since each call to this function invalidates the pointers from the previous call, you should not be calling this simultaneously across multiple
-threads. Instead, you need to make a copy of the returned data with your own higher level synchronization.
-
-
-Remarks
--------
-It is _not_ safe to assume the first device in the list is the default device.
-
-You can pass in NULL for the playback or capture lists in which case they'll be ignored.
-
-The returned pointers will become invalid upon the next call this this function, or when the context is uninitialized. Do not free the returned pointers.
-
-
-See Also
---------
-ma_context_get_devices()
-*/
-MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount);
-
-/*
-Retrieves information about a device of the given type, with the specified ID and share mode.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the query.
-
-deviceType (in)
-    The type of the device being queried. Must be either `ma_device_type_playback` or `ma_device_type_capture`.
-
-pDeviceID (in)
-    The ID of the device being queried.
-
-shareMode (in)
-    The share mode to query for device capabilities. This should be set to whatever you're intending on using when initializing the device. If you're unsure,
-    set this to `ma_share_mode_shared`.
-
-pDeviceInfo (out)
-    A pointer to the `ma_device_info` structure that will receive the device information.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. This is guarded using a simple mutex lock.
-
-
-Remarks
--------
-Do _not_ call this from within the `ma_context_enumerate_devices()` callback.
-
-It's possible for a device to have different information and capabilities depending on whether or not it's opened in shared or exclusive mode. For example, in
-shared mode, WASAPI always uses floating point samples for mixing, but in exclusive mode it can be anything. Therefore, this function allows you to specify
-which share mode you want information for. Note that not all backends and devices support shared or exclusive mode, in which case this function will fail if
-the requested share mode is unsupported.
-
-This leaves pDeviceInfo unmodified in the result of an error.
-*/
-MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, ma_device_info* pDeviceInfo);
-
-/*
-Determines if the given context supports loopback mode.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context getting queried.
-
-
-Return Value
-------------
-MA_TRUE if the context supports loopback mode; MA_FALSE otherwise.
-*/
-MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext);
-
-
-
-/*
-Initializes a device config with default settings.
-
-
-Parameters
-----------
-deviceType (in)
-    The type of the device this config is being initialized for. This must set to one of the following:
-
-    |-------------------------|
-    | Device Type             |
-    |-------------------------|
-    | ma_device_type_playback |
-    | ma_device_type_capture  |
-    | ma_device_type_duplex   |
-    | ma_device_type_loopback |
-    |-------------------------|
-
-
-Return Value
-------------
-A new device config object with default settings. You will typically want to adjust the config after this function returns. See remarks.
-
-
-Thread Safety
--------------
-Safe.
-
-
-Callback Safety
----------------
-Safe, but don't try initializing a device in a callback.
-
-
-Remarks
--------
-The returned config will be initialized to defaults. You will normally want to customize a few variables before initializing the device. See Example 1 for a
-typical configuration which sets the sample format, channel count, sample rate, data callback and user data. These are usually things you will want to change
-before initializing the device.
-
-See `ma_device_init()` for details on specific configuration options.
-
-
-Example 1 - Simple Configuration
---------------------------------
-The example below is what a program will typically want to configure for each device at a minimum. Notice how `ma_device_config_init()` is called first, and
-then the returned object is modified directly. This is important because it ensures that your program continues to work as new configuration options are added
-to the `ma_device_config` structure.
-
-```c
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.format   = ma_format_f32;
-config.playback.channels = 2;
-config.sampleRate        = 48000;
-config.dataCallback      = ma_data_callback;
-config.pUserData         = pMyUserData;
-```
-
-
-See Also
---------
-ma_device_init()
-ma_device_init_ex()
-*/
-MA_API ma_device_config ma_device_config_init(ma_device_type deviceType);
-
-
-/*
-Initializes a device.
-
-A device represents a physical audio device. The idea is you send or receive audio data from the device to either play it back through a speaker, or capture it
-from a microphone. Whether or not you should send or receive data from the device (or both) depends on the type of device you are initializing which can be
-playback, capture, full-duplex or loopback. (Note that loopback mode is only supported on select backends.) Sending and receiving audio data to and from the
-device is done via a callback which is fired by miniaudio at periodic time intervals.
-
-The frequency at which data is delivered to and from a device depends on the size of it's period. The size of the period can be defined in terms of PCM frames
-or milliseconds, whichever is more convenient. Generally speaking, the smaller the period, the lower the latency at the expense of higher CPU usage and
-increased risk of glitching due to the more frequent and granular data deliver intervals. The size of a period will depend on your requirements, but
-miniaudio's defaults should work fine for most scenarios. If you're building a game you should leave this fairly small, whereas if you're building a simple
-media player you can make it larger. Note that the period size you request is actually just a hint - miniaudio will tell the backend what you want, but the
-backend is ultimately responsible for what it gives you. You cannot assume you will get exactly what you ask for.
-
-When delivering data to and from a device you need to make sure it's in the correct format which you can set through the device configuration. You just set the
-format that you want to use and miniaudio will perform all of the necessary conversion for you internally. When delivering data to and from the callback you
-can assume the format is the same as what you requested when you initialized the device. See Remarks for more details on miniaudio's data conversion pipeline.
-
-
-Parameters
-----------
-pContext (in, optional)
-    A pointer to the context that owns the device. This can be null, in which case it creates a default context internally.
-
-pConfig (in)
-    A pointer to the device configuration. Cannot be null. See remarks for details.
-
-pDevice (out)
-    A pointer to the device object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to
-calling this at the same time as `ma_device_uninit()`.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-Setting `pContext` to NULL will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so:
-
-    ```c
-    ma_context_init(NULL, 0, NULL, &context);
-    ```
-
-Do not set `pContext` to NULL if you are needing to open multiple devices. You can, however, use NULL when initializing the first device, and then use
-device.pContext for the initialization of other devices.
-
-The device can be configured via the `pConfig` argument. The config object is initialized with `ma_device_config_init()`. Individual configuration settings can
-then be set directly on the structure. Below are the members of the `ma_device_config` object.
-
-    deviceType
-        Must be `ma_device_type_playback`, `ma_device_type_capture`, `ma_device_type_duplex` of `ma_device_type_loopback`.
-
-    sampleRate
-        The sample rate, in hertz. The most common sample rates are 48000 and 44100. Setting this to 0 will use the device's native sample rate.
-
-    periodSizeInFrames
-        The desired size of a period in PCM frames. If this is 0, `periodSizeInMilliseconds` will be used instead. If both are 0 the default buffer size will
-        be used depending on the selected performance profile. This value affects latency. See below for details.
-
-    periodSizeInMilliseconds
-        The desired size of a period in milliseconds. If this is 0, `periodSizeInFrames` will be used instead. If both are 0 the default buffer size will be
-        used depending on the selected performance profile. The value affects latency. See below for details.
-
-    periods
-        The number of periods making up the device's entire buffer. The total buffer size is `periodSizeInFrames` or `periodSizeInMilliseconds` multiplied by
-        this value. This is just a hint as backends will be the ones who ultimately decide how your periods will be configured.
-
-    performanceProfile
-        A hint to miniaudio as to the performance requirements of your program. Can be either `ma_performance_profile_low_latency` (default) or
-        `ma_performance_profile_conservative`. This mainly affects the size of default buffers and can usually be left at it's default value.
-
-    noPreZeroedOutputBuffer
-        When set to true, the contents of the output buffer passed into the data callback will be left undefined. When set to false (default), the contents of
-        the output buffer will be cleared the zero. You can use this to avoid the overhead of zeroing out the buffer if you can guarantee that your data
-        callback will write to every sample in the output buffer, or if you are doing your own clearing.
-
-    noClip
-        When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. When set to false (default), the
-        contents of the output buffer are left alone after returning and it will be left up to the backend itself to decide whether or not the clip. This only
-        applies when the playback sample format is f32.
-
-    dataCallback
-        The callback to fire whenever data is ready to be delivered to or from the device.
-
-    stopCallback
-        The callback to fire whenever the device has stopped, either explicitly via `ma_device_stop()`, or implicitly due to things like the device being
-        disconnected.
-
-    pUserData
-        The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`.
-
-    resampling.algorithm
-        The resampling algorithm to use when miniaudio needs to perform resampling between the rate specified by `sampleRate` and the device's native rate. The
-        default value is `ma_resample_algorithm_linear`, and the quality can be configured with `resampling.linear.lpfOrder`.
-
-    resampling.linear.lpfOrder
-        The linear resampler applies a low-pass filter as part of it's procesing for anti-aliasing. This setting controls the order of the filter. The higher
-        the value, the better the quality, in general. Setting this to 0 will disable low-pass filtering altogether. The maximum value is
-        `MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`.
-
-    playback.pDeviceID
-        A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this NULL (default) will use the system's
-        default playback device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
-
-    playback.format
-        The sample format to use for playback. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
-        initialization from the device object directly with `device.playback.format`.
-
-    playback.channels
-        The number of channels to use for playback. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
-        from the device object directly with `device.playback.channels`.
-
-    playback.channelMap
-        The channel map to use for playback. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
-        device object direct with `device.playback.channelMap`.
-
-    playback.shareMode
-        The preferred share mode to use for playback. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
-        exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
-        ma_share_mode_shared and reinitializing.
-
-    capture.pDeviceID
-        A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this NULL (default) will use the system's
-        default capture device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
-
-    capture.format
-        The sample format to use for capture. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
-        initialization from the device object directly with `device.capture.format`.
-
-    capture.channels
-        The number of channels to use for capture. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
-        from the device object directly with `device.capture.channels`.
-
-    capture.channelMap
-        The channel map to use for capture. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
-        device object direct with `device.capture.channelMap`.
-
-    capture.shareMode
-        The preferred share mode to use for capture. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
-        exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
-        ma_share_mode_shared and reinitializing.
-
-    wasapi.noAutoConvertSRC
-        WASAPI only. When set to true, disables WASAPI's automatic resampling and forces the use of miniaudio's resampler. Defaults to false.
-
-    wasapi.noDefaultQualitySRC
-        WASAPI only. Only used when `wasapi.noAutoConvertSRC` is set to false. When set to true, disables the use of `AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY`.
-        You should usually leave this set to false, which is the default.
-
-    wasapi.noAutoStreamRouting
-        WASAPI only. When set to true, disables automatic stream routing on the WASAPI backend. Defaults to false.
-
-    wasapi.noHardwareOffloading
-        WASAPI only. When set to true, disables the use of WASAPI's hardware offloading feature. Defaults to false.
-
-    alsa.noMMap
-        ALSA only. When set to true, disables MMap mode. Defaults to false.
-
-    alsa.noAutoFormat
-        ALSA only. When set to true, disables ALSA's automatic format conversion by including the SND_PCM_NO_AUTO_FORMAT flag. Defaults to false.
-
-    alsa.noAutoChannels
-        ALSA only. When set to true, disables ALSA's automatic channel conversion by including the SND_PCM_NO_AUTO_CHANNELS flag. Defaults to false.
-
-    alsa.noAutoResample
-        ALSA only. When set to true, disables ALSA's automatic resampling by including the SND_PCM_NO_AUTO_RESAMPLE flag. Defaults to false.
-
-    pulse.pStreamNamePlayback
-        PulseAudio only. Sets the stream name for playback.
-
-    pulse.pStreamNameCapture
-        PulseAudio only. Sets the stream name for capture.
-
-    coreaudio.allowNominalSampleRateChange
-        Core Audio only. Desktop only. When enabled, allows the sample rate of the device to be changed at the operating system level. This
-        is disabled by default in order to prevent intrusive changes to the user's system. This is useful if you want to use a sample rate
-        that is known to be natively supported by the hardware thereby avoiding the cost of resampling. When set to true, miniaudio will
-        find the closest match between the sample rate requested in the device config and the sample rates natively supported by the
-        hardware. When set to false, the sample rate currently set by the operating system will always be used.
-
-
-Once initialized, the device's config is immutable. If you need to change the config you will need to initialize a new device.
-
-After initializing the device it will be in a stopped state. To start it, use `ma_device_start()`.
-
-If both `periodSizeInFrames` and `periodSizeInMilliseconds` are set to zero, it will default to `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY` or
-`MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE`, depending on whether or not `performanceProfile` is set to `ma_performance_profile_low_latency` or
-`ma_performance_profile_conservative`.
-
-If you request exclusive mode and the backend does not support it an error will be returned. For robustness, you may want to first try initializing the device
-in exclusive mode, and then fall back to shared mode if required. Alternatively you can just request shared mode (the default if you leave it unset in the
-config) which is the most reliable option. Some backends do not have a practical way of choosing whether or not the device should be exclusive or not (ALSA,
-for example) in which case it just acts as a hint. Unless you have special requirements you should try avoiding exclusive mode as it's intrusive to the user.
-Starting with Windows 10, miniaudio will use low-latency shared mode where possible which may make exclusive mode unnecessary.
-
-When sending or receiving data to/from a device, miniaudio will internally perform a format conversion to convert between the format specified by the config
-and the format used internally by the backend. If you pass in 0 for the sample format, channel count, sample rate _and_ channel map, data transmission will run
-on an optimized pass-through fast path. You can retrieve the format, channel count and sample rate by inspecting the `playback/capture.format`,
-`playback/capture.channels` and `sampleRate` members of the device object.
-
-When compiling for UWP you must ensure you call this function on the main UI thread because the operating system may need to present the user with a message
-asking for permissions. Please refer to the official documentation for ActivateAudioInterfaceAsync() for more information.
-
-ALSA Specific: When initializing the default device, requesting shared mode will try using the "dmix" device for playback and the "dsnoop" device for capture.
-If these fail it will try falling back to the "hw" device.
-
-
-Example 1 - Simple Initialization
----------------------------------
-This example shows how to initialize a simple playback device using a standard configuration. If you are just needing to do simple playback from the default
-playback device this is usually all you need.
-
-```c
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.format   = ma_format_f32;
-config.playback.channels = 2;
-config.sampleRate        = 48000;
-config.dataCallback      = ma_data_callback;
-config.pMyUserData       = pMyUserData;
-
-ma_device device;
-ma_result result = ma_device_init(NULL, &config, &device);
-if (result != MA_SUCCESS) {
-    // Error
-}
-```
-
-
-Example 2 - Advanced Initialization
------------------------------------
-This example shows how you might do some more advanced initialization. In this hypothetical example we want to control the latency by setting the buffer size
-and period count. We also want to allow the user to be able to choose which device to output from which means we need a context so we can perform device
-enumeration.
-
-```c
-ma_context context;
-ma_result result = ma_context_init(NULL, 0, NULL, &context);
-if (result != MA_SUCCESS) {
-    // Error
-}
-
-ma_device_info* pPlaybackDeviceInfos;
-ma_uint32 playbackDeviceCount;
-result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL);
-if (result != MA_SUCCESS) {
-    // Error
-}
-
-// ... choose a device from pPlaybackDeviceInfos ...
-
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.pDeviceID       = pMyChosenDeviceID;    // <-- Get this from the `id` member of one of the `ma_device_info` objects returned by ma_context_get_devices().
-config.playback.format          = ma_format_f32;
-config.playback.channels        = 2;
-config.sampleRate               = 48000;
-config.dataCallback             = ma_data_callback;
-config.pUserData                = pMyUserData;
-config.periodSizeInMilliseconds = 10;
-config.periods                  = 3;
-
-ma_device device;
-result = ma_device_init(&context, &config, &device);
-if (result != MA_SUCCESS) {
-    // Error
-}
-```
-
-
-See Also
---------
-ma_device_config_init()
-ma_device_uninit()
-ma_device_start()
-ma_context_init()
-ma_context_get_devices()
-ma_context_enumerate_devices()
-*/
-MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice);
-
-/*
-Initializes a device without a context, with extra parameters for controlling the configuration of the internal self-managed context.
-
-This is the same as `ma_device_init()`, only instead of a context being passed in, the parameters from `ma_context_init()` are passed in instead. This function
-allows you to configure the internally created context.
-
-
-Parameters
-----------
-backends (in, optional)
-    A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
-
-backendCount (in, optional)
-    The number of items in `backend`. Ignored if `backend` is NULL.
-
-pContextConfig (in, optional)
-    The context configuration.
-
-pConfig (in)
-    A pointer to the device configuration. Cannot be null. See remarks for details.
-
-pDevice (out)
-    A pointer to the device object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to
-calling this at the same time as `ma_device_uninit()`.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-You only need to use this function if you want to configure the context differently to it's defaults. You should never use this function if you want to manage
-your own context.
-
-See the documentation for `ma_context_init()` for information on the different context configuration options.
-
-
-See Also
---------
-ma_device_init()
-ma_device_uninit()
-ma_device_config_init()
-ma_context_init()
-*/
-MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice);
-
-/*
-Uninitializes a device.
-
-This will explicitly stop the device. You do not need to call `ma_device_stop()` beforehand, but it's harmless if you do.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to stop.
-
-
-Return Value
-------------
-Nothing
-
-
-Thread Safety
--------------
-Unsafe. As soon as this API is called the device should be considered undefined.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.
-
-
-See Also
---------
-ma_device_init()
-ma_device_stop()
-*/
-MA_API void ma_device_uninit(ma_device* pDevice);
-
-/*
-Starts the device. For playback devices this begins playback. For capture devices it begins recording.
-
-Use `ma_device_stop()` to stop the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to start.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. It's safe to call this from any thread with the exception of the callback thread.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-For a playback device, this will retrieve an initial chunk of audio data from the client before returning. The reason for this is to ensure there is valid
-audio data in the buffer, which needs to be done before the device begins playback.
-
-This API waits until the backend device has been started for real by the worker thread. It also waits on a mutex for thread-safety.
-
-Do not call this in any callback.
-
-
-See Also
---------
-ma_device_stop()
-*/
-MA_API ma_result ma_device_start(ma_device* pDevice);
-
-/*
-Stops the device. For playback devices this stops playback. For capture devices it stops recording.
-
-Use `ma_device_start()` to start the device again.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to stop.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. It's safe to call this from any thread with the exception of the callback thread.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.
-
-
-Remarks
--------
-This API needs to wait on the worker thread to stop the backend device properly before returning. It also waits on a mutex for thread-safety. In addition, some
-backends need to wait for the device to finish playback/recording of the current fragment which can take some time (usually proportionate to the buffer size
-that was specified at initialization time).
-
-Backends are required to either pause the stream in-place or drain the buffer if pausing is not possible. The reason for this is that stopping the device and
-the resuming it with ma_device_start() (which you might do when your program loses focus) may result in a situation where those samples are never output to the
-speakers or received from the microphone which can in turn result in de-syncs.
-
-Do not call this in any callback.
-
-This will be called implicitly by `ma_device_uninit()`.
-
-
-See Also
---------
-ma_device_start()
-*/
-MA_API ma_result ma_device_stop(ma_device* pDevice);
-
-/*
-Determines whether or not the device is started.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose start state is being retrieved.
-
-
-Return Value
-------------
-True if the device is started, false otherwise.
-
-
-Thread Safety
--------------
-Safe. If another thread calls `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, there's a very small chance the return
-value will be out of sync.
-
-
-Callback Safety
----------------
-Safe. This is implemented as a simple accessor.
-
-
-See Also
---------
-ma_device_start()
-ma_device_stop()
-*/
-MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice);
-
-
-/*
-Retrieves the state of the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose state is being retrieved.
-
-
-Return Value
-------------
-The current state of the device. The return value will be one of the following:
-
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_UNINITIALIZED | Will only be returned if the device is in the middle of initialization.      |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STOPPED       | The device is stopped. The initial state of the device after initialization. |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STARTED       | The device started and requesting and/or delivering audio data.              |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STARTING      | The device is in the process of starting.                                    |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STOPPING      | The device is in the process of stopping.                                    |
-    +------------------------+------------------------------------------------------------------------------+
-
-
-Thread Safety
--------------
-Safe. This is implemented as a simple accessor. Note that if the device is started or stopped at the same time as this function is called,
-there's a possibility the return value could be out of sync. See remarks.
-
-
-Callback Safety
----------------
-Safe. This is implemented as a simple accessor.
-
-
-Remarks
--------
-The general flow of a devices state goes like this:
-
-    ```
-    ma_device_init()  -> MA_STATE_UNINITIALIZED -> MA_STATE_STOPPED
-    ma_device_start() -> MA_STATE_STARTING      -> MA_STATE_STARTED
-    ma_device_stop()  -> MA_STATE_STOPPING      -> MA_STATE_STOPPED
-    ```
-
-When the state of the device is changed with `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, the
-value returned by this function could potentially be out of sync. If this is significant to your program you need to implement your own
-synchronization.
-*/
-MA_API ma_uint32 ma_device_get_state(const ma_device* pDevice);
-
-
-/*
-Sets the master volume factor for the device.
-
-The volume factor must be between 0 (silence) and 1 (full volume). Use `ma_device_set_master_gain_db()` to use decibel notation, where 0 is full volume and
-values less than 0 decreases the volume.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose volume is being set.
-
-volume (in)
-    The new volume factor. Must be within the range of [0, 1].
-
-
-Return Value
-------------
-MA_SUCCESS if the volume was set successfully.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if the volume factor is not within the range of [0, 1].
-
-
-Thread Safety
--------------
-Safe. This just sets a local member of the device object.
-
-
-Callback Safety
----------------
-Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
-
-
-Remarks
--------
-This applies the volume factor across all channels.
-
-This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream.
-
-
-See Also
---------
-ma_device_get_master_volume()
-ma_device_set_master_volume_gain_db()
-ma_device_get_master_volume_gain_db()
-*/
-MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume);
-
-/*
-Retrieves the master volume factor for the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose volume factor is being retrieved.
-
-pVolume (in)
-    A pointer to the variable that will receive the volume factor. The returned value will be in the range of [0, 1].
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if pVolume is NULL.
-
-
-Thread Safety
--------------
-Safe. This just a simple member retrieval.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If an error occurs, `*pVolume` will be set to 0.
-
-
-See Also
---------
-ma_device_set_master_volume()
-ma_device_set_master_volume_gain_db()
-ma_device_get_master_volume_gain_db()
-*/
-MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume);
-
-/*
-Sets the master volume for the device as gain in decibels.
-
-A gain of 0 is full volume, whereas a gain of < 0 will decrease the volume.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose gain is being set.
-
-gainDB (in)
-    The new volume as gain in decibels. Must be less than or equal to 0, where 0 is full volume and anything less than 0 decreases the volume.
-
-
-Return Value
-------------
-MA_SUCCESS if the volume was set successfully.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if the gain is > 0.
-
-
-Thread Safety
--------------
-Safe. This just sets a local member of the device object.
-
-
-Callback Safety
----------------
-Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
-
-
-Remarks
--------
-This applies the gain across all channels.
-
-This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream.
-
-
-See Also
---------
-ma_device_get_master_volume_gain_db()
-ma_device_set_master_volume()
-ma_device_get_master_volume()
-*/
-MA_API ma_result ma_device_set_master_gain_db(ma_device* pDevice, float gainDB);
-
-/*
-Retrieves the master gain in decibels.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose gain is being retrieved.
-
-pGainDB (in)
-    A pointer to the variable that will receive the gain in decibels. The returned value will be <= 0.
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if pGainDB is NULL.
-
-
-Thread Safety
--------------
-Safe. This just a simple member retrieval.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If an error occurs, `*pGainDB` will be set to 0.
-
-
-See Also
---------
-ma_device_set_master_volume_gain_db()
-ma_device_set_master_volume()
-ma_device_get_master_volume()
-*/
-MA_API ma_result ma_device_get_master_gain_db(ma_device* pDevice, float* pGainDB);
-
-
-/*
-Called from the data callback of asynchronous backends to allow miniaudio to process the data and fire the miniaudio data callback.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to device whose processing the data callback.
-
-pOutput (out)
-    A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be NULL. On a duplex device
-    this can be NULL, in which case pInput must not be NULL.
-
-pInput (in)
-    A pointer to the buffer containing input PCM frame data. On a capture device this must not be NULL. On a duplex device this can be
-    NULL, in which case `pOutput` must not be NULL.
-
-frameCount (in)
-    The number of frames being processed.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other result code otherwise.
-
-
-Thread Safety
--------------
-This function should only ever be called from the internal data callback of the backend. It is safe to call this simultaneously between a
-playback and capture device in duplex setups.
-
-
-Callback Safety
----------------
-Do not call this from the miniaudio data callback. It should only ever be called from the internal data callback of the backend.
-
-
-Remarks
--------
-If both `pOutput` and `pInput` are NULL, and error will be returned. In duplex scenarios, both `pOutput` and `pInput` can be non-NULL, in
-which case `pInput` will be processed first, followed by `pOutput`.
-
-If you are implementing a custom backend, and that backend uses a callback for data delivery, you'll need to call this from inside that
-callback.
-*/
-MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-
-/*
-Calculates an appropriate buffer size from a descriptor, native sample rate and performance profile.
-
-This function is used by backends for helping determine an appropriately sized buffer to use with
-the device depending on the values of `periodSizeInFrames` and `periodSizeInMilliseconds` in the
-`pDescriptor` object. Since buffer size calculations based on time depends on the sample rate, a
-best guess at the device's native sample rate is also required which is where `nativeSampleRate`
-comes in. In addition, the performance profile is also needed for cases where both the period size
-in frames and milliseconds are both zero.
-
-
-Parameters
-----------
-pDescriptor (in)
-    A pointer to device descriptor whose `periodSizeInFrames` and `periodSizeInMilliseconds` members
-    will be used for the calculation of the buffer size.
-
-nativeSampleRate (in)
-    The device's native sample rate. This is only ever used when the `periodSizeInFrames` member of
-    `pDescriptor` is zero. In this case, `periodSizeInMilliseconds` will be used instead, in which
-    case a sample rate is required to convert to a size in frames.
-
-performanceProfile (in)
-    When both the `periodSizeInFrames` and `periodSizeInMilliseconds` members of `pDescriptor` are
-    zero, miniaudio will fall back to a buffer size based on the performance profile. The profile
-    to use for this calculation is determine by this parameter.
-
-
-Return Value
-------------
-The calculated buffer size in frames.
-
-
-Thread Safety
--------------
-This is safe so long as nothing modifies `pDescriptor` at the same time. However, this function
-should only ever be called from within the backend's device initialization routine and therefore
-shouldn't have any multithreading concerns.
-
-
-Callback Safety
----------------
-This is safe to call within the data callback, but there is no reason to ever do this.
-
-
-Remarks
--------
-If `nativeSampleRate` is zero, this function will fall back to `pDescriptor->sampleRate`. If that
-is also zero, `MA_DEFAULT_SAMPLE_RATE` will be used instead.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile);
-
-
-
-/*
-Retrieves a friendly name for a backend.
-*/
-MA_API const char* ma_get_backend_name(ma_backend backend);
-
-/*
-Determines whether or not the given backend is available by the compilation environment.
-*/
-MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend);
-
-/*
-Retrieves compile-time enabled backends.
-
-
-Parameters
-----------
-pBackends (out, optional)
-    A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting
-    the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends.
-
-backendCap (in)
-    The capacity of the `pBackends` buffer.
-
-pBackendCount (out)
-    A pointer to the variable that will receive the enabled backend count.
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if `pBackendCount` is NULL.
-MA_NO_SPACE if the capacity of `pBackends` is not large enough.
-
-If `MA_NO_SPACE` is returned, the `pBackends` buffer will be filled with `*pBackendCount` values.
-
-
-Thread Safety
--------------
-Safe.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If you want to retrieve the number of backends so you can determine the capacity of `pBackends` buffer, you can call
-this function with `pBackends` set to NULL.
-
-This will also enumerate the null backend. If you don't want to include this you need to check for `ma_backend_null`
-when you enumerate over the returned backends and handle it appropriately. Alternatively, you can disable it at
-compile time with `MA_NO_NULL`.
-
-The returned backends are determined based on compile time settings, not the platform it's currently running on. For
-example, PulseAudio will be returned if it was enabled at compile time, even when the user doesn't actually have
-PulseAudio installed.
-
-
-Example 1
----------
-The example below retrieves the enabled backend count using a fixed sized buffer allocated on the stack. The buffer is
-given a capacity of `MA_BACKEND_COUNT` which will guarantee it'll be large enough to store all available backends.
-Since `MA_BACKEND_COUNT` is always a relatively small value, this should be suitable for most scenarios.
-
-```
-ma_backend enabledBackends[MA_BACKEND_COUNT];
-size_t enabledBackendCount;
-
-result = ma_get_enabled_backends(enabledBackends, MA_BACKEND_COUNT, &enabledBackendCount);
-if (result != MA_SUCCESS) {
-    // Failed to retrieve enabled backends. Should never happen in this example since all inputs are valid.
-}
-```
-
-
-See Also
---------
-ma_is_backend_enabled()
-*/
-MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount);
-
-/*
-Determines whether or not loopback mode is support by a backend.
-*/
-MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend);
-
-#endif  /* MA_NO_DEVICE_IO */
-
-
-#ifndef MA_NO_THREADING
-
-/*
-Locks a spinlock.
-*/
-MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock);
-
-/*
-Locks a spinlock, but does not yield() when looping.
-*/
-MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock);
-
-/*
-Unlocks a spinlock.
-*/
-MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock);
-
-
-/*
-Creates a mutex.
-
-A mutex must be created from a valid context. A mutex is initially unlocked.
-*/
-MA_API ma_result ma_mutex_init(ma_mutex* pMutex);
-
-/*
-Deletes a mutex.
-*/
-MA_API void ma_mutex_uninit(ma_mutex* pMutex);
-
-/*
-Locks a mutex with an infinite timeout.
-*/
-MA_API void ma_mutex_lock(ma_mutex* pMutex);
-
-/*
-Unlocks a mutex.
-*/
-MA_API void ma_mutex_unlock(ma_mutex* pMutex);
-
-
-/*
-Initializes an auto-reset event.
-*/
-MA_API ma_result ma_event_init(ma_event* pEvent);
-
-/*
-Uninitializes an auto-reset event.
-*/
-MA_API void ma_event_uninit(ma_event* pEvent);
-
-/*
-Waits for the specified auto-reset event to become signalled.
-*/
-MA_API ma_result ma_event_wait(ma_event* pEvent);
-
-/*
-Signals the specified auto-reset event.
-*/
-MA_API ma_result ma_event_signal(ma_event* pEvent);
-#endif  /* MA_NO_THREADING */
-
-
-/************************************************************************************************************************************************************
-
-Utiltities
-
-************************************************************************************************************************************************************/
-
-/*
-Adjust buffer size based on a scaling factor.
-
-This just multiplies the base size by the scaling factor, making sure it's a size of at least 1.
-*/
-MA_API ma_uint32 ma_scale_buffer_size(ma_uint32 baseBufferSize, float scale);
-
-/*
-Calculates a buffer size in milliseconds from the specified number of frames and sample rate.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate);
-
-/*
-Calculates a buffer size in frames from the specified number of milliseconds and sample rate.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate);
-
-/*
-Copies PCM frames from one buffer to another.
-*/
-MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels);
-
-/*
-Copies silent frames into the given buffer.
-
-Remarks
--------
-For all formats except `ma_format_u8`, the output buffer will be filled with 0. For `ma_format_u8` it will be filled with 128. The reason for this is that it
-makes more sense for the purpose of mixing to initialize it to the center point.
-*/
-MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels);
-static MA_INLINE void ma_zero_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { ma_silence_pcm_frames(p, frameCount, format, channels); }
-
-
-/*
-Offsets a pointer by the specified number of PCM frames.
-*/
-MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels);
-MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels);
-static MA_INLINE float* ma_offset_pcm_frames_ptr_f32(float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (float*)ma_offset_pcm_frames_ptr((void*)p, offsetInFrames, ma_format_f32, channels); }
-static MA_INLINE const float* ma_offset_pcm_frames_const_ptr_f32(const float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (const float*)ma_offset_pcm_frames_const_ptr((const void*)p, offsetInFrames, ma_format_f32, channels); }
-
-
-/*
-Clips f32 samples.
-*/
-MA_API void ma_clip_samples_f32(float* p, ma_uint64 sampleCount);
-static MA_INLINE void ma_clip_pcm_frames_f32(float* p, ma_uint64 frameCount, ma_uint32 channels) { ma_clip_samples_f32(p, frameCount*channels); }
-
-/*
-Helper for applying a volume factor to samples.
-
-Note that the source and destination buffers can be the same, in which case it'll perform the operation in-place.
-*/
-MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor);
-
-MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor);
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFramesOut, const ma_uint8* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFramesOut, const ma_int16* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFramesOut, const ma_int32* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pPCMFramesOut, const float* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor);
-
-MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames(void* pFrames, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor);
-
-
-/*
-Helper for converting a linear factor to gain in decibels.
-*/
-MA_API float ma_factor_to_gain_db(float factor);
-
-/*
-Helper for converting gain in decibels to a linear factor.
-*/
-MA_API float ma_gain_db_to_factor(float gain);
-
-
-typedef void ma_data_source;
-
-typedef struct
-{
-    ma_result (* onRead)(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
-    ma_result (* onSeek)(ma_data_source* pDataSource, ma_uint64 frameIndex);
-    ma_result (* onMap)(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount);   /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-    ma_result (* onUnmap)(ma_data_source* pDataSource, ma_uint64 frameCount);
-    ma_result (* onGetDataFormat)(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
-    ma_result (* onGetCursor)(ma_data_source* pDataSource, ma_uint64* pCursor);
-    ma_result (* onGetLength)(ma_data_source* pDataSource, ma_uint64* pLength);
-} ma_data_source_callbacks;
-
-MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop);   /* Must support pFramesOut = NULL in which case a forward seek should be performed. */
-MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked, ma_bool32 loop); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount); */
-MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex);
-MA_API ma_result ma_data_source_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_data_source_unmap(ma_data_source* pDataSource, ma_uint64 frameCount);       /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
-MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor);
-MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength);    /* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */
-
-
-
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint64 cursor;
-    ma_uint64 sizeInFrames;
-    const void* pData;
-} ma_audio_buffer_ref;
-
-MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames);
-MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount);    /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_audio_buffer_ref_at_end(ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_get_available_frames(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames);
-
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint64 sizeInFrames;
-    const void* pData;  /* If set to NULL, will allocate a block of memory for you. */
-    ma_allocation_callbacks allocationCallbacks;
-} ma_audio_buffer_config;
-
-MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks);
-
-typedef struct
-{
-    ma_audio_buffer_ref ref;
-    ma_allocation_callbacks allocationCallbacks;
-    ma_bool32 ownsData;             /* Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). */
-    ma_uint8 _pExtraData[1];        /* For allocating a buffer with the memory located directly after the other memory of the structure. */
-} ma_audio_buffer;
-
-MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer);  /* Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit. */
-MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer);
-MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer);
-MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount);    /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_audio_buffer_at_end(ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_get_available_frames(ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames);
-
-
-
-/************************************************************************************************************************************************************
-
-VFS
-===
-
-The VFS object (virtual file system) is what's used to customize file access. This is useful in cases where stdio FILE* based APIs may not be entirely
-appropriate for a given situation.
-
-************************************************************************************************************************************************************/
-typedef void      ma_vfs;
-typedef ma_handle ma_vfs_file;
-
-#define MA_OPEN_MODE_READ   0x00000001
-#define MA_OPEN_MODE_WRITE  0x00000002
-
-typedef enum
-{
-    ma_seek_origin_start,
-    ma_seek_origin_current,
-    ma_seek_origin_end  /* Not used by decoders. */
-} ma_seek_origin;
-
-typedef struct
-{
-    ma_uint64 sizeInBytes;
-} ma_file_info;
-
-typedef struct
-{
-    ma_result (* onOpen) (ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-    ma_result (* onOpenW)(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-    ma_result (* onClose)(ma_vfs* pVFS, ma_vfs_file file);
-    ma_result (* onRead) (ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead);
-    ma_result (* onWrite)(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten);
-    ma_result (* onSeek) (ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin);
-    ma_result (* onTell) (ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor);
-    ma_result (* onInfo) (ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo);
-} ma_vfs_callbacks;
-
-MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file);
-MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead);
-MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten);
-MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin);
-MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor);
-MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo);
-MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks);
-
-typedef struct
-{
-    ma_vfs_callbacks cb;
-    ma_allocation_callbacks allocationCallbacks;    /* Only used for the wchar_t version of open() on non-Windows platforms. */
-} ma_default_vfs;
-
-MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks);
-
-
-
-
-#if !defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING)
-typedef enum
-{
-    ma_resource_format_wav
-} ma_resource_format;
-#endif
-
-/************************************************************************************************************************************************************
-
-Decoding
-========
-
-Decoders are independent of the main device API. Decoding APIs can be called freely inside the device's data callback, but they are not thread safe unless
-you do your own synchronization.
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DECODING
-typedef struct ma_decoder ma_decoder;
-
-typedef size_t    (* ma_decoder_read_proc)                    (ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead);     /* Returns the number of bytes read. */
-typedef ma_bool32 (* ma_decoder_seek_proc)                    (ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin);    /* Origin will never be ma_seek_origin_end. */
-typedef ma_uint64 (* ma_decoder_read_pcm_frames_proc)         (ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount);   /* Returns the number of frames read. Output data is in internal format. */
-typedef ma_result (* ma_decoder_seek_to_pcm_frame_proc)       (ma_decoder* pDecoder, ma_uint64 frameIndex);
-typedef ma_result (* ma_decoder_uninit_proc)                  (ma_decoder* pDecoder);
-typedef ma_uint64 (* ma_decoder_get_length_in_pcm_frames_proc)(ma_decoder* pDecoder);
-
-typedef struct
-{
-    ma_format format;      /* Set to 0 or ma_format_unknown to use the stream's internal format. */
-    ma_uint32 channels;    /* Set to 0 to use the stream's internal channels. */
-    ma_uint32 sampleRate;  /* Set to 0 to use the stream's internal sample rate. */
-    ma_channel channelMap[MA_MAX_CHANNELS];
-    ma_channel_mix_mode channelMixMode;
-    ma_dither_mode ditherMode;
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    ma_allocation_callbacks allocationCallbacks;
-} ma_decoder_config;
-
-struct ma_decoder
-{
-    ma_data_source_callbacks ds;
-    ma_decoder_read_proc onRead;
-    ma_decoder_seek_proc onSeek;
-    void* pUserData;
-    ma_uint64  readPointerInBytes;          /* In internal encoded data. */
-    ma_uint64  readPointerInPCMFrames;      /* In output sample rate. Used for keeping track of how many frames are available for decoding. */
-    ma_format  internalFormat;
-    ma_uint32  internalChannels;
-    ma_uint32  internalSampleRate;
-    ma_channel internalChannelMap[MA_MAX_CHANNELS];
-    ma_format  outputFormat;
-    ma_uint32  outputChannels;
-    ma_uint32  outputSampleRate;
-    ma_channel outputChannelMap[MA_MAX_CHANNELS];
-    ma_data_converter converter;   /* <-- Data conversion is achieved by running frames through this. */
-    ma_allocation_callbacks allocationCallbacks;
-    ma_decoder_read_pcm_frames_proc onReadPCMFrames;
-    ma_decoder_seek_to_pcm_frame_proc onSeekToPCMFrame;
-    ma_decoder_uninit_proc onUninit;
-    ma_decoder_get_length_in_pcm_frames_proc onGetLengthInPCMFrames;
-    void* pInternalDecoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
-    union
-    {
-        struct
-        {
-            ma_vfs* pVFS;
-            ma_vfs_file file;
-        } vfs;
-        struct
-        {
-            const ma_uint8* pData;
-            size_t dataSize;
-            size_t currentReadPos;
-        } memory;               /* Only used for decoders that were opened against a block of memory. */
-    } backend;
-};
-
-MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate);
-
-MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_wav(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_flac(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_mp3(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vorbis(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_raw(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_wav(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_flac(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_mp3(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_vorbis(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_raw(const void* pData, size_t dataSize, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_wav(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_flac(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_mp3(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_vorbis(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_wav_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_flac_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_mp3_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_vorbis_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_wav(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_flac(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_mp3(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_vorbis(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_wav_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_flac_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_mp3_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_vorbis_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder);
-
-/*
-Retrieves the current position of the read cursor in PCM frames.
-*/
-MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor);
-
-/*
-Retrieves the length of the decoder in PCM frames.
-
-Do not call this on streams of an undefined length, such as internet radio.
-
-If the length is unknown or an error occurs, 0 will be returned.
-
-This will always return 0 for Vorbis decoders. This is due to a limitation with stb_vorbis in push mode which is what miniaudio
-uses internally.
-
-For MP3's, this will decode the entire file. Do not call this in time critical scenarios.
-
-This function is not thread safe without your own synchronization.
-*/
-MA_API ma_uint64 ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder);
-
-/*
-Reads PCM frames from the given decoder.
-
-This is not thread safe without your own synchronization.
-*/
-MA_API ma_uint64 ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount);
-
-/*
-Seeks to a PCM frame based on it's absolute index.
-
-This is not thread safe without your own synchronization.
-*/
-MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex);
-
-/*
-Retrieves the number of frames that can be read before reaching the end.
-
-This calls `ma_decoder_get_length_in_pcm_frames()` so you need to be aware of the rules for that function, in
-particular ensuring you do not call it on streams of an undefined length, such as internet radio.
-
-If the total length of the decoder cannot be retrieved, such as with Vorbis decoders, `MA_NOT_IMPLEMENTED` will be
-returned.
-*/
-MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames);
-
-/*
-Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with ma_free(). On input,
-pConfig should be set to what you want. On output it will be set to what you got.
-*/
-MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-
-#endif  /* MA_NO_DECODING */
-
-
-/************************************************************************************************************************************************************
-
-Encoding
-========
-
-Encoders do not perform any format conversion for you. If your target format does not support the format, and error will be returned.
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_ENCODING
-typedef struct ma_encoder ma_encoder;
-
-typedef size_t    (* ma_encoder_write_proc)           (ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite);     /* Returns the number of bytes written. */
-typedef ma_bool32 (* ma_encoder_seek_proc)            (ma_encoder* pEncoder, int byteOffset, ma_seek_origin origin);
-typedef ma_result (* ma_encoder_init_proc)            (ma_encoder* pEncoder);
-typedef void      (* ma_encoder_uninit_proc)          (ma_encoder* pEncoder);
-typedef ma_uint64 (* ma_encoder_write_pcm_frames_proc)(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount);
-
-typedef struct
-{
-    ma_resource_format resourceFormat;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_allocation_callbacks allocationCallbacks;
-} ma_encoder_config;
-
-MA_API ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate);
-
-struct ma_encoder
-{
-    ma_encoder_config config;
-    ma_encoder_write_proc onWrite;
-    ma_encoder_seek_proc onSeek;
-    ma_encoder_init_proc onInit;
-    ma_encoder_uninit_proc onUninit;
-    ma_encoder_write_pcm_frames_proc onWritePCMFrames;
-    void* pUserData;
-    void* pInternalEncoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
-    void* pFile;    /* FILE*. Only used when initialized with ma_encoder_init_file(). */
-};
-
-MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API void ma_encoder_uninit(ma_encoder* pEncoder);
-MA_API ma_uint64 ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount);
-
-#endif /* MA_NO_ENCODING */
-
-
-/************************************************************************************************************************************************************
-
-Generation
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_GENERATION
-typedef enum
-{
-    ma_waveform_type_sine,
-    ma_waveform_type_square,
-    ma_waveform_type_triangle,
-    ma_waveform_type_sawtooth
-} ma_waveform_type;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_waveform_type type;
-    double amplitude;
-    double frequency;
-} ma_waveform_config;
-
-MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency);
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_waveform_config config;
-    double advance;
-    double time;
-} ma_waveform;
-
-MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform);
-MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount);
-MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex);
-MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude);
-MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency);
-MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type);
-MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate);
-
-typedef enum
-{
-    ma_noise_type_white,
-    ma_noise_type_pink,
-    ma_noise_type_brownian
-} ma_noise_type;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_noise_type type;
-    ma_int32 seed;
-    double amplitude;
-    ma_bool32 duplicateChannels;
-} ma_noise_config;
-
-MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude);
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_noise_config config;
-    ma_lcg lcg;
-    union
-    {
-        struct
-        {
-            double bin[MA_MAX_CHANNELS][16];
-            double accumulation[MA_MAX_CHANNELS];
-            ma_uint32 counter[MA_MAX_CHANNELS];
-        } pink;
-        struct
-        {
-            double accumulation[MA_MAX_CHANNELS];
-        } brownian;
-    } state;
-} ma_noise;
-
-MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, ma_noise* pNoise);
-MA_API ma_uint64 ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount);
-MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude);
-MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed);
-MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type);
-
-#endif  /* MA_NO_GENERATION */
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* miniaudio_h */
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-IMPLEMENTATION
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION)
-#ifndef miniaudio_c
-#define miniaudio_c
-
-#include <assert.h>
-#include <limits.h> /* For INT_MAX */
-#include <math.h>   /* sin(), etc. */
-
-#include <stdarg.h>
-#include <stdio.h>
-#if !defined(_MSC_VER) && !defined(__DMC__)
-    #include <strings.h>    /* For strcasecmp(). */
-    #include <wchar.h>      /* For wcslen(), wcsrtombs() */
-#endif
-
-#ifdef MA_WIN32
-#include <windows.h>
-#else
-#include <stdlib.h>     /* For malloc(), free(), wcstombs(). */
-#include <string.h>     /* For memset() */
-#include <sched.h>
-#include <sys/time.h>   /* select() (used for ma_sleep()). */
-#endif
-
-#include <sys/stat.h>   /* For fstat(), etc. */
-
-#ifdef MA_EMSCRIPTEN
-#include <emscripten/emscripten.h>
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#ifdef _WIN32
-#ifdef _WIN64
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#ifdef __GNUC__
-#ifdef __LP64__
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#include <stdint.h>
-#if INTPTR_MAX == INT64_MAX
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-
-/* Architecture Detection */
-#if defined(__x86_64__) || defined(_M_X64)
-#define MA_X64
-#elif defined(__i386) || defined(_M_IX86)
-#define MA_X86
-#elif defined(__arm__) || defined(_M_ARM)
-#define MA_ARM
-#endif
-
-/* Cannot currently support AVX-512 if AVX is disabled. */
-#if !defined(MA_NO_AVX512) && defined(MA_NO_AVX2)
-#define MA_NO_AVX512
-#endif
-
-/* Intrinsics Support */
-#if defined(MA_X64) || defined(MA_X86)
-    #if defined(_MSC_VER) && !defined(__clang__)
-        /* MSVC. */
-        #if _MSC_VER >= 1400 && !defined(MA_NO_SSE2)   /* 2005 */
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if _MSC_VER >= 1600 && !defined(MA_NO_AVX)*/    /* 2010 */
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if _MSC_VER >= 1700 && !defined(MA_NO_AVX2)   /* 2012 */
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if _MSC_VER >= 1910 && !defined(MA_NO_AVX512) /* 2017 */
-            #define MA_SUPPORT_AVX512
-        #endif
-    #else
-        /* Assume GNUC-style. */
-        #if defined(__SSE2__) && !defined(MA_NO_SSE2)
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if defined(__AVX__) && !defined(MA_NO_AVX)*/
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if defined(__AVX2__) && !defined(MA_NO_AVX2)
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if defined(__AVX512F__) && !defined(MA_NO_AVX512)
-            #define MA_SUPPORT_AVX512
-        #endif
-    #endif
-
-    /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
-    #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-        #if !defined(MA_SUPPORT_SSE2)   && !defined(MA_NO_SSE2)   && __has_include(<emmintrin.h>)
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if !defined(MA_SUPPORT_AVX)    && !defined(MA_NO_AVX)    && __has_include(<immintrin.h>)*/
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if !defined(MA_SUPPORT_AVX2)   && !defined(MA_NO_AVX2)   && __has_include(<immintrin.h>)
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if !defined(MA_SUPPORT_AVX512) && !defined(MA_NO_AVX512) && __has_include(<zmmintrin.h>)
-            #define MA_SUPPORT_AVX512
-        #endif
-    #endif
-
-    #if defined(MA_SUPPORT_AVX512)
-        #include <immintrin.h>  /* Not a mistake. Intentionally including <immintrin.h> instead of <zmmintrin.h> because otherwise the compiler will complain. */
-    #elif defined(MA_SUPPORT_AVX2) || defined(MA_SUPPORT_AVX)
-        #include <immintrin.h>
-    #elif defined(MA_SUPPORT_SSE2)
-        #include <emmintrin.h>
-    #endif
-#endif
-
-#if defined(MA_ARM)
-    #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-        #define MA_SUPPORT_NEON
-    #endif
-
-    /* Fall back to looking for the #include file. */
-    #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-        #if !defined(MA_SUPPORT_NEON) && !defined(MA_NO_NEON) && __has_include(<arm_neon.h>)
-            #define MA_SUPPORT_NEON
-        #endif
-    #endif
-
-    #if defined(MA_SUPPORT_NEON)
-        #include <arm_neon.h>
-    #endif
-#endif
-
-/* Begin globally disabled warnings. */
-#if defined(_MSC_VER)
-    #pragma warning(push)
-    #pragma warning(disable:4752)   /* found Intel(R) Advanced Vector Extensions; consider using /arch:AVX */
-#endif
-
-#if defined(MA_X64) || defined(MA_X86)
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static MA_INLINE void ma_cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define MA_NO_CPUID
-        #endif
-
-        #if _MSC_VER >= 1600 && (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219)
-            static MA_INLINE unsigned __int64 ma_xgetbv(int reg)
-            {
-                return _xgetbv(reg);
-            }
-        #else
-            #define MA_NO_XGETBV
-        #endif
-    #elif (defined(__GNUC__) || defined(__clang__)) && !defined(MA_ANDROID)
-        static MA_INLINE void ma_cpuid(int info[4], int fid)
-        {
-            /*
-            It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
-            specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
-            supporting different assembly dialects.
-
-            What's basically happening is that we're saving and restoring the ebx register manually.
-            */
-            #if defined(DRFLAC_X86) && defined(__PIC__)
-                __asm__ __volatile__ (
-                    "xchg{l} {%%}ebx, %k1;"
-                    "cpuid;"
-                    "xchg{l} {%%}ebx, %k1;"
-                    : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                );
-            #else
-                __asm__ __volatile__ (
-                    "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                );
-            #endif
-        }
-
-        static MA_INLINE ma_uint64 ma_xgetbv(int reg)
-        {
-            unsigned int hi;
-            unsigned int lo;
-
-            __asm__ __volatile__ (
-                "xgetbv" : "=a"(lo), "=d"(hi) : "c"(reg)
-            );
-
-            return ((ma_uint64)hi << 32) | (ma_uint64)lo;
-        }
-    #else
-        #define MA_NO_CPUID
-        #define MA_NO_XGETBV
-    #endif
-#else
-    #define MA_NO_CPUID
-    #define MA_NO_XGETBV
-#endif
-
-static MA_INLINE ma_bool32 ma_has_sse2(void)
-{
-#if defined(MA_SUPPORT_SSE2)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_SSE2)
-        #if defined(MA_X64)
-            return MA_TRUE;    /* 64-bit targets always support SSE2. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
-        #else
-            #if defined(MA_NO_CPUID)
-                return MA_FALSE;
-            #else
-                int info[4];
-                ma_cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* SSE2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-#if 0
-static MA_INLINE ma_bool32 ma_has_avx()
-{
-#if defined(MA_SUPPORT_AVX)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX)
-        #if defined(_AVX_) || defined(__AVX__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX code we can assume support. */
-        #else
-            /* AVX requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info[4];
-                ma_cpuid(info, 1);
-                if (((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0x06) == 0x06) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-#endif
-
-static MA_INLINE ma_bool32 ma_has_avx2(void)
-{
-#if defined(MA_SUPPORT_AVX2)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX2)
-        #if defined(_AVX2_) || defined(__AVX2__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX2 code we can assume support. */
-        #else
-            /* AVX2 requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info1[4];
-                int info7[4];
-                ma_cpuid(info1, 1);
-                ma_cpuid(info7, 7);
-                if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 5)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0x06) == 0x06) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_has_avx512f(void)
-{
-#if defined(MA_SUPPORT_AVX512)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX512)
-        #if defined(__AVX512F__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX-512F code we can assume support. */
-        #else
-            /* AVX-512 requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info1[4];
-                int info7[4];
-                ma_cpuid(info1, 1);
-                ma_cpuid(info7, 7);
-                if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 16)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0xE6) == 0xE6) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX-512F is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_has_neon(void)
-{
-#if defined(MA_SUPPORT_NEON)
-    #if defined(MA_ARM) && !defined(MA_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return MA_TRUE;    /* If the compiler is allowed to freely generate NEON code we can assume support. */
-        #else
-            /* TODO: Runtime check. */
-            return MA_FALSE;
-        #endif
-    #else
-        return MA_FALSE;       /* NEON is only supported on ARM architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-#define MA_SIMD_NONE    0
-#define MA_SIMD_SSE2    1
-#define MA_SIMD_AVX2    2
-#define MA_SIMD_NEON    3
-
-#ifndef MA_PREFERRED_SIMD
-    #  if defined(MA_SUPPORT_SSE2) && defined(MA_PREFER_SSE2)
-        #define MA_PREFERRED_SIMD MA_SIMD_SSE2
-    #elif defined(MA_SUPPORT_AVX2) && defined(MA_PREFER_AVX2)
-        #define MA_PREFERRED_SIMD MA_SIMD_AVX2
-    #elif defined(MA_SUPPORT_NEON) && defined(MA_PREFER_NEON)
-        #define MA_PREFERRED_SIMD MA_SIMD_NEON
-    #else
-        #define MA_PREFERRED_SIMD MA_SIMD_NONE
-    #endif
-#endif
-
-#if defined(__has_builtin)
-    #define MA_COMPILER_HAS_BUILTIN(x) __has_builtin(x)
-#else
-    #define MA_COMPILER_HAS_BUILTIN(x) 0
-#endif
-
-#ifndef MA_ASSUME
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_assume)
-        #define MA_ASSUME(x) __builtin_assume(x)
-    #elif MA_COMPILER_HAS_BUILTIN(__builtin_unreachable)
-        #define MA_ASSUME(x) do { if (!(x)) __builtin_unreachable(); } while (0)
-    #elif defined(_MSC_VER)
-        #define MA_ASSUME(x) __assume(x)
-    #else
-        #define MA_ASSUME(x) while(0)
-    #endif
-#endif
-
-#ifndef MA_RESTRICT
-    #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
-        #define MA_RESTRICT __restrict
-    #else
-        #define MA_RESTRICT
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define MA_HAS_BYTESWAP16_INTRINSIC
-    #define MA_HAS_BYTESWAP32_INTRINSIC
-    #define MA_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap16)
-        #define MA_HAS_BYTESWAP16_INTRINSIC
-    #endif
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap32)
-        #define MA_HAS_BYTESWAP32_INTRINSIC
-    #endif
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap64)
-        #define MA_HAS_BYTESWAP64_INTRINSIC
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define MA_HAS_BYTESWAP32_INTRINSIC
-        #define MA_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define MA_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-
-
-static MA_INLINE ma_bool32 ma_is_little_endian(void)
-{
-#if defined(MA_X86) || defined(MA_X64)
-    return MA_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_is_big_endian(void)
-{
-    return !ma_is_little_endian();
-}
-
-
-static MA_INLINE ma_uint32 ma_swap_endian_uint32(ma_uint32 n)
-{
-#ifdef MA_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(MA_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            ma_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(MA_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-
-#if !defined(MA_EMSCRIPTEN)
-#ifdef MA_WIN32
-static void ma_sleep__win32(ma_uint32 milliseconds)
-{
-    Sleep((DWORD)milliseconds);
-}
-#endif
-#ifdef MA_POSIX
-static void ma_sleep__posix(ma_uint32 milliseconds)
-{
-#ifdef MA_EMSCRIPTEN
-    (void)milliseconds;
-    MA_ASSERT(MA_FALSE);  /* The Emscripten build should never sleep. */
-#else
-    #if _POSIX_C_SOURCE >= 199309L
-        struct timespec ts;
-        ts.tv_sec  = milliseconds / 1000;
-        ts.tv_nsec = milliseconds % 1000 * 1000000;
-        nanosleep(&ts, NULL);
-    #else
-        struct timeval tv;
-        tv.tv_sec  = milliseconds / 1000;
-        tv.tv_usec = milliseconds % 1000 * 1000;
-        select(0, NULL, NULL, NULL, &tv);
-    #endif
-#endif
-}
-#endif
-
-static void ma_sleep(ma_uint32 milliseconds)
-{
-#ifdef MA_WIN32
-    ma_sleep__win32(milliseconds);
-#endif
-#ifdef MA_POSIX
-    ma_sleep__posix(milliseconds);
-#endif
-}
-#endif
-
-static MA_INLINE void ma_yield()
-{
-#if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
-    /* x86/x64 */
-    #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            _mm_pause();
-        #else
-            #if defined(__DMC__)
-                /* Digital Mars does not recognize the PAUSE opcode. Fall back to NOP. */
-                __asm nop;  
-            #else
-                __asm pause;
-            #endif
-        #endif
-    #else
-        __asm__ __volatile__ ("pause");
-    #endif
-#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || (defined(_M_ARM) && _M_ARM >= 7) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
-    /* ARM */
-    #if defined(_MSC_VER)
-        /* Apparently there is a __yield() intrinsic that's compatible with ARM, but I cannot find documentation for it nor can I find where it's declared. */
-        __yield();
-    #else
-        __asm__ __volatile__ ("yield"); /* ARMv6K/ARMv6T2 and above. */
-    #endif
-#else
-    /* Unknown or unsupported architecture. No-op. */
-#endif
-}
-
-
-
-#ifndef MA_COINIT_VALUE
-#define MA_COINIT_VALUE    0   /* 0 = COINIT_MULTITHREADED */
-#endif
-
-
-#ifndef MA_FLT_MAX
-    #ifdef FLT_MAX
-        #define MA_FLT_MAX FLT_MAX
-    #else
-        #define MA_FLT_MAX 3.402823466e+38F
-    #endif
-#endif
-
-
-#ifndef MA_PI
-#define MA_PI      3.14159265358979323846264f
-#endif
-#ifndef MA_PI_D
-#define MA_PI_D    3.14159265358979323846264
-#endif
-#ifndef MA_TAU
-#define MA_TAU     6.28318530717958647693f
-#endif
-#ifndef MA_TAU_D
-#define MA_TAU_D   6.28318530717958647693
-#endif
-
-
-/* The default format when ma_format_unknown (0) is requested when initializing a device. */
-#ifndef MA_DEFAULT_FORMAT
-#define MA_DEFAULT_FORMAT                                   ma_format_f32
-#endif
-
-/* The default channel count to use when 0 is used when initializing a device. */
-#ifndef MA_DEFAULT_CHANNELS
-#define MA_DEFAULT_CHANNELS                                 2
-#endif
-
-/* The default sample rate to use when 0 is used when initializing a device. */
-#ifndef MA_DEFAULT_SAMPLE_RATE
-#define MA_DEFAULT_SAMPLE_RATE                              48000
-#endif
-
-/* Default periods when none is specified in ma_device_init(). More periods means more work on the CPU. */
-#ifndef MA_DEFAULT_PERIODS
-#define MA_DEFAULT_PERIODS                                  3
-#endif
-
-/* The default period size in milliseconds for low latency mode. */
-#ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY
-#define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY  10
-#endif
-
-/* The default buffer size in milliseconds for conservative mode. */
-#ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE
-#define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE 100
-#endif
-
-/* The default LPF filter order for linear resampling. Note that this is clamped to MA_MAX_FILTER_ORDER. */
-#ifndef MA_DEFAULT_RESAMPLER_LPF_ORDER
-    #if MA_MAX_FILTER_ORDER >= 4
-        #define MA_DEFAULT_RESAMPLER_LPF_ORDER  4
-    #else
-        #define MA_DEFAULT_RESAMPLER_LPF_ORDER  MA_MAX_FILTER_ORDER
-    #endif
-#endif
-
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wunused-variable"
-#endif
-
-/* Standard sample rates, in order of priority. */
-static ma_uint32 g_maStandardSampleRatePriorities[] = {
-    (ma_uint32)ma_standard_sample_rate_48000,
-    (ma_uint32)ma_standard_sample_rate_44100,
-
-    (ma_uint32)ma_standard_sample_rate_32000,
-    (ma_uint32)ma_standard_sample_rate_24000,
-    (ma_uint32)ma_standard_sample_rate_22050,
-
-    (ma_uint32)ma_standard_sample_rate_88200,
-    (ma_uint32)ma_standard_sample_rate_96000,
-    (ma_uint32)ma_standard_sample_rate_176400,
-    (ma_uint32)ma_standard_sample_rate_192000,
-
-    (ma_uint32)ma_standard_sample_rate_16000,
-    (ma_uint32)ma_standard_sample_rate_11025,
-    (ma_uint32)ma_standard_sample_rate_8000,
-
-    (ma_uint32)ma_standard_sample_rate_352800,
-    (ma_uint32)ma_standard_sample_rate_384000
-};
-
-static MA_INLINE ma_bool32 ma_is_standard_sample_rate(ma_uint32 sampleRate)
-{
-    ma_uint32 iSampleRate;
-
-    for (iSampleRate = 0; iSampleRate < sizeof(g_maStandardSampleRatePriorities) / sizeof(g_maStandardSampleRatePriorities[0]); iSampleRate += 1) {
-        if (g_maStandardSampleRatePriorities[iSampleRate] == sampleRate) {
-            return MA_TRUE;
-        }
-    }
-
-    /* Getting here means the sample rate is not supported. */
-    return MA_FALSE;
-}
-
-
-static ma_format g_maFormatPriorities[] = {
-    ma_format_s16,         /* Most common */
-    ma_format_f32,
-
-    /*ma_format_s24_32,*/    /* Clean alignment */
-    ma_format_s32,
-
-    ma_format_s24,         /* Unclean alignment */
-
-    ma_format_u8           /* Low quality */
-};
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-
-
-MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = MA_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = MA_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = MA_VERSION_REVISION;
-    }
-}
-
-MA_API const char* ma_version_string(void)
-{
-    return MA_VERSION_STRING;
-}
-
-
-/******************************************************************************
-
-Standard Library Stuff
-
-******************************************************************************/
-#ifndef MA_MALLOC
-#ifdef MA_WIN32
-#define MA_MALLOC(sz) HeapAlloc(GetProcessHeap(), 0, (sz))
-#else
-#define MA_MALLOC(sz) malloc((sz))
-#endif
-#endif
-
-#ifndef MA_REALLOC
-#ifdef MA_WIN32
-#define MA_REALLOC(p, sz) (((sz) > 0) ? ((p) ? HeapReAlloc(GetProcessHeap(), 0, (p), (sz)) : HeapAlloc(GetProcessHeap(), 0, (sz))) : ((VOID*)(size_t)(HeapFree(GetProcessHeap(), 0, (p)) & 0)))
-#else
-#define MA_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#endif
-
-#ifndef MA_FREE
-#ifdef MA_WIN32
-#define MA_FREE(p) HeapFree(GetProcessHeap(), 0, (p))
-#else
-#define MA_FREE(p) free((p))
-#endif
-#endif
-
-#ifndef MA_ZERO_MEMORY
-#ifdef MA_WIN32
-#define MA_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz))
-#else
-#define MA_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#endif
-
-#ifndef MA_COPY_MEMORY
-#ifdef MA_WIN32
-#define MA_COPY_MEMORY(dst, src, sz) CopyMemory((dst), (src), (sz))
-#else
-#define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#endif
-
-#ifndef MA_ASSERT
-#ifdef MA_WIN32
-#define MA_ASSERT(condition) assert(condition)
-#else
-#define MA_ASSERT(condition) assert(condition)
-#endif
-#endif
-
-#define MA_ZERO_OBJECT(p) MA_ZERO_MEMORY((p), sizeof(*(p)))
-
-#define ma_countof(x)               (sizeof(x) / sizeof(x[0]))
-#define ma_max(x, y)                (((x) > (y)) ? (x) : (y))
-#define ma_min(x, y)                (((x) < (y)) ? (x) : (y))
-#define ma_abs(x)                   (((x) > 0) ? (x) : -(x))
-#define ma_clamp(x, lo, hi)         (ma_max(lo, ma_min(x, hi)))
-#define ma_offset_ptr(p, offset)    (((ma_uint8*)(p)) + (offset))
-
-#define ma_buffer_frame_capacity(buffer, channels, format) (sizeof(buffer) / ma_get_bytes_per_sample(format) / (channels))
-
-static MA_INLINE double ma_sin(double x)
-{
-    /* TODO: Implement custom sin(x). */
-    return sin(x);
-}
-
-static MA_INLINE double ma_exp(double x)
-{
-    /* TODO: Implement custom exp(x). */
-    return exp(x);
-}
-
-static MA_INLINE double ma_log(double x)
-{
-    /* TODO: Implement custom log(x). */
-    return log(x);
-}
-
-static MA_INLINE double ma_pow(double x, double y)
-{
-    /* TODO: Implement custom pow(x, y). */
-    return pow(x, y);
-}
-
-static MA_INLINE double ma_sqrt(double x)
-{
-    /* TODO: Implement custom sqrt(x). */
-    return sqrt(x);
-}
-
-
-static MA_INLINE double ma_cos(double x)
-{
-    return ma_sin((MA_PI_D*0.5) - x);
-}
-
-static MA_INLINE double ma_log10(double x)
-{
-    return ma_log(x) * 0.43429448190325182765;
-}
-
-static MA_INLINE float ma_powf(float x, float y)
-{
-    return (float)ma_pow((double)x, (double)y);
-}
-
-static MA_INLINE float ma_log10f(float x)
-{
-    return (float)ma_log10((double)x);
-}
-
-
-static MA_INLINE double ma_degrees_to_radians(double degrees)
-{
-    return degrees * 0.01745329252;
-}
-
-static MA_INLINE double ma_radians_to_degrees(double radians)
-{
-    return radians * 57.295779512896;
-}
-
-static MA_INLINE float ma_degrees_to_radians_f(float degrees)
-{
-    return degrees * 0.01745329252f;
-}
-
-static MA_INLINE float ma_radians_to_degrees_f(float radians)
-{
-    return radians * 57.295779512896f;
-}
-
-
-/*
-Return Values:
-  0:  Success
-  22: EINVAL
-  34: ERANGE
-
-Not using symbolic constants for errors because I want to avoid #including errno.h
-*/
-MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
-{
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    for (i = 0; i < dstSizeInBytes && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (i < dstSizeInBytes) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-MA_API int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src)
-{
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstCap == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    for (i = 0; i < dstCap && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (i < dstCap) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-
-MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
-{
-    size_t maxcount;
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    maxcount = count;
-    if (count == ((size_t)-1) || count >= dstSizeInBytes) {        /* -1 = _TRUNCATE */
-        maxcount = dstSizeInBytes - 1;
-    }
-
-    for (i = 0; i < maxcount && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (src[i] == '\0' || i == count || count == ((size_t)-1)) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-MA_API int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src)
-{
-    char* dstorig;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    dstorig = dst;
-
-    while (dstSizeInBytes > 0 && dst[0] != '\0') {
-        dst += 1;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        return 22;  /* Unterminated. */
-    }
-
-
-    while (dstSizeInBytes > 0 && src[0] != '\0') {
-        *dst++ = *src++;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes > 0) {
-        dst[0] = '\0';
-    } else {
-        dstorig[0] = '\0';
-        return 34;
-    }
-
-    return 0;
-}
-
-MA_API int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
-{
-    char* dstorig;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        return 22;
-    }
-
-    dstorig = dst;
-
-    while (dstSizeInBytes > 0 && dst[0] != '\0') {
-        dst += 1;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        return 22;  /* Unterminated. */
-    }
-
-
-    if (count == ((size_t)-1)) {        /* _TRUNCATE */
-        count = dstSizeInBytes - 1;
-    }
-
-    while (dstSizeInBytes > 0 && src[0] != '\0' && count > 0) {
-        *dst++ = *src++;
-        dstSizeInBytes -= 1;
-        count -= 1;
-    }
-
-    if (dstSizeInBytes > 0) {
-        dst[0] = '\0';
-    } else {
-        dstorig[0] = '\0';
-        return 34;
-    }
-
-    return 0;
-}
-
-MA_API int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix)
-{
-    int sign;
-    unsigned int valueU;
-    char* dstEnd;
-
-    if (dst == NULL || dstSizeInBytes == 0) {
-        return 22;
-    }
-    if (radix < 2 || radix > 36) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    sign = (value < 0 && radix == 10) ? -1 : 1;     /* The negative sign is only used when the base is 10. */
-
-    if (value < 0) {
-        valueU = -value;
-    } else {
-        valueU = value;
-    }
-
-    dstEnd = dst;
-    do
-    {
-        int remainder = valueU % radix;
-        if (remainder > 9) {
-            *dstEnd = (char)((remainder - 10) + 'a');
-        } else {
-            *dstEnd = (char)(remainder + '0');
-        }
-
-        dstEnd += 1;
-        dstSizeInBytes -= 1;
-        valueU /= radix;
-    } while (dstSizeInBytes > 0 && valueU > 0);
-
-    if (dstSizeInBytes == 0) {
-        dst[0] = '\0';
-        return 22;  /* Ran out of room in the output buffer. */
-    }
-
-    if (sign < 0) {
-        *dstEnd++ = '-';
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        dst[0] = '\0';
-        return 22;  /* Ran out of room in the output buffer. */
-    }
-
-    *dstEnd = '\0';
-
-
-    /* At this point the string will be reversed. */
-    dstEnd -= 1;
-    while (dst < dstEnd) {
-        char temp = *dst;
-        *dst = *dstEnd;
-        *dstEnd = temp;
-
-        dst += 1;
-        dstEnd -= 1;
-    }
-
-    return 0;
-}
-
-MA_API int ma_strcmp(const char* str1, const char* str2)
-{
-    if (str1 == str2) return  0;
-
-    /* These checks differ from the standard implementation. It's not important, but I prefer it just for sanity. */
-    if (str1 == NULL) return -1;
-    if (str2 == NULL) return  1;
-
-    for (;;) {
-        if (str1[0] == '\0') {
-            break;
-        }
-        if (str1[0] != str2[0]) {
-            break;
-        }
-
-        str1 += 1;
-        str2 += 1;
-    }
-
-    return ((unsigned char*)str1)[0] - ((unsigned char*)str2)[0];
-}
-
-MA_API int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char* srcB)
-{
-    int result;
-
-    result = ma_strncpy_s(dst, dstSize, srcA, (size_t)-1);
-    if (result != 0) {
-        return result;
-    }
-
-    result = ma_strncat_s(dst, dstSize, srcB, (size_t)-1);
-    if (result != 0) {
-        return result;
-    }
-
-    return result;
-}
-
-MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t sz = strlen(src)+1;
-    char* dst = (char*)ma_malloc(sz, pAllocationCallbacks);
-    if (dst == NULL) {
-        return NULL;
-    }
-
-    ma_strcpy_s(dst, sz, src);
-
-    return dst;
-}
-
-MA_API wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t sz = wcslen(src)+1;
-    wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks);
-    if (dst == NULL) {
-        return NULL;
-    }
-
-    ma_wcscpy_s(dst, sz, src);
-
-    return dst;
-}
-
-
-#include <errno.h>
-static ma_result ma_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return MA_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return MA_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return MA_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return MA_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return MA_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return MA_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return MA_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return MA_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return MA_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return MA_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return MA_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return MA_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return MA_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return MA_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return MA_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return MA_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return MA_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return MA_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return MA_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return MA_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return MA_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return MA_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return MA_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return MA_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return MA_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return MA_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return MA_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return MA_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return MA_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return MA_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return MA_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return MA_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return MA_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return MA_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return MA_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return MA_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return MA_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return MA_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return MA_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return MA_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return MA_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return MA_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return MA_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return MA_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return MA_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return MA_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return MA_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return MA_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return MA_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return MA_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return MA_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return MA_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return MA_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return MA_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return MA_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return MA_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return MA_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return MA_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return MA_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return MA_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return MA_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return MA_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return MA_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return MA_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return MA_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return MA_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return MA_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return MA_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return MA_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return MA_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return MA_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return MA_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return MA_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return MA_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return MA_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return MA_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return MA_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return MA_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return MA_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return MA_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return MA_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return MA_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return MA_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return MA_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return MA_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return MA_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return MA_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return MA_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return MA_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return MA_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return MA_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return MA_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return MA_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return MA_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return MA_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return MA_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return MA_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return MA_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return MA_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return MA_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return MA_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return MA_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return MA_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return MA_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return MA_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return MA_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return MA_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return MA_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return MA_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return MA_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return MA_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return MA_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return MA_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return MA_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return MA_ERROR;
-    #endif
-        default: return MA_ERROR;
-    }
-}
-
-MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return ma_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        ma_result result = ma_result_from_errno(errno);
-        if (result == MA_SUCCESS) {
-            result = MA_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define MA_HAS_WFOPEN
-    #endif
-#endif
-
-MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return ma_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return ma_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        MA_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return ma_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)ma_malloc(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        MA_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        ma_free(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return MA_ERROR;
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-
-static MA_INLINE void ma_copy_memory_64(void* dst, const void* src, ma_uint64 sizeInBytes)
-{
-#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX
-    MA_COPY_MEMORY(dst, src, (size_t)sizeInBytes);
-#else
-    while (sizeInBytes > 0) {
-        ma_uint64 bytesToCopyNow = sizeInBytes;
-        if (bytesToCopyNow > MA_SIZE_MAX) {
-            bytesToCopyNow = MA_SIZE_MAX;
-        }
-
-        MA_COPY_MEMORY(dst, src, (size_t)bytesToCopyNow);  /* Safe cast to size_t. */
-
-        sizeInBytes -= bytesToCopyNow;
-        dst = (      void*)((      ma_uint8*)dst + bytesToCopyNow);
-        src = (const void*)((const ma_uint8*)src + bytesToCopyNow);
-    }
-#endif
-}
-
-static MA_INLINE void ma_zero_memory_64(void* dst, ma_uint64 sizeInBytes)
-{
-#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX
-    MA_ZERO_MEMORY(dst, (size_t)sizeInBytes);
-#else
-    while (sizeInBytes > 0) {
-        ma_uint64 bytesToZeroNow = sizeInBytes;
-        if (bytesToZeroNow > MA_SIZE_MAX) {
-            bytesToZeroNow = MA_SIZE_MAX;
-        }
-
-        MA_ZERO_MEMORY(dst, (size_t)bytesToZeroNow);  /* Safe cast to size_t. */
-
-        sizeInBytes -= bytesToZeroNow;
-        dst = (void*)((ma_uint8*)dst + bytesToZeroNow);
-    }
-#endif
-}
-
-
-/* Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 */
-static MA_INLINE unsigned int ma_next_power_of_2(unsigned int x)
-{
-    x--;
-    x |= x >> 1;
-    x |= x >> 2;
-    x |= x >> 4;
-    x |= x >> 8;
-    x |= x >> 16;
-    x++;
-
-    return x;
-}
-
-static MA_INLINE unsigned int ma_prev_power_of_2(unsigned int x)
-{
-    return ma_next_power_of_2(x) >> 1;
-}
-
-static MA_INLINE unsigned int ma_round_to_power_of_2(unsigned int x)
-{
-    unsigned int prev = ma_prev_power_of_2(x);
-    unsigned int next = ma_next_power_of_2(x);
-    if ((next - x) > (x - prev)) {
-        return prev;
-    } else {
-        return next;
-    }
-}
-
-static MA_INLINE unsigned int ma_count_set_bits(unsigned int x)
-{
-    unsigned int count = 0;
-    while (x != 0) {
-        if (x & 1) {
-            count += 1;
-        }
-
-        x = x >> 1;
-    }
-
-    return count;
-}
-
-
-
-/* Clamps an f32 sample to -1..1 */
-static MA_INLINE float ma_clip_f32(float x)
-{
-    if (x < -1) return -1;
-    if (x > +1) return +1;
-    return x;
-}
-
-static MA_INLINE float ma_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static MA_INLINE float ma_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-    /*return x + (y - x)*a;*/
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE __m128 ma_mix_f32_fast__sse2(__m128 x, __m128 y, __m128 a)
-{
-    return _mm_add_ps(x, _mm_mul_ps(_mm_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE __m256 ma_mix_f32_fast__avx2(__m256 x, __m256 y, __m256 a)
-{
-    return _mm256_add_ps(x, _mm256_mul_ps(_mm256_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_AVX512)
-static MA_INLINE __m512 ma_mix_f32_fast__avx512(__m512 x, __m512 y, __m512 a)
-{
-    return _mm512_add_ps(x, _mm512_mul_ps(_mm512_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE float32x4_t ma_mix_f32_fast__neon(float32x4_t x, float32x4_t y, float32x4_t a)
-{
-    return vaddq_f32(x, vmulq_f32(vsubq_f32(y, x), a));
-}
-#endif
-
-
-static MA_INLINE double ma_mix_f64(double x, double y, double a)
-{
-    return x*(1-a) + y*a;
-}
-static MA_INLINE double ma_mix_f64_fast(double x, double y, double a)
-{
-    return x + (y - x)*a;
-}
-
-static MA_INLINE float ma_scale_to_range_f32(float x, float lo, float hi)
-{
-    return lo + x*(hi-lo);
-}
-
-
-/*
-Greatest common factor using Euclid's algorithm iteratively.
-*/
-static MA_INLINE ma_uint32 ma_gcf_u32(ma_uint32 a, ma_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            ma_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-
-    return a;
-}
-
-
-/*
-Random Number Generation
-
-miniaudio uses the LCG random number generation algorithm. This is good enough for audio.
-
-Note that miniaudio's global LCG implementation uses global state which is _not_ thread-local. When this is called across
-multiple threads, results will be unpredictable. However, it won't crash and results will still be random enough for
-miniaudio's purposes.
-*/
-#ifndef MA_DEFAULT_LCG_SEED
-#define MA_DEFAULT_LCG_SEED 4321
-#endif
-
-#define MA_LCG_M   2147483647
-#define MA_LCG_A   48271
-#define MA_LCG_C   0
-
-static ma_lcg g_maLCG = {MA_DEFAULT_LCG_SEED}; /* Non-zero initial seed. Use ma_seed() to use an explicit seed. */
-
-static MA_INLINE void ma_lcg_seed(ma_lcg* pLCG, ma_int32 seed)
-{
-    MA_ASSERT(pLCG != NULL);
-    pLCG->state = seed;
-}
-
-static MA_INLINE ma_int32 ma_lcg_rand_s32(ma_lcg* pLCG)
-{
-    pLCG->state = (MA_LCG_A * pLCG->state + MA_LCG_C) % MA_LCG_M;
-    return pLCG->state;
-}
-
-static MA_INLINE ma_uint32 ma_lcg_rand_u32(ma_lcg* pLCG)
-{
-    return (ma_uint32)ma_lcg_rand_s32(pLCG);
-}
-
-static MA_INLINE ma_int16 ma_lcg_rand_s16(ma_lcg* pLCG)
-{
-    return (ma_int16)(ma_lcg_rand_s32(pLCG) & 0xFFFF);
-}
-
-static MA_INLINE double ma_lcg_rand_f64(ma_lcg* pLCG)
-{
-    return ma_lcg_rand_s32(pLCG) / (double)0x7FFFFFFF;
-}
-
-static MA_INLINE float ma_lcg_rand_f32(ma_lcg* pLCG)
-{
-    return (float)ma_lcg_rand_f64(pLCG);
-}
-
-static MA_INLINE float ma_lcg_rand_range_f32(ma_lcg* pLCG, float lo, float hi)
-{
-    return ma_scale_to_range_f32(ma_lcg_rand_f32(pLCG), lo, hi);
-}
-
-static MA_INLINE ma_int32 ma_lcg_rand_range_s32(ma_lcg* pLCG, ma_int32 lo, ma_int32 hi)
-{
-    if (lo == hi) {
-        return lo;
-    }
-
-    return lo + ma_lcg_rand_u32(pLCG) / (0xFFFFFFFF / (hi - lo + 1) + 1);
-}
-
-
-
-static MA_INLINE void ma_seed(ma_int32 seed)
-{
-    ma_lcg_seed(&g_maLCG, seed);
-}
-
-static MA_INLINE ma_int32 ma_rand_s32(void)
-{
-    return ma_lcg_rand_s32(&g_maLCG);
-}
-
-static MA_INLINE ma_uint32 ma_rand_u32(void)
-{
-    return ma_lcg_rand_u32(&g_maLCG);
-}
-
-static MA_INLINE double ma_rand_f64(void)
-{
-    return ma_lcg_rand_f64(&g_maLCG);
-}
-
-static MA_INLINE float ma_rand_f32(void)
-{
-    return ma_lcg_rand_f32(&g_maLCG);
-}
-
-static MA_INLINE float ma_rand_range_f32(float lo, float hi)
-{
-    return ma_lcg_rand_range_f32(&g_maLCG, lo, hi);
-}
-
-static MA_INLINE ma_int32 ma_rand_range_s32(ma_int32 lo, ma_int32 hi)
-{
-    return ma_lcg_rand_range_s32(&g_maLCG, lo, hi);
-}
-
-
-static MA_INLINE float ma_dither_f32_rectangle(float ditherMin, float ditherMax)
-{
-    return ma_rand_range_f32(ditherMin, ditherMax);
-}
-
-static MA_INLINE float ma_dither_f32_triangle(float ditherMin, float ditherMax)
-{
-    float a = ma_rand_range_f32(ditherMin, 0);
-    float b = ma_rand_range_f32(0, ditherMax);
-    return a + b;
-}
-
-static MA_INLINE float ma_dither_f32(ma_dither_mode ditherMode, float ditherMin, float ditherMax)
-{
-    if (ditherMode == ma_dither_mode_rectangle) {
-        return ma_dither_f32_rectangle(ditherMin, ditherMax);
-    }
-    if (ditherMode == ma_dither_mode_triangle) {
-        return ma_dither_f32_triangle(ditherMin, ditherMax);
-    }
-
-    return 0;
-}
-
-static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 ditherMin, ma_int32 ditherMax)
-{
-    if (ditherMode == ma_dither_mode_rectangle) {
-        ma_int32 a = ma_rand_range_s32(ditherMin, ditherMax);
-        return a;
-    }
-    if (ditherMode == ma_dither_mode_triangle) {
-        ma_int32 a = ma_rand_range_s32(ditherMin, 0);
-        ma_int32 b = ma_rand_range_s32(0, ditherMax);
-        return a + b;
-    }
-
-    return 0;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Atomics
-
-**************************************************************************************************************************************************************/
-/* c89atomic.h begin */
-#ifndef c89atomic_h
-#define c89atomic_h
-#if defined(__cplusplus)
-extern "C" {
-#endif
-typedef   signed char           c89atomic_int8;
-typedef unsigned char           c89atomic_uint8;
-typedef   signed short          c89atomic_int16;
-typedef unsigned short          c89atomic_uint16;
-typedef   signed int            c89atomic_int32;
-typedef unsigned int            c89atomic_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    c89atomic_int64;
-    typedef unsigned __int64    c89atomic_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  c89atomic_int64;
-    typedef unsigned long long  c89atomic_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-typedef int                     c89atomic_memory_order;
-typedef unsigned char           c89atomic_bool;
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#ifdef _WIN32
-#ifdef _WIN64
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#endif
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#ifdef __GNUC__
-#ifdef __LP64__
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#endif
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#include <stdint.h>
-#if INTPTR_MAX == INT64_MAX
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#if defined(__x86_64__) || defined(_M_X64)
-#define C89ATOMIC_X64
-#elif defined(__i386) || defined(_M_IX86)
-#define C89ATOMIC_X86
-#elif defined(__arm__) || defined(_M_ARM)
-#define C89ATOMIC_ARM
-#endif
-#if defined(_MSC_VER)
-    #define C89ATOMIC_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define C89ATOMIC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define C89ATOMIC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__) || defined(__DMC__)
-    #define C89ATOMIC_INLINE __inline
-#else
-    #define C89ATOMIC_INLINE
-#endif
-#define C89ATOMIC_HAS_8
-#define C89ATOMIC_HAS_16
-#define C89ATOMIC_HAS_32
-#define C89ATOMIC_HAS_64
-#if (defined(_MSC_VER) ) || defined(__WATCOMC__) || defined(__DMC__)
-    #define c89atomic_memory_order_relaxed  0
-    #define c89atomic_memory_order_consume  1
-    #define c89atomic_memory_order_acquire  2
-    #define c89atomic_memory_order_release  3
-    #define c89atomic_memory_order_acq_rel  4
-    #define c89atomic_memory_order_seq_cst  5
-    #if _MSC_VER < 1600 && defined(C89ATOMIC_32BIT)
-        #define C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY
-    #endif
-    #if _MSC_VER < 1600
-        #undef C89ATOMIC_HAS_8
-        #undef C89ATOMIC_HAS_16
-    #endif
-    #if !defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #include <intrin.h>
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
-            {
-                c89atomic_uint8 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov al,  expected
-                    mov dl,  desired
-                    lock cmpxchg [ecx], dl
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
-            {
-                c89atomic_uint16 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  expected
-                    mov dx,  desired
-                    lock cmpxchg [ecx], dx
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
-            {
-                c89atomic_uint32 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov eax, expected
-                    mov edx, desired
-                    lock cmpxchg [ecx], edx
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
-            {
-                c89atomic_uint32 resultEAX = 0;
-                c89atomic_uint32 resultEDX = 0;
-                __asm {
-                    mov esi, dst
-                    mov eax, dword ptr expected
-                    mov edx, dword ptr expected + 4
-                    mov ebx, dword ptr desired
-                    mov ecx, dword ptr desired + 4
-                    lock cmpxchg8b qword ptr [esi]
-                    mov resultEAX, eax
-                    mov resultEDX, edx
-                }
-                return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            #define c89atomic_compare_and_swap_8( dst, expected, desired) (c89atomic_uint8 )_InterlockedCompareExchange8((volatile char*)dst, (char)desired, (char)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            #define c89atomic_compare_and_swap_16(dst, expected, desired) (c89atomic_uint16)_InterlockedCompareExchange16((volatile short*)dst, (short)desired, (short)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            #define c89atomic_compare_and_swap_32(dst, expected, desired) (c89atomic_uint32)_InterlockedCompareExchange((volatile long*)dst, (long)desired, (long)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_64)
-            #define c89atomic_compare_and_swap_64(dst, expected, desired) (c89atomic_uint64)_InterlockedCompareExchange64((volatile long long*)dst, (long long)desired, (long long)expected)
-        #endif
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint8 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov al,  src
-                    lock xchg [ecx], al
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint16 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  src
-                    lock xchg [ecx], ax
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint32 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov eax, src
-                    lock xchg [ecx], eax
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint8)_InterlockedExchange8((volatile char*)dst, (char)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint16)_InterlockedExchange16((volatile short*)dst, (short)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint32)_InterlockedExchange((volatile long*)dst, (long)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src);
-            }
-        #else
-        #endif
-    #endif
-    #if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            do {
-                oldValue = *dst;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint8 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov al,  src
-                    lock xadd [ecx], al
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint16 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  src
-                    lock xadd [ecx], ax
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint32 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov eax, src
-                    lock xadd [ecx], eax
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src);
-            }
-        #else
-        #endif
-    #endif
-    #if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue + src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        static C89ATOMIC_INLINE void __stdcall c89atomic_thread_fence(c89atomic_memory_order order)
-        {
-            (void)order;
-            __asm {
-                lock add [esp], 0
-            }
-        }
-    #else
-        #if defined(C89ATOMIC_X64)
-            #define c89atomic_thread_fence(order)   __faststorefence(), (void)order
-        #else
-            static C89ATOMIC_INLINE void c89atomic_thread_fence(c89atomic_memory_order order)
-            {
-                volatile c89atomic_uint32 barrier = 0;
-                c89atomic_fetch_add_explicit_32(&barrier, 0, order);
-            }
-        #endif
-    #endif
-    #define c89atomic_compiler_fence()      c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
-    #define c89atomic_signal_fence(order)   c89atomic_thread_fence(order)
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile const c89atomic_uint8* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_8((c89atomic_uint8*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile const c89atomic_uint16* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_16((c89atomic_uint16*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile const c89atomic_uint32* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_32((c89atomic_uint32*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile const c89atomic_uint64* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_64((c89atomic_uint64*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_store_explicit_8( dst, src, order) (void)c89atomic_exchange_explicit_8 (dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_store_explicit_16(dst, src, order) (void)c89atomic_exchange_explicit_16(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_store_explicit_32(dst, src, order) (void)c89atomic_exchange_explicit_32(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_store_explicit_64(dst, src, order) (void)c89atomic_exchange_explicit_64(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue - src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue - src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue & src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue & src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue | src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue | src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_test_and_set_explicit_8( dst, order) c89atomic_exchange_explicit_8 (dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_test_and_set_explicit_16(dst, order) c89atomic_exchange_explicit_16(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_test_and_set_explicit_32(dst, order) c89atomic_exchange_explicit_32(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_test_and_set_explicit_64(dst, order) c89atomic_exchange_explicit_64(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_clear_explicit_8( dst, order) c89atomic_store_explicit_8 (dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_clear_explicit_16(dst, order) c89atomic_store_explicit_16(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_clear_explicit_32(dst, order) c89atomic_store_explicit_32(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_clear_explicit_64(dst, order) c89atomic_store_explicit_64(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        typedef c89atomic_uint8 c89atomic_flag;
-        #define c89atomic_flag_test_and_set_explicit(ptr, order)    (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
-        #define c89atomic_flag_clear_explicit(ptr, order)           c89atomic_clear_explicit_8(ptr, order)
-        #define c89atoimc_flag_load_explicit(ptr, order)            c89atomic_load_explicit_8(ptr, order)
-    #else
-        typedef c89atomic_uint32 c89atomic_flag;
-        #define c89atomic_flag_test_and_set_explicit(ptr, order)    (c89atomic_bool)c89atomic_test_and_set_explicit_32(ptr, order)
-        #define c89atomic_flag_clear_explicit(ptr, order)           c89atomic_clear_explicit_32(ptr, order)
-        #define c89atoimc_flag_load_explicit(ptr, order)            c89atomic_load_explicit_32(ptr, order)
-    #endif
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE
-    #define C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE
-    #define c89atomic_memory_order_relaxed                          __ATOMIC_RELAXED
-    #define c89atomic_memory_order_consume                          __ATOMIC_CONSUME
-    #define c89atomic_memory_order_acquire                          __ATOMIC_ACQUIRE
-    #define c89atomic_memory_order_release                          __ATOMIC_RELEASE
-    #define c89atomic_memory_order_acq_rel                          __ATOMIC_ACQ_REL
-    #define c89atomic_memory_order_seq_cst                          __ATOMIC_SEQ_CST
-    #define c89atomic_compiler_fence()                              __asm__ __volatile__("":::"memory")
-    #define c89atomic_thread_fence(order)                           __atomic_thread_fence(order)
-    #define c89atomic_signal_fence(order)                           __atomic_signal_fence(order)
-    #define c89atomic_is_lock_free_8(ptr)                           __atomic_is_lock_free(1, ptr)
-    #define c89atomic_is_lock_free_16(ptr)                          __atomic_is_lock_free(2, ptr)
-    #define c89atomic_is_lock_free_32(ptr)                          __atomic_is_lock_free(4, ptr)
-    #define c89atomic_is_lock_free_64(ptr)                          __atomic_is_lock_free(8, ptr)
-    #define c89atomic_test_and_set_explicit_8( dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_16(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_32(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_64(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_clear_explicit_8( dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_16(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_32(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_64(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_store_explicit_8( dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_16(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_32(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_64(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_load_explicit_8( dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_16(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_32(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_64(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_exchange_explicit_8( dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_16(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_32(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_64(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_compare_exchange_strong_explicit_8( dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_fetch_add_explicit_8( dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_16(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_32(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_64(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_8( dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_16(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_32(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_64(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_or_explicit_8( dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_16(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_32(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_64(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_8( dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_16(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_32(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_64(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_and_explicit_8( dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_16(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_32(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_64(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_compare_and_swap_8 (dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_16(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_32(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_64(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    typedef c89atomic_uint8 c89atomic_flag;
-    #define c89atomic_flag_test_and_set_explicit(dst, order)        (c89atomic_bool)__atomic_test_and_set(dst, order)
-    #define c89atomic_flag_clear_explicit(dst, order)               __atomic_clear(dst, order)
-    #define c89atoimc_flag_load_explicit(ptr, order)                c89atomic_load_explicit_8(ptr, order)
-#else
-    #define c89atomic_memory_order_relaxed  1
-    #define c89atomic_memory_order_consume  2
-    #define c89atomic_memory_order_acquire  3
-    #define c89atomic_memory_order_release  4
-    #define c89atomic_memory_order_acq_rel  5
-    #define c89atomic_memory_order_seq_cst  6
-    #define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
-    #if defined(__GNUC__)
-        #define c89atomic_thread_fence(order) __sync_synchronize(), (void)order
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            if (order > c89atomic_memory_order_acquire) {
-                __sync_synchronize();
-            }
-            return __sync_lock_test_and_set(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        #define c89atomic_compare_and_swap_8( dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_16(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_32(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_64(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #else
-        #if defined(C89ATOMIC_X86)
-            #define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addl $0, (%%esp)" ::: "memory", "cc")
-        #elif defined(C89ATOMIC_X64)
-            #define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addq $0, (%%rsp)" ::: "memory", "cc")
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
-        {
-            c89atomic_uint8 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
-        {
-            c89atomic_uint16 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
-        {
-            c89atomic_uint32 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
-        {
-            volatile c89atomic_uint64 result;
-        #if defined(C89ATOMIC_X86)
-            c89atomic_uint32 resultEAX;
-            c89atomic_uint32 resultEDX;
-            __asm__ __volatile__("push %%ebx; xchg %5, %%ebx; lock; cmpxchg8b %0; pop %%ebx" : "+m"(*dst), "=a"(resultEAX), "=d"(resultEDX) : "a"(expected & 0xFFFFFFFF), "d"(expected >> 32), "r"(desired & 0xFFFFFFFF), "c"(desired >> 32) : "cc");
-            result = ((c89atomic_uint64)resultEDX << 32) | resultEAX;
-        #elif defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 result = 0;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 result = 0;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86)
-            do {
-                result = *dst;
-            } while (c89atomic_compare_and_swap_64(dst, result, src) != result);
-        #elif defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-        #if defined(C89ATOMIC_X86)
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            (void)order;
-            do {
-                oldValue = *dst;
-                newValue = oldValue + src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            return oldValue;
-        #elif defined(C89ATOMIC_X64)
-            c89atomic_uint64 result;
-            (void)order;
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-            return result;
-        #endif
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue - src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue - src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue & src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue & src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue | src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue | src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #define c89atomic_signal_fence(order)                           c89atomic_thread_fence(order)
-    static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile const c89atomic_uint8* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_8((c89atomic_uint8*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile const c89atomic_uint16* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_16((c89atomic_uint16*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile const c89atomic_uint32* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_32((c89atomic_uint32*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile const c89atomic_uint64* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_64((c89atomic_uint64*)ptr, 0, 0);
-    }
-    #define c89atomic_store_explicit_8( dst, src, order)            (void)c89atomic_exchange_explicit_8 (dst, src, order)
-    #define c89atomic_store_explicit_16(dst, src, order)            (void)c89atomic_exchange_explicit_16(dst, src, order)
-    #define c89atomic_store_explicit_32(dst, src, order)            (void)c89atomic_exchange_explicit_32(dst, src, order)
-    #define c89atomic_store_explicit_64(dst, src, order)            (void)c89atomic_exchange_explicit_64(dst, src, order)
-    #define c89atomic_test_and_set_explicit_8( dst, order)          c89atomic_exchange_explicit_8 (dst, 1, order)
-    #define c89atomic_test_and_set_explicit_16(dst, order)          c89atomic_exchange_explicit_16(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_32(dst, order)          c89atomic_exchange_explicit_32(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_64(dst, order)          c89atomic_exchange_explicit_64(dst, 1, order)
-    #define c89atomic_clear_explicit_8( dst, order)                 c89atomic_store_explicit_8 (dst, 0, order)
-    #define c89atomic_clear_explicit_16(dst, order)                 c89atomic_store_explicit_16(dst, 0, order)
-    #define c89atomic_clear_explicit_32(dst, order)                 c89atomic_store_explicit_32(dst, 0, order)
-    #define c89atomic_clear_explicit_64(dst, order)                 c89atomic_store_explicit_64(dst, 0, order)
-    typedef c89atomic_uint8 c89atomic_flag;
-    #define c89atomic_flag_test_and_set_explicit(ptr, order)        (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
-    #define c89atomic_flag_clear_explicit(ptr, order)               c89atomic_clear_explicit_8(ptr, order)
-    #define c89atoimc_flag_load_explicit(ptr, order)                c89atomic_load_explicit_8(ptr, order)
-#endif
-#if !defined(C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE)
-    #if defined(C89ATOMIC_HAS_8)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint8 expectedValue;
-            c89atomic_uint8 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_8(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_8(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_8(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint16 expectedValue;
-            c89atomic_uint16 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_16(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_16(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_16(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint32 expectedValue;
-            c89atomic_uint32 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_32(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_32(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_32(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint64 expectedValue;
-            c89atomic_uint64 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_64(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_64(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_64(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_8 (dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)
-#endif
-#if !defined(C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_8(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_16(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_32(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_64(volatile void* ptr)
-    {
-        (void)ptr;
-    #if defined(C89ATOMIC_64BIT)
-        return 1;
-    #else
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            return 1;
-        #else
-            return 0;
-        #endif
-    #endif
-    }
-#endif
-#if defined(C89ATOMIC_64BIT)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_ptr(volatile void** ptr)
-    {
-        return c89atomic_is_lock_free_64((volatile c89atomic_uint64*)ptr);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_load_explicit_ptr(volatile void** ptr, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_load_explicit_64((volatile c89atomic_uint64*)ptr, order);
-    }
-    static C89ATOMIC_INLINE void c89atomic_store_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        c89atomic_store_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)src, order);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_exchange_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_exchange_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)src, order);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_strong_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, volatile void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_weak_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired)
-    {
-        return (void*)c89atomic_compare_and_swap_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)expected, (c89atomic_uint64)desired);
-    }
-#elif defined(C89ATOMIC_32BIT)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_ptr(volatile void** ptr)
-    {
-        return c89atomic_is_lock_free_32((volatile c89atomic_uint32*)ptr);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_load_explicit_ptr(volatile void** ptr, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_load_explicit_32((volatile c89atomic_uint32*)ptr, order);
-    }
-    static C89ATOMIC_INLINE void c89atomic_store_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        c89atomic_store_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)src, order);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_exchange_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_exchange_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)src, order);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_strong_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, volatile void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_weak_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired)
-    {
-        return (void*)c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)expected, (c89atomic_uint32)desired);
-    }
-#else
-    #error Unsupported architecture.
-#endif
-#define c89atomic_flag_test_and_set(ptr)                                c89atomic_flag_test_and_set_explicit(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_flag_clear(ptr)                                       c89atomic_flag_clear_explicit(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_ptr(dst, src)                                   c89atomic_store_explicit_ptr((volatile void**)dst, (void*)src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_ptr(ptr)                                         c89atomic_load_explicit_ptr((volatile void**)ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_ptr(dst, src)                                c89atomic_exchange_explicit_ptr((volatile void**)dst, (void*)src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_ptr(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_ptr((volatile void**)dst, (void*)expected, (void*)desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_ptr(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_ptr((volatile void**)dst, (void*)expected, (void*)desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_8( ptr)                                  c89atomic_test_and_set_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_16(ptr)                                  c89atomic_test_and_set_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_32(ptr)                                  c89atomic_test_and_set_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_64(ptr)                                  c89atomic_test_and_set_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_8( ptr)                                         c89atomic_clear_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_16(ptr)                                         c89atomic_clear_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_32(ptr)                                         c89atomic_clear_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_64(ptr)                                         c89atomic_clear_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_8( dst, src)                                    c89atomic_store_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_16(dst, src)                                    c89atomic_store_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_32(dst, src)                                    c89atomic_store_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_64(dst, src)                                    c89atomic_store_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_8( ptr)                                          c89atomic_load_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_16(ptr)                                          c89atomic_load_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_32(ptr)                                          c89atomic_load_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_64(ptr)                                          c89atomic_load_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_8( dst, src)                                 c89atomic_exchange_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_16(dst, src)                                 c89atomic_exchange_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_32(dst, src)                                 c89atomic_exchange_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_64(dst, src)                                 c89atomic_exchange_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_8( dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_16(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_32(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_64(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_8(  dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_16( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_32( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_64( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_8( dst, src)                                c89atomic_fetch_add_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_16(dst, src)                                c89atomic_fetch_add_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_32(dst, src)                                c89atomic_fetch_add_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_64(dst, src)                                c89atomic_fetch_add_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_8( dst, src)                                c89atomic_fetch_sub_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_16(dst, src)                                c89atomic_fetch_sub_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_32(dst, src)                                c89atomic_fetch_sub_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_64(dst, src)                                c89atomic_fetch_sub_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_8( dst, src)                                 c89atomic_fetch_or_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_16(dst, src)                                 c89atomic_fetch_or_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_32(dst, src)                                 c89atomic_fetch_or_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_64(dst, src)                                 c89atomic_fetch_or_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_8( dst, src)                                c89atomic_fetch_xor_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_16(dst, src)                                c89atomic_fetch_xor_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_32(dst, src)                                c89atomic_fetch_xor_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_64(dst, src)                                c89atomic_fetch_xor_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_8( dst, src)                                c89atomic_fetch_and_explicit_8 (dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_16(dst, src)                                c89atomic_fetch_and_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_32(dst, src)                                c89atomic_fetch_and_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_64(dst, src)                                c89atomic_fetch_and_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_explicit_i8( ptr, order)                 (c89atomic_int8 )c89atomic_test_and_set_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_test_and_set_explicit_i16(ptr, order)                 (c89atomic_int16)c89atomic_test_and_set_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_test_and_set_explicit_i32(ptr, order)                 (c89atomic_int32)c89atomic_test_and_set_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_test_and_set_explicit_i64(ptr, order)                 (c89atomic_int64)c89atomic_test_and_set_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_clear_explicit_i8( ptr, order)                        c89atomic_clear_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_clear_explicit_i16(ptr, order)                        c89atomic_clear_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_clear_explicit_i32(ptr, order)                        c89atomic_clear_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_clear_explicit_i64(ptr, order)                        c89atomic_clear_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_store_explicit_i8( dst, src, order)                   (c89atomic_int8 )c89atomic_store_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_store_explicit_i16(dst, src, order)                   (c89atomic_int16)c89atomic_store_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_store_explicit_i32(dst, src, order)                   (c89atomic_int32)c89atomic_store_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_store_explicit_i64(dst, src, order)                   (c89atomic_int64)c89atomic_store_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_load_explicit_i8( ptr, order)                         (c89atomic_int8 )c89atomic_load_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_load_explicit_i16(ptr, order)                         (c89atomic_int16)c89atomic_load_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_load_explicit_i32(ptr, order)                         (c89atomic_int32)c89atomic_load_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_load_explicit_i64(ptr, order)                         (c89atomic_int64)c89atomic_load_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_exchange_explicit_i8( dst, src, order)                (c89atomic_int8 )c89atomic_exchange_explicit_8 ((c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_exchange_explicit_i16(dst, src, order)                (c89atomic_int16)c89atomic_exchange_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_exchange_explicit_i32(dst, src, order)                (c89atomic_int32)c89atomic_exchange_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_exchange_explicit_i64(dst, src, order)                (c89atomic_int64)c89atomic_exchange_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8* )expected, (c89atomic_uint8 )desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16*)expected, (c89atomic_uint16)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8* )expected, (c89atomic_uint8 )desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16*)expected, (c89atomic_uint16)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder)
-#define c89atomic_fetch_add_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_add_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_add_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_add_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_add_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_add_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_add_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_add_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_sub_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_sub_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_sub_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_sub_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_sub_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_sub_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_sub_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_sub_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_or_explicit_i8( dst, src, order)                (c89atomic_int8 )c89atomic_fetch_or_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_or_explicit_i16(dst, src, order)                (c89atomic_int16)c89atomic_fetch_or_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_or_explicit_i32(dst, src, order)                (c89atomic_int32)c89atomic_fetch_or_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_or_explicit_i64(dst, src, order)                (c89atomic_int64)c89atomic_fetch_or_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_xor_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_xor_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_xor_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_xor_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_xor_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_xor_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_xor_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_xor_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_and_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_and_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_and_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_and_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_and_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_and_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_and_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_and_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_test_and_set_i8( ptr)                                 c89atomic_test_and_set_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i16(ptr)                                 c89atomic_test_and_set_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i32(ptr)                                 c89atomic_test_and_set_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i64(ptr)                                 c89atomic_test_and_set_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i8( ptr)                                        c89atomic_clear_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i16(ptr)                                        c89atomic_clear_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i32(ptr)                                        c89atomic_clear_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i64(ptr)                                        c89atomic_clear_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i8( dst, src)                                   c89atomic_store_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i16(dst, src)                                   c89atomic_store_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i32(dst, src)                                   c89atomic_store_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i64(dst, src)                                   c89atomic_store_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i8( ptr)                                         c89atomic_load_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i16(ptr)                                         c89atomic_load_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i32(ptr)                                         c89atomic_load_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i64(ptr)                                         c89atomic_load_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i8( dst, src)                                c89atomic_exchange_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i16(dst, src)                                c89atomic_exchange_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i32(dst, src)                                c89atomic_exchange_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i64(dst, src)                                c89atomic_exchange_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i8( dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i16(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i32(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i64(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i8( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i16(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i32(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i64(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i8( dst, src)                               c89atomic_fetch_add_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i16(dst, src)                               c89atomic_fetch_add_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i32(dst, src)                               c89atomic_fetch_add_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i64(dst, src)                               c89atomic_fetch_add_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i8( dst, src)                               c89atomic_fetch_sub_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i16(dst, src)                               c89atomic_fetch_sub_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i32(dst, src)                               c89atomic_fetch_sub_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i64(dst, src)                               c89atomic_fetch_sub_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i8( dst, src)                                c89atomic_fetch_or_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i16(dst, src)                                c89atomic_fetch_or_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i32(dst, src)                                c89atomic_fetch_or_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i64(dst, src)                                c89atomic_fetch_or_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i8( dst, src)                               c89atomic_fetch_xor_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i16(dst, src)                               c89atomic_fetch_xor_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i32(dst, src)                               c89atomic_fetch_xor_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i64(dst, src)                               c89atomic_fetch_xor_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i8( dst, src)                               c89atomic_fetch_and_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i16(dst, src)                               c89atomic_fetch_and_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i32(dst, src)                               c89atomic_fetch_and_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i64(dst, src)                               c89atomic_fetch_and_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-typedef union
-{
-    c89atomic_uint32 i;
-    float f;
-} c89atomic_if32;
-typedef union
-{
-    c89atomic_uint64 i;
-    double f;
-} c89atomic_if64;
-#define c89atomic_clear_explicit_f32(ptr, order)                        c89atomic_clear_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_clear_explicit_f64(ptr, order)                        c89atomic_clear_explicit_64((c89atomic_uint64*)ptr, order)
-static C89ATOMIC_INLINE void c89atomic_store_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if32 x;
-    x.f = src;
-    c89atomic_store_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
-}
-static C89ATOMIC_INLINE void c89atomic_store_explicit_f64(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if64 x;
-    x.f = src;
-    c89atomic_store_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
-}
-static C89ATOMIC_INLINE float c89atomic_load_explicit_f32(volatile float* ptr, c89atomic_memory_order order)
-{
-    c89atomic_if32 r;
-    r.i = c89atomic_load_explicit_32((volatile c89atomic_uint32*)ptr, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE double c89atomic_load_explicit_f64(volatile double* ptr, c89atomic_memory_order order)
-{
-    c89atomic_if64 r;
-    r.i = c89atomic_load_explicit_64((volatile c89atomic_uint64*)ptr, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE float c89atomic_exchange_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if32 r;
-    c89atomic_if32 x;
-    x.f = src;
-    r.i = c89atomic_exchange_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE double c89atomic_exchange_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
-{
-    c89atomic_if64 r;
-    c89atomic_if64 x;
-    x.f = src;
-    r.i = c89atomic_exchange_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
-    return r.f;
-}
-#define c89atomic_clear_f32(ptr)                                        (float )c89atomic_clear_explicit_f32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_f64(ptr)                                        (double)c89atomic_clear_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_f32(dst, src)                                   c89atomic_store_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_f64(dst, src)                                   c89atomic_store_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_f32(ptr)                                         (float )c89atomic_load_explicit_f32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_f64(ptr)                                         (double)c89atomic_load_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_f32(dst, src)                                (float )c89atomic_exchange_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_f64(dst, src)                                (double)c89atomic_exchange_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
-typedef c89atomic_flag c89atomic_spinlock;
-static C89ATOMIC_INLINE void c89atomic_spinlock_lock(volatile c89atomic_spinlock* pSpinlock)
-{
-    for (;;) {
-        if (c89atomic_flag_test_and_set_explicit(pSpinlock, c89atomic_memory_order_acquire) == 0) {
-            break;
-        }
-        while (c89atoimc_flag_load_explicit(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
-        }
-    }
-}
-static C89ATOMIC_INLINE void c89atomic_spinlock_unlock(volatile c89atomic_spinlock* pSpinlock)
-{
-    c89atomic_flag_clear_explicit(pSpinlock, c89atomic_memory_order_release);
-}
-#if defined(__cplusplus)
-}
-#endif
-#endif
-/* c89atomic.h end */
-
-
-
-static void* ma__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return MA_MALLOC(sz);
-}
-
-static void* ma__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return MA_REALLOC(p, sz);
-}
-
-static void ma__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    MA_FREE(p);
-}
-
-
-static void* ma__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* ma__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            MA_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static MA_INLINE void* ma__calloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    void* p = ma__malloc_from_callbacks(sz, pAllocationCallbacks);
-    if (p != NULL) {
-        MA_ZERO_MEMORY(p, sz);
-    }
-
-    return p;
-}
-
-static void ma__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-static ma_allocation_callbacks ma_allocation_callbacks_init_default(void)
-{
-    ma_allocation_callbacks callbacks;
-    callbacks.pUserData = NULL;
-    callbacks.onMalloc  = ma__malloc_default;
-    callbacks.onRealloc = ma__realloc_default;
-    callbacks.onFree    = ma__free_default;
-
-    return callbacks;
-}
-
-static ma_result ma_allocation_callbacks_init_copy(ma_allocation_callbacks* pDst, const ma_allocation_callbacks* pSrc)
-{
-    if (pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pSrc == NULL) {
-        *pDst = ma_allocation_callbacks_init_default();
-    } else {
-        if (pSrc->pUserData == NULL && pSrc->onFree == NULL && pSrc->onMalloc == NULL && pSrc->onRealloc == NULL) {
-            *pDst = ma_allocation_callbacks_init_default();
-        } else {
-            if (pSrc->onFree == NULL || (pSrc->onMalloc == NULL && pSrc->onRealloc == NULL)) {
-                return MA_INVALID_ARGS;    /* Invalid allocation callbacks. */
-            } else {
-                *pDst = *pSrc;
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_uint64 ma_calculate_frame_count_after_resampling(ma_uint32 sampleRateOut, ma_uint32 sampleRateIn, ma_uint64 frameCountIn)
-{
-    /* For robustness we're going to use a resampler object to calculate this since that already has a way of calculating this. */
-    ma_result result;
-    ma_uint64 frameCountOut;
-    ma_resampler_config config;
-    ma_resampler resampler;
-
-    if (sampleRateOut == sampleRateIn) {
-        return frameCountIn;
-    }
-
-    config = ma_resampler_config_init(ma_format_s16, 1, sampleRateIn, sampleRateOut, ma_resample_algorithm_linear);
-    result = ma_resampler_init(&config, &resampler);
-    if (result != MA_SUCCESS) {
-        return 0;
-    }
-
-    frameCountOut = ma_resampler_get_expected_output_frame_count(&resampler, frameCountIn);
-
-    ma_resampler_uninit(&resampler);
-    return frameCountOut;
-}
-
-#ifndef MA_DATA_CONVERTER_STACK_BUFFER_SIZE
-#define MA_DATA_CONVERTER_STACK_BUFFER_SIZE     4096
-#endif
-
-
-
-#if defined(MA_WIN32)
-static ma_result ma_result_from_GetLastError(DWORD error)
-{
-    switch (error)
-    {
-        case ERROR_SUCCESS:             return MA_SUCCESS;
-        case ERROR_PATH_NOT_FOUND:      return MA_DOES_NOT_EXIST;
-        case ERROR_TOO_MANY_OPEN_FILES: return MA_TOO_MANY_OPEN_FILES;
-        case ERROR_NOT_ENOUGH_MEMORY:   return MA_OUT_OF_MEMORY;
-        case ERROR_DISK_FULL:           return MA_NO_SPACE;
-        case ERROR_HANDLE_EOF:          return MA_END_OF_FILE;
-        case ERROR_NEGATIVE_SEEK:       return MA_BAD_SEEK;
-        case ERROR_INVALID_PARAMETER:   return MA_INVALID_ARGS;
-        case ERROR_ACCESS_DENIED:       return MA_ACCESS_DENIED;
-        case ERROR_SEM_TIMEOUT:         return MA_TIMEOUT;
-        case ERROR_FILE_NOT_FOUND:      return MA_DOES_NOT_EXIST;
-        default: break;
-    }
-
-    return MA_ERROR;
-}
-#endif  /* MA_WIN32 */
-
-
-/*******************************************************************************
-
-Threading
-
-*******************************************************************************/
-#ifndef MA_NO_THREADING
-#ifdef MA_WIN32
-    #define MA_THREADCALL WINAPI
-    typedef unsigned long ma_thread_result;
-#else
-    #define MA_THREADCALL
-    typedef void* ma_thread_result;
-#endif
-typedef ma_thread_result (MA_THREADCALL * ma_thread_entry_proc)(void* pData);
-
-static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock, ma_bool32 yield)
-{
-    if (pSpinlock == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    for (;;) {
-        if (c89atomic_exchange_explicit_32(pSpinlock, 1, c89atomic_memory_order_acquire) == 0) {
-            break;
-        }
-
-        while (c89atomic_load_explicit_32(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
-            if (yield) {
-                ma_yield();
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock)
-{
-    return ma_spinlock_lock_ex(pSpinlock, MA_TRUE);
-}
-
-MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock)
-{
-    return ma_spinlock_lock_ex(pSpinlock, MA_FALSE);
-}
-
-MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock)
-{
-    if (pSpinlock == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    c89atomic_store_explicit_32(pSpinlock, 0, c89atomic_memory_order_release);
-    return MA_SUCCESS;
-}
-
-#ifdef MA_WIN32
-static int ma_thread_priority_to_win32(ma_thread_priority priority)
-{
-    switch (priority) {
-        case ma_thread_priority_idle:     return THREAD_PRIORITY_IDLE;
-        case ma_thread_priority_lowest:   return THREAD_PRIORITY_LOWEST;
-        case ma_thread_priority_low:      return THREAD_PRIORITY_BELOW_NORMAL;
-        case ma_thread_priority_normal:   return THREAD_PRIORITY_NORMAL;
-        case ma_thread_priority_high:     return THREAD_PRIORITY_ABOVE_NORMAL;
-        case ma_thread_priority_highest:  return THREAD_PRIORITY_HIGHEST;
-        case ma_thread_priority_realtime: return THREAD_PRIORITY_TIME_CRITICAL;
-        default:                          return THREAD_PRIORITY_NORMAL;
-    }
-}
-
-static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, NULL);
-    if (*pThread == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    SetThreadPriority((HANDLE)*pThread, ma_thread_priority_to_win32(priority));
-
-    return MA_SUCCESS;
-}
-
-static void ma_thread_wait__win32(ma_thread* pThread)
-{
-    WaitForSingleObject((HANDLE)*pThread, INFINITE);
-    CloseHandle((HANDLE)*pThread);
-}
-
-
-static ma_result ma_mutex_init__win32(ma_mutex* pMutex)
-{
-    *pMutex = CreateEventW(NULL, FALSE, TRUE, NULL);
-    if (*pMutex == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_mutex_uninit__win32(ma_mutex* pMutex)
-{
-    CloseHandle((HANDLE)*pMutex);
-}
-
-static void ma_mutex_lock__win32(ma_mutex* pMutex)
-{
-    WaitForSingleObject((HANDLE)*pMutex, INFINITE);
-}
-
-static void ma_mutex_unlock__win32(ma_mutex* pMutex)
-{
-    SetEvent((HANDLE)*pMutex);
-}
-
-
-static ma_result ma_event_init__win32(ma_event* pEvent)
-{
-    *pEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-    if (*pEvent == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_event_uninit__win32(ma_event* pEvent)
-{
-    CloseHandle((HANDLE)*pEvent);
-}
-
-static ma_result ma_event_wait__win32(ma_event* pEvent)
-{
-    DWORD result = WaitForSingleObject((HANDLE)*pEvent, INFINITE);
-    if (result == WAIT_OBJECT_0) {
-        return MA_SUCCESS;
-    }
-
-    if (result == WAIT_TIMEOUT) {
-        return MA_TIMEOUT;
-    }
-
-    return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_event_signal__win32(ma_event* pEvent)
-{
-    BOOL result = SetEvent((HANDLE)*pEvent);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore)
-{
-    *pSemaphore = CreateSemaphoreW(NULL, (LONG)initialValue, LONG_MAX, NULL);
-    if (*pSemaphore == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_semaphore_uninit__win32(ma_semaphore* pSemaphore)
-{
-    CloseHandle((HANDLE)*pSemaphore);
-}
-
-static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore)
-{
-    DWORD result = WaitForSingleObject((HANDLE)*pSemaphore, INFINITE);
-    if (result == WAIT_OBJECT_0) {
-        return MA_SUCCESS;
-    }
-
-    if (result == WAIT_TIMEOUT) {
-        return MA_TIMEOUT;
-    }
-
-    return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore)
-{
-    BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-#ifdef MA_POSIX
-static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    int result;
-    pthread_attr_t* pAttr = NULL;
-
-#if !defined(__EMSCRIPTEN__)
-    /* Try setting the thread priority. It's not critical if anything fails here. */
-    pthread_attr_t attr;
-    if (pthread_attr_init(&attr) == 0) {
-        int scheduler = -1;
-        if (priority == ma_thread_priority_idle) {
-#ifdef SCHED_IDLE
-            if (pthread_attr_setschedpolicy(&attr, SCHED_IDLE) == 0) {
-                scheduler = SCHED_IDLE;
-            }
-#endif
-        } else if (priority == ma_thread_priority_realtime) {
-#ifdef SCHED_FIFO
-            if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0) {
-                scheduler = SCHED_FIFO;
-            }
-#endif
-#ifdef MA_LINUX
-        } else {
-            scheduler = sched_getscheduler(0);
-#endif
-        }
-
-        if (stackSize > 0) {
-            pthread_attr_setstacksize(&attr, stackSize);
-        }
-
-        if (scheduler != -1) {
-            int priorityMin = sched_get_priority_min(scheduler);
-            int priorityMax = sched_get_priority_max(scheduler);
-            int priorityStep = (priorityMax - priorityMin) / 7;  /* 7 = number of priorities supported by miniaudio. */
-
-            struct sched_param sched;
-            if (pthread_attr_getschedparam(&attr, &sched) == 0) {
-                if (priority == ma_thread_priority_idle) {
-                    sched.sched_priority = priorityMin;
-                } else if (priority == ma_thread_priority_realtime) {
-                    sched.sched_priority = priorityMax;
-                } else {
-                    sched.sched_priority += ((int)priority + 5) * priorityStep;  /* +5 because the lowest priority is -5. */
-                    if (sched.sched_priority < priorityMin) {
-                        sched.sched_priority = priorityMin;
-                    }
-                    if (sched.sched_priority > priorityMax) {
-                        sched.sched_priority = priorityMax;
-                    }
-                }
-
-                if (pthread_attr_setschedparam(&attr, &sched) == 0) {
-                    pAttr = &attr;
-                }
-            }
-        }
-    }
-#else
-    /* It's the emscripten build. We'll have a few unused parameters. */
-    (void)priority;
-    (void)stackSize;
-#endif
-
-    result = pthread_create(pThread, pAttr, entryProc, pData);
-
-    /* The thread attributes object is no longer required. */
-    if (pAttr != NULL) {
-        pthread_attr_destroy(pAttr);
-    }
-
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_thread_wait__posix(ma_thread* pThread)
-{
-    pthread_join(*pThread, NULL);
-    pthread_detach(*pThread);
-}
-
-
-static ma_result ma_mutex_init__posix(ma_mutex* pMutex)
-{
-    int result = pthread_mutex_init((pthread_mutex_t*)pMutex, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_mutex_uninit__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_destroy((pthread_mutex_t*)pMutex);
-}
-
-static void ma_mutex_lock__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_lock((pthread_mutex_t*)pMutex);
-}
-
-static void ma_mutex_unlock__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_unlock((pthread_mutex_t*)pMutex);
-}
-
-
-static ma_result ma_event_init__posix(ma_event* pEvent)
-{
-    int result;
-
-    result = pthread_mutex_init(&pEvent->lock, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    result = pthread_cond_init(&pEvent->cond, NULL);
-    if (result != 0) {
-        pthread_mutex_destroy(&pEvent->lock);
-        return ma_result_from_errno(result);
-    }
-
-    pEvent->value = 0;
-    return MA_SUCCESS;
-}
-
-static void ma_event_uninit__posix(ma_event* pEvent)
-{
-    pthread_cond_destroy(&pEvent->cond);
-    pthread_mutex_destroy(&pEvent->lock);
-}
-
-static ma_result ma_event_wait__posix(ma_event* pEvent)
-{
-    pthread_mutex_lock(&pEvent->lock);
-    {
-        while (pEvent->value == 0) {
-            pthread_cond_wait(&pEvent->cond, &pEvent->lock);
-        }
-        pEvent->value = 0;  /* Auto-reset. */
-    }
-    pthread_mutex_unlock(&pEvent->lock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_event_signal__posix(ma_event* pEvent)
-{
-    pthread_mutex_lock(&pEvent->lock);
-    {
-        pEvent->value = 1;
-        pthread_cond_signal(&pEvent->cond);
-    }
-    pthread_mutex_unlock(&pEvent->lock);
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_semaphore_init__posix(int initialValue, ma_semaphore* pSemaphore)
-{
-    int result;
-
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pSemaphore->value = initialValue;
-
-    result = pthread_mutex_init(&pSemaphore->lock, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);  /* Failed to create mutex. */
-    }
-
-    result = pthread_cond_init(&pSemaphore->cond, NULL);
-    if (result != 0) {
-        pthread_mutex_destroy(&pSemaphore->lock);
-        return ma_result_from_errno(result);  /* Failed to create condition variable. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_semaphore_uninit__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return;
-    }
-
-    pthread_cond_destroy(&pSemaphore->cond);
-    pthread_mutex_destroy(&pSemaphore->lock);
-}
-
-static ma_result ma_semaphore_wait__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pthread_mutex_lock(&pSemaphore->lock);
-    {
-        /* We need to wait on a condition variable before escaping. We can't return from this function until the semaphore has been signaled. */
-        while (pSemaphore->value == 0) {
-            pthread_cond_wait(&pSemaphore->cond, &pSemaphore->lock);
-        }
-
-        pSemaphore->value -= 1;
-    }
-    pthread_mutex_unlock(&pSemaphore->lock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pthread_mutex_lock(&pSemaphore->lock);
-    {
-        pSemaphore->value += 1;
-        pthread_cond_signal(&pSemaphore->cond);
-    }
-    pthread_mutex_unlock(&pSemaphore->lock);
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    if (pThread == NULL || entryProc == NULL) {
-        return MA_FALSE;
-    }
-
-#ifdef MA_WIN32
-    return ma_thread_create__win32(pThread, priority, stackSize, entryProc, pData);
-#endif
-#ifdef MA_POSIX
-    return ma_thread_create__posix(pThread, priority, stackSize, entryProc, pData);
-#endif
-}
-
-static void ma_thread_wait(ma_thread* pThread)
-{
-    if (pThread == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_thread_wait__win32(pThread);
-#endif
-#ifdef MA_POSIX
-    ma_thread_wait__posix(pThread);
-#endif
-}
-
-
-MA_API ma_result ma_mutex_init(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_mutex_init__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    return ma_mutex_init__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_uninit(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_mutex_uninit__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_uninit__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_lock(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_mutex_lock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_lock__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_unlock(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return;
-}
-
-#ifdef MA_WIN32
-    ma_mutex_unlock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_unlock__posix(pMutex);
-#endif
-}
-
-
-MA_API ma_result ma_event_init(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_init__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_init__posix(pEvent);
-#endif
-}
-
-#if 0
-static ma_result ma_event_alloc_and_init(ma_event** ppEvent, ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_result result;
-    ma_event* pEvent;
-
-    if (ppEvent == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *ppEvent = NULL;
-
-    pEvent = ma_malloc(sizeof(*pEvent), pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-    if (pEvent == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    result = ma_event_init(pEvent);
-    if (result != MA_SUCCESS) {
-        ma_free(pEvent, pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-        return result;
-    }
-
-    *ppEvent = pEvent;
-    return result;
-}
-#endif
-
-MA_API void ma_event_uninit(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_event_uninit__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    ma_event_uninit__posix(pEvent);
-#endif
-}
-
-#if 0
-static void ma_event_uninit_and_free(ma_event* pEvent, ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pEvent == NULL) {
-        return;
-    }
-
-    ma_event_uninit(pEvent);
-    ma_free(pEvent, pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-}
-#endif
-
-MA_API ma_result ma_event_wait(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_wait__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_wait__posix(pEvent);
-#endif
-}
-
-MA_API ma_result ma_event_signal(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_signal__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_signal__posix(pEvent);
-#endif
-}
-
-
-MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_init__win32(initialValue, pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_init__posix(initialValue, pSemaphore);
-#endif
-}
-
-MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_semaphore_uninit__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    ma_semaphore_uninit__posix(pSemaphore);
-#endif
-}
-
-MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_wait__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_wait__posix(pSemaphore);
-#endif
-}
-
-MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_release__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_release__posix(pSemaphore);
-#endif
-}
-#else
-/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
-#ifndef MA_NO_DEVICE_IO
-#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
-#endif
-#endif  /* MA_NO_THREADING */
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DEVICE I/O
-==========
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DEVICE_IO
-#ifdef MA_WIN32
-    #include <objbase.h>
-    #include <mmreg.h>
-    #include <mmsystem.h>
-#endif
-
-#if defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
-    #include <mach/mach_time.h> /* For mach_absolute_time() */
-#endif
-
-#ifdef MA_POSIX
-    #include <sys/types.h>
-    #include <unistd.h>
-    #include <dlfcn.h>
-#endif
-
-/*
-Unfortunately using runtime linking for pthreads causes problems. This has occurred for me when testing on FreeBSD. When
-using runtime linking, deadlocks can occur (for me it happens when loading data from fread()). It turns out that doing
-compile-time linking fixes this. I'm not sure why this happens, but the safest way I can think of to fix this is to simply
-disable runtime linking by default. To enable runtime linking, #define this before the implementation of this file. I am
-not officially supporting this, but I'm leaving it here in case it's useful for somebody, somewhere.
-*/
-/*#define MA_USE_RUNTIME_LINKING_FOR_PTHREAD*/
-
-/* Disable run-time linking on certain backends. */
-#ifndef MA_NO_RUNTIME_LINKING
-    #if defined(MA_EMSCRIPTEN)
-        #define MA_NO_RUNTIME_LINKING
-    #endif
-#endif
-
-
-MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags)
-{
-    if (pDeviceInfo == NULL) {
-        return;
-    }
-
-    if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats)) {
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-        pDeviceInfo->nativeDataFormatCount += 1;
-    }
-}
-
-
-MA_API const char* ma_get_backend_name(ma_backend backend)
-{
-    switch (backend)
-    {
-        case ma_backend_wasapi:     return "WASAPI";
-        case ma_backend_dsound:     return "DirectSound";
-        case ma_backend_winmm:      return "WinMM";
-        case ma_backend_coreaudio:  return "Core Audio";
-        case ma_backend_sndio:      return "sndio";
-        case ma_backend_audio4:     return "audio(4)";
-        case ma_backend_oss:        return "OSS";
-        case ma_backend_pulseaudio: return "PulseAudio";
-        case ma_backend_alsa:       return "ALSA";
-        case ma_backend_jack:       return "JACK";
-        case ma_backend_aaudio:     return "AAudio";
-        case ma_backend_opensl:     return "OpenSL|ES";
-        case ma_backend_webaudio:   return "Web Audio";
-        case ma_backend_custom:     return "Custom";
-        case ma_backend_null:       return "Null";
-        default:                    return "Unknown";
-    }
-}
-
-MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend)
-{
-    /*
-    This looks a little bit gross, but we want all backends to be included in the switch to avoid warnings on some compilers
-    about some enums not being handled by the switch statement.
-    */
-    switch (backend)
-    {
-        case ma_backend_wasapi:
-        #if defined(MA_HAS_WASAPI)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_dsound:
-        #if defined(MA_HAS_DSOUND)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_winmm:
-        #if defined(MA_HAS_WINMM)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_coreaudio:
-        #if defined(MA_HAS_COREAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_sndio:
-        #if defined(MA_HAS_SNDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_audio4:
-        #if defined(MA_HAS_AUDIO4)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_oss:
-        #if defined(MA_HAS_OSS)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_pulseaudio:
-        #if defined(MA_HAS_PULSEAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_alsa:
-        #if defined(MA_HAS_ALSA)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_jack:
-        #if defined(MA_HAS_JACK)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_aaudio:
-        #if defined(MA_HAS_AAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_opensl:
-        #if defined(MA_HAS_OPENSL)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_webaudio:
-        #if defined(MA_HAS_WEBAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_custom:
-        #if defined(MA_HAS_CUSTOM)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_null:
-        #if defined(MA_HAS_NULL)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-
-        default: return MA_FALSE;
-    }
-}
-
-MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount)
-{
-    size_t backendCount;
-    size_t iBackend;
-    ma_result result = MA_SUCCESS;
-
-    if (pBackendCount == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    backendCount = 0;
-
-    for (iBackend = 0; iBackend <= ma_backend_null; iBackend += 1) {
-        ma_backend backend = (ma_backend)iBackend;
-
-        if (ma_is_backend_enabled(backend)) {
-            /* The backend is enabled. Try adding it to the list. If there's no room, MA_NO_SPACE needs to be returned. */
-            if (backendCount == backendCap) {
-                result = MA_NO_SPACE;
-                break;
-            } else {
-                pBackends[backendCount] = backend;
-                backendCount += 1;
-            }
-        }
-    }
-
-    if (pBackendCount != NULL) {
-        *pBackendCount = backendCount;
-    }
-
-    return result;
-}
-
-MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend)
-{
-    switch (backend)
-    {
-        case ma_backend_wasapi:     return MA_TRUE;
-        case ma_backend_dsound:     return MA_FALSE;
-        case ma_backend_winmm:      return MA_FALSE;
-        case ma_backend_coreaudio:  return MA_FALSE;
-        case ma_backend_sndio:      return MA_FALSE;
-        case ma_backend_audio4:     return MA_FALSE;
-        case ma_backend_oss:        return MA_FALSE;
-        case ma_backend_pulseaudio: return MA_FALSE;
-        case ma_backend_alsa:       return MA_FALSE;
-        case ma_backend_jack:       return MA_FALSE;
-        case ma_backend_aaudio:     return MA_FALSE;
-        case ma_backend_opensl:     return MA_FALSE;
-        case ma_backend_webaudio:   return MA_FALSE;
-        case ma_backend_custom:     return MA_FALSE;    /* <-- Will depend on the implementation of the backend. */
-        case ma_backend_null:       return MA_FALSE;
-        default:                    return MA_FALSE;
-    }
-}
-
-
-
-#ifdef MA_WIN32
-/* WASAPI error codes. */
-#define MA_AUDCLNT_E_NOT_INITIALIZED              ((HRESULT)0x88890001)
-#define MA_AUDCLNT_E_ALREADY_INITIALIZED          ((HRESULT)0x88890002)
-#define MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE          ((HRESULT)0x88890003)
-#define MA_AUDCLNT_E_DEVICE_INVALIDATED           ((HRESULT)0x88890004)
-#define MA_AUDCLNT_E_NOT_STOPPED                  ((HRESULT)0x88890005)
-#define MA_AUDCLNT_E_BUFFER_TOO_LARGE             ((HRESULT)0x88890006)
-#define MA_AUDCLNT_E_OUT_OF_ORDER                 ((HRESULT)0x88890007)
-#define MA_AUDCLNT_E_UNSUPPORTED_FORMAT           ((HRESULT)0x88890008)
-#define MA_AUDCLNT_E_INVALID_SIZE                 ((HRESULT)0x88890009)
-#define MA_AUDCLNT_E_DEVICE_IN_USE                ((HRESULT)0x8889000A)
-#define MA_AUDCLNT_E_BUFFER_OPERATION_PENDING     ((HRESULT)0x8889000B)
-#define MA_AUDCLNT_E_THREAD_NOT_REGISTERED        ((HRESULT)0x8889000C)
-#define MA_AUDCLNT_E_NO_SINGLE_PROCESS            ((HRESULT)0x8889000D)
-#define MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED   ((HRESULT)0x8889000E)
-#define MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED       ((HRESULT)0x8889000F)
-#define MA_AUDCLNT_E_SERVICE_NOT_RUNNING          ((HRESULT)0x88890010)
-#define MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED     ((HRESULT)0x88890011)
-#define MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY          ((HRESULT)0x88890012)
-#define MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL ((HRESULT)0x88890013)
-#define MA_AUDCLNT_E_EVENTHANDLE_NOT_SET          ((HRESULT)0x88890014)
-#define MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE        ((HRESULT)0x88890015)
-#define MA_AUDCLNT_E_BUFFER_SIZE_ERROR            ((HRESULT)0x88890016)
-#define MA_AUDCLNT_E_CPUUSAGE_EXCEEDED            ((HRESULT)0x88890017)
-#define MA_AUDCLNT_E_BUFFER_ERROR                 ((HRESULT)0x88890018)
-#define MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED      ((HRESULT)0x88890019)
-#define MA_AUDCLNT_E_INVALID_DEVICE_PERIOD        ((HRESULT)0x88890020)
-#define MA_AUDCLNT_E_INVALID_STREAM_FLAG          ((HRESULT)0x88890021)
-#define MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE ((HRESULT)0x88890022)
-#define MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES     ((HRESULT)0x88890023)
-#define MA_AUDCLNT_E_OFFLOAD_MODE_ONLY            ((HRESULT)0x88890024)
-#define MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY         ((HRESULT)0x88890025)
-#define MA_AUDCLNT_E_RESOURCES_INVALIDATED        ((HRESULT)0x88890026)
-#define MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED         ((HRESULT)0x88890027)
-#define MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED    ((HRESULT)0x88890028)
-#define MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED         ((HRESULT)0x88890029)
-#define MA_AUDCLNT_E_HEADTRACKING_ENABLED         ((HRESULT)0x88890030)
-#define MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED     ((HRESULT)0x88890040)
-#define MA_AUDCLNT_S_BUFFER_EMPTY                 ((HRESULT)0x08890001)
-#define MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED    ((HRESULT)0x08890002)
-#define MA_AUDCLNT_S_POSITION_STALLED             ((HRESULT)0x08890003)
-
-#define MA_DS_OK                                  ((HRESULT)0)
-#define MA_DS_NO_VIRTUALIZATION                   ((HRESULT)0x0878000A)
-#define MA_DSERR_ALLOCATED                        ((HRESULT)0x8878000A)
-#define MA_DSERR_CONTROLUNAVAIL                   ((HRESULT)0x8878001E)
-#define MA_DSERR_INVALIDPARAM                     ((HRESULT)0x80070057) /*E_INVALIDARG*/
-#define MA_DSERR_INVALIDCALL                      ((HRESULT)0x88780032)
-#define MA_DSERR_GENERIC                          ((HRESULT)0x80004005) /*E_FAIL*/
-#define MA_DSERR_PRIOLEVELNEEDED                  ((HRESULT)0x88780046)
-#define MA_DSERR_OUTOFMEMORY                      ((HRESULT)0x8007000E) /*E_OUTOFMEMORY*/
-#define MA_DSERR_BADFORMAT                        ((HRESULT)0x88780064)
-#define MA_DSERR_UNSUPPORTED                      ((HRESULT)0x80004001) /*E_NOTIMPL*/
-#define MA_DSERR_NODRIVER                         ((HRESULT)0x88780078)
-#define MA_DSERR_ALREADYINITIALIZED               ((HRESULT)0x88780082)
-#define MA_DSERR_NOAGGREGATION                    ((HRESULT)0x80040110) /*CLASS_E_NOAGGREGATION*/
-#define MA_DSERR_BUFFERLOST                       ((HRESULT)0x88780096)
-#define MA_DSERR_OTHERAPPHASPRIO                  ((HRESULT)0x887800A0)
-#define MA_DSERR_UNINITIALIZED                    ((HRESULT)0x887800AA)
-#define MA_DSERR_NOINTERFACE                      ((HRESULT)0x80004002) /*E_NOINTERFACE*/
-#define MA_DSERR_ACCESSDENIED                     ((HRESULT)0x80070005) /*E_ACCESSDENIED*/
-#define MA_DSERR_BUFFERTOOSMALL                   ((HRESULT)0x887800B4)
-#define MA_DSERR_DS8_REQUIRED                     ((HRESULT)0x887800BE)
-#define MA_DSERR_SENDLOOP                         ((HRESULT)0x887800C8)
-#define MA_DSERR_BADSENDBUFFERGUID                ((HRESULT)0x887800D2)
-#define MA_DSERR_OBJECTNOTFOUND                   ((HRESULT)0x88781161)
-#define MA_DSERR_FXUNAVAILABLE                    ((HRESULT)0x887800DC)
-
-static ma_result ma_result_from_HRESULT(HRESULT hr)
-{
-    switch (hr)
-    {
-        case NOERROR:                                   return MA_SUCCESS;
-        /*case S_OK:                                      return MA_SUCCESS;*/
-
-        case E_POINTER:                                 return MA_INVALID_ARGS;
-        case E_UNEXPECTED:                              return MA_ERROR;
-        case E_NOTIMPL:                                 return MA_NOT_IMPLEMENTED;
-        case E_OUTOFMEMORY:                             return MA_OUT_OF_MEMORY;
-        case E_INVALIDARG:                              return MA_INVALID_ARGS;
-        case E_NOINTERFACE:                             return MA_API_NOT_FOUND;
-        case E_HANDLE:                                  return MA_INVALID_ARGS;
-        case E_ABORT:                                   return MA_ERROR;
-        case E_FAIL:                                    return MA_ERROR;
-        case E_ACCESSDENIED:                            return MA_ACCESS_DENIED;
-
-        /* WASAPI */
-        case MA_AUDCLNT_E_NOT_INITIALIZED:              return MA_DEVICE_NOT_INITIALIZED;
-        case MA_AUDCLNT_E_ALREADY_INITIALIZED:          return MA_DEVICE_ALREADY_INITIALIZED;
-        case MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_DEVICE_INVALIDATED:           return MA_UNAVAILABLE;
-        case MA_AUDCLNT_E_NOT_STOPPED:                  return MA_DEVICE_NOT_STOPPED;
-        case MA_AUDCLNT_E_BUFFER_TOO_LARGE:             return MA_TOO_BIG;
-        case MA_AUDCLNT_E_OUT_OF_ORDER:                 return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_UNSUPPORTED_FORMAT:           return MA_FORMAT_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_INVALID_SIZE:                 return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_DEVICE_IN_USE:                return MA_BUSY;
-        case MA_AUDCLNT_E_BUFFER_OPERATION_PENDING:     return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_THREAD_NOT_REGISTERED:        return MA_DOES_NOT_EXIST;
-        case MA_AUDCLNT_E_NO_SINGLE_PROCESS:            return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED:   return MA_SHARE_MODE_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED:       return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-        case MA_AUDCLNT_E_SERVICE_NOT_RUNNING:          return MA_NOT_CONNECTED;
-        case MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED:     return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY:          return MA_SHARE_MODE_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_EVENTHANDLE_NOT_SET:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE:        return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_BUFFER_SIZE_ERROR:            return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_CPUUSAGE_EXCEEDED:            return MA_ERROR;
-        case MA_AUDCLNT_E_BUFFER_ERROR:                 return MA_ERROR;
-        case MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED:      return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INVALID_DEVICE_PERIOD:        return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INVALID_STREAM_FLAG:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES:     return MA_OUT_OF_MEMORY;
-        case MA_AUDCLNT_E_OFFLOAD_MODE_ONLY:            return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_RESOURCES_INVALIDATED:        return MA_INVALID_DATA;
-        case MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED:    return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_HEADTRACKING_ENABLED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED:     return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_S_BUFFER_EMPTY:                 return MA_NO_SPACE;
-        case MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED:    return MA_ALREADY_EXISTS;
-        case MA_AUDCLNT_S_POSITION_STALLED:             return MA_ERROR;
-
-        /* DirectSound */
-        /*case MA_DS_OK:                                  return MA_SUCCESS;*/          /* S_OK */
-        case MA_DS_NO_VIRTUALIZATION:                   return MA_SUCCESS;
-        case MA_DSERR_ALLOCATED:                        return MA_ALREADY_IN_USE;
-        case MA_DSERR_CONTROLUNAVAIL:                   return MA_INVALID_OPERATION;
-        /*case MA_DSERR_INVALIDPARAM:                    return MA_INVALID_ARGS;*/      /* E_INVALIDARG */
-        case MA_DSERR_INVALIDCALL:                      return MA_INVALID_OPERATION;
-        /*case MA_DSERR_GENERIC:                          return MA_ERROR;*/            /* E_FAIL */
-        case MA_DSERR_PRIOLEVELNEEDED:                  return MA_INVALID_OPERATION;
-        /*case MA_DSERR_OUTOFMEMORY:                      return MA_OUT_OF_MEMORY;*/    /* E_OUTOFMEMORY */
-        case MA_DSERR_BADFORMAT:                        return MA_FORMAT_NOT_SUPPORTED;
-        /*case MA_DSERR_UNSUPPORTED:                      return MA_NOT_IMPLEMENTED;*/  /* E_NOTIMPL */
-        case MA_DSERR_NODRIVER:                         return MA_FAILED_TO_INIT_BACKEND;
-        case MA_DSERR_ALREADYINITIALIZED:               return MA_DEVICE_ALREADY_INITIALIZED;
-        case MA_DSERR_NOAGGREGATION:                    return MA_ERROR;
-        case MA_DSERR_BUFFERLOST:                       return MA_UNAVAILABLE;
-        case MA_DSERR_OTHERAPPHASPRIO:                  return MA_ACCESS_DENIED;
-        case MA_DSERR_UNINITIALIZED:                    return MA_DEVICE_NOT_INITIALIZED;
-        /*case MA_DSERR_NOINTERFACE:                      return MA_API_NOT_FOUND;*/    /* E_NOINTERFACE */
-        /*case MA_DSERR_ACCESSDENIED:                     return MA_ACCESS_DENIED;*/    /* E_ACCESSDENIED */
-        case MA_DSERR_BUFFERTOOSMALL:                   return MA_NO_SPACE;
-        case MA_DSERR_DS8_REQUIRED:                     return MA_INVALID_OPERATION;
-        case MA_DSERR_SENDLOOP:                         return MA_DEADLOCK;
-        case MA_DSERR_BADSENDBUFFERGUID:                return MA_INVALID_ARGS;
-        case MA_DSERR_OBJECTNOTFOUND:                   return MA_NO_DEVICE;
-        case MA_DSERR_FXUNAVAILABLE:                    return MA_UNAVAILABLE;
-
-        default:                                        return MA_ERROR;
-    }
-}
-
-typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(LPVOID pvReserved, DWORD  dwCoInit);
-typedef void    (WINAPI * MA_PFN_CoUninitialize)(void);
-typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv);
-typedef void    (WINAPI * MA_PFN_CoTaskMemFree)(LPVOID pv);
-typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(PROPVARIANT *pvar);
-typedef int     (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, LPOLESTR lpsz, int cchMax);
-
-typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(void);
-typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(void);
-
-/* Microsoft documents these APIs as returning LSTATUS, but the Win32 API shipping with some compilers do not define it. It's just a LONG. */
-typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
-typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey);
-typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
-#endif
-
-
-#define MA_DEFAULT_PLAYBACK_DEVICE_NAME    "Default Playback Device"
-#define MA_DEFAULT_CAPTURE_DEVICE_NAME     "Default Capture Device"
-
-
-MA_API const char* ma_log_level_to_string(ma_uint32 logLevel)
-{
-    switch (logLevel)
-    {
-        case MA_LOG_LEVEL_VERBOSE: return "";
-        case MA_LOG_LEVEL_INFO:    return "INFO";
-        case MA_LOG_LEVEL_WARNING: return "WARNING";
-        case MA_LOG_LEVEL_ERROR:   return "ERROR";
-        default:                   return "ERROR";
-    }
-}
-
-/* Posts a log message. */
-static void ma_post_log_message(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-{
-    if (pContext == NULL) {
-        if (pDevice != NULL) {
-            pContext = pDevice->pContext;
-        }
-    }
-
-    /* All logs must be output when debug output is enabled. */
-#if defined(MA_DEBUG_OUTPUT)
-    printf("%s: %s\n", ma_log_level_to_string(logLevel), message);
-#endif
-
-    if (pContext == NULL) {
-        return;
-    }
-
-#if defined(MA_LOG_LEVEL)
-    if (logLevel <= MA_LOG_LEVEL) {
-        ma_log_proc onLog;
-
-        onLog = pContext->logCallback;
-        if (onLog) {
-            onLog(pContext, pDevice, logLevel, message);
-        }
-    }
-#endif
-}
-
-/*
-We need to emulate _vscprintf() for the VC6 build. This can be more efficient, but since it's only VC6, and it's just a
-logging function, I'm happy to keep this simple. In the VC6 build we can implement this in terms of _vsnprintf().
-*/
-#if defined(_MSC_VER) && _MSC_VER < 1900
-int ma_vscprintf(const char* format, va_list args)
-{
-#if _MSC_VER > 1200
-    return _vscprintf(format, args);
-#else
-    int result;
-    char* pTempBuffer = NULL;
-    size_t tempBufferCap = 1024;
-
-    if (format == NULL) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    for (;;) {
-        char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, NULL);    /* TODO: Add support for custom memory allocators? */
-        if (pNewTempBuffer == NULL) {
-            ma_free(pTempBuffer, NULL);
-            errno = ENOMEM;
-            return -1;  /* Out of memory. */
-        }
-
-        pTempBuffer = pNewTempBuffer;
-
-        result = _vsnprintf(pTempBuffer, tempBufferCap, format, args);
-        ma_free(pTempBuffer, NULL);
-
-        if (result != -1) {
-            break;  /* Got it. */
-        }
-
-        /* Buffer wasn't big enough. Ideally it'd be nice to use an error code to know the reason for sure, but this is reliable enough. */
-        tempBufferCap *= 2;
-    }
-
-    return result;
-#endif
-}
-#endif
-
-/* Posts a formatted log message. */
-static void ma_post_log_messagev(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* pFormat, va_list args)
-{
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || ((!defined(_MSC_VER) || _MSC_VER >= 1900) && !defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-    {
-        char pFormattedMessage[1024];
-        vsnprintf(pFormattedMessage, sizeof(pFormattedMessage), pFormat, args);
-        ma_post_log_message(pContext, pDevice, logLevel, pFormattedMessage);
-    }
-#else
-    {
-        /*
-        Without snprintf() we need to first measure the string and then heap allocate it. I'm only aware of Visual Studio having support for this without snprintf(), so we'll
-        need to restrict this branch to Visual Studio. For other compilers we need to just not support formatted logging because I don't want the security risk of overflowing
-        a fixed sized stack allocated buffer.
-        */
-    #if defined(_MSC_VER) && _MSC_VER >= 1200   /* 1200 = VC6 */
-        int formattedLen;
-        va_list args2;
-
-    #if _MSC_VER >= 1800
-        va_copy(args2, args);
-    #else
-        args2 = args;
-    #endif
-        formattedLen = ma_vscprintf(pFormat, args2);
-        va_end(args2);
-
-        if (formattedLen > 0) {
-            char* pFormattedMessage = NULL;
-            ma_allocation_callbacks* pAllocationCallbacks = NULL;
-
-            /* Make sure we have a context so we can allocate memory. */
-            if (pContext == NULL) {
-                if (pDevice != NULL) {
-                    pContext = pDevice->pContext;
-                }
-            }
-
-            if (pContext != NULL) {
-                pAllocationCallbacks = &pContext->allocationCallbacks;
-            }
-
-            pFormattedMessage = (char*)ma_malloc(formattedLen + 1, pAllocationCallbacks);
-            if (pFormattedMessage != NULL) {
-                /* We'll get errors on newer versions of Visual Studio if we try to use vsprintf().  */
-            #if _MSC_VER >= 1400    /* 1400 = Visual Studio 2005 */
-                vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args);
-            #else
-                vsprintf(pFormattedMessage, pFormat, args);
-            #endif
-
-                ma_post_log_message(pContext, pDevice, logLevel, pFormattedMessage);
-                ma_free(pFormattedMessage, pAllocationCallbacks);
-            }
-        }
-    #else
-        /* Can't do anything because we don't have a safe way of to emulate vsnprintf() without a manual solution. */
-        (void)pContext;
-        (void)pDevice;
-        (void)logLevel;
-        (void)pFormat;
-        (void)args;
-    #endif
-    }
-#endif
-}
-
-MA_API void ma_post_log_messagef(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* pFormat, ...)
-{
-    va_list args;
-    va_start(args, pFormat);
-    {
-        ma_post_log_messagev(pContext, pDevice, logLevel, pFormat, args);
-    }
-    va_end(args);
-}
-
-/* Posts an log message. Throw a breakpoint in here if you're needing to debug. The return value is always "resultCode". */
-static ma_result ma_context_post_error(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message, ma_result resultCode)
-{
-    ma_post_log_message(pContext, pDevice, logLevel, message);
-    return resultCode;
-}
-
-static ma_result ma_post_error(ma_device* pDevice, ma_uint32 logLevel, const char* message, ma_result resultCode)
-{
-    return ma_context_post_error(NULL, pDevice, logLevel, message, resultCode);
-}
-
-
-/*******************************************************************************
-
-Timing
-
-*******************************************************************************/
-#ifdef MA_WIN32
-    static LARGE_INTEGER g_ma_TimerFrequency;   /* <-- Initialized to zero since it's static. */
-    static void ma_timer_init(ma_timer* pTimer)
-    {
-        LARGE_INTEGER counter;
-
-        if (g_ma_TimerFrequency.QuadPart == 0) {
-            QueryPerformanceFrequency(&g_ma_TimerFrequency);
-        }
-
-        QueryPerformanceCounter(&counter);
-        pTimer->counter = counter.QuadPart;
-    }
-
-    static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        LARGE_INTEGER counter;
-        if (!QueryPerformanceCounter(&counter)) {
-            return 0;
-        }
-
-        return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart;
-    }
-#elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
-    static ma_uint64 g_ma_TimerFrequency = 0;
-    static void ma_timer_init(ma_timer* pTimer)
-    {
-        mach_timebase_info_data_t baseTime;
-        mach_timebase_info(&baseTime);
-        g_ma_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer;
-
-        pTimer->counter = mach_absolute_time();
-    }
-
-    static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        ma_uint64 newTimeCounter = mach_absolute_time();
-        ma_uint64 oldTimeCounter = pTimer->counter;
-
-        return (newTimeCounter - oldTimeCounter) / g_ma_TimerFrequency;
-    }
-#elif defined(MA_EMSCRIPTEN)
-    static MA_INLINE void ma_timer_init(ma_timer* pTimer)
-    {
-        pTimer->counterD = emscripten_get_now();
-    }
-
-    static MA_INLINE double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        return (emscripten_get_now() - pTimer->counterD) / 1000;    /* Emscripten is in milliseconds. */
-    }
-#else
-    #if _POSIX_C_SOURCE >= 199309L
-        #if defined(CLOCK_MONOTONIC)
-            #define MA_CLOCK_ID CLOCK_MONOTONIC
-        #else
-            #define MA_CLOCK_ID CLOCK_REALTIME
-        #endif
-
-        static void ma_timer_init(ma_timer* pTimer)
-        {
-            struct timespec newTime;
-            clock_gettime(MA_CLOCK_ID, &newTime);
-
-            pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
-        }
-
-        static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-        {
-            ma_uint64 newTimeCounter;
-            ma_uint64 oldTimeCounter;
-
-            struct timespec newTime;
-            clock_gettime(MA_CLOCK_ID, &newTime);
-
-            newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
-            oldTimeCounter = pTimer->counter;
-
-            return (newTimeCounter - oldTimeCounter) / 1000000000.0;
-        }
-    #else
-        static void ma_timer_init(ma_timer* pTimer)
-        {
-            struct timeval newTime;
-            gettimeofday(&newTime, NULL);
-
-            pTimer->counter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
-        }
-
-        static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-        {
-            ma_uint64 newTimeCounter;
-            ma_uint64 oldTimeCounter;
-
-            struct timeval newTime;
-            gettimeofday(&newTime, NULL);
-
-            newTimeCounter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
-            oldTimeCounter = pTimer->counter;
-
-            return (newTimeCounter - oldTimeCounter) / 1000000.0;
-        }
-    #endif
-#endif
-
-
-/*******************************************************************************
-
-Dynamic Linking
-
-*******************************************************************************/
-MA_API ma_handle ma_dlopen(ma_context* pContext, const char* filename)
-{
-    ma_handle handle;
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_VERBOSE
-    if (pContext != NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Loading library: ", filename);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_VERBOSE, message);
-    }
-#endif
-
-#ifdef _WIN32
-#ifdef MA_WIN32_DESKTOP
-    handle = (ma_handle)LoadLibraryA(filename);
-#else
-    /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
-    WCHAR filenameW[4096];
-    if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) {
-        handle = NULL;
-    } else {
-        handle = (ma_handle)LoadPackagedLibrary(filenameW, 0);
-    }
-#endif
-#else
-    handle = (ma_handle)dlopen(filename, RTLD_NOW);
-#endif
-
-    /*
-    I'm not considering failure to load a library an error nor a warning because seamlessly falling through to a lower-priority
-    backend is a deliberate design choice. Instead I'm logging it as an informational message.
-    */
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_INFO
-    if (handle == NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Failed to load library: ", filename);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, message);
-    }
-#endif
-
-    (void)pContext; /* It's possible for pContext to be unused. */
-    return handle;
-}
-
-MA_API void ma_dlclose(ma_context* pContext, ma_handle handle)
-{
-#ifdef _WIN32
-    FreeLibrary((HMODULE)handle);
-#else
-    dlclose((void*)handle);
-#endif
-
-    (void)pContext;
-}
-
-MA_API ma_proc ma_dlsym(ma_context* pContext, ma_handle handle, const char* symbol)
-{
-    ma_proc proc;
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_VERBOSE
-    if (pContext != NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Loading symbol: ", symbol);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_VERBOSE, message);
-    }
-#endif
-
-#ifdef _WIN32
-    proc = (ma_proc)GetProcAddress((HMODULE)handle, symbol);
-#else
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-    proc = (ma_proc)dlsym((void*)handle, symbol);
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-    #pragma GCC diagnostic pop
-#endif
-#endif
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_WARNING
-    if (handle == NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Failed to load symbol: ", symbol);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_WARNING, message);
-    }
-#endif
-
-    (void)pContext; /* It's possible for pContext to be unused. */
-    return proc;
-}
-
-
-#if 0
-static ma_uint32 ma_get_closest_standard_sample_rate(ma_uint32 sampleRateIn)
-{
-    ma_uint32 closestRate = 0;
-    ma_uint32 closestDiff = 0xFFFFFFFF;
-    size_t iStandardRate;
-
-    for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) {
-        ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate];
-        ma_uint32 diff;
-
-        if (sampleRateIn > standardRate) {
-            diff = sampleRateIn - standardRate;
-        } else {
-            diff = standardRate - sampleRateIn;
-        }
-
-        if (diff == 0) {
-            return standardRate;    /* The input sample rate is a standard rate. */
-        }
-
-        if (closestDiff > diff) {
-            closestDiff = diff;
-            closestRate = standardRate;
-        }
-    }
-
-    return closestRate;
-}
-#endif
-
-
-static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount)
-{
-    float masterVolumeFactor;
-
-    ma_device_get_master_volume(pDevice, &masterVolumeFactor);  /* Use ma_device_get_master_volume() to ensure the volume is loaded atomically. */
-
-    if (pDevice->onData) {
-        if (!pDevice->noPreZeroedOutputBuffer && pFramesOut != NULL) {
-            ma_silence_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels);
-        }
-
-        /* Volume control of input makes things a bit awkward because the input buffer is read-only. We'll need to use a temp buffer and loop in this case. */
-        if (pFramesIn != NULL && masterVolumeFactor < 1) {
-            ma_uint8 tempFramesIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            ma_uint32 bpfCapture  = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-            ma_uint32 bpfPlayback = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-            ma_uint32 totalFramesProcessed = 0;
-            while (totalFramesProcessed < frameCount) {
-                ma_uint32 framesToProcessThisIteration = frameCount - totalFramesProcessed;
-                if (framesToProcessThisIteration > sizeof(tempFramesIn)/bpfCapture) {
-                    framesToProcessThisIteration = sizeof(tempFramesIn)/bpfCapture;
-                }
-
-                ma_copy_and_apply_volume_factor_pcm_frames(tempFramesIn, ma_offset_ptr(pFramesIn, totalFramesProcessed*bpfCapture), framesToProcessThisIteration, pDevice->capture.format, pDevice->capture.channels, masterVolumeFactor);
-
-                pDevice->onData(pDevice, ma_offset_ptr(pFramesOut, totalFramesProcessed*bpfPlayback), tempFramesIn, framesToProcessThisIteration);
-
-                totalFramesProcessed += framesToProcessThisIteration;
-            }
-        } else {
-            pDevice->onData(pDevice, pFramesOut, pFramesIn, frameCount);
-        }
-
-        /* Volume control and clipping for playback devices. */
-        if (pFramesOut != NULL) {
-            if (masterVolumeFactor < 1) {
-                if (pFramesIn == NULL) {    /* <-- In full-duplex situations, the volume will have been applied to the input samples before the data callback. Applying it again post-callback will incorrectly compound it. */
-                    ma_apply_volume_factor_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels, masterVolumeFactor);
-                }
-            }
-
-            if (!pDevice->noClip && pDevice->playback.format == ma_format_f32) {
-                ma_clip_pcm_frames_f32((float*)pFramesOut, frameCount, pDevice->playback.channels);
-            }
-        }
-    }
-}
-
-
-
-/* A helper function for reading sample data from the client. */
-static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 frameCount, void* pFramesOut)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCount > 0);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pDevice->playback.converter.isPassthrough) {
-        ma_device__on_data(pDevice, pFramesOut, NULL, frameCount);
-    } else {
-        ma_result result;
-        ma_uint64 totalFramesReadOut;
-        ma_uint64 totalFramesReadIn;
-        void* pRunningFramesOut;
-
-        totalFramesReadOut = 0;
-        totalFramesReadIn  = 0;
-        pRunningFramesOut  = pFramesOut;
-
-        while (totalFramesReadOut < frameCount) {
-            ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In client format. */
-            ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-            ma_uint64 framesToReadThisIterationIn;
-            ma_uint64 framesReadThisIterationIn;
-            ma_uint64 framesToReadThisIterationOut;
-            ma_uint64 framesReadThisIterationOut;
-            ma_uint64 requiredInputFrameCount;
-
-            framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
-            framesToReadThisIterationIn = framesToReadThisIterationOut;
-            if (framesToReadThisIterationIn > intermediaryBufferCap) {
-                framesToReadThisIterationIn = intermediaryBufferCap;
-            }
-
-            requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, framesToReadThisIterationOut);
-            if (framesToReadThisIterationIn > requiredInputFrameCount) {
-                framesToReadThisIterationIn = requiredInputFrameCount;
-            }
-
-            if (framesToReadThisIterationIn > 0) {
-                ma_device__on_data(pDevice, pIntermediaryBuffer, NULL, (ma_uint32)framesToReadThisIterationIn);
-                totalFramesReadIn += framesToReadThisIterationIn;
-            }
-
-            /*
-            At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
-            input frames, we still want to try processing frames because there may some output frames generated from cached input data.
-            */
-            framesReadThisIterationIn  = framesToReadThisIterationIn;
-            framesReadThisIterationOut = framesToReadThisIterationOut;
-            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-
-            totalFramesReadOut += framesReadThisIterationOut;
-            pRunningFramesOut   = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-
-            if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) {
-                break;  /* We're done. */
-            }
-        }
-    }
-}
-
-/* A helper for sending sample data to the client. */
-static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCountInDeviceFormat > 0);
-    MA_ASSERT(pFramesInDeviceFormat != NULL);
-
-    if (pDevice->capture.converter.isPassthrough) {
-        ma_device__on_data(pDevice, NULL, pFramesInDeviceFormat, frameCountInDeviceFormat);
-    } else {
-        ma_result result;
-        ma_uint8 pFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-        ma_uint64 framesInClientFormatCap = sizeof(pFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-        ma_uint64 totalDeviceFramesProcessed = 0;
-        ma_uint64 totalClientFramesProcessed = 0;
-        const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
-
-        /* We just keep going until we've exhaused all of our input frames and cannot generate any more output frames. */
-        for (;;) {
-            ma_uint64 deviceFramesProcessedThisIteration;
-            ma_uint64 clientFramesProcessedThisIteration;
-
-            deviceFramesProcessedThisIteration = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
-            clientFramesProcessedThisIteration = framesInClientFormatCap;
-
-            result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &deviceFramesProcessedThisIteration, pFramesInClientFormat, &clientFramesProcessedThisIteration);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-
-            if (clientFramesProcessedThisIteration > 0) {
-                ma_device__on_data(pDevice, NULL, pFramesInClientFormat, (ma_uint32)clientFramesProcessedThisIteration);    /* Safe cast. */
-            }
-
-            pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, deviceFramesProcessedThisIteration * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-            totalDeviceFramesProcessed  += deviceFramesProcessedThisIteration;
-            totalClientFramesProcessed  += clientFramesProcessedThisIteration;
-
-            if (deviceFramesProcessedThisIteration == 0 && clientFramesProcessedThisIteration == 0) {
-                break;  /* We're done. */
-            }
-        }
-    }
-}
-
-static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat, ma_pcm_rb* pRB)
-{
-    ma_result result;
-    ma_uint32 totalDeviceFramesProcessed = 0;
-    const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCountInDeviceFormat > 0);
-    MA_ASSERT(pFramesInDeviceFormat != NULL);
-    MA_ASSERT(pRB != NULL);
-
-    /* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */
-    for (;;) {
-        ma_uint32 framesToProcessInDeviceFormat = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
-        ma_uint32 framesToProcessInClientFormat = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-        ma_uint64 framesProcessedInDeviceFormat;
-        ma_uint64 framesProcessedInClientFormat;
-        void* pFramesInClientFormat;
-
-        result = ma_pcm_rb_acquire_write(pRB, &framesToProcessInClientFormat, &pFramesInClientFormat);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to acquire capture PCM frames from ring buffer.", result);
-            break;
-        }
-
-        if (framesToProcessInClientFormat == 0) {
-            if (ma_pcm_rb_pointer_distance(pRB) == (ma_int32)ma_pcm_rb_get_subbuffer_size(pRB)) {
-                break;  /* Overrun. Not enough room in the ring buffer for input frame. Excess frames are dropped. */
-            }
-        }
-
-        /* Convert. */
-        framesProcessedInDeviceFormat = framesToProcessInDeviceFormat;
-        framesProcessedInClientFormat = framesToProcessInClientFormat;
-        result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &framesProcessedInDeviceFormat, pFramesInClientFormat, &framesProcessedInClientFormat);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        result = ma_pcm_rb_commit_write(pRB, (ma_uint32)framesProcessedInClientFormat, pFramesInClientFormat);  /* Safe cast. */
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to commit capture PCM frames to ring buffer.", result);
-            break;
-        }
-
-        pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, framesProcessedInDeviceFormat * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-        totalDeviceFramesProcessed += (ma_uint32)framesProcessedInDeviceFormat; /* Safe cast. */
-
-        /* We're done when we're unable to process any client nor device frames. */
-        if (framesProcessedInClientFormat == 0 && framesProcessedInDeviceFormat == 0) {
-            break;  /* Done. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice, ma_uint32 frameCount, void* pFramesInInternalFormat, ma_pcm_rb* pRB)
-{
-    ma_result result;
-    ma_uint8 playbackFramesInExternalFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint8 silentInputFrames[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 totalFramesToReadFromClient;
-    ma_uint32 totalFramesReadFromClient;
-    ma_uint32 totalFramesReadOut = 0;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCount > 0);
-    MA_ASSERT(pFramesInInternalFormat != NULL);
-    MA_ASSERT(pRB != NULL);
-
-    /*
-    Sitting in the ring buffer should be captured data from the capture callback in external format. If there's not enough data in there for
-    the whole frameCount frames we just use silence instead for the input data.
-    */
-    MA_ZERO_MEMORY(silentInputFrames, sizeof(silentInputFrames));
-
-    /* We need to calculate how many output frames are required to be read from the client to completely fill frameCount internal frames. */
-    totalFramesToReadFromClient = (ma_uint32)ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, frameCount);
-    totalFramesReadFromClient = 0;
-    while (totalFramesReadFromClient < totalFramesToReadFromClient && ma_device_is_started(pDevice)) {
-        ma_uint32 framesRemainingFromClient;
-        ma_uint32 framesToProcessFromClient;
-        ma_uint32 inputFrameCount;
-        void* pInputFrames;
-
-        framesRemainingFromClient = (totalFramesToReadFromClient - totalFramesReadFromClient);
-        framesToProcessFromClient = sizeof(playbackFramesInExternalFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-        if (framesToProcessFromClient > framesRemainingFromClient) {
-            framesToProcessFromClient = framesRemainingFromClient;
-        }
-
-        /* We need to grab captured samples before firing the callback. If there's not enough input samples we just pass silence. */
-        inputFrameCount = framesToProcessFromClient;
-        result = ma_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames);
-        if (result == MA_SUCCESS) {
-            if (inputFrameCount > 0) {
-                /* Use actual input frames. */
-                ma_device__on_data(pDevice, playbackFramesInExternalFormat, pInputFrames, inputFrameCount);
-            } else {
-                if (ma_pcm_rb_pointer_distance(pRB) == 0) {
-                    break;  /* Underrun. */
-                }
-            }
-
-            /* We're done with the captured samples. */
-            result = ma_pcm_rb_commit_read(pRB, inputFrameCount, pInputFrames);
-            if (result != MA_SUCCESS) {
-                break; /* Don't know what to do here... Just abandon ship. */
-            }
-        } else {
-            /* Use silent input frames. */
-            inputFrameCount = ma_min(
-                sizeof(playbackFramesInExternalFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels),
-                sizeof(silentInputFrames)              / ma_get_bytes_per_frame(pDevice->capture.format,  pDevice->capture.channels)
-            );
-
-            ma_device__on_data(pDevice, playbackFramesInExternalFormat, silentInputFrames, inputFrameCount);
-        }
-
-        /* We have samples in external format so now we need to convert to internal format and output to the device. */
-        {
-            ma_uint64 framesConvertedIn  = inputFrameCount;
-            ma_uint64 framesConvertedOut = (frameCount - totalFramesReadOut);
-            ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackFramesInExternalFormat, &framesConvertedIn, pFramesInInternalFormat, &framesConvertedOut);
-
-            totalFramesReadFromClient += (ma_uint32)framesConvertedIn;  /* Safe cast. */
-            totalFramesReadOut        += (ma_uint32)framesConvertedOut; /* Safe cast. */
-            pFramesInInternalFormat    = ma_offset_ptr(pFramesInInternalFormat, framesConvertedOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-/* A helper for changing the state of the device. */
-static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_uint32 newState)
-{
-    c89atomic_exchange_32(&pDevice->state, newState);
-}
-
-
-#ifdef MA_WIN32
-    GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM        = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-    GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-    /*GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW       = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
-    /*GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW      = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
-#endif
-
-
-
-MA_API ma_uint32 ma_get_format_priority_index(ma_format format) /* Lower = better. */
-{
-    ma_uint32 i;
-    for (i = 0; i < ma_countof(g_maFormatPriorities); ++i) {
-        if (g_maFormatPriorities[i] == format) {
-            return i;
-        }
-    }
-
-    /* Getting here means the format could not be found or is equal to ma_format_unknown. */
-    return (ma_uint32)-1;
-}
-
-static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType);
-
-
-static ma_bool32 ma_device_descriptor_is_valid(const ma_device_descriptor* pDeviceDescriptor)
-{
-    if (pDeviceDescriptor == NULL) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->format == ma_format_unknown) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->channels < MA_MIN_CHANNELS || pDeviceDescriptor->channels > MA_MAX_CHANNELS) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->sampleRate == 0) {
-        return MA_FALSE;
-    }
-
-    return MA_TRUE;
-}
-
-
-static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
-{
-    ma_result result = MA_SUCCESS;
-    ma_bool32 exitLoop = MA_FALSE;
-    ma_uint8  capturedDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint8  playbackDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 capturedDeviceDataCapInFrames = 0;
-    ma_uint32 playbackDeviceDataCapInFrames = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* Just some quick validation on the device type and the available callbacks. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        if (pDevice->pContext->callbacks.onDeviceRead == NULL) {
-            return MA_NOT_IMPLEMENTED;
-        }
-
-        capturedDeviceDataCapInFrames = sizeof(capturedDeviceData) / ma_get_bytes_per_frame(pDevice->capture.internalFormat,  pDevice->capture.internalChannels);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->pContext->callbacks.onDeviceWrite == NULL) {
-            return MA_NOT_IMPLEMENTED;
-        }
-
-        playbackDeviceDataCapInFrames = sizeof(playbackDeviceData) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    /* NOTE: The device was started outside of this function, in the worker thread. */
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && !exitLoop) {
-        switch (pDevice->type) {
-            case ma_device_type_duplex:
-            {
-                /* The process is: onDeviceRead() -> convert -> callback -> convert -> onDeviceWrite() */
-                ma_uint32 totalCapturedDeviceFramesProcessed = 0;
-                ma_uint32 capturedDevicePeriodSizeInFrames = ma_min(pDevice->capture.internalPeriodSizeInFrames, pDevice->playback.internalPeriodSizeInFrames);
-
-                while (totalCapturedDeviceFramesProcessed < capturedDevicePeriodSizeInFrames) {
-                    ma_uint32 capturedDeviceFramesRemaining;
-                    ma_uint32 capturedDeviceFramesProcessed;
-                    ma_uint32 capturedDeviceFramesToProcess;
-                    ma_uint32 capturedDeviceFramesToTryProcessing = capturedDevicePeriodSizeInFrames - totalCapturedDeviceFramesProcessed;
-                    if (capturedDeviceFramesToTryProcessing > capturedDeviceDataCapInFrames) {
-                        capturedDeviceFramesToTryProcessing = capturedDeviceDataCapInFrames;
-                    }
-
-                    result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, capturedDeviceFramesToTryProcessing, &capturedDeviceFramesToProcess);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    capturedDeviceFramesRemaining = capturedDeviceFramesToProcess;
-                    capturedDeviceFramesProcessed = 0;
-
-                    /* At this point we have our captured data in device format and we now need to convert it to client format. */
-                    for (;;) {
-                        ma_uint8  capturedClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                        ma_uint8  playbackClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                        ma_uint32 capturedClientDataCapInFrames = sizeof(capturedClientData) / ma_get_bytes_per_frame(pDevice->capture.format,  pDevice->capture.channels);
-                        ma_uint32 playbackClientDataCapInFrames = sizeof(playbackClientData) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-                        ma_uint64 capturedClientFramesToProcessThisIteration = ma_min(capturedClientDataCapInFrames, playbackClientDataCapInFrames);
-                        ma_uint64 capturedDeviceFramesToProcessThisIteration = capturedDeviceFramesRemaining;
-                        ma_uint8* pRunningCapturedDeviceFrames = ma_offset_ptr(capturedDeviceData, capturedDeviceFramesProcessed * ma_get_bytes_per_frame(pDevice->capture.internalFormat,  pDevice->capture.internalChannels));
-
-                        /* Convert capture data from device format to client format. */
-                        result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningCapturedDeviceFrames, &capturedDeviceFramesToProcessThisIteration, capturedClientData, &capturedClientFramesToProcessThisIteration);
-                        if (result != MA_SUCCESS) {
-                            break;
-                        }
-
-                        /*
-                        If we weren't able to generate any output frames it must mean we've exhaused all of our input. The only time this would not be the case is if capturedClientData was too small
-                        which should never be the case when it's of the size MA_DATA_CONVERTER_STACK_BUFFER_SIZE.
-                        */
-                        if (capturedClientFramesToProcessThisIteration == 0) {
-                            break;
-                        }
-
-                        ma_device__on_data(pDevice, playbackClientData, capturedClientData, (ma_uint32)capturedClientFramesToProcessThisIteration);    /* Safe cast .*/
-
-                        capturedDeviceFramesProcessed += (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
-                        capturedDeviceFramesRemaining -= (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
-
-                        /* At this point the playbackClientData buffer should be holding data that needs to be written to the device. */
-                        for (;;) {
-                            ma_uint64 convertedClientFrameCount = capturedClientFramesToProcessThisIteration;
-                            ma_uint64 convertedDeviceFrameCount = playbackDeviceDataCapInFrames;
-                            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackClientData, &convertedClientFrameCount, playbackDeviceData, &convertedDeviceFrameCount);
-                            if (result != MA_SUCCESS) {
-                                break;
-                            }
-
-                            result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, (ma_uint32)convertedDeviceFrameCount, NULL);   /* Safe cast. */
-                            if (result != MA_SUCCESS) {
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            capturedClientFramesToProcessThisIteration -= (ma_uint32)convertedClientFrameCount;  /* Safe cast. */
-                            if (capturedClientFramesToProcessThisIteration == 0) {
-                                break;
-                            }
-                        }
-
-                        /* In case an error happened from ma_device_write__null()... */
-                        if (result != MA_SUCCESS) {
-                            exitLoop = MA_TRUE;
-                            break;
-                        }
-                    }
-
-                    totalCapturedDeviceFramesProcessed += capturedDeviceFramesProcessed;
-                }
-            } break;
-
-            case ma_device_type_capture:
-            case ma_device_type_loopback:
-            {
-                ma_uint32 periodSizeInFrames = pDevice->capture.internalPeriodSizeInFrames;
-                ma_uint32 framesReadThisPeriod = 0;
-                while (framesReadThisPeriod < periodSizeInFrames) {
-                    ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesReadThisPeriod;
-                    ma_uint32 framesProcessed;
-                    ma_uint32 framesToReadThisIteration = framesRemainingInPeriod;
-                    if (framesToReadThisIteration > capturedDeviceDataCapInFrames) {
-                        framesToReadThisIteration = capturedDeviceDataCapInFrames;
-                    }
-
-                    result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, framesToReadThisIteration, &framesProcessed);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    ma_device__send_frames_to_client(pDevice, framesProcessed, capturedDeviceData);
-
-                    framesReadThisPeriod += framesProcessed;
-                }
-            } break;
-
-            case ma_device_type_playback:
-            {
-                /* We write in chunks of the period size, but use a stack allocated buffer for the intermediary. */
-                ma_uint32 periodSizeInFrames = pDevice->playback.internalPeriodSizeInFrames;
-                ma_uint32 framesWrittenThisPeriod = 0;
-                while (framesWrittenThisPeriod < periodSizeInFrames) {
-                    ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesWrittenThisPeriod;
-                    ma_uint32 framesProcessed;
-                    ma_uint32 framesToWriteThisIteration = framesRemainingInPeriod;
-                    if (framesToWriteThisIteration > playbackDeviceDataCapInFrames) {
-                        framesToWriteThisIteration = playbackDeviceDataCapInFrames;
-                    }
-
-                    ma_device__read_frames_from_client(pDevice, framesToWriteThisIteration, playbackDeviceData);
-
-                    result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, framesToWriteThisIteration, &framesProcessed);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    framesWrittenThisPeriod += framesProcessed;
-                }
-            } break;
-
-            /* Should never get here. */
-            default: break;
-        }
-    }
-
-    return result;
-}
-
-
-
-/*******************************************************************************
-
-Null Backend
-
-*******************************************************************************/
-#ifdef MA_HAS_NULL
-
-#define MA_DEVICE_OP_NONE__NULL    0
-#define MA_DEVICE_OP_START__NULL   1
-#define MA_DEVICE_OP_SUSPEND__NULL 2
-#define MA_DEVICE_OP_KILL__NULL    3
-
-static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData)
-{
-    ma_device* pDevice = (ma_device*)pData;
-    MA_ASSERT(pDevice != NULL);
-
-    for (;;) {  /* Keep the thread alive until the device is uninitialized. */
-        ma_uint32 operation;
-
-        /* Wait for an operation to be requested. */
-        ma_event_wait(&pDevice->null_device.operationEvent);
-
-        /* At this point an event should have been triggered. */
-        operation = pDevice->null_device.operation;
-
-        /* Starting the device needs to put the thread into a loop. */
-        if (operation == MA_DEVICE_OP_START__NULL) {
-            /* Reset the timer just in case. */
-            ma_timer_init(&pDevice->null_device.timer);
-
-            /* Getting here means a suspend or kill operation has been requested. */
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;
-        }
-
-        /* Suspending the device means we need to stop the timer and just continue the loop. */
-        if (operation == MA_DEVICE_OP_SUSPEND__NULL) {
-            /* We need to add the current run time to the prior run time, then reset the timer. */
-            pDevice->null_device.priorRunTime += ma_timer_get_time_in_seconds(&pDevice->null_device.timer);
-            ma_timer_init(&pDevice->null_device.timer);
-
-            /* We're done. */
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;
-        }
-
-        /* Killing the device means we need to get out of this loop so that this thread can terminate. */
-        if (operation == MA_DEVICE_OP_KILL__NULL) {
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            break;
-        }
-
-        /* Getting a signal on a "none" operation probably means an error. Return invalid operation. */
-        if (operation == MA_DEVICE_OP_NONE__NULL) {
-            MA_ASSERT(MA_FALSE);  /* <-- Trigger this in debug mode to ensure developers are aware they're doing something wrong (or there's a bug in a miniaudio). */
-            pDevice->null_device.operationResult = MA_INVALID_OPERATION;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;   /* Continue the loop. Don't terminate. */
-        }
-    }
-
-    return (ma_thread_result)0;
-}
-
-static ma_result ma_device_do_operation__null(ma_device* pDevice, ma_uint32 operation)
-{
-    ma_result result;
-
-    /*
-    TODO: Need to review this and consider just using mutual exclusion. I think the original motivation
-    for this was to just post the event to a queue and return immediately, but that has since changed
-    and now this function is synchronous. I think this can be simplified to just use a mutex.
-    */
-
-    /*
-    The first thing to do is wait for an operation slot to become available. We only have a single slot for this, but we could extend this later
-    to support queing of operations.
-    */
-    result = ma_semaphore_wait(&pDevice->null_device.operationSemaphore);
-    if (result != MA_SUCCESS) {
-        return result;  /* Failed to wait for the event. */
-    }
-
-    /*
-    When we get here it means the background thread is not referencing the operation code and it can be changed. After changing this we need to
-    signal an event to the worker thread to let it know that it can start work.
-    */
-    pDevice->null_device.operation = operation;
-
-    /* Once the operation code has been set, the worker thread can start work. */
-    if (ma_event_signal(&pDevice->null_device.operationEvent) != MA_SUCCESS) {
-        return MA_ERROR;
-    }
-
-    /* We want everything to be synchronous so we're going to wait for the worker thread to complete it's operation. */
-    if (ma_event_wait(&pDevice->null_device.operationCompletionEvent) != MA_SUCCESS) {
-        return MA_ERROR;
-    }
-
-    return pDevice->null_device.operationResult;
-}
-
-static ma_uint64 ma_device_get_total_run_time_in_frames__null(ma_device* pDevice)
-{
-    ma_uint32 internalSampleRate;
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        internalSampleRate = pDevice->capture.internalSampleRate;
-    } else {
-        internalSampleRate = pDevice->playback.internalSampleRate;
-    }
-
-    return (ma_uint64)((pDevice->null_device.priorRunTime + ma_timer_get_time_in_seconds(&pDevice->null_device.timer)) * internalSampleRate);
-}
-
-static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Playback Device", (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Capture Device", (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    (void)cbResult; /* Silence a static analysis warning. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__null(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (pDeviceID != NULL && pDeviceID->nullbackend != 0) {
-        return MA_NO_DEVICE;   /* Don't know the device. */
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Playback Device", (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Capture Device", (size_t)-1);
-    }
-
-    /* Support everything on the null backend. */
-    pDeviceInfo->nativeDataFormats[0].format     = ma_format_unknown;
-    pDeviceInfo->nativeDataFormats[0].channels   = 0;
-    pDeviceInfo->nativeDataFormats[0].sampleRate = 0;
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* Keep it clean and wait for the device thread to finish before returning. */
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_KILL__NULL);
-
-    /* Wait for the thread to finish before continuing. */
-    ma_thread_wait(&pDevice->null_device.deviceThread);
-
-    /* At this point the loop in the device thread is as good as terminated so we can uninitialize our events. */
-    ma_semaphore_uninit(&pDevice->null_device.operationSemaphore);
-    ma_event_uninit(&pDevice->null_device.operationCompletionEvent);
-    ma_event_uninit(&pDevice->null_device.operationEvent);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->null_device);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* The null backend supports everything exactly as we specify it. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        pDescriptorCapture->format     = (pDescriptorCapture->format     != ma_format_unknown) ? pDescriptorCapture->format     : MA_DEFAULT_FORMAT;
-        pDescriptorCapture->channels   = (pDescriptorCapture->channels   != 0)                 ? pDescriptorCapture->channels   : MA_DEFAULT_CHANNELS;
-        pDescriptorCapture->sampleRate = (pDescriptorCapture->sampleRate != 0)                 ? pDescriptorCapture->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-        if (pDescriptorCapture->channelMap[0] == MA_CHANNEL_NONE) {
-            ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        }
-
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        pDescriptorPlayback->format     = (pDescriptorPlayback->format     != ma_format_unknown) ? pDescriptorPlayback->format     : MA_DEFAULT_FORMAT;
-        pDescriptorPlayback->channels   = (pDescriptorPlayback->channels   != 0)                 ? pDescriptorPlayback->channels   : MA_DEFAULT_CHANNELS;
-        pDescriptorPlayback->sampleRate = (pDescriptorPlayback->sampleRate != 0)                 ? pDescriptorPlayback->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-        if (pDescriptorPlayback->channelMap[0] == MA_CHANNEL_NONE) {
-            ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        }
-
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-    }
-
-    /*
-    In order to get timing right, we need to create a thread that does nothing but keeps track of the timer. This timer is started when the
-    first period is "written" to it, and then stopped in ma_device_stop__null().
-    */
-    result = ma_event_init(&pDevice->null_device.operationEvent);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_event_init(&pDevice->null_device.operationCompletionEvent);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_semaphore_init(1, &pDevice->null_device.operationSemaphore);    /* <-- It's important that the initial value is set to 1. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_thread_create(&pDevice->null_device.deviceThread, pDevice->pContext->threadPriority, 0, ma_device_thread__null, pDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL);
-
-    c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_TRUE);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL);
-
-    c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_FALSE);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 totalPCMFramesProcessed;
-    ma_bool32 wasStartedOnEntry;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    wasStartedOnEntry = c89atomic_load_32(&pDevice->null_device.isStarted);
-
-    /* Keep going until everything has been read. */
-    totalPCMFramesProcessed = 0;
-    while (totalPCMFramesProcessed < frameCount) {
-        ma_uint64 targetFrame;
-
-        /* If there are any frames remaining in the current period, consume those first. */
-        if (pDevice->null_device.currentPeriodFramesRemainingPlayback > 0) {
-            ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed);
-            ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingPlayback;
-            if (framesToProcess > framesRemaining) {
-                framesToProcess = framesRemaining;
-            }
-
-            /* We don't actually do anything with pPCMFrames, so just mark it as unused to prevent a warning. */
-            (void)pPCMFrames;
-
-            pDevice->null_device.currentPeriodFramesRemainingPlayback -= framesToProcess;
-            totalPCMFramesProcessed += framesToProcess;
-        }
-
-        /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */
-        if (pDevice->null_device.currentPeriodFramesRemainingPlayback == 0) {
-            pDevice->null_device.currentPeriodFramesRemainingPlayback = 0;
-
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted) && !wasStartedOnEntry) {
-                result = ma_device_start__null(pDevice);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            }
-        }
-
-        /* If we've consumed the whole buffer we can return now. */
-        MA_ASSERT(totalPCMFramesProcessed <= frameCount);
-        if (totalPCMFramesProcessed == frameCount) {
-            break;
-        }
-
-        /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
-        targetFrame = pDevice->null_device.lastProcessedFramePlayback;
-        for (;;) {
-            ma_uint64 currentFrame;
-
-            /* Stop waiting if the device has been stopped. */
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
-                break;
-            }
-
-            currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice);
-            if (currentFrame >= targetFrame) {
-                break;
-            }
-
-            /* Getting here means we haven't yet reached the target sample, so continue waiting. */
-            ma_sleep(10);
-        }
-
-        pDevice->null_device.lastProcessedFramePlayback          += pDevice->playback.internalPeriodSizeInFrames;
-        pDevice->null_device.currentPeriodFramesRemainingPlayback = pDevice->playback.internalPeriodSizeInFrames;
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = totalPCMFramesProcessed;
-    }
-
-    return result;
-}
-
-static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 totalPCMFramesProcessed;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    /* Keep going until everything has been read. */
-    totalPCMFramesProcessed = 0;
-    while (totalPCMFramesProcessed < frameCount) {
-        ma_uint64 targetFrame;
-
-        /* If there are any frames remaining in the current period, consume those first. */
-        if (pDevice->null_device.currentPeriodFramesRemainingCapture > 0) {
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-            ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed);
-            ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingCapture;
-            if (framesToProcess > framesRemaining) {
-                framesToProcess = framesRemaining;
-            }
-
-            /* We need to ensure the output buffer is zeroed. */
-            MA_ZERO_MEMORY(ma_offset_ptr(pPCMFrames, totalPCMFramesProcessed*bpf), framesToProcess*bpf);
-
-            pDevice->null_device.currentPeriodFramesRemainingCapture -= framesToProcess;
-            totalPCMFramesProcessed += framesToProcess;
-        }
-
-        /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */
-        if (pDevice->null_device.currentPeriodFramesRemainingCapture == 0) {
-            pDevice->null_device.currentPeriodFramesRemainingCapture = 0;
-        }
-
-        /* If we've consumed the whole buffer we can return now. */
-        MA_ASSERT(totalPCMFramesProcessed <= frameCount);
-        if (totalPCMFramesProcessed == frameCount) {
-            break;
-        }
-
-        /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
-        targetFrame = pDevice->null_device.lastProcessedFrameCapture + pDevice->capture.internalPeriodSizeInFrames;
-        for (;;) {
-            ma_uint64 currentFrame;
-
-            /* Stop waiting if the device has been stopped. */
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
-                break;
-            }
-
-            currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice);
-            if (currentFrame >= targetFrame) {
-                break;
-            }
-
-            /* Getting here means we haven't yet reached the target sample, so continue waiting. */
-            ma_sleep(10);
-        }
-
-        pDevice->null_device.lastProcessedFrameCapture          += pDevice->capture.internalPeriodSizeInFrames;
-        pDevice->null_device.currentPeriodFramesRemainingCapture = pDevice->capture.internalPeriodSizeInFrames;
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = totalPCMFramesProcessed;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_uninit__null(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_null);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__null(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-    (void)pContext;
-
-    pCallbacks->onContextInit             = ma_context_init__null;
-    pCallbacks->onContextUninit           = ma_context_uninit__null;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__null;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__null;
-    pCallbacks->onDeviceInit              = ma_device_init__null;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__null;
-    pCallbacks->onDeviceStart             = ma_device_start__null;
-    pCallbacks->onDeviceStop              = ma_device_stop__null;
-    pCallbacks->onDeviceRead              = ma_device_read__null;
-    pCallbacks->onDeviceWrite             = ma_device_write__null;
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Our backend is asynchronous with a blocking read-write API which means we can get miniaudio to deal with the audio thread. */
-
-    /* The null backend always works. */
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-/*******************************************************************************
-
-WIN32 COMMON
-
-*******************************************************************************/
-#if defined(MA_WIN32)
-#if defined(MA_WIN32_DESKTOP)
-    #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit)                          ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit)
-    #define ma_CoUninitialize(pContext)                                                ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)()
-    #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv)  ((MA_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv)
-    #define ma_CoTaskMemFree(pContext, pv)                                             ((MA_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv)
-    #define ma_PropVariantClear(pContext, pvar)                                        ((MA_PFN_PropVariantClear)pContext->win32.PropVariantClear)(pvar)
-#else
-    #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit)                          CoInitializeEx(pvReserved, dwCoInit)
-    #define ma_CoUninitialize(pContext)                                                CoUninitialize()
-    #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv)  CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv)
-    #define ma_CoTaskMemFree(pContext, pv)                                             CoTaskMemFree(pv)
-    #define ma_PropVariantClear(pContext, pvar)                                        PropVariantClear(pvar)
-#endif
-
-#if !defined(MAXULONG_PTR) && !defined(__WATCOMC__)
-typedef size_t DWORD_PTR;
-#endif
-
-#if !defined(WAVE_FORMAT_44M08)
-#define WAVE_FORMAT_44M08 0x00000100
-#define WAVE_FORMAT_44S08 0x00000200
-#define WAVE_FORMAT_44M16 0x00000400
-#define WAVE_FORMAT_44S16 0x00000800
-#define WAVE_FORMAT_48M08 0x00001000
-#define WAVE_FORMAT_48S08 0x00002000
-#define WAVE_FORMAT_48M16 0x00004000
-#define WAVE_FORMAT_48S16 0x00008000
-#define WAVE_FORMAT_96M08 0x00010000
-#define WAVE_FORMAT_96S08 0x00020000
-#define WAVE_FORMAT_96M16 0x00040000
-#define WAVE_FORMAT_96S16 0x00080000
-#endif
-
-#ifndef SPEAKER_FRONT_LEFT
-#define SPEAKER_FRONT_LEFT            0x1
-#define SPEAKER_FRONT_RIGHT           0x2
-#define SPEAKER_FRONT_CENTER          0x4
-#define SPEAKER_LOW_FREQUENCY         0x8
-#define SPEAKER_BACK_LEFT             0x10
-#define SPEAKER_BACK_RIGHT            0x20
-#define SPEAKER_FRONT_LEFT_OF_CENTER  0x40
-#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
-#define SPEAKER_BACK_CENTER           0x100
-#define SPEAKER_SIDE_LEFT             0x200
-#define SPEAKER_SIDE_RIGHT            0x400
-#define SPEAKER_TOP_CENTER            0x800
-#define SPEAKER_TOP_FRONT_LEFT        0x1000
-#define SPEAKER_TOP_FRONT_CENTER      0x2000
-#define SPEAKER_TOP_FRONT_RIGHT       0x4000
-#define SPEAKER_TOP_BACK_LEFT         0x8000
-#define SPEAKER_TOP_BACK_CENTER       0x10000
-#define SPEAKER_TOP_BACK_RIGHT        0x20000
-#endif
-
-/*
-The SDK that comes with old versions of MSVC (VC6, for example) does not appear to define WAVEFORMATEXTENSIBLE. We
-define our own implementation in this case.
-*/
-#if (defined(_MSC_VER) && !defined(_WAVEFORMATEXTENSIBLE_)) || defined(__DMC__)
-typedef struct
-{
-    WAVEFORMATEX Format;
-    union
-    {
-        WORD wValidBitsPerSample;
-        WORD wSamplesPerBlock;
-        WORD wReserved;
-    } Samples;
-    DWORD dwChannelMask;
-    GUID SubFormat;
-} WAVEFORMATEXTENSIBLE;
-#endif
-
-#ifndef WAVE_FORMAT_EXTENSIBLE
-#define WAVE_FORMAT_EXTENSIBLE  0xFFFE
-#endif
-
-#ifndef WAVE_FORMAT_IEEE_FLOAT
-#define WAVE_FORMAT_IEEE_FLOAT  0x0003
-#endif
-
-/* Converts an individual Win32-style channel identifier (SPEAKER_FRONT_LEFT, etc.) to miniaudio. */
-static ma_uint8 ma_channel_id_to_ma__win32(DWORD id)
-{
-    switch (id)
-    {
-        case SPEAKER_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case SPEAKER_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case SPEAKER_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case SPEAKER_LOW_FREQUENCY:         return MA_CHANNEL_LFE;
-        case SPEAKER_BACK_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case SPEAKER_BACK_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case SPEAKER_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case SPEAKER_BACK_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case SPEAKER_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case SPEAKER_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case SPEAKER_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case SPEAKER_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case SPEAKER_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case SPEAKER_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case SPEAKER_TOP_BACK_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case SPEAKER_TOP_BACK_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        case SPEAKER_TOP_BACK_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to Win32-style. */
-static DWORD ma_channel_id_to_win32(DWORD id)
-{
-    switch (id)
-    {
-        case MA_CHANNEL_MONO:               return SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_FRONT_LEFT:         return SPEAKER_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return SPEAKER_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return SPEAKER_LOW_FREQUENCY;
-        case MA_CHANNEL_BACK_LEFT:          return SPEAKER_BACK_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return SPEAKER_BACK_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return SPEAKER_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return SPEAKER_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return SPEAKER_BACK_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return SPEAKER_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return SPEAKER_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return SPEAKER_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return SPEAKER_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return SPEAKER_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return SPEAKER_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return SPEAKER_TOP_BACK_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return SPEAKER_TOP_BACK_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return SPEAKER_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts a channel mapping to a Win32-style channel mask. */
-static DWORD ma_channel_map_to_channel_mask__win32(const ma_channel* pChannelMap, ma_uint32 channels)
-{
-    DWORD dwChannelMask = 0;
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        dwChannelMask |= ma_channel_id_to_win32(pChannelMap[iChannel]);
-    }
-
-    return dwChannelMask;
-}
-
-/* Converts a Win32-style channel mask to a miniaudio channel map. */
-static void ma_channel_mask_to_channel_map__win32(DWORD dwChannelMask, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (channels == 1 && dwChannelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_MONO;
-    } else if (channels == 2 && dwChannelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-        pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-    } else {
-        if (channels == 1 && (dwChannelMask & SPEAKER_FRONT_CENTER) != 0) {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } else {
-            /* Just iterate over each bit. */
-            ma_uint32 iChannel = 0;
-            ma_uint32 iBit;
-
-            for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) {
-                DWORD bitValue = (dwChannelMask & (1UL << iBit));
-                if (bitValue != 0) {
-                    /* The bit is set. */
-                    pChannelMap[iChannel] = ma_channel_id_to_ma__win32(bitValue);
-                    iChannel += 1;
-                }
-            }
-        }
-    }
-}
-
-#ifdef __cplusplus
-static ma_bool32 ma_is_guid_equal(const void* a, const void* b)
-{
-    return IsEqualGUID(*(const GUID*)a, *(const GUID*)b);
-}
-#else
-#define ma_is_guid_equal(a, b) IsEqualGUID((const GUID*)a, (const GUID*)b)
-#endif
-
-static MA_INLINE ma_bool32 ma_is_guid_null(const void* guid)
-{
-    static GUID nullguid = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
-    return ma_is_guid_equal(guid, &nullguid);
-}
-
-static ma_format ma_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF)
-{
-    MA_ASSERT(pWF != NULL);
-
-    if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-        const WAVEFORMATEXTENSIBLE* pWFEX = (const WAVEFORMATEXTENSIBLE*)pWF;
-        if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_PCM)) {
-            if (pWFEX->Samples.wValidBitsPerSample == 32) {
-                return ma_format_s32;
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 24) {
-                if (pWFEX->Format.wBitsPerSample == 32) {
-                    /*return ma_format_s24_32;*/
-                }
-                if (pWFEX->Format.wBitsPerSample == 24) {
-                    return ma_format_s24;
-                }
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 16) {
-                return ma_format_s16;
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 8) {
-                return ma_format_u8;
-            }
-        }
-        if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
-            if (pWFEX->Samples.wValidBitsPerSample == 32) {
-                return ma_format_f32;
-            }
-            /*
-            if (pWFEX->Samples.wValidBitsPerSample == 64) {
-                return ma_format_f64;
-            }
-            */
-        }
-    } else {
-        if (pWF->wFormatTag == WAVE_FORMAT_PCM) {
-            if (pWF->wBitsPerSample == 32) {
-                return ma_format_s32;
-            }
-            if (pWF->wBitsPerSample == 24) {
-                return ma_format_s24;
-            }
-            if (pWF->wBitsPerSample == 16) {
-                return ma_format_s16;
-            }
-            if (pWF->wBitsPerSample == 8) {
-                return ma_format_u8;
-            }
-        }
-        if (pWF->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
-            if (pWF->wBitsPerSample == 32) {
-                return ma_format_f32;
-            }
-            if (pWF->wBitsPerSample == 64) {
-                /*return ma_format_f64;*/
-            }
-        }
-    }
-
-    return ma_format_unknown;
-}
-#endif
-
-
-/*******************************************************************************
-
-WASAPI Backend
-
-*******************************************************************************/
-#ifdef MA_HAS_WASAPI
-#if 0
-#if defined(_MSC_VER)
-    #pragma warning(push)
-    #pragma warning(disable:4091)   /* 'typedef ': ignored on left of '' when no variable is declared */
-#endif
-#include <audioclient.h>
-#include <mmdeviceapi.h>
-#if defined(_MSC_VER)
-    #pragma warning(pop)
-#endif
-#endif  /* 0 */
-
-static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType);
-
-/* Some compilers don't define VerifyVersionInfoW. Need to write this ourselves. */
-#define MA_WIN32_WINNT_VISTA    0x0600
-#define MA_VER_MINORVERSION     0x01
-#define MA_VER_MAJORVERSION     0x02
-#define MA_VER_SERVICEPACKMAJOR 0x20
-#define MA_VER_GREATER_EQUAL    0x03
-
-typedef struct  {
-    DWORD dwOSVersionInfoSize;
-    DWORD dwMajorVersion;
-    DWORD dwMinorVersion;
-    DWORD dwBuildNumber;
-    DWORD dwPlatformId;
-    WCHAR szCSDVersion[128];
-    WORD  wServicePackMajor;
-    WORD  wServicePackMinor;
-    WORD  wSuiteMask;
-    BYTE  wProductType;
-    BYTE  wReserved;
-} ma_OSVERSIONINFOEXW;
-
-typedef BOOL      (WINAPI * ma_PFNVerifyVersionInfoW) (ma_OSVERSIONINFOEXW* lpVersionInfo, DWORD dwTypeMask, DWORDLONG dwlConditionMask);
-typedef ULONGLONG (WINAPI * ma_PFNVerSetConditionMask)(ULONGLONG dwlConditionMask, DWORD dwTypeBitMask, BYTE dwConditionMask);
-
-
-#ifndef PROPERTYKEY_DEFINED
-#define PROPERTYKEY_DEFINED
-#ifndef __WATCOMC__
-typedef struct
-{
-    GUID fmtid;
-    DWORD pid;
-} PROPERTYKEY;
-#endif
-#endif
-
-/* Some compilers don't define PropVariantInit(). We just do this ourselves since it's just a memset(). */
-static MA_INLINE void ma_PropVariantInit(PROPVARIANT* pProp)
-{
-    MA_ZERO_OBJECT(pProp);
-}
-
-
-static const PROPERTYKEY MA_PKEY_Device_FriendlyName             = {{0xA45C254E, 0xDF1C, 0x4EFD, {0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0}}, 14};
-static const PROPERTYKEY MA_PKEY_AudioEngine_DeviceFormat        = {{0xF19F064D, 0x82C,  0x4E27, {0xBC, 0x73, 0x68, 0x82, 0xA1, 0xBB, 0x8E, 0x4C}},  0};
-
-static const IID MA_IID_IUnknown                                 = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; /* 00000000-0000-0000-C000-000000000046 */
-#ifndef MA_WIN32_DESKTOP
-static const IID MA_IID_IAgileObject                             = {0x94EA2B94, 0xE9CC, 0x49E0, {0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90}}; /* 94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90 */
-#endif
-
-static const IID MA_IID_IAudioClient                             = {0x1CB9AD4C, 0xDBFA, 0x4C32, {0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2}}; /* 1CB9AD4C-DBFA-4C32-B178-C2F568A703B2 = __uuidof(IAudioClient) */
-static const IID MA_IID_IAudioClient2                            = {0x726778CD, 0xF60A, 0x4EDA, {0x82, 0xDE, 0xE4, 0x76, 0x10, 0xCD, 0x78, 0xAA}}; /* 726778CD-F60A-4EDA-82DE-E47610CD78AA = __uuidof(IAudioClient2) */
-static const IID MA_IID_IAudioClient3                            = {0x7ED4EE07, 0x8E67, 0x4CD4, {0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42}}; /* 7ED4EE07-8E67-4CD4-8C1A-2B7A5987AD42 = __uuidof(IAudioClient3) */
-static const IID MA_IID_IAudioRenderClient                       = {0xF294ACFC, 0x3146, 0x4483, {0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2}}; /* F294ACFC-3146-4483-A7BF-ADDCA7C260E2 = __uuidof(IAudioRenderClient) */
-static const IID MA_IID_IAudioCaptureClient                      = {0xC8ADBD64, 0xE71E, 0x48A0, {0xA4, 0xDE, 0x18, 0x5C, 0x39, 0x5C, 0xD3, 0x17}}; /* C8ADBD64-E71E-48A0-A4DE-185C395CD317 = __uuidof(IAudioCaptureClient) */
-static const IID MA_IID_IMMNotificationClient                    = {0x7991EEC9, 0x7E89, 0x4D85, {0x83, 0x90, 0x6C, 0x70, 0x3C, 0xEC, 0x60, 0xC0}}; /* 7991EEC9-7E89-4D85-8390-6C703CEC60C0 = __uuidof(IMMNotificationClient) */
-#ifndef MA_WIN32_DESKTOP
-static const IID MA_IID_DEVINTERFACE_AUDIO_RENDER                = {0xE6327CAD, 0xDCEC, 0x4949, {0xAE, 0x8A, 0x99, 0x1E, 0x97, 0x6A, 0x79, 0xD2}}; /* E6327CAD-DCEC-4949-AE8A-991E976A79D2 */
-static const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE               = {0x2EEF81BE, 0x33FA, 0x4800, {0x96, 0x70, 0x1C, 0xD4, 0x74, 0x97, 0x2C, 0x3F}}; /* 2EEF81BE-33FA-4800-9670-1CD474972C3F */
-static const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; /* 41D949AB-9862-444A-80F6-C261334DA5EB */
-#endif
-
-static const IID MA_CLSID_MMDeviceEnumerator_Instance            = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
-static const IID MA_IID_IMMDeviceEnumerator_Instance             = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
-#ifdef __cplusplus
-#define MA_CLSID_MMDeviceEnumerator MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator  MA_IID_IMMDeviceEnumerator_Instance
-#else
-#define MA_CLSID_MMDeviceEnumerator &MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator  &MA_IID_IMMDeviceEnumerator_Instance
-#endif
-
-typedef struct ma_IUnknown                                 ma_IUnknown;
-#ifdef MA_WIN32_DESKTOP
-#define MA_MM_DEVICE_STATE_ACTIVE                          1
-#define MA_MM_DEVICE_STATE_DISABLED                        2
-#define MA_MM_DEVICE_STATE_NOTPRESENT                      4
-#define MA_MM_DEVICE_STATE_UNPLUGGED                       8
-
-typedef struct ma_IMMDeviceEnumerator                      ma_IMMDeviceEnumerator;
-typedef struct ma_IMMDeviceCollection                      ma_IMMDeviceCollection;
-typedef struct ma_IMMDevice                                ma_IMMDevice;
-#else
-typedef struct ma_IActivateAudioInterfaceCompletionHandler ma_IActivateAudioInterfaceCompletionHandler;
-typedef struct ma_IActivateAudioInterfaceAsyncOperation    ma_IActivateAudioInterfaceAsyncOperation;
-#endif
-typedef struct ma_IPropertyStore                           ma_IPropertyStore;
-typedef struct ma_IAudioClient                             ma_IAudioClient;
-typedef struct ma_IAudioClient2                            ma_IAudioClient2;
-typedef struct ma_IAudioClient3                            ma_IAudioClient3;
-typedef struct ma_IAudioRenderClient                       ma_IAudioRenderClient;
-typedef struct ma_IAudioCaptureClient                      ma_IAudioCaptureClient;
-
-typedef ma_int64                                           MA_REFERENCE_TIME;
-
-#define MA_AUDCLNT_STREAMFLAGS_CROSSPROCESS                0x00010000
-#define MA_AUDCLNT_STREAMFLAGS_LOOPBACK                    0x00020000
-#define MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK               0x00040000
-#define MA_AUDCLNT_STREAMFLAGS_NOPERSIST                   0x00080000
-#define MA_AUDCLNT_STREAMFLAGS_RATEADJUST                  0x00100000
-#define MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY         0x08000000
-#define MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM              0x80000000
-#define MA_AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED          0x10000000
-#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE               0x20000000
-#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED    0x40000000
-
-/* Buffer flags. */
-#define MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY          1
-#define MA_AUDCLNT_BUFFERFLAGS_SILENT                      2
-#define MA_AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR             4
-
-typedef enum
-{
-    ma_eRender  = 0,
-    ma_eCapture = 1,
-    ma_eAll     = 2
-} ma_EDataFlow;
-
-typedef enum
-{
-    ma_eConsole        = 0,
-    ma_eMultimedia     = 1,
-    ma_eCommunications = 2
-} ma_ERole;
-
-typedef enum
-{
-    MA_AUDCLNT_SHAREMODE_SHARED,
-    MA_AUDCLNT_SHAREMODE_EXCLUSIVE
-} MA_AUDCLNT_SHAREMODE;
-
-typedef enum
-{
-    MA_AudioCategory_Other = 0  /* <-- miniaudio is only caring about Other. */
-} MA_AUDIO_STREAM_CATEGORY;
-
-typedef struct
-{
-    ma_uint32 cbSize;
-    BOOL bIsOffload;
-    MA_AUDIO_STREAM_CATEGORY eCategory;
-} ma_AudioClientProperties;
-
-/* IUnknown */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IUnknown* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IUnknown* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IUnknown* pThis);
-} ma_IUnknownVtbl;
-struct ma_IUnknown
-{
-    ma_IUnknownVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IUnknown_QueryInterface(ma_IUnknown* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IUnknown_AddRef(ma_IUnknown* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IUnknown_Release(ma_IUnknown* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-
-#ifdef MA_WIN32_DESKTOP
-    /* IMMNotificationClient */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMNotificationClient* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMNotificationClient* pThis);
-
-        /* IMMNotificationClient */
-        HRESULT (STDMETHODCALLTYPE * OnDeviceStateChanged)  (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState);
-        HRESULT (STDMETHODCALLTYPE * OnDeviceAdded)         (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnDeviceRemoved)       (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnDefaultDeviceChanged)(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnPropertyValueChanged)(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key);
-    } ma_IMMNotificationClientVtbl;
-
-    /* IMMDeviceEnumerator */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDeviceEnumerator* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDeviceEnumerator* pThis);
-
-        /* IMMDeviceEnumerator */
-        HRESULT (STDMETHODCALLTYPE * EnumAudioEndpoints)                    (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices);
-        HRESULT (STDMETHODCALLTYPE * GetDefaultAudioEndpoint)               (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint);
-        HRESULT (STDMETHODCALLTYPE * GetDevice)                             (ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice);
-        HRESULT (STDMETHODCALLTYPE * RegisterEndpointNotificationCallback)  (ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
-        HRESULT (STDMETHODCALLTYPE * UnregisterEndpointNotificationCallback)(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
-    } ma_IMMDeviceEnumeratorVtbl;
-    struct ma_IMMDeviceEnumerator
-    {
-        ma_IMMDeviceEnumeratorVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_QueryInterface(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDeviceEnumerator_AddRef(ma_IMMDeviceEnumerator* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDeviceEnumerator_Release(ma_IMMDeviceEnumerator* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_EnumAudioEndpoints(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices) { return pThis->lpVtbl->EnumAudioEndpoints(pThis, dataFlow, dwStateMask, ppDevices); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint) { return pThis->lpVtbl->GetDefaultAudioEndpoint(pThis, dataFlow, role, ppEndpoint); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDevice(ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice)        { return pThis->lpVtbl->GetDevice(pThis, pID, ppDevice); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->RegisterEndpointNotificationCallback(pThis, pClient); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->UnregisterEndpointNotificationCallback(pThis, pClient); }
-
-
-    /* IMMDeviceCollection */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDeviceCollection* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDeviceCollection* pThis);
-
-        /* IMMDeviceCollection */
-        HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IMMDeviceCollection* pThis, UINT* pDevices);
-        HRESULT (STDMETHODCALLTYPE * Item)    (ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice);
-    } ma_IMMDeviceCollectionVtbl;
-    struct ma_IMMDeviceCollection
-    {
-        ma_IMMDeviceCollectionVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_QueryInterface(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDeviceCollection_AddRef(ma_IMMDeviceCollection* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDeviceCollection_Release(ma_IMMDeviceCollection* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_GetCount(ma_IMMDeviceCollection* pThis, UINT* pDevices)                               { return pThis->lpVtbl->GetCount(pThis, pDevices); }
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_Item(ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice)            { return pThis->lpVtbl->Item(pThis, nDevice, ppDevice); }
-
-
-    /* IMMDevice */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDevice* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDevice* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDevice* pThis);
-
-        /* IMMDevice */
-        HRESULT (STDMETHODCALLTYPE * Activate)         (ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface);
-        HRESULT (STDMETHODCALLTYPE * OpenPropertyStore)(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties);
-        HRESULT (STDMETHODCALLTYPE * GetId)            (ma_IMMDevice* pThis, LPWSTR *pID);
-        HRESULT (STDMETHODCALLTYPE * GetState)         (ma_IMMDevice* pThis, DWORD *pState);
-    } ma_IMMDeviceVtbl;
-    struct ma_IMMDevice
-    {
-        ma_IMMDeviceVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDevice_QueryInterface(ma_IMMDevice* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDevice_AddRef(ma_IMMDevice* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDevice_Release(ma_IMMDevice* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDevice_Activate(ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface) { return pThis->lpVtbl->Activate(pThis, iid, dwClsCtx, pActivationParams, ppInterface); }
-    static MA_INLINE HRESULT ma_IMMDevice_OpenPropertyStore(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties) { return pThis->lpVtbl->OpenPropertyStore(pThis, stgmAccess, ppProperties); }
-    static MA_INLINE HRESULT ma_IMMDevice_GetId(ma_IMMDevice* pThis, LPWSTR *pID)                                     { return pThis->lpVtbl->GetId(pThis, pID); }
-    static MA_INLINE HRESULT ma_IMMDevice_GetState(ma_IMMDevice* pThis, DWORD *pState)                                { return pThis->lpVtbl->GetState(pThis, pState); }
-#else
-    /* IActivateAudioInterfaceAsyncOperation */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IActivateAudioInterfaceAsyncOperation* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IActivateAudioInterfaceAsyncOperation* pThis);
-
-        /* IActivateAudioInterfaceAsyncOperation */
-        HRESULT (STDMETHODCALLTYPE * GetActivateResult)(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface);
-    } ma_IActivateAudioInterfaceAsyncOperationVtbl;
-    struct ma_IActivateAudioInterfaceAsyncOperation
-    {
-        ma_IActivateAudioInterfaceAsyncOperationVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_QueryInterface(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IActivateAudioInterfaceAsyncOperation_AddRef(ma_IActivateAudioInterfaceAsyncOperation* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IActivateAudioInterfaceAsyncOperation_Release(ma_IActivateAudioInterfaceAsyncOperation* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface) { return pThis->lpVtbl->GetActivateResult(pThis, pActivateResult, ppActivatedInterface); }
-#endif
-
-/* IPropertyStore */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IPropertyStore* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IPropertyStore* pThis);
-
-    /* IPropertyStore */
-    HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IPropertyStore* pThis, DWORD* pPropCount);
-    HRESULT (STDMETHODCALLTYPE * GetAt)   (ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey);
-    HRESULT (STDMETHODCALLTYPE * GetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar);
-    HRESULT (STDMETHODCALLTYPE * SetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar);
-    HRESULT (STDMETHODCALLTYPE * Commit)  (ma_IPropertyStore* pThis);
-} ma_IPropertyStoreVtbl;
-struct ma_IPropertyStore
-{
-    ma_IPropertyStoreVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IPropertyStore_QueryInterface(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IPropertyStore_AddRef(ma_IPropertyStore* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IPropertyStore_Release(ma_IPropertyStore* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetCount(ma_IPropertyStore* pThis, DWORD* pPropCount)                            { return pThis->lpVtbl->GetCount(pThis, pPropCount); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetAt(ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey)          { return pThis->lpVtbl->GetAt(pThis, propIndex, pPropKey); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar) { return pThis->lpVtbl->GetValue(pThis, pKey, pPropVar); }
-static MA_INLINE HRESULT ma_IPropertyStore_SetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar) { return pThis->lpVtbl->SetValue(pThis, pKey, pPropVar); }
-static MA_INLINE HRESULT ma_IPropertyStore_Commit(ma_IPropertyStore* pThis)                                                 { return pThis->lpVtbl->Commit(pThis); }
-
-
-/* IAudioClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient* pThis, const IID* const riid, void** pp);
-} ma_IAudioClientVtbl;
-struct ma_IAudioClient
-{
-    ma_IAudioClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient_QueryInterface(ma_IAudioClient* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient_AddRef(ma_IAudioClient* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient_Release(ma_IAudioClient* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Initialize(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient_GetBufferSize(ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient_GetStreamLatency(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient_GetCurrentPadding(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient_IsFormatSupported(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient_GetMixFormat(ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient_GetDevicePeriod(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient_Start(ma_IAudioClient* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Stop(ma_IAudioClient* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Reset(ma_IAudioClient* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_SetEventHandle(ma_IAudioClient* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient_GetService(ma_IAudioClient* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-
-/* IAudioClient2 */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient2* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient2* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient2* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient2* pThis, const IID* const riid, void** pp);
-
-    /* IAudioClient2 */
-    HRESULT (STDMETHODCALLTYPE * IsOffloadCapable)   (ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
-    HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
-} ma_IAudioClient2Vtbl;
-struct ma_IAudioClient2
-{
-    ma_IAudioClient2Vtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient2_QueryInterface(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient2_AddRef(ma_IAudioClient2* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient2_Release(ma_IAudioClient2* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Initialize(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSize(ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetStreamLatency(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetCurrentPadding(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient2_IsFormatSupported(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetMixFormat(ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetDevicePeriod(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient2_Start(ma_IAudioClient2* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Stop(ma_IAudioClient2* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Reset(ma_IAudioClient2* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_SetEventHandle(ma_IAudioClient2* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetService(ma_IAudioClient2* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-static MA_INLINE HRESULT ma_IAudioClient2_IsOffloadCapable(ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
-static MA_INLINE HRESULT ma_IAudioClient2_SetClientProperties(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties)           { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSizeLimits(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
-
-
-/* IAudioClient3 */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient3* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient3* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient3* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient3* pThis, const IID* const riid, void** pp);
-
-    /* IAudioClient2 */
-    HRESULT (STDMETHODCALLTYPE * IsOffloadCapable)   (ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
-    HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
-
-    /* IAudioClient3 */
-    HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod)       (ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentSharedModeEnginePeriod)(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames);
-    HRESULT (STDMETHODCALLTYPE * InitializeSharedAudioStream)     (ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-} ma_IAudioClient3Vtbl;
-struct ma_IAudioClient3
-{
-    ma_IAudioClient3Vtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient3_QueryInterface(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient3_AddRef(ma_IAudioClient3* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient3_Release(ma_IAudioClient3* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Initialize(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSize(ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetStreamLatency(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentPadding(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_IsFormatSupported(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetMixFormat(ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetDevicePeriod(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient3_Start(ma_IAudioClient3* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Stop(ma_IAudioClient3* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Reset(ma_IAudioClient3* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_SetEventHandle(ma_IAudioClient3* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetService(ma_IAudioClient3* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-static MA_INLINE HRESULT ma_IAudioClient3_IsOffloadCapable(ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
-static MA_INLINE HRESULT ma_IAudioClient3_SetClientProperties(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties)           { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSizeLimits(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetSharedModeEnginePeriod(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentSharedModeEnginePeriod(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_InitializeSharedAudioStream(ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); }
-
-
-/* IAudioRenderClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioRenderClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioRenderClient* pThis);
-
-    /* IAudioRenderClient */
-    HRESULT (STDMETHODCALLTYPE * GetBuffer)    (ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData);
-    HRESULT (STDMETHODCALLTYPE * ReleaseBuffer)(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags);
-} ma_IAudioRenderClientVtbl;
-struct ma_IAudioRenderClient
-{
-    ma_IAudioRenderClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioRenderClient_QueryInterface(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject)   { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioRenderClient_AddRef(ma_IAudioRenderClient* pThis)                                                   { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioRenderClient_Release(ma_IAudioRenderClient* pThis)                                                  { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioRenderClient_GetBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData)   { return pThis->lpVtbl->GetBuffer(pThis, numFramesRequested, ppData); }
-static MA_INLINE HRESULT ma_IAudioRenderClient_ReleaseBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesWritten, dwFlags); }
-
-
-/* IAudioCaptureClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioCaptureClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioCaptureClient* pThis);
-
-    /* IAudioRenderClient */
-    HRESULT (STDMETHODCALLTYPE * GetBuffer)        (ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition);
-    HRESULT (STDMETHODCALLTYPE * ReleaseBuffer)    (ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead);
-    HRESULT (STDMETHODCALLTYPE * GetNextPacketSize)(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket);
-} ma_IAudioCaptureClientVtbl;
-struct ma_IAudioCaptureClient
-{
-    ma_IAudioCaptureClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioCaptureClient_QueryInterface(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioCaptureClient_AddRef(ma_IAudioCaptureClient* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioCaptureClient_Release(ma_IAudioCaptureClient* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_GetBuffer(ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition) { return pThis->lpVtbl->GetBuffer(pThis, ppData, pNumFramesToRead, pFlags, pDevicePosition, pQPCPosition); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_ReleaseBuffer(ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead)                 { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesRead); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_GetNextPacketSize(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket)   { return pThis->lpVtbl->GetNextPacketSize(pThis, pNumFramesInNextPacket); }
-
-#ifndef MA_WIN32_DESKTOP
-#include <mmdeviceapi.h>
-typedef struct ma_completion_handler_uwp ma_completion_handler_uwp;
-
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_completion_handler_uwp* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_completion_handler_uwp* pThis);
-
-    /* IActivateAudioInterfaceCompletionHandler */
-    HRESULT (STDMETHODCALLTYPE * ActivateCompleted)(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation);
-} ma_completion_handler_uwp_vtbl;
-struct ma_completion_handler_uwp
-{
-    ma_completion_handler_uwp_vtbl* lpVtbl;
-    MA_ATOMIC ma_uint32 counter;
-    HANDLE hEvent;
-};
-
-static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject)
-{
-    /*
-    We need to "implement" IAgileObject which is just an indicator that's used internally by WASAPI for some multithreading management. To
-    "implement" this, we just make sure we return pThis when the IAgileObject is requested.
-    */
-    if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IActivateAudioInterfaceCompletionHandler) && !ma_is_guid_equal(riid, &MA_IID_IAgileObject)) {
-        *ppObject = NULL;
-        return E_NOINTERFACE;
-    }
-
-    /* Getting here means the IID is IUnknown or IMMNotificationClient. */
-    *ppObject = (void*)pThis;
-    ((ma_completion_handler_uwp_vtbl*)pThis->lpVtbl)->AddRef(pThis);
-    return S_OK;
-}
-
-static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_AddRef(ma_completion_handler_uwp* pThis)
-{
-    return (ULONG)c89atomic_fetch_add_32(&pThis->counter, 1) + 1;
-}
-
-static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_Release(ma_completion_handler_uwp* pThis)
-{
-    ma_uint32 newRefCount = c89atomic_fetch_sub_32(&pThis->counter, 1) - 1;
-    if (newRefCount == 0) {
-        return 0;   /* We don't free anything here because we never allocate the object on the heap. */
-    }
-
-    return (ULONG)newRefCount;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_ActivateCompleted(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation)
-{
-    (void)pActivateOperation;
-    SetEvent(pThis->hEvent);
-    return S_OK;
-}
-
-
-static ma_completion_handler_uwp_vtbl g_maCompletionHandlerVtblInstance = {
-    ma_completion_handler_uwp_QueryInterface,
-    ma_completion_handler_uwp_AddRef,
-    ma_completion_handler_uwp_Release,
-    ma_completion_handler_uwp_ActivateCompleted
-};
-
-static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHandler)
-{
-    MA_ASSERT(pHandler != NULL);
-    MA_ZERO_OBJECT(pHandler);
-
-    pHandler->lpVtbl = &g_maCompletionHandlerVtblInstance;
-    pHandler->counter = 1;
-    pHandler->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-    if (pHandler->hEvent == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_completion_handler_uwp_uninit(ma_completion_handler_uwp* pHandler)
-{
-    if (pHandler->hEvent != NULL) {
-        CloseHandle(pHandler->hEvent);
-    }
-}
-
-static void ma_completion_handler_uwp_wait(ma_completion_handler_uwp* pHandler)
-{
-    WaitForSingleObject(pHandler->hEvent, INFINITE);
-}
-#endif  /* !MA_WIN32_DESKTOP */
-
-/* We need a virtual table for our notification client object that's used for detecting changes to the default device. */
-#ifdef MA_WIN32_DESKTOP
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_QueryInterface(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject)
-{
-    /*
-    We care about two interfaces - IUnknown and IMMNotificationClient. If the requested IID is something else
-    we just return E_NOINTERFACE. Otherwise we need to increment the reference counter and return S_OK.
-    */
-    if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IMMNotificationClient)) {
-        *ppObject = NULL;
-        return E_NOINTERFACE;
-    }
-
-    /* Getting here means the IID is IUnknown or IMMNotificationClient. */
-    *ppObject = (void*)pThis;
-    ((ma_IMMNotificationClientVtbl*)pThis->lpVtbl)->AddRef(pThis);
-    return S_OK;
-}
-
-static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_AddRef(ma_IMMNotificationClient* pThis)
-{
-    return (ULONG)c89atomic_fetch_add_32(&pThis->counter, 1) + 1;
-}
-
-static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_Release(ma_IMMNotificationClient* pThis)
-{
-    ma_uint32 newRefCount = c89atomic_fetch_sub_32(&pThis->counter, 1) - 1;
-    if (newRefCount == 0) {
-        return 0;   /* We don't free anything here because we never allocate the object on the heap. */
-    }
-
-    return (ULONG)newRefCount;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState)
-{
-    ma_bool32 isThisDevice = MA_FALSE;
-    ma_bool32 isCapture    = MA_FALSE;
-    ma_bool32 isPlayback   = MA_FALSE;
-    
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)", (unsigned int)dwNewState);
-#endif
-
-    /*
-    There have been reports of a hang when a playback device is disconnected. The idea with this code is to explicitly stop the device if we detect
-    that the device is disabled or has been unplugged.
-    */
-    if (pThis->pDevice->wasapi.allowCaptureAutoStreamRouting && (pThis->pDevice->type == ma_device_type_capture || pThis->pDevice->type == ma_device_type_duplex || pThis->pDevice->type == ma_device_type_loopback)) {
-        isCapture = MA_TRUE;
-        if (wcscmp(pThis->pDevice->capture.id.wasapi, pDeviceID) == 0) {
-            isThisDevice = MA_TRUE;
-        }
-    }
-
-    if (pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting && (pThis->pDevice->type == ma_device_type_playback || pThis->pDevice->type == ma_device_type_duplex)) {
-        isPlayback = MA_TRUE;
-        if (wcscmp(pThis->pDevice->playback.id.wasapi, pDeviceID) == 0) {
-            isThisDevice = MA_TRUE;
-        }
-    }
-
-
-    /*
-    If the device ID matches our device we need to mark our device as detached and stop it. When a
-    device is added in OnDeviceAdded(), we'll restart it. We only mark it as detached if the device
-    was started at the time of being removed.
-    */
-    if (isThisDevice) {
-        if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) == 0) {
-            /*
-            Unplugged or otherwise unavailable. Mark as detached if we were in a playing state. We'll
-            use this to determine whether or not we need to automatically start the device when it's
-            plugged back in again.
-            */
-            if (ma_device_get_state(pThis->pDevice) == MA_STATE_STARTED) {
-                if (isPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_TRUE;
-                }
-                if (isCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_TRUE;
-                }
-
-                ma_device_stop(pThis->pDevice);
-            }
-        }
-
-        if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) != 0) {
-            /* The device was activated. If we were detached, we need to start it again. */
-            ma_bool8 tryRestartingDevice = MA_FALSE;
-
-            if (isPlayback) {
-                if (pThis->pDevice->wasapi.isDetachedPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
-                    ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
-                    tryRestartingDevice = MA_TRUE;
-                }
-            }
-
-            if (isCapture) {
-                if (pThis->pDevice->wasapi.isDetachedCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
-                    ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
-                    tryRestartingDevice = MA_TRUE;
-                }
-            }
-
-            if (tryRestartingDevice) {
-                if (pThis->pDevice->wasapi.isDetachedPlayback == MA_FALSE && pThis->pDevice->wasapi.isDetachedCapture == MA_FALSE) {
-                    ma_device_start(pThis->pDevice);
-                }
-            }
-        }
-    }
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    /*printf("IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
-#endif
-
-    /* We don't need to worry about this event for our purposes. */
-    (void)pThis;
-    (void)pDeviceID;
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");
-#endif
-
-    /* We don't need to worry about this event for our purposes. */
-    (void)pThis;
-    (void)pDeviceID;
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");
-#endif
-
-    /* We only ever use the eConsole role in miniaudio. */
-    if (role != ma_eConsole) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting: role != eConsole\n");
-    #endif
-        return S_OK;
-    }
-
-    /* We only care about devices with the same data flow and role as the current device. */
-    if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) ||
-        (pThis->pDevice->type == ma_device_type_capture  && dataFlow != ma_eCapture)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n");
-    #endif
-        return S_OK;
-    }
-
-    /* Don't do automatic stream routing if we're not allowed. */
-    if ((dataFlow == ma_eRender  && pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting == MA_FALSE) ||
-        (dataFlow == ma_eCapture && pThis->pDevice->wasapi.allowCaptureAutoStreamRouting  == MA_FALSE)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because automatic stream routing has been disabled by the device config.\n");
-    #endif
-        return S_OK;
-    }
-
-    /*
-    Not currently supporting automatic stream routing in exclusive mode. This is not working correctly on my machine due to
-    AUDCLNT_E_DEVICE_IN_USE errors when reinitializing the device. If this is a bug in miniaudio, we can try re-enabling this once
-    it's fixed.
-    */
-    if ((dataFlow == ma_eRender  && pThis->pDevice->playback.shareMode == ma_share_mode_exclusive) ||
-        (dataFlow == ma_eCapture && pThis->pDevice->capture.shareMode  == ma_share_mode_exclusive)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because the device shared mode is exclusive.\n");
-    #endif
-        return S_OK;
-    }
-
-
-
-
-    /*
-    Second attempt at device rerouting. We're going to retrieve the device's state at the time of
-    the route change. We're then going to stop the device, reinitialize the device, and then start
-    it again if the state before stopping was MA_STATE_STARTED.
-    */
-    {
-        ma_uint32 previousState = ma_device_get_state(pThis->pDevice);
-        ma_bool8 restartDevice = MA_FALSE;
-
-        if (previousState == MA_STATE_STARTED) {
-            ma_device_stop(pThis->pDevice);
-            restartDevice = MA_TRUE;
-        }
-
-        if (pDefaultDeviceID != NULL) { /* <-- The input device ID will be null if there's no other device available. */
-            if (dataFlow == ma_eRender) {
-                ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
-
-                if (pThis->pDevice->wasapi.isDetachedPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
-                    
-                    if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedCapture) {
-                        restartDevice = MA_FALSE;   /* It's a duplex device and the capture side is detached. We cannot be restarting the device just yet. */
-                    } else {
-                        restartDevice = MA_TRUE;    /* It's not a duplex device, or the capture side is also attached so we can go ahead and restart the device. */
-                    }
-                }
-            } else {
-                ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
-
-                if (pThis->pDevice->wasapi.isDetachedCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
-                    
-                    if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedPlayback) {
-                        restartDevice = MA_FALSE;   /* It's a duplex device and the playback side is detached. We cannot be restarting the device just yet. */
-                    } else {
-                        restartDevice = MA_TRUE;    /* It's not a duplex device, or the playback side is also attached so we can go ahead and restart the device. */
-                    }
-                }
-            }
-
-            if (restartDevice) {
-                ma_device_start(pThis->pDevice);
-            }
-        }
-    }
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key)
-{
-#ifdef MA_DEBUG_OUTPUT
-    /*printf("IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
-#endif
-
-    (void)pThis;
-    (void)pDeviceID;
-    (void)key;
-    return S_OK;
-}
-
-static ma_IMMNotificationClientVtbl g_maNotificationCientVtbl = {
-    ma_IMMNotificationClient_QueryInterface,
-    ma_IMMNotificationClient_AddRef,
-    ma_IMMNotificationClient_Release,
-    ma_IMMNotificationClient_OnDeviceStateChanged,
-    ma_IMMNotificationClient_OnDeviceAdded,
-    ma_IMMNotificationClient_OnDeviceRemoved,
-    ma_IMMNotificationClient_OnDefaultDeviceChanged,
-    ma_IMMNotificationClient_OnPropertyValueChanged
-};
-#endif  /* MA_WIN32_DESKTOP */
-
-#ifdef MA_WIN32_DESKTOP
-typedef ma_IMMDevice ma_WASAPIDeviceInterface;
-#else
-typedef ma_IUnknown ma_WASAPIDeviceInterface;
-#endif
-
-
-#define MA_CONTEXT_COMMAND_QUIT__WASAPI                 1
-#define MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI  2
-#define MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI 3
-
-static ma_context_command__wasapi ma_context_init_command__wasapi(int code)
-{
-    ma_context_command__wasapi cmd;
-    
-    MA_ZERO_OBJECT(&cmd);
-    cmd.code = code;
-
-    return cmd;
-}
-
-static ma_result ma_context_post_command__wasapi(ma_context* pContext, const ma_context_command__wasapi* pCmd)
-{
-    /* For now we are doing everything synchronously, but I might relax this later if the need arises. */
-    ma_result result;
-    ma_bool32 isUsingLocalEvent = MA_FALSE;
-    ma_event localEvent;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCmd     != NULL);
-
-    if (pCmd->pEvent == NULL) {
-        isUsingLocalEvent = MA_TRUE;
-
-        result = ma_event_init(&localEvent);
-        if (result != MA_SUCCESS) {
-            return result;  /* Failed to create the event for this command. */
-        }
-    }
-
-    /* Here is where we add the command to the list. If there's not enough room we'll spin until there is. */
-    ma_mutex_lock(&pContext->wasapi.commandLock);
-    {
-        ma_uint32 index;
-
-        /* Spin until we've got some space available. */
-        while (pContext->wasapi.commandCount == ma_countof(pContext->wasapi.commands)) {
-            ma_yield();
-        }
-
-        /* Space is now available. Can safely add to the list. */
-        index = (pContext->wasapi.commandIndex + pContext->wasapi.commandCount) % ma_countof(pContext->wasapi.commands);
-        pContext->wasapi.commands[index]        = *pCmd;
-        pContext->wasapi.commands[index].pEvent = &localEvent;
-        pContext->wasapi.commandCount += 1;
-
-        /* Now that the command has been added, release the semaphore so ma_context_next_command__wasapi() can return. */
-        ma_semaphore_release(&pContext->wasapi.commandSem);
-    }
-    ma_mutex_unlock(&pContext->wasapi.commandLock);    
-
-    if (isUsingLocalEvent) {
-        ma_event_wait(&localEvent);
-        ma_event_uninit(&localEvent);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_next_command__wasapi(ma_context* pContext, ma_context_command__wasapi* pCmd)
-{
-    ma_result result = MA_SUCCESS;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCmd     != NULL);
-
-    result = ma_semaphore_wait(&pContext->wasapi.commandSem);
-    if (result == MA_SUCCESS) {
-        ma_mutex_lock(&pContext->wasapi.commandLock);
-        {
-            *pCmd = pContext->wasapi.commands[pContext->wasapi.commandIndex];
-            pContext->wasapi.commandIndex  = (pContext->wasapi.commandIndex + 1) % ma_countof(pContext->wasapi.commands);
-            pContext->wasapi.commandCount -= 1;
-        }
-        ma_mutex_unlock(&pContext->wasapi.commandLock);
-    }    
-
-    return result;
-}
-
-static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pUserData)
-{
-    ma_result result;
-    ma_context* pContext = (ma_context*)pUserData;
-    MA_ASSERT(pContext != NULL);
-
-    for (;;) {
-        ma_context_command__wasapi cmd;
-        result = ma_context_next_command__wasapi(pContext, &cmd);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        switch (cmd.code)
-        {
-            case MA_CONTEXT_COMMAND_QUIT__WASAPI:
-            {
-                /* Do nothing. Handled after the switch. */
-            } break;
-
-            case MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI:
-            {
-                if (cmd.data.createAudioClient.deviceType == ma_device_type_playback) {
-                    result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioRenderClient, cmd.data.createAudioClient.ppAudioClientService));
-                } else {
-                    result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioCaptureClient, cmd.data.createAudioClient.ppAudioClientService));
-                }
-            } break;
-
-            case MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI:
-            {
-                if (cmd.data.releaseAudioClient.deviceType == ma_device_type_playback) { 
-                    if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback != NULL) {
-                        ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback);
-                        cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback = NULL;
-                    }
-                }
-
-                if (cmd.data.releaseAudioClient.deviceType == ma_device_type_capture) {
-                    if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture != NULL) {
-                        ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture);
-                        cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture = NULL;
-                    }
-                }
-            } break;
-
-            default:
-            {
-                /* Unknown command. Ignore it, but trigger an assert in debug mode so we're aware of it. */
-                MA_ASSERT(MA_FALSE);
-            } break;
-        }
-
-        if (cmd.pEvent != NULL) {
-            ma_event_signal(cmd.pEvent);
-        }
-
-        if (cmd.code == MA_CONTEXT_COMMAND_QUIT__WASAPI) {
-            break;  /* Received a quit message. Get out of here. */
-        }
-    }
-
-    return (ma_thread_result)0;
-}
-
-static ma_result ma_device_create_IAudioClient_service__wasapi(ma_context* pContext, ma_device_type deviceType, ma_IAudioClient* pAudioClient, void** ppAudioClientService)
-{
-    ma_result result;
-    ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI);
-    cmd.data.createAudioClient.deviceType           = deviceType;
-    cmd.data.createAudioClient.pAudioClient         = (void*)pAudioClient;
-    cmd.data.createAudioClient.ppAudioClientService = ppAudioClientService;
-    cmd.data.createAudioClient.result               = MA_SUCCESS;
-    
-    result = ma_context_post_command__wasapi(pContext, &cmd);  /* This will not return until the command has actually been run. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return cmd.data.createAudioClient.result;
-}
-
-#if 0   /* Not used at the moment, but leaving here for future use. */
-static ma_result ma_device_release_IAudioClient_service__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-    ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI);
-    cmd.data.releaseAudioClient.pDevice    = pDevice;
-    cmd.data.releaseAudioClient.deviceType = deviceType;
-
-    result = ma_context_post_command__wasapi(pDevice->pContext, &cmd);  /* This will not return until the command has actually been run. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo)
-{
-    MA_ASSERT(pWF != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    if (pInfo->nativeDataFormatCount >= ma_countof(pInfo->nativeDataFormats)) {
-        return; /* Too many data formats. Need to ignore this one. Don't think this should ever happen with WASAPI. */
-    }
-
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].format     = ma_format_from_WAVEFORMATEX(pWF);
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].channels   = pWF->nChannels;
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].sampleRate = pWF->nSamplesPerSec;
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].flags      = (shareMode == ma_share_mode_exclusive) ? MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE : 0;
-    pInfo->nativeDataFormatCount += 1;
-}
-
-static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context* pContext, /*ma_IMMDevice**/void* pMMDevice, ma_IAudioClient* pAudioClient, ma_device_info* pInfo)
-{
-    HRESULT hr;
-    WAVEFORMATEX* pWF = NULL;
-
-    MA_ASSERT(pAudioClient != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    /* Shared Mode. We use GetMixFormat() here. */
-    hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (WAVEFORMATEX**)&pWF);
-    if (SUCCEEDED(hr)) {
-        ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_shared, pInfo);
-    } else {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve mix format for device info retrieval.", ma_result_from_HRESULT(hr));
-    }
-
-    /*
-    Exlcusive Mode. We repeatedly call IsFormatSupported() here. This is not currently supported on
-    UWP. Failure to retrieve the exclusive mode format is not considered an error, so from here on
-    out, MA_SUCCESS is guaranteed to be returned.
-    */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        ma_IPropertyStore *pProperties;
-
-        /*
-        The first thing to do is get the format from PKEY_AudioEngine_DeviceFormat. This should give us a channel count we assume is
-        correct which will simplify our searching.
-        */
-        hr = ma_IMMDevice_OpenPropertyStore((ma_IMMDevice*)pMMDevice, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT var;
-            ma_PropVariantInit(&var);
-
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_AudioEngine_DeviceFormat, &var);
-            if (SUCCEEDED(hr)) {
-                pWF = (WAVEFORMATEX*)var.blob.pBlobData;
-
-                /*
-                In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format
-                first. If this fails, fall back to a search.
-                */
-                hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL);
-                if (SUCCEEDED(hr)) {
-                    /* The format returned by PKEY_AudioEngine_DeviceFormat is supported. */
-                    ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_exclusive, pInfo);
-                } else {
-                    /*
-                    The format returned by PKEY_AudioEngine_DeviceFormat is not supported, so fall back to a search. We assume the channel
-                    count returned by MA_PKEY_AudioEngine_DeviceFormat is valid and correct. For simplicity we're only returning one format.
-                    */
-                    ma_uint32 channels = pInfo->minChannels;
-                    ma_channel defaultChannelMap[MA_MAX_CHANNELS];
-                    WAVEFORMATEXTENSIBLE wf;
-                    ma_bool32 found;
-                    ma_uint32 iFormat;
-
-                    /* Make sure we don't overflow the channel map. */
-                    if (channels > MA_MAX_CHANNELS) {
-                        channels = MA_MAX_CHANNELS;
-                    }
-
-                    ma_get_standard_channel_map(ma_standard_channel_map_microsoft, channels, defaultChannelMap);
-
-                    MA_ZERO_OBJECT(&wf);
-                    wf.Format.cbSize     = sizeof(wf);
-                    wf.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
-                    wf.Format.nChannels  = (WORD)channels;
-                    wf.dwChannelMask     = ma_channel_map_to_channel_mask__win32(defaultChannelMap, channels);
-
-                    found = MA_FALSE;
-                    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) {
-                        ma_format format = g_maFormatPriorities[iFormat];
-                        ma_uint32 iSampleRate;
-
-                        wf.Format.wBitsPerSample       = (WORD)(ma_get_bytes_per_sample(format)*8);
-                        wf.Format.nBlockAlign          = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-                        wf.Format.nAvgBytesPerSec      = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-                        wf.Samples.wValidBitsPerSample = /*(format == ma_format_s24_32) ? 24 :*/ wf.Format.wBitsPerSample;
-                        if (format == ma_format_f32) {
-                            wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
-                        } else {
-                            wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-                        }
-
-                        for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iSampleRate) {
-                            wf.Format.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate];
-
-                            hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (WAVEFORMATEX*)&wf, NULL);
-                            if (SUCCEEDED(hr)) {
-                                ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo);
-                                found = MA_TRUE;
-                                break;
-                            }
-                        }
-
-                        if (found) {
-                            break;
-                        }
-                    }
-
-                    ma_PropVariantClear(pContext, &var);
-
-                    if (!found) {
-                        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to find suitable device format for device info retrieval.", MA_FORMAT_NOT_SUPPORTED);
-                    }
-                }
-            } else {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to retrieve device format for device info retrieval.", ma_result_from_HRESULT(hr));
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        } else {
-            ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to open property store for device info retrieval.", ma_result_from_HRESULT(hr));
-        }
-    }
-    #endif
-
-    return MA_SUCCESS;
-}
-
-#ifdef MA_WIN32_DESKTOP
-static ma_EDataFlow ma_device_type_to_EDataFlow(ma_device_type deviceType)
-{
-    if (deviceType == ma_device_type_playback) {
-        return ma_eRender;
-    } else if (deviceType == ma_device_type_capture) {
-        return ma_eCapture;
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return ma_eRender; /* Should never hit this. */
-    }
-}
-
-static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator** ppDeviceEnumerator)
-{
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-
-    MA_ASSERT(pContext           != NULL);
-    MA_ASSERT(ppDeviceEnumerator != NULL);
-
-    *ppDeviceEnumerator = NULL; /* Safety. */
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDeviceEnumerator = pDeviceEnumerator;
-
-    return MA_SUCCESS;
-}
-
-static LPWSTR ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType)
-{
-    HRESULT hr;
-    ma_IMMDevice* pMMDefaultDevice = NULL;
-    LPWSTR pDefaultDeviceID = NULL;
-    ma_EDataFlow dataFlow;
-    ma_ERole role;
-
-    MA_ASSERT(pContext          != NULL);
-    MA_ASSERT(pDeviceEnumerator != NULL);
-
-    (void)pContext;
-
-    /* Grab the EDataFlow type from the device type. */
-    dataFlow = ma_device_type_to_EDataFlow(deviceType);
-
-    /* The role is always eConsole, but we may make this configurable later. */
-    role = ma_eConsole;
-
-    hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, dataFlow, role, &pMMDefaultDevice);
-    if (FAILED(hr)) {
-        return NULL;
-    }
-
-    hr = ma_IMMDevice_GetId(pMMDefaultDevice, &pDefaultDeviceID);
-
-    ma_IMMDevice_Release(pMMDefaultDevice);
-    pMMDefaultDevice = NULL;
-
-    if (FAILED(hr)) {
-        return NULL;
-    }
-
-    return pDefaultDeviceID;
-}
-
-static LPWSTR ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_device_type deviceType)    /* Free the returned pointer with ma_CoTaskMemFree() */
-{
-    ma_result result;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-    LPWSTR pDefaultDeviceID = NULL;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_context_create_IMMDeviceEnumerator__wasapi(pContext, &pDeviceEnumerator);
-    if (result != MA_SUCCESS) {
-        return NULL;
-    }
-
-    pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType);
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    return pDefaultDeviceID;
-}
-
-static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IMMDevice** ppMMDevice)
-{
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppMMDevice != NULL);
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    if (pDeviceID == NULL) {
-        hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, (deviceType == ma_device_type_capture) ? ma_eCapture : ma_eRender, ma_eConsole, ppMMDevice);
-    } else {
-        hr = ma_IMMDeviceEnumerator_GetDevice(pDeviceEnumerator, pDeviceID->wasapi, ppMMDevice);
-    }
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.", ma_result_from_HRESULT(hr));
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID)
-{
-    LPWSTR pDeviceIDString;
-    HRESULT hr;
-
-    MA_ASSERT(pDeviceID != NULL);
-
-    hr = ma_IMMDevice_GetId(pMMDevice, &pDeviceIDString);
-    if (SUCCEEDED(hr)) {
-        size_t idlen = wcslen(pDeviceIDString);
-        if (idlen+1 > ma_countof(pDeviceID->wasapi)) {
-            ma_CoTaskMemFree(pContext, pDeviceIDString);
-            MA_ASSERT(MA_FALSE);  /* NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. */
-            return MA_ERROR;
-        }
-
-        MA_COPY_MEMORY(pDeviceID->wasapi, pDeviceIDString, idlen * sizeof(wchar_t));
-        pDeviceID->wasapi[idlen] = '\0';
-
-        ma_CoTaskMemFree(pContext, pDeviceIDString);
-
-        return MA_SUCCESS;
-    }
-
-    return MA_ERROR;
-}
-
-static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, LPWSTR pDefaultDeviceID, ma_bool32 onlySimpleInfo, ma_device_info* pInfo)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pMMDevice != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    /* ID. */
-    result = ma_context_get_device_id_from_MMDevice__wasapi(pContext, pMMDevice, &pInfo->id);
-    if (result == MA_SUCCESS) {
-        if (pDefaultDeviceID != NULL) {
-            if (wcscmp(pInfo->id.wasapi, pDefaultDeviceID) == 0) {
-                pInfo->isDefault = MA_TRUE;
-            }
-        }
-    }
-
-    /* Description / Friendly Name */
-    {
-        ma_IPropertyStore *pProperties;
-        hr = ma_IMMDevice_OpenPropertyStore(pMMDevice, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT var;
-
-            ma_PropVariantInit(&var);
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &var);
-            if (SUCCEEDED(hr)) {
-                WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, pInfo->name, sizeof(pInfo->name), 0, FALSE);
-                ma_PropVariantClear(pContext, &var);
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        }
-    }
-
-    /* Format */
-    if (!onlySimpleInfo) {
-        ma_IAudioClient* pAudioClient;
-        hr = ma_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient);
-        if (SUCCEEDED(hr)) {
-            result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, pMMDevice, pAudioClient, pInfo);
-
-            ma_IAudioClient_Release(pAudioClient);
-            return result;
-        } else {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate audio client for device info retrieval.", ma_result_from_HRESULT(hr));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result = MA_SUCCESS;
-    UINT deviceCount;
-    HRESULT hr;
-    ma_uint32 iDevice;
-    LPWSTR pDefaultDeviceID = NULL;
-    ma_IMMDeviceCollection* pDeviceCollection = NULL;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Grab the default device. We use this to know whether or not flag the returned device info as being the default. */
-    pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType);
-
-    /* We need to enumerate the devices which returns a device collection. */
-    hr = ma_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, ma_device_type_to_EDataFlow(deviceType), MA_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection);
-    if (SUCCEEDED(hr)) {
-        hr = ma_IMMDeviceCollection_GetCount(pDeviceCollection, &deviceCount);
-        if (FAILED(hr)) {
-            result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get device count.", ma_result_from_HRESULT(hr));
-            goto done;
-        }
-
-        for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            ma_IMMDevice* pMMDevice;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-
-            hr = ma_IMMDeviceCollection_Item(pDeviceCollection, iDevice, &pMMDevice);
-            if (SUCCEEDED(hr)) {
-                result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_TRUE, &deviceInfo);   /* MA_TRUE = onlySimpleInfo. */
-
-                ma_IMMDevice_Release(pMMDevice);
-                if (result == MA_SUCCESS) {
-                    ma_bool32 cbResult = callback(pContext, deviceType, &deviceInfo, pUserData);
-                    if (cbResult == MA_FALSE) {
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
-done:
-    if (pDefaultDeviceID != NULL) {
-        ma_CoTaskMemFree(pContext, pDefaultDeviceID);
-        pDefaultDeviceID = NULL;
-    }
-
-    if (pDeviceCollection != NULL) {
-        ma_IMMDeviceCollection_Release(pDeviceCollection);
-        pDeviceCollection = NULL;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IMMDevice** ppMMDevice)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppAudioClient != NULL);
-    MA_ASSERT(ppMMDevice != NULL);
-
-    result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, ppMMDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    hr = ma_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)ppAudioClient);
-    if (FAILED(hr)) {
-        return ma_result_from_HRESULT(hr);
-    }
-
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface)
-{
-    ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL;
-    ma_completion_handler_uwp completionHandler;
-    IID iid;
-    LPOLESTR iidStr;
-    HRESULT hr;
-    ma_result result;
-    HRESULT activateResult;
-    ma_IUnknown* pActivatedInterface;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppAudioClient != NULL);
-
-    if (pDeviceID != NULL) {
-        MA_COPY_MEMORY(&iid, pDeviceID->wasapi, sizeof(iid));
-    } else {
-        if (deviceType == ma_device_type_playback) {
-            iid = MA_IID_DEVINTERFACE_AUDIO_RENDER;
-        } else {
-            iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE;
-        }
-    }
-
-#if defined(__cplusplus)
-    hr = StringFromIID(iid, &iidStr);
-#else
-    hr = StringFromIID(&iid, &iidStr);
-#endif
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.", ma_result_from_HRESULT(hr));
-    }
-
-    result = ma_completion_handler_uwp_init(&completionHandler);
-    if (result != MA_SUCCESS) {
-        ma_CoTaskMemFree(pContext, iidStr);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().", result);
-    }
-
-#if defined(__cplusplus)
-    hr = ActivateAudioInterfaceAsync(iidStr, MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#else
-    hr = ActivateAudioInterfaceAsync(iidStr, &MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#endif
-    if (FAILED(hr)) {
-        ma_completion_handler_uwp_uninit(&completionHandler);
-        ma_CoTaskMemFree(pContext, iidStr);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.", ma_result_from_HRESULT(hr));
-    }
-
-    ma_CoTaskMemFree(pContext, iidStr);
-
-    /* Wait for the async operation for finish. */
-    ma_completion_handler_uwp_wait(&completionHandler);
-    ma_completion_handler_uwp_uninit(&completionHandler);
-
-    hr = ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(pAsyncOp, &activateResult, &pActivatedInterface);
-    ma_IActivateAudioInterfaceAsyncOperation_Release(pAsyncOp);
-
-    if (FAILED(hr) || FAILED(activateResult)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.", FAILED(hr) ? ma_result_from_HRESULT(hr) : ma_result_from_HRESULT(activateResult));
-    }
-
-    /* Here is where we grab the IAudioClient interface. */
-    hr = ma_IUnknown_QueryInterface(pActivatedInterface, &MA_IID_IAudioClient, (void**)ppAudioClient);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.", ma_result_from_HRESULT(hr));
-    }
-
-    if (ppActivatedInterface) {
-        *ppActivatedInterface = pActivatedInterface;
-    } else {
-        ma_IUnknown_Release(pActivatedInterface);
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_WASAPIDeviceInterface** ppDeviceInterface)
-{
-#ifdef MA_WIN32_DESKTOP
-    return ma_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
-#else
-    return ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
-#endif
-}
-
-
-static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    /* Different enumeration for desktop and UWP. */
-#ifdef MA_WIN32_DESKTOP
-    /* Desktop */
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_playback, callback, pUserData);
-    ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_capture,  callback, pUserData);
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-#else
-    /*
-    UWP
-
-    The MMDevice API is only supported on desktop applications. For now, while I'm still figuring out how to properly enumerate
-    over devices without using MMDevice, I'm restricting devices to defaults.
-
-    Hint: DeviceInformation::FindAllAsync() with DeviceClass.AudioCapture/AudioRender. https://blogs.windows.com/buildingapps/2014/05/15/real-time-audio-in-windows-store-and-windows-phone-apps/
-    */
-    if (callback) {
-        ma_bool32 cbResult = MA_TRUE;
-
-        /* Playback. */
-        if (cbResult) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;
-            cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-        }
-
-        /* Capture. */
-        if (cbResult) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-#ifdef MA_WIN32_DESKTOP
-    ma_result result;
-    ma_IMMDevice* pMMDevice = NULL;
-    LPWSTR pDefaultDeviceID = NULL;
-
-    result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* We need the default device ID so we can set the isDefault flag in the device info. */
-    pDefaultDeviceID = ma_context_get_default_device_id__wasapi(pContext, deviceType);
-
-    result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_FALSE, pDeviceInfo);   /* MA_FALSE = !onlySimpleInfo. */
-
-    if (pDefaultDeviceID != NULL) {
-        ma_CoTaskMemFree(pContext, pDefaultDeviceID);
-        pDefaultDeviceID = NULL;
-    }
-
-    ma_IMMDevice_Release(pMMDevice);
-
-    return result;
-#else
-    ma_IAudioClient* pAudioClient;
-    ma_result result;
-
-    /* UWP currently only uses default devices. */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, &pAudioClient, NULL);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, NULL, pAudioClient, pDeviceInfo);
-
-    pDeviceInfo->isDefault = MA_TRUE;  /* UWP only supports default devices. */
-
-    ma_IAudioClient_Release(pAudioClient);
-    return result;
-#endif
-}
-
-static ma_result ma_device_uninit__wasapi(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-#ifdef MA_WIN32_DESKTOP
-    if (pDevice->wasapi.pDeviceEnumerator) {
-        ((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator)->lpVtbl->UnregisterEndpointNotificationCallback((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator, &pDevice->wasapi.notificationClient);
-        ma_IMMDeviceEnumerator_Release((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator);
-    }
-#endif
-
-    if (pDevice->wasapi.pRenderClient) {
-        ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-    }
-    if (pDevice->wasapi.pCaptureClient) {
-        ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-    }
-
-    if (pDevice->wasapi.pAudioClientPlayback) {
-        ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-    }
-    if (pDevice->wasapi.pAudioClientCapture) {
-        ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-    }
-
-    if (pDevice->wasapi.hEventPlayback) {
-        CloseHandle(pDevice->wasapi.hEventPlayback);
-    }
-    if (pDevice->wasapi.hEventCapture) {
-        CloseHandle(pDevice->wasapi.hEventCapture);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    /* Input. */
-    ma_format formatIn;
-    ma_uint32 channelsIn;
-    ma_uint32 sampleRateIn;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesIn;
-    ma_uint32 periodSizeInMillisecondsIn;
-    ma_uint32 periodsIn;
-    ma_share_mode shareMode;
-    ma_performance_profile performanceProfile;
-    ma_bool32 noAutoConvertSRC;
-    ma_bool32 noDefaultQualitySRC;
-    ma_bool32 noHardwareOffloading;
-
-    /* Output. */
-    ma_IAudioClient* pAudioClient;
-    ma_IAudioRenderClient* pRenderClient;
-    ma_IAudioCaptureClient* pCaptureClient;
-    ma_format formatOut;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesOut;
-    ma_uint32 periodsOut;
-    ma_bool32 usingAudioClient3;
-    char deviceName[256];
-    ma_device_id id;
-} ma_device_init_internal_data__wasapi;
-
-static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__wasapi* pData)
-{
-    HRESULT hr;
-    ma_result result = MA_SUCCESS;
-    const char* errorMsg = "";
-    MA_AUDCLNT_SHAREMODE shareMode = MA_AUDCLNT_SHAREMODE_SHARED;
-    DWORD streamFlags = 0;
-    MA_REFERENCE_TIME periodDurationInMicroseconds;
-    ma_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE;
-    WAVEFORMATEXTENSIBLE wf;
-    ma_WASAPIDeviceInterface* pDeviceInterface = NULL;
-    ma_IAudioClient2* pAudioClient2;
-    ma_uint32 nativeSampleRate;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pData != NULL);
-
-    /* This function is only used to initialize one device type: either playback, capture or loopback. Never full-duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    pData->pAudioClient = NULL;
-    pData->pRenderClient = NULL;
-    pData->pCaptureClient = NULL;
-
-    streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
-    if (!pData->noAutoConvertSRC && pData->sampleRateIn != 0 && pData->shareMode != ma_share_mode_exclusive) {    /* <-- Exclusive streams must use the native sample rate. */
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM;
-    }
-    if (!pData->noDefaultQualitySRC && pData->sampleRateIn != 0 && (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) != 0) {
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY;
-    }
-    if (deviceType == ma_device_type_loopback) {
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_LOOPBACK;
-    }
-
-    result = ma_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, &pData->pAudioClient, &pDeviceInterface);
-    if (result != MA_SUCCESS) {
-        goto done;
-    }
-
-    MA_ZERO_OBJECT(&wf);
-
-    /* Try enabling hardware offloading. */
-    if (!pData->noHardwareOffloading) {
-        hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient2, (void**)&pAudioClient2);
-        if (SUCCEEDED(hr)) {
-            BOOL isHardwareOffloadingSupported = 0;
-            hr = ma_IAudioClient2_IsOffloadCapable(pAudioClient2, MA_AudioCategory_Other, &isHardwareOffloadingSupported);
-            if (SUCCEEDED(hr) && isHardwareOffloadingSupported) {
-                ma_AudioClientProperties clientProperties;
-                MA_ZERO_OBJECT(&clientProperties);
-                clientProperties.cbSize = sizeof(clientProperties);
-                clientProperties.bIsOffload = 1;
-                clientProperties.eCategory = MA_AudioCategory_Other;
-                ma_IAudioClient2_SetClientProperties(pAudioClient2, &clientProperties);
-            }
-
-            pAudioClient2->lpVtbl->Release(pAudioClient2);
-        }
-    }
-
-    /* Here is where we try to determine the best format to use with the device. If the client if wanting exclusive mode, first try finding the best format for that. If this fails, fall back to shared mode. */
-    result = MA_FORMAT_NOT_SUPPORTED;
-    if (pData->shareMode == ma_share_mode_exclusive) {
-    #ifdef MA_WIN32_DESKTOP
-        /* In exclusive mode on desktop we always use the backend's native format. */
-        ma_IPropertyStore* pStore = NULL;
-        hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT prop;
-            ma_PropVariantInit(&prop);
-            hr = ma_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop);
-            if (SUCCEEDED(hr)) {
-                WAVEFORMATEX* pActualFormat = (WAVEFORMATEX*)prop.blob.pBlobData;
-                hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL);
-                if (SUCCEEDED(hr)) {
-                    MA_COPY_MEMORY(&wf, pActualFormat, sizeof(WAVEFORMATEXTENSIBLE));
-                }
-
-                ma_PropVariantClear(pContext, &prop);
-            }
-
-            ma_IPropertyStore_Release(pStore);
-        }
-    #else
-        /*
-        I do not know how to query the device's native format on UWP so for now I'm just disabling support for
-        exclusive mode. The alternative is to enumerate over different formats and check IsFormatSupported()
-        until you find one that works.
-
-        TODO: Add support for exclusive mode to UWP.
-        */
-        hr = S_FALSE;
-    #endif
-
-        if (hr == S_OK) {
-            shareMode = MA_AUDCLNT_SHAREMODE_EXCLUSIVE;
-            result = MA_SUCCESS;
-        } else {
-            result = MA_SHARE_MODE_NOT_SUPPORTED;
-        }
-    } else {
-        /* In shared mode we are always using the format reported by the operating system. */
-        WAVEFORMATEXTENSIBLE* pNativeFormat = NULL;
-        hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (WAVEFORMATEX**)&pNativeFormat);
-        if (hr != S_OK) {
-            result = MA_FORMAT_NOT_SUPPORTED;
-        } else {
-            MA_COPY_MEMORY(&wf, pNativeFormat, sizeof(wf));
-            result = MA_SUCCESS;
-        }
-
-        ma_CoTaskMemFree(pContext, pNativeFormat);
-
-        shareMode = MA_AUDCLNT_SHAREMODE_SHARED;
-    }
-
-    /* Return an error if we still haven't found a format. */
-    if (result != MA_SUCCESS) {
-        errorMsg = "[WASAPI] Failed to find best device mix format.";
-        goto done;
-    }
-
-    /*
-    Override the native sample rate with the one requested by the caller, but only if we're not using the default sample rate. We'll use
-    WASAPI to perform the sample rate conversion.
-    */
-    nativeSampleRate = wf.Format.nSamplesPerSec;
-    if (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) {
-        wf.Format.nSamplesPerSec = (pData->sampleRateIn != 0) ? pData->sampleRateIn : MA_DEFAULT_SAMPLE_RATE;
-        wf.Format.nAvgBytesPerSec = wf.Format.nSamplesPerSec * wf.Format.nBlockAlign;
-    }
-
-    pData->formatOut = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)&wf);
-    if (pData->formatOut == ma_format_unknown) {
-        /*
-        The format isn't supported. This is almost certainly because the exclusive mode format isn't supported by miniaudio. We need to return MA_SHARE_MODE_NOT_SUPPORTED
-        in this case so that the caller can detect it and fall back to shared mode if desired. We should never get here if shared mode was requested, but just for
-        completeness we'll check for it and return MA_FORMAT_NOT_SUPPORTED.
-        */
-        if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) {
-            result = MA_SHARE_MODE_NOT_SUPPORTED;
-        } else {
-            result = MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        errorMsg = "[WASAPI] Native format not supported.";
-        goto done;
-    }
-
-    pData->channelsOut = wf.Format.nChannels;
-    pData->sampleRateOut = wf.Format.nSamplesPerSec;
-
-    /* Get the internal channel map based on the channel mask. */
-    ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pData->channelsOut, pData->channelMapOut);
-
-    /* Period size. */
-    pData->periodsOut = (pData->periodsIn != 0) ? pData->periodsIn : MA_DEFAULT_PERIODS;
-    pData->periodSizeInFramesOut = pData->periodSizeInFramesIn;
-    if (pData->periodSizeInFramesOut == 0) {
-        if (pData->periodSizeInMillisecondsIn == 0) {
-            if (pData->performanceProfile == ma_performance_profile_low_latency) {
-                pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, wf.Format.nSamplesPerSec);
-            } else {
-                pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, wf.Format.nSamplesPerSec);
-            }
-        } else {
-            pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, wf.Format.nSamplesPerSec);
-        }
-    }
-
-    periodDurationInMicroseconds = ((ma_uint64)pData->periodSizeInFramesOut * 1000 * 1000) / wf.Format.nSamplesPerSec;
-
-
-    /* Slightly different initialization for shared and exclusive modes. We try exclusive mode first, and if it fails, fall back to shared mode. */
-    if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) {
-        MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * 10;
-
-        /*
-        If the periodicy is too small, Initialize() will fail with AUDCLNT_E_INVALID_DEVICE_PERIOD. In this case we should just keep increasing
-        it and trying it again.
-        */
-        hr = E_FAIL;
-        for (;;) {
-            hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
-            if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) {
-                if (bufferDuration > 500*10000) {
-                    break;
-                } else {
-                    if (bufferDuration == 0) {  /* <-- Just a sanity check to prevent an infinit loop. Should never happen, but it makes me feel better. */
-                        break;
-                    }
-
-                    bufferDuration = bufferDuration * 2;
-                    continue;
-                }
-            } else {
-                break;
-            }
-        }
-
-        if (hr == MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) {
-            ma_uint32 bufferSizeInFrames;
-            hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
-            if (SUCCEEDED(hr)) {
-                bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.Format.nSamplesPerSec * bufferSizeInFrames) + 0.5);
-
-                /* Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?! */
-                ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient);
-
-            #ifdef MA_WIN32_DESKTOP
-                hr = ma_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient);
-            #else
-                hr = ma_IUnknown_QueryInterface(pDeviceInterface, &MA_IID_IAudioClient, (void**)&pData->pAudioClient);
-            #endif
-
-                if (SUCCEEDED(hr)) {
-                    hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
-                }
-            }
-        }
-
-        if (FAILED(hr)) {
-            /* Failed to initialize in exclusive mode. Don't fall back to shared mode - instead tell the client about it. They can reinitialize in shared mode if they want. */
-            if (hr == E_ACCESSDENIED) {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Access denied.", result = MA_ACCESS_DENIED;
-            } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Device in use.", result = MA_BUSY;
-            } else {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode."; result = ma_result_from_HRESULT(hr);
-            }
-            goto done;
-        }
-    }
-
-    if (shareMode == MA_AUDCLNT_SHAREMODE_SHARED) {
-        /*
-        Low latency shared mode via IAudioClient3.
-
-        NOTE
-        ====
-        Contrary to the documentation on MSDN (https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclient3-initializesharedaudiostream), the
-        use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM and AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY with IAudioClient3_InitializeSharedAudioStream() absolutely does not work. Using
-        any of these flags will result in HRESULT code 0x88890021. The other problem is that calling IAudioClient3_GetSharedModeEnginePeriod() with a sample rate different to
-        that returned by IAudioClient_GetMixFormat() also results in an error. I'm therefore disabling low-latency shared mode with AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM.
-        */
-#ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE
-        if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.Format.nSamplesPerSec) {
-            ma_IAudioClient3* pAudioClient3 = NULL;
-            hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3);
-            if (SUCCEEDED(hr)) {
-                ma_uint32 defaultPeriodInFrames;
-                ma_uint32 fundamentalPeriodInFrames;
-                ma_uint32 minPeriodInFrames;
-                ma_uint32 maxPeriodInFrames;
-                hr = ma_IAudioClient3_GetSharedModeEnginePeriod(pAudioClient3, (WAVEFORMATEX*)&wf, &defaultPeriodInFrames, &fundamentalPeriodInFrames, &minPeriodInFrames, &maxPeriodInFrames);
-                if (SUCCEEDED(hr)) {
-                    ma_uint32 desiredPeriodInFrames = pData->periodSizeInFramesOut;
-                    ma_uint32 actualPeriodInFrames  = desiredPeriodInFrames;
-
-                    /* Make sure the period size is a multiple of fundamentalPeriodInFrames. */
-                    actualPeriodInFrames = actualPeriodInFrames / fundamentalPeriodInFrames;
-                    actualPeriodInFrames = actualPeriodInFrames * fundamentalPeriodInFrames;
-
-                    /* The period needs to be clamped between minPeriodInFrames and maxPeriodInFrames. */
-                    actualPeriodInFrames = ma_clamp(actualPeriodInFrames, minPeriodInFrames, maxPeriodInFrames);
-
-                #if defined(MA_DEBUG_OUTPUT)
-                    printf("[WASAPI] Trying IAudioClient3_InitializeSharedAudioStream(actualPeriodInFrames=%d)\n", actualPeriodInFrames);
-                    printf("    defaultPeriodInFrames=%d\n", defaultPeriodInFrames);
-                    printf("    fundamentalPeriodInFrames=%d\n", fundamentalPeriodInFrames);
-                    printf("    minPeriodInFrames=%d\n", minPeriodInFrames);
-                    printf("    maxPeriodInFrames=%d\n", maxPeriodInFrames);
-                #endif
-
-                    /* If the client requested a largish buffer than we don't actually want to use low latency shared mode because it forces small buffers. */
-                    if (actualPeriodInFrames >= desiredPeriodInFrames) {
-                        /*
-                        MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY must not be in the stream flags. If either of these are specified,
-                        IAudioClient3_InitializeSharedAudioStream() will fail.
-                        */
-                        hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (WAVEFORMATEX*)&wf, NULL);
-                        if (SUCCEEDED(hr)) {
-                            wasInitializedUsingIAudioClient3 = MA_TRUE;
-                            pData->periodSizeInFramesOut = actualPeriodInFrames;
-                        #if defined(MA_DEBUG_OUTPUT)
-                            printf("[WASAPI] Using IAudioClient3\n");
-                            printf("    periodSizeInFramesOut=%d\n", pData->periodSizeInFramesOut);
-                        #endif
-                        } else {
-                        #if defined(MA_DEBUG_OUTPUT)
-                            printf("[WASAPI] IAudioClient3_InitializeSharedAudioStream failed. Falling back to IAudioClient.\n");
-                        #endif
-                        }
-                    } else {
-                    #if defined(MA_DEBUG_OUTPUT)
-                        printf("[WASAPI] Not using IAudioClient3 because the desired period size is larger than the maximum supported by IAudioClient3.\n");
-                    #endif
-                    }
-                } else {
-                #if defined(MA_DEBUG_OUTPUT)
-                    printf("[WASAPI] IAudioClient3_GetSharedModeEnginePeriod failed. Falling back to IAudioClient.\n");
-                #endif
-                }
-
-                ma_IAudioClient3_Release(pAudioClient3);
-                pAudioClient3 = NULL;
-            }
-        }
-#else
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("[WASAPI] Not using IAudioClient3 because MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE is enabled.\n");
-    #endif
-#endif
-
-        /* If we don't have an IAudioClient3 then we need to use the normal initialization routine. */
-        if (!wasInitializedUsingIAudioClient3) {
-            MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10;   /* <-- Multiply by 10 for microseconds to 100-nanoseconds. */
-            hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (WAVEFORMATEX*)&wf, NULL);
-            if (FAILED(hr)) {
-                if (hr == E_ACCESSDENIED) {
-                    errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED;
-                } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) {
-                    errorMsg = "[WASAPI] Failed to initialize device. Device in use.", result = MA_BUSY;
-                } else {
-                    errorMsg = "[WASAPI] Failed to initialize device.", result = ma_result_from_HRESULT(hr);
-                }
-
-                goto done;
-            }
-        }
-    }
-
-    if (!wasInitializedUsingIAudioClient3) {
-        ma_uint32 bufferSizeInFrames;
-        hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
-        if (FAILED(hr)) {
-            errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = ma_result_from_HRESULT(hr);
-            goto done;
-        }
-
-        pData->periodSizeInFramesOut = bufferSizeInFrames / pData->periodsOut;
-    }
-
-    pData->usingAudioClient3 = wasInitializedUsingIAudioClient3;
-
-    
-    if (deviceType == ma_device_type_playback) {
-        result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pRenderClient);
-    } else {
-        result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pCaptureClient);
-    }
-
-    /*if (FAILED(hr)) {*/
-    if (result != MA_SUCCESS) {
-        errorMsg = "[WASAPI] Failed to get audio client service.";
-        goto done;
-    }
-
-
-    /* Grab the name of the device. */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        ma_IPropertyStore *pProperties;
-        hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT varName;
-            ma_PropVariantInit(&varName);
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &varName);
-            if (SUCCEEDED(hr)) {
-                WideCharToMultiByte(CP_UTF8, 0, varName.pwszVal, -1, pData->deviceName, sizeof(pData->deviceName), 0, FALSE);
-                ma_PropVariantClear(pContext, &varName);
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        }
-    }
-    #endif
-
-    /*
-    For the WASAPI backend we need to know the actual IDs of the device in order to do automatic
-    stream routing so that IDs can be compared and we can determine which device has been detached
-    and whether or not it matches with our ma_device.
-    */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        /* Desktop */
-        ma_context_get_device_id_from_MMDevice__wasapi(pContext, pDeviceInterface, &pData->id);
-    }
-    #else
-    {
-        /* UWP */
-        /* TODO: Implement me. Need to figure out how to get the ID of the default device. */
-    }
-    #endif
-
-done:
-    /* Clean up. */
-#ifdef MA_WIN32_DESKTOP
-    if (pDeviceInterface != NULL) {
-        ma_IMMDevice_Release(pDeviceInterface);
-    }
-#else
-    if (pDeviceInterface != NULL) {
-        ma_IUnknown_Release(pDeviceInterface);
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        if (pData->pRenderClient) {
-            ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pData->pRenderClient);
-            pData->pRenderClient = NULL;
-        }
-        if (pData->pCaptureClient) {
-            ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pData->pCaptureClient);
-            pData->pCaptureClient = NULL;
-        }
-        if (pData->pAudioClient) {
-            ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient);
-            pData->pAudioClient = NULL;
-        }
-
-        if (errorMsg != NULL && errorMsg[0] != '\0') {
-            ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, errorMsg, result);
-        }
-
-        return result;
-    } else {
-        return MA_SUCCESS;
-    }
-}
-
-static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_device_init_internal_data__wasapi data;
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* We only re-initialize the playback or capture device. Never a full-duplex device. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-
-    /*
-    Before reinitializing the device we need to free the previous audio clients.
-
-    There's a known memory leak here. We will be calling this from the routing change callback that
-    is fired by WASAPI. If we attempt to release the IAudioClient we will deadlock. In my opinion
-    this is a bug. I'm not sure what I need to do to handle this cleanly, but I think we'll probably
-    need some system where we post an event, but delay the execution of it until the callback has
-    returned. I'm not sure how to do this reliably, however. I have set up some infrastructure for
-    a command thread which might be useful for this.
-    */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) {
-        if (pDevice->wasapi.pCaptureClient) {
-            ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-            pDevice->wasapi.pCaptureClient = NULL;
-        }
-
-        if (pDevice->wasapi.pAudioClientCapture) {
-            /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_capture);*/
-            pDevice->wasapi.pAudioClientCapture = NULL;
-        }
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        if (pDevice->wasapi.pRenderClient) {
-            ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-            pDevice->wasapi.pRenderClient = NULL;
-        }
-
-        if (pDevice->wasapi.pAudioClientPlayback) {
-            /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_playback);*/
-            pDevice->wasapi.pAudioClientPlayback = NULL;
-        }
-    }
-
-
-    if (deviceType == ma_device_type_playback) {
-        data.formatIn               = pDevice->playback.format;
-        data.channelsIn             = pDevice->playback.channels;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap));
-        data.shareMode              = pDevice->playback.shareMode;
-    } else {
-        data.formatIn               = pDevice->capture.format;
-        data.channelsIn             = pDevice->capture.channels;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap));
-        data.shareMode              = pDevice->capture.shareMode;
-    }
-
-    data.sampleRateIn               = pDevice->sampleRate;
-    data.periodSizeInFramesIn       = pDevice->wasapi.originalPeriodSizeInFrames;
-    data.periodSizeInMillisecondsIn = pDevice->wasapi.originalPeriodSizeInMilliseconds;
-    data.periodsIn                  = pDevice->wasapi.originalPeriods;
-    data.performanceProfile         = pDevice->wasapi.originalPerformanceProfile;
-    data.noAutoConvertSRC           = pDevice->wasapi.noAutoConvertSRC;
-    data.noDefaultQualitySRC        = pDevice->wasapi.noDefaultQualitySRC;
-    data.noHardwareOffloading       = pDevice->wasapi.noHardwareOffloading;
-    result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* At this point we have some new objects ready to go. We need to uninitialize the previous ones and then set the new ones. */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) {
-        pDevice->wasapi.pAudioClientCapture         = data.pAudioClient;
-        pDevice->wasapi.pCaptureClient              = data.pCaptureClient;
-
-        pDevice->capture.internalFormat             = data.formatOut;
-        pDevice->capture.internalChannels           = data.channelsOut;
-        pDevice->capture.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->capture.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->capture.internalPeriods            = data.periodsOut;
-        ma_strcpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), data.deviceName);
-
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture,  pDevice->wasapi.hEventCapture);
-
-        pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualPeriodSizeInFramesCapture);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        pDevice->wasapi.pAudioClientPlayback         = data.pAudioClient;
-        pDevice->wasapi.pRenderClient                = data.pRenderClient;
-
-        pDevice->playback.internalFormat             = data.formatOut;
-        pDevice->playback.internalChannels           = data.channelsOut;
-        pDevice->playback.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->playback.internalPeriods            = data.periodsOut;
-        ma_strcpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), data.deviceName);
-
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
-
-        pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualPeriodSizeInFramesPlayback);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result = MA_SUCCESS;
-
-#ifdef MA_WIN32_DESKTOP
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-#endif
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->wasapi);
-    pDevice->wasapi.noAutoConvertSRC     = pConfig->wasapi.noAutoConvertSRC;
-    pDevice->wasapi.noDefaultQualitySRC  = pConfig->wasapi.noDefaultQualitySRC;
-    pDevice->wasapi.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
-
-    /* Exclusive mode is not allowed with loopback. */
-    if (pConfig->deviceType == ma_device_type_loopback && pConfig->playback.shareMode == ma_share_mode_exclusive) {
-        return MA_INVALID_DEVICE_CONFIG;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        ma_device_init_internal_data__wasapi data;
-        data.formatIn                   = pDescriptorCapture->format;
-        data.channelsIn                 = pDescriptorCapture->channels;
-        data.sampleRateIn               = pDescriptorCapture->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap));
-        data.periodSizeInFramesIn       = pDescriptorCapture->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn = pDescriptorCapture->periodSizeInMilliseconds;
-        data.periodsIn                  = pDescriptorCapture->periodCount;
-        data.shareMode                  = pDescriptorCapture->shareMode;
-        data.performanceProfile         = pConfig->performanceProfile;
-        data.noAutoConvertSRC           = pConfig->wasapi.noAutoConvertSRC;
-        data.noDefaultQualitySRC        = pConfig->wasapi.noDefaultQualitySRC;
-        data.noHardwareOffloading       = pConfig->wasapi.noHardwareOffloading;
-
-        result = ma_device_init_internal__wasapi(pDevice->pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture, pDescriptorCapture->pDeviceID, &data);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pDevice->wasapi.pAudioClientCapture              = data.pAudioClient;
-        pDevice->wasapi.pCaptureClient                   = data.pCaptureClient;
-        pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds;
-        pDevice->wasapi.originalPeriodSizeInFrames       = pDescriptorCapture->periodSizeInFrames;
-        pDevice->wasapi.originalPeriods                  = pDescriptorCapture->periodCount;
-        pDevice->wasapi.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        /*
-        The event for capture needs to be manual reset for the same reason as playback. We keep the initial state set to unsignaled,
-        however, because we want to block until we actually have something for the first call to ma_device_read().
-        */
-        pDevice->wasapi.hEventCapture = CreateEventW(NULL, FALSE, FALSE, NULL);  /* Auto reset, unsignaled by default. */
-        if (pDevice->wasapi.hEventCapture == NULL) {
-            result = ma_result_from_GetLastError(GetLastError());
-
-            if (pDevice->wasapi.pCaptureClient != NULL) {
-                ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                pDevice->wasapi.pCaptureClient = NULL;
-            }
-            if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                pDevice->wasapi.pAudioClientCapture = NULL;
-            }
-
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture.", result);
-        }
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, pDevice->wasapi.hEventCapture);
-
-        pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualPeriodSizeInFramesCapture);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
-
-        /* The descriptor needs to be updated with actual values. */
-        pDescriptorCapture->format             = data.formatOut;
-        pDescriptorCapture->channels           = data.channelsOut;
-        pDescriptorCapture->sampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorCapture->periodSizeInFrames = data.periodSizeInFramesOut;
-        pDescriptorCapture->periodCount        = data.periodsOut;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__wasapi data;
-        data.formatIn                   = pDescriptorPlayback->format;
-        data.channelsIn                 = pDescriptorPlayback->channels;
-        data.sampleRateIn               = pDescriptorPlayback->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap));
-        data.periodSizeInFramesIn       = pDescriptorPlayback->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds;
-        data.periodsIn                  = pDescriptorPlayback->periodCount;
-        data.shareMode                  = pDescriptorPlayback->shareMode;
-        data.performanceProfile         = pConfig->performanceProfile;
-        data.noAutoConvertSRC           = pConfig->wasapi.noAutoConvertSRC;
-        data.noDefaultQualitySRC        = pConfig->wasapi.noDefaultQualitySRC;
-        data.noHardwareOffloading       = pConfig->wasapi.noHardwareOffloading;
-
-        result = ma_device_init_internal__wasapi(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                if (pDevice->wasapi.pCaptureClient != NULL) {
-                    ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                    pDevice->wasapi.pCaptureClient = NULL;
-                }
-                if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                    ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                    pDevice->wasapi.pAudioClientCapture = NULL;
-                }
-
-                CloseHandle(pDevice->wasapi.hEventCapture);
-                pDevice->wasapi.hEventCapture = NULL;
-            }
-            return result;
-        }
-
-        pDevice->wasapi.pAudioClientPlayback             = data.pAudioClient;
-        pDevice->wasapi.pRenderClient                    = data.pRenderClient;
-        pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds;
-        pDevice->wasapi.originalPeriodSizeInFrames       = pDescriptorPlayback->periodSizeInFrames;
-        pDevice->wasapi.originalPeriods                  = pDescriptorPlayback->periodCount;
-        pDevice->wasapi.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        /*
-        The event for playback is needs to be manual reset because we want to explicitly control the fact that it becomes signalled
-        only after the whole available space has been filled, never before.
-
-        The playback event also needs to be initially set to a signaled state so that the first call to ma_device_write() is able
-        to get passed WaitForMultipleObjects().
-        */
-        pDevice->wasapi.hEventPlayback = CreateEventW(NULL, FALSE, TRUE, NULL);  /* Auto reset, signaled by default. */
-        if (pDevice->wasapi.hEventPlayback == NULL) {
-            result = ma_result_from_GetLastError(GetLastError());
-
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                if (pDevice->wasapi.pCaptureClient != NULL) {
-                    ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                    pDevice->wasapi.pCaptureClient = NULL;
-                }
-                if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                    ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                    pDevice->wasapi.pAudioClientCapture = NULL;
-                }
-
-                CloseHandle(pDevice->wasapi.hEventCapture);
-                pDevice->wasapi.hEventCapture = NULL;
-            }
-
-            if (pDevice->wasapi.pRenderClient != NULL) {
-                ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-                pDevice->wasapi.pRenderClient = NULL;
-            }
-            if (pDevice->wasapi.pAudioClientPlayback != NULL) {
-                ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                pDevice->wasapi.pAudioClientPlayback = NULL;
-            }
-
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback.", result);
-        }
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
-
-        pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualPeriodSizeInFramesPlayback);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
-
-        /* The descriptor needs to be updated with actual values. */
-        pDescriptorPlayback->format             = data.formatOut;
-        pDescriptorPlayback->channels           = data.channelsOut;
-        pDescriptorPlayback->sampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorPlayback->periodSizeInFrames = data.periodSizeInFramesOut;
-        pDescriptorPlayback->periodCount        = data.periodsOut;
-    }
-
-    /*
-    We need to register a notification client to detect when the device has been disabled, unplugged or re-routed (when the default device changes). When
-    we are connecting to the default device we want to do automatic stream routing when the device is disabled or unplugged. Otherwise we want to just
-    stop the device outright and let the application handle it.
-    */
-#ifdef MA_WIN32_DESKTOP
-    if (pConfig->wasapi.noAutoStreamRouting == MA_FALSE) {
-        if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.pDeviceID == NULL) {
-            pDevice->wasapi.allowCaptureAutoStreamRouting = MA_TRUE;
-        }
-        if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == NULL) {
-            pDevice->wasapi.allowPlaybackAutoStreamRouting = MA_TRUE;
-        }
-    }
-
-    hr = ma_CoCreateInstance(pDevice->pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        ma_device_uninit__wasapi(pDevice);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    pDevice->wasapi.notificationClient.lpVtbl  = (void*)&g_maNotificationCientVtbl;
-    pDevice->wasapi.notificationClient.counter = 1;
-    pDevice->wasapi.notificationClient.pDevice = pDevice;
-
-    hr = pDeviceEnumerator->lpVtbl->RegisterEndpointNotificationCallback(pDeviceEnumerator, &pDevice->wasapi.notificationClient);
-    if (SUCCEEDED(hr)) {
-        pDevice->wasapi.pDeviceEnumerator = (ma_ptr)pDeviceEnumerator;
-    } else {
-        /* Not the end of the world if we fail to register the notification callback. We just won't support automatic stream routing. */
-        ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    }
-#endif
-
-    c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture,  MA_FALSE);
-    c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_IAudioClient* pAudioClient, ma_uint32* pFrameCount)
-{
-    ma_uint32 paddingFramesCount;
-    HRESULT hr;
-    ma_share_mode shareMode;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFrameCount != NULL);
-
-    *pFrameCount = 0;
-
-    if ((ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientPlayback && (ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientCapture) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    I've had a report that GetCurrentPadding() is returning a frame count of 0 which is preventing
-    higher level function calls from doing anything because it thinks nothing is available. I have
-    taken a look at the documentation and it looks like this is unnecessary in exclusive mode.
-
-    From Microsoft's documentation:
-
-        For an exclusive-mode rendering or capture stream that was initialized with the
-        AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag, the client typically has no use for the padding
-        value reported by GetCurrentPadding. Instead, the client accesses an entire buffer during
-        each processing pass.
-
-    Considering this, I'm going to skip GetCurrentPadding() for exclusive mode and just report the
-    entire buffer. This depends on the caller making sure they wait on the event handler.
-    */
-    shareMode = ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) ? pDevice->playback.shareMode : pDevice->capture.shareMode;
-    if (shareMode == ma_share_mode_shared) {
-        /* Shared mode. */
-        hr = ma_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount);
-        if (FAILED(hr)) {
-            return ma_result_from_HRESULT(hr);
-        }
-
-        if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback - paddingFramesCount;
-        } else {
-            *pFrameCount = paddingFramesCount;
-        }
-    } else {
-        /* Exclusive mode. */
-        if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback;
-        } else {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesCapture;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("=== CHANGING DEVICE ===\n");
-#endif
-
-    result = ma_device_reinit__wasapi(pDevice, deviceType);
-    if (result != MA_SUCCESS) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Reinitializing device after route change failed.\n");
-    #endif
-        return result;
-    }
-
-    ma_device__post_init_setup(pDevice, deviceType);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__wasapi(ma_device* pDevice)
-{
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_TRUE);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* No need to do anything for playback as that'll be started automatically in the data loop. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__wasapi(ma_device* pDevice)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* The audio client needs to be reset otherwise restarting will fail. */
-        hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /*
-        The buffer needs to be drained before stopping the device. Not doing this will result in the last few frames not getting output to
-        the speakers. This is a problem for very short sounds because it'll result in a significant portion of it not getting played.
-        */
-        if (c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-            /* We need to make sure we put a timeout here or else we'll risk getting stuck in a deadlock in some cases. */
-            DWORD waitTime = pDevice->wasapi.actualPeriodSizeInFramesPlayback / pDevice->playback.internalSampleRate;
-
-            if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
-                WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
-            } else {
-                ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
-                ma_uint32 framesAvailablePlayback;
-                for (;;) {
-                    result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                    if (result != MA_SUCCESS) {
-                        break;
-                    }
-
-                    if (framesAvailablePlayback >= pDevice->wasapi.actualPeriodSizeInFramesPlayback) {
-                        break;
-                    }
-
-                    /*
-                    Just a safety check to avoid an infinite loop. If this iteration results in a situation where the number of available frames
-                    has not changed, get out of the loop. I don't think this should ever happen, but I think it's nice to have just in case.
-                    */
-                    if (framesAvailablePlayback == prevFramesAvaialablePlayback) {
-                        break;
-                    }
-                    prevFramesAvaialablePlayback = framesAvailablePlayback;
-
-                    WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
-                    ResetEvent(pDevice->wasapi.hEventPlayback); /* Manual reset. */
-                }
-            }
-        }
-
-        hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* The audio client needs to be reset otherwise restarting will fail. */
-        hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-#ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS
-#define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000
-#endif
-
-static ma_result ma_device_data_loop__wasapi(ma_device* pDevice)
-{
-    ma_result result;
-    HRESULT hr;
-    ma_bool32 exitLoop = MA_FALSE;
-    ma_uint32 framesWrittenToPlaybackDevice = 0;
-    ma_uint32 mappedDeviceBufferSizeInFramesCapture = 0;
-    ma_uint32 mappedDeviceBufferSizeInFramesPlayback = 0;
-    ma_uint32 mappedDeviceBufferFramesRemainingCapture = 0;
-    ma_uint32 mappedDeviceBufferFramesRemainingPlayback = 0;
-    BYTE* pMappedDeviceBufferCapture = NULL;
-    BYTE* pMappedDeviceBufferPlayback = NULL;
-    ma_uint32 bpfCaptureDevice = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    ma_uint32 bpfPlaybackDevice = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    ma_uint32 bpfCaptureClient = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-    ma_uint32 bpfPlaybackClient = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-    ma_uint8  inputDataInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 inputDataInClientFormatCap = 0;
-    ma_uint8  outputDataInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 outputDataInClientFormatCap = 0;
-    ma_uint32 outputDataInClientFormatCount = 0;
-    ma_uint32 outputDataInClientFormatConsumed = 0;
-    ma_uint32 periodSizeInFramesCapture = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        periodSizeInFramesCapture  = pDevice->capture.internalPeriodSizeInFrames;
-        inputDataInClientFormatCap = sizeof(inputDataInClientFormat) / bpfCaptureClient;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        outputDataInClientFormatCap = sizeof(outputDataInClientFormat) / bpfPlaybackClient;
-    }
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && !exitLoop) {
-        switch (pDevice->type)
-        {
-            case ma_device_type_duplex:
-            {
-                ma_uint32 framesAvailableCapture;
-                ma_uint32 framesAvailablePlayback;
-                DWORD flagsCapture;    /* Passed to IAudioCaptureClient_GetBuffer(). */
-
-                /* The process is to map the playback buffer and fill it as quickly as possible from input data. */
-                if (pMappedDeviceBufferPlayback == NULL) {
-                    result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                    if (result != MA_SUCCESS) {
-                        return result;
-                    }
-
-                    /*printf("TRACE 1: framesAvailablePlayback=%d\n", framesAvailablePlayback);*/
-
-
-                    /* In exclusive mode, the frame count needs to exactly match the value returned by GetCurrentPadding(). */
-                    if (pDevice->playback.shareMode != ma_share_mode_exclusive) {
-                        if (framesAvailablePlayback > pDevice->wasapi.periodSizeInFramesPlayback) {
-                            framesAvailablePlayback = pDevice->wasapi.periodSizeInFramesPlayback;
-                        }
-                    }
-
-                    /* We're ready to map the playback device's buffer. We don't release this until it's been entirely filled. */
-                    hr = ma_IAudioRenderClient_GetBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedDeviceBufferPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    mappedDeviceBufferSizeInFramesPlayback    = framesAvailablePlayback;
-                    mappedDeviceBufferFramesRemainingPlayback = framesAvailablePlayback;
-                }
-
-                if (mappedDeviceBufferFramesRemainingPlayback > 0) {
-                    /* At this point we should have a buffer available for output. We need to keep writing input samples to it. */
-                    for (;;) {
-                        /* Try grabbing some captured data if we haven't already got a mapped buffer. */
-                        if (pMappedDeviceBufferCapture == NULL) {
-                            if (pDevice->capture.shareMode == ma_share_mode_shared) {
-                                if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                                    return MA_ERROR;   /* Wait failed. */
-                                }
-                            }
-
-                            result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture);
-                            if (result != MA_SUCCESS) {
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            /*printf("TRACE 2: framesAvailableCapture=%d\n", framesAvailableCapture);*/
-
-                            /* Wait for more if nothing is available. */
-                            if (framesAvailableCapture == 0) {
-                                /* In exclusive mode we waited at the top. */
-                                if (pDevice->capture.shareMode != ma_share_mode_shared) {
-                                    if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                                        return MA_ERROR;   /* Wait failed. */
-                                    }
-                                }
-
-                                continue;
-                            }
-
-                            /* Getting here means there's data available for writing to the output device. */
-                            mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                            hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                            if (FAILED(hr)) {
-                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-
-                            /* Overrun detection. */
-                            if ((flagsCapture & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
-                                /* Glitched. Probably due to an overrun. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[WASAPI] Data discontinuity (possible overrun). framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                            #endif
-
-                                /*
-                                Exeriment: If we get an overrun it probably means we're straddling the end of the buffer. In order to prevent a never-ending sequence of glitches let's experiment
-                                by dropping every frame until we're left with only a single period. To do this we just keep retrieving and immediately releasing buffers until we're down to the
-                                last period.
-                                */
-                                if (framesAvailableCapture >= pDevice->wasapi.actualPeriodSizeInFramesCapture) {
-                                #ifdef MA_DEBUG_OUTPUT
-                                    printf("[WASAPI] Synchronizing capture stream. ");
-                                #endif
-                                    do
-                                    {
-                                        hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                                        if (FAILED(hr)) {
-                                            break;
-                                        }
-
-                                        framesAvailableCapture -= mappedDeviceBufferSizeInFramesCapture;
-
-                                        if (framesAvailableCapture > 0) {
-                                            mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                                            hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                                            if (FAILED(hr)) {
-                                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                                exitLoop = MA_TRUE;
-                                                break;
-                                            }
-                                        } else {
-                                            pMappedDeviceBufferCapture = NULL;
-                                            mappedDeviceBufferSizeInFramesCapture = 0;
-                                        }
-                                    } while (framesAvailableCapture > periodSizeInFramesCapture);
-                                #ifdef MA_DEBUG_OUTPUT
-                                    printf("framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                                #endif
-                                }
-                            } else {
-                            #ifdef MA_DEBUG_OUTPUT
-                                if (flagsCapture != 0) {
-                                    printf("[WASAPI] Capture Flags: %ld\n", flagsCapture);
-                                }
-                            #endif
-                            }
-
-                            mappedDeviceBufferFramesRemainingCapture = mappedDeviceBufferSizeInFramesCapture;
-                        }
-
-
-                        /* At this point we should have both input and output data available. We now need to convert the data and post it to the client. */
-                        for (;;) {
-                            BYTE* pRunningDeviceBufferCapture;
-                            BYTE* pRunningDeviceBufferPlayback;
-                            ma_uint32 framesToProcess;
-                            ma_uint32 framesProcessed;
-
-                            pRunningDeviceBufferCapture  = pMappedDeviceBufferCapture  + ((mappedDeviceBufferSizeInFramesCapture  - mappedDeviceBufferFramesRemainingCapture ) * bpfCaptureDevice);
-                            pRunningDeviceBufferPlayback = pMappedDeviceBufferPlayback + ((mappedDeviceBufferSizeInFramesPlayback - mappedDeviceBufferFramesRemainingPlayback) * bpfPlaybackDevice);
-
-                            /* There may be some data sitting in the converter that needs to be processed first. Once this is exhaused, run the data callback again. */
-                            if (!pDevice->playback.converter.isPassthrough && outputDataInClientFormatConsumed < outputDataInClientFormatCount) {
-                                ma_uint64 convertedFrameCountClient = (outputDataInClientFormatCount - outputDataInClientFormatConsumed);
-                                ma_uint64 convertedFrameCountDevice = mappedDeviceBufferFramesRemainingPlayback;
-                                void* pConvertedFramesClient = outputDataInClientFormat + (outputDataInClientFormatConsumed * bpfPlaybackClient);
-                                void* pConvertedFramesDevice = pRunningDeviceBufferPlayback;
-                                result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pConvertedFramesClient, &convertedFrameCountClient, pConvertedFramesDevice, &convertedFrameCountDevice);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                outputDataInClientFormatConsumed          += (ma_uint32)convertedFrameCountClient;  /* Safe cast. */
-                                mappedDeviceBufferFramesRemainingPlayback -= (ma_uint32)convertedFrameCountDevice;  /* Safe cast. */
-
-                                if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                                    break;
-                                }
-                            }
-
-                            /*
-                            Getting here means we need to fire the callback. If format conversion is unnecessary, we can optimize this by passing the pointers to the internal
-                            buffers directly to the callback.
-                            */
-                            if (pDevice->capture.converter.isPassthrough && pDevice->playback.converter.isPassthrough) {
-                                /* Optimal path. We can pass mapped pointers directly to the callback. */
-                                framesToProcess = ma_min(mappedDeviceBufferFramesRemainingCapture, mappedDeviceBufferFramesRemainingPlayback);
-                                framesProcessed = framesToProcess;
-
-                                ma_device__on_data(pDevice, pRunningDeviceBufferPlayback, pRunningDeviceBufferCapture, framesToProcess);
-
-                                mappedDeviceBufferFramesRemainingCapture  -= framesProcessed;
-                                mappedDeviceBufferFramesRemainingPlayback -= framesProcessed;
-
-                                if (mappedDeviceBufferFramesRemainingCapture == 0) {
-                                    break;  /* Exhausted input data. */
-                                }
-                                if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                                    break;  /* Exhausted output data. */
-                                }
-                            } else if (pDevice->capture.converter.isPassthrough) {
-                                /* The input buffer is a passthrough, but the playback buffer requires a conversion. */
-                                framesToProcess = ma_min(mappedDeviceBufferFramesRemainingCapture, outputDataInClientFormatCap);
-                                framesProcessed = framesToProcess;
-
-                                ma_device__on_data(pDevice, outputDataInClientFormat, pRunningDeviceBufferCapture, framesToProcess);
-                                outputDataInClientFormatCount    = framesProcessed;
-                                outputDataInClientFormatConsumed = 0;
-
-                                mappedDeviceBufferFramesRemainingCapture -= framesProcessed;
-                                if (mappedDeviceBufferFramesRemainingCapture == 0) {
-                                    break;  /* Exhausted input data. */
-                                }
-                            } else if (pDevice->playback.converter.isPassthrough) {
-                                /* The input buffer requires conversion, the playback buffer is passthrough. */
-                                ma_uint64 capturedDeviceFramesToProcess = mappedDeviceBufferFramesRemainingCapture;
-                                ma_uint64 capturedClientFramesToProcess = ma_min(inputDataInClientFormatCap, mappedDeviceBufferFramesRemainingPlayback);
-
-                                result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningDeviceBufferCapture, &capturedDeviceFramesToProcess, inputDataInClientFormat, &capturedClientFramesToProcess);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                if (capturedClientFramesToProcess == 0) {
-                                    break;
-                                }
-
-                                ma_device__on_data(pDevice, pRunningDeviceBufferPlayback, inputDataInClientFormat, (ma_uint32)capturedClientFramesToProcess);   /* Safe cast. */
-
-                                mappedDeviceBufferFramesRemainingCapture  -= (ma_uint32)capturedDeviceFramesToProcess;
-                                mappedDeviceBufferFramesRemainingPlayback -= (ma_uint32)capturedClientFramesToProcess;
-                            } else {
-                                ma_uint64 capturedDeviceFramesToProcess = mappedDeviceBufferFramesRemainingCapture;
-                                ma_uint64 capturedClientFramesToProcess = ma_min(inputDataInClientFormatCap, outputDataInClientFormatCap);
-
-                                result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningDeviceBufferCapture, &capturedDeviceFramesToProcess, inputDataInClientFormat, &capturedClientFramesToProcess);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                if (capturedClientFramesToProcess == 0) {
-                                    break;
-                                }
-
-                                ma_device__on_data(pDevice, outputDataInClientFormat, inputDataInClientFormat, (ma_uint32)capturedClientFramesToProcess);
-
-                                mappedDeviceBufferFramesRemainingCapture -= (ma_uint32)capturedDeviceFramesToProcess;
-                                outputDataInClientFormatCount             = (ma_uint32)capturedClientFramesToProcess;
-                                outputDataInClientFormatConsumed          = 0;
-                            }
-                        }
-
-
-                        /* If at this point we've run out of capture data we need to release the buffer. */
-                        if (mappedDeviceBufferFramesRemainingCapture == 0 && pMappedDeviceBufferCapture != NULL) {
-                            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                            if (FAILED(hr)) {
-                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            /*printf("TRACE: Released capture buffer\n");*/
-
-                            pMappedDeviceBufferCapture = NULL;
-                            mappedDeviceBufferFramesRemainingCapture = 0;
-                            mappedDeviceBufferSizeInFramesCapture    = 0;
-                        }
-
-                        /* Get out of this loop if we're run out of room in the playback buffer. */
-                        if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                            break;
-                        }
-                    }
-                }
-
-
-                /* If at this point we've run out of data we need to release the buffer. */
-                if (mappedDeviceBufferFramesRemainingPlayback == 0 && pMappedDeviceBufferPlayback != NULL) {
-                    hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedDeviceBufferSizeInFramesPlayback, 0);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    /*printf("TRACE: Released playback buffer\n");*/
-                    framesWrittenToPlaybackDevice += mappedDeviceBufferSizeInFramesPlayback;
-
-                    pMappedDeviceBufferPlayback = NULL;
-                    mappedDeviceBufferFramesRemainingPlayback = 0;
-                    mappedDeviceBufferSizeInFramesPlayback    = 0;
-                }
-
-                if (!c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-                    ma_uint32 startThreshold = pDevice->playback.internalPeriodSizeInFrames * 1;
-
-                    /* Prevent a deadlock. If we don't clamp against the actual buffer size we'll never end up starting the playback device which will result in a deadlock. */
-                    if (startThreshold > pDevice->wasapi.actualPeriodSizeInFramesPlayback) {
-                        startThreshold = pDevice->wasapi.actualPeriodSizeInFramesPlayback;
-                    }
-
-                    if (pDevice->playback.shareMode == ma_share_mode_exclusive || framesWrittenToPlaybackDevice >= startThreshold) {
-                        hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                        if (FAILED(hr)) {
-                            ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                            ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", ma_result_from_HRESULT(hr));
-                        }
-
-                        c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
-                    }
-                }
-
-                /* Make sure the device has started before waiting. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    return MA_ERROR;   /* Wait failed. */
-                }
-            } break;
-
-
-
-            case ma_device_type_capture:
-            case ma_device_type_loopback:
-            {
-                ma_uint32 framesAvailableCapture;
-                DWORD flagsCapture;    /* Passed to IAudioCaptureClient_GetBuffer(). */
-
-                /* Wait for data to become available first. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    exitLoop = MA_TRUE;
-                    break;   /* Wait failed. */
-                }
-
-                /* See how many frames are available. Since we waited at the top, I don't think this should ever return 0. I'm checking for this anyway. */
-                result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture);
-                if (result != MA_SUCCESS) {
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                if (framesAvailableCapture < pDevice->wasapi.periodSizeInFramesCapture) {
-                    continue;   /* Nothing available. Keep waiting. */
-                }
-
-                /* Map the data buffer in preparation for sending to the client. */
-                mappedDeviceBufferSizeInFramesCapture = framesAvailableCapture;
-                hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                if (FAILED(hr)) {
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                /* Overrun detection. */
-                if ((flagsCapture & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
-                    /* Glitched. Probably due to an overrun. */
-                #ifdef MA_DEBUG_OUTPUT
-                    printf("[WASAPI] Data discontinuity (possible overrun). framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                #endif
-
-                    /*
-                    Exeriment: If we get an overrun it probably means we're straddling the end of the buffer. In order to prevent a never-ending sequence of glitches let's experiment
-                    by dropping every frame until we're left with only a single period. To do this we just keep retrieving and immediately releasing buffers until we're down to the
-                    last period.
-                    */
-                    if (framesAvailableCapture >= pDevice->wasapi.actualPeriodSizeInFramesCapture) {
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[WASAPI] Synchronizing capture stream. ");
-                    #endif
-                        do
-                        {
-                            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                            if (FAILED(hr)) {
-                                break;
-                            }
-
-                            framesAvailableCapture -= mappedDeviceBufferSizeInFramesCapture;
-
-                            if (framesAvailableCapture > 0) {
-                                mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                                hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                                if (FAILED(hr)) {
-                                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                    exitLoop = MA_TRUE;
-                                    break;
-                                }
-                            } else {
-                                pMappedDeviceBufferCapture = NULL;
-                                mappedDeviceBufferSizeInFramesCapture = 0;
-                            }
-                        } while (framesAvailableCapture > periodSizeInFramesCapture);
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                    #endif
-                    }
-                } else {
-                #ifdef MA_DEBUG_OUTPUT
-                    if (flagsCapture != 0) {
-                        printf("[WASAPI] Capture Flags: %ld\n", flagsCapture);
-                    }
-                #endif
-                }
-
-                /* We should have a buffer at this point, but let's just do a sanity check anyway. */
-                if (mappedDeviceBufferSizeInFramesCapture > 0 && pMappedDeviceBufferCapture != NULL) {
-                    ma_device__send_frames_to_client(pDevice, mappedDeviceBufferSizeInFramesCapture, pMappedDeviceBufferCapture);
-
-                    /* At this point we're done with the buffer. */
-                    hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                    pMappedDeviceBufferCapture = NULL;    /* <-- Important. Not doing this can result in an error once we leave this loop because it will use this to know whether or not a final ReleaseBuffer() needs to be called. */
-                    mappedDeviceBufferSizeInFramesCapture = 0;
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-                }
-            } break;
-
-
-
-            case ma_device_type_playback:
-            {
-                ma_uint32 framesAvailablePlayback;
-
-                /* Check how much space is available. If this returns 0 we just keep waiting. */
-                result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                if (result != MA_SUCCESS) {
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                if (framesAvailablePlayback >= pDevice->wasapi.periodSizeInFramesPlayback) {
-                    /* Map a the data buffer in preparation for the callback. */
-                    hr = ma_IAudioRenderClient_GetBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedDeviceBufferPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    /* We should have a buffer at this point. */
-                    ma_device__read_frames_from_client(pDevice, framesAvailablePlayback, pMappedDeviceBufferPlayback);
-
-                    /* At this point we're done writing to the device and we just need to release the buffer. */
-                    hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, 0);
-                    pMappedDeviceBufferPlayback = NULL;    /* <-- Important. Not doing this can result in an error once we leave this loop because it will use this to know whether or not a final ReleaseBuffer() needs to be called. */
-                    mappedDeviceBufferSizeInFramesPlayback = 0;
-
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    framesWrittenToPlaybackDevice += framesAvailablePlayback;
-                }
-
-                if (!c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-                    hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
-                }
-
-                /* Make sure we don't wait on the event before we've started the device or we may end up deadlocking. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    exitLoop = MA_TRUE;
-                    break;   /* Wait failed. Probably timed out. */
-                }
-            } break;
-
-            default: return MA_INVALID_ARGS;
-        }
-    }
-
-    /* Here is where the device needs to be stopped. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        /* Any mapped buffers need to be released. */
-        if (pMappedDeviceBufferCapture != NULL) {
-            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Any mapped buffers need to be released. */
-        if (pMappedDeviceBufferPlayback != NULL) {
-            hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedDeviceBufferSizeInFramesPlayback, 0);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop_wakeup__wasapi(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        SetEvent((HANDLE)pDevice->wasapi.hEventCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        SetEvent((HANDLE)pDevice->wasapi.hEventPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__wasapi(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_wasapi);
-    
-    if (pContext->wasapi.commandThread != NULL) {
-        ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI);
-        ma_context_post_command__wasapi(pContext, &cmd);
-        ma_thread_wait(&pContext->wasapi.commandThread);
-
-        /* Only after the thread has been terminated can we uninitialize the sync objects for the command thread. */
-        ma_semaphore_uninit(&pContext->wasapi.commandSem);
-        ma_mutex_uninit(&pContext->wasapi.commandLock);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result = MA_SUCCESS;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-#ifdef MA_WIN32_DESKTOP
-    /*
-    WASAPI is only supported in Vista SP1 and newer. The reason for SP1 and not the base version of Vista is that event-driven
-    exclusive mode does not work until SP1.
-
-    Unfortunately older compilers don't define these functions so we need to dynamically load them in order to avoid a link error.
-    */
-    {
-        ma_OSVERSIONINFOEXW osvi;
-        ma_handle kernel32DLL;
-        ma_PFNVerifyVersionInfoW _VerifyVersionInfoW;
-        ma_PFNVerSetConditionMask _VerSetConditionMask;
-
-        kernel32DLL = ma_dlopen(pContext, "kernel32.dll");
-        if (kernel32DLL == NULL) {
-            return MA_NO_BACKEND;
-        }
-
-        _VerifyVersionInfoW  = (ma_PFNVerifyVersionInfoW )ma_dlsym(pContext, kernel32DLL, "VerifyVersionInfoW");
-        _VerSetConditionMask = (ma_PFNVerSetConditionMask)ma_dlsym(pContext, kernel32DLL, "VerSetConditionMask");
-        if (_VerifyVersionInfoW == NULL || _VerSetConditionMask == NULL) {
-            ma_dlclose(pContext, kernel32DLL);
-            return MA_NO_BACKEND;
-        }
-
-        MA_ZERO_OBJECT(&osvi);
-        osvi.dwOSVersionInfoSize = sizeof(osvi);
-        osvi.dwMajorVersion = ((MA_WIN32_WINNT_VISTA >> 8) & 0xFF);
-        osvi.dwMinorVersion = ((MA_WIN32_WINNT_VISTA >> 0) & 0xFF);
-        osvi.wServicePackMajor = 1;
-        if (_VerifyVersionInfoW(&osvi, MA_VER_MAJORVERSION | MA_VER_MINORVERSION | MA_VER_SERVICEPACKMAJOR, _VerSetConditionMask(_VerSetConditionMask(_VerSetConditionMask(0, MA_VER_MAJORVERSION, MA_VER_GREATER_EQUAL), MA_VER_MINORVERSION, MA_VER_GREATER_EQUAL), MA_VER_SERVICEPACKMAJOR, MA_VER_GREATER_EQUAL))) {
-            result = MA_SUCCESS;
-        } else {
-            result = MA_NO_BACKEND;
-        }
-
-        ma_dlclose(pContext, kernel32DLL);
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    MA_ZERO_OBJECT(&pContext->wasapi);
-
-    /*
-    Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread
-    than the one that retrieved it with GetService(). This can result in a deadlock in two
-    situations:
-
-        1) When calling ma_device_uninit() from a different thread to ma_device_init(); and
-        2) When uninitializing and reinitializing the internal IAudioClient object in response to
-           automatic stream routing.
-
-    We could define ma_device_uninit() such that it must be called on the same thread as
-    ma_device_init(). We could also just not release the IAudioClient when performing automatic
-    stream routing to avoid the deadlock. Neither of these are acceptable solutions in my view so
-    we're going to have to work around this with a worker thread. This is not ideal, but I can't
-    think of a better way to do this.
-
-    More information about this can be found here:
-
-        https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nn-audioclient-iaudiorenderclient
-
-    Note this section:
-
-        When releasing an IAudioRenderClient interface instance, the client must call the interface's
-        Release method from the same thread as the call to IAudioClient::GetService that created the
-        object.
-    */
-    {
-        result = ma_mutex_init(&pContext->wasapi.commandLock);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_semaphore_init(0, &pContext->wasapi.commandSem);
-        if (result != MA_SUCCESS) {
-            ma_mutex_uninit(&pContext->wasapi.commandLock);
-            return result;
-        }
-
-        result = ma_thread_create(&pContext->wasapi.commandThread, ma_thread_priority_normal, 0, ma_context_command_thread__wasapi, pContext);
-        if (result != MA_SUCCESS) {
-            ma_semaphore_uninit(&pContext->wasapi.commandSem);
-            ma_mutex_uninit(&pContext->wasapi.commandLock);
-            return result;
-        }
-    }
-
-
-    pCallbacks->onContextInit             = ma_context_init__wasapi;
-    pCallbacks->onContextUninit           = ma_context_uninit__wasapi;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__wasapi;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__wasapi;
-    pCallbacks->onDeviceInit              = ma_device_init__wasapi;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__wasapi;
-    pCallbacks->onDeviceStart             = ma_device_start__wasapi;
-    pCallbacks->onDeviceStop              = ma_device_stop__wasapi;
-    pCallbacks->onDeviceRead              = NULL;                   /* Not used. Reading is done manually in the audio thread. */
-    pCallbacks->onDeviceWrite             = NULL;                   /* Not used. Writing is done manually in the audio thread. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__wasapi;
-    pCallbacks->onDeviceDataLoopWakeup    = ma_device_data_loop_wakeup__wasapi;
-
-    return MA_SUCCESS;
-}
-#endif
-
-/******************************************************************************
-
-DirectSound Backend
-
-******************************************************************************/
-#ifdef MA_HAS_DSOUND
-/*#include <dsound.h>*/
-
-/*static const GUID MA_GUID_IID_DirectSoundNotify = {0xb0210783, 0x89cd, 0x11d0, {0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}};*/
-
-/* miniaudio only uses priority or exclusive modes. */
-#define MA_DSSCL_NORMAL                 1
-#define MA_DSSCL_PRIORITY               2
-#define MA_DSSCL_EXCLUSIVE              3
-#define MA_DSSCL_WRITEPRIMARY           4
-
-#define MA_DSCAPS_PRIMARYMONO           0x00000001
-#define MA_DSCAPS_PRIMARYSTEREO         0x00000002
-#define MA_DSCAPS_PRIMARY8BIT           0x00000004
-#define MA_DSCAPS_PRIMARY16BIT          0x00000008
-#define MA_DSCAPS_CONTINUOUSRATE        0x00000010
-#define MA_DSCAPS_EMULDRIVER            0x00000020
-#define MA_DSCAPS_CERTIFIED             0x00000040
-#define MA_DSCAPS_SECONDARYMONO         0x00000100
-#define MA_DSCAPS_SECONDARYSTEREO       0x00000200
-#define MA_DSCAPS_SECONDARY8BIT         0x00000400
-#define MA_DSCAPS_SECONDARY16BIT        0x00000800
-
-#define MA_DSBCAPS_PRIMARYBUFFER        0x00000001
-#define MA_DSBCAPS_STATIC               0x00000002
-#define MA_DSBCAPS_LOCHARDWARE          0x00000004
-#define MA_DSBCAPS_LOCSOFTWARE          0x00000008
-#define MA_DSBCAPS_CTRL3D               0x00000010
-#define MA_DSBCAPS_CTRLFREQUENCY        0x00000020
-#define MA_DSBCAPS_CTRLPAN              0x00000040
-#define MA_DSBCAPS_CTRLVOLUME           0x00000080
-#define MA_DSBCAPS_CTRLPOSITIONNOTIFY   0x00000100
-#define MA_DSBCAPS_CTRLFX               0x00000200
-#define MA_DSBCAPS_STICKYFOCUS          0x00004000
-#define MA_DSBCAPS_GLOBALFOCUS          0x00008000
-#define MA_DSBCAPS_GETCURRENTPOSITION2  0x00010000
-#define MA_DSBCAPS_MUTE3DATMAXDISTANCE  0x00020000
-#define MA_DSBCAPS_LOCDEFER             0x00040000
-#define MA_DSBCAPS_TRUEPLAYPOSITION     0x00080000
-
-#define MA_DSBPLAY_LOOPING              0x00000001
-#define MA_DSBPLAY_LOCHARDWARE          0x00000002
-#define MA_DSBPLAY_LOCSOFTWARE          0x00000004
-#define MA_DSBPLAY_TERMINATEBY_TIME     0x00000008
-#define MA_DSBPLAY_TERMINATEBY_DISTANCE 0x00000010
-#define MA_DSBPLAY_TERMINATEBY_PRIORITY 0x00000020
-
-#define MA_DSCBSTART_LOOPING            0x00000001
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-    WAVEFORMATEX* lpwfxFormat;
-    GUID guid3DAlgorithm;
-} MA_DSBUFFERDESC;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-    WAVEFORMATEX* lpwfxFormat;
-    DWORD dwFXCount;
-    void* lpDSCFXDesc;  /* <-- miniaudio doesn't use this, so set to void*. */
-} MA_DSCBUFFERDESC;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwMinSecondarySampleRate;
-    DWORD dwMaxSecondarySampleRate;
-    DWORD dwPrimaryBuffers;
-    DWORD dwMaxHwMixingAllBuffers;
-    DWORD dwMaxHwMixingStaticBuffers;
-    DWORD dwMaxHwMixingStreamingBuffers;
-    DWORD dwFreeHwMixingAllBuffers;
-    DWORD dwFreeHwMixingStaticBuffers;
-    DWORD dwFreeHwMixingStreamingBuffers;
-    DWORD dwMaxHw3DAllBuffers;
-    DWORD dwMaxHw3DStaticBuffers;
-    DWORD dwMaxHw3DStreamingBuffers;
-    DWORD dwFreeHw3DAllBuffers;
-    DWORD dwFreeHw3DStaticBuffers;
-    DWORD dwFreeHw3DStreamingBuffers;
-    DWORD dwTotalHwMemBytes;
-    DWORD dwFreeHwMemBytes;
-    DWORD dwMaxContigFreeHwMemBytes;
-    DWORD dwUnlockTransferRateHwBuffers;
-    DWORD dwPlayCpuOverheadSwBuffers;
-    DWORD dwReserved1;
-    DWORD dwReserved2;
-} MA_DSCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwUnlockTransferRate;
-    DWORD dwPlayCpuOverhead;
-} MA_DSBCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwFormats;
-    DWORD dwChannels;
-} MA_DSCCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-} MA_DSCBCAPS;
-
-typedef struct
-{
-    DWORD  dwOffset;
-    HANDLE hEventNotify;
-} MA_DSBPOSITIONNOTIFY;
-
-typedef struct ma_IDirectSound              ma_IDirectSound;
-typedef struct ma_IDirectSoundBuffer        ma_IDirectSoundBuffer;
-typedef struct ma_IDirectSoundCapture       ma_IDirectSoundCapture;
-typedef struct ma_IDirectSoundCaptureBuffer ma_IDirectSoundCaptureBuffer;
-typedef struct ma_IDirectSoundNotify        ma_IDirectSoundNotify;
-
-
-/*
-COM objects. The way these work is that you have a vtable (a list of function pointers, kind of
-like how C++ works internally), and then you have a structure with a single member, which is a
-pointer to the vtable. The vtable is where the methods of the object are defined. Methods need
-to be in a specific order, and parent classes need to have their methods declared first.
-*/
-
-/* IDirectSound */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSound* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSound* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSound* pThis);
-
-    /* IDirectSound */
-    HRESULT (STDMETHODCALLTYPE * CreateSoundBuffer)   (ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter);
-    HRESULT (STDMETHODCALLTYPE * GetCaps)             (ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps);
-    HRESULT (STDMETHODCALLTYPE * DuplicateSoundBuffer)(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate);
-    HRESULT (STDMETHODCALLTYPE * SetCooperativeLevel) (ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel);
-    HRESULT (STDMETHODCALLTYPE * Compact)             (ma_IDirectSound* pThis);
-    HRESULT (STDMETHODCALLTYPE * GetSpeakerConfig)    (ma_IDirectSound* pThis, DWORD* pSpeakerConfig);
-    HRESULT (STDMETHODCALLTYPE * SetSpeakerConfig)    (ma_IDirectSound* pThis, DWORD dwSpeakerConfig);
-    HRESULT (STDMETHODCALLTYPE * Initialize)          (ma_IDirectSound* pThis, const GUID* pGuidDevice);
-} ma_IDirectSoundVtbl;
-struct ma_IDirectSound
-{
-    ma_IDirectSoundVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSound_QueryInterface(ma_IDirectSound* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSound_AddRef(ma_IDirectSound* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSound_Release(ma_IDirectSound* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSound_CreateSoundBuffer(ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateSoundBuffer(pThis, pDSBufferDesc, ppDSBuffer, pUnkOuter); }
-static MA_INLINE HRESULT ma_IDirectSound_GetCaps(ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps)                            { return pThis->lpVtbl->GetCaps(pThis, pDSCaps); }
-static MA_INLINE HRESULT ma_IDirectSound_DuplicateSoundBuffer(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate) { return pThis->lpVtbl->DuplicateSoundBuffer(pThis, pDSBufferOriginal, ppDSBufferDuplicate); }
-static MA_INLINE HRESULT ma_IDirectSound_SetCooperativeLevel(ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel)          { return pThis->lpVtbl->SetCooperativeLevel(pThis, hwnd, dwLevel); }
-static MA_INLINE HRESULT ma_IDirectSound_Compact(ma_IDirectSound* pThis)                                                { return pThis->lpVtbl->Compact(pThis); }
-static MA_INLINE HRESULT ma_IDirectSound_GetSpeakerConfig(ma_IDirectSound* pThis, DWORD* pSpeakerConfig)                { return pThis->lpVtbl->GetSpeakerConfig(pThis, pSpeakerConfig); }
-static MA_INLINE HRESULT ma_IDirectSound_SetSpeakerConfig(ma_IDirectSound* pThis, DWORD dwSpeakerConfig)                { return pThis->lpVtbl->SetSpeakerConfig(pThis, dwSpeakerConfig); }
-static MA_INLINE HRESULT ma_IDirectSound_Initialize(ma_IDirectSound* pThis, const GUID* pGuidDevice)                    { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); }
-
-
-/* IDirectSoundBuffer */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundBuffer* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundBuffer* pThis);
-
-    /* IDirectSoundBuffer */
-    HRESULT (STDMETHODCALLTYPE * GetCaps)           (ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor);
-    HRESULT (STDMETHODCALLTYPE * GetFormat)         (ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
-    HRESULT (STDMETHODCALLTYPE * GetVolume)         (ma_IDirectSoundBuffer* pThis, LONG* pVolume);
-    HRESULT (STDMETHODCALLTYPE * GetPan)            (ma_IDirectSoundBuffer* pThis, LONG* pPan);
-    HRESULT (STDMETHODCALLTYPE * GetFrequency)      (ma_IDirectSoundBuffer* pThis, DWORD* pFrequency);
-    HRESULT (STDMETHODCALLTYPE * GetStatus)         (ma_IDirectSoundBuffer* pThis, DWORD* pStatus);
-    HRESULT (STDMETHODCALLTYPE * Initialize)        (ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc);
-    HRESULT (STDMETHODCALLTYPE * Lock)              (ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Play)              (ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * SetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition);
-    HRESULT (STDMETHODCALLTYPE * SetFormat)         (ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat);
-    HRESULT (STDMETHODCALLTYPE * SetVolume)         (ma_IDirectSoundBuffer* pThis, LONG volume);
-    HRESULT (STDMETHODCALLTYPE * SetPan)            (ma_IDirectSoundBuffer* pThis, LONG pan);
-    HRESULT (STDMETHODCALLTYPE * SetFrequency)      (ma_IDirectSoundBuffer* pThis, DWORD dwFrequency);
-    HRESULT (STDMETHODCALLTYPE * Stop)              (ma_IDirectSoundBuffer* pThis);
-    HRESULT (STDMETHODCALLTYPE * Unlock)            (ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2);
-    HRESULT (STDMETHODCALLTYPE * Restore)           (ma_IDirectSoundBuffer* pThis);
-} ma_IDirectSoundBufferVtbl;
-struct ma_IDirectSoundBuffer
-{
-    ma_IDirectSoundBufferVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_QueryInterface(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundBuffer_AddRef(ma_IDirectSoundBuffer* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundBuffer_Release(ma_IDirectSoundBuffer* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCaps(ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps)                     { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCurrentPlayCursor, pCurrentWriteCursor); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFormat(ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetVolume(ma_IDirectSoundBuffer* pThis, LONG* pVolume)                               { return pThis->lpVtbl->GetVolume(pThis, pVolume); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetPan(ma_IDirectSoundBuffer* pThis, LONG* pPan)                                     { return pThis->lpVtbl->GetPan(pThis, pPan); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFrequency(ma_IDirectSoundBuffer* pThis, DWORD* pFrequency)                        { return pThis->lpVtbl->GetFrequency(pThis, pFrequency); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetStatus(ma_IDirectSoundBuffer* pThis, DWORD* pStatus)                              { return pThis->lpVtbl->GetStatus(pThis, pStatus); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Initialize(ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSound, pDSBufferDesc); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Lock(ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Play(ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) { return pThis->lpVtbl->Play(pThis, dwReserved1, dwPriority, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition)                { return pThis->lpVtbl->SetCurrentPosition(pThis, dwNewPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFormat(ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat)                 { return pThis->lpVtbl->SetFormat(pThis, pFormat); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetVolume(ma_IDirectSoundBuffer* pThis, LONG volume)                                 { return pThis->lpVtbl->SetVolume(pThis, volume); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetPan(ma_IDirectSoundBuffer* pThis, LONG pan)                                       { return pThis->lpVtbl->SetPan(pThis, pan); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFrequency(ma_IDirectSoundBuffer* pThis, DWORD dwFrequency)                        { return pThis->lpVtbl->SetFrequency(pThis, dwFrequency); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Stop(ma_IDirectSoundBuffer* pThis)                                                   { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Unlock(ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Restore(ma_IDirectSoundBuffer* pThis)                                                { return pThis->lpVtbl->Restore(pThis); }
-
-
-/* IDirectSoundCapture */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundCapture* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundCapture* pThis);
-
-    /* IDirectSoundCapture */
-    HRESULT (STDMETHODCALLTYPE * CreateCaptureBuffer)(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter);
-    HRESULT (STDMETHODCALLTYPE * GetCaps)            (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps);
-    HRESULT (STDMETHODCALLTYPE * Initialize)         (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice);
-} ma_IDirectSoundCaptureVtbl;
-struct ma_IDirectSoundCapture
-{
-    ma_IDirectSoundCaptureVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundCapture_QueryInterface(ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundCapture_AddRef(ma_IDirectSoundCapture* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundCapture_Release(ma_IDirectSoundCapture* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_CreateCaptureBuffer(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateCaptureBuffer(pThis, pDSCBufferDesc, ppDSCBuffer, pUnkOuter); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_GetCaps            (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps)              { return pThis->lpVtbl->GetCaps(pThis, pDSCCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_Initialize         (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice)           { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); }
-
-
-/* IDirectSoundCaptureBuffer */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundCaptureBuffer* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundCaptureBuffer* pThis);
-
-    /* IDirectSoundCaptureBuffer */
-    HRESULT (STDMETHODCALLTYPE * GetCaps)           (ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition);
-    HRESULT (STDMETHODCALLTYPE * GetFormat)         (ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
-    HRESULT (STDMETHODCALLTYPE * GetStatus)         (ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus);
-    HRESULT (STDMETHODCALLTYPE * Initialize)        (ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc);
-    HRESULT (STDMETHODCALLTYPE * Lock)              (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Start)             (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Stop)              (ma_IDirectSoundCaptureBuffer* pThis);
-    HRESULT (STDMETHODCALLTYPE * Unlock)            (ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2);
-} ma_IDirectSoundCaptureBufferVtbl;
-struct ma_IDirectSoundCaptureBuffer
-{
-    ma_IDirectSoundCaptureBufferVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_QueryInterface(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundCaptureBuffer_AddRef(ma_IDirectSoundCaptureBuffer* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundCaptureBuffer_Release(ma_IDirectSoundCaptureBuffer* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCaps(ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps)                        { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCurrentPosition(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCapturePosition, pReadPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetFormat(ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetStatus(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus)                              { return pThis->lpVtbl->GetStatus(pThis, pStatus); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Initialize(ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Lock(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Start(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags)                                   { return pThis->lpVtbl->Start(pThis, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Stop(ma_IDirectSoundCaptureBuffer* pThis)                                                   { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Unlock(ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); }
-
-
-/* IDirectSoundNotify */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundNotify* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundNotify* pThis);
-
-    /* IDirectSoundNotify */
-    HRESULT (STDMETHODCALLTYPE * SetNotificationPositions)(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies);
-} ma_IDirectSoundNotifyVtbl;
-struct ma_IDirectSoundNotify
-{
-    ma_IDirectSoundNotifyVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundNotify_QueryInterface(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundNotify_AddRef(ma_IDirectSoundNotify* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundNotify_Release(ma_IDirectSoundNotify* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundNotify_SetNotificationPositions(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); }
-
-
-typedef BOOL    (CALLBACK * ma_DSEnumCallbackAProc)             (LPGUID pDeviceGUID, LPCSTR pDeviceDescription, LPCSTR pModule, LPVOID pContext);
-typedef HRESULT (WINAPI   * ma_DirectSoundCreateProc)           (const GUID* pcGuidDevice, ma_IDirectSound** ppDS8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI   * ma_DirectSoundEnumerateAProc)       (ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
-typedef HRESULT (WINAPI   * ma_DirectSoundCaptureCreateProc)    (const GUID* pcGuidDevice, ma_IDirectSoundCapture** ppDSC8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI   * ma_DirectSoundCaptureEnumerateAProc)(ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
-
-static ma_uint32 ma_get_best_sample_rate_within_range(ma_uint32 sampleRateMin, ma_uint32 sampleRateMax)
-{
-    /* Normalize the range in case we were given something stupid. */
-    if (sampleRateMin < (ma_uint32)ma_standard_sample_rate_min) {
-        sampleRateMin = (ma_uint32)ma_standard_sample_rate_min;
-    }
-    if (sampleRateMax > (ma_uint32)ma_standard_sample_rate_max) {
-        sampleRateMax = (ma_uint32)ma_standard_sample_rate_max;
-    }
-    if (sampleRateMin > sampleRateMax) {
-        sampleRateMin = sampleRateMax;
-    }
-
-    if (sampleRateMin == sampleRateMax) {
-        return sampleRateMax;
-    } else {
-        size_t iStandardRate;
-        for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) {
-            ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate];
-            if (standardRate >= sampleRateMin && standardRate <= sampleRateMax) {
-                return standardRate;
-            }
-        }
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-/*
-Retrieves the channel count and channel map for the given speaker configuration. If the speaker configuration is unknown,
-the channel count and channel map will be left unmodified.
-*/
-static void ma_get_channels_from_speaker_config__dsound(DWORD speakerConfig, WORD* pChannelsOut, DWORD* pChannelMapOut)
-{
-    WORD  channels;
-    DWORD channelMap;
-
-    channels = 0;
-    if (pChannelsOut != NULL) {
-        channels = *pChannelsOut;
-    }
-
-    channelMap = 0;
-    if (pChannelMapOut != NULL) {
-        channelMap = *pChannelMapOut;
-    }
-
-    /*
-    The speaker configuration is a combination of speaker config and speaker geometry. The lower 8 bits is what we care about. The upper
-    16 bits is for the geometry.
-    */
-    switch ((BYTE)(speakerConfig)) {
-        case 1 /*DSSPEAKER_HEADPHONE*/:                          channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break;
-        case 2 /*DSSPEAKER_MONO*/:                               channels = 1; channelMap = SPEAKER_FRONT_CENTER; break;
-        case 3 /*DSSPEAKER_QUAD*/:                               channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break;
-        case 4 /*DSSPEAKER_STEREO*/:                             channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break;
-        case 5 /*DSSPEAKER_SURROUND*/:                           channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER; break;
-        case 6 /*DSSPEAKER_5POINT1_BACK*/ /*DSSPEAKER_5POINT1*/: channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break;
-        case 7 /*DSSPEAKER_7POINT1_WIDE*/ /*DSSPEAKER_7POINT1*/: channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER; break;
-        case 8 /*DSSPEAKER_7POINT1_SURROUND*/:                   channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break;
-        case 9 /*DSSPEAKER_5POINT1_SURROUND*/:                   channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break;
-        default: break;
-    }
-
-    if (pChannelsOut != NULL) {
-        *pChannelsOut = channels;
-    }
-
-    if (pChannelMapOut != NULL) {
-        *pChannelMapOut = channelMap;
-    }
-}
-
-
-static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSound** ppDirectSound)
-{
-    ma_IDirectSound* pDirectSound;
-    HWND hWnd;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppDirectSound != NULL);
-
-    *ppDirectSound = NULL;
-    pDirectSound = NULL;
-
-    if (FAILED(((ma_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSound, NULL))) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    /* The cooperative level must be set before doing anything else. */
-    hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)();
-    if (hWnd == NULL) {
-        hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)();
-    }
-
-    hr = ma_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == ma_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_SetCooperateiveLevel() failed for playback device.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDirectSound = pDirectSound;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_create_IDirectSoundCapture__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSoundCapture** ppDirectSoundCapture)
-{
-    ma_IDirectSoundCapture* pDirectSoundCapture;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppDirectSoundCapture != NULL);
-
-    /* DirectSound does not support exclusive mode for capture. */
-    if (shareMode == ma_share_mode_exclusive) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    *ppDirectSoundCapture = NULL;
-    pDirectSoundCapture = NULL;
-
-    hr = ((ma_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, NULL);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDirectSoundCapture = pDirectSoundCapture;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_format_info_for_IDirectSoundCapture__dsound(ma_context* pContext, ma_IDirectSoundCapture* pDirectSoundCapture, WORD* pChannels, WORD* pBitsPerSample, DWORD* pSampleRate)
-{
-    HRESULT hr;
-    MA_DSCCAPS caps;
-    WORD bitsPerSample;
-    DWORD sampleRate;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDirectSoundCapture != NULL);
-
-    if (pChannels) {
-        *pChannels = 0;
-    }
-    if (pBitsPerSample) {
-        *pBitsPerSample = 0;
-    }
-    if (pSampleRate) {
-        *pSampleRate = 0;
-    }
-
-    MA_ZERO_OBJECT(&caps);
-    caps.dwSize = sizeof(caps);
-    hr = ma_IDirectSoundCapture_GetCaps(pDirectSoundCapture, &caps);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_GetCaps() failed for capture device.", ma_result_from_HRESULT(hr));
-    }
-
-    if (pChannels) {
-        *pChannels = (WORD)caps.dwChannels;
-    }
-
-    /* The device can support multiple formats. We just go through the different formats in order of priority and pick the first one. This the same type of system as the WinMM backend. */
-    bitsPerSample = 16;
-    sampleRate = 48000;
-
-    if (caps.dwChannels == 1) {
-        if ((caps.dwFormats & WAVE_FORMAT_48M16) != 0) {
-            sampleRate = 48000;
-        } else if ((caps.dwFormats & WAVE_FORMAT_44M16) != 0) {
-            sampleRate = 44100;
-        } else if ((caps.dwFormats & WAVE_FORMAT_2M16) != 0) {
-            sampleRate = 22050;
-        } else if ((caps.dwFormats & WAVE_FORMAT_1M16) != 0) {
-            sampleRate = 11025;
-        } else if ((caps.dwFormats & WAVE_FORMAT_96M16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((caps.dwFormats & WAVE_FORMAT_48M08) != 0) {
-                sampleRate = 48000;
-            } else if ((caps.dwFormats & WAVE_FORMAT_44M08) != 0) {
-                sampleRate = 44100;
-            } else if ((caps.dwFormats & WAVE_FORMAT_2M08) != 0) {
-                sampleRate = 22050;
-            } else if ((caps.dwFormats & WAVE_FORMAT_1M08) != 0) {
-                sampleRate = 11025;
-            } else if ((caps.dwFormats & WAVE_FORMAT_96M08) != 0) {
-                sampleRate = 96000;
-            } else {
-                bitsPerSample = 16;  /* Didn't find it. Just fall back to 16-bit. */
-            }
-        }
-    } else if (caps.dwChannels == 2) {
-        if ((caps.dwFormats & WAVE_FORMAT_48S16) != 0) {
-            sampleRate = 48000;
-        } else if ((caps.dwFormats & WAVE_FORMAT_44S16) != 0) {
-            sampleRate = 44100;
-        } else if ((caps.dwFormats & WAVE_FORMAT_2S16) != 0) {
-            sampleRate = 22050;
-        } else if ((caps.dwFormats & WAVE_FORMAT_1S16) != 0) {
-            sampleRate = 11025;
-        } else if ((caps.dwFormats & WAVE_FORMAT_96S16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((caps.dwFormats & WAVE_FORMAT_48S08) != 0) {
-                sampleRate = 48000;
-            } else if ((caps.dwFormats & WAVE_FORMAT_44S08) != 0) {
-                sampleRate = 44100;
-            } else if ((caps.dwFormats & WAVE_FORMAT_2S08) != 0) {
-                sampleRate = 22050;
-            } else if ((caps.dwFormats & WAVE_FORMAT_1S08) != 0) {
-                sampleRate = 11025;
-            } else if ((caps.dwFormats & WAVE_FORMAT_96S08) != 0) {
-                sampleRate = 96000;
-            } else {
-                bitsPerSample = 16;  /* Didn't find it. Just fall back to 16-bit. */
-            }
-        }
-    }
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = bitsPerSample;
-    }
-    if (pSampleRate) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_context* pContext;
-    ma_device_type deviceType;
-    ma_enum_devices_callback_proc callback;
-    void* pUserData;
-    ma_bool32 terminated;
-} ma_context_enumerate_devices_callback_data__dsound;
-
-static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
-    ma_context_enumerate_devices_callback_data__dsound* pData = (ma_context_enumerate_devices_callback_data__dsound*)lpContext;
-    ma_device_info deviceInfo;
-
-    (void)lpcstrModule;
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* ID. */
-    if (lpGuid != NULL) {
-        MA_COPY_MEMORY(deviceInfo.id.dsound, lpGuid, 16);
-    } else {
-        MA_ZERO_MEMORY(deviceInfo.id.dsound, 16);
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    /* Name / Description */
-    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), lpcstrDescription, (size_t)-1);
-
-
-    /* Call the callback function, but make sure we stop enumerating if the callee requested so. */
-    MA_ASSERT(pData != NULL);
-    pData->terminated = !pData->callback(pData->pContext, pData->deviceType, &deviceInfo, pData->pUserData);
-    if (pData->terminated) {
-        return FALSE;   /* Stop enumeration. */
-    } else {
-        return TRUE;    /* Continue enumeration. */
-    }
-}
-
-static ma_result ma_context_enumerate_devices__dsound(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__dsound data;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    data.pContext = pContext;
-    data.callback = callback;
-    data.pUserData = pUserData;
-    data.terminated = MA_FALSE;
-
-    /* Playback. */
-    if (!data.terminated) {
-        data.deviceType = ma_device_type_playback;
-        ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data);
-    }
-
-    /* Capture. */
-    if (!data.terminated) {
-        data.deviceType = ma_device_type_capture;
-        ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    const ma_device_id* pDeviceID;
-    ma_device_info* pDeviceInfo;
-    ma_bool32 found;
-} ma_context_get_device_info_callback_data__dsound;
-
-static BOOL CALLBACK ma_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
-    ma_context_get_device_info_callback_data__dsound* pData = (ma_context_get_device_info_callback_data__dsound*)lpContext;
-    MA_ASSERT(pData != NULL);
-
-    if ((pData->pDeviceID == NULL || ma_is_guid_null(pData->pDeviceID->dsound)) && (lpGuid == NULL || ma_is_guid_null(lpGuid))) {
-        /* Default device. */
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1);
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-        pData->found = MA_TRUE;
-        return FALSE;   /* Stop enumeration. */
-    } else {
-        /* Not the default device. */
-        if (lpGuid != NULL && pData->pDeviceID != NULL) {
-            if (memcmp(pData->pDeviceID->dsound, lpGuid, sizeof(pData->pDeviceID->dsound)) == 0) {
-                ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1);
-                pData->found = MA_TRUE;
-                return FALSE;   /* Stop enumeration. */
-            }
-        }
-    }
-
-    (void)lpcstrModule;
-    return TRUE;
-}
-
-static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-    HRESULT hr;
-
-    if (pDeviceID != NULL) {
-        ma_context_get_device_info_callback_data__dsound data;
-
-        /* ID. */
-        MA_COPY_MEMORY(pDeviceInfo->id.dsound, pDeviceID->dsound, 16);
-
-        /* Name / Description. This is retrieved by enumerating over each device until we find that one that matches the input ID. */
-        data.pDeviceID = pDeviceID;
-        data.pDeviceInfo = pDeviceInfo;
-        data.found = MA_FALSE;
-        if (deviceType == ma_device_type_playback) {
-            ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_get_device_info_callback__dsound, &data);
-        } else {
-            ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_get_device_info_callback__dsound, &data);
-        }
-
-        if (!data.found) {
-            return MA_NO_DEVICE;
-        }
-    } else {
-        /* I don't think there's a way to get the name of the default device with DirectSound. In this case we just need to use defaults. */
-
-        /* ID */
-        MA_ZERO_MEMORY(pDeviceInfo->id.dsound, 16);
-
-        /* Name / Description */
-        if (deviceType == ma_device_type_playback) {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        } else {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        }
-
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    /* Retrieving detailed information is slightly different depending on the device type. */
-    if (deviceType == ma_device_type_playback) {
-        /* Playback. */
-        ma_IDirectSound* pDirectSound;
-        MA_DSCAPS caps;
-        WORD channels;
-
-        result = ma_context_create_IDirectSound__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSound);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        MA_ZERO_OBJECT(&caps);
-        caps.dwSize = sizeof(caps);
-        hr = ma_IDirectSound_GetCaps(pDirectSound, &caps);
-        if (FAILED(hr)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", ma_result_from_HRESULT(hr));
-        }
-
-
-        /* Channels. Only a single channel count is reported for DirectSound. */
-        if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
-            /* It supports at least stereo, but could support more. */
-            DWORD speakerConfig;
-
-            channels = 2;
-
-            /* Look at the speaker configuration to get a better idea on the channel count. */
-            hr = ma_IDirectSound_GetSpeakerConfig(pDirectSound, &speakerConfig);
-            if (SUCCEEDED(hr)) {
-                ma_get_channels_from_speaker_config__dsound(speakerConfig, &channels, NULL);
-            }
-        } else {
-            /* It does not support stereo, which means we are stuck with mono. */
-            channels = 1;
-        }
-
-
-        /*
-        In DirectSound, our native formats are centered around sample rates. All formats are supported, and we're only reporting a single channel
-        count. However, DirectSound can report a range of supported sample rates. We're only going to include standard rates known by miniaudio
-        in order to keep the size of this within reason.
-        */
-        if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) {
-            /* Multiple sample rates are supported. We'll report in order of our preferred sample rates. */
-            size_t iStandardSampleRate;
-            for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) {
-                ma_uint32 sampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate];
-                if (sampleRate >= caps.dwMinSecondarySampleRate && sampleRate <= caps.dwMaxSecondarySampleRate) {
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = ma_format_unknown;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-                    pDeviceInfo->nativeDataFormatCount += 1;
-                }
-            }
-        } else {
-            /* Only a single sample rate is supported. */
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = ma_format_unknown;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = caps.dwMaxSecondarySampleRate;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-            pDeviceInfo->nativeDataFormatCount += 1;
-        }
-
-        ma_IDirectSound_Release(pDirectSound);
-    } else {
-        /*
-        Capture. This is a little different to playback due to the say the supported formats are reported. Technically capture
-        devices can support a number of different formats, but for simplicity and consistency with ma_device_init() I'm just
-        reporting the best format.
-        */
-        ma_IDirectSoundCapture* pDirectSoundCapture;
-        WORD channels;
-        WORD bitsPerSample;
-        DWORD sampleRate;
-
-        result = ma_context_create_IDirectSoundCapture__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSoundCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pContext, pDirectSoundCapture, &channels, &bitsPerSample, &sampleRate);
-        if (result != MA_SUCCESS) {
-            ma_IDirectSoundCapture_Release(pDirectSoundCapture);
-            return result;
-        }
-
-        ma_IDirectSoundCapture_Release(pDirectSoundCapture);
-
-        /* The format is always an integer format and is based on the bits per sample. */
-        if (bitsPerSample == 8) {
-            pDeviceInfo->formats[0] = ma_format_u8;
-        } else if (bitsPerSample == 16) {
-            pDeviceInfo->formats[0] = ma_format_s16;
-        } else if (bitsPerSample == 24) {
-            pDeviceInfo->formats[0] = ma_format_s24;
-        } else if (bitsPerSample == 32) {
-            pDeviceInfo->formats[0] = ma_format_s32;
-        } else {
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        pDeviceInfo->nativeDataFormats[0].channels   = channels;
-        pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[0].flags      = 0;
-        pDeviceInfo->nativeDataFormatCount = 1;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-
-static ma_result ma_device_uninit__dsound(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->dsound.pCaptureBuffer != NULL) {
-        ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-    }
-    if (pDevice->dsound.pCapture != NULL) {
-        ma_IDirectSoundCapture_Release((ma_IDirectSoundCapture*)pDevice->dsound.pCapture);
-    }
-
-    if (pDevice->dsound.pPlaybackBuffer != NULL) {
-        ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer);
-    }
-    if (pDevice->dsound.pPlaybackPrimaryBuffer != NULL) {
-        ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer);
-    }
-    if (pDevice->dsound.pPlayback != NULL) {
-        ma_IDirectSound_Release((ma_IDirectSound*)pDevice->dsound.pPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* pChannelMap, WAVEFORMATEXTENSIBLE* pWF)
-{
-    GUID subformat;
-
-    if (format == ma_format_unknown) {
-        format = MA_DEFAULT_FORMAT;
-    }
-
-    if (channels == 0) {
-        channels = MA_DEFAULT_CHANNELS;
-    }
-
-    if (sampleRate == 0) {
-        sampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-    switch (format)
-    {
-        case ma_format_u8:
-        case ma_format_s16:
-        case ma_format_s24:
-        /*case ma_format_s24_32:*/
-        case ma_format_s32:
-        {
-            subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-        } break;
-
-        case ma_format_f32:
-        {
-            subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
-        } break;
-
-        default:
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    MA_ZERO_OBJECT(pWF);
-    pWF->Format.cbSize               = sizeof(*pWF);
-    pWF->Format.wFormatTag           = WAVE_FORMAT_EXTENSIBLE;
-    pWF->Format.nChannels            = (WORD)channels;
-    pWF->Format.nSamplesPerSec       = (DWORD)sampleRate;
-    pWF->Format.wBitsPerSample       = (WORD)(ma_get_bytes_per_sample(format)*8);
-    pWF->Format.nBlockAlign          = (WORD)(pWF->Format.nChannels * pWF->Format.wBitsPerSample / 8);
-    pWF->Format.nAvgBytesPerSec      = pWF->Format.nBlockAlign * pWF->Format.nSamplesPerSec;
-    pWF->Samples.wValidBitsPerSample = pWF->Format.wBitsPerSample;
-    pWF->dwChannelMask               = ma_channel_map_to_channel_mask__win32(pChannelMap, channels);
-    pWF->SubFormat                   = subformat;
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__dsound(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /* DirectSound has a minimum period size of 20ms. */
-    ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(20, nativeSampleRate);
-    ma_uint32 periodSizeInFrames;
-
-    periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile);
-    if (periodSizeInFrames < minPeriodSizeInFrames) {
-        periodSizeInFrames = minPeriodSizeInFrames;
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->dsound);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /*
-    Unfortunately DirectSound uses different APIs and data structures for playback and catpure devices. We need to initialize
-    the capture device first because we'll want to match it's buffer size and period count on the playback side if we're using
-    full-duplex mode.
-    */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEFORMATEXTENSIBLE wf;
-        MA_DSCBUFFERDESC descDS;
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodCount;
-        char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
-        WAVEFORMATEXTENSIBLE* pActualFormat;
-
-        result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &wf);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_create_IDirectSoundCapture__dsound(pDevice->pContext, pDescriptorCapture->shareMode, pDescriptorCapture->pDeviceID, (ma_IDirectSoundCapture**)&pDevice->dsound.pCapture);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pDevice->pContext, (ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.Format.nChannels, &wf.Format.wBitsPerSample, &wf.Format.nSamplesPerSec);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        wf.Format.nBlockAlign          = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-        wf.Format.nAvgBytesPerSec      = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-        wf.Samples.wValidBitsPerSample = wf.Format.wBitsPerSample;
-        wf.SubFormat                   = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-
-        /* The size of the buffer must be a clean multiple of the period count. */
-        periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorCapture, wf.Format.nSamplesPerSec, pConfig->performanceProfile);
-        periodCount = (pDescriptorCapture->periodCount > 0) ? pDescriptorCapture->periodCount : MA_DEFAULT_PERIODS;
-
-        MA_ZERO_OBJECT(&descDS);
-        descDS.dwSize        = sizeof(descDS);
-        descDS.dwFlags       = 0;
-        descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.Format.nBlockAlign;
-        descDS.lpwfxFormat   = (WAVEFORMATEX*)&wf;
-        hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* Get the _actual_ properties of the buffer. */
-        pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
-        hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* We can now start setting the output data formats. */
-        pDescriptorCapture->format     = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
-        pDescriptorCapture->channels   = pActualFormat->Format.nChannels;
-        pDescriptorCapture->sampleRate = pActualFormat->Format.nSamplesPerSec;
-
-        /* Get the native channel map based on the channel mask. */
-        if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-            ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        } else {
-            ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        }
-
-        /*
-        After getting the actual format the size of the buffer in frames may have actually changed. However, we want this to be as close to what the
-        user has asked for as possible, so let's go ahead and release the old capture buffer and create a new one in this case.
-        */
-        if (periodSizeInFrames != (descDS.dwBufferBytes / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / periodCount)) {
-            descDS.dwBufferBytes = periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * periodCount;
-            ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-
-            hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL);
-            if (FAILED(hr)) {
-                ma_device_uninit__dsound(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", ma_result_from_HRESULT(hr));
-            }
-        }
-
-        /* DirectSound should give us a buffer exactly the size we asked for. */
-        pDescriptorCapture->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorCapture->periodCount        = periodCount;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEFORMATEXTENSIBLE wf;
-        MA_DSBUFFERDESC descDSPrimary;
-        MA_DSCAPS caps;
-        char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
-        WAVEFORMATEXTENSIBLE* pActualFormat;
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodCount;
-        MA_DSBUFFERDESC descDS;
-
-        result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &wf);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_create_IDirectSound__dsound(pDevice->pContext, pDescriptorPlayback->shareMode, pDescriptorPlayback->pDeviceID, (ma_IDirectSound**)&pDevice->dsound.pPlayback);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        MA_ZERO_OBJECT(&descDSPrimary);
-        descDSPrimary.dwSize  = sizeof(MA_DSBUFFERDESC);
-        descDSPrimary.dwFlags = MA_DSBCAPS_PRIMARYBUFFER | MA_DSBCAPS_CTRLVOLUME;
-        hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-
-        /* We may want to make some adjustments to the format if we are using defaults. */
-        MA_ZERO_OBJECT(&caps);
-        caps.dwSize = sizeof(caps);
-        hr = ma_IDirectSound_GetCaps((ma_IDirectSound*)pDevice->dsound.pPlayback, &caps);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        if (pDescriptorPlayback->channels == 0) {
-            if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
-                DWORD speakerConfig;
-
-                /* It supports at least stereo, but could support more. */
-                wf.Format.nChannels = 2;
-
-                /* Look at the speaker configuration to get a better idea on the channel count. */
-                if (SUCCEEDED(ma_IDirectSound_GetSpeakerConfig((ma_IDirectSound*)pDevice->dsound.pPlayback, &speakerConfig))) {
-                    ma_get_channels_from_speaker_config__dsound(speakerConfig, &wf.Format.nChannels, &wf.dwChannelMask);
-                }
-            } else {
-                /* It does not support stereo, which means we are stuck with mono. */
-                wf.Format.nChannels = 1;
-            }
-        }
-
-        if (pDescriptorPlayback->sampleRate == 0) {
-            /* We base the sample rate on the values returned by GetCaps(). */
-            if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) {
-                wf.Format.nSamplesPerSec = ma_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate);
-            } else {
-                wf.Format.nSamplesPerSec = caps.dwMaxSecondarySampleRate;
-            }
-        }
-
-        wf.Format.nBlockAlign     = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-        wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-
-        /*
-        From MSDN:
-
-        The method succeeds even if the hardware does not support the requested format; DirectSound sets the buffer to the closest
-        supported format. To determine whether this has happened, an application can call the GetFormat method for the primary buffer
-        and compare the result with the format that was requested with the SetFormat method.
-        */
-        hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)&wf);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* Get the _actual_ properties of the buffer. */
-        pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
-        hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* We now have enough information to start setting some output properties. */
-        pDescriptorPlayback->format     = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
-        pDescriptorPlayback->channels   = pActualFormat->Format.nChannels;
-        pDescriptorPlayback->sampleRate = pActualFormat->Format.nSamplesPerSec;
-
-        /* Get the internal channel map based on the channel mask. */
-        if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-            ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        } else {
-            ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        }
-
-        /* The size of the buffer must be a clean multiple of the period count. */
-        periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-        periodCount = (pDescriptorPlayback->periodCount > 0) ? pDescriptorPlayback->periodCount : MA_DEFAULT_PERIODS;
-
-        /*
-        Meaning of dwFlags (from MSDN):
-
-        DSBCAPS_CTRLPOSITIONNOTIFY
-          The buffer has position notification capability.
-
-        DSBCAPS_GLOBALFOCUS
-          With this flag set, an application using DirectSound can continue to play its buffers if the user switches focus to
-          another application, even if the new application uses DirectSound.
-
-        DSBCAPS_GETCURRENTPOSITION2
-          In the first version of DirectSound, the play cursor was significantly ahead of the actual playing sound on emulated
-          sound cards; it was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag is specified, the
-          application can get a more accurate play cursor.
-        */
-        MA_ZERO_OBJECT(&descDS);
-        descDS.dwSize = sizeof(descDS);
-        descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2;
-        descDS.dwBufferBytes = periodSizeInFrames * periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels);
-        descDS.lpwfxFormat = (WAVEFORMATEX*)&wf;
-        hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* DirectSound should give us a buffer exactly the size we asked for. */
-        pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorPlayback->periodCount        = periodCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 bpfDeviceCapture  = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    ma_uint32 bpfDevicePlayback = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    HRESULT hr;
-    DWORD lockOffsetInBytesCapture;
-    DWORD lockSizeInBytesCapture;
-    DWORD mappedSizeInBytesCapture;
-    DWORD mappedDeviceFramesProcessedCapture;
-    void* pMappedDeviceBufferCapture;
-    DWORD lockOffsetInBytesPlayback;
-    DWORD lockSizeInBytesPlayback;
-    DWORD mappedSizeInBytesPlayback;
-    void* pMappedDeviceBufferPlayback;
-    DWORD prevReadCursorInBytesCapture = 0;
-    DWORD prevPlayCursorInBytesPlayback = 0;
-    ma_bool32 physicalPlayCursorLoopFlagPlayback = 0;
-    DWORD virtualWriteCursorInBytesPlayback = 0;
-    ma_bool32 virtualWriteCursorLoopFlagPlayback = 0;
-    ma_bool32 isPlaybackDeviceStarted = MA_FALSE;
-    ma_uint32 framesWrittenToPlaybackDevice = 0;   /* For knowing whether or not the playback device needs to be started. */
-    ma_uint32 waitTimeInMilliseconds = 1;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* The first thing to do is start the capture device. The playback device is only started after the first period is written. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (FAILED(ma_IDirectSoundCaptureBuffer_Start((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, MA_DSCBSTART_LOOPING))) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Start() failed.", MA_FAILED_TO_START_BACKEND_DEVICE);
-        }
-    }
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        switch (pDevice->type)
-        {
-            case ma_device_type_duplex:
-            {
-                DWORD physicalCaptureCursorInBytes;
-                DWORD physicalReadCursorInBytes;
-                hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes);
-                if (FAILED(hr)) {
-                    return ma_result_from_HRESULT(hr);
-                }
-
-                /* If nothing is available we just sleep for a bit and return from this iteration. */
-                if (physicalReadCursorInBytes == prevReadCursorInBytesCapture) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                /*
-                The current position has moved. We need to map all of the captured samples and write them to the playback device, making sure
-                we don't return until every frame has been copied over.
-                */
-                if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) {
-                    /* The capture position has not looped. This is the simple case. */
-                    lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                    lockSizeInBytesCapture   = (physicalReadCursorInBytes - prevReadCursorInBytesCapture);
-                } else {
-                    /*
-                    The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything,
-                    do it again from the start.
-                    */
-                    if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) {
-                        /* Lock up to the end of the buffer. */
-                        lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                        lockSizeInBytesCapture   = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture;
-                    } else {
-                        /* Lock starting from the start of the buffer. */
-                        lockOffsetInBytesCapture = 0;
-                        lockSizeInBytesCapture   = physicalReadCursorInBytes;
-                    }
-                }
-
-                if (lockSizeInBytesCapture == 0) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                }
-
-
-                /* At this point we have some input data that we need to output. We do not return until every mapped frame of the input data is written to the playback device. */
-                mappedDeviceFramesProcessedCapture = 0;
-
-                for (;;) {  /* Keep writing to the playback device. */
-                    ma_uint8  inputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                    ma_uint32 inputFramesInClientFormatCap = sizeof(inputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-                    ma_uint8  outputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                    ma_uint32 outputFramesInClientFormatCap = sizeof(outputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-                    ma_uint32 outputFramesInClientFormatCount;
-                    ma_uint32 outputFramesInClientFormatConsumed = 0;
-                    ma_uint64 clientCapturedFramesToProcess = ma_min(inputFramesInClientFormatCap, outputFramesInClientFormatCap);
-                    ma_uint64 deviceCapturedFramesToProcess = (mappedSizeInBytesCapture / bpfDeviceCapture) - mappedDeviceFramesProcessedCapture;
-                    void* pRunningMappedDeviceBufferCapture = ma_offset_ptr(pMappedDeviceBufferCapture, mappedDeviceFramesProcessedCapture * bpfDeviceCapture);
-
-                    result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningMappedDeviceBufferCapture, &deviceCapturedFramesToProcess, inputFramesInClientFormat, &clientCapturedFramesToProcess);
-                    if (result != MA_SUCCESS) {
-                        break;
-                    }
-
-                    outputFramesInClientFormatCount     = (ma_uint32)clientCapturedFramesToProcess;
-                    mappedDeviceFramesProcessedCapture += (ma_uint32)deviceCapturedFramesToProcess;
-
-                    ma_device__on_data(pDevice, outputFramesInClientFormat, inputFramesInClientFormat, (ma_uint32)clientCapturedFramesToProcess);
-
-                    /* At this point we have input and output data in client format. All we need to do now is convert it to the output device format. This may take a few passes. */
-                    for (;;) {
-                        ma_uint32 framesWrittenThisIteration;
-                        DWORD physicalPlayCursorInBytes;
-                        DWORD physicalWriteCursorInBytes;
-                        DWORD availableBytesPlayback;
-                        DWORD silentPaddingInBytes = 0; /* <-- Must be initialized to 0. */
-
-                        /* We need the physical play and write cursors. */
-                        if (FAILED(ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) {
-                            break;
-                        }
-
-                        if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                            physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                        }
-                        prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                        /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */
-                        if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                            /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                            if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                                availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                                availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                            } else {
-                                /* This is an error. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                            #endif
-                                availableBytesPlayback = 0;
-                            }
-                        } else {
-                            /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                            if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                                availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                            } else {
-                                /* This is an error. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                            #endif
-                                availableBytesPlayback = 0;
-                            }
-                        }
-
-                    #ifdef MA_DEBUG_OUTPUT
-                        /*printf("[DirectSound] (Duplex/Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback);*/
-                    #endif
-
-                        /* If there's no room available for writing we need to wait for more. */
-                        if (availableBytesPlayback == 0) {
-                            /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */
-                            if (!isPlaybackDeviceStarted) {
-                                hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                                if (FAILED(hr)) {
-                                    ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-                                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                                }
-                                isPlaybackDeviceStarted = MA_TRUE;
-                            } else {
-                                ma_sleep(waitTimeInMilliseconds);
-                                continue;
-                            }
-                        }
-
-
-                        /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */
-                        lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback;
-                        if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                            /* Same loop iteration. Go up to the end of the buffer. */
-                            lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        } else {
-                            /* Different loop iterations. Go up to the physical play cursor. */
-                            lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                        }
-
-                        hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0);
-                        if (FAILED(hr)) {
-                            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                            break;
-                        }
-
-                        /*
-                        Experiment: If the playback buffer is being starved, pad it with some silence to get it back in sync. This will cause a glitch, but it may prevent
-                        endless glitching due to it constantly running out of data.
-                        */
-                        if (isPlaybackDeviceStarted) {
-                            DWORD bytesQueuedForPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - availableBytesPlayback;
-                            if (bytesQueuedForPlayback < (pDevice->playback.internalPeriodSizeInFrames*bpfDevicePlayback)) {
-                                silentPaddingInBytes   = (pDevice->playback.internalPeriodSizeInFrames*2*bpfDevicePlayback) - bytesQueuedForPlayback;
-                                if (silentPaddingInBytes > lockSizeInBytesPlayback) {
-                                    silentPaddingInBytes = lockSizeInBytesPlayback;
-                                }
-
-                        #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) Playback buffer starved. availableBytesPlayback=%ld, silentPaddingInBytes=%ld\n", availableBytesPlayback, silentPaddingInBytes);
-                        #endif
-                            }
-                        }
-
-                        /* At this point we have a buffer for output. */
-                        if (silentPaddingInBytes > 0) {
-                            MA_ZERO_MEMORY(pMappedDeviceBufferPlayback, silentPaddingInBytes);
-                            framesWrittenThisIteration = silentPaddingInBytes/bpfDevicePlayback;
-                        } else {
-                            ma_uint64 convertedFrameCountIn  = (outputFramesInClientFormatCount - outputFramesInClientFormatConsumed);
-                            ma_uint64 convertedFrameCountOut = mappedSizeInBytesPlayback/bpfDevicePlayback;
-                            void* pConvertedFramesIn  = ma_offset_ptr(outputFramesInClientFormat, outputFramesInClientFormatConsumed * bpfDevicePlayback);
-                            void* pConvertedFramesOut = pMappedDeviceBufferPlayback;
-
-                            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pConvertedFramesIn, &convertedFrameCountIn, pConvertedFramesOut, &convertedFrameCountOut);
-                            if (result != MA_SUCCESS) {
-                                break;
-                            }
-
-                            outputFramesInClientFormatConsumed += (ma_uint32)convertedFrameCountOut;
-                            framesWrittenThisIteration          = (ma_uint32)convertedFrameCountOut;
-                        }
-
-
-                        hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, framesWrittenThisIteration*bpfDevicePlayback, NULL, 0);
-                        if (FAILED(hr)) {
-                            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                            break;
-                        }
-
-                        virtualWriteCursorInBytesPlayback += framesWrittenThisIteration*bpfDevicePlayback;
-                        if ((virtualWriteCursorInBytesPlayback/bpfDevicePlayback) == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods) {
-                            virtualWriteCursorInBytesPlayback  = 0;
-                            virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback;
-                        }
-
-                        /*
-                        We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds
-                        a bit of a buffer to prevent the playback buffer from getting starved.
-                        */
-                        framesWrittenToPlaybackDevice += framesWrittenThisIteration;
-                        if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= (pDevice->playback.internalPeriodSizeInFrames*2)) {
-                            hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                            if (FAILED(hr)) {
-                                ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-                                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                            }
-                            isPlaybackDeviceStarted = MA_TRUE;
-                        }
-
-                        if (framesWrittenThisIteration < mappedSizeInBytesPlayback/bpfDevicePlayback) {
-                            break;  /* We're finished with the output data.*/
-                        }
-                    }
-
-                    if (clientCapturedFramesToProcess == 0) {
-                        break;  /* We just consumed every input sample. */
-                    }
-                }
-
-
-                /* At this point we're done with the mapped portion of the capture buffer. */
-                hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                }
-                prevReadCursorInBytesCapture = (lockOffsetInBytesCapture + mappedSizeInBytesCapture);
-            } break;
-
-
-
-            case ma_device_type_capture:
-            {
-                DWORD physicalCaptureCursorInBytes;
-                DWORD physicalReadCursorInBytes;
-                hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes);
-                if (FAILED(hr)) {
-                    return MA_ERROR;
-                }
-
-                /* If the previous capture position is the same as the current position we need to wait a bit longer. */
-                if (prevReadCursorInBytesCapture == physicalReadCursorInBytes) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue;
-                }
-
-                /* Getting here means we have capture data available. */
-                if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) {
-                    /* The capture position has not looped. This is the simple case. */
-                    lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                    lockSizeInBytesCapture   = (physicalReadCursorInBytes - prevReadCursorInBytesCapture);
-                } else {
-                    /*
-                    The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything,
-                    do it again from the start.
-                    */
-                    if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) {
-                        /* Lock up to the end of the buffer. */
-                        lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                        lockSizeInBytesCapture   = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture;
-                    } else {
-                        /* Lock starting from the start of the buffer. */
-                        lockOffsetInBytesCapture = 0;
-                        lockSizeInBytesCapture   = physicalReadCursorInBytes;
-                    }
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                /*printf("[DirectSound] (Capture) physicalCaptureCursorInBytes=%d, physicalReadCursorInBytes=%d\n", physicalCaptureCursorInBytes, physicalReadCursorInBytes);*/
-                /*printf("[DirectSound] (Capture) lockOffsetInBytesCapture=%d, lockSizeInBytesCapture=%d\n", lockOffsetInBytesCapture, lockSizeInBytesCapture);*/
-            #endif
-
-                if (lockSizeInBytesCapture < pDevice->capture.internalPeriodSizeInFrames) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                if (lockSizeInBytesCapture != mappedSizeInBytesCapture) {
-                    printf("[DirectSound] (Capture) lockSizeInBytesCapture=%ld != mappedSizeInBytesCapture=%ld\n", lockSizeInBytesCapture, mappedSizeInBytesCapture);
-                }
-            #endif
-
-                ma_device__send_frames_to_client(pDevice, mappedSizeInBytesCapture/bpfDeviceCapture, pMappedDeviceBufferCapture);
-
-                hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                }
-                prevReadCursorInBytesCapture = lockOffsetInBytesCapture + mappedSizeInBytesCapture;
-
-                if (prevReadCursorInBytesCapture == (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture)) {
-                    prevReadCursorInBytesCapture = 0;
-                }
-            } break;
-
-
-
-            case ma_device_type_playback:
-            {
-                DWORD availableBytesPlayback;
-                DWORD physicalPlayCursorInBytes;
-                DWORD physicalWriteCursorInBytes;
-                hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes);
-                if (FAILED(hr)) {
-                    break;
-                }
-
-                if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                    physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                }
-                prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                    } else {
-                        /* This is an error. */
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[DirectSound] (Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                    #endif
-                        availableBytesPlayback = 0;
-                    }
-                } else {
-                    /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                    } else {
-                        /* This is an error. */
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[DirectSound] (Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                    #endif
-                        availableBytesPlayback = 0;
-                    }
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                /*printf("[DirectSound] (Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback);*/
-            #endif
-
-                /* If there's no room available for writing we need to wait for more. */
-                if (availableBytesPlayback < pDevice->playback.internalPeriodSizeInFrames) {
-                    /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */
-                    if (availableBytesPlayback == 0 && !isPlaybackDeviceStarted) {
-                        hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                        if (FAILED(hr)) {
-                            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                        }
-                        isPlaybackDeviceStarted = MA_TRUE;
-                    } else {
-                        ma_sleep(waitTimeInMilliseconds);
-                        continue;
-                    }
-                }
-
-                /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */
-                lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback;
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. Go up to the end of the buffer. */
-                    lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                } else {
-                    /* Different loop iterations. Go up to the physical play cursor. */
-                    lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                }
-
-                hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                    break;
-                }
-
-                /* At this point we have a buffer for output. */
-                ma_device__read_frames_from_client(pDevice, (mappedSizeInBytesPlayback/bpfDevicePlayback), pMappedDeviceBufferPlayback);
-
-                hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, mappedSizeInBytesPlayback, NULL, 0);
-                if (FAILED(hr)) {
-                    result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                    break;
-                }
-
-                virtualWriteCursorInBytesPlayback += mappedSizeInBytesPlayback;
-                if (virtualWriteCursorInBytesPlayback == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) {
-                    virtualWriteCursorInBytesPlayback  = 0;
-                    virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback;
-                }
-
-                /*
-                We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds
-                a bit of a buffer to prevent the playback buffer from getting starved.
-                */
-                framesWrittenToPlaybackDevice += mappedSizeInBytesPlayback/bpfDevicePlayback;
-                if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= pDevice->playback.internalPeriodSizeInFrames) {
-                    hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                    if (FAILED(hr)) {
-                        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                    }
-                    isPlaybackDeviceStarted = MA_TRUE;
-                }
-            } break;
-
-
-            default: return MA_INVALID_ARGS;   /* Invalid device type. */
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    /* Getting here means the device is being stopped. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        hr = ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Stop() failed.", ma_result_from_HRESULT(hr));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
-        if (isPlaybackDeviceStarted) {
-            for (;;) {
-                DWORD availableBytesPlayback = 0;
-                DWORD physicalPlayCursorInBytes;
-                DWORD physicalWriteCursorInBytes;
-                hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes);
-                if (FAILED(hr)) {
-                    break;
-                }
-
-                if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                    physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                }
-                prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                    } else {
-                        break;
-                    }
-                } else {
-                    /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                    } else {
-                        break;
-                    }
-                }
-
-                if (availableBytesPlayback >= (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback)) {
-                    break;
-                }
-
-                ma_sleep(waitTimeInMilliseconds);
-            }
-        }
-
-        hr = ma_IDirectSoundBuffer_Stop((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Stop() failed.", ma_result_from_HRESULT(hr));
-        }
-
-        ma_IDirectSoundBuffer_SetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__dsound(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_dsound);
-
-    ma_dlclose(pContext, pContext->dsound.hDSoundDLL);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pContext->dsound.hDSoundDLL = ma_dlopen(pContext, "dsound.dll");
-    if (pContext->dsound.hDSoundDLL == NULL) {
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->dsound.DirectSoundCreate            = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCreate");
-    pContext->dsound.DirectSoundEnumerateA        = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundEnumerateA");
-    pContext->dsound.DirectSoundCaptureCreate     = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureCreate");
-    pContext->dsound.DirectSoundCaptureEnumerateA = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureEnumerateA");
-
-    pCallbacks->onContextInit             = ma_context_init__dsound;
-    pCallbacks->onContextUninit           = ma_context_uninit__dsound;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__dsound;
-    pCallbacks->onDeviceInit              = ma_device_init__dsound;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__dsound;
-    pCallbacks->onDeviceStart             = NULL;   /* Not used. Started in onDeviceDataLoop. */
-    pCallbacks->onDeviceStop              = NULL;   /* Not used. Stopped in onDeviceDataLoop. */
-    pCallbacks->onDeviceRead              = NULL;   /* Not used. Data is read directly in onDeviceDataLoop. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used. Data is written directly in onDeviceDataLoop. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__dsound;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-/******************************************************************************
-
-WinMM Backend
-
-******************************************************************************/
-#ifdef MA_HAS_WINMM
-
-/*
-Some older compilers don't have WAVEOUTCAPS2A and WAVEINCAPS2A, so we'll need to write this ourselves. These structures
-are exactly the same as the older ones but they have a few GUIDs for manufacturer/product/name identification. I'm keeping
-the names the same as the Win32 library for consistency, but namespaced to avoid naming conflicts with the Win32 version.
-*/
-typedef struct
-{
-    WORD wMid;
-    WORD wPid;
-    MMVERSION vDriverVersion;
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    WORD wReserved1;
-    DWORD dwSupport;
-    GUID ManufacturerGuid;
-    GUID ProductGuid;
-    GUID NameGuid;
-} MA_WAVEOUTCAPS2A;
-typedef struct
-{
-    WORD wMid;
-    WORD wPid;
-    MMVERSION vDriverVersion;
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    WORD wReserved1;
-    GUID ManufacturerGuid;
-    GUID ProductGuid;
-    GUID NameGuid;
-} MA_WAVEINCAPS2A;
-
-typedef UINT     (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutOpen)(LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutClose)(HWAVEOUT hwo);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutWrite)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutReset)(HWAVEOUT hwo);
-typedef UINT     (WINAPI * MA_PFN_waveInGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic);
-typedef MMRESULT (WINAPI * MA_PFN_waveInOpen)(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveInClose)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInStart)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInReset)(HWAVEIN hwi);
-
-static ma_result ma_result_from_MMRESULT(MMRESULT resultMM)
-{
-    switch (resultMM) {
-        case MMSYSERR_NOERROR:      return MA_SUCCESS;
-        case MMSYSERR_BADDEVICEID:  return MA_INVALID_ARGS;
-        case MMSYSERR_INVALHANDLE:  return MA_INVALID_ARGS;
-        case MMSYSERR_NOMEM:        return MA_OUT_OF_MEMORY;
-        case MMSYSERR_INVALFLAG:    return MA_INVALID_ARGS;
-        case MMSYSERR_INVALPARAM:   return MA_INVALID_ARGS;
-        case MMSYSERR_HANDLEBUSY:   return MA_BUSY;
-        case MMSYSERR_ERROR:        return MA_ERROR;
-        default:                    return MA_ERROR;
-    }
-}
-
-static char* ma_find_last_character(char* str, char ch)
-{
-    char* last;
-
-    if (str == NULL) {
-        return NULL;
-    }
-
-    last = NULL;
-    while (*str != '\0') {
-        if (*str == ch) {
-            last = str;
-        }
-
-        str += 1;
-    }
-
-    return last;
-}
-
-static ma_uint32 ma_get_period_size_in_bytes(ma_uint32 periodSizeInFrames, ma_format format, ma_uint32 channels)
-{
-    return periodSizeInFrames * ma_get_bytes_per_frame(format, channels);
-}
-
-
-/*
-Our own "WAVECAPS" structure that contains generic information shared between WAVEOUTCAPS2 and WAVEINCAPS2 so
-we can do things generically and typesafely. Names are being kept the same for consistency.
-*/
-typedef struct
-{
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    GUID NameGuid;
-} MA_WAVECAPSA;
-
-static ma_result ma_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD channels, WORD* pBitsPerSample, DWORD* pSampleRate)
-{
-    WORD bitsPerSample = 0;
-    DWORD sampleRate = 0;
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = 0;
-    }
-    if (pSampleRate) {
-        *pSampleRate = 0;
-    }
-
-    if (channels == 1) {
-        bitsPerSample = 16;
-        if ((dwFormats & WAVE_FORMAT_48M16) != 0) {
-            sampleRate = 48000;
-        } else if ((dwFormats & WAVE_FORMAT_44M16) != 0) {
-            sampleRate = 44100;
-        } else if ((dwFormats & WAVE_FORMAT_2M16) != 0) {
-            sampleRate = 22050;
-        } else if ((dwFormats & WAVE_FORMAT_1M16) != 0) {
-            sampleRate = 11025;
-        } else if ((dwFormats & WAVE_FORMAT_96M16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((dwFormats & WAVE_FORMAT_48M08) != 0) {
-                sampleRate = 48000;
-            } else if ((dwFormats & WAVE_FORMAT_44M08) != 0) {
-                sampleRate = 44100;
-            } else if ((dwFormats & WAVE_FORMAT_2M08) != 0) {
-                sampleRate = 22050;
-            } else if ((dwFormats & WAVE_FORMAT_1M08) != 0) {
-                sampleRate = 11025;
-            } else if ((dwFormats & WAVE_FORMAT_96M08) != 0) {
-                sampleRate = 96000;
-            } else {
-                return MA_FORMAT_NOT_SUPPORTED;
-            }
-        }
-    } else {
-        bitsPerSample = 16;
-        if ((dwFormats & WAVE_FORMAT_48S16) != 0) {
-            sampleRate = 48000;
-        } else if ((dwFormats & WAVE_FORMAT_44S16) != 0) {
-            sampleRate = 44100;
-        } else if ((dwFormats & WAVE_FORMAT_2S16) != 0) {
-            sampleRate = 22050;
-        } else if ((dwFormats & WAVE_FORMAT_1S16) != 0) {
-            sampleRate = 11025;
-        } else if ((dwFormats & WAVE_FORMAT_96S16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((dwFormats & WAVE_FORMAT_48S08) != 0) {
-                sampleRate = 48000;
-            } else if ((dwFormats & WAVE_FORMAT_44S08) != 0) {
-                sampleRate = 44100;
-            } else if ((dwFormats & WAVE_FORMAT_2S08) != 0) {
-                sampleRate = 22050;
-            } else if ((dwFormats & WAVE_FORMAT_1S08) != 0) {
-                sampleRate = 11025;
-            } else if ((dwFormats & WAVE_FORMAT_96S08) != 0) {
-                sampleRate = 96000;
-            } else {
-                return MA_FORMAT_NOT_SUPPORTED;
-            }
-        }
-    }
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = bitsPerSample;
-    }
-    if (pSampleRate) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, WAVEFORMATEX* pWF)
-{
-    ma_result result;
-
-    MA_ASSERT(pWF != NULL);
-
-    MA_ZERO_OBJECT(pWF);
-    pWF->cbSize     = sizeof(*pWF);
-    pWF->wFormatTag = WAVE_FORMAT_PCM;
-    pWF->nChannels  = (WORD)channels;
-    if (pWF->nChannels > 2) {
-        pWF->nChannels = 2;
-    }
-
-    result = ma_get_best_info_from_formats_flags__winmm(dwFormats, channels, &pWF->wBitsPerSample, &pWF->nSamplesPerSec);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pWF->nBlockAlign     = (WORD)(pWF->nChannels * pWF->wBitsPerSample / 8);
-    pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, MA_WAVECAPSA* pCaps, ma_device_info* pDeviceInfo)
-{
-    WORD bitsPerSample;
-    DWORD sampleRate;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /*
-    Name / Description
-
-    Unfortunately the name specified in WAVE(OUT/IN)CAPS2 is limited to 31 characters. This results in an unprofessional looking
-    situation where the names of the devices are truncated. To help work around this, we need to look at the name GUID and try
-    looking in the registry for the full name. If we can't find it there, we need to just fall back to the default name.
-    */
-
-    /* Set the default to begin with. */
-    ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), pCaps->szPname, (size_t)-1);
-
-    /*
-    Now try the registry. There's a few things to consider here:
-    - The name GUID can be null, in which we case we just need to stick to the original 31 characters.
-    - If the name GUID is not present in the registry we'll also need to stick to the original 31 characters.
-    - I like consistency, so I want the returned device names to be consistent with those returned by WASAPI and DirectSound. The
-      problem, however is that WASAPI and DirectSound use "<component> (<name>)" format (such as "Speakers (High Definition Audio)"),
-      but WinMM does not specificy the component name. From my admittedly limited testing, I've notice the component name seems to
-      usually fit within the 31 characters of the fixed sized buffer, so what I'm going to do is parse that string for the component
-      name, and then concatenate the name from the registry.
-    */
-    if (!ma_is_guid_null(&pCaps->NameGuid)) {
-        wchar_t guidStrW[256];
-        if (((MA_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, ma_countof(guidStrW)) > 0) {
-            char guidStr[256];
-            char keyStr[1024];
-            HKEY hKey;
-
-            WideCharToMultiByte(CP_UTF8, 0, guidStrW, -1, guidStr, sizeof(guidStr), 0, FALSE);
-
-            ma_strcpy_s(keyStr, sizeof(keyStr), "SYSTEM\\CurrentControlSet\\Control\\MediaCategories\\");
-            ma_strcat_s(keyStr, sizeof(keyStr), guidStr);
-
-            if (((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
-                BYTE nameFromReg[512];
-                DWORD nameFromRegSize = sizeof(nameFromReg);
-                result = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize);
-                ((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey);
-
-                if (result == ERROR_SUCCESS) {
-                    /* We have the value from the registry, so now we need to construct the name string. */
-                    char name[1024];
-                    if (ma_strcpy_s(name, sizeof(name), pDeviceInfo->name) == 0) {
-                        char* nameBeg = ma_find_last_character(name, '(');
-                        if (nameBeg != NULL) {
-                            size_t leadingLen = (nameBeg - name);
-                            ma_strncpy_s(nameBeg + 1, sizeof(name) - leadingLen, (const char*)nameFromReg, (size_t)-1);
-
-                            /* The closing ")", if it can fit. */
-                            if (leadingLen + nameFromRegSize < sizeof(name)-1) {
-                                ma_strcat_s(name, sizeof(name), ")");
-                            }
-
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), name, (size_t)-1);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    result = ma_get_best_info_from_formats_flags__winmm(pCaps->dwFormats, pCaps->wChannels, &bitsPerSample, &sampleRate);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (bitsPerSample == 8) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_u8;
-    } else if (bitsPerSample == 16) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s16;
-    } else if (bitsPerSample == 24) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s24;
-    } else if (bitsPerSample == 32) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s32;
-    } else {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-    pDeviceInfo->nativeDataFormats[0].channels   = pCaps->wChannels;
-    pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate;
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info_from_WAVEOUTCAPS2(ma_context* pContext, MA_WAVEOUTCAPS2A* pCaps, ma_device_info* pDeviceInfo)
-{
-    MA_WAVECAPSA caps;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname));
-    caps.dwFormats = pCaps->dwFormats;
-    caps.wChannels = pCaps->wChannels;
-    caps.NameGuid  = pCaps->NameGuid;
-    return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo);
-}
-
-static ma_result ma_context_get_device_info_from_WAVEINCAPS2(ma_context* pContext, MA_WAVEINCAPS2A* pCaps, ma_device_info* pDeviceInfo)
-{
-    MA_WAVECAPSA caps;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname));
-    caps.dwFormats = pCaps->dwFormats;
-    caps.wChannels = pCaps->wChannels;
-    caps.NameGuid  = pCaps->NameGuid;
-    return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo);
-}
-
-
-static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    UINT playbackDeviceCount;
-    UINT captureDeviceCount;
-    UINT iPlaybackDevice;
-    UINT iCaptureDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)();
-    for (iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) {
-        MMRESULT result;
-        MA_WAVEOUTCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            ma_device_info deviceInfo;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.winmm = iPlaybackDevice;
-
-            /* The first enumerated device is the default device. */
-            if (iPlaybackDevice == 0) {
-                deviceInfo.isDefault = MA_TRUE;
-            }
-
-            if (ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) {
-                ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    return MA_SUCCESS; /* Enumeration was stopped. */
-                }
-            }
-        }
-    }
-
-    /* Capture. */
-    captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)();
-    for (iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) {
-        MMRESULT result;
-        MA_WAVEINCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            ma_device_info deviceInfo;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.winmm = iCaptureDevice;
-
-            /* The first enumerated device is the default device. */
-            if (iCaptureDevice == 0) {
-                deviceInfo.isDefault = MA_TRUE;
-            }
-
-            if (ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) {
-                ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    return MA_SUCCESS; /* Enumeration was stopped. */
-                }
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    UINT winMMDeviceID;
-
-    MA_ASSERT(pContext != NULL);
-
-    winMMDeviceID = 0;
-    if (pDeviceID != NULL) {
-        winMMDeviceID = (UINT)pDeviceID->winmm;
-    }
-
-    pDeviceInfo->id.winmm = winMMDeviceID;
-
-    /* The first ID is the default device. */
-    if (winMMDeviceID == 0) {
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        MMRESULT result;
-        MA_WAVEOUTCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            return ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo);
-        }
-    } else {
-        MMRESULT result;
-        MA_WAVEINCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            return ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo);
-        }
-    }
-
-    return MA_NO_DEVICE;
-}
-
-
-static ma_result ma_device_uninit__winmm(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        CloseHandle((HANDLE)pDevice->winmm.hEventCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        CloseHandle((HANDLE)pDevice->winmm.hEventPlayback);
-    }
-
-    ma__free_from_callbacks(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
-
-    MA_ZERO_OBJECT(&pDevice->winmm);   /* Safety. */
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__winmm(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /* WinMM has a minimum period size of 40ms. */
-    ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(40, nativeSampleRate);
-    ma_uint32 periodSizeInFrames;
-
-    periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile);
-    if (periodSizeInFrames < minPeriodSizeInFrames) {
-        periodSizeInFrames = minPeriodSizeInFrames;
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    const char* errorMsg = "";
-    ma_result errorCode = MA_ERROR;
-    ma_result result = MA_SUCCESS;
-    ma_uint32 heapSize;
-    UINT winMMDeviceIDPlayback = 0;
-    UINT winMMDeviceIDCapture  = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->winmm);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exlusive mode with WinMM. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pDescriptorPlayback->pDeviceID != NULL) {
-        winMMDeviceIDPlayback = (UINT)pDescriptorPlayback->pDeviceID->winmm;
-    }
-    if (pDescriptorCapture->pDeviceID != NULL) {
-        winMMDeviceIDCapture = (UINT)pDescriptorCapture->pDeviceID->winmm;
-    }
-
-    /* The capture device needs to be initialized first. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEINCAPSA caps;
-        WAVEFORMATEX wf;
-        MMRESULT resultMM;
-
-        /* We use an event to know when a new fragment needs to be enqueued. */
-        pDevice->winmm.hEventCapture = (ma_handle)CreateEventW(NULL, TRUE, TRUE, NULL);
-        if (pDevice->winmm.hEventCapture == NULL) {
-            errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = ma_result_from_GetLastError(GetLastError());
-            goto on_error;
-        }
-
-        /* The format should be based on the device's actual format. */
-        if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
-            goto on_error;
-        }
-
-        result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf);
-        if (result != MA_SUCCESS) {
-            errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result;
-            goto on_error;
-        }
-
-        resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
-        if (resultMM != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-            goto on_error;
-        }
-
-        pDescriptorCapture->format             = ma_format_from_WAVEFORMATEX(&wf);
-        pDescriptorCapture->channels           = wf.nChannels;
-        pDescriptorCapture->sampleRate         = wf.nSamplesPerSec;
-        ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        pDescriptorCapture->periodCount        = pDescriptorCapture->periodCount;
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEOUTCAPSA caps;
-        WAVEFORMATEX wf;
-        MMRESULT resultMM;
-
-        /* We use an event to know when a new fragment needs to be enqueued. */
-        pDevice->winmm.hEventPlayback = (ma_handle)CreateEvent(NULL, TRUE, TRUE, NULL);
-        if (pDevice->winmm.hEventPlayback == NULL) {
-            errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = ma_result_from_GetLastError(GetLastError());
-            goto on_error;
-        }
-
-        /* The format should be based on the device's actual format. */
-        if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
-            goto on_error;
-        }
-
-        result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf);
-        if (result != MA_SUCCESS) {
-            errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result;
-            goto on_error;
-        }
-
-        resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
-        if (resultMM != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-            goto on_error;
-        }
-
-        pDescriptorPlayback->format             = ma_format_from_WAVEFORMATEX(&wf);
-        pDescriptorPlayback->channels           = wf.nChannels;
-        pDescriptorPlayback->sampleRate         = wf.nSamplesPerSec;
-        ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        pDescriptorPlayback->periodCount        = pDescriptorPlayback->periodCount;
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-    }
-
-    /*
-    The heap allocated data is allocated like so:
-
-    [Capture WAVEHDRs][Playback WAVEHDRs][Capture Intermediary Buffer][Playback Intermediary Buffer]
-    */
-    heapSize = 0;
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        heapSize += sizeof(WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
-    }
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        heapSize += sizeof(WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
-    }
-
-    pDevice->winmm._pHeapData = (ma_uint8*)ma__calloc_from_callbacks(heapSize, &pDevice->pContext->allocationCallbacks);
-    if (pDevice->winmm._pHeapData == NULL) {
-        errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MA_OUT_OF_MEMORY;
-        goto on_error;
-    }
-
-    MA_ZERO_MEMORY(pDevice->winmm._pHeapData, heapSize);
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-
-        if (pConfig->deviceType == ma_device_type_capture) {
-            pDevice->winmm.pWAVEHDRCapture            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
-        } else {
-            pDevice->winmm.pWAVEHDRCapture            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
-        }
-
-        /* Prepare headers. */
-        for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
-            ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->format, pDescriptorCapture->channels);
-
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData         = (LPSTR)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags        = 0L;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops        = 0L;
-            ((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-
-            /*
-            The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
-            it's unlocked and available for writing. A value of 1 means it's locked.
-            */
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-
-        if (pConfig->deviceType == ma_device_type_playback) {
-            pDevice->winmm.pWAVEHDRPlayback            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*pDescriptorPlayback->periodCount);
-        } else {
-            pDevice->winmm.pWAVEHDRPlayback            = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
-            pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
-        }
-
-        /* Prepare headers. */
-        for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
-            ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->format, pDescriptorPlayback->channels);
-
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData         = (LPSTR)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags        = 0L;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops        = 0L;
-            ((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
-
-            /*
-            The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
-            it's unlocked and available for writing. A value of 1 means it's locked.
-            */
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
-        }
-    }
-
-    return MA_SUCCESS;
-
-on_error:
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.pWAVEHDRCapture != NULL) {
-            ma_uint32 iPeriod;
-            for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
-                ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-            }
-        }
-
-        ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.pWAVEHDRCapture != NULL) {
-            ma_uint32 iPeriod;
-            for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
-                ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
-            }
-        }
-
-        ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-    }
-
-    ma__free_from_callbacks(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
-    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, errorMsg, errorCode);
-}
-
-static ma_result ma_device_start__winmm(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        MMRESULT resultMM;
-        WAVEHDR* pWAVEHDR;
-        ma_uint32 iPeriod;
-
-        pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
-
-        /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-        ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
-
-        /* To start the device we attach all of the buffers and then start it. As the buffers are filled with data we will get notifications. */
-        for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
-            resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-            if (resultMM != MMSYSERR_NOERROR) {
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.", ma_result_from_MMRESULT(resultMM));
-            }
-
-            /* Make sure all of the buffers start out locked. We don't want to access them until the backend tells us we can. */
-            pWAVEHDR[iPeriod].dwUser = 1;   /* 1 = locked. */
-        }
-
-        /* Capture devices need to be explicitly started, unlike playback devices. */
-        resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        if (resultMM != MMSYSERR_NOERROR) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Don't need to do anything for playback. It'll be started automatically in ma_device_start__winmm(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__winmm(ma_device* pDevice)
-{
-    MMRESULT resultMM;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.hDeviceCapture == NULL) {
-            return MA_INVALID_ARGS;
-        }
-
-        resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        if (resultMM != MMSYSERR_NOERROR) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset capture device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-        WAVEHDR* pWAVEHDR;
-
-        if (pDevice->winmm.hDevicePlayback == NULL) {
-            return MA_INVALID_ARGS;
-        }
-
-        /* We need to drain the device. To do this we just loop over each header and if it's locked just wait for the event. */
-        pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
-        for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; iPeriod += 1) {
-            if (pWAVEHDR[iPeriod].dwUser == 1) { /* 1 = locked. */
-                if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
-                    break;  /* An error occurred so just abandon ship and stop the device without draining. */
-                }
-
-                pWAVEHDR[iPeriod].dwUser = 0;
-            }
-        }
-
-        resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        if (resultMM != MMSYSERR_NOERROR) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset playback device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    MMRESULT resultMM;
-    ma_uint32 totalFramesWritten;
-    WAVEHDR* pWAVEHDR;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pPCMFrames != NULL);
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
-
-    /* Keep processing as much data as possible. */
-    totalFramesWritten = 0;
-    while (totalFramesWritten < frameCount) {
-        /* If the current header has some space available we need to write part of it. */
-        if (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser == 0) { /* 0 = unlocked. */
-            /*
-            This header has room in it. We copy as much of it as we can. If we end up fully consuming the buffer we need to
-            write it out and move on to the next iteration.
-            */
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-            ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedPlayback;
-
-            ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesWritten));
-            const void* pSrc = ma_offset_ptr(pPCMFrames, totalFramesWritten*bpf);
-            void* pDst = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].lpData, pDevice->winmm.headerFramesConsumedPlayback*bpf);
-            MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf);
-
-            pDevice->winmm.headerFramesConsumedPlayback += framesToCopy;
-            totalFramesWritten += framesToCopy;
-
-            /* If we've consumed the buffer entirely we need to write it out to the device. */
-            if (pDevice->winmm.headerFramesConsumedPlayback == (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf)) {
-                pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 1;            /* 1 = locked. */
-                pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
-
-                /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-                ResetEvent((HANDLE)pDevice->winmm.hEventPlayback);
-
-                /* The device will be started here. */
-                resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR));
-                if (resultMM != MMSYSERR_NOERROR) {
-                    result = ma_result_from_MMRESULT(resultMM);
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.", result);
-                    break;
-                }
-
-                /* Make sure we move to the next header. */
-                pDevice->winmm.iNextHeaderPlayback = (pDevice->winmm.iNextHeaderPlayback + 1) % pDevice->playback.internalPeriods;
-                pDevice->winmm.headerFramesConsumedPlayback = 0;
-            }
-
-            /* If at this point we have consumed the entire input buffer we can return. */
-            MA_ASSERT(totalFramesWritten <= frameCount);
-            if (totalFramesWritten == frameCount) {
-                break;
-            }
-
-            /* Getting here means there's more to process. */
-            continue;
-        }
-
-        /* Getting here means there isn't enough room in the buffer and we need to wait for one to become available. */
-        if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
-            result = MA_ERROR;
-            break;
-        }
-
-        /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
-        if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & WHDR_DONE) != 0) {
-            pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 0;    /* 0 = unlocked (make it available for writing). */
-            pDevice->winmm.headerFramesConsumedPlayback = 0;
-        }
-
-        /* If the device has been stopped we need to break. */
-        if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-            break;
-        }
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = totalFramesWritten;
-    }
-
-    return result;
-}
-
-static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_result result = MA_SUCCESS;
-    MMRESULT resultMM;
-    ma_uint32 totalFramesRead;
-    WAVEHDR* pWAVEHDR;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pPCMFrames != NULL);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
-
-    /* Keep processing as much data as possible. */
-    totalFramesRead = 0;
-    while (totalFramesRead < frameCount) {
-        /* If the current header has some space available we need to write part of it. */
-        if (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser == 0) { /* 0 = unlocked. */
-            /* The buffer is available for reading. If we fully consume it we need to add it back to the buffer. */
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-            ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedCapture;
-
-            ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesRead));
-            const void* pSrc = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderCapture].lpData, pDevice->winmm.headerFramesConsumedCapture*bpf);
-            void* pDst = ma_offset_ptr(pPCMFrames, totalFramesRead*bpf);
-            MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf);
-
-            pDevice->winmm.headerFramesConsumedCapture += framesToCopy;
-            totalFramesRead += framesToCopy;
-
-            /* If we've consumed the buffer entirely we need to add it back to the device. */
-            if (pDevice->winmm.headerFramesConsumedCapture == (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf)) {
-                pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 1;            /* 1 = locked. */
-                pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
-
-                /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-                ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
-
-                /* The device will be started here. */
-                resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR));
-                if (resultMM != MMSYSERR_NOERROR) {
-                    result = ma_result_from_MMRESULT(resultMM);
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.", result);
-                    break;
-                }
-
-                /* Make sure we move to the next header. */
-                pDevice->winmm.iNextHeaderCapture = (pDevice->winmm.iNextHeaderCapture + 1) % pDevice->capture.internalPeriods;
-                pDevice->winmm.headerFramesConsumedCapture = 0;
-            }
-
-            /* If at this point we have filled the entire input buffer we can return. */
-            MA_ASSERT(totalFramesRead <= frameCount);
-            if (totalFramesRead == frameCount) {
-                break;
-            }
-
-            /* Getting here means there's more to process. */
-            continue;
-        }
-
-        /* Getting here means there isn't enough any data left to send to the client which means we need to wait for more. */
-        if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventCapture, INFINITE) != WAIT_OBJECT_0) {
-            result = MA_ERROR;
-            break;
-        }
-
-        /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
-        if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & WHDR_DONE) != 0) {
-            pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 0;    /* 0 = unlocked (make it available for reading). */
-            pDevice->winmm.headerFramesConsumedCapture = 0;
-        }
-
-        /* If the device has been stopped we need to break. */
-        if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-            break;
-        }
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = totalFramesRead;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_uninit__winmm(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_winmm);
-
-    ma_dlclose(pContext, pContext->winmm.hWinMM);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__winmm(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pContext->winmm.hWinMM = ma_dlopen(pContext, "winmm.dll");
-    if (pContext->winmm.hWinMM == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->winmm.waveOutGetNumDevs      = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutGetNumDevs");
-    pContext->winmm.waveOutGetDevCapsA     = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutGetDevCapsA");
-    pContext->winmm.waveOutOpen            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutOpen");
-    pContext->winmm.waveOutClose           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutClose");
-    pContext->winmm.waveOutPrepareHeader   = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutPrepareHeader");
-    pContext->winmm.waveOutUnprepareHeader = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutUnprepareHeader");
-    pContext->winmm.waveOutWrite           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutWrite");
-    pContext->winmm.waveOutReset           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutReset");
-    pContext->winmm.waveInGetNumDevs       = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInGetNumDevs");
-    pContext->winmm.waveInGetDevCapsA      = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInGetDevCapsA");
-    pContext->winmm.waveInOpen             = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInOpen");
-    pContext->winmm.waveInClose            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInClose");
-    pContext->winmm.waveInPrepareHeader    = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInPrepareHeader");
-    pContext->winmm.waveInUnprepareHeader  = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInUnprepareHeader");
-    pContext->winmm.waveInAddBuffer        = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInAddBuffer");
-    pContext->winmm.waveInStart            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInStart");
-    pContext->winmm.waveInReset            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInReset");
-
-    pCallbacks->onContextInit             = ma_context_init__winmm;
-    pCallbacks->onContextUninit           = ma_context_uninit__winmm;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__winmm;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__winmm;
-    pCallbacks->onDeviceInit              = ma_device_init__winmm;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__winmm;
-    pCallbacks->onDeviceStart             = ma_device_start__winmm;
-    pCallbacks->onDeviceStop              = ma_device_stop__winmm;
-    pCallbacks->onDeviceRead              = ma_device_read__winmm;
-    pCallbacks->onDeviceWrite             = ma_device_write__winmm;
-    pCallbacks->onDeviceDataLoop          = NULL;   /* This is a blocking read-write API, so this can be NULL since miniaudio will manage the audio thread for us. */
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-
-/******************************************************************************
-
-ALSA Backend
-
-******************************************************************************/
-#ifdef MA_HAS_ALSA
-
-#ifdef MA_NO_RUNTIME_LINKING
-
-/* asoundlib.h marks some functions with "inline" which isn't always supported. Need to emulate it. */
-#if !defined(__cplusplus)
-    #if defined(__STRICT_ANSI__)
-        #if !defined(inline)
-            #define inline __inline__ __attribute__((always_inline))
-            #define MA_INLINE_DEFINED
-        #endif
-    #endif
-#endif
-#include <alsa/asoundlib.h>
-#if defined(MA_INLINE_DEFINED)
-    #undef inline
-    #undef MA_INLINE_DEFINED
-#endif
-
-typedef snd_pcm_uframes_t                       ma_snd_pcm_uframes_t;
-typedef snd_pcm_sframes_t                       ma_snd_pcm_sframes_t;
-typedef snd_pcm_stream_t                        ma_snd_pcm_stream_t;
-typedef snd_pcm_format_t                        ma_snd_pcm_format_t;
-typedef snd_pcm_access_t                        ma_snd_pcm_access_t;
-typedef snd_pcm_t                               ma_snd_pcm_t;
-typedef snd_pcm_hw_params_t                     ma_snd_pcm_hw_params_t;
-typedef snd_pcm_sw_params_t                     ma_snd_pcm_sw_params_t;
-typedef snd_pcm_format_mask_t                   ma_snd_pcm_format_mask_t;
-typedef snd_pcm_info_t                          ma_snd_pcm_info_t;
-typedef snd_pcm_channel_area_t                  ma_snd_pcm_channel_area_t;
-typedef snd_pcm_chmap_t                         ma_snd_pcm_chmap_t;
-typedef snd_pcm_state_t                         ma_snd_pcm_state_t;
-
-/* snd_pcm_stream_t */
-#define MA_SND_PCM_STREAM_PLAYBACK              SND_PCM_STREAM_PLAYBACK
-#define MA_SND_PCM_STREAM_CAPTURE               SND_PCM_STREAM_CAPTURE
-
-/* snd_pcm_format_t */
-#define MA_SND_PCM_FORMAT_UNKNOWN               SND_PCM_FORMAT_UNKNOWN
-#define MA_SND_PCM_FORMAT_U8                    SND_PCM_FORMAT_U8
-#define MA_SND_PCM_FORMAT_S16_LE                SND_PCM_FORMAT_S16_LE
-#define MA_SND_PCM_FORMAT_S16_BE                SND_PCM_FORMAT_S16_BE
-#define MA_SND_PCM_FORMAT_S24_LE                SND_PCM_FORMAT_S24_LE
-#define MA_SND_PCM_FORMAT_S24_BE                SND_PCM_FORMAT_S24_BE
-#define MA_SND_PCM_FORMAT_S32_LE                SND_PCM_FORMAT_S32_LE
-#define MA_SND_PCM_FORMAT_S32_BE                SND_PCM_FORMAT_S32_BE
-#define MA_SND_PCM_FORMAT_FLOAT_LE              SND_PCM_FORMAT_FLOAT_LE
-#define MA_SND_PCM_FORMAT_FLOAT_BE              SND_PCM_FORMAT_FLOAT_BE
-#define MA_SND_PCM_FORMAT_FLOAT64_LE            SND_PCM_FORMAT_FLOAT64_LE
-#define MA_SND_PCM_FORMAT_FLOAT64_BE            SND_PCM_FORMAT_FLOAT64_BE
-#define MA_SND_PCM_FORMAT_MU_LAW                SND_PCM_FORMAT_MU_LAW
-#define MA_SND_PCM_FORMAT_A_LAW                 SND_PCM_FORMAT_A_LAW
-#define MA_SND_PCM_FORMAT_S24_3LE               SND_PCM_FORMAT_S24_3LE
-#define MA_SND_PCM_FORMAT_S24_3BE               SND_PCM_FORMAT_S24_3BE
-
-/* ma_snd_pcm_access_t */
-#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED      SND_PCM_ACCESS_MMAP_INTERLEAVED
-#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED   SND_PCM_ACCESS_MMAP_NONINTERLEAVED
-#define MA_SND_PCM_ACCESS_MMAP_COMPLEX          SND_PCM_ACCESS_MMAP_COMPLEX
-#define MA_SND_PCM_ACCESS_RW_INTERLEAVED        SND_PCM_ACCESS_RW_INTERLEAVED
-#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED     SND_PCM_ACCESS_RW_NONINTERLEAVED
-
-/* Channel positions. */
-#define MA_SND_CHMAP_UNKNOWN                    SND_CHMAP_UNKNOWN
-#define MA_SND_CHMAP_NA                         SND_CHMAP_NA
-#define MA_SND_CHMAP_MONO                       SND_CHMAP_MONO
-#define MA_SND_CHMAP_FL                         SND_CHMAP_FL
-#define MA_SND_CHMAP_FR                         SND_CHMAP_FR
-#define MA_SND_CHMAP_RL                         SND_CHMAP_RL
-#define MA_SND_CHMAP_RR                         SND_CHMAP_RR
-#define MA_SND_CHMAP_FC                         SND_CHMAP_FC
-#define MA_SND_CHMAP_LFE                        SND_CHMAP_LFE
-#define MA_SND_CHMAP_SL                         SND_CHMAP_SL
-#define MA_SND_CHMAP_SR                         SND_CHMAP_SR
-#define MA_SND_CHMAP_RC                         SND_CHMAP_RC
-#define MA_SND_CHMAP_FLC                        SND_CHMAP_FLC
-#define MA_SND_CHMAP_FRC                        SND_CHMAP_FRC
-#define MA_SND_CHMAP_RLC                        SND_CHMAP_RLC
-#define MA_SND_CHMAP_RRC                        SND_CHMAP_RRC
-#define MA_SND_CHMAP_FLW                        SND_CHMAP_FLW
-#define MA_SND_CHMAP_FRW                        SND_CHMAP_FRW
-#define MA_SND_CHMAP_FLH                        SND_CHMAP_FLH
-#define MA_SND_CHMAP_FCH                        SND_CHMAP_FCH
-#define MA_SND_CHMAP_FRH                        SND_CHMAP_FRH
-#define MA_SND_CHMAP_TC                         SND_CHMAP_TC
-#define MA_SND_CHMAP_TFL                        SND_CHMAP_TFL
-#define MA_SND_CHMAP_TFR                        SND_CHMAP_TFR
-#define MA_SND_CHMAP_TFC                        SND_CHMAP_TFC
-#define MA_SND_CHMAP_TRL                        SND_CHMAP_TRL
-#define MA_SND_CHMAP_TRR                        SND_CHMAP_TRR
-#define MA_SND_CHMAP_TRC                        SND_CHMAP_TRC
-#define MA_SND_CHMAP_TFLC                       SND_CHMAP_TFLC
-#define MA_SND_CHMAP_TFRC                       SND_CHMAP_TFRC
-#define MA_SND_CHMAP_TSL                        SND_CHMAP_TSL
-#define MA_SND_CHMAP_TSR                        SND_CHMAP_TSR
-#define MA_SND_CHMAP_LLFE                       SND_CHMAP_LLFE
-#define MA_SND_CHMAP_RLFE                       SND_CHMAP_RLFE
-#define MA_SND_CHMAP_BC                         SND_CHMAP_BC
-#define MA_SND_CHMAP_BLC                        SND_CHMAP_BLC
-#define MA_SND_CHMAP_BRC                        SND_CHMAP_BRC
-
-/* Open mode flags. */
-#define MA_SND_PCM_NO_AUTO_RESAMPLE             SND_PCM_NO_AUTO_RESAMPLE
-#define MA_SND_PCM_NO_AUTO_CHANNELS             SND_PCM_NO_AUTO_CHANNELS
-#define MA_SND_PCM_NO_AUTO_FORMAT               SND_PCM_NO_AUTO_FORMAT
-#else
-#include <errno.h>  /* For EPIPE, etc. */
-typedef unsigned long                           ma_snd_pcm_uframes_t;
-typedef long                                    ma_snd_pcm_sframes_t;
-typedef int                                     ma_snd_pcm_stream_t;
-typedef int                                     ma_snd_pcm_format_t;
-typedef int                                     ma_snd_pcm_access_t;
-typedef int                                     ma_snd_pcm_state_t;
-typedef struct ma_snd_pcm_t                     ma_snd_pcm_t;
-typedef struct ma_snd_pcm_hw_params_t           ma_snd_pcm_hw_params_t;
-typedef struct ma_snd_pcm_sw_params_t           ma_snd_pcm_sw_params_t;
-typedef struct ma_snd_pcm_format_mask_t         ma_snd_pcm_format_mask_t;
-typedef struct ma_snd_pcm_info_t                ma_snd_pcm_info_t;
-typedef struct
-{
-    void* addr;
-    unsigned int first;
-    unsigned int step;
-} ma_snd_pcm_channel_area_t;
-typedef struct
-{
-    unsigned int channels;
-    unsigned int pos[1];
-} ma_snd_pcm_chmap_t;
-
-/* snd_pcm_state_t */
-#define MA_SND_PCM_STATE_OPEN                  0
-#define MA_SND_PCM_STATE_SETUP                 1
-#define MA_SND_PCM_STATE_PREPARED              2
-#define MA_SND_PCM_STATE_RUNNING               3
-#define MA_SND_PCM_STATE_XRUN                  4
-#define MA_SND_PCM_STATE_DRAINING              5
-#define MA_SND_PCM_STATE_PAUSED                6
-#define MA_SND_PCM_STATE_SUSPENDED             7
-#define MA_SND_PCM_STATE_DISCONNECTED          8
-
-/* snd_pcm_stream_t */
-#define MA_SND_PCM_STREAM_PLAYBACK             0
-#define MA_SND_PCM_STREAM_CAPTURE              1
-
-/* snd_pcm_format_t */
-#define MA_SND_PCM_FORMAT_UNKNOWN              -1
-#define MA_SND_PCM_FORMAT_U8                   1
-#define MA_SND_PCM_FORMAT_S16_LE               2
-#define MA_SND_PCM_FORMAT_S16_BE               3
-#define MA_SND_PCM_FORMAT_S24_LE               6
-#define MA_SND_PCM_FORMAT_S24_BE               7
-#define MA_SND_PCM_FORMAT_S32_LE               10
-#define MA_SND_PCM_FORMAT_S32_BE               11
-#define MA_SND_PCM_FORMAT_FLOAT_LE             14
-#define MA_SND_PCM_FORMAT_FLOAT_BE             15
-#define MA_SND_PCM_FORMAT_FLOAT64_LE           16
-#define MA_SND_PCM_FORMAT_FLOAT64_BE           17
-#define MA_SND_PCM_FORMAT_MU_LAW               20
-#define MA_SND_PCM_FORMAT_A_LAW                21
-#define MA_SND_PCM_FORMAT_S24_3LE              32
-#define MA_SND_PCM_FORMAT_S24_3BE              33
-
-/* snd_pcm_access_t */
-#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED     0
-#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED  1
-#define MA_SND_PCM_ACCESS_MMAP_COMPLEX         2
-#define MA_SND_PCM_ACCESS_RW_INTERLEAVED       3
-#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED    4
-
-/* Channel positions. */
-#define MA_SND_CHMAP_UNKNOWN                   0
-#define MA_SND_CHMAP_NA                        1
-#define MA_SND_CHMAP_MONO                      2
-#define MA_SND_CHMAP_FL                        3
-#define MA_SND_CHMAP_FR                        4
-#define MA_SND_CHMAP_RL                        5
-#define MA_SND_CHMAP_RR                        6
-#define MA_SND_CHMAP_FC                        7
-#define MA_SND_CHMAP_LFE                       8
-#define MA_SND_CHMAP_SL                        9
-#define MA_SND_CHMAP_SR                        10
-#define MA_SND_CHMAP_RC                        11
-#define MA_SND_CHMAP_FLC                       12
-#define MA_SND_CHMAP_FRC                       13
-#define MA_SND_CHMAP_RLC                       14
-#define MA_SND_CHMAP_RRC                       15
-#define MA_SND_CHMAP_FLW                       16
-#define MA_SND_CHMAP_FRW                       17
-#define MA_SND_CHMAP_FLH                       18
-#define MA_SND_CHMAP_FCH                       19
-#define MA_SND_CHMAP_FRH                       20
-#define MA_SND_CHMAP_TC                        21
-#define MA_SND_CHMAP_TFL                       22
-#define MA_SND_CHMAP_TFR                       23
-#define MA_SND_CHMAP_TFC                       24
-#define MA_SND_CHMAP_TRL                       25
-#define MA_SND_CHMAP_TRR                       26
-#define MA_SND_CHMAP_TRC                       27
-#define MA_SND_CHMAP_TFLC                      28
-#define MA_SND_CHMAP_TFRC                      29
-#define MA_SND_CHMAP_TSL                       30
-#define MA_SND_CHMAP_TSR                       31
-#define MA_SND_CHMAP_LLFE                      32
-#define MA_SND_CHMAP_RLFE                      33
-#define MA_SND_CHMAP_BC                        34
-#define MA_SND_CHMAP_BLC                       35
-#define MA_SND_CHMAP_BRC                       36
-
-/* Open mode flags. */
-#define MA_SND_PCM_NO_AUTO_RESAMPLE            0x00010000
-#define MA_SND_PCM_NO_AUTO_CHANNELS            0x00020000
-#define MA_SND_PCM_NO_AUTO_FORMAT              0x00040000
-#endif
-
-typedef int                  (* ma_snd_pcm_open_proc)                          (ma_snd_pcm_t **pcm, const char *name, ma_snd_pcm_stream_t stream, int mode);
-typedef int                  (* ma_snd_pcm_close_proc)                         (ma_snd_pcm_t *pcm);
-typedef size_t               (* ma_snd_pcm_hw_params_sizeof_proc)              (void);
-typedef int                  (* ma_snd_pcm_hw_params_any_proc)                 (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params);
-typedef int                  (* ma_snd_pcm_hw_params_set_format_proc)          (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val);
-typedef int                  (* ma_snd_pcm_hw_params_set_format_first_proc)    (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format);
-typedef void                 (* ma_snd_pcm_hw_params_get_format_mask_proc)     (ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_mask_t *mask);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_proc)        (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_near_proc)   (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_minmax_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *minimum, unsigned int *maximum);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_resample_proc)   (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_proc)            (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_near_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_buffer_size_near_proc)(ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val);
-typedef int                  (* ma_snd_pcm_hw_params_set_periods_near_proc)    (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_access_proc)          (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t _access);
-typedef int                  (* ma_snd_pcm_hw_params_get_format_proc)          (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_min_proc)    (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_max_proc)    (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_proc)            (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_min_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_max_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_buffer_size_proc)     (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_periods_proc)         (const ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_access_proc)          (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t *_access);
-typedef int                  (* ma_snd_pcm_hw_params_test_format_proc)         (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val);
-typedef int                  (* ma_snd_pcm_hw_params_test_channels_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_test_rate_proc)           (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir);
-typedef int                  (* ma_snd_pcm_hw_params_proc)                     (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params);
-typedef size_t               (* ma_snd_pcm_sw_params_sizeof_proc)              (void);
-typedef int                  (* ma_snd_pcm_sw_params_current_proc)             (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params);
-typedef int                  (* ma_snd_pcm_sw_params_get_boundary_proc)        (const ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t* val);
-typedef int                  (* ma_snd_pcm_sw_params_set_avail_min_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_set_start_threshold_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_set_stop_threshold_proc)  (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_proc)                     (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params);
-typedef size_t               (* ma_snd_pcm_format_mask_sizeof_proc)            (void);
-typedef int                  (* ma_snd_pcm_format_mask_test_proc)              (const ma_snd_pcm_format_mask_t *mask, ma_snd_pcm_format_t val);
-typedef ma_snd_pcm_chmap_t * (* ma_snd_pcm_get_chmap_proc)                     (ma_snd_pcm_t *pcm);
-typedef ma_snd_pcm_state_t   (* ma_snd_pcm_state_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_prepare_proc)                       (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_start_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_drop_proc)                          (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_drain_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_device_name_hint_proc)                  (int card, const char *iface, void ***hints);
-typedef char *               (* ma_snd_device_name_get_hint_proc)              (const void *hint, const char *id);
-typedef int                  (* ma_snd_card_get_index_proc)                    (const char *name);
-typedef int                  (* ma_snd_device_name_free_hint_proc)             (void **hints);
-typedef int                  (* ma_snd_pcm_mmap_begin_proc)                    (ma_snd_pcm_t *pcm, const ma_snd_pcm_channel_area_t **areas, ma_snd_pcm_uframes_t *offset, ma_snd_pcm_uframes_t *frames);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_mmap_commit_proc)                   (ma_snd_pcm_t *pcm, ma_snd_pcm_uframes_t offset, ma_snd_pcm_uframes_t frames);
-typedef int                  (* ma_snd_pcm_recover_proc)                       (ma_snd_pcm_t *pcm, int err, int silent);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_readi_proc)                         (ma_snd_pcm_t *pcm, void *buffer, ma_snd_pcm_uframes_t size);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_writei_proc)                        (ma_snd_pcm_t *pcm, const void *buffer, ma_snd_pcm_uframes_t size);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_proc)                         (ma_snd_pcm_t *pcm);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_update_proc)                  (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_wait_proc)                          (ma_snd_pcm_t *pcm, int timeout);
-typedef int                  (* ma_snd_pcm_info_proc)                          (ma_snd_pcm_t *pcm, ma_snd_pcm_info_t* info);
-typedef size_t               (* ma_snd_pcm_info_sizeof_proc)                   (void);
-typedef const char*          (* ma_snd_pcm_info_get_name_proc)                 (const ma_snd_pcm_info_t* info);
-typedef int                  (* ma_snd_config_update_free_global_proc)         (void);
-
-/* This array specifies each of the common devices that can be used for both playback and capture. */
-static const char* g_maCommonDeviceNamesALSA[] = {
-    "default",
-    "null",
-    "pulse",
-    "jack"
-};
-
-/* This array allows us to blacklist specific playback devices. */
-static const char* g_maBlacklistedPlaybackDeviceNamesALSA[] = {
-    ""
-};
-
-/* This array allows us to blacklist specific capture devices. */
-static const char* g_maBlacklistedCaptureDeviceNamesALSA[] = {
-    ""
-};
-
-
-static ma_snd_pcm_format_t ma_convert_ma_format_to_alsa_format(ma_format format)
-{
-    ma_snd_pcm_format_t ALSAFormats[] = {
-        MA_SND_PCM_FORMAT_UNKNOWN,     /* ma_format_unknown */
-        MA_SND_PCM_FORMAT_U8,          /* ma_format_u8 */
-        MA_SND_PCM_FORMAT_S16_LE,      /* ma_format_s16 */
-        MA_SND_PCM_FORMAT_S24_3LE,     /* ma_format_s24 */
-        MA_SND_PCM_FORMAT_S32_LE,      /* ma_format_s32 */
-        MA_SND_PCM_FORMAT_FLOAT_LE     /* ma_format_f32 */
-    };
-
-    if (ma_is_big_endian()) {
-        ALSAFormats[0] = MA_SND_PCM_FORMAT_UNKNOWN;
-        ALSAFormats[1] = MA_SND_PCM_FORMAT_U8;
-        ALSAFormats[2] = MA_SND_PCM_FORMAT_S16_BE;
-        ALSAFormats[3] = MA_SND_PCM_FORMAT_S24_3BE;
-        ALSAFormats[4] = MA_SND_PCM_FORMAT_S32_BE;
-        ALSAFormats[5] = MA_SND_PCM_FORMAT_FLOAT_BE;
-    }
-
-    return ALSAFormats[format];
-}
-
-static ma_format ma_format_from_alsa(ma_snd_pcm_format_t formatALSA)
-{
-    if (ma_is_little_endian()) {
-        switch (formatALSA) {
-            case MA_SND_PCM_FORMAT_S16_LE:   return ma_format_s16;
-            case MA_SND_PCM_FORMAT_S24_3LE:  return ma_format_s24;
-            case MA_SND_PCM_FORMAT_S32_LE:   return ma_format_s32;
-            case MA_SND_PCM_FORMAT_FLOAT_LE: return ma_format_f32;
-            default: break;
-        }
-    } else {
-        switch (formatALSA) {
-            case MA_SND_PCM_FORMAT_S16_BE:   return ma_format_s16;
-            case MA_SND_PCM_FORMAT_S24_3BE:  return ma_format_s24;
-            case MA_SND_PCM_FORMAT_S32_BE:   return ma_format_s32;
-            case MA_SND_PCM_FORMAT_FLOAT_BE: return ma_format_f32;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (formatALSA) {
-        case MA_SND_PCM_FORMAT_U8: return ma_format_u8;
-        default: return ma_format_unknown;
-    }
-}
-
-static ma_channel ma_convert_alsa_channel_position_to_ma_channel(unsigned int alsaChannelPos)
-{
-    switch (alsaChannelPos)
-    {
-        case MA_SND_CHMAP_MONO: return MA_CHANNEL_MONO;
-        case MA_SND_CHMAP_FL:   return MA_CHANNEL_FRONT_LEFT;
-        case MA_SND_CHMAP_FR:   return MA_CHANNEL_FRONT_RIGHT;
-        case MA_SND_CHMAP_RL:   return MA_CHANNEL_BACK_LEFT;
-        case MA_SND_CHMAP_RR:   return MA_CHANNEL_BACK_RIGHT;
-        case MA_SND_CHMAP_FC:   return MA_CHANNEL_FRONT_CENTER;
-        case MA_SND_CHMAP_LFE:  return MA_CHANNEL_LFE;
-        case MA_SND_CHMAP_SL:   return MA_CHANNEL_SIDE_LEFT;
-        case MA_SND_CHMAP_SR:   return MA_CHANNEL_SIDE_RIGHT;
-        case MA_SND_CHMAP_RC:   return MA_CHANNEL_BACK_CENTER;
-        case MA_SND_CHMAP_FLC:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case MA_SND_CHMAP_FRC:  return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case MA_SND_CHMAP_RLC:  return 0;
-        case MA_SND_CHMAP_RRC:  return 0;
-        case MA_SND_CHMAP_FLW:  return 0;
-        case MA_SND_CHMAP_FRW:  return 0;
-        case MA_SND_CHMAP_FLH:  return 0;
-        case MA_SND_CHMAP_FCH:  return 0;
-        case MA_SND_CHMAP_FRH:  return 0;
-        case MA_SND_CHMAP_TC:   return MA_CHANNEL_TOP_CENTER;
-        case MA_SND_CHMAP_TFL:  return MA_CHANNEL_TOP_FRONT_LEFT;
-        case MA_SND_CHMAP_TFR:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case MA_SND_CHMAP_TFC:  return MA_CHANNEL_TOP_FRONT_CENTER;
-        case MA_SND_CHMAP_TRL:  return MA_CHANNEL_TOP_BACK_LEFT;
-        case MA_SND_CHMAP_TRR:  return MA_CHANNEL_TOP_BACK_RIGHT;
-        case MA_SND_CHMAP_TRC:  return MA_CHANNEL_TOP_BACK_CENTER;
-        default: break;
-    }
-
-    return 0;
-}
-
-static ma_bool32 ma_is_common_device_name__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maCommonDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maCommonDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-static ma_bool32 ma_is_playback_device_blacklisted__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maBlacklistedPlaybackDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maBlacklistedPlaybackDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-static ma_bool32 ma_is_capture_device_blacklisted__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maBlacklistedCaptureDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maBlacklistedCaptureDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-static ma_bool32 ma_is_device_blacklisted__alsa(ma_device_type deviceType, const char* name)
-{
-    if (deviceType == ma_device_type_playback) {
-        return ma_is_playback_device_blacklisted__alsa(name);
-    } else {
-        return ma_is_capture_device_blacklisted__alsa(name);
-    }
-}
-
-
-static const char* ma_find_char(const char* str, char c, int* index)
-{
-    int i = 0;
-    for (;;) {
-        if (str[i] == '\0') {
-            if (index) *index = -1;
-            return NULL;
-        }
-
-        if (str[i] == c) {
-            if (index) *index = i;
-            return str + i;
-        }
-
-        i += 1;
-    }
-
-    /* Should never get here, but treat it as though the character was not found to make me feel better inside. */
-    if (index) *index = -1;
-    return NULL;
-}
-
-static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid)
-{
-    /* This function is just checking whether or not hwid is in "hw:%d,%d" format. */
-
-    int commaPos;
-    const char* dev;
-    int i;
-
-    if (hwid == NULL) {
-        return MA_FALSE;
-    }
-
-    if (hwid[0] != 'h' || hwid[1] != 'w' || hwid[2] != ':') {
-        return MA_FALSE;
-    }
-
-    hwid += 3;
-
-    dev = ma_find_char(hwid, ',', &commaPos);
-    if (dev == NULL) {
-        return MA_FALSE;
-    } else {
-        dev += 1;   /* Skip past the ",". */
-    }
-
-    /* Check if the part between the ":" and the "," contains only numbers. If not, return false. */
-    for (i = 0; i < commaPos; ++i) {
-        if (hwid[i] < '0' || hwid[i] > '9') {
-            return MA_FALSE;
-        }
-    }
-
-    /* Check if everything after the "," is numeric. If not, return false. */
-    i = 0;
-    while (dev[i] != '\0') {
-        if (dev[i] < '0' || dev[i] > '9') {
-            return MA_FALSE;
-        }
-        i += 1;
-    }
-
-    return MA_TRUE;
-}
-
-static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* dst, size_t dstSize, const char* src)  /* Returns 0 on success, non-0 on error. */
-{
-    /* src should look something like this: "hw:CARD=I82801AAICH,DEV=0" */
-
-    int colonPos;
-    int commaPos;
-    char card[256];
-    const char* dev;
-    int cardIndex;
-
-    if (dst == NULL) {
-        return -1;
-    }
-    if (dstSize < 7) {
-        return -1;     /* Absolute minimum size of the output buffer is 7 bytes. */
-    }
-
-    *dst = '\0';    /* Safety. */
-    if (src == NULL) {
-        return -1;
-    }
-
-    /* If the input name is already in "hw:%d,%d" format, just return that verbatim. */
-    if (ma_is_device_name_in_hw_format__alsa(src)) {
-        return ma_strcpy_s(dst, dstSize, src);
-    }
-
-    src = ma_find_char(src, ':', &colonPos);
-    if (src == NULL) {
-        return -1;  /* Couldn't find a colon */
-    }
-
-    dev = ma_find_char(src, ',', &commaPos);
-    if (dev == NULL) {
-        dev = "0";
-        ma_strncpy_s(card, sizeof(card), src+6, (size_t)-1);   /* +6 = ":CARD=" */
-    } else {
-        dev = dev + 5;  /* +5 = ",DEV=" */
-        ma_strncpy_s(card, sizeof(card), src+6, commaPos-6);   /* +6 = ":CARD=" */
-    }
-
-    cardIndex = ((ma_snd_card_get_index_proc)pContext->alsa.snd_card_get_index)(card);
-    if (cardIndex < 0) {
-        return -2;  /* Failed to retrieve the card index. */
-    }
-
-    /*printf("TESTING: CARD=%s,DEV=%s\n", card, dev); */
-
-
-    /* Construction. */
-    dst[0] = 'h'; dst[1] = 'w'; dst[2] = ':';
-    if (ma_itoa_s(cardIndex, dst+3, dstSize-3, 10) != 0) {
-        return -3;
-    }
-    if (ma_strcat_s(dst, dstSize, ",") != 0) {
-        return -3;
-    }
-    if (ma_strcat_s(dst, dstSize, dev) != 0) {
-        return -3;
-    }
-
-    return 0;
-}
-
-static ma_bool32 ma_does_id_exist_in_list__alsa(ma_device_id* pUniqueIDs, ma_uint32 count, const char* pHWID)
-{
-    ma_uint32 i;
-
-    MA_ASSERT(pHWID != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (ma_strcmp(pUniqueIDs[i].alsa, pHWID) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode shareMode, ma_device_type deviceType, const ma_device_id* pDeviceID, int openMode, ma_snd_pcm_t** ppPCM)
-{
-    ma_snd_pcm_t* pPCM;
-    ma_snd_pcm_stream_t stream;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppPCM != NULL);
-
-    *ppPCM = NULL;
-    pPCM = NULL;
-
-    stream = (deviceType == ma_device_type_playback) ? MA_SND_PCM_STREAM_PLAYBACK : MA_SND_PCM_STREAM_CAPTURE;
-
-    if (pDeviceID == NULL) {
-        ma_bool32 isDeviceOpen;
-        size_t i;
-
-        /*
-        We're opening the default device. I don't know if trying anything other than "default" is necessary, but it makes
-        me feel better to try as hard as we can get to get _something_ working.
-        */
-        const char* defaultDeviceNames[] = {
-            "default",
-            NULL,
-            NULL,
-            NULL,
-            NULL,
-            NULL,
-            NULL
-        };
-
-        if (shareMode == ma_share_mode_exclusive) {
-            defaultDeviceNames[1] = "hw";
-            defaultDeviceNames[2] = "hw:0";
-            defaultDeviceNames[3] = "hw:0,0";
-        } else {
-            if (deviceType == ma_device_type_playback) {
-                defaultDeviceNames[1] = "dmix";
-                defaultDeviceNames[2] = "dmix:0";
-                defaultDeviceNames[3] = "dmix:0,0";
-            } else {
-                defaultDeviceNames[1] = "dsnoop";
-                defaultDeviceNames[2] = "dsnoop:0";
-                defaultDeviceNames[3] = "dsnoop:0,0";
-            }
-            defaultDeviceNames[4] = "hw";
-            defaultDeviceNames[5] = "hw:0";
-            defaultDeviceNames[6] = "hw:0,0";
-        }
-
-        isDeviceOpen = MA_FALSE;
-        for (i = 0; i < ma_countof(defaultDeviceNames); ++i) {
-            if (defaultDeviceNames[i] != NULL && defaultDeviceNames[i][0] != '\0') {
-                if (((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, defaultDeviceNames[i], stream, openMode) == 0) {
-                    isDeviceOpen = MA_TRUE;
-                    break;
-                }
-            }
-        }
-
-        if (!isDeviceOpen) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed when trying to open an appropriate default device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-    } else {
-        /*
-        We're trying to open a specific device. There's a few things to consider here:
-
-        miniaudio recongnizes a special format of device id that excludes the "hw", "dmix", etc. prefix. It looks like this: ":0,0", ":0,1", etc. When
-        an ID of this format is specified, it indicates to miniaudio that it can try different combinations of plugins ("hw", "dmix", etc.) until it
-        finds an appropriate one that works. This comes in very handy when trying to open a device in shared mode ("dmix"), vs exclusive mode ("hw").
-        */
-
-        /* May end up needing to make small adjustments to the ID, so make a copy. */
-        ma_device_id deviceID = *pDeviceID;
-        int resultALSA = -ENODEV;
-
-        if (deviceID.alsa[0] != ':') {
-            /* The ID is not in ":0,0" format. Use the ID exactly as-is. */
-            resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, deviceID.alsa, stream, openMode);
-        } else {
-            char hwid[256];
-
-            /* The ID is in ":0,0" format. Try different plugins depending on the shared mode. */
-            if (deviceID.alsa[1] == '\0') {
-                deviceID.alsa[0] = '\0';  /* An ID of ":" should be converted to "". */
-            }
-
-            if (shareMode == ma_share_mode_shared) {
-                if (deviceType == ma_device_type_playback) {
-                    ma_strcpy_s(hwid, sizeof(hwid), "dmix");
-                } else {
-                    ma_strcpy_s(hwid, sizeof(hwid), "dsnoop");
-                }
-
-                if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) {
-                    resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode);
-                }
-            }
-
-            /* If at this point we still don't have an open device it means we're either preferencing exclusive mode or opening with "dmix"/"dsnoop" failed. */
-            if (resultALSA != 0) {
-                ma_strcpy_s(hwid, sizeof(hwid), "hw");
-                if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) {
-                    resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode);
-                }
-            }
-        }
-
-        if (resultALSA < 0) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    *ppPCM = pPCM;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    int resultALSA;
-    ma_bool32 cbResult = MA_TRUE;
-    char** ppDeviceHints;
-    ma_device_id* pUniqueIDs = NULL;
-    ma_uint32 uniqueIDCount = 0;
-    char** ppNextDeviceHint;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    ma_mutex_lock(&pContext->alsa.internalDeviceEnumLock);
-
-    resultALSA = ((ma_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints);
-    if (resultALSA < 0) {
-        ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
-        return ma_result_from_errno(-resultALSA);
-    }
-
-    ppNextDeviceHint = ppDeviceHints;
-    while (*ppNextDeviceHint != NULL) {
-        char* NAME = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "NAME");
-        char* DESC = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "DESC");
-        char* IOID = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "IOID");
-        ma_device_type deviceType = ma_device_type_playback;
-        ma_bool32 stopEnumeration = MA_FALSE;
-        char hwid[sizeof(pUniqueIDs->alsa)];
-        ma_device_info deviceInfo;
-
-        if ((IOID == NULL || ma_strcmp(IOID, "Output") == 0)) {
-            deviceType = ma_device_type_playback;
-        }
-        if ((IOID != NULL && ma_strcmp(IOID, "Input" ) == 0)) {
-            deviceType = ma_device_type_capture;
-        }
-
-        if (NAME != NULL) {
-            if (pContext->alsa.useVerboseDeviceEnumeration) {
-                /* Verbose mode. Use the name exactly as-is. */
-                ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1);
-            } else {
-                /* Simplified mode. Use ":%d,%d" format. */
-                if (ma_convert_device_name_to_hw_format__alsa(pContext, hwid, sizeof(hwid), NAME) == 0) {
-                    /*
-                    At this point, hwid looks like "hw:0,0". In simplified enumeration mode, we actually want to strip off the
-                    plugin name so it looks like ":0,0". The reason for this is that this special format is detected at device
-                    initialization time and is used as an indicator to try and use the most appropriate plugin depending on the
-                    device type and sharing mode.
-                    */
-                    char* dst = hwid;
-                    char* src = hwid+2;
-                    while ((*dst++ = *src++));
-                } else {
-                    /* Conversion to "hw:%d,%d" failed. Just use the name as-is. */
-                    ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1);
-                }
-
-                if (ma_does_id_exist_in_list__alsa(pUniqueIDs, uniqueIDCount, hwid)) {
-                    goto next_device;   /* The device has already been enumerated. Move on to the next one. */
-                } else {
-                    /* The device has not yet been enumerated. Make sure it's added to our list so that it's not enumerated again. */
-                    size_t oldCapacity = sizeof(*pUniqueIDs) *  uniqueIDCount;
-                    size_t newCapacity = sizeof(*pUniqueIDs) * (uniqueIDCount + 1);
-                    ma_device_id* pNewUniqueIDs = (ma_device_id*)ma__realloc_from_callbacks(pUniqueIDs, newCapacity, oldCapacity, &pContext->allocationCallbacks);
-                    if (pNewUniqueIDs == NULL) {
-                        goto next_device;   /* Failed to allocate memory. */
-                    }
-
-                    pUniqueIDs = pNewUniqueIDs;
-                    MA_COPY_MEMORY(pUniqueIDs[uniqueIDCount].alsa, hwid, sizeof(hwid));
-                    uniqueIDCount += 1;
-                }
-            }
-        } else {
-            MA_ZERO_MEMORY(hwid, sizeof(hwid));
-        }
-
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
-
-        /*
-        There's no good way to determine whether or not a device is the default on Linux. We're just going to do something simple and
-        just use the name of "default" as the indicator.
-        */
-        if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) {
-            deviceInfo.isDefault = MA_TRUE;
-        }
-
-
-        /*
-        DESC is the friendly name. We treat this slightly differently depending on whether or not we are using verbose
-        device enumeration. In verbose mode we want to take the entire description so that the end-user can distinguish
-        between the subdevices of each card/dev pair. In simplified mode, however, we only want the first part of the
-        description.
-
-        The value in DESC seems to be split into two lines, with the first line being the name of the device and the
-        second line being a description of the device. I don't like having the description be across two lines because
-        it makes formatting ugly and annoying. I'm therefore deciding to put it all on a single line with the second line
-        being put into parentheses. In simplified mode I'm just stripping the second line entirely.
-        */
-        if (DESC != NULL) {
-            int lfPos;
-            const char* line2 = ma_find_char(DESC, '\n', &lfPos);
-            if (line2 != NULL) {
-                line2 += 1; /* Skip past the new-line character. */
-
-                if (pContext->alsa.useVerboseDeviceEnumeration) {
-                    /* Verbose mode. Put the second line in brackets. */
-                    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos);
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), " (");
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), line2);
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), ")");
-                } else {
-                    /* Simplified mode. Strip the second line entirely. */
-                    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos);
-                }
-            } else {
-                /* There's no second line. Just copy the whole description. */
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, (size_t)-1);
-            }
-        }
-
-        if (!ma_is_device_blacklisted__alsa(deviceType, NAME)) {
-            cbResult = callback(pContext, deviceType, &deviceInfo, pUserData);
-        }
-
-        /*
-        Some devices are both playback and capture, but they are only enumerated by ALSA once. We need to fire the callback
-        again for the other device type in this case. We do this for known devices.
-        */
-        if (cbResult) {
-            if (ma_is_common_device_name__alsa(NAME)) {
-                if (deviceType == ma_device_type_playback) {
-                    if (!ma_is_capture_device_blacklisted__alsa(NAME)) {
-                        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                    }
-                } else {
-                    if (!ma_is_playback_device_blacklisted__alsa(NAME)) {
-                        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                    }
-                }
-            }
-        }
-
-        if (cbResult == MA_FALSE) {
-            stopEnumeration = MA_TRUE;
-        }
-
-    next_device:
-        free(NAME);
-        free(DESC);
-        free(IOID);
-        ppNextDeviceHint += 1;
-
-        /* We need to stop enumeration if the callback returned false. */
-        if (stopEnumeration) {
-            break;
-        }
-    }
-
-    ma__free_from_callbacks(pUniqueIDs, &pContext->allocationCallbacks);
-    ((ma_snd_device_name_free_hint_proc)pContext->alsa.snd_device_name_free_hint)((void**)ppDeviceHints);
-
-    ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_device_type deviceType;
-    const ma_device_id* pDeviceID;
-    ma_share_mode shareMode;
-    ma_device_info* pDeviceInfo;
-    ma_bool32 foundDevice;
-} ma_context_get_device_info_enum_callback_data__alsa;
-
-static ma_bool32 ma_context_get_device_info_enum_callback__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pDeviceInfo, void* pUserData)
-{
-    ma_context_get_device_info_enum_callback_data__alsa* pData = (ma_context_get_device_info_enum_callback_data__alsa*)pUserData;
-    MA_ASSERT(pData != NULL);
-
-    (void)pContext;
-
-    if (pData->pDeviceID == NULL && ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1);
-        pData->foundDevice = MA_TRUE;
-    } else {
-        if (pData->deviceType == deviceType && (pData->pDeviceID != NULL && ma_strcmp(pData->pDeviceID->alsa, pDeviceInfo->id.alsa) == 0)) {
-            ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1);
-            pData->foundDevice = MA_TRUE;
-        }
-    }
-
-    /* Keep enumerating until we have found the device. */
-    return !pData->foundDevice;
-}
-
-static void ma_context_test_rate_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pPCM        != NULL);
-    MA_ASSERT(pHWParams   != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats) && ((ma_snd_pcm_hw_params_test_rate_proc)pContext->alsa.snd_pcm_hw_params_test_rate)(pPCM, pHWParams, sampleRate, 0) == 0) {
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-        pDeviceInfo->nativeDataFormatCount += 1;
-    }
-}
-
-static void ma_context_iterate_rates_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    ma_uint32 iSampleRate;
-    unsigned int minSampleRate;
-    unsigned int maxSampleRate;
-    int sampleRateDir;  /* Not used. Just passed into snd_pcm_hw_params_get_rate_min/max(). */
-
-    /* There could be a range. */
-    ((ma_snd_pcm_hw_params_get_rate_min_proc)pContext->alsa.snd_pcm_hw_params_get_rate_min)(pHWParams, &minSampleRate, &sampleRateDir);
-    ((ma_snd_pcm_hw_params_get_rate_max_proc)pContext->alsa.snd_pcm_hw_params_get_rate_max)(pHWParams, &maxSampleRate, &sampleRateDir);
-
-    /* Make sure our sample rates are clamped to sane values. Stupid devices like "pulse" will reports rates like "1" which is ridiculus. */
-    minSampleRate = ma_clamp(minSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max);
-    maxSampleRate = ma_clamp(maxSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max);
-
-    for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) {
-        ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate];
-
-        if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) {
-            ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, standardSampleRate, flags, pDeviceInfo);
-        }
-    }
-
-    /* Now make sure our min and max rates are included just in case they aren't in the range of our standard rates. */
-    if (!ma_is_standard_sample_rate(minSampleRate)) {
-        ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, minSampleRate, flags, pDeviceInfo);
-    }
-
-    if (!ma_is_standard_sample_rate(maxSampleRate) && maxSampleRate != minSampleRate) {
-        ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, maxSampleRate, flags, pDeviceInfo);
-    }
-}
-
-static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_context_get_device_info_enum_callback_data__alsa data;
-    ma_result result;
-    int resultALSA;
-    ma_snd_pcm_t* pPCM;
-    ma_snd_pcm_hw_params_t* pHWParams;
-    ma_uint32 iFormat;
-    ma_uint32 iChannel;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* We just enumerate to find basic information about the device. */
-    data.deviceType  = deviceType;
-    data.pDeviceID   = pDeviceID;
-    data.pDeviceInfo = pDeviceInfo;
-    data.foundDevice = MA_FALSE;
-    result = ma_context_enumerate_devices__alsa(pContext, ma_context_get_device_info_enum_callback__alsa, &data);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (!data.foundDevice) {
-        return MA_NO_DEVICE;
-    }
-
-    if (ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) {
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    /* For detailed info we need to open the device. */
-    result = ma_context_open_pcm__alsa(pContext, ma_share_mode_shared, deviceType, pDeviceID, 0, &pPCM);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* We need to initialize a HW parameters object in order to know what formats are supported. */
-    pHWParams = (ma_snd_pcm_hw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_hw_params_sizeof_proc)pContext->alsa.snd_pcm_hw_params_sizeof)(), &pContext->allocationCallbacks);
-    if (pHWParams == NULL) {
-        ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    /*
-    Some ALSA devices can support many permutations of formats, channels and rates. We only support
-    a fixed number of permutations which means we need to employ some strategies to ensure the best
-    combinations are returned. An example is the "pulse" device which can do it's own data conversion
-    in software and as a result can support any combination of format, channels and rate.
-
-    We want to ensure the the first data formats are the best. We have a list of favored sample
-    formats and sample rates, so these will be the basis of our iteration.
-    */
-    
-    /* Formats. We just iterate over our standard formats and test them, making sure we reset the configuration space each iteration. */
-    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) {
-        ma_format format = g_maFormatPriorities[iFormat];
-
-        /*
-        For each format we need to make sure we reset the configuration space so we don't return
-        channel counts and rates that aren't compatible with a format.
-        */
-        ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-
-        /* Test the format first. If this fails it means the format is not supported and we can skip it. */
-        if (((ma_snd_pcm_hw_params_test_format_proc)pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format)) == 0) {
-            /* The format is supported. */
-            unsigned int minChannels;
-            unsigned int maxChannels;
-
-            /*
-            The configuration space needs to be restricted to this format so we can get an accurate
-            picture of which sample rates and channel counts are support with this format.
-            */
-            ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format));
-
-            /* Now we need to check for supported channels. */
-            ((ma_snd_pcm_hw_params_get_channels_min_proc)pContext->alsa.snd_pcm_hw_params_get_channels_min)(pHWParams, &minChannels);
-            ((ma_snd_pcm_hw_params_get_channels_max_proc)pContext->alsa.snd_pcm_hw_params_get_channels_max)(pHWParams, &maxChannels);
-
-            if (minChannels > MA_MAX_CHANNELS) {
-                continue;   /* Too many channels. */
-            }
-            if (maxChannels < MA_MIN_CHANNELS) {
-                continue;   /* Not enough channels. */
-            }
-
-            /*
-            Make sure the channel count is clamped. This is mainly intended for the max channels
-            because some devices can report an unbound maximum.
-            */
-            minChannels = ma_clamp(minChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-            maxChannels = ma_clamp(maxChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-
-            if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                /* The device supports all channels. Don't iterate over every single one. Instead just set the channels to 0 which means all channels are supported. */
-                ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, 0, 0, pDeviceInfo);    /* Intentionally setting the channel count to 0 as that means all channels are supported. */
-            } else {
-                /* The device only supports a specific set of channels. We need to iterate over all of them. */
-                for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                    /* Test the channel before applying it to the configuration space. */
-                    unsigned int channels = iChannel;
-
-                    /* Make sure our channel range is reset before testing again or else we'll always fail the test. */
-                    ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-                    ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format));
-
-                    if (((ma_snd_pcm_hw_params_test_channels_proc)pContext->alsa.snd_pcm_hw_params_test_channels)(pPCM, pHWParams, channels) == 0) {
-                        /* The channel count is supported. */
-
-                        /* The configuration space now needs to be restricted to the channel count before extracting the sample rate. */
-                        ((ma_snd_pcm_hw_params_set_channels_proc)pContext->alsa.snd_pcm_hw_params_set_channels)(pPCM, pHWParams, channels);
-
-                        /* Only after the configuration space has been restricted to the specific channel count should we iterate over our sample rates. */
-                        ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, 0, pDeviceInfo);
-                    } else {
-                        /* The channel count is not supported. Skip. */
-                    }
-                }
-            }
-        } else {
-            /* The format is not supported. Skip. */
-        }
-    }
-
-    ma__free_from_callbacks(pHWParams, &pContext->allocationCallbacks);
-
-    ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__alsa(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if ((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-    }
-
-    if ((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    ma_result result;
-    int resultALSA;
-    ma_snd_pcm_t* pPCM;
-    ma_bool32 isUsingMMap;
-    ma_snd_pcm_format_t formatALSA;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_channel internalChannelMap[MA_MAX_CHANNELS];
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-    int openMode;
-    ma_snd_pcm_hw_params_t* pHWParams;
-    ma_snd_pcm_sw_params_t* pSWParams;
-    ma_snd_pcm_uframes_t bufferBoundary;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should only be called for playback _or_ capture, never duplex. */
-    MA_ASSERT(pDevice != NULL);
-
-    formatALSA = ma_convert_ma_format_to_alsa_format(pDescriptor->format);
-
-    openMode = 0;
-    if (pConfig->alsa.noAutoResample) {
-        openMode |= MA_SND_PCM_NO_AUTO_RESAMPLE;
-    }
-    if (pConfig->alsa.noAutoChannels) {
-        openMode |= MA_SND_PCM_NO_AUTO_CHANNELS;
-    }
-    if (pConfig->alsa.noAutoFormat) {
-        openMode |= MA_SND_PCM_NO_AUTO_FORMAT;
-    }
-
-    result = ma_context_open_pcm__alsa(pDevice->pContext, pDescriptor->shareMode, deviceType, pDescriptor->pDeviceID, openMode, &pPCM);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-
-    /* Hardware parameters. */
-    pHWParams = (ma_snd_pcm_hw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_hw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_hw_params_sizeof)(), &pDevice->pContext->allocationCallbacks);
-    if (pHWParams == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_hw_params_any_proc)pDevice->pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    /* MMAP Mode. Try using interleaved MMAP access. If this fails, fall back to standard readi/writei. */
-    isUsingMMap = MA_FALSE;
-#if 0   /* NOTE: MMAP mode temporarily disabled. */
-    if (deviceType != ma_device_type_capture) {    /* <-- Disabling MMAP mode for capture devices because I apparently do not have a device that supports it which means I can't test it... Contributions welcome. */
-        if (!pConfig->alsa.noMMap && ma_device__is_async(pDevice)) {
-            if (((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) {
-                pDevice->alsa.isUsingMMap = MA_TRUE;
-            }
-        }
-    }
-#endif
-
-    if (!isUsingMMap) {
-        resultALSA = ((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_RW_INTERLEAVED);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    /*
-    Most important properties first. The documentation for OSS (yes, I know this is ALSA!) recommends format, channels, then sample rate. I can't
-    find any documentation for ALSA specifically, so I'm going to copy the recommendation for OSS.
-    */
-
-    /* Format. */
-    {
-        /*
-        At this point we should have a list of supported formats, so now we need to find the best one. We first check if the requested format is
-        supported, and if so, use that one. If it's not supported, we just run though a list of formats and try to find the best one.
-        */
-        if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN || ((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, formatALSA) != 0) {
-            /* We're either requesting the native format or the specified format is not supported. */
-            size_t iFormat;
-
-            formatALSA = MA_SND_PCM_FORMAT_UNKNOWN;
-            for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) {
-                if (((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat])) == 0) {
-                    formatALSA = ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat]);
-                    break;
-                }
-            }
-
-            if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN) {
-                ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-                ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. The device does not support any miniaudio formats.", MA_FORMAT_NOT_SUPPORTED);
-            }
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, formatALSA);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. snd_pcm_hw_params_set_format() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalFormat = ma_format_from_alsa(formatALSA);
-        if (internalFormat == ma_format_unknown) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] The chosen format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED);
-        }
-    }
-
-    /* Channels. */
-    {
-        unsigned int channels = pDescriptor->channels;
-        if (channels == 0) {
-            channels = MA_DEFAULT_CHANNELS;
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_channels_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_channels_near)(pPCM, pHWParams, &channels);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set channel count. snd_pcm_hw_params_set_channels_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalChannels = (ma_uint32)channels;
-    }
-
-    /* Sample Rate */
-    {
-        unsigned int sampleRate;
-
-        /*
-        It appears there's either a bug in ALSA, a bug in some drivers, or I'm doing something silly; but having resampling enabled causes
-        problems with some device configurations when used in conjunction with MMAP access mode. To fix this problem we need to disable
-        resampling.
-
-        To reproduce this problem, open the "plug:dmix" device, and set the sample rate to 44100. Internally, it looks like dmix uses a
-        sample rate of 48000. The hardware parameters will get set correctly with no errors, but it looks like the 44100 -> 48000 resampling
-        doesn't work properly - but only with MMAP access mode. You will notice skipping/crackling in the audio, and it'll run at a slightly
-        faster rate.
-
-        miniaudio has built-in support for sample rate conversion (albeit low quality at the moment), so disabling resampling should be fine
-        for us. The only problem is that it won't be taking advantage of any kind of hardware-accelerated resampling and it won't be very
-        good quality until I get a chance to improve the quality of miniaudio's software sample rate conversion.
-
-        I don't currently know if the dmix plugin is the only one with this error. Indeed, this is the only one I've been able to reproduce
-        this error with. In the future, we may want to restrict the disabling of resampling to only known bad plugins.
-        */
-        ((ma_snd_pcm_hw_params_set_rate_resample_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_resample)(pPCM, pHWParams, 0);
-
-        sampleRate = pDescriptor->sampleRate;
-        if (sampleRate == 0) {
-            sampleRate = MA_DEFAULT_SAMPLE_RATE;
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_rate_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_near)(pPCM, pHWParams, &sampleRate, 0);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Sample rate not supported. snd_pcm_hw_params_set_rate_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalSampleRate = (ma_uint32)sampleRate;
-    }
-
-    /* Periods. */
-    {
-        ma_uint32 periods = pDescriptor->periodCount;
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_periods_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, NULL);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set period count. snd_pcm_hw_params_set_periods_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalPeriods = periods;
-    }
-
-    /* Buffer Size */
-    {
-        ma_snd_pcm_uframes_t actualBufferSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile) * internalPeriods;
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_buffer_size_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_buffer_size_near)(pPCM, pHWParams, &actualBufferSizeInFrames);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set buffer size for device. snd_pcm_hw_params_set_buffer_size() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalPeriodSizeInFrames = actualBufferSizeInFrames / internalPeriods;
-    }
-
-    /* Apply hardware parameters. */
-    resultALSA = ((ma_snd_pcm_hw_params_proc)pDevice->pContext->alsa.snd_pcm_hw_params)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-    pHWParams = NULL;
-
-
-    /* Software parameters. */
-    pSWParams = (ma_snd_pcm_sw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_sw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_sw_params_sizeof)(), &pDevice->pContext->allocationCallbacks);
-    if (pSWParams == NULL) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_current_proc)pDevice->pContext->alsa.snd_pcm_sw_params_current)(pPCM, pSWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize software parameters. snd_pcm_sw_params_current() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_set_avail_min_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_avail_min)(pPCM, pSWParams, ma_prev_power_of_2(internalPeriodSizeInFrames));
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_get_boundary_proc)pDevice->pContext->alsa.snd_pcm_sw_params_get_boundary)(pSWParams, &bufferBoundary);
-    if (resultALSA < 0) {
-        bufferBoundary = internalPeriodSizeInFrames * internalPeriods;
-    }
-
-    /*printf("TRACE: bufferBoundary=%ld\n", bufferBoundary);*/
-
-    if (deviceType == ma_device_type_playback && !isUsingMMap) {   /* Only playback devices in writei/readi mode need a start threshold. */
-        /*
-        Subtle detail here with the start threshold. When in playback-only mode (no full-duplex) we can set the start threshold to
-        the size of a period. But for full-duplex we need to set it such that it is at least two periods.
-        */
-        resultALSA = ((ma_snd_pcm_sw_params_set_start_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_start_threshold)(pPCM, pSWParams, internalPeriodSizeInFrames*2);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        resultALSA = ((ma_snd_pcm_sw_params_set_stop_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_stop_threshold)(pPCM, pSWParams, bufferBoundary);
-        if (resultALSA < 0) { /* Set to boundary to loop instead of stop in the event of an xrun. */
-            ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set stop threshold for playback device. snd_pcm_sw_params_set_stop_threshold() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_proc)pDevice->pContext->alsa.snd_pcm_sw_params)(pPCM, pSWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-    pSWParams = NULL;
-
-
-    /* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */
-    {
-        ma_snd_pcm_chmap_t* pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM);
-        if (pChmap != NULL) {
-            ma_uint32 iChannel;
-
-            /* There are cases where the returned channel map can have a different channel count than was returned by snd_pcm_hw_params_set_channels_near(). */
-            if (pChmap->channels >= internalChannels) {
-                /* Drop excess channels. */
-                for (iChannel = 0; iChannel < internalChannels; ++iChannel) {
-                    internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]);
-                }
-            } else {
-                ma_uint32 i;
-
-                /*
-                Excess channels use defaults. Do an initial fill with defaults, overwrite the first pChmap->channels, validate to ensure there are no duplicate
-                channels. If validation fails, fall back to defaults.
-                */
-                ma_bool32 isValid = MA_TRUE;
-
-                /* Fill with defaults. */
-                ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-
-                /* Overwrite first pChmap->channels channels. */
-                for (iChannel = 0; iChannel < pChmap->channels; ++iChannel) {
-                    internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]);
-                }
-
-                /* Validate. */
-                for (i = 0; i < internalChannels && isValid; ++i) {
-                    ma_uint32 j;
-                    for (j = i+1; j < internalChannels; ++j) {
-                        if (internalChannelMap[i] == internalChannelMap[j]) {
-                            isValid = MA_FALSE;
-                            break;
-                        }
-                    }
-                }
-
-                /* If our channel map is invalid, fall back to defaults. */
-                if (!isValid) {
-                    ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-                }
-            }
-
-            free(pChmap);
-            pChmap = NULL;
-        } else {
-            /* Could not retrieve the channel map. Fall back to a hard-coded assumption. */
-            ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-        }
-    }
-
-
-    /* We're done. Prepare the device. */
-    resultALSA = ((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)(pPCM);
-    if (resultALSA < 0) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", ma_result_from_errno(-resultALSA));
-    }
-
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->alsa.pPCMCapture         = (ma_ptr)pPCM;
-        pDevice->alsa.isUsingMMapCapture  = isUsingMMap;
-    } else {
-        pDevice->alsa.pPCMPlayback        = (ma_ptr)pPCM;
-        pDevice->alsa.isUsingMMapPlayback = isUsingMMap;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_channel_map_copy(pDescriptor->channelMap, internalChannelMap, ma_min(internalChannels, MA_MAX_CHANNELS));
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-    /*printf("format=%d; channels=%d; sampleRate=%d; periodSizeInFrames=%d; periodCount=%d\n", internalFormat, internalChannels, internalSampleRate, internalPeriodSizeInFrames, internalPeriods);*/
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->alsa);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__alsa(ma_device* pDevice)
-{
-    int resultALSA;
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-        if (resultALSA < 0) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Don't need to do anything for playback because it'll be started automatically when enough data has been written. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__alsa(ma_device* pDevice)
-{
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_snd_pcm_drain_proc)pDevice->pContext->alsa.snd_pcm_drain)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-
-        /* We need to prepare the device again, otherwise we won't be able to restart the device. */
-        if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) < 0) {
-    #ifdef MA_DEBUG_OUTPUT
-            printf("[ALSA] Failed to prepare capture device after stopping.\n");
-    #endif
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_snd_pcm_drain_proc)pDevice->pContext->alsa.snd_pcm_drain)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-
-        /* We need to prepare the device again, otherwise we won't be able to restart the device. */
-        if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) < 0) {
-    #ifdef MA_DEBUG_OUTPUT
-            printf("[ALSA] Failed to prepare playback device after stopping.\n");
-    #endif
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_snd_pcm_sframes_t resultALSA;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    for (;;) {
-        resultALSA = ((ma_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, pFramesOut, frameCount);
-        if (resultALSA >= 0) {
-            break;  /* Success. */
-        } else {
-            if (resultALSA == -EAGAIN) {
-                /*printf("TRACE: EGAIN (read)\n");*/
-                continue;   /* Try again. */
-            } else if (resultALSA == -EPIPE) {
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("TRACE: EPIPE (read)\n");
-            #endif
-
-                /* Overrun. Recover and try again. If this fails we need to return an error. */
-                resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, resultALSA, MA_TRUE);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, pFramesOut, frameCount);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", ma_result_from_errno((int)-resultALSA));
-                }
-            }
-        }
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = resultALSA;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_snd_pcm_sframes_t resultALSA;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFrames != NULL);
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    for (;;) {
-        resultALSA = ((ma_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pFrames, frameCount);
-        if (resultALSA >= 0) {
-            break;  /* Success. */
-        } else {
-            if (resultALSA == -EAGAIN) {
-                /*printf("TRACE: EGAIN (write)\n");*/
-                continue;   /* Try again. */
-            } else if (resultALSA == -EPIPE) {
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("TRACE: EPIPE (write)\n");
-            #endif
-
-                /* Underrun. Recover and try again. If this fails we need to return an error. */
-                resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, resultALSA, MA_TRUE);
-                if (resultALSA < 0) { /* MA_TRUE=silent (don't print anything on error). */
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                /*
-                In my testing I have had a situation where writei() does not automatically restart the device even though I've set it
-                up as such in the software parameters. What will happen is writei() will block indefinitely even though the number of
-                frames is well beyond the auto-start threshold. To work around this I've needed to add an explicit start here. Not sure
-                if this is me just being stupid and not recovering the device properly, but this definitely feels like something isn't
-                quite right here.
-                */
-                resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pFrames, frameCount);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-            }
-        }
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = resultALSA;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__alsa(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_alsa);
-
-    /* Clean up memory for memory leak checkers. */
-    ((ma_snd_config_update_free_global_proc)pContext->alsa.snd_config_update_free_global)();
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->alsa.asoundSO);
-#endif
-
-    ma_mutex_uninit(&pContext->alsa.internalDeviceEnumLock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__alsa(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libasoundNames[] = {
-        "libasound.so.2",
-        "libasound.so"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libasoundNames); ++i) {
-        pContext->alsa.asoundSO = ma_dlopen(pContext, libasoundNames[i]);
-        if (pContext->alsa.asoundSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->alsa.asoundSO == NULL) {
-#ifdef MA_DEBUG_OUTPUT
-        printf("[ALSA] Failed to open shared object.\n");
-#endif
-        return MA_NO_BACKEND;
-    }
-
-    pContext->alsa.snd_pcm_open                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_open");
-    pContext->alsa.snd_pcm_close                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_close");
-    pContext->alsa.snd_pcm_hw_params_sizeof               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_sizeof");
-    pContext->alsa.snd_pcm_hw_params_any                  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_any");
-    pContext->alsa.snd_pcm_hw_params_set_format           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format");
-    pContext->alsa.snd_pcm_hw_params_set_format_first     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format_first");
-    pContext->alsa.snd_pcm_hw_params_get_format_mask      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format_mask");
-    pContext->alsa.snd_pcm_hw_params_set_channels         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels");
-    pContext->alsa.snd_pcm_hw_params_set_channels_near    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_near");
-    pContext->alsa.snd_pcm_hw_params_set_channels_minmax  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_minmax");
-    pContext->alsa.snd_pcm_hw_params_set_rate_resample    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_resample");
-    pContext->alsa.snd_pcm_hw_params_set_rate             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate");
-    pContext->alsa.snd_pcm_hw_params_set_rate_near        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_near");
-    pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_buffer_size_near");
-    pContext->alsa.snd_pcm_hw_params_set_periods_near     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_periods_near");
-    pContext->alsa.snd_pcm_hw_params_set_access           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_access");
-    pContext->alsa.snd_pcm_hw_params_get_format           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format");
-    pContext->alsa.snd_pcm_hw_params_get_channels         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels");
-    pContext->alsa.snd_pcm_hw_params_get_channels_min     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_min");
-    pContext->alsa.snd_pcm_hw_params_get_channels_max     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_max");
-    pContext->alsa.snd_pcm_hw_params_get_rate             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate");
-    pContext->alsa.snd_pcm_hw_params_get_rate_min         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_min");
-    pContext->alsa.snd_pcm_hw_params_get_rate_max         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_max");
-    pContext->alsa.snd_pcm_hw_params_get_buffer_size      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_buffer_size");
-    pContext->alsa.snd_pcm_hw_params_get_periods          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_periods");
-    pContext->alsa.snd_pcm_hw_params_get_access           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_access");
-    pContext->alsa.snd_pcm_hw_params_test_format          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_format");
-    pContext->alsa.snd_pcm_hw_params_test_channels        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_channels");
-    pContext->alsa.snd_pcm_hw_params_test_rate            = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_rate");
-    pContext->alsa.snd_pcm_hw_params                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params");
-    pContext->alsa.snd_pcm_sw_params_sizeof               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_sizeof");
-    pContext->alsa.snd_pcm_sw_params_current              = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_current");
-    pContext->alsa.snd_pcm_sw_params_get_boundary         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_get_boundary");
-    pContext->alsa.snd_pcm_sw_params_set_avail_min        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_avail_min");
-    pContext->alsa.snd_pcm_sw_params_set_start_threshold  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_start_threshold");
-    pContext->alsa.snd_pcm_sw_params_set_stop_threshold   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_stop_threshold");
-    pContext->alsa.snd_pcm_sw_params                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params");
-    pContext->alsa.snd_pcm_format_mask_sizeof             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_format_mask_sizeof");
-    pContext->alsa.snd_pcm_format_mask_test               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_format_mask_test");
-    pContext->alsa.snd_pcm_get_chmap                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_get_chmap");
-    pContext->alsa.snd_pcm_state                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_state");
-    pContext->alsa.snd_pcm_prepare                        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_prepare");
-    pContext->alsa.snd_pcm_start                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_start");
-    pContext->alsa.snd_pcm_drop                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_drop");
-    pContext->alsa.snd_pcm_drain                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_drain");
-    pContext->alsa.snd_device_name_hint                   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_hint");
-    pContext->alsa.snd_device_name_get_hint               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_get_hint");
-    pContext->alsa.snd_card_get_index                     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_card_get_index");
-    pContext->alsa.snd_device_name_free_hint              = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_free_hint");
-    pContext->alsa.snd_pcm_mmap_begin                     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_mmap_begin");
-    pContext->alsa.snd_pcm_mmap_commit                    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_mmap_commit");
-    pContext->alsa.snd_pcm_recover                        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_recover");
-    pContext->alsa.snd_pcm_readi                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_readi");
-    pContext->alsa.snd_pcm_writei                         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_writei");
-    pContext->alsa.snd_pcm_avail                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_avail");
-    pContext->alsa.snd_pcm_avail_update                   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_avail_update");
-    pContext->alsa.snd_pcm_wait                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_wait");
-    pContext->alsa.snd_pcm_info                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info");
-    pContext->alsa.snd_pcm_info_sizeof                    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info_sizeof");
-    pContext->alsa.snd_pcm_info_get_name                  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info_get_name");
-    pContext->alsa.snd_config_update_free_global          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_config_update_free_global");
-#else
-    /* The system below is just for type safety. */
-    ma_snd_pcm_open_proc                           _snd_pcm_open                           = snd_pcm_open;
-    ma_snd_pcm_close_proc                          _snd_pcm_close                          = snd_pcm_close;
-    ma_snd_pcm_hw_params_sizeof_proc               _snd_pcm_hw_params_sizeof               = snd_pcm_hw_params_sizeof;
-    ma_snd_pcm_hw_params_any_proc                  _snd_pcm_hw_params_any                  = snd_pcm_hw_params_any;
-    ma_snd_pcm_hw_params_set_format_proc           _snd_pcm_hw_params_set_format           = snd_pcm_hw_params_set_format;
-    ma_snd_pcm_hw_params_set_format_first_proc     _snd_pcm_hw_params_set_format_first     = snd_pcm_hw_params_set_format_first;
-    ma_snd_pcm_hw_params_get_format_mask_proc      _snd_pcm_hw_params_get_format_mask      = snd_pcm_hw_params_get_format_mask;
-    ma_snd_pcm_hw_params_set_channels_proc         _snd_pcm_hw_params_set_channels         = snd_pcm_hw_params_set_channels;
-    ma_snd_pcm_hw_params_set_channels_near_proc    _snd_pcm_hw_params_set_channels_near    = snd_pcm_hw_params_set_channels_near;
-    ma_snd_pcm_hw_params_set_rate_resample_proc    _snd_pcm_hw_params_set_rate_resample    = snd_pcm_hw_params_set_rate_resample;
-    ma_snd_pcm_hw_params_set_rate_near             _snd_pcm_hw_params_set_rate             = snd_pcm_hw_params_set_rate;
-    ma_snd_pcm_hw_params_set_rate_near_proc        _snd_pcm_hw_params_set_rate_near        = snd_pcm_hw_params_set_rate_near;
-    ma_snd_pcm_hw_params_set_rate_minmax_proc      _snd_pcm_hw_params_set_rate_minmax      = snd_pcm_hw_params_set_rate_minmax;
-    ma_snd_pcm_hw_params_set_buffer_size_near_proc _snd_pcm_hw_params_set_buffer_size_near = snd_pcm_hw_params_set_buffer_size_near;
-    ma_snd_pcm_hw_params_set_periods_near_proc     _snd_pcm_hw_params_set_periods_near     = snd_pcm_hw_params_set_periods_near;
-    ma_snd_pcm_hw_params_set_access_proc           _snd_pcm_hw_params_set_access           = snd_pcm_hw_params_set_access;
-    ma_snd_pcm_hw_params_get_format_proc           _snd_pcm_hw_params_get_format           = snd_pcm_hw_params_get_format;
-    ma_snd_pcm_hw_params_get_channels_proc         _snd_pcm_hw_params_get_channels         = snd_pcm_hw_params_get_channels;
-    ma_snd_pcm_hw_params_get_channels_min_proc     _snd_pcm_hw_params_get_channels_min     = snd_pcm_hw_params_get_channels_min;
-    ma_snd_pcm_hw_params_get_channels_max_proc     _snd_pcm_hw_params_get_channels_max     = snd_pcm_hw_params_get_channels_max;
-    ma_snd_pcm_hw_params_get_rate_proc             _snd_pcm_hw_params_get_rate             = snd_pcm_hw_params_get_rate;
-    ma_snd_pcm_hw_params_get_rate_min_proc         _snd_pcm_hw_params_get_rate_min         = snd_pcm_hw_params_get_rate_min;
-    ma_snd_pcm_hw_params_get_rate_max_proc         _snd_pcm_hw_params_get_rate_max         = snd_pcm_hw_params_get_rate_max;
-    ma_snd_pcm_hw_params_get_buffer_size_proc      _snd_pcm_hw_params_get_buffer_size      = snd_pcm_hw_params_get_buffer_size;
-    ma_snd_pcm_hw_params_get_periods_proc          _snd_pcm_hw_params_get_periods          = snd_pcm_hw_params_get_periods;
-    ma_snd_pcm_hw_params_get_access_proc           _snd_pcm_hw_params_get_access           = snd_pcm_hw_params_get_access;
-    ma_snd_pcm_hw_params_test_format_proc          _snd_pcm_hw_params_test_format          = snd_pcm_hw_params_test_format;
-    ma_snd_pcm_hw_params_test_channels_proc        _snd_pcm_hw_params_test_channels        = snd_pcm_hw_params_test_channels;
-    ma_snd_pcm_hw_params_test_rate_proc            _snd_pcm_hw_params_test_rate            = snd_pcm_hw_params_test_rate;
-    ma_snd_pcm_hw_params_proc                      _snd_pcm_hw_params                      = snd_pcm_hw_params;
-    ma_snd_pcm_sw_params_sizeof_proc               _snd_pcm_sw_params_sizeof               = snd_pcm_sw_params_sizeof;
-    ma_snd_pcm_sw_params_current_proc              _snd_pcm_sw_params_current              = snd_pcm_sw_params_current;
-    ma_snd_pcm_sw_params_get_boundary_proc         _snd_pcm_sw_params_get_boundary         = snd_pcm_sw_params_get_boundary;
-    ma_snd_pcm_sw_params_set_avail_min_proc        _snd_pcm_sw_params_set_avail_min        = snd_pcm_sw_params_set_avail_min;
-    ma_snd_pcm_sw_params_set_start_threshold_proc  _snd_pcm_sw_params_set_start_threshold  = snd_pcm_sw_params_set_start_threshold;
-    ma_snd_pcm_sw_params_set_stop_threshold_proc   _snd_pcm_sw_params_set_stop_threshold   = snd_pcm_sw_params_set_stop_threshold;
-    ma_snd_pcm_sw_params_proc                      _snd_pcm_sw_params                      = snd_pcm_sw_params;
-    ma_snd_pcm_format_mask_sizeof_proc             _snd_pcm_format_mask_sizeof             = snd_pcm_format_mask_sizeof;
-    ma_snd_pcm_format_mask_test_proc               _snd_pcm_format_mask_test               = snd_pcm_format_mask_test;
-    ma_snd_pcm_get_chmap_proc                      _snd_pcm_get_chmap                      = snd_pcm_get_chmap;
-    ma_snd_pcm_state_proc                          _snd_pcm_state                          = snd_pcm_state;
-    ma_snd_pcm_prepare_proc                        _snd_pcm_prepare                        = snd_pcm_prepare;
-    ma_snd_pcm_start_proc                          _snd_pcm_start                          = snd_pcm_start;
-    ma_snd_pcm_drop_proc                           _snd_pcm_drop                           = snd_pcm_drop;
-    ma_snd_pcm_drain_proc                          _snd_pcm_drain                          = snd_pcm_drain;
-    ma_snd_device_name_hint_proc                   _snd_device_name_hint                   = snd_device_name_hint;
-    ma_snd_device_name_get_hint_proc               _snd_device_name_get_hint               = snd_device_name_get_hint;
-    ma_snd_card_get_index_proc                     _snd_card_get_index                     = snd_card_get_index;
-    ma_snd_device_name_free_hint_proc              _snd_device_name_free_hint              = snd_device_name_free_hint;
-    ma_snd_pcm_mmap_begin_proc                     _snd_pcm_mmap_begin                     = snd_pcm_mmap_begin;
-    ma_snd_pcm_mmap_commit_proc                    _snd_pcm_mmap_commit                    = snd_pcm_mmap_commit;
-    ma_snd_pcm_recover_proc                        _snd_pcm_recover                        = snd_pcm_recover;
-    ma_snd_pcm_readi_proc                          _snd_pcm_readi                          = snd_pcm_readi;
-    ma_snd_pcm_writei_proc                         _snd_pcm_writei                         = snd_pcm_writei;
-    ma_snd_pcm_avail_proc                          _snd_pcm_avail                          = snd_pcm_avail;
-    ma_snd_pcm_avail_update_proc                   _snd_pcm_avail_update                   = snd_pcm_avail_update;
-    ma_snd_pcm_wait_proc                           _snd_pcm_wait                           = snd_pcm_wait;
-    ma_snd_pcm_info_proc                           _snd_pcm_info                           = snd_pcm_info;
-    ma_snd_pcm_info_sizeof_proc                    _snd_pcm_info_sizeof                    = snd_pcm_info_sizeof;
-    ma_snd_pcm_info_get_name_proc                  _snd_pcm_info_get_name                  = snd_pcm_info_get_name;
-    ma_snd_config_update_free_global_proc          _snd_config_update_free_global          = snd_config_update_free_global;
-
-    pContext->alsa.snd_pcm_open                           = (ma_proc)_snd_pcm_open;
-    pContext->alsa.snd_pcm_close                          = (ma_proc)_snd_pcm_close;
-    pContext->alsa.snd_pcm_hw_params_sizeof               = (ma_proc)_snd_pcm_hw_params_sizeof;
-    pContext->alsa.snd_pcm_hw_params_any                  = (ma_proc)_snd_pcm_hw_params_any;
-    pContext->alsa.snd_pcm_hw_params_set_format           = (ma_proc)_snd_pcm_hw_params_set_format;
-    pContext->alsa.snd_pcm_hw_params_set_format_first     = (ma_proc)_snd_pcm_hw_params_set_format_first;
-    pContext->alsa.snd_pcm_hw_params_get_format_mask      = (ma_proc)_snd_pcm_hw_params_get_format_mask;
-    pContext->alsa.snd_pcm_hw_params_set_channels         = (ma_proc)_snd_pcm_hw_params_set_channels;
-    pContext->alsa.snd_pcm_hw_params_set_channels_near    = (ma_proc)_snd_pcm_hw_params_set_channels_near;
-    pContext->alsa.snd_pcm_hw_params_set_channels_minmax  = (ma_proc)_snd_pcm_hw_params_set_channels_minmax;
-    pContext->alsa.snd_pcm_hw_params_set_rate_resample    = (ma_proc)_snd_pcm_hw_params_set_rate_resample;
-    pContext->alsa.snd_pcm_hw_params_set_rate             = (ma_proc)_snd_pcm_hw_params_set_rate;
-    pContext->alsa.snd_pcm_hw_params_set_rate_near        = (ma_proc)_snd_pcm_hw_params_set_rate_near;
-    pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)_snd_pcm_hw_params_set_buffer_size_near;
-    pContext->alsa.snd_pcm_hw_params_set_periods_near     = (ma_proc)_snd_pcm_hw_params_set_periods_near;
-    pContext->alsa.snd_pcm_hw_params_set_access           = (ma_proc)_snd_pcm_hw_params_set_access;
-    pContext->alsa.snd_pcm_hw_params_get_format           = (ma_proc)_snd_pcm_hw_params_get_format;
-    pContext->alsa.snd_pcm_hw_params_get_channels         = (ma_proc)_snd_pcm_hw_params_get_channels;
-    pContext->alsa.snd_pcm_hw_params_get_channels_min     = (ma_proc)_snd_pcm_hw_params_get_channels_min;
-    pContext->alsa.snd_pcm_hw_params_get_channels_max     = (ma_proc)_snd_pcm_hw_params_get_channels_max;
-    pContext->alsa.snd_pcm_hw_params_get_rate             = (ma_proc)_snd_pcm_hw_params_get_rate;
-    pContext->alsa.snd_pcm_hw_params_get_rate_min         = (ma_proc)_snd_pcm_hw_params_get_rate_min;
-    pContext->alsa.snd_pcm_hw_params_get_rate_max         = (ma_proc)_snd_pcm_hw_params_get_rate_max;
-    pContext->alsa.snd_pcm_hw_params_get_buffer_size      = (ma_proc)_snd_pcm_hw_params_get_buffer_size;
-    pContext->alsa.snd_pcm_hw_params_get_periods          = (ma_proc)_snd_pcm_hw_params_get_periods;
-    pContext->alsa.snd_pcm_hw_params_get_access           = (ma_proc)_snd_pcm_hw_params_get_access;
-    pContext->alsa.snd_pcm_hw_params_test_format          = (ma_proc)_snd_pcm_hw_params_test_format;
-    pContext->alsa.snd_pcm_hw_params_test_channels        = (ma_proc)_snd_pcm_hw_params_test_channels;
-    pContext->alsa.snd_pcm_hw_params_test_rate            = (ma_proc)_snd_pcm_hw_params_test_rate;
-    pContext->alsa.snd_pcm_hw_params                      = (ma_proc)_snd_pcm_hw_params;
-    pContext->alsa.snd_pcm_sw_params_sizeof               = (ma_proc)_snd_pcm_sw_params_sizeof;
-    pContext->alsa.snd_pcm_sw_params_current              = (ma_proc)_snd_pcm_sw_params_current;
-    pContext->alsa.snd_pcm_sw_params_get_boundary         = (ma_proc)_snd_pcm_sw_params_get_boundary;
-    pContext->alsa.snd_pcm_sw_params_set_avail_min        = (ma_proc)_snd_pcm_sw_params_set_avail_min;
-    pContext->alsa.snd_pcm_sw_params_set_start_threshold  = (ma_proc)_snd_pcm_sw_params_set_start_threshold;
-    pContext->alsa.snd_pcm_sw_params_set_stop_threshold   = (ma_proc)_snd_pcm_sw_params_set_stop_threshold;
-    pContext->alsa.snd_pcm_sw_params                      = (ma_proc)_snd_pcm_sw_params;
-    pContext->alsa.snd_pcm_format_mask_sizeof             = (ma_proc)_snd_pcm_format_mask_sizeof;
-    pContext->alsa.snd_pcm_format_mask_test               = (ma_proc)_snd_pcm_format_mask_test;
-    pContext->alsa.snd_pcm_get_chmap                      = (ma_proc)_snd_pcm_get_chmap;
-    pContext->alsa.snd_pcm_state                          = (ma_proc)_snd_pcm_state;
-    pContext->alsa.snd_pcm_prepare                        = (ma_proc)_snd_pcm_prepare;
-    pContext->alsa.snd_pcm_start                          = (ma_proc)_snd_pcm_start;
-    pContext->alsa.snd_pcm_drop                           = (ma_proc)_snd_pcm_drop;
-    pContext->alsa.snd_pcm_drain                          = (ma_proc)_snd_pcm_drain;
-    pContext->alsa.snd_device_name_hint                   = (ma_proc)_snd_device_name_hint;
-    pContext->alsa.snd_device_name_get_hint               = (ma_proc)_snd_device_name_get_hint;
-    pContext->alsa.snd_card_get_index                     = (ma_proc)_snd_card_get_index;
-    pContext->alsa.snd_device_name_free_hint              = (ma_proc)_snd_device_name_free_hint;
-    pContext->alsa.snd_pcm_mmap_begin                     = (ma_proc)_snd_pcm_mmap_begin;
-    pContext->alsa.snd_pcm_mmap_commit                    = (ma_proc)_snd_pcm_mmap_commit;
-    pContext->alsa.snd_pcm_recover                        = (ma_proc)_snd_pcm_recover;
-    pContext->alsa.snd_pcm_readi                          = (ma_proc)_snd_pcm_readi;
-    pContext->alsa.snd_pcm_writei                         = (ma_proc)_snd_pcm_writei;
-    pContext->alsa.snd_pcm_avail                          = (ma_proc)_snd_pcm_avail;
-    pContext->alsa.snd_pcm_avail_update                   = (ma_proc)_snd_pcm_avail_update;
-    pContext->alsa.snd_pcm_wait                           = (ma_proc)_snd_pcm_wait;
-    pContext->alsa.snd_pcm_info                           = (ma_proc)_snd_pcm_info;
-    pContext->alsa.snd_pcm_info_sizeof                    = (ma_proc)_snd_pcm_info_sizeof;
-    pContext->alsa.snd_pcm_info_get_name                  = (ma_proc)_snd_pcm_info_get_name;
-    pContext->alsa.snd_config_update_free_global          = (ma_proc)_snd_config_update_free_global;
-#endif
-
-    pContext->alsa.useVerboseDeviceEnumeration = pConfig->alsa.useVerboseDeviceEnumeration;
-
-    if (ma_mutex_init(&pContext->alsa.internalDeviceEnumLock) != MA_SUCCESS) {
-        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration.", MA_ERROR);
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__alsa;
-    pCallbacks->onContextUninit           = ma_context_uninit__alsa;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__alsa;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__alsa;
-    pCallbacks->onDeviceInit              = ma_device_init__alsa;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__alsa;
-    pCallbacks->onDeviceStart             = ma_device_start__alsa;
-    pCallbacks->onDeviceStop              = ma_device_stop__alsa;
-    pCallbacks->onDeviceRead              = ma_device_read__alsa;
-    pCallbacks->onDeviceWrite             = ma_device_write__alsa;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* ALSA */
-
-
-
-/******************************************************************************
-
-PulseAudio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_PULSEAUDIO
-/*
-The PulseAudio API, along with Apple's Core Audio, is the worst of the maintream audio APIs. This is a brief description of what's going on
-in the PulseAudio backend. I apologize if this gets a bit ranty for your liking - you might want to skip this discussion.
-
-PulseAudio has something they call the "Simple API", which unfortunately isn't suitable for miniaudio. I've not seen anywhere where it
-allows you to enumerate over devices, nor does it seem to support the ability to stop and start streams. Looking at the documentation, it
-appears as though the stream is constantly running and you prevent sound from being emitted or captured by simply not calling the read or
-write functions. This is not a professional solution as it would be much better to *actually* stop the underlying stream. Perhaps the
-simple API has some smarts to do this automatically, but I'm not sure. Another limitation with the simple API is that it seems inefficient
-when you want to have multiple streams to a single context. For these reasons, miniaudio is not using the simple API.
-
-Since we're not using the simple API, we're left with the asynchronous API as our only other option. And boy, is this where it starts to
-get fun, and I don't mean that in a good way...
-
-The problems start with the very name of the API - "asynchronous". Yes, this is an asynchronous oriented API which means your commands
-don't immediately take effect. You instead need to issue your commands, and then wait for them to complete. The waiting mechanism is
-enabled through the use of a "main loop". In the asychronous API you cannot get away from the main loop, and the main loop is where almost
-all of PulseAudio's problems stem from.
-
-When you first initialize PulseAudio you need an object referred to as "main loop". You can implement this yourself by defining your own
-vtable, but it's much easier to just use one of the built-in main loop implementations. There's two generic implementations called
-pa_mainloop and pa_threaded_mainloop, and another implementation specific to GLib called pa_glib_mainloop. We're using pa_threaded_mainloop
-because it simplifies management of the worker thread. The idea of the main loop object is pretty self explanatory - you're supposed to use
-it to implement a worker thread which runs in a loop. The main loop is where operations are actually executed.
-
-To initialize the main loop, you just use `pa_threaded_mainloop_new()`. This is the first function you'll call. You can then get a pointer
-to the vtable with `pa_threaded_mainloop_get_api()` (the main loop vtable is called `pa_mainloop_api`). Again, you can bypass the threaded
-main loop object entirely and just implement `pa_mainloop_api` directly, but there's no need for it unless you're doing something extremely
-specialized such as if you want to integrate it into your application's existing main loop infrastructure.
-
-(EDIT 2021-01-26: miniaudio is no longer using `pa_threaded_mainloop` due to this issue: https://github.com/mackron/miniaudio/issues/262.
-It is now using `pa_mainloop` which turns out to be a simpler solution anyway. The rest of this rant still applies, however.)
-
-Once you have your main loop vtable (the `pa_mainloop_api` object) you can create the PulseAudio context. This is very similar to
-miniaudio's context and they map to each other quite well. You have one context to many streams, which is basically the same as miniaudio's
-one `ma_context` to many `ma_device`s. Here's where it starts to get annoying, however. When you first create the PulseAudio context, which
-is done with `pa_context_new()`, it's not actually connected to anything. When you connect, you call `pa_context_connect()`. However, if
-you remember, PulseAudio is an asynchronous API. That means you cannot just assume the context is connected after `pa_context_context()`
-has returned. You instead need to wait for it to connect. To do this, you need to either wait for a callback to get fired, which you can
-set with `pa_context_set_state_callback()`, or you can continuously poll the context's state. Either way, you need to run this in a loop.
-All objects from here out are created from the context, and, I believe, you can't be creating these objects until the context is connected.
-This waiting loop is therefore unavoidable. In order for the waiting to ever complete, however, the main loop needs to be running. Before
-attempting to connect the context, the main loop needs to be started with `pa_threaded_mainloop_start()`.
-
-The reason for this asynchronous design is to support cases where you're connecting to a remote server, say through a local network or an
-internet connection. However, the *VAST* majority of cases don't involve this at all - they just connect to a local "server" running on the
-host machine. The fact that this would be the default rather than making `pa_context_connect()` synchronous tends to boggle the mind.
-
-Once the context has been created and connected you can start creating a stream. A PulseAudio stream is analogous to miniaudio's device.
-The initialization of a stream is fairly standard - you configure some attributes (analogous to miniaudio's device config) and then call
-`pa_stream_new()` to actually create it. Here is where we start to get into "operations". When configuring the stream, you can get
-information about the source (such as sample format, sample rate, etc.), however it's not synchronous. Instead, a `pa_operation` object
-is returned from `pa_context_get_source_info_by_name()` (capture) or `pa_context_get_sink_info_by_name()` (playback). Then, you need to
-run a loop (again!) to wait for the operation to complete which you can determine via a callback or polling, just like we did with the
-context. Then, as an added bonus, you need to decrement the reference counter of the `pa_operation` object to ensure memory is cleaned up.
-All of that just to retrieve basic information about a device!
-
-Once the basic information about the device has been retrieved, miniaudio can now create the stream with `ma_stream_new()`. Like the
-context, this needs to be connected. But we need to be careful here, because we're now about to introduce one of the most horrific design
-choices in PulseAudio.
-
-PulseAudio allows you to specify a callback that is fired when data can be written to or read from a stream. The language is important here
-because PulseAudio takes it literally, specifically the "can be". You would think these callbacks would be appropriate as the place for
-writing and reading data to and from the stream, and that would be right, except when it's not. When you initialize the stream, you can
-set a flag that tells PulseAudio to not start the stream automatically. This is required because miniaudio does not auto-start devices
-straight after initialization - you need to call `ma_device_start()` manually. The problem is that even when this flag is specified,
-PulseAudio will immediately fire it's write or read callback. This is *technically* correct (based on the wording in the documentation)
-because indeed, data *can* be written at this point. The problem is that it's not *practical*. It makes sense that the write/read callback
-would be where a program will want to write or read data to or from the stream, but when it's called before the application has even
-requested that the stream be started, it's just not practical because the program probably isn't ready for any kind of data delivery at
-that point (it may still need to load files or whatnot). Instead, this callback should only be fired when the application requests the
-stream be started which is how it works with literally *every* other callback-based audio API. Since miniaudio forbids firing of the data
-callback until the device has been started (as it should be with *all* callback based APIs), logic needs to be added to ensure miniaudio
-doesn't just blindly fire the application-defined data callback from within the PulseAudio callback before the stream has actually been
-started. The device state is used for this - if the state is anything other than `MA_STATE_STARTING` or `MA_STATE_STARTED`, the main data
-callback is not fired.
-
-This, unfortunately, is not the end of the problems with the PulseAudio write callback. Any normal callback based audio API will
-continuously fire the callback at regular intervals based on the size of the internal buffer. This will only ever be fired when the device
-is running, and will be fired regardless of whether or not the user actually wrote anything to the device/stream. This not the case in
-PulseAudio. In PulseAudio, the data callback will *only* be called if you wrote something to it previously. That means, if you don't call
-`pa_stream_write()`, the callback will not get fired. On the surface you wouldn't think this would matter because you should be always
-writing data, and if you don't have anything to write, just write silence. That's fine until you want to drain the stream. You see, if
-you're continuously writing data to the stream, the stream will never get drained! That means in order to drain the stream, you need to
-*not* write data to it! But remember, when you don't write data to the stream, the callback won't get fired again! Why is draining
-important? Because that's how we've defined stopping to work in miniaudio. In miniaudio, stopping the device requires it to be drained
-before returning from ma_device_stop(). So we've stopped the device, which requires us to drain, but draining requires us to *not* write
-data to the stream (or else it won't ever complete draining), but not writing to the stream means the callback won't get fired again!
-
-This becomes a problem when stopping and then restarting the device. When the device is stopped, it's drained, which requires us to *not*
-write anything to the stream. But then, since we didn't write anything to it, the write callback will *never* get called again if we just
-resume the stream naively. This means that starting the stream requires us to write data to the stream from outside the callback. This
-disconnect is something PulseAudio has got seriously wrong - there should only ever be a single source of data delivery, that being the
-callback. (I have tried using `pa_stream_flush()` to trigger the write callback to fire, but this just doesn't work for some reason.)
-
-Once you've created the stream, you need to connect it which involves the whole waiting procedure. This is the same process as the context,
-only this time you'll poll for the state with `pa_stream_get_status()`. The starting and stopping of a streaming is referred to as
-"corking" in PulseAudio. The analogy is corking a barrel. To start the stream, you uncork it, to stop it you cork it. Personally I think
-it's silly - why would you not just call it "starting" and "stopping" like any other normal audio API? Anyway, the act of corking is, you
-guessed it, asynchronous. This means you'll need our waiting loop as usual. Again, why this asynchronous design is the default is
-absolutely beyond me. Would it really be that hard to just make it run synchronously?
-
-Teardown is pretty simple (what?!). It's just a matter of calling the relevant `_unref()` function on each object in reverse order that
-they were initialized in.
-
-That's about it from the PulseAudio side. A bit ranty, I know, but they really need to fix that main loop and callback system. They're
-embarrassingly unpractical. The main loop thing is an easy fix - have synchronous versions of all APIs. If an application wants these to
-run asynchronously, they can execute them in a separate thread themselves. The desire to run these asynchronously is such a niche
-requirement - it makes no sense to make it the default. The stream write callback needs to be change, or an alternative provided, that is
-constantly fired, regardless of whether or not `pa_stream_write()` has been called, and it needs to take a pointer to a buffer as a
-parameter which the program just writes to directly rather than having to call `pa_stream_writable_size()` and `pa_stream_write()`. These
-changes alone will change PulseAudio from one of the worst audio APIs to one of the best.
-*/
-
-
-/*
-It is assumed pulseaudio.h is available when linking at compile time. When linking at compile time, we use the declarations in the header
-to check for type safety. We cannot do this when linking at run time because the header might not be available.
-*/
-#ifdef MA_NO_RUNTIME_LINKING
-
-/* pulseaudio.h marks some functions with "inline" which isn't always supported. Need to emulate it. */
-#if !defined(__cplusplus)
-    #if defined(__STRICT_ANSI__)
-        #if !defined(inline)
-            #define inline __inline__ __attribute__((always_inline))
-            #define MA_INLINE_DEFINED
-        #endif
-    #endif
-#endif
-#include <pulse/pulseaudio.h>
-#if defined(MA_INLINE_DEFINED)
-    #undef inline
-    #undef MA_INLINE_DEFINED
-#endif
-
-#define MA_PA_OK                                       PA_OK
-#define MA_PA_ERR_ACCESS                               PA_ERR_ACCESS
-#define MA_PA_ERR_INVALID                              PA_ERR_INVALID
-#define MA_PA_ERR_NOENTITY                             PA_ERR_NOENTITY
-
-#define MA_PA_CHANNELS_MAX                             PA_CHANNELS_MAX
-#define MA_PA_RATE_MAX                                 PA_RATE_MAX
-
-typedef pa_context_flags_t ma_pa_context_flags_t;
-#define MA_PA_CONTEXT_NOFLAGS                          PA_CONTEXT_NOFLAGS
-#define MA_PA_CONTEXT_NOAUTOSPAWN                      PA_CONTEXT_NOAUTOSPAWN
-#define MA_PA_CONTEXT_NOFAIL                           PA_CONTEXT_NOFAIL
-
-typedef pa_stream_flags_t ma_pa_stream_flags_t;
-#define MA_PA_STREAM_NOFLAGS                           PA_STREAM_NOFLAGS
-#define MA_PA_STREAM_START_CORKED                      PA_STREAM_START_CORKED
-#define MA_PA_STREAM_INTERPOLATE_TIMING                PA_STREAM_INTERPOLATE_TIMING
-#define MA_PA_STREAM_NOT_MONOTONIC                     PA_STREAM_NOT_MONOTONIC
-#define MA_PA_STREAM_AUTO_TIMING_UPDATE                PA_STREAM_AUTO_TIMING_UPDATE
-#define MA_PA_STREAM_NO_REMAP_CHANNELS                 PA_STREAM_NO_REMAP_CHANNELS
-#define MA_PA_STREAM_NO_REMIX_CHANNELS                 PA_STREAM_NO_REMIX_CHANNELS
-#define MA_PA_STREAM_FIX_FORMAT                        PA_STREAM_FIX_FORMAT
-#define MA_PA_STREAM_FIX_RATE                          PA_STREAM_FIX_RATE
-#define MA_PA_STREAM_FIX_CHANNELS                      PA_STREAM_FIX_CHANNELS
-#define MA_PA_STREAM_DONT_MOVE                         PA_STREAM_DONT_MOVE
-#define MA_PA_STREAM_VARIABLE_RATE                     PA_STREAM_VARIABLE_RATE
-#define MA_PA_STREAM_PEAK_DETECT                       PA_STREAM_PEAK_DETECT
-#define MA_PA_STREAM_START_MUTED                       PA_STREAM_START_MUTED
-#define MA_PA_STREAM_ADJUST_LATENCY                    PA_STREAM_ADJUST_LATENCY
-#define MA_PA_STREAM_EARLY_REQUESTS                    PA_STREAM_EARLY_REQUESTS
-#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND         PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
-#define MA_PA_STREAM_START_UNMUTED                     PA_STREAM_START_UNMUTED
-#define MA_PA_STREAM_FAIL_ON_SUSPEND                   PA_STREAM_FAIL_ON_SUSPEND
-#define MA_PA_STREAM_RELATIVE_VOLUME                   PA_STREAM_RELATIVE_VOLUME
-#define MA_PA_STREAM_PASSTHROUGH                       PA_STREAM_PASSTHROUGH
-
-typedef pa_sink_flags_t ma_pa_sink_flags_t;
-#define MA_PA_SINK_NOFLAGS                             PA_SINK_NOFLAGS
-#define MA_PA_SINK_HW_VOLUME_CTRL                      PA_SINK_HW_VOLUME_CTRL
-#define MA_PA_SINK_LATENCY                             PA_SINK_LATENCY
-#define MA_PA_SINK_HARDWARE                            PA_SINK_HARDWARE
-#define MA_PA_SINK_NETWORK                             PA_SINK_NETWORK
-#define MA_PA_SINK_HW_MUTE_CTRL                        PA_SINK_HW_MUTE_CTRL
-#define MA_PA_SINK_DECIBEL_VOLUME                      PA_SINK_DECIBEL_VOLUME
-#define MA_PA_SINK_FLAT_VOLUME                         PA_SINK_FLAT_VOLUME
-#define MA_PA_SINK_DYNAMIC_LATENCY                     PA_SINK_DYNAMIC_LATENCY
-#define MA_PA_SINK_SET_FORMATS                         PA_SINK_SET_FORMATS
-
-typedef pa_source_flags_t ma_pa_source_flags_t;
-#define MA_PA_SOURCE_NOFLAGS                           PA_SOURCE_NOFLAGS
-#define MA_PA_SOURCE_HW_VOLUME_CTRL                    PA_SOURCE_HW_VOLUME_CTRL
-#define MA_PA_SOURCE_LATENCY                           PA_SOURCE_LATENCY
-#define MA_PA_SOURCE_HARDWARE                          PA_SOURCE_HARDWARE
-#define MA_PA_SOURCE_NETWORK                           PA_SOURCE_NETWORK
-#define MA_PA_SOURCE_HW_MUTE_CTRL                      PA_SOURCE_HW_MUTE_CTRL
-#define MA_PA_SOURCE_DECIBEL_VOLUME                    PA_SOURCE_DECIBEL_VOLUME
-#define MA_PA_SOURCE_DYNAMIC_LATENCY                   PA_SOURCE_DYNAMIC_LATENCY
-#define MA_PA_SOURCE_FLAT_VOLUME                       PA_SOURCE_FLAT_VOLUME
-
-typedef pa_context_state_t ma_pa_context_state_t;
-#define MA_PA_CONTEXT_UNCONNECTED                      PA_CONTEXT_UNCONNECTED
-#define MA_PA_CONTEXT_CONNECTING                       PA_CONTEXT_CONNECTING
-#define MA_PA_CONTEXT_AUTHORIZING                      PA_CONTEXT_AUTHORIZING
-#define MA_PA_CONTEXT_SETTING_NAME                     PA_CONTEXT_SETTING_NAME
-#define MA_PA_CONTEXT_READY                            PA_CONTEXT_READY
-#define MA_PA_CONTEXT_FAILED                           PA_CONTEXT_FAILED
-#define MA_PA_CONTEXT_TERMINATED                       PA_CONTEXT_TERMINATED
-
-typedef pa_stream_state_t ma_pa_stream_state_t;
-#define MA_PA_STREAM_UNCONNECTED                       PA_STREAM_UNCONNECTED
-#define MA_PA_STREAM_CREATING                          PA_STREAM_CREATING
-#define MA_PA_STREAM_READY                             PA_STREAM_READY
-#define MA_PA_STREAM_FAILED                            PA_STREAM_FAILED
-#define MA_PA_STREAM_TERMINATED                        PA_STREAM_TERMINATED
-
-typedef pa_operation_state_t ma_pa_operation_state_t;
-#define MA_PA_OPERATION_RUNNING                        PA_OPERATION_RUNNING
-#define MA_PA_OPERATION_DONE                           PA_OPERATION_DONE
-#define MA_PA_OPERATION_CANCELLED                      PA_OPERATION_CANCELLED
-
-typedef pa_sink_state_t ma_pa_sink_state_t;
-#define MA_PA_SINK_INVALID_STATE                       PA_SINK_INVALID_STATE
-#define MA_PA_SINK_RUNNING                             PA_SINK_RUNNING
-#define MA_PA_SINK_IDLE                                PA_SINK_IDLE
-#define MA_PA_SINK_SUSPENDED                           PA_SINK_SUSPENDED
-
-typedef pa_source_state_t ma_pa_source_state_t;
-#define MA_PA_SOURCE_INVALID_STATE                     PA_SOURCE_INVALID_STATE
-#define MA_PA_SOURCE_RUNNING                           PA_SOURCE_RUNNING
-#define MA_PA_SOURCE_IDLE                              PA_SOURCE_IDLE
-#define MA_PA_SOURCE_SUSPENDED                         PA_SOURCE_SUSPENDED
-
-typedef pa_seek_mode_t ma_pa_seek_mode_t;
-#define MA_PA_SEEK_RELATIVE                            PA_SEEK_RELATIVE
-#define MA_PA_SEEK_ABSOLUTE                            PA_SEEK_ABSOLUTE
-#define MA_PA_SEEK_RELATIVE_ON_READ                    PA_SEEK_RELATIVE_ON_READ
-#define MA_PA_SEEK_RELATIVE_END                        PA_SEEK_RELATIVE_END
-
-typedef pa_channel_position_t ma_pa_channel_position_t;
-#define MA_PA_CHANNEL_POSITION_INVALID                 PA_CHANNEL_POSITION_INVALID
-#define MA_PA_CHANNEL_POSITION_MONO                    PA_CHANNEL_POSITION_MONO
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT              PA_CHANNEL_POSITION_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT             PA_CHANNEL_POSITION_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_FRONT_CENTER            PA_CHANNEL_POSITION_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_REAR_CENTER             PA_CHANNEL_POSITION_REAR_CENTER
-#define MA_PA_CHANNEL_POSITION_REAR_LEFT               PA_CHANNEL_POSITION_REAR_LEFT
-#define MA_PA_CHANNEL_POSITION_REAR_RIGHT              PA_CHANNEL_POSITION_REAR_RIGHT
-#define MA_PA_CHANNEL_POSITION_LFE                     PA_CHANNEL_POSITION_LFE
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER    PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER   PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
-#define MA_PA_CHANNEL_POSITION_SIDE_LEFT               PA_CHANNEL_POSITION_SIDE_LEFT
-#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT              PA_CHANNEL_POSITION_SIDE_RIGHT
-#define MA_PA_CHANNEL_POSITION_AUX0                    PA_CHANNEL_POSITION_AUX0
-#define MA_PA_CHANNEL_POSITION_AUX1                    PA_CHANNEL_POSITION_AUX1
-#define MA_PA_CHANNEL_POSITION_AUX2                    PA_CHANNEL_POSITION_AUX2
-#define MA_PA_CHANNEL_POSITION_AUX3                    PA_CHANNEL_POSITION_AUX3
-#define MA_PA_CHANNEL_POSITION_AUX4                    PA_CHANNEL_POSITION_AUX4
-#define MA_PA_CHANNEL_POSITION_AUX5                    PA_CHANNEL_POSITION_AUX5
-#define MA_PA_CHANNEL_POSITION_AUX6                    PA_CHANNEL_POSITION_AUX6
-#define MA_PA_CHANNEL_POSITION_AUX7                    PA_CHANNEL_POSITION_AUX7
-#define MA_PA_CHANNEL_POSITION_AUX8                    PA_CHANNEL_POSITION_AUX8
-#define MA_PA_CHANNEL_POSITION_AUX9                    PA_CHANNEL_POSITION_AUX9
-#define MA_PA_CHANNEL_POSITION_AUX10                   PA_CHANNEL_POSITION_AUX10
-#define MA_PA_CHANNEL_POSITION_AUX11                   PA_CHANNEL_POSITION_AUX11
-#define MA_PA_CHANNEL_POSITION_AUX12                   PA_CHANNEL_POSITION_AUX12
-#define MA_PA_CHANNEL_POSITION_AUX13                   PA_CHANNEL_POSITION_AUX13
-#define MA_PA_CHANNEL_POSITION_AUX14                   PA_CHANNEL_POSITION_AUX14
-#define MA_PA_CHANNEL_POSITION_AUX15                   PA_CHANNEL_POSITION_AUX15
-#define MA_PA_CHANNEL_POSITION_AUX16                   PA_CHANNEL_POSITION_AUX16
-#define MA_PA_CHANNEL_POSITION_AUX17                   PA_CHANNEL_POSITION_AUX17
-#define MA_PA_CHANNEL_POSITION_AUX18                   PA_CHANNEL_POSITION_AUX18
-#define MA_PA_CHANNEL_POSITION_AUX19                   PA_CHANNEL_POSITION_AUX19
-#define MA_PA_CHANNEL_POSITION_AUX20                   PA_CHANNEL_POSITION_AUX20
-#define MA_PA_CHANNEL_POSITION_AUX21                   PA_CHANNEL_POSITION_AUX21
-#define MA_PA_CHANNEL_POSITION_AUX22                   PA_CHANNEL_POSITION_AUX22
-#define MA_PA_CHANNEL_POSITION_AUX23                   PA_CHANNEL_POSITION_AUX23
-#define MA_PA_CHANNEL_POSITION_AUX24                   PA_CHANNEL_POSITION_AUX24
-#define MA_PA_CHANNEL_POSITION_AUX25                   PA_CHANNEL_POSITION_AUX25
-#define MA_PA_CHANNEL_POSITION_AUX26                   PA_CHANNEL_POSITION_AUX26
-#define MA_PA_CHANNEL_POSITION_AUX27                   PA_CHANNEL_POSITION_AUX27
-#define MA_PA_CHANNEL_POSITION_AUX28                   PA_CHANNEL_POSITION_AUX28
-#define MA_PA_CHANNEL_POSITION_AUX29                   PA_CHANNEL_POSITION_AUX29
-#define MA_PA_CHANNEL_POSITION_AUX30                   PA_CHANNEL_POSITION_AUX30
-#define MA_PA_CHANNEL_POSITION_AUX31                   PA_CHANNEL_POSITION_AUX31
-#define MA_PA_CHANNEL_POSITION_TOP_CENTER              PA_CHANNEL_POSITION_TOP_CENTER
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT          PA_CHANNEL_POSITION_TOP_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT         PA_CHANNEL_POSITION_TOP_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER        PA_CHANNEL_POSITION_TOP_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT           PA_CHANNEL_POSITION_TOP_REAR_LEFT
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT          PA_CHANNEL_POSITION_TOP_REAR_RIGHT
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER         PA_CHANNEL_POSITION_TOP_REAR_CENTER
-#define MA_PA_CHANNEL_POSITION_LEFT                    PA_CHANNEL_POSITION_LEFT
-#define MA_PA_CHANNEL_POSITION_RIGHT                   PA_CHANNEL_POSITION_RIGHT
-#define MA_PA_CHANNEL_POSITION_CENTER                  PA_CHANNEL_POSITION_CENTER
-#define MA_PA_CHANNEL_POSITION_SUBWOOFER               PA_CHANNEL_POSITION_SUBWOOFER
-
-typedef pa_channel_map_def_t ma_pa_channel_map_def_t;
-#define MA_PA_CHANNEL_MAP_AIFF                         PA_CHANNEL_MAP_AIFF
-#define MA_PA_CHANNEL_MAP_ALSA                         PA_CHANNEL_MAP_ALSA
-#define MA_PA_CHANNEL_MAP_AUX                          PA_CHANNEL_MAP_AUX
-#define MA_PA_CHANNEL_MAP_WAVEEX                       PA_CHANNEL_MAP_WAVEEX
-#define MA_PA_CHANNEL_MAP_OSS                          PA_CHANNEL_MAP_OSS
-#define MA_PA_CHANNEL_MAP_DEFAULT                      PA_CHANNEL_MAP_DEFAULT
-
-typedef pa_sample_format_t ma_pa_sample_format_t;
-#define MA_PA_SAMPLE_INVALID                           PA_SAMPLE_INVALID
-#define MA_PA_SAMPLE_U8                                PA_SAMPLE_U8
-#define MA_PA_SAMPLE_ALAW                              PA_SAMPLE_ALAW
-#define MA_PA_SAMPLE_ULAW                              PA_SAMPLE_ULAW
-#define MA_PA_SAMPLE_S16LE                             PA_SAMPLE_S16LE
-#define MA_PA_SAMPLE_S16BE                             PA_SAMPLE_S16BE
-#define MA_PA_SAMPLE_FLOAT32LE                         PA_SAMPLE_FLOAT32LE
-#define MA_PA_SAMPLE_FLOAT32BE                         PA_SAMPLE_FLOAT32BE
-#define MA_PA_SAMPLE_S32LE                             PA_SAMPLE_S32LE
-#define MA_PA_SAMPLE_S32BE                             PA_SAMPLE_S32BE
-#define MA_PA_SAMPLE_S24LE                             PA_SAMPLE_S24LE
-#define MA_PA_SAMPLE_S24BE                             PA_SAMPLE_S24BE
-#define MA_PA_SAMPLE_S24_32LE                          PA_SAMPLE_S24_32LE
-#define MA_PA_SAMPLE_S24_32BE                          PA_SAMPLE_S24_32BE
-
-typedef pa_mainloop             ma_pa_mainloop;
-typedef pa_threaded_mainloop    ma_pa_threaded_mainloop;
-typedef pa_mainloop_api         ma_pa_mainloop_api;
-typedef pa_context              ma_pa_context;
-typedef pa_operation            ma_pa_operation;
-typedef pa_stream               ma_pa_stream;
-typedef pa_spawn_api            ma_pa_spawn_api;
-typedef pa_buffer_attr          ma_pa_buffer_attr;
-typedef pa_channel_map          ma_pa_channel_map;
-typedef pa_cvolume              ma_pa_cvolume;
-typedef pa_sample_spec          ma_pa_sample_spec;
-typedef pa_sink_info            ma_pa_sink_info;
-typedef pa_source_info          ma_pa_source_info;
-
-typedef pa_context_notify_cb_t  ma_pa_context_notify_cb_t;
-typedef pa_sink_info_cb_t       ma_pa_sink_info_cb_t;
-typedef pa_source_info_cb_t     ma_pa_source_info_cb_t;
-typedef pa_stream_success_cb_t  ma_pa_stream_success_cb_t;
-typedef pa_stream_request_cb_t  ma_pa_stream_request_cb_t;
-typedef pa_free_cb_t            ma_pa_free_cb_t;
-#else
-#define MA_PA_OK                                       0
-#define MA_PA_ERR_ACCESS                               1
-#define MA_PA_ERR_INVALID                              2
-#define MA_PA_ERR_NOENTITY                             5
-
-#define MA_PA_CHANNELS_MAX                             32
-#define MA_PA_RATE_MAX                                 384000
-
-typedef int ma_pa_context_flags_t;
-#define MA_PA_CONTEXT_NOFLAGS                          0x00000000
-#define MA_PA_CONTEXT_NOAUTOSPAWN                      0x00000001
-#define MA_PA_CONTEXT_NOFAIL                           0x00000002
-
-typedef int ma_pa_stream_flags_t;
-#define MA_PA_STREAM_NOFLAGS                           0x00000000
-#define MA_PA_STREAM_START_CORKED                      0x00000001
-#define MA_PA_STREAM_INTERPOLATE_TIMING                0x00000002
-#define MA_PA_STREAM_NOT_MONOTONIC                     0x00000004
-#define MA_PA_STREAM_AUTO_TIMING_UPDATE                0x00000008
-#define MA_PA_STREAM_NO_REMAP_CHANNELS                 0x00000010
-#define MA_PA_STREAM_NO_REMIX_CHANNELS                 0x00000020
-#define MA_PA_STREAM_FIX_FORMAT                        0x00000040
-#define MA_PA_STREAM_FIX_RATE                          0x00000080
-#define MA_PA_STREAM_FIX_CHANNELS                      0x00000100
-#define MA_PA_STREAM_DONT_MOVE                         0x00000200
-#define MA_PA_STREAM_VARIABLE_RATE                     0x00000400
-#define MA_PA_STREAM_PEAK_DETECT                       0x00000800
-#define MA_PA_STREAM_START_MUTED                       0x00001000
-#define MA_PA_STREAM_ADJUST_LATENCY                    0x00002000
-#define MA_PA_STREAM_EARLY_REQUESTS                    0x00004000
-#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND         0x00008000
-#define MA_PA_STREAM_START_UNMUTED                     0x00010000
-#define MA_PA_STREAM_FAIL_ON_SUSPEND                   0x00020000
-#define MA_PA_STREAM_RELATIVE_VOLUME                   0x00040000
-#define MA_PA_STREAM_PASSTHROUGH                       0x00080000
-
-typedef int ma_pa_sink_flags_t;
-#define MA_PA_SINK_NOFLAGS                             0x00000000
-#define MA_PA_SINK_HW_VOLUME_CTRL                      0x00000001
-#define MA_PA_SINK_LATENCY                             0x00000002
-#define MA_PA_SINK_HARDWARE                            0x00000004
-#define MA_PA_SINK_NETWORK                             0x00000008
-#define MA_PA_SINK_HW_MUTE_CTRL                        0x00000010
-#define MA_PA_SINK_DECIBEL_VOLUME                      0x00000020
-#define MA_PA_SINK_FLAT_VOLUME                         0x00000040
-#define MA_PA_SINK_DYNAMIC_LATENCY                     0x00000080
-#define MA_PA_SINK_SET_FORMATS                         0x00000100
-
-typedef int ma_pa_source_flags_t;
-#define MA_PA_SOURCE_NOFLAGS                           0x00000000
-#define MA_PA_SOURCE_HW_VOLUME_CTRL                    0x00000001
-#define MA_PA_SOURCE_LATENCY                           0x00000002
-#define MA_PA_SOURCE_HARDWARE                          0x00000004
-#define MA_PA_SOURCE_NETWORK                           0x00000008
-#define MA_PA_SOURCE_HW_MUTE_CTRL                      0x00000010
-#define MA_PA_SOURCE_DECIBEL_VOLUME                    0x00000020
-#define MA_PA_SOURCE_DYNAMIC_LATENCY                   0x00000040
-#define MA_PA_SOURCE_FLAT_VOLUME                       0x00000080
-
-typedef int ma_pa_context_state_t;
-#define MA_PA_CONTEXT_UNCONNECTED                      0
-#define MA_PA_CONTEXT_CONNECTING                       1
-#define MA_PA_CONTEXT_AUTHORIZING                      2
-#define MA_PA_CONTEXT_SETTING_NAME                     3
-#define MA_PA_CONTEXT_READY                            4
-#define MA_PA_CONTEXT_FAILED                           5
-#define MA_PA_CONTEXT_TERMINATED                       6
-
-typedef int ma_pa_stream_state_t;
-#define MA_PA_STREAM_UNCONNECTED                       0
-#define MA_PA_STREAM_CREATING                          1
-#define MA_PA_STREAM_READY                             2
-#define MA_PA_STREAM_FAILED                            3
-#define MA_PA_STREAM_TERMINATED                        4
-
-typedef int ma_pa_operation_state_t;
-#define MA_PA_OPERATION_RUNNING                        0
-#define MA_PA_OPERATION_DONE                           1
-#define MA_PA_OPERATION_CANCELLED                      2
-
-typedef int ma_pa_sink_state_t;
-#define MA_PA_SINK_INVALID_STATE                       -1
-#define MA_PA_SINK_RUNNING                             0
-#define MA_PA_SINK_IDLE                                1
-#define MA_PA_SINK_SUSPENDED                           2
-
-typedef int ma_pa_source_state_t;
-#define MA_PA_SOURCE_INVALID_STATE                     -1
-#define MA_PA_SOURCE_RUNNING                           0
-#define MA_PA_SOURCE_IDLE                              1
-#define MA_PA_SOURCE_SUSPENDED                         2
-
-typedef int ma_pa_seek_mode_t;
-#define MA_PA_SEEK_RELATIVE                            0
-#define MA_PA_SEEK_ABSOLUTE                            1
-#define MA_PA_SEEK_RELATIVE_ON_READ                    2
-#define MA_PA_SEEK_RELATIVE_END                        3
-
-typedef int ma_pa_channel_position_t;
-#define MA_PA_CHANNEL_POSITION_INVALID                 -1
-#define MA_PA_CHANNEL_POSITION_MONO                    0
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT              1
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT             2
-#define MA_PA_CHANNEL_POSITION_FRONT_CENTER            3
-#define MA_PA_CHANNEL_POSITION_REAR_CENTER             4
-#define MA_PA_CHANNEL_POSITION_REAR_LEFT               5
-#define MA_PA_CHANNEL_POSITION_REAR_RIGHT              6
-#define MA_PA_CHANNEL_POSITION_LFE                     7
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER    8
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER   9
-#define MA_PA_CHANNEL_POSITION_SIDE_LEFT               10
-#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT              11
-#define MA_PA_CHANNEL_POSITION_AUX0                    12
-#define MA_PA_CHANNEL_POSITION_AUX1                    13
-#define MA_PA_CHANNEL_POSITION_AUX2                    14
-#define MA_PA_CHANNEL_POSITION_AUX3                    15
-#define MA_PA_CHANNEL_POSITION_AUX4                    16
-#define MA_PA_CHANNEL_POSITION_AUX5                    17
-#define MA_PA_CHANNEL_POSITION_AUX6                    18
-#define MA_PA_CHANNEL_POSITION_AUX7                    19
-#define MA_PA_CHANNEL_POSITION_AUX8                    20
-#define MA_PA_CHANNEL_POSITION_AUX9                    21
-#define MA_PA_CHANNEL_POSITION_AUX10                   22
-#define MA_PA_CHANNEL_POSITION_AUX11                   23
-#define MA_PA_CHANNEL_POSITION_AUX12                   24
-#define MA_PA_CHANNEL_POSITION_AUX13                   25
-#define MA_PA_CHANNEL_POSITION_AUX14                   26
-#define MA_PA_CHANNEL_POSITION_AUX15                   27
-#define MA_PA_CHANNEL_POSITION_AUX16                   28
-#define MA_PA_CHANNEL_POSITION_AUX17                   29
-#define MA_PA_CHANNEL_POSITION_AUX18                   30
-#define MA_PA_CHANNEL_POSITION_AUX19                   31
-#define MA_PA_CHANNEL_POSITION_AUX20                   32
-#define MA_PA_CHANNEL_POSITION_AUX21                   33
-#define MA_PA_CHANNEL_POSITION_AUX22                   34
-#define MA_PA_CHANNEL_POSITION_AUX23                   35
-#define MA_PA_CHANNEL_POSITION_AUX24                   36
-#define MA_PA_CHANNEL_POSITION_AUX25                   37
-#define MA_PA_CHANNEL_POSITION_AUX26                   38
-#define MA_PA_CHANNEL_POSITION_AUX27                   39
-#define MA_PA_CHANNEL_POSITION_AUX28                   40
-#define MA_PA_CHANNEL_POSITION_AUX29                   41
-#define MA_PA_CHANNEL_POSITION_AUX30                   42
-#define MA_PA_CHANNEL_POSITION_AUX31                   43
-#define MA_PA_CHANNEL_POSITION_TOP_CENTER              44
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT          45
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT         46
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER        47
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT           48
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT          49
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER         50
-#define MA_PA_CHANNEL_POSITION_LEFT                    MA_PA_CHANNEL_POSITION_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_RIGHT                   MA_PA_CHANNEL_POSITION_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_CENTER                  MA_PA_CHANNEL_POSITION_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_SUBWOOFER               MA_PA_CHANNEL_POSITION_LFE
-
-typedef int ma_pa_channel_map_def_t;
-#define MA_PA_CHANNEL_MAP_AIFF                         0
-#define MA_PA_CHANNEL_MAP_ALSA                         1
-#define MA_PA_CHANNEL_MAP_AUX                          2
-#define MA_PA_CHANNEL_MAP_WAVEEX                       3
-#define MA_PA_CHANNEL_MAP_OSS                          4
-#define MA_PA_CHANNEL_MAP_DEFAULT                      MA_PA_CHANNEL_MAP_AIFF
-
-typedef int ma_pa_sample_format_t;
-#define MA_PA_SAMPLE_INVALID                           -1
-#define MA_PA_SAMPLE_U8                                0
-#define MA_PA_SAMPLE_ALAW                              1
-#define MA_PA_SAMPLE_ULAW                              2
-#define MA_PA_SAMPLE_S16LE                             3
-#define MA_PA_SAMPLE_S16BE                             4
-#define MA_PA_SAMPLE_FLOAT32LE                         5
-#define MA_PA_SAMPLE_FLOAT32BE                         6
-#define MA_PA_SAMPLE_S32LE                             7
-#define MA_PA_SAMPLE_S32BE                             8
-#define MA_PA_SAMPLE_S24LE                             9
-#define MA_PA_SAMPLE_S24BE                             10
-#define MA_PA_SAMPLE_S24_32LE                          11
-#define MA_PA_SAMPLE_S24_32BE                          12
-
-typedef struct ma_pa_mainloop           ma_pa_mainloop;
-typedef struct ma_pa_threaded_mainloop  ma_pa_threaded_mainloop;
-typedef struct ma_pa_mainloop_api       ma_pa_mainloop_api;
-typedef struct ma_pa_context            ma_pa_context;
-typedef struct ma_pa_operation          ma_pa_operation;
-typedef struct ma_pa_stream             ma_pa_stream;
-typedef struct ma_pa_spawn_api          ma_pa_spawn_api;
-
-typedef struct
-{
-    ma_uint32 maxlength;
-    ma_uint32 tlength;
-    ma_uint32 prebuf;
-    ma_uint32 minreq;
-    ma_uint32 fragsize;
-} ma_pa_buffer_attr;
-
-typedef struct
-{
-    ma_uint8 channels;
-    ma_pa_channel_position_t map[MA_PA_CHANNELS_MAX];
-} ma_pa_channel_map;
-
-typedef struct
-{
-    ma_uint8 channels;
-    ma_uint32 values[MA_PA_CHANNELS_MAX];
-} ma_pa_cvolume;
-
-typedef struct
-{
-    ma_pa_sample_format_t format;
-    ma_uint32 rate;
-    ma_uint8 channels;
-} ma_pa_sample_spec;
-
-typedef struct
-{
-    const char* name;
-    ma_uint32 index;
-    const char* description;
-    ma_pa_sample_spec sample_spec;
-    ma_pa_channel_map channel_map;
-    ma_uint32 owner_module;
-    ma_pa_cvolume volume;
-    int mute;
-    ma_uint32 monitor_source;
-    const char* monitor_source_name;
-    ma_uint64 latency;
-    const char* driver;
-    ma_pa_sink_flags_t flags;
-    void* proplist;
-    ma_uint64 configured_latency;
-    ma_uint32 base_volume;
-    ma_pa_sink_state_t state;
-    ma_uint32 n_volume_steps;
-    ma_uint32 card;
-    ma_uint32 n_ports;
-    void** ports;
-    void* active_port;
-    ma_uint8 n_formats;
-    void** formats;
-} ma_pa_sink_info;
-
-typedef struct
-{
-    const char *name;
-    ma_uint32 index;
-    const char *description;
-    ma_pa_sample_spec sample_spec;
-    ma_pa_channel_map channel_map;
-    ma_uint32 owner_module;
-    ma_pa_cvolume volume;
-    int mute;
-    ma_uint32 monitor_of_sink;
-    const char *monitor_of_sink_name;
-    ma_uint64 latency;
-    const char *driver;
-    ma_pa_source_flags_t flags;
-    void* proplist;
-    ma_uint64 configured_latency;
-    ma_uint32 base_volume;
-    ma_pa_source_state_t state;
-    ma_uint32 n_volume_steps;
-    ma_uint32 card;
-    ma_uint32 n_ports;
-    void** ports;
-    void* active_port;
-    ma_uint8 n_formats;
-    void** formats;
-} ma_pa_source_info;
-
-typedef void (* ma_pa_context_notify_cb_t)(ma_pa_context* c, void* userdata);
-typedef void (* ma_pa_sink_info_cb_t)     (ma_pa_context* c, const ma_pa_sink_info* i, int eol, void* userdata);
-typedef void (* ma_pa_source_info_cb_t)   (ma_pa_context* c, const ma_pa_source_info* i, int eol, void* userdata);
-typedef void (* ma_pa_stream_success_cb_t)(ma_pa_stream* s, int success, void* userdata);
-typedef void (* ma_pa_stream_request_cb_t)(ma_pa_stream* s, size_t nbytes, void* userdata);
-typedef void (* ma_pa_free_cb_t)          (void* p);
-#endif
-
-
-typedef ma_pa_mainloop*          (* ma_pa_mainloop_new_proc)                   (void);
-typedef void                     (* ma_pa_mainloop_free_proc)                  (ma_pa_mainloop* m);
-typedef void                     (* ma_pa_mainloop_quit_proc)                  (ma_pa_mainloop* m, int retval);
-typedef ma_pa_mainloop_api*      (* ma_pa_mainloop_get_api_proc)               (ma_pa_mainloop* m);
-typedef int                      (* ma_pa_mainloop_iterate_proc)               (ma_pa_mainloop* m, int block, int* retval);
-typedef void                     (* ma_pa_mainloop_wakeup_proc)                (ma_pa_mainloop* m);
-typedef ma_pa_threaded_mainloop* (* ma_pa_threaded_mainloop_new_proc)          (void);
-typedef void                     (* ma_pa_threaded_mainloop_free_proc)         (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_start_proc)        (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_stop_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_lock_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_unlock_proc)       (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_wait_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_signal_proc)       (ma_pa_threaded_mainloop* m, int wait_for_accept);
-typedef void                     (* ma_pa_threaded_mainloop_accept_proc)       (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_get_retval_proc)   (ma_pa_threaded_mainloop* m);
-typedef ma_pa_mainloop_api*      (* ma_pa_threaded_mainloop_get_api_proc)      (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_in_thread_proc)    (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_set_name_proc)     (ma_pa_threaded_mainloop* m, const char* name);
-typedef ma_pa_context*           (* ma_pa_context_new_proc)                    (ma_pa_mainloop_api* mainloop, const char* name);
-typedef void                     (* ma_pa_context_unref_proc)                  (ma_pa_context* c);
-typedef int                      (* ma_pa_context_connect_proc)                (ma_pa_context* c, const char* server, ma_pa_context_flags_t flags, const ma_pa_spawn_api* api);
-typedef void                     (* ma_pa_context_disconnect_proc)             (ma_pa_context* c);
-typedef void                     (* ma_pa_context_set_state_callback_proc)     (ma_pa_context* c, ma_pa_context_notify_cb_t cb, void* userdata);
-typedef ma_pa_context_state_t    (* ma_pa_context_get_state_proc)              (ma_pa_context* c);
-typedef ma_pa_operation*         (* ma_pa_context_get_sink_info_list_proc)     (ma_pa_context* c, ma_pa_sink_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_source_info_list_proc)   (ma_pa_context* c, ma_pa_source_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_sink_info_by_name_proc)  (ma_pa_context* c, const char* name, ma_pa_sink_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_source_info_by_name_proc)(ma_pa_context* c, const char* name, ma_pa_source_info_cb_t cb, void* userdata);
-typedef void                     (* ma_pa_operation_unref_proc)                (ma_pa_operation* o);
-typedef ma_pa_operation_state_t  (* ma_pa_operation_get_state_proc)            (ma_pa_operation* o);
-typedef ma_pa_channel_map*       (* ma_pa_channel_map_init_extend_proc)        (ma_pa_channel_map* m, unsigned channels, ma_pa_channel_map_def_t def);
-typedef int                      (* ma_pa_channel_map_valid_proc)              (const ma_pa_channel_map* m);
-typedef int                      (* ma_pa_channel_map_compatible_proc)         (const ma_pa_channel_map* m, const ma_pa_sample_spec* ss);
-typedef ma_pa_stream*            (* ma_pa_stream_new_proc)                     (ma_pa_context* c, const char* name, const ma_pa_sample_spec* ss, const ma_pa_channel_map* map);
-typedef void                     (* ma_pa_stream_unref_proc)                   (ma_pa_stream* s);
-typedef int                      (* ma_pa_stream_connect_playback_proc)        (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags, const ma_pa_cvolume* volume, ma_pa_stream* sync_stream);
-typedef int                      (* ma_pa_stream_connect_record_proc)          (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags);
-typedef int                      (* ma_pa_stream_disconnect_proc)              (ma_pa_stream* s);
-typedef ma_pa_stream_state_t     (* ma_pa_stream_get_state_proc)               (ma_pa_stream* s);
-typedef const ma_pa_sample_spec* (* ma_pa_stream_get_sample_spec_proc)         (ma_pa_stream* s);
-typedef const ma_pa_channel_map* (* ma_pa_stream_get_channel_map_proc)         (ma_pa_stream* s);
-typedef const ma_pa_buffer_attr* (* ma_pa_stream_get_buffer_attr_proc)         (ma_pa_stream* s);
-typedef ma_pa_operation*         (* ma_pa_stream_set_buffer_attr_proc)         (ma_pa_stream* s, const ma_pa_buffer_attr* attr, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef const char*              (* ma_pa_stream_get_device_name_proc)         (ma_pa_stream* s);
-typedef void                     (* ma_pa_stream_set_write_callback_proc)      (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata);
-typedef void                     (* ma_pa_stream_set_read_callback_proc)       (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_flush_proc)                   (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_drain_proc)                   (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef int                      (* ma_pa_stream_is_corked_proc)               (ma_pa_stream* s);
-typedef ma_pa_operation*         (* ma_pa_stream_cork_proc)                    (ma_pa_stream* s, int b, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_trigger_proc)                 (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef int                      (* ma_pa_stream_begin_write_proc)             (ma_pa_stream* s, void** data, size_t* nbytes);
-typedef int                      (* ma_pa_stream_write_proc)                   (ma_pa_stream* s, const void* data, size_t nbytes, ma_pa_free_cb_t free_cb, int64_t offset, ma_pa_seek_mode_t seek);
-typedef int                      (* ma_pa_stream_peek_proc)                    (ma_pa_stream* s, const void** data, size_t* nbytes);
-typedef int                      (* ma_pa_stream_drop_proc)                    (ma_pa_stream* s);
-typedef size_t                   (* ma_pa_stream_writable_size_proc)           (ma_pa_stream* s);
-typedef size_t                   (* ma_pa_stream_readable_size_proc)           (ma_pa_stream* s);
-
-typedef struct
-{
-    ma_uint32 count;
-    ma_uint32 capacity;
-    ma_device_info* pInfo;
-} ma_pulse_device_enum_data;
-
-static ma_result ma_result_from_pulse(int result)
-{
-    if (result < 0) {
-        return MA_ERROR;
-    }
-
-    switch (result) {
-        case MA_PA_OK:           return MA_SUCCESS;
-        case MA_PA_ERR_ACCESS:   return MA_ACCESS_DENIED;
-        case MA_PA_ERR_INVALID:  return MA_INVALID_ARGS;
-        case MA_PA_ERR_NOENTITY: return MA_NO_DEVICE;
-        default:                 return MA_ERROR;
-    }
-}
-
-#if 0
-static ma_pa_sample_format_t ma_format_to_pulse(ma_format format)
-{
-    if (ma_is_little_endian()) {
-        switch (format) {
-            case ma_format_s16: return MA_PA_SAMPLE_S16LE;
-            case ma_format_s24: return MA_PA_SAMPLE_S24LE;
-            case ma_format_s32: return MA_PA_SAMPLE_S32LE;
-            case ma_format_f32: return MA_PA_SAMPLE_FLOAT32LE;
-            default: break;
-        }
-    } else {
-        switch (format) {
-            case ma_format_s16: return MA_PA_SAMPLE_S16BE;
-            case ma_format_s24: return MA_PA_SAMPLE_S24BE;
-            case ma_format_s32: return MA_PA_SAMPLE_S32BE;
-            case ma_format_f32: return MA_PA_SAMPLE_FLOAT32BE;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (format) {
-        case ma_format_u8: return MA_PA_SAMPLE_U8;
-        default: return MA_PA_SAMPLE_INVALID;
-    }
-}
-#endif
-
-static ma_format ma_format_from_pulse(ma_pa_sample_format_t format)
-{
-    if (ma_is_little_endian()) {
-        switch (format) {
-            case MA_PA_SAMPLE_S16LE:     return ma_format_s16;
-            case MA_PA_SAMPLE_S24LE:     return ma_format_s24;
-            case MA_PA_SAMPLE_S32LE:     return ma_format_s32;
-            case MA_PA_SAMPLE_FLOAT32LE: return ma_format_f32;
-            default: break;
-        }
-    } else {
-        switch (format) {
-            case MA_PA_SAMPLE_S16BE:     return ma_format_s16;
-            case MA_PA_SAMPLE_S24BE:     return ma_format_s24;
-            case MA_PA_SAMPLE_S32BE:     return ma_format_s32;
-            case MA_PA_SAMPLE_FLOAT32BE: return ma_format_f32;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (format) {
-        case MA_PA_SAMPLE_U8: return ma_format_u8;
-        default: return ma_format_unknown;
-    }
-}
-
-static ma_channel ma_channel_position_from_pulse(ma_pa_channel_position_t position)
-{
-    switch (position)
-    {
-        case MA_PA_CHANNEL_POSITION_INVALID:               return MA_CHANNEL_NONE;
-        case MA_PA_CHANNEL_POSITION_MONO:                  return MA_CHANNEL_MONO;
-        case MA_PA_CHANNEL_POSITION_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case MA_PA_CHANNEL_POSITION_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case MA_PA_CHANNEL_POSITION_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case MA_PA_CHANNEL_POSITION_REAR_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case MA_PA_CHANNEL_POSITION_REAR_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case MA_PA_CHANNEL_POSITION_REAR_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case MA_PA_CHANNEL_POSITION_LFE:                   return MA_CHANNEL_LFE;
-        case MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case MA_PA_CHANNEL_POSITION_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case MA_PA_CHANNEL_POSITION_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case MA_PA_CHANNEL_POSITION_AUX0:                  return MA_CHANNEL_AUX_0;
-        case MA_PA_CHANNEL_POSITION_AUX1:                  return MA_CHANNEL_AUX_1;
-        case MA_PA_CHANNEL_POSITION_AUX2:                  return MA_CHANNEL_AUX_2;
-        case MA_PA_CHANNEL_POSITION_AUX3:                  return MA_CHANNEL_AUX_3;
-        case MA_PA_CHANNEL_POSITION_AUX4:                  return MA_CHANNEL_AUX_4;
-        case MA_PA_CHANNEL_POSITION_AUX5:                  return MA_CHANNEL_AUX_5;
-        case MA_PA_CHANNEL_POSITION_AUX6:                  return MA_CHANNEL_AUX_6;
-        case MA_PA_CHANNEL_POSITION_AUX7:                  return MA_CHANNEL_AUX_7;
-        case MA_PA_CHANNEL_POSITION_AUX8:                  return MA_CHANNEL_AUX_8;
-        case MA_PA_CHANNEL_POSITION_AUX9:                  return MA_CHANNEL_AUX_9;
-        case MA_PA_CHANNEL_POSITION_AUX10:                 return MA_CHANNEL_AUX_10;
-        case MA_PA_CHANNEL_POSITION_AUX11:                 return MA_CHANNEL_AUX_11;
-        case MA_PA_CHANNEL_POSITION_AUX12:                 return MA_CHANNEL_AUX_12;
-        case MA_PA_CHANNEL_POSITION_AUX13:                 return MA_CHANNEL_AUX_13;
-        case MA_PA_CHANNEL_POSITION_AUX14:                 return MA_CHANNEL_AUX_14;
-        case MA_PA_CHANNEL_POSITION_AUX15:                 return MA_CHANNEL_AUX_15;
-        case MA_PA_CHANNEL_POSITION_AUX16:                 return MA_CHANNEL_AUX_16;
-        case MA_PA_CHANNEL_POSITION_AUX17:                 return MA_CHANNEL_AUX_17;
-        case MA_PA_CHANNEL_POSITION_AUX18:                 return MA_CHANNEL_AUX_18;
-        case MA_PA_CHANNEL_POSITION_AUX19:                 return MA_CHANNEL_AUX_19;
-        case MA_PA_CHANNEL_POSITION_AUX20:                 return MA_CHANNEL_AUX_20;
-        case MA_PA_CHANNEL_POSITION_AUX21:                 return MA_CHANNEL_AUX_21;
-        case MA_PA_CHANNEL_POSITION_AUX22:                 return MA_CHANNEL_AUX_22;
-        case MA_PA_CHANNEL_POSITION_AUX23:                 return MA_CHANNEL_AUX_23;
-        case MA_PA_CHANNEL_POSITION_AUX24:                 return MA_CHANNEL_AUX_24;
-        case MA_PA_CHANNEL_POSITION_AUX25:                 return MA_CHANNEL_AUX_25;
-        case MA_PA_CHANNEL_POSITION_AUX26:                 return MA_CHANNEL_AUX_26;
-        case MA_PA_CHANNEL_POSITION_AUX27:                 return MA_CHANNEL_AUX_27;
-        case MA_PA_CHANNEL_POSITION_AUX28:                 return MA_CHANNEL_AUX_28;
-        case MA_PA_CHANNEL_POSITION_AUX29:                 return MA_CHANNEL_AUX_29;
-        case MA_PA_CHANNEL_POSITION_AUX30:                 return MA_CHANNEL_AUX_30;
-        case MA_PA_CHANNEL_POSITION_AUX31:                 return MA_CHANNEL_AUX_31;
-        case MA_PA_CHANNEL_POSITION_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        default: return MA_CHANNEL_NONE;
-    }
-}
-
-#if 0
-static ma_pa_channel_position_t ma_channel_position_to_pulse(ma_channel position)
-{
-    switch (position)
-    {
-        case MA_CHANNEL_NONE:               return MA_PA_CHANNEL_POSITION_INVALID;
-        case MA_CHANNEL_FRONT_LEFT:         return MA_PA_CHANNEL_POSITION_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return MA_PA_CHANNEL_POSITION_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return MA_PA_CHANNEL_POSITION_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return MA_PA_CHANNEL_POSITION_LFE;
-        case MA_CHANNEL_BACK_LEFT:          return MA_PA_CHANNEL_POSITION_REAR_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return MA_PA_CHANNEL_POSITION_REAR_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return MA_PA_CHANNEL_POSITION_REAR_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return MA_PA_CHANNEL_POSITION_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return MA_PA_CHANNEL_POSITION_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return MA_PA_CHANNEL_POSITION_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT;
-        case MA_CHANNEL_19:                 return MA_PA_CHANNEL_POSITION_AUX18;
-        case MA_CHANNEL_20:                 return MA_PA_CHANNEL_POSITION_AUX19;
-        case MA_CHANNEL_21:                 return MA_PA_CHANNEL_POSITION_AUX20;
-        case MA_CHANNEL_22:                 return MA_PA_CHANNEL_POSITION_AUX21;
-        case MA_CHANNEL_23:                 return MA_PA_CHANNEL_POSITION_AUX22;
-        case MA_CHANNEL_24:                 return MA_PA_CHANNEL_POSITION_AUX23;
-        case MA_CHANNEL_25:                 return MA_PA_CHANNEL_POSITION_AUX24;
-        case MA_CHANNEL_26:                 return MA_PA_CHANNEL_POSITION_AUX25;
-        case MA_CHANNEL_27:                 return MA_PA_CHANNEL_POSITION_AUX26;
-        case MA_CHANNEL_28:                 return MA_PA_CHANNEL_POSITION_AUX27;
-        case MA_CHANNEL_29:                 return MA_PA_CHANNEL_POSITION_AUX28;
-        case MA_CHANNEL_30:                 return MA_PA_CHANNEL_POSITION_AUX29;
-        case MA_CHANNEL_31:                 return MA_PA_CHANNEL_POSITION_AUX30;
-        case MA_CHANNEL_32:                 return MA_PA_CHANNEL_POSITION_AUX31;
-        default: return (ma_pa_channel_position_t)position;
-    }
-}
-#endif
-
-static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_pa_operation* pOP)
-{
-    int resultPA;
-    ma_pa_operation_state_t state;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pOP != NULL);
-
-    for (;;) {
-        state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP);
-        if (state != MA_PA_OPERATION_RUNNING) {
-            break;  /* Done. */
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_wait_for_operation_and_unref__pulse(ma_context* pContext, ma_pa_operation* pOP)
-{
-    ma_result result;
-
-    if (pOP == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_wait_for_operation__pulse(pContext, pOP);
-    ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-    return result;
-}
-
-static ma_result ma_context_wait_for_pa_context_to_connect__pulse(ma_context* pContext)
-{
-    int resultPA;
-    ma_pa_context_state_t state;
-
-    for (;;) {
-        state = ((ma_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)((ma_pa_context*)pContext->pulse.pPulseContext);
-        if (state == MA_PA_CONTEXT_READY) {
-            break;  /* Done. */
-        }
-
-        if (state == MA_PA_CONTEXT_FAILED || state == MA_PA_CONTEXT_TERMINATED) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio context.", MA_ERROR);
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    /* Should never get here. */
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, ma_pa_stream* pStream)
-{
-    int resultPA;
-    ma_pa_stream_state_t state;
-
-    for (;;) {
-        state = ((ma_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)(pStream);
-        if (state == MA_PA_STREAM_READY) {
-            break;  /* Done. */
-        }
-
-        if (state == MA_PA_STREAM_FAILED || state == MA_PA_STREAM_TERMINATED) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio stream.", MA_ERROR);
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static void ma_device_sink_info_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_pa_sink_info* pInfoOut;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pInfoOut = (ma_pa_sink_info*)pUserData;
-    MA_ASSERT(pInfoOut != NULL);
-
-    *pInfoOut = *pInfo;
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_source_info_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_pa_source_info* pInfoOut;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pInfoOut = (ma_pa_source_info*)pUserData;
-    MA_ASSERT(pInfoOut != NULL);
-
-    *pInfoOut = *pInfo;
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_sink_name_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_device* pDevice;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), pInfo->description, (size_t)-1);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_source_name_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_device* pDevice;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), pInfo->description, (size_t)-1);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-
-static ma_result ma_context_get_sink_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_sink_info* pSinkInfo)
-{
-    ma_pa_operation* pOP;
-
-    pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_sink_info_callback, pSinkInfo);
-    if (pOP == NULL) {
-        return MA_ERROR;
-    }
-
-    return ma_wait_for_operation_and_unref__pulse(pContext, pOP);
-}
-
-static ma_result ma_context_get_source_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_source_info* pSourceInfo)
-{
-    ma_pa_operation* pOP;
-
-    pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_source_info_callback, pSourceInfo);
-    if (pOP == NULL) {
-        return MA_ERROR;
-    }
-
-    return ma_wait_for_operation_and_unref__pulse(pContext, pOP);;
-}
-
-static ma_result ma_context_get_default_device_index__pulse(ma_context* pContext, ma_device_type deviceType, ma_uint32* pIndex)
-{
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pIndex   != NULL);
-
-    if (pIndex != NULL) {
-        *pIndex = (ma_uint32)-1;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        ma_pa_sink_info sinkInfo;
-        result = ma_context_get_sink_info__pulse(pContext, NULL, &sinkInfo);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (pIndex != NULL) {
-            *pIndex = sinkInfo.index;
-        }
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        ma_pa_source_info sourceInfo;
-        result = ma_context_get_source_info__pulse(pContext, NULL, &sourceInfo);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (pIndex != NULL) {
-            *pIndex = sourceInfo.index;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_context* pContext;
-    ma_enum_devices_callback_proc callback;
-    void* pUserData;
-    ma_bool32 isTerminated;
-    ma_uint32 defaultDeviceIndexPlayback;
-    ma_uint32 defaultDeviceIndexCapture;
-} ma_context_enumerate_devices_callback_data__pulse;
-
-static void ma_context_enumerate_devices_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pSinkInfo, int endOfList, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData;
-    ma_device_info deviceInfo;
-
-    MA_ASSERT(pData != NULL);
-
-    if (endOfList || pData->isTerminated) {
-        return;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* The name from PulseAudio is the ID for miniaudio. */
-    if (pSinkInfo->name != NULL) {
-        ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSinkInfo->name, (size_t)-1);
-    }
-
-    /* The description from PulseAudio is the name for miniaudio. */
-    if (pSinkInfo->description != NULL) {
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSinkInfo->description, (size_t)-1);
-    }
-
-    if (pSinkInfo->index == pData->defaultDeviceIndexPlayback) {
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_playback, &deviceInfo, pData->pUserData);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_context_enumerate_devices_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pSourceInfo, int endOfList, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData;
-    ma_device_info deviceInfo;
-
-    MA_ASSERT(pData != NULL);
-
-    if (endOfList || pData->isTerminated) {
-        return;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* The name from PulseAudio is the ID for miniaudio. */
-    if (pSourceInfo->name != NULL) {
-        ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSourceInfo->name, (size_t)-1);
-    }
-
-    /* The description from PulseAudio is the name for miniaudio. */
-    if (pSourceInfo->description != NULL) {
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSourceInfo->description, (size_t)-1);
-    }
-
-    if (pSourceInfo->index == pData->defaultDeviceIndexCapture) {
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_capture, &deviceInfo, pData->pUserData);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result = MA_SUCCESS;
-    ma_context_enumerate_devices_callback_data__pulse callbackData;
-    ma_pa_operation* pOP = NULL;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    callbackData.pContext = pContext;
-    callbackData.callback = callback;
-    callbackData.pUserData = pUserData;
-    callbackData.isTerminated = MA_FALSE;
-    callbackData.defaultDeviceIndexPlayback = (ma_uint32)-1;
-    callbackData.defaultDeviceIndexCapture  = (ma_uint32)-1;
-
-    /* We need to get the index of the default devices. */
-    ma_context_get_default_device_index__pulse(pContext, ma_device_type_playback, &callbackData.defaultDeviceIndexPlayback);
-    ma_context_get_default_device_index__pulse(pContext, ma_device_type_capture,  &callbackData.defaultDeviceIndexCapture);
-
-    /* Playback. */
-    if (!callbackData.isTerminated) {
-        pOP = ((ma_pa_context_get_sink_info_list_proc)pContext->pulse.pa_context_get_sink_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_sink_callback__pulse, &callbackData);
-        if (pOP == NULL) {
-            result = MA_ERROR;
-            goto done;
-        }
-
-        result = ma_wait_for_operation__pulse(pContext, pOP);
-        ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-        if (result != MA_SUCCESS) {
-            goto done;
-        }
-    }
-
-
-    /* Capture. */
-    if (!callbackData.isTerminated) {
-        pOP = ((ma_pa_context_get_source_info_list_proc)pContext->pulse.pa_context_get_source_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_source_callback__pulse, &callbackData);
-        if (pOP == NULL) {
-            result = MA_ERROR;
-            goto done;
-        }
-
-        result = ma_wait_for_operation__pulse(pContext, pOP);
-        ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-        if (result != MA_SUCCESS) {
-            goto done;
-        }
-    }
-
-done:
-    return result;
-}
-
-
-typedef struct
-{
-    ma_device_info* pDeviceInfo;
-    ma_uint32 defaultDeviceIndex;
-    ma_bool32 foundDevice;
-} ma_context_get_device_info_callback_data__pulse;
-
-static void ma_context_get_device_info_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    MA_ASSERT(pData != NULL);
-    pData->foundDevice = MA_TRUE;
-
-    if (pInfo->name != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1);
-    }
-
-    if (pInfo->description != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1);
-    }
-
-    /*
-    We're just reporting a single data format here. I think technically PulseAudio might support
-    all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to
-    report the "native" device format.
-    */
-    pData->pDeviceInfo->nativeDataFormats[0].format     = ma_format_from_pulse(pInfo->sample_spec.format);
-    pData->pDeviceInfo->nativeDataFormats[0].channels   = pInfo->sample_spec.channels;
-    pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate;
-    pData->pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pData->pDeviceInfo->nativeDataFormatCount = 1;
-
-    if (pData->defaultDeviceIndex == pInfo->index) {
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_context_get_device_info_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    MA_ASSERT(pData != NULL);
-    pData->foundDevice = MA_TRUE;
-
-    if (pInfo->name != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1);
-    }
-
-    if (pInfo->description != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1);
-    }
-
-    /*
-    We're just reporting a single data format here. I think technically PulseAudio might support
-    all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to
-    report the "native" device format.
-    */
-    pData->pDeviceInfo->nativeDataFormats[0].format     = ma_format_from_pulse(pInfo->sample_spec.format);
-    pData->pDeviceInfo->nativeDataFormats[0].channels   = pInfo->sample_spec.channels;
-    pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate;
-    pData->pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pData->pDeviceInfo->nativeDataFormatCount = 1;
-
-    if (pData->defaultDeviceIndex == pInfo->index) {
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result = MA_SUCCESS;
-    ma_context_get_device_info_callback_data__pulse callbackData;
-    ma_pa_operation* pOP = NULL;
-
-    MA_ASSERT(pContext != NULL);
-
-    callbackData.pDeviceInfo = pDeviceInfo;
-    callbackData.foundDevice = MA_FALSE;
-
-    result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
-
-    if (deviceType == ma_device_type_playback) {
-        pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_sink_callback__pulse, &callbackData);
-    } else {
-        pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_source_callback__pulse, &callbackData);
-    }
-
-    if (pOP != NULL) {
-        ma_wait_for_operation_and_unref__pulse(pContext, pOP);
-    } else {
-        result = MA_ERROR;
-        goto done;
-    }
-
-    if (!callbackData.foundDevice) {
-        result = MA_NO_DEVICE;
-        goto done;
-    }
-
-done:
-    return result;
-}
-
-static ma_result ma_device_uninit__pulse(ma_device* pDevice)
-{
-    ma_context* pContext;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-
-    if (pDevice->type == ma_device_type_duplex) {
-        ma_duplex_rb_uninit(&pDevice->duplexRB);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_pa_buffer_attr ma_device__pa_buffer_attr_new(ma_uint32 periodSizeInFrames, ma_uint32 periods, const ma_pa_sample_spec* ss)
-{
-    ma_pa_buffer_attr attr;
-    attr.maxlength = periodSizeInFrames * periods * ma_get_bytes_per_frame(ma_format_from_pulse(ss->format), ss->channels);
-    attr.tlength   = attr.maxlength / periods;
-    attr.prebuf    = (ma_uint32)-1;
-    attr.minreq    = (ma_uint32)-1;
-    attr.fragsize  = attr.maxlength / periods;
-
-    return attr;
-}
-
-static ma_pa_stream* ma_context__pa_stream_new__pulse(ma_context* pContext, const char* pStreamName, const ma_pa_sample_spec* ss, const ma_pa_channel_map* cmap)
-{
-    static int g_StreamCounter = 0;
-    char actualStreamName[256];
-
-    if (pStreamName != NULL) {
-        ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1);
-    } else {
-        ma_strcpy_s(actualStreamName, sizeof(actualStreamName), "miniaudio:");
-        ma_itoa_s(g_StreamCounter, actualStreamName + 8, sizeof(actualStreamName)-8, 10);  /* 8 = strlen("miniaudio:") */
-    }
-    g_StreamCounter += 1;
-
-    return ((ma_pa_stream_new_proc)pContext->pulse.pa_stream_new)((ma_pa_context*)pContext->pulse.pPulseContext, actualStreamName, ss, cmap);
-}
-
-
-static void ma_device_on_read__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_uint32 bpf;
-    ma_uint64 frameCount;
-    ma_uint64 framesProcessed;
-
-    MA_ASSERT(pDevice != NULL);
-
-    bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    frameCount = byteCount / bpf;
-    framesProcessed = 0;
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && framesProcessed < frameCount) {
-        const void* pMappedPCMFrames;
-        size_t bytesMapped;
-        ma_uint64 framesMapped;
-
-        int pulseResult = ((ma_pa_stream_peek_proc)pDevice->pContext->pulse.pa_stream_peek)(pStream, &pMappedPCMFrames, &bytesMapped);
-        if (pulseResult < 0) {
-            break; /* Failed to map. Abort. */
-        }
-
-        framesMapped = bytesMapped / bpf;
-        if (framesMapped > 0) {
-            if (pMappedPCMFrames != NULL) {
-                ma_device_handle_backend_data_callback(pDevice, NULL, pMappedPCMFrames, framesMapped);
-            } else {
-                /* It's a hole. */
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("[PulseAudio] ma_device_on_read__pulse: Hole.\n");
-            #endif
-            }
-
-            pulseResult = ((ma_pa_stream_drop_proc)pDevice->pContext->pulse.pa_stream_drop)(pStream);
-            if (pulseResult < 0) {
-                break;  /* Failed to drop the buffer. */
-            }
-
-            framesProcessed += framesMapped;
-
-        } else {
-            /* Nothing was mapped. Just abort. */
-            break;
-        }
-    }
-}
-
-static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stream* pStream, ma_uint64* pFramesProcessed)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint64 framesProcessed = 0;
-    size_t bytesMapped;
-    ma_uint32 bpf;
-    ma_uint32 deviceState;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pStream != NULL);
-
-    bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    deviceState = ma_device_get_state(pDevice);
-
-    bytesMapped = ((ma_pa_stream_writable_size_proc)pDevice->pContext->pulse.pa_stream_writable_size)(pStream);
-    if (bytesMapped != (size_t)-1) {
-        if (bytesMapped > 0) {
-            ma_uint64 framesMapped;
-            void* pMappedPCMFrames;
-            int pulseResult = ((ma_pa_stream_begin_write_proc)pDevice->pContext->pulse.pa_stream_begin_write)(pStream, &pMappedPCMFrames, &bytesMapped);
-            if (pulseResult < 0) {
-                result = ma_result_from_pulse(pulseResult);
-                goto done;
-            }
-
-            framesMapped = bytesMapped / bpf;
-
-            if (deviceState == MA_STATE_STARTED) {
-                ma_device_handle_backend_data_callback(pDevice, pMappedPCMFrames, NULL, framesMapped);
-            } else {
-                /* Device is not started. Don't write anything to it. */
-            }
-
-            pulseResult = ((ma_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)(pStream, pMappedPCMFrames, bytesMapped, NULL, 0, MA_PA_SEEK_RELATIVE);
-            if (pulseResult < 0) {
-                result = ma_result_from_pulse(pulseResult);
-                goto done;  /* Failed to write data to stream. */
-            }
-
-            framesProcessed += framesMapped;
-        } else {
-            result = MA_ERROR;  /* No data available. Abort. */
-            goto done;
-        }
-    } else {
-        result = MA_ERROR;  /* Failed to retrieve the writable size. Abort. */
-        goto done;
-    }
-
-done:
-    if (pFramesProcessed != NULL) {
-        *pFramesProcessed = framesProcessed;
-    }
-
-    return result;
-}
-
-static void ma_device_on_write__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_uint32 bpf;
-    ma_uint64 frameCount;
-    ma_uint64 framesProcessed;
-    ma_uint32 deviceState;
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio
-    can fire this callback before the stream has even started. Ridiculous.
-    */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTING && deviceState != MA_STATE_STARTED) {
-        return;
-    }
-
-    bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    frameCount = byteCount / bpf;
-    framesProcessed = 0;
-
-    while (framesProcessed < frameCount) {
-        ma_uint64 framesProcessedThisIteration;
-
-        /* Don't keep trying to process frames if the device isn't started. */
-        deviceState = ma_device_get_state(pDevice);
-        if (deviceState != MA_STATE_STARTING && deviceState != MA_STATE_STARTED) {
-            break;
-        }
-
-        result = ma_device_write_to_stream__pulse(pDevice, pStream, &framesProcessedThisIteration);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        framesProcessed += framesProcessedThisIteration;
-    }
-}
-
-static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    /*
-    Notes for PulseAudio:
-
-      - We're always using native format/channels/rate regardless of whether or not PulseAudio
-        supports the format directly through their own data conversion system. I'm doing this to
-        reduce as much variability from the PulseAudio side as possible because it's seems to be
-        extremely unreliable at everything it does.
-
-      - When both the period size in frames and milliseconds are 0, we default to miniaudio's
-        default buffer sizes rather than leaving it up to PulseAudio because I don't trust
-        PulseAudio to give us any kind of reasonable latency by default.
-
-      - Do not ever, *ever* forget to use MA_PA_STREAM_ADJUST_LATENCY. If you don't specify this
-        flag, capture mode will just not work properly until you open another PulseAudio app.
-    */
-
-    ma_result result = MA_SUCCESS;
-    int error = 0;
-    const char* devPlayback = NULL;
-    const char* devCapture  = NULL;
-    ma_format format = ma_format_unknown;
-    ma_uint32 channels = 0;
-    ma_uint32 sampleRate = 0;
-    ma_pa_sink_info sinkInfo;
-    ma_pa_source_info sourceInfo;
-    ma_pa_sample_spec ss;
-    ma_pa_channel_map cmap;
-    ma_pa_buffer_attr attr;
-    const ma_pa_sample_spec* pActualSS   = NULL;
-    const ma_pa_channel_map* pActualCMap = NULL;
-    const ma_pa_buffer_attr* pActualAttr = NULL;
-    ma_uint32 iChannel;
-    ma_pa_stream_flags_t streamFlags;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ZERO_OBJECT(&pDevice->pulse);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with the PulseAudio backend. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        if (pDescriptorPlayback->pDeviceID != NULL) {
-            devPlayback = pDescriptorPlayback->pDeviceID->pulse;
-        }
-
-        format     = pDescriptorPlayback->format;
-        channels   = pDescriptorPlayback->channels;
-        sampleRate = pDescriptorPlayback->sampleRate;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) {
-        if (pDescriptorCapture->pDeviceID != NULL) {
-            devCapture = pDescriptorCapture->pDeviceID->pulse;
-        }
-        
-        format     = pDescriptorCapture->format;
-        channels   = pDescriptorCapture->channels;
-        sampleRate = pDescriptorCapture->sampleRate;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_context_get_source_info__pulse(pDevice->pContext, devCapture, &sourceInfo);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve source info for capture device.", result);
-            goto on_error0;
-        }
-
-        ss   = sourceInfo.sample_spec;
-        cmap = sourceInfo.channel_map;
-
-        /* We now have enough information to calculate our actual period size in frames. */
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, ss.rate, pConfig->performanceProfile);
-
-        attr = ma_device__pa_buffer_attr_new(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->periodCount, &ss);
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
-    #endif
-
-        pDevice->pulse.pStreamCapture = ma_context__pa_stream_new__pulse(pDevice->pContext, pConfig->pulse.pStreamNameCapture, &ss, &cmap);
-        if (pDevice->pulse.pStreamCapture == NULL) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            goto on_error0;
-        }
-
-
-        /* The callback needs to be set before connecting the stream. */
-        ((ma_pa_stream_set_read_callback_proc)pDevice->pContext->pulse.pa_stream_set_read_callback)((ma_pa_stream*)pDevice->pulse.pStreamCapture, ma_device_on_read__pulse, pDevice);
-
-
-        /* Connect after we've got all of our internal state set up. */
-        streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS;
-        if (devCapture != NULL) {
-            streamFlags |= MA_PA_STREAM_DONT_MOVE;
-        }
-
-        error = ((ma_pa_stream_connect_record_proc)pDevice->pContext->pulse.pa_stream_connect_record)((ma_pa_stream*)pDevice->pulse.pStreamCapture, devCapture, &attr, streamFlags);
-        if (error != MA_PA_OK) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio capture stream.", ma_result_from_pulse(error));
-            goto on_error1;
-        }
-
-        result = ma_context_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, (ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            goto on_error2;
-        }
-
-        /* Internal format. */
-        pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualSS != NULL) {
-            ss = *pActualSS;
-        }
-
-        pDescriptorCapture->format     = ma_format_from_pulse(ss.format);
-        pDescriptorCapture->channels   = ss.channels;
-        pDescriptorCapture->sampleRate = ss.rate;
-
-        /* Internal channel map. */
-        pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualCMap != NULL) {
-            cmap = *pActualCMap;
-        }
-
-        for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-            pDescriptorCapture->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
-        }
-
-
-        /* Buffer. */
-        pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualAttr != NULL) {
-            attr = *pActualAttr;
-        }
-
-        pDescriptorCapture->periodCount        = attr.maxlength / attr.fragsize;
-        pDescriptorCapture->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / pDescriptorCapture->periodCount;
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Capture actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
-    #endif
-
-
-        /* Name. */
-        devCapture = ((ma_pa_stream_get_device_name_proc)pDevice->pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (devCapture != NULL) {
-            ma_pa_operation* pOP = ((ma_pa_context_get_source_info_by_name_proc)pDevice->pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pDevice->pContext->pulse.pPulseContext, devCapture, ma_device_source_name_callback, pDevice);
-            ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_context_get_sink_info__pulse(pDevice->pContext, devPlayback, &sinkInfo);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve sink info for playback device.", result);
-            goto on_error2;
-        }
-
-        ss   = sinkInfo.sample_spec;
-        cmap = sinkInfo.channel_map;
-
-        /* We now have enough information to calculate the actual buffer size in frames. */
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, ss.rate, pConfig->performanceProfile);
-
-        attr = ma_device__pa_buffer_attr_new(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->periodCount, &ss);
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Playback attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames);
-    #endif
-
-        pDevice->pulse.pStreamPlayback = ma_context__pa_stream_new__pulse(pDevice->pContext, pConfig->pulse.pStreamNamePlayback, &ss, &cmap);
-        if (pDevice->pulse.pStreamPlayback == NULL) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            goto on_error2;
-        }
-
-
-        /*
-        Note that this callback will be fired as soon as the stream is connected, even though it's started as corked. The callback needs to handle a
-        device state of MA_STATE_UNINITIALIZED.
-        */
-        ((ma_pa_stream_set_write_callback_proc)pDevice->pContext->pulse.pa_stream_set_write_callback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_device_on_write__pulse, pDevice);
-
-
-        /* Connect after we've got all of our internal state set up. */
-        streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS;
-        if (devPlayback != NULL) {
-            streamFlags |= MA_PA_STREAM_DONT_MOVE;
-        }
-
-        error = ((ma_pa_stream_connect_playback_proc)pDevice->pContext->pulse.pa_stream_connect_playback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, streamFlags, NULL, NULL);
-        if (error != MA_PA_OK) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream.", ma_result_from_pulse(error));
-            goto on_error3;
-        }
-
-        result = ma_context_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, (ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            goto on_error3;
-        }
-
-
-        /* Internal format. */
-        pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualSS != NULL) {
-            ss = *pActualSS;
-        }
-
-        pDescriptorPlayback->format     = ma_format_from_pulse(ss.format);
-        pDescriptorPlayback->channels   = ss.channels;
-        pDescriptorPlayback->sampleRate = ss.rate;
-
-        /* Internal channel map. */
-        pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualCMap != NULL) {
-            cmap = *pActualCMap;
-        }
-
-        for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-            pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
-        }
-
-
-        /* Buffer. */
-        pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualAttr != NULL) {
-            attr = *pActualAttr;
-        }
-
-        pDescriptorPlayback->periodCount        = attr.maxlength / attr.tlength;
-        pDescriptorPlayback->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) / pDescriptorPlayback->periodCount;
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Playback actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalPeriodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->playback.internalPeriodSizeInFrames);
-    #endif
-
-
-        /* Name. */
-        devPlayback = ((ma_pa_stream_get_device_name_proc)pDevice->pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (devPlayback != NULL) {
-            ma_pa_operation* pOP = ((ma_pa_context_get_sink_info_by_name_proc)pDevice->pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pDevice->pContext->pulse.pPulseContext, devPlayback, ma_device_sink_name_callback, pDevice);
-            ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-        }
-    }
-
-
-    /*
-    We need a ring buffer for handling duplex mode. We can use the main duplex ring buffer in the main
-    part of the ma_device struct. We cannot, however, depend on ma_device_init() initializing this for
-    us later on because that will only do it if it's a fully asynchronous backend - i.e. the
-    onDeviceDataLoop callback is NULL, which is not the case for PulseAudio.
-    */
-    if (pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_duplex_rb_init(format, channels, sampleRate, pDescriptorCapture->sampleRate, pDescriptorCapture->periodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
-        if (result != MA_SUCCESS) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize ring buffer.", result);
-            goto on_error4;
-        }
-    }
-
-    return MA_SUCCESS;
-
-
-on_error4:
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-on_error3:
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-on_error2:
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-on_error1:
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-on_error0:
-    return result;
-}
-
-
-static void ma_pulse_operation_complete_callback(ma_pa_stream* pStream, int success, void* pUserData)
-{
-    ma_bool32* pIsSuccessful = (ma_bool32*)pUserData;
-    MA_ASSERT(pIsSuccessful != NULL);
-
-    *pIsSuccessful = (ma_bool32)success;
-
-    (void)pStream; /* Unused. */
-}
-
-static ma_result ma_device__cork_stream__pulse(ma_device* pDevice, ma_device_type deviceType, int cork)
-{
-    ma_context* pContext = pDevice->pContext;
-    ma_bool32 wasSuccessful;
-    ma_pa_stream* pStream;
-    ma_pa_operation* pOP;
-    ma_result result;
-
-    /* This should not be called with a duplex device type. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    wasSuccessful = MA_FALSE;
-
-    pStream = (ma_pa_stream*)((deviceType == ma_device_type_capture) ? pDevice->pulse.pStreamCapture : pDevice->pulse.pStreamPlayback);
-    MA_ASSERT(pStream != NULL);
-
-    pOP = ((ma_pa_stream_cork_proc)pContext->pulse.pa_stream_cork)(pStream, cork, ma_pulse_operation_complete_callback, &wasSuccessful);
-    if (pOP == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream.", (cork == 0) ? MA_FAILED_TO_START_BACKEND_DEVICE : MA_FAILED_TO_STOP_BACKEND_DEVICE);
-    }
-
-    result = ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while waiting for the PulseAudio stream to cork.", result);
-    }
-
-    if (!wasSuccessful) {
-        if (cork) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to stop PulseAudio stream.", MA_FAILED_TO_STOP_BACKEND_DEVICE);
-        } else {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to start PulseAudio stream.", MA_FAILED_TO_START_BACKEND_DEVICE);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__pulse(ma_device* pDevice)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 0);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* We need to fill some data before uncorking. Not doing this will result in the write callback never getting fired. */
-        result = ma_device_write_to_stream__pulse(pDevice, (ma_pa_stream*)(pDevice->pulse.pStreamPlayback), NULL);
-        if (result != MA_SUCCESS) {
-            return result; /* Failed to write data. Not sure what to do here... Just aborting. */
-        }
-
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 0);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__pulse(ma_device* pDevice)
-{
-    ma_result result;
-    ma_bool32 wasSuccessful;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 1);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* The stream needs to be drained if it's a playback device. */
-        ma_pa_operation* pOP = ((ma_pa_stream_drain_proc)pDevice->pContext->pulse.pa_stream_drain)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_pulse_operation_complete_callback, &wasSuccessful);
-        ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 1);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop__pulse(ma_device* pDevice)
-{
-    int resultPA;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* NOTE: Don't start the device here. It'll be done at a higher level. */
-
-    /*
-    All data is handled through callbacks. All we need to do is iterate over the main loop and let
-    the callbacks deal with it.
-    */
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            break;
-        }
-    }
-
-    /* NOTE: Don't stop the device here. It'll be done at a higher level. */
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop_wakeup__pulse(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ((ma_pa_mainloop_wakeup_proc)pDevice->pContext->pulse.pa_mainloop_wakeup)((ma_pa_mainloop*)pDevice->pContext->pulse.pMainLoop);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__pulse(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_pulseaudio);
-
-    ((ma_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)((ma_pa_context*)pContext->pulse.pPulseContext);
-    ((ma_pa_context_unref_proc)pContext->pulse.pa_context_unref)((ma_pa_context*)pContext->pulse.pPulseContext);
-    ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)pContext->pulse.pMainLoop);
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->pulse.pulseSO);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result;
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libpulseNames[] = {
-        "libpulse.so",
-        "libpulse.so.0"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libpulseNames); ++i) {
-        pContext->pulse.pulseSO = ma_dlopen(pContext, libpulseNames[i]);
-        if (pContext->pulse.pulseSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->pulse.pulseSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->pulse.pa_mainloop_new                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_new");
-    pContext->pulse.pa_mainloop_free                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_free");
-    pContext->pulse.pa_mainloop_quit                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_quit");
-    pContext->pulse.pa_mainloop_get_api                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_get_api");
-    pContext->pulse.pa_mainloop_iterate                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_iterate");
-    pContext->pulse.pa_mainloop_wakeup                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_wakeup");
-    pContext->pulse.pa_threaded_mainloop_new           = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_new");
-    pContext->pulse.pa_threaded_mainloop_free          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_free");
-    pContext->pulse.pa_threaded_mainloop_start         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_start");
-    pContext->pulse.pa_threaded_mainloop_stop          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_stop");
-    pContext->pulse.pa_threaded_mainloop_lock          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_lock");
-    pContext->pulse.pa_threaded_mainloop_unlock        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_unlock");
-    pContext->pulse.pa_threaded_mainloop_wait          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_wait");
-    pContext->pulse.pa_threaded_mainloop_signal        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_signal");
-    pContext->pulse.pa_threaded_mainloop_accept        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_accept");
-    pContext->pulse.pa_threaded_mainloop_get_retval    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_get_retval");
-    pContext->pulse.pa_threaded_mainloop_get_api       = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_get_api");
-    pContext->pulse.pa_threaded_mainloop_in_thread     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_in_thread");
-    pContext->pulse.pa_threaded_mainloop_set_name      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_set_name");
-    pContext->pulse.pa_context_new                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_new");
-    pContext->pulse.pa_context_unref                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_unref");
-    pContext->pulse.pa_context_connect                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_connect");
-    pContext->pulse.pa_context_disconnect              = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_disconnect");
-    pContext->pulse.pa_context_set_state_callback      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_set_state_callback");
-    pContext->pulse.pa_context_get_state               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_state");
-    pContext->pulse.pa_context_get_sink_info_list      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_sink_info_list");
-    pContext->pulse.pa_context_get_source_info_list    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_source_info_list");
-    pContext->pulse.pa_context_get_sink_info_by_name   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_sink_info_by_name");
-    pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_source_info_by_name");
-    pContext->pulse.pa_operation_unref                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_operation_unref");
-    pContext->pulse.pa_operation_get_state             = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_operation_get_state");
-    pContext->pulse.pa_channel_map_init_extend         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_init_extend");
-    pContext->pulse.pa_channel_map_valid               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_valid");
-    pContext->pulse.pa_channel_map_compatible          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_compatible");
-    pContext->pulse.pa_stream_new                      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_new");
-    pContext->pulse.pa_stream_unref                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_unref");
-    pContext->pulse.pa_stream_connect_playback         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_connect_playback");
-    pContext->pulse.pa_stream_connect_record           = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_connect_record");
-    pContext->pulse.pa_stream_disconnect               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_disconnect");
-    pContext->pulse.pa_stream_get_state                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_state");
-    pContext->pulse.pa_stream_get_sample_spec          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_sample_spec");
-    pContext->pulse.pa_stream_get_channel_map          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_channel_map");
-    pContext->pulse.pa_stream_get_buffer_attr          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_buffer_attr");
-    pContext->pulse.pa_stream_set_buffer_attr          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_buffer_attr");
-    pContext->pulse.pa_stream_get_device_name          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_device_name");
-    pContext->pulse.pa_stream_set_write_callback       = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_write_callback");
-    pContext->pulse.pa_stream_set_read_callback        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_read_callback");
-    pContext->pulse.pa_stream_flush                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_flush");
-    pContext->pulse.pa_stream_drain                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_drain");
-    pContext->pulse.pa_stream_is_corked                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_is_corked");
-    pContext->pulse.pa_stream_cork                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_cork");
-    pContext->pulse.pa_stream_trigger                  = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_trigger");
-    pContext->pulse.pa_stream_begin_write              = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_begin_write");
-    pContext->pulse.pa_stream_write                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_write");
-    pContext->pulse.pa_stream_peek                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_peek");
-    pContext->pulse.pa_stream_drop                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_drop");
-    pContext->pulse.pa_stream_writable_size            = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_writable_size");
-    pContext->pulse.pa_stream_readable_size            = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_readable_size");
-#else
-    /* This strange assignment system is just for type safety. */
-    ma_pa_mainloop_new_proc                    _pa_mainloop_new                   = pa_mainloop_new;
-    ma_pa_mainloop_free_proc                   _pa_mainloop_free                  = pa_mainloop_free;
-    ma_pa_mainloop_quit_proc                   _pa_mainloop_quit                  = pa_mainloop_quit;
-    ma_pa_mainloop_get_api_proc                _pa_mainloop_get_api               = pa_mainloop_get_api;
-    ma_pa_mainloop_iterate_proc                _pa_mainloop_iterate               = pa_mainloop_iterate;
-    ma_pa_mainloop_wakeup_proc                 _pa_mainloop_wakeup                = pa_mainloop_wakeup;
-    ma_pa_threaded_mainloop_new_proc           _pa_threaded_mainloop_new          = pa_threaded_mainloop_new;
-    ma_pa_threaded_mainloop_free_proc          _pa_threaded_mainloop_free         = pa_threaded_mainloop_free;
-    ma_pa_threaded_mainloop_start_proc         _pa_threaded_mainloop_start        = pa_threaded_mainloop_start;
-    ma_pa_threaded_mainloop_stop_proc          _pa_threaded_mainloop_stop         = pa_threaded_mainloop_stop;
-    ma_pa_threaded_mainloop_lock_proc          _pa_threaded_mainloop_lock         = pa_threaded_mainloop_lock;
-    ma_pa_threaded_mainloop_unlock_proc        _pa_threaded_mainloop_unlock       = pa_threaded_mainloop_unlock;
-    ma_pa_threaded_mainloop_wait_proc          _pa_threaded_mainloop_wait         = pa_threaded_mainloop_wait;
-    ma_pa_threaded_mainloop_signal_proc        _pa_threaded_mainloop_signal       = pa_threaded_mainloop_signal;
-    ma_pa_threaded_mainloop_accept_proc        _pa_threaded_mainloop_accept       = pa_threaded_mainloop_accept;
-    ma_pa_threaded_mainloop_get_retval_proc    _pa_threaded_mainloop_get_retval   = pa_threaded_mainloop_get_retval;
-    ma_pa_threaded_mainloop_get_api_proc       _pa_threaded_mainloop_get_api      = pa_threaded_mainloop_get_api;
-    ma_pa_threaded_mainloop_in_thread_proc     _pa_threaded_mainloop_in_thread    = pa_threaded_mainloop_in_thread;
-    ma_pa_threaded_mainloop_set_name_proc      _pa_threaded_mainloop_set_name     = pa_threaded_mainloop_set_name;
-    ma_pa_context_new_proc                     _pa_context_new                    = pa_context_new;
-    ma_pa_context_unref_proc                   _pa_context_unref                  = pa_context_unref;
-    ma_pa_context_connect_proc                 _pa_context_connect                = pa_context_connect;
-    ma_pa_context_disconnect_proc              _pa_context_disconnect             = pa_context_disconnect;
-    ma_pa_context_set_state_callback_proc      _pa_context_set_state_callback     = pa_context_set_state_callback;
-    ma_pa_context_get_state_proc               _pa_context_get_state              = pa_context_get_state;
-    ma_pa_context_get_sink_info_list_proc      _pa_context_get_sink_info_list     = pa_context_get_sink_info_list;
-    ma_pa_context_get_source_info_list_proc    _pa_context_get_source_info_list   = pa_context_get_source_info_list;
-    ma_pa_context_get_sink_info_by_name_proc   _pa_context_get_sink_info_by_name  = pa_context_get_sink_info_by_name;
-    ma_pa_context_get_source_info_by_name_proc _pa_context_get_source_info_by_name= pa_context_get_source_info_by_name;
-    ma_pa_operation_unref_proc                 _pa_operation_unref                = pa_operation_unref;
-    ma_pa_operation_get_state_proc             _pa_operation_get_state            = pa_operation_get_state;
-    ma_pa_channel_map_init_extend_proc         _pa_channel_map_init_extend        = pa_channel_map_init_extend;
-    ma_pa_channel_map_valid_proc               _pa_channel_map_valid              = pa_channel_map_valid;
-    ma_pa_channel_map_compatible_proc          _pa_channel_map_compatible         = pa_channel_map_compatible;
-    ma_pa_stream_new_proc                      _pa_stream_new                     = pa_stream_new;
-    ma_pa_stream_unref_proc                    _pa_stream_unref                   = pa_stream_unref;
-    ma_pa_stream_connect_playback_proc         _pa_stream_connect_playback        = pa_stream_connect_playback;
-    ma_pa_stream_connect_record_proc           _pa_stream_connect_record          = pa_stream_connect_record;
-    ma_pa_stream_disconnect_proc               _pa_stream_disconnect              = pa_stream_disconnect;
-    ma_pa_stream_get_state_proc                _pa_stream_get_state               = pa_stream_get_state;
-    ma_pa_stream_get_sample_spec_proc          _pa_stream_get_sample_spec         = pa_stream_get_sample_spec;
-    ma_pa_stream_get_channel_map_proc          _pa_stream_get_channel_map         = pa_stream_get_channel_map;
-    ma_pa_stream_get_buffer_attr_proc          _pa_stream_get_buffer_attr         = pa_stream_get_buffer_attr;
-    ma_pa_stream_set_buffer_attr_proc          _pa_stream_set_buffer_attr         = pa_stream_set_buffer_attr;
-    ma_pa_stream_get_device_name_proc          _pa_stream_get_device_name         = pa_stream_get_device_name;
-    ma_pa_stream_set_write_callback_proc       _pa_stream_set_write_callback      = pa_stream_set_write_callback;
-    ma_pa_stream_set_read_callback_proc        _pa_stream_set_read_callback       = pa_stream_set_read_callback;
-    ma_pa_stream_flush_proc                    _pa_stream_flush                   = pa_stream_flush;
-    ma_pa_stream_drain_proc                    _pa_stream_drain                   = pa_stream_drain;
-    ma_pa_stream_is_corked_proc                _pa_stream_is_corked               = pa_stream_is_corked;
-    ma_pa_stream_cork_proc                     _pa_stream_cork                    = pa_stream_cork;
-    ma_pa_stream_trigger_proc                  _pa_stream_trigger                 = pa_stream_trigger;
-    ma_pa_stream_begin_write_proc              _pa_stream_begin_write             = pa_stream_begin_write;
-    ma_pa_stream_write_proc                    _pa_stream_write                   = pa_stream_write;
-    ma_pa_stream_peek_proc                     _pa_stream_peek                    = pa_stream_peek;
-    ma_pa_stream_drop_proc                     _pa_stream_drop                    = pa_stream_drop;
-    ma_pa_stream_writable_size_proc            _pa_stream_writable_size           = pa_stream_writable_size;
-    ma_pa_stream_readable_size_proc            _pa_stream_readable_size           = pa_stream_readable_size;
-
-    pContext->pulse.pa_mainloop_new                    = (ma_proc)_pa_mainloop_new;
-    pContext->pulse.pa_mainloop_free                   = (ma_proc)_pa_mainloop_free;
-    pContext->pulse.pa_mainloop_quit                   = (ma_proc)_pa_mainloop_quit;
-    pContext->pulse.pa_mainloop_get_api                = (ma_proc)_pa_mainloop_get_api;
-    pContext->pulse.pa_mainloop_iterate                = (ma_proc)_pa_mainloop_iterate;
-    pContext->pulse.pa_mainloop_wakeup                 = (ma_proc)_pa_mainloop_wakeup;
-    pContext->pulse.pa_threaded_mainloop_new           = (ma_proc)_pa_threaded_mainloop_new;
-    pContext->pulse.pa_threaded_mainloop_free          = (ma_proc)_pa_threaded_mainloop_free;
-    pContext->pulse.pa_threaded_mainloop_start         = (ma_proc)_pa_threaded_mainloop_start;
-    pContext->pulse.pa_threaded_mainloop_stop          = (ma_proc)_pa_threaded_mainloop_stop;
-    pContext->pulse.pa_threaded_mainloop_lock          = (ma_proc)_pa_threaded_mainloop_lock;
-    pContext->pulse.pa_threaded_mainloop_unlock        = (ma_proc)_pa_threaded_mainloop_unlock;
-    pContext->pulse.pa_threaded_mainloop_wait          = (ma_proc)_pa_threaded_mainloop_wait;
-    pContext->pulse.pa_threaded_mainloop_signal        = (ma_proc)_pa_threaded_mainloop_signal;
-    pContext->pulse.pa_threaded_mainloop_accept        = (ma_proc)_pa_threaded_mainloop_accept;
-    pContext->pulse.pa_threaded_mainloop_get_retval    = (ma_proc)_pa_threaded_mainloop_get_retval;
-    pContext->pulse.pa_threaded_mainloop_get_api       = (ma_proc)_pa_threaded_mainloop_get_api;
-    pContext->pulse.pa_threaded_mainloop_in_thread     = (ma_proc)_pa_threaded_mainloop_in_thread;
-    pContext->pulse.pa_threaded_mainloop_set_name      = (ma_proc)_pa_threaded_mainloop_set_name;
-    pContext->pulse.pa_context_new                     = (ma_proc)_pa_context_new;
-    pContext->pulse.pa_context_unref                   = (ma_proc)_pa_context_unref;
-    pContext->pulse.pa_context_connect                 = (ma_proc)_pa_context_connect;
-    pContext->pulse.pa_context_disconnect              = (ma_proc)_pa_context_disconnect;
-    pContext->pulse.pa_context_set_state_callback      = (ma_proc)_pa_context_set_state_callback;
-    pContext->pulse.pa_context_get_state               = (ma_proc)_pa_context_get_state;
-    pContext->pulse.pa_context_get_sink_info_list      = (ma_proc)_pa_context_get_sink_info_list;
-    pContext->pulse.pa_context_get_source_info_list    = (ma_proc)_pa_context_get_source_info_list;
-    pContext->pulse.pa_context_get_sink_info_by_name   = (ma_proc)_pa_context_get_sink_info_by_name;
-    pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)_pa_context_get_source_info_by_name;
-    pContext->pulse.pa_operation_unref                 = (ma_proc)_pa_operation_unref;
-    pContext->pulse.pa_operation_get_state             = (ma_proc)_pa_operation_get_state;
-    pContext->pulse.pa_channel_map_init_extend         = (ma_proc)_pa_channel_map_init_extend;
-    pContext->pulse.pa_channel_map_valid               = (ma_proc)_pa_channel_map_valid;
-    pContext->pulse.pa_channel_map_compatible          = (ma_proc)_pa_channel_map_compatible;
-    pContext->pulse.pa_stream_new                      = (ma_proc)_pa_stream_new;
-    pContext->pulse.pa_stream_unref                    = (ma_proc)_pa_stream_unref;
-    pContext->pulse.pa_stream_connect_playback         = (ma_proc)_pa_stream_connect_playback;
-    pContext->pulse.pa_stream_connect_record           = (ma_proc)_pa_stream_connect_record;
-    pContext->pulse.pa_stream_disconnect               = (ma_proc)_pa_stream_disconnect;
-    pContext->pulse.pa_stream_get_state                = (ma_proc)_pa_stream_get_state;
-    pContext->pulse.pa_stream_get_sample_spec          = (ma_proc)_pa_stream_get_sample_spec;
-    pContext->pulse.pa_stream_get_channel_map          = (ma_proc)_pa_stream_get_channel_map;
-    pContext->pulse.pa_stream_get_buffer_attr          = (ma_proc)_pa_stream_get_buffer_attr;
-    pContext->pulse.pa_stream_set_buffer_attr          = (ma_proc)_pa_stream_set_buffer_attr;
-    pContext->pulse.pa_stream_get_device_name          = (ma_proc)_pa_stream_get_device_name;
-    pContext->pulse.pa_stream_set_write_callback       = (ma_proc)_pa_stream_set_write_callback;
-    pContext->pulse.pa_stream_set_read_callback        = (ma_proc)_pa_stream_set_read_callback;
-    pContext->pulse.pa_stream_flush                    = (ma_proc)_pa_stream_flush;
-    pContext->pulse.pa_stream_drain                    = (ma_proc)_pa_stream_drain;
-    pContext->pulse.pa_stream_is_corked                = (ma_proc)_pa_stream_is_corked;
-    pContext->pulse.pa_stream_cork                     = (ma_proc)_pa_stream_cork;
-    pContext->pulse.pa_stream_trigger                  = (ma_proc)_pa_stream_trigger;
-    pContext->pulse.pa_stream_begin_write              = (ma_proc)_pa_stream_begin_write;
-    pContext->pulse.pa_stream_write                    = (ma_proc)_pa_stream_write;
-    pContext->pulse.pa_stream_peek                     = (ma_proc)_pa_stream_peek;
-    pContext->pulse.pa_stream_drop                     = (ma_proc)_pa_stream_drop;
-    pContext->pulse.pa_stream_writable_size            = (ma_proc)_pa_stream_writable_size;
-    pContext->pulse.pa_stream_readable_size            = (ma_proc)_pa_stream_readable_size;
-#endif
-
-    /* The PulseAudio context maps well to miniaudio's notion of a context. The pa_context object will be initialized as part of the ma_context. */
-    pContext->pulse.pMainLoop = ((ma_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)();
-    if (pContext->pulse.pMainLoop == NULL) {
-        result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create mainloop.", MA_FAILED_TO_INIT_BACKEND);
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    pContext->pulse.pPulseContext = ((ma_pa_context_new_proc)pContext->pulse.pa_context_new)(((ma_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)((ma_pa_mainloop*)pContext->pulse.pMainLoop), pConfig->pulse.pApplicationName);
-    if (pContext->pulse.pPulseContext == NULL) {
-        result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context.", MA_FAILED_TO_INIT_BACKEND);
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    /* Now we need to connect to the context. Everything is asynchronous so we need to wait for it to connect before returning. */
-    result = ma_result_from_pulse(((ma_pa_context_connect_proc)pContext->pulse.pa_context_connect)((ma_pa_context*)pContext->pulse.pPulseContext, pConfig->pulse.pServerName, (pConfig->pulse.tryAutoSpawn) ? 0 : MA_PA_CONTEXT_NOAUTOSPAWN, NULL));
-    if (result != MA_SUCCESS) {
-        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context.", result);
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    /* Since ma_context_init() runs synchronously we need to wait for the PulseAudio context to connect before we return. */
-    result = ma_context_wait_for_pa_context_to_connect__pulse(pContext);
-    if (result != MA_SUCCESS) {
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-
-    /* With pa_mainloop we run a synchronous backend, but we implement our own main loop. */
-    pCallbacks->onContextInit             = ma_context_init__pulse;
-    pCallbacks->onContextUninit           = ma_context_uninit__pulse;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__pulse;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__pulse;
-    pCallbacks->onDeviceInit              = ma_device_init__pulse;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__pulse;
-    pCallbacks->onDeviceStart             = ma_device_start__pulse;
-    pCallbacks->onDeviceStop              = ma_device_stop__pulse;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because we're implementing onDeviceDataLoop. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because we're implementing onDeviceDataLoop. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__pulse;
-    pCallbacks->onDeviceDataLoopWakeup    = ma_device_data_loop_wakeup__pulse;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-/******************************************************************************
-
-JACK Backend
-
-******************************************************************************/
-#ifdef MA_HAS_JACK
-
-/* It is assumed jack.h is available when compile-time linking is being used. */
-#ifdef MA_NO_RUNTIME_LINKING
-#include <jack/jack.h>
-
-typedef jack_nframes_t              ma_jack_nframes_t;
-typedef jack_options_t              ma_jack_options_t;
-typedef jack_status_t               ma_jack_status_t;
-typedef jack_client_t               ma_jack_client_t;
-typedef jack_port_t                 ma_jack_port_t;
-typedef JackProcessCallback         ma_JackProcessCallback;
-typedef JackBufferSizeCallback      ma_JackBufferSizeCallback;
-typedef JackShutdownCallback        ma_JackShutdownCallback;
-#define MA_JACK_DEFAULT_AUDIO_TYPE  JACK_DEFAULT_AUDIO_TYPE
-#define ma_JackNoStartServer        JackNoStartServer
-#define ma_JackPortIsInput          JackPortIsInput
-#define ma_JackPortIsOutput         JackPortIsOutput
-#define ma_JackPortIsPhysical       JackPortIsPhysical
-#else
-typedef ma_uint32               ma_jack_nframes_t;
-typedef int                     ma_jack_options_t;
-typedef int                     ma_jack_status_t;
-typedef struct ma_jack_client_t ma_jack_client_t;
-typedef struct ma_jack_port_t   ma_jack_port_t;
-typedef int  (* ma_JackProcessCallback)   (ma_jack_nframes_t nframes, void* arg);
-typedef int  (* ma_JackBufferSizeCallback)(ma_jack_nframes_t nframes, void* arg);
-typedef void (* ma_JackShutdownCallback)  (void* arg);
-#define MA_JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
-#define ma_JackNoStartServer       1
-#define ma_JackPortIsInput         1
-#define ma_JackPortIsOutput        2
-#define ma_JackPortIsPhysical      4
-#endif
-
-typedef ma_jack_client_t* (* ma_jack_client_open_proc)             (const char* client_name, ma_jack_options_t options, ma_jack_status_t* status, ...);
-typedef int               (* ma_jack_client_close_proc)            (ma_jack_client_t* client);
-typedef int               (* ma_jack_client_name_size_proc)        (void);
-typedef int               (* ma_jack_set_process_callback_proc)    (ma_jack_client_t* client, ma_JackProcessCallback process_callback, void* arg);
-typedef int               (* ma_jack_set_buffer_size_callback_proc)(ma_jack_client_t* client, ma_JackBufferSizeCallback bufsize_callback, void* arg);
-typedef void              (* ma_jack_on_shutdown_proc)             (ma_jack_client_t* client, ma_JackShutdownCallback function, void* arg);
-typedef ma_jack_nframes_t (* ma_jack_get_sample_rate_proc)         (ma_jack_client_t* client);
-typedef ma_jack_nframes_t (* ma_jack_get_buffer_size_proc)         (ma_jack_client_t* client);
-typedef const char**      (* ma_jack_get_ports_proc)               (ma_jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
-typedef int               (* ma_jack_activate_proc)                (ma_jack_client_t* client);
-typedef int               (* ma_jack_deactivate_proc)              (ma_jack_client_t* client);
-typedef int               (* ma_jack_connect_proc)                 (ma_jack_client_t* client, const char* source_port, const char* destination_port);
-typedef ma_jack_port_t*   (* ma_jack_port_register_proc)           (ma_jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
-typedef const char*       (* ma_jack_port_name_proc)               (const ma_jack_port_t* port);
-typedef void*             (* ma_jack_port_get_buffer_proc)         (ma_jack_port_t* port, ma_jack_nframes_t nframes);
-typedef void              (* ma_jack_free_proc)                    (void* ptr);
-
-static ma_result ma_context_open_client__jack(ma_context* pContext, ma_jack_client_t** ppClient)
-{
-    size_t maxClientNameSize;
-    char clientName[256];
-    ma_jack_status_t status;
-    ma_jack_client_t* pClient;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppClient != NULL);
-
-    if (ppClient) {
-        *ppClient = NULL;
-    }
-
-    maxClientNameSize = ((ma_jack_client_name_size_proc)pContext->jack.jack_client_name_size)(); /* Includes null terminator. */
-    ma_strncpy_s(clientName, ma_min(sizeof(clientName), maxClientNameSize), (pContext->jack.pClientName != NULL) ? pContext->jack.pClientName : "miniaudio", (size_t)-1);
-
-    pClient = ((ma_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->jack.tryStartServer) ? 0 : ma_JackNoStartServer, &status, NULL);
-    if (pClient == NULL) {
-        return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-    }
-
-    if (ppClient) {
-        *ppClient = pClient;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__jack(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* JACK only uses default devices. */
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* JACK only uses default devices. */
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    (void)cbResult; /* For silencing a static analysis warning. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__jack(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_jack_client_t* pClient;
-    ma_result result;
-    const char** ppPorts;
-
-    MA_ASSERT(pContext != NULL);
-
-    if (pDeviceID != NULL && pDeviceID->jack != 0) {
-        return MA_NO_DEVICE;   /* Don't know the device. */
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    /* Jack only uses default devices. */
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    /* Jack only supports f32 and has a specific channel count and sample rate. */
-    pDeviceInfo->nativeDataFormats[0].format = ma_format_f32;
-
-    /* The channel count and sample rate can only be determined by opening the device. */
-    result = ma_context_open_client__jack(pContext, &pClient);
-    if (result != MA_SUCCESS) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", result);
-    }
-
-    pDeviceInfo->nativeDataFormats[0].sampleRate = ((ma_jack_get_sample_rate_proc)pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pClient);
-    pDeviceInfo->nativeDataFormats[0].channels   = 0;
-
-    ppPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ((deviceType == ma_device_type_playback) ? ma_JackPortIsInput : ma_JackPortIsOutput));
-    if (ppPorts == NULL) {
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    while (ppPorts[pDeviceInfo->nativeDataFormats[0].channels] != NULL) {
-        pDeviceInfo->nativeDataFormats[0].channels += 1;
-    }
-
-    pDeviceInfo->nativeDataFormats[0].flags = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts);
-    ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__jack(ma_device* pDevice)
-{
-    ma_context* pContext;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->jack.pClient != NULL) {
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDevice->jack.pClient);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_device__jack_shutdown_callback(void* pUserData)
-{
-    /* JACK died. Stop the device. */
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_stop(pDevice);
-}
-
-static int ma_device__jack_buffer_size_callback(ma_jack_nframes_t frameCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        size_t newBufferSize = frameCount * (pDevice->capture.internalChannels * ma_get_bytes_per_sample(pDevice->capture.internalFormat));
-        float* pNewBuffer = (float*)ma__calloc_from_callbacks(newBufferSize, &pDevice->pContext->allocationCallbacks);
-        if (pNewBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks);
-
-        pDevice->jack.pIntermediaryBufferCapture = pNewBuffer;
-        pDevice->playback.internalPeriodSizeInFrames = frameCount;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        size_t newBufferSize = frameCount * (pDevice->playback.internalChannels * ma_get_bytes_per_sample(pDevice->playback.internalFormat));
-        float* pNewBuffer = (float*)ma__calloc_from_callbacks(newBufferSize, &pDevice->pContext->allocationCallbacks);
-        if (pNewBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks);
-
-        pDevice->jack.pIntermediaryBufferPlayback = pNewBuffer;
-        pDevice->playback.internalPeriodSizeInFrames = frameCount;
-    }
-
-    return 0;
-}
-
-static int ma_device__jack_process_callback(ma_jack_nframes_t frameCount, void* pUserData)
-{
-    ma_device* pDevice;
-    ma_context* pContext;
-    ma_uint32 iChannel;
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        /* Channels need to be interleaved. */
-        for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-            const float* pSrc = (const float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.pPortsCapture[iChannel], frameCount);
-            if (pSrc != NULL) {
-                float* pDst = pDevice->jack.pIntermediaryBufferCapture + iChannel;
-                ma_jack_nframes_t iFrame;
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    *pDst = *pSrc;
-
-                    pDst += pDevice->capture.internalChannels;
-                    pSrc += 1;
-                }
-            }
-        }
-
-        ma_device_handle_backend_data_callback(pDevice, NULL, pDevice->jack.pIntermediaryBufferCapture, frameCount);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_handle_backend_data_callback(pDevice, pDevice->jack.pIntermediaryBufferPlayback, NULL, frameCount);
-
-        /* Channels need to be deinterleaved. */
-        for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-            float* pDst = (float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.pPortsPlayback[iChannel], frameCount);
-            if (pDst != NULL) {
-                const float* pSrc = pDevice->jack.pIntermediaryBufferPlayback + iChannel;
-                ma_jack_nframes_t iFrame;
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    *pDst = *pSrc;
-
-                    pDst += 1;
-                    pSrc += pDevice->playback.internalChannels;
-                }
-            }
-        }
-    }
-
-    return 0;
-}
-
-static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-    ma_uint32 periodSizeInFrames;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDevice != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* Only supporting default devices with JACK. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->pDeviceID != NULL && pDescriptorPlayback->pDeviceID->jack != 0) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->pDeviceID  != NULL && pDescriptorCapture->pDeviceID->jack  != 0)) {
-        return MA_NO_DEVICE;
-    }
-
-    /* No exclusive mode with the JACK backend. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Open the client. */
-    result = ma_context_open_client__jack(pDevice->pContext, (ma_jack_client_t**)&pDevice->jack.pClient);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", result);
-    }
-
-    /* Callbacks. */
-    if (((ma_jack_set_process_callback_proc)pDevice->pContext->jack.jack_set_process_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_process_callback, pDevice) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set process callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-    if (((ma_jack_set_buffer_size_callback_proc)pDevice->pContext->jack.jack_set_buffer_size_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_buffer_size_callback, pDevice) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set buffer size callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    ((ma_jack_on_shutdown_proc)pDevice->pContext->jack.jack_on_shutdown)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_shutdown_callback, pDevice);
-
-
-    /* The buffer size in frames can change. */
-    periodSizeInFrames = ((ma_jack_get_buffer_size_proc)pDevice->pContext->jack.jack_get_buffer_size)((ma_jack_client_t*)pDevice->jack.pClient);
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        const char** ppPorts;
-
-        pDescriptorCapture->format     = ma_format_f32;
-        pDescriptorCapture->channels   = 0;
-        pDescriptorCapture->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient);
-        ma_get_standard_channel_map(ma_standard_channel_map_alsa, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-
-        ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput);
-        if (ppPorts == NULL) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-
-        while (ppPorts[pDescriptorCapture->channels] != NULL) {
-            char name[64];
-            ma_strcpy_s(name, sizeof(name), "capture");
-            ma_itoa_s((int)pDescriptorCapture->channels, name+7, sizeof(name)-7, 10); /* 7 = length of "capture" */
-
-            pDevice->jack.pPortsCapture[pDescriptorCapture->channels] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsInput, 0);
-            if (pDevice->jack.pPortsCapture[pDescriptorCapture->channels] == NULL) {
-                ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-                ma_device_uninit__jack(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            }
-
-            pDescriptorCapture->channels += 1;
-        }
-
-        ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-
-        pDescriptorCapture->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorCapture->periodCount        = 1; /* There's no notion of a period in JACK. Just set to 1. */
-
-        pDevice->jack.pIntermediaryBufferCapture = (float*)ma__calloc_from_callbacks(pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels), &pDevice->pContext->allocationCallbacks);
-        if (pDevice->jack.pIntermediaryBufferCapture == NULL) {
-            ma_device_uninit__jack(pDevice);
-            return MA_OUT_OF_MEMORY;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        const char** ppPorts;
-
-        pDescriptorPlayback->format     = ma_format_f32;
-        pDescriptorPlayback->channels   = 0;
-        pDescriptorPlayback->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient);
-        ma_get_standard_channel_map(ma_standard_channel_map_alsa, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-
-        ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput);
-        if (ppPorts == NULL) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-
-        while (ppPorts[pDescriptorPlayback->channels] != NULL) {
-            char name[64];
-            ma_strcpy_s(name, sizeof(name), "playback");
-            ma_itoa_s((int)pDescriptorPlayback->channels, name+8, sizeof(name)-8, 10); /* 8 = length of "playback" */
-
-            pDevice->jack.pPortsPlayback[pDescriptorPlayback->channels] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsOutput, 0);
-            if (pDevice->jack.pPortsPlayback[pDescriptorPlayback->channels] == NULL) {
-                ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-                ma_device_uninit__jack(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            }
-
-            pDescriptorPlayback->channels += 1;
-        }
-
-        ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-
-        pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorPlayback->periodCount        = 1;   /* There's no notion of a period in JACK. Just set to 1. */
-
-        pDevice->jack.pIntermediaryBufferPlayback = (float*)ma__calloc_from_callbacks(pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels), &pDevice->pContext->allocationCallbacks);
-        if (pDevice->jack.pIntermediaryBufferPlayback == NULL) {
-            ma_device_uninit__jack(pDevice);
-            return MA_OUT_OF_MEMORY;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_start__jack(ma_device* pDevice)
-{
-    ma_context* pContext = pDevice->pContext;
-    int resultJACK;
-    size_t i;
-
-    resultJACK = ((ma_jack_activate_proc)pContext->jack.jack_activate)((ma_jack_client_t*)pDevice->jack.pClient);
-    if (resultJACK != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to activate the JACK client.", MA_FAILED_TO_START_BACKEND_DEVICE);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput);
-        if (ppServerPorts == NULL) {
-            ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR);
-        }
-
-        for (i = 0; ppServerPorts[i] != NULL; ++i) {
-            const char* pServerPort = ppServerPorts[i];
-            const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.pPortsCapture[i]);
-
-            resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pServerPort, pClientPort);
-            if (resultJACK != 0) {
-                ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-                ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR);
-            }
-        }
-
-        ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput);
-        if (ppServerPorts == NULL) {
-            ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR);
-        }
-
-        for (i = 0; ppServerPorts[i] != NULL; ++i) {
-            const char* pServerPort = ppServerPorts[i];
-            const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.pPortsPlayback[i]);
-
-            resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pClientPort, pServerPort);
-            if (resultJACK != 0) {
-                ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-                ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR);
-            }
-        }
-
-        ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__jack(ma_device* pDevice)
-{
-    ma_context* pContext = pDevice->pContext;
-    ma_stop_proc onStop;
-
-    if (((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] An error occurred when deactivating the JACK client.", MA_ERROR);
-    }
-
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__jack(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_jack);
-
-    ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks);
-    pContext->jack.pClientName = NULL;
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->jack.jackSO);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libjackNames[] = {
-#ifdef MA_WIN32
-        "libjack.dll",
-        "libjack64.dll"
-#else
-        "libjack.so",
-        "libjack.so.0"
-#endif
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libjackNames); ++i) {
-        pContext->jack.jackSO = ma_dlopen(pContext, libjackNames[i]);
-        if (pContext->jack.jackSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->jack.jackSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->jack.jack_client_open              = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_open");
-    pContext->jack.jack_client_close             = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_close");
-    pContext->jack.jack_client_name_size         = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_name_size");
-    pContext->jack.jack_set_process_callback     = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_set_process_callback");
-    pContext->jack.jack_set_buffer_size_callback = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_set_buffer_size_callback");
-    pContext->jack.jack_on_shutdown              = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_on_shutdown");
-    pContext->jack.jack_get_sample_rate          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_sample_rate");
-    pContext->jack.jack_get_buffer_size          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_buffer_size");
-    pContext->jack.jack_get_ports                = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_ports");
-    pContext->jack.jack_activate                 = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_activate");
-    pContext->jack.jack_deactivate               = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_deactivate");
-    pContext->jack.jack_connect                  = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_connect");
-    pContext->jack.jack_port_register            = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_register");
-    pContext->jack.jack_port_name                = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_name");
-    pContext->jack.jack_port_get_buffer          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_get_buffer");
-    pContext->jack.jack_free                     = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_free");
-#else
-    /*
-    This strange assignment system is here just to ensure type safety of miniaudio's function pointer
-    types. If anything differs slightly the compiler should throw a warning.
-    */
-    ma_jack_client_open_proc              _jack_client_open              = jack_client_open;
-    ma_jack_client_close_proc             _jack_client_close             = jack_client_close;
-    ma_jack_client_name_size_proc         _jack_client_name_size         = jack_client_name_size;
-    ma_jack_set_process_callback_proc     _jack_set_process_callback     = jack_set_process_callback;
-    ma_jack_set_buffer_size_callback_proc _jack_set_buffer_size_callback = jack_set_buffer_size_callback;
-    ma_jack_on_shutdown_proc              _jack_on_shutdown              = jack_on_shutdown;
-    ma_jack_get_sample_rate_proc          _jack_get_sample_rate          = jack_get_sample_rate;
-    ma_jack_get_buffer_size_proc          _jack_get_buffer_size          = jack_get_buffer_size;
-    ma_jack_get_ports_proc                _jack_get_ports                = jack_get_ports;
-    ma_jack_activate_proc                 _jack_activate                 = jack_activate;
-    ma_jack_deactivate_proc               _jack_deactivate               = jack_deactivate;
-    ma_jack_connect_proc                  _jack_connect                  = jack_connect;
-    ma_jack_port_register_proc            _jack_port_register            = jack_port_register;
-    ma_jack_port_name_proc                _jack_port_name                = jack_port_name;
-    ma_jack_port_get_buffer_proc          _jack_port_get_buffer          = jack_port_get_buffer;
-    ma_jack_free_proc                     _jack_free                     = jack_free;
-
-    pContext->jack.jack_client_open              = (ma_proc)_jack_client_open;
-    pContext->jack.jack_client_close             = (ma_proc)_jack_client_close;
-    pContext->jack.jack_client_name_size         = (ma_proc)_jack_client_name_size;
-    pContext->jack.jack_set_process_callback     = (ma_proc)_jack_set_process_callback;
-    pContext->jack.jack_set_buffer_size_callback = (ma_proc)_jack_set_buffer_size_callback;
-    pContext->jack.jack_on_shutdown              = (ma_proc)_jack_on_shutdown;
-    pContext->jack.jack_get_sample_rate          = (ma_proc)_jack_get_sample_rate;
-    pContext->jack.jack_get_buffer_size          = (ma_proc)_jack_get_buffer_size;
-    pContext->jack.jack_get_ports                = (ma_proc)_jack_get_ports;
-    pContext->jack.jack_activate                 = (ma_proc)_jack_activate;
-    pContext->jack.jack_deactivate               = (ma_proc)_jack_deactivate;
-    pContext->jack.jack_connect                  = (ma_proc)_jack_connect;
-    pContext->jack.jack_port_register            = (ma_proc)_jack_port_register;
-    pContext->jack.jack_port_name                = (ma_proc)_jack_port_name;
-    pContext->jack.jack_port_get_buffer          = (ma_proc)_jack_port_get_buffer;
-    pContext->jack.jack_free                     = (ma_proc)_jack_free;
-#endif
-
-    if (pConfig->jack.pClientName != NULL) {
-        pContext->jack.pClientName = ma_copy_string(pConfig->jack.pClientName, &pContext->allocationCallbacks);
-    }
-    pContext->jack.tryStartServer = pConfig->jack.tryStartServer;
-
-    /*
-    Getting here means the JACK library is installed, but it doesn't necessarily mean it's usable. We need to quickly test this by connecting
-    a temporary client.
-    */
-    {
-        ma_jack_client_t* pDummyClient;
-        ma_result result = ma_context_open_client__jack(pContext, &pDummyClient);
-        if (result != MA_SUCCESS) {
-            ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks);
-        #ifndef MA_NO_RUNTIME_LINKING
-            ma_dlclose(pContext, pContext->jack.jackSO);
-        #endif
-            return MA_NO_BACKEND;
-        }
-
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDummyClient);
-    }
-
-
-    pCallbacks->onContextInit             = ma_context_init__jack;
-    pCallbacks->onContextUninit           = ma_context_uninit__jack;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__jack;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__jack;
-    pCallbacks->onDeviceInit              = ma_device_init__jack;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__jack;
-    pCallbacks->onDeviceStart             = ma_device_start__jack;
-    pCallbacks->onDeviceStop              = ma_device_stop__jack;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because JACK is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because JACK is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not used because JACK is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* JACK */
-
-
-
-/******************************************************************************
-
-Core Audio Backend
-
-References
-==========
-- Technical Note TN2091: Device input using the HAL Output Audio Unit
-    https://developer.apple.com/library/archive/technotes/tn2091/_index.html
-
-******************************************************************************/
-#ifdef MA_HAS_COREAUDIO
-#include <TargetConditionals.h>
-
-#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
-    #define MA_APPLE_MOBILE
-    #if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
-        #define MA_APPLE_TV
-    #endif
-    #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
-        #define MA_APPLE_WATCH
-    #endif
-#else
-    #define MA_APPLE_DESKTOP
-#endif
-
-#if defined(MA_APPLE_DESKTOP)
-#include <CoreAudio/CoreAudio.h>
-#else
-#include <AVFoundation/AVFoundation.h>
-#endif
-
-#include <AudioToolbox/AudioToolbox.h>
-
-/* CoreFoundation */
-typedef Boolean (* ma_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding);
-typedef void (* ma_CFRelease_proc)(CFTypeRef cf);
-
-/* CoreAudio */
-#if defined(MA_APPLE_DESKTOP)
-typedef OSStatus (* ma_AudioObjectGetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* ioDataSize, void* outData);
-typedef OSStatus (* ma_AudioObjectGetPropertyDataSize_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);
-typedef OSStatus (* ma_AudioObjectSetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData);
-typedef OSStatus (* ma_AudioObjectAddPropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData);
-typedef OSStatus (* ma_AudioObjectRemovePropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData);
-#endif
-
-/* AudioToolbox */
-typedef AudioComponent (* ma_AudioComponentFindNext_proc)(AudioComponent inComponent, const AudioComponentDescription* inDesc);
-typedef OSStatus (* ma_AudioComponentInstanceDispose_proc)(AudioComponentInstance inInstance);
-typedef OSStatus (* ma_AudioComponentInstanceNew_proc)(AudioComponent inComponent, AudioComponentInstance* outInstance);
-typedef OSStatus (* ma_AudioOutputUnitStart_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioOutputUnitStop_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioUnitAddPropertyListener_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitPropertyListenerProc inProc, void* inProcUserData);
-typedef OSStatus (* ma_AudioUnitGetPropertyInfo_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32* outDataSize, Boolean* outWriteable);
-typedef OSStatus (* ma_AudioUnitGetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData, UInt32* ioDataSize);
-typedef OSStatus (* ma_AudioUnitSetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize);
-typedef OSStatus (* ma_AudioUnitInitialize_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioUnitRender_proc)(AudioUnit inUnit, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData);
-
-
-#define MA_COREAUDIO_OUTPUT_BUS    0
-#define MA_COREAUDIO_INPUT_BUS     1
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit);
-#endif
-
-/*
-Core Audio
-
-So far, Core Audio has been the worst backend to work with due to being both unintuitive and having almost no documentation
-apart from comments in the headers (which admittedly are quite good). For my own purposes, and for anybody out there whose
-needing to figure out how this darn thing works, I'm going to outline a few things here.
-
-Since miniaudio is a fairly low-level API, one of the things it needs is control over specific devices, and it needs to be
-able to identify whether or not it can be used as playback and/or capture. The AudioObject API is the only one I've seen
-that supports this level of detail. There was some public domain sample code I stumbled across that used the AudioComponent
-and AudioUnit APIs, but I couldn't see anything that gave low-level control over device selection and capabilities (the
-distinction between playback and capture in particular). Therefore, miniaudio is using the AudioObject API.
-
-Most (all?) functions in the AudioObject API take a AudioObjectID as it's input. This is the device identifier. When
-retrieving global information, such as the device list, you use kAudioObjectSystemObject. When retrieving device-specific
-data, you pass in the ID for that device. In order to retrieve device-specific IDs you need to enumerate over each of the
-devices. This is done using the AudioObjectGetPropertyDataSize() and AudioObjectGetPropertyData() APIs which seem to be
-the central APIs for retrieving information about the system and specific devices.
-
-To use the AudioObjectGetPropertyData() API you need to use the notion of a property address. A property address is a
-structure with three variables and is used to identify which property you are getting or setting. The first is the "selector"
-which is basically the specific property that you're wanting to retrieve or set. The second is the "scope", which is
-typically set to kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeInput for input-specific properties and
-kAudioObjectPropertyScopeOutput for output-specific properties. The last is the "element" which is always set to
-kAudioObjectPropertyElementMaster in miniaudio's case. I don't know of any cases where this would be set to anything different.
-
-Back to the earlier issue of device retrieval, you first use the AudioObjectGetPropertyDataSize() API to retrieve the size
-of the raw data which is just a list of AudioDeviceID's. You use the kAudioObjectSystemObject AudioObjectID, and a property
-address with the kAudioHardwarePropertyDevices selector and the kAudioObjectPropertyScopeGlobal scope. Once you have the
-size, allocate a block of memory of that size and then call AudioObjectGetPropertyData(). The data is just a list of
-AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
-*/
-
-static ma_result ma_result_from_OSStatus(OSStatus status)
-{
-    switch (status)
-    {
-        case noErr:                                   return MA_SUCCESS;
-    #if defined(MA_APPLE_DESKTOP)
-        case kAudioHardwareNotRunningError:           return MA_DEVICE_NOT_STARTED;
-        case kAudioHardwareUnspecifiedError:          return MA_ERROR;
-        case kAudioHardwareUnknownPropertyError:      return MA_INVALID_ARGS;
-        case kAudioHardwareBadPropertySizeError:      return MA_INVALID_OPERATION;
-        case kAudioHardwareIllegalOperationError:     return MA_INVALID_OPERATION;
-        case kAudioHardwareBadObjectError:            return MA_INVALID_ARGS;
-        case kAudioHardwareBadDeviceError:            return MA_INVALID_ARGS;
-        case kAudioHardwareBadStreamError:            return MA_INVALID_ARGS;
-        case kAudioHardwareUnsupportedOperationError: return MA_INVALID_OPERATION;
-        case kAudioDeviceUnsupportedFormatError:      return MA_FORMAT_NOT_SUPPORTED;
-        case kAudioDevicePermissionsError:            return MA_ACCESS_DENIED;
-    #endif
-        default:                                      return MA_ERROR;
-    }
-}
-
-#if 0
-static ma_channel ma_channel_from_AudioChannelBitmap(AudioChannelBitmap bit)
-{
-    switch (bit)
-    {
-        case kAudioChannelBit_Left:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelBit_Right:                return MA_CHANNEL_RIGHT;
-        case kAudioChannelBit_Center:               return MA_CHANNEL_FRONT_CENTER;
-        case kAudioChannelBit_LFEScreen:            return MA_CHANNEL_LFE;
-        case kAudioChannelBit_LeftSurround:         return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelBit_RightSurround:        return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelBit_LeftCenter:           return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case kAudioChannelBit_RightCenter:          return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case kAudioChannelBit_CenterSurround:       return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelBit_LeftSurroundDirect:   return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelBit_RightSurroundDirect:  return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelBit_TopCenterSurround:    return MA_CHANNEL_TOP_CENTER;
-        case kAudioChannelBit_VerticalHeightLeft:   return MA_CHANNEL_TOP_FRONT_LEFT;
-        case kAudioChannelBit_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER;
-        case kAudioChannelBit_VerticalHeightRight:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case kAudioChannelBit_TopBackLeft:          return MA_CHANNEL_TOP_BACK_LEFT;
-        case kAudioChannelBit_TopBackCenter:        return MA_CHANNEL_TOP_BACK_CENTER;
-        case kAudioChannelBit_TopBackRight:         return MA_CHANNEL_TOP_BACK_RIGHT;
-        default:                                    return MA_CHANNEL_NONE;
-    }
-}
-#endif
-
-static ma_result ma_format_from_AudioStreamBasicDescription(const AudioStreamBasicDescription* pDescription, ma_format* pFormatOut)
-{
-    MA_ASSERT(pDescription != NULL);
-    MA_ASSERT(pFormatOut != NULL);
-
-    *pFormatOut = ma_format_unknown;   /* Safety. */
-
-    /* There's a few things miniaudio doesn't support. */
-    if (pDescription->mFormatID != kAudioFormatLinearPCM) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* We don't support any non-packed formats that are aligned high. */
-    if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsAlignedHigh) != 0) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* Only supporting native-endian. */
-    if ((ma_is_little_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) != 0) || (ma_is_big_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) == 0)) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* We are not currently supporting non-interleaved formats (this will be added in a future version of miniaudio). */
-    /*if ((pDescription->mFormatFlags & kAudioFormatFlagIsNonInterleaved) != 0) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }*/
-
-    if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) {
-        if (pDescription->mBitsPerChannel == 32) {
-            *pFormatOut = ma_format_f32;
-            return MA_SUCCESS;
-        }
-    } else {
-        if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) {
-            if (pDescription->mBitsPerChannel == 16) {
-                *pFormatOut = ma_format_s16;
-                return MA_SUCCESS;
-            } else if (pDescription->mBitsPerChannel == 24) {
-                if (pDescription->mBytesPerFrame == (pDescription->mBitsPerChannel/8 * pDescription->mChannelsPerFrame)) {
-                    *pFormatOut = ma_format_s24;
-                    return MA_SUCCESS;
-                } else {
-                    if (pDescription->mBytesPerFrame/pDescription->mChannelsPerFrame == sizeof(ma_int32)) {
-                        /* TODO: Implement ma_format_s24_32. */
-                        /**pFormatOut = ma_format_s24_32;*/
-                        /*return MA_SUCCESS;*/
-                        return MA_FORMAT_NOT_SUPPORTED;
-                    }
-                }
-            } else if (pDescription->mBitsPerChannel == 32) {
-                *pFormatOut = ma_format_s32;
-                return MA_SUCCESS;
-            }
-        } else {
-            if (pDescription->mBitsPerChannel == 8) {
-                *pFormatOut = ma_format_u8;
-                return MA_SUCCESS;
-            }
-        }
-    }
-
-    /* Getting here means the format is not supported. */
-    return MA_FORMAT_NOT_SUPPORTED;
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_channel ma_channel_from_AudioChannelLabel(AudioChannelLabel label)
-{
-    switch (label)
-    {
-        case kAudioChannelLabel_Unknown:              return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Unused:               return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_UseCoordinates:       return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Left:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_Right:                return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_Center:               return MA_CHANNEL_FRONT_CENTER;
-        case kAudioChannelLabel_LFEScreen:            return MA_CHANNEL_LFE;
-        case kAudioChannelLabel_LeftSurround:         return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelLabel_RightSurround:        return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelLabel_LeftCenter:           return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case kAudioChannelLabel_RightCenter:          return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case kAudioChannelLabel_CenterSurround:       return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelLabel_LeftSurroundDirect:   return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelLabel_RightSurroundDirect:  return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelLabel_TopCenterSurround:    return MA_CHANNEL_TOP_CENTER;
-        case kAudioChannelLabel_VerticalHeightLeft:   return MA_CHANNEL_TOP_FRONT_LEFT;
-        case kAudioChannelLabel_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER;
-        case kAudioChannelLabel_VerticalHeightRight:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case kAudioChannelLabel_TopBackLeft:          return MA_CHANNEL_TOP_BACK_LEFT;
-        case kAudioChannelLabel_TopBackCenter:        return MA_CHANNEL_TOP_BACK_CENTER;
-        case kAudioChannelLabel_TopBackRight:         return MA_CHANNEL_TOP_BACK_RIGHT;
-        case kAudioChannelLabel_RearSurroundLeft:     return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelLabel_RearSurroundRight:    return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelLabel_LeftWide:             return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelLabel_RightWide:            return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelLabel_LFE2:                 return MA_CHANNEL_LFE;
-        case kAudioChannelLabel_LeftTotal:            return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_RightTotal:           return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_HearingImpaired:      return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Narration:            return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_Mono:                 return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_DialogCentricMix:     return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_CenterSurroundDirect: return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelLabel_Haptic:               return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_W:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_X:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_Y:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_Z:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_MS_Mid:               return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_MS_Side:              return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_XY_X:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_XY_Y:                 return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_HeadphonesLeft:       return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_HeadphonesRight:      return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_ClickTrack:           return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_ForeignLanguage:      return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Discrete:             return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Discrete_0:           return MA_CHANNEL_AUX_0;
-        case kAudioChannelLabel_Discrete_1:           return MA_CHANNEL_AUX_1;
-        case kAudioChannelLabel_Discrete_2:           return MA_CHANNEL_AUX_2;
-        case kAudioChannelLabel_Discrete_3:           return MA_CHANNEL_AUX_3;
-        case kAudioChannelLabel_Discrete_4:           return MA_CHANNEL_AUX_4;
-        case kAudioChannelLabel_Discrete_5:           return MA_CHANNEL_AUX_5;
-        case kAudioChannelLabel_Discrete_6:           return MA_CHANNEL_AUX_6;
-        case kAudioChannelLabel_Discrete_7:           return MA_CHANNEL_AUX_7;
-        case kAudioChannelLabel_Discrete_8:           return MA_CHANNEL_AUX_8;
-        case kAudioChannelLabel_Discrete_9:           return MA_CHANNEL_AUX_9;
-        case kAudioChannelLabel_Discrete_10:          return MA_CHANNEL_AUX_10;
-        case kAudioChannelLabel_Discrete_11:          return MA_CHANNEL_AUX_11;
-        case kAudioChannelLabel_Discrete_12:          return MA_CHANNEL_AUX_12;
-        case kAudioChannelLabel_Discrete_13:          return MA_CHANNEL_AUX_13;
-        case kAudioChannelLabel_Discrete_14:          return MA_CHANNEL_AUX_14;
-        case kAudioChannelLabel_Discrete_15:          return MA_CHANNEL_AUX_15;
-        case kAudioChannelLabel_Discrete_65535:       return MA_CHANNEL_NONE;
-
-    #if 0   /* Introduced in a later version of macOS. */
-        case kAudioChannelLabel_HOA_ACN:              return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_HOA_ACN_0:            return MA_CHANNEL_AUX_0;
-        case kAudioChannelLabel_HOA_ACN_1:            return MA_CHANNEL_AUX_1;
-        case kAudioChannelLabel_HOA_ACN_2:            return MA_CHANNEL_AUX_2;
-        case kAudioChannelLabel_HOA_ACN_3:            return MA_CHANNEL_AUX_3;
-        case kAudioChannelLabel_HOA_ACN_4:            return MA_CHANNEL_AUX_4;
-        case kAudioChannelLabel_HOA_ACN_5:            return MA_CHANNEL_AUX_5;
-        case kAudioChannelLabel_HOA_ACN_6:            return MA_CHANNEL_AUX_6;
-        case kAudioChannelLabel_HOA_ACN_7:            return MA_CHANNEL_AUX_7;
-        case kAudioChannelLabel_HOA_ACN_8:            return MA_CHANNEL_AUX_8;
-        case kAudioChannelLabel_HOA_ACN_9:            return MA_CHANNEL_AUX_9;
-        case kAudioChannelLabel_HOA_ACN_10:           return MA_CHANNEL_AUX_10;
-        case kAudioChannelLabel_HOA_ACN_11:           return MA_CHANNEL_AUX_11;
-        case kAudioChannelLabel_HOA_ACN_12:           return MA_CHANNEL_AUX_12;
-        case kAudioChannelLabel_HOA_ACN_13:           return MA_CHANNEL_AUX_13;
-        case kAudioChannelLabel_HOA_ACN_14:           return MA_CHANNEL_AUX_14;
-        case kAudioChannelLabel_HOA_ACN_15:           return MA_CHANNEL_AUX_15;
-        case kAudioChannelLabel_HOA_ACN_65024:        return MA_CHANNEL_NONE;
-    #endif
-
-        default:                                      return MA_CHANNEL_NONE;
-    }
-}
-
-static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    MA_ASSERT(pChannelLayout != NULL);
-
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) {
-        UInt32 iChannel;
-        for (iChannel = 0; iChannel < pChannelLayout->mNumberChannelDescriptions && iChannel < channelMapCap; ++iChannel) {
-            pChannelMap[iChannel] = ma_channel_from_AudioChannelLabel(pChannelLayout->mChannelDescriptions[iChannel].mChannelLabel);
-        }
-    } else
-#if 0
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) {
-        /* This is the same kind of system that's used by Windows audio APIs. */
-        UInt32 iChannel = 0;
-        UInt32 iBit;
-        AudioChannelBitmap bitmap = pChannelLayout->mChannelBitmap;
-        for (iBit = 0; iBit < 32 && iChannel < channelMapCap; ++iBit) {
-            AudioChannelBitmap bit = bitmap & (1 << iBit);
-            if (bit != 0) {
-                pChannelMap[iChannel++] = ma_channel_from_AudioChannelBit(bit);
-            }
-        }
-    } else
-#endif
-    {
-        /*
-        Need to use the tag to determine the channel map. For now I'm just assuming a default channel map, but later on this should
-        be updated to determine the mapping based on the tag.
-        */
-        UInt32 channelCount;
-
-        /* Our channel map retrieval APIs below take 32-bit integers, so we'll want to clamp the channel map capacity. */
-        if (channelMapCap > 0xFFFFFFFF) {
-            channelMapCap = 0xFFFFFFFF;
-        }
-
-        channelCount = ma_min(AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag), (UInt32)channelMapCap);
-
-        switch (pChannelLayout->mChannelLayoutTag)
-        {
-            case kAudioChannelLayoutTag_Mono:
-            case kAudioChannelLayoutTag_Stereo:
-            case kAudioChannelLayoutTag_StereoHeadphones:
-            case kAudioChannelLayoutTag_MatrixStereo:
-            case kAudioChannelLayoutTag_MidSide:
-            case kAudioChannelLayoutTag_XY:
-            case kAudioChannelLayoutTag_Binaural:
-            case kAudioChannelLayoutTag_Ambisonic_B_Format:
-            {
-                ma_get_standard_channel_map(ma_standard_channel_map_default, channelCount, pChannelMap);
-            } break;
-
-            case kAudioChannelLayoutTag_Octagonal:
-            {
-                pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-                pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            } /* Intentional fallthrough. */
-            case kAudioChannelLayoutTag_Hexagonal:
-            {
-                pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            } /* Intentional fallthrough. */
-            case kAudioChannelLayoutTag_Pentagonal:
-            {
-                pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            } /* Intentional fallghrough. */
-            case kAudioChannelLayoutTag_Quadraphonic:
-            {
-                pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-                pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-                pChannelMap[1] = MA_CHANNEL_RIGHT;
-                pChannelMap[0] = MA_CHANNEL_LEFT;
-            } break;
-
-            /* TODO: Add support for more tags here. */
-
-            default:
-            {
-                ma_get_standard_channel_map(ma_standard_channel_map_default, channelCount, pChannelMap);
-            } break;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt32* pDeviceCount, AudioObjectID** ppDeviceObjectIDs) /* NOTE: Free the returned buffer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddressDevices;
-    UInt32 deviceObjectsDataSize;
-    OSStatus status;
-    AudioObjectID* pDeviceObjectIDs;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceCount != NULL);
-    MA_ASSERT(ppDeviceObjectIDs != NULL);
-
-    /* Safety. */
-    *pDeviceCount = 0;
-    *ppDeviceObjectIDs = NULL;
-
-    propAddressDevices.mSelector = kAudioHardwarePropertyDevices;
-    propAddressDevices.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddressDevices.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pDeviceObjectIDs = (AudioObjectID*)ma_malloc(deviceObjectsDataSize, &pContext->allocationCallbacks);
-    if (pDeviceObjectIDs == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize, pDeviceObjectIDs);
-    if (status != noErr) {
-        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pDeviceCount = deviceObjectsDataSize / sizeof(AudioObjectID);
-    *ppDeviceObjectIDs = pDeviceObjectIDs;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_uid_as_CFStringRef(ma_context* pContext, AudioObjectID objectID, CFStringRef* pUID)
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    propAddress.mSelector = kAudioDevicePropertyDeviceUID;
-    propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(*pUID);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, pUID);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut)
-{
-    CFStringRef uid;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_uid_as_CFStringRef(pContext, objectID, &uid);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(uid, bufferOut, bufferSize, kCFStringEncodingUTF8)) {
-        return MA_ERROR;
-    }
-
-    ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(uid);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut)
-{
-    AudioObjectPropertyAddress propAddress;
-    CFStringRef deviceName = NULL;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    propAddress.mSelector = kAudioDevicePropertyDeviceNameCFString;
-    propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(deviceName);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, &deviceName);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(deviceName, bufferOut, bufferSize, kCFStringEncodingUTF8)) {
-        return MA_ERROR;
-    }
-
-    ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(deviceName);
-    return MA_SUCCESS;
-}
-
-static ma_bool32 ma_does_AudioObject_support_scope(ma_context* pContext, AudioObjectID deviceObjectID, AudioObjectPropertyScope scope)
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioBufferList* pBufferList;
-    ma_bool32 isSupported;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* To know whether or not a device is an input device we need ot look at the stream configuration. If it has an output channel it's a playback device. */
-    propAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
-    propAddress.mScope    = scope;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return MA_FALSE;
-    }
-
-    pBufferList = (AudioBufferList*)ma__malloc_from_callbacks(dataSize, &pContext->allocationCallbacks);
-    if (pBufferList == NULL) {
-        return MA_FALSE;   /* Out of memory. */
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferList);
-    if (status != noErr) {
-        ma__free_from_callbacks(pBufferList, &pContext->allocationCallbacks);
-        return MA_FALSE;
-    }
-
-    isSupported = MA_FALSE;
-    if (pBufferList->mNumberBuffers > 0) {
-        isSupported = MA_TRUE;
-    }
-
-    ma__free_from_callbacks(pBufferList, &pContext->allocationCallbacks);
-    return isSupported;
-}
-
-static ma_bool32 ma_does_AudioObject_support_playback(ma_context* pContext, AudioObjectID deviceObjectID)
-{
-    return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeOutput);
-}
-
-static ma_bool32 ma_does_AudioObject_support_capture(ma_context* pContext, AudioObjectID deviceObjectID)
-{
-    return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeInput);
-}
-
-
-static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pDescriptionCount, AudioStreamRangedDescription** ppDescriptions) /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioStreamRangedDescription* pDescriptions;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDescriptionCount != NULL);
-    MA_ASSERT(ppDescriptions != NULL);
-
-    /*
-    TODO: Experiment with kAudioStreamPropertyAvailablePhysicalFormats instead of (or in addition to) kAudioStreamPropertyAvailableVirtualFormats. My
-          MacBook Pro uses s24/32 format, however, which miniaudio does not currently support.
-    */
-    propAddress.mSelector = kAudioStreamPropertyAvailableVirtualFormats; /*kAudioStreamPropertyAvailablePhysicalFormats;*/
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pDescriptions = (AudioStreamRangedDescription*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pDescriptions == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pDescriptions);
-    if (status != noErr) {
-        ma_free(pDescriptions, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pDescriptionCount = dataSize / sizeof(*pDescriptions);
-    *ppDescriptions = pDescriptions;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_get_AudioObject_channel_layout(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, AudioChannelLayout** ppChannelLayout)   /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioChannelLayout* pChannelLayout;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppChannelLayout != NULL);
-
-    *ppChannelLayout = NULL;    /* Safety. */
-
-    propAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pChannelLayout = (AudioChannelLayout*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pChannelLayout == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pChannelLayout);
-    if (status != noErr) {
-        ma_free(pChannelLayout, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *ppChannelLayout = pChannelLayout;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_channel_count(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pChannelCount)
-{
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pChannelCount != NULL);
-
-    *pChannelCount = 0; /* Safety. */
-
-    result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) {
-        *pChannelCount = pChannelLayout->mNumberChannelDescriptions;
-    } else if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) {
-        *pChannelCount = ma_count_set_bits(pChannelLayout->mChannelBitmap);
-    } else {
-        *pChannelCount = AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag);
-    }
-
-    ma_free(pChannelLayout, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-#if 0
-static ma_result ma_get_AudioObject_channel_map(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout);
-    if (result != MA_SUCCESS) {
-        return result;  /* Rather than always failing here, would it be more robust to simply assume a default? */
-    }
-
-    result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap);
-    if (result != MA_SUCCESS) {
-        ma_free(pChannelLayout, &pContext->allocationCallbacks);
-        return result;
-    }
-
-    ma_free(pChannelLayout, &pContext->allocationCallbacks);
-    return result;
-}
-#endif
-
-static ma_result ma_get_AudioObject_sample_rates(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pSampleRateRangesCount, AudioValueRange** ppSampleRateRanges)   /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioValueRange* pSampleRateRanges;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pSampleRateRangesCount != NULL);
-    MA_ASSERT(ppSampleRateRanges != NULL);
-
-    /* Safety. */
-    *pSampleRateRangesCount = 0;
-    *ppSampleRateRanges = NULL;
-
-    propAddress.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pSampleRateRanges = (AudioValueRange*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pSampleRateRanges == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pSampleRateRanges);
-    if (status != noErr) {
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pSampleRateRangesCount = dataSize / sizeof(*pSampleRateRanges);
-    *ppSampleRateRanges = pSampleRateRanges;
-    return MA_SUCCESS;
-}
-
-#if 0
-static ma_result ma_get_AudioObject_get_closest_sample_rate(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 sampleRateIn, ma_uint32* pSampleRateOut)
-{
-    UInt32 sampleRateRangeCount;
-    AudioValueRange* pSampleRateRanges;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pSampleRateOut != NULL);
-
-    *pSampleRateOut = 0;    /* Safety. */
-
-    result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (sampleRateRangeCount == 0) {
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_ERROR;   /* Should never hit this case should we? */
-    }
-
-    if (sampleRateIn == 0) {
-        /* Search in order of miniaudio's preferred priority. */
-        UInt32 iMALSampleRate;
-        for (iMALSampleRate = 0; iMALSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iMALSampleRate) {
-            ma_uint32 malSampleRate = g_maStandardSampleRatePriorities[iMALSampleRate];
-            UInt32 iCASampleRate;
-            for (iCASampleRate = 0; iCASampleRate < sampleRateRangeCount; ++iCASampleRate) {
-                AudioValueRange caSampleRate = pSampleRateRanges[iCASampleRate];
-                if (caSampleRate.mMinimum <= malSampleRate && caSampleRate.mMaximum >= malSampleRate) {
-                    *pSampleRateOut = malSampleRate;
-                    ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-                    return MA_SUCCESS;
-                }
-            }
-        }
-
-        /*
-        If we get here it means none of miniaudio's standard sample rates matched any of the supported sample rates from the device. In this
-        case we just fall back to the first one reported by Core Audio.
-        */
-        MA_ASSERT(sampleRateRangeCount > 0);
-
-        *pSampleRateOut = pSampleRateRanges[0].mMinimum;
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_SUCCESS;
-    } else {
-        /* Find the closest match to this sample rate. */
-        UInt32 currentAbsoluteDifference = INT32_MAX;
-        UInt32 iCurrentClosestRange = (UInt32)-1;
-        UInt32 iRange;
-        for (iRange = 0; iRange < sampleRateRangeCount; ++iRange) {
-            if (pSampleRateRanges[iRange].mMinimum <= sampleRateIn && pSampleRateRanges[iRange].mMaximum >= sampleRateIn) {
-                *pSampleRateOut = sampleRateIn;
-                ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-                return MA_SUCCESS;
-            } else {
-                UInt32 absoluteDifference;
-                if (pSampleRateRanges[iRange].mMinimum > sampleRateIn) {
-                    absoluteDifference = pSampleRateRanges[iRange].mMinimum - sampleRateIn;
-                } else {
-                    absoluteDifference = sampleRateIn - pSampleRateRanges[iRange].mMaximum;
-                }
-
-                if (currentAbsoluteDifference > absoluteDifference) {
-                    currentAbsoluteDifference = absoluteDifference;
-                    iCurrentClosestRange = iRange;
-                }
-            }
-        }
-
-        MA_ASSERT(iCurrentClosestRange != (UInt32)-1);
-
-        *pSampleRateOut = pSampleRateRanges[iCurrentClosestRange].mMinimum;
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_SUCCESS;
-    }
-
-    /* Should never get here, but it would mean we weren't able to find any suitable sample rates. */
-    /*ma_free(pSampleRateRanges, &pContext->allocationCallbacks);*/
-    /*return MA_ERROR;*/
-}
-#endif
-
-static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 bufferSizeInFramesIn, ma_uint32* pBufferSizeInFramesOut)
-{
-    AudioObjectPropertyAddress propAddress;
-    AudioValueRange bufferSizeRange;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pBufferSizeInFramesOut != NULL);
-
-    *pBufferSizeInFramesOut = 0;    /* Safety. */
-
-    propAddress.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(bufferSizeRange);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &bufferSizeRange);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    /* This is just a clamp. */
-    if (bufferSizeInFramesIn < bufferSizeRange.mMinimum) {
-        *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMinimum;
-    } else if (bufferSizeInFramesIn > bufferSizeRange.mMaximum) {
-        *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMaximum;
-    } else {
-        *pBufferSizeInFramesOut = bufferSizeInFramesIn;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pPeriodSizeInOut)
-{
-    ma_result result;
-    ma_uint32 chosenBufferSizeInFrames;
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_closest_buffer_size_in_frames(pContext, deviceObjectID, deviceType, *pPeriodSizeInOut, &chosenBufferSizeInFrames);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Try setting the size of the buffer... If this fails we just use whatever is currently set. */
-    propAddress.mSelector = kAudioDevicePropertyBufferFrameSize;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames);
-
-    /* Get the actual size of the buffer. */
-    dataSize = sizeof(*pPeriodSizeInOut);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &chosenBufferSizeInFrames);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pPeriodSizeInOut = chosenBufferSizeInFrames;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_type deviceType, AudioObjectID* pDeviceObjectID)
-{
-    AudioObjectPropertyAddress propAddressDefaultDevice;
-    UInt32 defaultDeviceObjectIDSize = sizeof(AudioObjectID);
-    AudioObjectID defaultDeviceObjectID;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceObjectID != NULL);
-
-    /* Safety. */
-    *pDeviceObjectID = 0;
-
-    propAddressDefaultDevice.mScope = kAudioObjectPropertyScopeGlobal;
-    propAddressDefaultDevice.mElement = kAudioObjectPropertyElementMaster;
-    if (deviceType == ma_device_type_playback) {
-        propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-    } else {
-        propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-    }
-
-    defaultDeviceObjectIDSize = sizeof(AudioObjectID);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, NULL, &defaultDeviceObjectIDSize, &defaultDeviceObjectID);
-    if (status == noErr) {
-        *pDeviceObjectID = defaultDeviceObjectID;
-        return MA_SUCCESS;
-    }
-
-    /* If we get here it means we couldn't find the device. */
-    return MA_NO_DEVICE;
-}
-
-static ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, AudioObjectID* pDeviceObjectID)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceObjectID != NULL);
-
-    /* Safety. */
-    *pDeviceObjectID = 0;
-
-    if (pDeviceID == NULL) {
-        /* Default device. */
-        return ma_find_default_AudioObjectID(pContext, deviceType, pDeviceObjectID);
-    } else {
-        /* Explicit device. */
-        UInt32 deviceCount;
-        AudioObjectID* pDeviceObjectIDs;
-        ma_result result;
-        UInt32 iDevice;
-
-        result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice];
-
-            char uid[256];
-            if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(uid), uid) != MA_SUCCESS) {
-                continue;
-            }
-
-            if (deviceType == ma_device_type_playback) {
-                if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
-                    if (strcmp(uid, pDeviceID->coreaudio) == 0) {
-                        *pDeviceObjectID = deviceObjectID;
-                        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-                        return MA_SUCCESS;
-                    }
-                }
-            } else {
-                if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
-                    if (strcmp(uid, pDeviceID->coreaudio) == 0) {
-                        *pDeviceObjectID = deviceObjectID;
-                        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-                        return MA_SUCCESS;
-                    }
-                }
-            }
-        }
-
-        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-    }
-
-    /* If we get here it means we couldn't find the device. */
-    return MA_NO_DEVICE;
-}
-
-
-static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const AudioStreamBasicDescription* pOrigFormat, AudioStreamBasicDescription* pFormat)
-{
-    UInt32 deviceFormatDescriptionCount;
-    AudioStreamRangedDescription* pDeviceFormatDescriptions;
-    ma_result result;
-    ma_uint32 desiredSampleRate;
-    ma_uint32 desiredChannelCount;
-    ma_format desiredFormat;
-    AudioStreamBasicDescription bestDeviceFormatSoFar;
-    ma_bool32 hasSupportedFormat;
-    UInt32 iFormat;
-
-    result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &deviceFormatDescriptionCount, &pDeviceFormatDescriptions);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    desiredSampleRate = sampleRate;
-    if (desiredSampleRate == 0) {
-        desiredSampleRate = pOrigFormat->mSampleRate;
-    }
-
-    desiredChannelCount = channels;
-    if (desiredChannelCount == 0) {
-        desiredChannelCount = pOrigFormat->mChannelsPerFrame;
-    }
-
-    desiredFormat = format;
-    if (desiredFormat == ma_format_unknown) {
-        result = ma_format_from_AudioStreamBasicDescription(pOrigFormat, &desiredFormat);
-        if (result != MA_SUCCESS || desiredFormat == ma_format_unknown) {
-            desiredFormat = g_maFormatPriorities[0];
-        }
-    }
-
-    /*
-    If we get here it means we don't have an exact match to what the client is asking for. We'll need to find the closest one. The next
-    loop will check for formats that have the same sample rate to what we're asking for. If there is, we prefer that one in all cases.
-    */
-    MA_ZERO_OBJECT(&bestDeviceFormatSoFar);
-
-    hasSupportedFormat = MA_FALSE;
-    for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
-        ma_format format;
-        ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format);
-        if (formatResult == MA_SUCCESS && format != ma_format_unknown) {
-            hasSupportedFormat = MA_TRUE;
-            bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
-            break;
-        }
-    }
-
-    if (!hasSupportedFormat) {
-        ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks);
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-
-    for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
-        AudioStreamBasicDescription thisDeviceFormat = pDeviceFormatDescriptions[iFormat].mFormat;
-        ma_format thisSampleFormat;
-        ma_result formatResult;
-        ma_format bestSampleFormatSoFar;
-
-        /* If the format is not supported by miniaudio we need to skip this one entirely. */
-        formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &thisSampleFormat);
-        if (formatResult != MA_SUCCESS || thisSampleFormat == ma_format_unknown) {
-            continue;   /* The format is not supported by miniaudio. Skip. */
-        }
-
-        ma_format_from_AudioStreamBasicDescription(&bestDeviceFormatSoFar, &bestSampleFormatSoFar);
-
-        /* Getting here means the format is supported by miniaudio which makes this format a candidate. */
-        if (thisDeviceFormat.mSampleRate != desiredSampleRate) {
-            /*
-            The sample rate does not match, but this format could still be usable, although it's a very low priority. If the best format
-            so far has an equal sample rate we can just ignore this one.
-            */
-            if (bestDeviceFormatSoFar.mSampleRate == desiredSampleRate) {
-                continue;   /* The best sample rate so far has the same sample rate as what we requested which means it's still the best so far. Skip this format. */
-            } else {
-                /* In this case, neither the best format so far nor this one have the same sample rate. Check the channel count next. */
-                if (thisDeviceFormat.mChannelsPerFrame != desiredChannelCount) {
-                    /* This format has a different sample rate _and_ a different channel count. */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        continue;   /* No change to the best format. */
-                    } else {
-                        /*
-                        Both this format and the best so far have different sample rates and different channel counts. Whichever has the
-                        best format is the new best.
-                        */
-                        if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            continue;
-                        } else {
-                            continue;   /* No change to the best format. */
-                        }
-                    }
-                } else {
-                    /* This format has a different sample rate but the desired channel count. */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        /* Both this format and the best so far have the desired channel count. Whichever has the best format is the new best. */
-                        if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            continue;
-                        } else {
-                            continue;   /* No change to the best format for now. */
-                        }
-                    } else {
-                        /* This format has the desired channel count, but the best so far does not. We have a new best. */
-                        bestDeviceFormatSoFar = thisDeviceFormat;
-                        continue;
-                    }
-                }
-            }
-        } else {
-            /*
-            The sample rates match which makes this format a very high priority contender. If the best format so far has a different
-            sample rate it needs to be replaced with this one.
-            */
-            if (bestDeviceFormatSoFar.mSampleRate != desiredSampleRate) {
-                bestDeviceFormatSoFar = thisDeviceFormat;
-                continue;
-            } else {
-                /* In this case both this format and the best format so far have the same sample rate. Check the channel count next. */
-                if (thisDeviceFormat.mChannelsPerFrame == desiredChannelCount) {
-                    /*
-                    In this case this format has the same channel count as what the client is requesting. If the best format so far has
-                    a different count, this one becomes the new best.
-                    */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame != desiredChannelCount) {
-                        bestDeviceFormatSoFar = thisDeviceFormat;
-                        continue;
-                    } else {
-                        /* In this case both this format and the best so far have the ideal sample rate and channel count. Check the format. */
-                        if (thisSampleFormat == desiredFormat) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            break;  /* Found the exact match. */
-                        } else {
-                            /* The formats are different. The new best format is the one with the highest priority format according to miniaudio. */
-                            if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                                bestDeviceFormatSoFar = thisDeviceFormat;
-                                continue;
-                            } else {
-                                continue;   /* No change to the best format for now. */
-                            }
-                        }
-                    }
-                } else {
-                    /*
-                    In this case the channel count is different to what the client has requested. If the best so far has the same channel
-                    count as the requested count then it remains the best.
-                    */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        continue;
-                    } else {
-                        /*
-                        This is the case where both have the same sample rate (good) but different channel counts. Right now both have about
-                        the same priority, but we need to compare the format now.
-                        */
-                        if (thisSampleFormat == bestSampleFormatSoFar) {
-                            if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                                bestDeviceFormatSoFar = thisDeviceFormat;
-                                continue;
-                            } else {
-                                continue;   /* No change to the best format for now. */
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    *pFormat = bestDeviceFormatSoFar;
-
-    ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioUnit_channel_map(ma_context* pContext, AudioUnit audioUnit, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    AudioUnitScope deviceScope;
-    AudioUnitElement deviceBus;
-    UInt32 channelLayoutSize;
-    OSStatus status;
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    if (deviceType == ma_device_type_playback) {
-        deviceScope = kAudioUnitScope_Input;
-        deviceBus = MA_COREAUDIO_OUTPUT_BUS;
-    } else {
-        deviceScope = kAudioUnitScope_Output;
-        deviceBus = MA_COREAUDIO_INPUT_BUS;
-    }
-
-    status = ((ma_AudioUnitGetPropertyInfo_proc)pContext->coreaudio.AudioUnitGetPropertyInfo)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, &channelLayoutSize, NULL);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pChannelLayout = (AudioChannelLayout*)ma__malloc_from_callbacks(channelLayoutSize, &pContext->allocationCallbacks);
-    if (pChannelLayout == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, pChannelLayout, &channelLayoutSize);
-    if (status != noErr) {
-        ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap);
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-        return result;
-    }
-
-    ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-#endif /* MA_APPLE_DESKTOP */
-
-
-#if !defined(MA_APPLE_DESKTOP)
-static void ma_AVAudioSessionPortDescription_to_device_info(AVAudioSessionPortDescription* pPortDesc, ma_device_info* pInfo)
-{
-    MA_ZERO_OBJECT(pInfo);
-    ma_strncpy_s(pInfo->name,         sizeof(pInfo->name),         [pPortDesc.portName UTF8String], (size_t)-1);
-    ma_strncpy_s(pInfo->id.coreaudio, sizeof(pInfo->id.coreaudio), [pPortDesc.UID      UTF8String], (size_t)-1);
-}
-#endif
-
-static ma_result ma_context_enumerate_devices__coreaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-#if defined(MA_APPLE_DESKTOP)
-    UInt32 deviceCount;
-    AudioObjectID* pDeviceObjectIDs;
-    AudioObjectID defaultDeviceObjectIDPlayback;
-    AudioObjectID defaultDeviceObjectIDCapture;
-    ma_result result;
-    UInt32 iDevice;
-
-    ma_find_default_AudioObjectID(pContext, ma_device_type_playback, &defaultDeviceObjectIDPlayback);   /* OK if this fails. */
-    ma_find_default_AudioObjectID(pContext, ma_device_type_capture,  &defaultDeviceObjectIDCapture);    /* OK if this fails. */
-
-    result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-        AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice];
-        ma_device_info info;
-
-        MA_ZERO_OBJECT(&info);
-        if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(info.id.coreaudio), info.id.coreaudio) != MA_SUCCESS) {
-            continue;
-        }
-        if (ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(info.name), info.name) != MA_SUCCESS) {
-            continue;
-        }
-
-        if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
-            if (deviceObjectID == defaultDeviceObjectIDPlayback) {
-                info.isDefault = MA_TRUE;
-            }
-
-            if (!callback(pContext, ma_device_type_playback, &info, pUserData)) {
-                break;
-            }
-        }
-        if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
-            if (deviceObjectID == defaultDeviceObjectIDCapture) {
-                info.isDefault = MA_TRUE;
-            }
-
-            if (!callback(pContext, ma_device_type_capture, &info, pUserData)) {
-                break;
-            }
-        }
-    }
-
-    ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-#else
-    ma_device_info info;
-    NSArray *pInputs  = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-    NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs];
-
-    for (AVAudioSessionPortDescription* pPortDesc in pOutputs) {
-        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info);
-        if (!callback(pContext, ma_device_type_playback, &info, pUserData)) {
-            return MA_SUCCESS;
-        }
-    }
-
-    for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info);
-        if (!callback(pContext, ma_device_type_capture, &info, pUserData)) {
-            return MA_SUCCESS;
-        }
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-#if defined(MA_APPLE_DESKTOP)
-    /* Desktop */
-    {
-        AudioObjectID deviceObjectID;
-        AudioObjectID defaultDeviceObjectID;
-        UInt32 streamDescriptionCount;
-        AudioStreamRangedDescription* pStreamDescriptions;
-        UInt32 iStreamDescription;
-        UInt32 sampleRateRangeCount;
-        AudioValueRange* pSampleRateRanges;
-
-        ma_find_default_AudioObjectID(pContext, deviceType, &defaultDeviceObjectID);     /* OK if this fails. */
-
-        result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(pDeviceInfo->id.coreaudio), pDeviceInfo->id.coreaudio);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pDeviceInfo->name), pDeviceInfo->name);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (deviceObjectID == defaultDeviceObjectID) {
-            pDeviceInfo->isDefault = MA_TRUE;
-        }
-        
-        /*
-        There could be a large number of permutations here. Fortunately there is only a single channel count
-        being reported which reduces this quite a bit. For sample rates we're only reporting those that are
-        one of miniaudio's recognized "standard" rates. If there are still more formats than can fit into
-        our fixed sized array we'll just need to truncate them. This is unlikely and will probably only happen
-        if some driver performs software data conversion and therefore reports every possible format and
-        sample rate.
-        */
-        pDeviceInfo->nativeDataFormatCount = 0;
-        
-        /* Formats. */
-        {
-            ma_format uniqueFormats[ma_format_count];
-            ma_uint32 uniqueFormatCount = 0;
-            ma_uint32 channels;
-            
-            /* Channels. */
-            result = ma_get_AudioObject_channel_count(pContext, deviceObjectID, deviceType, &channels);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-            
-            /* Formats. */
-            result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &streamDescriptionCount, &pStreamDescriptions);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            for (iStreamDescription = 0; iStreamDescription < streamDescriptionCount; ++iStreamDescription) {
-                ma_format format;
-                ma_bool32 hasFormatBeenHandled = MA_FALSE;
-                ma_uint32 iOutputFormat;
-                ma_uint32 iSampleRate;
-
-                result = ma_format_from_AudioStreamBasicDescription(&pStreamDescriptions[iStreamDescription].mFormat, &format);
-                if (result != MA_SUCCESS) {
-                    continue;
-                }
-
-                MA_ASSERT(format != ma_format_unknown);
-
-                /* Make sure the format isn't already in the output list. */
-                for (iOutputFormat = 0; iOutputFormat < uniqueFormatCount; ++iOutputFormat) {
-                    if (uniqueFormats[iOutputFormat] == format) {
-                        hasFormatBeenHandled = MA_TRUE;
-                        break;
-                    }
-                }
-                
-                /* If we've already handled this format just skip it. */
-                if (hasFormatBeenHandled) {
-                    continue;
-                }
-                
-                uniqueFormatCount += 1;
-                
-
-                /* Sample Rates */
-                result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges);
-                if (result != MA_SUCCESS) {
-                    return result;
-                }
-                
-                /*
-                Annoyingly Core Audio reports a sample rate range. We just get all the standard rates that are
-                between this range.
-                */
-                for (iSampleRate = 0; iSampleRate < sampleRateRangeCount; ++iSampleRate) {
-                    ma_uint32 iStandardSampleRate;
-                    for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) {
-                        ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate];
-                        if (standardSampleRate >= pSampleRateRanges[iSampleRate].mMinimum && standardSampleRate <= pSampleRateRanges[iSampleRate].mMaximum) {
-                            /* We have a new data format. Add it to the list. */
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = standardSampleRate;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-                            pDeviceInfo->nativeDataFormatCount += 1;
-                            
-                            if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) {
-                                break;  /* No more room for any more formats. */
-                            }
-                        }
-                    }
-                }
-                
-                ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-
-                if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) {
-                    break;  /* No more room for any more formats. */
-                }
-            }
-
-            ma_free(pStreamDescriptions, &pContext->allocationCallbacks);
-        }
-    }
-#else
-    /* Mobile */
-    {
-        AudioComponentDescription desc;
-        AudioComponent component;
-        AudioUnit audioUnit;
-        OSStatus status;
-        AudioUnitScope formatScope;
-        AudioUnitElement formatElement;
-        AudioStreamBasicDescription bestFormat;
-        UInt32 propSize;
-
-        /* We want to ensure we use a consistent device name to device enumeration. */
-        if (pDeviceID != NULL) {
-            ma_bool32 found = MA_FALSE;
-            if (deviceType == ma_device_type_playback) {
-                NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs];
-                for (AVAudioSessionPortDescription* pPortDesc in pOutputs) {
-                    if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo);
-                        found = MA_TRUE;
-                        break;
-                    }
-                }
-            } else {
-                NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-                for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-                    if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo);
-                        found = MA_TRUE;
-                        break;
-                    }
-                }
-            }
-
-            if (!found) {
-                return MA_DOES_NOT_EXIST;
-            }
-        } else {
-            if (deviceType == ma_device_type_playback) {
-                ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-            } else {
-                ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            }
-        }
-
-
-        /*
-        Retrieving device information is more annoying on mobile than desktop. For simplicity I'm locking this down to whatever format is
-        reported on a temporary I/O unit. The problem, however, is that this doesn't return a value for the sample rate which we need to
-        retrieve from the AVAudioSession shared instance.
-        */
-        desc.componentType = kAudioUnitType_Output;
-        desc.componentSubType = kAudioUnitSubType_RemoteIO;
-        desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-        desc.componentFlags = 0;
-        desc.componentFlagsMask = 0;
-
-        component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc);
-        if (component == NULL) {
-            return MA_FAILED_TO_INIT_BACKEND;
-        }
-
-        status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)(component, &audioUnit);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-
-        formatScope   = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output;
-        formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS;
-
-        propSize = sizeof(bestFormat);
-        status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, &propSize);
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit);
-        audioUnit = NULL;
-
-        /* Only a single format is being reported for iOS. */
-        pDeviceInfo->nativeDataFormatCount = 1;
-        
-        result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pDeviceInfo->nativeDataFormats[0].format);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-        
-        pDeviceInfo->nativeDataFormats[0].channels = bestFormat.mChannelsPerFrame;
-
-        /*
-        It looks like Apple are wanting to push the whole AVAudioSession thing. Thus, we need to use that to determine device settings. To do
-        this we just get the shared instance and inspect.
-        */
-        @autoreleasepool {
-            AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-            MA_ASSERT(pAudioSession != NULL);
-
-            pDeviceInfo->nativeDataFormats[0].sampleRate = (ma_uint32)pAudioSession.sampleRate;
-        }
-    }
-#endif
-
-    (void)pDeviceInfo; /* Unused. */
-    return MA_SUCCESS;
-}
-
-static AudioBufferList* ma_allocate_AudioBufferList__coreaudio(ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    AudioBufferList* pBufferList;
-    UInt32 audioBufferSizeInBytes;
-    size_t allocationSize;
-
-    MA_ASSERT(sizeInFrames > 0);
-    MA_ASSERT(format != ma_format_unknown);
-    MA_ASSERT(channels > 0);
-
-    allocationSize = sizeof(AudioBufferList) - sizeof(AudioBuffer);  /* Subtract sizeof(AudioBuffer) because that part is dynamically sized. */
-    if (layout == ma_stream_layout_interleaved) {
-        /* Interleaved case. This is the simple case because we just have one buffer. */
-        allocationSize += sizeof(AudioBuffer) * 1;
-    } else {
-        /* Non-interleaved case. This is the more complex case because there's more than one buffer. */
-        allocationSize += sizeof(AudioBuffer) * channels;
-    }
-
-    allocationSize += sizeInFrames * ma_get_bytes_per_frame(format, channels);
-
-    pBufferList = (AudioBufferList*)ma__malloc_from_callbacks(allocationSize, pAllocationCallbacks);
-    if (pBufferList == NULL) {
-        return NULL;
-    }
-
-    audioBufferSizeInBytes = (UInt32)(sizeInFrames * ma_get_bytes_per_sample(format));
-
-    if (layout == ma_stream_layout_interleaved) {
-        pBufferList->mNumberBuffers = 1;
-        pBufferList->mBuffers[0].mNumberChannels = channels;
-        pBufferList->mBuffers[0].mDataByteSize   = audioBufferSizeInBytes * channels;
-        pBufferList->mBuffers[0].mData           = (ma_uint8*)pBufferList + sizeof(AudioBufferList);
-    } else {
-        ma_uint32 iBuffer;
-        pBufferList->mNumberBuffers = channels;
-        for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) {
-            pBufferList->mBuffers[iBuffer].mNumberChannels = 1;
-            pBufferList->mBuffers[iBuffer].mDataByteSize   = audioBufferSizeInBytes;
-            pBufferList->mBuffers[iBuffer].mData           = (ma_uint8*)pBufferList + ((sizeof(AudioBufferList) - sizeof(AudioBuffer)) + (sizeof(AudioBuffer) * channels)) + (audioBufferSizeInBytes * iBuffer);
-        }
-    }
-
-    return pBufferList;
-}
-
-static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice, ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(format != ma_format_unknown);
-    MA_ASSERT(channels > 0);
-
-    /* Only resize the buffer if necessary. */
-    if (pDevice->coreaudio.audioBufferCapInFrames < sizeInFrames) {
-        AudioBufferList* pNewAudioBufferList;
-
-        pNewAudioBufferList = ma_allocate_AudioBufferList__coreaudio(sizeInFrames, format, channels, layout, &pDevice->pContext->allocationCallbacks);
-        if (pNewAudioBufferList != NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        /* At this point we'll have a new AudioBufferList and we can free the old one. */
-        ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-        pDevice->coreaudio.pAudioBufferList = pNewAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames = sizeInFrames;
-    }
-
-    /* Getting here means the capacity of the audio is fine. */
-    return MA_SUCCESS;
-}
-
-
-static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pBufferList)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_stream_layout layout;
-
-    MA_ASSERT(pDevice != NULL);
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pBufferList->mNumberBuffers);
-#endif
-
-    /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */
-    layout = ma_stream_layout_interleaved;
-    if (pBufferList->mBuffers[0].mNumberChannels != pDevice->playback.internalChannels) {
-        layout = ma_stream_layout_deinterleaved;
-    }
-
-    if (layout == ma_stream_layout_interleaved) {
-        /* For now we can assume everything is interleaved. */
-        UInt32 iBuffer;
-        for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) {
-            if (pBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->playback.internalChannels) {
-                ma_uint32 frameCountForThisBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-                if (frameCountForThisBuffer > 0) {
-                    ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer);
-                }
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            } else {
-                /*
-                This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
-                not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams. We just
-                output silence here.
-                */
-                MA_ZERO_MEMORY(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize);
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            }
-        }
-    } else {
-        /* This is the deinterleaved case. We need to update each buffer in groups of internalChannels. This assumes each buffer is the same size. */
-        MA_ASSERT(pDevice->playback.internalChannels <= MA_MAX_CHANNELS);   /* This should heve been validated at initialization time. */
-
-        /*
-        For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something
-        very strange has happened and we're not going to support it.
-        */
-        if ((pBufferList->mNumberBuffers % pDevice->playback.internalChannels) == 0) {
-            ma_uint8 tempBuffer[4096];
-            UInt32 iBuffer;
-
-            for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; iBuffer += pDevice->playback.internalChannels) {
-                ma_uint32 frameCountPerBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_sample(pDevice->playback.internalFormat);
-                ma_uint32 framesRemaining = frameCountPerBuffer;
-
-                while (framesRemaining > 0) {
-                    void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
-                    ma_uint32 iChannel;
-                    ma_uint32 framesToRead = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-                    if (framesToRead > framesRemaining) {
-                        framesToRead = framesRemaining;
-                    }
-                    
-                    ma_device_handle_backend_data_callback(pDevice, tempBuffer, NULL, framesToRead);
-
-                    for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-                        ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pBufferList->mBuffers[iBuffer+iChannel].mData, (frameCountPerBuffer - framesRemaining) * ma_get_bytes_per_sample(pDevice->playback.internalFormat));
-                    }
-
-                    ma_deinterleave_pcm_frames(pDevice->playback.internalFormat, pDevice->playback.internalChannels, framesToRead, tempBuffer, ppDeinterleavedBuffers);
-
-                    framesRemaining -= framesToRead;
-                }
-            }
-        }
-    }
-
-    (void)pActionFlags;
-    (void)pTimeStamp;
-    (void)busNumber;
-    (void)frameCount;
-
-    return noErr;
-}
-
-static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pUnusedBufferList)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    AudioBufferList* pRenderedBufferList;
-    ma_result result;
-    ma_stream_layout layout;
-    ma_uint32 iBuffer;
-    OSStatus status;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList;
-    MA_ASSERT(pRenderedBufferList);
-
-    /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */
-    layout = ma_stream_layout_interleaved;
-    if (pRenderedBufferList->mBuffers[0].mNumberChannels != pDevice->capture.internalChannels) {
-        layout = ma_stream_layout_deinterleaved;
-    }
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pRenderedBufferList->mNumberBuffers);
-#endif
-
-    /*
-    There has been a situation reported where frame count passed into this function is greater than the capacity of
-    our capture buffer. There doesn't seem to be a reliable way to determine what the maximum frame count will be,
-    so we need to instead resort to dynamically reallocating our buffer to ensure it's large enough to capture the
-    number of frames requested by this callback.
-    */
-    result = ma_device_realloc_AudioBufferList__coreaudio(pDevice, frameCount, pDevice->capture.internalFormat, pDevice->capture.internalChannels, layout);
-    if (result != MA_SUCCESS) {
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("Failed to allocate AudioBufferList for capture.");
-    #endif
-        return noErr;
-    }
-
-    /*
-    When you call AudioUnitRender(), Core Audio tries to be helpful by setting the mDataByteSize to the number of bytes
-    that were actually rendered. The problem with this is that the next call can fail with -50 due to the size no longer
-    being set to the capacity of the buffer, but instead the size in bytes of the previous render. This will cause a
-    problem when a future call to this callback specifies a larger number of frames.
-
-    To work around this we need to explicitly set the size of each buffer to their respective size in bytes.
-    */
-    for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) {
-        pRenderedBufferList->mBuffers[iBuffer].mDataByteSize = pDevice->coreaudio.audioBufferCapInFrames * ma_get_bytes_per_sample(pDevice->capture.internalFormat) * pRenderedBufferList->mBuffers[iBuffer].mNumberChannels;
-    }
-
-    status = ((ma_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList);
-    if (status != noErr) {
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("  ERROR: AudioUnitRender() failed with %d\n", status);
-    #endif
-        return status;
-    }
-
-    if (layout == ma_stream_layout_interleaved) {
-        for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) {
-            if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) {
-                ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount);
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  mDataByteSize=%d\n", pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            } else {
-                /*
-                This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
-                not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams.
-                */
-                ma_uint8 silentBuffer[4096];
-                ma_uint32 framesRemaining;
-
-                MA_ZERO_MEMORY(silentBuffer, sizeof(silentBuffer));
-
-                framesRemaining = frameCount;
-                while (framesRemaining > 0) {
-                    ma_uint32 framesToSend = sizeof(silentBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-                    if (framesToSend > framesRemaining) {
-                        framesToSend = framesRemaining;
-                    }
-                    
-                    ma_device_handle_backend_data_callback(pDevice, NULL, silentBuffer, framesToSend);
-
-                    framesRemaining -= framesToSend;
-                }
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            }
-        }
-    } else {
-        /* This is the deinterleaved case. We need to interleave the audio data before sending it to the client. This assumes each buffer is the same size. */
-        MA_ASSERT(pDevice->capture.internalChannels <= MA_MAX_CHANNELS);    /* This should have been validated at initialization time. */
-
-        /*
-        For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something
-        very strange has happened and we're not going to support it.
-        */
-        if ((pRenderedBufferList->mNumberBuffers % pDevice->capture.internalChannels) == 0) {
-            ma_uint8 tempBuffer[4096];
-            for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; iBuffer += pDevice->capture.internalChannels) {
-                ma_uint32 framesRemaining = frameCount;
-                while (framesRemaining > 0) {
-                    void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
-                    ma_uint32 iChannel;
-                    ma_uint32 framesToSend = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-                    if (framesToSend > framesRemaining) {
-                        framesToSend = framesRemaining;
-                    }
-
-                    for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-                        ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pRenderedBufferList->mBuffers[iBuffer+iChannel].mData, (frameCount - framesRemaining) * ma_get_bytes_per_sample(pDevice->capture.internalFormat));
-                    }
-
-                    ma_interleave_pcm_frames(pDevice->capture.internalFormat, pDevice->capture.internalChannels, framesToSend, (const void**)ppDeinterleavedBuffers, tempBuffer);
-                    ma_device_handle_backend_data_callback(pDevice, NULL, tempBuffer, framesToSend);
-
-                    framesRemaining -= framesToSend;
-                }
-            }
-        }
-    }
-
-    (void)pActionFlags;
-    (void)pTimeStamp;
-    (void)busNumber;
-    (void)frameCount;
-    (void)pUnusedBufferList;
-
-    return noErr;
-}
-
-static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPropertyID propertyID, AudioUnitScope scope, AudioUnitElement element)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    There's been a report of a deadlock here when triggered by ma_device_uninit(). It looks like
-    AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in ma_device_uninit)
-    can try waiting on the same lock. I'm going to try working around this by not calling any Core
-    Audio APIs in the callback when the device has been stopped or uninitialized.
-    */
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED || ma_device_get_state(pDevice) == MA_STATE_STOPPING || ma_device_get_state(pDevice) == MA_STATE_STOPPED) {
-        ma_stop_proc onStop = pDevice->onStop;
-        if (onStop) {
-            onStop(pDevice);
-        }
-
-        ma_event_signal(&pDevice->coreaudio.stopEvent);
-    } else {
-        UInt32 isRunning;
-        UInt32 isRunningSize = sizeof(isRunning);
-        OSStatus status = ((ma_AudioUnitGetProperty_proc)pDevice->pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioOutputUnitProperty_IsRunning, scope, element, &isRunning, &isRunningSize);
-        if (status != noErr) {
-            return; /* Don't really know what to do in this case... just ignore it, I suppose... */
-        }
-
-        if (!isRunning) {
-            ma_stop_proc onStop;
-
-            /*
-            The stop event is a bit annoying in Core Audio because it will be called when we automatically switch the default device. Some scenarios to consider:
-
-            1) When the device is unplugged, this will be called _before_ the default device change notification.
-            2) When the device is changed via the default device change notification, this will be called _after_ the switch.
-
-            For case #1, we just check if there's a new default device available. If so, we just ignore the stop event. For case #2 we check a flag.
-            */
-            if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isDefaultPlaybackDevice) ||
-                ((audioUnit == pDevice->coreaudio.audioUnitCapture)  && pDevice->coreaudio.isDefaultCaptureDevice)) {
-                /*
-                It looks like the device is switching through an external event, such as the user unplugging the device or changing the default device
-                via the operating system's sound settings. If we're re-initializing the device, we just terminate because we want the stopping of the
-                device to be seamless to the client (we don't want them receiving the onStop event and thinking that the device has stopped when it
-                hasn't!).
-                */
-                if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) ||
-                    ((audioUnit == pDevice->coreaudio.audioUnitCapture)  && pDevice->coreaudio.isSwitchingCaptureDevice)) {
-                    return;
-                }
-
-                /*
-                Getting here means the device is not reinitializing which means it may have been unplugged. From what I can see, it looks like Core Audio
-                will try switching to the new default device seamlessly. We need to somehow find a way to determine whether or not Core Audio will most
-                likely be successful in switching to the new device.
-
-                TODO: Try to predict if Core Audio will switch devices. If not, the onStop callback needs to be posted.
-                */
-                return;
-            }
-
-            /* Getting here means we need to stop the device. */
-            onStop = pDevice->onStop;
-            if (onStop) {
-                onStop(pDevice);
-            }
-        }
-    }
-
-    (void)propertyID; /* Unused. */
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_spinlock g_DeviceTrackingInitLock_CoreAudio = 0;  /* A spinlock for mutal exclusion of the init/uninit of the global tracking data. Initialization to 0 is what we need. */
-static ma_uint32   g_DeviceTrackingInitCounter_CoreAudio = 0;
-static ma_mutex    g_DeviceTrackingMutex_CoreAudio;
-static ma_device** g_ppTrackedDevices_CoreAudio = NULL;
-static ma_uint32   g_TrackedDeviceCap_CoreAudio = 0;
-static ma_uint32   g_TrackedDeviceCount_CoreAudio = 0;
-
-static OSStatus ma_default_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData)
-{
-    ma_device_type deviceType;
-
-    /* Not sure if I really need to check this, but it makes me feel better. */
-    if (addressCount == 0) {
-        return noErr;
-    }
-
-    if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultOutputDevice) {
-        deviceType = ma_device_type_playback;
-    } else if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultInputDevice) {
-        deviceType = ma_device_type_capture;
-    } else {
-        return noErr;   /* Should never hit this. */
-    }
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        ma_uint32 iDevice;
-        for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) {
-            ma_result reinitResult;
-            ma_device* pDevice;
-
-            pDevice = g_ppTrackedDevices_CoreAudio[iDevice];
-            if (pDevice->type == deviceType || pDevice->type == ma_device_type_duplex) {
-                if (deviceType == ma_device_type_playback) {
-                    pDevice->coreaudio.isSwitchingPlaybackDevice = MA_TRUE;
-                    reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE);
-                    pDevice->coreaudio.isSwitchingPlaybackDevice = MA_FALSE;
-                } else {
-                    pDevice->coreaudio.isSwitchingCaptureDevice = MA_TRUE;
-                    reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE);
-                    pDevice->coreaudio.isSwitchingCaptureDevice = MA_FALSE;
-                }
-
-                if (reinitResult == MA_SUCCESS) {
-                    ma_device__post_init_setup(pDevice, deviceType);
-
-                    /* Restart the device if required. If this fails we need to stop the device entirely. */
-                    if (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-                        OSStatus status;
-                        if (deviceType == ma_device_type_playback) {
-                            status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-                            if (status != noErr) {
-                                if (pDevice->type == ma_device_type_duplex) {
-                                    ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                                }
-                                ma_device__set_state(pDevice, MA_STATE_STOPPED);
-                            }
-                        } else if (deviceType == ma_device_type_capture) {
-                            status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                            if (status != noErr) {
-                                if (pDevice->type == ma_device_type_duplex) {
-                                    ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-                                }
-                                ma_device__set_state(pDevice, MA_STATE_STOPPED);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    /* Unused parameters. */
-    (void)objectID;
-    (void)pUserData;
-
-    return noErr;
-}
-
-static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio);
-    {
-        /* Don't do anything if we've already initializd device tracking. */
-        if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
-            AudioObjectPropertyAddress propAddress;
-            propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            ma_mutex_init(&g_DeviceTrackingMutex_CoreAudio);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-            ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-            ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            g_DeviceTrackingInitCounter_CoreAudio += 1;
-        }
-    }
-    ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio);
-    {
-        g_DeviceTrackingInitCounter_CoreAudio -= 1;
-
-        if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
-            AudioObjectPropertyAddress propAddress;
-            propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-            ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-            ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            /* At this point there should be no tracked devices. If not there's an error somewhere. */
-            if (g_ppTrackedDevices_CoreAudio != NULL) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "You have uninitialized all contexts while an associated device is still active.", MA_INVALID_OPERATION);
-            }
-
-            ma_mutex_uninit(&g_DeviceTrackingMutex_CoreAudio);
-        }
-    }
-    ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__track__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        /* Allocate memory if required. */
-        if (g_TrackedDeviceCap_CoreAudio <= g_TrackedDeviceCount_CoreAudio) {
-            ma_uint32 oldCap;
-            ma_uint32 newCap;
-            ma_device** ppNewDevices;
-
-            oldCap = g_TrackedDeviceCap_CoreAudio;
-            newCap = g_TrackedDeviceCap_CoreAudio * 2;
-            if (newCap == 0) {
-                newCap = 1;
-            }
-
-            ppNewDevices = (ma_device**)ma__realloc_from_callbacks(g_ppTrackedDevices_CoreAudio, sizeof(*g_ppTrackedDevices_CoreAudio)*newCap, sizeof(*g_ppTrackedDevices_CoreAudio)*oldCap, &pDevice->pContext->allocationCallbacks);
-            if (ppNewDevices == NULL) {
-                ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-                return MA_OUT_OF_MEMORY;
-            }
-
-            g_ppTrackedDevices_CoreAudio = ppNewDevices;
-            g_TrackedDeviceCap_CoreAudio = newCap;
-        }
-
-        g_ppTrackedDevices_CoreAudio[g_TrackedDeviceCount_CoreAudio] = pDevice;
-        g_TrackedDeviceCount_CoreAudio += 1;
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        ma_uint32 iDevice;
-        for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) {
-            if (g_ppTrackedDevices_CoreAudio[iDevice] == pDevice) {
-                /* We've found the device. We now need to remove it from the list. */
-                ma_uint32 jDevice;
-                for (jDevice = iDevice; jDevice < g_TrackedDeviceCount_CoreAudio-1; jDevice += 1) {
-                    g_ppTrackedDevices_CoreAudio[jDevice] = g_ppTrackedDevices_CoreAudio[jDevice+1];
-                }
-
-                g_TrackedDeviceCount_CoreAudio -= 1;
-
-                /* If there's nothing else in the list we need to free memory. */
-                if (g_TrackedDeviceCount_CoreAudio == 0) {
-                    ma__free_from_callbacks(g_ppTrackedDevices_CoreAudio, &pDevice->pContext->allocationCallbacks);
-                    g_ppTrackedDevices_CoreAudio = NULL;
-                    g_TrackedDeviceCap_CoreAudio = 0;
-                }
-
-                break;
-            }
-        }
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    return MA_SUCCESS;
-}
-#endif
-
-#if defined(MA_APPLE_MOBILE)
-@interface ma_router_change_handler:NSObject {
-    ma_device* m_pDevice;
-}
-@end
-
-@implementation ma_router_change_handler
--(id)init:(ma_device*)pDevice
-{
-    self = [super init];
-    m_pDevice = pDevice;
-
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_route_change:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
-
-    return self;
-}
-
--(void)dealloc
-{
-    [self remove_handler];
-}
-
--(void)remove_handler
-{
-    [[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionRouteChangeNotification object:nil];
-}
-
--(void)handle_route_change:(NSNotification*)pNotification
-{
-    AVAudioSession* pSession = [AVAudioSession sharedInstance];
-
-    NSInteger reason = [[[pNotification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
-    switch (reason)
-    {
-        case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOldDeviceUnavailable\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNewDeviceAvailable\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonWakeFromSleep:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonWakeFromSleep\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonOverride:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOverride\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonCategoryChange:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonCategoryChange\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonUnknown:
-        default:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonUnknown\n");
-        #endif
-        } break;
-    }
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", (int)pSession.inputNumberOfChannels, (int)pSession.outputNumberOfChannels);
-#endif
-
-    ma_uint32 previousState = ma_device_get_state(m_pDevice);
-
-    if (previousState == MA_STATE_STARTED) {
-        ma_device_stop(m_pDevice);
-    }
-
-    if (m_pDevice->type == ma_device_type_capture || m_pDevice->type == ma_device_type_duplex) {
-        m_pDevice->capture.internalChannels   = (ma_uint32)pSession.inputNumberOfChannels;
-        m_pDevice->capture.internalSampleRate = (ma_uint32)pSession.sampleRate;
-        ma_device__post_init_setup(m_pDevice, ma_device_type_capture);
-    }
-    if (m_pDevice->type == ma_device_type_playback || m_pDevice->type == ma_device_type_duplex) {
-        m_pDevice->playback.internalChannels   = (ma_uint32)pSession.outputNumberOfChannels;
-        m_pDevice->playback.internalSampleRate = (ma_uint32)pSession.sampleRate;
-        ma_device__post_init_setup(m_pDevice, ma_device_type_playback);
-    }
-
-    if (previousState == MA_STATE_STARTED) {
-        ma_device_start(m_pDevice);
-    }
-}
-@end
-#endif
-
-static ma_result ma_device_uninit__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED);
-
-#if defined(MA_APPLE_DESKTOP)
-    /*
-    Make sure we're no longer tracking the device. It doesn't matter if we call this for a non-default device because it'll
-    just gracefully ignore it.
-    */
-    ma_device__untrack__coreaudio(pDevice);
-#endif
-#if defined(MA_APPLE_MOBILE)
-    if (pDevice->coreaudio.pRouteChangeHandler != NULL) {
-        ma_router_change_handler* pRouteChangeHandler = (__bridge_transfer ma_router_change_handler*)pDevice->coreaudio.pRouteChangeHandler;
-        [pRouteChangeHandler remove_handler];
-    }
-#endif
-
-    if (pDevice->coreaudio.audioUnitCapture != NULL) {
-        ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-    }
-    if (pDevice->coreaudio.audioUnitPlayback != NULL) {
-        ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-    }
-
-    if (pDevice->coreaudio.pAudioBufferList) {
-        ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-typedef struct
-{
-    ma_bool32 allowNominalSampleRateChange;
-
-    /* Input. */
-    ma_format formatIn;
-    ma_uint32 channelsIn;
-    ma_uint32 sampleRateIn;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesIn;
-    ma_uint32 periodSizeInMillisecondsIn;
-    ma_uint32 periodsIn;
-    ma_share_mode shareMode;
-    ma_performance_profile performanceProfile;
-    ma_bool32 registerStopEvent;
-
-    /* Output. */
-#if defined(MA_APPLE_DESKTOP)
-    AudioObjectID deviceObjectID;
-#endif
-    AudioComponent component;
-    AudioUnit audioUnit;
-    AudioBufferList* pAudioBufferList;  /* Only used for input devices. */
-    ma_format formatOut;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesOut;
-    ma_uint32 periodsOut;
-    char deviceName[256];
-} ma_device_init_internal_data__coreaudio;
-
-static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__coreaudio* pData, void* pDevice_DoNotReference)   /* <-- pDevice is typed as void* intentionally so as to avoid accidentally referencing it. */
-{
-    ma_result result;
-    OSStatus status;
-    UInt32 enableIOFlag;
-    AudioStreamBasicDescription bestFormat;
-    UInt32 actualPeriodSizeInFrames;
-    AURenderCallbackStruct callbackInfo;
-#if defined(MA_APPLE_DESKTOP)
-    AudioObjectID deviceObjectID;
-#else
-    UInt32 actualPeriodSizeInFramesSize = sizeof(actualPeriodSizeInFrames);
-#endif
-
-    /* This API should only be used for a single device type: playback or capture. No full-duplex mode. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(deviceType == ma_device_type_playback || deviceType == ma_device_type_capture);
-
-#if defined(MA_APPLE_DESKTOP)
-    pData->deviceObjectID = 0;
-#endif
-    pData->component = NULL;
-    pData->audioUnit = NULL;
-    pData->pAudioBufferList = NULL;
-
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pData->deviceObjectID = deviceObjectID;
-#endif
-
-    /* Core audio doesn't really use the notion of a period so we can leave this unmodified, but not too over the top. */
-    pData->periodsOut = pData->periodsIn;
-    if (pData->periodsOut == 0) {
-        pData->periodsOut = MA_DEFAULT_PERIODS;
-    }
-    if (pData->periodsOut > 16) {
-        pData->periodsOut = 16;
-    }
-
-
-    /* Audio unit. */
-    status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)((AudioComponent)pContext->coreaudio.component, (AudioUnit*)&pData->audioUnit);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-
-    /* The input/output buses need to be explicitly enabled and disabled. We set the flag based on the output unit first, then we just swap it for input. */
-    enableIOFlag = 1;
-    if (deviceType == ma_device_type_capture) {
-        enableIOFlag = 0;
-    }
-
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &enableIOFlag, sizeof(enableIOFlag));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    enableIOFlag = (enableIOFlag == 0) ? 1 : 0;
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &enableIOFlag, sizeof(enableIOFlag));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-
-    /* Set the device to use with this audio unit. This is only used on desktop since we are using defaults on mobile. */
-#if defined(MA_APPLE_DESKTOP)
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceObjectID, sizeof(deviceObjectID));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(result);
-    }
-#else
-    /*
-    For some reason it looks like Apple is only allowing selection of the input device. There does not appear to be any way to change
-    the default output route. I have no idea why this is like this, but for now we'll only be able to configure capture devices.
-    */
-    if (pDeviceID != NULL) {
-        if (deviceType == ma_device_type_capture) {
-            ma_bool32 found = MA_FALSE;
-            NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-            for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-                if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                    [[AVAudioSession sharedInstance] setPreferredInput:pPortDesc error:nil];
-                    found = MA_TRUE;
-                    break;
-                }
-            }
-
-            if (found == MA_FALSE) {
-                return MA_DOES_NOT_EXIST;
-            }
-        }
-    }
-#endif
-
-    /*
-    Format. This is the hardest part of initialization because there's a few variables to take into account.
-      1) The format must be supported by the device.
-      2) The format must be supported miniaudio.
-      3) There's a priority that miniaudio prefers.
-
-    Ideally we would like to use a format that's as close to the hardware as possible so we can get as close to a passthrough as possible. The
-    most important property is the sample rate. miniaudio can do format conversion for any sample rate and channel count, but cannot do the same
-    for the sample data format. If the sample data format is not supported by miniaudio it must be ignored completely.
-
-    On mobile platforms this is a bit different. We just force the use of whatever the audio unit's current format is set to.
-    */
-    {
-        AudioStreamBasicDescription origFormat;
-        UInt32 origFormatSize = sizeof(origFormat);
-        AudioUnitScope   formatScope   = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output;
-        AudioUnitElement formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS;
-
-        if (deviceType == ma_device_type_playback) {
-            status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &origFormat, &origFormatSize);
-        } else {
-            status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &origFormat, &origFormatSize);
-        }
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-
-    #if defined(MA_APPLE_DESKTOP)
-        result = ma_find_best_format__coreaudio(pContext, deviceObjectID, deviceType, pData->formatIn, pData->channelsIn, pData->sampleRateIn, &origFormat, &bestFormat);
-        if (result != MA_SUCCESS) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return result;
-        }
-
-        /*
-        Technical Note TN2091: Device input using the HAL Output Audio Unit
-            https://developer.apple.com/library/archive/technotes/tn2091/_index.html
-
-        This documentation says the following:
-
-            The internal AudioConverter can handle any *simple* conversion. Typically, this means that a client can specify ANY
-            variant of the PCM formats. Consequently, the device's sample rate should match the desired sample rate. If sample rate
-            conversion is needed, it can be accomplished by buffering the input and converting the data on a separate thread with
-            another AudioConverter.
-
-        The important part here is the mention that it can handle *simple* conversions, which does *not* include sample rate. We
-        therefore want to ensure the sample rate stays consistent. This document is specifically for input, but I'm going to play it
-        safe and apply the same rule to output as well.
-
-        I have tried going against the documentation by setting the sample rate anyway, but this just results in AudioUnitRender()
-        returning a result code of -10863. I have also tried changing the format directly on the input scope on the input bus, but
-        this just results in `ca_require: IsStreamFormatWritable(inScope, inElement) NotWritable` when trying to set the format.
-
-        Something that does seem to work, however, has been setting the nominal sample rate on the deivce object. The problem with
-        this, however, is that it actually changes the sample rate at the operating system level and not just the application. This
-        could be intrusive to the user, however, so I don't think it's wise to make this the default. Instead I'm making this a
-        configuration option. When the `coreaudio.allowNominalSampleRateChange` config option is set to true, changing the sample
-        rate will be allowed. Otherwise it'll be fixed to the current sample rate. To check the system-defined sample rate, run
-        the Audio MIDI Setup program that comes installed on macOS and observe how the sample rate changes as the sample rate is
-        changed by miniaudio.
-        */
-        if (pData->allowNominalSampleRateChange) {
-            AudioValueRange sampleRateRange;
-            AudioObjectPropertyAddress propAddress;
-
-            sampleRateRange.mMinimum = bestFormat.mSampleRate;
-            sampleRateRange.mMaximum = bestFormat.mSampleRate;
-
-            propAddress.mSelector = kAudioDevicePropertyNominalSampleRate;
-            propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(sampleRateRange), &sampleRateRange);
-            if (status != noErr) {
-                bestFormat.mSampleRate = origFormat.mSampleRate;
-            }
-        } else {
-            bestFormat.mSampleRate = origFormat.mSampleRate;
-        }
-
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
-        if (status != noErr) {
-            /* We failed to set the format, so fall back to the current format of the audio unit. */
-            bestFormat = origFormat;
-        }
-    #else
-        bestFormat = origFormat;
-
-        /*
-        Sample rate is a little different here because for some reason kAudioUnitProperty_StreamFormat returns 0... Oh well. We need to instead try
-        setting the sample rate to what the user has requested and then just see the results of it. Need to use some Objective-C here for this since
-        it depends on Apple's AVAudioSession API. To do this we just get the shared AVAudioSession instance and then set it. Note that from what I
-        can tell, it looks like the sample rate is shared between playback and capture for everything.
-        */
-        @autoreleasepool {
-            AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-            MA_ASSERT(pAudioSession != NULL);
-
-            [pAudioSession setPreferredSampleRate:(double)pData->sampleRateIn error:nil];
-            bestFormat.mSampleRate = pAudioSession.sampleRate;
-
-            /*
-            I've had a report that the channel count returned by AudioUnitGetProperty above is inconsistent with
-            AVAudioSession outputNumberOfChannels. I'm going to try using the AVAudioSession values instead.
-            */
-            if (deviceType == ma_device_type_playback) {
-                bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.outputNumberOfChannels;
-            }
-            if (deviceType == ma_device_type_capture) {
-                bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.inputNumberOfChannels;
-            }
-        }
-
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    #endif
-
-        result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pData->formatOut);
-        if (result != MA_SUCCESS) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return result;
-        }
-
-        if (pData->formatOut == ma_format_unknown) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        pData->channelsOut   = bestFormat.mChannelsPerFrame;
-        pData->sampleRateOut = bestFormat.mSampleRate;
-    }
-
-    /* Clamp the channel count for safety. */
-    if (pData->channelsOut > MA_MAX_CHANNELS) {
-        pData->channelsOut = MA_MAX_CHANNELS;
-    }
-
-    /*
-    Internal channel map. This is weird in my testing. If I use the AudioObject to get the
-    channel map, the channel descriptions are set to "Unknown" for some reason. To work around
-    this it looks like retrieving it from the AudioUnit will work. However, and this is where
-    it gets weird, it doesn't seem to work with capture devices, nor at all on iOS... Therefore
-    I'm going to fall back to a default assumption in these cases.
-    */
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_get_AudioUnit_channel_map(pContext, pData->audioUnit, deviceType, pData->channelMapOut, pData->channelsOut);
-    if (result != MA_SUCCESS) {
-    #if 0
-        /* Try falling back to the channel map from the AudioObject. */
-        result = ma_get_AudioObject_channel_map(pContext, deviceObjectID, deviceType, pData->channelMapOut, pData->channelsOut);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    #else
-        /* Fall back to default assumptions. */
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pData->channelsOut, pData->channelMapOut);
-    #endif
-    }
-#else
-    /* TODO: Figure out how to get the channel map using AVAudioSession. */
-    ma_get_standard_channel_map(ma_standard_channel_map_default, pData->channelsOut, pData->channelMapOut);
-#endif
-
-
-    /* Buffer size. Not allowing this to be configurable on iOS. */
-    if (pData->periodSizeInFramesIn == 0) {
-        if (pData->periodSizeInMillisecondsIn == 0) {
-            if (pData->performanceProfile == ma_performance_profile_low_latency) {
-                actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, pData->sampleRateOut);
-            } else {
-                actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, pData->sampleRateOut);
-            }
-        } else {
-            actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, pData->sampleRateOut);
-        }
-    } else {
-        actualPeriodSizeInFrames = pData->periodSizeInFramesIn;
-    }
-
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualPeriodSizeInFrames);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-#else
-    /*
-    I don't know how to configure buffer sizes on iOS so for now we're not allowing it to be configured. Instead we're
-    just going to set it to the value of kAudioUnitProperty_MaximumFramesPerSlice.
-    */
-    status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, &actualPeriodSizeInFramesSize);
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-#endif
-
-
-    /*
-    During testing I discovered that the buffer size can be too big. You'll get an error like this:
-
-      kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=4096, mMaxFramesPerSlice=512
-
-    Note how inFramesToProcess is smaller than mMaxFramesPerSlice. To fix, we need to set kAudioUnitProperty_MaximumFramesPerSlice to that
-    of the size of our buffer, or do it the other way around and set our buffer size to the kAudioUnitProperty_MaximumFramesPerSlice.
-    */
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, sizeof(actualPeriodSizeInFrames));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    pData->periodSizeInFramesOut = (ma_uint32)actualPeriodSizeInFrames;
-
-    /* We need a buffer list if this is an input device. We render into this in the input callback. */
-    if (deviceType == ma_device_type_capture) {
-        ma_bool32 isInterleaved = (bestFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0;
-        AudioBufferList* pBufferList;
-
-        pBufferList = ma_allocate_AudioBufferList__coreaudio(pData->periodSizeInFramesOut, pData->formatOut, pData->channelsOut, (isInterleaved) ? ma_stream_layout_interleaved : ma_stream_layout_deinterleaved, &pContext->allocationCallbacks);
-        if (pBufferList == NULL) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pData->pAudioBufferList = pBufferList;
-    }
-
-    /* Callbacks. */
-    callbackInfo.inputProcRefCon = pDevice_DoNotReference;
-    if (deviceType == ma_device_type_playback) {
-        callbackInfo.inputProc = ma_on_output__coreaudio;
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    } else {
-        callbackInfo.inputProc = ma_on_input__coreaudio;
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* We need to listen for stop events. */
-    if (pData->registerStopEvent) {
-        status = ((ma_AudioUnitAddPropertyListener_proc)pContext->coreaudio.AudioUnitAddPropertyListener)(pData->audioUnit, kAudioOutputUnitProperty_IsRunning, on_start_stop__coreaudio, pDevice_DoNotReference);
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* Initialize the audio unit. */
-    status = ((ma_AudioUnitInitialize_proc)pContext->coreaudio.AudioUnitInitialize)(pData->audioUnit);
-    if (status != noErr) {
-        ma__free_from_callbacks(pData->pAudioBufferList, &pContext->allocationCallbacks);
-        pData->pAudioBufferList = NULL;
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    /* Grab the name. */
-#if defined(MA_APPLE_DESKTOP)
-    ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pData->deviceName), pData->deviceName);
-#else
-    if (deviceType == ma_device_type_playback) {
-        ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_PLAYBACK_DEVICE_NAME);
-    } else {
-        ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_CAPTURE_DEVICE_NAME);
-    }
-#endif
-
-    return result;
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit)
-{
-    ma_device_init_internal_data__coreaudio data;
-    ma_result result;
-
-    /* This should only be called for playback or capture, not duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    data.allowNominalSampleRateChange = MA_FALSE;   /* Don't change the nominal sample rate when switching devices. */
-
-    if (deviceType == ma_device_type_capture) {
-        data.formatIn               = pDevice->capture.format;
-        data.channelsIn             = pDevice->capture.channels;
-        data.sampleRateIn           = pDevice->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap));
-        data.shareMode              = pDevice->capture.shareMode;
-        data.performanceProfile     = pDevice->coreaudio.originalPerformanceProfile;
-        data.registerStopEvent      = MA_TRUE;
-
-        if (disposePreviousAudioUnit) {
-            ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-            ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        }
-        if (pDevice->coreaudio.pAudioBufferList) {
-            ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-        }
-    } else if (deviceType == ma_device_type_playback) {
-        data.formatIn               = pDevice->playback.format;
-        data.channelsIn             = pDevice->playback.channels;
-        data.sampleRateIn           = pDevice->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap));
-        data.shareMode              = pDevice->playback.shareMode;
-        data.performanceProfile     = pDevice->coreaudio.originalPerformanceProfile;
-        data.registerStopEvent      = (pDevice->type != ma_device_type_duplex);
-
-        if (disposePreviousAudioUnit) {
-            ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-            ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        }
-    }
-    data.periodSizeInFramesIn       = pDevice->coreaudio.originalPeriodSizeInFrames;
-    data.periodSizeInMillisecondsIn = pDevice->coreaudio.originalPeriodSizeInMilliseconds;
-    data.periodsIn                  = pDevice->coreaudio.originalPeriods;
-
-    /* Need at least 3 periods for duplex. */
-    if (data.periodsIn < 3 && pDevice->type == ma_device_type_duplex) {
-        data.periodsIn = 3;
-    }
-
-    result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (deviceType == ma_device_type_capture) {
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDCapture     = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitCapture          = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.pAudioBufferList          = (ma_ptr)data.pAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames    = data.periodSizeInFramesOut;
-
-        pDevice->capture.internalFormat              = data.formatOut;
-        pDevice->capture.internalChannels            = data.channelsOut;
-        pDevice->capture.internalSampleRate          = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->capture.internalPeriodSizeInFrames  = data.periodSizeInFramesOut;
-        pDevice->capture.internalPeriods             = data.periodsOut;
-    } else if (deviceType == ma_device_type_playback) {
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDPlayback    = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitPlayback         = (ma_ptr)data.audioUnit;
-
-        pDevice->playback.internalFormat             = data.formatOut;
-        pDevice->playback.internalChannels           = data.channelsOut;
-        pDevice->playback.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->playback.internalPeriods            = data.periodsOut;
-    }
-
-    return MA_SUCCESS;
-}
-#endif /* MA_APPLE_DESKTOP */
-
-static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pConfig != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with the Core Audio backend for now. */
-    if (((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Capture needs to be initialized first. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__coreaudio data;
-        data.allowNominalSampleRateChange = pConfig->coreaudio.allowNominalSampleRateChange;
-        data.formatIn                     = pDescriptorCapture->format;
-        data.channelsIn                   = pDescriptorCapture->channels;
-        data.sampleRateIn                 = pDescriptorCapture->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap));
-        data.periodSizeInFramesIn         = pDescriptorCapture->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn   = pDescriptorCapture->periodSizeInMilliseconds;
-        data.periodsIn                    = pDescriptorCapture->periodCount;
-        data.shareMode                    = pDescriptorCapture->shareMode;
-        data.performanceProfile           = pConfig->performanceProfile;
-        data.registerStopEvent            = MA_TRUE;
-
-        /* Need at least 3 periods for duplex. */
-        if (data.periodsIn < 3 && pConfig->deviceType == ma_device_type_duplex) {
-            data.periodsIn = 3;
-        }
-
-        result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_capture, pDescriptorCapture->pDeviceID, &data, (void*)pDevice);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pDevice->coreaudio.isDefaultCaptureDevice           = (pConfig->capture.pDeviceID == NULL);
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDCapture            = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitCapture                 = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.pAudioBufferList                 = (ma_ptr)data.pAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames           = data.periodSizeInFramesOut;
-        pDevice->coreaudio.originalPeriodSizeInFrames       = pDescriptorCapture->periodSizeInFrames;
-        pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds;
-        pDevice->coreaudio.originalPeriods                  = pDescriptorCapture->periodCount;
-        pDevice->coreaudio.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        pDescriptorCapture->format                          = data.formatOut;
-        pDescriptorCapture->channels                        = data.channelsOut;
-        pDescriptorCapture->sampleRate                      = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorCapture->periodSizeInFrames              = data.periodSizeInFramesOut;
-        pDescriptorCapture->periodCount                     = data.periodsOut;
-
-    #if defined(MA_APPLE_DESKTOP)
-        /*
-        If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
-        switch the device in the background.
-        */
-        if (pConfig->capture.pDeviceID == NULL) {
-            ma_device__track__coreaudio(pDevice);
-        }
-    #endif
-    }
-
-    /* Playback. */
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__coreaudio data;
-        data.allowNominalSampleRateChange   = pConfig->coreaudio.allowNominalSampleRateChange;
-        data.formatIn                       = pDescriptorPlayback->format;
-        data.channelsIn                     = pDescriptorPlayback->channels;
-        data.sampleRateIn                   = pDescriptorPlayback->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap));
-        data.shareMode                      = pDescriptorPlayback->shareMode;
-        data.performanceProfile             = pConfig->performanceProfile;
-
-        /* In full-duplex mode we want the playback buffer to be the same size as the capture buffer. */
-        if (pConfig->deviceType == ma_device_type_duplex) {
-            data.periodSizeInFramesIn       = pDescriptorCapture->periodSizeInFrames;
-            data.periodsIn                  = pDescriptorCapture->periodCount;
-            data.registerStopEvent          = MA_FALSE;
-        } else {
-            data.periodSizeInFramesIn       = pDescriptorPlayback->periodSizeInFrames;
-            data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds;
-            data.periodsIn                  = pDescriptorPlayback->periodCount;
-            data.registerStopEvent          = MA_TRUE;
-        }
-
-        result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data, (void*)pDevice);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                if (pDevice->coreaudio.pAudioBufferList) {
-                    ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-                }
-            }
-            return result;
-        }
-
-        pDevice->coreaudio.isDefaultPlaybackDevice          = (pConfig->playback.pDeviceID == NULL);
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDPlayback           = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitPlayback                = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.originalPeriodSizeInFrames       = pDescriptorPlayback->periodSizeInFrames;
-        pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds;
-        pDevice->coreaudio.originalPeriods                  = pDescriptorPlayback->periodCount;
-        pDevice->coreaudio.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        pDescriptorPlayback->format                         = data.formatOut;
-        pDescriptorPlayback->channels                       = data.channelsOut;
-        pDescriptorPlayback->sampleRate                     = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorPlayback->periodSizeInFrames             = data.periodSizeInFramesOut;
-        pDescriptorPlayback->periodCount                    = data.periodsOut;
-
-    #if defined(MA_APPLE_DESKTOP)
-        /*
-        If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
-        switch the device in the background.
-        */
-        if (pDescriptorPlayback->pDeviceID == NULL && (pConfig->deviceType != ma_device_type_duplex || pDescriptorCapture->pDeviceID != NULL)) {
-            ma_device__track__coreaudio(pDevice);
-        }
-    #endif
-    }
-
-    
-
-    /*
-    When stopping the device, a callback is called on another thread. We need to wait for this callback
-    before returning from ma_device_stop(). This event is used for this.
-    */
-    ma_event_init(&pDevice->coreaudio.stopEvent);
-
-    /*
-    We need to detect when a route has changed so we can update the data conversion pipeline accordingly. This is done
-    differently on non-Desktop Apple platforms.
-    */
-#if defined(MA_APPLE_MOBILE)
-    pDevice->coreaudio.pRouteChangeHandler = (__bridge_retained void*)[[ma_router_change_handler alloc] init:pDevice];
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_start__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        if (status != noErr) {
-            if (pDevice->type == ma_device_type_duplex) {
-                ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-            }
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* It's not clear from the documentation whether or not AudioOutputUnitStop() actually drains the device or not. */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* We need to wait for the callback to finish before returning. */
-    ma_event_wait(&pDevice->coreaudio.stopEvent);
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_coreaudio);
-
-#if defined(MA_APPLE_MOBILE)
-    if (!pContext->coreaudio.noAudioSessionDeactivate) {
-        if (![[AVAudioSession sharedInstance] setActive:false error:nil]) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to deactivate audio session.", MA_FAILED_TO_INIT_BACKEND);
-        }
-    }
-#endif
-
-#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-    ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-    ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-    ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-#endif
-
-#if !defined(MA_APPLE_MOBILE)
-    ma_context__uninit_device_tracking__coreaudio(pContext);
-#endif
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-#if defined(MA_APPLE_MOBILE)
-static AVAudioSessionCategory ma_to_AVAudioSessionCategory(ma_ios_session_category category)
-{
-    /* The "default" and "none" categories are treated different and should not be used as an input into this function. */
-    MA_ASSERT(category != ma_ios_session_category_default);
-    MA_ASSERT(category != ma_ios_session_category_none);
-
-    switch (category) {
-        case ma_ios_session_category_ambient:         return AVAudioSessionCategoryAmbient;
-        case ma_ios_session_category_solo_ambient:    return AVAudioSessionCategorySoloAmbient;
-        case ma_ios_session_category_playback:        return AVAudioSessionCategoryPlayback;
-        case ma_ios_session_category_record:          return AVAudioSessionCategoryRecord;
-        case ma_ios_session_category_play_and_record: return AVAudioSessionCategoryPlayAndRecord;
-        case ma_ios_session_category_multi_route:     return AVAudioSessionCategoryMultiRoute;
-        case ma_ios_session_category_none:            return AVAudioSessionCategoryAmbient;
-        case ma_ios_session_category_default:         return AVAudioSessionCategoryAmbient;
-        default:                                      return AVAudioSessionCategoryAmbient;
-    }
-}
-#endif
-
-static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#if !defined(MA_APPLE_MOBILE)
-    ma_result result;
-#endif
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pContext != NULL);
-
-#if defined(MA_APPLE_MOBILE)
-    @autoreleasepool {
-        AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-        AVAudioSessionCategoryOptions options = pConfig->coreaudio.sessionCategoryOptions;
-
-        MA_ASSERT(pAudioSession != NULL);
-
-        if (pConfig->coreaudio.sessionCategory == ma_ios_session_category_default) {
-            /*
-            I'm going to use trial and error to determine our default session category. First we'll try PlayAndRecord. If that fails
-            we'll try Playback and if that fails we'll try record. If all of these fail we'll just not set the category.
-            */
-        #if !defined(MA_APPLE_TV) && !defined(MA_APPLE_WATCH)
-            options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
-        #endif
-
-            if ([pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:options error:nil]) {
-                /* Using PlayAndRecord */
-            } else if ([pAudioSession setCategory: AVAudioSessionCategoryPlayback withOptions:options error:nil]) {
-                /* Using Playback */
-            } else if ([pAudioSession setCategory: AVAudioSessionCategoryRecord withOptions:options error:nil]) {
-                /* Using Record */
-            } else {
-                /* Leave as default? */
-            }
-        } else {
-            if (pConfig->coreaudio.sessionCategory != ma_ios_session_category_none) {
-                if (![pAudioSession setCategory: ma_to_AVAudioSessionCategory(pConfig->coreaudio.sessionCategory) withOptions:options error:nil]) {
-                    return MA_INVALID_OPERATION;    /* Failed to set session category. */
-                }
-            }
-        }
-
-        if (!pConfig->coreaudio.noAudioSessionActivate) {
-            if (![pAudioSession setActive:true error:nil]) {
-                return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to activate audio session.", MA_FAILED_TO_INIT_BACKEND);
-            }
-        }
-    }
-#endif
-
-#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-    pContext->coreaudio.hCoreFoundation = ma_dlopen(pContext, "CoreFoundation.framework/CoreFoundation");
-    if (pContext->coreaudio.hCoreFoundation == NULL) {
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->coreaudio.CFStringGetCString = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFStringGetCString");
-    pContext->coreaudio.CFRelease          = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFRelease");
-
-
-    pContext->coreaudio.hCoreAudio = ma_dlopen(pContext, "CoreAudio.framework/CoreAudio");
-    if (pContext->coreaudio.hCoreAudio == NULL) {
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->coreaudio.AudioObjectGetPropertyData        = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyData");
-    pContext->coreaudio.AudioObjectGetPropertyDataSize    = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyDataSize");
-    pContext->coreaudio.AudioObjectSetPropertyData        = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectSetPropertyData");
-    pContext->coreaudio.AudioObjectAddPropertyListener    = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectAddPropertyListener");
-    pContext->coreaudio.AudioObjectRemovePropertyListener = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectRemovePropertyListener");
-
-    /*
-    It looks like Apple has moved some APIs from AudioUnit into AudioToolbox on more recent versions of macOS. They are still
-    defined in AudioUnit, but just in case they decide to remove them from there entirely I'm going to implement a fallback.
-    The way it'll work is that it'll first try AudioUnit, and if the required symbols are not present there we'll fall back to
-    AudioToolbox.
-    */
-    pContext->coreaudio.hAudioUnit = ma_dlopen(pContext, "AudioUnit.framework/AudioUnit");
-    if (pContext->coreaudio.hAudioUnit == NULL) {
-        ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        return MA_API_NOT_FOUND;
-    }
-
-    if (ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == NULL) {
-        /* Couldn't find the required symbols in AudioUnit, so fall back to AudioToolbox. */
-        ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-        pContext->coreaudio.hAudioUnit = ma_dlopen(pContext, "AudioToolbox.framework/AudioToolbox");
-        if (pContext->coreaudio.hAudioUnit == NULL) {
-            ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-            return MA_API_NOT_FOUND;
-        }
-    }
-
-    pContext->coreaudio.AudioComponentFindNext            = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentFindNext");
-    pContext->coreaudio.AudioComponentInstanceDispose     = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentInstanceDispose");
-    pContext->coreaudio.AudioComponentInstanceNew         = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentInstanceNew");
-    pContext->coreaudio.AudioOutputUnitStart              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioOutputUnitStart");
-    pContext->coreaudio.AudioOutputUnitStop               = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioOutputUnitStop");
-    pContext->coreaudio.AudioUnitAddPropertyListener      = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitAddPropertyListener");
-    pContext->coreaudio.AudioUnitGetPropertyInfo          = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitGetPropertyInfo");
-    pContext->coreaudio.AudioUnitGetProperty              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitGetProperty");
-    pContext->coreaudio.AudioUnitSetProperty              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitSetProperty");
-    pContext->coreaudio.AudioUnitInitialize               = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitInitialize");
-    pContext->coreaudio.AudioUnitRender                   = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitRender");
-#else
-    pContext->coreaudio.CFStringGetCString                = (ma_proc)CFStringGetCString;
-    pContext->coreaudio.CFRelease                         = (ma_proc)CFRelease;
-
-    #if defined(MA_APPLE_DESKTOP)
-    pContext->coreaudio.AudioObjectGetPropertyData        = (ma_proc)AudioObjectGetPropertyData;
-    pContext->coreaudio.AudioObjectGetPropertyDataSize    = (ma_proc)AudioObjectGetPropertyDataSize;
-    pContext->coreaudio.AudioObjectSetPropertyData        = (ma_proc)AudioObjectSetPropertyData;
-    pContext->coreaudio.AudioObjectAddPropertyListener    = (ma_proc)AudioObjectAddPropertyListener;
-    pContext->coreaudio.AudioObjectRemovePropertyListener = (ma_proc)AudioObjectRemovePropertyListener;
-    #endif
-
-    pContext->coreaudio.AudioComponentFindNext            = (ma_proc)AudioComponentFindNext;
-    pContext->coreaudio.AudioComponentInstanceDispose     = (ma_proc)AudioComponentInstanceDispose;
-    pContext->coreaudio.AudioComponentInstanceNew         = (ma_proc)AudioComponentInstanceNew;
-    pContext->coreaudio.AudioOutputUnitStart              = (ma_proc)AudioOutputUnitStart;
-    pContext->coreaudio.AudioOutputUnitStop               = (ma_proc)AudioOutputUnitStop;
-    pContext->coreaudio.AudioUnitAddPropertyListener      = (ma_proc)AudioUnitAddPropertyListener;
-    pContext->coreaudio.AudioUnitGetPropertyInfo          = (ma_proc)AudioUnitGetPropertyInfo;
-    pContext->coreaudio.AudioUnitGetProperty              = (ma_proc)AudioUnitGetProperty;
-    pContext->coreaudio.AudioUnitSetProperty              = (ma_proc)AudioUnitSetProperty;
-    pContext->coreaudio.AudioUnitInitialize               = (ma_proc)AudioUnitInitialize;
-    pContext->coreaudio.AudioUnitRender                   = (ma_proc)AudioUnitRender;
-#endif
-
-    /* Audio component. */
-    {
-        AudioComponentDescription desc;
-        desc.componentType         = kAudioUnitType_Output;
-    #if defined(MA_APPLE_DESKTOP)
-        desc.componentSubType      = kAudioUnitSubType_HALOutput;
-    #else
-        desc.componentSubType      = kAudioUnitSubType_RemoteIO;
-    #endif
-        desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-        desc.componentFlags        = 0;
-        desc.componentFlagsMask    = 0;
-
-        pContext->coreaudio.component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc);
-        if (pContext->coreaudio.component == NULL) {
-        #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-            ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        #endif
-            return MA_FAILED_TO_INIT_BACKEND;
-        }
-    }
-
-#if !defined(MA_APPLE_MOBILE)
-    result = ma_context__init_device_tracking__coreaudio(pContext);
-    if (result != MA_SUCCESS) {
-    #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-        ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-    #endif
-        return result;
-    }
-#endif
-
-    pContext->coreaudio.noAudioSessionDeactivate = pConfig->coreaudio.noAudioSessionDeactivate;
-    
-    pCallbacks->onContextInit             = ma_context_init__coreaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__coreaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__coreaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__coreaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__coreaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__coreaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__coreaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__coreaudio;
-    pCallbacks->onDeviceRead              = NULL;
-    pCallbacks->onDeviceWrite             = NULL;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* Core Audio */
-
-
-
-/******************************************************************************
-
-sndio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_SNDIO
-#include <fcntl.h>
-
-/*
-Only supporting OpenBSD. This did not work very well at all on FreeBSD when I tried it. Not sure if this is due
-to miniaudio's implementation or if it's some kind of system configuration issue, but basically the default device
-just doesn't emit any sound, or at times you'll hear tiny pieces. I will consider enabling this when there's
-demand for it or if I can get it tested and debugged more thoroughly.
-*/
-#if 0
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-#include <sys/audioio.h>
-#endif
-#if defined(__FreeBSD__) || defined(__DragonFly__)
-#include <sys/soundcard.h>
-#endif
-#endif
-
-#define MA_SIO_DEVANY   "default"
-#define MA_SIO_PLAY     1
-#define MA_SIO_REC      2
-#define MA_SIO_NENC     8
-#define MA_SIO_NCHAN    8
-#define MA_SIO_NRATE    16
-#define MA_SIO_NCONF    4
-
-struct ma_sio_hdl; /* <-- Opaque */
-
-struct ma_sio_par
-{
-    unsigned int bits;
-    unsigned int bps;
-    unsigned int sig;
-    unsigned int le;
-    unsigned int msb;
-    unsigned int rchan;
-    unsigned int pchan;
-    unsigned int rate;
-    unsigned int bufsz;
-    unsigned int xrun;
-    unsigned int round;
-    unsigned int appbufsz;
-    int __pad[3];
-    unsigned int __magic;
-};
-
-struct ma_sio_enc
-{
-    unsigned int bits;
-    unsigned int bps;
-    unsigned int sig;
-    unsigned int le;
-    unsigned int msb;
-};
-
-struct ma_sio_conf
-{
-    unsigned int enc;
-    unsigned int rchan;
-    unsigned int pchan;
-    unsigned int rate;
-};
-
-struct ma_sio_cap
-{
-    struct ma_sio_enc enc[MA_SIO_NENC];
-    unsigned int rchan[MA_SIO_NCHAN];
-    unsigned int pchan[MA_SIO_NCHAN];
-    unsigned int rate[MA_SIO_NRATE];
-    int __pad[7];
-    unsigned int nconf;
-    struct ma_sio_conf confs[MA_SIO_NCONF];
-};
-
-typedef struct ma_sio_hdl* (* ma_sio_open_proc)   (const char*, unsigned int, int);
-typedef void               (* ma_sio_close_proc)  (struct ma_sio_hdl*);
-typedef int                (* ma_sio_setpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*);
-typedef int                (* ma_sio_getpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*);
-typedef int                (* ma_sio_getcap_proc) (struct ma_sio_hdl*, struct ma_sio_cap*);
-typedef size_t             (* ma_sio_write_proc)  (struct ma_sio_hdl*, const void*, size_t);
-typedef size_t             (* ma_sio_read_proc)   (struct ma_sio_hdl*, void*, size_t);
-typedef int                (* ma_sio_start_proc)  (struct ma_sio_hdl*);
-typedef int                (* ma_sio_stop_proc)   (struct ma_sio_hdl*);
-typedef int                (* ma_sio_initpar_proc)(struct ma_sio_par*);
-
-static ma_uint32 ma_get_standard_sample_rate_priority_index__sndio(ma_uint32 sampleRate)   /* Lower = higher priority */
-{
-    ma_uint32 i;
-    for (i = 0; i < ma_countof(g_maStandardSampleRatePriorities); ++i) {
-        if (g_maStandardSampleRatePriorities[i] == sampleRate) {
-            return i;
-        }
-    }
-
-    return (ma_uint32)-1;
-}
-
-static ma_format ma_format_from_sio_enc__sndio(unsigned int bits, unsigned int bps, unsigned int sig, unsigned int le, unsigned int msb)
-{
-    /* We only support native-endian right now. */
-    if ((ma_is_little_endian() && le == 0) || (ma_is_big_endian() && le == 1)) {
-        return ma_format_unknown;
-    }
-
-    if (bits ==  8 && bps == 1 && sig == 0) {
-        return ma_format_u8;
-    }
-    if (bits == 16 && bps == 2 && sig == 1) {
-        return ma_format_s16;
-    }
-    if (bits == 24 && bps == 3 && sig == 1) {
-        return ma_format_s24;
-    }
-    if (bits == 24 && bps == 4 && sig == 1 && msb == 0) {
-        /*return ma_format_s24_32;*/
-    }
-    if (bits == 32 && bps == 4 && sig == 1) {
-        return ma_format_s32;
-    }
-
-    return ma_format_unknown;
-}
-
-static ma_format ma_find_best_format_from_sio_cap__sndio(struct ma_sio_cap* caps)
-{
-    ma_format bestFormat;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-
-    bestFormat = ma_format_unknown;
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format == ma_format_unknown) {
-                continue;   /* Format not supported. */
-            }
-
-            if (bestFormat == ma_format_unknown) {
-                bestFormat = format;
-            } else {
-                if (ma_get_format_priority_index(bestFormat) > ma_get_format_priority_index(format)) {    /* <-- Lower = better. */
-                    bestFormat = format;
-                }
-            }
-        }
-    }
-
-    return bestFormat;
-}
-
-static ma_uint32 ma_find_best_channels_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat)
-{
-    ma_uint32 maxChannels;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-    MA_ASSERT(requiredFormat != ma_format_unknown);
-
-    /* Just pick whatever configuration has the most channels. */
-    maxChannels = 0;
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        /* The encoding should be of requiredFormat. */
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int iChannel;
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format != requiredFormat) {
-                continue;
-            }
-
-            /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps->confs[iConfig].pchan;
-                } else {
-                    chan = caps->confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps->pchan[iChannel];
-                } else {
-                    channels = caps->rchan[iChannel];
-                }
-
-                if (maxChannels < channels) {
-                    maxChannels = channels;
-                }
-            }
-        }
-    }
-
-    return maxChannels;
-}
-
-static ma_uint32 ma_find_best_sample_rate_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat, ma_uint32 requiredChannels)
-{
-    ma_uint32 firstSampleRate;
-    ma_uint32 bestSampleRate;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-    MA_ASSERT(requiredFormat != ma_format_unknown);
-    MA_ASSERT(requiredChannels > 0);
-    MA_ASSERT(requiredChannels <= MA_MAX_CHANNELS);
-
-    firstSampleRate = 0; /* <-- If the device does not support a standard rate we'll fall back to the first one that's found. */
-    bestSampleRate  = 0;
-
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        /* The encoding should be of requiredFormat. */
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int iChannel;
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format != requiredFormat) {
-                continue;
-            }
-
-            /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-                unsigned int iRate;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps->confs[iConfig].pchan;
-                } else {
-                    chan = caps->confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps->pchan[iChannel];
-                } else {
-                    channels = caps->rchan[iChannel];
-                }
-
-                if (channels != requiredChannels) {
-                    continue;
-                }
-
-                /* Getting here means we have found a compatible encoding/channel pair. */
-                for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) {
-                    ma_uint32 rate = (ma_uint32)caps->rate[iRate];
-                    ma_uint32 ratePriority;
-
-                    if (firstSampleRate == 0) {
-                        firstSampleRate = rate;
-                    }
-
-                    /* Disregard this rate if it's not a standard one. */
-                    ratePriority = ma_get_standard_sample_rate_priority_index__sndio(rate);
-                    if (ratePriority == (ma_uint32)-1) {
-                        continue;
-                    }
-
-                    if (ma_get_standard_sample_rate_priority_index__sndio(bestSampleRate) > ratePriority) {   /* Lower = better. */
-                        bestSampleRate = rate;
-                    }
-                }
-            }
-        }
-    }
-
-    /* If a standard sample rate was not found just fall back to the first one that was iterated. */
-    if (bestSampleRate == 0) {
-        bestSampleRate = firstSampleRate;
-    }
-
-    return bestSampleRate;
-}
-
-
-static ma_result ma_context_enumerate_devices__sndio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 isTerminating = MA_FALSE;
-    struct ma_sio_hdl* handle;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* sndio doesn't seem to have a good device enumeration API, so I'm therefore only enumerating over default devices for now. */
-
-    /* Playback. */
-    if (!isTerminating) {
-        handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_PLAY, 0);
-        if (handle != NULL) {
-            /* Supports playback. */
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), MA_SIO_DEVANY);
-            ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME);
-
-            isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-
-            ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-        }
-    }
-
-    /* Capture. */
-    if (!isTerminating) {
-        handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_REC, 0);
-        if (handle != NULL) {
-            /* Supports capture. */
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), "default");
-            ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME);
-
-            isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-
-            ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    char devid[256];
-    struct ma_sio_hdl* handle;
-    struct ma_sio_cap caps;
-    unsigned int iConfig;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* We need to open the device before we can get information about it. */
-    if (pDeviceID == NULL) {
-        ma_strcpy_s(devid, sizeof(devid), MA_SIO_DEVANY);
-        ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == ma_device_type_playback) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : MA_DEFAULT_CAPTURE_DEVICE_NAME);
-    } else {
-        ma_strcpy_s(devid, sizeof(devid), pDeviceID->sndio);
-        ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), devid);
-    }
-
-    handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == ma_device_type_playback) ? MA_SIO_PLAY : MA_SIO_REC, 0);
-    if (handle == NULL) {
-        return MA_NO_DEVICE;
-    }
-
-    if (((ma_sio_getcap_proc)pContext->sndio.sio_getcap)(handle, &caps) == 0) {
-        return MA_ERROR;
-    }
-
-    pDeviceInfo->nativeDataFormatCount = 0;
-
-    for (iConfig = 0; iConfig < caps.nconf; iConfig += 1) {
-        /*
-        The main thing we care about is that the encoding is supported by miniaudio. If it is, we want to give
-        preference to some formats over others.
-        */
-        unsigned int iEncoding;
-        unsigned int iChannel;
-        unsigned int iRate;
-
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps.confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps.enc[iEncoding].bits;
-            bps  = caps.enc[iEncoding].bps;
-            sig  = caps.enc[iEncoding].sig;
-            le   = caps.enc[iEncoding].le;
-            msb  = caps.enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format == ma_format_unknown) {
-                continue;   /* Format not supported. */
-            }
-
-
-            /* Channels. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps.confs[iConfig].pchan;
-                } else {
-                    chan = caps.confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps.pchan[iChannel];
-                } else {
-                    channels = caps.rchan[iChannel];
-                }
-
-
-                /* Sample Rates. */
-                for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) {
-                    if ((caps.confs[iConfig].rate & (1UL << iRate)) != 0) {
-                        ma_device_info_add_native_data_format(pDeviceInfo, format, channels, caps.rate[iRate], 0);
-                    }
-                }
-            }
-        }
-    }
-
-    ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    const char* pDeviceName;
-    ma_ptr handle;
-    int openFlags = 0;
-    struct ma_sio_cap caps;
-    struct ma_sio_par par;
-    const ma_device_id* pDeviceID;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    MA_ASSERT(pDevice    != NULL);
-
-    if (deviceType == ma_device_type_capture) {
-        openFlags  = MA_SIO_REC;
-    } else {
-        openFlags = MA_SIO_PLAY;
-    }
-
-    pDeviceID  = pDescriptor->pDeviceID;
-    format     = pDescriptor->format;
-    channels   = pDescriptor->channels;
-    sampleRate = pDescriptor->sampleRate;
-
-    pDeviceName = MA_SIO_DEVANY;
-    if (pDeviceID != NULL) {
-        pDeviceName = pDeviceID->sndio;
-    }
-
-    handle = (ma_ptr)((ma_sio_open_proc)pDevice->pContext->sndio.sio_open)(pDeviceName, openFlags, 0);
-    if (handle == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    /* We need to retrieve the device caps to determine the most appropriate format to use. */
-    if (((ma_sio_getcap_proc)pDevice->pContext->sndio.sio_getcap)((struct ma_sio_hdl*)handle, &caps) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve device caps.", MA_ERROR);
-    }
-
-    /*
-    Note: sndio reports a huge range of available channels. This is inconvenient for us because there's no real
-    way, as far as I can tell, to get the _actual_ channel count of the device. I'm therefore restricting this
-    to the requested channels, regardless of whether or not the default channel count is requested.
-
-    For hardware devices, I'm suspecting only a single channel count will be reported and we can safely use the
-    value returned by ma_find_best_channels_from_sio_cap__sndio().
-    */
-    if (deviceType == ma_device_type_capture) {
-        if (format == ma_format_unknown) {
-            format = ma_find_best_format_from_sio_cap__sndio(&caps);
-        }
-
-        if (channels == 0) {
-            if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) {
-                channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format);
-            } else {
-                channels = MA_DEFAULT_CHANNELS;
-            }
-        }
-    } else {
-        if (format == ma_format_unknown) {
-            format = ma_find_best_format_from_sio_cap__sndio(&caps);
-        }
-
-        if (channels == 0) {
-            if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) {
-                channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format);
-            } else {
-                channels = MA_DEFAULT_CHANNELS;
-            }
-        }
-    }
-
-    if (sampleRate == 0) {
-        sampleRate = ma_find_best_sample_rate_from_sio_cap__sndio(&caps, pConfig->deviceType, format, channels);
-    }
-
-
-    ((ma_sio_initpar_proc)pDevice->pContext->sndio.sio_initpar)(&par);
-    par.msb = 0;
-    par.le  = ma_is_little_endian();
-
-    switch (format) {
-        case ma_format_u8:
-        {
-            par.bits = 8;
-            par.bps  = 1;
-            par.sig  = 0;
-        } break;
-
-        case ma_format_s24:
-        {
-            par.bits = 24;
-            par.bps  = 3;
-            par.sig  = 1;
-        } break;
-
-        case ma_format_s32:
-        {
-            par.bits = 32;
-            par.bps  = 4;
-            par.sig  = 1;
-        } break;
-
-        case ma_format_s16:
-        case ma_format_f32:
-        case ma_format_unknown:
-        default:
-        {
-            par.bits = 16;
-            par.bps  = 2;
-            par.sig  = 1;
-        } break;
-    }
-    
-    if (deviceType == ma_device_type_capture) {
-        par.rchan = channels;
-    } else {
-        par.pchan = channels;
-    }
-
-    par.rate = sampleRate;
-
-    internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, par.rate, pConfig->performanceProfile);
-
-    par.round    = internalPeriodSizeInFrames;
-    par.appbufsz = par.round * pDescriptor->periodCount;
-
-    if (((ma_sio_setpar_proc)pDevice->pContext->sndio.sio_setpar)((struct ma_sio_hdl*)handle, &par) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to set buffer size.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    if (((ma_sio_getpar_proc)pDevice->pContext->sndio.sio_getpar)((struct ma_sio_hdl*)handle, &par) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve buffer size.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    internalFormat             = ma_format_from_sio_enc__sndio(par.bits, par.bps, par.sig, par.le, par.msb);
-    internalChannels           = (deviceType == ma_device_type_capture) ? par.rchan : par.pchan;
-    internalSampleRate         = par.rate;
-    internalPeriods            = par.appbufsz / par.round;
-    internalPeriodSizeInFrames = par.round;
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->sndio.handleCapture  = handle;
-    } else {
-        pDevice->sndio.handlePlayback = handle;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sndio, pDevice->playback.internalChannels, pDevice->playback.internalChannelMap);
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("DEVICE INFO\n");
-    printf("    Format:      %s\n", ma_get_format_name(internalFormat));
-    printf("    Channels:    %d\n", internalChannels);
-    printf("    Sample Rate: %d\n", internalSampleRate);
-    printf("    Period Size: %d\n", internalPeriodSizeInFrames);
-    printf("    Periods:     %d\n", internalPeriods);
-    printf("    appbufsz:    %d\n", par.appbufsz);
-    printf("    round:       %d\n", par.round);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->sndio);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);   /* <-- Doesn't actually playback until data is written. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the documentation:
-
-        The sio_stop() function puts the audio subsystem in the same state as before sio_start() is called. It stops recording, drains the play buffer and then
-        stops playback. If samples to play are queued but playback hasn't started yet then playback is forced immediately; playback will actually stop once the
-        buffer is drained. In no case are samples in the play buffer discarded.
-
-    Therefore, sio_stop() performs all of the necessary draining for us.
-    */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__sndio(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int result;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    result = ((ma_sio_write_proc)pDevice->pContext->sndio.sio_write)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (result == 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to send data from the client to the device.", MA_IO_ERROR);
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int result;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    result = ((ma_sio_read_proc)pDevice->pContext->sndio.sio_read)((struct ma_sio_hdl*)pDevice->sndio.handleCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (result == 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to read data from the device to be sent to the device.", MA_IO_ERROR);
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__sndio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_sndio);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__sndio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libsndioNames[] = {
-        "libsndio.so"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libsndioNames); ++i) {
-        pContext->sndio.sndioSO = ma_dlopen(pContext, libsndioNames[i]);
-        if (pContext->sndio.sndioSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->sndio.sndioSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->sndio.sio_open    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_open");
-    pContext->sndio.sio_close   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_close");
-    pContext->sndio.sio_setpar  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_setpar");
-    pContext->sndio.sio_getpar  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_getpar");
-    pContext->sndio.sio_getcap  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_getcap");
-    pContext->sndio.sio_write   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_write");
-    pContext->sndio.sio_read    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_read");
-    pContext->sndio.sio_start   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_start");
-    pContext->sndio.sio_stop    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_stop");
-    pContext->sndio.sio_initpar = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_initpar");
-#else
-    pContext->sndio.sio_open    = sio_open;
-    pContext->sndio.sio_close   = sio_close;
-    pContext->sndio.sio_setpar  = sio_setpar;
-    pContext->sndio.sio_getpar  = sio_getpar;
-    pContext->sndio.sio_getcap  = sio_getcap;
-    pContext->sndio.sio_write   = sio_write;
-    pContext->sndio.sio_read    = sio_read;
-    pContext->sndio.sio_start   = sio_start;
-    pContext->sndio.sio_stop    = sio_stop;
-    pContext->sndio.sio_initpar = sio_initpar;
-#endif
-
-    pCallbacks->onContextInit             = ma_context_init__sndio;
-    pCallbacks->onContextUninit           = ma_context_uninit__sndio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__sndio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__sndio;
-    pCallbacks->onDeviceInit              = ma_device_init__sndio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__sndio;
-    pCallbacks->onDeviceStart             = ma_device_start__sndio;
-    pCallbacks->onDeviceStop              = ma_device_stop__sndio;
-    pCallbacks->onDeviceRead              = ma_device_read__sndio;
-    pCallbacks->onDeviceWrite             = ma_device_write__sndio;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-#endif  /* sndio */
-
-
-
-/******************************************************************************
-
-audio(4) Backend
-
-******************************************************************************/
-#ifdef MA_HAS_AUDIO4
-#include <fcntl.h>
-#include <poll.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/audioio.h>
-
-#if defined(__OpenBSD__)
-    #include <sys/param.h>
-    #if defined(OpenBSD) && OpenBSD >= 201709
-        #define MA_AUDIO4_USE_NEW_API
-    #endif
-#endif
-
-static void ma_construct_device_id__audio4(char* id, size_t idSize, const char* base, int deviceIndex)
-{
-    size_t baseLen;
-
-    MA_ASSERT(id != NULL);
-    MA_ASSERT(idSize > 0);
-    MA_ASSERT(deviceIndex >= 0);
-
-    baseLen = strlen(base);
-    MA_ASSERT(idSize > baseLen);
-
-    ma_strcpy_s(id, idSize, base);
-    ma_itoa_s(deviceIndex, id+baseLen, idSize-baseLen, 10);
-}
-
-static ma_result ma_extract_device_index_from_id__audio4(const char* id, const char* base, int* pIndexOut)
-{
-    size_t idLen;
-    size_t baseLen;
-    const char* deviceIndexStr;
-
-    MA_ASSERT(id != NULL);
-    MA_ASSERT(base != NULL);
-    MA_ASSERT(pIndexOut != NULL);
-
-    idLen = strlen(id);
-    baseLen = strlen(base);
-    if (idLen <= baseLen) {
-        return MA_ERROR;   /* Doesn't look like the id starts with the base. */
-    }
-
-    if (strncmp(id, base, baseLen) != 0) {
-        return MA_ERROR;   /* ID does not begin with base. */
-    }
-
-    deviceIndexStr = id + baseLen;
-    if (deviceIndexStr[0] == '\0') {
-        return MA_ERROR;   /* No index specified in the ID. */
-    }
-
-    if (pIndexOut) {
-        *pIndexOut = atoi(deviceIndexStr);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-#if !defined(MA_AUDIO4_USE_NEW_API)    /* Old API */
-static ma_format ma_format_from_encoding__audio4(unsigned int encoding, unsigned int precision)
-{
-    if (precision == 8 && (encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR_LE || encoding == AUDIO_ENCODING_ULINEAR_BE)) {
-        return ma_format_u8;
-    } else {
-        if (ma_is_little_endian() && encoding == AUDIO_ENCODING_SLINEAR_LE) {
-            if (precision == 16) {
-                return ma_format_s16;
-            } else if (precision == 24) {
-                return ma_format_s24;
-            } else if (precision == 32) {
-                return ma_format_s32;
-            }
-        } else if (ma_is_big_endian() && encoding == AUDIO_ENCODING_SLINEAR_BE) {
-            if (precision == 16) {
-                return ma_format_s16;
-            } else if (precision == 24) {
-                return ma_format_s24;
-            } else if (precision == 32) {
-                return ma_format_s32;
-            }
-        }
-    }
-
-    return ma_format_unknown;  /* Encoding not supported. */
-}
-
-static void ma_encoding_from_format__audio4(ma_format format, unsigned int* pEncoding, unsigned int* pPrecision)
-{
-    MA_ASSERT(pEncoding  != NULL);
-    MA_ASSERT(pPrecision != NULL);
-
-    switch (format)
-    {
-        case ma_format_u8:
-        {
-            *pEncoding = AUDIO_ENCODING_ULINEAR;
-            *pPrecision = 8;
-        } break;
-
-        case ma_format_s24:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 24;
-        } break;
-
-        case ma_format_s32:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 32;
-        } break;
-
-        case ma_format_s16:
-        case ma_format_f32:
-        case ma_format_unknown:
-        default:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 16;
-        } break;
-    }
-}
-
-static ma_format ma_format_from_prinfo__audio4(struct audio_prinfo* prinfo)
-{
-    return ma_format_from_encoding__audio4(prinfo->encoding, prinfo->precision);
-}
-
-static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredFormat)
-{
-    audio_encoding_t encoding;
-    ma_uint32 iFormat;
-    int counter = 0;
-
-    /* First check to see if the preferred format is supported. */
-    if (preferredFormat != ma_format_unknown) {
-        counter = 0;
-        for (;;) {
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            if (preferredFormat == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) {
-                return preferredFormat;  /* Found the preferred format. */
-            }
-
-            /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */
-            counter += 1;
-        }
-    }
-
-    /* Getting here means our preferred format is not supported, so fall back to our standard priorities. */
-    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) {
-        ma_format format = g_maFormatPriorities[iFormat];
-
-        counter = 0;
-        for (;;) {
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            if (format == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) {
-                return format;  /* Found a workable format. */
-            }
-
-            /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */
-            counter += 1;
-        }
-    }
-
-    /* Getting here means not appropriate format was found. */
-    return ma_format_unknown;
-}
-#else
-static ma_format ma_format_from_swpar__audio4(struct audio_swpar* par)
-{
-    if (par->bits == 8 && par->bps == 1 && par->sig == 0) {
-        return ma_format_u8;
-    }
-    if (par->bits == 16 && par->bps == 2 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_s16;
-    }
-    if (par->bits == 24 && par->bps == 3 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_s24;
-    }
-    if (par->bits == 32 && par->bps == 4 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_f32;
-    }
-
-    /* Format not supported. */
-    return ma_format_unknown;
-}
-#endif
-
-static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext, ma_device_type deviceType, int fd, ma_device_info* pDeviceInfo)
-{
-    audio_device_t fdDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(fd >= 0);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    (void)pContext;
-    (void)deviceType;
-
-    if (ioctl(fd, AUDIO_GETDEV, &fdDevice) < 0) {
-        return MA_ERROR;   /* Failed to retrieve device info. */
-    }
-
-    /* Name. */
-    ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), fdDevice.name);
-
-    #if !defined(MA_AUDIO4_USE_NEW_API)
-    {
-        audio_info_t fdInfo;
-        int counter = 0;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-
-        if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) {
-            return MA_ERROR;
-        }
-
-        if (deviceType == ma_device_type_playback) {
-            channels   = fdInfo.play.channels;
-            sampleRate = fdInfo.play.sample_rate;
-        } else {
-            channels   = fdInfo.record.channels;
-            sampleRate = fdInfo.record.sample_rate;
-        }
-
-        /* Supported formats. We get this by looking at the encodings. */
-        pDeviceInfo->nativeDataFormatCount = 0;
-        for (;;) {
-            audio_encoding_t encoding;
-            ma_format format;
-
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            format = ma_format_from_encoding__audio4(encoding.encoding, encoding.precision);
-            if (format != ma_format_unknown) {
-                ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0);
-            }
-
-            counter += 1;
-        }
-    }
-    #else
-    {
-        struct audio_swpar fdPar;
-        ma_format format;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-
-        if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-            return MA_ERROR;
-        }
-
-        format = ma_format_from_swpar__audio4(&fdPar);
-        if (format == ma_format_unknown) {
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        if (deviceType == ma_device_type_playback) {
-            channels = fdPar.pchan;
-        } else {
-            channels = fdPar.rchan;
-        }
-
-        sampleRate = fdPar.rate;
-
-        pDeviceInfo->nativeDataFormatCount = 0;
-        ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0);
-    }
-    #endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices__audio4(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    const int maxDevices = 64;
-    char devpath[256];
-    int iDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /*
-    Every device will be named "/dev/audioN", with a "/dev/audioctlN" equivalent. We use the "/dev/audioctlN"
-    version here since we can open it even when another process has control of the "/dev/audioN" device.
-    */
-    for (iDevice = 0; iDevice < maxDevices; ++iDevice) {
-        struct stat st;
-        int fd;
-        ma_bool32 isTerminating = MA_FALSE;
-
-        ma_strcpy_s(devpath, sizeof(devpath), "/dev/audioctl");
-        ma_itoa_s(iDevice, devpath+strlen(devpath), sizeof(devpath)-strlen(devpath), 10);
-
-        if (stat(devpath, &st) < 0) {
-            break;
-        }
-
-        /* The device exists, but we need to check if it's usable as playback and/or capture. */
-
-        /* Playback. */
-        if (!isTerminating) {
-            fd = open(devpath, O_RDONLY, 0);
-            if (fd >= 0) {
-                /* Supports playback. */
-                ma_device_info deviceInfo;
-                MA_ZERO_OBJECT(&deviceInfo);
-                ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice);
-                if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_playback, fd, &deviceInfo) == MA_SUCCESS) {
-                    isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                }
-
-                close(fd);
-            }
-        }
-
-        /* Capture. */
-        if (!isTerminating) {
-            fd = open(devpath, O_WRONLY, 0);
-            if (fd >= 0) {
-                /* Supports capture. */
-                ma_device_info deviceInfo;
-                MA_ZERO_OBJECT(&deviceInfo);
-                ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice);
-                if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_capture, fd, &deviceInfo) == MA_SUCCESS) {
-                    isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                }
-
-                close(fd);
-            }
-        }
-
-        if (isTerminating) {
-            break;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__audio4(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    int fd = -1;
-    int deviceIndex = -1;
-    char ctlid[256];
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /*
-    We need to open the "/dev/audioctlN" device to get the info. To do this we need to extract the number
-    from the device ID which will be in "/dev/audioN" format.
-    */
-    if (pDeviceID == NULL) {
-        /* Default device. */
-        ma_strcpy_s(ctlid, sizeof(ctlid), "/dev/audioctl");
-    } else {
-        /* Specific device. We need to convert from "/dev/audioN" to "/dev/audioctlN". */
-        result = ma_extract_device_index_from_id__audio4(pDeviceID->audio4, "/dev/audio", &deviceIndex);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        ma_construct_device_id__audio4(ctlid, sizeof(ctlid), "/dev/audioctl", deviceIndex);
-    }
-
-    fd = open(ctlid, (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY, 0);
-    if (fd == -1) {
-        return MA_NO_DEVICE;
-    }
-
-    if (deviceIndex == -1) {
-        ma_strcpy_s(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio");
-    } else {
-        ma_construct_device_id__audio4(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio", deviceIndex);
-    }
-
-    result = ma_context_get_device_info_from_fd__audio4(pContext, deviceType, fd, pDeviceInfo);
-
-    close(fd);
-    return result;
-}
-
-static ma_result ma_device_uninit__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->audio4.fdCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->audio4.fdPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    const char* pDefaultDeviceNames[] = {
-        "/dev/audio",
-        "/dev/audio0"
-    };
-    int fd;
-    int fdFlags = 0;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    MA_ASSERT(pDevice    != NULL);
-
-    /* The first thing to do is open the file. */
-    if (deviceType == ma_device_type_capture) {
-        fdFlags = O_RDONLY;
-    } else {
-        fdFlags = O_WRONLY;
-    }
-    /*fdFlags |= O_NONBLOCK;*/
-
-    if (pDescriptor->pDeviceID == NULL) {
-        /* Default device. */
-        size_t iDevice;
-        for (iDevice = 0; iDevice < ma_countof(pDefaultDeviceNames); ++iDevice) {
-            fd = open(pDefaultDeviceNames[iDevice], fdFlags, 0);
-            if (fd != -1) {
-                break;
-            }
-        }
-    } else {
-        /* Specific device. */
-        fd = open(pDescriptor->pDeviceID->audio4, fdFlags, 0);
-    }
-
-    if (fd == -1) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to open device.", ma_result_from_errno(errno));
-    }
-
-    #if !defined(MA_AUDIO4_USE_NEW_API)    /* Old API */
-    {
-        audio_info_t fdInfo;
-
-        /*
-        The documentation is a little bit unclear to me as to how it handles formats. It says the
-        following:
-
-            Regardless of formats supported by underlying driver, the audio driver accepts the
-            following formats.
-
-        By then the next sentence says this:
-
-            `encoding` and `precision` are one of the values obtained by AUDIO_GETENC.
-
-        It sounds like a direct contradiction to me. I'm going to play this safe any only use the
-        best sample format returned by AUDIO_GETENC. If the requested format is supported we'll
-        use that, but otherwise we'll just use our standard format priorities to pick an
-        appropriate one.
-        */
-        AUDIO_INITINFO(&fdInfo);
-
-        /* We get the driver to do as much of the data conversion as possible. */
-        if (deviceType == ma_device_type_capture) {
-            fdInfo.mode = AUMODE_RECORD;
-            ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.record.encoding, &fdInfo.record.precision);
-
-            if (pDescriptor->channels != 0) {
-                fdInfo.record.channels = ma_clamp(pDescriptor->channels, 1, 12);    /* From the documentation: `channels` ranges from 1 to 12. */
-            }
-
-            if (pDescriptor->sampleRate != 0) {
-                fdInfo.record.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000);    /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */
-            }
-        } else {
-            fdInfo.mode = AUMODE_PLAY;
-            ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.play.encoding, &fdInfo.play.precision);
-
-            if (pDescriptor->channels != 0) {
-                fdInfo.play.channels = ma_clamp(pDescriptor->channels, 1, 12);    /* From the documentation: `channels` ranges from 1 to 12. */
-            }
-
-            if (pDescriptor->sampleRate != 0) {
-                fdInfo.play.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000);    /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */
-            }
-        }
-
-        if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device format. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        if (deviceType == ma_device_type_capture) {
-            internalFormat     = ma_format_from_prinfo__audio4(&fdInfo.record);
-            internalChannels   = fdInfo.record.channels;
-            internalSampleRate = fdInfo.record.sample_rate;
-        } else {
-            internalFormat     = ma_format_from_prinfo__audio4(&fdInfo.play);
-            internalChannels   = fdInfo.play.channels;
-            internalSampleRate = fdInfo.play.sample_rate;
-        }
-
-        if (internalFormat == ma_format_unknown) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        /* Buffer. */
-        {
-            ma_uint32 internalPeriodSizeInBytes;
-
-            internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile);
-
-            internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels);
-            if (internalPeriodSizeInBytes < 16) {
-                internalPeriodSizeInBytes = 16;
-            }
-
-            internalPeriods = pDescriptor->periodCount;
-            if (internalPeriods < 2) {
-                internalPeriods = 2;
-            }
-
-            /* What miniaudio calls a period, audio4 calls a block. */
-            AUDIO_INITINFO(&fdInfo);
-            fdInfo.hiwat     = internalPeriods;
-            fdInfo.lowat     = internalPeriods-1;
-            fdInfo.blocksize = internalPeriodSizeInBytes;
-            if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set internal buffer size. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-            }
-
-            internalPeriods            = fdInfo.hiwat;
-            internalPeriodSizeInFrames = fdInfo.blocksize / ma_get_bytes_per_frame(internalFormat, internalChannels);
-        }
-    }
-    #else
-    {
-        struct audio_swpar fdPar;
-
-        /* We need to retrieve the format of the device so we can know the channel count and sample rate. Then we can calculate the buffer size. */
-        if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve initial device parameters.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        internalFormat     = ma_format_from_swpar__audio4(&fdPar);
-        internalChannels   = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan;
-        internalSampleRate = fdPar.rate;
-
-        if (internalFormat == ma_format_unknown) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        /* Buffer. */
-        {
-            ma_uint32 internalPeriodSizeInBytes;
-
-            internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile);
-
-            /* What miniaudio calls a period, audio4 calls a block. */
-            internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels);
-            if (internalPeriodSizeInBytes < 16) {
-                internalPeriodSizeInBytes = 16;
-            }
-
-            fdPar.nblks = pDescriptor->periodCount;
-            fdPar.round = internalPeriodSizeInBytes;
-
-            if (ioctl(fd, AUDIO_SETPAR, &fdPar) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device parameters.", MA_FORMAT_NOT_SUPPORTED);
-            }
-
-            if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve actual device parameters.", MA_FORMAT_NOT_SUPPORTED);
-            }
-        }
-
-        internalFormat             = ma_format_from_swpar__audio4(&fdPar);
-        internalChannels           = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan;
-        internalSampleRate         = fdPar.rate;
-        internalPeriods            = fdPar.nblks;
-        internalPeriodSizeInFrames = fdPar.round / ma_get_bytes_per_frame(internalFormat, internalChannels);
-    }
-    #endif
-
-    if (internalFormat == ma_format_unknown) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->audio4.fdCapture  = fd;
-    } else {
-        pDevice->audio4.fdPlayback = fd;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sound4, internalChannels, pDescriptor->channelMap);
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->audio4);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    pDevice->audio4.fdCapture  = -1;
-    pDevice->audio4.fdPlayback = -1;
-
-    /*
-    The version of the operating system dictates whether or not the device is exclusive or shared. NetBSD
-    introduced in-kernel mixing which means it's shared. All other BSD flavours are exclusive as far as
-    I'm aware.
-    */
-#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 800000000
-    /* NetBSD 8.0+ */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-#else
-    /* All other flavors. */
-#endif
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                close(pDevice->audio4.fdCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->audio4.fdCapture == -1) {
-            return MA_INVALID_ARGS;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->audio4.fdPlayback == -1) {
-            return MA_INVALID_ARGS;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop_fd__audio4(ma_device* pDevice, int fd)
-{
-    if (fd == -1) {
-        return MA_INVALID_ARGS;
-    }
-
-#if !defined(MA_AUDIO4_USE_NEW_API)
-    if (ioctl(fd, AUDIO_FLUSH, 0) < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed.", ma_result_from_errno(errno));
-    }
-#else
-    if (ioctl(fd, AUDIO_STOP, 0) < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_STOP failed.", ma_result_from_errno(errno));
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result;
-
-        result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result;
-
-        /* Drain the device first. If this fails we'll just need to flush without draining. Unfortunately draining isn't available on newer version of OpenBSD. */
-    #if !defined(MA_AUDIO4_USE_NEW_API)
-        ioctl(pDevice->audio4.fdPlayback, AUDIO_DRAIN, 0);
-    #endif
-
-        /* Here is where the device is stopped immediately. */
-        result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__audio4(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int result;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    result = write(pDevice->audio4.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (result < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to write data to the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int result;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    result = read(pDevice->audio4.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (result < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to read data from the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__audio4(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_audio4);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__audio4(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pCallbacks->onContextInit             = ma_context_init__audio4;
-    pCallbacks->onContextUninit           = ma_context_uninit__audio4;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__audio4;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__audio4;
-    pCallbacks->onDeviceInit              = ma_device_init__audio4;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__audio4;
-    pCallbacks->onDeviceStart             = ma_device_start__audio4;
-    pCallbacks->onDeviceStop              = ma_device_stop__audio4;
-    pCallbacks->onDeviceRead              = ma_device_read__audio4;
-    pCallbacks->onDeviceWrite             = ma_device_write__audio4;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* audio4 */
-
-
-/******************************************************************************
-
-OSS Backend
-
-******************************************************************************/
-#ifdef MA_HAS_OSS
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/soundcard.h>
-
-#ifndef SNDCTL_DSP_HALT
-#define SNDCTL_DSP_HALT SNDCTL_DSP_RESET
-#endif
-
-#define MA_OSS_DEFAULT_DEVICE_NAME  "/dev/dsp"
-
-static int ma_open_temp_device__oss()
-{
-    /* The OSS sample code uses "/dev/mixer" as the device for getting system properties so I'm going to do the same. */
-    int fd = open("/dev/mixer", O_RDONLY, 0);
-    if (fd >= 0) {
-        return fd;
-    }
-
-    return -1;
-}
-
-static ma_result ma_context_open_device__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, int* pfd)
-{
-    const char* deviceName;
-    int flags;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pfd != NULL);
-    (void)pContext;
-
-    *pfd = -1;
-
-    /* This function should only be called for playback or capture, not duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    deviceName = MA_OSS_DEFAULT_DEVICE_NAME;
-    if (pDeviceID != NULL) {
-        deviceName = pDeviceID->oss;
-    }
-
-    flags = (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY;
-    if (shareMode == ma_share_mode_exclusive) {
-        flags |= O_EXCL;
-    }
-
-    *pfd = open(deviceName, flags, 0);
-    if (*pfd == -1) {
-        return ma_result_from_errno(errno);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices__oss(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    int fd;
-    oss_sysinfo si;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    fd = ma_open_temp_device__oss();
-    if (fd == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND);
-    }
-
-    result = ioctl(fd, SNDCTL_SYSINFO, &si);
-    if (result != -1) {
-        int iAudioDevice;
-        for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) {
-            oss_audioinfo ai;
-            ai.dev = iAudioDevice;
-            result = ioctl(fd, SNDCTL_AUDIOINFO, &ai);
-            if (result != -1) {
-                if (ai.devnode[0] != '\0') {    /* <-- Can be blank, according to documentation. */
-                    ma_device_info deviceInfo;
-                    ma_bool32 isTerminating = MA_FALSE;
-
-                    MA_ZERO_OBJECT(&deviceInfo);
-
-                    /* ID */
-                    ma_strncpy_s(deviceInfo.id.oss, sizeof(deviceInfo.id.oss), ai.devnode, (size_t)-1);
-
-                    /*
-                    The human readable device name should be in the "ai.handle" variable, but it can
-                    sometimes be empty in which case we just fall back to "ai.name" which is less user
-                    friendly, but usually has a value.
-                    */
-                    if (ai.handle[0] != '\0') {
-                        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.handle, (size_t)-1);
-                    } else {
-                        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.name, (size_t)-1);
-                    }
-
-                    /* The device can be both playback and capture. */
-                    if (!isTerminating && (ai.caps & PCM_CAP_OUTPUT) != 0) {
-                        isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                    }
-                    if (!isTerminating && (ai.caps & PCM_CAP_INPUT) != 0) {
-                        isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                    }
-
-                    if (isTerminating) {
-                        break;
-                    }
-                }
-            }
-        }
-    } else {
-        close(fd);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND);
-    }
-
-    close(fd);
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_native_data_format__oss(ma_context* pContext, oss_audioinfo* pAudioInfo, ma_format format, ma_device_info* pDeviceInfo)
-{
-    unsigned int minChannels;
-    unsigned int maxChannels;
-    unsigned int iRate;
-
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pAudioInfo  != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /* If we support all channels we just report 0. */
-    minChannels = ma_clamp(pAudioInfo->min_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-    maxChannels = ma_clamp(pAudioInfo->max_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-
-    /*
-    OSS has this annoying thing where sample rates can be reported in two ways. We prefer explicitness,
-    which OSS has in the form of nrates/rates, however there are times where nrates can be 0, in which
-    case we'll need to use min_rate and max_rate and report only standard rates.
-    */
-    if (pAudioInfo->nrates > 0) {
-        for (iRate = 0; iRate < pAudioInfo->nrates; iRate += 1) {
-            unsigned int rate = pAudioInfo->rates[iRate];
-
-            if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                ma_device_info_add_native_data_format(pDeviceInfo, format, 0, rate, 0);   /* Set the channel count to 0 to indicate that all channel counts are supported. */
-            } else {
-                unsigned int iChannel;
-                for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                     ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, rate, 0);
-                }
-            }
-        }
-    } else {
-        for (iRate = 0; iRate < ma_countof(g_maStandardSampleRatePriorities); iRate += 1) {
-            ma_uint32 standardRate = g_maStandardSampleRatePriorities[iRate];
-
-            if (standardRate >= (ma_uint32)pAudioInfo->min_rate && standardRate <= (ma_uint32)pAudioInfo->max_rate) {
-                if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                    ma_device_info_add_native_data_format(pDeviceInfo, format, 0, standardRate, 0);   /* Set the channel count to 0 to indicate that all channel counts are supported. */
-                } else {
-                    unsigned int iChannel;
-                    for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                         ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, standardRate, 0);
-                    }
-                }
-            }
-        }
-    }
-}
-
-static ma_result ma_context_get_device_info__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_bool32 foundDevice;
-    int fdTemp;
-    oss_sysinfo si;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* Handle the default device a little differently. */
-    if (pDeviceID == NULL) {
-        if (deviceType == ma_device_type_playback) {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        } else {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        }
-
-        return MA_SUCCESS;
-    }
-
-
-    /* If we get here it means we are _not_ using the default device. */
-    foundDevice = MA_FALSE;
-
-    fdTemp = ma_open_temp_device__oss();
-    if (fdTemp == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND);
-    }
-
-    result = ioctl(fdTemp, SNDCTL_SYSINFO, &si);
-    if (result != -1) {
-        int iAudioDevice;
-        for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) {
-            oss_audioinfo ai;
-            ai.dev = iAudioDevice;
-            result = ioctl(fdTemp, SNDCTL_AUDIOINFO, &ai);
-            if (result != -1) {
-                if (ma_strcmp(ai.devnode, pDeviceID->oss) == 0) {
-                    /* It has the same name, so now just confirm the type. */
-                    if ((deviceType == ma_device_type_playback && ((ai.caps & PCM_CAP_OUTPUT) != 0)) ||
-                        (deviceType == ma_device_type_capture  && ((ai.caps & PCM_CAP_INPUT)  != 0))) {
-                        unsigned int formatMask;
-
-                        /* ID */
-                        ma_strncpy_s(pDeviceInfo->id.oss, sizeof(pDeviceInfo->id.oss), ai.devnode, (size_t)-1);
-
-                        /*
-                        The human readable device name should be in the "ai.handle" variable, but it can
-                        sometimes be empty in which case we just fall back to "ai.name" which is less user
-                        friendly, but usually has a value.
-                        */
-                        if (ai.handle[0] != '\0') {
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.handle, (size_t)-1);
-                        } else {
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.name, (size_t)-1);
-                        }
-
-
-                        pDeviceInfo->nativeDataFormatCount = 0;
-
-                        if (deviceType == ma_device_type_playback) {
-                            formatMask = ai.oformats;
-                        } else {
-                            formatMask = ai.iformats;
-                        }
-
-                        if (((formatMask & AFMT_S16_LE) != 0 && ma_is_little_endian()) || (AFMT_S16_BE && ma_is_big_endian())) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s16, pDeviceInfo);
-                        }
-                        if (((formatMask & AFMT_S32_LE) != 0 && ma_is_little_endian()) || (AFMT_S32_BE && ma_is_big_endian())) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s32, pDeviceInfo);
-                        }
-                        if ((formatMask & AFMT_U8) != 0) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_u8, pDeviceInfo);
-                        }
-
-                        foundDevice = MA_TRUE;
-                        break;
-                    }
-                }
-            }
-        }
-    } else {
-        close(fdTemp);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND);
-    }
-
-
-    close(fdTemp);
-
-    if (!foundDevice) {
-        return MA_NO_DEVICE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->oss.fdCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->oss.fdPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static int ma_format_to_oss(ma_format format)
-{
-    int ossFormat = AFMT_U8;
-    switch (format) {
-        case ma_format_s16: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break;
-        case ma_format_s24: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break;
-        case ma_format_s32: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break;
-        case ma_format_f32: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break;
-        case ma_format_u8:
-        default: ossFormat = AFMT_U8; break;
-    }
-
-    return ossFormat;
-}
-
-static ma_format ma_format_from_oss(int ossFormat)
-{
-    if (ossFormat == AFMT_U8) {
-        return ma_format_u8;
-    } else {
-        if (ma_is_little_endian()) {
-            switch (ossFormat) {
-                case AFMT_S16_LE: return ma_format_s16;
-                case AFMT_S32_LE: return ma_format_s32;
-                default: return ma_format_unknown;
-            }
-        } else {
-            switch (ossFormat) {
-                case AFMT_S16_BE: return ma_format_s16;
-                case AFMT_S32_BE: return ma_format_s32;
-                default: return ma_format_unknown;
-            }
-        }
-    }
-
-    return ma_format_unknown;
-}
-
-static ma_result ma_device_init_fd__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    ma_result result;
-    int ossResult;
-    int fd;
-    const ma_device_id* pDeviceID = NULL;
-    ma_share_mode shareMode;
-    int ossFormat;
-    int ossChannels;
-    int ossSampleRate;
-    int ossFragment;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    
-    pDeviceID     = pDescriptor->pDeviceID;
-    shareMode     = pDescriptor->shareMode;
-    ossFormat     = ma_format_to_oss((pDescriptor->format != ma_format_unknown) ? pDescriptor->format : ma_format_s16); /* Use s16 by default because OSS doesn't like floating point. */
-    ossChannels   = (int)(pDescriptor->channels   > 0) ? pDescriptor->channels   : MA_DEFAULT_CHANNELS;
-    ossSampleRate = (int)(pDescriptor->sampleRate > 0) ? pDescriptor->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-    result = ma_context_open_device__oss(pDevice->pContext, deviceType, pDeviceID, shareMode, &fd);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-    }
-
-    /*
-    The OSS documantation is very clear about the order we should be initializing the device's properties:
-      1) Format
-      2) Channels
-      3) Sample rate.
-    */
-
-    /* Format. */
-    ossResult = ioctl(fd, SNDCTL_DSP_SETFMT, &ossFormat);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set format.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /* Channels. */
-    ossResult = ioctl(fd, SNDCTL_DSP_CHANNELS, &ossChannels);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set channel count.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /* Sample Rate. */
-    ossResult = ioctl(fd, SNDCTL_DSP_SPEED, &ossSampleRate);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set sample rate.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /*
-    Buffer.
-
-    The documentation says that the fragment settings should be set as soon as possible, but I'm not sure if
-    it should be done before or after format/channels/rate.
-
-    OSS wants the fragment size in bytes and a power of 2. When setting, we specify the power, not the actual
-    value.
-    */
-    {
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodSizeInBytes;
-        ma_uint32 ossFragmentSizePower;
-
-        periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, (ma_uint32)ossSampleRate, pConfig->performanceProfile);
-
-        periodSizeInBytes = ma_round_to_power_of_2(periodSizeInFrames * ma_get_bytes_per_frame(ma_format_from_oss(ossFormat), ossChannels));
-        if (periodSizeInBytes < 16) {
-            periodSizeInBytes = 16;
-        }
-
-        ossFragmentSizePower = 4;
-        periodSizeInBytes >>= 4;
-        while (periodSizeInBytes >>= 1) {
-            ossFragmentSizePower += 1;
-        }
-
-        ossFragment = (int)((pConfig->periods << 16) | ossFragmentSizePower);
-        ossResult = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment);
-        if (ossResult == -1) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count.", MA_FORMAT_NOT_SUPPORTED);
-        }
-    }
-
-    /* Internal settings. */
-    if (deviceType == ma_device_type_capture) {
-        pDevice->oss.fdCapture  = fd;
-    } else {
-        pDevice->oss.fdPlayback = fd;
-    }
-
-    pDescriptor->format             = ma_format_from_oss(ossFormat);
-    pDescriptor->channels           = ossChannels;
-    pDescriptor->sampleRate         = ossSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sound4, pDescriptor->channels, pDescriptor->channelMap);
-    pDescriptor->periodCount        = (ma_uint32)(ossFragment >> 16);
-    pDescriptor->periodSizeInFrames = (ma_uint32)(1 << (ossFragment & 0xFFFF)) / ma_get_bytes_per_frame(pDescriptor->format, pDescriptor->channels);
-
-    if (pDescriptor->format == ma_format_unknown) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice  != NULL);
-    MA_ASSERT(pConfig  != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->oss);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-/*
-Note on Starting and Stopping
-=============================
-In the past I was using SNDCTL_DSP_HALT to stop the device, however this results in issues when
-trying to resume the device again. If we use SNDCTL_DSP_HALT, the next write() or read() will
-fail. Instead what we need to do is just not write or read to and from the device when the
-device is not running.
-
-As a result, both the start and stop functions for OSS are just empty stubs. The starting and
-stopping logic is handled by ma_device_write__oss() and ma_device_read__oss(). These will check
-the device state, and if the device is stopped they will simply not do any kind of processing.
-
-The downside to this technique is that I've noticed a fairly lengthy delay in stopping the
-device, up to a second. This is on a virtual machine, and as such might just be due to the
-virtual drivers, but I'm not fully sure. I am not sure how to work around this problem so for
-the moment that's just how it's going to have to be.
-
-When starting the device, OSS will automatically start it when write() or read() is called.
-*/
-static ma_result ma_device_start__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* The device is automatically started with reading and writing. */
-    (void)pDevice;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* See note above on why this is empty. */
-    (void)pDevice;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__oss(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int resultOSS;
-    ma_uint32 deviceState;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    /* Don't do any processing if the device is stopped. */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTED && deviceState != MA_STATE_STARTING) {
-        return MA_SUCCESS;
-    }
-
-    resultOSS = write(pDevice->oss.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (resultOSS < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to send data from the client to the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int resultOSS;
-    ma_uint32 deviceState;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    /* Don't do any processing if the device is stopped. */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTED && deviceState != MA_STATE_STARTING) {
-        return MA_SUCCESS;
-    }
-
-    resultOSS = read(pDevice->oss.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (resultOSS < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to read data from the device to be sent to the client.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__oss(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_oss);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    int fd;
-    int ossVersion;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    /* Try opening a temporary device first so we can get version information. This is closed at the end. */
-    fd = ma_open_temp_device__oss();
-    if (fd == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open temporary device for retrieving system properties.", MA_NO_BACKEND);   /* Looks liks OSS isn't installed, or there are no available devices. */
-    }
-
-    /* Grab the OSS version. */
-    ossVersion = 0;
-    result = ioctl(fd, OSS_GETVERSION, &ossVersion);
-    if (result == -1) {
-        close(fd);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve OSS version.", MA_NO_BACKEND);
-    }
-
-    /* The file handle to temp device is no longer needed. Close ASAP. */
-    close(fd);
-
-    pContext->oss.versionMajor = ((ossVersion & 0xFF0000) >> 16);
-    pContext->oss.versionMinor = ((ossVersion & 0x00FF00) >> 8);
-
-    pCallbacks->onContextInit             = ma_context_init__oss;
-    pCallbacks->onContextUninit           = ma_context_uninit__oss;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__oss;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__oss;
-    pCallbacks->onDeviceInit              = ma_device_init__oss;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__oss;
-    pCallbacks->onDeviceStart             = ma_device_start__oss;
-    pCallbacks->onDeviceStop              = ma_device_stop__oss;
-    pCallbacks->onDeviceRead              = ma_device_read__oss;
-    pCallbacks->onDeviceWrite             = ma_device_write__oss;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* OSS */
-
-
-/******************************************************************************
-
-AAudio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_AAUDIO
-
-/*#include <AAudio/AAudio.h>*/
-
-typedef int32_t                                         ma_aaudio_result_t;
-typedef int32_t                                         ma_aaudio_direction_t;
-typedef int32_t                                         ma_aaudio_sharing_mode_t;
-typedef int32_t                                         ma_aaudio_format_t;
-typedef int32_t                                         ma_aaudio_stream_state_t;
-typedef int32_t                                         ma_aaudio_performance_mode_t;
-typedef int32_t                                         ma_aaudio_usage_t;
-typedef int32_t                                         ma_aaudio_content_type_t;
-typedef int32_t                                         ma_aaudio_input_preset_t;
-typedef int32_t                                         ma_aaudio_data_callback_result_t;
-typedef struct ma_AAudioStreamBuilder_t*                ma_AAudioStreamBuilder;
-typedef struct ma_AAudioStream_t*                       ma_AAudioStream;
-
-#define MA_AAUDIO_UNSPECIFIED                           0
-
-/* Result codes. miniaudio only cares about the success code. */
-#define MA_AAUDIO_OK                                    0
-
-/* Directions. */
-#define MA_AAUDIO_DIRECTION_OUTPUT                      0
-#define MA_AAUDIO_DIRECTION_INPUT                       1
-
-/* Sharing modes. */
-#define MA_AAUDIO_SHARING_MODE_EXCLUSIVE                0
-#define MA_AAUDIO_SHARING_MODE_SHARED                   1
-
-/* Formats. */
-#define MA_AAUDIO_FORMAT_PCM_I16                        1
-#define MA_AAUDIO_FORMAT_PCM_FLOAT                      2
-
-/* Stream states. */
-#define MA_AAUDIO_STREAM_STATE_UNINITIALIZED            0
-#define MA_AAUDIO_STREAM_STATE_UNKNOWN                  1
-#define MA_AAUDIO_STREAM_STATE_OPEN                     2
-#define MA_AAUDIO_STREAM_STATE_STARTING                 3
-#define MA_AAUDIO_STREAM_STATE_STARTED                  4
-#define MA_AAUDIO_STREAM_STATE_PAUSING                  5
-#define MA_AAUDIO_STREAM_STATE_PAUSED                   6
-#define MA_AAUDIO_STREAM_STATE_FLUSHING                 7
-#define MA_AAUDIO_STREAM_STATE_FLUSHED                  8
-#define MA_AAUDIO_STREAM_STATE_STOPPING                 9
-#define MA_AAUDIO_STREAM_STATE_STOPPED                  10
-#define MA_AAUDIO_STREAM_STATE_CLOSING                  11
-#define MA_AAUDIO_STREAM_STATE_CLOSED                   12
-#define MA_AAUDIO_STREAM_STATE_DISCONNECTED             13
-
-/* Performance modes. */
-#define MA_AAUDIO_PERFORMANCE_MODE_NONE                 10
-#define MA_AAUDIO_PERFORMANCE_MODE_POWER_SAVING         11
-#define MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY          12
-
-/* Usage types. */
-#define MA_AAUDIO_USAGE_MEDIA                           1
-#define MA_AAUDIO_USAGE_VOICE_COMMUNICATION             2
-#define MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING  3
-#define MA_AAUDIO_USAGE_ALARM                           4
-#define MA_AAUDIO_USAGE_NOTIFICATION                    5
-#define MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE           6
-#define MA_AAUDIO_USAGE_NOTIFICATION_EVENT              10
-#define MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY        11
-#define MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE  12
-#define MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION         13
-#define MA_AAUDIO_USAGE_GAME                            14
-#define MA_AAUDIO_USAGE_ASSISTANT                       16
-#define MA_AAUDIO_SYSTEM_USAGE_EMERGENCY                1000
-#define MA_AAUDIO_SYSTEM_USAGE_SAFETY                   1001
-#define MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS           1002
-#define MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT             1003
-
-/* Content types. */
-#define MA_AAUDIO_CONTENT_TYPE_SPEECH                   1
-#define MA_AAUDIO_CONTENT_TYPE_MUSIC                    2
-#define MA_AAUDIO_CONTENT_TYPE_MOVIE                    3
-#define MA_AAUDIO_CONTENT_TYPE_SONIFICATION             4
-
-/* Input presets. */
-#define MA_AAUDIO_INPUT_PRESET_GENERIC                  1
-#define MA_AAUDIO_INPUT_PRESET_CAMCORDER                5
-#define MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION        6
-#define MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION      7
-#define MA_AAUDIO_INPUT_PRESET_UNPROCESSED              9
-#define MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE        10
-
-/* Callback results. */
-#define MA_AAUDIO_CALLBACK_RESULT_CONTINUE              0
-#define MA_AAUDIO_CALLBACK_RESULT_STOP                  1
-
-
-typedef ma_aaudio_data_callback_result_t (* ma_AAudioStream_dataCallback) (ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t numFrames);
-typedef void                             (* ma_AAudioStream_errorCallback)(ma_AAudioStream *pStream, void *pUserData, ma_aaudio_result_t error);
-
-typedef ma_aaudio_result_t       (* MA_PFN_AAudio_createStreamBuilder)                   (ma_AAudioStreamBuilder** ppBuilder);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStreamBuilder_delete)                   (ma_AAudioStreamBuilder* pBuilder);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDeviceId)              (ma_AAudioStreamBuilder* pBuilder, int32_t deviceId);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDirection)             (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_direction_t direction);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setSharingMode)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_sharing_mode_t sharingMode);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setFormat)                (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_format_t format);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setChannelCount)          (ma_AAudioStreamBuilder* pBuilder, int32_t channelCount);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setSampleRate)            (ma_AAudioStreamBuilder* pBuilder, int32_t sampleRate);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)(ma_AAudioStreamBuilder* pBuilder, int32_t numFrames);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback) (ma_AAudioStreamBuilder* pBuilder, int32_t numFrames);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDataCallback)          (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_dataCallback callback, void* pUserData);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setErrorCallback)         (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_errorCallback callback, void* pUserData);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setPerformanceMode)       (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_performance_mode_t mode);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setUsage)                 (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_usage_t contentType);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setContentType)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_content_type_t contentType);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setInputPreset)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_input_preset_t inputPreset);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStreamBuilder_openStream)               (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_close)                           (ma_AAudioStream* pStream);
-typedef ma_aaudio_stream_state_t (* MA_PFN_AAudioStream_getState)                        (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_waitForStateChange)              (ma_AAudioStream* pStream, ma_aaudio_stream_state_t inputState, ma_aaudio_stream_state_t* pNextState, int64_t timeoutInNanoseconds);
-typedef ma_aaudio_format_t       (* MA_PFN_AAudioStream_getFormat)                       (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getChannelCount)                 (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getSampleRate)                   (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getBufferCapacityInFrames)       (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getFramesPerDataCallback)        (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getFramesPerBurst)               (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_requestStart)                    (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_requestStop)                     (ma_AAudioStream* pStream);
-
-static ma_result ma_result_from_aaudio(ma_aaudio_result_t resultAA)
-{
-    switch (resultAA)
-    {
-        case MA_AAUDIO_OK: return MA_SUCCESS;
-        default: break;
-    }
-
-    return MA_ERROR;
-}
-
-static ma_aaudio_usage_t ma_to_usage__aaudio(ma_aaudio_usage usage)
-{
-    switch (usage) {
-        case ma_aaudio_usage_announcement:                   return MA_AAUDIO_USAGE_MEDIA;
-        case ma_aaudio_usage_emergency:                      return MA_AAUDIO_USAGE_VOICE_COMMUNICATION;
-        case ma_aaudio_usage_safety:                         return MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
-        case ma_aaudio_usage_vehicle_status:                 return MA_AAUDIO_USAGE_ALARM;
-        case ma_aaudio_usage_alarm:                          return MA_AAUDIO_USAGE_NOTIFICATION;
-        case ma_aaudio_usage_assistance_accessibility:       return MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE;
-        case ma_aaudio_usage_assistance_navigation_guidance: return MA_AAUDIO_USAGE_NOTIFICATION_EVENT;
-        case ma_aaudio_usage_assistance_sonification:        return MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY;
-        case ma_aaudio_usage_assitant:                       return MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
-        case ma_aaudio_usage_game:                           return MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION;
-        case ma_aaudio_usage_media:                          return MA_AAUDIO_USAGE_GAME;
-        case ma_aaudio_usage_notification:                   return MA_AAUDIO_USAGE_ASSISTANT;
-        case ma_aaudio_usage_notification_event:             return MA_AAUDIO_SYSTEM_USAGE_EMERGENCY;
-        case ma_aaudio_usage_notification_ringtone:          return MA_AAUDIO_SYSTEM_USAGE_SAFETY;
-        case ma_aaudio_usage_voice_communication:            return MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS;
-        case ma_aaudio_usage_voice_communication_signalling: return MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT;
-        default: break;
-    }
-
-    return MA_AAUDIO_USAGE_MEDIA;
-}
-
-static ma_aaudio_content_type_t ma_to_content_type__aaudio(ma_aaudio_content_type contentType)
-{
-    switch (contentType) {
-        case ma_aaudio_content_type_movie:        return MA_AAUDIO_CONTENT_TYPE_MOVIE;
-        case ma_aaudio_content_type_music:        return MA_AAUDIO_CONTENT_TYPE_MUSIC;
-        case ma_aaudio_content_type_sonification: return MA_AAUDIO_CONTENT_TYPE_SONIFICATION;
-        case ma_aaudio_content_type_speech:       return MA_AAUDIO_CONTENT_TYPE_SPEECH;
-        default: break;
-    }
-
-    return MA_AAUDIO_CONTENT_TYPE_SPEECH;
-}
-
-static ma_aaudio_input_preset_t ma_to_input_preset__aaudio(ma_aaudio_input_preset inputPreset)
-{
-    switch (inputPreset) {
-        case ma_aaudio_input_preset_generic:             return MA_AAUDIO_INPUT_PRESET_GENERIC;
-        case ma_aaudio_input_preset_camcorder:           return MA_AAUDIO_INPUT_PRESET_CAMCORDER;
-        case ma_aaudio_input_preset_unprocessed:         return MA_AAUDIO_INPUT_PRESET_UNPROCESSED;
-        case ma_aaudio_input_preset_voice_recognition:   return MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION;
-        case ma_aaudio_input_preset_voice_communication: return MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION;
-        case ma_aaudio_input_preset_voice_performance:   return MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE;
-        default: break;
-    }
-
-    return MA_AAUDIO_INPUT_PRESET_GENERIC;
-}
-
-static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUserData, ma_aaudio_result_t error)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    (void)error;
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("[AAudio] ERROR CALLBACK: error=%d, AAudioStream_getState()=%d\n", error, ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream));
-#endif
-
-    /*
-    From the documentation for AAudio, when a device is disconnected all we can do is stop it. However, we cannot stop it from the callback - we need
-    to do it from another thread. Therefore we are going to use an event thread for the AAudio backend to do this cleanly and safely.
-    */
-    if (((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream) == MA_AAUDIO_STREAM_STATE_DISCONNECTED) {
-#if defined(MA_DEBUG_OUTPUT)
-        printf("[AAudio] Device Disconnected.\n");
-#endif
-    }
-}
-
-static ma_aaudio_data_callback_result_t ma_stream_data_callback_capture__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_handle_backend_data_callback(pDevice, NULL, pAudioData, frameCount);
-
-    (void)pStream;
-    return MA_AAUDIO_CALLBACK_RESULT_CONTINUE;
-}
-
-static ma_aaudio_data_callback_result_t ma_stream_data_callback_playback__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_handle_backend_data_callback(pDevice, pAudioData, NULL, frameCount);
-
-    (void)pStream;
-    return MA_AAUDIO_CALLBACK_RESULT_CONTINUE;
-}
-
-static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, const ma_device_descriptor* pDescriptor, const ma_device_config* pConfig, ma_device* pDevice, ma_AAudioStreamBuilder** ppBuilder)
-{
-    ma_AAudioStreamBuilder* pBuilder;
-    ma_aaudio_result_t resultAA;
-    ma_uint32 bufferCapacityInFrames;
-
-    /* Safety. */
-    *ppBuilder = NULL;
-
-    resultAA = ((MA_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    if (pDeviceID != NULL) {
-        ((MA_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio);
-    }
-
-    ((MA_PFN_AAudioStreamBuilder_setDirection)pContext->aaudio.AAudioStreamBuilder_setDirection)(pBuilder, (deviceType == ma_device_type_playback) ? MA_AAUDIO_DIRECTION_OUTPUT : MA_AAUDIO_DIRECTION_INPUT);
-    ((MA_PFN_AAudioStreamBuilder_setSharingMode)pContext->aaudio.AAudioStreamBuilder_setSharingMode)(pBuilder, (shareMode == ma_share_mode_shared) ? MA_AAUDIO_SHARING_MODE_SHARED : MA_AAUDIO_SHARING_MODE_EXCLUSIVE);
-
-
-    /* If we have a device descriptor make sure we configure the stream builder to take our requested parameters. */
-    if (pDescriptor != NULL) {
-        MA_ASSERT(pConfig != NULL); /* We must have a device config if we also have a descriptor. The config is required for AAudio specific configuration options. */
-
-        if (pDescriptor->sampleRate != 0) {
-            ((MA_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pDescriptor->sampleRate);
-        }
-
-        if (deviceType == ma_device_type_capture) {
-            if (pDescriptor->channels != 0) {
-                ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels);
-            }
-            if (pDescriptor->format != ma_format_unknown) {
-                ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT);
-            }
-        } else {
-            if (pDescriptor->channels != 0) {
-                ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels);
-            }
-            if (pDescriptor->format != ma_format_unknown) {
-                ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT);
-            }
-        }
-
-        /*
-        AAudio is annoying when it comes to it's buffer calculation stuff because it doesn't let you
-        retrieve the actual sample rate until after you've opened the stream. But you need to configure
-        the buffer capacity before you open the stream... :/
-
-        To solve, we're just going to assume MA_DEFAULT_SAMPLE_RATE (48000) and move on.
-        */
-        bufferCapacityInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile) * pDescriptor->periodCount;
-
-        ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames);
-        ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pDescriptor->periodCount);
-
-        if (deviceType == ma_device_type_capture) {
-            if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setInputPreset)pContext->aaudio.AAudioStreamBuilder_setInputPreset)(pBuilder, ma_to_input_preset__aaudio(pConfig->aaudio.inputPreset));
-            }
-
-            ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_capture__aaudio, (void*)pDevice);
-        } else {
-            if (pConfig->aaudio.usage != ma_aaudio_usage_default && pContext->aaudio.AAudioStreamBuilder_setUsage != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setUsage)pContext->aaudio.AAudioStreamBuilder_setUsage)(pBuilder, ma_to_usage__aaudio(pConfig->aaudio.usage));
-            }
-
-            if (pConfig->aaudio.contentType != ma_aaudio_content_type_default && pContext->aaudio.AAudioStreamBuilder_setContentType != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setContentType)pContext->aaudio.AAudioStreamBuilder_setContentType)(pBuilder, ma_to_content_type__aaudio(pConfig->aaudio.contentType));
-            }
-
-            ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_playback__aaudio, (void*)pDevice);
-        }
-
-        /* Not sure how this affects things, but since there's a mapping between miniaudio's performance profiles and AAudio's performance modes, let go ahead and set it. */
-        ((MA_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == ma_performance_profile_low_latency) ? MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MA_AAUDIO_PERFORMANCE_MODE_NONE);
-    
-        /* We need to set an error callback to detect device changes. */
-        if (pDevice != NULL) {  /* <-- pDevice should never be null if pDescriptor is not null, which is always the case if we hit this branch. Check anyway for safety. */
-            ((MA_PFN_AAudioStreamBuilder_setErrorCallback)pContext->aaudio.AAudioStreamBuilder_setErrorCallback)(pBuilder, ma_stream_error_callback__aaudio, (void*)pDevice);
-        }
-    }
-
-    *ppBuilder = pBuilder;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_open_stream_and_close_builder__aaudio(ma_context* pContext, ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-
-    result = ma_result_from_aaudio(((MA_PFN_AAudioStreamBuilder_openStream)pContext->aaudio.AAudioStreamBuilder_openStream)(pBuilder, ppStream));
-    ((MA_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder);
-
-    return result;
-}
-
-static ma_result ma_open_stream_basic__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    ma_AAudioStreamBuilder* pBuilder;
-
-    *ppStream = NULL;
-
-    result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pContext, pDeviceID, deviceType, shareMode, NULL, NULL, NULL, &pBuilder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_open_stream_and_close_builder__aaudio(pContext, pBuilder, ppStream);
-}
-
-static ma_result ma_open_stream__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, const ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    ma_AAudioStreamBuilder* pBuilder;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pConfig->deviceType != ma_device_type_duplex);   /* This function should not be called for a full-duplex device type. */
-
-    *ppStream = NULL;
-
-    result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pDevice->pContext, pDescriptor->pDeviceID, deviceType, pDescriptor->shareMode, pDescriptor, pConfig, pDevice, &pBuilder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_open_stream_and_close_builder__aaudio(pDevice->pContext, pBuilder, ppStream);
-}
-
-static ma_result ma_close_stream__aaudio(ma_context* pContext, ma_AAudioStream* pStream)
-{
-    return ma_result_from_aaudio(((MA_PFN_AAudioStream_close)pContext->aaudio.AAudioStream_close)(pStream));
-}
-
-static ma_bool32 ma_has_default_device__aaudio(ma_context* pContext, ma_device_type deviceType)
-{
-    /* The only way to know this is to try creating a stream. */
-    ma_AAudioStream* pStream;
-    ma_result result = ma_open_stream_basic__aaudio(pContext, NULL, deviceType, ma_share_mode_shared, &pStream);
-    if (result != MA_SUCCESS) {
-        return MA_FALSE;
-    }
-
-    ma_close_stream__aaudio(pContext, pStream);
-    return MA_TRUE;
-}
-
-static ma_result ma_wait_for_simple_state_transition__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_aaudio_stream_state_t oldState, ma_aaudio_stream_state_t newState)
-{
-    ma_aaudio_stream_state_t actualNewState;
-    ma_aaudio_result_t resultAA = ((MA_PFN_AAudioStream_waitForStateChange)pContext->aaudio.AAudioStream_waitForStateChange)(pStream, oldState, &actualNewState, 5000000000); /* 5 second timeout. */
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    if (newState != actualNewState) {
-        return MA_ERROR;   /* Failed to transition into the expected state. */
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__aaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Unfortunately AAudio does not have an enumeration API. Therefore I'm only going to report default devices, but only if it can instantiate a stream. */
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED;
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-
-        if (ma_has_default_device__aaudio(pContext, ma_device_type_playback)) {
-            cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-        }
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED;
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-
-        if (ma_has_default_device__aaudio(pContext, ma_device_type_capture)) {
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_format format, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pStream     != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream);
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)(pStream);
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-    pDeviceInfo->nativeDataFormatCount += 1;
-}
-
-static void ma_context_add_native_data_format_from_AAudioStream__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    /* AAudio supports s16 and f32. */
-    ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_f32, flags, pDeviceInfo);
-    ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_s16, flags, pDeviceInfo);
-}
-
-static ma_result ma_context_get_device_info__aaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_AAudioStream* pStream;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* ID */
-    if (pDeviceID != NULL) {
-        pDeviceInfo->id.aaudio = pDeviceID->aaudio;
-    } else {
-        pDeviceInfo->id.aaudio = MA_AAUDIO_UNSPECIFIED;
-    }
-
-    /* Name */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-
-    pDeviceInfo->nativeDataFormatCount = 0;
-
-    /* We'll need to open the device to get accurate sample rate and channel count information. */
-    result = ma_open_stream_basic__aaudio(pContext, pDeviceID, deviceType, ma_share_mode_shared, &pStream);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    ma_context_add_native_data_format_from_AAudioStream__aaudio(pContext, pStream, 0, pDeviceInfo);
-
-    ma_close_stream__aaudio(pContext, pStream);
-    pStream = NULL;
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__aaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        pDevice->aaudio.pStreamCapture = NULL;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        pDevice->aaudio.pStreamPlayback = NULL;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_by_type__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    int32_t bufferCapacityInFrames;
-    int32_t framesPerDataCallback;
-    ma_AAudioStream* pStream;
-
-    MA_ASSERT(pDevice     != NULL);
-    MA_ASSERT(pConfig     != NULL);
-    MA_ASSERT(pDescriptor != NULL);
-
-    *ppStream = NULL;   /* Safety. */
-
-    /* First step is to open the stream. From there we'll be able to extract the internal configuration. */
-    result = ma_open_stream__aaudio(pDevice, pConfig, deviceType, pDescriptor, &pStream);
-    if (result != MA_SUCCESS) {
-        return result;  /* Failed to open the AAudio stream. */
-    }
-
-    /* Now extract the internal configuration. */
-    pDescriptor->format     = (((MA_PFN_AAudioStream_getFormat)pDevice->pContext->aaudio.AAudioStream_getFormat)(pStream) == MA_AAUDIO_FORMAT_PCM_I16) ? ma_format_s16 : ma_format_f32;
-    pDescriptor->channels   = ((MA_PFN_AAudioStream_getChannelCount)pDevice->pContext->aaudio.AAudioStream_getChannelCount)(pStream);
-    pDescriptor->sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pDevice->pContext->aaudio.AAudioStream_getSampleRate)(pStream);
-
-    /* For the channel map we need to be sure we don't overflow any buffers. */
-    if (pDescriptor->channels <= MA_MAX_CHANNELS) {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptor->channels, pDescriptor->channelMap); /* <-- Cannot find info on channel order, so assuming a default. */
-    } else {
-        ma_channel_map_init_blank(MA_MAX_CHANNELS, pDescriptor->channelMap); /* Too many channels. Use a blank channel map. */
-    }
-
-    bufferCapacityInFrames = ((MA_PFN_AAudioStream_getBufferCapacityInFrames)pDevice->pContext->aaudio.AAudioStream_getBufferCapacityInFrames)(pStream);
-    framesPerDataCallback = ((MA_PFN_AAudioStream_getFramesPerDataCallback)pDevice->pContext->aaudio.AAudioStream_getFramesPerDataCallback)(pStream);
-
-    if (framesPerDataCallback > 0) {
-        pDescriptor->periodSizeInFrames = framesPerDataCallback;
-        pDescriptor->periodCount        = bufferCapacityInFrames / framesPerDataCallback;
-    } else {
-        pDescriptor->periodSizeInFrames = bufferCapacityInFrames;
-        pDescriptor->periodCount        = 1;
-    }
-
-    *ppStream = pStream;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with AAudio. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_capture, pDescriptorCapture, (ma_AAudioStream**)&pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_playback, pDescriptorPlayback, (ma_AAudioStream**)&pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream)
-{
-    ma_aaudio_result_t resultAA;
-    ma_aaudio_stream_state_t currentState;
-
-    MA_ASSERT(pDevice != NULL);
-
-    resultAA = ((MA_PFN_AAudioStream_requestStart)pDevice->pContext->aaudio.AAudioStream_requestStart)(pStream);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    /* Do we actually need to wait for the device to transition into it's started state? */
-
-    /* The device should be in either a starting or started state. If it's not set to started we need to wait for it to transition. It should go from starting to started. */
-    currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream);
-    if (currentState != MA_AAUDIO_STREAM_STATE_STARTED) {
-        ma_result result;
-
-        if (currentState != MA_AAUDIO_STREAM_STATE_STARTING) {
-            return MA_ERROR;   /* Expecting the stream to be a starting or started state. */
-        }
-
-        result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STARTED);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream)
-{
-    ma_aaudio_result_t resultAA;
-    ma_aaudio_stream_state_t currentState;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the AAudio documentation:
-
-        The stream will stop after all of the data currently buffered has been played.
-
-    This maps with miniaudio's requirement that device's be drained which means we don't need to implement any draining logic.
-    */
-
-    resultAA = ((MA_PFN_AAudioStream_requestStop)pDevice->pContext->aaudio.AAudioStream_requestStop)(pStream);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    /* The device should be in either a stopping or stopped state. If it's not set to started we need to wait for it to transition. It should go from stopping to stopped. */
-    currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream);
-    if (currentState != MA_AAUDIO_STREAM_STATE_STOPPED) {
-        ma_result result;
-
-        if (currentState != MA_AAUDIO_STREAM_STATE_STOPPING) {
-            return MA_ERROR;   /* Expecting the stream to be a stopping or stopped state. */
-        }
-
-        result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STOPPED);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__aaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            if (pDevice->type == ma_device_type_duplex) {
-                ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__aaudio(ma_device* pDevice)
-{
-    ma_stop_proc onStop;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__aaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_aaudio);
-
-    ma_dlclose(pContext, pContext->aaudio.hAAudio);
-    pContext->aaudio.hAAudio = NULL;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    size_t i;
-    const char* libNames[] = {
-        "libaaudio.so"
-    };
-
-    for (i = 0; i < ma_countof(libNames); ++i) {
-        pContext->aaudio.hAAudio = ma_dlopen(pContext, libNames[i]);
-        if (pContext->aaudio.hAAudio != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->aaudio.hAAudio == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->aaudio.AAudio_createStreamBuilder                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudio_createStreamBuilder");
-    pContext->aaudio.AAudioStreamBuilder_delete                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_delete");
-    pContext->aaudio.AAudioStreamBuilder_setDeviceId               = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDeviceId");
-    pContext->aaudio.AAudioStreamBuilder_setDirection              = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDirection");
-    pContext->aaudio.AAudioStreamBuilder_setSharingMode            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSharingMode");
-    pContext->aaudio.AAudioStreamBuilder_setFormat                 = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFormat");
-    pContext->aaudio.AAudioStreamBuilder_setChannelCount           = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setChannelCount");
-    pContext->aaudio.AAudioStreamBuilder_setSampleRate             = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSampleRate");
-    pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setBufferCapacityInFrames");
-    pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFramesPerDataCallback");
-    pContext->aaudio.AAudioStreamBuilder_setDataCallback           = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDataCallback");
-    pContext->aaudio.AAudioStreamBuilder_setErrorCallback          = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setErrorCallback");
-    pContext->aaudio.AAudioStreamBuilder_setPerformanceMode        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setPerformanceMode");
-    pContext->aaudio.AAudioStreamBuilder_setUsage                  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setUsage");
-    pContext->aaudio.AAudioStreamBuilder_setContentType            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setContentType");
-    pContext->aaudio.AAudioStreamBuilder_setInputPreset            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setInputPreset");
-    pContext->aaudio.AAudioStreamBuilder_openStream                = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_openStream");
-    pContext->aaudio.AAudioStream_close                            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_close");
-    pContext->aaudio.AAudioStream_getState                         = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getState");
-    pContext->aaudio.AAudioStream_waitForStateChange               = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_waitForStateChange");
-    pContext->aaudio.AAudioStream_getFormat                        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFormat");
-    pContext->aaudio.AAudioStream_getChannelCount                  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getChannelCount");
-    pContext->aaudio.AAudioStream_getSampleRate                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getSampleRate");
-    pContext->aaudio.AAudioStream_getBufferCapacityInFrames        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getBufferCapacityInFrames");
-    pContext->aaudio.AAudioStream_getFramesPerDataCallback         = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFramesPerDataCallback");
-    pContext->aaudio.AAudioStream_getFramesPerBurst                = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFramesPerBurst");
-    pContext->aaudio.AAudioStream_requestStart                     = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_requestStart");
-    pContext->aaudio.AAudioStream_requestStop                      = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_requestStop");
-
-
-    pCallbacks->onContextInit             = ma_context_init__aaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__aaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__aaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__aaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__aaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__aaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__aaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__aaudio;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because AAudio is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because AAudio is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not used because AAudio is asynchronous. */
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-#endif  /* AAudio */
-
-
-/******************************************************************************
-
-OpenSL|ES Backend
-
-******************************************************************************/
-#ifdef MA_HAS_OPENSL
-#include <SLES/OpenSLES.h>
-#ifdef MA_ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-typedef SLresult (SLAPIENTRY * ma_slCreateEngine_proc)(SLObjectItf* pEngine, SLuint32 numOptions, SLEngineOption* pEngineOptions, SLuint32 numInterfaces, SLInterfaceID* pInterfaceIds, SLboolean* pInterfaceRequired);
-
-/* OpenSL|ES has one-per-application objects :( */
-static SLObjectItf g_maEngineObjectSL    = NULL;
-static SLEngineItf g_maEngineSL          = NULL;
-static ma_uint32   g_maOpenSLInitCounter = 0;
-static ma_spinlock g_maOpenSLSpinlock    = 0;   /* For init/uninit. */
-
-#define MA_OPENSL_OBJ(p)         (*((SLObjectItf)(p)))
-#define MA_OPENSL_OUTPUTMIX(p)   (*((SLOutputMixItf)(p)))
-#define MA_OPENSL_PLAY(p)        (*((SLPlayItf)(p)))
-#define MA_OPENSL_RECORD(p)      (*((SLRecordItf)(p)))
-
-#ifdef MA_ANDROID
-#define MA_OPENSL_BUFFERQUEUE(p) (*((SLAndroidSimpleBufferQueueItf)(p)))
-#else
-#define MA_OPENSL_BUFFERQUEUE(p) (*((SLBufferQueueItf)(p)))
-#endif
-
-static ma_result ma_result_from_OpenSL(SLuint32 result)
-{
-    switch (result)
-    {
-        case SL_RESULT_SUCCESS:                 return MA_SUCCESS;
-        case SL_RESULT_PRECONDITIONS_VIOLATED:  return MA_ERROR;
-        case SL_RESULT_PARAMETER_INVALID:       return MA_INVALID_ARGS;
-        case SL_RESULT_MEMORY_FAILURE:          return MA_OUT_OF_MEMORY;
-        case SL_RESULT_RESOURCE_ERROR:          return MA_INVALID_DATA;
-        case SL_RESULT_RESOURCE_LOST:           return MA_ERROR;
-        case SL_RESULT_IO_ERROR:                return MA_IO_ERROR;
-        case SL_RESULT_BUFFER_INSUFFICIENT:     return MA_NO_SPACE;
-        case SL_RESULT_CONTENT_CORRUPTED:       return MA_INVALID_DATA;
-        case SL_RESULT_CONTENT_UNSUPPORTED:     return MA_FORMAT_NOT_SUPPORTED;
-        case SL_RESULT_CONTENT_NOT_FOUND:       return MA_ERROR;
-        case SL_RESULT_PERMISSION_DENIED:       return MA_ACCESS_DENIED;
-        case SL_RESULT_FEATURE_UNSUPPORTED:     return MA_NOT_IMPLEMENTED;
-        case SL_RESULT_INTERNAL_ERROR:          return MA_ERROR;
-        case SL_RESULT_UNKNOWN_ERROR:           return MA_ERROR;
-        case SL_RESULT_OPERATION_ABORTED:       return MA_ERROR;
-        case SL_RESULT_CONTROL_LOST:            return MA_ERROR;
-        default:                                return MA_ERROR;
-    }
-}
-
-/* Converts an individual OpenSL-style channel identifier (SL_SPEAKER_FRONT_LEFT, etc.) to miniaudio. */
-static ma_uint8 ma_channel_id_to_ma__opensl(SLuint32 id)
-{
-    switch (id)
-    {
-        case SL_SPEAKER_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case SL_SPEAKER_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case SL_SPEAKER_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case SL_SPEAKER_LOW_FREQUENCY:         return MA_CHANNEL_LFE;
-        case SL_SPEAKER_BACK_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case SL_SPEAKER_BACK_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case SL_SPEAKER_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case SL_SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case SL_SPEAKER_BACK_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case SL_SPEAKER_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case SL_SPEAKER_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case SL_SPEAKER_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case SL_SPEAKER_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case SL_SPEAKER_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case SL_SPEAKER_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case SL_SPEAKER_TOP_BACK_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case SL_SPEAKER_TOP_BACK_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        case SL_SPEAKER_TOP_BACK_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to OpenSL-style. */
-static SLuint32 ma_channel_id_to_opensl(ma_uint8 id)
-{
-    switch (id)
-    {
-        case MA_CHANNEL_MONO:               return SL_SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_FRONT_LEFT:         return SL_SPEAKER_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return SL_SPEAKER_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return SL_SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return SL_SPEAKER_LOW_FREQUENCY;
-        case MA_CHANNEL_BACK_LEFT:          return SL_SPEAKER_BACK_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return SL_SPEAKER_BACK_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return SL_SPEAKER_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return SL_SPEAKER_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return SL_SPEAKER_BACK_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return SL_SPEAKER_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return SL_SPEAKER_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return SL_SPEAKER_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return SL_SPEAKER_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return SL_SPEAKER_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return SL_SPEAKER_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return SL_SPEAKER_TOP_BACK_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return SL_SPEAKER_TOP_BACK_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return SL_SPEAKER_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts a channel mapping to an OpenSL-style channel mask. */
-static SLuint32 ma_channel_map_to_channel_mask__opensl(const ma_channel* pChannelMap, ma_uint32 channels)
-{
-    SLuint32 channelMask = 0;
-    ma_uint32 iChannel;
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        channelMask |= ma_channel_id_to_opensl(pChannelMap[iChannel]);
-    }
-
-    return channelMask;
-}
-
-/* Converts an OpenSL-style channel mask to a miniaudio channel map. */
-static void ma_channel_mask_to_channel_map__opensl(SLuint32 channelMask, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (channels == 1 && channelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_MONO;
-    } else if (channels == 2 && channelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-        pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-    } else {
-        if (channels == 1 && (channelMask & SL_SPEAKER_FRONT_CENTER) != 0) {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } else {
-            /* Just iterate over each bit. */
-            ma_uint32 iChannel = 0;
-            ma_uint32 iBit;
-            for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) {
-                SLuint32 bitValue = (channelMask & (1UL << iBit));
-                if (bitValue != 0) {
-                    /* The bit is set. */
-                    pChannelMap[iChannel] = ma_channel_id_to_ma__opensl(bitValue);
-                    iChannel += 1;
-                }
-            }
-        }
-    }
-}
-
-static SLuint32 ma_round_to_standard_sample_rate__opensl(SLuint32 samplesPerSec)
-{
-    if (samplesPerSec <= SL_SAMPLINGRATE_8) {
-        return SL_SAMPLINGRATE_8;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_11_025) {
-        return SL_SAMPLINGRATE_11_025;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_12) {
-        return SL_SAMPLINGRATE_12;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_16) {
-        return SL_SAMPLINGRATE_16;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_22_05) {
-        return SL_SAMPLINGRATE_22_05;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_24) {
-        return SL_SAMPLINGRATE_24;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_32) {
-        return SL_SAMPLINGRATE_32;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_44_1) {
-        return SL_SAMPLINGRATE_44_1;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_48) {
-        return SL_SAMPLINGRATE_48;
-    }
-
-    /* Android doesn't support more than 48000. */
-#ifndef MA_ANDROID
-    if (samplesPerSec <= SL_SAMPLINGRATE_64) {
-        return SL_SAMPLINGRATE_64;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_88_2) {
-        return SL_SAMPLINGRATE_88_2;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_96) {
-        return SL_SAMPLINGRATE_96;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_192) {
-        return SL_SAMPLINGRATE_192;
-    }
-#endif
-
-    return SL_SAMPLINGRATE_16;
-}
-
-
-static SLint32 ma_to_stream_type__opensl(ma_opensl_stream_type streamType)
-{
-    switch (streamType) {
-        case ma_opensl_stream_type_voice:        return SL_ANDROID_STREAM_VOICE;
-        case ma_opensl_stream_type_system:       return SL_ANDROID_STREAM_SYSTEM;
-        case ma_opensl_stream_type_ring:         return SL_ANDROID_STREAM_RING;
-        case ma_opensl_stream_type_media:        return SL_ANDROID_STREAM_MEDIA;
-        case ma_opensl_stream_type_alarm:        return SL_ANDROID_STREAM_ALARM;
-        case ma_opensl_stream_type_notification: return SL_ANDROID_STREAM_NOTIFICATION;
-        default: break;
-    }
-
-    return SL_ANDROID_STREAM_VOICE;
-}
-
-static SLint32 ma_to_recording_preset__opensl(ma_opensl_recording_preset recordingPreset)
-{
-    switch (recordingPreset) {
-        case ma_opensl_recording_preset_generic:             return SL_ANDROID_RECORDING_PRESET_GENERIC;
-        case ma_opensl_recording_preset_camcorder:           return SL_ANDROID_RECORDING_PRESET_CAMCORDER;
-        case ma_opensl_recording_preset_voice_recognition:   return SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
-        case ma_opensl_recording_preset_voice_communication: return SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
-        case ma_opensl_recording_preset_voice_unprocessed:   return SL_ANDROID_RECORDING_PRESET_UNPROCESSED;
-        default: break;
-    }
-
-    return SL_ANDROID_RECORDING_PRESET_NONE;
-}
-
-
-static ma_result ma_context_enumerate_devices__opensl(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to enumerate devices. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    TODO: Test Me.
-
-    This is currently untested, so for now we are just returning default devices.
-    */
-#if 0 && !defined(MA_ANDROID)
-    ma_bool32 isTerminated = MA_FALSE;
-
-    SLuint32 pDeviceIDs[128];
-    SLint32 deviceCount = sizeof(pDeviceIDs) / sizeof(pDeviceIDs[0]);
-
-    SLAudioIODeviceCapabilitiesItf deviceCaps;
-    SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        /* The interface may not be supported so just report a default device. */
-        goto return_default_device;
-    }
-
-    /* Playback */
-    if (!isTerminated) {
-        resultSL = (*deviceCaps)->GetAvailableAudioOutputs(deviceCaps, &deviceCount, pDeviceIDs);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.opensl = pDeviceIDs[iDevice];
-
-            SLAudioOutputDescriptor desc;
-            resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.pDeviceName, (size_t)-1);
-
-                ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    isTerminated = MA_TRUE;
-                    break;
-                }
-            }
-        }
-    }
-
-    /* Capture */
-    if (!isTerminated) {
-        resultSL = (*deviceCaps)->GetAvailableAudioInputs(deviceCaps, &deviceCount, pDeviceIDs);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.opensl = pDeviceIDs[iDevice];
-
-            SLAudioInputDescriptor desc;
-            resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.deviceName, (size_t)-1);
-
-                ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    isTerminated = MA_TRUE;
-                    break;
-                }
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-#else
-    goto return_default_device;
-#endif
-
-return_default_device:;
-    cbResult = MA_TRUE;
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_data_format_ex__opensl(ma_context* pContext, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount += 1;
-}
-
-static void ma_context_add_data_format__opensl(ma_context* pContext, ma_format format, ma_device_info* pDeviceInfo)
-{
-    ma_uint32 minChannels   = 1;
-    ma_uint32 maxChannels   = 2;
-    ma_uint32 minSampleRate = (ma_uint32)ma_standard_sample_rate_8000;
-    ma_uint32 maxSampleRate = (ma_uint32)ma_standard_sample_rate_48000;
-    ma_uint32 iChannel;
-    ma_uint32 iSampleRate;
-
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /*
-    Each sample format can support mono and stereo, and we'll support a small subset of standard
-    rates (up to 48000). A better solution would be to somehow find a native sample rate.
-    */
-    for (iChannel = minChannels; iChannel < maxChannels; iChannel += 1) {
-        for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) {
-            ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate];
-            if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) {
-                ma_context_add_data_format_ex__opensl(pContext, format, iChannel, standardSampleRate, pDeviceInfo);
-            }
-        }
-    }
-}
-
-static ma_result ma_context_get_device_info__opensl(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to get device info. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    TODO: Test Me.
-
-    This is currently untested, so for now we are just returning default devices.
-    */
-#if 0 && !defined(MA_ANDROID)
-    SLAudioIODeviceCapabilitiesItf deviceCaps;
-    SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        /* The interface may not be supported so just report a default device. */
-        goto return_default_device;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        SLAudioOutputDescriptor desc;
-        resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, pDeviceID->opensl, &desc);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.pDeviceName, (size_t)-1);
-    } else {
-        SLAudioInputDescriptor desc;
-        resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, pDeviceID->opensl, &desc);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.deviceName, (size_t)-1);
-    }
-
-    goto return_detailed_info;
-#else
-    goto return_default_device;
-#endif
-
-return_default_device:
-    if (pDeviceID != NULL) {
-        if ((deviceType == ma_device_type_playback && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOOUTPUT) ||
-            (deviceType == ma_device_type_capture  && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOINPUT)) {
-            return MA_NO_DEVICE;   /* Don't know the device. */
-        }
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    goto return_detailed_info;
-
-
-return_detailed_info:
-
-    /*
-    For now we're just outputting a set of values that are supported by the API but not necessarily supported
-    by the device natively. Later on we should work on this so that it more closely reflects the device's
-    actual native format.
-    */
-    pDeviceInfo->nativeDataFormatCount = 0;
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    ma_context_add_data_format__opensl(pContext, ma_format_f32, pDeviceInfo);
-#endif
-    ma_context_add_data_format__opensl(pContext, ma_format_s16, pDeviceInfo);
-    ma_context_add_data_format__opensl(pContext, ma_format_u8,  pDeviceInfo);
-
-    return MA_SUCCESS;
-}
-
-
-#ifdef MA_ANDROID
-/*void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, SLuint32 eventFlags, const void* pBuffer, SLuint32 bufferSize, SLuint32 dataUsed, void* pContext)*/
-static void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    size_t periodSizeInBytes;
-    ma_uint8* pBuffer;
-    SLresult resultSL;
-
-    MA_ASSERT(pDevice != NULL);
-
-    (void)pBufferQueue;
-
-    /*
-    For now, don't do anything unless the buffer was fully processed. From what I can tell, it looks like
-    OpenSL|ES 1.1 improves on buffer queues to the point that we could much more intelligently handle this,
-    but unfortunately it looks like Android is only supporting OpenSL|ES 1.0.1 for now :(
-    */
-
-    /* Don't do anything if the device is not started. */
-    if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-        return;
-    }
-
-    /* Don't do anything if the device is being drained. */
-    if (pDevice->opensl.isDrainingCapture) {
-        return;
-    }
-
-    periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    pBuffer = pDevice->opensl.pBufferCapture + (pDevice->opensl.currentBufferIndexCapture * periodSizeInBytes);
-
-    ma_device_handle_backend_data_callback(pDevice, NULL, pBuffer, pDevice->capture.internalPeriodSizeInFrames);
-
-    resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        return;
-    }
-
-    pDevice->opensl.currentBufferIndexCapture = (pDevice->opensl.currentBufferIndexCapture + 1) % pDevice->capture.internalPeriods;
-}
-
-static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    size_t periodSizeInBytes;
-    ma_uint8* pBuffer;
-    SLresult resultSL;
-
-    MA_ASSERT(pDevice != NULL);
-
-    (void)pBufferQueue;
-
-    /* Don't do anything if the device is not started. */
-    if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-        return;
-    }
-
-    /* Don't do anything if the device is being drained. */
-    if (pDevice->opensl.isDrainingPlayback) {
-        return;
-    }
-
-    periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    pBuffer = pDevice->opensl.pBufferPlayback + (pDevice->opensl.currentBufferIndexPlayback * periodSizeInBytes);
-
-    ma_device_handle_backend_data_callback(pDevice, pBuffer, NULL, pDevice->playback.internalPeriodSizeInFrames);
-
-    resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        return;
-    }
-
-    pDevice->opensl.currentBufferIndexPlayback = (pDevice->opensl.currentBufferIndexPlayback + 1) % pDevice->playback.internalPeriods;
-}
-#endif
-
-static ma_result ma_device_uninit__opensl(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before uninitializing the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->opensl.pAudioRecorderObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioRecorderObj);
-        }
-
-        ma__free_from_callbacks(pDevice->opensl.pBufferCapture, &pDevice->pContext->allocationCallbacks);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->opensl.pAudioPlayerObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioPlayerObj);
-        }
-        if (pDevice->opensl.pOutputMixObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Destroy((SLObjectItf)pDevice->opensl.pOutputMixObj);
-        }
-
-        ma__free_from_callbacks(pDevice->opensl.pBufferPlayback, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-typedef SLAndroidDataFormat_PCM_EX  ma_SLDataFormat_PCM;
-#else
-typedef SLDataFormat_PCM            ma_SLDataFormat_PCM;
-#endif
-
-static ma_result ma_SLDataFormat_PCM_init__opensl(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* channelMap, ma_SLDataFormat_PCM* pDataFormat)
-{
-    /* We need to convert our format/channels/rate so that they aren't set to default. */
-    if (format == ma_format_unknown) {
-        format = MA_DEFAULT_FORMAT;
-    }
-    if (channels == 0) {
-        channels = MA_DEFAULT_CHANNELS;
-    }
-    if (sampleRate == 0) {
-        sampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    if (format == ma_format_f32) {
-        pDataFormat->formatType     = SL_ANDROID_DATAFORMAT_PCM_EX;
-        pDataFormat->representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
-    } else {
-        pDataFormat->formatType = SL_DATAFORMAT_PCM;
-    }
-#else
-    pDataFormat->formatType = SL_DATAFORMAT_PCM;
-#endif
-
-    pDataFormat->numChannels   = channels;
-    ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = ma_round_to_standard_sample_rate__opensl(sampleRate) * 1000;  /* In millihertz. Annoyingly, the sample rate variable is named differently between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM */
-    pDataFormat->bitsPerSample = ma_get_bytes_per_sample(format)*8;
-    pDataFormat->channelMask   = ma_channel_map_to_channel_mask__opensl(channelMap, channels);
-    pDataFormat->endianness    = (ma_is_little_endian()) ? SL_BYTEORDER_LITTLEENDIAN : SL_BYTEORDER_BIGENDIAN;
-
-    /*
-    Android has a few restrictions on the format as documented here: https://developer.android.com/ndk/guides/audio/opensl-for-android.html
-     - Only mono and stereo is supported.
-     - Only u8 and s16 formats are supported.
-     - Maximum sample rate of 48000.
-    */
-#ifdef MA_ANDROID
-    if (pDataFormat->numChannels > 2) {
-        pDataFormat->numChannels = 2;
-    }
-#if __ANDROID_API__ >= 21
-    if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) {
-        /* It's floating point. */
-        MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT);
-        if (pDataFormat->bitsPerSample > 32) {
-            pDataFormat->bitsPerSample = 32;
-        }
-    } else {
-        if (pDataFormat->bitsPerSample > 16) {
-            pDataFormat->bitsPerSample = 16;
-        }
-    }
-#else
-    if (pDataFormat->bitsPerSample > 16) {
-        pDataFormat->bitsPerSample = 16;
-    }
-#endif
-    if (((SLDataFormat_PCM*)pDataFormat)->samplesPerSec > SL_SAMPLINGRATE_48) {
-        ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = SL_SAMPLINGRATE_48;
-    }
-#endif
-
-    pDataFormat->containerSize = pDataFormat->bitsPerSample;  /* Always tightly packed for now. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_deconstruct_SLDataFormat_PCM__opensl(ma_SLDataFormat_PCM* pDataFormat, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    ma_bool32 isFloatingPoint = MA_FALSE;
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) {
-        MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT);
-        isFloatingPoint = MA_TRUE;
-    }
-#endif
-    if (isFloatingPoint) {
-        if (pDataFormat->bitsPerSample == 32) {
-            *pFormat = ma_format_f32;
-        }
-    } else {
-        if (pDataFormat->bitsPerSample == 8) {
-            *pFormat = ma_format_u8;
-        } else if (pDataFormat->bitsPerSample == 16) {
-            *pFormat = ma_format_s16;
-        } else if (pDataFormat->bitsPerSample == 24) {
-            *pFormat = ma_format_s24;
-        } else if (pDataFormat->bitsPerSample == 32) {
-            *pFormat = ma_format_s32;
-        }
-    }
-
-    *pChannels   = pDataFormat->numChannels;
-    *pSampleRate = ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec / 1000;
-    ma_channel_mask_to_channel_map__opensl(pDataFormat->channelMask, ma_min(pDataFormat->numChannels, channelMapCap), pChannelMap);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-#ifdef MA_ANDROID
-    SLDataLocator_AndroidSimpleBufferQueue queue;
-    SLresult resultSL;
-    size_t bufferSizeInBytes;
-    SLInterfaceID itfIDs1[1];
-    const SLboolean itfIDsRequired1[] = {SL_BOOLEAN_TRUE};
-#endif
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to initialize a new device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /*
-    For now, only supporting Android implementations of OpenSL|ES since that's the only one I've
-    been able to test with and I currently depend on Android-specific extensions (simple buffer
-    queues).
-    */
-#ifdef MA_ANDROID
-    itfIDs1[0] = (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-
-    /* No exclusive mode with OpenSL|ES. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Now we can start initializing the device properly. */
-    MA_ASSERT(pDevice != NULL);
-    MA_ZERO_OBJECT(&pDevice->opensl);
-
-    queue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_SLDataFormat_PCM pcm;
-        SLDataLocator_IODevice locatorDevice;
-        SLDataSource source;
-        SLDataSink sink;
-        SLAndroidConfigurationItf pRecorderConfig;
-
-        ma_SLDataFormat_PCM_init__opensl(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &pcm);
-
-        locatorDevice.locatorType = SL_DATALOCATOR_IODEVICE;
-        locatorDevice.deviceType  = SL_IODEVICE_AUDIOINPUT;
-        locatorDevice.deviceID    = (pDescriptorCapture->pDeviceID == NULL) ? SL_DEFAULTDEVICEID_AUDIOINPUT : pDescriptorCapture->pDeviceID->opensl;
-        locatorDevice.device      = NULL;
-
-        source.pLocator = &locatorDevice;
-        source.pFormat  = NULL;
-
-        queue.numBuffers = pDescriptorCapture->periodCount;
-
-        sink.pLocator = &queue;
-        sink.pFormat  = (SLDataFormat_PCM*)&pcm;
-
-        resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED) {
-            /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */
-            pcm.formatType    = SL_DATAFORMAT_PCM;
-            pcm.numChannels   = 1;
-            ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16;  /* The name of the sample rate variable is different between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM. */
-            pcm.bitsPerSample = 16;
-            pcm.containerSize = pcm.bitsPerSample;  /* Always tightly packed for now. */
-            pcm.channelMask   = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
-            resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        }
-
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio recorder.", ma_result_from_OpenSL(resultSL));
-        }
-
-
-        /* Set the recording preset before realizing the player. */
-        if (pConfig->opensl.recordingPreset != ma_opensl_recording_preset_default) {
-            resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pRecorderConfig);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                SLint32 recordingPreset = ma_to_recording_preset__opensl(pConfig->opensl.recordingPreset);
-                resultSL = (*pRecorderConfig)->SetConfiguration(pRecorderConfig, SL_ANDROID_KEY_RECORDING_PRESET, &recordingPreset, sizeof(SLint32));
-                if (resultSL != SL_RESULT_SUCCESS) {
-                    /* Failed to set the configuration. Just keep going. */
-                }
-            }
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Realize((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio recorder.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_RECORD, &pDevice->opensl.pAudioRecorder);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_RECORD interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueueCapture);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, ma_buffer_queue_callback_capture__opensl_android, pDevice);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* The internal format is determined by the "pcm" object. */
-        ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorCapture->format, &pDescriptorCapture->channels, &pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap));
-
-        /* Buffer. */
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-        pDevice->opensl.currentBufferIndexCapture = 0;
-
-        bufferSizeInBytes = pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * pDescriptorCapture->periodCount;
-        pDevice->opensl.pBufferCapture = (ma_uint8*)ma__calloc_from_callbacks(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks);
-        if (pDevice->opensl.pBufferCapture == NULL) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY);
-        }
-        MA_ZERO_MEMORY(pDevice->opensl.pBufferCapture, bufferSizeInBytes);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_SLDataFormat_PCM pcm;
-        SLDataSource source;
-        SLDataLocator_OutputMix outmixLocator;
-        SLDataSink sink;
-        SLAndroidConfigurationItf pPlayerConfig;
-
-        ma_SLDataFormat_PCM_init__opensl(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &pcm);
-
-        resultSL = (*g_maEngineSL)->CreateOutputMix(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, NULL, NULL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Realize((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize output mix object.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->GetInterface((SLObjectItf)pDevice->opensl.pOutputMixObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_OUTPUTMIX, &pDevice->opensl.pOutputMix);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_OUTPUTMIX interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* Set the output device. */
-        if (pDescriptorPlayback->pDeviceID != NULL) {
-            SLuint32 deviceID_OpenSL = pDescriptorPlayback->pDeviceID->opensl;
-            MA_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL);
-        }
-
-        queue.numBuffers = pDescriptorPlayback->periodCount;
-
-        source.pLocator = &queue;
-        source.pFormat  = (SLDataFormat_PCM*)&pcm;
-
-        outmixLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX;
-        outmixLocator.outputMix   = (SLObjectItf)pDevice->opensl.pOutputMixObj;
-
-        sink.pLocator = &outmixLocator;
-        sink.pFormat  = NULL;
-
-        resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED) {
-            /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */
-            pcm.formatType = SL_DATAFORMAT_PCM;
-            pcm.numChannels = 2;
-            ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16;
-            pcm.bitsPerSample = 16;
-            pcm.containerSize = pcm.bitsPerSample;  /* Always tightly packed for now. */
-            pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
-            resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        }
-
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio player.", ma_result_from_OpenSL(resultSL));
-        }
-
-
-        /* Set the stream type before realizing the player. */
-        if (pConfig->opensl.streamType != ma_opensl_stream_type_default) {
-            resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pPlayerConfig);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                SLint32 streamType = ma_to_stream_type__opensl(pConfig->opensl.streamType);
-                resultSL = (*pPlayerConfig)->SetConfiguration(pPlayerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
-                if (resultSL != SL_RESULT_SUCCESS) {
-                    /* Failed to set the configuration. Just keep going. */
-                }
-            }
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Realize((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio player.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_PLAY, &pDevice->opensl.pAudioPlayer);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_PLAY interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueuePlayback);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, ma_buffer_queue_callback_playback__opensl_android, pDevice);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* The internal format is determined by the "pcm" object. */
-        ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorPlayback->format, &pDescriptorPlayback->channels, &pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap));
-
-        /* Buffer. */
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-        pDevice->opensl.currentBufferIndexPlayback   = 0;
-
-        bufferSizeInBytes = pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) * pDescriptorPlayback->periodCount;
-        pDevice->opensl.pBufferPlayback = (ma_uint8*)ma__calloc_from_callbacks(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks);
-        if (pDevice->opensl.pBufferPlayback == NULL) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY);
-        }
-        MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, bufferSizeInBytes);
-    }
-
-    return MA_SUCCESS;
-#else
-    return MA_NO_BACKEND;   /* Non-Android implementations are not supported. */
-#endif
-}
-
-static ma_result ma_device_start__opensl(ma_device* pDevice)
-{
-    SLresult resultSL;
-    size_t periodSizeInBytes;
-    ma_uint32 iPeriod;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to start the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_RECORDING);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal capture device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-        for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
-            resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pDevice->opensl.pBufferCapture + (periodSizeInBytes * iPeriod), periodSizeInBytes);
-            if (resultSL != SL_RESULT_SUCCESS) {
-                MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for capture device.", ma_result_from_OpenSL(resultSL));
-            }
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_PLAYING);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal playback device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* In playback mode (no duplex) we need to load some initial buffers. In duplex mode we need to enqueu silent buffers. */
-        if (pDevice->type == ma_device_type_duplex) {
-            MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-        } else {
-            ma_device__read_frames_from_client(pDevice, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods, pDevice->opensl.pBufferPlayback);
-        }
-
-        periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-        for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; ++iPeriod) {
-            resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pDevice->opensl.pBufferPlayback + (periodSizeInBytes * iPeriod), periodSizeInBytes);
-            if (resultSL != SL_RESULT_SUCCESS) {
-                MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for playback device.", ma_result_from_OpenSL(resultSL));
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_drain__opensl(ma_device* pDevice, ma_device_type deviceType)
-{
-    SLAndroidSimpleBufferQueueItf pBufferQueue;
-
-    MA_ASSERT(deviceType == ma_device_type_capture || deviceType == ma_device_type_playback);
-
-    if (pDevice->type == ma_device_type_capture) {
-        pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture;
-        pDevice->opensl.isDrainingCapture  = MA_TRUE;
-    } else {
-        pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback;
-        pDevice->opensl.isDrainingPlayback = MA_TRUE;
-    }
-
-    for (;;) {
-        SLAndroidSimpleBufferQueueState state;
-
-        MA_OPENSL_BUFFERQUEUE(pBufferQueue)->GetState(pBufferQueue, &state);
-        if (state.count == 0) {
-            break;
-        }
-
-        ma_sleep(10);
-    }
-
-    if (pDevice->type == ma_device_type_capture) {
-        pDevice->opensl.isDrainingCapture  = MA_FALSE;
-    } else {
-        pDevice->opensl.isDrainingPlayback = MA_FALSE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__opensl(ma_device* pDevice)
-{
-    SLresult resultSL;
-    ma_stop_proc onStop;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before stopping/uninitializing the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_device_drain__opensl(pDevice, ma_device_type_capture);
-
-        resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal capture device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_drain__opensl(pDevice, ma_device_type_playback);
-
-        resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal playback device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback);
-    }
-
-    /* Make sure the client is aware that the device has stopped. There may be an OpenSL|ES callback for this, but I haven't found it. */
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__opensl(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_opensl);
-    (void)pContext;
-
-    /* Uninit global data. */
-    ma_spinlock_lock(&g_maOpenSLSpinlock);
-    {
-        MA_ASSERT(g_maOpenSLInitCounter > 0);   /* If you've triggered this, it means you have ma_context_init/uninit mismatch. Each successful call to ma_context_init() must be matched up with a call to ma_context_uninit(). */
-
-        g_maOpenSLInitCounter -= 1;
-        if (g_maOpenSLInitCounter == 0) {
-            (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
-        }
-    }
-    ma_spinlock_unlock(&g_maOpenSLSpinlock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_dlsym_SLInterfaceID__opensl(ma_context* pContext, const char* pName, ma_handle* pHandle)
-{
-    /* We need to return an error if the symbol cannot be found. This is important because there have been reports that some symbols do not exist. */
-    ma_handle* p = (ma_handle*)ma_dlsym(pContext, pContext->opensl.libOpenSLES, pName);
-    if (p == NULL) {
-        ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Cannot find symbol %s", pName);
-        return MA_NO_BACKEND;
-    }
-
-    *pHandle = *p;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_engine_nolock__opensl(ma_context* pContext)
-{
-    g_maOpenSLInitCounter += 1;
-    if (g_maOpenSLInitCounter == 1) {
-        SLresult resultSL;
-
-        resultSL = ((ma_slCreateEngine_proc)pContext->opensl.slCreateEngine)(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            g_maOpenSLInitCounter -= 1;
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        (*g_maEngineObjectSL)->Realize(g_maEngineObjectSL, SL_BOOLEAN_FALSE);
-
-        resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_ENGINE, &g_maEngineSL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
-            g_maOpenSLInitCounter -= 1;
-            return ma_result_from_OpenSL(resultSL);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result;
-
-#if !defined(MA_NO_RUNTIME_LINKING)
-    size_t i;
-    const char* libOpenSLESNames[] = {
-        "libOpenSLES.so"
-    };
-#endif
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-#if !defined(MA_NO_RUNTIME_LINKING)
-    /*
-    Dynamically link against libOpenSLES.so. I have now had multiple reports that SL_IID_ANDROIDSIMPLEBUFFERQUEUE cannot be found. One
-    report was happening at compile time and another at runtime. To try working around this, I'm going to link to libOpenSLES at runtime
-    and extract the symbols rather than reference them directly. This should, hopefully, fix these issues as the compiler won't see any
-    references to the symbols and will hopefully skip the checks.
-    */
-    for (i = 0; i < ma_countof(libOpenSLESNames); i += 1) {
-        pContext->opensl.libOpenSLES = ma_dlopen(pContext, libOpenSLESNames[i]);
-        if (pContext->opensl.libOpenSLES != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->opensl.libOpenSLES == NULL) {
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Could not find libOpenSLES.so");
-        return MA_NO_BACKEND;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ENGINE", &pContext->opensl.SL_IID_ENGINE);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_AUDIOIODEVICECAPABILITIES", &pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDSIMPLEBUFFERQUEUE", &pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_RECORD", &pContext->opensl.SL_IID_RECORD);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_PLAY", &pContext->opensl.SL_IID_PLAY);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_OUTPUTMIX", &pContext->opensl.SL_IID_OUTPUTMIX);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDCONFIGURATION", &pContext->opensl.SL_IID_ANDROIDCONFIGURATION);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    pContext->opensl.slCreateEngine = (ma_proc)ma_dlsym(pContext, pContext->opensl.libOpenSLES, "slCreateEngine");
-    if (pContext->opensl.slCreateEngine == NULL) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Cannot find symbol slCreateEngine.");
-        return MA_NO_BACKEND;
-    }
-#else
-    pContext->opensl.SL_IID_ENGINE                    = (ma_handle)SL_IID_ENGINE;
-    pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES = (ma_handle)SL_IID_AUDIOIODEVICECAPABILITIES;
-    pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE  = (ma_handle)SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-    pContext->opensl.SL_IID_RECORD                    = (ma_handle)SL_IID_RECORD;
-    pContext->opensl.SL_IID_PLAY                      = (ma_handle)SL_IID_PLAY;
-    pContext->opensl.SL_IID_OUTPUTMIX                 = (ma_handle)SL_IID_OUTPUTMIX;
-    pContext->opensl.SL_IID_ANDROIDCONFIGURATION      = (ma_handle)SL_IID_ANDROIDCONFIGURATION;
-    pContext->opensl.slCreateEngine                   = (ma_proc)slCreateEngine;
-#endif
-
-
-    /* Initialize global data first if applicable. */
-    ma_spinlock_lock(&g_maOpenSLSpinlock);
-    {
-        result = ma_context_init_engine_nolock__opensl(pContext);
-    }
-    ma_spinlock_unlock(&g_maOpenSLSpinlock);
-
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Failed to initialize OpenSL engine.");
-        return result;
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__opensl;
-    pCallbacks->onContextUninit           = ma_context_uninit__opensl;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__opensl;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__opensl;
-    pCallbacks->onDeviceInit              = ma_device_init__opensl;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__opensl;
-    pCallbacks->onDeviceStart             = ma_device_start__opensl;
-    pCallbacks->onDeviceStop              = ma_device_stop__opensl;
-    pCallbacks->onDeviceRead              = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* OpenSL|ES */
-
-
-/******************************************************************************
-
-Web Audio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_WEBAUDIO
-#include <emscripten/emscripten.h>
-
-static ma_bool32 ma_is_capture_supported__webaudio()
-{
-    return EM_ASM_INT({
-        return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined);
-    }, 0) != 0; /* Must pass in a dummy argument for C99 compatibility. */
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
-{
-    ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount);
-}
-
-void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_playback__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
-{
-    ma_device_handle_backend_data_callback(pDevice, pFrames, NULL, (ma_uint32)frameCount);
-}
-#ifdef __cplusplus
-}
-#endif
-
-static ma_result ma_context_enumerate_devices__webaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Only supporting default devices for now. */
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* Only supporting default devices. */
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        if (ma_is_capture_supported__webaudio()) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;    /* Only supporting default devices. */
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) {
-        return MA_NO_DEVICE;
-    }
-
-    MA_ZERO_MEMORY(pDeviceInfo->id.webaudio, sizeof(pDeviceInfo->id.webaudio));
-
-    /* Only supporting default devices for now. */
-    (void)pDeviceID;
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    /* Only supporting default devices. */
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    /* Web Audio can support any number of channels and sample rates. It only supports f32 formats, however. */
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormats[0].format     = ma_format_unknown;
-    pDeviceInfo->nativeDataFormats[0].channels   = 0; /* All channels are supported. */
-    pDeviceInfo->nativeDataFormats[0].sampleRate = EM_ASM_INT({
-        try {
-            var temp = new (window.AudioContext || window.webkitAudioContext)();
-            var sampleRate = temp.sampleRate;
-            temp.close();
-            return sampleRate;
-        } catch(e) {
-            return 0;
-        }
-    }, 0);  /* Must pass in a dummy argument for C99 compatibility. */
-
-    if (pDeviceInfo->nativeDataFormats[0].sampleRate == 0) {
-        return MA_NO_DEVICE;
-    }
-
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    return MA_SUCCESS;
-}
-
-
-static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type deviceType, int deviceIndex)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    EM_ASM({
-        var device = miniaudio.get_device_by_index($0);
-
-        /* Make sure all nodes are disconnected and marked for collection. */
-        if (device.scriptNode !== undefined) {
-            device.scriptNode.onaudioprocess = function(e) {};  /* We want to reset the callback to ensure it doesn't get called after AudioContext.close() has returned. Shouldn't happen since we're disconnecting, but just to be safe... */
-            device.scriptNode.disconnect();
-            device.scriptNode = undefined;
-        }
-        if (device.streamNode !== undefined) {
-            device.streamNode.disconnect();
-            device.streamNode = undefined;
-        }
-
-        /*
-        Stop the device. I think there is a chance the callback could get fired after calling this, hence why we want
-        to clear the callback before closing.
-        */
-        device.webaudio.close();
-        device.webaudio = undefined;
-
-        /* Can't forget to free the intermediary buffer. This is the buffer that's shared between JavaScript and C. */
-        if (device.intermediaryBuffer !== undefined) {
-            Module._free(device.intermediaryBuffer);
-            device.intermediaryBuffer = undefined;
-            device.intermediaryBufferView = undefined;
-            device.intermediaryBufferSizeInBytes = undefined;
-        }
-
-        /* Make sure the device is untracked so the slot can be reused later. */
-        miniaudio.untrack_device_by_index($0);
-    }, deviceIndex, deviceType);
-}
-
-static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_playback, pDevice->webaudio.indexPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /*
-    There have been reports of the default buffer size being too small on some browsers. There have been reports of the default buffer
-    size being too small on some browsers. If we're using default buffer size, we'll make sure the period size is a big biffer than our
-    standard defaults.
-    */
-    ma_uint32 periodSizeInFrames;
-
-    if (pDescriptor->periodSizeInFrames == 0) {
-        if (pDescriptor->periodSizeInMilliseconds == 0) {
-            if (performanceProfile == ma_performance_profile_low_latency) {
-                periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(33, nativeSampleRate);  /* 1 frame @ 30 FPS */
-            } else {
-                periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(333, nativeSampleRate);
-            }
-        } else {
-            periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate);
-        }
-    } else {
-        periodSizeInFrames = pDescriptor->periodSizeInFrames;
-    }
-
-    /* The size of the buffer must be a power of 2 and between 256 and 16384. */
-    if (periodSizeInFrames < 256) {
-        periodSizeInFrames = 256;
-    } else if (periodSizeInFrames > 16384) {
-        periodSizeInFrames = 16384;
-    } else {
-        periodSizeInFrames = ma_next_power_of_2(periodSizeInFrames);
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    int deviceIndex;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 periodSizeInFrames;
-
-    MA_ASSERT(pDevice    != NULL);
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-
-    if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) {
-        return MA_NO_DEVICE;
-    }
-
-    /* We're going to calculate some stuff in C just to simplify the JS code. */
-    channels           = (pDescriptor->channels   > 0) ? pDescriptor->channels   : MA_DEFAULT_CHANNELS;
-    sampleRate         = (pDescriptor->sampleRate > 0) ? pDescriptor->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-    periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__webaudio(pDescriptor, sampleRate, pConfig->performanceProfile);
-
-
-    /* We create the device on the JavaScript side and reference it using an index. We use this to make it possible to reference the device between JavaScript and C. */
-    deviceIndex = EM_ASM_INT({
-        var channels   = $0;
-        var sampleRate = $1;
-        var bufferSize = $2;    /* In PCM frames. */
-        var isCapture  = $3;
-        var pDevice    = $4;
-
-        if (typeof(miniaudio) === 'undefined') {
-            return -1;  /* Context not initialized. */
-        }
-
-        var device = {};
-
-        /* The AudioContext must be created in a suspended state. */
-        device.webaudio = new (window.AudioContext || window.webkitAudioContext)({sampleRate:sampleRate});
-        device.webaudio.suspend();
-        device.state = 1; /* MA_STATE_STOPPED */
-
-        /*
-        We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. Because it's passed between
-        JavaScript and C it needs to be allocated and freed using Module._malloc() and Module._free().
-        */
-        device.intermediaryBufferSizeInBytes = channels * bufferSize * 4;
-        device.intermediaryBuffer = Module._malloc(device.intermediaryBufferSizeInBytes);
-        device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-
-        /*
-        Both playback and capture devices use a ScriptProcessorNode for performing per-sample operations.
-
-        ScriptProcessorNode is actually deprecated so this is likely to be temporary. The way this works for playback is very simple. You just set a callback
-        that's periodically fired, just like a normal audio callback function. But apparently this design is "flawed" and is now deprecated in favour of
-        something called AudioWorklets which _forces_ you to load a _separate_ .js file at run time... nice... Hopefully ScriptProcessorNode will continue to
-        work for years to come, but this may need to change to use AudioSourceBufferNode instead, which I think is what Emscripten uses for it's built-in SDL
-        implementation. I'll be avoiding that insane AudioWorklet API like the plague...
-
-        For capture it is a bit unintuitive. We use the ScriptProccessorNode _only_ to get the raw PCM data. It is connected to an AudioContext just like the
-        playback case, however we just output silence to the AudioContext instead of passing any real data. It would make more sense to me to use the
-        MediaRecorder API, but unfortunately you need to specify a MIME time (Opus, Vorbis, etc.) for the binary blob that's returned to the client, but I've
-        been unable to figure out how to get this as raw PCM. The closest I can think is to use the MIME type for WAV files and just parse it, but I don't know
-        how well this would work. Although ScriptProccessorNode is deprecated, in practice it seems to have pretty good browser support so I'm leaving it like
-        this for now. If anyone knows how I could get raw PCM data using the MediaRecorder API please let me know!
-        */
-        device.scriptNode = device.webaudio.createScriptProcessor(bufferSize, channels, channels);
-
-        if (isCapture) {
-            device.scriptNode.onaudioprocess = function(e) {
-                if (device.intermediaryBuffer === undefined) {
-                    return; /* This means the device has been uninitialized. */
-                }
-
-                if(device.intermediaryBufferView.length == 0) {
-                    /* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
-                    device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-                }
-
-                /* Make sure silence it output to the AudioContext destination. Not doing this will cause sound to come out of the speakers! */
-                for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                    e.outputBuffer.getChannelData(iChannel).fill(0.0);
-                }
-
-                /* There are some situations where we may want to send silence to the client. */
-                var sendSilence = false;
-                if (device.streamNode === undefined) {
-                    sendSilence = true;
-                }
-
-                /* Sanity check. This will never happen, right? */
-                if (e.inputBuffer.numberOfChannels != channels) {
-                    console.log("Capture: Channel count mismatch. " + e.inputBufer.numberOfChannels + " != " + channels + ". Sending silence.");
-                    sendSilence = true;
-                }
-
-                /* This looped design guards against the situation where e.inputBuffer is a different size to the original buffer size. Should never happen in practice. */
-                var totalFramesProcessed = 0;
-                while (totalFramesProcessed < e.inputBuffer.length) {
-                    var framesRemaining = e.inputBuffer.length - totalFramesProcessed;
-                    var framesToProcess = framesRemaining;
-                    if (framesToProcess > (device.intermediaryBufferSizeInBytes/channels/4)) {
-                        framesToProcess = (device.intermediaryBufferSizeInBytes/channels/4);
-                    }
-
-                    /* We need to do the reverse of the playback case. We need to interleave the input data and copy it into the intermediary buffer. Then we send it to the client. */
-                    if (sendSilence) {
-                        device.intermediaryBufferView.fill(0.0);
-                    } else {
-                        for (var iFrame = 0; iFrame < framesToProcess; ++iFrame) {
-                            for (var iChannel = 0; iChannel < e.inputBuffer.numberOfChannels; ++iChannel) {
-                                device.intermediaryBufferView[iFrame*channels + iChannel] = e.inputBuffer.getChannelData(iChannel)[totalFramesProcessed + iFrame];
-                            }
-                        }
-                    }
-
-                    /* Send data to the client from our intermediary buffer. */
-                    ccall("ma_device_process_pcm_frames_capture__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
-
-                    totalFramesProcessed += framesToProcess;
-                }
-            };
-
-            navigator.mediaDevices.getUserMedia({audio:true, video:false})
-                .then(function(stream) {
-                    device.streamNode = device.webaudio.createMediaStreamSource(stream);
-                    device.streamNode.connect(device.scriptNode);
-                    device.scriptNode.connect(device.webaudio.destination);
-                })
-                .catch(function(error) {
-                    /* I think this should output silence... */
-                    device.scriptNode.connect(device.webaudio.destination);
-                });
-        } else {
-            device.scriptNode.onaudioprocess = function(e) {
-                if (device.intermediaryBuffer === undefined) {
-                    return; /* This means the device has been uninitialized. */
-                }
-
-                if(device.intermediaryBufferView.length == 0) {
-                    /* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
-                    device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-                }
-
-                var outputSilence = false;
-
-                /* Sanity check. This will never happen, right? */
-                if (e.outputBuffer.numberOfChannels != channels) {
-                    console.log("Playback: Channel count mismatch. " + e.outputBufer.numberOfChannels + " != " + channels + ". Outputting silence.");
-                    outputSilence = true;
-                    return;
-                }
-
-                /* This looped design guards against the situation where e.outputBuffer is a different size to the original buffer size. Should never happen in practice. */
-                var totalFramesProcessed = 0;
-                while (totalFramesProcessed < e.outputBuffer.length) {
-                    var framesRemaining = e.outputBuffer.length - totalFramesProcessed;
-                    var framesToProcess = framesRemaining;
-                    if (framesToProcess > (device.intermediaryBufferSizeInBytes/channels/4)) {
-                        framesToProcess = (device.intermediaryBufferSizeInBytes/channels/4);
-                    }
-
-                    /* Read data from the client into our intermediary buffer. */
-                    ccall("ma_device_process_pcm_frames_playback__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
-
-                    /* At this point we'll have data in our intermediary buffer which we now need to deinterleave and copy over to the output buffers. */
-                    if (outputSilence) {
-                        for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                            e.outputBuffer.getChannelData(iChannel).fill(0.0);
-                        }
-                    } else {
-                        for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                            for (var iFrame = 0; iFrame < framesToProcess; ++iFrame) {
-                                e.outputBuffer.getChannelData(iChannel)[totalFramesProcessed + iFrame] = device.intermediaryBufferView[iFrame*channels + iChannel];
-                            }
-                        }
-                    }
-
-                    totalFramesProcessed += framesToProcess;
-                }
-            };
-
-            device.scriptNode.connect(device.webaudio.destination);
-        }
-
-        return miniaudio.track_device(device);
-    }, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice);
-
-    if (deviceIndex < 0) {
-        return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->webaudio.indexCapture  = deviceIndex;
-    } else {
-        pDevice->webaudio.indexPlayback = deviceIndex;
-    }
-
-    pDescriptor->format              = ma_format_f32;
-    pDescriptor->channels            = channels;
-    ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDescriptor->channels, pDescriptor->channelMap);
-    pDescriptor->sampleRate          = EM_ASM_INT({ return miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
-    pDescriptor->periodSizeInFrames  = periodSizeInFrames;
-    pDescriptor->periodCount         = 1;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with Web Audio. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__webaudio(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__webaudio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.resume();
-            device.state = 2; /* MA_STATE_STARTED */
-        }, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.resume();
-            device.state = 2; /* MA_STATE_STARTED */
-        }, pDevice->webaudio.indexPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the WebAudio API documentation for AudioContext.suspend():
-
-        Suspends the progression of AudioContext's currentTime, allows any current context processing blocks that are already processed to be played to the
-        destination, and then allows the system to release its claim on audio hardware.
-
-    I read this to mean that "any current context processing blocks" are processed by suspend() - i.e. They they are drained. We therefore shouldn't need to
-    do any kind of explicit draining.
-    */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.suspend();
-            device.state = 1; /* MA_STATE_STOPPED */
-        }, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.suspend();
-            device.state = 1; /* MA_STATE_STOPPED */
-        }, pDevice->webaudio.indexPlayback);
-    }
-
-    ma_stop_proc onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__webaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_webaudio);
-
-    /* Nothing needs to be done here. */
-    (void)pContext;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    int resultFromJS;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig; /* Unused. */
-
-    /* Here is where our global JavaScript object is initialized. */
-    resultFromJS = EM_ASM_INT({
-        if ((window.AudioContext || window.webkitAudioContext) === undefined) {
-            return 0;   /* Web Audio not supported. */
-        }
-
-        if (typeof(miniaudio) === 'undefined') {
-            miniaudio = {};
-            miniaudio.devices = [];   /* Device cache for mapping devices to indexes for JavaScript/C interop. */
-
-            miniaudio.track_device = function(device) {
-                /* Try inserting into a free slot first. */
-                for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) {
-                    if (miniaudio.devices[iDevice] == null) {
-                        miniaudio.devices[iDevice] = device;
-                        return iDevice;
-                    }
-                }
-
-                /* Getting here means there is no empty slots in the array so we just push to the end. */
-                miniaudio.devices.push(device);
-                return miniaudio.devices.length - 1;
-            };
-
-            miniaudio.untrack_device_by_index = function(deviceIndex) {
-                /* We just set the device's slot to null. The slot will get reused in the next call to ma_track_device. */
-                miniaudio.devices[deviceIndex] = null;
-
-                /* Trim the array if possible. */
-                while (miniaudio.devices.length > 0) {
-                    if (miniaudio.devices[miniaudio.devices.length-1] == null) {
-                        miniaudio.devices.pop();
-                    } else {
-                        break;
-                    }
-                }
-            };
-
-            miniaudio.untrack_device = function(device) {
-                for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) {
-                    if (miniaudio.devices[iDevice] == device) {
-                        return miniaudio.untrack_device_by_index(iDevice);
-                    }
-                }
-            };
-
-            miniaudio.get_device_by_index = function(deviceIndex) {
-                return miniaudio.devices[deviceIndex];
-            };
-
-            miniaudio.unlock_event_types = (function(){
-                return ['touchstart', 'touchend', 'click'];
-            })();
-
-            miniaudio.unlock = function() {
-                for(var i = 0; i < miniaudio.devices.length; ++i) {
-                    var device = miniaudio.devices[i];
-                    if (device != null && device.webaudio != null && device.state === 2 /* MA_STATE_STARTED */) {
-                        device.webaudio.resume();
-                    }
-                }
-                miniaudio.unlock_event_types.map(function(event_type) {
-                    document.removeEventListener(event_type, miniaudio.unlock, true);
-                });
-            };
-
-            miniaudio.unlock_event_types.map(function(event_type) {
-                document.addEventListener(event_type, miniaudio.unlock, true);
-            });
-        }
-
-        return 1;
-    }, 0);  /* Must pass in a dummy argument for C99 compatibility. */
-
-    if (resultFromJS != 1) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__webaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__webaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__webaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__webaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__webaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__webaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__webaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__webaudio;
-    pCallbacks->onDeviceRead              = NULL;   /* Not needed because WebAudio is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not needed because WebAudio is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not needed because WebAudio is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* Web Audio */
-
-
-
-static ma_bool32 ma__is_channel_map_valid(const ma_channel* channelMap, ma_uint32 channels)
-{
-    /* A blank channel map should be allowed, in which case it should use an appropriate default which will depend on context. */
-    if (channelMap[0] != MA_CHANNEL_NONE) {
-        ma_uint32 iChannel;
-
-        if (channels == 0 || channels > MA_MAX_CHANNELS) {
-            return MA_FALSE;   /* Channel count out of range. */
-        }
-
-        /* A channel cannot be present in the channel map more than once. */
-        for (iChannel = 0; iChannel < channels; ++iChannel) {
-            ma_uint32 jChannel;
-            for (jChannel = iChannel + 1; jChannel < channels; ++jChannel) {
-                if (channelMap[iChannel] == channelMap[jChannel]) {
-                    return MA_FALSE;
-                }
-            }
-        }
-    }
-
-    return MA_TRUE;
-}
-
-
-static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex) {
-        if (pDevice->capture.format == ma_format_unknown) {
-            pDevice->capture.format = pDevice->capture.internalFormat;
-        }
-        if (pDevice->capture.channels == 0) {
-            pDevice->capture.channels = pDevice->capture.internalChannels;
-        }
-        if (pDevice->capture.channelMap[0] == MA_CHANNEL_NONE) {
-            MA_ASSERT(pDevice->capture.channels <= MA_MAX_CHANNELS);
-            if (pDevice->capture.internalChannels == pDevice->capture.channels) {
-                ma_channel_map_copy(pDevice->capture.channelMap, pDevice->capture.internalChannelMap, pDevice->capture.channels);
-            } else {
-                if (pDevice->capture.channelMixMode == ma_channel_mix_mode_simple) {
-                    ma_channel_map_init_blank(pDevice->capture.channels, pDevice->capture.channelMap);
-                } else {
-                    ma_get_standard_channel_map(ma_standard_channel_map_default, pDevice->capture.channels, pDevice->capture.channelMap);
-                }
-            }
-        }
-    }
-
-    if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
-        if (pDevice->playback.format == ma_format_unknown) {
-            pDevice->playback.format = pDevice->playback.internalFormat;
-        }
-        if (pDevice->playback.channels == 0) {
-            pDevice->playback.channels = pDevice->playback.internalChannels;
-        }
-        if (pDevice->playback.channelMap[0] == MA_CHANNEL_NONE) {
-            MA_ASSERT(pDevice->playback.channels <= MA_MAX_CHANNELS);
-            if (pDevice->playback.internalChannels == pDevice->playback.channels) {
-                ma_channel_map_copy(pDevice->playback.channelMap, pDevice->playback.internalChannelMap, pDevice->playback.channels);
-            } else {
-                if (pDevice->playback.channelMixMode == ma_channel_mix_mode_simple) {
-                    ma_channel_map_init_blank(pDevice->playback.channels, pDevice->playback.channelMap);
-                } else {
-                    ma_get_standard_channel_map(ma_standard_channel_map_default, pDevice->playback.channels, pDevice->playback.channelMap);
-                }
-            }
-        }
-    }
-
-    if (pDevice->sampleRate == 0) {
-        if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex) {
-            pDevice->sampleRate = pDevice->capture.internalSampleRate;
-        } else {
-            pDevice->sampleRate = pDevice->playback.internalSampleRate;
-        }
-    }
-
-    /* Data converters. */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) {
-        /* Converting from internal device format to client format. */
-        ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
-        converterConfig.formatIn                   = pDevice->capture.internalFormat;
-        converterConfig.channelsIn                 = pDevice->capture.internalChannels;
-        converterConfig.sampleRateIn               = pDevice->capture.internalSampleRate;
-        ma_channel_map_copy(converterConfig.channelMapIn, pDevice->capture.internalChannelMap, ma_min(pDevice->capture.internalChannels, MA_MAX_CHANNELS));
-        converterConfig.formatOut                  = pDevice->capture.format;
-        converterConfig.channelsOut                = pDevice->capture.channels;
-        converterConfig.sampleRateOut              = pDevice->sampleRate;
-        ma_channel_map_copy(converterConfig.channelMapOut, pDevice->capture.channelMap, ma_min(pDevice->capture.channels, MA_MAX_CHANNELS));
-        converterConfig.channelMixMode             = pDevice->capture.channelMixMode;
-        converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;
-        converterConfig.resampling.algorithm       = pDevice->resampling.algorithm;
-        converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
-        converterConfig.resampling.speex.quality   = pDevice->resampling.speex.quality;
-
-        result = ma_data_converter_init(&converterConfig, &pDevice->capture.converter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
-        /* Converting from client format to device format. */
-        ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
-        converterConfig.formatIn                   = pDevice->playback.format;
-        converterConfig.channelsIn                 = pDevice->playback.channels;
-        converterConfig.sampleRateIn               = pDevice->sampleRate;
-        ma_channel_map_copy(converterConfig.channelMapIn, pDevice->playback.channelMap, ma_min(pDevice->playback.channels, MA_MAX_CHANNELS));
-        converterConfig.formatOut                  = pDevice->playback.internalFormat;
-        converterConfig.channelsOut                = pDevice->playback.internalChannels;
-        converterConfig.sampleRateOut              = pDevice->playback.internalSampleRate;
-        ma_channel_map_copy(converterConfig.channelMapOut, pDevice->playback.internalChannelMap, ma_min(pDevice->playback.internalChannels, MA_MAX_CHANNELS));
-        converterConfig.channelMixMode             = pDevice->playback.channelMixMode;
-        converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;
-        converterConfig.resampling.algorithm       = pDevice->resampling.algorithm;
-        converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
-        converterConfig.resampling.speex.quality   = pDevice->resampling.speex.quality;
-
-        result = ma_data_converter_init(&converterConfig, &pDevice->playback.converter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
-{
-    ma_device* pDevice = (ma_device*)pData;
-    MA_ASSERT(pDevice != NULL);
-
-#ifdef MA_WIN32
-    ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE);
-#endif
-
-    /*
-    When the device is being initialized it's initial state is set to MA_STATE_UNINITIALIZED. Before returning from
-    ma_device_init(), the state needs to be set to something valid. In miniaudio the device's default state immediately
-    after initialization is stopped, so therefore we need to mark the device as such. miniaudio will wait on the worker
-    thread to signal an event to know when the worker thread is ready for action.
-    */
-    ma_device__set_state(pDevice, MA_STATE_STOPPED);
-    ma_event_signal(&pDevice->stopEvent);
-
-    for (;;) {  /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
-        ma_stop_proc onStop;
-
-        /* We wait on an event to know when something has requested that the device be started and the main loop entered. */
-        ma_event_wait(&pDevice->wakeupEvent);
-
-        /* Default result code. */
-        pDevice->workResult = MA_SUCCESS;
-
-        /* If the reason for the wake up is that we are terminating, just break from the loop. */
-        if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-            break;
-        }
-
-        /*
-        Getting to this point means the device is wanting to get started. The function that has requested that the device
-        be started will be waiting on an event (pDevice->startEvent) which means we need to make sure we signal the event
-        in both the success and error case. It's important that the state of the device is set _before_ signaling the event.
-        */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STARTING);
-
-        /* If the device has a start callback, start it now. */
-        if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
-            ma_result result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
-            if (result != MA_SUCCESS) {
-                pDevice->workResult = result;   /* Failed to start the device. */
-            }
-        }
-
-        /* Make sure the state is set appropriately. */
-        ma_device__set_state(pDevice, MA_STATE_STARTED);
-        ma_event_signal(&pDevice->startEvent);
-
-        if (pDevice->pContext->callbacks.onDeviceDataLoop != NULL) {
-            pDevice->pContext->callbacks.onDeviceDataLoop(pDevice);
-        } else {
-            /* The backend is not using a custom main loop implementation, so now fall back to the blocking read-write implementation. */
-            ma_device_audio_thread__default_read_write(pDevice);
-        }
-
-        /*
-        Getting here means we have broken from the main loop which happens the application has requested that device be stopped. Note that this
-        may have actually already happened above if the device was lost and miniaudio has attempted to re-initialize the device. In this case we
-        don't want to be doing this a second time.
-        */
-        if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
-            if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
-                pDevice->pContext->callbacks.onDeviceStop(pDevice);
-            }
-        }
-
-        /* After the device has stopped, make sure an event is posted. */
-        onStop = pDevice->onStop;
-        if (onStop) {
-            onStop(pDevice);
-        }
-
-        /*
-        A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. Note that
-        it's possible that the device has been uninitialized which means we need to _not_ change the status to stopped. We cannot go from an
-        uninitialized state to stopped state.
-        */
-        if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-            ma_event_signal(&pDevice->stopEvent);
-        }
-    }
-
-    /* Make sure we aren't continuously waiting on a stop event. */
-    ma_event_signal(&pDevice->stopEvent);  /* <-- Is this still needed? */
-
-#ifdef MA_WIN32
-    ma_CoUninitialize(pDevice->pContext);
-#endif
-
-    return (ma_thread_result)0;
-}
-
-
-/* Helper for determining whether or not the given device is initialized. */
-static ma_bool32 ma_device__is_initialized(ma_device* pDevice)
-{
-    if (pDevice == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED;
-}
-
-
-#ifdef MA_WIN32
-static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
-{
-    ma_CoUninitialize(pContext);
-    ma_dlclose(pContext, pContext->win32.hUser32DLL);
-    ma_dlclose(pContext, pContext->win32.hOle32DLL);
-    ma_dlclose(pContext, pContext->win32.hAdvapi32DLL);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
-{
-#ifdef MA_WIN32_DESKTOP
-    /* Ole32.dll */
-    pContext->win32.hOle32DLL = ma_dlopen(pContext, "ole32.dll");
-    if (pContext->win32.hOle32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.CoInitializeEx   = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoInitializeEx");
-    pContext->win32.CoUninitialize   = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoUninitialize");
-    pContext->win32.CoCreateInstance = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoCreateInstance");
-    pContext->win32.CoTaskMemFree    = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoTaskMemFree");
-    pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "PropVariantClear");
-    pContext->win32.StringFromGUID2  = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "StringFromGUID2");
-
-
-    /* User32.dll */
-    pContext->win32.hUser32DLL = ma_dlopen(pContext, "user32.dll");
-    if (pContext->win32.hUser32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.GetForegroundWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetForegroundWindow");
-    pContext->win32.GetDesktopWindow    = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetDesktopWindow");
-
-
-    /* Advapi32.dll */
-    pContext->win32.hAdvapi32DLL = ma_dlopen(pContext, "advapi32.dll");
-    if (pContext->win32.hAdvapi32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.RegOpenKeyExA    = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
-    pContext->win32.RegCloseKey      = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegCloseKey");
-    pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
-#endif
-
-    ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE);
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_context_uninit_backend_apis__nix(ma_context* pContext)
-{
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
-    ma_dlclose(pContext, pContext->posix.pthreadSO);
-#else
-    (void)pContext;
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_backend_apis__nix(ma_context* pContext)
-{
-    /* pthread */
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
-    const char* libpthreadFileNames[] = {
-        "libpthread.so",
-        "libpthread.so.0",
-        "libpthread.dylib"
-    };
-    size_t i;
-
-    for (i = 0; i < sizeof(libpthreadFileNames) / sizeof(libpthreadFileNames[0]); ++i) {
-        pContext->posix.pthreadSO = ma_dlopen(pContext, libpthreadFileNames[i]);
-        if (pContext->posix.pthreadSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->posix.pthreadSO == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->posix.pthread_create              = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_create");
-    pContext->posix.pthread_join                = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_join");
-    pContext->posix.pthread_mutex_init          = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_init");
-    pContext->posix.pthread_mutex_destroy       = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_destroy");
-    pContext->posix.pthread_mutex_lock          = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_lock");
-    pContext->posix.pthread_mutex_unlock        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_unlock");
-    pContext->posix.pthread_cond_init           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_init");
-    pContext->posix.pthread_cond_destroy        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_destroy");
-    pContext->posix.pthread_cond_wait           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_wait");
-    pContext->posix.pthread_cond_signal         = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_signal");
-    pContext->posix.pthread_attr_init           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_init");
-    pContext->posix.pthread_attr_destroy        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_destroy");
-    pContext->posix.pthread_attr_setschedpolicy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedpolicy");
-    pContext->posix.pthread_attr_getschedparam  = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_getschedparam");
-    pContext->posix.pthread_attr_setschedparam  = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedparam");
-#else
-    pContext->posix.pthread_create              = (ma_proc)pthread_create;
-    pContext->posix.pthread_join                = (ma_proc)pthread_join;
-    pContext->posix.pthread_mutex_init          = (ma_proc)pthread_mutex_init;
-    pContext->posix.pthread_mutex_destroy       = (ma_proc)pthread_mutex_destroy;
-    pContext->posix.pthread_mutex_lock          = (ma_proc)pthread_mutex_lock;
-    pContext->posix.pthread_mutex_unlock        = (ma_proc)pthread_mutex_unlock;
-    pContext->posix.pthread_cond_init           = (ma_proc)pthread_cond_init;
-    pContext->posix.pthread_cond_destroy        = (ma_proc)pthread_cond_destroy;
-    pContext->posix.pthread_cond_wait           = (ma_proc)pthread_cond_wait;
-    pContext->posix.pthread_cond_signal         = (ma_proc)pthread_cond_signal;
-    pContext->posix.pthread_attr_init           = (ma_proc)pthread_attr_init;
-    pContext->posix.pthread_attr_destroy        = (ma_proc)pthread_attr_destroy;
-#if !defined(__EMSCRIPTEN__)
-    pContext->posix.pthread_attr_setschedpolicy = (ma_proc)pthread_attr_setschedpolicy;
-    pContext->posix.pthread_attr_getschedparam  = (ma_proc)pthread_attr_getschedparam;
-    pContext->posix.pthread_attr_setschedparam  = (ma_proc)pthread_attr_setschedparam;
-#endif
-#endif
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_context_init_backend_apis(ma_context* pContext)
-{
-    ma_result result;
-#ifdef MA_WIN32
-    result = ma_context_init_backend_apis__win32(pContext);
-#else
-    result = ma_context_init_backend_apis__nix(pContext);
-#endif
-
-    return result;
-}
-
-static ma_result ma_context_uninit_backend_apis(ma_context* pContext)
-{
-    ma_result result;
-#ifdef MA_WIN32
-    result = ma_context_uninit_backend_apis__win32(pContext);
-#else
-    result = ma_context_uninit_backend_apis__nix(pContext);
-#endif
-
-    return result;
-}
-
-
-static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) {
-        if (pContext->callbacks.onDeviceDataLoop == NULL) {
-            return MA_TRUE;
-        } else {
-            return MA_FALSE;
-        }
-    } else {
-        return MA_FALSE;
-    }
-}
-
-
-MA_API ma_context_config ma_context_config_init()
-{
-    ma_context_config config;
-    MA_ZERO_OBJECT(&config);
-
-    return config;
-}
-
-MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext)
-{
-    ma_result result;
-    ma_context_config defaultConfig;
-    ma_backend defaultBackends[ma_backend_null+1];
-    ma_uint32 iBackend;
-    ma_backend* pBackendsToIterate;
-    ma_uint32 backendsToIterateCount;
-
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pContext);
-
-    /* Always make sure the config is set first to ensure properties are available as soon as possible. */
-    if (pConfig == NULL) {
-        defaultConfig = ma_context_config_init();
-        pConfig = &defaultConfig;
-    }
-
-    pContext->logCallback     = pConfig->logCallback;
-    pContext->threadPriority  = pConfig->threadPriority;
-    pContext->threadStackSize = pConfig->threadStackSize;
-    pContext->pUserData       = pConfig->pUserData;
-
-    result = ma_allocation_callbacks_init_copy(&pContext->allocationCallbacks, &pConfig->allocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Backend APIs need to be initialized first. This is where external libraries will be loaded and linked. */
-    result = ma_context_init_backend_apis(pContext);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) {
-        defaultBackends[iBackend] = (ma_backend)iBackend;
-    }
-
-    pBackendsToIterate = (ma_backend*)backends;
-    backendsToIterateCount = backendCount;
-    if (pBackendsToIterate == NULL) {
-        pBackendsToIterate = (ma_backend*)defaultBackends;
-        backendsToIterateCount = ma_countof(defaultBackends);
-    }
-
-    MA_ASSERT(pBackendsToIterate != NULL);
-
-    for (iBackend = 0; iBackend < backendsToIterateCount; iBackend += 1) {
-        ma_backend backend = pBackendsToIterate[iBackend];
-
-        /* Make sure all callbacks are reset so we don't accidentally drag in any from previously failed initialization attempts. */
-        MA_ZERO_OBJECT(&pContext->callbacks);
-
-        /* These backends are using the new callback system. */
-        switch (backend) {
-        #ifdef MA_HAS_WASAPI
-            case ma_backend_wasapi:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__wasapi;
-            } break;
-        #endif
-        #ifdef MA_HAS_DSOUND
-            case ma_backend_dsound:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__dsound;
-            } break;
-        #endif
-        #ifdef MA_HAS_WINMM
-            case ma_backend_winmm:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__winmm;
-            } break;
-        #endif
-        #ifdef MA_HAS_COREAUDIO
-            case ma_backend_coreaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__coreaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_SNDIO
-            case ma_backend_sndio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__sndio;
-            } break;
-        #endif
-        #ifdef MA_HAS_AUDIO4
-            case ma_backend_audio4:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__audio4;
-            } break;
-        #endif
-        #ifdef MA_HAS_OSS
-            case ma_backend_oss:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__oss;
-            } break;
-        #endif
-        #ifdef MA_HAS_PULSEAUDIO
-            case ma_backend_pulseaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__pulse;
-            } break;
-        #endif
-        #ifdef MA_HAS_ALSA
-            case ma_backend_alsa:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__alsa;
-            } break;
-        #endif
-        #ifdef MA_HAS_JACK
-            case ma_backend_jack:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__jack;
-            } break;
-        #endif
-        #ifdef MA_HAS_AAUDIO
-            case ma_backend_aaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__aaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_OPENSL
-            case ma_backend_opensl:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__opensl;
-            } break;
-        #endif
-        #ifdef MA_HAS_WEBAUDIO
-            case ma_backend_webaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__webaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_CUSTOM
-            case ma_backend_custom:
-            {
-                /* Slightly different logic for custom backends. Custom backends can optionally set all of their callbacks in the config. */
-                pContext->callbacks = pConfig->custom;
-            } break;
-        #endif
-        #ifdef MA_HAS_NULL
-            case ma_backend_null:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__null;
-            } break;
-        #endif
-
-            default: break;
-        }
-
-        if (pContext->callbacks.onContextInit != NULL) {
-            ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_VERBOSE, "Attempting to initialize %s backend...", ma_get_backend_name(backend));
-            result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks);
-        } else {
-            result = MA_NO_BACKEND;
-        }
-
-        /* If this iteration was successful, return. */
-        if (result == MA_SUCCESS) {
-            result = ma_mutex_init(&pContext->deviceEnumLock);
-            if (result != MA_SUCCESS) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. ma_context_get_devices() is not thread safe.", result);
-            }
-
-            result = ma_mutex_init(&pContext->deviceInfoLock);
-            if (result != MA_SUCCESS) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. ma_context_get_device_info() is not thread safe.", result);
-            }
-
-            #ifdef MA_DEBUG_OUTPUT
-            {
-                printf("[miniaudio] Endian:  %s\n", ma_is_little_endian() ? "LE" : "BE");
-                printf("[miniaudio] SSE2:    %s\n", ma_has_sse2()    ? "YES" : "NO");
-                printf("[miniaudio] AVX2:    %s\n", ma_has_avx2()    ? "YES" : "NO");
-                printf("[miniaudio] AVX512F: %s\n", ma_has_avx512f() ? "YES" : "NO");
-                printf("[miniaudio] NEON:    %s\n", ma_has_neon()    ? "YES" : "NO");
-            }
-            #endif
-
-            pContext->backend = backend;
-            return result;
-        } else {
-            ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_VERBOSE, "Failed to initialize %s backend.", ma_get_backend_name(backend));
-        }
-    }
-
-    /* If we get here it means an error occurred. */
-    MA_ZERO_OBJECT(pContext);  /* Safety. */
-    return MA_NO_BACKEND;
-}
-
-MA_API ma_result ma_context_uninit(ma_context* pContext)
-{
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextUninit != NULL) {
-        pContext->callbacks.onContextUninit(pContext);
-    }
-
-    ma_mutex_uninit(&pContext->deviceEnumLock);
-    ma_mutex_uninit(&pContext->deviceInfoLock);
-    ma__free_from_callbacks(pContext->pDeviceInfos, &pContext->allocationCallbacks);
-    ma_context_uninit_backend_apis(pContext);
-
-    return MA_SUCCESS;
-}
-
-MA_API size_t ma_context_sizeof()
-{
-    return sizeof(ma_context);
-}
-
-
-MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result;
-
-    if (pContext == NULL || callback == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextEnumerateDevices == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    ma_mutex_lock(&pContext->deviceEnumLock);
-    {
-        result = pContext->callbacks.onContextEnumerateDevices(pContext, callback, pUserData);
-    }
-    ma_mutex_unlock(&pContext->deviceEnumLock);
-
-    return result;
-}
-
-
-static ma_bool32 ma_context_get_devices__enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData)
-{
-    /*
-    We need to insert the device info into our main internal buffer. Where it goes depends on the device type. If it's a capture device
-    it's just appended to the end. If it's a playback device it's inserted just before the first capture device.
-    */
-
-    /*
-    First make sure we have room. Since the number of devices we add to the list is usually relatively small I've decided to use a
-    simple fixed size increment for buffer expansion.
-    */
-    const ma_uint32 bufferExpansionCount = 2;
-    const ma_uint32 totalDeviceInfoCount = pContext->playbackDeviceInfoCount + pContext->captureDeviceInfoCount;
-
-    if (totalDeviceInfoCount >= pContext->deviceInfoCapacity) {
-        ma_uint32 oldCapacity = pContext->deviceInfoCapacity;
-        ma_uint32 newCapacity = oldCapacity + bufferExpansionCount;
-        ma_device_info* pNewInfos = (ma_device_info*)ma__realloc_from_callbacks(pContext->pDeviceInfos, sizeof(*pContext->pDeviceInfos)*newCapacity, sizeof(*pContext->pDeviceInfos)*oldCapacity, &pContext->allocationCallbacks);
-        if (pNewInfos == NULL) {
-            return MA_FALSE;   /* Out of memory. */
-        }
-
-        pContext->pDeviceInfos = pNewInfos;
-        pContext->deviceInfoCapacity = newCapacity;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        /* Playback. Insert just before the first capture device. */
-
-        /* The first thing to do is move all of the capture devices down a slot. */
-        ma_uint32 iFirstCaptureDevice = pContext->playbackDeviceInfoCount;
-        size_t iCaptureDevice;
-        for (iCaptureDevice = totalDeviceInfoCount; iCaptureDevice > iFirstCaptureDevice; --iCaptureDevice) {
-            pContext->pDeviceInfos[iCaptureDevice] = pContext->pDeviceInfos[iCaptureDevice-1];
-        }
-
-        /* Now just insert where the first capture device was before moving it down a slot. */
-        pContext->pDeviceInfos[iFirstCaptureDevice] = *pInfo;
-        pContext->playbackDeviceInfoCount += 1;
-    } else {
-        /* Capture. Insert at the end. */
-        pContext->pDeviceInfos[totalDeviceInfoCount] = *pInfo;
-        pContext->captureDeviceInfoCount += 1;
-    }
-
-    (void)pUserData;
-    return MA_TRUE;
-}
-
-MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount)
-{
-    ma_result result;
-
-    /* Safety. */
-    if (ppPlaybackDeviceInfos != NULL) *ppPlaybackDeviceInfos = NULL;
-    if (pPlaybackDeviceCount  != NULL) *pPlaybackDeviceCount  = 0;
-    if (ppCaptureDeviceInfos  != NULL) *ppCaptureDeviceInfos  = NULL;
-    if (pCaptureDeviceCount   != NULL) *pCaptureDeviceCount   = 0;
-
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextEnumerateDevices == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* Note that we don't use ma_context_enumerate_devices() here because we want to do locking at a higher level. */
-    ma_mutex_lock(&pContext->deviceEnumLock);
-    {
-        /* Reset everything first. */
-        pContext->playbackDeviceInfoCount = 0;
-        pContext->captureDeviceInfoCount = 0;
-
-        /* Now enumerate over available devices. */
-        result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, NULL);
-        if (result == MA_SUCCESS) {
-            /* Playback devices. */
-            if (ppPlaybackDeviceInfos != NULL) {
-                *ppPlaybackDeviceInfos = pContext->pDeviceInfos;
-            }
-            if (pPlaybackDeviceCount != NULL) {
-                *pPlaybackDeviceCount = pContext->playbackDeviceInfoCount;
-            }
-
-            /* Capture devices. */
-            if (ppCaptureDeviceInfos != NULL) {
-                *ppCaptureDeviceInfos = pContext->pDeviceInfos + pContext->playbackDeviceInfoCount; /* Capture devices come after playback devices. */
-            }
-            if (pCaptureDeviceCount != NULL) {
-                *pCaptureDeviceCount = pContext->captureDeviceInfoCount;
-            }
-        }
-    }
-    ma_mutex_unlock(&pContext->deviceEnumLock);
-
-    return result;
-}
-
-MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-    ma_device_info deviceInfo;
-
-    (void)shareMode;    /* Unused. This parameter will be removed in version 0.11. */
-
-    /* NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. */
-    if (pContext == NULL || pDeviceInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* Help the backend out by copying over the device ID if we have one. */
-    if (pDeviceID != NULL) {
-        MA_COPY_MEMORY(&deviceInfo.id, pDeviceID, sizeof(*pDeviceID));
-    }
-
-    if (pContext->callbacks.onContextGetDeviceInfo == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    ma_mutex_lock(&pContext->deviceInfoLock);
-    {
-        result = pContext->callbacks.onContextGetDeviceInfo(pContext, deviceType, pDeviceID, &deviceInfo);
-    }
-    ma_mutex_unlock(&pContext->deviceInfoLock);
-
-    /*
-    If the backend is using the new device info system, do a pass to fill out the old settings for backwards compatibility. This will be removed in
-    the future when all backends have implemented the new device info system.
-    */
-    if (deviceInfo.nativeDataFormatCount > 0) {
-        ma_uint32 iNativeFormat;
-        ma_uint32 iSampleFormat;
-
-        deviceInfo.minChannels   = 0xFFFFFFFF;
-        deviceInfo.maxChannels   = 0;
-        deviceInfo.minSampleRate = 0xFFFFFFFF;
-        deviceInfo.maxSampleRate = 0;
-
-        for (iNativeFormat = 0; iNativeFormat < deviceInfo.nativeDataFormatCount; iNativeFormat += 1) {
-            /* Formats. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].format == ma_format_unknown) {
-                /* All formats are supported. */
-                deviceInfo.formats[0] = ma_format_u8;
-                deviceInfo.formats[1] = ma_format_s16;
-                deviceInfo.formats[2] = ma_format_s24;
-                deviceInfo.formats[3] = ma_format_s32;
-                deviceInfo.formats[4] = ma_format_f32;
-                deviceInfo.formatCount = 5;
-            } else {
-                /* Make sure the format isn't already in the list. If so, skip. */
-                ma_bool32 alreadyExists = MA_FALSE;
-                for (iSampleFormat = 0; iSampleFormat < deviceInfo.formatCount; iSampleFormat += 1) {
-                    if (deviceInfo.formats[iSampleFormat] == deviceInfo.nativeDataFormats[iNativeFormat].format) {
-                        alreadyExists = MA_TRUE;
-                        break;
-                    }
-                }
-
-                if (!alreadyExists) {
-                    deviceInfo.formats[deviceInfo.formatCount++] = deviceInfo.nativeDataFormats[iNativeFormat].format;
-                }
-            }
-
-            /* Channels. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].channels == 0) {
-                /* All channels supported. */
-                deviceInfo.minChannels = MA_MIN_CHANNELS;
-                deviceInfo.maxChannels = MA_MAX_CHANNELS;
-            } else {
-                if (deviceInfo.minChannels > deviceInfo.nativeDataFormats[iNativeFormat].channels) {
-                    deviceInfo.minChannels = deviceInfo.nativeDataFormats[iNativeFormat].channels;
-                }
-                if (deviceInfo.maxChannels < deviceInfo.nativeDataFormats[iNativeFormat].channels) {
-                    deviceInfo.maxChannels = deviceInfo.nativeDataFormats[iNativeFormat].channels;
-                }
-            }
-
-            /* Sample rate. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].sampleRate == 0) {
-                /* All sample rates supported. */
-                deviceInfo.minSampleRate = (ma_uint32)ma_standard_sample_rate_min;
-                deviceInfo.maxSampleRate = (ma_uint32)ma_standard_sample_rate_max;
-            } else {
-                if (deviceInfo.minSampleRate > deviceInfo.nativeDataFormats[iNativeFormat].sampleRate) {
-                    deviceInfo.minSampleRate = deviceInfo.nativeDataFormats[iNativeFormat].sampleRate;
-                }
-                if (deviceInfo.maxSampleRate < deviceInfo.nativeDataFormats[iNativeFormat].sampleRate) {
-                    deviceInfo.maxSampleRate = deviceInfo.nativeDataFormats[iNativeFormat].sampleRate;
-                }
-            }
-        }
-    }
-
-
-    /* Clamp ranges. */
-    deviceInfo.minChannels   = ma_max(deviceInfo.minChannels,   MA_MIN_CHANNELS);
-    deviceInfo.maxChannels   = ma_min(deviceInfo.maxChannels,   MA_MAX_CHANNELS);
-    deviceInfo.minSampleRate = ma_max(deviceInfo.minSampleRate, (ma_uint32)ma_standard_sample_rate_min);
-    deviceInfo.maxSampleRate = ma_min(deviceInfo.maxSampleRate, (ma_uint32)ma_standard_sample_rate_max);
-
-    *pDeviceInfo = deviceInfo;
-    return result;
-}
-
-MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext)
-{
-    if (pContext == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_is_loopback_supported(pContext->backend);
-}
-
-
-MA_API ma_device_config ma_device_config_init(ma_device_type deviceType)
-{
-    ma_device_config config;
-    MA_ZERO_OBJECT(&config);
-    config.deviceType = deviceType;
-
-    /* Resampling defaults. We must never use the Speex backend by default because it uses licensed third party code. */
-    config.resampling.algorithm       = ma_resample_algorithm_linear;
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.resampling.speex.quality   = 3;
-
-    return config;
-}
-
-MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice)
-{
-    ma_result result;
-    ma_device_descriptor descriptorPlayback;
-    ma_device_descriptor descriptorCapture;
-
-    /* The context can be null, in which case we self-manage it. */
-    if (pContext == NULL) {
-        return ma_device_init_ex(NULL, 0, NULL, pConfig, pDevice);
-    }
-
-    if (pDevice == NULL) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    MA_ZERO_OBJECT(pDevice);
-
-    if (pConfig == NULL) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid arguments (pConfig == NULL).", MA_INVALID_ARGS);
-    }
-
-
-    /* Check that we have our callbacks defined. */
-    if (pContext->callbacks.onDeviceInit == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-
-    /* Basic config validation. */
-    if (pConfig->deviceType != ma_device_type_playback && pConfig->deviceType != ma_device_type_capture && pConfig->deviceType != ma_device_type_duplex && pConfig->deviceType != ma_device_type_loopback) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Device type is invalid. Make sure the device type has been set in the config.", MA_INVALID_DEVICE_CONFIG);
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        if (pConfig->capture.channels > MA_MAX_CHANNELS) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Capture channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
-        }
-        if (!ma__is_channel_map_valid(pConfig->capture.channelMap, pConfig->capture.channels)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Capture channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        if (pConfig->playback.channels > MA_MAX_CHANNELS) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Playback channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
-        }
-        if (!ma__is_channel_map_valid(pConfig->playback.channelMap, pConfig->playback.channels)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Playback channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
-        }
-    }
-
-    pDevice->pContext = pContext;
-
-    /* Set the user data and log callback ASAP to ensure it is available for the entire initialization process. */
-    pDevice->pUserData = pConfig->pUserData;
-    pDevice->onData    = pConfig->dataCallback;
-    pDevice->onStop    = pConfig->stopCallback;
-
-    if (((ma_uintptr)pDevice % sizeof(pDevice)) != 0) {
-        if (pContext->logCallback) {
-            pContext->logCallback(pContext, pDevice, MA_LOG_LEVEL_WARNING, "WARNING: ma_device_init() called for a device that is not properly aligned. Thread safety is not supported.");
-        }
-    }
-
-    if (pConfig->playback.pDeviceID != NULL) {
-        MA_COPY_MEMORY(&pDevice->playback.id, pConfig->playback.pDeviceID, sizeof(pDevice->playback.id));
-    }
-
-    if (pConfig->capture.pDeviceID != NULL) {
-        MA_COPY_MEMORY(&pDevice->capture.id, pConfig->capture.pDeviceID, sizeof(pDevice->capture.id));
-    }
-
-    pDevice->noPreZeroedOutputBuffer = pConfig->noPreZeroedOutputBuffer;
-    pDevice->noClip = pConfig->noClip;
-    pDevice->masterVolumeFactor = 1;
-
-    pDevice->type                       = pConfig->deviceType;
-    pDevice->sampleRate                 = pConfig->sampleRate;
-    pDevice->resampling.algorithm       = pConfig->resampling.algorithm;
-    pDevice->resampling.linear.lpfOrder = pConfig->resampling.linear.lpfOrder;
-    pDevice->resampling.speex.quality   = pConfig->resampling.speex.quality;
-
-    pDevice->capture.shareMode          = pConfig->capture.shareMode;
-    pDevice->capture.format             = pConfig->capture.format;
-    pDevice->capture.channels           = pConfig->capture.channels;
-    ma_channel_map_copy(pDevice->capture.channelMap, pConfig->capture.channelMap, pConfig->capture.channels);
-    pDevice->capture.channelMixMode     = pConfig->capture.channelMixMode;
-    
-    pDevice->playback.shareMode         = pConfig->playback.shareMode;
-    pDevice->playback.format            = pConfig->playback.format;
-    pDevice->playback.channels          = pConfig->playback.channels;
-    ma_channel_map_copy(pDevice->playback.channelMap, pConfig->playback.channelMap, pConfig->playback.channels);
-    pDevice->playback.channelMixMode    = pConfig->playback.channelMixMode;
-    
-
-    result = ma_mutex_init(&pDevice->startStopLock);
-    if (result != MA_SUCCESS) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create mutex.", result);
-    }
-
-    /*
-    When the device is started, the worker thread is the one that does the actual startup of the backend device. We
-    use a semaphore to wait for the background thread to finish the work. The same applies for stopping the device.
-
-    Each of these semaphores is released internally by the worker thread when the work is completed. The start
-    semaphore is also used to wake up the worker thread.
-    */
-    result = ma_event_init(&pDevice->wakeupEvent);
-    if (result != MA_SUCCESS) {
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread wakeup event.", result);
-    }
-
-    result = ma_event_init(&pDevice->startEvent);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread start event.", result);
-    }
-
-    result = ma_event_init(&pDevice->stopEvent);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->startEvent);
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread stop event.", result);
-    }
-
-
-    MA_ZERO_OBJECT(&descriptorPlayback);
-    descriptorPlayback.pDeviceID                = pConfig->playback.pDeviceID;
-    descriptorPlayback.shareMode                = pConfig->playback.shareMode;
-    descriptorPlayback.format                   = pConfig->playback.format;
-    descriptorPlayback.channels                 = pConfig->playback.channels;
-    descriptorPlayback.sampleRate               = pConfig->sampleRate;
-    ma_channel_map_copy(descriptorPlayback.channelMap, pConfig->playback.channelMap, pConfig->playback.channels);
-    descriptorPlayback.periodSizeInFrames       = pConfig->periodSizeInFrames;
-    descriptorPlayback.periodSizeInMilliseconds = pConfig->periodSizeInMilliseconds;
-    descriptorPlayback.periodCount              = pConfig->periods;
-
-    if (descriptorPlayback.periodCount == 0) {
-        descriptorPlayback.periodCount = MA_DEFAULT_PERIODS;
-    }
-
-
-    MA_ZERO_OBJECT(&descriptorCapture);
-    descriptorCapture.pDeviceID                 = pConfig->capture.pDeviceID;
-    descriptorCapture.shareMode                 = pConfig->capture.shareMode;
-    descriptorCapture.format                    = pConfig->capture.format;
-    descriptorCapture.channels                  = pConfig->capture.channels;
-    descriptorCapture.sampleRate                = pConfig->sampleRate;
-    ma_channel_map_copy(descriptorCapture.channelMap, pConfig->capture.channelMap, pConfig->capture.channels);
-    descriptorCapture.periodSizeInFrames        = pConfig->periodSizeInFrames;
-    descriptorCapture.periodSizeInMilliseconds  = pConfig->periodSizeInMilliseconds;
-    descriptorCapture.periodCount               = pConfig->periods;
-
-    if (descriptorCapture.periodCount == 0) {
-        descriptorCapture.periodCount = MA_DEFAULT_PERIODS;
-    }
-
-
-    result = pContext->callbacks.onDeviceInit(pDevice, pConfig, &descriptorPlayback, &descriptorCapture);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->startEvent);
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return result;
-    }
-
-
-    /*
-    On output the descriptors will contain the *actual* data format of the device. We need this to know how to convert the data between
-    the requested format and the internal format.
-    */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        if (!ma_device_descriptor_is_valid(&descriptorCapture)) {
-            ma_device_uninit(pDevice);
-            return MA_INVALID_ARGS;
-        }
-
-        pDevice->capture.internalFormat             = descriptorCapture.format;
-        pDevice->capture.internalChannels           = descriptorCapture.channels;
-        pDevice->capture.internalSampleRate         = descriptorCapture.sampleRate;
-        ma_channel_map_copy(pDevice->capture.internalChannelMap, descriptorCapture.channelMap, descriptorCapture.channels);
-        pDevice->capture.internalPeriodSizeInFrames = descriptorCapture.periodSizeInFrames;
-        pDevice->capture.internalPeriods            = descriptorCapture.periodCount;
-
-        if (pDevice->capture.internalPeriodSizeInFrames == 0) {
-            pDevice->capture.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorCapture.periodSizeInMilliseconds, descriptorCapture.sampleRate);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        if (!ma_device_descriptor_is_valid(&descriptorPlayback)) {
-            ma_device_uninit(pDevice);
-            return MA_INVALID_ARGS;
-        }
-
-        pDevice->playback.internalFormat             = descriptorPlayback.format;
-        pDevice->playback.internalChannels           = descriptorPlayback.channels;
-        pDevice->playback.internalSampleRate         = descriptorPlayback.sampleRate;
-        ma_channel_map_copy(pDevice->playback.internalChannelMap, descriptorPlayback.channelMap, descriptorPlayback.channels);
-        pDevice->playback.internalPeriodSizeInFrames = descriptorPlayback.periodSizeInFrames;
-        pDevice->playback.internalPeriods            = descriptorPlayback.periodCount;
-
-        if (pDevice->playback.internalPeriodSizeInFrames == 0) {
-            pDevice->playback.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorPlayback.periodSizeInMilliseconds, descriptorPlayback.sampleRate);
-        }
-    }
-
-
-    /*
-    The name of the device can be retrieved from device info. This may be temporary and replaced with a `ma_device_get_info(pDevice, deviceType)` instead.
-    For loopback devices, we need to retrieve the name of the playback device.
-    */
-    {
-        ma_device_info deviceInfo;
-
-        if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-            result = ma_context_get_device_info(pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, descriptorCapture.pDeviceID, descriptorCapture.shareMode, &deviceInfo);
-            if (result == MA_SUCCESS) {
-                ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1);
-            } else {
-                /* We failed to retrieve the device info. Fall back to a default name. */
-                if (descriptorCapture.pDeviceID == NULL) {
-                    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-                } else {
-                    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1);
-                }
-            }
-        }
-
-        if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-            result = ma_context_get_device_info(pContext, ma_device_type_playback, descriptorPlayback.pDeviceID, descriptorPlayback.shareMode, &deviceInfo);
-            if (result == MA_SUCCESS) {
-                ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1);
-            } else {
-                /* We failed to retrieve the device info. Fall back to a default name. */
-                if (descriptorPlayback.pDeviceID == NULL) {
-                    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-                } else {
-                    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1);
-                }
-            }
-        }
-    }
-
-
-    ma_device__post_init_setup(pDevice, pConfig->deviceType);
-
-
-    /* Some backends don't require the worker thread. */
-    if (!ma_context_is_backend_asynchronous(pContext)) {
-        /* The worker thread. */
-        result = ma_thread_create(&pDevice->thread, pContext->threadPriority, pContext->threadStackSize, ma_worker_thread, pDevice);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit(pDevice);
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread.", result);
-        }
-
-        /* Wait for the worker thread to put the device into it's stopped state for real. */
-        ma_event_wait(&pDevice->stopEvent);
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-    } else {
-        /*
-        If the backend is asynchronous and the device is duplex, we'll need an intermediary ring buffer. Note that this needs to be done
-        after ma_device__post_init_setup().
-        */
-        if (ma_context_is_backend_asynchronous(pContext)) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                result = ma_duplex_rb_init(pDevice->capture.format, pDevice->capture.channels, pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalPeriodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
-                if (result != MA_SUCCESS) {
-                    ma_device_uninit(pDevice);
-                    return result;
-                }
-            }
-        }
-
-        ma_device__set_state(pDevice, MA_STATE_STOPPED);
-    }
-
-
-    ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "[%s]", ma_get_backend_name(pDevice->pContext->backend));
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "  %s (%s)", pDevice->capture.name, "Capture");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Format:      %s -> %s", ma_get_format_name(pDevice->capture.internalFormat), ma_get_format_name(pDevice->capture.format));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Channels:    %d -> %d", pDevice->capture.internalChannels, pDevice->capture.channels);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Sample Rate: %d -> %d", pDevice->capture.internalSampleRate, pDevice->sampleRate);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Buffer Size: %d*%d (%d)", pDevice->capture.internalPeriodSizeInFrames, pDevice->capture.internalPeriods, (pDevice->capture.internalPeriodSizeInFrames * pDevice->capture.internalPeriods));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Conversion:");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Pre Format Conversion:    %s", pDevice->capture.converter.hasPreFormatConversion  ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Post Format Conversion:   %s", pDevice->capture.converter.hasPostFormatConversion ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Channel Routing:          %s", pDevice->capture.converter.hasChannelConverter     ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Resampling:               %s", pDevice->capture.converter.hasResampler            ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Passthrough:              %s", pDevice->capture.converter.isPassthrough           ? "YES" : "NO");
-    }
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "  %s (%s)", pDevice->playback.name, "Playback");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Format:      %s -> %s", ma_get_format_name(pDevice->playback.format), ma_get_format_name(pDevice->playback.internalFormat));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Channels:    %d -> %d", pDevice->playback.channels, pDevice->playback.internalChannels);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Sample Rate: %d -> %d", pDevice->sampleRate, pDevice->playback.internalSampleRate);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Buffer Size: %d*%d (%d)", pDevice->playback.internalPeriodSizeInFrames, pDevice->playback.internalPeriods, (pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Conversion:");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Pre Format Conversion:    %s", pDevice->playback.converter.hasPreFormatConversion  ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Post Format Conversion:   %s", pDevice->playback.converter.hasPostFormatConversion ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Channel Routing:          %s", pDevice->playback.converter.hasChannelConverter     ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Resampling:               %s", pDevice->playback.converter.hasResampler            ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Passthrough:              %s", pDevice->playback.converter.isPassthrough           ? "YES" : "NO");
-    }
-
-    MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice)
-{
-    ma_result result;
-    ma_context* pContext;
-    ma_backend defaultBackends[ma_backend_null+1];
-    ma_uint32 iBackend;
-    ma_backend* pBackendsToIterate;
-    ma_uint32 backendsToIterateCount;
-    ma_allocation_callbacks allocationCallbacks;
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContextConfig != NULL) {
-        result = ma_allocation_callbacks_init_copy(&allocationCallbacks, &pContextConfig->allocationCallbacks);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    } else {
-        allocationCallbacks = ma_allocation_callbacks_init_default();
-    }
-
-
-    pContext = (ma_context*)ma__malloc_from_callbacks(sizeof(*pContext), &allocationCallbacks);
-    if (pContext == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) {
-        defaultBackends[iBackend] = (ma_backend)iBackend;
-    }
-
-    pBackendsToIterate = (ma_backend*)backends;
-    backendsToIterateCount = backendCount;
-    if (pBackendsToIterate == NULL) {
-        pBackendsToIterate = (ma_backend*)defaultBackends;
-        backendsToIterateCount = ma_countof(defaultBackends);
-    }
-
-    result = MA_NO_BACKEND;
-
-    for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
-        result = ma_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
-        if (result == MA_SUCCESS) {
-            result = ma_device_init(pContext, pConfig, pDevice);
-            if (result == MA_SUCCESS) {
-                break;  /* Success. */
-            } else {
-                ma_context_uninit(pContext);   /* Failure. */
-            }
-        }
-    }
-
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pContext, &allocationCallbacks);
-        return result;
-    }
-
-    pDevice->isOwnerOfContext = MA_TRUE;
-    return result;
-}
-
-MA_API void ma_device_uninit(ma_device* pDevice)
-{
-    if (!ma_device__is_initialized(pDevice)) {
-        return;
-    }
-
-    /* Make sure the device is stopped first. The backends will probably handle this naturally, but I like to do it explicitly for my own sanity. */
-    if (ma_device_is_started(pDevice)) {
-        ma_device_stop(pDevice);
-    }
-
-    /* Putting the device into an uninitialized state will make the worker thread return. */
-    ma_device__set_state(pDevice, MA_STATE_UNINITIALIZED);
-
-    /* Wake up the worker thread and wait for it to properly terminate. */
-    if (!ma_context_is_backend_asynchronous(pDevice->pContext)) {
-        ma_event_signal(&pDevice->wakeupEvent);
-        ma_thread_wait(&pDevice->thread);
-    }
-
-    if (pDevice->pContext->callbacks.onDeviceUninit != NULL) {
-        pDevice->pContext->callbacks.onDeviceUninit(pDevice);
-    }
-
-
-    ma_event_uninit(&pDevice->stopEvent);
-    ma_event_uninit(&pDevice->startEvent);
-    ma_event_uninit(&pDevice->wakeupEvent);
-    ma_mutex_uninit(&pDevice->startStopLock);
-
-    if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-        if (pDevice->type == ma_device_type_duplex) {
-            ma_duplex_rb_uninit(&pDevice->duplexRB);
-        }
-    }
-
-    if (pDevice->isOwnerOfContext) {
-        ma_allocation_callbacks allocationCallbacks = pDevice->pContext->allocationCallbacks;
-
-        ma_context_uninit(pDevice->pContext);
-        ma__free_from_callbacks(pDevice->pContext, &allocationCallbacks);
-    }
-
-    MA_ZERO_OBJECT(pDevice);
-}
-
-MA_API ma_result ma_device_start(ma_device* pDevice)
-{
-    ma_result result;
-
-    if (pDevice == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_start() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_start() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_WARNING, "ma_device_start() called when the device is already started.", MA_INVALID_OPERATION);  /* Already started. Returning an error to let the application know because it probably means they're doing something wrong. */
-    }
-
-    ma_mutex_lock(&pDevice->startStopLock);
-    {
-        /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a stopped or paused state. */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-
-        ma_device__set_state(pDevice, MA_STATE_STARTING);
-
-        /* Asynchronous backends need to be handled differently. */
-        if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-            if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
-                result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
-            } else {
-                result = MA_INVALID_OPERATION;
-            }
-
-            if (result == MA_SUCCESS) {
-                ma_device__set_state(pDevice, MA_STATE_STARTED);
-            }
-        } else {
-            /*
-            Synchronous backends are started by signaling an event that's being waited on in the worker thread. We first wake up the
-            thread and then wait for the start event.
-            */
-            ma_event_signal(&pDevice->wakeupEvent);
-
-            /*
-            Wait for the worker thread to finish starting the device. Note that the worker thread will be the one who puts the device
-            into the started state. Don't call ma_device__set_state() here.
-            */
-            ma_event_wait(&pDevice->startEvent);
-            result = pDevice->workResult;
-        }
-
-        /* We changed the state from stopped to started, so if we failed, make sure we put the state back to stopped. */
-        if (result != MA_SUCCESS) {
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-        }
-    }
-    ma_mutex_unlock(&pDevice->startStopLock);
-
-    return result;
-}
-
-MA_API ma_result ma_device_stop(ma_device* pDevice)
-{
-    ma_result result;
-
-    if (pDevice == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_stop() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_stop() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_STOPPED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_WARNING, "ma_device_stop() called when the device is already stopped.", MA_INVALID_OPERATION);   /* Already stopped. Returning an error to let the application know because it probably means they're doing something wrong. */
-    }
-
-    ma_mutex_lock(&pDevice->startStopLock);
-    {
-        /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STARTED);
-
-        ma_device__set_state(pDevice, MA_STATE_STOPPING);
-
-        /* Asynchronous backends need to be handled differently. */
-        if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-            /* Asynchronous backends must have a stop operation. */
-            if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
-                result = pDevice->pContext->callbacks.onDeviceStop(pDevice);
-            } else {
-                result = MA_INVALID_OPERATION;
-            }
-
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-        } else {
-            /*
-            Synchronous backends. The stop callback is always called from the worker thread. Do not call the stop callback here. If
-            the backend is implementing it's own audio thread loop we'll need to wake it up if required. Note that we need to make
-            sure the state of the device is *not* playing right now, which it shouldn't be since we set it above. This is super
-            important though, so I'm asserting it here as well for extra safety in case we accidentally change something later.
-            */
-            MA_ASSERT(ma_device_get_state(pDevice) != MA_STATE_STARTED);
-
-            if (pDevice->pContext->callbacks.onDeviceDataLoopWakeup != NULL) {
-                pDevice->pContext->callbacks.onDeviceDataLoopWakeup(pDevice);
-            }
-
-            /*
-            We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be
-            the one who puts the device into the stopped state. Don't call ma_device__set_state() here.
-            */
-            ma_event_wait(&pDevice->stopEvent);
-            result = MA_SUCCESS;
-        }
-    }
-    ma_mutex_unlock(&pDevice->startStopLock);
-
-    return result;
-}
-
-MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice)
-{
-    return ma_device_get_state(pDevice) == MA_STATE_STARTED;
-}
-
-MA_API ma_uint32 ma_device_get_state(const ma_device* pDevice)
-{
-    if (pDevice == NULL) {
-        return MA_STATE_UNINITIALIZED;
-    }
-
-    return c89atomic_load_32((ma_uint32*)&pDevice->state);  /* Naughty cast to get rid of a const warning. */
-}
-
-MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume)
-{
-    if (pDevice == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (volume < 0.0f || volume > 1.0f) {
-        return MA_INVALID_ARGS;
-    }
-
-    c89atomic_exchange_f32(&pDevice->masterVolumeFactor, volume);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume)
-{
-    if (pVolume == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDevice == NULL) {
-        *pVolume = 0;
-        return MA_INVALID_ARGS;
-    }
-
-    *pVolume = c89atomic_load_f32(&pDevice->masterVolumeFactor);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_set_master_gain_db(ma_device* pDevice, float gainDB)
-{
-    if (gainDB > 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_device_set_master_volume(pDevice, ma_gain_db_to_factor(gainDB));
-}
-
-MA_API ma_result ma_device_get_master_gain_db(ma_device* pDevice, float* pGainDB)
-{
-    float factor;
-    ma_result result;
-
-    if (pGainDB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_device_get_master_volume(pDevice, &factor);
-    if (result != MA_SUCCESS) {
-        *pGainDB = 0;
-        return result;
-    }
-
-    *pGainDB = ma_factor_to_gain_db(factor);
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
-{
-    if (pDevice == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pOutput == NULL && pInput == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDevice->type == ma_device_type_duplex) {
-        if (pInput != NULL) {
-            ma_device__handle_duplex_callback_capture(pDevice, frameCount, pInput, &pDevice->duplexRB.rb);
-        }
-
-        if (pOutput != NULL) {
-            ma_device__handle_duplex_callback_playback(pDevice, frameCount, pOutput, &pDevice->duplexRB.rb);
-        }
-    } else {
-        if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_loopback) {
-            if (pInput == NULL) {
-                return MA_INVALID_ARGS;
-            }
-
-            ma_device__send_frames_to_client(pDevice, frameCount, pInput);
-        }
-
-        if (pDevice->type == ma_device_type_playback) {
-            if (pOutput == NULL) {
-                return MA_INVALID_ARGS;
-            }
-
-            ma_device__read_frames_from_client(pDevice, frameCount, pOutput);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    if (pDescriptor == NULL) {
-        return 0;
-    }
-
-    /*
-    We must have a non-0 native sample rate, but some backends don't allow retrieval of this at the
-    time when the size of the buffer needs to be determined. In this case we need to just take a best
-    guess and move on. We'll try using the sample rate in pDescriptor first. If that's not set we'll
-    just fall back to MA_DEFAULT_SAMPLE_RATE.
-    */
-    if (nativeSampleRate == 0) {
-        nativeSampleRate = pDescriptor->sampleRate;
-    }
-    if (nativeSampleRate == 0) {
-        nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-    MA_ASSERT(nativeSampleRate != 0);
-
-    if (pDescriptor->periodSizeInFrames == 0) {
-        if (pDescriptor->periodSizeInMilliseconds == 0) {
-            if (performanceProfile == ma_performance_profile_low_latency) {
-                return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, nativeSampleRate);
-            } else {
-                return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, nativeSampleRate);
-            }
-        } else {
-            return ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate);
-        }
-    } else {
-        return pDescriptor->periodSizeInFrames;
-    }
-}
-#endif  /* MA_NO_DEVICE_IO */
-
-
-MA_API ma_uint32 ma_scale_buffer_size(ma_uint32 baseBufferSize, float scale)
-{
-    return ma_max(1, (ma_uint32)(baseBufferSize*scale));
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate)
-{
-    /* Prevent a division by zero. */
-    if (sampleRate == 0) {
-        return 0;
-    }
-
-    return bufferSizeInFrames*1000 / sampleRate;
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate)
-{
-    /* Prevent a division by zero. */
-    if (sampleRate == 0) {
-        return 0;
-    }
-
-    return bufferSizeInMilliseconds*sampleRate / 1000;
-}
-
-MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels)
-{
-    if (dst == src) {
-        return; /* No-op. */
-    }
-
-    ma_copy_memory_64(dst, src, frameCount * ma_get_bytes_per_frame(format, channels));
-}
-
-MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels)
-{
-    if (format == ma_format_u8) {
-        ma_uint64 sampleCount = frameCount * channels;
-        ma_uint64 iSample;
-        for (iSample = 0; iSample < sampleCount; iSample += 1) {
-            ((ma_uint8*)p)[iSample] = 128;
-        }
-    } else {
-        ma_zero_memory_64(p, frameCount * ma_get_bytes_per_frame(format, channels));
-    }
-}
-
-MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels)
-{
-    return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels));
-}
-
-MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels)
-{
-    return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels));
-}
-
-
-MA_API void ma_clip_samples_f32(float* p, ma_uint64 sampleCount)
-{
-    ma_uint32 iSample;
-
-    /* TODO: Research a branchless SSE implementation. */
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        p[iSample] = ma_clip_f32(p[iSample]);
-    }
-}
-
-
-MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_uint8)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_int16)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-    ma_uint8* pSamplesOut8;
-    ma_uint8* pSamplesIn8;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    pSamplesOut8 = (ma_uint8*)pSamplesOut;
-    pSamplesIn8  = (ma_uint8*)pSamplesIn;
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        ma_int32 sampleS32;
-
-        sampleS32 = (ma_int32)(((ma_uint32)(pSamplesIn8[iSample*3+0]) << 8) | ((ma_uint32)(pSamplesIn8[iSample*3+1]) << 16) | ((ma_uint32)(pSamplesIn8[iSample*3+2])) << 24);
-        sampleS32 = (ma_int32)(sampleS32 * factor);
-
-        pSamplesOut8[iSample*3+0] = (ma_uint8)(((ma_uint32)sampleS32 & 0x0000FF00) >>  8);
-        pSamplesOut8[iSample*3+1] = (ma_uint8)(((ma_uint32)sampleS32 & 0x00FF0000) >> 16);
-        pSamplesOut8[iSample*3+2] = (ma_uint8)(((ma_uint32)sampleS32 & 0xFF000000) >> 24);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_int32)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = pSamplesIn[iSample] * factor;
-    }
-}
-
-MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_u8(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s16(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s24(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s32(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_f32(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFramesOut, const ma_uint8* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_u8(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFramesOut, const ma_int16* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s16(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s24(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFramesOut, const ma_int32* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s32(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pPCMFramesOut, const float* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_f32(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor)
-{
-    switch (format)
-    {
-    case ma_format_u8:  ma_copy_and_apply_volume_factor_pcm_frames_u8 ((ma_uint8*)pPCMFramesOut, (const ma_uint8*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s16: ma_copy_and_apply_volume_factor_pcm_frames_s16((ma_int16*)pPCMFramesOut, (const ma_int16*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s24: ma_copy_and_apply_volume_factor_pcm_frames_s24(           pPCMFramesOut,                  pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s32: ma_copy_and_apply_volume_factor_pcm_frames_s32((ma_int32*)pPCMFramesOut, (const ma_int32*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_f32: ma_copy_and_apply_volume_factor_pcm_frames_f32(   (float*)pPCMFramesOut,    (const float*)pPCMFramesIn, frameCount, channels, factor); return;
-    default: return;    /* Do nothing. */
-    }
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_u8(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s16(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s24(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s32(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_f32(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames(void* pPCMFrames, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames(pPCMFrames, pPCMFrames, frameCount, format, channels, factor);
-}
-
-
-MA_API float ma_factor_to_gain_db(float factor)
-{
-    return (float)(20*ma_log10f(factor));
-}
-
-MA_API float ma_gain_db_to_factor(float gain)
-{
-    return (float)ma_powf(10, gain/20.0f);
-}
-
-
-/**************************************************************************************************************************************************************
-
-Format Conversion
-
-**************************************************************************************************************************************************************/
-
-static MA_INLINE ma_int16 ma_pcm_sample_f32_to_s16(float x)
-{
-    return (ma_int16)(x * 32767.0f);
-}
-
-static MA_INLINE ma_int16 ma_pcm_sample_u8_to_s16_no_scale(ma_uint8 x)
-{
-    return (ma_int16)((ma_int16)x - 128);
-}
-
-static MA_INLINE ma_int64 ma_pcm_sample_s24_to_s32_no_scale(const ma_uint8* x)
-{
-    return (ma_int64)(((ma_uint64)x[0] << 40) | ((ma_uint64)x[1] << 48) | ((ma_uint64)x[2] << 56)) >> 40;  /* Make sure the sign bits are maintained. */
-}
-
-static MA_INLINE void ma_pcm_sample_s32_to_s24_no_scale(ma_int64 x, ma_uint8* s24)
-{
-    s24[0] = (ma_uint8)((x & 0x000000FF) >>  0);
-    s24[1] = (ma_uint8)((x & 0x0000FF00) >>  8);
-    s24[2] = (ma_uint8)((x & 0x00FF0000) >> 16);
-}
-
-
-static MA_INLINE ma_uint8 ma_clip_u8(ma_int16 x)
-{
-    return (ma_uint8)(ma_clamp(x, -128, 127) + 128);
-}
-
-static MA_INLINE ma_int16 ma_clip_s16(ma_int32 x)
-{
-    return (ma_int16)ma_clamp(x, -32768, 32767);
-}
-
-static MA_INLINE ma_int64 ma_clip_s24(ma_int64 x)
-{
-    return (ma_int64)ma_clamp(x, -8388608, 8388607);
-}
-
-static MA_INLINE ma_int32 ma_clip_s32(ma_int64 x)
-{
-    /* This dance is to silence warnings with -std=c89. A good compiler should be able to optimize this away. */
-    ma_int64 clipMin;
-    ma_int64 clipMax;
-    clipMin = -((ma_int64)2147483647 + 1);
-    clipMax =   (ma_int64)2147483647;
-
-    return (ma_int32)ma_clamp(x, clipMin, clipMax);
-}
-
-
-/* u8 */
-MA_API void ma_pcm_u8_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-    ma_copy_memory_64(dst, src, count * sizeof(ma_uint8));
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int16 x = src_u8[i];
-        x = (ma_int16)(x - 128);
-        x = (ma_int16)(x << 8);
-        dst_s16[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int16 x = src_u8[i];
-        x = (ma_int16)(x - 128);
-
-        dst_s24[i*3+0] = 0;
-        dst_s24[i*3+1] = 0;
-        dst_s24[i*3+2] = (ma_uint8)((ma_int8)x);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int32 x = src_u8[i];
-        x = x - 128;
-        x = x << 24;
-        dst_s32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)src_u8[i];
-        x = x * 0.00784313725490196078f;    /* 0..255 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-static MA_INLINE void ma_pcm_interleave_u8__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8** src_u8 = (const ma_uint8**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame];
-        }
-    }
-}
-#else
-static MA_INLINE void ma_pcm_interleave_u8__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8** src_u8 = (const ma_uint8**)src;
-
-    if (channels == 1) {
-        ma_copy_memory_64(dst, src[0], frameCount * sizeof(ma_uint8));
-    } else if (channels == 2) {
-        ma_uint64 iFrame;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            dst_u8[iFrame*2 + 0] = src_u8[0][iFrame];
-            dst_u8[iFrame*2 + 1] = src_u8[1][iFrame];
-        }
-    } else {
-        ma_uint64 iFrame;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_uint32 iChannel;
-            for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame];
-            }
-        }
-    }
-}
-#endif
-
-MA_API void ma_pcm_interleave_u8(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_u8__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_u8__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_u8__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8** dst_u8 = (ma_uint8**)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_u8[iChannel][iFrame] = src_u8[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_u8__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_u8(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_u8__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* s16 */
-static MA_INLINE void ma_pcm_s16_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int16 x = src_s16[i];
-            x = (ma_int16)(x >> 8);
-            x = (ma_int16)(x + 128);
-            dst_u8[i] = (ma_uint8)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int16 x = src_s16[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x80, 0x7F);
-            if ((x + dither) <= 0x7FFF) {
-                x = (ma_int16)(x + dither);
-            } else {
-                x = 0x7FFF;
-            }
-
-            x = (ma_int16)(x >> 8);
-            x = (ma_int16)(x + 128);
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s16_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s16_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-    ma_copy_memory_64(dst, src, count * sizeof(ma_int16));
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s24[i*3+0] = 0;
-        dst_s24[i*3+1] = (ma_uint8)(src_s16[i] & 0xFF);
-        dst_s24[i*3+2] = (ma_uint8)(src_s16[i] >> 8);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s32[i] = src_s16[i] << 16;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)src_s16[i];
-
-#if 0
-        /* The accurate way. */
-        x = x + 32768.0f;                   /* -32768..32767 to 0..65535 */
-        x = x * 0.00003051804379339284f;    /* 0..65535 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-#else
-        /* The fast way. */
-        x = x * 0.000030517578125f;         /* -32768..32767 to -1..0.999969482421875 */
-#endif
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s16__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_int16** src_s16 = (const ma_int16**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s16[iFrame*channels + iChannel] = src_s16[iChannel][iFrame];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s16__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s16__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s16(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s16__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s16__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s16__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int16** dst_s16 = (ma_int16**)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s16[iChannel][iFrame] = src_s16[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s16__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s16(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s16__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* s24 */
-static MA_INLINE void ma_pcm_s24_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            dst_u8[i] = (ma_uint8)((ma_int8)src_s24[i*3 + 2] + 128);
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s24_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_uint16 dst_lo =            ((ma_uint16)src_s24[i*3 + 1]);
-            ma_uint16 dst_hi = (ma_uint16)((ma_uint16)src_s24[i*3 + 2] << 8);
-            dst_s16[i] = (ma_int16)(dst_lo | dst_hi);
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s24_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s24_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * 3);
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s32[i] = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s24_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)(((ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24)) >> 8);
-
-#if 0
-        /* The accurate way. */
-        x = x + 8388608.0f;                 /* -8388608..8388607 to 0..16777215 */
-        x = x * 0.00000011920929665621f;    /* 0..16777215 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-#else
-        /* The fast way. */
-        x = x * 0.00000011920928955078125f; /* -8388608..8388607 to -1..0.999969482421875 */
-#endif
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s24_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s24__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst8 = (ma_uint8*)dst;
-    const ma_uint8** src8 = (const ma_uint8**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst8[iFrame*3*channels + iChannel*3 + 0] = src8[iChannel][iFrame*3 + 0];
-            dst8[iFrame*3*channels + iChannel*3 + 1] = src8[iChannel][iFrame*3 + 1];
-            dst8[iFrame*3*channels + iChannel*3 + 2] = src8[iChannel][iFrame*3 + 2];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s24__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s24__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s24(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s24__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s24__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s24__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8** dst8 = (ma_uint8**)dst;
-    const ma_uint8* src8 = (const ma_uint8*)src;
-
-    ma_uint32 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst8[iChannel][iFrame*3 + 0] = src8[iFrame*3*channels + iChannel*3 + 0];
-            dst8[iChannel][iFrame*3 + 1] = src8[iFrame*3*channels + iChannel*3 + 1];
-            dst8[iChannel][iFrame*3 + 2] = src8[iFrame*3*channels + iChannel*3 + 2];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s24__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s24(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s24__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-
-/* s32 */
-static MA_INLINE void ma_pcm_s32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_uint32 x = (ma_uint32)src_s32[i];
-        dst_s24[i*3+0] = (ma_uint8)((x & 0x0000FF00) >>  8);
-        dst_s24[i*3+1] = (ma_uint8)((x & 0x00FF0000) >> 16);
-        dst_s24[i*3+2] = (ma_uint8)((x & 0xFF000000) >> 24);
-    }
-
-    (void)ditherMode;   /* No dithering for s32 -> s24. */
-}
-
-static MA_INLINE void ma_pcm_s32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * sizeof(ma_int32));
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        double x = src_s32[i];
-
-#if 0
-        x = x + 2147483648.0;
-        x = x * 0.0000000004656612873077392578125;
-        x = x - 1;
-#else
-        x = x / 2147483648.0;
-#endif
-
-        dst_f32[i] = (float)x;
-    }
-
-    (void)ditherMode;   /* No dithering for s32 -> f32. */
-}
-
-static MA_INLINE void ma_pcm_s32_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_int32** src_s32 = (const ma_int32**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s32[iFrame*channels + iChannel] = src_s32[iChannel][iFrame];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int32** dst_s32 = (ma_int32**)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s32[iChannel][iFrame] = src_s32[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* f32 */
-static MA_INLINE void ma_pcm_f32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -128;
-        ditherMax = 1.0f /  127;
-    }
-
-    for (i = 0; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 127.5f;                             /* 0..2 to 0..255 */
-
-        dst_u8[i] = (ma_uint8)x;
-    }
-}
-
-static MA_INLINE void ma_pcm_f32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-static MA_INLINE void ma_pcm_f32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    for (i = 0; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 32767.5f;                           /* 0..2 to 0..65535 */
-        x = x - 32768.0f;                           /* 0...65535 to -32768..32767 */
-#else
-        /* The fast way. */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-#endif
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#else
-static MA_INLINE void ma_pcm_f32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i4;
-    ma_uint64 count4;
-
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    /* Unrolled. */
-    i = 0;
-    count4 = count >> 2;
-    for (i4 = 0; i4 < count4; i4 += 1) {
-        float d0 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d1 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d2 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d3 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-
-        float x0 = src_f32[i+0];
-        float x1 = src_f32[i+1];
-        float x2 = src_f32[i+2];
-        float x3 = src_f32[i+3];
-
-        x0 = x0 + d0;
-        x1 = x1 + d1;
-        x2 = x2 + d2;
-        x3 = x3 + d3;
-
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-
-        dst_s16[i+0] = (ma_int16)x0;
-        dst_s16[i+1] = (ma_int16)x1;
-        dst_s16[i+2] = (ma_int16)x2;
-        dst_s16[i+3] = (ma_int16)x3;
-
-        i += 4;
-    }
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i8;
-    ma_uint64 count8;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    /* Both the input and output buffers need to be aligned to 16 bytes. */
-    if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* SSE2. SSE allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */
-    count8 = count >> 3;
-    for (i8 = 0; i8 < count8; i8 += 1) {
-        __m128 d0;
-        __m128 d1;
-        __m128 x0;
-        __m128 x1;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = _mm_set1_ps(0);
-            d1 = _mm_set1_ps(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            d0 = _mm_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-            d1 = _mm_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-        } else {
-            d0 = _mm_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-            d1 = _mm_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-        }
-
-        x0 = *((__m128*)(src_f32 + i) + 0);
-        x1 = *((__m128*)(src_f32 + i) + 1);
-
-        x0 = _mm_add_ps(x0, d0);
-        x1 = _mm_add_ps(x1, d1);
-
-        x0 = _mm_mul_ps(x0, _mm_set1_ps(32767.0f));
-        x1 = _mm_mul_ps(x1, _mm_set1_ps(32767.0f));
-
-        _mm_stream_si128(((__m128i*)(dst_s16 + i)), _mm_packs_epi32(_mm_cvttps_epi32(x0), _mm_cvttps_epi32(x1)));
-
-        i += 8;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* SSE2 */
-
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i16;
-    ma_uint64 count16;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    /* Both the input and output buffers need to be aligned to 32 bytes. */
-    if ((((ma_uintptr)dst & 31) != 0) || (((ma_uintptr)src & 31) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* AVX2. AVX2 allows us to output 16 s16's at a time which means our loop is unrolled 16 times. */
-    count16 = count >> 4;
-    for (i16 = 0; i16 < count16; i16 += 1) {
-        __m256 d0;
-        __m256 d1;
-        __m256 x0;
-        __m256 x1;
-        __m256i i0;
-        __m256i i1;
-        __m256i p0;
-        __m256i p1;
-        __m256i r;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = _mm256_set1_ps(0);
-            d1 = _mm256_set1_ps(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            d0 = _mm256_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-            d1 = _mm256_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-        } else {
-            d0 = _mm256_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-            d1 = _mm256_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-        }
-
-        x0 = *((__m256*)(src_f32 + i) + 0);
-        x1 = *((__m256*)(src_f32 + i) + 1);
-
-        x0 = _mm256_add_ps(x0, d0);
-        x1 = _mm256_add_ps(x1, d1);
-
-        x0 = _mm256_mul_ps(x0, _mm256_set1_ps(32767.0f));
-        x1 = _mm256_mul_ps(x1, _mm256_set1_ps(32767.0f));
-
-        /* Computing the final result is a little more complicated for AVX2 than SSE2. */
-        i0 = _mm256_cvttps_epi32(x0);
-        i1 = _mm256_cvttps_epi32(x1);
-        p0 = _mm256_permute2x128_si256(i0, i1, 0 | 32);
-        p1 = _mm256_permute2x128_si256(i0, i1, 1 | 48);
-        r  = _mm256_packs_epi32(p0, p1);
-
-        _mm256_stream_si256(((__m256i*)(dst_s16 + i)), r);
-
-        i += 16;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* AVX2 */
-
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i8;
-    ma_uint64 count8;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    if (!ma_has_neon()) {
-        return ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-    }
-
-    /* Both the input and output buffers need to be aligned to 16 bytes. */
-    if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* NEON. NEON allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */
-    count8 = count >> 3;
-    for (i8 = 0; i8 < count8; i8 += 1) {
-        float32x4_t d0;
-        float32x4_t d1;
-        float32x4_t x0;
-        float32x4_t x1;
-        int32x4_t i0;
-        int32x4_t i1;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = vmovq_n_f32(0);
-            d1 = vmovq_n_f32(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            float d0v[4];
-            d0v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0 = vld1q_f32(d0v);
-
-            float d1v[4];
-            d1v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1 = vld1q_f32(d1v);
-        } else {
-            float d0v[4];
-            d0v[0] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[1] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[2] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[3] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0 = vld1q_f32(d0v);
-
-            float d1v[4];
-            d1v[0] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[1] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[2] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[3] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1 = vld1q_f32(d1v);
-        }
-
-        x0 = *((float32x4_t*)(src_f32 + i) + 0);
-        x1 = *((float32x4_t*)(src_f32 + i) + 1);
-
-        x0 = vaddq_f32(x0, d0);
-        x1 = vaddq_f32(x1, d1);
-
-        x0 = vmulq_n_f32(x0, 32767.0f);
-        x1 = vmulq_n_f32(x1, 32767.0f);
-
-        i0 = vcvtq_s32_f32(x0);
-        i1 = vcvtq_s32_f32(x1);
-        *((int16x8_t*)(dst_s16 + i)) = vcombine_s16(vqmovn_s32(i0), vqmovn_s32(i1));
-
-        i += 8;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* Neon */
-#endif  /* MA_USE_REFERENCE_CONVERSION_APIS */
-
-MA_API void ma_pcm_f32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_f32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int32 r;
-        float x = src_f32[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 8388607.5f;                         /* 0..2 to 0..16777215 */
-        x = x - 8388608.0f;                         /* 0..16777215 to -8388608..8388607 */
-#else
-        /* The fast way. */
-        x = x * 8388607.0f;                         /* -1..1 to -8388607..8388607 */
-#endif
-
-        r = (ma_int32)x;
-        dst_s24[(i*3)+0] = (ma_uint8)((r & 0x0000FF) >>  0);
-        dst_s24[(i*3)+1] = (ma_uint8)((r & 0x00FF00) >>  8);
-        dst_s24[(i*3)+2] = (ma_uint8)((r & 0xFF0000) >> 16);
-    }
-
-    (void)ditherMode;   /* No dithering for f32 -> s24. */
-}
-
-static MA_INLINE void ma_pcm_f32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_f32_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint32 i;
-    for (i = 0; i < count; i += 1) {
-        double x = src_f32[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 2147483647.5;                       /* 0..2 to 0..4294967295 */
-        x = x - 2147483648.0;                       /* 0...4294967295 to -2147483648..2147483647 */
-#else
-        /* The fast way. */
-        x = x * 2147483647.0;                       /* -1..1 to -2147483647..2147483647 */
-#endif
-
-        dst_s32[i] = (ma_int32)x;
-    }
-
-    (void)ditherMode;   /* No dithering for f32 -> s32. */
-}
-
-static MA_INLINE void ma_pcm_f32_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_f32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * sizeof(float));
-}
-
-
-static void ma_pcm_interleave_f32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    float* dst_f32 = (float*)dst;
-    const float** src_f32 = (const float**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_f32[iFrame*channels + iChannel] = src_f32[iChannel][iFrame];
-        }
-    }
-}
-
-static void ma_pcm_interleave_f32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_f32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_f32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_f32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_f32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static void ma_pcm_deinterleave_f32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    float** dst_f32 = (float**)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_f32[iChannel][iFrame] = src_f32[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static void ma_pcm_deinterleave_f32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_f32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_f32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode)
-{
-    if (formatOut == formatIn) {
-        ma_copy_memory_64(pOut, pIn, sampleCount * ma_get_bytes_per_sample(formatOut));
-        return;
-    }
-
-    switch (formatIn)
-    {
-        case ma_format_u8:
-        {
-            switch (formatOut)
-            {
-                case ma_format_s16: ma_pcm_u8_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_u8_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_u8_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_u8_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s16_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_s16_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_s16_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s16_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s24_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_s24_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_s24_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s24_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s32_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_s32_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_s32_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s32_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_f32_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_f32_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_f32_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_f32_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        default: break;
-    }
-}
-
-MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode)
-{
-    ma_pcm_convert(pOut, formatOut, pIn, formatIn, frameCount * channels, ditherMode);
-}
-
-MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames)
-{
-    if (pInterleavedPCMFrames == NULL || ppDeinterleavedPCMFrames == NULL) {
-        return; /* Invalid args. */
-    }
-
-    /* For efficiency we do this per format. */
-    switch (format) {
-        case ma_format_s16:
-        {
-            const ma_int16* pSrcS16 = (const ma_int16*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    ma_int16* pDstS16 = (ma_int16*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstS16[iPCMFrame] = pSrcS16[iPCMFrame*channels+iChannel];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            const float* pSrcF32 = (const float*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    float* pDstF32 = (float*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstF32[iPCMFrame] = pSrcF32[iPCMFrame*channels+iChannel];
-                }
-            }
-        } break;
-
-        default:
-        {
-            ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format);
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                          void* pDst = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes);
-                    const void* pSrc = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes);
-                    memcpy(pDst, pSrc, sampleSizeInBytes);
-                }
-            }
-        } break;
-    }
-}
-
-MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames)
-{
-    switch (format)
-    {
-        case ma_format_s16:
-        {
-            ma_int16* pDstS16 = (ma_int16*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    const ma_int16* pSrcS16 = (const ma_int16*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstS16[iPCMFrame*channels+iChannel] = pSrcS16[iPCMFrame];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            float* pDstF32 = (float*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    const float* pSrcF32 = (const float*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstF32[iPCMFrame*channels+iChannel] = pSrcF32[iPCMFrame];
-                }
-            }
-        } break;
-
-        default:
-        {
-            ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format);
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                          void* pDst = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes);
-                    const void* pSrc = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes);
-                    memcpy(pDst, pSrc, sampleSizeInBytes);
-                }
-            }
-        } break;
-    }
-}
-
-
-/**************************************************************************************************************************************************************
-
-Biquad Filter
-
-**************************************************************************************************************************************************************/
-#ifndef MA_BIQUAD_FIXED_POINT_SHIFT
-#define MA_BIQUAD_FIXED_POINT_SHIFT 14
-#endif
-
-static ma_int32 ma_biquad_float_to_fp(double x)
-{
-    return (ma_int32)(x * (1 << MA_BIQUAD_FIXED_POINT_SHIFT));
-}
-
-MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2)
-{
-    ma_biquad_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.b0 = b0;
-    config.b1 = b1;
-    config.b2 = b2;
-    config.a0 = a0;
-    config.a1 = a1;
-    config.a2 = a2;
-
-    return config;
-}
-
-MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, ma_biquad* pBQ)
-{
-    if (pBQ == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBQ);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_reinit(pConfig, pBQ);
-}
-
-MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ)
-{
-    if (pBQ == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->a0 == 0) {
-        return MA_INVALID_ARGS; /* Division by zero. */
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pBQ->format != ma_format_unknown && pBQ->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pBQ->channels != 0 && pBQ->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-
-    pBQ->format   = pConfig->format;
-    pBQ->channels = pConfig->channels;
-
-    /* Normalize. */
-    if (pConfig->format == ma_format_f32) {
-        pBQ->b0.f32 = (float)(pConfig->b0 / pConfig->a0);
-        pBQ->b1.f32 = (float)(pConfig->b1 / pConfig->a0);
-        pBQ->b2.f32 = (float)(pConfig->b2 / pConfig->a0);
-        pBQ->a1.f32 = (float)(pConfig->a1 / pConfig->a0);
-        pBQ->a2.f32 = (float)(pConfig->a2 / pConfig->a0);
-    } else {
-        pBQ->b0.s32 = ma_biquad_float_to_fp(pConfig->b0 / pConfig->a0);
-        pBQ->b1.s32 = ma_biquad_float_to_fp(pConfig->b1 / pConfig->a0);
-        pBQ->b2.s32 = ma_biquad_float_to_fp(pConfig->b2 / pConfig->a0);
-        pBQ->a1.s32 = ma_biquad_float_to_fp(pConfig->a1 / pConfig->a0);
-        pBQ->a2.s32 = ma_biquad_float_to_fp(pConfig->a2 / pConfig->a0);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(ma_biquad* pBQ, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pBQ->channels;
-    const float b0 = pBQ->b0.f32;
-    const float b1 = pBQ->b1.f32;
-    const float b2 = pBQ->b2.f32;
-    const float a1 = pBQ->a1.f32;
-    const float a2 = pBQ->a2.f32;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pBQ->r1[c].f32;
-        float r2 = pBQ->r2[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y  = b0*x        + r1;
-        r1 = b1*x - a1*y + r2;
-        r2 = b2*x - a2*y;
-
-        pY[c]          = y;
-        pBQ->r1[c].f32 = r1;
-        pBQ->r2[c].f32 = r2;
-    }
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_f32(ma_biquad* pBQ, float* pY, const float* pX)
-{
-    ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX);
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pBQ->channels;
-    const ma_int32 b0 = pBQ->b0.s32;
-    const ma_int32 b1 = pBQ->b1.s32;
-    const ma_int32 b2 = pBQ->b2.s32;
-    const ma_int32 a1 = pBQ->a1.s32;
-    const ma_int32 a2 = pBQ->a2.s32;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pBQ->r1[c].s32;
-        ma_int32 r2 = pBQ->r2[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y  = (b0*x        + r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-        r1 = (b1*x - a1*y + r2);
-        r2 = (b2*x - a2*y);
-
-        pY[c]          = (ma_int16)ma_clamp(y, -32768, 32767);
-        pBQ->r1[c].s32 = r1;
-        pBQ->r2[c].s32 = r2;
-    }
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_s16(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX)
-{
-    ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX);
-}
-
-MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pBQ == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pBQ->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX);
-            pY += pBQ->channels;
-            pX += pBQ->channels;
-        }
-    } else if (pBQ->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX);
-            pY += pBQ->channels;
-            pX += pBQ->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ)
-{
-    if (pBQ == NULL) {
-        return 0;
-    }
-
-    return 2;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Low-Pass Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency)
-{
-    ma_lpf1_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = 0.5;
-
-    return config;
-}
-
-MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_lpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, ma_lpf1* pLPF)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_lpf1_reinit(pConfig, pLPF);
-}
-
-MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF)
-{
-    double a;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    pLPF->format   = pConfig->format;
-    pLPF->channels = pConfig->channels;
-
-    a = ma_exp(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate);
-    if (pConfig->format == ma_format_f32) {
-        pLPF->a.f32 = (float)a;
-    } else {
-        pLPF->a.s32 = ma_biquad_float_to_fp(a);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_lpf1_process_pcm_frame_f32(ma_lpf1* pLPF, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pLPF->channels;
-    const float a = pLPF->a.f32;
-    const float b = 1 - a;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pLPF->r1[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y = b*x + a*r1;
-
-        pY[c]           = y;
-        pLPF->r1[c].f32 = y;
-    }
-}
-
-static MA_INLINE void ma_lpf1_process_pcm_frame_s16(ma_lpf1* pLPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pLPF->channels;
-    const ma_int32 a = pLPF->a.s32;
-    const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a);
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pLPF->r1[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y = (b*x + a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-
-        pY[c]           = (ma_int16)y;
-        pLPF->r1[c].s32 = (ma_int32)y;
-    }
-}
-
-MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pLPF == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pLPF->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_lpf1_process_pcm_frame_f32(pLPF, pY, pX);
-            pY += pLPF->channels;
-            pX += pLPF->channels;
-        }
-    } else if (pLPF->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_lpf1_process_pcm_frame_s16(pLPF, pY, pX);
-            pY += pLPF->channels;
-            pX += pLPF->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return 1;
-}
-
-
-static MA_INLINE ma_biquad_config ma_lpf2__get_biquad_config(const ma_lpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 = (1 - c) / 2;
-    bqConfig.b1 =  1 - c;
-    bqConfig.b2 = (1 - c) / 2;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, ma_lpf2* pLPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_lpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pLPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_lpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pLPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_lpf2_process_pcm_frame_s16(ma_lpf2* pLPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pLPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_lpf2_process_pcm_frame_f32(ma_lpf2* pLPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pLPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pLPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pLPF->bq);
-}
-
-
-MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_lpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, ma_lpf* pLPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 lpf1Count;
-    ma_uint32 lpf2Count;
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    lpf1Count = pConfig->order % 2;
-    lpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(lpf1Count <= ma_countof(pLPF->lpf1));
-    MA_ASSERT(lpf2Count <= ma_countof(pLPF->lpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pLPF->lpf1Count != lpf1Count || pLPF->lpf2Count != lpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ilpf1 = 0; ilpf1 < lpf1Count; ilpf1 += 1) {
-        ma_lpf1_config lpf1Config = ma_lpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency);
-
-        if (isNew) {
-            result = ma_lpf1_init(&lpf1Config, &pLPF->lpf1[ilpf1]);
-        } else {
-            result = ma_lpf1_reinit(&lpf1Config, &pLPF->lpf1[ilpf1]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    for (ilpf2 = 0; ilpf2 < lpf2Count; ilpf2 += 1) {
-        ma_lpf2_config lpf2Config;
-        double q;
-        double a;
-
-        /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */
-        if (lpf1Count == 1) {
-            a = (1 + ilpf2*1) * (MA_PI_D/(pConfig->order*1));   /* Odd order. */
-        } else {
-            a = (1 + ilpf2*2) * (MA_PI_D/(pConfig->order*2));   /* Even order. */
-        }
-        q = 1 / (2*ma_cos(a));
-
-        lpf2Config = ma_lpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_lpf2_init(&lpf2Config, &pLPF->lpf2[ilpf2]);
-        } else {
-            result = ma_lpf2_reinit(&lpf2Config, &pLPF->lpf2[ilpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pLPF->lpf1Count  = lpf1Count;
-    pLPF->lpf2Count  = lpf2Count;
-    pLPF->format     = pConfig->format;
-    pLPF->channels   = pConfig->channels;
-    pLPF->sampleRate = pConfig->sampleRate;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, ma_lpf* pLPF)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_lpf_reinit__internal(pConfig, pLPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF)
-{
-    return ma_lpf_reinit__internal(pConfig, pLPF, /*isNew*/MA_FALSE);
-}
-
-static MA_INLINE void ma_lpf_process_pcm_frame_f32(ma_lpf* pLPF, float* pY, const void* pX)
-{
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    MA_ASSERT(pLPF->format == ma_format_f32);
-
-    MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
-
-    for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-        ma_lpf1_process_pcm_frame_f32(&pLPF->lpf1[ilpf1], pY, pY);
-    }
-
-    for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-        ma_lpf2_process_pcm_frame_f32(&pLPF->lpf2[ilpf2], pY, pY);
-    }
-}
-
-static MA_INLINE void ma_lpf_process_pcm_frame_s16(ma_lpf* pLPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    MA_ASSERT(pLPF->format == ma_format_s16);
-
-    MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
-
-    for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-        ma_lpf1_process_pcm_frame_s16(&pLPF->lpf1[ilpf1], pY, pY);
-    }
-
-    for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-        ma_lpf2_process_pcm_frame_s16(&pLPF->lpf2[ilpf2], pY, pY);
-    }
-}
-
-MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-            result = ma_lpf1_process_pcm_frames(&pLPF->lpf1[ilpf1], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-
-        for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-            result = ma_lpf2_process_pcm_frames(&pLPF->lpf2[ilpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pLPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_lpf_process_pcm_frame_f32(pLPF, pFramesOutF32, pFramesInF32);
-                pFramesOutF32 += pLPF->channels;
-                pFramesInF32  += pLPF->channels;
-            }
-        } else if (pLPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_lpf_process_pcm_frame_s16(pLPF, pFramesOutS16, pFramesInS16);
-                pFramesOutS16 += pLPF->channels;
-                pFramesInS16  += pLPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return pLPF->lpf2Count*2 + pLPF->lpf1Count;
-}
-
-
-/**************************************************************************************************************************************************************
-
-High-Pass Filtering
-
-**************************************************************************************************************************************************************/
-MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency)
-{
-    ma_hpf1_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-
-    return config;
-}
-
-MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_hpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, ma_hpf1* pHPF)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_hpf1_reinit(pConfig, pHPF);
-}
-
-MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF)
-{
-    double a;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    pHPF->format   = pConfig->format;
-    pHPF->channels = pConfig->channels;
-
-    a = ma_exp(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate);
-    if (pConfig->format == ma_format_f32) {
-        pHPF->a.f32 = (float)a;
-    } else {
-        pHPF->a.s32 = ma_biquad_float_to_fp(a);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hpf1_process_pcm_frame_f32(ma_hpf1* pHPF, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pHPF->channels;
-    const float a = 1 - pHPF->a.f32;
-    const float b = 1 - a;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pHPF->r1[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y = b*x - a*r1;
-
-        pY[c]           = y;
-        pHPF->r1[c].f32 = y;
-    }
-}
-
-static MA_INLINE void ma_hpf1_process_pcm_frame_s16(ma_hpf1* pHPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pHPF->channels;
-    const ma_int32 a = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - pHPF->a.s32);
-    const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a);
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pHPF->r1[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y = (b*x - a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-
-        pY[c]           = (ma_int16)y;
-        pHPF->r1[c].s32 = (ma_int32)y;
-    }
-}
-
-MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pHPF == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pHPF->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_hpf1_process_pcm_frame_f32(pHPF, pY, pX);
-            pY += pHPF->channels;
-            pX += pHPF->channels;
-        }
-    } else if (pHPF->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_hpf1_process_pcm_frame_s16(pHPF, pY, pX);
-            pY += pHPF->channels;
-            pX += pHPF->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return 1;
-}
-
-
-static MA_INLINE ma_biquad_config ma_hpf2__get_biquad_config(const ma_hpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  (1 + c) / 2;
-    bqConfig.b1 = -(1 + c);
-    bqConfig.b2 =  (1 + c) / 2;
-    bqConfig.a0 =   1 + a;
-    bqConfig.a1 =  -2 * c;
-    bqConfig.a2 =   1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, ma_hpf2* pHPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pHPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pHPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hpf2_process_pcm_frame_s16(ma_hpf2* pHPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pHPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_hpf2_process_pcm_frame_f32(ma_hpf2* pHPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pHPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pHPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pHPF->bq);
-}
-
-
-MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_hpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, ma_hpf* pHPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 hpf1Count;
-    ma_uint32 hpf2Count;
-    ma_uint32 ihpf1;
-    ma_uint32 ihpf2;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    hpf1Count = pConfig->order % 2;
-    hpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(hpf1Count <= ma_countof(pHPF->hpf1));
-    MA_ASSERT(hpf2Count <= ma_countof(pHPF->hpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pHPF->hpf1Count != hpf1Count || pHPF->hpf2Count != hpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ihpf1 = 0; ihpf1 < hpf1Count; ihpf1 += 1) {
-        ma_hpf1_config hpf1Config = ma_hpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency);
-
-        if (isNew) {
-            result = ma_hpf1_init(&hpf1Config, &pHPF->hpf1[ihpf1]);
-        } else {
-            result = ma_hpf1_reinit(&hpf1Config, &pHPF->hpf1[ihpf1]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    for (ihpf2 = 0; ihpf2 < hpf2Count; ihpf2 += 1) {
-        ma_hpf2_config hpf2Config;
-        double q;
-        double a;
-
-        /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */
-        if (hpf1Count == 1) {
-            a = (1 + ihpf2*1) * (MA_PI_D/(pConfig->order*1));   /* Odd order. */
-        } else {
-            a = (1 + ihpf2*2) * (MA_PI_D/(pConfig->order*2));   /* Even order. */
-        }
-        q = 1 / (2*ma_cos(a));
-
-        hpf2Config = ma_hpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_hpf2_init(&hpf2Config, &pHPF->hpf2[ihpf2]);
-        } else {
-            result = ma_hpf2_reinit(&hpf2Config, &pHPF->hpf2[ihpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pHPF->hpf1Count  = hpf1Count;
-    pHPF->hpf2Count  = hpf2Count;
-    pHPF->format     = pConfig->format;
-    pHPF->channels   = pConfig->channels;
-    pHPF->sampleRate = pConfig->sampleRate;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, ma_hpf* pHPF)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_hpf_reinit__internal(pConfig, pHPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF)
-{
-    return ma_hpf_reinit__internal(pConfig, pHPF, /*isNew*/MA_FALSE);
-}
-
-MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ihpf1;
-    ma_uint32 ihpf2;
-
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-            result = ma_hpf1_process_pcm_frames(&pHPF->hpf1[ihpf1], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-
-        for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-            result = ma_hpf2_process_pcm_frames(&pHPF->hpf2[ihpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pHPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pHPF->format, pHPF->channels));
-
-                for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-                    ma_hpf1_process_pcm_frame_f32(&pHPF->hpf1[ihpf1], pFramesOutF32, pFramesOutF32);
-                }
-
-                for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-                    ma_hpf2_process_pcm_frame_f32(&pHPF->hpf2[ihpf2], pFramesOutF32, pFramesOutF32);
-                }
-
-                pFramesOutF32 += pHPF->channels;
-                pFramesInF32  += pHPF->channels;
-            }
-        } else if (pHPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pHPF->format, pHPF->channels));
-
-                for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-                    ma_hpf1_process_pcm_frame_s16(&pHPF->hpf1[ihpf1], pFramesOutS16, pFramesOutS16);
-                }
-
-                for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-                    ma_hpf2_process_pcm_frame_s16(&pHPF->hpf2[ihpf2], pFramesOutS16, pFramesOutS16);
-                }
-
-                pFramesOutS16 += pHPF->channels;
-                pFramesInS16  += pHPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return pHPF->hpf2Count*2 + pHPF->hpf1Count;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Band-Pass Filtering
-
-**************************************************************************************************************************************************************/
-MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_bpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_bpf2__get_biquad_config(const ma_bpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  q * a;
-    bqConfig.b1 =  0;
-    bqConfig.b2 = -q * a;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, ma_bpf2* pBPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_bpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pBPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pBPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_bpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pBPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_bpf2_process_pcm_frame_s16(ma_bpf2* pBPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pBPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_bpf2_process_pcm_frame_f32(ma_bpf2* pBPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pBPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pBPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF)
-{
-    if (pBPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pBPF->bq);
-}
-
-
-MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_bpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_bpf_reinit__internal(const ma_bpf_config* pConfig, ma_bpf* pBPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 bpf2Count;
-    ma_uint32 ibpf2;
-
-    if (pBPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pBPF->format != ma_format_unknown && pBPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pBPF->channels != 0 && pBPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* We must have an even number of order. */
-    if ((pConfig->order & 0x1) != 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    bpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(bpf2Count <= ma_countof(pBPF->bpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pBPF->bpf2Count != bpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ibpf2 = 0; ibpf2 < bpf2Count; ibpf2 += 1) {
-        ma_bpf2_config bpf2Config;
-        double q;
-
-        /* TODO: Calculate Q to make this a proper Butterworth filter. */
-        q = 0.707107;
-
-        bpf2Config = ma_bpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_bpf2_init(&bpf2Config, &pBPF->bpf2[ibpf2]);
-        } else {
-            result = ma_bpf2_reinit(&bpf2Config, &pBPF->bpf2[ibpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pBPF->bpf2Count = bpf2Count;
-    pBPF->format    = pConfig->format;
-    pBPF->channels  = pConfig->channels;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, ma_bpf* pBPF)
-{
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_bpf_reinit__internal(pConfig, pBPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF)
-{
-    return ma_bpf_reinit__internal(pConfig, pBPF, /*isNew*/MA_FALSE);
-}
-
-MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ibpf2;
-
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-            result = ma_bpf2_process_pcm_frames(&pBPF->bpf2[ibpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pBPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pBPF->format, pBPF->channels));
-
-                for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-                    ma_bpf2_process_pcm_frame_f32(&pBPF->bpf2[ibpf2], pFramesOutF32, pFramesOutF32);
-                }
-
-                pFramesOutF32 += pBPF->channels;
-                pFramesInF32  += pBPF->channels;
-            }
-        } else if (pBPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pBPF->format, pBPF->channels));
-
-                for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-                    ma_bpf2_process_pcm_frame_s16(&pBPF->bpf2[ibpf2], pFramesOutS16, pFramesOutS16);
-                }
-
-                pFramesOutS16 += pBPF->channels;
-                pFramesInS16  += pBPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF)
-{
-    if (pBPF == NULL) {
-        return 0;
-    }
-
-    return pBPF->bpf2Count*2;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Notching Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency)
-{
-    ma_notch2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.q          = q;
-    config.frequency  = frequency;
-
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  1;
-    bqConfig.b1 = -2 * c;
-    bqConfig.b2 =  1;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_notch2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_notch2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_notch2_process_pcm_frame_s16(ma_notch2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_notch2_process_pcm_frame_f32(ma_notch2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Peaking EQ Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency)
-{
-    ma_peak2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.q          = q;
-    config.frequency  = frequency;
-
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-    double A;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-
-    bqConfig.b0 =  1 + (a * A);
-    bqConfig.b1 = -2 * c;
-    bqConfig.b2 =  1 - (a * A);
-    bqConfig.a0 =  1 + (a / A);
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - (a / A);
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_peak2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_peak2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_peak2_process_pcm_frame_s16(ma_peak2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_peak2_process_pcm_frame_f32(ma_peak2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-/**************************************************************************************************************************************************************
-
-Low Shelf Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency)
-{
-    ma_loshelf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.shelfSlope = shelfSlope;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_loshelf2__get_biquad_config(const ma_loshelf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double w;
-    double s;
-    double c;
-    double A;
-    double S;
-    double a;
-    double sqrtA;
-
-    MA_ASSERT(pConfig != NULL);
-
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-    S = pConfig->shelfSlope;
-    a = s/2 * ma_sqrt((A + 1/A) * (1/S - 1) + 2);
-    sqrtA = 2*ma_sqrt(A)*a;
-
-    bqConfig.b0 =  A * ((A + 1) - (A - 1)*c + sqrtA);
-    bqConfig.b1 =  2 * A * ((A - 1) - (A + 1)*c);
-    bqConfig.b2 =  A * ((A + 1) - (A - 1)*c - sqrtA);
-    bqConfig.a0 =  (A + 1) + (A - 1)*c + sqrtA;
-    bqConfig.a1 = -2 * ((A - 1) + (A + 1)*c);
-    bqConfig.a2 =  (A + 1) + (A - 1)*c - sqrtA;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_loshelf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_loshelf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_loshelf2_process_pcm_frame_s16(ma_loshelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_loshelf2_process_pcm_frame_f32(ma_loshelf2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-/**************************************************************************************************************************************************************
-
-High Shelf Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency)
-{
-    ma_hishelf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.shelfSlope = shelfSlope;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_hishelf2__get_biquad_config(const ma_hishelf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double w;
-    double s;
-    double c;
-    double A;
-    double S;
-    double a;
-    double sqrtA;
-
-    MA_ASSERT(pConfig != NULL);
-
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-    S = pConfig->shelfSlope;
-    a = s/2 * ma_sqrt((A + 1/A) * (1/S - 1) + 2);
-    sqrtA = 2*ma_sqrt(A)*a;
-
-    bqConfig.b0 =  A * ((A + 1) + (A - 1)*c + sqrtA);
-    bqConfig.b1 = -2 * A * ((A - 1) + (A + 1)*c);
-    bqConfig.b2 =  A * ((A + 1) + (A - 1)*c - sqrtA);
-    bqConfig.a0 =  (A + 1) - (A - 1)*c + sqrtA;
-    bqConfig.a1 =  2 * ((A - 1) - (A + 1)*c);
-    bqConfig.a2 =  (A + 1) - (A - 1)*c - sqrtA;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hishelf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hishelf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hishelf2_process_pcm_frame_s16(ma_hishelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_hishelf2_process_pcm_frame_f32(ma_hishelf2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Resampling
-
-**************************************************************************************************************************************************************/
-MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    ma_linear_resampler_config config;
-    MA_ZERO_OBJECT(&config);
-    config.format           = format;
-    config.channels         = channels;
-    config.sampleRateIn     = sampleRateIn;
-    config.sampleRateOut    = sampleRateOut;
-    config.lpfOrder         = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.lpfNyquistFactor = 1;
-
-    return config;
-}
-
-static void ma_linear_resampler_adjust_timer_for_new_rate(ma_linear_resampler* pResampler, ma_uint32 oldSampleRateOut, ma_uint32 newSampleRateOut)
-{
-    /*
-    So what's happening here? Basically we need to adjust the fractional component of the time advance based on the new rate. The old time advance will
-    be based on the old sample rate, but we are needing to adjust it to that it's based on the new sample rate.
-    */
-    ma_uint32 oldRateTimeWhole = pResampler->inTimeFrac / oldSampleRateOut;  /* <-- This should almost never be anything other than 0, but leaving it here to make this more general and robust just in case. */
-    ma_uint32 oldRateTimeFract = pResampler->inTimeFrac % oldSampleRateOut;
-
-    pResampler->inTimeFrac =
-         (oldRateTimeWhole * newSampleRateOut) +
-        ((oldRateTimeFract * newSampleRateOut) / oldSampleRateOut);
-
-    /* Make sure the fractional part is less than the output sample rate. */
-    pResampler->inTimeInt += pResampler->inTimeFrac / pResampler->config.sampleRateOut;
-    pResampler->inTimeFrac = pResampler->inTimeFrac % pResampler->config.sampleRateOut;
-}
-
-static ma_result ma_linear_resampler_set_rate_internal(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_bool32 isResamplerAlreadyInitialized)
-{
-    ma_result result;
-    ma_uint32 gcf;
-    ma_uint32 lpfSampleRate;
-    double lpfCutoffFrequency;
-    ma_lpf_config lpfConfig;
-    ma_uint32 oldSampleRateOut; /* Required for adjusting time advance down the bottom. */
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (sampleRateIn == 0 || sampleRateOut == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    oldSampleRateOut = pResampler->config.sampleRateOut;
-
-    pResampler->config.sampleRateIn  = sampleRateIn;
-    pResampler->config.sampleRateOut = sampleRateOut;
-
-    /* Simplify the sample rate. */
-    gcf = ma_gcf_u32(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut);
-    pResampler->config.sampleRateIn  /= gcf;
-    pResampler->config.sampleRateOut /= gcf;
-
-    /* Always initialize the low-pass filter, even when the order is 0. */
-    if (pResampler->config.lpfOrder > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    lpfSampleRate      = (ma_uint32)(ma_max(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut));
-    lpfCutoffFrequency = (   double)(ma_min(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut) * 0.5 * pResampler->config.lpfNyquistFactor);
-
-    lpfConfig = ma_lpf_config_init(pResampler->config.format, pResampler->config.channels, lpfSampleRate, lpfCutoffFrequency, pResampler->config.lpfOrder);
-
-    /*
-    If the resampler is alreay initialized we don't want to do a fresh initialization of the low-pass filter because it will result in the cached frames
-    getting cleared. Instead we re-initialize the filter which will maintain any cached frames.
-    */
-    if (isResamplerAlreadyInitialized) {
-        result = ma_lpf_reinit(&lpfConfig, &pResampler->lpf);
-    } else {
-        result = ma_lpf_init(&lpfConfig, &pResampler->lpf);
-    }
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-
-    pResampler->inAdvanceInt  = pResampler->config.sampleRateIn / pResampler->config.sampleRateOut;
-    pResampler->inAdvanceFrac = pResampler->config.sampleRateIn % pResampler->config.sampleRateOut;
-
-    /* Our timer was based on the old rate. We need to adjust it so that it's based on the new rate. */
-    ma_linear_resampler_adjust_timer_for_new_rate(pResampler, oldSampleRateOut, pResampler->config.sampleRateOut);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, ma_linear_resampler* pResampler)
-{
-    ma_result result;
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pResampler);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config = *pConfig;
-
-    /* Setting the rate will set up the filter and time advances for us. */
-    result = ma_linear_resampler_set_rate_internal(pResampler, pConfig->sampleRateIn, pConfig->sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_FALSE);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pResampler->inTimeInt  = 1;  /* Set this to one to force an input sample to always be loaded for the first output frame. */
-    pResampler->inTimeFrac = 0;
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return;
-    }
-}
-
-static MA_INLINE ma_int16 ma_linear_resampler_mix_s16(ma_int16 x, ma_int16 y, ma_int32 a, const ma_int32 shift)
-{
-    ma_int32 b;
-    ma_int32 c;
-    ma_int32 r;
-
-    MA_ASSERT(a <= (1<<shift));
-
-    b = x * ((1<<shift) - a);
-    c = y * a;
-    r = b + c;
-
-    return (ma_int16)(r >> shift);
-}
-
-static void ma_linear_resampler_interpolate_frame_s16(ma_linear_resampler* pResampler, ma_int16* MA_RESTRICT pFrameOut)
-{
-    ma_uint32 c;
-    ma_uint32 a;
-    const ma_uint32 channels = pResampler->config.channels;
-    const ma_uint32 shift = 12;
-
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFrameOut  != NULL);
-
-    a = (pResampler->inTimeFrac << shift) / pResampler->config.sampleRateOut;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int16 s = ma_linear_resampler_mix_s16(pResampler->x0.s16[c], pResampler->x1.s16[c], a, shift);
-        pFrameOut[c] = s;
-    }
-}
-
-
-static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResampler, float* MA_RESTRICT pFrameOut)
-{
-    ma_uint32 c;
-    float a;
-    const ma_uint32 channels = pResampler->config.channels;
-
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFrameOut  != NULL);
-
-    a = (float)pResampler->inTimeFrac / pResampler->config.sampleRateOut;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float s = ma_mix_f32_fast(pResampler->x0.f32[c], pResampler->x1.f32[c], a);
-        pFrameOut[c] = s;
-    }
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const ma_int16* pFramesInS16;
-    /* */ ma_int16* pFramesOutS16;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInS16       = (const ma_int16*)pFramesIn;
-    pFramesOutS16      = (      ma_int16*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInS16 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = pFramesInS16[iChannel];
-                }
-                pFramesInS16 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = 0;
-                }
-            }
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pResampler->x1.s16, pResampler->x1.s16);
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */
-        if (pFramesOutS16 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16);
-
-            pFramesOutS16 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const ma_int16* pFramesInS16;
-    /* */ ma_int16* pFramesOutS16;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInS16       = (const ma_int16*)pFramesIn;
-    pFramesOutS16      = (      ma_int16*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInS16 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = pFramesInS16[iChannel];
-                }
-                pFramesInS16 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = 0;
-                }
-            }
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and we can generate the next output frame. */
-        if (pFramesOutS16 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16);
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pFramesOutS16, pFramesOutS16);
-
-            pFramesOutS16 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) {
-        return ma_linear_resampler_process_pcm_frames_s16_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        return ma_linear_resampler_process_pcm_frames_s16_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const float* pFramesInF32;
-    /* */ float* pFramesOutF32;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInF32       = (const float*)pFramesIn;
-    pFramesOutF32      = (      float*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInF32 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = pFramesInF32[iChannel];
-                }
-                pFramesInF32 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = 0;
-                }
-            }
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pResampler->x1.f32, pResampler->x1.f32);
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */
-        if (pFramesOutF32 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32);
-
-            pFramesOutF32 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const float* pFramesInF32;
-    /* */ float* pFramesOutF32;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInF32       = (const float*)pFramesIn;
-    pFramesOutF32      = (      float*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInF32 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = pFramesInF32[iChannel];
-                }
-                pFramesInF32 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = 0;
-                }
-            }
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and we can generate the next output frame. */
-        if (pFramesOutF32 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32);
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pFramesOutF32, pFramesOutF32);
-
-            pFramesOutF32 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) {
-        return ma_linear_resampler_process_pcm_frames_f32_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        return ma_linear_resampler_process_pcm_frames_f32_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-
-MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /*  */ if (pResampler->config.format == ma_format_s16) {
-        return ma_linear_resampler_process_pcm_frames_s16(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else if (pResampler->config.format == ma_format_f32) {
-        return ma_linear_resampler_process_pcm_frames_f32(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Should never get here. Getting here means the format is not supported and you didn't check the return value of ma_linear_resampler_init(). */
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS;
-    }
-}
-
-
-MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    return ma_linear_resampler_set_rate_internal(pResampler, sampleRateIn, sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_TRUE);
-}
-
-MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut)
-{
-    ma_uint32 n;
-    ma_uint32 d;
-
-    d = 1000;
-    n = (ma_uint32)(ratioInOut * d);
-
-    if (n == 0) {
-        return MA_INVALID_ARGS; /* Ratio too small. */
-    }
-
-    MA_ASSERT(n != 0);
-
-    return ma_linear_resampler_set_rate(pResampler, n, d);
-}
-
-
-MA_API ma_uint64 ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount)
-{
-    ma_uint64 inputFrameCount;
-
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    if (outputFrameCount == 0) {
-        return 0;
-    }
-
-    /* Any whole input frames are consumed before the first output frame is generated. */
-    inputFrameCount = pResampler->inTimeInt;
-    outputFrameCount -= 1;
-
-    /* The rest of the output frames can be calculated in constant time. */
-    inputFrameCount += outputFrameCount * pResampler->inAdvanceInt;
-    inputFrameCount += (pResampler->inTimeFrac + (outputFrameCount * pResampler->inAdvanceFrac)) / pResampler->config.sampleRateOut;
-
-    return inputFrameCount;
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount)
-{
-    ma_uint64 outputFrameCount;
-    ma_uint64 preliminaryInputFrameCountFromFrac;
-    ma_uint64 preliminaryInputFrameCount;
-
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    /*
-    The first step is to get a preliminary output frame count. This will either be exactly equal to what we need, or less by 1. We need to
-    determine how many input frames will be consumed by this value. If it's greater than our original input frame count it means we won't
-    be able to generate an extra frame because we will have run out of input data. Otherwise we will have enough input for the generation
-    of an extra output frame. This add-by-one logic is necessary due to how the data loading logic works when processing frames.
-    */
-    outputFrameCount = (inputFrameCount * pResampler->config.sampleRateOut) / pResampler->config.sampleRateIn;
-
-    /*
-    We need to determine how many *whole* input frames will have been processed to generate our preliminary output frame count. This is
-    used in the logic below to determine whether or not we need to add an extra output frame.
-    */
-    preliminaryInputFrameCountFromFrac = (pResampler->inTimeFrac + outputFrameCount*pResampler->inAdvanceFrac) / pResampler->config.sampleRateOut;
-    preliminaryInputFrameCount         = (pResampler->inTimeInt  + outputFrameCount*pResampler->inAdvanceInt ) + preliminaryInputFrameCountFromFrac;
-
-    /*
-    If the total number of *whole* input frames that would be required to generate our preliminary output frame count is greather than
-    the amount of whole input frames we have available as input we need to *not* add an extra output frame as there won't be enough data
-    to actually process. Otherwise we need to add the extra output frame.
-    */
-    if (preliminaryInputFrameCount <= inputFrameCount) {
-        outputFrameCount += 1;
-    }
-
-    return outputFrameCount;
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    return 1 + ma_lpf_get_latency(&pResampler->lpf);
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    return ma_linear_resampler_get_input_latency(pResampler) * pResampler->config.sampleRateOut / pResampler->config.sampleRateIn;
-}
-
-
-#if defined(ma_speex_resampler_h)
-#define MA_HAS_SPEEX_RESAMPLER
-
-static ma_result ma_result_from_speex_err(int err)
-{
-    switch (err)
-    {
-        case RESAMPLER_ERR_SUCCESS:      return MA_SUCCESS;
-        case RESAMPLER_ERR_ALLOC_FAILED: return MA_OUT_OF_MEMORY;
-        case RESAMPLER_ERR_BAD_STATE:    return MA_ERROR;
-        case RESAMPLER_ERR_INVALID_ARG:  return MA_INVALID_ARGS;
-        case RESAMPLER_ERR_PTR_OVERLAP:  return MA_INVALID_ARGS;
-        case RESAMPLER_ERR_OVERFLOW:     return MA_ERROR;
-        default: return MA_ERROR;
-    }
-}
-#endif  /* ma_speex_resampler_h */
-
-MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm)
-{
-    ma_resampler_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRateIn = sampleRateIn;
-    config.sampleRateOut = sampleRateOut;
-    config.algorithm = algorithm;
-
-    /* Linear. */
-    config.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.linear.lpfNyquistFactor = 1;
-
-    /* Speex. */
-    config.speex.quality = 3;   /* Cannot leave this as 0 as that is actually a valid value for Speex resampling quality. */
-
-    return config;
-}
-
-MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, ma_resampler* pResampler)
-{
-    ma_result result;
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pResampler);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config = *pConfig;
-
-    switch (pConfig->algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            ma_linear_resampler_config linearConfig;
-            linearConfig = ma_linear_resampler_config_init(pConfig->format, pConfig->channels, pConfig->sampleRateIn, pConfig->sampleRateOut);
-            linearConfig.lpfOrder         = pConfig->linear.lpfOrder;
-            linearConfig.lpfNyquistFactor = pConfig->linear.lpfNyquistFactor;
-
-            result = ma_linear_resampler_init(&linearConfig, &pResampler->state.linear);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            int speexErr;
-            pResampler->state.speex.pSpeexResamplerState = speex_resampler_init(pConfig->channels, pConfig->sampleRateIn, pConfig->sampleRateOut, pConfig->speex.quality, &speexErr);
-            if (pResampler->state.speex.pSpeexResamplerState == NULL) {
-                return ma_result_from_speex_err(speexErr);
-            }
-        #else
-            /* Speex resampler not available. */
-            return MA_NO_BACKEND;
-        #endif
-        } break;
-
-        default: return MA_INVALID_ARGS;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_resampler_uninit(ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return;
-    }
-
-    if (pResampler->config.algorithm == ma_resample_algorithm_linear) {
-        ma_linear_resampler_uninit(&pResampler->state.linear);
-    }
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-    if (pResampler->config.algorithm == ma_resample_algorithm_speex) {
-        speex_resampler_destroy((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-    }
-#endif
-}
-
-static ma_result ma_resampler_process_pcm_frames__read__linear(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    return ma_linear_resampler_process_pcm_frames(&pResampler->state.linear, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-}
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-static ma_result ma_resampler_process_pcm_frames__read__speex(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    int speexErr;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCountIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint64 framesProcessedIn;
-    unsigned int framesPerIteration = UINT_MAX;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFramesOut     != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-
-    /*
-    Reading from the Speex resampler requires a bit of dancing around for a few reasons. The first thing is that it's frame counts
-    are in unsigned int's whereas ours is in ma_uint64. We therefore need to run the conversion in a loop. The other, more complicated
-    problem, is that we need to keep track of the input time, similar to what we do with the linear resampler. The reason we need to
-    do this is for ma_resampler_get_required_input_frame_count() and ma_resampler_get_expected_output_frame_count().
-    */
-    frameCountOut      = *pFrameCountOut;
-    frameCountIn       = *pFrameCountIn;
-    framesProcessedOut = 0;
-    framesProcessedIn  = 0;
-
-    while (framesProcessedOut < frameCountOut && framesProcessedIn < frameCountIn) {
-        unsigned int frameCountInThisIteration;
-        unsigned int frameCountOutThisIteration;
-        const void* pFramesInThisIteration;
-        void* pFramesOutThisIteration;
-
-        frameCountInThisIteration = framesPerIteration;
-        if ((ma_uint64)frameCountInThisIteration > (frameCountIn - framesProcessedIn)) {
-            frameCountInThisIteration = (unsigned int)(frameCountIn - framesProcessedIn);
-        }
-
-        frameCountOutThisIteration = framesPerIteration;
-        if ((ma_uint64)frameCountOutThisIteration > (frameCountOut - framesProcessedOut)) {
-            frameCountOutThisIteration = (unsigned int)(frameCountOut - framesProcessedOut);
-        }
-
-        pFramesInThisIteration  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels));
-        pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels));
-
-        if (pResampler->config.format == ma_format_f32) {
-            speexErr = speex_resampler_process_interleaved_float((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, (const float*)pFramesInThisIteration, &frameCountInThisIteration, (float*)pFramesOutThisIteration, &frameCountOutThisIteration);
-        } else if (pResampler->config.format == ma_format_s16) {
-            speexErr = speex_resampler_process_interleaved_int((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, (const spx_int16_t*)pFramesInThisIteration, &frameCountInThisIteration, (spx_int16_t*)pFramesOutThisIteration, &frameCountOutThisIteration);
-        } else {
-            /* Format not supported. Should never get here. */
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;
-        }
-
-        if (speexErr != RESAMPLER_ERR_SUCCESS) {
-            return ma_result_from_speex_err(speexErr);
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-    }
-
-    *pFrameCountOut = framesProcessedOut;
-    *pFrameCountIn  = framesProcessedIn;
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_resampler_process_pcm_frames__read(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    /* pFramesOut is not NULL, which means we must have a capacity. */
-    if (pFrameCountOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* It doesn't make sense to not have any input frames to process. */
-    if (pFrameCountIn == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_resampler_process_pcm_frames__read__linear(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_resampler_process_pcm_frames__read__speex(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_ARGS;
-}
-
-
-static ma_result ma_resampler_process_pcm_frames__seek__linear(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    /* Seeking is supported natively by the linear resampler. */
-    return ma_linear_resampler_process_pcm_frames(&pResampler->state.linear, pFramesIn, pFrameCountIn, NULL, pFrameCountOut);
-}
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-static ma_result ma_resampler_process_pcm_frames__seek__speex(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    /* The generic seek method is implemented in on top of ma_resampler_process_pcm_frames__read() by just processing into a dummy buffer. */
-    float devnull[4096];
-    ma_uint64 totalOutputFramesToProcess;
-    ma_uint64 totalOutputFramesProcessed;
-    ma_uint64 totalInputFramesProcessed;
-    ma_uint32 bpf;
-    ma_result result;
-
-    MA_ASSERT(pResampler != NULL);
-
-    totalOutputFramesProcessed = 0;
-    totalInputFramesProcessed = 0;
-    bpf = ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels);
-
-    if (pFrameCountOut != NULL) {
-        /* Seek by output frames. */
-        totalOutputFramesToProcess = *pFrameCountOut;
-    } else {
-        /* Seek by input frames. */
-        MA_ASSERT(pFrameCountIn != NULL);
-        totalOutputFramesToProcess = ma_resampler_get_expected_output_frame_count(pResampler, *pFrameCountIn);
-    }
-
-    if (pFramesIn != NULL) {
-        /* Process input data. */
-        MA_ASSERT(pFrameCountIn != NULL);
-        while (totalOutputFramesProcessed < totalOutputFramesToProcess && totalInputFramesProcessed < *pFrameCountIn) {
-            ma_uint64 inputFramesToProcessThisIteration  = (*pFrameCountIn - totalInputFramesProcessed);
-            ma_uint64 outputFramesToProcessThisIteration = (totalOutputFramesToProcess - totalOutputFramesProcessed);
-            if (outputFramesToProcessThisIteration > sizeof(devnull) / bpf) {
-                outputFramesToProcessThisIteration = sizeof(devnull) / bpf;
-            }
-
-            result = ma_resampler_process_pcm_frames__read(pResampler, ma_offset_ptr(pFramesIn, totalInputFramesProcessed*bpf), &inputFramesToProcessThisIteration, ma_offset_ptr(devnull, totalOutputFramesProcessed*bpf), &outputFramesToProcessThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            totalOutputFramesProcessed += outputFramesToProcessThisIteration;
-            totalInputFramesProcessed  += inputFramesToProcessThisIteration;
-        }
-    } else {
-        /* Don't process input data - just update timing and filter state as if zeroes were passed in. */
-        while (totalOutputFramesProcessed < totalOutputFramesToProcess) {
-            ma_uint64 inputFramesToProcessThisIteration  = 16384;
-            ma_uint64 outputFramesToProcessThisIteration = (totalOutputFramesToProcess - totalOutputFramesProcessed);
-            if (outputFramesToProcessThisIteration > sizeof(devnull) / bpf) {
-                outputFramesToProcessThisIteration = sizeof(devnull) / bpf;
-            }
-
-            result = ma_resampler_process_pcm_frames__read(pResampler, NULL, &inputFramesToProcessThisIteration, ma_offset_ptr(devnull, totalOutputFramesProcessed*bpf), &outputFramesToProcessThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            totalOutputFramesProcessed += outputFramesToProcessThisIteration;
-            totalInputFramesProcessed  += inputFramesToProcessThisIteration;
-        }
-    }
-
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = totalInputFramesProcessed;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = totalOutputFramesProcessed;
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_resampler_process_pcm_frames__seek(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_resampler_process_pcm_frames__seek__linear(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_resampler_process_pcm_frames__seek__speex(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-        #else
-            break;
-        #endif
-        };
-
-        default: break;
-    }
-
-    /* Should never hit this. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_ARGS;
-}
-
-
-MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFrameCountOut == NULL && pFrameCountIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesOut != NULL) {
-        /* Reading. */
-        return ma_resampler_process_pcm_frames__read(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Seeking. */
-        return ma_resampler_process_pcm_frames__seek(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-    }
-}
-
-MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (sampleRateIn == 0 || sampleRateOut == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config.sampleRateIn  = sampleRateIn;
-    pResampler->config.sampleRateOut = sampleRateOut;
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_set_rate(&pResampler->state.linear, sampleRateIn, sampleRateOut);
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_result_from_speex_err(speex_resampler_set_rate((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, sampleRateIn, sampleRateOut));
-        #else
-            break;
-        #endif
-        };
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_OPERATION;
-}
-
-MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pResampler->config.algorithm == ma_resample_algorithm_linear) {
-        return ma_linear_resampler_set_rate_ratio(&pResampler->state.linear, ratio);
-    } else {
-        /* Getting here means the backend does not have native support for setting the rate as a ratio so we just do it generically. */
-        ma_uint32 n;
-        ma_uint32 d;
-
-        d = 1000;
-        n = (ma_uint32)(ratio * d);
-
-        if (n == 0) {
-            return MA_INVALID_ARGS; /* Ratio too small. */
-        }
-
-        MA_ASSERT(n != 0);
-
-        return ma_resampler_set_rate(pResampler, n, d);
-    }
-}
-
-MA_API ma_uint64 ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    if (outputFrameCount == 0) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_required_input_frame_count(&pResampler->state.linear, outputFrameCount);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            spx_uint64_t count;
-            int speexErr = ma_speex_resampler_get_required_input_frame_count((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, outputFrameCount, &count);
-            if (speexErr != RESAMPLER_ERR_SUCCESS) {
-                return 0;
-            }
-
-            return (ma_uint64)count;
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount)
-{
-    if (pResampler == NULL) {
-        return 0;   /* Invalid args. */
-    }
-
-    if (inputFrameCount == 0) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_expected_output_frame_count(&pResampler->state.linear, inputFrameCount);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            spx_uint64_t count;
-            int speexErr = ma_speex_resampler_get_expected_output_frame_count((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, inputFrameCount, &count);
-            if (speexErr != RESAMPLER_ERR_SUCCESS) {
-                return 0;
-            }
-
-            return (ma_uint64)count;
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_input_latency(&pResampler->state.linear);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return (ma_uint64)ma_speex_resampler_get_input_latency((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_output_latency(&pResampler->state.linear);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return (ma_uint64)ma_speex_resampler_get_output_latency((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-/**************************************************************************************************************************************************************
-
-Channel Conversion
-
-**************************************************************************************************************************************************************/
-#ifndef MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT
-#define MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT  12
-#endif
-
-#define MA_PLANE_LEFT      0
-#define MA_PLANE_RIGHT     1
-#define MA_PLANE_FRONT     2
-#define MA_PLANE_BACK      3
-#define MA_PLANE_BOTTOM    4
-#define MA_PLANE_TOP       5
-
-static float g_maChannelPlaneRatios[MA_CHANNEL_POSITION_COUNT][6] = {
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_NONE */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_MONO */
-    { 0.5f,  0.0f,  0.5f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_LEFT */
-    { 0.0f,  0.5f,  0.5f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_RIGHT */
-    { 0.0f,  0.0f,  1.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_CENTER */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_LFE */
-    { 0.5f,  0.0f,  0.0f,  0.5f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_LEFT */
-    { 0.0f,  0.5f,  0.0f,  0.5f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_RIGHT */
-    { 0.25f, 0.0f,  0.75f, 0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_LEFT_CENTER */
-    { 0.0f,  0.25f, 0.75f, 0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_RIGHT_CENTER */
-    { 0.0f,  0.0f,  0.0f,  1.0f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_CENTER */
-    { 1.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_SIDE_LEFT */
-    { 0.0f,  1.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_SIDE_RIGHT */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  1.0f},  /* MA_CHANNEL_TOP_CENTER */
-    { 0.33f, 0.0f,  0.33f, 0.0f,  0.0f,  0.34f}, /* MA_CHANNEL_TOP_FRONT_LEFT */
-    { 0.0f,  0.0f,  0.5f,  0.0f,  0.0f,  0.5f},  /* MA_CHANNEL_TOP_FRONT_CENTER */
-    { 0.0f,  0.33f, 0.33f, 0.0f,  0.0f,  0.34f}, /* MA_CHANNEL_TOP_FRONT_RIGHT */
-    { 0.33f, 0.0f,  0.0f,  0.33f, 0.0f,  0.34f}, /* MA_CHANNEL_TOP_BACK_LEFT */
-    { 0.0f,  0.0f,  0.0f,  0.5f,  0.0f,  0.5f},  /* MA_CHANNEL_TOP_BACK_CENTER */
-    { 0.0f,  0.33f, 0.0f,  0.33f, 0.0f,  0.34f}, /* MA_CHANNEL_TOP_BACK_RIGHT */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_0 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_1 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_2 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_3 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_4 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_5 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_6 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_7 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_8 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_9 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_10 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_11 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_12 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_13 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_14 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_15 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_16 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_17 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_18 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_19 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_20 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_21 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_22 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_23 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_24 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_25 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_26 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_27 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_28 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_29 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_30 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_31 */
-};
-
-static float ma_calculate_channel_position_rectangular_weight(ma_channel channelPositionA, ma_channel channelPositionB)
-{
-    /*
-    Imagine the following simplified example: You have a single input speaker which is the front/left speaker which you want to convert to
-    the following output configuration:
-
-     - front/left
-     - side/left
-     - back/left
-
-    The front/left output is easy - it the same speaker position so it receives the full contribution of the front/left input. The amount
-    of contribution to apply to the side/left and back/left speakers, however, is a bit more complicated.
-
-    Imagine the front/left speaker as emitting audio from two planes - the front plane and the left plane. You can think of the front/left
-    speaker emitting half of it's total volume from the front, and the other half from the left. Since part of it's volume is being emitted
-    from the left side, and the side/left and back/left channels also emit audio from the left plane, one would expect that they would
-    receive some amount of contribution from front/left speaker. The amount of contribution depends on how many planes are shared between
-    the two speakers. Note that in the examples below I've added a top/front/left speaker as an example just to show how the math works
-    across 3 spatial dimensions.
-
-    The first thing to do is figure out how each speaker's volume is spread over each of plane:
-     - front/left:     2 planes (front and left)      = 1/2 = half it's total volume on each plane
-     - side/left:      1 plane (left only)            = 1/1 = entire volume from left plane
-     - back/left:      2 planes (back and left)       = 1/2 = half it's total volume on each plane
-     - top/front/left: 3 planes (top, front and left) = 1/3 = one third it's total volume on each plane
-
-    The amount of volume each channel contributes to each of it's planes is what controls how much it is willing to given and take to other
-    channels on the same plane. The volume that is willing to the given by one channel is multiplied by the volume that is willing to be
-    taken by the other to produce the final contribution.
-    */
-
-    /* Contribution = Sum(Volume to Give * Volume to Take) */
-    float contribution =
-        g_maChannelPlaneRatios[channelPositionA][0] * g_maChannelPlaneRatios[channelPositionB][0] +
-        g_maChannelPlaneRatios[channelPositionA][1] * g_maChannelPlaneRatios[channelPositionB][1] +
-        g_maChannelPlaneRatios[channelPositionA][2] * g_maChannelPlaneRatios[channelPositionB][2] +
-        g_maChannelPlaneRatios[channelPositionA][3] * g_maChannelPlaneRatios[channelPositionB][3] +
-        g_maChannelPlaneRatios[channelPositionA][4] * g_maChannelPlaneRatios[channelPositionB][4] +
-        g_maChannelPlaneRatios[channelPositionA][5] * g_maChannelPlaneRatios[channelPositionB][5];
-
-    return contribution;
-}
-
-MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode)
-{
-    ma_channel_converter_config config;
-
-    /* Channel counts need to be clamped. */
-    channelsIn  = ma_min(channelsIn,  ma_countof(config.channelMapIn));
-    channelsOut = ma_min(channelsOut, ma_countof(config.channelMapOut));
-
-    MA_ZERO_OBJECT(&config);
-    config.format      = format;
-    config.channelsIn  = channelsIn;
-    config.channelsOut = channelsOut;
-    ma_channel_map_copy_or_default(config.channelMapIn,  pChannelMapIn,  channelsIn);
-    ma_channel_map_copy_or_default(config.channelMapOut, pChannelMapOut, channelsOut);
-    config.mixingMode  = mixingMode;
-
-    return config;
-}
-
-static ma_int32 ma_channel_converter_float_to_fixed(float x)
-{
-    return (ma_int32)(x * (1<<MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT));
-}
-
-static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition)
-{
-    int i;
-
-    if (channelPosition == MA_CHANNEL_NONE || channelPosition == MA_CHANNEL_MONO || channelPosition == MA_CHANNEL_LFE) {
-        return MA_FALSE;
-    }
-
-    for (i = 0; i < 6; ++i) {   /* Each side of a cube. */
-        if (g_maChannelPlaneRatios[channelPosition][i] != 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter)
-{
-    ma_uint32 iChannelIn;
-    ma_uint32 iChannelOut;
-
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pConverter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Basic validation for channel counts. */
-    if (pConfig->channelsIn  < MA_MIN_CHANNELS || pConfig->channelsIn  > MA_MAX_CHANNELS ||
-        pConfig->channelsOut < MA_MIN_CHANNELS || pConfig->channelsOut > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (!ma_channel_map_valid(pConfig->channelsIn, pConfig->channelMapIn)) {
-        return MA_INVALID_ARGS; /* Invalid input channel map. */
-    }
-    if (!ma_channel_map_valid(pConfig->channelsOut, pConfig->channelMapOut)) {
-        return MA_INVALID_ARGS; /* Invalid output channel map. */
-    }
-
-    pConverter->format      = pConfig->format;
-    pConverter->channelsIn  = pConfig->channelsIn;
-    pConverter->channelsOut = pConfig->channelsOut;
-    ma_channel_map_copy(pConverter->channelMapIn,  pConfig->channelMapIn,  pConfig->channelsIn);
-    ma_channel_map_copy(pConverter->channelMapOut, pConfig->channelMapOut, pConfig->channelsOut);
-    pConverter->mixingMode  = pConfig->mixingMode;
-
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) {
-        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-            if (pConverter->format == ma_format_f32) {
-                pConverter->weights.f32[iChannelIn][iChannelOut] = pConfig->weights[iChannelIn][iChannelOut];
-            } else {
-                pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(pConfig->weights[iChannelIn][iChannelOut]);
-            }
-        }
-    }
-
-
-
-    /* If the input and output channels and channel maps are the same we should use a passthrough. */
-    if (pConverter->channelsIn == pConverter->channelsOut) {
-        if (ma_channel_map_equal(pConverter->channelsIn, pConverter->channelMapIn, pConverter->channelMapOut)) {
-            pConverter->isPassthrough = MA_TRUE;
-        }
-        if (ma_channel_map_blank(pConverter->channelsIn, pConverter->channelMapIn) || ma_channel_map_blank(pConverter->channelsOut, pConverter->channelMapOut)) {
-            pConverter->isPassthrough = MA_TRUE;
-        }
-    }
-
-
-    /*
-    We can use a simple case for expanding the mono channel. This will used when expanding a mono input into any output so long
-    as no LFE is present in the output.
-    */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsIn == 1 && pConverter->channelMapIn[0] == MA_CHANNEL_MONO) {
-            /* Optimal case if no LFE is in the output channel map. */
-            pConverter->isSimpleMonoExpansion = MA_TRUE;
-            if (ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->channelMapOut, MA_CHANNEL_LFE)) {
-                pConverter->isSimpleMonoExpansion = MA_FALSE;
-            }
-        }
-    }
-
-    /* Another optimized case is stereo to mono. */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsOut == 1 && pConverter->channelMapOut[0] == MA_CHANNEL_MONO && pConverter->channelsIn == 2) {
-            /* Optimal case if no LFE is in the input channel map. */
-            pConverter->isStereoToMono = MA_TRUE;
-            if (ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->channelMapIn, MA_CHANNEL_LFE)) {
-                pConverter->isStereoToMono = MA_FALSE;
-            }
-        }
-    }
-
-
-    /*
-    Here is where we do a bit of pre-processing to know how each channel should be combined to make up the output. Rules:
-
-        1) If it's a passthrough, do nothing - it's just a simple memcpy().
-        2) If the channel counts are the same and every channel position in the input map is present in the output map, use a
-           simple shuffle. An example might be different 5.1 channel layouts.
-        3) Otherwise channels are blended based on spatial locality.
-    */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsIn == pConverter->channelsOut) {
-            ma_bool32 areAllChannelPositionsPresent = MA_TRUE;
-            for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                ma_bool32 isInputChannelPositionInOutput = MA_FALSE;
-                for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                    if (pConverter->channelMapIn[iChannelIn] == pConverter->channelMapOut[iChannelOut]) {
-                        isInputChannelPositionInOutput = MA_TRUE;
-                        break;
-                    }
-                }
-
-                if (!isInputChannelPositionInOutput) {
-                    areAllChannelPositionsPresent = MA_FALSE;
-                    break;
-                }
-            }
-
-            if (areAllChannelPositionsPresent) {
-                pConverter->isSimpleShuffle = MA_TRUE;
-
-                /*
-                All the router will be doing is rearranging channels which means all we need to do is use a shuffling table which is just
-                a mapping between the index of the input channel to the index of the output channel.
-                */
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        if (pConverter->channelMapIn[iChannelIn] == pConverter->channelMapOut[iChannelOut]) {
-                            pConverter->shuffleTable[iChannelIn] = (ma_uint8)iChannelOut;
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    /*
-    Here is where weights are calculated. Note that we calculate the weights at all times, even when using a passthrough and simple
-    shuffling. We use different algorithms for calculating weights depending on our mixing mode.
-
-    In simple mode we don't do any blending (except for converting between mono, which is done in a later step). Instead we just
-    map 1:1 matching channels. In this mode, if no channels in the input channel map correspond to anything in the output channel
-    map, nothing will be heard!
-    */
-
-    /* In all cases we need to make sure all channels that are present in both channel maps have a 1:1 mapping. */
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-            ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-            if (channelPosIn == channelPosOut) {
-                if (pConverter->format == ma_format_f32) {
-                    pConverter->weights.f32[iChannelIn][iChannelOut] = 1;
-                } else {
-                    pConverter->weights.s16[iChannelIn][iChannelOut] = (1 << MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT);
-                }
-            }
-        }
-    }
-
-    /*
-    The mono channel is accumulated on all other channels, except LFE. Make sure in this loop we exclude output mono channels since
-    they were handled in the pass above.
-    */
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-        if (channelPosIn == MA_CHANNEL_MONO) {
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (channelPosOut != MA_CHANNEL_NONE && channelPosOut != MA_CHANNEL_MONO && channelPosOut != MA_CHANNEL_LFE) {
-                    if (pConverter->format == ma_format_f32) {
-                        pConverter->weights.f32[iChannelIn][iChannelOut] = 1;
-                    } else {
-                        pConverter->weights.s16[iChannelIn][iChannelOut] = (1 << MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT);
-                    }
-                }
-            }
-        }
-    }
-
-    /* The output mono channel is the average of all non-none, non-mono and non-lfe input channels. */
-    {
-        ma_uint32 len = 0;
-        for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-            ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-            if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) {
-                len += 1;
-            }
-        }
-
-        if (len > 0) {
-            float monoWeight = 1.0f / len;
-
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (channelPosOut == MA_CHANNEL_MONO) {
-                    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                        if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) {
-                            if (pConverter->format == ma_format_f32) {
-                                pConverter->weights.f32[iChannelIn][iChannelOut] = monoWeight;
-                            } else {
-                                pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(monoWeight);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    /* Input and output channels that are not present on the other side need to be blended in based on spatial locality. */
-    switch (pConverter->mixingMode)
-    {
-        case ma_channel_mix_mode_rectangular:
-        {
-            /* Unmapped input channels. */
-            for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                if (ma_is_spatial_channel_position(channelPosIn)) {
-                    if (!ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->channelMapOut, channelPosIn)) {
-                        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                            ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                            if (ma_is_spatial_channel_position(channelPosOut)) {
-                                float weight = 0;
-                                if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) {
-                                    weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut);
-                                }
-
-                                /* Only apply the weight if we haven't already got some contribution from the respective channels. */
-                                if (pConverter->format == ma_format_f32) {
-                                    if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.f32[iChannelIn][iChannelOut] = weight;
-                                    }
-                                } else {
-                                    if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            /* Unmapped output channels. */
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (ma_is_spatial_channel_position(channelPosOut)) {
-                    if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->channelMapIn, channelPosOut)) {
-                        for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                            ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                            if (ma_is_spatial_channel_position(channelPosIn)) {
-                                float weight = 0;
-                                if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) {
-                                    weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut);
-                                }
-
-                                /* Only apply the weight if we haven't already got some contribution from the respective channels. */
-                                if (pConverter->format == ma_format_f32) {
-                                    if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.f32[iChannelIn][iChannelOut] = weight;
-                                    }
-                                } else {
-                                    if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } break;
-
-        case ma_channel_mix_mode_simple:
-        {
-            /* In simple mode, excess channels need to be silenced or dropped. */
-            ma_uint32 iChannel;
-            for (iChannel = 0; iChannel < ma_min(pConverter->channelsIn, pConverter->channelsOut); iChannel += 1) {
-                if (pConverter->format == ma_format_f32) {
-                    if (pConverter->weights.f32[iChannel][iChannel] == 0) {
-                        pConverter->weights.f32[iChannel][iChannel] = 1;
-                    }
-                } else {
-                    if (pConverter->weights.s16[iChannel][iChannel] == 0) {
-                        pConverter->weights.s16[iChannel][iChannel] = ma_channel_converter_float_to_fixed(1);
-                    }
-                }
-            }
-        } break;
-
-        case ma_channel_mix_mode_custom_weights:
-        default:
-        {
-            /* Fallthrough. */
-        } break;
-    }
-
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return;
-    }
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__passthrough(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-
-    ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__simple_shuffle(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 iFrame;
-    ma_uint32 iChannelIn;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn == pConverter->channelsOut);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutU8[pConverter->shuffleTable[iChannelIn]] = pFramesInU8[iChannelIn];
-                }
-
-                pFramesOutU8 += pConverter->channelsOut;
-                pFramesInU8  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutS16[pConverter->shuffleTable[iChannelIn]] = pFramesInS16[iChannelIn];
-                }
-
-                pFramesOutS16 += pConverter->channelsOut;
-                pFramesInS16  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    ma_uint32 iChannelOut = pConverter->shuffleTable[iChannelIn];
-                    pFramesOutS24[iChannelOut*3 + 0] = pFramesInS24[iChannelIn*3 + 0];
-                    pFramesOutS24[iChannelOut*3 + 1] = pFramesInS24[iChannelIn*3 + 1];
-                    pFramesOutS24[iChannelOut*3 + 2] = pFramesInS24[iChannelIn*3 + 2];
-                }
-
-                pFramesOutS24 += pConverter->channelsOut*3;
-                pFramesInS24  += pConverter->channelsIn*3;
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutS32[pConverter->shuffleTable[iChannelIn]] = pFramesInS32[iChannelIn];
-                }
-
-                pFramesOutS32 += pConverter->channelsOut;
-                pFramesInS32  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutF32[pConverter->shuffleTable[iChannelIn]] = pFramesInF32[iChannelIn];
-                }
-
-                pFramesOutF32 += pConverter->channelsOut;
-                pFramesInF32  += pConverter->channelsIn;
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__simple_mono_expansion(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn == 1);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    pFramesOutU8[iFrame*pConverter->channelsOut + iChannel] = pFramesInU8[iFrame];
-                }
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            if (pConverter->channelsOut == 2) {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    pFramesOutS16[iFrame*2 + 0] = pFramesInS16[iFrame];
-                    pFramesOutS16[iFrame*2 + 1] = pFramesInS16[iFrame];
-                }
-            } else {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    ma_uint32 iChannel;
-                    for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                        pFramesOutS16[iFrame*pConverter->channelsOut + iChannel] = pFramesInS16[iFrame];
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    ma_uint64 iSampleOut = iFrame*pConverter->channelsOut + iChannel;
-                    ma_uint64 iSampleIn  = iFrame;
-                    pFramesOutS24[iSampleOut*3 + 0] = pFramesInS24[iSampleIn*3 + 0];
-                    pFramesOutS24[iSampleOut*3 + 1] = pFramesInS24[iSampleIn*3 + 1];
-                    pFramesOutS24[iSampleOut*3 + 2] = pFramesInS24[iSampleIn*3 + 2];
-                }
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    pFramesOutS32[iFrame*pConverter->channelsOut + iChannel] = pFramesInS32[iFrame];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            if (pConverter->channelsOut == 2) {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    pFramesOutF32[iFrame*2 + 0] = pFramesInF32[iFrame];
-                    pFramesOutF32[iFrame*2 + 1] = pFramesInF32[iFrame];
-                }
-            } else {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    ma_uint32 iChannel;
-                    for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                        pFramesOutF32[iFrame*pConverter->channelsOut + iChannel] = pFramesInF32[iFrame];
-                    }
-                }
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__stereo_to_mono(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn  == 2);
-    MA_ASSERT(pConverter->channelsOut == 1);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutU8[iFrame] = ma_clip_u8((ma_int16)((ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8[iFrame*2+0]) + ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8[iFrame*2+1])) / 2));
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutS16[iFrame] = (ma_int16)(((ma_int32)pFramesInS16[iFrame*2+0] + (ma_int32)pFramesInS16[iFrame*2+1]) / 2);
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_int64 s24_0 = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24[(iFrame*2+0)*3]);
-                ma_int64 s24_1 = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24[(iFrame*2+1)*3]);
-                ma_pcm_sample_s32_to_s24_no_scale((s24_0 + s24_1) / 2, &pFramesOutS24[iFrame*3]);
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutS32[iFrame] = (ma_int16)(((ma_int32)pFramesInS32[iFrame*2+0] + (ma_int32)pFramesInS32[iFrame*2+1]) / 2);
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutF32[iFrame] = (pFramesInF32[iFrame*2+0] + pFramesInF32[iFrame*2+0]) * 0.5f;
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__weights(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 iFrame;
-    ma_uint32 iChannelIn;
-    ma_uint32 iChannelOut;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-
-    /* This is the more complicated case. Each of the output channels is accumulated with 0 or more input channels. */
-
-    /* Clear. */
-    ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-
-    /* Accumulate. */
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int16 u8_O = ma_pcm_sample_u8_to_s16_no_scale(pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut]);
-                        ma_int16 u8_I = ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8 [iFrame*pConverter->channelsIn  + iChannelIn ]);
-                        ma_int32 s    = (ma_int32)ma_clamp(u8_O + ((u8_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -128, 127);
-                        pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_u8((ma_int16)s);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int32 s = pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut];
-                        s += (pFramesInS16[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT;
-
-                        pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut] = (ma_int16)ma_clamp(s, -32768, 32767);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int64 s24_O = ma_pcm_sample_s24_to_s32_no_scale(&pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]);
-                        ma_int64 s24_I = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24 [(iFrame*pConverter->channelsIn  + iChannelIn )*3]);
-                        ma_int64 s24   = (ma_int32)ma_clamp(s24_O + ((s24_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -8388608, 8388607);
-                        ma_pcm_sample_s32_to_s24_no_scale(s24, &pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int64 s = pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut];
-                        s += ((ma_int64)pFramesInS32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT;
-
-                        pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_s32(s);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        pFramesOutF32[iFrame*pConverter->channelsOut + iChannelOut] += pFramesInF32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.f32[iChannelIn][iChannelOut];
-                    }
-                }
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesIn == NULL) {
-        ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-        return MA_SUCCESS;
-    }
-
-    if (pConverter->isPassthrough) {
-        return ma_channel_converter_process_pcm_frames__passthrough(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isSimpleShuffle) {
-        return ma_channel_converter_process_pcm_frames__simple_shuffle(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isSimpleMonoExpansion) {
-        return ma_channel_converter_process_pcm_frames__simple_mono_expansion(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isStereoToMono) {
-        return ma_channel_converter_process_pcm_frames__stereo_to_mono(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else {
-        return ma_channel_converter_process_pcm_frames__weights(pConverter, pFramesOut, pFramesIn, frameCount);
-    }
-}
-
-
-/**************************************************************************************************************************************************************
-
-Data Conversion
-
-**************************************************************************************************************************************************************/
-MA_API ma_data_converter_config ma_data_converter_config_init_default()
-{
-    ma_data_converter_config config;
-    MA_ZERO_OBJECT(&config);
-
-    config.ditherMode = ma_dither_mode_none;
-    config.resampling.algorithm = ma_resample_algorithm_linear;
-    config.resampling.allowDynamicSampleRate = MA_FALSE; /* Disable dynamic sample rates by default because dynamic rate adjustments should be quite rare and it allows an optimization for cases when the in and out sample rates are the same. */
-
-    /* Linear resampling defaults. */
-    config.resampling.linear.lpfOrder = 1;
-    config.resampling.linear.lpfNyquistFactor = 1;
-
-    /* Speex resampling defaults. */
-    config.resampling.speex.quality = 3;
-
-    return config;
-}
-
-MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    ma_data_converter_config config = ma_data_converter_config_init_default();
-    config.formatIn      = formatIn;
-    config.formatOut     = formatOut;
-    config.channelsIn    = ma_min(channelsIn,  MA_MAX_CHANNELS);
-    config.channelsOut   = ma_min(channelsOut, MA_MAX_CHANNELS);
-    config.sampleRateIn  = sampleRateIn;
-    config.sampleRateOut = sampleRateOut;
-
-    return config;
-}
-
-MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter)
-{
-    ma_result result;
-    ma_format midFormat;
-
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pConverter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pConverter->config = *pConfig;
-
-    /* Basic validation. */
-    if (pConfig->channelsIn < MA_MIN_CHANNELS || pConfig->channelsOut < MA_MIN_CHANNELS ||
-        pConfig->channelsIn > MA_MAX_CHANNELS || pConfig->channelsOut > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    /*
-    We want to avoid as much data conversion as possible. The channel converter and resampler both support s16 and f32 natively. We need to decide
-    on the format to use for this stage. We call this the mid format because it's used in the middle stage of the conversion pipeline. If the output
-    format is either s16 or f32 we use that one. If that is not the case it will do the same thing for the input format. If it's neither we just
-    use f32.
-    */
-    /*  */ if (pConverter->config.formatOut == ma_format_s16 || pConverter->config.formatOut == ma_format_f32) {
-        midFormat = pConverter->config.formatOut;
-    } else if (pConverter->config.formatIn  == ma_format_s16 || pConverter->config.formatIn  == ma_format_f32) {
-        midFormat = pConverter->config.formatIn;
-    } else {
-        midFormat = ma_format_f32;
-    }
-
-    /* Channel converter. We always initialize this, but we check if it configures itself as a passthrough to determine whether or not it's needed. */
-    {
-        ma_uint32 iChannelIn;
-        ma_uint32 iChannelOut;
-        ma_channel_converter_config channelConverterConfig;
-
-        channelConverterConfig = ma_channel_converter_config_init(midFormat, pConverter->config.channelsIn, pConverter->config.channelMapIn, pConverter->config.channelsOut, pConverter->config.channelMapOut, pConverter->config.channelMixMode);
-
-        /* Channel weights. */
-        for (iChannelIn = 0; iChannelIn < pConverter->config.channelsIn; iChannelIn += 1) {
-            for (iChannelOut = 0; iChannelOut < pConverter->config.channelsOut; iChannelOut += 1) {
-                channelConverterConfig.weights[iChannelIn][iChannelOut] = pConverter->config.channelWeights[iChannelIn][iChannelOut];
-            }
-        }
-
-        result = ma_channel_converter_init(&channelConverterConfig, &pConverter->channelConverter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        /* If the channel converter is not a passthrough we need to enable it. Otherwise we can skip it. */
-        if (pConverter->channelConverter.isPassthrough == MA_FALSE) {
-            pConverter->hasChannelConverter = MA_TRUE;
-        }
-    }
-
-
-    /* Always enable dynamic sample rates if the input sample rate is different because we're always going to need a resampler in this case anyway. */
-    if (pConverter->config.resampling.allowDynamicSampleRate == MA_FALSE) {
-        pConverter->config.resampling.allowDynamicSampleRate = pConverter->config.sampleRateIn != pConverter->config.sampleRateOut;
-    }
-
-    /* Resampler. */
-    if (pConverter->config.resampling.allowDynamicSampleRate) {
-        ma_resampler_config resamplerConfig;
-        ma_uint32 resamplerChannels;
-
-        /* The resampler is the most expensive part of the conversion process, so we need to do it at the stage where the channel count is at it's lowest. */
-        if (pConverter->config.channelsIn < pConverter->config.channelsOut) {
-            resamplerChannels = pConverter->config.channelsIn;
-        } else {
-            resamplerChannels = pConverter->config.channelsOut;
-        }
-
-        resamplerConfig = ma_resampler_config_init(midFormat, resamplerChannels, pConverter->config.sampleRateIn, pConverter->config.sampleRateOut, pConverter->config.resampling.algorithm);
-        resamplerConfig.linear.lpfOrder         = pConverter->config.resampling.linear.lpfOrder;
-        resamplerConfig.linear.lpfNyquistFactor = pConverter->config.resampling.linear.lpfNyquistFactor;
-        resamplerConfig.speex.quality           = pConverter->config.resampling.speex.quality;
-
-        result = ma_resampler_init(&resamplerConfig, &pConverter->resampler);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pConverter->hasResampler = MA_TRUE;
-    }
-
-
-    /* We can simplify pre- and post-format conversion if we have neither channel conversion nor resampling. */
-    if (pConverter->hasChannelConverter == MA_FALSE && pConverter->hasResampler == MA_FALSE) {
-        /* We have neither channel conversion nor resampling so we'll only need one of pre- or post-format conversion, or none if the input and output formats are the same. */
-        if (pConverter->config.formatIn == pConverter->config.formatOut) {
-            /* The formats are the same so we can just pass through. */
-            pConverter->hasPreFormatConversion  = MA_FALSE;
-            pConverter->hasPostFormatConversion = MA_FALSE;
-        } else {
-            /* The formats are different so we need to do either pre- or post-format conversion. It doesn't matter which. */
-            pConverter->hasPreFormatConversion  = MA_FALSE;
-            pConverter->hasPostFormatConversion = MA_TRUE;
-        }
-    } else {
-        /* We have a channel converter and/or resampler so we'll need channel conversion based on the mid format. */
-        if (pConverter->config.formatIn != midFormat) {
-            pConverter->hasPreFormatConversion = MA_TRUE;
-        }
-        if (pConverter->config.formatOut != midFormat) {
-            pConverter->hasPostFormatConversion = MA_TRUE;
-        }
-    }
-
-    /* We can enable passthrough optimizations if applicable. Note that we'll only be able to do this if the sample rate is static. */
-    if (pConverter->hasPreFormatConversion  == MA_FALSE &&
-        pConverter->hasPostFormatConversion == MA_FALSE &&
-        pConverter->hasChannelConverter     == MA_FALSE &&
-        pConverter->hasResampler            == MA_FALSE) {
-        pConverter->isPassthrough = MA_TRUE;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_data_converter_uninit(ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return;
-    }
-
-    if (pConverter->hasResampler) {
-        ma_resampler_uninit(&pConverter->resampler);
-    }
-}
-
-static ma_result ma_data_converter_process_pcm_frames__passthrough(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pFramesOut != NULL) {
-        if (pFramesIn != NULL) {
-            ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        } else {
-            ma_zero_memory_64(pFramesOut,            frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__format_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pFramesOut != NULL) {
-        if (pFramesIn != NULL) {
-            ma_convert_pcm_frames_format(pFramesOut, pConverter->config.formatOut, pFramesIn, pConverter->config.formatIn, frameCount, pConverter->config.channelsIn, pConverter->config.ditherMode);
-        } else {
-            ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conversion(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-        const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-        const void* pFramesInThisIteration;
-        /* */ void* pFramesOutThisIteration;
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-
-        if (pFramesIn != NULL) {
-            pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        } else {
-            pFramesInThisIteration = NULL;
-        }
-
-        if (pFramesOut != NULL) {
-            pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        } else {
-            pFramesOutThisIteration = NULL;
-        }
-
-        /* Do a pre format conversion if necessary. */
-        if (pConverter->hasPreFormatConversion) {
-            ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-
-            frameCountInThisIteration  = (frameCountIn - framesProcessedIn);
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-
-            if (pConverter->hasPostFormatConversion) {
-               if (frameCountInThisIteration > tempBufferOutCap) {
-                   frameCountInThisIteration = tempBufferOutCap;
-               }
-            }
-
-            if (pFramesInThisIteration != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.config.format, pFramesInThisIteration, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-            } else {
-                MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn));
-            }
-
-            frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-
-            if (pConverter->hasPostFormatConversion) {
-                /* Both input and output conversion required. Output to the temp buffer. */
-                if (frameCountOutThisIteration > tempBufferOutCap) {
-                    frameCountOutThisIteration = tempBufferOutCap;
-                }
-
-                result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration);
-            } else {
-                /* Only pre-format required. Output straight to the output buffer. */
-                result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pFramesOutThisIteration, &frameCountOutThisIteration);
-            }
-
-            if (result != MA_SUCCESS) {
-                break;
-            }
-        } else {
-            /* No pre-format required. Just read straight from the input buffer. */
-            MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE);
-
-            frameCountInThisIteration  = (frameCountIn  - framesProcessedIn);
-            frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-
-            result = ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesInThisIteration, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-        }
-
-        /* If we are doing a post format conversion we need to do that now. */
-        if (pConverter->hasPostFormatConversion) {
-            if (pFramesOutThisIteration != NULL) {
-                ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->config.formatOut, pTempBufferOut, pConverter->resampler.config.format, frameCountOutThisIteration, pConverter->resampler.config.channels, pConverter->config.ditherMode);
-            }
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return result;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__resample_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pConverter != NULL);
-
-    if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) {
-        /* Neither pre- nor post-format required. This is simple case where only resampling is required. */
-        return ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Format conversion required. */
-        return ma_data_converter_process_pcm_frames__resample_with_format_conversion(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) {
-        /* No format conversion required. */
-        result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOut, pFramesIn, frameCount);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    } else {
-        /* Format conversion required. */
-        ma_uint64 framesProcessed = 0;
-
-        while (framesProcessed < frameCount) {
-            ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-            const void* pFramesInThisIteration;
-            /* */ void* pFramesOutThisIteration;
-            ma_uint64 frameCountThisIteration;
-
-            if (pFramesIn != NULL) {
-                pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessed * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-            } else {
-                pFramesInThisIteration = NULL;
-            }
-
-            if (pFramesOut != NULL) {
-                pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessed * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-            } else {
-                pFramesOutThisIteration = NULL;
-            }
-
-            /* Do a pre format conversion if necessary. */
-            if (pConverter->hasPreFormatConversion) {
-                ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn);
-
-                frameCountThisIteration = (frameCount - framesProcessed);
-                if (frameCountThisIteration > tempBufferInCap) {
-                    frameCountThisIteration = tempBufferInCap;
-                }
-
-                if (pConverter->hasPostFormatConversion) {
-                    if (frameCountThisIteration > tempBufferOutCap) {
-                        frameCountThisIteration = tempBufferOutCap;
-                    }
-                }
-
-                if (pFramesInThisIteration != NULL) {
-                    ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pFramesInThisIteration, pConverter->config.formatIn, frameCountThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                } else {
-                    MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn));
-                }
-
-                if (pConverter->hasPostFormatConversion) {
-                    /* Both input and output conversion required. Output to the temp buffer. */
-                    result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pTempBufferIn, frameCountThisIteration);
-                } else {
-                    /* Only pre-format required. Output straight to the output buffer. */
-                    result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOutThisIteration, pTempBufferIn, frameCountThisIteration);
-                }
-
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            } else {
-                /* No pre-format required. Just read straight from the input buffer. */
-                MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE);
-
-                frameCountThisIteration = (frameCount - framesProcessed);
-                if (frameCountThisIteration > tempBufferOutCap) {
-                    frameCountThisIteration = tempBufferOutCap;
-                }
-
-                result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pFramesInThisIteration, frameCountThisIteration);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            }
-
-            /* If we are doing a post format conversion we need to do that now. */
-            if (pConverter->hasPostFormatConversion) {
-                if (pFramesOutThisIteration != NULL) {
-                    ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->config.formatOut, pTempBufferOut, pConverter->channelConverter.format, frameCountThisIteration, pConverter->channelConverter.channelsOut, pConverter->config.ditherMode);
-                }
-            }
-
-            framesProcessed += frameCountThisIteration;
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__resampling_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint8  pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];   /* In resampler format. */
-    ma_uint64 tempBufferInCap;
-    ma_uint8  pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In resampler format, channel converter input format. */
-    ma_uint64 tempBufferMidCap;
-    ma_uint8  pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In channel converter output format. */
-    ma_uint64 tempBufferOutCap;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pConverter->resampler.config.format   == pConverter->channelConverter.format);
-    MA_ASSERT(pConverter->resampler.config.channels == pConverter->channelConverter.channelsIn);
-    MA_ASSERT(pConverter->resampler.config.channels <  pConverter->channelConverter.channelsOut);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    tempBufferInCap  = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-    tempBufferMidCap = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-    tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-        const void* pRunningFramesIn = NULL;
-        void* pRunningFramesOut = NULL;
-        const void* pResampleBufferIn;
-        void* pChannelsBufferOut;
-
-        if (pFramesIn != NULL) {
-            pRunningFramesIn  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        }
-        if (pFramesOut != NULL) {
-            pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-
-        /* Run input data through the resampler and output it to the temporary buffer. */
-        frameCountInThisIteration = (frameCountIn - framesProcessedIn);
-
-        if (pConverter->hasPreFormatConversion) {
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-        }
-
-        frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-        if (frameCountOutThisIteration > tempBufferMidCap) {
-            frameCountOutThisIteration = tempBufferMidCap;
-        }
-
-        /* We can't read more frames than can fit in the output buffer. */
-        if (pConverter->hasPostFormatConversion) {
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-        }
-
-        /* We need to ensure we don't try to process too many input frames that we run out of room in the output buffer. If this happens we'll end up glitching. */
-        {
-            ma_uint64 requiredInputFrameCount = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration);
-            if (frameCountInThisIteration > requiredInputFrameCount) {
-                frameCountInThisIteration = requiredInputFrameCount;
-            }
-        }
-
-        if (pConverter->hasPreFormatConversion) {
-            if (pFramesIn != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.config.format, pRunningFramesIn, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                pResampleBufferIn = pTempBufferIn;
-            } else {
-                pResampleBufferIn = NULL;
-            }
-        } else {
-            pResampleBufferIn = pRunningFramesIn;
-        }
-
-        result = ma_resampler_process_pcm_frames(&pConverter->resampler, pResampleBufferIn, &frameCountInThisIteration, pTempBufferMid, &frameCountOutThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-
-        /*
-        The input data has been resampled so now we need to run it through the channel converter. The input data is always contained in pTempBufferMid. We only need to do
-        this part if we have an output buffer.
-        */
-        if (pFramesOut != NULL) {
-            if (pConverter->hasPostFormatConversion) {
-                pChannelsBufferOut = pTempBufferOut;
-            } else {
-                pChannelsBufferOut = pRunningFramesOut;
-            }
-
-            result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pChannelsBufferOut, pTempBufferMid, frameCountOutThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            /* Finally we do post format conversion. */
-            if (pConverter->hasPostFormatConversion) {
-                ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->config.formatOut, pChannelsBufferOut, pConverter->channelConverter.format, frameCountOutThisIteration, pConverter->channelConverter.channelsOut, pConverter->config.ditherMode);
-            }
-        }
-
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint8  pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];   /* In resampler format. */
-    ma_uint64 tempBufferInCap;
-    ma_uint8  pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In resampler format, channel converter input format. */
-    ma_uint64 tempBufferMidCap;
-    ma_uint8  pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In channel converter output format. */
-    ma_uint64 tempBufferOutCap;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pConverter->resampler.config.format   == pConverter->channelConverter.format);
-    MA_ASSERT(pConverter->resampler.config.channels == pConverter->channelConverter.channelsOut);
-    MA_ASSERT(pConverter->resampler.config.channels <  pConverter->channelConverter.channelsIn);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    tempBufferInCap  = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn);
-    tempBufferMidCap = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-    tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-        const void* pRunningFramesIn = NULL;
-        void* pRunningFramesOut = NULL;
-        const void* pChannelsBufferIn;
-        void* pResampleBufferOut;
-
-        if (pFramesIn != NULL) {
-            pRunningFramesIn  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        }
-        if (pFramesOut != NULL) {
-            pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-
-        /* Run input data through the channel converter and output it to the temporary buffer. */
-        frameCountInThisIteration = (frameCountIn - framesProcessedIn);
-
-        if (pConverter->hasPreFormatConversion) {
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-
-            if (pRunningFramesIn != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pRunningFramesIn, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                pChannelsBufferIn = pTempBufferIn;
-            } else {
-                pChannelsBufferIn = NULL;
-            }
-        } else {
-            pChannelsBufferIn = pRunningFramesIn;
-        }
-
-        /*
-        We can't convert more frames than will fit in the output buffer. We shouldn't actually need to do this check because the channel count is always reduced
-        in this case which means we should always have capacity, but I'm leaving it here just for safety for future maintenance.
-        */
-        if (frameCountInThisIteration > tempBufferMidCap) {
-            frameCountInThisIteration = tempBufferMidCap;
-        }
-
-        /*
-        Make sure we don't read any more input frames than we need to fill the output frame count. If we do this we will end up in a situation where we lose some
-        input samples and will end up glitching.
-        */
-        frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-        if (frameCountOutThisIteration > tempBufferMidCap) {
-            frameCountOutThisIteration = tempBufferMidCap;
-        }
-
-        if (pConverter->hasPostFormatConversion) {
-            ma_uint64 requiredInputFrameCount;
-
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-
-            requiredInputFrameCount = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration);
-            if (frameCountInThisIteration > requiredInputFrameCount) {
-                frameCountInThisIteration = requiredInputFrameCount;
-            }
-        }
-
-        result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferMid, pChannelsBufferIn, frameCountInThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-
-        /* At this point we have converted the channels to the output channel count which we now need to resample. */
-        if (pConverter->hasPostFormatConversion) {
-            pResampleBufferOut = pTempBufferOut;
-        } else {
-            pResampleBufferOut = pRunningFramesOut;
-        }
-
-        result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferMid, &frameCountInThisIteration, pResampleBufferOut, &frameCountOutThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        /* Finally we can do the post format conversion. */
-        if (pConverter->hasPostFormatConversion) {
-            if (pRunningFramesOut != NULL) {
-                ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->config.formatOut, pResampleBufferOut, pConverter->resampler.config.format, frameCountOutThisIteration, pConverter->config.channelsOut, pConverter->config.ditherMode);
-            }
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->isPassthrough) {
-        return ma_data_converter_process_pcm_frames__passthrough(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-
-    /*
-    Here is where the real work is done. Getting here means we're not using a passthrough and we need to move the data through each of the relevant stages. The order
-    of our stages depends on the input and output channel count. If the input channels is less than the output channels we want to do sample rate conversion first so
-    that it has less work (resampling is the most expensive part of format conversion).
-    */
-    if (pConverter->config.channelsIn < pConverter->config.channelsOut) {
-        /* Do resampling first, if necessary. */
-        MA_ASSERT(pConverter->hasChannelConverter == MA_TRUE);
-
-        if (pConverter->hasResampler) {
-            /* Resampling first. */
-            return ma_data_converter_process_pcm_frames__resampling_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        } else {
-            /* Resampling not required. */
-            return ma_data_converter_process_pcm_frames__channels_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        }
-    } else {
-        /* Do channel conversion first, if necessary. */
-        if (pConverter->hasChannelConverter) {
-            if (pConverter->hasResampler) {
-                /* Channel routing first. */
-                return ma_data_converter_process_pcm_frames__channels_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            } else {
-                /* Resampling not required. */
-                return ma_data_converter_process_pcm_frames__channels_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            }
-        } else {
-            /* Channel routing not required. */
-            if (pConverter->hasResampler) {
-                /* Resampling only. */
-                return ma_data_converter_process_pcm_frames__resample_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            } else {
-                /* No channel routing nor resampling required. Just format conversion. */
-                return ma_data_converter_process_pcm_frames__format_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            }
-        }
-    }
-}
-
-MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->hasResampler == MA_FALSE) {
-        return MA_INVALID_OPERATION;    /* Dynamic resampling not enabled. */
-    }
-
-    return ma_resampler_set_rate(&pConverter->resampler, sampleRateIn, sampleRateOut);
-}
-
-MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->hasResampler == MA_FALSE) {
-        return MA_INVALID_OPERATION;    /* Dynamic resampling not enabled. */
-    }
-
-    return ma_resampler_set_rate_ratio(&pConverter->resampler, ratioInOut);
-}
-
-MA_API ma_uint64 ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_required_input_frame_count(&pConverter->resampler, outputFrameCount);
-    } else {
-        return outputFrameCount;    /* 1:1 */
-    }
-}
-
-MA_API ma_uint64 ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_expected_output_frame_count(&pConverter->resampler, inputFrameCount);
-    } else {
-        return inputFrameCount;     /* 1:1 */
-    }
-}
-
-MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_input_latency(&pConverter->resampler);
-    }
-
-    return 0;   /* No latency without a resampler. */
-}
-
-MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_output_latency(&pConverter->resampler);
-    }
-
-    return 0;   /* No latency without a resampler. */
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Channel Maps
-
-**************************************************************************************************************************************************************/
-MA_API void ma_channel_map_init_blank(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (pChannelMap == NULL) {
-        return;
-    }
-
-    MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channels);
-}
-
-static void ma_get_standard_channel_map_microsoft(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    /* Based off the speaker configurations mentioned here: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ksmedia/ns-ksmedia-ksaudio_channel_config */
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-        } break;
-
-        case 3: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-#ifndef MA_USE_QUAD_MICROSOFT_CHANNEL_MAP
-            /* Surround. Using the Surround profile has the advantage of the 3rd channel (MA_CHANNEL_FRONT_CENTER) mapping nicely with higher channel counts. */
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_CENTER;
-#else
-            /* Quad. */
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-#endif
-        } break;
-
-        case 5: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[5] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 7: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[5] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_alsa(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_rfc3551(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 6; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-6));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_flac(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[5] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_vorbis(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    /* In Vorbis' type 0 channel mapping, the first two channels are not always the standard left/right - it will have the center speaker where the right usually goes. Why?! */
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[6] = MA_CHANNEL_LFE;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[6] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[7] = MA_CHANNEL_LFE;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_sound4(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[6] = MA_CHANNEL_LFE;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_sndio(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 6) {
-        ma_uint32 iChannel;
-        for (iChannel = 6; iChannel < channels && iChannel < MA_MAX_CHANNELS; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-6));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-MA_API void ma_get_standard_channel_map(ma_standard_channel_map standardChannelMap, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (standardChannelMap)
-    {
-        case ma_standard_channel_map_alsa:
-        {
-            ma_get_standard_channel_map_alsa(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_rfc3551:
-        {
-            ma_get_standard_channel_map_rfc3551(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_flac:
-        {
-            ma_get_standard_channel_map_flac(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_vorbis:
-        {
-            ma_get_standard_channel_map_vorbis(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_sound4:
-        {
-            ma_get_standard_channel_map_sound4(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_sndio:
-        {
-            ma_get_standard_channel_map_sndio(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_microsoft: /* Also default. */
-        /*case ma_standard_channel_map_default;*/
-        default:
-        {
-            ma_get_standard_channel_map_microsoft(channels, pChannelMap);
-        } break;
-    }
-}
-
-MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels)
-{
-    if (pOut != NULL && pIn != NULL && channels > 0) {
-        MA_COPY_MEMORY(pOut, pIn, sizeof(*pOut) * channels);
-    }
-}
-
-MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels)
-{
-    if (pOut == NULL || channels == 0) {
-        return;
-    }
-
-    if (pIn != NULL) {
-        ma_channel_map_copy(pOut, pIn, channels);
-    } else {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, channels, pOut);
-    }
-}
-
-MA_API ma_bool32 ma_channel_map_valid(ma_uint32 channels, const ma_channel* pChannelMap)
-{
-    if (pChannelMap == NULL) {
-        return MA_FALSE;
-    }
-
-    /* A channel count of 0 is invalid. */
-    if (channels == 0) {
-        return MA_FALSE;
-    }
-
-    /* It does not make sense to have a mono channel when there is more than 1 channel. */
-    if (channels > 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; ++iChannel) {
-            if (pChannelMap[iChannel] == MA_CHANNEL_MONO) {
-                return MA_FALSE;
-            }
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_equal(ma_uint32 channels, const ma_channel* pChannelMapA, const ma_channel* pChannelMapB)
-{
-    ma_uint32 iChannel;
-
-    if (pChannelMapA == pChannelMapB) {
-        return MA_TRUE;
-    }
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMapA[iChannel] != pChannelMapB[iChannel]) {
-            return MA_FALSE;
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_blank(ma_uint32 channels, const ma_channel* pChannelMap)
-{
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMap[iChannel] != MA_CHANNEL_NONE) {
-            return MA_FALSE;
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition)
-{
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMap[iChannel] == channelPosition) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Conversion Helpers
-
-**************************************************************************************************************************************************************/
-MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn)
-{
-    ma_data_converter_config config;
-
-    config = ma_data_converter_config_init(formatIn, formatOut, channelsIn, channelsOut, sampleRateIn, sampleRateOut);
-    ma_get_standard_channel_map(ma_standard_channel_map_default, channelsOut, config.channelMapOut);
-    ma_get_standard_channel_map(ma_standard_channel_map_default, channelsIn,  config.channelMapIn);
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-
-    return ma_convert_frames_ex(pOut, frameCountOut, pIn, frameCountIn, &config);
-}
-
-MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig)
-{
-    ma_result result;
-    ma_data_converter converter;
-
-    if (frameCountIn == 0 || pConfig == NULL) {
-        return 0;
-    }
-
-    result = ma_data_converter_init(pConfig, &converter);
-    if (result != MA_SUCCESS) {
-        return 0;   /* Failed to initialize the data converter. */
-    }
-
-    if (pOut == NULL) {
-        frameCountOut = ma_data_converter_get_expected_output_frame_count(&converter, frameCountIn);
-    } else {
-        result = ma_data_converter_process_pcm_frames(&converter, pIn, &frameCountIn, pOut, &frameCountOut);
-        if (result != MA_SUCCESS) {
-            frameCountOut = 0;
-        }
-    }
-
-    ma_data_converter_uninit(&converter);
-    return frameCountOut;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Ring Buffer
-
-**************************************************************************************************************************************************************/
-static MA_INLINE ma_uint32 ma_rb__extract_offset_in_bytes(ma_uint32 encodedOffset)
-{
-    return encodedOffset & 0x7FFFFFFF;
-}
-
-static MA_INLINE ma_uint32 ma_rb__extract_offset_loop_flag(ma_uint32 encodedOffset)
-{
-    return encodedOffset & 0x80000000;
-}
-
-static MA_INLINE void* ma_rb__get_read_ptr(ma_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-    return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(c89atomic_load_32(&pRB->encodedReadOffset)));
-}
-
-static MA_INLINE void* ma_rb__get_write_ptr(ma_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-    return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(c89atomic_load_32(&pRB->encodedWriteOffset)));
-}
-
-static MA_INLINE ma_uint32 ma_rb__construct_offset(ma_uint32 offsetInBytes, ma_uint32 offsetLoopFlag)
-{
-    return offsetLoopFlag | offsetInBytes;
-}
-
-static MA_INLINE void ma_rb__deconstruct_offset(ma_uint32 encodedOffset, ma_uint32* pOffsetInBytes, ma_uint32* pOffsetLoopFlag)
-{
-    MA_ASSERT(pOffsetInBytes != NULL);
-    MA_ASSERT(pOffsetLoopFlag != NULL);
-
-    *pOffsetInBytes  = ma_rb__extract_offset_in_bytes(encodedOffset);
-    *pOffsetLoopFlag = ma_rb__extract_offset_loop_flag(encodedOffset);
-}
-
-
-MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB)
-{
-    ma_result result;
-    const ma_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1);
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (subbufferSizeInBytes == 0 || subbufferCount == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (subbufferSizeInBytes > maxSubBufferSize) {
-        return MA_INVALID_ARGS;    /* Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. */
-    }
-
-
-    MA_ZERO_OBJECT(pRB);
-
-    result = ma_allocation_callbacks_init_copy(&pRB->allocationCallbacks, pAllocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pRB->subbufferSizeInBytes = (ma_uint32)subbufferSizeInBytes;
-    pRB->subbufferCount = (ma_uint32)subbufferCount;
-
-    if (pOptionalPreallocatedBuffer != NULL) {
-        pRB->subbufferStrideInBytes = (ma_uint32)subbufferStrideInBytes;
-        pRB->pBuffer = pOptionalPreallocatedBuffer;
-    } else {
-        size_t bufferSizeInBytes;
-
-        /*
-        Here is where we allocate our own buffer. We always want to align this to MA_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this
-        we need to make sure the stride is a multiple of MA_SIMD_ALIGNMENT.
-        */
-        pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MA_SIMD_ALIGNMENT-1)) & ~MA_SIMD_ALIGNMENT;
-
-        bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes;
-        pRB->pBuffer = ma_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT, &pRB->allocationCallbacks);
-        if (pRB->pBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        MA_ZERO_MEMORY(pRB->pBuffer, bufferSizeInBytes);
-        pRB->ownsBuffer = MA_TRUE;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB)
-{
-    return ma_rb_init_ex(bufferSizeInBytes, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB);
-}
-
-MA_API void ma_rb_uninit(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    if (pRB->ownsBuffer) {
-        ma_aligned_free(pRB->pBuffer, &pRB->allocationCallbacks);
-    }
-}
-
-MA_API void ma_rb_reset(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, 0);
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, 0);
-}
-
-MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut)
-{
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    size_t bytesAvailable;
-    size_t bytesRequested;
-
-    if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The returned buffer should never move ahead of the write pointer. */
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    /*
-    The number of bytes available depends on whether or not the read and write pointers are on the same loop iteration. If so, we
-    can only read up to the write pointer. If not, we can only read up to the end of the buffer.
-    */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        bytesAvailable = writeOffsetInBytes - readOffsetInBytes;
-    } else {
-        bytesAvailable = pRB->subbufferSizeInBytes - readOffsetInBytes;
-    }
-
-    bytesRequested = *pSizeInBytes;
-    if (bytesRequested > bytesAvailable) {
-        bytesRequested = bytesAvailable;
-    }
-
-    *pSizeInBytes = bytesRequested;
-    (*ppBufferOut) = ma_rb__get_read_ptr(pRB);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 newReadOffsetInBytes;
-    ma_uint32 newReadOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Validate the buffer. */
-    if (pBufferOut != ma_rb__get_read_ptr(pRB)) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */
-    newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + sizeInBytes);
-    if (newReadOffsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;    /* <-- sizeInBytes will cause the read offset to overflow. */
-    }
-
-    /* Move the read pointer back to the start if necessary. */
-    newReadOffsetLoopFlag = readOffsetLoopFlag;
-    if (newReadOffsetInBytes == pRB->subbufferSizeInBytes) {
-        newReadOffsetInBytes = 0;
-        newReadOffsetLoopFlag ^= 0x80000000;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetLoopFlag, newReadOffsetInBytes));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    size_t bytesAvailable;
-    size_t bytesRequested;
-
-    if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The returned buffer should never overtake the read buffer. */
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    /*
-    In the case of writing, if the write pointer and the read pointer are on the same loop iteration we can only
-    write up to the end of the buffer. Otherwise we can only write up to the read pointer. The write pointer should
-    never overtake the read pointer.
-    */
-    if (writeOffsetLoopFlag == readOffsetLoopFlag) {
-        bytesAvailable = pRB->subbufferSizeInBytes - writeOffsetInBytes;
-    } else {
-        bytesAvailable = readOffsetInBytes - writeOffsetInBytes;
-    }
-
-    bytesRequested = *pSizeInBytes;
-    if (bytesRequested > bytesAvailable) {
-        bytesRequested = bytesAvailable;
-    }
-
-    *pSizeInBytes = bytesRequested;
-    *ppBufferOut  = ma_rb__get_write_ptr(pRB);
-
-    /* Clear the buffer if desired. */
-    if (pRB->clearOnWriteAcquire) {
-        MA_ZERO_MEMORY(*ppBufferOut, *pSizeInBytes);
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut)
-{
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newWriteOffsetInBytes;
-    ma_uint32 newWriteOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Validate the buffer. */
-    if (pBufferOut != ma_rb__get_write_ptr(pRB)) {
-        return MA_INVALID_ARGS;
-    }
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */
-    newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + sizeInBytes);
-    if (newWriteOffsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;    /* <-- sizeInBytes will cause the read offset to overflow. */
-    }
-
-    /* Move the read pointer back to the start if necessary. */
-    newWriteOffsetLoopFlag = writeOffsetLoopFlag;
-    if (newWriteOffsetInBytes == pRB->subbufferSizeInBytes) {
-        newWriteOffsetInBytes = 0;
-        newWriteOffsetLoopFlag ^= 0x80000000;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetLoopFlag, newWriteOffsetInBytes));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newReadOffsetInBytes;
-    ma_uint32 newReadOffsetLoopFlag;
-
-    if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    newReadOffsetLoopFlag = readOffsetLoopFlag;
-
-    /* We cannot go past the write buffer. */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        if ((readOffsetInBytes + offsetInBytes) > writeOffsetInBytes) {
-            newReadOffsetInBytes = writeOffsetInBytes;
-        } else {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes);
-        }
-    } else {
-        /* May end up looping. */
-        if ((readOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes;
-            newReadOffsetLoopFlag ^= 0x80000000;    /* <-- Looped. */
-        } else {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes);
-        }
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetInBytes, newReadOffsetLoopFlag));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newWriteOffsetInBytes;
-    ma_uint32 newWriteOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    newWriteOffsetLoopFlag = writeOffsetLoopFlag;
-
-    /* We cannot go past the write buffer. */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        /* May end up looping. */
-        if ((writeOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes;
-            newWriteOffsetLoopFlag ^= 0x80000000;    /* <-- Looped. */
-        } else {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes);
-        }
-    } else {
-        if ((writeOffsetInBytes + offsetInBytes) > readOffsetInBytes) {
-            newWriteOffsetInBytes = readOffsetInBytes;
-        } else {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes);
-        }
-    }
-
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetInBytes, newWriteOffsetLoopFlag));
-    return MA_SUCCESS;
-}
-
-MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        return writeOffsetInBytes - readOffsetInBytes;
-    } else {
-        return writeOffsetInBytes + (pRB->subbufferSizeInBytes - readOffsetInBytes);
-    }
-}
-
-MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB)
-{
-    ma_int32 dist;
-
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    dist = ma_rb_pointer_distance(pRB);
-    if (dist < 0) {
-        return 0;
-    }
-
-    return dist;
-}
-
-MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_size(pRB) - ma_rb_pointer_distance(pRB));
-}
-
-MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return pRB->subbufferSizeInBytes;
-}
-
-MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    if (pRB->subbufferStrideInBytes == 0) {
-        return (size_t)pRB->subbufferSizeInBytes;
-    }
-
-    return (size_t)pRB->subbufferStrideInBytes;
-}
-
-MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return subbufferIndex * ma_rb_get_subbuffer_stride(pRB);
-}
-
-MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer)
-{
-    if (pRB == NULL) {
-        return NULL;
-    }
-
-    return ma_offset_ptr(pBuffer, ma_rb_get_subbuffer_offset(pRB, subbufferIndex));
-}
-
-
-
-static MA_INLINE ma_uint32 ma_pcm_rb_get_bpf(ma_pcm_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-
-    return ma_get_bytes_per_frame(pRB->format, pRB->channels);
-}
-
-MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB)
-{
-    ma_uint32 bpf;
-    ma_result result;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pRB);
-
-    bpf = ma_get_bytes_per_frame(format, channels);
-    if (bpf == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_rb_init_ex(subbufferSizeInFrames*bpf, subbufferCount, subbufferStrideInFrames*bpf, pOptionalPreallocatedBuffer, pAllocationCallbacks, &pRB->rb);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pRB->format   = format;
-    pRB->channels = channels;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB)
-{
-    return ma_pcm_rb_init_ex(format, channels, bufferSizeInFrames, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB);
-}
-
-MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    ma_rb_uninit(&pRB->rb);
-}
-
-MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    ma_rb_reset(&pRB->rb);
-}
-
-MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut)
-{
-    size_t sizeInBytes;
-    ma_result result;
-
-    if (pRB == NULL || pSizeInFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB);
-
-    result = ma_rb_acquire_read(&pRB->rb, &sizeInBytes, ppBufferOut);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pSizeInFrames = (ma_uint32)(sizeInBytes / (size_t)ma_pcm_rb_get_bpf(pRB));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_commit_read(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB), pBufferOut);
-}
-
-MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut)
-{
-    size_t sizeInBytes;
-    ma_result result;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB);
-
-    result = ma_rb_acquire_write(&pRB->rb, &sizeInBytes, ppBufferOut);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pSizeInFrames = (ma_uint32)(sizeInBytes / ma_pcm_rb_get_bpf(pRB));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_commit_write(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB), pBufferOut);
-}
-
-MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_seek_read(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_seek_write(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_pointer_distance(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_available_read(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_available_write(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_size(&pRB->rb) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_stride(&pRB->rb) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_offset(&pRB->rb, subbufferIndex) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer)
-{
-    if (pRB == NULL) {
-        return NULL;
-    }
-
-    return ma_rb_get_subbuffer_ptr(&pRB->rb, subbufferIndex, pBuffer);
-}
-
-
-
-MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB)
-{
-    ma_result result;
-    ma_uint32 sizeInFrames;
-
-    sizeInFrames = (ma_uint32)ma_calculate_frame_count_after_resampling(sampleRate, captureInternalSampleRate, captureInternalPeriodSizeInFrames * 5);
-    if (sizeInFrames == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_pcm_rb_init(captureFormat, captureChannels, sizeInFrames, NULL, pAllocationCallbacks, &pRB->rb);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Seek forward a bit so we have a bit of a buffer in case of desyncs. */
-    ma_pcm_rb_seek_write((ma_pcm_rb*)pRB, captureInternalPeriodSizeInFrames * 2);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB)
-{
-    ma_pcm_rb_uninit((ma_pcm_rb*)pRB);
-    return MA_SUCCESS;
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Miscellaneous Helpers
-
-**************************************************************************************************************************************************************/
-MA_API const char* ma_result_description(ma_result result)
-{
-    switch (result)
-    {
-        case MA_SUCCESS:                       return "No error";
-        case MA_ERROR:                         return "Unknown error";
-        case MA_INVALID_ARGS:                  return "Invalid argument";
-        case MA_INVALID_OPERATION:             return "Invalid operation";
-        case MA_OUT_OF_MEMORY:                 return "Out of memory";
-        case MA_OUT_OF_RANGE:                  return "Out of range";
-        case MA_ACCESS_DENIED:                 return "Permission denied";
-        case MA_DOES_NOT_EXIST:                return "Resource does not exist";
-        case MA_ALREADY_EXISTS:                return "Resource already exists";
-        case MA_TOO_MANY_OPEN_FILES:           return "Too many open files";
-        case MA_INVALID_FILE:                  return "Invalid file";
-        case MA_TOO_BIG:                       return "Too large";
-        case MA_PATH_TOO_LONG:                 return "Path too long";
-        case MA_NAME_TOO_LONG:                 return "Name too long";
-        case MA_NOT_DIRECTORY:                 return "Not a directory";
-        case MA_IS_DIRECTORY:                  return "Is a directory";
-        case MA_DIRECTORY_NOT_EMPTY:           return "Directory not empty";
-        case MA_END_OF_FILE:                   return "End of file";
-        case MA_NO_SPACE:                      return "No space available";
-        case MA_BUSY:                          return "Device or resource busy";
-        case MA_IO_ERROR:                      return "Input/output error";
-        case MA_INTERRUPT:                     return "Interrupted";
-        case MA_UNAVAILABLE:                   return "Resource unavailable";
-        case MA_ALREADY_IN_USE:                return "Resource already in use";
-        case MA_BAD_ADDRESS:                   return "Bad address";
-        case MA_BAD_SEEK:                      return "Illegal seek";
-        case MA_BAD_PIPE:                      return "Broken pipe";
-        case MA_DEADLOCK:                      return "Deadlock";
-        case MA_TOO_MANY_LINKS:                return "Too many links";
-        case MA_NOT_IMPLEMENTED:               return "Not implemented";
-        case MA_NO_MESSAGE:                    return "No message of desired type";
-        case MA_BAD_MESSAGE:                   return "Invalid message";
-        case MA_NO_DATA_AVAILABLE:             return "No data available";
-        case MA_INVALID_DATA:                  return "Invalid data";
-        case MA_TIMEOUT:                       return "Timeout";
-        case MA_NO_NETWORK:                    return "Network unavailable";
-        case MA_NOT_UNIQUE:                    return "Not unique";
-        case MA_NOT_SOCKET:                    return "Socket operation on non-socket";
-        case MA_NO_ADDRESS:                    return "Destination address required";
-        case MA_BAD_PROTOCOL:                  return "Protocol wrong type for socket";
-        case MA_PROTOCOL_UNAVAILABLE:          return "Protocol not available";
-        case MA_PROTOCOL_NOT_SUPPORTED:        return "Protocol not supported";
-        case MA_PROTOCOL_FAMILY_NOT_SUPPORTED: return "Protocol family not supported";
-        case MA_ADDRESS_FAMILY_NOT_SUPPORTED:  return "Address family not supported";
-        case MA_SOCKET_NOT_SUPPORTED:          return "Socket type not supported";
-        case MA_CONNECTION_RESET:              return "Connection reset";
-        case MA_ALREADY_CONNECTED:             return "Already connected";
-        case MA_NOT_CONNECTED:                 return "Not connected";
-        case MA_CONNECTION_REFUSED:            return "Connection refused";
-        case MA_NO_HOST:                       return "No host";
-        case MA_IN_PROGRESS:                   return "Operation in progress";
-        case MA_CANCELLED:                     return "Operation cancelled";
-        case MA_MEMORY_ALREADY_MAPPED:         return "Memory already mapped";
-        case MA_AT_END:                        return "Reached end of collection";
-
-        case MA_FORMAT_NOT_SUPPORTED:          return "Format not supported";
-        case MA_DEVICE_TYPE_NOT_SUPPORTED:     return "Device type not supported";
-        case MA_SHARE_MODE_NOT_SUPPORTED:      return "Share mode not supported";
-        case MA_NO_BACKEND:                    return "No backend";
-        case MA_NO_DEVICE:                     return "No device";
-        case MA_API_NOT_FOUND:                 return "API not found";
-        case MA_INVALID_DEVICE_CONFIG:         return "Invalid device config";
-
-        case MA_DEVICE_NOT_INITIALIZED:        return "Device not initialized";
-        case MA_DEVICE_NOT_STARTED:            return "Device not started";
-
-        case MA_FAILED_TO_INIT_BACKEND:        return "Failed to initialize backend";
-        case MA_FAILED_TO_OPEN_BACKEND_DEVICE: return "Failed to open backend device";
-        case MA_FAILED_TO_START_BACKEND_DEVICE: return "Failed to start backend device";
-        case MA_FAILED_TO_STOP_BACKEND_DEVICE: return "Failed to stop backend device";
-
-        default:                               return "Unknown error";
-    }
-}
-
-MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return ma__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return ma__malloc_default(sz, NULL);
-    }
-}
-
-MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        if (pAllocationCallbacks->onRealloc != NULL) {
-            return pAllocationCallbacks->onRealloc(p, sz, pAllocationCallbacks->pUserData);
-        } else {
-            return NULL;    /* This requires a native implementation of realloc(). */
-        }
-    } else {
-        return ma__realloc_default(p, sz, NULL);
-    }
-}
-
-MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        ma__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        ma__free_default(p, NULL);
-    }
-}
-
-MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t extraBytes;
-    void* pUnaligned;
-    void* pAligned;
-
-    if (alignment == 0) {
-        return 0;
-    }
-
-    extraBytes = alignment-1 + sizeof(void*);
-
-    pUnaligned = ma_malloc(sz + extraBytes, pAllocationCallbacks);
-    if (pUnaligned == NULL) {
-        return NULL;
-    }
-
-    pAligned = (void*)(((ma_uintptr)pUnaligned + extraBytes) & ~((ma_uintptr)(alignment-1)));
-    ((void**)pAligned)[-1] = pUnaligned;
-
-    return pAligned;
-}
-
-MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_free(((void**)p)[-1], pAllocationCallbacks);
-}
-
-MA_API const char* ma_get_format_name(ma_format format)
-{
-    switch (format)
-    {
-        case ma_format_unknown: return "Unknown";
-        case ma_format_u8:      return "8-bit Unsigned Integer";
-        case ma_format_s16:     return "16-bit Signed Integer";
-        case ma_format_s24:     return "24-bit Signed Integer (Tightly Packed)";
-        case ma_format_s32:     return "32-bit Signed Integer";
-        case ma_format_f32:     return "32-bit IEEE Floating Point";
-        default:                return "Invalid";
-    }
-}
-
-MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels)
-{
-    ma_uint32 i;
-    for (i = 0; i < channels; ++i) {
-        pOut[i] = ma_mix_f32(pInA[i], pInB[i], factor);
-    }
-}
-
-
-MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format)
-{
-    ma_uint32 sizes[] = {
-        0,  /* unknown */
-        1,  /* u8 */
-        2,  /* s16 */
-        3,  /* s24 */
-        4,  /* s32 */
-        4,  /* f32 */
-    };
-    return sizes[format];
-}
-
-
-
-MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    /* Safety. */
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onRead == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    /* A very small optimization for the non looping case. */
-    if (loop == MA_FALSE) {
-        return pCallbacks->onRead(pDataSource, pFramesOut, frameCount, pFramesRead);
-    } else {
-        ma_format format;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-        if (ma_data_source_get_data_format(pDataSource, &format, &channels, &sampleRate) != MA_SUCCESS) {
-            return pCallbacks->onRead(pDataSource, pFramesOut, frameCount, pFramesRead); /* We don't have a way to retrieve the data format which means we don't know how to offset the output buffer. Just read as much as we can. */
-        } else {
-            ma_result result = MA_SUCCESS;
-            ma_uint64 totalFramesProcessed;
-            void* pRunningFramesOut = pFramesOut;
-
-            totalFramesProcessed = 0;
-            while (totalFramesProcessed < frameCount) {
-                ma_uint64 framesProcessed;
-                ma_uint64 framesRemaining = frameCount - totalFramesProcessed;
-
-                result = pCallbacks->onRead(pDataSource, pRunningFramesOut, framesRemaining, &framesProcessed);
-                totalFramesProcessed += framesProcessed;
-
-                /*
-                If we encounted an error from the read callback, make sure it's propagated to the caller. The caller may need to know whether or not MA_BUSY is returned which is
-                not necessarily considered an error.
-                */
-                if (result != MA_SUCCESS && result != MA_AT_END) {
-                    break;
-                }
-
-                /*
-                We can determine if we've reached the end by checking the return value of the onRead() callback. If it's less than what we requested it means
-                we've reached the end. To loop back to the start, all we need to do is seek back to the first frame.
-                */
-                if (framesProcessed < framesRemaining || result == MA_AT_END) {
-                    if (ma_data_source_seek_to_pcm_frame(pDataSource, 0) != MA_SUCCESS) {
-                        break;
-                    }
-                }
-
-                if (pRunningFramesOut != NULL) {
-                    pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesProcessed * ma_get_bytes_per_frame(format, channels));
-                }
-            }
-
-            if (pFramesRead != NULL) {
-                *pFramesRead = totalFramesProcessed;
-            }
-
-            return result;
-        }
-    }
-}
-
-MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked, ma_bool32 loop)
-{
-    return ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, pFramesSeeked, loop);
-}
-
-MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onSeek(pDataSource, frameIndex);
-}
-
-MA_API ma_result ma_data_source_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onMap == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onMap(pDataSource, ppFramesOut, pFrameCount);
-}
-
-MA_API ma_result ma_data_source_unmap(ma_data_source* pDataSource, ma_uint64 frameCount)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onUnmap == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onUnmap(pDataSource, frameCount);
-}
-
-MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_result result;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pFormat != NULL) {
-        *pFormat = ma_format_unknown;
-    }
-
-    if (pChannels != NULL) {
-        *pChannels = 0;
-    }
-
-    if (pSampleRate != NULL) {
-        *pSampleRate = 0;
-    }
-
-    if (pCallbacks == NULL || pCallbacks->onGetDataFormat == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = pCallbacks->onGetDataFormat(pDataSource, &format, &channels, &sampleRate);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFormat != NULL) {
-        *pFormat = format;
-    }
-    if (pChannels != NULL) {
-        *pChannels = channels;
-    }
-    if (pSampleRate != NULL) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onGetCursor == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onGetCursor(pDataSource, pCursor);
-}
-
-MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pLength == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pLength = 0;
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onGetLength == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onGetLength(pDataSource, pLength);
-}
-
-
-
-
-static ma_result ma_audio_buffer_ref__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_audio_buffer_ref_read_pcm_frames((ma_audio_buffer_ref*)pDataSource, pFramesOut, frameCount, MA_FALSE);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_audio_buffer_ref_seek_to_pcm_frame((ma_audio_buffer_ref*)pDataSource, frameIndex);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    return ma_audio_buffer_ref_map((ma_audio_buffer_ref*)pDataSource, ppFramesOut, pFrameCount);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_unmap(ma_data_source* pDataSource, ma_uint64 frameCount)
-{
-    return ma_audio_buffer_ref_unmap((ma_audio_buffer_ref*)pDataSource, frameCount);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pFormat     = pAudioBufferRef->format;
-    *pChannels   = pAudioBufferRef->channels;
-    *pSampleRate = 0;   /* There is no notion of a sample rate with audio buffers. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pCursor = pAudioBufferRef->cursor;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pLength = pAudioBufferRef->sizeInFrames;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pAudioBufferRef);
-
-    pAudioBufferRef->ds.onRead          = ma_audio_buffer_ref__data_source_on_read;
-    pAudioBufferRef->ds.onSeek          = ma_audio_buffer_ref__data_source_on_seek;
-    pAudioBufferRef->ds.onMap           = ma_audio_buffer_ref__data_source_on_map;
-    pAudioBufferRef->ds.onUnmap         = ma_audio_buffer_ref__data_source_on_unmap;
-    pAudioBufferRef->ds.onGetDataFormat = ma_audio_buffer_ref__data_source_on_get_data_format;
-    pAudioBufferRef->ds.onGetCursor     = ma_audio_buffer_ref__data_source_on_get_cursor;
-    pAudioBufferRef->ds.onGetLength     = ma_audio_buffer_ref__data_source_on_get_length;
-    pAudioBufferRef->format             = format;
-    pAudioBufferRef->channels           = channels;
-    pAudioBufferRef->cursor             = 0;
-    pAudioBufferRef->sizeInFrames       = sizeInFrames;
-    pAudioBufferRef->pData              = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pAudioBufferRef->cursor       = 0;
-    pAudioBufferRef->sizeInFrames = sizeInFrames;
-    pAudioBufferRef->pData        = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop)
-{
-    ma_uint64 totalFramesRead = 0;
-
-    if (pAudioBufferRef == NULL) {
-        return 0;
-    }
-
-    if (frameCount == 0) {
-        return 0;
-    }
-
-    while (totalFramesRead < frameCount) {
-        ma_uint64 framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-        ma_uint64 framesRemaining = frameCount - totalFramesRead;
-        ma_uint64 framesToRead;
-
-        framesToRead = framesRemaining;
-        if (framesToRead > framesAvailable) {
-            framesToRead = framesAvailable;
-        }
-
-        if (pFramesOut != NULL) {
-            ma_copy_pcm_frames(pFramesOut, ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), framesToRead, pAudioBufferRef->format, pAudioBufferRef->channels);
-        }
-
-        totalFramesRead += framesToRead;
-
-        pAudioBufferRef->cursor += framesToRead;
-        if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) {
-            if (loop) {
-                pAudioBufferRef->cursor = 0;
-            } else {
-                break;  /* We've reached the end and we're not looping. Done. */
-            }
-        }
-
-        MA_ASSERT(pAudioBufferRef->cursor < pAudioBufferRef->sizeInFrames);
-    }
-
-    return totalFramesRead;
-}
-
-MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (frameIndex > pAudioBufferRef->sizeInFrames) {
-        return MA_INVALID_ARGS;
-    }
-
-    pAudioBufferRef->cursor = (size_t)frameIndex;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    ma_uint64 framesAvailable;
-    ma_uint64 frameCount = 0;
-
-    if (ppFramesOut != NULL) {
-        *ppFramesOut = NULL;    /* Safety. */
-    }
-
-    if (pFrameCount != NULL) {
-        frameCount = *pFrameCount;
-        *pFrameCount = 0;       /* Safety. */
-    }
-
-    if (pAudioBufferRef == NULL || ppFramesOut == NULL || pFrameCount == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    if (frameCount > framesAvailable) {
-        frameCount = framesAvailable;
-    }
-
-    *ppFramesOut = ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels));
-    *pFrameCount = frameCount;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount)
-{
-    ma_uint64 framesAvailable;
-
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    if (frameCount > framesAvailable) {
-        return MA_INVALID_ARGS;   /* The frame count was too big. This should never happen in an unmapping. Need to make sure the caller is aware of this. */
-    }
-
-    pAudioBufferRef->cursor += frameCount;
-
-    if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) {
-        return MA_AT_END;   /* Successful. Need to tell the caller that the end has been reached so that it can loop if desired. */
-    } else {
-        return MA_SUCCESS;
-    }
-}
-
-MA_API ma_result ma_audio_buffer_ref_at_end(ma_audio_buffer_ref* pAudioBufferRef)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_FALSE;
-    }
-
-    return pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames;
-}
-
-MA_API ma_result ma_audio_buffer_ref_get_available_frames(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames)
-{
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pAudioBufferRef->sizeInFrames <= pAudioBufferRef->cursor) {
-        *pAvailableFrames = 0;
-    } else {
-        *pAvailableFrames = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-
-
-MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_audio_buffer_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sizeInFrames = sizeInFrames;
-    config.pData = pData;
-    ma_allocation_callbacks_init_copy(&config.allocationCallbacks, pAllocationCallbacks);
-
-    return config;
-}
-
-static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, ma_bool32 doCopy, ma_audio_buffer* pAudioBuffer)
-{
-    ma_result result;
-
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_MEMORY(pAudioBuffer, sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData));   /* Safety. Don't overwrite the extra data. */
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->sizeInFrames == 0) {
-        return MA_INVALID_ARGS; /* Not allowing buffer sizes of 0 frames. */
-    }
-
-    result = ma_audio_buffer_ref_init(pConfig->format, pConfig->channels, NULL, 0, &pAudioBuffer->ref);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-    
-    ma_allocation_callbacks_init_copy(&pAudioBuffer->allocationCallbacks, &pConfig->allocationCallbacks);
-
-    if (doCopy) {
-        ma_uint64 allocationSizeInBytes;
-        void* pData;
-
-        allocationSizeInBytes = pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels);
-        if (allocationSizeInBytes > MA_SIZE_MAX) {
-            return MA_OUT_OF_MEMORY;    /* Too big. */
-        }
-
-        pData = ma__malloc_from_callbacks((size_t)allocationSizeInBytes, &pAudioBuffer->allocationCallbacks);   /* Safe cast to size_t. */
-        if (pData == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        if (pConfig->pData != NULL) {
-            ma_copy_pcm_frames(pData, pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-        } else {
-            ma_silence_pcm_frames(pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-        }
-
-        ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pData, pConfig->sizeInFrames);
-        pAudioBuffer->ownsData = MA_TRUE;
-    } else {
-        ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pConfig->pData, pConfig->sizeInFrames);
-        pAudioBuffer->ownsData = MA_FALSE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_audio_buffer_uninit_ex(ma_audio_buffer* pAudioBuffer, ma_bool32 doFree)
-{
-    if (pAudioBuffer == NULL) {
-        return;
-    }
-
-    if (pAudioBuffer->ownsData && pAudioBuffer->ref.pData != &pAudioBuffer->_pExtraData[0]) {
-        ma__free_from_callbacks((void*)pAudioBuffer->ref.pData, &pAudioBuffer->allocationCallbacks);    /* Naugty const cast, but OK in this case since we've guarded it with the ownsData check. */
-    }
-
-    if (doFree) {
-        ma__free_from_callbacks(pAudioBuffer, &pAudioBuffer->allocationCallbacks);
-    }
-}
-
-MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer)
-{
-    return ma_audio_buffer_init_ex(pConfig, MA_FALSE, pAudioBuffer);
-}
-
-MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer)
-{
-    return ma_audio_buffer_init_ex(pConfig, MA_TRUE, pAudioBuffer);
-}
-
-MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer)
-{
-    ma_result result;
-    ma_audio_buffer* pAudioBuffer;
-    ma_audio_buffer_config innerConfig; /* We'll be making some changes to the config, so need to make a copy. */
-    ma_uint64 allocationSizeInBytes;
-
-    if (ppAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *ppAudioBuffer = NULL;  /* Safety. */
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    innerConfig = *pConfig;
-    ma_allocation_callbacks_init_copy(&innerConfig.allocationCallbacks, &pConfig->allocationCallbacks);
-
-    allocationSizeInBytes = sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData) + (pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels));
-    if (allocationSizeInBytes > MA_SIZE_MAX) {
-        return MA_OUT_OF_MEMORY;    /* Too big. */
-    }
-
-    pAudioBuffer = (ma_audio_buffer*)ma__malloc_from_callbacks((size_t)allocationSizeInBytes, &innerConfig.allocationCallbacks);  /* Safe cast to size_t. */
-    if (pAudioBuffer == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    if (pConfig->pData != NULL) {
-        ma_copy_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-    } else {
-        ma_silence_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-    }
-
-    innerConfig.pData = &pAudioBuffer->_pExtraData[0];
-
-    result = ma_audio_buffer_init_ex(&innerConfig, MA_FALSE, pAudioBuffer);
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pAudioBuffer, &innerConfig.allocationCallbacks);
-        return result;
-    }
-
-    *ppAudioBuffer = pAudioBuffer;
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer)
-{
-    ma_audio_buffer_uninit_ex(pAudioBuffer, MA_FALSE);
-}
-
-MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer)
-{
-    ma_audio_buffer_uninit_ex(pAudioBuffer, MA_TRUE);
-}
-
-MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop)
-{
-    if (pAudioBuffer == NULL) {
-        return 0;
-    }
-
-    return ma_audio_buffer_ref_read_pcm_frames(&pAudioBuffer->ref, pFramesOut, frameCount, loop);
-}
-
-MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_seek_to_pcm_frame(&pAudioBuffer->ref, frameIndex);
-}
-
-MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    if (ppFramesOut != NULL) {
-        *ppFramesOut = NULL;    /* Safety. */
-    }
-
-    if (pAudioBuffer == NULL) {
-        if (pFrameCount != NULL) {
-            *pFrameCount = 0;
-        }
-
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_map(&pAudioBuffer->ref, ppFramesOut, pFrameCount);
-}
-
-MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_unmap(&pAudioBuffer->ref, frameCount);
-}
-
-MA_API ma_result ma_audio_buffer_at_end(ma_audio_buffer* pAudioBuffer)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_audio_buffer_ref_at_end(&pAudioBuffer->ref);
-}
-
-MA_API ma_result ma_audio_buffer_get_available_frames(ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames)
-{
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_get_available_frames(&pAudioBuffer->ref, pAvailableFrames);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-VFS
-
-**************************************************************************************************************************************************************/
-MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pVFS == NULL || pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onOpen == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onOpen(pVFS, pFilePath, openMode, pFile);
-}
-
-MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pVFS == NULL || pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onOpenW == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onOpenW(pVFS, pFilePath, openMode, pFile);
-}
-
-MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onClose == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onClose(pVFS, file);
-}
-
-MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = 0;
-    }
-
-    if (pVFS == NULL || file == NULL || pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onRead == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onRead(pVFS, file, pDst, sizeInBytes, pBytesRead);
-}
-
-MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = 0;
-    }
-
-    if (pVFS == NULL || file == NULL || pSrc == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onWrite == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onWrite(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-}
-
-MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onSeek == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onSeek(pVFS, file, offset, origin);
-}
-
-MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onTell == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onTell(pVFS, file, pCursor);
-}
-
-MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pInfo);
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onInfo == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onInfo(pVFS, file, pInfo);
-}
-
-
-static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePath, const wchar_t* pFilePathW, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks, ma_uint32 allocationType)
-{
-    ma_result result;
-    ma_vfs_file file;
-    ma_file_info info;
-    void* pData;
-    size_t bytesRead;
-
-    (void)allocationType;
-
-    if (ppData != NULL) {
-        *ppData = NULL;
-    }
-    if (pSize != NULL) {
-        *pSize = 0;
-    }
-
-    if (ppData == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFilePath != NULL) {
-        result = ma_vfs_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    } else {
-        result = ma_vfs_open_w(pVFS, pFilePathW, MA_OPEN_MODE_READ, &file);
-    }
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_vfs_info(pVFS, file, &info);
-    if (result != MA_SUCCESS) {
-        ma_vfs_close(pVFS, file);
-        return result;
-    }
-
-    if (info.sizeInBytes > MA_SIZE_MAX) {
-        ma_vfs_close(pVFS, file);
-        return MA_TOO_BIG;
-    }
-
-    pData = ma__malloc_from_callbacks((size_t)info.sizeInBytes, pAllocationCallbacks);  /* Safe cast. */
-    if (pData == NULL) {
-        ma_vfs_close(pVFS, file);
-        return result;
-    }
-
-    result = ma_vfs_read(pVFS, file, pData, (size_t)info.sizeInBytes, &bytesRead);  /* Safe cast. */
-    ma_vfs_close(pVFS, file);
-
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pData, pAllocationCallbacks);
-        return result;
-    }
-
-    if (pSize != NULL) {
-        *pSize = bytesRead;
-    }
-
-    MA_ASSERT(ppData != NULL);
-    *ppData = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    return ma_vfs_open_and_read_file_ex(pVFS, pFilePath, NULL, ppData, pSize, pAllocationCallbacks, 0 /*MA_ALLOCATION_TYPE_GENERAL*/);
-}
-
-MA_API ma_result ma_vfs_open_and_read_file_w(ma_vfs* pVFS, const wchar_t* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    return ma_vfs_open_and_read_file_ex(pVFS, NULL, pFilePath, ppData, pSize, pAllocationCallbacks, 0 /*MA_ALLOCATION_TYPE_GENERAL*/);
-}
-
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-static void ma_default_vfs__get_open_settings_win32(ma_uint32 openMode, DWORD* pDesiredAccess, DWORD* pShareMode, DWORD* pCreationDisposition)
-{
-    *pDesiredAccess = 0;
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        *pDesiredAccess |= GENERIC_READ;
-    }
-    if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-        *pDesiredAccess |= GENERIC_WRITE;
-    }
-
-    *pShareMode = 0;
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        *pShareMode |= FILE_SHARE_READ;
-    }
-
-    if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-        *pCreationDisposition = CREATE_ALWAYS;  /* Opening in write mode. Truncate. */
-    } else {
-        *pCreationDisposition = OPEN_EXISTING;  /* Opening in read mode. File must exist. */
-    }
-}
-
-static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    HANDLE hFile;
-    DWORD dwDesiredAccess;
-    DWORD dwShareMode;
-    DWORD dwCreationDisposition;
-
-    (void)pVFS;
-
-    ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition);
-
-    hFile = CreateFileA(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile == INVALID_HANDLE_VALUE) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    *pFile = hFile;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    HANDLE hFile;
-    DWORD dwDesiredAccess;
-    DWORD dwShareMode;
-    DWORD dwCreationDisposition;
-
-    (void)pVFS;
-
-    ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition);
-
-    hFile = CreateFileW(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile == INVALID_HANDLE_VALUE) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    *pFile = hFile;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_close__win32(ma_vfs* pVFS, ma_vfs_file file)
-{
-    (void)pVFS;
-
-    if (CloseHandle((HANDLE)file) == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_default_vfs_read__win32(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    ma_result result = MA_SUCCESS;
-    size_t totalBytesRead;
-
-    (void)pVFS;
-
-    totalBytesRead = 0;
-    while (totalBytesRead < sizeInBytes) {
-        size_t bytesRemaining;
-        DWORD bytesToRead;
-        DWORD bytesRead;
-        BOOL readResult;
-
-        bytesRemaining = sizeInBytes - totalBytesRead;
-        if (bytesRemaining >= 0xFFFFFFFF) {
-            bytesToRead = 0xFFFFFFFF;
-        } else {
-            bytesToRead = (DWORD)bytesRemaining;
-        }
-
-        readResult = ReadFile((HANDLE)file, ma_offset_ptr(pDst, totalBytesRead), bytesToRead, &bytesRead, NULL);
-        if (readResult == 1 && bytesRead == 0) {
-            break;  /* EOF */
-        }
-
-        totalBytesRead += bytesRead;
-
-        if (bytesRead < bytesToRead) {
-            break;  /* EOF */
-        }
-
-        if (readResult == 0) {
-            result = ma_result_from_GetLastError(GetLastError());
-            break;
-        }
-    }
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = totalBytesRead;
-    }
-
-    return result;
-}
-
-static ma_result ma_default_vfs_write__win32(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    size_t totalBytesWritten;
-
-    (void)pVFS;
-
-    totalBytesWritten = 0;
-    while (totalBytesWritten < sizeInBytes) {
-        size_t bytesRemaining;
-        DWORD bytesToWrite;
-        DWORD bytesWritten;
-        BOOL writeResult;
-
-        bytesRemaining = sizeInBytes - totalBytesWritten;
-        if (bytesRemaining >= 0xFFFFFFFF) {
-            bytesToWrite = 0xFFFFFFFF;
-        } else {
-            bytesToWrite = (DWORD)bytesRemaining;
-        }
-
-        writeResult = WriteFile((HANDLE)file, ma_offset_ptr(pSrc, totalBytesWritten), bytesToWrite, &bytesWritten, NULL);
-        totalBytesWritten += bytesWritten;
-
-        if (writeResult == 0) {
-            result = ma_result_from_GetLastError(GetLastError());
-            break;
-        }
-    }
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = totalBytesWritten;
-    }
-
-    return result;
-}
-
-
-static ma_result ma_default_vfs_seek__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    LARGE_INTEGER liDistanceToMove;
-    DWORD dwMoveMethod;
-    BOOL result;
-
-    (void)pVFS;
-
-    liDistanceToMove.QuadPart = offset;
-
-    /*  */ if (origin == ma_seek_origin_current) {
-        dwMoveMethod = FILE_CURRENT;
-    } else if (origin == ma_seek_origin_end) {
-        dwMoveMethod = FILE_END;
-    } else {
-        dwMoveMethod = FILE_BEGIN;
-    }
-
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    /* No SetFilePointerEx() so restrict to 31 bits. */
-    if (origin > 0x7FFFFFFF) {
-        return MA_OUT_OF_RANGE;
-    }
-
-    result = SetFilePointer((HANDLE)file, (LONG)liDistanceToMove.QuadPart, NULL, dwMoveMethod);
-#else
-    result = SetFilePointerEx((HANDLE)file, liDistanceToMove, NULL, dwMoveMethod);
-#endif
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    LARGE_INTEGER liZero;
-    LARGE_INTEGER liTell;
-    BOOL result;
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    LONG tell;
-#endif
-
-    (void)pVFS;
-
-    liZero.QuadPart = 0;
-
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    result = SetFilePointer((HANDLE)file, (LONG)liZero.QuadPart, &tell, FILE_CURRENT);
-    liTell.QuadPart = tell;
-#else
-    result = SetFilePointerEx((HANDLE)file, liZero, &liTell, FILE_CURRENT);
-#endif
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    if (pCursor != NULL) {
-        *pCursor = liTell.QuadPart;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    BY_HANDLE_FILE_INFORMATION fi;
-    BOOL result;
-
-    (void)pVFS;
-
-    result = GetFileInformationByHandle((HANDLE)file, &fi);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    pInfo->sizeInBytes = ((ma_uint64)fi.nFileSizeHigh << 32) | ((ma_uint64)fi.nFileSizeLow);
-
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_result result;
-    FILE* pFileStd;
-    const char* pOpenModeStr;
-
-    MA_ASSERT(pFilePath != NULL);
-    MA_ASSERT(openMode  != 0);
-    MA_ASSERT(pFile     != NULL);
-
-    (void)pVFS;
-
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-            pOpenModeStr = "r+";
-        } else {
-            pOpenModeStr = "rb";
-        }
-    } else {
-        pOpenModeStr = "wb";
-    }
-
-    result = ma_fopen(&pFileStd, pFilePath, pOpenModeStr);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pFile = pFileStd;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_result result;
-    FILE* pFileStd;
-    const wchar_t* pOpenModeStr;
-
-    MA_ASSERT(pFilePath != NULL);
-    MA_ASSERT(openMode  != 0);
-    MA_ASSERT(pFile     != NULL);
-
-    (void)pVFS;
-
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-            pOpenModeStr = L"r+";
-        } else {
-            pOpenModeStr = L"rb";
-        }
-    } else {
-        pOpenModeStr = L"wb";
-    }
-
-    result = ma_wfopen(&pFileStd, pFilePath, pOpenModeStr, (pVFS != NULL) ? &((ma_default_vfs*)pVFS)->allocationCallbacks : NULL);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pFile = pFileStd;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_close__stdio(ma_vfs* pVFS, ma_vfs_file file)
-{
-    MA_ASSERT(file != NULL);
-
-    (void)pVFS;
-
-    fclose((FILE*)file);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_read__stdio(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    size_t result;
-
-    MA_ASSERT(file != NULL);
-    MA_ASSERT(pDst != NULL);
-
-    (void)pVFS;
-
-    result = fread(pDst, 1, sizeInBytes, (FILE*)file);
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = result;
-    }
-
-    if (result != sizeInBytes) {
-        if (feof((FILE*)file)) {
-            return MA_END_OF_FILE;
-        } else {
-            return ma_result_from_errno(ferror((FILE*)file));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_write__stdio(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    size_t result;
-
-    MA_ASSERT(file != NULL);
-    MA_ASSERT(pSrc != NULL);
-
-    (void)pVFS;
-
-    result = fwrite(pSrc, 1, sizeInBytes, (FILE*)file);
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = result;
-    }
-
-    if (result != sizeInBytes) {
-        return ma_result_from_errno(ferror((FILE*)file));
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_seek__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    int result;
-
-    MA_ASSERT(file != NULL);
-
-    (void)pVFS;
-
-#if defined(_WIN32)
-    #if defined(_MSC_VER) && _MSC_VER > 1200
-        result = _fseeki64((FILE*)file, offset, origin);
-    #else
-        /* No _fseeki64() so restrict to 31 bits. */
-        if (origin > 0x7FFFFFFF) {
-            return MA_OUT_OF_RANGE;
-        }
-
-        result = fseek((FILE*)file, (int)offset, origin);
-    #endif
-#else
-    result = fseek((FILE*)file, (long int)offset, origin);
-#endif
-    if (result != 0) {
-        return MA_ERROR;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_tell__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    ma_int64 result;
-
-    MA_ASSERT(file    != NULL);
-    MA_ASSERT(pCursor != NULL);
-
-    (void)pVFS;
-
-#if defined(_WIN32)
-    #if defined(_MSC_VER) && _MSC_VER > 1200
-        result = _ftelli64((FILE*)file);
-    #else
-        result = ftell((FILE*)file);
-    #endif
-#else
-    result = ftell((FILE*)file);
-#endif
-
-    *pCursor = result;
-
-    return MA_SUCCESS;
-}
-
-#if !defined(_MSC_VER) && !((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)) && !defined(MA_BSD)
-int fileno(FILE *stream);
-#endif
-
-static ma_result ma_default_vfs_info__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    int fd;
-    struct stat info;
-
-    MA_ASSERT(file  != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    (void)pVFS;
-
-#if defined(_MSC_VER)
-    fd = _fileno((FILE*)file);
-#else
-    fd =  fileno((FILE*)file);
-#endif
-
-    if (fstat(fd, &info) != 0) {
-        return ma_result_from_errno(errno);
-    }
-
-    pInfo->sizeInBytes = info.st_size;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_open__win32(pVFS, pFilePath, openMode, pFile);
-#else
-    return ma_default_vfs_open__stdio(pVFS, pFilePath, openMode, pFile);
-#endif
-}
-
-static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_open_w__win32(pVFS, pFilePath, openMode, pFile);
-#else
-    return ma_default_vfs_open_w__stdio(pVFS, pFilePath, openMode, pFile);
-#endif
-}
-
-static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_close__win32(pVFS, file);
-#else
-    return ma_default_vfs_close__stdio(pVFS, file);
-#endif
-}
-
-static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    if (pBytesRead != NULL) {
-        *pBytesRead = 0;
-    }
-
-    if (file == NULL || pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_read__win32(pVFS, file, pDst, sizeInBytes, pBytesRead);
-#else
-    return ma_default_vfs_read__stdio(pVFS, file, pDst, sizeInBytes, pBytesRead);
-#endif
-}
-
-static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = 0;
-    }
-
-    if (file == NULL || pSrc == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_write__win32(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-#else
-    return ma_default_vfs_write__stdio(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-#endif
-}
-
-static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_seek__win32(pVFS, file, offset, origin);
-#else
-    return ma_default_vfs_seek__stdio(pVFS, file, offset, origin);
-#endif
-}
-
-static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_tell__win32(pVFS, file, pCursor);
-#else
-    return ma_default_vfs_tell__stdio(pVFS, file, pCursor);
-#endif
-}
-
-static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    if (pInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pInfo);
-
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_info__win32(pVFS, file, pInfo);
-#else
-    return ma_default_vfs_info__stdio(pVFS, file, pInfo);
-#endif
-}
-
-
-MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pVFS == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pVFS->cb.onOpen  = ma_default_vfs_open;
-    pVFS->cb.onOpenW = ma_default_vfs_open_w;
-    pVFS->cb.onClose = ma_default_vfs_close;
-    pVFS->cb.onRead  = ma_default_vfs_read;
-    pVFS->cb.onWrite = ma_default_vfs_write;
-    pVFS->cb.onSeek  = ma_default_vfs_seek;
-    pVFS->cb.onTell  = ma_default_vfs_tell;
-    pVFS->cb.onInfo  = ma_default_vfs_info;
-    ma_allocation_callbacks_init_copy(&pVFS->allocationCallbacks, pAllocationCallbacks);
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_vfs_or_default_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_open(pVFS, pFilePath, openMode, pFile);
-    } else {
-        return ma_default_vfs_open(pVFS, pFilePath, openMode, pFile);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_open_w(pVFS, pFilePath, openMode, pFile);
-    } else {
-        return ma_default_vfs_open_w(pVFS, pFilePath, openMode, pFile);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_close(pVFS, file);
-    } else {
-        return ma_default_vfs_close(pVFS, file);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead);
-    } else {
-        return ma_default_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-    } else {
-        return ma_default_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_seek(pVFS, file, offset, origin);
-    } else {
-        return ma_default_vfs_seek(pVFS, file, offset, origin);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_tell(pVFS, file, pCursor);
-    } else {
-        return ma_default_vfs_tell(pVFS, file, pCursor);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_info(pVFS, file, pInfo);
-    } else {
-        return ma_default_vfs_info(pVFS, file, pInfo);
-    }
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Decoding and Encoding Headers. These are auto-generated from a tool.
-
-**************************************************************************************************************************************************************/
-#if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING))
-/* dr_wav_h begin */
-#ifndef dr_wav_h
-#define dr_wav_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRWAV_STRINGIFY(x)      #x
-#define DRWAV_XSTRINGIFY(x)     DRWAV_STRINGIFY(x)
-#define DRWAV_VERSION_MAJOR     0
-#define DRWAV_VERSION_MINOR     12
-#define DRWAV_VERSION_REVISION  19
-#define DRWAV_VERSION_STRING    DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drwav_int8;
-typedef unsigned char           drwav_uint8;
-typedef   signed short          drwav_int16;
-typedef unsigned short          drwav_uint16;
-typedef   signed int            drwav_int32;
-typedef unsigned int            drwav_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drwav_int64;
-    typedef unsigned __int64    drwav_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drwav_int64;
-    typedef unsigned long long  drwav_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drwav_uint64        drwav_uintptr;
-#else
-    typedef drwav_uint32        drwav_uintptr;
-#endif
-typedef drwav_uint8             drwav_bool8;
-typedef drwav_uint32            drwav_bool32;
-#define DRWAV_TRUE              1
-#define DRWAV_FALSE             0
-#if !defined(DRWAV_API)
-    #if defined(DRWAV_DLL)
-        #if defined(_WIN32)
-            #define DRWAV_DLL_IMPORT  __declspec(dllimport)
-            #define DRWAV_DLL_EXPORT  __declspec(dllexport)
-            #define DRWAV_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRWAV_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRWAV_DLL_IMPORT
-                #define DRWAV_DLL_EXPORT
-                #define DRWAV_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-            #define DRWAV_API  DRWAV_DLL_EXPORT
-        #else
-            #define DRWAV_API  DRWAV_DLL_IMPORT
-        #endif
-        #define DRWAV_PRIVATE DRWAV_DLL_PRIVATE
-    #else
-        #define DRWAV_API extern
-        #define DRWAV_PRIVATE static
-    #endif
-#endif
-typedef drwav_int32 drwav_result;
-#define DRWAV_SUCCESS                        0
-#define DRWAV_ERROR                         -1
-#define DRWAV_INVALID_ARGS                  -2
-#define DRWAV_INVALID_OPERATION             -3
-#define DRWAV_OUT_OF_MEMORY                 -4
-#define DRWAV_OUT_OF_RANGE                  -5
-#define DRWAV_ACCESS_DENIED                 -6
-#define DRWAV_DOES_NOT_EXIST                -7
-#define DRWAV_ALREADY_EXISTS                -8
-#define DRWAV_TOO_MANY_OPEN_FILES           -9
-#define DRWAV_INVALID_FILE                  -10
-#define DRWAV_TOO_BIG                       -11
-#define DRWAV_PATH_TOO_LONG                 -12
-#define DRWAV_NAME_TOO_LONG                 -13
-#define DRWAV_NOT_DIRECTORY                 -14
-#define DRWAV_IS_DIRECTORY                  -15
-#define DRWAV_DIRECTORY_NOT_EMPTY           -16
-#define DRWAV_END_OF_FILE                   -17
-#define DRWAV_NO_SPACE                      -18
-#define DRWAV_BUSY                          -19
-#define DRWAV_IO_ERROR                      -20
-#define DRWAV_INTERRUPT                     -21
-#define DRWAV_UNAVAILABLE                   -22
-#define DRWAV_ALREADY_IN_USE                -23
-#define DRWAV_BAD_ADDRESS                   -24
-#define DRWAV_BAD_SEEK                      -25
-#define DRWAV_BAD_PIPE                      -26
-#define DRWAV_DEADLOCK                      -27
-#define DRWAV_TOO_MANY_LINKS                -28
-#define DRWAV_NOT_IMPLEMENTED               -29
-#define DRWAV_NO_MESSAGE                    -30
-#define DRWAV_BAD_MESSAGE                   -31
-#define DRWAV_NO_DATA_AVAILABLE             -32
-#define DRWAV_INVALID_DATA                  -33
-#define DRWAV_TIMEOUT                       -34
-#define DRWAV_NO_NETWORK                    -35
-#define DRWAV_NOT_UNIQUE                    -36
-#define DRWAV_NOT_SOCKET                    -37
-#define DRWAV_NO_ADDRESS                    -38
-#define DRWAV_BAD_PROTOCOL                  -39
-#define DRWAV_PROTOCOL_UNAVAILABLE          -40
-#define DRWAV_PROTOCOL_NOT_SUPPORTED        -41
-#define DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRWAV_SOCKET_NOT_SUPPORTED          -44
-#define DRWAV_CONNECTION_RESET              -45
-#define DRWAV_ALREADY_CONNECTED             -46
-#define DRWAV_NOT_CONNECTED                 -47
-#define DRWAV_CONNECTION_REFUSED            -48
-#define DRWAV_NO_HOST                       -49
-#define DRWAV_IN_PROGRESS                   -50
-#define DRWAV_CANCELLED                     -51
-#define DRWAV_MEMORY_ALREADY_MAPPED         -52
-#define DRWAV_AT_END                        -53
-#define DR_WAVE_FORMAT_PCM          0x1
-#define DR_WAVE_FORMAT_ADPCM        0x2
-#define DR_WAVE_FORMAT_IEEE_FLOAT   0x3
-#define DR_WAVE_FORMAT_ALAW         0x6
-#define DR_WAVE_FORMAT_MULAW        0x7
-#define DR_WAVE_FORMAT_DVI_ADPCM    0x11
-#define DR_WAVE_FORMAT_EXTENSIBLE   0xFFFE
-#ifndef DRWAV_MAX_SMPL_LOOPS
-#define DRWAV_MAX_SMPL_LOOPS        1
-#endif
-#define DRWAV_SEQUENTIAL            0x00000001
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision);
-DRWAV_API const char* drwav_version_string(void);
-typedef enum
-{
-    drwav_seek_origin_start,
-    drwav_seek_origin_current
-} drwav_seek_origin;
-typedef enum
-{
-    drwav_container_riff,
-    drwav_container_w64,
-    drwav_container_rf64
-} drwav_container;
-typedef struct
-{
-    union
-    {
-        drwav_uint8 fourcc[4];
-        drwav_uint8 guid[16];
-    } id;
-    drwav_uint64 sizeInBytes;
-    unsigned int paddingSize;
-} drwav_chunk_header;
-typedef struct
-{
-    drwav_uint16 formatTag;
-    drwav_uint16 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 avgBytesPerSec;
-    drwav_uint16 blockAlign;
-    drwav_uint16 bitsPerSample;
-    drwav_uint16 extendedSize;
-    drwav_uint16 validBitsPerSample;
-    drwav_uint32 channelMask;
-    drwav_uint8 subFormat[16];
-} drwav_fmt;
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT);
-typedef size_t (* drwav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef size_t (* drwav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite);
-typedef drwav_bool32 (* drwav_seek_proc)(void* pUserData, int offset, drwav_seek_origin origin);
-typedef drwav_uint64 (* drwav_chunk_proc)(void* pChunkUserData, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_chunk_header* pChunkHeader, drwav_container container, const drwav_fmt* pFMT);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drwav_allocation_callbacks;
-typedef struct
-{
-    const drwav_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drwav__memory_stream;
-typedef struct
-{
-    void** ppData;
-    size_t* pDataSize;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t currentWritePos;
-} drwav__memory_stream_write;
-typedef struct
-{
-    drwav_container container;
-    drwav_uint32 format;
-    drwav_uint32 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 bitsPerSample;
-} drwav_data_format;
-typedef struct
-{
-    drwav_uint32 cuePointId;
-    drwav_uint32 type;
-    drwav_uint32 start;
-    drwav_uint32 end;
-    drwav_uint32 fraction;
-    drwav_uint32 playCount;
-} drwav_smpl_loop;
- typedef struct
-{
-    drwav_uint32 manufacturer;
-    drwav_uint32 product;
-    drwav_uint32 samplePeriod;
-    drwav_uint32 midiUnityNotes;
-    drwav_uint32 midiPitchFraction;
-    drwav_uint32 smpteFormat;
-    drwav_uint32 smpteOffset;
-    drwav_uint32 numSampleLoops;
-    drwav_uint32 samplerData;
-    drwav_smpl_loop loops[DRWAV_MAX_SMPL_LOOPS];
-} drwav_smpl;
-typedef struct
-{
-    drwav_read_proc onRead;
-    drwav_write_proc onWrite;
-    drwav_seek_proc onSeek;
-    void* pUserData;
-    drwav_allocation_callbacks allocationCallbacks;
-    drwav_container container;
-    drwav_fmt fmt;
-    drwav_uint32 sampleRate;
-    drwav_uint16 channels;
-    drwav_uint16 bitsPerSample;
-    drwav_uint16 translatedFormatTag;
-    drwav_uint64 totalPCMFrameCount;
-    drwav_uint64 dataChunkDataSize;
-    drwav_uint64 dataChunkDataPos;
-    drwav_uint64 bytesRemaining;
-    drwav_uint64 dataChunkDataSizeTargetWrite;
-    drwav_bool32 isSequentialWrite;
-    drwav_smpl smpl;
-    drwav__memory_stream memoryStream;
-    drwav__memory_stream_write memoryStreamWrite;
-    struct
-    {
-        drwav_uint64 iCurrentPCMFrame;
-    } compressed;
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_uint16 predictor[2];
-        drwav_int32  delta[2];
-        drwav_int32  cachedFrames[4];
-        drwav_uint32 cachedFrameCount;
-        drwav_int32  prevFrames[2][2];
-    } msadpcm;
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_int32  predictor[2];
-        drwav_int32  stepIndex[2];
-        drwav_int32  cachedFrames[16];
-        drwav_uint32 cachedFrameCount;
-    } ima;
-} drwav;
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-DRWAV_API drwav_result drwav_uninit(drwav* pWav);
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex);
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-#ifndef DR_WAV_NO_CONVERSION_API
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount);
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-#endif
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_CONVERSION_API
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data);
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data);
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data);
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data);
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data);
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data);
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16]);
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_wav_h end */
-#endif  /* MA_NO_WAV */
-
-#if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING)
-/* dr_flac_h begin */
-#ifndef dr_flac_h
-#define dr_flac_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRFLAC_STRINGIFY(x)      #x
-#define DRFLAC_XSTRINGIFY(x)     DRFLAC_STRINGIFY(x)
-#define DRFLAC_VERSION_MAJOR     0
-#define DRFLAC_VERSION_MINOR     12
-#define DRFLAC_VERSION_REVISION  29
-#define DRFLAC_VERSION_STRING    DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drflac_int8;
-typedef unsigned char           drflac_uint8;
-typedef   signed short          drflac_int16;
-typedef unsigned short          drflac_uint16;
-typedef   signed int            drflac_int32;
-typedef unsigned int            drflac_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drflac_int64;
-    typedef unsigned __int64    drflac_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drflac_int64;
-    typedef unsigned long long  drflac_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drflac_uint64       drflac_uintptr;
-#else
-    typedef drflac_uint32       drflac_uintptr;
-#endif
-typedef drflac_uint8            drflac_bool8;
-typedef drflac_uint32           drflac_bool32;
-#define DRFLAC_TRUE             1
-#define DRFLAC_FALSE            0
-#if !defined(DRFLAC_API)
-    #if defined(DRFLAC_DLL)
-        #if defined(_WIN32)
-            #define DRFLAC_DLL_IMPORT  __declspec(dllimport)
-            #define DRFLAC_DLL_EXPORT  __declspec(dllexport)
-            #define DRFLAC_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRFLAC_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRFLAC_DLL_IMPORT
-                #define DRFLAC_DLL_EXPORT
-                #define DRFLAC_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-            #define DRFLAC_API  DRFLAC_DLL_EXPORT
-        #else
-            #define DRFLAC_API  DRFLAC_DLL_IMPORT
-        #endif
-        #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
-    #else
-        #define DRFLAC_API extern
-        #define DRFLAC_PRIVATE static
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1700
-    #define DRFLAC_DEPRECATED       __declspec(deprecated)
-#elif (defined(__GNUC__) && __GNUC__ >= 4)
-    #define DRFLAC_DEPRECATED       __attribute__((deprecated))
-#elif defined(__has_feature)
-    #if __has_feature(attribute_deprecated)
-        #define DRFLAC_DEPRECATED   __attribute__((deprecated))
-    #else
-        #define DRFLAC_DEPRECATED
-    #endif
-#else
-    #define DRFLAC_DEPRECATED
-#endif
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
-DRFLAC_API const char* drflac_version_string(void);
-#ifndef DR_FLAC_BUFFER_SIZE
-#define DR_FLAC_BUFFER_SIZE   4096
-#endif
-#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-#define DRFLAC_64BIT
-#endif
-#ifdef DRFLAC_64BIT
-typedef drflac_uint64 drflac_cache_t;
-#else
-typedef drflac_uint32 drflac_cache_t;
-#endif
-#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO       0
-#define DRFLAC_METADATA_BLOCK_TYPE_PADDING          1
-#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION      2
-#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE        3
-#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT   4
-#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET         5
-#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE          6
-#define DRFLAC_METADATA_BLOCK_TYPE_INVALID          127
-#define DRFLAC_PICTURE_TYPE_OTHER                   0
-#define DRFLAC_PICTURE_TYPE_FILE_ICON               1
-#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON         2
-#define DRFLAC_PICTURE_TYPE_COVER_FRONT             3
-#define DRFLAC_PICTURE_TYPE_COVER_BACK              4
-#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE            5
-#define DRFLAC_PICTURE_TYPE_MEDIA                   6
-#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST             7
-#define DRFLAC_PICTURE_TYPE_ARTIST                  8
-#define DRFLAC_PICTURE_TYPE_CONDUCTOR               9
-#define DRFLAC_PICTURE_TYPE_BAND                    10
-#define DRFLAC_PICTURE_TYPE_COMPOSER                11
-#define DRFLAC_PICTURE_TYPE_LYRICIST                12
-#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION      13
-#define DRFLAC_PICTURE_TYPE_DURING_RECORDING        14
-#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE      15
-#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE          16
-#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH     17
-#define DRFLAC_PICTURE_TYPE_ILLUSTRATION            18
-#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE           19
-#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE      20
-typedef enum
-{
-    drflac_container_native,
-    drflac_container_ogg,
-    drflac_container_unknown
-} drflac_container;
-typedef enum
-{
-    drflac_seek_origin_start,
-    drflac_seek_origin_current
-} drflac_seek_origin;
-#pragma pack(2)
-typedef struct
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 flacFrameOffset;
-    drflac_uint16 pcmFrameCount;
-} drflac_seekpoint;
-#pragma pack()
-typedef struct
-{
-    drflac_uint16 minBlockSizeInPCMFrames;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint32 minFrameSizeInPCMFrames;
-    drflac_uint32 maxFrameSizeInPCMFrames;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint8  md5[16];
-} drflac_streaminfo;
-typedef struct
-{
-    drflac_uint32 type;
-    const void* pRawData;
-    drflac_uint32 rawDataSize;
-    union
-    {
-        drflac_streaminfo streaminfo;
-        struct
-        {
-            int unused;
-        } padding;
-        struct
-        {
-            drflac_uint32 id;
-            const void* pData;
-            drflac_uint32 dataSize;
-        } application;
-        struct
-        {
-            drflac_uint32 seekpointCount;
-            const drflac_seekpoint* pSeekpoints;
-        } seektable;
-        struct
-        {
-            drflac_uint32 vendorLength;
-            const char* vendor;
-            drflac_uint32 commentCount;
-            const void* pComments;
-        } vorbis_comment;
-        struct
-        {
-            char catalog[128];
-            drflac_uint64 leadInSampleCount;
-            drflac_bool32 isCD;
-            drflac_uint8 trackCount;
-            const void* pTrackData;
-        } cuesheet;
-        struct
-        {
-            drflac_uint32 type;
-            drflac_uint32 mimeLength;
-            const char* mime;
-            drflac_uint32 descriptionLength;
-            const char* description;
-            drflac_uint32 width;
-            drflac_uint32 height;
-            drflac_uint32 colorDepth;
-            drflac_uint32 indexColorCount;
-            drflac_uint32 pictureDataSize;
-            const drflac_uint8* pPictureData;
-        } picture;
-    } data;
-} drflac_metadata;
-typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
-typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drflac_allocation_callbacks;
-typedef struct
-{
-    const drflac_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drflac__memory_stream;
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    void* pUserData;
-    size_t unalignedByteCount;
-    drflac_cache_t unalignedCache;
-    drflac_uint32 nextL2Line;
-    drflac_uint32 consumedBits;
-    drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
-    drflac_cache_t cache;
-    drflac_uint16 crc16;
-    drflac_cache_t crc16Cache;
-    drflac_uint32 crc16CacheIgnoredBytes;
-} drflac_bs;
-typedef struct
-{
-    drflac_uint8 subframeType;
-    drflac_uint8 wastedBitsPerSample;
-    drflac_uint8 lpcOrder;
-    drflac_int32* pSamplesS32;
-} drflac_subframe;
-typedef struct
-{
-    drflac_uint64 pcmFrameNumber;
-    drflac_uint32 flacFrameNumber;
-    drflac_uint32 sampleRate;
-    drflac_uint16 blockSizeInPCMFrames;
-    drflac_uint8 channelAssignment;
-    drflac_uint8 bitsPerSample;
-    drflac_uint8 crc8;
-} drflac_frame_header;
-typedef struct
-{
-    drflac_frame_header header;
-    drflac_uint32 pcmFramesRemaining;
-    drflac_subframe subframes[8];
-} drflac_frame;
-typedef struct
-{
-    drflac_meta_proc onMeta;
-    void* pUserDataMD;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac_uint32 sampleRate;
-    drflac_uint8 channels;
-    drflac_uint8 bitsPerSample;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_container container;
-    drflac_uint32 seekpointCount;
-    drflac_frame currentFLACFrame;
-    drflac_uint64 currentPCMFrame;
-    drflac_uint64 firstFLACFramePosInBytes;
-    drflac__memory_stream memoryStream;
-    drflac_int32* pDecodedSamples;
-    drflac_seekpoint* pSeekpoints;
-    void* _oggbs;
-    drflac_bool32 _noSeekTableSeek    : 1;
-    drflac_bool32 _noBinarySearchSeek : 1;
-    drflac_bool32 _noBruteForceSeek   : 1;
-    drflac_bs bs;
-    drflac_uint8 pExtraData[1];
-} drflac;
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API void drflac_close(drflac* pFlac);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_vorbis_comment_iterator;
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_cuesheet_track_iterator;
-#pragma pack(4)
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 index;
-    drflac_uint8 reserved[3];
-} drflac_cuesheet_track_index;
-#pragma pack()
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 trackNumber;
-    char ISRC[12];
-    drflac_bool8 isAudio;
-    drflac_bool8 preEmphasis;
-    drflac_uint8 indexCount;
-    const drflac_cuesheet_track_index* pIndexPoints;
-} drflac_cuesheet_track;
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_flac_h end */
-#endif  /* MA_NO_FLAC */
-
-#if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING)
-/* dr_mp3_h begin */
-#ifndef dr_mp3_h
-#define dr_mp3_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRMP3_STRINGIFY(x)      #x
-#define DRMP3_XSTRINGIFY(x)     DRMP3_STRINGIFY(x)
-#define DRMP3_VERSION_MAJOR     0
-#define DRMP3_VERSION_MINOR     6
-#define DRMP3_VERSION_REVISION  27
-#define DRMP3_VERSION_STRING    DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drmp3_int8;
-typedef unsigned char           drmp3_uint8;
-typedef   signed short          drmp3_int16;
-typedef unsigned short          drmp3_uint16;
-typedef   signed int            drmp3_int32;
-typedef unsigned int            drmp3_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drmp3_int64;
-    typedef unsigned __int64    drmp3_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drmp3_int64;
-    typedef unsigned long long  drmp3_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drmp3_uint64        drmp3_uintptr;
-#else
-    typedef drmp3_uint32        drmp3_uintptr;
-#endif
-typedef drmp3_uint8             drmp3_bool8;
-typedef drmp3_uint32            drmp3_bool32;
-#define DRMP3_TRUE              1
-#define DRMP3_FALSE             0
-#if !defined(DRMP3_API)
-    #if defined(DRMP3_DLL)
-        #if defined(_WIN32)
-            #define DRMP3_DLL_IMPORT  __declspec(dllimport)
-            #define DRMP3_DLL_EXPORT  __declspec(dllexport)
-            #define DRMP3_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRMP3_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRMP3_DLL_IMPORT
-                #define DRMP3_DLL_EXPORT
-                #define DRMP3_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-            #define DRMP3_API  DRMP3_DLL_EXPORT
-        #else
-            #define DRMP3_API  DRMP3_DLL_IMPORT
-        #endif
-        #define DRMP3_PRIVATE DRMP3_DLL_PRIVATE
-    #else
-        #define DRMP3_API extern
-        #define DRMP3_PRIVATE static
-    #endif
-#endif
-typedef drmp3_int32 drmp3_result;
-#define DRMP3_SUCCESS                        0
-#define DRMP3_ERROR                         -1
-#define DRMP3_INVALID_ARGS                  -2
-#define DRMP3_INVALID_OPERATION             -3
-#define DRMP3_OUT_OF_MEMORY                 -4
-#define DRMP3_OUT_OF_RANGE                  -5
-#define DRMP3_ACCESS_DENIED                 -6
-#define DRMP3_DOES_NOT_EXIST                -7
-#define DRMP3_ALREADY_EXISTS                -8
-#define DRMP3_TOO_MANY_OPEN_FILES           -9
-#define DRMP3_INVALID_FILE                  -10
-#define DRMP3_TOO_BIG                       -11
-#define DRMP3_PATH_TOO_LONG                 -12
-#define DRMP3_NAME_TOO_LONG                 -13
-#define DRMP3_NOT_DIRECTORY                 -14
-#define DRMP3_IS_DIRECTORY                  -15
-#define DRMP3_DIRECTORY_NOT_EMPTY           -16
-#define DRMP3_END_OF_FILE                   -17
-#define DRMP3_NO_SPACE                      -18
-#define DRMP3_BUSY                          -19
-#define DRMP3_IO_ERROR                      -20
-#define DRMP3_INTERRUPT                     -21
-#define DRMP3_UNAVAILABLE                   -22
-#define DRMP3_ALREADY_IN_USE                -23
-#define DRMP3_BAD_ADDRESS                   -24
-#define DRMP3_BAD_SEEK                      -25
-#define DRMP3_BAD_PIPE                      -26
-#define DRMP3_DEADLOCK                      -27
-#define DRMP3_TOO_MANY_LINKS                -28
-#define DRMP3_NOT_IMPLEMENTED               -29
-#define DRMP3_NO_MESSAGE                    -30
-#define DRMP3_BAD_MESSAGE                   -31
-#define DRMP3_NO_DATA_AVAILABLE             -32
-#define DRMP3_INVALID_DATA                  -33
-#define DRMP3_TIMEOUT                       -34
-#define DRMP3_NO_NETWORK                    -35
-#define DRMP3_NOT_UNIQUE                    -36
-#define DRMP3_NOT_SOCKET                    -37
-#define DRMP3_NO_ADDRESS                    -38
-#define DRMP3_BAD_PROTOCOL                  -39
-#define DRMP3_PROTOCOL_UNAVAILABLE          -40
-#define DRMP3_PROTOCOL_NOT_SUPPORTED        -41
-#define DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRMP3_SOCKET_NOT_SUPPORTED          -44
-#define DRMP3_CONNECTION_RESET              -45
-#define DRMP3_ALREADY_CONNECTED             -46
-#define DRMP3_NOT_CONNECTED                 -47
-#define DRMP3_CONNECTION_REFUSED            -48
-#define DRMP3_NO_HOST                       -49
-#define DRMP3_IN_PROGRESS                   -50
-#define DRMP3_CANCELLED                     -51
-#define DRMP3_MEMORY_ALREADY_MAPPED         -52
-#define DRMP3_AT_END                        -53
-#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME  1152
-#define DRMP3_MAX_SAMPLES_PER_FRAME         (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
-#ifdef _MSC_VER
-    #define DRMP3_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRMP3_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRMP3_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRMP3_INLINE __inline
-#else
-    #define DRMP3_INLINE
-#endif
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision);
-DRMP3_API const char* drmp3_version_string(void);
-typedef struct
-{
-    int frame_bytes, channels, hz, layer, bitrate_kbps;
-} drmp3dec_frame_info;
-typedef struct
-{
-    float mdct_overlap[2][9*32], qmf_state[15*2*32];
-    int reserv, free_format_bytes;
-    drmp3_uint8 header[4], reserv_buf[511];
-} drmp3dec;
-DRMP3_API void drmp3dec_init(drmp3dec *dec);
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info);
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples);
-typedef enum
-{
-    drmp3_seek_origin_start,
-    drmp3_seek_origin_current
-} drmp3_seek_origin;
-typedef struct
-{
-    drmp3_uint64 seekPosInBytes;
-    drmp3_uint64 pcmFrameIndex;
-    drmp3_uint16 mp3FramesToDiscard;
-    drmp3_uint16 pcmFramesToDiscard;
-} drmp3_seek_point;
-typedef size_t (* drmp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef drmp3_bool32 (* drmp3_seek_proc)(void* pUserData, int offset, drmp3_seek_origin origin);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drmp3_allocation_callbacks;
-typedef struct
-{
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-} drmp3_config;
-typedef struct
-{
-    drmp3dec decoder;
-    drmp3dec_frame_info frameInfo;
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-    drmp3_read_proc onRead;
-    drmp3_seek_proc onSeek;
-    void* pUserData;
-    drmp3_allocation_callbacks allocationCallbacks;
-    drmp3_uint32 mp3FrameChannels;
-    drmp3_uint32 mp3FrameSampleRate;
-    drmp3_uint32 pcmFramesConsumedInMP3Frame;
-    drmp3_uint32 pcmFramesRemainingInMP3Frame;
-    drmp3_uint8 pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 streamCursor;
-    drmp3_seek_point* pSeekPoints;
-    drmp3_uint32 seekPointCount;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t dataConsumed;
-    drmp3_uint8* pData;
-    drmp3_bool32 atEnd : 1;
-    struct
-    {
-        const drmp3_uint8* pData;
-        size_t dataSize;
-        size_t currentReadPos;
-    } memory;
-} drmp3;
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRMP3_API void drmp3_uninit(drmp3* pMP3);
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut);
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut);
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex);
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3);
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3);
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount);
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints);
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints);
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_mp3_h end */
-#endif  /* MA_NO_MP3 */
-
-
-/**************************************************************************************************************************************************************
-
-Decoding
-
-**************************************************************************************************************************************************************/
-#ifndef MA_NO_DECODING
-
-static size_t ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead;
-
-    MA_ASSERT(pDecoder != NULL);
-    MA_ASSERT(pBufferOut != NULL);
-
-    bytesRead = pDecoder->onRead(pDecoder, pBufferOut, bytesToRead);
-    pDecoder->readPointerInBytes += bytesRead;
-
-    return bytesRead;
-}
-
-static ma_bool32 ma_decoder_seek_bytes(ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin)
-{
-    ma_bool32 wasSuccessful;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    wasSuccessful = pDecoder->onSeek(pDecoder, byteOffset, origin);
-    if (wasSuccessful) {
-        if (origin == ma_seek_origin_start) {
-            pDecoder->readPointerInBytes = (ma_uint64)byteOffset;
-        } else {
-            pDecoder->readPointerInBytes += byteOffset;
-        }
-    }
-
-    return wasSuccessful;
-}
-
-
-MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate)
-{
-    ma_decoder_config config;
-    MA_ZERO_OBJECT(&config);
-    config.format     = outputFormat;
-    config.channels   = ma_min(outputChannels, ma_countof(config.channelMap));
-    config.sampleRate = outputSampleRate;
-    config.resampling.algorithm = ma_resample_algorithm_linear;
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.resampling.speex.quality = 3;
-
-    /* Note that we are intentionally leaving the channel map empty here which will cause the default channel map to be used. */
-
-    return config;
-}
-
-MA_API ma_decoder_config ma_decoder_config_init_copy(const ma_decoder_config* pConfig)
-{
-    ma_decoder_config config;
-    if (pConfig != NULL) {
-        config = *pConfig;
-    } else {
-        MA_ZERO_OBJECT(&config);
-    }
-
-    return config;
-}
-
-static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_decoder_config* pConfig)
-{
-    ma_data_converter_config converterConfig;
-
-    MA_ASSERT(pDecoder != NULL);
-    MA_ASSERT(pConfig  != NULL);
-
-    /* Make sure we're not asking for too many channels. */
-    if (pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The internal channels should have already been validated at a higher level, but we'll do it again explicitly here for safety. */
-    if (pDecoder->internalChannels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-
-    /* Output format. */
-    if (pConfig->format == ma_format_unknown) {
-        pDecoder->outputFormat = pDecoder->internalFormat;
-    } else {
-        pDecoder->outputFormat = pConfig->format;
-    }
-
-    if (pConfig->channels == 0) {
-        pDecoder->outputChannels = pDecoder->internalChannels;
-    } else {
-        pDecoder->outputChannels = pConfig->channels;
-    }
-
-    if (pConfig->sampleRate == 0) {
-        pDecoder->outputSampleRate = pDecoder->internalSampleRate;
-    } else {
-        pDecoder->outputSampleRate = pConfig->sampleRate;
-    }
-
-    if (ma_channel_map_blank(pDecoder->outputChannels, pConfig->channelMap)) {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pDecoder->outputChannels, pDecoder->outputChannelMap);
-    } else {
-        MA_COPY_MEMORY(pDecoder->outputChannelMap, pConfig->channelMap, sizeof(pConfig->channelMap));
-    }
-
-
-    converterConfig = ma_data_converter_config_init(
-        pDecoder->internalFormat,     pDecoder->outputFormat,
-        pDecoder->internalChannels,   pDecoder->outputChannels,
-        pDecoder->internalSampleRate, pDecoder->outputSampleRate
-    );
-    ma_channel_map_copy(converterConfig.channelMapIn,  pDecoder->internalChannelMap, pDecoder->internalChannels);
-    ma_channel_map_copy(converterConfig.channelMapOut, pDecoder->outputChannelMap,   pDecoder->outputChannels);
-    converterConfig.channelMixMode             = pConfig->channelMixMode;
-    converterConfig.ditherMode                 = pConfig->ditherMode;
-    converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;   /* Never allow dynamic sample rate conversion. Setting this to true will disable passthrough optimizations. */
-    converterConfig.resampling.algorithm       = pConfig->resampling.algorithm;
-    converterConfig.resampling.linear.lpfOrder = pConfig->resampling.linear.lpfOrder;
-    converterConfig.resampling.speex.quality   = pConfig->resampling.speex.quality;
-
-    return ma_data_converter_init(&converterConfig, &pDecoder->converter);
-}
-
-/* WAV */
-#ifdef dr_wav_h
-#define MA_HAS_WAV
-
-static size_t ma_decoder_internal_on_read__wav(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drwav_bool32 ma_decoder_internal_on_seek__wav(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drwav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__wav(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pWav = (drwav*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pWav != NULL);
-
-    switch (pDecoder->internalFormat) {
-        case ma_format_s16: return drwav_read_pcm_frames_s16(pWav, frameCount, (drwav_int16*)pFramesOut);
-        case ma_format_s32: return drwav_read_pcm_frames_s32(pWav, frameCount, (drwav_int32*)pFramesOut);
-        case ma_format_f32: return drwav_read_pcm_frames_f32(pWav, frameCount,       (float*)pFramesOut);
-        default: break;
-    }
-
-    /* Should never get here. If we do, it means the internal format was not set correctly at initialization time. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__wav(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drwav* pWav;
-    drwav_bool32 result;
-
-    pWav = (drwav*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pWav != NULL);
-
-    result = drwav_seek_to_pcm_frame(pWav, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__wav(ma_decoder* pDecoder)
-{
-    drwav_uninit((drwav*)pDecoder->pInternalDecoder);
-    ma__free_from_callbacks(pDecoder->pInternalDecoder, &pDecoder->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__wav(ma_decoder* pDecoder)
-{
-    return ((drwav*)pDecoder->pInternalDecoder)->totalPCMFrameCount;
-}
-
-static ma_result ma_decoder_init_wav__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drwav* pWav;
-    drwav_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfig;
-
-    pWav = (drwav*)ma__malloc_from_callbacks(sizeof(*pWav), &pDecoder->allocationCallbacks);
-    if (pWav == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /* Try opening the decoder first. */
-    if (!drwav_init(pWav, ma_decoder_internal_on_read__wav, ma_decoder_internal_on_seek__wav, pDecoder, &allocationCallbacks)) {
-        ma__free_from_callbacks(pWav, &pDecoder->allocationCallbacks);
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the WAV decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__wav;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__wav;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__wav;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__wav;
-    pDecoder->pInternalDecoder       = pWav;
-
-    /* Try to be as optimal as possible for the internal format. If miniaudio does not support a format we will fall back to f32. */
-    pDecoder->internalFormat = ma_format_unknown;
-    switch (pWav->translatedFormatTag) {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            if (pWav->bitsPerSample == 8) {
-                pDecoder->internalFormat = ma_format_s16;
-            } else if (pWav->bitsPerSample == 16) {
-                pDecoder->internalFormat = ma_format_s16;
-            } else if (pWav->bitsPerSample == 32) {
-                pDecoder->internalFormat = ma_format_s32;
-            }
-        } break;
-
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            if (pWav->bitsPerSample == 32) {
-                pDecoder->internalFormat = ma_format_f32;
-            }
-        } break;
-
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        {
-            pDecoder->internalFormat = ma_format_s16;
-        } break;
-    }
-
-    if (pDecoder->internalFormat == ma_format_unknown) {
-        pDecoder->internalFormat = ma_format_f32;
-    }
-
-    pDecoder->internalChannels = pWav->channels;
-    pDecoder->internalSampleRate = pWav->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_wav_h */
-
-/* FLAC */
-#ifdef dr_flac_h
-#define MA_HAS_FLAC
-
-static size_t ma_decoder_internal_on_read__flac(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drflac_bool32 ma_decoder_internal_on_seek__flac(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drflac_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__flac(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drflac* pFlac;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pFlac = (drflac*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pFlac != NULL);
-
-    switch (pDecoder->internalFormat) {
-        case ma_format_s16: return drflac_read_pcm_frames_s16(pFlac, frameCount, (drflac_int16*)pFramesOut);
-        case ma_format_s32: return drflac_read_pcm_frames_s32(pFlac, frameCount, (drflac_int32*)pFramesOut);
-        case ma_format_f32: return drflac_read_pcm_frames_f32(pFlac, frameCount,        (float*)pFramesOut);
-        default: break;
-    }
-
-    /* Should never get here. If we do, it means the internal format was not set correctly at initialization time. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__flac(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drflac* pFlac;
-    drflac_bool32 result;
-
-    pFlac = (drflac*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pFlac != NULL);
-
-    result = drflac_seek_to_pcm_frame(pFlac, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__flac(ma_decoder* pDecoder)
-{
-    drflac_close((drflac*)pDecoder->pInternalDecoder);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__flac(ma_decoder* pDecoder)
-{
-    return ((drflac*)pDecoder->pInternalDecoder)->totalPCMFrameCount;
-}
-
-static ma_result ma_decoder_init_flac__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drflac* pFlac;
-    drflac_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig  != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /* Try opening the decoder first. */
-    pFlac = drflac_open(ma_decoder_internal_on_read__flac, ma_decoder_internal_on_seek__flac, pDecoder, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the FLAC decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__flac;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__flac;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__flac;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__flac;
-    pDecoder->pInternalDecoder       = pFlac;
-
-    /*
-    dr_flac supports reading as s32, s16 and f32. Try to do a one-to-one mapping if possible, but fall back to s32 if not. s32 is the "native" FLAC format
-    since it's the only one that's truly lossless. If the internal bits per sample is <= 16 we will decode to ma_format_s16 to keep it more efficient.
-    */
-    if (pConfig->format == ma_format_unknown) {
-        if (pFlac->bitsPerSample <= 16) {
-            pDecoder->internalFormat = ma_format_s16;
-        } else {
-            pDecoder->internalFormat = ma_format_s32;
-        }
-    } else {
-        if (pConfig->format == ma_format_s16 || pConfig->format == ma_format_f32) {
-            pDecoder->internalFormat = pConfig->format;
-        } else {
-            pDecoder->internalFormat = ma_format_s32;   /* s32 as the baseline to ensure no loss of precision for 24-bit encoded files. */
-        }
-    }
-
-    pDecoder->internalChannels = pFlac->channels;
-    pDecoder->internalSampleRate = pFlac->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_flac, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_flac_h */
-
-/* MP3 */
-#ifdef dr_mp3_h
-#define MA_HAS_MP3
-
-static size_t ma_decoder_internal_on_read__mp3(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drmp3_bool32 ma_decoder_internal_on_seek__mp3(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drmp3_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__mp3(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drmp3* pMP3;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pMP3 = (drmp3*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pMP3 != NULL);
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    MA_ASSERT(pDecoder->internalFormat == ma_format_f32);
-    return drmp3_read_pcm_frames_f32(pMP3, frameCount, (float*)pFramesOut);
-#else
-    MA_ASSERT(pDecoder->internalFormat == ma_format_s16);
-    return drmp3_read_pcm_frames_s16(pMP3, frameCount, (drmp3_int16*)pFramesOut);
-#endif
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__mp3(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drmp3* pMP3;
-    drmp3_bool32 result;
-
-    pMP3 = (drmp3*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pMP3 != NULL);
-
-    result = drmp3_seek_to_pcm_frame(pMP3, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__mp3(ma_decoder* pDecoder)
-{
-    drmp3_uninit((drmp3*)pDecoder->pInternalDecoder);
-    ma__free_from_callbacks(pDecoder->pInternalDecoder, &pDecoder->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__mp3(ma_decoder* pDecoder)
-{
-    return drmp3_get_pcm_frame_count((drmp3*)pDecoder->pInternalDecoder);
-}
-
-static ma_result ma_decoder_init_mp3__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drmp3* pMP3;
-    drmp3_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfig;
-
-    pMP3 = (drmp3*)ma__malloc_from_callbacks(sizeof(*pMP3), &pDecoder->allocationCallbacks);
-    if (pMP3 == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /*
-    Try opening the decoder first. We always use whatever dr_mp3 reports for channel count and sample rate. The format is determined by
-    the presence of DR_MP3_FLOAT_OUTPUT.
-    */
-    if (!drmp3_init(pMP3, ma_decoder_internal_on_read__mp3, ma_decoder_internal_on_seek__mp3, pDecoder, &allocationCallbacks)) {
-        ma__free_from_callbacks(pMP3, &pDecoder->allocationCallbacks);
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the MP3 decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__mp3;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__mp3;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__mp3;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__mp3;
-    pDecoder->pInternalDecoder       = pMP3;
-
-    /* Internal format. */
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    pDecoder->internalFormat     = ma_format_f32;
-#else
-    pDecoder->internalFormat     = ma_format_s16;
-#endif
-    pDecoder->internalChannels   = pMP3->channels;
-    pDecoder->internalSampleRate = pMP3->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_default, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_mp3_h */
-
-/* Vorbis */
-#ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H
-#define MA_HAS_VORBIS
-
-/* The size in bytes of each chunk of data to read from the Vorbis stream. */
-#define MA_VORBIS_DATA_CHUNK_SIZE  4096
-
-typedef struct
-{
-    stb_vorbis* pInternalVorbis;
-    ma_uint8* pData;
-    size_t dataSize;
-    size_t dataCapacity;
-    ma_uint32 framesConsumed;  /* The number of frames consumed in ppPacketData. */
-    ma_uint32 framesRemaining; /* The number of frames remaining in ppPacketData. */
-    float** ppPacketData;
-} ma_vorbis_decoder;
-
-static ma_uint64 ma_vorbis_decoder_read_pcm_frames(ma_vorbis_decoder* pVorbis, ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    float* pFramesOutF;
-    ma_uint64 totalFramesRead;
-
-    MA_ASSERT(pVorbis  != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    pFramesOutF = (float*)pFramesOut;
-
-    totalFramesRead = 0;
-    while (frameCount > 0) {
-        /* Read from the in-memory buffer first. */
-        ma_uint32 framesToReadFromCache = (ma_uint32)ma_min(pVorbis->framesRemaining, frameCount);  /* Safe cast because pVorbis->framesRemaining is 32-bit. */
-
-        if (pFramesOut != NULL) {
-            ma_uint64 iFrame;
-            for (iFrame = 0; iFrame < framesToReadFromCache; iFrame += 1) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pDecoder->internalChannels; ++iChannel) {
-                    pFramesOutF[iChannel] = pVorbis->ppPacketData[iChannel][pVorbis->framesConsumed+iFrame];
-                }
-                pFramesOutF += pDecoder->internalChannels;
-            }
-        }
-
-        pVorbis->framesConsumed  += framesToReadFromCache;
-        pVorbis->framesRemaining -= framesToReadFromCache;
-        frameCount               -= framesToReadFromCache;
-        totalFramesRead          += framesToReadFromCache;
-
-        if (frameCount == 0) {
-            break;
-        }
-
-        MA_ASSERT(pVorbis->framesRemaining == 0);
-
-        /* We've run out of cached frames, so decode the next packet and continue iteration. */
-        do
-        {
-            int samplesRead;
-            int consumedDataSize;
-
-            if (pVorbis->dataSize > INT_MAX) {
-                break;  /* Too big. */
-            }
-
-            samplesRead = 0;
-            consumedDataSize = stb_vorbis_decode_frame_pushdata(pVorbis->pInternalVorbis, pVorbis->pData, (int)pVorbis->dataSize, NULL, (float***)&pVorbis->ppPacketData, &samplesRead);
-            if (consumedDataSize != 0) {
-                size_t leftoverDataSize = (pVorbis->dataSize - (size_t)consumedDataSize);
-                size_t i;
-                for (i = 0; i < leftoverDataSize; ++i) {
-                    pVorbis->pData[i] = pVorbis->pData[i + consumedDataSize];
-                }
-
-                pVorbis->dataSize = leftoverDataSize;
-                pVorbis->framesConsumed = 0;
-                pVorbis->framesRemaining = samplesRead;
-                break;
-            } else {
-                /* Need more data. If there's any room in the existing buffer allocation fill that first. Otherwise expand. */
-                size_t bytesRead;
-                if (pVorbis->dataCapacity == pVorbis->dataSize) {
-                    /* No room. Expand. */
-                    size_t oldCap = pVorbis->dataCapacity;
-                    size_t newCap = pVorbis->dataCapacity + MA_VORBIS_DATA_CHUNK_SIZE;
-                    ma_uint8* pNewData;
-
-                    pNewData = (ma_uint8*)ma__realloc_from_callbacks(pVorbis->pData, newCap, oldCap, &pDecoder->allocationCallbacks);
-                    if (pNewData == NULL) {
-                        return totalFramesRead; /* Out of memory. */
-                    }
-
-                    pVorbis->pData = pNewData;
-                    pVorbis->dataCapacity = newCap;
-                }
-
-                /* Fill in a chunk. */
-                bytesRead = ma_decoder_read_bytes(pDecoder, pVorbis->pData + pVorbis->dataSize, (pVorbis->dataCapacity - pVorbis->dataSize));
-                if (bytesRead == 0) {
-                    return totalFramesRead; /* Error reading more data. */
-                }
-
-                pVorbis->dataSize += bytesRead;
-            }
-        } while (MA_TRUE);
-    }
-
-    return totalFramesRead;
-}
-
-static ma_result ma_vorbis_decoder_seek_to_pcm_frame(ma_vorbis_decoder* pVorbis, ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    float buffer[4096];
-
-    MA_ASSERT(pVorbis != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /*
-    This is terribly inefficient because stb_vorbis does not have a good seeking solution with it's push API. Currently this just performs
-    a full decode right from the start of the stream. Later on I'll need to write a layer that goes through all of the Ogg pages until we
-    find the one containing the sample we need. Then we know exactly where to seek for stb_vorbis.
-
-    TODO: Use seeking logic documented for stb_vorbis_flush_pushdata().
-    */
-    if (!ma_decoder_seek_bytes(pDecoder, 0, ma_seek_origin_start)) {
-        return MA_ERROR;
-    }
-
-    stb_vorbis_flush_pushdata(pVorbis->pInternalVorbis);
-    pVorbis->framesConsumed  = 0;
-    pVorbis->framesRemaining = 0;
-    pVorbis->dataSize        = 0;
-
-    while (frameIndex > 0) {
-        ma_uint32 framesRead;
-        ma_uint32 framesToRead = ma_countof(buffer)/pDecoder->internalChannels;
-        if (framesToRead > frameIndex) {
-            framesToRead = (ma_uint32)frameIndex;
-        }
-
-        framesRead = (ma_uint32)ma_vorbis_decoder_read_pcm_frames(pVorbis, pDecoder, buffer, framesToRead);
-        if (framesRead == 0) {
-            return MA_ERROR;
-        }
-
-        frameIndex -= framesRead;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__vorbis(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    ma_vorbis_decoder* pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    return ma_vorbis_decoder_seek_to_pcm_frame(pVorbis, pDecoder, frameIndex);
-}
-
-static ma_result ma_decoder_internal_on_uninit__vorbis(ma_decoder* pDecoder)
-{
-    ma_vorbis_decoder* pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    stb_vorbis_close(pVorbis->pInternalVorbis);
-    ma__free_from_callbacks(pVorbis->pData, &pDecoder->allocationCallbacks);
-    ma__free_from_callbacks(pVorbis,        &pDecoder->allocationCallbacks);
-
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__vorbis(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_vorbis_decoder* pVorbis;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pDecoder->internalFormat == ma_format_f32);
-
-    pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    return ma_vorbis_decoder_read_pcm_frames(pVorbis, pDecoder, pFramesOut, frameCount);
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__vorbis(ma_decoder* pDecoder)
-{
-    /* No good way to do this with Vorbis. */
-    (void)pDecoder;
-    return 0;
-}
-
-static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    stb_vorbis* pInternalVorbis = NULL;
-    size_t dataSize = 0;
-    size_t dataCapacity = 0;
-    ma_uint8* pData = NULL;
-    stb_vorbis_info vorbisInfo;
-    size_t vorbisDataSize;
-    ma_vorbis_decoder* pVorbis;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /* We grow the buffer in chunks. */
-    do
-    {
-        /* Allocate memory for a new chunk. */
-        ma_uint8* pNewData;
-        size_t bytesRead;
-        int vorbisError = 0;
-        int consumedDataSize = 0;
-        size_t oldCapacity = dataCapacity;
-
-        dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE;
-        pNewData = (ma_uint8*)ma__realloc_from_callbacks(pData, dataCapacity, oldCapacity, &pDecoder->allocationCallbacks);
-        if (pNewData == NULL) {
-            ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pData = pNewData;
-
-        /* Fill in a chunk. */
-        bytesRead = ma_decoder_read_bytes(pDecoder, pData + dataSize, (dataCapacity - dataSize));
-        if (bytesRead == 0) {
-            return MA_ERROR;
-        }
-
-        dataSize += bytesRead;
-        if (dataSize > INT_MAX) {
-            return MA_ERROR;   /* Too big. */
-        }
-
-        pInternalVorbis = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL);
-        if (pInternalVorbis != NULL) {
-            /*
-            If we get here it means we were able to open the stb_vorbis decoder. There may be some leftover bytes in our buffer, so
-            we need to move those bytes down to the front of the buffer since they'll be needed for future decoding.
-            */
-            size_t leftoverDataSize = (dataSize - (size_t)consumedDataSize);
-            size_t i;
-            for (i = 0; i < leftoverDataSize; ++i) {
-                pData[i] = pData[i + consumedDataSize];
-            }
-
-            dataSize = leftoverDataSize;
-            break;  /* Success. */
-        } else {
-            if (vorbisError == VORBIS_need_more_data) {
-                continue;
-            } else {
-                return MA_ERROR;   /* Failed to open the stb_vorbis decoder. */
-            }
-        }
-    } while (MA_TRUE);
-
-
-    /* If we get here it means we successfully opened the Vorbis decoder. */
-    vorbisInfo = stb_vorbis_get_info(pInternalVorbis);
-
-    /* Don't allow more than MA_MAX_CHANNELS channels. */
-    if (vorbisInfo.channels > MA_MAX_CHANNELS) {
-        stb_vorbis_close(pInternalVorbis);
-        ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-        return MA_ERROR;   /* Too many channels. */
-    }
-
-    vorbisDataSize = sizeof(ma_vorbis_decoder) + sizeof(float)*vorbisInfo.max_frame_size;
-    pVorbis = (ma_vorbis_decoder*)ma__malloc_from_callbacks(vorbisDataSize, &pDecoder->allocationCallbacks);
-    if (pVorbis == NULL) {
-        stb_vorbis_close(pInternalVorbis);
-        ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    MA_ZERO_MEMORY(pVorbis, vorbisDataSize);
-    pVorbis->pInternalVorbis = pInternalVorbis;
-    pVorbis->pData = pData;
-    pVorbis->dataSize = dataSize;
-    pVorbis->dataCapacity = dataCapacity;
-
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__vorbis;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__vorbis;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__vorbis;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__vorbis;
-    pDecoder->pInternalDecoder       = pVorbis;
-
-    /* The internal format is always f32. */
-    pDecoder->internalFormat     = ma_format_f32;
-    pDecoder->internalChannels   = vorbisInfo.channels;
-    pDecoder->internalSampleRate = vorbisInfo.sample_rate;
-    ma_get_standard_channel_map(ma_standard_channel_map_vorbis, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* STB_VORBIS_INCLUDE_STB_VORBIS_H */
-
-/* Raw */
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__raw(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint32 bpf;
-    ma_uint64 totalFramesRead;
-    void* pRunningFramesOut;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    /* For raw decoding we just read directly from the decoder's callbacks. */
-    bpf = ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-
-    totalFramesRead   = 0;
-    pRunningFramesOut = pFramesOut;
-
-    while (totalFramesRead < frameCount) {
-        ma_uint64 framesReadThisIteration;
-        ma_uint64 framesToReadThisIteration = (frameCount - totalFramesRead);
-        if (framesToReadThisIteration > 0x7FFFFFFF/bpf) {
-            framesToReadThisIteration = 0x7FFFFFFF/bpf;
-        }
-
-        if (pFramesOut != NULL) {
-            framesReadThisIteration = ma_decoder_read_bytes(pDecoder, pRunningFramesOut, (size_t)framesToReadThisIteration * bpf) / bpf;    /* Safe cast to size_t. */
-            pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIteration * bpf);
-        } else {
-            /* We'll first try seeking. If this fails it means the end was reached and we'll to do a read-and-discard slow path to get the exact amount. */
-            if (ma_decoder_seek_bytes(pDecoder, (int)framesToReadThisIteration, ma_seek_origin_current)) {
-                framesReadThisIteration = framesToReadThisIteration;
-            } else {
-                /* Slow path. Need to fall back to a read-and-discard. This is required so we can get the exact number of remaining. */
-                ma_uint8 buffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                ma_uint32 bufferCap = sizeof(buffer) / bpf;
-
-                framesReadThisIteration = 0;
-                while (framesReadThisIteration < framesToReadThisIteration) {
-                    ma_uint64 framesReadNow;
-                    ma_uint64 framesToReadNow = framesToReadThisIteration - framesReadThisIteration;
-                    if (framesToReadNow > bufferCap) {
-                        framesToReadNow = bufferCap;
-                    }
-
-                    framesReadNow = ma_decoder_read_bytes(pDecoder, buffer, (size_t)(framesToReadNow * bpf)) / bpf; /* Safe cast. */
-                    framesReadThisIteration += framesReadNow;
-
-                    if (framesReadNow < framesToReadNow) {
-                        break;  /* The end has been reached. */
-                    }
-                }
-            }
-        }
-
-        totalFramesRead += framesReadThisIteration;
-
-        if (framesReadThisIteration < framesToReadThisIteration) {
-            break;  /* Done. */
-        }
-    }
-
-    return totalFramesRead;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__raw(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    ma_bool32 result = MA_FALSE;
-    ma_uint64 totalBytesToSeek;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    if (pDecoder->onSeek == NULL) {
-        return MA_ERROR;
-    }
-
-    /* The callback uses a 32 bit integer whereas we use a 64 bit unsigned integer. We just need to continuously seek until we're at the correct position. */
-    totalBytesToSeek = frameIndex * ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-    if (totalBytesToSeek < 0x7FFFFFFF) {
-        /* Simple case. */
-        result = ma_decoder_seek_bytes(pDecoder, (int)(frameIndex * ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels)), ma_seek_origin_start);
-    } else {
-        /* Complex case. Start by doing a seek relative to the start. Then keep looping using offset seeking. */
-        result = ma_decoder_seek_bytes(pDecoder, 0x7FFFFFFF, ma_seek_origin_start);
-        if (result == MA_TRUE) {
-            totalBytesToSeek -= 0x7FFFFFFF;
-
-            while (totalBytesToSeek > 0) {
-                ma_uint64 bytesToSeekThisIteration = totalBytesToSeek;
-                if (bytesToSeekThisIteration > 0x7FFFFFFF) {
-                    bytesToSeekThisIteration = 0x7FFFFFFF;
-                }
-
-                result = ma_decoder_seek_bytes(pDecoder, (int)bytesToSeekThisIteration, ma_seek_origin_current);
-                if (result != MA_TRUE) {
-                    break;
-                }
-
-                totalBytesToSeek -= bytesToSeekThisIteration;
-            }
-        }
-    }
-
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__raw(ma_decoder* pDecoder)
-{
-    (void)pDecoder;
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__raw(ma_decoder* pDecoder)
-{
-    (void)pDecoder;
-    return 0;
-}
-
-static ma_result ma_decoder_init_raw__internal(const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    MA_ASSERT(pConfigIn != NULL);
-    MA_ASSERT(pConfigOut != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfigOut;
-
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__raw;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__raw;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__raw;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__raw;
-
-    /* Internal format. */
-    pDecoder->internalFormat     = pConfigIn->format;
-    pDecoder->internalChannels   = pConfigIn->channels;
-    pDecoder->internalSampleRate = pConfigIn->sampleRate;
-    ma_channel_map_copy(pDecoder->internalChannelMap, pConfigIn->channelMap, pConfigIn->channels);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__init_allocation_callbacks(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    MA_ASSERT(pDecoder != NULL);
-
-    if (pConfig != NULL) {
-        return ma_allocation_callbacks_init_copy(&pDecoder->allocationCallbacks, &pConfig->allocationCallbacks);
-    } else {
-        pDecoder->allocationCallbacks = ma_allocation_callbacks_init_default();
-        return MA_SUCCESS;
-    }
-}
-
-static ma_result ma_decoder__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_decoder_read_pcm_frames((ma_decoder*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_decoder_seek_to_pcm_frame((ma_decoder*)pDataSource, frameIndex);
-}
-
-static ma_result ma_decoder__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    *pFormat     = pDecoder->outputFormat;
-    *pChannels   = pDecoder->outputChannels;
-    *pSampleRate = pDecoder->outputSampleRate;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    return ma_decoder_get_cursor_in_pcm_frames(pDecoder, pLength);
-}
-
-static ma_result ma_decoder__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    *pLength = ma_decoder_get_length_in_pcm_frames(pDecoder);
-    if (*pLength == 0) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-
-    MA_ASSERT(pConfig != NULL);
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pDecoder);
-
-    if (onRead == NULL || onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pDecoder->ds.onRead          = ma_decoder__data_source_on_read;
-    pDecoder->ds.onSeek          = ma_decoder__data_source_on_seek;
-    pDecoder->ds.onGetDataFormat = ma_decoder__data_source_on_get_data_format;
-    pDecoder->ds.onGetCursor     = ma_decoder__data_source_on_get_cursor;
-    pDecoder->ds.onGetLength     = ma_decoder__data_source_on_get_length;
-
-    pDecoder->onRead    = onRead;
-    pDecoder->onSeek    = onSeek;
-    pDecoder->pUserData = pUserData;
-
-    result = ma_decoder__init_allocation_callbacks(pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__postinit(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = MA_SUCCESS;
-
-    /* Basic validation in case the internal decoder supports different limits to miniaudio. */
-    if (pDecoder->internalChannels < MA_MIN_CHANNELS || pDecoder->internalChannels > MA_MAX_CHANNELS) {
-        result = MA_INVALID_DATA;
-    }
-
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__init_data_converter(pDecoder, pConfig);
-    }
-
-    /* If we failed post initialization we need to uninitialize the decoder before returning to prevent a memory leak. */
-    if (result != MA_SUCCESS) {
-        ma_decoder_uninit(pDecoder);
-        return result;
-    }
-
-    return result;
-}
-
-MA_API ma_result ma_decoder_init_wav(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_flac(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_mp3(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vorbis(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_raw(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfigOut);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_raw__internal(pConfigIn, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-}
-
-static ma_result ma_decoder_init__internal(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = MA_NO_BACKEND;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /* Silence some warnings in the case that we don't have any decoder backends enabled. */
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-
-    /* We use trial and error to open a decoder. */
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_wav__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_flac__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_mp3__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_VORBIS
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_vorbis__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder_init__internal(onRead, onSeek, pUserData, &config, pDecoder);
-}
-
-
-static size_t ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRemaining;
-
-    MA_ASSERT(pDecoder->backend.memory.dataSize >= pDecoder->backend.memory.currentReadPos);
-
-    bytesRemaining = pDecoder->backend.memory.dataSize - pDecoder->backend.memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        MA_COPY_MEMORY(pBufferOut, pDecoder->backend.memory.pData + pDecoder->backend.memory.currentReadPos, bytesToRead);
-        pDecoder->backend.memory.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static ma_bool32 ma_decoder__on_seek_memory(ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin)
-{
-    if (origin == ma_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pDecoder->backend.memory.currentReadPos + byteOffset > pDecoder->backend.memory.dataSize) {
-                byteOffset = (int)(pDecoder->backend.memory.dataSize - pDecoder->backend.memory.currentReadPos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pDecoder->backend.memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pDecoder->backend.memory.currentReadPos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pDecoder->backend.memory.currentReadPos += byteOffset;
-    } else {
-        if ((ma_uint32)byteOffset <= pDecoder->backend.memory.dataSize) {
-            pDecoder->backend.memory.currentReadPos = byteOffset;
-        } else {
-            pDecoder->backend.memory.currentReadPos = pDecoder->backend.memory.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return MA_TRUE;
-}
-
-static ma_result ma_decoder__preinit_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = ma_decoder__preinit(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pData == NULL || dataSize == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pDecoder->backend.memory.pData = (const ma_uint8*)pData;
-    pDecoder->backend.memory.dataSize = dataSize;
-    pDecoder->backend.memory.currentReadPos = 0;
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder_init__internal(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, &config, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_memory_wav(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_flac(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_mp3(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_vorbis(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_raw(const void* pData, size_t dataSize, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfigOut);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_raw__internal(pConfigIn, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-}
-
-
-#if defined(MA_HAS_WAV)    || \
-    defined(MA_HAS_MP3)    || \
-    defined(MA_HAS_FLAC)   || \
-    defined(MA_HAS_VORBIS) || \
-    defined(MA_HAS_OPUS)
-#define MA_HAS_PATH_API
-#endif
-
-#if defined(MA_HAS_PATH_API)
-static const char* ma_path_file_name(const char* path)
-{
-    const char* fileName;
-
-    if (path == NULL) {
-        return NULL;
-    }
-
-    fileName = path;
-
-    /* We just loop through the path until we find the last slash. */
-    while (path[0] != '\0') {
-        if (path[0] == '/' || path[0] == '\\') {
-            fileName = path;
-        }
-
-        path += 1;
-    }
-
-    /* At this point the file name is sitting on a slash, so just move forward. */
-    while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) {
-        fileName += 1;
-    }
-
-    return fileName;
-}
-
-static const wchar_t* ma_path_file_name_w(const wchar_t* path)
-{
-    const wchar_t* fileName;
-
-    if (path == NULL) {
-        return NULL;
-    }
-
-    fileName = path;
-
-    /* We just loop through the path until we find the last slash. */
-    while (path[0] != '\0') {
-        if (path[0] == '/' || path[0] == '\\') {
-            fileName = path;
-        }
-
-        path += 1;
-    }
-
-    /* At this point the file name is sitting on a slash, so just move forward. */
-    while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) {
-        fileName += 1;
-    }
-
-    return fileName;
-}
-
-
-static const char* ma_path_extension(const char* path)
-{
-    const char* extension;
-    const char* lastOccurance;
-
-    if (path == NULL) {
-        path = "";
-    }
-
-    extension = ma_path_file_name(path);
-    lastOccurance = NULL;
-
-    /* Just find the last '.' and return. */
-    while (extension[0] != '\0') {
-        if (extension[0] == '.') {
-            extension += 1;
-            lastOccurance = extension;
-        }
-
-        extension += 1;
-    }
-
-    return (lastOccurance != NULL) ? lastOccurance : extension;
-}
-
-static const wchar_t* ma_path_extension_w(const wchar_t* path)
-{
-    const wchar_t* extension;
-    const wchar_t* lastOccurance;
-
-    if (path == NULL) {
-        path = L"";
-    }
-
-    extension = ma_path_file_name_w(path);
-    lastOccurance = NULL;
-
-    /* Just find the last '.' and return. */
-    while (extension[0] != '\0') {
-        if (extension[0] == '.') {
-            extension += 1;
-            lastOccurance = extension;
-        }
-
-        extension += 1;
-    }
-
-    return (lastOccurance != NULL) ? lastOccurance : extension;
-}
-
-
-static ma_bool32 ma_path_extension_equal(const char* path, const char* extension)
-{
-    const char* ext1;
-    const char* ext2;
-
-    if (path == NULL || extension == NULL) {
-        return MA_FALSE;
-    }
-
-    ext1 = extension;
-    ext2 = ma_path_extension(path);
-
-#if defined(_MSC_VER) || defined(__DMC__)
-    return _stricmp(ext1, ext2) == 0;
-#else
-    return strcasecmp(ext1, ext2) == 0;
-#endif
-}
-
-static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* extension)
-{
-    const wchar_t* ext1;
-    const wchar_t* ext2;
-
-    if (path == NULL || extension == NULL) {
-        return MA_FALSE;
-    }
-
-    ext1 = extension;
-    ext2 = ma_path_extension_w(path);
-
-#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)
-    return _wcsicmp(ext1, ext2) == 0;
-#else
-    /*
-    I'm not aware of a wide character version of strcasecmp(). I'm therefore converting the extensions to multibyte strings and comparing those. This
-    isn't the most efficient way to do it, but it should work OK.
-    */
-    {
-        char ext1MB[4096];
-        char ext2MB[4096];
-        const wchar_t* pext1 = ext1;
-        const wchar_t* pext2 = ext2;
-        mbstate_t mbs1;
-        mbstate_t mbs2;
-
-        MA_ZERO_OBJECT(&mbs1);
-        MA_ZERO_OBJECT(&mbs2);
-
-        if (wcsrtombs(ext1MB, &pext1, sizeof(ext1MB), &mbs1) == (size_t)-1) {
-            return MA_FALSE;
-        }
-        if (wcsrtombs(ext2MB, &pext2, sizeof(ext2MB), &mbs2) == (size_t)-1) {
-            return MA_FALSE;
-        }
-
-        return strcasecmp(ext1MB, ext2MB) == 0;
-    }
-#endif
-}
-#endif  /* MA_HAS_PATH_API */
-
-
-
-static size_t ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pBufferOut != NULL);
-
-    ma_vfs_or_default_read(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file, pBufferOut, bytesToRead, &bytesRead);
-
-    return bytesRead;
-}
-
-static ma_bool32 ma_decoder__on_seek_vfs(ma_decoder* pDecoder, int offset, ma_seek_origin origin)
-{
-    ma_result result;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    result = ma_vfs_or_default_seek(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file, offset, origin);
-    if (result != MA_SUCCESS) {
-        return MA_FALSE;
-    }
-
-    return MA_TRUE;
-}
-
-static ma_result ma_decoder__preinit_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_vfs_file file;
-
-    result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFilePath == NULL || pFilePath[0] == '\0') {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pDecoder->backend.vfs.pVFS = pVFS;
-    pDecoder->backend.vfs.file = file;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = MA_NO_BACKEND;
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "wav")) {
-        result = ma_decoder_init_wav__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "flac")) {
-        result = ma_decoder_init_flac__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "mp3")) {
-        result = ma_decoder_init_mp3__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder);
-    } else {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_wav(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_flac(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_mp3(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_vorbis(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-
-
-static ma_result ma_decoder__preinit_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_vfs_file file;
-
-    result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFilePath == NULL || pFilePath[0] == '\0') {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_vfs_or_default_open_w(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pDecoder->backend.vfs.pVFS = pVFS;
-    pDecoder->backend.vfs.file = file;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = MA_NO_BACKEND;
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"wav")) {
-        result = ma_decoder_init_wav__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"flac")) {
-        result = ma_decoder_init_flac__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"mp3")) {
-        result = ma_decoder_init_mp3__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder);
-    } else {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_wav_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_flac_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_mp3_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_vorbis_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-
-
-MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_wav(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_wav(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_flac(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_flac(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_mp3(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_mp3(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_vorbis(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_vorbis(NULL, pFilePath, pConfig, pDecoder);
-}
-
-
-
-MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_wav_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_wav_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_flac_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_flac_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_mp3_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_mp3_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_vorbis_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_vorbis_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder)
-{
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDecoder->onUninit) {
-        pDecoder->onUninit(pDecoder);
-    }
-
-    if (pDecoder->onRead == ma_decoder__on_read_vfs) {
-        ma_vfs_or_default_close(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file);
-    }
-
-    ma_data_converter_uninit(&pDecoder->converter);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor)
-{
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = pDecoder->readPointerInPCMFrames;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint64 ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder)
-{
-    if (pDecoder == NULL) {
-        return 0;
-    }
-
-    if (pDecoder->onGetLengthInPCMFrames) {
-        ma_uint64 nativeLengthInPCMFrames = pDecoder->onGetLengthInPCMFrames(pDecoder);
-        if (pDecoder->internalSampleRate == pDecoder->outputSampleRate) {
-            return nativeLengthInPCMFrames;
-        } else {
-            return ma_calculate_frame_count_after_resampling(pDecoder->outputSampleRate, pDecoder->internalSampleRate, nativeLengthInPCMFrames);
-        }
-    }
-
-    return 0;
-}
-
-MA_API ma_uint64 ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint64 totalFramesReadOut;
-    ma_uint64 totalFramesReadIn;
-    void* pRunningFramesOut;
-
-    if (pDecoder == NULL) {
-        return 0;
-    }
-
-    if (pDecoder->onReadPCMFrames == NULL) {
-        return 0;
-    }
-
-    /* Fast path. */
-    if (pDecoder->converter.isPassthrough) {
-        totalFramesReadOut = pDecoder->onReadPCMFrames(pDecoder, pFramesOut, frameCount);
-    } else {
-        /*
-        Getting here means we need to do data conversion. If we're seeking forward and are _not_ doing resampling we can run this in a fast path. If we're doing resampling we
-        need to run through each sample because we need to ensure it's internal cache is updated.
-        */
-        if (pFramesOut == NULL && pDecoder->converter.hasResampler == MA_FALSE) {
-            totalFramesReadOut = pDecoder->onReadPCMFrames(pDecoder, NULL, frameCount);   /* All decoder backends must support passing in NULL for the output buffer. */
-        } else {
-            /* Slow path. Need to run everything through the data converter. */
-            totalFramesReadOut = 0;
-            totalFramesReadIn  = 0;
-            pRunningFramesOut  = pFramesOut;
-
-            while (totalFramesReadOut < frameCount) {
-                ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In internal format. */
-                ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-                ma_uint64 framesToReadThisIterationIn;
-                ma_uint64 framesReadThisIterationIn;
-                ma_uint64 framesToReadThisIterationOut;
-                ma_uint64 framesReadThisIterationOut;
-                ma_uint64 requiredInputFrameCount;
-
-                framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
-                framesToReadThisIterationIn = framesToReadThisIterationOut;
-                if (framesToReadThisIterationIn > intermediaryBufferCap) {
-                    framesToReadThisIterationIn = intermediaryBufferCap;
-                }
-
-                requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(&pDecoder->converter, framesToReadThisIterationOut);
-                if (framesToReadThisIterationIn > requiredInputFrameCount) {
-                    framesToReadThisIterationIn = requiredInputFrameCount;
-                }
-
-                if (requiredInputFrameCount > 0) {
-                    framesReadThisIterationIn = pDecoder->onReadPCMFrames(pDecoder, pIntermediaryBuffer, framesToReadThisIterationIn);
-                    totalFramesReadIn += framesReadThisIterationIn;
-                } else {
-                    framesReadThisIterationIn = 0;
-                }
-
-                /*
-                At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
-                input frames, we still want to try processing frames because there may some output frames generated from cached input data.
-                */
-                framesReadThisIterationOut = framesToReadThisIterationOut;
-                result = ma_data_converter_process_pcm_frames(&pDecoder->converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-
-                totalFramesReadOut += framesReadThisIterationOut;
-
-                if (pRunningFramesOut != NULL) {
-                    pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels));
-                }
-
-                if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) {
-                    break;  /* We're done. */
-                }
-            }
-        }
-    }
-
-    pDecoder->readPointerInPCMFrames += totalFramesReadOut;
-
-    return totalFramesReadOut;
-}
-
-MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDecoder->onSeekToPCMFrame) {
-        ma_result result;
-        ma_uint64 internalFrameIndex;
-        if (pDecoder->internalSampleRate == pDecoder->outputSampleRate) {
-            internalFrameIndex = frameIndex;
-        } else {
-            internalFrameIndex = ma_calculate_frame_count_after_resampling(pDecoder->internalSampleRate, pDecoder->outputSampleRate, frameIndex);
-        }
-
-        result = pDecoder->onSeekToPCMFrame(pDecoder, internalFrameIndex);
-        if (result == MA_SUCCESS) {
-            pDecoder->readPointerInPCMFrames = frameIndex;
-        }
-
-        return result;
-    }
-
-    /* Should never get here, but if we do it means onSeekToPCMFrame was not set by the backend. */
-    return MA_INVALID_ARGS;
-}
-
-MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames)
-{
-    ma_uint64 totalFrameCount;
-
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    totalFrameCount = ma_decoder_get_length_in_pcm_frames(pDecoder);
-    if (totalFrameCount == 0) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    if (totalFrameCount <= pDecoder->readPointerInPCMFrames) {
-        *pAvailableFrames = 0;
-    } else {
-        *pAvailableFrames = totalFrameCount - pDecoder->readPointerInPCMFrames;
-    }
-
-    return MA_SUCCESS;   /* No frames available. */
-}
-
-
-static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_decoder_config* pConfigOut, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_uint64 totalFrameCount;
-    ma_uint64 bpf;
-    ma_uint64 dataCapInFrames;
-    void* pPCMFramesOut;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    totalFrameCount = 0;
-    bpf = ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels);
-
-    /* The frame count is unknown until we try reading. Thus, we just run in a loop. */
-    dataCapInFrames = 0;
-    pPCMFramesOut = NULL;
-    for (;;) {
-        ma_uint64 frameCountToTryReading;
-        ma_uint64 framesJustRead;
-
-        /* Make room if there's not enough. */
-        if (totalFrameCount == dataCapInFrames) {
-            void* pNewPCMFramesOut;
-            ma_uint64 oldDataCapInFrames = dataCapInFrames;
-            ma_uint64 newDataCapInFrames = dataCapInFrames*2;
-            if (newDataCapInFrames == 0) {
-                newDataCapInFrames = 4096;
-            }
-
-            if ((newDataCapInFrames * bpf) > MA_SIZE_MAX) {
-                ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-                return MA_TOO_BIG;
-            }
-
-
-            pNewPCMFramesOut = (void*)ma__realloc_from_callbacks(pPCMFramesOut, (size_t)(newDataCapInFrames * bpf), (size_t)(oldDataCapInFrames * bpf), &pDecoder->allocationCallbacks);
-            if (pNewPCMFramesOut == NULL) {
-                ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-                return MA_OUT_OF_MEMORY;
-            }
-
-            dataCapInFrames = newDataCapInFrames;
-            pPCMFramesOut = pNewPCMFramesOut;
-        }
-
-        frameCountToTryReading = dataCapInFrames - totalFrameCount;
-        MA_ASSERT(frameCountToTryReading > 0);
-
-        framesJustRead = ma_decoder_read_pcm_frames(pDecoder, (ma_uint8*)pPCMFramesOut + (totalFrameCount * bpf), frameCountToTryReading);
-        totalFrameCount += framesJustRead;
-
-        if (framesJustRead < frameCountToTryReading) {
-            break;
-        }
-    }
-
-
-    if (pConfigOut != NULL) {
-        pConfigOut->format = pDecoder->outputFormat;
-        pConfigOut->channels = pDecoder->outputChannels;
-        pConfigOut->sampleRate = pDecoder->outputSampleRate;
-        ma_channel_map_copy(pConfigOut->channelMap, pDecoder->outputChannelMap, pDecoder->outputChannels);
-    }
-
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = pPCMFramesOut;
-    } else {
-        ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-    }
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = totalFrameCount;
-    }
-
-    ma_decoder_uninit(pDecoder);
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_result result;
-    ma_decoder_config config;
-    ma_decoder decoder;
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = 0;
-    }
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = NULL;
-    }
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder_init_vfs(pVFS, pFilePath, &config, &decoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
-
-    return result;
-}
-
-MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    return ma_decode_from_vfs(NULL, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut);
-}
-
-MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_decoder_config config;
-    ma_decoder decoder;
-    ma_result result;
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = 0;
-    }
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = NULL;
-    }
-
-    if (pData == NULL || dataSize == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder_init_memory(pData, dataSize, &config, &decoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
-}
-#endif  /* MA_NO_DECODING */
-
-
-#ifndef MA_NO_ENCODING
-
-#if defined(MA_HAS_WAV)
-static size_t ma_encoder__internal_on_write_wav(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    ma_encoder* pEncoder = (ma_encoder*)pUserData;
-    MA_ASSERT(pEncoder != NULL);
-
-    return pEncoder->onWrite(pEncoder, pData, bytesToWrite);
-}
-
-static drwav_bool32 ma_encoder__internal_on_seek_wav(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    ma_encoder* pEncoder = (ma_encoder*)pUserData;
-    MA_ASSERT(pEncoder != NULL);
-
-    return pEncoder->onSeek(pEncoder, offset, (origin == drwav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_result ma_encoder__on_init_wav(ma_encoder* pEncoder)
-{
-    drwav_data_format wavFormat;
-    drwav_allocation_callbacks allocationCallbacks;
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)ma__malloc_from_callbacks(sizeof(*pWav), &pEncoder->config.allocationCallbacks);
-    if (pWav == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    wavFormat.container     = drwav_container_riff;
-    wavFormat.channels      = pEncoder->config.channels;
-    wavFormat.sampleRate    = pEncoder->config.sampleRate;
-    wavFormat.bitsPerSample = ma_get_bytes_per_sample(pEncoder->config.format) * 8;
-    if (pEncoder->config.format == ma_format_f32) {
-        wavFormat.format    = DR_WAVE_FORMAT_IEEE_FLOAT;
-    } else {
-        wavFormat.format    = DR_WAVE_FORMAT_PCM;
-    }
-
-    allocationCallbacks.pUserData = pEncoder->config.allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pEncoder->config.allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pEncoder->config.allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pEncoder->config.allocationCallbacks.onFree;
-
-    if (!drwav_init_write(pWav, &wavFormat, ma_encoder__internal_on_write_wav, ma_encoder__internal_on_seek_wav, pEncoder, &allocationCallbacks)) {
-        return MA_ERROR;
-    }
-
-    pEncoder->pInternalEncoder = pWav;
-
-    return MA_SUCCESS;
-}
-
-static void ma_encoder__on_uninit_wav(ma_encoder* pEncoder)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)pEncoder->pInternalEncoder;
-    MA_ASSERT(pWav != NULL);
-
-    drwav_uninit(pWav);
-    ma__free_from_callbacks(pWav, &pEncoder->config.allocationCallbacks);
-}
-
-static ma_uint64 ma_encoder__on_write_pcm_frames_wav(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)pEncoder->pInternalEncoder;
-    MA_ASSERT(pWav != NULL);
-
-    return drwav_write_pcm_frames(pWav, frameCount, pFramesIn);
-}
-#endif
-
-MA_API ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
-{
-    ma_encoder_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.resourceFormat = resourceFormat;
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-
-    return config;
-}
-
-MA_API ma_result ma_encoder_preinit(const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-
-    if (pEncoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pEncoder);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->format == ma_format_unknown || pConfig->channels == 0 || pConfig->sampleRate == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pEncoder->config = *pConfig;
-
-    result = ma_allocation_callbacks_init_copy(&pEncoder->config.allocationCallbacks, &pConfig->allocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_encoder_init__internal(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, ma_encoder* pEncoder)
-{
-    ma_result result = MA_SUCCESS;
-
-    /* This assumes ma_encoder_preinit() has been called prior. */
-    MA_ASSERT(pEncoder != NULL);
-
-    if (onWrite == NULL || onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pEncoder->onWrite   = onWrite;
-    pEncoder->onSeek    = onSeek;
-    pEncoder->pUserData = pUserData;
-
-    switch (pEncoder->config.resourceFormat)
-    {
-        case ma_resource_format_wav:
-        {
-        #if defined(MA_HAS_WAV)
-            pEncoder->onInit           = ma_encoder__on_init_wav;
-            pEncoder->onUninit         = ma_encoder__on_uninit_wav;
-            pEncoder->onWritePCMFrames = ma_encoder__on_write_pcm_frames_wav;
-        #else
-            result = MA_NO_BACKEND;
-        #endif
-        } break;
-
-        default:
-        {
-            result = MA_INVALID_ARGS;
-        } break;
-    }
-
-    /* Getting here means we should have our backend callbacks set up. */
-    if (result == MA_SUCCESS) {
-        result = pEncoder->onInit(pEncoder);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API size_t ma_encoder__on_write_stdio(ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite)
-{
-    return fwrite(pBufferIn, 1, bytesToWrite, (FILE*)pEncoder->pFile);
-}
-
-MA_API ma_bool32 ma_encoder__on_seek_stdio(ma_encoder* pEncoder, int byteOffset, ma_seek_origin origin)
-{
-    return fseek((FILE*)pEncoder->pFile, byteOffset, (origin == ma_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-    FILE* pFile;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Now open the file. If this fails we don't need to uninitialize the encoder. */
-    result = ma_fopen(&pFile, pFilePath, "wb");
-    if (pFile == NULL) {
-        return result;
-    }
-
-    pEncoder->pFile = pFile;
-
-    return ma_encoder_init__internal(ma_encoder__on_write_stdio, ma_encoder__on_seek_stdio, NULL, pEncoder);
-}
-
-MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-    FILE* pFile;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Now open the file. If this fails we don't need to uninitialize the encoder. */
-    result = ma_wfopen(&pFile, pFilePath, L"wb", &pEncoder->config.allocationCallbacks);
-    if (pFile != NULL) {
-        return result;
-    }
-
-    pEncoder->pFile = pFile;
-
-    return ma_encoder_init__internal(ma_encoder__on_write_stdio, ma_encoder__on_seek_stdio, NULL, pEncoder);
-}
-
-MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_encoder_init__internal(onWrite, onSeek, pUserData, pEncoder);
-}
-
-
-MA_API void ma_encoder_uninit(ma_encoder* pEncoder)
-{
-    if (pEncoder == NULL) {
-        return;
-    }
-
-    if (pEncoder->onUninit) {
-        pEncoder->onUninit(pEncoder);
-    }
-
-    /* If we have a file handle, close it. */
-    if (pEncoder->onWrite == ma_encoder__on_write_stdio) {
-        fclose((FILE*)pEncoder->pFile);
-    }
-}
-
-
-MA_API ma_uint64 ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pEncoder == NULL || pFramesIn == NULL) {
-        return 0;
-    }
-
-    return pEncoder->onWritePCMFrames(pEncoder, pFramesIn, frameCount);
-}
-#endif  /* MA_NO_ENCODING */
-
-
-
-/**************************************************************************************************************************************************************
-
-Generation
-
-**************************************************************************************************************************************************************/
-#ifndef MA_NO_GENERATION
-MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency)
-{
-    ma_waveform_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.type       = type;
-    config.amplitude  = amplitude;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-static ma_result ma_waveform__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_waveform_read_pcm_frames((ma_waveform*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_waveform__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_waveform_seek_to_pcm_frame((ma_waveform*)pDataSource, frameIndex);
-}
-
-static ma_result ma_waveform__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_waveform* pWaveform = (ma_waveform*)pDataSource;
-
-    *pFormat     = pWaveform->config.format;
-    *pChannels   = pWaveform->config.channels;
-    *pSampleRate = pWaveform->config.sampleRate;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_waveform__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_waveform* pWaveform = (ma_waveform*)pDataSource;
-
-    *pCursor = (ma_uint64)(pWaveform->time / pWaveform->advance);
-
-    return MA_SUCCESS;
-}
-
-static double ma_waveform__calculate_advance(ma_uint32 sampleRate, double frequency)
-{
-    return (1.0 / (sampleRate / frequency));
-}
-
-static void ma_waveform__update_advance(ma_waveform* pWaveform)
-{
-    pWaveform->advance = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency);
-}
-
-MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pWaveform);
-    pWaveform->ds.onRead          = ma_waveform__data_source_on_read;
-    pWaveform->ds.onSeek          = ma_waveform__data_source_on_seek;
-    pWaveform->ds.onGetDataFormat = ma_waveform__data_source_on_get_data_format;
-    pWaveform->ds.onGetCursor     = ma_waveform__data_source_on_get_cursor;
-    pWaveform->ds.onGetLength     = NULL;   /* Intentionally set to NULL since there's no notion of a length in waveforms. */
-    pWaveform->config             = *pConfig;
-    pWaveform->advance            = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency);
-    pWaveform->time               = 0;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.amplitude = amplitude;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.frequency = frequency;
-    ma_waveform__update_advance(pWaveform);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.type = type;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.sampleRate = sampleRate;
-    ma_waveform__update_advance(pWaveform);
-
-    return MA_SUCCESS;
-}
-
-static float ma_waveform_sine_f32(double time, double amplitude)
-{
-    return (float)(ma_sin(MA_TAU_D * time) * amplitude);
-}
-
-static ma_int16 ma_waveform_sine_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_sine_f32(time, amplitude));
-}
-
-static float ma_waveform_square_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    if (f < 0.5) {
-        r =  amplitude;
-    } else {
-        r = -amplitude;
-    }
-
-    return (float)r;
-}
-
-static ma_int16 ma_waveform_square_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_square_f32(time, amplitude));
-}
-
-static float ma_waveform_triangle_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    r = 2 * ma_abs(2 * (f - 0.5)) - 1;
-
-    return (float)(r * amplitude);
-}
-
-static ma_int16 ma_waveform_triangle_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_triangle_f32(time, amplitude));
-}
-
-static float ma_waveform_sawtooth_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    r = 2 * (f - 0.5);
-
-    return (float)(r * amplitude);
-}
-
-static ma_int16 ma_waveform_sawtooth_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_sawtooth_f32(time, amplitude));
-}
-
-static void ma_waveform_read_pcm_frames__sine(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_sine_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__square(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_square_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_square_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_square_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__triangle(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_triangle_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__sawtooth(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_sawtooth_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    if (pWaveform == NULL) {
-        return 0;
-    }
-
-    if (pFramesOut != NULL) {
-        switch (pWaveform->config.type)
-        {
-            case ma_waveform_type_sine:
-            {
-                ma_waveform_read_pcm_frames__sine(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_square:
-            {
-                ma_waveform_read_pcm_frames__square(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_triangle:
-            {
-                ma_waveform_read_pcm_frames__triangle(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_sawtooth:
-            {
-                ma_waveform_read_pcm_frames__sawtooth(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            default: return 0;
-        }
-    } else {
-        pWaveform->time += pWaveform->advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */
-    }
-
-    return frameCount;
-}
-
-MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->time = pWaveform->advance * (ma_int64)frameIndex;    /* Casting for VC6. Won't be an issue in practice. */
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude)
-{
-    ma_noise_config config;
-    MA_ZERO_OBJECT(&config);
-
-    config.format    = format;
-    config.channels  = channels;
-    config.type      = type;
-    config.seed      = seed;
-    config.amplitude = amplitude;
-
-    if (config.seed == 0) {
-        config.seed = MA_DEFAULT_LCG_SEED;
-    }
-
-    return config;
-}
-
-
-static ma_result ma_noise__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_noise_read_pcm_frames((ma_noise*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_noise__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    /* No-op. Just pretend to be successful. */
-    (void)pDataSource;
-    (void)frameIndex;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_noise__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_noise* pNoise = (ma_noise*)pDataSource;
-
-    *pFormat     = pNoise->config.format;
-    *pChannels   = pNoise->config.channels;
-    *pSampleRate = 0;   /* There is no notion of sample rate with noise generation. */
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, ma_noise* pNoise)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pNoise);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->ds.onRead          = ma_noise__data_source_on_read;
-    pNoise->ds.onSeek          = ma_noise__data_source_on_seek;  /* <-- No-op for noise. */
-    pNoise->ds.onGetDataFormat = ma_noise__data_source_on_get_data_format;
-    pNoise->ds.onGetCursor     = NULL;  /* No notion of a cursor for noise. */
-    pNoise->ds.onGetLength     = NULL;  /* No notion of a length for noise. */
-    pNoise->config             = *pConfig;
-    ma_lcg_seed(&pNoise->lcg, pConfig->seed);
-
-    if (pNoise->config.type == ma_noise_type_pink) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) {
-            pNoise->state.pink.accumulation[iChannel] = 0;
-            pNoise->state.pink.counter[iChannel]      = 1;
-        }
-    }
-
-    if (pNoise->config.type == ma_noise_type_brownian) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) {
-            pNoise->state.brownian.accumulation[iChannel] = 0;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->config.amplitude = amplitude;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->lcg.state = seed;
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->config.type = type;
-    return MA_SUCCESS;
-}
-
-static MA_INLINE float ma_noise_f32_white(ma_noise* pNoise)
-{
-    return (float)(ma_lcg_rand_f64(&pNoise->lcg) * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_white(ma_noise* pNoise)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_white(pNoise));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__white(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_white(pNoise);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_white(pNoise);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_white(pNoise);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-
-static MA_INLINE unsigned int ma_tzcnt32(unsigned int x)
-{
-    unsigned int n;
-
-    /* Special case for odd numbers since they should happen about half the time. */
-    if (x & 0x1)  {
-        return 0;
-    }
-
-    if (x == 0) {
-        return sizeof(x) << 3;
-    }
-
-    n = 1;
-    if ((x & 0x0000FFFF) == 0) { x >>= 16; n += 16; }
-    if ((x & 0x000000FF) == 0) { x >>=  8; n +=  8; }
-    if ((x & 0x0000000F) == 0) { x >>=  4; n +=  4; }
-    if ((x & 0x00000003) == 0) { x >>=  2; n +=  2; }
-    n -= x & 0x00000001;
-
-    return n;
-}
-
-/*
-Pink noise generation based on Tonic (public domain) with modifications. https://github.com/TonicAudio/Tonic/blob/master/src/Tonic/Noise.h
-
-This is basically _the_ reference for pink noise from what I've found: http://www.firstpr.com.au/dsp/pink-noise/
-*/
-static MA_INLINE float ma_noise_f32_pink(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    double result;
-    double binPrev;
-    double binNext;
-    unsigned int ibin;
-
-    ibin = ma_tzcnt32(pNoise->state.pink.counter[iChannel]) & (ma_countof(pNoise->state.pink.bin[0]) - 1);
-
-    binPrev = pNoise->state.pink.bin[iChannel][ibin];
-    binNext = ma_lcg_rand_f64(&pNoise->lcg);
-    pNoise->state.pink.bin[iChannel][ibin] = binNext;
-
-    pNoise->state.pink.accumulation[iChannel] += (binNext - binPrev);
-    pNoise->state.pink.counter[iChannel]      += 1;
-
-    result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.pink.accumulation[iChannel]);
-    result /= 10;
-
-    return (float)(result * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_pink(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_pink(pNoise, iChannel));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__pink(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_pink(pNoise, iChannel);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_pink(pNoise, iChannel);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_pink(pNoise, iChannel);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-
-static MA_INLINE float ma_noise_f32_brownian(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    double result;
-
-    result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.brownian.accumulation[iChannel]);
-    result /= 1.005; /* Don't escape the -1..1 range on average. */
-
-    pNoise->state.brownian.accumulation[iChannel] = result;
-    result /= 20;
-
-    return (float)(result * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_brownian(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_brownian(pNoise, iChannel));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__brownian(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_brownian(pNoise, iChannel);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_brownian(pNoise, iChannel);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_brownian(pNoise, iChannel);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-MA_API ma_uint64 ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    if (pNoise == NULL) {
-        return 0;
-    }
-
-    /* The output buffer is allowed to be NULL. Since we aren't tracking cursors or anything we can just do nothing and pretend to be successful. */
-    if (pFramesOut == NULL) {
-        return frameCount;
-    }
-
-    if (pNoise->config.type == ma_noise_type_white) {
-        return ma_noise_read_pcm_frames__white(pNoise, pFramesOut, frameCount);
-    }
-
-    if (pNoise->config.type == ma_noise_type_pink) {
-        return ma_noise_read_pcm_frames__pink(pNoise, pFramesOut, frameCount);
-    }
-
-    if (pNoise->config.type == ma_noise_type_brownian) {
-        return ma_noise_read_pcm_frames__brownian(pNoise, pFramesOut, frameCount);
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-#endif /* MA_NO_GENERATION */
-
-
-
-/**************************************************************************************************************************************************************
-***************************************************************************************************************************************************************
-
-Auto Generated
-==============
-All code below is auto-generated from a tool. This mostly consists of decoding backend implementations such as dr_wav, dr_flac, etc. If you find a bug in the
-code below please report the bug to the respective repository for the relevant project (probably dr_libs).
-
-***************************************************************************************************************************************************************
-**************************************************************************************************************************************************************/
-#if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING))
-#if !defined(DR_WAV_IMPLEMENTATION) && !defined(DRWAV_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_wav_c begin */
-#ifndef dr_wav_c
-#define dr_wav_c
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#ifndef DR_WAV_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#endif
-#ifndef DRWAV_ASSERT
-#include <assert.h>
-#define DRWAV_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRWAV_MALLOC
-#define DRWAV_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRWAV_REALLOC
-#define DRWAV_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRWAV_FREE
-#define DRWAV_FREE(p)                      free((p))
-#endif
-#ifndef DRWAV_COPY_MEMORY
-#define DRWAV_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRWAV_ZERO_MEMORY
-#define DRWAV_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRWAV_ZERO_OBJECT
-#define DRWAV_ZERO_OBJECT(p)               DRWAV_ZERO_MEMORY((p), sizeof(*p))
-#endif
-#define drwav_countof(x)                   (sizeof(x) / sizeof(x[0]))
-#define drwav_align(x, a)                  ((((x) + (a) - 1) / (a)) * (a))
-#define drwav_min(a, b)                    (((a) < (b)) ? (a) : (b))
-#define drwav_max(a, b)                    (((a) > (b)) ? (a) : (b))
-#define drwav_clamp(x, lo, hi)             (drwav_max((lo), drwav_min((hi), (x))))
-#define DRWAV_MAX_SIMD_VECTOR_SIZE         64
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRWAV_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRWAV_X86
-#elif defined(__arm__) || defined(_M_ARM)
-    #define DRWAV_ARM
-#endif
-#ifdef _MSC_VER
-    #define DRWAV_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRWAV_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRWAV_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRWAV_INLINE __inline
-#else
-    #define DRWAV_INLINE
-#endif
-#if defined(SIZE_MAX)
-    #define DRWAV_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRWAV_SIZE_MAX  ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRWAV_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRWAV_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRWAV_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRWAV_VERSION_REVISION;
-    }
-}
-DRWAV_API const char* drwav_version_string(void)
-{
-    return DRWAV_VERSION_STRING;
-}
-#ifndef DRWAV_MAX_SAMPLE_RATE
-#define DRWAV_MAX_SAMPLE_RATE       384000
-#endif
-#ifndef DRWAV_MAX_CHANNELS
-#define DRWAV_MAX_CHANNELS          256
-#endif
-#ifndef DRWAV_MAX_BITS_PER_SAMPLE
-#define DRWAV_MAX_BITS_PER_SAMPLE   64
-#endif
-static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00};
-static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static DRWAV_INLINE int drwav__is_little_endian(void)
-{
-#if defined(DRWAV_X86) || defined(DRWAV_X64)
-    return DRWAV_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRWAV_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-static DRWAV_INLINE void drwav__bytes_to_guid(const drwav_uint8* data, drwav_uint8* guid)
-{
-    int i;
-    for (i = 0; i < 16; ++i) {
-        guid[i] = data[i];
-    }
-}
-static DRWAV_INLINE drwav_uint16 drwav__bswap16(drwav_uint16 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-static DRWAV_INLINE drwav_uint32 drwav__bswap32(drwav_uint32 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT)
-            drwav_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRWAV_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-static DRWAV_INLINE drwav_uint64 drwav__bswap64(drwav_uint64 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & ((drwav_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drwav_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drwav_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drwav_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drwav_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drwav_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drwav_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drwav_uint64)0x000000FF      )) << 56);
-#endif
-}
-static DRWAV_INLINE drwav_int16 drwav__bswap_s16(drwav_int16 n)
-{
-    return (drwav_int16)drwav__bswap16((drwav_uint16)n);
-}
-static DRWAV_INLINE void drwav__bswap_samples_s16(drwav_int16* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s16(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE void drwav__bswap_s24(drwav_uint8* p)
-{
-    drwav_uint8 t;
-    t = p[0];
-    p[0] = p[2];
-    p[2] = t;
-}
-static DRWAV_INLINE void drwav__bswap_samples_s24(drwav_uint8* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        drwav_uint8* pSample = pSamples + (iSample*3);
-        drwav__bswap_s24(pSample);
-    }
-}
-static DRWAV_INLINE drwav_int32 drwav__bswap_s32(drwav_int32 n)
-{
-    return (drwav_int32)drwav__bswap32((drwav_uint32)n);
-}
-static DRWAV_INLINE void drwav__bswap_samples_s32(drwav_int32* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s32(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE float drwav__bswap_f32(float n)
-{
-    union {
-        drwav_uint32 i;
-        float f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap32(x.i);
-    return x.f;
-}
-static DRWAV_INLINE void drwav__bswap_samples_f32(float* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f32(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE double drwav__bswap_f64(double n)
-{
-    union {
-        drwav_uint64 i;
-        double f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap64(x.i);
-    return x.f;
-}
-static DRWAV_INLINE void drwav__bswap_samples_f64(double* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f64(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples_pcm(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-        case 2:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case 3:
-        {
-            drwav__bswap_samples_s24((drwav_uint8*)pSamples, sampleCount);
-        } break;
-        case 4:
-        {
-            drwav__bswap_samples_s32((drwav_int32*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples_ieee(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-    #if 0
-        case 2:
-        {
-            drwav__bswap_samples_f16((drwav_float16*)pSamples, sampleCount);
-        } break;
-    #endif
-        case 4:
-        {
-            drwav__bswap_samples_f32((float*)pSamples, sampleCount);
-        } break;
-        case 8:
-        {
-            drwav__bswap_samples_f64((double*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample, drwav_uint16 format)
-{
-    switch (format)
-    {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            drwav__bswap_samples_pcm(pSamples, sampleCount, bytesPerSample);
-        } break;
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            drwav__bswap_samples_ieee(pSamples, sampleCount, bytesPerSample);
-        } break;
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-DRWAV_PRIVATE void* drwav__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_MALLOC(sz);
-}
-DRWAV_PRIVATE void* drwav__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_REALLOC(p, sz);
-}
-DRWAV_PRIVATE void drwav__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRWAV_FREE(p);
-}
-DRWAV_PRIVATE void* drwav__malloc_from_callbacks(size_t sz, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-DRWAV_PRIVATE void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRWAV_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-DRWAV_PRIVATE void drwav__free_from_callbacks(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-DRWAV_PRIVATE drwav_allocation_callbacks drwav_copy_allocation_callbacks_or_defaults(const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return *pAllocationCallbacks;
-    } else {
-        drwav_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drwav__malloc_default;
-        allocationCallbacks.onRealloc = drwav__realloc_default;
-        allocationCallbacks.onFree    = drwav__free_default;
-        return allocationCallbacks;
-    }
-}
-static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
-{
-    return
-        formatTag == DR_WAVE_FORMAT_ADPCM ||
-        formatTag == DR_WAVE_FORMAT_DVI_ADPCM;
-}
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_riff(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 2);
-}
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_w64(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 8);
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-DRWAV_PRIVATE drwav_result drwav__read_chunk_header(drwav_read_proc onRead, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_chunk_header* pHeaderOut)
-{
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        drwav_uint8 sizeInBytes[4];
-        if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) {
-            return DRWAV_AT_END;
-        }
-        if (onRead(pUserData, sizeInBytes, 4) != 4) {
-            return DRWAV_INVALID_FILE;
-        }
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u32(sizeInBytes);
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_riff(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 8;
-    } else {
-        drwav_uint8 sizeInBytes[8];
-        if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) {
-            return DRWAV_AT_END;
-        }
-        if (onRead(pUserData, sizeInBytes, 8) != 8) {
-            return DRWAV_INVALID_FILE;
-        }
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u64(sizeInBytes) - 24;
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_w64(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 24;
-    }
-    return DRWAV_SUCCESS;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__seek_forward(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    drwav_uint64 bytesRemainingToSeek = offset;
-    while (bytesRemainingToSeek > 0) {
-        if (bytesRemainingToSeek > 0x7FFFFFFF) {
-            if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek -= 0x7FFFFFFF;
-        } else {
-            if (!onSeek(pUserData, (int)bytesRemainingToSeek, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek = 0;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__seek_from_start(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return onSeek(pUserData, (int)offset, drwav_seek_origin_start);
-    }
-    if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-    for (;;) {
-        if (offset <= 0x7FFFFFFF) {
-            return onSeek(pUserData, (int)offset, drwav_seek_origin_current);
-        }
-        if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        offset -= 0x7FFFFFFF;
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav__read_fmt(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_fmt* fmtOut)
-{
-    drwav_chunk_header header;
-    drwav_uint8 fmt[16];
-    if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    while (((container == drwav_container_riff || container == drwav_container_rf64) && !drwav_fourcc_equal(header.id.fourcc, "fmt ")) || (container == drwav_container_w64 && !drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT))) {
-        if (!drwav__seek_forward(onSeek, header.sizeInBytes + header.paddingSize, pUserData)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.sizeInBytes + header.paddingSize;
-        if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        if (!drwav_fourcc_equal(header.id.fourcc, "fmt ")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        if (!drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT)) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (onRead(pUserData, fmt, sizeof(fmt)) != sizeof(fmt)) {
-        return DRWAV_FALSE;
-    }
-    *pRunningBytesReadOut += sizeof(fmt);
-    fmtOut->formatTag      = drwav_bytes_to_u16(fmt + 0);
-    fmtOut->channels       = drwav_bytes_to_u16(fmt + 2);
-    fmtOut->sampleRate     = drwav_bytes_to_u32(fmt + 4);
-    fmtOut->avgBytesPerSec = drwav_bytes_to_u32(fmt + 8);
-    fmtOut->blockAlign     = drwav_bytes_to_u16(fmt + 12);
-    fmtOut->bitsPerSample  = drwav_bytes_to_u16(fmt + 14);
-    fmtOut->extendedSize       = 0;
-    fmtOut->validBitsPerSample = 0;
-    fmtOut->channelMask        = 0;
-    memset(fmtOut->subFormat, 0, sizeof(fmtOut->subFormat));
-    if (header.sizeInBytes > 16) {
-        drwav_uint8 fmt_cbSize[2];
-        int bytesReadSoFar = 0;
-        if (onRead(pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += sizeof(fmt_cbSize);
-        bytesReadSoFar = 18;
-        fmtOut->extendedSize = drwav_bytes_to_u16(fmt_cbSize);
-        if (fmtOut->extendedSize > 0) {
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                if (fmtOut->extendedSize != 22) {
-                    return DRWAV_FALSE;
-                }
-            }
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                drwav_uint8 fmtext[22];
-                if (onRead(pUserData, fmtext, fmtOut->extendedSize) != fmtOut->extendedSize) {
-                    return DRWAV_FALSE;
-                }
-                fmtOut->validBitsPerSample = drwav_bytes_to_u16(fmtext + 0);
-                fmtOut->channelMask        = drwav_bytes_to_u32(fmtext + 2);
-                drwav__bytes_to_guid(fmtext + 6, fmtOut->subFormat);
-            } else {
-                if (!onSeek(pUserData, fmtOut->extendedSize, drwav_seek_origin_current)) {
-                    return DRWAV_FALSE;
-                }
-            }
-            *pRunningBytesReadOut += fmtOut->extendedSize;
-            bytesReadSoFar += fmtOut->extendedSize;
-        }
-        if (!onSeek(pUserData, (int)(header.sizeInBytes - bytesReadSoFar), drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += (header.sizeInBytes - bytesReadSoFar);
-    }
-    if (header.paddingSize > 0) {
-        if (!onSeek(pUserData, header.paddingSize, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.paddingSize;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE size_t drwav__on_read(drwav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
-{
-    size_t bytesRead;
-    DRWAV_ASSERT(onRead != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-    bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
-    *pCursor += bytesRead;
-    return bytesRead;
-}
-#if 0
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek(drwav_seek_proc onSeek, void* pUserData, int offset, drwav_seek_origin origin, drwav_uint64* pCursor)
-{
-    DRWAV_ASSERT(onSeek != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-    if (!onSeek(pUserData, offset, origin)) {
-        return DRWAV_FALSE;
-    }
-    if (origin == drwav_seek_origin_start) {
-        *pCursor = offset;
-    } else {
-        *pCursor += offset;
-    }
-    return DRWAV_TRUE;
-}
-#endif
-DRWAV_PRIVATE drwav_uint32 drwav_get_bytes_per_pcm_frame(drwav* pWav)
-{
-    if ((pWav->bitsPerSample & 0x7) == 0) {
-        return (pWav->bitsPerSample * pWav->fmt.channels) >> 3;
-    } else {
-        return pWav->fmt.blockAlign;
-    }
-}
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT)
-{
-    if (pFMT == NULL) {
-        return 0;
-    }
-    if (pFMT->formatTag != DR_WAVE_FORMAT_EXTENSIBLE) {
-        return pFMT->formatTag;
-    } else {
-        return drwav_bytes_to_u16(pFMT->subFormat);
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav_preinit(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onRead == NULL || onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onRead    = onRead;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pReadSeekUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags)
-{
-    drwav_uint64 cursor;
-    drwav_bool32 sequential;
-    drwav_uint8 riff[4];
-    drwav_fmt fmt;
-    unsigned short translatedFormatTag;
-    drwav_bool32 foundDataChunk;
-    drwav_uint64 dataChunkSize = 0;
-    drwav_uint64 sampleCountFromFactChunk = 0;
-    drwav_uint64 chunkSize;
-    cursor = 0;
-    sequential = (flags & DRWAV_SEQUENTIAL) != 0;
-    if (drwav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) {
-        return DRWAV_FALSE;
-    }
-    if (drwav_fourcc_equal(riff, "RIFF")) {
-        pWav->container = drwav_container_riff;
-    } else if (drwav_fourcc_equal(riff, "riff")) {
-        int i;
-        drwav_uint8 riff2[12];
-        pWav->container = drwav_container_w64;
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) {
-            return DRWAV_FALSE;
-        }
-        for (i = 0; i < 12; ++i) {
-            if (riff2[i] != drwavGUID_W64_RIFF[i+4]) {
-                return DRWAV_FALSE;
-            }
-        }
-    } else if (drwav_fourcc_equal(riff, "RF64")) {
-        pWav->container = drwav_container_rf64;
-    } else {
-        return DRWAV_FALSE;
-    }
-    if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-        drwav_uint8 chunkSizeBytes[4];
-        drwav_uint8 wave[4];
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_bytes_to_u32(chunkSizeBytes) < 36) {
-                return DRWAV_FALSE;
-            }
-        } else {
-            if (drwav_bytes_to_u32(chunkSizeBytes) != 0xFFFFFFFF) {
-                return DRWAV_FALSE;
-            }
-        }
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_fourcc_equal(wave, "WAVE")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        drwav_uint8 chunkSizeBytes[8];
-        drwav_uint8 wave[16];
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        if (drwav_bytes_to_u64(chunkSizeBytes) < 80) {
-            return DRWAV_FALSE;
-        }
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_guid_equal(wave, drwavGUID_W64_WAVE)) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (pWav->container == drwav_container_rf64) {
-        drwav_uint8 sizeBytes[8];
-        drwav_uint64 bytesRemainingInChunk;
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_fourcc_equal(header.id.fourcc, "ds64")) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk = header.sizeInBytes + header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        cursor += 8;
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        dataChunkSize = drwav_bytes_to_u64(sizeBytes);
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        sampleCountFromFactChunk = drwav_bytes_to_u64(sizeBytes);
-        if (!drwav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor += bytesRemainingInChunk;
-    }
-    if (!drwav__read_fmt(pWav->onRead, pWav->onSeek, pWav->pUserData, pWav->container, &cursor, &fmt)) {
-        return DRWAV_FALSE;
-    }
-    if ((fmt.sampleRate    == 0 || fmt.sampleRate    > DRWAV_MAX_SAMPLE_RATE)     ||
-        (fmt.channels      == 0 || fmt.channels      > DRWAV_MAX_CHANNELS)        ||
-        (fmt.bitsPerSample == 0 || fmt.bitsPerSample > DRWAV_MAX_BITS_PER_SAMPLE) ||
-        fmt.blockAlign == 0) {
-        return DRWAV_FALSE;
-    }
-    translatedFormatTag = fmt.formatTag;
-    if (translatedFormatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-        translatedFormatTag = drwav_bytes_to_u16(fmt.subFormat + 0);
-    }
-    foundDataChunk = DRWAV_FALSE;
-    for (;;)
-    {
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            if (!foundDataChunk) {
-                return DRWAV_FALSE;
-            } else {
-                break;
-            }
-        }
-        if (!sequential && onChunk != NULL) {
-            drwav_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt);
-            if (callbackBytesRead > 0) {
-                if (!drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData)) {
-                    return DRWAV_FALSE;
-                }
-            }
-        }
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-        chunkSize = header.sizeInBytes;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "data")) {
-                foundDataChunk = DRWAV_TRUE;
-                if (pWav->container != drwav_container_rf64) {
-                    dataChunkSize = chunkSize;
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA)) {
-                foundDataChunk = DRWAV_TRUE;
-                dataChunkSize = chunkSize;
-            }
-        }
-        if (foundDataChunk && sequential) {
-            break;
-        }
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_fourcc_equal(header.id.fourcc, "fact")) {
-                drwav_uint32 sampleCount;
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 4;
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    sampleCountFromFactChunk = sampleCount;
-                } else {
-                    sampleCountFromFactChunk = 0;
-                }
-            }
-        } else if (pWav->container == drwav_container_w64) {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_FACT)) {
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 8;
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-            }
-        } else if (pWav->container == drwav_container_rf64) {
-        }
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "smpl")) {
-                drwav_uint8 smplHeaderData[36];
-                if (chunkSize >= sizeof(smplHeaderData)) {
-                    drwav_uint64 bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplHeaderData, sizeof(smplHeaderData), &cursor);
-                    chunkSize -= bytesJustRead;
-                    if (bytesJustRead == sizeof(smplHeaderData)) {
-                        drwav_uint32 iLoop;
-                        pWav->smpl.manufacturer      = drwav_bytes_to_u32(smplHeaderData+0);
-                        pWav->smpl.product           = drwav_bytes_to_u32(smplHeaderData+4);
-                        pWav->smpl.samplePeriod      = drwav_bytes_to_u32(smplHeaderData+8);
-                        pWav->smpl.midiUnityNotes    = drwav_bytes_to_u32(smplHeaderData+12);
-                        pWav->smpl.midiPitchFraction = drwav_bytes_to_u32(smplHeaderData+16);
-                        pWav->smpl.smpteFormat       = drwav_bytes_to_u32(smplHeaderData+20);
-                        pWav->smpl.smpteOffset       = drwav_bytes_to_u32(smplHeaderData+24);
-                        pWav->smpl.numSampleLoops    = drwav_bytes_to_u32(smplHeaderData+28);
-                        pWav->smpl.samplerData       = drwav_bytes_to_u32(smplHeaderData+32);
-                        for (iLoop = 0; iLoop < pWav->smpl.numSampleLoops && iLoop < drwav_countof(pWav->smpl.loops); ++iLoop) {
-                            drwav_uint8 smplLoopData[24];
-                            bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplLoopData, sizeof(smplLoopData), &cursor);
-                            chunkSize -= bytesJustRead;
-                            if (bytesJustRead == sizeof(smplLoopData)) {
-                                pWav->smpl.loops[iLoop].cuePointId = drwav_bytes_to_u32(smplLoopData+0);
-                                pWav->smpl.loops[iLoop].type       = drwav_bytes_to_u32(smplLoopData+4);
-                                pWav->smpl.loops[iLoop].start      = drwav_bytes_to_u32(smplLoopData+8);
-                                pWav->smpl.loops[iLoop].end        = drwav_bytes_to_u32(smplLoopData+12);
-                                pWav->smpl.loops[iLoop].fraction   = drwav_bytes_to_u32(smplLoopData+16);
-                                pWav->smpl.loops[iLoop].playCount  = drwav_bytes_to_u32(smplLoopData+20);
-                            } else {
-                                break;
-                            }
-                        }
-                    }
-                } else {
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_SMPL)) {
-            }
-        }
-        chunkSize += header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData)) {
-            break;
-        }
-        cursor += chunkSize;
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-    }
-    if (!foundDataChunk) {
-        return DRWAV_FALSE;
-    }
-    if (!sequential) {
-        if (!drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor = pWav->dataChunkDataPos;
-    }
-    pWav->fmt                 = fmt;
-    pWav->sampleRate          = fmt.sampleRate;
-    pWav->channels            = fmt.channels;
-    pWav->bitsPerSample       = fmt.bitsPerSample;
-    pWav->bytesRemaining      = dataChunkSize;
-    pWav->translatedFormatTag = translatedFormatTag;
-    pWav->dataChunkDataSize   = dataChunkSize;
-    if (sampleCountFromFactChunk != 0) {
-        pWav->totalPCMFrameCount = sampleCountFromFactChunk;
-    } else {
-        pWav->totalPCMFrameCount = dataChunkSize / drwav_get_bytes_per_pcm_frame(pWav);
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-            totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-        }
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-            totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-            pWav->totalPCMFrameCount += blockCount;
-        }
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        if (pWav->channels > 2) {
-            return DRWAV_FALSE;
-        }
-    }
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels;
-    }
-#endif
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-DRWAV_PRIVATE drwav_uint32 drwav__riff_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize);
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-    return (drwav_uint32)chunkSize;
-}
-DRWAV_PRIVATE drwav_uint32 drwav__data_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    if (dataChunkSize <= 0xFFFFFFFFUL) {
-        return (drwav_uint32)dataChunkSize;
-    } else {
-        return 0xFFFFFFFFUL;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 dataSubchunkPaddingSize = drwav__chunk_padding_size_w64(dataChunkSize);
-    return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    return 24 + dataChunkSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 36 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize);
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-    return chunkSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    return dataChunkSize;
-}
-DRWAV_PRIVATE size_t drwav__write(drwav* pWav, const void* pData, size_t dataSize)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    return pWav->onWrite(pWav->pUserData, pData, dataSize);
-}
-DRWAV_PRIVATE size_t drwav__write_u16ne_to_le(drwav* pWav, drwav_uint16 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap16(value);
-    }
-    return drwav__write(pWav, &value, 2);
-}
-DRWAV_PRIVATE size_t drwav__write_u32ne_to_le(drwav* pWav, drwav_uint32 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap32(value);
-    }
-    return drwav__write(pWav, &value, 4);
-}
-DRWAV_PRIVATE size_t drwav__write_u64ne_to_le(drwav* pWav, drwav_uint64 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap64(value);
-    }
-    return drwav__write(pWav, &value, 8);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_preinit_write(drwav* pWav, const drwav_data_format* pFormat, drwav_bool32 isSequential, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onWrite == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (!isSequential && onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_EXTENSIBLE) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_ADPCM || pFormat->format == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return DRWAV_FALSE;
-    }
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onWrite   = onWrite;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;
-    }
-    pWav->fmt.formatTag = (drwav_uint16)pFormat->format;
-    pWav->fmt.channels = (drwav_uint16)pFormat->channels;
-    pWav->fmt.sampleRate = pFormat->sampleRate;
-    pWav->fmt.avgBytesPerSec = (drwav_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8);
-    pWav->fmt.blockAlign = (drwav_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8);
-    pWav->fmt.bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->fmt.extendedSize = 0;
-    pWav->isSequentialWrite = isSequential;
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    size_t runningPos = 0;
-    drwav_uint64 initialDataChunkSize = 0;
-    drwav_uint64 chunkSizeFMT;
-    if (pWav->isSequentialWrite) {
-        initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8;
-        if (pFormat->container == drwav_container_riff) {
-            if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
-                return DRWAV_FALSE;
-            }
-        }
-    }
-    pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize;
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeRIFF = 28 + (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "RIFF", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize;
-        runningPos += drwav__write(pWav, drwavGUID_W64_RIFF, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, drwavGUID_W64_WAVE, 16);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "RF64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    }
-    if (pFormat->container == drwav_container_rf64) {
-        drwav_uint32 initialds64ChunkSize = 28;
-        drwav_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize;
-        runningPos += drwav__write(pWav, "ds64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, initialds64ChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, initialRiffChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, initialDataChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, totalSampleCount);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0);
-    }
-    if (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64) {
-        chunkSizeFMT = 16;
-        runningPos += drwav__write(pWav, "fmt ", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, (drwav_uint32)chunkSizeFMT);
-    } else if (pFormat->container == drwav_container_w64) {
-        chunkSizeFMT = 40;
-        runningPos += drwav__write(pWav, drwavGUID_W64_FMT, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeFMT);
-    }
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.formatTag);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.channels);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize;
-        runningPos += drwav__write(pWav, drwavGUID_W64_DATA, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
-    }
-    pWav->container = pFormat->container;
-    pWav->channels = (drwav_uint16)pFormat->channels;
-    pWav->sampleRate = pFormat->sampleRate;
-    pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
-    pWav->dataChunkDataPos = runningPos;
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write__internal(pWav, pFormat, 0);
-}
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks);
-}
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    drwav_uint64 targetDataSizeBytes = (drwav_uint64)((drwav_int64)totalSampleCount * pFormat->channels * pFormat->bitsPerSample/8.0);
-    drwav_uint64 riffChunkSizeBytes;
-    drwav_uint64 fileSizeBytes = 0;
-    if (pFormat->container == drwav_container_riff) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_riff(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);
-    } else if (pFormat->container == drwav_container_w64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_w64(targetDataSizeBytes);
-        fileSizeBytes = riffChunkSizeBytes;
-    } else if (pFormat->container == drwav_container_rf64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_rf64(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);
-    }
-    return fileSizeBytes;
-}
-#ifndef DR_WAV_NO_STDIO
-#include <errno.h>
-DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRWAV_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRWAV_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRWAV_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRWAV_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRWAV_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRWAV_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRWAV_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRWAV_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRWAV_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRWAV_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRWAV_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRWAV_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRWAV_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRWAV_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRWAV_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRWAV_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRWAV_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRWAV_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRWAV_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRWAV_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRWAV_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRWAV_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRWAV_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRWAV_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRWAV_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRWAV_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRWAV_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRWAV_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRWAV_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRWAV_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRWAV_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRWAV_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRWAV_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRWAV_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRWAV_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRWAV_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRWAV_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRWAV_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRWAV_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRWAV_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRWAV_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRWAV_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRWAV_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRWAV_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRWAV_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRWAV_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRWAV_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRWAV_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRWAV_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRWAV_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRWAV_ERROR;
-    #endif
-        default: return DRWAV_ERROR;
-    }
-}
-DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drwav_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drwav_result result = drwav_result_from_errno(errno);
-        if (result == DRWAV_SUCCESS) {
-            result = DRWAV_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRWAV_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRWAV_HAS_WFOPEN
-    #endif
-#endif
-DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-#if defined(DRWAV_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drwav_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drwav_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRWAV_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drwav_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drwav__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRWAV_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRWAV_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRWAV_ERROR;
-    }
-#endif
-    return DRWAV_SUCCESS;
-}
-DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-DRWAV_PRIVATE size_t drwav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_stdio(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drwav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFile, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-    result = drwav_preinit(pWav, drwav__on_read_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-    result = drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    result = drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "wb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-#endif
-DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos);
-    bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRWAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead);
-        pWav->memoryStream.currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) {
-                return DRWAV_FALSE;
-            }
-        } else {
-            if (pWav->memoryStream.currentReadPos < (size_t)-offset) {
-                return DRWAV_FALSE;
-            }
-        }
-        pWav->memoryStream.currentReadPos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStream.dataSize) {
-            pWav->memoryStream.currentReadPos = offset;
-        } else {
-            return DRWAV_FALSE;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE size_t drwav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos);
-    bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos;
-    if (bytesRemaining < bytesToWrite) {
-        void* pNewData;
-        size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2;
-        if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) {
-            newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite;
-        }
-        pNewData = drwav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks);
-        if (pNewData == NULL) {
-            return 0;
-        }
-        *pWav->memoryStreamWrite.ppData = pNewData;
-        pWav->memoryStreamWrite.dataCapacity = newDataCapacity;
-    }
-    DRWAV_COPY_MEMORY(((drwav_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite);
-    pWav->memoryStreamWrite.currentWritePos += bytesToWrite;
-    if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) {
-        pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos;
-    }
-    *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize;
-    return bytesToWrite;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory_write(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) {
-                offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos);
-            }
-        } else {
-            if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) {
-                offset = -(int)pWav->memoryStreamWrite.currentWritePos;
-            }
-        }
-        pWav->memoryStreamWrite.currentWritePos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStreamWrite.dataSize) {
-            pWav->memoryStreamWrite.currentWritePos = offset;
-        } else {
-            pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (data == NULL || dataSize == 0) {
-        return DRWAV_FALSE;
-    }
-    if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    pWav->memoryStream.data = (const drwav_uint8*)data;
-    pWav->memoryStream.dataSize = dataSize;
-    pWav->memoryStream.currentReadPos = 0;
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_memory_write__internal(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppData == NULL || pDataSize == NULL) {
-        return DRWAV_FALSE;
-    }
-    *ppData = NULL;
-    *pDataSize = 0;
-    if (!drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_memory, drwav__on_seek_memory_write, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    pWav->memoryStreamWrite.ppData = ppData;
-    pWav->memoryStreamWrite.pDataSize = pDataSize;
-    pWav->memoryStreamWrite.dataSize = 0;
-    pWav->memoryStreamWrite.dataCapacity = 0;
-    pWav->memoryStreamWrite.currentWritePos = 0;
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-DRWAV_API drwav_result drwav_uninit(drwav* pWav)
-{
-    drwav_result result = DRWAV_SUCCESS;
-    if (pWav == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-    if (pWav->onWrite != NULL) {
-        drwav_uint32 paddingSize = 0;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            paddingSize = drwav__chunk_padding_size_riff(pWav->dataChunkDataSize);
-        } else {
-            paddingSize = drwav__chunk_padding_size_w64(pWav->dataChunkDataSize);
-        }
-        if (paddingSize > 0) {
-            drwav_uint64 paddingData = 0;
-            drwav__write(pWav, &paddingData, paddingSize);
-        }
-        if (pWav->onSeek && !pWav->isSequentialWrite) {
-            if (pWav->container == drwav_container_riff) {
-                if (pWav->onSeek(pWav->pUserData, 4, drwav_seek_origin_start)) {
-                    drwav_uint32 riffChunkSize = drwav__riff_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
-                    drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_w64) {
-                if (pWav->onSeek(pWav->pUserData, 16, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_rf64) {
-                int ds64BodyPos = 12 + 8;
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            }
-        }
-        if (pWav->isSequentialWrite) {
-            if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
-                result = DRWAV_INVALID_FILE;
-            }
-        }
-    }
-#ifndef DR_WAV_NO_STDIO
-    if (pWav->onRead == drwav__on_read_stdio || pWav->onWrite == drwav__on_write_stdio) {
-        fclose((FILE*)pWav->pUserData);
-    }
-#endif
-    return result;
-}
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut)
-{
-    size_t bytesRead;
-    if (pWav == NULL || bytesToRead == 0) {
-        return 0;
-    }
-    if (bytesToRead > pWav->bytesRemaining) {
-        bytesToRead = (size_t)pWav->bytesRemaining;
-    }
-    if (pBufferOut != NULL) {
-        bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead);
-    } else {
-        bytesRead = 0;
-        while (bytesRead < bytesToRead) {
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > 0x7FFFFFFF) {
-                bytesToSeek = 0x7FFFFFFF;
-            }
-            if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, drwav_seek_origin_current) == DRWAV_FALSE) {
-                break;
-            }
-            bytesRead += bytesToSeek;
-        }
-        while (bytesRead < bytesToRead) {
-            drwav_uint8 buffer[4096];
-            size_t bytesSeeked;
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > sizeof(buffer)) {
-                bytesToSeek = sizeof(buffer);
-            }
-            bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek);
-            bytesRead += bytesSeeked;
-            if (bytesSeeked < bytesToSeek) {
-                break;
-            }
-        }
-    }
-    pWav->bytesRemaining -= bytesRead;
-    return bytesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint32 bytesPerFrame;
-    drwav_uint64 bytesToRead;
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        return 0;
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    bytesToRead = framesToRead * bytesPerFrame;
-    if (bytesToRead > DRWAV_SIZE_MAX) {
-        bytesToRead = (DRWAV_SIZE_MAX / bytesPerFrame) * bytesPerFrame;
-    }
-    if (bytesToRead == 0) {
-        return 0;
-    }
-    return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL) {
-        drwav__bswap_samples(pBufferOut, framesRead*pWav->channels, drwav_get_bytes_per_pcm_frame(pWav)/pWav->channels, pWav->translatedFormatTag);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    } else {
-        return drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav_seek_to_first_pcm_frame(drwav* pWav)
-{
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-    if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        pWav->compressed.iCurrentPCMFrame = 0;
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->msadpcm);
-        } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->ima);
-        } else {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        }
-    }
-    pWav->bytesRemaining = pWav->dataChunkDataSize;
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
-{
-    if (pWav == NULL || pWav->onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pWav->totalPCMFrameCount == 0) {
-        return DRWAV_TRUE;
-    }
-    if (targetFrameIndex >= pWav->totalPCMFrameCount) {
-        targetFrameIndex  = pWav->totalPCMFrameCount - 1;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        if (targetFrameIndex < pWav->compressed.iCurrentPCMFrame) {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-        }
-        if (targetFrameIndex > pWav->compressed.iCurrentPCMFrame) {
-            drwav_uint64 offsetInFrames = targetFrameIndex - pWav->compressed.iCurrentPCMFrame;
-            drwav_int16 devnull[2048];
-            while (offsetInFrames > 0) {
-                drwav_uint64 framesRead = 0;
-                drwav_uint64 framesToRead = offsetInFrames;
-                if (framesToRead > drwav_countof(devnull)/pWav->channels) {
-                    framesToRead = drwav_countof(devnull)/pWav->channels;
-                }
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull);
-                } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull);
-                } else {
-                    DRWAV_ASSERT(DRWAV_FALSE);
-                }
-                if (framesRead != framesToRead) {
-                    return DRWAV_FALSE;
-                }
-                offsetInFrames -= framesRead;
-            }
-        }
-    } else {
-        drwav_uint64 totalSizeInBytes;
-        drwav_uint64 currentBytePos;
-        drwav_uint64 targetBytePos;
-        drwav_uint64 offset;
-        totalSizeInBytes = pWav->totalPCMFrameCount * drwav_get_bytes_per_pcm_frame(pWav);
-        DRWAV_ASSERT(totalSizeInBytes >= pWav->bytesRemaining);
-        currentBytePos = totalSizeInBytes - pWav->bytesRemaining;
-        targetBytePos  = targetFrameIndex * drwav_get_bytes_per_pcm_frame(pWav);
-        if (currentBytePos < targetBytePos) {
-            offset = (targetBytePos - currentBytePos);
-        } else {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-            offset = targetBytePos;
-        }
-        while (offset > 0) {
-            int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset);
-            if (!pWav->onSeek(pWav->pUserData, offset32, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            pWav->bytesRemaining -= offset32;
-            offset -= offset32;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData)
-{
-    size_t bytesWritten;
-    if (pWav == NULL || bytesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
-    pWav->dataChunkDataSize += bytesWritten;
-    return bytesWritten;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    const drwav_uint8* pRunningData;
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-    while (bytesToWrite > 0) {
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    drwav_uint32 bytesPerSample;
-    const drwav_uint8* pRunningData;
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-    bytesPerSample = drwav_get_bytes_per_pcm_frame(pWav) / pWav->channels;
-    while (bytesToWrite > 0) {
-        drwav_uint8 temp[4096];
-        drwav_uint32 sampleCount;
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);
-        sampleCount = sizeof(temp)/bytesPerSample;
-        if (bytesToWriteThisIteration > ((drwav_uint64)sampleCount)*bytesPerSample) {
-            bytesToWriteThisIteration = ((drwav_uint64)sampleCount)*bytesPerSample;
-        }
-        DRWAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration);
-        drwav__bswap_samples(temp, sampleCount, bytesPerSample, pWav->translatedFormatTag);
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_write_pcm_frames_le(pWav, framesToWrite, pData);
-    } else {
-        return drwav_write_pcm_frames_be(pWav, framesToWrite, pData);
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0);
-        if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                drwav_uint8 header[7];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                pWav->msadpcm.predictor[0]     = header[0];
-                pWav->msadpcm.delta[0]         = drwav_bytes_to_s16(header + 1);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 3);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 5);
-                pWav->msadpcm.cachedFrames[2]  = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[3]  = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            } else {
-                drwav_uint8 header[14];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                pWav->msadpcm.predictor[0] = header[0];
-                pWav->msadpcm.predictor[1] = header[1];
-                pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 2);
-                pWav->msadpcm.delta[1] = drwav_bytes_to_s16(header + 4);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 6);
-                pWav->msadpcm.prevFrames[1][1] = (drwav_int32)drwav_bytes_to_s16(header + 8);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 10);
-                pWav->msadpcm.prevFrames[1][0] = (drwav_int32)drwav_bytes_to_s16(header + 12);
-                pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0];
-                pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            }
-        }
-        while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample = 0;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->msadpcm.cachedFrames[(drwav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->msadpcm.cachedFrameCount -= 1;
-        }
-        if (framesToRead == 0) {
-            break;
-        }
-        if (pWav->msadpcm.cachedFrameCount == 0) {
-            if (pWav->msadpcm.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                static drwav_int32 adaptationTable[] = {
-                    230, 230, 230, 230, 307, 409, 512, 614,
-                    768, 614, 512, 409, 307, 230, 230, 230
-                };
-                static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460,  392 };
-                static drwav_int32 coeff2Table[] = { 0,  -256, 0, 64,  0,  -208, -232 };
-                drwav_uint8 nibbles;
-                drwav_int32 nibble0;
-                drwav_int32 nibble1;
-                if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock -= 1;
-                nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
-                nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
-                if (pWav->channels == 1) {
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-                    newSample1  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[0];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample1;
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 2;
-                } else {
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-                    newSample1  = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[1];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-                    pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8;
-                    if (pWav->msadpcm.delta[1] < 16) {
-                        pWav->msadpcm.delta[1] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1];
-                    pWav->msadpcm.prevFrames[1][1] = newSample1;
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 1;
-                }
-            }
-        }
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_uint32 iChannel;
-    static drwav_int32 indexTable[16] = {
-        -1, -1, -1, -1, 2, 4, 6, 8,
-        -1, -1, -1, -1, 2, 4, 6, 8
-    };
-    static drwav_int32 stepTable[89] = {
-        7,     8,     9,     10,    11,    12,    13,    14,    16,    17,
-        19,    21,    23,    25,    28,    31,    34,    37,    41,    45,
-        50,    55,    60,    66,    73,    80,    88,    97,    107,   118,
-        130,   143,   157,   173,   190,   209,   230,   253,   279,   307,
-        337,   371,   408,   449,   494,   544,   598,   658,   724,   796,
-        876,   963,   1060,  1166,  1282,  1411,  1552,  1707,  1878,  2066,
-        2272,  2499,  2749,  3024,  3327,  3660,  4026,  4428,  4871,  5358,
-        5894,  6484,  7132,  7845,  8630,  9493,  10442, 11487, 12635, 13899,
-        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-    };
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0);
-        if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                drwav_uint8 header[4];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                if (header[2] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead;
-                }
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrameCount = 1;
-            } else {
-                drwav_uint8 header[8];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                if (header[2] >= drwav_countof(stepTable) || header[6] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead;
-                }
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.predictor[1] = drwav_bytes_to_s16(header + 4);
-                pWav->ima.stepIndex[1] = header[6];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1];
-                pWav->ima.cachedFrameCount = 1;
-            }
-        }
-        while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->ima.cachedFrameCount -= 1;
-        }
-        if (framesToRead == 0) {
-            break;
-        }
-        if (pWav->ima.cachedFrameCount == 0) {
-            if (pWav->ima.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                pWav->ima.cachedFrameCount = 8;
-                for (iChannel = 0; iChannel < pWav->channels; ++iChannel) {
-                    drwav_uint32 iByte;
-                    drwav_uint8 nibbles[4];
-                    if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) {
-                        pWav->ima.cachedFrameCount = 0;
-                        return totalFramesRead;
-                    }
-                    pWav->ima.bytesRemainingInBlock -= 4;
-                    for (iByte = 0; iByte < 4; ++iByte) {
-                        drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
-                        drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
-                        drwav_int32 step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        drwav_int32 predictor = pWav->ima.predictor[iChannel];
-                        drwav_int32      diff  = step >> 3;
-                        if (nibble0 & 1) diff += step >> 2;
-                        if (nibble0 & 2) diff += step >> 1;
-                        if (nibble0 & 4) diff += step;
-                        if (nibble0 & 8) diff  = -diff;
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor;
-                        step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        predictor = pWav->ima.predictor[iChannel];
-                                         diff  = step >> 3;
-                        if (nibble1 & 1) diff += step >> 2;
-                        if (nibble1 & 2) diff += step >> 1;
-                        if (nibble1 & 4) diff += step;
-                        if (nibble1 & 8) diff  = -diff;
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor;
-                    }
-                }
-            }
-        }
-    }
-    return totalFramesRead;
-}
-#ifndef DR_WAV_NO_CONVERSION_API
-static unsigned short g_drwavAlawTable[256] = {
-    0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
-    0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
-    0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
-    0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
-    0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
-    0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
-    0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
-    0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
-    0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
-    0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
-    0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
-    0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
-    0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
-    0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
-    0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
-    0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
-};
-static unsigned short g_drwavMulawTable[256] = {
-    0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
-    0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
-    0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
-    0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
-    0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
-    0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
-    0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
-    0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
-    0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
-    0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
-    0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
-    0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
-    0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
-    0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
-    0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
-    0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
-};
-static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavAlawTable[sampleIn];
-}
-static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavMulawTable[sampleIn];
-}
-DRWAV_PRIVATE void drwav__pcm_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int16*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_s16(pOut, (const drwav_int32*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (drwav_int16)((drwav_int64)sample >> 48);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if ((pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(drwav_int16) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int16) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x << 8;
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = ((int)(((unsigned int)(((const drwav_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+2])) << 24)) >> 8;
-        r = x >> 8;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x >> 16;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        float c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5f);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        double x = pIn[i];
-        double c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__alaw_to_s16(pIn[i]);
-    }
-}
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__mulaw_to_s16(pIn[i]);
-    }
-}
-DRWAV_PRIVATE void drwav__pcm_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        drwav_s16_to_f32(pOut, (const drwav_int16*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_f32(pOut, (const drwav_int32*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (float)((drwav_int64)sample / 9223372036854775807.0);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        unsigned int i;
-        for (i = 0; i < sampleCount; ++i) {
-            *pOut++ = ((const float*)pIn)[i];
-        }
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_f32(pOut, (const double*)pIn, sampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__pcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_f32(pBufferOut, sampleData, (size_t)framesRead*pWav->channels, bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ima(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ieee(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__alaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__mulaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(float) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(float) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_f32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_f32__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
-    }
-#else
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        x = x * 0.00784313725490196078f;
-        x = x - 1;
-        *pOut++ = x;
-    }
-#endif
-}
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] * 0.000030517578125f;
-    }
-}
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        double x;
-        drwav_uint32 a = ((drwav_uint32)(pIn[i*3+0]) <<  8);
-        drwav_uint32 b = ((drwav_uint32)(pIn[i*3+1]) << 16);
-        drwav_uint32 c = ((drwav_uint32)(pIn[i*3+2]) << 24);
-        x = (double)((drwav_int32)(a | b | c) >> 8);
-        *pOut++ = (float)(x * 0.00000011920928955078125);
-    }
-}
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)(pIn[i] / 2147483648.0);
-    }
-}
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)pIn[i];
-    }
-}
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__alaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__mulaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-DRWAV_PRIVATE void drwav__pcm_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        drwav_s16_to_s32(pOut, (const drwav_int16*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int32*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (drwav_int32)((drwav_int64)sample >> 32);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(drwav_int32) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int32) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s32__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((int)pIn[i] - 128) << 24;
-    }
-}
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] << 16;
-    }
-}
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        unsigned int s0 = pIn[i*3 + 0];
-        unsigned int s1 = pIn[i*3 + 1];
-        unsigned int s2 = pIn[i*3 + 2];
-        drwav_int32 sample32 = (drwav_int32)((s0 << 8) | (s1 << 16) | (s2 << 24));
-        *pOut++ = sample32;
-    }
-}
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__alaw_to_s16(pIn[i])) << 16;
-    }
-}
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i= 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__mulaw_to_s16(pIn[i])) << 16;
-    }
-}
-DRWAV_PRIVATE drwav_int16* drwav__read_pcm_frames_and_close_s16(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int16* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int16);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (drwav_int16*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_PRIVATE float* drwav__read_pcm_frames_and_close_f32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    float* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (float*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_PRIVATE drwav_int32* drwav__read_pcm_frames_and_close_s32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int32* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int32);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (drwav_int32*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drwav__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drwav__free_default(p, NULL);
-    }
-}
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8);
-}
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data)
-{
-    return (short)drwav_bytes_to_u16(data);
-}
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-}
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data)
-{
-    return (drwav_int32)drwav_bytes_to_u32(data);
-}
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data)
-{
-    return
-        ((drwav_uint64)data[0] <<  0) | ((drwav_uint64)data[1] <<  8) | ((drwav_uint64)data[2] << 16) | ((drwav_uint64)data[3] << 24) |
-        ((drwav_uint64)data[4] << 32) | ((drwav_uint64)data[5] << 40) | ((drwav_uint64)data[6] << 48) | ((drwav_uint64)data[7] << 56);
-}
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data)
-{
-    return (drwav_int64)drwav_bytes_to_u64(data);
-}
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
-{
-    int i;
-    for (i = 0; i < 16; i += 1) {
-        if (a[i] != b[i]) {
-            return DRWAV_FALSE;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
-{
-    return
-        a[0] == b[0] &&
-        a[1] == b[1] &&
-        a[2] == b[2] &&
-        a[3] == b[3];
-}
-#endif
-/* dr_wav_c end */
-#endif  /* DRWAV_IMPLEMENTATION */
-#endif  /* MA_NO_WAV */
-
-#if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING)
-#if !defined(DR_FLAC_IMPLEMENTATION) && !defined(DRFLAC_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_flac_c begin */
-#ifndef dr_flac_c
-#define dr_flac_c
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #if __GNUC__ >= 7
-    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-    #endif
-#endif
-#ifdef __linux__
-    #ifndef _BSD_SOURCE
-        #define _BSD_SOURCE
-    #endif
-    #ifndef _DEFAULT_SOURCE
-        #define _DEFAULT_SOURCE
-    #endif
-    #ifndef __USE_BSD
-        #define __USE_BSD
-    #endif
-    #include <endian.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#ifdef _MSC_VER
-    #define DRFLAC_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRFLAC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRFLAC_INLINE __inline
-#else
-    #define DRFLAC_INLINE
-#endif
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRFLAC_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
-    #define DRFLAC_ARM
-#endif
-#if !defined(DR_FLAC_NO_SIMD)
-    #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
-        #if defined(_MSC_VER) && !defined(__clang__)
-            #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
-            #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-        #if defined(DRFLAC_SUPPORT_SSE41)
-            #include <smmintrin.h>
-        #elif defined(DRFLAC_SUPPORT_SSE2)
-            #include <emmintrin.h>
-        #endif
-    #endif
-    #if defined(DRFLAC_ARM)
-        #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            #define DRFLAC_SUPPORT_NEON
-        #endif
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include(<arm_neon.h>)
-                #define DRFLAC_SUPPORT_NEON
-            #endif
-        #endif
-        #if defined(DRFLAC_SUPPORT_NEON)
-            #include <arm_neon.h>
-        #endif
-    #endif
-#endif
-#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #else
-        #if defined(__GNUC__) || defined(__clang__)
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                #if defined(DRFLAC_X86) && defined(__PIC__)
-                    __asm__ __volatile__ (
-                        "xchg{l} {%%}ebx, %k1;"
-                        "cpuid;"
-                        "xchg{l} {%%}ebx, %k1;"
-                        : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #else
-                    __asm__ __volatile__ (
-                        "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #endif
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #endif
-#else
-    #define DRFLAC_NO_CPUID
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return DRFLAC_TRUE;
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
-            return DRFLAC_TRUE;
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[2] & (1 << 19)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
-            #define DRFLAC_HAS_LZCNT_INTRINSIC
-        #endif
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#elif defined(__WATCOMC__) && defined(__386__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
-    extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
-    extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
-#pragma aux _watcom_bswap16 = \
-    "xchg al, ah" \
-    parm   [ax]   \
-    modify [ax];
-#pragma aux _watcom_bswap32 = \
-    "bswap eax"  \
-    parm   [eax] \
-    modify [eax];
-#pragma aux _watcom_bswap64 = \
-    "bswap eax"     \
-    "bswap edx"     \
-    "xchg eax,edx"  \
-    parm [eax edx]  \
-    modify [eax edx];
-#endif
-#ifndef DRFLAC_ASSERT
-#include <assert.h>
-#define DRFLAC_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRFLAC_MALLOC
-#define DRFLAC_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRFLAC_REALLOC
-#define DRFLAC_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRFLAC_FREE
-#define DRFLAC_FREE(p)                      free((p))
-#endif
-#ifndef DRFLAC_COPY_MEMORY
-#define DRFLAC_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRFLAC_ZERO_MEMORY
-#define DRFLAC_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRFLAC_ZERO_OBJECT
-#define DRFLAC_ZERO_OBJECT(p)               DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
-#endif
-#define DRFLAC_MAX_SIMD_VECTOR_SIZE                     64
-typedef drflac_int32 drflac_result;
-#define DRFLAC_SUCCESS                                   0
-#define DRFLAC_ERROR                                    -1
-#define DRFLAC_INVALID_ARGS                             -2
-#define DRFLAC_INVALID_OPERATION                        -3
-#define DRFLAC_OUT_OF_MEMORY                            -4
-#define DRFLAC_OUT_OF_RANGE                             -5
-#define DRFLAC_ACCESS_DENIED                            -6
-#define DRFLAC_DOES_NOT_EXIST                           -7
-#define DRFLAC_ALREADY_EXISTS                           -8
-#define DRFLAC_TOO_MANY_OPEN_FILES                      -9
-#define DRFLAC_INVALID_FILE                             -10
-#define DRFLAC_TOO_BIG                                  -11
-#define DRFLAC_PATH_TOO_LONG                            -12
-#define DRFLAC_NAME_TOO_LONG                            -13
-#define DRFLAC_NOT_DIRECTORY                            -14
-#define DRFLAC_IS_DIRECTORY                             -15
-#define DRFLAC_DIRECTORY_NOT_EMPTY                      -16
-#define DRFLAC_END_OF_FILE                              -17
-#define DRFLAC_NO_SPACE                                 -18
-#define DRFLAC_BUSY                                     -19
-#define DRFLAC_IO_ERROR                                 -20
-#define DRFLAC_INTERRUPT                                -21
-#define DRFLAC_UNAVAILABLE                              -22
-#define DRFLAC_ALREADY_IN_USE                           -23
-#define DRFLAC_BAD_ADDRESS                              -24
-#define DRFLAC_BAD_SEEK                                 -25
-#define DRFLAC_BAD_PIPE                                 -26
-#define DRFLAC_DEADLOCK                                 -27
-#define DRFLAC_TOO_MANY_LINKS                           -28
-#define DRFLAC_NOT_IMPLEMENTED                          -29
-#define DRFLAC_NO_MESSAGE                               -30
-#define DRFLAC_BAD_MESSAGE                              -31
-#define DRFLAC_NO_DATA_AVAILABLE                        -32
-#define DRFLAC_INVALID_DATA                             -33
-#define DRFLAC_TIMEOUT                                  -34
-#define DRFLAC_NO_NETWORK                               -35
-#define DRFLAC_NOT_UNIQUE                               -36
-#define DRFLAC_NOT_SOCKET                               -37
-#define DRFLAC_NO_ADDRESS                               -38
-#define DRFLAC_BAD_PROTOCOL                             -39
-#define DRFLAC_PROTOCOL_UNAVAILABLE                     -40
-#define DRFLAC_PROTOCOL_NOT_SUPPORTED                   -41
-#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED            -42
-#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED             -43
-#define DRFLAC_SOCKET_NOT_SUPPORTED                     -44
-#define DRFLAC_CONNECTION_RESET                         -45
-#define DRFLAC_ALREADY_CONNECTED                        -46
-#define DRFLAC_NOT_CONNECTED                            -47
-#define DRFLAC_CONNECTION_REFUSED                       -48
-#define DRFLAC_NO_HOST                                  -49
-#define DRFLAC_IN_PROGRESS                              -50
-#define DRFLAC_CANCELLED                                -51
-#define DRFLAC_MEMORY_ALREADY_MAPPED                    -52
-#define DRFLAC_AT_END                                   -53
-#define DRFLAC_CRC_MISMATCH                             -128
-#define DRFLAC_SUBFRAME_CONSTANT                        0
-#define DRFLAC_SUBFRAME_VERBATIM                        1
-#define DRFLAC_SUBFRAME_FIXED                           8
-#define DRFLAC_SUBFRAME_LPC                             32
-#define DRFLAC_SUBFRAME_RESERVED                        255
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE  0
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
-#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT           0
-#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE             8
-#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE            9
-#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE              10
-#define drflac_align(x, a)                              ((((x) + (a) - 1) / (a)) * (a))
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRFLAC_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRFLAC_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRFLAC_VERSION_REVISION;
-    }
-}
-DRFLAC_API const char* drflac_version_string(void)
-{
-    return DRFLAC_VERSION_STRING;
-}
-#if defined(__has_feature)
-    #if __has_feature(thread_sanitizer)
-        #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
-    #else
-        #define DRFLAC_NO_THREAD_SANITIZE
-    #endif
-#else
-    #define DRFLAC_NO_THREAD_SANITIZE
-#endif
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
-#endif
-#ifndef DRFLAC_NO_CPUID
-static drflac_bool32 drflac__gIsSSE2Supported  = DRFLAC_FALSE;
-static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
-    if (!isCPUCapsInitialized) {
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-        int info[4] = {0};
-        drflac__cpuid(info, 0x80000001);
-        drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
-#endif
-        drflac__gIsSSE2Supported = drflac_has_sse2();
-        drflac__gIsSSE41Supported = drflac_has_sse41();
-        isCPUCapsInitialized = DRFLAC_TRUE;
-    }
-}
-#else
-static drflac_bool32 drflac__gIsNEONSupported  = DRFLAC_FALSE;
-static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
-{
-#if defined(DRFLAC_SUPPORT_NEON)
-    #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return DRFLAC_TRUE;
-        #else
-            return DRFLAC_FALSE;
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    drflac__gIsNEONSupported = drflac__has_neon();
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    drflac__gIsLZCNTSupported = DRFLAC_TRUE;
-#endif
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
-{
-#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
-    return DRFLAC_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRFLAC_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRFLAC_64BIT)
-            drflac_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRFLAC_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap32(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drflac_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drflac_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drflac_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drflac_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drflac_uint64)0x000000FF      )) << 56);
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint16(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint64(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
-{
-    if (!drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
-{
-    drflac_uint32 result = 0;
-    result |= (n & 0x7F000000) >> 3;
-    result |= (n & 0x007F0000) >> 2;
-    result |= (n & 0x00007F00) >> 1;
-    result |= (n & 0x0000007F) >> 0;
-    return result;
-}
-static drflac_uint8 drflac__crc8_table[] = {
-    0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
-    0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
-    0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
-    0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
-    0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
-    0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
-    0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
-    0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
-    0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
-    0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
-    0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
-    0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
-    0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
-    0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
-    0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
-    0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-static drflac_uint16 drflac__crc16_table[] = {
-    0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
-    0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
-    0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
-    0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
-    0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
-    0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
-    0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
-    0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
-    0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
-    0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
-    0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
-    0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
-    0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
-    0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
-    0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
-    0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
-    0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
-    0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
-    0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
-    0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
-    0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
-    0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
-    0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
-    0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
-    0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
-    0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
-    0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
-    0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
-    0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
-    0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
-    0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
-    0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
-};
-static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
-{
-    return drflac__crc8_table[crc ^ data];
-}
-static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    drflac_uint8 p = 0x07;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint8 bit = (data & (1 << i)) >> i;
-        if (crc & 0x80) {
-            crc = ((crc << 1) | bit) ^ p;
-        } else {
-            crc = ((crc << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 32);
-    wholeBytes = count >> 3;
-    leftoverBits = count - (wholeBytes*8);
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
-    }
-    return crc;
-#endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
-{
-    return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
-{
-#ifdef DRFLAC_64BIT
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc;
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
-{
-    switch (byteCount)
-    {
-#ifdef DRFLAC_64BIT
-    case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    }
-    return crc;
-}
-#if 0
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    drflac_uint16 p = 0x8005;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint16 bit = (data & (1ULL << i)) >> i;
-        if (r & 0x8000) {
-            r = ((r << 1) | bit) ^ p;
-        } else {
-            r = ((r << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 64);
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        default:
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 64);
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        default:
-        case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits)));
-        case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
-        case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
-        case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000      ) << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000      ) << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00      ) << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF      ) << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
-{
-#ifdef DRFLAC_64BIT
-    return drflac_crc16__64bit(crc, data, count);
-#else
-    return drflac_crc16__32bit(crc, data, count);
-#endif
-}
-#endif
-#ifdef DRFLAC_64BIT
-#define drflac__be2host__cache_line drflac__be2host_64
-#else
-#define drflac__be2host__cache_line drflac__be2host_32
-#endif
-#define DRFLAC_CACHE_L1_SIZE_BYTES(bs)                      (sizeof((bs)->cache))
-#define DRFLAC_CACHE_L1_SIZE_BITS(bs)                       (sizeof((bs)->cache)*8)
-#define DRFLAC_CACHE_L1_BITS_REMAINING(bs)                  (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
-#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount)           (~((~(drflac_cache_t)0) >> (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount)      (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
-#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount)               (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount)     (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >>  DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
-#define DRFLAC_CACHE_L2_SIZE_BYTES(bs)                      (sizeof((bs)->cacheL2))
-#define DRFLAC_CACHE_L2_LINE_COUNT(bs)                      (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
-#define DRFLAC_CACHE_L2_LINES_REMAINING(bs)                 (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
-#ifndef DR_FLAC_NO_CRC
-static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
-{
-    bs->crc16 = 0;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-}
-static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
-{
-    if (bs->crc16CacheIgnoredBytes == 0) {
-        bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = 0;
-    }
-}
-static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
-{
-    DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
-    if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
-        drflac__update_crc16(bs);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-    }
-    return bs->crc16;
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
-{
-    size_t bytesRead;
-    size_t alignedL1LineCount;
-    if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-    if (bs->unalignedByteCount > 0) {
-        return DRFLAC_FALSE;
-    }
-    bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
-    bs->nextL2Line = 0;
-    if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-    alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
-    bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    if (bs->unalignedByteCount > 0) {
-        bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
-    }
-    if (alignedL1LineCount > 0) {
-        size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
-        size_t i;
-        for (i = alignedL1LineCount; i > 0; --i) {
-            bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
-        }
-        bs->nextL2Line = (drflac_uint32)offset;
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    } else {
-        bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-        return DRFLAC_FALSE;
-    }
-}
-static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
-{
-    size_t bytesRead;
-#ifndef DR_FLAC_NO_CRC
-    drflac__update_crc16(bs);
-#endif
-    if (drflac__reload_l1_cache_from_l2(bs)) {
-        bs->cache = drflac__be2host__cache_line(bs->cache);
-        bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-        bs->crc16Cache = bs->cache;
-#endif
-        return DRFLAC_TRUE;
-    }
-    bytesRead = bs->unalignedByteCount;
-    if (bytesRead == 0) {
-        bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
-    bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
-    bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs));
-    bs->unalignedByteCount = 0;
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = bs->cache >> bs->consumedBits;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-#endif
-    return DRFLAC_TRUE;
-}
-static void drflac__reset_cache(drflac_bs* bs)
-{
-    bs->nextL2Line   = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-    bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-    bs->cache = 0;
-    bs->unalignedByteCount = 0;
-    bs->unalignedCache = 0;
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = 0;
-    bs->crc16CacheIgnoredBytes = 0;
-#endif
-}
-static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResultOut != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-    if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-#ifdef DRFLAC_64BIT
-        *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-        bs->consumedBits += bitCount;
-        bs->cache <<= bitCount;
-#else
-        if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-            bs->consumedBits += bitCount;
-            bs->cache <<= bitCount;
-        } else {
-            *pResultOut = (drflac_uint32)bs->cache;
-            bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-            bs->cache = 0;
-        }
-#endif
-        return DRFLAC_TRUE;
-    } else {
-        drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        drflac_uint32 bitCountLo = bitCount - bitCountHi;
-        drflac_uint32 resultHi;
-        DRFLAC_ASSERT(bitCountHi > 0);
-        DRFLAC_ASSERT(bitCountHi < 32);
-        resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-        *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    if (bitCount < 32) {
-        drflac_uint32 signbit;
-        signbit = ((result >> (bitCount-1)) & 0x01);
-        result |= (~signbit + 1) << bitCount;
-    }
-    *pResult = (drflac_int32)result;
-    return DRFLAC_TRUE;
-}
-#ifdef DRFLAC_64BIT
-static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
-{
-    drflac_uint32 resultHi;
-    drflac_uint32 resultLo;
-    DRFLAC_ASSERT(bitCount <= 64);
-    DRFLAC_ASSERT(bitCount >  32);
-    if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac__read_uint32(bs, 32, &resultLo)) {
-        return DRFLAC_FALSE;
-    }
-    *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
-{
-    drflac_uint64 result;
-    drflac_uint64 signbit;
-    DRFLAC_ASSERT(bitCount <= 64);
-    if (!drflac__read_uint64(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    signbit = ((result >> (bitCount-1)) & 0x01);
-    result |= (~signbit + 1) << bitCount;
-    *pResultOut = (drflac_int64)result;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_uint16)result;
-    return DRFLAC_TRUE;
-}
-#if 0
-static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
-{
-    drflac_int32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_int16)result;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_uint8)result;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
-{
-    drflac_int32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_int8)result;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
-{
-    if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        bs->consumedBits += (drflac_uint32)bitsToSeek;
-        bs->cache <<= bitsToSeek;
-        return DRFLAC_TRUE;
-    } else {
-        bitsToSeek       -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->cache         = 0;
-#ifdef DRFLAC_64BIT
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint64 bin;
-            if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#else
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint32 bin;
-            if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#endif
-        while (bitsToSeek >= 8) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, 8, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= 8;
-        }
-        if (bitsToSeek > 0) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek = 0;
-        }
-        DRFLAC_ASSERT(bitsToSeek == 0);
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-        return DRFLAC_FALSE;
-    }
-    for (;;) {
-        drflac_uint8 hi;
-#ifndef DR_FLAC_NO_CRC
-        drflac__reset_crc16(bs);
-#endif
-        if (!drflac__read_uint8(bs, 8, &hi)) {
-            return DRFLAC_FALSE;
-        }
-        if (hi == 0xFF) {
-            drflac_uint8 lo;
-            if (!drflac__read_uint8(bs, 6, &lo)) {
-                return DRFLAC_FALSE;
-            }
-            if (lo == 0x3E) {
-                return DRFLAC_TRUE;
-            } else {
-                if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-#define DRFLAC_IMPLEMENT_CLZ_LZCNT
-#endif
-#if  defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
-#define DRFLAC_IMPLEMENT_CLZ_MSVC
-#endif
-#if  defined(__WATCOMC__) && defined(__386__)
-#define DRFLAC_IMPLEMENT_CLZ_WATCOM
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    static drflac_uint32 clz_table_4[] = {
-        0,
-        4,
-        3, 3,
-        2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1
-    };
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-    n = clz_table_4[x >> (sizeof(x)*8 - 4)];
-    if (n == 0) {
-#ifdef DRFLAC_64BIT
-        if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n  = 32; x <<= 32; }
-        if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
-        if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8;  x <<= 8;  }
-        if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4;  x <<= 4;  }
-#else
-        if ((x & 0xFFFF0000) == 0) { n  = 16; x <<= 16; }
-        if ((x & 0xFF000000) == 0) { n += 8;  x <<= 8;  }
-        if ((x & 0xF0000000) == 0) { n += 4;  x <<= 4;  }
-#endif
-        n += clz_table_4[x >> (sizeof(x)*8 - 4)];
-    }
-    return n - 1;
-}
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
-{
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    return DRFLAC_TRUE;
-#else
-    #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
-        return drflac__gIsLZCNTSupported;
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
-{
-#if defined(_MSC_VER)
-    #ifdef DRFLAC_64BIT
-        return (drflac_uint32)__lzcnt64(x);
-    #else
-        return (drflac_uint32)__lzcnt(x);
-    #endif
-#else
-    #if defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_X64)
-            {
-                drflac_uint64 r;
-                __asm__ __volatile__ (
-                    "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-                return (drflac_uint32)r;
-            }
-        #elif defined(DRFLAC_X86)
-            {
-                drflac_uint32 r;
-                __asm__ __volatile__ (
-                    "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-                return r;
-            }
-        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)
-            {
-                unsigned int r;
-                __asm__ __volatile__ (
-                #if defined(DRFLAC_64BIT)
-                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)
-                #else
-                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
-                #endif
-                );
-                return r;
-            }
-        #else
-            if (x == 0) {
-                return sizeof(x)*8;
-            }
-            #ifdef DRFLAC_64BIT
-                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
-            #else
-                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
-            #endif
-        #endif
-    #else
-        #error "This compiler does not support the lzcnt intrinsic."
-    #endif
-#endif
-}
-#endif
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-#include <intrin.h>
-static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-#ifdef DRFLAC_64BIT
-    _BitScanReverse64((unsigned long*)&n, x);
-#else
-    _BitScanReverse((unsigned long*)&n, x);
-#endif
-    return sizeof(x)*8 - n - 1;
-}
-#endif
-#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
-static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
-#pragma aux drflac__clz_watcom = \
-    "bsr eax, eax" \
-    "xor eax, 31" \
-    parm [eax] nomemory \
-    value [eax] \
-    modify exact [eax] nomemory;
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
-{
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-    if (drflac__is_lzcnt_supported()) {
-        return drflac__clz_lzcnt(x);
-    } else
-#endif
-    {
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-        return drflac__clz_msvc(x);
-#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
-        return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
-#else
-        return drflac__clz_software(x);
-#endif
-    }
-}
-static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 setBitOffsetPlus1;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    setBitOffsetPlus1 += 1;
-    bs->consumedBits += setBitOffsetPlus1;
-    bs->cache <<= setBitOffsetPlus1;
-    *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(offsetFromStart > 0);
-    if (offsetFromStart > 0x7FFFFFFF) {
-        drflac_uint64 bytesRemaining = offsetFromStart;
-        if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        bytesRemaining -= 0x7FFFFFFF;
-        while (bytesRemaining > 0x7FFFFFFF) {
-            if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemaining -= 0x7FFFFFFF;
-        }
-        if (bytesRemaining > 0) {
-            if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-    } else {
-        if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    drflac__reset_cache(bs);
-    return DRFLAC_TRUE;
-}
-static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
-{
-    drflac_uint8 crc;
-    drflac_uint64 result;
-    drflac_uint8 utf8[7] = {0};
-    int byteCount;
-    int i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pNumberOut != NULL);
-    DRFLAC_ASSERT(pCRCOut != NULL);
-    crc = *pCRCOut;
-    if (!drflac__read_uint8(bs, 8, utf8)) {
-        *pNumberOut = 0;
-        return DRFLAC_AT_END;
-    }
-    crc = drflac_crc8(crc, utf8[0], 8);
-    if ((utf8[0] & 0x80) == 0) {
-        *pNumberOut = utf8[0];
-        *pCRCOut = crc;
-        return DRFLAC_SUCCESS;
-    }
-    if ((utf8[0] & 0xE0) == 0xC0) {
-        byteCount = 2;
-    } else if ((utf8[0] & 0xF0) == 0xE0) {
-        byteCount = 3;
-    } else if ((utf8[0] & 0xF8) == 0xF0) {
-        byteCount = 4;
-    } else if ((utf8[0] & 0xFC) == 0xF8) {
-        byteCount = 5;
-    } else if ((utf8[0] & 0xFE) == 0xFC) {
-        byteCount = 6;
-    } else if ((utf8[0] & 0xFF) == 0xFE) {
-        byteCount = 7;
-    } else {
-        *pNumberOut = 0;
-        return DRFLAC_CRC_MISMATCH;
-    }
-    DRFLAC_ASSERT(byteCount > 1);
-    result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
-    for (i = 1; i < byteCount; ++i) {
-        if (!drflac__read_uint8(bs, 8, utf8 + i)) {
-            *pNumberOut = 0;
-            return DRFLAC_AT_END;
-        }
-        crc = drflac_crc8(crc, utf8[i], 8);
-        result = (result << 6) | (utf8[i] & 0x3F);
-    }
-    *pNumberOut = result;
-    *pCRCOut = crc;
-    return DRFLAC_SUCCESS;
-}
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int32 prediction = 0;
-    DRFLAC_ASSERT(order <= 32);
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
-    }
-    return (drflac_int32)(prediction >> shift);
-}
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int64 prediction;
-    DRFLAC_ASSERT(order <= 32);
-#ifndef DRFLAC_64BIT
-    if (order == 8)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
-    }
-    else if (order == 7)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-    }
-    else if (order == 3)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-    }
-    else if (order == 6)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-    }
-    else if (order == 5)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-    }
-    else if (order == 4)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-    }
-    else if (order == 12)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-        prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    }
-    else if (order == 2)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-    }
-    else if (order == 1)
-    {
-        prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-    }
-    else if (order == 10)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-    }
-    else if (order == 9)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-    }
-    else if (order == 11)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    }
-    else
-    {
-        int j;
-        prediction = 0;
-        for (j = 0; j < (int)order; ++j) {
-            prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
-        }
-    }
-#endif
-#ifdef DRFLAC_64BIT
-    prediction = 0;
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
-    }
-#endif
-    return (drflac_int32)(prediction >> shift);
-}
-#if 0
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    for (i = 0; i < count; ++i) {
-        drflac_uint32 zeroCounter = 0;
-        for (;;) {
-            drflac_uint8 bit;
-            if (!drflac__read_uint8(bs, 1, &bit)) {
-                return DRFLAC_FALSE;
-            }
-            if (bit == 0) {
-                zeroCounter += 1;
-            } else {
-                break;
-            }
-        }
-        drflac_uint32 decodedRice;
-        if (riceParam > 0) {
-            if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            decodedRice = 0;
-        }
-        decodedRice |= (zeroCounter << riceParam);
-        if ((decodedRice & 0x01)) {
-            decodedRice = ~(decodedRice >> 1);
-        } else {
-            decodedRice =  (decodedRice >> 1);
-        }
-        if (bitsPerSample+shift >= 32) {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 decodedRice;
-    for (;;) {
-        drflac_uint8 bit;
-        if (!drflac__read_uint8(bs, 1, &bit)) {
-            return DRFLAC_FALSE;
-        }
-        if (bit == 0) {
-            zeroCounter += 1;
-        } else {
-            break;
-        }
-    }
-    if (riceParam > 0) {
-        if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        decodedRice = 0;
-    }
-    *pZeroCounterOut = zeroCounter;
-    *pRiceParamPartOut = decodedRice;
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_cache_t riceParamMask;
-    drflac_uint32 zeroCounter;
-    drflac_uint32 setBitOffsetPlus1;
-    drflac_uint32 riceParamPart;
-    drflac_uint32 riceLength;
-    DRFLAC_ASSERT(riceParam > 0);
-    riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
-    zeroCounter = 0;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    zeroCounter += setBitOffsetPlus1;
-    setBitOffsetPlus1 += 1;
-    riceLength = setBitOffsetPlus1 + riceParam;
-    if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
-        bs->consumedBits += riceLength;
-        bs->cache <<= riceLength;
-    } else {
-        drflac_uint32 bitCountLo;
-        drflac_cache_t resultHi;
-        bs->consumedBits += riceLength;
-        bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1);
-        bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam);
-        if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-#ifndef DR_FLAC_NO_CRC
-            drflac__update_crc16(bs);
-#endif
-            bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-            bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-            bs->crc16Cache = bs->cache;
-#endif
-        } else {
-            if (!drflac__reload_cache(bs)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-    }
-    pZeroCounterOut[0] = zeroCounter;
-    pRiceParamPartOut[0] = riceParamPart;
-    return DRFLAC_TRUE;
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        pZeroCounterOut[0] = lzcount;
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartHi;
-            drflac_uint32 riceParamPartLo;
-            drflac_uint32 riceParamPartLoBitCount;
-            riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-            riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
-            pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-            lzcount = drflac__clz(bs_cache);
-            zeroCounter += lzcount;
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-        pZeroCounterOut[0] = zeroCounter;
-        goto extract_rice_param_part;
-    }
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-    return DRFLAC_TRUE;
-}
-static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-            lzcount = drflac__clz(bs_cache);
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-        goto extract_rice_param_part;
-    }
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0;
-    drflac_uint32 riceParamPart0;
-    drflac_uint32 riceParamMask;
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    (void)bitsPerSample;
-    (void)order;
-    (void)shift;
-    (void)coefficients;
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    i = 0;
-    while (i < count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        pSamplesOut[i] = riceParamPart0;
-        i += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0 = 0;
-    drflac_uint32 zeroCountPart1 = 0;
-    drflac_uint32 zeroCountPart2 = 0;
-    drflac_uint32 zeroCountPart3 = 0;
-    drflac_uint32 riceParamPart0 = 0;
-    drflac_uint32 riceParamPart1 = 0;
-    drflac_uint32 riceParamPart2 = 0;
-    drflac_uint32 riceParamPart3 = 0;
-    drflac_uint32 riceParamMask;
-    const drflac_int32* pSamplesOutEnd;
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order == 0) {
-        return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    pSamplesOutEnd = pSamplesOut + (count & ~3);
-    if (bitsPerSample+shift > 32) {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
-            pSamplesOut += 4;
-        }
-    } else {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
-            pSamplesOut += 4;
-        }
-    }
-    i = (count & ~3);
-    while (i < count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        if (bitsPerSample+shift > 32) {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-        } else {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-        }
-        i += 1;
-        pSamplesOut += 1;
-    }
-    return DRFLAC_TRUE;
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
-{
-    __m128i r;
-    r = _mm_packs_epi32(a, b);
-    r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    return r;
-}
-#endif
-#if defined(DRFLAC_SUPPORT_SSE41)
-static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
-{
-    return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
-}
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
-{
-    __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-    __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
-    return _mm_add_epi32(x64, x32);
-}
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
-{
-    return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-}
-static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
-{
-    __m128i lo = _mm_srli_epi64(x, count);
-    __m128i hi = _mm_srai_epi32(x, count);
-    hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0));
-    return _mm_or_si128(lo, hi);
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i riceParamMask128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-    coefficients128_0 = _mm_setzero_si128();
-    coefficients128_4 = _mm_setzero_si128();
-    coefficients128_8 = _mm_setzero_si128();
-    samples128_0 = _mm_setzero_si128();
-    samples128_4 = _mm_setzero_si128();
-    samples128_8 = _mm_setzero_si128();
-#if 1
-    {
-        int runningOrder = order;
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i prediction128;
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01)));
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_4, samples128_4);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_8, samples128_8);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        }
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i prediction128;
-    __m128i riceParamMask128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    DRFLAC_ASSERT(order <= 12);
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-    prediction128 = _mm_setzero_si128();
-    coefficients128_0  = _mm_setzero_si128();
-    coefficients128_4  = _mm_setzero_si128();
-    coefficients128_8  = _mm_setzero_si128();
-    samples128_0  = _mm_setzero_si128();
-    samples128_4  = _mm_setzero_si128();
-    samples128_8  = _mm_setzero_si128();
-#if 1
-    {
-        int runningOrder = order;
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
-        for (i = 0; i < 4; i += 1) {
-            prediction128 = _mm_xor_si128(prediction128, prediction128);
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
-            case 10:
-            case  9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  8:
-            case  7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  6:
-            case  5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  4:
-            case  3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  2:
-            case  1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
-            }
-            prediction128 = drflac__mm_hadd_epi64(prediction128);
-            prediction128 = drflac__mm_srai_epi64(prediction128, shift);
-            prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-            samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-            samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-            samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-            riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-        }
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
-{
-    vst1q_s32(p+0, x.val[0]);
-    vst1q_s32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
-{
-    vst1q_u32(p+0, x.val[0]);
-    vst1q_u32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
-{
-    vst1q_f32(p+0, x.val[0]);
-    vst1q_f32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
-{
-    vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
-}
-static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
-{
-    vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
-}
-static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
-{
-    drflac_int32 x[4];
-    x[3] = x3;
-    x[2] = x2;
-    x[1] = x1;
-    x[0] = x0;
-    return vld1q_s32(x);
-}
-static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
-{
-    return vextq_s32(b, a, 1);
-}
-static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
-{
-    return vextq_u32(b, a, 1);
-}
-static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
-{
-    int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
-    return vpadd_s32(r, r);
-}
-static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
-{
-    return vadd_s64(vget_high_s64(x), vget_low_s64(x));
-}
-static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
-{
-    return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
-}
-static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
-{
-    return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
-}
-static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
-{
-    return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int32x2_t shift64;
-    uint32x4_t one128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s32(-shift);
-    one128 = vdupq_n_u32(1);
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3];
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2];
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1];
-            }
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7];
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6];
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5];
-            }
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11];
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10];
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9];
-            }
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int32x4_t prediction128;
-        int32x2_t prediction64;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = vmulq_s32(coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_8, samples128_8);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        }
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int64x1_t shift64;
-    uint32x4_t one128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s64(-shift);
-    one128 = vdupq_n_u32(1);
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3];
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2];
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1];
-            }
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7];
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6];
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5];
-            }
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11];
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10];
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9];
-            }
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int64x2_t prediction128;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-        for (i = 0; i < 4; i += 1) {
-            int64x1_t prediction64;
-            prediction128 = veorq_s64(prediction128, prediction128);
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
-            case 10:
-            case  9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
-            case  8:
-            case  7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
-            case  6:
-            case  5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
-            case  4:
-            case  3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
-            case  2:
-            case  1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
-            }
-            prediction64 = drflac__vhaddq_s64(prediction128);
-            prediction64 = vshl_s64(prediction64, shift64);
-            prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
-            samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-            samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-            samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
-            riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-        }
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    if (drflac__gIsSSE41Supported) {
-        return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported) {
-        return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#endif
-    {
-    #if 0
-        return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #else
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #endif
-    }
-}
-static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    for (i = 0; i < count; ++i) {
-        if (!drflac__seek_rice_parts(bs, riceParam)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(unencodedBitsPerSample <= 31);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    for (i = 0; i < count; ++i) {
-        if (unencodedBitsPerSample > 0) {
-            if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            pSamplesOut[i] = 0;
-        }
-        if (bitsPerSample >= 24) {
-            pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    DRFLAC_ASSERT(pDecodedSamples != NULL);
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;
-    }
-    pDecodedSamples += order;
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-    if ((blockSize / (1 << partitionOrder)) < order) {
-        return DRFLAC_FALSE;
-    }
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;) {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-        if (riceParam != 0xFF) {
-            if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        pDecodedSamples += samplesInPartition;
-        if (partitionsRemaining == 1) {
-            break;
-        }
-        partitionsRemaining -= 1;
-        if (partitionOrder != 0) {
-            samplesInPartition = blockSize / (1 << partitionOrder);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;)
-    {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-        if (riceParam != 0xFF) {
-            if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        if (partitionsRemaining == 1) {
-            break;
-        }
-        partitionsRemaining -= 1;
-        samplesInPartition = blockSize / (1 << partitionOrder);
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    drflac_int32 sample;
-    if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-        return DRFLAC_FALSE;
-    }
-    for (i = 0; i < blockSize; ++i) {
-        pDecodedSamples[i] = sample;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    for (i = 0; i < blockSize; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    static drflac_int32 lpcCoefficientsTable[5][4] = {
-        {0,  0, 0,  0},
-        {1,  0, 0,  0},
-        {2, -1, 0,  0},
-        {3, -3, 1,  0},
-        {4, -6, 4, -1}
-    };
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 i;
-    drflac_uint8 lpcPrecision;
-    drflac_int8 lpcShift;
-    drflac_int32 coefficients[32];
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcPrecision == 15) {
-        return DRFLAC_FALSE;
-    }
-    lpcPrecision += 1;
-    if (!drflac__read_int8(bs, 5, &lpcShift)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcShift < 0) {
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
-    for (i = 0; i < lpcOrder; ++i) {
-        if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
-{
-    const drflac_uint32 sampleRateTable[12]  = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
-    const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1};
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(header != NULL);
-    for (;;) {
-        drflac_uint8 crc8 = 0xCE;
-        drflac_uint8 reserved = 0;
-        drflac_uint8 blockingStrategy = 0;
-        drflac_uint8 blockSize = 0;
-        drflac_uint8 sampleRate = 0;
-        drflac_uint8 channelAssignment = 0;
-        drflac_uint8 bitsPerSample = 0;
-        drflac_bool32 isVariableBlockSize;
-        if (!drflac__find_and_seek_to_next_sync_code(bs)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-        if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, blockingStrategy, 1);
-        if (!drflac__read_uint8(bs, 4, &blockSize)) {
-            return DRFLAC_FALSE;
-        }
-        if (blockSize == 0) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, blockSize, 4);
-        if (!drflac__read_uint8(bs, 4, &sampleRate)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, sampleRate, 4);
-        if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
-            return DRFLAC_FALSE;
-        }
-        if (channelAssignment > 10) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, channelAssignment, 4);
-        if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        if (bitsPerSample == 3 || bitsPerSample == 7) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, bitsPerSample, 3);
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-        isVariableBlockSize = blockingStrategy == 1;
-        if (isVariableBlockSize) {
-            drflac_uint64 pcmFrameNumber;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = 0;
-            header->pcmFrameNumber = pcmFrameNumber;
-        } else {
-            drflac_uint64 flacFrameNumber = 0;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = (drflac_uint32)flacFrameNumber;
-            header->pcmFrameNumber = 0;
-        }
-        DRFLAC_ASSERT(blockSize > 0);
-        if (blockSize == 1) {
-            header->blockSizeInPCMFrames = 192;
-        } else if (blockSize <= 5) {
-            DRFLAC_ASSERT(blockSize >= 2);
-            header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
-        } else if (blockSize == 6) {
-            if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
-            header->blockSizeInPCMFrames += 1;
-        } else if (blockSize == 7) {
-            if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
-            header->blockSizeInPCMFrames += 1;
-        } else {
-            DRFLAC_ASSERT(blockSize >= 8);
-            header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
-        }
-        if (sampleRate <= 11) {
-            header->sampleRate = sampleRateTable[sampleRate];
-        } else if (sampleRate == 12) {
-            if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 8);
-            header->sampleRate *= 1000;
-        } else if (sampleRate == 13) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-        } else if (sampleRate == 14) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-            header->sampleRate *= 10;
-        } else {
-            continue;
-        }
-        header->channelAssignment = channelAssignment;
-        header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
-        if (header->bitsPerSample == 0) {
-            header->bitsPerSample = streaminfoBitsPerSample;
-        }
-        if (!drflac__read_uint8(bs, 8, &header->crc8)) {
-            return DRFLAC_FALSE;
-        }
-#ifndef DR_FLAC_NO_CRC
-        if (header->crc8 != crc8) {
-            continue;
-        }
-#endif
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
-{
-    drflac_uint8 header;
-    int type;
-    if (!drflac__read_uint8(bs, 8, &header)) {
-        return DRFLAC_FALSE;
-    }
-    if ((header & 0x80) != 0) {
-        return DRFLAC_FALSE;
-    }
-    type = (header & 0x7E) >> 1;
-    if (type == 0) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
-    } else if (type == 1) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
-    } else {
-        if ((type & 0x20) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
-        } else if ((type & 0x08) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
-            if (pSubframe->lpcOrder > 4) {
-                pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-                pSubframe->lpcOrder = 0;
-            }
-        } else {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-        }
-    }
-    if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
-        return DRFLAC_FALSE;
-    }
-    pSubframe->wastedBitsPerSample = 0;
-    if ((header & 0x01) == 1) {
-        unsigned int wastedBitsPerSample;
-        if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-    pSubframe->pSamplesS32 = pDecodedSamplesOut;
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-        default: return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-    pSubframe->pSamplesS32 = NULL;
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac_uint8 lpcPrecision;
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-                return DRFLAC_FALSE;
-            }
-            if (lpcPrecision == 15) {
-                return DRFLAC_FALSE;
-            }
-            lpcPrecision += 1;
-            bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        default: return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
-{
-    drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
-    DRFLAC_ASSERT(channelAssignment <= 10);
-    return lookup[channelAssignment];
-}
-static drflac_result drflac__decode_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint8 paddingSizeInBits;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-    DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
-    if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_ERROR;
-    }
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    if (channelCount != (int)pFlac->channels) {
-        return DRFLAC_ERROR;
-    }
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
-            return DRFLAC_ERROR;
-        }
-    }
-    paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
-    if (paddingSizeInBits > 0) {
-        drflac_uint8 padding = 0;
-        if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
-            return DRFLAC_AT_END;
-        }
-    }
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;
-    }
-#endif
-    pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    return DRFLAC_SUCCESS;
-}
-static drflac_result drflac__seek_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
-            return DRFLAC_ERROR;
-        }
-    }
-    if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
-        return DRFLAC_ERROR;
-    }
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    for (;;) {
-        drflac_result result;
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-        result = drflac__decode_flac_frame(pFlac);
-        if (result != DRFLAC_SUCCESS) {
-            if (result == DRFLAC_CRC_MISMATCH) {
-                continue;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-        return DRFLAC_TRUE;
-    }
-}
-static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 lastPCMFrame;
-    DRFLAC_ASSERT(pFlac != NULL);
-    firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
-    if (firstPCMFrame == 0) {
-        firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
-    }
-    lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    if (lastPCMFrame > 0) {
-        lastPCMFrame -= 1;
-    }
-    if (pFirstPCMFrame) {
-        *pFirstPCMFrame = firstPCMFrame;
-    }
-    if (pLastPCMFrame) {
-        *pLastPCMFrame = lastPCMFrame;
-    }
-}
-static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
-{
-    drflac_bool32 result;
-    DRFLAC_ASSERT(pFlac != NULL);
-    result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
-    DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-    pFlac->currentPCMFrame = 0;
-    return result;
-}
-static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    return drflac__seek_flac_frame(pFlac);
-}
-static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
-{
-    drflac_uint64 pcmFramesRead = 0;
-    while (pcmFramesToSeek > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
-                pcmFramesRead   += pcmFramesToSeek;
-                pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek;
-                pcmFramesToSeek  = 0;
-            } else {
-                pcmFramesRead   += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-            }
-        }
-    }
-    pFlac->currentPCMFrame += pcmFramesRead;
-    return pcmFramesRead;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    DRFLAC_ASSERT(pFlac != NULL);
-    if (pcmFrameIndex >= pFlac->currentPCMFrame) {
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        runningPCMFrameCount = 0;
-        if (!drflac__seek_to_first_frame(pFlac)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-    next_iteration:
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-#if !defined(DR_FLAC_NO_CRC)
-#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
-static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
-    DRFLAC_ASSERT(targetByte >= rangeLo);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-    *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
-    for (;;) {
-        drflac_uint64 lastTargetByte = targetByte;
-        if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
-            if (targetByte == 0) {
-                drflac__seek_to_first_frame(pFlac);
-                return DRFLAC_FALSE;
-            }
-            targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-            rangeHi = targetByte;
-        } else {
-            DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-#if 1
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#else
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#endif
-        }
-        if(targetByte == lastTargetByte) {
-            return DRFLAC_FALSE;
-        }
-    }
-    drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-    *pLastSuccessfulSeekOffset = targetByte;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
-{
-#if 0
-    if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
-        if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-    }
-#endif
-    return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
-{
-    drflac_uint64 targetByte;
-    drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
-    drflac_uint64 pcmRangeHi = 0;
-    drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
-    drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-    targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
-    if (targetByte > byteRangeHi) {
-        targetByte = byteRangeHi;
-    }
-    for (;;) {
-        if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
-            drflac_uint64 newPCMRangeLo;
-            drflac_uint64 newPCMRangeHi;
-            drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
-            if (pcmRangeLo == newPCMRangeLo) {
-                if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
-                    break;
-                }
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;
-                }
-            }
-            pcmRangeLo = newPCMRangeLo;
-            pcmRangeHi = newPCMRangeHi;
-            if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;
-                }
-            } else {
-                const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-                if (pcmRangeLo > pcmFrameIndex) {
-                    byteRangeHi = lastSuccessfulSeekOffset;
-                    if (byteRangeLo > byteRangeHi) {
-                        byteRangeLo = byteRangeHi;
-                    }
-                    targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
-                    if (targetByte < byteRangeLo) {
-                        targetByte = byteRangeLo;
-                    }
-                } else  {
-                    if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
-                        if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                            return DRFLAC_TRUE;
-                        } else {
-                            break;
-                        }
-                    } else {
-                        byteRangeLo = lastSuccessfulSeekOffset;
-                        if (byteRangeHi < byteRangeLo) {
-                            byteRangeHi = byteRangeLo;
-                        }
-                        targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
-                        if (targetByte > byteRangeHi) {
-                            targetByte = byteRangeHi;
-                        }
-                        if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
-                            closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
-                        }
-                    }
-                }
-            }
-        } else {
-            break;
-        }
-    }
-    drflac__seek_to_first_frame(pFlac);
-    return DRFLAC_FALSE;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint64 byteRangeLo;
-    drflac_uint64 byteRangeHi;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-    if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
-        return DRFLAC_FALSE;
-    }
-    if (pcmFrameIndex < seekForwardThreshold) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
-    }
-    byteRangeLo = pFlac->firstFLACFramePosInBytes;
-    byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-    return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
-}
-#endif
-static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint32 iClosestSeekpoint = 0;
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    drflac_uint32 iSeekpoint;
-    DRFLAC_ASSERT(pFlac != NULL);
-    if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
-        return DRFLAC_FALSE;
-    }
-    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-        if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
-            break;
-        }
-        iClosestSeekpoint = iSeekpoint;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
-        return DRFLAC_FALSE;
-    }
-#if !defined(DR_FLAC_NO_CRC)
-    if (pFlac->totalPCMFrameCount > 0) {
-        drflac_uint64 byteRangeLo;
-        drflac_uint64 byteRangeHi;
-        byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-        byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
-        if (iClosestSeekpoint < pFlac->seekpointCount-1) {
-            drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
-            if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
-                return DRFLAC_FALSE;
-            }
-            if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) {
-                byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1;
-            }
-        }
-        if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-                if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
-                    return DRFLAC_TRUE;
-                }
-            }
-        }
-    }
-#endif
-    if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
-        if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-    next_iteration:
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-#ifndef DR_FLAC_NO_OGG
-typedef struct
-{
-    drflac_uint8 capturePattern[4];
-    drflac_uint8 structureVersion;
-    drflac_uint8 headerType;
-    drflac_uint64 granulePosition;
-    drflac_uint32 serialNumber;
-    drflac_uint32 sequenceNumber;
-    drflac_uint32 checksum;
-    drflac_uint8 segmentCount;
-    drflac_uint8 segmentTable[255];
-} drflac_ogg_page_header;
-#endif
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    drflac_meta_proc onMeta;
-    drflac_container container;
-    void* pUserData;
-    void* pUserDataMD;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 runningFilePos;
-    drflac_bool32 hasStreamInfoBlock;
-    drflac_bool32 hasMetadataBlocks;
-    drflac_bs bs;
-    drflac_frame_header firstFrameHeader;
-#ifndef DR_FLAC_NO_OGG
-    drflac_uint32 oggSerial;
-    drflac_uint64 oggFirstBytePos;
-    drflac_ogg_page_header oggBosHeader;
-#endif
-} drflac_init_info;
-static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    blockHeader = drflac__be2host_32(blockHeader);
-    *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
-    *blockType   = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
-    *blockSize   =                (blockHeader & 0x00FFFFFFUL);
-}
-static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    drflac_uint32 blockHeader;
-    *blockSize = 0;
-    if (onRead(pUserData, &blockHeader, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-    drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
-{
-    drflac_uint32 blockSizes;
-    drflac_uint64 frameSizes = 0;
-    drflac_uint64 importantProps;
-    drflac_uint8 md5[16];
-    if (onRead(pUserData, &blockSizes, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, &frameSizes, 6) != 6) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, &importantProps, 8) != 8) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
-        return DRFLAC_FALSE;
-    }
-    blockSizes     = drflac__be2host_32(blockSizes);
-    frameSizes     = drflac__be2host_64(frameSizes);
-    importantProps = drflac__be2host_64(importantProps);
-    pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
-    pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
-    pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
-    pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) <<  0)) >> 16);
-    pStreamInfo->sampleRate              = (drflac_uint32)((importantProps &  (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
-    pStreamInfo->channels                = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
-    pStreamInfo->bitsPerSample           = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
-    pStreamInfo->totalPCMFrameCount      =                ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
-    DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
-    return DRFLAC_TRUE;
-}
-static void* drflac__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_MALLOC(sz);
-}
-static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_REALLOC(p, sz);
-}
-static void drflac__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRFLAC_FREE(p);
-}
-static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRFLAC_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_uint64 runningFilePos = 42;
-    drflac_uint64 seektablePos   = 0;
-    drflac_uint32 seektableSize  = 0;
-    for (;;) {
-        drflac_metadata metadata;
-        drflac_uint8 isLastBlock = 0;
-        drflac_uint8 blockType;
-        drflac_uint32 blockSize;
-        if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-        runningFilePos += 4;
-        metadata.type = blockType;
-        metadata.pRawData = NULL;
-        metadata.rawDataSize = 0;
-        switch (blockType)
-        {
-            case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
-            {
-                if (blockSize < 4) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.application.id       = drflac__be2host_32(*(drflac_uint32*)pRawData);
-                    metadata.data.application.pData    = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
-                    metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
-            {
-                seektablePos  = runningFilePos;
-                seektableSize = blockSize;
-                if (onMeta) {
-                    drflac_uint32 iSeekpoint;
-                    void* pRawData;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
-                    metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-                    for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
-                        drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
-                        pSeekpoint->firstPCMFrame   = drflac__be2host_64(pSeekpoint->firstPCMFrame);
-                        pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
-                        pSeekpoint->pcmFrameCount   = drflac__be2host_16(pSeekpoint->pcmFrameCount);
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
-            {
-                if (blockSize < 8) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint32 i;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.vendor       = pRunningData;                                            pRunningData += metadata.data.vorbis_comment.vendorLength;
-                    metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.pComments    = pRunningData;
-                    for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
-                        drflac_uint32 commentLength;
-                        if (pRunningDataEnd - pRunningData < 4) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += commentLength;
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
-            {
-                if (blockSize < 396) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint8 iTrack;
-                    drflac_uint8 iIndex;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128);                              pRunningData += 128;
-                    metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
-                    metadata.data.cuesheet.isCD              = (pRunningData[0] & 0x80) != 0;                           pRunningData += 259;
-                    metadata.data.cuesheet.trackCount        = pRunningData[0];                                         pRunningData += 1;
-                    metadata.data.cuesheet.pTrackData        = pRunningData;
-                    for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
-                        drflac_uint8 indexCount;
-                        drflac_uint32 indexPointSize;
-                        if (pRunningDataEnd - pRunningData < 36) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += 35;
-                        indexCount = pRunningData[0]; pRunningData += 1;
-                        indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        for (iIndex = 0; iIndex < indexCount; ++iIndex) {
-                            drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
-                            pRunningData += sizeof(drflac_cuesheet_track_index);
-                            pTrack->offset = drflac__be2host_64(pTrack->offset);
-                        }
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
-            {
-                if (blockSize < 32) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    metadata.data.picture.type       = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.mime              = pRunningData;                                            pRunningData += metadata.data.picture.mimeLength;
-                    metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.description     = pRunningData;                                            pRunningData += metadata.data.picture.descriptionLength;
-                    metadata.data.picture.width           = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.height          = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.colorDepth      = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pPictureData    = (const drflac_uint8*)pRunningData;
-                    if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
-            {
-                if (onMeta) {
-                    metadata.data.padding.unused = 0;
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;
-                    } else {
-                        onMeta(pUserDataMD, &metadata);
-                    }
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
-            {
-                if (onMeta) {
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;
-                    }
-                }
-            } break;
-            default:
-            {
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-        }
-        if (onMeta == NULL && blockSize > 0) {
-            if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                isLastBlock = DRFLAC_TRUE;
-            }
-        }
-        runningFilePos += blockSize;
-        if (isLastBlock) {
-            break;
-        }
-    }
-    *pSeektablePos = seektablePos;
-    *pSeektableSize = seektableSize;
-    *pFirstFramePos = runningFilePos;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_uint8 isLastBlock;
-    drflac_uint8 blockType;
-    drflac_uint32 blockSize;
-    (void)onSeek;
-    pInit->container = drflac_container_native;
-    if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-        return DRFLAC_FALSE;
-    }
-    if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-        if (!relaxed) {
-            return DRFLAC_FALSE;
-        } else {
-            pInit->hasStreamInfoBlock = DRFLAC_FALSE;
-            pInit->hasMetadataBlocks  = DRFLAC_FALSE;
-            if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
-                return DRFLAC_FALSE;
-            }
-            if (pInit->firstFrameHeader.bitsPerSample == 0) {
-                return DRFLAC_FALSE;
-            }
-            pInit->sampleRate              = pInit->firstFrameHeader.sampleRate;
-            pInit->channels                = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
-            pInit->bitsPerSample           = pInit->firstFrameHeader.bitsPerSample;
-            pInit->maxBlockSizeInPCMFrames = 65535;
-            return DRFLAC_TRUE;
-        }
-    } else {
-        drflac_streaminfo streaminfo;
-        if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-            return DRFLAC_FALSE;
-        }
-        pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-        pInit->sampleRate              = streaminfo.sampleRate;
-        pInit->channels                = streaminfo.channels;
-        pInit->bitsPerSample           = streaminfo.bitsPerSample;
-        pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-        pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-        pInit->hasMetadataBlocks       = !isLastBlock;
-        if (onMeta) {
-            drflac_metadata metadata;
-            metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-            metadata.pRawData = NULL;
-            metadata.rawDataSize = 0;
-            metadata.data.streaminfo = streaminfo;
-            onMeta(pUserDataMD, &metadata);
-        }
-        return DRFLAC_TRUE;
-    }
-}
-#ifndef DR_FLAC_NO_OGG
-#define DRFLAC_OGG_MAX_PAGE_SIZE            65307
-#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32    1605413199
-typedef enum
-{
-    drflac_ogg_recover_on_crc_mismatch,
-    drflac_ogg_fail_on_crc_mismatch
-} drflac_ogg_crc_mismatch_recovery;
-#ifndef DR_FLAC_NO_CRC
-static drflac_uint32 drflac__crc32_table[] = {
-    0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
-    0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
-    0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
-    0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
-    0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
-    0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
-    0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
-    0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
-    0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
-    0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
-    0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
-    0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
-    0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
-    0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
-    0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
-    0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
-    0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
-    0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
-    0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
-    0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
-    0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
-    0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
-    0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
-    0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
-    0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
-    0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
-    0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
-    0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
-    0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
-    0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
-    0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
-    0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
-    0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
-    0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
-    0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
-    0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
-    0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
-    0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
-    0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
-    0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
-    0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
-    0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
-    0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
-    0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
-    0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
-    0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
-    0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
-    0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
-    0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
-    0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
-    0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
-    0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
-    0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
-    0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
-    0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
-    0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
-    0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
-    0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
-    0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
-    0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
-    0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
-    0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
-    0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
-    0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
-};
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
-{
-#ifndef DR_FLAC_NO_CRC
-    return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
-#else
-    (void)data;
-    return crc32;
-#endif
-}
-#if 0
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
-{
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  8) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc32;
-}
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
-{
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >>  0) & 0xFFFFFFFF));
-    return crc32;
-}
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
-{
-    drflac_uint32 i;
-    for (i = 0; i < dataSize; ++i) {
-        crc32 = drflac_crc32_byte(crc32, pData[i]);
-    }
-    return crc32;
-}
-static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
-{
-    return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
-}
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
-{
-    return 27 + pHeader->segmentCount;
-}
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
-{
-    drflac_uint32 pageBodySize = 0;
-    int i;
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        pageBodySize += pHeader->segmentTable[i];
-    }
-    return pageBodySize;
-}
-static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 data[23];
-    drflac_uint32 i;
-    DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
-    if (onRead(pUserData, data, 23) != 23) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 23;
-    pHeader->capturePattern[0] = 'O';
-    pHeader->capturePattern[1] = 'g';
-    pHeader->capturePattern[2] = 'g';
-    pHeader->capturePattern[3] = 'S';
-    pHeader->structureVersion = data[0];
-    pHeader->headerType       = data[1];
-    DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
-    DRFLAC_COPY_MEMORY(&pHeader->serialNumber,    &data[10], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber,  &data[14], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->checksum,        &data[18], 4);
-    pHeader->segmentCount     = data[22];
-    data[18] = 0;
-    data[19] = 0;
-    data[20] = 0;
-    data[21] = 0;
-    for (i = 0; i < 23; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
-    }
-    if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += pHeader->segmentCount;
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
-    }
-    return DRFLAC_SUCCESS;
-}
-static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 id[4];
-    *pBytesRead = 0;
-    if (onRead(pUserData, id, 4) != 4) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 4;
-    for (;;) {
-        if (drflac_ogg__is_capture_pattern(id)) {
-            drflac_result result;
-            *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-            result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
-            if (result == DRFLAC_SUCCESS) {
-                return DRFLAC_SUCCESS;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return result;
-                }
-            }
-        } else {
-            id[0] = id[1];
-            id[1] = id[2];
-            id[2] = id[3];
-            if (onRead(pUserData, &id[3], 1) != 1) {
-                return DRFLAC_AT_END;
-            }
-            *pBytesRead += 1;
-        }
-    }
-}
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    void* pUserData;
-    drflac_uint64 currentBytePos;
-    drflac_uint64 firstBytePos;
-    drflac_uint32 serialNumber;
-    drflac_ogg_page_header bosPageHeader;
-    drflac_ogg_page_header currentPageHeader;
-    drflac_uint32 bytesRemainingInPage;
-    drflac_uint32 pageDataSize;
-    drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
-} drflac_oggbs;
-static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
-{
-    size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
-    oggbs->currentBytePos += bytesActuallyRead;
-    return bytesActuallyRead;
-}
-static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
-{
-    if (origin == drflac_seek_origin_start) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-            return DRFLAC_TRUE;
-        } else {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-            return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
-        }
-    } else {
-        while (offset > 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos += 0x7FFFFFFF;
-            offset -= 0x7FFFFFFF;
-        }
-        if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += offset;
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
-{
-    drflac_ogg_page_header header;
-    for (;;) {
-        drflac_uint32 crc32 = 0;
-        drflac_uint32 bytesRead;
-        drflac_uint32 pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        drflac_uint32 actualCRC32;
-#endif
-        if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += bytesRead;
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
-            continue;
-        }
-        if (header.serialNumber != oggbs->serialNumber) {
-            if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            continue;
-        }
-        if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->pageDataSize = pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
-        if (actualCRC32 != header.checksum) {
-            if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
-                continue;
-            } else {
-                drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
-                return DRFLAC_FALSE;
-            }
-        }
-#else
-        (void)recoveryMethod;
-#endif
-        oggbs->currentPageHeader = header;
-        oggbs->bytesRemainingInPage = pageBodySize;
-        return DRFLAC_TRUE;
-    }
-}
-#if 0
-static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
-{
-    drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
-    drflac_uint8 iSeg = 0;
-    drflac_uint32 iByte = 0;
-    while (iByte < bytesConsumedInPage) {
-        drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-        if (iByte + segmentSize > bytesConsumedInPage) {
-            break;
-        } else {
-            iSeg += 1;
-            iByte += segmentSize;
-        }
-    }
-    *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
-    return iSeg;
-}
-static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
-{
-    for (;;) {
-        drflac_bool32 atEndOfPage = DRFLAC_FALSE;
-        drflac_uint8 bytesRemainingInSeg;
-        drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
-        drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
-        for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
-            drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-            if (segmentSize < 255) {
-                if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
-                    atEndOfPage = DRFLAC_TRUE;
-                }
-                break;
-            }
-            bytesToEndOfPacketOrPage += segmentSize;
-        }
-        drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
-        oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
-        if (atEndOfPage) {
-            if (!drflac_oggbs__goto_next_page(oggbs)) {
-                return DRFLAC_FALSE;
-            }
-            if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-                return DRFLAC_TRUE;
-            }
-        } else {
-            return DRFLAC_TRUE;
-        }
-    }
-}
-static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
-{
-    return drflac_oggbs__seek_to_next_packet(oggbs);
-}
-#endif
-static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
-    size_t bytesRead = 0;
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(pRunningBufferOut != NULL);
-    while (bytesRead < bytesToRead) {
-        size_t bytesRemainingToRead = bytesToRead - bytesRead;
-        if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
-            bytesRead += bytesRemainingToRead;
-            oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
-            break;
-        }
-        if (oggbs->bytesRemainingInPage > 0) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
-            bytesRead += oggbs->bytesRemainingInPage;
-            pRunningBufferOut += oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-        DRFLAC_ASSERT(bytesRemainingToRead > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            break;
-        }
-    }
-    return bytesRead;
-}
-static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    int bytesSeeked = 0;
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(offset >= 0);
-    if (origin == drflac_seek_origin_start) {
-        if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-        return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
-    }
-    DRFLAC_ASSERT(origin == drflac_seek_origin_current);
-    while (bytesSeeked < offset) {
-        int bytesRemainingToSeek = offset - bytesSeeked;
-        DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
-        if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
-            bytesSeeked += bytesRemainingToSeek;
-            (void)bytesSeeked;
-            oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
-            break;
-        }
-        if (oggbs->bytesRemainingInPage > 0) {
-            bytesSeeked += (int)oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-        DRFLAC_ASSERT(bytesRemainingToSeek > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-    drflac_uint64 originalBytePos;
-    drflac_uint64 runningGranulePosition;
-    drflac_uint64 runningFrameBytePos;
-    drflac_uint64 runningPCMFrameCount;
-    DRFLAC_ASSERT(oggbs != NULL);
-    originalBytePos = oggbs->currentBytePos;
-    if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
-        return DRFLAC_FALSE;
-    }
-    oggbs->bytesRemainingInPage = 0;
-    runningGranulePosition = 0;
-    for (;;) {
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
-            return DRFLAC_FALSE;
-        }
-        runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
-        if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
-            break;
-        }
-        if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-            if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
-                drflac_uint8 firstBytesInPage[2];
-                firstBytesInPage[0] = oggbs->pageData[0];
-                firstBytesInPage[1] = oggbs->pageData[1];
-                if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) {
-                    runningGranulePosition = oggbs->currentPageHeader.granulePosition;
-                }
-                continue;
-            }
-        }
-    }
-    if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-        return DRFLAC_FALSE;
-    }
-    runningPCMFrameCount = runningGranulePosition;
-    for (;;) {
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac_uint64 pcmFrameCountInThisFrame;
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                return DRFLAC_TRUE;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount);
-                if (pcmFramesToDecode == 0) {
-                    return DRFLAC_TRUE;
-                }
-                pFlac->currentPCMFrame = runningPCMFrameCount;
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                runningPCMFrameCount += pcmFrameCountInThisFrame;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_ogg_page_header header;
-    drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-    drflac_uint32 bytesRead = 0;
-    (void)relaxed;
-    pInit->container = drflac_container_ogg;
-    pInit->oggFirstBytePos = 0;
-    if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-        return DRFLAC_FALSE;
-    }
-    pInit->runningFilePos += bytesRead;
-    for (;;) {
-        int pageBodySize;
-        if ((header.headerType & 0x02) == 0) {
-            return DRFLAC_FALSE;
-        }
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize == 51) {
-            drflac_uint32 bytesRemainingInPage = pageBodySize;
-            drflac_uint8 packetType;
-            if (onRead(pUserData, &packetType, 1) != 1) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemainingInPage -= 1;
-            if (packetType == 0x7F) {
-                drflac_uint8 sig[4];
-                if (onRead(pUserData, sig, 4) != 4) {
-                    return DRFLAC_FALSE;
-                }
-                bytesRemainingInPage -= 4;
-                if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
-                    drflac_uint8 mappingVersion[2];
-                    if (onRead(pUserData, mappingVersion, 2) != 2) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (mappingVersion[0] != 1) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, sig, 4) != 4) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
-                        drflac_streaminfo streaminfo;
-                        drflac_uint8 isLastBlock;
-                        drflac_uint8 blockType;
-                        drflac_uint32 blockSize;
-                        if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-                            return DRFLAC_FALSE;
-                        }
-                        if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-                            return DRFLAC_FALSE;
-                        }
-                        if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-                            pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-                            pInit->sampleRate              = streaminfo.sampleRate;
-                            pInit->channels                = streaminfo.channels;
-                            pInit->bitsPerSample           = streaminfo.bitsPerSample;
-                            pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-                            pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-                            pInit->hasMetadataBlocks       = !isLastBlock;
-                            if (onMeta) {
-                                drflac_metadata metadata;
-                                metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-                                metadata.pRawData = NULL;
-                                metadata.rawDataSize = 0;
-                                metadata.data.streaminfo = streaminfo;
-                                onMeta(pUserDataMD, &metadata);
-                            }
-                            pInit->runningFilePos  += pageBodySize;
-                            pInit->oggFirstBytePos  = pInit->runningFilePos - 79;
-                            pInit->oggSerial        = header.serialNumber;
-                            pInit->oggBosHeader     = header;
-                            break;
-                        } else {
-                            return DRFLAC_FALSE;
-                        }
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                } else {
-                    if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        pInit->runningFilePos += pageBodySize;
-        if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += bytesRead;
-    }
-    pInit->hasMetadataBlocks = DRFLAC_TRUE;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
-{
-    drflac_bool32 relaxed;
-    drflac_uint8 id[4];
-    if (pInit == NULL || onRead == NULL || onSeek == NULL) {
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
-    pInit->onRead       = onRead;
-    pInit->onSeek       = onSeek;
-    pInit->onMeta       = onMeta;
-    pInit->container    = container;
-    pInit->pUserData    = pUserData;
-    pInit->pUserDataMD  = pUserDataMD;
-    pInit->bs.onRead    = onRead;
-    pInit->bs.onSeek    = onSeek;
-    pInit->bs.pUserData = pUserData;
-    drflac__reset_cache(&pInit->bs);
-    relaxed = container != drflac_container_unknown;
-    for (;;) {
-        if (onRead(pUserData, id, 4) != 4) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += 4;
-        if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
-            drflac_uint8 header[6];
-            drflac_uint8 flags;
-            drflac_uint32 headerSize;
-            if (onRead(pUserData, header, 6) != 6) {
-                return DRFLAC_FALSE;
-            }
-            pInit->runningFilePos += 6;
-            flags = header[1];
-            DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
-            headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
-            if (flags & 0x10) {
-                headerSize += 10;
-            }
-            if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            pInit->runningFilePos += headerSize;
-        } else {
-            break;
-        }
-    }
-    if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
-        return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
-        return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#endif
-    if (relaxed) {
-        if (container == drflac_container_native) {
-            return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (container == drflac_container_ogg) {
-            return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#endif
-    }
-    return DRFLAC_FALSE;
-}
-static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pInit != NULL);
-    DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
-    pFlac->bs                      = pInit->bs;
-    pFlac->onMeta                  = pInit->onMeta;
-    pFlac->pUserDataMD             = pInit->pUserDataMD;
-    pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
-    pFlac->sampleRate              = pInit->sampleRate;
-    pFlac->channels                = (drflac_uint8)pInit->channels;
-    pFlac->bitsPerSample           = (drflac_uint8)pInit->bitsPerSample;
-    pFlac->totalPCMFrameCount      = pInit->totalPCMFrameCount;
-    pFlac->container               = pInit->container;
-}
-static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_init_info init;
-    drflac_uint32 allocationSize;
-    drflac_uint32 wholeSIMDVectorCountPerChannel;
-    drflac_uint32 decodedSamplesAllocationSize;
-#ifndef DR_FLAC_NO_OGG
-    drflac_oggbs oggbs;
-#endif
-    drflac_uint64 firstFramePos;
-    drflac_uint64 seektablePos;
-    drflac_uint32 seektableSize;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac* pFlac;
-    drflac__init_cpu_caps();
-    if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
-        return NULL;
-    }
-    if (pAllocationCallbacks != NULL) {
-        allocationCallbacks = *pAllocationCallbacks;
-        if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
-            return NULL;
-        }
-    } else {
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drflac__malloc_default;
-        allocationCallbacks.onRealloc = drflac__realloc_default;
-        allocationCallbacks.onFree    = drflac__free_default;
-    }
-    allocationSize = sizeof(drflac);
-    if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
-    } else {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
-    }
-    decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
-    allocationSize += decodedSamplesAllocationSize;
-    allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE;
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        allocationSize += sizeof(drflac_oggbs);
-    }
-    DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
-    if (init.container == drflac_container_ogg) {
-        oggbs.onRead = onRead;
-        oggbs.onSeek = onSeek;
-        oggbs.pUserData = pUserData;
-        oggbs.currentBytePos = init.oggFirstBytePos;
-        oggbs.firstBytePos = init.oggFirstBytePos;
-        oggbs.serialNumber = init.oggSerial;
-        oggbs.bosPageHeader = init.oggBosHeader;
-        oggbs.bytesRemainingInPage = 0;
-    }
-#endif
-    firstFramePos = 42;
-    seektablePos  = 0;
-    seektableSize = 0;
-    if (init.hasMetadataBlocks) {
-        drflac_read_proc onReadOverride = onRead;
-        drflac_seek_proc onSeekOverride = onSeek;
-        void* pUserDataOverride = pUserData;
-#ifndef DR_FLAC_NO_OGG
-        if (init.container == drflac_container_ogg) {
-            onReadOverride = drflac__on_read_ogg;
-            onSeekOverride = drflac__on_seek_ogg;
-            pUserDataOverride = (void*)&oggbs;
-        }
-#endif
-        if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
-            return NULL;
-        }
-        allocationSize += seektableSize;
-    }
-    pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    drflac__init_from_info(pFlac, &init);
-    pFlac->allocationCallbacks = allocationCallbacks;
-    pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
-        *pInternalOggbs = oggbs;
-        pFlac->bs.onRead = drflac__on_read_ogg;
-        pFlac->bs.onSeek = drflac__on_seek_ogg;
-        pFlac->bs.pUserData = (void*)pInternalOggbs;
-        pFlac->_oggbs = (void*)pInternalOggbs;
-    }
-#endif
-    pFlac->firstFLACFramePosInBytes = firstFramePos;
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg)
-    {
-        pFlac->pSeekpoints = NULL;
-        pFlac->seekpointCount = 0;
-    }
-    else
-#endif
-    {
-        if (seektablePos != 0) {
-            pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
-            pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
-            DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
-            DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
-            if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
-                if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
-                    drflac_uint32 iSeekpoint;
-                    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-                        pFlac->pSeekpoints[iSeekpoint].firstPCMFrame   = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
-                        pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
-                        pFlac->pSeekpoints[iSeekpoint].pcmFrameCount   = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
-                    }
-                } else {
-                    pFlac->pSeekpoints = NULL;
-                    pFlac->seekpointCount = 0;
-                }
-                if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            } else {
-                pFlac->pSeekpoints = NULL;
-                pFlac->seekpointCount = 0;
-            }
-        }
-    }
-    if (!init.hasStreamInfoBlock) {
-        pFlac->currentFLACFrame.header = init.firstFrameHeader;
-        for (;;) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                break;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                        drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                        return NULL;
-                    }
-                    continue;
-                } else {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            }
-        }
-    }
-    return pFlac;
-}
-#ifndef DR_FLAC_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#include <errno.h>
-static drflac_result drflac_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRFLAC_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRFLAC_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRFLAC_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRFLAC_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRFLAC_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRFLAC_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRFLAC_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRFLAC_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRFLAC_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRFLAC_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRFLAC_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRFLAC_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRFLAC_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRFLAC_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRFLAC_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRFLAC_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRFLAC_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRFLAC_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRFLAC_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRFLAC_ERROR;
-    #endif
-        default: return DRFLAC_ERROR;
-    }
-}
-static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drflac_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drflac_result result = drflac_result_from_errno(errno);
-        if (result == DRFLAC_SUCCESS) {
-            result = DRFLAC_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRFLAC_HAS_WFOPEN
-    #endif
-#endif
-static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-#if defined(DRFLAC_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drflac_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drflac_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRFLAC_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drflac_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRFLAC_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRFLAC_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRFLAC_ERROR;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    DRFLAC_ASSERT(offset >= 0);
-    return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-    return pFlac;
-}
-#endif
-static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    size_t bytesRemaining;
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
-    bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
-        memoryStream->currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(offset >= 0);
-    if (offset > (drflac_int64)memoryStream->dataSize) {
-        return DRFLAC_FALSE;
-    }
-    if (origin == drflac_seek_origin_current) {
-        if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos += offset;
-        } else {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        if ((drflac_uint32)offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos = offset;
-        } else {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    pFlac->memoryStream = memoryStream;
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    pFlac->memoryStream = memoryStream;
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API void drflac_close(drflac* pFlac)
-{
-    if (pFlac == NULL) {
-        return;
-    }
-#ifndef DR_FLAC_NO_STDIO
-    if (pFlac->bs.onRead == drflac__on_read_stdio) {
-        fclose((FILE*)pFlac->bs.pUserData);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg) {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
-        if (oggbs->onRead == drflac__on_read_stdio) {
-            fclose((FILE*)oggbs->pUserData);
-        }
-    }
-#endif
-#endif
-    drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    int32x4_t  wbpsShift0_4;
-    int32x4_t  wbpsShift1_4;
-    uint32x4_t one4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    one4         = vdupq_n_u32(1);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        int32x4_t shift4;
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift4_0 = vdupq_n_s32(shift0);
-    int32x4_t shift4_1 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
-        drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = ((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = ((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = ((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = ((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = ((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = ((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = ((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = ((drflac_int32)(mid3 - side3) >> 1);
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    int32x4_t wbpsShift0_4;
-    int32x4_t wbpsShift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        int32x4_t shift4;
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        tempL0 >>= 16;
-        tempL1 >>= 16;
-        tempL2 >>= 16;
-        tempL3 >>= 16;
-        tempR0 >>= 16;
-        tempR1 >>= 16;
-        tempR2 >>= 16;
-        tempR3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int16)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int16)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int16)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int16)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int16)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int16)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int16)tempR3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4 = vdupq_n_s32(shift0);
-    int32x4_t shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-        left  = vshrq_n_s32(left,  16);
-        right = vshrq_n_s32(right, 16);
-        drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        left   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right  = vsubq_u32(left, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        side   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left   = vaddq_u32(right, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    __m128 factor128;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = 1.0f / 8388608.0f;
-    factor128 = _mm_set1_ps(factor);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128  leftf;
-            __m128  rightf;
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            tempL  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            tempR  = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128 leftf;
-            __m128 rightf;
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            tempL  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            tempR  = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    float32x4_t factor4;
-    int32x4_t shift4;
-    int32x4_t wbps0_4;
-    int32x4_t wbps1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor  = 1.0f / 8388608.0f;
-    factor4 = vdupq_n_f32(factor);
-    wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-            uint32x4_t mid  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            lefti  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-            mid    = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            lefti  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float factor = 1.0f / 8388608.0f;
-    __m128 factor128 = _mm_set1_ps(factor);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i lefti;
-        __m128i righti;
-        __m128 leftf;
-        __m128 rightf;
-        lefti  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        leftf  = _mm_mul_ps(_mm_cvtepi32_ps(lefti),  factor128);
-        rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float factor = 1.0f / 8388608.0f;
-    float32x4_t factor4 = vdupq_n_f32(factor);
-    int32x4_t shift0_4  = vdupq_n_s32(shift0);
-    int32x4_t shift1_4  = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t lefti;
-        int32x4_t righti;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        lefti  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-        leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    if (pFlac == NULL) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->currentPCMFrame == pcmFrameIndex) {
-        return DRFLAC_TRUE;
-    }
-    if (pFlac->firstFLACFramePosInBytes == 0) {
-        return DRFLAC_FALSE;
-    }
-    if (pcmFrameIndex == 0) {
-        pFlac->currentPCMFrame = 0;
-        return drflac__seek_to_first_frame(pFlac);
-    } else {
-        drflac_bool32 wasSuccessful = DRFLAC_FALSE;
-        drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
-        if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
-            pcmFrameIndex = pFlac->totalPCMFrameCount;
-        }
-        if (pcmFrameIndex > pFlac->currentPCMFrame) {
-            drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
-            if (pFlac->currentFLACFrame.pcmFramesRemaining >  offset) {
-                pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        } else {
-            drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
-            drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-            drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
-            if (currentFLACFramePCMFramesConsumed > offsetAbs) {
-                pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (pFlac->container == drflac_container_ogg)
-        {
-            wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
-        }
-        else
-#endif
-        {
-            if (!pFlac->_noSeekTableSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
-            }
-#if !defined(DR_FLAC_NO_CRC)
-            if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
-                wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
-            }
-#endif
-            if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
-            }
-        }
-        if (wasSuccessful) {
-            pFlac->currentPCMFrame = pcmFrameIndex;
-        } else {
-            if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
-                drflac_seek_to_pcm_frame(pFlac, 0);
-            }
-        }
-        return wasSuccessful;
-    }
-}
-#if defined(SIZE_MAX)
-    #define DRFLAC_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(DRFLAC_64BIT)
-        #define DRFLAC_SIZE_MAX  ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRFLAC_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
-static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
-{                                                                                                                                                                   \
-    type* pSampleData = NULL;                                                                                                                                       \
-    drflac_uint64 totalPCMFrameCount;                                                                                                                               \
-                                                                                                                                                                    \
-    DRFLAC_ASSERT(pFlac != NULL);                                                                                                                                   \
-                                                                                                                                                                    \
-    totalPCMFrameCount = pFlac->totalPCMFrameCount;                                                                                                                 \
-                                                                                                                                                                    \
-    if (totalPCMFrameCount == 0) {                                                                                                                                  \
-        type buffer[4096];                                                                                                                                          \
-        drflac_uint64 pcmFramesRead;                                                                                                                                \
-        size_t sampleDataBufferSize = sizeof(buffer);                                                                                                               \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks);                                                      \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) {          \
-            if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) {                                                   \
-                type* pNewSampleData;                                                                                                                               \
-                size_t newSampleDataBufferSize;                                                                                                                     \
-                                                                                                                                                                    \
-                newSampleDataBufferSize = sampleDataBufferSize * 2;                                                                                                 \
-                pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks);    \
-                if (pNewSampleData == NULL) {                                                                                                                       \
-                    drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks);                                                                          \
-                    goto on_error;                                                                                                                                  \
-                }                                                                                                                                                   \
-                                                                                                                                                                    \
-                sampleDataBufferSize = newSampleDataBufferSize;                                                                                                     \
-                pSampleData = pNewSampleData;                                                                                                                       \
-            }                                                                                                                                                       \
-                                                                                                                                                                    \
-            DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type)));                   \
-            totalPCMFrameCount += pcmFramesRead;                                                                                                                    \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-                                                                                                                         \
-        DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type)));   \
-    } else {                                                                                                                                                        \
-        drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type);                                                                                   \
-        if (dataSize > DRFLAC_SIZE_MAX) {                                                                                                                           \
-            goto on_error;                                                                                                        \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks);               \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData);                                                     \
-    }                                                                                                                                                               \
-                                                                                                                                                                    \
-    if (sampleRateOut) *sampleRateOut = pFlac->sampleRate;                                                                                                          \
-    if (channelsOut) *channelsOut = pFlac->channels;                                                                                                                \
-    if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount;                                                                                         \
-                                                                                                                                                                    \
-    drflac_close(pFlac);                                                                                                                                            \
-    return pSampleData;                                                                                                                                             \
-                                                                                                                                                                    \
-on_error:                                                                                                                                                           \
-    drflac_close(pFlac);                                                                                                                                            \
-    return NULL;                                                                                                                                                    \
-}
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-#endif
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drflac__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drflac__free_default(p, NULL);
-    }
-}
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
-{
-    if (pIter == NULL) {
-        return;
-    }
-    pIter->countRemaining = commentCount;
-    pIter->pRunningData   = (const char*)pComments;
-}
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
-{
-    drflac_int32 length;
-    const char* pComment;
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = 0;
-    }
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return NULL;
-    }
-    length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
-    pIter->pRunningData += 4;
-    pComment = pIter->pRunningData;
-    pIter->pRunningData += length;
-    pIter->countRemaining -= 1;
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = length;
-    }
-    return pComment;
-}
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
-{
-    if (pIter == NULL) {
-        return;
-    }
-    pIter->countRemaining = trackCount;
-    pIter->pRunningData   = (const char*)pTrackData;
-}
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
-{
-    drflac_cuesheet_track cuesheetTrack;
-    const char* pRunningData;
-    drflac_uint64 offsetHi;
-    drflac_uint64 offsetLo;
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return DRFLAC_FALSE;
-    }
-    pRunningData = pIter->pRunningData;
-    offsetHi                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    offsetLo                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    cuesheetTrack.offset       = offsetLo | (offsetHi << 32);
-    cuesheetTrack.trackNumber  = pRunningData[0];                                         pRunningData += 1;
-    DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC));     pRunningData += 12;
-    cuesheetTrack.isAudio      = (pRunningData[0] & 0x80) != 0;
-    cuesheetTrack.preEmphasis  = (pRunningData[0] & 0x40) != 0;                           pRunningData += 14;
-    cuesheetTrack.indexCount   = pRunningData[0];                                         pRunningData += 1;
-    cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData;        pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
-    pIter->pRunningData = pRunningData;
-    pIter->countRemaining -= 1;
-    if (pCuesheetTrack) {
-        *pCuesheetTrack = cuesheetTrack;
-    }
-    return DRFLAC_TRUE;
-}
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-#endif
-/* dr_flac_c end */
-#endif  /* DRFLAC_IMPLEMENTATION */
-#endif  /* MA_NO_FLAC */
-
-#if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING)
-#if !defined(DR_MP3_IMPLEMENTATION) && !defined(DRMP3_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_mp3_c begin */
-#ifndef dr_mp3_c
-#define dr_mp3_c
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRMP3_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRMP3_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRMP3_VERSION_REVISION;
-    }
-}
-DRMP3_API const char* drmp3_version_string(void)
-{
-    return DRMP3_VERSION_STRING;
-}
-#if defined(__TINYC__)
-#define DR_MP3_NO_SIMD
-#endif
-#define DRMP3_OFFSET_PTR(p, offset) ((void*)((drmp3_uint8*)(p) + (offset)))
-#define DRMP3_MAX_FREE_FORMAT_FRAME_SIZE  2304
-#ifndef DRMP3_MAX_FRAME_SYNC_MATCHES
-#define DRMP3_MAX_FRAME_SYNC_MATCHES      10
-#endif
-#define DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES  DRMP3_MAX_FREE_FORMAT_FRAME_SIZE
-#define DRMP3_MAX_BITRESERVOIR_BYTES      511
-#define DRMP3_SHORT_BLOCK_TYPE            2
-#define DRMP3_STOP_BLOCK_TYPE             3
-#define DRMP3_MODE_MONO                   3
-#define DRMP3_MODE_JOINT_STEREO           1
-#define DRMP3_HDR_SIZE                    4
-#define DRMP3_HDR_IS_MONO(h)              (((h[3]) & 0xC0) == 0xC0)
-#define DRMP3_HDR_IS_MS_STEREO(h)         (((h[3]) & 0xE0) == 0x60)
-#define DRMP3_HDR_IS_FREE_FORMAT(h)       (((h[2]) & 0xF0) == 0)
-#define DRMP3_HDR_IS_CRC(h)               (!((h[1]) & 1))
-#define DRMP3_HDR_TEST_PADDING(h)         ((h[2]) & 0x2)
-#define DRMP3_HDR_TEST_MPEG1(h)           ((h[1]) & 0x8)
-#define DRMP3_HDR_TEST_NOT_MPEG25(h)      ((h[1]) & 0x10)
-#define DRMP3_HDR_TEST_I_STEREO(h)        ((h[3]) & 0x10)
-#define DRMP3_HDR_TEST_MS_STEREO(h)       ((h[3]) & 0x20)
-#define DRMP3_HDR_GET_STEREO_MODE(h)      (((h[3]) >> 6) & 3)
-#define DRMP3_HDR_GET_STEREO_MODE_EXT(h)  (((h[3]) >> 4) & 3)
-#define DRMP3_HDR_GET_LAYER(h)            (((h[1]) >> 1) & 3)
-#define DRMP3_HDR_GET_BITRATE(h)          ((h[2]) >> 4)
-#define DRMP3_HDR_GET_SAMPLE_RATE(h)      (((h[2]) >> 2) & 3)
-#define DRMP3_HDR_GET_MY_SAMPLE_RATE(h)   (DRMP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3)
-#define DRMP3_HDR_IS_FRAME_576(h)         ((h[1] & 14) == 2)
-#define DRMP3_HDR_IS_LAYER_1(h)           ((h[1] & 6) == 6)
-#define DRMP3_BITS_DEQUANTIZER_OUT        -1
-#define DRMP3_MAX_SCF                     (255 + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210)
-#define DRMP3_MAX_SCFI                    ((DRMP3_MAX_SCF + 3) & ~3)
-#define DRMP3_MIN(a, b)           ((a) > (b) ? (b) : (a))
-#define DRMP3_MAX(a, b)           ((a) < (b) ? (b) : (a))
-#if !defined(DR_MP3_NO_SIMD)
-#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
-#define DR_MP3_ONLY_SIMD
-#endif
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
-#if defined(_MSC_VER)
-#include <intrin.h>
-#endif
-#include <emmintrin.h>
-#define DRMP3_HAVE_SSE 1
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE _mm_storeu_ps
-#define DRMP3_VLD _mm_loadu_ps
-#define DRMP3_VSET _mm_set1_ps
-#define DRMP3_VADD _mm_add_ps
-#define DRMP3_VSUB _mm_sub_ps
-#define DRMP3_VMUL _mm_mul_ps
-#define DRMP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMUL_S(x, s)  _mm_mul_ps(x, _mm_set1_ps(s))
-#define DRMP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3))
-typedef __m128 drmp3_f4;
-#if defined(_MSC_VER) || defined(DR_MP3_ONLY_SIMD)
-#define drmp3_cpuid __cpuid
-#else
-static __inline__ __attribute__((always_inline)) void drmp3_cpuid(int CPUInfo[], const int InfoType)
-{
-#if defined(__PIC__)
-    __asm__ __volatile__(
-#if defined(__x86_64__)
-        "push %%rbx\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-        "pop  %%rbx\n"
-#else
-        "xchgl %%ebx, %1\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-#endif
-        : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#else
-    __asm__ __volatile__(
-        "cpuid"
-        : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#endif
-}
-#endif
-static int drmp3_have_simd(void)
-{
-#ifdef DR_MP3_ONLY_SIMD
-    return 1;
-#else
-    static int g_have_simd;
-    int CPUInfo[4];
-#ifdef MINIMP3_TEST
-    static int g_counter;
-    if (g_counter++ > 100)
-        return 0;
-#endif
-    if (g_have_simd)
-        goto end;
-    drmp3_cpuid(CPUInfo, 0);
-    if (CPUInfo[0] > 0)
-    {
-        drmp3_cpuid(CPUInfo, 1);
-        g_have_simd = (CPUInfo[3] & (1 << 26)) + 1;
-        return g_have_simd - 1;
-    }
-end:
-    return g_have_simd - 1;
-#endif
-}
-#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
-#include <arm_neon.h>
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE vst1q_f32
-#define DRMP3_VLD vld1q_f32
-#define DRMP3_VSET vmovq_n_f32
-#define DRMP3_VADD vaddq_f32
-#define DRMP3_VSUB vsubq_f32
-#define DRMP3_VMUL vmulq_f32
-#define DRMP3_VMAC(a, x, y) vmlaq_f32(a, x, y)
-#define DRMP3_VMSB(a, x, y) vmlsq_f32(a, x, y)
-#define DRMP3_VMUL_S(x, s)  vmulq_f32(x, vmovq_n_f32(s))
-#define DRMP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x)))
-typedef float32x4_t drmp3_f4;
-static int drmp3_have_simd(void)
-{
-    return 1;
-}
-#else
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 0
-#ifdef DR_MP3_ONLY_SIMD
-#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
-#endif
-#endif
-#else
-#define DRMP3_HAVE_SIMD 0
-#endif
-#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64)
-#define DRMP3_HAVE_ARMV6 1
-static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_arm(int32_t a)
-{
-    drmp3_int32 x = 0;
-    __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
-    return x;
-}
-#else
-#define DRMP3_HAVE_ARMV6 0
-#endif
-typedef struct
-{
-    const drmp3_uint8 *buf;
-    int pos, limit;
-} drmp3_bs;
-typedef struct
-{
-    float scf[3*64];
-    drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64];
-} drmp3_L12_scale_info;
-typedef struct
-{
-    drmp3_uint8 tab_offset, code_tab_width, band_count;
-} drmp3_L12_subband_alloc;
-typedef struct
-{
-    const drmp3_uint8 *sfbtab;
-    drmp3_uint16 part_23_length, big_values, scalefac_compress;
-    drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb;
-    drmp3_uint8 table_select[3], region_count[3], subblock_gain[3];
-    drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi;
-} drmp3_L3_gr_info;
-typedef struct
-{
-    drmp3_bs bs;
-    drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES];
-    drmp3_L3_gr_info gr_info[4];
-    float grbuf[2][576], scf[40], syn[18 + 15][2*32];
-    drmp3_uint8 ist_pos[2][39];
-} drmp3dec_scratch;
-static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes)
-{
-    bs->buf   = data;
-    bs->pos   = 0;
-    bs->limit = bytes*8;
-}
-static drmp3_uint32 drmp3_bs_get_bits(drmp3_bs *bs, int n)
-{
-    drmp3_uint32 next, cache = 0, s = bs->pos & 7;
-    int shl = n + s;
-    const drmp3_uint8 *p = bs->buf + (bs->pos >> 3);
-    if ((bs->pos += n) > bs->limit)
-        return 0;
-    next = *p++ & (255 >> s);
-    while ((shl -= 8) > 0)
-    {
-        cache |= next << shl;
-        next = *p++;
-    }
-    return cache | (next >> -shl);
-}
-static int drmp3_hdr_valid(const drmp3_uint8 *h)
-{
-    return h[0] == 0xff &&
-        ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) &&
-        (DRMP3_HDR_GET_LAYER(h) != 0) &&
-        (DRMP3_HDR_GET_BITRATE(h) != 15) &&
-        (DRMP3_HDR_GET_SAMPLE_RATE(h) != 3);
-}
-static int drmp3_hdr_compare(const drmp3_uint8 *h1, const drmp3_uint8 *h2)
-{
-    return drmp3_hdr_valid(h2) &&
-        ((h1[1] ^ h2[1]) & 0xFE) == 0 &&
-        ((h1[2] ^ h2[2]) & 0x0C) == 0 &&
-        !(DRMP3_HDR_IS_FREE_FORMAT(h1) ^ DRMP3_HDR_IS_FREE_FORMAT(h2));
-}
-static unsigned drmp3_hdr_bitrate_kbps(const drmp3_uint8 *h)
-{
-    static const drmp3_uint8 halfrate[2][3][15] = {
-        { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } },
-        { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } },
-    };
-    return 2*halfrate[!!DRMP3_HDR_TEST_MPEG1(h)][DRMP3_HDR_GET_LAYER(h) - 1][DRMP3_HDR_GET_BITRATE(h)];
-}
-static unsigned drmp3_hdr_sample_rate_hz(const drmp3_uint8 *h)
-{
-    static const unsigned g_hz[3] = { 44100, 48000, 32000 };
-    return g_hz[DRMP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!DRMP3_HDR_TEST_MPEG1(h) >> (int)!DRMP3_HDR_TEST_NOT_MPEG25(h);
-}
-static unsigned drmp3_hdr_frame_samples(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)DRMP3_HDR_IS_FRAME_576(h));
-}
-static int drmp3_hdr_frame_bytes(const drmp3_uint8 *h, int free_format_size)
-{
-    int frame_bytes = drmp3_hdr_frame_samples(h)*drmp3_hdr_bitrate_kbps(h)*125/drmp3_hdr_sample_rate_hz(h);
-    if (DRMP3_HDR_IS_LAYER_1(h))
-    {
-        frame_bytes &= ~3;
-    }
-    return frame_bytes ? frame_bytes : free_format_size;
-}
-static int drmp3_hdr_padding(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_TEST_PADDING(h) ? (DRMP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0;
-}
-#ifndef DR_MP3_ONLY_MP3
-static const drmp3_L12_subband_alloc *drmp3_L12_subband_alloc_table(const drmp3_uint8 *hdr, drmp3_L12_scale_info *sci)
-{
-    const drmp3_L12_subband_alloc *alloc;
-    int mode = DRMP3_HDR_GET_STEREO_MODE(hdr);
-    int nbands, stereo_bands = (mode == DRMP3_MODE_MONO) ? 0 : (mode == DRMP3_MODE_JOINT_STEREO) ? (DRMP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32;
-    if (DRMP3_HDR_IS_LAYER_1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } };
-        alloc = g_alloc_L1;
-        nbands = 32;
-    } else if (!DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } };
-        alloc = g_alloc_L2M2;
-        nbands = 30;
-    } else
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } };
-        int sample_rate_idx = DRMP3_HDR_GET_SAMPLE_RATE(hdr);
-        unsigned kbps = drmp3_hdr_bitrate_kbps(hdr) >> (int)(mode != DRMP3_MODE_MONO);
-        if (!kbps)
-        {
-            kbps = 192;
-        }
-        alloc = g_alloc_L2M1;
-        nbands = 27;
-        if (kbps < 56)
-        {
-            static const drmp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } };
-            alloc = g_alloc_L2M1_lowrate;
-            nbands = sample_rate_idx == 2 ? 12 : 8;
-        } else if (kbps >= 96 && sample_rate_idx != 1)
-        {
-            nbands = 30;
-        }
-    }
-    sci->total_bands = (drmp3_uint8)nbands;
-    sci->stereo_bands = (drmp3_uint8)DRMP3_MIN(stereo_bands, nbands);
-    return alloc;
-}
-static void drmp3_L12_read_scalefactors(drmp3_bs *bs, drmp3_uint8 *pba, drmp3_uint8 *scfcod, int bands, float *scf)
-{
-    static const float g_deq_L12[18*3] = {
-#define DRMP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x
-        DRMP3_DQ(3),DRMP3_DQ(7),DRMP3_DQ(15),DRMP3_DQ(31),DRMP3_DQ(63),DRMP3_DQ(127),DRMP3_DQ(255),DRMP3_DQ(511),DRMP3_DQ(1023),DRMP3_DQ(2047),DRMP3_DQ(4095),DRMP3_DQ(8191),DRMP3_DQ(16383),DRMP3_DQ(32767),DRMP3_DQ(65535),DRMP3_DQ(3),DRMP3_DQ(5),DRMP3_DQ(9)
-    };
-    int i, m;
-    for (i = 0; i < bands; i++)
-    {
-        float s = 0;
-        int ba = *pba++;
-        int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0;
-        for (m = 4; m; m >>= 1)
-        {
-            if (mask & m)
-            {
-                int b = drmp3_bs_get_bits(bs, 6);
-                s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3);
-            }
-            *scf++ = s;
-        }
-    }
-}
-static void drmp3_L12_read_scale_info(const drmp3_uint8 *hdr, drmp3_bs *bs, drmp3_L12_scale_info *sci)
-{
-    static const drmp3_uint8 g_bitalloc_code_tab[] = {
-        0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16,
-        0,17,18, 3,19,4,5,16,
-        0,17,18,16,
-        0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14,
-        0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16
-    };
-    const drmp3_L12_subband_alloc *subband_alloc = drmp3_L12_subband_alloc_table(hdr, sci);
-    int i, k = 0, ba_bits = 0;
-    const drmp3_uint8 *ba_code_tab = g_bitalloc_code_tab;
-    for (i = 0; i < sci->total_bands; i++)
-    {
-        drmp3_uint8 ba;
-        if (i == k)
-        {
-            k += subband_alloc->band_count;
-            ba_bits = subband_alloc->code_tab_width;
-            ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset;
-            subband_alloc++;
-        }
-        ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        sci->bitalloc[2*i] = ba;
-        if (i < sci->stereo_bands)
-        {
-            ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        }
-        sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0;
-    }
-    for (i = 0; i < 2*sci->total_bands; i++)
-    {
-        sci->scfcod[i] = (drmp3_uint8)(sci->bitalloc[i] ? DRMP3_HDR_IS_LAYER_1(hdr) ? 2 : drmp3_bs_get_bits(bs, 2) : 6);
-    }
-    drmp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf);
-    for (i = sci->stereo_bands; i < sci->total_bands; i++)
-    {
-        sci->bitalloc[2*i + 1] = 0;
-    }
-}
-static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_scale_info *sci, int group_size)
-{
-    int i, j, k, choff = 576;
-    for (j = 0; j < 4; j++)
-    {
-        float *dst = grbuf + group_size*j;
-        for (i = 0; i < 2*sci->total_bands; i++)
-        {
-            int ba = sci->bitalloc[i];
-            if (ba != 0)
-            {
-                if (ba < 17)
-                {
-                    int half = (1 << (ba - 1)) - 1;
-                    for (k = 0; k < group_size; k++)
-                    {
-                        dst[k] = (float)((int)drmp3_bs_get_bits(bs, ba) - half);
-                    }
-                } else
-                {
-                    unsigned mod = (2 << (ba - 17)) + 1;
-                    unsigned code = drmp3_bs_get_bits(bs, mod + 2 - (mod >> 3));
-                    for (k = 0; k < group_size; k++, code /= mod)
-                    {
-                        dst[k] = (float)((int)(code % mod - mod/2));
-                    }
-                }
-            }
-            dst += choff;
-            choff = 18 - choff;
-        }
-    }
-    return group_size*4;
-}
-static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
-{
-    int i, k;
-    memcpy(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
-    for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
-    {
-        for (k = 0; k < 12; k++)
-        {
-            dst[k + 0]   *= scf[0];
-            dst[k + 576] *= scf[3];
-        }
-    }
-}
-#endif
-static int drmp3_L3_read_side_info(drmp3_bs *bs, drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    static const drmp3_uint8 g_scf_long[8][23] = {
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 },
-        { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 },
-        { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 }
-    };
-    static const drmp3_uint8 g_scf_short[8][40] = {
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    static const drmp3_uint8 g_scf_mixed[8][40] = {
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    unsigned tables, scfsi = 0;
-    int main_data_begin, part_23_sum = 0;
-    int gr_count = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    int sr_idx = DRMP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0);
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        gr_count *= 2;
-        main_data_begin = drmp3_bs_get_bits(bs, 9);
-        scfsi = drmp3_bs_get_bits(bs, 7 + gr_count);
-    } else
-    {
-        main_data_begin = drmp3_bs_get_bits(bs, 8 + gr_count) >> gr_count;
-    }
-    do
-    {
-        if (DRMP3_HDR_IS_MONO(hdr))
-        {
-            scfsi <<= 4;
-        }
-        gr->part_23_length = (drmp3_uint16)drmp3_bs_get_bits(bs, 12);
-        part_23_sum += gr->part_23_length;
-        gr->big_values = (drmp3_uint16)drmp3_bs_get_bits(bs,  9);
-        if (gr->big_values > 288)
-        {
-            return -1;
-        }
-        gr->global_gain = (drmp3_uint8)drmp3_bs_get_bits(bs, 8);
-        gr->scalefac_compress = (drmp3_uint16)drmp3_bs_get_bits(bs, DRMP3_HDR_TEST_MPEG1(hdr) ? 4 : 9);
-        gr->sfbtab = g_scf_long[sr_idx];
-        gr->n_long_sfb  = 22;
-        gr->n_short_sfb = 0;
-        if (drmp3_bs_get_bits(bs, 1))
-        {
-            gr->block_type = (drmp3_uint8)drmp3_bs_get_bits(bs, 2);
-            if (!gr->block_type)
-            {
-                return -1;
-            }
-            gr->mixed_block_flag = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-            gr->region_count[0] = 7;
-            gr->region_count[1] = 255;
-            if (gr->block_type == DRMP3_SHORT_BLOCK_TYPE)
-            {
-                scfsi &= 0x0F0F;
-                if (!gr->mixed_block_flag)
-                {
-                    gr->region_count[0] = 8;
-                    gr->sfbtab = g_scf_short[sr_idx];
-                    gr->n_long_sfb = 0;
-                    gr->n_short_sfb = 39;
-                } else
-                {
-                    gr->sfbtab = g_scf_mixed[sr_idx];
-                    gr->n_long_sfb = DRMP3_HDR_TEST_MPEG1(hdr) ? 8 : 6;
-                    gr->n_short_sfb = 30;
-                }
-            }
-            tables = drmp3_bs_get_bits(bs, 10);
-            tables <<= 5;
-            gr->subblock_gain[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[2] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-        } else
-        {
-            gr->block_type = 0;
-            gr->mixed_block_flag = 0;
-            tables = drmp3_bs_get_bits(bs, 15);
-            gr->region_count[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 4);
-            gr->region_count[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->region_count[2] = 255;
-        }
-        gr->table_select[0] = (drmp3_uint8)(tables >> 10);
-        gr->table_select[1] = (drmp3_uint8)((tables >> 5) & 31);
-        gr->table_select[2] = (drmp3_uint8)((tables) & 31);
-        gr->preflag = (drmp3_uint8)(DRMP3_HDR_TEST_MPEG1(hdr) ? drmp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500));
-        gr->scalefac_scale = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->count1_table = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->scfsi = (drmp3_uint8)((scfsi >> 12) & 15);
-        scfsi <<= 4;
-        gr++;
-    } while(--gr_count);
-    if (part_23_sum + bs->pos > bs->limit + main_data_begin*8)
-    {
-        return -1;
-    }
-    return main_data_begin;
-}
-static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, const drmp3_uint8 *scf_size, const drmp3_uint8 *scf_count, drmp3_bs *bitbuf, int scfsi)
-{
-    int i, k;
-    for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2)
-    {
-        int cnt = scf_count[i];
-        if (scfsi & 8)
-        {
-            memcpy(scf, ist_pos, cnt);
-        } else
-        {
-            int bits = scf_size[i];
-            if (!bits)
-            {
-                memset(scf, 0, cnt);
-                memset(ist_pos, 0, cnt);
-            } else
-            {
-                int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
-                for (k = 0; k < cnt; k++)
-                {
-                    int s = drmp3_bs_get_bits(bitbuf, bits);
-                    ist_pos[k] = (drmp3_uint8)(s == max_scf ? -1 : s);
-                    scf[k] = (drmp3_uint8)s;
-                }
-            }
-        }
-        ist_pos += cnt;
-        scf += cnt;
-    }
-    scf[0] = scf[1] = scf[2] = 0;
-}
-static float drmp3_L3_ldexp_q2(float y, int exp_q2)
-{
-    static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f };
-    int e;
-    do
-    {
-        e = DRMP3_MIN(30*4, exp_q2);
-        y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));
-    } while ((exp_q2 -= e) > 0);
-    return y;
-}
-static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *ist_pos, drmp3_bs *bs, const drmp3_L3_gr_info *gr, float *scf, int ch)
-{
-    static const drmp3_uint8 g_scf_partitions[3][28] = {
-        { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 },
-        { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 },
-        { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 }
-    };
-    const drmp3_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb];
-    drmp3_uint8 scf_size[4], iscf[40];
-    int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi;
-    float gain;
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 };
-        int part = g_scfc_decode[gr->scalefac_compress];
-        scf_size[1] = scf_size[0] = (drmp3_uint8)(part >> 2);
-        scf_size[3] = scf_size[2] = (drmp3_uint8)(part & 3);
-    } else
-    {
-        static const drmp3_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 };
-        int k, modprod, sfc, ist = DRMP3_HDR_TEST_I_STEREO(hdr) && ch;
-        sfc = gr->scalefac_compress >> ist;
-        for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4)
-        {
-            for (modprod = 1, i = 3; i >= 0; i--)
-            {
-                scf_size[i] = (drmp3_uint8)(sfc / modprod % g_mod[k + i]);
-                modprod *= g_mod[k + i];
-            }
-        }
-        scf_partition += k;
-        scfsi = -16;
-    }
-    drmp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi);
-    if (gr->n_short_sfb)
-    {
-        int sh = 3 - scf_shift;
-        for (i = 0; i < gr->n_short_sfb; i += 3)
-        {
-            iscf[gr->n_long_sfb + i + 0] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh));
-            iscf[gr->n_long_sfb + i + 1] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh));
-            iscf[gr->n_long_sfb + i + 2] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh));
-        }
-    } else if (gr->preflag)
-    {
-        static const drmp3_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 };
-        for (i = 0; i < 10; i++)
-        {
-            iscf[11 + i] = (drmp3_uint8)(iscf[11 + i] + g_preamp[i]);
-        }
-    }
-    gain_exp = gr->global_gain + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210 - (DRMP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0);
-    gain = drmp3_L3_ldexp_q2(1 << (DRMP3_MAX_SCFI/4),  DRMP3_MAX_SCFI - gain_exp);
-    for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++)
-    {
-        scf[i] = drmp3_L3_ldexp_q2(gain, iscf[i] << scf_shift);
-    }
-}
-static const float g_drmp3_pow43[129 + 16] = {
-    0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f,
-    0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f
-};
-static float drmp3_L3_pow_43(int x)
-{
-    float frac;
-    int sign, mult = 256;
-    if (x < 129)
-    {
-        return g_drmp3_pow43[16 + x];
-    }
-    if (x < 1024)
-    {
-        mult = 16;
-        x <<= 3;
-    }
-    sign = 2*x & 64;
-    frac = (float)((x & 63) - sign) / ((x & ~63) + sign);
-    return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult;
-}
-static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit)
-{
-    static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,
-        -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288,
-        -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288,
-        -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258,
-        -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259,
-        -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258,
-        -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258,
-        -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259,
-        -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258,
-        -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290,
-        -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259,
-        -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258,
-        -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259,
-        -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258,
-        -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 };
-    static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205};
-    static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
-    static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
-    static const drmp3_uint8 g_linbits[] =  { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-#define DRMP3_PEEK_BITS(n)    (bs_cache >> (32 - n))
-#define DRMP3_FLUSH_BITS(n)   { bs_cache <<= (n); bs_sh += (n); }
-#define DRMP3_CHECK_BITS      while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
-#define DRMP3_BSPOS           ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
-    float one = 0.0f;
-    int ireg = 0, big_val_cnt = gr_info->big_values;
-    const drmp3_uint8 *sfb = gr_info->sfbtab;
-    const drmp3_uint8 *bs_next_ptr = bs->buf + bs->pos/8;
-    drmp3_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7);
-    int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8;
-    bs_next_ptr += 4;
-    while (big_val_cnt > 0)
-    {
-        int tab_num = gr_info->table_select[ireg];
-        int sfb_cnt = gr_info->region_count[ireg++];
-        const drmp3_int16 *codebook = tabs + tabindex[tab_num];
-        int linbits = g_linbits[tab_num];
-        if (linbits)
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        if (lsb == 15)
-                        {
-                            lsb += DRMP3_PEEK_BITS(linbits);
-                            DRMP3_FLUSH_BITS(linbits);
-                            DRMP3_CHECK_BITS;
-                            *dst = one*drmp3_L3_pow_43(lsb)*((drmp3_int32)bs_cache < 0 ? -1: 1);
-                        } else
-                        {
-                            *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        }
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        } else
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        }
-    }
-    for (np = 1 - big_val_cnt;; dst += 4)
-    {
-        const drmp3_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
-        int leaf = codebook_count1[DRMP3_PEEK_BITS(4)];
-        if (!(leaf & 8))
-        {
-            leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))];
-        }
-        DRMP3_FLUSH_BITS(leaf & 7);
-        if (DRMP3_BSPOS > layer3gr_limit)
-        {
-            break;
-        }
-#define DRMP3_RELOAD_SCALEFACTOR  if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; }
-#define DRMP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((drmp3_int32)bs_cache < 0) ? -one : one; DRMP3_FLUSH_BITS(1) }
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(0);
-        DRMP3_DEQ_COUNT1(1);
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(2);
-        DRMP3_DEQ_COUNT1(3);
-        DRMP3_CHECK_BITS;
-    }
-    bs->pos = layer3gr_limit;
-}
-static void drmp3_L3_midside_stereo(float *left, int n)
-{
-    int i = 0;
-    float *right = left + 576;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; i < n - 3; i += 4)
-    {
-        drmp3_f4 vl = DRMP3_VLD(left + i);
-        drmp3_f4 vr = DRMP3_VLD(right + i);
-        DRMP3_VSTORE(left + i, DRMP3_VADD(vl, vr));
-        DRMP3_VSTORE(right + i, DRMP3_VSUB(vl, vr));
-    }
-#endif
-    for (; i < n; i++)
-    {
-        float a = left[i];
-        float b = right[i];
-        left[i] = a + b;
-        right[i] = a - b;
-    }
-}
-static void drmp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr)
-{
-    int i;
-    for (i = 0; i < n; i++)
-    {
-        left[i + 576] = left[i]*kr;
-        left[i] = left[i]*kl;
-    }
-}
-static void drmp3_L3_stereo_top_band(const float *right, const drmp3_uint8 *sfb, int nbands, int max_band[3])
-{
-    int i, k;
-    max_band[0] = max_band[1] = max_band[2] = -1;
-    for (i = 0; i < nbands; i++)
-    {
-        for (k = 0; k < sfb[i]; k += 2)
-        {
-            if (right[k] != 0 || right[k + 1] != 0)
-            {
-                max_band[i % 3] = i;
-                break;
-            }
-        }
-        right += sfb[i];
-    }
-}
-static void drmp3_L3_stereo_process(float *left, const drmp3_uint8 *ist_pos, const drmp3_uint8 *sfb, const drmp3_uint8 *hdr, int max_band[3], int mpeg2_sh)
-{
-    static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 };
-    unsigned i, max_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 7 : 64;
-    for (i = 0; sfb[i]; i++)
-    {
-        unsigned ipos = ist_pos[i];
-        if ((int)i > max_band[i % 3] && ipos < max_pos)
-        {
-            float kl, kr, s = DRMP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1;
-            if (DRMP3_HDR_TEST_MPEG1(hdr))
-            {
-                kl = g_pan[2*ipos];
-                kr = g_pan[2*ipos + 1];
-            } else
-            {
-                kl = 1;
-                kr = drmp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh);
-                if (ipos & 1)
-                {
-                    kl = kr;
-                    kr = 1;
-                }
-            }
-            drmp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s);
-        } else if (DRMP3_HDR_TEST_MS_STEREO(hdr))
-        {
-            drmp3_L3_midside_stereo(left, sfb[i]);
-        }
-        left += sfb[i];
-    }
-}
-static void drmp3_L3_intensity_stereo(float *left, drmp3_uint8 *ist_pos, const drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb;
-    int i, max_blocks = gr->n_short_sfb ? 3 : 1;
-    drmp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band);
-    if (gr->n_long_sfb)
-    {
-        max_band[0] = max_band[1] = max_band[2] = DRMP3_MAX(DRMP3_MAX(max_band[0], max_band[1]), max_band[2]);
-    }
-    for (i = 0; i < max_blocks; i++)
-    {
-        int default_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 3 : 0;
-        int itop = n_sfb - max_blocks + i;
-        int prev = itop - max_blocks;
-        ist_pos[itop] = (drmp3_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]);
-    }
-    drmp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1);
-}
-static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sfb)
-{
-    int i, len;
-    float *src = grbuf, *dst = scratch;
-    for (;0 != (len = *sfb); sfb += 3, src += 2*len)
-    {
-        for (i = 0; i < len; i++, src++)
-        {
-            *dst++ = src[0*len];
-            *dst++ = src[1*len];
-            *dst++ = src[2*len];
-        }
-    }
-    memcpy(grbuf, scratch, (dst - scratch)*sizeof(float));
-}
-static void drmp3_L3_antialias(float *grbuf, int nbands)
-{
-    static const float g_aa[2][8] = {
-        {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f},
-        {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f}
-    };
-    for (; nbands > 0; nbands--, grbuf += 18)
-    {
-        int i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vu = DRMP3_VLD(grbuf + 18 + i);
-            drmp3_f4 vd = DRMP3_VLD(grbuf + 14 - i);
-            drmp3_f4 vc0 = DRMP3_VLD(g_aa[0] + i);
-            drmp3_f4 vc1 = DRMP3_VLD(g_aa[1] + i);
-            vd = DRMP3_VREV(vd);
-            DRMP3_VSTORE(grbuf + 18 + i, DRMP3_VSUB(DRMP3_VMUL(vu, vc0), DRMP3_VMUL(vd, vc1)));
-            vd = DRMP3_VADD(DRMP3_VMUL(vu, vc1), DRMP3_VMUL(vd, vc0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vd));
-        }
-#endif
-#ifndef DR_MP3_ONLY_SIMD
-        for(; i < 8; i++)
-        {
-            float u = grbuf[18 + i];
-            float d = grbuf[17 - i];
-            grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i];
-            grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i];
-        }
-#endif
-    }
-}
-static void drmp3_L3_dct3_9(float *y)
-{
-    float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4;
-    s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8];
-    t0 = s0 + s6*0.5f;
-    s0 -= s6;
-    t4 = (s4 + s2)*0.93969262f;
-    t2 = (s8 + s2)*0.76604444f;
-    s6 = (s4 - s8)*0.17364818f;
-    s4 += s8 - s2;
-    s2 = s0 - s4*0.5f;
-    y[4] = s4 + s0;
-    s8 = t0 - t2 + s6;
-    s0 = t0 - t4 + t2;
-    s4 = t0 + t4 - s6;
-    s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7];
-    s3 *= 0.86602540f;
-    t0 = (s5 + s1)*0.98480775f;
-    t4 = (s5 - s7)*0.34202014f;
-    t2 = (s1 + s7)*0.64278761f;
-    s1 = (s1 - s5 - s7)*0.86602540f;
-    s5 = t0 - s3 - t2;
-    s7 = t4 - s3 - t0;
-    s3 = t4 + s3 - t2;
-    y[0] = s4 - s7;
-    y[1] = s2 + s1;
-    y[2] = s0 - s3;
-    y[3] = s8 + s5;
-    y[5] = s8 - s5;
-    y[6] = s0 + s3;
-    y[7] = s2 - s1;
-    y[8] = s4 + s7;
-}
-static void drmp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands)
-{
-    int i, j;
-    static const float g_twid9[18] = {
-        0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f
-    };
-    for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9)
-    {
-        float co[9], si[9];
-        co[0] = -grbuf[0];
-        si[0] = grbuf[17];
-        for (i = 0; i < 4; i++)
-        {
-            si[8 - 2*i] =   grbuf[4*i + 1] - grbuf[4*i + 2];
-            co[1 + 2*i] =   grbuf[4*i + 1] + grbuf[4*i + 2];
-            si[7 - 2*i] =   grbuf[4*i + 4] - grbuf[4*i + 3];
-            co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]);
-        }
-        drmp3_L3_dct3_9(co);
-        drmp3_L3_dct3_9(si);
-        si[1] = -si[1];
-        si[3] = -si[3];
-        si[5] = -si[5];
-        si[7] = -si[7];
-        i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vovl = DRMP3_VLD(overlap + i);
-            drmp3_f4 vc = DRMP3_VLD(co + i);
-            drmp3_f4 vs = DRMP3_VLD(si + i);
-            drmp3_f4 vr0 = DRMP3_VLD(g_twid9 + i);
-            drmp3_f4 vr1 = DRMP3_VLD(g_twid9 + 9 + i);
-            drmp3_f4 vw0 = DRMP3_VLD(window + i);
-            drmp3_f4 vw1 = DRMP3_VLD(window + 9 + i);
-            drmp3_f4 vsum = DRMP3_VADD(DRMP3_VMUL(vc, vr1), DRMP3_VMUL(vs, vr0));
-            DRMP3_VSTORE(overlap + i, DRMP3_VSUB(DRMP3_VMUL(vc, vr0), DRMP3_VMUL(vs, vr1)));
-            DRMP3_VSTORE(grbuf + i, DRMP3_VSUB(DRMP3_VMUL(vovl, vw0), DRMP3_VMUL(vsum, vw1)));
-            vsum = DRMP3_VADD(DRMP3_VMUL(vovl, vw1), DRMP3_VMUL(vsum, vw0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vsum));
-        }
-#endif
-        for (; i < 9; i++)
-        {
-            float ovl  = overlap[i];
-            float sum  = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i];
-            overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i];
-            grbuf[i]      = ovl*window[0 + i] - sum*window[9 + i];
-            grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i];
-        }
-    }
-}
-static void drmp3_L3_idct3(float x0, float x1, float x2, float *dst)
-{
-    float m1 = x1*0.86602540f;
-    float a1 = x0 - x2*0.5f;
-    dst[1] = x0 + x2;
-    dst[0] = a1 + m1;
-    dst[2] = a1 - m1;
-}
-static void drmp3_L3_imdct12(float *x, float *dst, float *overlap)
-{
-    static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f };
-    float co[3], si[3];
-    int i;
-    drmp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co);
-    drmp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si);
-    si[1] = -si[1];
-    for (i = 0; i < 3; i++)
-    {
-        float ovl  = overlap[i];
-        float sum  = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i];
-        overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i];
-        dst[i]     = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i];
-        dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i];
-    }
-}
-static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
-{
-    for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
-    {
-        float tmp[18];
-        memcpy(tmp, grbuf, sizeof(tmp));
-        memcpy(grbuf, overlap, 6*sizeof(float));
-        drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
-        drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
-        drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
-    }
-}
-static void drmp3_L3_change_sign(float *grbuf)
-{
-    int b, i;
-    for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36)
-        for (i = 1; i < 18; i += 2)
-            grbuf[i] = -grbuf[i];
-}
-static void drmp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands)
-{
-    static const float g_mdct_window[2][18] = {
-        { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f },
-        { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f }
-    };
-    if (n_long_bands)
-    {
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands);
-        grbuf += 18*n_long_bands;
-        overlap += 9*n_long_bands;
-    }
-    if (block_type == DRMP3_SHORT_BLOCK_TYPE)
-        drmp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands);
-    else
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == DRMP3_STOP_BLOCK_TYPE], 32 - n_long_bands);
-}
-static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
-{
-    int pos = (s->bs.pos + 7)/8u;
-    int remains = s->bs.limit/8u - pos;
-    if (remains > DRMP3_MAX_BITRESERVOIR_BYTES)
-    {
-        pos += remains - DRMP3_MAX_BITRESERVOIR_BYTES;
-        remains = DRMP3_MAX_BITRESERVOIR_BYTES;
-    }
-    if (remains > 0)
-    {
-        memmove(h->reserv_buf, s->maindata + pos, remains);
-    }
-    h->reserv = remains;
-}
-static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratch *s, int main_data_begin)
-{
-    int frame_bytes = (bs->limit - bs->pos)/8;
-    int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
-    memcpy(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
-    memcpy(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
-    drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
-    return h->reserv >= main_data_begin;
-}
-static void drmp3_L3_decode(drmp3dec *h, drmp3dec_scratch *s, drmp3_L3_gr_info *gr_info, int nch)
-{
-    int ch;
-    for (ch = 0; ch < nch; ch++)
-    {
-        int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length;
-        drmp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch);
-        drmp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit);
-    }
-    if (DRMP3_HDR_TEST_I_STEREO(h->header))
-    {
-        drmp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header);
-    } else if (DRMP3_HDR_IS_MS_STEREO(h->header))
-    {
-        drmp3_L3_midside_stereo(s->grbuf[0], 576);
-    }
-    for (ch = 0; ch < nch; ch++, gr_info++)
-    {
-        int aa_bands = 31;
-        int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(DRMP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2);
-        if (gr_info->n_short_sfb)
-        {
-            aa_bands = n_long_bands - 1;
-            drmp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb);
-        }
-        drmp3_L3_antialias(s->grbuf[ch], aa_bands);
-        drmp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands);
-        drmp3_L3_change_sign(s->grbuf[ch]);
-    }
-}
-static void drmp3d_DCT_II(float *grbuf, int n)
-{
-    static const float g_sec[24] = {
-        10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f
-    };
-    int i, k = 0;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; k < n; k += 4)
-    {
-        drmp3_f4 t[4][8], *x;
-        float *y = grbuf + k;
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            drmp3_f4 x0 = DRMP3_VLD(&y[i*18]);
-            drmp3_f4 x1 = DRMP3_VLD(&y[(15 - i)*18]);
-            drmp3_f4 x2 = DRMP3_VLD(&y[(16 + i)*18]);
-            drmp3_f4 x3 = DRMP3_VLD(&y[(31 - i)*18]);
-            drmp3_f4 t0 = DRMP3_VADD(x0, x3);
-            drmp3_f4 t1 = DRMP3_VADD(x1, x2);
-            drmp3_f4 t2 = DRMP3_VMUL_S(DRMP3_VSUB(x1, x2), g_sec[3*i + 0]);
-            drmp3_f4 t3 = DRMP3_VMUL_S(DRMP3_VSUB(x0, x3), g_sec[3*i + 1]);
-            x[0] = DRMP3_VADD(t0, t1);
-            x[8] = DRMP3_VMUL_S(DRMP3_VSUB(t0, t1), g_sec[3*i + 2]);
-            x[16] = DRMP3_VADD(t3, t2);
-            x[24] = DRMP3_VMUL_S(DRMP3_VSUB(t3, t2), g_sec[3*i + 2]);
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            drmp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = DRMP3_VSUB(x0, x7); x0 = DRMP3_VADD(x0, x7);
-            x7 = DRMP3_VSUB(x1, x6); x1 = DRMP3_VADD(x1, x6);
-            x6 = DRMP3_VSUB(x2, x5); x2 = DRMP3_VADD(x2, x5);
-            x5 = DRMP3_VSUB(x3, x4); x3 = DRMP3_VADD(x3, x4);
-            x4 = DRMP3_VSUB(x0, x3); x0 = DRMP3_VADD(x0, x3);
-            x3 = DRMP3_VSUB(x1, x2); x1 = DRMP3_VADD(x1, x2);
-            x[0] = DRMP3_VADD(x0, x1);
-            x[4] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x1), 0.70710677f);
-            x5 = DRMP3_VADD(x5, x6);
-            x6 = DRMP3_VMUL_S(DRMP3_VADD(x6, x7), 0.70710677f);
-            x7 = DRMP3_VADD(x7, xt);
-            x3 = DRMP3_VMUL_S(DRMP3_VADD(x3, x4), 0.70710677f);
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x7 = DRMP3_VADD(x7, DRMP3_VMUL_S(x5, 0.382683432f));
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x0 = DRMP3_VSUB(xt, x6); xt = DRMP3_VADD(xt, x6);
-            x[1] = DRMP3_VMUL_S(DRMP3_VADD(xt, x7), 0.50979561f);
-            x[2] = DRMP3_VMUL_S(DRMP3_VADD(x4, x3), 0.54119611f);
-            x[3] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x5), 0.60134488f);
-            x[5] = DRMP3_VMUL_S(DRMP3_VADD(x0, x5), 0.89997619f);
-            x[6] = DRMP3_VMUL_S(DRMP3_VSUB(x4, x3), 1.30656302f);
-            x[7] = DRMP3_VMUL_S(DRMP3_VSUB(xt, x7), 2.56291556f);
-        }
-        if (k > n - 3)
-        {
-#if DRMP3_HAVE_SSE
-#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
-#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18],  vget_low_f32(v))
-#endif
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE2(0, t[0][i]);
-                DRMP3_VSAVE2(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE2(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE2(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE2(0, t[0][7]);
-            DRMP3_VSAVE2(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE2(2, t[1][7]);
-            DRMP3_VSAVE2(3, t[3][7]);
-        } else
-        {
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE4(0, t[0][i]);
-                DRMP3_VSAVE4(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE4(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE4(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE4(0, t[0][7]);
-            DRMP3_VSAVE4(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE4(2, t[1][7]);
-            DRMP3_VSAVE4(3, t[3][7]);
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {}
-#else
-    for (; k < n; k++)
-    {
-        float t[4][8], *x, *y = grbuf + k;
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            float x0 = y[i*18];
-            float x1 = y[(15 - i)*18];
-            float x2 = y[(16 + i)*18];
-            float x3 = y[(31 - i)*18];
-            float t0 = x0 + x3;
-            float t1 = x1 + x2;
-            float t2 = (x1 - x2)*g_sec[3*i + 0];
-            float t3 = (x0 - x3)*g_sec[3*i + 1];
-            x[0] = t0 + t1;
-            x[8] = (t0 - t1)*g_sec[3*i + 2];
-            x[16] = t3 + t2;
-            x[24] = (t3 - t2)*g_sec[3*i + 2];
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = x0 - x7; x0 += x7;
-            x7 = x1 - x6; x1 += x6;
-            x6 = x2 - x5; x2 += x5;
-            x5 = x3 - x4; x3 += x4;
-            x4 = x0 - x3; x0 += x3;
-            x3 = x1 - x2; x1 += x2;
-            x[0] = x0 + x1;
-            x[4] = (x0 - x1)*0.70710677f;
-            x5 =  x5 + x6;
-            x6 = (x6 + x7)*0.70710677f;
-            x7 =  x7 + xt;
-            x3 = (x3 + x4)*0.70710677f;
-            x5 -= x7*0.198912367f;
-            x7 += x5*0.382683432f;
-            x5 -= x7*0.198912367f;
-            x0 = xt - x6; xt += x6;
-            x[1] = (xt + x7)*0.50979561f;
-            x[2] = (x4 + x3)*0.54119611f;
-            x[3] = (x0 - x5)*0.60134488f;
-            x[5] = (x0 + x5)*0.89997619f;
-            x[6] = (x4 - x3)*1.30656302f;
-            x[7] = (xt - x7)*2.56291556f;
-        }
-        for (i = 0; i < 7; i++, y += 4*18)
-        {
-            y[0*18] = t[0][i];
-            y[1*18] = t[2][i] + t[3][i] + t[3][i + 1];
-            y[2*18] = t[1][i] + t[1][i + 1];
-            y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1];
-        }
-        y[0*18] = t[0][7];
-        y[1*18] = t[2][7] + t[3][7];
-        y[2*18] = t[1][7];
-        y[3*18] = t[3][7];
-    }
-#endif
-}
-#ifndef DR_MP3_FLOAT_OUTPUT
-typedef drmp3_int16 drmp3d_sample_t;
-static drmp3_int16 drmp3d_scale_pcm(float sample)
-{
-    drmp3_int16 s;
-#if DRMP3_HAVE_ARMV6
-    drmp3_int32 s32 = (drmp3_int32)(sample + .5f);
-    s32 -= (s32 < 0);
-    s = (drmp3_int16)drmp3_clip_int16_arm(s32);
-#else
-    if (sample >=  32766.5) return (drmp3_int16) 32767;
-    if (sample <= -32767.5) return (drmp3_int16)-32768;
-    s = (drmp3_int16)(sample + .5f);
-    s -= (s < 0);
-#endif
-    return s;
-}
-#else
-typedef float drmp3d_sample_t;
-static float drmp3d_scale_pcm(float sample)
-{
-    return sample*(1.f/32768.f);
-}
-#endif
-static void drmp3d_synth_pair(drmp3d_sample_t *pcm, int nch, const float *z)
-{
-    float a;
-    a  = (z[14*64] - z[    0]) * 29;
-    a += (z[ 1*64] + z[13*64]) * 213;
-    a += (z[12*64] - z[ 2*64]) * 459;
-    a += (z[ 3*64] + z[11*64]) * 2037;
-    a += (z[10*64] - z[ 4*64]) * 5153;
-    a += (z[ 5*64] + z[ 9*64]) * 6574;
-    a += (z[ 8*64] - z[ 6*64]) * 37489;
-    a +=  z[ 7*64]             * 75038;
-    pcm[0] = drmp3d_scale_pcm(a);
-    z += 2;
-    a  = z[14*64] * 104;
-    a += z[12*64] * 1567;
-    a += z[10*64] * 9727;
-    a += z[ 8*64] * 64019;
-    a += z[ 6*64] * -9975;
-    a += z[ 4*64] * -45;
-    a += z[ 2*64] * 146;
-    a += z[ 0*64] * -5;
-    pcm[16*nch] = drmp3d_scale_pcm(a);
-}
-static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
-{
-    int i;
-    float *xr = xl + 576*(nch - 1);
-    drmp3d_sample_t *dstr = dstl + (nch - 1);
-    static const float g_win[] = {
-        -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992,
-        -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856,
-        -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630,
-        -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313,
-        -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908,
-        -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415,
-        -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835,
-        -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169,
-        -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420,
-        -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590,
-        -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679,
-        -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692,
-        -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629,
-        -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494,
-        -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290
-    };
-    float *zlin = lins + 15*64;
-    const float *w = g_win;
-    zlin[4*15]     = xl[18*16];
-    zlin[4*15 + 1] = xr[18*16];
-    zlin[4*15 + 2] = xl[0];
-    zlin[4*15 + 3] = xr[0];
-    zlin[4*31]     = xl[1 + 18*16];
-    zlin[4*31 + 1] = xr[1 + 18*16];
-    zlin[4*31 + 2] = xl[1];
-    zlin[4*31 + 3] = xr[1];
-    drmp3d_synth_pair(dstr, nch, lins + 4*15 + 1);
-    drmp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1);
-    drmp3d_synth_pair(dstl, nch, lins + 4*15);
-    drmp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64);
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_VLOAD(k) drmp3_f4 w0 = DRMP3_VSET(*w++); drmp3_f4 w1 = DRMP3_VSET(*w++); drmp3_f4 vz = DRMP3_VLD(&zlin[4*i - 64*k]); drmp3_f4 vy = DRMP3_VLD(&zlin[4*i - 64*(15 - k)]);
-#define DRMP3_V0(k) { DRMP3_VLOAD(k) b =               DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0)) ; a =               DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1));  }
-#define DRMP3_V1(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1))); }
-#define DRMP3_V2(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vy, w1), DRMP3_VMUL(vz, w0))); }
-        drmp3_f4 a, b;
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*i + 64] = xl[1 + 18*(1 + i)];
-        zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*i - 64 + 2] = xl[18*(1 + i)];
-        zlin[4*i - 64 + 3] = xr[18*(1 + i)];
-        DRMP3_V0(0) DRMP3_V2(1) DRMP3_V1(2) DRMP3_V2(3) DRMP3_V1(4) DRMP3_V2(5) DRMP3_V1(6) DRMP3_V2(7)
-        {
-#ifndef DR_MP3_FLOAT_OUTPUT
-#if DRMP3_HAVE_SSE
-            static const drmp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f };
-            static const drmp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f };
-            __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)),
-                                           _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min)));
-            dstr[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-            dstr[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-            dstl[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-            dstl[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-            dstr[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-            dstr[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-            dstl[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-            dstl[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-#else
-            int16x4_t pcma, pcmb;
-            a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-            b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-            pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-            pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-            vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1);
-            vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1);
-            vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0);
-            vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0);
-            vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3);
-            vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3);
-            vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2);
-            vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
-#endif
-#else
-            static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
-            a = DRMP3_VMUL(a, g_scale);
-            b = DRMP3_VMUL(b, g_scale);
-#if DRMP3_HAVE_SSE
-            _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2)));
-            _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2)));
-#else
-            vst1q_lane_f32(dstr + (15 - i)*nch, a, 1);
-            vst1q_lane_f32(dstr + (17 + i)*nch, b, 1);
-            vst1q_lane_f32(dstl + (15 - i)*nch, a, 0);
-            vst1q_lane_f32(dstl + (17 + i)*nch, b, 0);
-            vst1q_lane_f32(dstr + (47 - i)*nch, a, 3);
-            vst1q_lane_f32(dstr + (49 + i)*nch, b, 3);
-            vst1q_lane_f32(dstl + (47 - i)*nch, a, 2);
-            vst1q_lane_f32(dstl + (49 + i)*nch, b, 2);
-#endif
-#endif
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {}
-#else
-    for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64];
-#define DRMP3_S0(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j]  = vz[j]*w1 + vy[j]*w0, a[j]  = vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S1(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S2(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; }
-        float a[4], b[4];
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*(i + 16)]   = xl[1 + 18*(1 + i)];
-        zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*(i - 16) + 2] = xl[18*(1 + i)];
-        zlin[4*(i - 16) + 3] = xr[18*(1 + i)];
-        DRMP3_S0(0) DRMP3_S2(1) DRMP3_S1(2) DRMP3_S2(3) DRMP3_S1(4) DRMP3_S2(5) DRMP3_S1(6) DRMP3_S2(7)
-        dstr[(15 - i)*nch] = drmp3d_scale_pcm(a[1]);
-        dstr[(17 + i)*nch] = drmp3d_scale_pcm(b[1]);
-        dstl[(15 - i)*nch] = drmp3d_scale_pcm(a[0]);
-        dstl[(17 + i)*nch] = drmp3d_scale_pcm(b[0]);
-        dstr[(47 - i)*nch] = drmp3d_scale_pcm(a[3]);
-        dstr[(49 + i)*nch] = drmp3d_scale_pcm(b[3]);
-        dstl[(47 - i)*nch] = drmp3d_scale_pcm(a[2]);
-        dstl[(49 + i)*nch] = drmp3d_scale_pcm(b[2]);
-    }
-#endif
-}
-static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, drmp3d_sample_t *pcm, float *lins)
-{
-    int i;
-    for (i = 0; i < nch; i++)
-    {
-        drmp3d_DCT_II(grbuf + 576*i, nbands);
-    }
-    memcpy(lins, qmf_state, sizeof(float)*15*64);
-    for (i = 0; i < nbands; i += 2)
-    {
-        drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
-    }
-#ifndef DR_MP3_NONSTANDARD_BUT_LOGICAL
-    if (nch == 1)
-    {
-        for (i = 0; i < 15*64; i += 2)
-        {
-            qmf_state[i] = lins[nbands*64 + i];
-        }
-    } else
-#endif
-    {
-        memcpy(qmf_state, lins + nbands*64, sizeof(float)*15*64);
-    }
-}
-static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
-{
-    int i, nmatch;
-    for (i = 0, nmatch = 0; nmatch < DRMP3_MAX_FRAME_SYNC_MATCHES; nmatch++)
-    {
-        i += drmp3_hdr_frame_bytes(hdr + i, frame_bytes) + drmp3_hdr_padding(hdr + i);
-        if (i + DRMP3_HDR_SIZE > mp3_bytes)
-            return nmatch > 0;
-        if (!drmp3_hdr_compare(hdr, hdr + i))
-            return 0;
-    }
-    return 1;
-}
-static int drmp3d_find_frame(const drmp3_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes)
-{
-    int i, k;
-    for (i = 0; i < mp3_bytes - DRMP3_HDR_SIZE; i++, mp3++)
-    {
-        if (drmp3_hdr_valid(mp3))
-        {
-            int frame_bytes = drmp3_hdr_frame_bytes(mp3, *free_format_bytes);
-            int frame_and_padding = frame_bytes + drmp3_hdr_padding(mp3);
-            for (k = DRMP3_HDR_SIZE; !frame_bytes && k < DRMP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - DRMP3_HDR_SIZE; k++)
-            {
-                if (drmp3_hdr_compare(mp3, mp3 + k))
-                {
-                    int fb = k - drmp3_hdr_padding(mp3);
-                    int nextfb = fb + drmp3_hdr_padding(mp3 + k);
-                    if (i + k + nextfb + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + k + nextfb))
-                        continue;
-                    frame_and_padding = k;
-                    frame_bytes = fb;
-                    *free_format_bytes = fb;
-                }
-            }
-            if ((frame_bytes && i + frame_and_padding <= mp3_bytes &&
-                drmp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) ||
-                (!i && frame_and_padding == mp3_bytes))
-            {
-                *ptr_frame_bytes = frame_and_padding;
-                return i;
-            }
-            *free_format_bytes = 0;
-        }
-    }
-    *ptr_frame_bytes = 0;
-    return mp3_bytes;
-}
-DRMP3_API void drmp3dec_init(drmp3dec *dec)
-{
-    dec->header[0] = 0;
-}
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
-{
-    int i = 0, igr, frame_size = 0, success = 1;
-    const drmp3_uint8 *hdr;
-    drmp3_bs bs_frame[1];
-    drmp3dec_scratch scratch;
-    if (mp3_bytes > 4 && dec->header[0] == 0xff && drmp3_hdr_compare(dec->header, mp3))
-    {
-        frame_size = drmp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + drmp3_hdr_padding(mp3);
-        if (frame_size != mp3_bytes && (frame_size + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + frame_size)))
-        {
-            frame_size = 0;
-        }
-    }
-    if (!frame_size)
-    {
-        memset(dec, 0, sizeof(drmp3dec));
-        i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
-        if (!frame_size || i + frame_size > mp3_bytes)
-        {
-            info->frame_bytes = i;
-            return 0;
-        }
-    }
-    hdr = mp3 + i;
-    memcpy(dec->header, hdr, DRMP3_HDR_SIZE);
-    info->frame_bytes = i + frame_size;
-    info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    info->hz = drmp3_hdr_sample_rate_hz(hdr);
-    info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr);
-    info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr);
-    drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE);
-    if (DRMP3_HDR_IS_CRC(hdr))
-    {
-        drmp3_bs_get_bits(bs_frame, 16);
-    }
-    if (info->layer == 3)
-    {
-        int main_data_begin = drmp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr);
-        if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit)
-        {
-            drmp3dec_init(dec);
-            return 0;
-        }
-        success = drmp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin);
-        if (success && pcm != NULL)
-        {
-            for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
-            {
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-            }
-        }
-        drmp3_L3_save_reservoir(dec, &scratch);
-    } else
-    {
-#ifdef DR_MP3_ONLY_MP3
-        return 0;
-#else
-        drmp3_L12_scale_info sci[1];
-        if (pcm == NULL) {
-            return drmp3_hdr_frame_samples(hdr);
-        }
-        drmp3_L12_read_scale_info(hdr, bs_frame, sci);
-        memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-        for (i = 0, igr = 0; igr < 3; igr++)
-        {
-            if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
-            {
-                i = 0;
-                drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
-            }
-            if (bs_frame->pos > bs_frame->limit)
-            {
-                drmp3dec_init(dec);
-                return 0;
-            }
-        }
-#endif
-    }
-    return success*drmp3_hdr_frame_samples(dec->header);
-}
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples)
-{
-    size_t i = 0;
-#if DRMP3_HAVE_SIMD
-    size_t aligned_count = num_samples & ~7;
-    for(; i < aligned_count; i+=8)
-    {
-        drmp3_f4 scale = DRMP3_VSET(32768.0f);
-        drmp3_f4 a = DRMP3_VMUL(DRMP3_VLD(&in[i  ]), scale);
-        drmp3_f4 b = DRMP3_VMUL(DRMP3_VLD(&in[i+4]), scale);
-#if DRMP3_HAVE_SSE
-        drmp3_f4 s16max = DRMP3_VSET( 32767.0f);
-        drmp3_f4 s16min = DRMP3_VSET(-32768.0f);
-        __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)),
-                                        _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min)));
-        out[i  ] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-        out[i+1] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-        out[i+2] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-        out[i+3] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-        out[i+4] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-        out[i+5] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-        out[i+6] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-        out[i+7] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-#else
-        int16x4_t pcma, pcmb;
-        a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-        b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-        pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-        pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-        vst1_lane_s16(out+i  , pcma, 0);
-        vst1_lane_s16(out+i+1, pcma, 1);
-        vst1_lane_s16(out+i+2, pcma, 2);
-        vst1_lane_s16(out+i+3, pcma, 3);
-        vst1_lane_s16(out+i+4, pcmb, 0);
-        vst1_lane_s16(out+i+5, pcmb, 1);
-        vst1_lane_s16(out+i+6, pcmb, 2);
-        vst1_lane_s16(out+i+7, pcmb, 3);
-#endif
-    }
-#endif
-    for(; i < num_samples; i++)
-    {
-        float sample = in[i] * 32768.0f;
-        if (sample >=  32766.5)
-            out[i] = (drmp3_int16) 32767;
-        else if (sample <= -32767.5)
-            out[i] = (drmp3_int16)-32768;
-        else
-        {
-            short s = (drmp3_int16)(sample + .5f);
-            s -= (s < 0);
-            out[i] = s;
-        }
-    }
-}
-#include <math.h>
-#if defined(SIZE_MAX)
-    #define DRMP3_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRMP3_SIZE_MAX  ((drmp3_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRMP3_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#ifndef DRMP3_SEEK_LEADING_MP3_FRAMES
-#define DRMP3_SEEK_LEADING_MP3_FRAMES   2
-#endif
-#define DRMP3_MIN_DATA_CHUNK_SIZE   16384
-#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE  DRMP3_MIN_DATA_CHUNK_SIZE*4
-#endif
-#ifndef DRMP3_ASSERT
-#include <assert.h>
-#define DRMP3_ASSERT(expression) assert(expression)
-#endif
-#ifndef DRMP3_COPY_MEMORY
-#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#ifndef DRMP3_ZERO_MEMORY
-#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
-#ifndef DRMP3_MALLOC
-#define DRMP3_MALLOC(sz) malloc((sz))
-#endif
-#ifndef DRMP3_REALLOC
-#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#ifndef DRMP3_FREE
-#define DRMP3_FREE(p) free((p))
-#endif
-#define DRMP3_COUNTOF(x)        (sizeof(x) / sizeof(x[0]))
-#define DRMP3_CLAMP(x, lo, hi)  (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
-#ifndef DRMP3_PI_D
-#define DRMP3_PI_D    3.14159265358979323846264
-#endif
-#define DRMP3_DEFAULT_RESAMPLER_LPF_ORDER   2
-static DRMP3_INLINE float drmp3_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static DRMP3_INLINE float drmp3_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-}
-static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            drmp3_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-    return a;
-}
-static DRMP3_INLINE double drmp3_sin(double x)
-{
-    return sin(x);
-}
-static DRMP3_INLINE double drmp3_exp(double x)
-{
-    return exp(x);
-}
-static DRMP3_INLINE double drmp3_cos(double x)
-{
-    return drmp3_sin((DRMP3_PI_D*0.5) - x);
-}
-static void* drmp3__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_MALLOC(sz);
-}
-static void* drmp3__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_REALLOC(p, sz);
-}
-static void drmp3__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRMP3_FREE(p);
-}
-static void* drmp3__malloc_from_callbacks(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRMP3_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-static void drmp3__free_from_callbacks(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-static drmp3_allocation_callbacks drmp3_copy_allocation_callbacks_or_defaults(const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return *pAllocationCallbacks;
-    } else {
-        drmp3_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drmp3__malloc_default;
-        allocationCallbacks.onRealloc = drmp3__realloc_default;
-        allocationCallbacks.onFree    = drmp3__free_default;
-        return allocationCallbacks;
-    }
-}
-static size_t drmp3__on_read(drmp3* pMP3, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead);
-    pMP3->streamCursor += bytesRead;
-    return bytesRead;
-}
-static drmp3_bool32 drmp3__on_seek(drmp3* pMP3, int offset, drmp3_seek_origin origin)
-{
-    DRMP3_ASSERT(offset >= 0);
-    if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) {
-        return DRMP3_FALSE;
-    }
-    if (origin == drmp3_seek_origin_start) {
-        pMP3->streamCursor = (drmp3_uint64)offset;
-    } else {
-        pMP3->streamCursor += offset;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3__on_seek_64(drmp3* pMP3, drmp3_uint64 offset, drmp3_seek_origin origin)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return drmp3__on_seek(pMP3, (int)offset, origin);
-    }
-    if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-    while (offset > 0) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!drmp3__on_seek(pMP3, (int)offset, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset = 0;
-        } else {
-            if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset -= 0x7FFFFFFF;
-        }
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-    if (pMP3->atEnd) {
-        return 0;
-    }
-    for (;;) {
-        drmp3dec_frame_info info;
-        if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
-            size_t bytesRead;
-            if (pMP3->pData != NULL) {
-                memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            }
-            pMP3->dataConsumed = 0;
-            if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-                newDataCap = DRMP3_DATA_CHUNK_SIZE;
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0;
-                }
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                if (pMP3->dataSize == 0) {
-                    pMP3->atEnd = DRMP3_TRUE;
-                    return 0;
-                }
-            }
-            pMP3->dataSize += bytesRead;
-        }
-        if (pMP3->dataSize > INT_MAX) {
-            pMP3->atEnd = DRMP3_TRUE;
-            return 0;
-        }
-        DRMP3_ASSERT(pMP3->pData != NULL);
-        DRMP3_ASSERT(pMP3->dataCapacity > 0);
-        pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);
-        if (info.frame_bytes > 0) {
-            pMP3->dataConsumed += (size_t)info.frame_bytes;
-            pMP3->dataSize     -= (size_t)info.frame_bytes;
-        }
-        if (pcmFramesRead > 0) {
-            pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
-            pMP3->pcmFramesConsumedInMP3Frame = 0;
-            pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-            pMP3->mp3FrameChannels = info.channels;
-            pMP3->mp3FrameSampleRate = info.hz;
-            break;
-        } else if (info.frame_bytes == 0) {
-            size_t bytesRead;
-            memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            pMP3->dataConsumed = 0;
-            if (pMP3->dataCapacity == pMP3->dataSize) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-                newDataCap = pMP3->dataCapacity + DRMP3_DATA_CHUNK_SIZE;
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0;
-                }
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                pMP3->atEnd = DRMP3_TRUE;
-                return 0;
-            }
-            pMP3->dataSize += bytesRead;
-        }
-    };
-    return pcmFramesRead;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    drmp3dec_frame_info info;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.pData != NULL);
-    if (pMP3->atEnd) {
-        return 0;
-    }
-    pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
-    if (pcmFramesRead > 0) {
-        pMP3->pcmFramesConsumedInMP3Frame  = 0;
-        pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-        pMP3->mp3FrameChannels             = info.channels;
-        pMP3->mp3FrameSampleRate           = info.hz;
-    }
-    pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
-    return pcmFramesRead;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) {
-        return drmp3_decode_next_frame_ex__memory(pMP3, pPCMFrames);
-    } else {
-        return drmp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames);
-    }
-}
-static drmp3_uint32 drmp3_decode_next_frame(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    return drmp3_decode_next_frame_ex(pMP3, (drmp3d_sample_t*)pMP3->pcmFrames);
-}
-#if 0
-static drmp3_uint32 drmp3_seek_next_frame(drmp3* pMP3)
-{
-    drmp3_uint32 pcmFrameCount;
-    DRMP3_ASSERT(pMP3 != NULL);
-    pcmFrameCount = drmp3_decode_next_frame_ex(pMP3, NULL);
-    if (pcmFrameCount == 0) {
-        return 0;
-    }
-    pMP3->currentPCMFrame             += pcmFrameCount;
-    pMP3->pcmFramesConsumedInMP3Frame  = pcmFrameCount;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    return pcmFrameCount;
-}
-#endif
-static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(onRead != NULL);
-    drmp3dec_init(&pMP3->decoder);
-    pMP3->onRead = onRead;
-    pMP3->onSeek = onSeek;
-    pMP3->pUserData = pUserData;
-    pMP3->allocationCallbacks = drmp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
-        return DRMP3_FALSE;
-    }
-    if (!drmp3_decode_next_frame(pMP3)) {
-        drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-        return DRMP3_FALSE;
-    }
-    pMP3->channels   = pMP3->mp3FrameChannels;
-    pMP3->sampleRate = pMP3->mp3FrameSampleRate;
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL || onRead == NULL) {
-        return DRMP3_FALSE;
-    }
-    DRMP3_ZERO_OBJECT(pMP3);
-    return drmp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks);
-}
-static size_t drmp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    size_t bytesRemaining;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos);
-    bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRMP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead);
-        pMP3->memory.currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-static drmp3_bool32 drmp3__on_seek_memory(void* pUserData, int byteOffset, drmp3_seek_origin origin)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    DRMP3_ASSERT(pMP3 != NULL);
-    if (origin == drmp3_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) {
-                byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos);
-            }
-        } else {
-            if (pMP3->memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pMP3->memory.currentReadPos;
-            }
-        }
-        pMP3->memory.currentReadPos += byteOffset;
-    } else {
-        if ((drmp3_uint32)byteOffset <= pMP3->memory.dataSize) {
-            pMP3->memory.currentReadPos = byteOffset;
-        } else {
-            pMP3->memory.currentReadPos = pMP3->memory.dataSize;
-        }
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    DRMP3_ZERO_OBJECT(pMP3);
-    if (pData == NULL || dataSize == 0) {
-        return DRMP3_FALSE;
-    }
-    pMP3->memory.pData = (const drmp3_uint8*)pData;
-    pMP3->memory.dataSize = dataSize;
-    pMP3->memory.currentReadPos = 0;
-    return drmp3_init_internal(pMP3, drmp3__on_read_memory, drmp3__on_seek_memory, pMP3, pAllocationCallbacks);
-}
-#ifndef DR_MP3_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#include <errno.h>
-static drmp3_result drmp3_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRMP3_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRMP3_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRMP3_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRMP3_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRMP3_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRMP3_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRMP3_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRMP3_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRMP3_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRMP3_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRMP3_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRMP3_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRMP3_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRMP3_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRMP3_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRMP3_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRMP3_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRMP3_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRMP3_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRMP3_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRMP3_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRMP3_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRMP3_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRMP3_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRMP3_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRMP3_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRMP3_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRMP3_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRMP3_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRMP3_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRMP3_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRMP3_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRMP3_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRMP3_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRMP3_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRMP3_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRMP3_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRMP3_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRMP3_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRMP3_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRMP3_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRMP3_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRMP3_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRMP3_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRMP3_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRMP3_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRMP3_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRMP3_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRMP3_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRMP3_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRMP3_ERROR;
-    #endif
-        default: return DRMP3_ERROR;
-    }
-}
-static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drmp3_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drmp3_result result = drmp3_result_from_errno(errno);
-        if (result == DRMP3_SUCCESS) {
-            result = DRMP3_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRMP3_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRMP3_HAS_WFOPEN
-    #endif
-#endif
-static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-#if defined(DRMP3_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drmp3_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drmp3_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRMP3_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drmp3_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drmp3__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRMP3_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRMP3_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRMP3_ERROR;
-    }
-#endif
-    return DRMP3_SUCCESS;
-}
-static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-static drmp3_bool32 drmp3__on_seek_stdio(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drmp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-    if (drmp3_fopen(&pFile, pFilePath, "rb") != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-    if (drmp3_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRMP3_TRUE;
-}
-#endif
-DRMP3_API void drmp3_uninit(drmp3* pMP3)
-{
-    if (pMP3 == NULL) {
-        return;
-    }
-#ifndef DR_MP3_NO_STDIO
-    if (pMP3->onRead == drmp3__on_read_stdio) {
-        FILE* pFile = (FILE*)pMP3->pUserData;
-        if (pFile != NULL) {
-            fclose(pFile);
-            pMP3->pUserData = NULL;
-        }
-    }
-#endif
-    drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-}
-#if defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_f32_to_s16(drmp3_int16* dst, const float* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    drmp3_uint64 i4;
-    drmp3_uint64 sampleCount4;
-    i = 0;
-    sampleCount4 = sampleCount >> 2;
-    for (i4 = 0; i4 < sampleCount4; i4 += 1) {
-        float x0 = src[i+0];
-        float x1 = src[i+1];
-        float x2 = src[i+2];
-        float x3 = src[i+3];
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-        dst[i+0] = (drmp3_int16)x0;
-        dst[i+1] = (drmp3_int16)x1;
-        dst[i+2] = (drmp3_int16)x2;
-        dst[i+3] = (drmp3_int16)x3;
-        i += 4;
-    }
-    for (; i < sampleCount; i += 1) {
-        float x = src[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        x = x * 32767.0f;
-        dst[i] = (drmp3_int16)x;
-    }
-}
-#endif
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_s16_to_f32(float* dst, const drmp3_int16* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    for (i = 0; i < sampleCount; i += 1) {
-        float x = (float)src[i];
-        x = x * 0.000030517578125f;
-        dst[i] = x;
-    }
-}
-#endif
-static drmp3_uint64 drmp3_read_pcm_frames_raw(drmp3* pMP3, drmp3_uint64 framesToRead, void* pBufferOut)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-    while (framesToRead > 0) {
-        drmp3_uint32 framesToConsume = (drmp3_uint32)DRMP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead);
-        if (pBufferOut != NULL) {
-        #if defined(DR_MP3_FLOAT_OUTPUT)
-            float* pFramesOutF32 = (float*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(float) * totalFramesRead                   * pMP3->channels);
-            float* pFramesInF32  = (float*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels);
-        #else
-            drmp3_int16* pFramesOutS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(drmp3_int16) * totalFramesRead                   * pMP3->channels);
-            drmp3_int16* pFramesInS16  = (drmp3_int16*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(drmp3_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(drmp3_int16) * framesToConsume * pMP3->channels);
-        #endif
-        }
-        pMP3->currentPCMFrame              += framesToConsume;
-        pMP3->pcmFramesConsumedInMP3Frame  += framesToConsume;
-        pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume;
-        totalFramesRead                    += framesToConsume;
-        framesToRead                       -= framesToConsume;
-        if (framesToRead == 0) {
-            break;
-        }
-        DRMP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0);
-        if (drmp3_decode_next_frame(pMP3) == 0) {
-            break;
-        }
-    }
-    return totalFramesRead;
-}
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    {
-        drmp3_int16 pTempS16[8192];
-        drmp3_uint64 totalPCMFramesRead = 0;
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempS16) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16);
-            if (framesJustRead == 0) {
-                break;
-            }
-            drmp3_s16_to_f32((float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-        return totalPCMFramesRead;
-    }
-#endif
-}
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    {
-        float pTempF32[4096];
-        drmp3_uint64 totalPCMFramesRead = 0;
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempF32) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32);
-            if (framesJustRead == 0) {
-                break;
-            }
-            drmp3_f32_to_s16((drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-        return totalPCMFramesRead;
-    }
-#endif
-}
-static void drmp3_reset(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    pMP3->pcmFramesConsumedInMP3Frame = 0;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    pMP3->currentPCMFrame = 0;
-    pMP3->dataSize = 0;
-    pMP3->atEnd = DRMP3_FALSE;
-    drmp3dec_init(&pMP3->decoder);
-}
-static drmp3_bool32 drmp3_seek_to_start_of_stream(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onSeek != NULL);
-    if (!drmp3__on_seek(pMP3, 0, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    drmp3_reset(pMP3);
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_forward_by_pcm_frames__brute_force(drmp3* pMP3, drmp3_uint64 frameOffset)
-{
-    drmp3_uint64 framesRead;
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    framesRead = drmp3_read_pcm_frames_f32(pMP3, frameOffset, NULL);
-#else
-    framesRead = drmp3_read_pcm_frames_s16(pMP3, frameOffset, NULL);
-#endif
-    if (framesRead != frameOffset) {
-        return DRMP3_FALSE;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_to_pcm_frame__brute_force(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    if (frameIndex == pMP3->currentPCMFrame) {
-        return DRMP3_TRUE;
-    }
-    if (frameIndex < pMP3->currentPCMFrame) {
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-    }
-    DRMP3_ASSERT(frameIndex >= pMP3->currentPCMFrame);
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame));
-}
-static drmp3_bool32 drmp3_find_closest_seek_point(drmp3* pMP3, drmp3_uint64 frameIndex, drmp3_uint32* pSeekPointIndex)
-{
-    drmp3_uint32 iSeekPoint;
-    DRMP3_ASSERT(pSeekPointIndex != NULL);
-    *pSeekPointIndex = 0;
-    if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) {
-        return DRMP3_FALSE;
-    }
-    for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) {
-        if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) {
-            break;
-        }
-        *pSeekPointIndex = iSeekPoint;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_to_pcm_frame__seek_table(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    drmp3_seek_point seekPoint;
-    drmp3_uint32 priorSeekPointIndex;
-    drmp3_uint16 iMP3Frame;
-    drmp3_uint64 leftoverFrames;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->pSeekPoints != NULL);
-    DRMP3_ASSERT(pMP3->seekPointCount > 0);
-    if (drmp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) {
-        seekPoint = pMP3->pSeekPoints[priorSeekPointIndex];
-    } else {
-        seekPoint.seekPosInBytes     = 0;
-        seekPoint.pcmFrameIndex      = 0;
-        seekPoint.mp3FramesToDiscard = 0;
-        seekPoint.pcmFramesToDiscard = 0;
-    }
-    if (!drmp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    drmp3_reset(pMP3);
-    for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) {
-        drmp3_uint32 pcmFramesRead;
-        drmp3d_sample_t* pPCMFrames;
-        pPCMFrames = NULL;
-        if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) {
-            pPCMFrames = (drmp3d_sample_t*)pMP3->pcmFrames;
-        }
-        pcmFramesRead = drmp3_decode_next_frame_ex(pMP3, pPCMFrames);
-        if (pcmFramesRead == 0) {
-            return DRMP3_FALSE;
-        }
-    }
-    pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard;
-    leftoverFrames = frameIndex - pMP3->currentPCMFrame;
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames);
-}
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    if (pMP3 == NULL || pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (frameIndex == 0) {
-        return drmp3_seek_to_start_of_stream(pMP3);
-    }
-    if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) {
-        return drmp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex);
-    } else {
-        return drmp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex);
-    }
-}
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount)
-{
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalPCMFrameCount;
-    drmp3_uint64 totalMP3FrameCount;
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-    currentPCMFrame = pMP3->currentPCMFrame;
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-    totalPCMFrameCount = 0;
-    totalMP3FrameCount = 0;
-    for (;;) {
-        drmp3_uint32 pcmFramesInCurrentMP3Frame;
-        pcmFramesInCurrentMP3Frame = drmp3_decode_next_frame_ex(pMP3, NULL);
-        if (pcmFramesInCurrentMP3Frame == 0) {
-            break;
-        }
-        totalPCMFrameCount += pcmFramesInCurrentMP3Frame;
-        totalMP3FrameCount += 1;
-    }
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-    if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-        return DRMP3_FALSE;
-    }
-    if (pMP3FrameCount != NULL) {
-        *pMP3FrameCount = totalMP3FrameCount;
-    }
-    if (pPCMFrameCount != NULL) {
-        *pPCMFrameCount = totalPCMFrameCount;
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalPCMFrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) {
-        return 0;
-    }
-    return totalPCMFrameCount;
-}
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalMP3FrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) {
-        return 0;
-    }
-    return totalMP3FrameCount;
-}
-static void drmp3__accumulate_running_pcm_frame_count(drmp3* pMP3, drmp3_uint32 pcmFrameCountIn, drmp3_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart)
-{
-    float srcRatio;
-    float pcmFrameCountOutF;
-    drmp3_uint32 pcmFrameCountOut;
-    srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate;
-    DRMP3_ASSERT(srcRatio > 0);
-    pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio);
-    pcmFrameCountOut  = (drmp3_uint32)pcmFrameCountOutF;
-    *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut;
-    *pRunningPCMFrameCount += pcmFrameCountOut;
-}
-typedef struct
-{
-    drmp3_uint64 bytePos;
-    drmp3_uint64 pcmFrameIndex;
-} drmp3__seeking_mp3_frame_info;
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    drmp3_uint32 seekPointCount;
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalMP3FrameCount;
-    drmp3_uint64 totalPCMFrameCount;
-    if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) {
-        return DRMP3_FALSE;
-    }
-    seekPointCount = *pSeekPointCount;
-    if (seekPointCount == 0) {
-        return DRMP3_FALSE;
-    }
-    currentPCMFrame = pMP3->currentPCMFrame;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) {
-        return DRMP3_FALSE;
-    }
-    if (totalMP3FrameCount < DRMP3_SEEK_LEADING_MP3_FRAMES+1) {
-        seekPointCount = 1;
-        pSeekPoints[0].seekPosInBytes     = 0;
-        pSeekPoints[0].pcmFrameIndex      = 0;
-        pSeekPoints[0].mp3FramesToDiscard = 0;
-        pSeekPoints[0].pcmFramesToDiscard = 0;
-    } else {
-        drmp3_uint64 pcmFramesBetweenSeekPoints;
-        drmp3__seeking_mp3_frame_info mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES+1];
-        drmp3_uint64 runningPCMFrameCount = 0;
-        float runningPCMFrameCountFractionalPart = 0;
-        drmp3_uint64 nextTargetPCMFrame;
-        drmp3_uint32 iMP3Frame;
-        drmp3_uint32 iSeekPoint;
-        if (seekPointCount > totalMP3FrameCount-1) {
-            seekPointCount = (drmp3_uint32)totalMP3FrameCount-1;
-        }
-        pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1);
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        for (iMP3Frame = 0; iMP3Frame < DRMP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) {
-            drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-            DRMP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize);
-            mp3FrameInfo[iMP3Frame].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-            mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount;
-            pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-            if (pcmFramesInCurrentMP3FrameIn == 0) {
-                return DRMP3_FALSE;
-            }
-            drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-        }
-        nextTargetPCMFrame = 0;
-        for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
-            nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
-            for (;;) {
-                if (nextTargetPCMFrame < runningPCMFrameCount) {
-                    pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                    pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                    pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                    pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                    break;
-                } else {
-                    size_t i;
-                    drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-                    for (i = 0; i < DRMP3_COUNTOF(mp3FrameInfo)-1; ++i) {
-                        mp3FrameInfo[i] = mp3FrameInfo[i+1];
-                    }
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount;
-                    pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-                    if (pcmFramesInCurrentMP3FrameIn == 0) {
-                        pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                        pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                        pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                        pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                        break;
-                    }
-                    drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-                }
-            }
-        }
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-            return DRMP3_FALSE;
-        }
-    }
-    *pSeekPointCount = seekPointCount;
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (seekPointCount == 0 || pSeekPoints == NULL) {
-        pMP3->seekPointCount = 0;
-        pMP3->pSeekPoints = NULL;
-    } else {
-        pMP3->seekPointCount = seekPointCount;
-        pMP3->pSeekPoints = pSeekPoints;
-    }
-    return DRMP3_TRUE;
-}
-static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    float* pFrames = NULL;
-    float temp[4096];
-    DRMP3_ASSERT(pMP3 != NULL);
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            float* pNewFrames;
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(float);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-            pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float)));
-        totalFramesRead += framesJustRead;
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-    drmp3_uninit(pMP3);
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-    return pFrames;
-}
-static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    drmp3_int16* pFrames = NULL;
-    drmp3_int16 temp[4096];
-    DRMP3_ASSERT(pMP3 != NULL);
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            drmp3_int16* pNewFrames;
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(drmp3_int16);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-            pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(drmp3_int16)));
-        totalFramesRead += framesJustRead;
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-    drmp3_uninit(pMP3);
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-    return pFrames;
-}
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#endif
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return drmp3__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return drmp3__malloc_default(sz, NULL);
-    }
-}
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drmp3__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drmp3__free_default(p, NULL);
-    }
-}
-#endif
-/* dr_mp3_c end */
-#endif  /* DRMP3_IMPLEMENTATION */
-#endif  /* MA_NO_MP3 */
-
-
-/* End globally disabled warnings. */
-#if defined(_MSC_VER)
-    #pragma warning(pop)
-#endif
-
-#endif  /* miniaudio_c */
-#endif  /* MINIAUDIO_IMPLEMENTATION */
-
-/*
-RELEASE NOTES - VERSION 0.10.x
-==============================
-Version 0.10 includes major API changes and refactoring, mostly concerned with the data conversion system. Data conversion is performed internally to convert
-audio data between the format requested when initializing the `ma_device` object and the format of the internal device used by the backend. The same applies
-to the `ma_decoder` object. The previous design has several design flaws and missing features which necessitated a complete redesign.
-
-
-Changes to Data Conversion
---------------------------
-The previous data conversion system used callbacks to deliver input data for conversion. This design works well in some specific situations, but in other
-situations it has some major readability and maintenance issues. The decision was made to replace this with a more iterative approach where you just pass in a
-pointer to the input data directly rather than dealing with a callback.
-
-The following are the data conversion APIs that have been removed and their replacements:
-
-  - ma_format_converter -> ma_convert_pcm_frames_format()
-  - ma_channel_router   -> ma_channel_converter
-  - ma_src              -> ma_resampler
-  - ma_pcm_converter    -> ma_data_converter
-
-The previous conversion APIs accepted a callback in their configs. There are no longer any callbacks to deal with. Instead you just pass the data into the
-`*_process_pcm_frames()` function as a pointer to a buffer.
-
-The simplest aspect of data conversion is sample format conversion. To convert between two formats, just call `ma_convert_pcm_frames_format()`. Channel
-conversion is also simple which you can do with `ma_channel_converter` via `ma_channel_converter_process_pcm_frames()`.
-
-Resampling is more complicated because the number of output frames that are processed is different to the number of input frames that are consumed. When you
-call `ma_resampler_process_pcm_frames()` you need to pass in the number of input frames available for processing and the number of output frames you want to
-output. Upon returning they will receive the number of input frames that were consumed and the number of output frames that were generated.
-
-The `ma_data_converter` API is a wrapper around format, channel and sample rate conversion and handles all of the data conversion you'll need which probably
-makes it the best option if you need to do data conversion.
-
-In addition to changes to the API design, a few other changes have been made to the data conversion pipeline:
-
-  - The sinc resampler has been removed. This was completely broken and never actually worked properly.
-  - The linear resampler now uses low-pass filtering to remove aliasing. The quality of the low-pass filter can be controlled via the resampler config with the
-    `lpfOrder` option, which has a maximum value of MA_MAX_FILTER_ORDER.
-  - Data conversion now supports s16 natively which runs through a fixed point pipeline. Previously everything needed to be converted to floating point before
-    processing, whereas now both s16 and f32 are natively supported. Other formats still require conversion to either s16 or f32 prior to processing, however
-    `ma_data_converter` will handle this for you.
-
-
-Custom Memory Allocators
-------------------------
-miniaudio has always supported macro level customization for memory allocation via MA_MALLOC, MA_REALLOC and MA_FREE, however some scenarios require more
-flexibility by allowing a user data pointer to be passed to the custom allocation routines. Support for this has been added to version 0.10 via the
-`ma_allocation_callbacks` structure. Anything making use of heap allocations has been updated to accept this new structure.
-
-The `ma_context_config` structure has been updated with a new member called `allocationCallbacks`. Leaving this set to it's defaults returned by
-`ma_context_config_init()` will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. Likewise, The `ma_decoder_config` structure has been updated in the same
-way, and leaving everything as-is after `ma_decoder_config_init()` will cause it to use the same defaults.
-
-The following APIs have been updated to take a pointer to a `ma_allocation_callbacks` object. Setting this parameter to NULL will cause it to use defaults.
-Otherwise they will use the relevant callback in the structure.
-
-  - ma_malloc()
-  - ma_realloc()
-  - ma_free()
-  - ma_aligned_malloc()
-  - ma_aligned_free()
-  - ma_rb_init() / ma_rb_init_ex()
-  - ma_pcm_rb_init() / ma_pcm_rb_init_ex()
-
-Note that you can continue to use MA_MALLOC, MA_REALLOC and MA_FREE as per normal. These will continue to be used by default if you do not specify custom
-allocation callbacks.
-
-
-Buffer and Period Configuration Changes
----------------------------------------
-The way in which the size of the internal buffer and periods are specified in the device configuration have changed. In previous versions, the config variables
-`bufferSizeInFrames` and `bufferSizeInMilliseconds` defined the size of the entire buffer, with the size of a period being the size of this variable divided by
-the period count. This became confusing because people would expect the value of `bufferSizeInFrames` or `bufferSizeInMilliseconds` to independantly determine
-latency, when in fact it was that value divided by the period count that determined it. These variables have been removed and replaced with new ones called
-`periodSizeInFrames` and `periodSizeInMilliseconds`.
-
-These new configuration variables work in the same way as their predecessors in that if one is set to 0, the other will be used, but the main difference is
-that you now set these to you desired latency rather than the size of the entire buffer. The benefit of this is that it's much easier and less confusing to
-configure latency.
-
-The following unused APIs have been removed:
-
-    ma_get_default_buffer_size_in_milliseconds()
-    ma_get_default_buffer_size_in_frames()
-
-The following macros have been removed:
-
-    MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY
-    MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE
-
-
-Other API Changes
------------------
-Other less major API changes have also been made in version 0.10.
-
-`ma_device_set_stop_callback()` has been removed. If you require a stop callback, you must now set it via the device config just like the data callback.
-
-The `ma_sine_wave` API has been replaced with a more general API called `ma_waveform`. This supports generation of different types of waveforms, including
-sine, square, triangle and sawtooth. Use `ma_waveform_init()` in place of `ma_sine_wave_init()` to initialize the waveform object. This takes a configuration
-object called `ma_waveform_config` which defines the properties of the waveform. Use `ma_waveform_config_init()` to initialize a `ma_waveform_config` object.
-Use `ma_waveform_read_pcm_frames()` in place of `ma_sine_wave_read_f32()` and `ma_sine_wave_read_f32_ex()`.
-
-`ma_convert_frames()` and `ma_convert_frames_ex()` have been changed. Both of these functions now take a new parameter called `frameCountOut` which specifies
-the size of the output buffer in PCM frames. This has been added for safety. In addition to this, the parameters for `ma_convert_frames_ex()` have changed to
-take a pointer to a `ma_data_converter_config` object to specify the input and output formats to convert between. This was done to make it more flexible, to
-prevent the parameter list getting too long, and to prevent API breakage whenever a new conversion property is added.
-
-`ma_calculate_frame_count_after_src()` has been renamed to `ma_calculate_frame_count_after_resampling()` for consistency with the new `ma_resampler` API.
-
-
-Filters
--------
-The following filters have been added:
-
-    |-------------|-------------------------------------------------------------------|
-    | API         | Description                                                       |
-    |-------------|-------------------------------------------------------------------|
-    | ma_biquad   | Biquad filter (transposed direct form 2)                          |
-    | ma_lpf1     | First order low-pass filter                                       |
-    | ma_lpf2     | Second order low-pass filter                                      |
-    | ma_lpf      | High order low-pass filter (Butterworth)                          |
-    | ma_hpf1     | First order high-pass filter                                      |
-    | ma_hpf2     | Second order high-pass filter                                     |
-    | ma_hpf      | High order high-pass filter (Butterworth)                         |
-    | ma_bpf2     | Second order band-pass filter                                     |
-    | ma_bpf      | High order band-pass filter                                       |
-    | ma_peak2    | Second order peaking filter                                       |
-    | ma_notch2   | Second order notching filter                                      |
-    | ma_loshelf2 | Second order low shelf filter                                     |
-    | ma_hishelf2 | Second order high shelf filter                                    |
-    |-------------|-------------------------------------------------------------------|
-
-These filters all support 32-bit floating point and 16-bit signed integer formats natively. Other formats need to be converted beforehand.
-
-
-Sine, Square, Triangle and Sawtooth Waveforms
----------------------------------------------
-Previously miniaudio supported only sine wave generation. This has now been generalized to support sine, square, triangle and sawtooth waveforms. The old
-`ma_sine_wave` API has been removed and replaced with the `ma_waveform` API. Use `ma_waveform_config_init()` to initialize a config object, and then pass it
-into `ma_waveform_init()`. Then use `ma_waveform_read_pcm_frames()` to read PCM data.
-
-
-Noise Generation
-----------------
-A noise generation API has been added. This is used via the `ma_noise` API. Currently white, pink and Brownian noise is supported. The `ma_noise` API is
-similar to the waveform API. Use `ma_noise_config_init()` to initialize a config object, and then pass it into `ma_noise_init()` to initialize a `ma_noise`
-object. Then use `ma_noise_read_pcm_frames()` to read PCM data.
-
-
-Miscellaneous Changes
----------------------
-The MA_NO_STDIO option has been removed. This would disable file I/O APIs, however this has proven to be too hard to maintain for it's perceived value and was
-therefore removed.
-
-Internal functions have all been made static where possible. If you get warnings about unused functions, please submit a bug report.
-
-The `ma_device` structure is no longer defined as being aligned to MA_SIMD_ALIGNMENT. This resulted in a possible crash when allocating a `ma_device` object on
-the heap, but not aligning it to MA_SIMD_ALIGNMENT. This crash would happen due to the compiler seeing the alignment specified on the structure and assuming it
-was always aligned as such and thinking it was safe to emit alignment-dependant SIMD instructions. Since miniaudio's philosophy is for things to just work,
-this has been removed from all structures.
-
-Results codes have been overhauled. Unnecessary result codes have been removed, and some have been renumbered for organisation purposes. If you are are binding
-maintainer you will need to update your result codes. Support has also been added for retrieving a human readable description of a given result code via the
-`ma_result_description()` API.
-
-ALSA: The automatic format conversion, channel conversion and resampling performed by ALSA is now disabled by default as they were causing some compatibility
-issues with certain devices and configurations. These can be individually enabled via the device config:
-
-    ```c
-    deviceConfig.alsa.noAutoFormat   = MA_TRUE;
-    deviceConfig.alsa.noAutoChannels = MA_TRUE;
-    deviceConfig.alsa.noAutoResample = MA_TRUE;
-    ```
-*/
-
-/*
-RELEASE NOTES - VERSION 0.9.x
-=============================
-Version 0.9 includes major API changes, centered mostly around full-duplex and the rebrand to "miniaudio". Before I go into detail about the major changes I
-would like to apologize. I know it's annoying dealing with breaking API changes, but I think it's best to get these changes out of the way now while the
-library is still relatively young and unknown.
-
-There's been a lot of refactoring with this release so there's a good chance a few bugs have been introduced. I apologize in advance for this. You may want to
-hold off on upgrading for the short term if you're worried. If mini_al v0.8.14 works for you, and you don't need full-duplex support, you can avoid upgrading
-(though you won't be getting future bug fixes).
-
-
-Rebranding to "miniaudio"
--------------------------
-The decision was made to rename mini_al to miniaudio. Don't worry, it's the same project. The reason for this is simple:
-
-1) Having the word "audio" in the title makes it immediately clear that the library is related to audio; and
-2) I don't like the look of the underscore.
-
-This rebrand has necessitated a change in namespace from "mal" to "ma". I know this is annoying, and I apologize, but it's better to get this out of the road
-now rather than later. Also, since there are necessary API changes for full-duplex support I think it's better to just get the namespace change over and done
-with at the same time as the full-duplex changes. I'm hoping this will be the last of the major API changes. Fingers crossed!
-
-The implementation define is now "#define MINIAUDIO_IMPLEMENTATION". You can also use "#define MA_IMPLEMENTATION" if that's your preference.
-
-
-Full-Duplex Support
--------------------
-The major feature added to version 0.9 is full-duplex. This has necessitated a few API changes.
-
-1) The data callback has now changed. Previously there was one type of callback for playback and another for capture. I wanted to avoid a third callback just
-   for full-duplex so the decision was made to break this API and unify the callbacks. Now, there is just one callback which is the same for all three modes
-   (playback, capture, duplex). The new callback looks like the following:
-
-       void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-   This callback allows you to move data straight out of the input buffer and into the output buffer in full-duplex mode. In playback-only mode, pInput will be
-   null. Likewise, pOutput will be null in capture-only mode. The sample count is no longer returned from the callback since it's not necessary for miniaudio
-   anymore.
-
-2) The device config needed to change in order to support full-duplex. Full-duplex requires the ability to allow the client to choose a different PCM format
-   for the playback and capture sides. The old ma_device_config object simply did not allow this and needed to change. With these changes you now specify the
-   device ID, format, channels, channel map and share mode on a per-playback and per-capture basis (see example below). The sample rate must be the same for
-   playback and capture.
-
-   Since the device config API has changed I have also decided to take the opportunity to simplify device initialization. Now, the device ID, device type and
-   callback user data are set in the config. ma_device_init() is now simplified down to taking just the context, device config and a pointer to the device
-   object being initialized. The rationale for this change is that it just makes more sense to me that these are set as part of the config like everything
-   else.
-
-   Example device initialization:
-
-       ma_device_config config = ma_device_config_init(ma_device_type_duplex);   // Or ma_device_type_playback or ma_device_type_capture.
-       config.playback.pDeviceID = &myPlaybackDeviceID; // Or NULL for the default playback device.
-       config.playback.format    = ma_format_f32;
-       config.playback.channels  = 2;
-       config.capture.pDeviceID  = &myCaptureDeviceID;  // Or NULL for the default capture device.
-       config.capture.format     = ma_format_s16;
-       config.capture.channels   = 1;
-       config.sampleRate         = 44100;
-       config.dataCallback       = data_callback;
-       config.pUserData          = &myUserData;
-
-       result = ma_device_init(&myContext, &config, &device);
-       if (result != MA_SUCCESS) {
-           ... handle error ...
-       }
-
-   Note that the "onDataCallback" member of ma_device_config has been renamed to "dataCallback". Also, "onStopCallback" has been renamed to "stopCallback".
-
-This is the first pass for full-duplex and there is a known bug. You will hear crackling on the following backends when sample rate conversion is required for
-the playback device:
-  - Core Audio
-  - JACK
-  - AAudio
-  - OpenSL
-  - WebAudio
-
-In addition to the above, not all platforms have been absolutely thoroughly tested simply because I lack the hardware for such thorough testing. If you
-experience a bug, an issue report on GitHub or an email would be greatly appreciated (and a sample program that reproduces the issue if possible).
-
-
-Other API Changes
------------------
-In addition to the above, the following API changes have been made:
-
-- The log callback is no longer passed to ma_context_config_init(). Instead you need to set it manually after initialization.
-- The onLogCallback member of ma_context_config has been renamed to "logCallback".
-- The log callback now takes a logLevel parameter. The new callback looks like: void log_callback(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-  - You can use ma_log_level_to_string() to convert the logLevel to human readable text if you want to log it.
-- Some APIs have been renamed:
-  - mal_decoder_read()          -> ma_decoder_read_pcm_frames()
-  - mal_decoder_seek_to_frame() -> ma_decoder_seek_to_pcm_frame()
-  - mal_sine_wave_read()        -> ma_sine_wave_read_f32()
-  - mal_sine_wave_read_ex()     -> ma_sine_wave_read_f32_ex()
-- Some APIs have been removed:
-  - mal_device_get_buffer_size_in_bytes()
-  - mal_device_set_recv_callback()
-  - mal_device_set_send_callback()
-  - mal_src_set_input_sample_rate()
-  - mal_src_set_output_sample_rate()
-- Error codes have been rearranged. If you're a binding maintainer you will need to update.
-- The ma_backend enums have been rearranged to priority order. The rationale for this is to simplify automatic backend selection and to make it easier to see
-  the priority. If you're a binding maintainer you will need to update.
-- ma_dsp has been renamed to ma_pcm_converter. The rationale for this change is that I'm expecting "ma_dsp" to conflict with some future planned high-level
-  APIs.
-- For functions that take a pointer/count combo, such as ma_decoder_read_pcm_frames(), the parameter order has changed so that the pointer comes before the
-  count. The rationale for this is to keep it consistent with things like memcpy().
-
-
-Miscellaneous Changes
----------------------
-The following miscellaneous changes have also been made.
-
-- The AAudio backend has been added for Android 8 and above. This is Android's new "High-Performance Audio" API. (For the record, this is one of the nicest
-  audio APIs out there, just behind the BSD audio APIs).
-- The WebAudio backend has been added. This is based on ScriptProcessorNode. This removes the need for SDL.
-- The SDL and OpenAL backends have been removed. These were originally implemented to add support for platforms for which miniaudio was not explicitly
-  supported. These are no longer needed and have therefore been removed.
-- Device initialization now fails if the requested share mode is not supported. If you ask for exclusive mode, you either get an exclusive mode device, or an
-  error. The rationale for this change is to give the client more control over how to handle cases when the desired shared mode is unavailable.
-- A lock-free ring buffer API has been added. There are two varients of this. "ma_rb" operates on bytes, whereas "ma_pcm_rb" operates on PCM frames.
-- The library is now licensed as a choice of Public Domain (Unlicense) _or_ MIT-0 (No Attribution) which is the same as MIT, but removes the attribution
-  requirement. The rationale for this is to support countries that don't recognize public domain.
-*/
-
-/*
-REVISION HISTORY
-================
-v0.10.33 - 2021-04-04
-  - Core Audio: Fix a memory leak.
-  - Core Audio: Fix a bug where the performance profile is not being used by playback devices.
-  - JACK: Fix loading of 64-bit JACK on Windows.
-  - Fix a calculation error and add a safety check to the following APIs to prevent a division by zero:
-    - ma_calculate_buffer_size_in_milliseconds_from_frames()
-    - ma_calculate_buffer_size_in_frames_from_milliseconds()
-  - Fix compilation errors relating to c89atomic.
-  - Update FLAC decoder.
-
-v0.10.32 - 2021-02-23
-  - WASAPI: Fix a deadlock in exclusive mode.
-  - WASAPI: No longer return an error from ma_context_get_device_info() when an exclusive mode format
-    cannot be retrieved.
-  - WASAPI: Attempt to fix some bugs with device uninitialization.
-  - PulseAudio: Yet another refactor, this time to remove the dependency on `pa_threaded_mainloop`.
-  - Web Audio: Fix a bug on Chrome and any other browser using the same engine.
-  - Web Audio: Automatically start the device on some user input if the device has been started. This
-    is to work around Google's policy of not starting audio if no user input has yet been performed.
-  - Fix a bug where thread handles are not being freed.
-  - Fix some static analysis warnings in FLAC, WAV and MP3 decoders.
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-  - Update to latest version of c89atomic.
-  - Internal refactoring to migrate over to the new backend callback system for the following backends:
-    - PulseAudio
-    - ALSA
-    - Core Audio
-    - AAudio
-    - OpenSL|ES
-    - OSS
-    - audio(4)
-    - sndio
-
-v0.10.31 - 2021-01-17
-  - Make some functions const correct.
-  - Update ma_data_source_read_pcm_frames() to initialize pFramesRead to 0 for safety.
-  - Add the MA_ATOMIC annotation for use with variables that should be used atomically and remove unnecessary volatile qualifiers.
-  - Add support for enabling only specific backends at compile time. This is the reverse of the pre-existing system. With the new
-    system, all backends are first disabled with `MA_ENABLE_ONLY_SPECIFIC_BACKENDS`, which is then followed with `MA_ENABLE_*`. The
-    old system where you disable backends with `MA_NO_*` still exists and is still the default.
-
-v0.10.30 - 2021-01-10
-  - Fix a crash in ma_audio_buffer_read_pcm_frames().
-  - Update spinlock APIs to take a volatile parameter as input.
-  - Silence some unused parameter warnings.
-  - Fix a warning on GCC when compiling as C++.
-
-v0.10.29 - 2020-12-26
-  - Fix some subtle multi-threading bugs on non-x86 platforms.
-  - Fix a bug resulting in superfluous memory allocations when enumerating devices.
-  - Core Audio: Fix a compilation error when compiling for iOS.
-
-v0.10.28 - 2020-12-16
-  - Fix a crash when initializing a POSIX thread.
-  - OpenSL|ES: Respect the MA_NO_RUNTIME_LINKING option.
-
-v0.10.27 - 2020-12-04
-  - Add support for dynamically configuring some properties of `ma_noise` objects post-initialization.
-  - Add support for configuring the channel mixing mode in the device config.
-  - Fix a bug with simple channel mixing mode (drop or silence excess channels).
-  - Fix some bugs with trying to access uninitialized variables.
-  - Fix some errors with stopping devices for synchronous backends where the backend's stop callback would get fired twice.
-  - Fix a bug in the decoder due to using an uninitialized variable.
-  - Fix some data race errors.
-
-v0.10.26 - 2020-11-24
-  - WASAPI: Fix a bug where the exclusive mode format may not be retrieved correctly due to accessing freed memory.
-  - Fix a bug with ma_waveform where glitching occurs after changing frequency.
-  - Fix compilation with OpenWatcom.
-  - Fix compilation with TCC.
-  - Fix compilation with Digital Mars.
-  - Fix compilation warnings.
-  - Remove bitfields from public structures to aid in binding maintenance.
-
-v0.10.25 - 2020-11-15
-  - PulseAudio: Fix a bug where the stop callback isn't fired.
-  - WebAudio: Fix an error that occurs when Emscripten increases the size of it's heap.
-  - Custom Backends: Change the onContextInit and onDeviceInit callbacks to take a parameter which is a pointer to the config that was
-    passed into ma_context_init() and ma_device_init(). This replaces the deviceType parameter of onDeviceInit.
-  - Fix compilation warnings on older versions of GCC.
-
-v0.10.24 - 2020-11-10
-  - Fix a bug where initialization of a backend can fail due to some bad state being set from a prior failed attempt at initializing a
-    lower priority backend.
-
-v0.10.23 - 2020-11-09
-  - AAudio: Add support for configuring a playback stream's usage.
-  - Fix a compilation error when all built-in asynchronous backends are disabled at compile time.
-  - Fix compilation errors when compiling as C++.
-
-v0.10.22 - 2020-11-08
-  - Add support for custom backends.
-  - Add support for detecting default devices during device enumeration and with `ma_context_get_device_info()`.
-  - Refactor to the PulseAudio backend. This simplifies the implementation and fixes a capture bug.
-  - ALSA: Fix a bug in `ma_context_get_device_info()` where the PCM handle is left open in the event of an error.
-  - Core Audio: Further improvements to sample rate selection.
-  - Core Audio: Fix some bugs with capture mode.
-  - OpenSL: Add support for configuring stream types and recording presets.
-  - AAudio: Add support for configuring content types and input presets.
-  - Fix bugs in `ma_decoder_init_file*()` where the file handle is not closed after a decoding error.
-  - Fix some compilation warnings on GCC and Clang relating to the Speex resampler.
-  - Fix a compilation error for the Linux build when the ALSA and JACK backends are both disabled.
-  - Fix a compilation error for the BSD build.
-  - Fix some compilation errors on older versions of GCC.
-  - Add documentation for `MA_NO_RUNTIME_LINKING`.
-
-v0.10.21 - 2020-10-30
-  - Add ma_is_backend_enabled() and ma_get_enabled_backends() for retrieving enabled backends at run-time.
-  - WASAPI: Fix a copy and paste bug relating to loopback mode.
-  - Core Audio: Fix a bug when using multiple contexts.
-  - Core Audio: Fix a compilation warning.
-  - Core Audio: Improvements to sample rate selection.
-  - Core Audio: Improvements to format/channels/rate selection when requesting defaults.
-  - Core Audio: Add notes regarding the Apple notarization process.
-  - Fix some bugs due to null pointer dereferences.
-
-v0.10.20 - 2020-10-06
-  - Fix build errors with UWP.
-  - Minor documentation updates.
-
-v0.10.19 - 2020-09-22
-  - WASAPI: Return an error when exclusive mode is requested, but the native format is not supported by miniaudio.
-  - Fix a bug where ma_decoder_seek_to_pcm_frames() never returns MA_SUCCESS even though it was successful.
-  - Store the sample rate in the `ma_lpf` and `ma_hpf` structures.
-
-v0.10.18 - 2020-08-30
-  - Fix build errors with VC6.
-  - Fix a bug in channel converter for s32 format.
-  - Change channel converter configs to use the default channel map instead of a blank channel map when no channel map is specified when initializing the
-    config. This fixes an issue where the optimized mono expansion path would never get used.
-  - Use a more appropriate default format for FLAC decoders. This will now use ma_format_s16 when the FLAC is encoded as 16-bit.
-  - Update FLAC decoder.
-  - Update links to point to the new repository location (https://github.com/mackron/miniaudio).
-
-v0.10.17 - 2020-08-28
-  - Fix an error where the WAV codec is incorrectly excluded from the build depending on which compile time options are set.
-  - Fix a bug in ma_audio_buffer_read_pcm_frames() where it isn't returning the correct number of frames processed.
-  - Fix compilation error on Android.
-  - Core Audio: Fix a bug with full-duplex mode.
-  - Add ma_decoder_get_cursor_in_pcm_frames().
-  - Update WAV codec.
-
-v0.10.16 - 2020-08-14
-  - WASAPI: Fix a potential crash due to using an uninitialized variable.
-  - OpenSL: Enable runtime linking.
-  - OpenSL: Fix a multithreading bug when initializing and uninitializing multiple contexts at the same time.
-  - iOS: Improvements to device enumeration.
-  - Fix a crash in ma_data_source_read_pcm_frames() when the output frame count parameter is NULL.
-  - Fix a bug in ma_data_source_read_pcm_frames() where looping doesn't work.
-  - Fix some compilation warnings on Windows when both DirectSound and WinMM are disabled.
-  - Fix some compilation warnings when no decoders are enabled.
-  - Add ma_audio_buffer_get_available_frames().
-  - Add ma_decoder_get_available_frames().
-  - Add sample rate to ma_data_source_get_data_format().
-  - Change volume APIs to take 64-bit frame counts.
-  - Updates to documentation.
-
-v0.10.15 - 2020-07-15
-  - Fix a bug when converting bit-masked channel maps to miniaudio channel maps. This affects the WASAPI and OpenSL backends.
-
-v0.10.14 - 2020-07-14
-  - Fix compilation errors on Android.
-  - Fix compilation errors with -march=armv6.
-  - Updates to the documentation.
-
-v0.10.13 - 2020-07-11
-  - Fix some potential buffer overflow errors with channel maps when channel counts are greater than MA_MAX_CHANNELS.
-  - Fix compilation error on Emscripten.
-  - Silence some unused function warnings.
-  - Increase the default buffer size on the Web Audio backend. This fixes glitching issues on some browsers.
-  - Bring FLAC decoder up-to-date with dr_flac.
-  - Bring MP3 decoder up-to-date with dr_mp3.
-
-v0.10.12 - 2020-07-04
-  - Fix compilation errors on the iOS build.
-
-v0.10.11 - 2020-06-28
-  - Fix some bugs with device tracking on Core Audio.
-  - Updates to documentation.
-
-v0.10.10 - 2020-06-26
-  - Add include guard for the implementation section.
-  - Mark ma_device_sink_info_callback() as static.
-  - Fix compilation errors with MA_NO_DECODING and MA_NO_ENCODING.
-  - Fix compilation errors with MA_NO_DEVICE_IO
-
-v0.10.9 - 2020-06-24
-  - Amalgamation of dr_wav, dr_flac and dr_mp3. With this change, including the header section of these libraries before the implementation of miniaudio is no
-    longer required. Decoding of WAV, FLAC and MP3 should be supported seamlessly without any additional libraries. Decoders can be excluded from the build
-    with the following options:
-    - MA_NO_WAV
-    - MA_NO_FLAC
-    - MA_NO_MP3
-    If you get errors about multiple definitions you need to either enable the options above, move the implementation of dr_wav, dr_flac and/or dr_mp3 to before
-    the implementation of miniaudio, or update dr_wav, dr_flac and/or dr_mp3.
-  - Changes to the internal atomics library. This has been replaced with c89atomic.h which is embedded within this file.
-  - Fix a bug when a decoding backend reports configurations outside the limits of miniaudio's decoder abstraction.
-  - Fix the UWP build.
-  - Fix the Core Audio build.
-  - Fix the -std=c89 build on GCC.
-
-v0.10.8 - 2020-06-22
-  - Remove dependency on ma_context from mutexes.
-  - Change ma_data_source_read_pcm_frames() to return a result code and output the frames read as an output parameter.
-  - Change ma_data_source_seek_pcm_frames() to return a result code and output the frames seeked as an output parameter.
-  - Change ma_audio_buffer_unmap() to return MA_AT_END when the end has been reached. This should be considered successful.
-  - Change playback.pDeviceID and capture.pDeviceID to constant pointers in ma_device_config.
-  - Add support for initializing decoders from a virtual file system object. This is achieved via the ma_vfs API and allows the application to customize file
-    IO for the loading and reading of raw audio data. Passing in NULL for the VFS will use defaults. New APIs:
-    - ma_decoder_init_vfs()
-    - ma_decoder_init_vfs_wav()
-    - ma_decoder_init_vfs_flac()
-    - ma_decoder_init_vfs_mp3()
-    - ma_decoder_init_vfs_vorbis()
-    - ma_decoder_init_vfs_w()
-    - ma_decoder_init_vfs_wav_w()
-    - ma_decoder_init_vfs_flac_w()
-    - ma_decoder_init_vfs_mp3_w()
-    - ma_decoder_init_vfs_vorbis_w()
-  - Add support for memory mapping to ma_data_source.
-    - ma_data_source_map()
-    - ma_data_source_unmap()
-  - Add ma_offset_pcm_frames_ptr() and ma_offset_pcm_frames_const_ptr() which can be used for offsetting a pointer by a specified number of PCM frames.
-  - Add initial implementation of ma_yield() which is useful for spin locks which will be used in some upcoming work.
-  - Add documentation for log levels.
-  - The ma_event API has been made public in preparation for some uncoming work.
-  - Fix a bug in ma_decoder_seek_to_pcm_frame() where the internal sample rate is not being taken into account for determining the seek location.
-  - Fix some bugs with the linear resampler when dynamically changing the sample rate.
-  - Fix compilation errors with MA_NO_DEVICE_IO.
-  - Fix some warnings with GCC and -std=c89.
-  - Fix some formatting warnings with GCC and -Wall and -Wpedantic.
-  - Fix some warnings with VC6.
-  - Minor optimization to ma_copy_pcm_frames(). This is now a no-op when the input and output buffers are the same.
-
-v0.10.7 - 2020-05-25
-  - Fix a compilation error in the C++ build.
-  - Silence a warning.
-
-v0.10.6 - 2020-05-24
-  - Change ma_clip_samples_f32() and ma_clip_pcm_frames_f32() to take a 64-bit sample/frame count.
-  - Change ma_zero_pcm_frames() to clear to 128 for ma_format_u8.
-  - Add ma_silence_pcm_frames() which replaces ma_zero_pcm_frames(). ma_zero_pcm_frames() will be removed in version 0.11.
-  - Add support for u8, s24 and s32 formats to ma_channel_converter.
-  - Add compile-time and run-time version querying.
-    - MA_VERSION_MINOR
-    - MA_VERSION_MAJOR
-    - MA_VERSION_REVISION
-    - MA_VERSION_STRING
-    - ma_version()
-    - ma_version_string()
-  - Add ma_audio_buffer for reading raw audio data directly from memory.
-  - Fix a bug in shuffle mode in ma_channel_converter.
-  - Fix compilation errors in certain configurations for ALSA and PulseAudio.
-  - The data callback now initializes the output buffer to 128 when the playback sample format is ma_format_u8.
-
-v0.10.5 - 2020-05-05
-  - Change ma_zero_pcm_frames() to take a 64-bit frame count.
-  - Add ma_copy_pcm_frames().
-  - Add MA_NO_GENERATION build option to exclude the `ma_waveform` and `ma_noise` APIs from the build.
-  - Add support for formatted logging to the VC6 build.
-  - Fix a crash in the linear resampler when LPF order is 0.
-  - Fix compilation errors and warnings with older versions of Visual Studio.
-  - Minor documentation updates.
-
-v0.10.4 - 2020-04-12
-  - Fix a data conversion bug when converting from the client format to the native device format.
-
-v0.10.3 - 2020-04-07
-  - Bring up to date with breaking changes to dr_mp3.
-  - Remove MA_NO_STDIO. This was causing compilation errors and the maintenance cost versus practical benefit is no longer worthwhile.
-  - Fix a bug with data conversion where it was unnecessarily converting to s16 or f32 and then straight back to the original format.
-  - Fix compilation errors and warnings with Visual Studio 2005.
-  - ALSA: Disable ALSA's automatic data conversion by default and add configuration options to the device config:
-    - alsa.noAutoFormat
-    - alsa.noAutoChannels
-    - alsa.noAutoResample
-  - WASAPI: Add some overrun recovery for ma_device_type_capture devices.
-
-v0.10.2 - 2020-03-22
-  - Decorate some APIs with MA_API which were missed in the previous version.
-  - Fix a bug in ma_linear_resampler_set_rate() and ma_linear_resampler_set_rate_ratio().
-
-v0.10.1 - 2020-03-17
-  - Add MA_API decoration. This can be customized by defining it before including miniaudio.h.
-  - Fix a bug where opening a file would return a success code when in fact it failed.
-  - Fix compilation errors with Visual Studio 6 and 2003.
-  - Fix warnings on macOS.
-
-v0.10.0 - 2020-03-07
-  - API CHANGE: Refactor data conversion APIs
-    - ma_format_converter has been removed. Use ma_convert_pcm_frames_format() instead.
-    - ma_channel_router has been replaced with ma_channel_converter.
-    - ma_src has been replaced with ma_resampler
-    - ma_pcm_converter has been replaced with ma_data_converter
-  - API CHANGE: Add support for custom memory allocation callbacks. The following APIs have been updated to take an extra parameter for the allocation
-    callbacks:
-    - ma_malloc()
-    - ma_realloc()
-    - ma_free()
-    - ma_aligned_malloc()
-    - ma_aligned_free()
-    - ma_rb_init() / ma_rb_init_ex()
-    - ma_pcm_rb_init() / ma_pcm_rb_init_ex()
-  - API CHANGE: Simplify latency specification in device configurations. The bufferSizeInFrames and bufferSizeInMilliseconds parameters have been replaced with
-    periodSizeInFrames and periodSizeInMilliseconds respectively. The previous variables defined the size of the entire buffer, whereas the new ones define the
-    size of a period. The following APIs have been removed since they are no longer relevant:
-    - ma_get_default_buffer_size_in_milliseconds()
-    - ma_get_default_buffer_size_in_frames()
-  - API CHANGE: ma_device_set_stop_callback() has been removed. If you require a stop callback, you must now set it via the device config just like the data
-    callback.
-  - API CHANGE: The ma_sine_wave API has been replaced with ma_waveform. The following APIs have been removed:
-    - ma_sine_wave_init()
-    - ma_sine_wave_read_f32()
-    - ma_sine_wave_read_f32_ex()
-  - API CHANGE: ma_convert_frames() has been updated to take an extra parameter which is the size of the output buffer in PCM frames. Parameters have also been
-    reordered.
-  - API CHANGE: ma_convert_frames_ex() has been changed to take a pointer to a ma_data_converter_config object to specify the input and output formats to
-    convert between.
-  - API CHANGE: ma_calculate_frame_count_after_src() has been renamed to ma_calculate_frame_count_after_resampling().
-  - Add support for the following filters:
-    - Biquad (ma_biquad)
-    - First order low-pass (ma_lpf1)
-    - Second order low-pass (ma_lpf2)
-    - Low-pass with configurable order (ma_lpf)
-    - First order high-pass (ma_hpf1)
-    - Second order high-pass (ma_hpf2)
-    - High-pass with configurable order (ma_hpf)
-    - Second order band-pass (ma_bpf2)
-    - Band-pass with configurable order (ma_bpf)
-    - Second order peaking EQ (ma_peak2)
-    - Second order notching (ma_notch2)
-    - Second order low shelf (ma_loshelf2)
-    - Second order high shelf (ma_hishelf2)
-  - Add waveform generation API (ma_waveform) with support for the following:
-    - Sine
-    - Square
-    - Triangle
-    - Sawtooth
-  - Add noise generation API (ma_noise) with support for the following:
-    - White
-    - Pink
-    - Brownian
-  - Add encoding API (ma_encoder). This only supports outputting to WAV files via dr_wav.
-  - Add ma_result_description() which is used to retrieve a human readable description of a given result code.
-  - Result codes have been changed. Binding maintainers will need to update their result code constants.
-  - More meaningful result codes are now returned when a file fails to open.
-  - Internal functions have all been made static where possible.
-  - Fix potential crash when ma_device object's are not aligned to MA_SIMD_ALIGNMENT.
-  - Fix a bug in ma_decoder_get_length_in_pcm_frames() where it was returning the length based on the internal sample rate rather than the output sample rate.
-  - Fix bugs in some backends where the device is not drained properly in ma_device_stop().
-  - Improvements to documentation.
-
-v0.9.10 - 2020-01-15
-  - Fix compilation errors due to #if/#endif mismatches.
-  - WASAPI: Fix a bug where automatic stream routing is being performed for devices that are initialized with an explicit device ID.
-  - iOS: Fix a crash on device uninitialization.
-
-v0.9.9 - 2020-01-09
-  - Fix compilation errors with MinGW.
-  - Fix compilation errors when compiling on Apple platforms.
-  - WASAPI: Add support for disabling hardware offloading.
-  - WASAPI: Add support for disabling automatic stream routing.
-  - Core Audio: Fix bugs in the case where the internal device uses deinterleaved buffers.
-  - Core Audio: Add support for controlling the session category (AVAudioSessionCategory) and options (AVAudioSessionCategoryOptions).
-  - JACK: Fix bug where incorrect ports are connected.
-
-v0.9.8 - 2019-10-07
-  - WASAPI: Fix a potential deadlock when starting a full-duplex device.
-  - WASAPI: Enable automatic resampling by default. Disable with config.wasapi.noAutoConvertSRC.
-  - Core Audio: Fix bugs with automatic stream routing.
-  - Add support for controlling whether or not the content of the output buffer passed in to the data callback is pre-initialized
-    to zero. By default it will be initialized to zero, but this can be changed by setting noPreZeroedOutputBuffer in the device
-    config. Setting noPreZeroedOutputBuffer to true will leave the contents undefined.
-  - Add support for clipping samples after the data callback has returned. This only applies when the playback sample format is
-    configured as ma_format_f32. If you are doing clipping yourself, you can disable this overhead by setting noClip to true in
-    the device config.
-  - Add support for master volume control for devices.
-    - Use ma_device_set_master_volume() to set the volume to a factor between 0 and 1, where 0 is silence and 1 is full volume.
-    - Use ma_device_set_master_gain_db() to set the volume in decibels where 0 is full volume and < 0 reduces the volume.
-  - Fix warnings emitted by GCC when `__inline__` is undefined or defined as nothing.
-
-v0.9.7 - 2019-08-28
-  - Add support for loopback mode (WASAPI only).
-    - To use this, set the device type to ma_device_type_loopback, and then fill out the capture section of the device config.
-    - If you need to capture from a specific output device, set the capture device ID to that of a playback device.
-  - Fix a crash when an error is posted in ma_device_init().
-  - Fix a compilation error when compiling for ARM architectures.
-  - Fix a bug with the audio(4) backend where the device is incorrectly being opened in non-blocking mode.
-  - Fix memory leaks in the Core Audio backend.
-  - Minor refactoring to the WinMM, ALSA, PulseAudio, OSS, audio(4), sndio and null backends.
-
-v0.9.6 - 2019-08-04
-  - Add support for loading decoders using a wchar_t string for file paths.
-  - Don't trigger an assert when ma_device_start() is called on a device that is already started. This will now log a warning
-    and return MA_INVALID_OPERATION. The same applies for ma_device_stop().
-  - Try fixing an issue with PulseAudio taking a long time to start playback.
-  - Fix a bug in ma_convert_frames() and ma_convert_frames_ex().
-  - Fix memory leaks in the WASAPI backend.
-  - Fix a compilation error with Visual Studio 2010.
-
-v0.9.5 - 2019-05-21
-  - Add logging to ma_dlopen() and ma_dlsym().
-  - Add ma_decoder_get_length_in_pcm_frames().
-  - Fix a bug with capture on the OpenSL|ES backend.
-  - Fix a bug with the ALSA backend where a device would not restart after being stopped.
-
-v0.9.4 - 2019-05-06
-  - Add support for C89. With this change, miniaudio should compile clean with GCC/Clang with "-std=c89 -ansi -pedantic" and
-    Microsoft compilers back to VC6. Other compilers should also work, but have not been tested.
-
-v0.9.3 - 2019-04-19
-  - Fix compiler errors on GCC when compiling with -std=c99.
-
-v0.9.2 - 2019-04-08
-  - Add support for per-context user data.
-  - Fix a potential bug with context configs.
-  - Fix some bugs with PulseAudio.
-
-v0.9.1 - 2019-03-17
-  - Fix a bug where the output buffer is not getting zeroed out before calling the data callback. This happens when
-    the device is running in passthrough mode (not doing any data conversion).
-  - Fix an issue where the data callback is getting called too frequently on the WASAPI and DirectSound backends.
-  - Fix error on the UWP build.
-  - Fix a build error on Apple platforms.
-
-v0.9 - 2019-03-06
-  - Rebranded to "miniaudio". All namespaces have been renamed from "mal" to "ma".
-  - API CHANGE: ma_device_init() and ma_device_config_init() have changed significantly:
-    - The device type, device ID and user data pointer have moved from ma_device_init() to the config.
-    - All variations of ma_device_config_init_*() have been removed in favor of just ma_device_config_init().
-    - ma_device_config_init() now takes only one parameter which is the device type. All other properties need
-      to be set on the returned object directly.
-    - The onDataCallback and onStopCallback members of ma_device_config have been renamed to "dataCallback"
-      and "stopCallback".
-    - The ID of the physical device is now split into two: one for the playback device and the other for the
-      capture device. This is required for full-duplex. These are named "pPlaybackDeviceID" and "pCaptureDeviceID".
-  - API CHANGE: The data callback has changed. It now uses a unified callback for all device types rather than
-    being separate for each. It now takes two pointers - one containing input data and the other output data. This
-    design in required for full-duplex. The return value is now void instead of the number of frames written. The
-    new callback looks like the following:
-        void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-  - API CHANGE: Remove the log callback parameter from ma_context_config_init(). With this change,
-    ma_context_config_init() now takes no parameters and the log callback is set via the structure directly. The
-    new policy for config initialization is that only mandatory settings are passed in to *_config_init(). The
-    "onLog" member of ma_context_config has been renamed to "logCallback".
-  - API CHANGE: Remove ma_device_get_buffer_size_in_bytes().
-  - API CHANGE: Rename decoding APIs to "pcm_frames" convention.
-    - mal_decoder_read()          -> ma_decoder_read_pcm_frames()
-    - mal_decoder_seek_to_frame() -> ma_decoder_seek_to_pcm_frame()
-  - API CHANGE: Rename sine wave reading APIs to f32 convention.
-    - mal_sine_wave_read()    -> ma_sine_wave_read_f32()
-    - mal_sine_wave_read_ex() -> ma_sine_wave_read_f32_ex()
-  - API CHANGE: Remove some deprecated APIs
-    - mal_device_set_recv_callback()
-    - mal_device_set_send_callback()
-    - mal_src_set_input_sample_rate()
-    - mal_src_set_output_sample_rate()
-  - API CHANGE: Add log level to the log callback. New signature:
-    - void on_log(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-  - API CHANGE: Changes to result codes. Constants have changed and unused codes have been removed. If you're
-    a binding mainainer you will need to update your result code constants.
-  - API CHANGE: Change the order of the ma_backend enums to priority order. If you are a binding maintainer, you
-    will need to update.
-  - API CHANGE: Rename mal_dsp to ma_pcm_converter. All functions have been renamed from mal_dsp_*() to
-    ma_pcm_converter_*(). All structures have been renamed from mal_dsp* to ma_pcm_converter*.
-  - API CHANGE: Reorder parameters of ma_decoder_read_pcm_frames() to be consistent with the new parameter order scheme.
-  - The resampling algorithm has been changed from sinc to linear. The rationale for this is that the sinc implementation
-    is too inefficient right now. This will hopefully be improved at a later date.
-  - Device initialization will no longer fall back to shared mode if exclusive mode is requested but is unusable.
-    With this change, if you request an device in exclusive mode, but exclusive mode is not supported, it will not
-    automatically fall back to shared mode. The client will need to reinitialize the device in shared mode if that's
-    what they want.
-  - Add ring buffer API. This is ma_rb and ma_pcm_rb, the difference being that ma_rb operates on bytes and
-    ma_pcm_rb operates on PCM frames.
-  - Add Web Audio backend. This is used when compiling with Emscripten. The SDL backend, which was previously
-    used for web support, will be removed in a future version.
-  - Add AAudio backend (Android Audio). This is the new priority backend for Android. Support for AAudio starts
-    with Android 8. OpenSL|ES is used as a fallback for older versions of Android.
-  - Remove OpenAL and SDL backends.
-  - Fix a possible deadlock when rapidly stopping the device after it has started.
-  - Update documentation.
-  - Change licensing to a choice of public domain _or_ MIT-0 (No Attribution).
-
-v0.8.14 - 2018-12-16
-  - Core Audio: Fix a bug where the device state is not set correctly after stopping.
-  - Add support for custom weights to the channel router.
-  - Update decoders to use updated APIs in dr_flac, dr_mp3 and dr_wav.
-
-v0.8.13 - 2018-12-04
-  - Core Audio: Fix a bug with channel mapping.
-  - Fix a bug with channel routing where the back/left and back/right channels have the wrong weight.
-
-v0.8.12 - 2018-11-27
-  - Drop support for SDL 1.2. The Emscripten build now requires "-s USE_SDL=2".
-  - Fix a linking error with ALSA.
-  - Fix a bug on iOS where the device name is not set correctly.
-
-v0.8.11 - 2018-11-21
-  - iOS bug fixes.
-  - Minor tweaks to PulseAudio.
-
-v0.8.10 - 2018-10-21
-  - Core Audio: Fix a hang when uninitializing a device.
-  - Fix a bug where an incorrect value is returned from mal_device_stop().
-
-v0.8.9 - 2018-09-28
-  - Fix a bug with the SDL backend where device initialization fails.
-
-v0.8.8 - 2018-09-14
-  - Fix Linux build with the ALSA backend.
-  - Minor documentation fix.
-
-v0.8.7 - 2018-09-12
-  - Fix a bug with UWP detection.
-
-v0.8.6 - 2018-08-26
-  - Automatically switch the internal device when the default device is unplugged. Note that this is still in the
-    early stages and not all backends handle this the same way. As of this version, this will not detect a default
-    device switch when changed from the operating system's audio preferences (unless the backend itself handles
-    this automatically). This is not supported in exclusive mode.
-  - WASAPI and Core Audio: Add support for stream routing. When the application is using a default device and the
-    user switches the default device via the operating system's audio preferences, miniaudio will automatically switch
-    the internal device to the new default. This is not supported in exclusive mode.
-  - WASAPI: Add support for hardware offloading via IAudioClient2. Only supported on Windows 8 and newer.
-  - WASAPI: Add support for low-latency shared mode via IAudioClient3. Only supported on Windows 10 and newer.
-  - Add support for compiling the UWP build as C.
-  - mal_device_set_recv_callback() and mal_device_set_send_callback() have been deprecated. You must now set this
-    when the device is initialized with mal_device_init*(). These will be removed in version 0.9.0.
-
-v0.8.5 - 2018-08-12
-  - Add support for specifying the size of a device's buffer in milliseconds. You can still set the buffer size in
-    frames if that suits you. When bufferSizeInFrames is 0, bufferSizeInMilliseconds will be used. If both are non-0
-    then bufferSizeInFrames will take priority. If both are set to 0 the default buffer size is used.
-  - Add support for the audio(4) backend to OpenBSD.
-  - Fix a bug with the ALSA backend that was causing problems on Raspberry Pi. This significantly improves the
-    Raspberry Pi experience.
-  - Fix a bug where an incorrect number of samples is returned from sinc resampling.
-  - Add support for setting the value to be passed to internal calls to CoInitializeEx().
-  - WASAPI and WinMM: Stop the device when it is unplugged.
-
-v0.8.4 - 2018-08-06
-  - Add sndio backend for OpenBSD.
-  - Add audio(4) backend for NetBSD.
-  - Drop support for the OSS backend on everything except FreeBSD and DragonFly BSD.
-  - Formats are now native-endian (were previously little-endian).
-  - Mark some APIs as deprecated:
-    - mal_src_set_input_sample_rate() and mal_src_set_output_sample_rate() are replaced with mal_src_set_sample_rate().
-    - mal_dsp_set_input_sample_rate() and mal_dsp_set_output_sample_rate() are replaced with mal_dsp_set_sample_rate().
-  - Fix a bug when capturing using the WASAPI backend.
-  - Fix some aliasing issues with resampling, specifically when increasing the sample rate.
-  - Fix warnings.
-
-v0.8.3 - 2018-07-15
-  - Fix a crackling bug when resampling in capture mode.
-  - Core Audio: Fix a bug where capture does not work.
-  - ALSA: Fix a bug where the worker thread can get stuck in an infinite loop.
-  - PulseAudio: Fix a bug where mal_context_init() succeeds when PulseAudio is unusable.
-  - JACK: Fix a bug where mal_context_init() succeeds when JACK is unusable.
-
-v0.8.2 - 2018-07-07
-  - Fix a bug on macOS with Core Audio where the internal callback is not called.
-
-v0.8.1 - 2018-07-06
-  - Fix compilation errors and warnings.
-
-v0.8 - 2018-07-05
-  - Changed MAL_IMPLEMENTATION to MINI_AL_IMPLEMENTATION for consistency with other libraries. The old
-    way is still supported for now, but you should update as it may be removed in the future.
-  - API CHANGE: Replace device enumeration APIs. mal_enumerate_devices() has been replaced with
-    mal_context_get_devices(). An additional low-level device enumration API has been introduced called
-    mal_context_enumerate_devices() which uses a callback to report devices.
-  - API CHANGE: Rename mal_get_sample_size_in_bytes() to mal_get_bytes_per_sample() and add
-    mal_get_bytes_per_frame().
-  - API CHANGE: Replace mal_device_config.preferExclusiveMode with mal_device_config.shareMode.
-    - This new config can be set to mal_share_mode_shared (default) or mal_share_mode_exclusive.
-  - API CHANGE: Remove excludeNullDevice from mal_context_config.alsa.
-  - API CHANGE: Rename MAL_MAX_SAMPLE_SIZE_IN_BYTES to MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES.
-  - API CHANGE: Change the default channel mapping to the standard Microsoft mapping.
-  - API CHANGE: Remove backend-specific result codes.
-  - API CHANGE: Changes to the format conversion APIs (mal_pcm_f32_to_s16(), etc.)
-  - Add support for Core Audio (Apple).
-  - Add support for PulseAudio.
-    - This is the highest priority backend on Linux (higher priority than ALSA) since it is commonly
-      installed by default on many of the popular distros and offer's more seamless integration on
-      platforms where PulseAudio is used. In addition, if PulseAudio is installed and running (which
-      is extremely common), it's better to just use PulseAudio directly rather than going through the
-      "pulse" ALSA plugin (which is what the "default" ALSA device is likely set to).
-  - Add support for JACK.
-  - Remove dependency on asound.h for the ALSA backend. This means the ALSA development packages are no
-    longer required to build miniaudio.
-  - Remove dependency on dsound.h for the DirectSound backend. This fixes build issues with some
-    distributions of MinGW.
-  - Remove dependency on audioclient.h for the WASAPI backend. This fixes build issues with some
-    distributions of MinGW.
-  - Add support for dithering to format conversion.
-  - Add support for configuring the priority of the worker thread.
-  - Add a sine wave generator.
-  - Improve efficiency of sample rate conversion.
-  - Introduce the notion of standard channel maps. Use mal_get_standard_channel_map().
-  - Introduce the notion of default device configurations. A default config uses the same configuration
-    as the backend's internal device, and as such results in a pass-through data transmission pipeline.
-  - Add support for passing in NULL for the device config in mal_device_init(), which uses a default
-    config. This requires manually calling mal_device_set_send/recv_callback().
-  - Add support for decoding from raw PCM data (mal_decoder_init_raw(), etc.)
-  - Make mal_device_init_ex() more robust.
-  - Make some APIs more const-correct.
-  - Fix errors with SDL detection on Apple platforms.
-  - Fix errors with OpenAL detection.
-  - Fix some memory leaks.
-  - Fix a bug with opening decoders from memory.
-  - Early work on SSE2, AVX2 and NEON optimizations.
-  - Miscellaneous bug fixes.
-  - Documentation updates.
-
-v0.7 - 2018-02-25
-  - API CHANGE: Change mal_src_read_frames() and mal_dsp_read_frames() to use 64-bit sample counts.
-  - Add decoder APIs for loading WAV, FLAC, Vorbis and MP3 files.
-  - Allow opening of devices without a context.
-    - In this case the context is created and managed internally by the device.
-  - Change the default channel mapping to the same as that used by FLAC.
-  - Fix build errors with macOS.
-
-v0.6c - 2018-02-12
-  - Fix build errors with BSD/OSS.
-
-v0.6b - 2018-02-03
-  - Fix some warnings when compiling with Visual C++.
-
-v0.6a - 2018-01-26
-  - Fix errors with channel mixing when increasing the channel count.
-  - Improvements to the build system for the OpenAL backend.
-  - Documentation fixes.
-
-v0.6 - 2017-12-08
-  - API CHANGE: Expose and improve mutex APIs. If you were using the mutex APIs before this version you'll
-    need to update.
-  - API CHANGE: SRC and DSP callbacks now take a pointer to a mal_src and mal_dsp object respectively.
-  - API CHANGE: Improvements to event and thread APIs. These changes make these APIs more consistent.
-  - Add support for SDL and Emscripten.
-  - Simplify the build system further for when development packages for various backends are not installed.
-    With this change, when the compiler supports __has_include, backends without the relevant development
-    packages installed will be ignored. This fixes the build for old versions of MinGW.
-  - Fixes to the Android build.
-  - Add mal_convert_frames(). This is a high-level helper API for performing a one-time, bulk conversion of
-    audio data to a different format.
-  - Improvements to f32 -> u8/s16/s24/s32 conversion routines.
-  - Fix a bug where the wrong value is returned from mal_device_start() for the OpenSL backend.
-  - Fixes and improvements for Raspberry Pi.
-  - Warning fixes.
-
-v0.5 - 2017-11-11
-  - API CHANGE: The mal_context_init() function now takes a pointer to a mal_context_config object for
-    configuring the context. The works in the same kind of way as the device config. The rationale for this
-    change is to give applications better control over context-level properties, add support for backend-
-    specific configurations, and support extensibility without breaking the API.
-  - API CHANGE: The alsa.preferPlugHW device config variable has been removed since it's not really useful for
-    anything anymore.
-  - ALSA: By default, device enumeration will now only enumerate over unique card/device pairs. Applications
-    can enable verbose device enumeration by setting the alsa.useVerboseDeviceEnumeration context config
-    variable.
-  - ALSA: When opening a device in shared mode (the default), the dmix/dsnoop plugin will be prioritized. If
-    this fails it will fall back to the hw plugin. With this change the preferExclusiveMode config is now
-    honored. Note that this does not happen when alsa.useVerboseDeviceEnumeration is set to true (see above)
-    which is by design.
-  - ALSA: Add support for excluding the "null" device using the alsa.excludeNullDevice context config variable.
-  - ALSA: Fix a bug with channel mapping which causes an assertion to fail.
-  - Fix errors with enumeration when pInfo is set to NULL.
-  - OSS: Fix a bug when starting a device when the client sends 0 samples for the initial buffer fill.
-
-v0.4 - 2017-11-05
-  - API CHANGE: The log callback is now per-context rather than per-device and as is thus now passed to
-    mal_context_init(). The rationale for this change is that it allows applications to capture diagnostic
-    messages at the context level. Previously this was only available at the device level.
-  - API CHANGE: The device config passed to mal_device_init() is now const.
-  - Added support for OSS which enables support on BSD platforms.
-  - Added support for WinMM (waveOut/waveIn).
-  - Added support for UWP (Universal Windows Platform) applications. Currently C++ only.
-  - Added support for exclusive mode for selected backends. Currently supported on WASAPI.
-  - POSIX builds no longer require explicit linking to libpthread (-lpthread).
-  - ALSA: Explicit linking to libasound (-lasound) is no longer required.
-  - ALSA: Latency improvements.
-  - ALSA: Use MMAP mode where available. This can be disabled with the alsa.noMMap config.
-  - ALSA: Use "hw" devices instead of "plughw" devices by default. This can be disabled with the
-    alsa.preferPlugHW config.
-  - WASAPI is now the highest priority backend on Windows platforms.
-  - Fixed an error with sample rate conversion which was causing crackling when capturing.
-  - Improved error handling.
-  - Improved compiler support.
-  - Miscellaneous bug fixes.
-
-v0.3 - 2017-06-19
-  - API CHANGE: Introduced the notion of a context. The context is the highest level object and is required for
-    enumerating and creating devices. Now, applications must first create a context, and then use that to
-    enumerate and create devices. The reason for this change is to ensure device enumeration and creation is
-    tied to the same backend. In addition, some backends are better suited to this design.
-  - API CHANGE: Removed the rewinding APIs because they're too inconsistent across the different backends, hard
-    to test and maintain, and just generally unreliable.
-  - Added helper APIs for initializing mal_device_config objects.
-  - Null Backend: Fixed a crash when recording.
-  - Fixed build for UWP.
-  - Added support for f32 formats to the OpenSL|ES backend.
-  - Added initial implementation of the WASAPI backend.
-  - Added initial implementation of the OpenAL backend.
-  - Added support for low quality linear sample rate conversion.
-  - Added early support for basic channel mapping.
-
-v0.2 - 2016-10-28
-  - API CHANGE: Add user data pointer as the last parameter to mal_device_init(). The rationale for this
-    change is to ensure the logging callback has access to the user data during initialization.
-  - API CHANGE: Have device configuration properties be passed to mal_device_init() via a structure. Rationale:
-    1) The number of parameters is just getting too much.
-    2) It makes it a bit easier to add new configuration properties in the future. In particular, there's a
-       chance there will be support added for backend-specific properties.
-  - Dropped support for f64, A-law and Mu-law formats since they just aren't common enough to justify the
-    added maintenance cost.
-  - DirectSound: Increased the default buffer size for capture devices.
-  - Added initial implementation of the OpenSL|ES backend.
-
-v0.1 - 2016-10-21
-  - Initial versioned release.
-*/
-
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib/external/msf_gif.h b/raylib/external/msf_gif.h
deleted file mode 100644 (file)
index 348b1b1..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
-HOW TO USE:
-
-    In exactly one translation unit (.c or .cpp file), #define MSF_GIF_IMPL before including the header, like so:
-
-    #define MSF_GIF_IMPL
-    #include "msf_gif.h"
-
-    Everywhere else, just include the header like normal.
-
-
-USAGE EXAMPLE:
-
-    int width = 480, height = 320, centisecondsPerFrame = 5, bitDepth = 16;
-    MsfGifState gifState = {};
-    msf_gif_begin(&gifState, width, height);
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 1
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 2
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 3, etc...
-    MsfGifResult result = msf_gif_end(&gifState);
-    FILE * fp = fopen("MyGif.gif", "wb");
-    fwrite(result.data, result.dataSize, 1, fp);
-    fclose(fp);
-    msf_gif_free(result);
-
-Detailed function documentation can be found in the header section below.
-
-
-REPLACING MALLOC:
-
-    This library uses malloc+realloc+free internally for memory allocation.
-    To facilitate integration with custom memory allocators, these calls go through macros, which can be redefined.
-    The expected function signature equivalents of the macros are as follows:
-
-    void * MSF_GIF_MALLOC(void * context, size_t newSize)
-    void * MSF_GIF_REALLOC(void * context, void * oldMemory, size_t oldSize, size_t newSize)
-    void MSF_GIF_FREE(void * context, void * oldMemory, size_t oldSize)
-
-    If your allocator needs a context pointer, you can set the `customAllocatorContext` field of the MsfGifState struct
-    before calling msf_gif_begin(), and it will be passed to all subsequent allocator macro calls.
-
-See end of file for license information.
-*/
-
-//version 2.1
-
-#ifndef MSF_GIF_H
-#define MSF_GIF_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-typedef struct {
-    void * data;
-    size_t dataSize;
-
-    size_t allocSize; //internal use
-    void * contextPointer; //internal use
-} MsfGifResult;
-
-typedef struct { //internal use
-    uint32_t * pixels;
-    int depth, count, rbits, gbits, bbits;
-} MsfCookedFrame;
-
-typedef struct {
-    MsfCookedFrame previousFrame;
-    uint8_t * listHead;
-    uint8_t * listTail;
-    int width, height;
-    void * customAllocatorContext;
-} MsfGifState;
-
-#ifdef __cplusplus
-extern "C" {
-#endif //__cplusplus
-
-/**
- * @param width                Image width in pixels.
- * @param height               Image height in pixels.
- * @return                     Non-zero on success, 0 on error.
- */
-int msf_gif_begin(MsfGifState * handle, int width, int height);
-
-/**
- * @param pixelData            Pointer to raw framebuffer data. Rows must be contiguous in memory, in RGBA8 format.
- *                             Note: This function does NOT free `pixelData`. You must free it yourself afterwards.
- * @param centiSecondsPerFrame How many hundredths of a second this frame should be displayed for.
- *                             Note: This being specified in centiseconds is a limitation of the GIF format.
- * @param maxBitDepth          Limits how many bits per pixel can be used when quantizing the gif.
- *                             The actual bit depth chosen for a given frame will be less than or equal to
- *                             the supplied maximum, depending on the variety of colors used in the frame.
- *                             `maxBitDepth` will be clamped between 1 and 16. The recommended default is 16.
- *                             Lowering this value can result in faster exports and smaller gifs,
- *                             but the quality may suffer.
- *                             Please experiment with this value to find what works best for your application.
- * @param pitchInBytes         The number of bytes from the beginning of one row of pixels to the beginning of the next.
- *                             If you want to flip the image, just pass in a negative pitch.
- * @return                     Non-zero on success, 0 on error.
- */
-int msf_gif_frame(MsfGifState * handle, uint8_t * pixelData, int centiSecondsPerFame, int maxBitDepth, int pitchInBytes);
-
-/**
- * @return                     A block of memory containing the gif file data, or NULL on error.
- *                             You are responsible for freeing this via `msf_gif_free()`.
- */
-MsfGifResult msf_gif_end(MsfGifState * handle);
-
-/**
- * @param result                The MsfGifResult struct, verbatim as it was returned from `msf_gif_end()`.
- */
-void msf_gif_free(MsfGifResult result);
-
-#ifdef __cplusplus
-}
-#endif //__cplusplus
-
-#endif //MSF_GIF_H
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// IMPLEMENTATION                                                                                                   ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSF_GIF_IMPL
-#ifndef MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-#define MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-
-#ifndef MSF_GIF_BUFFER_INIT_SIZE
-#define MSF_GIF_BUFFER_INIT_SIZE 1024 * 1024 * 4 //4MB by default, you can increase this if you want to realloc less
-#endif
-
-//ensure the library user has either defined all of malloc/realloc/free, or none
-#if defined(MSF_GIF_MALLOC) && defined(MSF_GIF_REALLOC) && defined(MSF_GIF_FREE) //ok
-#elif !defined(MSF_GIF_MALLOC) && !defined(MSF_GIF_REALLOC) && !defined(MSF_GIF_FREE) //ok
-#else
-#error "You must either define all of MSF_GIF_MALLOC, MSF_GIF_REALLOC, and MSF_GIF_FREE, or define none of them"
-#endif
-
-//provide default allocator definitions that redirect to the standard global allocator
-#if !defined(MSF_GIF_MALLOC)
-#include <stdlib.h> //malloc, etc.
-#define MSF_GIF_MALLOC(contextPointer, newSize) malloc(newSize)
-#define MSF_GIF_REALLOC(contextPointer, oldMemory, oldSize, newSize) realloc(oldMemory, newSize)
-#define MSF_GIF_FREE(contextPointer, oldMemory, oldSize) free(oldMemory)
-#endif
-
-//instrumentation for capturing profiling traces (useless for the library user, but useful for the library author)
-#ifdef MSF_GIF_ENABLE_TRACING
-#define MsfTimeFunc TimeFunc
-#define MsfTimeLoop TimeLoop
-#define msf_init_profiling_thread init_profiling_thread
-#else
-#define MsfTimeFunc
-#define MsfTimeLoop(name)
-#define msf_init_profiling_thread()
-#endif //MSF_GIF_ENABLE_TRACING
-
-#include <string.h> //memcpy
-
-//TODO: use compiler-specific notation to force-inline functions currently marked inline
-#if defined(__GNUC__) //gcc, clang
-static inline int msf_bit_log(int i) { return 32 - __builtin_clz(i); }
-#elif defined(_MSC_VER) //msvc
-#include <intrin.h>
-static inline int msf_bit_log(int i) { unsigned long idx; _BitScanReverse(&idx, i); return idx + 1; }
-#else //fallback implementation for other compilers
-//from https://stackoverflow.com/a/31718095/3064745 - thanks!
-static inline int msf_bit_log(int i) {
-    static const int MultiplyDeBruijnBitPosition[32] = {
-        0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
-        8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31,
-    };
-    i |= i >> 1;
-    i |= i >> 2;
-    i |= i >> 4;
-    i |= i >> 8;
-    i |= i >> 16;
-    return MultiplyDeBruijnBitPosition[(uint32_t)(i * 0x07C4ACDDU) >> 27] + 1;
-}
-#endif
-static inline int msf_imin(int a, int b) { return a < b? a : b; }
-static inline int msf_imax(int a, int b) { return b < a? a : b; }
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Frame Cooking                                                                                                    ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if (defined (__SSE2__) || defined (_M_X64) || _M_IX86_FP == 2) && !defined(MSF_GIF_NO_SSE2)
-#include <emmintrin.h>
-#endif
-
-static MsfCookedFrame msf_cook_frame(void * allocContext, uint8_t * raw, uint8_t * used,
-                                     int width, int height, int pitch, int depth)
-{ MsfTimeFunc
-    //bit depth for each channel
-    const static int rdepths[17] = { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 };
-    const static int gdepths[17] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 };
-    const static int bdepths[17] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
-
-    const static int ditherKernel[16] = {
-         0 << 12,  8 << 12,  2 << 12, 10 << 12,
-        12 << 12,  4 << 12, 14 << 12,  6 << 12,
-         3 << 12, 11 << 12,  1 << 12,  9 << 12,
-        15 << 12,  7 << 12, 13 << 12,  5 << 12,
-    };
-
-    uint32_t * cooked = (uint32_t *) MSF_GIF_MALLOC(allocContext, width * height * sizeof(uint32_t));
-    if (!cooked) { MsfCookedFrame blank = {0}; return blank; }
-
-    int count = 0;
-    MsfTimeLoop("do") do {
-        int rbits = rdepths[depth], gbits = gdepths[depth], bbits = bdepths[depth];
-        int paletteSize = 1 << (rbits + gbits + bbits);
-        memset(used, 0, paletteSize * sizeof(uint8_t));
-
-        //TODO: document what this math does and why it's correct
-        int rdiff = (1 << (8 - rbits)) - 1;
-        int gdiff = (1 << (8 - gbits)) - 1;
-        int bdiff = (1 << (8 - bbits)) - 1;
-        short rmul = (short) ((255.0f - rdiff) / 255.0f * 257);
-        short gmul = (short) ((255.0f - gdiff) / 255.0f * 257);
-        short bmul = (short) ((255.0f - bdiff) / 255.0f * 257);
-
-        int gmask = ((1 << gbits) - 1) << rbits;
-        int bmask = ((1 << bbits) - 1) << rbits << gbits;
-
-        MsfTimeLoop("cook") for (int y = 0; y < height; ++y) {
-            int x = 0;
-
-            #if (defined (__SSE2__) || defined (_M_X64) || _M_IX86_FP == 2) && !defined(MSF_GIF_NO_SSE2)
-                __m128i k = _mm_loadu_si128((__m128i *) &ditherKernel[(y & 3) * 4]);
-                __m128i k2 = _mm_or_si128(_mm_srli_epi32(k, rbits), _mm_slli_epi32(_mm_srli_epi32(k, bbits), 16));
-                // MsfTimeLoop("SIMD")
-                for (; x < width - 3; x += 4) {
-                    uint8_t * pixels = &raw[y * pitch + x * 4];
-                    __m128i p = _mm_loadu_si128((__m128i *) pixels);
-
-                    __m128i rb = _mm_and_si128(p, _mm_set1_epi32(0x00FF00FF));
-                    __m128i rb1 = _mm_mullo_epi16(rb, _mm_set_epi16(bmul, rmul, bmul, rmul, bmul, rmul, bmul, rmul));
-                    __m128i rb2 = _mm_adds_epu16(rb1, k2);
-                    __m128i r3 = _mm_srli_epi32(_mm_and_si128(rb2, _mm_set1_epi32(0x0000FFFF)), 16 - rbits);
-                    __m128i b3 = _mm_and_si128(_mm_srli_epi32(rb2, 32 - rbits - gbits - bbits), _mm_set1_epi32(bmask));
-
-                    __m128i g = _mm_and_si128(_mm_srli_epi32(p, 8), _mm_set1_epi32(0x000000FF));
-                    __m128i g1 = _mm_mullo_epi16(g, _mm_set1_epi32(gmul));
-                    __m128i g2 = _mm_adds_epu16(g1, _mm_srli_epi32(k, gbits));
-                    __m128i g3 = _mm_and_si128(_mm_srli_epi32(g2, 16 - rbits - gbits), _mm_set1_epi32(gmask));
-
-                    //TODO: does storing this as a __m128i then reading it back as a uint32_t violate strict aliasing?
-                    uint32_t * c = &cooked[y * width + x];
-                    __m128i out = _mm_or_si128(_mm_or_si128(r3, g3), b3);
-                    _mm_storeu_si128((__m128i *) c, out);
-                }
-            #endif
-
-            //scalar cleanup loop
-            // MsfTimeLoop("scalar")
-            for (; x < width; ++x) {
-                uint8_t * p = &raw[y * pitch + x * 4];
-                int dx = x & 3, dy = y & 3;
-                int k = ditherKernel[dy * 4 + dx];
-                cooked[y * width + x] =
-                    (msf_imin(65535, p[2] * bmul + (k >> bbits)) >> (16 - rbits - gbits - bbits) & bmask) |
-                    (msf_imin(65535, p[1] * gmul + (k >> gbits)) >> (16 - rbits - gbits        ) & gmask) |
-                     msf_imin(65535, p[0] * rmul + (k >> rbits)) >> (16 - rbits                );
-            }
-        }
-
-        count = 0;
-        MsfTimeLoop("mark and count") for (int i = 0; i < width * height; ++i) {
-            used[cooked[i]] = 1;
-        }
-
-        //count used colors
-        MsfTimeLoop("count") for (int j = 0; j < paletteSize; ++j) {
-            count += used[j];
-        }
-    } while (count >= 256 && --depth);
-
-    MsfCookedFrame ret = { cooked, depth, count, rdepths[depth], gdepths[depth], bdepths[depth] };
-    return ret;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Frame Compression                                                                                                ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct {
-    uint8_t * next;
-    size_t size;
-} MsfBufferHeader;
-
-static inline int msf_put_code(uint8_t * * writeHead, uint32_t * blockBits, int len, uint32_t code) {
-    //insert new code into block buffer
-    int idx = *blockBits / 8;
-    int bit = *blockBits % 8;
-    (*writeHead)[idx + 0] |= code <<       bit ;
-    (*writeHead)[idx + 1] |= code >> ( 8 - bit);
-    (*writeHead)[idx + 2] |= code >> (16 - bit);
-    *blockBits += len;
-
-    //prep the next block buffer if the current one is full
-    if (*blockBits >= 256 * 8) {
-        *blockBits -= 255 * 8;
-        (*writeHead) += 256;
-        (*writeHead)[2] = (*writeHead)[1];
-        (*writeHead)[1] = (*writeHead)[0];
-        (*writeHead)[0] = 255;
-        memset((*writeHead) + 4, 0, 256);
-    }
-
-    return 1;
-}
-
-typedef struct {
-    int16_t * data;
-    int len;
-    int stride;
-} MsfStridedList;
-
-static inline void msf_lzw_reset(MsfStridedList * lzw, int tableSize, int stride) { MsfTimeFunc
-    memset(lzw->data, 0xFF, 4096 * stride * sizeof(int16_t));
-    lzw->len = tableSize + 2;
-    lzw->stride = stride;
-}
-
-static uint8_t * msf_compress_frame(void * allocContext, int width, int height, int centiSeconds,
-                                    MsfCookedFrame frame, MsfCookedFrame previous, uint8_t * used)
-{ MsfTimeFunc
-    //NOTE: we reserve enough memory for theoretical the worst case upfront because it's a reasonable amount,
-    //      and prevents us from ever having to check size or realloc during compression
-    int maxBufSize = sizeof(MsfBufferHeader) + 32 + 256 * 3 + width * height * 3 / 2; //headers + color table + data
-    uint8_t * allocation = (uint8_t *) MSF_GIF_MALLOC(allocContext, maxBufSize);
-    if (!allocation) { return NULL; }
-    uint8_t * writeBase = allocation + sizeof(MsfBufferHeader);
-    uint8_t * writeHead = writeBase;
-    int lzwAllocSize = 4096 * (frame.count + 1) * sizeof(int16_t);
-    MsfStridedList lzw = { (int16_t *) MSF_GIF_MALLOC(allocContext, lzwAllocSize) };
-    if (!lzw.data) { MSF_GIF_FREE(allocContext, allocation, maxBufSize); return NULL; }
-
-    //allocate tlb
-    int totalBits = frame.rbits + frame.gbits + frame.bbits;
-    int tlbSize = 1 << totalBits;
-    uint8_t tlb[1 << 16]; //only 64k, so stack allocating is fine
-
-    //generate palette
-    typedef struct { uint8_t r, g, b; } Color3;
-    Color3 table[256] = { {0} };
-    int tableIdx = 1; //we start counting at 1 because 0 is the transparent color
-    MsfTimeLoop("table") for (int i = 0; i < tlbSize; ++i) {
-        if (used[i]) {
-            tlb[i] = tableIdx;
-            int rmask = (1 << frame.rbits) - 1;
-            int gmask = (1 << frame.gbits) - 1;
-            //isolate components
-            int r = i & rmask;
-            int g = i >> frame.rbits & gmask;
-            int b = i >> (frame.rbits + frame.gbits);
-            //shift into highest bits
-            r <<= 8 - frame.rbits;
-            g <<= 8 - frame.gbits;
-            b <<= 8 - frame.bbits;
-            table[tableIdx].r = r | r >> frame.rbits | r >> (frame.rbits * 2) | r >> (frame.rbits * 3);
-            table[tableIdx].g = g | g >> frame.gbits | g >> (frame.gbits * 2) | g >> (frame.gbits * 3);
-            table[tableIdx].b = b | b >> frame.bbits | b >> (frame.bbits * 2) | b >> (frame.bbits * 3);
-            ++tableIdx;
-        }
-    }
-
-    //SPEC: "Because of some algorithmic constraints however, black & white images which have one color bit
-    //       must be indicated as having a code size of 2."
-    int tableBits = msf_imax(2, msf_bit_log(tableIdx - 1));
-    int tableSize = 1 << tableBits;
-    //NOTE: we don't just compare `depth` field here because it will be wrong for the first frame and we will segfault
-    int hasSamePal = frame.rbits == previous.rbits && frame.gbits == previous.gbits && frame.bbits == previous.bbits;
-
-    //NOTE: because __attribute__((__packed__)) is annoyingly compiler-specific, we do this unreadable weirdness
-    char headerBytes[19] = "\x21\xF9\x04\x05\0\0\0\0" "\x2C\0\0\0\0\0\0\0\0\x80";
-    memcpy(&headerBytes[4], &centiSeconds, 2);
-    memcpy(&headerBytes[13], &width, 2);
-    memcpy(&headerBytes[15], &height, 2);
-    headerBytes[17] |= tableBits - 1;
-    memcpy(writeHead, headerBytes, 18);
-    writeHead += 18;
-
-    //local color table
-    memcpy(writeHead, table, tableSize * sizeof(Color3));
-    writeHead += tableSize * sizeof(Color3);
-    *writeHead++ = tableBits;
-
-    //prep block
-    memset(writeHead, 0, 260);
-    writeHead[0] = 255;
-    uint32_t blockBits = 8; //relative to block.head
-
-    //SPEC: "Encoders should output a Clear code as the first code of each image data stream."
-    msf_lzw_reset(&lzw, tableSize, tableIdx);
-    msf_put_code(&writeHead, &blockBits, msf_bit_log(lzw.len - 1), tableSize);
-
-    int lastCode = hasSamePal && frame.pixels[0] == previous.pixels[0]? 0 : tlb[frame.pixels[0]];
-    MsfTimeLoop("compress") for (int i = 1; i < width * height; ++i) {
-        //PERF: branching vs. branchless version of this line is observed to have no discernable impact on speed
-        int color = hasSamePal && frame.pixels[i] == previous.pixels[i]? 0 : tlb[frame.pixels[i]];
-        //PERF: branchless version must use && otherwise it will segfault on frame 1, but it's well-predicted so OK
-        // int color = (!(hasSamePal && frame.pixels[i] == previous.pixels[i])) * tlb[frame.pixels[i]];
-        int code = (&lzw.data[lastCode * lzw.stride])[color];
-        if (code < 0) {
-            //write to code stream
-            int codeBits = msf_bit_log(lzw.len - 1);
-            msf_put_code(&writeHead, &blockBits, codeBits, lastCode);
-
-            if (lzw.len > 4095) {
-                //reset buffer code table
-                msf_put_code(&writeHead, &blockBits, codeBits, tableSize);
-                msf_lzw_reset(&lzw, tableSize, tableIdx);
-            } else {
-                (&lzw.data[lastCode * lzw.stride])[color] = lzw.len;
-                ++lzw.len;
-            }
-
-            lastCode = color;
-        } else {
-            lastCode = code;
-        }
-    }
-
-    MSF_GIF_FREE(allocContext, lzw.data, lzwAllocSize);
-    MSF_GIF_FREE(allocContext, previous.pixels, width * height * sizeof(uint32_t));
-
-    //write code for leftover index buffer contents, then the end code
-    msf_put_code(&writeHead, &blockBits, msf_imin(12, msf_bit_log(lzw.len - 1)), lastCode);
-    msf_put_code(&writeHead, &blockBits, msf_imin(12, msf_bit_log(lzw.len)), tableSize + 1);
-
-    //flush remaining data
-    if (blockBits > 8) {
-        int bytes = (blockBits + 7) / 8; //round up
-        writeHead[0] = bytes - 1;
-        writeHead += bytes;
-    }
-    *writeHead++ = 0; //terminating block
-
-    //filling in buffer header and shrink buffer to fit data
-    MsfBufferHeader * header = (MsfBufferHeader *) allocation;
-    header->next = NULL;
-    header->size = writeHead - writeBase;
-    uint8_t * moved = (uint8_t *) MSF_GIF_REALLOC(allocContext, allocation, maxBufSize, writeHead - allocation);
-    if (!moved) { MSF_GIF_FREE(allocContext, allocation, maxBufSize); return NULL; }
-    return moved;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Incremental API                                                                                                  ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-int msf_gif_begin(MsfGifState * handle, int width, int height) { MsfTimeFunc
-    MsfCookedFrame empty = {0}; //god I hate MSVC...
-    handle->previousFrame = empty;
-    handle->width = width;
-    handle->height = height;
-
-    //setup header buffer header (lol)
-    handle->listHead = (uint8_t *) MSF_GIF_MALLOC(handle->customAllocatorContext, sizeof(MsfBufferHeader) + 32);
-    if (!handle->listHead) { return 0; }
-    handle->listTail = handle->listHead;
-    MsfBufferHeader * header = (MsfBufferHeader *) handle->listHead;
-    header->next = NULL;
-    header->size = 32;
-
-    //NOTE: because __attribute__((__packed__)) is annoyingly compiler-specific, we do this unreadable weirdness
-    char headerBytes[33] = "GIF89a\0\0\0\0\x10\0\0" "\x21\xFF\x0BNETSCAPE2.0\x03\x01\0\0\0";
-    memcpy(&headerBytes[6], &width, 2);
-    memcpy(&headerBytes[8], &height, 2);
-    memcpy(handle->listHead + sizeof(MsfBufferHeader), headerBytes, 32);
-    return 1;
-}
-
-int msf_gif_frame(MsfGifState * handle, uint8_t * pixelData, int centiSecondsPerFame, int maxBitDepth, int pitchInBytes)
-{ MsfTimeFunc
-    if (!handle->listHead) { return 0; }
-
-    maxBitDepth = msf_imax(1, msf_imin(16, maxBitDepth));
-    if (pitchInBytes == 0) pitchInBytes = handle->width * 4;
-    if (pitchInBytes < 0) pixelData -= pitchInBytes * (handle->height - 1);
-
-    uint8_t used[1 << 16]; //only 64k, so stack allocating is fine
-    MsfCookedFrame frame =
-        msf_cook_frame(handle->customAllocatorContext, pixelData, used, handle->width, handle->height, pitchInBytes,
-            msf_imin(maxBitDepth, handle->previousFrame.depth + 160 / msf_imax(1, handle->previousFrame.count)));
-    //TODO: de-duplicate cleanup code
-    if (!frame.pixels) {
-        MSF_GIF_FREE(handle->customAllocatorContext,
-                     handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            node = header->next;
-            MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-        }
-        handle->listHead = handle->listTail = NULL;
-        return 0;
-    }
-
-    uint8_t * buffer = msf_compress_frame(handle->customAllocatorContext,
-        handle->width, handle->height, centiSecondsPerFame, frame, handle->previousFrame, used);
-    ((MsfBufferHeader *) handle->listTail)->next = buffer;
-    handle->listTail = buffer;
-    if (!buffer) {
-        MSF_GIF_FREE(handle->customAllocatorContext, frame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        MSF_GIF_FREE(handle->customAllocatorContext,
-                     handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            node = header->next;
-            MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-        }
-        handle->listHead = handle->listTail = NULL;
-        return 0;
-    }
-
-    handle->previousFrame = frame;
-    return 1;
-}
-
-MsfGifResult msf_gif_end(MsfGifState * handle) { MsfTimeFunc
-    if (!handle->listHead) { MsfGifResult empty = {0}; return empty; }
-
-    MSF_GIF_FREE(handle->customAllocatorContext,
-                 handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-
-    //first pass: determine total size
-    size_t total = 1; //1 byte for trailing marker
-    for (uint8_t * node = handle->listHead; node;) {
-        MsfBufferHeader * header = (MsfBufferHeader *) node;
-        node = header->next;
-        total += header->size;
-    }
-
-    //second pass: write data
-    uint8_t * buffer = (uint8_t *) MSF_GIF_MALLOC(handle->customAllocatorContext, total);
-    if (buffer) {
-        uint8_t * writeHead = buffer;
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            memcpy(writeHead, node + sizeof(MsfBufferHeader), header->size);
-            writeHead += header->size;
-            node = header->next;
-        }
-        *writeHead++ = 0x3B;
-    }
-
-    //third pass: free buffers
-    for (uint8_t * node = handle->listHead; node;) {
-        MsfBufferHeader * header = (MsfBufferHeader *) node;
-        node = header->next;
-        MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-    }
-
-    MsfGifResult ret = { buffer, total, total, handle->customAllocatorContext };
-    return ret;
-}
-
-void msf_gif_free(MsfGifResult result) {
-    if (result.data) { MSF_GIF_FREE(result.contextPointer, result.data, result.allocSize); }
-}
-
-#endif //MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-#endif //MSF_GIF_IMPL
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Miles Fogle
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/par_shapes.h b/raylib/external/par_shapes.h
deleted file mode 100644 (file)
index 8b65e38..0000000
+++ /dev/null
@@ -1,2051 +0,0 @@
-// SHAPES :: https://github.com/prideout/par
-// Simple C library for creation and manipulation of triangle meshes.
-//
-// The API is divided into three sections:
-//
-//   - Generators.  Create parametric surfaces, platonic solids, etc.
-//   - Queries.     Ask a mesh for its axis-aligned bounding box, etc.
-//   - Transforms.  Rotate a mesh, merge it with another, add normals, etc.
-//
-// In addition to the comment block above each function declaration, the API
-// has informal documentation here:
-//
-//     https://prideout.net/shapes
-//
-// For our purposes, a "mesh" is a list of points and a list of triangles; the
-// former is a flattened list of three-tuples (32-bit floats) and the latter is
-// also a flattened list of three-tuples (16-bit uints).  Triangles are always
-// oriented such that their front face winds counter-clockwise.
-//
-// Optionally, meshes can contain 3D normals (one per vertex), and 2D texture
-// coordinates (one per vertex).  That's it!  If you need something fancier,
-// look elsewhere.
-//
-// The MIT License
-// Copyright (c) 2015 Philip Rideout
-
-#ifndef PAR_SHAPES_H
-#define PAR_SHAPES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-// Ray: commented to avoid conflict with raylib bool
-/*
-#if !defined(_MSC_VER)
-# include <stdbool.h>
-#else // MSVC
-# if _MSC_VER >= 1800
-#  include <stdbool.h>
-# else // stdbool.h missing prior to MSVC++ 12.0 (VS2013)
-//#  define bool int      
-//#  define true 1
-//#  define false 0
-# endif
-#endif
-*/
-
-#ifndef PAR_SHAPES_T
-#define PAR_SHAPES_T uint16_t
-#endif
-
-typedef struct par_shapes_mesh_s {
-    float* points;           // Flat list of 3-tuples (X Y Z X Y Z...)
-    int npoints;             // Number of points
-    PAR_SHAPES_T* triangles; // Flat list of 3-tuples (I J K I J K...)
-    int ntriangles;          // Number of triangles
-    float* normals;          // Optional list of 3-tuples (X Y Z X Y Z...)
-    float* tcoords;          // Optional list of 2-tuples (U V U V U V...)
-} par_shapes_mesh;
-
-void par_shapes_free_mesh(par_shapes_mesh*);
-
-// Generators ------------------------------------------------------------------
-
-// Instance a cylinder that sits on the Z=0 plane using the given tessellation
-// levels across the UV domain.  Think of "slices" like a number of pizza
-// slices, and "stacks" like a number of stacked rings.  Height and radius are
-// both 1.0, but they can easily be changed with par_shapes_scale.
-par_shapes_mesh* par_shapes_create_cylinder(int slices, int stacks);
-
-// Create a donut that sits on the Z=0 plane with the specified inner radius.
-// The outer radius can be controlled with par_shapes_scale.
-par_shapes_mesh* par_shapes_create_torus(int slices, int stacks, float radius);
-
-// Create a sphere with texture coordinates and small triangles near the poles.
-par_shapes_mesh* par_shapes_create_parametric_sphere(int slices, int stacks);
-
-// Approximate a sphere with a subdivided icosahedron, which produces a nice
-// distribution of triangles, but no texture coordinates.  Each subdivision
-// level scales the number of triangles by four, so use a very low number.
-par_shapes_mesh* par_shapes_create_subdivided_sphere(int nsubdivisions);
-
-// More parametric surfaces.
-par_shapes_mesh* par_shapes_create_klein_bottle(int slices, int stacks);
-par_shapes_mesh* par_shapes_create_trefoil_knot(int slices, int stacks,
-    float radius);
-par_shapes_mesh* par_shapes_create_hemisphere(int slices, int stacks);
-par_shapes_mesh* par_shapes_create_plane(int slices, int stacks);
-
-// Create a parametric surface from a callback function that consumes a 2D
-// point in [0,1] and produces a 3D point.
-typedef void (*par_shapes_fn)(float const*, float*, void*);
-par_shapes_mesh* par_shapes_create_parametric(par_shapes_fn, int slices,
-    int stacks, void* userdata);
-
-// Generate points for a 20-sided polyhedron that fits in the unit sphere.
-// Texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_icosahedron();
-
-// Generate points for a 12-sided polyhedron that fits in the unit sphere.
-// Again, texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_dodecahedron();
-
-// More platonic solids.
-par_shapes_mesh* par_shapes_create_octahedron();
-par_shapes_mesh* par_shapes_create_tetrahedron();
-par_shapes_mesh* par_shapes_create_cube();
-
-// Generate an orientable disk shape in 3-space.  Does not include normals or
-// texture coordinates.
-par_shapes_mesh* par_shapes_create_disk(float radius, int slices,
-    float const* center, float const* normal);
-
-// Create an empty shape.  Useful for building scenes with merge_and_free.
-par_shapes_mesh* par_shapes_create_empty();
-
-// Generate a rock shape that sits on the Y=0 plane, and sinks into it a bit.
-// This includes smooth normals but no texture coordinates.  Each subdivision
-// level scales the number of triangles by four, so use a very low number.
-par_shapes_mesh* par_shapes_create_rock(int seed, int nsubdivisions);
-
-// Create trees or vegetation by executing a recursive turtle graphics program.
-// The program is a list of command-argument pairs.  See the unit test for
-// an example.  Texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_lsystem(char const* program, int slices,
-    int maxdepth);
-
-// Queries ---------------------------------------------------------------------
-
-// Dump out a text file conforming to the venerable OBJ format.
-void par_shapes_export(par_shapes_mesh const*, char const* objfile);
-
-// Take a pointer to 6 floats and set them to min xyz, max xyz.
-void par_shapes_compute_aabb(par_shapes_mesh const* mesh, float* aabb);
-
-// Make a deep copy of a mesh.  To make a brand new copy, pass null to "target".
-// To avoid memory churn, pass an existing mesh to "target".
-par_shapes_mesh* par_shapes_clone(par_shapes_mesh const* mesh,
-    par_shapes_mesh* target);
-
-// Transformations -------------------------------------------------------------
-
-void par_shapes_merge(par_shapes_mesh* dst, par_shapes_mesh const* src);
-void par_shapes_translate(par_shapes_mesh*, float x, float y, float z);
-void par_shapes_rotate(par_shapes_mesh*, float radians, float const* axis);
-void par_shapes_scale(par_shapes_mesh*, float x, float y, float z);
-void par_shapes_merge_and_free(par_shapes_mesh* dst, par_shapes_mesh* src);
-
-// Reverse the winding of a run of faces.  Useful when drawing the inside of
-// a Cornell Box.  Pass 0 for nfaces to reverse every face in the mesh.
-void par_shapes_invert(par_shapes_mesh*, int startface, int nfaces);
-
-// Remove all triangles whose area is less than minarea.
-void par_shapes_remove_degenerate(par_shapes_mesh*, float minarea);
-
-// Dereference the entire index buffer and replace the point list.
-// This creates an inefficient structure, but is useful for drawing facets.
-// If create_indices is true, a trivial "0 1 2 3..." index buffer is generated.
-void par_shapes_unweld(par_shapes_mesh* mesh, bool create_indices);
-
-// Merge colocated verts, build a new index buffer, and return the
-// optimized mesh.  Epsilon is the maximum distance to consider when
-// welding vertices. The mapping argument can be null, or a pointer to
-// npoints integers, which gets filled with the mapping from old vertex
-// indices to new indices.
-par_shapes_mesh* par_shapes_weld(par_shapes_mesh const*, float epsilon,
-    PAR_SHAPES_T* mapping);
-
-// Compute smooth normals by averaging adjacent facet normals.
-void par_shapes_compute_normals(par_shapes_mesh* m);
-
-#ifndef PAR_PI
-#define PAR_PI (3.14159265359)
-#define PAR_MIN(a, b) (a > b ? b : a)
-#define PAR_MAX(a, b) (a > b ? a : b)
-#define PAR_CLAMP(v, lo, hi) PAR_MAX(lo, PAR_MIN(hi, v))
-#define PAR_SWAP(T, A, B) { T tmp = B; B = A; A = tmp; }
-#define PAR_SQR(a) ((a) * (a))
-#endif
-
-#ifndef PAR_MALLOC
-#define PAR_MALLOC(T, N) ((T*) malloc(N * sizeof(T)))
-#define PAR_CALLOC(T, N) ((T*) calloc(N * sizeof(T), 1))
-#define PAR_REALLOC(T, BUF, N) ((T*) realloc(BUF, sizeof(T) * (N)))
-#define PAR_FREE(BUF) free(BUF)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-// -----------------------------------------------------------------------------
-// END PUBLIC API
-// -----------------------------------------------------------------------------
-
-#ifdef PAR_SHAPES_IMPLEMENTATION
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <float.h>
-#include <string.h>
-#include <math.h>
-#include <errno.h>
-
-static void par_shapes__sphere(float const* uv, float* xyz, void*);
-static void par_shapes__hemisphere(float const* uv, float* xyz, void*);
-static void par_shapes__plane(float const* uv, float* xyz, void*);
-static void par_shapes__klein(float const* uv, float* xyz, void*);
-static void par_shapes__cylinder(float const* uv, float* xyz, void*);
-static void par_shapes__torus(float const* uv, float* xyz, void*);
-static void par_shapes__trefoil(float const* uv, float* xyz, void*);
-
-struct osn_context;
-static int par__simplex_noise(int64_t seed, struct osn_context** ctx);
-static void par__simplex_noise_free(struct osn_context* ctx);
-static double par__simplex_noise2(struct osn_context* ctx, double x, double y);
-
-static void par_shapes__copy3(float* result, float const* a)
-{
-    result[0] = a[0];
-    result[1] = a[1];
-    result[2] = a[2];
-}
-
-static float par_shapes__dot3(float const* a, float const* b)
-{
-    return b[0] * a[0] + b[1] * a[1] + b[2] * a[2];
-}
-
-static void par_shapes__transform3(float* p, float const* x, float const* y,
-    float const* z)
-{
-    float px = par_shapes__dot3(p, x);
-    float py = par_shapes__dot3(p, y);
-    float pz = par_shapes__dot3(p, z);
-    p[0] = px;
-    p[1] = py;
-    p[2] = pz;
-}
-
-static void par_shapes__cross3(float* result, float const* a, float const* b)
-{
-    float x = (a[1] * b[2]) - (a[2] * b[1]);
-    float y = (a[2] * b[0]) - (a[0] * b[2]);
-    float z = (a[0] * b[1]) - (a[1] * b[0]);
-    result[0] = x;
-    result[1] = y;
-    result[2] = z;
-}
-
-static void par_shapes__mix3(float* d, float const* a, float const* b, float t)
-{
-    float x = b[0] * t + a[0] * (1 - t);
-    float y = b[1] * t + a[1] * (1 - t);
-    float z = b[2] * t + a[2] * (1 - t);
-    d[0] = x;
-    d[1] = y;
-    d[2] = z;
-}
-
-static void par_shapes__scale3(float* result, float a)
-{
-    result[0] *= a;
-    result[1] *= a;
-    result[2] *= a;
-}
-
-static void par_shapes__normalize3(float* v)
-{
-    float lsqr = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
-    if (lsqr > 0) {
-        par_shapes__scale3(v, 1.0f / lsqr);
-    }
-}
-
-static void par_shapes__subtract3(float* result, float const* a)
-{
-    result[0] -= a[0];
-    result[1] -= a[1];
-    result[2] -= a[2];
-}
-
-static void par_shapes__add3(float* result, float const* a)
-{
-    result[0] += a[0];
-    result[1] += a[1];
-    result[2] += a[2];
-}
-
-static float par_shapes__sqrdist3(float const* a, float const* b)
-{
-    float dx = a[0] - b[0];
-    float dy = a[1] - b[1];
-    float dz = a[2] - b[2];
-    return dx * dx + dy * dy + dz * dz;
-}
-
-static void par_shapes__compute_welded_normals(par_shapes_mesh* m)
-{
-    m->normals = PAR_MALLOC(float, m->npoints * 3);
-    PAR_SHAPES_T* weldmap = PAR_MALLOC(PAR_SHAPES_T, m->npoints);
-    par_shapes_mesh* welded = par_shapes_weld(m, 0.01, weldmap);
-    par_shapes_compute_normals(welded);
-    float* pdst = m->normals;
-    for (int i = 0; i < m->npoints; i++, pdst += 3) {
-        int d = weldmap[i];
-        float const* pnormal = welded->normals + d * 3;
-        pdst[0] = pnormal[0];
-        pdst[1] = pnormal[1];
-        pdst[2] = pnormal[2];
-    }
-    PAR_FREE(weldmap);
-    par_shapes_free_mesh(welded);
-}
-
-par_shapes_mesh* par_shapes_create_cylinder(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 1) {
-        return 0;
-    }
-    return par_shapes_create_parametric(par_shapes__cylinder, slices,
-        stacks, 0);
-}
-
-par_shapes_mesh* par_shapes_create_parametric_sphere(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* m = par_shapes_create_parametric(par_shapes__sphere,
-        slices, stacks, 0);
-    par_shapes_remove_degenerate(m, 0.0001);
-    return m;
-}
-
-par_shapes_mesh* par_shapes_create_hemisphere(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* m = par_shapes_create_parametric(par_shapes__hemisphere,
-        slices, stacks, 0);
-    par_shapes_remove_degenerate(m, 0.0001);
-    return m;
-}
-
-par_shapes_mesh* par_shapes_create_torus(int slices, int stacks, float radius)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    assert(radius <= 1.0 && "Use smaller radius to avoid self-intersection.");
-    assert(radius >= 0.1 && "Use larger radius to avoid self-intersection.");
-    void* userdata = (void*) &radius;
-    return par_shapes_create_parametric(par_shapes__torus, slices,
-        stacks, userdata);
-}
-
-par_shapes_mesh* par_shapes_create_klein_bottle(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* mesh = par_shapes_create_parametric(
-        par_shapes__klein, slices, stacks, 0);
-    int face = 0;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++, face += 2) {
-            if (stack < 27 * stacks / 32) {
-                par_shapes_invert(mesh, face, 2);
-            }
-        }
-    }
-    par_shapes__compute_welded_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_trefoil_knot(int slices, int stacks,
-    float radius)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    assert(radius <= 3.0 && "Use smaller radius to avoid self-intersection.");
-    assert(radius >= 0.5 && "Use larger radius to avoid self-intersection.");
-    void* userdata = (void*) &radius;
-    return par_shapes_create_parametric(par_shapes__trefoil, slices,
-        stacks, userdata);
-}
-
-par_shapes_mesh* par_shapes_create_plane(int slices, int stacks)
-{
-    if (slices < 1 || stacks < 1) {
-        return 0;
-    }
-    return par_shapes_create_parametric(par_shapes__plane, slices,
-        stacks, 0);
-}
-
-par_shapes_mesh* par_shapes_create_parametric(par_shapes_fn fn,
-    int slices, int stacks, void* userdata)
-{
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-
-    // Generate verts.
-    mesh->npoints = (slices + 1) * (stacks + 1);
-    mesh->points = PAR_CALLOC(float, 3 * mesh->npoints);
-    float uv[2];
-    float xyz[3];
-    float* points = mesh->points;
-    for (int stack = 0; stack < stacks + 1; stack++) {
-        uv[0] = (float) stack / stacks;
-        for (int slice = 0; slice < slices + 1; slice++) {
-            uv[1] = (float) slice / slices;
-            fn(uv, xyz, userdata);
-            *points++ = xyz[0];
-            *points++ = xyz[1];
-            *points++ = xyz[2];
-        }
-    }
-
-    // Generate texture coordinates.
-    mesh->tcoords = PAR_CALLOC(float, 2 * mesh->npoints);
-    float* uvs = mesh->tcoords;
-    for (int stack = 0; stack < stacks + 1; stack++) {
-        uv[0] = (float) stack / stacks;
-        for (int slice = 0; slice < slices + 1; slice++) {
-            uv[1] = (float) slice / slices;
-            *uvs++ = uv[0];
-            *uvs++ = uv[1];
-        }
-    }
-
-    // Generate faces.
-    mesh->ntriangles = 2 * slices * stacks;
-    mesh->triangles = PAR_CALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    int v = 0;
-    PAR_SHAPES_T* face = mesh->triangles;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++) {
-            int next = slice + 1;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next;
-            *face++ = v + slice;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next + slices + 1;
-            *face++ = v + next;
-        }
-        v += slices + 1;
-    }
-
-    par_shapes__compute_welded_normals(mesh);
-    return mesh;
-}
-
-void par_shapes_free_mesh(par_shapes_mesh* mesh)
-{
-    PAR_FREE(mesh->points);
-    PAR_FREE(mesh->triangles);
-    PAR_FREE(mesh->normals);
-    PAR_FREE(mesh->tcoords);
-    PAR_FREE(mesh);
-}
-
-void par_shapes_export(par_shapes_mesh const* mesh, char const* filename)
-{
-    FILE* objfile = fopen(filename, "wt");
-    float const* points = mesh->points;
-    float const* tcoords = mesh->tcoords;
-    float const* norms = mesh->normals;
-    PAR_SHAPES_T const* indices = mesh->triangles;
-    if (tcoords && norms) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vt %f %f\n", tcoords[0], tcoords[1]);
-            fprintf(objfile, "vn %f %f %f\n", norms[0], norms[1], norms[2]);
-            points += 3;
-            norms += 3;
-            tcoords += 2;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d/%d/%d %d/%d/%d %d/%d/%d\n",
-                a, a, a, b, b, b, c, c, c);
-        }
-    } else if (norms) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vn %f %f %f\n", norms[0], norms[1], norms[2]);
-            points += 3;
-            norms += 3;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d//%d %d//%d %d//%d\n", a, a, b, b, c, c);
-        }
-    } else if (tcoords) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vt %f %f\n", tcoords[0], tcoords[1]);
-            points += 3;
-            tcoords += 2;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d/%d %d/%d %d/%d\n", a, a, b, b, c, c);
-        }
-    } else {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            points += 3;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d %d %d\n", a, b, c);
-        }
-    }
-    fclose(objfile);
-}
-
-static void par_shapes__sphere(float const* uv, float* xyz, void* userdata)
-{
-    float phi = uv[0] * PAR_PI;
-    float theta = uv[1] * 2 * PAR_PI;
-    xyz[0] = cosf(theta) * sinf(phi);
-    xyz[1] = sinf(theta) * sinf(phi);
-    xyz[2] = cosf(phi);
-}
-
-static void par_shapes__hemisphere(float const* uv, float* xyz, void* userdata)
-{
-    float phi = uv[0] * PAR_PI;
-    float theta = uv[1] * PAR_PI;
-    xyz[0] = cosf(theta) * sinf(phi);
-    xyz[1] = sinf(theta) * sinf(phi);
-    xyz[2] = cosf(phi);
-}
-
-static void par_shapes__plane(float const* uv, float* xyz, void* userdata)
-{
-    xyz[0] = uv[0];
-    xyz[1] = uv[1];
-    xyz[2] = 0;
-}
-
-static void par_shapes__klein(float const* uv, float* xyz, void* userdata)
-{
-    float u = uv[0] * PAR_PI;
-    float v = uv[1] * 2 * PAR_PI;
-    u = u * 2;
-    if (u < PAR_PI) {
-        xyz[0] = 3 * cosf(u) * (1 + sinf(u)) + (2 * (1 - cosf(u) / 2)) *
-            cosf(u) * cosf(v);
-        xyz[2] = -8 * sinf(u) - 2 * (1 - cosf(u) / 2) * sinf(u) * cosf(v);
-    } else {
-        xyz[0] = 3 * cosf(u) * (1 + sinf(u)) + (2 * (1 - cosf(u) / 2)) *
-            cosf(v + PAR_PI);
-        xyz[2] = -8 * sinf(u);
-    }
-    xyz[1] = -2 * (1 - cosf(u) / 2) * sinf(v);
-}
-
-static void par_shapes__cylinder(float const* uv, float* xyz, void* userdata)
-{
-    float theta = uv[1] * 2 * PAR_PI;
-    xyz[0] = sinf(theta);
-    xyz[1] = cosf(theta);
-    xyz[2] = uv[0];
-}
-
-static void par_shapes__torus(float const* uv, float* xyz, void* userdata)
-{
-    float major = 1;
-    float minor = *((float*) userdata);
-    float theta = uv[0] * 2 * PAR_PI;
-    float phi = uv[1] * 2 * PAR_PI;
-    float beta = major + minor * cosf(phi);
-    xyz[0] = cosf(theta) * beta;
-    xyz[1] = sinf(theta) * beta;
-    xyz[2] = sinf(phi) * minor;
-}
-
-static void par_shapes__trefoil(float const* uv, float* xyz, void* userdata)
-{
-    float minor = *((float*) userdata);
-    const float a = 0.5f;
-    const float b = 0.3f;
-    const float c = 0.5f;
-    const float d = minor * 0.1f;
-    const float u = (1 - uv[0]) * 4 * PAR_PI;
-    const float v = uv[1] * 2 * PAR_PI;
-    const float r = a + b * cos(1.5f * u);
-    const float x = r * cos(u);
-    const float y = r * sin(u);
-    const float z = c * sin(1.5f * u);
-    float q[3];
-    q[0] =
-        -1.5f * b * sin(1.5f * u) * cos(u) - (a + b * cos(1.5f * u)) * sin(u);
-    q[1] =
-        -1.5f * b * sin(1.5f * u) * sin(u) + (a + b * cos(1.5f * u)) * cos(u);
-    q[2] = 1.5f * c * cos(1.5f * u);
-    par_shapes__normalize3(q);
-    float qvn[3] = {q[1], -q[0], 0};
-    par_shapes__normalize3(qvn);
-    float ww[3];
-    par_shapes__cross3(ww, q, qvn);
-    xyz[0] = x + d * (qvn[0] * cos(v) + ww[0] * sin(v));
-    xyz[1] = y + d * (qvn[1] * cos(v) + ww[1] * sin(v));
-    xyz[2] = z + d * ww[2] * sin(v);
-}
-
-void par_shapes_merge(par_shapes_mesh* dst, par_shapes_mesh const* src)
-{
-    PAR_SHAPES_T offset = dst->npoints;
-    int npoints = dst->npoints + src->npoints;
-    int vecsize = sizeof(float) * 3;
-    dst->points = PAR_REALLOC(float, dst->points, 3 * npoints);
-    memcpy(dst->points + 3 * dst->npoints, src->points, vecsize * src->npoints);
-    dst->npoints = npoints;
-    if (src->normals || dst->normals) {
-        dst->normals = PAR_REALLOC(float, dst->normals, 3 * npoints);
-        if (src->normals) {
-            memcpy(dst->normals + 3 * offset, src->normals,
-                vecsize * src->npoints);
-        }
-    }
-    if (src->tcoords || dst->tcoords) {
-        int uvsize = sizeof(float) * 2;
-        dst->tcoords = PAR_REALLOC(float, dst->tcoords, 2 * npoints);
-        if (src->tcoords) {
-            memcpy(dst->tcoords + 2 * offset, src->tcoords,
-                uvsize * src->npoints);
-        }
-    }
-    int ntriangles = dst->ntriangles + src->ntriangles;
-    dst->triangles = PAR_REALLOC(PAR_SHAPES_T, dst->triangles, 3 * ntriangles);
-    PAR_SHAPES_T* ptriangles = dst->triangles + 3 * dst->ntriangles;
-    PAR_SHAPES_T const* striangles = src->triangles;
-    for (int i = 0; i < src->ntriangles; i++) {
-        *ptriangles++ = offset + *striangles++;
-        *ptriangles++ = offset + *striangles++;
-        *ptriangles++ = offset + *striangles++;
-    }
-    dst->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_disk(float radius, int slices,
-    float const* center, float const* normal)
-{
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    mesh->npoints = slices + 1;
-    mesh->points = PAR_MALLOC(float, 3 * mesh->npoints);
-    float* points = mesh->points;
-    *points++ = 0;
-    *points++ = 0;
-    *points++ = 0;
-    for (int i = 0; i < slices; i++) {
-        float theta = i * PAR_PI * 2 / slices;
-        *points++ = radius * cos(theta);
-        *points++ = radius * sin(theta);
-        *points++ = 0;
-    }
-    float nnormal[3] = {normal[0], normal[1], normal[2]};
-    par_shapes__normalize3(nnormal);
-    mesh->normals = PAR_MALLOC(float, 3 * mesh->npoints);
-    float* norms = mesh->normals;
-    for (int i = 0; i < mesh->npoints; i++) {
-        *norms++ = nnormal[0];
-        *norms++ = nnormal[1];
-        *norms++ = nnormal[2];
-    }
-    mesh->ntriangles = slices;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    PAR_SHAPES_T* triangles = mesh->triangles;
-    for (int i = 0; i < slices; i++) {
-        *triangles++ = 0;
-        *triangles++ = 1 + i;
-        *triangles++ = 1 + (i + 1) % slices;
-    }
-    float k[3] = {0, 0, -1};
-    float axis[3];
-    par_shapes__cross3(axis, nnormal, k);
-    par_shapes__normalize3(axis);
-    par_shapes_rotate(mesh, acos(nnormal[2]), axis);
-    par_shapes_translate(mesh, center[0], center[1], center[2]);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_empty()
-{
-    return PAR_CALLOC(par_shapes_mesh, 1);
-}
-
-void par_shapes_translate(par_shapes_mesh* m, float x, float y, float z)
-{
-    float* points = m->points;
-    for (int i = 0; i < m->npoints; i++) {
-        *points++ += x;
-        *points++ += y;
-        *points++ += z;
-    }
-}
-
-void par_shapes_rotate(par_shapes_mesh* mesh, float radians, float const* axis)
-{
-    float s = sinf(radians);
-    float c = cosf(radians);
-    float x = axis[0];
-    float y = axis[1];
-    float z = axis[2];
-    float xy = x * y;
-    float yz = y * z;
-    float zx = z * x;
-    float oneMinusC = 1.0f - c;
-    float col0[3] = {
-        (((x * x) * oneMinusC) + c),
-        ((xy * oneMinusC) + (z * s)), ((zx * oneMinusC) - (y * s))
-    };
-    float col1[3] = {
-        ((xy * oneMinusC) - (z * s)),
-        (((y * y) * oneMinusC) + c), ((yz * oneMinusC) + (x * s))
-    };
-    float col2[3] = {
-        ((zx * oneMinusC) + (y * s)),
-        ((yz * oneMinusC) - (x * s)), (((z * z) * oneMinusC) + c)
-    };
-    float* p = mesh->points;
-    for (int i = 0; i < mesh->npoints; i++, p += 3) {
-        float x = col0[0] * p[0] + col1[0] * p[1] + col2[0] * p[2];
-        float y = col0[1] * p[0] + col1[1] * p[1] + col2[1] * p[2];
-        float z = col0[2] * p[0] + col1[2] * p[1] + col2[2] * p[2];
-        p[0] = x;
-        p[1] = y;
-        p[2] = z;
-    }
-    p = mesh->normals;
-    if (p) {
-        for (int i = 0; i < mesh->npoints; i++, p += 3) {
-            float x = col0[0] * p[0] + col1[0] * p[1] + col2[0] * p[2];
-            float y = col0[1] * p[0] + col1[1] * p[1] + col2[1] * p[2];
-            float z = col0[2] * p[0] + col1[2] * p[1] + col2[2] * p[2];
-            p[0] = x;
-            p[1] = y;
-            p[2] = z;
-        }
-    }
-}
-
-void par_shapes_scale(par_shapes_mesh* m, float x, float y, float z)
-{
-    float* points = m->points;
-    for (int i = 0; i < m->npoints; i++) {
-        *points++ *= x;
-        *points++ *= y;
-        *points++ *= z;
-    }
-}
-
-void par_shapes_merge_and_free(par_shapes_mesh* dst, par_shapes_mesh* src)
-{
-    par_shapes_merge(dst, src);
-    par_shapes_free_mesh(src);
-}
-
-void par_shapes_compute_aabb(par_shapes_mesh const* m, float* aabb)
-{
-    float* points = m->points;
-    aabb[0] = aabb[3] = points[0];
-    aabb[1] = aabb[4] = points[1];
-    aabb[2] = aabb[5] = points[2];
-    points += 3;
-    for (int i = 1; i < m->npoints; i++, points += 3) {
-        aabb[0] = PAR_MIN(points[0], aabb[0]);
-        aabb[1] = PAR_MIN(points[1], aabb[1]);
-        aabb[2] = PAR_MIN(points[2], aabb[2]);
-        aabb[3] = PAR_MAX(points[0], aabb[3]);
-        aabb[4] = PAR_MAX(points[1], aabb[4]);
-        aabb[5] = PAR_MAX(points[2], aabb[5]);
-    }
-}
-
-void par_shapes_invert(par_shapes_mesh* m, int face, int nfaces)
-{
-    nfaces = nfaces ? nfaces : m->ntriangles;
-    PAR_SHAPES_T* tri = m->triangles + face * 3;
-    for (int i = 0; i < nfaces; i++) {
-        PAR_SWAP(PAR_SHAPES_T, tri[0], tri[2]);
-        tri += 3;
-    }
-}
-
-par_shapes_mesh* par_shapes_create_icosahedron()
-{
-    static float verts[] = {
-        0.000,  0.000,  1.000,
-        0.894,  0.000,  0.447,
-        0.276,  0.851,  0.447,
-        -0.724,  0.526,  0.447,
-        -0.724, -0.526,  0.447,
-        0.276, -0.851,  0.447,
-        0.724,  0.526, -0.447,
-        -0.276,  0.851, -0.447,
-        -0.894,  0.000, -0.447,
-        -0.276, -0.851, -0.447,
-        0.724, -0.526, -0.447,
-        0.000,  0.000, -1.000
-    };
-    static PAR_SHAPES_T faces[] = {
-        0,1,2,
-        0,2,3,
-        0,3,4,
-        0,4,5,
-        0,5,1,
-        7,6,11,
-        8,7,11,
-        9,8,11,
-        10,9,11,
-        6,10,11,
-        6,2,1,
-        7,3,2,
-        8,4,3,
-        9,5,4,
-        10,1,5,
-        6,7,2,
-        7,8,3,
-        8,9,4,
-        9,10,5,
-        10,6,1
-    };
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    mesh->npoints = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->points = PAR_MALLOC(float, sizeof(verts) / 4);
-    memcpy(mesh->points, verts, sizeof(verts));
-    mesh->ntriangles = sizeof(faces) / sizeof(faces[0]) / 3;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, sizeof(faces) / 2);
-    memcpy(mesh->triangles, faces, sizeof(faces));
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_dodecahedron()
-{
-    static float verts[20 * 3] = {
-        0.607, 0.000, 0.795,
-        0.188, 0.577, 0.795,
-        -0.491, 0.357, 0.795,
-        -0.491, -0.357, 0.795,
-        0.188, -0.577, 0.795,
-        0.982, 0.000, 0.188,
-        0.304, 0.934, 0.188,
-        -0.795, 0.577, 0.188,
-        -0.795, -0.577, 0.188,
-        0.304, -0.934, 0.188,
-        0.795, 0.577, -0.188,
-        -0.304, 0.934, -0.188,
-        -0.982, 0.000, -0.188,
-        -0.304, -0.934, -0.188,
-        0.795, -0.577, -0.188,
-        0.491, 0.357, -0.795,
-        -0.188, 0.577, -0.795,
-        -0.607, 0.000, -0.795,
-        -0.188, -0.577, -0.795,
-        0.491, -0.357, -0.795,
-    };
-    static PAR_SHAPES_T pentagons[12 * 5] = {
-        0,1,2,3,4,
-        5,10,6,1,0,
-        6,11,7,2,1,
-        7,12,8,3,2,
-        8,13,9,4,3,
-        9,14,5,0,4,
-        15,16,11,6,10,
-        16,17,12,7,11,
-        17,18,13,8,12,
-        18,19,14,9,13,
-        19,15,10,5,14,
-        19,18,17,16,15
-    };
-    int npentagons = sizeof(pentagons) / sizeof(pentagons[0]) / 5;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* pentagon = pentagons;
-    mesh->ntriangles = npentagons * 3;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < npentagons; p++, pentagon += 5) {
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[1];
-        *tris++ = pentagon[2];
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[2];
-        *tris++ = pentagon[3];
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[3];
-        *tris++ = pentagon[4];
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_octahedron()
-{
-    static float verts[6 * 3] = {
-        0.000, 0.000, 1.000,
-        1.000, 0.000, 0.000,
-        0.000, 1.000, 0.000,
-        -1.000, 0.000, 0.000,
-        0.000, -1.000, 0.000,
-        0.000, 0.000, -1.000
-    };
-    static PAR_SHAPES_T triangles[8 * 3] = {
-        0,1,2,
-        0,2,3,
-        0,3,4,
-        0,4,1,
-        2,1,5,
-        3,2,5,
-        4,3,5,
-        1,4,5,
-    };
-    int ntris = sizeof(triangles) / sizeof(triangles[0]) / 3;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* triangle = triangles;
-    mesh->ntriangles = ntris;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < ntris; p++) {
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_tetrahedron()
-{
-    static float verts[4 * 3] = {
-        0.000, 1.333, 0,
-        0.943, 0, 0,
-        -0.471, 0, 0.816,
-        -0.471, 0, -0.816,
-    };
-    static PAR_SHAPES_T triangles[4 * 3] = {
-        2,1,0,
-        3,2,0,
-        1,3,0,
-        1,2,3,
-    };
-    int ntris = sizeof(triangles) / sizeof(triangles[0]) / 3;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* triangle = triangles;
-    mesh->ntriangles = ntris;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < ntris; p++) {
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_cube()
-{
-    static float verts[8 * 3] = {
-        0, 0, 0, // 0
-        0, 1, 0, // 1
-        1, 1, 0, // 2
-        1, 0, 0, // 3
-        0, 0, 1, // 4
-        0, 1, 1, // 5
-        1, 1, 1, // 6
-        1, 0, 1, // 7
-    };
-    static PAR_SHAPES_T quads[6 * 4] = {
-        7,6,5,4, // front
-        0,1,2,3, // back
-        6,7,3,2, // right
-        5,6,2,1, // top
-        4,5,1,0, // left
-        7,4,0,3, // bottom
-    };
-    int nquads = sizeof(quads) / sizeof(quads[0]) / 4;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* quad = quads;
-    mesh->ntriangles = nquads * 2;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < nquads; p++, quad += 4) {
-        *tris++ = quad[0];
-        *tris++ = quad[1];
-        *tris++ = quad[2];
-        *tris++ = quad[2];
-        *tris++ = quad[3];
-        *tris++ = quad[0];
-    }
-    return mesh;
-}
-
-typedef struct {
-    char* cmd;
-    char* arg;
-} par_shapes__command;
-
-typedef struct {
-    char const* name;
-    int weight;
-    int ncommands;
-    par_shapes__command* commands;
-} par_shapes__rule;
-
-typedef struct {
-    int pc;
-    float position[3];
-    float scale[3];
-    par_shapes_mesh* orientation;
-    par_shapes__rule* rule;
-} par_shapes__stackframe;
-
-static par_shapes__rule* par_shapes__pick_rule(const char* name,
-    par_shapes__rule* rules, int nrules)
-{
-    par_shapes__rule* rule = 0;
-    int total = 0;
-    for (int i = 0; i < nrules; i++) {
-        rule = rules + i;
-        if (!strcmp(rule->name, name)) {
-            total += rule->weight;
-        }
-    }
-    float r = (float) rand() / RAND_MAX;
-    float t = 0;
-    for (int i = 0; i < nrules; i++) {
-        rule = rules + i;
-        if (!strcmp(rule->name, name)) {
-            t += (float) rule->weight / total;
-            if (t >= r) {
-                return rule;
-            }
-        }
-    }
-    return rule;
-}
-
-static par_shapes_mesh* par_shapes__create_turtle()
-{
-    const float xaxis[] = {1, 0, 0};
-    const float yaxis[] = {0, 1, 0};
-    const float zaxis[] = {0, 0, 1};
-    par_shapes_mesh* turtle = PAR_CALLOC(par_shapes_mesh, 1);
-    turtle->npoints = 3;
-    turtle->points = PAR_CALLOC(float, turtle->npoints * 3);
-    par_shapes__copy3(turtle->points + 0, xaxis);
-    par_shapes__copy3(turtle->points + 3, yaxis);
-    par_shapes__copy3(turtle->points + 6, zaxis);
-    return turtle;
-}
-
-static par_shapes_mesh* par_shapes__apply_turtle(par_shapes_mesh* mesh,
-    par_shapes_mesh* turtle, float const* pos, float const* scale)
-{
-    par_shapes_mesh* m = par_shapes_clone(mesh, 0);
-    for (int p = 0; p < m->npoints; p++) {
-        float* pt = m->points + p * 3;
-        pt[0] *= scale[0];
-        pt[1] *= scale[1];
-        pt[2] *= scale[2];
-        par_shapes__transform3(pt,
-            turtle->points + 0, turtle->points + 3, turtle->points + 6);
-        pt[0] += pos[0];
-        pt[1] += pos[1];
-        pt[2] += pos[2];
-    }
-    return m;
-}
-
-static void par_shapes__connect(par_shapes_mesh* scene,
-    par_shapes_mesh* cylinder, int slices)
-{
-    int stacks = 1;
-    int npoints = (slices + 1) * (stacks + 1);
-    assert(scene->npoints >= npoints && "Cannot connect to empty scene.");
-
-    // Create the new point list.
-    npoints = scene->npoints + (slices + 1);
-    float* points = PAR_MALLOC(float, npoints * 3);
-    memcpy(points, scene->points, sizeof(float) * scene->npoints * 3);
-    float* newpts = points + scene->npoints * 3;
-    memcpy(newpts, cylinder->points + (slices + 1) * 3,
-        sizeof(float) * (slices + 1) * 3);
-    PAR_FREE(scene->points);
-    scene->points = points;
-
-    // Create the new triangle list.
-    int ntriangles = scene->ntriangles + 2 * slices * stacks;
-    PAR_SHAPES_T* triangles = PAR_MALLOC(PAR_SHAPES_T, ntriangles * 3);
-    memcpy(triangles, scene->triangles, 2 * scene->ntriangles * 3);
-    int v = scene->npoints - (slices + 1);
-    PAR_SHAPES_T* face = triangles + scene->ntriangles * 3;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++) {
-            int next = slice + 1;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next;
-            *face++ = v + slice;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next + slices + 1;
-            *face++ = v + next;
-        }
-        v += slices + 1;
-    }
-    PAR_FREE(scene->triangles);
-    scene->triangles = triangles;
-
-    scene->npoints = npoints;
-    scene->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_lsystem(char const* text, int slices,
-    int maxdepth)
-{
-    char* program;
-    program = PAR_MALLOC(char, strlen(text) + 1);
-
-    // The first pass counts the number of rules and commands.
-    strcpy(program, text);
-    char *cmd = strtok(program, " ");
-    int nrules = 1;
-    int ncommands = 0;
-    while (cmd) {
-        char *arg = strtok(0, " ");
-        if (!arg) {
-            //puts("lsystem error: unexpected end of program.");
-            break;
-        }
-        if (!strcmp(cmd, "rule")) {
-            nrules++;
-        } else {
-            ncommands++;
-        }
-        cmd = strtok(0, " ");
-    }
-
-    // Allocate space.
-    par_shapes__rule* rules = PAR_MALLOC(par_shapes__rule, nrules);
-    par_shapes__command* commands = PAR_MALLOC(par_shapes__command, ncommands);
-
-    // Initialize the entry rule.
-    par_shapes__rule* current_rule = &rules[0];
-    par_shapes__command* current_command = &commands[0];
-    current_rule->name = "entry";
-    current_rule->weight = 1;
-    current_rule->ncommands = 0;
-    current_rule->commands = current_command;
-
-    // The second pass fills in the structures.
-    strcpy(program, text);
-    cmd = strtok(program, " ");
-    while (cmd) {
-        char *arg = strtok(0, " ");
-        if (!strcmp(cmd, "rule")) {
-            current_rule++;
-
-            // Split the argument into a rule name and weight.
-            char* dot = strchr(arg, '.');
-            if (dot) {
-                current_rule->weight = atoi(dot + 1);
-                *dot = 0;
-            } else {
-                current_rule->weight = 1;
-            }
-
-            current_rule->name = arg;
-            current_rule->ncommands = 0;
-            current_rule->commands = current_command;
-        } else {
-            current_rule->ncommands++;
-            current_command->cmd = cmd;
-            current_command->arg = arg;
-            current_command++;
-        }
-        cmd = strtok(0, " ");
-    }
-
-    // For testing purposes, dump out the parsed program.
-    #ifdef TEST_PARSE
-    /*
-    for (int i = 0; i < nrules; i++) {
-        par_shapes__rule rule = rules[i];
-        printf("rule %s.%d\n", rule.name, rule.weight);
-        for (int c = 0; c < rule.ncommands; c++) {
-            par_shapes__command cmd = rule.commands[c];
-            printf("\t%s %s\n", cmd.cmd, cmd.arg);
-        }
-    }
-    */
-    #endif
-
-    // Instantiate the aggregated shape and the template shapes.
-    par_shapes_mesh* scene = PAR_CALLOC(par_shapes_mesh, 1);
-    par_shapes_mesh* tube = par_shapes_create_cylinder(slices, 1);
-    par_shapes_mesh* turtle = par_shapes__create_turtle();
-
-    // We're not attempting to support texture coordinates and normals
-    // with L-systems, so remove them from the template shape.
-    PAR_FREE(tube->normals);
-    PAR_FREE(tube->tcoords);
-    tube->normals = 0;
-    tube->tcoords = 0;
-
-    const float xaxis[] = {1, 0, 0};
-    const float yaxis[] = {0, 1, 0};
-    const float zaxis[] = {0, 0, 1};
-    const float units[] = {1, 1, 1};
-
-    // Execute the L-system program until the stack size is 0.
-    par_shapes__stackframe* stack =
-        PAR_CALLOC(par_shapes__stackframe, maxdepth);
-    int stackptr = 0;
-    stack[0].orientation = turtle;
-    stack[0].rule = &rules[0];
-    par_shapes__copy3(stack[0].scale, units);
-    while (stackptr >= 0) {
-        par_shapes__stackframe* frame = &stack[stackptr];
-        par_shapes__rule* rule = frame->rule;
-        par_shapes_mesh* turtle = frame->orientation;
-        float* position = frame->position;
-        float* scale = frame->scale;
-        if (frame->pc >= rule->ncommands) {
-            par_shapes_free_mesh(turtle);
-            stackptr--;
-            continue;
-        }
-
-        par_shapes__command* cmd = rule->commands + (frame->pc++);
-        #ifdef DUMP_TRACE
-        //printf("%5s %5s %5s:%d  %03d\n", cmd->cmd, cmd->arg, rule->name, frame->pc - 1, stackptr);
-        #endif
-
-        float value;
-        if (!strcmp(cmd->cmd, "shape")) {
-            par_shapes_mesh* m = par_shapes__apply_turtle(tube, turtle,
-                position, scale);
-            if (!strcmp(cmd->arg, "connect")) {
-                par_shapes__connect(scene, m, slices);
-            } else {
-                par_shapes_merge(scene, m);
-            }
-            par_shapes_free_mesh(m);
-        } else if (!strcmp(cmd->cmd, "call") && stackptr < maxdepth - 1) {
-            rule = par_shapes__pick_rule(cmd->arg, rules, nrules);
-            frame = &stack[++stackptr];
-            frame->rule = rule;
-            frame->orientation = par_shapes_clone(turtle, 0);
-            frame->pc = 0;
-            par_shapes__copy3(frame->scale, scale);
-            par_shapes__copy3(frame->position, position);
-            continue;
-        } else {
-            value = atof(cmd->arg);
-            if (!strcmp(cmd->cmd, "rx")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, xaxis);
-            } else if (!strcmp(cmd->cmd, "ry")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, yaxis);
-            } else if (!strcmp(cmd->cmd, "rz")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, zaxis);
-            } else if (!strcmp(cmd->cmd, "tx")) {
-                float vec[3] = {value, 0, 0};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "ty")) {
-                float vec[3] = {0, value, 0};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "tz")) {
-                float vec[3] = {0, 0, value};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "sx")) {
-                scale[0] *= value;
-            } else if (!strcmp(cmd->cmd, "sy")) {
-                scale[1] *= value;
-            } else if (!strcmp(cmd->cmd, "sz")) {
-                scale[2] *= value;
-            } else if (!strcmp(cmd->cmd, "sa")) {
-                scale[0] *= value;
-                scale[1] *= value;
-                scale[2] *= value;
-            }
-        }
-    }
-    PAR_FREE(stack);
-    PAR_FREE(program);
-    PAR_FREE(rules);
-    PAR_FREE(commands);
-    return scene;
-}
-
-void par_shapes_unweld(par_shapes_mesh* mesh, bool create_indices)
-{
-    int npoints = mesh->ntriangles * 3;
-    float* points = PAR_MALLOC(float, 3 * npoints);
-    float* dst = points;
-    PAR_SHAPES_T const* index = mesh->triangles;
-    for (int i = 0; i < npoints; i++) {
-        float const* src = mesh->points + 3 * (*index++);
-        *dst++ = src[0];
-        *dst++ = src[1];
-        *dst++ = src[2];
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = points;
-    mesh->npoints = npoints;
-    if (create_indices) {
-        PAR_SHAPES_T* tris = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-        PAR_SHAPES_T* index = tris;
-        for (int i = 0; i < mesh->ntriangles * 3; i++) {
-            *index++ = i;
-        }
-        PAR_FREE(mesh->triangles);
-        mesh->triangles = tris;
-    }
-}
-
-void par_shapes_compute_normals(par_shapes_mesh* m)
-{
-    PAR_FREE(m->normals);
-    m->normals = PAR_CALLOC(float, m->npoints * 3);
-    PAR_SHAPES_T const* triangle = m->triangles;
-    float next[3], prev[3], cp[3];
-    for (int f = 0; f < m->ntriangles; f++, triangle += 3) {
-        float const* pa = m->points + 3 * triangle[0];
-        float const* pb = m->points + 3 * triangle[1];
-        float const* pc = m->points + 3 * triangle[2];
-        par_shapes__copy3(next, pb);
-        par_shapes__subtract3(next, pa);
-        par_shapes__copy3(prev, pc);
-        par_shapes__subtract3(prev, pa);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[0], cp);
-        par_shapes__copy3(next, pc);
-        par_shapes__subtract3(next, pb);
-        par_shapes__copy3(prev, pa);
-        par_shapes__subtract3(prev, pb);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[1], cp);
-        par_shapes__copy3(next, pa);
-        par_shapes__subtract3(next, pc);
-        par_shapes__copy3(prev, pb);
-        par_shapes__subtract3(prev, pc);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[2], cp);
-    }
-    float* normal = m->normals;
-    for (int p = 0; p < m->npoints; p++, normal += 3) {
-        par_shapes__normalize3(normal);
-    }
-}
-
-static void par_shapes__subdivide(par_shapes_mesh* mesh)
-{
-    assert(mesh->npoints == mesh->ntriangles * 3 && "Must be unwelded.");
-    int ntriangles = mesh->ntriangles * 4;
-    int npoints = ntriangles * 3;
-    float* points = PAR_CALLOC(float, npoints * 3);
-    float* dpoint = points;
-    float const* spoint = mesh->points;
-    for (int t = 0; t < mesh->ntriangles; t++, spoint += 9, dpoint += 3) {
-        float const* a = spoint;
-        float const* b = spoint + 3;
-        float const* c = spoint + 6;
-        float const* p0 = dpoint;
-        float const* p1 = dpoint + 3;
-        float const* p2 = dpoint + 6;
-        par_shapes__mix3(dpoint, a, b, 0.5);
-        par_shapes__mix3(dpoint += 3, b, c, 0.5);
-        par_shapes__mix3(dpoint += 3, a, c, 0.5);
-        par_shapes__add3(dpoint += 3, a);
-        par_shapes__add3(dpoint += 3, p0);
-        par_shapes__add3(dpoint += 3, p2);
-        par_shapes__add3(dpoint += 3, p0);
-        par_shapes__add3(dpoint += 3, b);
-        par_shapes__add3(dpoint += 3, p1);
-        par_shapes__add3(dpoint += 3, p2);
-        par_shapes__add3(dpoint += 3, p1);
-        par_shapes__add3(dpoint += 3, c);
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = points;
-    mesh->npoints = npoints;
-    mesh->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_subdivided_sphere(int nsubd)
-{
-    par_shapes_mesh* mesh = par_shapes_create_icosahedron();
-    par_shapes_unweld(mesh, false);
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = 0;
-    while (nsubd--) {
-        par_shapes__subdivide(mesh);
-    }
-    for (int i = 0; i < mesh->npoints; i++) {
-        par_shapes__normalize3(mesh->points + i * 3);
-    }
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    for (int i = 0; i < mesh->ntriangles * 3; i++) {
-        mesh->triangles[i] = i;
-    }
-    par_shapes_mesh* tmp = mesh;
-    mesh = par_shapes_weld(mesh, 0.01, 0);
-    par_shapes_free_mesh(tmp);
-    par_shapes_compute_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_rock(int seed, int subd)
-{
-    par_shapes_mesh* mesh = par_shapes_create_subdivided_sphere(subd);
-    struct osn_context* ctx;
-    par__simplex_noise(seed, &ctx);
-    for (int p = 0; p < mesh->npoints; p++) {
-        float* pt = mesh->points + p * 3;
-        float a = 0.25, f = 1.0;
-        double n = a * par__simplex_noise2(ctx, f * pt[0], f * pt[2]);
-        a *= 0.5; f *= 2;
-        n += a * par__simplex_noise2(ctx, f * pt[0], f * pt[2]);
-        pt[0] *= 1 + 2 * n;
-        pt[1] *= 1 + n;
-        pt[2] *= 1 + 2 * n;
-        if (pt[1] < 0) {
-            pt[1] = -pow(-pt[1], 0.5) / 2;
-        }
-    }
-    par__simplex_noise_free(ctx);
-    par_shapes_compute_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_clone(par_shapes_mesh const* mesh,
-    par_shapes_mesh* clone)
-{
-    if (!clone) {
-        clone = PAR_CALLOC(par_shapes_mesh, 1);
-    }
-    clone->npoints = mesh->npoints;
-    clone->points = PAR_REALLOC(float, clone->points, 3 * clone->npoints);
-    memcpy(clone->points, mesh->points, sizeof(float) * 3 * clone->npoints);
-    clone->ntriangles = mesh->ntriangles;
-    clone->triangles = PAR_REALLOC(PAR_SHAPES_T, clone->triangles, 3 *
-        clone->ntriangles);
-    memcpy(clone->triangles, mesh->triangles,
-        sizeof(PAR_SHAPES_T) * 3 * clone->ntriangles);
-    if (mesh->normals) {
-        clone->normals = PAR_REALLOC(float, clone->normals, 3 * clone->npoints);
-        memcpy(clone->normals, mesh->normals,
-            sizeof(float) * 3 * clone->npoints);
-    }
-    if (mesh->tcoords) {
-        clone->tcoords = PAR_REALLOC(float, clone->tcoords, 2 * clone->npoints);
-        memcpy(clone->tcoords, mesh->tcoords,
-            sizeof(float) * 2 * clone->npoints);
-    }
-    return clone;
-}
-
-static struct {
-    float const* points;
-    int gridsize;
-} par_shapes__sort_context;
-
-static int par_shapes__cmp1(const void *arg0, const void *arg1)
-{
-    const int g = par_shapes__sort_context.gridsize;
-
-    // Convert arg0 into a flattened grid index.
-    PAR_SHAPES_T d0 = *(const PAR_SHAPES_T*) arg0;
-    float const* p0 = par_shapes__sort_context.points + d0 * 3;
-    int i0 = (int) p0[0];
-    int j0 = (int) p0[1];
-    int k0 = (int) p0[2];
-    int index0 = i0 + g * j0 + g * g * k0;
-
-    // Convert arg1 into a flattened grid index.
-    PAR_SHAPES_T d1 = *(const PAR_SHAPES_T*) arg1;
-    float const* p1 = par_shapes__sort_context.points + d1 * 3;
-    int i1 = (int) p1[0];
-    int j1 = (int) p1[1];
-    int k1 = (int) p1[2];
-    int index1 = i1 + g * j1 + g * g * k1;
-
-    // Return the ordering.
-    if (index0 < index1) return -1;
-    if (index0 > index1) return 1;
-    return 0;
-}
-
-static void par_shapes__sort_points(par_shapes_mesh* mesh, int gridsize,
-    PAR_SHAPES_T* sortmap)
-{
-    // Run qsort over a list of consecutive integers that get deferenced
-    // within the comparator function; this creates a reorder mapping.
-    for (int i = 0; i < mesh->npoints; i++) {
-        sortmap[i] = i;
-    }
-    par_shapes__sort_context.gridsize = gridsize;
-    par_shapes__sort_context.points = mesh->points;
-    qsort(sortmap, mesh->npoints, sizeof(PAR_SHAPES_T), par_shapes__cmp1);
-
-    // Apply the reorder mapping to the XYZ coordinate data.
-    float* newpts = PAR_MALLOC(float, mesh->npoints * 3);
-    PAR_SHAPES_T* invmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    float* dstpt = newpts;
-    for (int i = 0; i < mesh->npoints; i++) {
-        invmap[sortmap[i]] = i;
-        float const* srcpt = mesh->points + 3 * sortmap[i];
-        *dstpt++ = *srcpt++;
-        *dstpt++ = *srcpt++;
-        *dstpt++ = *srcpt++;
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = newpts;
-
-    // Apply the inverse reorder mapping to the triangle indices.
-    PAR_SHAPES_T* newinds = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* dstind = newinds;
-    PAR_SHAPES_T const* srcind = mesh->triangles;
-    for (int i = 0; i < mesh->ntriangles * 3; i++) {
-        *dstind++ = invmap[*srcind++];
-    }
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = newinds;
-
-    // Cleanup.
-    memcpy(sortmap, invmap, sizeof(PAR_SHAPES_T) * mesh->npoints);
-    PAR_FREE(invmap);
-}
-
-static void par_shapes__weld_points(par_shapes_mesh* mesh, int gridsize,
-    float epsilon, PAR_SHAPES_T* weldmap)
-{
-    // Each bin contains a "pointer" (really an index) to its first point.
-    // We add 1 because 0 is reserved to mean that the bin is empty.
-    // Since the points are spatially sorted, there's no need to store
-    // a point count in each bin.
-    PAR_SHAPES_T* bins = PAR_CALLOC(PAR_SHAPES_T,
-        gridsize * gridsize * gridsize);
-    int prev_binindex = -1;
-    for (int p = 0; p < mesh->npoints; p++) {
-        float const* pt = mesh->points + p * 3;
-        int i = (int) pt[0];
-        int j = (int) pt[1];
-        int k = (int) pt[2];
-        int this_binindex = i + gridsize * j + gridsize * gridsize * k;
-        if (this_binindex != prev_binindex) {
-            bins[this_binindex] = 1 + p;
-        }
-        prev_binindex = this_binindex;
-    }
-
-    // Examine all bins that intersect the epsilon-sized cube centered at each
-    // point, and check for colocated points within those bins.
-    float const* pt = mesh->points;
-    int nremoved = 0;
-    for (int p = 0; p < mesh->npoints; p++, pt += 3) {
-
-        // Skip if this point has already been welded.
-        if (weldmap[p] != p) {
-            continue;
-        }
-
-        // Build a list of bins that intersect the epsilon-sized cube.
-        int nearby[8];
-        int nbins = 0;
-        int minp[3], maxp[3];
-        for (int c = 0; c < 3; c++) {
-            minp[c] = (int) (pt[c] - epsilon);
-            maxp[c] = (int) (pt[c] + epsilon);
-        }
-        for (int i = minp[0]; i <= maxp[0]; i++) {
-            for (int j = minp[1]; j <= maxp[1]; j++) {
-                for (int k = minp[2]; k <= maxp[2]; k++) {
-                    int binindex = i + gridsize * j + gridsize * gridsize * k;
-                    PAR_SHAPES_T binvalue = *(bins + binindex);
-                    if (binvalue > 0) {
-                        if (nbins == 8) {
-                            //printf("Epsilon value is too large.\n");
-                            break;
-                        }
-                        nearby[nbins++] = binindex;
-                    }
-                }
-            }
-        }
-
-        // Check for colocated points in each nearby bin.
-        for (int b = 0; b < nbins; b++) {
-            int binindex = nearby[b];
-            PAR_SHAPES_T binvalue = *(bins + binindex);
-            PAR_SHAPES_T nindex = binvalue - 1;
-            while (true) {
-
-                // If this isn't "self" and it's colocated, then weld it!
-                if (nindex != p && weldmap[nindex] == nindex) {
-                    float const* thatpt = mesh->points + nindex * 3;
-                    float dist2 = par_shapes__sqrdist3(thatpt, pt);
-                    if (dist2 < epsilon) {
-                        weldmap[nindex] = p;
-                        nremoved++;
-                    }
-                }
-
-                // Advance to the next point if possible.
-                if (++nindex >= mesh->npoints) {
-                    break;
-                }
-
-                // If the next point is outside the bin, then we're done.
-                float const* nextpt = mesh->points + nindex * 3;
-                int i = (int) nextpt[0];
-                int j = (int) nextpt[1];
-                int k = (int) nextpt[2];
-                int nextbinindex = i + gridsize * j + gridsize * gridsize * k;
-                if (nextbinindex != binindex) {
-                    break;
-                }
-            }
-        }
-    }
-    PAR_FREE(bins);
-
-    // Apply the weldmap to the vertices.
-    int npoints = mesh->npoints - nremoved;
-    float* newpts = PAR_MALLOC(float, 3 * npoints);
-    float* dst = newpts;
-    PAR_SHAPES_T* condensed_map = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    PAR_SHAPES_T* cmap = condensed_map;
-    float const* src = mesh->points;
-    int ci = 0;
-    for (int p = 0; p < mesh->npoints; p++, src += 3) {
-        if (weldmap[p] == p) {
-            *dst++ = src[0];
-            *dst++ = src[1];
-            *dst++ = src[2];
-            *cmap++ = ci++;
-        } else {
-            *cmap++ = condensed_map[weldmap[p]];
-        }
-    }
-    assert(ci == npoints);
-    PAR_FREE(mesh->points);
-    memcpy(weldmap, condensed_map, mesh->npoints * sizeof(PAR_SHAPES_T));
-    PAR_FREE(condensed_map);
-    mesh->points = newpts;
-    mesh->npoints = npoints;
-
-    // Apply the weldmap to the triangle indices and skip the degenerates.
-    PAR_SHAPES_T const* tsrc = mesh->triangles;
-    PAR_SHAPES_T* tdst = mesh->triangles;
-    int ntriangles = 0;
-    for (int i = 0; i < mesh->ntriangles; i++, tsrc += 3) {
-        PAR_SHAPES_T a = weldmap[tsrc[0]];
-        PAR_SHAPES_T b = weldmap[tsrc[1]];
-        PAR_SHAPES_T c = weldmap[tsrc[2]];
-        if (a != b && a != c && b != c) {
-            *tdst++ = a;
-            *tdst++ = b;
-            *tdst++ = c;
-            ntriangles++;
-        }
-    }
-    mesh->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_weld(par_shapes_mesh const* mesh, float epsilon,
-    PAR_SHAPES_T* weldmap)
-{
-    par_shapes_mesh* clone = par_shapes_clone(mesh, 0);
-    float aabb[6];
-    int gridsize = 20;
-    float maxcell = gridsize - 1;
-    par_shapes_compute_aabb(clone, aabb);
-    float scale[3] = {
-        aabb[3] == aabb[0] ? 1.0f : maxcell / (aabb[3] - aabb[0]),
-        aabb[4] == aabb[1] ? 1.0f : maxcell / (aabb[4] - aabb[1]),
-        aabb[5] == aabb[2] ? 1.0f : maxcell / (aabb[5] - aabb[2]),
-    };
-    par_shapes_translate(clone, -aabb[0], -aabb[1], -aabb[2]);
-    par_shapes_scale(clone, scale[0], scale[1], scale[2]);
-    PAR_SHAPES_T* sortmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    par_shapes__sort_points(clone, gridsize, sortmap);
-    bool owner = false;
-    if (!weldmap) {
-        owner = true;
-        weldmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    }
-    for (int i = 0; i < mesh->npoints; i++) {
-        weldmap[i] = i;
-    }
-    par_shapes__weld_points(clone, gridsize, epsilon, weldmap);
-    if (owner) {
-        PAR_FREE(weldmap);
-    } else {
-        PAR_SHAPES_T* newmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-        for (int i = 0; i < mesh->npoints; i++) {
-            newmap[i] = weldmap[sortmap[i]];
-        }
-        memcpy(weldmap, newmap, sizeof(PAR_SHAPES_T) * mesh->npoints);
-        PAR_FREE(newmap);
-    }
-    PAR_FREE(sortmap);
-    par_shapes_scale(clone, 1.0 / scale[0], 1.0 / scale[1], 1.0 / scale[2]);
-    par_shapes_translate(clone, aabb[0], aabb[1], aabb[2]);
-    return clone;
-}
-
-// -----------------------------------------------------------------------------
-// BEGIN OPEN SIMPLEX NOISE
-// -----------------------------------------------------------------------------
-
-#define STRETCH_CONSTANT_2D (-0.211324865405187)  // (1 / sqrt(2 + 1) - 1 ) / 2;
-#define SQUISH_CONSTANT_2D (0.366025403784439)  // (sqrt(2 + 1) -1) / 2;
-#define STRETCH_CONSTANT_3D (-1.0 / 6.0)  // (1 / sqrt(3 + 1) - 1) / 3;
-#define SQUISH_CONSTANT_3D (1.0 / 3.0)  // (sqrt(3+1)-1)/3;
-#define STRETCH_CONSTANT_4D (-0.138196601125011)  // (1 / sqrt(4 + 1) - 1) / 4;
-#define SQUISH_CONSTANT_4D (0.309016994374947)  // (sqrt(4 + 1) - 1) / 4;
-
-#define NORM_CONSTANT_2D (47.0)
-#define NORM_CONSTANT_3D (103.0)
-#define NORM_CONSTANT_4D (30.0)
-
-#define DEFAULT_SEED (0LL)
-
-struct osn_context {
-    int16_t* perm;
-    int16_t* permGradIndex3D;
-};
-
-#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
-
-/*
- * Gradients for 2D. They approximate the directions to the
- * vertices of an octagon from the center.
- */
-static const int8_t gradients2D[] = {
-    5, 2, 2, 5, -5, 2, -2, 5, 5, -2, 2, -5, -5, -2, -2, -5,
-};
-
-/*
- * Gradients for 3D. They approximate the directions to the
- * vertices of a rhombicuboctahedron from the center, skewed so
- * that the triangular and square facets can be inscribed inside
- * circles of the same radius.
- */
-static const signed char gradients3D[] = {
-    -11, 4, 4, -4, 11, 4, -4, 4, 11, 11, 4, 4, 4, 11, 4, 4, 4, 11, -11, -4, 4,
-    -4, -11, 4, -4, -4, 11, 11, -4, 4, 4, -11, 4, 4, -4, 11, -11, 4, -4, -4, 11,
-    -4, -4, 4, -11, 11, 4, -4, 4, 11, -4, 4, 4, -11, -11, -4, -4, -4, -11, -4,
-    -4, -4, -11, 11, -4, -4, 4, -11, -4, 4, -4, -11,
-};
-
-/*
- * Gradients for 4D. They approximate the directions to the
- * vertices of a disprismatotesseractihexadecachoron from the center,
- * skewed so that the tetrahedral and cubic facets can be inscribed inside
- * spheres of the same radius.
- */
-static const signed char gradients4D[] = {
-    3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, -3, 1, 1, 1, -1, 3, 1, 1,
-    -1, 1, 3, 1, -1, 1, 1, 3, 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1,
-    3, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, 3, 1, -1, 1, 1,
-    3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3,
-    1, -1, 1, -1, 3, 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, -3,
-    -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, 3, 1, 1, -1, 1, 3,
-    1, -1, 1, 1, 3, -1, 1, 1, 1, -3, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1,
-    -1, 1, 1, -3, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, -3,
-    -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, 3, 1, -1, -1, 1, 3,
-    -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3,
-    -1, -1, 1, -1, -3, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1,
-    -3, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3,
-};
-
-static double extrapolate2(
-    struct osn_context* ctx, int xsb, int ysb, double dx, double dy)
-{
-    int16_t* perm = ctx->perm;
-    int index = perm[(perm[xsb & 0xFF] + ysb) & 0xFF] & 0x0E;
-    return gradients2D[index] * dx + gradients2D[index + 1] * dy;
-}
-
-static inline int fastFloor(double x)
-{
-    int xi = (int) x;
-    return x < xi ? xi - 1 : xi;
-}
-
-static int allocate_perm(struct osn_context* ctx, int nperm, int ngrad)
-{
-    PAR_FREE(ctx->perm);
-    PAR_FREE(ctx->permGradIndex3D);
-    ctx->perm = PAR_MALLOC(int16_t, nperm);
-    if (!ctx->perm) {
-        return -ENOMEM;
-    }
-    ctx->permGradIndex3D = PAR_MALLOC(int16_t, ngrad);
-    if (!ctx->permGradIndex3D) {
-        PAR_FREE(ctx->perm);
-        return -ENOMEM;
-    }
-    return 0;
-}
-
-static int par__simplex_noise(int64_t seed, struct osn_context** ctx)
-{
-    int rc;
-    int16_t source[256];
-    int i;
-    int16_t* perm;
-    int16_t* permGradIndex3D;
-    *ctx = PAR_MALLOC(struct osn_context, 1);
-    if (!(*ctx)) {
-        return -ENOMEM;
-    }
-    (*ctx)->perm = NULL;
-    (*ctx)->permGradIndex3D = NULL;
-    rc = allocate_perm(*ctx, 256, 256);
-    if (rc) {
-        PAR_FREE(*ctx);
-        return rc;
-    }
-    perm = (*ctx)->perm;
-    permGradIndex3D = (*ctx)->permGradIndex3D;
-    for (i = 0; i < 256; i++) {
-        source[i] = (int16_t) i;
-    }
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    for (i = 255; i >= 0; i--) {
-        seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-        int r = (int) ((seed + 31) % (i + 1));
-        if (r < 0)
-            r += (i + 1);
-        perm[i] = source[r];
-        permGradIndex3D[i] =
-            (short) ((perm[i] % (ARRAYSIZE(gradients3D) / 3)) * 3);
-        source[r] = source[i];
-    }
-    return 0;
-}
-
-static void par__simplex_noise_free(struct osn_context* ctx)
-{
-    if (!ctx)
-        return;
-    if (ctx->perm) {
-        PAR_FREE(ctx->perm);
-        ctx->perm = NULL;
-    }
-    if (ctx->permGradIndex3D) {
-        PAR_FREE(ctx->permGradIndex3D);
-        ctx->permGradIndex3D = NULL;
-    }
-    PAR_FREE(ctx);
-}
-
-static double par__simplex_noise2(struct osn_context* ctx, double x, double y)
-{
-    // Place input coordinates onto grid.
-    double stretchOffset = (x + y) * STRETCH_CONSTANT_2D;
-    double xs = x + stretchOffset;
-    double ys = y + stretchOffset;
-
-    // Floor to get grid coordinates of rhombus (stretched square) super-cell
-    // origin.
-    int xsb = fastFloor(xs);
-    int ysb = fastFloor(ys);
-
-    // Skew out to get actual coordinates of rhombus origin. We'll need these
-    // later.
-    double squishOffset = (xsb + ysb) * SQUISH_CONSTANT_2D;
-    double xb = xsb + squishOffset;
-    double yb = ysb + squishOffset;
-
-    // Compute grid coordinates relative to rhombus origin.
-    double xins = xs - xsb;
-    double yins = ys - ysb;
-
-    // Sum those together to get a value that determines which region we're in.
-    double inSum = xins + yins;
-
-    // Positions relative to origin point.
-    double dx0 = x - xb;
-    double dy0 = y - yb;
-
-    // We'll be defining these inside the next block and using them afterwards.
-    double dx_ext, dy_ext;
-    int xsv_ext, ysv_ext;
-
-    double value = 0;
-
-    // Contribution (1,0)
-    double dx1 = dx0 - 1 - SQUISH_CONSTANT_2D;
-    double dy1 = dy0 - 0 - SQUISH_CONSTANT_2D;
-    double attn1 = 2 - dx1 * dx1 - dy1 * dy1;
-    if (attn1 > 0) {
-        attn1 *= attn1;
-        value += attn1 * attn1 * extrapolate2(ctx, xsb + 1, ysb + 0, dx1, dy1);
-    }
-
-    // Contribution (0,1)
-    double dx2 = dx0 - 0 - SQUISH_CONSTANT_2D;
-    double dy2 = dy0 - 1 - SQUISH_CONSTANT_2D;
-    double attn2 = 2 - dx2 * dx2 - dy2 * dy2;
-    if (attn2 > 0) {
-        attn2 *= attn2;
-        value += attn2 * attn2 * extrapolate2(ctx, xsb + 0, ysb + 1, dx2, dy2);
-    }
-
-    if (inSum <= 1) {  // We're inside the triangle (2-Simplex) at (0,0)
-        double zins = 1 - inSum;
-        if (zins > xins || zins > yins) {
-            if (xins > yins) {
-                xsv_ext = xsb + 1;
-                ysv_ext = ysb - 1;
-                dx_ext = dx0 - 1;
-                dy_ext = dy0 + 1;
-            } else {
-                xsv_ext = xsb - 1;
-                ysv_ext = ysb + 1;
-                dx_ext = dx0 + 1;
-                dy_ext = dy0 - 1;
-            }
-        } else {  //(1,0) and (0,1) are the closest two vertices.
-            xsv_ext = xsb + 1;
-            ysv_ext = ysb + 1;
-            dx_ext = dx0 - 1 - 2 * SQUISH_CONSTANT_2D;
-            dy_ext = dy0 - 1 - 2 * SQUISH_CONSTANT_2D;
-        }
-    } else {  // We're inside the triangle (2-Simplex) at (1,1)
-        double zins = 2 - inSum;
-        if (zins < xins || zins < yins) {
-            if (xins > yins) {
-                xsv_ext = xsb + 2;
-                ysv_ext = ysb + 0;
-                dx_ext = dx0 - 2 - 2 * SQUISH_CONSTANT_2D;
-                dy_ext = dy0 + 0 - 2 * SQUISH_CONSTANT_2D;
-            } else {
-                xsv_ext = xsb + 0;
-                ysv_ext = ysb + 2;
-                dx_ext = dx0 + 0 - 2 * SQUISH_CONSTANT_2D;
-                dy_ext = dy0 - 2 - 2 * SQUISH_CONSTANT_2D;
-            }
-        } else {  //(1,0) and (0,1) are the closest two vertices.
-            dx_ext = dx0;
-            dy_ext = dy0;
-            xsv_ext = xsb;
-            ysv_ext = ysb;
-        }
-        xsb += 1;
-        ysb += 1;
-        dx0 = dx0 - 1 - 2 * SQUISH_CONSTANT_2D;
-        dy0 = dy0 - 1 - 2 * SQUISH_CONSTANT_2D;
-    }
-
-    // Contribution (0,0) or (1,1)
-    double attn0 = 2 - dx0 * dx0 - dy0 * dy0;
-    if (attn0 > 0) {
-        attn0 *= attn0;
-        value += attn0 * attn0 * extrapolate2(ctx, xsb, ysb, dx0, dy0);
-    }
-
-    // Extra Vertex
-    double attn_ext = 2 - dx_ext * dx_ext - dy_ext * dy_ext;
-    if (attn_ext > 0) {
-        attn_ext *= attn_ext;
-        value += attn_ext * attn_ext *
-            extrapolate2(ctx, xsv_ext, ysv_ext, dx_ext, dy_ext);
-    }
-
-    return value / NORM_CONSTANT_2D;
-}
-
-void par_shapes_remove_degenerate(par_shapes_mesh* mesh, float mintriarea)
-{
-    int ntriangles = 0;
-    PAR_SHAPES_T* triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* dst = triangles;
-    PAR_SHAPES_T const* src = mesh->triangles;
-    float next[3], prev[3], cp[3];
-    float mincplen2 = (mintriarea * 2) * (mintriarea * 2);
-    for (int f = 0; f < mesh->ntriangles; f++, src += 3) {
-        float const* pa = mesh->points + 3 * src[0];
-        float const* pb = mesh->points + 3 * src[1];
-        float const* pc = mesh->points + 3 * src[2];
-        par_shapes__copy3(next, pb);
-        par_shapes__subtract3(next, pa);
-        par_shapes__copy3(prev, pc);
-        par_shapes__subtract3(prev, pa);
-        par_shapes__cross3(cp, next, prev);
-        float cplen2 = par_shapes__dot3(cp, cp);
-        if (cplen2 >= mincplen2) {
-            *dst++ = src[0];
-            *dst++ = src[1];
-            *dst++ = src[2];
-            ntriangles++;
-        }
-    }
-    mesh->ntriangles = ntriangles;
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = triangles;
-}
-
-#endif // PAR_SHAPES_IMPLEMENTATION
-#endif // PAR_SHAPES_H
diff --git a/raylib/external/sdefl.h b/raylib/external/sdefl.h
deleted file mode 100644 (file)
index 218e754..0000000
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
-# Small Deflate
-`sdefl` is a small bare bone lossless compression library in ANSI C (ISO C90)
-which implements the Deflate (RFC 1951) compressed data format specification standard.
-It is mainly tuned to get as much speed and compression ratio from as little code
-as needed to keep the implementation as concise as possible.
-
-## Features
-- Portable single header and source file duo written in ANSI C (ISO C90)
-- Dual license with either MIT or public domain
-- Small implementation
-    - Deflate: 525 LoC
-    - Inflate: 320 LoC
-- Webassembly:
-    - Deflate ~3.7 KB (~2.2KB compressed)
-    - Inflate ~3.6 KB (~2.2KB compressed)
-
-## Usage:
-This file behaves differently depending on what symbols you define
-before including it.
-
-Header-File mode:
-If you do not define `SDEFL_IMPLEMENTATION` before including this file, it
-will operate in header only mode. In this mode it declares all used structs
-and the API of the library without including the implementation of the library.
-
-Implementation mode:
-If you define `SDEFL_IMPLEMENTATION` before including this file, it will
-compile the implementation . Make sure that you only include
-this file implementation in *one* C or C++ file to prevent collisions.
-
-### Benchmark
-
-| Compressor name         | Compression| Decompress.| Compr. size | Ratio |
-| ------------------------| -----------| -----------| ----------- | ----- |
-| sdefl 1.0 -0            |   127 MB/s |   233 MB/s |    40004116 | 39.88 |
-| sdefl 1.0 -1            |   111 MB/s |   259 MB/s |    38940674 | 38.82 |
-| sdefl 1.0 -5            |    45 MB/s |   275 MB/s |    36577183 | 36.46 |
-| sdefl 1.0 -7            |    38 MB/s |   276 MB/s |    36523781 | 36.41 |
-| zlib 1.2.11 -1          |    72 MB/s |   307 MB/s |    42298774 | 42.30 |
-| zlib 1.2.11 -6          |    24 MB/s |   313 MB/s |    36548921 | 36.55 |
-| zlib 1.2.11 -9          |    20 MB/s |   314 MB/s |    36475792 | 36.48 |
-| miniz 1.0 -1            |   122 MB/s |   208 MB/s |    48510028 | 48.51 |
-| miniz 1.0 -6            |    27 MB/s |   260 MB/s |    36513697 | 36.51 |
-| miniz 1.0 -9            |    23 MB/s |   261 MB/s |    36460101 | 36.46 |
-| libdeflate 1.3 -1       |   147 MB/s |   667 MB/s |    39597378 | 39.60 |
-| libdeflate 1.3 -6       |    69 MB/s |   689 MB/s |    36648318 | 36.65 |
-| libdeflate 1.3 -9       |    13 MB/s |   672 MB/s |    35197141 | 35.20 |
-| libdeflate 1.3 -12      |  8.13 MB/s |   670 MB/s |    35100568 | 35.10 |
-
-### Compression
-Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-
-| File    |   Original | `sdefl 0`     | `sdefl 5`     | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 |  4,260,187|  3,845,261|   3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 |  19,565,867 |
-| mr      |  9.970.564 | 3,860,531 |  3,673,460 |   3,665,627 |
-| nci     | 33.553.445 | 4,030,283 |  3,094,526 |   3,006,075 |
-| ooffice |  6.152.192 | 3,320,063 |  3,186,373 |   3,183,815 |
-| osdb    | 10.085.684 | 3,919,646 |  3,649,510 |   3,649,477 |
-| reymont |  6.627.202 | 2,263,378 |  1,857,588 |   1,827,237 |
-| samba   | 21.606.400 | 6,121,797 |  5,462,670 |   5,450,762 |
-| sao     |  7.251.944 | 5,612,421 |  5,485,380 |   5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 |  11,991,421 |
-| xml     |  5.345.280 | 886,620|    674,009 |     662,141 |
-| x-ray   |  8.474.240 | 6,304,655 |  6,244,779 |   6,244,779 |
-
-## License
-```
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-```
-*/
-#ifndef SDEFL_H_INCLUDED
-#define SDEFL_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SDEFL_MAX_OFF   (1 << 15)
-#define SDEFL_WIN_SIZ   SDEFL_MAX_OFF
-#define SDEFL_WIN_MSK   (SDEFL_WIN_SIZ-1)
-
-#define SDEFL_HASH_BITS 15
-#define SDEFL_HASH_SIZ  (1 << SDEFL_HASH_BITS)
-#define SDEFL_HASH_MSK  (SDEFL_HASH_SIZ-1)
-
-#define SDEFL_MIN_MATCH 4
-#define SDEFL_BLK_MAX   (256*1024)
-#define SDEFL_SEQ_SIZ   ((SDEFL_BLK_MAX + SDEFL_MIN_MATCH)/SDEFL_MIN_MATCH)
-
-#define SDEFL_SYM_MAX   (288)
-#define SDEFL_OFF_MAX   (32)
-#define SDEFL_PRE_MAX   (19)
-
-#define SDEFL_LVL_MIN   0
-#define SDEFL_LVL_DEF   5
-#define SDEFL_LVL_MAX   8
-
-struct sdefl_freq {
-  unsigned lit[SDEFL_SYM_MAX];
-  unsigned off[SDEFL_OFF_MAX];
-};
-struct sdefl_code_words {
-  unsigned lit[SDEFL_SYM_MAX];
-  unsigned off[SDEFL_OFF_MAX];
-};
-struct sdefl_lens {
-  unsigned char lit[SDEFL_SYM_MAX];
-  unsigned char off[SDEFL_OFF_MAX];
-};
-struct sdefl_codes {
-  struct sdefl_code_words word;
-  struct sdefl_lens len;
-};
-struct sdefl_seqt {
-  int off, len;
-};
-struct sdefl {
-  int bits, bitcnt;
-  int tbl[SDEFL_HASH_SIZ];
-  int prv[SDEFL_WIN_SIZ];
-
-  int seq_cnt;
-  struct sdefl_seqt seq[SDEFL_SEQ_SIZ];
-  struct sdefl_freq freq;
-  struct sdefl_codes cod;
-};
-extern int sdefl_bound(int in_len);
-extern int sdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
-extern int zsdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SDEFL_H_INCLUDED */
-
-#ifdef SDEFL_IMPLEMENTATION
-
-#include <assert.h> /* assert */
-#include <string.h> /* memcpy */
-#include <limits.h> /* CHAR_BIT */
-
-#define SDEFL_NIL               (-1)
-#define SDEFL_MAX_MATCH         258
-#define SDEFL_MAX_CODE_LEN      (15)
-#define SDEFL_SYM_BITS          (10u)
-#define SDEFL_SYM_MSK           ((1u << SDEFL_SYM_BITS)-1u)
-#define SDEFL_LIT_LEN_CODES     (14)
-#define SDEFL_OFF_CODES         (15)
-#define SDEFL_PRE_CODES         (7)
-#define SDEFL_CNT_NUM(n)        ((((n)+3u/4u)+3u)&~3u)
-#define SDEFL_EOB               (256)
-
-#define sdefl_npow2(n) (1 << (sdefl_ilog2((n)-1) + 1))
-
-static int
-sdefl_ilog2(int n) {
-  if (!n) return 0;
-#ifdef _MSC_VER
-  unsigned long msbp = 0;
-  _BitScanReverse(&msbp, (unsigned long)n);
-  return (int)msbp;
-#elif defined(__GNUC__) || defined(__clang__)
-  return (int)sizeof(unsigned long) * CHAR_BIT - 1 - __builtin_clzl((unsigned long)n);
-#else
-  #define lt(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
-  static const char tbl[256] = {
-    0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,lt(4), lt(5), lt(5), lt(6), lt(6), lt(6), lt(6),
-    lt(7), lt(7), lt(7), lt(7), lt(7), lt(7), lt(7), lt(7)};
-  int tt, t;
-  if ((tt = (n >> 16))) {
-    return (t = (tt >> 8)) ? 24 + tbl[t] : 16 + tbl[tt];
-  } else {
-    return (t = (n >> 8)) ? 8 + tbl[t] : tbl[n];
-  }
-  #undef lt
-#endif
-}
-static unsigned
-sdefl_uload32(const void *p) {
-  /* hopefully will be optimized to an unaligned read */
-  unsigned n = 0;
-  memcpy(&n, p, sizeof(n));
-  return n;
-}
-static unsigned
-sdefl_hash32(const void *p) {
-  unsigned n = sdefl_uload32(p);
-  return (n * 0x9E377989) >> (32 - SDEFL_HASH_BITS);
-}
-static void
-sdefl_put(unsigned char **dst, struct sdefl *s, int code, int bitcnt) {
-  s->bits |= (code << s->bitcnt);
-  s->bitcnt += bitcnt;
-  while (s->bitcnt >= 8) {
-    unsigned char *tar = *dst;
-    *tar = (unsigned char)(s->bits & 0xFF);
-    s->bits >>= 8;
-    s->bitcnt -= 8;
-    *dst = *dst + 1;
-  }
-}
-static void
-sdefl_heap_sub(unsigned A[], unsigned len, unsigned sub) {
-  unsigned c, p = sub;
-  unsigned v = A[sub];
-  while ((c = p << 1) <= len) {
-    if (c < len && A[c + 1] > A[c]) c++;
-    if (v >= A[c]) break;
-    A[p] = A[c], p = c;
-  }
-  A[p] = v;
-}
-static void
-sdefl_heap_array(unsigned *A, unsigned len) {
-  unsigned sub;
-  for (sub = len >> 1; sub >= 1; sub--)
-    sdefl_heap_sub(A, len, sub);
-}
-static void
-sdefl_heap_sort(unsigned *A, unsigned n) {
-  A--;
-  sdefl_heap_array(A, n);
-  while (n >= 2) {
-    unsigned tmp = A[n];
-    A[n--] = A[1];
-    A[1] = tmp;
-    sdefl_heap_sub(A, n, 1);
-  }
-}
-static unsigned
-sdefl_sort_sym(unsigned sym_cnt, unsigned *freqs,
-               unsigned char *lens, unsigned *sym_out) {
-  unsigned cnts[SDEFL_CNT_NUM(SDEFL_SYM_MAX)] = {0};
-  unsigned cnt_num = SDEFL_CNT_NUM(sym_cnt);
-  unsigned used_sym = 0;
-  unsigned sym, i;
-  for (sym = 0; sym < sym_cnt; sym++)
-    cnts[freqs[sym] < cnt_num-1 ? freqs[sym]: cnt_num-1]++;
-  for (i = 1; i < cnt_num; i++) {
-    unsigned cnt = cnts[i];
-    cnts[i] = used_sym;
-    used_sym += cnt;
-  }
-  for (sym = 0; sym < sym_cnt; sym++) {
-    unsigned freq = freqs[sym];
-    if (freq) {
-        unsigned idx = freq < cnt_num-1 ? freq : cnt_num-1;
-        sym_out[cnts[idx]++] = sym | (freq << SDEFL_SYM_BITS);
-    } else lens[sym] = 0;
-  }
-  sdefl_heap_sort(sym_out + cnts[cnt_num-2], cnts[cnt_num-1] - cnts[cnt_num-2]);
-  return used_sym;
-}
-static void
-sdefl_build_tree(unsigned *A, unsigned sym_cnt) {
-  unsigned i = 0, b = 0, e = 0;
-  do {
-    unsigned m, n, freq_shift;
-    if (i != sym_cnt && (b == e || (A[i] >> SDEFL_SYM_BITS) <= (A[b] >> SDEFL_SYM_BITS)))
-      m = i++;
-    else m = b++;
-    if (i != sym_cnt && (b == e || (A[i] >> SDEFL_SYM_BITS) <= (A[b] >> SDEFL_SYM_BITS)))
-      n = i++;
-    else n = b++;
-
-    freq_shift = (A[m] & ~SDEFL_SYM_MSK) + (A[n] & ~SDEFL_SYM_MSK);
-    A[m] = (A[m] & SDEFL_SYM_MSK) | (e << SDEFL_SYM_BITS);
-    A[n] = (A[n] & SDEFL_SYM_MSK) | (e << SDEFL_SYM_BITS);
-    A[e] = (A[e] & SDEFL_SYM_MSK) | freq_shift;
-  } while (sym_cnt - ++e > 1);
-}
-static void
-sdefl_gen_len_cnt(unsigned *A, unsigned root, unsigned *len_cnt,
-                  unsigned max_code_len) {
-  int n;
-  unsigned i;
-  for (i = 0; i <= max_code_len; i++)
-    len_cnt[i] = 0;
-  len_cnt[1] = 2;
-
-  A[root] &= SDEFL_SYM_MSK;
-  for (n = (int)root - 1; n >= 0; n--) {
-    unsigned p = A[n] >> SDEFL_SYM_BITS;
-    unsigned pdepth = A[p] >> SDEFL_SYM_BITS;
-    unsigned depth = pdepth + 1;
-    unsigned len = depth;
-
-    A[n] = (A[n] & SDEFL_SYM_MSK) | (depth << SDEFL_SYM_BITS);
-    if (len >= max_code_len) {
-      len = max_code_len;
-      do len--; while (!len_cnt[len]);
-    }
-    len_cnt[len]--;
-    len_cnt[len+1] += 2;
-  }
-}
-static void
-sdefl_gen_codes(unsigned *A, unsigned char *lens, const unsigned *len_cnt,
-                unsigned max_code_word_len, unsigned sym_cnt) {
-  unsigned i, sym, len, nxt[SDEFL_MAX_CODE_LEN + 1];
-  for (i = 0, len = max_code_word_len; len >= 1; len--) {
-    unsigned cnt = len_cnt[len];
-    while (cnt--) lens[A[i++] & SDEFL_SYM_MSK] = (unsigned char)len;
-  }
-  nxt[0] = nxt[1] = 0;
-  for (len = 2; len <= max_code_word_len; len++)
-    nxt[len] = (nxt[len-1] + len_cnt[len-1]) << 1;
-  for (sym = 0; sym < sym_cnt; sym++)
-    A[sym] = nxt[lens[sym]]++;
-}
-static unsigned
-sdefl_rev(unsigned c, unsigned char n) {
-  c = ((c & 0x5555) << 1) | ((c & 0xAAAA) >> 1);
-  c = ((c & 0x3333) << 2) | ((c & 0xCCCC) >> 2);
-  c = ((c & 0x0F0F) << 4) | ((c & 0xF0F0) >> 4);
-  c = ((c & 0x00FF) << 8) | ((c & 0xFF00) >> 8);
-  return c >> (16-n);
-}
-static void
-sdefl_huff(unsigned char *lens, unsigned *codes, unsigned *freqs,
-           unsigned num_syms, unsigned max_code_len) {
-  unsigned c, *A = codes;
-  unsigned len_cnt[SDEFL_MAX_CODE_LEN + 1];
-  unsigned used_syms = sdefl_sort_sym(num_syms, freqs, lens, A);
-  if (!used_syms) return;
-  if (used_syms == 1) {
-    unsigned s = A[0] & SDEFL_SYM_MSK;
-    unsigned i = s ? s : 1;
-    codes[0] = 0, lens[0] = 1;
-    codes[i] = 1, lens[i] = 1;
-    return;
-  }
-  sdefl_build_tree(A, used_syms);
-  sdefl_gen_len_cnt(A, used_syms-2, len_cnt, max_code_len);
-  sdefl_gen_codes(A, lens, len_cnt, max_code_len, num_syms);
-  for (c = 0; c < num_syms; c++) {
-    codes[c] = sdefl_rev(codes[c], lens[c]);
-  }
-}
-struct sdefl_symcnt {
-  int items;
-  int lit;
-  int off;
-};
-static void
-sdefl_precode(struct sdefl_symcnt *cnt, unsigned *freqs, unsigned *items,
-              const unsigned char *litlen, const unsigned char *offlen) {
-  unsigned *at = items;
-  unsigned run_start = 0;
-
-  unsigned total = 0;
-  unsigned char lens[SDEFL_SYM_MAX + SDEFL_OFF_MAX];
-  for (cnt->lit = SDEFL_SYM_MAX; cnt->lit > 257; cnt->lit--)
-    if (litlen[cnt->lit - 1]) break;
-  for (cnt->off = SDEFL_OFF_MAX; cnt->off > 1; cnt->off--)
-    if (offlen[cnt->off - 1]) break;
-
-  total = (unsigned)(cnt->lit + cnt->off);
-  memcpy(lens, litlen, sizeof(unsigned char) * cnt->lit);
-  memcpy(lens + cnt->lit, offlen, sizeof(unsigned char) * cnt->off);
-  do {
-    unsigned len = lens[run_start];
-    unsigned run_end = run_start;
-    do run_end++; while (run_end != total && len == lens[run_end]);
-    if (!len) {
-      while ((run_end - run_start) >= 11) {
-        unsigned n = (run_end - run_start) - 11;
-        unsigned xbits =  n < 0x7f ? n : 0x7f;
-        freqs[18]++;
-        *at++ = 18u | (xbits << 5u);
-        run_start += 11 + xbits;
-      }
-      if ((run_end - run_start) >= 3) {
-        unsigned n = (run_end - run_start) - 3;
-        unsigned xbits =  n < 0x7 ? n : 0x7;
-        freqs[17]++;
-        *at++ = 17u | (xbits << 5u);
-        run_start += 3 + xbits;
-      }
-    } else if ((run_end - run_start) >= 4) {
-      freqs[len]++;
-      *at++ = len;
-      run_start++;
-      do {
-        unsigned xbits = (run_end - run_start) - 3;
-        xbits = xbits < 0x03 ? xbits : 0x03;
-        *at++ = 16 | (xbits << 5);
-        run_start += 3 + xbits;
-        freqs[16]++;
-      } while ((run_end - run_start) >= 3);
-    }
-    while (run_start != run_end) {
-      freqs[len]++;
-      *at++ = len;
-      run_start++;
-    }
-  } while (run_start != total);
-  cnt->items = (int)(at - items);
-}
-struct sdefl_match_codes {
-  int ls, lc;
-  int dc, dx;
-};
-static void
-sdefl_match_codes(struct sdefl_match_codes *cod, int dist, int len) {
-  static const short dxmax[] = {0,6,12,24,48,96,192,384,768,1536,3072,6144,12288,24576};
-  static const unsigned char lslot[258+1] = {
-    0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12,
-    12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16,
-    16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18,
-    18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-    20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-    21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-    22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-    23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25,
-    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26,
-    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-    26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-    27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-    27, 27, 28
-  };
-  cod->ls = lslot[len];
-  cod->lc = 257 + cod->ls;
-  cod->dx = sdefl_ilog2(sdefl_npow2(dist) >> 2);
-  cod->dc = cod->dx ? ((cod->dx + 1) << 1) + (dist > dxmax[cod->dx]) : dist-1;
-}
-static void
-sdefl_match(unsigned char **dst, struct sdefl *s, int dist, int len) {
-  static const char lxn[] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-  static const short lmin[] = {3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,
-      51,59,67,83,99,115,131,163,195,227,258};
-  static const short dmin[] = {1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,
-      385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577};
-
-  struct sdefl_match_codes cod;
-  sdefl_match_codes(&cod, dist, len);
-  sdefl_put(dst, s, (int)s->cod.word.lit[cod.lc], s->cod.len.lit[cod.lc]);
-  sdefl_put(dst, s, len - lmin[cod.ls], lxn[cod.ls]);
-  sdefl_put(dst, s, (int)s->cod.word.off[cod.dc], s->cod.len.off[cod.dc]);
-  sdefl_put(dst, s, dist - dmin[cod.dc], cod.dx);
-}
-static void
-sdefl_flush(unsigned char **dst, struct sdefl *s, int is_last,
-            const unsigned char *in) {
-  int j, i = 0, item_cnt = 0;
-  struct sdefl_symcnt symcnt = {0};
-  unsigned codes[SDEFL_PRE_MAX];
-  unsigned char lens[SDEFL_PRE_MAX];
-  unsigned freqs[SDEFL_PRE_MAX] = {0};
-  unsigned items[SDEFL_SYM_MAX + SDEFL_OFF_MAX];
-  static const unsigned char perm[SDEFL_PRE_MAX] = {16,17,18,0,8,7,9,6,10,5,11,
-      4,12,3,13,2,14,1,15};
-
-  /* huffman codes */
-  s->freq.lit[SDEFL_EOB]++;
-  sdefl_huff(s->cod.len.lit, s->cod.word.lit, s->freq.lit, SDEFL_SYM_MAX, SDEFL_LIT_LEN_CODES);
-  sdefl_huff(s->cod.len.off, s->cod.word.off, s->freq.off, SDEFL_OFF_MAX, SDEFL_OFF_CODES);
-  sdefl_precode(&symcnt, freqs, items, s->cod.len.lit, s->cod.len.off);
-  sdefl_huff(lens, codes, freqs, SDEFL_PRE_MAX, SDEFL_PRE_CODES);
-  for (item_cnt = SDEFL_PRE_MAX; item_cnt > 4; item_cnt--) {
-    if (lens[perm[item_cnt - 1]]) break;
-  }
-  /* block header */
-  sdefl_put(dst, s, is_last ? 0x01 : 0x00, 1); /* block */
-  sdefl_put(dst, s, 0x02, 2); /* dynamic huffman */
-  sdefl_put(dst, s, symcnt.lit - 257, 5);
-  sdefl_put(dst, s, symcnt.off - 1, 5);
-  sdefl_put(dst, s, item_cnt - 4, 4);
-  for (i = 0; i < item_cnt; ++i)
-    sdefl_put(dst, s, lens[perm[i]], 3);
-  for (i = 0; i < symcnt.items; ++i) {
-    unsigned sym = items[i] & 0x1F;
-    sdefl_put(dst, s, (int)codes[sym], lens[sym]);
-    if (sym < 16) continue;
-    if (sym == 16) sdefl_put(dst, s, items[i] >> 5, 2);
-    else if(sym == 17) sdefl_put(dst, s, items[i] >> 5, 3);
-    else sdefl_put(dst, s, items[i] >> 5, 7);
-  }
-  /* block sequences */
-  for (i = 0; i < s->seq_cnt; ++i) {
-    if (s->seq[i].off >= 0)
-      for (j = 0; j < s->seq[i].len; ++j) {
-        int c = in[s->seq[i].off + j];
-        sdefl_put(dst, s, (int)s->cod.word.lit[c], s->cod.len.lit[c]);
-      }
-    else sdefl_match(dst, s, -s->seq[i].off, s->seq[i].len);
-  }
-  sdefl_put(dst, s, (int)(s)->cod.word.lit[SDEFL_EOB], (s)->cod.len.lit[SDEFL_EOB]);
-  memset(&s->freq, 0, sizeof(s->freq));
-  s->seq_cnt = 0;
-}
-static void
-sdefl_seq(struct sdefl *s, int off, int len) {
-  assert(s->seq_cnt + 2 < SDEFL_SEQ_SIZ);
-  s->seq[s->seq_cnt].off = off;
-  s->seq[s->seq_cnt].len = len;
-  s->seq_cnt++;
-}
-static void
-sdefl_reg_match(struct sdefl *s, int off, int len) {
-  struct sdefl_match_codes cod;
-  sdefl_match_codes(&cod, off, len);
-  s->freq.lit[cod.lc]++;
-  s->freq.off[cod.dc]++;
-}
-struct sdefl_match {
-  int off;
-  int len;
-};
-static void
-sdefl_fnd(struct sdefl_match *m, const struct sdefl *s,
-          int chain_len, int max_match, const unsigned char *in, int p) {
-  int i = s->tbl[sdefl_hash32(&in[p])];
-  int limit = ((p-SDEFL_WIN_SIZ)<SDEFL_NIL)?SDEFL_NIL:(p-SDEFL_WIN_SIZ);
-  while (i > limit) {
-    if (in[i+m->len] == in[p+m->len] &&
-        (sdefl_uload32(&in[i]) == sdefl_uload32(&in[p]))){
-      int n = SDEFL_MIN_MATCH;
-      while (n < max_match && in[i+n] == in[p+n]) n++;
-      if (n > m->len) {
-        m->len = n, m->off = p - i;
-        if (n == max_match) break;
-      }
-    }
-    if (!(--chain_len)) break;
-    i = s->prv[i&SDEFL_WIN_MSK];
-  }
-}
-static int
-sdefl_compr(struct sdefl *s, unsigned char *out, const unsigned char *in,
-            int in_len, int lvl) {
-  unsigned char *q = out;
-  static const unsigned char pref[] = {8,10,14,24,30,48,65,96,130};
-  int max_chain = (lvl < 8) ? (1 << (lvl + 1)): (1 << 13);
-  int n, i = 0, litlen = 0;
-  for (n = 0; n < SDEFL_HASH_SIZ; ++n) {
-    s->tbl[n] = SDEFL_NIL;
-  }
-  do {int blk_end = i + SDEFL_BLK_MAX < in_len ? i + SDEFL_BLK_MAX : in_len;
-    while (i < blk_end) {
-      struct sdefl_match m = {0};
-      int max_match = ((in_len-i)>SDEFL_MAX_MATCH) ? SDEFL_MAX_MATCH:(in_len-i);
-      int nice_match = pref[lvl] < max_match ? pref[lvl] : max_match;
-      int run = 1, inc = 1, run_inc;
-      if (max_match > SDEFL_MIN_MATCH) {
-        sdefl_fnd(&m, s, max_chain, max_match, in, i);
-      }
-      if (lvl >= 5 && m.len >= SDEFL_MIN_MATCH && m.len < nice_match){
-        struct sdefl_match m2 = {0};
-        sdefl_fnd(&m2, s, max_chain, m.len+1, in, i+1);
-        m.len = (m2.len > m.len) ? 0 : m.len;
-      }
-      if (m.len >= SDEFL_MIN_MATCH) {
-        if (litlen) {
-          sdefl_seq(s, i - litlen, litlen);
-          litlen = 0;
-        }
-        sdefl_seq(s, -m.off, m.len);
-        sdefl_reg_match(s, m.off, m.len);
-        if (lvl < 2 && m.len >= nice_match) {
-          inc = m.len;
-        } else {
-          run = m.len;
-        }
-      } else {
-        s->freq.lit[in[i]]++;
-        litlen++;
-      }
-      run_inc = run * inc;
-      if (in_len - (i + run_inc) > SDEFL_MIN_MATCH) {
-        while (run-- > 0) {
-          unsigned h = sdefl_hash32(&in[i]);
-          s->prv[i&SDEFL_WIN_MSK] = s->tbl[h];
-          s->tbl[h] = i, i += inc;
-        }
-      } else {
-        i += run_inc;
-      }
-    }
-    if (litlen) {
-      sdefl_seq(s, i - litlen, litlen);
-      litlen = 0;
-    }
-    sdefl_flush(&q, s, blk_end == in_len, in);
-  } while (i < in_len);
-
-  if (s->bitcnt)
-    sdefl_put(&q, s, 0x00, 8 - s->bitcnt);
-  return (int)(q - out);
-}
-extern int
-sdeflate(struct sdefl *s, void *out, const void *in, int n, int lvl) {
-  s->bits = s->bitcnt = 0;
-  return sdefl_compr(s, (unsigned char*)out, (const unsigned char*)in, n, lvl);
-}
-static unsigned
-sdefl_adler32(unsigned adler32, const unsigned char *in, int in_len) {
-  #define SDEFL_ADLER_INIT (1)
-  const unsigned ADLER_MOD = 65521;
-  unsigned s1 = adler32 & 0xffff;
-  unsigned s2 = adler32 >> 16;
-  unsigned blk_len, i;
-
-  blk_len = in_len % 5552;
-  while (in_len) {
-    for (i = 0; i + 7 < blk_len; i += 8) {
-      s1 += in[0]; s2 += s1;
-      s1 += in[1]; s2 += s1;
-      s1 += in[2]; s2 += s1;
-      s1 += in[3]; s2 += s1;
-      s1 += in[4]; s2 += s1;
-      s1 += in[5]; s2 += s1;
-      s1 += in[6]; s2 += s1;
-      s1 += in[7]; s2 += s1;
-      in += 8;
-    }
-    for (; i < blk_len; ++i) {
-      s1 += *in++, s2 += s1;
-    }
-    s1 %= ADLER_MOD;
-    s2 %= ADLER_MOD;
-    in_len -= blk_len;
-    blk_len = 5552;
-  }
-  return (unsigned)(s2 << 16) + (unsigned)s1;
-}
-extern int
-zsdeflate(struct sdefl *s, void *out, const void *in, int n, int lvl) {
-  int p = 0;
-  unsigned a = 0;
-  unsigned char *q = (unsigned char*)out;
-
-  s->bits = s->bitcnt = 0;
-  sdefl_put(&q, s, 0x78, 8); /* deflate, 32k window */
-  sdefl_put(&q, s, 0x01, 8); /* fast compression */
-  q += sdefl_compr(s, q, (const unsigned char*)in, n, lvl);
-
-  /* append adler checksum */
-  a = sdefl_adler32(SDEFL_ADLER_INIT, (const unsigned char*)in, n);
-  for (p = 0; p < 4; ++p) {
-    sdefl_put(&q, s, (a >> 24) & 0xFF, 8);
-    a <<= 8;
-  }
-  return (int)(q - (unsigned char*)out);
-}
-extern int
-sdefl_bound(int len) {
-  int a = 128 + (len * 110) / 100;
-  int b = 128 + len + ((len / (31 * 1024)) + 1) * 5;
-  return (a > b) ? a : b;
-}
-#endif /* SDEFL_IMPLEMENTATION */
-
diff --git a/raylib/external/sinfl.h b/raylib/external/sinfl.h
deleted file mode 100644 (file)
index 37c1aae..0000000
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
-# Small Deflate
-`sdefl` is a small bare bone lossless compression library in ANSI C (ISO C90)
-which implements the Deflate (RFC 1951) compressed data format specification standard.
-It is mainly tuned to get as much speed and compression ratio from as little code
-as needed to keep the implementation as concise as possible.
-
-## Features
-- Portable single header and source file duo written in ANSI C (ISO C90)
-- Dual license with either MIT or public domain
-- Small implementation
-    - Deflate: 525 LoC
-    - Inflate: 320 LoC
-- Webassembly:
-    - Deflate ~3.7 KB (~2.2KB compressed)
-    - Inflate ~3.6 KB (~2.2KB compressed)
-
-## Usage:
-This file behaves differently depending on what symbols you define
-before including it.
-
-Header-File mode:
-If you do not define `SINFL_IMPLEMENTATION` before including this file, it
-will operate in header only mode. In this mode it declares all used structs
-and the API of the library without including the implementation of the library.
-
-Implementation mode:
-If you define `SINFL_IMPLEMENTATION` before including this file, it will
-compile the implementation. Make sure that you only include
-this file implementation in *one* C or C++ file to prevent collisions.
-
-### Benchmark
-
-| Compressor name         | Compression| Decompress.| Compr. size | Ratio |
-| ------------------------| -----------| -----------| ----------- | ----- |
-| sdefl 1.0 -0            |   127 MB/s |   233 MB/s |    40004116 | 39.88 |
-| sdefl 1.0 -1            |   111 MB/s |   259 MB/s |    38940674 | 38.82 |
-| sdefl 1.0 -5            |    45 MB/s |   275 MB/s |    36577183 | 36.46 |
-| sdefl 1.0 -7            |    38 MB/s |   276 MB/s |    36523781 | 36.41 |
-| zlib 1.2.11 -1          |    72 MB/s |   307 MB/s |    42298774 | 42.30 |
-| zlib 1.2.11 -6          |    24 MB/s |   313 MB/s |    36548921 | 36.55 |
-| zlib 1.2.11 -9          |    20 MB/s |   314 MB/s |    36475792 | 36.48 |
-| miniz 1.0 -1            |   122 MB/s |   208 MB/s |    48510028 | 48.51 |
-| miniz 1.0 -6            |    27 MB/s |   260 MB/s |    36513697 | 36.51 |
-| miniz 1.0 -9            |    23 MB/s |   261 MB/s |    36460101 | 36.46 |
-| libdeflate 1.3 -1       |   147 MB/s |   667 MB/s |    39597378 | 39.60 |
-| libdeflate 1.3 -6       |    69 MB/s |   689 MB/s |    36648318 | 36.65 |
-| libdeflate 1.3 -9       |    13 MB/s |   672 MB/s |    35197141 | 35.20 |
-| libdeflate 1.3 -12      |  8.13 MB/s |   670 MB/s |    35100568 | 35.10 |
-
-### Compression
-Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-
-| File    |   Original | `sdefl 0`     | `sdefl 5`     | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 |  4,260,187|  3,845,261|   3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 |  19,565,867 |
-| mr      |  9.970.564 | 3,860,531 |  3,673,460 |   3,665,627 |
-| nci     | 33.553.445 | 4,030,283 |  3,094,526 |   3,006,075 |
-| ooffice |  6.152.192 | 3,320,063 |  3,186,373 |   3,183,815 |
-| osdb    | 10.085.684 | 3,919,646 |  3,649,510 |   3,649,477 |
-| reymont |  6.627.202 | 2,263,378 |  1,857,588 |   1,827,237 |
-| samba   | 21.606.400 | 6,121,797 |  5,462,670 |   5,450,762 |
-| sao     |  7.251.944 | 5,612,421 |  5,485,380 |   5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 |  11,991,421 |
-| xml     |  5.345.280 | 886,620|    674,009 |     662,141 |
-| x-ray   |  8.474.240 | 6,304,655 |  6,244,779 |   6,244,779 |
-
-## License
-```
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-```
-*/
-#ifndef SINFL_H_INCLUDED
-#define SINFL_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SINFL_PRE_TBL_SIZE 128
-#define SINFL_LIT_TBL_SIZE 1334
-#define SINFL_OFF_TBL_SIZE 402
-
-struct sinfl {
-  int bits, bitcnt;
-  unsigned lits[SINFL_LIT_TBL_SIZE];
-  unsigned dsts[SINFL_OFF_TBL_SIZE];
-};
-extern int sinflate(void *out, const void *in, int size);
-extern int zsinflate(void *out, const void *in, int size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SINFL_H_INCLUDED */
-
-#ifdef SINFL_IMPLEMENTATION
-
-#include <string.h> /* memcpy, memset */
-
-static int
-sinfl_bsr(unsigned n) {
-#ifdef _MSC_VER
-  _BitScanReverse(&n, n);
-  return n;
-#elif defined(__GNUC__) || defined(__clang__)
-  return 31 - __builtin_clz(n);
-#endif
-}
-static int
-sinfl_get(const unsigned char **src, const unsigned char *end, struct sinfl *s,
-          int n) {
-  const unsigned char *in = *src;
-  int v = s->bits & ((1 << n)-1);
-  s->bits >>= n;
-  s->bitcnt = s->bitcnt - n;
-  s->bitcnt = s->bitcnt < 0 ? 0 : s->bitcnt;
-  while (s->bitcnt < 16 && in < end) {
-    s->bits |= (*in++) << s->bitcnt;
-    s->bitcnt += 8;
-  }
-  *src = in;
-  return v;
-}
-struct sinfl_gen {
-  int len;
-  int cnt;
-  int word;
-  short* sorted;
-};
-static int
-sinfl_build_tbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
-                const int *cnt) {
-  int tbl_end = 0;
-  while (!(gen->cnt = cnt[gen->len])) {
-    ++gen->len;
-  }
-  tbl_end = 1 << gen->len;
-  while (gen->len <= tbl_bits) {
-    do {unsigned bit = 0;
-      tbl[gen->word] = (*gen->sorted++ << 16) | gen->len;
-      if (gen->word == tbl_end - 1) {
-        for (; gen->len < tbl_bits; gen->len++) {
-          memcpy(&tbl[tbl_end], tbl, (size_t)tbl_end * sizeof(tbl[0]));
-          tbl_end <<= 1;
-        }
-        return 1;
-      }
-      bit = 1 << sinfl_bsr((unsigned)(gen->word ^ (tbl_end - 1)));
-      gen->word &= bit - 1;
-      gen->word |= bit;
-    } while (--gen->cnt);
-    do {
-      if (++gen->len <= tbl_bits) {
-        memcpy(&tbl[tbl_end], tbl, (size_t)tbl_end * sizeof(tbl[0]));
-        tbl_end <<= 1;
-      }
-    } while (!(gen->cnt = cnt[gen->len]));
-  }
-  return 0;
-}
-static void
-sinfl_build_subtbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
-                   const int *cnt) {
-  int sub_bits = 0;
-  int sub_start = 0;
-  int sub_prefix = -1;
-  int tbl_end = 1 << tbl_bits;
-  while (1) {
-    unsigned entry;
-    int bit, stride, i;
-    /* start new subtable */
-    if ((gen->word & ((1 << tbl_bits)-1)) != sub_prefix) {
-      int used = 0;
-      sub_prefix = gen->word & ((1 << tbl_bits)-1);
-      sub_start = tbl_end;
-      sub_bits = gen->len - tbl_bits;
-      used = gen->cnt;
-      while (used < (1 << sub_bits)) {
-        sub_bits++;
-        used = (used << 1) + cnt[tbl_bits + sub_bits];
-      }
-      tbl_end = sub_start + (1 << sub_bits);
-      tbl[sub_prefix] = (sub_start << 16) | 0x10 | (sub_bits & 0xf);
-    }
-    /* fill subtable */
-    entry = (*gen->sorted << 16) | ((gen->len - tbl_bits) & 0xf);
-    gen->sorted++;
-    i = sub_start + (gen->word >> tbl_bits);
-    stride = 1 << (gen->len - tbl_bits);
-    do {
-      tbl[i] = entry;
-      i += stride;
-    } while (i < tbl_end);
-    if (gen->word == (1 << gen->len)-1) {
-      return;
-    }
-    bit = 1 << sinfl_bsr(gen->word ^ ((1 << gen->len) - 1));
-    gen->word &= bit - 1;
-    gen->word |= bit;
-    gen->cnt--;
-    while (!gen->cnt) {
-      gen->cnt = cnt[++gen->len];
-    }
-  }
-}
-static void
-sinfl_build(unsigned *tbl, unsigned char *lens, int tbl_bits, int maxlen,
-            int symcnt) {
-  int i, used = 0;
-  short sort[288];
-  int cnt[16] = {0}, off[16]= {0};
-  struct sinfl_gen gen = {0};
-  gen.sorted = sort;
-  gen.len = 1;
-
-  for (i = 0; i < symcnt; ++i)
-    cnt[lens[i]]++;
-  off[1] = cnt[0];
-  for (i = 1; i < maxlen; ++i) {
-    off[i + 1] = off[i] + cnt[i];
-    used = (used << 1) + cnt[i];
-  }
-  used = (used << 1) + cnt[i];
-  for (i = 0; i < symcnt; ++i)
-    gen.sorted[off[lens[i]]++] = (short)i;
-  gen.sorted += off[0];
-
-  if (used < (1 << maxlen)){
-    for (i = 0; i < 1 << tbl_bits; ++i)
-      tbl[i] = (0 << 16u) | 1;
-    return;
-  }
-  if (!sinfl_build_tbl(&gen, tbl, tbl_bits, cnt)){
-    sinfl_build_subtbl(&gen, tbl, tbl_bits, cnt);
-  }
-}
-static int
-sinfl_decode(const unsigned char **in, const unsigned char *end,
-             struct sinfl *s, const unsigned *tbl, int bit_len) {
-  int idx = s->bits & ((1 << bit_len) - 1);
-  unsigned key = tbl[idx];
-  if (key & 0x10) {
-    /* sub-table lookup */
-    int len = key & 0x0f;
-    sinfl_get(in, end, s, bit_len);
-    idx = s->bits & ((1 << len)-1);
-    key = tbl[((key >> 16) & 0xffff) + (unsigned)idx];
-  }
-  sinfl_get(in, end, s, key & 0x0f);
-  return (key >> 16) & 0x0fff;
-}
-static int
-sinfl_decompress(unsigned char *out, const unsigned char *in, int size) {
-  static const unsigned char order[] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-  static const short dbase[30+2] = {1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,
-      257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577};
-  static const unsigned char dbits[30+2] = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,
-      10,10,11,11,12,12,13,13,0,0};
-  static const short lbase[29+2] = {3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,
-      43,51,59,67,83,99,115,131,163,195,227,258,0,0};
-  static const unsigned char lbits[29+2] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,
-      4,4,4,5,5,5,5,0,0,0};
-
-  const unsigned char *e = in + size, *o = out;
-  enum sinfl_states {hdr,stored,fixed,dyn,blk};
-  enum sinfl_states state = hdr;
-  struct sinfl s = {0};
-  int last = 0;
-
-  sinfl_get(&in,e,&s,0); /* buffer input */
-  while (in < e || s.bitcnt) {
-    switch (state) {
-    case hdr: {
-      int type = 0; /* block header */
-      last = sinfl_get(&in,e,&s,1);
-      type = sinfl_get(&in,e,&s,2);
-
-      switch (type) {default: return (int)(out-o);
-      case 0x00: state = stored; break;
-      case 0x01: state = fixed; break;
-      case 0x02: state = dyn; break;}
-    } break;
-    case stored: {
-      int len; /* uncompressed block */
-      sinfl_get(&in,e,&s,s.bitcnt & 7);
-      len = sinfl_get(&in,e,&s,16);
-      //int nlen = sinfl_get(&in,e,&s,16);
-      in -= 2; s.bitcnt = 0;
-
-      if (len > (e-in) || !len)
-        return (int)(out-o);
-      memcpy(out, in, (size_t)len);
-      in += len, out += len;
-      state = hdr;
-    } break;
-    case fixed: {
-      /* fixed huffman codes */
-      int n; unsigned char lens[288+32];
-      for (n = 0; n <= 143; n++) lens[n] = 8;
-      for (n = 144; n <= 255; n++) lens[n] = 9;
-      for (n = 256; n <= 279; n++) lens[n] = 7;
-      for (n = 280; n <= 287; n++) lens[n] = 8;
-      for (n = 0; n < 32; n++) lens[288+n] = 5;
-
-      /* build lit/dist tables */
-      sinfl_build(s.lits, lens, 10, 15, 288);
-      sinfl_build(s.dsts, lens + 288, 8, 15, 32);
-      state = blk;
-    } break;
-    case dyn: {
-        /* dynamic huffman codes */
-        int n, i;
-        unsigned hlens[SINFL_PRE_TBL_SIZE];
-        unsigned char nlens[19] = {0}, lens[288+32];
-        int nlit = 257 + sinfl_get(&in,e,&s,5);
-        int ndist = 1 + sinfl_get(&in,e,&s,5);
-        int nlen = 4 + sinfl_get(&in,e,&s,4);
-        for (n = 0; n < nlen; n++)
-          nlens[order[n]] = (unsigned char)sinfl_get(&in,e,&s,3);
-        sinfl_build(hlens, nlens, 7, 7, 19);
-
-        /* decode code lengths */
-        for (n = 0; n < nlit + ndist;) {
-          int sym = sinfl_decode(&in, e, &s, hlens, 7);
-          switch (sym) {default: lens[n++] = (unsigned char)sym; break;
-          case 16: for (i=3+sinfl_get(&in,e,&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
-          case 17: for (i=3+sinfl_get(&in,e,&s,3);i;i--,n++) lens[n]=0; break;
-          case 18: for (i=11+sinfl_get(&in,e,&s,7);i;i--,n++) lens[n]=0; break;}
-        }
-        /* build lit/dist tables */
-        sinfl_build(s.lits, lens, 10, 15, nlit);
-        sinfl_build(s.dsts, lens + nlit, 8, 15, ndist);
-        state = blk;
-    } break;
-    case blk: {
-      /* decompress block */
-      int i, sym = sinfl_decode(&in, e, &s, s.lits, 10);
-      if (sym > 256) {sym -= 257; /* match symbol */
-        {int len = sinfl_get(&in, e, &s, lbits[sym]) + lbase[sym];
-        int dsym = sinfl_decode(&in, e, &s, s.dsts, 8);
-        int offs = sinfl_get(&in, e, &s, dbits[dsym]) + dbase[dsym];
-        if (offs > (int)(out-o)) {
-          return (int)(out-o);
-        } else if (offs == 1) {
-          /* rle match copying */
-          unsigned char c = *(out - offs);
-          unsigned long w = (c << 24) | (c << 16) | (c << 8) | c;
-          for (i = 0; i < len >> 2; ++i) {
-            memcpy(out, &w, 4);
-            out += 4;
-          }
-          len = len & 3;
-        } else if (offs >= 4) {
-          /* copy match */
-          int wcnt = len >> 2;
-          for (i = 0; i < wcnt; ++i) {
-            unsigned long w = 0;
-            memcpy(&w, out - offs, 4);
-            memcpy(out, &w, 4);
-            out += 4;
-          }
-          len = len & 3;
-        }
-        for (i = 0; i < len; ++i)
-          {*out = *(out-offs), out++;}
-        }
-      } else if (sym == 256) {
-        /* end of block */
-        if (last) return (int)(out-o);
-        state = hdr;
-        break;
-        /* literal */
-      } else *out++ = (unsigned char)sym;
-    } break;}
-  }
-  return (int)(out-o);
-}
-extern int
-sinflate(void *out, const void *in, int size) {
-  return sinfl_decompress((unsigned char*)out, (const unsigned char*)in, size);
-}
-static unsigned
-sinfl_adler32(unsigned adler32, const unsigned char *in, int in_len) {
-  const unsigned ADLER_MOD = 65521;
-  unsigned s1 = adler32 & 0xffff;
-  unsigned s2 = adler32 >> 16;
-  unsigned blk_len, i;
-
-  blk_len = in_len % 5552;
-  while (in_len) {
-    for (i=0; i + 7 < blk_len; i += 8) {
-      s1 += in[0]; s2 += s1;
-      s1 += in[1]; s2 += s1;
-      s1 += in[2]; s2 += s1;
-      s1 += in[3]; s2 += s1;
-      s1 += in[4]; s2 += s1;
-      s1 += in[5]; s2 += s1;
-      s1 += in[6]; s2 += s1;
-      s1 += in[7]; s2 += s1;
-      in += 8;
-    }
-    for (; i < blk_len; ++i)
-      s1 += *in++, s2 += s1;
-    s1 %= ADLER_MOD; s2 %= ADLER_MOD;
-    in_len -= blk_len;
-    blk_len = 5552;
-  } return (unsigned)(s2 << 16) + (unsigned)s1;
-}
-extern int
-zsinflate(void *out, const void *mem, int size) {
-  const unsigned char *in = (const unsigned char*)mem;
-  if (size >= 6) {
-    const unsigned char *eob = in + size - 4;
-    int n = sinfl_decompress((unsigned char*)out, in + 2u, size);
-    unsigned a = sinfl_adler32(1u, (unsigned char*)out, n);
-    unsigned h = eob[0] << 24 | eob[1] << 16 | eob[2] << 8 | eob[3] << 0;
-    return a == h ? n : -1;
-  } else {
-    return -1;
-  }
-}
-#endif
-
diff --git a/raylib/external/stb_image.h b/raylib/external/stb_image.h
deleted file mode 100644 (file)
index accef48..0000000
+++ /dev/null
@@ -1,7762 +0,0 @@
-/* stb_image - v2.26 - public domain image loader - http://nothings.org/stb
-                                  no warranty implied; use at your own risk
-
-   Do this:
-      #define STB_IMAGE_IMPLEMENTATION
-   before you include this file in *one* C or C++ file to create the implementation.
-
-   // i.e. it should look like this:
-   #include ...
-   #include ...
-   #include ...
-   #define STB_IMAGE_IMPLEMENTATION
-   #include "stb_image.h"
-
-   You can #define STBI_ASSERT(x) before the #include to avoid using assert.h.
-   And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free
-
-
-   QUICK NOTES:
-      Primarily of interest to game developers and other people who can
-          avoid problematic images and only need the trivial interface
-
-      JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
-      PNG 1/2/4/8/16-bit-per-channel
-
-      TGA (not sure what subset, if a subset)
-      BMP non-1bpp, non-RLE
-      PSD (composited view only, no extra channels, 8/16 bit-per-channel)
-
-      GIF (*comp always reports as 4-channel)
-      HDR (radiance rgbE format)
-      PIC (Softimage PIC)
-      PNM (PPM and PGM binary only)
-
-      Animated GIF still needs a proper API, but here's one way to do it:
-          http://gist.github.com/urraka/685d9a6340b26b830d49
-
-      - decode from memory or through FILE (define STBI_NO_STDIO to remove code)
-      - decode from arbitrary I/O callbacks
-      - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON)
-
-   Full documentation under "DOCUMENTATION" below.
-
-
-LICENSE
-
-  See end of file for license information.
-
-RECENT REVISION HISTORY:
-
-      2.26  (2020-07-13) many minor fixes
-      2.25  (2020-02-02) fix warnings
-      2.24  (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically
-      2.23  (2019-08-11) fix clang static analysis warning
-      2.22  (2019-03-04) gif fixes, fix warnings
-      2.21  (2019-02-25) fix typo in comment
-      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
-      2.19  (2018-02-11) fix warning
-      2.18  (2018-01-30) fix warnings
-      2.17  (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings
-      2.16  (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes
-      2.15  (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC
-      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
-      2.13  (2016-12-04) experimental 16-bit API, only for PNG so far; fixes
-      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
-      2.11  (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64
-                         RGB-format JPEG; remove white matting in PSD;
-                         allocate large structures on the stack;
-                         correct channel count for PNG & BMP
-      2.10  (2016-01-22) avoid warning introduced in 2.09
-      2.09  (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED
-
-   See end of file for full revision history.
-
-
- ============================    Contributors    =========================
-
- Image formats                          Extensions, features
-    Sean Barrett (jpeg, png, bmp)          Jetro Lauha (stbi_info)
-    Nicolas Schulz (hdr, psd)              Martin "SpartanJ" Golini (stbi_info)
-    Jonathan Dummer (tga)                  James "moose2000" Brown (iPhone PNG)
-    Jean-Marc Lienher (gif)                Ben "Disch" Wenger (io callbacks)
-    Tom Seddon (pic)                       Omar Cornut (1/2/4-bit PNG)
-    Thatcher Ulrich (psd)                  Nicolas Guillemot (vertical flip)
-    Ken Miller (pgm, ppm)                  Richard Mitton (16-bit PSD)
-    github:urraka (animated gif)           Junggon Kim (PNM comments)
-    Christopher Forseth (animated gif)     Daniel Gibson (16-bit TGA)
-                                           socks-the-fox (16-bit PNG)
-                                           Jeremy Sawicki (handle all ImageNet JPGs)
- Optimizations & bugfixes                  Mikhail Morozov (1-bit BMP)
-    Fabian "ryg" Giesen                    Anael Seghezzi (is-16-bit query)
-    Arseny Kapoulkine
-    John-Mark Allen
-    Carmelo J Fdez-Aguera
-
- Bug & warning fixes
-    Marc LeBlanc            David Woo          Guillaume George     Martins Mozeiko
-    Christpher Lloyd        Jerry Jansson      Joseph Thomson       Blazej Dariusz Roszkowski
-    Phil Jordan                                Dave Moore           Roy Eltham
-    Hayaki Saito            Nathan Reed        Won Chun
-    Luke Graham             Johan Duparc       Nick Verigakis       the Horde3D community
-    Thomas Ruf              Ronny Chevalier                         github:rlyeh
-    Janez Zemva             John Bartholomew   Michal Cichon        github:romigrou
-    Jonathan Blow           Ken Hamada         Tero Hanninen        github:svdijk
-                            Laurent Gomila     Cort Stratton        github:snagar
-    Aruelien Pocheville     Sergio Gonzalez    Thibault Reuille     github:Zelex
-    Cass Everitt            Ryamond Barbiero                        github:grim210
-    Paul Du Bois            Engin Manap        Aldo Culquicondor    github:sammyhw
-    Philipp Wiesemann       Dale Weiler        Oriol Ferrer Mesia   github:phprus
-    Josh Tobin                                 Matthew Gregan       github:poppolopoppo
-    Julian Raschke          Gregory Mullen     Christian Floisand   github:darealshinji
-    Baldur Karlsson         Kevin Schmidt      JR Smith             github:Michaelangel007
-                            Brad Weinberger    Matvey Cherevko      [reserved]
-    Luca Sas                Alexander Veselov  Zack Middleton       [reserved]
-    Ryan C. Gordon          [reserved]                              [reserved]
-                     DO NOT ADD YOUR NAME HERE
-
-  To add your name to the credits, pick a random blank space in the middle and fill it.
-  80% of merge conflicts on stb PRs are due to people adding their name at the end
-  of the credits.
-*/
-
-#ifndef STBI_INCLUDE_STB_IMAGE_H
-#define STBI_INCLUDE_STB_IMAGE_H
-
-// DOCUMENTATION
-//
-// Limitations:
-//    - no 12-bit-per-channel JPEG
-//    - no JPEGs with arithmetic coding
-//    - GIF always returns *comp=4
-//
-// Basic usage (see HDR discussion below for HDR usage):
-//    int x,y,n;
-//    unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
-//    // ... process data if not NULL ...
-//    // ... x = width, y = height, n = # 8-bit components per pixel ...
-//    // ... replace '0' with '1'..'4' to force that many components per pixel
-//    // ... but 'n' will always be the number that it would have been if you said 0
-//    stbi_image_free(data)
-//
-// Standard parameters:
-//    int *x                 -- outputs image width in pixels
-//    int *y                 -- outputs image height in pixels
-//    int *channels_in_file  -- outputs # of image components in image file
-//    int desired_channels   -- if non-zero, # of image components requested in result
-//
-// The return value from an image loader is an 'unsigned char *' which points
-// to the pixel data, or NULL on an allocation failure or if the image is
-// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels,
-// with each pixel consisting of N interleaved 8-bit components; the first
-// pixel pointed to is top-left-most in the image. There is no padding between
-// image scanlines or between pixels, regardless of format. The number of
-// components N is 'desired_channels' if desired_channels is non-zero, or
-// *channels_in_file otherwise. If desired_channels is non-zero,
-// *channels_in_file has the number of components that _would_ have been
-// output otherwise. E.g. if you set desired_channels to 4, you will always
-// get RGBA output, but you can check *channels_in_file to see if it's trivially
-// opaque because e.g. there were only 3 channels in the source image.
-//
-// An output image with N components has the following components interleaved
-// in this order in each pixel:
-//
-//     N=#comp     components
-//       1           grey
-//       2           grey, alpha
-//       3           red, green, blue
-//       4           red, green, blue, alpha
-//
-// If image loading fails for any reason, the return value will be NULL,
-// and *x, *y, *channels_in_file will be unchanged. The function
-// stbi_failure_reason() can be queried for an extremely brief, end-user
-// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS
-// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
-// more user-friendly ones.
-//
-// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
-//
-// ===========================================================================
-//
-// UNICODE:
-//
-//   If compiling for Windows and you wish to use Unicode filenames, compile
-//   with
-//       #define STBI_WINDOWS_UTF8
-//   and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert
-//   Windows wchar_t filenames to utf8.
-//
-// ===========================================================================
-//
-// Philosophy
-//
-// stb libraries are designed with the following priorities:
-//
-//    1. easy to use
-//    2. easy to maintain
-//    3. good performance
-//
-// Sometimes I let "good performance" creep up in priority over "easy to maintain",
-// and for best performance I may provide less-easy-to-use APIs that give higher
-// performance, in addition to the easy-to-use ones. Nevertheless, it's important
-// to keep in mind that from the standpoint of you, a client of this library,
-// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all.
-//
-// Some secondary priorities arise directly from the first two, some of which
-// provide more explicit reasons why performance can't be emphasized.
-//
-//    - Portable ("ease of use")
-//    - Small source code footprint ("easy to maintain")
-//    - No dependencies ("ease of use")
-//
-// ===========================================================================
-//
-// I/O callbacks
-//
-// I/O callbacks allow you to read from arbitrary sources, like packaged
-// files or some other source. Data read from callbacks are processed
-// through a small internal buffer (currently 128 bytes) to try to reduce
-// overhead.
-//
-// The three functions you must define are "read" (reads some bytes of data),
-// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
-//
-// ===========================================================================
-//
-// SIMD support
-//
-// The JPEG decoder will try to automatically use SIMD kernels on x86 when
-// supported by the compiler. For ARM Neon support, you must explicitly
-// request it.
-//
-// (The old do-it-yourself SIMD API is no longer supported in the current
-// code.)
-//
-// On x86, SSE2 will automatically be used when available based on a run-time
-// test; if not, the generic C versions are used as a fall-back. On ARM targets,
-// the typical path is to have separate builds for NEON and non-NEON devices
-// (at least this is true for iOS and Android). Therefore, the NEON support is
-// toggled by a build flag: define STBI_NEON to get NEON loops.
-//
-// If for some reason you do not want to use any of SIMD code, or if
-// you have issues compiling it, you can disable it entirely by
-// defining STBI_NO_SIMD.
-//
-// ===========================================================================
-//
-// HDR image support   (disable by defining STBI_NO_HDR)
-//
-// stb_image supports loading HDR images in general, and currently the Radiance
-// .HDR file format specifically. You can still load any file through the existing
-// interface; if you attempt to load an HDR file, it will be automatically remapped
-// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
-// both of these constants can be reconfigured through this interface:
-//
-//     stbi_hdr_to_ldr_gamma(2.2f);
-//     stbi_hdr_to_ldr_scale(1.0f);
-//
-// (note, do not use _inverse_ constants; stbi_image will invert them
-// appropriately).
-//
-// Additionally, there is a new, parallel interface for loading files as
-// (linear) floats to preserve the full dynamic range:
-//
-//    float *data = stbi_loadf(filename, &x, &y, &n, 0);
-//
-// If you load LDR images through this interface, those images will
-// be promoted to floating point values, run through the inverse of
-// constants corresponding to the above:
-//
-//     stbi_ldr_to_hdr_scale(1.0f);
-//     stbi_ldr_to_hdr_gamma(2.2f);
-//
-// Finally, given a filename (or an open file or memory block--see header
-// file for details) containing image data, you can query for the "most
-// appropriate" interface to use (that is, whether the image is HDR or
-// not), using:
-//
-//     stbi_is_hdr(char *filename);
-//
-// ===========================================================================
-//
-// iPhone PNG support:
-//
-// By default we convert iphone-formatted PNGs back to RGB, even though
-// they are internally encoded differently. You can disable this conversion
-// by calling stbi_convert_iphone_png_to_rgb(0), in which case
-// you will always just get the native iphone "format" through (which
-// is BGR stored in RGB).
-//
-// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
-// pixel to remove any premultiplied alpha *only* if the image file explicitly
-// says there's premultiplied data (currently only happens in iPhone images,
-// and only if iPhone convert-to-rgb processing is on).
-//
-// ===========================================================================
-//
-// ADDITIONAL CONFIGURATION
-//
-//  - You can suppress implementation of any of the decoders to reduce
-//    your code footprint by #defining one or more of the following
-//    symbols before creating the implementation.
-//
-//        STBI_NO_JPEG
-//        STBI_NO_PNG
-//        STBI_NO_BMP
-//        STBI_NO_PSD
-//        STBI_NO_TGA
-//        STBI_NO_GIF
-//        STBI_NO_HDR
-//        STBI_NO_PIC
-//        STBI_NO_PNM   (.ppm and .pgm)
-//
-//  - You can request *only* certain decoders and suppress all other ones
-//    (this will be more forward-compatible, as addition of new decoders
-//    doesn't require you to disable them explicitly):
-//
-//        STBI_ONLY_JPEG
-//        STBI_ONLY_PNG
-//        STBI_ONLY_BMP
-//        STBI_ONLY_PSD
-//        STBI_ONLY_TGA
-//        STBI_ONLY_GIF
-//        STBI_ONLY_HDR
-//        STBI_ONLY_PIC
-//        STBI_ONLY_PNM   (.ppm and .pgm)
-//
-//   - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still
-//     want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB
-//
-//  - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater
-//    than that size (in either width or height) without further processing.
-//    This is to let programs in the wild set an upper bound to prevent
-//    denial-of-service attacks on untrusted data, as one could generate a
-//    valid image of gigantic dimensions and force stb_image to allocate a
-//    huge block of memory and spend disproportionate time decoding it. By
-//    default this is set to (1 << 24), which is 16777216, but that's still
-//    very big.
-
-#ifndef STBI_NO_STDIO
-#include <stdio.h>
-#endif // STBI_NO_STDIO
-
-#define STBI_VERSION 1
-
-enum
-{
-   STBI_default = 0, // only used for desired_channels
-
-   STBI_grey       = 1,
-   STBI_grey_alpha = 2,
-   STBI_rgb        = 3,
-   STBI_rgb_alpha  = 4
-};
-
-#include <stdlib.h>
-typedef unsigned char stbi_uc;
-typedef unsigned short stbi_us;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef STBIDEF
-#ifdef STB_IMAGE_STATIC
-#define STBIDEF static
-#else
-#define STBIDEF extern
-#endif
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// PRIMARY API - works on images of any type
-//
-
-//
-// load image by filename, open file, or memory buffer
-//
-
-typedef struct
-{
-   int      (*read)  (void *user,char *data,int size);   // fill 'data' with 'size' bytes.  return number of bytes actually read
-   void     (*skip)  (void *user,int n);                 // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
-   int      (*eof)   (void *user);                       // returns nonzero if we are at end of file/data
-} stbi_io_callbacks;
-
-////////////////////////////////////
-//
-// 8-bits-per-channel interface
-//
-
-STBIDEF stbi_uc *stbi_load_from_memory   (stbi_uc           const *buffer, int len   , int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk  , void *user, int *x, int *y, int *channels_in_file, int desired_channels);
-
-#ifndef STBI_NO_STDIO
-STBIDEF stbi_uc *stbi_load            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_uc *stbi_load_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-// for stbi_load_from_file, file pointer is left pointing immediately after image
-#endif
-
-#ifndef STBI_NO_GIF
-STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
-#endif
-
-#ifdef STBI_WINDOWS_UTF8
-STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
-#endif
-
-////////////////////////////////////
-//
-// 16-bits-per-channel interface
-//
-
-STBIDEF stbi_us *stbi_load_16_from_memory   (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels);
-
-#ifndef STBI_NO_STDIO
-STBIDEF stbi_us *stbi_load_16          (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-#endif
-
-////////////////////////////////////
-//
-// float-per-channel interface
-//
-#ifndef STBI_NO_LINEAR
-   STBIDEF float *stbi_loadf_from_memory     (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
-   STBIDEF float *stbi_loadf_from_callbacks  (stbi_io_callbacks const *clbk, void *user, int *x, int *y,  int *channels_in_file, int desired_channels);
-
-   #ifndef STBI_NO_STDIO
-   STBIDEF float *stbi_loadf            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-   STBIDEF float *stbi_loadf_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-   #endif
-#endif
-
-#ifndef STBI_NO_HDR
-   STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma);
-   STBIDEF void   stbi_hdr_to_ldr_scale(float scale);
-#endif // STBI_NO_HDR
-
-#ifndef STBI_NO_LINEAR
-   STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma);
-   STBIDEF void   stbi_ldr_to_hdr_scale(float scale);
-#endif // STBI_NO_LINEAR
-
-// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
-STBIDEF int    stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
-STBIDEF int    stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_is_hdr          (char const *filename);
-STBIDEF int      stbi_is_hdr_from_file(FILE *f);
-#endif // STBI_NO_STDIO
-
-
-// get a VERY brief reason for failure
-// on most compilers (and ALL modern mainstream compilers) this is threadsafe
-STBIDEF const char *stbi_failure_reason  (void);
-
-// free the loaded image -- this is just free()
-STBIDEF void     stbi_image_free      (void *retval_from_stbi_load);
-
-// get image dimensions & components without fully decoding
-STBIDEF int      stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
-STBIDEF int      stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
-STBIDEF int      stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len);
-STBIDEF int      stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user);
-
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_info               (char const *filename,     int *x, int *y, int *comp);
-STBIDEF int      stbi_info_from_file     (FILE *f,                  int *x, int *y, int *comp);
-STBIDEF int      stbi_is_16_bit          (char const *filename);
-STBIDEF int      stbi_is_16_bit_from_file(FILE *f);
-#endif
-
-
-
-// for image formats that explicitly notate that they have premultiplied alpha,
-// we just return the colors as stored in the file. set this flag to force
-// unpremultiplication. results are undefined if the unpremultiply overflow.
-STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
-
-// indicate whether we should process iphone images back to canonical format,
-// or just pass them through "as-is"
-STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
-
-// flip the image vertically, so the first pixel in the output array is the bottom left
-STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
-
-// as above, but only applies to images loaded on the thread that calls the function
-// this function is only available if your compiler supports thread-local variables;
-// calling it will fail to link if your compiler doesn't
-STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
-
-// ZLIB client - used by PNG, available for other purposes
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
-STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);
-STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
-STBIDEF int   stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
-
-STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
-STBIDEF int   stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-//
-//
-////   end header file   /////////////////////////////////////////////////////
-#endif // STBI_INCLUDE_STB_IMAGE_H
-
-#ifdef STB_IMAGE_IMPLEMENTATION
-
-#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \
-  || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \
-  || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \
-  || defined(STBI_ONLY_ZLIB)
-   #ifndef STBI_ONLY_JPEG
-   #define STBI_NO_JPEG
-   #endif
-   #ifndef STBI_ONLY_PNG
-   #define STBI_NO_PNG
-   #endif
-   #ifndef STBI_ONLY_BMP
-   #define STBI_NO_BMP
-   #endif
-   #ifndef STBI_ONLY_PSD
-   #define STBI_NO_PSD
-   #endif
-   #ifndef STBI_ONLY_TGA
-   #define STBI_NO_TGA
-   #endif
-   #ifndef STBI_ONLY_GIF
-   #define STBI_NO_GIF
-   #endif
-   #ifndef STBI_ONLY_HDR
-   #define STBI_NO_HDR
-   #endif
-   #ifndef STBI_ONLY_PIC
-   #define STBI_NO_PIC
-   #endif
-   #ifndef STBI_ONLY_PNM
-   #define STBI_NO_PNM
-   #endif
-#endif
-
-#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB)
-#define STBI_NO_ZLIB
-#endif
-
-
-#include <stdarg.h>
-#include <stddef.h> // ptrdiff_t on osx
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-#include <math.h>  // ldexp, pow
-#endif
-
-#ifndef STBI_NO_STDIO
-#include <stdio.h>
-#endif
-
-#ifndef STBI_ASSERT
-#include <assert.h>
-#define STBI_ASSERT(x) assert(x)
-#endif
-
-#ifdef __cplusplus
-#define STBI_EXTERN extern "C"
-#else
-#define STBI_EXTERN extern
-#endif
-
-
-#ifndef _MSC_VER
-   #ifdef __cplusplus
-   #define stbi_inline inline
-   #else
-   #define stbi_inline
-   #endif
-#else
-   #define stbi_inline __forceinline
-#endif
-
-#ifndef STBI_NO_THREAD_LOCALS
-   #if defined(__cplusplus) &&  __cplusplus >= 201103L
-      #define STBI_THREAD_LOCAL       thread_local
-   #elif defined(__GNUC__) && __GNUC__ < 5
-      #define STBI_THREAD_LOCAL       __thread
-   #elif defined(_MSC_VER)
-      #define STBI_THREAD_LOCAL       __declspec(thread)
-   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
-      #define STBI_THREAD_LOCAL       _Thread_local
-   #endif
-
-   #ifndef STBI_THREAD_LOCAL
-      #if defined(__GNUC__)
-        #define STBI_THREAD_LOCAL       __thread
-      #endif
-   #endif
-#endif
-
-#ifdef _MSC_VER
-typedef unsigned short stbi__uint16;
-typedef   signed short stbi__int16;
-typedef unsigned int   stbi__uint32;
-typedef   signed int   stbi__int32;
-#else
-#include <stdint.h>
-typedef uint16_t stbi__uint16;
-typedef int16_t  stbi__int16;
-typedef uint32_t stbi__uint32;
-typedef int32_t  stbi__int32;
-#endif
-
-// should produce compiler error if size is wrong
-typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
-
-#ifdef _MSC_VER
-#define STBI_NOTUSED(v)  (void)(v)
-#else
-#define STBI_NOTUSED(v)  (void)sizeof(v)
-#endif
-
-#ifdef _MSC_VER
-#define STBI_HAS_LROTL
-#endif
-
-#ifdef STBI_HAS_LROTL
-   #define stbi_lrot(x,y)  _lrotl(x,y)
-#else
-   #define stbi_lrot(x,y)  (((x) << (y)) | ((x) >> (32 - (y))))
-#endif
-
-#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
-// ok
-#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED)
-// ok
-#else
-#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)."
-#endif
-
-#ifndef STBI_MALLOC
-#define STBI_MALLOC(sz)           malloc(sz)
-#define STBI_REALLOC(p,newsz)     realloc(p,newsz)
-#define STBI_FREE(p)              free(p)
-#endif
-
-#ifndef STBI_REALLOC_SIZED
-#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz)
-#endif
-
-// x86/x64 detection
-#if defined(__x86_64__) || defined(_M_X64)
-#define STBI__X64_TARGET
-#elif defined(__i386) || defined(_M_IX86)
-#define STBI__X86_TARGET
-#endif
-
-#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)
-// gcc doesn't support sse2 intrinsics unless you compile with -msse2,
-// which in turn means it gets to use SSE2 everywhere. This is unfortunate,
-// but previous attempts to provide the SSE2 functions with runtime
-// detection caused numerous issues. The way architecture extensions are
-// exposed in GCC/Clang is, sadly, not really suited for one-file libs.
-// New behavior: if compiled with -msse2, we use SSE2 without any
-// detection; if not, we don't use it at all.
-#define STBI_NO_SIMD
-#endif
-
-#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)
-// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET
-//
-// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the
-// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.
-// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not
-// simultaneously enabling "-mstackrealign".
-//
-// See https://github.com/nothings/stb/issues/81 for more information.
-//
-// So default to no SSE2 on 32-bit MinGW. If you've read this far and added
-// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.
-#define STBI_NO_SIMD
-#endif
-
-#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET))
-#define STBI_SSE2
-#include <emmintrin.h>
-
-#ifdef _MSC_VER
-
-#if _MSC_VER >= 1400  // not VC6
-#include <intrin.h> // __cpuid
-static int stbi__cpuid3(void)
-{
-   int info[4];
-   __cpuid(info,1);
-   return info[3];
-}
-#else
-static int stbi__cpuid3(void)
-{
-   int res;
-   __asm {
-      mov  eax,1
-      cpuid
-      mov  res,edx
-   }
-   return res;
-}
-#endif
-
-#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
-
-#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
-static int stbi__sse2_available(void)
-{
-   int info3 = stbi__cpuid3();
-   return ((info3 >> 26) & 1) != 0;
-}
-#endif
-
-#else // assume GCC-style if not VC++
-#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
-
-#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
-static int stbi__sse2_available(void)
-{
-   // If we're even attempting to compile this on GCC/Clang, that means
-   // -msse2 is on, which means the compiler is allowed to use SSE2
-   // instructions at will, and so are we.
-   return 1;
-}
-#endif
-
-#endif
-#endif
-
-// ARM NEON
-#if defined(STBI_NO_SIMD) && defined(STBI_NEON)
-#undef STBI_NEON
-#endif
-
-#ifdef STBI_NEON
-#include <arm_neon.h>
-// assume GCC or Clang on ARM targets
-#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
-#endif
-
-#ifndef STBI_SIMD_ALIGN
-#define STBI_SIMD_ALIGN(type, name) type name
-#endif
-
-#ifndef STBI_MAX_DIMENSIONS
-#define STBI_MAX_DIMENSIONS (1 << 24)
-#endif
-
-///////////////////////////////////////////////
-//
-//  stbi__context struct and start_xxx functions
-
-// stbi__context structure is our basic context used by all images, so it
-// contains all the IO context, plus some basic image information
-typedef struct
-{
-   stbi__uint32 img_x, img_y;
-   int img_n, img_out_n;
-
-   stbi_io_callbacks io;
-   void *io_user_data;
-
-   int read_from_callbacks;
-   int buflen;
-   stbi_uc buffer_start[128];
-   int callback_already_read;
-
-   stbi_uc *img_buffer, *img_buffer_end;
-   stbi_uc *img_buffer_original, *img_buffer_original_end;
-} stbi__context;
-
-
-static void stbi__refill_buffer(stbi__context *s);
-
-// initialize a memory-decode context
-static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len)
-{
-   s->io.read = NULL;
-   s->read_from_callbacks = 0;
-   s->callback_already_read = 0;
-   s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer;
-   s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len;
-}
-
-// initialize a callback-based context
-static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user)
-{
-   s->io = *c;
-   s->io_user_data = user;
-   s->buflen = sizeof(s->buffer_start);
-   s->read_from_callbacks = 1;
-   s->callback_already_read = 0;
-   s->img_buffer = s->img_buffer_original = s->buffer_start;
-   stbi__refill_buffer(s);
-   s->img_buffer_original_end = s->img_buffer_end;
-}
-
-#ifndef STBI_NO_STDIO
-
-static int stbi__stdio_read(void *user, char *data, int size)
-{
-   return (int) fread(data,1,size,(FILE*) user);
-}
-
-static void stbi__stdio_skip(void *user, int n)
-{
-   int ch;
-   fseek((FILE*) user, n, SEEK_CUR);
-   ch = fgetc((FILE*) user);  /* have to read a byte to reset feof()'s flag */
-   if (ch != EOF) {
-      ungetc(ch, (FILE *) user);  /* push byte back onto stream if valid. */
-   }
-}
-
-static int stbi__stdio_eof(void *user)
-{
-   return feof((FILE*) user) || ferror((FILE *) user);
-}
-
-static stbi_io_callbacks stbi__stdio_callbacks =
-{
-   stbi__stdio_read,
-   stbi__stdio_skip,
-   stbi__stdio_eof,
-};
-
-static void stbi__start_file(stbi__context *s, FILE *f)
-{
-   stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f);
-}
-
-//static void stop_file(stbi__context *s) { }
-
-#endif // !STBI_NO_STDIO
-
-static void stbi__rewind(stbi__context *s)
-{
-   // conceptually rewind SHOULD rewind to the beginning of the stream,
-   // but we just rewind to the beginning of the initial buffer, because
-   // we only use it after doing 'test', which only ever looks at at most 92 bytes
-   s->img_buffer = s->img_buffer_original;
-   s->img_buffer_end = s->img_buffer_original_end;
-}
-
-enum
-{
-   STBI_ORDER_RGB,
-   STBI_ORDER_BGR
-};
-
-typedef struct
-{
-   int bits_per_channel;
-   int num_channels;
-   int channel_order;
-} stbi__result_info;
-
-#ifndef STBI_NO_JPEG
-static int      stbi__jpeg_test(stbi__context *s);
-static void    *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PNG
-static int      stbi__png_test(stbi__context *s);
-static void    *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__png_info(stbi__context *s, int *x, int *y, int *comp);
-static int      stbi__png_is16(stbi__context *s);
-#endif
-
-#ifndef STBI_NO_BMP
-static int      stbi__bmp_test(stbi__context *s);
-static void    *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_TGA
-static int      stbi__tga_test(stbi__context *s);
-static void    *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__tga_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PSD
-static int      stbi__psd_test(stbi__context *s);
-static void    *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc);
-static int      stbi__psd_info(stbi__context *s, int *x, int *y, int *comp);
-static int      stbi__psd_is16(stbi__context *s);
-#endif
-
-#ifndef STBI_NO_HDR
-static int      stbi__hdr_test(stbi__context *s);
-static float   *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PIC
-static int      stbi__pic_test(stbi__context *s);
-static void    *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__pic_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_GIF
-static int      stbi__gif_test(stbi__context *s);
-static void    *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static void    *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
-static int      stbi__gif_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PNM
-static int      stbi__pnm_test(stbi__context *s);
-static void    *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-static
-#ifdef STBI_THREAD_LOCAL
-STBI_THREAD_LOCAL
-#endif
-const char *stbi__g_failure_reason;
-
-STBIDEF const char *stbi_failure_reason(void)
-{
-   return stbi__g_failure_reason;
-}
-
-#ifndef STBI_NO_FAILURE_STRINGS
-static int stbi__err(const char *str)
-{
-   stbi__g_failure_reason = str;
-   return 0;
-}
-#endif
-
-static void *stbi__malloc(size_t size)
-{
-    return STBI_MALLOC(size);
-}
-
-// stb_image uses ints pervasively, including for offset calculations.
-// therefore the largest decoded image size we can support with the
-// current code, even on 64-bit targets, is INT_MAX. this is not a
-// significant limitation for the intended use case.
-//
-// we do, however, need to make sure our size calculations don't
-// overflow. hence a few helper functions for size calculations that
-// multiply integers together, making sure that they're non-negative
-// and no overflow occurs.
-
-// return 1 if the sum is valid, 0 on overflow.
-// negative terms are considered invalid.
-static int stbi__addsizes_valid(int a, int b)
-{
-   if (b < 0) return 0;
-   // now 0 <= b <= INT_MAX, hence also
-   // 0 <= INT_MAX - b <= INTMAX.
-   // And "a + b <= INT_MAX" (which might overflow) is the
-   // same as a <= INT_MAX - b (no overflow)
-   return a <= INT_MAX - b;
-}
-
-// returns 1 if the product is valid, 0 on overflow.
-// negative factors are considered invalid.
-static int stbi__mul2sizes_valid(int a, int b)
-{
-   if (a < 0 || b < 0) return 0;
-   if (b == 0) return 1; // mul-by-0 is always safe
-   // portable way to check for no overflows in a*b
-   return a <= INT_MAX/b;
-}
-
-#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
-// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow
-static int stbi__mad2sizes_valid(int a, int b, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add);
-}
-#endif
-
-// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow
-static int stbi__mad3sizes_valid(int a, int b, int c, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
-      stbi__addsizes_valid(a*b*c, add);
-}
-
-// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
-      stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
-}
-#endif
-
-#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
-// mallocs with size overflow checking
-static void *stbi__malloc_mad2(int a, int b, int add)
-{
-   if (!stbi__mad2sizes_valid(a, b, add)) return NULL;
-   return stbi__malloc(a*b + add);
-}
-#endif
-
-static void *stbi__malloc_mad3(int a, int b, int c, int add)
-{
-   if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL;
-   return stbi__malloc(a*b*c + add);
-}
-
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
-{
-   if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
-   return stbi__malloc(a*b*c*d + add);
-}
-#endif
-
-// stbi__err - error
-// stbi__errpf - error returning pointer to float
-// stbi__errpuc - error returning pointer to unsigned char
-
-#ifdef STBI_NO_FAILURE_STRINGS
-   #define stbi__err(x,y)  0
-#elif defined(STBI_FAILURE_USERMSG)
-   #define stbi__err(x,y)  stbi__err(y)
-#else
-   #define stbi__err(x,y)  stbi__err(x)
-#endif
-
-#define stbi__errpf(x,y)   ((float *)(size_t) (stbi__err(x,y)?NULL:NULL))
-#define stbi__errpuc(x,y)  ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))
-
-STBIDEF void stbi_image_free(void *retval_from_stbi_load)
-{
-   STBI_FREE(retval_from_stbi_load);
-}
-
-#ifndef STBI_NO_LINEAR
-static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp);
-#endif
-
-#ifndef STBI_NO_HDR
-static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp);
-#endif
-
-static int stbi__vertically_flip_on_load_global = 0;
-
-STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip)
-{
-   stbi__vertically_flip_on_load_global = flag_true_if_should_flip;
-}
-
-#ifndef STBI_THREAD_LOCAL
-#define stbi__vertically_flip_on_load  stbi__vertically_flip_on_load_global
-#else
-static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set;
-
-STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip)
-{
-   stbi__vertically_flip_on_load_local = flag_true_if_should_flip;
-   stbi__vertically_flip_on_load_set = 1;
-}
-
-#define stbi__vertically_flip_on_load  (stbi__vertically_flip_on_load_set       \
-                                         ? stbi__vertically_flip_on_load_local  \
-                                         : stbi__vertically_flip_on_load_global)
-#endif // STBI_THREAD_LOCAL
-
-static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
-{
-   memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields
-   ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed
-   ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
-   ri->num_channels = 0;
-
-   #ifndef STBI_NO_JPEG
-   if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PNG
-   if (stbi__png_test(s))  return stbi__png_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_BMP
-   if (stbi__bmp_test(s))  return stbi__bmp_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_GIF
-   if (stbi__gif_test(s))  return stbi__gif_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_test(s))  return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc);
-   #else
-   STBI_NOTUSED(bpc);
-   #endif
-   #ifndef STBI_NO_PIC
-   if (stbi__pic_test(s))  return stbi__pic_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PNM
-   if (stbi__pnm_test(s))  return stbi__pnm_load(s,x,y,comp,req_comp, ri);
-   #endif
-
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_test(s)) {
-      float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri);
-      return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);
-   }
-   #endif
-
-   #ifndef STBI_NO_TGA
-   // test tga last because it's a crappy test!
-   if (stbi__tga_test(s))
-      return stbi__tga_load(s,x,y,comp,req_comp, ri);
-   #endif
-
-   return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt");
-}
-
-static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)
-{
-   int i;
-   int img_len = w * h * channels;
-   stbi_uc *reduced;
-
-   reduced = (stbi_uc *) stbi__malloc(img_len);
-   if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory");
-
-   for (i = 0; i < img_len; ++i)
-      reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling
-
-   STBI_FREE(orig);
-   return reduced;
-}
-
-static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels)
-{
-   int i;
-   int img_len = w * h * channels;
-   stbi__uint16 *enlarged;
-
-   enlarged = (stbi__uint16 *) stbi__malloc(img_len*2);
-   if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
-
-   for (i = 0; i < img_len; ++i)
-      enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff
-
-   STBI_FREE(orig);
-   return enlarged;
-}
-
-static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel)
-{
-   int row;
-   size_t bytes_per_row = (size_t)w * bytes_per_pixel;
-   stbi_uc temp[2048];
-   stbi_uc *bytes = (stbi_uc *)image;
-
-   for (row = 0; row < (h>>1); row++) {
-      stbi_uc *row0 = bytes + row*bytes_per_row;
-      stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row;
-      // swap row0 with row1
-      size_t bytes_left = bytes_per_row;
-      while (bytes_left) {
-         size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp);
-         memcpy(temp, row0, bytes_copy);
-         memcpy(row0, row1, bytes_copy);
-         memcpy(row1, temp, bytes_copy);
-         row0 += bytes_copy;
-         row1 += bytes_copy;
-         bytes_left -= bytes_copy;
-      }
-   }
-}
-
-#ifndef STBI_NO_GIF
-static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel)
-{
-   int slice;
-   int slice_size = w * h * bytes_per_pixel;
-
-   stbi_uc *bytes = (stbi_uc *)image;
-   for (slice = 0; slice < z; ++slice) {
-      stbi__vertical_flip(bytes, w, h, bytes_per_pixel);
-      bytes += slice_size;
-   }
-}
-#endif
-
-static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__result_info ri;
-   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8);
-
-   if (result == NULL)
-      return NULL;
-
-   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
-   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
-
-   if (ri.bits_per_channel != 8) {
-      result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
-      ri.bits_per_channel = 8;
-   }
-
-   // @TODO: move stbi__convert_format to here
-
-   if (stbi__vertically_flip_on_load) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc));
-   }
-
-   return (unsigned char *) result;
-}
-
-static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__result_info ri;
-   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16);
-
-   if (result == NULL)
-      return NULL;
-
-   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
-   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
-
-   if (ri.bits_per_channel != 16) {
-      result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
-      ri.bits_per_channel = 16;
-   }
-
-   // @TODO: move stbi__convert_format16 to here
-   // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision
-
-   if (stbi__vertically_flip_on_load) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16));
-   }
-
-   return (stbi__uint16 *) result;
-}
-
-#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR)
-static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp)
-{
-   if (stbi__vertically_flip_on_load && result != NULL) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(float));
-   }
-}
-#endif
-
-#ifndef STBI_NO_STDIO
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
-STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
-#endif
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
-{
-       return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
-}
-#endif
-
-static FILE *stbi__fopen(char const *filename, char const *mode)
-{
-   FILE *f;
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-   wchar_t wMode[64];
-   wchar_t wFilename[1024];
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
-      return 0;
-
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
-      return 0;
-
-#if _MSC_VER >= 1400
-       if (0 != _wfopen_s(&f, wFilename, wMode))
-               f = 0;
-#else
-   f = _wfopen(wFilename, wMode);
-#endif
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
-   if (0 != fopen_s(&f, filename, mode))
-      f=0;
-#else
-   f = fopen(filename, mode);
-#endif
-   return f;
-}
-
-
-STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   unsigned char *result;
-   if (!f) return stbi__errpuc("can't fopen", "Unable to open file");
-   result = stbi_load_from_file(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   unsigned char *result;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-   if (result) {
-      // need to 'unget' all the characters in the IO buffer
-      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
-   }
-   return result;
-}
-
-STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__uint16 *result;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp);
-   if (result) {
-      // need to 'unget' all the characters in the IO buffer
-      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
-   }
-   return result;
-}
-
-STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   stbi__uint16 *result;
-   if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file");
-   result = stbi_load_from_file_16(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-
-#endif //!STBI_NO_STDIO
-
-STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
-}
-
-STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user);
-   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
-}
-
-STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-}
-
-STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-}
-
-#ifndef STBI_NO_GIF
-STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
-{
-   unsigned char *result;
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-
-   result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);
-   if (stbi__vertically_flip_on_load) {
-      stbi__vertical_flip_slices( result, *x, *y, *z, *comp );
-   }
-
-   return result;
-}
-#endif
-
-#ifndef STBI_NO_LINEAR
-static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   unsigned char *data;
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_test(s)) {
-      stbi__result_info ri;
-      float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri);
-      if (hdr_data)
-         stbi__float_postprocess(hdr_data,x,y,comp,req_comp);
-      return hdr_data;
-   }
-   #endif
-   data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp);
-   if (data)
-      return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp);
-   return stbi__errpf("unknown image type", "Image not of any known type, or corrupt");
-}
-
-STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-
-STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   float *result;
-   FILE *f = stbi__fopen(filename, "rb");
-   if (!f) return stbi__errpf("can't fopen", "Unable to open file");
-   result = stbi_loadf_from_file(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_file(&s,f);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-#endif // !STBI_NO_STDIO
-
-#endif // !STBI_NO_LINEAR
-
-// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is
-// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always
-// reports false!
-
-STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len)
-{
-   #ifndef STBI_NO_HDR
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__hdr_test(&s);
-   #else
-   STBI_NOTUSED(buffer);
-   STBI_NOTUSED(len);
-   return 0;
-   #endif
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_is_hdr          (char const *filename)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   int result=0;
-   if (f) {
-      result = stbi_is_hdr_from_file(f);
-      fclose(f);
-   }
-   return result;
-}
-
-STBIDEF int stbi_is_hdr_from_file(FILE *f)
-{
-   #ifndef STBI_NO_HDR
-   long pos = ftell(f);
-   int res;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   res = stbi__hdr_test(&s);
-   fseek(f, pos, SEEK_SET);
-   return res;
-   #else
-   STBI_NOTUSED(f);
-   return 0;
-   #endif
-}
-#endif // !STBI_NO_STDIO
-
-STBIDEF int      stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user)
-{
-   #ifndef STBI_NO_HDR
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__hdr_test(&s);
-   #else
-   STBI_NOTUSED(clbk);
-   STBI_NOTUSED(user);
-   return 0;
-   #endif
-}
-
-#ifndef STBI_NO_LINEAR
-static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f;
-
-STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; }
-STBIDEF void   stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; }
-#endif
-
-static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f;
-
-STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; }
-STBIDEF void   stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; }
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Common code used by all image loaders
-//
-
-enum
-{
-   STBI__SCAN_load=0,
-   STBI__SCAN_type,
-   STBI__SCAN_header
-};
-
-static void stbi__refill_buffer(stbi__context *s)
-{
-   int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen);
-   s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original);
-   if (n == 0) {
-      // at end of file, treat same as if from memory, but need to handle case
-      // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file
-      s->read_from_callbacks = 0;
-      s->img_buffer = s->buffer_start;
-      s->img_buffer_end = s->buffer_start+1;
-      *s->img_buffer = 0;
-   } else {
-      s->img_buffer = s->buffer_start;
-      s->img_buffer_end = s->buffer_start + n;
-   }
-}
-
-stbi_inline static stbi_uc stbi__get8(stbi__context *s)
-{
-   if (s->img_buffer < s->img_buffer_end)
-      return *s->img_buffer++;
-   if (s->read_from_callbacks) {
-      stbi__refill_buffer(s);
-      return *s->img_buffer++;
-   }
-   return 0;
-}
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-stbi_inline static int stbi__at_eof(stbi__context *s)
-{
-   if (s->io.read) {
-      if (!(s->io.eof)(s->io_user_data)) return 0;
-      // if feof() is true, check if buffer = end
-      // special case: we've only got the special 0 character at the end
-      if (s->read_from_callbacks == 0) return 1;
-   }
-
-   return s->img_buffer >= s->img_buffer_end;
-}
-#endif
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC)
-// nothing
-#else
-static void stbi__skip(stbi__context *s, int n)
-{
-   if (n == 0) return;  // already there!
-   if (n < 0) {
-      s->img_buffer = s->img_buffer_end;
-      return;
-   }
-   if (s->io.read) {
-      int blen = (int) (s->img_buffer_end - s->img_buffer);
-      if (blen < n) {
-         s->img_buffer = s->img_buffer_end;
-         (s->io.skip)(s->io_user_data, n - blen);
-         return;
-      }
-   }
-   s->img_buffer += n;
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM)
-// nothing
-#else
-static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)
-{
-   if (s->io.read) {
-      int blen = (int) (s->img_buffer_end - s->img_buffer);
-      if (blen < n) {
-         int res, count;
-
-         memcpy(buffer, s->img_buffer, blen);
-
-         count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen);
-         res = (count == (n-blen));
-         s->img_buffer = s->img_buffer_end;
-         return res;
-      }
-   }
-
-   if (s->img_buffer+n <= s->img_buffer_end) {
-      memcpy(buffer, s->img_buffer, n);
-      s->img_buffer += n;
-      return 1;
-   } else
-      return 0;
-}
-#endif
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
-// nothing
-#else
-static int stbi__get16be(stbi__context *s)
-{
-   int z = stbi__get8(s);
-   return (z << 8) + stbi__get8(s);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
-// nothing
-#else
-static stbi__uint32 stbi__get32be(stbi__context *s)
-{
-   stbi__uint32 z = stbi__get16be(s);
-   return (z << 16) + stbi__get16be(s);
-}
-#endif
-
-#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF)
-// nothing
-#else
-static int stbi__get16le(stbi__context *s)
-{
-   int z = stbi__get8(s);
-   return z + (stbi__get8(s) << 8);
-}
-#endif
-
-#ifndef STBI_NO_BMP
-static stbi__uint32 stbi__get32le(stbi__context *s)
-{
-   stbi__uint32 z = stbi__get16le(s);
-   return z + (stbi__get16le(s) << 16);
-}
-#endif
-
-#define STBI__BYTECAST(x)  ((stbi_uc) ((x) & 255))  // truncate int to byte without warnings
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-//////////////////////////////////////////////////////////////////////////////
-//
-//  generic converter from built-in img_n to req_comp
-//    individual types do this automatically as much as possible (e.g. jpeg
-//    does all cases internally since it needs to colorspace convert anyway,
-//    and it never has alpha, so very few cases ). png can automatically
-//    interleave an alpha=255 channel, but falls back to this for other cases
-//
-//  assume data buffer is malloced, so malloc a new one and free that one
-//  only failure mode is malloc failing
-
-static stbi_uc stbi__compute_y(int r, int g, int b)
-{
-   return (stbi_uc) (((r*77) + (g*150) +  (29*b)) >> 8);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
-{
-   int i,j;
-   unsigned char *good;
-
-   if (req_comp == img_n) return data;
-   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
-
-   good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0);
-   if (good == NULL) {
-      STBI_FREE(data);
-      return stbi__errpuc("outofmem", "Out of memory");
-   }
-
-   for (j=0; j < (int) y; ++j) {
-      unsigned char *src  = data + j * x * img_n   ;
-      unsigned char *dest = good + j * x * req_comp;
-
-      #define STBI__COMBO(a,b)  ((a)*8+(b))
-      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
-      // convert source image with img_n components to one with req_comp components;
-      // avoid switch per pixel, so use switch per scanline and massive macros
-      switch (STBI__COMBO(img_n, req_comp)) {
-         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255;                                     } break;
-         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
-         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255;                     } break;
-         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;
-         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
-         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                  } break;
-         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255;        } break;
-         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255;    } break;
-         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
-         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                    } break;
-         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion");
-      }
-      #undef STBI__CASE
-   }
-
-   STBI_FREE(data);
-   return good;
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
-// nothing
-#else
-static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
-{
-   return (stbi__uint16) (((r*77) + (g*150) +  (29*b)) >> 8);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
-// nothing
-#else
-static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
-{
-   int i,j;
-   stbi__uint16 *good;
-
-   if (req_comp == img_n) return data;
-   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
-
-   good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
-   if (good == NULL) {
-      STBI_FREE(data);
-      return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
-   }
-
-   for (j=0; j < (int) y; ++j) {
-      stbi__uint16 *src  = data + j * x * img_n   ;
-      stbi__uint16 *dest = good + j * x * req_comp;
-
-      #define STBI__COMBO(a,b)  ((a)*8+(b))
-      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
-      // convert source image with img_n components to one with req_comp components;
-      // avoid switch per pixel, so use switch per scanline and massive macros
-      switch (STBI__COMBO(img_n, req_comp)) {
-         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff;                                     } break;
-         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
-         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff;                     } break;
-         STBI__CASE(2,1) { dest[0]=src[0];                                                     } break;
-         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
-         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                     } break;
-         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff;        } break;
-         STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break;
-         STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break;
-         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                       } break;
-         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion");
-      }
-      #undef STBI__CASE
-   }
-
-   STBI_FREE(data);
-   return good;
-}
-#endif
-
-#ifndef STBI_NO_LINEAR
-static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp)
-{
-   int i,k,n;
-   float *output;
-   if (!data) return NULL;
-   output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0);
-   if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); }
-   // compute number of non-alpha components
-   if (comp & 1) n = comp; else n = comp-1;
-   for (i=0; i < x*y; ++i) {
-      for (k=0; k < n; ++k) {
-         output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale);
-      }
-   }
-   if (n < comp) {
-      for (i=0; i < x*y; ++i) {
-         output[i*comp + n] = data[i*comp + n]/255.0f;
-      }
-   }
-   STBI_FREE(data);
-   return output;
-}
-#endif
-
-#ifndef STBI_NO_HDR
-#define stbi__float2int(x)   ((int) (x))
-static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp)
-{
-   int i,k,n;
-   stbi_uc *output;
-   if (!data) return NULL;
-   output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0);
-   if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); }
-   // compute number of non-alpha components
-   if (comp & 1) n = comp; else n = comp-1;
-   for (i=0; i < x*y; ++i) {
-      for (k=0; k < n; ++k) {
-         float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f;
-         if (z < 0) z = 0;
-         if (z > 255) z = 255;
-         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
-      }
-      if (k < comp) {
-         float z = data[i*comp+k] * 255 + 0.5f;
-         if (z < 0) z = 0;
-         if (z > 255) z = 255;
-         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
-      }
-   }
-   STBI_FREE(data);
-   return output;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  "baseline" JPEG/JFIF decoder
-//
-//    simple implementation
-//      - doesn't support delayed output of y-dimension
-//      - simple interface (only one output format: 8-bit interleaved RGB)
-//      - doesn't try to recover corrupt jpegs
-//      - doesn't allow partial loading, loading multiple at once
-//      - still fast on x86 (copying globals into locals doesn't help x86)
-//      - allocates lots of intermediate memory (full size of all components)
-//        - non-interleaved case requires this anyway
-//        - allows good upsampling (see next)
-//    high-quality
-//      - upsampled channels are bilinearly interpolated, even across blocks
-//      - quality integer IDCT derived from IJG's 'slow'
-//    performance
-//      - fast huffman; reasonable integer IDCT
-//      - some SIMD kernels for common paths on targets with SSE2/NEON
-//      - uses a lot of intermediate memory, could cache poorly
-
-#ifndef STBI_NO_JPEG
-
-// huffman decoding acceleration
-#define FAST_BITS   9  // larger handles more cases; smaller stomps less cache
-
-typedef struct
-{
-   stbi_uc  fast[1 << FAST_BITS];
-   // weirdly, repacking this into AoS is a 10% speed loss, instead of a win
-   stbi__uint16 code[256];
-   stbi_uc  values[256];
-   stbi_uc  size[257];
-   unsigned int maxcode[18];
-   int    delta[17];   // old 'firstsymbol' - old 'firstcode'
-} stbi__huffman;
-
-typedef struct
-{
-   stbi__context *s;
-   stbi__huffman huff_dc[4];
-   stbi__huffman huff_ac[4];
-   stbi__uint16 dequant[4][64];
-   stbi__int16 fast_ac[4][1 << FAST_BITS];
-
-// sizes for components, interleaved MCUs
-   int img_h_max, img_v_max;
-   int img_mcu_x, img_mcu_y;
-   int img_mcu_w, img_mcu_h;
-
-// definition of jpeg image component
-   struct
-   {
-      int id;
-      int h,v;
-      int tq;
-      int hd,ha;
-      int dc_pred;
-
-      int x,y,w2,h2;
-      stbi_uc *data;
-      void *raw_data, *raw_coeff;
-      stbi_uc *linebuf;
-      short   *coeff;   // progressive only
-      int      coeff_w, coeff_h; // number of 8x8 coefficient blocks
-   } img_comp[4];
-
-   stbi__uint32   code_buffer; // jpeg entropy-coded buffer
-   int            code_bits;   // number of valid bits
-   unsigned char  marker;      // marker seen while filling entropy buffer
-   int            nomore;      // flag if we saw a marker so must stop
-
-   int            progressive;
-   int            spec_start;
-   int            spec_end;
-   int            succ_high;
-   int            succ_low;
-   int            eob_run;
-   int            jfif;
-   int            app14_color_transform; // Adobe APP14 tag
-   int            rgb;
-
-   int scan_n, order[4];
-   int restart_interval, todo;
-
-// kernels
-   void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]);
-   void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step);
-   stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs);
-} stbi__jpeg;
-
-static int stbi__build_huffman(stbi__huffman *h, int *count)
-{
-   int i,j,k=0;
-   unsigned int code;
-   // build size list for each symbol (from JPEG spec)
-   for (i=0; i < 16; ++i)
-      for (j=0; j < count[i]; ++j)
-         h->size[k++] = (stbi_uc) (i+1);
-   h->size[k] = 0;
-
-   // compute actual symbols (from jpeg spec)
-   code = 0;
-   k = 0;
-   for(j=1; j <= 16; ++j) {
-      // compute delta to add to code to compute symbol id
-      h->delta[j] = k - code;
-      if (h->size[k] == j) {
-         while (h->size[k] == j)
-            h->code[k++] = (stbi__uint16) (code++);
-         if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG");
-      }
-      // compute largest code + 1 for this size, preshifted as needed later
-      h->maxcode[j] = code << (16-j);
-      code <<= 1;
-   }
-   h->maxcode[j] = 0xffffffff;
-
-   // build non-spec acceleration table; 255 is flag for not-accelerated
-   memset(h->fast, 255, 1 << FAST_BITS);
-   for (i=0; i < k; ++i) {
-      int s = h->size[i];
-      if (s <= FAST_BITS) {
-         int c = h->code[i] << (FAST_BITS-s);
-         int m = 1 << (FAST_BITS-s);
-         for (j=0; j < m; ++j) {
-            h->fast[c+j] = (stbi_uc) i;
-         }
-      }
-   }
-   return 1;
-}
-
-// build a table that decodes both magnitude and value of small ACs in
-// one go.
-static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h)
-{
-   int i;
-   for (i=0; i < (1 << FAST_BITS); ++i) {
-      stbi_uc fast = h->fast[i];
-      fast_ac[i] = 0;
-      if (fast < 255) {
-         int rs = h->values[fast];
-         int run = (rs >> 4) & 15;
-         int magbits = rs & 15;
-         int len = h->size[fast];
-
-         if (magbits && len + magbits <= FAST_BITS) {
-            // magnitude code followed by receive_extend code
-            int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits);
-            int m = 1 << (magbits - 1);
-            if (k < m) k += (~0U << magbits) + 1;
-            // if the result is small enough, we can fit it in fast_ac table
-            if (k >= -128 && k <= 127)
-               fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits));
-         }
-      }
-   }
-}
-
-static void stbi__grow_buffer_unsafe(stbi__jpeg *j)
-{
-   do {
-      unsigned int b = j->nomore ? 0 : stbi__get8(j->s);
-      if (b == 0xff) {
-         int c = stbi__get8(j->s);
-         while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes
-         if (c != 0) {
-            j->marker = (unsigned char) c;
-            j->nomore = 1;
-            return;
-         }
-      }
-      j->code_buffer |= b << (24 - j->code_bits);
-      j->code_bits += 8;
-   } while (j->code_bits <= 24);
-}
-
-// (1 << n) - 1
-static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
-
-// decode a jpeg huffman value from the bitstream
-stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)
-{
-   unsigned int temp;
-   int c,k;
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-
-   // look at the top FAST_BITS and determine what symbol ID it is,
-   // if the code is <= FAST_BITS
-   c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-   k = h->fast[c];
-   if (k < 255) {
-      int s = h->size[k];
-      if (s > j->code_bits)
-         return -1;
-      j->code_buffer <<= s;
-      j->code_bits -= s;
-      return h->values[k];
-   }
-
-   // naive test is to shift the code_buffer down so k bits are
-   // valid, then test against maxcode. To speed this up, we've
-   // preshifted maxcode left so that it has (16-k) 0s at the
-   // end; in other words, regardless of the number of bits, it
-   // wants to be compared against something shifted to have 16;
-   // that way we don't need to shift inside the loop.
-   temp = j->code_buffer >> 16;
-   for (k=FAST_BITS+1 ; ; ++k)
-      if (temp < h->maxcode[k])
-         break;
-   if (k == 17) {
-      // error! code not found
-      j->code_bits -= 16;
-      return -1;
-   }
-
-   if (k > j->code_bits)
-      return -1;
-
-   // convert the huffman code to the symbol id
-   c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];
-   STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);
-
-   // convert the id to a symbol
-   j->code_bits -= k;
-   j->code_buffer <<= k;
-   return h->values[c];
-}
-
-// bias[n] = (-1<<n) + 1
-static const int stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767};
-
-// combined JPEG 'receive' and JPEG 'extend', since baseline
-// always extends everything it receives.
-stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
-{
-   unsigned int k;
-   int sgn;
-   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
-
-   sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB
-   k = stbi_lrot(j->code_buffer, n);
-   if (n < 0 || n >= (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))) return 0;
-   j->code_buffer = k & ~stbi__bmask[n];
-   k &= stbi__bmask[n];
-   j->code_bits -= n;
-   return k + (stbi__jbias[n] & ~sgn);
-}
-
-// get some unsigned bits
-stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n)
-{
-   unsigned int k;
-   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
-   k = stbi_lrot(j->code_buffer, n);
-   j->code_buffer = k & ~stbi__bmask[n];
-   k &= stbi__bmask[n];
-   j->code_bits -= n;
-   return k;
-}
-
-stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)
-{
-   unsigned int k;
-   if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);
-   k = j->code_buffer;
-   j->code_buffer <<= 1;
-   --j->code_bits;
-   return k & 0x80000000;
-}
-
-// given a value that's at position X in the zigzag stream,
-// where does it appear in the 8x8 matrix coded as row-major?
-static const stbi_uc stbi__jpeg_dezigzag[64+15] =
-{
-    0,  1,  8, 16,  9,  2,  3, 10,
-   17, 24, 32, 25, 18, 11,  4,  5,
-   12, 19, 26, 33, 40, 48, 41, 34,
-   27, 20, 13,  6,  7, 14, 21, 28,
-   35, 42, 49, 56, 57, 50, 43, 36,
-   29, 22, 15, 23, 30, 37, 44, 51,
-   58, 59, 52, 45, 38, 31, 39, 46,
-   53, 60, 61, 54, 47, 55, 62, 63,
-   // let corrupt input sample past end
-   63, 63, 63, 63, 63, 63, 63, 63,
-   63, 63, 63, 63, 63, 63, 63
-};
-
-// decode one 64-entry block--
-static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant)
-{
-   int diff,dc,k;
-   int t;
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-   t = stbi__jpeg_huff_decode(j, hdc);
-   if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-
-   // 0 all the ac values now so we can do it 32-bits at a time
-   memset(data,0,64*sizeof(data[0]));
-
-   diff = t ? stbi__extend_receive(j, t) : 0;
-   dc = j->img_comp[b].dc_pred + diff;
-   j->img_comp[b].dc_pred = dc;
-   data[0] = (short) (dc * dequant[0]);
-
-   // decode AC components, see JPEG spec
-   k = 1;
-   do {
-      unsigned int zig;
-      int c,r,s;
-      if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-      c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-      r = fac[c];
-      if (r) { // fast-AC path
-         k += (r >> 4) & 15; // run
-         s = r & 15; // combined length
-         j->code_buffer <<= s;
-         j->code_bits -= s;
-         // decode into unzigzag'd location
-         zig = stbi__jpeg_dezigzag[k++];
-         data[zig] = (short) ((r >> 8) * dequant[zig]);
-      } else {
-         int rs = stbi__jpeg_huff_decode(j, hac);
-         if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-         s = rs & 15;
-         r = rs >> 4;
-         if (s == 0) {
-            if (rs != 0xf0) break; // end block
-            k += 16;
-         } else {
-            k += r;
-            // decode into unzigzag'd location
-            zig = stbi__jpeg_dezigzag[k++];
-            data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]);
-         }
-      }
-   } while (k < 64);
-   return 1;
-}
-
-static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b)
-{
-   int diff,dc;
-   int t;
-   if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-
-   if (j->succ_high == 0) {
-      // first scan for DC coefficient, must be first
-      memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
-      t = stbi__jpeg_huff_decode(j, hdc);
-      if (t == -1) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-      diff = t ? stbi__extend_receive(j, t) : 0;
-
-      dc = j->img_comp[b].dc_pred + diff;
-      j->img_comp[b].dc_pred = dc;
-      data[0] = (short) (dc << j->succ_low);
-   } else {
-      // refinement scan for DC coefficient
-      if (stbi__jpeg_get_bit(j))
-         data[0] += (short) (1 << j->succ_low);
-   }
-   return 1;
-}
-
-// @OPTIMIZE: store non-zigzagged during the decode passes,
-// and only de-zigzag when dequantizing
-static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac)
-{
-   int k;
-   if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-
-   if (j->succ_high == 0) {
-      int shift = j->succ_low;
-
-      if (j->eob_run) {
-         --j->eob_run;
-         return 1;
-      }
-
-      k = j->spec_start;
-      do {
-         unsigned int zig;
-         int c,r,s;
-         if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-         c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-         r = fac[c];
-         if (r) { // fast-AC path
-            k += (r >> 4) & 15; // run
-            s = r & 15; // combined length
-            j->code_buffer <<= s;
-            j->code_bits -= s;
-            zig = stbi__jpeg_dezigzag[k++];
-            data[zig] = (short) ((r >> 8) << shift);
-         } else {
-            int rs = stbi__jpeg_huff_decode(j, hac);
-            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-            s = rs & 15;
-            r = rs >> 4;
-            if (s == 0) {
-               if (r < 15) {
-                  j->eob_run = (1 << r);
-                  if (r)
-                     j->eob_run += stbi__jpeg_get_bits(j, r);
-                  --j->eob_run;
-                  break;
-               }
-               k += 16;
-            } else {
-               k += r;
-               zig = stbi__jpeg_dezigzag[k++];
-               data[zig] = (short) (stbi__extend_receive(j,s) << shift);
-            }
-         }
-      } while (k <= j->spec_end);
-   } else {
-      // refinement scan for these AC coefficients
-
-      short bit = (short) (1 << j->succ_low);
-
-      if (j->eob_run) {
-         --j->eob_run;
-         for (k = j->spec_start; k <= j->spec_end; ++k) {
-            short *p = &data[stbi__jpeg_dezigzag[k]];
-            if (*p != 0)
-               if (stbi__jpeg_get_bit(j))
-                  if ((*p & bit)==0) {
-                     if (*p > 0)
-                        *p += bit;
-                     else
-                        *p -= bit;
-                  }
-         }
-      } else {
-         k = j->spec_start;
-         do {
-            int r,s;
-            int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh
-            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-            s = rs & 15;
-            r = rs >> 4;
-            if (s == 0) {
-               if (r < 15) {
-                  j->eob_run = (1 << r) - 1;
-                  if (r)
-                     j->eob_run += stbi__jpeg_get_bits(j, r);
-                  r = 64; // force end of block
-               } else {
-                  // r=15 s=0 should write 16 0s, so we just do
-                  // a run of 15 0s and then write s (which is 0),
-                  // so we don't have to do anything special here
-               }
-            } else {
-               if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG");
-               // sign bit
-               if (stbi__jpeg_get_bit(j))
-                  s = bit;
-               else
-                  s = -bit;
-            }
-
-            // advance by r
-            while (k <= j->spec_end) {
-               short *p = &data[stbi__jpeg_dezigzag[k++]];
-               if (*p != 0) {
-                  if (stbi__jpeg_get_bit(j))
-                     if ((*p & bit)==0) {
-                        if (*p > 0)
-                           *p += bit;
-                        else
-                           *p -= bit;
-                     }
-               } else {
-                  if (r == 0) {
-                     *p = (short) s;
-                     break;
-                  }
-                  --r;
-               }
-            }
-         } while (k <= j->spec_end);
-      }
-   }
-   return 1;
-}
-
-// take a -128..127 value and stbi__clamp it and convert to 0..255
-stbi_inline static stbi_uc stbi__clamp(int x)
-{
-   // trick to use a single test to catch both cases
-   if ((unsigned int) x > 255) {
-      if (x < 0) return 0;
-      if (x > 255) return 255;
-   }
-   return (stbi_uc) x;
-}
-
-#define stbi__f2f(x)  ((int) (((x) * 4096 + 0.5)))
-#define stbi__fsh(x)  ((x) * 4096)
-
-// derived from jidctint -- DCT_ISLOW
-#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \
-   int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \
-   p2 = s2;                                    \
-   p3 = s6;                                    \
-   p1 = (p2+p3) * stbi__f2f(0.5411961f);       \
-   t2 = p1 + p3*stbi__f2f(-1.847759065f);      \
-   t3 = p1 + p2*stbi__f2f( 0.765366865f);      \
-   p2 = s0;                                    \
-   p3 = s4;                                    \
-   t0 = stbi__fsh(p2+p3);                      \
-   t1 = stbi__fsh(p2-p3);                      \
-   x0 = t0+t3;                                 \
-   x3 = t0-t3;                                 \
-   x1 = t1+t2;                                 \
-   x2 = t1-t2;                                 \
-   t0 = s7;                                    \
-   t1 = s5;                                    \
-   t2 = s3;                                    \
-   t3 = s1;                                    \
-   p3 = t0+t2;                                 \
-   p4 = t1+t3;                                 \
-   p1 = t0+t3;                                 \
-   p2 = t1+t2;                                 \
-   p5 = (p3+p4)*stbi__f2f( 1.175875602f);      \
-   t0 = t0*stbi__f2f( 0.298631336f);           \
-   t1 = t1*stbi__f2f( 2.053119869f);           \
-   t2 = t2*stbi__f2f( 3.072711026f);           \
-   t3 = t3*stbi__f2f( 1.501321110f);           \
-   p1 = p5 + p1*stbi__f2f(-0.899976223f);      \
-   p2 = p5 + p2*stbi__f2f(-2.562915447f);      \
-   p3 = p3*stbi__f2f(-1.961570560f);           \
-   p4 = p4*stbi__f2f(-0.390180644f);           \
-   t3 += p1+p4;                                \
-   t2 += p2+p3;                                \
-   t1 += p2+p4;                                \
-   t0 += p1+p3;
-
-static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])
-{
-   int i,val[64],*v=val;
-   stbi_uc *o;
-   short *d = data;
-
-   // columns
-   for (i=0; i < 8; ++i,++d, ++v) {
-      // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing
-      if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0
-           && d[40]==0 && d[48]==0 && d[56]==0) {
-         //    no shortcut                 0     seconds
-         //    (1|2|3|4|5|6|7)==0          0     seconds
-         //    all separate               -0.047 seconds
-         //    1 && 2|3 && 4|5 && 6|7:    -0.047 seconds
-         int dcterm = d[0]*4;
-         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;
-      } else {
-         STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56])
-         // constants scaled things up by 1<<12; let's bring them back
-         // down, but keep 2 extra bits of precision
-         x0 += 512; x1 += 512; x2 += 512; x3 += 512;
-         v[ 0] = (x0+t3) >> 10;
-         v[56] = (x0-t3) >> 10;
-         v[ 8] = (x1+t2) >> 10;
-         v[48] = (x1-t2) >> 10;
-         v[16] = (x2+t1) >> 10;
-         v[40] = (x2-t1) >> 10;
-         v[24] = (x3+t0) >> 10;
-         v[32] = (x3-t0) >> 10;
-      }
-   }
-
-   for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) {
-      // no fast case since the first 1D IDCT spread components out
-      STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7])
-      // constants scaled things up by 1<<12, plus we had 1<<2 from first
-      // loop, plus horizontal and vertical each scale by sqrt(8) so together
-      // we've got an extra 1<<3, so 1<<17 total we need to remove.
-      // so we want to round that, which means adding 0.5 * 1<<17,
-      // aka 65536. Also, we'll end up with -128 to 127 that we want
-      // to encode as 0..255 by adding 128, so we'll add that before the shift
-      x0 += 65536 + (128<<17);
-      x1 += 65536 + (128<<17);
-      x2 += 65536 + (128<<17);
-      x3 += 65536 + (128<<17);
-      // tried computing the shifts into temps, or'ing the temps to see
-      // if any were out of range, but that was slower
-      o[0] = stbi__clamp((x0+t3) >> 17);
-      o[7] = stbi__clamp((x0-t3) >> 17);
-      o[1] = stbi__clamp((x1+t2) >> 17);
-      o[6] = stbi__clamp((x1-t2) >> 17);
-      o[2] = stbi__clamp((x2+t1) >> 17);
-      o[5] = stbi__clamp((x2-t1) >> 17);
-      o[3] = stbi__clamp((x3+t0) >> 17);
-      o[4] = stbi__clamp((x3-t0) >> 17);
-   }
-}
-
-#ifdef STBI_SSE2
-// sse2 integer IDCT. not the fastest possible implementation but it
-// produces bit-identical results to the generic C version so it's
-// fully "transparent".
-static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
-{
-   // This is constructed to match our regular (generic) integer IDCT exactly.
-   __m128i row0, row1, row2, row3, row4, row5, row6, row7;
-   __m128i tmp;
-
-   // dot product constant: even elems=x, odd elems=y
-   #define dct_const(x,y)  _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y))
-
-   // out(0) = c0[even]*x + c0[odd]*y   (c0, x, y 16-bit, out 32-bit)
-   // out(1) = c1[even]*x + c1[odd]*y
-   #define dct_rot(out0,out1, x,y,c0,c1) \
-      __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \
-      __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \
-      __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \
-      __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \
-      __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \
-      __m128i out1##_h = _mm_madd_epi16(c0##hi, c1)
-
-   // out = in << 12  (in 16-bit, out 32-bit)
-   #define dct_widen(out, in) \
-      __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \
-      __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4)
-
-   // wide add
-   #define dct_wadd(out, a, b) \
-      __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \
-      __m128i out##_h = _mm_add_epi32(a##_h, b##_h)
-
-   // wide sub
-   #define dct_wsub(out, a, b) \
-      __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \
-      __m128i out##_h = _mm_sub_epi32(a##_h, b##_h)
-
-   // butterfly a/b, add bias, then shift by "s" and pack
-   #define dct_bfly32o(out0, out1, a,b,bias,s) \
-      { \
-         __m128i abiased_l = _mm_add_epi32(a##_l, bias); \
-         __m128i abiased_h = _mm_add_epi32(a##_h, bias); \
-         dct_wadd(sum, abiased, b); \
-         dct_wsub(dif, abiased, b); \
-         out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \
-         out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \
-      }
-
-   // 8-bit interleave step (for transposes)
-   #define dct_interleave8(a, b) \
-      tmp = a; \
-      a = _mm_unpacklo_epi8(a, b); \
-      b = _mm_unpackhi_epi8(tmp, b)
-
-   // 16-bit interleave step (for transposes)
-   #define dct_interleave16(a, b) \
-      tmp = a; \
-      a = _mm_unpacklo_epi16(a, b); \
-      b = _mm_unpackhi_epi16(tmp, b)
-
-   #define dct_pass(bias,shift) \
-      { \
-         /* even part */ \
-         dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \
-         __m128i sum04 = _mm_add_epi16(row0, row4); \
-         __m128i dif04 = _mm_sub_epi16(row0, row4); \
-         dct_widen(t0e, sum04); \
-         dct_widen(t1e, dif04); \
-         dct_wadd(x0, t0e, t3e); \
-         dct_wsub(x3, t0e, t3e); \
-         dct_wadd(x1, t1e, t2e); \
-         dct_wsub(x2, t1e, t2e); \
-         /* odd part */ \
-         dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \
-         dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \
-         __m128i sum17 = _mm_add_epi16(row1, row7); \
-         __m128i sum35 = _mm_add_epi16(row3, row5); \
-         dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \
-         dct_wadd(x4, y0o, y4o); \
-         dct_wadd(x5, y1o, y5o); \
-         dct_wadd(x6, y2o, y5o); \
-         dct_wadd(x7, y3o, y4o); \
-         dct_bfly32o(row0,row7, x0,x7,bias,shift); \
-         dct_bfly32o(row1,row6, x1,x6,bias,shift); \
-         dct_bfly32o(row2,row5, x2,x5,bias,shift); \
-         dct_bfly32o(row3,row4, x3,x4,bias,shift); \
-      }
-
-   __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f));
-   __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f));
-   __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f));
-   __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f));
-   __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f));
-   __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f));
-   __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));
-   __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));
-
-   // rounding biases in column/row passes, see stbi__idct_block for explanation.
-   __m128i bias_0 = _mm_set1_epi32(512);
-   __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17));
-
-   // load
-   row0 = _mm_load_si128((const __m128i *) (data + 0*8));
-   row1 = _mm_load_si128((const __m128i *) (data + 1*8));
-   row2 = _mm_load_si128((const __m128i *) (data + 2*8));
-   row3 = _mm_load_si128((const __m128i *) (data + 3*8));
-   row4 = _mm_load_si128((const __m128i *) (data + 4*8));
-   row5 = _mm_load_si128((const __m128i *) (data + 5*8));
-   row6 = _mm_load_si128((const __m128i *) (data + 6*8));
-   row7 = _mm_load_si128((const __m128i *) (data + 7*8));
-
-   // column pass
-   dct_pass(bias_0, 10);
-
-   {
-      // 16bit 8x8 transpose pass 1
-      dct_interleave16(row0, row4);
-      dct_interleave16(row1, row5);
-      dct_interleave16(row2, row6);
-      dct_interleave16(row3, row7);
-
-      // transpose pass 2
-      dct_interleave16(row0, row2);
-      dct_interleave16(row1, row3);
-      dct_interleave16(row4, row6);
-      dct_interleave16(row5, row7);
-
-      // transpose pass 3
-      dct_interleave16(row0, row1);
-      dct_interleave16(row2, row3);
-      dct_interleave16(row4, row5);
-      dct_interleave16(row6, row7);
-   }
-
-   // row pass
-   dct_pass(bias_1, 17);
-
-   {
-      // pack
-      __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7
-      __m128i p1 = _mm_packus_epi16(row2, row3);
-      __m128i p2 = _mm_packus_epi16(row4, row5);
-      __m128i p3 = _mm_packus_epi16(row6, row7);
-
-      // 8bit 8x8 transpose pass 1
-      dct_interleave8(p0, p2); // a0e0a1e1...
-      dct_interleave8(p1, p3); // c0g0c1g1...
-
-      // transpose pass 2
-      dct_interleave8(p0, p1); // a0c0e0g0...
-      dct_interleave8(p2, p3); // b0d0f0h0...
-
-      // transpose pass 3
-      dct_interleave8(p0, p2); // a0b0c0d0...
-      dct_interleave8(p1, p3); // a4b4c4d4...
-
-      // store
-      _mm_storel_epi64((__m128i *) out, p0); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p2); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p1); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p3); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e));
-   }
-
-#undef dct_const
-#undef dct_rot
-#undef dct_widen
-#undef dct_wadd
-#undef dct_wsub
-#undef dct_bfly32o
-#undef dct_interleave8
-#undef dct_interleave16
-#undef dct_pass
-}
-
-#endif // STBI_SSE2
-
-#ifdef STBI_NEON
-
-// NEON integer IDCT. should produce bit-identical
-// results to the generic C version.
-static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
-{
-   int16x8_t row0, row1, row2, row3, row4, row5, row6, row7;
-
-   int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f));
-   int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f));
-   int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f));
-   int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f));
-   int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f));
-   int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f));
-   int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f));
-   int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f));
-   int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f));
-   int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f));
-   int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f));
-   int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f));
-
-#define dct_long_mul(out, inq, coeff) \
-   int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \
-   int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff)
-
-#define dct_long_mac(out, acc, inq, coeff) \
-   int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \
-   int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff)
-
-#define dct_widen(out, inq) \
-   int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \
-   int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12)
-
-// wide add
-#define dct_wadd(out, a, b) \
-   int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \
-   int32x4_t out##_h = vaddq_s32(a##_h, b##_h)
-
-// wide sub
-#define dct_wsub(out, a, b) \
-   int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \
-   int32x4_t out##_h = vsubq_s32(a##_h, b##_h)
-
-// butterfly a/b, then shift using "shiftop" by "s" and pack
-#define dct_bfly32o(out0,out1, a,b,shiftop,s) \
-   { \
-      dct_wadd(sum, a, b); \
-      dct_wsub(dif, a, b); \
-      out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \
-      out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \
-   }
-
-#define dct_pass(shiftop, shift) \
-   { \
-      /* even part */ \
-      int16x8_t sum26 = vaddq_s16(row2, row6); \
-      dct_long_mul(p1e, sum26, rot0_0); \
-      dct_long_mac(t2e, p1e, row6, rot0_1); \
-      dct_long_mac(t3e, p1e, row2, rot0_2); \
-      int16x8_t sum04 = vaddq_s16(row0, row4); \
-      int16x8_t dif04 = vsubq_s16(row0, row4); \
-      dct_widen(t0e, sum04); \
-      dct_widen(t1e, dif04); \
-      dct_wadd(x0, t0e, t3e); \
-      dct_wsub(x3, t0e, t3e); \
-      dct_wadd(x1, t1e, t2e); \
-      dct_wsub(x2, t1e, t2e); \
-      /* odd part */ \
-      int16x8_t sum15 = vaddq_s16(row1, row5); \
-      int16x8_t sum17 = vaddq_s16(row1, row7); \
-      int16x8_t sum35 = vaddq_s16(row3, row5); \
-      int16x8_t sum37 = vaddq_s16(row3, row7); \
-      int16x8_t sumodd = vaddq_s16(sum17, sum35); \
-      dct_long_mul(p5o, sumodd, rot1_0); \
-      dct_long_mac(p1o, p5o, sum17, rot1_1); \
-      dct_long_mac(p2o, p5o, sum35, rot1_2); \
-      dct_long_mul(p3o, sum37, rot2_0); \
-      dct_long_mul(p4o, sum15, rot2_1); \
-      dct_wadd(sump13o, p1o, p3o); \
-      dct_wadd(sump24o, p2o, p4o); \
-      dct_wadd(sump23o, p2o, p3o); \
-      dct_wadd(sump14o, p1o, p4o); \
-      dct_long_mac(x4, sump13o, row7, rot3_0); \
-      dct_long_mac(x5, sump24o, row5, rot3_1); \
-      dct_long_mac(x6, sump23o, row3, rot3_2); \
-      dct_long_mac(x7, sump14o, row1, rot3_3); \
-      dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \
-      dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \
-      dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \
-      dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \
-   }
-
-   // load
-   row0 = vld1q_s16(data + 0*8);
-   row1 = vld1q_s16(data + 1*8);
-   row2 = vld1q_s16(data + 2*8);
-   row3 = vld1q_s16(data + 3*8);
-   row4 = vld1q_s16(data + 4*8);
-   row5 = vld1q_s16(data + 5*8);
-   row6 = vld1q_s16(data + 6*8);
-   row7 = vld1q_s16(data + 7*8);
-
-   // add DC bias
-   row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0));
-
-   // column pass
-   dct_pass(vrshrn_n_s32, 10);
-
-   // 16bit 8x8 transpose
-   {
-// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively.
-// whether compilers actually get this is another story, sadly.
-#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; }
-#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); }
-#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); }
-
-      // pass 1
-      dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6
-      dct_trn16(row2, row3);
-      dct_trn16(row4, row5);
-      dct_trn16(row6, row7);
-
-      // pass 2
-      dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4
-      dct_trn32(row1, row3);
-      dct_trn32(row4, row6);
-      dct_trn32(row5, row7);
-
-      // pass 3
-      dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0
-      dct_trn64(row1, row5);
-      dct_trn64(row2, row6);
-      dct_trn64(row3, row7);
-
-#undef dct_trn16
-#undef dct_trn32
-#undef dct_trn64
-   }
-
-   // row pass
-   // vrshrn_n_s32 only supports shifts up to 16, we need
-   // 17. so do a non-rounding shift of 16 first then follow
-   // up with a rounding shift by 1.
-   dct_pass(vshrn_n_s32, 16);
-
-   {
-      // pack and round
-      uint8x8_t p0 = vqrshrun_n_s16(row0, 1);
-      uint8x8_t p1 = vqrshrun_n_s16(row1, 1);
-      uint8x8_t p2 = vqrshrun_n_s16(row2, 1);
-      uint8x8_t p3 = vqrshrun_n_s16(row3, 1);
-      uint8x8_t p4 = vqrshrun_n_s16(row4, 1);
-      uint8x8_t p5 = vqrshrun_n_s16(row5, 1);
-      uint8x8_t p6 = vqrshrun_n_s16(row6, 1);
-      uint8x8_t p7 = vqrshrun_n_s16(row7, 1);
-
-      // again, these can translate into one instruction, but often don't.
-#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; }
-#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); }
-#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); }
-
-      // sadly can't use interleaved stores here since we only write
-      // 8 bytes to each scan line!
-
-      // 8x8 8-bit transpose pass 1
-      dct_trn8_8(p0, p1);
-      dct_trn8_8(p2, p3);
-      dct_trn8_8(p4, p5);
-      dct_trn8_8(p6, p7);
-
-      // pass 2
-      dct_trn8_16(p0, p2);
-      dct_trn8_16(p1, p3);
-      dct_trn8_16(p4, p6);
-      dct_trn8_16(p5, p7);
-
-      // pass 3
-      dct_trn8_32(p0, p4);
-      dct_trn8_32(p1, p5);
-      dct_trn8_32(p2, p6);
-      dct_trn8_32(p3, p7);
-
-      // store
-      vst1_u8(out, p0); out += out_stride;
-      vst1_u8(out, p1); out += out_stride;
-      vst1_u8(out, p2); out += out_stride;
-      vst1_u8(out, p3); out += out_stride;
-      vst1_u8(out, p4); out += out_stride;
-      vst1_u8(out, p5); out += out_stride;
-      vst1_u8(out, p6); out += out_stride;
-      vst1_u8(out, p7);
-
-#undef dct_trn8_8
-#undef dct_trn8_16
-#undef dct_trn8_32
-   }
-
-#undef dct_long_mul
-#undef dct_long_mac
-#undef dct_widen
-#undef dct_wadd
-#undef dct_wsub
-#undef dct_bfly32o
-#undef dct_pass
-}
-
-#endif // STBI_NEON
-
-#define STBI__MARKER_none  0xff
-// if there's a pending marker from the entropy stream, return that
-// otherwise, fetch from the stream and get a marker. if there's no
-// marker, return 0xff, which is never a valid marker value
-static stbi_uc stbi__get_marker(stbi__jpeg *j)
-{
-   stbi_uc x;
-   if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; }
-   x = stbi__get8(j->s);
-   if (x != 0xff) return STBI__MARKER_none;
-   while (x == 0xff)
-      x = stbi__get8(j->s); // consume repeated 0xff fill bytes
-   return x;
-}
-
-// in each scan, we'll have scan_n components, and the order
-// of the components is specified by order[]
-#define STBI__RESTART(x)     ((x) >= 0xd0 && (x) <= 0xd7)
-
-// after a restart interval, stbi__jpeg_reset the entropy decoder and
-// the dc prediction
-static void stbi__jpeg_reset(stbi__jpeg *j)
-{
-   j->code_bits = 0;
-   j->code_buffer = 0;
-   j->nomore = 0;
-   j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0;
-   j->marker = STBI__MARKER_none;
-   j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff;
-   j->eob_run = 0;
-   // no more than 1<<31 MCUs if no restart_interal? that's plenty safe,
-   // since we don't even allow 1<<30 pixels
-}
-
-static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
-{
-   stbi__jpeg_reset(z);
-   if (!z->progressive) {
-      if (z->scan_n == 1) {
-         int i,j;
-         STBI_SIMD_ALIGN(short, data[64]);
-         int n = z->order[0];
-         // non-interleaved data, we just need to process one block at a time,
-         // in trivial scanline order
-         // number of blocks to do just depends on how many actual "pixels" this
-         // component has, independent of interleaved MCU blocking and such
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               int ha = z->img_comp[n].ha;
-               if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
-               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
-               // every data block is an MCU, so countdown the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  // if it's NOT a restart, then just bail, so we get corrupt data
-                  // rather than no data
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      } else { // interleaved
-         int i,j,k,x,y;
-         STBI_SIMD_ALIGN(short, data[64]);
-         for (j=0; j < z->img_mcu_y; ++j) {
-            for (i=0; i < z->img_mcu_x; ++i) {
-               // scan an interleaved mcu... process scan_n components in order
-               for (k=0; k < z->scan_n; ++k) {
-                  int n = z->order[k];
-                  // scan out an mcu's worth of this component; that's just determined
-                  // by the basic H and V specified for the component
-                  for (y=0; y < z->img_comp[n].v; ++y) {
-                     for (x=0; x < z->img_comp[n].h; ++x) {
-                        int x2 = (i*z->img_comp[n].h + x)*8;
-                        int y2 = (j*z->img_comp[n].v + y)*8;
-                        int ha = z->img_comp[n].ha;
-                        if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
-                        z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data);
-                     }
-                  }
-               }
-               // after all interleaved components, that's an interleaved MCU,
-               // so now count down the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      }
-   } else {
-      if (z->scan_n == 1) {
-         int i,j;
-         int n = z->order[0];
-         // non-interleaved data, we just need to process one block at a time,
-         // in trivial scanline order
-         // number of blocks to do just depends on how many actual "pixels" this
-         // component has, independent of interleaved MCU blocking and such
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
-               if (z->spec_start == 0) {
-                  if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
-                     return 0;
-               } else {
-                  int ha = z->img_comp[n].ha;
-                  if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha]))
-                     return 0;
-               }
-               // every data block is an MCU, so countdown the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      } else { // interleaved
-         int i,j,k,x,y;
-         for (j=0; j < z->img_mcu_y; ++j) {
-            for (i=0; i < z->img_mcu_x; ++i) {
-               // scan an interleaved mcu... process scan_n components in order
-               for (k=0; k < z->scan_n; ++k) {
-                  int n = z->order[k];
-                  // scan out an mcu's worth of this component; that's just determined
-                  // by the basic H and V specified for the component
-                  for (y=0; y < z->img_comp[n].v; ++y) {
-                     for (x=0; x < z->img_comp[n].h; ++x) {
-                        int x2 = (i*z->img_comp[n].h + x);
-                        int y2 = (j*z->img_comp[n].v + y);
-                        short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w);
-                        if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
-                           return 0;
-                     }
-                  }
-               }
-               // after all interleaved components, that's an interleaved MCU,
-               // so now count down the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      }
-   }
-}
-
-static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)
-{
-   int i;
-   for (i=0; i < 64; ++i)
-      data[i] *= dequant[i];
-}
-
-static void stbi__jpeg_finish(stbi__jpeg *z)
-{
-   if (z->progressive) {
-      // dequantize and idct the data
-      int i,j,n;
-      for (n=0; n < z->s->img_n; ++n) {
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
-               stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]);
-               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
-            }
-         }
-      }
-   }
-}
-
-static int stbi__process_marker(stbi__jpeg *z, int m)
-{
-   int L;
-   switch (m) {
-      case STBI__MARKER_none: // no marker found
-         return stbi__err("expected marker","Corrupt JPEG");
-
-      case 0xDD: // DRI - specify restart interval
-         if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG");
-         z->restart_interval = stbi__get16be(z->s);
-         return 1;
-
-      case 0xDB: // DQT - define quantization table
-         L = stbi__get16be(z->s)-2;
-         while (L > 0) {
-            int q = stbi__get8(z->s);
-            int p = q >> 4, sixteen = (p != 0);
-            int t = q & 15,i;
-            if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");
-            if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
-
-            for (i=0; i < 64; ++i)
-               z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s));
-            L -= (sixteen ? 129 : 65);
-         }
-         return L==0;
-
-      case 0xC4: // DHT - define huffman table
-         L = stbi__get16be(z->s)-2;
-         while (L > 0) {
-            stbi_uc *v;
-            int sizes[16],i,n=0;
-            int q = stbi__get8(z->s);
-            int tc = q >> 4;
-            int th = q & 15;
-            if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG");
-            for (i=0; i < 16; ++i) {
-               sizes[i] = stbi__get8(z->s);
-               n += sizes[i];
-            }
-            L -= 17;
-            if (tc == 0) {
-               if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
-               v = z->huff_dc[th].values;
-            } else {
-               if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0;
-               v = z->huff_ac[th].values;
-            }
-            for (i=0; i < n; ++i)
-               v[i] = stbi__get8(z->s);
-            if (tc != 0)
-               stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th);
-            L -= n;
-         }
-         return L==0;
-   }
-
-   // check for comment block or APP blocks
-   if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) {
-      L = stbi__get16be(z->s);
-      if (L < 2) {
-         if (m == 0xFE)
-            return stbi__err("bad COM len","Corrupt JPEG");
-         else
-            return stbi__err("bad APP len","Corrupt JPEG");
-      }
-      L -= 2;
-
-      if (m == 0xE0 && L >= 5) { // JFIF APP0 segment
-         static const unsigned char tag[5] = {'J','F','I','F','\0'};
-         int ok = 1;
-         int i;
-         for (i=0; i < 5; ++i)
-            if (stbi__get8(z->s) != tag[i])
-               ok = 0;
-         L -= 5;
-         if (ok)
-            z->jfif = 1;
-      } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment
-         static const unsigned char tag[6] = {'A','d','o','b','e','\0'};
-         int ok = 1;
-         int i;
-         for (i=0; i < 6; ++i)
-            if (stbi__get8(z->s) != tag[i])
-               ok = 0;
-         L -= 6;
-         if (ok) {
-            stbi__get8(z->s); // version
-            stbi__get16be(z->s); // flags0
-            stbi__get16be(z->s); // flags1
-            z->app14_color_transform = stbi__get8(z->s); // color transform
-            L -= 6;
-         }
-      }
-
-      stbi__skip(z->s, L);
-      return 1;
-   }
-
-   return stbi__err("unknown marker","Corrupt JPEG");
-}
-
-// after we see SOS
-static int stbi__process_scan_header(stbi__jpeg *z)
-{
-   int i;
-   int Ls = stbi__get16be(z->s);
-   z->scan_n = stbi__get8(z->s);
-   if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG");
-   if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG");
-   for (i=0; i < z->scan_n; ++i) {
-      int id = stbi__get8(z->s), which;
-      int q = stbi__get8(z->s);
-      for (which = 0; which < z->s->img_n; ++which)
-         if (z->img_comp[which].id == id)
-            break;
-      if (which == z->s->img_n) return 0; // no match
-      z->img_comp[which].hd = q >> 4;   if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG");
-      z->img_comp[which].ha = q & 15;   if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG");
-      z->order[i] = which;
-   }
-
-   {
-      int aa;
-      z->spec_start = stbi__get8(z->s);
-      z->spec_end   = stbi__get8(z->s); // should be 63, but might be 0
-      aa = stbi__get8(z->s);
-      z->succ_high = (aa >> 4);
-      z->succ_low  = (aa & 15);
-      if (z->progressive) {
-         if (z->spec_start > 63 || z->spec_end > 63  || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13)
-            return stbi__err("bad SOS", "Corrupt JPEG");
-      } else {
-         if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG");
-         if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG");
-         z->spec_end = 63;
-      }
-   }
-
-   return 1;
-}
-
-static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why)
-{
-   int i;
-   for (i=0; i < ncomp; ++i) {
-      if (z->img_comp[i].raw_data) {
-         STBI_FREE(z->img_comp[i].raw_data);
-         z->img_comp[i].raw_data = NULL;
-         z->img_comp[i].data = NULL;
-      }
-      if (z->img_comp[i].raw_coeff) {
-         STBI_FREE(z->img_comp[i].raw_coeff);
-         z->img_comp[i].raw_coeff = 0;
-         z->img_comp[i].coeff = 0;
-      }
-      if (z->img_comp[i].linebuf) {
-         STBI_FREE(z->img_comp[i].linebuf);
-         z->img_comp[i].linebuf = NULL;
-      }
-   }
-   return why;
-}
-
-static int stbi__process_frame_header(stbi__jpeg *z, int scan)
-{
-   stbi__context *s = z->s;
-   int Lf,p,i,q, h_max=1,v_max=1,c;
-   Lf = stbi__get16be(s);         if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG
-   p  = stbi__get8(s);            if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline
-   s->img_y = stbi__get16be(s);   if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG
-   s->img_x = stbi__get16be(s);   if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   c = stbi__get8(s);
-   if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG");
-   s->img_n = c;
-   for (i=0; i < c; ++i) {
-      z->img_comp[i].data = NULL;
-      z->img_comp[i].linebuf = NULL;
-   }
-
-   if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG");
-
-   z->rgb = 0;
-   for (i=0; i < s->img_n; ++i) {
-      static const unsigned char rgb[3] = { 'R', 'G', 'B' };
-      z->img_comp[i].id = stbi__get8(s);
-      if (s->img_n == 3 && z->img_comp[i].id == rgb[i])
-         ++z->rgb;
-      q = stbi__get8(s);
-      z->img_comp[i].h = (q >> 4);  if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG");
-      z->img_comp[i].v = q & 15;    if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG");
-      z->img_comp[i].tq = stbi__get8(s);  if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG");
-   }
-
-   if (scan != STBI__SCAN_load) return 1;
-
-   if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode");
-
-   for (i=0; i < s->img_n; ++i) {
-      if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;
-      if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
-   }
-
-   // compute interleaved mcu info
-   z->img_h_max = h_max;
-   z->img_v_max = v_max;
-   z->img_mcu_w = h_max * 8;
-   z->img_mcu_h = v_max * 8;
-   // these sizes can't be more than 17 bits
-   z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w;
-   z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h;
-
-   for (i=0; i < s->img_n; ++i) {
-      // number of effective pixels (e.g. for non-interleaved MCU)
-      z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;
-      z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;
-      // to simplify generation, we'll allocate enough memory to decode
-      // the bogus oversized data from using interleaved MCUs and their
-      // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't
-      // discard the extra data until colorspace conversion
-      //
-      // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier)
-      // so these muls can't overflow with 32-bit ints (which we require)
-      z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
-      z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;
-      z->img_comp[i].coeff = 0;
-      z->img_comp[i].raw_coeff = 0;
-      z->img_comp[i].linebuf = NULL;
-      z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);
-      if (z->img_comp[i].raw_data == NULL)
-         return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
-      // align blocks for idct using mmx/sse
-      z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
-      if (z->progressive) {
-         // w2, h2 are multiples of 8 (see above)
-         z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8;
-         z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8;
-         z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15);
-         if (z->img_comp[i].raw_coeff == NULL)
-            return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
-         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);
-      }
-   }
-
-   return 1;
-}
-
-// use comparisons since in some cases we handle more than one case (e.g. SOF)
-#define stbi__DNL(x)         ((x) == 0xdc)
-#define stbi__SOI(x)         ((x) == 0xd8)
-#define stbi__EOI(x)         ((x) == 0xd9)
-#define stbi__SOF(x)         ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2)
-#define stbi__SOS(x)         ((x) == 0xda)
-
-#define stbi__SOF_progressive(x)   ((x) == 0xc2)
-
-static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)
-{
-   int m;
-   z->jfif = 0;
-   z->app14_color_transform = -1; // valid values are 0,1,2
-   z->marker = STBI__MARKER_none; // initialize cached marker to empty
-   m = stbi__get_marker(z);
-   if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG");
-   if (scan == STBI__SCAN_type) return 1;
-   m = stbi__get_marker(z);
-   while (!stbi__SOF(m)) {
-      if (!stbi__process_marker(z,m)) return 0;
-      m = stbi__get_marker(z);
-      while (m == STBI__MARKER_none) {
-         // some files have extra padding after their blocks, so ok, we'll scan
-         if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG");
-         m = stbi__get_marker(z);
-      }
-   }
-   z->progressive = stbi__SOF_progressive(m);
-   if (!stbi__process_frame_header(z, scan)) return 0;
-   return 1;
-}
-
-// decode image to YCbCr format
-static int stbi__decode_jpeg_image(stbi__jpeg *j)
-{
-   int m;
-   for (m = 0; m < 4; m++) {
-      j->img_comp[m].raw_data = NULL;
-      j->img_comp[m].raw_coeff = NULL;
-   }
-   j->restart_interval = 0;
-   if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;
-   m = stbi__get_marker(j);
-   while (!stbi__EOI(m)) {
-      if (stbi__SOS(m)) {
-         if (!stbi__process_scan_header(j)) return 0;
-         if (!stbi__parse_entropy_coded_data(j)) return 0;
-         if (j->marker == STBI__MARKER_none ) {
-            // handle 0s at the end of image data from IP Kamera 9060
-            while (!stbi__at_eof(j->s)) {
-               int x = stbi__get8(j->s);
-               if (x == 255) {
-                  j->marker = stbi__get8(j->s);
-                  break;
-               }
-            }
-            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
-         }
-      } else if (stbi__DNL(m)) {
-         int Ld = stbi__get16be(j->s);
-         stbi__uint32 NL = stbi__get16be(j->s);
-         if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
-         if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
-      } else {
-         if (!stbi__process_marker(j, m)) return 0;
-      }
-      m = stbi__get_marker(j);
-   }
-   if (j->progressive)
-      stbi__jpeg_finish(j);
-   return 1;
-}
-
-// static jfif-centered resampling (across block boundaries)
-
-typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1,
-                                    int w, int hs);
-
-#define stbi__div4(x) ((stbi_uc) ((x) >> 2))
-
-static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   STBI_NOTUSED(out);
-   STBI_NOTUSED(in_far);
-   STBI_NOTUSED(w);
-   STBI_NOTUSED(hs);
-   return in_near;
-}
-
-static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate two samples vertically for every one in input
-   int i;
-   STBI_NOTUSED(hs);
-   for (i=0; i < w; ++i)
-      out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2);
-   return out;
-}
-
-static stbi_uc*  stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate two samples horizontally for every one in input
-   int i;
-   stbi_uc *input = in_near;
-
-   if (w == 1) {
-      // if only one sample, can't do any interpolation
-      out[0] = out[1] = input[0];
-      return out;
-   }
-
-   out[0] = input[0];
-   out[1] = stbi__div4(input[0]*3 + input[1] + 2);
-   for (i=1; i < w-1; ++i) {
-      int n = 3*input[i]+2;
-      out[i*2+0] = stbi__div4(n+input[i-1]);
-      out[i*2+1] = stbi__div4(n+input[i+1]);
-   }
-   out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2);
-   out[i*2+1] = input[w-1];
-
-   STBI_NOTUSED(in_far);
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-
-#define stbi__div16(x) ((stbi_uc) ((x) >> 4))
-
-static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate 2x2 samples for every one in input
-   int i,t0,t1;
-   if (w == 1) {
-      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
-      return out;
-   }
-
-   t1 = 3*in_near[0] + in_far[0];
-   out[0] = stbi__div4(t1+2);
-   for (i=1; i < w; ++i) {
-      t0 = t1;
-      t1 = 3*in_near[i]+in_far[i];
-      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
-      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
-   }
-   out[w*2-1] = stbi__div4(t1+2);
-
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-
-#if defined(STBI_SSE2) || defined(STBI_NEON)
-static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate 2x2 samples for every one in input
-   int i=0,t0,t1;
-
-   if (w == 1) {
-      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
-      return out;
-   }
-
-   t1 = 3*in_near[0] + in_far[0];
-   // process groups of 8 pixels for as long as we can.
-   // note we can't handle the last pixel in a row in this loop
-   // because we need to handle the filter boundary conditions.
-   for (; i < ((w-1) & ~7); i += 8) {
-#if defined(STBI_SSE2)
-      // load and perform the vertical filtering pass
-      // this uses 3*x + y = 4*x + (y - x)
-      __m128i zero  = _mm_setzero_si128();
-      __m128i farb  = _mm_loadl_epi64((__m128i *) (in_far + i));
-      __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i));
-      __m128i farw  = _mm_unpacklo_epi8(farb, zero);
-      __m128i nearw = _mm_unpacklo_epi8(nearb, zero);
-      __m128i diff  = _mm_sub_epi16(farw, nearw);
-      __m128i nears = _mm_slli_epi16(nearw, 2);
-      __m128i curr  = _mm_add_epi16(nears, diff); // current row
-
-      // horizontal filter works the same based on shifted vers of current
-      // row. "prev" is current row shifted right by 1 pixel; we need to
-      // insert the previous pixel value (from t1).
-      // "next" is current row shifted left by 1 pixel, with first pixel
-      // of next block of 8 pixels added in.
-      __m128i prv0 = _mm_slli_si128(curr, 2);
-      __m128i nxt0 = _mm_srli_si128(curr, 2);
-      __m128i prev = _mm_insert_epi16(prv0, t1, 0);
-      __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7);
-
-      // horizontal filter, polyphase implementation since it's convenient:
-      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
-      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
-      // note the shared term.
-      __m128i bias  = _mm_set1_epi16(8);
-      __m128i curs = _mm_slli_epi16(curr, 2);
-      __m128i prvd = _mm_sub_epi16(prev, curr);
-      __m128i nxtd = _mm_sub_epi16(next, curr);
-      __m128i curb = _mm_add_epi16(curs, bias);
-      __m128i even = _mm_add_epi16(prvd, curb);
-      __m128i odd  = _mm_add_epi16(nxtd, curb);
-
-      // interleave even and odd pixels, then undo scaling.
-      __m128i int0 = _mm_unpacklo_epi16(even, odd);
-      __m128i int1 = _mm_unpackhi_epi16(even, odd);
-      __m128i de0  = _mm_srli_epi16(int0, 4);
-      __m128i de1  = _mm_srli_epi16(int1, 4);
-
-      // pack and write output
-      __m128i outv = _mm_packus_epi16(de0, de1);
-      _mm_storeu_si128((__m128i *) (out + i*2), outv);
-#elif defined(STBI_NEON)
-      // load and perform the vertical filtering pass
-      // this uses 3*x + y = 4*x + (y - x)
-      uint8x8_t farb  = vld1_u8(in_far + i);
-      uint8x8_t nearb = vld1_u8(in_near + i);
-      int16x8_t diff  = vreinterpretq_s16_u16(vsubl_u8(farb, nearb));
-      int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2));
-      int16x8_t curr  = vaddq_s16(nears, diff); // current row
-
-      // horizontal filter works the same based on shifted vers of current
-      // row. "prev" is current row shifted right by 1 pixel; we need to
-      // insert the previous pixel value (from t1).
-      // "next" is current row shifted left by 1 pixel, with first pixel
-      // of next block of 8 pixels added in.
-      int16x8_t prv0 = vextq_s16(curr, curr, 7);
-      int16x8_t nxt0 = vextq_s16(curr, curr, 1);
-      int16x8_t prev = vsetq_lane_s16(t1, prv0, 0);
-      int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7);
-
-      // horizontal filter, polyphase implementation since it's convenient:
-      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
-      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
-      // note the shared term.
-      int16x8_t curs = vshlq_n_s16(curr, 2);
-      int16x8_t prvd = vsubq_s16(prev, curr);
-      int16x8_t nxtd = vsubq_s16(next, curr);
-      int16x8_t even = vaddq_s16(curs, prvd);
-      int16x8_t odd  = vaddq_s16(curs, nxtd);
-
-      // undo scaling and round, then store with even/odd phases interleaved
-      uint8x8x2_t o;
-      o.val[0] = vqrshrun_n_s16(even, 4);
-      o.val[1] = vqrshrun_n_s16(odd,  4);
-      vst2_u8(out + i*2, o);
-#endif
-
-      // "previous" value for next iter
-      t1 = 3*in_near[i+7] + in_far[i+7];
-   }
-
-   t0 = t1;
-   t1 = 3*in_near[i] + in_far[i];
-   out[i*2] = stbi__div16(3*t1 + t0 + 8);
-
-   for (++i; i < w; ++i) {
-      t0 = t1;
-      t1 = 3*in_near[i]+in_far[i];
-      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
-      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
-   }
-   out[w*2-1] = stbi__div4(t1+2);
-
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-#endif
-
-static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // resample with nearest-neighbor
-   int i,j;
-   STBI_NOTUSED(in_far);
-   for (i=0; i < w; ++i)
-      for (j=0; j < hs; ++j)
-         out[i*hs+j] = in_near[i];
-   return out;
-}
-
-// this is a reduced-precision calculation of YCbCr-to-RGB introduced
-// to make sure the code produces the same results in both SIMD and scalar
-#define stbi__float2fixed(x)  (((int) ((x) * 4096.0f + 0.5f)) << 8)
-static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
-{
-   int i;
-   for (i=0; i < count; ++i) {
-      int y_fixed = (y[i] << 20) + (1<<19); // rounding
-      int r,g,b;
-      int cr = pcr[i] - 128;
-      int cb = pcb[i] - 128;
-      r = y_fixed +  cr* stbi__float2fixed(1.40200f);
-      g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
-      b = y_fixed                                     +   cb* stbi__float2fixed(1.77200f);
-      r >>= 20;
-      g >>= 20;
-      b >>= 20;
-      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
-      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
-      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
-      out[0] = (stbi_uc)r;
-      out[1] = (stbi_uc)g;
-      out[2] = (stbi_uc)b;
-      out[3] = 255;
-      out += step;
-   }
-}
-
-#if defined(STBI_SSE2) || defined(STBI_NEON)
-static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)
-{
-   int i = 0;
-
-#ifdef STBI_SSE2
-   // step == 3 is pretty ugly on the final interleave, and i'm not convinced
-   // it's useful in practice (you wouldn't use it for textures, for example).
-   // so just accelerate step == 4 case.
-   if (step == 4) {
-      // this is a fairly straightforward implementation and not super-optimized.
-      __m128i signflip  = _mm_set1_epi8(-0x80);
-      __m128i cr_const0 = _mm_set1_epi16(   (short) ( 1.40200f*4096.0f+0.5f));
-      __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));
-      __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));
-      __m128i cb_const1 = _mm_set1_epi16(   (short) ( 1.77200f*4096.0f+0.5f));
-      __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);
-      __m128i xw = _mm_set1_epi16(255); // alpha channel
-
-      for (; i+7 < count; i += 8) {
-         // load
-         __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i));
-         __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i));
-         __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i));
-         __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128
-         __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128
-
-         // unpack to short (and left-shift cr, cb by 8)
-         __m128i yw  = _mm_unpacklo_epi8(y_bias, y_bytes);
-         __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased);
-         __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased);
-
-         // color transform
-         __m128i yws = _mm_srli_epi16(yw, 4);
-         __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw);
-         __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw);
-         __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1);
-         __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1);
-         __m128i rws = _mm_add_epi16(cr0, yws);
-         __m128i gwt = _mm_add_epi16(cb0, yws);
-         __m128i bws = _mm_add_epi16(yws, cb1);
-         __m128i gws = _mm_add_epi16(gwt, cr1);
-
-         // descale
-         __m128i rw = _mm_srai_epi16(rws, 4);
-         __m128i bw = _mm_srai_epi16(bws, 4);
-         __m128i gw = _mm_srai_epi16(gws, 4);
-
-         // back to byte, set up for transpose
-         __m128i brb = _mm_packus_epi16(rw, bw);
-         __m128i gxb = _mm_packus_epi16(gw, xw);
-
-         // transpose to interleave channels
-         __m128i t0 = _mm_unpacklo_epi8(brb, gxb);
-         __m128i t1 = _mm_unpackhi_epi8(brb, gxb);
-         __m128i o0 = _mm_unpacklo_epi16(t0, t1);
-         __m128i o1 = _mm_unpackhi_epi16(t0, t1);
-
-         // store
-         _mm_storeu_si128((__m128i *) (out + 0), o0);
-         _mm_storeu_si128((__m128i *) (out + 16), o1);
-         out += 32;
-      }
-   }
-#endif
-
-#ifdef STBI_NEON
-   // in this version, step=3 support would be easy to add. but is there demand?
-   if (step == 4) {
-      // this is a fairly straightforward implementation and not super-optimized.
-      uint8x8_t signflip = vdup_n_u8(0x80);
-      int16x8_t cr_const0 = vdupq_n_s16(   (short) ( 1.40200f*4096.0f+0.5f));
-      int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f));
-      int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f));
-      int16x8_t cb_const1 = vdupq_n_s16(   (short) ( 1.77200f*4096.0f+0.5f));
-
-      for (; i+7 < count; i += 8) {
-         // load
-         uint8x8_t y_bytes  = vld1_u8(y + i);
-         uint8x8_t cr_bytes = vld1_u8(pcr + i);
-         uint8x8_t cb_bytes = vld1_u8(pcb + i);
-         int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip));
-         int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip));
-
-         // expand to s16
-         int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4));
-         int16x8_t crw = vshll_n_s8(cr_biased, 7);
-         int16x8_t cbw = vshll_n_s8(cb_biased, 7);
-
-         // color transform
-         int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0);
-         int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0);
-         int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1);
-         int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1);
-         int16x8_t rws = vaddq_s16(yws, cr0);
-         int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1);
-         int16x8_t bws = vaddq_s16(yws, cb1);
-
-         // undo scaling, round, convert to byte
-         uint8x8x4_t o;
-         o.val[0] = vqrshrun_n_s16(rws, 4);
-         o.val[1] = vqrshrun_n_s16(gws, 4);
-         o.val[2] = vqrshrun_n_s16(bws, 4);
-         o.val[3] = vdup_n_u8(255);
-
-         // store, interleaving r/g/b/a
-         vst4_u8(out, o);
-         out += 8*4;
-      }
-   }
-#endif
-
-   for (; i < count; ++i) {
-      int y_fixed = (y[i] << 20) + (1<<19); // rounding
-      int r,g,b;
-      int cr = pcr[i] - 128;
-      int cb = pcb[i] - 128;
-      r = y_fixed + cr* stbi__float2fixed(1.40200f);
-      g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
-      b = y_fixed                                   +   cb* stbi__float2fixed(1.77200f);
-      r >>= 20;
-      g >>= 20;
-      b >>= 20;
-      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
-      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
-      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
-      out[0] = (stbi_uc)r;
-      out[1] = (stbi_uc)g;
-      out[2] = (stbi_uc)b;
-      out[3] = 255;
-      out += step;
-   }
-}
-#endif
-
-// set up the kernels
-static void stbi__setup_jpeg(stbi__jpeg *j)
-{
-   j->idct_block_kernel = stbi__idct_block;
-   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row;
-   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2;
-
-#ifdef STBI_SSE2
-   if (stbi__sse2_available()) {
-      j->idct_block_kernel = stbi__idct_simd;
-      j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
-      j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
-   }
-#endif
-
-#ifdef STBI_NEON
-   j->idct_block_kernel = stbi__idct_simd;
-   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
-   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
-#endif
-}
-
-// clean up the temporary component buffers
-static void stbi__cleanup_jpeg(stbi__jpeg *j)
-{
-   stbi__free_jpeg_components(j, j->s->img_n, 0);
-}
-
-typedef struct
-{
-   resample_row_func resample;
-   stbi_uc *line0,*line1;
-   int hs,vs;   // expansion factor in each axis
-   int w_lores; // horizontal pixels pre-expansion
-   int ystep;   // how far through vertical expansion we are
-   int ypos;    // which pre-expansion row we're on
-} stbi__resample;
-
-// fast 0..255 * 0..255 => 0..255 rounded multiplication
-static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y)
-{
-   unsigned int t = x*y + 128;
-   return (stbi_uc) ((t + (t >>8)) >> 8);
-}
-
-static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
-{
-   int n, decode_n, is_rgb;
-   z->s->img_n = 0; // make stbi__cleanup_jpeg safe
-
-   // validate req_comp
-   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
-
-   // load a jpeg image from whichever source, but leave in YCbCr format
-   if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; }
-
-   // determine actual number of components to generate
-   n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1;
-
-   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));
-
-   if (z->s->img_n == 3 && n < 3 && !is_rgb)
-      decode_n = 1;
-   else
-      decode_n = z->s->img_n;
-
-   // resample and color-convert
-   {
-      int k;
-      unsigned int i,j;
-      stbi_uc *output;
-      stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL };
-
-      stbi__resample res_comp[4];
-
-      for (k=0; k < decode_n; ++k) {
-         stbi__resample *r = &res_comp[k];
-
-         // allocate line buffer big enough for upsampling off the edges
-         // with upsample factor of 4
-         z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3);
-         if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
-
-         r->hs      = z->img_h_max / z->img_comp[k].h;
-         r->vs      = z->img_v_max / z->img_comp[k].v;
-         r->ystep   = r->vs >> 1;
-         r->w_lores = (z->s->img_x + r->hs-1) / r->hs;
-         r->ypos    = 0;
-         r->line0   = r->line1 = z->img_comp[k].data;
-
-         if      (r->hs == 1 && r->vs == 1) r->resample = resample_row_1;
-         else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2;
-         else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2;
-         else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel;
-         else                               r->resample = stbi__resample_row_generic;
-      }
-
-      // can't error after this so, this is safe
-      output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1);
-      if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
-
-      // now go ahead and resample
-      for (j=0; j < z->s->img_y; ++j) {
-         stbi_uc *out = output + n * z->s->img_x * j;
-         for (k=0; k < decode_n; ++k) {
-            stbi__resample *r = &res_comp[k];
-            int y_bot = r->ystep >= (r->vs >> 1);
-            coutput[k] = r->resample(z->img_comp[k].linebuf,
-                                     y_bot ? r->line1 : r->line0,
-                                     y_bot ? r->line0 : r->line1,
-                                     r->w_lores, r->hs);
-            if (++r->ystep >= r->vs) {
-               r->ystep = 0;
-               r->line0 = r->line1;
-               if (++r->ypos < z->img_comp[k].y)
-                  r->line1 += z->img_comp[k].w2;
-            }
-         }
-         if (n >= 3) {
-            stbi_uc *y = coutput[0];
-            if (z->s->img_n == 3) {
-               if (is_rgb) {
-                  for (i=0; i < z->s->img_x; ++i) {
-                     out[0] = y[i];
-                     out[1] = coutput[1][i];
-                     out[2] = coutput[2][i];
-                     out[3] = 255;
-                     out += n;
-                  }
-               } else {
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-               }
-            } else if (z->s->img_n == 4) {
-               if (z->app14_color_transform == 0) { // CMYK
-                  for (i=0; i < z->s->img_x; ++i) {
-                     stbi_uc m = coutput[3][i];
-                     out[0] = stbi__blinn_8x8(coutput[0][i], m);
-                     out[1] = stbi__blinn_8x8(coutput[1][i], m);
-                     out[2] = stbi__blinn_8x8(coutput[2][i], m);
-                     out[3] = 255;
-                     out += n;
-                  }
-               } else if (z->app14_color_transform == 2) { // YCCK
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-                  for (i=0; i < z->s->img_x; ++i) {
-                     stbi_uc m = coutput[3][i];
-                     out[0] = stbi__blinn_8x8(255 - out[0], m);
-                     out[1] = stbi__blinn_8x8(255 - out[1], m);
-                     out[2] = stbi__blinn_8x8(255 - out[2], m);
-                     out += n;
-                  }
-               } else { // YCbCr + alpha?  Ignore the fourth channel for now
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-               }
-            } else
-               for (i=0; i < z->s->img_x; ++i) {
-                  out[0] = out[1] = out[2] = y[i];
-                  out[3] = 255; // not used if n==3
-                  out += n;
-               }
-         } else {
-            if (is_rgb) {
-               if (n == 1)
-                  for (i=0; i < z->s->img_x; ++i)
-                     *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
-               else {
-                  for (i=0; i < z->s->img_x; ++i, out += 2) {
-                     out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
-                     out[1] = 255;
-                  }
-               }
-            } else if (z->s->img_n == 4 && z->app14_color_transform == 0) {
-               for (i=0; i < z->s->img_x; ++i) {
-                  stbi_uc m = coutput[3][i];
-                  stbi_uc r = stbi__blinn_8x8(coutput[0][i], m);
-                  stbi_uc g = stbi__blinn_8x8(coutput[1][i], m);
-                  stbi_uc b = stbi__blinn_8x8(coutput[2][i], m);
-                  out[0] = stbi__compute_y(r, g, b);
-                  out[1] = 255;
-                  out += n;
-               }
-            } else if (z->s->img_n == 4 && z->app14_color_transform == 2) {
-               for (i=0; i < z->s->img_x; ++i) {
-                  out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]);
-                  out[1] = 255;
-                  out += n;
-               }
-            } else {
-               stbi_uc *y = coutput[0];
-               if (n == 1)
-                  for (i=0; i < z->s->img_x; ++i) out[i] = y[i];
-               else
-                  for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; }
-            }
-         }
-      }
-      stbi__cleanup_jpeg(z);
-      *out_x = z->s->img_x;
-      *out_y = z->s->img_y;
-      if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output
-      return output;
-   }
-}
-
-static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   unsigned char* result;
-   stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
-   STBI_NOTUSED(ri);
-   j->s = s;
-   stbi__setup_jpeg(j);
-   result = load_jpeg_image(j, x,y,comp,req_comp);
-   STBI_FREE(j);
-   return result;
-}
-
-static int stbi__jpeg_test(stbi__context *s)
-{
-   int r;
-   stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
-   j->s = s;
-   stbi__setup_jpeg(j);
-   r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
-   stbi__rewind(s);
-   STBI_FREE(j);
-   return r;
-}
-
-static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp)
-{
-   if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) {
-      stbi__rewind( j->s );
-      return 0;
-   }
-   if (x) *x = j->s->img_x;
-   if (y) *y = j->s->img_y;
-   if (comp) *comp = j->s->img_n >= 3 ? 3 : 1;
-   return 1;
-}
-
-static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int result;
-   stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
-   j->s = s;
-   result = stbi__jpeg_info_raw(j, x, y, comp);
-   STBI_FREE(j);
-   return result;
-}
-#endif
-
-// public domain zlib decode    v0.2  Sean Barrett 2006-11-18
-//    simple implementation
-//      - all input must be provided in an upfront buffer
-//      - all output is written to a single output buffer (can malloc/realloc)
-//    performance
-//      - fast huffman
-
-#ifndef STBI_NO_ZLIB
-
-// fast-way is faster to check than jpeg huffman, but slow way is slower
-#define STBI__ZFAST_BITS  9 // accelerate all cases in default tables
-#define STBI__ZFAST_MASK  ((1 << STBI__ZFAST_BITS) - 1)
-
-// zlib-style huffman encoding
-// (jpegs packs from left, zlib from right, so can't share code)
-typedef struct
-{
-   stbi__uint16 fast[1 << STBI__ZFAST_BITS];
-   stbi__uint16 firstcode[16];
-   int maxcode[17];
-   stbi__uint16 firstsymbol[16];
-   stbi_uc  size[288];
-   stbi__uint16 value[288];
-} stbi__zhuffman;
-
-stbi_inline static int stbi__bitreverse16(int n)
-{
-  n = ((n & 0xAAAA) >>  1) | ((n & 0x5555) << 1);
-  n = ((n & 0xCCCC) >>  2) | ((n & 0x3333) << 2);
-  n = ((n & 0xF0F0) >>  4) | ((n & 0x0F0F) << 4);
-  n = ((n & 0xFF00) >>  8) | ((n & 0x00FF) << 8);
-  return n;
-}
-
-stbi_inline static int stbi__bit_reverse(int v, int bits)
-{
-   STBI_ASSERT(bits <= 16);
-   // to bit reverse n bits, reverse 16 and shift
-   // e.g. 11 bits, bit reverse and shift away 5
-   return stbi__bitreverse16(v) >> (16-bits);
-}
-
-static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num)
-{
-   int i,k=0;
-   int code, next_code[16], sizes[17];
-
-   // DEFLATE spec for generating codes
-   memset(sizes, 0, sizeof(sizes));
-   memset(z->fast, 0, sizeof(z->fast));
-   for (i=0; i < num; ++i)
-      ++sizes[sizelist[i]];
-   sizes[0] = 0;
-   for (i=1; i < 16; ++i)
-      if (sizes[i] > (1 << i))
-         return stbi__err("bad sizes", "Corrupt PNG");
-   code = 0;
-   for (i=1; i < 16; ++i) {
-      next_code[i] = code;
-      z->firstcode[i] = (stbi__uint16) code;
-      z->firstsymbol[i] = (stbi__uint16) k;
-      code = (code + sizes[i]);
-      if (sizes[i])
-         if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG");
-      z->maxcode[i] = code << (16-i); // preshift for inner loop
-      code <<= 1;
-      k += sizes[i];
-   }
-   z->maxcode[16] = 0x10000; // sentinel
-   for (i=0; i < num; ++i) {
-      int s = sizelist[i];
-      if (s) {
-         int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];
-         stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i);
-         z->size [c] = (stbi_uc     ) s;
-         z->value[c] = (stbi__uint16) i;
-         if (s <= STBI__ZFAST_BITS) {
-            int j = stbi__bit_reverse(next_code[s],s);
-            while (j < (1 << STBI__ZFAST_BITS)) {
-               z->fast[j] = fastv;
-               j += (1 << s);
-            }
-         }
-         ++next_code[s];
-      }
-   }
-   return 1;
-}
-
-// zlib-from-memory implementation for PNG reading
-//    because PNG allows splitting the zlib stream arbitrarily,
-//    and it's annoying structurally to have PNG call ZLIB call PNG,
-//    we require PNG read all the IDATs and combine them into a single
-//    memory buffer
-
-typedef struct
-{
-   stbi_uc *zbuffer, *zbuffer_end;
-   int num_bits;
-   stbi__uint32 code_buffer;
-
-   char *zout;
-   char *zout_start;
-   char *zout_end;
-   int   z_expandable;
-
-   stbi__zhuffman z_length, z_distance;
-} stbi__zbuf;
-
-stbi_inline static int stbi__zeof(stbi__zbuf *z)
-{
-   return (z->zbuffer >= z->zbuffer_end);
-}
-
-stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z)
-{
-   return stbi__zeof(z) ? 0 : *z->zbuffer++;
-}
-
-static void stbi__fill_bits(stbi__zbuf *z)
-{
-   do {
-      if (z->code_buffer >= (1U << z->num_bits)) {
-        z->zbuffer = z->zbuffer_end;  /* treat this as EOF so we fail. */
-        return;
-      }
-      z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits;
-      z->num_bits += 8;
-   } while (z->num_bits <= 24);
-}
-
-stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n)
-{
-   unsigned int k;
-   if (z->num_bits < n) stbi__fill_bits(z);
-   k = z->code_buffer & ((1 << n) - 1);
-   z->code_buffer >>= n;
-   z->num_bits -= n;
-   return k;
-}
-
-static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)
-{
-   int b,s,k;
-   // not resolved by fast table, so compute it the slow way
-   // use jpeg approach, which requires MSbits at top
-   k = stbi__bit_reverse(a->code_buffer, 16);
-   for (s=STBI__ZFAST_BITS+1; ; ++s)
-      if (k < z->maxcode[s])
-         break;
-   if (s >= 16) return -1; // invalid code!
-   // code size is s, so:
-   b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
-   if (b >= sizeof (z->size)) return -1; // some data was corrupt somewhere!
-   if (z->size[b] != s) return -1;  // was originally an assert, but report failure instead.
-   a->code_buffer >>= s;
-   a->num_bits -= s;
-   return z->value[b];
-}
-
-stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)
-{
-   int b,s;
-   if (a->num_bits < 16) {
-      if (stbi__zeof(a)) {
-         return -1;   /* report error for unexpected end of data. */
-      }
-      stbi__fill_bits(a);
-   }
-   b = z->fast[a->code_buffer & STBI__ZFAST_MASK];
-   if (b) {
-      s = b >> 9;
-      a->code_buffer >>= s;
-      a->num_bits -= s;
-      return b & 511;
-   }
-   return stbi__zhuffman_decode_slowpath(a, z);
-}
-
-static int stbi__zexpand(stbi__zbuf *z, char *zout, int n)  // need to make room for n bytes
-{
-   char *q;
-   unsigned int cur, limit, old_limit;
-   z->zout = zout;
-   if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG");
-   cur   = (unsigned int) (z->zout - z->zout_start);
-   limit = old_limit = (unsigned) (z->zout_end - z->zout_start);
-   if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory");
-   while (cur + n > limit) {
-      if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory");
-      limit *= 2;
-   }
-   q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);
-   STBI_NOTUSED(old_limit);
-   if (q == NULL) return stbi__err("outofmem", "Out of memory");
-   z->zout_start = q;
-   z->zout       = q + cur;
-   z->zout_end   = q + limit;
-   return 1;
-}
-
-static const int stbi__zlength_base[31] = {
-   3,4,5,6,7,8,9,10,11,13,
-   15,17,19,23,27,31,35,43,51,59,
-   67,83,99,115,131,163,195,227,258,0,0 };
-
-static const int stbi__zlength_extra[31]=
-{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };
-
-static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,
-257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};
-
-static const int stbi__zdist_extra[32] =
-{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-static int stbi__parse_huffman_block(stbi__zbuf *a)
-{
-   char *zout = a->zout;
-   for(;;) {
-      int z = stbi__zhuffman_decode(a, &a->z_length);
-      if (z < 256) {
-         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes
-         if (zout >= a->zout_end) {
-            if (!stbi__zexpand(a, zout, 1)) return 0;
-            zout = a->zout;
-         }
-         *zout++ = (char) z;
-      } else {
-         stbi_uc *p;
-         int len,dist;
-         if (z == 256) {
-            a->zout = zout;
-            return 1;
-         }
-         z -= 257;
-         len = stbi__zlength_base[z];
-         if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);
-         z = stbi__zhuffman_decode(a, &a->z_distance);
-         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG");
-         dist = stbi__zdist_base[z];
-         if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);
-         if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG");
-         if (zout + len > a->zout_end) {
-            if (!stbi__zexpand(a, zout, len)) return 0;
-            zout = a->zout;
-         }
-         p = (stbi_uc *) (zout - dist);
-         if (dist == 1) { // run of one byte; common in images.
-            stbi_uc v = *p;
-            if (len) { do *zout++ = v; while (--len); }
-         } else {
-            if (len) { do *zout++ = *p++; while (--len); }
-         }
-      }
-   }
-}
-
-static int stbi__compute_huffman_codes(stbi__zbuf *a)
-{
-   static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
-   stbi__zhuffman z_codelength;
-   stbi_uc lencodes[286+32+137];//padding for maximum single op
-   stbi_uc codelength_sizes[19];
-   int i,n;
-
-   int hlit  = stbi__zreceive(a,5) + 257;
-   int hdist = stbi__zreceive(a,5) + 1;
-   int hclen = stbi__zreceive(a,4) + 4;
-   int ntot  = hlit + hdist;
-
-   memset(codelength_sizes, 0, sizeof(codelength_sizes));
-   for (i=0; i < hclen; ++i) {
-      int s = stbi__zreceive(a,3);
-      codelength_sizes[length_dezigzag[i]] = (stbi_uc) s;
-   }
-   if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;
-
-   n = 0;
-   while (n < ntot) {
-      int c = stbi__zhuffman_decode(a, &z_codelength);
-      if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG");
-      if (c < 16)
-         lencodes[n++] = (stbi_uc) c;
-      else {
-         stbi_uc fill = 0;
-         if (c == 16) {
-            c = stbi__zreceive(a,2)+3;
-            if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG");
-            fill = lencodes[n-1];
-         } else if (c == 17) {
-            c = stbi__zreceive(a,3)+3;
-         } else if (c == 18) {
-            c = stbi__zreceive(a,7)+11;
-         } else {
-            return stbi__err("bad codelengths", "Corrupt PNG");
-         }
-         if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG");
-         memset(lencodes+n, fill, c);
-         n += c;
-      }
-   }
-   if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG");
-   if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0;
-   if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0;
-   return 1;
-}
-
-static int stbi__parse_uncompressed_block(stbi__zbuf *a)
-{
-   stbi_uc header[4];
-   int len,nlen,k;
-   if (a->num_bits & 7)
-      stbi__zreceive(a, a->num_bits & 7); // discard
-   // drain the bit-packed data into header
-   k = 0;
-   while (a->num_bits > 0) {
-      header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check
-      a->code_buffer >>= 8;
-      a->num_bits -= 8;
-   }
-   if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG");
-   // now fill header the normal way
-   while (k < 4)
-      header[k++] = stbi__zget8(a);
-   len  = header[1] * 256 + header[0];
-   nlen = header[3] * 256 + header[2];
-   if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG");
-   if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG");
-   if (a->zout + len > a->zout_end)
-      if (!stbi__zexpand(a, a->zout, len)) return 0;
-   memcpy(a->zout, a->zbuffer, len);
-   a->zbuffer += len;
-   a->zout += len;
-   return 1;
-}
-
-static int stbi__parse_zlib_header(stbi__zbuf *a)
-{
-   int cmf   = stbi__zget8(a);
-   int cm    = cmf & 15;
-   /* int cinfo = cmf >> 4; */
-   int flg   = stbi__zget8(a);
-   if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
-   if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
-   if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
-   if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
-   // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
-   return 1;
-}
-
-static const stbi_uc stbi__zdefault_length[288] =
-{
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8
-};
-static const stbi_uc stbi__zdefault_distance[32] =
-{
-   5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
-};
-/*
-Init algorithm:
-{
-   int i;   // use <= to match clearly with spec
-   for (i=0; i <= 143; ++i)     stbi__zdefault_length[i]   = 8;
-   for (   ; i <= 255; ++i)     stbi__zdefault_length[i]   = 9;
-   for (   ; i <= 279; ++i)     stbi__zdefault_length[i]   = 7;
-   for (   ; i <= 287; ++i)     stbi__zdefault_length[i]   = 8;
-
-   for (i=0; i <=  31; ++i)     stbi__zdefault_distance[i] = 5;
-}
-*/
-
-static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
-{
-   int final, type;
-   if (parse_header)
-      if (!stbi__parse_zlib_header(a)) return 0;
-   a->num_bits = 0;
-   a->code_buffer = 0;
-   do {
-      final = stbi__zreceive(a,1);
-      type = stbi__zreceive(a,2);
-      if (type == 0) {
-         if (!stbi__parse_uncompressed_block(a)) return 0;
-      } else if (type == 3) {
-         return 0;
-      } else {
-         if (type == 1) {
-            // use fixed code lengths
-            if (!stbi__zbuild_huffman(&a->z_length  , stbi__zdefault_length  , 288)) return 0;
-            if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance,  32)) return 0;
-         } else {
-            if (!stbi__compute_huffman_codes(a)) return 0;
-         }
-         if (!stbi__parse_huffman_block(a)) return 0;
-      }
-   } while (!final);
-   return 1;
-}
-
-static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header)
-{
-   a->zout_start = obuf;
-   a->zout       = obuf;
-   a->zout_end   = obuf + olen;
-   a->z_expandable = exp;
-
-   return stbi__parse_zlib(a, parse_header);
-}
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer + len;
-   if (stbi__do_zlib(&a, p, initial_size, 1, 1)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)
-{
-   return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen);
-}
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer + len;
-   if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
-{
-   stbi__zbuf a;
-   a.zbuffer = (stbi_uc *) ibuffer;
-   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
-   if (stbi__do_zlib(&a, obuffer, olen, 0, 1))
-      return (int) (a.zout - a.zout_start);
-   else
-      return -1;
-}
-
-STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(16384);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer+len;
-   if (stbi__do_zlib(&a, p, 16384, 1, 0)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen)
-{
-   stbi__zbuf a;
-   a.zbuffer = (stbi_uc *) ibuffer;
-   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
-   if (stbi__do_zlib(&a, obuffer, olen, 0, 0))
-      return (int) (a.zout - a.zout_start);
-   else
-      return -1;
-}
-#endif
-
-// public domain "baseline" PNG decoder   v0.10  Sean Barrett 2006-11-18
-//    simple implementation
-//      - only 8-bit samples
-//      - no CRC checking
-//      - allocates lots of intermediate memory
-//        - avoids problem of streaming data between subsystems
-//        - avoids explicit window management
-//    performance
-//      - uses stb_zlib, a PD zlib implementation with fast huffman decoding
-
-#ifndef STBI_NO_PNG
-typedef struct
-{
-   stbi__uint32 length;
-   stbi__uint32 type;
-} stbi__pngchunk;
-
-static stbi__pngchunk stbi__get_chunk_header(stbi__context *s)
-{
-   stbi__pngchunk c;
-   c.length = stbi__get32be(s);
-   c.type   = stbi__get32be(s);
-   return c;
-}
-
-static int stbi__check_png_header(stbi__context *s)
-{
-   static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 };
-   int i;
-   for (i=0; i < 8; ++i)
-      if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG");
-   return 1;
-}
-
-typedef struct
-{
-   stbi__context *s;
-   stbi_uc *idata, *expanded, *out;
-   int depth;
-} stbi__png;
-
-
-enum {
-   STBI__F_none=0,
-   STBI__F_sub=1,
-   STBI__F_up=2,
-   STBI__F_avg=3,
-   STBI__F_paeth=4,
-   // synthetic filters used for first scanline to avoid needing a dummy row of 0s
-   STBI__F_avg_first,
-   STBI__F_paeth_first
-};
-
-static stbi_uc first_row_filter[5] =
-{
-   STBI__F_none,
-   STBI__F_sub,
-   STBI__F_none,
-   STBI__F_avg_first,
-   STBI__F_paeth_first
-};
-
-static int stbi__paeth(int a, int b, int c)
-{
-   int p = a + b - c;
-   int pa = abs(p-a);
-   int pb = abs(p-b);
-   int pc = abs(p-c);
-   if (pa <= pb && pa <= pc) return a;
-   if (pb <= pc) return b;
-   return c;
-}
-
-static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 };
-
-// create the png data from post-deflated data
-static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color)
-{
-   int bytes = (depth == 16? 2 : 1);
-   stbi__context *s = a->s;
-   stbi__uint32 i,j,stride = x*out_n*bytes;
-   stbi__uint32 img_len, img_width_bytes;
-   int k;
-   int img_n = s->img_n; // copy it into a local for later
-
-   int output_bytes = out_n*bytes;
-   int filter_bytes = img_n*bytes;
-   int width = x;
-
-   STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1);
-   a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into
-   if (!a->out) return stbi__err("outofmem", "Out of memory");
-
-   if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG");
-   img_width_bytes = (((img_n * x * depth) + 7) >> 3);
-   img_len = (img_width_bytes + 1) * y;
-
-   // we used to check for exact match between raw_len and img_len on non-interlaced PNGs,
-   // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros),
-   // so just check for raw_len < img_len always.
-   if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG");
-
-   for (j=0; j < y; ++j) {
-      stbi_uc *cur = a->out + stride*j;
-      stbi_uc *prior;
-      int filter = *raw++;
-
-      if (filter > 4)
-         return stbi__err("invalid filter","Corrupt PNG");
-
-      if (depth < 8) {
-         if (img_width_bytes > x) return stbi__err("invalid width","Corrupt PNG");
-         cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place
-         filter_bytes = 1;
-         width = img_width_bytes;
-      }
-      prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above
-
-      // if first row, use special filter that doesn't sample previous row
-      if (j == 0) filter = first_row_filter[filter];
-
-      // handle first byte explicitly
-      for (k=0; k < filter_bytes; ++k) {
-         switch (filter) {
-            case STBI__F_none       : cur[k] = raw[k]; break;
-            case STBI__F_sub        : cur[k] = raw[k]; break;
-            case STBI__F_up         : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
-            case STBI__F_avg        : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break;
-            case STBI__F_paeth      : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break;
-            case STBI__F_avg_first  : cur[k] = raw[k]; break;
-            case STBI__F_paeth_first: cur[k] = raw[k]; break;
-         }
-      }
-
-      if (depth == 8) {
-         if (img_n != out_n)
-            cur[img_n] = 255; // first pixel
-         raw += img_n;
-         cur += out_n;
-         prior += out_n;
-      } else if (depth == 16) {
-         if (img_n != out_n) {
-            cur[filter_bytes]   = 255; // first pixel top byte
-            cur[filter_bytes+1] = 255; // first pixel bottom byte
-         }
-         raw += filter_bytes;
-         cur += output_bytes;
-         prior += output_bytes;
-      } else {
-         raw += 1;
-         cur += 1;
-         prior += 1;
-      }
-
-      // this is a little gross, so that we don't switch per-pixel or per-component
-      if (depth < 8 || img_n == out_n) {
-         int nk = (width - 1)*filter_bytes;
-         #define STBI__CASE(f) \
-             case f:     \
-                for (k=0; k < nk; ++k)
-         switch (filter) {
-            // "none" filter turns into a memcpy here; make that explicit.
-            case STBI__F_none:         memcpy(cur, raw, nk); break;
-            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break;
-            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
-            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break;
-            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break;
-            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break;
-            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break;
-         }
-         #undef STBI__CASE
-         raw += nk;
-      } else {
-         STBI_ASSERT(img_n+1 == out_n);
-         #define STBI__CASE(f) \
-             case f:     \
-                for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \
-                   for (k=0; k < filter_bytes; ++k)
-         switch (filter) {
-            STBI__CASE(STBI__F_none)         { cur[k] = raw[k]; } break;
-            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break;
-            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
-            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break;
-            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break;
-            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break;
-            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break;
-         }
-         #undef STBI__CASE
-
-         // the loop above sets the high byte of the pixels' alpha, but for
-         // 16 bit png files we also need the low byte set. we'll do that here.
-         if (depth == 16) {
-            cur = a->out + stride*j; // start at the beginning of the row again
-            for (i=0; i < x; ++i,cur+=output_bytes) {
-               cur[filter_bytes+1] = 255;
-            }
-         }
-      }
-   }
-
-   // we make a separate pass to expand bits to pixels; for performance,
-   // this could run two scanlines behind the above code, so it won't
-   // intefere with filtering but will still be in the cache.
-   if (depth < 8) {
-      for (j=0; j < y; ++j) {
-         stbi_uc *cur = a->out + stride*j;
-         stbi_uc *in  = a->out + stride*j + x*out_n - img_width_bytes;
-         // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit
-         // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop
-         stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range
-
-         // note that the final byte might overshoot and write more data than desired.
-         // we can allocate enough data that this never writes out of memory, but it
-         // could also overwrite the next scanline. can it overwrite non-empty data
-         // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel.
-         // so we need to explicitly clamp the final ones
-
-         if (depth == 4) {
-            for (k=x*img_n; k >= 2; k-=2, ++in) {
-               *cur++ = scale * ((*in >> 4)       );
-               *cur++ = scale * ((*in     ) & 0x0f);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 4)       );
-         } else if (depth == 2) {
-            for (k=x*img_n; k >= 4; k-=4, ++in) {
-               *cur++ = scale * ((*in >> 6)       );
-               *cur++ = scale * ((*in >> 4) & 0x03);
-               *cur++ = scale * ((*in >> 2) & 0x03);
-               *cur++ = scale * ((*in     ) & 0x03);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 6)       );
-            if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03);
-            if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03);
-         } else if (depth == 1) {
-            for (k=x*img_n; k >= 8; k-=8, ++in) {
-               *cur++ = scale * ((*in >> 7)       );
-               *cur++ = scale * ((*in >> 6) & 0x01);
-               *cur++ = scale * ((*in >> 5) & 0x01);
-               *cur++ = scale * ((*in >> 4) & 0x01);
-               *cur++ = scale * ((*in >> 3) & 0x01);
-               *cur++ = scale * ((*in >> 2) & 0x01);
-               *cur++ = scale * ((*in >> 1) & 0x01);
-               *cur++ = scale * ((*in     ) & 0x01);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 7)       );
-            if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01);
-            if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01);
-            if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01);
-            if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01);
-            if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01);
-            if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01);
-         }
-         if (img_n != out_n) {
-            int q;
-            // insert alpha = 255
-            cur = a->out + stride*j;
-            if (img_n == 1) {
-               for (q=x-1; q >= 0; --q) {
-                  cur[q*2+1] = 255;
-                  cur[q*2+0] = cur[q];
-               }
-            } else {
-               STBI_ASSERT(img_n == 3);
-               for (q=x-1; q >= 0; --q) {
-                  cur[q*4+3] = 255;
-                  cur[q*4+2] = cur[q*3+2];
-                  cur[q*4+1] = cur[q*3+1];
-                  cur[q*4+0] = cur[q*3+0];
-               }
-            }
-         }
-      }
-   } else if (depth == 16) {
-      // force the image data from big-endian to platform-native.
-      // this is done in a separate pass due to the decoding relying
-      // on the data being untouched, but could probably be done
-      // per-line during decode if care is taken.
-      stbi_uc *cur = a->out;
-      stbi__uint16 *cur16 = (stbi__uint16*)cur;
-
-      for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) {
-         *cur16 = (cur[0] << 8) | cur[1];
-      }
-   }
-
-   return 1;
-}
-
-static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced)
-{
-   int bytes = (depth == 16 ? 2 : 1);
-   int out_bytes = out_n * bytes;
-   stbi_uc *final;
-   int p;
-   if (!interlaced)
-      return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color);
-
-   // de-interlacing
-   final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
-   for (p=0; p < 7; ++p) {
-      int xorig[] = { 0,4,0,2,0,1,0 };
-      int yorig[] = { 0,0,4,0,2,0,1 };
-      int xspc[]  = { 8,8,4,4,2,2,1 };
-      int yspc[]  = { 8,8,8,4,4,2,2 };
-      int i,j,x,y;
-      // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1
-      x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p];
-      y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p];
-      if (x && y) {
-         stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;
-         if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) {
-            STBI_FREE(final);
-            return 0;
-         }
-         for (j=0; j < y; ++j) {
-            for (i=0; i < x; ++i) {
-               int out_y = j*yspc[p]+yorig[p];
-               int out_x = i*xspc[p]+xorig[p];
-               memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes,
-                      a->out + (j*x+i)*out_bytes, out_bytes);
-            }
-         }
-         STBI_FREE(a->out);
-         image_data += img_len;
-         image_data_len -= img_len;
-      }
-   }
-   a->out = final;
-
-   return 1;
-}
-
-static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi_uc *p = z->out;
-
-   // compute color-based transparency, assuming we've
-   // already got 255 as the alpha value in the output
-   STBI_ASSERT(out_n == 2 || out_n == 4);
-
-   if (out_n == 2) {
-      for (i=0; i < pixel_count; ++i) {
-         p[1] = (p[0] == tc[0] ? 0 : 255);
-         p += 2;
-      }
-   } else {
-      for (i=0; i < pixel_count; ++i) {
-         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
-            p[3] = 0;
-         p += 4;
-      }
-   }
-   return 1;
-}
-
-static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi__uint16 *p = (stbi__uint16*) z->out;
-
-   // compute color-based transparency, assuming we've
-   // already got 65535 as the alpha value in the output
-   STBI_ASSERT(out_n == 2 || out_n == 4);
-
-   if (out_n == 2) {
-      for (i = 0; i < pixel_count; ++i) {
-         p[1] = (p[0] == tc[0] ? 0 : 65535);
-         p += 2;
-      }
-   } else {
-      for (i = 0; i < pixel_count; ++i) {
-         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
-            p[3] = 0;
-         p += 4;
-      }
-   }
-   return 1;
-}
-
-static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n)
-{
-   stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y;
-   stbi_uc *p, *temp_out, *orig = a->out;
-
-   p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0);
-   if (p == NULL) return stbi__err("outofmem", "Out of memory");
-
-   // between here and free(out) below, exitting would leak
-   temp_out = p;
-
-   if (pal_img_n == 3) {
-      for (i=0; i < pixel_count; ++i) {
-         int n = orig[i]*4;
-         p[0] = palette[n  ];
-         p[1] = palette[n+1];
-         p[2] = palette[n+2];
-         p += 3;
-      }
-   } else {
-      for (i=0; i < pixel_count; ++i) {
-         int n = orig[i]*4;
-         p[0] = palette[n  ];
-         p[1] = palette[n+1];
-         p[2] = palette[n+2];
-         p[3] = palette[n+3];
-         p += 4;
-      }
-   }
-   STBI_FREE(a->out);
-   a->out = temp_out;
-
-   STBI_NOTUSED(len);
-
-   return 1;
-}
-
-static int stbi__unpremultiply_on_load = 0;
-static int stbi__de_iphone_flag = 0;
-
-STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)
-{
-   stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply;
-}
-
-STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
-{
-   stbi__de_iphone_flag = flag_true_if_should_convert;
-}
-
-static void stbi__de_iphone(stbi__png *z)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi_uc *p = z->out;
-
-   if (s->img_out_n == 3) {  // convert bgr to rgb
-      for (i=0; i < pixel_count; ++i) {
-         stbi_uc t = p[0];
-         p[0] = p[2];
-         p[2] = t;
-         p += 3;
-      }
-   } else {
-      STBI_ASSERT(s->img_out_n == 4);
-      if (stbi__unpremultiply_on_load) {
-         // convert bgr to rgb and unpremultiply
-         for (i=0; i < pixel_count; ++i) {
-            stbi_uc a = p[3];
-            stbi_uc t = p[0];
-            if (a) {
-               stbi_uc half = a / 2;
-               p[0] = (p[2] * 255 + half) / a;
-               p[1] = (p[1] * 255 + half) / a;
-               p[2] = ( t   * 255 + half) / a;
-            } else {
-               p[0] = p[2];
-               p[2] = t;
-            }
-            p += 4;
-         }
-      } else {
-         // convert bgr to rgb
-         for (i=0; i < pixel_count; ++i) {
-            stbi_uc t = p[0];
-            p[0] = p[2];
-            p[2] = t;
-            p += 4;
-         }
-      }
-   }
-}
-
-#define STBI__PNG_TYPE(a,b,c,d)  (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d))
-
-static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
-{
-   stbi_uc palette[1024], pal_img_n=0;
-   stbi_uc has_trans=0, tc[3]={0};
-   stbi__uint16 tc16[3];
-   stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
-   int first=1,k,interlace=0, color=0, is_iphone=0;
-   stbi__context *s = z->s;
-
-   z->expanded = NULL;
-   z->idata = NULL;
-   z->out = NULL;
-
-   if (!stbi__check_png_header(s)) return 0;
-
-   if (scan == STBI__SCAN_type) return 1;
-
-   for (;;) {
-      stbi__pngchunk c = stbi__get_chunk_header(s);
-      switch (c.type) {
-         case STBI__PNG_TYPE('C','g','B','I'):
-            is_iphone = 1;
-            stbi__skip(s, c.length);
-            break;
-         case STBI__PNG_TYPE('I','H','D','R'): {
-            int comp,filter;
-            if (!first) return stbi__err("multiple IHDR","Corrupt PNG");
-            first = 0;
-            if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG");
-            s->img_x = stbi__get32be(s);
-            s->img_y = stbi__get32be(s);
-            if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-            if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-            z->depth = stbi__get8(s);  if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16)  return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only");
-            color = stbi__get8(s);  if (color > 6)         return stbi__err("bad ctype","Corrupt PNG");
-            if (color == 3 && z->depth == 16)                  return stbi__err("bad ctype","Corrupt PNG");
-            if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG");
-            comp  = stbi__get8(s);  if (comp) return stbi__err("bad comp method","Corrupt PNG");
-            filter= stbi__get8(s);  if (filter) return stbi__err("bad filter method","Corrupt PNG");
-            interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG");
-            if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG");
-            if (!pal_img_n) {
-               s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);
-               if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");
-               if (scan == STBI__SCAN_header) return 1;
-            } else {
-               // if paletted, then pal_n is our final components, and
-               // img_n is # components to decompress/filter.
-               s->img_n = 1;
-               if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG");
-               // if SCAN_header, have to scan to see if we have a tRNS
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('P','L','T','E'):  {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG");
-            pal_len = c.length / 3;
-            if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG");
-            for (i=0; i < pal_len; ++i) {
-               palette[i*4+0] = stbi__get8(s);
-               palette[i*4+1] = stbi__get8(s);
-               palette[i*4+2] = stbi__get8(s);
-               palette[i*4+3] = 255;
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('t','R','N','S'): {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG");
-            if (pal_img_n) {
-               if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; }
-               if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG");
-               if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG");
-               pal_img_n = 4;
-               for (i=0; i < c.length; ++i)
-                  palette[i*4+3] = stbi__get8(s);
-            } else {
-               if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG");
-               if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG");
-               has_trans = 1;
-               if (z->depth == 16) {
-                  for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
-               } else {
-                  for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
-               }
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('I','D','A','T'): {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG");
-            if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; }
-            if ((int)(ioff + c.length) < (int)ioff) return 0;
-            if (ioff + c.length > idata_limit) {
-               stbi__uint32 idata_limit_old = idata_limit;
-               stbi_uc *p;
-               if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096;
-               while (ioff + c.length > idata_limit)
-                  idata_limit *= 2;
-               STBI_NOTUSED(idata_limit_old);
-               p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory");
-               z->idata = p;
-            }
-            if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG");
-            ioff += c.length;
-            break;
-         }
-
-         case STBI__PNG_TYPE('I','E','N','D'): {
-            stbi__uint32 raw_len, bpl;
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (scan != STBI__SCAN_load) return 1;
-            if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG");
-            // initial guess for decoded data size to avoid unnecessary reallocs
-            bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component
-            raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */;
-            z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone);
-            if (z->expanded == NULL) return 0; // zlib should set error
-            STBI_FREE(z->idata); z->idata = NULL;
-            if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)
-               s->img_out_n = s->img_n+1;
-            else
-               s->img_out_n = s->img_n;
-            if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0;
-            if (has_trans) {
-               if (z->depth == 16) {
-                  if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0;
-               } else {
-                  if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0;
-               }
-            }
-            if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2)
-               stbi__de_iphone(z);
-            if (pal_img_n) {
-               // pal_img_n == 3 or 4
-               s->img_n = pal_img_n; // record the actual colors we had
-               s->img_out_n = pal_img_n;
-               if (req_comp >= 3) s->img_out_n = req_comp;
-               if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n))
-                  return 0;
-            } else if (has_trans) {
-               // non-paletted image with tRNS -> source image has (constant) alpha
-               ++s->img_n;
-            }
-            STBI_FREE(z->expanded); z->expanded = NULL;
-            // end of PNG chunk, read and skip CRC
-            stbi__get32be(s);
-            return 1;
-         }
-
-         default:
-            // if critical, fail
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if ((c.type & (1 << 29)) == 0) {
-               #ifndef STBI_NO_FAILURE_STRINGS
-               // not threadsafe
-               static char invalid_chunk[] = "XXXX PNG chunk not known";
-               invalid_chunk[0] = STBI__BYTECAST(c.type >> 24);
-               invalid_chunk[1] = STBI__BYTECAST(c.type >> 16);
-               invalid_chunk[2] = STBI__BYTECAST(c.type >>  8);
-               invalid_chunk[3] = STBI__BYTECAST(c.type >>  0);
-               #endif
-               return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type");
-            }
-            stbi__skip(s, c.length);
-            break;
-      }
-      // end of PNG chunk, read and skip CRC
-      stbi__get32be(s);
-   }
-}
-
-static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri)
-{
-   void *result=NULL;
-   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
-   if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {
-      if (p->depth <= 8)
-         ri->bits_per_channel = 8;
-      else if (p->depth == 16)
-         ri->bits_per_channel = 16;
-      else
-         return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth");
-      result = p->out;
-      p->out = NULL;
-      if (req_comp && req_comp != p->s->img_out_n) {
-         if (ri->bits_per_channel == 8)
-            result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
-         else
-            result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
-         p->s->img_out_n = req_comp;
-         if (result == NULL) return result;
-      }
-      *x = p->s->img_x;
-      *y = p->s->img_y;
-      if (n) *n = p->s->img_n;
-   }
-   STBI_FREE(p->out);      p->out      = NULL;
-   STBI_FREE(p->expanded); p->expanded = NULL;
-   STBI_FREE(p->idata);    p->idata    = NULL;
-
-   return result;
-}
-
-static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi__png p;
-   p.s = s;
-   return stbi__do_png(&p, x,y,comp,req_comp, ri);
-}
-
-static int stbi__png_test(stbi__context *s)
-{
-   int r;
-   r = stbi__check_png_header(s);
-   stbi__rewind(s);
-   return r;
-}
-
-static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp)
-{
-   if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) {
-      stbi__rewind( p->s );
-      return 0;
-   }
-   if (x) *x = p->s->img_x;
-   if (y) *y = p->s->img_y;
-   if (comp) *comp = p->s->img_n;
-   return 1;
-}
-
-static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   stbi__png p;
-   p.s = s;
-   return stbi__png_info_raw(&p, x, y, comp);
-}
-
-static int stbi__png_is16(stbi__context *s)
-{
-   stbi__png p;
-   p.s = s;
-   if (!stbi__png_info_raw(&p, NULL, NULL, NULL))
-          return 0;
-   if (p.depth != 16) {
-      stbi__rewind(p.s);
-      return 0;
-   }
-   return 1;
-}
-#endif
-
-// Microsoft/Windows BMP image
-
-#ifndef STBI_NO_BMP
-static int stbi__bmp_test_raw(stbi__context *s)
-{
-   int r;
-   int sz;
-   if (stbi__get8(s) != 'B') return 0;
-   if (stbi__get8(s) != 'M') return 0;
-   stbi__get32le(s); // discard filesize
-   stbi__get16le(s); // discard reserved
-   stbi__get16le(s); // discard reserved
-   stbi__get32le(s); // discard data offset
-   sz = stbi__get32le(s);
-   r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124);
-   return r;
-}
-
-static int stbi__bmp_test(stbi__context *s)
-{
-   int r = stbi__bmp_test_raw(s);
-   stbi__rewind(s);
-   return r;
-}
-
-
-// returns 0..31 for the highest set bit
-static int stbi__high_bit(unsigned int z)
-{
-   int n=0;
-   if (z == 0) return -1;
-   if (z >= 0x10000) { n += 16; z >>= 16; }
-   if (z >= 0x00100) { n +=  8; z >>=  8; }
-   if (z >= 0x00010) { n +=  4; z >>=  4; }
-   if (z >= 0x00004) { n +=  2; z >>=  2; }
-   if (z >= 0x00002) { n +=  1;/* >>=  1;*/ }
-   return n;
-}
-
-static int stbi__bitcount(unsigned int a)
-{
-   a = (a & 0x55555555) + ((a >>  1) & 0x55555555); // max 2
-   a = (a & 0x33333333) + ((a >>  2) & 0x33333333); // max 4
-   a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits
-   a = (a + (a >> 8)); // max 16 per 8 bits
-   a = (a + (a >> 16)); // max 32 per 8 bits
-   return a & 0xff;
-}
-
-// extract an arbitrarily-aligned N-bit value (N=bits)
-// from v, and then make it 8-bits long and fractionally
-// extend it to full full range.
-static int stbi__shiftsigned(unsigned int v, int shift, int bits)
-{
-   static unsigned int mul_table[9] = {
-      0,
-      0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/,
-      0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/,
-   };
-   static unsigned int shift_table[9] = {
-      0, 0,0,1,0,2,4,6,0,
-   };
-   if (shift < 0)
-      v <<= -shift;
-   else
-      v >>= shift;
-   STBI_ASSERT(v < 256);
-   v >>= (8-bits);
-   STBI_ASSERT(bits >= 0 && bits <= 8);
-   return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits];
-}
-
-typedef struct
-{
-   int bpp, offset, hsz;
-   unsigned int mr,mg,mb,ma, all_a;
-   int extra_read;
-} stbi__bmp_data;
-
-static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
-{
-   int hsz;
-   if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP");
-   stbi__get32le(s); // discard filesize
-   stbi__get16le(s); // discard reserved
-   stbi__get16le(s); // discard reserved
-   info->offset = stbi__get32le(s);
-   info->hsz = hsz = stbi__get32le(s);
-   info->mr = info->mg = info->mb = info->ma = 0;
-   info->extra_read = 14;
-
-   if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP");
-
-   if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown");
-   if (hsz == 12) {
-      s->img_x = stbi__get16le(s);
-      s->img_y = stbi__get16le(s);
-   } else {
-      s->img_x = stbi__get32le(s);
-      s->img_y = stbi__get32le(s);
-   }
-   if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP");
-   info->bpp = stbi__get16le(s);
-   if (hsz != 12) {
-      int compress = stbi__get32le(s);
-      if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
-      stbi__get32le(s); // discard sizeof
-      stbi__get32le(s); // discard hres
-      stbi__get32le(s); // discard vres
-      stbi__get32le(s); // discard colorsused
-      stbi__get32le(s); // discard max important
-      if (hsz == 40 || hsz == 56) {
-         if (hsz == 56) {
-            stbi__get32le(s);
-            stbi__get32le(s);
-            stbi__get32le(s);
-            stbi__get32le(s);
-         }
-         if (info->bpp == 16 || info->bpp == 32) {
-            if (compress == 0) {
-               if (info->bpp == 32) {
-                  info->mr = 0xffu << 16;
-                  info->mg = 0xffu <<  8;
-                  info->mb = 0xffu <<  0;
-                  info->ma = 0xffu << 24;
-                  info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
-               } else {
-                  info->mr = 31u << 10;
-                  info->mg = 31u <<  5;
-                  info->mb = 31u <<  0;
-               }
-            } else if (compress == 3) {
-               info->mr = stbi__get32le(s);
-               info->mg = stbi__get32le(s);
-               info->mb = stbi__get32le(s);
-               info->extra_read += 12;
-               // not documented, but generated by photoshop and handled by mspaint
-               if (info->mr == info->mg && info->mg == info->mb) {
-                  // ?!?!?
-                  return stbi__errpuc("bad BMP", "bad BMP");
-               }
-            } else
-               return stbi__errpuc("bad BMP", "bad BMP");
-         }
-      } else {
-         int i;
-         if (hsz != 108 && hsz != 124)
-            return stbi__errpuc("bad BMP", "bad BMP");
-         info->mr = stbi__get32le(s);
-         info->mg = stbi__get32le(s);
-         info->mb = stbi__get32le(s);
-         info->ma = stbi__get32le(s);
-         stbi__get32le(s); // discard color space
-         for (i=0; i < 12; ++i)
-            stbi__get32le(s); // discard color space parameters
-         if (hsz == 124) {
-            stbi__get32le(s); // discard rendering intent
-            stbi__get32le(s); // discard offset of profile data
-            stbi__get32le(s); // discard size of profile data
-            stbi__get32le(s); // discard reserved
-         }
-      }
-   }
-   return (void *) 1;
-}
-
-
-static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *out;
-   unsigned int mr=0,mg=0,mb=0,ma=0, all_a;
-   stbi_uc pal[256][4];
-   int psize=0,i,j,width;
-   int flip_vertically, pad, target;
-   stbi__bmp_data info;
-   STBI_NOTUSED(ri);
-
-   info.all_a = 255;
-   if (stbi__bmp_parse_header(s, &info) == NULL)
-      return NULL; // error code already set
-
-   flip_vertically = ((int) s->img_y) > 0;
-   s->img_y = abs((int) s->img_y);
-
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   mr = info.mr;
-   mg = info.mg;
-   mb = info.mb;
-   ma = info.ma;
-   all_a = info.all_a;
-
-   if (info.hsz == 12) {
-      if (info.bpp < 24)
-         psize = (info.offset - info.extra_read - 24) / 3;
-   } else {
-      if (info.bpp < 16)
-         psize = (info.offset - info.extra_read - info.hsz) >> 2;
-   }
-   if (psize == 0) {
-      STBI_ASSERT(info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original));
-      if (info.offset != s->callback_already_read + (s->img_buffer - s->buffer_start)) {
-        return stbi__errpuc("bad offset", "Corrupt BMP");
-      }
-   }
-
-   if (info.bpp == 24 && ma == 0xff000000)
-      s->img_n = 3;
-   else
-      s->img_n = ma ? 4 : 3;
-   if (req_comp && req_comp >= 3) // we can directly decode 3 or 4
-      target = req_comp;
-   else
-      target = s->img_n; // if they want monochrome, we'll post-convert
-
-   // sanity-check size
-   if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0))
-      return stbi__errpuc("too large", "Corrupt BMP");
-
-   out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0);
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   if (info.bpp < 16) {
-      int z=0;
-      if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); }
-      for (i=0; i < psize; ++i) {
-         pal[i][2] = stbi__get8(s);
-         pal[i][1] = stbi__get8(s);
-         pal[i][0] = stbi__get8(s);
-         if (info.hsz != 12) stbi__get8(s);
-         pal[i][3] = 255;
-      }
-      stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4));
-      if (info.bpp == 1) width = (s->img_x + 7) >> 3;
-      else if (info.bpp == 4) width = (s->img_x + 1) >> 1;
-      else if (info.bpp == 8) width = s->img_x;
-      else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); }
-      pad = (-width)&3;
-      if (info.bpp == 1) {
-         for (j=0; j < (int) s->img_y; ++j) {
-            int bit_offset = 7, v = stbi__get8(s);
-            for (i=0; i < (int) s->img_x; ++i) {
-               int color = (v>>bit_offset)&0x1;
-               out[z++] = pal[color][0];
-               out[z++] = pal[color][1];
-               out[z++] = pal[color][2];
-               if (target == 4) out[z++] = 255;
-               if (i+1 == (int) s->img_x) break;
-               if((--bit_offset) < 0) {
-                  bit_offset = 7;
-                  v = stbi__get8(s);
-               }
-            }
-            stbi__skip(s, pad);
-         }
-      } else {
-         for (j=0; j < (int) s->img_y; ++j) {
-            for (i=0; i < (int) s->img_x; i += 2) {
-               int v=stbi__get8(s),v2=0;
-               if (info.bpp == 4) {
-                  v2 = v & 15;
-                  v >>= 4;
-               }
-               out[z++] = pal[v][0];
-               out[z++] = pal[v][1];
-               out[z++] = pal[v][2];
-               if (target == 4) out[z++] = 255;
-               if (i+1 == (int) s->img_x) break;
-               v = (info.bpp == 8) ? stbi__get8(s) : v2;
-               out[z++] = pal[v][0];
-               out[z++] = pal[v][1];
-               out[z++] = pal[v][2];
-               if (target == 4) out[z++] = 255;
-            }
-            stbi__skip(s, pad);
-         }
-      }
-   } else {
-      int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0;
-      int z = 0;
-      int easy=0;
-      stbi__skip(s, info.offset - info.extra_read - info.hsz);
-      if (info.bpp == 24) width = 3 * s->img_x;
-      else if (info.bpp == 16) width = 2*s->img_x;
-      else /* bpp = 32 and pad = 0 */ width=0;
-      pad = (-width) & 3;
-      if (info.bpp == 24) {
-         easy = 1;
-      } else if (info.bpp == 32) {
-         if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000)
-            easy = 2;
-      }
-      if (!easy) {
-         if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
-         // right shift amt to put high bit in position #7
-         rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr);
-         gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg);
-         bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb);
-         ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma);
-         if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
-      }
-      for (j=0; j < (int) s->img_y; ++j) {
-         if (easy) {
-            for (i=0; i < (int) s->img_x; ++i) {
-               unsigned char a;
-               out[z+2] = stbi__get8(s);
-               out[z+1] = stbi__get8(s);
-               out[z+0] = stbi__get8(s);
-               z += 3;
-               a = (easy == 2 ? stbi__get8(s) : 255);
-               all_a |= a;
-               if (target == 4) out[z++] = a;
-            }
-         } else {
-            int bpp = info.bpp;
-            for (i=0; i < (int) s->img_x; ++i) {
-               stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s));
-               unsigned int a;
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount));
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount));
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount));
-               a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255);
-               all_a |= a;
-               if (target == 4) out[z++] = STBI__BYTECAST(a);
-            }
-         }
-         stbi__skip(s, pad);
-      }
-   }
-
-   // if alpha channel is all 0s, replace with all 255s
-   if (target == 4 && all_a == 0)
-      for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4)
-         out[i] = 255;
-
-   if (flip_vertically) {
-      stbi_uc t;
-      for (j=0; j < (int) s->img_y>>1; ++j) {
-         stbi_uc *p1 = out +      j     *s->img_x*target;
-         stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target;
-         for (i=0; i < (int) s->img_x*target; ++i) {
-            t = p1[i]; p1[i] = p2[i]; p2[i] = t;
-         }
-      }
-   }
-
-   if (req_comp && req_comp != target) {
-      out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-
-   *x = s->img_x;
-   *y = s->img_y;
-   if (comp) *comp = s->img_n;
-   return out;
-}
-#endif
-
-// Targa Truevision - TGA
-// by Jonathan Dummer
-#ifndef STBI_NO_TGA
-// returns STBI_rgb or whatever, 0 on error
-static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16)
-{
-   // only RGB or RGBA (incl. 16bit) or grey allowed
-   if (is_rgb16) *is_rgb16 = 0;
-   switch(bits_per_pixel) {
-      case 8:  return STBI_grey;
-      case 16: if(is_grey) return STBI_grey_alpha;
-               // fallthrough
-      case 15: if(is_rgb16) *is_rgb16 = 1;
-               return STBI_rgb;
-      case 24: // fallthrough
-      case 32: return bits_per_pixel/8;
-      default: return 0;
-   }
-}
-
-static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp)
-{
-    int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp;
-    int sz, tga_colormap_type;
-    stbi__get8(s);                   // discard Offset
-    tga_colormap_type = stbi__get8(s); // colormap type
-    if( tga_colormap_type > 1 ) {
-        stbi__rewind(s);
-        return 0;      // only RGB or indexed allowed
-    }
-    tga_image_type = stbi__get8(s); // image type
-    if ( tga_colormap_type == 1 ) { // colormapped (paletted) image
-        if (tga_image_type != 1 && tga_image_type != 9) {
-            stbi__rewind(s);
-            return 0;
-        }
-        stbi__skip(s,4);       // skip index of first colormap entry and number of entries
-        sz = stbi__get8(s);    //   check bits per palette color entry
-        if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) {
-            stbi__rewind(s);
-            return 0;
-        }
-        stbi__skip(s,4);       // skip image x and y origin
-        tga_colormap_bpp = sz;
-    } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE
-        if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) {
-            stbi__rewind(s);
-            return 0; // only RGB or grey allowed, +/- RLE
-        }
-        stbi__skip(s,9); // skip colormap specification and image x/y origin
-        tga_colormap_bpp = 0;
-    }
-    tga_w = stbi__get16le(s);
-    if( tga_w < 1 ) {
-        stbi__rewind(s);
-        return 0;   // test width
-    }
-    tga_h = stbi__get16le(s);
-    if( tga_h < 1 ) {
-        stbi__rewind(s);
-        return 0;   // test height
-    }
-    tga_bits_per_pixel = stbi__get8(s); // bits per pixel
-    stbi__get8(s); // ignore alpha bits
-    if (tga_colormap_bpp != 0) {
-        if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) {
-            // when using a colormap, tga_bits_per_pixel is the size of the indexes
-            // I don't think anything but 8 or 16bit indexes makes sense
-            stbi__rewind(s);
-            return 0;
-        }
-        tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL);
-    } else {
-        tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL);
-    }
-    if(!tga_comp) {
-      stbi__rewind(s);
-      return 0;
-    }
-    if (x) *x = tga_w;
-    if (y) *y = tga_h;
-    if (comp) *comp = tga_comp;
-    return 1;                   // seems to have passed everything
-}
-
-static int stbi__tga_test(stbi__context *s)
-{
-   int res = 0;
-   int sz, tga_color_type;
-   stbi__get8(s);      //   discard Offset
-   tga_color_type = stbi__get8(s);   //   color type
-   if ( tga_color_type > 1 ) goto errorEnd;   //   only RGB or indexed allowed
-   sz = stbi__get8(s);   //   image type
-   if ( tga_color_type == 1 ) { // colormapped (paletted) image
-      if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9
-      stbi__skip(s,4);       // skip index of first colormap entry and number of entries
-      sz = stbi__get8(s);    //   check bits per palette color entry
-      if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
-      stbi__skip(s,4);       // skip image x and y origin
-   } else { // "normal" image w/o colormap
-      if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE
-      stbi__skip(s,9); // skip colormap specification and image x/y origin
-   }
-   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test width
-   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test height
-   sz = stbi__get8(s);   //   bits per pixel
-   if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index
-   if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
-
-   res = 1; // if we got this far, everything's good and we can return 1 instead of 0
-
-errorEnd:
-   stbi__rewind(s);
-   return res;
-}
-
-// read 16bit value and convert to 24bit RGB
-static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out)
-{
-   stbi__uint16 px = (stbi__uint16)stbi__get16le(s);
-   stbi__uint16 fiveBitMask = 31;
-   // we have 3 channels with 5bits each
-   int r = (px >> 10) & fiveBitMask;
-   int g = (px >> 5) & fiveBitMask;
-   int b = px & fiveBitMask;
-   // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later
-   out[0] = (stbi_uc)((r * 255)/31);
-   out[1] = (stbi_uc)((g * 255)/31);
-   out[2] = (stbi_uc)((b * 255)/31);
-
-   // some people claim that the most significant bit might be used for alpha
-   // (possibly if an alpha-bit is set in the "image descriptor byte")
-   // but that only made 16bit test images completely translucent..
-   // so let's treat all 15 and 16bit TGAs as RGB with no alpha.
-}
-
-static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   //   read in the TGA header stuff
-   int tga_offset = stbi__get8(s);
-   int tga_indexed = stbi__get8(s);
-   int tga_image_type = stbi__get8(s);
-   int tga_is_RLE = 0;
-   int tga_palette_start = stbi__get16le(s);
-   int tga_palette_len = stbi__get16le(s);
-   int tga_palette_bits = stbi__get8(s);
-   int tga_x_origin = stbi__get16le(s);
-   int tga_y_origin = stbi__get16le(s);
-   int tga_width = stbi__get16le(s);
-   int tga_height = stbi__get16le(s);
-   int tga_bits_per_pixel = stbi__get8(s);
-   int tga_comp, tga_rgb16=0;
-   int tga_inverted = stbi__get8(s);
-   // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?)
-   //   image data
-   unsigned char *tga_data;
-   unsigned char *tga_palette = NULL;
-   int i, j;
-   unsigned char raw_data[4] = {0};
-   int RLE_count = 0;
-   int RLE_repeating = 0;
-   int read_next_pixel = 1;
-   STBI_NOTUSED(ri);
-   STBI_NOTUSED(tga_x_origin); // @TODO
-   STBI_NOTUSED(tga_y_origin); // @TODO
-
-   if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   //   do a tiny bit of precessing
-   if ( tga_image_type >= 8 )
-   {
-      tga_image_type -= 8;
-      tga_is_RLE = 1;
-   }
-   tga_inverted = 1 - ((tga_inverted >> 5) & 1);
-
-   //   If I'm paletted, then I'll use the number of bits from the palette
-   if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16);
-   else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16);
-
-   if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency
-      return stbi__errpuc("bad format", "Can't find out TGA pixelformat");
-
-   //   tga info
-   *x = tga_width;
-   *y = tga_height;
-   if (comp) *comp = tga_comp;
-
-   if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0))
-      return stbi__errpuc("too large", "Corrupt TGA");
-
-   tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0);
-   if (!tga_data) return stbi__errpuc("outofmem", "Out of memory");
-
-   // skip to the data's starting position (offset usually = 0)
-   stbi__skip(s, tga_offset );
-
-   if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) {
-      for (i=0; i < tga_height; ++i) {
-         int row = tga_inverted ? tga_height -i - 1 : i;
-         stbi_uc *tga_row = tga_data + row*tga_width*tga_comp;
-         stbi__getn(s, tga_row, tga_width * tga_comp);
-      }
-   } else  {
-      //   do I need to load a palette?
-      if ( tga_indexed)
-      {
-         if (tga_palette_len == 0) {  /* you have to have at least one entry! */
-            STBI_FREE(tga_data);
-            return stbi__errpuc("bad palette", "Corrupt TGA");
-         }
-
-         //   any data to skip? (offset usually = 0)
-         stbi__skip(s, tga_palette_start );
-         //   load the palette
-         tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0);
-         if (!tga_palette) {
-            STBI_FREE(tga_data);
-            return stbi__errpuc("outofmem", "Out of memory");
-         }
-         if (tga_rgb16) {
-            stbi_uc *pal_entry = tga_palette;
-            STBI_ASSERT(tga_comp == STBI_rgb);
-            for (i=0; i < tga_palette_len; ++i) {
-               stbi__tga_read_rgb16(s, pal_entry);
-               pal_entry += tga_comp;
-            }
-         } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) {
-               STBI_FREE(tga_data);
-               STBI_FREE(tga_palette);
-               return stbi__errpuc("bad palette", "Corrupt TGA");
-         }
-      }
-      //   load the data
-      for (i=0; i < tga_width * tga_height; ++i)
-      {
-         //   if I'm in RLE mode, do I need to get a RLE stbi__pngchunk?
-         if ( tga_is_RLE )
-         {
-            if ( RLE_count == 0 )
-            {
-               //   yep, get the next byte as a RLE command
-               int RLE_cmd = stbi__get8(s);
-               RLE_count = 1 + (RLE_cmd & 127);
-               RLE_repeating = RLE_cmd >> 7;
-               read_next_pixel = 1;
-            } else if ( !RLE_repeating )
-            {
-               read_next_pixel = 1;
-            }
-         } else
-         {
-            read_next_pixel = 1;
-         }
-         //   OK, if I need to read a pixel, do it now
-         if ( read_next_pixel )
-         {
-            //   load however much data we did have
-            if ( tga_indexed )
-            {
-               // read in index, then perform the lookup
-               int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s);
-               if ( pal_idx >= tga_palette_len ) {
-                  // invalid index
-                  pal_idx = 0;
-               }
-               pal_idx *= tga_comp;
-               for (j = 0; j < tga_comp; ++j) {
-                  raw_data[j] = tga_palette[pal_idx+j];
-               }
-            } else if(tga_rgb16) {
-               STBI_ASSERT(tga_comp == STBI_rgb);
-               stbi__tga_read_rgb16(s, raw_data);
-            } else {
-               //   read in the data raw
-               for (j = 0; j < tga_comp; ++j) {
-                  raw_data[j] = stbi__get8(s);
-               }
-            }
-            //   clear the reading flag for the next pixel
-            read_next_pixel = 0;
-         } // end of reading a pixel
-
-         // copy data
-         for (j = 0; j < tga_comp; ++j)
-           tga_data[i*tga_comp+j] = raw_data[j];
-
-         //   in case we're in RLE mode, keep counting down
-         --RLE_count;
-      }
-      //   do I need to invert the image?
-      if ( tga_inverted )
-      {
-         for (j = 0; j*2 < tga_height; ++j)
-         {
-            int index1 = j * tga_width * tga_comp;
-            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
-            for (i = tga_width * tga_comp; i > 0; --i)
-            {
-               unsigned char temp = tga_data[index1];
-               tga_data[index1] = tga_data[index2];
-               tga_data[index2] = temp;
-               ++index1;
-               ++index2;
-            }
-         }
-      }
-      //   clear my palette, if I had one
-      if ( tga_palette != NULL )
-      {
-         STBI_FREE( tga_palette );
-      }
-   }
-
-   // swap RGB - if the source data was RGB16, it already is in the right order
-   if (tga_comp >= 3 && !tga_rgb16)
-   {
-      unsigned char* tga_pixel = tga_data;
-      for (i=0; i < tga_width * tga_height; ++i)
-      {
-         unsigned char temp = tga_pixel[0];
-         tga_pixel[0] = tga_pixel[2];
-         tga_pixel[2] = temp;
-         tga_pixel += tga_comp;
-      }
-   }
-
-   // convert to target component count
-   if (req_comp && req_comp != tga_comp)
-      tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height);
-
-   //   the things I do to get rid of an error message, and yet keep
-   //   Microsoft's C compilers happy... [8^(
-   tga_palette_start = tga_palette_len = tga_palette_bits =
-         tga_x_origin = tga_y_origin = 0;
-   STBI_NOTUSED(tga_palette_start);
-   //   OK, done
-   return tga_data;
-}
-#endif
-
-// *************************************************************************************************
-// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB
-
-#ifndef STBI_NO_PSD
-static int stbi__psd_test(stbi__context *s)
-{
-   int r = (stbi__get32be(s) == 0x38425053);
-   stbi__rewind(s);
-   return r;
-}
-
-static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount)
-{
-   int count, nleft, len;
-
-   count = 0;
-   while ((nleft = pixelCount - count) > 0) {
-      len = stbi__get8(s);
-      if (len == 128) {
-         // No-op.
-      } else if (len < 128) {
-         // Copy next len+1 bytes literally.
-         len++;
-         if (len > nleft) return 0; // corrupt data
-         count += len;
-         while (len) {
-            *p = stbi__get8(s);
-            p += 4;
-            len--;
-         }
-      } else if (len > 128) {
-         stbi_uc   val;
-         // Next -len+1 bytes in the dest are replicated from next source byte.
-         // (Interpret len as a negative 8-bit int.)
-         len = 257 - len;
-         if (len > nleft) return 0; // corrupt data
-         val = stbi__get8(s);
-         count += len;
-         while (len) {
-            *p = val;
-            p += 4;
-            len--;
-         }
-      }
-   }
-
-   return 1;
-}
-
-static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
-{
-   int pixelCount;
-   int channelCount, compression;
-   int channel, i;
-   int bitdepth;
-   int w,h;
-   stbi_uc *out;
-   STBI_NOTUSED(ri);
-
-   // Check identifier
-   if (stbi__get32be(s) != 0x38425053)   // "8BPS"
-      return stbi__errpuc("not PSD", "Corrupt PSD image");
-
-   // Check file type version.
-   if (stbi__get16be(s) != 1)
-      return stbi__errpuc("wrong version", "Unsupported version of PSD image");
-
-   // Skip 6 reserved bytes.
-   stbi__skip(s, 6 );
-
-   // Read the number of channels (R, G, B, A, etc).
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16)
-      return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");
-
-   // Read the rows and columns of the image.
-   h = stbi__get32be(s);
-   w = stbi__get32be(s);
-
-   if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   // Make sure the depth is 8 bits.
-   bitdepth = stbi__get16be(s);
-   if (bitdepth != 8 && bitdepth != 16)
-      return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");
-
-   // Make sure the color mode is RGB.
-   // Valid options are:
-   //   0: Bitmap
-   //   1: Grayscale
-   //   2: Indexed color
-   //   3: RGB color
-   //   4: CMYK color
-   //   7: Multichannel
-   //   8: Duotone
-   //   9: Lab color
-   if (stbi__get16be(s) != 3)
-      return stbi__errpuc("wrong color format", "PSD is not in RGB color format");
-
-   // Skip the Mode Data.  (It's the palette for indexed color; other info for other modes.)
-   stbi__skip(s,stbi__get32be(s) );
-
-   // Skip the image resources.  (resolution, pen tool paths, etc)
-   stbi__skip(s, stbi__get32be(s) );
-
-   // Skip the reserved data.
-   stbi__skip(s, stbi__get32be(s) );
-
-   // Find out if the data is compressed.
-   // Known values:
-   //   0: no compression
-   //   1: RLE compressed
-   compression = stbi__get16be(s);
-   if (compression > 1)
-      return stbi__errpuc("bad compression", "PSD has an unknown compression format");
-
-   // Check size
-   if (!stbi__mad3sizes_valid(4, w, h, 0))
-      return stbi__errpuc("too large", "Corrupt PSD");
-
-   // Create the destination image.
-
-   if (!compression && bitdepth == 16 && bpc == 16) {
-      out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0);
-      ri->bits_per_channel = 16;
-   } else
-      out = (stbi_uc *) stbi__malloc(4 * w*h);
-
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   pixelCount = w*h;
-
-   // Initialize the data to zero.
-   //memset( out, 0, pixelCount * 4 );
-
-   // Finally, the image data.
-   if (compression) {
-      // RLE as used by .PSD and .TIFF
-      // Loop until you get the number of unpacked bytes you are expecting:
-      //     Read the next source byte into n.
-      //     If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
-      //     Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
-      //     Else if n is 128, noop.
-      // Endloop
-
-      // The RLE-compressed data is preceded by a 2-byte data count for each row in the data,
-      // which we're going to just skip.
-      stbi__skip(s, h * channelCount * 2 );
-
-      // Read the RLE data by channel.
-      for (channel = 0; channel < 4; channel++) {
-         stbi_uc *p;
-
-         p = out+channel;
-         if (channel >= channelCount) {
-            // Fill this channel with default data.
-            for (i = 0; i < pixelCount; i++, p += 4)
-               *p = (channel == 3 ? 255 : 0);
-         } else {
-            // Read the RLE data.
-            if (!stbi__psd_decode_rle(s, p, pixelCount)) {
-               STBI_FREE(out);
-               return stbi__errpuc("corrupt", "bad RLE data");
-            }
-         }
-      }
-
-   } else {
-      // We're at the raw image data.  It's each channel in order (Red, Green, Blue, Alpha, ...)
-      // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image.
-
-      // Read the data by channel.
-      for (channel = 0; channel < 4; channel++) {
-         if (channel >= channelCount) {
-            // Fill this channel with default data.
-            if (bitdepth == 16 && bpc == 16) {
-               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
-               stbi__uint16 val = channel == 3 ? 65535 : 0;
-               for (i = 0; i < pixelCount; i++, q += 4)
-                  *q = val;
-            } else {
-               stbi_uc *p = out+channel;
-               stbi_uc val = channel == 3 ? 255 : 0;
-               for (i = 0; i < pixelCount; i++, p += 4)
-                  *p = val;
-            }
-         } else {
-            if (ri->bits_per_channel == 16) {    // output bpc
-               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
-               for (i = 0; i < pixelCount; i++, q += 4)
-                  *q = (stbi__uint16) stbi__get16be(s);
-            } else {
-               stbi_uc *p = out+channel;
-               if (bitdepth == 16) {  // input bpc
-                  for (i = 0; i < pixelCount; i++, p += 4)
-                     *p = (stbi_uc) (stbi__get16be(s) >> 8);
-               } else {
-                  for (i = 0; i < pixelCount; i++, p += 4)
-                     *p = stbi__get8(s);
-               }
-            }
-         }
-      }
-   }
-
-   // remove weird white matte from PSD
-   if (channelCount >= 4) {
-      if (ri->bits_per_channel == 16) {
-         for (i=0; i < w*h; ++i) {
-            stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i;
-            if (pixel[3] != 0 && pixel[3] != 65535) {
-               float a = pixel[3] / 65535.0f;
-               float ra = 1.0f / a;
-               float inv_a = 65535.0f * (1 - ra);
-               pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a);
-               pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a);
-               pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a);
-            }
-         }
-      } else {
-         for (i=0; i < w*h; ++i) {
-            unsigned char *pixel = out + 4*i;
-            if (pixel[3] != 0 && pixel[3] != 255) {
-               float a = pixel[3] / 255.0f;
-               float ra = 1.0f / a;
-               float inv_a = 255.0f * (1 - ra);
-               pixel[0] = (unsigned char) (pixel[0]*ra + inv_a);
-               pixel[1] = (unsigned char) (pixel[1]*ra + inv_a);
-               pixel[2] = (unsigned char) (pixel[2]*ra + inv_a);
-            }
-         }
-      }
-   }
-
-   // convert to desired output format
-   if (req_comp && req_comp != 4) {
-      if (ri->bits_per_channel == 16)
-         out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h);
-      else
-         out = stbi__convert_format(out, 4, req_comp, w, h);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-
-   if (comp) *comp = 4;
-   *y = h;
-   *x = w;
-
-   return out;
-}
-#endif
-
-// *************************************************************************************************
-// Softimage PIC loader
-// by Tom Seddon
-//
-// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format
-// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/
-
-#ifndef STBI_NO_PIC
-static int stbi__pic_is4(stbi__context *s,const char *str)
-{
-   int i;
-   for (i=0; i<4; ++i)
-      if (stbi__get8(s) != (stbi_uc)str[i])
-         return 0;
-
-   return 1;
-}
-
-static int stbi__pic_test_core(stbi__context *s)
-{
-   int i;
-
-   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34"))
-      return 0;
-
-   for(i=0;i<84;++i)
-      stbi__get8(s);
-
-   if (!stbi__pic_is4(s,"PICT"))
-      return 0;
-
-   return 1;
-}
-
-typedef struct
-{
-   stbi_uc size,type,channel;
-} stbi__pic_packet;
-
-static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest)
-{
-   int mask=0x80, i;
-
-   for (i=0; i<4; ++i, mask>>=1) {
-      if (channel & mask) {
-         if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short");
-         dest[i]=stbi__get8(s);
-      }
-   }
-
-   return dest;
-}
-
-static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src)
-{
-   int mask=0x80,i;
-
-   for (i=0;i<4; ++i, mask>>=1)
-      if (channel&mask)
-         dest[i]=src[i];
-}
-
-static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)
-{
-   int act_comp=0,num_packets=0,y,chained;
-   stbi__pic_packet packets[10];
-
-   // this will (should...) cater for even some bizarre stuff like having data
-    // for the same channel in multiple packets.
-   do {
-      stbi__pic_packet *packet;
-
-      if (num_packets==sizeof(packets)/sizeof(packets[0]))
-         return stbi__errpuc("bad format","too many packets");
-
-      packet = &packets[num_packets++];
-
-      chained = stbi__get8(s);
-      packet->size    = stbi__get8(s);
-      packet->type    = stbi__get8(s);
-      packet->channel = stbi__get8(s);
-
-      act_comp |= packet->channel;
-
-      if (stbi__at_eof(s))          return stbi__errpuc("bad file","file too short (reading packets)");
-      if (packet->size != 8)  return stbi__errpuc("bad format","packet isn't 8bpp");
-   } while (chained);
-
-   *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?
-
-   for(y=0; y<height; ++y) {
-      int packet_idx;
-
-      for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {
-         stbi__pic_packet *packet = &packets[packet_idx];
-         stbi_uc *dest = result+y*width*4;
-
-         switch (packet->type) {
-            default:
-               return stbi__errpuc("bad format","packet has bad compression type");
-
-            case 0: {//uncompressed
-               int x;
-
-               for(x=0;x<width;++x, dest+=4)
-                  if (!stbi__readval(s,packet->channel,dest))
-                     return 0;
-               break;
-            }
-
-            case 1://Pure RLE
-               {
-                  int left=width, i;
-
-                  while (left>0) {
-                     stbi_uc count,value[4];
-
-                     count=stbi__get8(s);
-                     if (stbi__at_eof(s))   return stbi__errpuc("bad file","file too short (pure read count)");
-
-                     if (count > left)
-                        count = (stbi_uc) left;
-
-                     if (!stbi__readval(s,packet->channel,value))  return 0;
-
-                     for(i=0; i<count; ++i,dest+=4)
-                        stbi__copyval(packet->channel,dest,value);
-                     left -= count;
-                  }
-               }
-               break;
-
-            case 2: {//Mixed RLE
-               int left=width;
-               while (left>0) {
-                  int count = stbi__get8(s), i;
-                  if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (mixed read count)");
-
-                  if (count >= 128) { // Repeated
-                     stbi_uc value[4];
-
-                     if (count==128)
-                        count = stbi__get16be(s);
-                     else
-                        count -= 127;
-                     if (count > left)
-                        return stbi__errpuc("bad file","scanline overrun");
-
-                     if (!stbi__readval(s,packet->channel,value))
-                        return 0;
-
-                     for(i=0;i<count;++i, dest += 4)
-                        stbi__copyval(packet->channel,dest,value);
-                  } else { // Raw
-                     ++count;
-                     if (count>left) return stbi__errpuc("bad file","scanline overrun");
-
-                     for(i=0;i<count;++i, dest+=4)
-                        if (!stbi__readval(s,packet->channel,dest))
-                           return 0;
-                  }
-                  left-=count;
-               }
-               break;
-            }
-         }
-      }
-   }
-
-   return result;
-}
-
-static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *result;
-   int i, x,y, internal_comp;
-   STBI_NOTUSED(ri);
-
-   if (!comp) comp = &internal_comp;
-
-   for (i=0; i<92; ++i)
-      stbi__get8(s);
-
-   x = stbi__get16be(s);
-   y = stbi__get16be(s);
-
-   if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (pic header)");
-   if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode");
-
-   stbi__get32be(s); //skip `ratio'
-   stbi__get16be(s); //skip `fields'
-   stbi__get16be(s); //skip `pad'
-
-   // intermediate buffer is RGBA
-   result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
-   memset(result, 0xff, x*y*4);
-
-   if (!stbi__pic_load_core(s,x,y,comp, result)) {
-      STBI_FREE(result);
-      result=0;
-   }
-   *px = x;
-   *py = y;
-   if (req_comp == 0) req_comp = *comp;
-   result=stbi__convert_format(result,4,req_comp,x,y);
-
-   return result;
-}
-
-static int stbi__pic_test(stbi__context *s)
-{
-   int r = stbi__pic_test_core(s);
-   stbi__rewind(s);
-   return r;
-}
-#endif
-
-// *************************************************************************************************
-// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
-
-#ifndef STBI_NO_GIF
-typedef struct
-{
-   stbi__int16 prefix;
-   stbi_uc first;
-   stbi_uc suffix;
-} stbi__gif_lzw;
-
-typedef struct
-{
-   int w,h;
-   stbi_uc *out;                 // output buffer (always 4 components)
-   stbi_uc *background;          // The current "background" as far as a gif is concerned
-   stbi_uc *history;
-   int flags, bgindex, ratio, transparent, eflags;
-   stbi_uc  pal[256][4];
-   stbi_uc lpal[256][4];
-   stbi__gif_lzw codes[8192];
-   stbi_uc *color_table;
-   int parse, step;
-   int lflags;
-   int start_x, start_y;
-   int max_x, max_y;
-   int cur_x, cur_y;
-   int line_size;
-   int delay;
-} stbi__gif;
-
-static int stbi__gif_test_raw(stbi__context *s)
-{
-   int sz;
-   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0;
-   sz = stbi__get8(s);
-   if (sz != '9' && sz != '7') return 0;
-   if (stbi__get8(s) != 'a') return 0;
-   return 1;
-}
-
-static int stbi__gif_test(stbi__context *s)
-{
-   int r = stbi__gif_test_raw(s);
-   stbi__rewind(s);
-   return r;
-}
-
-static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp)
-{
-   int i;
-   for (i=0; i < num_entries; ++i) {
-      pal[i][2] = stbi__get8(s);
-      pal[i][1] = stbi__get8(s);
-      pal[i][0] = stbi__get8(s);
-      pal[i][3] = transp == i ? 0 : 255;
-   }
-}
-
-static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info)
-{
-   stbi_uc version;
-   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8')
-      return stbi__err("not GIF", "Corrupt GIF");
-
-   version = stbi__get8(s);
-   if (version != '7' && version != '9')    return stbi__err("not GIF", "Corrupt GIF");
-   if (stbi__get8(s) != 'a')                return stbi__err("not GIF", "Corrupt GIF");
-
-   stbi__g_failure_reason = "";
-   g->w = stbi__get16le(s);
-   g->h = stbi__get16le(s);
-   g->flags = stbi__get8(s);
-   g->bgindex = stbi__get8(s);
-   g->ratio = stbi__get8(s);
-   g->transparent = -1;
-
-   if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-
-   if (comp != 0) *comp = 4;  // can't actually tell whether it's 3 or 4 until we parse the comments
-
-   if (is_info) return 1;
-
-   if (g->flags & 0x80)
-      stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1);
-
-   return 1;
-}
-
-static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
-{
-   stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
-   if (!stbi__gif_header(s, g, comp, 1)) {
-      STBI_FREE(g);
-      stbi__rewind( s );
-      return 0;
-   }
-   if (x) *x = g->w;
-   if (y) *y = g->h;
-   STBI_FREE(g);
-   return 1;
-}
-
-static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)
-{
-   stbi_uc *p, *c;
-   int idx;
-
-   // recurse to decode the prefixes, since the linked-list is backwards,
-   // and working backwards through an interleaved image would be nasty
-   if (g->codes[code].prefix >= 0)
-      stbi__out_gif_code(g, g->codes[code].prefix);
-
-   if (g->cur_y >= g->max_y) return;
-
-   idx = g->cur_x + g->cur_y;
-   p = &g->out[idx];
-   g->history[idx / 4] = 1;
-
-   c = &g->color_table[g->codes[code].suffix * 4];
-   if (c[3] > 128) { // don't render transparent pixels;
-      p[0] = c[2];
-      p[1] = c[1];
-      p[2] = c[0];
-      p[3] = c[3];
-   }
-   g->cur_x += 4;
-
-   if (g->cur_x >= g->max_x) {
-      g->cur_x = g->start_x;
-      g->cur_y += g->step;
-
-      while (g->cur_y >= g->max_y && g->parse > 0) {
-         g->step = (1 << g->parse) * g->line_size;
-         g->cur_y = g->start_y + (g->step >> 1);
-         --g->parse;
-      }
-   }
-}
-
-static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
-{
-   stbi_uc lzw_cs;
-   stbi__int32 len, init_code;
-   stbi__uint32 first;
-   stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;
-   stbi__gif_lzw *p;
-
-   lzw_cs = stbi__get8(s);
-   if (lzw_cs > 12) return NULL;
-   clear = 1 << lzw_cs;
-   first = 1;
-   codesize = lzw_cs + 1;
-   codemask = (1 << codesize) - 1;
-   bits = 0;
-   valid_bits = 0;
-   for (init_code = 0; init_code < clear; init_code++) {
-      g->codes[init_code].prefix = -1;
-      g->codes[init_code].first = (stbi_uc) init_code;
-      g->codes[init_code].suffix = (stbi_uc) init_code;
-   }
-
-   // support no starting clear code
-   avail = clear+2;
-   oldcode = -1;
-
-   len = 0;
-   for(;;) {
-      if (valid_bits < codesize) {
-         if (len == 0) {
-            len = stbi__get8(s); // start new block
-            if (len == 0)
-               return g->out;
-         }
-         --len;
-         bits |= (stbi__int32) stbi__get8(s) << valid_bits;
-         valid_bits += 8;
-      } else {
-         stbi__int32 code = bits & codemask;
-         bits >>= codesize;
-         valid_bits -= codesize;
-         // @OPTIMIZE: is there some way we can accelerate the non-clear path?
-         if (code == clear) {  // clear code
-            codesize = lzw_cs + 1;
-            codemask = (1 << codesize) - 1;
-            avail = clear + 2;
-            oldcode = -1;
-            first = 0;
-         } else if (code == clear + 1) { // end of stream code
-            stbi__skip(s, len);
-            while ((len = stbi__get8(s)) > 0)
-               stbi__skip(s,len);
-            return g->out;
-         } else if (code <= avail) {
-            if (first) {
-               return stbi__errpuc("no clear code", "Corrupt GIF");
-            }
-
-            if (oldcode >= 0) {
-               p = &g->codes[avail++];
-               if (avail > 8192) {
-                  return stbi__errpuc("too many codes", "Corrupt GIF");
-               }
-
-               p->prefix = (stbi__int16) oldcode;
-               p->first = g->codes[oldcode].first;
-               p->suffix = (code == avail) ? p->first : g->codes[code].first;
-            } else if (code == avail)
-               return stbi__errpuc("illegal code in raster", "Corrupt GIF");
-
-            stbi__out_gif_code(g, (stbi__uint16) code);
-
-            if ((avail & codemask) == 0 && avail <= 0x0FFF) {
-               codesize++;
-               codemask = (1 << codesize) - 1;
-            }
-
-            oldcode = code;
-         } else {
-            return stbi__errpuc("illegal code in raster", "Corrupt GIF");
-         }
-      }
-   }
-}
-
-// this function is designed to support animated gifs, although stb_image doesn't support it
-// two back is the image from two frames ago, used for a very specific disposal format
-static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
-{
-   int dispose;
-   int first_frame;
-   int pi;
-   int pcount;
-   STBI_NOTUSED(req_comp);
-
-   // on first frame, any non-written pixels get the background colour (non-transparent)
-   first_frame = 0;
-   if (g->out == 0) {
-      if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header
-      if (!stbi__mad3sizes_valid(4, g->w, g->h, 0))
-         return stbi__errpuc("too large", "GIF image is too large");
-      pcount = g->w * g->h;
-      g->out = (stbi_uc *) stbi__malloc(4 * pcount);
-      g->background = (stbi_uc *) stbi__malloc(4 * pcount);
-      g->history = (stbi_uc *) stbi__malloc(pcount);
-      if (!g->out || !g->background || !g->history)
-         return stbi__errpuc("outofmem", "Out of memory");
-
-      // image is treated as "transparent" at the start - ie, nothing overwrites the current background;
-      // background colour is only used for pixels that are not rendered first frame, after that "background"
-      // color refers to the color that was there the previous frame.
-      memset(g->out, 0x00, 4 * pcount);
-      memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent)
-      memset(g->history, 0x00, pcount);        // pixels that were affected previous frame
-      first_frame = 1;
-   } else {
-      // second frame - how do we dispose of the previous one?
-      dispose = (g->eflags & 0x1C) >> 2;
-      pcount = g->w * g->h;
-
-      if ((dispose == 3) && (two_back == 0)) {
-         dispose = 2; // if I don't have an image to revert back to, default to the old background
-      }
-
-      if (dispose == 3) { // use previous graphic
-         for (pi = 0; pi < pcount; ++pi) {
-            if (g->history[pi]) {
-               memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 );
-            }
-         }
-      } else if (dispose == 2) {
-         // restore what was changed last frame to background before that frame;
-         for (pi = 0; pi < pcount; ++pi) {
-            if (g->history[pi]) {
-               memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 );
-            }
-         }
-      } else {
-         // This is a non-disposal case eithe way, so just
-         // leave the pixels as is, and they will become the new background
-         // 1: do not dispose
-         // 0:  not specified.
-      }
-
-      // background is what out is after the undoing of the previou frame;
-      memcpy( g->background, g->out, 4 * g->w * g->h );
-   }
-
-   // clear my history;
-   memset( g->history, 0x00, g->w * g->h );        // pixels that were affected previous frame
-
-   for (;;) {
-      int tag = stbi__get8(s);
-      switch (tag) {
-         case 0x2C: /* Image Descriptor */
-         {
-            stbi__int32 x, y, w, h;
-            stbi_uc *o;
-
-            x = stbi__get16le(s);
-            y = stbi__get16le(s);
-            w = stbi__get16le(s);
-            h = stbi__get16le(s);
-            if (((x + w) > (g->w)) || ((y + h) > (g->h)))
-               return stbi__errpuc("bad Image Descriptor", "Corrupt GIF");
-
-            g->line_size = g->w * 4;
-            g->start_x = x * 4;
-            g->start_y = y * g->line_size;
-            g->max_x   = g->start_x + w * 4;
-            g->max_y   = g->start_y + h * g->line_size;
-            g->cur_x   = g->start_x;
-            g->cur_y   = g->start_y;
-
-            // if the width of the specified rectangle is 0, that means
-            // we may not see *any* pixels or the image is malformed;
-            // to make sure this is caught, move the current y down to
-            // max_y (which is what out_gif_code checks).
-            if (w == 0)
-               g->cur_y = g->max_y;
-
-            g->lflags = stbi__get8(s);
-
-            if (g->lflags & 0x40) {
-               g->step = 8 * g->line_size; // first interlaced spacing
-               g->parse = 3;
-            } else {
-               g->step = g->line_size;
-               g->parse = 0;
-            }
-
-            if (g->lflags & 0x80) {
-               stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
-               g->color_table = (stbi_uc *) g->lpal;
-            } else if (g->flags & 0x80) {
-               g->color_table = (stbi_uc *) g->pal;
-            } else
-               return stbi__errpuc("missing color table", "Corrupt GIF");
-
-            o = stbi__process_gif_raster(s, g);
-            if (!o) return NULL;
-
-            // if this was the first frame,
-            pcount = g->w * g->h;
-            if (first_frame && (g->bgindex > 0)) {
-               // if first frame, any pixel not drawn to gets the background color
-               for (pi = 0; pi < pcount; ++pi) {
-                  if (g->history[pi] == 0) {
-                     g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be;
-                     memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 );
-                  }
-               }
-            }
-
-            return o;
-         }
-
-         case 0x21: // Comment Extension.
-         {
-            int len;
-            int ext = stbi__get8(s);
-            if (ext == 0xF9) { // Graphic Control Extension.
-               len = stbi__get8(s);
-               if (len == 4) {
-                  g->eflags = stbi__get8(s);
-                  g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths.
-
-                  // unset old transparent
-                  if (g->transparent >= 0) {
-                     g->pal[g->transparent][3] = 255;
-                  }
-                  if (g->eflags & 0x01) {
-                     g->transparent = stbi__get8(s);
-                     if (g->transparent >= 0) {
-                        g->pal[g->transparent][3] = 0;
-                     }
-                  } else {
-                     // don't need transparent
-                     stbi__skip(s, 1);
-                     g->transparent = -1;
-                  }
-               } else {
-                  stbi__skip(s, len);
-                  break;
-               }
-            }
-            while ((len = stbi__get8(s)) != 0) {
-               stbi__skip(s, len);
-            }
-            break;
-         }
-
-         case 0x3B: // gif stream termination code
-            return (stbi_uc *) s; // using '1' causes warning on some compilers
-
-         default:
-            return stbi__errpuc("unknown code", "Corrupt GIF");
-      }
-   }
-}
-
-static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
-{
-   if (stbi__gif_test(s)) {
-      int layers = 0;
-      stbi_uc *u = 0;
-      stbi_uc *out = 0;
-      stbi_uc *two_back = 0;
-      stbi__gif g;
-      int stride;
-      int out_size = 0;
-      int delays_size = 0;
-      memset(&g, 0, sizeof(g));
-      if (delays) {
-         *delays = 0;
-      }
-
-      do {
-         u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);
-         if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
-
-         if (u) {
-            *x = g.w;
-            *y = g.h;
-            ++layers;
-            stride = g.w * g.h * 4;
-
-            if (out) {
-               void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
-               if (NULL == tmp) {
-                  STBI_FREE(g.out);
-                  STBI_FREE(g.history);
-                  STBI_FREE(g.background);
-                  return stbi__errpuc("outofmem", "Out of memory");
-               }
-               else {
-                   out = (stbi_uc*) tmp;
-                   out_size = layers * stride;
-               }
-
-               if (delays) {
-                  *delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
-                  delays_size = layers * sizeof(int);
-               }
-            } else {
-               out = (stbi_uc*)stbi__malloc( layers * stride );
-               out_size = layers * stride;
-               if (delays) {
-                  *delays = (int*) stbi__malloc( layers * sizeof(int) );
-                  delays_size = layers * sizeof(int);
-               }
-            }
-            memcpy( out + ((layers - 1) * stride), u, stride );
-            if (layers >= 2) {
-               two_back = out - 2 * stride;
-            }
-
-            if (delays) {
-               (*delays)[layers - 1U] = g.delay;
-            }
-         }
-      } while (u != 0);
-
-      // free temp buffer;
-      STBI_FREE(g.out);
-      STBI_FREE(g.history);
-      STBI_FREE(g.background);
-
-      // do the final conversion after loading everything;
-      if (req_comp && req_comp != 4)
-         out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h);
-
-      *z = layers;
-      return out;
-   } else {
-      return stbi__errpuc("not GIF", "Image was not as a gif type.");
-   }
-}
-
-static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *u = 0;
-   stbi__gif g;
-   memset(&g, 0, sizeof(g));
-   STBI_NOTUSED(ri);
-
-   u = stbi__gif_load_next(s, &g, comp, req_comp, 0);
-   if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
-   if (u) {
-      *x = g.w;
-      *y = g.h;
-
-      // moved conversion to after successful load so that the same
-      // can be done for multiple frames.
-      if (req_comp && req_comp != 4)
-         u = stbi__convert_format(u, 4, req_comp, g.w, g.h);
-   } else if (g.out) {
-      // if there was an error and we allocated an image buffer, free it!
-      STBI_FREE(g.out);
-   }
-
-   // free buffers needed for multiple frame loading;
-   STBI_FREE(g.history);
-   STBI_FREE(g.background);
-
-   return u;
-}
-
-static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   return stbi__gif_info_raw(s,x,y,comp);
-}
-#endif
-
-// *************************************************************************************************
-// Radiance RGBE HDR loader
-// originally by Nicolas Schulz
-#ifndef STBI_NO_HDR
-static int stbi__hdr_test_core(stbi__context *s, const char *signature)
-{
-   int i;
-   for (i=0; signature[i]; ++i)
-      if (stbi__get8(s) != signature[i])
-          return 0;
-   stbi__rewind(s);
-   return 1;
-}
-
-static int stbi__hdr_test(stbi__context* s)
-{
-   int r = stbi__hdr_test_core(s, "#?RADIANCE\n");
-   stbi__rewind(s);
-   if(!r) {
-       r = stbi__hdr_test_core(s, "#?RGBE\n");
-       stbi__rewind(s);
-   }
-   return r;
-}
-
-#define STBI__HDR_BUFLEN  1024
-static char *stbi__hdr_gettoken(stbi__context *z, char *buffer)
-{
-   int len=0;
-   char c = '\0';
-
-   c = (char) stbi__get8(z);
-
-   while (!stbi__at_eof(z) && c != '\n') {
-      buffer[len++] = c;
-      if (len == STBI__HDR_BUFLEN-1) {
-         // flush to end of line
-         while (!stbi__at_eof(z) && stbi__get8(z) != '\n')
-            ;
-         break;
-      }
-      c = (char) stbi__get8(z);
-   }
-
-   buffer[len] = 0;
-   return buffer;
-}
-
-static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)
-{
-   if ( input[3] != 0 ) {
-      float f1;
-      // Exponent
-      f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8));
-      if (req_comp <= 2)
-         output[0] = (input[0] + input[1] + input[2]) * f1 / 3;
-      else {
-         output[0] = input[0] * f1;
-         output[1] = input[1] * f1;
-         output[2] = input[2] * f1;
-      }
-      if (req_comp == 2) output[1] = 1;
-      if (req_comp == 4) output[3] = 1;
-   } else {
-      switch (req_comp) {
-         case 4: output[3] = 1; /* fallthrough */
-         case 3: output[0] = output[1] = output[2] = 0;
-                 break;
-         case 2: output[1] = 1; /* fallthrough */
-         case 1: output[0] = 0;
-                 break;
-      }
-   }
-}
-
-static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   char buffer[STBI__HDR_BUFLEN];
-   char *token;
-   int valid = 0;
-   int width, height;
-   stbi_uc *scanline;
-   float *hdr_data;
-   int len;
-   unsigned char count, value;
-   int i, j, k, c1,c2, z;
-   const char *headerToken;
-   STBI_NOTUSED(ri);
-
-   // Check identifier
-   headerToken = stbi__hdr_gettoken(s,buffer);
-   if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0)
-      return stbi__errpf("not HDR", "Corrupt HDR image");
-
-   // Parse header
-   for(;;) {
-      token = stbi__hdr_gettoken(s,buffer);
-      if (token[0] == 0) break;
-      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
-   }
-
-   if (!valid)    return stbi__errpf("unsupported format", "Unsupported HDR format");
-
-   // Parse width and height
-   // can't use sscanf() if we're not using stdio!
-   token = stbi__hdr_gettoken(s,buffer);
-   if (strncmp(token, "-Y ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
-   token += 3;
-   height = (int) strtol(token, &token, 10);
-   while (*token == ' ') ++token;
-   if (strncmp(token, "+X ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
-   token += 3;
-   width = (int) strtol(token, NULL, 10);
-
-   if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
-   if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
-
-   *x = width;
-   *y = height;
-
-   if (comp) *comp = 3;
-   if (req_comp == 0) req_comp = 3;
-
-   if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0))
-      return stbi__errpf("too large", "HDR image is too large");
-
-   // Read data
-   hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0);
-   if (!hdr_data)
-      return stbi__errpf("outofmem", "Out of memory");
-
-   // Load image data
-   // image data is stored as some number of sca
-   if ( width < 8 || width >= 32768) {
-      // Read flat data
-      for (j=0; j < height; ++j) {
-         for (i=0; i < width; ++i) {
-            stbi_uc rgbe[4];
-           main_decode_loop:
-            stbi__getn(s, rgbe, 4);
-            stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp);
-         }
-      }
-   } else {
-      // Read RLE-encoded data
-      scanline = NULL;
-
-      for (j = 0; j < height; ++j) {
-         c1 = stbi__get8(s);
-         c2 = stbi__get8(s);
-         len = stbi__get8(s);
-         if (c1 != 2 || c2 != 2 || (len & 0x80)) {
-            // not run-length encoded, so we have to actually use THIS data as a decoded
-            // pixel (note this can't be a valid pixel--one of RGB must be >= 128)
-            stbi_uc rgbe[4];
-            rgbe[0] = (stbi_uc) c1;
-            rgbe[1] = (stbi_uc) c2;
-            rgbe[2] = (stbi_uc) len;
-            rgbe[3] = (stbi_uc) stbi__get8(s);
-            stbi__hdr_convert(hdr_data, rgbe, req_comp);
-            i = 1;
-            j = 0;
-            STBI_FREE(scanline);
-            goto main_decode_loop; // yes, this makes no sense
-         }
-         len <<= 8;
-         len |= stbi__get8(s);
-         if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); }
-         if (scanline == NULL) {
-            scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0);
-            if (!scanline) {
-               STBI_FREE(hdr_data);
-               return stbi__errpf("outofmem", "Out of memory");
-            }
-         }
-
-         for (k = 0; k < 4; ++k) {
-            int nleft;
-            i = 0;
-            while ((nleft = width - i) > 0) {
-               count = stbi__get8(s);
-               if (count > 128) {
-                  // Run
-                  value = stbi__get8(s);
-                  count -= 128;
-                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
-                  for (z = 0; z < count; ++z)
-                     scanline[i++ * 4 + k] = value;
-               } else {
-                  // Dump
-                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
-                  for (z = 0; z < count; ++z)
-                     scanline[i++ * 4 + k] = stbi__get8(s);
-               }
-            }
-         }
-         for (i=0; i < width; ++i)
-            stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp);
-      }
-      if (scanline)
-         STBI_FREE(scanline);
-   }
-
-   return hdr_data;
-}
-
-static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   char buffer[STBI__HDR_BUFLEN];
-   char *token;
-   int valid = 0;
-   int dummy;
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   if (stbi__hdr_test(s) == 0) {
-       stbi__rewind( s );
-       return 0;
-   }
-
-   for(;;) {
-      token = stbi__hdr_gettoken(s,buffer);
-      if (token[0] == 0) break;
-      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
-   }
-
-   if (!valid) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token = stbi__hdr_gettoken(s,buffer);
-   if (strncmp(token, "-Y ", 3)) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token += 3;
-   *y = (int) strtol(token, &token, 10);
-   while (*token == ' ') ++token;
-   if (strncmp(token, "+X ", 3)) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token += 3;
-   *x = (int) strtol(token, NULL, 10);
-   *comp = 3;
-   return 1;
-}
-#endif // STBI_NO_HDR
-
-#ifndef STBI_NO_BMP
-static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   void *p;
-   stbi__bmp_data info;
-
-   info.all_a = 255;
-   p = stbi__bmp_parse_header(s, &info);
-   stbi__rewind( s );
-   if (p == NULL)
-      return 0;
-   if (x) *x = s->img_x;
-   if (y) *y = s->img_y;
-   if (comp) {
-      if (info.bpp == 24 && info.ma == 0xff000000)
-         *comp = 3;
-      else
-         *comp = info.ma ? 4 : 3;
-   }
-   return 1;
-}
-#endif
-
-#ifndef STBI_NO_PSD
-static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int channelCount, dummy, depth;
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-   if (stbi__get32be(s) != 0x38425053) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 1) {
-       stbi__rewind( s );
-       return 0;
-   }
-   stbi__skip(s, 6);
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   *y = stbi__get32be(s);
-   *x = stbi__get32be(s);
-   depth = stbi__get16be(s);
-   if (depth != 8 && depth != 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 3) {
-       stbi__rewind( s );
-       return 0;
-   }
-   *comp = 4;
-   return 1;
-}
-
-static int stbi__psd_is16(stbi__context *s)
-{
-   int channelCount, depth;
-   if (stbi__get32be(s) != 0x38425053) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 1) {
-       stbi__rewind( s );
-       return 0;
-   }
-   stbi__skip(s, 6);
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   (void) stbi__get32be(s);
-   (void) stbi__get32be(s);
-   depth = stbi__get16be(s);
-   if (depth != 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   return 1;
-}
-#endif
-
-#ifndef STBI_NO_PIC
-static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int act_comp=0,num_packets=0,chained,dummy;
-   stbi__pic_packet packets[10];
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) {
-      stbi__rewind(s);
-      return 0;
-   }
-
-   stbi__skip(s, 88);
-
-   *x = stbi__get16be(s);
-   *y = stbi__get16be(s);
-   if (stbi__at_eof(s)) {
-      stbi__rewind( s);
-      return 0;
-   }
-   if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) {
-      stbi__rewind( s );
-      return 0;
-   }
-
-   stbi__skip(s, 8);
-
-   do {
-      stbi__pic_packet *packet;
-
-      if (num_packets==sizeof(packets)/sizeof(packets[0]))
-         return 0;
-
-      packet = &packets[num_packets++];
-      chained = stbi__get8(s);
-      packet->size    = stbi__get8(s);
-      packet->type    = stbi__get8(s);
-      packet->channel = stbi__get8(s);
-      act_comp |= packet->channel;
-
-      if (stbi__at_eof(s)) {
-          stbi__rewind( s );
-          return 0;
-      }
-      if (packet->size != 8) {
-          stbi__rewind( s );
-          return 0;
-      }
-   } while (chained);
-
-   *comp = (act_comp & 0x10 ? 4 : 3);
-
-   return 1;
-}
-#endif
-
-// *************************************************************************************************
-// Portable Gray Map and Portable Pixel Map loader
-// by Ken Miller
-//
-// PGM: http://netpbm.sourceforge.net/doc/pgm.html
-// PPM: http://netpbm.sourceforge.net/doc/ppm.html
-//
-// Known limitations:
-//    Does not support comments in the header section
-//    Does not support ASCII image data (formats P2 and P3)
-//    Does not support 16-bit-per-channel
-
-#ifndef STBI_NO_PNM
-
-static int      stbi__pnm_test(stbi__context *s)
-{
-   char p, t;
-   p = (char) stbi__get8(s);
-   t = (char) stbi__get8(s);
-   if (p != 'P' || (t != '5' && t != '6')) {
-       stbi__rewind( s );
-       return 0;
-   }
-   return 1;
-}
-
-static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *out;
-   STBI_NOTUSED(ri);
-
-   if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n))
-      return 0;
-
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   *x = s->img_x;
-   *y = s->img_y;
-   if (comp) *comp = s->img_n;
-
-   if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0))
-      return stbi__errpuc("too large", "PNM too large");
-
-   out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0);
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   stbi__getn(s, out, s->img_n * s->img_x * s->img_y);
-
-   if (req_comp && req_comp != s->img_n) {
-      out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-   return out;
-}
-
-static int      stbi__pnm_isspace(char c)
-{
-   return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
-}
-
-static void     stbi__pnm_skip_whitespace(stbi__context *s, char *c)
-{
-   for (;;) {
-      while (!stbi__at_eof(s) && stbi__pnm_isspace(*c))
-         *c = (char) stbi__get8(s);
-
-      if (stbi__at_eof(s) || *c != '#')
-         break;
-
-      while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' )
-         *c = (char) stbi__get8(s);
-   }
-}
-
-static int      stbi__pnm_isdigit(char c)
-{
-   return c >= '0' && c <= '9';
-}
-
-static int      stbi__pnm_getinteger(stbi__context *s, char *c)
-{
-   int value = 0;
-
-   while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {
-      value = value*10 + (*c - '0');
-      *c = (char) stbi__get8(s);
-   }
-
-   return value;
-}
-
-static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int maxv, dummy;
-   char c, p, t;
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   stbi__rewind(s);
-
-   // Get identifier
-   p = (char) stbi__get8(s);
-   t = (char) stbi__get8(s);
-   if (p != 'P' || (t != '5' && t != '6')) {
-       stbi__rewind(s);
-       return 0;
-   }
-
-   *comp = (t == '6') ? 3 : 1;  // '5' is 1-component .pgm; '6' is 3-component .ppm
-
-   c = (char) stbi__get8(s);
-   stbi__pnm_skip_whitespace(s, &c);
-
-   *x = stbi__pnm_getinteger(s, &c); // read width
-   stbi__pnm_skip_whitespace(s, &c);
-
-   *y = stbi__pnm_getinteger(s, &c); // read height
-   stbi__pnm_skip_whitespace(s, &c);
-
-   maxv = stbi__pnm_getinteger(s, &c);  // read max value
-
-   if (maxv > 255)
-      return stbi__err("max value > 255", "PPM image not 8-bit");
-   else
-      return 1;
-}
-#endif
-
-static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp)
-{
-   #ifndef STBI_NO_JPEG
-   if (stbi__jpeg_info(s, x, y, comp)) return 1;
-   #endif
-
-   #ifndef STBI_NO_PNG
-   if (stbi__png_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_GIF
-   if (stbi__gif_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_BMP
-   if (stbi__bmp_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PIC
-   if (stbi__pic_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PNM
-   if (stbi__pnm_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_info(s, x, y, comp))  return 1;
-   #endif
-
-   // test tga last because it's a crappy test!
-   #ifndef STBI_NO_TGA
-   if (stbi__tga_info(s, x, y, comp))
-       return 1;
-   #endif
-   return stbi__err("unknown image type", "Image not of any known type, or corrupt");
-}
-
-static int stbi__is_16_main(stbi__context *s)
-{
-   #ifndef STBI_NO_PNG
-   if (stbi__png_is16(s))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_is16(s))  return 1;
-   #endif
-
-   return 0;
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp)
-{
-    FILE *f = stbi__fopen(filename, "rb");
-    int result;
-    if (!f) return stbi__err("can't fopen", "Unable to open file");
-    result = stbi_info_from_file(f, x, y, comp);
-    fclose(f);
-    return result;
-}
-
-STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp)
-{
-   int r;
-   stbi__context s;
-   long pos = ftell(f);
-   stbi__start_file(&s, f);
-   r = stbi__info_main(&s,x,y,comp);
-   fseek(f,pos,SEEK_SET);
-   return r;
-}
-
-STBIDEF int stbi_is_16_bit(char const *filename)
-{
-    FILE *f = stbi__fopen(filename, "rb");
-    int result;
-    if (!f) return stbi__err("can't fopen", "Unable to open file");
-    result = stbi_is_16_bit_from_file(f);
-    fclose(f);
-    return result;
-}
-
-STBIDEF int stbi_is_16_bit_from_file(FILE *f)
-{
-   int r;
-   stbi__context s;
-   long pos = ftell(f);
-   stbi__start_file(&s, f);
-   r = stbi__is_16_main(&s);
-   fseek(f,pos,SEEK_SET);
-   return r;
-}
-#endif // !STBI_NO_STDIO
-
-STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__info_main(&s,x,y,comp);
-}
-
-STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
-   return stbi__info_main(&s,x,y,comp);
-}
-
-STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__is_16_main(&s);
-}
-
-STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
-   return stbi__is_16_main(&s);
-}
-
-#endif // STB_IMAGE_IMPLEMENTATION
-
-/*
-   revision history:
-      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
-      2.19  (2018-02-11) fix warning
-      2.18  (2018-01-30) fix warnings
-      2.17  (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug
-                         1-bit BMP
-                         *_is_16_bit api
-                         avoid warnings
-      2.16  (2017-07-23) all functions have 16-bit variants;
-                         STBI_NO_STDIO works again;
-                         compilation fixes;
-                         fix rounding in unpremultiply;
-                         optimize vertical flip;
-                         disable raw_len validation;
-                         documentation fixes
-      2.15  (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode;
-                         warning fixes; disable run-time SSE detection on gcc;
-                         uniform handling of optional "return" values;
-                         thread-safe initialization of zlib tables
-      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
-      2.13  (2016-11-29) add 16-bit API, only supported for PNG right now
-      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
-      2.11  (2016-04-02) allocate large structures on the stack
-                         remove white matting for transparent PSD
-                         fix reported channel count for PNG & BMP
-                         re-enable SSE2 in non-gcc 64-bit
-                         support RGB-formatted JPEG
-                         read 16-bit PNGs (only as 8-bit)
-      2.10  (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED
-      2.09  (2016-01-16) allow comments in PNM files
-                         16-bit-per-pixel TGA (not bit-per-component)
-                         info() for TGA could break due to .hdr handling
-                         info() for BMP to shares code instead of sloppy parse
-                         can use STBI_REALLOC_SIZED if allocator doesn't support realloc
-                         code cleanup
-      2.08  (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA
-      2.07  (2015-09-13) fix compiler warnings
-                         partial animated GIF support
-                         limited 16-bpc PSD support
-                         #ifdef unused functions
-                         bug with < 92 byte PIC,PNM,HDR,TGA
-      2.06  (2015-04-19) fix bug where PSD returns wrong '*comp' value
-      2.05  (2015-04-19) fix bug in progressive JPEG handling, fix warning
-      2.04  (2015-04-15) try to re-enable SIMD on MinGW 64-bit
-      2.03  (2015-04-12) extra corruption checking (mmozeiko)
-                         stbi_set_flip_vertically_on_load (nguillemot)
-                         fix NEON support; fix mingw support
-      2.02  (2015-01-19) fix incorrect assert, fix warning
-      2.01  (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2
-      2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG
-      2.00  (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg)
-                         progressive JPEG (stb)
-                         PGM/PPM support (Ken Miller)
-                         STBI_MALLOC,STBI_REALLOC,STBI_FREE
-                         GIF bugfix -- seemingly never worked
-                         STBI_NO_*, STBI_ONLY_*
-      1.48  (2014-12-14) fix incorrectly-named assert()
-      1.47  (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb)
-                         optimize PNG (ryg)
-                         fix bug in interlaced PNG with user-specified channel count (stb)
-      1.46  (2014-08-26)
-              fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG
-      1.45  (2014-08-16)
-              fix MSVC-ARM internal compiler error by wrapping malloc
-      1.44  (2014-08-07)
-              various warning fixes from Ronny Chevalier
-      1.43  (2014-07-15)
-              fix MSVC-only compiler problem in code changed in 1.42
-      1.42  (2014-07-09)
-              don't define _CRT_SECURE_NO_WARNINGS (affects user code)
-              fixes to stbi__cleanup_jpeg path
-              added STBI_ASSERT to avoid requiring assert.h
-      1.41  (2014-06-25)
-              fix search&replace from 1.36 that messed up comments/error messages
-      1.40  (2014-06-22)
-              fix gcc struct-initialization warning
-      1.39  (2014-06-15)
-              fix to TGA optimization when req_comp != number of components in TGA;
-              fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite)
-              add support for BMP version 5 (more ignored fields)
-      1.38  (2014-06-06)
-              suppress MSVC warnings on integer casts truncating values
-              fix accidental rename of 'skip' field of I/O
-      1.37  (2014-06-04)
-              remove duplicate typedef
-      1.36  (2014-06-03)
-              convert to header file single-file library
-              if de-iphone isn't set, load iphone images color-swapped instead of returning NULL
-      1.35  (2014-05-27)
-              various warnings
-              fix broken STBI_SIMD path
-              fix bug where stbi_load_from_file no longer left file pointer in correct place
-              fix broken non-easy path for 32-bit BMP (possibly never used)
-              TGA optimization by Arseny Kapoulkine
-      1.34  (unknown)
-              use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case
-      1.33  (2011-07-14)
-              make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements
-      1.32  (2011-07-13)
-              support for "info" function for all supported filetypes (SpartanJ)
-      1.31  (2011-06-20)
-              a few more leak fixes, bug in PNG handling (SpartanJ)
-      1.30  (2011-06-11)
-              added ability to load files via callbacks to accomidate custom input streams (Ben Wenger)
-              removed deprecated format-specific test/load functions
-              removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway
-              error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha)
-              fix inefficiency in decoding 32-bit BMP (David Woo)
-      1.29  (2010-08-16)
-              various warning fixes from Aurelien Pocheville
-      1.28  (2010-08-01)
-              fix bug in GIF palette transparency (SpartanJ)
-      1.27  (2010-08-01)
-              cast-to-stbi_uc to fix warnings
-      1.26  (2010-07-24)
-              fix bug in file buffering for PNG reported by SpartanJ
-      1.25  (2010-07-17)
-              refix trans_data warning (Won Chun)
-      1.24  (2010-07-12)
-              perf improvements reading from files on platforms with lock-heavy fgetc()
-              minor perf improvements for jpeg
-              deprecated type-specific functions so we'll get feedback if they're needed
-              attempt to fix trans_data warning (Won Chun)
-      1.23    fixed bug in iPhone support
-      1.22  (2010-07-10)
-              removed image *writing* support
-              stbi_info support from Jetro Lauha
-              GIF support from Jean-Marc Lienher
-              iPhone PNG-extensions from James Brown
-              warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva)
-      1.21    fix use of 'stbi_uc' in header (reported by jon blow)
-      1.20    added support for Softimage PIC, by Tom Seddon
-      1.19    bug in interlaced PNG corruption check (found by ryg)
-      1.18  (2008-08-02)
-              fix a threading bug (local mutable static)
-      1.17    support interlaced PNG
-      1.16    major bugfix - stbi__convert_format converted one too many pixels
-      1.15    initialize some fields for thread safety
-      1.14    fix threadsafe conversion bug
-              header-file-only version (#define STBI_HEADER_FILE_ONLY before including)
-      1.13    threadsafe
-      1.12    const qualifiers in the API
-      1.11    Support installable IDCT, colorspace conversion routines
-      1.10    Fixes for 64-bit (don't use "unsigned long")
-              optimized upsampling by Fabian "ryg" Giesen
-      1.09    Fix format-conversion for PSD code (bad global variables!)
-      1.08    Thatcher Ulrich's PSD code integrated by Nicolas Schulz
-      1.07    attempt to fix C++ warning/errors again
-      1.06    attempt to fix C++ warning/errors again
-      1.05    fix TGA loading to return correct *comp and use good luminance calc
-      1.04    default float alpha is 1, not 255; use 'void *' for stbi_image_free
-      1.03    bugfixes to STBI_NO_STDIO, STBI_NO_HDR
-      1.02    support for (subset of) HDR files, float interface for preferred access to them
-      1.01    fix bug: possible bug in handling right-side up bmps... not sure
-              fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all
-      1.00    interface to zlib that skips zlib header
-      0.99    correct handling of alpha in palette
-      0.98    TGA loader by lonesock; dynamically add loaders (untested)
-      0.97    jpeg errors on too large a file; also catch another malloc failure
-      0.96    fix detection of invalid v value - particleman@mollyrocket forum
-      0.95    during header scan, seek to markers in case of padding
-      0.94    STBI_NO_STDIO to disable stdio usage; rename all #defines the same
-      0.93    handle jpegtran output; verbose errors
-      0.92    read 4,8,16,24,32-bit BMP files of several formats
-      0.91    output 24-bit Windows 3.0 BMP files
-      0.90    fix a few more warnings; bump version number to approach 1.0
-      0.61    bugfixes due to Marc LeBlanc, Christopher Lloyd
-      0.60    fix compiling as c++
-      0.59    fix warnings: merge Dave Moore's -Wall fixes
-      0.58    fix bug: zlib uncompressed mode len/nlen was wrong endian
-      0.57    fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available
-      0.56    fix bug: zlib uncompressed mode len vs. nlen
-      0.55    fix bug: restart_interval not initialized to 0
-      0.54    allow NULL for 'int *comp'
-      0.53    fix bug in png 3->4; speedup png decoding
-      0.52    png handles req_comp=3,4 directly; minor cleanup; jpeg comments
-      0.51    obey req_comp requests, 1-component jpegs return as 1-component,
-              on 'test' only check type, not whether we support this variant
-      0.50  (2006-11-19)
-              first released version
-*/
-
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_image_resize.h b/raylib/external/stb_image_resize.h
deleted file mode 100644 (file)
index 42a8efb..0000000
+++ /dev/null
@@ -1,2631 +0,0 @@
-/* stb_image_resize - v0.96 - public domain image resizing
-   by Jorge L Rodriguez (@VinoBS) - 2014
-   http://github.com/nothings/stb
-
-   Written with emphasis on usability, portability, and efficiency. (No
-   SIMD or threads, so it be easily outperformed by libs that use those.)
-   Only scaling and translation is supported, no rotations or shears.
-   Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation.
-
-   COMPILING & LINKING
-      In one C/C++ file that #includes this file, do this:
-         #define STB_IMAGE_RESIZE_IMPLEMENTATION
-      before the #include. That will create the implementation in that file.
-
-   QUICKSTART
-      stbir_resize_uint8(      input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0, num_channels)
-      stbir_resize_float(...)
-      stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0,
-                               num_channels , alpha_chan  , 0)
-      stbir_resize_uint8_srgb_edgemode(
-                               input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0,
-                               num_channels , alpha_chan  , 0, STBIR_EDGE_CLAMP)
-                                                            // WRAP/REFLECT/ZERO
-
-   FULL API
-      See the "header file" section of the source for API documentation.
-
-   ADDITIONAL DOCUMENTATION
-
-      SRGB & FLOATING POINT REPRESENTATION
-         The sRGB functions presume IEEE floating point. If you do not have
-         IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use
-         a slower implementation.
-
-      MEMORY ALLOCATION
-         The resize functions here perform a single memory allocation using
-         malloc. To control the memory allocation, before the #include that
-         triggers the implementation, do:
-
-            #define STBIR_MALLOC(size,context) ...
-            #define STBIR_FREE(ptr,context)   ...
-
-         Each resize function makes exactly one call to malloc/free, so to use
-         temp memory, store the temp memory in the context and return that.
-
-      ASSERT
-         Define STBIR_ASSERT(boolval) to override assert() and not use assert.h
-
-      OPTIMIZATION
-         Define STBIR_SATURATE_INT to compute clamp values in-range using
-         integer operations instead of float operations. This may be faster
-         on some platforms.
-
-      DEFAULT FILTERS
-         For functions which don't provide explicit control over what filters
-         to use, you can change the compile-time defaults with
-
-            #define STBIR_DEFAULT_FILTER_UPSAMPLE     STBIR_FILTER_something
-            #define STBIR_DEFAULT_FILTER_DOWNSAMPLE   STBIR_FILTER_something
-
-         See stbir_filter in the header-file section for the list of filters.
-
-      NEW FILTERS
-         A number of 1D filter kernels are used. For a list of
-         supported filters see the stbir_filter enum. To add a new filter,
-         write a filter function and add it to stbir__filter_info_table.
-
-      PROGRESS
-         For interactive use with slow resize operations, you can install
-         a progress-report callback:
-
-            #define STBIR_PROGRESS_REPORT(val)   some_func(val)
-
-         The parameter val is a float which goes from 0 to 1 as progress is made.
-
-         For example:
-
-            static void my_progress_report(float progress);
-            #define STBIR_PROGRESS_REPORT(val) my_progress_report(val)
-
-            #define STB_IMAGE_RESIZE_IMPLEMENTATION
-            #include "stb_image_resize.h"
-
-            static void my_progress_report(float progress)
-            {
-               printf("Progress: %f%%\n", progress*100);
-            }
-
-      MAX CHANNELS
-         If your image has more than 64 channels, define STBIR_MAX_CHANNELS
-         to the max you'll have.
-
-      ALPHA CHANNEL
-         Most of the resizing functions provide the ability to control how
-         the alpha channel of an image is processed. The important things
-         to know about this:
-
-         1. The best mathematically-behaved version of alpha to use is
-         called "premultiplied alpha", in which the other color channels
-         have had the alpha value multiplied in. If you use premultiplied
-         alpha, linear filtering (such as image resampling done by this
-         library, or performed in texture units on GPUs) does the "right
-         thing". While premultiplied alpha is standard in the movie CGI
-         industry, it is still uncommon in the videogame/real-time world.
-
-         If you linearly filter non-premultiplied alpha, strange effects
-         occur. (For example, the 50/50 average of 99% transparent bright green
-         and 1% transparent black produces 50% transparent dark green when
-         non-premultiplied, whereas premultiplied it produces 50%
-         transparent near-black. The former introduces green energy
-         that doesn't exist in the source image.)
-
-         2. Artists should not edit premultiplied-alpha images; artists
-         want non-premultiplied alpha images. Thus, art tools generally output
-         non-premultiplied alpha images.
-
-         3. You will get best results in most cases by converting images
-         to premultiplied alpha before processing them mathematically.
-
-         4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the
-         resizer does not do anything special for the alpha channel;
-         it is resampled identically to other channels. This produces
-         the correct results for premultiplied-alpha images, but produces
-         less-than-ideal results for non-premultiplied-alpha images.
-
-         5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED,
-         then the resizer weights the contribution of input pixels
-         based on their alpha values, or, equivalently, it multiplies
-         the alpha value into the color channels, resamples, then divides
-         by the resultant alpha value. Input pixels which have alpha=0 do
-         not contribute at all to output pixels unless _all_ of the input
-         pixels affecting that output pixel have alpha=0, in which case
-         the result for that pixel is the same as it would be without
-         STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for
-         input images in integer formats. For input images in float format,
-         input pixels with alpha=0 have no effect, and output pixels
-         which have alpha=0 will be 0 in all channels. (For float images,
-         you can manually achieve the same result by adding a tiny epsilon
-         value to the alpha channel of every image, and then subtracting
-         or clamping it at the end.)
-
-         6. You can suppress the behavior described in #5 and make
-         all-0-alpha pixels have 0 in all channels by #defining
-         STBIR_NO_ALPHA_EPSILON.
-
-         7. You can separately control whether the alpha channel is
-         interpreted as linear or affected by the colorspace. By default
-         it is linear; you almost never want to apply the colorspace.
-         (For example, graphics hardware does not apply sRGB conversion
-         to the alpha channel.)
-
-   CONTRIBUTORS
-      Jorge L Rodriguez: Implementation
-      Sean Barrett: API design, optimizations
-      Aras Pranckevicius: bugfix
-      Nathan Reed: warning fixes
-
-   REVISIONS
-      0.97 (2020-02-02) fixed warning
-      0.96 (2019-03-04) fixed warnings
-      0.95 (2017-07-23) fixed warnings
-      0.94 (2017-03-18) fixed warnings
-      0.93 (2017-03-03) fixed bug with certain combinations of heights
-      0.92 (2017-01-02) fix integer overflow on large (>2GB) images
-      0.91 (2016-04-02) fix warnings; fix handling of subpixel regions
-      0.90 (2014-09-17) first released version
-
-   LICENSE
-     See end of file for license information.
-
-   TODO
-      Don't decode all of the image data when only processing a partial tile
-      Don't use full-width decode buffers when only processing a partial tile
-      When processing wide images, break processing into tiles so data fits in L1 cache
-      Installable filters?
-      Resize that respects alpha test coverage
-         (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage:
-         https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp )
-*/
-
-#ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-#define STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-
-#ifdef _MSC_VER
-typedef unsigned char  stbir_uint8;
-typedef unsigned short stbir_uint16;
-typedef unsigned int   stbir_uint32;
-#else
-#include <stdint.h>
-typedef uint8_t  stbir_uint8;
-typedef uint16_t stbir_uint16;
-typedef uint32_t stbir_uint32;
-#endif
-
-#ifndef STBIRDEF
-#ifdef STB_IMAGE_RESIZE_STATIC
-#define STBIRDEF static
-#else
-#ifdef __cplusplus
-#define STBIRDEF extern "C"
-#else
-#define STBIRDEF extern
-#endif
-#endif
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Easy-to-use API:
-//
-//     * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4)
-//     * input_w is input image width (x-axis), input_h is input image height (y-axis)
-//     * stride is the offset between successive rows of image data in memory, in bytes. you can
-//       specify 0 to mean packed continuously in memory
-//     * alpha channel is treated identically to other channels.
-//     * colorspace is linear or sRGB as specified by function name
-//     * returned result is 1 for success or 0 in case of an error.
-//       #define STBIR_ASSERT() to trigger an assert on parameter validation errors.
-//     * Memory required grows approximately linearly with input and output size, but with
-//       discontinuities at input_w == output_w and input_h == output_h.
-//     * These functions use a "default" resampling filter defined at compile time. To change the filter,
-//       you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE
-//       and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API.
-
-STBIRDEF int stbir_resize_uint8(     const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels);
-
-STBIRDEF int stbir_resize_float(     const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           float *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels);
-
-
-// The following functions interpret image data as gamma-corrected sRGB.
-// Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel,
-// or otherwise provide the index of the alpha channel. Flags value
-// of 0 will probably do the right thing if you're not sure what
-// the flags mean.
-
-#define STBIR_ALPHA_CHANNEL_NONE       -1
-
-// Set this flag if your texture has premultiplied alpha. Otherwise, stbir will
-// use alpha-weighted resampling (effectively premultiplying, resampling,
-// then unpremultiplying).
-#define STBIR_FLAG_ALPHA_PREMULTIPLIED    (1 << 0)
-// The specified alpha channel should be handled as gamma-corrected value even
-// when doing sRGB operations.
-#define STBIR_FLAG_ALPHA_USES_COLORSPACE  (1 << 1)
-
-STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels, int alpha_channel, int flags);
-
-
-typedef enum
-{
-    STBIR_EDGE_CLAMP   = 1,
-    STBIR_EDGE_REFLECT = 2,
-    STBIR_EDGE_WRAP    = 3,
-    STBIR_EDGE_ZERO    = 4,
-} stbir_edge;
-
-// This function adds the ability to specify how requests to sample off the edge of the image are handled.
-STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                                    unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                              int num_channels, int alpha_channel, int flags,
-                                              stbir_edge edge_wrap_mode);
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Medium-complexity API
-//
-// This extends the easy-to-use API as follows:
-//
-//     * Alpha-channel can be processed separately
-//       * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE
-//         * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT)
-//         * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)
-//     * Filter can be selected explicitly
-//     * uint16 image type
-//     * sRGB colorspace available for all types
-//     * context parameter for passing to STBIR_MALLOC
-
-typedef enum
-{
-    STBIR_FILTER_DEFAULT      = 0,  // use same filter type that easy-to-use API chooses
-    STBIR_FILTER_BOX          = 1,  // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios
-    STBIR_FILTER_TRIANGLE     = 2,  // On upsampling, produces same results as bilinear texture filtering
-    STBIR_FILTER_CUBICBSPLINE = 3,  // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque
-    STBIR_FILTER_CATMULLROM   = 4,  // An interpolating cubic spline
-    STBIR_FILTER_MITCHELL     = 5,  // Mitchell-Netrevalli filter with B=1/3, C=1/3
-} stbir_filter;
-
-typedef enum
-{
-    STBIR_COLORSPACE_LINEAR,
-    STBIR_COLORSPACE_SRGB,
-
-    STBIR_MAX_COLORSPACES,
-} stbir_colorspace;
-
-// The following functions are all identical except for the type of the image data
-
-STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                               unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels  , int input_w , int input_h , int input_stride_in_bytes,
-                                               stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-STBIRDEF int stbir_resize_float_generic( const float *input_pixels         , int input_w , int input_h , int input_stride_in_bytes,
-                                               float *output_pixels        , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Full-complexity API
-//
-// This extends the medium API as follows:
-//
-//       * uint32 image type
-//     * not typesafe
-//     * separate filter types for each axis
-//     * separate edge modes for each axis
-//     * can specify scale explicitly for subpixel correctness
-//     * can specify image source tile using texture coordinates
-
-typedef enum
-{
-    STBIR_TYPE_UINT8 ,
-    STBIR_TYPE_UINT16,
-    STBIR_TYPE_UINT32,
-    STBIR_TYPE_FLOAT ,
-
-    STBIR_MAX_TYPES
-} stbir_datatype;
-
-STBIRDEF int stbir_resize(         const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context);
-
-STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float x_scale, float y_scale,
-                                   float x_offset, float y_offset);
-
-STBIRDEF int stbir_resize_region(  const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float s0, float t0, float s1, float t1);
-// (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use.
-
-//
-//
-////   end header file   /////////////////////////////////////////////////////
-#endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-
-
-
-
-
-#ifdef STB_IMAGE_RESIZE_IMPLEMENTATION
-
-#ifndef STBIR_ASSERT
-#include <assert.h>
-#define STBIR_ASSERT(x) assert(x)
-#endif
-
-// For memset
-#include <string.h>
-
-#include <math.h>
-
-#ifndef STBIR_MALLOC
-#include <stdlib.h>
-// use comma operator to evaluate c, to avoid "unused parameter" warnings
-#define STBIR_MALLOC(size,c) ((void)(c), malloc(size))
-#define STBIR_FREE(ptr,c)    ((void)(c), free(ptr))
-#endif
-
-#ifndef _MSC_VER
-#ifdef __cplusplus
-#define stbir__inline inline
-#else
-#define stbir__inline
-#endif
-#else
-#define stbir__inline __forceinline
-#endif
-
-
-// should produce compiler error if size is wrong
-typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1];
-
-#ifdef _MSC_VER
-#define STBIR__NOTUSED(v)  (void)(v)
-#else
-#define STBIR__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-#define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0]))
-
-#ifndef STBIR_DEFAULT_FILTER_UPSAMPLE
-#define STBIR_DEFAULT_FILTER_UPSAMPLE    STBIR_FILTER_CATMULLROM
-#endif
-
-#ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE
-#define STBIR_DEFAULT_FILTER_DOWNSAMPLE  STBIR_FILTER_MITCHELL
-#endif
-
-#ifndef STBIR_PROGRESS_REPORT
-#define STBIR_PROGRESS_REPORT(float_0_to_1)
-#endif
-
-#ifndef STBIR_MAX_CHANNELS
-#define STBIR_MAX_CHANNELS 64
-#endif
-
-#if STBIR_MAX_CHANNELS > 65536
-#error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536."
-// because we store the indices in 16-bit variables
-#endif
-
-// This value is added to alpha just before premultiplication to avoid
-// zeroing out color values. It is equivalent to 2^-80. If you don't want
-// that behavior (it may interfere if you have floating point images with
-// very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to
-// disable it.
-#ifndef STBIR_ALPHA_EPSILON
-#define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20))
-#endif
-
-
-
-#ifdef _MSC_VER
-#define STBIR__UNUSED_PARAM(v)  (void)(v)
-#else
-#define STBIR__UNUSED_PARAM(v)  (void)sizeof(v)
-#endif
-
-// must match stbir_datatype
-static unsigned char stbir__type_size[] = {
-    1, // STBIR_TYPE_UINT8
-    2, // STBIR_TYPE_UINT16
-    4, // STBIR_TYPE_UINT32
-    4, // STBIR_TYPE_FLOAT
-};
-
-// Kernel function centered at 0
-typedef float (stbir__kernel_fn)(float x, float scale);
-typedef float (stbir__support_fn)(float scale);
-
-typedef struct
-{
-    stbir__kernel_fn* kernel;
-    stbir__support_fn* support;
-} stbir__filter_info;
-
-// When upsampling, the contributors are which source pixels contribute.
-// When downsampling, the contributors are which destination pixels are contributed to.
-typedef struct
-{
-    int n0; // First contributing pixel
-    int n1; // Last contributing pixel
-} stbir__contributors;
-
-typedef struct
-{
-    const void* input_data;
-    int input_w;
-    int input_h;
-    int input_stride_bytes;
-
-    void* output_data;
-    int output_w;
-    int output_h;
-    int output_stride_bytes;
-
-    float s0, t0, s1, t1;
-
-    float horizontal_shift; // Units: output pixels
-    float vertical_shift;   // Units: output pixels
-    float horizontal_scale;
-    float vertical_scale;
-
-    int channels;
-    int alpha_channel;
-    stbir_uint32 flags;
-    stbir_datatype type;
-    stbir_filter horizontal_filter;
-    stbir_filter vertical_filter;
-    stbir_edge edge_horizontal;
-    stbir_edge edge_vertical;
-    stbir_colorspace colorspace;
-
-    stbir__contributors* horizontal_contributors;
-    float* horizontal_coefficients;
-
-    stbir__contributors* vertical_contributors;
-    float* vertical_coefficients;
-
-    int decode_buffer_pixels;
-    float* decode_buffer;
-
-    float* horizontal_buffer;
-
-    // cache these because ceil/floor are inexplicably showing up in profile
-    int horizontal_coefficient_width;
-    int vertical_coefficient_width;
-    int horizontal_filter_pixel_width;
-    int vertical_filter_pixel_width;
-    int horizontal_filter_pixel_margin;
-    int vertical_filter_pixel_margin;
-    int horizontal_num_contributors;
-    int vertical_num_contributors;
-
-    int ring_buffer_length_bytes;   // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter)
-    int ring_buffer_num_entries;    // Total number of entries in the ring buffer.
-    int ring_buffer_first_scanline;
-    int ring_buffer_last_scanline;
-    int ring_buffer_begin_index;    // first_scanline is at this index in the ring buffer
-    float* ring_buffer;
-
-    float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds.
-
-    int horizontal_contributors_size;
-    int horizontal_coefficients_size;
-    int vertical_contributors_size;
-    int vertical_coefficients_size;
-    int decode_buffer_size;
-    int horizontal_buffer_size;
-    int ring_buffer_size;
-    int encode_buffer_size;
-} stbir__info;
-
-
-static const float stbir__max_uint8_as_float  = 255.0f;
-static const float stbir__max_uint16_as_float = 65535.0f;
-static const double stbir__max_uint32_as_float = 4294967295.0;
-
-
-static stbir__inline int stbir__min(int a, int b)
-{
-    return a < b ? a : b;
-}
-
-static stbir__inline float stbir__saturate(float x)
-{
-    if (x < 0)
-        return 0;
-
-    if (x > 1)
-        return 1;
-
-    return x;
-}
-
-#ifdef STBIR_SATURATE_INT
-static stbir__inline stbir_uint8 stbir__saturate8(int x)
-{
-    if ((unsigned int) x <= 255)
-        return x;
-
-    if (x < 0)
-        return 0;
-
-    return 255;
-}
-
-static stbir__inline stbir_uint16 stbir__saturate16(int x)
-{
-    if ((unsigned int) x <= 65535)
-        return x;
-
-    if (x < 0)
-        return 0;
-
-    return 65535;
-}
-#endif
-
-static float stbir__srgb_uchar_to_linear_float[256] = {
-    0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f,
-    0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f,
-    0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f,
-    0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f,
-    0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f,
-    0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f,
-    0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f,
-    0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f,
-    0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f,
-    0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f,
-    0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f,
-    0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f,
-    0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f,
-    0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f,
-    0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f,
-    0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f,
-    0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f,
-    0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f,
-    0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f,
-    0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f,
-    0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f,
-    0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f,
-    0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f,
-    0.982251f, 0.991102f, 1.0f
-};
-
-static float stbir__srgb_to_linear(float f)
-{
-    if (f <= 0.04045f)
-        return f / 12.92f;
-    else
-        return (float)pow((f + 0.055f) / 1.055f, 2.4f);
-}
-
-static float stbir__linear_to_srgb(float f)
-{
-    if (f <= 0.0031308f)
-        return f * 12.92f;
-    else
-        return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f;
-}
-
-#ifndef STBIR_NON_IEEE_FLOAT
-// From https://gist.github.com/rygorous/2203834
-
-typedef union
-{
-    stbir_uint32 u;
-    float f;
-} stbir__FP32;
-
-static const stbir_uint32 fp32_to_srgb8_tab4[104] = {
-    0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d,
-    0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a,
-    0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033,
-    0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067,
-    0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5,
-    0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2,
-    0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143,
-    0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af,
-    0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240,
-    0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300,
-    0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401,
-    0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559,
-    0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723,
-};
-
-static stbir_uint8 stbir__linear_to_srgb_uchar(float in)
-{
-    static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps
-    static const stbir__FP32 minval = { (127-13) << 23 };
-    stbir_uint32 tab,bias,scale,t;
-    stbir__FP32 f;
-
-    // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively.
-    // The tests are carefully written so that NaNs map to 0, same as in the reference
-    // implementation.
-    if (!(in > minval.f)) // written this way to catch NaNs
-        in = minval.f;
-    if (in > almostone.f)
-        in = almostone.f;
-
-    // Do the table lookup and unpack bias, scale
-    f.f = in;
-    tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20];
-    bias = (tab >> 16) << 9;
-    scale = tab & 0xffff;
-
-    // Grab next-highest mantissa bits and perform linear interpolation
-    t = (f.u >> 12) & 0xff;
-    return (unsigned char) ((bias + scale*t) >> 16);
-}
-
-#else
-// sRGB transition values, scaled by 1<<28
-static int stbir__srgb_offset_to_linear_scaled[256] =
-{
-            0,     40738,    122216,    203693,    285170,    366648,    448125,    529603,
-       611080,    692557,    774035,    855852,    942009,   1033024,   1128971,   1229926,
-      1335959,   1447142,   1563542,   1685229,   1812268,   1944725,   2082664,   2226148,
-      2375238,   2529996,   2690481,   2856753,   3028870,   3206888,   3390865,   3580856,
-      3776916,   3979100,   4187460,   4402049,   4622919,   4850123,   5083710,   5323731,
-      5570236,   5823273,   6082892,   6349140,   6622065,   6901714,   7188133,   7481369,
-      7781466,   8088471,   8402427,   8723380,   9051372,   9386448,   9728650,  10078021,
-     10434603,  10798439,  11169569,  11548036,  11933879,  12327139,  12727857,  13136073,
-     13551826,  13975156,  14406100,  14844697,  15290987,  15745007,  16206795,  16676389,
-     17153826,  17639142,  18132374,  18633560,  19142734,  19659934,  20185196,  20718552,
-     21260042,  21809696,  22367554,  22933648,  23508010,  24090680,  24681686,  25281066,
-     25888850,  26505076,  27129772,  27762974,  28404716,  29055026,  29713942,  30381490,
-     31057708,  31742624,  32436272,  33138682,  33849884,  34569912,  35298800,  36036568,
-     36783260,  37538896,  38303512,  39077136,  39859796,  40651528,  41452360,  42262316,
-     43081432,  43909732,  44747252,  45594016,  46450052,  47315392,  48190064,  49074096,
-     49967516,  50870356,  51782636,  52704392,  53635648,  54576432,  55526772,  56486700,
-     57456236,  58435408,  59424248,  60422780,  61431036,  62449032,  63476804,  64514376,
-     65561776,  66619028,  67686160,  68763192,  69850160,  70947088,  72053992,  73170912,
-     74297864,  75434880,  76581976,  77739184,  78906536,  80084040,  81271736,  82469648,
-     83677792,  84896192,  86124888,  87363888,  88613232,  89872928,  91143016,  92423512,
-     93714432,  95015816,  96327688,  97650056,  98982952, 100326408, 101680440, 103045072,
-    104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544,
-    115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832,
-    127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528,
-    140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968,
-    154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184,
-    168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992,
-    183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968,
-    199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480,
-    215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656,
-    232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464,
-    250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664,
-};
-
-static stbir_uint8 stbir__linear_to_srgb_uchar(float f)
-{
-    int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp
-    int v = 0;
-    int i;
-
-    // Refine the guess with a short binary search.
-    i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-
-    return (stbir_uint8) v;
-}
-#endif
-
-static float stbir__filter_trapezoid(float x, float scale)
-{
-    float halfscale = scale / 2;
-    float t = 0.5f + halfscale;
-    STBIR_ASSERT(scale <= 1);
-
-    x = (float)fabs(x);
-
-    if (x >= t)
-        return 0;
-    else
-    {
-        float r = 0.5f - halfscale;
-        if (x <= r)
-            return 1;
-        else
-            return (t - x) / scale;
-    }
-}
-
-static float stbir__support_trapezoid(float scale)
-{
-    STBIR_ASSERT(scale <= 1);
-    return 0.5f + scale / 2;
-}
-
-static float stbir__filter_triangle(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x <= 1.0f)
-        return 1 - x;
-    else
-        return 0;
-}
-
-static float stbir__filter_cubic(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return (4 + x*x*(3*x - 6))/6;
-    else if (x < 2.0f)
-        return (8 + x*(-12 + x*(6 - x)))/6;
-
-    return (0.0f);
-}
-
-static float stbir__filter_catmullrom(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return 1 - x*x*(2.5f - 1.5f*x);
-    else if (x < 2.0f)
-        return 2 - x*(4 + x*(0.5f*x - 2.5f));
-
-    return (0.0f);
-}
-
-static float stbir__filter_mitchell(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return (16 + x*x*(21 * x - 36))/18;
-    else if (x < 2.0f)
-        return (32 + x*(-60 + x*(36 - 7*x)))/18;
-
-    return (0.0f);
-}
-
-static float stbir__support_zero(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 0;
-}
-
-static float stbir__support_one(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 1;
-}
-
-static float stbir__support_two(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 2;
-}
-
-static stbir__filter_info stbir__filter_info_table[] = {
-        { NULL,                     stbir__support_zero },
-        { stbir__filter_trapezoid,  stbir__support_trapezoid },
-        { stbir__filter_triangle,   stbir__support_one },
-        { stbir__filter_cubic,      stbir__support_two },
-        { stbir__filter_catmullrom, stbir__support_two },
-        { stbir__filter_mitchell,   stbir__support_two },
-};
-
-stbir__inline static int stbir__use_upsampling(float ratio)
-{
-    return ratio > 1;
-}
-
-stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info)
-{
-    return stbir__use_upsampling(stbir_info->horizontal_scale);
-}
-
-stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info)
-{
-    return stbir__use_upsampling(stbir_info->vertical_scale);
-}
-
-// This is the maximum number of input samples that can affect an output sample
-// with the given filter
-static int stbir__get_filter_pixel_width(stbir_filter filter, float scale)
-{
-    STBIR_ASSERT(filter != 0);
-    STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-
-    if (stbir__use_upsampling(scale))
-        return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2);
-    else
-        return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale);
-}
-
-// This is how much to expand buffers to account for filters seeking outside
-// the image boundaries.
-static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale)
-{
-    return stbir__get_filter_pixel_width(filter, scale) / 2;
-}
-
-static int stbir__get_coefficient_width(stbir_filter filter, float scale)
-{
-    if (stbir__use_upsampling(scale))
-        return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2);
-    else
-        return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2);
-}
-
-static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size)
-{
-    if (stbir__use_upsampling(scale))
-        return output_size;
-    else
-        return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2);
-}
-
-static int stbir__get_total_horizontal_coefficients(stbir__info* info)
-{
-    return info->horizontal_num_contributors
-         * stbir__get_coefficient_width      (info->horizontal_filter, info->horizontal_scale);
-}
-
-static int stbir__get_total_vertical_coefficients(stbir__info* info)
-{
-    return info->vertical_num_contributors
-         * stbir__get_coefficient_width      (info->vertical_filter, info->vertical_scale);
-}
-
-static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n)
-{
-    return &contributors[n];
-}
-
-// For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample,
-// if you change it here change it there too.
-static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c)
-{
-    int width = stbir__get_coefficient_width(filter, scale);
-    return &coefficients[width*n + c];
-}
-
-static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max)
-{
-    switch (edge)
-    {
-    case STBIR_EDGE_ZERO:
-        return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later
-
-    case STBIR_EDGE_CLAMP:
-        if (n < 0)
-            return 0;
-
-        if (n >= max)
-            return max - 1;
-
-        return n; // NOTREACHED
-
-    case STBIR_EDGE_REFLECT:
-    {
-        if (n < 0)
-        {
-            if (n < max)
-                return -n;
-            else
-                return max - 1;
-        }
-
-        if (n >= max)
-        {
-            int max2 = max * 2;
-            if (n >= max2)
-                return 0;
-            else
-                return max2 - n - 1;
-        }
-
-        return n; // NOTREACHED
-    }
-
-    case STBIR_EDGE_WRAP:
-        if (n >= 0)
-            return (n % max);
-        else
-        {
-            int m = (-n) % max;
-
-            if (m != 0)
-                m = max - m;
-
-            return (m);
-        }
-        // NOTREACHED
-
-    default:
-        STBIR_ASSERT(!"Unimplemented edge type");
-        return 0;
-    }
-}
-
-stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max)
-{
-    // avoid per-pixel switch
-    if (n >= 0 && n < max)
-        return n;
-    return stbir__edge_wrap_slow(edge, n, max);
-}
-
-// What input pixels contribute to this output pixel?
-static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out)
-{
-    float out_pixel_center = (float)n + 0.5f;
-    float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius;
-    float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius;
-
-    float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio;
-    float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio;
-
-    *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio;
-    *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5));
-    *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5));
-}
-
-// What output pixels does this input pixel contribute to?
-static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in)
-{
-    float in_pixel_center = (float)n + 0.5f;
-    float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius;
-    float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius;
-
-    float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift;
-    float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift;
-
-    *out_center_of_in = in_pixel_center * scale_ratio - out_shift;
-    *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5));
-    *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5));
-}
-
-static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group)
-{
-    int i;
-    float total_filter = 0;
-    float filter_scale;
-
-    STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
-
-    contributor->n0 = in_first_pixel;
-    contributor->n1 = in_last_pixel;
-
-    STBIR_ASSERT(contributor->n1 >= contributor->n0);
-
-    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
-    {
-        float in_pixel_center = (float)(i + in_first_pixel) + 0.5f;
-        coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale);
-
-        // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.)
-        if (i == 0 && !coefficient_group[i])
-        {
-            contributor->n0 = ++in_first_pixel;
-            i--;
-            continue;
-        }
-
-        total_filter += coefficient_group[i];
-    }
-
-    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0);
-
-    STBIR_ASSERT(total_filter > 0.9);
-    STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off.
-
-    // Make sure the sum of all coefficients is 1.
-    filter_scale = 1 / total_filter;
-
-    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
-        coefficient_group[i] *= filter_scale;
-
-    for (i = in_last_pixel - in_first_pixel; i >= 0; i--)
-    {
-        if (coefficient_group[i])
-            break;
-
-        // This line has no weight. We can skip it.
-        contributor->n1 = contributor->n0 + i - 1;
-    }
-}
-
-static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group)
-{
-    int i;
-
-     STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
-
-    contributor->n0 = out_first_pixel;
-    contributor->n1 = out_last_pixel;
-
-    STBIR_ASSERT(contributor->n1 >= contributor->n0);
-
-    for (i = 0; i <= out_last_pixel - out_first_pixel; i++)
-    {
-        float out_pixel_center = (float)(i + out_first_pixel) + 0.5f;
-        float x = out_pixel_center - out_center_of_in;
-        coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio;
-    }
-
-    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0);
-
-    for (i = out_last_pixel - out_first_pixel; i >= 0; i--)
-    {
-        if (coefficient_group[i])
-            break;
-
-        // This line has no weight. We can skip it.
-        contributor->n1 = contributor->n0 + i - 1;
-    }
-}
-
-static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size)
-{
-    int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size);
-    int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio);
-    int i, j;
-    int skip;
-
-    for (i = 0; i < output_size; i++)
-    {
-        float scale;
-        float total = 0;
-
-        for (j = 0; j < num_contributors; j++)
-        {
-            if (i >= contributors[j].n0 && i <= contributors[j].n1)
-            {
-                float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0);
-                total += coefficient;
-            }
-            else if (i < contributors[j].n0)
-                break;
-        }
-
-        STBIR_ASSERT(total > 0.9f);
-        STBIR_ASSERT(total < 1.1f);
-
-        scale = 1 / total;
-
-        for (j = 0; j < num_contributors; j++)
-        {
-            if (i >= contributors[j].n0 && i <= contributors[j].n1)
-                *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale;
-            else if (i < contributors[j].n0)
-                break;
-        }
-    }
-
-    // Optimize: Skip zero coefficients and contributions outside of image bounds.
-    // Do this after normalizing because normalization depends on the n0/n1 values.
-    for (j = 0; j < num_contributors; j++)
-    {
-        int range, max, width;
-
-        skip = 0;
-        while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0)
-            skip++;
-
-        contributors[j].n0 += skip;
-
-        while (contributors[j].n0 < 0)
-        {
-            contributors[j].n0++;
-            skip++;
-        }
-
-        range = contributors[j].n1 - contributors[j].n0 + 1;
-        max = stbir__min(num_coefficients, range);
-
-        width = stbir__get_coefficient_width(filter, scale_ratio);
-        for (i = 0; i < max; i++)
-        {
-            if (i + skip >= width)
-                break;
-
-            *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip);
-        }
-
-        continue;
-    }
-
-    // Using min to avoid writing into invalid pixels.
-    for (i = 0; i < num_contributors; i++)
-        contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1);
-}
-
-// Each scan line uses the same kernel values so we should calculate the kernel
-// values once and then we can use them for every scan line.
-static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size)
-{
-    int n;
-    int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size);
-
-    if (stbir__use_upsampling(scale_ratio))
-    {
-        float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio;
-
-        // Looping through out pixels
-        for (n = 0; n < total_contributors; n++)
-        {
-            float in_center_of_out; // Center of the current out pixel in the in pixel space
-            int in_first_pixel, in_last_pixel;
-
-            stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out);
-
-            stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0));
-        }
-    }
-    else
-    {
-        float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio;
-
-        // Looping through in pixels
-        for (n = 0; n < total_contributors; n++)
-        {
-            float out_center_of_in; // Center of the current out pixel in the in pixel space
-            int out_first_pixel, out_last_pixel;
-            int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio);
-
-            stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in);
-
-            stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0));
-        }
-
-        stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size);
-    }
-}
-
-static float* stbir__get_decode_buffer(stbir__info* stbir_info)
-{
-    // The 0 index of the decode buffer starts after the margin. This makes
-    // it okay to use negative indexes on the decode buffer.
-    return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels];
-}
-
-#define STBIR__DECODE(type, colorspace) ((int)(type) * (STBIR_MAX_COLORSPACES) + (int)(colorspace))
-
-static void stbir__decode_scanline(stbir__info* stbir_info, int n)
-{
-    int c;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int input_w = stbir_info->input_w;
-    size_t input_stride_bytes = stbir_info->input_stride_bytes;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir_edge edge_horizontal = stbir_info->edge_horizontal;
-    stbir_edge edge_vertical = stbir_info->edge_vertical;
-    size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes;
-    const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset;
-    int max_x = input_w + stbir_info->horizontal_filter_pixel_margin;
-    int decode = STBIR__DECODE(type, colorspace);
-
-    int x = -stbir_info->horizontal_filter_pixel_margin;
-
-    // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input,
-    // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO
-    if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h))
-    {
-        for (; x < max_x; x++)
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        return;
-    }
-
-    switch (decode)
-    {
-    case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float);
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float);
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float));
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float);
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c];
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]);
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel];
-        }
-
-        break;
-
-    default:
-        STBIR_ASSERT(!"Unknown type/colorspace/channels combination.");
-        break;
-    }
-
-    if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED))
-    {
-        for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-
-            // If the alpha value is 0 it will clobber the color values. Make sure it's not.
-            float alpha = decode_buffer[decode_pixel_index + alpha_channel];
-#ifndef STBIR_NO_ALPHA_EPSILON
-            if (stbir_info->type != STBIR_TYPE_FLOAT) {
-                alpha += STBIR_ALPHA_EPSILON;
-                decode_buffer[decode_pixel_index + alpha_channel] = alpha;
-            }
-#endif
-            for (c = 0; c < channels; c++)
-            {
-                if (c == alpha_channel)
-                    continue;
-
-                decode_buffer[decode_pixel_index + c] *= alpha;
-            }
-        }
-    }
-
-    if (edge_horizontal == STBIR_EDGE_ZERO)
-    {
-        for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++)
-        {
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        }
-        for (x = input_w; x < max_x; x++)
-        {
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        }
-    }
-}
-
-static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length)
-{
-    return &ring_buffer[index * ring_buffer_length];
-}
-
-static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n)
-{
-    int ring_buffer_index;
-    float* ring_buffer;
-
-    stbir_info->ring_buffer_last_scanline = n;
-
-    if (stbir_info->ring_buffer_begin_index < 0)
-    {
-        ring_buffer_index = stbir_info->ring_buffer_begin_index = 0;
-        stbir_info->ring_buffer_first_scanline = n;
-    }
-    else
-    {
-        ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries;
-        STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index);
-    }
-
-    ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float));
-    memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes);
-
-    return ring_buffer;
-}
-
-
-static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    int channels = stbir_info->channels;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors;
-    float* horizontal_coefficients = stbir_info->horizontal_coefficients;
-    int coefficient_width = stbir_info->horizontal_coefficient_width;
-
-    for (x = 0; x < output_w; x++)
-    {
-        int n0 = horizontal_contributors[x].n0;
-        int n1 = horizontal_contributors[x].n1;
-
-        int out_pixel_index = x * channels;
-        int coefficient_group = coefficient_width * x;
-        int coefficient_counter = 0;
-
-        STBIR_ASSERT(n1 >= n0);
-        STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
-
-        switch (channels) {
-            case 1:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 1;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                }
-                break;
-            case 2:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 2;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                }
-                break;
-            case 3:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 3;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                }
-                break;
-            case 4:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 4;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                    output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient;
-                }
-                break;
-            default:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * channels;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    int c;
-                    STBIR_ASSERT(coefficient != 0);
-                    for (c = 0; c < channels; c++)
-                        output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient;
-                }
-                break;
-        }
-    }
-}
-
-static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer)
-{
-    int x, k;
-    int input_w = stbir_info->input_w;
-    int channels = stbir_info->channels;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors;
-    float* horizontal_coefficients = stbir_info->horizontal_coefficients;
-    int coefficient_width = stbir_info->horizontal_coefficient_width;
-    int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin;
-    int max_x = input_w + filter_pixel_margin * 2;
-
-    STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info));
-
-    switch (channels) {
-        case 1:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 1;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 1;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                }
-            }
-            break;
-
-        case 2:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 2;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 2;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                }
-            }
-            break;
-
-        case 3:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 3;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 3;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                }
-            }
-            break;
-
-        case 4:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 4;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 4;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                    output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient;
-                }
-            }
-            break;
-
-        default:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * channels;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int c;
-                    int out_pixel_index = k * channels;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    for (c = 0; c < channels; c++)
-                        output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient;
-                }
-            }
-            break;
-    }
-}
-
-static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n)
-{
-    // Decode the nth scanline from the source image into the decode buffer.
-    stbir__decode_scanline(stbir_info, n);
-
-    // Now resample it into the ring buffer.
-    if (stbir__use_width_upsampling(stbir_info))
-        stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n));
-    else
-        stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n));
-
-    // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling.
-}
-
-static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n)
-{
-    // Decode the nth scanline from the source image into the decode buffer.
-    stbir__decode_scanline(stbir_info, n);
-
-    memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float));
-
-    // Now resample it into the horizontal buffer.
-    if (stbir__use_width_upsampling(stbir_info))
-        stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer);
-    else
-        stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer);
-
-    // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers.
-}
-
-// Get the specified scan line from the ring buffer.
-static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length)
-{
-    int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries;
-    return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length);
-}
-
-
-static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode)
-{
-    int x;
-    int n;
-    int num_nonalpha;
-    stbir_uint16 nonalpha[STBIR_MAX_CHANNELS];
-
-    if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED))
-    {
-        for (x=0; x < num_pixels; ++x)
-        {
-            int pixel_index = x*channels;
-
-            float alpha = encode_buffer[pixel_index + alpha_channel];
-            float reciprocal_alpha = alpha ? 1.0f / alpha : 0;
-
-            // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb
-            for (n = 0; n < channels; n++)
-                if (n != alpha_channel)
-                    encode_buffer[pixel_index + n] *= reciprocal_alpha;
-
-            // We added in a small epsilon to prevent the color channel from being deleted with zero alpha.
-            // Because we only add it for integer types, it will automatically be discarded on integer
-            // conversion, so we don't need to subtract it back out (which would be problematic for
-            // numeric precision reasons).
-        }
-    }
-
-    // build a table of all channels that need colorspace correction, so
-    // we don't perform colorspace correction on channels that don't need it.
-    for (x = 0, num_nonalpha = 0; x < channels; ++x)
-    {
-        if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE))
-        {
-            nonalpha[num_nonalpha++] = (stbir_uint16)x;
-        }
-    }
-
-    #define STBIR__ROUND_INT(f)    ((int)          ((f)+0.5))
-    #define STBIR__ROUND_UINT(f)   ((stbir_uint32) ((f)+0.5))
-
-    #ifdef STBIR__SATURATE_INT
-    #define STBIR__ENCODE_LINEAR8(f)   stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float ))
-    #define STBIR__ENCODE_LINEAR16(f)  stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float))
-    #else
-    #define STBIR__ENCODE_LINEAR8(f)   (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float )
-    #define STBIR__ENCODE_LINEAR16(f)  (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float)
-    #endif
-
-    switch (decode)
-    {
-        case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]);
-                }
-
-                if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]);
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]);
-            }
-
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float);
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((float*)output_buffer)[index] = encode_buffer[index];
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel];
-            }
-            break;
-
-        default:
-            STBIR_ASSERT(!"Unknown type/colorspace/channels combination.");
-            break;
-    }
-}
-
-static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    stbir__contributors* vertical_contributors = stbir_info->vertical_contributors;
-    float* vertical_coefficients = stbir_info->vertical_coefficients;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int ring_buffer_entries = stbir_info->ring_buffer_num_entries;
-    void* output_data = stbir_info->output_data;
-    float* encode_buffer = stbir_info->encode_buffer;
-    int decode = STBIR__DECODE(type, colorspace);
-    int coefficient_width = stbir_info->vertical_coefficient_width;
-    int coefficient_counter;
-    int contributor = n;
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index;
-    int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-
-    int n0,n1, output_row_start;
-    int coefficient_group = coefficient_width * contributor;
-
-    n0 = vertical_contributors[contributor].n0;
-    n1 = vertical_contributors[contributor].n1;
-
-    output_row_start = n * stbir_info->output_stride_bytes;
-
-    STBIR_ASSERT(stbir__use_height_upsampling(stbir_info));
-
-    memset(encode_buffer, 0, output_w * sizeof(float) * channels);
-
-    // I tried reblocking this for better cache usage of encode_buffer
-    // (using x_outer, k, x_inner), but it lost speed. -- stb
-
-    coefficient_counter = 0;
-    switch (channels) {
-        case 1:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 1;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                }
-            }
-            break;
-        case 2:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 2;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                }
-            }
-            break;
-        case 3:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 3;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                    encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient;
-                }
-            }
-            break;
-        case 4:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 4;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                    encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient;
-                    encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient;
-                }
-            }
-            break;
-        default:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * channels;
-                    int c;
-                    for (c = 0; c < channels; c++)
-                        encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient;
-                }
-            }
-            break;
-    }
-    stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode);
-}
-
-static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    stbir__contributors* vertical_contributors = stbir_info->vertical_contributors;
-    float* vertical_coefficients = stbir_info->vertical_coefficients;
-    int channels = stbir_info->channels;
-    int ring_buffer_entries = stbir_info->ring_buffer_num_entries;
-    float* horizontal_buffer = stbir_info->horizontal_buffer;
-    int coefficient_width = stbir_info->vertical_coefficient_width;
-    int contributor = n + stbir_info->vertical_filter_pixel_margin;
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index;
-    int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-    int n0,n1;
-
-    n0 = vertical_contributors[contributor].n0;
-    n1 = vertical_contributors[contributor].n1;
-
-    STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info));
-
-    for (k = n0; k <= n1; k++)
-    {
-        int coefficient_index = k - n0;
-        int coefficient_group = coefficient_width * contributor;
-        float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-
-        float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-
-        switch (channels) {
-            case 1:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 1;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                }
-                break;
-            case 2:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 2;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                }
-                break;
-            case 3:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 3;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient;
-                }
-                break;
-            case 4:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 4;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient;
-                }
-                break;
-            default:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * channels;
-
-                    int c;
-                    for (c = 0; c < channels; c++)
-                        ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient;
-                }
-                break;
-        }
-    }
-}
-
-static void stbir__buffer_loop_upsample(stbir__info* stbir_info)
-{
-    int y;
-    float scale_ratio = stbir_info->vertical_scale;
-    float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio;
-
-    STBIR_ASSERT(stbir__use_height_upsampling(stbir_info));
-
-    for (y = 0; y < stbir_info->output_h; y++)
-    {
-        float in_center_of_out = 0; // Center of the current out scanline in the in scanline space
-        int in_first_scanline = 0, in_last_scanline = 0;
-
-        stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out);
-
-        STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries);
-
-        if (stbir_info->ring_buffer_begin_index >= 0)
-        {
-            // Get rid of whatever we don't need anymore.
-            while (in_first_scanline > stbir_info->ring_buffer_first_scanline)
-            {
-                if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline)
-                {
-                    // We just popped the last scanline off the ring buffer.
-                    // Reset it to the empty state.
-                    stbir_info->ring_buffer_begin_index = -1;
-                    stbir_info->ring_buffer_first_scanline = 0;
-                    stbir_info->ring_buffer_last_scanline = 0;
-                    break;
-                }
-                else
-                {
-                    stbir_info->ring_buffer_first_scanline++;
-                    stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries;
-                }
-            }
-        }
-
-        // Load in new ones.
-        if (stbir_info->ring_buffer_begin_index < 0)
-            stbir__decode_and_resample_upsample(stbir_info, in_first_scanline);
-
-        while (in_last_scanline > stbir_info->ring_buffer_last_scanline)
-            stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1);
-
-        // Now all buffers should be ready to write a row of vertical sampling.
-        stbir__resample_vertical_upsample(stbir_info, y);
-
-        STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h);
-    }
-}
-
-static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline)
-{
-    int output_stride_bytes = stbir_info->output_stride_bytes;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int output_w = stbir_info->output_w;
-    void* output_data = stbir_info->output_data;
-    int decode = STBIR__DECODE(type, colorspace);
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-
-    if (stbir_info->ring_buffer_begin_index >= 0)
-    {
-        // Get rid of whatever we don't need anymore.
-        while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline)
-        {
-            if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h)
-            {
-                int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes;
-                float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length);
-                stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode);
-                STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h);
-            }
-
-            if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline)
-            {
-                // We just popped the last scanline off the ring buffer.
-                // Reset it to the empty state.
-                stbir_info->ring_buffer_begin_index = -1;
-                stbir_info->ring_buffer_first_scanline = 0;
-                stbir_info->ring_buffer_last_scanline = 0;
-                break;
-            }
-            else
-            {
-                stbir_info->ring_buffer_first_scanline++;
-                stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries;
-            }
-        }
-    }
-}
-
-static void stbir__buffer_loop_downsample(stbir__info* stbir_info)
-{
-    int y;
-    float scale_ratio = stbir_info->vertical_scale;
-    int output_h = stbir_info->output_h;
-    float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio;
-    int pixel_margin = stbir_info->vertical_filter_pixel_margin;
-    int max_y = stbir_info->input_h + pixel_margin;
-
-    STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info));
-
-    for (y = -pixel_margin; y < max_y; y++)
-    {
-        float out_center_of_in; // Center of the current out scanline in the in scanline space
-        int out_first_scanline, out_last_scanline;
-
-        stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in);
-
-        STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries);
-
-        if (out_last_scanline < 0 || out_first_scanline >= output_h)
-            continue;
-
-        stbir__empty_ring_buffer(stbir_info, out_first_scanline);
-
-        stbir__decode_and_resample_downsample(stbir_info, y);
-
-        // Load in new ones.
-        if (stbir_info->ring_buffer_begin_index < 0)
-            stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline);
-
-        while (out_last_scanline > stbir_info->ring_buffer_last_scanline)
-            stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1);
-
-        // Now the horizontal buffer is ready to write to all ring buffer rows.
-        stbir__resample_vertical_downsample(stbir_info, y);
-    }
-
-    stbir__empty_ring_buffer(stbir_info, stbir_info->output_h);
-}
-
-static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels)
-{
-    info->input_w = input_w;
-    info->input_h = input_h;
-    info->output_w = output_w;
-    info->output_h = output_h;
-    info->channels = channels;
-}
-
-static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform)
-{
-    info->s0 = s0;
-    info->t0 = t0;
-    info->s1 = s1;
-    info->t1 = t1;
-
-    if (transform)
-    {
-        info->horizontal_scale = transform[0];
-        info->vertical_scale   = transform[1];
-        info->horizontal_shift = transform[2];
-        info->vertical_shift   = transform[3];
-    }
-    else
-    {
-        info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0);
-        info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0);
-
-        info->horizontal_shift = s0 * info->output_w / (s1 - s0);
-        info->vertical_shift = t0 * info->output_h / (t1 - t0);
-    }
-}
-
-static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter)
-{
-    if (h_filter == 0)
-        h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE;
-    if (v_filter == 0)
-        v_filter = stbir__use_upsampling(info->vertical_scale)   ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE;
-    info->horizontal_filter = h_filter;
-    info->vertical_filter = v_filter;
-}
-
-static stbir_uint32 stbir__calculate_memory(stbir__info *info)
-{
-    int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale);
-    int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale);
-
-    info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w);
-    info->vertical_num_contributors   = stbir__get_contributors(info->vertical_scale  , info->vertical_filter  , info->input_h, info->output_h);
-
-    // One extra entry because floating point precision problems sometimes cause an extra to be necessary.
-    info->ring_buffer_num_entries = filter_height + 1;
-
-    info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors);
-    info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float);
-    info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors);
-    info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float);
-    info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float);
-    info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float);
-    info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float);
-    info->encode_buffer_size = info->output_w * info->channels * sizeof(float);
-
-    STBIR_ASSERT(info->horizontal_filter != 0);
-    STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late
-    STBIR_ASSERT(info->vertical_filter != 0);
-    STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late
-
-    if (stbir__use_height_upsampling(info))
-        // The horizontal buffer is for when we're downsampling the height and we
-        // can't output the result of sampling the decode buffer directly into the
-        // ring buffers.
-        info->horizontal_buffer_size = 0;
-    else
-        // The encode buffer is to retain precision in the height upsampling method
-        // and isn't used when height downsampling.
-        info->encode_buffer_size = 0;
-
-    return info->horizontal_contributors_size + info->horizontal_coefficients_size
-        + info->vertical_contributors_size + info->vertical_coefficients_size
-        + info->decode_buffer_size + info->horizontal_buffer_size
-        + info->ring_buffer_size + info->encode_buffer_size;
-}
-
-static int stbir__resize_allocated(stbir__info *info,
-    const void* input_data, int input_stride_in_bytes,
-    void* output_data, int output_stride_in_bytes,
-    int alpha_channel, stbir_uint32 flags, stbir_datatype type,
-    stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace,
-    void* tempmem, size_t tempmem_size_in_bytes)
-{
-    size_t memory_required = stbir__calculate_memory(info);
-
-    int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type];
-    int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type];
-
-#ifdef STBIR_DEBUG_OVERWRITE_TEST
-#define OVERWRITE_ARRAY_SIZE 8
-    unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE];
-
-    size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type];
-    memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE);
-#endif
-
-    STBIR_ASSERT(info->channels >= 0);
-    STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS);
-
-    if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS)
-        return 0;
-
-    STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-    STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-
-    if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
-        return 0;
-    if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
-        return 0;
-
-    if (alpha_channel < 0)
-        flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED;
-
-    if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) {
-        STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels);
-    }
-
-    if (alpha_channel >= info->channels)
-        return 0;
-
-    STBIR_ASSERT(tempmem);
-
-    if (!tempmem)
-        return 0;
-
-    STBIR_ASSERT(tempmem_size_in_bytes >= memory_required);
-
-    if (tempmem_size_in_bytes < memory_required)
-        return 0;
-
-    memset(tempmem, 0, tempmem_size_in_bytes);
-
-    info->input_data = input_data;
-    info->input_stride_bytes = width_stride_input;
-
-    info->output_data = output_data;
-    info->output_stride_bytes = width_stride_output;
-
-    info->alpha_channel = alpha_channel;
-    info->flags = flags;
-    info->type = type;
-    info->edge_horizontal = edge_horizontal;
-    info->edge_vertical = edge_vertical;
-    info->colorspace = colorspace;
-
-    info->horizontal_coefficient_width   = stbir__get_coefficient_width  (info->horizontal_filter, info->horizontal_scale);
-    info->vertical_coefficient_width     = stbir__get_coefficient_width  (info->vertical_filter  , info->vertical_scale  );
-    info->horizontal_filter_pixel_width  = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale);
-    info->vertical_filter_pixel_width    = stbir__get_filter_pixel_width (info->vertical_filter  , info->vertical_scale  );
-    info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale);
-    info->vertical_filter_pixel_margin   = stbir__get_filter_pixel_margin(info->vertical_filter  , info->vertical_scale  );
-
-    info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float);
-    info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2;
-
-#define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size)
-
-    info->horizontal_contributors = (stbir__contributors *) tempmem;
-    info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float);
-    info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors);
-    info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float);
-    info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float);
-
-    if (stbir__use_height_upsampling(info))
-    {
-        info->horizontal_buffer = NULL;
-        info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
-        info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float);
-
-        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
-    }
-    else
-    {
-        info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
-        info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float);
-        info->encode_buffer = NULL;
-
-        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
-    }
-
-#undef STBIR__NEXT_MEMPTR
-
-    // This signals that the ring buffer is empty
-    info->ring_buffer_begin_index = -1;
-
-    stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w);
-    stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h);
-
-    STBIR_PROGRESS_REPORT(0);
-
-    if (stbir__use_height_upsampling(info))
-        stbir__buffer_loop_upsample(info);
-    else
-        stbir__buffer_loop_downsample(info);
-
-    STBIR_PROGRESS_REPORT(1);
-
-#ifdef STBIR_DEBUG_OVERWRITE_TEST
-    STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0);
-#endif
-
-    return 1;
-}
-
-
-static int stbir__resize_arbitrary(
-    void *alloc_context,
-    const void* input_data, int input_w, int input_h, int input_stride_in_bytes,
-    void* output_data, int output_w, int output_h, int output_stride_in_bytes,
-    float s0, float t0, float s1, float t1, float *transform,
-    int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type,
-    stbir_filter h_filter, stbir_filter v_filter,
-    stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace)
-{
-    stbir__info info;
-    int result;
-    size_t memory_required;
-    void* extra_memory;
-
-    stbir__setup(&info, input_w, input_h, output_w, output_h, channels);
-    stbir__calculate_transform(&info, s0,t0,s1,t1,transform);
-    stbir__choose_filter(&info, h_filter, v_filter);
-    memory_required = stbir__calculate_memory(&info);
-    extra_memory = STBIR_MALLOC(memory_required, alloc_context);
-
-    if (!extra_memory)
-        return 0;
-
-    result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes,
-                                            output_data, output_stride_in_bytes,
-                                            alpha_channel, flags, type,
-                                            edge_horizontal, edge_vertical,
-                                            colorspace, extra_memory, memory_required);
-
-    STBIR_FREE(extra_memory, alloc_context);
-
-    return result;
-}
-
-STBIRDEF int stbir_resize_uint8(     const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR);
-}
-
-STBIRDEF int stbir_resize_float(     const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           float *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR);
-}
-
-STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels, int alpha_channel, int flags)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB);
-}
-
-STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                                    unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                              int num_channels, int alpha_channel, int flags,
-                                              stbir_edge edge_wrap_mode)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB);
-}
-
-STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                               unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels  , int input_w , int input_h , int input_stride_in_bytes,
-                                               stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-
-STBIRDEF int stbir_resize_float_generic( const float *input_pixels         , int input_w , int input_h , int input_stride_in_bytes,
-                                               float *output_pixels        , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-
-STBIRDEF int stbir_resize(         const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-
-STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float x_scale, float y_scale,
-                                   float x_offset, float y_offset)
-{
-    float transform[4];
-    transform[0] = x_scale;
-    transform[1] = y_scale;
-    transform[2] = x_offset;
-    transform[3] = y_offset;
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-STBIRDEF int stbir_resize_region(  const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float s0, float t0, float s1, float t1)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-#endif // STB_IMAGE_RESIZE_IMPLEMENTATION
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_image_write.h b/raylib/external/stb_image_write.h
deleted file mode 100644 (file)
index 95943eb..0000000
+++ /dev/null
@@ -1,1690 +0,0 @@
-/* stb_image_write - v1.15 - public domain - http://nothings.org/stb
-   writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015
-                                     no warranty implied; use at your own risk
-
-   Before #including,
-
-       #define STB_IMAGE_WRITE_IMPLEMENTATION
-
-   in the file that you want to have the implementation.
-
-   Will probably not work correctly with strict-aliasing optimizations.
-
-ABOUT:
-
-   This header file is a library for writing images to C stdio or a callback.
-
-   The PNG output is not optimal; it is 20-50% larger than the file
-   written by a decent optimizing implementation; though providing a custom
-   zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that.
-   This library is designed for source code compactness and simplicity,
-   not optimal image file size or run-time performance.
-
-BUILDING:
-
-   You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h.
-   You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace
-   malloc,realloc,free.
-   You can #define STBIW_MEMMOVE() to replace memmove()
-   You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function
-   for PNG compression (instead of the builtin one), it must have the following signature:
-   unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality);
-   The returned data will be freed with STBIW_FREE() (free() by default),
-   so it must be heap allocated with STBIW_MALLOC() (malloc() by default),
-
-UNICODE:
-
-   If compiling for Windows and you wish to use Unicode filenames, compile
-   with
-       #define STBIW_WINDOWS_UTF8
-   and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert
-   Windows wchar_t filenames to utf8.
-
-USAGE:
-
-   There are five functions, one for each image file format:
-
-     int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
-     int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
-     int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
-     int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality);
-     int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
-
-     void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically
-
-   There are also five equivalent functions that use an arbitrary write function. You are
-   expected to open/close your file-equivalent before and after calling these:
-
-     int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);
-     int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-     int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-     int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
-     int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);
-
-   where the callback is:
-      void stbi_write_func(void *context, void *data, int size);
-
-   You can configure it with these global variables:
-      int stbi_write_tga_with_rle;             // defaults to true; set to 0 to disable RLE
-      int stbi_write_png_compression_level;    // defaults to 8; set to higher for more compression
-      int stbi_write_force_png_filter;         // defaults to -1; set to 0..5 to force a filter mode
-
-
-   You can define STBI_WRITE_NO_STDIO to disable the file variant of these
-   functions, so the library will not use stdio.h at all. However, this will
-   also disable HDR writing, because it requires stdio for formatted output.
-
-   Each function returns 0 on failure and non-0 on success.
-
-   The functions create an image file defined by the parameters. The image
-   is a rectangle of pixels stored from left-to-right, top-to-bottom.
-   Each pixel contains 'comp' channels of data stored interleaved with 8-bits
-   per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is
-   monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall.
-   The *data pointer points to the first byte of the top-left-most pixel.
-   For PNG, "stride_in_bytes" is the distance in bytes from the first byte of
-   a row of pixels to the first byte of the next row of pixels.
-
-   PNG creates output files with the same number of components as the input.
-   The BMP format expands Y to RGB in the file format and does not
-   output alpha.
-
-   PNG supports writing rectangles of data even when the bytes storing rows of
-   data are not consecutive in memory (e.g. sub-rectangles of a larger image),
-   by supplying the stride between the beginning of adjacent rows. The other
-   formats do not. (Thus you cannot write a native-format BMP through the BMP
-   writer, both because it is in BGR order and because it may have padding
-   at the end of the line.)
-
-   PNG allows you to set the deflate compression level by setting the global
-   variable 'stbi_write_png_compression_level' (it defaults to 8).
-
-   HDR expects linear float data. Since the format is always 32-bit rgb(e)
-   data, alpha (if provided) is discarded, and for monochrome data it is
-   replicated across all three channels.
-
-   TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed
-   data, set the global variable 'stbi_write_tga_with_rle' to 0.
-
-   JPEG does ignore alpha channels in input data; quality is between 1 and 100.
-   Higher quality looks better but results in a bigger image.
-   JPEG baseline (no JPEG progressive).
-
-CREDITS:
-
-
-   Sean Barrett           -    PNG/BMP/TGA
-   Baldur Karlsson        -    HDR
-   Jean-Sebastien Guay    -    TGA monochrome
-   Tim Kelsey             -    misc enhancements
-   Alan Hickman           -    TGA RLE
-   Emmanuel Julien        -    initial file IO callback implementation
-   Jon Olick              -    original jo_jpeg.cpp code
-   Daniel Gibson          -    integrate JPEG, allow external zlib
-   Aarni Koskela          -    allow choosing PNG filter
-
-   bugfixes:
-      github:Chribba
-      Guillaume Chereau
-      github:jry2
-      github:romigrou
-      Sergio Gonzalez
-      Jonas Karlsson
-      Filip Wasil
-      Thatcher Ulrich
-      github:poppolopoppo
-      Patrick Boettcher
-      github:xeekworx
-      Cap Petschulat
-      Simon Rodriguez
-      Ivan Tikhonov
-      github:ignotion
-      Adam Schackart
-
-LICENSE
-
-  See end of file for license information.
-
-*/
-
-#ifndef INCLUDE_STB_IMAGE_WRITE_H
-#define INCLUDE_STB_IMAGE_WRITE_H
-
-#include <stdlib.h>
-
-// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline'
-#ifndef STBIWDEF
-#ifdef STB_IMAGE_WRITE_STATIC
-#define STBIWDEF  static
-#else
-#ifdef __cplusplus
-#define STBIWDEF  extern "C"
-#else
-#define STBIWDEF  extern
-#endif
-#endif
-#endif
-
-#ifndef STB_IMAGE_WRITE_STATIC  // C++ forbids static forward declarations
-extern int stbi_write_tga_with_rle;
-extern int stbi_write_png_compression_level;
-extern int stbi_write_force_png_filter;
-#endif
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void  *data, int stride_in_bytes);
-STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
-STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void  *data, int quality);
-
-#ifdef STBI_WINDOWS_UTF8
-STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
-#endif
-#endif
-
-typedef void stbi_write_func(void *context, void *data, int size);
-
-STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);
-STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
-STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void  *data, int quality);
-
-STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);
-
-#endif//INCLUDE_STB_IMAGE_WRITE_H
-
-#ifdef STB_IMAGE_WRITE_IMPLEMENTATION
-
-#ifdef _WIN32
-   #ifndef _CRT_SECURE_NO_WARNINGS
-   #define _CRT_SECURE_NO_WARNINGS
-   #endif
-   #ifndef _CRT_NONSTDC_NO_DEPRECATE
-   #define _CRT_NONSTDC_NO_DEPRECATE
-   #endif
-#endif
-
-#ifndef STBI_WRITE_NO_STDIO
-#include <stdio.h>
-#endif // STBI_WRITE_NO_STDIO
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED))
-// ok
-#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED)
-// ok
-#else
-#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)."
-#endif
-
-#ifndef STBIW_MALLOC
-#define STBIW_MALLOC(sz)        malloc(sz)
-#define STBIW_REALLOC(p,newsz)  realloc(p,newsz)
-#define STBIW_FREE(p)           free(p)
-#endif
-
-#ifndef STBIW_REALLOC_SIZED
-#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)
-#endif
-
-
-#ifndef STBIW_MEMMOVE
-#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)
-#endif
-
-
-#ifndef STBIW_ASSERT
-#include <assert.h>
-#define STBIW_ASSERT(x) assert(x)
-#endif
-
-#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)
-
-#ifdef STB_IMAGE_WRITE_STATIC
-static int stbi_write_png_compression_level = 8;
-static int stbi_write_tga_with_rle = 1;
-static int stbi_write_force_png_filter = -1;
-#else
-int stbi_write_png_compression_level = 8;
-int stbi_write_tga_with_rle = 1;
-int stbi_write_force_png_filter = -1;
-#endif
-
-static int stbi__flip_vertically_on_write = 0;
-
-STBIWDEF void stbi_flip_vertically_on_write(int flag)
-{
-   stbi__flip_vertically_on_write = flag;
-}
-
-typedef struct
-{
-   stbi_write_func *func;
-   void *context;
-   unsigned char buffer[64];
-   int buf_used;
-} stbi__write_context;
-
-// initialize a callback-based context
-static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context)
-{
-   s->func    = c;
-   s->context = context;
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-
-static void stbi__stdio_write(void *context, void *data, int size)
-{
-   fwrite(data,1,size,(FILE*) context);
-}
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-#ifdef __cplusplus
-#define STBIW_EXTERN extern "C"
-#else
-#define STBIW_EXTERN extern
-#endif
-STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
-STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
-
-STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
-{
-       return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
-}
-#endif
-
-static FILE *stbiw__fopen(char const *filename, char const *mode)
-{
-   FILE *f;
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-   wchar_t wMode[64];
-   wchar_t wFilename[1024];
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
-      return 0;
-
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
-      return 0;
-
-#if _MSC_VER >= 1400
-       if (0 != _wfopen_s(&f, wFilename, wMode))
-               f = 0;
-#else
-   f = _wfopen(wFilename, wMode);
-#endif
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
-   if (0 != fopen_s(&f, filename, mode))
-      f=0;
-#else
-   f = fopen(filename, mode);
-#endif
-   return f;
-}
-
-static int stbi__start_write_file(stbi__write_context *s, const char *filename)
-{
-   FILE *f = stbiw__fopen(filename, "wb");
-   stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
-   return f != NULL;
-}
-
-static void stbi__end_write_file(stbi__write_context *s)
-{
-   fclose((FILE *)s->context);
-}
-
-#endif // !STBI_WRITE_NO_STDIO
-
-typedef unsigned int stbiw_uint32;
-typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
-
-static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v)
-{
-   while (*fmt) {
-      switch (*fmt++) {
-         case ' ': break;
-         case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int));
-                     s->func(s->context,&x,1);
-                     break; }
-         case '2': { int x = va_arg(v,int);
-                     unsigned char b[2];
-                     b[0] = STBIW_UCHAR(x);
-                     b[1] = STBIW_UCHAR(x>>8);
-                     s->func(s->context,b,2);
-                     break; }
-         case '4': { stbiw_uint32 x = va_arg(v,int);
-                     unsigned char b[4];
-                     b[0]=STBIW_UCHAR(x);
-                     b[1]=STBIW_UCHAR(x>>8);
-                     b[2]=STBIW_UCHAR(x>>16);
-                     b[3]=STBIW_UCHAR(x>>24);
-                     s->func(s->context,b,4);
-                     break; }
-         default:
-            STBIW_ASSERT(0);
-            return;
-      }
-   }
-}
-
-static void stbiw__writef(stbi__write_context *s, const char *fmt, ...)
-{
-   va_list v;
-   va_start(v, fmt);
-   stbiw__writefv(s, fmt, v);
-   va_end(v);
-}
-
-static void stbiw__write_flush(stbi__write_context *s)
-{
-   if (s->buf_used) {
-      s->func(s->context, &s->buffer, s->buf_used);
-      s->buf_used = 0;
-   }
-}
-
-static void stbiw__putc(stbi__write_context *s, unsigned char c)
-{
-   s->func(s->context, &c, 1);
-}
-
-static void stbiw__write1(stbi__write_context *s, unsigned char a)
-{
-   if (s->buf_used + 1 > sizeof(s->buffer))
-      stbiw__write_flush(s);
-   s->buffer[s->buf_used++] = a;
-}
-
-static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)
-{
-   int n;
-   if (s->buf_used + 3 > sizeof(s->buffer))
-      stbiw__write_flush(s);
-   n = s->buf_used;
-   s->buf_used = n+3;
-   s->buffer[n+0] = a;
-   s->buffer[n+1] = b;
-   s->buffer[n+2] = c;
-}
-
-static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
-{
-   unsigned char bg[3] = { 255, 0, 255}, px[3];
-   int k;
-
-   if (write_alpha < 0)
-      stbiw__write1(s, d[comp - 1]);
-
-   switch (comp) {
-      case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
-      case 1:
-         if (expand_mono)
-            stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
-         else
-            stbiw__write1(s, d[0]);  // monochrome TGA
-         break;
-      case 4:
-         if (!write_alpha) {
-            // composite against pink background
-            for (k = 0; k < 3; ++k)
-               px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;
-            stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
-            break;
-         }
-         /* FALLTHROUGH */
-      case 3:
-         stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
-         break;
-   }
-   if (write_alpha > 0)
-      stbiw__write1(s, d[comp - 1]);
-}
-
-static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
-{
-   stbiw_uint32 zero = 0;
-   int i,j, j_end;
-
-   if (y <= 0)
-      return;
-
-   if (stbi__flip_vertically_on_write)
-      vdir *= -1;
-
-   if (vdir < 0) {
-      j_end = -1; j = y-1;
-   } else {
-      j_end =  y; j = 0;
-   }
-
-   for (; j != j_end; j += vdir) {
-      for (i=0; i < x; ++i) {
-         unsigned char *d = (unsigned char *) data + (j*x+i)*comp;
-         stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
-      }
-      stbiw__write_flush(s);
-      s->func(s->context, &zero, scanline_pad);
-   }
-}
-
-static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...)
-{
-   if (y < 0 || x < 0) {
-      return 0;
-   } else {
-      va_list v;
-      va_start(v, fmt);
-      stbiw__writefv(s, fmt, v);
-      va_end(v);
-      stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono);
-      return 1;
-   }
-}
-
-static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
-{
-   int pad = (-x*3) & 3;
-   return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
-           "11 4 22 4" "4 44 22 444444",
-           'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40,  // file header
-            40, x,y, 1,24, 0,0,0,0,0,0);             // bitmap header
-}
-
-STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_bmp_core(&s, x, y, comp, data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_bmp_core(&s, x, y, comp, data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif //!STBI_WRITE_NO_STDIO
-
-static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)
-{
-   int has_alpha = (comp == 2 || comp == 4);
-   int colorbytes = has_alpha ? comp-1 : comp;
-   int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3
-
-   if (y < 0 || x < 0)
-      return 0;
-
-   if (!stbi_write_tga_with_rle) {
-      return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
-         "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
-   } else {
-      int i,j,k;
-      int jend, jdir;
-
-      stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);
-
-      if (stbi__flip_vertically_on_write) {
-         j = 0;
-         jend = y;
-         jdir = 1;
-      } else {
-         j = y-1;
-         jend = -1;
-         jdir = -1;
-      }
-      for (; j != jend; j += jdir) {
-         unsigned char *row = (unsigned char *) data + j * x * comp;
-         int len;
-
-         for (i = 0; i < x; i += len) {
-            unsigned char *begin = row + i * comp;
-            int diff = 1;
-            len = 1;
-
-            if (i < x - 1) {
-               ++len;
-               diff = memcmp(begin, row + (i + 1) * comp, comp);
-               if (diff) {
-                  const unsigned char *prev = begin;
-                  for (k = i + 2; k < x && len < 128; ++k) {
-                     if (memcmp(prev, row + k * comp, comp)) {
-                        prev += comp;
-                        ++len;
-                     } else {
-                        --len;
-                        break;
-                     }
-                  }
-               } else {
-                  for (k = i + 2; k < x && len < 128; ++k) {
-                     if (!memcmp(begin, row + k * comp, comp)) {
-                        ++len;
-                     } else {
-                        break;
-                     }
-                  }
-               }
-            }
-
-            if (diff) {
-               unsigned char header = STBIW_UCHAR(len - 1);
-               stbiw__write1(s, header);
-               for (k = 0; k < len; ++k) {
-                  stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);
-               }
-            } else {
-               unsigned char header = STBIW_UCHAR(len - 129);
-               stbiw__write1(s, header);
-               stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);
-            }
-         }
-      }
-      stbiw__write_flush(s);
-   }
-   return 1;
-}
-
-STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_tga_core(&s, x, y, comp, (void *) data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif
-
-// *************************************************************************************************
-// Radiance RGBE HDR writer
-// by Baldur Karlsson
-
-#define stbiw__max(a, b)  ((a) > (b) ? (a) : (b))
-
-static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)
-{
-   int exponent;
-   float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2]));
-
-   if (maxcomp < 1e-32f) {
-      rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
-   } else {
-      float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp;
-
-      rgbe[0] = (unsigned char)(linear[0] * normalize);
-      rgbe[1] = (unsigned char)(linear[1] * normalize);
-      rgbe[2] = (unsigned char)(linear[2] * normalize);
-      rgbe[3] = (unsigned char)(exponent + 128);
-   }
-}
-
-static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)
-{
-   unsigned char lengthbyte = STBIW_UCHAR(length+128);
-   STBIW_ASSERT(length+128 <= 255);
-   s->func(s->context, &lengthbyte, 1);
-   s->func(s->context, &databyte, 1);
-}
-
-static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)
-{
-   unsigned char lengthbyte = STBIW_UCHAR(length);
-   STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code
-   s->func(s->context, &lengthbyte, 1);
-   s->func(s->context, data, length);
-}
-
-static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)
-{
-   unsigned char scanlineheader[4] = { 2, 2, 0, 0 };
-   unsigned char rgbe[4];
-   float linear[3];
-   int x;
-
-   scanlineheader[2] = (width&0xff00)>>8;
-   scanlineheader[3] = (width&0x00ff);
-
-   /* skip RLE for images too small or large */
-   if (width < 8 || width >= 32768) {
-      for (x=0; x < width; x++) {
-         switch (ncomp) {
-            case 4: /* fallthrough */
-            case 3: linear[2] = scanline[x*ncomp + 2];
-                    linear[1] = scanline[x*ncomp + 1];
-                    linear[0] = scanline[x*ncomp + 0];
-                    break;
-            default:
-                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
-                    break;
-         }
-         stbiw__linear_to_rgbe(rgbe, linear);
-         s->func(s->context, rgbe, 4);
-      }
-   } else {
-      int c,r;
-      /* encode into scratch buffer */
-      for (x=0; x < width; x++) {
-         switch(ncomp) {
-            case 4: /* fallthrough */
-            case 3: linear[2] = scanline[x*ncomp + 2];
-                    linear[1] = scanline[x*ncomp + 1];
-                    linear[0] = scanline[x*ncomp + 0];
-                    break;
-            default:
-                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
-                    break;
-         }
-         stbiw__linear_to_rgbe(rgbe, linear);
-         scratch[x + width*0] = rgbe[0];
-         scratch[x + width*1] = rgbe[1];
-         scratch[x + width*2] = rgbe[2];
-         scratch[x + width*3] = rgbe[3];
-      }
-
-      s->func(s->context, scanlineheader, 4);
-
-      /* RLE each component separately */
-      for (c=0; c < 4; c++) {
-         unsigned char *comp = &scratch[width*c];
-
-         x = 0;
-         while (x < width) {
-            // find first run
-            r = x;
-            while (r+2 < width) {
-               if (comp[r] == comp[r+1] && comp[r] == comp[r+2])
-                  break;
-               ++r;
-            }
-            if (r+2 >= width)
-               r = width;
-            // dump up to first run
-            while (x < r) {
-               int len = r-x;
-               if (len > 128) len = 128;
-               stbiw__write_dump_data(s, len, &comp[x]);
-               x += len;
-            }
-            // if there's a run, output it
-            if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd
-               // find next byte after run
-               while (r < width && comp[r] == comp[x])
-                  ++r;
-               // output run up to r
-               while (x < r) {
-                  int len = r-x;
-                  if (len > 127) len = 127;
-                  stbiw__write_run_data(s, len, comp[x]);
-                  x += len;
-               }
-            }
-         }
-      }
-   }
-}
-
-static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)
-{
-   if (y <= 0 || x <= 0 || data == NULL)
-      return 0;
-   else {
-      // Each component is stored separately. Allocate scratch space for full output scanline.
-      unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);
-      int i, len;
-      char buffer[128];
-      char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
-      s->func(s->context, header, sizeof(header)-1);
-
-#ifdef __STDC_WANT_SECURE_LIB__
-      len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
-#else
-      len = sprintf(buffer, "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
-#endif
-      s->func(s->context, buffer, len);
-
-      for(i=0; i < y; i++)
-         stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));
-      STBIW_FREE(scratch);
-      return 1;
-   }
-}
-
-STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif // STBI_WRITE_NO_STDIO
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// PNG writer
-//
-
-#ifndef STBIW_ZLIB_COMPRESS
-// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size()
-#define stbiw__sbraw(a) ((int *) (void *) (a) - 2)
-#define stbiw__sbm(a)   stbiw__sbraw(a)[0]
-#define stbiw__sbn(a)   stbiw__sbraw(a)[1]
-
-#define stbiw__sbneedgrow(a,n)  ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a))
-#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0)
-#define stbiw__sbgrow(a,n)  stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a)))
-
-#define stbiw__sbpush(a, v)      (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v))
-#define stbiw__sbcount(a)        ((a) ? stbiw__sbn(a) : 0)
-#define stbiw__sbfree(a)         ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0)
-
-static void *stbiw__sbgrowf(void **arr, int increment, int itemsize)
-{
-   int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;
-   void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);
-   STBIW_ASSERT(p);
-   if (p) {
-      if (!*arr) ((int *) p)[1] = 0;
-      *arr = (void *) ((int *) p + 2);
-      stbiw__sbm(*arr) = m;
-   }
-   return *arr;
-}
-
-static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)
-{
-   while (*bitcount >= 8) {
-      stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer));
-      *bitbuffer >>= 8;
-      *bitcount -= 8;
-   }
-   return data;
-}
-
-static int stbiw__zlib_bitrev(int code, int codebits)
-{
-   int res=0;
-   while (codebits--) {
-      res = (res << 1) | (code & 1);
-      code >>= 1;
-   }
-   return res;
-}
-
-static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit)
-{
-   int i;
-   for (i=0; i < limit && i < 258; ++i)
-      if (a[i] != b[i]) break;
-   return i;
-}
-
-static unsigned int stbiw__zhash(unsigned char *data)
-{
-   stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16);
-   hash ^= hash << 3;
-   hash += hash >> 5;
-   hash ^= hash << 4;
-   hash += hash >> 17;
-   hash ^= hash << 25;
-   hash += hash >> 6;
-   return hash;
-}
-
-#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount))
-#define stbiw__zlib_add(code,codebits) \
-      (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush())
-#define stbiw__zlib_huffa(b,c)  stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c)
-// default huffman tables
-#define stbiw__zlib_huff1(n)  stbiw__zlib_huffa(0x30 + (n), 8)
-#define stbiw__zlib_huff2(n)  stbiw__zlib_huffa(0x190 + (n)-144, 9)
-#define stbiw__zlib_huff3(n)  stbiw__zlib_huffa(0 + (n)-256,7)
-#define stbiw__zlib_huff4(n)  stbiw__zlib_huffa(0xc0 + (n)-280,8)
-#define stbiw__zlib_huff(n)  ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n))
-#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n))
-
-#define stbiw__ZHASH   16384
-
-#endif // STBIW_ZLIB_COMPRESS
-
-STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)
-{
-#ifdef STBIW_ZLIB_COMPRESS
-   // user provided a zlib compress implementation, use that
-   return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);
-#else // use builtin
-   static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };
-   static unsigned char  lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5,  0 };
-   static unsigned short distc[]   = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };
-   static unsigned char  disteb[]  = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };
-   unsigned int bitbuf=0;
-   int i,j, bitcount=0;
-   unsigned char *out = NULL;
-   unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**));
-   if (hash_table == NULL)
-      return NULL;
-   if (quality < 5) quality = 5;
-
-   stbiw__sbpush(out, 0x78);   // DEFLATE 32K window
-   stbiw__sbpush(out, 0x5e);   // FLEVEL = 1
-   stbiw__zlib_add(1,1);  // BFINAL = 1
-   stbiw__zlib_add(1,2);  // BTYPE = 1 -- fixed huffman
-
-   for (i=0; i < stbiw__ZHASH; ++i)
-      hash_table[i] = NULL;
-
-   i=0;
-   while (i < data_len-3) {
-      // hash next 3 bytes of data to be compressed
-      int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;
-      unsigned char *bestloc = 0;
-      unsigned char **hlist = hash_table[h];
-      int n = stbiw__sbcount(hlist);
-      for (j=0; j < n; ++j) {
-         if (hlist[j]-data > i-32768) { // if entry lies within window
-            int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);
-            if (d >= best) { best=d; bestloc=hlist[j]; }
-         }
-      }
-      // when hash table entry is too long, delete half the entries
-      if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {
-         STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);
-         stbiw__sbn(hash_table[h]) = quality;
-      }
-      stbiw__sbpush(hash_table[h],data+i);
-
-      if (bestloc) {
-         // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal
-         h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);
-         hlist = hash_table[h];
-         n = stbiw__sbcount(hlist);
-         for (j=0; j < n; ++j) {
-            if (hlist[j]-data > i-32767) {
-               int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);
-               if (e > best) { // if next match is better, bail on current match
-                  bestloc = NULL;
-                  break;
-               }
-            }
-         }
-      }
-
-      if (bestloc) {
-         int d = (int) (data+i - bestloc); // distance back
-         STBIW_ASSERT(d <= 32767 && best <= 258);
-         for (j=0; best > lengthc[j+1]-1; ++j);
-         stbiw__zlib_huff(j+257);
-         if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);
-         for (j=0; d > distc[j+1]-1; ++j);
-         stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);
-         if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);
-         i += best;
-      } else {
-         stbiw__zlib_huffb(data[i]);
-         ++i;
-      }
-   }
-   // write out final bytes
-   for (;i < data_len; ++i)
-      stbiw__zlib_huffb(data[i]);
-   stbiw__zlib_huff(256); // end of block
-   // pad with 0 bits to byte boundary
-   while (bitcount)
-      stbiw__zlib_add(0,1);
-
-   for (i=0; i < stbiw__ZHASH; ++i)
-      (void) stbiw__sbfree(hash_table[i]);
-   STBIW_FREE(hash_table);
-
-   {
-      // compute adler32 on input
-      unsigned int s1=1, s2=0;
-      int blocklen = (int) (data_len % 5552);
-      j=0;
-      while (j < data_len) {
-         for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; }
-         s1 %= 65521; s2 %= 65521;
-         j += blocklen;
-         blocklen = 5552;
-      }
-      stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8));
-      stbiw__sbpush(out, STBIW_UCHAR(s2));
-      stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));
-      stbiw__sbpush(out, STBIW_UCHAR(s1));
-   }
-   *out_len = stbiw__sbn(out);
-   // make returned pointer freeable
-   STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);
-   return (unsigned char *) stbiw__sbraw(out);
-#endif // STBIW_ZLIB_COMPRESS
-}
-
-static unsigned int stbiw__crc32(unsigned char *buffer, int len)
-{
-#ifdef STBIW_CRC32
-    return STBIW_CRC32(buffer, len);
-#else
-   static unsigned int crc_table[256] =
-   {
-      0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
-      0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
-      0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
-      0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
-      0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
-      0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
-      0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
-      0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
-      0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
-      0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
-      0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
-      0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
-      0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
-      0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
-      0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
-      0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
-      0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
-      0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
-      0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
-      0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
-      0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
-      0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
-      0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
-      0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
-      0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
-      0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
-      0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
-      0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
-      0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
-      0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
-      0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
-      0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
-   };
-
-   unsigned int crc = ~0u;
-   int i;
-   for (i=0; i < len; ++i)
-      crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)];
-   return ~crc;
-#endif
-}
-
-#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4)
-#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v));
-#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3])
-
-static void stbiw__wpcrc(unsigned char **data, int len)
-{
-   unsigned int crc = stbiw__crc32(*data - len - 4, len+4);
-   stbiw__wp32(*data, crc);
-}
-
-static unsigned char stbiw__paeth(int a, int b, int c)
-{
-   int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c);
-   if (pa <= pb && pa <= pc) return STBIW_UCHAR(a);
-   if (pb <= pc) return STBIW_UCHAR(b);
-   return STBIW_UCHAR(c);
-}
-
-// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
-static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)
-{
-   static int mapping[] = { 0,1,2,3,4 };
-   static int firstmap[] = { 0,1,0,5,6 };
-   int *mymap = (y != 0) ? mapping : firstmap;
-   int i;
-   int type = mymap[filter_type];
-   unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
-   int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;
-
-   if (type==0) {
-      memcpy(line_buffer, z, width*n);
-      return;
-   }
-
-   // first loop isn't optimized since it's just one pixel
-   for (i = 0; i < n; ++i) {
-      switch (type) {
-         case 1: line_buffer[i] = z[i]; break;
-         case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break;
-         case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break;
-         case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break;
-         case 5: line_buffer[i] = z[i]; break;
-         case 6: line_buffer[i] = z[i]; break;
-      }
-   }
-   switch (type) {
-      case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break;
-      case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break;
-      case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break;
-      case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break;
-      case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break;
-      case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break;
-   }
-}
-
-STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
-{
-   int force_filter = stbi_write_force_png_filter;
-   int ctype[5] = { -1, 0, 4, 2, 6 };
-   unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };
-   unsigned char *out,*o, *filt, *zlib;
-   signed char *line_buffer;
-   int j,zlen;
-
-   if (stride_bytes == 0)
-      stride_bytes = x * n;
-
-   if (force_filter >= 5) {
-      force_filter = -1;
-   }
-
-   filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;
-   line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
-   for (j=0; j < y; ++j) {
-      int filter_type;
-      if (force_filter > -1) {
-         filter_type = force_filter;
-         stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);
-      } else { // Estimate the best filter by running through all of them:
-         int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
-         for (filter_type = 0; filter_type < 5; filter_type++) {
-            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);
-
-            // Estimate the entropy of the line using this filter; the less, the better.
-            est = 0;
-            for (i = 0; i < x*n; ++i) {
-               est += abs((signed char) line_buffer[i]);
-            }
-            if (est < best_filter_val) {
-               best_filter_val = est;
-               best_filter = filter_type;
-            }
-         }
-         if (filter_type != best_filter) {  // If the last iteration already got us the best filter, don't redo it
-            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);
-            filter_type = best_filter;
-         }
-      }
-      // when we get here, filter_type contains the filter type, and line_buffer contains the data
-      filt[j*(x*n+1)] = (unsigned char) filter_type;
-      STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);
-   }
-   STBIW_FREE(line_buffer);
-   zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);
-   STBIW_FREE(filt);
-   if (!zlib) return 0;
-
-   // each tag requires 12 bytes of overhead
-   out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);
-   if (!out) return 0;
-   *out_len = 8 + 12+13 + 12+zlen + 12;
-
-   o=out;
-   STBIW_MEMMOVE(o,sig,8); o+= 8;
-   stbiw__wp32(o, 13); // header length
-   stbiw__wptag(o, "IHDR");
-   stbiw__wp32(o, x);
-   stbiw__wp32(o, y);
-   *o++ = 8;
-   *o++ = STBIW_UCHAR(ctype[n]);
-   *o++ = 0;
-   *o++ = 0;
-   *o++ = 0;
-   stbiw__wpcrc(&o,13);
-
-   stbiw__wp32(o, zlen);
-   stbiw__wptag(o, "IDAT");
-   STBIW_MEMMOVE(o, zlib, zlen);
-   o += zlen;
-   STBIW_FREE(zlib);
-   stbiw__wpcrc(&o, zlen);
-
-   stbiw__wp32(o,0);
-   stbiw__wptag(o, "IEND");
-   stbiw__wpcrc(&o,0);
-
-   STBIW_ASSERT(o == out + *out_len);
-
-   return out;
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
-{
-   FILE *f;
-   int len;
-   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
-   if (png == NULL) return 0;
-
-   f = stbiw__fopen(filename, "wb");
-   if (!f) { STBIW_FREE(png); return 0; }
-   fwrite(png, 1, len, f);
-   fclose(f);
-   STBIW_FREE(png);
-   return 1;
-}
-#endif
-
-STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)
-{
-   int len;
-   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
-   if (png == NULL) return 0;
-   func(context, png, len);
-   STBIW_FREE(png);
-   return 1;
-}
-
-
-/* ***************************************************************************
- *
- * JPEG writer
- *
- * This is based on Jon Olick's jo_jpeg.cpp:
- * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html
- */
-
-static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
-      24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };
-
-static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {
-   int bitBuf = *bitBufP, bitCnt = *bitCntP;
-   bitCnt += bs[1];
-   bitBuf |= bs[0] << (24 - bitCnt);
-   while(bitCnt >= 8) {
-      unsigned char c = (bitBuf >> 16) & 255;
-      stbiw__putc(s, c);
-      if(c == 255) {
-         stbiw__putc(s, 0);
-      }
-      bitBuf <<= 8;
-      bitCnt -= 8;
-   }
-   *bitBufP = bitBuf;
-   *bitCntP = bitCnt;
-}
-
-static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) {
-   float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;
-   float z1, z2, z3, z4, z5, z11, z13;
-
-   float tmp0 = d0 + d7;
-   float tmp7 = d0 - d7;
-   float tmp1 = d1 + d6;
-   float tmp6 = d1 - d6;
-   float tmp2 = d2 + d5;
-   float tmp5 = d2 - d5;
-   float tmp3 = d3 + d4;
-   float tmp4 = d3 - d4;
-
-   // Even part
-   float tmp10 = tmp0 + tmp3;   // phase 2
-   float tmp13 = tmp0 - tmp3;
-   float tmp11 = tmp1 + tmp2;
-   float tmp12 = tmp1 - tmp2;
-
-   d0 = tmp10 + tmp11;       // phase 3
-   d4 = tmp10 - tmp11;
-
-   z1 = (tmp12 + tmp13) * 0.707106781f; // c4
-   d2 = tmp13 + z1;       // phase 5
-   d6 = tmp13 - z1;
-
-   // Odd part
-   tmp10 = tmp4 + tmp5;       // phase 2
-   tmp11 = tmp5 + tmp6;
-   tmp12 = tmp6 + tmp7;
-
-   // The rotator is modified from fig 4-8 to avoid extra negations.
-   z5 = (tmp10 - tmp12) * 0.382683433f; // c6
-   z2 = tmp10 * 0.541196100f + z5; // c2-c6
-   z4 = tmp12 * 1.306562965f + z5; // c2+c6
-   z3 = tmp11 * 0.707106781f; // c4
-
-   z11 = tmp7 + z3;      // phase 5
-   z13 = tmp7 - z3;
-
-   *d5p = z13 + z2;         // phase 6
-   *d3p = z13 - z2;
-   *d1p = z11 + z4;
-   *d7p = z11 - z4;
-
-   *d0p = d0;  *d2p = d2;  *d4p = d4;  *d6p = d6;
-}
-
-static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {
-   int tmp1 = val < 0 ? -val : val;
-   val = val < 0 ? val-1 : val;
-   bits[1] = 1;
-   while(tmp1 >>= 1) {
-      ++bits[1];
-   }
-   bits[0] = val & ((1<<bits[1])-1);
-}
-
-static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, int du_stride, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) {
-   const unsigned short EOB[2] = { HTAC[0x00][0], HTAC[0x00][1] };
-   const unsigned short M16zeroes[2] = { HTAC[0xF0][0], HTAC[0xF0][1] };
-   int dataOff, i, j, n, diff, end0pos, x, y;
-   int DU[64];
-
-   // DCT rows
-   for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) {
-      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]);
-   }
-   // DCT columns
-   for(dataOff=0; dataOff<8; ++dataOff) {
-      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4],
-                     &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]);
-   }
-   // Quantize/descale/zigzag the coefficients
-   for(y = 0, j=0; y < 8; ++y) {
-      for(x = 0; x < 8; ++x,++j) {
-         float v;
-         i = y*du_stride+x;
-         v = CDU[i]*fdtbl[j];
-         // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f));
-         // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway?
-         DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f);
-      }
-   }
-
-   // Encode DC
-   diff = DU[0] - DC;
-   if (diff == 0) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
-   } else {
-      unsigned short bits[2];
-      stbiw__jpg_calcBits(diff, bits);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
-   }
-   // Encode ACs
-   end0pos = 63;
-   for(; (end0pos>0)&&(DU[end0pos]==0); --end0pos) {
-   }
-   // end0pos = first element in reverse order !=0
-   if(end0pos == 0) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
-      return DU[0];
-   }
-   for(i = 1; i <= end0pos; ++i) {
-      int startpos = i;
-      int nrzeroes;
-      unsigned short bits[2];
-      for (; DU[i]==0 && i<=end0pos; ++i) {
-      }
-      nrzeroes = i-startpos;
-      if ( nrzeroes >= 16 ) {
-         int lng = nrzeroes>>4;
-         int nrmarker;
-         for (nrmarker=1; nrmarker <= lng; ++nrmarker)
-            stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
-         nrzeroes &= 15;
-      }
-      stbiw__jpg_calcBits(DU[i], bits);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
-   }
-   if(end0pos != 63) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
-   }
-   return DU[0];
-}
-
-static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {
-   // Constants that don't pollute global namespace
-   static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};
-   static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
-   static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};
-   static const unsigned char std_ac_luminance_values[] = {
-      0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
-      0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
-      0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
-      0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
-      0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,
-      0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
-      0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
-   };
-   static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};
-   static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
-   static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};
-   static const unsigned char std_ac_chrominance_values[] = {
-      0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
-      0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
-      0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
-      0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,
-      0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,
-      0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,
-      0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
-   };
-   // Huffman tables
-   static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};
-   static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};
-   static const unsigned short YAC_HT[256][2] = {
-      {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
-   };
-   static const unsigned short UVAC_HT[256][2] = {
-      {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
-   };
-   static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,
-                             37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99};
-   static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,
-                              99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99};
-   static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f,
-                                 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f };
-
-   int row, col, i, k, subsample;
-   float fdtbl_Y[64], fdtbl_UV[64];
-   unsigned char YTable[64], UVTable[64];
-
-   if(!data || !width || !height || comp > 4 || comp < 1) {
-      return 0;
-   }
-
-   quality = quality ? quality : 90;
-   subsample = quality <= 90 ? 1 : 0;
-   quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;
-   quality = quality < 50 ? 5000 / quality : 200 - quality * 2;
-
-   for(i = 0; i < 64; ++i) {
-      int uvti, yti = (YQT[i]*quality+50)/100;
-      YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);
-      uvti = (UVQT[i]*quality+50)/100;
-      UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
-   }
-
-   for(row = 0, k = 0; row < 8; ++row) {
-      for(col = 0; col < 8; ++col, ++k) {
-         fdtbl_Y[k]  = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
-         fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
-      }
-   }
-
-   // Write Headers
-   {
-      static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };
-      static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };
-      const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width),
-                                      3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };
-      s->func(s->context, (void*)head0, sizeof(head0));
-      s->func(s->context, (void*)YTable, sizeof(YTable));
-      stbiw__putc(s, 1);
-      s->func(s->context, UVTable, sizeof(UVTable));
-      s->func(s->context, (void*)head1, sizeof(head1));
-      s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1);
-      s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values));
-      stbiw__putc(s, 0x10); // HTYACinfo
-      s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1);
-      s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values));
-      stbiw__putc(s, 1); // HTUDCinfo
-      s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1);
-      s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values));
-      stbiw__putc(s, 0x11); // HTUACinfo
-      s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1);
-      s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values));
-      s->func(s->context, (void*)head2, sizeof(head2));
-   }
-
-   // Encode 8x8 macroblocks
-   {
-      static const unsigned short fillBits[] = {0x7F, 7};
-      int DCY=0, DCU=0, DCV=0;
-      int bitBuf=0, bitCnt=0;
-      // comp == 2 is grey+alpha (alpha is ignored)
-      int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;
-      const unsigned char *dataR = (const unsigned char *)data;
-      const unsigned char *dataG = dataR + ofsG;
-      const unsigned char *dataB = dataR + ofsB;
-      int x, y, pos;
-      if(subsample) {
-         for(y = 0; y < height; y += 16) {
-            for(x = 0; x < width; x += 16) {
-               float Y[256], U[256], V[256];
-               for(row = y, pos = 0; row < y+16; ++row) {
-                  // row >= height => use last input row
-                  int clamped_row = (row < height) ? row : height - 1;
-                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
-                  for(col = x; col < x+16; ++col, ++pos) {
-                     // if col >= width => use pixel from last input column
-                     int p = base_p + ((col < width) ? col : (width-1))*comp;
-                     float r = dataR[p], g = dataG[p], b = dataB[p];
-                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
-                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
-                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
-                  }
-               }
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-
-               // subsample U,V
-               {
-                  float subU[64], subV[64];
-                  int yy, xx;
-                  for(yy = 0, pos = 0; yy < 8; ++yy) {
-                     for(xx = 0; xx < 8; ++xx, ++pos) {
-                        int j = yy*32+xx*2;
-                        subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f;
-                        subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f;
-                     }
-                  }
-                  DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
-                  DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
-               }
-            }
-         }
-      } else {
-         for(y = 0; y < height; y += 8) {
-            for(x = 0; x < width; x += 8) {
-               float Y[64], U[64], V[64];
-               for(row = y, pos = 0; row < y+8; ++row) {
-                  // row >= height => use last input row
-                  int clamped_row = (row < height) ? row : height - 1;
-                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
-                  for(col = x; col < x+8; ++col, ++pos) {
-                     // if col >= width => use pixel from last input column
-                     int p = base_p + ((col < width) ? col : (width-1))*comp;
-                     float r = dataR[p], g = dataG[p], b = dataB[p];
-                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
-                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
-                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
-                  }
-               }
-
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y,  DCY, YDC_HT, YAC_HT);
-               DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
-               DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
-            }
-         }
-      }
-
-      // Do the bit alignment of the EOI marker
-      stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits);
-   }
-
-   // EOI
-   stbiw__putc(s, 0xFF);
-   stbiw__putc(s, 0xD9);
-
-   return 1;
-}
-
-STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);
-}
-
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif
-
-#endif // STB_IMAGE_WRITE_IMPLEMENTATION
-
-/* Revision history
-      1.14  (2020-02-02) updated JPEG writer to downsample chroma channels
-      1.13
-      1.12
-      1.11  (2019-08-11)
-
-      1.10  (2019-02-07)
-             support utf8 filenames in Windows; fix warnings and platform ifdefs
-      1.09  (2018-02-11)
-             fix typo in zlib quality API, improve STB_I_W_STATIC in C++
-      1.08  (2018-01-29)
-             add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter
-      1.07  (2017-07-24)
-             doc fix
-      1.06 (2017-07-23)
-             writing JPEG (using Jon Olick's code)
-      1.05   ???
-      1.04 (2017-03-03)
-             monochrome BMP expansion
-      1.03   ???
-      1.02 (2016-04-02)
-             avoid allocating large structures on the stack
-      1.01 (2016-01-16)
-             STBIW_REALLOC_SIZED: support allocators with no realloc support
-             avoid race-condition in crc initialization
-             minor compile issues
-      1.00 (2015-09-14)
-             installable file IO function
-      0.99 (2015-09-13)
-             warning fixes; TGA rle support
-      0.98 (2015-04-08)
-             added STBIW_MALLOC, STBIW_ASSERT etc
-      0.97 (2015-01-18)
-             fixed HDR asserts, rewrote HDR rle logic
-      0.96 (2015-01-17)
-             add HDR output
-             fix monochrome BMP
-      0.95 (2014-08-17)
-                      add monochrome TGA output
-      0.94 (2014-05-31)
-             rename private functions to avoid conflicts with stb_image.h
-      0.93 (2014-05-27)
-             warning fixes
-      0.92 (2010-08-01)
-             casts to unsigned char to fix warnings
-      0.91 (2010-07-17)
-             first public release
-      0.90   first internal release
-*/
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_perlin.h b/raylib/external/stb_perlin.h
deleted file mode 100644 (file)
index 47cb9a4..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-// stb_perlin.h - v0.5 - perlin noise
-// public domain single-file C implementation by Sean Barrett
-//
-// LICENSE
-//
-//   See end of file.
-//
-//
-// to create the implementation,
-//     #define STB_PERLIN_IMPLEMENTATION
-// in *one* C/CPP file that includes this file.
-//
-//
-// Documentation:
-//
-// float  stb_perlin_noise3( float x,
-//                           float y,
-//                           float z,
-//                           int   x_wrap=0,
-//                           int   y_wrap=0,
-//                           int   z_wrap=0)
-//
-// This function computes a random value at the coordinate (x,y,z).
-// Adjacent random values are continuous but the noise fluctuates
-// its randomness with period 1, i.e. takes on wholly unrelated values
-// at integer points. Specifically, this implements Ken Perlin's
-// revised noise function from 2002.
-//
-// The "wrap" parameters can be used to create wraparound noise that
-// wraps at powers of two. The numbers MUST be powers of two. Specify
-// 0 to mean "don't care". (The noise always wraps every 256 due
-// details of the implementation, even if you ask for larger or no
-// wrapping.)
-//
-// float  stb_perlin_noise3_seed( float x,
-//                                float y,
-//                                float z,
-//                                int   x_wrap=0,
-//                                int   y_wrap=0,
-//                                int   z_wrap=0,
-//                                int   seed)
-//
-// As above, but 'seed' selects from multiple different variations of the
-// noise function. The current implementation only uses the bottom 8 bits
-// of 'seed', but possibly in the future more bits will be used.
-//
-//
-// Fractal Noise:
-//
-// Three common fractal noise functions are included, which produce
-// a wide variety of nice effects depending on the parameters
-// provided. Note that each function will call stb_perlin_noise3
-// 'octaves' times, so this parameter will affect runtime.
-//
-// float stb_perlin_ridge_noise3(float x, float y, float z,
-//                               float lacunarity, float gain, float offset, int octaves)
-//
-// float stb_perlin_fbm_noise3(float x, float y, float z,
-//                             float lacunarity, float gain, int octaves)
-//
-// float stb_perlin_turbulence_noise3(float x, float y, float z,
-//                                    float lacunarity, float gain, int octaves)
-//
-// Typical values to start playing with:
-//     octaves    =   6     -- number of "octaves" of noise3() to sum
-//     lacunarity = ~ 2.0   -- spacing between successive octaves (use exactly 2.0 for wrapping output)
-//     gain       =   0.5   -- relative weighting applied to each successive octave
-//     offset     =   1.0?  -- used to invert the ridges, may need to be larger, not sure
-//
-//
-// Contributors:
-//    Jack Mott - additional noise functions
-//    Jordan Peck - seeded noise
-//
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap);
-extern float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed);
-extern float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves);
-extern float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
-extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
-extern float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed);
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef STB_PERLIN_IMPLEMENTATION
-
-#include <math.h> // fabs()
-
-// not same permutation table as Perlin's reference to avoid copyright issues;
-// Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/
-static unsigned char stb__perlin_randtab[512] =
-{
-   23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
-   152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
-   175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
-   8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
-   225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
-   94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
-   165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
-   65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
-   26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
-   250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
-   132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
-   91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
-   38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
-   131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
-   27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
-   61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
-
-   // and a second copy so we don't need an extra mask or static initializer
-   23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
-   152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
-   175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
-   8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
-   225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
-   94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
-   165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
-   65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
-   26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
-   250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
-   132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
-   91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
-   38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
-   131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
-   27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
-   61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
-};
-
-
-// perlin's gradient has 12 cases so some get used 1/16th of the time
-// and some 2/16ths. We reduce bias by changing those fractions
-// to 5/64ths and 6/64ths
-
-// this array is designed to match the previous implementation
-// of gradient hash: indices[stb__perlin_randtab[i]&63]
-static unsigned char stb__perlin_randtab_grad_idx[512] =
-{
-    7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
-    8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
-    7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
-    8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
-    5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
-    2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
-    9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
-    1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
-    10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
-    6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
-    4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
-    11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
-    10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
-    3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
-    11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
-    9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
-
-    // and a second copy so we don't need an extra mask or static initializer
-    7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
-    8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
-    7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
-    8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
-    5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
-    2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
-    9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
-    1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
-    10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
-    6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
-    4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
-    11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
-    10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
-    3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
-    11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
-    9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
-};
-
-static float stb__perlin_lerp(float a, float b, float t)
-{
-   return a + (b-a) * t;
-}
-
-static int stb__perlin_fastfloor(float a)
-{
-    int ai = (int) a;
-    return (a < ai) ? ai-1 : ai;
-}
-
-// different grad function from Perlin's, but easy to modify to match reference
-static float stb__perlin_grad(int grad_idx, float x, float y, float z)
-{
-   static float basis[12][4] =
-   {
-      {  1, 1, 0 },
-      { -1, 1, 0 },
-      {  1,-1, 0 },
-      { -1,-1, 0 },
-      {  1, 0, 1 },
-      { -1, 0, 1 },
-      {  1, 0,-1 },
-      { -1, 0,-1 },
-      {  0, 1, 1 },
-      {  0,-1, 1 },
-      {  0, 1,-1 },
-      {  0,-1,-1 },
-   };
-
-   float *grad = basis[grad_idx];
-   return grad[0]*x + grad[1]*y + grad[2]*z;
-}
-
-float stb_perlin_noise3_internal(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
-{
-   float u,v,w;
-   float n000,n001,n010,n011,n100,n101,n110,n111;
-   float n00,n01,n10,n11;
-   float n0,n1;
-
-   unsigned int x_mask = (x_wrap-1) & 255;
-   unsigned int y_mask = (y_wrap-1) & 255;
-   unsigned int z_mask = (z_wrap-1) & 255;
-   int px = stb__perlin_fastfloor(x);
-   int py = stb__perlin_fastfloor(y);
-   int pz = stb__perlin_fastfloor(z);
-   int x0 = px & x_mask, x1 = (px+1) & x_mask;
-   int y0 = py & y_mask, y1 = (py+1) & y_mask;
-   int z0 = pz & z_mask, z1 = (pz+1) & z_mask;
-   int r0,r1, r00,r01,r10,r11;
-
-   #define stb__perlin_ease(a)   (((a*6-15)*a + 10) * a * a * a)
-
-   x -= px; u = stb__perlin_ease(x);
-   y -= py; v = stb__perlin_ease(y);
-   z -= pz; w = stb__perlin_ease(z);
-
-   r0 = stb__perlin_randtab[x0+seed];
-   r1 = stb__perlin_randtab[x1+seed];
-
-   r00 = stb__perlin_randtab[r0+y0];
-   r01 = stb__perlin_randtab[r0+y1];
-   r10 = stb__perlin_randtab[r1+y0];
-   r11 = stb__perlin_randtab[r1+y1];
-
-   n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x  , y  , z   );
-   n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x  , y  , z-1 );
-   n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x  , y-1, z   );
-   n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x  , y-1, z-1 );
-   n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y  , z   );
-   n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y  , z-1 );
-   n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z   );
-   n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
-
-   n00 = stb__perlin_lerp(n000,n001,w);
-   n01 = stb__perlin_lerp(n010,n011,w);
-   n10 = stb__perlin_lerp(n100,n101,w);
-   n11 = stb__perlin_lerp(n110,n111,w);
-
-   n0 = stb__perlin_lerp(n00,n01,v);
-   n1 = stb__perlin_lerp(n10,n11,v);
-
-   return stb__perlin_lerp(n0,n1,u);
-}
-
-float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap)
-{
-    return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap,0);
-}
-
-float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed)
-{
-    return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap, (unsigned char) seed);
-}
-
-float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float prev = 1.0f;
-   float amplitude = 0.5f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i);
-      r = offset - (float) fabs(r);
-      r = r*r;
-      sum += r*amplitude*prev;
-      prev = r;
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float amplitude = 1.0f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      sum += stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float amplitude = 1.0f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
-      sum += (float) fabs(r);
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
-{
-   float u,v,w;
-   float n000,n001,n010,n011,n100,n101,n110,n111;
-   float n00,n01,n10,n11;
-   float n0,n1;
-
-   int px = stb__perlin_fastfloor(x);
-   int py = stb__perlin_fastfloor(y);
-   int pz = stb__perlin_fastfloor(z);
-   int x_wrap2 = (x_wrap ? x_wrap : 256);
-   int y_wrap2 = (y_wrap ? y_wrap : 256);
-   int z_wrap2 = (z_wrap ? z_wrap : 256);
-   int x0 = px % x_wrap2, x1;
-   int y0 = py % y_wrap2, y1;
-   int z0 = pz % z_wrap2, z1;
-   int r0,r1, r00,r01,r10,r11;
-
-   if (x0 < 0) x0 += x_wrap2;
-   if (y0 < 0) y0 += y_wrap2;
-   if (z0 < 0) z0 += z_wrap2;
-   x1 = (x0+1) % x_wrap2;
-   y1 = (y0+1) % y_wrap2;
-   z1 = (z0+1) % z_wrap2;
-
-   #define stb__perlin_ease(a)   (((a*6-15)*a + 10) * a * a * a)
-
-   x -= px; u = stb__perlin_ease(x);
-   y -= py; v = stb__perlin_ease(y);
-   z -= pz; w = stb__perlin_ease(z);
-
-   r0 = stb__perlin_randtab[x0];
-   r0 = stb__perlin_randtab[r0+seed];
-   r1 = stb__perlin_randtab[x1];
-   r1 = stb__perlin_randtab[r1+seed];
-
-   r00 = stb__perlin_randtab[r0+y0];
-   r01 = stb__perlin_randtab[r0+y1];
-   r10 = stb__perlin_randtab[r1+y0];
-   r11 = stb__perlin_randtab[r1+y1];
-
-   n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x  , y  , z   );
-   n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x  , y  , z-1 );
-   n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x  , y-1, z   );
-   n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x  , y-1, z-1 );
-   n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y  , z   );
-   n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y  , z-1 );
-   n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z   );
-   n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
-
-   n00 = stb__perlin_lerp(n000,n001,w);
-   n01 = stb__perlin_lerp(n010,n011,w);
-   n10 = stb__perlin_lerp(n100,n101,w);
-   n11 = stb__perlin_lerp(n110,n111,w);
-
-   n0 = stb__perlin_lerp(n00,n01,v);
-   n1 = stb__perlin_lerp(n10,n11,v);
-
-   return stb__perlin_lerp(n0,n1,u);
-}
-#endif  // STB_PERLIN_IMPLEMENTATION
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_rect_pack.h b/raylib/external/stb_rect_pack.h
deleted file mode 100644 (file)
index 5c848de..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-// stb_rect_pack.h - v1.00 - public domain - rectangle packing
-// Sean Barrett 2014
-//
-// Useful for e.g. packing rectangular textures into an atlas.
-// Does not do rotation.
-//
-// Not necessarily the awesomest packing method, but better than
-// the totally naive one in stb_truetype (which is primarily what
-// this is meant to replace).
-//
-// Has only had a few tests run, may have issues.
-//
-// More docs to come.
-//
-// No memory allocations; uses qsort() and assert() from stdlib.
-// Can override those by defining STBRP_SORT and STBRP_ASSERT.
-//
-// This library currently uses the Skyline Bottom-Left algorithm.
-//
-// Please note: better rectangle packers are welcome! Please
-// implement them to the same API, but with a different init
-// function.
-//
-// Credits
-//
-//  Library
-//    Sean Barrett
-//  Minor features
-//    Martins Mozeiko
-//    github:IntellectualKitty
-//
-//  Bugfixes / warning fixes
-//    Jeremy Jaussaud
-//    Fabian Giesen
-//
-// Version history:
-//
-//     1.00  (2019-02-25)  avoid small space waste; gracefully fail too-wide rectangles
-//     0.99  (2019-02-07)  warning fixes
-//     0.11  (2017-03-03)  return packing success/fail result
-//     0.10  (2016-10-25)  remove cast-away-const to avoid warnings
-//     0.09  (2016-08-27)  fix compiler warnings
-//     0.08  (2015-09-13)  really fix bug with empty rects (w=0 or h=0)
-//     0.07  (2015-09-13)  fix bug with empty rects (w=0 or h=0)
-//     0.06  (2015-04-15)  added STBRP_SORT to allow replacing qsort
-//     0.05:  added STBRP_ASSERT to allow replacing assert
-//     0.04:  fixed minor bug in STBRP_LARGE_RECTS support
-//     0.01:  initial release
-//
-// LICENSE
-//
-//   See end of file for license information.
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//       INCLUDE SECTION
-//
-
-#ifndef STB_INCLUDE_STB_RECT_PACK_H
-#define STB_INCLUDE_STB_RECT_PACK_H
-
-#define STB_RECT_PACK_VERSION  1
-
-#ifdef STBRP_STATIC
-#define STBRP_DEF static
-#else
-#define STBRP_DEF extern
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct stbrp_context stbrp_context;
-typedef struct stbrp_node    stbrp_node;
-typedef struct stbrp_rect    stbrp_rect;
-
-#ifdef STBRP_LARGE_RECTS
-typedef int            stbrp_coord;
-#else
-typedef unsigned short stbrp_coord;
-#endif
-
-STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
-// Assign packed locations to rectangles. The rectangles are of type
-// 'stbrp_rect' defined below, stored in the array 'rects', and there
-// are 'num_rects' many of them.
-//
-// Rectangles which are successfully packed have the 'was_packed' flag
-// set to a non-zero value and 'x' and 'y' store the minimum location
-// on each axis (i.e. bottom-left in cartesian coordinates, top-left
-// if you imagine y increasing downwards). Rectangles which do not fit
-// have the 'was_packed' flag set to 0.
-//
-// You should not try to access the 'rects' array from another thread
-// while this function is running, as the function temporarily reorders
-// the array while it executes.
-//
-// To pack into another rectangle, you need to call stbrp_init_target
-// again. To continue packing into the same rectangle, you can call
-// this function again. Calling this multiple times with multiple rect
-// arrays will probably produce worse packing results than calling it
-// a single time with the full rectangle array, but the option is
-// available.
-//
-// The function returns 1 if all of the rectangles were successfully
-// packed and 0 otherwise.
-
-struct stbrp_rect
-{
-   // reserved for your use:
-   int            id;
-
-   // input:
-   stbrp_coord    w, h;
-
-   // output:
-   stbrp_coord    x, y;
-   int            was_packed;  // non-zero if valid packing
-
-}; // 16 bytes, nominally
-
-
-STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
-// Initialize a rectangle packer to:
-//    pack a rectangle that is 'width' by 'height' in dimensions
-//    using temporary storage provided by the array 'nodes', which is 'num_nodes' long
-//
-// You must call this function every time you start packing into a new target.
-//
-// There is no "shutdown" function. The 'nodes' memory must stay valid for
-// the following stbrp_pack_rects() call (or calls), but can be freed after
-// the call (or calls) finish.
-//
-// Note: to guarantee best results, either:
-//       1. make sure 'num_nodes' >= 'width'
-//   or  2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
-//
-// If you don't do either of the above things, widths will be quantized to multiples
-// of small integers to guarantee the algorithm doesn't run out of temporary storage.
-//
-// If you do #2, then the non-quantized algorithm will be used, but the algorithm
-// may run out of temporary storage and be unable to pack some rectangles.
-
-STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
-// Optionally call this function after init but before doing any packing to
-// change the handling of the out-of-temp-memory scenario, described above.
-// If you call init again, this will be reset to the default (false).
-
-
-STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
-// Optionally select which packing heuristic the library should use. Different
-// heuristics will produce better/worse results for different data sets.
-// If you call init again, this will be reset to the default.
-
-enum
-{
-   STBRP_HEURISTIC_Skyline_default=0,
-   STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
-   STBRP_HEURISTIC_Skyline_BF_sortHeight
-};
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// the details of the following structures don't matter to you, but they must
-// be visible so you can handle the memory allocations for them
-
-struct stbrp_node
-{
-   stbrp_coord  x,y;
-   stbrp_node  *next;
-};
-
-struct stbrp_context
-{
-   int width;
-   int height;
-   int align;
-   int init_mode;
-   int heuristic;
-   int num_nodes;
-   stbrp_node *active_head;
-   stbrp_node *free_head;
-   stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//     IMPLEMENTATION SECTION
-//
-
-#ifdef STB_RECT_PACK_IMPLEMENTATION
-#ifndef STBRP_SORT
-#include <stdlib.h>
-#define STBRP_SORT qsort
-#endif
-
-#ifndef STBRP_ASSERT
-#include <assert.h>
-#define STBRP_ASSERT assert
-#endif
-
-#ifdef _MSC_VER
-#define STBRP__NOTUSED(v)  (void)(v)
-#else
-#define STBRP__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-enum
-{
-   STBRP__INIT_skyline = 1
-};
-
-STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
-{
-   switch (context->init_mode) {
-      case STBRP__INIT_skyline:
-         STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
-         context->heuristic = heuristic;
-         break;
-      default:
-         STBRP_ASSERT(0);
-   }
-}
-
-STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
-{
-   if (allow_out_of_mem)
-      // if it's ok to run out of memory, then don't bother aligning them;
-      // this gives better packing, but may fail due to OOM (even though
-      // the rectangles easily fit). @TODO a smarter approach would be to only
-      // quantize once we've hit OOM, then we could get rid of this parameter.
-      context->align = 1;
-   else {
-      // if it's not ok to run out of memory, then quantize the widths
-      // so that num_nodes is always enough nodes.
-      //
-      // I.e. num_nodes * align >= width
-      //                  align >= width / num_nodes
-      //                  align = ceil(width/num_nodes)
-
-      context->align = (context->width + context->num_nodes-1) / context->num_nodes;
-   }
-}
-
-STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
-{
-   int i;
-#ifndef STBRP_LARGE_RECTS
-   STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
-#endif
-
-   for (i=0; i < num_nodes-1; ++i)
-      nodes[i].next = &nodes[i+1];
-   nodes[i].next = NULL;
-   context->init_mode = STBRP__INIT_skyline;
-   context->heuristic = STBRP_HEURISTIC_Skyline_default;
-   context->free_head = &nodes[0];
-   context->active_head = &context->extra[0];
-   context->width = width;
-   context->height = height;
-   context->num_nodes = num_nodes;
-   stbrp_setup_allow_out_of_mem(context, 0);
-
-   // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
-   context->extra[0].x = 0;
-   context->extra[0].y = 0;
-   context->extra[0].next = &context->extra[1];
-   context->extra[1].x = (stbrp_coord) width;
-#ifdef STBRP_LARGE_RECTS
-   context->extra[1].y = (1<<30);
-#else
-   context->extra[1].y = 65535;
-#endif
-   context->extra[1].next = NULL;
-}
-
-// find minimum y position if it starts at x1
-static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
-{
-   stbrp_node *node = first;
-   int x1 = x0 + width;
-   int min_y, visited_width, waste_area;
-
-   STBRP__NOTUSED(c);
-
-   STBRP_ASSERT(first->x <= x0);
-
-   #if 0
-   // skip in case we're past the node
-   while (node->next->x <= x0)
-      ++node;
-   #else
-   STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
-   #endif
-
-   STBRP_ASSERT(node->x <= x0);
-
-   min_y = 0;
-   waste_area = 0;
-   visited_width = 0;
-   while (node->x < x1) {
-      if (node->y > min_y) {
-         // raise min_y higher.
-         // we've accounted for all waste up to min_y,
-         // but we'll now add more waste for everything we've visted
-         waste_area += visited_width * (node->y - min_y);
-         min_y = node->y;
-         // the first time through, visited_width might be reduced
-         if (node->x < x0)
-            visited_width += node->next->x - x0;
-         else
-            visited_width += node->next->x - node->x;
-      } else {
-         // add waste area
-         int under_width = node->next->x - node->x;
-         if (under_width + visited_width > width)
-            under_width = width - visited_width;
-         waste_area += under_width * (min_y - node->y);
-         visited_width += under_width;
-      }
-      node = node->next;
-   }
-
-   *pwaste = waste_area;
-   return min_y;
-}
-
-typedef struct
-{
-   int x,y;
-   stbrp_node **prev_link;
-} stbrp__findresult;
-
-static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
-{
-   int best_waste = (1<<30), best_x, best_y = (1 << 30);
-   stbrp__findresult fr;
-   stbrp_node **prev, *node, *tail, **best = NULL;
-
-   // align to multiple of c->align
-   width = (width + c->align - 1);
-   width -= width % c->align;
-   STBRP_ASSERT(width % c->align == 0);
-
-   // if it can't possibly fit, bail immediately
-   if (width > c->width || height > c->height) {
-      fr.prev_link = NULL;
-      fr.x = fr.y = 0;
-      return fr;
-   }
-
-   node = c->active_head;
-   prev = &c->active_head;
-   while (node->x + width <= c->width) {
-      int y,waste;
-      y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
-      if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
-         // bottom left
-         if (y < best_y) {
-            best_y = y;
-            best = prev;
-         }
-      } else {
-         // best-fit
-         if (y + height <= c->height) {
-            // can only use it if it first vertically
-            if (y < best_y || (y == best_y && waste < best_waste)) {
-               best_y = y;
-               best_waste = waste;
-               best = prev;
-            }
-         }
-      }
-      prev = &node->next;
-      node = node->next;
-   }
-
-   best_x = (best == NULL) ? 0 : (*best)->x;
-
-   // if doing best-fit (BF), we also have to try aligning right edge to each node position
-   //
-   // e.g, if fitting
-   //
-   //     ____________________
-   //    |____________________|
-   //
-   //            into
-   //
-   //   |                         |
-   //   |             ____________|
-   //   |____________|
-   //
-   // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
-   //
-   // This makes BF take about 2x the time
-
-   if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
-      tail = c->active_head;
-      node = c->active_head;
-      prev = &c->active_head;
-      // find first node that's admissible
-      while (tail->x < width)
-         tail = tail->next;
-      while (tail) {
-         int xpos = tail->x - width;
-         int y,waste;
-         STBRP_ASSERT(xpos >= 0);
-         // find the left position that matches this
-         while (node->next->x <= xpos) {
-            prev = &node->next;
-            node = node->next;
-         }
-         STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
-         y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
-         if (y + height <= c->height) {
-            if (y <= best_y) {
-               if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
-                  best_x = xpos;
-                  STBRP_ASSERT(y <= best_y);
-                  best_y = y;
-                  best_waste = waste;
-                  best = prev;
-               }
-            }
-         }
-         tail = tail->next;
-      }
-   }
-
-   fr.prev_link = best;
-   fr.x = best_x;
-   fr.y = best_y;
-   return fr;
-}
-
-static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
-{
-   // find best position according to heuristic
-   stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
-   stbrp_node *node, *cur;
-
-   // bail if:
-   //    1. it failed
-   //    2. the best node doesn't fit (we don't always check this)
-   //    3. we're out of memory
-   if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
-      res.prev_link = NULL;
-      return res;
-   }
-
-   // on success, create new node
-   node = context->free_head;
-   node->x = (stbrp_coord) res.x;
-   node->y = (stbrp_coord) (res.y + height);
-
-   context->free_head = node->next;
-
-   // insert the new node into the right starting point, and
-   // let 'cur' point to the remaining nodes needing to be
-   // stiched back in
-
-   cur = *res.prev_link;
-   if (cur->x < res.x) {
-      // preserve the existing one, so start testing with the next one
-      stbrp_node *next = cur->next;
-      cur->next = node;
-      cur = next;
-   } else {
-      *res.prev_link = node;
-   }
-
-   // from here, traverse cur and free the nodes, until we get to one
-   // that shouldn't be freed
-   while (cur->next && cur->next->x <= res.x + width) {
-      stbrp_node *next = cur->next;
-      // move the current node to the free list
-      cur->next = context->free_head;
-      context->free_head = cur;
-      cur = next;
-   }
-
-   // stitch the list back in
-   node->next = cur;
-
-   if (cur->x < res.x + width)
-      cur->x = (stbrp_coord) (res.x + width);
-
-#ifdef _DEBUG
-   cur = context->active_head;
-   while (cur->x < context->width) {
-      STBRP_ASSERT(cur->x < cur->next->x);
-      cur = cur->next;
-   }
-   STBRP_ASSERT(cur->next == NULL);
-
-   {
-      int count=0;
-      cur = context->active_head;
-      while (cur) {
-         cur = cur->next;
-         ++count;
-      }
-      cur = context->free_head;
-      while (cur) {
-         cur = cur->next;
-         ++count;
-      }
-      STBRP_ASSERT(count == context->num_nodes+2);
-   }
-#endif
-
-   return res;
-}
-
-static int rect_height_compare(const void *a, const void *b)
-{
-   const stbrp_rect *p = (const stbrp_rect *) a;
-   const stbrp_rect *q = (const stbrp_rect *) b;
-   if (p->h > q->h)
-      return -1;
-   if (p->h < q->h)
-      return  1;
-   return (p->w > q->w) ? -1 : (p->w < q->w);
-}
-
-static int rect_original_order(const void *a, const void *b)
-{
-   const stbrp_rect *p = (const stbrp_rect *) a;
-   const stbrp_rect *q = (const stbrp_rect *) b;
-   return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
-}
-
-#ifdef STBRP_LARGE_RECTS
-#define STBRP__MAXVAL  0xffffffff
-#else
-#define STBRP__MAXVAL  0xffff
-#endif
-
-STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
-{
-   int i, all_rects_packed = 1;
-
-   // we use the 'was_packed' field internally to allow sorting/unsorting
-   for (i=0; i < num_rects; ++i) {
-      rects[i].was_packed = i;
-   }
-
-   // sort according to heuristic
-   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
-
-   for (i=0; i < num_rects; ++i) {
-      if (rects[i].w == 0 || rects[i].h == 0) {
-         rects[i].x = rects[i].y = 0;  // empty rect needs no space
-      } else {
-         stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
-         if (fr.prev_link) {
-            rects[i].x = (stbrp_coord) fr.x;
-            rects[i].y = (stbrp_coord) fr.y;
-         } else {
-            rects[i].x = rects[i].y = STBRP__MAXVAL;
-         }
-      }
-   }
-
-   // unsort
-   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
-
-   // set was_packed flags and all_rects_packed status
-   for (i=0; i < num_rects; ++i) {
-      rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
-      if (!rects[i].was_packed)
-         all_rects_packed = 0;
-   }
-
-   // return the all_rects_packed status
-   return all_rects_packed;
-}
-#endif
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_truetype.h b/raylib/external/stb_truetype.h
deleted file mode 100644 (file)
index 935a6de..0000000
+++ /dev/null
@@ -1,5011 +0,0 @@
-// stb_truetype.h - v1.24 - public domain
-// authored from 2009-2020 by Sean Barrett / RAD Game Tools
-//
-// =======================================================================
-//
-//    NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES
-//
-// This library does no range checking of the offsets found in the file,
-// meaning an attacker can use it to read arbitrary memory.
-//
-// =======================================================================
-//
-//   This library processes TrueType files:
-//        parse files
-//        extract glyph metrics
-//        extract glyph shapes
-//        render glyphs to one-channel bitmaps with antialiasing (box filter)
-//        render glyphs to one-channel SDF bitmaps (signed-distance field/function)
-//
-//   Todo:
-//        non-MS cmaps
-//        crashproof on bad data
-//        hinting? (no longer patented)
-//        cleartype-style AA?
-//        optimize: use simple memory allocator for intermediates
-//        optimize: build edge-list directly from curves
-//        optimize: rasterize directly from curves?
-//
-// ADDITIONAL CONTRIBUTORS
-//
-//   Mikko Mononen: compound shape support, more cmap formats
-//   Tor Andersson: kerning, subpixel rendering
-//   Dougall Johnson: OpenType / Type 2 font handling
-//   Daniel Ribeiro Maciel: basic GPOS-based kerning
-//
-//   Misc other:
-//       Ryan Gordon
-//       Simon Glass
-//       github:IntellectualKitty
-//       Imanol Celaya
-//       Daniel Ribeiro Maciel
-//
-//   Bug/warning reports/fixes:
-//       "Zer" on mollyrocket       Fabian "ryg" Giesen   github:NiLuJe
-//       Cass Everitt               Martins Mozeiko       github:aloucks
-//       stoiko (Haemimont Games)   Cap Petschulat        github:oyvindjam
-//       Brian Hook                 Omar Cornut           github:vassvik
-//       Walter van Niftrik         Ryan Griege
-//       David Gow                  Peter LaValle
-//       David Given                Sergey Popov
-//       Ivan-Assen Ivanov          Giumo X. Clanjor
-//       Anthony Pesch              Higor Euripedes
-//       Johan Duparc               Thomas Fields
-//       Hou Qiming                 Derek Vinyard
-//       Rob Loach                  Cort Stratton
-//       Kenney Phillis Jr.         Brian Costabile            
-//       Ken Voskuil (kaesve)       
-//
-// VERSION HISTORY
-//
-//   1.24 (2020-02-05) fix warning
-//   1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS)
-//   1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined
-//   1.21 (2019-02-25) fix warning
-//   1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
-//   1.19 (2018-02-11) GPOS kerning, STBTT_fmod
-//   1.18 (2018-01-29) add missing function
-//   1.17 (2017-07-23) make more arguments const; doc fix
-//   1.16 (2017-07-12) SDF support
-//   1.15 (2017-03-03) make more arguments const
-//   1.14 (2017-01-16) num-fonts-in-TTC function
-//   1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
-//   1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
-//   1.11 (2016-04-02) fix unused-variable warning
-//   1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef
-//   1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly
-//   1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
-//   1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
-//                     variant PackFontRanges to pack and render in separate phases;
-//                     fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
-//                     fixed an assert() bug in the new rasterizer
-//                     replace assert() with STBTT_assert() in new rasterizer
-//
-//   Full history can be found at the end of this file.
-//
-// LICENSE
-//
-//   See end of file for license information.
-//
-// USAGE
-//
-//   Include this file in whatever places need to refer to it. In ONE C/C++
-//   file, write:
-//      #define STB_TRUETYPE_IMPLEMENTATION
-//   before the #include of this file. This expands out the actual
-//   implementation into that C/C++ file.
-//
-//   To make the implementation private to the file that generates the implementation,
-//      #define STBTT_STATIC
-//
-//   Simple 3D API (don't ship this, but it's fine for tools and quick start)
-//           stbtt_BakeFontBitmap()               -- bake a font to a bitmap for use as texture
-//           stbtt_GetBakedQuad()                 -- compute quad to draw for a given char
-//
-//   Improved 3D API (more shippable):
-//           #include "stb_rect_pack.h"           -- optional, but you really want it
-//           stbtt_PackBegin()
-//           stbtt_PackSetOversampling()          -- for improved quality on small fonts
-//           stbtt_PackFontRanges()               -- pack and renders
-//           stbtt_PackEnd()
-//           stbtt_GetPackedQuad()
-//
-//   "Load" a font file from a memory buffer (you have to keep the buffer loaded)
-//           stbtt_InitFont()
-//           stbtt_GetFontOffsetForIndex()        -- indexing for TTC font collections
-//           stbtt_GetNumberOfFonts()             -- number of fonts for TTC font collections
-//
-//   Render a unicode codepoint to a bitmap
-//           stbtt_GetCodepointBitmap()           -- allocates and returns a bitmap
-//           stbtt_MakeCodepointBitmap()          -- renders into bitmap you provide
-//           stbtt_GetCodepointBitmapBox()        -- how big the bitmap must be
-//
-//   Character advance/positioning
-//           stbtt_GetCodepointHMetrics()
-//           stbtt_GetFontVMetrics()
-//           stbtt_GetFontVMetricsOS2()
-//           stbtt_GetCodepointKernAdvance()
-//
-//   Starting with version 1.06, the rasterizer was replaced with a new,
-//   faster and generally-more-precise rasterizer. The new rasterizer more
-//   accurately measures pixel coverage for anti-aliasing, except in the case
-//   where multiple shapes overlap, in which case it overestimates the AA pixel
-//   coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If
-//   this turns out to be a problem, you can re-enable the old rasterizer with
-//        #define STBTT_RASTERIZER_VERSION 1
-//   which will incur about a 15% speed hit.
-//
-// ADDITIONAL DOCUMENTATION
-//
-//   Immediately after this block comment are a series of sample programs.
-//
-//   After the sample programs is the "header file" section. This section
-//   includes documentation for each API function.
-//
-//   Some important concepts to understand to use this library:
-//
-//      Codepoint
-//         Characters are defined by unicode codepoints, e.g. 65 is
-//         uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is
-//         the hiragana for "ma".
-//
-//      Glyph
-//         A visual character shape (every codepoint is rendered as
-//         some glyph)
-//
-//      Glyph index
-//         A font-specific integer ID representing a glyph
-//
-//      Baseline
-//         Glyph shapes are defined relative to a baseline, which is the
-//         bottom of uppercase characters. Characters extend both above
-//         and below the baseline.
-//
-//      Current Point
-//         As you draw text to the screen, you keep track of a "current point"
-//         which is the origin of each character. The current point's vertical
-//         position is the baseline. Even "baked fonts" use this model.
-//
-//      Vertical Font Metrics
-//         The vertical qualities of the font, used to vertically position
-//         and space the characters. See docs for stbtt_GetFontVMetrics.
-//
-//      Font Size in Pixels or Points
-//         The preferred interface for specifying font sizes in stb_truetype
-//         is to specify how tall the font's vertical extent should be in pixels.
-//         If that sounds good enough, skip the next paragraph.
-//
-//         Most font APIs instead use "points", which are a common typographic
-//         measurement for describing font size, defined as 72 points per inch.
-//         stb_truetype provides a point API for compatibility. However, true
-//         "per inch" conventions don't make much sense on computer displays
-//         since different monitors have different number of pixels per
-//         inch. For example, Windows traditionally uses a convention that
-//         there are 96 pixels per inch, thus making 'inch' measurements have
-//         nothing to do with inches, and thus effectively defining a point to
-//         be 1.333 pixels. Additionally, the TrueType font data provides
-//         an explicit scale factor to scale a given font's glyphs to points,
-//         but the author has observed that this scale factor is often wrong
-//         for non-commercial fonts, thus making fonts scaled in points
-//         according to the TrueType spec incoherently sized in practice.
-//
-// DETAILED USAGE:
-//
-//  Scale:
-//    Select how high you want the font to be, in points or pixels.
-//    Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute
-//    a scale factor SF that will be used by all other functions.
-//
-//  Baseline:
-//    You need to select a y-coordinate that is the baseline of where
-//    your text will appear. Call GetFontBoundingBox to get the baseline-relative
-//    bounding box for all characters. SF*-y0 will be the distance in pixels
-//    that the worst-case character could extend above the baseline, so if
-//    you want the top edge of characters to appear at the top of the
-//    screen where y=0, then you would set the baseline to SF*-y0.
-//
-//  Current point:
-//    Set the current point where the first character will appear. The
-//    first character could extend left of the current point; this is font
-//    dependent. You can either choose a current point that is the leftmost
-//    point and hope, or add some padding, or check the bounding box or
-//    left-side-bearing of the first character to be displayed and set
-//    the current point based on that.
-//
-//  Displaying a character:
-//    Compute the bounding box of the character. It will contain signed values
-//    relative to <current_point, baseline>. I.e. if it returns x0,y0,x1,y1,
-//    then the character should be displayed in the rectangle from
-//    <current_point+SF*x0, baseline+SF*y0> to <current_point+SF*x1,baseline+SF*y1).
-//
-//  Advancing for the next character:
-//    Call GlyphHMetrics, and compute 'current_point += SF * advance'.
-//
-//
-// ADVANCED USAGE
-//
-//   Quality:
-//
-//    - Use the functions with Subpixel at the end to allow your characters
-//      to have subpixel positioning. Since the font is anti-aliased, not
-//      hinted, this is very import for quality. (This is not possible with
-//      baked fonts.)
-//
-//    - Kerning is now supported, and if you're supporting subpixel rendering
-//      then kerning is worth using to give your text a polished look.
-//
-//   Performance:
-//
-//    - Convert Unicode codepoints to glyph indexes and operate on the glyphs;
-//      if you don't do this, stb_truetype is forced to do the conversion on
-//      every call.
-//
-//    - There are a lot of memory allocations. We should modify it to take
-//      a temp buffer and allocate from the temp buffer (without freeing),
-//      should help performance a lot.
-//
-// NOTES
-//
-//   The system uses the raw data found in the .ttf file without changing it
-//   and without building auxiliary data structures. This is a bit inefficient
-//   on little-endian systems (the data is big-endian), but assuming you're
-//   caching the bitmaps or glyph shapes this shouldn't be a big deal.
-//
-//   It appears to be very hard to programmatically determine what font a
-//   given file is in a general way. I provide an API for this, but I don't
-//   recommend it.
-//
-//
-// PERFORMANCE MEASUREMENTS FOR 1.06:
-//
-//                      32-bit     64-bit
-//   Previous release:  8.83 s     7.68 s
-//   Pool allocations:  7.72 s     6.34 s
-//   Inline sort     :  6.54 s     5.65 s
-//   New rasterizer  :  5.63 s     5.00 s
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-////
-////  SAMPLE PROGRAMS
-////
-//
-//  Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless
-//
-#if 0
-#define STB_TRUETYPE_IMPLEMENTATION  // force following include to generate implementation
-#include "stb_truetype.h"
-
-unsigned char ttf_buffer[1<<20];
-unsigned char temp_bitmap[512*512];
-
-stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
-GLuint ftex;
-
-void my_stbtt_initfont(void)
-{
-   fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb"));
-   stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits!
-   // can free ttf_buffer at this point
-   glGenTextures(1, &ftex);
-   glBindTexture(GL_TEXTURE_2D, ftex);
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);
-   // can free temp_bitmap at this point
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-}
-
-void my_stbtt_print(float x, float y, char *text)
-{
-   // assume orthographic projection with units = screen pixels, origin at top left
-   glEnable(GL_TEXTURE_2D);
-   glBindTexture(GL_TEXTURE_2D, ftex);
-   glBegin(GL_QUADS);
-   while (*text) {
-      if (*text >= 32 && *text < 128) {
-         stbtt_aligned_quad q;
-         stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9
-         glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0);
-         glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0);
-         glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1);
-         glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1);
-      }
-      ++text;
-   }
-   glEnd();
-}
-#endif
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// Complete program (this compiles): get a single bitmap, print as ASCII art
-//
-#if 0
-#include <stdio.h>
-#define STB_TRUETYPE_IMPLEMENTATION  // force following include to generate implementation
-#include "stb_truetype.h"
-
-char ttf_buffer[1<<25];
-
-int main(int argc, char **argv)
-{
-   stbtt_fontinfo font;
-   unsigned char *bitmap;
-   int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20);
-
-   fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb"));
-
-   stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
-   bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0);
-
-   for (j=0; j < h; ++j) {
-      for (i=0; i < w; ++i)
-         putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
-      putchar('\n');
-   }
-   return 0;
-}
-#endif
-//
-// Output:
-//
-//     .ii.
-//    @@@@@@.
-//   V@Mio@@o
-//   :i.  V@V
-//     :oM@@M
-//   :@@@MM@M
-//   @@o  o@M
-//  :@@.  M@M
-//   @@@o@@@@
-//   :M@@V:@@.
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// Complete program: print "Hello World!" banner, with bugs
-//
-#if 0
-char buffer[24<<20];
-unsigned char screen[20][79];
-
-int main(int arg, char **argv)
-{
-   stbtt_fontinfo font;
-   int i,j,ascent,baseline,ch=0;
-   float scale, xpos=2; // leave a little padding in case the character extends left
-   char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness
-
-   fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb"));
-   stbtt_InitFont(&font, buffer, 0);
-
-   scale = stbtt_ScaleForPixelHeight(&font, 15);
-   stbtt_GetFontVMetrics(&font, &ascent,0,0);
-   baseline = (int) (ascent*scale);
-
-   while (text[ch]) {
-      int advance,lsb,x0,y0,x1,y1;
-      float x_shift = xpos - (float) floor(xpos);
-      stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb);
-      stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1);
-      stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]);
-      // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong
-      // because this API is really for baking character bitmaps into textures. if you want to render
-      // a sequence of characters, you really need to render each bitmap to a temp buffer, then
-      // "alpha blend" that into the working buffer
-      xpos += (advance * scale);
-      if (text[ch+1])
-         xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]);
-      ++ch;
-   }
-
-   for (j=0; j < 20; ++j) {
-      for (i=0; i < 78; ++i)
-         putchar(" .:ioVM@"[screen[j][i]>>5]);
-      putchar('\n');
-   }
-
-   return 0;
-}
-#endif
-
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-////
-////   INTEGRATION WITH YOUR CODEBASE
-////
-////   The following sections allow you to supply alternate definitions
-////   of C library functions used by stb_truetype, e.g. if you don't
-////   link with the C runtime library.
-
-#ifdef STB_TRUETYPE_IMPLEMENTATION
-   // #define your own (u)stbtt_int8/16/32 before including to override this
-   #ifndef stbtt_uint8
-   typedef unsigned char   stbtt_uint8;
-   typedef signed   char   stbtt_int8;
-   typedef unsigned short  stbtt_uint16;
-   typedef signed   short  stbtt_int16;
-   typedef unsigned int    stbtt_uint32;
-   typedef signed   int    stbtt_int32;
-   #endif
-
-   typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
-   typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
-
-   // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h
-   #ifndef STBTT_ifloor
-   #include <math.h>
-   #define STBTT_ifloor(x)   ((int) floor(x))
-   #define STBTT_iceil(x)    ((int) ceil(x))
-   #endif
-
-   #ifndef STBTT_sqrt
-   #include <math.h>
-   #define STBTT_sqrt(x)      sqrt(x)
-   #define STBTT_pow(x,y)     pow(x,y)
-   #endif
-
-   #ifndef STBTT_fmod
-   #include <math.h>
-   #define STBTT_fmod(x,y)    fmod(x,y)
-   #endif
-
-   #ifndef STBTT_cos
-   #include <math.h>
-   #define STBTT_cos(x)       cos(x)
-   #define STBTT_acos(x)      acos(x)
-   #endif
-
-   #ifndef STBTT_fabs
-   #include <math.h>
-   #define STBTT_fabs(x)      fabs(x)
-   #endif
-
-   // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h
-   #ifndef STBTT_malloc
-   #include <stdlib.h>
-   #define STBTT_malloc(x,u)  ((void)(u),malloc(x))
-   #define STBTT_free(x,u)    ((void)(u),free(x))
-   #endif
-
-   #ifndef STBTT_assert
-   #include <assert.h>
-   #define STBTT_assert(x)    assert(x)
-   #endif
-
-   #ifndef STBTT_strlen
-   #include <string.h>
-   #define STBTT_strlen(x)    strlen(x)
-   #endif
-
-   #ifndef STBTT_memcpy
-   #include <string.h>
-   #define STBTT_memcpy       memcpy
-   #define STBTT_memset       memset
-   #endif
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-////
-////   INTERFACE
-////
-////
-
-#ifndef __STB_INCLUDE_STB_TRUETYPE_H__
-#define __STB_INCLUDE_STB_TRUETYPE_H__
-
-#ifdef STBTT_STATIC
-#define STBTT_DEF static
-#else
-#define STBTT_DEF extern
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// private structure
-typedef struct
-{
-   unsigned char *data;
-   int cursor;
-   int size;
-} stbtt__buf;
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// TEXTURE BAKING API
-//
-// If you use this API, you only have to call two functions ever.
-//
-
-typedef struct
-{
-   unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
-   float xoff,yoff,xadvance;
-} stbtt_bakedchar;
-
-STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
-                                float pixel_height,                     // height of font in pixels
-                                unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
-                                int first_char, int num_chars,          // characters to bake
-                                stbtt_bakedchar *chardata);             // you allocate this, it's num_chars long
-// if return is positive, the first unused row of the bitmap
-// if return is negative, returns the negative of the number of characters that fit
-// if return is 0, no characters fit and no rows were used
-// This uses a very crappy packing.
-
-typedef struct
-{
-   float x0,y0,s0,t0; // top-left
-   float x1,y1,s1,t1; // bottom-right
-} stbtt_aligned_quad;
-
-STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
-                               int char_index,             // character to display
-                               float *xpos, float *ypos,   // pointers to current position in screen pixel space
-                               stbtt_aligned_quad *q,      // output: quad to draw
-                               int opengl_fillrule);       // true if opengl fill rule; false if DX9 or earlier
-// Call GetBakedQuad with char_index = 'character - first_char', and it
-// creates the quad you need to draw and advances the current position.
-//
-// The coordinate system used assumes y increases downwards.
-//
-// Characters will extend both above and below the current position;
-// see discussion of "BASELINE" above.
-//
-// It's inefficient; you might want to c&p it and optimize it.
-
-STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap);
-// Query the font vertical metrics without having to create a font first.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// NEW TEXTURE BAKING API
-//
-// This provides options for packing multiple fonts into one atlas, not
-// perfectly but better than nothing.
-
-typedef struct
-{
-   unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
-   float xoff,yoff,xadvance;
-   float xoff2,yoff2;
-} stbtt_packedchar;
-
-typedef struct stbtt_pack_context stbtt_pack_context;
-typedef struct stbtt_fontinfo stbtt_fontinfo;
-#ifndef STB_RECT_PACK_VERSION
-typedef struct stbrp_rect stbrp_rect;
-#endif
-
-STBTT_DEF int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
-// Initializes a packing context stored in the passed-in stbtt_pack_context.
-// Future calls using this context will pack characters into the bitmap passed
-// in here: a 1-channel bitmap that is width * height. stride_in_bytes is
-// the distance from one row to the next (or 0 to mean they are packed tightly
-// together). "padding" is the amount of padding to leave between each
-// character (normally you want '1' for bitmaps you'll use as textures with
-// bilinear filtering).
-//
-// Returns 0 on failure, 1 on success.
-
-STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc);
-// Cleans up the packing context and frees all memory.
-
-#define STBTT_POINT_SIZE(x)   (-(x))
-
-STBTT_DEF int  stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
-                                int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
-// Creates character bitmaps from the font_index'th font found in fontdata (use
-// font_index=0 if you don't know what that is). It creates num_chars_in_range
-// bitmaps for characters with unicode values starting at first_unicode_char_in_range
-// and increasing. Data for how to render them is stored in chardata_for_range;
-// pass these to stbtt_GetPackedQuad to get back renderable quads.
-//
-// font_size is the full height of the character from ascender to descender,
-// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed
-// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE()
-// and pass that result as 'font_size':
-//       ...,                  20 , ... // font max minus min y is 20 pixels tall
-//       ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall
-
-typedef struct
-{
-   float font_size;
-   int first_unicode_codepoint_in_range;  // if non-zero, then the chars are continuous, and this is the first codepoint
-   int *array_of_unicode_codepoints;       // if non-zero, then this is an array of unicode codepoints
-   int num_chars;
-   stbtt_packedchar *chardata_for_range; // output
-   unsigned char h_oversample, v_oversample; // don't set these, they're used internally
-} stbtt_pack_range;
-
-STBTT_DEF int  stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
-// Creates character bitmaps from multiple ranges of characters stored in
-// ranges. This will usually create a better-packed bitmap than multiple
-// calls to stbtt_PackFontRange. Note that you can call this multiple
-// times within a single PackBegin/PackEnd.
-
-STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
-// Oversampling a font increases the quality by allowing higher-quality subpixel
-// positioning, and is especially valuable at smaller text sizes.
-//
-// This function sets the amount of oversampling for all following calls to
-// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given
-// pack context. The default (no oversampling) is achieved by h_oversample=1
-// and v_oversample=1. The total number of pixels required is
-// h_oversample*v_oversample larger than the default; for example, 2x2
-// oversampling requires 4x the storage of 1x1. For best results, render
-// oversampled textures with bilinear filtering. Look at the readme in
-// stb/tests/oversample for information about oversampled fonts
-//
-// To use with PackFontRangesGather etc., you must set it before calls
-// call to PackFontRangesGatherRects.
-
-STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
-// If skip != 0, this tells stb_truetype to skip any codepoints for which
-// there is no corresponding glyph. If skip=0, which is the default, then
-// codepoints without a glyph recived the font's "missing character" glyph,
-// typically an empty box by convention.
-
-STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph,  // same data as above
-                               int char_index,             // character to display
-                               float *xpos, float *ypos,   // pointers to current position in screen pixel space
-                               stbtt_aligned_quad *q,      // output: quad to draw
-                               int align_to_integer);
-
-STBTT_DEF int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
-STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects);
-STBTT_DEF int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
-// Calling these functions in sequence is roughly equivalent to calling
-// stbtt_PackFontRanges(). If you more control over the packing of multiple
-// fonts, or if you want to pack custom data into a font texture, take a look
-// at the source to of stbtt_PackFontRanges() and create a custom version
-// using these functions, e.g. call GatherRects multiple times,
-// building up a single array of rects, then call PackRects once,
-// then call RenderIntoRects repeatedly. This may result in a
-// better packing than calling PackFontRanges multiple times
-// (or it may not).
-
-// this is an opaque structure that you shouldn't mess with which holds
-// all the context needed from PackBegin to PackEnd.
-struct stbtt_pack_context {
-   void *user_allocator_context;
-   void *pack_info;
-   int   width;
-   int   height;
-   int   stride_in_bytes;
-   int   padding;
-   int   skip_missing;
-   unsigned int   h_oversample, v_oversample;
-   unsigned char *pixels;
-   void  *nodes;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// FONT LOADING
-//
-//
-
-STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data);
-// This function will determine the number of fonts in a font file.  TrueType
-// collection (.ttc) files may contain multiple fonts, while TrueType font
-// (.ttf) files only contain one font. The number of fonts can be used for
-// indexing with the previous function where the index is between zero and one
-// less than the total fonts. If an error occurs, -1 is returned.
-
-STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
-// Each .ttf/.ttc file may have more than one font. Each font has a sequential
-// index number starting from 0. Call this function to get the font offset for
-// a given index; it returns -1 if the index is out of range. A regular .ttf
-// file will only define one font and it always be at offset 0, so it will
-// return '0' for index 0, and -1 for all other indices.
-
-// The following structure is defined publicly so you can declare one on
-// the stack or as a global or etc, but you should treat it as opaque.
-struct stbtt_fontinfo
-{
-   void           * userdata;
-   unsigned char  * data;              // pointer to .ttf file
-   int              fontstart;         // offset of start of font
-
-   int numGlyphs;                     // number of glyphs, needed for range checking
-
-   int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf
-   int index_map;                     // a cmap mapping for our chosen character encoding
-   int indexToLocFormat;              // format needed to map from glyph index to glyph
-
-   stbtt__buf cff;                    // cff font data
-   stbtt__buf charstrings;            // the charstring index
-   stbtt__buf gsubrs;                 // global charstring subroutines index
-   stbtt__buf subrs;                  // private charstring subroutines index
-   stbtt__buf fontdicts;              // array of font dicts
-   stbtt__buf fdselect;               // map from glyph to fontdict
-};
-
-STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
-// Given an offset into the file that defines a font, this function builds
-// the necessary cached info for the rest of the system. You must allocate
-// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
-// need to do anything special to free it, because the contents are pure
-// value data with no additional data structures. Returns 0 on failure.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// CHARACTER TO GLYPH-INDEX CONVERSIOn
-
-STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
-// If you're going to perform multiple operations on the same character
-// and you want a speed-up, call this function with the character you're
-// going to process, then use glyph-based functions instead of the
-// codepoint-based functions.
-// Returns 0 if the character codepoint is not defined in the font.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// CHARACTER PROPERTIES
-//
-
-STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
-// computes a scale factor to produce a font whose "height" is 'pixels' tall.
-// Height is measured as the distance from the highest ascender to the lowest
-// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
-// and computing:
-//       scale = pixels / (ascent - descent)
-// so if you prefer to measure height by the ascent only, use a similar calculation.
-
-STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
-// computes a scale factor to produce a font whose EM size is mapped to
-// 'pixels' tall. This is probably what traditional APIs compute, but
-// I'm not positive.
-
-STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
-// ascent is the coordinate above the baseline the font extends; descent
-// is the coordinate below the baseline the font extends (i.e. it is typically negative)
-// lineGap is the spacing between one row's descent and the next row's ascent...
-// so you should advance the vertical position by "*ascent - *descent + *lineGap"
-//   these are expressed in unscaled coordinates, so you must multiply by
-//   the scale factor for a given size
-
-STBTT_DEF int  stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap);
-// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2
-// table (specific to MS/Windows TTF files).
-//
-// Returns 1 on success (table present), 0 on failure.
-
-STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
-// the bounding box around all possible characters
-
-STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
-// leftSideBearing is the offset from the current horizontal position to the left edge of the character
-// advanceWidth is the offset from the current horizontal position to the next horizontal position
-//   these are expressed in unscaled coordinates
-
-STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
-// an additional amount to add to the 'advance' value between ch1 and ch2
-
-STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
-// Gets the bounding box of the visible part of the glyph, in unscaled coordinates
-
-STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
-STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
-STBTT_DEF int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
-// as above, but takes one or more glyph indices for greater efficiency
-
-typedef struct stbtt_kerningentry
-{
-   int glyph1; // use stbtt_FindGlyphIndex
-   int glyph2;
-   int advance;
-} stbtt_kerningentry;
-
-STBTT_DEF int  stbtt_GetKerningTableLength(const stbtt_fontinfo *info);
-STBTT_DEF int  stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length);
-// Retrieves a complete list of all of the kerning pairs provided by the font
-// stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write.
-// The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1)
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// GLYPH SHAPES (you probably don't need these, but they have to go before
-// the bitmaps for C declaration-order reasons)
-//
-
-#ifndef STBTT_vmove // you can predefine these to use different values (but why?)
-   enum {
-      STBTT_vmove=1,
-      STBTT_vline,
-      STBTT_vcurve,
-      STBTT_vcubic
-   };
-#endif
-
-#ifndef stbtt_vertex // you can predefine this to use different values
-                   // (we share this with other code at RAD)
-   #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file
-   typedef struct
-   {
-      stbtt_vertex_type x,y,cx,cy,cx1,cy1;
-      unsigned char type,padding;
-   } stbtt_vertex;
-#endif
-
-STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
-// returns non-zero if nothing is drawn for this glyph
-
-STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
-STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
-// returns # of vertices and fills *vertices with the pointer to them
-//   these are expressed in "unscaled" coordinates
-//
-// The shape is a series of contours. Each one starts with
-// a STBTT_moveto, then consists of a series of mixed
-// STBTT_lineto and STBTT_curveto segments. A lineto
-// draws a line from previous endpoint to its x,y; a curveto
-// draws a quadratic bezier from previous endpoint to
-// its x,y, using cx,cy as the bezier control point.
-
-STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
-// frees the data allocated above
-
-STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg);
-STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg);
-// fills svg with the character's SVG data.
-// returns data size or 0 if SVG not found.
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// BITMAP RENDERING
-//
-
-STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
-// frees the bitmap allocated below
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
-// allocates a large-enough single-channel 8bpp bitmap and renders the
-// specified character/glyph at the specified scale into it, with
-// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
-// *width & *height are filled out with the width & height of the bitmap,
-// which is stored left-to-right, top-to-bottom.
-//
-// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
-// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
-// shift for the character
-
-STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
-// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
-// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
-// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
-// width and height and positioning info for it first.
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
-// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
-// shift for the character
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint);
-// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering
-// is performed (see stbtt_PackSetOversampling)
-
-STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
-// get the bbox of the bitmap centered around the glyph origin; so the
-// bitmap width is ix1-ix0, height is iy1-iy0, and location to place
-// the bitmap top left is (leftSideBearing*scale,iy0).
-// (Note that the bitmap uses y-increases-down, but the shape uses
-// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
-
-STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
-// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
-// shift for the character
-
-// the following functions are equivalent to the above functions, but operate
-// on glyph indices instead of Unicode codepoints (for efficiency)
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph);
-STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
-STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
-
-
-// @TODO: don't expose this structure
-typedef struct
-{
-   int w,h,stride;
-   unsigned char *pixels;
-} stbtt__bitmap;
-
-// rasterize a shape with quadratic beziers into a bitmap
-STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result,        // 1-channel bitmap to draw into
-                               float flatness_in_pixels,     // allowable error of curve in pixels
-                               stbtt_vertex *vertices,       // array of vertices defining shape
-                               int num_verts,                // number of vertices in above array
-                               float scale_x, float scale_y, // scale applied to input vertices
-                               float shift_x, float shift_y, // translation applied to input vertices
-                               int x_off, int y_off,         // another translation applied to input
-                               int invert,                   // if non-zero, vertically flip shape
-                               void *userdata);              // context for to STBTT_MALLOC
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Signed Distance Function (or Field) rendering
-
-STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata);
-// frees the SDF bitmap allocated below
-
-STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
-// These functions compute a discretized SDF field for a single character, suitable for storing
-// in a single-channel texture, sampling with bilinear filtering, and testing against
-// larger than some threshold to produce scalable fonts.
-//        info              --  the font
-//        scale             --  controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
-//        glyph/codepoint   --  the character to generate the SDF for
-//        padding           --  extra "pixels" around the character which are filled with the distance to the character (not 0),
-//                                 which allows effects like bit outlines
-//        onedge_value      --  value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character)
-//        pixel_dist_scale  --  what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale)
-//                                 if positive, > onedge_value is inside; if negative, < onedge_value is inside
-//        width,height      --  output height & width of the SDF bitmap (including padding)
-//        xoff,yoff         --  output origin of the character
-//        return value      --  a 2D array of bytes 0..255, width*height in size
-//
-// pixel_dist_scale & onedge_value are a scale & bias that allows you to make
-// optimal use of the limited 0..255 for your application, trading off precision
-// and special effects. SDF values outside the range 0..255 are clamped to 0..255.
-//
-// Example:
-//      scale = stbtt_ScaleForPixelHeight(22)
-//      padding = 5
-//      onedge_value = 180
-//      pixel_dist_scale = 180/5.0 = 36.0
-//
-//      This will create an SDF bitmap in which the character is about 22 pixels
-//      high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled
-//      shape, sample the SDF at each pixel and fill the pixel if the SDF value
-//      is greater than or equal to 180/255. (You'll actually want to antialias,
-//      which is beyond the scope of this example.) Additionally, you can compute
-//      offset outlines (e.g. to stroke the character border inside & outside,
-//      or only outside). For example, to fill outside the character up to 3 SDF
-//      pixels, you would compare against (180-36.0*3)/255 = 72/255. The above
-//      choice of variables maps a range from 5 pixels outside the shape to
-//      2 pixels inside the shape to 0..255; this is intended primarily for apply
-//      outside effects only (the interior range is needed to allow proper
-//      antialiasing of the font at *smaller* sizes)
-//
-// The function computes the SDF analytically at each SDF pixel, not by e.g.
-// building a higher-res bitmap and approximating it. In theory the quality
-// should be as high as possible for an SDF of this size & representation, but
-// unclear if this is true in practice (perhaps building a higher-res bitmap
-// and computing from that can allow drop-out prevention).
-//
-// The algorithm has not been optimized at all, so expect it to be slow
-// if computing lots of characters or very large sizes.
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Finding the right font...
-//
-// You should really just solve this offline, keep your own tables
-// of what font is what, and don't try to get it out of the .ttf file.
-// That's because getting it out of the .ttf file is really hard, because
-// the names in the file can appear in many possible encodings, in many
-// possible languages, and e.g. if you need a case-insensitive comparison,
-// the details of that depend on the encoding & language in a complex way
-// (actually underspecified in truetype, but also gigantic).
-//
-// But you can use the provided functions in two possible ways:
-//     stbtt_FindMatchingFont() will use *case-sensitive* comparisons on
-//             unicode-encoded names to try to find the font you want;
-//             you can run this before calling stbtt_InitFont()
-//
-//     stbtt_GetFontNameString() lets you get any of the various strings
-//             from the file yourself and do your own comparisons on them.
-//             You have to have called stbtt_InitFont() first.
-
-
-STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
-// returns the offset (not index) of the font that matches, or -1 if none
-//   if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
-//   if you use any other flag, use a font name like "Arial"; this checks
-//     the 'macStyle' header field; i don't know if fonts set this consistently
-#define STBTT_MACSTYLE_DONTCARE     0
-#define STBTT_MACSTYLE_BOLD         1
-#define STBTT_MACSTYLE_ITALIC       2
-#define STBTT_MACSTYLE_UNDERSCORE   4
-#define STBTT_MACSTYLE_NONE         8   // <= not same as 0, this makes us check the bitfield is 0
-
-STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
-// returns 1/0 whether the first string interpreted as utf8 is identical to
-// the second string interpreted as big-endian utf16... useful for strings from next func
-
-STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
-// returns the string (which may be big-endian double byte, e.g. for unicode)
-// and puts the length in bytes in *length.
-//
-// some of the values for the IDs are below; for more see the truetype spec:
-//     http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
-//     http://www.microsoft.com/typography/otspec/name.htm
-
-enum { // platformID
-   STBTT_PLATFORM_ID_UNICODE   =0,
-   STBTT_PLATFORM_ID_MAC       =1,
-   STBTT_PLATFORM_ID_ISO       =2,
-   STBTT_PLATFORM_ID_MICROSOFT =3
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_UNICODE
-   STBTT_UNICODE_EID_UNICODE_1_0    =0,
-   STBTT_UNICODE_EID_UNICODE_1_1    =1,
-   STBTT_UNICODE_EID_ISO_10646      =2,
-   STBTT_UNICODE_EID_UNICODE_2_0_BMP=3,
-   STBTT_UNICODE_EID_UNICODE_2_0_FULL=4
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT
-   STBTT_MS_EID_SYMBOL        =0,
-   STBTT_MS_EID_UNICODE_BMP   =1,
-   STBTT_MS_EID_SHIFTJIS      =2,
-   STBTT_MS_EID_UNICODE_FULL  =10
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes
-   STBTT_MAC_EID_ROMAN        =0,   STBTT_MAC_EID_ARABIC       =4,
-   STBTT_MAC_EID_JAPANESE     =1,   STBTT_MAC_EID_HEBREW       =5,
-   STBTT_MAC_EID_CHINESE_TRAD =2,   STBTT_MAC_EID_GREEK        =6,
-   STBTT_MAC_EID_KOREAN       =3,   STBTT_MAC_EID_RUSSIAN      =7
-};
-
-enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID...
-       // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs
-   STBTT_MS_LANG_ENGLISH     =0x0409,   STBTT_MS_LANG_ITALIAN     =0x0410,
-   STBTT_MS_LANG_CHINESE     =0x0804,   STBTT_MS_LANG_JAPANESE    =0x0411,
-   STBTT_MS_LANG_DUTCH       =0x0413,   STBTT_MS_LANG_KOREAN      =0x0412,
-   STBTT_MS_LANG_FRENCH      =0x040c,   STBTT_MS_LANG_RUSSIAN     =0x0419,
-   STBTT_MS_LANG_GERMAN      =0x0407,   STBTT_MS_LANG_SPANISH     =0x0409,
-   STBTT_MS_LANG_HEBREW      =0x040d,   STBTT_MS_LANG_SWEDISH     =0x041D
-};
-
-enum { // languageID for STBTT_PLATFORM_ID_MAC
-   STBTT_MAC_LANG_ENGLISH      =0 ,   STBTT_MAC_LANG_JAPANESE     =11,
-   STBTT_MAC_LANG_ARABIC       =12,   STBTT_MAC_LANG_KOREAN       =23,
-   STBTT_MAC_LANG_DUTCH        =4 ,   STBTT_MAC_LANG_RUSSIAN      =32,
-   STBTT_MAC_LANG_FRENCH       =1 ,   STBTT_MAC_LANG_SPANISH      =6 ,
-   STBTT_MAC_LANG_GERMAN       =2 ,   STBTT_MAC_LANG_SWEDISH      =5 ,
-   STBTT_MAC_LANG_HEBREW       =10,   STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33,
-   STBTT_MAC_LANG_ITALIAN      =3 ,   STBTT_MAC_LANG_CHINESE_TRAD =19
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __STB_INCLUDE_STB_TRUETYPE_H__
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-////
-////   IMPLEMENTATION
-////
-////
-
-#ifdef STB_TRUETYPE_IMPLEMENTATION
-
-#ifndef STBTT_MAX_OVERSAMPLE
-#define STBTT_MAX_OVERSAMPLE   8
-#endif
-
-#if STBTT_MAX_OVERSAMPLE > 255
-#error "STBTT_MAX_OVERSAMPLE cannot be > 255"
-#endif
-
-typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1];
-
-#ifndef STBTT_RASTERIZER_VERSION
-#define STBTT_RASTERIZER_VERSION 2
-#endif
-
-#ifdef _MSC_VER
-#define STBTT__NOTUSED(v)  (void)(v)
-#else
-#define STBTT__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-//////////////////////////////////////////////////////////////////////////
-//
-// stbtt__buf helpers to parse data from file
-//
-
-static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b)
-{
-   if (b->cursor >= b->size)
-      return 0;
-   return b->data[b->cursor++];
-}
-
-static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b)
-{
-   if (b->cursor >= b->size)
-      return 0;
-   return b->data[b->cursor];
-}
-
-static void stbtt__buf_seek(stbtt__buf *b, int o)
-{
-   STBTT_assert(!(o > b->size || o < 0));
-   b->cursor = (o > b->size || o < 0) ? b->size : o;
-}
-
-static void stbtt__buf_skip(stbtt__buf *b, int o)
-{
-   stbtt__buf_seek(b, b->cursor + o);
-}
-
-static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n)
-{
-   stbtt_uint32 v = 0;
-   int i;
-   STBTT_assert(n >= 1 && n <= 4);
-   for (i = 0; i < n; i++)
-      v = (v << 8) | stbtt__buf_get8(b);
-   return v;
-}
-
-static stbtt__buf stbtt__new_buf(const void *p, size_t size)
-{
-   stbtt__buf r;
-   STBTT_assert(size < 0x40000000);
-   r.data = (stbtt_uint8*) p;
-   r.size = (int) size;
-   r.cursor = 0;
-   return r;
-}
-
-#define stbtt__buf_get16(b)  stbtt__buf_get((b), 2)
-#define stbtt__buf_get32(b)  stbtt__buf_get((b), 4)
-
-static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s)
-{
-   stbtt__buf r = stbtt__new_buf(NULL, 0);
-   if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r;
-   r.data = b->data + o;
-   r.size = s;
-   return r;
-}
-
-static stbtt__buf stbtt__cff_get_index(stbtt__buf *b)
-{
-   int count, start, offsize;
-   start = b->cursor;
-   count = stbtt__buf_get16(b);
-   if (count) {
-      offsize = stbtt__buf_get8(b);
-      STBTT_assert(offsize >= 1 && offsize <= 4);
-      stbtt__buf_skip(b, offsize * count);
-      stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1);
-   }
-   return stbtt__buf_range(b, start, b->cursor - start);
-}
-
-static stbtt_uint32 stbtt__cff_int(stbtt__buf *b)
-{
-   int b0 = stbtt__buf_get8(b);
-   if (b0 >= 32 && b0 <= 246)       return b0 - 139;
-   else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108;
-   else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108;
-   else if (b0 == 28)               return stbtt__buf_get16(b);
-   else if (b0 == 29)               return stbtt__buf_get32(b);
-   STBTT_assert(0);
-   return 0;
-}
-
-static void stbtt__cff_skip_operand(stbtt__buf *b) {
-   int v, b0 = stbtt__buf_peek8(b);
-   STBTT_assert(b0 >= 28);
-   if (b0 == 30) {
-      stbtt__buf_skip(b, 1);
-      while (b->cursor < b->size) {
-         v = stbtt__buf_get8(b);
-         if ((v & 0xF) == 0xF || (v >> 4) == 0xF)
-            break;
-      }
-   } else {
-      stbtt__cff_int(b);
-   }
-}
-
-static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key)
-{
-   stbtt__buf_seek(b, 0);
-   while (b->cursor < b->size) {
-      int start = b->cursor, end, op;
-      while (stbtt__buf_peek8(b) >= 28)
-         stbtt__cff_skip_operand(b);
-      end = b->cursor;
-      op = stbtt__buf_get8(b);
-      if (op == 12)  op = stbtt__buf_get8(b) | 0x100;
-      if (op == key) return stbtt__buf_range(b, start, end-start);
-   }
-   return stbtt__buf_range(b, 0, 0);
-}
-
-static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out)
-{
-   int i;
-   stbtt__buf operands = stbtt__dict_get(b, key);
-   for (i = 0; i < outcount && operands.cursor < operands.size; i++)
-      out[i] = stbtt__cff_int(&operands);
-}
-
-static int stbtt__cff_index_count(stbtt__buf *b)
-{
-   stbtt__buf_seek(b, 0);
-   return stbtt__buf_get16(b);
-}
-
-static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i)
-{
-   int count, offsize, start, end;
-   stbtt__buf_seek(&b, 0);
-   count = stbtt__buf_get16(&b);
-   offsize = stbtt__buf_get8(&b);
-   STBTT_assert(i >= 0 && i < count);
-   STBTT_assert(offsize >= 1 && offsize <= 4);
-   stbtt__buf_skip(&b, i*offsize);
-   start = stbtt__buf_get(&b, offsize);
-   end = stbtt__buf_get(&b, offsize);
-   return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start);
-}
-
-//////////////////////////////////////////////////////////////////////////
-//
-// accessors to parse data from file
-//
-
-// on platforms that don't allow misaligned reads, if we want to allow
-// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE
-
-#define ttBYTE(p)     (* (stbtt_uint8 *) (p))
-#define ttCHAR(p)     (* (stbtt_int8 *) (p))
-#define ttFixed(p)    ttLONG(p)
-
-static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; }
-static stbtt_int16 ttSHORT(stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
-static stbtt_uint32 ttULONG(stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
-static stbtt_int32 ttLONG(stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
-
-#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
-#define stbtt_tag(p,str)           stbtt_tag4(p,str[0],str[1],str[2],str[3])
-
-static int stbtt__isfont(stbtt_uint8 *font)
-{
-   // check the version number
-   if (stbtt_tag4(font, '1',0,0,0))  return 1; // TrueType 1
-   if (stbtt_tag(font, "typ1"))   return 1; // TrueType with type 1 font -- we don't support this!
-   if (stbtt_tag(font, "OTTO"))   return 1; // OpenType with CFF
-   if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0
-   if (stbtt_tag(font, "true"))   return 1; // Apple specification for TrueType fonts
-   return 0;
-}
-
-// @OPTIMIZE: binary search
-static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag)
-{
-   stbtt_int32 num_tables = ttUSHORT(data+fontstart+4);
-   stbtt_uint32 tabledir = fontstart + 12;
-   stbtt_int32 i;
-   for (i=0; i < num_tables; ++i) {
-      stbtt_uint32 loc = tabledir + 16*i;
-      if (stbtt_tag(data+loc+0, tag))
-         return ttULONG(data+loc+8);
-   }
-   return 0;
-}
-
-static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index)
-{
-   // if it's just a font, there's only one valid index
-   if (stbtt__isfont(font_collection))
-      return index == 0 ? 0 : -1;
-
-   // check if it's a TTC
-   if (stbtt_tag(font_collection, "ttcf")) {
-      // version 1?
-      if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
-         stbtt_int32 n = ttLONG(font_collection+8);
-         if (index >= n)
-            return -1;
-         return ttULONG(font_collection+12+index*4);
-      }
-   }
-   return -1;
-}
-
-static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection)
-{
-   // if it's just a font, there's only one valid font
-   if (stbtt__isfont(font_collection))
-      return 1;
-
-   // check if it's a TTC
-   if (stbtt_tag(font_collection, "ttcf")) {
-      // version 1?
-      if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
-         return ttLONG(font_collection+8);
-      }
-   }
-   return 0;
-}
-
-static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict)
-{
-   stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 };
-   stbtt__buf pdict;
-   stbtt__dict_get_ints(&fontdict, 18, 2, private_loc);
-   if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0);
-   pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]);
-   stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff);
-   if (!subrsoff) return stbtt__new_buf(NULL, 0);
-   stbtt__buf_seek(&cff, private_loc[1]+subrsoff);
-   return stbtt__cff_get_index(&cff);
-}
-
-// since most people won't use this, find this table the first time it's needed
-static int stbtt__get_svg(stbtt_fontinfo *info)
-{
-   stbtt_uint32 t;
-   if (info->svg < 0) {
-      t = stbtt__find_table(info->data, info->fontstart, "SVG ");
-      if (t) {
-         stbtt_uint32 offset = ttULONG(info->data + t + 2);
-         info->svg = t + offset;
-      } else {
-         info->svg = 0;
-      }
-   }
-   return info->svg;
-}
-
-static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart)
-{
-   stbtt_uint32 cmap, t;
-   stbtt_int32 i,numTables;
-
-   info->data = data;
-   info->fontstart = fontstart;
-   info->cff = stbtt__new_buf(NULL, 0);
-
-   cmap = stbtt__find_table(data, fontstart, "cmap");       // required
-   info->loca = stbtt__find_table(data, fontstart, "loca"); // required
-   info->head = stbtt__find_table(data, fontstart, "head"); // required
-   info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required
-   info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required
-   info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required
-   info->kern = stbtt__find_table(data, fontstart, "kern"); // not required
-   info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required
-
-   if (!cmap || !info->head || !info->hhea || !info->hmtx)
-      return 0;
-   if (info->glyf) {
-      // required for truetype
-      if (!info->loca) return 0;
-   } else {
-      // initialization for CFF / Type2 fonts (OTF)
-      stbtt__buf b, topdict, topdictidx;
-      stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0;
-      stbtt_uint32 cff;
-
-      cff = stbtt__find_table(data, fontstart, "CFF ");
-      if (!cff) return 0;
-
-      info->fontdicts = stbtt__new_buf(NULL, 0);
-      info->fdselect = stbtt__new_buf(NULL, 0);
-
-      // @TODO this should use size from table (not 512MB)
-      info->cff = stbtt__new_buf(data+cff, 512*1024*1024);
-      b = info->cff;
-
-      // read the header
-      stbtt__buf_skip(&b, 2);
-      stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize
-
-      // @TODO the name INDEX could list multiple fonts,
-      // but we just use the first one.
-      stbtt__cff_get_index(&b);  // name INDEX
-      topdictidx = stbtt__cff_get_index(&b);
-      topdict = stbtt__cff_index_get(topdictidx, 0);
-      stbtt__cff_get_index(&b);  // string INDEX
-      info->gsubrs = stbtt__cff_get_index(&b);
-
-      stbtt__dict_get_ints(&topdict, 17, 1, &charstrings);
-      stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype);
-      stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff);
-      stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff);
-      info->subrs = stbtt__get_subrs(b, topdict);
-
-      // we only support Type 2 charstrings
-      if (cstype != 2) return 0;
-      if (charstrings == 0) return 0;
-
-      if (fdarrayoff) {
-         // looks like a CID font
-         if (!fdselectoff) return 0;
-         stbtt__buf_seek(&b, fdarrayoff);
-         info->fontdicts = stbtt__cff_get_index(&b);
-         info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff);
-      }
-
-      stbtt__buf_seek(&b, charstrings);
-      info->charstrings = stbtt__cff_get_index(&b);
-   }
-
-   t = stbtt__find_table(data, fontstart, "maxp");
-   if (t)
-      info->numGlyphs = ttUSHORT(data+t+4);
-   else
-      info->numGlyphs = 0xffff;
-
-   info->svg = -1;
-
-   // find a cmap encoding table we understand *now* to avoid searching
-   // later. (todo: could make this installable)
-   // the same regardless of glyph.
-   numTables = ttUSHORT(data + cmap + 2);
-   info->index_map = 0;
-   for (i=0; i < numTables; ++i) {
-      stbtt_uint32 encoding_record = cmap + 4 + 8 * i;
-      // find an encoding we understand:
-      switch(ttUSHORT(data+encoding_record)) {
-         case STBTT_PLATFORM_ID_MICROSOFT:
-            switch (ttUSHORT(data+encoding_record+2)) {
-               case STBTT_MS_EID_UNICODE_BMP:
-               case STBTT_MS_EID_UNICODE_FULL:
-                  // MS/Unicode
-                  info->index_map = cmap + ttULONG(data+encoding_record+4);
-                  break;
-            }
-            break;
-        case STBTT_PLATFORM_ID_UNICODE:
-            // Mac/iOS has these
-            // all the encodingIDs are unicode, so we don't bother to check it
-            info->index_map = cmap + ttULONG(data+encoding_record+4);
-            break;
-      }
-   }
-   if (info->index_map == 0)
-      return 0;
-
-   info->indexToLocFormat = ttUSHORT(data+info->head + 50);
-   return 1;
-}
-
-STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
-{
-   stbtt_uint8 *data = info->data;
-   stbtt_uint32 index_map = info->index_map;
-
-   stbtt_uint16 format = ttUSHORT(data + index_map + 0);
-   if (format == 0) { // apple byte encoding
-      stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
-      if (unicode_codepoint < bytes-6)
-         return ttBYTE(data + index_map + 6 + unicode_codepoint);
-      return 0;
-   } else if (format == 6) {
-      stbtt_uint32 first = ttUSHORT(data + index_map + 6);
-      stbtt_uint32 count = ttUSHORT(data + index_map + 8);
-      if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count)
-         return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2);
-      return 0;
-   } else if (format == 2) {
-      STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean
-      return 0;
-   } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges
-      stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1;
-      stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1;
-      stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10);
-      stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1;
-
-      // do a binary search of the segments
-      stbtt_uint32 endCount = index_map + 14;
-      stbtt_uint32 search = endCount;
-
-      if (unicode_codepoint > 0xffff)
-         return 0;
-
-      // they lie from endCount .. endCount + segCount
-      // but searchRange is the nearest power of two, so...
-      if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2))
-         search += rangeShift*2;
-
-      // now decrement to bias correctly to find smallest
-      search -= 2;
-      while (entrySelector) {
-         stbtt_uint16 end;
-         searchRange >>= 1;
-         end = ttUSHORT(data + search + searchRange*2);
-         if (unicode_codepoint > end)
-            search += searchRange*2;
-         --entrySelector;
-      }
-      search += 2;
-
-      {
-         stbtt_uint16 offset, start;
-         stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);
-
-         STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item));
-         start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
-         if (unicode_codepoint < start)
-            return 0;
-
-         offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
-         if (offset == 0)
-            return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
-
-         return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
-      }
-   } else if (format == 12 || format == 13) {
-      stbtt_uint32 ngroups = ttULONG(data+index_map+12);
-      stbtt_int32 low,high;
-      low = 0; high = (stbtt_int32)ngroups;
-      // Binary search the right group.
-      while (low < high) {
-         stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high
-         stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12);
-         stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4);
-         if ((stbtt_uint32) unicode_codepoint < start_char)
-            high = mid;
-         else if ((stbtt_uint32) unicode_codepoint > end_char)
-            low = mid+1;
-         else {
-            stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8);
-            if (format == 12)
-               return start_glyph + unicode_codepoint-start_char;
-            else // format == 13
-               return start_glyph;
-         }
-      }
-      return 0; // not found
-   }
-   // @TODO
-   STBTT_assert(0);
-   return 0;
-}
-
-STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
-{
-   return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
-}
-
-static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy)
-{
-   v->type = type;
-   v->x = (stbtt_int16) x;
-   v->y = (stbtt_int16) y;
-   v->cx = (stbtt_int16) cx;
-   v->cy = (stbtt_int16) cy;
-}
-
-static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
-{
-   int g1,g2;
-
-   STBTT_assert(!info->cff.size);
-
-   if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range
-   if (info->indexToLocFormat >= 2)    return -1; // unknown index->glyph map format
-
-   if (info->indexToLocFormat == 0) {
-      g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
-      g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
-   } else {
-      g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4);
-      g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4);
-   }
-
-   return g1==g2 ? -1 : g1; // if length is 0, return -1
-}
-
-static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
-
-STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
-{
-   if (info->cff.size) {
-      stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
-   } else {
-      int g = stbtt__GetGlyfOffset(info, glyph_index);
-      if (g < 0) return 0;
-
-      if (x0) *x0 = ttSHORT(info->data + g + 2);
-      if (y0) *y0 = ttSHORT(info->data + g + 4);
-      if (x1) *x1 = ttSHORT(info->data + g + 6);
-      if (y1) *y1 = ttSHORT(info->data + g + 8);
-   }
-   return 1;
-}
-
-STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
-{
-   return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
-}
-
-STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
-{
-   stbtt_int16 numberOfContours;
-   int g;
-   if (info->cff.size)
-      return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0;
-   g = stbtt__GetGlyfOffset(info, glyph_index);
-   if (g < 0) return 1;
-   numberOfContours = ttSHORT(info->data + g);
-   return numberOfContours == 0;
-}
-
-static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off,
-    stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy)
-{
-   if (start_off) {
-      if (was_off)
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
-      stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy);
-   } else {
-      if (was_off)
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy);
-      else
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0);
-   }
-   return num_vertices;
-}
-
-static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   stbtt_int16 numberOfContours;
-   stbtt_uint8 *endPtsOfContours;
-   stbtt_uint8 *data = info->data;
-   stbtt_vertex *vertices=0;
-   int num_vertices=0;
-   int g = stbtt__GetGlyfOffset(info, glyph_index);
-
-   *pvertices = NULL;
-
-   if (g < 0) return 0;
-
-   numberOfContours = ttSHORT(data + g);
-
-   if (numberOfContours > 0) {
-      stbtt_uint8 flags=0,flagcount;
-      stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0;
-      stbtt_int32 x,y,cx,cy,sx,sy, scx,scy;
-      stbtt_uint8 *points;
-      endPtsOfContours = (data + g + 10);
-      ins = ttUSHORT(data + g + 10 + numberOfContours * 2);
-      points = data + g + 10 + numberOfContours * 2 + 2 + ins;
-
-      n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2);
-
-      m = n + 2*numberOfContours;  // a loose bound on how many vertices we might need
-      vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata);
-      if (vertices == 0)
-         return 0;
-
-      next_move = 0;
-      flagcount=0;
-
-      // in first pass, we load uninterpreted data into the allocated array
-      // above, shifted to the end of the array so we won't overwrite it when
-      // we create our final data starting from the front
-
-      off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated
-
-      // first load flags
-
-      for (i=0; i < n; ++i) {
-         if (flagcount == 0) {
-            flags = *points++;
-            if (flags & 8)
-               flagcount = *points++;
-         } else
-            --flagcount;
-         vertices[off+i].type = flags;
-      }
-
-      // now load x coordinates
-      x=0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         if (flags & 2) {
-            stbtt_int16 dx = *points++;
-            x += (flags & 16) ? dx : -dx; // ???
-         } else {
-            if (!(flags & 16)) {
-               x = x + (stbtt_int16) (points[0]*256 + points[1]);
-               points += 2;
-            }
-         }
-         vertices[off+i].x = (stbtt_int16) x;
-      }
-
-      // now load y coordinates
-      y=0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         if (flags & 4) {
-            stbtt_int16 dy = *points++;
-            y += (flags & 32) ? dy : -dy; // ???
-         } else {
-            if (!(flags & 32)) {
-               y = y + (stbtt_int16) (points[0]*256 + points[1]);
-               points += 2;
-            }
-         }
-         vertices[off+i].y = (stbtt_int16) y;
-      }
-
-      // now convert them to our format
-      num_vertices=0;
-      sx = sy = cx = cy = scx = scy = 0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         x     = (stbtt_int16) vertices[off+i].x;
-         y     = (stbtt_int16) vertices[off+i].y;
-
-         if (next_move == i) {
-            if (i != 0)
-               num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
-
-            // now start the new one
-            start_off = !(flags & 1);
-            if (start_off) {
-               // if we start off with an off-curve point, then when we need to find a point on the curve
-               // where we can start, and we need to save some state for when we wraparound.
-               scx = x;
-               scy = y;
-               if (!(vertices[off+i+1].type & 1)) {
-                  // next point is also a curve point, so interpolate an on-point curve
-                  sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1;
-                  sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1;
-               } else {
-                  // otherwise just use the next point as our start point
-                  sx = (stbtt_int32) vertices[off+i+1].x;
-                  sy = (stbtt_int32) vertices[off+i+1].y;
-                  ++i; // we're using point i+1 as the starting point, so skip it
-               }
-            } else {
-               sx = x;
-               sy = y;
-            }
-            stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0);
-            was_off = 0;
-            next_move = 1 + ttUSHORT(endPtsOfContours+j*2);
-            ++j;
-         } else {
-            if (!(flags & 1)) { // if it's a curve
-               if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
-               cx = x;
-               cy = y;
-               was_off = 1;
-            } else {
-               if (was_off)
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy);
-               else
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0);
-               was_off = 0;
-            }
-         }
-      }
-      num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
-   } else if (numberOfContours < 0) {
-      // Compound shapes.
-      int more = 1;
-      stbtt_uint8 *comp = data + g + 10;
-      num_vertices = 0;
-      vertices = 0;
-      while (more) {
-         stbtt_uint16 flags, gidx;
-         int comp_num_verts = 0, i;
-         stbtt_vertex *comp_verts = 0, *tmp = 0;
-         float mtx[6] = {1,0,0,1,0,0}, m, n;
-
-         flags = ttSHORT(comp); comp+=2;
-         gidx = ttSHORT(comp); comp+=2;
-
-         if (flags & 2) { // XY values
-            if (flags & 1) { // shorts
-               mtx[4] = ttSHORT(comp); comp+=2;
-               mtx[5] = ttSHORT(comp); comp+=2;
-            } else {
-               mtx[4] = ttCHAR(comp); comp+=1;
-               mtx[5] = ttCHAR(comp); comp+=1;
-            }
-         }
-         else {
-            // @TODO handle matching point
-            STBTT_assert(0);
-         }
-         if (flags & (1<<3)) { // WE_HAVE_A_SCALE
-            mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = mtx[2] = 0;
-         } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE
-            mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = mtx[2] = 0;
-            mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-         } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO
-            mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[2] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-         }
-
-         // Find transformation scales.
-         m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
-         n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
-
-         // Get indexed glyph.
-         comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts);
-         if (comp_num_verts > 0) {
-            // Transform vertices.
-            for (i = 0; i < comp_num_verts; ++i) {
-               stbtt_vertex* v = &comp_verts[i];
-               stbtt_vertex_type x,y;
-               x=v->x; y=v->y;
-               v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
-               v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
-               x=v->cx; y=v->cy;
-               v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
-               v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
-            }
-            // Append vertices.
-            tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata);
-            if (!tmp) {
-               if (vertices) STBTT_free(vertices, info->userdata);
-               if (comp_verts) STBTT_free(comp_verts, info->userdata);
-               return 0;
-            }
-            if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex));
-            STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex));
-            if (vertices) STBTT_free(vertices, info->userdata);
-            vertices = tmp;
-            STBTT_free(comp_verts, info->userdata);
-            num_vertices += comp_num_verts;
-         }
-         // More components ?
-         more = flags & (1<<5);
-      }
-   } else {
-      // numberOfCounters == 0, do nothing
-   }
-
-   *pvertices = vertices;
-   return num_vertices;
-}
-
-typedef struct
-{
-   int bounds;
-   int started;
-   float first_x, first_y;
-   float x, y;
-   stbtt_int32 min_x, max_x, min_y, max_y;
-
-   stbtt_vertex *pvertices;
-   int num_vertices;
-} stbtt__csctx;
-
-#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0}
-
-static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y)
-{
-   if (x > c->max_x || !c->started) c->max_x = x;
-   if (y > c->max_y || !c->started) c->max_y = y;
-   if (x < c->min_x || !c->started) c->min_x = x;
-   if (y < c->min_y || !c->started) c->min_y = y;
-   c->started = 1;
-}
-
-static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1)
-{
-   if (c->bounds) {
-      stbtt__track_vertex(c, x, y);
-      if (type == STBTT_vcubic) {
-         stbtt__track_vertex(c, cx, cy);
-         stbtt__track_vertex(c, cx1, cy1);
-      }
-   } else {
-      stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy);
-      c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1;
-      c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1;
-   }
-   c->num_vertices++;
-}
-
-static void stbtt__csctx_close_shape(stbtt__csctx *ctx)
-{
-   if (ctx->first_x != ctx->x || ctx->first_y != ctx->y)
-      stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy)
-{
-   stbtt__csctx_close_shape(ctx);
-   ctx->first_x = ctx->x = ctx->x + dx;
-   ctx->first_y = ctx->y = ctx->y + dy;
-   stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy)
-{
-   ctx->x += dx;
-   ctx->y += dy;
-   stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
-{
-   float cx1 = ctx->x + dx1;
-   float cy1 = ctx->y + dy1;
-   float cx2 = cx1 + dx2;
-   float cy2 = cy1 + dy2;
-   ctx->x = cx2 + dx3;
-   ctx->y = cy2 + dy3;
-   stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2);
-}
-
-static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n)
-{
-   int count = stbtt__cff_index_count(&idx);
-   int bias = 107;
-   if (count >= 33900)
-      bias = 32768;
-   else if (count >= 1240)
-      bias = 1131;
-   n += bias;
-   if (n < 0 || n >= count)
-      return stbtt__new_buf(NULL, 0);
-   return stbtt__cff_index_get(idx, n);
-}
-
-static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index)
-{
-   stbtt__buf fdselect = info->fdselect;
-   int nranges, start, end, v, fmt, fdselector = -1, i;
-
-   stbtt__buf_seek(&fdselect, 0);
-   fmt = stbtt__buf_get8(&fdselect);
-   if (fmt == 0) {
-      // untested
-      stbtt__buf_skip(&fdselect, glyph_index);
-      fdselector = stbtt__buf_get8(&fdselect);
-   } else if (fmt == 3) {
-      nranges = stbtt__buf_get16(&fdselect);
-      start = stbtt__buf_get16(&fdselect);
-      for (i = 0; i < nranges; i++) {
-         v = stbtt__buf_get8(&fdselect);
-         end = stbtt__buf_get16(&fdselect);
-         if (glyph_index >= start && glyph_index < end) {
-            fdselector = v;
-            break;
-         }
-         start = end;
-      }
-   }
-   if (fdselector == -1) stbtt__new_buf(NULL, 0);
-   return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector));
-}
-
-static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c)
-{
-   int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0;
-   int has_subrs = 0, clear_stack;
-   float s[48];
-   stbtt__buf subr_stack[10], subrs = info->subrs, b;
-   float f;
-
-#define STBTT__CSERR(s) (0)
-
-   // this currently ignores the initial width value, which isn't needed if we have hmtx
-   b = stbtt__cff_index_get(info->charstrings, glyph_index);
-   while (b.cursor < b.size) {
-      i = 0;
-      clear_stack = 1;
-      b0 = stbtt__buf_get8(&b);
-      switch (b0) {
-      // @TODO implement hinting
-      case 0x13: // hintmask
-      case 0x14: // cntrmask
-         if (in_header)
-            maskbits += (sp / 2); // implicit "vstem"
-         in_header = 0;
-         stbtt__buf_skip(&b, (maskbits + 7) / 8);
-         break;
-
-      case 0x01: // hstem
-      case 0x03: // vstem
-      case 0x12: // hstemhm
-      case 0x17: // vstemhm
-         maskbits += (sp / 2);
-         break;
-
-      case 0x15: // rmoveto
-         in_header = 0;
-         if (sp < 2) return STBTT__CSERR("rmoveto stack");
-         stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]);
-         break;
-      case 0x04: // vmoveto
-         in_header = 0;
-         if (sp < 1) return STBTT__CSERR("vmoveto stack");
-         stbtt__csctx_rmove_to(c, 0, s[sp-1]);
-         break;
-      case 0x16: // hmoveto
-         in_header = 0;
-         if (sp < 1) return STBTT__CSERR("hmoveto stack");
-         stbtt__csctx_rmove_to(c, s[sp-1], 0);
-         break;
-
-      case 0x05: // rlineto
-         if (sp < 2) return STBTT__CSERR("rlineto stack");
-         for (; i + 1 < sp; i += 2)
-            stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         break;
-
-      // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical
-      // starting from a different place.
-
-      case 0x07: // vlineto
-         if (sp < 1) return STBTT__CSERR("vlineto stack");
-         goto vlineto;
-      case 0x06: // hlineto
-         if (sp < 1) return STBTT__CSERR("hlineto stack");
-         for (;;) {
-            if (i >= sp) break;
-            stbtt__csctx_rline_to(c, s[i], 0);
-            i++;
-      vlineto:
-            if (i >= sp) break;
-            stbtt__csctx_rline_to(c, 0, s[i]);
-            i++;
-         }
-         break;
-
-      case 0x1F: // hvcurveto
-         if (sp < 4) return STBTT__CSERR("hvcurveto stack");
-         goto hvcurveto;
-      case 0x1E: // vhcurveto
-         if (sp < 4) return STBTT__CSERR("vhcurveto stack");
-         for (;;) {
-            if (i + 3 >= sp) break;
-            stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f);
-            i += 4;
-      hvcurveto:
-            if (i + 3 >= sp) break;
-            stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]);
-            i += 4;
-         }
-         break;
-
-      case 0x08: // rrcurveto
-         if (sp < 6) return STBTT__CSERR("rcurveline stack");
-         for (; i + 5 < sp; i += 6)
-            stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         break;
-
-      case 0x18: // rcurveline
-         if (sp < 8) return STBTT__CSERR("rcurveline stack");
-         for (; i + 5 < sp - 2; i += 6)
-            stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack");
-         stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         break;
-
-      case 0x19: // rlinecurve
-         if (sp < 8) return STBTT__CSERR("rlinecurve stack");
-         for (; i + 1 < sp - 6; i += 2)
-            stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack");
-         stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         break;
-
-      case 0x1A: // vvcurveto
-      case 0x1B: // hhcurveto
-         if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack");
-         f = 0.0;
-         if (sp & 1) { f = s[i]; i++; }
-         for (; i + 3 < sp; i += 4) {
-            if (b0 == 0x1B)
-               stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0);
-            else
-               stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]);
-            f = 0.0;
-         }
-         break;
-
-      case 0x0A: // callsubr
-         if (!has_subrs) {
-            if (info->fdselect.size)
-               subrs = stbtt__cid_get_glyph_subrs(info, glyph_index);
-            has_subrs = 1;
-         }
-         // fallthrough
-      case 0x1D: // callgsubr
-         if (sp < 1) return STBTT__CSERR("call(g|)subr stack");
-         v = (int) s[--sp];
-         if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit");
-         subr_stack[subr_stack_height++] = b;
-         b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v);
-         if (b.size == 0) return STBTT__CSERR("subr not found");
-         b.cursor = 0;
-         clear_stack = 0;
-         break;
-
-      case 0x0B: // return
-         if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr");
-         b = subr_stack[--subr_stack_height];
-         clear_stack = 0;
-         break;
-
-      case 0x0E: // endchar
-         stbtt__csctx_close_shape(c);
-         return 1;
-
-      case 0x0C: { // two-byte escape
-         float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6;
-         float dx, dy;
-         int b1 = stbtt__buf_get8(&b);
-         switch (b1) {
-         // @TODO These "flex" implementations ignore the flex-depth and resolution,
-         // and always draw beziers.
-         case 0x22: // hflex
-            if (sp < 7) return STBTT__CSERR("hflex stack");
-            dx1 = s[0];
-            dx2 = s[1];
-            dy2 = s[2];
-            dx3 = s[3];
-            dx4 = s[4];
-            dx5 = s[5];
-            dx6 = s[6];
-            stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0);
-            stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0);
-            break;
-
-         case 0x23: // flex
-            if (sp < 13) return STBTT__CSERR("flex stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dy3 = s[5];
-            dx4 = s[6];
-            dy4 = s[7];
-            dx5 = s[8];
-            dy5 = s[9];
-            dx6 = s[10];
-            dy6 = s[11];
-            //fd is s[12]
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
-            stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
-            break;
-
-         case 0x24: // hflex1
-            if (sp < 9) return STBTT__CSERR("hflex1 stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dx4 = s[5];
-            dx5 = s[6];
-            dy5 = s[7];
-            dx6 = s[8];
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0);
-            stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5));
-            break;
-
-         case 0x25: // flex1
-            if (sp < 11) return STBTT__CSERR("flex1 stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dy3 = s[5];
-            dx4 = s[6];
-            dy4 = s[7];
-            dx5 = s[8];
-            dy5 = s[9];
-            dx6 = dy6 = s[10];
-            dx = dx1+dx2+dx3+dx4+dx5;
-            dy = dy1+dy2+dy3+dy4+dy5;
-            if (STBTT_fabs(dx) > STBTT_fabs(dy))
-               dy6 = -dy;
-            else
-               dx6 = -dx;
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
-            stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
-            break;
-
-         default:
-            return STBTT__CSERR("unimplemented");
-         }
-      } break;
-
-      default:
-         if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254))
-            return STBTT__CSERR("reserved operator");
-
-         // push immediate
-         if (b0 == 255) {
-            f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000;
-         } else {
-            stbtt__buf_skip(&b, -1);
-            f = (float)(stbtt_int16)stbtt__cff_int(&b);
-         }
-         if (sp >= 48) return STBTT__CSERR("push stack overflow");
-         s[sp++] = f;
-         clear_stack = 0;
-         break;
-      }
-      if (clear_stack) sp = 0;
-   }
-   return STBTT__CSERR("no endchar");
-
-#undef STBTT__CSERR
-}
-
-static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   // runs the charstring twice, once to count and once to output (to avoid realloc)
-   stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1);
-   stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0);
-   if (stbtt__run_charstring(info, glyph_index, &count_ctx)) {
-      *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata);
-      output_ctx.pvertices = *pvertices;
-      if (stbtt__run_charstring(info, glyph_index, &output_ctx)) {
-         STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices);
-         return output_ctx.num_vertices;
-      }
-   }
-   *pvertices = NULL;
-   return 0;
-}
-
-static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
-{
-   stbtt__csctx c = STBTT__CSCTX_INIT(1);
-   int r = stbtt__run_charstring(info, glyph_index, &c);
-   if (x0)  *x0 = r ? c.min_x : 0;
-   if (y0)  *y0 = r ? c.min_y : 0;
-   if (x1)  *x1 = r ? c.max_x : 0;
-   if (y1)  *y1 = r ? c.max_y : 0;
-   return r ? c.num_vertices : 0;
-}
-
-STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   if (!info->cff.size)
-      return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices);
-   else
-      return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices);
-}
-
-STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
-{
-   stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
-   if (glyph_index < numOfLongHorMetrics) {
-      if (advanceWidth)     *advanceWidth    = ttSHORT(info->data + info->hmtx + 4*glyph_index);
-      if (leftSideBearing)  *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
-   } else {
-      if (advanceWidth)     *advanceWidth    = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
-      if (leftSideBearing)  *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
-   }
-}
-
-STBTT_DEF int  stbtt_GetKerningTableLength(const stbtt_fontinfo *info)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   return ttUSHORT(data+10);
-}
-
-STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-   int k, length;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   length = ttUSHORT(data+10);
-   if (table_length < length)
-      length = table_length;
-
-   for (k = 0; k < length; k++)
-   {
-      table[k].glyph1 = ttUSHORT(data+18+(k*6));
-      table[k].glyph2 = ttUSHORT(data+20+(k*6));
-      table[k].advance = ttSHORT(data+22+(k*6));
-   }
-
-   return length;
-}
-
-static int  stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-   stbtt_uint32 needle, straw;
-   int l, r, m;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   l = 0;
-   r = ttUSHORT(data+10) - 1;
-   needle = glyph1 << 16 | glyph2;
-   while (l <= r) {
-      m = (l + r) >> 1;
-      straw = ttULONG(data+18+(m*6)); // note: unaligned read
-      if (needle < straw)
-         r = m - 1;
-      else if (needle > straw)
-         l = m + 1;
-      else
-         return ttSHORT(data+22+(m*6));
-   }
-   return 0;
-}
-
-static stbtt_int32  stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
-{
-    stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
-    switch(coverageFormat) {
-        case 1: {
-            stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);
-
-            // Binary search.
-            stbtt_int32 l=0, r=glyphCount-1, m;
-            int straw, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *glyphArray = coverageTable + 4;
-                stbtt_uint16 glyphID;
-                m = (l + r) >> 1;
-                glyphID = ttUSHORT(glyphArray + 2 * m);
-                straw = glyphID;
-                if (needle < straw)
-                    r = m - 1;
-                else if (needle > straw)
-                    l = m + 1;
-                else {
-                     return m;
-                }
-            }
-        } break;
-
-        case 2: {
-            stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
-            stbtt_uint8 *rangeArray = coverageTable + 4;
-
-            // Binary search.
-            stbtt_int32 l=0, r=rangeCount-1, m;
-            int strawStart, strawEnd, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *rangeRecord;
-                m = (l + r) >> 1;
-                rangeRecord = rangeArray + 6 * m;
-                strawStart = ttUSHORT(rangeRecord);
-                strawEnd = ttUSHORT(rangeRecord + 2);
-                if (needle < strawStart)
-                    r = m - 1;
-                else if (needle > strawEnd)
-                    l = m + 1;
-                else {
-                    stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
-                    return startCoverageIndex + glyph - strawStart;
-                }
-            }
-        } break;
-
-        default: {
-            // There are no other cases.
-            STBTT_assert(0);
-        } break;
-    }
-
-    return -1;
-}
-
-static stbtt_int32  stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
-{
-    stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
-    switch(classDefFormat)
-    {
-        case 1: {
-            stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2);
-            stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4);
-            stbtt_uint8 *classDef1ValueArray = classDefTable + 6;
-
-            if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
-                return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
-
-            classDefTable = classDef1ValueArray + 2 * glyphCount;
-        } break;
-
-        case 2: {
-            stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2);
-            stbtt_uint8 *classRangeRecords = classDefTable + 4;
-
-            // Binary search.
-            stbtt_int32 l=0, r=classRangeCount-1, m;
-            int strawStart, strawEnd, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *classRangeRecord;
-                m = (l + r) >> 1;
-                classRangeRecord = classRangeRecords + 6 * m;
-                strawStart = ttUSHORT(classRangeRecord);
-                strawEnd = ttUSHORT(classRangeRecord + 2);
-                if (needle < strawStart)
-                    r = m - 1;
-                else if (needle > strawEnd)
-                    l = m + 1;
-                else
-                    return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
-            }
-
-            classDefTable = classRangeRecords + 6 * classRangeCount;
-        } break;
-
-        default: {
-            // There are no other cases.
-            STBTT_assert(0);
-        } break;
-    }
-
-    return -1;
-}
-
-// Define to STBTT_assert(x) if you want to break on unimplemented formats.
-#define STBTT_GPOS_TODO_assert(x)
-
-static stbtt_int32  stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
-{
-    stbtt_uint16 lookupListOffset;
-    stbtt_uint8 *lookupList;
-    stbtt_uint16 lookupCount;
-    stbtt_uint8 *data;
-    stbtt_int32 i;
-
-    if (!info->gpos) return 0;
-
-    data = info->data + info->gpos;
-
-    if (ttUSHORT(data+0) != 1) return 0; // Major version 1
-    if (ttUSHORT(data+2) != 0) return 0; // Minor version 0
-
-    lookupListOffset = ttUSHORT(data+8);
-    lookupList = data + lookupListOffset;
-    lookupCount = ttUSHORT(lookupList);
-
-    for (i=0; i<lookupCount; ++i) {
-        stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
-        stbtt_uint8 *lookupTable = lookupList + lookupOffset;
-
-        stbtt_uint16 lookupType = ttUSHORT(lookupTable);
-        stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
-        stbtt_uint8 *subTableOffsets = lookupTable + 6;
-        switch(lookupType) {
-            case 2: { // Pair Adjustment Positioning Subtable
-                stbtt_int32 sti;
-                for (sti=0; sti<subTableCount; sti++) {
-                    stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
-                    stbtt_uint8 *table = lookupTable + subtableOffset;
-                    stbtt_uint16 posFormat = ttUSHORT(table);
-                    stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
-                    stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
-                    if (coverageIndex == -1) continue;
-
-                    switch (posFormat) {
-                        case 1: {
-                            stbtt_int32 l, r, m;
-                            int straw, needle;
-                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
-                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
-                            stbtt_int32 valueRecordPairSizeInBytes = 2;
-                            stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
-                            stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
-                            stbtt_uint8 *pairValueTable = table + pairPosOffset;
-                            stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
-                            stbtt_uint8 *pairValueArray = pairValueTable + 2;
-                            // TODO: Support more formats.
-                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
-                            if (valueFormat1 != 4) return 0;
-                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
-                            if (valueFormat2 != 0) return 0;
-
-                            STBTT_assert(coverageIndex < pairSetCount);
-                            STBTT__NOTUSED(pairSetCount);
-
-                            needle=glyph2;
-                            r=pairValueCount-1;
-                            l=0;
-
-                            // Binary search.
-                            while (l <= r) {
-                                stbtt_uint16 secondGlyph;
-                                stbtt_uint8 *pairValue;
-                                m = (l + r) >> 1;
-                                pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
-                                secondGlyph = ttUSHORT(pairValue);
-                                straw = secondGlyph;
-                                if (needle < straw)
-                                    r = m - 1;
-                                else if (needle > straw)
-                                    l = m + 1;
-                                else {
-                                    stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
-                                    return xAdvance;
-                                }
-                            }
-                        } break;
-
-                        case 2: {
-                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
-                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
-
-                            stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
-                            stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
-                            int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
-                            int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);
-
-                            stbtt_uint16 class1Count = ttUSHORT(table + 12);
-                            stbtt_uint16 class2Count = ttUSHORT(table + 14);
-                            STBTT_assert(glyph1class < class1Count);
-                            STBTT_assert(glyph2class < class2Count);
-
-                            // TODO: Support more formats.
-                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
-                            if (valueFormat1 != 4) return 0;
-                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
-                            if (valueFormat2 != 0) return 0;
-
-                            if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) {
-                                stbtt_uint8 *class1Records = table + 16;
-                                stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count);
-                                stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class);
-                                return xAdvance;
-                            }
-                        } break;
-
-                        default: {
-                            // There are no other cases.
-                            STBTT_assert(0);
-                            break;
-                        };
-                    }
-                }
-                break;
-            };
-
-            default:
-                // TODO: Implement other stuff.
-                break;
-        }
-    }
-
-    return 0;
-}
-
-STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
-{
-   int xAdvance = 0;
-
-   if (info->gpos)
-      xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
-   else if (info->kern)
-      xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
-
-   return xAdvance;
-}
-
-STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
-{
-   if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs
-      return 0;
-   return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
-}
-
-STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
-{
-   stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
-}
-
-STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
-{
-   if (ascent ) *ascent  = ttSHORT(info->data+info->hhea + 4);
-   if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
-   if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
-}
-
-STBTT_DEF int  stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap)
-{
-   int tab = stbtt__find_table(info->data, info->fontstart, "OS/2");
-   if (!tab)
-      return 0;
-   if (typoAscent ) *typoAscent  = ttSHORT(info->data+tab + 68);
-   if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70);
-   if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72);
-   return 1;
-}
-
-STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
-{
-   *x0 = ttSHORT(info->data + info->head + 36);
-   *y0 = ttSHORT(info->data + info->head + 38);
-   *x1 = ttSHORT(info->data + info->head + 40);
-   *y1 = ttSHORT(info->data + info->head + 42);
-}
-
-STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
-{
-   int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
-   return (float) height / fheight;
-}
-
-STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
-{
-   int unitsPerEm = ttUSHORT(info->data + info->head + 18);
-   return pixels / unitsPerEm;
-}
-
-STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
-{
-   STBTT_free(v, info->userdata);
-}
-
-STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl)
-{
-   int i;
-   stbtt_uint8 *data = info->data;
-   stbtt_uint8 *svg_doc_list = data + stbtt__get_svg((stbtt_fontinfo *) info);
-
-   int numEntries = ttUSHORT(svg_doc_list);
-   stbtt_uint8 *svg_docs = svg_doc_list + 2;
-
-   for(i=0; i<numEntries; i++) {
-      stbtt_uint8 *svg_doc = svg_docs + (12 * i);
-      if ((gl >= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2)))
-         return svg_doc;
-   }
-   return 0;
-}
-
-STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg)
-{
-   stbtt_uint8 *data = info->data;
-   stbtt_uint8 *svg_doc;
-
-   if (info->svg == 0)
-      return 0;
-
-   svg_doc = stbtt_FindSVGDoc(info, gl);
-   if (svg_doc != NULL) {
-      *svg = (char *) data + info->svg + ttULONG(svg_doc + 4);
-      return ttULONG(svg_doc + 8);
-   } else {
-      return 0;
-   }
-}
-
-STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg)
-{
-   return stbtt_GetGlyphSVG(info, stbtt_FindGlyphIndex(info, unicode_codepoint), svg);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// antialiasing software rasterizer
-//
-
-STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning
-   if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
-      // e.g. space character
-      if (ix0) *ix0 = 0;
-      if (iy0) *iy0 = 0;
-      if (ix1) *ix1 = 0;
-      if (iy1) *iy1 = 0;
-   } else {
-      // move to integral bboxes (treating pixels as little squares, what pixels get touched)?
-      if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x);
-      if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y);
-      if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x);
-      if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y);
-   }
-}
-
-STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
-}
-
-STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
-}
-
-STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  Rasterizer
-
-typedef struct stbtt__hheap_chunk
-{
-   struct stbtt__hheap_chunk *next;
-} stbtt__hheap_chunk;
-
-typedef struct stbtt__hheap
-{
-   struct stbtt__hheap_chunk *head;
-   void   *first_free;
-   int    num_remaining_in_head_chunk;
-} stbtt__hheap;
-
-static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata)
-{
-   if (hh->first_free) {
-      void *p = hh->first_free;
-      hh->first_free = * (void **) p;
-      return p;
-   } else {
-      if (hh->num_remaining_in_head_chunk == 0) {
-         int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
-         stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata);
-         if (c == NULL)
-            return NULL;
-         c->next = hh->head;
-         hh->head = c;
-         hh->num_remaining_in_head_chunk = count;
-      }
-      --hh->num_remaining_in_head_chunk;
-      return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk;
-   }
-}
-
-static void stbtt__hheap_free(stbtt__hheap *hh, void *p)
-{
-   *(void **) p = hh->first_free;
-   hh->first_free = p;
-}
-
-static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata)
-{
-   stbtt__hheap_chunk *c = hh->head;
-   while (c) {
-      stbtt__hheap_chunk *n = c->next;
-      STBTT_free(c, userdata);
-      c = n;
-   }
-}
-
-typedef struct stbtt__edge {
-   float x0,y0, x1,y1;
-   int invert;
-} stbtt__edge;
-
-
-typedef struct stbtt__active_edge
-{
-   struct stbtt__active_edge *next;
-   #if STBTT_RASTERIZER_VERSION==1
-   int x,dx;
-   float ey;
-   int direction;
-   #elif STBTT_RASTERIZER_VERSION==2
-   float fx,fdx,fdy;
-   float direction;
-   float sy;
-   float ey;
-   #else
-   #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-   #endif
-} stbtt__active_edge;
-
-#if STBTT_RASTERIZER_VERSION == 1
-#define STBTT_FIXSHIFT   10
-#define STBTT_FIX        (1 << STBTT_FIXSHIFT)
-#define STBTT_FIXMASK    (STBTT_FIX-1)
-
-static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
-{
-   stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
-   float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-   STBTT_assert(z != NULL);
-   if (!z) return z;
-
-   // round dx down to avoid overshooting
-   if (dxdy < 0)
-      z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy);
-   else
-      z->dx = STBTT_ifloor(STBTT_FIX * dxdy);
-
-   z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount
-   z->x -= off_x * STBTT_FIX;
-
-   z->ey = e->y1;
-   z->next = 0;
-   z->direction = e->invert ? 1 : -1;
-   return z;
-}
-#elif STBTT_RASTERIZER_VERSION == 2
-static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
-{
-   stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
-   float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-   STBTT_assert(z != NULL);
-   //STBTT_assert(e->y0 <= start_point);
-   if (!z) return z;
-   z->fdx = dxdy;
-   z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f;
-   z->fx = e->x0 + dxdy * (start_point - e->y0);
-   z->fx -= off_x;
-   z->direction = e->invert ? 1.0f : -1.0f;
-   z->sy = e->y0;
-   z->ey = e->y1;
-   z->next = 0;
-   return z;
-}
-#else
-#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-
-#if STBTT_RASTERIZER_VERSION == 1
-// note: this routine clips fills that extend off the edges... ideally this
-// wouldn't happen, but it could happen if the truetype glyph bounding boxes
-// are wrong, or if the user supplies a too-small bitmap
-static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight)
-{
-   // non-zero winding fill
-   int x0=0, w=0;
-
-   while (e) {
-      if (w == 0) {
-         // if we're currently at zero, we need to record the edge start point
-         x0 = e->x; w += e->direction;
-      } else {
-         int x1 = e->x; w += e->direction;
-         // if we went to zero, we need to draw
-         if (w == 0) {
-            int i = x0 >> STBTT_FIXSHIFT;
-            int j = x1 >> STBTT_FIXSHIFT;
-
-            if (i < len && j >= 0) {
-               if (i == j) {
-                  // x0,x1 are the same pixel, so compute combined coverage
-                  scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT);
-               } else {
-                  if (i >= 0) // add antialiasing for x0
-                     scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT);
-                  else
-                     i = -1; // clip
-
-                  if (j < len) // add antialiasing for x1
-                     scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT);
-                  else
-                     j = len; // clip
-
-                  for (++i; i < j; ++i) // fill pixels between x0 and x1
-                     scanline[i] = scanline[i] + (stbtt_uint8) max_weight;
-               }
-            }
-         }
-      }
-
-      e = e->next;
-   }
-}
-
-static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
-{
-   stbtt__hheap hh = { 0, 0, 0 };
-   stbtt__active_edge *active = NULL;
-   int y,j=0;
-   int max_weight = (255 / vsubsample);  // weight per vertical scanline
-   int s; // vertical subsample index
-   unsigned char scanline_data[512], *scanline;
-
-   if (result->w > 512)
-      scanline = (unsigned char *) STBTT_malloc(result->w, userdata);
-   else
-      scanline = scanline_data;
-
-   y = off_y * vsubsample;
-   e[n].y0 = (off_y + result->h) * (float) vsubsample + 1;
-
-   while (j < result->h) {
-      STBTT_memset(scanline, 0, result->w);
-      for (s=0; s < vsubsample; ++s) {
-         // find center of pixel for this scanline
-         float scan_y = y + 0.5f;
-         stbtt__active_edge **step = &active;
-
-         // update all active edges;
-         // remove all active edges that terminate before the center of this scanline
-         while (*step) {
-            stbtt__active_edge * z = *step;
-            if (z->ey <= scan_y) {
-               *step = z->next; // delete from list
-               STBTT_assert(z->direction);
-               z->direction = 0;
-               stbtt__hheap_free(&hh, z);
-            } else {
-               z->x += z->dx; // advance to position for current scanline
-               step = &((*step)->next); // advance through list
-            }
-         }
-
-         // resort the list if needed
-         for(;;) {
-            int changed=0;
-            step = &active;
-            while (*step && (*step)->next) {
-               if ((*step)->x > (*step)->next->x) {
-                  stbtt__active_edge *t = *step;
-                  stbtt__active_edge *q = t->next;
-
-                  t->next = q->next;
-                  q->next = t;
-                  *step = q;
-                  changed = 1;
-               }
-               step = &(*step)->next;
-            }
-            if (!changed) break;
-         }
-
-         // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
-         while (e->y0 <= scan_y) {
-            if (e->y1 > scan_y) {
-               stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata);
-               if (z != NULL) {
-                  // find insertion point
-                  if (active == NULL)
-                     active = z;
-                  else if (z->x < active->x) {
-                     // insert at front
-                     z->next = active;
-                     active = z;
-                  } else {
-                     // find thing to insert AFTER
-                     stbtt__active_edge *p = active;
-                     while (p->next && p->next->x < z->x)
-                        p = p->next;
-                     // at this point, p->next->x is NOT < z->x
-                     z->next = p->next;
-                     p->next = z;
-                  }
-               }
-            }
-            ++e;
-         }
-
-         // now process all active edges in XOR fashion
-         if (active)
-            stbtt__fill_active_edges(scanline, result->w, active, max_weight);
-
-         ++y;
-      }
-      STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w);
-      ++j;
-   }
-
-   stbtt__hheap_cleanup(&hh, userdata);
-
-   if (scanline != scanline_data)
-      STBTT_free(scanline, userdata);
-}
-
-#elif STBTT_RASTERIZER_VERSION == 2
-
-// the edge passed in here does not cross the vertical line at x or the vertical line at x+1
-// (i.e. it has already been clipped to those)
-static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1)
-{
-   if (y0 == y1) return;
-   STBTT_assert(y0 < y1);
-   STBTT_assert(e->sy <= e->ey);
-   if (y0 > e->ey) return;
-   if (y1 < e->sy) return;
-   if (y0 < e->sy) {
-      x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
-      y0 = e->sy;
-   }
-   if (y1 > e->ey) {
-      x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
-      y1 = e->ey;
-   }
-
-   if (x0 == x)
-      STBTT_assert(x1 <= x+1);
-   else if (x0 == x+1)
-      STBTT_assert(x1 >= x);
-   else if (x0 <= x)
-      STBTT_assert(x1 <= x);
-   else if (x0 >= x+1)
-      STBTT_assert(x1 >= x+1);
-   else
-      STBTT_assert(x1 >= x && x1 <= x+1);
-
-   if (x0 <= x && x1 <= x)
-      scanline[x] += e->direction * (y1-y0);
-   else if (x0 >= x+1 && x1 >= x+1)
-      ;
-   else {
-      STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
-      scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position
-   }
-}
-
-static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top)
-{
-   float y_bottom = y_top+1;
-
-   while (e) {
-      // brute force every pixel
-
-      // compute intersection points with top & bottom
-      STBTT_assert(e->ey >= y_top);
-
-      if (e->fdx == 0) {
-         float x0 = e->fx;
-         if (x0 < len) {
-            if (x0 >= 0) {
-               stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom);
-               stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom);
-            } else {
-               stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
-            }
-         }
-      } else {
-         float x0 = e->fx;
-         float dx = e->fdx;
-         float xb = x0 + dx;
-         float x_top, x_bottom;
-         float sy0,sy1;
-         float dy = e->fdy;
-         STBTT_assert(e->sy <= y_bottom && e->ey >= y_top);
-
-         // compute endpoints of line segment clipped to this scanline (if the
-         // line segment starts on this scanline. x0 is the intersection of the
-         // line with y_top, but that may be off the line segment.
-         if (e->sy > y_top) {
-            x_top = x0 + dx * (e->sy - y_top);
-            sy0 = e->sy;
-         } else {
-            x_top = x0;
-            sy0 = y_top;
-         }
-         if (e->ey < y_bottom) {
-            x_bottom = x0 + dx * (e->ey - y_top);
-            sy1 = e->ey;
-         } else {
-            x_bottom = xb;
-            sy1 = y_bottom;
-         }
-
-         if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) {
-            // from here on, we don't have to range check x values
-
-            if ((int) x_top == (int) x_bottom) {
-               float height;
-               // simple case, only spans one pixel
-               int x = (int) x_top;
-               height = sy1 - sy0;
-               STBTT_assert(x >= 0 && x < len);
-               scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2)  * height;
-               scanline_fill[x] += e->direction * height; // everything right of this pixel is filled
-            } else {
-               int x,x1,x2;
-               float y_crossing, step, sign, area;
-               // covers 2+ pixels
-               if (x_top > x_bottom) {
-                  // flip scanline vertically; signed area is the same
-                  float t;
-                  sy0 = y_bottom - (sy0 - y_top);
-                  sy1 = y_bottom - (sy1 - y_top);
-                  t = sy0, sy0 = sy1, sy1 = t;
-                  t = x_bottom, x_bottom = x_top, x_top = t;
-                  dx = -dx;
-                  dy = -dy;
-                  t = x0, x0 = xb, xb = t;
-               }
-
-               x1 = (int) x_top;
-               x2 = (int) x_bottom;
-               // compute intersection with y axis at x1+1
-               y_crossing = (x1+1 - x0) * dy + y_top;
-
-               sign = e->direction;
-               // area of the rectangle covered from y0..y_crossing
-               area = sign * (y_crossing-sy0);
-               // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing)
-               scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2);
-
-               step = sign * dy;
-               for (x = x1+1; x < x2; ++x) {
-                  scanline[x] += area + step/2;
-                  area += step;
-               }
-               y_crossing += dy * (x2 - (x1+1));
-
-               STBTT_assert(STBTT_fabs(area) <= 1.01f);
-
-               scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing);
-
-               scanline_fill[x2] += sign * (sy1-sy0);
-            }
-         } else {
-            // if edge goes outside of box we're drawing, we require
-            // clipping logic. since this does not match the intended use
-            // of this library, we use a different, very slow brute
-            // force implementation
-            int x;
-            for (x=0; x < len; ++x) {
-               // cases:
-               //
-               // there can be up to two intersections with the pixel. any intersection
-               // with left or right edges can be handled by splitting into two (or three)
-               // regions. intersections with top & bottom do not necessitate case-wise logic.
-               //
-               // the old way of doing this found the intersections with the left & right edges,
-               // then used some simple logic to produce up to three segments in sorted order
-               // from top-to-bottom. however, this had a problem: if an x edge was epsilon
-               // across the x border, then the corresponding y position might not be distinct
-               // from the other y segment, and it might ignored as an empty segment. to avoid
-               // that, we need to explicitly produce segments based on x positions.
-
-               // rename variables to clearly-defined pairs
-               float y0 = y_top;
-               float x1 = (float) (x);
-               float x2 = (float) (x+1);
-               float x3 = xb;
-               float y3 = y_bottom;
-
-               // x = e->x + e->dx * (y-y_top)
-               // (y-y_top) = (x - e->x) / e->dx
-               // y = (x - e->x) / e->dx + y_top
-               float y1 = (x - x0) / dx + y_top;
-               float y2 = (x+1 - x0) / dx + y_top;
-
-               if (x0 < x1 && x3 > x2) {         // three segments descending down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else if (x3 < x1 && x0 > x2) {  // three segments descending down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x0 < x1 && x3 > x1) {  // two segments across x, down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x3 < x1 && x0 > x1) {  // two segments across x, down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x0 < x2 && x3 > x2) {  // two segments across x+1, down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else if (x3 < x2 && x0 > x2) {  // two segments across x+1, down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else {  // one segment
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3);
-               }
-            }
-         }
-      }
-      e = e->next;
-   }
-}
-
-// directly AA rasterize edges w/o supersampling
-static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
-{
-   stbtt__hheap hh = { 0, 0, 0 };
-   stbtt__active_edge *active = NULL;
-   int y,j=0, i;
-   float scanline_data[129], *scanline, *scanline2;
-
-   STBTT__NOTUSED(vsubsample);
-
-   if (result->w > 64)
-      scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata);
-   else
-      scanline = scanline_data;
-
-   scanline2 = scanline + result->w;
-
-   y = off_y;
-   e[n].y0 = (float) (off_y + result->h) + 1;
-
-   while (j < result->h) {
-      // find center of pixel for this scanline
-      float scan_y_top    = y + 0.0f;
-      float scan_y_bottom = y + 1.0f;
-      stbtt__active_edge **step = &active;
-
-      STBTT_memset(scanline , 0, result->w*sizeof(scanline[0]));
-      STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0]));
-
-      // update all active edges;
-      // remove all active edges that terminate before the top of this scanline
-      while (*step) {
-         stbtt__active_edge * z = *step;
-         if (z->ey <= scan_y_top) {
-            *step = z->next; // delete from list
-            STBTT_assert(z->direction);
-            z->direction = 0;
-            stbtt__hheap_free(&hh, z);
-         } else {
-            step = &((*step)->next); // advance through list
-         }
-      }
-
-      // insert all edges that start before the bottom of this scanline
-      while (e->y0 <= scan_y_bottom) {
-         if (e->y0 != e->y1) {
-            stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
-            if (z != NULL) {
-               if (j == 0 && off_y != 0) {
-                  if (z->ey < scan_y_top) {
-                     // this can happen due to subpixel positioning and some kind of fp rounding error i think
-                     z->ey = scan_y_top;
-                  }
-               }
-               STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds
-               // insert at front
-               z->next = active;
-               active = z;
-            }
-         }
-         ++e;
-      }
-
-      // now process all active edges
-      if (active)
-         stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
-
-      {
-         float sum = 0;
-         for (i=0; i < result->w; ++i) {
-            float k;
-            int m;
-            sum += scanline2[i];
-            k = scanline[i] + sum;
-            k = (float) STBTT_fabs(k)*255 + 0.5f;
-            m = (int) k;
-            if (m > 255) m = 255;
-            result->pixels[j*result->stride + i] = (unsigned char) m;
-         }
-      }
-      // advance all the edges
-      step = &active;
-      while (*step) {
-         stbtt__active_edge *z = *step;
-         z->fx += z->fdx; // advance to position for current scanline
-         step = &((*step)->next); // advance through list
-      }
-
-      ++y;
-      ++j;
-   }
-
-   stbtt__hheap_cleanup(&hh, userdata);
-
-   if (scanline != scanline_data)
-      STBTT_free(scanline, userdata);
-}
-#else
-#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-
-#define STBTT__COMPARE(a,b)  ((a)->y0 < (b)->y0)
-
-static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
-{
-   int i,j;
-   for (i=1; i < n; ++i) {
-      stbtt__edge t = p[i], *a = &t;
-      j = i;
-      while (j > 0) {
-         stbtt__edge *b = &p[j-1];
-         int c = STBTT__COMPARE(a,b);
-         if (!c) break;
-         p[j] = p[j-1];
-         --j;
-      }
-      if (i != j)
-         p[j] = t;
-   }
-}
-
-static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
-{
-   /* threshold for transitioning to insertion sort */
-   while (n > 12) {
-      stbtt__edge t;
-      int c01,c12,c,m,i,j;
-
-      /* compute median of three */
-      m = n >> 1;
-      c01 = STBTT__COMPARE(&p[0],&p[m]);
-      c12 = STBTT__COMPARE(&p[m],&p[n-1]);
-      /* if 0 >= mid >= end, or 0 < mid < end, then use mid */
-      if (c01 != c12) {
-         /* otherwise, we'll need to swap something else to middle */
-         int z;
-         c = STBTT__COMPARE(&p[0],&p[n-1]);
-         /* 0>mid && mid<n:  0>n => n; 0<n => 0 */
-         /* 0<mid && mid>n:  0>n => 0; 0<n => n */
-         z = (c == c12) ? 0 : n-1;
-         t = p[z];
-         p[z] = p[m];
-         p[m] = t;
-      }
-      /* now p[m] is the median-of-three */
-      /* swap it to the beginning so it won't move around */
-      t = p[0];
-      p[0] = p[m];
-      p[m] = t;
-
-      /* partition loop */
-      i=1;
-      j=n-1;
-      for(;;) {
-         /* handling of equality is crucial here */
-         /* for sentinels & efficiency with duplicates */
-         for (;;++i) {
-            if (!STBTT__COMPARE(&p[i], &p[0])) break;
-         }
-         for (;;--j) {
-            if (!STBTT__COMPARE(&p[0], &p[j])) break;
-         }
-         /* make sure we haven't crossed */
-         if (i >= j) break;
-         t = p[i];
-         p[i] = p[j];
-         p[j] = t;
-
-         ++i;
-         --j;
-      }
-      /* recurse on smaller side, iterate on larger */
-      if (j < (n-i)) {
-         stbtt__sort_edges_quicksort(p,j);
-         p = p+i;
-         n = n-i;
-      } else {
-         stbtt__sort_edges_quicksort(p+i, n-i);
-         n = j;
-      }
-   }
-}
-
-static void stbtt__sort_edges(stbtt__edge *p, int n)
-{
-   stbtt__sort_edges_quicksort(p, n);
-   stbtt__sort_edges_ins_sort(p, n);
-}
-
-typedef struct
-{
-   float x,y;
-} stbtt__point;
-
-static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata)
-{
-   float y_scale_inv = invert ? -scale_y : scale_y;
-   stbtt__edge *e;
-   int n,i,j,k,m;
-#if STBTT_RASTERIZER_VERSION == 1
-   int vsubsample = result->h < 8 ? 15 : 5;
-#elif STBTT_RASTERIZER_VERSION == 2
-   int vsubsample = 1;
-#else
-   #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-   // vsubsample should divide 255 evenly; otherwise we won't reach full opacity
-
-   // now we have to blow out the windings into explicit edge lists
-   n = 0;
-   for (i=0; i < windings; ++i)
-      n += wcount[i];
-
-   e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel
-   if (e == 0) return;
-   n = 0;
-
-   m=0;
-   for (i=0; i < windings; ++i) {
-      stbtt__point *p = pts + m;
-      m += wcount[i];
-      j = wcount[i]-1;
-      for (k=0; k < wcount[i]; j=k++) {
-         int a=k,b=j;
-         // skip the edge if horizontal
-         if (p[j].y == p[k].y)
-            continue;
-         // add edge from j to k to the list
-         e[n].invert = 0;
-         if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
-            e[n].invert = 1;
-            a=j,b=k;
-         }
-         e[n].x0 = p[a].x * scale_x + shift_x;
-         e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample;
-         e[n].x1 = p[b].x * scale_x + shift_x;
-         e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample;
-         ++n;
-      }
-   }
-
-   // now sort the edges by their highest point (should snap to integer, and then by x)
-   //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare);
-   stbtt__sort_edges(e, n);
-
-   // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule
-   stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata);
-
-   STBTT_free(e, userdata);
-}
-
-static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
-{
-   if (!points) return; // during first pass, it's unallocated
-   points[n].x = x;
-   points[n].y = y;
-}
-
-// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching
-static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
-{
-   // midpoint
-   float mx = (x0 + 2*x1 + x2)/4;
-   float my = (y0 + 2*y1 + y2)/4;
-   // versus directly drawn line
-   float dx = (x0+x2)/2 - mx;
-   float dy = (y0+y2)/2 - my;
-   if (n > 16) // 65536 segments on one curve better be enough!
-      return 1;
-   if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA
-      stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
-      stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
-   } else {
-      stbtt__add_point(points, *num_points,x2,y2);
-      *num_points = *num_points+1;
-   }
-   return 1;
-}
-
-static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n)
-{
-   // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough
-   float dx0 = x1-x0;
-   float dy0 = y1-y0;
-   float dx1 = x2-x1;
-   float dy1 = y2-y1;
-   float dx2 = x3-x2;
-   float dy2 = y3-y2;
-   float dx = x3-x0;
-   float dy = y3-y0;
-   float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2));
-   float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy);
-   float flatness_squared = longlen*longlen-shortlen*shortlen;
-
-   if (n > 16) // 65536 segments on one curve better be enough!
-      return;
-
-   if (flatness_squared > objspace_flatness_squared) {
-      float x01 = (x0+x1)/2;
-      float y01 = (y0+y1)/2;
-      float x12 = (x1+x2)/2;
-      float y12 = (y1+y2)/2;
-      float x23 = (x2+x3)/2;
-      float y23 = (y2+y3)/2;
-
-      float xa = (x01+x12)/2;
-      float ya = (y01+y12)/2;
-      float xb = (x12+x23)/2;
-      float yb = (y12+y23)/2;
-
-      float mx = (xa+xb)/2;
-      float my = (ya+yb)/2;
-
-      stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1);
-      stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1);
-   } else {
-      stbtt__add_point(points, *num_points,x3,y3);
-      *num_points = *num_points+1;
-   }
-}
-
-// returns number of contours
-static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
-{
-   stbtt__point *points=0;
-   int num_points=0;
-
-   float objspace_flatness_squared = objspace_flatness * objspace_flatness;
-   int i,n=0,start=0, pass;
-
-   // count how many "moves" there are to get the contour count
-   for (i=0; i < num_verts; ++i)
-      if (vertices[i].type == STBTT_vmove)
-         ++n;
-
-   *num_contours = n;
-   if (n == 0) return 0;
-
-   *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata);
-
-   if (*contour_lengths == 0) {
-      *num_contours = 0;
-      return 0;
-   }
-
-   // make two passes through the points so we don't need to realloc
-   for (pass=0; pass < 2; ++pass) {
-      float x=0,y=0;
-      if (pass == 1) {
-         points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata);
-         if (points == NULL) goto error;
-      }
-      num_points = 0;
-      n= -1;
-      for (i=0; i < num_verts; ++i) {
-         switch (vertices[i].type) {
-            case STBTT_vmove:
-               // start the next contour
-               if (n >= 0)
-                  (*contour_lengths)[n] = num_points - start;
-               ++n;
-               start = num_points;
-
-               x = vertices[i].x, y = vertices[i].y;
-               stbtt__add_point(points, num_points++, x,y);
-               break;
-            case STBTT_vline:
-               x = vertices[i].x, y = vertices[i].y;
-               stbtt__add_point(points, num_points++, x, y);
-               break;
-            case STBTT_vcurve:
-               stbtt__tesselate_curve(points, &num_points, x,y,
-                                        vertices[i].cx, vertices[i].cy,
-                                        vertices[i].x,  vertices[i].y,
-                                        objspace_flatness_squared, 0);
-               x = vertices[i].x, y = vertices[i].y;
-               break;
-            case STBTT_vcubic:
-               stbtt__tesselate_cubic(points, &num_points, x,y,
-                                        vertices[i].cx, vertices[i].cy,
-                                        vertices[i].cx1, vertices[i].cy1,
-                                        vertices[i].x,  vertices[i].y,
-                                        objspace_flatness_squared, 0);
-               x = vertices[i].x, y = vertices[i].y;
-               break;
-         }
-      }
-      (*contour_lengths)[n] = num_points - start;
-   }
-
-   return points;
-error:
-   STBTT_free(points, userdata);
-   STBTT_free(*contour_lengths, userdata);
-   *contour_lengths = 0;
-   *num_contours = 0;
-   return NULL;
-}
-
-STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
-{
-   float scale            = scale_x > scale_y ? scale_y : scale_x;
-   int winding_count      = 0;
-   int *winding_lengths   = NULL;
-   stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata);
-   if (windings) {
-      stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata);
-      STBTT_free(winding_lengths, userdata);
-      STBTT_free(windings, userdata);
-   }
-}
-
-STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
-{
-   STBTT_free(bitmap, userdata);
-}
-
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
-{
-   int ix0,iy0,ix1,iy1;
-   stbtt__bitmap gbm;
-   stbtt_vertex *vertices;
-   int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
-
-   if (scale_x == 0) scale_x = scale_y;
-   if (scale_y == 0) {
-      if (scale_x == 0) {
-         STBTT_free(vertices, info->userdata);
-         return NULL;
-      }
-      scale_y = scale_x;
-   }
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1);
-
-   // now we get the size
-   gbm.w = (ix1 - ix0);
-   gbm.h = (iy1 - iy0);
-   gbm.pixels = NULL; // in case we error
-
-   if (width ) *width  = gbm.w;
-   if (height) *height = gbm.h;
-   if (xoff  ) *xoff   = ix0;
-   if (yoff  ) *yoff   = iy0;
-
-   if (gbm.w && gbm.h) {
-      gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata);
-      if (gbm.pixels) {
-         gbm.stride = gbm.w;
-
-         stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata);
-      }
-   }
-   STBTT_free(vertices, info->userdata);
-   return gbm.pixels;
-}
-
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
-{
-   int ix0,iy0;
-   stbtt_vertex *vertices;
-   int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
-   stbtt__bitmap gbm;
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0);
-   gbm.pixels = output;
-   gbm.w = out_w;
-   gbm.h = out_h;
-   gbm.stride = out_stride;
-
-   if (gbm.w && gbm.h)
-      stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata);
-
-   STBTT_free(vertices, info->userdata);
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
-}
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
-{
-   stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint));
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
-}
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
-{
-   stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// bitmap baking
-//
-// This is SUPER-CRAPPY packing to keep source code small
-
-static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
-                                float pixel_height,                     // height of font in pixels
-                                unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
-                                int first_char, int num_chars,          // characters to bake
-                                stbtt_bakedchar *chardata)
-{
-   float scale;
-   int x,y,bottom_y, i;
-   stbtt_fontinfo f;
-   f.userdata = NULL;
-   if (!stbtt_InitFont(&f, data, offset))
-      return -1;
-   STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
-   x=y=1;
-   bottom_y = 1;
-
-   scale = stbtt_ScaleForPixelHeight(&f, pixel_height);
-
-   for (i=0; i < num_chars; ++i) {
-      int advance, lsb, x0,y0,x1,y1,gw,gh;
-      int g = stbtt_FindGlyphIndex(&f, first_char + i);
-      stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb);
-      stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1);
-      gw = x1-x0;
-      gh = y1-y0;
-      if (x + gw + 1 >= pw)
-         y = bottom_y, x = 1; // advance to next row
-      if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row
-         return -i;
-      STBTT_assert(x+gw < pw);
-      STBTT_assert(y+gh < ph);
-      stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g);
-      chardata[i].x0 = (stbtt_int16) x;
-      chardata[i].y0 = (stbtt_int16) y;
-      chardata[i].x1 = (stbtt_int16) (x + gw);
-      chardata[i].y1 = (stbtt_int16) (y + gh);
-      chardata[i].xadvance = scale * advance;
-      chardata[i].xoff     = (float) x0;
-      chardata[i].yoff     = (float) y0;
-      x = x + gw + 1;
-      if (y+gh+1 > bottom_y)
-         bottom_y = y+gh+1;
-   }
-   return bottom_y;
-}
-
-STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
-{
-   float d3d_bias = opengl_fillrule ? 0 : -0.5f;
-   float ipw = 1.0f / pw, iph = 1.0f / ph;
-   const stbtt_bakedchar *b = chardata + char_index;
-   int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f);
-   int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);
-
-   q->x0 = round_x + d3d_bias;
-   q->y0 = round_y + d3d_bias;
-   q->x1 = round_x + b->x1 - b->x0 + d3d_bias;
-   q->y1 = round_y + b->y1 - b->y0 + d3d_bias;
-
-   q->s0 = b->x0 * ipw;
-   q->t0 = b->y0 * iph;
-   q->s1 = b->x1 * ipw;
-   q->t1 = b->y1 * iph;
-
-   *xpos += b->xadvance;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// rectangle packing replacement routines if you don't have stb_rect_pack.h
-//
-
-#ifndef STB_RECT_PACK_VERSION
-
-typedef int stbrp_coord;
-
-////////////////////////////////////////////////////////////////////////////////////
-//                                                                                //
-//                                                                                //
-// COMPILER WARNING ?!?!?                                                         //
-//                                                                                //
-//                                                                                //
-// if you get a compile warning due to these symbols being defined more than      //
-// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h"         //
-//                                                                                //
-////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct
-{
-   int width,height;
-   int x,y,bottom_y;
-} stbrp_context;
-
-typedef struct
-{
-   unsigned char x;
-} stbrp_node;
-
-struct stbrp_rect
-{
-   stbrp_coord x,y;
-   int id,w,h,was_packed;
-};
-
-static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
-{
-   con->width  = pw;
-   con->height = ph;
-   con->x = 0;
-   con->y = 0;
-   con->bottom_y = 0;
-   STBTT__NOTUSED(nodes);
-   STBTT__NOTUSED(num_nodes);
-}
-
-static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects)
-{
-   int i;
-   for (i=0; i < num_rects; ++i) {
-      if (con->x + rects[i].w > con->width) {
-         con->x = 0;
-         con->y = con->bottom_y;
-      }
-      if (con->y + rects[i].h > con->height)
-         break;
-      rects[i].x = con->x;
-      rects[i].y = con->y;
-      rects[i].was_packed = 1;
-      con->x += rects[i].w;
-      if (con->y + rects[i].h > con->bottom_y)
-         con->bottom_y = con->y + rects[i].h;
-   }
-   for (   ; i < num_rects; ++i)
-      rects[i].was_packed = 0;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// bitmap baking
-//
-// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
-// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
-
-STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
-{
-   stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context)            ,alloc_context);
-   int            num_nodes = pw - padding;
-   stbrp_node    *nodes   = (stbrp_node    *) STBTT_malloc(sizeof(*nodes  ) * num_nodes,alloc_context);
-
-   if (context == NULL || nodes == NULL) {
-      if (context != NULL) STBTT_free(context, alloc_context);
-      if (nodes   != NULL) STBTT_free(nodes  , alloc_context);
-      return 0;
-   }
-
-   spc->user_allocator_context = alloc_context;
-   spc->width = pw;
-   spc->height = ph;
-   spc->pixels = pixels;
-   spc->pack_info = context;
-   spc->nodes = nodes;
-   spc->padding = padding;
-   spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
-   spc->h_oversample = 1;
-   spc->v_oversample = 1;
-   spc->skip_missing = 0;
-
-   stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
-
-   if (pixels)
-      STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
-
-   return 1;
-}
-
-STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc)
-{
-   STBTT_free(spc->nodes    , spc->user_allocator_context);
-   STBTT_free(spc->pack_info, spc->user_allocator_context);
-}
-
-STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
-{
-   STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
-   STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
-   if (h_oversample <= STBTT_MAX_OVERSAMPLE)
-      spc->h_oversample = h_oversample;
-   if (v_oversample <= STBTT_MAX_OVERSAMPLE)
-      spc->v_oversample = v_oversample;
-}
-
-STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
-{
-   spc->skip_missing = skip;
-}
-
-#define STBTT__OVER_MASK  (STBTT_MAX_OVERSAMPLE-1)
-
-static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
-{
-   unsigned char buffer[STBTT_MAX_OVERSAMPLE];
-   int safe_w = w - kernel_width;
-   int j;
-   STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
-   for (j=0; j < h; ++j) {
-      int i;
-      unsigned int total;
-      STBTT_memset(buffer, 0, kernel_width);
-
-      total = 0;
-
-      // make kernel_width a constant in common cases so compiler can optimize out the divide
-      switch (kernel_width) {
-         case 2:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 2);
-            }
-            break;
-         case 3:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 3);
-            }
-            break;
-         case 4:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 4);
-            }
-            break;
-         case 5:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 5);
-            }
-            break;
-         default:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / kernel_width);
-            }
-            break;
-      }
-
-      for (; i < w; ++i) {
-         STBTT_assert(pixels[i] == 0);
-         total -= buffer[i & STBTT__OVER_MASK];
-         pixels[i] = (unsigned char) (total / kernel_width);
-      }
-
-      pixels += stride_in_bytes;
-   }
-}
-
-static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
-{
-   unsigned char buffer[STBTT_MAX_OVERSAMPLE];
-   int safe_h = h - kernel_width;
-   int j;
-   STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
-   for (j=0; j < w; ++j) {
-      int i;
-      unsigned int total;
-      STBTT_memset(buffer, 0, kernel_width);
-
-      total = 0;
-
-      // make kernel_width a constant in common cases so compiler can optimize out the divide
-      switch (kernel_width) {
-         case 2:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 2);
-            }
-            break;
-         case 3:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 3);
-            }
-            break;
-         case 4:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 4);
-            }
-            break;
-         case 5:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 5);
-            }
-            break;
-         default:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
-            }
-            break;
-      }
-
-      for (; i < h; ++i) {
-         STBTT_assert(pixels[i*stride_in_bytes] == 0);
-         total -= buffer[i & STBTT__OVER_MASK];
-         pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
-      }
-
-      pixels += 1;
-   }
-}
-
-static float stbtt__oversample_shift(int oversample)
-{
-   if (!oversample)
-      return 0.0f;
-
-   // The prefilter is a box filter of width "oversample",
-   // which shifts phase by (oversample - 1)/2 pixels in
-   // oversampled space. We want to shift in the opposite
-   // direction to counter this.
-   return (float)-(oversample - 1) / (2.0f * (float)oversample);
-}
-
-// rects array must be big enough to accommodate all characters in the given ranges
-STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
-{
-   int i,j,k;
-   int missing_glyph_added = 0;
-
-   k=0;
-   for (i=0; i < num_ranges; ++i) {
-      float fh = ranges[i].font_size;
-      float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
-      ranges[i].h_oversample = (unsigned char) spc->h_oversample;
-      ranges[i].v_oversample = (unsigned char) spc->v_oversample;
-      for (j=0; j < ranges[i].num_chars; ++j) {
-         int x0,y0,x1,y1;
-         int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
-         int glyph = stbtt_FindGlyphIndex(info, codepoint);
-         if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) {
-            rects[k].w = rects[k].h = 0;
-         } else {
-            stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
-                                            scale * spc->h_oversample,
-                                            scale * spc->v_oversample,
-                                            0,0,
-                                            &x0,&y0,&x1,&y1);
-            rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
-            rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
-            if (glyph == 0)
-               missing_glyph_added = 1;
-         }
-         ++k;
-      }
-   }
-
-   return k;
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info,
-                                 output,
-                                 out_w - (prefilter_x - 1),
-                                 out_h - (prefilter_y - 1),
-                                 out_stride,
-                                 scale_x,
-                                 scale_y,
-                                 shift_x,
-                                 shift_y,
-                                 glyph);
-
-   if (prefilter_x > 1)
-      stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x);
-
-   if (prefilter_y > 1)
-      stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y);
-
-   *sub_x = stbtt__oversample_shift(prefilter_x);
-   *sub_y = stbtt__oversample_shift(prefilter_y);
-}
-
-// rects array must be big enough to accommodate all characters in the given ranges
-STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
-{
-   int i,j,k, missing_glyph = -1, return_value = 1;
-
-   // save current values
-   int old_h_over = spc->h_oversample;
-   int old_v_over = spc->v_oversample;
-
-   k = 0;
-   for (i=0; i < num_ranges; ++i) {
-      float fh = ranges[i].font_size;
-      float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
-      float recip_h,recip_v,sub_x,sub_y;
-      spc->h_oversample = ranges[i].h_oversample;
-      spc->v_oversample = ranges[i].v_oversample;
-      recip_h = 1.0f / spc->h_oversample;
-      recip_v = 1.0f / spc->v_oversample;
-      sub_x = stbtt__oversample_shift(spc->h_oversample);
-      sub_y = stbtt__oversample_shift(spc->v_oversample);
-      for (j=0; j < ranges[i].num_chars; ++j) {
-         stbrp_rect *r = &rects[k];
-         if (r->was_packed && r->w != 0 && r->h != 0) {
-            stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
-            int advance, lsb, x0,y0,x1,y1;
-            int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
-            int glyph = stbtt_FindGlyphIndex(info, codepoint);
-            stbrp_coord pad = (stbrp_coord) spc->padding;
-
-            // pad on left and top
-            r->x += pad;
-            r->y += pad;
-            r->w -= pad;
-            r->h -= pad;
-            stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
-            stbtt_GetGlyphBitmapBox(info, glyph,
-                                    scale * spc->h_oversample,
-                                    scale * spc->v_oversample,
-                                    &x0,&y0,&x1,&y1);
-            stbtt_MakeGlyphBitmapSubpixel(info,
-                                          spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                          r->w - spc->h_oversample+1,
-                                          r->h - spc->v_oversample+1,
-                                          spc->stride_in_bytes,
-                                          scale * spc->h_oversample,
-                                          scale * spc->v_oversample,
-                                          0,0,
-                                          glyph);
-
-            if (spc->h_oversample > 1)
-               stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                  r->w, r->h, spc->stride_in_bytes,
-                                  spc->h_oversample);
-
-            if (spc->v_oversample > 1)
-               stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                  r->w, r->h, spc->stride_in_bytes,
-                                  spc->v_oversample);
-
-            bc->x0       = (stbtt_int16)  r->x;
-            bc->y0       = (stbtt_int16)  r->y;
-            bc->x1       = (stbtt_int16) (r->x + r->w);
-            bc->y1       = (stbtt_int16) (r->y + r->h);
-            bc->xadvance =                scale * advance;
-            bc->xoff     =       (float)  x0 * recip_h + sub_x;
-            bc->yoff     =       (float)  y0 * recip_v + sub_y;
-            bc->xoff2    =                (x0 + r->w) * recip_h + sub_x;
-            bc->yoff2    =                (y0 + r->h) * recip_v + sub_y;
-
-            if (glyph == 0)
-               missing_glyph = j;
-         } else if (spc->skip_missing) {
-            return_value = 0;
-         } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) {
-            ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph];
-         } else {
-            return_value = 0; // if any fail, report failure
-         }
-
-         ++k;
-      }
-   }
-
-   // restore original values
-   spc->h_oversample = old_h_over;
-   spc->v_oversample = old_v_over;
-
-   return return_value;
-}
-
-STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects)
-{
-   stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects);
-}
-
-STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
-{
-   stbtt_fontinfo info;
-   int i,j,n, return_value = 1;
-   //stbrp_context *context = (stbrp_context *) spc->pack_info;
-   stbrp_rect    *rects;
-
-   // flag all characters as NOT packed
-   for (i=0; i < num_ranges; ++i)
-      for (j=0; j < ranges[i].num_chars; ++j)
-         ranges[i].chardata_for_range[j].x0 =
-         ranges[i].chardata_for_range[j].y0 =
-         ranges[i].chardata_for_range[j].x1 =
-         ranges[i].chardata_for_range[j].y1 = 0;
-
-   n = 0;
-   for (i=0; i < num_ranges; ++i)
-      n += ranges[i].num_chars;
-
-   rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
-   if (rects == NULL)
-      return 0;
-
-   info.userdata = spc->user_allocator_context;
-   stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index));
-
-   n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
-
-   stbtt_PackFontRangesPackRects(spc, rects, n);
-
-   return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects);
-
-   STBTT_free(rects, spc->user_allocator_context);
-   return return_value;
-}
-
-STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
-            int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
-{
-   stbtt_pack_range range;
-   range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range;
-   range.array_of_unicode_codepoints = NULL;
-   range.num_chars                   = num_chars_in_range;
-   range.chardata_for_range          = chardata_for_range;
-   range.font_size                   = font_size;
-   return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
-}
-
-STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap)
-{
-   int i_ascent, i_descent, i_lineGap;
-   float scale;
-   stbtt_fontinfo info;
-   stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index));
-   scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size);
-   stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap);
-   *ascent  = (float) i_ascent  * scale;
-   *descent = (float) i_descent * scale;
-   *lineGap = (float) i_lineGap * scale;
-}
-
-STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
-{
-   float ipw = 1.0f / pw, iph = 1.0f / ph;
-   const stbtt_packedchar *b = chardata + char_index;
-
-   if (align_to_integer) {
-      float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f);
-      float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f);
-      q->x0 = x;
-      q->y0 = y;
-      q->x1 = x + b->xoff2 - b->xoff;
-      q->y1 = y + b->yoff2 - b->yoff;
-   } else {
-      q->x0 = *xpos + b->xoff;
-      q->y0 = *ypos + b->yoff;
-      q->x1 = *xpos + b->xoff2;
-      q->y1 = *ypos + b->yoff2;
-   }
-
-   q->s0 = b->x0 * ipw;
-   q->t0 = b->y0 * iph;
-   q->s1 = b->x1 * ipw;
-   q->t1 = b->y1 * iph;
-
-   *xpos += b->xadvance;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// sdf computation
-//
-
-#define STBTT_min(a,b)  ((a) < (b) ? (a) : (b))
-#define STBTT_max(a,b)  ((a) < (b) ? (b) : (a))
-
-static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2])
-{
-   float q0perp = q0[1]*ray[0] - q0[0]*ray[1];
-   float q1perp = q1[1]*ray[0] - q1[0]*ray[1];
-   float q2perp = q2[1]*ray[0] - q2[0]*ray[1];
-   float roperp = orig[1]*ray[0] - orig[0]*ray[1];
-
-   float a = q0perp - 2*q1perp + q2perp;
-   float b = q1perp - q0perp;
-   float c = q0perp - roperp;
-
-   float s0 = 0., s1 = 0.;
-   int num_s = 0;
-
-   if (a != 0.0) {
-      float discr = b*b - a*c;
-      if (discr > 0.0) {
-         float rcpna = -1 / a;
-         float d = (float) STBTT_sqrt(discr);
-         s0 = (b+d) * rcpna;
-         s1 = (b-d) * rcpna;
-         if (s0 >= 0.0 && s0 <= 1.0)
-            num_s = 1;
-         if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) {
-            if (num_s == 0) s0 = s1;
-            ++num_s;
-         }
-      }
-   } else {
-      // 2*b*s + c = 0
-      // s = -c / (2*b)
-      s0 = c / (-2 * b);
-      if (s0 >= 0.0 && s0 <= 1.0)
-         num_s = 1;
-   }
-
-   if (num_s == 0)
-      return 0;
-   else {
-      float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]);
-      float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2;
-
-      float q0d =   q0[0]*rayn_x +   q0[1]*rayn_y;
-      float q1d =   q1[0]*rayn_x +   q1[1]*rayn_y;
-      float q2d =   q2[0]*rayn_x +   q2[1]*rayn_y;
-      float rod = orig[0]*rayn_x + orig[1]*rayn_y;
-
-      float q10d = q1d - q0d;
-      float q20d = q2d - q0d;
-      float q0rd = q0d - rod;
-
-      hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d;
-      hits[0][1] = a*s0+b;
-
-      if (num_s > 1) {
-         hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d;
-         hits[1][1] = a*s1+b;
-         return 2;
-      } else {
-         return 1;
-      }
-   }
-}
-
-static int equal(float *a, float *b)
-{
-   return (a[0] == b[0] && a[1] == b[1]);
-}
-
-static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts)
-{
-   int i;
-   float orig[2], ray[2] = { 1, 0 };
-   float y_frac;
-   int winding = 0;
-
-   orig[0] = x;
-   orig[1] = y;
-
-   // make sure y never passes through a vertex of the shape
-   y_frac = (float) STBTT_fmod(y, 1.0f);
-   if (y_frac < 0.01f)
-      y += 0.01f;
-   else if (y_frac > 0.99f)
-      y -= 0.01f;
-   orig[1] = y;
-
-   // test a ray from (-infinity,y) to (x,y)
-   for (i=0; i < nverts; ++i) {
-      if (verts[i].type == STBTT_vline) {
-         int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y;
-         int x1 = (int) verts[i  ].x, y1 = (int) verts[i  ].y;
-         if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
-            float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
-            if (x_inter < x)
-               winding += (y0 < y1) ? 1 : -1;
-         }
-      }
-      if (verts[i].type == STBTT_vcurve) {
-         int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ;
-         int x1 = (int) verts[i  ].cx, y1 = (int) verts[i  ].cy;
-         int x2 = (int) verts[i  ].x , y2 = (int) verts[i  ].y ;
-         int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2));
-         int by = STBTT_max(y0,STBTT_max(y1,y2));
-         if (y > ay && y < by && x > ax) {
-            float q0[2],q1[2],q2[2];
-            float hits[2][2];
-            q0[0] = (float)x0;
-            q0[1] = (float)y0;
-            q1[0] = (float)x1;
-            q1[1] = (float)y1;
-            q2[0] = (float)x2;
-            q2[1] = (float)y2;
-            if (equal(q0,q1) || equal(q1,q2)) {
-               x0 = (int)verts[i-1].x;
-               y0 = (int)verts[i-1].y;
-               x1 = (int)verts[i  ].x;
-               y1 = (int)verts[i  ].y;
-               if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
-                  float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
-                  if (x_inter < x)
-                     winding += (y0 < y1) ? 1 : -1;
-               }
-            } else {
-               int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits);
-               if (num_hits >= 1)
-                  if (hits[0][0] < 0)
-                     winding += (hits[0][1] < 0 ? -1 : 1);
-               if (num_hits >= 2)
-                  if (hits[1][0] < 0)
-                     winding += (hits[1][1] < 0 ? -1 : 1);
-            }
-         }
-      }
-   }
-   return winding;
-}
-
-static float stbtt__cuberoot( float x )
-{
-   if (x<0)
-      return -(float) STBTT_pow(-x,1.0f/3.0f);
-   else
-      return  (float) STBTT_pow( x,1.0f/3.0f);
-}
-
-// x^3 + c*x^2 + b*x + a = 0
-static int stbtt__solve_cubic(float a, float b, float c, float* r)
-{
-       float s = -a / 3;
-       float p = b - a*a / 3;
-       float q = a * (2*a*a - 9*b) / 27 + c;
-   float p3 = p*p*p;
-       float d = q*q + 4*p3 / 27;
-       if (d >= 0) {
-               float z = (float) STBTT_sqrt(d);
-               float u = (-q + z) / 2;
-               float v = (-q - z) / 2;
-               u = stbtt__cuberoot(u);
-               v = stbtt__cuberoot(v);
-               r[0] = s + u + v;
-               return 1;
-       } else {
-          float u = (float) STBTT_sqrt(-p/3);
-          float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative
-          float m = (float) STBTT_cos(v);
-      float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f;
-          r[0] = s + u * 2 * m;
-          r[1] = s - u * (m + n);
-          r[2] = s - u * (m - n);
-
-      //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f);  // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe?
-      //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f);
-      //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f);
-       return 3;
-   }
-}
-
-STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
-{
-   float scale_x = scale, scale_y = scale;
-   int ix0,iy0,ix1,iy1;
-   int w,h;
-   unsigned char *data;
-
-   if (scale == 0) return NULL;
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1);
-
-   // if empty, return NULL
-   if (ix0 == ix1 || iy0 == iy1)
-      return NULL;
-
-   ix0 -= padding;
-   iy0 -= padding;
-   ix1 += padding;
-   iy1 += padding;
-
-   w = (ix1 - ix0);
-   h = (iy1 - iy0);
-
-   if (width ) *width  = w;
-   if (height) *height = h;
-   if (xoff  ) *xoff   = ix0;
-   if (yoff  ) *yoff   = iy0;
-
-   // invert for y-downwards bitmaps
-   scale_y = -scale_y;
-
-   {
-      int x,y,i,j;
-      float *precompute;
-      stbtt_vertex *verts;
-      int num_verts = stbtt_GetGlyphShape(info, glyph, &verts);
-      data = (unsigned char *) STBTT_malloc(w * h, info->userdata);
-      precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata);
-
-      for (i=0,j=num_verts-1; i < num_verts; j=i++) {
-         if (verts[i].type == STBTT_vline) {
-            float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
-            float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;
-            float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
-            precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;
-         } else if (verts[i].type == STBTT_vcurve) {
-            float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;
-            float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;
-            float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;
-            float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
-            float len2 = bx*bx + by*by;
-            if (len2 != 0.0f)
-               precompute[i] = 1.0f / (bx*bx + by*by);
-            else
-               precompute[i] = 0.0f;
-         } else
-            precompute[i] = 0.0f;
-      }
-
-      for (y=iy0; y < iy1; ++y) {
-         for (x=ix0; x < ix1; ++x) {
-            float val;
-            float min_dist = 999999.0f;
-            float sx = (float) x + 0.5f;
-            float sy = (float) y + 0.5f;
-            float x_gspace = (sx / scale_x);
-            float y_gspace = (sy / scale_y);
-
-            int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path
-
-            for (i=0; i < num_verts; ++i) {
-               float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
-
-               // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve
-               float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
-               if (dist2 < min_dist*min_dist)
-                  min_dist = (float) STBTT_sqrt(dist2);
-
-               if (verts[i].type == STBTT_vline) {
-                  float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y;
-
-                  // coarse culling against bbox
-                  //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist &&
-                  //    sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist)
-                  float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i];
-                  STBTT_assert(i != 0);
-                  if (dist < min_dist) {
-                     // check position along line
-                     // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0)
-                     // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy)
-                     float dx = x1-x0, dy = y1-y0;
-                     float px = x0-sx, py = y0-sy;
-                     // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy
-                     // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve
-                     float t = -(px*dx + py*dy) / (dx*dx + dy*dy);
-                     if (t >= 0.0f && t <= 1.0f)
-                        min_dist = dist;
-                  }
-               } else if (verts[i].type == STBTT_vcurve) {
-                  float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y;
-                  float x1 = verts[i  ].cx*scale_x, y1 = verts[i  ].cy*scale_y;
-                  float box_x0 = STBTT_min(STBTT_min(x0,x1),x2);
-                  float box_y0 = STBTT_min(STBTT_min(y0,y1),y2);
-                  float box_x1 = STBTT_max(STBTT_max(x0,x1),x2);
-                  float box_y1 = STBTT_max(STBTT_max(y0,y1),y2);
-                  // coarse culling against bbox to avoid computing cubic unnecessarily
-                  if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) {
-                     int num=0;
-                     float ax = x1-x0, ay = y1-y0;
-                     float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
-                     float mx = x0 - sx, my = y0 - sy;
-                     float res[3],px,py,t,it;
-                     float a_inv = precompute[i];
-                     if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula
-                        float a = 3*(ax*bx + ay*by);
-                        float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);
-                        float c = mx*ax+my*ay;
-                        if (a == 0.0) { // if a is 0, it's linear
-                           if (b != 0.0) {
-                              res[num++] = -c/b;
-                           }
-                        } else {
-                           float discriminant = b*b - 4*a*c;
-                           if (discriminant < 0)
-                              num = 0;
-                           else {
-                              float root = (float) STBTT_sqrt(discriminant);
-                              res[0] = (-b - root)/(2*a);
-                              res[1] = (-b + root)/(2*a);
-                              num = 2; // don't bother distinguishing 1-solution case, as code below will still work
-                           }
-                        }
-                     } else {
-                        float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point
-                        float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv;
-                        float d = (mx*ax+my*ay) * a_inv;
-                        num = stbtt__solve_cubic(b, c, d, res);
-                     }
-                     if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) {
-                        t = res[0], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                     if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) {
-                        t = res[1], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                     if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) {
-                        t = res[2], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                  }
-               }
-            }
-            if (winding == 0)
-               min_dist = -min_dist;  // if outside the shape, value is negative
-            val = onedge_value + pixel_dist_scale * min_dist;
-            if (val < 0)
-               val = 0;
-            else if (val > 255)
-               val = 255;
-            data[(y-iy0)*w+(x-ix0)] = (unsigned char) val;
-         }
-      }
-      STBTT_free(precompute, info->userdata);
-      STBTT_free(verts, info->userdata);
-   }
-   return data;
-}
-
-STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff);
-}
-
-STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata)
-{
-   STBTT_free(bitmap, userdata);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// font name matching -- recommended not to use this
-//
-
-// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
-static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
-{
-   stbtt_int32 i=0;
-
-   // convert utf16 to utf8 and compare the results while converting
-   while (len2) {
-      stbtt_uint16 ch = s2[0]*256 + s2[1];
-      if (ch < 0x80) {
-         if (i >= len1) return -1;
-         if (s1[i++] != ch) return -1;
-      } else if (ch < 0x800) {
-         if (i+1 >= len1) return -1;
-         if (s1[i++] != 0xc0 + (ch >> 6)) return -1;
-         if (s1[i++] != 0x80 + (ch & 0x3f)) return -1;
-      } else if (ch >= 0xd800 && ch < 0xdc00) {
-         stbtt_uint32 c;
-         stbtt_uint16 ch2 = s2[2]*256 + s2[3];
-         if (i+3 >= len1) return -1;
-         c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000;
-         if (s1[i++] != 0xf0 + (c >> 18)) return -1;
-         if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((c >>  6) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((c      ) & 0x3f)) return -1;
-         s2 += 2; // plus another 2 below
-         len2 -= 2;
-      } else if (ch >= 0xdc00 && ch < 0xe000) {
-         return -1;
-      } else {
-         if (i+2 >= len1) return -1;
-         if (s1[i++] != 0xe0 + (ch >> 12)) return -1;
-         if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((ch     ) & 0x3f)) return -1;
-      }
-      s2 += 2;
-      len2 -= 2;
-   }
-   return i;
-}
-
-static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
-{
-   return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
-}
-
-// returns results in whatever encoding you request... but note that 2-byte encodings
-// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
-STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
-{
-   stbtt_int32 i,count,stringOffset;
-   stbtt_uint8 *fc = font->data;
-   stbtt_uint32 offset = font->fontstart;
-   stbtt_uint32 nm = stbtt__find_table(fc, offset, "name");
-   if (!nm) return NULL;
-
-   count = ttUSHORT(fc+nm+2);
-   stringOffset = nm + ttUSHORT(fc+nm+4);
-   for (i=0; i < count; ++i) {
-      stbtt_uint32 loc = nm + 6 + 12 * i;
-      if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2)
-          && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) {
-         *length = ttUSHORT(fc+loc+8);
-         return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10));
-      }
-   }
-   return NULL;
-}
-
-static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id)
-{
-   stbtt_int32 i;
-   stbtt_int32 count = ttUSHORT(fc+nm+2);
-   stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4);
-
-   for (i=0; i < count; ++i) {
-      stbtt_uint32 loc = nm + 6 + 12 * i;
-      stbtt_int32 id = ttUSHORT(fc+loc+6);
-      if (id == target_id) {
-         // find the encoding
-         stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4);
-
-         // is this a Unicode encoding?
-         if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) {
-            stbtt_int32 slen = ttUSHORT(fc+loc+8);
-            stbtt_int32 off = ttUSHORT(fc+loc+10);
-
-            // check if there's a prefix match
-            stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen);
-            if (matchlen >= 0) {
-               // check for target_id+1 immediately following, with same encoding & language
-               if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) {
-                  slen = ttUSHORT(fc+loc+12+8);
-                  off = ttUSHORT(fc+loc+12+10);
-                  if (slen == 0) {
-                     if (matchlen == nlen)
-                        return 1;
-                  } else if (matchlen < nlen && name[matchlen] == ' ') {
-                     ++matchlen;
-                     if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen))
-                        return 1;
-                  }
-               } else {
-                  // if nothing immediately following
-                  if (matchlen == nlen)
-                     return 1;
-               }
-            }
-         }
-
-         // @TODO handle other encodings
-      }
-   }
-   return 0;
-}
-
-static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags)
-{
-   stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name);
-   stbtt_uint32 nm,hd;
-   if (!stbtt__isfont(fc+offset)) return 0;
-
-   // check italics/bold/underline flags in macStyle...
-   if (flags) {
-      hd = stbtt__find_table(fc, offset, "head");
-      if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0;
-   }
-
-   nm = stbtt__find_table(fc, offset, "name");
-   if (!nm) return 0;
-
-   if (flags) {
-      // if we checked the macStyle flags, then just check the family and ignore the subfamily
-      if (stbtt__matchpair(fc, nm, name, nlen, 16, -1))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  1, -1))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  3, -1))  return 1;
-   } else {
-      if (stbtt__matchpair(fc, nm, name, nlen, 16, 17))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  1,  2))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  3, -1))  return 1;
-   }
-
-   return 0;
-}
-
-static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags)
-{
-   stbtt_int32 i;
-   for (i=0;;++i) {
-      stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i);
-      if (off < 0) return off;
-      if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags))
-         return off;
-   }
-}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
-STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,
-                                float pixel_height, unsigned char *pixels, int pw, int ph,
-                                int first_char, int num_chars, stbtt_bakedchar *chardata)
-{
-   return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata);
-}
-
-STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
-{
-   return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
-}
-
-STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
-{
-   return stbtt_GetNumberOfFonts_internal((unsigned char *) data);
-}
-
-STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
-{
-   return stbtt_InitFont_internal(info, (unsigned char *) data, offset);
-}
-
-STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags)
-{
-   return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags);
-}
-
-STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
-{
-   return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
-}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
-#endif // STB_TRUETYPE_IMPLEMENTATION
-
-
-// FULL VERSION HISTORY
-//
-//   1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod
-//   1.18 (2018-01-29) add missing function
-//   1.17 (2017-07-23) make more arguments const; doc fix
-//   1.16 (2017-07-12) SDF support
-//   1.15 (2017-03-03) make more arguments const
-//   1.14 (2017-01-16) num-fonts-in-TTC function
-//   1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
-//   1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
-//   1.11 (2016-04-02) fix unused-variable warning
-//   1.10 (2016-04-02) allow user-defined fabs() replacement
-//                     fix memory leak if fontsize=0.0
-//                     fix warning from duplicate typedef
-//   1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges
-//   1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
-//   1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
-//                     allow PackFontRanges to pack and render in separate phases;
-//                     fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
-//                     fixed an assert() bug in the new rasterizer
-//                     replace assert() with STBTT_assert() in new rasterizer
-//   1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine)
-//                     also more precise AA rasterizer, except if shapes overlap
-//                     remove need for STBTT_sort
-//   1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC
-//   1.04 (2015-04-15) typo in example
-//   1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes
-//   1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++
-//   1.01 (2014-12-08) fix subpixel position when oversampling to exactly match
-//                        non-oversampled; STBTT_POINT_SIZE for packed case only
-//   1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling
-//   0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg)
-//   0.9  (2014-08-07) support certain mac/iOS fonts without an MS platformID
-//   0.8b (2014-07-07) fix a warning
-//   0.8  (2014-05-25) fix a few more warnings
-//   0.7  (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back
-//   0.6c (2012-07-24) improve documentation
-//   0.6b (2012-07-20) fix a few more warnings
-//   0.6  (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels,
-//                        stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty
-//   0.5  (2011-12-09) bugfixes:
-//                        subpixel glyph renderer computed wrong bounding box
-//                        first vertex of shape can be off-curve (FreeSans)
-//   0.4b (2011-12-03) fixed an error in the font baking example
-//   0.4  (2011-12-01) kerning, subpixel rendering (tor)
-//                    bugfixes for:
-//                        codepoint-to-glyph conversion using table fmt=12
-//                        codepoint-to-glyph conversion using table fmt=4
-//                        stbtt_GetBakedQuad with non-square texture (Zer)
-//                    updated Hello World! sample to use kerning and subpixel
-//                    fixed some warnings
-//   0.3  (2009-06-24) cmap fmt=12, compound shapes (MM)
-//                    userdata, malloc-from-userdata, non-zero fill (stb)
-//   0.2  (2009-03-11) Fix unsigned/signed char warnings
-//   0.1  (2009-03-09) First public release
-//
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/stb_vorbis.h b/raylib/external/stb_vorbis.h
deleted file mode 100644 (file)
index c9ee5cc..0000000
+++ /dev/null
@@ -1,5475 +0,0 @@
-// Ogg Vorbis audio decoder - v1.14 - public domain
-// http://nothings.org/stb_vorbis/
-//
-// Original version written by Sean Barrett in 2007.
-//
-// Originally sponsored by RAD Game Tools. Seeking implementation
-// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker,
-// Elias Software, Aras Pranckevicius, and Sean Barrett.
-//
-// LICENSE
-//
-//   See end of file for license information.
-//
-// Limitations:
-//
-//   - floor 0 not supported (used in old ogg vorbis files pre-2004)
-//   - lossless sample-truncation at beginning ignored
-//   - cannot concatenate multiple vorbis streams
-//   - sample positions are 32-bit, limiting seekable 192Khz
-//       files to around 6 hours (Ogg supports 64-bit)
-//
-// Feature contributors:
-//    Dougall Johnson (sample-exact seeking)
-//
-// Bugfix/warning contributors:
-//    Terje Mathisen     Niklas Frykholm     Andy Hill
-//    Casey Muratori     John Bolton         Gargaj
-//    Laurent Gomila     Marc LeBlanc        Ronny Chevalier
-//    Bernhard Wodo      Evan Balster        alxprd@github
-//    Tom Beaumont       Ingo Leitgeb        Nicolas Guillemot
-//    Phillip Bennefall  Rohit               Thiago Goulart
-//    manxorist@github   saga musix          github:infatum
-//    Timur Gagiev       BareRose
-//
-// Partial history:
-//    1.14    - 2018-02-11 - delete bogus dealloca usage
-//    1.13    - 2018-01-29 - fix truncation of last frame (hopefully)
-//    1.12    - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
-//    1.11    - 2017-07-23 - fix MinGW compilation 
-//    1.10    - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
-//    1.09    - 2016-04-04 - back out 'truncation of last frame' fix from previous version
-//    1.08    - 2016-04-02 - warnings; setup memory leaks; truncation of last frame
-//    1.07    - 2015-01-16 - fixes for crashes on invalid files; warning fixes; const
-//    1.06    - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
-//                           some crash fixes when out of memory or with corrupt files
-//                           fix some inappropriately signed shifts
-//    1.05    - 2015-04-19 - don't define __forceinline if it's redundant
-//    1.04    - 2014-08-27 - fix missing const-correct case in API
-//    1.03    - 2014-08-07 - warning fixes
-//    1.02    - 2014-07-09 - declare qsort comparison as explicitly _cdecl in Windows
-//    1.01    - 2014-06-18 - fix stb_vorbis_get_samples_float (interleaved was correct)
-//    1.0     - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in >2-channel;
-//                           (API change) report sample rate for decode-full-file funcs
-//
-// See end of file for full version history.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  HEADER BEGINS HERE
-//
-
-#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H
-#define STB_VORBIS_INCLUDE_STB_VORBIS_H
-
-#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
-#define STB_VORBIS_NO_STDIO
-#endif
-
-#ifndef STB_VORBIS_NO_STDIO
-#include <stdio.h>
-#endif
-
-// NOTE: Added to work with raylib on Android
-#if defined(PLATFORM_ANDROID)
-    #include "utils.h"  // Android fopen function map
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef STB_VORBIS_STATIC
-#define STBVDEF static
-#else
-#define STBVDEF extern
-#endif
-
-///////////   THREAD SAFETY
-
-// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
-// them from multiple threads at the same time. However, you can have multiple
-// stb_vorbis* handles and decode from them independently in multiple thrads.
-
-
-///////////   MEMORY ALLOCATION
-
-// normally stb_vorbis uses malloc() to allocate memory at startup,
-// and alloca() to allocate temporary memory during a frame on the
-// stack. (Memory consumption will depend on the amount of setup
-// data in the file and how you set the compile flags for speed
-// vs. size. In my test files the maximal-size usage is ~150KB.)
-//
-// You can modify the wrapper functions in the source (stbv_setup_malloc,
-// stbv_setup_temp_malloc, temp_malloc) to change this behavior, or you
-// can use a simpler allocation model: you pass in a buffer from
-// which stb_vorbis will allocate _all_ its memory (including the
-// temp memory). "open" may fail with a VORBIS_outofmem if you
-// do not pass in enough data; there is no way to determine how
-// much you do need except to succeed (at which point you can
-// query get_info to find the exact amount required. yes I know
-// this is lame).
-//
-// If you pass in a non-NULL buffer of the type below, allocation
-// will occur from it as described above. Otherwise just pass NULL
-// to use malloc()/alloca()
-
-typedef struct
-{
-   char *alloc_buffer;
-   int   alloc_buffer_length_in_bytes;
-} stb_vorbis_alloc;
-
-
-///////////   FUNCTIONS USEABLE WITH ALL INPUT MODES
-
-typedef struct stb_vorbis stb_vorbis;
-
-typedef struct
-{
-   unsigned int sample_rate;
-   int channels;
-
-   unsigned int setup_memory_required;
-   unsigned int setup_temp_memory_required;
-   unsigned int temp_memory_required;
-
-   int max_frame_size;
-} stb_vorbis_info;
-
-// get general information about the file
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
-
-// get the last error detected (clears it, too)
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f);
-
-// close an ogg vorbis file and free all memory in use
-STBVDEF void stb_vorbis_close(stb_vorbis *f);
-
-// this function returns the offset (in samples) from the beginning of the
-// file that will be returned by the next decode, if it is known, or -1
-// otherwise. after a flush_pushdata() call, this may take a while before
-// it becomes valid again.
-// NOT WORKING YET after a seek with PULLDATA API
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f);
-
-// returns the current seek point within the file, or offset from the beginning
-// of the memory buffer. In pushdata mode it returns 0.
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
-
-///////////   PUSHDATA API
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-
-// this API allows you to get blocks of data from any source and hand
-// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
-// you how much it used, and you have to give it the rest next time;
-// and stb_vorbis may not have enough data to work with and you will
-// need to give it the same data again PLUS more. Note that the Vorbis
-// specification does not bound the size of an individual frame.
-
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
-         const unsigned char * datablock, int datablock_length_in_bytes,
-         int *datablock_memory_consumed_in_bytes,
-         int *error,
-         const stb_vorbis_alloc *alloc_buffer);
-// create a vorbis decoder by passing in the initial data block containing
-//    the ogg&vorbis headers (you don't need to do parse them, just provide
-//    the first N bytes of the file--you're told if it's not enough, see below)
-// on success, returns an stb_vorbis *, does not set error, returns the amount of
-//    data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
-// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
-// if returns NULL and *error is VORBIS_need_more_data, then the input block was
-//       incomplete and you need to pass in a larger block from the start of the file
-
-STBVDEF int stb_vorbis_decode_frame_pushdata(
-         stb_vorbis *f,
-         const unsigned char *datablock, int datablock_length_in_bytes,
-         int *channels,             // place to write number of float * buffers
-         float ***output,           // place to write float ** array of float * buffers
-         int *samples               // place to write number of output samples
-     );
-// decode a frame of audio sample data if possible from the passed-in data block
-//
-// return value: number of bytes we used from datablock
-//
-// possible cases:
-//     0 bytes used, 0 samples output (need more data)
-//     N bytes used, 0 samples output (resynching the stream, keep going)
-//     N bytes used, M samples output (one frame of data)
-// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
-// frame, because Vorbis always "discards" the first frame.
-//
-// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
-// instead only datablock_length_in_bytes-3 or less. This is because it wants
-// to avoid missing parts of a page header if they cross a datablock boundary,
-// without writing state-machiney code to record a partial detection.
-//
-// The number of channels returned are stored in *channels (which can be
-// NULL--it is always the same as the number of channels reported by
-// get_info). *output will contain an array of float* buffers, one per
-// channel. In other words, (*output)[0][0] contains the first sample from
-// the first channel, and (*output)[1][0] contains the first sample from
-// the second channel.
-
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f);
-// inform stb_vorbis that your next datablock will not be contiguous with
-// previous ones (e.g. you've seeked in the data); future attempts to decode
-// frames will cause stb_vorbis to resynchronize (as noted above), and
-// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it
-// will begin decoding the _next_ frame.
-//
-// if you want to seek using pushdata, you need to seek in your file, then
-// call stb_vorbis_flush_pushdata(), then start calling decoding, then once
-// decoding is returning you data, call stb_vorbis_get_sample_offset, and
-// if you don't like the result, seek your file again and repeat.
-#endif
-
-
-//////////   PULLING INPUT API
-
-#ifndef STB_VORBIS_NO_PULLDATA_API
-// This API assumes stb_vorbis is allowed to pull data from a source--
-// either a block of memory containing the _entire_ vorbis stream, or a
-// FILE * that you or it create, or possibly some other reading mechanism
-// if you go modify the source to replace the FILE * case with some kind
-// of callback to your code. (But if you don't support seeking, you may
-// just want to go ahead and use pushdata.)
-
-#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
-#endif
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
-#endif
-// decode an entire file and output the data interleaved into a malloc()ed
-// buffer stored in *output. The return value is the number of samples
-// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
-// When you're done with it, just free() the pointer returned in *output.
-
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from an ogg vorbis stream in memory (note
-// this must be the entire stream!). on failure, returns NULL and sets *error
-
-#ifndef STB_VORBIS_NO_STDIO
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from a filename via fopen(). on failure,
-// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
-
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from an open FILE *, looking for a stream at
-// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
-// note that stb_vorbis must "own" this stream; if you seek it in between
-// calls to stb_vorbis, it will become confused. Morever, if you attempt to
-// perform stb_vorbis_seek_*() operations on this file, it will assume it
-// owns the _entire_ rest of the file after the start point. Use the next
-// function, stb_vorbis_open_file_section(), to limit it.
-
-STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
-                int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len);
-// create an ogg vorbis decoder from an open FILE *, looking for a stream at
-// the _current_ seek point (ftell); the stream will be of length 'len' bytes.
-// on failure, returns NULL and sets *error. note that stb_vorbis must "own"
-// this stream; if you seek it in between calls to stb_vorbis, it will become
-// confused.
-#endif
-
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
-// these functions seek in the Vorbis file to (approximately) 'sample_number'.
-// after calling seek_frame(), the next call to get_frame_*() will include
-// the specified sample. after calling stb_vorbis_seek(), the next call to
-// stb_vorbis_get_samples_* will start with the specified sample. If you
-// do not need to seek to EXACTLY the target sample when using get_samples_*,
-// you can also use seek_frame().
-
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f);
-// this function is equivalent to stb_vorbis_seek(f,0)
-
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
-STBVDEF float        stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
-// these functions return the total length of the vorbis stream
-
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
-// decode the next frame and return the number of samples. the number of
-// channels returned are stored in *channels (which can be NULL--it is always
-// the same as the number of channels reported by get_info). *output will
-// contain an array of float* buffers, one per channel. These outputs will
-// be overwritten on the next call to stb_vorbis_get_frame_*.
-//
-// You generally should not intermix calls to stb_vorbis_get_frame_*()
-// and stb_vorbis_get_samples_*(), since the latter calls the former.
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_frame_short            (stb_vorbis *f, int num_c, short **buffer, int num_samples);
-#endif
-// decode the next frame and return the number of *samples* per channel.
-// Note that for interleaved data, you pass in the number of shorts (the
-// size of your array), but the return value is the number of samples per
-// channel, not the total number of samples.
-//
-// The data is coerced to the number of channels you request according to the
-// channel coercion rules (see below). You must pass in the size of your
-// buffer(s) so that stb_vorbis will not overwrite the end of the buffer.
-// The maximum buffer size needed can be gotten from get_info(); however,
-// the Vorbis I specification implies an absolute maximum of 4096 samples
-// per channel.
-
-// Channel coercion rules:
-//    Let M be the number of channels requested, and N the number of channels present,
-//    and Cn be the nth channel; let stereo L be the sum of all L and center channels,
-//    and stereo R be the sum of all R and center channels (channel assignment from the
-//    vorbis spec).
-//        M    N       output
-//        1    k      sum(Ck) for all k
-//        2    *      stereo L, stereo R
-//        k    l      k > l, the first l channels, then 0s
-//        k    l      k <= l, the first k channels
-//    Note that this is not _good_ surround etc. mixing at all! It's just so
-//    you get something useful.
-
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
-// gets num_samples samples, not necessarily on a frame boundary--this requires
-// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES.
-// Returns the number of samples stored per channel; it may be less than requested
-// at the end of the file. If there are no more samples in the file, returns 0.
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
-#endif
-// gets num_samples samples, not necessarily on a frame boundary--this requires
-// buffering so you have to supply the buffers. Applies the coercion rules above
-// to produce 'channels' channels. Returns the number of samples stored per channel;
-// it may be less than requested at the end of the file. If there are no more
-// samples in the file, returns 0.
-
-#endif
-
-////////   ERROR CODES
-
-enum STBVorbisError
-{
-   VORBIS__no_error,
-
-   VORBIS_need_more_data=1,             // not a real error
-
-   VORBIS_invalid_api_mixing,           // can't mix API modes
-   VORBIS_outofmem,                     // not enough memory
-   VORBIS_feature_not_supported,        // uses floor 0
-   VORBIS_too_many_channels,            // STB_VORBIS_MAX_CHANNELS is too small
-   VORBIS_file_open_failure,            // fopen() failed
-   VORBIS_seek_without_length,          // can't seek in unknown-length file
-
-   VORBIS_unexpected_eof=10,            // file is truncated?
-   VORBIS_seek_invalid,                 // seek past EOF
-
-   // decoding errors (corrupt/invalid stream) -- you probably
-   // don't care about the exact details of these
-
-   // vorbis errors:
-   VORBIS_invalid_setup=20,
-   VORBIS_invalid_stream,
-
-   // ogg errors:
-   VORBIS_missing_capture_pattern=30,
-   VORBIS_invalid_stream_structure_version,
-   VORBIS_continued_packet_flag_invalid,
-   VORBIS_incorrect_stream_serial_number,
-   VORBIS_invalid_first_page,
-   VORBIS_bad_packet_type,
-   VORBIS_cant_find_last_page,
-   VORBIS_seek_failed
-};
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H
-//
-//  HEADER ENDS HERE
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifdef STB_VORBIS_IMPLEMENTATION
-
-// global configuration settings (e.g. set these in the project/makefile),
-// or just set them in this file at the top (although ideally the first few
-// should be visible when the header file is compiled too, although it's not
-// crucial)
-
-// STB_VORBIS_NO_PUSHDATA_API
-//     does not compile the code for the various stb_vorbis_*_pushdata()
-//     functions
-// #define STB_VORBIS_NO_PUSHDATA_API
-
-// STB_VORBIS_NO_PULLDATA_API
-//     does not compile the code for the non-pushdata APIs
-// #define STB_VORBIS_NO_PULLDATA_API
-
-// STB_VORBIS_NO_STDIO
-//     does not compile the code for the APIs that use FILE *s internally
-//     or externally (implied by STB_VORBIS_NO_PULLDATA_API)
-// #define STB_VORBIS_NO_STDIO
-
-// STB_VORBIS_NO_INTEGER_CONVERSION
-//     does not compile the code for converting audio sample data from
-//     float to integer (implied by STB_VORBIS_NO_PULLDATA_API)
-// #define STB_VORBIS_NO_INTEGER_CONVERSION
-
-// STB_VORBIS_NO_FAST_SCALED_FLOAT
-//      does not use a fast float-to-int trick to accelerate float-to-int on
-//      most platforms which requires endianness be defined correctly.
-// #define STB_VORBIS_NO_FAST_SCALED_FLOAT
-
-
-// STB_VORBIS_MAX_CHANNELS [number]
-//     globally define this to the maximum number of channels you need.
-//     The spec does not put a restriction on channels except that
-//     the count is stored in a byte, so 255 is the hard limit.
-//     Reducing this saves about 16 bytes per value, so using 16 saves
-//     (255-16)*16 or around 4KB. Plus anything other memory usage
-//     I forgot to account for. Can probably go as low as 8 (7.1 audio),
-//     6 (5.1 audio), or 2 (stereo only).
-#ifndef STB_VORBIS_MAX_CHANNELS
-#define STB_VORBIS_MAX_CHANNELS    16  // enough for anyone?
-#endif
-
-// STB_VORBIS_PUSHDATA_CRC_COUNT [number]
-//     after a flush_pushdata(), stb_vorbis begins scanning for the
-//     next valid page, without backtracking. when it finds something
-//     that looks like a page, it streams through it and verifies its
-//     CRC32. Should that validation fail, it keeps scanning. But it's
-//     possible that _while_ streaming through to check the CRC32 of
-//     one candidate page, it sees another candidate page. This #define
-//     determines how many "overlapping" candidate pages it can search
-//     at once. Note that "real" pages are typically ~4KB to ~8KB, whereas
-//     garbage pages could be as big as 64KB, but probably average ~16KB.
-//     So don't hose ourselves by scanning an apparent 64KB page and
-//     missing a ton of real ones in the interim; so minimum of 2
-#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT
-#define STB_VORBIS_PUSHDATA_CRC_COUNT  4
-#endif
-
-// STB_VORBIS_FAST_HUFFMAN_LENGTH [number]
-//     sets the log size of the huffman-acceleration table.  Maximum
-//     supported value is 24. with larger numbers, more decodings are O(1),
-//     but the table size is larger so worse cache missing, so you'll have
-//     to probe (and try multiple ogg vorbis files) to find the sweet spot.
-#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH
-#define STB_VORBIS_FAST_HUFFMAN_LENGTH   10
-#endif
-
-// STB_VORBIS_FAST_BINARY_LENGTH [number]
-//     sets the log size of the binary-search acceleration table. this
-//     is used in similar fashion to the fast-huffman size to set initial
-//     parameters for the binary search
-
-// STB_VORBIS_FAST_HUFFMAN_INT
-//     The fast huffman tables are much more efficient if they can be
-//     stored as 16-bit results instead of 32-bit results. This restricts
-//     the codebooks to having only 65535 possible outcomes, though.
-//     (At least, accelerated by the huffman table.)
-#ifndef STB_VORBIS_FAST_HUFFMAN_INT
-#define STB_VORBIS_FAST_HUFFMAN_SHORT
-#endif
-
-// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-//     If the 'fast huffman' search doesn't succeed, then stb_vorbis falls
-//     back on binary searching for the correct one. This requires storing
-//     extra tables with the huffman codes in sorted order. Defining this
-//     symbol trades off space for speed by forcing a linear search in the
-//     non-fast case, except for "sparse" codebooks.
-// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-
-// STB_VORBIS_DIVIDES_IN_RESIDUE
-//     stb_vorbis precomputes the result of the scalar residue decoding
-//     that would otherwise require a divide per chunk. you can trade off
-//     space for time by defining this symbol.
-// #define STB_VORBIS_DIVIDES_IN_RESIDUE
-
-// STB_VORBIS_DIVIDES_IN_CODEBOOK
-//     vorbis VQ codebooks can be encoded two ways: with every case explicitly
-//     stored, or with all elements being chosen from a small range of values,
-//     and all values possible in all elements. By default, stb_vorbis expands
-//     this latter kind out to look like the former kind for ease of decoding,
-//     because otherwise an integer divide-per-vector-element is required to
-//     unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can
-//     trade off storage for speed.
-//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
-
-#ifdef STB_VORBIS_CODEBOOK_SHORTS
-#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
-#endif
-
-// STB_VORBIS_DIVIDE_TABLE
-//     this replaces small integer divides in the floor decode loop with
-//     table lookups. made less than 1% difference, so disabled by default.
-
-// STB_VORBIS_NO_INLINE_DECODE
-//     disables the inlining of the scalar codebook fast-huffman decode.
-//     might save a little codespace; useful for debugging
-// #define STB_VORBIS_NO_INLINE_DECODE
-
-// STB_VORBIS_NO_DEFER_FLOOR
-//     Normally we only decode the floor without synthesizing the actual
-//     full curve. We can instead synthesize the curve immediately. This
-//     requires more memory and is very likely slower, so I don't think
-//     you'd ever want to do it except for debugging.
-// #define STB_VORBIS_NO_DEFER_FLOOR
-
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-#ifdef STB_VORBIS_NO_PULLDATA_API
-   #define STB_VORBIS_NO_INTEGER_CONVERSION
-   #define STB_VORBIS_NO_STDIO
-#endif
-
-#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
-   #define STB_VORBIS_NO_STDIO 1
-#endif
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
-
-   // only need endianness for fast-float-to-int, which we don't
-   // use for pushdata
-
-   #ifndef STB_VORBIS_BIG_ENDIAN
-     #define STB_VORBIS_ENDIAN  0
-   #else
-     #define STB_VORBIS_ENDIAN  1
-   #endif
-
-#endif
-#endif
-
-
-#ifndef STB_VORBIS_NO_STDIO
-#include <stdio.h>
-#endif
-
-#ifndef STB_VORBIS_NO_CRT
-   #include <stdlib.h>
-   #include <string.h>
-   #include <assert.h>
-   #include <math.h>
-
-   // find definition of alloca if it's not in stdlib.h:
-   #if defined(_MSC_VER) || defined(__MINGW32__)
-      #include <malloc.h>
-   #endif
-   #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__)
-      #include <alloca.h>
-   #endif
-#else // STB_VORBIS_NO_CRT
-   #define NULL 0
-   #define malloc(s)   0
-   #define free(s)     ((void) 0)
-   #define realloc(s)  0
-#endif // STB_VORBIS_NO_CRT
-
-#include <limits.h>
-
-#ifdef __MINGW32__
-   // eff you mingw:
-   //     "fixed":
-   //         http://sourceforge.net/p/mingw-w64/mailman/message/32882927/
-   //     "no that broke the build, reverted, who cares about C":
-   //         http://sourceforge.net/p/mingw-w64/mailman/message/32890381/
-   #ifdef __forceinline
-   #undef __forceinline
-   #endif
-   #define __forceinline
-   #ifndef alloca
-   #define alloca(s) __builtin_alloca(s)
-   #endif
-#elif !defined(_MSC_VER)
-   #if __GNUC__
-      #define __forceinline inline
-   #else
-      #define __forceinline
-   #endif
-#endif
-
-#if STB_VORBIS_MAX_CHANNELS > 256
-#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range"
-#endif
-
-#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24
-#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range"
-#endif
-
-
-#if 0
-#include <crtdbg.h>
-#define STBV_CHECK(f)   _CrtIsValidHeapPointer(f->channel_buffers[1])
-#else
-#define STBV_CHECK(f)   ((void) 0)
-#endif
-
-#define STBV_MAX_BLOCKSIZE_LOG  13   // from specification
-#define STBV_MAX_BLOCKSIZE      (1 << STBV_MAX_BLOCKSIZE_LOG)
-
-
-typedef unsigned char  stbv_uint8;
-typedef   signed char  stbv_int8;
-typedef unsigned short stbv_uint16;
-typedef   signed short stbv_int16;
-typedef unsigned int   stbv_uint32;
-typedef   signed int   stbv_int32;
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-typedef float stbv_codetype;
-
-// @NOTE
-//
-// Some arrays below are tagged "//varies", which means it's actually
-// a variable-sized piece of data, but rather than malloc I assume it's
-// small enough it's better to just allocate it all together with the
-// main thing
-//
-// Most of the variables are specified with the smallest size I could pack
-// them into. It might give better performance to make them all full-sized
-// integers. It should be safe to freely rearrange the structures or change
-// the sizes larger--nothing relies on silently truncating etc., nor the
-// order of variables.
-
-#define STBV_FAST_HUFFMAN_TABLE_SIZE   (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
-#define STBV_FAST_HUFFMAN_TABLE_MASK   (STBV_FAST_HUFFMAN_TABLE_SIZE - 1)
-
-typedef struct
-{
-   int dimensions, entries;
-   stbv_uint8 *codeword_lengths;
-   float  minimum_value;
-   float  delta_value;
-   stbv_uint8  value_bits;
-   stbv_uint8  lookup_type;
-   stbv_uint8  sequence_p;
-   stbv_uint8  sparse;
-   stbv_uint32 lookup_values;
-   stbv_codetype *multiplicands;
-   stbv_uint32 *codewords;
-   #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
-    stbv_int16  fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
-   #else
-    stbv_int32  fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
-   #endif
-   stbv_uint32 *sorted_codewords;
-   int    *sorted_values;
-   int     sorted_entries;
-} StbvCodebook;
-
-typedef struct
-{
-   stbv_uint8 order;
-   stbv_uint16 rate;
-   stbv_uint16 bark_map_size;
-   stbv_uint8 amplitude_bits;
-   stbv_uint8 amplitude_offset;
-   stbv_uint8 number_of_books;
-   stbv_uint8 book_list[16]; // varies
-} StbvFloor0;
-
-typedef struct
-{
-   stbv_uint8 partitions;
-   stbv_uint8 partition_class_list[32]; // varies
-   stbv_uint8 class_dimensions[16]; // varies
-   stbv_uint8 class_subclasses[16]; // varies
-   stbv_uint8 class_masterbooks[16]; // varies
-   stbv_int16 subclass_books[16][8]; // varies
-   stbv_uint16 Xlist[31*8+2]; // varies
-   stbv_uint8 sorted_order[31*8+2];
-   stbv_uint8 stbv_neighbors[31*8+2][2];
-   stbv_uint8 floor1_multiplier;
-   stbv_uint8 rangebits;
-   int values;
-} StbvFloor1;
-
-typedef union
-{
-   StbvFloor0 floor0;
-   StbvFloor1 floor1;
-} StbvFloor;
-
-typedef struct
-{
-   stbv_uint32 begin, end;
-   stbv_uint32 part_size;
-   stbv_uint8 classifications;
-   stbv_uint8 classbook;
-   stbv_uint8 **classdata;
-   stbv_int16 (*residue_books)[8];
-} StbvResidue;
-
-typedef struct
-{
-   stbv_uint8 magnitude;
-   stbv_uint8 angle;
-   stbv_uint8 mux;
-} StbvMappingChannel;
-
-typedef struct
-{
-   stbv_uint16 coupling_steps;
-   StbvMappingChannel *chan;
-   stbv_uint8  submaps;
-   stbv_uint8  submap_floor[15]; // varies
-   stbv_uint8  submap_residue[15]; // varies
-} StbvMapping;
-
-typedef struct
-{
-   stbv_uint8 blockflag;
-   stbv_uint8 mapping;
-   stbv_uint16 windowtype;
-   stbv_uint16 transformtype;
-} StbvMode;
-
-typedef struct
-{
-   stbv_uint32  goal_crc;    // expected crc if match
-   int     bytes_left;  // bytes left in packet
-   stbv_uint32  crc_so_far;  // running crc
-   int     bytes_done;  // bytes processed in _current_ chunk
-   stbv_uint32  sample_loc;  // granule pos encoded in page
-} StbvCRCscan;
-
-typedef struct
-{
-   stbv_uint32 page_start, page_end;
-   stbv_uint32 last_decoded_sample;
-} StbvProbedPage;
-
-struct stb_vorbis
-{
-  // user-accessible info
-   unsigned int sample_rate;
-   int channels;
-
-   unsigned int setup_memory_required;
-   unsigned int temp_memory_required;
-   unsigned int setup_temp_memory_required;
-
-  // input config
-#ifndef STB_VORBIS_NO_STDIO
-   FILE *f;
-   stbv_uint32 f_start;
-   int close_on_free;
-#endif
-
-   stbv_uint8 *stream;
-   stbv_uint8 *stream_start;
-   stbv_uint8 *stream_end;
-
-   stbv_uint32 stream_len;
-
-   stbv_uint8  push_mode;
-
-   stbv_uint32 first_audio_page_offset;
-
-   StbvProbedPage p_first, p_last;
-
-  // memory management
-   stb_vorbis_alloc alloc;
-   int setup_offset;
-   int temp_offset;
-
-  // run-time results
-   int eof;
-   enum STBVorbisError error;
-
-  // user-useful data
-
-  // header info
-   int blocksize[2];
-   int blocksize_0, blocksize_1;
-   int codebook_count;
-   StbvCodebook *codebooks;
-   int floor_count;
-   stbv_uint16 floor_types[64]; // varies
-   StbvFloor *floor_config;
-   int residue_count;
-   stbv_uint16 residue_types[64]; // varies
-   StbvResidue *residue_config;
-   int mapping_count;
-   StbvMapping *mapping;
-   int mode_count;
-   StbvMode mode_config[64];  // varies
-
-   stbv_uint32 total_samples;
-
-  // decode buffer
-   float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
-   float *outputs        [STB_VORBIS_MAX_CHANNELS];
-
-   float *previous_window[STB_VORBIS_MAX_CHANNELS];
-   int previous_length;
-
-   #ifndef STB_VORBIS_NO_DEFER_FLOOR
-   stbv_int16 *finalY[STB_VORBIS_MAX_CHANNELS];
-   #else
-   float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
-   #endif
-
-   stbv_uint32 current_loc; // sample location of next frame to decode
-   int    current_loc_valid;
-
-  // per-blocksize precomputed data
-   
-   // twiddle factors
-   float *A[2],*B[2],*C[2];
-   float *window[2];
-   stbv_uint16 *stbv_bit_reverse[2];
-
-  // current page/packet/segment streaming info
-   stbv_uint32 serial; // stream serial number for verification
-   int last_page;
-   int segment_count;
-   stbv_uint8 segments[255];
-   stbv_uint8 page_flag;
-   stbv_uint8 bytes_in_seg;
-   stbv_uint8 first_decode;
-   int next_seg;
-   int last_seg;  // flag that we're on the last segment
-   int last_seg_which; // what was the segment number of the last seg?
-   stbv_uint32 acc;
-   int valid_bits;
-   int packet_bytes;
-   int end_seg_with_known_loc;
-   stbv_uint32 known_loc_for_packet;
-   int discard_samples_deferred;
-   stbv_uint32 samples_output;
-
-  // push mode scanning
-   int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-   StbvCRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
-#endif
-
-  // sample-access
-   int channel_buffer_start;
-   int channel_buffer_end;
-};
-
-#if defined(STB_VORBIS_NO_PUSHDATA_API)
-   #define STBV_IS_PUSH_MODE(f)   FALSE
-#elif defined(STB_VORBIS_NO_PULLDATA_API)
-   #define STBV_IS_PUSH_MODE(f)   TRUE
-#else
-   #define STBV_IS_PUSH_MODE(f)   ((f)->push_mode)
-#endif
-
-typedef struct stb_vorbis stbv_vorb;
-
-static int stbv_error(stbv_vorb *f, enum STBVorbisError e)
-{
-   f->error = e;
-   if (!f->eof && e != VORBIS_need_more_data) {
-      f->error=e; // breakpoint for debugging
-   }
-   return 0;
-}
-
-
-// these functions are used for allocating temporary memory
-// while decoding. if you can afford the stack space, use
-// alloca(); otherwise, provide a temp buffer and it will
-// allocate out of those.
-
-#define stbv_array_size_required(count,size)  (count*(sizeof(void *)+(size)))
-
-#define stbv_temp_alloc(f,size)              (f->alloc.alloc_buffer ? stbv_setup_temp_malloc(f,size) : alloca(size))
-#define stbv_temp_free(f,p)                  0
-#define stbv_temp_alloc_save(f)              ((f)->temp_offset)
-#define stbv_temp_alloc_restore(f,p)         ((f)->temp_offset = (p))
-
-#define stbv_temp_block_array(f,count,size)  stbv_make_block_array(stbv_temp_alloc(f,stbv_array_size_required(count,size)), count, size)
-
-// given a sufficiently large block of memory, make an array of pointers to subblocks of it
-static void *stbv_make_block_array(void *mem, int count, int size)
-{
-   int i;
-   void ** p = (void **) mem;
-   char *q = (char *) (p + count);
-   for (i=0; i < count; ++i) {
-      p[i] = q;
-      q += size;
-   }
-   return p;
-}
-
-static void *stbv_setup_malloc(stbv_vorb *f, int sz)
-{
-   sz = (sz+3) & ~3;
-   f->setup_memory_required += sz;
-   if (f->alloc.alloc_buffer) {
-      void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
-      if (f->setup_offset + sz > f->temp_offset) return NULL;
-      f->setup_offset += sz;
-      return p;
-   }
-   return sz ? malloc(sz) : NULL;
-}
-
-static void stbv_setup_free(stbv_vorb *f, void *p)
-{
-   if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
-   free(p);
-}
-
-static void *stbv_setup_temp_malloc(stbv_vorb *f, int sz)
-{
-   sz = (sz+3) & ~3;
-   if (f->alloc.alloc_buffer) {
-      if (f->temp_offset - sz < f->setup_offset) return NULL;
-      f->temp_offset -= sz;
-      return (char *) f->alloc.alloc_buffer + f->temp_offset;
-   }
-   return malloc(sz);
-}
-
-static void stbv_setup_temp_free(stbv_vorb *f, void *p, int sz)
-{
-   if (f->alloc.alloc_buffer) {
-      f->temp_offset += (sz+3)&~3;
-      return;
-   }
-   free(p);
-}
-
-#define STBV_CRC32_POLY    0x04c11db7   // from spec
-
-static stbv_uint32 stbv_crc_table[256];
-static void stbv_crc32_init(void)
-{
-   int i,j;
-   stbv_uint32 s;
-   for(i=0; i < 256; i++) {
-      for (s=(stbv_uint32) i << 24, j=0; j < 8; ++j)
-         s = (s << 1) ^ (s >= (1U<<31) ? STBV_CRC32_POLY : 0);
-      stbv_crc_table[i] = s;
-   }
-}
-
-static __forceinline stbv_uint32 stbv_crc32_update(stbv_uint32 crc, stbv_uint8 byte)
-{
-   return (crc << 8) ^ stbv_crc_table[byte ^ (crc >> 24)];
-}
-
-
-// used in setup, and for huffman that doesn't go fast path
-static unsigned int stbv_bit_reverse(unsigned int n)
-{
-  n = ((n & 0xAAAAAAAA) >>  1) | ((n & 0x55555555) << 1);
-  n = ((n & 0xCCCCCCCC) >>  2) | ((n & 0x33333333) << 2);
-  n = ((n & 0xF0F0F0F0) >>  4) | ((n & 0x0F0F0F0F) << 4);
-  n = ((n & 0xFF00FF00) >>  8) | ((n & 0x00FF00FF) << 8);
-  return (n >> 16) | (n << 16);
-}
-
-static float stbv_square(float x)
-{
-   return x*x;
-}
-
-// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3
-// as required by the specification. fast(?) implementation from stb.h
-// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup
-static int stbv_ilog(stbv_int32 n)
-{
-   static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
-
-   if (n < 0) return 0; // signed n returns 0
-
-   // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
-   if (n < (1 << 14))
-        if (n < (1 <<  4))            return  0 + log2_4[n      ];
-        else if (n < (1 <<  9))       return  5 + log2_4[n >>  5];
-             else                     return 10 + log2_4[n >> 10];
-   else if (n < (1 << 24))
-             if (n < (1 << 19))       return 15 + log2_4[n >> 15];
-             else                     return 20 + log2_4[n >> 20];
-        else if (n < (1 << 29))       return 25 + log2_4[n >> 25];
-             else                     return 30 + log2_4[n >> 30];
-}
-
-#ifndef M_PI
-  #define M_PI  3.14159265358979323846264f  // from CRC
-#endif
-
-// code length assigned to a value with no huffman encoding
-#define NO_CODE   255
-
-/////////////////////// LEAF SETUP FUNCTIONS //////////////////////////
-//
-// these functions are only called at setup, and only a few times
-// per file
-
-static float stbv_float32_unpack(stbv_uint32 x)
-{
-   // from the specification
-   stbv_uint32 mantissa = x & 0x1fffff;
-   stbv_uint32 sign = x & 0x80000000;
-   stbv_uint32 exp = (x & 0x7fe00000) >> 21;
-   double res = sign ? -(double)mantissa : (double)mantissa;
-   return (float) ldexp((float)res, exp-788);
-}
-
-
-// zlib & jpeg huffman tables assume that the output symbols
-// can either be arbitrarily arranged, or have monotonically
-// increasing frequencies--they rely on the lengths being sorted;
-// this makes for a very simple generation algorithm.
-// vorbis allows a huffman table with non-sorted lengths. This
-// requires a more sophisticated construction, since symbols in
-// order do not map to huffman codes "in order".
-static void stbv_add_entry(StbvCodebook *c, stbv_uint32 huff_code, int symbol, int count, int len, stbv_uint32 *values)
-{
-   if (!c->sparse) {
-      c->codewords      [symbol] = huff_code;
-   } else {
-      c->codewords       [count] = huff_code;
-      c->codeword_lengths[count] = len;
-      values             [count] = symbol;
-   }
-}
-
-static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_uint32 *values)
-{
-   int i,k,m=0;
-   stbv_uint32 available[32];
-
-   memset(available, 0, sizeof(available));
-   // find the first entry
-   for (k=0; k < n; ++k) if (len[k] < NO_CODE) break;
-   if (k == n) { assert(c->sorted_entries == 0); return TRUE; }
-   // add to the list
-   stbv_add_entry(c, 0, k, m++, len[k], values);
-   // add all available leaves
-   for (i=1; i <= len[k]; ++i)
-      available[i] = 1U << (32-i);
-   // note that the above code treats the first case specially,
-   // but it's really the same as the following code, so they
-   // could probably be combined (except the initial code is 0,
-   // and I use 0 in available[] to mean 'empty')
-   for (i=k+1; i < n; ++i) {
-      stbv_uint32 res;
-      int z = len[i], y;
-      if (z == NO_CODE) continue;
-      // find lowest available leaf (should always be earliest,
-      // which is what the specification calls for)
-      // note that this property, and the fact we can never have
-      // more than one free leaf at a given level, isn't totally
-      // trivial to prove, but it seems true and the assert never
-      // fires, so!
-      while (z > 0 && !available[z]) --z;
-      if (z == 0) { return FALSE; }
-      res = available[z];
-      assert(z >= 0 && z < 32);
-      available[z] = 0;
-      stbv_add_entry(c, stbv_bit_reverse(res), i, m++, len[i], values);
-      // propogate availability up the tree
-      if (z != len[i]) {
-         assert(len[i] >= 0 && len[i] < 32);
-         for (y=len[i]; y > z; --y) {
-            assert(available[y] == 0);
-            available[y] = res + (1 << (32-y));
-         }
-      }
-   }
-   return TRUE;
-}
-
-// accelerated huffman table allows fast O(1) match of all symbols
-// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
-static void stbv_compute_accelerated_huffman(StbvCodebook *c)
-{
-   int i, len;
-   for (i=0; i < STBV_FAST_HUFFMAN_TABLE_SIZE; ++i)
-      c->fast_huffman[i] = -1;
-
-   len = c->sparse ? c->sorted_entries : c->entries;
-   #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
-   if (len > 32767) len = 32767; // largest possible value we can encode!
-   #endif
-   for (i=0; i < len; ++i) {
-      if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
-         stbv_uint32 z = c->sparse ? stbv_bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
-         // set table entries for all bit combinations in the higher bits
-         while (z < STBV_FAST_HUFFMAN_TABLE_SIZE) {
-             c->fast_huffman[z] = i;
-             z += 1 << c->codeword_lengths[i];
-         }
-      }
-   }
-}
-
-#ifdef _MSC_VER
-#define STBV_CDECL __cdecl
-#else
-#define STBV_CDECL
-#endif
-
-static int STBV_CDECL stbv_uint32_compare(const void *p, const void *q)
-{
-   stbv_uint32 x = * (stbv_uint32 *) p;
-   stbv_uint32 y = * (stbv_uint32 *) q;
-   return x < y ? -1 : x > y;
-}
-
-static int stbv_include_in_sort(StbvCodebook *c, stbv_uint8 len)
-{
-   if (c->sparse) { assert(len != NO_CODE); return TRUE; }
-   if (len == NO_CODE) return FALSE;
-   if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE;
-   return FALSE;
-}
-
-// if the fast table above doesn't work, we want to binary
-// search them... need to reverse the bits
-static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, stbv_uint32 *values)
-{
-   int i, len;
-   // build a list of all the entries
-   // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN.
-   // this is kind of a frivolous optimization--I don't see any performance improvement,
-   // but it's like 4 extra lines of code, so.
-   if (!c->sparse) {
-      int k = 0;
-      for (i=0; i < c->entries; ++i)
-         if (stbv_include_in_sort(c, lengths[i])) 
-            c->sorted_codewords[k++] = stbv_bit_reverse(c->codewords[i]);
-      assert(k == c->sorted_entries);
-   } else {
-      for (i=0; i < c->sorted_entries; ++i)
-         c->sorted_codewords[i] = stbv_bit_reverse(c->codewords[i]);
-   }
-
-   qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), stbv_uint32_compare);
-   c->sorted_codewords[c->sorted_entries] = 0xffffffff;
-
-   len = c->sparse ? c->sorted_entries : c->entries;
-   // now we need to indicate how they correspond; we could either
-   //   #1: sort a different data structure that says who they correspond to
-   //   #2: for each sorted entry, search the original list to find who corresponds
-   //   #3: for each original entry, find the sorted entry
-   // #1 requires extra storage, #2 is slow, #3 can use binary search!
-   for (i=0; i < len; ++i) {
-      int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
-      if (stbv_include_in_sort(c,huff_len)) {
-         stbv_uint32 code = stbv_bit_reverse(c->codewords[i]);
-         int x=0, n=c->sorted_entries;
-         while (n > 1) {
-            // invariant: sc[x] <= code < sc[x+n]
-            int m = x + (n >> 1);
-            if (c->sorted_codewords[m] <= code) {
-               x = m;
-               n -= (n>>1);
-            } else {
-               n >>= 1;
-            }
-         }
-         assert(c->sorted_codewords[x] == code);
-         if (c->sparse) {
-            c->sorted_values[x] = values[i];
-            c->codeword_lengths[x] = huff_len;
-         } else {
-            c->sorted_values[x] = i;
-         }
-      }
-   }
-}
-
-// only run while parsing the header (3 times)
-static int stbv_vorbis_validate(stbv_uint8 *data)
-{
-   static stbv_uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
-   return memcmp(data, vorbis, 6) == 0;
-}
-
-// called from setup only, once per code book
-// (formula implied by specification)
-static int stbv_lookup1_values(int entries, int dim)
-{
-   int r = (int) floor(exp((float) log((float) entries) / dim));
-   if ((int) floor(pow((float) r+1, dim)) <= entries)   // (int) cast for MinGW warning;
-      ++r;                                              // floor() to avoid _ftol() when non-CRT
-   assert(pow((float) r+1, dim) > entries);
-   assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above
-   return r;
-}
-
-// called twice per file
-static void stbv_compute_twiddle_factors(int n, float *A, float *B, float *C)
-{
-   int n4 = n >> 2, n8 = n >> 3;
-   int k,k2;
-
-   for (k=k2=0; k < n4; ++k,k2+=2) {
-      A[k2  ] = (float)  cos(4*k*M_PI/n);
-      A[k2+1] = (float) -sin(4*k*M_PI/n);
-      B[k2  ] = (float)  cos((k2+1)*M_PI/n/2) * 0.5f;
-      B[k2+1] = (float)  sin((k2+1)*M_PI/n/2) * 0.5f;
-   }
-   for (k=k2=0; k < n8; ++k,k2+=2) {
-      C[k2  ] = (float)  cos(2*(k2+1)*M_PI/n);
-      C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
-   }
-}
-
-static void stbv_compute_window(int n, float *window)
-{
-   int n2 = n >> 1, i;
-   for (i=0; i < n2; ++i)
-      window[i] = (float) sin(0.5 * M_PI * stbv_square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
-}
-
-static void stbv_compute_bitreverse(int n, stbv_uint16 *rev)
-{
-   int ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-   int i, n8 = n >> 3;
-   for (i=0; i < n8; ++i)
-      rev[i] = (stbv_bit_reverse(i) >> (32-ld+3)) << 2;
-}
-
-static int stbv_init_blocksize(stbv_vorb *f, int b, int n)
-{
-   int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
-   f->A[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   f->B[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   f->C[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n4);
-   if (!f->A[b] || !f->B[b] || !f->C[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
-   f->window[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   if (!f->window[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_window(n, f->window[b]);
-   f->stbv_bit_reverse[b] = (stbv_uint16 *) stbv_setup_malloc(f, sizeof(stbv_uint16) * n8);
-   if (!f->stbv_bit_reverse[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_bitreverse(n, f->stbv_bit_reverse[b]);
-   return TRUE;
-}
-
-static void stbv_neighbors(stbv_uint16 *x, int n, int *plow, int *phigh)
-{
-   int low = -1;
-   int high = 65536;
-   int i;
-   for (i=0; i < n; ++i) {
-      if (x[i] > low  && x[i] < x[n]) { *plow  = i; low = x[i]; }
-      if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; }
-   }
-}
-
-// this has been repurposed so y is now the original index instead of y
-typedef struct
-{
-   stbv_uint16 x,id;
-} stbv_floor_ordering;
-
-static int STBV_CDECL stbv_point_compare(const void *p, const void *q)
-{
-   stbv_floor_ordering *a = (stbv_floor_ordering *) p;
-   stbv_floor_ordering *b = (stbv_floor_ordering *) q;
-   return a->x < b->x ? -1 : a->x > b->x;
-}
-
-//
-/////////////////////// END LEAF SETUP FUNCTIONS //////////////////////////
-
-
-#if defined(STB_VORBIS_NO_STDIO)
-   #define STBV_USE_MEMORY(z)    TRUE
-#else
-   #define STBV_USE_MEMORY(z)    ((z)->stream)
-#endif
-
-static stbv_uint8 stbv_get8(stbv_vorb *z)
-{
-   if (STBV_USE_MEMORY(z)) {
-      if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
-      return *z->stream++;
-   }
-
-   #ifndef STB_VORBIS_NO_STDIO
-   {
-   int c = fgetc(z->f);
-   if (c == EOF) { z->eof = TRUE; return 0; }
-   return c;
-   }
-   #endif
-}
-
-static stbv_uint32 stbv_get32(stbv_vorb *f)
-{
-   stbv_uint32 x;
-   x = stbv_get8(f);
-   x += stbv_get8(f) << 8;
-   x += stbv_get8(f) << 16;
-   x += (stbv_uint32) stbv_get8(f) << 24;
-   return x;
-}
-
-static int stbv_getn(stbv_vorb *z, stbv_uint8 *data, int n)
-{
-   if (STBV_USE_MEMORY(z)) {
-      if (z->stream+n > z->stream_end) { z->eof = 1; return 0; }
-      memcpy(data, z->stream, n);
-      z->stream += n;
-      return 1;
-   }
-
-   #ifndef STB_VORBIS_NO_STDIO   
-   if (fread(data, n, 1, z->f) == 1)
-      return 1;
-   else {
-      z->eof = 1;
-      return 0;
-   }
-   #endif
-}
-
-static void stbv_skip(stbv_vorb *z, int n)
-{
-   if (STBV_USE_MEMORY(z)) {
-      z->stream += n;
-      if (z->stream >= z->stream_end) z->eof = 1;
-      return;
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   {
-      long x = ftell(z->f);
-      fseek(z->f, x+n, SEEK_SET);
-   }
-   #endif
-}
-
-static int stbv_set_file_offset(stb_vorbis *f, unsigned int loc)
-{
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (f->push_mode) return 0;
-   #endif
-   f->eof = 0;
-   if (STBV_USE_MEMORY(f)) {
-      if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
-         f->stream = f->stream_end;
-         f->eof = 1;
-         return 0;
-      } else {
-         f->stream = f->stream_start + loc;
-         return 1;
-      }
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   if (loc + f->f_start < loc || loc >= 0x80000000) {
-      loc = 0x7fffffff;
-      f->eof = 1;
-   } else {
-      loc += f->f_start;
-   }
-   if (!fseek(f->f, loc, SEEK_SET))
-      return 1;
-   f->eof = 1;
-   fseek(f->f, f->f_start, SEEK_END);
-   return 0;
-   #endif
-}
-
-
-static stbv_uint8 stbv_ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
-
-static int stbv_capture_pattern(stbv_vorb *f)
-{
-   if (0x4f != stbv_get8(f)) return FALSE;
-   if (0x67 != stbv_get8(f)) return FALSE;
-   if (0x67 != stbv_get8(f)) return FALSE;
-   if (0x53 != stbv_get8(f)) return FALSE;
-   return TRUE;
-}
-
-#define STBV_PAGEFLAG_continued_packet   1
-#define STBV_PAGEFLAG_first_page         2
-#define STBV_PAGEFLAG_last_page          4
-
-static int stbv_start_page_no_capturepattern(stbv_vorb *f)
-{
-   stbv_uint32 loc0,loc1,n;
-   // stream structure version
-   if (0 != stbv_get8(f)) return stbv_error(f, VORBIS_invalid_stream_structure_version);
-   // header flag
-   f->page_flag = stbv_get8(f);
-   // absolute granule position
-   loc0 = stbv_get32(f); 
-   loc1 = stbv_get32(f);
-   // @TODO: validate loc0,loc1 as valid positions?
-   // stream serial number -- vorbis doesn't interleave, so discard
-   stbv_get32(f);
-   //if (f->serial != stbv_get32(f)) return stbv_error(f, VORBIS_incorrect_stream_serial_number);
-   // page sequence number
-   n = stbv_get32(f);
-   f->last_page = n;
-   // CRC32
-   stbv_get32(f);
-   // page_segments
-   f->segment_count = stbv_get8(f);
-   if (!stbv_getn(f, f->segments, f->segment_count))
-      return stbv_error(f, VORBIS_unexpected_eof);
-   // assume we _don't_ know any the sample position of any segments
-   f->end_seg_with_known_loc = -2;
-   if (loc0 != ~0U || loc1 != ~0U) {
-      int i;
-      // determine which packet is the last one that will complete
-      for (i=f->segment_count-1; i >= 0; --i)
-         if (f->segments[i] < 255)
-            break;
-      // 'i' is now the index of the _last_ segment of a packet that ends
-      if (i >= 0) {
-         f->end_seg_with_known_loc = i;
-         f->known_loc_for_packet   = loc0;
-      }
-   }
-   if (f->first_decode) {
-      int i,len;
-      StbvProbedPage p;
-      len = 0;
-      for (i=0; i < f->segment_count; ++i)
-         len += f->segments[i];
-      len += 27 + f->segment_count;
-      p.page_start = f->first_audio_page_offset;
-      p.page_end = p.page_start + len;
-      p.last_decoded_sample = loc0;
-      f->p_first = p;
-   }
-   f->next_seg = 0;
-   return TRUE;
-}
-
-static int stbv_start_page(stbv_vorb *f)
-{
-   if (!stbv_capture_pattern(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-   return stbv_start_page_no_capturepattern(f);
-}
-
-static int stbv_start_packet(stbv_vorb *f)
-{
-   while (f->next_seg == -1) {
-      if (!stbv_start_page(f)) return FALSE;
-      if (f->page_flag & STBV_PAGEFLAG_continued_packet)
-         return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-   }
-   f->last_seg = FALSE;
-   f->valid_bits = 0;
-   f->packet_bytes = 0;
-   f->bytes_in_seg = 0;
-   // f->next_seg is now valid
-   return TRUE;
-}
-
-static int stbv_maybe_start_packet(stbv_vorb *f)
-{
-   if (f->next_seg == -1) {
-      int x = stbv_get8(f);
-      if (f->eof) return FALSE; // EOF at page boundary is not an error!
-      if (0x4f != x      ) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x53 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (!stbv_start_page_no_capturepattern(f)) return FALSE;
-      if (f->page_flag & STBV_PAGEFLAG_continued_packet) {
-         // set up enough state that we can read this packet if we want,
-         // e.g. during recovery
-         f->last_seg = FALSE;
-         f->bytes_in_seg = 0;
-         return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-      }
-   }
-   return stbv_start_packet(f);
-}
-
-static int stbv_next_segment(stbv_vorb *f)
-{
-   int len;
-   if (f->last_seg) return 0;
-   if (f->next_seg == -1) {
-      f->last_seg_which = f->segment_count-1; // in case stbv_start_page fails
-      if (!stbv_start_page(f)) { f->last_seg = 1; return 0; }
-      if (!(f->page_flag & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-   }
-   len = f->segments[f->next_seg++];
-   if (len < 255) {
-      f->last_seg = TRUE;
-      f->last_seg_which = f->next_seg-1;
-   }
-   if (f->next_seg >= f->segment_count)
-      f->next_seg = -1;
-   assert(f->bytes_in_seg == 0);
-   f->bytes_in_seg = len;
-   return len;
-}
-
-#define STBV_EOP    (-1)
-#define STBV_INVALID_BITS  (-1)
-
-static int stbv_get8_packet_raw(stbv_vorb *f)
-{
-   if (!f->bytes_in_seg) {  // CLANG!
-      if (f->last_seg) return STBV_EOP;
-      else if (!stbv_next_segment(f)) return STBV_EOP;
-   }
-   assert(f->bytes_in_seg > 0);
-   --f->bytes_in_seg;
-   ++f->packet_bytes;
-   return stbv_get8(f);
-}
-
-static int stbv_get8_packet(stbv_vorb *f)
-{
-   int x = stbv_get8_packet_raw(f);
-   f->valid_bits = 0;
-   return x;
-}
-
-static void stbv_flush_packet(stbv_vorb *f)
-{
-   while (stbv_get8_packet_raw(f) != STBV_EOP);
-}
-
-// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important
-// as the huffman decoder?
-static stbv_uint32 stbv_get_bits(stbv_vorb *f, int n)
-{
-   stbv_uint32 z;
-
-   if (f->valid_bits < 0) return 0;
-   if (f->valid_bits < n) {
-      if (n > 24) {
-         // the accumulator technique below would not work correctly in this case
-         z = stbv_get_bits(f, 24);
-         z += stbv_get_bits(f, n-24) << 24;
-         return z;
-      }
-      if (f->valid_bits == 0) f->acc = 0;
-      while (f->valid_bits < n) {
-         int z = stbv_get8_packet_raw(f);
-         if (z == STBV_EOP) {
-            f->valid_bits = STBV_INVALID_BITS;
-            return 0;
-         }
-         f->acc += z << f->valid_bits;
-         f->valid_bits += 8;
-      }
-   }
-   if (f->valid_bits < 0) return 0;
-   z = f->acc & ((1 << n)-1);
-   f->acc >>= n;
-   f->valid_bits -= n;
-   return z;
-}
-
-// @OPTIMIZE: primary accumulator for huffman
-// expand the buffer to as many bits as possible without reading off end of packet
-// it might be nice to allow f->valid_bits and f->acc to be stored in registers,
-// e.g. cache them locally and decode locally
-static __forceinline void stbv_prep_huffman(stbv_vorb *f)
-{
-   if (f->valid_bits <= 24) {
-      if (f->valid_bits == 0) f->acc = 0;
-      do {
-         int z;
-         if (f->last_seg && !f->bytes_in_seg) return;
-         z = stbv_get8_packet_raw(f);
-         if (z == STBV_EOP) return;
-         f->acc += (unsigned) z << f->valid_bits;
-         f->valid_bits += 8;
-      } while (f->valid_bits <= 24);
-   }
-}
-
-enum
-{
-   STBV_VORBIS_packet_id = 1,
-   STBV_VORBIS_packet_comment = 3,
-   STBV_VORBIS_packet_setup = 5
-};
-
-static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
-{
-   int i;
-   stbv_prep_huffman(f);
-
-   if (c->codewords == NULL && c->sorted_codewords == NULL)
-      return -1;
-
-   // cases to use binary search: sorted_codewords && !c->codewords
-   //                             sorted_codewords && c->entries > 8
-   if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
-      // binary search
-      stbv_uint32 code = stbv_bit_reverse(f->acc);
-      int x=0, n=c->sorted_entries, len;
-
-      while (n > 1) {
-         // invariant: sc[x] <= code < sc[x+n]
-         int m = x + (n >> 1);
-         if (c->sorted_codewords[m] <= code) {
-            x = m;
-            n -= (n>>1);
-         } else {
-            n >>= 1;
-         }
-      }
-      // x is now the sorted index
-      if (!c->sparse) x = c->sorted_values[x];
-      // x is now sorted index if sparse, or symbol otherwise
-      len = c->codeword_lengths[x];
-      if (f->valid_bits >= len) {
-         f->acc >>= len;
-         f->valid_bits -= len;
-         return x;
-      }
-
-      f->valid_bits = 0;
-      return -1;
-   }
-
-   // if small, linear search
-   assert(!c->sparse);
-   for (i=0; i < c->entries; ++i) {
-      if (c->codeword_lengths[i] == NO_CODE) continue;
-      if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) {
-         if (f->valid_bits >= c->codeword_lengths[i]) {
-            f->acc >>= c->codeword_lengths[i];
-            f->valid_bits -= c->codeword_lengths[i];
-            return i;
-         }
-         f->valid_bits = 0;
-         return -1;
-      }
-   }
-
-   stbv_error(f, VORBIS_invalid_stream);
-   f->valid_bits = 0;
-   return -1;
-}
-
-#ifndef STB_VORBIS_NO_INLINE_DECODE
-
-#define STBV_DECODE_RAW(var, f,c)                                  \
-   if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)        \
-      stbv_prep_huffman(f);                                        \
-   var = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK;                    \
-   var = c->fast_huffman[var];                                \
-   if (var >= 0) {                                            \
-      int n = c->codeword_lengths[var];                       \
-      f->acc >>= n;                                           \
-      f->valid_bits -= n;                                     \
-      if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
-   } else {                                                   \
-      var = stbv_codebook_decode_scalar_raw(f,c);                  \
-   }
-
-#else
-
-static int stbv_codebook_decode_scalar(stbv_vorb *f, StbvCodebook *c)
-{
-   int i;
-   if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
-      stbv_prep_huffman(f);
-   // fast huffman table lookup
-   i = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK;
-   i = c->fast_huffman[i];
-   if (i >= 0) {
-      f->acc >>= c->codeword_lengths[i];
-      f->valid_bits -= c->codeword_lengths[i];
-      if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
-      return i;
-   }
-   return stbv_codebook_decode_scalar_raw(f,c);
-}
-
-#define STBV_DECODE_RAW(var,f,c)    var = stbv_codebook_decode_scalar(f,c);
-
-#endif
-
-#define STBV_DECODE(var,f,c)                                       \
-   STBV_DECODE_RAW(var,f,c)                                        \
-   if (c->sparse) var = c->sorted_values[var];
-
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-  #define DECODE_VQ(var,f,c)   STBV_DECODE_RAW(var,f,c)
-#else
-  #define DECODE_VQ(var,f,c)   STBV_DECODE(var,f,c)
-#endif
-
-
-
-
-
-
-// STBV_CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
-// where we avoid one addition
-#define STBV_CODEBOOK_ELEMENT(c,off)          (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_FAST(c,off)     (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_BASE(c)         (0)
-
-static int stbv_codebook_decode_start(stbv_vorb *f, StbvCodebook *c)
-{
-   int z = -1;
-
-   // type 0 is only legal in a scalar context
-   if (c->lookup_type == 0)
-      stbv_error(f, VORBIS_invalid_stream);
-   else {
-      DECODE_VQ(z,f,c);
-      if (c->sparse) assert(z < c->sorted_entries);
-      if (z < 0) {  // check for STBV_EOP
-         if (!f->bytes_in_seg)
-            if (f->last_seg)
-               return z;
-         stbv_error(f, VORBIS_invalid_stream);
-      }
-   }
-   return z;
-}
-
-static int stbv_codebook_decode(stbv_vorb *f, StbvCodebook *c, float *output, int len)
-{
-   int i,z = stbv_codebook_decode_start(f,c);
-   if (z < 0) return FALSE;
-   if (len > c->dimensions) len = c->dimensions;
-
-#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-   if (c->lookup_type == 1) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      int div = 1;
-      for (i=0; i < len; ++i) {
-         int off = (z / div) % c->lookup_values;
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-         output[i] += val;
-         if (c->sequence_p) last = val + c->minimum_value;
-         div *= c->lookup_values;
-      }
-      return TRUE;
-   }
-#endif
-
-   z *= c->dimensions;
-   if (c->sequence_p) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      for (i=0; i < len; ++i) {
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-         output[i] += val;
-         last = val + c->minimum_value;
-      }
-   } else {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      for (i=0; i < len; ++i) {
-         output[i] += STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-      }
-   }
-
-   return TRUE;
-}
-
-static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *output, int len, int step)
-{
-   int i,z = stbv_codebook_decode_start(f,c);
-   float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-   if (z < 0) return FALSE;
-   if (len > c->dimensions) len = c->dimensions;
-
-#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-   if (c->lookup_type == 1) {
-      int div = 1;
-      for (i=0; i < len; ++i) {
-         int off = (z / div) % c->lookup_values;
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-         output[i*step] += val;
-         if (c->sequence_p) last = val;
-         div *= c->lookup_values;
-      }
-      return TRUE;
-   }
-#endif
-
-   z *= c->dimensions;
-   for (i=0; i < len; ++i) {
-      float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-      output[i*step] += val;
-      if (c->sequence_p) last = val;
-   }
-
-   return TRUE;
-}
-
-static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
-{
-   int c_inter = *c_inter_p;
-   int p_inter = *p_inter_p;
-   int i,z, effective = c->dimensions;
-
-   // type 0 is only legal in a scalar context
-   if (c->lookup_type == 0)   return stbv_error(f, VORBIS_invalid_stream);
-
-   while (total_decode > 0) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      DECODE_VQ(z,f,c);
-      #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-      assert(!c->sparse || z < c->sorted_entries);
-      #endif
-      if (z < 0) {
-         if (!f->bytes_in_seg)
-            if (f->last_seg) return FALSE;
-         return stbv_error(f, VORBIS_invalid_stream);
-      }
-
-      // if this will take us off the end of the buffers, stop short!
-      // we check by computing the length of the virtual interleaved
-      // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
-      // and the length we'll be using (effective)
-      if (c_inter + p_inter*ch + effective > len * ch) {
-         effective = len*ch - (p_inter*ch - c_inter);
-      }
-
-   #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-      if (c->lookup_type == 1) {
-         int div = 1;
-         for (i=0; i < effective; ++i) {
-            int off = (z / div) % c->lookup_values;
-            float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-            if (outputs[c_inter])
-               outputs[c_inter][p_inter] += val;
-            if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-            if (c->sequence_p) last = val;
-            div *= c->lookup_values;
-         }
-      } else
-   #endif
-      {
-         z *= c->dimensions;
-         if (c->sequence_p) {
-            for (i=0; i < effective; ++i) {
-               float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-               if (outputs[c_inter])
-                  outputs[c_inter][p_inter] += val;
-               if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-               last = val;
-            }
-         } else {
-            for (i=0; i < effective; ++i) {
-               float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-               if (outputs[c_inter])
-                  outputs[c_inter][p_inter] += val;
-               if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-            }
-         }
-      }
-
-      total_decode -= effective;
-   }
-   *c_inter_p = c_inter;
-   *p_inter_p = p_inter;
-   return TRUE;
-}
-
-static int stbv_predict_point(int x, int x0, int x1, int y0, int y1)
-{
-   int dy = y1 - y0;
-   int adx = x1 - x0;
-   // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86?
-   int err = abs(dy) * (x - x0);
-   int off = err / adx;
-   return dy < 0 ? y0 - off : y0 + off;
-}
-
-// the following table is block-copied from the specification
-static float stbv_inverse_db_table[256] =
-{
-  1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, 
-  1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, 
-  1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, 
-  2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, 
-  2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, 
-  3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, 
-  4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, 
-  6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, 
-  7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, 
-  1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, 
-  1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, 
-  1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, 
-  2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, 
-  2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, 
-  3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, 
-  4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, 
-  5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, 
-  7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, 
-  9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, 
-  1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, 
-  1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, 
-  2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, 
-  2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, 
-  3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, 
-  4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, 
-  5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, 
-  7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, 
-  9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, 
-  0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, 
-  0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, 
-  0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, 
-  0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, 
-  0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, 
-  0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, 
-  0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, 
-  0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, 
-  0.00092223983f, 0.00098217216f, 0.0010459992f,  0.0011139742f, 
-  0.0011863665f,  0.0012634633f,  0.0013455702f,  0.0014330129f, 
-  0.0015261382f,  0.0016253153f,  0.0017309374f,  0.0018434235f, 
-  0.0019632195f,  0.0020908006f,  0.0022266726f,  0.0023713743f, 
-  0.0025254795f,  0.0026895994f,  0.0028643847f,  0.0030505286f, 
-  0.0032487691f,  0.0034598925f,  0.0036847358f,  0.0039241906f, 
-  0.0041792066f,  0.0044507950f,  0.0047400328f,  0.0050480668f, 
-  0.0053761186f,  0.0057254891f,  0.0060975636f,  0.0064938176f, 
-  0.0069158225f,  0.0073652516f,  0.0078438871f,  0.0083536271f, 
-  0.0088964928f,  0.009474637f,   0.010090352f,   0.010746080f, 
-  0.011444421f,   0.012188144f,   0.012980198f,   0.013823725f, 
-  0.014722068f,   0.015678791f,   0.016697687f,   0.017782797f, 
-  0.018938423f,   0.020169149f,   0.021479854f,   0.022875735f, 
-  0.024362330f,   0.025945531f,   0.027631618f,   0.029427276f, 
-  0.031339626f,   0.033376252f,   0.035545228f,   0.037855157f, 
-  0.040315199f,   0.042935108f,   0.045725273f,   0.048696758f, 
-  0.051861348f,   0.055231591f,   0.058820850f,   0.062643361f, 
-  0.066714279f,   0.071049749f,   0.075666962f,   0.080584227f, 
-  0.085821044f,   0.091398179f,   0.097337747f,   0.10366330f, 
-  0.11039993f,    0.11757434f,    0.12521498f,    0.13335215f, 
-  0.14201813f,    0.15124727f,    0.16107617f,    0.17154380f, 
-  0.18269168f,    0.19456402f,    0.20720788f,    0.22067342f, 
-  0.23501402f,    0.25028656f,    0.26655159f,    0.28387361f, 
-  0.30232132f,    0.32196786f,    0.34289114f,    0.36517414f, 
-  0.38890521f,    0.41417847f,    0.44109412f,    0.46975890f, 
-  0.50028648f,    0.53279791f,    0.56742212f,    0.60429640f, 
-  0.64356699f,    0.68538959f,    0.72993007f,    0.77736504f, 
-  0.82788260f,    0.88168307f,    0.9389798f,     1.0f
-};
-
-
-// @OPTIMIZE: if you want to replace this bresenham line-drawing routine,
-// note that you must produce bit-identical output to decode correctly;
-// this specific sequence of operations is specified in the spec (it's
-// drawing integer-quantized frequency-space lines that the encoder
-// expects to be exactly the same)
-//     ... also, isn't the whole point of Bresenham's algorithm to NOT
-// have to divide in the setup? sigh.
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-#define STBV_LINE_OP(a,b)   a *= b
-#else
-#define STBV_LINE_OP(a,b)   a = b
-#endif
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-#define STBV_DIVTAB_NUMER   32
-#define STBV_DIVTAB_DENOM   64
-stbv_int8 stbv_integer_divide_table[STBV_DIVTAB_NUMER][STBV_DIVTAB_DENOM]; // 2KB
-#endif
-
-static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1, int y1, int n)
-{
-   int dy = y1 - y0;
-   int adx = x1 - x0;
-   int ady = abs(dy);
-   int base;
-   int x=x0,y=y0;
-   int err = 0;
-   int sy;
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-   if (adx < STBV_DIVTAB_DENOM && ady < STBV_DIVTAB_NUMER) {
-      if (dy < 0) {
-         base = -stbv_integer_divide_table[ady][adx];
-         sy = base-1;
-      } else {
-         base =  stbv_integer_divide_table[ady][adx];
-         sy = base+1;
-      }
-   } else {
-      base = dy / adx;
-      if (dy < 0)
-         sy = base - 1;
-      else
-         sy = base+1;
-   }
-#else
-   base = dy / adx;
-   if (dy < 0)
-      sy = base - 1;
-   else
-      sy = base+1;
-#endif
-   ady -= abs(base) * adx;
-   if (x1 > n) x1 = n;
-   if (x < x1) {
-      STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
-      for (++x; x < x1; ++x) {
-         err += ady;
-         if (err >= adx) {
-            err -= adx;
-            y += sy;
-         } else
-            y += base;
-         STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
-      }
-   }
-}
-
-static int stbv_residue_decode(stbv_vorb *f, StbvCodebook *book, float *target, int offset, int n, int rtype)
-{
-   int k;
-   if (rtype == 0) {
-      int step = n / book->dimensions;
-      for (k=0; k < step; ++k)
-         if (!stbv_codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
-            return FALSE;
-   } else {
-      for (k=0; k < n; ) {
-         if (!stbv_codebook_decode(f, book, target+offset, n-k))
-            return FALSE;
-         k += book->dimensions;
-         offset += book->dimensions;
-      }
-   }
-   return TRUE;
-}
-
-// n is 1/2 of the blocksize --
-// specification: "Correct per-vector decode length is [n]/2"
-static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch, int n, int rn, stbv_uint8 *do_not_decode)
-{
-   int i,j,pass;
-   StbvResidue *r = f->residue_config + rn;
-   int rtype = f->residue_types[rn];
-   int c = r->classbook;
-   int classwords = f->codebooks[c].dimensions;
-   unsigned int actual_size = rtype == 2 ? n*2 : n;
-   unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size);
-   unsigned int limit_r_end   = (r->end   < actual_size ? r->end   : actual_size);
-   int n_read = limit_r_end - limit_r_begin;
-   int part_read = n_read / r->part_size;
-   int temp_alloc_point = stbv_temp_alloc_save(f);
-   #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-   stbv_uint8 ***part_classdata = (stbv_uint8 ***) stbv_temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
-   #else
-   int **classifications = (int **) stbv_temp_block_array(f,f->channels, part_read * sizeof(**classifications));
-   #endif
-
-   STBV_CHECK(f);
-
-   for (i=0; i < ch; ++i)
-      if (!do_not_decode[i])
-         memset(residue_buffers[i], 0, sizeof(float) * n);
-
-   if (rtype == 2 && ch != 1) {
-      for (j=0; j < ch; ++j)
-         if (!do_not_decode[j])
-            break;
-      if (j == ch)
-         goto done;
-
-      for (pass=0; pass < 8; ++pass) {
-         int pcount = 0, class_set = 0;
-         if (ch == 2) {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = (z & 1), p_inter = z>>1;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                     #else
-                     // saves 1%
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                     #endif
-                  } else {
-                     z += r->part_size;
-                     c_inter = z & 1;
-                     p_inter = z >> 1;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         } else if (ch == 1) {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = 0, p_inter = z;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                  } else {
-                     z += r->part_size;
-                     c_inter = 0;
-                     p_inter = z;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         } else {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = z % ch, p_inter = z/ch;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                  } else {
-                     z += r->part_size;
-                     c_inter = z % ch;
-                     p_inter = z / ch;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         }
-      }
-      goto done;
-   }
-   STBV_CHECK(f);
-
-   for (pass=0; pass < 8; ++pass) {
-      int pcount = 0, class_set=0;
-      while (pcount < part_read) {
-         if (pass == 0) {
-            for (j=0; j < ch; ++j) {
-               if (!do_not_decode[j]) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int temp;
-                  STBV_DECODE(temp,f,c);
-                  if (temp == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[j][class_set] = r->classdata[temp];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[j][i+pcount] = temp % r->classifications;
-                     temp /= r->classifications;
-                  }
-                  #endif
-               }
-            }
-         }
-         for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-            for (j=0; j < ch; ++j) {
-               if (!do_not_decode[j]) {
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[j][class_set][i];
-                  #else
-                  int c = classifications[j][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     float *target = residue_buffers[j];
-                     int offset = r->begin + pcount * r->part_size;
-                     int n = r->part_size;
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_residue_decode(f, book, target, offset, n, rtype))
-                        goto done;
-                  }
-               }
-            }
-         }
-         #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-         ++class_set;
-         #endif
-      }
-   }
-  done:
-   STBV_CHECK(f);
-   #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-   stbv_temp_free(f,part_classdata);
-   #else
-   stbv_temp_free(f,classifications);
-   #endif
-   stbv_temp_alloc_restore(f,temp_alloc_point);
-}
-
-
-#if 0
-// slow way for debugging
-void inverse_mdct_slow(float *buffer, int n)
-{
-   int i,j;
-   int n2 = n >> 1;
-   float *x = (float *) malloc(sizeof(*x) * n2);
-   memcpy(x, buffer, sizeof(*x) * n2);
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n2; ++j)
-         // formula from paper:
-         //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
-         // formula from wikipedia
-         //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
-         // these are equivalent, except the formula from the paper inverts the multiplier!
-         // however, what actually works is NO MULTIPLIER!?!
-         //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
-         acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
-      buffer[i] = acc;
-   }
-   free(x);
-}
-#elif 0
-// same as above, but just barely able to run in real time on modern machines
-void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   float mcos[16384];
-   int i,j;
-   int n2 = n >> 1, nmask = (n << 2) -1;
-   float *x = (float *) malloc(sizeof(*x) * n2);
-   memcpy(x, buffer, sizeof(*x) * n2);
-   for (i=0; i < 4*n; ++i)
-      mcos[i] = (float) cos(M_PI / 2 * i / n);
-
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n2; ++j)
-         acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask];
-      buffer[i] = acc;
-   }
-   free(x);
-}
-#elif 0
-// transform to use a slow dct-iv; this is STILL basically trivial,
-// but only requires half as many ops
-void dct_iv_slow(float *buffer, int n)
-{
-   float mcos[16384];
-   float x[2048];
-   int i,j;
-   int n2 = n >> 1, nmask = (n << 3) - 1;
-   memcpy(x, buffer, sizeof(*x) * n);
-   for (i=0; i < 8*n; ++i)
-      mcos[i] = (float) cos(M_PI / 4 * i / n);
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n; ++j)
-         acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask];
-      buffer[i] = acc;
-   }
-}
-
-void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4;
-   float temp[4096];
-
-   memcpy(temp, buffer, n2 * sizeof(float));
-   dct_iv_slow(temp, n2);  // returns -c'-d, a-b'
-
-   for (i=0; i < n4  ; ++i) buffer[i] = temp[i+n4];            // a-b'
-   for (   ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1];   // b-a', c+d'
-   for (   ; i < n   ; ++i) buffer[i] = -temp[i - n3_4];       // c'+d
-}
-#endif
-
-#ifndef LIBVORBIS_MDCT
-#define LIBVORBIS_MDCT 0
-#endif
-
-#if LIBVORBIS_MDCT
-// directly call the vorbis MDCT using an interface documented
-// by Jeff Roberts... useful for performance comparison
-typedef struct 
-{
-  int n;
-  int log2n;
-  
-  float *trig;
-  int   *bitrev;
-
-  float scale;
-} mdct_lookup;
-
-extern void mdct_init(mdct_lookup *lookup, int n);
-extern void mdct_clear(mdct_lookup *l);
-extern void mdct_backward(mdct_lookup *init, float *in, float *out);
-
-mdct_lookup M1,M2;
-
-void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   mdct_lookup *M;
-   if (M1.n == n) M = &M1;
-   else if (M2.n == n) M = &M2;
-   else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; }
-   else { 
-      if (M2.n) __asm int 3;
-      mdct_init(&M2, n);
-      M = &M2;
-   }
-
-   mdct_backward(M, buffer, buffer);
-}
-#endif
-
-
-// the following were split out into separate functions while optimizing;
-// they could be pushed back up but eh. __forceinline showed no change;
-// they're probably already being inlined.
-static void stbv_imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
-{
-   float *ee0 = e + i_off;
-   float *ee2 = ee0 + k_off;
-   int i;
-
-   assert((n & 3) == 0);
-   for (i=(n>>2); i > 0; --i) {
-      float k00_20, k01_21;
-      k00_20  = ee0[ 0] - ee2[ 0];
-      k01_21  = ee0[-1] - ee2[-1];
-      ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0];
-      ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1];
-      ee2[ 0] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-1] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-2] - ee2[-2];
-      k01_21  = ee0[-3] - ee2[-3];
-      ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2];
-      ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3];
-      ee2[-2] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-3] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-4] - ee2[-4];
-      k01_21  = ee0[-5] - ee2[-5];
-      ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4];
-      ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5];
-      ee2[-4] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-5] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-6] - ee2[-6];
-      k01_21  = ee0[-7] - ee2[-7];
-      ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6];
-      ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7];
-      ee2[-6] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-7] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-      ee0 -= 8;
-      ee2 -= 8;
-   }
-}
-
-static void stbv_imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
-{
-   int i;
-   float k00_20, k01_21;
-
-   float *e0 = e + d0;
-   float *e2 = e0 + k_off;
-
-   for (i=lim >> 2; i > 0; --i) {
-      k00_20 = e0[-0] - e2[-0];
-      k01_21 = e0[-1] - e2[-1];
-      e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0];
-      e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1];
-      e2[-0] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-1] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-2] - e2[-2];
-      k01_21 = e0[-3] - e2[-3];
-      e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2];
-      e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3];
-      e2[-2] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-3] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-4] - e2[-4];
-      k01_21 = e0[-5] - e2[-5];
-      e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4];
-      e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5];
-      e2[-4] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-5] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-6] - e2[-6];
-      k01_21 = e0[-7] - e2[-7];
-      e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6];
-      e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7];
-      e2[-6] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-7] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      e0 -= 8;
-      e2 -= 8;
-
-      A += k1;
-   }
-}
-
-static void stbv_imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
-{
-   int i;
-   float A0 = A[0];
-   float A1 = A[0+1];
-   float A2 = A[0+a_off];
-   float A3 = A[0+a_off+1];
-   float A4 = A[0+a_off*2+0];
-   float A5 = A[0+a_off*2+1];
-   float A6 = A[0+a_off*3+0];
-   float A7 = A[0+a_off*3+1];
-
-   float k00,k11;
-
-   float *ee0 = e  +i_off;
-   float *ee2 = ee0+k_off;
-
-   for (i=n; i > 0; --i) {
-      k00     = ee0[ 0] - ee2[ 0];
-      k11     = ee0[-1] - ee2[-1];
-      ee0[ 0] =  ee0[ 0] + ee2[ 0];
-      ee0[-1] =  ee0[-1] + ee2[-1];
-      ee2[ 0] = (k00) * A0 - (k11) * A1;
-      ee2[-1] = (k11) * A0 + (k00) * A1;
-
-      k00     = ee0[-2] - ee2[-2];
-      k11     = ee0[-3] - ee2[-3];
-      ee0[-2] =  ee0[-2] + ee2[-2];
-      ee0[-3] =  ee0[-3] + ee2[-3];
-      ee2[-2] = (k00) * A2 - (k11) * A3;
-      ee2[-3] = (k11) * A2 + (k00) * A3;
-
-      k00     = ee0[-4] - ee2[-4];
-      k11     = ee0[-5] - ee2[-5];
-      ee0[-4] =  ee0[-4] + ee2[-4];
-      ee0[-5] =  ee0[-5] + ee2[-5];
-      ee2[-4] = (k00) * A4 - (k11) * A5;
-      ee2[-5] = (k11) * A4 + (k00) * A5;
-
-      k00     = ee0[-6] - ee2[-6];
-      k11     = ee0[-7] - ee2[-7];
-      ee0[-6] =  ee0[-6] + ee2[-6];
-      ee0[-7] =  ee0[-7] + ee2[-7];
-      ee2[-6] = (k00) * A6 - (k11) * A7;
-      ee2[-7] = (k11) * A6 + (k00) * A7;
-
-      ee0 -= k0;
-      ee2 -= k0;
-   }
-}
-
-static __forceinline void stbv_iter_54(float *z)
-{
-   float k00,k11,k22,k33;
-   float y0,y1,y2,y3;
-
-   k00  = z[ 0] - z[-4];
-   y0   = z[ 0] + z[-4];
-   y2   = z[-2] + z[-6];
-   k22  = z[-2] - z[-6];
-
-   z[-0] = y0 + y2;      // z0 + z4 + z2 + z6
-   z[-2] = y0 - y2;      // z0 + z4 - z2 - z6
-
-   // done with y0,y2
-
-   k33  = z[-3] - z[-7];
-
-   z[-4] = k00 + k33;    // z0 - z4 + z3 - z7
-   z[-6] = k00 - k33;    // z0 - z4 - z3 + z7
-
-   // done with k33
-
-   k11  = z[-1] - z[-5];
-   y1   = z[-1] + z[-5];
-   y3   = z[-3] + z[-7];
-
-   z[-1] = y1 + y3;      // z1 + z5 + z3 + z7
-   z[-3] = y1 - y3;      // z1 + z5 - z3 - z7
-   z[-5] = k11 - k22;    // z1 - z5 + z2 - z6
-   z[-7] = k11 + k22;    // z1 - z5 - z2 + z6
-}
-
-static void stbv_imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
-{
-   int a_off = base_n >> 3;
-   float A2 = A[0+a_off];
-   float *z = e + i_off;
-   float *base = z - 16 * n;
-
-   while (z > base) {
-      float k00,k11;
-
-      k00   = z[-0] - z[-8];
-      k11   = z[-1] - z[-9];
-      z[-0] = z[-0] + z[-8];
-      z[-1] = z[-1] + z[-9];
-      z[-8] =  k00;
-      z[-9] =  k11 ;
-
-      k00    = z[ -2] - z[-10];
-      k11    = z[ -3] - z[-11];
-      z[ -2] = z[ -2] + z[-10];
-      z[ -3] = z[ -3] + z[-11];
-      z[-10] = (k00+k11) * A2;
-      z[-11] = (k11-k00) * A2;
-
-      k00    = z[-12] - z[ -4];  // reverse to avoid a unary negation
-      k11    = z[ -5] - z[-13];
-      z[ -4] = z[ -4] + z[-12];
-      z[ -5] = z[ -5] + z[-13];
-      z[-12] = k11;
-      z[-13] = k00;
-
-      k00    = z[-14] - z[ -6];  // reverse to avoid a unary negation
-      k11    = z[ -7] - z[-15];
-      z[ -6] = z[ -6] + z[-14];
-      z[ -7] = z[ -7] + z[-15];
-      z[-14] = (k00+k11) * A2;
-      z[-15] = (k00-k11) * A2;
-
-      stbv_iter_54(z);
-      stbv_iter_54(z-8);
-      z -= 16;
-   }
-}
-
-static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
-   int ld;
-   // @OPTIMIZE: reduce register pressure by using fewer variables?
-   int save_point = stbv_temp_alloc_save(f);
-   float *buf2 = (float *) stbv_temp_alloc(f, n2 * sizeof(*buf2));
-   float *u=NULL,*v=NULL;
-   // twiddle factors
-   float *A = f->A[blocktype];
-
-   // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
-   // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function.
-
-   // kernel from paper
-
-
-   // merged:
-   //   copy and reflect spectral data
-   //   step 0
-
-   // note that it turns out that the items added together during
-   // this step are, in fact, being added to themselves (as reflected
-   // by step 0). inexplicable inefficiency! this became obvious
-   // once I combined the passes.
-
-   // so there's a missing 'times 2' here (for adding X to itself).
-   // this propogates through linearly to the end, where the numbers
-   // are 1/2 too small, and need to be compensated for.
-
-   {
-      float *d,*e, *AA, *e_stop;
-      d = &buf2[n2-2];
-      AA = A;
-      e = &buffer[0];
-      e_stop = &buffer[n2];
-      while (e != e_stop) {
-         d[1] = (e[0] * AA[0] - e[2]*AA[1]);
-         d[0] = (e[0] * AA[1] + e[2]*AA[0]);
-         d -= 2;
-         AA += 2;
-         e += 4;
-      }
-
-      e = &buffer[n2-3];
-      while (d >= buf2) {
-         d[1] = (-e[2] * AA[0] - -e[0]*AA[1]);
-         d[0] = (-e[2] * AA[1] + -e[0]*AA[0]);
-         d -= 2;
-         AA += 2;
-         e -= 4;
-      }
-   }
-
-   // now we use symbolic names for these, so that we can
-   // possibly swap their meaning as we change which operations
-   // are in place
-
-   u = buffer;
-   v = buf2;
-
-   // step 2    (paper output is w, now u)
-   // this could be in place, but the data ends up in the wrong
-   // place... _somebody_'s got to swap it, so this is nominated
-   {
-      float *AA = &A[n2-8];
-      float *d0,*d1, *e0, *e1;
-
-      e0 = &v[n4];
-      e1 = &v[0];
-
-      d0 = &u[n4];
-      d1 = &u[0];
-
-      while (AA >= A) {
-         float v40_20, v41_21;
-
-         v41_21 = e0[1] - e1[1];
-         v40_20 = e0[0] - e1[0];
-         d0[1]  = e0[1] + e1[1];
-         d0[0]  = e0[0] + e1[0];
-         d1[1]  = v41_21*AA[4] - v40_20*AA[5];
-         d1[0]  = v40_20*AA[4] + v41_21*AA[5];
-
-         v41_21 = e0[3] - e1[3];
-         v40_20 = e0[2] - e1[2];
-         d0[3]  = e0[3] + e1[3];
-         d0[2]  = e0[2] + e1[2];
-         d1[3]  = v41_21*AA[0] - v40_20*AA[1];
-         d1[2]  = v40_20*AA[0] + v41_21*AA[1];
-
-         AA -= 8;
-
-         d0 += 4;
-         d1 += 4;
-         e0 += 4;
-         e1 += 4;
-      }
-   }
-
-   // step 3
-   ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-
-   // optimized step 3:
-
-   // the original step3 loop can be nested r inside s or s inside r;
-   // it's written originally as s inside r, but this is dumb when r
-   // iterates many times, and s few. So I have two copies of it and
-   // switch between them halfway.
-
-   // this is iteration 0 of step 3
-   stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
-   stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
-
-   // this is iteration 1 of step 3
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
-
-   l=2;
-   for (; l < (ld-3)>>1; ++l) {
-      int k0 = n >> (l+2), k0_2 = k0>>1;
-      int lim = 1 << (l+1);
-      int i;
-      for (i=0; i < lim; ++i)
-         stbv_imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
-   }
-
-   for (; l < ld-6; ++l) {
-      int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1;
-      int rlim = n >> (l+6), r;
-      int lim = 1 << (l+1);
-      int i_off;
-      float *A0 = A;
-      i_off = n2-1;
-      for (r=rlim; r > 0; --r) {
-         stbv_imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
-         A0 += k1*4;
-         i_off -= 8;
-      }
-   }
-
-   // iterations with count:
-   //   ld-6,-5,-4 all interleaved together
-   //       the big win comes from getting rid of needless flops
-   //         due to the constants on pass 5 & 4 being all 1 and 0;
-   //       combining them to be simultaneous to improve cache made little difference
-   stbv_imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
-
-   // output is u
-
-   // step 4, 5, and 6
-   // cannot be in-place because of step 5
-   {
-      stbv_uint16 *bitrev = f->stbv_bit_reverse[blocktype];
-      // weirdly, I'd have thought reading sequentially and writing
-      // erratically would have been better than vice-versa, but in
-      // fact that's not what my testing showed. (That is, with
-      // j = bitreverse(i), do you read i and write j, or read j and write i.)
-
-      float *d0 = &v[n4-4];
-      float *d1 = &v[n2-4];
-      while (d0 >= v) {
-         int k4;
-
-         k4 = bitrev[0];
-         d1[3] = u[k4+0];
-         d1[2] = u[k4+1];
-         d0[3] = u[k4+2];
-         d0[2] = u[k4+3];
-
-         k4 = bitrev[1];
-         d1[1] = u[k4+0];
-         d1[0] = u[k4+1];
-         d0[1] = u[k4+2];
-         d0[0] = u[k4+3];
-         
-         d0 -= 4;
-         d1 -= 4;
-         bitrev += 2;
-      }
-   }
-   // (paper output is u, now v)
-
-
-   // data must be in buf2
-   assert(v == buf2);
-
-   // step 7   (paper output is v, now v)
-   // this is now in place
-   {
-      float *C = f->C[blocktype];
-      float *d, *e;
-
-      d = v;
-      e = v + n2 - 4;
-
-      while (d < e) {
-         float a02,a11,b0,b1,b2,b3;
-
-         a02 = d[0] - e[2];
-         a11 = d[1] + e[3];
-
-         b0 = C[1]*a02 + C[0]*a11;
-         b1 = C[1]*a11 - C[0]*a02;
-
-         b2 = d[0] + e[ 2];
-         b3 = d[1] - e[ 3];
-
-         d[0] = b2 + b0;
-         d[1] = b3 + b1;
-         e[2] = b2 - b0;
-         e[3] = b1 - b3;
-
-         a02 = d[2] - e[0];
-         a11 = d[3] + e[1];
-
-         b0 = C[3]*a02 + C[2]*a11;
-         b1 = C[3]*a11 - C[2]*a02;
-
-         b2 = d[2] + e[ 0];
-         b3 = d[3] - e[ 1];
-
-         d[2] = b2 + b0;
-         d[3] = b3 + b1;
-         e[0] = b2 - b0;
-         e[1] = b1 - b3;
-
-         C += 4;
-         d += 4;
-         e -= 4;
-      }
-   }
-
-   // data must be in buf2
-
-
-   // step 8+decode   (paper output is X, now buffer)
-   // this generates pairs of data a la 8 and pushes them directly through
-   // the decode kernel (pushing rather than pulling) to avoid having
-   // to make another pass later
-
-   // this cannot POSSIBLY be in place, so we refer to the buffers directly
-
-   {
-      float *d0,*d1,*d2,*d3;
-
-      float *B = f->B[blocktype] + n2 - 8;
-      float *e = buf2 + n2 - 8;
-      d0 = &buffer[0];
-      d1 = &buffer[n2-4];
-      d2 = &buffer[n2];
-      d3 = &buffer[n-4];
-      while (e >= v) {
-         float p0,p1,p2,p3;
-
-         p3 =  e[6]*B[7] - e[7]*B[6];
-         p2 = -e[6]*B[6] - e[7]*B[7]; 
-
-         d0[0] =   p3;
-         d1[3] = - p3;
-         d2[0] =   p2;
-         d3[3] =   p2;
-
-         p1 =  e[4]*B[5] - e[5]*B[4];
-         p0 = -e[4]*B[4] - e[5]*B[5]; 
-
-         d0[1] =   p1;
-         d1[2] = - p1;
-         d2[1] =   p0;
-         d3[2] =   p0;
-
-         p3 =  e[2]*B[3] - e[3]*B[2];
-         p2 = -e[2]*B[2] - e[3]*B[3]; 
-
-         d0[2] =   p3;
-         d1[1] = - p3;
-         d2[2] =   p2;
-         d3[1] =   p2;
-
-         p1 =  e[0]*B[1] - e[1]*B[0];
-         p0 = -e[0]*B[0] - e[1]*B[1]; 
-
-         d0[3] =   p1;
-         d1[0] = - p1;
-         d2[3] =   p0;
-         d3[0] =   p0;
-
-         B -= 8;
-         e -= 8;
-         d0 += 4;
-         d2 += 4;
-         d1 -= 4;
-         d3 -= 4;
-      }
-   }
-
-   stbv_temp_free(f,buf2);
-   stbv_temp_alloc_restore(f,save_point);
-}
-
-#if 0
-// this is the original version of the above code, if you want to optimize it from scratch
-void inverse_mdct_naive(float *buffer, int n)
-{
-   float s;
-   float A[1 << 12], B[1 << 12], C[1 << 11];
-   int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
-   int n3_4 = n - n4, ld;
-   // how can they claim this only uses N words?!
-   // oh, because they're only used sparsely, whoops
-   float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13];
-   // set up twiddle factors
-
-   for (k=k2=0; k < n4; ++k,k2+=2) {
-      A[k2  ] = (float)  cos(4*k*M_PI/n);
-      A[k2+1] = (float) -sin(4*k*M_PI/n);
-      B[k2  ] = (float)  cos((k2+1)*M_PI/n/2);
-      B[k2+1] = (float)  sin((k2+1)*M_PI/n/2);
-   }
-   for (k=k2=0; k < n8; ++k,k2+=2) {
-      C[k2  ] = (float)  cos(2*(k2+1)*M_PI/n);
-      C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
-   }
-
-   // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
-   // Note there are bugs in that pseudocode, presumably due to them attempting
-   // to rename the arrays nicely rather than representing the way their actual
-   // implementation bounces buffers back and forth. As a result, even in the
-   // "some formulars corrected" version, a direct implementation fails. These
-   // are noted below as "paper bug".
-
-   // copy and reflect spectral data
-   for (k=0; k < n2; ++k) u[k] = buffer[k];
-   for (   ; k < n ; ++k) u[k] = -buffer[n - k - 1];
-   // kernel from paper
-   // step 1
-   for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) {
-      v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2]   - (u[k4+2] - u[n-k4-3])*A[k2+1];
-      v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2];
-   }
-   // step 2
-   for (k=k4=0; k < n8; k+=1, k4+=4) {
-      w[n2+3+k4] = v[n2+3+k4] + v[k4+3];
-      w[n2+1+k4] = v[n2+1+k4] + v[k4+1];
-      w[k4+3]    = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4];
-      w[k4+1]    = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4];
-   }
-   // step 3
-   ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-   for (l=0; l < ld-3; ++l) {
-      int k0 = n >> (l+2), k1 = 1 << (l+3);
-      int rlim = n >> (l+4), r4, r;
-      int s2lim = 1 << (l+2), s2;
-      for (r=r4=0; r < rlim; r4+=4,++r) {
-         for (s2=0; s2 < s2lim; s2+=2) {
-            u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4];
-            u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4];
-            u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1]
-                                - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1];
-            u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1]
-                                + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1];
-         }
-      }
-      if (l+1 < ld-3) {
-         // paper bug: ping-ponging of u&w here is omitted
-         memcpy(w, u, sizeof(u));
-      }
-   }
-
-   // step 4
-   for (i=0; i < n8; ++i) {
-      int j = stbv_bit_reverse(i) >> (32-ld+3);
-      assert(j < n8);
-      if (i == j) {
-         // paper bug: original code probably swapped in place; if copying,
-         //            need to directly copy in this case
-         int i8 = i << 3;
-         v[i8+1] = u[i8+1];
-         v[i8+3] = u[i8+3];
-         v[i8+5] = u[i8+5];
-         v[i8+7] = u[i8+7];
-      } else if (i < j) {
-         int i8 = i << 3, j8 = j << 3;
-         v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1];
-         v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3];
-         v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5];
-         v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7];
-      }
-   }
-   // step 5
-   for (k=0; k < n2; ++k) {
-      w[k] = v[k*2+1];
-   }
-   // step 6
-   for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) {
-      u[n-1-k2] = w[k4];
-      u[n-2-k2] = w[k4+1];
-      u[n3_4 - 1 - k2] = w[k4+2];
-      u[n3_4 - 2 - k2] = w[k4+3];
-   }
-   // step 7
-   for (k=k2=0; k < n8; ++k, k2 += 2) {
-      v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
-      v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
-      v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
-      v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
-   }
-   // step 8
-   for (k=k2=0; k < n4; ++k,k2 += 2) {
-      X[k]      = v[k2+n2]*B[k2  ] + v[k2+1+n2]*B[k2+1];
-      X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2  ];
-   }
-
-   // decode kernel to output
-   // determined the following value experimentally
-   // (by first figuring out what made inverse_mdct_slow work); then matching that here
-   // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?)
-   s = 0.5; // theoretically would be n4
-
-   // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code,
-   //     so it needs to use the "old" B values to behave correctly, or else
-   //     set s to 1.0 ]]]
-   for (i=0; i < n4  ; ++i) buffer[i] = s * X[i+n4];
-   for (   ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1];
-   for (   ; i < n   ; ++i) buffer[i] = -s * X[i - n3_4];
-}
-#endif
-
-static float *stbv_get_window(stbv_vorb *f, int len)
-{
-   len <<= 1;
-   if (len == f->blocksize_0) return f->window[0];
-   if (len == f->blocksize_1) return f->window[1];
-   assert(0);
-   return NULL;
-}
-
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-typedef stbv_int16 STBV_YTYPE;
-#else
-typedef int STBV_YTYPE;
-#endif
-static int stbv_do_floor(stbv_vorb *f, StbvMapping *map, int i, int n, float *target, STBV_YTYPE *finalY, stbv_uint8 *step2_flag)
-{
-   int n2 = n >> 1;
-   int s = map->chan[i].mux, floor;
-   floor = map->submap_floor[s];
-   if (f->floor_types[floor] == 0) {
-      return stbv_error(f, VORBIS_invalid_stream);
-   } else {
-      StbvFloor1 *g = &f->floor_config[floor].floor1;
-      int j,q;
-      int lx = 0, ly = finalY[0] * g->floor1_multiplier;
-      for (q=1; q < g->values; ++q) {
-         j = g->sorted_order[q];
-         #ifndef STB_VORBIS_NO_DEFER_FLOOR
-         if (finalY[j] >= 0)
-         #else
-         if (step2_flag[j])
-         #endif
-         {
-            int hy = finalY[j] * g->floor1_multiplier;
-            int hx = g->Xlist[j];
-            if (lx != hx)
-               stbv_draw_line(target, lx,ly, hx,hy, n2);
-            STBV_CHECK(f);
-            lx = hx, ly = hy;
-         }
-      }
-      if (lx < n2) {
-         // optimization of: stbv_draw_line(target, lx,ly, n,ly, n2);
-         for (j=lx; j < n2; ++j)
-            STBV_LINE_OP(target[j], stbv_inverse_db_table[ly]);
-         STBV_CHECK(f);
-      }
-   }
-   return TRUE;
-}
-
-// The meaning of "left" and "right"
-//
-// For a given frame:
-//     we compute samples from 0..n
-//     window_center is n/2
-//     we'll window and mix the samples from left_start to left_end with data from the previous frame
-//     all of the samples from left_end to right_start can be output without mixing; however,
-//        this interval is 0-length except when transitioning between short and long frames
-//     all of the samples from right_start to right_end need to be mixed with the next frame,
-//        which we don't have, so those get saved in a buffer
-//     frame N's right_end-right_start, the number of samples to mix with the next frame,
-//        has to be the same as frame N+1's left_end-left_start (which they are by
-//        construction)
-
-static int stbv_vorbis_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
-{
-   StbvMode *m;
-   int i, n, prev, next, window_center;
-   f->channel_buffer_start = f->channel_buffer_end = 0;
-
-  retry:
-   if (f->eof) return FALSE;
-   if (!stbv_maybe_start_packet(f))
-      return FALSE;
-   // check packet type
-   if (stbv_get_bits(f,1) != 0) {
-      if (STBV_IS_PUSH_MODE(f))
-         return stbv_error(f,VORBIS_bad_packet_type);
-      while (STBV_EOP != stbv_get8_packet(f));
-      goto retry;
-   }
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-
-   i = stbv_get_bits(f, stbv_ilog(f->mode_count-1));
-   if (i == STBV_EOP) return FALSE;
-   if (i >= f->mode_count) return FALSE;
-   *mode = i;
-   m = f->mode_config + i;
-   if (m->blockflag) {
-      n = f->blocksize_1;
-      prev = stbv_get_bits(f,1);
-      next = stbv_get_bits(f,1);
-   } else {
-      prev = next = 0;
-      n = f->blocksize_0;
-   }
-
-// WINDOWING
-
-   window_center = n >> 1;
-   if (m->blockflag && !prev) {
-      *p_left_start = (n - f->blocksize_0) >> 2;
-      *p_left_end   = (n + f->blocksize_0) >> 2;
-   } else {
-      *p_left_start = 0;
-      *p_left_end   = window_center;
-   }
-   if (m->blockflag && !next) {
-      *p_right_start = (n*3 - f->blocksize_0) >> 2;
-      *p_right_end   = (n*3 + f->blocksize_0) >> 2;
-   } else {
-      *p_right_start = window_center;
-      *p_right_end   = n;
-   }
-
-   return TRUE;
-}
-
-static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
-{
-   StbvMapping *map;
-   int i,j,k,n,n2;
-   int zero_channel[256];
-   int really_zero_channel[256];
-
-// WINDOWING
-
-   n = f->blocksize[m->blockflag];
-   map = &f->mapping[m->mapping];
-
-// FLOORS
-   n2 = n >> 1;
-
-   STBV_CHECK(f);
-
-   for (i=0; i < f->channels; ++i) {
-      int s = map->chan[i].mux, floor;
-      zero_channel[i] = FALSE;
-      floor = map->submap_floor[s];
-      if (f->floor_types[floor] == 0) {
-         return stbv_error(f, VORBIS_invalid_stream);
-      } else {
-         StbvFloor1 *g = &f->floor_config[floor].floor1;
-         if (stbv_get_bits(f, 1)) {
-            short *finalY;
-            stbv_uint8 step2_flag[256];
-            static int range_list[4] = { 256, 128, 86, 64 };
-            int range = range_list[g->floor1_multiplier-1];
-            int offset = 2;
-            finalY = f->finalY[i];
-            finalY[0] = stbv_get_bits(f, stbv_ilog(range)-1);
-            finalY[1] = stbv_get_bits(f, stbv_ilog(range)-1);
-            for (j=0; j < g->partitions; ++j) {
-               int pclass = g->partition_class_list[j];
-               int cdim = g->class_dimensions[pclass];
-               int cbits = g->class_subclasses[pclass];
-               int csub = (1 << cbits)-1;
-               int cval = 0;
-               if (cbits) {
-                  StbvCodebook *c = f->codebooks + g->class_masterbooks[pclass];
-                  STBV_DECODE(cval,f,c);
-               }
-               for (k=0; k < cdim; ++k) {
-                  int book = g->subclass_books[pclass][cval & csub];
-                  cval = cval >> cbits;
-                  if (book >= 0) {
-                     int temp;
-                     StbvCodebook *c = f->codebooks + book;
-                     STBV_DECODE(temp,f,c);
-                     finalY[offset++] = temp;
-                  } else
-                     finalY[offset++] = 0;
-               }
-            }
-            if (f->valid_bits == STBV_INVALID_BITS) goto error; // behavior according to spec
-            step2_flag[0] = step2_flag[1] = 1;
-            for (j=2; j < g->values; ++j) {
-               int low, high, pred, highroom, lowroom, room, val;
-               low = g->stbv_neighbors[j][0];
-               high = g->stbv_neighbors[j][1];
-               //stbv_neighbors(g->Xlist, j, &low, &high);
-               pred = stbv_predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
-               val = finalY[j];
-               highroom = range - pred;
-               lowroom = pred;
-               if (highroom < lowroom)
-                  room = highroom * 2;
-               else
-                  room = lowroom * 2;
-               if (val) {
-                  step2_flag[low] = step2_flag[high] = 1;
-                  step2_flag[j] = 1;
-                  if (val >= room)
-                     if (highroom > lowroom)
-                        finalY[j] = val - lowroom + pred;
-                     else
-                        finalY[j] = pred - val + highroom - 1;
-                  else
-                     if (val & 1)
-                        finalY[j] = pred - ((val+1)>>1);
-                     else
-                        finalY[j] = pred + (val>>1);
-               } else {
-                  step2_flag[j] = 0;
-                  finalY[j] = pred;
-               }
-            }
-
-#ifdef STB_VORBIS_NO_DEFER_FLOOR
-            stbv_do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
-#else
-            // defer final floor computation until _after_ residue
-            for (j=0; j < g->values; ++j) {
-               if (!step2_flag[j])
-                  finalY[j] = -1;
-            }
-#endif
-         } else {
-           error:
-            zero_channel[i] = TRUE;
-         }
-         // So we just defer everything else to later
-
-         // at this point we've decoded the floor into buffer
-      }
-   }
-   STBV_CHECK(f);
-   // at this point we've decoded all floors
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-
-   // re-enable coupled channels if necessary
-   memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels);
-   for (i=0; i < map->coupling_steps; ++i)
-      if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) {
-         zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
-      }
-
-   STBV_CHECK(f);
-// RESIDUE STBV_DECODE
-   for (i=0; i < map->submaps; ++i) {
-      float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
-      int r;
-      stbv_uint8 do_not_decode[256];
-      int ch = 0;
-      for (j=0; j < f->channels; ++j) {
-         if (map->chan[j].mux == i) {
-            if (zero_channel[j]) {
-               do_not_decode[ch] = TRUE;
-               residue_buffers[ch] = NULL;
-            } else {
-               do_not_decode[ch] = FALSE;
-               residue_buffers[ch] = f->channel_buffers[j];
-            }
-            ++ch;
-         }
-      }
-      r = map->submap_residue[i];
-      stbv_decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
-   }
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-   STBV_CHECK(f);
-
-// INVERSE COUPLING
-   for (i = map->coupling_steps-1; i >= 0; --i) {
-      int n2 = n >> 1;
-      float *m = f->channel_buffers[map->chan[i].magnitude];
-      float *a = f->channel_buffers[map->chan[i].angle    ];
-      for (j=0; j < n2; ++j) {
-         float a2,m2;
-         if (m[j] > 0)
-            if (a[j] > 0)
-               m2 = m[j], a2 = m[j] - a[j];
-            else
-               a2 = m[j], m2 = m[j] + a[j];
-         else
-            if (a[j] > 0)
-               m2 = m[j], a2 = m[j] + a[j];
-            else
-               a2 = m[j], m2 = m[j] - a[j];
-         m[j] = m2;
-         a[j] = a2;
-      }
-   }
-   STBV_CHECK(f);
-
-   // finish decoding the floors
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-   for (i=0; i < f->channels; ++i) {
-      if (really_zero_channel[i]) {
-         memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
-      } else {
-         stbv_do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
-      }
-   }
-#else
-   for (i=0; i < f->channels; ++i) {
-      if (really_zero_channel[i]) {
-         memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
-      } else {
-         for (j=0; j < n2; ++j)
-            f->channel_buffers[i][j] *= f->floor_buffers[i][j];
-      }
-   }
-#endif
-
-// INVERSE MDCT
-   STBV_CHECK(f);
-   for (i=0; i < f->channels; ++i)
-      stbv_inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
-   STBV_CHECK(f);
-
-   // this shouldn't be necessary, unless we exited on an error
-   // and want to flush to get to the next packet
-   stbv_flush_packet(f);
-
-   if (f->first_decode) {
-      // assume we start so first non-discarded sample is sample 0
-      // this isn't to spec, but spec would require us to read ahead
-      // and decode the size of all current frames--could be done,
-      // but presumably it's not a commonly used feature
-      f->current_loc = -n2; // start of first frame is positioned for discard
-      // we might have to discard samples "from" the next frame too,
-      // if we're lapping a large block then a small at the start?
-      f->discard_samples_deferred = n - right_end;
-      f->current_loc_valid = TRUE;
-      f->first_decode = FALSE;
-   } else if (f->discard_samples_deferred) {
-      if (f->discard_samples_deferred >= right_start - left_start) {
-         f->discard_samples_deferred -= (right_start - left_start);
-         left_start = right_start;
-         *p_left = left_start;
-      } else {
-         left_start += f->discard_samples_deferred;
-         *p_left = left_start;
-         f->discard_samples_deferred = 0;
-      }
-   } else if (f->previous_length == 0 && f->current_loc_valid) {
-      // we're recovering from a seek... that means we're going to discard
-      // the samples from this packet even though we know our position from
-      // the last page header, so we need to update the position based on
-      // the discarded samples here
-      // but wait, the code below is going to add this in itself even
-      // on a discard, so we don't need to do it here...
-   }
-
-   // check if we have ogg information about the sample # for this packet
-   if (f->last_seg_which == f->end_seg_with_known_loc) {
-      // if we have a valid current loc, and this is final:
-      if (f->current_loc_valid && (f->page_flag & STBV_PAGEFLAG_last_page)) {
-         stbv_uint32 current_end = f->known_loc_for_packet;
-         // then let's infer the size of the (probably) short final frame
-         if (current_end < f->current_loc + (right_end-left_start)) {
-            if (current_end < f->current_loc) {
-               // negative truncation, that's impossible!
-               *len = 0;
-            } else {
-               *len = current_end - f->current_loc;
-            }
-            *len += left_start; // this doesn't seem right, but has no ill effect on my test files
-            if (*len > right_end) *len = right_end; // this should never happen
-            f->current_loc += *len;
-            return TRUE;
-         }
-      }
-      // otherwise, just set our sample loc
-      // guess that the ogg granule pos refers to the _middle_ of the
-      // last frame?
-      // set f->current_loc to the position of left_start
-      f->current_loc = f->known_loc_for_packet - (n2-left_start);
-      f->current_loc_valid = TRUE;
-   }
-   if (f->current_loc_valid)
-      f->current_loc += (right_start - left_start);
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-   *len = right_end;  // ignore samples after the window goes to 0
-   STBV_CHECK(f);
-
-   return TRUE;
-}
-
-static int stbv_vorbis_decode_packet(stbv_vorb *f, int *len, int *p_left, int *p_right)
-{
-   int mode, left_end, right_end;
-   if (!stbv_vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
-   return stbv_vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
-}
-
-static int stbv_vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
-{
-   int prev,i,j;
-   // we use right&left (the start of the right- and left-window sin()-regions)
-   // to determine how much to return, rather than inferring from the rules
-   // (same result, clearer code); 'left' indicates where our sin() window
-   // starts, therefore where the previous window's right edge starts, and
-   // therefore where to start mixing from the previous buffer. 'right'
-   // indicates where our sin() ending-window starts, therefore that's where
-   // we start saving, and where our returned-data ends.
-
-   // mixin from previous window
-   if (f->previous_length) {
-      int i,j, n = f->previous_length;
-      float *w = stbv_get_window(f, n);
-      for (i=0; i < f->channels; ++i) {
-         for (j=0; j < n; ++j)
-            f->channel_buffers[i][left+j] =
-               f->channel_buffers[i][left+j]*w[    j] +
-               f->previous_window[i][     j]*w[n-1-j];
-      }
-   }
-
-   prev = f->previous_length;
-
-   // last half of this data becomes previous window
-   f->previous_length = len - right;
-
-   // @OPTIMIZE: could avoid this copy by double-buffering the
-   // output (flipping previous_window with channel_buffers), but
-   // then previous_window would have to be 2x as large, and
-   // channel_buffers couldn't be temp mem (although they're NOT
-   // currently temp mem, they could be (unless we want to level
-   // performance by spreading out the computation))
-   for (i=0; i < f->channels; ++i)
-      for (j=0; right+j < len; ++j)
-         f->previous_window[i][j] = f->channel_buffers[i][right+j];
-
-   if (!prev)
-      // there was no previous packet, so this data isn't valid...
-      // this isn't entirely true, only the would-have-overlapped data
-      // isn't valid, but this seems to be what the spec requires
-      return 0;
-
-   // truncate a short frame
-   if (len < right) right = len;
-
-   f->samples_output += right-left;
-
-   return right - left;
-}
-
-static int stbv_vorbis_pump_first_frame(stb_vorbis *f)
-{
-   int len, right, left, res;
-   res = stbv_vorbis_decode_packet(f, &len, &left, &right);
-   if (res)
-      stbv_vorbis_finish_frame(f, len, left, right);
-   return res;
-}
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-static int stbv_is_whole_packet_present(stb_vorbis *f, int end_page)
-{
-   // make sure that we have the packet available before continuing...
-   // this requires a full ogg parse, but we know we can fetch from f->stream
-
-   // instead of coding this out explicitly, we could save the current read state,
-   // read the next packet with stbv_get8() until end-of-packet, check f->eof, then
-   // reset the state? but that would be slower, esp. since we'd have over 256 bytes
-   // of state to restore (primarily the page segment table)
-
-   int s = f->next_seg, first = TRUE;
-   stbv_uint8 *p = f->stream;
-
-   if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag
-      for (; s < f->segment_count; ++s) {
-         p += f->segments[s];
-         if (f->segments[s] < 255)               // stop at first short segment
-            break;
-      }
-      // either this continues, or it ends it...
-      if (end_page)
-         if (s < f->segment_count-1)             return stbv_error(f, VORBIS_invalid_stream);
-      if (s == f->segment_count)
-         s = -1; // set 'crosses page' flag
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      first = FALSE;
-   }
-   for (; s == -1;) {
-      stbv_uint8 *q; 
-      int n;
-
-      // check that we have the page header ready
-      if (p + 26 >= f->stream_end)               return stbv_error(f, VORBIS_need_more_data);
-      // validate the page
-      if (memcmp(p, stbv_ogg_page_header, 4))         return stbv_error(f, VORBIS_invalid_stream);
-      if (p[4] != 0)                             return stbv_error(f, VORBIS_invalid_stream);
-      if (first) { // the first segment must NOT have 'continued_packet', later ones MUST
-         if (f->previous_length)
-            if ((p[5] & STBV_PAGEFLAG_continued_packet))  return stbv_error(f, VORBIS_invalid_stream);
-         // if no previous length, we're resynching, so we can come in on a continued-packet,
-         // which we'll just drop
-      } else {
-         if (!(p[5] & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_invalid_stream);
-      }
-      n = p[26]; // segment counts
-      q = p+27;  // q points to segment table
-      p = q + n; // advance past header
-      // make sure we've read the segment table
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      for (s=0; s < n; ++s) {
-         p += q[s];
-         if (q[s] < 255)
-            break;
-      }
-      if (end_page)
-         if (s < n-1)                            return stbv_error(f, VORBIS_invalid_stream);
-      if (s == n)
-         s = -1; // set 'crosses page' flag
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      first = FALSE;
-   }
-   return TRUE;
-}
-#endif // !STB_VORBIS_NO_PUSHDATA_API
-
-static int stbv_start_decoder(stbv_vorb *f)
-{
-   stbv_uint8 header[6], x,y;
-   int len,i,j,k, max_submaps = 0;
-   int longest_floorlist=0;
-
-   // first page, first packet
-
-   if (!stbv_start_page(f))                              return FALSE;
-   // validate page flag
-   if (!(f->page_flag & STBV_PAGEFLAG_first_page))       return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->page_flag & STBV_PAGEFLAG_last_page)           return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->page_flag & STBV_PAGEFLAG_continued_packet)    return stbv_error(f, VORBIS_invalid_first_page);
-   // check for expected packet length
-   if (f->segment_count != 1)                       return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->segments[0] != 30)                        return stbv_error(f, VORBIS_invalid_first_page);
-   // read packet
-   // check packet header
-   if (stbv_get8(f) != STBV_VORBIS_packet_id)                 return stbv_error(f, VORBIS_invalid_first_page);
-   if (!stbv_getn(f, header, 6))                         return stbv_error(f, VORBIS_unexpected_eof);
-   if (!stbv_vorbis_validate(header))                    return stbv_error(f, VORBIS_invalid_first_page);
-   // vorbis_version
-   if (stbv_get32(f) != 0)                               return stbv_error(f, VORBIS_invalid_first_page);
-   f->channels = stbv_get8(f); if (!f->channels)         return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->channels > STB_VORBIS_MAX_CHANNELS)       return stbv_error(f, VORBIS_too_many_channels);
-   f->sample_rate = stbv_get32(f); if (!f->sample_rate)  return stbv_error(f, VORBIS_invalid_first_page);
-   stbv_get32(f); // bitrate_maximum
-   stbv_get32(f); // bitrate_nominal
-   stbv_get32(f); // bitrate_minimum
-   x = stbv_get8(f);
-   {
-      int log0,log1;
-      log0 = x & 15;
-      log1 = x >> 4;
-      f->blocksize_0 = 1 << log0;
-      f->blocksize_1 = 1 << log1;
-      if (log0 < 6 || log0 > 13)                       return stbv_error(f, VORBIS_invalid_setup);
-      if (log1 < 6 || log1 > 13)                       return stbv_error(f, VORBIS_invalid_setup);
-      if (log0 > log1)                                 return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   // framing_flag
-   x = stbv_get8(f);
-   if (!(x & 1))                                    return stbv_error(f, VORBIS_invalid_first_page);
-
-   // second packet!
-   if (!stbv_start_page(f))                              return FALSE;
-
-   if (!stbv_start_packet(f))                            return FALSE;
-   do {
-      len = stbv_next_segment(f);
-      stbv_skip(f, len);
-      f->bytes_in_seg = 0;
-   } while (len);
-
-   // third packet!
-   if (!stbv_start_packet(f))                            return FALSE;
-
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (STBV_IS_PUSH_MODE(f)) {
-      if (!stbv_is_whole_packet_present(f, TRUE)) {
-         // convert error in ogg header to write type
-         if (f->error == VORBIS_invalid_stream)
-            f->error = VORBIS_invalid_setup;
-         return FALSE;
-      }
-   }
-   #endif
-
-   stbv_crc32_init(); // always init it, to avoid multithread race conditions
-
-   if (stbv_get8_packet(f) != STBV_VORBIS_packet_setup)       return stbv_error(f, VORBIS_invalid_setup);
-   for (i=0; i < 6; ++i) header[i] = stbv_get8_packet(f);
-   if (!stbv_vorbis_validate(header))                    return stbv_error(f, VORBIS_invalid_setup);
-
-   // codebooks
-
-   f->codebook_count = stbv_get_bits(f,8) + 1;
-   f->codebooks = (StbvCodebook *) stbv_setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
-   if (f->codebooks == NULL)                        return stbv_error(f, VORBIS_outofmem);
-   memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
-   for (i=0; i < f->codebook_count; ++i) {
-      stbv_uint32 *values;
-      int ordered, sorted_count;
-      int total=0;
-      stbv_uint8 *lengths;
-      StbvCodebook *c = f->codebooks+i;
-      STBV_CHECK(f);
-      x = stbv_get_bits(f, 8); if (x != 0x42)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8); if (x != 0x43)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8); if (x != 0x56)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8);
-      c->dimensions = (stbv_get_bits(f, 8)<<8) + x;
-      x = stbv_get_bits(f, 8);
-      y = stbv_get_bits(f, 8);
-      c->entries = (stbv_get_bits(f, 8)<<16) + (y<<8) + x;
-      ordered = stbv_get_bits(f,1);
-      c->sparse = ordered ? 0 : stbv_get_bits(f,1);
-
-      if (c->dimensions == 0 && c->entries != 0)    return stbv_error(f, VORBIS_invalid_setup);
-
-      if (c->sparse)
-         lengths = (stbv_uint8 *) stbv_setup_temp_malloc(f, c->entries);
-      else
-         lengths = c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
-
-      if (!lengths) return stbv_error(f, VORBIS_outofmem);
-
-      if (ordered) {
-         int current_entry = 0;
-         int current_length = stbv_get_bits(f,5) + 1;
-         while (current_entry < c->entries) {
-            int limit = c->entries - current_entry;
-            int n = stbv_get_bits(f, stbv_ilog(limit));
-            if (current_entry + n > (int) c->entries) { return stbv_error(f, VORBIS_invalid_setup); }
-            memset(lengths + current_entry, current_length, n);
-            current_entry += n;
-            ++current_length;
-         }
-      } else {
-         for (j=0; j < c->entries; ++j) {
-            int present = c->sparse ? stbv_get_bits(f,1) : 1;
-            if (present) {
-               lengths[j] = stbv_get_bits(f, 5) + 1;
-               ++total;
-               if (lengths[j] == 32)
-                  return stbv_error(f, VORBIS_invalid_setup);
-            } else {
-               lengths[j] = NO_CODE;
-            }
-         }
-      }
-
-      if (c->sparse && total >= c->entries >> 2) {
-         // convert sparse items to non-sparse!
-         if (c->entries > (int) f->setup_temp_memory_required)
-            f->setup_temp_memory_required = c->entries;
-
-         c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
-         if (c->codeword_lengths == NULL) return stbv_error(f, VORBIS_outofmem);
-         memcpy(c->codeword_lengths, lengths, c->entries);
-         stbv_setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
-         lengths = c->codeword_lengths;
-         c->sparse = 0;
-      }
-
-      // compute the size of the sorted tables
-      if (c->sparse) {
-         sorted_count = total;
-      } else {
-         sorted_count = 0;
-         #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-         for (j=0; j < c->entries; ++j)
-            if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
-               ++sorted_count;
-         #endif
-      }
-
-      c->sorted_entries = sorted_count;
-      values = NULL;
-
-      STBV_CHECK(f);
-      if (!c->sparse) {
-         c->codewords = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
-         if (!c->codewords)                  return stbv_error(f, VORBIS_outofmem);
-      } else {
-         unsigned int size;
-         if (c->sorted_entries) {
-            c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->sorted_entries);
-            if (!c->codeword_lengths)           return stbv_error(f, VORBIS_outofmem);
-            c->codewords = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
-            if (!c->codewords)                  return stbv_error(f, VORBIS_outofmem);
-            values = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
-            if (!values)                        return stbv_error(f, VORBIS_outofmem);
-         }
-         size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
-         if (size > f->setup_temp_memory_required)
-            f->setup_temp_memory_required = size;
-      }
-
-      if (!stbv_compute_codewords(c, lengths, c->entries, values)) {
-         if (c->sparse) stbv_setup_temp_free(f, values, 0);
-         return stbv_error(f, VORBIS_invalid_setup);
-      }
-
-      if (c->sorted_entries) {
-         // allocate an extra slot for sentinels
-         c->sorted_codewords = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
-         if (c->sorted_codewords == NULL) return stbv_error(f, VORBIS_outofmem);
-         // allocate an extra slot at the front so that c->sorted_values[-1] is defined
-         // so that we can catch that case without an extra if
-         c->sorted_values    = ( int   *) stbv_setup_malloc(f, sizeof(*c->sorted_values   ) * (c->sorted_entries+1));
-         if (c->sorted_values == NULL) return stbv_error(f, VORBIS_outofmem);
-         ++c->sorted_values;
-         c->sorted_values[-1] = -1;
-         stbv_compute_sorted_huffman(c, lengths, values);
-      }
-
-      if (c->sparse) {
-         stbv_setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
-         stbv_setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
-         stbv_setup_temp_free(f, lengths, c->entries);
-         c->codewords = NULL;
-      }
-
-      stbv_compute_accelerated_huffman(c);
-
-      STBV_CHECK(f);
-      c->lookup_type = stbv_get_bits(f, 4);
-      if (c->lookup_type > 2) return stbv_error(f, VORBIS_invalid_setup);
-      if (c->lookup_type > 0) {
-         stbv_uint16 *mults;
-         c->minimum_value = stbv_float32_unpack(stbv_get_bits(f, 32));
-         c->delta_value = stbv_float32_unpack(stbv_get_bits(f, 32));
-         c->value_bits = stbv_get_bits(f, 4)+1;
-         c->sequence_p = stbv_get_bits(f,1);
-         if (c->lookup_type == 1) {
-            c->lookup_values = stbv_lookup1_values(c->entries, c->dimensions);
-         } else {
-            c->lookup_values = c->entries * c->dimensions;
-         }
-         if (c->lookup_values == 0) return stbv_error(f, VORBIS_invalid_setup);
-         mults = (stbv_uint16 *) stbv_setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
-         if (mults == NULL) return stbv_error(f, VORBIS_outofmem);
-         for (j=0; j < (int) c->lookup_values; ++j) {
-            int q = stbv_get_bits(f, c->value_bits);
-            if (q == STBV_EOP) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_invalid_setup); }
-            mults[j] = q;
-         }
-
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-         if (c->lookup_type == 1) {
-            int len, sparse = c->sparse;
-            float last=0;
-            // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
-            if (sparse) {
-               if (c->sorted_entries == 0) goto stbv_skip;
-               c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
-            } else
-               c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries        * c->dimensions);
-            if (c->multiplicands == NULL) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
-            len = sparse ? c->sorted_entries : c->entries;
-            for (j=0; j < len; ++j) {
-               unsigned int z = sparse ? c->sorted_values[j] : j;
-               unsigned int div=1;
-               for (k=0; k < c->dimensions; ++k) {
-                  int off = (z / div) % c->lookup_values;
-                  float val = mults[off];
-                  val = mults[off]*c->delta_value + c->minimum_value + last;
-                  c->multiplicands[j*c->dimensions + k] = val;
-                  if (c->sequence_p)
-                     last = val;
-                  if (k+1 < c->dimensions) {
-                     if (div > UINT_MAX / (unsigned int) c->lookup_values) {
-                        stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
-                        return stbv_error(f, VORBIS_invalid_setup);
-                     }
-                     div *= c->lookup_values;
-                  }
-               }
-            }
-            c->lookup_type = 2;
-         }
-         else
-#endif
-         {
-            float last=0;
-            STBV_CHECK(f);
-            c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
-            if (c->multiplicands == NULL) { stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
-            for (j=0; j < (int) c->lookup_values; ++j) {
-               float val = mults[j] * c->delta_value + c->minimum_value + last;
-               c->multiplicands[j] = val;
-               if (c->sequence_p)
-                  last = val;
-            }
-         }
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-        stbv_skip:;
-#endif
-         stbv_setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
-
-         STBV_CHECK(f);
-      }
-      STBV_CHECK(f);
-   }
-
-   // time domain transfers (notused)
-
-   x = stbv_get_bits(f, 6) + 1;
-   for (i=0; i < x; ++i) {
-      stbv_uint32 z = stbv_get_bits(f, 16);
-      if (z != 0) return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   // Floors
-   f->floor_count = stbv_get_bits(f, 6)+1;
-   f->floor_config = (StbvFloor *)  stbv_setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
-   if (f->floor_config == NULL) return stbv_error(f, VORBIS_outofmem);
-   for (i=0; i < f->floor_count; ++i) {
-      f->floor_types[i] = stbv_get_bits(f, 16);
-      if (f->floor_types[i] > 1) return stbv_error(f, VORBIS_invalid_setup);
-      if (f->floor_types[i] == 0) {
-         StbvFloor0 *g = &f->floor_config[i].floor0;
-         g->order = stbv_get_bits(f,8);
-         g->rate = stbv_get_bits(f,16);
-         g->bark_map_size = stbv_get_bits(f,16);
-         g->amplitude_bits = stbv_get_bits(f,6);
-         g->amplitude_offset = stbv_get_bits(f,8);
-         g->number_of_books = stbv_get_bits(f,4) + 1;
-         for (j=0; j < g->number_of_books; ++j)
-            g->book_list[j] = stbv_get_bits(f,8);
-         return stbv_error(f, VORBIS_feature_not_supported);
-      } else {
-         stbv_floor_ordering p[31*8+2];
-         StbvFloor1 *g = &f->floor_config[i].floor1;
-         int max_class = -1; 
-         g->partitions = stbv_get_bits(f, 5);
-         for (j=0; j < g->partitions; ++j) {
-            g->partition_class_list[j] = stbv_get_bits(f, 4);
-            if (g->partition_class_list[j] > max_class)
-               max_class = g->partition_class_list[j];
-         }
-         for (j=0; j <= max_class; ++j) {
-            g->class_dimensions[j] = stbv_get_bits(f, 3)+1;
-            g->class_subclasses[j] = stbv_get_bits(f, 2);
-            if (g->class_subclasses[j]) {
-               g->class_masterbooks[j] = stbv_get_bits(f, 8);
-               if (g->class_masterbooks[j] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            }
-            for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
-               g->subclass_books[j][k] = stbv_get_bits(f,8)-1;
-               if (g->subclass_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            }
-         }
-         g->floor1_multiplier = stbv_get_bits(f,2)+1;
-         g->rangebits = stbv_get_bits(f,4);
-         g->Xlist[0] = 0;
-         g->Xlist[1] = 1 << g->rangebits;
-         g->values = 2;
-         for (j=0; j < g->partitions; ++j) {
-            int c = g->partition_class_list[j];
-            for (k=0; k < g->class_dimensions[c]; ++k) {
-               g->Xlist[g->values] = stbv_get_bits(f, g->rangebits);
-               ++g->values;
-            }
-         }
-         // precompute the sorting
-         for (j=0; j < g->values; ++j) {
-            p[j].x = g->Xlist[j];
-            p[j].id = j;
-         }
-         qsort(p, g->values, sizeof(p[0]), stbv_point_compare);
-         for (j=0; j < g->values; ++j)
-            g->sorted_order[j] = (stbv_uint8) p[j].id;
-         // precompute the stbv_neighbors
-         for (j=2; j < g->values; ++j) {
-            int low,hi;
-            stbv_neighbors(g->Xlist, j, &low,&hi);
-            g->stbv_neighbors[j][0] = low;
-            g->stbv_neighbors[j][1] = hi;
-         }
-
-         if (g->values > longest_floorlist)
-            longest_floorlist = g->values;
-      }
-   }
-
-   // StbvResidue
-   f->residue_count = stbv_get_bits(f, 6)+1;
-   f->residue_config = (StbvResidue *) stbv_setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
-   if (f->residue_config == NULL) return stbv_error(f, VORBIS_outofmem);
-   memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
-   for (i=0; i < f->residue_count; ++i) {
-      stbv_uint8 residue_cascade[64];
-      StbvResidue *r = f->residue_config+i;
-      f->residue_types[i] = stbv_get_bits(f, 16);
-      if (f->residue_types[i] > 2) return stbv_error(f, VORBIS_invalid_setup);
-      r->begin = stbv_get_bits(f, 24);
-      r->end = stbv_get_bits(f, 24);
-      if (r->end < r->begin) return stbv_error(f, VORBIS_invalid_setup);
-      r->part_size = stbv_get_bits(f,24)+1;
-      r->classifications = stbv_get_bits(f,6)+1;
-      r->classbook = stbv_get_bits(f,8);
-      if (r->classbook >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-      for (j=0; j < r->classifications; ++j) {
-         stbv_uint8 high_bits=0;
-         stbv_uint8 low_bits=stbv_get_bits(f,3);
-         if (stbv_get_bits(f,1))
-            high_bits = stbv_get_bits(f,5);
-         residue_cascade[j] = high_bits*8 + low_bits;
-      }
-      r->residue_books = (short (*)[8]) stbv_setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
-      if (r->residue_books == NULL) return stbv_error(f, VORBIS_outofmem);
-      for (j=0; j < r->classifications; ++j) {
-         for (k=0; k < 8; ++k) {
-            if (residue_cascade[j] & (1 << k)) {
-               r->residue_books[j][k] = stbv_get_bits(f, 8);
-               if (r->residue_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            } else {
-               r->residue_books[j][k] = -1;
-            }
-         }
-      }
-      // precompute the classifications[] array to avoid inner-loop mod/divide
-      // call it 'classdata' since we already have r->classifications
-      r->classdata = (stbv_uint8 **) stbv_setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
-      if (!r->classdata) return stbv_error(f, VORBIS_outofmem);
-      memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
-      for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
-         int classwords = f->codebooks[r->classbook].dimensions;
-         int temp = j;
-         r->classdata[j] = (stbv_uint8 *) stbv_setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
-         if (r->classdata[j] == NULL) return stbv_error(f, VORBIS_outofmem);
-         for (k=classwords-1; k >= 0; --k) {
-            r->classdata[j][k] = temp % r->classifications;
-            temp /= r->classifications;
-         }
-      }
-   }
-
-   f->mapping_count = stbv_get_bits(f,6)+1;
-   f->mapping = (StbvMapping *) stbv_setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
-   if (f->mapping == NULL) return stbv_error(f, VORBIS_outofmem);
-   memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
-   for (i=0; i < f->mapping_count; ++i) {
-      StbvMapping *m = f->mapping + i;      
-      int mapping_type = stbv_get_bits(f,16);
-      if (mapping_type != 0) return stbv_error(f, VORBIS_invalid_setup);
-      m->chan = (StbvMappingChannel *) stbv_setup_malloc(f, f->channels * sizeof(*m->chan));
-      if (m->chan == NULL) return stbv_error(f, VORBIS_outofmem);
-      if (stbv_get_bits(f,1))
-         m->submaps = stbv_get_bits(f,4)+1;
-      else
-         m->submaps = 1;
-      if (m->submaps > max_submaps)
-         max_submaps = m->submaps;
-      if (stbv_get_bits(f,1)) {
-         m->coupling_steps = stbv_get_bits(f,8)+1;
-         for (k=0; k < m->coupling_steps; ++k) {
-            m->chan[k].magnitude = stbv_get_bits(f, stbv_ilog(f->channels-1));
-            m->chan[k].angle = stbv_get_bits(f, stbv_ilog(f->channels-1));
-            if (m->chan[k].magnitude >= f->channels)        return stbv_error(f, VORBIS_invalid_setup);
-            if (m->chan[k].angle     >= f->channels)        return stbv_error(f, VORBIS_invalid_setup);
-            if (m->chan[k].magnitude == m->chan[k].angle)   return stbv_error(f, VORBIS_invalid_setup);
-         }
-      } else
-         m->coupling_steps = 0;
-
-      // reserved field
-      if (stbv_get_bits(f,2)) return stbv_error(f, VORBIS_invalid_setup);
-      if (m->submaps > 1) {
-         for (j=0; j < f->channels; ++j) {
-            m->chan[j].mux = stbv_get_bits(f, 4);
-            if (m->chan[j].mux >= m->submaps)                return stbv_error(f, VORBIS_invalid_setup);
-         }
-      } else
-         // @SPECIFICATION: this case is missing from the spec
-         for (j=0; j < f->channels; ++j)
-            m->chan[j].mux = 0;
-
-      for (j=0; j < m->submaps; ++j) {
-         stbv_get_bits(f,8); // discard
-         m->submap_floor[j] = stbv_get_bits(f,8);
-         m->submap_residue[j] = stbv_get_bits(f,8);
-         if (m->submap_floor[j] >= f->floor_count)      return stbv_error(f, VORBIS_invalid_setup);
-         if (m->submap_residue[j] >= f->residue_count)  return stbv_error(f, VORBIS_invalid_setup);
-      }
-   }
-
-   // Modes
-   f->mode_count = stbv_get_bits(f, 6)+1;
-   for (i=0; i < f->mode_count; ++i) {
-      StbvMode *m = f->mode_config+i;
-      m->blockflag = stbv_get_bits(f,1);
-      m->windowtype = stbv_get_bits(f,16);
-      m->transformtype = stbv_get_bits(f,16);
-      m->mapping = stbv_get_bits(f,8);
-      if (m->windowtype != 0)                 return stbv_error(f, VORBIS_invalid_setup);
-      if (m->transformtype != 0)              return stbv_error(f, VORBIS_invalid_setup);
-      if (m->mapping >= f->mapping_count)     return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   stbv_flush_packet(f);
-
-   f->previous_length = 0;
-
-   for (i=0; i < f->channels; ++i) {
-      f->channel_buffers[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1);
-      f->previous_window[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
-      f->finalY[i]          = (stbv_int16 *) stbv_setup_malloc(f, sizeof(stbv_int16) * longest_floorlist);
-      if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return stbv_error(f, VORBIS_outofmem);
-      memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1);
-      #ifdef STB_VORBIS_NO_DEFER_FLOOR
-      f->floor_buffers[i]   = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
-      if (f->floor_buffers[i] == NULL) return stbv_error(f, VORBIS_outofmem);
-      #endif
-   }
-
-   if (!stbv_init_blocksize(f, 0, f->blocksize_0)) return FALSE;
-   if (!stbv_init_blocksize(f, 1, f->blocksize_1)) return FALSE;
-   f->blocksize[0] = f->blocksize_0;
-   f->blocksize[1] = f->blocksize_1;
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-   if (stbv_integer_divide_table[1][1]==0)
-      for (i=0; i < STBV_DIVTAB_NUMER; ++i)
-         for (j=1; j < STBV_DIVTAB_DENOM; ++j)
-            stbv_integer_divide_table[i][j] = i / j;
-#endif
-
-   // compute how much temporary memory is needed
-
-   // 1.
-   {
-      stbv_uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
-      stbv_uint32 classify_mem;
-      int i,max_part_read=0;
-      for (i=0; i < f->residue_count; ++i) {
-         StbvResidue *r = f->residue_config + i;
-         unsigned int actual_size = f->blocksize_1 / 2;
-         unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
-         unsigned int limit_r_end   = r->end   < actual_size ? r->end   : actual_size;
-         int n_read = limit_r_end - limit_r_begin;
-         int part_read = n_read / r->part_size;
-         if (part_read > max_part_read)
-            max_part_read = part_read;
-      }
-      #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-      classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(stbv_uint8 *));
-      #else
-      classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
-      #endif
-
-      // maximum reasonable partition size is f->blocksize_1
-
-      f->temp_memory_required = classify_mem;
-      if (imdct_mem > f->temp_memory_required)
-         f->temp_memory_required = imdct_mem;
-   }
-
-   f->first_decode = TRUE;
-
-   if (f->alloc.alloc_buffer) {
-      assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
-      // check if there's enough temp memory so we don't error later
-      if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
-         return stbv_error(f, VORBIS_outofmem);
-   }
-
-   f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
-
-   return TRUE;
-}
-
-static void stbv_vorbis_deinit(stb_vorbis *p)
-{
-   int i,j;
-   if (p->residue_config) {
-      for (i=0; i < p->residue_count; ++i) {
-         StbvResidue *r = p->residue_config+i;
-         if (r->classdata) {
-            for (j=0; j < p->codebooks[r->classbook].entries; ++j)
-               stbv_setup_free(p, r->classdata[j]);
-            stbv_setup_free(p, r->classdata);
-         }
-         stbv_setup_free(p, r->residue_books);
-      }
-   }
-
-   if (p->codebooks) {
-      STBV_CHECK(p);
-      for (i=0; i < p->codebook_count; ++i) {
-         StbvCodebook *c = p->codebooks + i;
-         stbv_setup_free(p, c->codeword_lengths);
-         stbv_setup_free(p, c->multiplicands);
-         stbv_setup_free(p, c->codewords);
-         stbv_setup_free(p, c->sorted_codewords);
-         // c->sorted_values[-1] is the first entry in the array
-         stbv_setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
-      }
-      stbv_setup_free(p, p->codebooks);
-   }
-   stbv_setup_free(p, p->floor_config);
-   stbv_setup_free(p, p->residue_config);
-   if (p->mapping) {
-      for (i=0; i < p->mapping_count; ++i)
-         stbv_setup_free(p, p->mapping[i].chan);
-      stbv_setup_free(p, p->mapping);
-   }
-   STBV_CHECK(p);
-   for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
-      stbv_setup_free(p, p->channel_buffers[i]);
-      stbv_setup_free(p, p->previous_window[i]);
-      #ifdef STB_VORBIS_NO_DEFER_FLOOR
-      stbv_setup_free(p, p->floor_buffers[i]);
-      #endif
-      stbv_setup_free(p, p->finalY[i]);
-   }
-   for (i=0; i < 2; ++i) {
-      stbv_setup_free(p, p->A[i]);
-      stbv_setup_free(p, p->B[i]);
-      stbv_setup_free(p, p->C[i]);
-      stbv_setup_free(p, p->window[i]);
-      stbv_setup_free(p, p->stbv_bit_reverse[i]);
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   if (p->close_on_free) fclose(p->f);
-   #endif
-}
-
-STBVDEF void stb_vorbis_close(stb_vorbis *p)
-{
-   if (p == NULL) return;
-   stbv_vorbis_deinit(p);
-   stbv_setup_free(p,p);
-}
-
-static void stbv_vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
-{
-   memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
-   if (z) {
-      p->alloc = *z;
-      p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
-      p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
-   }
-   p->eof = 0;
-   p->error = VORBIS__no_error;
-   p->stream = NULL;
-   p->codebooks = NULL;
-   p->page_crc_tests = -1;
-   #ifndef STB_VORBIS_NO_STDIO
-   p->close_on_free = FALSE;
-   p->f = NULL;
-   #endif
-}
-
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f)
-{
-   if (f->current_loc_valid)
-      return f->current_loc;
-   else
-      return -1;
-}
-
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
-{
-   stb_vorbis_info d;
-   d.channels = f->channels;
-   d.sample_rate = f->sample_rate;
-   d.setup_memory_required = f->setup_memory_required;
-   d.setup_temp_memory_required = f->setup_temp_memory_required;
-   d.temp_memory_required = f->temp_memory_required;
-   d.max_frame_size = f->blocksize_1 >> 1;
-   return d;
-}
-
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f)
-{
-   int e = f->error;
-   f->error = VORBIS__no_error;
-   return e;
-}
-
-static stb_vorbis * stbv_vorbis_alloc(stb_vorbis *f)
-{
-   stb_vorbis *p = (stb_vorbis *) stbv_setup_malloc(f, sizeof(*p));
-   return p;
-}
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f)
-{
-   f->previous_length = 0;
-   f->page_crc_tests  = 0;
-   f->discard_samples_deferred = 0;
-   f->current_loc_valid = FALSE;
-   f->first_decode = FALSE;
-   f->samples_output = 0;
-   f->channel_buffer_start = 0;
-   f->channel_buffer_end = 0;
-}
-
-static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data, int data_len)
-{
-   int i,n;
-   for (i=0; i < f->page_crc_tests; ++i)
-      f->scan[i].bytes_done = 0;
-
-   // if we have room for more scans, search for them first, because
-   // they may cause us to stop early if their header is incomplete
-   if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) {
-      if (data_len < 4) return 0;
-      data_len -= 3; // need to look for 4-byte sequence, so don't miss
-                     // one that straddles a boundary
-      for (i=0; i < data_len; ++i) {
-         if (data[i] == 0x4f) {
-            if (0==memcmp(data+i, stbv_ogg_page_header, 4)) {
-               int j,len;
-               stbv_uint32 crc;
-               // make sure we have the whole page header
-               if (i+26 >= data_len || i+27+data[i+26] >= data_len) {
-                  // only read up to this page start, so hopefully we'll
-                  // have the whole page header start next time
-                  data_len = i;
-                  break;
-               }
-               // ok, we have it all; compute the length of the page
-               len = 27 + data[i+26];
-               for (j=0; j < data[i+26]; ++j)
-                  len += data[i+27+j];
-               // scan everything up to the embedded crc (which we must 0)
-               crc = 0;
-               for (j=0; j < 22; ++j)
-                  crc = stbv_crc32_update(crc, data[i+j]);
-               // now process 4 0-bytes
-               for (   ; j < 26; ++j)
-                  crc = stbv_crc32_update(crc, 0);
-               // len is the total number of bytes we need to scan
-               n = f->page_crc_tests++;
-               f->scan[n].bytes_left = len-j;
-               f->scan[n].crc_so_far = crc;
-               f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24);
-               // if the last frame on a page is continued to the next, then
-               // we can't recover the sample_loc immediately
-               if (data[i+27+data[i+26]-1] == 255)
-                  f->scan[n].sample_loc = ~0;
-               else
-                  f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24);
-               f->scan[n].bytes_done = i+j;
-               if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT)
-                  break;
-               // keep going if we still have room for more
-            }
-         }
-      }
-   }
-
-   for (i=0; i < f->page_crc_tests;) {
-      stbv_uint32 crc;
-      int j;
-      int n = f->scan[i].bytes_done;
-      int m = f->scan[i].bytes_left;
-      if (m > data_len - n) m = data_len - n;
-      // m is the bytes to scan in the current chunk
-      crc = f->scan[i].crc_so_far;
-      for (j=0; j < m; ++j)
-         crc = stbv_crc32_update(crc, data[n+j]);
-      f->scan[i].bytes_left -= m;
-      f->scan[i].crc_so_far = crc;
-      if (f->scan[i].bytes_left == 0) {
-         // does it match?
-         if (f->scan[i].crc_so_far == f->scan[i].goal_crc) {
-            // Houston, we have page
-            data_len = n+m; // consumption amount is wherever that scan ended
-            f->page_crc_tests = -1; // drop out of page scan mode
-            f->previous_length = 0; // decode-but-don't-output one frame
-            f->next_seg = -1;       // start a new page
-            f->current_loc = f->scan[i].sample_loc; // set the current sample location
-                                    // to the amount we'd have decoded had we decoded this page
-            f->current_loc_valid = f->current_loc != ~0U;
-            return data_len;
-         }
-         // delete entry
-         f->scan[i] = f->scan[--f->page_crc_tests];
-      } else {
-         ++i;
-      }
-   }
-
-   return data_len;
-}
-
-// return value: number of bytes we used
-STBVDEF int stb_vorbis_decode_frame_pushdata(
-         stb_vorbis *f,                   // the file we're decoding
-         const stbv_uint8 *data, int data_len, // the memory available for decoding
-         int *channels,                   // place to write number of float * buffers
-         float ***output,                 // place to write float ** array of float * buffers
-         int *samples                     // place to write number of output samples
-     )
-{
-   int i;
-   int len,right,left;
-
-   if (!STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   if (f->page_crc_tests >= 0) {
-      *samples = 0;
-      return stbv_vorbis_search_for_page_pushdata(f, (stbv_uint8 *) data, data_len);
-   }
-
-   f->stream     = (stbv_uint8 *) data;
-   f->stream_end = (stbv_uint8 *) data + data_len;
-   f->error      = VORBIS__no_error;
-
-   // check that we have the entire packet in memory
-   if (!stbv_is_whole_packet_present(f, FALSE)) {
-      *samples = 0;
-      return 0;
-   }
-
-   if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
-      // save the actual error we encountered
-      enum STBVorbisError error = f->error;
-      if (error == VORBIS_bad_packet_type) {
-         // flush and resynch
-         f->error = VORBIS__no_error;
-         while (stbv_get8_packet(f) != STBV_EOP)
-            if (f->eof) break;
-         *samples = 0;
-         return (int) (f->stream - data);
-      }
-      if (error == VORBIS_continued_packet_flag_invalid) {
-         if (f->previous_length == 0) {
-            // we may be resynching, in which case it's ok to hit one
-            // of these; just discard the packet
-            f->error = VORBIS__no_error;
-            while (stbv_get8_packet(f) != STBV_EOP)
-               if (f->eof) break;
-            *samples = 0;
-            return (int) (f->stream - data);
-         }
-      }
-      // if we get an error while parsing, what to do?
-      // well, it DEFINITELY won't work to continue from where we are!
-      stb_vorbis_flush_pushdata(f);
-      // restore the error that actually made us bail
-      f->error = error;
-      *samples = 0;
-      return 1;
-   }
-
-   // success!
-   len = stbv_vorbis_finish_frame(f, len, left, right);
-   for (i=0; i < f->channels; ++i)
-      f->outputs[i] = f->channel_buffers[i] + left;
-
-   if (channels) *channels = f->channels;
-   *samples = len;
-   *output = f->outputs;
-   return (int) (f->stream - data);
-}
-
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
-         const unsigned char *data, int data_len, // the memory available for decoding
-         int *data_used,              // only defined if result is not NULL
-         int *error, const stb_vorbis_alloc *alloc)
-{
-   stb_vorbis *f, p;
-   stbv_vorbis_init(&p, alloc);
-   p.stream     = (stbv_uint8 *) data;
-   p.stream_end = (stbv_uint8 *) data + data_len;
-   p.push_mode  = TRUE;
-   if (!stbv_start_decoder(&p)) {
-      if (p.eof)
-         *error = VORBIS_need_more_data;
-      else
-         *error = p.error;
-      return NULL;
-   }
-   f = stbv_vorbis_alloc(&p);
-   if (f) {
-      *f = p;
-      *data_used = (int) (f->stream - data);
-      *error = 0;
-      return f;
-   } else {
-      stbv_vorbis_deinit(&p);
-      return NULL;
-   }
-}
-#endif // STB_VORBIS_NO_PUSHDATA_API
-
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
-{
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (f->push_mode) return 0;
-   #endif
-   if (STBV_USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
-   #ifndef STB_VORBIS_NO_STDIO
-   return (unsigned int) (ftell(f->f) - f->f_start);
-   #endif
-}
-
-#ifndef STB_VORBIS_NO_PULLDATA_API
-//
-// DATA-PULLING API
-//
-
-static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_uint32 *last)
-{
-   for(;;) {
-      int n;
-      if (f->eof) return 0;
-      n = stbv_get8(f);
-      if (n == 0x4f) { // page header candidate
-         unsigned int retry_loc = stb_vorbis_get_file_offset(f);
-         int i;
-         // check if we're off the end of a file_section stream
-         if (retry_loc - 25 > f->stream_len)
-            return 0;
-         // check the rest of the header
-         for (i=1; i < 4; ++i)
-            if (stbv_get8(f) != stbv_ogg_page_header[i])
-               break;
-         if (f->eof) return 0;
-         if (i == 4) {
-            stbv_uint8 header[27];
-            stbv_uint32 i, crc, goal, len;
-            for (i=0; i < 4; ++i)
-               header[i] = stbv_ogg_page_header[i];
-            for (; i < 27; ++i)
-               header[i] = stbv_get8(f);
-            if (f->eof) return 0;
-            if (header[4] != 0) goto invalid;
-            goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24);
-            for (i=22; i < 26; ++i)
-               header[i] = 0;
-            crc = 0;
-            for (i=0; i < 27; ++i)
-               crc = stbv_crc32_update(crc, header[i]);
-            len = 0;
-            for (i=0; i < header[26]; ++i) {
-               int s = stbv_get8(f);
-               crc = stbv_crc32_update(crc, s);
-               len += s;
-            }
-            if (len && f->eof) return 0;
-            for (i=0; i < len; ++i)
-               crc = stbv_crc32_update(crc, stbv_get8(f));
-            // finished parsing probable page
-            if (crc == goal) {
-               // we could now check that it's either got the last
-               // page flag set, OR it's followed by the capture
-               // pattern, but I guess TECHNICALLY you could have
-               // a file with garbage between each ogg page and recover
-               // from it automatically? So even though that paranoia
-               // might decrease the chance of an invalid decode by
-               // another 2^32, not worth it since it would hose those
-               // invalid-but-useful files?
-               if (end)
-                  *end = stb_vorbis_get_file_offset(f);
-               if (last) {
-                  if (header[5] & 0x04)
-                     *last = 1;
-                  else
-                     *last = 0;
-               }
-               stbv_set_file_offset(f, retry_loc-1);
-               return 1;
-            }
-         }
-        invalid:
-         // not a valid page, so rewind and look for next one
-         stbv_set_file_offset(f, retry_loc);
-      }
-   }
-}
-
-
-#define STBV_SAMPLE_unknown  0xffffffff
-
-// seeking is implemented with a binary search, which narrows down the range to
-// 64K, before using a linear search (because finding the synchronization
-// pattern can be expensive, and the chance we'd find the end page again is
-// relatively high for small ranges)
-//
-// two initial interpolation-style probes are used at the start of the search
-// to try to bound either side of the binary search sensibly, while still
-// working in O(log n) time if they fail.
-
-static int stbv_get_seek_page_info(stb_vorbis *f, StbvProbedPage *z)
-{
-   stbv_uint8 header[27], lacing[255];
-   int i,len;
-
-   // record where the page starts
-   z->page_start = stb_vorbis_get_file_offset(f);
-
-   // parse the header
-   stbv_getn(f, header, 27);
-   if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
-      return 0;
-   stbv_getn(f, lacing, header[26]);
-
-   // determine the length of the payload
-   len = 0;
-   for (i=0; i < header[26]; ++i)
-      len += lacing[i];
-
-   // this implies where the page ends
-   z->page_end = z->page_start + 27 + header[26] + len;
-
-   // read the last-decoded sample out of the data
-   z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
-
-   // restore file state to where we were
-   stbv_set_file_offset(f, z->page_start);
-   return 1;
-}
-
-// rarely used function to seek back to the preceeding page while finding the
-// start of a packet
-static int stbv_go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
-{
-   unsigned int previous_safe, end;
-
-   // now we want to seek back 64K from the limit
-   if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset)
-      previous_safe = limit_offset - 65536;
-   else
-      previous_safe = f->first_audio_page_offset;
-
-   stbv_set_file_offset(f, previous_safe);
-
-   while (stbv_vorbis_find_page(f, &end, NULL)) {
-      if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
-         return 1;
-      stbv_set_file_offset(f, end);
-   }
-
-   return 0;
-}
-
-// implements the search logic for finding a page and starting decoding. if
-// the function succeeds, current_loc_valid will be true and current_loc will
-// be less than or equal to the provided sample number (the closer the
-// better).
-static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
-{
-   StbvProbedPage left, right, mid;
-   int i, start_seg_with_known_loc, end_pos, page_start;
-   stbv_uint32 delta, stream_length, padding;
-   double offset, bytes_per_sample;
-   int probe = 0;
-
-   // find the last page and validate the target sample
-   stream_length = stb_vorbis_stream_length_in_samples(f);
-   if (stream_length == 0)            return stbv_error(f, VORBIS_seek_without_length);
-   if (sample_number > stream_length) return stbv_error(f, VORBIS_seek_invalid);
-
-   // this is the maximum difference between the window-center (which is the
-   // actual granule position value), and the right-start (which the spec
-   // indicates should be the granule position (give or take one)).
-   padding = ((f->blocksize_1 - f->blocksize_0) >> 2);
-   if (sample_number < padding)
-      sample_number = 0;
-   else
-      sample_number -= padding;
-
-   left = f->p_first;
-   while (left.last_decoded_sample == ~0U) {
-      // (untested) the first page does not have a 'last_decoded_sample'
-      stbv_set_file_offset(f, left.page_end);
-      if (!stbv_get_seek_page_info(f, &left)) goto error;
-   }
-
-   right = f->p_last;
-   assert(right.last_decoded_sample != ~0U);
-
-   // starting from the start is handled differently
-   if (sample_number <= left.last_decoded_sample) {
-      if (stb_vorbis_seek_start(f))
-         return 1;
-      return 0;
-   }
-
-   while (left.page_end != right.page_start) {
-      assert(left.page_end < right.page_start);
-      // search range in bytes
-      delta = right.page_start - left.page_end;
-      if (delta <= 65536) {
-         // there's only 64K left to search - handle it linearly
-         stbv_set_file_offset(f, left.page_end);
-      } else {
-         if (probe < 2) {
-            if (probe == 0) {
-               // first probe (interpolate)
-               double data_bytes = right.page_end - left.page_start;
-               bytes_per_sample = data_bytes / right.last_decoded_sample;
-               offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample);
-            } else {
-               // second probe (try to bound the other side)
-               double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample;
-               if (error >= 0 && error <  8000) error =  8000;
-               if (error <  0 && error > -8000) error = -8000;
-               offset += error * 2;
-            }
-
-            // ensure the offset is valid
-            if (offset < left.page_end)
-               offset = left.page_end;
-            if (offset > right.page_start - 65536)
-               offset = right.page_start - 65536;
-
-            stbv_set_file_offset(f, (unsigned int) offset);
-         } else {
-            // binary search for large ranges (offset by 32K to ensure
-            // we don't hit the right page)
-            stbv_set_file_offset(f, left.page_end + (delta / 2) - 32768);
-         }
-
-         if (!stbv_vorbis_find_page(f, NULL, NULL)) goto error;
-      }
-
-      for (;;) {
-         if (!stbv_get_seek_page_info(f, &mid)) goto error;
-         if (mid.last_decoded_sample != ~0U) break;
-         // (untested) no frames end on this page
-         stbv_set_file_offset(f, mid.page_end);
-         assert(mid.page_start < right.page_start);
-      }
-
-      // if we've just found the last page again then we're in a tricky file,
-      // and we're close enough.
-      if (mid.page_start == right.page_start)
-         break;
-
-      if (sample_number < mid.last_decoded_sample)
-         right = mid;
-      else
-         left = mid;
-
-      ++probe;
-   }
-
-   // seek back to start of the last packet
-   page_start = left.page_start;
-   stbv_set_file_offset(f, page_start);
-   if (!stbv_start_page(f)) return stbv_error(f, VORBIS_seek_failed);
-   end_pos = f->end_seg_with_known_loc;
-   assert(end_pos >= 0);
-
-   for (;;) {
-      for (i = end_pos; i > 0; --i)
-         if (f->segments[i-1] != 255)
-            break;
-
-      start_seg_with_known_loc = i;
-
-      if (start_seg_with_known_loc > 0 || !(f->page_flag & STBV_PAGEFLAG_continued_packet))
-         break;
-
-      // (untested) the final packet begins on an earlier page
-      if (!stbv_go_to_page_before(f, page_start))
-         goto error;
-
-      page_start = stb_vorbis_get_file_offset(f);
-      if (!stbv_start_page(f)) goto error;
-      end_pos = f->segment_count - 1;
-   }
-
-   // prepare to start decoding
-   f->current_loc_valid = FALSE;
-   f->last_seg = FALSE;
-   f->valid_bits = 0;
-   f->packet_bytes = 0;
-   f->bytes_in_seg = 0;
-   f->previous_length = 0;
-   f->next_seg = start_seg_with_known_loc;
-
-   for (i = 0; i < start_seg_with_known_loc; i++)
-      stbv_skip(f, f->segments[i]);
-
-   // start decoding (optimizable - this frame is generally discarded)
-   if (!stbv_vorbis_pump_first_frame(f))
-      return 0;
-   if (f->current_loc > sample_number)
-      return stbv_error(f, VORBIS_seek_failed);
-   return 1;
-
-error:
-   // try to restore the file to a valid state
-   stb_vorbis_seek_start(f);
-   return stbv_error(f, VORBIS_seek_failed);
-}
-
-// the same as stbv_vorbis_decode_initial, but without advancing
-static int stbv_peek_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
-{
-   int bits_read, bytes_read;
-
-   if (!stbv_vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
-      return 0;
-
-   // either 1 or 2 bytes were read, figure out which so we can rewind
-   bits_read = 1 + stbv_ilog(f->mode_count-1);
-   if (f->mode_config[*mode].blockflag)
-      bits_read += 2;
-   bytes_read = (bits_read + 7) / 8;
-
-   f->bytes_in_seg += bytes_read;
-   f->packet_bytes -= bytes_read;
-   stbv_skip(f, -bytes_read);
-   if (f->next_seg == -1)
-      f->next_seg = f->segment_count - 1;
-   else
-      f->next_seg--;
-   f->valid_bits = 0;
-
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
-{
-   stbv_uint32 max_frame_samples;
-
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   // fast page-level search
-   if (!stbv_seek_to_sample_coarse(f, sample_number))
-      return 0;
-
-   assert(f->current_loc_valid);
-   assert(f->current_loc <= sample_number);
-
-   // linear search for the relevant packet
-   max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
-   while (f->current_loc < sample_number) {
-      int left_start, left_end, right_start, right_end, mode, frame_samples;
-      if (!stbv_peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
-         return stbv_error(f, VORBIS_seek_failed);
-      // calculate the number of samples returned by the next frame
-      frame_samples = right_start - left_start;
-      if (f->current_loc + frame_samples > sample_number) {
-         return 1; // the next frame will contain the sample
-      } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
-         // there's a chance the frame after this could contain the sample
-         stbv_vorbis_pump_first_frame(f);
-      } else {
-         // this frame is too early to be relevant
-         f->current_loc += frame_samples;
-         f->previous_length = 0;
-         stbv_maybe_start_packet(f);
-         stbv_flush_packet(f);
-      }
-   }
-   // the next frame will start with the sample
-   assert(f->current_loc == sample_number);
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
-{
-   if (!stb_vorbis_seek_frame(f, sample_number))
-      return 0;
-
-   if (sample_number != f->current_loc) {
-      int n;
-      stbv_uint32 frame_start = f->current_loc;
-      stb_vorbis_get_frame_float(f, &n, NULL);
-      assert(sample_number > frame_start);
-      assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end);
-      f->channel_buffer_start += (sample_number - frame_start);
-   }
-
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f)
-{
-   if (STBV_IS_PUSH_MODE(f)) { return stbv_error(f, VORBIS_invalid_api_mixing); }
-   stbv_set_file_offset(f, f->first_audio_page_offset);
-   f->previous_length = 0;
-   f->first_decode = TRUE;
-   f->next_seg = -1;
-   return stbv_vorbis_pump_first_frame(f);
-}
-
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
-{
-   unsigned int restore_offset, previous_safe;
-   unsigned int end, last_page_loc;
-
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-   if (!f->total_samples) {
-      unsigned int last;
-      stbv_uint32 lo,hi;
-      char header[6];
-
-      // first, store the current decode position so we can restore it
-      restore_offset = stb_vorbis_get_file_offset(f);
-
-      // now we want to seek back 64K from the end (the last page must
-      // be at most a little less than 64K, but let's allow a little slop)
-      if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset)
-         previous_safe = f->stream_len - 65536;
-      else
-         previous_safe = f->first_audio_page_offset;
-
-      stbv_set_file_offset(f, previous_safe);
-      // previous_safe is now our candidate 'earliest known place that seeking
-      // to will lead to the final page'
-
-      if (!stbv_vorbis_find_page(f, &end, &last)) {
-         // if we can't find a page, we're hosed!
-         f->error = VORBIS_cant_find_last_page;
-         f->total_samples = 0xffffffff;
-         goto done;
-      }
-
-      // check if there are more pages
-      last_page_loc = stb_vorbis_get_file_offset(f);
-
-      // stop when the last_page flag is set, not when we reach eof;
-      // this allows us to stop short of a 'file_section' end without
-      // explicitly checking the length of the section
-      while (!last) {
-         stbv_set_file_offset(f, end);
-         if (!stbv_vorbis_find_page(f, &end, &last)) {
-            // the last page we found didn't have the 'last page' flag
-            // set. whoops!
-            break;
-         }
-         previous_safe = last_page_loc+1;
-         last_page_loc = stb_vorbis_get_file_offset(f);
-      }
-
-      stbv_set_file_offset(f, last_page_loc);
-
-      // parse the header
-      stbv_getn(f, (unsigned char *)header, 6);
-      // extract the absolute granule position
-      lo = stbv_get32(f);
-      hi = stbv_get32(f);
-      if (lo == 0xffffffff && hi == 0xffffffff) {
-         f->error = VORBIS_cant_find_last_page;
-         f->total_samples = STBV_SAMPLE_unknown;
-         goto done;
-      }
-      if (hi)
-         lo = 0xfffffffe; // saturate
-      f->total_samples = lo;
-
-      f->p_last.page_start = last_page_loc;
-      f->p_last.page_end   = end;
-      f->p_last.last_decoded_sample = lo;
-
-     done:
-      stbv_set_file_offset(f, restore_offset);
-   }
-   return f->total_samples == STBV_SAMPLE_unknown ? 0 : f->total_samples;
-}
-
-STBVDEF float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
-{
-   return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
-}
-
-
-
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
-{
-   int len, right,left,i;
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
-      f->channel_buffer_start = f->channel_buffer_end = 0;
-      return 0;
-   }
-
-   len = stbv_vorbis_finish_frame(f, len, left, right);
-   for (i=0; i < f->channels; ++i)
-      f->outputs[i] = f->channel_buffers[i] + left;
-
-   f->channel_buffer_start = left;
-   f->channel_buffer_end   = left+len;
-
-   if (channels) *channels = f->channels;
-   if (output)   *output = f->outputs;
-   return len;
-}
-
-#ifndef STB_VORBIS_NO_STDIO
-
-STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length)
-{
-   stb_vorbis *f, p;
-   stbv_vorbis_init(&p, alloc);
-   p.f = file;
-   p.f_start = (stbv_uint32) ftell(file);
-   p.stream_len   = length;
-   p.close_on_free = close_on_free;
-   if (stbv_start_decoder(&p)) {
-      f = stbv_vorbis_alloc(&p);
-      if (f) {
-         *f = p;
-         stbv_vorbis_pump_first_frame(f);
-         return f;
-      }
-   }
-   if (error) *error = p.error;
-   stbv_vorbis_deinit(&p);
-   return NULL;
-}
-
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
-{
-   unsigned int len, start;
-   start = (unsigned int) ftell(file);
-   fseek(file, 0, SEEK_END);
-   len = (unsigned int) (ftell(file) - start);
-   fseek(file, start, SEEK_SET);
-   return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
-}
-
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
-{
-   FILE *f = fopen(filename, "rb");
-   if (f) 
-      return stb_vorbis_open_file(f, TRUE, error, alloc);
-   if (error) *error = VORBIS_file_open_failure;
-   return NULL;
-}
-#endif // STB_VORBIS_NO_STDIO
-
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
-{
-   stb_vorbis *f, p;
-   if (data == NULL) return NULL;
-   stbv_vorbis_init(&p, alloc);
-   p.stream = (stbv_uint8 *) data;
-   p.stream_end = (stbv_uint8 *) data + len;
-   p.stream_start = (stbv_uint8 *) p.stream;
-   p.stream_len = len;
-   p.push_mode = FALSE;
-   if (stbv_start_decoder(&p)) {
-      f = stbv_vorbis_alloc(&p);
-      if (f) {
-         *f = p;
-         stbv_vorbis_pump_first_frame(f);
-         if (error) *error = VORBIS__no_error;
-         return f;
-      }
-   }
-   if (error) *error = p.error;
-   stbv_vorbis_deinit(&p);
-   return NULL;
-}
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-#define STBV_PLAYBACK_MONO 1
-#define STBV_PLAYBACK_LEFT 2
-#define STBV_PLAYBACK_RIGHT 4
-
-#define STBV_L  (STBV_PLAYBACK_LEFT  | STBV_PLAYBACK_MONO)
-#define STBV_C  (STBV_PLAYBACK_LEFT  | STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
-#define STBV_R  (STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
-
-static stbv_int8 stbv_channel_position[7][6] =
-{
-   { 0 },
-   { STBV_C },
-   { STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R },
-   { STBV_L, STBV_R, STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R, STBV_C },
-};
-
-
-#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
-   typedef union {
-      float f;
-      int i;
-   } stbv_float_conv;
-   typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
-   #define STBV_FASTDEF(x) stbv_float_conv x
-   // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round
-   #define STBV_MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
-   #define STBV_ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
-   #define STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + STBV_MAGIC(s), temp.i - STBV_ADDEND(s))
-   #define stbv_check_endianness()  
-#else
-   #define STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
-   #define stbv_check_endianness()
-   #define STBV_FASTDEF(x)
-#endif
-
-static void stbv_copy_samples(short *dest, float *src, int len)
-{
-   int i;
-   stbv_check_endianness();
-   for (i=0; i < len; ++i) {
-      STBV_FASTDEF(temp);
-      int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
-      if ((unsigned int) (v + 32768) > 65535)
-         v = v < 0 ? -32768 : 32767;
-      dest[i] = v;
-   }
-}
-
-static void stbv_compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
-{
-   #define BUFFER_SIZE  32
-   float buffer[BUFFER_SIZE];
-   int i,j,o,n = BUFFER_SIZE;
-   stbv_check_endianness();
-   for (o = 0; o < len; o += BUFFER_SIZE) {
-      memset(buffer, 0, sizeof(buffer));
-      if (o + n > len) n = len - o;
-      for (j=0; j < num_c; ++j) {
-         if (stbv_channel_position[num_c][j] & mask) {
-            for (i=0; i < n; ++i)
-               buffer[i] += data[j][d_offset+o+i];
-         }
-      }
-      for (i=0; i < n; ++i) {
-         STBV_FASTDEF(temp);
-         int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
-         if ((unsigned int) (v + 32768) > 65535)
-            v = v < 0 ? -32768 : 32767;
-         output[o+i] = v;
-      }
-   }
-}
-
-static void stbv_compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
-{
-   #define BUFFER_SIZE  32
-   float buffer[BUFFER_SIZE];
-   int i,j,o,n = BUFFER_SIZE >> 1;
-   // o is the offset in the source data
-   stbv_check_endianness();
-   for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
-      // o2 is the offset in the output data
-      int o2 = o << 1;
-      memset(buffer, 0, sizeof(buffer));
-      if (o + n > len) n = len - o;
-      for (j=0; j < num_c; ++j) {
-         int m = stbv_channel_position[num_c][j] & (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT);
-         if (m == (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT)) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+0] += data[j][d_offset+o+i];
-               buffer[i*2+1] += data[j][d_offset+o+i];
-            }
-         } else if (m == STBV_PLAYBACK_LEFT) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+0] += data[j][d_offset+o+i];
-            }
-         } else if (m == STBV_PLAYBACK_RIGHT) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+1] += data[j][d_offset+o+i];
-            }
-         }
-      }
-      for (i=0; i < (n<<1); ++i) {
-         STBV_FASTDEF(temp);
-         int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
-         if ((unsigned int) (v + 32768) > 65535)
-            v = v < 0 ? -32768 : 32767;
-         output[o2+i] = v;
-      }
-   }
-}
-
-static void stbv_convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
-{
-   int i;
-   if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
-      static int channel_selector[3][2] = { {0}, {STBV_PLAYBACK_MONO}, {STBV_PLAYBACK_LEFT, STBV_PLAYBACK_RIGHT} };
-      for (i=0; i < buf_c; ++i)
-         stbv_compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
-   } else {
-      int limit = buf_c < data_c ? buf_c : data_c;
-      for (i=0; i < limit; ++i)
-         stbv_copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
-      for (   ; i < buf_c; ++i)
-         memset(buffer[i]+b_offset, 0, sizeof(short) * samples);
-   }
-}
-
-STBVDEF int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
-{
-   float **output;
-   int len = stb_vorbis_get_frame_float(f, NULL, &output);
-   if (len > num_samples) len = num_samples;
-   if (len)
-      stbv_convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
-   return len;
-}
-
-static void stbv_convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
-{
-   int i;
-   stbv_check_endianness();
-   if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
-      assert(buf_c == 2);
-      for (i=0; i < buf_c; ++i)
-         stbv_compute_stereo_samples(buffer, data_c, data, d_offset, len);
-   } else {
-      int limit = buf_c < data_c ? buf_c : data_c;
-      int j;
-      for (j=0; j < len; ++j) {
-         for (i=0; i < limit; ++i) {
-            STBV_FASTDEF(temp);
-            float f = data[i][d_offset+j];
-            int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
-            if ((unsigned int) (v + 32768) > 65535)
-               v = v < 0 ? -32768 : 32767;
-            *buffer++ = v;
-         }
-         for (   ; i < buf_c; ++i)
-            *buffer++ = 0;
-      }
-   }
-}
-
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
-{
-   float **output;
-   int len;
-   if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts);
-   len = stb_vorbis_get_frame_float(f, NULL, &output);
-   if (len) {
-      if (len*num_c > num_shorts) len = num_shorts / num_c;
-      stbv_convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
-   }
-   return len;
-}
-
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
-{
-   float **outputs;
-   int len = num_shorts / channels;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      if (k)
-         stbv_convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);
-      buffer += k*channels;
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len) break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
-   }
-   return n;
-}
-
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
-{
-   float **outputs;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      if (k)
-         stbv_convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k);
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len) break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
-   }
-   return n;
-}
-
-#ifndef STB_VORBIS_NO_STDIO
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
-{
-   int data_len, offset, total, limit, error;
-   short *data;
-   stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL);
-   if (v == NULL) return -1;
-   limit = v->channels * 4096;
-   *channels = v->channels;
-   if (sample_rate)
-      *sample_rate = v->sample_rate;
-   offset = data_len = 0;
-   total = limit;
-   data = (short *) malloc(total * sizeof(*data));
-   if (data == NULL) {
-      stb_vorbis_close(v);
-      return -2;
-   }
-   for (;;) {
-      int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
-      if (n == 0) break;
-      data_len += n;
-      offset += n * v->channels;
-      if (offset + limit > total) {
-         short *data2;
-         total *= 2;
-         data2 = (short *) realloc(data, total * sizeof(*data));
-         if (data2 == NULL) {
-            free(data);
-            stb_vorbis_close(v);
-            return -2;
-         }
-         data = data2;
-      }
-   }
-   *output = data;
-   stb_vorbis_close(v);
-   return data_len;
-}
-#endif // NO_STDIO
-
-STBVDEF int stb_vorbis_decode_memory(const stbv_uint8 *mem, int len, int *channels, int *sample_rate, short **output)
-{
-   int data_len, offset, total, limit, error;
-   short *data;
-   stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL);
-   if (v == NULL) return -1;
-   limit = v->channels * 4096;
-   *channels = v->channels;
-   if (sample_rate)
-      *sample_rate = v->sample_rate;
-   offset = data_len = 0;
-   total = limit;
-   data = (short *) malloc(total * sizeof(*data));
-   if (data == NULL) {
-      stb_vorbis_close(v);
-      return -2;
-   }
-   for (;;) {
-      int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
-      if (n == 0) break;
-      data_len += n;
-      offset += n * v->channels;
-      if (offset + limit > total) {
-         short *data2;
-         total *= 2;
-         data2 = (short *) realloc(data, total * sizeof(*data));
-         if (data2 == NULL) {
-            free(data);
-            stb_vorbis_close(v);
-            return -2;
-         }
-         data = data2;
-      }
-   }
-   *output = data;
-   stb_vorbis_close(v);
-   return data_len;
-}
-#endif // STB_VORBIS_NO_INTEGER_CONVERSION
-
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
-{
-   float **outputs;
-   int len = num_floats / channels;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int i,j;
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      for (j=0; j < k; ++j) {
-         for (i=0; i < z; ++i)
-            *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j];
-         for (   ; i < channels; ++i)
-            *buffer++ = 0;
-      }
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len)
-         break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
-         break;
-   }
-   return n;
-}
-
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
-{
-   float **outputs;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < num_samples) {
-      int i;
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= num_samples) k = num_samples - n;
-      if (k) {
-         for (i=0; i < z; ++i)
-            memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k);
-         for (   ; i < channels; ++i)
-            memset(buffer[i]+n, 0, sizeof(float) * k);
-      }
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == num_samples)
-         break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
-         break;
-   }
-   return n;
-}
-#endif // STB_VORBIS_NO_PULLDATA_API
-
-/* Version history
-    1.12    - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
-    1.11    - 2017-07-23 - fix MinGW compilation 
-    1.10    - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
-    1.09    - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version
-    1.08    - 2016-04-02 - fixed multiple warnings; fix setup memory leaks;
-                           avoid discarding last frame of audio data
-    1.07    - 2015-01-16 - fixed some warnings, fix mingw, const-correct API
-                           some more crash fixes when out of memory or with corrupt files 
-    1.06    - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
-                           some crash fixes when out of memory or with corrupt files
-    1.05    - 2015-04-19 - don't define __forceinline if it's redundant
-    1.04    - 2014-08-27 - fix missing const-correct case in API
-    1.03    - 2014-08-07 - Warning fixes
-    1.02    - 2014-07-09 - Declare qsort compare function _cdecl on windows
-    1.01    - 2014-06-18 - fix stb_vorbis_get_samples_float
-    1.0     - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in multichannel
-                           (API change) report sample rate for decode-full-file funcs
-    0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila
-    0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem
-    0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence
-    0.99993 - remove assert that fired on legal files with empty tables
-    0.99992 - rewind-to-start
-    0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo
-    0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++
-    0.9998 - add a full-decode function with a memory source
-    0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition
-    0.9996 - query length of vorbis stream in samples/seconds
-    0.9995 - bugfix to another optimization that only happened in certain files
-    0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors
-    0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation
-    0.9992 - performance improvement of IMDCT; now performs close to reference implementation
-    0.9991 - performance improvement of IMDCT
-    0.999 - (should have been 0.9990) performance improvement of IMDCT
-    0.998 - no-CRT support from Casey Muratori
-    0.997 - bugfixes for bugs found by Terje Mathisen
-    0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen
-    0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen
-    0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen
-    0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen
-    0.992 - fixes for MinGW warning
-    0.991 - turn fast-float-conversion on by default
-    0.990 - fix push-mode seek recovery if you seek into the headers
-    0.98b - fix to bad release of 0.98
-    0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode
-    0.97 - builds under c++ (typecasting, don't use 'class' keyword)
-    0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code
-    0.95 - clamping code for 16-bit functions
-    0.94 - not publically released
-    0.93 - fixed all-zero-floor case (was decoding garbage)
-    0.92 - fixed a memory leak
-    0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION
-    0.90 - first public release
-*/
-
-#endif // STB_VORBIS_IMPLEMENTATION
-
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of 
-this software and associated documentation files (the "Software"), to deal in 
-the Software without restriction, including without limitation the rights to 
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
-of the Software, and to permit persons to whom the Software is furnished to do 
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all 
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 
-software, either in source code form or as a compiled binary, for any purpose, 
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this 
-software dedicate any and all copyright interest in the software to the public 
-domain. We make this dedication for the benefit of the public at large and to 
-the detriment of our heirs and successors. We intend this dedication to be an 
-overt act of relinquishment in perpetuity of all present and future rights to 
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib/external/tinyobj_loader_c.h b/raylib/external/tinyobj_loader_c.h
deleted file mode 100644 (file)
index 6bd63fc..0000000
+++ /dev/null
@@ -1,1587 +0,0 @@
-/*
-   The MIT License (MIT)
-
-   Copyright (c) 2016 - 2019 Syoyo Fujita and many contributors.
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-   THE SOFTWARE.
-   */
-#ifndef TINOBJ_LOADER_C_H_
-#define TINOBJ_LOADER_C_H_
-
-/* @todo { Remove stddef dependency. unsigned int? } ---> RAY: DONE. */
-//#include <stddef.h>
-
-typedef struct {
-  char *name;
-
-  float ambient[3];
-  float diffuse[3];
-  float specular[3];
-  float transmittance[3];
-  float emission[3];
-  float shininess;
-  float ior;      /* index of refraction */
-  float dissolve; /* 1 == opaque; 0 == fully transparent */
-  /* illumination model (see http://www.fileformat.info/format/material/) */
-  int illum;
-
-  int pad0;
-
-  char *ambient_texname;            /* map_Ka */
-  char *diffuse_texname;            /* map_Kd */
-  char *specular_texname;           /* map_Ks */
-  char *specular_highlight_texname; /* map_Ns */
-  char *bump_texname;               /* map_bump, bump */
-  char *displacement_texname;       /* disp */
-  char *alpha_texname;              /* map_d */
-} tinyobj_material_t;
-
-typedef struct {
-  char *name; /* group name or object name. */
-  unsigned int face_offset;
-  unsigned int length;
-} tinyobj_shape_t;
-
-typedef struct { int v_idx, vt_idx, vn_idx; } tinyobj_vertex_index_t;
-
-typedef struct {
-  unsigned int num_vertices;
-  unsigned int num_normals;
-  unsigned int num_texcoords;
-  unsigned int num_faces;
-  unsigned int num_face_num_verts;
-
-  int pad0;
-
-  float *vertices;
-  float *normals;
-  float *texcoords;
-  tinyobj_vertex_index_t *faces;
-  int *face_num_verts;
-  int *material_ids;
-} tinyobj_attrib_t;
-
-
-#define TINYOBJ_FLAG_TRIANGULATE (1 << 0)
-
-#define TINYOBJ_INVALID_INDEX (0x80000000)
-
-#define TINYOBJ_SUCCESS (0)
-#define TINYOBJ_ERROR_EMPTY (-1)
-#define TINYOBJ_ERROR_INVALID_PARAMETER (-2)
-#define TINYOBJ_ERROR_FILE_OPERATION (-3)
-
-/* Parse wavefront .obj(.obj string data is expanded to linear char array `buf')
- * flags are combination of TINYOBJ_FLAG_***
- * Returns TINYOBJ_SUCCESS if things goes well.
- * Returns TINYOBJ_ERR_*** when there is an error.
- */
-extern int tinyobj_parse_obj(tinyobj_attrib_t *attrib, tinyobj_shape_t **shapes,
-                             unsigned int *num_shapes, tinyobj_material_t **materials,
-                             unsigned int *num_materials, const char *buf, unsigned int len,
-                             unsigned int flags);
-extern int tinyobj_parse_mtl_file(tinyobj_material_t **materials_out,
-                                  unsigned int *num_materials_out,
-                                  const char *filename);
-
-extern void tinyobj_attrib_init(tinyobj_attrib_t *attrib);
-extern void tinyobj_attrib_free(tinyobj_attrib_t *attrib);
-extern void tinyobj_shapes_free(tinyobj_shape_t *shapes, unsigned int num_shapes);
-extern void tinyobj_materials_free(tinyobj_material_t *materials,
-                                   unsigned int num_materials);
-
-#ifdef TINYOBJ_LOADER_C_IMPLEMENTATION
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <errno.h>
-
-#if defined(TINYOBJ_MALLOC) && defined(TINYOBJ_REALLOC) && defined(TINYOBJ_CALLOC) && defined(TINYOBJ_FREE)
-/* ok */
-#elif !defined(TINYOBJ_MALLOC) && !defined(TINYOBJ_REALLOC) && !defined(TINYOBJ_CALLOC) && !defined(TINYOBJ_FREE)
-/* ok */
-#else
-#error "Must define all or none of TINYOBJ_MALLOC, TINYOBJ_REALLOC, TINYOBJ_CALLOC and TINYOBJ_FREE."
-#endif
-
-#ifndef TINYOBJ_MALLOC
-#include <stdlib.h>
-#define TINYOBJ_MALLOC malloc
-#define TINYOBJ_REALLOC realloc
-#define TINYOBJ_CALLOC calloc
-#define TINYOBJ_FREE free
-#endif
-
-#define TINYOBJ_MAX_FACES_PER_F_LINE (16)
-
-#define IS_SPACE(x) (((x) == ' ') || ((x) == '\t'))
-#define IS_DIGIT(x) ((unsigned int)((x) - '0') < (unsigned int)(10))
-#define IS_NEW_LINE(x) (((x) == '\r') || ((x) == '\n') || ((x) == '\0'))
-
-static void skip_space(const char **token) {
-  while ((*token)[0] == ' ' || (*token)[0] == '\t') {
-    (*token)++;
-  }
-}
-
-static void skip_space_and_cr(const char **token) {
-  while ((*token)[0] == ' ' || (*token)[0] == '\t' || (*token)[0] == '\r') {
-    (*token)++;
-  }
-}
-
-static int until_space(const char *token) {
-  const char *p = token;
-  while (p[0] != '\0' && p[0] != ' ' && p[0] != '\t' && p[0] != '\r') {
-    p++;
-  }
-
-  return (int)(p - token);
-}
-
-static unsigned int length_until_newline(const char *token, unsigned int n) {
-  unsigned int len = 0;
-
-  /* Assume token[n-1] = '\0' */
-  for (len = 0; len < n - 1; len++) {
-    if (token[len] == '\n') {
-      break;
-    }
-    if ((token[len] == '\r') && ((len < (n - 2)) && (token[len + 1] != '\n'))) {
-      break;
-    }
-  }
-
-  return len;
-}
-
-static unsigned int length_until_line_feed(const char *token, unsigned int n) {
-  unsigned int len = 0;
-
-  /* Assume token[n-1] = '\0' */
-  for (len = 0; len < n; len++) {
-    if ((token[len] == '\n') || (token[len] == '\r')) {
-      break;
-    }
-  }
-
-  return len;
-}
-
-/* http://stackoverflow.com/questions/5710091/how-does-atoi-function-in-c-work
-*/
-static int my_atoi(const char *c) {
-  int value = 0;
-  int sign = 1;
-  if (*c == '+' || *c == '-') {
-    if (*c == '-') sign = -1;
-    c++;
-  }
-  while (((*c) >= '0') && ((*c) <= '9')) { /* isdigit(*c) */
-    value *= 10;
-    value += (int)(*c - '0');
-    c++;
-  }
-  return value * sign;
-}
-
-/* Make index zero-base, and also support relative index. */
-static int fixIndex(int idx, unsigned int n) {
-  if (idx > 0) return idx - 1;
-  if (idx == 0) return 0;
-  return (int)n + idx; /* negative value = relative */
-}
-
-/* Parse raw triples: i, i/j/k, i//k, i/j */
-static tinyobj_vertex_index_t parseRawTriple(const char **token) {
-  tinyobj_vertex_index_t vi;
-  /* 0x80000000 = -2147483648 = invalid */
-  vi.v_idx = (int)(0x80000000);
-  vi.vn_idx = (int)(0x80000000);
-  vi.vt_idx = (int)(0x80000000);
-
-  vi.v_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  if ((*token)[0] != '/') {
-    return vi;
-  }
-  (*token)++;
-
-  /* i//k */
-  if ((*token)[0] == '/') {
-    (*token)++;
-    vi.vn_idx = my_atoi((*token));
-    while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-           (*token)[0] != '\t' && (*token)[0] != '\r') {
-      (*token)++;
-    }
-    return vi;
-  }
-
-  /* i/j/k or i/j */
-  vi.vt_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  if ((*token)[0] != '/') {
-    return vi;
-  }
-
-  /* i/j/k */
-  (*token)++; /* skip '/' */
-  vi.vn_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  return vi;
-}
-
-static int parseInt(const char **token) {
-  int i = 0;
-  skip_space(token);
-  i = my_atoi((*token));
-  (*token) += until_space((*token));
-  return i;
-}
-
-/*
- * Tries to parse a floating point number located at s.
- *
- * s_end should be a location in the string where reading should absolutely
- * stop. For example at the end of the string, to prevent buffer overflows.
- *
- * Parses the following EBNF grammar:
- *   sign    = "+" | "-" ;
- *   END     = ? anything not in digit ?
- *   digit   = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
- *   integer = [sign] , digit , {digit} ;
- *   decimal = integer , ["." , integer] ;
- *   float   = ( decimal , END ) | ( decimal , ("E" | "e") , integer , END ) ;
- *
- *  Valid strings are for example:
- *   -0  +3.1417e+2  -0.0E-3  1.0324  -1.41   11e2
- *
- * If the parsing is a success, result is set to the parsed value and true
- * is returned.
- *
- * The function is greedy and will parse until any of the following happens:
- *  - a non-conforming character is encountered.
- *  - s_end is reached.
- *
- * The following situations triggers a failure:
- *  - s >= s_end.
- *  - parse failure.
- */
-static int tryParseDouble(const char *s, const char *s_end, double *result) {
-  double mantissa = 0.0;
-  /* This exponent is base 2 rather than 10.
-   * However the exponent we parse is supposed to be one of ten,
-   * thus we must take care to convert the exponent/and or the
-   * mantissa to a * 2^E, where a is the mantissa and E is the
-   * exponent.
-   * To get the final double we will use ldexp, it requires the
-   * exponent to be in base 2.
-   */
-  int exponent = 0;
-
-  /* NOTE: THESE MUST BE DECLARED HERE SINCE WE ARE NOT ALLOWED
-   * TO JUMP OVER DEFINITIONS.
-   */
-  char sign = '+';
-  char exp_sign = '+';
-  char const *curr = s;
-
-  /* How many characters were read in a loop. */
-  int read = 0;
-  /* Tells whether a loop terminated due to reaching s_end. */
-  int end_not_reached = 0;
-
-  /*
-     BEGIN PARSING.
-     */
-
-  if (s >= s_end) {
-    return 0; /* fail */
-  }
-
-  /* Find out what sign we've got. */
-  if (*curr == '+' || *curr == '-') {
-    sign = *curr;
-    curr++;
-  } else if (IS_DIGIT(*curr)) { /* Pass through. */
-  } else {
-    goto fail;
-  }
-
-  /* Read the integer part. */
-  end_not_reached = (curr != s_end);
-  while (end_not_reached && IS_DIGIT(*curr)) {
-    mantissa *= 10;
-    mantissa += (int)(*curr - 0x30);
-    curr++;
-    read++;
-    end_not_reached = (curr != s_end);
-  }
-
-  /* We must make sure we actually got something. */
-  if (read == 0) goto fail;
-  /* We allow numbers of form "#", "###" etc. */
-  if (!end_not_reached) goto assemble;
-
-  /* Read the decimal part. */
-  if (*curr == '.') {
-    curr++;
-    read = 1;
-    end_not_reached = (curr != s_end);
-    while (end_not_reached && IS_DIGIT(*curr)) {
-      /* pow(10.0, -read) */
-      double frac_value = 1.0;
-      int f;
-      for (f = 0; f < read; f++) {
-        frac_value *= 0.1;
-      }
-      mantissa += (int)(*curr - 0x30) * frac_value;
-      read++;
-      curr++;
-      end_not_reached = (curr != s_end);
-    }
-  } else if (*curr == 'e' || *curr == 'E') {
-  } else {
-    goto assemble;
-  }
-
-  if (!end_not_reached) goto assemble;
-
-  /* Read the exponent part. */
-  if (*curr == 'e' || *curr == 'E') {
-    curr++;
-    /* Figure out if a sign is present and if it is. */
-    end_not_reached = (curr != s_end);
-    if (end_not_reached && (*curr == '+' || *curr == '-')) {
-      exp_sign = *curr;
-      curr++;
-    } else if (IS_DIGIT(*curr)) { /* Pass through. */
-    } else {
-      /* Empty E is not allowed. */
-      goto fail;
-    }
-
-    read = 0;
-    end_not_reached = (curr != s_end);
-    while (end_not_reached && IS_DIGIT(*curr)) {
-      exponent *= 10;
-      exponent += (int)(*curr - 0x30);
-      curr++;
-      read++;
-      end_not_reached = (curr != s_end);
-    }
-    if (read == 0) goto fail;
-  }
-
-assemble :
-
-  {
-    double a = 1.0; /* = pow(5.0, exponent); */
-    double b  = 1.0; /* = 2.0^exponent */
-    int i;
-    for (i = 0; i < exponent; i++) {
-      a = a * 5.0;
-    }
-
-    for (i = 0; i < exponent; i++) {
-      b = b * 2.0;
-    }
-
-    if (exp_sign == '-') {
-      a = 1.0 / a;
-      b = 1.0 / b;
-    }
-
-    *result =
-      /* (sign == '+' ? 1 : -1) * ldexp(mantissa * pow(5.0, exponent),
-         exponent); */
-      (sign == '+' ? 1 : -1) * (mantissa * a * b);
-  }
-
-  return 1;
-fail:
-  return 0;
-}
-
-static float parseFloat(const char **token) {
-  const char *end;
-  double val = 0.0;
-  float f = 0.0f;
-  skip_space(token);
-  end = (*token) + until_space((*token));
-  val = 0.0;
-  tryParseDouble((*token), end, &val);
-  f = (float)(val);
-  (*token) = end;
-  return f;
-}
-
-static void parseFloat2(float *x, float *y, const char **token) {
-  (*x) = parseFloat(token);
-  (*y) = parseFloat(token);
-}
-
-static void parseFloat3(float *x, float *y, float *z, const char **token) {
-  (*x) = parseFloat(token);
-  (*y) = parseFloat(token);
-  (*z) = parseFloat(token);
-}
-
-static unsigned int my_strnlen(const char *s, unsigned int n) {
-    const char *p = memchr(s, 0, n);
-    return p ? (unsigned int)(p - s) : n;
-}
-
-static char *my_strdup(const char *s, unsigned int max_length) {
-  char *d;
-  unsigned int len;
-
-  if (s == NULL) return NULL;
-
-  /* Do not consider CRLF line ending(#19) */
-  len = length_until_line_feed(s, max_length);
-  /* len = strlen(s); */
-
-  /* trim line ending and append '\0' */
-  d = (char *)TINYOBJ_MALLOC(len + 1); /* + '\0' */
-  memcpy(d, s, (unsigned int)(len));
-  d[len] = '\0';
-
-  return d;
-}
-
-static char *my_strndup(const char *s, unsigned int len) {
-  char *d;
-  unsigned int slen;
-
-  if (s == NULL) return NULL;
-  if (len == 0) return NULL;
-
-  slen = my_strnlen(s, len);
-  d = (char *)TINYOBJ_MALLOC(slen + 1); /* + '\0' */
-  if (!d) {
-    return NULL;
-  }
-  memcpy(d, s, slen);
-  d[slen] = '\0';
-
-  return d;
-}
-
-char *dynamic_fgets(char **buf, unsigned int *size, FILE *file) {
-  char *offset;
-  char *ret;
-  unsigned int old_size;
-
-  if (!(ret = fgets(*buf, (int)*size, file))) {
-    return ret;
-  }
-
-  if (NULL != strchr(*buf, '\n')) {
-    return ret;
-  }
-
-  do {
-    old_size = *size;
-    *size *= 2;
-    *buf = (char*)TINYOBJ_REALLOC(*buf, *size);
-    offset = &((*buf)[old_size - 1]);
-
-    ret = fgets(offset, (int)(old_size + 1), file);
-  } while(ret && (NULL == strchr(*buf, '\n')));
-
-  return ret;
-}
-
-static void initMaterial(tinyobj_material_t *material) {
-  int i;
-  material->name = NULL;
-  material->ambient_texname = NULL;
-  material->diffuse_texname = NULL;
-  material->specular_texname = NULL;
-  material->specular_highlight_texname = NULL;
-  material->bump_texname = NULL;
-  material->displacement_texname = NULL;
-  material->alpha_texname = NULL;
-  for (i = 0; i < 3; i++) {
-    material->ambient[i] = 0.f;
-    material->diffuse[i] = 0.f;
-    material->specular[i] = 0.f;
-    material->transmittance[i] = 0.f;
-    material->emission[i] = 0.f;
-  }
-  material->illum = 0;
-  material->dissolve = 1.f;
-  material->shininess = 1.f;
-  material->ior = 1.f;
-}
-
-/* Implementation of string to int hashtable */
-
-#define HASH_TABLE_ERROR 1 
-#define HASH_TABLE_SUCCESS 0
-
-#define HASH_TABLE_DEFAULT_SIZE 10
-
-typedef struct hash_table_entry_t
-{
-  unsigned long hash;
-  int filled;
-  int pad0;
-  long value;
-
-  struct hash_table_entry_t* next;
-} hash_table_entry_t;
-
-typedef struct
-{
-  unsigned long* hashes;
-  hash_table_entry_t* entries;
-  unsigned int capacity;
-  unsigned int n;
-} hash_table_t;
-
-static unsigned long hash_djb2(const unsigned char* str)
-{
-  unsigned long hash = 5381;
-  int c;
-
-  while ((c = *str++)) {
-    hash = ((hash << 5) + hash) + (unsigned long)(c);
-  }
-
-  return hash;
-}
-
-static void create_hash_table(unsigned int start_capacity, hash_table_t* hash_table)
-{
-  if (start_capacity < 1)
-    start_capacity = HASH_TABLE_DEFAULT_SIZE;
-  hash_table->hashes = (unsigned long*) TINYOBJ_MALLOC(start_capacity * sizeof(unsigned long));
-  hash_table->entries = (hash_table_entry_t*) TINYOBJ_CALLOC(start_capacity, sizeof(hash_table_entry_t));
-  hash_table->capacity = start_capacity;
-  hash_table->n = 0;
-}
-
-static void destroy_hash_table(hash_table_t* hash_table)
-{
-  TINYOBJ_FREE(hash_table->entries);
-  TINYOBJ_FREE(hash_table->hashes);
-}
-
-/* Insert with quadratic probing */
-static int hash_table_insert_value(unsigned long hash, long value, hash_table_t* hash_table)
-{
-  /* Insert value */
-  unsigned int start_index = hash % hash_table->capacity;
-  unsigned int index = start_index;
-  hash_table_entry_t* start_entry = hash_table->entries + start_index;
-  unsigned int i;
-  hash_table_entry_t* entry;
-
-  for (i = 1; hash_table->entries[index].filled; i++)
-  {
-    if (i >= hash_table->capacity)
-      return HASH_TABLE_ERROR;
-    index = (start_index + (i * i)) % hash_table->capacity; 
-  }
-
-  entry = hash_table->entries + index;
-  entry->hash = hash;
-  entry->filled = 1;
-  entry->value = value;
-
-  if (index != start_index) {
-    /* This is a new entry, but not the start entry, hence we need to add a next pointer to our entry */
-    entry->next = start_entry->next;
-    start_entry->next = entry;
-  }
-
-  return HASH_TABLE_SUCCESS;
-}
-
-static int hash_table_insert(unsigned long hash, long value, hash_table_t* hash_table)
-{
-  int ret = hash_table_insert_value(hash, value, hash_table);
-  if (ret == HASH_TABLE_SUCCESS)
-  {
-    hash_table->hashes[hash_table->n] = hash;
-    hash_table->n++;
-  }
-  return ret;
-}
-
-static hash_table_entry_t* hash_table_find(unsigned long hash, hash_table_t* hash_table)
-{
-  hash_table_entry_t* entry = hash_table->entries + (hash % hash_table->capacity);
-  while (entry)
-  {
-    if (entry->hash == hash && entry->filled)
-    {
-      return entry;
-    }
-    entry = entry->next;
-  }
-  return NULL;
-}
-
-static void hash_table_maybe_grow(unsigned int new_n, hash_table_t* hash_table)
-{
-  unsigned int new_capacity;
-  hash_table_t new_hash_table;
-  unsigned int i;
-
-  if (new_n <= hash_table->capacity) {
-    return;
-  }
-  new_capacity = 2 * ((2 * hash_table->capacity) > new_n ? hash_table->capacity : new_n);
-  /* Create a new hash table. We're not calling create_hash_table because we want to realloc the hash array */
-  new_hash_table.hashes = hash_table->hashes = (unsigned long*) TINYOBJ_REALLOC((void*) hash_table->hashes, sizeof(unsigned long) * new_capacity);
-  new_hash_table.entries = (hash_table_entry_t*) TINYOBJ_CALLOC(new_capacity, sizeof(hash_table_entry_t));
-  new_hash_table.capacity = new_capacity;
-  new_hash_table.n = hash_table->n;
-
-  /* Rehash */
-  for (i = 0; i < hash_table->capacity; i++)
-  {
-    hash_table_entry_t* entry = hash_table_find(hash_table->hashes[i], hash_table);
-    hash_table_insert_value(hash_table->hashes[i], entry->value, &new_hash_table);
-  }
-
-  TINYOBJ_FREE(hash_table->entries);
-  (*hash_table) = new_hash_table;
-}
-
-static int hash_table_exists(const char* name, hash_table_t* hash_table)
-{
-  return hash_table_find(hash_djb2((const unsigned char*)name), hash_table) != NULL;
-}
-
-static void hash_table_set(const char* name, unsigned int val, hash_table_t* hash_table)
-{
-  /* Hash name */
-  unsigned long hash = hash_djb2((const unsigned char *)name);
-
-  hash_table_entry_t* entry = hash_table_find(hash, hash_table);
-  if (entry)
-  {
-    entry->value = (long)val;
-    return;
-  }
-
-  /* Expand if necessary
-   * Grow until the element has been added
-   */
-  do
-  {
-    hash_table_maybe_grow(hash_table->n + 1, hash_table);
-  }
-  while (hash_table_insert(hash, (long)val, hash_table) != HASH_TABLE_SUCCESS);
-}
-
-static long hash_table_get(const char* name, hash_table_t* hash_table)
-{
-  hash_table_entry_t* ret = hash_table_find(hash_djb2((const unsigned char*)(name)), hash_table);
-  return ret->value;
-}
-
-static tinyobj_material_t *tinyobj_material_add(tinyobj_material_t *prev,
-                                                unsigned int num_materials,
-                                                tinyobj_material_t *new_mat) {
-  tinyobj_material_t *dst;
-  dst = (tinyobj_material_t *)TINYOBJ_REALLOC(
-                                      prev, sizeof(tinyobj_material_t) * (num_materials + 1));
-
-  dst[num_materials] = (*new_mat); /* Just copy pointer for char* members */
-  return dst;
-}
-
-static int tinyobj_parse_and_index_mtl_file(tinyobj_material_t **materials_out,
-                                            unsigned int *num_materials_out,
-                                            const char *filename,
-                                            hash_table_t* material_table) {
-  tinyobj_material_t material;
-  unsigned int buffer_size = 128;
-  char *linebuf;
-  FILE *fp;
-  unsigned int num_materials = 0;
-  tinyobj_material_t *materials = NULL;
-  int has_previous_material = 0;
-  const char *line_end = NULL;
-
-  if (materials_out == NULL) {
-    return TINYOBJ_ERROR_INVALID_PARAMETER;
-  }
-
-  if (num_materials_out == NULL) {
-    return TINYOBJ_ERROR_INVALID_PARAMETER;
-  }
-
-  (*materials_out) = NULL;
-  (*num_materials_out) = 0;
-
-  fp = fopen(filename, "r");
-  if (!fp) {
-    fprintf(stderr, "TINYOBJ: Error reading file '%s': %s (%d)\n", filename, strerror(errno), errno);
-    return TINYOBJ_ERROR_FILE_OPERATION;
-  }
-
-  /* Create a default material */
-  initMaterial(&material);
-
-  linebuf = (char*)TINYOBJ_MALLOC(buffer_size);
-  while (NULL != dynamic_fgets(&linebuf, &buffer_size, fp)) {
-    const char *token = linebuf;
-
-    line_end = token + strlen(token);
-
-    /* Skip leading space. */
-    token += strspn(token, " \t");
-
-    assert(token);
-    if (token[0] == '\0') continue; /* empty line */
-
-    if (token[0] == '#') continue; /* comment line */
-
-    /* new mtl */
-    if ((0 == strncmp(token, "newmtl", 6)) && IS_SPACE((token[6]))) {
-      char namebuf[4096];
-
-      /* flush previous material. */
-      if (has_previous_material) {
-        materials = tinyobj_material_add(materials, num_materials, &material);
-        num_materials++;
-      } else {
-        has_previous_material = 1;
-      }
-
-      /* initial temporary material */
-      initMaterial(&material);
-
-      /* set new mtl name */
-      token += 7;
-#ifdef _MSC_VER
-      sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
-#else
-      sscanf(token, "%s", namebuf);
-#endif
-      material.name = my_strdup(namebuf, (unsigned int) (line_end - token));
-
-      /* Add material to material table */
-      if (material_table)
-        hash_table_set(material.name, num_materials, material_table);
-
-      continue;
-    }
-
-    /* ambient */
-    if (token[0] == 'K' && token[1] == 'a' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.ambient[0] = r;
-      material.ambient[1] = g;
-      material.ambient[2] = b;
-      continue;
-    }
-
-    /* diffuse */
-    if (token[0] == 'K' && token[1] == 'd' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.diffuse[0] = r;
-      material.diffuse[1] = g;
-      material.diffuse[2] = b;
-      continue;
-    }
-
-    /* specular */
-    if (token[0] == 'K' && token[1] == 's' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.specular[0] = r;
-      material.specular[1] = g;
-      material.specular[2] = b;
-      continue;
-    }
-
-    /* transmittance */
-    if (token[0] == 'K' && token[1] == 't' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.transmittance[0] = r;
-      material.transmittance[1] = g;
-      material.transmittance[2] = b;
-      continue;
-    }
-
-    /* ior(index of refraction) */
-    if (token[0] == 'N' && token[1] == 'i' && IS_SPACE((token[2]))) {
-      token += 2;
-      material.ior = parseFloat(&token);
-      continue;
-    }
-
-    /* emission */
-    if (token[0] == 'K' && token[1] == 'e' && IS_SPACE(token[2])) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.emission[0] = r;
-      material.emission[1] = g;
-      material.emission[2] = b;
-      continue;
-    }
-
-    /* shininess */
-    if (token[0] == 'N' && token[1] == 's' && IS_SPACE(token[2])) {
-      token += 2;
-      material.shininess = parseFloat(&token);
-      continue;
-    }
-
-    /* illum model */
-    if (0 == strncmp(token, "illum", 5) && IS_SPACE(token[5])) {
-      token += 6;
-      material.illum = parseInt(&token);
-      continue;
-    }
-
-    /* dissolve */
-    if ((token[0] == 'd' && IS_SPACE(token[1]))) {
-      token += 1;
-      material.dissolve = parseFloat(&token);
-      continue;
-    }
-    if (token[0] == 'T' && token[1] == 'r' && IS_SPACE(token[2])) {
-      token += 2;
-      /* Invert value of Tr(assume Tr is in range [0, 1]) */
-      material.dissolve = 1.0f - parseFloat(&token);
-      continue;
-    }
-
-    /* ambient texture */
-    if ((0 == strncmp(token, "map_Ka", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.ambient_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* diffuse texture */
-    if ((0 == strncmp(token, "map_Kd", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.diffuse_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* specular texture */
-    if ((0 == strncmp(token, "map_Ks", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.specular_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* specular highlight texture */
-    if ((0 == strncmp(token, "map_Ns", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.specular_highlight_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* bump texture */
-    if ((0 == strncmp(token, "map_bump", 8)) && IS_SPACE(token[8])) {
-      token += 9;
-      material.bump_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* alpha texture */
-    if ((0 == strncmp(token, "map_d", 5)) && IS_SPACE(token[5])) {
-      token += 6;
-      material.alpha_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* bump texture */
-    if ((0 == strncmp(token, "bump", 4)) && IS_SPACE(token[4])) {
-      token += 5;
-      material.bump_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* displacement texture */
-    if ((0 == strncmp(token, "disp", 4)) && IS_SPACE(token[4])) {
-      token += 5;
-      material.displacement_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* @todo { unknown parameter } */
-  }
-
-  if (material.name) {
-    /* Flush last material element */
-    materials = tinyobj_material_add(materials, num_materials, &material);
-    num_materials++;
-  }
-
-  (*num_materials_out) = num_materials;
-  (*materials_out) = materials;
-
-  if (linebuf) {
-    TINYOBJ_FREE(linebuf);
-  }
-
-  return TINYOBJ_SUCCESS;
-}
-
-int tinyobj_parse_mtl_file(tinyobj_material_t **materials_out,
-                           unsigned int *num_materials_out,
-                           const char *filename) {
-  return tinyobj_parse_and_index_mtl_file(materials_out, num_materials_out, filename, NULL);
-} 
-
-
-typedef enum {
-  COMMAND_EMPTY,
-  COMMAND_V,
-  COMMAND_VN,
-  COMMAND_VT,
-  COMMAND_F,
-  COMMAND_G,
-  COMMAND_O,
-  COMMAND_USEMTL,
-  COMMAND_MTLLIB
-
-} CommandType;
-
-typedef struct {
-  float vx, vy, vz;
-  float nx, ny, nz;
-  float tx, ty;
-
-  /* @todo { Use dynamic array } */
-  tinyobj_vertex_index_t f[TINYOBJ_MAX_FACES_PER_F_LINE];
-  unsigned int num_f;
-
-  int f_num_verts[TINYOBJ_MAX_FACES_PER_F_LINE];
-  unsigned int num_f_num_verts;
-
-  const char *group_name;
-  unsigned int group_name_len;
-  int pad0;
-
-  const char *object_name;
-  unsigned int object_name_len;
-  int pad1;
-
-  const char *material_name;
-  unsigned int material_name_len;
-  int pad2;
-
-  const char *mtllib_name;
-  unsigned int mtllib_name_len;
-
-  CommandType type;
-} Command;
-
-static int parseLine(Command *command, const char *p, unsigned int p_len,
-                     int triangulate) {
-  char linebuf[4096];
-  const char *token;
-  assert(p_len < 4095);
-
-  memcpy(linebuf, p, p_len);
-  linebuf[p_len] = '\0';
-
-  token = linebuf;
-
-  command->type = COMMAND_EMPTY;
-
-  /* Skip leading space. */
-  skip_space(&token);
-
-  assert(token);
-  if (token[0] == '\0') { /* empty line */
-    return 0;
-  }
-
-  if (token[0] == '#') { /* comment line */
-    return 0;
-  }
-
-  /* vertex */
-  if (token[0] == 'v' && IS_SPACE((token[1]))) {
-    float x, y, z;
-    token += 2;
-    parseFloat3(&x, &y, &z, &token);
-    command->vx = x;
-    command->vy = y;
-    command->vz = z;
-    command->type = COMMAND_V;
-    return 1;
-  }
-
-  /* normal */
-  if (token[0] == 'v' && token[1] == 'n' && IS_SPACE((token[2]))) {
-    float x, y, z;
-    token += 3;
-    parseFloat3(&x, &y, &z, &token);
-    command->nx = x;
-    command->ny = y;
-    command->nz = z;
-    command->type = COMMAND_VN;
-    return 1;
-  }
-
-  /* texcoord */
-  if (token[0] == 'v' && token[1] == 't' && IS_SPACE((token[2]))) {
-    float x, y;
-    token += 3;
-    parseFloat2(&x, &y, &token);
-    command->tx = x;
-    command->ty = y;
-    command->type = COMMAND_VT;
-    return 1;
-  }
-
-  /* face */
-  if (token[0] == 'f' && IS_SPACE((token[1]))) {
-    unsigned int num_f = 0;
-
-    tinyobj_vertex_index_t f[TINYOBJ_MAX_FACES_PER_F_LINE];
-    token += 2;
-    skip_space(&token);
-
-    while (!IS_NEW_LINE(token[0])) {
-      tinyobj_vertex_index_t vi = parseRawTriple(&token);
-      skip_space_and_cr(&token);
-
-      f[num_f] = vi;
-      num_f++;
-    }
-
-    command->type = COMMAND_F;
-
-    if (triangulate) {
-      unsigned int k;
-      unsigned int n = 0;
-
-      tinyobj_vertex_index_t i0 = f[0];
-      tinyobj_vertex_index_t i1;
-      tinyobj_vertex_index_t i2 = f[1];
-
-      assert(3 * num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
-
-      for (k = 2; k < num_f; k++) {
-        i1 = i2;
-        i2 = f[k];
-        command->f[3 * n + 0] = i0;
-        command->f[3 * n + 1] = i1;
-        command->f[3 * n + 2] = i2;
-
-        command->f_num_verts[n] = 3;
-        n++;
-      }
-      command->num_f = 3 * n;
-      command->num_f_num_verts = n;
-
-    } else {
-      unsigned int k = 0;
-      assert(num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
-      for (k = 0; k < num_f; k++) {
-        command->f[k] = f[k];
-      }
-
-      command->num_f = num_f;
-      command->f_num_verts[0] = (int)num_f;
-      command->num_f_num_verts = 1;
-    }
-
-    return 1;
-  }
-
-  /* use mtl */
-  if ((0 == strncmp(token, "usemtl", 6)) && IS_SPACE((token[6]))) {
-    token += 7;
-
-    skip_space(&token);
-    command->material_name = p + (token - linebuf);
-    command->material_name_len = (unsigned int)length_until_newline(
-                                                                    token, (p_len - (unsigned int)(token - linebuf)) + 1);
-    command->type = COMMAND_USEMTL;
-
-    return 1;
-  }
-
-  /* load mtl */
-  if ((0 == strncmp(token, "mtllib", 6)) && IS_SPACE((token[6]))) {
-    /* By specification, `mtllib` should be appear only once in .obj */
-    token += 7;
-
-    skip_space(&token);
-    command->mtllib_name = p + (token - linebuf);
-    command->mtllib_name_len = (unsigned int)length_until_newline(
-                                                                  token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_MTLLIB;
-
-    return 1;
-  }
-
-  /* group name */
-  if (token[0] == 'g' && IS_SPACE((token[1]))) {
-    /* @todo { multiple group name. } */
-    token += 2;
-
-    command->group_name = p + (token - linebuf);
-    command->group_name_len = (unsigned int)length_until_newline(
-                                                                 token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_G;
-
-    return 1;
-  }
-
-  /* object name */
-  if (token[0] == 'o' && IS_SPACE((token[1]))) {
-    /* @todo { multiple object name? } */
-    token += 2;
-
-    command->object_name = p + (token - linebuf);
-    command->object_name_len = (unsigned int)length_until_newline(
-                                                                  token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_O;
-
-    return 1;
-  }
-
-  return 0;
-}
-
-typedef struct {
-  unsigned int pos;
-  unsigned int len;
-} LineInfo;
-
-static int is_line_ending(const char *p, unsigned int i, unsigned int end_i) {
-  if (p[i] == '\0') return 1;
-  if (p[i] == '\n') return 1; /* this includes \r\n */
-  if (p[i] == '\r') {
-    if (((i + 1) < end_i) && (p[i + 1] != '\n')) { /* detect only \r case */
-      return 1;
-    }
-  }
-  return 0;
-}
-
-int tinyobj_parse_obj(tinyobj_attrib_t *attrib, tinyobj_shape_t **shapes,
-                      unsigned int *num_shapes, tinyobj_material_t **materials_out,
-                      unsigned int *num_materials_out, const char *buf, unsigned int len,
-                      unsigned int flags) {
-  LineInfo *line_infos = NULL;
-  Command *commands = NULL;
-  unsigned int num_lines = 0;
-
-  unsigned int num_v = 0;
-  unsigned int num_vn = 0;
-  unsigned int num_vt = 0;
-  unsigned int num_f = 0;
-  unsigned int num_faces = 0;
-
-  int mtllib_line_index = -1;
-
-  tinyobj_material_t *materials = NULL;
-  unsigned int num_materials = 0;
-
-  hash_table_t material_table;
-
-  if (len < 1) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (attrib == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (shapes == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (num_shapes == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (buf == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (materials_out == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (num_materials_out == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-
-  tinyobj_attrib_init(attrib);
-   /* 1. Find '\n' and create line data. */
-  {
-    unsigned int i;
-    unsigned int end_idx = len;
-    unsigned int prev_pos = 0;
-    unsigned int line_no = 0;
-    unsigned int last_line_ending = 0;
-
-    /* Count # of lines. */
-    for (i = 0; i < end_idx; i++) {
-      if (is_line_ending(buf, i, end_idx)) {
-        num_lines++;
-        last_line_ending = i;
-      }
-    }
-    /* The last char from the input may not be a line
-     * ending character so add an extra line if there
-     * are more characters after the last line ending
-     * that was found. */
-    if (end_idx - last_line_ending > 0) {
-        num_lines++;
-    }
-
-    if (num_lines == 0) return TINYOBJ_ERROR_EMPTY;
-
-    line_infos = (LineInfo *)TINYOBJ_MALLOC(sizeof(LineInfo) * num_lines);
-
-    /* Fill line infos. */
-    for (i = 0; i < end_idx; i++) {
-      if (is_line_ending(buf, i, end_idx)) {
-        line_infos[line_no].pos = prev_pos;
-        line_infos[line_no].len = i - prev_pos;
-        prev_pos = i + 1;
-        line_no++;
-      }
-    }
-    if (end_idx - last_line_ending > 0) {
-      line_infos[line_no].pos = prev_pos;
-      line_infos[line_no].len = end_idx - 1 - last_line_ending;
-    }
-  }
-
-  commands = (Command *)TINYOBJ_MALLOC(sizeof(Command) * num_lines); 
-
-  create_hash_table(HASH_TABLE_DEFAULT_SIZE, &material_table);
-
-  /* 2. parse each line */
-  {
-    unsigned int i = 0;
-    for (i = 0; i < num_lines; i++) {
-      int ret = parseLine(&commands[i], &buf[line_infos[i].pos],
-                          line_infos[i].len, flags & TINYOBJ_FLAG_TRIANGULATE);
-      if (ret) {
-        if (commands[i].type == COMMAND_V) {
-          num_v++;
-        } else if (commands[i].type == COMMAND_VN) {
-          num_vn++;
-        } else if (commands[i].type == COMMAND_VT) {
-          num_vt++;
-        } else if (commands[i].type == COMMAND_F) {
-          num_f += commands[i].num_f;
-          num_faces += commands[i].num_f_num_verts;
-        }
-
-        if (commands[i].type == COMMAND_MTLLIB) {
-          mtllib_line_index = (int)i;
-        }
-      }
-    }
-  }
-
-  /* line_infos are not used anymore. Release memory. */
-  if (line_infos) {
-    TINYOBJ_FREE(line_infos);
-  }
-
-  /* Load material(if exits) */
-  if (mtllib_line_index >= 0 && commands[mtllib_line_index].mtllib_name &&
-      commands[mtllib_line_index].mtllib_name_len > 0) {
-    char *filename = my_strndup(commands[mtllib_line_index].mtllib_name,
-                                commands[mtllib_line_index].mtllib_name_len);
-
-    int ret = tinyobj_parse_and_index_mtl_file(&materials, &num_materials, filename, &material_table);
-
-    if (ret != TINYOBJ_SUCCESS) {
-      /* warning. */
-      fprintf(stderr, "TINYOBJ: Failed to parse material file '%s': %d\n", filename, ret);
-    }
-
-    TINYOBJ_FREE(filename);
-
-  }
-
-  /* Construct attributes */
-
-  {
-    unsigned int v_count = 0;
-    unsigned int n_count = 0;
-    unsigned int t_count = 0;
-    unsigned int f_count = 0;
-    unsigned int face_count = 0;
-    int material_id = -1; /* -1 = default unknown material. */
-    unsigned int i = 0;
-
-    attrib->vertices = (float *)TINYOBJ_MALLOC(sizeof(float) * num_v * 3);
-    attrib->num_vertices = (unsigned int)num_v;
-    attrib->normals = (float *)TINYOBJ_MALLOC(sizeof(float) * num_vn * 3);
-    attrib->num_normals = (unsigned int)num_vn;
-    attrib->texcoords = (float *)TINYOBJ_MALLOC(sizeof(float) * num_vt * 2);
-    attrib->num_texcoords = (unsigned int)num_vt;
-    attrib->faces = (tinyobj_vertex_index_t *)TINYOBJ_MALLOC(sizeof(tinyobj_vertex_index_t) * num_f);
-    attrib->face_num_verts = (int *)TINYOBJ_MALLOC(sizeof(int) * num_faces);
-    
-    attrib->num_faces = (unsigned int)num_faces;
-    attrib->num_face_num_verts = (unsigned int)num_f;
-    
-    attrib->material_ids = (int *)TINYOBJ_MALLOC(sizeof(int) * num_faces);
-
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_EMPTY) {
-        continue;
-      } else if (commands[i].type == COMMAND_USEMTL) {
-        /* @todo
-           if (commands[t][i].material_name &&
-           commands[t][i].material_name_len > 0) {
-           std::string material_name(commands[t][i].material_name,
-           commands[t][i].material_name_len);
-
-           if (material_map.find(material_name) != material_map.end()) {
-           material_id = material_map[material_name];
-           } else {
-        // Assign invalid material ID
-        material_id = -1;
-        }
-        }
-        */
-        if (commands[i].material_name &&
-           commands[i].material_name_len >0) 
-        {
-          /* Create a null terminated string */
-          char* material_name_null_term = (char*) TINYOBJ_MALLOC(commands[i].material_name_len + 1);
-          memcpy((void*) material_name_null_term, (const void*) commands[i].material_name, commands[i].material_name_len);
-          material_name_null_term[commands[i].material_name_len] = 0;
-
-          if (hash_table_exists(material_name_null_term, &material_table))
-            material_id = (int)hash_table_get(material_name_null_term, &material_table);
-          else
-            material_id = -1;
-
-          TINYOBJ_FREE(material_name_null_term);
-        }
-      } else if (commands[i].type == COMMAND_V) {
-        attrib->vertices[3 * v_count + 0] = commands[i].vx;
-        attrib->vertices[3 * v_count + 1] = commands[i].vy;
-        attrib->vertices[3 * v_count + 2] = commands[i].vz;
-        v_count++;
-      } else if (commands[i].type == COMMAND_VN) {
-        attrib->normals[3 * n_count + 0] = commands[i].nx;
-        attrib->normals[3 * n_count + 1] = commands[i].ny;
-        attrib->normals[3 * n_count + 2] = commands[i].nz;
-        n_count++;
-      } else if (commands[i].type == COMMAND_VT) {
-        attrib->texcoords[2 * t_count + 0] = commands[i].tx;
-        attrib->texcoords[2 * t_count + 1] = commands[i].ty;
-        t_count++;
-      } else if (commands[i].type == COMMAND_F) {
-        unsigned int k = 0;
-        for (k = 0; k < commands[i].num_f; k++) {
-          tinyobj_vertex_index_t vi = commands[i].f[k];
-          int v_idx = fixIndex(vi.v_idx, v_count);
-          int vn_idx = fixIndex(vi.vn_idx, n_count);
-          int vt_idx = fixIndex(vi.vt_idx, t_count);
-          attrib->faces[f_count + k].v_idx = v_idx;
-          attrib->faces[f_count + k].vn_idx = vn_idx;
-          attrib->faces[f_count + k].vt_idx = vt_idx;
-        }
-
-        for (k = 0; k < commands[i].num_f_num_verts; k++) {
-          attrib->material_ids[face_count + k] = material_id;
-          attrib->face_num_verts[face_count + k] = commands[i].f_num_verts[k];
-        }
-
-        f_count += commands[i].num_f;
-        face_count += commands[i].num_f_num_verts;
-      }
-    }
-  }
-
-  /* 5. Construct shape information. */
-  {
-    unsigned int face_count = 0;
-    unsigned int i = 0;
-    unsigned int n = 0;
-    unsigned int shape_idx = 0;
-
-    const char *shape_name = NULL;
-    unsigned int shape_name_len = 0;
-    const char *prev_shape_name = NULL;
-    unsigned int prev_shape_name_len = 0;
-    unsigned int prev_shape_face_offset = 0;
-    unsigned int prev_face_offset = 0;
-    tinyobj_shape_t prev_shape = {NULL, 0, 0};
-
-    /* Find the number of shapes in .obj */
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_O || commands[i].type == COMMAND_G) {
-        n++;
-      }
-    }
-
-    /* Allocate array of shapes with maximum possible size(+1 for unnamed
-     * group/object).
-     * Actual # of shapes found in .obj is determined in the later */
-    (*shapes) = (tinyobj_shape_t*)TINYOBJ_MALLOC(sizeof(tinyobj_shape_t) * (n + 1));
-
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_O || commands[i].type == COMMAND_G) {
-        if (commands[i].type == COMMAND_O) {
-          shape_name = commands[i].object_name;
-          shape_name_len = commands[i].object_name_len;
-        } else {
-          shape_name = commands[i].group_name;
-          shape_name_len = commands[i].group_name_len;
-        }
-
-        if (face_count == 0) {
-          /* 'o' or 'g' appears before any 'f' */
-          prev_shape_name = shape_name;
-          prev_shape_name_len = shape_name_len;
-          prev_shape_face_offset = face_count;
-          prev_face_offset = face_count;
-        } else {
-          if (shape_idx == 0) {
-            /* 'o' or 'g' after some 'v' lines. */
-            (*shapes)[shape_idx].name = my_strndup(
-                                                   prev_shape_name, prev_shape_name_len); /* may be NULL */
-            (*shapes)[shape_idx].face_offset = prev_shape.face_offset;
-            (*shapes)[shape_idx].length = face_count - prev_face_offset;
-            shape_idx++;
-
-            prev_face_offset = face_count;
-
-          } else {
-            if ((face_count - prev_face_offset) > 0) {
-              (*shapes)[shape_idx].name =
-                my_strndup(prev_shape_name, prev_shape_name_len);
-              (*shapes)[shape_idx].face_offset = prev_face_offset;
-              (*shapes)[shape_idx].length = face_count - prev_face_offset;
-              shape_idx++;
-              prev_face_offset = face_count;
-            }
-          }
-
-          /* Record shape info for succeeding 'o' or 'g' command. */
-          prev_shape_name = shape_name;
-          prev_shape_name_len = shape_name_len;
-          prev_shape_face_offset = face_count;
-        }
-      }
-      if (commands[i].type == COMMAND_F) {
-        face_count++;
-      }
-    }
-
-    if ((face_count - prev_face_offset) > 0) {
-      unsigned int length = face_count - prev_shape_face_offset;
-      if (length > 0) {
-        (*shapes)[shape_idx].name =
-          my_strndup(prev_shape_name, prev_shape_name_len);
-        (*shapes)[shape_idx].face_offset = prev_face_offset;
-        (*shapes)[shape_idx].length = face_count - prev_face_offset;
-        shape_idx++;
-      }
-    } else {
-      /* Guess no 'v' line occurrence after 'o' or 'g', so discards current
-       * shape information. */
-    }
-
-    (*num_shapes) = shape_idx;
-  }
-
-  if (commands) {
-    TINYOBJ_FREE(commands);
-  }
-
-  destroy_hash_table(&material_table);
-  
-  (*materials_out) = materials;
-  (*num_materials_out) = num_materials;
-
-  return TINYOBJ_SUCCESS;
-}
-
-void tinyobj_attrib_init(tinyobj_attrib_t *attrib) {
-  attrib->vertices = NULL;
-  attrib->num_vertices = 0;
-  attrib->normals = NULL;
-  attrib->num_normals = 0;
-  attrib->texcoords = NULL;
-  attrib->num_texcoords = 0;
-  attrib->faces = NULL;
-  attrib->num_faces = 0;
-  attrib->face_num_verts = NULL;
-  attrib->num_face_num_verts = 0;
-  attrib->material_ids = NULL;
-}
-
-void tinyobj_attrib_free(tinyobj_attrib_t *attrib) {
-  if (attrib->vertices) TINYOBJ_FREE(attrib->vertices);
-  if (attrib->normals) TINYOBJ_FREE(attrib->normals);
-  if (attrib->texcoords) TINYOBJ_FREE(attrib->texcoords);
-  if (attrib->faces) TINYOBJ_FREE(attrib->faces);
-  if (attrib->face_num_verts) TINYOBJ_FREE(attrib->face_num_verts);
-  if (attrib->material_ids) TINYOBJ_FREE(attrib->material_ids);
-}
-
-void tinyobj_shapes_free(tinyobj_shape_t *shapes, unsigned int num_shapes) {
-  unsigned int i;
-  if (shapes == NULL) return;
-
-  for (i = 0; i < num_shapes; i++) {
-    if (shapes[i].name) TINYOBJ_FREE(shapes[i].name);
-  }
-
-  TINYOBJ_FREE(shapes);
-}
-
-void tinyobj_materials_free(tinyobj_material_t *materials,
-                            unsigned int num_materials) {
-  unsigned int i;
-  if (materials == NULL) return;
-
-  for (i = 0; i < num_materials; i++) {
-    if (materials[i].name) TINYOBJ_FREE(materials[i].name);
-    if (materials[i].ambient_texname) TINYOBJ_FREE(materials[i].ambient_texname);
-    if (materials[i].diffuse_texname) TINYOBJ_FREE(materials[i].diffuse_texname);
-    if (materials[i].specular_texname) TINYOBJ_FREE(materials[i].specular_texname);
-    if (materials[i].specular_highlight_texname)
-      TINYOBJ_FREE(materials[i].specular_highlight_texname);
-    if (materials[i].bump_texname) TINYOBJ_FREE(materials[i].bump_texname);
-    if (materials[i].displacement_texname)
-      TINYOBJ_FREE(materials[i].displacement_texname);
-    if (materials[i].alpha_texname) TINYOBJ_FREE(materials[i].alpha_texname);
-  }
-
-  TINYOBJ_FREE(materials);
-}
-#endif /* TINYOBJ_LOADER_C_IMPLEMENTATION */
-
-#endif /* TINOBJ_LOADER_C_H_ */
diff --git a/raylib_pi4_test/external/cgltf.h b/raylib_pi4_test/external/cgltf.h
deleted file mode 100644 (file)
index 4cc2d7e..0000000
+++ /dev/null
@@ -1,6327 +0,0 @@
-/**
- * cgltf - a single-file glTF 2.0 parser written in C99.
- *
- * Version: 1.10
- *
- * Website: https://github.com/jkuhlmann/cgltf
- *
- * Distributed under the MIT License, see notice at the end of this file.
- *
- * Building:
- * Include this file where you need the struct and function
- * declarations. Have exactly one source file where you define
- * `CGLTF_IMPLEMENTATION` before including this file to get the
- * function definitions.
- *
- * Reference:
- * `cgltf_result cgltf_parse(const cgltf_options*, const void*,
- * cgltf_size, cgltf_data**)` parses both glTF and GLB data. If
- * this function returns `cgltf_result_success`, you have to call
- * `cgltf_free()` on the created `cgltf_data*` variable.
- * Note that contents of external files for buffers and images are not
- * automatically loaded. You'll need to read these files yourself using
- * URIs in the `cgltf_data` structure.
- *
- * `cgltf_options` is the struct passed to `cgltf_parse()` to control
- * parts of the parsing process. You can use it to force the file type
- * and provide memory allocation as well as file operation callbacks.
- * Should be zero-initialized to trigger default behavior.
- *
- * `cgltf_data` is the struct allocated and filled by `cgltf_parse()`.
- * It generally mirrors the glTF format as described by the spec (see
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0).
- *
- * `void cgltf_free(cgltf_data*)` frees the allocated `cgltf_data`
- * variable.
- *
- * `cgltf_result cgltf_load_buffers(const cgltf_options*, cgltf_data*,
- * const char* gltf_path)` can be optionally called to open and read buffer
- * files using the `FILE*` APIs. The `gltf_path` argument is the path to
- * the original glTF file, which allows the parser to resolve the path to
- * buffer files.
- *
- * `cgltf_result cgltf_load_buffer_base64(const cgltf_options* options,
- * cgltf_size size, const char* base64, void** out_data)` decodes
- * base64-encoded data content. Used internally by `cgltf_load_buffers()`.
- * This is useful when decoding data URIs in images.
- *
- * `cgltf_result cgltf_parse_file(const cgltf_options* options, const
- * char* path, cgltf_data** out_data)` can be used to open the given
- * file using `FILE*` APIs and parse the data using `cgltf_parse()`.
- *
- * `cgltf_result cgltf_validate(cgltf_data*)` can be used to do additional
- * checks to make sure the parsed glTF data is valid.
- *
- * `cgltf_node_transform_local` converts the translation / rotation / scale properties of a node
- * into a mat4.
- *
- * `cgltf_node_transform_world` calls `cgltf_node_transform_local` on every ancestor in order
- * to compute the root-to-node transformation.
- *
- * `cgltf_accessor_unpack_floats` reads in the data from an accessor, applies sparse data (if any),
- * and converts them to floating point. Assumes that `cgltf_load_buffers` has already been called.
- * By passing null for the output pointer, users can find out how many floats are required in the
- * output buffer.
- *
- * `cgltf_accessor_num_components` is a tiny utility that tells you the dimensionality of
- * a certain accessor type. This can be used before `cgltf_accessor_unpack_floats` to help allocate
- * the necessary amount of memory.
- *
- * `cgltf_accessor_read_float` reads a certain element from a non-sparse accessor and converts it to
- * floating point, assuming that `cgltf_load_buffers` has already been called. The passed-in element
- * size is the number of floats in the output buffer, which should be in the range [1, 16]. Returns
- * false if the passed-in element_size is too small, or if the accessor is sparse.
- *
- * `cgltf_accessor_read_uint` is similar to its floating-point counterpart, but limited to reading
- * vector types and does not support matrix types. The passed-in element size is the number of uints
- * in the output buffer, which should be in the range [1, 4]. Returns false if the passed-in 
- * element_size is too small, or if the accessor is sparse.
- *
- * `cgltf_accessor_read_index` is similar to its floating-point counterpart, but it returns size_t
- * and only works with single-component data types.
- *
- * `cgltf_result cgltf_copy_extras_json(const cgltf_data*, const cgltf_extras*,
- * char* dest, cgltf_size* dest_size)` allows users to retrieve the "extras" data that
- * can be attached to many glTF objects (which can be arbitrary JSON data). The
- * `cgltf_extras` struct stores the offsets of the start and end of the extras JSON data
- * as it appears in the complete glTF JSON data. This function copies the extras data
- * into the provided buffer. If `dest` is NULL, the length of the data is written into
- * `dest_size`. You can then parse this data using your own JSON parser
- * or, if you've included the cgltf implementation using the integrated JSMN JSON parser.
- */
-#ifndef CGLTF_H_INCLUDED__
-#define CGLTF_H_INCLUDED__
-
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef size_t cgltf_size;
-typedef float cgltf_float;
-typedef int cgltf_int;
-typedef unsigned int cgltf_uint;
-typedef int cgltf_bool;
-
-typedef enum cgltf_file_type
-{
-       cgltf_file_type_invalid,
-       cgltf_file_type_gltf,
-       cgltf_file_type_glb,
-} cgltf_file_type;
-
-typedef enum cgltf_result
-{
-       cgltf_result_success,
-       cgltf_result_data_too_short,
-       cgltf_result_unknown_format,
-       cgltf_result_invalid_json,
-       cgltf_result_invalid_gltf,
-       cgltf_result_invalid_options,
-       cgltf_result_file_not_found,
-       cgltf_result_io_error,
-       cgltf_result_out_of_memory,
-       cgltf_result_legacy_gltf,
-} cgltf_result;
-
-typedef struct cgltf_memory_options
-{
-       void* (*alloc)(void* user, cgltf_size size);
-       void (*free) (void* user, void* ptr);
-       void* user_data;
-} cgltf_memory_options;
-
-typedef struct cgltf_file_options
-{
-       cgltf_result(*read)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data);
-       void (*release)(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data);
-       void* user_data;
-} cgltf_file_options;
-
-typedef struct cgltf_options
-{
-       cgltf_file_type type; /* invalid == auto detect */
-       cgltf_size json_token_count; /* 0 == auto */
-       cgltf_memory_options memory;
-       cgltf_file_options file;
-} cgltf_options;
-
-typedef enum cgltf_buffer_view_type
-{
-       cgltf_buffer_view_type_invalid,
-       cgltf_buffer_view_type_indices,
-       cgltf_buffer_view_type_vertices,
-} cgltf_buffer_view_type;
-
-typedef enum cgltf_attribute_type
-{
-       cgltf_attribute_type_invalid,
-       cgltf_attribute_type_position,
-       cgltf_attribute_type_normal,
-       cgltf_attribute_type_tangent,
-       cgltf_attribute_type_texcoord,
-       cgltf_attribute_type_color,
-       cgltf_attribute_type_joints,
-       cgltf_attribute_type_weights,
-} cgltf_attribute_type;
-
-typedef enum cgltf_component_type
-{
-       cgltf_component_type_invalid,
-       cgltf_component_type_r_8, /* BYTE */
-       cgltf_component_type_r_8u, /* UNSIGNED_BYTE */
-       cgltf_component_type_r_16, /* SHORT */
-       cgltf_component_type_r_16u, /* UNSIGNED_SHORT */
-       cgltf_component_type_r_32u, /* UNSIGNED_INT */
-       cgltf_component_type_r_32f, /* FLOAT */
-} cgltf_component_type;
-
-typedef enum cgltf_type
-{
-       cgltf_type_invalid,
-       cgltf_type_scalar,
-       cgltf_type_vec2,
-       cgltf_type_vec3,
-       cgltf_type_vec4,
-       cgltf_type_mat2,
-       cgltf_type_mat3,
-       cgltf_type_mat4,
-} cgltf_type;
-
-typedef enum cgltf_primitive_type
-{
-       cgltf_primitive_type_points,
-       cgltf_primitive_type_lines,
-       cgltf_primitive_type_line_loop,
-       cgltf_primitive_type_line_strip,
-       cgltf_primitive_type_triangles,
-       cgltf_primitive_type_triangle_strip,
-       cgltf_primitive_type_triangle_fan,
-} cgltf_primitive_type;
-
-typedef enum cgltf_alpha_mode
-{
-       cgltf_alpha_mode_opaque,
-       cgltf_alpha_mode_mask,
-       cgltf_alpha_mode_blend,
-} cgltf_alpha_mode;
-
-typedef enum cgltf_animation_path_type {
-       cgltf_animation_path_type_invalid,
-       cgltf_animation_path_type_translation,
-       cgltf_animation_path_type_rotation,
-       cgltf_animation_path_type_scale,
-       cgltf_animation_path_type_weights,
-} cgltf_animation_path_type;
-
-typedef enum cgltf_interpolation_type {
-       cgltf_interpolation_type_linear,
-       cgltf_interpolation_type_step,
-       cgltf_interpolation_type_cubic_spline,
-} cgltf_interpolation_type;
-
-typedef enum cgltf_camera_type {
-       cgltf_camera_type_invalid,
-       cgltf_camera_type_perspective,
-       cgltf_camera_type_orthographic,
-} cgltf_camera_type;
-
-typedef enum cgltf_light_type {
-       cgltf_light_type_invalid,
-       cgltf_light_type_directional,
-       cgltf_light_type_point,
-       cgltf_light_type_spot,
-} cgltf_light_type;
-
-typedef struct cgltf_extras {
-       cgltf_size start_offset;
-       cgltf_size end_offset;
-} cgltf_extras;
-
-typedef struct cgltf_extension {
-       char* name;
-       char* data;
-} cgltf_extension;
-
-typedef struct cgltf_buffer
-{
-       char* name;
-       cgltf_size size;
-       char* uri;
-       void* data; /* loaded by cgltf_load_buffers */
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_buffer;
-
-typedef enum cgltf_meshopt_compression_mode {
-       cgltf_meshopt_compression_mode_invalid,
-       cgltf_meshopt_compression_mode_attributes,
-       cgltf_meshopt_compression_mode_triangles,
-       cgltf_meshopt_compression_mode_indices,
-} cgltf_meshopt_compression_mode;
-
-typedef enum cgltf_meshopt_compression_filter {
-       cgltf_meshopt_compression_filter_none,
-       cgltf_meshopt_compression_filter_octahedral,
-       cgltf_meshopt_compression_filter_quaternion,
-       cgltf_meshopt_compression_filter_exponential,
-} cgltf_meshopt_compression_filter;
-
-typedef struct cgltf_meshopt_compression
-{
-       cgltf_buffer* buffer;
-       cgltf_size offset;
-       cgltf_size size;
-       cgltf_size stride;
-       cgltf_size count;
-       cgltf_meshopt_compression_mode mode;
-       cgltf_meshopt_compression_filter filter;
-} cgltf_meshopt_compression;
-
-typedef struct cgltf_buffer_view
-{
-       char *name;
-       cgltf_buffer* buffer;
-       cgltf_size offset;
-       cgltf_size size;
-       cgltf_size stride; /* 0 == automatically determined by accessor */
-       cgltf_buffer_view_type type;
-       void* data; /* overrides buffer->data if present, filled by extensions */
-       cgltf_bool has_meshopt_compression;
-       cgltf_meshopt_compression meshopt_compression;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_buffer_view;
-
-typedef struct cgltf_accessor_sparse
-{
-       cgltf_size count;
-       cgltf_buffer_view* indices_buffer_view;
-       cgltf_size indices_byte_offset;
-       cgltf_component_type indices_component_type;
-       cgltf_buffer_view* values_buffer_view;
-       cgltf_size values_byte_offset;
-       cgltf_extras extras;
-       cgltf_extras indices_extras;
-       cgltf_extras values_extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-       cgltf_size indices_extensions_count;
-       cgltf_extension* indices_extensions;
-       cgltf_size values_extensions_count;
-       cgltf_extension* values_extensions;
-} cgltf_accessor_sparse;
-
-typedef struct cgltf_accessor
-{
-       char* name;
-       cgltf_component_type component_type;
-       cgltf_bool normalized;
-       cgltf_type type;
-       cgltf_size offset;
-       cgltf_size count;
-       cgltf_size stride;
-       cgltf_buffer_view* buffer_view;
-       cgltf_bool has_min;
-       cgltf_float min[16];
-       cgltf_bool has_max;
-       cgltf_float max[16];
-       cgltf_bool is_sparse;
-       cgltf_accessor_sparse sparse;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_accessor;
-
-typedef struct cgltf_attribute
-{
-       char* name;
-       cgltf_attribute_type type;
-       cgltf_int index;
-       cgltf_accessor* data;
-} cgltf_attribute;
-
-typedef struct cgltf_image
-{
-       char* name;
-       char* uri;
-       cgltf_buffer_view* buffer_view;
-       char* mime_type;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_image;
-
-typedef struct cgltf_sampler
-{
-       char* name;
-       cgltf_int mag_filter;
-       cgltf_int min_filter;
-       cgltf_int wrap_s;
-       cgltf_int wrap_t;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_sampler;
-
-typedef struct cgltf_texture
-{
-       char* name;
-       cgltf_image* image;
-       cgltf_sampler* sampler;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_texture;
-
-typedef struct cgltf_texture_transform
-{
-       cgltf_float offset[2];
-       cgltf_float rotation;
-       cgltf_float scale[2];
-       cgltf_int texcoord;
-} cgltf_texture_transform;
-
-typedef struct cgltf_texture_view
-{
-       cgltf_texture* texture;
-       cgltf_int texcoord;
-       cgltf_float scale; /* equivalent to strength for occlusion_texture */
-       cgltf_bool has_transform;
-       cgltf_texture_transform transform;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_texture_view;
-
-typedef struct cgltf_pbr_metallic_roughness
-{
-       cgltf_texture_view base_color_texture;
-       cgltf_texture_view metallic_roughness_texture;
-
-       cgltf_float base_color_factor[4];
-       cgltf_float metallic_factor;
-       cgltf_float roughness_factor;
-
-       cgltf_extras extras;
-} cgltf_pbr_metallic_roughness;
-
-typedef struct cgltf_pbr_specular_glossiness
-{
-       cgltf_texture_view diffuse_texture;
-       cgltf_texture_view specular_glossiness_texture;
-
-       cgltf_float diffuse_factor[4];
-       cgltf_float specular_factor[3];
-       cgltf_float glossiness_factor;
-} cgltf_pbr_specular_glossiness;
-
-typedef struct cgltf_clearcoat
-{
-       cgltf_texture_view clearcoat_texture;
-       cgltf_texture_view clearcoat_roughness_texture;
-       cgltf_texture_view clearcoat_normal_texture;
-
-       cgltf_float clearcoat_factor;
-       cgltf_float clearcoat_roughness_factor;
-} cgltf_clearcoat;
-
-typedef struct cgltf_transmission
-{
-       cgltf_texture_view transmission_texture;
-       cgltf_float transmission_factor;
-} cgltf_transmission;
-
-typedef struct cgltf_ior
-{
-       cgltf_float ior;
-} cgltf_ior;
-
-typedef struct cgltf_specular
-{
-       cgltf_texture_view specular_texture;
-       cgltf_texture_view specular_color_texture;
-       cgltf_float specular_color_factor[3];
-       cgltf_float specular_factor;
-} cgltf_specular;
-
-typedef struct cgltf_volume
-{
-       cgltf_texture_view thickness_texture;
-       cgltf_float thickness_factor;
-       cgltf_float attenuation_color[3];
-       cgltf_float attenuation_distance;
-} cgltf_volume;
-
-typedef struct cgltf_sheen
-{
-       cgltf_texture_view sheen_color_texture;
-       cgltf_float sheen_color_factor[3];
-       cgltf_texture_view sheen_roughness_texture;
-       cgltf_float sheen_roughness_factor;
-} cgltf_sheen;
-
-typedef struct cgltf_material
-{
-       char* name;
-       cgltf_bool has_pbr_metallic_roughness;
-       cgltf_bool has_pbr_specular_glossiness;
-       cgltf_bool has_clearcoat;
-       cgltf_bool has_transmission;
-       cgltf_bool has_volume;
-       cgltf_bool has_ior;
-       cgltf_bool has_specular;
-       cgltf_bool has_sheen;
-       cgltf_pbr_metallic_roughness pbr_metallic_roughness;
-       cgltf_pbr_specular_glossiness pbr_specular_glossiness;
-       cgltf_clearcoat clearcoat;
-       cgltf_ior ior;
-       cgltf_specular specular;
-       cgltf_sheen sheen;
-       cgltf_transmission transmission;
-       cgltf_volume volume;
-       cgltf_texture_view normal_texture;
-       cgltf_texture_view occlusion_texture;
-       cgltf_texture_view emissive_texture;
-       cgltf_float emissive_factor[3];
-       cgltf_alpha_mode alpha_mode;
-       cgltf_float alpha_cutoff;
-       cgltf_bool double_sided;
-       cgltf_bool unlit;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_material;
-
-typedef struct cgltf_material_mapping
-{
-       cgltf_size variant;
-       cgltf_material* material;
-       cgltf_extras extras;
-} cgltf_material_mapping;
-
-typedef struct cgltf_morph_target {
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-} cgltf_morph_target;
-
-typedef struct cgltf_draco_mesh_compression {
-       cgltf_buffer_view* buffer_view;
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-} cgltf_draco_mesh_compression;
-
-typedef struct cgltf_primitive {
-       cgltf_primitive_type type;
-       cgltf_accessor* indices;
-       cgltf_material* material;
-       cgltf_attribute* attributes;
-       cgltf_size attributes_count;
-       cgltf_morph_target* targets;
-       cgltf_size targets_count;
-       cgltf_extras extras;
-       cgltf_bool has_draco_mesh_compression;
-       cgltf_draco_mesh_compression draco_mesh_compression;
-       cgltf_material_mapping* mappings;
-       cgltf_size mappings_count;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_primitive;
-
-typedef struct cgltf_mesh {
-       char* name;
-       cgltf_primitive* primitives;
-       cgltf_size primitives_count;
-       cgltf_float* weights;
-       cgltf_size weights_count;
-       char** target_names;
-       cgltf_size target_names_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_mesh;
-
-typedef struct cgltf_node cgltf_node;
-
-typedef struct cgltf_skin {
-       char* name;
-       cgltf_node** joints;
-       cgltf_size joints_count;
-       cgltf_node* skeleton;
-       cgltf_accessor* inverse_bind_matrices;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_skin;
-
-typedef struct cgltf_camera_perspective {
-       cgltf_bool has_aspect_ratio;
-       cgltf_float aspect_ratio;
-       cgltf_float yfov;
-       cgltf_bool has_zfar;
-       cgltf_float zfar;
-       cgltf_float znear;
-       cgltf_extras extras;
-} cgltf_camera_perspective;
-
-typedef struct cgltf_camera_orthographic {
-       cgltf_float xmag;
-       cgltf_float ymag;
-       cgltf_float zfar;
-       cgltf_float znear;
-       cgltf_extras extras;
-} cgltf_camera_orthographic;
-
-typedef struct cgltf_camera {
-       char* name;
-       cgltf_camera_type type;
-       union {
-               cgltf_camera_perspective perspective;
-               cgltf_camera_orthographic orthographic;
-       } data;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_camera;
-
-typedef struct cgltf_light {
-       char* name;
-       cgltf_float color[3];
-       cgltf_float intensity;
-       cgltf_light_type type;
-       cgltf_float range;
-       cgltf_float spot_inner_cone_angle;
-       cgltf_float spot_outer_cone_angle;
-} cgltf_light;
-
-struct cgltf_node {
-       char* name;
-       cgltf_node* parent;
-       cgltf_node** children;
-       cgltf_size children_count;
-       cgltf_skin* skin;
-       cgltf_mesh* mesh;
-       cgltf_camera* camera;
-       cgltf_light* light;
-       cgltf_float* weights;
-       cgltf_size weights_count;
-       cgltf_bool has_translation;
-       cgltf_bool has_rotation;
-       cgltf_bool has_scale;
-       cgltf_bool has_matrix;
-       cgltf_float translation[3];
-       cgltf_float rotation[4];
-       cgltf_float scale[3];
-       cgltf_float matrix[16];
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-};
-
-typedef struct cgltf_scene {
-       char* name;
-       cgltf_node** nodes;
-       cgltf_size nodes_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_scene;
-
-typedef struct cgltf_animation_sampler {
-       cgltf_accessor* input;
-       cgltf_accessor* output;
-       cgltf_interpolation_type interpolation;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation_sampler;
-
-typedef struct cgltf_animation_channel {
-       cgltf_animation_sampler* sampler;
-       cgltf_node* target_node;
-       cgltf_animation_path_type target_path;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation_channel;
-
-typedef struct cgltf_animation {
-       char* name;
-       cgltf_animation_sampler* samplers;
-       cgltf_size samplers_count;
-       cgltf_animation_channel* channels;
-       cgltf_size channels_count;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_animation;
-
-typedef struct cgltf_material_variant
-{
-       char* name;
-       cgltf_extras extras;
-} cgltf_material_variant;
-
-typedef struct cgltf_asset {
-       char* copyright;
-       char* generator;
-       char* version;
-       char* min_version;
-       cgltf_extras extras;
-       cgltf_size extensions_count;
-       cgltf_extension* extensions;
-} cgltf_asset;
-
-typedef struct cgltf_data
-{
-       cgltf_file_type file_type;
-       void* file_data;
-
-       cgltf_asset asset;
-
-       cgltf_mesh* meshes;
-       cgltf_size meshes_count;
-
-       cgltf_material* materials;
-       cgltf_size materials_count;
-
-       cgltf_accessor* accessors;
-       cgltf_size accessors_count;
-
-       cgltf_buffer_view* buffer_views;
-       cgltf_size buffer_views_count;
-
-       cgltf_buffer* buffers;
-       cgltf_size buffers_count;
-
-       cgltf_image* images;
-       cgltf_size images_count;
-
-       cgltf_texture* textures;
-       cgltf_size textures_count;
-
-       cgltf_sampler* samplers;
-       cgltf_size samplers_count;
-
-       cgltf_skin* skins;
-       cgltf_size skins_count;
-
-       cgltf_camera* cameras;
-       cgltf_size cameras_count;
-
-       cgltf_light* lights;
-       cgltf_size lights_count;
-
-       cgltf_node* nodes;
-       cgltf_size nodes_count;
-
-       cgltf_scene* scenes;
-       cgltf_size scenes_count;
-
-       cgltf_scene* scene;
-
-       cgltf_animation* animations;
-       cgltf_size animations_count;
-
-       cgltf_material_variant* variants;
-       cgltf_size variants_count;
-
-       cgltf_extras extras;
-
-       cgltf_size data_extensions_count;
-       cgltf_extension* data_extensions;
-
-       char** extensions_used;
-       cgltf_size extensions_used_count;
-
-       char** extensions_required;
-       cgltf_size extensions_required_count;
-
-       const char* json;
-       cgltf_size json_size;
-
-       const void* bin;
-       cgltf_size bin_size;
-
-       cgltf_memory_options memory;
-       cgltf_file_options file;
-} cgltf_data;
-
-cgltf_result cgltf_parse(
-               const cgltf_options* options,
-               const void* data,
-               cgltf_size size,
-               cgltf_data** out_data);
-
-cgltf_result cgltf_parse_file(
-               const cgltf_options* options,
-               const char* path,
-               cgltf_data** out_data);
-
-cgltf_result cgltf_load_buffers(
-               const cgltf_options* options,
-               cgltf_data* data,
-               const char* gltf_path);
-
-cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data);
-
-void cgltf_decode_uri(char* uri);
-
-cgltf_result cgltf_validate(cgltf_data* data);
-
-void cgltf_free(cgltf_data* data);
-
-void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix);
-void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix);
-
-cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size);
-cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size);
-cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index);
-
-cgltf_size cgltf_num_components(cgltf_type type);
-
-cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count);
-
-cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* #ifndef CGLTF_H_INCLUDED__ */
-
-/*
- *
- * Stop now, if you are only interested in the API.
- * Below, you find the implementation.
- *
- */
-
-#if defined(__INTELLISENSE__) || defined(__JETBRAINS_IDE__)
-/* This makes MSVC/CLion intellisense work. */
-#define CGLTF_IMPLEMENTATION
-#endif
-
-#ifdef CGLTF_IMPLEMENTATION
-
-#include <stdint.h> /* For uint8_t, uint32_t */
-#include <string.h> /* For strncpy */
-#include <stdio.h>  /* For fopen */
-#include <limits.h> /* For UINT_MAX etc */
-#include <float.h>  /* For FLT_MAX */
-
-#if !defined(CGLTF_MALLOC) || !defined(CGLTF_FREE) || !defined(CGLTF_ATOI) || !defined(CGLTF_ATOF)
-#include <stdlib.h> /* For malloc, free, atoi, atof */
-#endif
-
-/* JSMN_PARENT_LINKS is necessary to make parsing large structures linear in input size */
-#define JSMN_PARENT_LINKS
-
-/* JSMN_STRICT is necessary to reject invalid JSON documents */
-#define JSMN_STRICT
-
-/*
- * -- jsmn.h start --
- * Source: https://github.com/zserge/jsmn
- * License: MIT
- */
-typedef enum {
-       JSMN_UNDEFINED = 0,
-       JSMN_OBJECT = 1,
-       JSMN_ARRAY = 2,
-       JSMN_STRING = 3,
-       JSMN_PRIMITIVE = 4
-} jsmntype_t;
-enum jsmnerr {
-       /* Not enough tokens were provided */
-       JSMN_ERROR_NOMEM = -1,
-       /* Invalid character inside JSON string */
-       JSMN_ERROR_INVAL = -2,
-       /* The string is not a full JSON packet, more bytes expected */
-       JSMN_ERROR_PART = -3
-};
-typedef struct {
-       jsmntype_t type;
-       int start;
-       int end;
-       int size;
-#ifdef JSMN_PARENT_LINKS
-       int parent;
-#endif
-} jsmntok_t;
-typedef struct {
-       unsigned int pos; /* offset in the JSON string */
-       unsigned int toknext; /* next token to allocate */
-       int toksuper; /* superior token node, e.g parent object or array */
-} jsmn_parser;
-static void jsmn_init(jsmn_parser *parser);
-static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len, jsmntok_t *tokens, size_t num_tokens);
-/*
- * -- jsmn.h end --
- */
-
-
-static const cgltf_size GlbHeaderSize = 12;
-static const cgltf_size GlbChunkHeaderSize = 8;
-static const uint32_t GlbVersion = 2;
-static const uint32_t GlbMagic = 0x46546C67;
-static const uint32_t GlbMagicJsonChunk = 0x4E4F534A;
-static const uint32_t GlbMagicBinChunk = 0x004E4942;
-
-#ifndef CGLTF_MALLOC
-#define CGLTF_MALLOC(size) malloc(size)
-#endif
-#ifndef CGLTF_FREE
-#define CGLTF_FREE(ptr) free(ptr)
-#endif
-#ifndef CGLTF_ATOI
-#define CGLTF_ATOI(str) atoi(str)
-#endif
-#ifndef CGLTF_ATOF
-#define CGLTF_ATOF(str) atof(str)
-#endif
-#ifndef CGLTF_VALIDATE_ENABLE_ASSERTS
-#define CGLTF_VALIDATE_ENABLE_ASSERTS 0
-#endif
-
-static void* cgltf_default_alloc(void* user, cgltf_size size)
-{
-       (void)user;
-       return CGLTF_MALLOC(size);
-}
-
-static void cgltf_default_free(void* user, void* ptr)
-{
-       (void)user;
-       CGLTF_FREE(ptr);
-}
-
-static void* cgltf_calloc(cgltf_options* options, size_t element_size, cgltf_size count)
-{
-       if (SIZE_MAX / element_size < count)
-       {
-               return NULL;
-       }
-       void* result = options->memory.alloc(options->memory.user_data, element_size * count);
-       if (!result)
-       {
-               return NULL;
-       }
-       memset(result, 0, element_size * count);
-       return result;
-}
-
-static cgltf_result cgltf_default_file_read(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, const char* path, cgltf_size* size, void** data)
-{
-       (void)file_options;
-       void* (*memory_alloc)(void*, cgltf_size) = memory_options->alloc ? memory_options->alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free;
-
-       FILE* file = fopen(path, "rb");
-       if (!file)
-       {
-               return cgltf_result_file_not_found;
-       }
-
-       cgltf_size file_size = size ? *size : 0;
-
-       if (file_size == 0)
-       {
-               fseek(file, 0, SEEK_END);
-
-               long length = ftell(file);
-               if (length < 0)
-               {
-                       fclose(file);
-                       return cgltf_result_io_error;
-               }
-
-               fseek(file, 0, SEEK_SET);
-               file_size = (cgltf_size)length;
-       }
-
-       char* file_data = (char*)memory_alloc(memory_options->user_data, file_size);
-       if (!file_data)
-       {
-               fclose(file);
-               return cgltf_result_out_of_memory;
-       }
-       
-       cgltf_size read_size = fread(file_data, 1, file_size, file);
-
-       fclose(file);
-
-       if (read_size != file_size)
-       {
-               memory_free(memory_options->user_data, file_data);
-               return cgltf_result_io_error;
-       }
-
-       if (size)
-       {
-               *size = file_size;
-       }
-       if (data)
-       {
-               *data = file_data;
-       }
-
-       return cgltf_result_success;
-}
-
-static void cgltf_default_file_release(const struct cgltf_memory_options* memory_options, const struct cgltf_file_options* file_options, void* data)
-{
-       (void)file_options;
-       void (*memfree)(void*, void*) = memory_options->free ? memory_options->free : &cgltf_default_free;
-       memfree(memory_options->user_data, data);
-}
-
-static cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data);
-
-cgltf_result cgltf_parse(const cgltf_options* options, const void* data, cgltf_size size, cgltf_data** out_data)
-{
-       if (size < GlbHeaderSize)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       cgltf_options fixed_options = *options;
-       if (fixed_options.memory.alloc == NULL)
-       {
-               fixed_options.memory.alloc = &cgltf_default_alloc;
-       }
-       if (fixed_options.memory.free == NULL)
-       {
-               fixed_options.memory.free = &cgltf_default_free;
-       }
-
-       uint32_t tmp;
-       // Magic
-       memcpy(&tmp, data, 4);
-       if (tmp != GlbMagic)
-       {
-               if (fixed_options.type == cgltf_file_type_invalid)
-               {
-                       fixed_options.type = cgltf_file_type_gltf;
-               }
-               else if (fixed_options.type == cgltf_file_type_glb)
-               {
-                       return cgltf_result_unknown_format;
-               }
-       }
-
-       if (fixed_options.type == cgltf_file_type_gltf)
-       {
-               cgltf_result json_result = cgltf_parse_json(&fixed_options, (const uint8_t*)data, size, out_data);
-               if (json_result != cgltf_result_success)
-               {
-                       return json_result;
-               }
-
-               (*out_data)->file_type = cgltf_file_type_gltf;
-
-               return cgltf_result_success;
-       }
-
-       const uint8_t* ptr = (const uint8_t*)data;
-       // Version
-       memcpy(&tmp, ptr + 4, 4);
-       uint32_t version = tmp;
-       if (version != GlbVersion)
-       {
-               return version < GlbVersion ? cgltf_result_legacy_gltf : cgltf_result_unknown_format;
-       }
-
-       // Total length
-       memcpy(&tmp, ptr + 8, 4);
-       if (tmp > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       const uint8_t* json_chunk = ptr + GlbHeaderSize;
-
-       if (GlbHeaderSize + GlbChunkHeaderSize > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       // JSON chunk: length
-       uint32_t json_length;
-       memcpy(&json_length, json_chunk, 4);
-       if (GlbHeaderSize + GlbChunkHeaderSize + json_length > size)
-       {
-               return cgltf_result_data_too_short;
-       }
-
-       // JSON chunk: magic
-       memcpy(&tmp, json_chunk + 4, 4);
-       if (tmp != GlbMagicJsonChunk)
-       {
-               return cgltf_result_unknown_format;
-       }
-
-       json_chunk += GlbChunkHeaderSize;
-
-       const void* bin = 0;
-       cgltf_size bin_size = 0;
-
-       if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize <= size)
-       {
-               // We can read another chunk
-               const uint8_t* bin_chunk = json_chunk + json_length;
-
-               // Bin chunk: length
-               uint32_t bin_length;
-               memcpy(&bin_length, bin_chunk, 4);
-               if (GlbHeaderSize + GlbChunkHeaderSize + json_length + GlbChunkHeaderSize + bin_length > size)
-               {
-                       return cgltf_result_data_too_short;
-               }
-
-               // Bin chunk: magic
-               memcpy(&tmp, bin_chunk + 4, 4);
-               if (tmp != GlbMagicBinChunk)
-               {
-                       return cgltf_result_unknown_format;
-               }
-
-               bin_chunk += GlbChunkHeaderSize;
-
-               bin = bin_chunk;
-               bin_size = bin_length;
-       }
-
-       cgltf_result json_result = cgltf_parse_json(&fixed_options, json_chunk, json_length, out_data);
-       if (json_result != cgltf_result_success)
-       {
-               return json_result;
-       }
-
-       (*out_data)->file_type = cgltf_file_type_glb;
-       (*out_data)->bin = bin;
-       (*out_data)->bin_size = bin_size;
-
-       return cgltf_result_success;
-}
-
-cgltf_result cgltf_parse_file(const cgltf_options* options, const char* path, cgltf_data** out_data)
-{
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-       cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
-
-       void* file_data = NULL;
-       cgltf_size file_size = 0;
-       cgltf_result result = file_read(&options->memory, &options->file, path, &file_size, &file_data);
-       if (result != cgltf_result_success)
-       {
-               return result;
-       }
-
-       result = cgltf_parse(options, file_data, file_size, out_data);
-
-       if (result != cgltf_result_success)
-       {
-               memory_free(options->memory.user_data, file_data);
-               return result;
-       }
-
-       (*out_data)->file_data = file_data;
-
-       return cgltf_result_success;
-}
-
-static void cgltf_combine_paths(char* path, const char* base, const char* uri)
-{
-       const char* s0 = strrchr(base, '/');
-       const char* s1 = strrchr(base, '\\');
-       const char* slash = s0 ? (s1 && s1 > s0 ? s1 : s0) : s1;
-
-       if (slash)
-       {
-               size_t prefix = slash - base + 1;
-
-               strncpy(path, base, prefix);
-               strcpy(path + prefix, uri);
-       }
-       else
-       {
-               strcpy(path, uri);
-       }
-}
-
-static cgltf_result cgltf_load_buffer_file(const cgltf_options* options, cgltf_size size, const char* uri, const char* gltf_path, void** out_data)
-{
-       void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-       cgltf_result (*file_read)(const struct cgltf_memory_options*, const struct cgltf_file_options*, const char*, cgltf_size*, void**) = options->file.read ? options->file.read : &cgltf_default_file_read;
-
-       char* path = (char*)memory_alloc(options->memory.user_data, strlen(uri) + strlen(gltf_path) + 1);
-       if (!path)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       cgltf_combine_paths(path, gltf_path, uri);
-
-       // after combining, the tail of the resulting path is a uri; decode_uri converts it into path
-       cgltf_decode_uri(path + strlen(path) - strlen(uri));
-
-       void* file_data = NULL;
-       cgltf_result result = file_read(&options->memory, &options->file, path, &size, &file_data);
-
-       memory_free(options->memory.user_data, path);
-
-       *out_data = (result == cgltf_result_success) ? file_data : NULL;
-
-       return result;
-}
-
-cgltf_result cgltf_load_buffer_base64(const cgltf_options* options, cgltf_size size, const char* base64, void** out_data)
-{
-       void* (*memory_alloc)(void*, cgltf_size) = options->memory.alloc ? options->memory.alloc : &cgltf_default_alloc;
-       void (*memory_free)(void*, void*) = options->memory.free ? options->memory.free : &cgltf_default_free;
-
-       unsigned char* data = (unsigned char*)memory_alloc(options->memory.user_data, size);
-       if (!data)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       unsigned int buffer = 0;
-       unsigned int buffer_bits = 0;
-
-       for (cgltf_size i = 0; i < size; ++i)
-       {
-               while (buffer_bits < 8)
-               {
-                       char ch = *base64++;
-
-                       int index =
-                               (unsigned)(ch - 'A') < 26 ? (ch - 'A') :
-                               (unsigned)(ch - 'a') < 26 ? (ch - 'a') + 26 :
-                               (unsigned)(ch - '0') < 10 ? (ch - '0') + 52 :
-                               ch == '+' ? 62 :
-                               ch == '/' ? 63 :
-                               -1;
-
-                       if (index < 0)
-                       {
-                               memory_free(options->memory.user_data, data);
-                               return cgltf_result_io_error;
-                       }
-
-                       buffer = (buffer << 6) | index;
-                       buffer_bits += 6;
-               }
-
-               data[i] = (unsigned char)(buffer >> (buffer_bits - 8));
-               buffer_bits -= 8;
-       }
-
-       *out_data = data;
-
-       return cgltf_result_success;
-}
-
-static int cgltf_unhex(char ch)
-{
-       return
-               (unsigned)(ch - '0') < 10 ? (ch - '0') :
-               (unsigned)(ch - 'A') < 6 ? (ch - 'A') + 10 :
-               (unsigned)(ch - 'a') < 6 ? (ch - 'a') + 10 :
-               -1;
-}
-
-void cgltf_decode_uri(char* uri)
-{
-       char* write = uri;
-       char* i = uri;
-
-       while (*i)
-       {
-               if (*i == '%')
-               {
-                       int ch1 = cgltf_unhex(i[1]);
-
-                       if (ch1 >= 0)
-                       {
-                               int ch2 = cgltf_unhex(i[2]);
-
-                               if (ch2 >= 0)
-                               {
-                                       *write++ = (char)(ch1 * 16 + ch2);
-                                       i += 3;
-                                       continue;
-                               }
-                       }
-               }
-
-               *write++ = *i++;
-       }
-
-       *write = 0;
-}
-
-cgltf_result cgltf_load_buffers(const cgltf_options* options, cgltf_data* data, const char* gltf_path)
-{
-       if (options == NULL)
-       {
-               return cgltf_result_invalid_options;
-       }
-
-       if (data->buffers_count && data->buffers[0].data == NULL && data->buffers[0].uri == NULL && data->bin)
-       {
-               if (data->bin_size < data->buffers[0].size)
-               {
-                       return cgltf_result_data_too_short;
-               }
-
-               data->buffers[0].data = (void*)data->bin;
-       }
-
-       for (cgltf_size i = 0; i < data->buffers_count; ++i)
-       {
-               if (data->buffers[i].data)
-               {
-                       continue;
-               }
-
-               const char* uri = data->buffers[i].uri;
-
-               if (uri == NULL)
-               {
-                       continue;
-               }
-
-               if (strncmp(uri, "data:", 5) == 0)
-               {
-                       const char* comma = strchr(uri, ',');
-
-                       if (comma && comma - uri >= 7 && strncmp(comma - 7, ";base64", 7) == 0)
-                       {
-                               cgltf_result res = cgltf_load_buffer_base64(options, data->buffers[i].size, comma + 1, &data->buffers[i].data);
-
-                               if (res != cgltf_result_success)
-                               {
-                                       return res;
-                               }
-                       }
-                       else
-                       {
-                               return cgltf_result_unknown_format;
-                       }
-               }
-               else if (strstr(uri, "://") == NULL && gltf_path)
-               {
-                       cgltf_result res = cgltf_load_buffer_file(options, data->buffers[i].size, uri, gltf_path, &data->buffers[i].data);
-
-                       if (res != cgltf_result_success)
-                       {
-                               return res;
-                       }
-               }
-               else
-               {
-                       return cgltf_result_unknown_format;
-               }
-       }
-
-       return cgltf_result_success;
-}
-
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type);
-
-static cgltf_size cgltf_calc_index_bound(cgltf_buffer_view* buffer_view, cgltf_size offset, cgltf_component_type component_type, cgltf_size count)
-{
-       char* data = (char*)buffer_view->buffer->data + offset + buffer_view->offset;
-       cgltf_size bound = 0;
-
-       switch (component_type)
-       {
-       case cgltf_component_type_r_8u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned char*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       case cgltf_component_type_r_16u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned short*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       case cgltf_component_type_r_32u:
-               for (size_t i = 0; i < count; ++i)
-               {
-                       cgltf_size v = ((unsigned int*)data)[i];
-                       bound = bound > v ? bound : v;
-               }
-               break;
-
-       default:
-               ;
-       }
-
-       return bound;
-}
-
-#if CGLTF_VALIDATE_ENABLE_ASSERTS
-#define CGLTF_ASSERT_IF(cond, result) assert(!(cond)); if (cond) return result;
-#else
-#define CGLTF_ASSERT_IF(cond, result) if (cond) return result;
-#endif
-
-cgltf_result cgltf_validate(cgltf_data* data)
-{
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               cgltf_accessor* accessor = &data->accessors[i];
-
-               cgltf_size element_size = cgltf_calc_size(accessor->type, accessor->component_type);
-
-               if (accessor->buffer_view)
-               {
-                       cgltf_size req_size = accessor->offset + accessor->stride * (accessor->count - 1) + element_size;
-
-                       CGLTF_ASSERT_IF(accessor->buffer_view->size < req_size, cgltf_result_data_too_short);
-               }
-
-               if (accessor->is_sparse)
-               {
-                       cgltf_accessor_sparse* sparse = &accessor->sparse;
-
-                       cgltf_size indices_component_size = cgltf_calc_size(cgltf_type_scalar, sparse->indices_component_type);
-                       cgltf_size indices_req_size = sparse->indices_byte_offset + indices_component_size * sparse->count;
-                       cgltf_size values_req_size = sparse->values_byte_offset + element_size * sparse->count;
-
-                       CGLTF_ASSERT_IF(sparse->indices_buffer_view->size < indices_req_size ||
-                                                       sparse->values_buffer_view->size < values_req_size, cgltf_result_data_too_short);
-
-                       CGLTF_ASSERT_IF(sparse->indices_component_type != cgltf_component_type_r_8u &&
-                                                       sparse->indices_component_type != cgltf_component_type_r_16u &&
-                                                       sparse->indices_component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
-
-                       if (sparse->indices_buffer_view->buffer->data)
-                       {
-                               cgltf_size index_bound = cgltf_calc_index_bound(sparse->indices_buffer_view, sparse->indices_byte_offset, sparse->indices_component_type, sparse->count);
-
-                               CGLTF_ASSERT_IF(index_bound >= accessor->count, cgltf_result_data_too_short);
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               cgltf_size req_size = data->buffer_views[i].offset + data->buffer_views[i].size;
-
-               CGLTF_ASSERT_IF(data->buffer_views[i].buffer && data->buffer_views[i].buffer->size < req_size, cgltf_result_data_too_short);
-
-               if (data->buffer_views[i].has_meshopt_compression)
-               {
-                       cgltf_meshopt_compression* mc = &data->buffer_views[i].meshopt_compression;
-
-                       CGLTF_ASSERT_IF(mc->buffer == NULL || mc->buffer->size < mc->offset + mc->size, cgltf_result_data_too_short);
-
-                       CGLTF_ASSERT_IF(data->buffer_views[i].stride && mc->stride != data->buffer_views[i].stride, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(data->buffer_views[i].size != mc->stride * mc->count, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_invalid, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_attributes && !(mc->stride % 4 == 0 && mc->stride <= 256), cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->mode == cgltf_meshopt_compression_mode_triangles && mc->count % 3 != 0, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->stride != 2 && mc->stride != 4, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF((mc->mode == cgltf_meshopt_compression_mode_triangles || mc->mode == cgltf_meshopt_compression_mode_indices) && mc->filter != cgltf_meshopt_compression_filter_none, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_octahedral && mc->stride != 4 && mc->stride != 8, cgltf_result_invalid_gltf);
-
-                       CGLTF_ASSERT_IF(mc->filter == cgltf_meshopt_compression_filter_quaternion && mc->stride != 8, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               if (data->meshes[i].weights)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].weights_count, cgltf_result_invalid_gltf);
-               }
-
-               if (data->meshes[i].target_names)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives_count && data->meshes[i].primitives[0].targets_count != data->meshes[i].target_names_count, cgltf_result_invalid_gltf);
-               }
-
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets_count != data->meshes[i].primitives[0].targets_count, cgltf_result_invalid_gltf);
-
-                       if (data->meshes[i].primitives[j].attributes_count)
-                       {
-                               cgltf_accessor* first = data->meshes[i].primitives[j].attributes[0].data;
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                               {
-                                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
-                               }
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                               {
-                                       for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                                       {
-                                               CGLTF_ASSERT_IF(data->meshes[i].primitives[j].targets[k].attributes[m].data->count != first->count, cgltf_result_invalid_gltf);
-                                       }
-                               }
-
-                               cgltf_accessor* indices = data->meshes[i].primitives[j].indices;
-
-                               CGLTF_ASSERT_IF(indices &&
-                                       indices->component_type != cgltf_component_type_r_8u &&
-                                       indices->component_type != cgltf_component_type_r_16u &&
-                                       indices->component_type != cgltf_component_type_r_32u, cgltf_result_invalid_gltf);
-
-                               if (indices && indices->buffer_view && indices->buffer_view->buffer->data)
-                               {
-                                       cgltf_size index_bound = cgltf_calc_index_bound(indices->buffer_view, indices->offset, indices->component_type, indices->count);
-
-                                       CGLTF_ASSERT_IF(index_bound >= first->count, cgltf_result_data_too_short);
-                               }
-
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
-                               {
-                                       CGLTF_ASSERT_IF(data->meshes[i].primitives[j].mappings[k].variant >= data->variants_count, cgltf_result_invalid_gltf);
-                               }
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               if (data->nodes[i].weights && data->nodes[i].mesh)
-               {
-                       CGLTF_ASSERT_IF (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               cgltf_node* p1 = data->nodes[i].parent;
-               cgltf_node* p2 = p1 ? p1->parent : NULL;
-
-               while (p1 && p2)
-               {
-                       CGLTF_ASSERT_IF(p1 == p2, cgltf_result_invalid_gltf);
-
-                       p1 = p1->parent;
-                       p2 = p2->parent ? p2->parent->parent : NULL;
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
-               {
-                       CGLTF_ASSERT_IF(data->scenes[i].nodes[j]->parent, cgltf_result_invalid_gltf);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
-               {
-                       cgltf_animation_channel* channel = &data->animations[i].channels[j];
-
-                       if (!channel->target_node)
-                       {
-                               continue;
-                       }
-
-                       cgltf_size components = 1;
-
-                       if (channel->target_path == cgltf_animation_path_type_weights)
-                       {
-                               CGLTF_ASSERT_IF(!channel->target_node->mesh || !channel->target_node->mesh->primitives_count, cgltf_result_invalid_gltf);
-
-                               components = channel->target_node->mesh->primitives[0].targets_count;
-                       }
-
-                       cgltf_size values = channel->sampler->interpolation == cgltf_interpolation_type_cubic_spline ? 3 : 1;
-
-                       CGLTF_ASSERT_IF(channel->sampler->input->count * components * values != channel->sampler->output->count, cgltf_result_data_too_short);
-               }
-       }
-
-       return cgltf_result_success;
-}
-
-cgltf_result cgltf_copy_extras_json(const cgltf_data* data, const cgltf_extras* extras, char* dest, cgltf_size* dest_size)
-{
-       cgltf_size json_size = extras->end_offset - extras->start_offset;
-
-       if (!dest)
-       {
-               if (dest_size)
-               {
-                       *dest_size = json_size + 1;
-                       return cgltf_result_success;
-               }
-               return cgltf_result_invalid_options;
-       }
-
-       if (*dest_size + 1 < json_size)
-       {
-               strncpy(dest, data->json + extras->start_offset, *dest_size - 1);
-               dest[*dest_size - 1] = 0;
-       }
-       else
-       {
-               strncpy(dest, data->json + extras->start_offset, json_size);
-               dest[json_size] = 0;
-       }
-
-       return cgltf_result_success;
-}
-
-void cgltf_free_extensions(cgltf_data* data, cgltf_extension* extensions, cgltf_size extensions_count)
-{
-       for (cgltf_size i = 0; i < extensions_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, extensions[i].name);
-               data->memory.free(data->memory.user_data, extensions[i].data);
-       }
-       data->memory.free(data->memory.user_data, extensions);
-}
-
-void cgltf_free(cgltf_data* data)
-{
-       if (!data)
-       {
-               return;
-       }
-
-       void (*file_release)(const struct cgltf_memory_options*, const struct cgltf_file_options*, void* data) = data->file.release ? data->file.release : cgltf_default_file_release;
-
-       data->memory.free(data->memory.user_data, data->asset.copyright);
-       data->memory.free(data->memory.user_data, data->asset.generator);
-       data->memory.free(data->memory.user_data, data->asset.version);
-       data->memory.free(data->memory.user_data, data->asset.min_version);
-
-       cgltf_free_extensions(data, data->asset.extensions, data->asset.extensions_count);
-
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->accessors[i].name);
-
-               if(data->accessors[i].is_sparse)
-               {
-                       cgltf_free_extensions(data, data->accessors[i].sparse.extensions, data->accessors[i].sparse.extensions_count);
-                       cgltf_free_extensions(data, data->accessors[i].sparse.indices_extensions, data->accessors[i].sparse.indices_extensions_count);
-                       cgltf_free_extensions(data, data->accessors[i].sparse.values_extensions, data->accessors[i].sparse.values_extensions_count);
-               }
-               cgltf_free_extensions(data, data->accessors[i].extensions, data->accessors[i].extensions_count);
-       }
-       data->memory.free(data->memory.user_data, data->accessors);
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->buffer_views[i].name);
-               data->memory.free(data->memory.user_data, data->buffer_views[i].data);
-
-               cgltf_free_extensions(data, data->buffer_views[i].extensions, data->buffer_views[i].extensions_count);
-       }
-       data->memory.free(data->memory.user_data, data->buffer_views);
-
-       for (cgltf_size i = 0; i < data->buffers_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->buffers[i].name);
-
-               if (data->buffers[i].data != data->bin)
-               {
-                       file_release(&data->memory, &data->file, data->buffers[i].data);
-               }
-               data->memory.free(data->memory.user_data, data->buffers[i].uri);
-
-               cgltf_free_extensions(data, data->buffers[i].extensions, data->buffers[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->buffers);
-
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->meshes[i].name);
-
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                       {
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes[k].name);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].attributes);
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                       {
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                               {
-                                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes[m].name);
-                               }
-
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets[k].attributes);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].targets);
-
-                       if (data->meshes[i].primitives[j].has_draco_mesh_compression)
-                       {
-                               for (cgltf_size k = 0; k < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++k)
-                               {
-                                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes[k].name);
-                               }
-
-                               data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].draco_mesh_compression.attributes);
-                       }
-
-                       data->memory.free(data->memory.user_data, data->meshes[i].primitives[j].mappings);
-
-                       cgltf_free_extensions(data, data->meshes[i].primitives[j].extensions, data->meshes[i].primitives[j].extensions_count);
-               }
-
-               data->memory.free(data->memory.user_data, data->meshes[i].primitives);
-               data->memory.free(data->memory.user_data, data->meshes[i].weights);
-
-               for (cgltf_size j = 0; j < data->meshes[i].target_names_count; ++j)
-               {
-                       data->memory.free(data->memory.user_data, data->meshes[i].target_names[j]);
-               }
-
-               cgltf_free_extensions(data, data->meshes[i].extensions, data->meshes[i].extensions_count);
-
-               data->memory.free(data->memory.user_data, data->meshes[i].target_names);
-       }
-
-       data->memory.free(data->memory.user_data, data->meshes);
-
-       for (cgltf_size i = 0; i < data->materials_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->materials[i].name);
-
-               if(data->materials[i].has_pbr_metallic_roughness)
-               {
-                       cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions, data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions, data->materials[i].pbr_metallic_roughness.base_color_texture.extensions_count);
-               }
-               if(data->materials[i].has_pbr_specular_glossiness)
-               {
-                       cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions, data->materials[i].pbr_specular_glossiness.diffuse_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions, data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.extensions_count);
-               }
-               if(data->materials[i].has_clearcoat)
-               {
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_texture.extensions, data->materials[i].clearcoat.clearcoat_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions, data->materials[i].clearcoat.clearcoat_roughness_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].clearcoat.clearcoat_normal_texture.extensions, data->materials[i].clearcoat.clearcoat_normal_texture.extensions_count);
-               }
-               if(data->materials[i].has_specular)
-               {
-                       cgltf_free_extensions(data, data->materials[i].specular.specular_texture.extensions, data->materials[i].specular.specular_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].specular.specular_color_texture.extensions, data->materials[i].specular.specular_color_texture.extensions_count);
-               }
-               if(data->materials[i].has_transmission)
-               {
-                       cgltf_free_extensions(data, data->materials[i].transmission.transmission_texture.extensions, data->materials[i].transmission.transmission_texture.extensions_count);
-               }
-               if (data->materials[i].has_volume)
-               {
-                       cgltf_free_extensions(data, data->materials[i].volume.thickness_texture.extensions, data->materials[i].volume.thickness_texture.extensions_count);
-               }
-               if(data->materials[i].has_sheen)
-               {
-                       cgltf_free_extensions(data, data->materials[i].sheen.sheen_color_texture.extensions, data->materials[i].sheen.sheen_color_texture.extensions_count);
-                       cgltf_free_extensions(data, data->materials[i].sheen.sheen_roughness_texture.extensions, data->materials[i].sheen.sheen_roughness_texture.extensions_count);
-               }
-
-               cgltf_free_extensions(data, data->materials[i].normal_texture.extensions, data->materials[i].normal_texture.extensions_count);
-               cgltf_free_extensions(data, data->materials[i].occlusion_texture.extensions, data->materials[i].occlusion_texture.extensions_count);
-               cgltf_free_extensions(data, data->materials[i].emissive_texture.extensions, data->materials[i].emissive_texture.extensions_count);
-
-               cgltf_free_extensions(data, data->materials[i].extensions, data->materials[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->materials);
-
-       for (cgltf_size i = 0; i < data->images_count; ++i) 
-       {
-               data->memory.free(data->memory.user_data, data->images[i].name);
-               data->memory.free(data->memory.user_data, data->images[i].uri);
-               data->memory.free(data->memory.user_data, data->images[i].mime_type);
-
-               cgltf_free_extensions(data, data->images[i].extensions, data->images[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->images);
-
-       for (cgltf_size i = 0; i < data->textures_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->textures[i].name);
-               cgltf_free_extensions(data, data->textures[i].extensions, data->textures[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->textures);
-
-       for (cgltf_size i = 0; i < data->samplers_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->samplers[i].name);
-               cgltf_free_extensions(data, data->samplers[i].extensions, data->samplers[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->samplers);
-
-       for (cgltf_size i = 0; i < data->skins_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->skins[i].name);
-               data->memory.free(data->memory.user_data, data->skins[i].joints);
-
-               cgltf_free_extensions(data, data->skins[i].extensions, data->skins[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->skins);
-
-       for (cgltf_size i = 0; i < data->cameras_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->cameras[i].name);
-               cgltf_free_extensions(data, data->cameras[i].extensions, data->cameras[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->cameras);
-
-       for (cgltf_size i = 0; i < data->lights_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->lights[i].name);
-       }
-
-       data->memory.free(data->memory.user_data, data->lights);
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->nodes[i].name);
-               data->memory.free(data->memory.user_data, data->nodes[i].children);
-               data->memory.free(data->memory.user_data, data->nodes[i].weights);
-               cgltf_free_extensions(data, data->nodes[i].extensions, data->nodes[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->nodes);
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->scenes[i].name);
-               data->memory.free(data->memory.user_data, data->scenes[i].nodes);
-
-               cgltf_free_extensions(data, data->scenes[i].extensions, data->scenes[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->scenes);
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->animations[i].name);
-               for (cgltf_size j = 0; j <  data->animations[i].samplers_count; ++j)
-               {
-                       cgltf_free_extensions(data, data->animations[i].samplers[j].extensions, data->animations[i].samplers[j].extensions_count);
-               }
-               data->memory.free(data->memory.user_data, data->animations[i].samplers);
-
-               for (cgltf_size j = 0; j <  data->animations[i].channels_count; ++j)
-               {
-                       cgltf_free_extensions(data, data->animations[i].channels[j].extensions, data->animations[i].channels[j].extensions_count);
-               }
-               data->memory.free(data->memory.user_data, data->animations[i].channels);
-
-               cgltf_free_extensions(data, data->animations[i].extensions, data->animations[i].extensions_count);
-       }
-
-       data->memory.free(data->memory.user_data, data->animations);
-
-       for (cgltf_size i = 0; i < data->variants_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->variants[i].name);
-       }
-
-       data->memory.free(data->memory.user_data, data->variants);
-
-       cgltf_free_extensions(data, data->data_extensions, data->data_extensions_count);
-
-       for (cgltf_size i = 0; i < data->extensions_used_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->extensions_used[i]);
-       }
-
-       data->memory.free(data->memory.user_data, data->extensions_used);
-
-       for (cgltf_size i = 0; i < data->extensions_required_count; ++i)
-       {
-               data->memory.free(data->memory.user_data, data->extensions_required[i]);
-       }
-
-       data->memory.free(data->memory.user_data, data->extensions_required);
-
-       file_release(&data->memory, &data->file, data->file_data);
-
-       data->memory.free(data->memory.user_data, data);
-}
-
-void cgltf_node_transform_local(const cgltf_node* node, cgltf_float* out_matrix)
-{
-       cgltf_float* lm = out_matrix;
-
-       if (node->has_matrix)
-       {
-               memcpy(lm, node->matrix, sizeof(float) * 16);
-       }
-       else
-       {
-               float tx = node->translation[0];
-               float ty = node->translation[1];
-               float tz = node->translation[2];
-
-               float qx = node->rotation[0];
-               float qy = node->rotation[1];
-               float qz = node->rotation[2];
-               float qw = node->rotation[3];
-
-               float sx = node->scale[0];
-               float sy = node->scale[1];
-               float sz = node->scale[2];
-
-               lm[0] = (1 - 2 * qy*qy - 2 * qz*qz) * sx;
-               lm[1] = (2 * qx*qy + 2 * qz*qw) * sx;
-               lm[2] = (2 * qx*qz - 2 * qy*qw) * sx;
-               lm[3] = 0.f;
-
-               lm[4] = (2 * qx*qy - 2 * qz*qw) * sy;
-               lm[5] = (1 - 2 * qx*qx - 2 * qz*qz) * sy;
-               lm[6] = (2 * qy*qz + 2 * qx*qw) * sy;
-               lm[7] = 0.f;
-
-               lm[8] = (2 * qx*qz + 2 * qy*qw) * sz;
-               lm[9] = (2 * qy*qz - 2 * qx*qw) * sz;
-               lm[10] = (1 - 2 * qx*qx - 2 * qy*qy) * sz;
-               lm[11] = 0.f;
-
-               lm[12] = tx;
-               lm[13] = ty;
-               lm[14] = tz;
-               lm[15] = 1.f;
-       }
-}
-
-void cgltf_node_transform_world(const cgltf_node* node, cgltf_float* out_matrix)
-{
-       cgltf_float* lm = out_matrix;
-       cgltf_node_transform_local(node, lm);
-
-       const cgltf_node* parent = node->parent;
-
-       while (parent)
-       {
-               float pm[16];
-               cgltf_node_transform_local(parent, pm);
-
-               for (int i = 0; i < 4; ++i)
-               {
-                       float l0 = lm[i * 4 + 0];
-                       float l1 = lm[i * 4 + 1];
-                       float l2 = lm[i * 4 + 2];
-
-                       float r0 = l0 * pm[0] + l1 * pm[4] + l2 * pm[8];
-                       float r1 = l0 * pm[1] + l1 * pm[5] + l2 * pm[9];
-                       float r2 = l0 * pm[2] + l1 * pm[6] + l2 * pm[10];
-
-                       lm[i * 4 + 0] = r0;
-                       lm[i * 4 + 1] = r1;
-                       lm[i * 4 + 2] = r2;
-               }
-
-               lm[12] += pm[12];
-               lm[13] += pm[13];
-               lm[14] += pm[14];
-
-               parent = parent->parent;
-       }
-}
-
-static cgltf_size cgltf_component_read_index(const void* in, cgltf_component_type component_type)
-{
-       switch (component_type)
-       {
-               case cgltf_component_type_r_16:
-                       return *((const int16_t*) in);
-               case cgltf_component_type_r_16u:
-                       return *((const uint16_t*) in);
-               case cgltf_component_type_r_32u:
-                       return *((const uint32_t*) in);
-               case cgltf_component_type_r_32f:
-                       return (cgltf_size)*((const float*) in);
-               case cgltf_component_type_r_8:
-                       return *((const int8_t*) in);
-               case cgltf_component_type_r_8u:
-                       return *((const uint8_t*) in);
-               default:
-                       return 0;
-       }
-}
-
-static cgltf_float cgltf_component_read_float(const void* in, cgltf_component_type component_type, cgltf_bool normalized)
-{
-       if (component_type == cgltf_component_type_r_32f)
-       {
-               return *((const float*) in);
-       }
-
-       if (normalized)
-       {
-               switch (component_type)
-               {
-                       // note: glTF spec doesn't currently define normalized conversions for 32-bit integers
-                       case cgltf_component_type_r_16:
-                               return *((const int16_t*) in) / (cgltf_float)32767;
-                       case cgltf_component_type_r_16u:
-                               return *((const uint16_t*) in) / (cgltf_float)65535;
-                       case cgltf_component_type_r_8:
-                               return *((const int8_t*) in) / (cgltf_float)127;
-                       case cgltf_component_type_r_8u:
-                               return *((const uint8_t*) in) / (cgltf_float)255;
-                       default:
-                               return 0;
-               }
-       }
-
-       return (cgltf_float)cgltf_component_read_index(in, component_type);
-}
-
-static cgltf_size cgltf_component_size(cgltf_component_type component_type);
-
-static cgltf_bool cgltf_element_read_float(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_bool normalized, cgltf_float* out, cgltf_size element_size)
-{
-       cgltf_size num_components = cgltf_num_components(type);
-
-       if (element_size < num_components) {
-               return 0;
-       }
-
-       // There are three special cases for component extraction, see #data-alignment in the 2.0 spec.
-
-       cgltf_size component_size = cgltf_component_size(component_type);
-
-       if (type == cgltf_type_mat2 && component_size == 1)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 5, component_type, normalized);
-               return 1;
-       }
-
-       if (type == cgltf_type_mat3 && component_size == 1)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 1, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 2, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[4] = cgltf_component_read_float(element + 5, component_type, normalized);
-               out[5] = cgltf_component_read_float(element + 6, component_type, normalized);
-               out[6] = cgltf_component_read_float(element + 8, component_type, normalized);
-               out[7] = cgltf_component_read_float(element + 9, component_type, normalized);
-               out[8] = cgltf_component_read_float(element + 10, component_type, normalized);
-               return 1;
-       }
-
-       if (type == cgltf_type_mat3 && component_size == 2)
-       {
-               out[0] = cgltf_component_read_float(element, component_type, normalized);
-               out[1] = cgltf_component_read_float(element + 2, component_type, normalized);
-               out[2] = cgltf_component_read_float(element + 4, component_type, normalized);
-               out[3] = cgltf_component_read_float(element + 8, component_type, normalized);
-               out[4] = cgltf_component_read_float(element + 10, component_type, normalized);
-               out[5] = cgltf_component_read_float(element + 12, component_type, normalized);
-               out[6] = cgltf_component_read_float(element + 16, component_type, normalized);
-               out[7] = cgltf_component_read_float(element + 18, component_type, normalized);
-               out[8] = cgltf_component_read_float(element + 20, component_type, normalized);
-               return 1;
-       }
-
-       for (cgltf_size i = 0; i < num_components; ++i)
-       {
-               out[i] = cgltf_component_read_float(element + component_size * i, component_type, normalized);
-       }
-       return 1;
-}
-
-const uint8_t* cgltf_buffer_view_data(const cgltf_buffer_view* view)
-{
-       if (view->data)
-               return (const uint8_t*)view->data;
-
-       if (!view->buffer->data)
-               return NULL;
-
-       const uint8_t* result = (const uint8_t*)view->buffer->data;
-       result += view->offset;
-       return result;
-}
-
-cgltf_bool cgltf_accessor_read_float(const cgltf_accessor* accessor, cgltf_size index, cgltf_float* out, cgltf_size element_size)
-{
-       if (accessor->is_sparse)
-       {
-               return 0;
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               memset(out, 0, element_size * sizeof(cgltf_float));
-               return 1;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0;
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_element_read_float(element, accessor->type, accessor->component_type, accessor->normalized, out, element_size);
-}
-
-cgltf_size cgltf_accessor_unpack_floats(const cgltf_accessor* accessor, cgltf_float* out, cgltf_size float_count)
-{
-       cgltf_size floats_per_element = cgltf_num_components(accessor->type);
-       cgltf_size available_floats = accessor->count * floats_per_element;
-       if (out == NULL)
-       {
-               return available_floats;
-       }
-
-       float_count = available_floats < float_count ? available_floats : float_count;
-       cgltf_size element_count = float_count / floats_per_element;
-
-       // First pass: convert each element in the base accessor.
-       cgltf_float* dest = out;
-       cgltf_accessor dense = *accessor;
-       dense.is_sparse = 0;
-       for (cgltf_size index = 0; index < element_count; index++, dest += floats_per_element)
-       {
-               if (!cgltf_accessor_read_float(&dense, index, dest, floats_per_element))
-               {
-                       return 0;
-               }
-       }
-
-       // Second pass: write out each element in the sparse accessor.
-       if (accessor->is_sparse)
-       {
-               const cgltf_accessor_sparse* sparse = &dense.sparse;
-
-               const uint8_t* index_data = cgltf_buffer_view_data(sparse->indices_buffer_view);
-               const uint8_t* reader_head = cgltf_buffer_view_data(sparse->values_buffer_view);
-
-               if (index_data == NULL || reader_head == NULL)
-               {
-                       return 0;
-               }
-
-               index_data += sparse->indices_byte_offset;
-               reader_head += sparse->values_byte_offset;
-
-               cgltf_size index_stride = cgltf_component_size(sparse->indices_component_type);
-               for (cgltf_size reader_index = 0; reader_index < sparse->count; reader_index++, index_data += index_stride)
-               {
-                       size_t writer_index = cgltf_component_read_index(index_data, sparse->indices_component_type);
-                       float* writer_head = out + writer_index * floats_per_element;
-
-                       if (!cgltf_element_read_float(reader_head, dense.type, dense.component_type, dense.normalized, writer_head, floats_per_element))
-                       {
-                               return 0;
-                       }
-
-                       reader_head += dense.stride;
-               }
-       }
-
-       return element_count * floats_per_element;
-}
-
-static cgltf_uint cgltf_component_read_uint(const void* in, cgltf_component_type component_type)
-{
-       switch (component_type)
-       {
-               case cgltf_component_type_r_8:
-                       return *((const int8_t*) in);
-
-               case cgltf_component_type_r_8u:
-                       return *((const uint8_t*) in);
-
-               case cgltf_component_type_r_16:
-                       return *((const int16_t*) in);
-
-               case cgltf_component_type_r_16u:
-                       return *((const uint16_t*) in);
-
-               case cgltf_component_type_r_32u:
-                       return *((const uint32_t*) in);
-
-               default:
-                       return 0;
-       }
-}
-
-static cgltf_bool cgltf_element_read_uint(const uint8_t* element, cgltf_type type, cgltf_component_type component_type, cgltf_uint* out, cgltf_size element_size)
-{
-       cgltf_size num_components = cgltf_num_components(type);
-
-       if (element_size < num_components)
-       {
-               return 0;
-       }
-
-       // Reading integer matrices is not a valid use case
-       if (type == cgltf_type_mat2 || type == cgltf_type_mat3 || type == cgltf_type_mat4)
-       {
-               return 0;
-       }
-
-       cgltf_size component_size = cgltf_component_size(component_type);
-
-       for (cgltf_size i = 0; i < num_components; ++i)
-       {
-               out[i] = cgltf_component_read_uint(element + component_size * i, component_type);
-       }
-       return 1;
-}
-
-cgltf_bool cgltf_accessor_read_uint(const cgltf_accessor* accessor, cgltf_size index, cgltf_uint* out, cgltf_size element_size)
-{
-       if (accessor->is_sparse)
-       {
-               return 0;
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               memset(out, 0, element_size * sizeof( cgltf_uint ));
-               return 1;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0;
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_element_read_uint(element, accessor->type, accessor->component_type, out, element_size);
-}
-
-cgltf_size cgltf_accessor_read_index(const cgltf_accessor* accessor, cgltf_size index)
-{
-       if (accessor->is_sparse)
-       {
-               return 0; // This is an error case, but we can't communicate the error with existing interface.
-       }
-       if (accessor->buffer_view == NULL)
-       {
-               return 0;
-       }
-       const uint8_t* element = cgltf_buffer_view_data(accessor->buffer_view);
-       if (element == NULL)
-       {
-               return 0; // This is an error case, but we can't communicate the error with existing interface.
-       }
-       element += accessor->offset + accessor->stride * index;
-       return cgltf_component_read_index(element, accessor->component_type);
-}
-
-#define CGLTF_ERROR_JSON -1
-#define CGLTF_ERROR_NOMEM -2
-#define CGLTF_ERROR_LEGACY -3
-
-#define CGLTF_CHECK_TOKTYPE(tok_, type_) if ((tok_).type != (type_)) { return CGLTF_ERROR_JSON; }
-#define CGLTF_CHECK_KEY(tok_) if ((tok_).type != JSMN_STRING || (tok_).size == 0) { return CGLTF_ERROR_JSON; } /* checking size for 0 verifies that a value follows the key */
-
-#define CGLTF_PTRINDEX(type, idx) (type*)((cgltf_size)idx + 1)
-#define CGLTF_PTRFIXUP(var, data, size) if (var) { if ((cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1]; }
-#define CGLTF_PTRFIXUP_REQ(var, data, size) if (!var || (cgltf_size)var > size) { return CGLTF_ERROR_JSON; } var = &data[(cgltf_size)var-1];
-
-static int cgltf_json_strcmp(jsmntok_t const* tok, const uint8_t* json_chunk, const char* str)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_STRING);
-       size_t const str_len = strlen(str);
-       size_t const name_length = tok->end - tok->start;
-       return (str_len == name_length) ? strncmp((const char*)json_chunk + tok->start, str, str_len) : 128;
-}
-
-static int cgltf_json_to_int(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
-       char tmp[128];
-       int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
-       strncpy(tmp, (const char*)json_chunk + tok->start, size);
-       tmp[size] = 0;
-       return CGLTF_ATOI(tmp);
-}
-
-static cgltf_float cgltf_json_to_float(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       CGLTF_CHECK_TOKTYPE(*tok, JSMN_PRIMITIVE);
-       char tmp[128];
-       int size = (cgltf_size)(tok->end - tok->start) < sizeof(tmp) ? tok->end - tok->start : (int)(sizeof(tmp) - 1);
-       strncpy(tmp, (const char*)json_chunk + tok->start, size);
-       tmp[size] = 0;
-       return (cgltf_float)CGLTF_ATOF(tmp);
-}
-
-static cgltf_bool cgltf_json_to_bool(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       int size = tok->end - tok->start;
-       return size == 4 && memcmp(json_chunk + tok->start, "true", 4) == 0;
-}
-
-static int cgltf_skip_json(jsmntok_t const* tokens, int i)
-{
-       int end = i + 1;
-
-       while (i < end)
-       {
-               switch (tokens[i].type)
-               {
-               case JSMN_OBJECT:
-                       end += tokens[i].size * 2;
-                       break;
-
-               case JSMN_ARRAY:
-                       end += tokens[i].size;
-                       break;
-
-               case JSMN_PRIMITIVE:
-               case JSMN_STRING:
-                       break;
-
-               default:
-                       return -1;
-               }
-
-               i++;
-       }
-
-       return i;
-}
-
-static void cgltf_fill_float_array(float* out_array, int size, float value)
-{
-       for (int j = 0; j < size; ++j)
-       {
-               out_array[j] = value;
-       }
-}
-
-static int cgltf_parse_json_float_array(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, float* out_array, int size)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-       if (tokens[i].size != size)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       ++i;
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-               out_array[j] = cgltf_json_to_float(tokens + i, json_chunk);
-               ++i;
-       }
-       return i;
-}
-
-static int cgltf_parse_json_string(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char** out_string)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
-       if (*out_string)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       int size = tokens[i].end - tokens[i].start;
-       char* result = (char*)options->memory.alloc(options->memory.user_data, size + 1);
-       if (!result)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(result, (const char*)json_chunk + tokens[i].start, size);
-       result[size] = 0;
-       *out_string = result;
-       return i + 1;
-}
-
-static int cgltf_parse_json_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, size_t element_size, void** out_array, cgltf_size* out_size)
-{
-       (void)json_chunk;
-       if (tokens[i].type != JSMN_ARRAY)
-       {
-               return tokens[i].type == JSMN_OBJECT ? CGLTF_ERROR_LEGACY : CGLTF_ERROR_JSON;
-       }
-       if (*out_array)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-       int size = tokens[i].size;
-       void* result = cgltf_calloc(options, element_size, size);
-       if (!result)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       *out_array = result;
-       *out_size = size;
-       return i + 1;
-}
-
-static int cgltf_parse_json_string_array(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, char*** out_array, cgltf_size* out_size)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(char*), (void**)out_array, out_size);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < *out_size; ++j)
-       {
-               i = cgltf_parse_json_string(options, tokens, i, json_chunk, j + (*out_array));
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static void cgltf_parse_attribute_type(const char* name, cgltf_attribute_type* out_type, int* out_index)
-{
-       const char* us = strchr(name, '_');
-       size_t len = us ? (size_t)(us - name) : strlen(name);
-
-       if (len == 8 && strncmp(name, "POSITION", 8) == 0)
-       {
-               *out_type = cgltf_attribute_type_position;
-       }
-       else if (len == 6 && strncmp(name, "NORMAL", 6) == 0)
-       {
-               *out_type = cgltf_attribute_type_normal;
-       }
-       else if (len == 7 && strncmp(name, "TANGENT", 7) == 0)
-       {
-               *out_type = cgltf_attribute_type_tangent;
-       }
-       else if (len == 8 && strncmp(name, "TEXCOORD", 8) == 0)
-       {
-               *out_type = cgltf_attribute_type_texcoord;
-       }
-       else if (len == 5 && strncmp(name, "COLOR", 5) == 0)
-       {
-               *out_type = cgltf_attribute_type_color;
-       }
-       else if (len == 6 && strncmp(name, "JOINTS", 6) == 0)
-       {
-               *out_type = cgltf_attribute_type_joints;
-       }
-       else if (len == 7 && strncmp(name, "WEIGHTS", 7) == 0)
-       {
-               *out_type = cgltf_attribute_type_weights;
-       }
-       else
-       {
-               *out_type = cgltf_attribute_type_invalid;
-       }
-
-       if (us && *out_type != cgltf_attribute_type_invalid)
-       {
-               *out_index = CGLTF_ATOI(us + 1);
-       }
-}
-
-static int cgltf_parse_json_attribute_list(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_attribute** out_attributes, cgltf_size* out_attributes_count)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       if (*out_attributes)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       *out_attributes_count = tokens[i].size;
-       *out_attributes = (cgltf_attribute*)cgltf_calloc(options, sizeof(cgltf_attribute), *out_attributes_count);
-       ++i;
-
-       if (!*out_attributes)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-
-       for (cgltf_size j = 0; j < *out_attributes_count; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               i = cgltf_parse_json_string(options, tokens, i, json_chunk, &(*out_attributes)[j].name);
-               if (i < 0)
-               {
-                       return CGLTF_ERROR_JSON;
-               }
-
-               cgltf_parse_attribute_type((*out_attributes)[j].name, &(*out_attributes)[j].type, &(*out_attributes)[j].index);
-
-               (*out_attributes)[j].data = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-               ++i;
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_extras(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extras* out_extras)
-{
-       (void)json_chunk;
-       out_extras->start_offset = tokens[i].start;
-       out_extras->end_offset = tokens[i].end;
-       i = cgltf_skip_json(tokens, i);
-       return i;
-}
-
-static int cgltf_parse_json_unprocessed_extension(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_extension* out_extension)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_STRING);
-       CGLTF_CHECK_TOKTYPE(tokens[i+1], JSMN_OBJECT);
-       if (out_extension->name)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       cgltf_size name_length = tokens[i].end - tokens[i].start;
-       out_extension->name = (char*)options->memory.alloc(options->memory.user_data, name_length + 1);
-       if (!out_extension->name)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(out_extension->name, (const char*)json_chunk + tokens[i].start, name_length);
-       out_extension->name[name_length] = 0;
-       i++;
-
-       size_t start = tokens[i].start;
-       size_t size = tokens[i].end - start;
-       out_extension->data = (char*)options->memory.alloc(options->memory.user_data, size + 1);
-       if (!out_extension->data)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-       strncpy(out_extension->data, (const char*)json_chunk + start, size);
-       out_extension->data[size] = '\0';
-
-       i = cgltf_skip_json(tokens, i);
-
-       return i;
-}
-
-static int cgltf_parse_json_unprocessed_extensions(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_size* out_extensions_count, cgltf_extension** out_extensions)
-{
-       ++i;
-
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       if(*out_extensions)
-       {
-               return CGLTF_ERROR_JSON;
-       }
-
-       int extensions_size = tokens[i].size;
-       *out_extensions_count = 0;
-       *out_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-       if (!*out_extensions)
-       {
-               return CGLTF_ERROR_NOMEM;
-       }
-
-       ++i;
-
-       for (int j = 0; j < extensions_size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               cgltf_size extension_index = (*out_extensions_count)++;
-               cgltf_extension* extension = &((*out_extensions)[extension_index]);
-               i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, extension);
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_draco_mesh_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_draco_mesh_compression* out_draco_mesh_compression)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "attributes") == 0)
-               {
-                       i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_draco_mesh_compression->attributes, &out_draco_mesh_compression->attributes_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_draco_mesh_compression->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material_mapping_data(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_mapping* out_mappings, cgltf_size* offset)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_ARRAY);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-               int obj_size = tokens[i].size;
-               ++i;
-
-               int material = -1;
-               int variants_tok = -1;
-               cgltf_extras extras = {0, 0};
-
-               for (int k = 0; k < obj_size; ++k)
-               {
-                       CGLTF_CHECK_KEY(tokens[i]);
-
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "material") == 0)
-                       {
-                               ++i;
-                               material = cgltf_json_to_int(tokens + i, json_chunk);
-                               ++i;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
-                       {
-                               variants_tok = i+1;
-                               CGLTF_CHECK_TOKTYPE(tokens[variants_tok], JSMN_ARRAY);
-
-                               i = cgltf_skip_json(tokens, i+1);
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                       {
-                               i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &extras);
-                       }
-                       else
-                       {
-                               i = cgltf_skip_json(tokens, i+1);
-                       }
-
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-               }
-
-               if (material < 0 || variants_tok < 0)
-               {
-                       return CGLTF_ERROR_JSON;
-               }
-
-               if (out_mappings)
-               {
-                       for (int k = 0; k < tokens[variants_tok].size; ++k)
-                       {
-                               int variant = cgltf_json_to_int(&tokens[variants_tok + 1 + k], json_chunk);
-                               if (variant < 0)
-                                       return variant;
-
-                               out_mappings[*offset].material = CGLTF_PTRINDEX(cgltf_material, material);
-                               out_mappings[*offset].variant = variant;
-                               out_mappings[*offset].extras = extras;
-
-                               (*offset)++;
-                       }
-               }
-               else
-               {
-                       (*offset) += tokens[variants_tok].size;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material_mappings(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "mappings") == 0)
-               {
-                       if (out_prim->mappings)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       cgltf_size mappings_offset = 0;
-                       int k = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, NULL, &mappings_offset);
-                       if (k < 0)
-                       {
-                               return k;
-                       }
-
-                       out_prim->mappings_count = mappings_offset;
-                       out_prim->mappings = (cgltf_material_mapping*)cgltf_calloc(options, sizeof(cgltf_material_mapping), out_prim->mappings_count);
-
-                       mappings_offset = 0;
-                       i = cgltf_parse_json_material_mapping_data(options, tokens, i + 1, json_chunk, out_prim->mappings, &mappings_offset);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_primitive(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_primitive* out_prim)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_prim->type = cgltf_primitive_type_triangles;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
-               {
-                       ++i;
-                       out_prim->type
-                                       = (cgltf_primitive_type)
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
-               {
-                       ++i;
-                       out_prim->indices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "material") == 0)
-               {
-                       ++i;
-                       out_prim->material = CGLTF_PTRINDEX(cgltf_material, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "attributes") == 0)
-               {
-                       i = cgltf_parse_json_attribute_list(options, tokens, i + 1, json_chunk, &out_prim->attributes, &out_prim->attributes_count);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "targets") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_morph_target), (void**)&out_prim->targets, &out_prim->targets_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_prim->targets_count; ++k)
-                       {
-                               i = cgltf_parse_json_attribute_list(options, tokens, i, json_chunk, &out_prim->targets[k].attributes, &out_prim->targets[k].attributes_count);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_prim->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_prim->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_prim->extensions_count = 0;
-                       out_prim->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_prim->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_draco_mesh_compression") == 0)
-                               {
-                                       out_prim->has_draco_mesh_compression = 1;
-                                       i = cgltf_parse_json_draco_mesh_compression(options, tokens, i + 1, json_chunk, &out_prim->draco_mesh_compression);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
-                               {
-                                       i = cgltf_parse_json_material_mappings(options, tokens, i + 1, json_chunk, out_prim);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_prim->extensions[out_prim->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_mesh(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_mesh* out_mesh)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_mesh->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "primitives") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_primitive), (void**)&out_mesh->primitives, &out_mesh->primitives_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size prim_index = 0; prim_index < out_mesh->primitives_count; ++prim_index)
-                       {
-                               i = cgltf_parse_json_primitive(options, tokens, i, json_chunk, &out_mesh->primitives[prim_index]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_mesh->weights, &out_mesh->weights_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_mesh->weights, (int)out_mesh->weights_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       ++i;
-
-                       out_mesh->extras.start_offset = tokens[i].start;
-                       out_mesh->extras.end_offset = tokens[i].end;
-
-                       if (tokens[i].type == JSMN_OBJECT)
-                       {
-                               int extras_size = tokens[i].size;
-                               ++i;
-
-                               for (int k = 0; k < extras_size; ++k)
-                               {
-                                       CGLTF_CHECK_KEY(tokens[i]);
-
-                                       if (cgltf_json_strcmp(tokens+i, json_chunk, "targetNames") == 0 && tokens[i+1].type == JSMN_ARRAY)
-                                       {
-                                               i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_mesh->target_names, &out_mesh->target_names_count);
-                                       }
-                                       else
-                                       {
-                                               i = cgltf_skip_json(tokens, i+1);
-                                       }
-
-                                       if (i < 0)
-                                       {
-                                               return i;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               i = cgltf_skip_json(tokens, i);
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_mesh->extensions_count, &out_mesh->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_meshes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_mesh), (void**)&out_data->meshes, &out_data->meshes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->meshes_count; ++j)
-       {
-               i = cgltf_parse_json_mesh(options, tokens, i, json_chunk, &out_data->meshes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static cgltf_component_type cgltf_json_to_component_type(jsmntok_t const* tok, const uint8_t* json_chunk)
-{
-       int type = cgltf_json_to_int(tok, json_chunk);
-
-       switch (type)
-       {
-       case 5120:
-               return cgltf_component_type_r_8;
-       case 5121:
-               return cgltf_component_type_r_8u;
-       case 5122:
-               return cgltf_component_type_r_16;
-       case 5123:
-               return cgltf_component_type_r_16u;
-       case 5125:
-               return cgltf_component_type_r_32u;
-       case 5126:
-               return cgltf_component_type_r_32f;
-       default:
-               return cgltf_component_type_invalid;
-       }
-}
-
-static int cgltf_parse_json_accessor_sparse(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor_sparse* out_sparse)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_sparse->count = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "indices") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int indices_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < indices_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_byte_offset = cgltf_json_to_int(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->indices_component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->indices_extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->indices_extensions_count, &out_sparse->indices_extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "values") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int values_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < values_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->values_buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-                               {
-                                       ++i;
-                                       out_sparse->values_byte_offset = cgltf_json_to_int(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->values_extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->values_extensions_count, &out_sparse->values_extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sparse->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sparse->extensions_count, &out_sparse->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_accessor(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_accessor* out_accessor)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_accessor->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_accessor->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_accessor->offset =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "componentType") == 0)
-               {
-                       ++i;
-                       out_accessor->component_type = cgltf_json_to_component_type(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "normalized") == 0)
-               {
-                       ++i;
-                       out_accessor->normalized = cgltf_json_to_bool(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_accessor->count =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "SCALAR") == 0)
-                       {
-                               out_accessor->type = cgltf_type_scalar;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC2") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec2;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC3") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec3;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "VEC4") == 0)
-                       {
-                               out_accessor->type = cgltf_type_vec4;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT2") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat2;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT3") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat3;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "MAT4") == 0)
-                       {
-                               out_accessor->type = cgltf_type_mat4;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "min") == 0)
-               {
-                       ++i;
-                       out_accessor->has_min = 1;
-                       // note: we can't parse the precise number of elements since type may not have been computed yet
-                       int min_size = tokens[i].size > 16 ? 16 : tokens[i].size;
-                       i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->min, min_size);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "max") == 0)
-               {
-                       ++i;
-                       out_accessor->has_max = 1;
-                       // note: we can't parse the precise number of elements since type may not have been computed yet
-                       int max_size = tokens[i].size > 16 ? 16 : tokens[i].size;
-                       i = cgltf_parse_json_float_array(tokens, i, json_chunk, out_accessor->max, max_size);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "sparse") == 0)
-               {
-                       out_accessor->is_sparse = 1;
-                       i = cgltf_parse_json_accessor_sparse(options, tokens, i + 1, json_chunk, &out_accessor->sparse);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_accessor->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_accessor->extensions_count, &out_accessor->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture_transform(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_transform* out_texture_transform)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "offset") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->offset, 2);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "rotation") == 0)
-               {
-                       ++i;
-                       out_texture_transform->rotation = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_texture_transform->scale, 2);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
-               {
-                       ++i;
-                       out_texture_transform->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture_view* out_texture_view)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_texture_view->scale = 1.0f;
-       cgltf_fill_float_array(out_texture_view->transform.scale, 2, 1.0f);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "index") == 0)
-               {
-                       ++i;
-                       out_texture_view->texture = CGLTF_PTRINDEX(cgltf_texture, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "texCoord") == 0)
-               {
-                       ++i;
-                       out_texture_view->texcoord = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scale") == 0) 
-               {
-                       ++i;
-                       out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "strength") == 0)
-               {
-                       ++i;
-                       out_texture_view->scale = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture_view->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_texture_view->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_texture_view->extensions_count = 0;
-                       out_texture_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_texture_view->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_texture_transform") == 0)
-                               {
-                                       out_texture_view->has_transform = 1;
-                                       i = cgltf_parse_json_texture_transform(tokens, i + 1, json_chunk, &out_texture_view->transform);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture_view->extensions[out_texture_view->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_pbr_metallic_roughness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_metallic_roughness* out_pbr)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "metallicFactor") == 0)
-               {
-                       ++i;
-                       out_pbr->metallic_factor = 
-                               cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "roughnessFactor") == 0) 
-               {
-                       ++i;
-                       out_pbr->roughness_factor =
-                               cgltf_json_to_float(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->base_color_factor, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "baseColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_pbr->base_color_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "metallicRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_pbr->metallic_roughness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_pbr->extras);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_pbr_specular_glossiness(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_pbr_specular_glossiness* out_pbr)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->diffuse_factor, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_pbr->specular_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "glossinessFactor") == 0)
-               {
-                       ++i;
-                       out_pbr->glossiness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "diffuseTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->diffuse_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularGlossinessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_pbr->specular_glossiness_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_clearcoat(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_clearcoat* out_clearcoat)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatFactor") == 0)
-               {
-                       ++i;
-                       out_clearcoat->clearcoat_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessFactor") == 0)
-               {
-                       ++i;
-                       out_clearcoat->clearcoat_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_roughness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "clearcoatNormalTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_clearcoat->clearcoat_normal_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_ior(jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_ior* out_ior)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       // Default values
-       out_ior->ior = 1.5f;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "ior") == 0)
-               {
-                       ++i;
-                       out_ior->ior = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_specular(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_specular* out_specular)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       // Default values
-       out_specular->specular_factor = 1.0f;
-       cgltf_fill_float_array(out_specular->specular_color_factor, 3, 1.0f);
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "specularFactor") == 0)
-               {
-                       ++i;
-                       out_specular->specular_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_specular->specular_color_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "specularTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "specularColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_specular->specular_color_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_transmission(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_transmission* out_transmission)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionFactor") == 0)
-               {
-                       ++i;
-                       out_transmission->transmission_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "transmissionTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_transmission->transmission_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_volume(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_volume* out_volume)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessFactor") == 0)
-               {
-                       ++i;
-                       out_volume->thickness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "thicknessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_volume->thickness_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationColor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_volume->attenuation_color, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "attenuationDistance") == 0)
-               {
-                       ++i;
-                       out_volume->attenuation_distance = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_sheen(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sheen* out_sheen)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_sheen->sheen_color_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenColorTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_color_texture);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessFactor") == 0)
-               {
-                       ++i;
-                       out_sheen->sheen_roughness_factor = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "sheenRoughnessTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk, &out_sheen->sheen_roughness_texture);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_image(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_image* out_image)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j) 
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "uri") == 0) 
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->uri);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "bufferView") == 0)
-               {
-                       ++i;
-                       out_image->buffer_view = CGLTF_PTRINDEX(cgltf_buffer_view, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "mimeType") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->mime_type);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_image->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_image->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_image->extensions_count, &out_image->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_sampler* out_sampler)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_sampler->wrap_s = 10497;
-       out_sampler->wrap_t = 10497;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_sampler->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "magFilter") == 0)
-               {
-                       ++i;
-                       out_sampler->mag_filter
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "minFilter") == 0)
-               {
-                       ++i;
-                       out_sampler->min_filter
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapS") == 0)
-               {
-                       ++i;
-                       out_sampler->wrap_s
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "wrapT") == 0) 
-               {
-                       ++i;
-                       out_sampler->wrap_t
-                               = cgltf_json_to_int(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_texture* out_texture)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_texture->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "sampler") == 0)
-               {
-                       ++i;
-                       out_texture->sampler = CGLTF_PTRINDEX(cgltf_sampler, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0) 
-               {
-                       ++i;
-                       out_texture->image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_texture->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_texture->extensions_count, &out_texture->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_material(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material* out_material)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       cgltf_fill_float_array(out_material->pbr_metallic_roughness.base_color_factor, 4, 1.0f);
-       out_material->pbr_metallic_roughness.metallic_factor = 1.0f;
-       out_material->pbr_metallic_roughness.roughness_factor = 1.0f;
-
-       cgltf_fill_float_array(out_material->pbr_specular_glossiness.diffuse_factor, 4, 1.0f);
-       cgltf_fill_float_array(out_material->pbr_specular_glossiness.specular_factor, 3, 1.0f);
-       out_material->pbr_specular_glossiness.glossiness_factor = 1.0f;
-
-       cgltf_fill_float_array(out_material->volume.attenuation_color, 3, 1.0f);
-       out_material->volume.attenuation_distance = FLT_MAX;
-
-       out_material->alpha_cutoff = 0.5f;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_material->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "pbrMetallicRoughness") == 0)
-               {
-                       out_material->has_pbr_metallic_roughness = 1;
-                       i = cgltf_parse_json_pbr_metallic_roughness(options, tokens, i + 1, json_chunk, &out_material->pbr_metallic_roughness);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "emissiveFactor") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_material->emissive_factor, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "normalTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->normal_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "occlusionTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->occlusion_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "emissiveTexture") == 0)
-               {
-                       i = cgltf_parse_json_texture_view(options, tokens, i + 1, json_chunk,
-                               &out_material->emissive_texture);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaMode") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "OPAQUE") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_opaque;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "MASK") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_mask;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "BLEND") == 0)
-                       {
-                               out_material->alpha_mode = cgltf_alpha_mode_blend;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "alphaCutoff") == 0)
-               {
-                       ++i;
-                       out_material->alpha_cutoff = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "doubleSided") == 0)
-               {
-                       ++i;
-                       out_material->double_sided =
-                               cgltf_json_to_bool(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_material->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_material->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       ++i;
-                       out_material->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-                       out_material->extensions_count= 0;
-
-                       if (!out_material->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_pbrSpecularGlossiness") == 0)
-                               {
-                                       out_material->has_pbr_specular_glossiness = 1;
-                                       i = cgltf_parse_json_pbr_specular_glossiness(options, tokens, i + 1, json_chunk, &out_material->pbr_specular_glossiness);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_unlit") == 0)
-                               {
-                                       out_material->unlit = 1;
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_clearcoat") == 0)
-                               {
-                                       out_material->has_clearcoat = 1;
-                                       i = cgltf_parse_json_clearcoat(options, tokens, i + 1, json_chunk, &out_material->clearcoat);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_ior") == 0)
-                               {
-                                       out_material->has_ior = 1;
-                                       i = cgltf_parse_json_ior(tokens, i + 1, json_chunk, &out_material->ior);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_specular") == 0)
-                               {
-                                       out_material->has_specular = 1;
-                                       i = cgltf_parse_json_specular(options, tokens, i + 1, json_chunk, &out_material->specular);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_transmission") == 0)
-                               {
-                                       out_material->has_transmission = 1;
-                                       i = cgltf_parse_json_transmission(options, tokens, i + 1, json_chunk, &out_material->transmission);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "KHR_materials_volume") == 0)
-                               {
-                                       out_material->has_volume = 1;
-                                       i = cgltf_parse_json_volume(options, tokens, i + 1, json_chunk, &out_material->volume);
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_sheen") == 0)
-                               {
-                                       out_material->has_sheen = 1;
-                                       i = cgltf_parse_json_sheen(options, tokens, i + 1, json_chunk, &out_material->sheen);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_material->extensions[out_material->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_accessors(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_accessor), (void**)&out_data->accessors, &out_data->accessors_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->accessors_count; ++j)
-       {
-               i = cgltf_parse_json_accessor(options, tokens, i, json_chunk, &out_data->accessors[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_materials(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material), (void**)&out_data->materials, &out_data->materials_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->materials_count; ++j)
-       {
-               i = cgltf_parse_json_material(options, tokens, i, json_chunk, &out_data->materials[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_images(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_image), (void**)&out_data->images, &out_data->images_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->images_count; ++j)
-       {
-               i = cgltf_parse_json_image(options, tokens, i, json_chunk, &out_data->images[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_textures(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_texture), (void**)&out_data->textures, &out_data->textures_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->textures_count; ++j)
-       {
-               i = cgltf_parse_json_texture(options, tokens, i, json_chunk, &out_data->textures[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_samplers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_sampler), (void**)&out_data->samplers, &out_data->samplers_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->samplers_count; ++j)
-       {
-               i = cgltf_parse_json_sampler(options, tokens, i, json_chunk, &out_data->samplers[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_meshopt_compression(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_meshopt_compression* out_meshopt_compression)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->offset = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->size = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->stride = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "count") == 0)
-               {
-                       ++i;
-                       out_meshopt_compression->count = cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "mode") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "ATTRIBUTES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_attributes;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "TRIANGLES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_triangles;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "INDICES") == 0)
-                       {
-                               out_meshopt_compression->mode = cgltf_meshopt_compression_mode_indices;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "filter") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens+i, json_chunk, "NONE") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_none;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "OCTAHEDRAL") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_octahedral;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "QUATERNION") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_quaternion;
-                       }
-                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "EXPONENTIAL") == 0)
-                       {
-                               out_meshopt_compression->filter = cgltf_meshopt_compression_filter_exponential;
-                       }
-                       ++i;
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffer_view(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer_view* out_buffer_view)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer_view->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "buffer") == 0)
-               {
-                       ++i;
-                       out_buffer_view->buffer = CGLTF_PTRINDEX(cgltf_buffer, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteOffset") == 0)
-               {
-                       ++i;
-                       out_buffer_view->offset =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_buffer_view->size =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteStride") == 0)
-               {
-                       ++i;
-                       out_buffer_view->stride =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
-               {
-                       ++i;
-                       int type = cgltf_json_to_int(tokens+i, json_chunk);
-                       switch (type)
-                       {
-                       case 34962:
-                               type = cgltf_buffer_view_type_vertices;
-                               break;
-                       case 34963:
-                               type = cgltf_buffer_view_type_indices;
-                               break;
-                       default:
-                               type = cgltf_buffer_view_type_invalid;
-                               break;
-                       }
-                       out_buffer_view->type = (cgltf_buffer_view_type)type;
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer_view->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_buffer_view->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_buffer_view->extensions_count = 0;
-                       out_buffer_view->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_buffer_view->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "EXT_meshopt_compression") == 0)
-                               {
-                                       out_buffer_view->has_meshopt_compression = 1;
-                                       i = cgltf_parse_json_meshopt_compression(options, tokens, i + 1, json_chunk, &out_buffer_view->meshopt_compression);
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_buffer_view->extensions[out_buffer_view->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffer_views(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer_view), (void**)&out_data->buffer_views, &out_data->buffer_views_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->buffer_views_count; ++j)
-       {
-               i = cgltf_parse_json_buffer_view(options, tokens, i, json_chunk, &out_data->buffer_views[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_buffer(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_buffer* out_buffer)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "byteLength") == 0)
-               {
-                       ++i;
-                       out_buffer->size =
-                                       cgltf_json_to_int(tokens+i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "uri") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_buffer->uri);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_buffer->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_buffer->extensions_count, &out_buffer->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_buffers(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_buffer), (void**)&out_data->buffers, &out_data->buffers_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->buffers_count; ++j)
-       {
-               i = cgltf_parse_json_buffer(options, tokens, i, json_chunk, &out_data->buffers[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_skin(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_skin* out_skin)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_skin->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "joints") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_skin->joints, &out_skin->joints_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_skin->joints_count; ++k)
-                       {
-                               out_skin->joints[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "skeleton") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_skin->skeleton = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "inverseBindMatrices") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_skin->inverse_bind_matrices = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_skin->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_skin->extensions_count, &out_skin->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_skins(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_skin), (void**)&out_data->skins, &out_data->skins_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->skins_count; ++j)
-       {
-               i = cgltf_parse_json_skin(options, tokens, i, json_chunk, &out_data->skins[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_camera(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_camera* out_camera)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_camera->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "perspective") == 0)
-                       {
-                               out_camera->type = cgltf_camera_type_perspective;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "orthographic") == 0)
-                       {
-                               out_camera->type = cgltf_camera_type_orthographic;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "perspective") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       out_camera->type = cgltf_camera_type_perspective;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "aspectRatio") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.has_aspect_ratio = 1;
-                                       out_camera->data.perspective.aspect_ratio = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "yfov") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.yfov = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.has_zfar = 1;
-                                       out_camera->data.perspective.zfar = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.perspective.znear = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.perspective.extras);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "orthographic") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       out_camera->type = cgltf_camera_type_orthographic;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "xmag") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.xmag = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "ymag") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.ymag = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "zfar") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.zfar = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "znear") == 0)
-                               {
-                                       ++i;
-                                       out_camera->data.orthographic.znear = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->data.orthographic.extras);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_camera->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_camera->extensions_count, &out_camera->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_cameras(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_camera), (void**)&out_data->cameras, &out_data->cameras_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->cameras_count; ++j)
-       {
-               i = cgltf_parse_json_camera(options, tokens, i, json_chunk, &out_data->cameras[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_light(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_light* out_light)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_light->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "color") == 0)
-               {
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_light->color, 3);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "intensity") == 0)
-               {
-                       ++i;
-                       out_light->intensity = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "type") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "directional") == 0)
-                       {
-                               out_light->type = cgltf_light_type_directional;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "point") == 0)
-                       {
-                               out_light->type = cgltf_light_type_point;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "spot") == 0)
-                       {
-                               out_light->type = cgltf_light_type_spot;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "range") == 0)
-               {
-                       ++i;
-                       out_light->range = cgltf_json_to_float(tokens + i, json_chunk);
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "spot") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int data_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < data_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "innerConeAngle") == 0)
-                               {
-                                       ++i;
-                                       out_light->spot_inner_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "outerConeAngle") == 0)
-                               {
-                                       ++i;
-                                       out_light->spot_outer_cone_angle = cgltf_json_to_float(tokens + i, json_chunk);
-                                       ++i;
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_lights(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_light), (void**)&out_data->lights, &out_data->lights_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->lights_count; ++j)
-       {
-               i = cgltf_parse_json_light(options, tokens, i, json_chunk, &out_data->lights[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_node(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_node* out_node)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       out_node->rotation[3] = 1.0f;
-       out_node->scale[0] = 1.0f;
-       out_node->scale[1] = 1.0f;
-       out_node->scale[2] = 1.0f;
-       out_node->matrix[0] = 1.0f;
-       out_node->matrix[5] = 1.0f;
-       out_node->matrix[10] = 1.0f;
-       out_node->matrix[15] = 1.0f;
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_node->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "children") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_node->children, &out_node->children_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_node->children_count; ++k)
-                       {
-                               out_node->children[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "mesh") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->mesh = CGLTF_PTRINDEX(cgltf_mesh, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "skin") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->skin = CGLTF_PTRINDEX(cgltf_skin, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "camera") == 0)
-               {
-                       ++i;
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                       out_node->camera = CGLTF_PTRINDEX(cgltf_camera, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
-               {
-                       out_node->has_translation = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->translation, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
-               {
-                       out_node->has_rotation = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->rotation, 4);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
-               {
-                       out_node->has_scale = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->scale, 3);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "matrix") == 0)
-               {
-                       out_node->has_matrix = 1;
-                       i = cgltf_parse_json_float_array(tokens, i + 1, json_chunk, out_node->matrix, 16);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "weights") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_float), (void**)&out_node->weights, &out_node->weights_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       i = cgltf_parse_json_float_array(tokens, i - 1, json_chunk, out_node->weights, (int)out_node->weights_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_node->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_node->extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_node->extensions_count= 0;
-                       out_node->extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_node->extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "light") == 0)
-                                               {
-                                                       ++i;
-                                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_PRIMITIVE);
-                                                       out_node->light = CGLTF_PTRINDEX(cgltf_light, cgltf_json_to_int(tokens + i, json_chunk));
-                                                       ++i;
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_node->extensions[out_node->extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_nodes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_node), (void**)&out_data->nodes, &out_data->nodes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->nodes_count; ++j)
-       {
-               i = cgltf_parse_json_node(options, tokens, i, json_chunk, &out_data->nodes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_scene(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_scene* out_scene)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_scene->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "nodes") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_node*), (void**)&out_scene->nodes, &out_scene->nodes_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_scene->nodes_count; ++k)
-                       {
-                               out_scene->nodes[k] = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                               ++i;
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_scene->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_scene->extensions_count, &out_scene->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_scenes(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_scene), (void**)&out_data->scenes, &out_data->scenes_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->scenes_count; ++j)
-       {
-               i = cgltf_parse_json_scene(options, tokens, i, json_chunk, &out_data->scenes[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_animation_sampler(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_sampler* out_sampler)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "input") == 0)
-               {
-                       ++i;
-                       out_sampler->input = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "output") == 0)
-               {
-                       ++i;
-                       out_sampler->output = CGLTF_PTRINDEX(cgltf_accessor, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "interpolation") == 0)
-               {
-                       ++i;
-                       if (cgltf_json_strcmp(tokens + i, json_chunk, "LINEAR") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_linear;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "STEP") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_step;
-                       }
-                       else if (cgltf_json_strcmp(tokens + i, json_chunk, "CUBICSPLINE") == 0)
-                       {
-                               out_sampler->interpolation = cgltf_interpolation_type_cubic_spline;
-                       }
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_sampler->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_sampler->extensions_count, &out_sampler->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animation_channel(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation_channel* out_channel)
-{
-       (void)options;
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "sampler") == 0)
-               {
-                       ++i;
-                       out_channel->sampler = CGLTF_PTRINDEX(cgltf_animation_sampler, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "target") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                       int target_size = tokens[i].size;
-                       ++i;
-
-                       for (int k = 0; k < target_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "node") == 0)
-                               {
-                                       ++i;
-                                       out_channel->target_node = CGLTF_PTRINDEX(cgltf_node, cgltf_json_to_int(tokens + i, json_chunk));
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "path") == 0)
-                               {
-                                       ++i;
-                                       if (cgltf_json_strcmp(tokens+i, json_chunk, "translation") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_translation;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "rotation") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_rotation;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "scale") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_scale;
-                                       }
-                                       else if (cgltf_json_strcmp(tokens+i, json_chunk, "weights") == 0)
-                                       {
-                                               out_channel->target_path = cgltf_animation_path_type_weights;
-                                       }
-                                       ++i;
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-                               {
-                                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_channel->extras);
-                               }
-                               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-                               {
-                                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_channel->extensions_count, &out_channel->extensions);
-                               }
-                               else
-                               {
-                                       i = cgltf_skip_json(tokens, i+1);
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animation(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_animation* out_animation)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_animation->name);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "samplers") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_sampler), (void**)&out_animation->samplers, &out_animation->samplers_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_animation->samplers_count; ++k)
-                       {
-                               i = cgltf_parse_json_animation_sampler(options, tokens, i, json_chunk, &out_animation->samplers[k]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "channels") == 0)
-               {
-                       i = cgltf_parse_json_array(options, tokens, i + 1, json_chunk, sizeof(cgltf_animation_channel), (void**)&out_animation->channels, &out_animation->channels_count);
-                       if (i < 0)
-                       {
-                               return i;
-                       }
-
-                       for (cgltf_size k = 0; k < out_animation->channels_count; ++k)
-                       {
-                               i = cgltf_parse_json_animation_channel(options, tokens, i, json_chunk, &out_animation->channels[k]);
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_animation->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_animation->extensions_count, &out_animation->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_animations(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_animation), (void**)&out_data->animations, &out_data->animations_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->animations_count; ++j)
-       {
-               i = cgltf_parse_json_animation(options, tokens, i, json_chunk, &out_data->animations[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_variant(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_material_variant* out_variant)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "name") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_variant->name);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_variant->extras);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-static int cgltf_parse_json_variants(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       i = cgltf_parse_json_array(options, tokens, i, json_chunk, sizeof(cgltf_material_variant), (void**)&out_data->variants, &out_data->variants_count);
-       if (i < 0)
-       {
-               return i;
-       }
-
-       for (cgltf_size j = 0; j < out_data->variants_count; ++j)
-       {
-               i = cgltf_parse_json_variant(options, tokens, i, json_chunk, &out_data->variants[j]);
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-       return i;
-}
-
-static int cgltf_parse_json_asset(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_asset* out_asset)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens+i, json_chunk, "copyright") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->copyright);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "generator") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->generator);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "version") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->version);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "minVersion") == 0)
-               {
-                       i = cgltf_parse_json_string(options, tokens, i + 1, json_chunk, &out_asset->min_version);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_asset->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       i = cgltf_parse_json_unprocessed_extensions(options, tokens, i, json_chunk, &out_asset->extensions_count, &out_asset->extensions);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i+1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       if (out_asset->version && CGLTF_ATOF(out_asset->version) < 2)
-       {
-               return CGLTF_ERROR_LEGACY;
-       }
-
-       return i;
-}
-
-cgltf_size cgltf_num_components(cgltf_type type) {
-       switch (type)
-       {
-       case cgltf_type_vec2:
-               return 2;
-       case cgltf_type_vec3:
-               return 3;
-       case cgltf_type_vec4:
-               return 4;
-       case cgltf_type_mat2:
-               return 4;
-       case cgltf_type_mat3:
-               return 9;
-       case cgltf_type_mat4:
-               return 16;
-       case cgltf_type_invalid:
-       case cgltf_type_scalar:
-       default:
-               return 1;
-       }
-}
-
-static cgltf_size cgltf_component_size(cgltf_component_type component_type) {
-       switch (component_type)
-       {
-       case cgltf_component_type_r_8:
-       case cgltf_component_type_r_8u:
-               return 1;
-       case cgltf_component_type_r_16:
-       case cgltf_component_type_r_16u:
-               return 2;
-       case cgltf_component_type_r_32u:
-       case cgltf_component_type_r_32f:
-               return 4;
-       case cgltf_component_type_invalid:
-       default:
-               return 0;
-       }
-}
-
-static cgltf_size cgltf_calc_size(cgltf_type type, cgltf_component_type component_type)
-{
-       cgltf_size component_size = cgltf_component_size(component_type);
-       if (type == cgltf_type_mat2 && component_size == 1)
-       {
-               return 8 * component_size;
-       }
-       else if (type == cgltf_type_mat3 && (component_size == 1 || component_size == 2))
-       {
-               return 12 * component_size;
-       }
-       return component_size * cgltf_num_components(type);
-}
-
-static int cgltf_fixup_pointers(cgltf_data* out_data);
-
-static int cgltf_parse_json_root(cgltf_options* options, jsmntok_t const* tokens, int i, const uint8_t* json_chunk, cgltf_data* out_data)
-{
-       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-       int size = tokens[i].size;
-       ++i;
-
-       for (int j = 0; j < size; ++j)
-       {
-               CGLTF_CHECK_KEY(tokens[i]);
-
-               if (cgltf_json_strcmp(tokens + i, json_chunk, "asset") == 0)
-               {
-                       i = cgltf_parse_json_asset(options, tokens, i + 1, json_chunk, &out_data->asset);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "meshes") == 0)
-               {
-                       i = cgltf_parse_json_meshes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "accessors") == 0)
-               {
-                       i = cgltf_parse_json_accessors(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "bufferViews") == 0)
-               {
-                       i = cgltf_parse_json_buffer_views(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "buffers") == 0)
-               {
-                       i = cgltf_parse_json_buffers(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "materials") == 0)
-               {
-                       i = cgltf_parse_json_materials(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "images") == 0)
-               {
-                       i = cgltf_parse_json_images(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "textures") == 0)
-               {
-                       i = cgltf_parse_json_textures(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "samplers") == 0)
-               {
-                       i = cgltf_parse_json_samplers(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "skins") == 0)
-               {
-                       i = cgltf_parse_json_skins(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "cameras") == 0)
-               {
-                       i = cgltf_parse_json_cameras(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "nodes") == 0)
-               {
-                       i = cgltf_parse_json_nodes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scenes") == 0)
-               {
-                       i = cgltf_parse_json_scenes(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "scene") == 0)
-               {
-                       ++i;
-                       out_data->scene = CGLTF_PTRINDEX(cgltf_scene, cgltf_json_to_int(tokens + i, json_chunk));
-                       ++i;
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "animations") == 0)
-               {
-                       i = cgltf_parse_json_animations(options, tokens, i + 1, json_chunk, out_data);
-               }
-               else if (cgltf_json_strcmp(tokens+i, json_chunk, "extras") == 0)
-               {
-                       i = cgltf_parse_json_extras(tokens, i + 1, json_chunk, &out_data->extras);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensions") == 0)
-               {
-                       ++i;
-
-                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-                       if(out_data->data_extensions)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       int extensions_size = tokens[i].size;
-                       out_data->data_extensions_count = 0;
-                       out_data->data_extensions = (cgltf_extension*)cgltf_calloc(options, sizeof(cgltf_extension), extensions_size);
-
-                       if (!out_data->data_extensions)
-                       {
-                               return CGLTF_ERROR_NOMEM;
-                       }
-
-                       ++i;
-
-                       for (int k = 0; k < extensions_size; ++k)
-                       {
-                               CGLTF_CHECK_KEY(tokens[i]);
-
-                               if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_lights_punctual") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "lights") == 0)
-                                               {
-                                                       i = cgltf_parse_json_lights(options, tokens, i + 1, json_chunk, out_data);
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else if (cgltf_json_strcmp(tokens+i, json_chunk, "KHR_materials_variants") == 0)
-                               {
-                                       ++i;
-
-                                       CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
-
-                                       int data_size = tokens[i].size;
-                                       ++i;
-
-                                       for (int m = 0; m < data_size; ++m)
-                                       {
-                                               CGLTF_CHECK_KEY(tokens[i]);
-
-                                               if (cgltf_json_strcmp(tokens + i, json_chunk, "variants") == 0)
-                                               {
-                                                       i = cgltf_parse_json_variants(options, tokens, i + 1, json_chunk, out_data);
-                                               }
-                                               else
-                                               {
-                                                       i = cgltf_skip_json(tokens, i + 1);
-                                               }
-
-                                               if (i < 0)
-                                               {
-                                                       return i;
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_data->data_extensions[out_data->data_extensions_count++]));
-                               }
-
-                               if (i < 0)
-                               {
-                                       return i;
-                               }
-                       }
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsUsed") == 0)
-               {
-                       i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_used, &out_data->extensions_used_count);
-               }
-               else if (cgltf_json_strcmp(tokens + i, json_chunk, "extensionsRequired") == 0)
-               {
-                       i = cgltf_parse_json_string_array(options, tokens, i + 1, json_chunk, &out_data->extensions_required, &out_data->extensions_required_count);
-               }
-               else
-               {
-                       i = cgltf_skip_json(tokens, i + 1);
-               }
-
-               if (i < 0)
-               {
-                       return i;
-               }
-       }
-
-       return i;
-}
-
-cgltf_result cgltf_parse_json(cgltf_options* options, const uint8_t* json_chunk, cgltf_size size, cgltf_data** out_data)
-{
-       jsmn_parser parser = { 0, 0, 0 };
-
-       if (options->json_token_count == 0)
-       {
-               int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, NULL, 0);
-
-               if (token_count <= 0)
-               {
-                       return cgltf_result_invalid_json;
-               }
-
-               options->json_token_count = token_count;
-       }
-
-       jsmntok_t* tokens = (jsmntok_t*)options->memory.alloc(options->memory.user_data, sizeof(jsmntok_t) * (options->json_token_count + 1));
-
-       if (!tokens)
-       {
-               return cgltf_result_out_of_memory;
-       }
-
-       jsmn_init(&parser);
-
-       int token_count = jsmn_parse(&parser, (const char*)json_chunk, size, tokens, options->json_token_count);
-
-       if (token_count <= 0)
-       {
-               options->memory.free(options->memory.user_data, tokens);
-               return cgltf_result_invalid_json;
-       }
-
-       // this makes sure that we always have an UNDEFINED token at the end of the stream
-       // for invalid JSON inputs this makes sure we don't perform out of bound reads of token data
-       tokens[token_count].type = JSMN_UNDEFINED;
-
-       cgltf_data* data = (cgltf_data*)options->memory.alloc(options->memory.user_data, sizeof(cgltf_data));
-
-       if (!data)
-       {
-               options->memory.free(options->memory.user_data, tokens);
-               return cgltf_result_out_of_memory;
-       }
-
-       memset(data, 0, sizeof(cgltf_data));
-       data->memory = options->memory;
-       data->file = options->file;
-
-       int i = cgltf_parse_json_root(options, tokens, 0, json_chunk, data);
-
-       options->memory.free(options->memory.user_data, tokens);
-
-       if (i < 0)
-       {
-               cgltf_free(data);
-
-               switch (i)
-               {
-               case CGLTF_ERROR_NOMEM: return cgltf_result_out_of_memory;
-               case CGLTF_ERROR_LEGACY: return cgltf_result_legacy_gltf;
-               default: return cgltf_result_invalid_gltf;
-               }
-       }
-
-       if (cgltf_fixup_pointers(data) < 0)
-       {
-               cgltf_free(data);
-               return cgltf_result_invalid_gltf;
-       }
-
-       data->json = (const char*)json_chunk;
-       data->json_size = size;
-
-       *out_data = data;
-
-       return cgltf_result_success;
-}
-
-static int cgltf_fixup_pointers(cgltf_data* data)
-{
-       for (cgltf_size i = 0; i < data->meshes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->meshes[i].primitives_count; ++j)
-               {
-                       CGLTF_PTRFIXUP(data->meshes[i].primitives[j].indices, data->accessors, data->accessors_count);
-                       CGLTF_PTRFIXUP(data->meshes[i].primitives[j].material, data->materials, data->materials_count);
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].attributes_count; ++k)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].attributes[k].data, data->accessors, data->accessors_count);
-                       }
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].targets_count; ++k)
-                       {
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].targets[k].attributes_count; ++m)
-                               {
-                                       CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].targets[k].attributes[m].data, data->accessors, data->accessors_count);
-                               }
-                       }
-
-                       if (data->meshes[i].primitives[j].has_draco_mesh_compression)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.buffer_view, data->buffer_views, data->buffer_views_count);
-                               for (cgltf_size m = 0; m < data->meshes[i].primitives[j].draco_mesh_compression.attributes_count; ++m)
-                               {
-                                       CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].draco_mesh_compression.attributes[m].data, data->accessors, data->accessors_count);
-                               }
-                       }
-
-                       for (cgltf_size k = 0; k < data->meshes[i].primitives[j].mappings_count; ++k)
-                       {
-                               CGLTF_PTRFIXUP_REQ(data->meshes[i].primitives[j].mappings[k].material, data->materials, data->materials_count);
-                       }
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->accessors_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->accessors[i].buffer_view, data->buffer_views, data->buffer_views_count);
-
-               if (data->accessors[i].is_sparse)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.indices_buffer_view, data->buffer_views, data->buffer_views_count);
-                       CGLTF_PTRFIXUP_REQ(data->accessors[i].sparse.values_buffer_view, data->buffer_views, data->buffer_views_count);
-               }
-
-               if (data->accessors[i].buffer_view)
-               {
-                       data->accessors[i].stride = data->accessors[i].buffer_view->stride;
-               }
-
-               if (data->accessors[i].stride == 0)
-               {
-                       data->accessors[i].stride = cgltf_calc_size(data->accessors[i].type, data->accessors[i].component_type);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->textures_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count);
-               CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count);
-       }
-
-       for (cgltf_size i = 0; i < data->images_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->images[i].buffer_view, data->buffer_views, data->buffer_views_count);
-       }
-
-       for (cgltf_size i = 0; i < data->materials_count; ++i)
-       {
-               CGLTF_PTRFIXUP(data->materials[i].normal_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].emissive_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].occlusion_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.base_color_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.diffuse_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].pbr_specular_glossiness.specular_glossiness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_roughness_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].clearcoat.clearcoat_normal_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].specular.specular_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].specular.specular_color_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].transmission.transmission_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].volume.thickness_texture.texture, data->textures, data->textures_count);
-
-               CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_color_texture.texture, data->textures, data->textures_count);
-               CGLTF_PTRFIXUP(data->materials[i].sheen.sheen_roughness_texture.texture, data->textures, data->textures_count);
-       }
-
-       for (cgltf_size i = 0; i < data->buffer_views_count; ++i)
-       {
-               CGLTF_PTRFIXUP_REQ(data->buffer_views[i].buffer, data->buffers, data->buffers_count);
-
-               if (data->buffer_views[i].has_meshopt_compression)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->buffer_views[i].meshopt_compression.buffer, data->buffers, data->buffers_count);
-               }
-       }
-
-       for (cgltf_size i = 0; i < data->skins_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->skins[i].joints_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->skins[i].joints[j], data->nodes, data->nodes_count);
-               }
-
-               CGLTF_PTRFIXUP(data->skins[i].skeleton, data->nodes, data->nodes_count);
-               CGLTF_PTRFIXUP(data->skins[i].inverse_bind_matrices, data->accessors, data->accessors_count);
-       }
-
-       for (cgltf_size i = 0; i < data->nodes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->nodes[i].children_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->nodes[i].children[j], data->nodes, data->nodes_count);
-
-                       if (data->nodes[i].children[j]->parent)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-
-                       data->nodes[i].children[j]->parent = &data->nodes[i];
-               }
-
-               CGLTF_PTRFIXUP(data->nodes[i].mesh, data->meshes, data->meshes_count);
-               CGLTF_PTRFIXUP(data->nodes[i].skin, data->skins, data->skins_count);
-               CGLTF_PTRFIXUP(data->nodes[i].camera, data->cameras, data->cameras_count);
-               CGLTF_PTRFIXUP(data->nodes[i].light, data->lights, data->lights_count);
-       }
-
-       for (cgltf_size i = 0; i < data->scenes_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->scenes[i].nodes_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->scenes[i].nodes[j], data->nodes, data->nodes_count);
-
-                       if (data->scenes[i].nodes[j]->parent)
-                       {
-                               return CGLTF_ERROR_JSON;
-                       }
-               }
-       }
-
-       CGLTF_PTRFIXUP(data->scene, data->scenes, data->scenes_count);
-
-       for (cgltf_size i = 0; i < data->animations_count; ++i)
-       {
-               for (cgltf_size j = 0; j < data->animations[i].samplers_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].input, data->accessors, data->accessors_count);
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].samplers[j].output, data->accessors, data->accessors_count);
-               }
-
-               for (cgltf_size j = 0; j < data->animations[i].channels_count; ++j)
-               {
-                       CGLTF_PTRFIXUP_REQ(data->animations[i].channels[j].sampler, data->animations[i].samplers, data->animations[i].samplers_count);
-                       CGLTF_PTRFIXUP(data->animations[i].channels[j].target_node, data->nodes, data->nodes_count);
-               }
-       }
-
-       return 0;
-}
-
-/*
- * -- jsmn.c start --
- * Source: https://github.com/zserge/jsmn
- * License: MIT
- *
- * Copyright (c) 2010 Serge A. Zaitsev
-
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
-
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
-
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * Allocates a fresh unused token from the token pull.
- */
-static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
-                                  jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *tok;
-       if (parser->toknext >= num_tokens) {
-               return NULL;
-       }
-       tok = &tokens[parser->toknext++];
-       tok->start = tok->end = -1;
-       tok->size = 0;
-#ifdef JSMN_PARENT_LINKS
-       tok->parent = -1;
-#endif
-       return tok;
-}
-
-/**
- * Fills token type and boundaries.
- */
-static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
-                               int start, int end) {
-       token->type = type;
-       token->start = start;
-       token->end = end;
-       token->size = 0;
-}
-
-/**
- * Fills next available token with JSON primitive.
- */
-static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
-                               size_t len, jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *token;
-       int start;
-
-       start = parser->pos;
-
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               switch (js[parser->pos]) {
-#ifndef JSMN_STRICT
-               /* In strict mode primitive must be followed by "," or "}" or "]" */
-               case ':':
-#endif
-               case '\t' : case '\r' : case '\n' : case ' ' :
-               case ','  : case ']'  : case '}' :
-                       goto found;
-               }
-               if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
-                       parser->pos = start;
-                       return JSMN_ERROR_INVAL;
-               }
-       }
-#ifdef JSMN_STRICT
-       /* In strict mode primitive must be followed by a comma/object/array */
-       parser->pos = start;
-       return JSMN_ERROR_PART;
-#endif
-
-found:
-       if (tokens == NULL) {
-               parser->pos--;
-               return 0;
-       }
-       token = jsmn_alloc_token(parser, tokens, num_tokens);
-       if (token == NULL) {
-               parser->pos = start;
-               return JSMN_ERROR_NOMEM;
-       }
-       jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-       token->parent = parser->toksuper;
-#endif
-       parser->pos--;
-       return 0;
-}
-
-/**
- * Fills next token with JSON string.
- */
-static int jsmn_parse_string(jsmn_parser *parser, const char *js,
-                                size_t len, jsmntok_t *tokens, size_t num_tokens) {
-       jsmntok_t *token;
-
-       int start = parser->pos;
-
-       parser->pos++;
-
-       /* Skip starting quote */
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               char c = js[parser->pos];
-
-               /* Quote: end of string */
-               if (c == '\"') {
-                       if (tokens == NULL) {
-                               return 0;
-                       }
-                       token = jsmn_alloc_token(parser, tokens, num_tokens);
-                       if (token == NULL) {
-                               parser->pos = start;
-                               return JSMN_ERROR_NOMEM;
-                       }
-                       jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos);
-#ifdef JSMN_PARENT_LINKS
-                       token->parent = parser->toksuper;
-#endif
-                       return 0;
-               }
-
-               /* Backslash: Quoted symbol expected */
-               if (c == '\\' && parser->pos + 1 < len) {
-                       int i;
-                       parser->pos++;
-                       switch (js[parser->pos]) {
-                       /* Allowed escaped symbols */
-                       case '\"': case '/' : case '\\' : case 'b' :
-                       case 'f' : case 'r' : case 'n'  : case 't' :
-                               break;
-                               /* Allows escaped symbol \uXXXX */
-                       case 'u':
-                               parser->pos++;
-                               for(i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; i++) {
-                                       /* If it isn't a hex character we have an error */
-                                       if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */
-                                                (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */
-                                                (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
-                                               parser->pos = start;
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       parser->pos++;
-                               }
-                               parser->pos--;
-                               break;
-                               /* Unexpected symbol */
-                       default:
-                               parser->pos = start;
-                               return JSMN_ERROR_INVAL;
-                       }
-               }
-       }
-       parser->pos = start;
-       return JSMN_ERROR_PART;
-}
-
-/**
- * Parse JSON string and fill tokens.
- */
-static int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
-                  jsmntok_t *tokens, size_t num_tokens) {
-       int r;
-       int i;
-       jsmntok_t *token;
-       int count = parser->toknext;
-
-       for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
-               char c;
-               jsmntype_t type;
-
-               c = js[parser->pos];
-               switch (c) {
-               case '{': case '[':
-                       count++;
-                       if (tokens == NULL) {
-                               break;
-                       }
-                       token = jsmn_alloc_token(parser, tokens, num_tokens);
-                       if (token == NULL)
-                               return JSMN_ERROR_NOMEM;
-                       if (parser->toksuper != -1) {
-                               tokens[parser->toksuper].size++;
-#ifdef JSMN_PARENT_LINKS
-                               token->parent = parser->toksuper;
-#endif
-                       }
-                       token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
-                       token->start = parser->pos;
-                       parser->toksuper = parser->toknext - 1;
-                       break;
-               case '}': case ']':
-                       if (tokens == NULL)
-                               break;
-                       type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
-#ifdef JSMN_PARENT_LINKS
-                       if (parser->toknext < 1) {
-                               return JSMN_ERROR_INVAL;
-                       }
-                       token = &tokens[parser->toknext - 1];
-                       for (;;) {
-                               if (token->start != -1 && token->end == -1) {
-                                       if (token->type != type) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       token->end = parser->pos + 1;
-                                       parser->toksuper = token->parent;
-                                       break;
-                               }
-                               if (token->parent == -1) {
-                                       if(token->type != type || parser->toksuper == -1) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       break;
-                               }
-                               token = &tokens[token->parent];
-                       }
-#else
-                       for (i = parser->toknext - 1; i >= 0; i--) {
-                               token = &tokens[i];
-                               if (token->start != -1 && token->end == -1) {
-                                       if (token->type != type) {
-                                               return JSMN_ERROR_INVAL;
-                                       }
-                                       parser->toksuper = -1;
-                                       token->end = parser->pos + 1;
-                                       break;
-                               }
-                       }
-                       /* Error if unmatched closing bracket */
-                       if (i == -1) return JSMN_ERROR_INVAL;
-                       for (; i >= 0; i--) {
-                               token = &tokens[i];
-                               if (token->start != -1 && token->end == -1) {
-                                       parser->toksuper = i;
-                                       break;
-                               }
-                       }
-#endif
-                       break;
-               case '\"':
-                       r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
-                       if (r < 0) return r;
-                       count++;
-                       if (parser->toksuper != -1 && tokens != NULL)
-                               tokens[parser->toksuper].size++;
-                       break;
-               case '\t' : case '\r' : case '\n' : case ' ':
-                       break;
-               case ':':
-                       parser->toksuper = parser->toknext - 1;
-                       break;
-               case ',':
-                       if (tokens != NULL && parser->toksuper != -1 &&
-                                       tokens[parser->toksuper].type != JSMN_ARRAY &&
-                                       tokens[parser->toksuper].type != JSMN_OBJECT) {
-#ifdef JSMN_PARENT_LINKS
-                               parser->toksuper = tokens[parser->toksuper].parent;
-#else
-                               for (i = parser->toknext - 1; i >= 0; i--) {
-                                       if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
-                                               if (tokens[i].start != -1 && tokens[i].end == -1) {
-                                                       parser->toksuper = i;
-                                                       break;
-                                               }
-                                       }
-                               }
-#endif
-                       }
-                       break;
-#ifdef JSMN_STRICT
-                       /* In strict mode primitives are: numbers and booleans */
-               case '-': case '0': case '1' : case '2': case '3' : case '4':
-               case '5': case '6': case '7' : case '8': case '9':
-               case 't': case 'f': case 'n' :
-                       /* And they must not be keys of the object */
-                       if (tokens != NULL && parser->toksuper != -1) {
-                               jsmntok_t *t = &tokens[parser->toksuper];
-                               if (t->type == JSMN_OBJECT ||
-                                               (t->type == JSMN_STRING && t->size != 0)) {
-                                       return JSMN_ERROR_INVAL;
-                               }
-                       }
-#else
-                       /* In non-strict mode every unquoted value is a primitive */
-               default:
-#endif
-                       r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
-                       if (r < 0) return r;
-                       count++;
-                       if (parser->toksuper != -1 && tokens != NULL)
-                               tokens[parser->toksuper].size++;
-                       break;
-
-#ifdef JSMN_STRICT
-                       /* Unexpected char in strict mode */
-               default:
-                       return JSMN_ERROR_INVAL;
-#endif
-               }
-       }
-
-       if (tokens != NULL) {
-               for (i = parser->toknext - 1; i >= 0; i--) {
-                       /* Unmatched opened object or array */
-                       if (tokens[i].start != -1 && tokens[i].end == -1) {
-                               return JSMN_ERROR_PART;
-                       }
-               }
-       }
-
-       return count;
-}
-
-/**
- * Creates a new parser based over a given  buffer with an array of tokens
- * available.
- */
-static void jsmn_init(jsmn_parser *parser) {
-       parser->pos = 0;
-       parser->toknext = 0;
-       parser->toksuper = -1;
-}
-/*
- * -- jsmn.c end --
- */
-
-#endif /* #ifdef CGLTF_IMPLEMENTATION */
-
-/* cgltf is distributed under MIT license:
- *
- * Copyright (c) 2018 Johannes Kuhlmann
-
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
-
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
-
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
diff --git a/raylib_pi4_test/external/dirent.h b/raylib_pi4_test/external/dirent.h
deleted file mode 100644 (file)
index c611376..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/****************************************************************************
-
-    Declaration of POSIX directory browsing functions and types for Win32.
-
-    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
-    History: Created March 1997. Updated June 2003.
-             Reviewed by Ramon Santamaria for raylib on January 2020.
-
-    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives.
-    
-    This software is supplied "as is" without express or implied warranty.
-
-    But that said, if there are any problems please get in touch.
-
-****************************************************************************/
-
-#ifndef DIRENT_H
-#define DIRENT_H
-
-// Allow custom memory allocators
-#ifndef DIRENT_MALLOC
-    #define DIRENT_MALLOC(sz)   malloc(sz)
-#endif
-#ifndef DIRENT_FREE
-    #define DIRENT_FREE(p)      free(p)
-#endif
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-
-// Fordward declaration of DIR, implementation below
-typedef struct DIR DIR;
-
-struct dirent {
-    char *d_name;
-};
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//------------------------------------------------------------------------------------
-// Functions Declaration
-//------------------------------------------------------------------------------------
-DIR *opendir(const char *name);
-int closedir(DIR *dir);
-struct dirent *readdir(DIR *dir);
-void rewinddir(DIR *dir);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif      // DIRENT_H
-
-/****************************************************************************
-
-    Implementation of POSIX directory browsing functions and types for Win32.
-
-    Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
-    History: Created March 1997. Updated June 2003.
-             Reviewed by Ramon Santamaria for raylib on January 2020.
-
-    Copyright Kevlin Henney, 1997, 2003. All rights reserved.
-
-    Permission to use, copy, modify, and distribute this software and its
-    documentation for any purpose is hereby granted without fee, provided
-    that this copyright and permissions notice appear in all copies and
-    derivatives.
-    
-    This software is supplied "as is" without express or implied warranty.
-
-    But that said, if there are any problems please get in touch.
-
-****************************************************************************/
-
-#include <io.h>         // _findfirst and _findnext set errno iff they return -1
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-//----------------------------------------------------------------------------------
-// Types and Structures Definition
-//----------------------------------------------------------------------------------
-typedef ptrdiff_t handle_type;  // C99's intptr_t not sufficiently portable
-
-struct DIR {
-    handle_type handle;         // -1 for failed rewind
-    struct _finddata_t info;
-    struct dirent result;       // d_name null iff first time
-    char *name;                 // null-terminated char string
-};
-
-DIR *opendir(const char *name)
-{
-    DIR *dir = 0;
-
-    if (name && name[0])
-    {
-        size_t base_length = strlen(name);
-        
-        // Search pattern must end with suitable wildcard
-        const char *all = strchr("/\\", name[base_length - 1]) ? "*" : "/*";
-
-        if ((dir = (DIR *)DIRENT_MALLOC(sizeof *dir)) != 0 &&
-            (dir->name = (char *)DIRENT_MALLOC(base_length + strlen(all) + 1)) != 0)
-        {
-            strcat(strcpy(dir->name, name), all);
-
-            if ((dir->handle = (handle_type) _findfirst(dir->name, &dir->info)) != -1)
-            {
-                dir->result.d_name = 0;
-            }
-            else  // rollback
-            {
-                DIRENT_FREE(dir->name);
-                DIRENT_FREE(dir);
-                dir = 0;
-            }
-        }
-        else  // rollback
-        {
-            DIRENT_FREE(dir);
-            dir   = 0;
-            errno = ENOMEM;
-        }
-    }
-    else errno = EINVAL;
-
-    return dir;
-}
-
-int closedir(DIR *dir)
-{
-    int result = -1;
-
-    if (dir)
-    {
-        if (dir->handle != -1) result = _findclose(dir->handle);
-
-        DIRENT_FREE(dir->name);
-        DIRENT_FREE(dir);
-    }
-
-    // NOTE: All errors ampped to EBADF
-    if (result == -1) errno = EBADF;
-
-    return result;
-}
-
-struct dirent *readdir(DIR *dir)
-{
-    struct dirent *result = 0;
-
-    if (dir && dir->handle != -1)
-    {
-        if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
-        {
-            result = &dir->result;
-            result->d_name = dir->info.name;
-        }
-    }
-    else errno = EBADF;
-
-    return result;
-}
-
-void rewinddir(DIR *dir)
-{
-    if (dir && dir->handle != -1)
-    {
-        _findclose(dir->handle);
-        dir->handle = (handle_type) _findfirst(dir->name, &dir->info);
-        dir->result.d_name = 0;
-    }
-    else errno = EBADF;
-}
diff --git a/raylib_pi4_test/external/dr_flac.h b/raylib_pi4_test/external/dr_flac.h
deleted file mode 100644 (file)
index a797350..0000000
+++ /dev/null
@@ -1,12263 +0,0 @@
-/*
-FLAC audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_flac - v0.12.29 - 2021-04-02
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-*/
-
-/*
-RELEASE NOTES - v0.12.0
-=======================
-Version 0.12.0 has breaking API changes including changes to the existing API and the removal of deprecated APIs.
-
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drflac_allocation_callbacks object to drflac_open() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drflac_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drflac* pFlac = drflac_open_file("my_file.flac", &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_flac to use defaults which is the same as DRFLAC_MALLOC,
-DRFLAC_REALLOC and DRFLAC_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drflac object now takes this extra parameter. These include the following:
-
-    drflac_open()
-    drflac_open_relaxed()
-    drflac_open_with_metadata()
-    drflac_open_with_metadata_relaxed()
-    drflac_open_file()
-    drflac_open_file_with_metadata()
-    drflac_open_memory()
-    drflac_open_memory_with_metadata()
-    drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_read_pcm_frames_f32()
-    drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_memory_and_read_pcm_frames_f32()
-
-
-
-Optimizations
--------------
-Seeking performance has been greatly improved. A new binary search based seeking algorithm has been introduced which significantly
-improves performance over the brute force method which was used when no seek table was present. Seek table based seeking also takes
-advantage of the new binary search seeking system to further improve performance there as well. Note that this depends on CRC which
-means it will be disabled when DR_FLAC_NO_CRC is used.
-
-The SSE4.1 pipeline has been cleaned up and optimized. You should see some improvements with decoding speed of 24-bit files in
-particular. 16-bit streams should also see some improvement.
-
-drflac_read_pcm_frames_s16() has been optimized. Previously this sat on top of drflac_read_pcm_frames_s32() and performed it's s32
-to s16 conversion in a second pass. This is now all done in a single pass. This includes SSE2 and ARM NEON optimized paths.
-
-A minor optimization has been implemented for drflac_read_pcm_frames_s32(). This will now use an SSE2 optimized pipeline for stereo
-channel reconstruction which is the last part of the decoding process.
-
-The ARM build has seen a few improvements. The CLZ (count leading zeroes) and REV (byte swap) instructions are now used when
-compiling with GCC and Clang which is achieved using inline assembly. The CLZ instruction requires ARM architecture version 5 at
-compile time and the REV instruction requires ARM architecture version 6.
-
-An ARM NEON optimized pipeline has been implemented. To enable this you'll need to add -mfpu=neon to the command line when compiling.
-
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.11.0 and have been completely removed in version 0.12.0:
-
-    drflac_read_s32()                   -> drflac_read_pcm_frames_s32()
-    drflac_read_s16()                   -> drflac_read_pcm_frames_s16()
-    drflac_read_f32()                   -> drflac_read_pcm_frames_f32()
-    drflac_seek_to_sample()             -> drflac_seek_to_pcm_frame()
-    drflac_open_and_decode_s32()        -> drflac_open_and_read_pcm_frames_s32()
-    drflac_open_and_decode_s16()        -> drflac_open_and_read_pcm_frames_s16()
-    drflac_open_and_decode_f32()        -> drflac_open_and_read_pcm_frames_f32()
-    drflac_open_and_decode_file_s32()   -> drflac_open_file_and_read_pcm_frames_s32()
-    drflac_open_and_decode_file_s16()   -> drflac_open_file_and_read_pcm_frames_s16()
-    drflac_open_and_decode_file_f32()   -> drflac_open_file_and_read_pcm_frames_f32()
-    drflac_open_and_decode_memory_s32() -> drflac_open_memory_and_read_pcm_frames_s32()
-    drflac_open_and_decode_memory_s16() -> drflac_open_memory_and_read_pcm_frames_s16()
-    drflac_open_and_decode_memory_f32() -> drflac_open_memroy_and_read_pcm_frames_f32()
-
-Prior versions of dr_flac operated on a per-sample basis whereas now it operates on PCM frames. The removed APIs all relate
-to the old per-sample APIs. You now need to use the "pcm_frame" versions.
-*/
-
-
-/*
-Introduction
-============
-dr_flac is a single file library. To use it, do something like the following in one .c file.
-
-    ```c
-    #define DR_FLAC_IMPLEMENTATION
-    #include "dr_flac.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
-
-    ```c
-    drflac* pFlac = drflac_open_file("MySong.flac", NULL);
-    if (pFlac == NULL) {
-        // Failed to open FLAC file
-    }
-
-    drflac_int32* pSamples = malloc(pFlac->totalPCMFrameCount * pFlac->channels * sizeof(drflac_int32));
-    drflac_uint64 numberOfInterleavedSamplesActuallyRead = drflac_read_pcm_frames_s32(pFlac, pFlac->totalPCMFrameCount, pSamples);
-    ```
-
-The drflac object represents the decoder. It is a transparent type so all the information you need, such as the number of channels and the bits per sample,
-should be directly accessible - just make sure you don't change their values. Samples are always output as interleaved signed 32-bit PCM. In the example above
-a native FLAC stream was opened, however dr_flac has seamless support for Ogg encapsulated FLAC streams as well.
-
-You do not need to decode the entire stream in one go - you just specify how many samples you'd like at any given time and the decoder will give you as many
-samples as it can, up to the amount requested. Later on when you need the next batch of samples, just call it again. Example:
-
-    ```c
-    while (drflac_read_pcm_frames_s32(pFlac, chunkSizeInPCMFrames, pChunkSamples) > 0) {
-        do_something();
-    }
-    ```
-
-You can seek to a specific PCM frame with `drflac_seek_to_pcm_frame()`.
-
-If you just want to quickly decode an entire FLAC file in one go you can do something like this:
-
-    ```c
-    unsigned int channels;
-    unsigned int sampleRate;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_int32* pSampleData = drflac_open_file_and_read_pcm_frames_s32("MySong.flac", &channels, &sampleRate, &totalPCMFrameCount, NULL);
-    if (pSampleData == NULL) {
-        // Failed to open and decode FLAC file.
-    }
-
-    ...
-
-    drflac_free(pSampleData, NULL);
-    ```
-
-You can read samples as signed 16-bit integer and 32-bit floating-point PCM with the *_s16() and *_f32() family of APIs respectively, but note that these
-should be considered lossy.
-
-
-If you need access to metadata (album art, etc.), use `drflac_open_with_metadata()`, `drflac_open_file_with_metdata()` or `drflac_open_memory_with_metadata()`.
-The rationale for keeping these APIs separate is that they're slightly slower than the normal versions and also just a little bit harder to use. dr_flac
-reports metadata to the application through the use of a callback, and every metadata block is reported before `drflac_open_with_metdata()` returns.
-
-The main opening APIs (`drflac_open()`, etc.) will fail if the header is not present. The presents a problem in certain scenarios such as broadcast style
-streams or internet radio where the header may not be present because the user has started playback mid-stream. To handle this, use the relaxed APIs:
-    
-    `drflac_open_relaxed()`
-    `drflac_open_with_metadata_relaxed()`
-
-It is not recommended to use these APIs for file based streams because a missing header would usually indicate a corrupt or perverse file. In addition, these
-APIs can take a long time to initialize because they may need to spend a lot of time finding the first frame.
-
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_FLAC_NO_STDIO
-  Disable `drflac_open_file()` and family.
-
-#define DR_FLAC_NO_OGG
-  Disables support for Ogg/FLAC streams.
-
-#define DR_FLAC_BUFFER_SIZE <number>
-  Defines the size of the internal buffer to store data from onRead(). This buffer is used to reduce the number of calls back to the client for more data.
-  Larger values means more memory, but better performance. My tests show diminishing returns after about 4KB (which is the default). Consider reducing this if
-  you have a very efficient implementation of onRead(), or increase it if it's very inefficient. Must be a multiple of 8.
-
-#define DR_FLAC_NO_CRC
-  Disables CRC checks. This will offer a performance boost when CRC is unnecessary. This will disable binary search seeking. When seeking, the seek table will
-  be used if available. Otherwise the seek will be performed using brute force.
-
-#define DR_FLAC_NO_SIMD
-  Disables SIMD optimizations (SSE on x86/x64 architectures, NEON on ARM architectures). Use this if you are having compatibility issues with your compiler.
-
-
-
-Notes
-=====
-- dr_flac does not support changing the sample rate nor channel count mid stream.
-- dr_flac is not thread-safe, but its APIs can be called from any thread so long as you do your own synchronization.
-- When using Ogg encapsulation, a corrupted metadata block will result in `drflac_open_with_metadata()` and `drflac_open()` returning inconsistent samples due
-  to differences in corrupted stream recorvery logic between the two APIs.
-*/
-
-#ifndef dr_flac_h
-#define dr_flac_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRFLAC_STRINGIFY(x)      #x
-#define DRFLAC_XSTRINGIFY(x)     DRFLAC_STRINGIFY(x)
-
-#define DRFLAC_VERSION_MAJOR     0
-#define DRFLAC_VERSION_MINOR     12
-#define DRFLAC_VERSION_REVISION  29
-#define DRFLAC_VERSION_STRING    DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drflac_int8;
-typedef unsigned char           drflac_uint8;
-typedef   signed short          drflac_int16;
-typedef unsigned short          drflac_uint16;
-typedef   signed int            drflac_int32;
-typedef unsigned int            drflac_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drflac_int64;
-    typedef unsigned __int64    drflac_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drflac_int64;
-    typedef unsigned long long  drflac_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drflac_uint64       drflac_uintptr;
-#else
-    typedef drflac_uint32       drflac_uintptr;
-#endif
-typedef drflac_uint8            drflac_bool8;
-typedef drflac_uint32           drflac_bool32;
-#define DRFLAC_TRUE             1
-#define DRFLAC_FALSE            0
-
-#if !defined(DRFLAC_API)
-    #if defined(DRFLAC_DLL)
-        #if defined(_WIN32)
-            #define DRFLAC_DLL_IMPORT  __declspec(dllimport)
-            #define DRFLAC_DLL_EXPORT  __declspec(dllexport)
-            #define DRFLAC_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRFLAC_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRFLAC_DLL_IMPORT
-                #define DRFLAC_DLL_EXPORT
-                #define DRFLAC_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-            #define DRFLAC_API  DRFLAC_DLL_EXPORT
-        #else
-            #define DRFLAC_API  DRFLAC_DLL_IMPORT
-        #endif
-        #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
-    #else
-        #define DRFLAC_API extern
-        #define DRFLAC_PRIVATE static
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1700   /* Visual Studio 2012 */
-    #define DRFLAC_DEPRECATED       __declspec(deprecated)
-#elif (defined(__GNUC__) && __GNUC__ >= 4)  /* GCC 4 */
-    #define DRFLAC_DEPRECATED       __attribute__((deprecated))
-#elif defined(__has_feature)                /* Clang */
-    #if __has_feature(attribute_deprecated)
-        #define DRFLAC_DEPRECATED   __attribute__((deprecated))
-    #else
-        #define DRFLAC_DEPRECATED
-    #endif
-#else
-    #define DRFLAC_DEPRECATED
-#endif
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
-DRFLAC_API const char* drflac_version_string(void);
-
-/*
-As data is read from the client it is placed into an internal buffer for fast access. This controls the size of that buffer. Larger values means more speed,
-but also more memory. In my testing there is diminishing returns after about 4KB, but you can fiddle with this to suit your own needs. Must be a multiple of 8.
-*/
-#ifndef DR_FLAC_BUFFER_SIZE
-#define DR_FLAC_BUFFER_SIZE   4096
-#endif
-
-/* Check if we can enable 64-bit optimizations. */
-#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-#define DRFLAC_64BIT
-#endif
-
-#ifdef DRFLAC_64BIT
-typedef drflac_uint64 drflac_cache_t;
-#else
-typedef drflac_uint32 drflac_cache_t;
-#endif
-
-/* The various metadata block types. */
-#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO       0
-#define DRFLAC_METADATA_BLOCK_TYPE_PADDING          1
-#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION      2
-#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE        3
-#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT   4
-#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET         5
-#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE          6
-#define DRFLAC_METADATA_BLOCK_TYPE_INVALID          127
-
-/* The various picture types specified in the PICTURE block. */
-#define DRFLAC_PICTURE_TYPE_OTHER                   0
-#define DRFLAC_PICTURE_TYPE_FILE_ICON               1
-#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON         2
-#define DRFLAC_PICTURE_TYPE_COVER_FRONT             3
-#define DRFLAC_PICTURE_TYPE_COVER_BACK              4
-#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE            5
-#define DRFLAC_PICTURE_TYPE_MEDIA                   6
-#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST             7
-#define DRFLAC_PICTURE_TYPE_ARTIST                  8
-#define DRFLAC_PICTURE_TYPE_CONDUCTOR               9
-#define DRFLAC_PICTURE_TYPE_BAND                    10
-#define DRFLAC_PICTURE_TYPE_COMPOSER                11
-#define DRFLAC_PICTURE_TYPE_LYRICIST                12
-#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION      13
-#define DRFLAC_PICTURE_TYPE_DURING_RECORDING        14
-#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE      15
-#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE          16
-#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH     17
-#define DRFLAC_PICTURE_TYPE_ILLUSTRATION            18
-#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE           19
-#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE      20
-
-typedef enum
-{
-    drflac_container_native,
-    drflac_container_ogg,
-    drflac_container_unknown
-} drflac_container;
-
-typedef enum
-{
-    drflac_seek_origin_start,
-    drflac_seek_origin_current
-} drflac_seek_origin;
-
-/* Packing is important on this structure because we map this directly to the raw data within the SEEKTABLE metadata block. */
-#pragma pack(2)
-typedef struct
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 flacFrameOffset;   /* The offset from the first byte of the header of the first frame. */
-    drflac_uint16 pcmFrameCount;
-} drflac_seekpoint;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint16 minBlockSizeInPCMFrames;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint32 minFrameSizeInPCMFrames;
-    drflac_uint32 maxFrameSizeInPCMFrames;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint8  md5[16];
-} drflac_streaminfo;
-
-typedef struct
-{
-    /*
-    The metadata type. Use this to know how to interpret the data below. Will be set to one of the
-    DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-    */
-    drflac_uint32 type;
-
-    /*
-    A pointer to the raw data. This points to a temporary buffer so don't hold on to it. It's best to
-    not modify the contents of this buffer. Use the structures below for more meaningful and structured
-    information about the metadata. It's possible for this to be null.
-    */
-    const void* pRawData;
-
-    /* The size in bytes of the block and the buffer pointed to by pRawData if it's non-NULL. */
-    drflac_uint32 rawDataSize;
-
-    union
-    {
-        drflac_streaminfo streaminfo;
-
-        struct
-        {
-            int unused;
-        } padding;
-
-        struct
-        {
-            drflac_uint32 id;
-            const void* pData;
-            drflac_uint32 dataSize;
-        } application;
-
-        struct
-        {
-            drflac_uint32 seekpointCount;
-            const drflac_seekpoint* pSeekpoints;
-        } seektable;
-
-        struct
-        {
-            drflac_uint32 vendorLength;
-            const char* vendor;
-            drflac_uint32 commentCount;
-            const void* pComments;
-        } vorbis_comment;
-
-        struct
-        {
-            char catalog[128];
-            drflac_uint64 leadInSampleCount;
-            drflac_bool32 isCD;
-            drflac_uint8 trackCount;
-            const void* pTrackData;
-        } cuesheet;
-
-        struct
-        {
-            drflac_uint32 type;
-            drflac_uint32 mimeLength;
-            const char* mime;
-            drflac_uint32 descriptionLength;
-            const char* description;
-            drflac_uint32 width;
-            drflac_uint32 height;
-            drflac_uint32 colorDepth;
-            drflac_uint32 indexColorCount;
-            drflac_uint32 pictureDataSize;
-            const drflac_uint8* pPictureData;
-        } picture;
-    } data;
-} drflac_metadata;
-
-
-/*
-Callback for when data needs to be read from the client.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pBufferOut (out)
-    The output buffer.
-
-bytesToRead (in)
-    The number of bytes to read.
-
-
-Return Value
-------------
-The number of bytes actually read.
-
-
-Remarks
--------
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until either the entire bytesToRead is filled or
-you have reached the end of the stream.
-*/
-typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data needs to be seeked.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-offset (in)
-    The number of bytes to move, relative to the origin. Will never be negative.
-
-origin (in)
-    The origin of the seek - the current position or the start of the stream.
-
-
-Return Value
-------------
-Whether or not the seek was successful.
-
-
-Remarks
--------
-The offset will never be negative. Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be
-either drflac_seek_origin_start or drflac_seek_origin_current.
-
-When seeking to a PCM frame using drflac_seek_to_pcm_frame(), dr_flac may call this with an offset beyond the end of the FLAC stream. This needs to be detected
-and handled by returning DRFLAC_FALSE.
-*/
-typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
-
-/*
-Callback for when a metadata block is read.
-
-
-Parameters
-----------
-pUserData (in)
-    The user data that was passed to drflac_open() and family.
-
-pMetadata (in)
-    A pointer to a structure containing the data of the metadata block.
-
-
-Remarks
--------
-Use pMetadata->type to determine which metadata block is being handled and how to read the data. This
-will be set to one of the DRFLAC_METADATA_BLOCK_TYPE_* tokens.
-*/
-typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
-
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drflac_allocation_callbacks;
-
-/* Structure for internal use. Only used for decoders opened with drflac_open_memory. */
-typedef struct
-{
-    const drflac_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drflac__memory_stream;
-
-/* Structure for internal use. Used for bit streaming. */
-typedef struct
-{
-    /* The function to call when more data needs to be read. */
-    drflac_read_proc onRead;
-
-    /* The function to call when the current read position needs to be moved. */
-    drflac_seek_proc onSeek;
-
-    /* The user data to pass around to onRead and onSeek. */
-    void* pUserData;
-
-
-    /*
-    The number of unaligned bytes in the L2 cache. This will always be 0 until the end of the stream is hit. At the end of the
-    stream there will be a number of bytes that don't cleanly fit in an L1 cache line, so we use this variable to know whether
-    or not the bistreamer needs to run on a slower path to read those last bytes. This will never be more than sizeof(drflac_cache_t).
-    */
-    size_t unalignedByteCount;
-
-    /* The content of the unaligned bytes. */
-    drflac_cache_t unalignedCache;
-
-    /* The index of the next valid cache line in the "L2" cache. */
-    drflac_uint32 nextL2Line;
-
-    /* The number of bits that have been consumed by the cache. This is used to determine how many valid bits are remaining. */
-    drflac_uint32 consumedBits;
-
-    /*
-    The cached data which was most recently read from the client. There are two levels of cache. Data flows as such:
-    Client -> L2 -> L1. The L2 -> L1 movement is aligned and runs on a fast path in just a few instructions.
-    */
-    drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
-    drflac_cache_t cache;
-
-    /*
-    CRC-16. This is updated whenever bits are read from the bit stream. Manually set this to 0 to reset the CRC. For FLAC, this
-    is reset to 0 at the beginning of each frame.
-    */
-    drflac_uint16 crc16;
-    drflac_cache_t crc16Cache;              /* A cache for optimizing CRC calculations. This is filled when when the L1 cache is reloaded. */
-    drflac_uint32 crc16CacheIgnoredBytes;   /* The number of bytes to ignore when updating the CRC-16 from the CRC-16 cache. */
-} drflac_bs;
-
-typedef struct
-{
-    /* The type of the subframe: SUBFRAME_CONSTANT, SUBFRAME_VERBATIM, SUBFRAME_FIXED or SUBFRAME_LPC. */
-    drflac_uint8 subframeType;
-
-    /* The number of wasted bits per sample as specified by the sub-frame header. */
-    drflac_uint8 wastedBitsPerSample;
-
-    /* The order to use for the prediction stage for SUBFRAME_FIXED and SUBFRAME_LPC. */
-    drflac_uint8 lpcOrder;
-
-    /* A pointer to the buffer containing the decoded samples in the subframe. This pointer is an offset from drflac::pExtraData. */
-    drflac_int32* pSamplesS32;
-} drflac_subframe;
-
-typedef struct
-{
-    /*
-    If the stream uses variable block sizes, this will be set to the index of the first PCM frame. If fixed block sizes are used, this will
-    always be set to 0. This is 64-bit because the decoded PCM frame number will be 36 bits.
-    */
-    drflac_uint64 pcmFrameNumber;
-
-    /*
-    If the stream uses fixed block sizes, this will be set to the frame number. If variable block sizes are used, this will always be 0. This
-    is 32-bit because in fixed block sizes, the maximum frame number will be 31 bits.
-    */
-    drflac_uint32 flacFrameNumber;
-
-    /* The sample rate of this frame. */
-    drflac_uint32 sampleRate;
-
-    /* The number of PCM frames in each sub-frame within this frame. */
-    drflac_uint16 blockSizeInPCMFrames;
-
-    /*
-    The channel assignment of this frame. This is not always set to the channel count. If interchannel decorrelation is being used this
-    will be set to DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE, DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE or DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE.
-    */
-    drflac_uint8 channelAssignment;
-
-    /* The number of bits per sample within this frame. */
-    drflac_uint8 bitsPerSample;
-
-    /* The frame's CRC. */
-    drflac_uint8 crc8;
-} drflac_frame_header;
-
-typedef struct
-{
-    /* The header. */
-    drflac_frame_header header;
-
-    /*
-    The number of PCM frames left to be read in this FLAC frame. This is initially set to the block size. As PCM frames are read,
-    this will be decremented. When it reaches 0, the decoder will see this frame as fully consumed and load the next frame.
-    */
-    drflac_uint32 pcmFramesRemaining;
-
-    /* The list of sub-frames within the frame. There is one sub-frame for each channel, and there's a maximum of 8 channels. */
-    drflac_subframe subframes[8];
-} drflac_frame;
-
-typedef struct
-{
-    /* The function to call when a metadata block is read. */
-    drflac_meta_proc onMeta;
-
-    /* The user data posted to the metadata callback function. */
-    void* pUserDataMD;
-
-    /* Memory allocation callbacks. */
-    drflac_allocation_callbacks allocationCallbacks;
-
-
-    /* The sample rate. Will be set to something like 44100. */
-    drflac_uint32 sampleRate;
-
-    /*
-    The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. Maximum 8. This is set based on the
-    value specified in the STREAMINFO block.
-    */
-    drflac_uint8 channels;
-
-    /* The bits per sample. Will be set to something like 16, 24, etc. */
-    drflac_uint8 bitsPerSample;
-
-    /* The maximum block size, in samples. This number represents the number of samples in each channel (not combined). */
-    drflac_uint16 maxBlockSizeInPCMFrames;
-
-    /*
-    The total number of PCM Frames making up the stream. Can be 0 in which case it's still a valid stream, but just means
-    the total PCM frame count is unknown. Likely the case with streams like internet radio.
-    */
-    drflac_uint64 totalPCMFrameCount;
-
-
-    /* The container type. This is set based on whether or not the decoder was opened from a native or Ogg stream. */
-    drflac_container container;
-
-    /* The number of seekpoints in the seektable. */
-    drflac_uint32 seekpointCount;
-
-
-    /* Information about the frame the decoder is currently sitting on. */
-    drflac_frame currentFLACFrame;
-
-
-    /* The index of the PCM frame the decoder is currently sitting on. This is only used for seeking. */
-    drflac_uint64 currentPCMFrame;
-
-    /* The position of the first FLAC frame in the stream. This is only ever used for seeking. */
-    drflac_uint64 firstFLACFramePosInBytes;
-
-
-    /* A hack to avoid a malloc() when opening a decoder with drflac_open_memory(). */
-    drflac__memory_stream memoryStream;
-
-
-    /* A pointer to the decoded sample data. This is an offset of pExtraData. */
-    drflac_int32* pDecodedSamples;
-
-    /* A pointer to the seek table. This is an offset of pExtraData, or NULL if there is no seek table. */
-    drflac_seekpoint* pSeekpoints;
-
-    /* Internal use only. Only used with Ogg containers. Points to a drflac_oggbs object. This is an offset of pExtraData. */
-    void* _oggbs;
-
-    /* Internal use only. Used for profiling and testing different seeking modes. */
-    drflac_bool32 _noSeekTableSeek    : 1;
-    drflac_bool32 _noBinarySearchSeek : 1;
-    drflac_bool32 _noBruteForceSeek   : 1;
-
-    /* The bit streamer. The raw FLAC data is fed through this object. */
-    drflac_bs bs;
-
-    /* Variable length extra data. We attach this to the end of the object so we can avoid unnecessary mallocs. */
-    drflac_uint8 pExtraData[1];
-} drflac;
-
-
-/*
-Opens a FLAC decoder.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-Returns a pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This function will automatically detect whether or not you are attempting to open a native or Ogg encapsulated FLAC, both of which should work seamlessly
-without any manual intervention. Ogg encapsulation also works with multiplexed streams which basically means it can play FLAC encoded audio tracks in videos.
-
-This is the lowest level function for opening a FLAC stream. You can also use `drflac_open_file()` and `drflac_open_memory()` to open the stream from a file or
-from a block of memory respectively.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_relaxed()` to open a FLAC stream where the header may not be present.
-
-Use `drflac_open_with_metadata()` if you need access to metadata.
-
-
-Seek Also
----------
-drflac_open_file()
-drflac_open_memory()
-drflac_open_with_metadata()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC stream with relaxed validation of the header block.
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-container (in)
-    Whether or not the FLAC stream is encapsulated using standard FLAC encapsulation or Ogg encapsulation.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead and onSeek.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-The same as drflac_open(), except attempts to open the stream even when a header block is not present.
-
-Because the header is not necessarily available, the caller must explicitly define the container (Native or Ogg). Do not set this to `drflac_container_unknown`
-as that is for internal use only.
-
-Opening in relaxed mode will continue reading data from onRead until it finds a valid frame. If a frame is never found it will continue forever. To abort,
-force your `onRead` callback to return 0, which dr_flac will use as an indicator that the end of the stream was found.
-
-Use `drflac_open_with_metadata_relaxed()` if you need access to metadata.
-*/
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder and notifies the caller of the metadata chunks (album art, etc.).
-
-
-Parameters
-----------
-onRead (in)
-    The function to call when data needs to be read from the client.
-
-onSeek (in)
-    The function to call when the read position of the client data needs to move.
-
-onMeta (in)
-    The function to call for every metadata block.
-
-pUserData (in, optional)
-    A pointer to application defined data that will be passed to onRead, onSeek and onMeta.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with `drflac_close()`.
-
-`pAllocationCallbacks` can be NULL in which case it will use `DRFLAC_MALLOC`, `DRFLAC_REALLOC` and `DRFLAC_FREE`.
-
-This is slower than `drflac_open()`, so avoid this one if you don't need metadata. Internally, this will allocate and free memory on the heap for every
-metadata block except for STREAMINFO and PADDING blocks.
-
-The caller is notified of the metadata via the `onMeta` callback. All metadata blocks will be handled before the function returns. This callback takes a
-pointer to a `drflac_metadata` object which is a union containing the data of all relevant metadata blocks. Use the `type` member to discriminate against
-the different metadata types.
-
-The STREAMINFO block must be present for this to succeed. Use `drflac_open_with_metadata_relaxed()` to open a FLAC stream where the header may not be present.
-
-Note that this will behave inconsistently with `drflac_open()` if the stream is an Ogg encapsulated stream and a metadata block is corrupted. This is due to
-the way the Ogg stream recovers from corrupted pages. When `drflac_open_with_metadata()` is being used, the open routine will try to read the contents of the
-metadata block, whereas `drflac_open()` will simply seek past it (for the sake of efficiency). This inconsistency can result in different samples being
-returned depending on whether or not the stream is being opened with metadata.
-
-
-Seek Also
----------
-drflac_open_file_with_metadata()
-drflac_open_memory_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-The same as drflac_open_with_metadata(), except attempts to open the stream even when a header block is not present.
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open_relaxed()
-*/
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Closes the given FLAC decoder.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder to close.
-
-
-Remarks
--------
-This will destroy the decoder object.
-
-
-See Also
---------
-drflac_open()
-drflac_open_with_metadata()
-drflac_open_file()
-drflac_open_file_w()
-drflac_open_file_with_metadata()
-drflac_open_file_with_metadata_w()
-drflac_open_memory()
-drflac_open_memory_with_metadata()
-*/
-DRFLAC_API void drflac_close(drflac* pFlac);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 32-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
-
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved signed 16-bit PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this is lossy for streams where the bits per sample is larger than 16.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
-
-/*
-Reads sample data from the given FLAC decoder, output as interleaved 32-bit floating point PCM.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-framesToRead (in)
-    The number of PCM frames to read.
-
-pBufferOut (out, optional)
-    A pointer to the buffer that will receive the decoded samples.
-
-
-Return Value
-------------
-Returns the number of PCM frames actually read. If the return value is less than `framesToRead` it has reached the end.
-
-
-Remarks
--------
-pBufferOut can be null, in which case the call will act as a seek, and the return value will be the number of frames seeked.
-
-Note that this should be considered lossy due to the nature of floating point numbers not being able to exactly represent every possible number.
-*/
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
-
-/*
-Seeks to the PCM frame at the given index.
-
-
-Parameters
-----------
-pFlac (in)
-    The decoder.
-
-pcmFrameIndex (in)
-    The index of the PCM frame to seek to. See notes below.
-
-
-Return Value
--------------
-`DRFLAC_TRUE` if successful; `DRFLAC_FALSE` otherwise.
-*/
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-/*
-Opens a FLAC decoder from the file at the given path.
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-Close the decoder with drflac_close().
-
-
-Remarks
--------
-This will hold a handle to the file until the decoder is closed with drflac_close(). Some platforms will restrict the number of files a process can have open
-at any given time, so keep this mind if you have many decoders open at the same time.
-
-
-See Also
---------
-drflac_open_file_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from the file at the given path and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pFileName (in)
-    The path of the file to open, either absolute or relative to the current directory.
-
-pAllocationCallbacks (in, optional)
-    A pointer to application defined callbacks for managing memory allocations.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
---------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Return Value
-------------
-A pointer to an object representing the decoder.
-
-
-Remarks
--------
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for the lifetime of the decoder.
-
-
-See Also
---------
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Opens a FLAC decoder from a pre-allocated block of memory and notifies the caller of the metadata chunks (album art, etc.)
-
-
-Parameters
-----------
-pData (in)
-    A pointer to the raw encoded FLAC data.
-
-dataSize (in)
-    The size in bytes of `data`.
-
-onMeta (in)
-    The callback to fire for each metadata block.
-
-pUserData (in)
-    A pointer to the user data to pass to the metadata callback.
-
-pAllocationCallbacks (in)
-    A pointer to application defined callbacks for managing memory allocations.
-
-
-Remarks
--------
-Look at the documentation for drflac_open_with_metadata() for more information on how metadata is handled.
-
-
-See Also
--------
-drflac_open_with_metadata()
-drflac_open()
-drflac_close()
-*/
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-
-/* High Level APIs */
-
-/*
-Opens a FLAC stream from the given callbacks and fully decodes it in a single operation. The return value is a
-pointer to the sample data as interleaved signed 32-bit PCM. The returned data must be freed with drflac_free().
-
-You can pass in custom memory allocation callbacks via the pAllocationCallbacks parameter. This can be NULL in which
-case it will use DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-
-Sometimes a FLAC file won't keep track of the total sample count. In this situation the function will continuously
-read samples into a dynamically sized buffer on the heap until no samples are left.
-
-Do not call this function on a broadcast type of stream (like internet radio streams and whatnot).
-*/
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_FLAC_NO_STDIO
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a file. */
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_file_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/* Same as drflac_open_and_read_pcm_frames_s32() except opens the decoder from a block of memory. */
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns signed 16-bit integer samples. */
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/* Same as drflac_open_memory_and_read_pcm_frames_s32(), except returns 32-bit floating-point samples. */
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Frees memory that was allocated internally by dr_flac.
-
-Set pAllocationCallbacks to the same object that was passed to drflac_open_*_and_read_pcm_frames_*(). If you originally passed in NULL, pass in NULL for this.
-*/
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
-
-
-/* Structure representing an iterator for vorbis comments in a VORBIS_COMMENT metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_vorbis_comment_iterator;
-
-/*
-Initializes a vorbis comment iterator. This can be used for iterating over the vorbis comments in a VORBIS_COMMENT
-metadata block.
-*/
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
-
-/*
-Goes to the next vorbis comment in the given iterator. If null is returned it means there are no more comments. The
-returned string is NOT null terminated.
-*/
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
-
-
-/* Structure representing an iterator for cuesheet tracks in a CUESHEET metadata block. */
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_cuesheet_track_iterator;
-
-/* Packing is important on this structure because we map this directly to the raw data within the CUESHEET metadata block. */
-#pragma pack(4)
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 index;
-    drflac_uint8 reserved[3];
-} drflac_cuesheet_track_index;
-#pragma pack()
-
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 trackNumber;
-    char ISRC[12];
-    drflac_bool8 isAudio;
-    drflac_bool8 preEmphasis;
-    drflac_uint8 indexCount;
-    const drflac_cuesheet_track_index* pIndexPoints;
-} drflac_cuesheet_track;
-
-/*
-Initializes a cuesheet track iterator. This can be used for iterating over the cuesheet tracks in a CUESHEET metadata
-block.
-*/
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
-
-/* Goes to the next cuesheet track in the given iterator. If DRFLAC_FALSE is returned it means there are no more comments. */
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_flac_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-#ifndef dr_flac_c
-#define dr_flac_c
-
-/* Disable some annoying warnings. */
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #if __GNUC__ >= 7
-    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-    #endif
-#endif
-
-#ifdef __linux__
-    #ifndef _BSD_SOURCE
-        #define _BSD_SOURCE
-    #endif
-    #ifndef _DEFAULT_SOURCE
-        #define _DEFAULT_SOURCE
-    #endif
-    #ifndef __USE_BSD
-        #define __USE_BSD
-    #endif
-    #include <endian.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _MSC_VER
-    #define DRFLAC_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRFLAC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRFLAC_INLINE __inline
-#else
-    #define DRFLAC_INLINE
-#endif
-
-/* CPU architecture. */
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRFLAC_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
-    #define DRFLAC_ARM
-#endif
-
-/*
-Intrinsics Support
-
-There's a bug in GCC 4.2.x which results in an incorrect compilation error when using _mm_slli_epi32() where it complains with
-
-    "error: shift must be an immediate"
-
-Unfortuantely dr_flac depends on this for a few things so we're just going to disable SSE on GCC 4.2 and below.
-*/
-#if !defined(DR_FLAC_NO_SIMD)
-    #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
-        #if defined(_MSC_VER) && !defined(__clang__)
-            /* MSVC. */
-            #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2)    /* 2005 */
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41)   /* 2010 */
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
-            /* Assume GNUC-style. */
-            #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_SSE41)
-            #include <smmintrin.h>
-        #elif defined(DRFLAC_SUPPORT_SSE2)
-            #include <emmintrin.h>
-        #endif
-    #endif
-
-    #if defined(DRFLAC_ARM)
-        #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            #define DRFLAC_SUPPORT_NEON
-        #endif
-
-        /* Fall back to looking for the #include file. */
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include(<arm_neon.h>)
-                #define DRFLAC_SUPPORT_NEON
-            #endif
-        #endif
-
-        #if defined(DRFLAC_SUPPORT_NEON)
-            #include <arm_neon.h>
-        #endif
-    #endif
-#endif
-
-/* Compile-time CPU feature support. */
-#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #else
-        #if defined(__GNUC__) || defined(__clang__)
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                /*
-                It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
-                specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
-                supporting different assembly dialects.
-
-                What's basically happening is that we're saving and restoring the ebx register manually.
-                */
-                #if defined(DRFLAC_X86) && defined(__PIC__)
-                    __asm__ __volatile__ (
-                        "xchg{l} {%%}ebx, %k1;"
-                        "cpuid;"
-                        "xchg{l} {%%}ebx, %k1;"
-                        : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #else
-                    __asm__ __volatile__ (
-                        "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #endif
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #endif
-#else
-    #define DRFLAC_NO_CPUID
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE2. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;    /* 64-bit targets always support SSE4.1. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate SSE41 code we can assume support. */
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[2] & (1 << 19)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* SSE41 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
-            #define DRFLAC_HAS_LZCNT_INTRINSIC
-        #endif
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#elif defined(__WATCOMC__) && defined(__386__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
-    extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
-    extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
-#pragma aux _watcom_bswap16 = \
-    "xchg al, ah" \
-    parm   [ax]   \
-    modify [ax];
-#pragma aux _watcom_bswap32 = \
-    "bswap eax"  \
-    parm   [eax] \
-    modify [eax];
-#pragma aux _watcom_bswap64 = \
-    "bswap eax"     \
-    "bswap edx"     \
-    "xchg eax,edx"  \
-    parm [eax edx]  \
-    modify [eax edx];
-#endif
-
-
-/* Standard library stuff. */
-#ifndef DRFLAC_ASSERT
-#include <assert.h>
-#define DRFLAC_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRFLAC_MALLOC
-#define DRFLAC_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRFLAC_REALLOC
-#define DRFLAC_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRFLAC_FREE
-#define DRFLAC_FREE(p)                      free((p))
-#endif
-#ifndef DRFLAC_COPY_MEMORY
-#define DRFLAC_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRFLAC_ZERO_MEMORY
-#define DRFLAC_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRFLAC_ZERO_OBJECT
-#define DRFLAC_ZERO_OBJECT(p)               DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
-#endif
-
-#define DRFLAC_MAX_SIMD_VECTOR_SIZE                     64  /* 64 for AVX-512 in the future. */
-
-typedef drflac_int32 drflac_result;
-#define DRFLAC_SUCCESS                                   0
-#define DRFLAC_ERROR                                    -1   /* A generic error. */
-#define DRFLAC_INVALID_ARGS                             -2
-#define DRFLAC_INVALID_OPERATION                        -3
-#define DRFLAC_OUT_OF_MEMORY                            -4
-#define DRFLAC_OUT_OF_RANGE                             -5
-#define DRFLAC_ACCESS_DENIED                            -6
-#define DRFLAC_DOES_NOT_EXIST                           -7
-#define DRFLAC_ALREADY_EXISTS                           -8
-#define DRFLAC_TOO_MANY_OPEN_FILES                      -9
-#define DRFLAC_INVALID_FILE                             -10
-#define DRFLAC_TOO_BIG                                  -11
-#define DRFLAC_PATH_TOO_LONG                            -12
-#define DRFLAC_NAME_TOO_LONG                            -13
-#define DRFLAC_NOT_DIRECTORY                            -14
-#define DRFLAC_IS_DIRECTORY                             -15
-#define DRFLAC_DIRECTORY_NOT_EMPTY                      -16
-#define DRFLAC_END_OF_FILE                              -17
-#define DRFLAC_NO_SPACE                                 -18
-#define DRFLAC_BUSY                                     -19
-#define DRFLAC_IO_ERROR                                 -20
-#define DRFLAC_INTERRUPT                                -21
-#define DRFLAC_UNAVAILABLE                              -22
-#define DRFLAC_ALREADY_IN_USE                           -23
-#define DRFLAC_BAD_ADDRESS                              -24
-#define DRFLAC_BAD_SEEK                                 -25
-#define DRFLAC_BAD_PIPE                                 -26
-#define DRFLAC_DEADLOCK                                 -27
-#define DRFLAC_TOO_MANY_LINKS                           -28
-#define DRFLAC_NOT_IMPLEMENTED                          -29
-#define DRFLAC_NO_MESSAGE                               -30
-#define DRFLAC_BAD_MESSAGE                              -31
-#define DRFLAC_NO_DATA_AVAILABLE                        -32
-#define DRFLAC_INVALID_DATA                             -33
-#define DRFLAC_TIMEOUT                                  -34
-#define DRFLAC_NO_NETWORK                               -35
-#define DRFLAC_NOT_UNIQUE                               -36
-#define DRFLAC_NOT_SOCKET                               -37
-#define DRFLAC_NO_ADDRESS                               -38
-#define DRFLAC_BAD_PROTOCOL                             -39
-#define DRFLAC_PROTOCOL_UNAVAILABLE                     -40
-#define DRFLAC_PROTOCOL_NOT_SUPPORTED                   -41
-#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED            -42
-#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED             -43
-#define DRFLAC_SOCKET_NOT_SUPPORTED                     -44
-#define DRFLAC_CONNECTION_RESET                         -45
-#define DRFLAC_ALREADY_CONNECTED                        -46
-#define DRFLAC_NOT_CONNECTED                            -47
-#define DRFLAC_CONNECTION_REFUSED                       -48
-#define DRFLAC_NO_HOST                                  -49
-#define DRFLAC_IN_PROGRESS                              -50
-#define DRFLAC_CANCELLED                                -51
-#define DRFLAC_MEMORY_ALREADY_MAPPED                    -52
-#define DRFLAC_AT_END                                   -53
-#define DRFLAC_CRC_MISMATCH                             -128
-
-#define DRFLAC_SUBFRAME_CONSTANT                        0
-#define DRFLAC_SUBFRAME_VERBATIM                        1
-#define DRFLAC_SUBFRAME_FIXED                           8
-#define DRFLAC_SUBFRAME_LPC                             32
-#define DRFLAC_SUBFRAME_RESERVED                        255
-
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE  0
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
-
-#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT           0
-#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE             8
-#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE            9
-#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE              10
-
-#define drflac_align(x, a)                              ((((x) + (a) - 1) / (a)) * (a))
-
-
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRFLAC_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRFLAC_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRFLAC_VERSION_REVISION;
-    }
-}
-
-DRFLAC_API const char* drflac_version_string(void)
-{
-    return DRFLAC_VERSION_STRING;
-}
-
-
-/* CPU caps. */
-#if defined(__has_feature)
-    #if __has_feature(thread_sanitizer)
-        #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
-    #else
-        #define DRFLAC_NO_THREAD_SANITIZE
-    #endif
-#else
-    #define DRFLAC_NO_THREAD_SANITIZE
-#endif
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
-#endif
-
-#ifndef DRFLAC_NO_CPUID
-static drflac_bool32 drflac__gIsSSE2Supported  = DRFLAC_FALSE;
-static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
-
-/*
-I've had a bug report that Clang's ThreadSanitizer presents a warning in this function. Having reviewed this, this does
-actually make sense. However, since CPU caps should never differ for a running process, I don't think the trade off of
-complicating internal API's by passing around CPU caps versus just disabling the warnings is worthwhile. I'm therefore
-just going to disable these warnings. This is disabled via the DRFLAC_NO_THREAD_SANITIZE attribute.
-*/
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
-
-    if (!isCPUCapsInitialized) {
-        /* LZCNT */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-        int info[4] = {0};
-        drflac__cpuid(info, 0x80000001);
-        drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
-#endif
-
-        /* SSE2 */
-        drflac__gIsSSE2Supported = drflac_has_sse2();
-
-        /* SSE4.1 */
-        drflac__gIsSSE41Supported = drflac_has_sse41();
-
-        /* Initialized. */
-        isCPUCapsInitialized = DRFLAC_TRUE;
-    }
-}
-#else
-static drflac_bool32 drflac__gIsNEONSupported  = DRFLAC_FALSE;
-
-static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
-{
-#if defined(DRFLAC_SUPPORT_NEON)
-    #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return DRFLAC_TRUE;    /* If the compiler is allowed to freely generate NEON code we can assume support. */
-        #else
-            /* TODO: Runtime check. */
-            return DRFLAC_FALSE;
-        #endif
-    #else
-        return DRFLAC_FALSE;       /* NEON is only supported on ARM architectures. */
-    #endif
-#else
-    return DRFLAC_FALSE;           /* No compiler support. */
-#endif
-}
-
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    drflac__gIsNEONSupported = drflac__has_neon();
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    drflac__gIsLZCNTSupported = DRFLAC_TRUE;
-#endif
-}
-#endif
-
-
-/* Endian Management */
-static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
-{
-#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
-    return DRFLAC_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRFLAC_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRFLAC_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            drflac_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRFLAC_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap32(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-    return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drflac_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drflac_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drflac_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drflac_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drflac_uint64)0x000000FF      )) << 56);
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint16(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint64(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
-{
-    if (!drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-
-    return n;
-}
-
-
-static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
-{
-    drflac_uint32 result = 0;
-    result |= (n & 0x7F000000) >> 3;
-    result |= (n & 0x007F0000) >> 2;
-    result |= (n & 0x00007F00) >> 1;
-    result |= (n & 0x0000007F) >> 0;
-
-    return result;
-}
-
-
-
-/* The CRC code below is based on this document: http://zlib.net/crc_v3.txt */
-static drflac_uint8 drflac__crc8_table[] = {
-    0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
-    0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
-    0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
-    0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
-    0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
-    0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
-    0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
-    0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
-    0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
-    0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
-    0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
-    0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
-    0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
-    0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
-    0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
-    0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-
-static drflac_uint16 drflac__crc16_table[] = {
-    0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
-    0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
-    0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
-    0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
-    0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
-    0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
-    0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
-    0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
-    0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
-    0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
-    0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
-    0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
-    0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
-    0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
-    0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
-    0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
-    0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
-    0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
-    0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
-    0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
-    0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
-    0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
-    0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
-    0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
-    0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
-    0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
-    0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
-    0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
-    0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
-    0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
-    0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
-    0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
-};
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
-{
-    return drflac__crc8_table[crc ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc8(crc, 0, 8);") */
-    drflac_uint8 p = 0x07;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint8 bit = (data & (1 << i)) >> i;
-        if (crc & 0x80) {
-            crc = ((crc << 1) | bit) ^ p;
-        } else {
-            crc = ((crc << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 32);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count - (wholeBytes*8);
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
-{
-    return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
-{
-#ifdef DRFLAC_64BIT
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-
-    return crc;
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
-{
-    switch (byteCount)
-    {
-#ifdef DRFLAC_64BIT
-    case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    }
-
-    return crc;
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    /* REFERENCE (use of this implementation requires an explicit flush by doing "drflac_crc16(crc, 0, 16);") */
-    drflac_uint16 p = 0x8005;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint16 bit = (data & (1ULL << i)) >> i;
-        if (r & 0x8000) {
-            r = ((r << 1) | bit) ^ p;
-        } else {
-            r = ((r << 1) | bit);
-        }
-    }
-
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-
-    DRFLAC_ASSERT(count <= 64);
-
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-
-    switch (wholeBytes) {
-        default:
-        case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits)));    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-        case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
-        case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
-        case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000      ) << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000      ) << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00      ) << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF      ) << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
-{
-#ifdef DRFLAC_64BIT
-    return drflac_crc16__64bit(crc, data, count);
-#else
-    return drflac_crc16__32bit(crc, data, count);
-#endif
-}
-#endif
-
-
-#ifdef DRFLAC_64BIT
-#define drflac__be2host__cache_line drflac__be2host_64
-#else
-#define drflac__be2host__cache_line drflac__be2host_32
-#endif
-
-/*
-BIT READING ATTEMPT #2
-
-This uses a 32- or 64-bit bit-shifted cache - as bits are read, the cache is shifted such that the first valid bit is sitting
-on the most significant bit. It uses the notion of an L1 and L2 cache (borrowed from CPU architecture), where the L1 cache
-is a 32- or 64-bit unsigned integer (depending on whether or not a 32- or 64-bit build is being compiled) and the L2 is an
-array of "cache lines", with each cache line being the same size as the L1. The L2 is a buffer of about 4KB and is where data
-from onRead() is read into.
-*/
-#define DRFLAC_CACHE_L1_SIZE_BYTES(bs)                      (sizeof((bs)->cache))
-#define DRFLAC_CACHE_L1_SIZE_BITS(bs)                       (sizeof((bs)->cache)*8)
-#define DRFLAC_CACHE_L1_BITS_REMAINING(bs)                  (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
-#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount)           (~((~(drflac_cache_t)0) >> (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount)      (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
-#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount)               (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount)     (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >>  DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
-#define DRFLAC_CACHE_L2_SIZE_BYTES(bs)                      (sizeof((bs)->cacheL2))
-#define DRFLAC_CACHE_L2_LINE_COUNT(bs)                      (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
-#define DRFLAC_CACHE_L2_LINES_REMAINING(bs)                 (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
-
-
-#ifndef DR_FLAC_NO_CRC
-static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
-{
-    bs->crc16 = 0;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-}
-
-static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
-{
-    if (bs->crc16CacheIgnoredBytes == 0) {
-        bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = 0;
-    }
-}
-
-static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
-{
-    /* We should never be flushing in a situation where we are not aligned on a byte boundary. */
-    DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
-
-    /*
-    The bits that were read from the L1 cache need to be accumulated. The number of bytes needing to be accumulated is determined
-    by the number of bits that have been consumed.
-    */
-    if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
-        drflac__update_crc16(bs);
-    } else {
-        /* We only accumulate the consumed bits. */
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
-
-        /*
-        The bits that we just accumulated should never be accumulated again. We need to keep track of how many bytes were accumulated
-        so we can handle that later.
-        */
-        bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-    }
-
-    return bs->crc16;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
-{
-    size_t bytesRead;
-    size_t alignedL1LineCount;
-
-    /* Fast path. Try loading straight from L2. */
-    if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we get here it means we've run out of data in the L2 cache. We'll need to fetch more from the client, if there's
-    any left.
-    */
-    if (bs->unalignedByteCount > 0) {
-        return DRFLAC_FALSE;   /* If we have any unaligned bytes it means there's no more aligned bytes left in the client. */
-    }
-
-    bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
-
-    bs->nextL2Line = 0;
-    if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-
-
-    /*
-    If we get here it means we were unable to retrieve enough data to fill the entire L2 cache. It probably
-    means we've just reached the end of the file. We need to move the valid data down to the end of the buffer
-    and adjust the index of the next line accordingly. Also keep in mind that the L2 cache must be aligned to
-    the size of the L1 so we'll need to seek backwards by any misaligned bytes.
-    */
-    alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
-
-    /* We need to keep track of any unaligned bytes for later use. */
-    bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    if (bs->unalignedByteCount > 0) {
-        bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
-    }
-
-    if (alignedL1LineCount > 0) {
-        size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
-        size_t i;
-        for (i = alignedL1LineCount; i > 0; --i) {
-            bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
-        }
-
-        bs->nextL2Line = (drflac_uint32)offset;
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    } else {
-        /* If we get into this branch it means we weren't able to load any L1-aligned data. */
-        bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-        return DRFLAC_FALSE;
-    }
-}
-
-static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
-{
-    size_t bytesRead;
-
-#ifndef DR_FLAC_NO_CRC
-    drflac__update_crc16(bs);
-#endif
-
-    /* Fast path. Try just moving the next value in the L2 cache to the L1 cache. */
-    if (drflac__reload_l1_cache_from_l2(bs)) {
-        bs->cache = drflac__be2host__cache_line(bs->cache);
-        bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-        bs->crc16Cache = bs->cache;
-#endif
-        return DRFLAC_TRUE;
-    }
-
-    /* Slow path. */
-
-    /*
-    If we get here it means we have failed to load the L1 cache from the L2. Likely we've just reached the end of the stream and the last
-    few bytes did not meet the alignment requirements for the L2 cache. In this case we need to fall back to a slower path and read the
-    data from the unaligned cache.
-    */
-    bytesRead = bs->unalignedByteCount;
-    if (bytesRead == 0) {
-        bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- The stream has been exhausted, so marked the bits as consumed. */
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
-
-    bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
-    bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs));    /* <-- Make sure the consumed bits are always set to zero. Other parts of the library depend on this property. */
-    bs->unalignedByteCount = 0;     /* <-- At this point the unaligned bytes have been moved into the cache and we thus have no more unaligned bytes. */
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = bs->cache >> bs->consumedBits;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-#endif
-    return DRFLAC_TRUE;
-}
-
-static void drflac__reset_cache(drflac_bs* bs)
-{
-    bs->nextL2Line   = DRFLAC_CACHE_L2_LINE_COUNT(bs);  /* <-- This clears the L2 cache. */
-    bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);   /* <-- This clears the L1 cache. */
-    bs->cache = 0;
-    bs->unalignedByteCount = 0;                         /* <-- This clears the trailing unaligned bytes. */
-    bs->unalignedCache = 0;
-
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = 0;
-    bs->crc16CacheIgnoredBytes = 0;
-#endif
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResultOut != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        /*
-        If we want to load all 32-bits from a 32-bit cache we need to do it slightly differently because we can't do
-        a 32-bit shift on a 32-bit integer. This will never be the case on 64-bit caches, so we can have a slightly
-        more optimal solution for this.
-        */
-#ifdef DRFLAC_64BIT
-        *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-        bs->consumedBits += bitCount;
-        bs->cache <<= bitCount;
-#else
-        if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-            bs->consumedBits += bitCount;
-            bs->cache <<= bitCount;
-        } else {
-            /* Cannot shift by 32-bits, so need to do it differently. */
-            *pResultOut = (drflac_uint32)bs->cache;
-            bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-            bs->cache = 0;
-        }
-#endif
-
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        drflac_uint32 bitCountLo = bitCount - bitCountHi;
-        drflac_uint32 resultHi;
-
-        DRFLAC_ASSERT(bitCountHi > 0);
-        DRFLAC_ASSERT(bitCountHi < 32);
-        resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
-
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Do not attempt to shift by 32 as it's undefined. */
-    if (bitCount < 32) {
-        drflac_uint32 signbit;
-        signbit = ((result >> (bitCount-1)) & 0x01);
-        result |= (~signbit + 1) << bitCount;
-    }
-
-    *pResult = (drflac_int32)result;
-    return DRFLAC_TRUE;
-}
-
-#ifdef DRFLAC_64BIT
-static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
-{
-    drflac_uint32 resultHi;
-    drflac_uint32 resultLo;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-    DRFLAC_ASSERT(bitCount >  32);
-
-    if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (!drflac__read_uint32(bs, 32, &resultLo)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
-    return DRFLAC_TRUE;
-}
-#endif
-
-/* Function below is unused, but leaving it here in case I need to quickly add it again. */
-#if 0
-static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
-{
-    drflac_uint64 result;
-    drflac_uint64 signbit;
-
-    DRFLAC_ASSERT(bitCount <= 64);
-
-    if (!drflac__read_uint64(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    signbit = ((result >> (bitCount-1)) & 0x01);
-    result |= (~signbit + 1) << bitCount;
-
-    *pResultOut = (drflac_int64)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint16)result;
-    return DRFLAC_TRUE;
-}
-
-#if 0
-static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int16)result;
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
-{
-    drflac_uint32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_uint8)result;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
-{
-    drflac_int32 result;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-
-    *pResult = (drflac_int8)result;
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
-{
-    if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        bs->consumedBits += (drflac_uint32)bitsToSeek;
-        bs->cache <<= bitsToSeek;
-        return DRFLAC_TRUE;
-    } else {
-        /* It straddles the cached data. This function isn't called too frequently so I'm favouring simplicity here. */
-        bitsToSeek       -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->cache         = 0;
-
-        /* Simple case. Seek in groups of the same number as bits that fit within a cache line. */
-#ifdef DRFLAC_64BIT
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint64 bin;
-            if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#else
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint32 bin;
-            if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#endif
-
-        /* Whole leftover bytes. */
-        while (bitsToSeek >= 8) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, 8, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= 8;
-        }
-
-        /* Leftover bits. */
-        if (bitsToSeek > 0) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek = 0; /* <-- Necessary for the assert below. */
-        }
-
-        DRFLAC_ASSERT(bitsToSeek == 0);
-        return DRFLAC_TRUE;
-    }
-}
-
-
-/* This function moves the bit streamer to the first bit after the sync code (bit 15 of the of the frame header). It will also update the CRC-16. */
-static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
-{
-    DRFLAC_ASSERT(bs != NULL);
-
-    /*
-    The sync code is always aligned to 8 bits. This is convenient for us because it means we can do byte-aligned movements. The first
-    thing to do is align to the next byte.
-    */
-    if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-        return DRFLAC_FALSE;
-    }
-
-    for (;;) {
-        drflac_uint8 hi;
-
-#ifndef DR_FLAC_NO_CRC
-        drflac__reset_crc16(bs);
-#endif
-
-        if (!drflac__read_uint8(bs, 8, &hi)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (hi == 0xFF) {
-            drflac_uint8 lo;
-            if (!drflac__read_uint8(bs, 6, &lo)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (lo == 0x3E) {
-                return DRFLAC_TRUE;
-            } else {
-                if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-
-    /* Should never get here. */
-    /*return DRFLAC_FALSE;*/
-}
-
-
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-#define DRFLAC_IMPLEMENT_CLZ_LZCNT
-#endif
-#if  defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
-#define DRFLAC_IMPLEMENT_CLZ_MSVC
-#endif
-#if  defined(__WATCOMC__) && defined(__386__)
-#define DRFLAC_IMPLEMENT_CLZ_WATCOM
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    static drflac_uint32 clz_table_4[] = {
-        0,
-        4,
-        3, 3,
-        2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1
-    };
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-    n = clz_table_4[x >> (sizeof(x)*8 - 4)];
-    if (n == 0) {
-#ifdef DRFLAC_64BIT
-        if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n  = 32; x <<= 32; }
-        if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
-        if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8;  x <<= 8;  }
-        if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4;  x <<= 4;  }
-#else
-        if ((x & 0xFFFF0000) == 0) { n  = 16; x <<= 16; }
-        if ((x & 0xFF000000) == 0) { n += 8;  x <<= 8;  }
-        if ((x & 0xF0000000) == 0) { n += 4;  x <<= 4;  }
-#endif
-        n += clz_table_4[x >> (sizeof(x)*8 - 4)];
-    }
-
-    return n - 1;
-}
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
-{
-    /* Fast compile time check for ARM. */
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    return DRFLAC_TRUE;
-#else
-    /* If the compiler itself does not support the intrinsic then we'll need to return false. */
-    #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
-        return drflac__gIsLZCNTSupported;
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#endif
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
-{
-    /*
-    It's critical for competitive decoding performance that this function be highly optimal. With MSVC we can use the __lzcnt64() and __lzcnt() intrinsics
-    to achieve good performance, however on GCC and Clang it's a little bit more annoying. The __builtin_clzl() and __builtin_clzll() intrinsics leave
-    it undefined as to the return value when `x` is 0. We need this to be well defined as returning 32 or 64, depending on whether or not it's a 32- or
-    64-bit build. To work around this we would need to add a conditional to check for the x = 0 case, but this creates unnecessary inefficiency. To work
-    around this problem I have written some inline assembly to emit the LZCNT (x86) or CLZ (ARM) instruction directly which removes the need to include
-    the conditional. This has worked well in the past, but for some reason Clang's MSVC compatible driver, clang-cl, does not seem to be handling this
-    in the same way as the normal Clang driver. It seems that `clang-cl` is just outputting the wrong results sometimes, maybe due to some register
-    getting clobbered?
-
-    I'm not sure if this is a bug with dr_flac's inlined assembly (most likely), a bug in `clang-cl` or just a misunderstanding on my part with inline
-    assembly rules for `clang-cl`. If somebody can identify an error in dr_flac's inlined assembly I'm happy to get that fixed.
-
-    Fortunately there is an easy workaround for this. Clang implements MSVC-specific intrinsics for compatibility. It also defines _MSC_VER for extra
-    compatibility. We can therefore just check for _MSC_VER and use the MSVC intrinsic which, fortunately for us, Clang supports. It would still be nice
-    to know how to fix the inlined assembly for correctness sake, however.
-    */
-
-#if defined(_MSC_VER) /*&& !defined(__clang__)*/    /* <-- Intentionally wanting Clang to use the MSVC __lzcnt64/__lzcnt intrinsics due to above ^. */
-    #ifdef DRFLAC_64BIT
-        return (drflac_uint32)__lzcnt64(x);
-    #else
-        return (drflac_uint32)__lzcnt(x);
-    #endif
-#else
-    #if defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_X64)
-            {
-                drflac_uint64 r;
-                __asm__ __volatile__ (
-                    "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return (drflac_uint32)r;
-            }
-        #elif defined(DRFLAC_X86)
-            {
-                drflac_uint32 r;
-                __asm__ __volatile__ (
-                    "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-
-                return r;
-            }
-        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)   /* <-- I haven't tested 64-bit inline assembly, so only enabling this for the 32-bit build for now. */
-            {
-                unsigned int r;
-                __asm__ __volatile__ (
-                #if defined(DRFLAC_64BIT)
-                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-                #else
-                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
-                #endif
-                );
-
-                return r;
-            }
-        #else
-            if (x == 0) {
-                return sizeof(x)*8;
-            }
-            #ifdef DRFLAC_64BIT
-                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
-            #else
-                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
-            #endif
-        #endif
-    #else
-        /* Unsupported compiler. */
-        #error "This compiler does not support the lzcnt intrinsic."
-    #endif
-#endif
-}
-#endif
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-#include <intrin.h> /* For BitScanReverse(). */
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
-{
-    drflac_uint32 n;
-
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-
-#ifdef DRFLAC_64BIT
-    _BitScanReverse64((unsigned long*)&n, x);
-#else
-    _BitScanReverse((unsigned long*)&n, x);
-#endif
-    return sizeof(x)*8 - n - 1;
-}
-#endif
-
-#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
-static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
-#pragma aux drflac__clz_watcom = \
-    "bsr eax, eax" \
-    "xor eax, 31" \
-    parm [eax] nomemory \
-    value [eax] \
-    modify exact [eax] nomemory;
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
-{
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-    if (drflac__is_lzcnt_supported()) {
-        return drflac__clz_lzcnt(x);
-    } else
-#endif
-    {
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-        return drflac__clz_msvc(x);
-#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
-        return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
-#else
-        return drflac__clz_software(x);
-#endif
-    }
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 setBitOffsetPlus1;
-
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    setBitOffsetPlus1 += 1;
-
-    bs->consumedBits += setBitOffsetPlus1;
-    bs->cache <<= setBitOffsetPlus1;
-
-    *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
-    return DRFLAC_TRUE;
-}
-
-
-
-static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(offsetFromStart > 0);
-
-    /*
-    Seeking from the start is not quite as trivial as it sounds because the onSeek callback takes a signed 32-bit integer (which
-    is intentional because it simplifies the implementation of the onSeek callbacks), however offsetFromStart is unsigned 64-bit.
-    To resolve we just need to do an initial seek from the start, and then a series of offset seeks to make up the remainder.
-    */
-    if (offsetFromStart > 0x7FFFFFFF) {
-        drflac_uint64 bytesRemaining = offsetFromStart;
-        if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        bytesRemaining -= 0x7FFFFFFF;
-
-        while (bytesRemaining > 0x7FFFFFFF) {
-            if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemaining -= 0x7FFFFFFF;
-        }
-
-        if (bytesRemaining > 0) {
-            if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-    } else {
-        if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The cache should be reset to force a reload of fresh data from the client. */
-    drflac__reset_cache(bs);
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
-{
-    drflac_uint8 crc;
-    drflac_uint64 result;
-    drflac_uint8 utf8[7] = {0};
-    int byteCount;
-    int i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pNumberOut != NULL);
-    DRFLAC_ASSERT(pCRCOut != NULL);
-
-    crc = *pCRCOut;
-
-    if (!drflac__read_uint8(bs, 8, utf8)) {
-        *pNumberOut = 0;
-        return DRFLAC_AT_END;
-    }
-    crc = drflac_crc8(crc, utf8[0], 8);
-
-    if ((utf8[0] & 0x80) == 0) {
-        *pNumberOut = utf8[0];
-        *pCRCOut = crc;
-        return DRFLAC_SUCCESS;
-    }
-
-    /*byteCount = 1;*/
-    if ((utf8[0] & 0xE0) == 0xC0) {
-        byteCount = 2;
-    } else if ((utf8[0] & 0xF0) == 0xE0) {
-        byteCount = 3;
-    } else if ((utf8[0] & 0xF8) == 0xF0) {
-        byteCount = 4;
-    } else if ((utf8[0] & 0xFC) == 0xF8) {
-        byteCount = 5;
-    } else if ((utf8[0] & 0xFE) == 0xFC) {
-        byteCount = 6;
-    } else if ((utf8[0] & 0xFF) == 0xFE) {
-        byteCount = 7;
-    } else {
-        *pNumberOut = 0;
-        return DRFLAC_CRC_MISMATCH;     /* Bad UTF-8 encoding. */
-    }
-
-    /* Read extra bytes. */
-    DRFLAC_ASSERT(byteCount > 1);
-
-    result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
-    for (i = 1; i < byteCount; ++i) {
-        if (!drflac__read_uint8(bs, 8, utf8 + i)) {
-            *pNumberOut = 0;
-            return DRFLAC_AT_END;
-        }
-        crc = drflac_crc8(crc, utf8[i], 8);
-
-        result = (result << 6) | (utf8[i] & 0x3F);
-    }
-
-    *pNumberOut = result;
-    *pCRCOut = crc;
-    return DRFLAC_SUCCESS;
-}
-
-
-
-/*
-The next two functions are responsible for calculating the prediction.
-
-When the bits per sample is >16 we need to use 64-bit integer arithmetic because otherwise we'll run out of precision. It's
-safe to assume this will be slower on 32-bit platforms so we use a more optimal solution when the bits per sample is <=16.
-*/
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int32 prediction = 0;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 32-bit version. */
-
-    /* VC++ optimizes this to a single jmp. I've not yet verified this for other compilers. */
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
-    }
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int64 prediction;
-
-    DRFLAC_ASSERT(order <= 32);
-
-    /* 64-bit version. */
-
-    /* This method is faster on the 32-bit build when compiling with VC++. See note below. */
-#ifndef DRFLAC_64BIT
-    if (order == 8)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
-    }
-    else if (order == 7)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-    }
-    else if (order == 3)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-    }
-    else if (order == 6)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-    }
-    else if (order == 5)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-    }
-    else if (order == 4)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-    }
-    else if (order == 12)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-        prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    }
-    else if (order == 2)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-    }
-    else if (order == 1)
-    {
-        prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-    }
-    else if (order == 10)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-    }
-    else if (order == 9)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-    }
-    else if (order == 11)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    }
-    else
-    {
-        int j;
-
-        prediction = 0;
-        for (j = 0; j < (int)order; ++j) {
-            prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
-        }
-    }
-#endif
-
-    /*
-    VC++ optimizes this to a single jmp instruction, but only the 64-bit build. The 32-bit build generates less efficient code for some
-    reason. The ugly version above is faster so we'll just switch between the two depending on the target platform.
-    */
-#ifdef DRFLAC_64BIT
-    prediction = 0;
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
-    }
-#endif
-
-    return (drflac_int32)(prediction >> shift);
-}
-
-
-#if 0
-/*
-Reference implementation for reading and decoding samples with residual. This is intentionally left unoptimized for the
-sake of readability and should only be used as a reference.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        drflac_uint32 zeroCounter = 0;
-        for (;;) {
-            drflac_uint8 bit;
-            if (!drflac__read_uint8(bs, 1, &bit)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (bit == 0) {
-                zeroCounter += 1;
-            } else {
-                break;
-            }
-        }
-
-        drflac_uint32 decodedRice;
-        if (riceParam > 0) {
-            if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            decodedRice = 0;
-        }
-
-        decodedRice |= (zeroCounter << riceParam);
-        if ((decodedRice & 0x01)) {
-            decodedRice = ~(decodedRice >> 1);
-        } else {
-            decodedRice =  (decodedRice >> 1);
-        }
-
-
-        if (bitsPerSample+shift >= 32) {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 decodedRice;
-
-    for (;;) {
-        drflac_uint8 bit;
-        if (!drflac__read_uint8(bs, 1, &bit)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (bit == 0) {
-            zeroCounter += 1;
-        } else {
-            break;
-        }
-    }
-
-    if (riceParam > 0) {
-        if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        decodedRice = 0;
-    }
-
-    *pZeroCounterOut = zeroCounter;
-    *pRiceParamPartOut = decodedRice;
-    return DRFLAC_TRUE;
-}
-#endif
-
-#if 0
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_cache_t riceParamMask;
-    drflac_uint32 zeroCounter;
-    drflac_uint32 setBitOffsetPlus1;
-    drflac_uint32 riceParamPart;
-    drflac_uint32 riceLength;
-
-    DRFLAC_ASSERT(riceParam > 0);   /* <-- riceParam should never be 0. drflac__read_rice_parts__param_equals_zero() should be used instead for this case. */
-
-    riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
-
-    zeroCounter = 0;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    zeroCounter += setBitOffsetPlus1;
-    setBitOffsetPlus1 += 1;
-
-    riceLength = setBitOffsetPlus1 + riceParam;
-    if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= riceLength;
-    } else {
-        drflac_uint32 bitCountLo;
-        drflac_cache_t resultHi;
-
-        bs->consumedBits += riceLength;
-        bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1);    /* <-- Equivalent to "if (setBitOffsetPlus1 < DRFLAC_CACHE_L1_SIZE_BITS(bs)) { bs->cache <<= setBitOffsetPlus1; }" */
-
-        /* It straddles the cached data. It will never cover more than the next chunk. We just read the number in two parts and combine them. */
-        bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam);  /* <-- Use DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE() if ever this function allows riceParam=0. */
-
-        if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-#ifndef DR_FLAC_NO_CRC
-            drflac__update_crc16(bs);
-#endif
-            bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-            bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-            bs->crc16Cache = bs->cache;
-#endif
-        } else {
-            /* Slow path. We need to fetch more data from the client. */
-            if (!drflac__reload_cache(bs)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
-
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-    }
-
-    pZeroCounterOut[0] = zeroCounter;
-    pRiceParamPartOut[0] = riceParamPart;
-
-    return DRFLAC_TRUE;
-}
-#endif
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    /*drflac_cache_t riceParamPlus1Mask  = DRFLAC_CACHE_L1_SELECTION_MASK(riceParamPlus1);*/
-    drflac_uint32  riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        pZeroCounterOut[0] = lzcount;
-
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartHi;
-            drflac_uint32 riceParamPartLo;
-            drflac_uint32 riceParamPartLoBitCount;
-
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Grab the high part of the rice parameter part. */
-            riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            /* We should now have enough information to construct the rice parameter part. */
-            riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
-            pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            zeroCounter += lzcount;
-
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        pZeroCounterOut[0] = zeroCounter;
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-
-    /*
-    The idea here is to use local variables for the cache in an attempt to encourage the compiler to store them in registers. I have
-    no idea how this will work in practice...
-    */
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-
-    /* The first thing to do is find the first unset bit. Most likely a bit will be set in the current cache line. */
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        /*
-        It is most likely that the riceParam part (which comes after the zero counter) is also on this cache line. When extracting
-        this, we include the set bit from the unary coded part because it simplifies cache management. This bit will be handled
-        outside of this function at a higher level.
-        */
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            /* Getting here means the rice parameter part is wholly contained within the current cache line. */
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            /*
-            Getting here means the rice parameter part straddles the cache line. We need to read from the tail of the current cache
-            line, reload the cache, and then combine it with the head of the next cache line.
-            */
-
-            /* Before reloading the cache we need to grab the size in bits of the low part. */
-            drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-
-            /* Now reload the cache. */
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        /*
-        Getting here means there are no bits set on the cache line. This is a less optimal case because we just wasted a call
-        to drflac__clz() and we need to reload the cache.
-        */
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                /* Slow path. We need to fetch more data from the client. */
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-
-            lzcount = drflac__clz(bs_cache);
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-
-        goto extract_rice_param_part;
-    }
-
-    /* Make sure the cache is restored at the end of it all. */
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0;
-    drflac_uint32 riceParamPart0;
-    drflac_uint32 riceParamMask;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    (void)bitsPerSample;
-    (void)order;
-    (void)shift;
-    (void)coefficients;
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-
-    i = 0;
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-
-        pSamplesOut[i] = riceParamPart0;
-
-        i += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0 = 0;
-    drflac_uint32 zeroCountPart1 = 0;
-    drflac_uint32 zeroCountPart2 = 0;
-    drflac_uint32 zeroCountPart3 = 0;
-    drflac_uint32 riceParamPart0 = 0;
-    drflac_uint32 riceParamPart1 = 0;
-    drflac_uint32 riceParamPart2 = 0;
-    drflac_uint32 riceParamPart3 = 0;
-    drflac_uint32 riceParamMask;
-    const drflac_int32* pSamplesOutEnd;
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    if (order == 0) {
-        return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    pSamplesOutEnd = pSamplesOut + (count & ~3);
-
-    if (bitsPerSample+shift > 32) {
-        while (pSamplesOut < pSamplesOutEnd) {
-            /*
-            Rice extraction. It's faster to do this one at a time against local variables than it is to use the x4 version
-            against an array. Not sure why, but perhaps it's making more efficient use of registers?
-            */
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    } else {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
-
-            pSamplesOut += 4;
-        }
-    }
-
-    i = (count & ~3);
-    while (i < count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        /*riceParamPart0  = (riceParamPart0 >> 1) ^ (~(riceParamPart0 & 0x01) + 1);*/
-
-        /* Sample reconstruction. */
-        if (bitsPerSample+shift > 32) {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-        } else {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-        }
-
-        i += 1;
-        pSamplesOut += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
-{
-    __m128i r;
-
-    /* Pack. */
-    r = _mm_packs_epi32(a, b);
-
-    /* a3a2 a1a0 b3b2 b1b0 -> a3a2 b3b2 a1a0 b1b0 */
-    r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    /* a3a2 b3b2 a1a0 b1b0 -> a3b3 a2b2 a1b1 a0b0 */
-    r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-
-    return r;
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_SSE41)
-static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
-{
-    return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
-{
-    __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-    __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
-    return _mm_add_epi32(x64, x32);
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
-{
-    return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-}
-
-static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
-{
-    /*
-    To simplify this we are assuming count < 32. This restriction allows us to work on a low side and a high side. The low side
-    is shifted with zero bits, whereas the right side is shifted with sign bits.
-    */
-    __m128i lo = _mm_srli_epi64(x, count);
-    __m128i hi = _mm_srai_epi32(x, count);
-
-    hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0));    /* The high part needs to have the low part cleared. */
-
-    return _mm_or_si128(lo, hi);
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    /* Pre-load. */
-    coefficients128_0 = _mm_setzero_si128();
-    coefficients128_4 = _mm_setzero_si128();
-    coefficients128_8 = _mm_setzero_si128();
-
-    samples128_0 = _mm_setzero_si128();
-    samples128_4 = _mm_setzero_si128();
-    samples128_8 = _mm_setzero_si128();
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be convenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    /* This causes strict-aliasing warnings with GCC. */
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i prediction128;
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01)));  /* <-- SSE2 compatible */
-        /*riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_mullo_epi32(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01)), _mm_set1_epi32(0xFFFFFFFF)));*/   /* <-- Only supported from SSE4.1 and is slower in my testing... */
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_4, samples128_4);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_8, samples128_8);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-
-                /* Horizontal add and shift. */
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-                samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i prediction128;
-    __m128i riceParamMask128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    DRFLAC_ASSERT(order <= 12);
-
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-
-    prediction128 = _mm_setzero_si128();
-
-    /* Pre-load. */
-    coefficients128_0  = _mm_setzero_si128();
-    coefficients128_4  = _mm_setzero_si128();
-    coefficients128_8  = _mm_setzero_si128();
-
-    samples128_0  = _mm_setzero_si128();
-    samples128_4  = _mm_setzero_si128();
-    samples128_8  = _mm_setzero_si128();
-
-#if 1
-    {
-        int runningOrder = order;
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
-
-        for (i = 0; i < 4; i += 1) {
-            prediction128 = _mm_xor_si128(prediction128, prediction128);    /* Reset to 0. */
-
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
-            case 10:
-            case  9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  8:
-            case  7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  6:
-            case  5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  4:
-            case  3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  2:
-            case  1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
-            }
-
-            /* Horizontal add and shift. */
-            prediction128 = drflac__mm_hadd_epi64(prediction128);
-            prediction128 = drflac__mm_srai_epi64(prediction128, shift);
-            prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-
-            /* Our value should be sitting in prediction128[0]. We need to combine this with our SSE samples. */
-            samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-            samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-            samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-        }
-
-        /* We store samples in groups of 4. */
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the SSE implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
-{
-    vst1q_s32(p+0, x.val[0]);
-    vst1q_s32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
-{
-    vst1q_u32(p+0, x.val[0]);
-    vst1q_u32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
-{
-    vst1q_f32(p+0, x.val[0]);
-    vst1q_f32(p+4, x.val[1]);
-}
-
-static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
-{
-    vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
-{
-    vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
-{
-    drflac_int32 x[4];
-    x[3] = x3;
-    x[2] = x2;
-    x[1] = x1;
-    x[0] = x0;
-    return vld1q_s32(x);
-}
-
-static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_s32(b, a, 1);
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
-{
-    /* Equivalent to SSE's _mm_alignr_epi8(a, b, 4) */
-
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(a, 0),
-        vgetq_lane_s32(b, 3),
-        vgetq_lane_s32(b, 2),
-        vgetq_lane_s32(b, 1)
-    );*/
-
-    return vextq_u32(b, a, 1);
-}
-
-static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
-{
-    /* The sum must end up in position 0. */
-
-    /* Reference */
-    /*return vdupq_n_s32(
-        vgetq_lane_s32(x, 3) +
-        vgetq_lane_s32(x, 2) +
-        vgetq_lane_s32(x, 1) +
-        vgetq_lane_s32(x, 0)
-    );*/
-
-    int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
-    return vpadd_s32(r, r);
-}
-
-static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
-{
-    return vadd_s64(vget_high_s64(x), vget_low_s64(x));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
-{
-    /* Reference */
-    /*return drflac__vdupq_n_s32x4(
-        vgetq_lane_s32(x, 0),
-        vgetq_lane_s32(x, 1),
-        vgetq_lane_s32(x, 2),
-        vgetq_lane_s32(x, 3)
-    );*/
-
-    return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
-}
-
-static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
-{
-    return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
-}
-
-static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
-{
-    return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int32x2_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s32(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int32x4_t prediction128;
-        int32x2_t prediction64;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = vmulq_s32(coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_8, samples128_8);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-
-                /* Horizontal add and shift. */
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-
-                samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int64x1_t shift64;
-    uint32x4_t one128;
-
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s64(-shift); /* Negate the shift because we'll be doing a variable shift using vshlq_s32(). */
-    one128 = vdupq_n_u32(1);
-
-    /*
-    Pre-loading the coefficients and prior samples is annoying because we need to ensure we don't try reading more than
-    what's available in the input buffers. It would be conenient to use a fall-through switch to do this, but this results
-    in strict aliasing warnings with GCC. To work around this I'm just doing something hacky. This feels a bit convoluted
-    so I think there's opportunity for this to be simplified.
-    */
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-
-        /* 0 - 3. */
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3]; /* fallthrough */
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2]; /* fallthrough */
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1]; /* fallthrough */
-            }
-
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 4 - 7 */
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7]; /* fallthrough */
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6]; /* fallthrough */
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5]; /* fallthrough */
-            }
-
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* 8 - 11 */
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11]; /* fallthrough */
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10]; /* fallthrough */
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9]; /* fallthrough */
-            }
-
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-
-        /* Coefficients need to be shuffled for our streaming algorithm below to work. Samples are already in the correct order from the loading routine above. */
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-
-    /* For this version we are doing one sample at a time. */
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int64x2_t prediction128;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-
-        for (i = 0; i < 4; i += 1) {
-            int64x1_t prediction64;
-
-            prediction128 = veorq_s64(prediction128, prediction128);    /* Reset to 0. */
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
-            case 10:
-            case  9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
-            case  8:
-            case  7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
-            case  6:
-            case  5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
-            case  4:
-            case  3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
-            case  2:
-            case  1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
-            }
-
-            /* Horizontal add and shift. */
-            prediction64 = drflac__vhaddq_s64(prediction128);
-            prediction64 = vshl_s64(prediction64, shift64);
-            prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
-
-            /* Our value should be sitting in prediction64[0]. We need to combine this with our SSE samples. */
-            samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-            samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-            samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
-
-            /* Slide our rice parameter down so that the value in position 0 contains the next one to process. */
-            riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-        }
-
-        /* We store samples in groups of 4. */
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-
-    /* Make sure we process the last few samples. */
-    i = (count & ~3);
-    while (i < (int)count) {
-        /* Rice extraction. */
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Rice reconstruction. */
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-
-        /* Sample reconstruction. */
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-
-        i += 1;
-        pDecodedSamples += 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    /* In my testing the order is rarely > 12, so in this case I'm going to simplify the NEON implementation by only handling order <= 12. */
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    if (drflac__gIsSSE41Supported) {
-        return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported) {
-        return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-    #if 0
-        return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #else
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #endif
-    }
-}
-
-/* Reads and seeks past a string of residual values as Rice codes. The decoder should be sitting on the first bit of the Rice codes. */
-static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (!drflac__seek_rice_parts(bs, riceParam)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(unencodedBitsPerSample <= 31);    /* <-- unencodedBitsPerSample is a 5 bit number, so cannot exceed 31. */
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (unencodedBitsPerSample > 0) {
-            if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            pSamplesOut[i] = 0;
-        }
-
-        if (bitsPerSample >= 24) {
-            pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-/*
-Reads and decodes the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be ignored. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    DRFLAC_ASSERT(pDecodedSamples != NULL);       /* <-- Should we allow NULL, in which case we just seek past the residual rather than do a full decode? */
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    /* Ignore the first <order> values. */
-    pDecodedSamples += order;
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) < order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;) {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pDecodedSamples += samplesInPartition;
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-
-        if (partitionOrder != 0) {
-            samplesInPartition = blockSize / (1 << partitionOrder);
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-/*
-Reads and seeks past the residual for the sub-frame the decoder is currently sitting on. This function should be called
-when the decoder is sitting at the very start of the RESIDUAL block. The first <order> residuals will be set to 0. The
-<blockSize> and <order> parameters are used to determine how many residual values need to be decoded.
-*/
-static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;    /* Unknown or unsupported residual coding method. */
-    }
-
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC spec:
-      The Rice partition order in a Rice-coded residual section must be less than or equal to 8.
-    */
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Validation check. */
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;)
-    {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-
-        if (riceParam != 0xFF) {
-            if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-
-        if (partitionsRemaining == 1) {
-            break;
-        }
-
-        partitionsRemaining -= 1;
-        samplesInPartition = blockSize / (1 << partitionOrder);
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    /* Only a single sample needs to be decoded here. */
-    drflac_int32 sample;
-    if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    We don't really need to expand this, but it does simplify the process of reading samples. If this becomes a performance issue (unlikely)
-    we'll want to look at a more efficient way.
-    */
-    for (i = 0; i < blockSize; ++i) {
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    for (i = 0; i < blockSize; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-
-    static drflac_int32 lpcCoefficientsTable[5][4] = {
-        {0,  0, 0,  0},
-        {1,  0, 0,  0},
-        {2, -1, 0,  0},
-        {3, -3, 1,  0},
-        {4, -6, 4, -1}
-    };
-
-    /* Warm up samples and coefficients. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 i;
-    drflac_uint8 lpcPrecision;
-    drflac_int8 lpcShift;
-    drflac_int32 coefficients[32];
-
-    /* Warm up samples. */
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-
-        pDecodedSamples[i] = sample;
-    }
-
-    if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcPrecision == 15) {
-        return DRFLAC_FALSE;    /* Invalid. */
-    }
-    lpcPrecision += 1;
-
-    if (!drflac__read_int8(bs, 5, &lpcShift)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    From the FLAC specification:
-
-        Quantized linear predictor coefficient shift needed in bits (NOTE: this number is signed two's-complement)
-
-    Emphasis on the "signed two's-complement". In practice there does not seem to be any encoders nor decoders supporting negative shifts. For now dr_flac is
-    not going to support negative shifts as I don't have any reference files. However, when a reference file comes through I will consider adding support.
-    */
-    if (lpcShift < 0) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
-    for (i = 0; i < lpcOrder; ++i) {
-        if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
-{
-    const drflac_uint32 sampleRateTable[12]  = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
-    const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1};   /* -1 = reserved. */
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(header != NULL);
-
-    /* Keep looping until we find a valid sync code. */
-    for (;;) {
-        drflac_uint8 crc8 = 0xCE; /* 0xCE = drflac_crc8(0, 0x3FFE, 14); */
-        drflac_uint8 reserved = 0;
-        drflac_uint8 blockingStrategy = 0;
-        drflac_uint8 blockSize = 0;
-        drflac_uint8 sampleRate = 0;
-        drflac_uint8 channelAssignment = 0;
-        drflac_uint8 bitsPerSample = 0;
-        drflac_bool32 isVariableBlockSize;
-
-        if (!drflac__find_and_seek_to_next_sync_code(bs)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-        if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, blockingStrategy, 1);
-
-        if (!drflac__read_uint8(bs, 4, &blockSize)) {
-            return DRFLAC_FALSE;
-        }
-        if (blockSize == 0) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, blockSize, 4);
-
-        if (!drflac__read_uint8(bs, 4, &sampleRate)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, sampleRate, 4);
-
-        if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
-            return DRFLAC_FALSE;
-        }
-        if (channelAssignment > 10) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, channelAssignment, 4);
-
-        if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        if (bitsPerSample == 3 || bitsPerSample == 7) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, bitsPerSample, 3);
-
-
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-
-
-        isVariableBlockSize = blockingStrategy == 1;
-        if (isVariableBlockSize) {
-            drflac_uint64 pcmFrameNumber;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = 0;
-            header->pcmFrameNumber = pcmFrameNumber;
-        } else {
-            drflac_uint64 flacFrameNumber = 0;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = (drflac_uint32)flacFrameNumber;   /* <-- Safe cast. */
-            header->pcmFrameNumber = 0;
-        }
-
-
-        DRFLAC_ASSERT(blockSize > 0);
-        if (blockSize == 1) {
-            header->blockSizeInPCMFrames = 192;
-        } else if (blockSize <= 5) {
-            DRFLAC_ASSERT(blockSize >= 2);
-            header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
-        } else if (blockSize == 6) {
-            if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
-            header->blockSizeInPCMFrames += 1;
-        } else if (blockSize == 7) {
-            if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
-            header->blockSizeInPCMFrames += 1;
-        } else {
-            DRFLAC_ASSERT(blockSize >= 8);
-            header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
-        }
-
-
-        if (sampleRate <= 11) {
-            header->sampleRate = sampleRateTable[sampleRate];
-        } else if (sampleRate == 12) {
-            if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 8);
-            header->sampleRate *= 1000;
-        } else if (sampleRate == 13) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-        } else if (sampleRate == 14) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-            header->sampleRate *= 10;
-        } else {
-            continue;  /* Invalid. Assume an invalid block. */
-        }
-
-
-        header->channelAssignment = channelAssignment;
-
-        header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
-        if (header->bitsPerSample == 0) {
-            header->bitsPerSample = streaminfoBitsPerSample;
-        }
-
-        if (!drflac__read_uint8(bs, 8, &header->crc8)) {
-            return DRFLAC_FALSE;
-        }
-
-#ifndef DR_FLAC_NO_CRC
-        if (header->crc8 != crc8) {
-            continue;    /* CRC mismatch. Loop back to the top and find the next sync code. */
-        }
-#endif
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
-{
-    drflac_uint8 header;
-    int type;
-
-    if (!drflac__read_uint8(bs, 8, &header)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* First bit should always be 0. */
-    if ((header & 0x80) != 0) {
-        return DRFLAC_FALSE;
-    }
-
-    type = (header & 0x7E) >> 1;
-    if (type == 0) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
-    } else if (type == 1) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
-    } else {
-        if ((type & 0x20) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
-        } else if ((type & 0x08) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
-            if (pSubframe->lpcOrder > 4) {
-                pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-                pSubframe->lpcOrder = 0;
-            }
-        } else {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-        }
-    }
-
-    if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Wasted bits per sample. */
-    pSubframe->wastedBitsPerSample = 0;
-    if ((header & 0x01) == 1) {
-        unsigned int wastedBitsPerSample;
-        if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = pDecodedSamplesOut;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Side channels require an extra bit per sample. Took a while to figure that one out... */
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-
-    /* Need to handle wasted bits per sample. */
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-
-    pSubframe->pSamplesS32 = NULL;
-
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac_uint8 lpcPrecision;
-
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-                return DRFLAC_FALSE;
-            }
-            if (lpcPrecision == 15) {
-                return DRFLAC_FALSE;    /* Invalid. */
-            }
-            lpcPrecision += 1;
-
-
-            bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5;    /* +5 for shift. */
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-
-        default: return DRFLAC_FALSE;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
-{
-    drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
-
-    DRFLAC_ASSERT(channelAssignment <= 10);
-    return lookup[channelAssignment];
-}
-
-static drflac_result drflac__decode_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint8 paddingSizeInBits;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    /* This function should be called while the stream is sitting on the first byte after the frame header. */
-    DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
-
-    /* The frame block size must never be larger than the maximum block size defined by the FLAC stream. */
-    if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_ERROR;
-    }
-
-    /* The number of channels in the frame must match the channel count from the STREAMINFO block. */
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    if (channelCount != (int)pFlac->channels) {
-        return DRFLAC_ERROR;
-    }
-
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
-    if (paddingSizeInBits > 0) {
-        drflac_uint8 padding = 0;
-        if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
-            return DRFLAC_AT_END;
-        }
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac__seek_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
-            return DRFLAC_ERROR;
-        }
-    }
-
-    /* Padding. */
-    if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
-        return DRFLAC_ERROR;
-    }
-
-    /* CRC. */
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;    /* CRC mismatch. */
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    for (;;) {
-        drflac_result result;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        result = drflac__decode_flac_frame(pFlac);
-        if (result != DRFLAC_SUCCESS) {
-            if (result == DRFLAC_CRC_MISMATCH) {
-                continue;   /* CRC mismatch. Skip to the next frame. */
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 lastPCMFrame;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
-    if (firstPCMFrame == 0) {
-        firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
-    }
-
-    lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    if (lastPCMFrame > 0) {
-        lastPCMFrame -= 1; /* Needs to be zero based. */
-    }
-
-    if (pFirstPCMFrame) {
-        *pFirstPCMFrame = firstPCMFrame;
-    }
-    if (pLastPCMFrame) {
-        *pLastPCMFrame = lastPCMFrame;
-    }
-}
-
-static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
-{
-    drflac_bool32 result;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
-
-    DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-    pFlac->currentPCMFrame = 0;
-
-    return result;
-}
-
-static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
-{
-    /* This function should only ever be called while the decoder is sitting on the first byte past the FRAME_HEADER section. */
-    DRFLAC_ASSERT(pFlac != NULL);
-    return drflac__seek_flac_frame(pFlac);
-}
-
-
-static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
-{
-    drflac_uint64 pcmFramesRead = 0;
-    while (pcmFramesToSeek > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
-                pcmFramesRead   += pcmFramesToSeek;
-                pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek;   /* <-- Safe cast. Will always be < currentFrame.pcmFramesRemaining < 65536. */
-                pcmFramesToSeek  = 0;
-            } else {
-                pcmFramesRead   += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-            }
-        }
-    }
-
-    pFlac->currentPCMFrame += pcmFramesRead;
-    return pcmFramesRead;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    /* If we are seeking forward we start from the current position. Otherwise we need to start all the way from the start of the file. */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame) {
-        /* Seeking forward. Need to seek from the current position. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Seeking backwards. Need to seek from the start of the file. */
-        runningPCMFrameCount = 0;
-
-        /* Move back to the start. */
-        if (!drflac__seek_to_first_frame(pFlac)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Decode the first frame in preparation for sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /*
-    We need to as quickly as possible find the frame that contains the target sample. To do this, we iterate over each frame and inspect its
-    header. If based on the header we can determine that the frame contains the sample, we do a full decode of that frame.
-    */
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#if !defined(DR_FLAC_NO_CRC)
-/*
-We use an average compression ratio to determine our approximate start location. FLAC files are generally about 50%-70% the size of their
-uncompressed counterparts so we'll use this as a basis. I'm going to split the middle and use a factor of 0.6 to determine the starting
-location.
-*/
-#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
-
-static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
-    DRFLAC_ASSERT(targetByte >= rangeLo);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
-
-    for (;;) {
-        /* After rangeLo == rangeHi == targetByte fails, we need to break out. */
-        drflac_uint64 lastTargetByte = targetByte;
-
-        /* When seeking to a byte, failure probably means we've attempted to seek beyond the end of the stream. To counter this we just halve it each attempt. */
-        if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
-            /* If we couldn't even seek to the first byte in the stream we have a problem. Just abandon the whole thing. */
-            if (targetByte == 0) {
-                drflac__seek_to_first_frame(pFlac); /* Try to recover. */
-                return DRFLAC_FALSE;
-            }
-
-            /* Halve the byte location and continue. */
-            targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-            rangeHi = targetByte;
-        } else {
-            /* Getting here should mean that we have seeked to an appropriate byte. */
-
-            /* Clear the details of the FLAC frame so we don't misreport data. */
-            DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-
-            /*
-            Now seek to the next FLAC frame. We need to decode the entire frame (not just the header) because it's possible for the header to incorrectly pass the
-            CRC check and return bad data. We need to decode the entire frame to be more certain. Although this seems unlikely, this has happened to me in testing
-            so it needs to stay this way for now.
-            */
-#if 1
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#else
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                /* Halve the byte location and continue. */
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#endif
-        }
-
-        /* We already tried this byte and there are no more to try, break out. */
-        if(targetByte == lastTargetByte) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    /* The current PCM frame needs to be updated based on the frame we just seeked to. */
-    drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-
-    *pLastSuccessfulSeekOffset = targetByte;
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
-{
-    /* This section of code would be used if we were only decoding the FLAC frame header when calling drflac__seek_to_approximate_flac_frame_to_byte(). */
-#if 0
-    if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
-        /* We failed to decode this frame which may be due to it being corrupt. We'll just use the next valid FLAC frame. */
-        if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-    }
-#endif
-
-    return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
-}
-
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
-{
-    /* This assumes pFlac->currentPCMFrame is sitting on byteRangeLo upon entry. */
-
-    drflac_uint64 targetByte;
-    drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
-    drflac_uint64 pcmRangeHi = 0;
-    drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
-    drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
-    if (targetByte > byteRangeHi) {
-        targetByte = byteRangeHi;
-    }
-
-    for (;;) {
-        if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
-            /* We found a FLAC frame. We need to check if it contains the sample we're looking for. */
-            drflac_uint64 newPCMRangeLo;
-            drflac_uint64 newPCMRangeHi;
-            drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
-
-            /* If we selected the same frame, it means we should be pretty close. Just decode the rest. */
-            if (pcmRangeLo == newPCMRangeLo) {
-                if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
-                    break;  /* Failed to seek to closest frame. */
-                }
-
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek forward. */
-                }
-            }
-
-            pcmRangeLo = newPCMRangeLo;
-            pcmRangeHi = newPCMRangeHi;
-
-            if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
-                /* The target PCM frame is in this FLAC frame. */
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;  /* Failed to seek to FLAC frame. */
-                }
-            } else {
-                const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-                if (pcmRangeLo > pcmFrameIndex) {
-                    /* We seeked too far forward. We need to move our target byte backward and try again. */
-                    byteRangeHi = lastSuccessfulSeekOffset;
-                    if (byteRangeLo > byteRangeHi) {
-                        byteRangeLo = byteRangeHi;
-                    }
-
-                    targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
-                    if (targetByte < byteRangeLo) {
-                        targetByte = byteRangeLo;
-                    }
-                } else /*if (pcmRangeHi < pcmFrameIndex)*/ {
-                    /* We didn't seek far enough. We need to move our target byte forward and try again. */
-
-                    /* If we're close enough we can just seek forward. */
-                    if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
-                        if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                            return DRFLAC_TRUE;
-                        } else {
-                            break;  /* Failed to seek to FLAC frame. */
-                        }
-                    } else {
-                        byteRangeLo = lastSuccessfulSeekOffset;
-                        if (byteRangeHi < byteRangeLo) {
-                            byteRangeHi = byteRangeLo;
-                        }
-
-                        targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
-                        if (targetByte > byteRangeHi) {
-                            targetByte = byteRangeHi;
-                        }
-
-                        if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
-                            closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
-                        }
-                    }
-                }
-            }
-        } else {
-            /* Getting here is really bad. We just recover as best we can, but moving to the first frame in the stream, and then abort. */
-            break;
-        }
-    }
-
-    drflac__seek_to_first_frame(pFlac); /* <-- Try to recover. */
-    return DRFLAC_FALSE;
-}
-
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint64 byteRangeLo;
-    drflac_uint64 byteRangeHi;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-
-    /* Our algorithm currently assumes the FLAC stream is currently sitting at the start. */
-    if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
-        return DRFLAC_FALSE;
-    }
-
-    /* If we're close enough to the start, just move to the start and seek forward. */
-    if (pcmFrameIndex < seekForwardThreshold) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
-    }
-
-    /*
-    Our starting byte range is the byte position of the first FLAC frame and the approximate end of the file as if it were completely uncompressed. This ensures
-    the entire file is included, even though most of the time it'll exceed the end of the actual stream. This is OK as the frame searching logic will handle it.
-    */
-    byteRangeLo = pFlac->firstFLACFramePosInBytes;
-    byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-
-    return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
-}
-#endif  /* !DR_FLAC_NO_CRC */
-
-static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint32 iClosestSeekpoint = 0;
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    drflac_uint32 iSeekpoint;
-
-
-    DRFLAC_ASSERT(pFlac != NULL);
-
-    if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-        if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
-            break;
-        }
-
-        iClosestSeekpoint = iSeekpoint;
-    }
-
-    /* There's been cases where the seek table contains only zeros. We need to do some basic validation on the closest seekpoint. */
-    if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
-        return DRFLAC_FALSE;
-    }
-
-#if !defined(DR_FLAC_NO_CRC)
-    /* At this point we should know the closest seek point. We can use a binary search for this. We need to know the total sample count for this. */
-    if (pFlac->totalPCMFrameCount > 0) {
-        drflac_uint64 byteRangeLo;
-        drflac_uint64 byteRangeHi;
-
-        byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-        byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
-
-        /*
-        If our closest seek point is not the last one, we only need to search between it and the next one. The section below calculates an appropriate starting
-        value for byteRangeHi which will clamp it appropriately.
-
-        Note that the next seekpoint must have an offset greater than the closest seekpoint because otherwise our binary search algorithm will break down. There
-        have been cases where a seektable consists of seek points where every byte offset is set to 0 which causes problems. If this happens we need to abort.
-        */
-        if (iClosestSeekpoint < pFlac->seekpointCount-1) {
-            drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
-
-            /* Basic validation on the seekpoints to ensure they're usable. */
-            if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
-                return DRFLAC_FALSE;    /* The next seekpoint doesn't look right. The seek table cannot be trusted from here. Abort. */
-            }
-
-            if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) { /* Make sure it's not a placeholder seekpoint. */
-                byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1; /* byteRangeHi must be zero based. */
-            }
-        }
-
-        if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-
-                if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
-                    return DRFLAC_TRUE;
-                }
-            }
-        }
-    }
-#endif  /* !DR_FLAC_NO_CRC */
-
-    /* Getting here means we need to use a slower algorithm because the binary search method failed or cannot be used. */
-
-    /*
-    If we are seeking forward and the closest seekpoint is _before_ the current sample, we just seek forward from where we are. Otherwise we start seeking
-    from the seekpoint's first sample.
-    */
-    if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
-        /* Optimized case. Just seek forward from where we are. */
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-
-        /* The frame header for the first frame may not yet have been read. We need to do that if necessary. */
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        /* Slower case. Seek to the start of the seekpoint and then seek forward from there. */
-        runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
-
-        if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Grab the frame the seekpoint is sitting on in preparation for the sample-exact seeking below. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            /*
-            The sample should be in this frame. We need to fully decode it, but if it's an invalid frame (a CRC mismatch) we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* We started seeking mid-frame which means we need to skip the frame decoding part. */
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;   /* CRC mismatch. Pretend this frame never existed. */
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /*
-                We started seeking mid-frame which means we need to seek by reading to the end of the frame instead of with
-                drflac__seek_to_next_flac_frame() which only works if the decoder is sitting on the byte just after the frame header.
-                */
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-
-            /* If we are seeking to the end of the file and we've just hit it, we're done. */
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-
-    next_iteration:
-        /* Grab the next frame in preparation for the next iteration. */
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-
-
-#ifndef DR_FLAC_NO_OGG
-typedef struct
-{
-    drflac_uint8 capturePattern[4];  /* Should be "OggS" */
-    drflac_uint8 structureVersion;   /* Always 0. */
-    drflac_uint8 headerType;
-    drflac_uint64 granulePosition;
-    drflac_uint32 serialNumber;
-    drflac_uint32 sequenceNumber;
-    drflac_uint32 checksum;
-    drflac_uint8 segmentCount;
-    drflac_uint8 segmentTable[255];
-} drflac_ogg_page_header;
-#endif
-
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    drflac_meta_proc onMeta;
-    drflac_container container;
-    void* pUserData;
-    void* pUserDataMD;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 runningFilePos;
-    drflac_bool32 hasStreamInfoBlock;
-    drflac_bool32 hasMetadataBlocks;
-    drflac_bs bs;                           /* <-- A bit streamer is required for loading data during initialization. */
-    drflac_frame_header firstFrameHeader;   /* <-- The header of the first frame that was read during relaxed initalization. Only set if there is no STREAMINFO block. */
-
-#ifndef DR_FLAC_NO_OGG
-    drflac_uint32 oggSerial;
-    drflac_uint64 oggFirstBytePos;
-    drflac_ogg_page_header oggBosHeader;
-#endif
-} drflac_init_info;
-
-static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    blockHeader = drflac__be2host_32(blockHeader);
-    *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
-    *blockType   = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
-    *blockSize   =                (blockHeader & 0x00FFFFFFUL);
-}
-
-static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    drflac_uint32 blockHeader;
-
-    *blockSize = 0;
-    if (onRead(pUserData, &blockHeader, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
-{
-    drflac_uint32 blockSizes;
-    drflac_uint64 frameSizes = 0;
-    drflac_uint64 importantProps;
-    drflac_uint8 md5[16];
-
-    /* min/max block size. */
-    if (onRead(pUserData, &blockSizes, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-
-    /* min/max frame size. */
-    if (onRead(pUserData, &frameSizes, 6) != 6) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Sample rate, channels, bits per sample and total sample count. */
-    if (onRead(pUserData, &importantProps, 8) != 8) {
-        return DRFLAC_FALSE;
-    }
-
-    /* MD5 */
-    if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
-        return DRFLAC_FALSE;
-    }
-
-    blockSizes     = drflac__be2host_32(blockSizes);
-    frameSizes     = drflac__be2host_64(frameSizes);
-    importantProps = drflac__be2host_64(importantProps);
-
-    pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
-    pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
-    pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
-    pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) <<  0)) >> 16);
-    pStreamInfo->sampleRate              = (drflac_uint32)((importantProps &  (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
-    pStreamInfo->channels                = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
-    pStreamInfo->bitsPerSample           = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
-    pStreamInfo->totalPCMFrameCount      =                ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
-    DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
-
-    return DRFLAC_TRUE;
-}
-
-
-static void* drflac__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_MALLOC(sz);
-}
-
-static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_REALLOC(p, sz);
-}
-
-static void drflac__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRFLAC_FREE(p);
-}
-
-
-static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRFLAC_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    /*
-    We want to keep track of the byte position in the stream of the seektable. At the time of calling this function we know that
-    we'll be sitting on byte 42.
-    */
-    drflac_uint64 runningFilePos = 42;
-    drflac_uint64 seektablePos   = 0;
-    drflac_uint32 seektableSize  = 0;
-
-    for (;;) {
-        drflac_metadata metadata;
-        drflac_uint8 isLastBlock = 0;
-        drflac_uint8 blockType;
-        drflac_uint32 blockSize;
-        if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-        runningFilePos += 4;
-
-        metadata.type = blockType;
-        metadata.pRawData = NULL;
-        metadata.rawDataSize = 0;
-
-        switch (blockType)
-        {
-            case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
-            {
-                if (blockSize < 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.application.id       = drflac__be2host_32(*(drflac_uint32*)pRawData);
-                    metadata.data.application.pData    = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
-                    metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
-            {
-                seektablePos  = runningFilePos;
-                seektableSize = blockSize;
-
-                if (onMeta) {
-                    drflac_uint32 iSeekpoint;
-                    void* pRawData;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
-                    metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-
-                    /* Endian swap. */
-                    for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
-                        drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
-                        pSeekpoint->firstPCMFrame   = drflac__be2host_64(pSeekpoint->firstPCMFrame);
-                        pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
-                        pSeekpoint->pcmFrameCount   = drflac__be2host_16(pSeekpoint->pcmFrameCount);
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
-            {
-                if (blockSize < 8) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint32 i;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.vendor       = pRunningData;                                            pRunningData += metadata.data.vorbis_comment.vendorLength;
-                    metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for 'commentCount' comments after the block, which at minimum is a drflac_uint32 per comment */
-                    if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.pComments    = pRunningData;
-
-                    /* Check that the comments section is valid before passing it to the callback */
-                    for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
-                        drflac_uint32 commentLength;
-
-                        if (pRunningDataEnd - pRunningData < 4) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += commentLength;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
-            {
-                if (blockSize < 396) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint8 iTrack;
-                    drflac_uint8 iIndex;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128);                              pRunningData += 128;
-                    metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
-                    metadata.data.cuesheet.isCD              = (pRunningData[0] & 0x80) != 0;                           pRunningData += 259;
-                    metadata.data.cuesheet.trackCount        = pRunningData[0];                                         pRunningData += 1;
-                    metadata.data.cuesheet.pTrackData        = pRunningData;
-
-                    /* Check that the cuesheet tracks are valid before passing it to the callback */
-                    for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
-                        drflac_uint8 indexCount;
-                        drflac_uint32 indexPointSize;
-
-                        if (pRunningDataEnd - pRunningData < 36) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Skip to the index point count */
-                        pRunningData += 35;
-                        indexCount = pRunningData[0]; pRunningData += 1;
-                        indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-
-                        /* Endian swap. */
-                        for (iIndex = 0; iIndex < indexCount; ++iIndex) {
-                            drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
-                            pRunningData += sizeof(drflac_cuesheet_track_index);
-                            pTrack->offset = drflac__be2host_64(pTrack->offset);
-                        }
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
-            {
-                if (blockSize < 32) {
-                    return DRFLAC_FALSE;
-                }
-
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-
-                    metadata.data.picture.type       = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.mime              = pRunningData;                                            pRunningData += metadata.data.picture.mimeLength;
-                    metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-
-                    /* Need space for the rest of the block */
-                    if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.description     = pRunningData;                                            pRunningData += metadata.data.picture.descriptionLength;
-                    metadata.data.picture.width           = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.height          = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.colorDepth      = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pPictureData    = (const drflac_uint8*)pRunningData;
-
-                    /* Need space for the picture after the block */
-                    if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) { /* <-- Note the order of operations to avoid overflow to a valid value */
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
-            {
-                if (onMeta) {
-                    metadata.data.padding.unused = 0;
-
-                    /* Padding doesn't have anything meaningful in it, so just skip over it, but make sure the caller is aware of it by firing the callback. */
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    } else {
-                        onMeta(pUserDataMD, &metadata);
-                    }
-                }
-            } break;
-
-            case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
-            {
-                /* Invalid chunk. Just skip over this one. */
-                if (onMeta) {
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;  /* An error occurred while seeking. Attempt to recover by treating this as the last block which will in turn terminate the loop. */
-                    }
-                }
-            } break;
-
-            default:
-            {
-                /*
-                It's an unknown chunk, but not necessarily invalid. There's a chance more metadata blocks might be defined later on, so we
-                can at the very least report the chunk to the application and let it look at the raw data.
-                */
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    onMeta(pUserDataMD, &metadata);
-
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-        }
-
-        /* If we're not handling metadata, just skip over the block. If we are, it will have been handled earlier in the switch statement above. */
-        if (onMeta == NULL && blockSize > 0) {
-            if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                isLastBlock = DRFLAC_TRUE;
-            }
-        }
-
-        runningFilePos += blockSize;
-        if (isLastBlock) {
-            break;
-        }
-    }
-
-    *pSeektablePos = seektablePos;
-    *pSeektableSize = seektableSize;
-    *pFirstFramePos = runningFilePos;
-
-    return DRFLAC_TRUE;
-}
-
-static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte id header. */
-
-    drflac_uint8 isLastBlock;
-    drflac_uint8 blockType;
-    drflac_uint32 blockSize;
-
-    (void)onSeek;
-
-    pInit->container = drflac_container_native;
-
-    /* The first metadata block should be the STREAMINFO block. */
-    if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-        return DRFLAC_FALSE;
-    }
-
-    if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-        if (!relaxed) {
-            /* We're opening in strict mode and the first block is not the STREAMINFO block. Error. */
-            return DRFLAC_FALSE;
-        } else {
-            /*
-            Relaxed mode. To open from here we need to just find the first frame and set the sample rate, etc. to whatever is defined
-            for that frame.
-            */
-            pInit->hasStreamInfoBlock = DRFLAC_FALSE;
-            pInit->hasMetadataBlocks  = DRFLAC_FALSE;
-
-            if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
-                return DRFLAC_FALSE;    /* Couldn't find a frame. */
-            }
-
-            if (pInit->firstFrameHeader.bitsPerSample == 0) {
-                return DRFLAC_FALSE;    /* Failed to initialize because the first frame depends on the STREAMINFO block, which does not exist. */
-            }
-
-            pInit->sampleRate              = pInit->firstFrameHeader.sampleRate;
-            pInit->channels                = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
-            pInit->bitsPerSample           = pInit->firstFrameHeader.bitsPerSample;
-            pInit->maxBlockSizeInPCMFrames = 65535;   /* <-- See notes here: https://xiph.org/flac/format.html#metadata_block_streaminfo */
-            return DRFLAC_TRUE;
-        }
-    } else {
-        drflac_streaminfo streaminfo;
-        if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-            return DRFLAC_FALSE;
-        }
-
-        pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-        pInit->sampleRate              = streaminfo.sampleRate;
-        pInit->channels                = streaminfo.channels;
-        pInit->bitsPerSample           = streaminfo.bitsPerSample;
-        pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-        pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;    /* Don't care about the min block size - only the max (used for determining the size of the memory allocation). */
-        pInit->hasMetadataBlocks       = !isLastBlock;
-
-        if (onMeta) {
-            drflac_metadata metadata;
-            metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-            metadata.pRawData = NULL;
-            metadata.rawDataSize = 0;
-            metadata.data.streaminfo = streaminfo;
-            onMeta(pUserDataMD, &metadata);
-        }
-
-        return DRFLAC_TRUE;
-    }
-}
-
-#ifndef DR_FLAC_NO_OGG
-#define DRFLAC_OGG_MAX_PAGE_SIZE            65307
-#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32    1605413199  /* CRC-32 of "OggS". */
-
-typedef enum
-{
-    drflac_ogg_recover_on_crc_mismatch,
-    drflac_ogg_fail_on_crc_mismatch
-} drflac_ogg_crc_mismatch_recovery;
-
-#ifndef DR_FLAC_NO_CRC
-static drflac_uint32 drflac__crc32_table[] = {
-    0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
-    0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
-    0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
-    0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
-    0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
-    0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
-    0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
-    0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
-    0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
-    0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
-    0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
-    0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
-    0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
-    0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
-    0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
-    0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
-    0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
-    0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
-    0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
-    0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
-    0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
-    0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
-    0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
-    0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
-    0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
-    0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
-    0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
-    0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
-    0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
-    0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
-    0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
-    0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
-    0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
-    0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
-    0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
-    0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
-    0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
-    0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
-    0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
-    0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
-    0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
-    0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
-    0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
-    0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
-    0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
-    0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
-    0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
-    0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
-    0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
-    0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
-    0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
-    0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
-    0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
-    0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
-    0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
-    0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
-    0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
-    0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
-    0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
-    0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
-    0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
-    0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
-    0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
-    0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
-};
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
-{
-#ifndef DR_FLAC_NO_CRC
-    return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
-#else
-    (void)data;
-    return crc32;
-#endif
-}
-
-#if 0
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
-{
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  8) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc32;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
-{
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >>  0) & 0xFFFFFFFF));
-    return crc32;
-}
-#endif
-
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
-{
-    /* This can be optimized. */
-    drflac_uint32 i;
-    for (i = 0; i < dataSize; ++i) {
-        crc32 = drflac_crc32_byte(crc32, pData[i]);
-    }
-    return crc32;
-}
-
-
-static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
-{
-    return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
-{
-    return 27 + pHeader->segmentCount;
-}
-
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
-{
-    drflac_uint32 pageBodySize = 0;
-    int i;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        pageBodySize += pHeader->segmentTable[i];
-    }
-
-    return pageBodySize;
-}
-
-static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 data[23];
-    drflac_uint32 i;
-
-    DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
-
-    if (onRead(pUserData, data, 23) != 23) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 23;
-
-    /*
-    It's not actually used, but set the capture pattern to 'OggS' for completeness. Not doing this will cause static analysers to complain about
-    us trying to access uninitialized data. We could alternatively just comment out this member of the drflac_ogg_page_header structure, but I
-    like to have it map to the structure of the underlying data.
-    */
-    pHeader->capturePattern[0] = 'O';
-    pHeader->capturePattern[1] = 'g';
-    pHeader->capturePattern[2] = 'g';
-    pHeader->capturePattern[3] = 'S';
-
-    pHeader->structureVersion = data[0];
-    pHeader->headerType       = data[1];
-    DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
-    DRFLAC_COPY_MEMORY(&pHeader->serialNumber,    &data[10], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber,  &data[14], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->checksum,        &data[18], 4);
-    pHeader->segmentCount     = data[22];
-
-    /* Calculate the CRC. Note that for the calculation the checksum part of the page needs to be set to 0. */
-    data[18] = 0;
-    data[19] = 0;
-    data[20] = 0;
-    data[21] = 0;
-
-    for (i = 0; i < 23; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
-    }
-
-
-    if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += pHeader->segmentCount;
-
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
-    }
-
-    return DRFLAC_SUCCESS;
-}
-
-static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 id[4];
-
-    *pBytesRead = 0;
-
-    if (onRead(pUserData, id, 4) != 4) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 4;
-
-    /* We need to read byte-by-byte until we find the OggS capture pattern. */
-    for (;;) {
-        if (drflac_ogg__is_capture_pattern(id)) {
-            drflac_result result;
-
-            *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-
-            result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
-            if (result == DRFLAC_SUCCESS) {
-                return DRFLAC_SUCCESS;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return result;
-                }
-            }
-        } else {
-            /* The first 4 bytes did not equal the capture pattern. Read the next byte and try again. */
-            id[0] = id[1];
-            id[1] = id[2];
-            id[2] = id[3];
-            if (onRead(pUserData, &id[3], 1) != 1) {
-                return DRFLAC_AT_END;
-            }
-            *pBytesRead += 1;
-        }
-    }
-}
-
-
-/*
-The main part of the Ogg encapsulation is the conversion from the physical Ogg bitstream to the native FLAC bitstream. It works
-in three general stages: Ogg Physical Bitstream -> Ogg/FLAC Logical Bitstream -> FLAC Native Bitstream. dr_flac is designed
-in such a way that the core sections assume everything is delivered in native format. Therefore, for each encapsulation type
-dr_flac is supporting there needs to be a layer sitting on top of the onRead and onSeek callbacks that ensures the bits read from
-the physical Ogg bitstream are converted and delivered in native FLAC format.
-*/
-typedef struct
-{
-    drflac_read_proc onRead;                /* The original onRead callback from drflac_open() and family. */
-    drflac_seek_proc onSeek;                /* The original onSeek callback from drflac_open() and family. */
-    void* pUserData;                        /* The user data passed on onRead and onSeek. This is the user data that was passed on drflac_open() and family. */
-    drflac_uint64 currentBytePos;           /* The position of the byte we are sitting on in the physical byte stream. Used for efficient seeking. */
-    drflac_uint64 firstBytePos;             /* The position of the first byte in the physical bitstream. Points to the start of the "OggS" identifier of the FLAC bos page. */
-    drflac_uint32 serialNumber;             /* The serial number of the FLAC audio pages. This is determined by the initial header page that was read during initialization. */
-    drflac_ogg_page_header bosPageHeader;   /* Used for seeking. */
-    drflac_ogg_page_header currentPageHeader;
-    drflac_uint32 bytesRemainingInPage;
-    drflac_uint32 pageDataSize;
-    drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
-} drflac_oggbs; /* oggbs = Ogg Bitstream */
-
-static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
-{
-    size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
-    oggbs->currentBytePos += bytesActuallyRead;
-
-    return bytesActuallyRead;
-}
-
-static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
-{
-    if (origin == drflac_seek_origin_start) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return DRFLAC_TRUE;
-        } else {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-
-            return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
-        }
-    } else {
-        while (offset > 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos += 0x7FFFFFFF;
-            offset -= 0x7FFFFFFF;
-        }
-
-        if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) {    /* <-- Safe cast thanks to the loop above. */
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += offset;
-
-        return DRFLAC_TRUE;
-    }
-}
-
-static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
-{
-    drflac_ogg_page_header header;
-    for (;;) {
-        drflac_uint32 crc32 = 0;
-        drflac_uint32 bytesRead;
-        drflac_uint32 pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        drflac_uint32 actualCRC32;
-#endif
-
-        if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += bytesRead;
-
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
-            continue;   /* Invalid page size. Assume it's corrupted and just move to the next page. */
-        }
-
-        if (header.serialNumber != oggbs->serialNumber) {
-            /* It's not a FLAC page. Skip it. */
-            if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            continue;
-        }
-
-
-        /* We need to read the entire page and then do a CRC check on it. If there's a CRC mismatch we need to skip this page. */
-        if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->pageDataSize = pageBodySize;
-
-#ifndef DR_FLAC_NO_CRC
-        actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
-        if (actualCRC32 != header.checksum) {
-            if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
-                continue;   /* CRC mismatch. Skip this page. */
-            } else {
-                /*
-                Even though we are failing on a CRC mismatch, we still want our stream to be in a good state. Therefore we
-                go to the next valid page to ensure we're in a good state, but return false to let the caller know that the
-                seek did not fully complete.
-                */
-                drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
-                return DRFLAC_FALSE;
-            }
-        }
-#else
-        (void)recoveryMethod;   /* <-- Silence a warning. */
-#endif
-
-        oggbs->currentPageHeader = header;
-        oggbs->bytesRemainingInPage = pageBodySize;
-        return DRFLAC_TRUE;
-    }
-}
-
-/* Function below is unused at the moment, but I might be re-adding it later. */
-#if 0
-static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
-{
-    drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
-    drflac_uint8 iSeg = 0;
-    drflac_uint32 iByte = 0;
-    while (iByte < bytesConsumedInPage) {
-        drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-        if (iByte + segmentSize > bytesConsumedInPage) {
-            break;
-        } else {
-            iSeg += 1;
-            iByte += segmentSize;
-        }
-    }
-
-    *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
-    return iSeg;
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
-{
-    /* The current packet ends when we get to the segment with a lacing value of < 255 which is not at the end of a page. */
-    for (;;) {
-        drflac_bool32 atEndOfPage = DRFLAC_FALSE;
-
-        drflac_uint8 bytesRemainingInSeg;
-        drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
-
-        drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
-        for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
-            drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-            if (segmentSize < 255) {
-                if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
-                    atEndOfPage = DRFLAC_TRUE;
-                }
-
-                break;
-            }
-
-            bytesToEndOfPacketOrPage += segmentSize;
-        }
-
-        /*
-        At this point we will have found either the packet or the end of the page. If were at the end of the page we'll
-        want to load the next page and keep searching for the end of the packet.
-        */
-        drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
-        oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
-
-        if (atEndOfPage) {
-            /*
-            We're potentially at the next packet, but we need to check the next page first to be sure because the packet may
-            straddle pages.
-            */
-            if (!drflac_oggbs__goto_next_page(oggbs)) {
-                return DRFLAC_FALSE;
-            }
-
-            /* If it's a fresh packet it most likely means we're at the next packet. */
-            if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* We're at the next packet. */
-            return DRFLAC_TRUE;
-        }
-    }
-}
-
-static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
-{
-    /* The bitstream should be sitting on the first byte just after the header of the frame. */
-
-    /* What we're actually doing here is seeking to the start of the next packet. */
-    return drflac_oggbs__seek_to_next_packet(oggbs);
-}
-#endif
-
-static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
-    size_t bytesRead = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(pRunningBufferOut != NULL);
-
-    /* Reading is done page-by-page. If we've run out of bytes in the page we need to move to the next one. */
-    while (bytesRead < bytesToRead) {
-        size_t bytesRemainingToRead = bytesToRead - bytesRead;
-
-        if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
-            bytesRead += bytesRemainingToRead;
-            oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
-            bytesRead += oggbs->bytesRemainingInPage;
-            pRunningBufferOut += oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToRead > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            break;  /* Failed to go to the next page. Might have simply hit the end of the stream. */
-        }
-    }
-
-    return bytesRead;
-}
-
-static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    int bytesSeeked = 0;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    /* Seeking is always forward which makes things a lot simpler. */
-    if (origin == drflac_seek_origin_start) {
-        if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-
-        return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
-    }
-
-    DRFLAC_ASSERT(origin == drflac_seek_origin_current);
-
-    while (bytesSeeked < offset) {
-        int bytesRemainingToSeek = offset - bytesSeeked;
-        DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
-
-        if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
-            bytesSeeked += bytesRemainingToSeek;
-            (void)bytesSeeked;  /* <-- Silence a dead store warning emitted by Clang Static Analyzer. */
-            oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
-            break;
-        }
-
-        /* If we get here it means some of the requested data is contained in the next pages. */
-        if (oggbs->bytesRemainingInPage > 0) {
-            bytesSeeked += (int)oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-
-        DRFLAC_ASSERT(bytesRemainingToSeek > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            /* Failed to go to the next page. We either hit the end of the stream or had a CRC mismatch. */
-            return DRFLAC_FALSE;
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-
-static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-    drflac_uint64 originalBytePos;
-    drflac_uint64 runningGranulePosition;
-    drflac_uint64 runningFrameBytePos;
-    drflac_uint64 runningPCMFrameCount;
-
-    DRFLAC_ASSERT(oggbs != NULL);
-
-    originalBytePos = oggbs->currentBytePos;   /* For recovery. Points to the OggS identifier. */
-
-    /* First seek to the first frame. */
-    if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
-        return DRFLAC_FALSE;
-    }
-    oggbs->bytesRemainingInPage = 0;
-
-    runningGranulePosition = 0;
-    for (;;) {
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
-            return DRFLAC_FALSE;   /* Never did find that sample... */
-        }
-
-        runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
-        if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
-            break; /* The sample is somewhere in the previous page. */
-        }
-
-        /*
-        At this point we know the sample is not in the previous page. It could possibly be in this page. For simplicity we
-        disregard any pages that do not begin a fresh packet.
-        */
-        if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {    /* <-- Is it a fresh page? */
-            if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
-                drflac_uint8 firstBytesInPage[2];
-                firstBytesInPage[0] = oggbs->pageData[0];
-                firstBytesInPage[1] = oggbs->pageData[1];
-
-                if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) {    /* <-- Does the page begin with a frame's sync code? */
-                    runningGranulePosition = oggbs->currentPageHeader.granulePosition;
-                }
-
-                continue;
-            }
-        }
-    }
-
-    /*
-    We found the page that that is closest to the sample, so now we need to find it. The first thing to do is seek to the
-    start of that page. In the loop above we checked that it was a fresh page which means this page is also the start of
-    a new frame. This property means that after we've seeked to the page we can immediately start looping over frames until
-    we find the one containing the target sample.
-    */
-    if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-        return DRFLAC_FALSE;
-    }
-
-    /*
-    At this point we'll be sitting on the first byte of the frame header of the first frame in the page. We just keep
-    looping over these frames until we find the one containing the sample we're after.
-    */
-    runningPCMFrameCount = runningGranulePosition;
-    for (;;) {
-        /*
-        There are two ways to find the sample and seek past irrelevant frames:
-          1) Use the native FLAC decoder.
-          2) Use Ogg's framing system.
-
-        Both of these options have their own pros and cons. Using the native FLAC decoder is slower because it needs to
-        do a full decode of the frame. Using Ogg's framing system is faster, but more complicated and involves some code
-        duplication for the decoding of frame headers.
-
-        Another thing to consider is that using the Ogg framing system will perform direct seeking of the physical Ogg
-        bitstream. This is important to consider because it means we cannot read data from the drflac_bs object using the
-        standard drflac__*() APIs because that will read in extra data for its own internal caching which in turn breaks
-        the positioning of the read pointer of the physical Ogg bitstream. Therefore, anything that would normally be read
-        using the native FLAC decoding APIs, such as drflac__read_next_flac_frame_header(), need to be re-implemented so as to
-        avoid the use of the drflac_bs object.
-
-        Considering these issues, I have decided to use the slower native FLAC decoding method for the following reasons:
-          1) Seeking is already partially accelerated using Ogg's paging system in the code block above.
-          2) Seeking in an Ogg encapsulated FLAC stream is probably quite uncommon.
-          3) Simplicity.
-        */
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac_uint64 pcmFrameCountInThisFrame;
-
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-
-        pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-
-        /* If we are seeking to the end of the file and we've just hit it, we're done. */
-        if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                return DRFLAC_TRUE;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
-            /*
-            The sample should be in this FLAC frame. We need to fully decode it, however if it's an invalid frame (a CRC mismatch), we need to pretend
-            it never existed and keep iterating.
-            */
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                /* The frame is valid. We just need to skip over some samples to ensure it's sample-exact. */
-                drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount);    /* <-- Safe cast because the maximum number of samples in a frame is 65535. */
-                if (pcmFramesToDecode == 0) {
-                    return DRFLAC_TRUE;
-                }
-
-                pFlac->currentPCMFrame = runningPCMFrameCount;
-
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;  /* <-- If this fails, something bad has happened (it should never fail). */
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            /*
-            It's not in this frame. We need to seek past the frame, but check if there was a CRC mismatch. If so, we pretend this
-            frame never existed and leave the running sample count untouched.
-            */
-            drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                runningPCMFrameCount += pcmFrameCountInThisFrame;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;   /* CRC mismatch. Pretend this frame never existed. */
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-
-
-
-static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_ogg_page_header header;
-    drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-    drflac_uint32 bytesRead = 0;
-
-    /* Pre Condition: The bit stream should be sitting just past the 4-byte OggS capture pattern. */
-    (void)relaxed;
-
-    pInit->container = drflac_container_ogg;
-    pInit->oggFirstBytePos = 0;
-
-    /*
-    We'll get here if the first 4 bytes of the stream were the OggS capture pattern, however it doesn't necessarily mean the
-    stream includes FLAC encoded audio. To check for this we need to scan the beginning-of-stream page markers and check if
-    any match the FLAC specification. Important to keep in mind that the stream may be multiplexed.
-    */
-    if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-        return DRFLAC_FALSE;
-    }
-    pInit->runningFilePos += bytesRead;
-
-    for (;;) {
-        int pageBodySize;
-
-        /* Break if we're past the beginning of stream page. */
-        if ((header.headerType & 0x02) == 0) {
-            return DRFLAC_FALSE;
-        }
-
-        /* Check if it's a FLAC header. */
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize == 51) {   /* 51 = the lacing value of the FLAC header packet. */
-            /* It could be a FLAC page... */
-            drflac_uint32 bytesRemainingInPage = pageBodySize;
-            drflac_uint8 packetType;
-
-            if (onRead(pUserData, &packetType, 1) != 1) {
-                return DRFLAC_FALSE;
-            }
-
-            bytesRemainingInPage -= 1;
-            if (packetType == 0x7F) {
-                /* Increasingly more likely to be a FLAC page... */
-                drflac_uint8 sig[4];
-                if (onRead(pUserData, sig, 4) != 4) {
-                    return DRFLAC_FALSE;
-                }
-
-                bytesRemainingInPage -= 4;
-                if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
-                    /* Almost certainly a FLAC page... */
-                    drflac_uint8 mappingVersion[2];
-                    if (onRead(pUserData, mappingVersion, 2) != 2) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (mappingVersion[0] != 1) {
-                        return DRFLAC_FALSE;   /* Only supporting version 1.x of the Ogg mapping. */
-                    }
-
-                    /*
-                    The next 2 bytes are the non-audio packets, not including this one. We don't care about this because we're going to
-                    be handling it in a generic way based on the serial number and packet types.
-                    */
-                    if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    /* Expecting the native FLAC signature "fLaC". */
-                    if (onRead(pUserData, sig, 4) != 4) {
-                        return DRFLAC_FALSE;
-                    }
-
-                    if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
-                        /* The remaining data in the page should be the STREAMINFO block. */
-                        drflac_streaminfo streaminfo;
-                        drflac_uint8 isLastBlock;
-                        drflac_uint8 blockType;
-                        drflac_uint32 blockSize;
-                        if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-                            return DRFLAC_FALSE;
-                        }
-
-                        if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-                            return DRFLAC_FALSE;    /* Invalid block type. First block must be the STREAMINFO block. */
-                        }
-
-                        if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-                            /* Success! */
-                            pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-                            pInit->sampleRate              = streaminfo.sampleRate;
-                            pInit->channels                = streaminfo.channels;
-                            pInit->bitsPerSample           = streaminfo.bitsPerSample;
-                            pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-                            pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-                            pInit->hasMetadataBlocks       = !isLastBlock;
-
-                            if (onMeta) {
-                                drflac_metadata metadata;
-                                metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-                                metadata.pRawData = NULL;
-                                metadata.rawDataSize = 0;
-                                metadata.data.streaminfo = streaminfo;
-                                onMeta(pUserDataMD, &metadata);
-                            }
-
-                            pInit->runningFilePos  += pageBodySize;
-                            pInit->oggFirstBytePos  = pInit->runningFilePos - 79;   /* Subtracting 79 will place us right on top of the "OggS" identifier of the FLAC bos page. */
-                            pInit->oggSerial        = header.serialNumber;
-                            pInit->oggBosHeader     = header;
-                            break;
-                        } else {
-                            /* Failed to read STREAMINFO block. Aww, so close... */
-                            return DRFLAC_FALSE;
-                        }
-                    } else {
-                        /* Invalid file. */
-                        return DRFLAC_FALSE;
-                    }
-                } else {
-                    /* Not a FLAC header. Skip it. */
-                    if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                /* Not a FLAC header. Seek past the entire page and move on to the next. */
-                if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-
-        pInit->runningFilePos += pageBodySize;
-
-
-        /* Read the header of the next page. */
-        if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += bytesRead;
-    }
-
-    /*
-    If we get here it means we found a FLAC audio stream. We should be sitting on the first byte of the header of the next page. The next
-    packets in the FLAC logical stream contain the metadata. The only thing left to do in the initialization phase for Ogg is to create the
-    Ogg bistream object.
-    */
-    pInit->hasMetadataBlocks = DRFLAC_TRUE;    /* <-- Always have at least VORBIS_COMMENT metadata block. */
-    return DRFLAC_TRUE;
-}
-#endif
-
-static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
-{
-    drflac_bool32 relaxed;
-    drflac_uint8 id[4];
-
-    if (pInit == NULL || onRead == NULL || onSeek == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
-    pInit->onRead       = onRead;
-    pInit->onSeek       = onSeek;
-    pInit->onMeta       = onMeta;
-    pInit->container    = container;
-    pInit->pUserData    = pUserData;
-    pInit->pUserDataMD  = pUserDataMD;
-
-    pInit->bs.onRead    = onRead;
-    pInit->bs.onSeek    = onSeek;
-    pInit->bs.pUserData = pUserData;
-    drflac__reset_cache(&pInit->bs);
-
-
-    /* If the container is explicitly defined then we can try opening in relaxed mode. */
-    relaxed = container != drflac_container_unknown;
-
-    /* Skip over any ID3 tags. */
-    for (;;) {
-        if (onRead(pUserData, id, 4) != 4) {
-            return DRFLAC_FALSE;    /* Ran out of data. */
-        }
-        pInit->runningFilePos += 4;
-
-        if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
-            drflac_uint8 header[6];
-            drflac_uint8 flags;
-            drflac_uint32 headerSize;
-
-            if (onRead(pUserData, header, 6) != 6) {
-                return DRFLAC_FALSE;    /* Ran out of data. */
-            }
-            pInit->runningFilePos += 6;
-
-            flags = header[1];
-
-            DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
-            headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
-            if (flags & 0x10) {
-                headerSize += 10;
-            }
-
-            if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;    /* Failed to seek past the tag. */
-            }
-            pInit->runningFilePos += headerSize;
-        } else {
-            break;
-        }
-    }
-
-    if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
-        return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
-        return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#endif
-
-    /* If we get here it means we likely don't have a header. Try opening in relaxed mode, if applicable. */
-    if (relaxed) {
-        if (container == drflac_container_native) {
-            return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (container == drflac_container_ogg) {
-            return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#endif
-    }
-
-    /* Unsupported container. */
-    return DRFLAC_FALSE;
-}
-
-static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pInit != NULL);
-
-    DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
-    pFlac->bs                      = pInit->bs;
-    pFlac->onMeta                  = pInit->onMeta;
-    pFlac->pUserDataMD             = pInit->pUserDataMD;
-    pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
-    pFlac->sampleRate              = pInit->sampleRate;
-    pFlac->channels                = (drflac_uint8)pInit->channels;
-    pFlac->bitsPerSample           = (drflac_uint8)pInit->bitsPerSample;
-    pFlac->totalPCMFrameCount      = pInit->totalPCMFrameCount;
-    pFlac->container               = pInit->container;
-}
-
-
-static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_init_info init;
-    drflac_uint32 allocationSize;
-    drflac_uint32 wholeSIMDVectorCountPerChannel;
-    drflac_uint32 decodedSamplesAllocationSize;
-#ifndef DR_FLAC_NO_OGG
-    drflac_oggbs oggbs;
-#endif
-    drflac_uint64 firstFramePos;
-    drflac_uint64 seektablePos;
-    drflac_uint32 seektableSize;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac* pFlac;
-
-    /* CPU support first. */
-    drflac__init_cpu_caps();
-
-    if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks != NULL) {
-        allocationCallbacks = *pAllocationCallbacks;
-        if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
-            return NULL;    /* Invalid allocation callbacks. */
-        }
-    } else {
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drflac__malloc_default;
-        allocationCallbacks.onRealloc = drflac__realloc_default;
-        allocationCallbacks.onFree    = drflac__free_default;
-    }
-
-
-    /*
-    The size of the allocation for the drflac object needs to be large enough to fit the following:
-      1) The main members of the drflac structure
-      2) A block of memory large enough to store the decoded samples of the largest frame in the stream
-      3) If the container is Ogg, a drflac_oggbs object
-
-    The complicated part of the allocation is making sure there's enough room the decoded samples, taking into consideration
-    the different SIMD instruction sets.
-    */
-    allocationSize = sizeof(drflac);
-
-    /*
-    The allocation size for decoded frames depends on the number of 32-bit integers that fit inside the largest SIMD vector
-    we are supporting.
-    */
-    if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
-    } else {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
-    }
-
-    decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
-
-    allocationSize += decodedSamplesAllocationSize;
-    allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE;  /* Allocate extra bytes to ensure we have enough for alignment. */
-
-#ifndef DR_FLAC_NO_OGG
-    /* There's additional data required for Ogg streams. */
-    if (init.container == drflac_container_ogg) {
-        allocationSize += sizeof(drflac_oggbs);
-    }
-
-    DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
-    if (init.container == drflac_container_ogg) {
-        oggbs.onRead = onRead;
-        oggbs.onSeek = onSeek;
-        oggbs.pUserData = pUserData;
-        oggbs.currentBytePos = init.oggFirstBytePos;
-        oggbs.firstBytePos = init.oggFirstBytePos;
-        oggbs.serialNumber = init.oggSerial;
-        oggbs.bosPageHeader = init.oggBosHeader;
-        oggbs.bytesRemainingInPage = 0;
-    }
-#endif
-
-    /*
-    This part is a bit awkward. We need to load the seektable so that it can be referenced in-memory, but I want the drflac object to
-    consist of only a single heap allocation. To this, the size of the seek table needs to be known, which we determine when reading
-    and decoding the metadata.
-    */
-    firstFramePos = 42;   /* <-- We know we are at byte 42 at this point. */
-    seektablePos  = 0;
-    seektableSize = 0;
-    if (init.hasMetadataBlocks) {
-        drflac_read_proc onReadOverride = onRead;
-        drflac_seek_proc onSeekOverride = onSeek;
-        void* pUserDataOverride = pUserData;
-
-#ifndef DR_FLAC_NO_OGG
-        if (init.container == drflac_container_ogg) {
-            onReadOverride = drflac__on_read_ogg;
-            onSeekOverride = drflac__on_seek_ogg;
-            pUserDataOverride = (void*)&oggbs;
-        }
-#endif
-
-        if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
-            return NULL;
-        }
-
-        allocationSize += seektableSize;
-    }
-
-
-    pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    drflac__init_from_info(pFlac, &init);
-    pFlac->allocationCallbacks = allocationCallbacks;
-    pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
-
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
-        *pInternalOggbs = oggbs;
-
-        /* The Ogg bistream needs to be layered on top of the original bitstream. */
-        pFlac->bs.onRead = drflac__on_read_ogg;
-        pFlac->bs.onSeek = drflac__on_seek_ogg;
-        pFlac->bs.pUserData = (void*)pInternalOggbs;
-        pFlac->_oggbs = (void*)pInternalOggbs;
-    }
-#endif
-
-    pFlac->firstFLACFramePosInBytes = firstFramePos;
-
-    /* NOTE: Seektables are not currently compatible with Ogg encapsulation (Ogg has its own accelerated seeking system). I may change this later, so I'm leaving this here for now. */
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg)
-    {
-        pFlac->pSeekpoints = NULL;
-        pFlac->seekpointCount = 0;
-    }
-    else
-#endif
-    {
-        /* If we have a seektable we need to load it now, making sure we move back to where we were previously. */
-        if (seektablePos != 0) {
-            pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
-            pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
-
-            DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
-            DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
-
-            /* Seek to the seektable, then just read directly into our seektable buffer. */
-            if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
-                if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
-                    /* Endian swap. */
-                    drflac_uint32 iSeekpoint;
-                    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-                        pFlac->pSeekpoints[iSeekpoint].firstPCMFrame   = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
-                        pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
-                        pFlac->pSeekpoints[iSeekpoint].pcmFrameCount   = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
-                    }
-                } else {
-                    /* Failed to read the seektable. Pretend we don't have one. */
-                    pFlac->pSeekpoints = NULL;
-                    pFlac->seekpointCount = 0;
-                }
-
-                /* We need to seek back to where we were. If this fails it's a critical error. */
-                if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            } else {
-                /* Failed to seek to the seektable. Ominous sign, but for now we can just pretend we don't have one. */
-                pFlac->pSeekpoints = NULL;
-                pFlac->seekpointCount = 0;
-            }
-        }
-    }
-
-
-    /*
-    If we get here, but don't have a STREAMINFO block, it means we've opened the stream in relaxed mode and need to decode
-    the first frame.
-    */
-    if (!init.hasStreamInfoBlock) {
-        pFlac->currentFLACFrame.header = init.firstFrameHeader;
-        for (;;) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                break;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                        drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                        return NULL;
-                    }
-                    continue;
-                } else {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            }
-        }
-    }
-
-    return pFlac;
-}
-
-
-
-#ifndef DR_FLAC_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>      /* For wcslen(), wcsrtombs() */
-
-/* drflac_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
-#include <errno.h>
-static drflac_result drflac_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRFLAC_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRFLAC_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRFLAC_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRFLAC_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRFLAC_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRFLAC_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRFLAC_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRFLAC_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRFLAC_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRFLAC_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRFLAC_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRFLAC_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRFLAC_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRFLAC_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRFLAC_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRFLAC_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRFLAC_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRFLAC_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRFLAC_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRFLAC_ERROR;
-    #endif
-        default: return DRFLAC_ERROR;
-    }
-}
-
-static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drflac_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drflac_result result = drflac_result_from_errno(errno);
-        if (result == DRFLAC_SUCCESS) {
-            result = DRFLAC_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRFLAC_HAS_WFOPEN
-    #endif
-#endif
-
-static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-
-#if defined(DRFLAC_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drflac_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drflac_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRFLAC_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drflac_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRFLAC_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRFLAC_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRFLAC_ERROR;
-    }
-#endif
-
-    return DRFLAC_SUCCESS;
-}
-
-static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    DRFLAC_ASSERT(offset >= 0);  /* <-- Never seek backwards. */
-
-    return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-
-    return pFlac;
-}
-#endif  /* DR_FLAC_NO_STDIO */
-
-static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    size_t bytesRemaining;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
-
-    bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
-        memoryStream->currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(offset >= 0); /* <-- Never seek backwards. */
-
-    if (offset > (drflac_int64)memoryStream->dataSize) {
-        return DRFLAC_FALSE;
-    }
-
-    if (origin == drflac_seek_origin_current) {
-        if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos += offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    } else {
-        if ((drflac_uint32)offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos = offset;
-        } else {
-            return DRFLAC_FALSE;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return DRFLAC_TRUE;
-}
-
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    pFlac->memoryStream = memoryStream;
-
-    /* This is an awful hack... */
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-
-    return pFlac;
-}
-
-
-
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
-}
-
-DRFLAC_API void drflac_close(drflac* pFlac)
-{
-    if (pFlac == NULL) {
-        return;
-    }
-
-#ifndef DR_FLAC_NO_STDIO
-    /*
-    If we opened the file with drflac_open_file() we will want to close the file handle. We can know whether or not drflac_open_file()
-    was used by looking at the callbacks.
-    */
-    if (pFlac->bs.onRead == drflac__on_read_stdio) {
-        fclose((FILE*)pFlac->bs.pUserData);
-    }
-
-#ifndef DR_FLAC_NO_OGG
-    /* Need to clean up Ogg streams a bit differently due to the way the bit streaming is chained. */
-    if (pFlac->container == drflac_container_ogg) {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
-
-        if (oggbs->onRead == drflac__on_read_stdio) {
-            fclose((FILE*)oggbs->pUserData);
-        }
-    }
-#endif
-#endif
-
-    drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    int32x4_t  wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t  wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-    uint32x4_t one4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    one4         = vdupq_n_u32(1);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift4_0 = vdupq_n_s32(shift0);
-    int32x4_t shift4_1 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
-
-        drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        left  >>= 16;
-        right >>= 16;
-
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = ((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = ((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = ((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = ((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = ((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = ((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = ((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = ((drflac_int32)(mid3 - side3) >> 1);
-
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    int32x4_t wbpsShift0_4; /* wbps = Wasted Bits Per Sample */
-    int32x4_t wbpsShift1_4; /* wbps = Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        int32x4_t shift4;
-
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        tempL0 >>= 16;
-        tempL1 >>= 16;
-        tempL2 >>= 16;
-        tempL3 >>= 16;
-
-        tempR0 >>= 16;
-        tempR1 >>= 16;
-        tempR2 >>= 16;
-        tempR3 >>= 16;
-
-        pOutputSamples[i*8+0] = (drflac_int16)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int16)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int16)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int16)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int16)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int16)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int16)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int16)tempR3;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-
-        /* At this point we have results. We can now pack and interleave these into a single __m128i object and then store the in the output buffer. */
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    int32x4_t shift0_4 = vdupq_n_s32(shift0);
-    int32x4_t shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        left  = vshrq_n_s32(left,  16);
-        right = vshrq_n_s32(right, 16);
-
-        drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        left   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right  = vsubq_u32(left, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        side   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left   = vaddq_u32(right, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-        mid = (mid << 1) | (side & 0x01);
-
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    __m128 factor128;
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor = 1.0f / 8388608.0f;
-    factor128 = _mm_set1_ps(factor);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128  leftf;
-            __m128  rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            tempR  = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128 leftf;
-            __m128 rightf;
-
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-
-            tempL  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            tempR  = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    float32x4_t factor4;
-    int32x4_t shift4;
-    int32x4_t wbps0_4;  /* Wasted Bits Per Sample */
-    int32x4_t wbps1_4;  /* Wasted Bits Per Sample */
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-
-    factor  = 1.0f / 8388608.0f;
-    factor4 = vdupq_n_f32(factor);
-    wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            uint32x4_t mid  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-
-            mid    = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-
-            lefti  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-
-            mid = (mid << 1) | (side & 0x01);
-
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    __m128 factor128 = _mm_set1_ps(factor);
-
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i lefti;
-        __m128i righti;
-        __m128 leftf;
-        __m128 rightf;
-
-        lefti  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-
-        leftf  = _mm_mul_ps(_mm_cvtepi32_ps(lefti),  factor128);
-        rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
-
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-
-    float factor = 1.0f / 8388608.0f;
-    float32x4_t factor4 = vdupq_n_f32(factor);
-    int32x4_t shift0_4  = vdupq_n_s32(shift0);
-    int32x4_t shift1_4  = vdupq_n_s32(shift1);
-
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t lefti;
-        int32x4_t righti;
-        float32x4_t leftf;
-        float32x4_t rightf;
-
-        lefti  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-
-        leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-        /* Scalar fallback. */
-#if 0
-        drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-
-    framesRead = 0;
-    while (framesToRead > 0) {
-        /* If we've run out of samples in this frame, go to the next. */
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;  /* Couldn't read the next frame, so just break from the loop and return. */
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                /* Generic interleaving. */
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
-                    }
-                }
-            }
-
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
-        }
-    }
-
-    return framesRead;
-}
-
-
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    if (pFlac == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    /* Don't do anything if we're already on the seek point. */
-    if (pFlac->currentPCMFrame == pcmFrameIndex) {
-        return DRFLAC_TRUE;
-    }
-
-    /*
-    If we don't know where the first frame begins then we can't seek. This will happen when the STREAMINFO block was not present
-    when the decoder was opened.
-    */
-    if (pFlac->firstFLACFramePosInBytes == 0) {
-        return DRFLAC_FALSE;
-    }
-
-    if (pcmFrameIndex == 0) {
-        pFlac->currentPCMFrame = 0;
-        return drflac__seek_to_first_frame(pFlac);
-    } else {
-        drflac_bool32 wasSuccessful = DRFLAC_FALSE;
-        drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
-
-        /* Clamp the sample to the end. */
-        if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
-            pcmFrameIndex = pFlac->totalPCMFrameCount;
-        }
-
-        /* If the target sample and the current sample are in the same frame we just move the position forward. */
-        if (pcmFrameIndex > pFlac->currentPCMFrame) {
-            /* Forward. */
-            drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
-            if (pFlac->currentFLACFrame.pcmFramesRemaining >  offset) {
-                pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        } else {
-            /* Backward. */
-            drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
-            drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-            drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
-            if (currentFLACFramePCMFramesConsumed > offsetAbs) {
-                pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        }
-
-        /*
-        Different techniques depending on encapsulation. Using the native FLAC seektable with Ogg encapsulation is a bit awkward so
-        we'll instead use Ogg's natural seeking facility.
-        */
-#ifndef DR_FLAC_NO_OGG
-        if (pFlac->container == drflac_container_ogg)
-        {
-            wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
-        }
-        else
-#endif
-        {
-            /* First try seeking via the seek table. If this fails, fall back to a brute force seek which is much slower. */
-            if (/*!wasSuccessful && */!pFlac->_noSeekTableSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
-            }
-
-#if !defined(DR_FLAC_NO_CRC)
-            /* Fall back to binary search if seek table seeking fails. This requires the length of the stream to be known. */
-            if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
-                wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
-            }
-#endif
-
-            /* Fall back to brute force if all else fails. */
-            if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
-            }
-        }
-
-        if (wasSuccessful) {
-            pFlac->currentPCMFrame = pcmFrameIndex;
-        } else {
-            /* Seek failed. Try putting the decoder back to it's original state. */
-            if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
-                /* Failed to seek back to the original PCM frame. Fall back to 0. */
-                drflac_seek_to_pcm_frame(pFlac, 0);
-            }
-        }
-
-        return wasSuccessful;
-    }
-}
-
-
-
-/* High Level APIs */
-
-#if defined(SIZE_MAX)
-    #define DRFLAC_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(DRFLAC_64BIT)
-        #define DRFLAC_SIZE_MAX  ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRFLAC_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-
-/* Using a macro as the definition of the drflac__full_decode_and_close_*() API family. Sue me. */
-#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
-static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
-{                                                                                                                                                                   \
-    type* pSampleData = NULL;                                                                                                                                       \
-    drflac_uint64 totalPCMFrameCount;                                                                                                                               \
-                                                                                                                                                                    \
-    DRFLAC_ASSERT(pFlac != NULL);                                                                                                                                   \
-                                                                                                                                                                    \
-    totalPCMFrameCount = pFlac->totalPCMFrameCount;                                                                                                                 \
-                                                                                                                                                                    \
-    if (totalPCMFrameCount == 0) {                                                                                                                                  \
-        type buffer[4096];                                                                                                                                          \
-        drflac_uint64 pcmFramesRead;                                                                                                                                \
-        size_t sampleDataBufferSize = sizeof(buffer);                                                                                                               \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks);                                                      \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) {          \
-            if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) {                                                   \
-                type* pNewSampleData;                                                                                                                               \
-                size_t newSampleDataBufferSize;                                                                                                                     \
-                                                                                                                                                                    \
-                newSampleDataBufferSize = sampleDataBufferSize * 2;                                                                                                 \
-                pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks);    \
-                if (pNewSampleData == NULL) {                                                                                                                       \
-                    drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks);                                                                          \
-                    goto on_error;                                                                                                                                  \
-                }                                                                                                                                                   \
-                                                                                                                                                                    \
-                sampleDataBufferSize = newSampleDataBufferSize;                                                                                                     \
-                pSampleData = pNewSampleData;                                                                                                                       \
-            }                                                                                                                                                       \
-                                                                                                                                                                    \
-            DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type)));                   \
-            totalPCMFrameCount += pcmFramesRead;                                                                                                                    \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        /* At this point everything should be decoded, but we just want to fill the unused part buffer with silence - need to                                       \
-           protect those ears from random noise! */                                                                                                                 \
-        DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type)));   \
-    } else {                                                                                                                                                        \
-        drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type);                                                                                   \
-        if (dataSize > DRFLAC_SIZE_MAX) {                                                                                                                           \
-            goto on_error;  /* The decoded data is too big. */                                                                                                      \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks);    /* <-- Safe cast as per the check above. */           \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData);                                                     \
-    }                                                                                                                                                               \
-                                                                                                                                                                    \
-    if (sampleRateOut) *sampleRateOut = pFlac->sampleRate;                                                                                                          \
-    if (channelsOut) *channelsOut = pFlac->channels;                                                                                                                \
-    if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount;                                                                                         \
-                                                                                                                                                                    \
-    drflac_close(pFlac);                                                                                                                                            \
-    return pSampleData;                                                                                                                                             \
-                                                                                                                                                                    \
-on_error:                                                                                                                                                           \
-    drflac_close(pFlac);                                                                                                                                            \
-    return NULL;                                                                                                                                                    \
-}
-
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
-
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-#endif
-
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-
-
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drflac__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drflac__free_default(p, NULL);
-    }
-}
-
-
-
-
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = commentCount;
-    pIter->pRunningData   = (const char*)pComments;
-}
-
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
-{
-    drflac_int32 length;
-    const char* pComment;
-
-    /* Safety. */
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = 0;
-    }
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return NULL;
-    }
-
-    length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
-    pIter->pRunningData += 4;
-
-    pComment = pIter->pRunningData;
-    pIter->pRunningData += length;
-    pIter->countRemaining -= 1;
-
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = length;
-    }
-
-    return pComment;
-}
-
-
-
-
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
-{
-    if (pIter == NULL) {
-        return;
-    }
-
-    pIter->countRemaining = trackCount;
-    pIter->pRunningData   = (const char*)pTrackData;
-}
-
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
-{
-    drflac_cuesheet_track cuesheetTrack;
-    const char* pRunningData;
-    drflac_uint64 offsetHi;
-    drflac_uint64 offsetLo;
-
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return DRFLAC_FALSE;
-    }
-
-    pRunningData = pIter->pRunningData;
-
-    offsetHi                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    offsetLo                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    cuesheetTrack.offset       = offsetLo | (offsetHi << 32);
-    cuesheetTrack.trackNumber  = pRunningData[0];                                         pRunningData += 1;
-    DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC));     pRunningData += 12;
-    cuesheetTrack.isAudio      = (pRunningData[0] & 0x80) != 0;
-    cuesheetTrack.preEmphasis  = (pRunningData[0] & 0x40) != 0;                           pRunningData += 14;
-    cuesheetTrack.indexCount   = pRunningData[0];                                         pRunningData += 1;
-    cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData;        pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
-
-    pIter->pRunningData = pRunningData;
-    pIter->countRemaining -= 1;
-
-    if (pCuesheetTrack) {
-        *pCuesheetTrack = cuesheetTrack;
-    }
-
-    return DRFLAC_TRUE;
-}
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-#endif  /* dr_flac_c */
-#endif  /* DR_FLAC_IMPLEMENTATION */
-
-
-/*
-REVISION HISTORY
-================
-v0.12.29 - 2021-04-02
-  - Fix a bug where the running PCM frame index is set to an invalid value when over-seeking.
-  - Fix a decoding error due to an incorrect validation check.
-
-v0.12.28 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-
-v0.12.27 - 2021-01-31
-  - Fix a static analysis warning.
-
-v0.12.26 - 2021-01-17
-  - Fix a compilation warning due to _BSD_SOURCE being deprecated.
-
-v0.12.25 - 2020-12-26
-  - Update documentation.
-
-v0.12.24 - 2020-11-29
-  - Fix ARM64/NEON detection when compiling with MSVC.
-
-v0.12.23 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.12.22 - 2020-11-01
-  - Fix an error with the previous release.
-
-v0.12.21 - 2020-11-01
-  - Fix a possible deadlock when seeking.
-  - Improve compiler support for older versions of GCC.
-
-v0.12.20 - 2020-09-08
-  - Fix a compilation error on older compilers.
-
-v0.12.19 - 2020-08-30
-  - Fix a bug due to an undefined 32-bit shift.
-
-v0.12.18 - 2020-08-14
-  - Fix a crash when compiling with clang-cl.
-
-v0.12.17 - 2020-08-02
-  - Simplify sized types.
-
-v0.12.16 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.12.15 - 2020-07-06
-  - Check for negative LPC shifts and return an error.
-
-v0.12.14 - 2020-06-23
-  - Add include guard for the implementation section.
-
-v0.12.13 - 2020-05-16
-  - Add compile-time and run-time version querying.
-    - DRFLAC_VERSION_MINOR
-    - DRFLAC_VERSION_MAJOR
-    - DRFLAC_VERSION_REVISION
-    - DRFLAC_VERSION_STRING
-    - drflac_version()
-    - drflac_version_string()
-
-v0.12.12 - 2020-04-30
-  - Fix compilation errors with VC6.
-
-v0.12.11 - 2020-04-19
-  - Fix some pedantic warnings.
-  - Fix some undefined behaviour warnings.
-
-v0.12.10 - 2020-04-10
-  - Fix some bugs when trying to seek with an invalid seek table.
-
-v0.12.9 - 2020-04-05
-  - Fix warnings.
-
-v0.12.8 - 2020-04-04
-  - Add drflac_open_file_w() and drflac_open_file_with_metadata_w().
-  - Fix some static analysis warnings.
-  - Minor documentation updates.
-
-v0.12.7 - 2020-03-14
-  - Fix compilation errors with VC6.
-
-v0.12.6 - 2020-03-07
-  - Fix compilation error with Visual Studio .NET 2003.
-
-v0.12.5 - 2020-01-30
-  - Silence some static analysis warnings.
-
-v0.12.4 - 2020-01-29
-  - Silence some static analysis warnings.
-
-v0.12.3 - 2019-12-02
-  - Fix some warnings when compiling with GCC and the -Og flag.
-  - Fix a crash in out-of-memory situations.
-  - Fix potential integer overflow bug.
-  - Fix some static analysis warnings.
-  - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
-  - Fix a bug with binary search seeking where the bits per sample is not a multiple of 8.
-
-v0.12.2 - 2019-10-07
-  - Internal code clean up.
-
-v0.12.1 - 2019-09-29
-  - Fix some Clang Static Analyzer warnings.
-  - Fix an unused variable warning.
-
-v0.12.0 - 2019-09-23
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drflac_open()
-    - drflac_open_relaxed()
-    - drflac_open_with_metadata()
-    - drflac_open_with_metadata_relaxed()
-    - drflac_open_file()
-    - drflac_open_file_with_metadata()
-    - drflac_open_memory()
-    - drflac_open_memory_with_metadata()
-    - drflac_open_and_read_pcm_frames_s32()
-    - drflac_open_and_read_pcm_frames_s16()
-    - drflac_open_and_read_pcm_frames_f32()
-    - drflac_open_file_and_read_pcm_frames_s32()
-    - drflac_open_file_and_read_pcm_frames_s16()
-    - drflac_open_file_and_read_pcm_frames_f32()
-    - drflac_open_memory_and_read_pcm_frames_s32()
-    - drflac_open_memory_and_read_pcm_frames_s16()
-    - drflac_open_memory_and_read_pcm_frames_f32()
-    Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
-    DRFLAC_MALLOC, DRFLAC_REALLOC and DRFLAC_FREE.
-  - Remove deprecated APIs:
-    - drflac_read_s32()
-    - drflac_read_s16()
-    - drflac_read_f32()
-    - drflac_seek_to_sample()
-    - drflac_open_and_decode_s32()
-    - drflac_open_and_decode_s16()
-    - drflac_open_and_decode_f32()
-    - drflac_open_and_decode_file_s32()
-    - drflac_open_and_decode_file_s16()
-    - drflac_open_and_decode_file_f32()
-    - drflac_open_and_decode_memory_s32()
-    - drflac_open_and_decode_memory_s16()
-    - drflac_open_and_decode_memory_f32()
-  - Remove drflac.totalSampleCount which is now replaced with drflac.totalPCMFrameCount. You can emulate drflac.totalSampleCount
-    by doing pFlac->totalPCMFrameCount*pFlac->channels.
-  - Rename drflac.currentFrame to drflac.currentFLACFrame to remove ambiguity with PCM frames.
-  - Fix errors when seeking to the end of a stream.
-  - Optimizations to seeking.
-  - SSE improvements and optimizations.
-  - ARM NEON optimizations.
-  - Optimizations to drflac_read_pcm_frames_s16().
-  - Optimizations to drflac_read_pcm_frames_s32().
-
-v0.11.10 - 2019-06-26
-  - Fix a compiler error.
-
-v0.11.9 - 2019-06-16
-  - Silence some ThreadSanitizer warnings.
-
-v0.11.8 - 2019-05-21
-  - Fix warnings.
-
-v0.11.7 - 2019-05-06
-  - C89 fixes.
-
-v0.11.6 - 2019-05-05
-  - Add support for C89.
-  - Fix a compiler warning when CRC is disabled.
-  - Change license to choice of public domain or MIT-0.
-
-v0.11.5 - 2019-04-19
-  - Fix a compiler error with GCC.
-
-v0.11.4 - 2019-04-17
-  - Fix some warnings with GCC when compiling with -std=c99.
-
-v0.11.3 - 2019-04-07
-  - Silence warnings with GCC.
-
-v0.11.2 - 2019-03-10
-  - Fix a warning.
-
-v0.11.1 - 2019-02-17
-  - Fix a potential bug with seeking.
-
-v0.11.0 - 2018-12-16
-  - API CHANGE: Deprecated drflac_read_s32(), drflac_read_s16() and drflac_read_f32() and replaced them with
-    drflac_read_pcm_frames_s32(), drflac_read_pcm_frames_s16() and drflac_read_pcm_frames_f32(). The new APIs take
-    and return PCM frame counts instead of sample counts. To upgrade you will need to change the input count by
-    dividing it by the channel count, and then do the same with the return value.
-  - API_CHANGE: Deprecated drflac_seek_to_sample() and replaced with drflac_seek_to_pcm_frame(). Same rules as
-    the changes to drflac_read_*() apply.
-  - API CHANGE: Deprecated drflac_open_and_decode_*() and replaced with drflac_open_*_and_read_*(). Same rules as
-    the changes to drflac_read_*() apply.
-  - Optimizations.
-
-v0.10.0 - 2018-09-11
-  - Remove the DR_FLAC_NO_WIN32_IO option and the Win32 file IO functionality. If you need to use Win32 file IO you
-    need to do it yourself via the callback API.
-  - Fix the clang build.
-  - Fix undefined behavior.
-  - Fix errors with CUESHEET metdata blocks.
-  - Add an API for iterating over each cuesheet track in the CUESHEET metadata block. This works the same way as the
-    Vorbis comment API.
-  - Other miscellaneous bug fixes, mostly relating to invalid FLAC streams.
-  - Minor optimizations.
-
-v0.9.11 - 2018-08-29
-  - Fix a bug with sample reconstruction.
-
-v0.9.10 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.9.9 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-
-v0.9.8 - 2018-07-24
-  - Fix compilation errors.
-
-v0.9.7 - 2018-07-05
-  - Fix a warning.
-
-v0.9.6 - 2018-06-29
-  - Fix some typos.
-
-v0.9.5 - 2018-06-23
-  - Fix some warnings.
-
-v0.9.4 - 2018-06-14
-  - Optimizations to seeking.
-  - Clean up.
-
-v0.9.3 - 2018-05-22
-  - Bug fix.
-
-v0.9.2 - 2018-05-12
-  - Fix a compilation error due to a missing break statement.
-
-v0.9.1 - 2018-04-29
-  - Fix compilation error with Clang.
-
-v0.9 - 2018-04-24
-  - Fix Clang build.
-  - Start using major.minor.revision versioning.
-
-v0.8g - 2018-04-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8f - 2018-02-02
-  - Stop pretending to support changing rate/channels mid stream.
-
-v0.8e - 2018-02-01
-  - Fix a crash when the block size of a frame is larger than the maximum block size defined by the FLAC stream.
-  - Fix a crash the the Rice partition order is invalid.
-
-v0.8d - 2017-09-22
-  - Add support for decoding streams with ID3 tags. ID3 tags are just skipped.
-
-v0.8c - 2017-09-07
-  - Fix warning on non-x86/x64 architectures.
-
-v0.8b - 2017-08-19
-  - Fix build on non-x86/x64 architectures.
-
-v0.8a - 2017-08-13
-  - A small optimization for the Clang build.
-
-v0.8 - 2017-08-12
-  - API CHANGE: Rename dr_* types to drflac_*.
-  - Optimizations. This brings dr_flac back to about the same class of efficiency as the reference implementation.
-  - Add support for custom implementations of malloc(), realloc(), etc.
-  - Add CRC checking to Ogg encapsulated streams.
-  - Fix VC++ 6 build. This is only for the C++ compiler. The C compiler is not currently supported.
-  - Bug fixes.
-
-v0.7 - 2017-07-23
-  - Add support for opening a stream without a header block. To do this, use drflac_open_relaxed() / drflac_open_with_metadata_relaxed().
-
-v0.6 - 2017-07-22
-  - Add support for recovering from invalid frames. With this change, dr_flac will simply skip over invalid frames as if they
-    never existed. Frames are checked against their sync code, the CRC-8 of the frame header and the CRC-16 of the whole frame.
-
-v0.5 - 2017-07-16
-  - Fix typos.
-  - Change drflac_bool* types to unsigned.
-  - Add CRC checking. This makes dr_flac slower, but can be disabled with #define DR_FLAC_NO_CRC.
-
-v0.4f - 2017-03-10
-  - Fix a couple of bugs with the bitstreaming code.
-
-v0.4e - 2017-02-17
-  - Fix some warnings.
-
-v0.4d - 2016-12-26
-  - Add support for 32-bit floating-point PCM decoding.
-  - Use drflac_int* and drflac_uint* sized types to improve compiler support.
-  - Minor improvements to documentation.
-
-v0.4c - 2016-12-26
-  - Add support for signed 16-bit integer PCM decoding.
-
-v0.4b - 2016-10-23
-  - A minor change to drflac_bool8 and drflac_bool32 types.
-
-v0.4a - 2016-10-11
-  - Rename drBool32 to drflac_bool32 for styling consistency.
-
-v0.4 - 2016-09-29
-  - API/ABI CHANGE: Use fixed size 32-bit booleans instead of the built-in bool type.
-  - API CHANGE: Rename drflac_open_and_decode*() to drflac_open_and_decode*_s32().
-  - API CHANGE: Swap the order of "channels" and "sampleRate" parameters in drflac_open_and_decode*(). Rationale for this is to
-    keep it consistent with drflac_audio.
-
-v0.3f - 2016-09-21
-  - Fix a warning with GCC.
-
-v0.3e - 2016-09-18
-  - Fixed a bug where GCC 4.3+ was not getting properly identified.
-  - Fixed a few typos.
-  - Changed date formats to ISO 8601 (YYYY-MM-DD).
-
-v0.3d - 2016-06-11
-  - Minor clean up.
-
-v0.3c - 2016-05-28
-  - Fixed compilation error.
-
-v0.3b - 2016-05-16
-  - Fixed Linux/GCC build.
-  - Updated documentation.
-
-v0.3a - 2016-05-15
-  - Minor fixes to documentation.
-
-v0.3 - 2016-05-11
-  - Optimizations. Now at about parity with the reference implementation on 32-bit builds.
-  - Lots of clean up.
-
-v0.2b - 2016-05-10
-  - Bug fixes.
-
-v0.2a - 2016-05-10
-  - Made drflac_open_and_decode() more robust.
-  - Removed an unused debugging variable
-
-v0.2 - 2016-05-09
-  - Added support for Ogg encapsulation.
-  - API CHANGE. Have the onSeek callback take a third argument which specifies whether or not the seek
-    should be relative to the start or the current position. Also changes the seeking rules such that
-    seeking offsets will never be negative.
-  - Have drflac_open_and_decode() fail gracefully if the stream has an unknown total sample count.
-
-v0.1b - 2016-05-07
-  - Properly close the file handle in drflac_open_file() and family when the decoder fails to initialize.
-  - Removed a stale comment.
-
-v0.1a - 2016-05-05
-  - Minor formatting changes.
-  - Fixed a warning on the GCC build.
-
-v0.1 - 2016-05-03
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib_pi4_test/external/dr_mp3.h b/raylib_pi4_test/external/dr_mp3.h
deleted file mode 100644 (file)
index e28f318..0000000
+++ /dev/null
@@ -1,4750 +0,0 @@
-/*
-MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_mp3 - v0.6.27 - 2021-02-21
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-
-Based on minimp3 (https://github.com/lieff/minimp3) which is where the real work was done. See the bottom of this file for differences between minimp3 and dr_mp3.
-*/
-
-/*
-RELEASE NOTES - VERSION 0.6
-===========================
-Version 0.6 includes breaking changes with the configuration of decoders. The ability to customize the number of output channels and the sample rate has been
-removed. You must now use the channel count and sample rate reported by the MP3 stream itself, and all channel and sample rate conversion must be done
-yourself.
-
-
-Changes to Initialization
--------------------------
-Previously, `drmp3_init()`, etc. took a pointer to a `drmp3_config` object that allowed you to customize the output channels and sample rate. This has been
-removed. If you need the old behaviour you will need to convert the data yourself or just not upgrade. The following APIs have changed.
-
-    `drmp3_init()`
-    `drmp3_init_memory()`
-    `drmp3_init_file()`
-
-
-Miscellaneous Changes
----------------------
-Support for loading a file from a `wchar_t` string has been added via the `drmp3_init_file_w()` API.
-*/
-
-/*
-Introducation
-=============
-dr_mp3 is a single file library. To use it, do something like the following in one .c file.
-
-    ```c
-    #define DR_MP3_IMPLEMENTATION
-    #include "dr_mp3.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. To decode audio data, do something like the following:
-
-    ```c
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, "MySong.mp3", NULL)) {
-        // Failed to open file
-    }
-
-    ...
-
-    drmp3_uint64 framesRead = drmp3_read_pcm_frames_f32(pMP3, framesToRead, pFrames);
-    ```
-
-The drmp3 object is transparent so you can get access to the channel count and sample rate like so:
-
-    ```
-    drmp3_uint32 channels = mp3.channels;
-    drmp3_uint32 sampleRate = mp3.sampleRate;
-    ```
-
-The example above initializes a decoder from a file, but you can also initialize it from a block of memory and read and seek callbacks with
-`drmp3_init_memory()` and `drmp3_init()` respectively.
-
-You do not need to do any annoying memory management when reading PCM frames - this is all managed internally. You can request any number of PCM frames in each
-call to `drmp3_read_pcm_frames_f32()` and it will return as many PCM frames as it can, up to the requested amount.
-
-You can also decode an entire file in one go with `drmp3_open_and_read_pcm_frames_f32()`, `drmp3_open_memory_and_read_pcm_frames_f32()` and
-`drmp3_open_file_and_read_pcm_frames_f32()`.
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_MP3_NO_STDIO
-  Disable drmp3_init_file(), etc.
-
-#define DR_MP3_NO_SIMD
-  Disable SIMD optimizations.
-*/
-
-#ifndef dr_mp3_h
-#define dr_mp3_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRMP3_STRINGIFY(x)      #x
-#define DRMP3_XSTRINGIFY(x)     DRMP3_STRINGIFY(x)
-
-#define DRMP3_VERSION_MAJOR     0
-#define DRMP3_VERSION_MINOR     6
-#define DRMP3_VERSION_REVISION  27
-#define DRMP3_VERSION_STRING    DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drmp3_int8;
-typedef unsigned char           drmp3_uint8;
-typedef   signed short          drmp3_int16;
-typedef unsigned short          drmp3_uint16;
-typedef   signed int            drmp3_int32;
-typedef unsigned int            drmp3_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drmp3_int64;
-    typedef unsigned __int64    drmp3_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drmp3_int64;
-    typedef unsigned long long  drmp3_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drmp3_uint64        drmp3_uintptr;
-#else
-    typedef drmp3_uint32        drmp3_uintptr;
-#endif
-typedef drmp3_uint8             drmp3_bool8;
-typedef drmp3_uint32            drmp3_bool32;
-#define DRMP3_TRUE              1
-#define DRMP3_FALSE             0
-
-#if !defined(DRMP3_API)
-    #if defined(DRMP3_DLL)
-        #if defined(_WIN32)
-            #define DRMP3_DLL_IMPORT  __declspec(dllimport)
-            #define DRMP3_DLL_EXPORT  __declspec(dllexport)
-            #define DRMP3_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRMP3_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRMP3_DLL_IMPORT
-                #define DRMP3_DLL_EXPORT
-                #define DRMP3_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-            #define DRMP3_API  DRMP3_DLL_EXPORT
-        #else
-            #define DRMP3_API  DRMP3_DLL_IMPORT
-        #endif
-        #define DRMP3_PRIVATE DRMP3_DLL_PRIVATE
-    #else
-        #define DRMP3_API extern
-        #define DRMP3_PRIVATE static
-    #endif
-#endif
-
-typedef drmp3_int32 drmp3_result;
-#define DRMP3_SUCCESS                        0
-#define DRMP3_ERROR                         -1   /* A generic error. */
-#define DRMP3_INVALID_ARGS                  -2
-#define DRMP3_INVALID_OPERATION             -3
-#define DRMP3_OUT_OF_MEMORY                 -4
-#define DRMP3_OUT_OF_RANGE                  -5
-#define DRMP3_ACCESS_DENIED                 -6
-#define DRMP3_DOES_NOT_EXIST                -7
-#define DRMP3_ALREADY_EXISTS                -8
-#define DRMP3_TOO_MANY_OPEN_FILES           -9
-#define DRMP3_INVALID_FILE                  -10
-#define DRMP3_TOO_BIG                       -11
-#define DRMP3_PATH_TOO_LONG                 -12
-#define DRMP3_NAME_TOO_LONG                 -13
-#define DRMP3_NOT_DIRECTORY                 -14
-#define DRMP3_IS_DIRECTORY                  -15
-#define DRMP3_DIRECTORY_NOT_EMPTY           -16
-#define DRMP3_END_OF_FILE                   -17
-#define DRMP3_NO_SPACE                      -18
-#define DRMP3_BUSY                          -19
-#define DRMP3_IO_ERROR                      -20
-#define DRMP3_INTERRUPT                     -21
-#define DRMP3_UNAVAILABLE                   -22
-#define DRMP3_ALREADY_IN_USE                -23
-#define DRMP3_BAD_ADDRESS                   -24
-#define DRMP3_BAD_SEEK                      -25
-#define DRMP3_BAD_PIPE                      -26
-#define DRMP3_DEADLOCK                      -27
-#define DRMP3_TOO_MANY_LINKS                -28
-#define DRMP3_NOT_IMPLEMENTED               -29
-#define DRMP3_NO_MESSAGE                    -30
-#define DRMP3_BAD_MESSAGE                   -31
-#define DRMP3_NO_DATA_AVAILABLE             -32
-#define DRMP3_INVALID_DATA                  -33
-#define DRMP3_TIMEOUT                       -34
-#define DRMP3_NO_NETWORK                    -35
-#define DRMP3_NOT_UNIQUE                    -36
-#define DRMP3_NOT_SOCKET                    -37
-#define DRMP3_NO_ADDRESS                    -38
-#define DRMP3_BAD_PROTOCOL                  -39
-#define DRMP3_PROTOCOL_UNAVAILABLE          -40
-#define DRMP3_PROTOCOL_NOT_SUPPORTED        -41
-#define DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRMP3_SOCKET_NOT_SUPPORTED          -44
-#define DRMP3_CONNECTION_RESET              -45
-#define DRMP3_ALREADY_CONNECTED             -46
-#define DRMP3_NOT_CONNECTED                 -47
-#define DRMP3_CONNECTION_REFUSED            -48
-#define DRMP3_NO_HOST                       -49
-#define DRMP3_IN_PROGRESS                   -50
-#define DRMP3_CANCELLED                     -51
-#define DRMP3_MEMORY_ALREADY_MAPPED         -52
-#define DRMP3_AT_END                        -53
-
-
-#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME  1152
-#define DRMP3_MAX_SAMPLES_PER_FRAME         (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
-
-#ifdef _MSC_VER
-    #define DRMP3_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRMP3_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRMP3_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRMP3_INLINE __inline
-#else
-    #define DRMP3_INLINE
-#endif
-
-
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision);
-DRMP3_API const char* drmp3_version_string(void);
-
-
-/*
-Low Level Push API
-==================
-*/
-typedef struct
-{
-    int frame_bytes, channels, hz, layer, bitrate_kbps;
-} drmp3dec_frame_info;
-
-typedef struct
-{
-    float mdct_overlap[2][9*32], qmf_state[15*2*32];
-    int reserv, free_format_bytes;
-    drmp3_uint8 header[4], reserv_buf[511];
-} drmp3dec;
-
-/* Initializes a low level decoder. */
-DRMP3_API void drmp3dec_init(drmp3dec *dec);
-
-/* Reads a frame from a low level decoder. */
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info);
-
-/* Helper for converting between f32 and s16. */
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples);
-
-
-
-/*
-Main API (Pull API)
-===================
-*/
-typedef enum
-{
-    drmp3_seek_origin_start,
-    drmp3_seek_origin_current
-} drmp3_seek_origin;
-
-typedef struct
-{
-    drmp3_uint64 seekPosInBytes;        /* Points to the first byte of an MP3 frame. */
-    drmp3_uint64 pcmFrameIndex;         /* The index of the PCM frame this seek point targets. */
-    drmp3_uint16 mp3FramesToDiscard;    /* The number of whole MP3 frames to be discarded before pcmFramesToDiscard. */
-    drmp3_uint16 pcmFramesToDiscard;    /* The number of leading samples to read and discard. These are discarded after mp3FramesToDiscard. */
-} drmp3_seek_point;
-
-/*
-Callback for when data is read. Return value is the number of bytes actually read.
-
-pUserData   [in]  The user data that was passed to drmp3_init(), drmp3_open() and family.
-pBufferOut  [out] The output buffer.
-bytesToRead [in]  The number of bytes to read.
-
-Returns the number of bytes actually read.
-
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
-either the entire bytesToRead is filled or you have reached the end of the stream.
-*/
-typedef size_t (* drmp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data needs to be seeked.
-
-pUserData [in] The user data that was passed to drmp3_init(), drmp3_open() and family.
-offset    [in] The number of bytes to move, relative to the origin. Will never be negative.
-origin    [in] The origin of the seek - the current position or the start of the stream.
-
-Returns whether or not the seek was successful.
-
-Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which
-will be either drmp3_seek_origin_start or drmp3_seek_origin_current.
-*/
-typedef drmp3_bool32 (* drmp3_seek_proc)(void* pUserData, int offset, drmp3_seek_origin origin);
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drmp3_allocation_callbacks;
-
-typedef struct
-{
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-} drmp3_config;
-
-typedef struct
-{
-    drmp3dec decoder;
-    drmp3dec_frame_info frameInfo;
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-    drmp3_read_proc onRead;
-    drmp3_seek_proc onSeek;
-    void* pUserData;
-    drmp3_allocation_callbacks allocationCallbacks;
-    drmp3_uint32 mp3FrameChannels;      /* The number of channels in the currently loaded MP3 frame. Internal use only. */
-    drmp3_uint32 mp3FrameSampleRate;    /* The sample rate of the currently loaded MP3 frame. Internal use only. */
-    drmp3_uint32 pcmFramesConsumedInMP3Frame;
-    drmp3_uint32 pcmFramesRemainingInMP3Frame;
-    drmp3_uint8 pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];  /* <-- Multipled by sizeof(float) to ensure there's enough room for DR_MP3_FLOAT_OUTPUT. */
-    drmp3_uint64 currentPCMFrame;       /* The current PCM frame, globally, based on the output sample rate. Mainly used for seeking. */
-    drmp3_uint64 streamCursor;          /* The current byte the decoder is sitting on in the raw stream. */
-    drmp3_seek_point* pSeekPoints;      /* NULL by default. Set with drmp3_bind_seek_table(). Memory is owned by the client. dr_mp3 will never attempt to free this pointer. */
-    drmp3_uint32 seekPointCount;        /* The number of items in pSeekPoints. When set to 0 assumes to no seek table. Defaults to zero. */
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t dataConsumed;
-    drmp3_uint8* pData;
-    drmp3_bool32 atEnd : 1;
-    struct
-    {
-        const drmp3_uint8* pData;
-        size_t dataSize;
-        size_t currentReadPos;
-    } memory;   /* Only used for decoders that were opened against a block of memory. */
-} drmp3;
-
-/*
-Initializes an MP3 decoder.
-
-onRead    [in]           The function to call when data needs to be read from the client.
-onSeek    [in]           The function to call when the read position of the client data needs to move.
-pUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
-
-Returns true if successful; false otherwise.
-
-Close the loader with drmp3_uninit().
-
-See also: drmp3_init_file(), drmp3_init_memory(), drmp3_uninit()
-*/
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Initializes an MP3 decoder from a block of memory.
-
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
-the lifetime of the drmp3 object.
-
-The buffer should contain the contents of the entire MP3 file.
-*/
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_MP3_NO_STDIO
-/*
-Initializes an MP3 decoder from a file.
-
-This holds the internal FILE object until drmp3_uninit() is called. Keep this in mind if you're caching drmp3
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Uninitializes an MP3 decoder.
-*/
-DRMP3_API void drmp3_uninit(drmp3* pMP3);
-
-/*
-Reads PCM frames as interleaved 32-bit IEEE floating point PCM.
-
-Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
-*/
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut);
-
-/*
-Reads PCM frames as interleaved signed 16-bit integer PCM.
-
-Note that framesToRead specifies the number of PCM frames to read, _not_ the number of MP3 frames.
-*/
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut);
-
-/*
-Seeks to a specific frame.
-
-Note that this is _not_ an MP3 frame, but rather a PCM frame.
-*/
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex);
-
-/*
-Calculates the total number of PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-*/
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3);
-
-/*
-Calculates the total number of MP3 frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-*/
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3);
-
-/*
-Calculates the total number of MP3 and PCM frames in the MP3 stream. Cannot be used for infinite streams such as internet
-radio. Runs in linear time. Returns 0 on error.
-
-This is equivalent to calling drmp3_get_mp3_frame_count() and drmp3_get_pcm_frame_count() except that it's more efficient.
-*/
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount);
-
-/*
-Calculates the seekpoints based on PCM frames. This is slow.
-
-pSeekpoint count is a pointer to a uint32 containing the seekpoint count. On input it contains the desired count.
-On output it contains the actual count. The reason for this design is that the client may request too many
-seekpoints, in which case dr_mp3 will return a corrected count.
-
-Note that seektable seeking is not quite sample exact when the MP3 stream contains inconsistent sample rates.
-*/
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints);
-
-/*
-Binds a seek table to the decoder.
-
-This does _not_ make a copy of pSeekPoints - it only references it. It is up to the application to ensure this
-remains valid while it is bound to the decoder.
-
-Use drmp3_calculate_seek_points() to calculate the seek points.
-*/
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints);
-
-
-/*
-Opens an decodes an entire MP3 stream as a single operation.
-
-On output pConfig will receive the channel count and sample rate of the stream.
-
-Free the returned pointer with drmp3_free().
-*/
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/*
-Allocates a block of memory on the heap.
-*/
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Frees any memory that was allocated by a public drmp3 API.
-*/
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks);
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_mp3_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-#ifndef dr_mp3_c
-#define dr_mp3_c
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h> /* For INT_MAX */
-
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRMP3_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRMP3_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRMP3_VERSION_REVISION;
-    }
-}
-
-DRMP3_API const char* drmp3_version_string(void)
-{
-    return DRMP3_VERSION_STRING;
-}
-
-/* Disable SIMD when compiling with TCC for now. */
-#if defined(__TINYC__)
-#define DR_MP3_NO_SIMD
-#endif
-
-#define DRMP3_OFFSET_PTR(p, offset) ((void*)((drmp3_uint8*)(p) + (offset)))
-
-#define DRMP3_MAX_FREE_FORMAT_FRAME_SIZE  2304    /* more than ISO spec's */
-#ifndef DRMP3_MAX_FRAME_SYNC_MATCHES
-#define DRMP3_MAX_FRAME_SYNC_MATCHES      10
-#endif
-
-#define DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES  DRMP3_MAX_FREE_FORMAT_FRAME_SIZE /* MUST be >= 320000/8/32000*1152 = 1440 */
-
-#define DRMP3_MAX_BITRESERVOIR_BYTES      511
-#define DRMP3_SHORT_BLOCK_TYPE            2
-#define DRMP3_STOP_BLOCK_TYPE             3
-#define DRMP3_MODE_MONO                   3
-#define DRMP3_MODE_JOINT_STEREO           1
-#define DRMP3_HDR_SIZE                    4
-#define DRMP3_HDR_IS_MONO(h)              (((h[3]) & 0xC0) == 0xC0)
-#define DRMP3_HDR_IS_MS_STEREO(h)         (((h[3]) & 0xE0) == 0x60)
-#define DRMP3_HDR_IS_FREE_FORMAT(h)       (((h[2]) & 0xF0) == 0)
-#define DRMP3_HDR_IS_CRC(h)               (!((h[1]) & 1))
-#define DRMP3_HDR_TEST_PADDING(h)         ((h[2]) & 0x2)
-#define DRMP3_HDR_TEST_MPEG1(h)           ((h[1]) & 0x8)
-#define DRMP3_HDR_TEST_NOT_MPEG25(h)      ((h[1]) & 0x10)
-#define DRMP3_HDR_TEST_I_STEREO(h)        ((h[3]) & 0x10)
-#define DRMP3_HDR_TEST_MS_STEREO(h)       ((h[3]) & 0x20)
-#define DRMP3_HDR_GET_STEREO_MODE(h)      (((h[3]) >> 6) & 3)
-#define DRMP3_HDR_GET_STEREO_MODE_EXT(h)  (((h[3]) >> 4) & 3)
-#define DRMP3_HDR_GET_LAYER(h)            (((h[1]) >> 1) & 3)
-#define DRMP3_HDR_GET_BITRATE(h)          ((h[2]) >> 4)
-#define DRMP3_HDR_GET_SAMPLE_RATE(h)      (((h[2]) >> 2) & 3)
-#define DRMP3_HDR_GET_MY_SAMPLE_RATE(h)   (DRMP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3)
-#define DRMP3_HDR_IS_FRAME_576(h)         ((h[1] & 14) == 2)
-#define DRMP3_HDR_IS_LAYER_1(h)           ((h[1] & 6) == 6)
-
-#define DRMP3_BITS_DEQUANTIZER_OUT        -1
-#define DRMP3_MAX_SCF                     (255 + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210)
-#define DRMP3_MAX_SCFI                    ((DRMP3_MAX_SCF + 3) & ~3)
-
-#define DRMP3_MIN(a, b)           ((a) > (b) ? (b) : (a))
-#define DRMP3_MAX(a, b)           ((a) < (b) ? (b) : (a))
-
-#if !defined(DR_MP3_NO_SIMD)
-
-#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
-/* x64 always have SSE2, arm64 always have neon, no need for generic code */
-#define DR_MP3_ONLY_SIMD
-#endif
-
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
-#if defined(_MSC_VER)
-#include <intrin.h>
-#endif
-#include <emmintrin.h>
-#define DRMP3_HAVE_SSE 1
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE _mm_storeu_ps
-#define DRMP3_VLD _mm_loadu_ps
-#define DRMP3_VSET _mm_set1_ps
-#define DRMP3_VADD _mm_add_ps
-#define DRMP3_VSUB _mm_sub_ps
-#define DRMP3_VMUL _mm_mul_ps
-#define DRMP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMUL_S(x, s)  _mm_mul_ps(x, _mm_set1_ps(s))
-#define DRMP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3))
-typedef __m128 drmp3_f4;
-#if defined(_MSC_VER) || defined(DR_MP3_ONLY_SIMD)
-#define drmp3_cpuid __cpuid
-#else
-static __inline__ __attribute__((always_inline)) void drmp3_cpuid(int CPUInfo[], const int InfoType)
-{
-#if defined(__PIC__)
-    __asm__ __volatile__(
-#if defined(__x86_64__)
-        "push %%rbx\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-        "pop  %%rbx\n"
-#else
-        "xchgl %%ebx, %1\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-#endif
-        : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#else
-    __asm__ __volatile__(
-        "cpuid"
-        : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#endif
-}
-#endif
-static int drmp3_have_simd(void)
-{
-#ifdef DR_MP3_ONLY_SIMD
-    return 1;
-#else
-    static int g_have_simd;
-    int CPUInfo[4];
-#ifdef MINIMP3_TEST
-    static int g_counter;
-    if (g_counter++ > 100)
-        return 0;
-#endif
-    if (g_have_simd)
-        goto end;
-    drmp3_cpuid(CPUInfo, 0);
-    if (CPUInfo[0] > 0)
-    {
-        drmp3_cpuid(CPUInfo, 1);
-        g_have_simd = (CPUInfo[3] & (1 << 26)) + 1; /* SSE2 */
-        return g_have_simd - 1;
-    }
-
-end:
-    return g_have_simd - 1;
-#endif
-}
-#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
-#include <arm_neon.h>
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE vst1q_f32
-#define DRMP3_VLD vld1q_f32
-#define DRMP3_VSET vmovq_n_f32
-#define DRMP3_VADD vaddq_f32
-#define DRMP3_VSUB vsubq_f32
-#define DRMP3_VMUL vmulq_f32
-#define DRMP3_VMAC(a, x, y) vmlaq_f32(a, x, y)
-#define DRMP3_VMSB(a, x, y) vmlsq_f32(a, x, y)
-#define DRMP3_VMUL_S(x, s)  vmulq_f32(x, vmovq_n_f32(s))
-#define DRMP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x)))
-typedef float32x4_t drmp3_f4;
-static int drmp3_have_simd(void)
-{   /* TODO: detect neon for !DR_MP3_ONLY_SIMD */
-    return 1;
-}
-#else
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 0
-#ifdef DR_MP3_ONLY_SIMD
-#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
-#endif
-#endif
-
-#else
-
-#define DRMP3_HAVE_SIMD 0
-
-#endif
-
-#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64)
-#define DRMP3_HAVE_ARMV6 1
-static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_arm(int32_t a)
-{
-    drmp3_int32 x = 0;
-    __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
-    return x;
-}
-#else
-#define DRMP3_HAVE_ARMV6 0
-#endif
-
-
-typedef struct
-{
-    const drmp3_uint8 *buf;
-    int pos, limit;
-} drmp3_bs;
-
-typedef struct
-{
-    float scf[3*64];
-    drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64];
-} drmp3_L12_scale_info;
-
-typedef struct
-{
-    drmp3_uint8 tab_offset, code_tab_width, band_count;
-} drmp3_L12_subband_alloc;
-
-typedef struct
-{
-    const drmp3_uint8 *sfbtab;
-    drmp3_uint16 part_23_length, big_values, scalefac_compress;
-    drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb;
-    drmp3_uint8 table_select[3], region_count[3], subblock_gain[3];
-    drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi;
-} drmp3_L3_gr_info;
-
-typedef struct
-{
-    drmp3_bs bs;
-    drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES];
-    drmp3_L3_gr_info gr_info[4];
-    float grbuf[2][576], scf[40], syn[18 + 15][2*32];
-    drmp3_uint8 ist_pos[2][39];
-} drmp3dec_scratch;
-
-static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes)
-{
-    bs->buf   = data;
-    bs->pos   = 0;
-    bs->limit = bytes*8;
-}
-
-static drmp3_uint32 drmp3_bs_get_bits(drmp3_bs *bs, int n)
-{
-    drmp3_uint32 next, cache = 0, s = bs->pos & 7;
-    int shl = n + s;
-    const drmp3_uint8 *p = bs->buf + (bs->pos >> 3);
-    if ((bs->pos += n) > bs->limit)
-        return 0;
-    next = *p++ & (255 >> s);
-    while ((shl -= 8) > 0)
-    {
-        cache |= next << shl;
-        next = *p++;
-    }
-    return cache | (next >> -shl);
-}
-
-static int drmp3_hdr_valid(const drmp3_uint8 *h)
-{
-    return h[0] == 0xff &&
-        ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) &&
-        (DRMP3_HDR_GET_LAYER(h) != 0) &&
-        (DRMP3_HDR_GET_BITRATE(h) != 15) &&
-        (DRMP3_HDR_GET_SAMPLE_RATE(h) != 3);
-}
-
-static int drmp3_hdr_compare(const drmp3_uint8 *h1, const drmp3_uint8 *h2)
-{
-    return drmp3_hdr_valid(h2) &&
-        ((h1[1] ^ h2[1]) & 0xFE) == 0 &&
-        ((h1[2] ^ h2[2]) & 0x0C) == 0 &&
-        !(DRMP3_HDR_IS_FREE_FORMAT(h1) ^ DRMP3_HDR_IS_FREE_FORMAT(h2));
-}
-
-static unsigned drmp3_hdr_bitrate_kbps(const drmp3_uint8 *h)
-{
-    static const drmp3_uint8 halfrate[2][3][15] = {
-        { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } },
-        { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } },
-    };
-    return 2*halfrate[!!DRMP3_HDR_TEST_MPEG1(h)][DRMP3_HDR_GET_LAYER(h) - 1][DRMP3_HDR_GET_BITRATE(h)];
-}
-
-static unsigned drmp3_hdr_sample_rate_hz(const drmp3_uint8 *h)
-{
-    static const unsigned g_hz[3] = { 44100, 48000, 32000 };
-    return g_hz[DRMP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!DRMP3_HDR_TEST_MPEG1(h) >> (int)!DRMP3_HDR_TEST_NOT_MPEG25(h);
-}
-
-static unsigned drmp3_hdr_frame_samples(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)DRMP3_HDR_IS_FRAME_576(h));
-}
-
-static int drmp3_hdr_frame_bytes(const drmp3_uint8 *h, int free_format_size)
-{
-    int frame_bytes = drmp3_hdr_frame_samples(h)*drmp3_hdr_bitrate_kbps(h)*125/drmp3_hdr_sample_rate_hz(h);
-    if (DRMP3_HDR_IS_LAYER_1(h))
-    {
-        frame_bytes &= ~3; /* slot align */
-    }
-    return frame_bytes ? frame_bytes : free_format_size;
-}
-
-static int drmp3_hdr_padding(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_TEST_PADDING(h) ? (DRMP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0;
-}
-
-#ifndef DR_MP3_ONLY_MP3
-static const drmp3_L12_subband_alloc *drmp3_L12_subband_alloc_table(const drmp3_uint8 *hdr, drmp3_L12_scale_info *sci)
-{
-    const drmp3_L12_subband_alloc *alloc;
-    int mode = DRMP3_HDR_GET_STEREO_MODE(hdr);
-    int nbands, stereo_bands = (mode == DRMP3_MODE_MONO) ? 0 : (mode == DRMP3_MODE_JOINT_STEREO) ? (DRMP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32;
-
-    if (DRMP3_HDR_IS_LAYER_1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } };
-        alloc = g_alloc_L1;
-        nbands = 32;
-    } else if (!DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } };
-        alloc = g_alloc_L2M2;
-        nbands = 30;
-    } else
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } };
-        int sample_rate_idx = DRMP3_HDR_GET_SAMPLE_RATE(hdr);
-        unsigned kbps = drmp3_hdr_bitrate_kbps(hdr) >> (int)(mode != DRMP3_MODE_MONO);
-        if (!kbps) /* free-format */
-        {
-            kbps = 192;
-        }
-
-        alloc = g_alloc_L2M1;
-        nbands = 27;
-        if (kbps < 56)
-        {
-            static const drmp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } };
-            alloc = g_alloc_L2M1_lowrate;
-            nbands = sample_rate_idx == 2 ? 12 : 8;
-        } else if (kbps >= 96 && sample_rate_idx != 1)
-        {
-            nbands = 30;
-        }
-    }
-
-    sci->total_bands = (drmp3_uint8)nbands;
-    sci->stereo_bands = (drmp3_uint8)DRMP3_MIN(stereo_bands, nbands);
-
-    return alloc;
-}
-
-static void drmp3_L12_read_scalefactors(drmp3_bs *bs, drmp3_uint8 *pba, drmp3_uint8 *scfcod, int bands, float *scf)
-{
-    static const float g_deq_L12[18*3] = {
-#define DRMP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x
-        DRMP3_DQ(3),DRMP3_DQ(7),DRMP3_DQ(15),DRMP3_DQ(31),DRMP3_DQ(63),DRMP3_DQ(127),DRMP3_DQ(255),DRMP3_DQ(511),DRMP3_DQ(1023),DRMP3_DQ(2047),DRMP3_DQ(4095),DRMP3_DQ(8191),DRMP3_DQ(16383),DRMP3_DQ(32767),DRMP3_DQ(65535),DRMP3_DQ(3),DRMP3_DQ(5),DRMP3_DQ(9)
-    };
-    int i, m;
-    for (i = 0; i < bands; i++)
-    {
-        float s = 0;
-        int ba = *pba++;
-        int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0;
-        for (m = 4; m; m >>= 1)
-        {
-            if (mask & m)
-            {
-                int b = drmp3_bs_get_bits(bs, 6);
-                s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3);
-            }
-            *scf++ = s;
-        }
-    }
-}
-
-static void drmp3_L12_read_scale_info(const drmp3_uint8 *hdr, drmp3_bs *bs, drmp3_L12_scale_info *sci)
-{
-    static const drmp3_uint8 g_bitalloc_code_tab[] = {
-        0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16,
-        0,17,18, 3,19,4,5,16,
-        0,17,18,16,
-        0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14,
-        0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16
-    };
-    const drmp3_L12_subband_alloc *subband_alloc = drmp3_L12_subband_alloc_table(hdr, sci);
-
-    int i, k = 0, ba_bits = 0;
-    const drmp3_uint8 *ba_code_tab = g_bitalloc_code_tab;
-
-    for (i = 0; i < sci->total_bands; i++)
-    {
-        drmp3_uint8 ba;
-        if (i == k)
-        {
-            k += subband_alloc->band_count;
-            ba_bits = subband_alloc->code_tab_width;
-            ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset;
-            subband_alloc++;
-        }
-        ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        sci->bitalloc[2*i] = ba;
-        if (i < sci->stereo_bands)
-        {
-            ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        }
-        sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0;
-    }
-
-    for (i = 0; i < 2*sci->total_bands; i++)
-    {
-        sci->scfcod[i] = (drmp3_uint8)(sci->bitalloc[i] ? DRMP3_HDR_IS_LAYER_1(hdr) ? 2 : drmp3_bs_get_bits(bs, 2) : 6);
-    }
-
-    drmp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf);
-
-    for (i = sci->stereo_bands; i < sci->total_bands; i++)
-    {
-        sci->bitalloc[2*i + 1] = 0;
-    }
-}
-
-static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_scale_info *sci, int group_size)
-{
-    int i, j, k, choff = 576;
-    for (j = 0; j < 4; j++)
-    {
-        float *dst = grbuf + group_size*j;
-        for (i = 0; i < 2*sci->total_bands; i++)
-        {
-            int ba = sci->bitalloc[i];
-            if (ba != 0)
-            {
-                if (ba < 17)
-                {
-                    int half = (1 << (ba - 1)) - 1;
-                    for (k = 0; k < group_size; k++)
-                    {
-                        dst[k] = (float)((int)drmp3_bs_get_bits(bs, ba) - half);
-                    }
-                } else
-                {
-                    unsigned mod = (2 << (ba - 17)) + 1;    /* 3, 5, 9 */
-                    unsigned code = drmp3_bs_get_bits(bs, mod + 2 - (mod >> 3));  /* 5, 7, 10 */
-                    for (k = 0; k < group_size; k++, code /= mod)
-                    {
-                        dst[k] = (float)((int)(code % mod - mod/2));
-                    }
-                }
-            }
-            dst += choff;
-            choff = 18 - choff;
-        }
-    }
-    return group_size*4;
-}
-
-static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
-{
-    int i, k;
-    memcpy(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
-    for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
-    {
-        for (k = 0; k < 12; k++)
-        {
-            dst[k + 0]   *= scf[0];
-            dst[k + 576] *= scf[3];
-        }
-    }
-}
-#endif
-
-static int drmp3_L3_read_side_info(drmp3_bs *bs, drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    static const drmp3_uint8 g_scf_long[8][23] = {
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 },
-        { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 },
-        { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 }
-    };
-    static const drmp3_uint8 g_scf_short[8][40] = {
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    static const drmp3_uint8 g_scf_mixed[8][40] = {
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-
-    unsigned tables, scfsi = 0;
-    int main_data_begin, part_23_sum = 0;
-    int gr_count = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    int sr_idx = DRMP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0);
-
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        gr_count *= 2;
-        main_data_begin = drmp3_bs_get_bits(bs, 9);
-        scfsi = drmp3_bs_get_bits(bs, 7 + gr_count);
-    } else
-    {
-        main_data_begin = drmp3_bs_get_bits(bs, 8 + gr_count) >> gr_count;
-    }
-
-    do
-    {
-        if (DRMP3_HDR_IS_MONO(hdr))
-        {
-            scfsi <<= 4;
-        }
-        gr->part_23_length = (drmp3_uint16)drmp3_bs_get_bits(bs, 12);
-        part_23_sum += gr->part_23_length;
-        gr->big_values = (drmp3_uint16)drmp3_bs_get_bits(bs,  9);
-        if (gr->big_values > 288)
-        {
-            return -1;
-        }
-        gr->global_gain = (drmp3_uint8)drmp3_bs_get_bits(bs, 8);
-        gr->scalefac_compress = (drmp3_uint16)drmp3_bs_get_bits(bs, DRMP3_HDR_TEST_MPEG1(hdr) ? 4 : 9);
-        gr->sfbtab = g_scf_long[sr_idx];
-        gr->n_long_sfb  = 22;
-        gr->n_short_sfb = 0;
-        if (drmp3_bs_get_bits(bs, 1))
-        {
-            gr->block_type = (drmp3_uint8)drmp3_bs_get_bits(bs, 2);
-            if (!gr->block_type)
-            {
-                return -1;
-            }
-            gr->mixed_block_flag = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-            gr->region_count[0] = 7;
-            gr->region_count[1] = 255;
-            if (gr->block_type == DRMP3_SHORT_BLOCK_TYPE)
-            {
-                scfsi &= 0x0F0F;
-                if (!gr->mixed_block_flag)
-                {
-                    gr->region_count[0] = 8;
-                    gr->sfbtab = g_scf_short[sr_idx];
-                    gr->n_long_sfb = 0;
-                    gr->n_short_sfb = 39;
-                } else
-                {
-                    gr->sfbtab = g_scf_mixed[sr_idx];
-                    gr->n_long_sfb = DRMP3_HDR_TEST_MPEG1(hdr) ? 8 : 6;
-                    gr->n_short_sfb = 30;
-                }
-            }
-            tables = drmp3_bs_get_bits(bs, 10);
-            tables <<= 5;
-            gr->subblock_gain[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[2] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-        } else
-        {
-            gr->block_type = 0;
-            gr->mixed_block_flag = 0;
-            tables = drmp3_bs_get_bits(bs, 15);
-            gr->region_count[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 4);
-            gr->region_count[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->region_count[2] = 255;
-        }
-        gr->table_select[0] = (drmp3_uint8)(tables >> 10);
-        gr->table_select[1] = (drmp3_uint8)((tables >> 5) & 31);
-        gr->table_select[2] = (drmp3_uint8)((tables) & 31);
-        gr->preflag = (drmp3_uint8)(DRMP3_HDR_TEST_MPEG1(hdr) ? drmp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500));
-        gr->scalefac_scale = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->count1_table = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->scfsi = (drmp3_uint8)((scfsi >> 12) & 15);
-        scfsi <<= 4;
-        gr++;
-    } while(--gr_count);
-
-    if (part_23_sum + bs->pos > bs->limit + main_data_begin*8)
-    {
-        return -1;
-    }
-
-    return main_data_begin;
-}
-
-static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, const drmp3_uint8 *scf_size, const drmp3_uint8 *scf_count, drmp3_bs *bitbuf, int scfsi)
-{
-    int i, k;
-    for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2)
-    {
-        int cnt = scf_count[i];
-        if (scfsi & 8)
-        {
-            memcpy(scf, ist_pos, cnt);
-        } else
-        {
-            int bits = scf_size[i];
-            if (!bits)
-            {
-                memset(scf, 0, cnt);
-                memset(ist_pos, 0, cnt);
-            } else
-            {
-                int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
-                for (k = 0; k < cnt; k++)
-                {
-                    int s = drmp3_bs_get_bits(bitbuf, bits);
-                    ist_pos[k] = (drmp3_uint8)(s == max_scf ? -1 : s);
-                    scf[k] = (drmp3_uint8)s;
-                }
-            }
-        }
-        ist_pos += cnt;
-        scf += cnt;
-    }
-    scf[0] = scf[1] = scf[2] = 0;
-}
-
-static float drmp3_L3_ldexp_q2(float y, int exp_q2)
-{
-    static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f };
-    int e;
-    do
-    {
-        e = DRMP3_MIN(30*4, exp_q2);
-        y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));
-    } while ((exp_q2 -= e) > 0);
-    return y;
-}
-
-static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *ist_pos, drmp3_bs *bs, const drmp3_L3_gr_info *gr, float *scf, int ch)
-{
-    static const drmp3_uint8 g_scf_partitions[3][28] = {
-        { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 },
-        { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 },
-        { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 }
-    };
-    const drmp3_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb];
-    drmp3_uint8 scf_size[4], iscf[40];
-    int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi;
-    float gain;
-
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 };
-        int part = g_scfc_decode[gr->scalefac_compress];
-        scf_size[1] = scf_size[0] = (drmp3_uint8)(part >> 2);
-        scf_size[3] = scf_size[2] = (drmp3_uint8)(part & 3);
-    } else
-    {
-        static const drmp3_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 };
-        int k, modprod, sfc, ist = DRMP3_HDR_TEST_I_STEREO(hdr) && ch;
-        sfc = gr->scalefac_compress >> ist;
-        for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4)
-        {
-            for (modprod = 1, i = 3; i >= 0; i--)
-            {
-                scf_size[i] = (drmp3_uint8)(sfc / modprod % g_mod[k + i]);
-                modprod *= g_mod[k + i];
-            }
-        }
-        scf_partition += k;
-        scfsi = -16;
-    }
-    drmp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi);
-
-    if (gr->n_short_sfb)
-    {
-        int sh = 3 - scf_shift;
-        for (i = 0; i < gr->n_short_sfb; i += 3)
-        {
-            iscf[gr->n_long_sfb + i + 0] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh));
-            iscf[gr->n_long_sfb + i + 1] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh));
-            iscf[gr->n_long_sfb + i + 2] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh));
-        }
-    } else if (gr->preflag)
-    {
-        static const drmp3_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 };
-        for (i = 0; i < 10; i++)
-        {
-            iscf[11 + i] = (drmp3_uint8)(iscf[11 + i] + g_preamp[i]);
-        }
-    }
-
-    gain_exp = gr->global_gain + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210 - (DRMP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0);
-    gain = drmp3_L3_ldexp_q2(1 << (DRMP3_MAX_SCFI/4),  DRMP3_MAX_SCFI - gain_exp);
-    for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++)
-    {
-        scf[i] = drmp3_L3_ldexp_q2(gain, iscf[i] << scf_shift);
-    }
-}
-
-static const float g_drmp3_pow43[129 + 16] = {
-    0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f,
-    0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f
-};
-
-static float drmp3_L3_pow_43(int x)
-{
-    float frac;
-    int sign, mult = 256;
-
-    if (x < 129)
-    {
-        return g_drmp3_pow43[16 + x];
-    }
-
-    if (x < 1024)
-    {
-        mult = 16;
-        x <<= 3;
-    }
-
-    sign = 2*x & 64;
-    frac = (float)((x & 63) - sign) / ((x & ~63) + sign);
-    return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult;
-}
-
-static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit)
-{
-    static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,
-        -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288,
-        -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288,
-        -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258,
-        -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259,
-        -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258,
-        -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258,
-        -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259,
-        -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258,
-        -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290,
-        -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259,
-        -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258,
-        -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259,
-        -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258,
-        -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 };
-    static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205};
-    static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
-    static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
-    static const drmp3_uint8 g_linbits[] =  { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-
-#define DRMP3_PEEK_BITS(n)    (bs_cache >> (32 - n))
-#define DRMP3_FLUSH_BITS(n)   { bs_cache <<= (n); bs_sh += (n); }
-#define DRMP3_CHECK_BITS      while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
-#define DRMP3_BSPOS           ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
-
-    float one = 0.0f;
-    int ireg = 0, big_val_cnt = gr_info->big_values;
-    const drmp3_uint8 *sfb = gr_info->sfbtab;
-    const drmp3_uint8 *bs_next_ptr = bs->buf + bs->pos/8;
-    drmp3_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7);
-    int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8;
-    bs_next_ptr += 4;
-
-    while (big_val_cnt > 0)
-    {
-        int tab_num = gr_info->table_select[ireg];
-        int sfb_cnt = gr_info->region_count[ireg++];
-        const drmp3_int16 *codebook = tabs + tabindex[tab_num];
-        int linbits = g_linbits[tab_num];
-        if (linbits)
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        if (lsb == 15)
-                        {
-                            lsb += DRMP3_PEEK_BITS(linbits);
-                            DRMP3_FLUSH_BITS(linbits);
-                            DRMP3_CHECK_BITS;
-                            *dst = one*drmp3_L3_pow_43(lsb)*((drmp3_int32)bs_cache < 0 ? -1: 1);
-                        } else
-                        {
-                            *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        }
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        } else
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        }
-    }
-
-    for (np = 1 - big_val_cnt;; dst += 4)
-    {
-        const drmp3_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
-        int leaf = codebook_count1[DRMP3_PEEK_BITS(4)];
-        if (!(leaf & 8))
-        {
-            leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))];
-        }
-        DRMP3_FLUSH_BITS(leaf & 7);
-        if (DRMP3_BSPOS > layer3gr_limit)
-        {
-            break;
-        }
-#define DRMP3_RELOAD_SCALEFACTOR  if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; }
-#define DRMP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((drmp3_int32)bs_cache < 0) ? -one : one; DRMP3_FLUSH_BITS(1) }
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(0);
-        DRMP3_DEQ_COUNT1(1);
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(2);
-        DRMP3_DEQ_COUNT1(3);
-        DRMP3_CHECK_BITS;
-    }
-
-    bs->pos = layer3gr_limit;
-}
-
-static void drmp3_L3_midside_stereo(float *left, int n)
-{
-    int i = 0;
-    float *right = left + 576;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; i < n - 3; i += 4)
-    {
-        drmp3_f4 vl = DRMP3_VLD(left + i);
-        drmp3_f4 vr = DRMP3_VLD(right + i);
-        DRMP3_VSTORE(left + i, DRMP3_VADD(vl, vr));
-        DRMP3_VSTORE(right + i, DRMP3_VSUB(vl, vr));
-    }
-#endif
-    for (; i < n; i++)
-    {
-        float a = left[i];
-        float b = right[i];
-        left[i] = a + b;
-        right[i] = a - b;
-    }
-}
-
-static void drmp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr)
-{
-    int i;
-    for (i = 0; i < n; i++)
-    {
-        left[i + 576] = left[i]*kr;
-        left[i] = left[i]*kl;
-    }
-}
-
-static void drmp3_L3_stereo_top_band(const float *right, const drmp3_uint8 *sfb, int nbands, int max_band[3])
-{
-    int i, k;
-
-    max_band[0] = max_band[1] = max_band[2] = -1;
-
-    for (i = 0; i < nbands; i++)
-    {
-        for (k = 0; k < sfb[i]; k += 2)
-        {
-            if (right[k] != 0 || right[k + 1] != 0)
-            {
-                max_band[i % 3] = i;
-                break;
-            }
-        }
-        right += sfb[i];
-    }
-}
-
-static void drmp3_L3_stereo_process(float *left, const drmp3_uint8 *ist_pos, const drmp3_uint8 *sfb, const drmp3_uint8 *hdr, int max_band[3], int mpeg2_sh)
-{
-    static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 };
-    unsigned i, max_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 7 : 64;
-
-    for (i = 0; sfb[i]; i++)
-    {
-        unsigned ipos = ist_pos[i];
-        if ((int)i > max_band[i % 3] && ipos < max_pos)
-        {
-            float kl, kr, s = DRMP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1;
-            if (DRMP3_HDR_TEST_MPEG1(hdr))
-            {
-                kl = g_pan[2*ipos];
-                kr = g_pan[2*ipos + 1];
-            } else
-            {
-                kl = 1;
-                kr = drmp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh);
-                if (ipos & 1)
-                {
-                    kl = kr;
-                    kr = 1;
-                }
-            }
-            drmp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s);
-        } else if (DRMP3_HDR_TEST_MS_STEREO(hdr))
-        {
-            drmp3_L3_midside_stereo(left, sfb[i]);
-        }
-        left += sfb[i];
-    }
-}
-
-static void drmp3_L3_intensity_stereo(float *left, drmp3_uint8 *ist_pos, const drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb;
-    int i, max_blocks = gr->n_short_sfb ? 3 : 1;
-
-    drmp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band);
-    if (gr->n_long_sfb)
-    {
-        max_band[0] = max_band[1] = max_band[2] = DRMP3_MAX(DRMP3_MAX(max_band[0], max_band[1]), max_band[2]);
-    }
-    for (i = 0; i < max_blocks; i++)
-    {
-        int default_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 3 : 0;
-        int itop = n_sfb - max_blocks + i;
-        int prev = itop - max_blocks;
-        ist_pos[itop] = (drmp3_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]);
-    }
-    drmp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1);
-}
-
-static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sfb)
-{
-    int i, len;
-    float *src = grbuf, *dst = scratch;
-
-    for (;0 != (len = *sfb); sfb += 3, src += 2*len)
-    {
-        for (i = 0; i < len; i++, src++)
-        {
-            *dst++ = src[0*len];
-            *dst++ = src[1*len];
-            *dst++ = src[2*len];
-        }
-    }
-    memcpy(grbuf, scratch, (dst - scratch)*sizeof(float));
-}
-
-static void drmp3_L3_antialias(float *grbuf, int nbands)
-{
-    static const float g_aa[2][8] = {
-        {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f},
-        {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f}
-    };
-
-    for (; nbands > 0; nbands--, grbuf += 18)
-    {
-        int i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vu = DRMP3_VLD(grbuf + 18 + i);
-            drmp3_f4 vd = DRMP3_VLD(grbuf + 14 - i);
-            drmp3_f4 vc0 = DRMP3_VLD(g_aa[0] + i);
-            drmp3_f4 vc1 = DRMP3_VLD(g_aa[1] + i);
-            vd = DRMP3_VREV(vd);
-            DRMP3_VSTORE(grbuf + 18 + i, DRMP3_VSUB(DRMP3_VMUL(vu, vc0), DRMP3_VMUL(vd, vc1)));
-            vd = DRMP3_VADD(DRMP3_VMUL(vu, vc1), DRMP3_VMUL(vd, vc0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vd));
-        }
-#endif
-#ifndef DR_MP3_ONLY_SIMD
-        for(; i < 8; i++)
-        {
-            float u = grbuf[18 + i];
-            float d = grbuf[17 - i];
-            grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i];
-            grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i];
-        }
-#endif
-    }
-}
-
-static void drmp3_L3_dct3_9(float *y)
-{
-    float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4;
-
-    s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8];
-    t0 = s0 + s6*0.5f;
-    s0 -= s6;
-    t4 = (s4 + s2)*0.93969262f;
-    t2 = (s8 + s2)*0.76604444f;
-    s6 = (s4 - s8)*0.17364818f;
-    s4 += s8 - s2;
-
-    s2 = s0 - s4*0.5f;
-    y[4] = s4 + s0;
-    s8 = t0 - t2 + s6;
-    s0 = t0 - t4 + t2;
-    s4 = t0 + t4 - s6;
-
-    s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7];
-
-    s3 *= 0.86602540f;
-    t0 = (s5 + s1)*0.98480775f;
-    t4 = (s5 - s7)*0.34202014f;
-    t2 = (s1 + s7)*0.64278761f;
-    s1 = (s1 - s5 - s7)*0.86602540f;
-
-    s5 = t0 - s3 - t2;
-    s7 = t4 - s3 - t0;
-    s3 = t4 + s3 - t2;
-
-    y[0] = s4 - s7;
-    y[1] = s2 + s1;
-    y[2] = s0 - s3;
-    y[3] = s8 + s5;
-    y[5] = s8 - s5;
-    y[6] = s0 + s3;
-    y[7] = s2 - s1;
-    y[8] = s4 + s7;
-}
-
-static void drmp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands)
-{
-    int i, j;
-    static const float g_twid9[18] = {
-        0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f
-    };
-
-    for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9)
-    {
-        float co[9], si[9];
-        co[0] = -grbuf[0];
-        si[0] = grbuf[17];
-        for (i = 0; i < 4; i++)
-        {
-            si[8 - 2*i] =   grbuf[4*i + 1] - grbuf[4*i + 2];
-            co[1 + 2*i] =   grbuf[4*i + 1] + grbuf[4*i + 2];
-            si[7 - 2*i] =   grbuf[4*i + 4] - grbuf[4*i + 3];
-            co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]);
-        }
-        drmp3_L3_dct3_9(co);
-        drmp3_L3_dct3_9(si);
-
-        si[1] = -si[1];
-        si[3] = -si[3];
-        si[5] = -si[5];
-        si[7] = -si[7];
-
-        i = 0;
-
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vovl = DRMP3_VLD(overlap + i);
-            drmp3_f4 vc = DRMP3_VLD(co + i);
-            drmp3_f4 vs = DRMP3_VLD(si + i);
-            drmp3_f4 vr0 = DRMP3_VLD(g_twid9 + i);
-            drmp3_f4 vr1 = DRMP3_VLD(g_twid9 + 9 + i);
-            drmp3_f4 vw0 = DRMP3_VLD(window + i);
-            drmp3_f4 vw1 = DRMP3_VLD(window + 9 + i);
-            drmp3_f4 vsum = DRMP3_VADD(DRMP3_VMUL(vc, vr1), DRMP3_VMUL(vs, vr0));
-            DRMP3_VSTORE(overlap + i, DRMP3_VSUB(DRMP3_VMUL(vc, vr0), DRMP3_VMUL(vs, vr1)));
-            DRMP3_VSTORE(grbuf + i, DRMP3_VSUB(DRMP3_VMUL(vovl, vw0), DRMP3_VMUL(vsum, vw1)));
-            vsum = DRMP3_VADD(DRMP3_VMUL(vovl, vw1), DRMP3_VMUL(vsum, vw0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vsum));
-        }
-#endif
-        for (; i < 9; i++)
-        {
-            float ovl  = overlap[i];
-            float sum  = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i];
-            overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i];
-            grbuf[i]      = ovl*window[0 + i] - sum*window[9 + i];
-            grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i];
-        }
-    }
-}
-
-static void drmp3_L3_idct3(float x0, float x1, float x2, float *dst)
-{
-    float m1 = x1*0.86602540f;
-    float a1 = x0 - x2*0.5f;
-    dst[1] = x0 + x2;
-    dst[0] = a1 + m1;
-    dst[2] = a1 - m1;
-}
-
-static void drmp3_L3_imdct12(float *x, float *dst, float *overlap)
-{
-    static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f };
-    float co[3], si[3];
-    int i;
-
-    drmp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co);
-    drmp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si);
-    si[1] = -si[1];
-
-    for (i = 0; i < 3; i++)
-    {
-        float ovl  = overlap[i];
-        float sum  = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i];
-        overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i];
-        dst[i]     = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i];
-        dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i];
-    }
-}
-
-static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
-{
-    for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
-    {
-        float tmp[18];
-        memcpy(tmp, grbuf, sizeof(tmp));
-        memcpy(grbuf, overlap, 6*sizeof(float));
-        drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
-        drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
-        drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
-    }
-}
-
-static void drmp3_L3_change_sign(float *grbuf)
-{
-    int b, i;
-    for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36)
-        for (i = 1; i < 18; i += 2)
-            grbuf[i] = -grbuf[i];
-}
-
-static void drmp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands)
-{
-    static const float g_mdct_window[2][18] = {
-        { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f },
-        { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f }
-    };
-    if (n_long_bands)
-    {
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands);
-        grbuf += 18*n_long_bands;
-        overlap += 9*n_long_bands;
-    }
-    if (block_type == DRMP3_SHORT_BLOCK_TYPE)
-        drmp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands);
-    else
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == DRMP3_STOP_BLOCK_TYPE], 32 - n_long_bands);
-}
-
-static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
-{
-    int pos = (s->bs.pos + 7)/8u;
-    int remains = s->bs.limit/8u - pos;
-    if (remains > DRMP3_MAX_BITRESERVOIR_BYTES)
-    {
-        pos += remains - DRMP3_MAX_BITRESERVOIR_BYTES;
-        remains = DRMP3_MAX_BITRESERVOIR_BYTES;
-    }
-    if (remains > 0)
-    {
-        memmove(h->reserv_buf, s->maindata + pos, remains);
-    }
-    h->reserv = remains;
-}
-
-static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratch *s, int main_data_begin)
-{
-    int frame_bytes = (bs->limit - bs->pos)/8;
-    int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
-    memcpy(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
-    memcpy(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
-    drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
-    return h->reserv >= main_data_begin;
-}
-
-static void drmp3_L3_decode(drmp3dec *h, drmp3dec_scratch *s, drmp3_L3_gr_info *gr_info, int nch)
-{
-    int ch;
-
-    for (ch = 0; ch < nch; ch++)
-    {
-        int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length;
-        drmp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch);
-        drmp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit);
-    }
-
-    if (DRMP3_HDR_TEST_I_STEREO(h->header))
-    {
-        drmp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header);
-    } else if (DRMP3_HDR_IS_MS_STEREO(h->header))
-    {
-        drmp3_L3_midside_stereo(s->grbuf[0], 576);
-    }
-
-    for (ch = 0; ch < nch; ch++, gr_info++)
-    {
-        int aa_bands = 31;
-        int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(DRMP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2);
-
-        if (gr_info->n_short_sfb)
-        {
-            aa_bands = n_long_bands - 1;
-            drmp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb);
-        }
-
-        drmp3_L3_antialias(s->grbuf[ch], aa_bands);
-        drmp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands);
-        drmp3_L3_change_sign(s->grbuf[ch]);
-    }
-}
-
-static void drmp3d_DCT_II(float *grbuf, int n)
-{
-    static const float g_sec[24] = {
-        10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f
-    };
-    int i, k = 0;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; k < n; k += 4)
-    {
-        drmp3_f4 t[4][8], *x;
-        float *y = grbuf + k;
-
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            drmp3_f4 x0 = DRMP3_VLD(&y[i*18]);
-            drmp3_f4 x1 = DRMP3_VLD(&y[(15 - i)*18]);
-            drmp3_f4 x2 = DRMP3_VLD(&y[(16 + i)*18]);
-            drmp3_f4 x3 = DRMP3_VLD(&y[(31 - i)*18]);
-            drmp3_f4 t0 = DRMP3_VADD(x0, x3);
-            drmp3_f4 t1 = DRMP3_VADD(x1, x2);
-            drmp3_f4 t2 = DRMP3_VMUL_S(DRMP3_VSUB(x1, x2), g_sec[3*i + 0]);
-            drmp3_f4 t3 = DRMP3_VMUL_S(DRMP3_VSUB(x0, x3), g_sec[3*i + 1]);
-            x[0] = DRMP3_VADD(t0, t1);
-            x[8] = DRMP3_VMUL_S(DRMP3_VSUB(t0, t1), g_sec[3*i + 2]);
-            x[16] = DRMP3_VADD(t3, t2);
-            x[24] = DRMP3_VMUL_S(DRMP3_VSUB(t3, t2), g_sec[3*i + 2]);
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            drmp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = DRMP3_VSUB(x0, x7); x0 = DRMP3_VADD(x0, x7);
-            x7 = DRMP3_VSUB(x1, x6); x1 = DRMP3_VADD(x1, x6);
-            x6 = DRMP3_VSUB(x2, x5); x2 = DRMP3_VADD(x2, x5);
-            x5 = DRMP3_VSUB(x3, x4); x3 = DRMP3_VADD(x3, x4);
-            x4 = DRMP3_VSUB(x0, x3); x0 = DRMP3_VADD(x0, x3);
-            x3 = DRMP3_VSUB(x1, x2); x1 = DRMP3_VADD(x1, x2);
-            x[0] = DRMP3_VADD(x0, x1);
-            x[4] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x1), 0.70710677f);
-            x5 = DRMP3_VADD(x5, x6);
-            x6 = DRMP3_VMUL_S(DRMP3_VADD(x6, x7), 0.70710677f);
-            x7 = DRMP3_VADD(x7, xt);
-            x3 = DRMP3_VMUL_S(DRMP3_VADD(x3, x4), 0.70710677f);
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f)); /* rotate by PI/8 */
-            x7 = DRMP3_VADD(x7, DRMP3_VMUL_S(x5, 0.382683432f));
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x0 = DRMP3_VSUB(xt, x6); xt = DRMP3_VADD(xt, x6);
-            x[1] = DRMP3_VMUL_S(DRMP3_VADD(xt, x7), 0.50979561f);
-            x[2] = DRMP3_VMUL_S(DRMP3_VADD(x4, x3), 0.54119611f);
-            x[3] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x5), 0.60134488f);
-            x[5] = DRMP3_VMUL_S(DRMP3_VADD(x0, x5), 0.89997619f);
-            x[6] = DRMP3_VMUL_S(DRMP3_VSUB(x4, x3), 1.30656302f);
-            x[7] = DRMP3_VMUL_S(DRMP3_VSUB(xt, x7), 2.56291556f);
-        }
-
-        if (k > n - 3)
-        {
-#if DRMP3_HAVE_SSE
-#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
-#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18],  vget_low_f32(v))
-#endif
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE2(0, t[0][i]);
-                DRMP3_VSAVE2(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE2(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE2(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE2(0, t[0][7]);
-            DRMP3_VSAVE2(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE2(2, t[1][7]);
-            DRMP3_VSAVE2(3, t[3][7]);
-        } else
-        {
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE4(0, t[0][i]);
-                DRMP3_VSAVE4(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE4(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE4(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE4(0, t[0][7]);
-            DRMP3_VSAVE4(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE4(2, t[1][7]);
-            DRMP3_VSAVE4(3, t[3][7]);
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
-#else
-    for (; k < n; k++)
-    {
-        float t[4][8], *x, *y = grbuf + k;
-
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            float x0 = y[i*18];
-            float x1 = y[(15 - i)*18];
-            float x2 = y[(16 + i)*18];
-            float x3 = y[(31 - i)*18];
-            float t0 = x0 + x3;
-            float t1 = x1 + x2;
-            float t2 = (x1 - x2)*g_sec[3*i + 0];
-            float t3 = (x0 - x3)*g_sec[3*i + 1];
-            x[0] = t0 + t1;
-            x[8] = (t0 - t1)*g_sec[3*i + 2];
-            x[16] = t3 + t2;
-            x[24] = (t3 - t2)*g_sec[3*i + 2];
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = x0 - x7; x0 += x7;
-            x7 = x1 - x6; x1 += x6;
-            x6 = x2 - x5; x2 += x5;
-            x5 = x3 - x4; x3 += x4;
-            x4 = x0 - x3; x0 += x3;
-            x3 = x1 - x2; x1 += x2;
-            x[0] = x0 + x1;
-            x[4] = (x0 - x1)*0.70710677f;
-            x5 =  x5 + x6;
-            x6 = (x6 + x7)*0.70710677f;
-            x7 =  x7 + xt;
-            x3 = (x3 + x4)*0.70710677f;
-            x5 -= x7*0.198912367f;  /* rotate by PI/8 */
-            x7 += x5*0.382683432f;
-            x5 -= x7*0.198912367f;
-            x0 = xt - x6; xt += x6;
-            x[1] = (xt + x7)*0.50979561f;
-            x[2] = (x4 + x3)*0.54119611f;
-            x[3] = (x0 - x5)*0.60134488f;
-            x[5] = (x0 + x5)*0.89997619f;
-            x[6] = (x4 - x3)*1.30656302f;
-            x[7] = (xt - x7)*2.56291556f;
-
-        }
-        for (i = 0; i < 7; i++, y += 4*18)
-        {
-            y[0*18] = t[0][i];
-            y[1*18] = t[2][i] + t[3][i] + t[3][i + 1];
-            y[2*18] = t[1][i] + t[1][i + 1];
-            y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1];
-        }
-        y[0*18] = t[0][7];
-        y[1*18] = t[2][7] + t[3][7];
-        y[2*18] = t[1][7];
-        y[3*18] = t[3][7];
-    }
-#endif
-}
-
-#ifndef DR_MP3_FLOAT_OUTPUT
-typedef drmp3_int16 drmp3d_sample_t;
-
-static drmp3_int16 drmp3d_scale_pcm(float sample)
-{
-    drmp3_int16 s;
-#if DRMP3_HAVE_ARMV6
-    drmp3_int32 s32 = (drmp3_int32)(sample + .5f);
-    s32 -= (s32 < 0);
-    s = (drmp3_int16)drmp3_clip_int16_arm(s32);
-#else
-    if (sample >=  32766.5) return (drmp3_int16) 32767;
-    if (sample <= -32767.5) return (drmp3_int16)-32768;
-    s = (drmp3_int16)(sample + .5f);
-    s -= (s < 0);   /* away from zero, to be compliant */
-#endif
-    return s;
-}
-#else
-typedef float drmp3d_sample_t;
-
-static float drmp3d_scale_pcm(float sample)
-{
-    return sample*(1.f/32768.f);
-}
-#endif
-
-static void drmp3d_synth_pair(drmp3d_sample_t *pcm, int nch, const float *z)
-{
-    float a;
-    a  = (z[14*64] - z[    0]) * 29;
-    a += (z[ 1*64] + z[13*64]) * 213;
-    a += (z[12*64] - z[ 2*64]) * 459;
-    a += (z[ 3*64] + z[11*64]) * 2037;
-    a += (z[10*64] - z[ 4*64]) * 5153;
-    a += (z[ 5*64] + z[ 9*64]) * 6574;
-    a += (z[ 8*64] - z[ 6*64]) * 37489;
-    a +=  z[ 7*64]             * 75038;
-    pcm[0] = drmp3d_scale_pcm(a);
-
-    z += 2;
-    a  = z[14*64] * 104;
-    a += z[12*64] * 1567;
-    a += z[10*64] * 9727;
-    a += z[ 8*64] * 64019;
-    a += z[ 6*64] * -9975;
-    a += z[ 4*64] * -45;
-    a += z[ 2*64] * 146;
-    a += z[ 0*64] * -5;
-    pcm[16*nch] = drmp3d_scale_pcm(a);
-}
-
-static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
-{
-    int i;
-    float *xr = xl + 576*(nch - 1);
-    drmp3d_sample_t *dstr = dstl + (nch - 1);
-
-    static const float g_win[] = {
-        -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992,
-        -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856,
-        -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630,
-        -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313,
-        -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908,
-        -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415,
-        -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835,
-        -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169,
-        -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420,
-        -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590,
-        -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679,
-        -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692,
-        -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629,
-        -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494,
-        -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290
-    };
-    float *zlin = lins + 15*64;
-    const float *w = g_win;
-
-    zlin[4*15]     = xl[18*16];
-    zlin[4*15 + 1] = xr[18*16];
-    zlin[4*15 + 2] = xl[0];
-    zlin[4*15 + 3] = xr[0];
-
-    zlin[4*31]     = xl[1 + 18*16];
-    zlin[4*31 + 1] = xr[1 + 18*16];
-    zlin[4*31 + 2] = xl[1];
-    zlin[4*31 + 3] = xr[1];
-
-    drmp3d_synth_pair(dstr, nch, lins + 4*15 + 1);
-    drmp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1);
-    drmp3d_synth_pair(dstl, nch, lins + 4*15);
-    drmp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64);
-
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_VLOAD(k) drmp3_f4 w0 = DRMP3_VSET(*w++); drmp3_f4 w1 = DRMP3_VSET(*w++); drmp3_f4 vz = DRMP3_VLD(&zlin[4*i - 64*k]); drmp3_f4 vy = DRMP3_VLD(&zlin[4*i - 64*(15 - k)]);
-#define DRMP3_V0(k) { DRMP3_VLOAD(k) b =               DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0)) ; a =               DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1));  }
-#define DRMP3_V1(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1))); }
-#define DRMP3_V2(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vy, w1), DRMP3_VMUL(vz, w0))); }
-        drmp3_f4 a, b;
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*i + 64] = xl[1 + 18*(1 + i)];
-        zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*i - 64 + 2] = xl[18*(1 + i)];
-        zlin[4*i - 64 + 3] = xr[18*(1 + i)];
-
-        DRMP3_V0(0) DRMP3_V2(1) DRMP3_V1(2) DRMP3_V2(3) DRMP3_V1(4) DRMP3_V2(5) DRMP3_V1(6) DRMP3_V2(7)
-
-        {
-#ifndef DR_MP3_FLOAT_OUTPUT
-#if DRMP3_HAVE_SSE
-            static const drmp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f };
-            static const drmp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f };
-            __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)),
-                                           _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min)));
-            dstr[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-            dstr[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-            dstl[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-            dstl[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-            dstr[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-            dstr[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-            dstl[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-            dstl[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-#else
-            int16x4_t pcma, pcmb;
-            a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-            b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-            pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-            pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-            vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1);
-            vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1);
-            vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0);
-            vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0);
-            vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3);
-            vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3);
-            vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2);
-            vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
-#endif
-#else
-            static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
-            a = DRMP3_VMUL(a, g_scale);
-            b = DRMP3_VMUL(b, g_scale);
-#if DRMP3_HAVE_SSE
-            _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2)));
-            _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2)));
-#else
-            vst1q_lane_f32(dstr + (15 - i)*nch, a, 1);
-            vst1q_lane_f32(dstr + (17 + i)*nch, b, 1);
-            vst1q_lane_f32(dstl + (15 - i)*nch, a, 0);
-            vst1q_lane_f32(dstl + (17 + i)*nch, b, 0);
-            vst1q_lane_f32(dstr + (47 - i)*nch, a, 3);
-            vst1q_lane_f32(dstr + (49 + i)*nch, b, 3);
-            vst1q_lane_f32(dstl + (47 - i)*nch, a, 2);
-            vst1q_lane_f32(dstl + (49 + i)*nch, b, 2);
-#endif
-#endif /* DR_MP3_FLOAT_OUTPUT */
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {} /* for HAVE_SIMD=1, MINIMP3_ONLY_SIMD=1 case we do not need non-intrinsic "else" branch */
-#else
-    for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64];
-#define DRMP3_S0(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j]  = vz[j]*w1 + vy[j]*w0, a[j]  = vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S1(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S2(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; }
-        float a[4], b[4];
-
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*(i + 16)]   = xl[1 + 18*(1 + i)];
-        zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*(i - 16) + 2] = xl[18*(1 + i)];
-        zlin[4*(i - 16) + 3] = xr[18*(1 + i)];
-
-        DRMP3_S0(0) DRMP3_S2(1) DRMP3_S1(2) DRMP3_S2(3) DRMP3_S1(4) DRMP3_S2(5) DRMP3_S1(6) DRMP3_S2(7)
-
-        dstr[(15 - i)*nch] = drmp3d_scale_pcm(a[1]);
-        dstr[(17 + i)*nch] = drmp3d_scale_pcm(b[1]);
-        dstl[(15 - i)*nch] = drmp3d_scale_pcm(a[0]);
-        dstl[(17 + i)*nch] = drmp3d_scale_pcm(b[0]);
-        dstr[(47 - i)*nch] = drmp3d_scale_pcm(a[3]);
-        dstr[(49 + i)*nch] = drmp3d_scale_pcm(b[3]);
-        dstl[(47 - i)*nch] = drmp3d_scale_pcm(a[2]);
-        dstl[(49 + i)*nch] = drmp3d_scale_pcm(b[2]);
-    }
-#endif
-}
-
-static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, drmp3d_sample_t *pcm, float *lins)
-{
-    int i;
-    for (i = 0; i < nch; i++)
-    {
-        drmp3d_DCT_II(grbuf + 576*i, nbands);
-    }
-
-    memcpy(lins, qmf_state, sizeof(float)*15*64);
-
-    for (i = 0; i < nbands; i += 2)
-    {
-        drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
-    }
-#ifndef DR_MP3_NONSTANDARD_BUT_LOGICAL
-    if (nch == 1)
-    {
-        for (i = 0; i < 15*64; i += 2)
-        {
-            qmf_state[i] = lins[nbands*64 + i];
-        }
-    } else
-#endif
-    {
-        memcpy(qmf_state, lins + nbands*64, sizeof(float)*15*64);
-    }
-}
-
-static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
-{
-    int i, nmatch;
-    for (i = 0, nmatch = 0; nmatch < DRMP3_MAX_FRAME_SYNC_MATCHES; nmatch++)
-    {
-        i += drmp3_hdr_frame_bytes(hdr + i, frame_bytes) + drmp3_hdr_padding(hdr + i);
-        if (i + DRMP3_HDR_SIZE > mp3_bytes)
-            return nmatch > 0;
-        if (!drmp3_hdr_compare(hdr, hdr + i))
-            return 0;
-    }
-    return 1;
-}
-
-static int drmp3d_find_frame(const drmp3_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes)
-{
-    int i, k;
-    for (i = 0; i < mp3_bytes - DRMP3_HDR_SIZE; i++, mp3++)
-    {
-        if (drmp3_hdr_valid(mp3))
-        {
-            int frame_bytes = drmp3_hdr_frame_bytes(mp3, *free_format_bytes);
-            int frame_and_padding = frame_bytes + drmp3_hdr_padding(mp3);
-
-            for (k = DRMP3_HDR_SIZE; !frame_bytes && k < DRMP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - DRMP3_HDR_SIZE; k++)
-            {
-                if (drmp3_hdr_compare(mp3, mp3 + k))
-                {
-                    int fb = k - drmp3_hdr_padding(mp3);
-                    int nextfb = fb + drmp3_hdr_padding(mp3 + k);
-                    if (i + k + nextfb + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + k + nextfb))
-                        continue;
-                    frame_and_padding = k;
-                    frame_bytes = fb;
-                    *free_format_bytes = fb;
-                }
-            }
-
-            if ((frame_bytes && i + frame_and_padding <= mp3_bytes &&
-                drmp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) ||
-                (!i && frame_and_padding == mp3_bytes))
-            {
-                *ptr_frame_bytes = frame_and_padding;
-                return i;
-            }
-            *free_format_bytes = 0;
-        }
-    }
-    *ptr_frame_bytes = 0;
-    return mp3_bytes;
-}
-
-DRMP3_API void drmp3dec_init(drmp3dec *dec)
-{
-    dec->header[0] = 0;
-}
-
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
-{
-    int i = 0, igr, frame_size = 0, success = 1;
-    const drmp3_uint8 *hdr;
-    drmp3_bs bs_frame[1];
-    drmp3dec_scratch scratch;
-
-    if (mp3_bytes > 4 && dec->header[0] == 0xff && drmp3_hdr_compare(dec->header, mp3))
-    {
-        frame_size = drmp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + drmp3_hdr_padding(mp3);
-        if (frame_size != mp3_bytes && (frame_size + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + frame_size)))
-        {
-            frame_size = 0;
-        }
-    }
-    if (!frame_size)
-    {
-        memset(dec, 0, sizeof(drmp3dec));
-        i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
-        if (!frame_size || i + frame_size > mp3_bytes)
-        {
-            info->frame_bytes = i;
-            return 0;
-        }
-    }
-
-    hdr = mp3 + i;
-    memcpy(dec->header, hdr, DRMP3_HDR_SIZE);
-    info->frame_bytes = i + frame_size;
-    info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    info->hz = drmp3_hdr_sample_rate_hz(hdr);
-    info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr);
-    info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr);
-
-    drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE);
-    if (DRMP3_HDR_IS_CRC(hdr))
-    {
-        drmp3_bs_get_bits(bs_frame, 16);
-    }
-
-    if (info->layer == 3)
-    {
-        int main_data_begin = drmp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr);
-        if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit)
-        {
-            drmp3dec_init(dec);
-            return 0;
-        }
-        success = drmp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin);
-        if (success && pcm != NULL)
-        {
-            for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
-            {
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-            }
-        }
-        drmp3_L3_save_reservoir(dec, &scratch);
-    } else
-    {
-#ifdef DR_MP3_ONLY_MP3
-        return 0;
-#else
-        drmp3_L12_scale_info sci[1];
-
-        if (pcm == NULL) {
-            return drmp3_hdr_frame_samples(hdr);
-        }
-
-        drmp3_L12_read_scale_info(hdr, bs_frame, sci);
-
-        memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-        for (i = 0, igr = 0; igr < 3; igr++)
-        {
-            if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
-            {
-                i = 0;
-                drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
-            }
-            if (bs_frame->pos > bs_frame->limit)
-            {
-                drmp3dec_init(dec);
-                return 0;
-            }
-        }
-#endif
-    }
-
-    return success*drmp3_hdr_frame_samples(dec->header);
-}
-
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples)
-{
-    size_t i = 0;
-#if DRMP3_HAVE_SIMD
-    size_t aligned_count = num_samples & ~7;
-    for(; i < aligned_count; i+=8)
-    {
-        drmp3_f4 scale = DRMP3_VSET(32768.0f);
-        drmp3_f4 a = DRMP3_VMUL(DRMP3_VLD(&in[i  ]), scale);
-        drmp3_f4 b = DRMP3_VMUL(DRMP3_VLD(&in[i+4]), scale);
-#if DRMP3_HAVE_SSE
-        drmp3_f4 s16max = DRMP3_VSET( 32767.0f);
-        drmp3_f4 s16min = DRMP3_VSET(-32768.0f);
-        __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)),
-                                        _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min)));
-        out[i  ] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-        out[i+1] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-        out[i+2] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-        out[i+3] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-        out[i+4] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-        out[i+5] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-        out[i+6] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-        out[i+7] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-#else
-        int16x4_t pcma, pcmb;
-        a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-        b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-        pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-        pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-        vst1_lane_s16(out+i  , pcma, 0);
-        vst1_lane_s16(out+i+1, pcma, 1);
-        vst1_lane_s16(out+i+2, pcma, 2);
-        vst1_lane_s16(out+i+3, pcma, 3);
-        vst1_lane_s16(out+i+4, pcmb, 0);
-        vst1_lane_s16(out+i+5, pcmb, 1);
-        vst1_lane_s16(out+i+6, pcmb, 2);
-        vst1_lane_s16(out+i+7, pcmb, 3);
-#endif
-    }
-#endif
-    for(; i < num_samples; i++)
-    {
-        float sample = in[i] * 32768.0f;
-        if (sample >=  32766.5)
-            out[i] = (drmp3_int16) 32767;
-        else if (sample <= -32767.5)
-            out[i] = (drmp3_int16)-32768;
-        else
-        {
-            short s = (drmp3_int16)(sample + .5f);
-            s -= (s < 0);   /* away from zero, to be compliant */
-            out[i] = s;
-        }
-    }
-}
-
-
-
-/************************************************************************************************************************************************************
-
- Main Public API
-
- ************************************************************************************************************************************************************/
-#include <math.h>   /* For sin() and exp(). */
-
-#if defined(SIZE_MAX)
-    #define DRMP3_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRMP3_SIZE_MAX  ((drmp3_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRMP3_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-/* Options. */
-#ifndef DRMP3_SEEK_LEADING_MP3_FRAMES
-#define DRMP3_SEEK_LEADING_MP3_FRAMES   2
-#endif
-
-#define DRMP3_MIN_DATA_CHUNK_SIZE   16384
-
-/* The size in bytes of each chunk of data to read from the MP3 stream. minimp3 recommends at least 16K, but in an attempt to reduce data movement I'm making this slightly larger. */
-#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE  DRMP3_MIN_DATA_CHUNK_SIZE*4
-#endif
-
-
-/* Standard library stuff. */
-#ifndef DRMP3_ASSERT
-#include <assert.h>
-#define DRMP3_ASSERT(expression) assert(expression)
-#endif
-#ifndef DRMP3_COPY_MEMORY
-#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#ifndef DRMP3_ZERO_MEMORY
-#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
-#ifndef DRMP3_MALLOC
-#define DRMP3_MALLOC(sz) malloc((sz))
-#endif
-#ifndef DRMP3_REALLOC
-#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#ifndef DRMP3_FREE
-#define DRMP3_FREE(p) free((p))
-#endif
-
-#define DRMP3_COUNTOF(x)        (sizeof(x) / sizeof(x[0]))
-#define DRMP3_CLAMP(x, lo, hi)  (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
-
-#ifndef DRMP3_PI_D
-#define DRMP3_PI_D    3.14159265358979323846264
-#endif
-
-#define DRMP3_DEFAULT_RESAMPLER_LPF_ORDER   2
-
-static DRMP3_INLINE float drmp3_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static DRMP3_INLINE float drmp3_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-    /*return x + (y - x)*a;*/
-}
-
-
-/*
-Greatest common factor using Euclid's algorithm iteratively.
-*/
-static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            drmp3_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-
-    return a;
-}
-
-
-static DRMP3_INLINE double drmp3_sin(double x)
-{
-    /* TODO: Implement custom sin(x). */
-    return sin(x);
-}
-
-static DRMP3_INLINE double drmp3_exp(double x)
-{
-    /* TODO: Implement custom exp(x). */
-    return exp(x);
-}
-
-static DRMP3_INLINE double drmp3_cos(double x)
-{
-    return drmp3_sin((DRMP3_PI_D*0.5) - x);
-}
-
-
-static void* drmp3__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_MALLOC(sz);
-}
-
-static void* drmp3__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_REALLOC(p, sz);
-}
-
-static void drmp3__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRMP3_FREE(p);
-}
-
-
-static void* drmp3__malloc_from_callbacks(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRMP3_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static void drmp3__free_from_callbacks(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-static drmp3_allocation_callbacks drmp3_copy_allocation_callbacks_or_defaults(const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        /* Copy. */
-        return *pAllocationCallbacks;
-    } else {
-        /* Defaults. */
-        drmp3_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drmp3__malloc_default;
-        allocationCallbacks.onRealloc = drmp3__realloc_default;
-        allocationCallbacks.onFree    = drmp3__free_default;
-        return allocationCallbacks;
-    }
-}
-
-
-
-static size_t drmp3__on_read(drmp3* pMP3, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead);
-    pMP3->streamCursor += bytesRead;
-    return bytesRead;
-}
-
-static drmp3_bool32 drmp3__on_seek(drmp3* pMP3, int offset, drmp3_seek_origin origin)
-{
-    DRMP3_ASSERT(offset >= 0);
-
-    if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) {
-        return DRMP3_FALSE;
-    }
-
-    if (origin == drmp3_seek_origin_start) {
-        pMP3->streamCursor = (drmp3_uint64)offset;
-    } else {
-        pMP3->streamCursor += offset;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3__on_seek_64(drmp3* pMP3, drmp3_uint64 offset, drmp3_seek_origin origin)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return drmp3__on_seek(pMP3, (int)offset, origin);
-    }
-
-
-    /* Getting here "offset" is too large for a 32-bit integer. We just keep seeking forward until we hit the offset. */
-    if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-
-    offset -= 0x7FFFFFFF;
-    while (offset > 0) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!drmp3__on_seek(pMP3, (int)offset, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset = 0;
-        } else {
-            if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset -= 0x7FFFFFFF;
-        }
-    }
-
-    return DRMP3_TRUE;
-}
-
-
-static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-
-    if (pMP3->atEnd) {
-        return 0;
-    }
-
-    for (;;) {
-        drmp3dec_frame_info info;
-
-        /* minimp3 recommends doing data submission in chunks of at least 16K. If we don't have at least 16K bytes available, get more. */
-        if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
-            size_t bytesRead;
-
-            /* First we need to move the data down. */
-            if (pMP3->pData != NULL) {
-                memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            }
-
-            pMP3->dataConsumed = 0;
-
-            if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-
-                newDataCap = DRMP3_DATA_CHUNK_SIZE;
-
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0; /* Out of memory. */
-                }
-
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                if (pMP3->dataSize == 0) {
-                    pMP3->atEnd = DRMP3_TRUE;
-                    return 0; /* No data. */
-                }
-            }
-
-            pMP3->dataSize += bytesRead;
-        }
-
-        if (pMP3->dataSize > INT_MAX) {
-            pMP3->atEnd = DRMP3_TRUE;
-            return 0; /* File too big. */
-        }
-
-        DRMP3_ASSERT(pMP3->pData != NULL);
-        DRMP3_ASSERT(pMP3->dataCapacity > 0);
-
-        pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);    /* <-- Safe size_t -> int conversion thanks to the check above. */
-
-        /* Consume the data. */
-        if (info.frame_bytes > 0) {
-            pMP3->dataConsumed += (size_t)info.frame_bytes;
-            pMP3->dataSize     -= (size_t)info.frame_bytes;
-        }
-
-        /* pcmFramesRead will be equal to 0 if decoding failed. If it is zero and info.frame_bytes > 0 then we have successfully decoded the frame. */
-        if (pcmFramesRead > 0) {
-            pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
-            pMP3->pcmFramesConsumedInMP3Frame = 0;
-            pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-            pMP3->mp3FrameChannels = info.channels;
-            pMP3->mp3FrameSampleRate = info.hz;
-            break;
-        } else if (info.frame_bytes == 0) {
-            /* Need more data. minimp3 recommends doing data submission in 16K chunks. */
-            size_t bytesRead;
-
-            /* First we need to move the data down. */
-            memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            pMP3->dataConsumed = 0;
-
-            if (pMP3->dataCapacity == pMP3->dataSize) {
-                /* No room. Expand. */
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-
-                newDataCap = pMP3->dataCapacity + DRMP3_DATA_CHUNK_SIZE;
-
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0; /* Out of memory. */
-                }
-
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-
-            /* Fill in a chunk. */
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                pMP3->atEnd = DRMP3_TRUE;
-                return 0; /* Error reading more data. */
-            }
-
-            pMP3->dataSize += bytesRead;
-        }
-    };
-
-    return pcmFramesRead;
-}
-
-static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    drmp3dec_frame_info info;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.pData != NULL);
-
-    if (pMP3->atEnd) {
-        return 0;
-    }
-
-    pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
-    if (pcmFramesRead > 0) {
-        pMP3->pcmFramesConsumedInMP3Frame  = 0;
-        pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-        pMP3->mp3FrameChannels             = info.channels;
-        pMP3->mp3FrameSampleRate           = info.hz;
-    }
-
-    /* Consume the data. */
-    pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
-
-    return pcmFramesRead;
-}
-
-static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) {
-        return drmp3_decode_next_frame_ex__memory(pMP3, pPCMFrames);
-    } else {
-        return drmp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames);
-    }
-}
-
-static drmp3_uint32 drmp3_decode_next_frame(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    return drmp3_decode_next_frame_ex(pMP3, (drmp3d_sample_t*)pMP3->pcmFrames);
-}
-
-#if 0
-static drmp3_uint32 drmp3_seek_next_frame(drmp3* pMP3)
-{
-    drmp3_uint32 pcmFrameCount;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    pcmFrameCount = drmp3_decode_next_frame_ex(pMP3, NULL);
-    if (pcmFrameCount == 0) {
-        return 0;
-    }
-
-    /* We have essentially just skipped past the frame, so just set the remaining samples to 0. */
-    pMP3->currentPCMFrame             += pcmFrameCount;
-    pMP3->pcmFramesConsumedInMP3Frame  = pcmFrameCount;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-
-    return pcmFrameCount;
-}
-#endif
-
-static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(onRead != NULL);
-
-    /* This function assumes the output object has already been reset to 0. Do not do that here, otherwise things will break. */
-    drmp3dec_init(&pMP3->decoder);
-
-    pMP3->onRead = onRead;
-    pMP3->onSeek = onSeek;
-    pMP3->pUserData = pUserData;
-    pMP3->allocationCallbacks = drmp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
-        return DRMP3_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    /* Decode the first frame to confirm that it is indeed a valid MP3 stream. */
-    if (!drmp3_decode_next_frame(pMP3)) {
-        drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);    /* The call above may have allocated memory. Need to make sure it's freed before aborting. */
-        return DRMP3_FALSE; /* Not a valid MP3 stream. */
-    }
-
-    pMP3->channels   = pMP3->mp3FrameChannels;
-    pMP3->sampleRate = pMP3->mp3FrameSampleRate;
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL || onRead == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    DRMP3_ZERO_OBJECT(pMP3);
-    return drmp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks);
-}
-
-
-static size_t drmp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    size_t bytesRemaining;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos);
-
-    bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRMP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead);
-        pMP3->memory.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static drmp3_bool32 drmp3__on_seek_memory(void* pUserData, int byteOffset, drmp3_seek_origin origin)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    if (origin == drmp3_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) {
-                byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pMP3->memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pMP3->memory.currentReadPos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pMP3->memory.currentReadPos += byteOffset;
-    } else {
-        if ((drmp3_uint32)byteOffset <= pMP3->memory.dataSize) {
-            pMP3->memory.currentReadPos = byteOffset;
-        } else {
-            pMP3->memory.currentReadPos = pMP3->memory.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    DRMP3_ZERO_OBJECT(pMP3);
-
-    if (pData == NULL || dataSize == 0) {
-        return DRMP3_FALSE;
-    }
-
-    pMP3->memory.pData = (const drmp3_uint8*)pData;
-    pMP3->memory.dataSize = dataSize;
-    pMP3->memory.currentReadPos = 0;
-
-    return drmp3_init_internal(pMP3, drmp3__on_read_memory, drmp3__on_seek_memory, pMP3, pAllocationCallbacks);
-}
-
-
-#ifndef DR_MP3_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>      /* For wcslen(), wcsrtombs() */
-
-/* drmp3_result_from_errno() is only used inside DR_MP3_NO_STDIO for now. Move this out if it's ever used elsewhere. */
-#include <errno.h>
-static drmp3_result drmp3_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRMP3_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRMP3_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRMP3_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRMP3_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRMP3_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRMP3_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRMP3_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRMP3_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRMP3_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRMP3_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRMP3_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRMP3_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRMP3_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRMP3_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRMP3_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRMP3_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRMP3_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRMP3_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRMP3_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRMP3_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRMP3_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRMP3_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRMP3_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRMP3_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRMP3_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRMP3_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRMP3_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRMP3_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRMP3_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRMP3_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRMP3_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRMP3_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRMP3_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRMP3_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRMP3_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRMP3_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRMP3_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRMP3_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRMP3_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRMP3_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRMP3_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRMP3_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRMP3_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRMP3_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRMP3_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRMP3_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRMP3_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRMP3_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRMP3_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRMP3_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRMP3_ERROR;
-    #endif
-        default: return DRMP3_ERROR;
-    }
-}
-
-static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drmp3_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drmp3_result result = drmp3_result_from_errno(errno);
-        if (result == DRMP3_SUCCESS) {
-            result = DRMP3_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRMP3_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRMP3_HAS_WFOPEN
-    #endif
-#endif
-
-static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-
-#if defined(DRMP3_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drmp3_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drmp3_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRMP3_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drmp3_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drmp3__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRMP3_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRMP3_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRMP3_ERROR;
-    }
-#endif
-
-    return DRMP3_SUCCESS;
-}
-
-
-
-static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-static drmp3_bool32 drmp3__on_seek_stdio(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drmp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-
-    if (drmp3_fopen(&pFile, pFilePath, "rb") != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-
-    if (drmp3_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRMP3_TRUE;
-}
-#endif
-
-DRMP3_API void drmp3_uninit(drmp3* pMP3)
-{
-    if (pMP3 == NULL) {
-        return;
-    }
-    
-#ifndef DR_MP3_NO_STDIO
-    if (pMP3->onRead == drmp3__on_read_stdio) {
-        FILE* pFile = (FILE*)pMP3->pUserData;
-        if (pFile != NULL) {
-            fclose(pFile);
-            pMP3->pUserData = NULL; /* Make sure the file handle is cleared to NULL to we don't attempt to close it a second time. */
-        }
-    }
-#endif
-
-    drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-}
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_f32_to_s16(drmp3_int16* dst, const float* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    drmp3_uint64 i4;
-    drmp3_uint64 sampleCount4;
-
-    /* Unrolled. */
-    i = 0;
-    sampleCount4 = sampleCount >> 2;
-    for (i4 = 0; i4 < sampleCount4; i4 += 1) {
-        float x0 = src[i+0];
-        float x1 = src[i+1];
-        float x2 = src[i+2];
-        float x3 = src[i+3];
-
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-
-        dst[i+0] = (drmp3_int16)x0;
-        dst[i+1] = (drmp3_int16)x1;
-        dst[i+2] = (drmp3_int16)x2;
-        dst[i+3] = (drmp3_int16)x3;
-
-        i += 4;
-    }
-
-    /* Leftover. */
-    for (; i < sampleCount; i += 1) {
-        float x = src[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst[i] = (drmp3_int16)x;
-    }
-}
-#endif
-
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_s16_to_f32(float* dst, const drmp3_int16* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    for (i = 0; i < sampleCount; i += 1) {
-        float x = (float)src[i];
-        x = x * 0.000030517578125f;         /* -32768..32767 to -1..0.999969482421875 */
-        dst[i] = x;
-    }
-}
-#endif
-
-
-static drmp3_uint64 drmp3_read_pcm_frames_raw(drmp3* pMP3, drmp3_uint64 framesToRead, void* pBufferOut)
-{
-    drmp3_uint64 totalFramesRead = 0;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-
-    while (framesToRead > 0) {
-        drmp3_uint32 framesToConsume = (drmp3_uint32)DRMP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead);
-        if (pBufferOut != NULL) {
-        #if defined(DR_MP3_FLOAT_OUTPUT)
-            /* f32 */
-            float* pFramesOutF32 = (float*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(float) * totalFramesRead                   * pMP3->channels);
-            float* pFramesInF32  = (float*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels);
-        #else
-            /* s16 */
-            drmp3_int16* pFramesOutS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(drmp3_int16) * totalFramesRead                   * pMP3->channels);
-            drmp3_int16* pFramesInS16  = (drmp3_int16*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(drmp3_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(drmp3_int16) * framesToConsume * pMP3->channels);
-        #endif
-        }
-
-        pMP3->currentPCMFrame              += framesToConsume;
-        pMP3->pcmFramesConsumedInMP3Frame  += framesToConsume;
-        pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume;
-        totalFramesRead                    += framesToConsume;
-        framesToRead                       -= framesToConsume;
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-        DRMP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0);
-
-        /*
-        At this point we have exhausted our in-memory buffer so we need to re-fill. Note that the sample rate may have changed
-        at this point which means we'll also need to update our sample rate conversion pipeline.
-        */
-        if (drmp3_decode_next_frame(pMP3) == 0) {
-            break;
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    /* Fast path. No conversion required. */
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    /* Slow path. Convert from s16 to f32. */
-    {
-        drmp3_int16 pTempS16[8192];
-        drmp3_uint64 totalPCMFramesRead = 0;
-
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempS16) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16);
-            if (framesJustRead == 0) {
-                break;
-            }
-
-            drmp3_s16_to_f32((float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-
-        return totalPCMFramesRead;
-    }
-#endif
-}
-
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-    /* Fast path. No conversion required. */
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    /* Slow path. Convert from f32 to s16. */
-    {
-        float pTempF32[4096];
-        drmp3_uint64 totalPCMFramesRead = 0;
-
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempF32) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32);
-            if (framesJustRead == 0) {
-                break;
-            }
-
-            drmp3_f32_to_s16((drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-
-        return totalPCMFramesRead;
-    }
-#endif
-}
-
-static void drmp3_reset(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    pMP3->pcmFramesConsumedInMP3Frame = 0;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    pMP3->currentPCMFrame = 0;
-    pMP3->dataSize = 0;
-    pMP3->atEnd = DRMP3_FALSE;
-    drmp3dec_init(&pMP3->decoder);
-}
-
-static drmp3_bool32 drmp3_seek_to_start_of_stream(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onSeek != NULL);
-
-    /* Seek to the start of the stream to begin with. */
-    if (!drmp3__on_seek(pMP3, 0, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-
-    /* Clear any cached data. */
-    drmp3_reset(pMP3);
-    return DRMP3_TRUE;
-}
-
-
-static drmp3_bool32 drmp3_seek_forward_by_pcm_frames__brute_force(drmp3* pMP3, drmp3_uint64 frameOffset)
-{
-    drmp3_uint64 framesRead;
-
-    /*
-    Just using a dumb read-and-discard for now. What would be nice is to parse only the header of the MP3 frame, and then skip over leading
-    frames without spending the time doing a full decode. I cannot see an easy way to do this in minimp3, however, so it may involve some
-    kind of manual processing.
-    */
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    framesRead = drmp3_read_pcm_frames_f32(pMP3, frameOffset, NULL);
-#else
-    framesRead = drmp3_read_pcm_frames_s16(pMP3, frameOffset, NULL);
-#endif
-    if (framesRead != frameOffset) {
-        return DRMP3_FALSE;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3_seek_to_pcm_frame__brute_force(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    if (frameIndex == pMP3->currentPCMFrame) {
-        return DRMP3_TRUE;
-    }
-
-    /*
-    If we're moving foward we just read from where we're at. Otherwise we need to move back to the start of
-    the stream and read from the beginning.
-    */
-    if (frameIndex < pMP3->currentPCMFrame) {
-        /* Moving backward. Move to the start of the stream and then move forward. */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    DRMP3_ASSERT(frameIndex >= pMP3->currentPCMFrame);
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame));
-}
-
-static drmp3_bool32 drmp3_find_closest_seek_point(drmp3* pMP3, drmp3_uint64 frameIndex, drmp3_uint32* pSeekPointIndex)
-{
-    drmp3_uint32 iSeekPoint;
-
-    DRMP3_ASSERT(pSeekPointIndex != NULL);
-
-    *pSeekPointIndex = 0;
-
-    if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) {
-        return DRMP3_FALSE;
-    }
-
-    /* Linear search for simplicity to begin with while I'm getting this thing working. Once it's all working change this to a binary search. */
-    for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) {
-        if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) {
-            break;  /* Found it. */
-        }
-
-        *pSeekPointIndex = iSeekPoint;
-    }
-
-    return DRMP3_TRUE;
-}
-
-static drmp3_bool32 drmp3_seek_to_pcm_frame__seek_table(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    drmp3_seek_point seekPoint;
-    drmp3_uint32 priorSeekPointIndex;
-    drmp3_uint16 iMP3Frame;
-    drmp3_uint64 leftoverFrames;
-
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->pSeekPoints != NULL);
-    DRMP3_ASSERT(pMP3->seekPointCount > 0);
-
-    /* If there is no prior seekpoint it means the target PCM frame comes before the first seek point. Just assume a seekpoint at the start of the file in this case. */
-    if (drmp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) {
-        seekPoint = pMP3->pSeekPoints[priorSeekPointIndex];
-    } else {
-        seekPoint.seekPosInBytes     = 0;
-        seekPoint.pcmFrameIndex      = 0;
-        seekPoint.mp3FramesToDiscard = 0;
-        seekPoint.pcmFramesToDiscard = 0;
-    }
-
-    /* First thing to do is seek to the first byte of the relevant MP3 frame. */
-    if (!drmp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE; /* Failed to seek. */
-    }
-
-    /* Clear any cached data. */
-    drmp3_reset(pMP3);
-
-    /* Whole MP3 frames need to be discarded first. */
-    for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) {
-        drmp3_uint32 pcmFramesRead;
-        drmp3d_sample_t* pPCMFrames;
-
-        /* Pass in non-null for the last frame because we want to ensure the sample rate converter is preloaded correctly. */
-        pPCMFrames = NULL;
-        if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) {
-            pPCMFrames = (drmp3d_sample_t*)pMP3->pcmFrames;
-        }
-
-        /* We first need to decode the next frame. */
-        pcmFramesRead = drmp3_decode_next_frame_ex(pMP3, pPCMFrames);
-        if (pcmFramesRead == 0) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    /* We seeked to an MP3 frame in the raw stream so we need to make sure the current PCM frame is set correctly. */
-    pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard;
-
-    /*
-    Now at this point we can follow the same process as the brute force technique where we just skip over unnecessary MP3 frames and then
-    read-and-discard at least 2 whole MP3 frames.
-    */
-    leftoverFrames = frameIndex - pMP3->currentPCMFrame;
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames);
-}
-
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    if (pMP3 == NULL || pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    if (frameIndex == 0) {
-        return drmp3_seek_to_start_of_stream(pMP3);
-    }
-
-    /* Use the seek table if we have one. */
-    if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) {
-        return drmp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex);
-    } else {
-        return drmp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex);
-    }
-}
-
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount)
-{
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalPCMFrameCount;
-    drmp3_uint64 totalMP3FrameCount;
-
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    /*
-    The way this works is we move back to the start of the stream, iterate over each MP3 frame and calculate the frame count based
-    on our output sample rate, the seek back to the PCM frame we were sitting on before calling this function.
-    */
-
-    /* The stream must support seeking for this to work. */
-    if (pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    /* We'll need to seek back to where we were, so grab the PCM frame we're currently sitting on so we can restore later. */
-    currentPCMFrame = pMP3->currentPCMFrame;
-    
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-
-    totalPCMFrameCount = 0;
-    totalMP3FrameCount = 0;
-
-    for (;;) {
-        drmp3_uint32 pcmFramesInCurrentMP3Frame;
-
-        pcmFramesInCurrentMP3Frame = drmp3_decode_next_frame_ex(pMP3, NULL);
-        if (pcmFramesInCurrentMP3Frame == 0) {
-            break;
-        }
-
-        totalPCMFrameCount += pcmFramesInCurrentMP3Frame;
-        totalMP3FrameCount += 1;
-    }
-
-    /* Finally, we need to seek back to where we were. */
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-
-    if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-        return DRMP3_FALSE;
-    }
-
-    if (pMP3FrameCount != NULL) {
-        *pMP3FrameCount = totalMP3FrameCount;
-    }
-    if (pPCMFrameCount != NULL) {
-        *pPCMFrameCount = totalPCMFrameCount;
-    }
-
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalPCMFrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) {
-        return 0;
-    }
-
-    return totalPCMFrameCount;
-}
-
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalMP3FrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) {
-        return 0;
-    }
-
-    return totalMP3FrameCount;
-}
-
-static void drmp3__accumulate_running_pcm_frame_count(drmp3* pMP3, drmp3_uint32 pcmFrameCountIn, drmp3_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart)
-{
-    float srcRatio;
-    float pcmFrameCountOutF;
-    drmp3_uint32 pcmFrameCountOut;
-
-    srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate;
-    DRMP3_ASSERT(srcRatio > 0);
-
-    pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio);
-    pcmFrameCountOut  = (drmp3_uint32)pcmFrameCountOutF;
-    *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut;
-    *pRunningPCMFrameCount += pcmFrameCountOut;
-}
-
-typedef struct
-{
-    drmp3_uint64 bytePos;
-    drmp3_uint64 pcmFrameIndex; /* <-- After sample rate conversion. */
-} drmp3__seeking_mp3_frame_info;
-
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    drmp3_uint32 seekPointCount;
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalMP3FrameCount;
-    drmp3_uint64 totalPCMFrameCount;
-
-    if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) {
-        return DRMP3_FALSE; /* Invalid args. */
-    }
-
-    seekPointCount = *pSeekPointCount;
-    if (seekPointCount == 0) {
-        return DRMP3_FALSE;  /* The client has requested no seek points. Consider this to be invalid arguments since the client has probably not intended this. */
-    }
-
-    /* We'll need to seek back to the current sample after calculating the seekpoints so we need to go ahead and grab the current location at the top. */
-    currentPCMFrame = pMP3->currentPCMFrame;
-    
-    /* We never do more than the total number of MP3 frames and we limit it to 32-bits. */
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) {
-        return DRMP3_FALSE;
-    }
-
-    /* If there's less than DRMP3_SEEK_LEADING_MP3_FRAMES+1 frames we just report 1 seek point which will be the very start of the stream. */
-    if (totalMP3FrameCount < DRMP3_SEEK_LEADING_MP3_FRAMES+1) {
-        seekPointCount = 1;
-        pSeekPoints[0].seekPosInBytes     = 0;
-        pSeekPoints[0].pcmFrameIndex      = 0;
-        pSeekPoints[0].mp3FramesToDiscard = 0;
-        pSeekPoints[0].pcmFramesToDiscard = 0;
-    } else {
-        drmp3_uint64 pcmFramesBetweenSeekPoints;
-        drmp3__seeking_mp3_frame_info mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES+1];
-        drmp3_uint64 runningPCMFrameCount = 0;
-        float runningPCMFrameCountFractionalPart = 0;
-        drmp3_uint64 nextTargetPCMFrame;
-        drmp3_uint32 iMP3Frame;
-        drmp3_uint32 iSeekPoint;
-
-        if (seekPointCount > totalMP3FrameCount-1) {
-            seekPointCount = (drmp3_uint32)totalMP3FrameCount-1;
-        }
-
-        pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1);
-
-        /*
-        Here is where we actually calculate the seek points. We need to start by moving the start of the stream. We then enumerate over each
-        MP3 frame.
-        */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-
-        /*
-        We need to cache the byte positions of the previous MP3 frames. As a new MP3 frame is iterated, we cycle the byte positions in this
-        array. The value in the first item in this array is the byte position that will be reported in the next seek point.
-        */
-
-        /* We need to initialize the array of MP3 byte positions for the leading MP3 frames. */
-        for (iMP3Frame = 0; iMP3Frame < DRMP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) {
-            drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-
-            /* The byte position of the next frame will be the stream's cursor position, minus whatever is sitting in the buffer. */
-            DRMP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize);
-            mp3FrameInfo[iMP3Frame].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-            mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount;
-
-            /* We need to get information about this frame so we can know how many samples it contained. */
-            pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-            if (pcmFramesInCurrentMP3FrameIn == 0) {
-                return DRMP3_FALSE; /* This should never happen. */
-            }
-
-            drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-        }
-
-        /*
-        At this point we will have extracted the byte positions of the leading MP3 frames. We can now start iterating over each seek point and
-        calculate them.
-        */
-        nextTargetPCMFrame = 0;
-        for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
-            nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
-
-            for (;;) {
-                if (nextTargetPCMFrame < runningPCMFrameCount) {
-                    /* The next seek point is in the current MP3 frame. */
-                    pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                    pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                    pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                    pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                    break;
-                } else {
-                    size_t i;
-                    drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-
-                    /*
-                    The next seek point is not in the current MP3 frame, so continue on to the next one. The first thing to do is cycle the cached
-                    MP3 frame info.
-                    */
-                    for (i = 0; i < DRMP3_COUNTOF(mp3FrameInfo)-1; ++i) {
-                        mp3FrameInfo[i] = mp3FrameInfo[i+1];
-                    }
-
-                    /* Cache previous MP3 frame info. */
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount;
-
-                    /*
-                    Go to the next MP3 frame. This shouldn't ever fail, but just in case it does we just set the seek point and break. If it happens, it
-                    should only ever do it for the last seek point.
-                    */
-                    pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-                    if (pcmFramesInCurrentMP3FrameIn == 0) {
-                        pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                        pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                        pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                        pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                        break;
-                    }
-
-                    drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-                }
-            }
-        }
-
-        /* Finally, we need to seek back to where we were. */
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-            return DRMP3_FALSE;
-        }
-    }
-
-    *pSeekPointCount = seekPointCount;
-    return DRMP3_TRUE;
-}
-
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-
-    if (seekPointCount == 0 || pSeekPoints == NULL) {
-        /* Unbinding. */
-        pMP3->seekPointCount = 0;
-        pMP3->pSeekPoints = NULL;
-    } else {
-        /* Binding. */
-        pMP3->seekPointCount = seekPointCount;
-        pMP3->pSeekPoints = pSeekPoints;
-    }
-
-    return DRMP3_TRUE;
-}
-
-
-static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    float* pFrames = NULL;
-    float temp[4096];
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-
-        /* Reallocate the output buffer if there's not enough room. */
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            float* pNewFrames;
-
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(float);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-
-            pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float)));
-        totalFramesRead += framesJustRead;
-
-        /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-
-    drmp3_uninit(pMP3);
-
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-
-    return pFrames;
-}
-
-static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    drmp3_int16* pFrames = NULL;
-    drmp3_int16 temp[4096];
-
-    DRMP3_ASSERT(pMP3 != NULL);
-
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-
-        /* Reallocate the output buffer if there's not enough room. */
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            drmp3_int16* pNewFrames;
-
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(drmp3_int16);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-
-            pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(drmp3_int16)));
-        totalFramesRead += framesJustRead;
-
-        /* If the number of frames we asked for is less that what we actually read it means we've reached the end. */
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-
-    drmp3_uninit(pMP3);
-
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-
-    return pFrames;
-}
-
-
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-
-
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-
-
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#endif
-
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return drmp3__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return drmp3__malloc_default(sz, NULL);
-    }
-}
-
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drmp3__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drmp3__free_default(p, NULL);
-    }
-}
-
-#endif  /* dr_mp3_c */
-#endif  /*DR_MP3_IMPLEMENTATION*/
-
-/*
-DIFFERENCES BETWEEN minimp3 AND dr_mp3
-======================================
-- First, keep in mind that minimp3 (https://github.com/lieff/minimp3) is where all the real work was done. All of the
-  code relating to the actual decoding remains mostly unmodified, apart from some namespacing changes.
-- dr_mp3 adds a pulling style API which allows you to deliver raw data via callbacks. So, rather than pushing data
-  to the decoder, the decoder _pulls_ data from your callbacks.
-- In addition to callbacks, a decoder can be initialized from a block of memory and a file.
-- The dr_mp3 pull API reads PCM frames rather than whole MP3 frames.
-- dr_mp3 adds convenience APIs for opening and decoding entire files in one go.
-- dr_mp3 is fully namespaced, including the implementation section, which is more suitable when compiling projects
-  as a single translation unit (aka unity builds). At the time of writing this, a unity build is not possible when
-  using minimp3 in conjunction with stb_vorbis. dr_mp3 addresses this.
-*/
-
-/*
-RELEASE NOTES - v0.5.0
-=======================
-Version 0.5.0 has breaking API changes.
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRMP3_MALLOC, DRMP3_REALLOC and DRMP3_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drmp3_allocation_callbacks object to drmp3_init() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drmp3_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drmp3_init_file(&mp3, "my_file.mp3", NULL, &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_mp3 to use defaults which is the same as DRMP3_MALLOC,
-DRMP3_REALLOC and DRMP3_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drmp3 object now takes this extra parameter. These include the following:
-
-    drmp3_init()
-    drmp3_init_file()
-    drmp3_init_memory()
-    drmp3_open_and_read_pcm_frames_f32()
-    drmp3_open_and_read_pcm_frames_s16()
-    drmp3_open_memory_and_read_pcm_frames_f32()
-    drmp3_open_memory_and_read_pcm_frames_s16()
-    drmp3_open_file_and_read_pcm_frames_f32()
-    drmp3_open_file_and_read_pcm_frames_s16()
-
-Renamed APIs
-------------
-The following APIs have been renamed for consistency with other dr_* libraries and to make it clear that they return PCM frame
-counts rather than sample counts.
-
-    drmp3_open_and_read_f32()        -> drmp3_open_and_read_pcm_frames_f32()
-    drmp3_open_and_read_s16()        -> drmp3_open_and_read_pcm_frames_s16()
-    drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
-    drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
-    drmp3_open_file_and_read_f32()   -> drmp3_open_file_and_read_pcm_frames_f32()
-    drmp3_open_file_and_read_s16()   -> drmp3_open_file_and_read_pcm_frames_s16()
-*/
-
-/*
-REVISION HISTORY
-================
-v0.6.27 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-
-v0.6.26 - 2021-01-31
-  - Bring up to date with minimp3.
-
-v0.6.25 - 2020-12-26
-  - Remove DRMP3_DEFAULT_CHANNELS and DRMP3_DEFAULT_SAMPLE_RATE which are leftovers from some removed APIs.
-
-v0.6.24 - 2020-12-07
-  - Fix a typo in version date for 0.6.23.
-
-v0.6.23 - 2020-12-03
-  - Fix an error where a file can be closed twice when initialization of the decoder fails.
-
-v0.6.22 - 2020-12-02
-  - Fix an error where it's possible for a file handle to be left open when initialization of the decoder fails.
-
-v0.6.21 - 2020-11-28
-  - Bring up to date with minimp3.
-
-v0.6.20 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.6.19 - 2020-11-13
-  - Minor code clean up.
-
-v0.6.18 - 2020-11-01
-  - Improve compiler support for older versions of GCC.
-
-v0.6.17 - 2020-09-28
-  - Bring up to date with minimp3.
-
-v0.6.16 - 2020-08-02
-  - Simplify sized types.
-
-v0.6.15 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.6.14 - 2020-07-23
-  - Fix undefined behaviour with memmove().
-
-v0.6.13 - 2020-07-06
-  - Fix a bug when converting from s16 to f32 in drmp3_read_pcm_frames_f32().
-
-v0.6.12 - 2020-06-23
-  - Add include guard for the implementation section.
-
-v0.6.11 - 2020-05-26
-  - Fix use of uninitialized variable error.
-
-v0.6.10 - 2020-05-16
-  - Add compile-time and run-time version querying.
-    - DRMP3_VERSION_MINOR
-    - DRMP3_VERSION_MAJOR
-    - DRMP3_VERSION_REVISION
-    - DRMP3_VERSION_STRING
-    - drmp3_version()
-    - drmp3_version_string()
-
-v0.6.9 - 2020-04-30
-  - Change the `pcm` parameter of drmp3dec_decode_frame() to a `const drmp3_uint8*` for consistency with internal APIs.
-
-v0.6.8 - 2020-04-26
-  - Optimizations to decoding when initializing from memory.
-
-v0.6.7 - 2020-04-25
-  - Fix a compilation error with DR_MP3_NO_STDIO
-  - Optimization to decoding by reducing some data movement.
-
-v0.6.6 - 2020-04-23
-  - Fix a minor bug with the running PCM frame counter.
-
-v0.6.5 - 2020-04-19
-  - Fix compilation error on ARM builds.
-
-v0.6.4 - 2020-04-19
-  - Bring up to date with changes to minimp3.
-
-v0.6.3 - 2020-04-13
-  - Fix some pedantic warnings.
-
-v0.6.2 - 2020-04-10
-  - Fix a crash in drmp3_open_*_and_read_pcm_frames_*() if the output config object is NULL.
-
-v0.6.1 - 2020-04-05
-  - Fix warnings.
-
-v0.6.0 - 2020-04-04
-  - API CHANGE: Remove the pConfig parameter from the following APIs:
-    - drmp3_init()
-    - drmp3_init_memory()
-    - drmp3_init_file()
-  - Add drmp3_init_file_w() for opening a file from a wchar_t encoded path.
-
-v0.5.6 - 2020-02-12
-  - Bring up to date with minimp3.
-
-v0.5.5 - 2020-01-29
-  - Fix a memory allocation bug in high level s16 decoding APIs.
-
-v0.5.4 - 2019-12-02
-  - Fix a possible null pointer dereference when using custom memory allocators for realloc().
-
-v0.5.3 - 2019-11-14
-  - Fix typos in documentation.
-
-v0.5.2 - 2019-11-02
-  - Bring up to date with minimp3.
-
-v0.5.1 - 2019-10-08
-  - Fix a warning with GCC.
-
-v0.5.0 - 2019-10-07
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drmp3_init()
-    - drmp3_init_file()
-    - drmp3_init_memory()
-    - drmp3_open_and_read_pcm_frames_f32()
-    - drmp3_open_and_read_pcm_frames_s16()
-    - drmp3_open_memory_and_read_pcm_frames_f32()
-    - drmp3_open_memory_and_read_pcm_frames_s16()
-    - drmp3_open_file_and_read_pcm_frames_f32()
-    - drmp3_open_file_and_read_pcm_frames_s16()
-  - API CHANGE: Renamed the following APIs:
-    - drmp3_open_and_read_f32()        -> drmp3_open_and_read_pcm_frames_f32()
-    - drmp3_open_and_read_s16()        -> drmp3_open_and_read_pcm_frames_s16()
-    - drmp3_open_memory_and_read_f32() -> drmp3_open_memory_and_read_pcm_frames_f32()
-    - drmp3_open_memory_and_read_s16() -> drmp3_open_memory_and_read_pcm_frames_s16()
-    - drmp3_open_file_and_read_f32()   -> drmp3_open_file_and_read_pcm_frames_f32()
-    - drmp3_open_file_and_read_s16()   -> drmp3_open_file_and_read_pcm_frames_s16()
-
-v0.4.7 - 2019-07-28
-  - Fix a compiler error.
-
-v0.4.6 - 2019-06-14
-  - Fix a compiler error.
-
-v0.4.5 - 2019-06-06
-  - Bring up to date with minimp3.
-
-v0.4.4 - 2019-05-06
-  - Fixes to the VC6 build.
-
-v0.4.3 - 2019-05-05
-  - Use the channel count and/or sample rate of the first MP3 frame instead of DRMP3_DEFAULT_CHANNELS and
-    DRMP3_DEFAULT_SAMPLE_RATE when they are set to 0. To use the old behaviour, just set the relevant property to
-    DRMP3_DEFAULT_CHANNELS or DRMP3_DEFAULT_SAMPLE_RATE.
-  - Add s16 reading APIs
-    - drmp3_read_pcm_frames_s16
-    - drmp3_open_memory_and_read_pcm_frames_s16
-    - drmp3_open_and_read_pcm_frames_s16
-    - drmp3_open_file_and_read_pcm_frames_s16
-  - Add drmp3_get_mp3_and_pcm_frame_count() to the public header section.
-  - Add support for C89.
-  - Change license to choice of public domain or MIT-0.
-
-v0.4.2 - 2019-02-21
-  - Fix a warning.
-
-v0.4.1 - 2018-12-30
-  - Fix a warning.
-
-v0.4.0 - 2018-12-16
-  - API CHANGE: Rename some APIs:
-    - drmp3_read_f32 -> to drmp3_read_pcm_frames_f32
-    - drmp3_seek_to_frame -> drmp3_seek_to_pcm_frame
-    - drmp3_open_and_decode_f32 -> drmp3_open_and_read_pcm_frames_f32
-    - drmp3_open_and_decode_memory_f32 -> drmp3_open_memory_and_read_pcm_frames_f32
-    - drmp3_open_and_decode_file_f32 -> drmp3_open_file_and_read_pcm_frames_f32
-  - Add drmp3_get_pcm_frame_count().
-  - Add drmp3_get_mp3_frame_count().
-  - Improve seeking performance.
-
-v0.3.2 - 2018-09-11
-  - Fix a couple of memory leaks.
-  - Bring up to date with minimp3.
-
-v0.3.1 - 2018-08-25
-  - Fix C++ build.
-
-v0.3.0 - 2018-08-25
-  - Bring up to date with minimp3. This has a minor API change: the "pcm" parameter of drmp3dec_decode_frame() has
-    been changed from short* to void* because it can now output both s16 and f32 samples, depending on whether or
-    not the DR_MP3_FLOAT_OUTPUT option is set.
-
-v0.2.11 - 2018-08-08
-  - Fix a bug where the last part of a file is not read.
-
-v0.2.10 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.2.9 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-  - Bring up to date with minimp3.
-
-v0.2.8 - 2018-08-02
-  - Fix compilation errors with older versions of GCC.
-
-v0.2.7 - 2018-07-13
-  - Bring up to date with minimp3.
-
-v0.2.6 - 2018-07-12
-  - Bring up to date with minimp3.
-
-v0.2.5 - 2018-06-22
-  - Bring up to date with minimp3.
-
-v0.2.4 - 2018-05-12
-  - Bring up to date with minimp3.
-
-v0.2.3 - 2018-04-29
-  - Fix TCC build.
-
-v0.2.2 - 2018-04-28
-  - Fix bug when opening a decoder from memory.
-
-v0.2.1 - 2018-04-27
-  - Efficiency improvements when the decoder reaches the end of the stream.
-
-v0.2 - 2018-04-21
-  - Bring up to date with minimp3.
-  - Start using major.minor.revision versioning.
-
-v0.1d - 2018-03-30
-  - Bring up to date with minimp3.
-
-v0.1c - 2018-03-11
-  - Fix C++ build error.
-
-v0.1b - 2018-03-07
-  - Bring up to date with minimp3.
-
-v0.1a - 2018-02-28
-  - Fix compilation error on GCC/Clang.
-  - Fix some warnings.
-
-v0.1 - 2018-02-xx
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-
-/*
-    https://github.com/lieff/minimp3
-    To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide.
-    This software is distributed without any warranty.
-    See <http://creativecommons.org/publicdomain/zero/1.0/>.
-*/
diff --git a/raylib_pi4_test/external/dr_wav.h b/raylib_pi4_test/external/dr_wav.h
deleted file mode 100644 (file)
index be1438b..0000000
+++ /dev/null
@@ -1,6407 +0,0 @@
-/*
-WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
-dr_wav - v0.12.19 - 2021-02-21
-
-David Reid - mackron@gmail.com
-
-GitHub: https://github.com/mackron/dr_libs
-*/
-
-/*
-RELEASE NOTES - VERSION 0.12
-============================
-Version 0.12 includes breaking changes to custom chunk handling.
-
-
-Changes to Chunk Callback
--------------------------
-dr_wav supports the ability to fire a callback when a chunk is encounted (except for WAVE and FMT chunks). The callback has been updated to include both the
-container (RIFF or Wave64) and the FMT chunk which contains information about the format of the data in the wave file.
-
-Previously, there was no direct way to determine the container, and therefore no way to discriminate against the different IDs in the chunk header (RIFF and
-Wave64 containers encode chunk ID's differently). The `container` parameter can be used to know which ID to use.
-
-Sometimes it can be useful to know the data format at the time the chunk callback is fired. A pointer to a `drwav_fmt` object is now passed into the chunk
-callback which will give you information about the data format. To determine the sample format, use `drwav_fmt_get_format()`. This will return one of the
-`DR_WAVE_FORMAT_*` tokens.
-*/
-
-/*
-Introduction
-============
-This is a single file library. To use it, do something like the following in one .c file.
-    
-    ```c
-    #define DR_WAV_IMPLEMENTATION
-    #include "dr_wav.h"
-    ```
-
-You can then #include this file in other parts of the program as you would with any other header file. Do something like the following to read audio data:
-
-    ```c
-    drwav wav;
-    if (!drwav_init_file(&wav, "my_song.wav", NULL)) {
-        // Error opening WAV file.
-    }
-
-    drwav_int32* pDecodedInterleavedPCMFrames = malloc(wav.totalPCMFrameCount * wav.channels * sizeof(drwav_int32));
-    size_t numberOfSamplesActuallyDecoded = drwav_read_pcm_frames_s32(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
-
-    ...
-
-    drwav_uninit(&wav);
-    ```
-
-If you just want to quickly open and read the audio data in a single operation you can do something like this:
-
-    ```c
-    unsigned int channels;
-    unsigned int sampleRate;
-    drwav_uint64 totalPCMFrameCount;
-    float* pSampleData = drwav_open_file_and_read_pcm_frames_f32("my_song.wav", &channels, &sampleRate, &totalPCMFrameCount, NULL);
-    if (pSampleData == NULL) {
-        // Error opening and reading WAV file.
-    }
-
-    ...
-
-    drwav_free(pSampleData, NULL);
-    ```
-
-The examples above use versions of the API that convert the audio data to a consistent format (32-bit signed PCM, in this case), but you can still output the
-audio data in its internal format (see notes below for supported formats):
-
-    ```c
-    size_t framesRead = drwav_read_pcm_frames(&wav, wav.totalPCMFrameCount, pDecodedInterleavedPCMFrames);
-    ```
-
-You can also read the raw bytes of audio data, which could be useful if dr_wav does not have native support for a particular data format:
-
-    ```c
-    size_t bytesRead = drwav_read_raw(&wav, bytesToRead, pRawDataBuffer);
-    ```
-
-dr_wav can also be used to output WAV files. This does not currently support compressed formats. To use this, look at `drwav_init_write()`,
-`drwav_init_file_write()`, etc. Use `drwav_write_pcm_frames()` to write samples, or `drwav_write_raw()` to write raw data in the "data" chunk.
-
-    ```c
-    drwav_data_format format;
-    format.container = drwav_container_riff;     // <-- drwav_container_riff = normal WAV files, drwav_container_w64 = Sony Wave64.
-    format.format = DR_WAVE_FORMAT_PCM;          // <-- Any of the DR_WAVE_FORMAT_* codes.
-    format.channels = 2;
-    format.sampleRate = 44100;
-    format.bitsPerSample = 16;
-    drwav_init_file_write(&wav, "data/recording.wav", &format, NULL);
-
-    ...
-
-    drwav_uint64 framesWritten = drwav_write_pcm_frames(pWav, frameCount, pSamples);
-    ```
-
-dr_wav has seamless support the Sony Wave64 format. The decoder will automatically detect it and it should Just Work without any manual intervention.
-
-
-Build Options
-=============
-#define these options before including this file.
-
-#define DR_WAV_NO_CONVERSION_API
-  Disables conversion APIs such as `drwav_read_pcm_frames_f32()` and `drwav_s16_to_f32()`.
-
-#define DR_WAV_NO_STDIO
-  Disables APIs that initialize a decoder from a file such as `drwav_init_file()`, `drwav_init_file_write()`, etc.
-
-
-
-Notes
-=====
-- Samples are always interleaved.
-- The default read function does not do any data conversion. Use `drwav_read_pcm_frames_f32()`, `drwav_read_pcm_frames_s32()` and `drwav_read_pcm_frames_s16()`
-  to read and convert audio data to 32-bit floating point, signed 32-bit integer and signed 16-bit integer samples respectively. Tested and supported internal
-  formats include the following:
-  - Unsigned 8-bit PCM
-  - Signed 12-bit PCM
-  - Signed 16-bit PCM
-  - Signed 24-bit PCM
-  - Signed 32-bit PCM
-  - IEEE 32-bit floating point
-  - IEEE 64-bit floating point
-  - A-law and u-law
-  - Microsoft ADPCM
-  - IMA ADPCM (DVI, format code 0x11)
-- dr_wav will try to read the WAV file as best it can, even if it's not strictly conformant to the WAV format.
-*/
-
-#ifndef dr_wav_h
-#define dr_wav_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define DRWAV_STRINGIFY(x)      #x
-#define DRWAV_XSTRINGIFY(x)     DRWAV_STRINGIFY(x)
-
-#define DRWAV_VERSION_MAJOR     0
-#define DRWAV_VERSION_MINOR     12
-#define DRWAV_VERSION_REVISION  19
-#define DRWAV_VERSION_STRING    DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           drwav_int8;
-typedef unsigned char           drwav_uint8;
-typedef   signed short          drwav_int16;
-typedef unsigned short          drwav_uint16;
-typedef   signed int            drwav_int32;
-typedef unsigned int            drwav_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drwav_int64;
-    typedef unsigned __int64    drwav_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drwav_int64;
-    typedef unsigned long long  drwav_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drwav_uint64        drwav_uintptr;
-#else
-    typedef drwav_uint32        drwav_uintptr;
-#endif
-typedef drwav_uint8             drwav_bool8;
-typedef drwav_uint32            drwav_bool32;
-#define DRWAV_TRUE              1
-#define DRWAV_FALSE             0
-
-#if !defined(DRWAV_API)
-    #if defined(DRWAV_DLL)
-        #if defined(_WIN32)
-            #define DRWAV_DLL_IMPORT  __declspec(dllimport)
-            #define DRWAV_DLL_EXPORT  __declspec(dllexport)
-            #define DRWAV_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRWAV_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRWAV_DLL_IMPORT
-                #define DRWAV_DLL_EXPORT
-                #define DRWAV_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-            #define DRWAV_API  DRWAV_DLL_EXPORT
-        #else
-            #define DRWAV_API  DRWAV_DLL_IMPORT
-        #endif
-        #define DRWAV_PRIVATE DRWAV_DLL_PRIVATE
-    #else
-        #define DRWAV_API extern
-        #define DRWAV_PRIVATE static
-    #endif
-#endif
-
-typedef drwav_int32 drwav_result;
-#define DRWAV_SUCCESS                        0
-#define DRWAV_ERROR                         -1   /* A generic error. */
-#define DRWAV_INVALID_ARGS                  -2
-#define DRWAV_INVALID_OPERATION             -3
-#define DRWAV_OUT_OF_MEMORY                 -4
-#define DRWAV_OUT_OF_RANGE                  -5
-#define DRWAV_ACCESS_DENIED                 -6
-#define DRWAV_DOES_NOT_EXIST                -7
-#define DRWAV_ALREADY_EXISTS                -8
-#define DRWAV_TOO_MANY_OPEN_FILES           -9
-#define DRWAV_INVALID_FILE                  -10
-#define DRWAV_TOO_BIG                       -11
-#define DRWAV_PATH_TOO_LONG                 -12
-#define DRWAV_NAME_TOO_LONG                 -13
-#define DRWAV_NOT_DIRECTORY                 -14
-#define DRWAV_IS_DIRECTORY                  -15
-#define DRWAV_DIRECTORY_NOT_EMPTY           -16
-#define DRWAV_END_OF_FILE                   -17
-#define DRWAV_NO_SPACE                      -18
-#define DRWAV_BUSY                          -19
-#define DRWAV_IO_ERROR                      -20
-#define DRWAV_INTERRUPT                     -21
-#define DRWAV_UNAVAILABLE                   -22
-#define DRWAV_ALREADY_IN_USE                -23
-#define DRWAV_BAD_ADDRESS                   -24
-#define DRWAV_BAD_SEEK                      -25
-#define DRWAV_BAD_PIPE                      -26
-#define DRWAV_DEADLOCK                      -27
-#define DRWAV_TOO_MANY_LINKS                -28
-#define DRWAV_NOT_IMPLEMENTED               -29
-#define DRWAV_NO_MESSAGE                    -30
-#define DRWAV_BAD_MESSAGE                   -31
-#define DRWAV_NO_DATA_AVAILABLE             -32
-#define DRWAV_INVALID_DATA                  -33
-#define DRWAV_TIMEOUT                       -34
-#define DRWAV_NO_NETWORK                    -35
-#define DRWAV_NOT_UNIQUE                    -36
-#define DRWAV_NOT_SOCKET                    -37
-#define DRWAV_NO_ADDRESS                    -38
-#define DRWAV_BAD_PROTOCOL                  -39
-#define DRWAV_PROTOCOL_UNAVAILABLE          -40
-#define DRWAV_PROTOCOL_NOT_SUPPORTED        -41
-#define DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRWAV_SOCKET_NOT_SUPPORTED          -44
-#define DRWAV_CONNECTION_RESET              -45
-#define DRWAV_ALREADY_CONNECTED             -46
-#define DRWAV_NOT_CONNECTED                 -47
-#define DRWAV_CONNECTION_REFUSED            -48
-#define DRWAV_NO_HOST                       -49
-#define DRWAV_IN_PROGRESS                   -50
-#define DRWAV_CANCELLED                     -51
-#define DRWAV_MEMORY_ALREADY_MAPPED         -52
-#define DRWAV_AT_END                        -53
-
-/* Common data formats. */
-#define DR_WAVE_FORMAT_PCM          0x1
-#define DR_WAVE_FORMAT_ADPCM        0x2
-#define DR_WAVE_FORMAT_IEEE_FLOAT   0x3
-#define DR_WAVE_FORMAT_ALAW         0x6
-#define DR_WAVE_FORMAT_MULAW        0x7
-#define DR_WAVE_FORMAT_DVI_ADPCM    0x11
-#define DR_WAVE_FORMAT_EXTENSIBLE   0xFFFE
-
-/* Constants. */
-#ifndef DRWAV_MAX_SMPL_LOOPS
-#define DRWAV_MAX_SMPL_LOOPS        1
-#endif
-
-/* Flags to pass into drwav_init_ex(), etc. */
-#define DRWAV_SEQUENTIAL            0x00000001
-
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision);
-DRWAV_API const char* drwav_version_string(void);
-
-typedef enum
-{
-    drwav_seek_origin_start,
-    drwav_seek_origin_current
-} drwav_seek_origin;
-
-typedef enum
-{
-    drwav_container_riff,
-    drwav_container_w64,
-    drwav_container_rf64
-} drwav_container;
-
-typedef struct
-{
-    union
-    {
-        drwav_uint8 fourcc[4];
-        drwav_uint8 guid[16];
-    } id;
-
-    /* The size in bytes of the chunk. */
-    drwav_uint64 sizeInBytes;
-
-    /*
-    RIFF = 2 byte alignment.
-    W64  = 8 byte alignment.
-    */
-    unsigned int paddingSize;
-} drwav_chunk_header;
-
-typedef struct
-{
-    /*
-    The format tag exactly as specified in the wave file's "fmt" chunk. This can be used by applications
-    that require support for data formats not natively supported by dr_wav.
-    */
-    drwav_uint16 formatTag;
-
-    /* The number of channels making up the audio data. When this is set to 1 it is mono, 2 is stereo, etc. */
-    drwav_uint16 channels;
-
-    /* The sample rate. Usually set to something like 44100. */
-    drwav_uint32 sampleRate;
-
-    /* Average bytes per second. You probably don't need this, but it's left here for informational purposes. */
-    drwav_uint32 avgBytesPerSec;
-
-    /* Block align. This is equal to the number of channels * bytes per sample. */
-    drwav_uint16 blockAlign;
-
-    /* Bits per sample. */
-    drwav_uint16 bitsPerSample;
-
-    /* The size of the extended data. Only used internally for validation, but left here for informational purposes. */
-    drwav_uint16 extendedSize;
-
-    /*
-    The number of valid bits per sample. When <formatTag> is equal to WAVE_FORMAT_EXTENSIBLE, <bitsPerSample>
-    is always rounded up to the nearest multiple of 8. This variable contains information about exactly how
-    many bits are valid per sample. Mainly used for informational purposes.
-    */
-    drwav_uint16 validBitsPerSample;
-
-    /* The channel mask. Not used at the moment. */
-    drwav_uint32 channelMask;
-
-    /* The sub-format, exactly as specified by the wave file. */
-    drwav_uint8 subFormat[16];
-} drwav_fmt;
-
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT);
-
-
-/*
-Callback for when data is read. Return value is the number of bytes actually read.
-
-pUserData   [in]  The user data that was passed to drwav_init() and family.
-pBufferOut  [out] The output buffer.
-bytesToRead [in]  The number of bytes to read.
-
-Returns the number of bytes actually read.
-
-A return value of less than bytesToRead indicates the end of the stream. Do _not_ return from this callback until
-either the entire bytesToRead is filled or you have reached the end of the stream.
-*/
-typedef size_t (* drwav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-
-/*
-Callback for when data is written. Returns value is the number of bytes actually written.
-
-pUserData    [in]  The user data that was passed to drwav_init_write() and family.
-pData        [out] A pointer to the data to write.
-bytesToWrite [in]  The number of bytes to write.
-
-Returns the number of bytes actually written.
-
-If the return value differs from bytesToWrite, it indicates an error.
-*/
-typedef size_t (* drwav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite);
-
-/*
-Callback for when data needs to be seeked.
-
-pUserData [in] The user data that was passed to drwav_init() and family.
-offset    [in] The number of bytes to move, relative to the origin. Will never be negative.
-origin    [in] The origin of the seek - the current position or the start of the stream.
-
-Returns whether or not the seek was successful.
-
-Whether or not it is relative to the beginning or current position is determined by the "origin" parameter which will be either drwav_seek_origin_start or
-drwav_seek_origin_current.
-*/
-typedef drwav_bool32 (* drwav_seek_proc)(void* pUserData, int offset, drwav_seek_origin origin);
-
-/*
-Callback for when drwav_init_ex() finds a chunk.
-
-pChunkUserData    [in] The user data that was passed to the pChunkUserData parameter of drwav_init_ex() and family.
-onRead            [in] A pointer to the function to call when reading.
-onSeek            [in] A pointer to the function to call when seeking.
-pReadSeekUserData [in] The user data that was passed to the pReadSeekUserData parameter of drwav_init_ex() and family.
-pChunkHeader      [in] A pointer to an object containing basic header information about the chunk. Use this to identify the chunk.
-container         [in] Whether or not the WAV file is a RIFF or Wave64 container. If you're unsure of the difference, assume RIFF.
-pFMT              [in] A pointer to the object containing the contents of the "fmt" chunk.
-
-Returns the number of bytes read + seeked.
-
-To read data from the chunk, call onRead(), passing in pReadSeekUserData as the first parameter. Do the same for seeking with onSeek(). The return value must
-be the total number of bytes you have read _plus_ seeked.
-
-Use the `container` argument to discriminate the fields in `pChunkHeader->id`. If the container is `drwav_container_riff` or `drwav_container_rf64` you should
-use `id.fourcc`, otherwise you should use `id.guid`.
-
-The `pFMT` parameter can be used to determine the data format of the wave file. Use `drwav_fmt_get_format()` to get the sample format, which will be one of the
-`DR_WAVE_FORMAT_*` identifiers. 
-
-The read pointer will be sitting on the first byte after the chunk's header. You must not attempt to read beyond the boundary of the chunk.
-*/
-typedef drwav_uint64 (* drwav_chunk_proc)(void* pChunkUserData, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_chunk_header* pChunkHeader, drwav_container container, const drwav_fmt* pFMT);
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drwav_allocation_callbacks;
-
-/* Structure for internal use. Only used for loaders opened with drwav_init_memory(). */
-typedef struct
-{
-    const drwav_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drwav__memory_stream;
-
-/* Structure for internal use. Only used for writers opened with drwav_init_memory_write(). */
-typedef struct
-{
-    void** ppData;
-    size_t* pDataSize;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t currentWritePos;
-} drwav__memory_stream_write;
-
-typedef struct
-{
-    drwav_container container;  /* RIFF, W64. */
-    drwav_uint32 format;        /* DR_WAVE_FORMAT_* */
-    drwav_uint32 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 bitsPerSample;
-} drwav_data_format;
-
-
-/* See the following for details on the 'smpl' chunk: https://sites.google.com/site/musicgapi/technical-documents/wav-file-format#smpl */
-typedef struct
-{
-    drwav_uint32 cuePointId;
-    drwav_uint32 type;
-    drwav_uint32 start;
-    drwav_uint32 end;
-    drwav_uint32 fraction;
-    drwav_uint32 playCount;
-} drwav_smpl_loop;
-
- typedef struct
-{
-    drwav_uint32 manufacturer;
-    drwav_uint32 product;
-    drwav_uint32 samplePeriod;
-    drwav_uint32 midiUnityNotes;
-    drwav_uint32 midiPitchFraction;
-    drwav_uint32 smpteFormat;
-    drwav_uint32 smpteOffset;
-    drwav_uint32 numSampleLoops;
-    drwav_uint32 samplerData;
-    drwav_smpl_loop loops[DRWAV_MAX_SMPL_LOOPS];
-} drwav_smpl;
-
-typedef struct
-{
-    /* A pointer to the function to call when more data is needed. */
-    drwav_read_proc onRead;
-
-    /* A pointer to the function to call when data needs to be written. Only used when the drwav object is opened in write mode. */
-    drwav_write_proc onWrite;
-
-    /* A pointer to the function to call when the wav file needs to be seeked. */
-    drwav_seek_proc onSeek;
-
-    /* The user data to pass to callbacks. */
-    void* pUserData;
-
-    /* Allocation callbacks. */
-    drwav_allocation_callbacks allocationCallbacks;
-
-
-    /* Whether or not the WAV file is formatted as a standard RIFF file or W64. */
-    drwav_container container;
-
-
-    /* Structure containing format information exactly as specified by the wav file. */
-    drwav_fmt fmt;
-
-    /* The sample rate. Will be set to something like 44100. */
-    drwav_uint32 sampleRate;
-
-    /* The number of channels. This will be set to 1 for monaural streams, 2 for stereo, etc. */
-    drwav_uint16 channels;
-
-    /* The bits per sample. Will be set to something like 16, 24, etc. */
-    drwav_uint16 bitsPerSample;
-
-    /* Equal to fmt.formatTag, or the value specified by fmt.subFormat if fmt.formatTag is equal to 65534 (WAVE_FORMAT_EXTENSIBLE). */
-    drwav_uint16 translatedFormatTag;
-
-    /* The total number of PCM frames making up the audio data. */
-    drwav_uint64 totalPCMFrameCount;
-
-
-    /* The size in bytes of the data chunk. */
-    drwav_uint64 dataChunkDataSize;
-    
-    /* The position in the stream of the first data byte of the data chunk. This is used for seeking. */
-    drwav_uint64 dataChunkDataPos;
-
-    /* The number of bytes remaining in the data chunk. */
-    drwav_uint64 bytesRemaining;
-
-
-    /*
-    Only used in sequential write mode. Keeps track of the desired size of the "data" chunk at the point of initialization time. Always
-    set to 0 for non-sequential writes and when the drwav object is opened in read mode. Used for validation.
-    */
-    drwav_uint64 dataChunkDataSizeTargetWrite;
-
-    /* Keeps track of whether or not the wav writer was initialized in sequential mode. */
-    drwav_bool32 isSequentialWrite;
-
-
-    /* smpl chunk. */
-    drwav_smpl smpl;
-
-
-    /* A hack to avoid a DRWAV_MALLOC() when opening a decoder with drwav_init_memory(). */
-    drwav__memory_stream memoryStream;
-    drwav__memory_stream_write memoryStreamWrite;
-
-    /* Generic data for compressed formats. This data is shared across all block-compressed formats. */
-    struct
-    {
-        drwav_uint64 iCurrentPCMFrame;  /* The index of the next PCM frame that will be read by drwav_read_*(). This is used with "totalPCMFrameCount" to ensure we don't read excess samples at the end of the last block. */
-    } compressed;
-    
-    /* Microsoft ADPCM specific data. */
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_uint16 predictor[2];
-        drwav_int32  delta[2];
-        drwav_int32  cachedFrames[4];  /* Samples are stored in this cache during decoding. */
-        drwav_uint32 cachedFrameCount;
-        drwav_int32  prevFrames[2][2]; /* The previous 2 samples for each channel (2 channels at most). */
-    } msadpcm;
-
-    /* IMA ADPCM specific data. */
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_int32  predictor[2];
-        drwav_int32  stepIndex[2];
-        drwav_int32  cachedFrames[16]; /* Samples are stored in this cache during decoding. */
-        drwav_uint32 cachedFrameCount;
-    } ima;
-} drwav;
-
-
-/*
-Initializes a pre-allocated drwav object for reading.
-
-pWav                         [out]          A pointer to the drwav object being initialized.
-onRead                       [in]           The function to call when data needs to be read from the client.
-onSeek                       [in]           The function to call when the read position of the client data needs to move.
-onChunk                      [in, optional] The function to call when a chunk is enumerated at initialized time.
-pUserData, pReadSeekUserData [in, optional] A pointer to application defined data that will be passed to onRead and onSeek.
-pChunkUserData               [in, optional] A pointer to application defined data that will be passed to onChunk.
-flags                        [in, optional] A set of flags for controlling how things are loaded.
-
-Returns true if successful; false otherwise.
-
-Close the loader with drwav_uninit().
-
-This is the lowest level function for initializing a WAV file. You can also use drwav_init_file() and drwav_init_memory()
-to open the stream from a file or from a block of memory respectively.
-
-Possible values for flags:
-  DRWAV_SEQUENTIAL: Never perform a backwards seek while loading. This disables the chunk callback and will cause this function
-                    to return as soon as the data chunk is found. Any chunks after the data chunk will be ignored.
-
-drwav_init() is equivalent to "drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0);".
-
-The onChunk callback is not called for the WAVE or FMT chunks. The contents of the FMT chunk can be read from pWav->fmt
-after the function returns.
-
-See also: drwav_init_file(), drwav_init_memory(), drwav_uninit()
-*/
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Initializes a pre-allocated drwav object for writing.
-
-onWrite   [in]           The function to call when data needs to be written.
-onSeek    [in]           The function to call when the write position needs to move.
-pUserData [in, optional] A pointer to application defined data that will be passed to onWrite and onSeek.
-
-Returns true if successful; false otherwise.
-
-Close the writer with drwav_uninit().
-
-This is the lowest level function for initializing a WAV file. You can also use drwav_init_file_write() and drwav_init_memory_write()
-to open the stream from a file or from a block of memory respectively.
-
-If the total sample count is known, you can use drwav_init_write_sequential(). This avoids the need for dr_wav to perform
-a post-processing step for storing the total sample count and the size of the data chunk which requires a backwards seek.
-
-See also: drwav_init_file_write(), drwav_init_memory_write(), drwav_uninit()
-*/
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Utility function to determine the target size of the entire data to be written (including all headers and chunks).
-
-Returns the target size in bytes.
-
-Useful if the application needs to know the size to allocate.
-
-Only writing to the RIFF chunk and one data chunk is currently supported.
-
-See also: drwav_init_write(), drwav_init_file_write(), drwav_init_memory_write()
-*/
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-
-/*
-Uninitializes the given drwav object.
-
-Use this only for objects initialized with drwav_init*() functions (drwav_init(), drwav_init_ex(), drwav_init_write(), drwav_init_write_sequential()).
-*/
-DRWAV_API drwav_result drwav_uninit(drwav* pWav);
-
-
-/*
-Reads raw audio data.
-
-This is the lowest level function for reading audio data. It simply reads the given number of
-bytes of the raw internal sample data.
-
-Consider using drwav_read_pcm_frames_s16(), drwav_read_pcm_frames_s32() or drwav_read_pcm_frames_f32() for
-reading sample data in a consistent format.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of bytes actually read.
-*/
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut);
-
-/*
-Reads up to the specified number of PCM frames from the WAV file.
-
-The output data will be in the file's internal format, converted to native-endian byte order. Use
-drwav_read_pcm_frames_s16/f32/s32() to read data in a specific format.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached or
-you have requested more PCM frames than can possibly fit in the output buffer.
-
-This function will only work when sample data is of a fixed size and uncompressed. If you are
-using a compressed format consider using drwav_read_raw() or drwav_read_pcm_frames_s16/s32/f32().
-
-pBufferOut can be NULL in which case a seek will be performed.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-
-/*
-Seeks to the given PCM frame.
-
-Returns true if successful; false otherwise.
-*/
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex);
-
-
-/*
-Writes raw audio data.
-
-Returns the number of bytes actually written. If this differs from bytesToWrite, it indicates an error.
-*/
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData);
-
-/*
-Writes PCM frames.
-
-Returns the number of PCM frames written.
-
-Input samples need to be in native-endian byte order. On big-endian architectures the input data will be converted to
-little-endian. Use drwav_write_raw() to write raw audio data without performing any conversion.
-*/
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-
-
-/* Conversion Utilities */
-#ifndef DR_WAV_NO_CONVERSION_API
-
-/*
-Reads a chunk of audio data and converts it to signed 16-bit PCM samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 32-bit PCM samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 32-bit floating point samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to signed 16-bit PCM samples. */
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-
-/*
-Reads a chunk of audio data and converts it to IEEE 32-bit floating point samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 16-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 32-bit PCM samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to IEEE 32-bit floating point samples. */
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-
-/*
-Reads a chunk of audio data and converts it to signed 32-bit PCM samples.
-
-pBufferOut can be NULL in which case a seek will be performed.
-
-Returns the number of PCM frames actually read.
-
-If the return value is less than <framesToRead> it means the end of the file has been reached.
-*/
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-
-/* Low-level function for converting unsigned 8-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 16-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount);
-
-/* Low-level function for converting signed 24-bit PCM samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 32-bit floating point samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount);
-
-/* Low-level function for converting IEEE 64-bit floating point samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount);
-
-/* Low-level function for converting A-law samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-/* Low-level function for converting u-law samples to signed 32-bit PCM samples. */
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-
-#endif  /* DR_WAV_NO_CONVERSION_API */
-
-
-/* High-Level Convenience Helpers */
-
-#ifndef DR_WAV_NO_STDIO
-/*
-Helper for initializing a wave file for reading using stdio.
-
-This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Helper for initializing a wave file for writing using stdio.
-
-This holds the internal FILE object until drwav_uninit() is called. Keep this in mind if you're caching drwav
-objects because the operating system may restrict the number of file handles an application can have open at
-any given time.
-*/
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif  /* DR_WAV_NO_STDIO */
-
-/*
-Helper for initializing a loader from a pre-allocated memory buffer.
-
-This does not create a copy of the data. It is up to the application to ensure the buffer remains valid for
-the lifetime of the drwav object.
-
-The buffer should contain the contents of the entire wave file, not just the sample data.
-*/
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Helper for initializing a writer which outputs data to a memory buffer.
-
-dr_wav will manage the memory allocations, however it is up to the caller to free the data with drwav_free().
-
-The buffer will remain allocated even after drwav_uninit() is called. The buffer should not be considered valid
-until after drwav_uninit() has been called.
-*/
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-
-#ifndef DR_WAV_NO_CONVERSION_API
-/*
-Opens and reads an entire wav file in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_STDIO
-/*
-Opens and decodes an entire wav file in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-/*
-Opens and decodes an entire wav file from a block of memory in a single operation.
-
-The return value is a heap-allocated buffer containing the audio data. Use drwav_free() to free the buffer.
-*/
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-
-/* Frees data that was allocated internally by dr_wav. */
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks);
-
-/* Converts bytes from a wav stream to a sized type of native endian. */
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data);
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data);
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data);
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data);
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data);
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data);
-
-/* Compares a GUID for the purpose of checking the type of a Wave64 chunk. */
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16]);
-
-/* Compares a four-character-code for the purpose of checking the type of a RIFF chunk. */
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* dr_wav_h */
-
-
-/************************************************************************************************************************************************************
- ************************************************************************************************************************************************************
-
- IMPLEMENTATION
-
- ************************************************************************************************************************************************************
- ************************************************************************************************************************************************************/
-#if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-#ifndef dr_wav_c
-#define dr_wav_c
-
-#include <stdlib.h>
-#include <string.h> /* For memcpy(), memset() */
-#include <limits.h> /* For INT_MAX */
-
-#ifndef DR_WAV_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#endif
-
-/* Standard library stuff. */
-#ifndef DRWAV_ASSERT
-#include <assert.h>
-#define DRWAV_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRWAV_MALLOC
-#define DRWAV_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRWAV_REALLOC
-#define DRWAV_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRWAV_FREE
-#define DRWAV_FREE(p)                      free((p))
-#endif
-#ifndef DRWAV_COPY_MEMORY
-#define DRWAV_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRWAV_ZERO_MEMORY
-#define DRWAV_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRWAV_ZERO_OBJECT
-#define DRWAV_ZERO_OBJECT(p)               DRWAV_ZERO_MEMORY((p), sizeof(*p))
-#endif
-
-#define drwav_countof(x)                   (sizeof(x) / sizeof(x[0]))
-#define drwav_align(x, a)                  ((((x) + (a) - 1) / (a)) * (a))
-#define drwav_min(a, b)                    (((a) < (b)) ? (a) : (b))
-#define drwav_max(a, b)                    (((a) > (b)) ? (a) : (b))
-#define drwav_clamp(x, lo, hi)             (drwav_max((lo), drwav_min((hi), (x))))
-
-#define DRWAV_MAX_SIMD_VECTOR_SIZE         64  /* 64 for AVX-512 in the future. */
-
-/* CPU architecture. */
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRWAV_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRWAV_X86
-#elif defined(__arm__) || defined(_M_ARM)
-    #define DRWAV_ARM
-#endif
-
-#ifdef _MSC_VER
-    #define DRWAV_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define DRWAV_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRWAV_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRWAV_INLINE __inline
-#else
-    #define DRWAV_INLINE
-#endif
-
-#if defined(SIZE_MAX)
-    #define DRWAV_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRWAV_SIZE_MAX  ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRWAV_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRWAV_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = DRWAV_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = DRWAV_VERSION_REVISION;
-    }
-}
-
-DRWAV_API const char* drwav_version_string(void)
-{
-    return DRWAV_VERSION_STRING;
-}
-
-/*
-These limits are used for basic validation when initializing the decoder. If you exceed these limits, first of all: what on Earth are
-you doing?! (Let me know, I'd be curious!) Second, you can adjust these by #define-ing them before the dr_wav implementation.
-*/
-#ifndef DRWAV_MAX_SAMPLE_RATE
-#define DRWAV_MAX_SAMPLE_RATE       384000
-#endif
-#ifndef DRWAV_MAX_CHANNELS
-#define DRWAV_MAX_CHANNELS          256
-#endif
-#ifndef DRWAV_MAX_BITS_PER_SAMPLE
-#define DRWAV_MAX_BITS_PER_SAMPLE   64
-#endif
-
-static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00};    /* 66666972-912E-11CF-A5D6-28DB04C10000 */
-static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 65766177-ACF3-11D3-8CD1-00C04F8EDB8A */
-/*static const drwav_uint8 drwavGUID_W64_JUNK[16] = {0x6A,0x75,0x6E,0x6B, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};*/    /* 6B6E756A-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 20746D66-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 74636166-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 61746164-ACF3-11D3-8CD1-00C04F8EDB8A */
-static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};    /* 6C706D73-ACF3-11D3-8CD1-00C04F8EDB8A */
-
-
-static DRWAV_INLINE int drwav__is_little_endian(void)
-{
-#if defined(DRWAV_X86) || defined(DRWAV_X64)
-    return DRWAV_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRWAV_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-
-static DRWAV_INLINE void drwav__bytes_to_guid(const drwav_uint8* data, drwav_uint8* guid)
-{
-    int i;
-    for (i = 0; i < 16; ++i) {
-        guid[i] = data[i];
-    }
-}
-
-
-static DRWAV_INLINE drwav_uint16 drwav__bswap16(drwav_uint16 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-
-static DRWAV_INLINE drwav_uint32 drwav__bswap32(drwav_uint32 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            drwav_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRWAV_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-static DRWAV_INLINE drwav_uint64 drwav__bswap64(drwav_uint64 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    /* Weird "<< 32" bitshift is required for C89 because it doesn't support 64-bit constants. Should be optimized out by a good compiler. */
-    return ((n & ((drwav_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drwav_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drwav_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drwav_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drwav_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drwav_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drwav_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drwav_uint64)0x000000FF      )) << 56);
-#endif
-}
-
-
-static DRWAV_INLINE drwav_int16 drwav__bswap_s16(drwav_int16 n)
-{
-    return (drwav_int16)drwav__bswap16((drwav_uint16)n);
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s16(drwav_int16* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s16(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE void drwav__bswap_s24(drwav_uint8* p)
-{
-    drwav_uint8 t;
-    t = p[0];
-    p[0] = p[2];
-    p[2] = t;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s24(drwav_uint8* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        drwav_uint8* pSample = pSamples + (iSample*3);
-        drwav__bswap_s24(pSample);
-    }
-}
-
-
-static DRWAV_INLINE drwav_int32 drwav__bswap_s32(drwav_int32 n)
-{
-    return (drwav_int32)drwav__bswap32((drwav_uint32)n);
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_s32(drwav_int32* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s32(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE float drwav__bswap_f32(float n)
-{
-    union {
-        drwav_uint32 i;
-        float f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap32(x.i);
-
-    return x.f;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_f32(float* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f32(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE double drwav__bswap_f64(double n)
-{
-    union {
-        drwav_uint64 i;
-        double f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap64(x.i);
-
-    return x.f;
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_f64(double* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f64(pSamples[iSample]);
-    }
-}
-
-
-static DRWAV_INLINE void drwav__bswap_samples_pcm(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    /* Assumes integer PCM. Floating point PCM is done in drwav__bswap_samples_ieee(). */
-    switch (bytesPerSample)
-    {
-        case 2: /* s16, s12 (loosely packed) */
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case 3: /* s24 */
-        {
-            drwav__bswap_samples_s24((drwav_uint8*)pSamples, sampleCount);
-        } break;
-        case 4: /* s32 */
-        {
-            drwav__bswap_samples_s32((drwav_int32*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-static DRWAV_INLINE void drwav__bswap_samples_ieee(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-    #if 0   /* Contributions welcome for f16 support. */
-        case 2: /* f16 */
-        {
-            drwav__bswap_samples_f16((drwav_float16*)pSamples, sampleCount);
-        } break;
-    #endif
-        case 4: /* f32 */
-        {
-            drwav__bswap_samples_f32((float*)pSamples, sampleCount);
-        } break;
-        case 8: /* f64 */
-        {
-            drwav__bswap_samples_f64((double*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-static DRWAV_INLINE void drwav__bswap_samples(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample, drwav_uint16 format)
-{
-    switch (format)
-    {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            drwav__bswap_samples_pcm(pSamples, sampleCount, bytesPerSample);
-        } break;
-
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            drwav__bswap_samples_ieee(pSamples, sampleCount, bytesPerSample);
-        } break;
-
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        default:
-        {
-            /* Unsupported format. */
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-
-
-DRWAV_PRIVATE void* drwav__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_MALLOC(sz);
-}
-
-DRWAV_PRIVATE void* drwav__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_REALLOC(p, sz);
-}
-
-DRWAV_PRIVATE void drwav__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRWAV_FREE(p);
-}
-
-
-DRWAV_PRIVATE void* drwav__malloc_from_callbacks(size_t sz, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-DRWAV_PRIVATE void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            DRWAV_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-DRWAV_PRIVATE void drwav__free_from_callbacks(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-
-DRWAV_PRIVATE drwav_allocation_callbacks drwav_copy_allocation_callbacks_or_defaults(const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        /* Copy. */
-        return *pAllocationCallbacks;
-    } else {
-        /* Defaults. */
-        drwav_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drwav__malloc_default;
-        allocationCallbacks.onRealloc = drwav__realloc_default;
-        allocationCallbacks.onFree    = drwav__free_default;
-        return allocationCallbacks;
-    }
-}
-
-
-static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
-{
-    return
-        formatTag == DR_WAVE_FORMAT_ADPCM ||
-        formatTag == DR_WAVE_FORMAT_DVI_ADPCM;
-}
-
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_riff(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 2);
-}
-
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_w64(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 8);
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-
-DRWAV_PRIVATE drwav_result drwav__read_chunk_header(drwav_read_proc onRead, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_chunk_header* pHeaderOut)
-{
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        drwav_uint8 sizeInBytes[4];
-
-        if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) {
-            return DRWAV_AT_END;
-        }
-
-        if (onRead(pUserData, sizeInBytes, 4) != 4) {
-            return DRWAV_INVALID_FILE;
-        }
-
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u32(sizeInBytes);
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_riff(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 8;
-    } else {
-        drwav_uint8 sizeInBytes[8];
-
-        if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) {
-            return DRWAV_AT_END;
-        }
-
-        if (onRead(pUserData, sizeInBytes, 8) != 8) {
-            return DRWAV_INVALID_FILE;
-        }
-
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u64(sizeInBytes) - 24;    /* <-- Subtract 24 because w64 includes the size of the header. */
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_w64(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 24;
-    }
-
-    return DRWAV_SUCCESS;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__seek_forward(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    drwav_uint64 bytesRemainingToSeek = offset;
-    while (bytesRemainingToSeek > 0) {
-        if (bytesRemainingToSeek > 0x7FFFFFFF) {
-            if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek -= 0x7FFFFFFF;
-        } else {
-            if (!onSeek(pUserData, (int)bytesRemainingToSeek, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek = 0;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__seek_from_start(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return onSeek(pUserData, (int)offset, drwav_seek_origin_start);
-    }
-
-    /* Larger than 32-bit seek. */
-    if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-
-    for (;;) {
-        if (offset <= 0x7FFFFFFF) {
-            return onSeek(pUserData, (int)offset, drwav_seek_origin_current);
-        }
-
-        if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        offset -= 0x7FFFFFFF;
-    }
-
-    /* Should never get here. */
-    /*return DRWAV_TRUE; */
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav__read_fmt(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_fmt* fmtOut)
-{
-    drwav_chunk_header header;
-    drwav_uint8 fmt[16];
-
-    if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-
-    /* Skip non-fmt chunks. */
-    while (((container == drwav_container_riff || container == drwav_container_rf64) && !drwav_fourcc_equal(header.id.fourcc, "fmt ")) || (container == drwav_container_w64 && !drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT))) {
-        if (!drwav__seek_forward(onSeek, header.sizeInBytes + header.paddingSize, pUserData)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.sizeInBytes + header.paddingSize;
-
-        /* Try the next header. */
-        if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    /* Validation. */
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        if (!drwav_fourcc_equal(header.id.fourcc, "fmt ")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        if (!drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT)) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    if (onRead(pUserData, fmt, sizeof(fmt)) != sizeof(fmt)) {
-        return DRWAV_FALSE;
-    }
-    *pRunningBytesReadOut += sizeof(fmt);
-
-    fmtOut->formatTag      = drwav_bytes_to_u16(fmt + 0);
-    fmtOut->channels       = drwav_bytes_to_u16(fmt + 2);
-    fmtOut->sampleRate     = drwav_bytes_to_u32(fmt + 4);
-    fmtOut->avgBytesPerSec = drwav_bytes_to_u32(fmt + 8);
-    fmtOut->blockAlign     = drwav_bytes_to_u16(fmt + 12);
-    fmtOut->bitsPerSample  = drwav_bytes_to_u16(fmt + 14);
-
-    fmtOut->extendedSize       = 0;
-    fmtOut->validBitsPerSample = 0;
-    fmtOut->channelMask        = 0;
-    memset(fmtOut->subFormat, 0, sizeof(fmtOut->subFormat));
-
-    if (header.sizeInBytes > 16) {
-        drwav_uint8 fmt_cbSize[2];
-        int bytesReadSoFar = 0;
-
-        if (onRead(pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) {
-            return DRWAV_FALSE;    /* Expecting more data. */
-        }
-        *pRunningBytesReadOut += sizeof(fmt_cbSize);
-
-        bytesReadSoFar = 18;
-
-        fmtOut->extendedSize = drwav_bytes_to_u16(fmt_cbSize);
-        if (fmtOut->extendedSize > 0) {
-            /* Simple validation. */
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                if (fmtOut->extendedSize != 22) {
-                    return DRWAV_FALSE;
-                }
-            }
-
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                drwav_uint8 fmtext[22];
-                if (onRead(pUserData, fmtext, fmtOut->extendedSize) != fmtOut->extendedSize) {
-                    return DRWAV_FALSE;    /* Expecting more data. */
-                }
-
-                fmtOut->validBitsPerSample = drwav_bytes_to_u16(fmtext + 0);
-                fmtOut->channelMask        = drwav_bytes_to_u32(fmtext + 2);
-                drwav__bytes_to_guid(fmtext + 6, fmtOut->subFormat);
-            } else {
-                if (!onSeek(pUserData, fmtOut->extendedSize, drwav_seek_origin_current)) {
-                    return DRWAV_FALSE;
-                }
-            }
-            *pRunningBytesReadOut += fmtOut->extendedSize;
-
-            bytesReadSoFar += fmtOut->extendedSize;
-        }
-
-        /* Seek past any leftover bytes. For w64 the leftover will be defined based on the chunk size. */
-        if (!onSeek(pUserData, (int)(header.sizeInBytes - bytesReadSoFar), drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += (header.sizeInBytes - bytesReadSoFar);
-    }
-
-    if (header.paddingSize > 0) {
-        if (!onSeek(pUserData, header.paddingSize, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.paddingSize;
-    }
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_PRIVATE size_t drwav__on_read(drwav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
-{
-    size_t bytesRead;
-
-    DRWAV_ASSERT(onRead != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-
-    bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
-    *pCursor += bytesRead;
-    return bytesRead;
-}
-
-#if 0
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek(drwav_seek_proc onSeek, void* pUserData, int offset, drwav_seek_origin origin, drwav_uint64* pCursor)
-{
-    DRWAV_ASSERT(onSeek != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-
-    if (!onSeek(pUserData, offset, origin)) {
-        return DRWAV_FALSE;
-    }
-
-    if (origin == drwav_seek_origin_start) {
-        *pCursor = offset;
-    } else {
-        *pCursor += offset;
-    }
-
-    return DRWAV_TRUE;
-}
-#endif
-
-
-
-DRWAV_PRIVATE drwav_uint32 drwav_get_bytes_per_pcm_frame(drwav* pWav)
-{
-    /*
-    The bytes per frame is a bit ambiguous. It can be either be based on the bits per sample, or the block align. The way I'm doing it here
-    is that if the bits per sample is a multiple of 8, use floor(bitsPerSample*channels/8), otherwise fall back to the block align.
-    */
-    if ((pWav->bitsPerSample & 0x7) == 0) {
-        /* Bits per sample is a multiple of 8. */
-        return (pWav->bitsPerSample * pWav->fmt.channels) >> 3;
-    } else {
-        return pWav->fmt.blockAlign;
-    }
-}
-
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT)
-{
-    if (pFMT == NULL) {
-        return 0;
-    }
-
-    if (pFMT->formatTag != DR_WAVE_FORMAT_EXTENSIBLE) {
-        return pFMT->formatTag;
-    } else {
-        return drwav_bytes_to_u16(pFMT->subFormat);    /* Only the first two bytes are required. */
-    }
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_preinit(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onRead == NULL || onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onRead    = onRead;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pReadSeekUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags)
-{
-    /* This function assumes drwav_preinit() has been called beforehand. */
-
-    drwav_uint64 cursor;    /* <-- Keeps track of the byte position so we can seek to specific locations. */
-    drwav_bool32 sequential;
-    drwav_uint8 riff[4];
-    drwav_fmt fmt;
-    unsigned short translatedFormatTag;
-    drwav_bool32 foundDataChunk;
-    drwav_uint64 dataChunkSize = 0; /* <-- Important! Don't explicitly set this to 0 anywhere else. Calculation of the size of the data chunk is performed in different paths depending on the container. */
-    drwav_uint64 sampleCountFromFactChunk = 0;  /* Same as dataChunkSize - make sure this is the only place this is initialized to 0. */
-    drwav_uint64 chunkSize;
-
-    cursor = 0;
-    sequential = (flags & DRWAV_SEQUENTIAL) != 0;
-
-    /* The first 4 bytes should be the RIFF identifier. */
-    if (drwav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) {
-        return DRWAV_FALSE;
-    }
-
-    /*
-    The first 4 bytes can be used to identify the container. For RIFF files it will start with "RIFF" and for
-    w64 it will start with "riff".
-    */
-    if (drwav_fourcc_equal(riff, "RIFF")) {
-        pWav->container = drwav_container_riff;
-    } else if (drwav_fourcc_equal(riff, "riff")) {
-        int i;
-        drwav_uint8 riff2[12];
-
-        pWav->container = drwav_container_w64;
-
-        /* Check the rest of the GUID for validity. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) {
-            return DRWAV_FALSE;
-        }
-
-        for (i = 0; i < 12; ++i) {
-            if (riff2[i] != drwavGUID_W64_RIFF[i+4]) {
-                return DRWAV_FALSE;
-            }
-        }
-    } else if (drwav_fourcc_equal(riff, "RF64")) {
-        pWav->container = drwav_container_rf64;
-    } else {
-        return DRWAV_FALSE;   /* Unknown or unsupported container. */
-    }
-
-
-    if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-        drwav_uint8 chunkSizeBytes[4];
-        drwav_uint8 wave[4];
-
-        /* RIFF/WAVE */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_bytes_to_u32(chunkSizeBytes) < 36) {
-                return DRWAV_FALSE;    /* Chunk size should always be at least 36 bytes. */
-            }
-        } else {
-            if (drwav_bytes_to_u32(chunkSizeBytes) != 0xFFFFFFFF) {
-                return DRWAV_FALSE;    /* Chunk size should always be set to -1/0xFFFFFFFF for RF64. The actual size is retrieved later. */
-            }
-        }
-
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_fourcc_equal(wave, "WAVE")) {
-            return DRWAV_FALSE;    /* Expecting "WAVE". */
-        }
-    } else {
-        drwav_uint8 chunkSizeBytes[8];
-        drwav_uint8 wave[16];
-
-        /* W64 */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-
-        if (drwav_bytes_to_u64(chunkSizeBytes) < 80) {
-            return DRWAV_FALSE;
-        }
-
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_guid_equal(wave, drwavGUID_W64_WAVE)) {
-            return DRWAV_FALSE;
-        }
-    }
-
-
-    /* For RF64, the "ds64" chunk must come next, before the "fmt " chunk. */
-    if (pWav->container == drwav_container_rf64) {
-        drwav_uint8 sizeBytes[8];
-        drwav_uint64 bytesRemainingInChunk;
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-
-        if (!drwav_fourcc_equal(header.id.fourcc, "ds64")) {
-            return DRWAV_FALSE; /* Expecting "ds64". */
-        }
-
-        bytesRemainingInChunk = header.sizeInBytes + header.paddingSize;
-
-        /* We don't care about the size of the RIFF chunk - skip it. */
-        if (!drwav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        cursor += 8;
-
-
-        /* Next 8 bytes is the size of the "data" chunk. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        dataChunkSize = drwav_bytes_to_u64(sizeBytes);
-
-
-        /* Next 8 bytes is the same count which we would usually derived from the FACT chunk if it was available. */
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        sampleCountFromFactChunk = drwav_bytes_to_u64(sizeBytes);
-
-
-        /* Skip over everything else. */
-        if (!drwav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor += bytesRemainingInChunk;
-    }
-
-
-    /* The next bytes should be the "fmt " chunk. */
-    if (!drwav__read_fmt(pWav->onRead, pWav->onSeek, pWav->pUserData, pWav->container, &cursor, &fmt)) {
-        return DRWAV_FALSE;    /* Failed to read the "fmt " chunk. */
-    }
-
-    /* Basic validation. */
-    if ((fmt.sampleRate    == 0 || fmt.sampleRate    > DRWAV_MAX_SAMPLE_RATE)     ||
-        (fmt.channels      == 0 || fmt.channels      > DRWAV_MAX_CHANNELS)        ||
-        (fmt.bitsPerSample == 0 || fmt.bitsPerSample > DRWAV_MAX_BITS_PER_SAMPLE) ||
-        fmt.blockAlign == 0) {
-        return DRWAV_FALSE; /* Probably an invalid WAV file. */
-    }
-
-
-    /* Translate the internal format. */
-    translatedFormatTag = fmt.formatTag;
-    if (translatedFormatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-        translatedFormatTag = drwav_bytes_to_u16(fmt.subFormat + 0);
-    }
-
-
-    /*
-    We need to enumerate over each chunk for two reasons:
-      1) The "data" chunk may not be the next one
-      2) We may want to report each chunk back to the client
-    
-    In order to correctly report each chunk back to the client we will need to keep looping until the end of the file.
-    */
-    foundDataChunk = DRWAV_FALSE;
-
-    /* The next chunk we care about is the "data" chunk. This is not necessarily the next chunk so we'll need to loop. */
-    for (;;)
-    {
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            if (!foundDataChunk) {
-                return DRWAV_FALSE;
-            } else {
-                break;  /* Probably at the end of the file. Get out of the loop. */
-            }
-        }
-
-        /* Tell the client about this chunk. */
-        if (!sequential && onChunk != NULL) {
-            drwav_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt);
-
-            /*
-            dr_wav may need to read the contents of the chunk, so we now need to seek back to the position before
-            we called the callback.
-            */
-            if (callbackBytesRead > 0) {
-                if (!drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData)) {
-                    return DRWAV_FALSE;
-                }
-            }
-        }
-        
-
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-
-        chunkSize = header.sizeInBytes;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "data")) {
-                foundDataChunk = DRWAV_TRUE;
-                if (pWav->container != drwav_container_rf64) {  /* The data chunk size for RF64 will always be set to 0xFFFFFFFF here. It was set to it's true value earlier. */
-                    dataChunkSize = chunkSize;
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA)) {
-                foundDataChunk = DRWAV_TRUE;
-                dataChunkSize = chunkSize;
-            }
-        }
-
-        /*
-        If at this point we have found the data chunk and we're running in sequential mode, we need to break out of this loop. The reason for
-        this is that we would otherwise require a backwards seek which sequential mode forbids.
-        */
-        if (foundDataChunk && sequential) {
-            break;
-        }
-
-        /* Optional. Get the total sample count from the FACT chunk. This is useful for compressed formats. */
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_fourcc_equal(header.id.fourcc, "fact")) {
-                drwav_uint32 sampleCount;
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 4;
-
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-
-                /*
-                The sample count in the "fact" chunk is either unreliable, or I'm not understanding it properly. For now I am only enabling this
-                for Microsoft ADPCM formats.
-                */
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    sampleCountFromFactChunk = sampleCount;
-                } else {
-                    sampleCountFromFactChunk = 0;
-                }
-            }
-        } else if (pWav->container == drwav_container_w64) {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_FACT)) {
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 8;
-
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-            }
-        } else if (pWav->container == drwav_container_rf64) {
-            /* We retrieved the sample count from the ds64 chunk earlier so no need to do that here. */
-        }
-
-        /* "smpl" chunk. */
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "smpl")) {
-                drwav_uint8 smplHeaderData[36];    /* 36 = size of the smpl header section, not including the loop data. */
-                if (chunkSize >= sizeof(smplHeaderData)) {
-                    drwav_uint64 bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplHeaderData, sizeof(smplHeaderData), &cursor);
-                    chunkSize -= bytesJustRead;
-
-                    if (bytesJustRead == sizeof(smplHeaderData)) {
-                        drwav_uint32 iLoop;
-
-                        pWav->smpl.manufacturer      = drwav_bytes_to_u32(smplHeaderData+0);
-                        pWav->smpl.product           = drwav_bytes_to_u32(smplHeaderData+4);
-                        pWav->smpl.samplePeriod      = drwav_bytes_to_u32(smplHeaderData+8);
-                        pWav->smpl.midiUnityNotes    = drwav_bytes_to_u32(smplHeaderData+12);
-                        pWav->smpl.midiPitchFraction = drwav_bytes_to_u32(smplHeaderData+16);
-                        pWav->smpl.smpteFormat       = drwav_bytes_to_u32(smplHeaderData+20);
-                        pWav->smpl.smpteOffset       = drwav_bytes_to_u32(smplHeaderData+24);
-                        pWav->smpl.numSampleLoops    = drwav_bytes_to_u32(smplHeaderData+28);
-                        pWav->smpl.samplerData       = drwav_bytes_to_u32(smplHeaderData+32);
-
-                        for (iLoop = 0; iLoop < pWav->smpl.numSampleLoops && iLoop < drwav_countof(pWav->smpl.loops); ++iLoop) {
-                            drwav_uint8 smplLoopData[24];  /* 24 = size of a loop section in the smpl chunk. */
-                            bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplLoopData, sizeof(smplLoopData), &cursor);
-                            chunkSize -= bytesJustRead;
-
-                            if (bytesJustRead == sizeof(smplLoopData)) {
-                                pWav->smpl.loops[iLoop].cuePointId = drwav_bytes_to_u32(smplLoopData+0);
-                                pWav->smpl.loops[iLoop].type       = drwav_bytes_to_u32(smplLoopData+4);
-                                pWav->smpl.loops[iLoop].start      = drwav_bytes_to_u32(smplLoopData+8);
-                                pWav->smpl.loops[iLoop].end        = drwav_bytes_to_u32(smplLoopData+12);
-                                pWav->smpl.loops[iLoop].fraction   = drwav_bytes_to_u32(smplLoopData+16);
-                                pWav->smpl.loops[iLoop].playCount  = drwav_bytes_to_u32(smplLoopData+20);
-                            } else {
-                                break;  /* Break from the smpl loop for loop. */
-                            }
-                        }
-                    }
-                } else {
-                    /* Looks like invalid data. Ignore the chunk. */
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_SMPL)) {
-                /*
-                This path will be hit when a W64 WAV file contains a smpl chunk. I don't have a sample file to test this path, so a contribution
-                is welcome to add support for this.
-                */
-            }
-        }
-
-        /* Make sure we seek past the padding. */
-        chunkSize += header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData)) {
-            break;
-        }
-        cursor += chunkSize;
-
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-    }
-
-    /* If we haven't found a data chunk, return an error. */
-    if (!foundDataChunk) {
-        return DRWAV_FALSE;
-    }
-
-    /* We may have moved passed the data chunk. If so we need to move back. If running in sequential mode we can assume we are already sitting on the data chunk. */
-    if (!sequential) {
-        if (!drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor = pWav->dataChunkDataPos;
-    }
-    
-
-    /* At this point we should be sitting on the first byte of the raw audio data. */
-
-    pWav->fmt                 = fmt;
-    pWav->sampleRate          = fmt.sampleRate;
-    pWav->channels            = fmt.channels;
-    pWav->bitsPerSample       = fmt.bitsPerSample;
-    pWav->bytesRemaining      = dataChunkSize;
-    pWav->translatedFormatTag = translatedFormatTag;
-    pWav->dataChunkDataSize   = dataChunkSize;
-
-    if (sampleCountFromFactChunk != 0) {
-        pWav->totalPCMFrameCount = sampleCountFromFactChunk;
-    } else {
-        pWav->totalPCMFrameCount = dataChunkSize / drwav_get_bytes_per_pcm_frame(pWav);
-
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-
-            /* Make sure any trailing partial block is accounted for. */
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-
-            /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
-            totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-        }
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-
-            /* Make sure any trailing partial block is accounted for. */
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-
-            /* We decode two samples per byte. There will be blockCount headers in the data chunk. This is enough to know how to calculate the total PCM frame count. */
-            totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-
-            /* The header includes a decoded sample for each channel which acts as the initial predictor sample. */
-            pWav->totalPCMFrameCount += blockCount;
-        }
-    }
-
-    /* Some formats only support a certain number of channels. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        if (pWav->channels > 2) {
-            return DRWAV_FALSE;
-        }
-    }
-
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    /*
-    I use libsndfile as a benchmark for testing, however in the version I'm using (from the Windows installer on the libsndfile website),
-    it appears the total sample count libsndfile uses for MS-ADPCM is incorrect. It would seem they are computing the total sample count
-    from the number of blocks, however this results in the inclusion of extra silent samples at the end of the last block. The correct
-    way to know the total sample count is to inspect the "fact" chunk, which should always be present for compressed formats, and should
-    always include the sample count. This little block of code below is only used to emulate the libsndfile logic so I can properly run my
-    correctness tests against libsndfile, and is disabled by default.
-    */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels;  /* x2 because two samples per byte. */
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels;
-    }
-#endif
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-
-
-DRWAV_PRIVATE drwav_uint32 drwav__riff_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 24 = "fmt " chunk. */
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-
-    return (drwav_uint32)chunkSize; /* Safe cast due to the clamp above. */
-}
-
-DRWAV_PRIVATE drwav_uint32 drwav__data_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    if (dataChunkSize <= 0xFFFFFFFFUL) {
-        return (drwav_uint32)dataChunkSize;
-    } else {
-        return 0xFFFFFFFFUL;
-    }
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 dataSubchunkPaddingSize = drwav__chunk_padding_size_w64(dataChunkSize);
-
-    return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize;   /* +24 because W64 includes the size of the GUID and size fields. */
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    return 24 + dataChunkSize;        /* +24 because W64 includes the size of the GUID and size fields. */
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 36 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize); /* 4 = "WAVE". 36 = "ds64" chunk. 24 = "fmt " chunk. */
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-
-    return chunkSize;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    return dataChunkSize;
-}
-
-
-DRWAV_PRIVATE size_t drwav__write(drwav* pWav, const void* pData, size_t dataSize)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    /* Generic write. Assumes no byte reordering required. */
-    return pWav->onWrite(pWav->pUserData, pData, dataSize);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u16ne_to_le(drwav* pWav, drwav_uint16 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap16(value);
-    }
-
-    return drwav__write(pWav, &value, 2);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u32ne_to_le(drwav* pWav, drwav_uint32 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap32(value);
-    }
-
-    return drwav__write(pWav, &value, 4);
-}
-
-DRWAV_PRIVATE size_t drwav__write_u64ne_to_le(drwav* pWav, drwav_uint64 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap64(value);
-    }
-
-    return drwav__write(pWav, &value, 8);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_preinit_write(drwav* pWav, const drwav_data_format* pFormat, drwav_bool32 isSequential, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onWrite == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    if (!isSequential && onSeek == NULL) {
-        return DRWAV_FALSE; /* <-- onSeek is required when in non-sequential mode. */
-    }
-
-    /* Not currently supporting compressed formats. Will need to add support for the "fact" chunk before we enable this. */
-    if (pFormat->format == DR_WAVE_FORMAT_EXTENSIBLE) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_ADPCM || pFormat->format == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return DRWAV_FALSE;
-    }
-
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onWrite   = onWrite;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;    /* Invalid allocation callbacks. */
-    }
-
-    pWav->fmt.formatTag = (drwav_uint16)pFormat->format;
-    pWav->fmt.channels = (drwav_uint16)pFormat->channels;
-    pWav->fmt.sampleRate = pFormat->sampleRate;
-    pWav->fmt.avgBytesPerSec = (drwav_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8);
-    pWav->fmt.blockAlign = (drwav_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8);
-    pWav->fmt.bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->fmt.extendedSize = 0;
-    pWav->isSequentialWrite = isSequential;
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    /* The function assumes drwav_preinit_write() was called beforehand. */
-
-    size_t runningPos = 0;
-    drwav_uint64 initialDataChunkSize = 0;
-    drwav_uint64 chunkSizeFMT;
-
-    /*
-    The initial values for the "RIFF" and "data" chunks depends on whether or not we are initializing in sequential mode or not. In
-    sequential mode we set this to its final values straight away since they can be calculated from the total sample count. In non-
-    sequential mode we initialize it all to zero and fill it out in drwav_uninit() using a backwards seek.
-    */
-    if (pWav->isSequentialWrite) {
-        initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8;
-
-        /*
-        The RIFF container has a limit on the number of samples. drwav is not allowing this. There's no practical limits for Wave64
-        so for the sake of simplicity I'm not doing any validation for that.
-        */
-        if (pFormat->container == drwav_container_riff) {
-            if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
-                return DRWAV_FALSE; /* Not enough room to store every sample. */
-            }
-        }
-    }
-
-    pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize;
-
-
-    /* "RIFF" chunk. */
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeRIFF = 28 + (drwav_uint32)initialDataChunkSize;   /* +28 = "WAVE" + [sizeof "fmt " chunk] */
-        runningPos += drwav__write(pWav, "RIFF", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize;            /* +24 because W64 includes the size of the GUID and size fields. */
-        runningPos += drwav__write(pWav, drwavGUID_W64_RIFF, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, drwavGUID_W64_WAVE, 16);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "RF64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);               /* Always 0xFFFFFFFF for RF64. Set to a proper value in the "ds64" chunk. */
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    }
-
-    
-    /* "ds64" chunk (RF64 only). */
-    if (pFormat->container == drwav_container_rf64) {
-        drwav_uint32 initialds64ChunkSize = 28;                                 /* 28 = [Size of RIFF (8 bytes)] + [Size of DATA (8 bytes)] + [Sample Count (8 bytes)] + [Table Length (4 bytes)]. Table length always set to 0. */
-        drwav_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize;    /* +8 for the ds64 header. */
-
-        runningPos += drwav__write(pWav, "ds64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, initialds64ChunkSize);     /* Size of ds64. */
-        runningPos += drwav__write_u64ne_to_le(pWav, initialRiffChunkSize);     /* Size of RIFF. Set to true value at the end. */
-        runningPos += drwav__write_u64ne_to_le(pWav, initialDataChunkSize);     /* Size of DATA. Set to true value at the end. */
-        runningPos += drwav__write_u64ne_to_le(pWav, totalSampleCount);         /* Sample count. */
-        runningPos += drwav__write_u32ne_to_le(pWav, 0);                        /* Table length. Always set to zero in our case since we're not doing any other chunks than "DATA". */
-    }
-
-
-    /* "fmt " chunk. */
-    if (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64) {
-        chunkSizeFMT = 16;
-        runningPos += drwav__write(pWav, "fmt ", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, (drwav_uint32)chunkSizeFMT);
-    } else if (pFormat->container == drwav_container_w64) {
-        chunkSizeFMT = 40;
-        runningPos += drwav__write(pWav, drwavGUID_W64_FMT, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeFMT);
-    }
-
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.formatTag);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.channels);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
-
-    /* "data" chunk. */
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize;     /* +24 because W64 includes the size of the GUID and size fields. */
-        runningPos += drwav__write(pWav, drwavGUID_W64_DATA, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);   /* Always set to 0xFFFFFFFF for RF64. The true size of the data chunk is specified in the ds64 chunk. */
-    }
-
-    /* Set some properties for the client's convenience. */
-    pWav->container = pFormat->container;
-    pWav->channels = (drwav_uint16)pFormat->channels;
-    pWav->sampleRate = pFormat->sampleRate;
-    pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
-    pWav->dataChunkDataPos = runningPos;
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write__internal(pWav, pFormat, 0);               /* DRWAV_FALSE = Not Sequential */
-}
-
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount); /* DRWAV_TRUE = Sequential */
-}
-
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    /* Casting totalSampleCount to drwav_int64 for VC6 compatibility. No issues in practice because nobody is going to exhaust the whole 63 bits. */
-    drwav_uint64 targetDataSizeBytes = (drwav_uint64)((drwav_int64)totalSampleCount * pFormat->channels * pFormat->bitsPerSample/8.0);
-    drwav_uint64 riffChunkSizeBytes;
-    drwav_uint64 fileSizeBytes = 0;
-
-    if (pFormat->container == drwav_container_riff) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_riff(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);   /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
-    } else if (pFormat->container == drwav_container_w64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_w64(targetDataSizeBytes);
-        fileSizeBytes = riffChunkSizeBytes;
-    } else if (pFormat->container == drwav_container_rf64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_rf64(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);   /* +8 because WAV doesn't include the size of the ChunkID and ChunkSize fields. */
-    }
-
-    return fileSizeBytes;
-}
-
-
-#ifndef DR_WAV_NO_STDIO
-
-/* drwav_result_from_errno() is only used for fopen() and wfopen() so putting it inside DR_WAV_NO_STDIO for now. If something else needs this later we can move it out. */
-#include <errno.h>
-DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRWAV_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRWAV_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRWAV_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRWAV_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRWAV_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRWAV_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRWAV_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRWAV_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRWAV_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRWAV_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRWAV_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRWAV_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRWAV_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRWAV_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRWAV_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRWAV_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRWAV_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRWAV_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRWAV_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRWAV_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRWAV_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRWAV_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRWAV_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRWAV_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRWAV_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRWAV_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRWAV_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRWAV_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRWAV_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRWAV_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRWAV_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRWAV_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRWAV_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRWAV_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRWAV_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRWAV_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRWAV_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRWAV_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRWAV_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRWAV_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRWAV_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRWAV_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRWAV_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRWAV_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRWAV_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRWAV_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRWAV_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRWAV_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRWAV_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRWAV_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRWAV_ERROR;
-    #endif
-        default: return DRWAV_ERROR;
-    }
-}
-
-DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drwav_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drwav_result result = drwav_result_from_errno(errno);
-        if (result == DRWAV_SUCCESS) {
-            result = DRWAV_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return DRWAV_SUCCESS;
-}
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRWAV_HAS_WFOPEN
-    #endif
-#endif
-
-DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-#if defined(DRWAV_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drwav_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drwav_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        DRWAV_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drwav_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)drwav__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRWAV_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        DRWAV_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return DRWAV_ERROR;
-    }
-#endif
-
-    return DRWAV_SUCCESS;
-}
-
-
-DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-
-DRWAV_PRIVATE size_t drwav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_stdio(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drwav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFile, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-
-    result = drwav_preinit(pWav, drwav__on_read_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-
-    result = drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    result = drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "wb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-
-    /* This takes ownership of the FILE* object. */
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-#endif  /* DR_WAV_NO_STDIO */
-
-
-DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos);
-
-    bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        DRWAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead);
-        pWav->memoryStream.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) {
-                return DRWAV_FALSE; /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pWav->memoryStream.currentReadPos < (size_t)-offset) {
-                return DRWAV_FALSE; /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pWav->memoryStream.currentReadPos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStream.dataSize) {
-            pWav->memoryStream.currentReadPos = offset;
-        } else {
-            return DRWAV_FALSE; /* Trying to seek too far forward. */
-        }
-    }
-    
-    return DRWAV_TRUE;
-}
-
-DRWAV_PRIVATE size_t drwav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos);
-
-    bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos;
-    if (bytesRemaining < bytesToWrite) {
-        /* Need to reallocate. */
-        void* pNewData;
-        size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2;
-
-        /* If doubling wasn't enough, just make it the minimum required size to write the data. */
-        if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) {
-            newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite;
-        }
-
-        pNewData = drwav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks);
-        if (pNewData == NULL) {
-            return 0;
-        }
-
-        *pWav->memoryStreamWrite.ppData = pNewData;
-        pWav->memoryStreamWrite.dataCapacity = newDataCapacity;
-    }
-
-    DRWAV_COPY_MEMORY(((drwav_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite);
-
-    pWav->memoryStreamWrite.currentWritePos += bytesToWrite;
-    if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) {
-        pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos;
-    }
-
-    *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize;
-
-    return bytesToWrite;
-}
-
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory_write(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) {
-                offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) {
-                offset = -(int)pWav->memoryStreamWrite.currentWritePos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pWav->memoryStreamWrite.currentWritePos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStreamWrite.dataSize) {
-            pWav->memoryStreamWrite.currentWritePos = offset;
-        } else {
-            pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-    
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (data == NULL || dataSize == 0) {
-        return DRWAV_FALSE;
-    }
-
-    if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    pWav->memoryStream.data = (const drwav_uint8*)data;
-    pWav->memoryStream.dataSize = dataSize;
-    pWav->memoryStream.currentReadPos = 0;
-
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_init_memory_write__internal(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppData == NULL || pDataSize == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    *ppData = NULL; /* Important because we're using realloc()! */
-    *pDataSize = 0;
-
-    if (!drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_memory, drwav__on_seek_memory_write, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-
-    pWav->memoryStreamWrite.ppData = ppData;
-    pWav->memoryStreamWrite.pDataSize = pDataSize;
-    pWav->memoryStreamWrite.dataSize = 0;
-    pWav->memoryStreamWrite.dataCapacity = 0;
-    pWav->memoryStreamWrite.currentWritePos = 0;
-
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    return drwav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-
-
-
-DRWAV_API drwav_result drwav_uninit(drwav* pWav)
-{
-    drwav_result result = DRWAV_SUCCESS;
-
-    if (pWav == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-
-    /*
-    If the drwav object was opened in write mode we'll need to finalize a few things:
-      - Make sure the "data" chunk is aligned to 16-bits for RIFF containers, or 64 bits for W64 containers.
-      - Set the size of the "data" chunk.
-    */
-    if (pWav->onWrite != NULL) {
-        drwav_uint32 paddingSize = 0;
-
-        /* Padding. Do not adjust pWav->dataChunkDataSize - this should not include the padding. */
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            paddingSize = drwav__chunk_padding_size_riff(pWav->dataChunkDataSize);
-        } else {
-            paddingSize = drwav__chunk_padding_size_w64(pWav->dataChunkDataSize);
-        }
-        
-        if (paddingSize > 0) {
-            drwav_uint64 paddingData = 0;
-            drwav__write(pWav, &paddingData, paddingSize);  /* Byte order does not matter for this. */
-        }
-
-        /*
-        Chunk sizes. When using sequential mode, these will have been filled in at initialization time. We only need
-        to do this when using non-sequential mode.
-        */
-        if (pWav->onSeek && !pWav->isSequentialWrite) {
-            if (pWav->container == drwav_container_riff) {
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, 4, drwav_seek_origin_start)) {
-                    drwav_uint32 riffChunkSize = drwav__riff_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
-                    drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_w64) {
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, 16, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_rf64) {
-                /* We only need to update the ds64 chunk. The "RIFF" and "data" chunks always have their sizes set to 0xFFFFFFFF for RF64. */
-                int ds64BodyPos = 12 + 8;
-
-                /* The "RIFF" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-
-                /* The "data" chunk size. */
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            }
-        }
-
-        /* Validation for sequential mode. */
-        if (pWav->isSequentialWrite) {
-            if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
-                result = DRWAV_INVALID_FILE;
-            }
-        }
-    }
-
-#ifndef DR_WAV_NO_STDIO
-    /*
-    If we opened the file with drwav_open_file() we will want to close the file handle. We can know whether or not drwav_open_file()
-    was used by looking at the onRead and onSeek callbacks.
-    */
-    if (pWav->onRead == drwav__on_read_stdio || pWav->onWrite == drwav__on_write_stdio) {
-        fclose((FILE*)pWav->pUserData);
-    }
-#endif
-
-    return result;
-}
-
-
-
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut)
-{
-    size_t bytesRead;
-
-    if (pWav == NULL || bytesToRead == 0) {
-        return 0;
-    }
-
-    if (bytesToRead > pWav->bytesRemaining) {
-        bytesToRead = (size_t)pWav->bytesRemaining;
-    }
-
-    if (pBufferOut != NULL) {
-        bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead);
-    } else {
-        /* We need to seek. If we fail, we need to read-and-discard to make sure we get a good byte count. */
-        bytesRead = 0;
-        while (bytesRead < bytesToRead) {
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > 0x7FFFFFFF) {
-                bytesToSeek = 0x7FFFFFFF;
-            }
-
-            if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, drwav_seek_origin_current) == DRWAV_FALSE) {
-                break;
-            }
-
-            bytesRead += bytesToSeek;
-        }
-
-        /* When we get here we may need to read-and-discard some data. */
-        while (bytesRead < bytesToRead) {
-            drwav_uint8 buffer[4096];
-            size_t bytesSeeked;
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > sizeof(buffer)) {
-                bytesToSeek = sizeof(buffer);
-            }
-
-            bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek);
-            bytesRead += bytesSeeked;
-
-            if (bytesSeeked < bytesToSeek) {
-                break;  /* Reached the end. */
-            }
-        }
-    }
-
-    pWav->bytesRemaining -= bytesRead;
-    return bytesRead;
-}
-
-
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint32 bytesPerFrame;
-    drwav_uint64 bytesToRead;   /* Intentionally uint64 instead of size_t so we can do a check that we're not reading too much on 32-bit builds. */
-
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    /* Cannot use this function for compressed formats. */
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        return 0;
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    bytesToRead = framesToRead * bytesPerFrame;
-    if (bytesToRead > DRWAV_SIZE_MAX) {
-        bytesToRead = (DRWAV_SIZE_MAX / bytesPerFrame) * bytesPerFrame; /* Round the number of bytes to read to a clean frame boundary. */
-    }
-
-    /*
-    Doing an explicit check here just to make it clear that we don't want to be attempt to read anything if there's no bytes to read. There
-    *could* be a time where it evaluates to 0 due to overflowing.
-    */
-    if (bytesToRead == 0) {
-        return 0;
-    }
-
-    return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-
-    if (pBufferOut != NULL) {
-        drwav__bswap_samples(pBufferOut, framesRead*pWav->channels, drwav_get_bytes_per_pcm_frame(pWav)/pWav->channels, pWav->translatedFormatTag);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    } else {
-        return drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
-    }
-}
-
-
-
-DRWAV_PRIVATE drwav_bool32 drwav_seek_to_first_pcm_frame(drwav* pWav)
-{
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE; /* No seeking in write mode. */
-    }
-
-    if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        pWav->compressed.iCurrentPCMFrame = 0;
-
-        /* Cached data needs to be cleared for compressed formats. */
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->msadpcm);
-        } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->ima);
-        } else {
-            DRWAV_ASSERT(DRWAV_FALSE);  /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
-        }
-    }
-    
-    pWav->bytesRemaining = pWav->dataChunkDataSize;
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
-{
-    /* Seeking should be compatible with wave files > 2GB. */
-
-    if (pWav == NULL || pWav->onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-
-    /* No seeking in write mode. */
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-
-    /* If there are no samples, just return DRWAV_TRUE without doing anything. */
-    if (pWav->totalPCMFrameCount == 0) {
-        return DRWAV_TRUE;
-    }
-
-    /* Make sure the sample is clamped. */
-    if (targetFrameIndex >= pWav->totalPCMFrameCount) {
-        targetFrameIndex  = pWav->totalPCMFrameCount - 1;
-    }
-
-    /*
-    For compressed formats we just use a slow generic seek. If we are seeking forward we just seek forward. If we are going backwards we need
-    to seek back to the start.
-    */
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        /* TODO: This can be optimized. */
-        
-        /*
-        If we're seeking forward it's simple - just keep reading samples until we hit the sample we're requesting. If we're seeking backwards,
-        we first need to seek back to the start and then just do the same thing as a forward seek.
-        */
-        if (targetFrameIndex < pWav->compressed.iCurrentPCMFrame) {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-        }
-
-        if (targetFrameIndex > pWav->compressed.iCurrentPCMFrame) {
-            drwav_uint64 offsetInFrames = targetFrameIndex - pWav->compressed.iCurrentPCMFrame;
-
-            drwav_int16 devnull[2048];
-            while (offsetInFrames > 0) {
-                drwav_uint64 framesRead = 0;
-                drwav_uint64 framesToRead = offsetInFrames;
-                if (framesToRead > drwav_countof(devnull)/pWav->channels) {
-                    framesToRead = drwav_countof(devnull)/pWav->channels;
-                }
-
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull);
-                } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull);
-                } else {
-                    DRWAV_ASSERT(DRWAV_FALSE);  /* If this assertion is triggered it means I've implemented a new compressed format but forgot to add a branch for it here. */
-                }
-
-                if (framesRead != framesToRead) {
-                    return DRWAV_FALSE;
-                }
-
-                offsetInFrames -= framesRead;
-            }
-        }
-    } else {
-        drwav_uint64 totalSizeInBytes;
-        drwav_uint64 currentBytePos;
-        drwav_uint64 targetBytePos;
-        drwav_uint64 offset;
-
-        totalSizeInBytes = pWav->totalPCMFrameCount * drwav_get_bytes_per_pcm_frame(pWav);
-        DRWAV_ASSERT(totalSizeInBytes >= pWav->bytesRemaining);
-
-        currentBytePos = totalSizeInBytes - pWav->bytesRemaining;
-        targetBytePos  = targetFrameIndex * drwav_get_bytes_per_pcm_frame(pWav);
-
-        if (currentBytePos < targetBytePos) {
-            /* Offset forwards. */
-            offset = (targetBytePos - currentBytePos);
-        } else {
-            /* Offset backwards. */
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-            offset = targetBytePos;
-        }
-
-        while (offset > 0) {
-            int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset);
-            if (!pWav->onSeek(pWav->pUserData, offset32, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-
-            pWav->bytesRemaining -= offset32;
-            offset -= offset32;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData)
-{
-    size_t bytesWritten;
-
-    if (pWav == NULL || bytesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
-    pWav->dataChunkDataSize += bytesWritten;
-
-    return bytesWritten;
-}
-
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    const drwav_uint8* pRunningData;
-
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-
-    while (bytesToWrite > 0) {
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);  /* <-- This is checked above. */
-
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    drwav_uint32 bytesPerSample;
-    const drwav_uint8* pRunningData;
-
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-
-    bytesPerSample = drwav_get_bytes_per_pcm_frame(pWav) / pWav->channels;
-    
-    while (bytesToWrite > 0) {
-        drwav_uint8 temp[4096];
-        drwav_uint32 sampleCount;
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);  /* <-- This is checked above. */
-
-        /*
-        WAV files are always little-endian. We need to byte swap on big-endian architectures. Since our input buffer is read-only we need
-        to use an intermediary buffer for the conversion.
-        */
-        sampleCount = sizeof(temp)/bytesPerSample;
-
-        if (bytesToWriteThisIteration > ((drwav_uint64)sampleCount)*bytesPerSample) {
-            bytesToWriteThisIteration = ((drwav_uint64)sampleCount)*bytesPerSample;
-        }
-
-        DRWAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration);
-        drwav__bswap_samples(temp, sampleCount, bytesPerSample, pWav->translatedFormatTag);
-
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_write_pcm_frames_le(pWav, framesToWrite, pData);
-    } else {
-        return drwav_write_pcm_frames_be(pWav, framesToWrite, pData);
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-
-    /* TODO: Lots of room for optimization here. */
-
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
-
-        /* If there are no cached frames we need to load a new block. */
-        if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                /* Mono. */
-                drwav_uint8 header[7];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                pWav->msadpcm.predictor[0]     = header[0];
-                pWav->msadpcm.delta[0]         = drwav_bytes_to_s16(header + 1);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 3);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 5);
-                pWav->msadpcm.cachedFrames[2]  = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[3]  = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            } else {
-                /* Stereo. */
-                drwav_uint8 header[14];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                pWav->msadpcm.predictor[0] = header[0];
-                pWav->msadpcm.predictor[1] = header[1];
-                pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 2);
-                pWav->msadpcm.delta[1] = drwav_bytes_to_s16(header + 4);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 6);
-                pWav->msadpcm.prevFrames[1][1] = (drwav_int32)drwav_bytes_to_s16(header + 8);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 10);
-                pWav->msadpcm.prevFrames[1][0] = (drwav_int32)drwav_bytes_to_s16(header + 12);
-
-                pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0];
-                pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            }
-        }
-
-        /* Output anything that's cached. */
-        while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample = 0;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->msadpcm.cachedFrames[(drwav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample];
-                }
-
-                pBufferOut += pWav->channels;
-            }
-
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->msadpcm.cachedFrameCount -= 1;
-        }
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-
-        /*
-        If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
-        loop iteration which will trigger the loading of a new block.
-        */
-        if (pWav->msadpcm.cachedFrameCount == 0) {
-            if (pWav->msadpcm.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                static drwav_int32 adaptationTable[] = { 
-                    230, 230, 230, 230, 307, 409, 512, 614, 
-                    768, 614, 512, 409, 307, 230, 230, 230 
-                };
-                static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460,  392 };
-                static drwav_int32 coeff2Table[] = { 0,  -256, 0, 64,  0,  -208, -232 };
-
-                drwav_uint8 nibbles;
-                drwav_int32 nibble0;
-                drwav_int32 nibble1;
-
-                if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock -= 1;
-
-                /* TODO: Optimize away these if statements. */
-                nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
-                nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
-
-                if (pWav->channels == 1) {
-                    /* Mono. */
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-
-
-                    newSample1  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[0];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample1;
-
-
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 2;
-                } else {
-                    /* Stereo. */
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-
-                    /* Left. */
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-
-
-                    /* Right. */
-                    newSample1  = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[1];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-
-                    pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8;
-                    if (pWav->msadpcm.delta[1] < 16) {
-                        pWav->msadpcm.delta[1] = 16;
-                    }
-
-                    pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1];
-                    pWav->msadpcm.prevFrames[1][1] = newSample1;
-
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 1;
-                }
-            }
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_uint32 iChannel;
-
-    static drwav_int32 indexTable[16] = {
-        -1, -1, -1, -1, 2, 4, 6, 8,
-        -1, -1, -1, -1, 2, 4, 6, 8
-    };
-
-    static drwav_int32 stepTable[89] = {
-        7,     8,     9,     10,    11,    12,    13,    14,    16,    17, 
-        19,    21,    23,    25,    28,    31,    34,    37,    41,    45, 
-        50,    55,    60,    66,    73,    80,    88,    97,    107,   118, 
-        130,   143,   157,   173,   190,   209,   230,   253,   279,   307,
-        337,   371,   408,   449,   494,   544,   598,   658,   724,   796,
-        876,   963,   1060,  1166,  1282,  1411,  1552,  1707,  1878,  2066, 
-        2272,  2499,  2749,  3024,  3327,  3660,  4026,  4428,  4871,  5358,
-        5894,  6484,  7132,  7845,  8630,  9493,  10442, 11487, 12635, 13899, 
-        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 
-    };
-
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-
-    /* TODO: Lots of room for optimization here. */
-
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
-
-        /* If there are no cached samples we need to load a new block. */
-        if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                /* Mono. */
-                drwav_uint8 header[4];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                if (header[2] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead; /* Invalid data. */
-                }
-
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrameCount = 1;
-            } else {
-                /* Stereo. */
-                drwav_uint8 header[8];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-
-                if (header[2] >= drwav_countof(stepTable) || header[6] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead; /* Invalid data. */
-                }
-
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.predictor[1] = drwav_bytes_to_s16(header + 4);
-                pWav->ima.stepIndex[1] = header[6];
-
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1];
-                pWav->ima.cachedFrameCount = 1;
-            }
-        }
-
-        /* Output anything that's cached. */
-        while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->ima.cachedFrameCount -= 1;
-        }
-
-        if (framesToRead == 0) {
-            break;
-        }
-
-        /*
-        If there's nothing left in the cache, just go ahead and load more. If there's nothing left to load in the current block we just continue to the next
-        loop iteration which will trigger the loading of a new block.
-        */
-        if (pWav->ima.cachedFrameCount == 0) {
-            if (pWav->ima.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                /*
-                From what I can tell with stereo streams, it looks like every 4 bytes (8 samples) is for one channel. So it goes 4 bytes for the
-                left channel, 4 bytes for the right channel.
-                */
-                pWav->ima.cachedFrameCount = 8;
-                for (iChannel = 0; iChannel < pWav->channels; ++iChannel) {
-                    drwav_uint32 iByte;
-                    drwav_uint8 nibbles[4];
-                    if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) {
-                        pWav->ima.cachedFrameCount = 0;
-                        return totalFramesRead;
-                    }
-                    pWav->ima.bytesRemainingInBlock -= 4;
-
-                    for (iByte = 0; iByte < 4; ++iByte) {
-                        drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
-                        drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
-
-                        drwav_int32 step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        drwav_int32 predictor = pWav->ima.predictor[iChannel];
-
-                        drwav_int32      diff  = step >> 3;
-                        if (nibble0 & 1) diff += step >> 2;
-                        if (nibble0 & 2) diff += step >> 1;
-                        if (nibble0 & 4) diff += step;
-                        if (nibble0 & 8) diff  = -diff;
-
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor;
-
-
-                        step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        predictor = pWav->ima.predictor[iChannel];
-
-                                         diff  = step >> 3;
-                        if (nibble1 & 1) diff += step >> 2;
-                        if (nibble1 & 2) diff += step >> 1;
-                        if (nibble1 & 4) diff += step;
-                        if (nibble1 & 8) diff  = -diff;
-
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor;
-                    }
-                }
-            }
-        }
-    }
-
-    return totalFramesRead;
-}
-
-
-#ifndef DR_WAV_NO_CONVERSION_API
-static unsigned short g_drwavAlawTable[256] = {
-    0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580, 
-    0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0, 
-    0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600, 
-    0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00, 
-    0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58, 
-    0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58, 
-    0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960, 
-    0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0, 
-    0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80, 
-    0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40, 
-    0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00, 
-    0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500, 
-    0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8, 
-    0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8, 
-    0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0, 
-    0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
-};
-
-static unsigned short g_drwavMulawTable[256] = {
-    0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84, 
-    0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84, 
-    0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004, 
-    0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844, 
-    0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64, 
-    0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74, 
-    0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C, 
-    0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000, 
-    0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C, 
-    0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C, 
-    0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC, 
-    0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC, 
-    0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C, 
-    0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C, 
-    0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084, 
-    0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
-};
-
-static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavAlawTable[sampleIn];
-}
-
-static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavMulawTable[sampleIn];
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int16*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_s16(pOut, (const drwav_int32*)pIn, totalSampleCount);
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (drwav_int16)((drwav_int64)sample >> 48);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if ((pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-    
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(drwav_int16) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int16) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x << 8;
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = ((int)(((unsigned int)(((const drwav_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+2])) << 24)) >> 8;
-        r = x >> 8;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x >> 16;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        float c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5f);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        double x = pIn[i];
-        double c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__alaw_to_s16(pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__mulaw_to_s16(pIn[i]);
-    }
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        drwav_s16_to_f32(pOut, (const drwav_int16*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_f32(pOut, (const drwav_int32*)pIn, sampleCount);
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < sampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (float)((drwav_int64)sample / 9223372036854775807.0);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        unsigned int i;
-        for (i = 0; i < sampleCount; ++i) {
-            *pOut++ = ((const float*)pIn)[i];
-        }
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_f32(pOut, (const double*)pIn, sampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__pcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_f32(pBufferOut, sampleData, (size_t)framesRead*pWav->channels, bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ima(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since IMA-ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ieee(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__alaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__mulaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(float) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(float) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_f32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_f32__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    /*
-    It appears libsndfile uses slightly different logic for the u8 -> f32 conversion to dr_wav, which in my opinion is incorrect. It appears
-    libsndfile performs the conversion something like "f32 = (u8 / 256) * 2 - 1", however I think it should be "f32 = (u8 / 255) * 2 - 1" (note
-    the divisor of 256 vs 255). I use libsndfile as a benchmark for testing, so I'm therefore leaving this block here just for my automated
-    correctness testing. This is disabled by default.
-    */
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
-    }
-#else
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        x = x * 0.00784313725490196078f;    /* 0..255 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-
-        *pOut++ = x;
-    }
-#endif
-}
-
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] * 0.000030517578125f;
-    }
-}
-
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        double x;
-        drwav_uint32 a = ((drwav_uint32)(pIn[i*3+0]) <<  8);
-        drwav_uint32 b = ((drwav_uint32)(pIn[i*3+1]) << 16);
-        drwav_uint32 c = ((drwav_uint32)(pIn[i*3+2]) << 24);
-
-        x = (double)((drwav_int32)(a | b | c) >> 8);
-        *pOut++ = (float)(x * 0.00000011920928955078125);
-    }
-}
-
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)(pIn[i] / 2147483648.0);
-    }
-}
-
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)pIn[i];
-    }
-}
-
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__alaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__mulaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-
-
-
-DRWAV_PRIVATE void drwav__pcm_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-
-    /* Special case for 8-bit sample data because it's treated as unsigned. */
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-
-    /* Slightly more optimal implementation for common formats. */
-    if (bytesPerSample == 2) {
-        drwav_s16_to_s32(pOut, (const drwav_int16*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int32*)pIn)[i];
-        }
-        return;
-    }
-
-
-    /* Anything more than 64 bits per sample is not supported. */
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-
-
-    /* Generic, slow converter. */
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-
-        pIn += j;
-        *pOut++ = (drwav_int32)((drwav_int64)sample >> 32);
-    }
-}
-
-DRWAV_PRIVATE void drwav__ieee_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        /* Only supporting 32- and 64-bit float. Output silence in all other cases. Contributions welcome for 16-bit float. */
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-
-    /* Fast path. */
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__pcm_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    /*
-    We're just going to borrow the implementation from the drwav_read_s16() since IMA-ADPCM is a little bit more complicated than other formats and I don't
-    want to duplicate that code.
-    */
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));   /* <-- Safe cast because we're clamping to 2048. */
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav__ieee_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_alaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-
-    totalFramesRead = 0;
-
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-
-        drwav_mulaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-
-    return totalFramesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-
-    /* Don't try to read more samples than can potentially fit in the output buffer. */
-    if (framesToRead * pWav->channels * sizeof(drwav_int32) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int32) / pWav->channels;
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s32__ima(pWav, framesToRead, pBufferOut);
-    }
-
-    return 0;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-
-    return framesRead;
-}
-
-
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((int)pIn[i] - 128) << 24;
-    }
-}
-
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] << 16;
-    }
-}
-
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        unsigned int s0 = pIn[i*3 + 0];
-        unsigned int s1 = pIn[i*3 + 1];
-        unsigned int s2 = pIn[i*3 + 2];
-
-        drwav_int32 sample32 = (drwav_int32)((s0 << 8) | (s1 << 16) | (s2 << 24));
-        *pOut++ = sample32;
-    }
-}
-
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__alaw_to_s16(pIn[i])) << 16;
-    }
-}
-
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-
-    for (i= 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__mulaw_to_s16(pIn[i])) << 16;
-    }
-}
-
-
-
-DRWAV_PRIVATE drwav_int16* drwav__read_pcm_frames_and_close_s16(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int16* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int16);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (drwav_int16*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-DRWAV_PRIVATE float* drwav__read_pcm_frames_and_close_f32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    float* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (float*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-DRWAV_PRIVATE drwav_int32* drwav__read_pcm_frames_and_close_s32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int32* pSampleData;
-    drwav_uint64 framesRead;
-
-    DRWAV_ASSERT(pWav != NULL);
-
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int32);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;    /* File's too big. */
-    }
-
-    pSampleData = (drwav_int32*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks); /* <-- Safe cast due to the check above. */
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;    /* Failed to allocate memory. */
-    }
-
-    framesRead = drwav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;    /* There was an error reading the samples. */
-    }
-
-    drwav_uninit(pWav);
-
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-
-    return pSampleData;
-}
-
-
-
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif  /* DR_WAV_NO_CONVERSION_API */
-
-
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drwav__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drwav__free_default(p, NULL);
-    }
-}
-
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8);
-}
-
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data)
-{
-    return (short)drwav_bytes_to_u16(data);
-}
-
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-}
-
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data)
-{
-    return (drwav_int32)drwav_bytes_to_u32(data);
-}
-
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data)
-{
-    return
-        ((drwav_uint64)data[0] <<  0) | ((drwav_uint64)data[1] <<  8) | ((drwav_uint64)data[2] << 16) | ((drwav_uint64)data[3] << 24) |
-        ((drwav_uint64)data[4] << 32) | ((drwav_uint64)data[5] << 40) | ((drwav_uint64)data[6] << 48) | ((drwav_uint64)data[7] << 56);
-}
-
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data)
-{
-    return (drwav_int64)drwav_bytes_to_u64(data);
-}
-
-
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
-{
-    int i;
-    for (i = 0; i < 16; i += 1) {
-        if (a[i] != b[i]) {
-            return DRWAV_FALSE;
-        }
-    }
-
-    return DRWAV_TRUE;
-}
-
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
-{
-    return
-        a[0] == b[0] &&
-        a[1] == b[1] &&
-        a[2] == b[2] &&
-        a[3] == b[3];
-}
-
-#endif  /* dr_wav_c */
-#endif  /* DR_WAV_IMPLEMENTATION */
-
-/*
-RELEASE NOTES - v0.11.0
-=======================
-Version 0.11.0 has breaking API changes.
-
-Improved Client-Defined Memory Allocation
------------------------------------------
-The main change with this release is the addition of a more flexible way of implementing custom memory allocation routines. The
-existing system of DRWAV_MALLOC, DRWAV_REALLOC and DRWAV_FREE are still in place and will be used by default when no custom
-allocation callbacks are specified.
-
-To use the new system, you pass in a pointer to a drwav_allocation_callbacks object to drwav_init() and family, like this:
-
-    void* my_malloc(size_t sz, void* pUserData)
-    {
-        return malloc(sz);
-    }
-    void* my_realloc(void* p, size_t sz, void* pUserData)
-    {
-        return realloc(p, sz);
-    }
-    void my_free(void* p, void* pUserData)
-    {
-        free(p);
-    }
-
-    ...
-
-    drwav_allocation_callbacks allocationCallbacks;
-    allocationCallbacks.pUserData = &myData;
-    allocationCallbacks.onMalloc  = my_malloc;
-    allocationCallbacks.onRealloc = my_realloc;
-    allocationCallbacks.onFree    = my_free;
-    drwav_init_file(&wav, "my_file.wav", &allocationCallbacks);
-
-The advantage of this new system is that it allows you to specify user data which will be passed in to the allocation routines.
-
-Passing in null for the allocation callbacks object will cause dr_wav to use defaults which is the same as DRWAV_MALLOC,
-DRWAV_REALLOC and DRWAV_FREE and the equivalent of how it worked in previous versions.
-
-Every API that opens a drwav object now takes this extra parameter. These include the following:
-
-    drwav_init()
-    drwav_init_ex()
-    drwav_init_file()
-    drwav_init_file_ex()
-    drwav_init_file_w()
-    drwav_init_file_w_ex()
-    drwav_init_memory()
-    drwav_init_memory_ex()
-    drwav_init_write()
-    drwav_init_write_sequential()
-    drwav_init_write_sequential_pcm_frames()
-    drwav_init_file_write()
-    drwav_init_file_write_sequential()
-    drwav_init_file_write_sequential_pcm_frames()
-    drwav_init_file_write_w()
-    drwav_init_file_write_sequential_w()
-    drwav_init_file_write_sequential_pcm_frames_w()
-    drwav_init_memory_write()
-    drwav_init_memory_write_sequential()
-    drwav_init_memory_write_sequential_pcm_frames()
-    drwav_open_and_read_pcm_frames_s16()
-    drwav_open_and_read_pcm_frames_f32()
-    drwav_open_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_s16()
-    drwav_open_file_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_s16_w()
-    drwav_open_file_and_read_pcm_frames_f32_w()
-    drwav_open_file_and_read_pcm_frames_s32_w()
-    drwav_open_memory_and_read_pcm_frames_s16()
-    drwav_open_memory_and_read_pcm_frames_f32()
-    drwav_open_memory_and_read_pcm_frames_s32()
-
-Endian Improvements
--------------------
-Previously, the following APIs returned little-endian audio data. These now return native-endian data. This improves compatibility
-on big-endian architectures.
-
-    drwav_read_pcm_frames()
-    drwav_read_pcm_frames_s16()
-    drwav_read_pcm_frames_s32()
-    drwav_read_pcm_frames_f32()
-    drwav_open_and_read_pcm_frames_s16()
-    drwav_open_and_read_pcm_frames_s32()
-    drwav_open_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s16()
-    drwav_open_file_and_read_pcm_frames_s32()
-    drwav_open_file_and_read_pcm_frames_f32()
-    drwav_open_file_and_read_pcm_frames_s16_w()
-    drwav_open_file_and_read_pcm_frames_s32_w()
-    drwav_open_file_and_read_pcm_frames_f32_w()
-    drwav_open_memory_and_read_pcm_frames_s16()
-    drwav_open_memory_and_read_pcm_frames_s32()
-    drwav_open_memory_and_read_pcm_frames_f32()
-
-APIs have been added to give you explicit control over whether or not audio data is read or written in big- or little-endian byte
-order:
-
-    drwav_read_pcm_frames_le()
-    drwav_read_pcm_frames_be()
-    drwav_read_pcm_frames_s16le()
-    drwav_read_pcm_frames_s16be()
-    drwav_read_pcm_frames_f32le()
-    drwav_read_pcm_frames_f32be()
-    drwav_read_pcm_frames_s32le()
-    drwav_read_pcm_frames_s32be()
-    drwav_write_pcm_frames_le()
-    drwav_write_pcm_frames_be()
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.10.0 and have now been removed:
-
-    drwav_open()
-    drwav_open_ex()
-    drwav_open_write()
-    drwav_open_write_sequential()
-    drwav_open_file()
-    drwav_open_file_ex()
-    drwav_open_file_write()
-    drwav_open_file_write_sequential()
-    drwav_open_memory()
-    drwav_open_memory_ex()
-    drwav_open_memory_write()
-    drwav_open_memory_write_sequential()
-    drwav_close()
-
-
-
-RELEASE NOTES - v0.10.0
-=======================
-Version 0.10.0 has breaking API changes. There are no significant bug fixes in this release, so if you are affected you do
-not need to upgrade.
-
-Removed APIs
-------------
-The following APIs were deprecated in version 0.9.0 and have been completely removed in version 0.10.0:
-
-    drwav_read()
-    drwav_read_s16()
-    drwav_read_f32()
-    drwav_read_s32()
-    drwav_seek_to_sample()
-    drwav_write()
-    drwav_open_and_read_s16()
-    drwav_open_and_read_f32()
-    drwav_open_and_read_s32()
-    drwav_open_file_and_read_s16()
-    drwav_open_file_and_read_f32()
-    drwav_open_file_and_read_s32()
-    drwav_open_memory_and_read_s16()
-    drwav_open_memory_and_read_f32()
-    drwav_open_memory_and_read_s32()
-    drwav::totalSampleCount
-
-See release notes for version 0.9.0 at the bottom of this file for replacement APIs.
-
-Deprecated APIs
----------------
-The following APIs have been deprecated. There is a confusing and completely arbitrary difference between drwav_init*() and
-drwav_open*(), where drwav_init*() initializes a pre-allocated drwav object, whereas drwav_open*() will first allocated a
-drwav object on the heap and then initialize it. drwav_open*() has been deprecated which means you must now use a pre-
-allocated drwav object with drwav_init*(). If you need the previous functionality, you can just do a malloc() followed by
-a called to one of the drwav_init*() APIs.
-
-    drwav_open()
-    drwav_open_ex()
-    drwav_open_write()
-    drwav_open_write_sequential()
-    drwav_open_file()
-    drwav_open_file_ex()
-    drwav_open_file_write()
-    drwav_open_file_write_sequential()
-    drwav_open_memory()
-    drwav_open_memory_ex()
-    drwav_open_memory_write()
-    drwav_open_memory_write_sequential()
-    drwav_close()
-
-These APIs will be removed completely in a future version. The rationale for this change is to remove confusion between the
-two different ways to initialize a drwav object.
-*/
-
-/*
-REVISION HISTORY
-================
-v0.12.19 - 2021-02-21
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-  - Minor improvements to the management of some internal state concerning the data chunk cursor.
-
-v0.12.18 - 2021-01-31
-  - Clean up some static analysis warnings.
-
-v0.12.17 - 2021-01-17
-  - Minor fix to sample code in documentation.
-  - Correctly qualify a private API as private rather than public.
-  - Code cleanup.
-
-v0.12.16 - 2020-12-02
-  - Fix a bug when trying to read more bytes than can fit in a size_t.
-
-v0.12.15 - 2020-11-21
-  - Fix compilation with OpenWatcom.
-
-v0.12.14 - 2020-11-13
-  - Minor code clean up.
-
-v0.12.13 - 2020-11-01
-  - Improve compiler support for older versions of GCC.
-
-v0.12.12 - 2020-09-28
-  - Add support for RF64.
-  - Fix a bug in writing mode where the size of the RIFF chunk incorrectly includes the header section.
-
-v0.12.11 - 2020-09-08
-  - Fix a compilation error on older compilers.
-
-v0.12.10 - 2020-08-24
-  - Fix a bug when seeking with ADPCM formats.
-
-v0.12.9 - 2020-08-02
-  - Simplify sized types.
-
-v0.12.8 - 2020-07-25
-  - Fix a compilation warning.
-
-v0.12.7 - 2020-07-15
-  - Fix some bugs on big-endian architectures.
-  - Fix an error in s24 to f32 conversion.
-
-v0.12.6 - 2020-06-23
-  - Change drwav_read_*() to allow NULL to be passed in as the output buffer which is equivalent to a forward seek.
-  - Fix a buffer overflow when trying to decode invalid IMA-ADPCM files.
-  - Add include guard for the implementation section.
-
-v0.12.5 - 2020-05-27
-  - Minor documentation fix.
-
-v0.12.4 - 2020-05-16
-  - Replace assert() with DRWAV_ASSERT().
-  - Add compile-time and run-time version querying.
-    - DRWAV_VERSION_MINOR
-    - DRWAV_VERSION_MAJOR
-    - DRWAV_VERSION_REVISION
-    - DRWAV_VERSION_STRING
-    - drwav_version()
-    - drwav_version_string()
-
-v0.12.3 - 2020-04-30
-  - Fix compilation errors with VC6.
-
-v0.12.2 - 2020-04-21
-  - Fix a bug where drwav_init_file() does not close the file handle after attempting to load an erroneous file.
-
-v0.12.1 - 2020-04-13
-  - Fix some pedantic warnings.
-
-v0.12.0 - 2020-04-04
-  - API CHANGE: Add container and format parameters to the chunk callback.
-  - Minor documentation updates.
-
-v0.11.5 - 2020-03-07
-  - Fix compilation error with Visual Studio .NET 2003.
-
-v0.11.4 - 2020-01-29
-  - Fix some static analysis warnings.
-  - Fix a bug when reading f32 samples from an A-law encoded stream.
-
-v0.11.3 - 2020-01-12
-  - Minor changes to some f32 format conversion routines.
-  - Minor bug fix for ADPCM conversion when end of file is reached.
-
-v0.11.2 - 2019-12-02
-  - Fix a possible crash when using custom memory allocators without a custom realloc() implementation.
-  - Fix an integer overflow bug.
-  - Fix a null pointer dereference bug.
-  - Add limits to sample rate, channels and bits per sample to tighten up some validation.
-
-v0.11.1 - 2019-10-07
-  - Internal code clean up.
-
-v0.11.0 - 2019-10-06
-  - API CHANGE: Add support for user defined memory allocation routines. This system allows the program to specify their own memory allocation
-    routines with a user data pointer for client-specific contextual data. This adds an extra parameter to the end of the following APIs:
-    - drwav_init()
-    - drwav_init_ex()
-    - drwav_init_file()
-    - drwav_init_file_ex()
-    - drwav_init_file_w()
-    - drwav_init_file_w_ex()
-    - drwav_init_memory()
-    - drwav_init_memory_ex()
-    - drwav_init_write()
-    - drwav_init_write_sequential()
-    - drwav_init_write_sequential_pcm_frames()
-    - drwav_init_file_write()
-    - drwav_init_file_write_sequential()
-    - drwav_init_file_write_sequential_pcm_frames()
-    - drwav_init_file_write_w()
-    - drwav_init_file_write_sequential_w()
-    - drwav_init_file_write_sequential_pcm_frames_w()
-    - drwav_init_memory_write()
-    - drwav_init_memory_write_sequential()
-    - drwav_init_memory_write_sequential_pcm_frames()
-    - drwav_open_and_read_pcm_frames_s16()
-    - drwav_open_and_read_pcm_frames_f32()
-    - drwav_open_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_s16()
-    - drwav_open_file_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_s16_w()
-    - drwav_open_file_and_read_pcm_frames_f32_w()
-    - drwav_open_file_and_read_pcm_frames_s32_w()
-    - drwav_open_memory_and_read_pcm_frames_s16()
-    - drwav_open_memory_and_read_pcm_frames_f32()
-    - drwav_open_memory_and_read_pcm_frames_s32()
-    Set this extra parameter to NULL to use defaults which is the same as the previous behaviour. Setting this NULL will use
-    DRWAV_MALLOC, DRWAV_REALLOC and DRWAV_FREE.
-  - Add support for reading and writing PCM frames in an explicit endianness. New APIs:
-    - drwav_read_pcm_frames_le()
-    - drwav_read_pcm_frames_be()
-    - drwav_read_pcm_frames_s16le()
-    - drwav_read_pcm_frames_s16be()
-    - drwav_read_pcm_frames_f32le()
-    - drwav_read_pcm_frames_f32be()
-    - drwav_read_pcm_frames_s32le()
-    - drwav_read_pcm_frames_s32be()
-    - drwav_write_pcm_frames_le()
-    - drwav_write_pcm_frames_be()
-  - Remove deprecated APIs.
-  - API CHANGE: The following APIs now return native-endian data. Previously they returned little-endian data.
-    - drwav_read_pcm_frames()
-    - drwav_read_pcm_frames_s16()
-    - drwav_read_pcm_frames_s32()
-    - drwav_read_pcm_frames_f32()
-    - drwav_open_and_read_pcm_frames_s16()
-    - drwav_open_and_read_pcm_frames_s32()
-    - drwav_open_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s16()
-    - drwav_open_file_and_read_pcm_frames_s32()
-    - drwav_open_file_and_read_pcm_frames_f32()
-    - drwav_open_file_and_read_pcm_frames_s16_w()
-    - drwav_open_file_and_read_pcm_frames_s32_w()
-    - drwav_open_file_and_read_pcm_frames_f32_w()
-    - drwav_open_memory_and_read_pcm_frames_s16()
-    - drwav_open_memory_and_read_pcm_frames_s32()
-    - drwav_open_memory_and_read_pcm_frames_f32()
-
-v0.10.1 - 2019-08-31
-  - Correctly handle partial trailing ADPCM blocks.
-
-v0.10.0 - 2019-08-04
-  - Remove deprecated APIs.
-  - Add wchar_t variants for file loading APIs:
-      drwav_init_file_w()
-      drwav_init_file_ex_w()
-      drwav_init_file_write_w()
-      drwav_init_file_write_sequential_w()
-  - Add drwav_target_write_size_bytes() which calculates the total size in bytes of a WAV file given a format and sample count.
-  - Add APIs for specifying the PCM frame count instead of the sample count when opening in sequential write mode:
-      drwav_init_write_sequential_pcm_frames()
-      drwav_init_file_write_sequential_pcm_frames()
-      drwav_init_file_write_sequential_pcm_frames_w()
-      drwav_init_memory_write_sequential_pcm_frames()
-  - Deprecate drwav_open*() and drwav_close():
-      drwav_open()
-      drwav_open_ex()
-      drwav_open_write()
-      drwav_open_write_sequential()
-      drwav_open_file()
-      drwav_open_file_ex()
-      drwav_open_file_write()
-      drwav_open_file_write_sequential()
-      drwav_open_memory()
-      drwav_open_memory_ex()
-      drwav_open_memory_write()
-      drwav_open_memory_write_sequential()
-      drwav_close()
-  - Minor documentation updates.
-
-v0.9.2 - 2019-05-21
-  - Fix warnings.
-
-v0.9.1 - 2019-05-05
-  - Add support for C89.
-  - Change license to choice of public domain or MIT-0.
-
-v0.9.0 - 2018-12-16
-  - API CHANGE: Add new reading APIs for reading by PCM frames instead of samples. Old APIs have been deprecated and
-    will be removed in v0.10.0. Deprecated APIs and their replacements:
-      drwav_read()                     -> drwav_read_pcm_frames()
-      drwav_read_s16()                 -> drwav_read_pcm_frames_s16()
-      drwav_read_f32()                 -> drwav_read_pcm_frames_f32()
-      drwav_read_s32()                 -> drwav_read_pcm_frames_s32()
-      drwav_seek_to_sample()           -> drwav_seek_to_pcm_frame()
-      drwav_write()                    -> drwav_write_pcm_frames()
-      drwav_open_and_read_s16()        -> drwav_open_and_read_pcm_frames_s16()
-      drwav_open_and_read_f32()        -> drwav_open_and_read_pcm_frames_f32()
-      drwav_open_and_read_s32()        -> drwav_open_and_read_pcm_frames_s32()
-      drwav_open_file_and_read_s16()   -> drwav_open_file_and_read_pcm_frames_s16()
-      drwav_open_file_and_read_f32()   -> drwav_open_file_and_read_pcm_frames_f32()
-      drwav_open_file_and_read_s32()   -> drwav_open_file_and_read_pcm_frames_s32()
-      drwav_open_memory_and_read_s16() -> drwav_open_memory_and_read_pcm_frames_s16()
-      drwav_open_memory_and_read_f32() -> drwav_open_memory_and_read_pcm_frames_f32()
-      drwav_open_memory_and_read_s32() -> drwav_open_memory_and_read_pcm_frames_s32()
-      drwav::totalSampleCount          -> drwav::totalPCMFrameCount
-  - API CHANGE: Rename drwav_open_and_read_file_*() to drwav_open_file_and_read_*().
-  - API CHANGE: Rename drwav_open_and_read_memory_*() to drwav_open_memory_and_read_*().
-  - Add built-in support for smpl chunks.
-  - Add support for firing a callback for each chunk in the file at initialization time.
-    - This is enabled through the drwav_init_ex(), etc. family of APIs.
-  - Handle invalid FMT chunks more robustly.
-
-v0.8.5 - 2018-09-11
-  - Const correctness.
-  - Fix a potential stack overflow.
-
-v0.8.4 - 2018-08-07
-  - Improve 64-bit detection.
-
-v0.8.3 - 2018-08-05
-  - Fix C++ build on older versions of GCC.
-
-v0.8.2 - 2018-08-02
-  - Fix some big-endian bugs.
-
-v0.8.1 - 2018-06-29
-  - Add support for sequential writing APIs.
-  - Disable seeking in write mode.
-  - Fix bugs with Wave64.
-  - Fix typos.
-
-v0.8 - 2018-04-27
-  - Bug fix.
-  - Start using major.minor.revision versioning.
-
-v0.7f - 2018-02-05
-  - Restrict ADPCM formats to a maximum of 2 channels.
-
-v0.7e - 2018-02-02
-  - Fix a crash.
-
-v0.7d - 2018-02-01
-  - Fix a crash.
-
-v0.7c - 2018-02-01
-  - Set drwav.bytesPerSample to 0 for all compressed formats.
-  - Fix a crash when reading 16-bit floating point WAV files. In this case dr_wav will output silence for
-    all format conversion reading APIs (*_s16, *_s32, *_f32 APIs).
-  - Fix some divide-by-zero errors.
-
-v0.7b - 2018-01-22
-  - Fix errors with seeking of compressed formats.
-  - Fix compilation error when DR_WAV_NO_CONVERSION_API
-
-v0.7a - 2017-11-17
-  - Fix some GCC warnings.
-
-v0.7 - 2017-11-04
-  - Add writing APIs.
-
-v0.6 - 2017-08-16
-  - API CHANGE: Rename dr_* types to drwav_*.
-  - Add support for custom implementations of malloc(), realloc(), etc.
-  - Add support for Microsoft ADPCM.
-  - Add support for IMA ADPCM (DVI, format code 0x11).
-  - Optimizations to drwav_read_s16().
-  - Bug fixes.
-
-v0.5g - 2017-07-16
-  - Change underlying type for booleans to unsigned.
-
-v0.5f - 2017-04-04
-  - Fix a minor bug with drwav_open_and_read_s16() and family.
-
-v0.5e - 2016-12-29
-  - Added support for reading samples as signed 16-bit integers. Use the _s16() family of APIs for this.
-  - Minor fixes to documentation.
-
-v0.5d - 2016-12-28
-  - Use drwav_int* and drwav_uint* sized types to improve compiler support.
-
-v0.5c - 2016-11-11
-  - Properly handle JUNK chunks that come before the FMT chunk.
-
-v0.5b - 2016-10-23
-  - A minor change to drwav_bool8 and drwav_bool32 types.
-
-v0.5a - 2016-10-11
-  - Fixed a bug with drwav_open_and_read() and family due to incorrect argument ordering.
-  - Improve A-law and mu-law efficiency.
-
-v0.5 - 2016-09-29
-  - API CHANGE. Swap the order of "channels" and "sampleRate" parameters in drwav_open_and_read*(). Rationale for this is to
-    keep it consistent with dr_audio and dr_flac.
-
-v0.4b - 2016-09-18
-  - Fixed a typo in documentation.
-
-v0.4a - 2016-09-18
-  - Fixed a typo.
-  - Change date format to ISO 8601 (YYYY-MM-DD)
-
-v0.4 - 2016-07-13
-  - API CHANGE. Make onSeek consistent with dr_flac.
-  - API CHANGE. Rename drwav_seek() to drwav_seek_to_sample() for clarity and consistency with dr_flac.
-  - Added support for Sony Wave64.
-
-v0.3a - 2016-05-28
-  - API CHANGE. Return drwav_bool32 instead of int in onSeek callback.
-  - Fixed a memory leak.
-
-v0.3 - 2016-05-22
-  - Lots of API changes for consistency.
-
-v0.2a - 2016-05-16
-  - Fixed Linux/GCC build.
-
-v0.2 - 2016-05-11
-  - Added support for reading data as signed 32-bit PCM for consistency with dr_flac.
-
-v0.1a - 2016-05-07
-  - Fixed a bug in drwav_open_file() where the file handle would not be closed if the loader failed to initialize.
-
-v0.1 - 2016-05-04
-  - Initial versioned release.
-*/
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib_pi4_test/external/glad.h b/raylib_pi4_test/external/glad.h
deleted file mode 100644 (file)
index c92e184..0000000
+++ /dev/null
@@ -1,5474 +0,0 @@
-/*
-
-    OpenGL loader generated by glad 0.1.10a0 on Fri Jun 10 12:54:12 2016.
-
-    Language/Generator: C/C++
-    Specification: gl
-    APIs: gl=3.3
-    Profile: core
-    Extensions:
-        GL_AMD_debug_output, GL_AMD_query_buffer_object, GL_ARB_ES2_compatibility, GL_ARB_ES3_compatibility, GL_ARB_buffer_storage, GL_ARB_compatibility, GL_ARB_compressed_texture_pixel_storage, GL_ARB_debug_output, GL_ARB_depth_buffer_float, GL_ARB_depth_clamp, GL_ARB_depth_texture, GL_ARB_draw_buffers, GL_ARB_draw_buffers_blend, GL_ARB_explicit_attrib_location, GL_ARB_explicit_uniform_location, GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_framebuffer_object, GL_ARB_framebuffer_sRGB, GL_ARB_multisample, GL_ARB_sample_locations, GL_ARB_texture_compression, GL_ARB_texture_float, GL_ARB_texture_multisample, GL_ARB_texture_non_power_of_two, GL_ARB_texture_rg, GL_ARB_texture_swizzle, GL_ARB_uniform_buffer_object, GL_ARB_vertex_array_object, GL_ARB_vertex_attrib_binding, GL_ARB_vertex_buffer_object, GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_element_array, GL_ATI_fragment_shader, GL_ATI_vertex_array_object, GL_EXT_blend_color, GL_EXT_blend_equation_separate, GL_EXT_blend_func_separate, GL_EXT_framebuffer_blit, GL_EXT_framebuffer_multisample, GL_EXT_framebuffer_multisample_blit_scaled, GL_EXT_framebuffer_object, GL_EXT_framebuffer_sRGB, GL_EXT_index_array_formats, GL_EXT_texture, GL_EXT_texture_compression_s3tc, GL_EXT_texture_sRGB, GL_EXT_texture_swizzle, GL_EXT_vertex_array, GL_EXT_vertex_shader
-    Loader: No
-
-    Commandline:
-        --profile="core" --api="gl=3.3" --generator="c" --spec="gl" --no-loader --extensions="GL_AMD_debug_output,GL_AMD_query_buffer_object,GL_ARB_ES2_compatibility,GL_ARB_ES3_compatibility,GL_ARB_buffer_storage,GL_ARB_compatibility,GL_ARB_compressed_texture_pixel_storage,GL_ARB_debug_output,GL_ARB_depth_buffer_float,GL_ARB_depth_clamp,GL_ARB_depth_texture,GL_ARB_draw_buffers,GL_ARB_draw_buffers_blend,GL_ARB_explicit_attrib_location,GL_ARB_explicit_uniform_location,GL_ARB_fragment_program,GL_ARB_fragment_shader,GL_ARB_framebuffer_object,GL_ARB_framebuffer_sRGB,GL_ARB_multisample,GL_ARB_sample_locations,GL_ARB_texture_compression,GL_ARB_texture_float,GL_ARB_texture_multisample,GL_ARB_texture_non_power_of_two,GL_ARB_texture_rg,GL_ARB_texture_swizzle,GL_ARB_uniform_buffer_object,GL_ARB_vertex_array_object,GL_ARB_vertex_attrib_binding,GL_ARB_vertex_buffer_object,GL_ARB_vertex_program,GL_ARB_vertex_shader,GL_ATI_element_array,GL_ATI_fragment_shader,GL_ATI_vertex_array_object,GL_EXT_blend_color,GL_EXT_blend_equation_separate,GL_EXT_blend_func_separate,GL_EXT_framebuffer_blit,GL_EXT_framebuffer_multisample,GL_EXT_framebuffer_multisample_blit_scaled,GL_EXT_framebuffer_object,GL_EXT_framebuffer_sRGB,GL_EXT_index_array_formats,GL_EXT_texture,GL_EXT_texture_compression_s3tc,GL_EXT_texture_sRGB,GL_EXT_texture_swizzle,GL_EXT_vertex_array,GL_EXT_vertex_shader"
-    Online:
-        http://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&extensions=GL_AMD_debug_output&extensions=GL_AMD_query_buffer_object&extensions=GL_ARB_ES2_compatibility&extensions=GL_ARB_ES3_compatibility&extensions=GL_ARB_buffer_storage&extensions=GL_ARB_compatibility&extensions=GL_ARB_compressed_texture_pixel_storage&extensions=GL_ARB_debug_output&extensions=GL_ARB_depth_buffer_float&extensions=GL_ARB_depth_clamp&extensions=GL_ARB_depth_texture&extensions=GL_ARB_draw_buffers&extensions=GL_ARB_draw_buffers_blend&extensions=GL_ARB_explicit_attrib_location&extensions=GL_ARB_explicit_uniform_location&extensions=GL_ARB_fragment_program&extensions=GL_ARB_fragment_shader&extensions=GL_ARB_framebuffer_object&extensions=GL_ARB_framebuffer_sRGB&extensions=GL_ARB_multisample&extensions=GL_ARB_sample_locations&extensions=GL_ARB_texture_compression&extensions=GL_ARB_texture_float&extensions=GL_ARB_texture_multisample&extensions=GL_ARB_texture_non_power_of_two&extensions=GL_ARB_texture_rg&extensions=GL_ARB_texture_swizzle&extensions=GL_ARB_uniform_buffer_object&extensions=GL_ARB_vertex_array_object&extensions=GL_ARB_vertex_attrib_binding&extensions=GL_ARB_vertex_buffer_object&extensions=GL_ARB_vertex_program&extensions=GL_ARB_vertex_shader&extensions=GL_ATI_element_array&extensions=GL_ATI_fragment_shader&extensions=GL_ATI_vertex_array_object&extensions=GL_EXT_blend_color&extensions=GL_EXT_blend_equation_separate&extensions=GL_EXT_blend_func_separate&extensions=GL_EXT_framebuffer_blit&extensions=GL_EXT_framebuffer_multisample&extensions=GL_EXT_framebuffer_multisample_blit_scaled&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_framebuffer_sRGB&extensions=GL_EXT_index_array_formats&extensions=GL_EXT_texture&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_sRGB&extensions=GL_EXT_texture_swizzle&extensions=GL_EXT_vertex_array&extensions=GL_EXT_vertex_shader
-*/
-
-
-#ifndef __glad_h_
-#define __glad_h_
-
-#ifdef __gl_h_
-#error OpenGL header already included, remove this include, glad already provides it
-#endif
-#define __gl_h_
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN 1
-#endif
-//#include <windows.h>
-#define APIENTRY __stdcall      // RAY: Added
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-
-// RAY: Added
-#ifndef GLAD_REALLOC
-    #define GLAD_REALLOC(n,sz)  realloc(n,sz)
-#endif
-#ifndef GLAD_FREE
-    #define GLAD_FREE(p)        free(p)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct gladGLversionStruct {
-    int major;
-    int minor;
-};
-
-typedef void* (* GLADloadproc)(const char *name);
-
-#ifndef GLAPI
-# if defined(GLAD_GLAPI_EXPORT)
-#  if defined(WIN32) || defined(__CYGWIN__)
-#   if defined(GLAD_GLAPI_EXPORT_BUILD)
-#    if defined(__GNUC__)
-#     define GLAPI __attribute__ ((dllexport)) extern
-#    else
-#     define GLAPI __declspec(dllexport) extern
-#    endif
-#   else
-#    if defined(__GNUC__)
-#     define GLAPI __attribute__ ((dllimport)) extern
-#    else
-#     define GLAPI __declspec(dllimport) extern
-#    endif
-#   endif
-#  elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)
-#   define GLAPI __attribute__ ((visibility ("default"))) extern
-#  else
-#   define GLAPI extern
-#  endif
-# else
-#  define GLAPI extern
-# endif
-#endif
-
-GLAPI struct gladGLversionStruct GLVersion;
-GLAPI int gladLoadGLLoader(GLADloadproc);
-
-#include <stddef.h>
-//#include <KHR/khrplatform.h>      // RAY: Not required
-#ifndef GLEXT_64_TYPES_DEFINED
-/* This code block is duplicated in glxext.h, so must be protected */
-#define GLEXT_64_TYPES_DEFINED
-/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
-/* (as used in the GL_EXT_timer_query extension). */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
-#include <inttypes.h>
-#elif defined(__sun__) || defined(__digital__)
-#include <inttypes.h>
-#if defined(__STDC__)
-#if defined(__arch64__) || defined(_LP64)
-typedef long int int64_t;
-typedef unsigned long int uint64_t;
-#else
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#endif /* __arch64__ */
-#endif /* __STDC__ */
-#elif defined( __VMS ) || defined(__sgi)
-#include <inttypes.h>
-#elif defined(__SCO__) || defined(__USLC__)
-#include <stdint.h>
-#elif defined(__UNIXOS2__) || defined(__SOL64__)
-typedef long int int32_t;
-typedef long long int int64_t;
-typedef unsigned long long int uint64_t;
-#elif defined(_WIN32) && defined(__GNUC__)
-#include <stdint.h>
-#elif defined(_WIN32)
-typedef __int32 int32_t;
-typedef __int64 int64_t;
-typedef unsigned __int64 uint64_t;
-#else
-/* Fallback if nothing above works */
-#include <inttypes.h>
-#endif
-#endif
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef void GLvoid;
-typedef signed char GLbyte;
-typedef short GLshort;
-typedef int GLint;
-typedef int GLclampx;
-typedef unsigned char GLubyte;
-typedef unsigned short GLushort;
-typedef unsigned int GLuint;
-typedef int GLsizei;
-typedef float GLfloat;
-typedef float GLclampf;
-typedef double GLdouble;
-typedef double GLclampd;
-typedef void *GLeglImageOES;
-typedef char GLchar;
-typedef char GLcharARB;
-#ifdef __APPLE__
-typedef void *GLhandleARB;
-#else
-typedef unsigned int GLhandleARB;
-#endif
-typedef unsigned short GLhalfARB;
-typedef unsigned short GLhalf;
-typedef GLint GLfixed;
-typedef ptrdiff_t GLintptr;
-typedef ptrdiff_t GLsizeiptr;
-typedef int64_t GLint64;
-typedef uint64_t GLuint64;
-typedef ptrdiff_t GLintptrARB;
-typedef ptrdiff_t GLsizeiptrARB;
-typedef int64_t GLint64EXT;
-typedef uint64_t GLuint64EXT;
-typedef struct __GLsync *GLsync;
-struct _cl_context;
-struct _cl_event;
-typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
-typedef unsigned short GLhalfNV;
-typedef GLintptr GLvdpauSurfaceNV;
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_FALSE 0
-#define GL_TRUE 1
-#define GL_POINTS 0x0000
-#define GL_LINES 0x0001
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_STRIP 0x0003
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_NEVER 0x0200
-#define GL_LESS 0x0201
-#define GL_EQUAL 0x0202
-#define GL_LEQUAL 0x0203
-#define GL_GREATER 0x0204
-#define GL_NOTEQUAL 0x0205
-#define GL_GEQUAL 0x0206
-#define GL_ALWAYS 0x0207
-#define GL_ZERO 0
-#define GL_ONE 1
-#define GL_SRC_COLOR 0x0300
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_SRC_ALPHA 0x0302
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_DST_ALPHA 0x0304
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_DST_COLOR 0x0306
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_NONE 0
-#define GL_FRONT_LEFT 0x0400
-#define GL_FRONT_RIGHT 0x0401
-#define GL_BACK_LEFT 0x0402
-#define GL_BACK_RIGHT 0x0403
-#define GL_FRONT 0x0404
-#define GL_BACK 0x0405
-#define GL_LEFT 0x0406
-#define GL_RIGHT 0x0407
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_NO_ERROR 0
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVALID_OPERATION 0x0502
-#define GL_OUT_OF_MEMORY 0x0505
-#define GL_CW 0x0900
-#define GL_CCW 0x0901
-#define GL_POINT_SIZE 0x0B11
-#define GL_POINT_SIZE_RANGE 0x0B12
-#define GL_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_LINE_SMOOTH 0x0B20
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINE_WIDTH_RANGE 0x0B22
-#define GL_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_POLYGON_MODE 0x0B40
-#define GL_POLYGON_SMOOTH 0x0B41
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_FRONT_FACE 0x0B46
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_VIEWPORT 0x0BA2
-#define GL_DITHER 0x0BD0
-#define GL_BLEND_DST 0x0BE0
-#define GL_BLEND_SRC 0x0BE1
-#define GL_BLEND 0x0BE2
-#define GL_LOGIC_OP_MODE 0x0BF0
-#define GL_COLOR_LOGIC_OP 0x0BF2
-#define GL_DRAW_BUFFER 0x0C01
-#define GL_READ_BUFFER 0x0C02
-#define GL_SCISSOR_BOX 0x0C10
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_DOUBLEBUFFER 0x0C32
-#define GL_STEREO 0x0C33
-#define GL_LINE_SMOOTH_HINT 0x0C52
-#define GL_POLYGON_SMOOTH_HINT 0x0C53
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_UNPACK_LSB_FIRST 0x0CF1
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_PACK_LSB_FIRST 0x0D01
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_POLYGON_OFFSET_POINT 0x2A01
-#define GL_POLYGON_OFFSET_LINE 0x2A02
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_TEXTURE_BINDING_1D 0x8068
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_WIDTH 0x1000
-#define GL_TEXTURE_HEIGHT 0x1001
-#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
-#define GL_TEXTURE_BORDER_COLOR 0x1004
-#define GL_TEXTURE_RED_SIZE 0x805C
-#define GL_TEXTURE_GREEN_SIZE 0x805D
-#define GL_TEXTURE_BLUE_SIZE 0x805E
-#define GL_TEXTURE_ALPHA_SIZE 0x805F
-#define GL_DONT_CARE 0x1100
-#define GL_FASTEST 0x1101
-#define GL_NICEST 0x1102
-#define GL_BYTE 0x1400
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_SHORT 0x1402
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_INT 0x1404
-#define GL_UNSIGNED_INT 0x1405
-#define GL_FLOAT 0x1406
-#define GL_DOUBLE 0x140A
-#define GL_CLEAR 0x1500
-#define GL_AND 0x1501
-#define GL_AND_REVERSE 0x1502
-#define GL_COPY 0x1503
-#define GL_AND_INVERTED 0x1504
-#define GL_NOOP 0x1505
-#define GL_XOR 0x1506
-#define GL_OR 0x1507
-#define GL_NOR 0x1508
-#define GL_EQUIV 0x1509
-#define GL_INVERT 0x150A
-#define GL_OR_REVERSE 0x150B
-#define GL_COPY_INVERTED 0x150C
-#define GL_OR_INVERTED 0x150D
-#define GL_NAND 0x150E
-#define GL_SET 0x150F
-#define GL_TEXTURE 0x1702
-#define GL_COLOR 0x1800
-#define GL_DEPTH 0x1801
-#define GL_STENCIL 0x1802
-#define GL_STENCIL_INDEX 0x1901
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_RED 0x1903
-#define GL_GREEN 0x1904
-#define GL_BLUE 0x1905
-#define GL_ALPHA 0x1906
-#define GL_RGB 0x1907
-#define GL_RGBA 0x1908
-#define GL_POINT 0x1B00
-#define GL_LINE 0x1B01
-#define GL_FILL 0x1B02
-#define GL_KEEP 0x1E00
-#define GL_REPLACE 0x1E01
-#define GL_INCR 0x1E02
-#define GL_DECR 0x1E03
-#define GL_VENDOR 0x1F00
-#define GL_RENDERER 0x1F01
-#define GL_VERSION 0x1F02
-#define GL_EXTENSIONS 0x1F03
-#define GL_NEAREST 0x2600
-#define GL_LINEAR 0x2601
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_PROXY_TEXTURE_1D 0x8063
-#define GL_PROXY_TEXTURE_2D 0x8064
-#define GL_REPEAT 0x2901
-#define GL_R3_G3_B2 0x2A10
-#define GL_RGB4 0x804F
-#define GL_RGB5 0x8050
-#define GL_RGB8 0x8051
-#define GL_RGB10 0x8052
-#define GL_RGB12 0x8053
-#define GL_RGB16 0x8054
-#define GL_RGBA2 0x8055
-#define GL_RGBA4 0x8056
-#define GL_RGB5_A1 0x8057
-#define GL_RGBA8 0x8058
-#define GL_RGB10_A2 0x8059
-#define GL_RGBA12 0x805A
-#define GL_RGBA16 0x805B
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_TEXTURE_3D 0x806F
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_MULTISAMPLE 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_COMPRESSED_RGB 0x84ED
-#define GL_COMPRESSED_RGBA 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
-#define GL_TEXTURE_COMPRESSED 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_DEPTH_COMPONENT32 0x81A7
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_TEXTURE_LOD_BIAS 0x8501
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-#define GL_TEXTURE_DEPTH_SIZE 0x884A
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_QUERY_COUNTER_BITS 0x8864
-#define GL_CURRENT_QUERY 0x8865
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_READ_ONLY 0x88B8
-#define GL_WRITE_ONLY 0x88B9
-#define GL_READ_WRITE 0x88BA
-#define GL_BUFFER_ACCESS 0x88BB
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_STREAM_COPY 0x88E2
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STATIC_COPY 0x88E6
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_SAMPLES_PASSED 0x8914
-#define GL_SRC1_ALPHA 0x8589
-#define GL_BLEND_EQUATION_RGB 0x8009
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLER_1D_SHADOW 0x8B61
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_DELETE_STATUS 0x8B80
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
-#define GL_LOWER_LEFT 0x8CA1
-#define GL_UPPER_LEFT 0x8CA2
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
-#define GL_FLOAT_MAT2x3 0x8B65
-#define GL_FLOAT_MAT2x4 0x8B66
-#define GL_FLOAT_MAT3x2 0x8B67
-#define GL_FLOAT_MAT3x4 0x8B68
-#define GL_FLOAT_MAT4x2 0x8B69
-#define GL_FLOAT_MAT4x3 0x8B6A
-#define GL_SRGB 0x8C40
-#define GL_SRGB8 0x8C41
-#define GL_SRGB_ALPHA 0x8C42
-#define GL_SRGB8_ALPHA8 0x8C43
-#define GL_COMPRESSED_SRGB 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
-#define GL_COMPARE_REF_TO_TEXTURE 0x884E
-#define GL_CLIP_DISTANCE0 0x3000
-#define GL_CLIP_DISTANCE1 0x3001
-#define GL_CLIP_DISTANCE2 0x3002
-#define GL_CLIP_DISTANCE3 0x3003
-#define GL_CLIP_DISTANCE4 0x3004
-#define GL_CLIP_DISTANCE5 0x3005
-#define GL_CLIP_DISTANCE6 0x3006
-#define GL_CLIP_DISTANCE7 0x3007
-#define GL_MAX_CLIP_DISTANCES 0x0D32
-#define GL_MAJOR_VERSION 0x821B
-#define GL_MINOR_VERSION 0x821C
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_CONTEXT_FLAGS 0x821E
-#define GL_COMPRESSED_RED 0x8225
-#define GL_COMPRESSED_RG 0x8226
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_RGBA32F 0x8814
-#define GL_RGB32F 0x8815
-#define GL_RGBA16F 0x881A
-#define GL_RGB16F 0x881B
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
-#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
-#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
-#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
-#define GL_CLAMP_READ_COLOR 0x891C
-#define GL_FIXED_ONLY 0x891D
-#define GL_MAX_VARYING_COMPONENTS 0x8B4B
-#define GL_TEXTURE_1D_ARRAY 0x8C18
-#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
-#define GL_TEXTURE_2D_ARRAY 0x8C1A
-#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
-#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
-#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
-#define GL_R11F_G11F_B10F 0x8C3A
-#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
-#define GL_RGB9_E5 0x8C3D
-#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
-#define GL_TEXTURE_SHARED_SIZE 0x8C3F
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_PRIMITIVES_GENERATED 0x8C87
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_RASTERIZER_DISCARD 0x8C89
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_INTERLEAVED_ATTRIBS 0x8C8C
-#define GL_SEPARATE_ATTRIBS 0x8C8D
-#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_RGBA32UI 0x8D70
-#define GL_RGB32UI 0x8D71
-#define GL_RGBA16UI 0x8D76
-#define GL_RGB16UI 0x8D77
-#define GL_RGBA8UI 0x8D7C
-#define GL_RGB8UI 0x8D7D
-#define GL_RGBA32I 0x8D82
-#define GL_RGB32I 0x8D83
-#define GL_RGBA16I 0x8D88
-#define GL_RGB16I 0x8D89
-#define GL_RGBA8I 0x8D8E
-#define GL_RGB8I 0x8D8F
-#define GL_RED_INTEGER 0x8D94
-#define GL_GREEN_INTEGER 0x8D95
-#define GL_BLUE_INTEGER 0x8D96
-#define GL_RGB_INTEGER 0x8D98
-#define GL_RGBA_INTEGER 0x8D99
-#define GL_BGR_INTEGER 0x8D9A
-#define GL_BGRA_INTEGER 0x8D9B
-#define GL_SAMPLER_1D_ARRAY 0x8DC0
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#define GL_INT_SAMPLER_1D 0x8DC9
-#define GL_INT_SAMPLER_2D 0x8DCA
-#define GL_INT_SAMPLER_3D 0x8DCB
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#define GL_QUERY_WAIT 0x8E13
-#define GL_QUERY_NO_WAIT 0x8E14
-#define GL_QUERY_BY_REGION_WAIT 0x8E15
-#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
-#define GL_BUFFER_ACCESS_FLAGS 0x911F
-#define GL_BUFFER_MAP_LENGTH 0x9120
-#define GL_BUFFER_MAP_OFFSET 0x9121
-#define GL_DEPTH_COMPONENT32F 0x8CAC
-#define GL_DEPTH32F_STENCIL8 0x8CAD
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_DEFAULT 0x8218
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#define GL_DEPTH_STENCIL 0x84F9
-#define GL_UNSIGNED_INT_24_8 0x84FA
-#define GL_DEPTH24_STENCIL8 0x88F0
-#define GL_TEXTURE_STENCIL_SIZE 0x88F1
-#define GL_TEXTURE_RED_TYPE 0x8C10
-#define GL_TEXTURE_GREEN_TYPE 0x8C11
-#define GL_TEXTURE_BLUE_TYPE 0x8C12
-#define GL_TEXTURE_ALPHA_TYPE 0x8C13
-#define GL_TEXTURE_DEPTH_TYPE 0x8C16
-#define GL_UNSIGNED_NORMALIZED 0x8C17
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
-#define GL_RENDERBUFFER_SAMPLES 0x8CAB
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#define GL_COLOR_ATTACHMENT3 0x8CE3
-#define GL_COLOR_ATTACHMENT4 0x8CE4
-#define GL_COLOR_ATTACHMENT5 0x8CE5
-#define GL_COLOR_ATTACHMENT6 0x8CE6
-#define GL_COLOR_ATTACHMENT7 0x8CE7
-#define GL_COLOR_ATTACHMENT8 0x8CE8
-#define GL_COLOR_ATTACHMENT9 0x8CE9
-#define GL_COLOR_ATTACHMENT10 0x8CEA
-#define GL_COLOR_ATTACHMENT11 0x8CEB
-#define GL_COLOR_ATTACHMENT12 0x8CEC
-#define GL_COLOR_ATTACHMENT13 0x8CED
-#define GL_COLOR_ATTACHMENT14 0x8CEE
-#define GL_COLOR_ATTACHMENT15 0x8CEF
-#define GL_COLOR_ATTACHMENT16 0x8CF0
-#define GL_COLOR_ATTACHMENT17 0x8CF1
-#define GL_COLOR_ATTACHMENT18 0x8CF2
-#define GL_COLOR_ATTACHMENT19 0x8CF3
-#define GL_COLOR_ATTACHMENT20 0x8CF4
-#define GL_COLOR_ATTACHMENT21 0x8CF5
-#define GL_COLOR_ATTACHMENT22 0x8CF6
-#define GL_COLOR_ATTACHMENT23 0x8CF7
-#define GL_COLOR_ATTACHMENT24 0x8CF8
-#define GL_COLOR_ATTACHMENT25 0x8CF9
-#define GL_COLOR_ATTACHMENT26 0x8CFA
-#define GL_COLOR_ATTACHMENT27 0x8CFB
-#define GL_COLOR_ATTACHMENT28 0x8CFC
-#define GL_COLOR_ATTACHMENT29 0x8CFD
-#define GL_COLOR_ATTACHMENT30 0x8CFE
-#define GL_COLOR_ATTACHMENT31 0x8CFF
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_RENDERBUFFER 0x8D41
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_STENCIL_INDEX1 0x8D46
-#define GL_STENCIL_INDEX4 0x8D47
-#define GL_STENCIL_INDEX8 0x8D48
-#define GL_STENCIL_INDEX16 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_MAX_SAMPLES 0x8D57
-#define GL_INDEX 0x8222
-#define GL_FRAMEBUFFER_SRGB 0x8DB9
-#define GL_HALF_FLOAT 0x140B
-#define GL_MAP_READ_BIT 0x0001
-#define GL_MAP_WRITE_BIT 0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
-#define GL_COMPRESSED_RED_RGTC1 0x8DBB
-#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
-#define GL_COMPRESSED_RG_RGTC2 0x8DBD
-#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
-#define GL_RG 0x8227
-#define GL_RG_INTEGER 0x8228
-#define GL_R8 0x8229
-#define GL_R16 0x822A
-#define GL_RG8 0x822B
-#define GL_RG16 0x822C
-#define GL_R16F 0x822D
-#define GL_R32F 0x822E
-#define GL_RG16F 0x822F
-#define GL_RG32F 0x8230
-#define GL_R8I 0x8231
-#define GL_R8UI 0x8232
-#define GL_R16I 0x8233
-#define GL_R16UI 0x8234
-#define GL_R32I 0x8235
-#define GL_R32UI 0x8236
-#define GL_RG8I 0x8237
-#define GL_RG8UI 0x8238
-#define GL_RG16I 0x8239
-#define GL_RG16UI 0x823A
-#define GL_RG32I 0x823B
-#define GL_RG32UI 0x823C
-#define GL_VERTEX_ARRAY_BINDING 0x85B5
-#define GL_SAMPLER_2D_RECT 0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
-#define GL_SAMPLER_BUFFER 0x8DC2
-#define GL_INT_SAMPLER_2D_RECT 0x8DCD
-#define GL_INT_SAMPLER_BUFFER 0x8DD0
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
-#define GL_TEXTURE_BUFFER 0x8C2A
-#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
-#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
-#define GL_R8_SNORM 0x8F94
-#define GL_RG8_SNORM 0x8F95
-#define GL_RGB8_SNORM 0x8F96
-#define GL_RGBA8_SNORM 0x8F97
-#define GL_R16_SNORM 0x8F98
-#define GL_RG16_SNORM 0x8F99
-#define GL_RGB16_SNORM 0x8F9A
-#define GL_RGBA16_SNORM 0x8F9B
-#define GL_SIGNED_NORMALIZED 0x8F9C
-#define GL_PRIMITIVE_RESTART 0x8F9D
-#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
-#define GL_COPY_READ_BUFFER 0x8F36
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#define GL_UNIFORM_BUFFER 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING 0x8A28
-#define GL_UNIFORM_BUFFER_START 0x8A29
-#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
-#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
-#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#define GL_UNIFORM_TYPE 0x8A37
-#define GL_UNIFORM_SIZE 0x8A38
-#define GL_UNIFORM_NAME_LENGTH 0x8A39
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#define GL_UNIFORM_OFFSET 0x8A3B
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_INVALID_INDEX 0xFFFFFFFF
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_LINES_ADJACENCY 0x000A
-#define GL_LINE_STRIP_ADJACENCY 0x000B
-#define GL_TRIANGLES_ADJACENCY 0x000C
-#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
-#define GL_PROGRAM_POINT_SIZE 0x8642
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
-#define GL_GEOMETRY_SHADER 0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT 0x8916
-#define GL_GEOMETRY_INPUT_TYPE 0x8917
-#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
-#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
-#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_DEPTH_CLAMP 0x864F
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
-#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
-#define GL_LAST_VERTEX_CONVENTION 0x8E4E
-#define GL_PROVOKING_VERTEX 0x8E4F
-#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
-#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
-#define GL_OBJECT_TYPE 0x9112
-#define GL_SYNC_CONDITION 0x9113
-#define GL_SYNC_STATUS 0x9114
-#define GL_SYNC_FLAGS 0x9115
-#define GL_SYNC_FENCE 0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#define GL_UNSIGNALED 0x9118
-#define GL_SIGNALED 0x9119
-#define GL_ALREADY_SIGNALED 0x911A
-#define GL_TIMEOUT_EXPIRED 0x911B
-#define GL_CONDITION_SATISFIED 0x911C
-#define GL_WAIT_FAILED 0x911D
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#define GL_SAMPLE_POSITION 0x8E50
-#define GL_SAMPLE_MASK 0x8E51
-#define GL_SAMPLE_MASK_VALUE 0x8E52
-#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
-#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
-#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
-#define GL_TEXTURE_SAMPLES 0x9106
-#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
-#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
-#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
-#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
-#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
-#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
-#define GL_MAX_INTEGER_SAMPLES 0x9110
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_SRC1_COLOR 0x88F9
-#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
-#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
-#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
-#define GL_ANY_SAMPLES_PASSED 0x8C2F
-#define GL_SAMPLER_BINDING 0x8919
-#define GL_RGB10_A2UI 0x906F
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
-#define GL_TIME_ELAPSED 0x88BF
-#define GL_TIMESTAMP 0x8E28
-#define GL_INT_2_10_10_10_REV 0x8D9F
-#ifndef GL_VERSION_1_0
-#define GL_VERSION_1_0 1
-GLAPI int GLAD_GL_VERSION_1_0;
-typedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum mode);
-GLAPI PFNGLCULLFACEPROC glad_glCullFace;
-#define glCullFace glad_glCullFace
-typedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode);
-GLAPI PFNGLFRONTFACEPROC glad_glFrontFace;
-#define glFrontFace glad_glFrontFace
-typedef void (APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode);
-GLAPI PFNGLHINTPROC glad_glHint;
-#define glHint glad_glHint
-typedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width);
-GLAPI PFNGLLINEWIDTHPROC glad_glLineWidth;
-#define glLineWidth glad_glLineWidth
-typedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size);
-GLAPI PFNGLPOINTSIZEPROC glad_glPointSize;
-#define glPointSize glad_glPointSize
-typedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
-GLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-#define glPolygonMode glad_glPolygonMode
-typedef void (APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLSCISSORPROC glad_glScissor;
-#define glScissor glad_glScissor
-typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
-GLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-#define glTexParameterf glad_glTexParameterf
-typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat* params);
-GLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-#define glTexParameterfv glad_glTexParameterfv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
-GLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-#define glTexParameteri glad_glTexParameteri
-typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint* params);
-GLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-#define glTexParameteriv glad_glTexParameteriv
-typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-#define glTexImage1D glad_glTexImage1D
-typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-#define glTexImage2D glad_glTexImage2D
-typedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf);
-GLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-#define glDrawBuffer glad_glDrawBuffer
-typedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield mask);
-GLAPI PFNGLCLEARPROC glad_glClear;
-#define glClear glad_glClear
-typedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLCLEARCOLORPROC glad_glClearColor;
-#define glClearColor glad_glClearColor
-typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s);
-GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil;
-#define glClearStencil glad_glClearStencil
-typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth);
-GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth;
-#define glClearDepth glad_glClearDepth
-typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask);
-GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;
-#define glStencilMask glad_glStencilMask
-typedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-GLAPI PFNGLCOLORMASKPROC glad_glColorMask;
-#define glColorMask glad_glColorMask
-typedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag);
-GLAPI PFNGLDEPTHMASKPROC glad_glDepthMask;
-#define glDepthMask glad_glDepthMask
-typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap);
-GLAPI PFNGLDISABLEPROC glad_glDisable;
-#define glDisable glad_glDisable
-typedef void (APIENTRYP PFNGLENABLEPROC)(GLenum cap);
-GLAPI PFNGLENABLEPROC glad_glEnable;
-#define glEnable glad_glEnable
-typedef void (APIENTRYP PFNGLFINISHPROC)();
-GLAPI PFNGLFINISHPROC glad_glFinish;
-#define glFinish glad_glFinish
-typedef void (APIENTRYP PFNGLFLUSHPROC)();
-GLAPI PFNGLFLUSHPROC glad_glFlush;
-#define glFlush glad_glFlush
-typedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
-GLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc;
-#define glBlendFunc glad_glBlendFunc
-typedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode);
-GLAPI PFNGLLOGICOPPROC glad_glLogicOp;
-#define glLogicOp glad_glLogicOp
-typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
-GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-#define glStencilFunc glad_glStencilFunc
-typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
-GLAPI PFNGLSTENCILOPPROC glad_glStencilOp;
-#define glStencilOp glad_glStencilOp
-typedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func);
-GLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-#define glDepthFunc glad_glDepthFunc
-typedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
-GLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-#define glPixelStoref glad_glPixelStoref
-typedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
-GLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-#define glPixelStorei glad_glPixelStorei
-typedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum src);
-GLAPI PFNGLREADBUFFERPROC glad_glReadBuffer;
-#define glReadBuffer glad_glReadBuffer
-typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
-GLAPI PFNGLREADPIXELSPROC glad_glReadPixels;
-#define glReadPixels glad_glReadPixels
-typedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean* data);
-GLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-#define glGetBooleanv glad_glGetBooleanv
-typedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble* data);
-GLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-#define glGetDoublev glad_glGetDoublev
-typedef GLenum (APIENTRYP PFNGLGETERRORPROC)();
-GLAPI PFNGLGETERRORPROC glad_glGetError;
-#define glGetError glad_glGetError
-typedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat* data);
-GLAPI PFNGLGETFLOATVPROC glad_glGetFloatv;
-#define glGetFloatv glad_glGetFloatv
-typedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint* data);
-GLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-#define glGetIntegerv glad_glGetIntegerv
-typedef const GLubyte* (APIENTRYP PFNGLGETSTRINGPROC)(GLenum name);
-GLAPI PFNGLGETSTRINGPROC glad_glGetString;
-#define glGetString glad_glGetString
-typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void* pixels);
-GLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-#define glGetTexImage glad_glGetTexImage
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-#define glGetTexParameterfv glad_glGetTexParameterfv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-#define glGetTexParameteriv glad_glGetTexParameteriv
-typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
-typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
-typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap);
-GLAPI PFNGLISENABLEDPROC glad_glIsEnabled;
-#define glIsEnabled glad_glIsEnabled
-typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble near, GLdouble far);
-GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange;
-#define glDepthRange glad_glDepthRange
-typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLVIEWPORTPROC glad_glViewport;
-#define glViewport glad_glViewport
-#endif
-#ifndef GL_VERSION_1_1
-#define GL_VERSION_1_1 1
-GLAPI int GLAD_GL_VERSION_1_1;
-typedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
-GLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-#define glDrawArrays glad_glDrawArrays
-typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices);
-GLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-#define glDrawElements glad_glDrawElements
-typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
-GLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-#define glPolygonOffset glad_glPolygonOffset
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-GLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-#define glCopyTexImage1D glad_glCopyTexImage1D
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-#define glCopyTexImage2D glad_glCopyTexImage2D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-GLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-#define glTexSubImage1D glad_glTexSubImage1D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-#define glTexSubImage2D glad_glTexSubImage2D
-typedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
-GLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture;
-#define glBindTexture glad_glBindTexture
-typedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint* textures);
-GLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-#define glDeleteTextures glad_glDeleteTextures
-typedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint* textures);
-GLAPI PFNGLGENTEXTURESPROC glad_glGenTextures;
-#define glGenTextures glad_glGenTextures
-typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture);
-GLAPI PFNGLISTEXTUREPROC glad_glIsTexture;
-#define glIsTexture glad_glIsTexture
-#endif
-#ifndef GL_VERSION_1_2
-#define GL_VERSION_1_2 1
-GLAPI int GLAD_GL_VERSION_1_2;
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices);
-GLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-#define glDrawRangeElements glad_glDrawRangeElements
-typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-#define glTexImage3D glad_glTexImage3D
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels);
-GLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-#define glTexSubImage3D glad_glTexSubImage3D
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
-#endif
-#ifndef GL_VERSION_1_3
-#define GL_VERSION_1_3 1
-GLAPI int GLAD_GL_VERSION_1_3;
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture);
-GLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-#define glActiveTexture glad_glActiveTexture
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
-GLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-#define glSampleCoverage glad_glSampleCoverage
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-#define glCompressedTexImage3D glad_glCompressedTexImage3D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-#define glCompressedTexImage2D glad_glCompressedTexImage2D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-#define glCompressedTexImage1D glad_glCompressedTexImage1D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void* img);
-GLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-#define glGetCompressedTexImage glad_glGetCompressedTexImage
-#endif
-#ifndef GL_VERSION_1_4
-#define GL_VERSION_1_4 1
-GLAPI int GLAD_GL_VERSION_1_4;
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-#define glBlendFuncSeparate glad_glBlendFuncSeparate
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount);
-GLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-#define glMultiDrawArrays glad_glMultiDrawArrays
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei* count, GLenum type, const void** indices, GLsizei drawcount);
-GLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-#define glMultiDrawElements glad_glMultiDrawElements
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
-GLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-#define glPointParameterf glad_glPointParameterf
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat* params);
-GLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-#define glPointParameterfv glad_glPointParameterfv
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
-GLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-#define glPointParameteri glad_glPointParameteri
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint* params);
-GLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-#define glPointParameteriv glad_glPointParameteriv
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLBLENDCOLORPROC glad_glBlendColor;
-#define glBlendColor glad_glBlendColor
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode);
-GLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-#define glBlendEquation glad_glBlendEquation
-#endif
-#ifndef GL_VERSION_1_5
-#define GL_VERSION_1_5 1
-GLAPI int GLAD_GL_VERSION_1_5;
-typedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint* ids);
-GLAPI PFNGLGENQUERIESPROC glad_glGenQueries;
-#define glGenQueries glad_glGenQueries
-typedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint* ids);
-GLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-#define glDeleteQueries glad_glDeleteQueries
-typedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint id);
-GLAPI PFNGLISQUERYPROC glad_glIsQuery;
-#define glIsQuery glad_glIsQuery
-typedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
-GLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery;
-#define glBeginQuery glad_glBeginQuery
-typedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum target);
-GLAPI PFNGLENDQUERYPROC glad_glEndQuery;
-#define glEndQuery glad_glEndQuery
-typedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-#define glGetQueryiv glad_glGetQueryiv
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint* params);
-GLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-#define glGetQueryObjectiv glad_glGetQueryObjectiv
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint* params);
-GLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
-typedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
-GLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer;
-#define glBindBuffer glad_glBindBuffer
-typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint* buffers);
-GLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-#define glDeleteBuffers glad_glDeleteBuffers
-typedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint* buffers);
-GLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers;
-#define glGenBuffers glad_glGenBuffers
-typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer);
-GLAPI PFNGLISBUFFERPROC glad_glIsBuffer;
-#define glIsBuffer glad_glIsBuffer
-typedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void* data, GLenum usage);
-GLAPI PFNGLBUFFERDATAPROC glad_glBufferData;
-#define glBufferData glad_glBufferData
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
-GLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-#define glBufferSubData glad_glBufferSubData
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void* data);
-GLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-#define glGetBufferSubData glad_glGetBufferSubData
-typedef void* (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
-GLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer;
-#define glMapBuffer glad_glMapBuffer
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target);
-GLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-#define glUnmapBuffer glad_glUnmapBuffer
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-#define glGetBufferParameteriv glad_glGetBufferParameteriv
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void** params);
-GLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-#define glGetBufferPointerv glad_glGetBufferPointerv
-#endif
-#ifndef GL_VERSION_2_0
-#define GL_VERSION_2_0 1
-GLAPI int GLAD_GL_VERSION_2_0;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-#define glBlendEquationSeparate glad_glBlendEquationSeparate
-typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum* bufs);
-GLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-#define glDrawBuffers glad_glDrawBuffers
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-GLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-#define glStencilOpSeparate glad_glStencilOpSeparate
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
-GLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-#define glStencilFuncSeparate glad_glStencilFuncSeparate
-typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
-GLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-#define glStencilMaskSeparate glad_glStencilMaskSeparate
-typedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
-GLAPI PFNGLATTACHSHADERPROC glad_glAttachShader;
-#define glAttachShader glad_glAttachShader
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar* name);
-GLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-#define glBindAttribLocation glad_glBindAttribLocation
-typedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader);
-GLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader;
-#define glCompileShader glad_glCompileShader
-typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)();
-GLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-#define glCreateProgram glad_glCreateProgram
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type);
-GLAPI PFNGLCREATESHADERPROC glad_glCreateShader;
-#define glCreateShader glad_glCreateShader
-typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-#define glDeleteProgram glad_glDeleteProgram
-typedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader);
-GLAPI PFNGLDELETESHADERPROC glad_glDeleteShader;
-#define glDeleteShader glad_glDeleteShader
-typedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
-GLAPI PFNGLDETACHSHADERPROC glad_glDetachShader;
-#define glDetachShader glad_glDetachShader
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
-GLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
-GLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-#define glGetActiveAttrib glad_glGetActiveAttrib
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-#define glGetActiveUniform glad_glGetActiveUniform
-typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders);
-GLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-#define glGetAttachedShaders glad_glGetAttachedShaders
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-#define glGetAttribLocation glad_glGetAttribLocation
-typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint* params);
-GLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-#define glGetProgramiv glad_glGetProgramiv
-typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
-GLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-#define glGetProgramInfoLog glad_glGetProgramInfoLog
-typedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint* params);
-GLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-#define glGetShaderiv glad_glGetShaderiv
-typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog);
-GLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-#define glGetShaderInfoLog glad_glGetShaderInfoLog
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source);
-GLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-#define glGetShaderSource glad_glGetShaderSource
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-#define glGetUniformLocation glad_glGetUniformLocation
-typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat* params);
-GLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-#define glGetUniformfv glad_glGetUniformfv
-typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint* params);
-GLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-#define glGetUniformiv glad_glGetUniformiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble* params);
-GLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-#define glGetVertexAttribdv glad_glGetVertexAttribdv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-#define glGetVertexAttribfv glad_glGetVertexAttribfv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-#define glGetVertexAttribiv glad_glGetVertexAttribiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void** pointer);
-GLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint program);
-GLAPI PFNGLISPROGRAMPROC glad_glIsProgram;
-#define glIsProgram glad_glIsProgram
-typedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint shader);
-GLAPI PFNGLISSHADERPROC glad_glIsShader;
-#define glIsShader glad_glIsShader
-typedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program);
-GLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-#define glLinkProgram glad_glLinkProgram
-typedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
-GLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource;
-#define glShaderSource glad_glShaderSource
-typedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram;
-#define glUseProgram glad_glUseProgram
-typedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
-GLAPI PFNGLUNIFORM1FPROC glad_glUniform1f;
-#define glUniform1f glad_glUniform1f
-typedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
-GLAPI PFNGLUNIFORM2FPROC glad_glUniform2f;
-#define glUniform2f glad_glUniform2f
-typedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-GLAPI PFNGLUNIFORM3FPROC glad_glUniform3f;
-#define glUniform3f glad_glUniform3f
-typedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-GLAPI PFNGLUNIFORM4FPROC glad_glUniform4f;
-#define glUniform4f glad_glUniform4f
-typedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
-GLAPI PFNGLUNIFORM1IPROC glad_glUniform1i;
-#define glUniform1i glad_glUniform1i
-typedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
-GLAPI PFNGLUNIFORM2IPROC glad_glUniform2i;
-#define glUniform2i glad_glUniform2i
-typedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
-GLAPI PFNGLUNIFORM3IPROC glad_glUniform3i;
-#define glUniform3i glad_glUniform3i
-typedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-GLAPI PFNGLUNIFORM4IPROC glad_glUniform4i;
-#define glUniform4i glad_glUniform4i
-typedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-#define glUniform1fv glad_glUniform1fv
-typedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-#define glUniform2fv glad_glUniform2fv
-typedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-#define glUniform3fv glad_glUniform3fv
-typedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat* value);
-GLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-#define glUniform4fv glad_glUniform4fv
-typedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-#define glUniform1iv glad_glUniform1iv
-typedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-#define glUniform2iv glad_glUniform2iv
-typedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-#define glUniform3iv glad_glUniform3iv
-typedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint* value);
-GLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-#define glUniform4iv glad_glUniform4iv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-#define glUniformMatrix2fv glad_glUniformMatrix2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-#define glUniformMatrix3fv glad_glUniformMatrix3fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-#define glUniformMatrix4fv glad_glUniformMatrix4fv
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program);
-GLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-#define glValidateProgram glad_glValidateProgram
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
-GLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-#define glVertexAttrib1d glad_glVertexAttrib1d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-#define glVertexAttrib1dv glad_glVertexAttrib1dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
-GLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-#define glVertexAttrib1f glad_glVertexAttrib1f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-#define glVertexAttrib1fv glad_glVertexAttrib1fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
-GLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-#define glVertexAttrib1s glad_glVertexAttrib1s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-#define glVertexAttrib1sv glad_glVertexAttrib1sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
-GLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-#define glVertexAttrib2d glad_glVertexAttrib2d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-#define glVertexAttrib2dv glad_glVertexAttrib2dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
-GLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-#define glVertexAttrib2f glad_glVertexAttrib2f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-#define glVertexAttrib2fv glad_glVertexAttrib2fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
-GLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-#define glVertexAttrib2s glad_glVertexAttrib2s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-#define glVertexAttrib2sv glad_glVertexAttrib2sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-#define glVertexAttrib3d glad_glVertexAttrib3d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-#define glVertexAttrib3dv glad_glVertexAttrib3dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-#define glVertexAttrib3f glad_glVertexAttrib3f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-#define glVertexAttrib3fv glad_glVertexAttrib3fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-#define glVertexAttrib3s glad_glVertexAttrib3s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-#define glVertexAttrib3sv glad_glVertexAttrib3sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-#define glVertexAttrib4bv glad_glVertexAttrib4bv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-#define glVertexAttrib4d glad_glVertexAttrib4d
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-#define glVertexAttrib4dv glad_glVertexAttrib4dv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-#define glVertexAttrib4f glad_glVertexAttrib4f
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-#define glVertexAttrib4fv glad_glVertexAttrib4fv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-#define glVertexAttrib4iv glad_glVertexAttrib4iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-#define glVertexAttrib4s glad_glVertexAttrib4s
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-#define glVertexAttrib4sv glad_glVertexAttrib4sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-#define glVertexAttrib4usv glad_glVertexAttrib4usv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-#define glVertexAttribPointer glad_glVertexAttribPointer
-#endif
-#ifndef GL_VERSION_2_1
-#define GL_VERSION_2_1 1
-GLAPI int GLAD_GL_VERSION_2_1;
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
-#endif
-#ifndef GL_VERSION_3_0
-#define GL_VERSION_3_0 1
-GLAPI int GLAD_GL_VERSION_3_0;
-typedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
-GLAPI PFNGLCOLORMASKIPROC glad_glColorMaski;
-#define glColorMaski glad_glColorMaski
-typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean* data);
-GLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-#define glGetBooleani_v glad_glGetBooleani_v
-typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint* data);
-GLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-#define glGetIntegeri_v glad_glGetIntegeri_v
-typedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLENABLEIPROC glad_glEnablei;
-#define glEnablei glad_glEnablei
-typedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLDISABLEIPROC glad_glDisablei;
-#define glDisablei glad_glDisablei
-typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
-GLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi;
-#define glIsEnabledi glad_glIsEnabledi
-typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
-GLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-#define glBeginTransformFeedback glad_glBeginTransformFeedback
-typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)();
-GLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-#define glEndTransformFeedback glad_glEndTransformFeedback
-typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-#define glBindBufferRange glad_glBindBufferRange
-typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
-GLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-#define glBindBufferBase glad_glBindBufferBase
-typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar** varyings, GLenum bufferMode);
-GLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
-typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
-GLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
-typedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
-GLAPI PFNGLCLAMPCOLORPROC glad_glClampColor;
-#define glClampColor glad_glClampColor
-typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
-GLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-#define glBeginConditionalRender glad_glBeginConditionalRender
-typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)();
-GLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-#define glEndConditionalRender glad_glEndConditionalRender
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-#define glVertexAttribIPointer glad_glVertexAttribIPointer
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint* params);
-GLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
-GLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-#define glVertexAttribI1i glad_glVertexAttribI1i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
-GLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-#define glVertexAttribI2i glad_glVertexAttribI2i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
-GLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-#define glVertexAttribI3i glad_glVertexAttribI3i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
-GLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-#define glVertexAttribI4i glad_glVertexAttribI4i
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
-GLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-#define glVertexAttribI1ui glad_glVertexAttribI1ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
-GLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-#define glVertexAttribI2ui glad_glVertexAttribI2ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
-GLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-#define glVertexAttribI3ui glad_glVertexAttribI3ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-#define glVertexAttribI4ui glad_glVertexAttribI4ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-#define glVertexAttribI1iv glad_glVertexAttribI1iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-#define glVertexAttribI2iv glad_glVertexAttribI2iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-#define glVertexAttribI3iv glad_glVertexAttribI3iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-#define glVertexAttribI4iv glad_glVertexAttribI4iv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-#define glVertexAttribI4bv glad_glVertexAttribI4bv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-#define glVertexAttribI4sv glad_glVertexAttribI4sv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-#define glVertexAttribI4usv glad_glVertexAttribI4usv
-typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint* params);
-GLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-#define glGetUniformuiv glad_glGetUniformuiv
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar* name);
-GLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-#define glBindFragDataLocation glad_glBindFragDataLocation
-typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-#define glGetFragDataLocation glad_glGetFragDataLocation
-typedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
-GLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-#define glUniform1ui glad_glUniform1ui
-typedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
-GLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-#define glUniform2ui glad_glUniform2ui
-typedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
-GLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-#define glUniform3ui glad_glUniform3ui
-typedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-#define glUniform4ui glad_glUniform4ui
-typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-#define glUniform1uiv glad_glUniform1uiv
-typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-#define glUniform2uiv glad_glUniform2uiv
-typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-#define glUniform3uiv glad_glUniform3uiv
-typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint* value);
-GLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-#define glUniform4uiv glad_glUniform4uiv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint* params);
-GLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-#define glTexParameterIiv glad_glTexParameterIiv
-typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint* params);
-GLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-#define glTexParameterIuiv glad_glTexParameterIuiv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-#define glGetTexParameterIiv glad_glGetTexParameterIiv
-typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint* params);
-GLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint* value);
-GLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-#define glClearBufferiv glad_glClearBufferiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint* value);
-GLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-#define glClearBufferuiv glad_glClearBufferuiv
-typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat* value);
-GLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-#define glClearBufferfv glad_glClearBufferfv
-typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-GLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-#define glClearBufferfi glad_glClearBufferfi
-typedef const GLubyte* (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
-GLAPI PFNGLGETSTRINGIPROC glad_glGetStringi;
-#define glGetStringi glad_glGetStringi
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
-GLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-#define glIsRenderbuffer glad_glIsRenderbuffer
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
-GLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-#define glBindRenderbuffer glad_glBindRenderbuffer
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint* renderbuffers);
-GLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint* renderbuffers);
-GLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-#define glGenRenderbuffers glad_glGenRenderbuffers
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-#define glRenderbufferStorage glad_glRenderbufferStorage
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
-GLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-#define glIsFramebuffer glad_glIsFramebuffer
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
-GLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-#define glBindFramebuffer glad_glBindFramebuffer
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint* framebuffers);
-GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-#define glDeleteFramebuffers glad_glDeleteFramebuffers
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint* framebuffers);
-GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-#define glGenFramebuffers glad_glGenFramebuffers
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
-GLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-#define glFramebufferTexture1D glad_glFramebufferTexture1D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-#define glFramebufferTexture2D glad_glFramebufferTexture2D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-#define glFramebufferTexture3D glad_glFramebufferTexture3D
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target);
-GLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-#define glGenerateMipmap glad_glGenerateMipmap
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-#define glBlitFramebuffer glad_glBlitFramebuffer
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
-typedef void* (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-#define glMapBufferRange glad_glMapBufferRange
-typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
-GLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
-typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array);
-GLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-#define glBindVertexArray glad_glBindVertexArray
-typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint* arrays);
-GLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-#define glDeleteVertexArrays glad_glDeleteVertexArrays
-typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint* arrays);
-GLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-#define glGenVertexArrays glad_glGenVertexArrays
-typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array);
-GLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-#define glIsVertexArray glad_glIsVertexArray
-#endif
-#ifndef GL_VERSION_3_1
-#define GL_VERSION_3_1 1
-GLAPI int GLAD_GL_VERSION_3_1;
-typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
-GLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-#define glDrawArraysInstanced glad_glDrawArraysInstanced
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount);
-GLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-#define glDrawElementsInstanced glad_glDrawElementsInstanced
-typedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
-GLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer;
-#define glTexBuffer glad_glTexBuffer
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
-GLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
-typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-GLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-#define glCopyBufferSubData glad_glCopyBufferSubData
-typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar** uniformNames, GLuint* uniformIndices);
-GLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-#define glGetUniformIndices glad_glGetUniformIndices
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
-GLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformName);
-GLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-#define glGetActiveUniformName glad_glGetActiveUniformName
-typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar* uniformBlockName);
-GLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
-GLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
-GLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
-typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-GLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-#define glUniformBlockBinding glad_glUniformBlockBinding
-#endif
-#ifndef GL_VERSION_3_2
-#define GL_VERSION_3_2 1
-GLAPI int GLAD_GL_VERSION_3_2;
-typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLint basevertex);
-GLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices, GLint basevertex);
-GLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
-typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLint basevertex);
-GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei* count, GLenum type, const void** indices, GLsizei drawcount, const GLint* basevertex);
-GLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
-typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
-GLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-#define glProvokingVertex glad_glProvokingVertex
-typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
-GLAPI PFNGLFENCESYNCPROC glad_glFenceSync;
-#define glFenceSync glad_glFenceSync
-typedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync sync);
-GLAPI PFNGLISSYNCPROC glad_glIsSync;
-#define glIsSync glad_glIsSync
-typedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync);
-GLAPI PFNGLDELETESYNCPROC glad_glDeleteSync;
-#define glDeleteSync glad_glDeleteSync
-typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-#define glClientWaitSync glad_glClientWaitSync
-typedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
-GLAPI PFNGLWAITSYNCPROC glad_glWaitSync;
-#define glWaitSync glad_glWaitSync
-typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64* data);
-GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-#define glGetInteger64v glad_glGetInteger64v
-typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
-GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv;
-#define glGetSynciv glad_glGetSynciv
-typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64* data);
-GLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-#define glGetInteger64i_v glad_glGetInteger64i_v
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64* params);
-GLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-#define glFramebufferTexture glad_glFramebufferTexture
-typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
-GLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-#define glTexImage2DMultisample glad_glTexImage2DMultisample
-typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
-GLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-#define glTexImage3DMultisample glad_glTexImage3DMultisample
-typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat* val);
-GLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-#define glGetMultisamplefv glad_glGetMultisamplefv
-typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
-GLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-#define glSampleMaski glad_glSampleMaski
-#endif
-#ifndef GL_VERSION_3_3
-#define GL_VERSION_3_3 1
-GLAPI int GLAD_GL_VERSION_3_3;
-typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar* name);
-GLAPI PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
-typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar* name);
-GLAPI PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-#define glGetFragDataIndex glad_glGetFragDataIndex
-typedef void (APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint* samplers);
-GLAPI PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-#define glGenSamplers glad_glGenSamplers
-typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint* samplers);
-GLAPI PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-#define glDeleteSamplers glad_glDeleteSamplers
-typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler);
-GLAPI PFNGLISSAMPLERPROC glad_glIsSampler;
-#define glIsSampler glad_glIsSampler
-typedef void (APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
-GLAPI PFNGLBINDSAMPLERPROC glad_glBindSampler;
-#define glBindSampler glad_glBindSampler
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
-GLAPI PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-#define glSamplerParameteri glad_glSamplerParameteri
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint* param);
-GLAPI PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-#define glSamplerParameteriv glad_glSamplerParameteriv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
-GLAPI PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-#define glSamplerParameterf glad_glSamplerParameterf
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat* param);
-GLAPI PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-#define glSamplerParameterfv glad_glSamplerParameterfv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint* param);
-GLAPI PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-#define glSamplerParameterIiv glad_glSamplerParameterIiv
-typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint* param);
-GLAPI PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
-typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint* params);
-GLAPI PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
-typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
-GLAPI PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-#define glQueryCounter glad_glQueryCounter
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64* params);
-GLAPI PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64* params);
-GLAPI PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
-typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
-GLAPI PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-#define glVertexAttribDivisor glad_glVertexAttribDivisor
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-#define glVertexAttribP1ui glad_glVertexAttribP1ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-#define glVertexAttribP2ui glad_glVertexAttribP2ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-#define glVertexAttribP3ui glad_glVertexAttribP3ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
-GLAPI PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-#define glVertexAttribP4ui glad_glVertexAttribP4ui
-typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint* value);
-GLAPI PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
-typedef void (APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-#define glVertexP2ui glad_glVertexP2ui
-typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-#define glVertexP2uiv glad_glVertexP2uiv
-typedef void (APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-#define glVertexP3ui glad_glVertexP3ui
-typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-#define glVertexP3uiv glad_glVertexP3uiv
-typedef void (APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value);
-GLAPI PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-#define glVertexP4ui glad_glVertexP4ui
-typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint* value);
-GLAPI PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-#define glVertexP4uiv glad_glVertexP4uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-#define glTexCoordP1ui glad_glTexCoordP1ui
-typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-#define glTexCoordP1uiv glad_glTexCoordP1uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-#define glTexCoordP2ui glad_glTexCoordP2ui
-typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-#define glTexCoordP2uiv glad_glTexCoordP2uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-#define glTexCoordP3ui glad_glTexCoordP3ui
-typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-#define glTexCoordP3uiv glad_glTexCoordP3uiv
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-#define glTexCoordP4ui glad_glTexCoordP4ui
-typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-#define glTexCoordP4uiv glad_glTexCoordP4uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords);
-GLAPI PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
-typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint* coords);
-GLAPI PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
-typedef void (APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords);
-GLAPI PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-#define glNormalP3ui glad_glNormalP3ui
-typedef void (APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint* coords);
-GLAPI PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-#define glNormalP3uiv glad_glNormalP3uiv
-typedef void (APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLCOLORP3UIPROC glad_glColorP3ui;
-#define glColorP3ui glad_glColorP3ui
-typedef void (APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-#define glColorP3uiv glad_glColorP3uiv
-typedef void (APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLCOLORP4UIPROC glad_glColorP4ui;
-#define glColorP4ui glad_glColorP4ui
-typedef void (APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-#define glColorP4uiv glad_glColorP4uiv
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color);
-GLAPI PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
-typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint* color);
-GLAPI PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
-#endif
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145
-#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147
-#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148
-#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149
-#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A
-#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B
-#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C
-#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D
-#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E
-#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F
-#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150
-#define GL_QUERY_BUFFER_AMD 0x9192
-#define GL_QUERY_BUFFER_BINDING_AMD 0x9193
-#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194
-#define GL_FIXED 0x140C
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_LOW_INT 0x8DF3
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_HIGH_INT 0x8DF5
-#define GL_SHADER_COMPILER 0x8DFA
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_RGB565 0x8D62
-#define GL_COMPRESSED_RGB8_ETC2 0x9274
-#define GL_COMPRESSED_SRGB8_ETC2 0x9275
-#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
-#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
-#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
-#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
-#define GL_COMPRESSED_R11_EAC 0x9270
-#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
-#define GL_COMPRESSED_RG11_EAC 0x9272
-#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
-#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
-#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
-#define GL_MAX_ELEMENT_INDEX 0x8D6B
-#define GL_MAP_PERSISTENT_BIT 0x0040
-#define GL_MAP_COHERENT_BIT 0x0080
-#define GL_DYNAMIC_STORAGE_BIT 0x0100
-#define GL_CLIENT_STORAGE_BIT 0x0200
-#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
-#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
-#define GL_BUFFER_STORAGE_FLAGS 0x8220
-#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
-#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
-#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
-#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
-#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
-#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
-#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
-#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243
-#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245
-#define GL_DEBUG_SOURCE_API_ARB 0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249
-#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A
-#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B
-#define GL_DEBUG_TYPE_ERROR_ARB 0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250
-#define GL_DEBUG_TYPE_OTHER_ARB 0x8251
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145
-#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147
-#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148
-#define GL_DEPTH_COMPONENT16_ARB 0x81A5
-#define GL_DEPTH_COMPONENT24_ARB 0x81A6
-#define GL_DEPTH_COMPONENT32_ARB 0x81A7
-#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
-#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
-#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
-#define GL_DRAW_BUFFER0_ARB 0x8825
-#define GL_DRAW_BUFFER1_ARB 0x8826
-#define GL_DRAW_BUFFER2_ARB 0x8827
-#define GL_DRAW_BUFFER3_ARB 0x8828
-#define GL_DRAW_BUFFER4_ARB 0x8829
-#define GL_DRAW_BUFFER5_ARB 0x882A
-#define GL_DRAW_BUFFER6_ARB 0x882B
-#define GL_DRAW_BUFFER7_ARB 0x882C
-#define GL_DRAW_BUFFER8_ARB 0x882D
-#define GL_DRAW_BUFFER9_ARB 0x882E
-#define GL_DRAW_BUFFER10_ARB 0x882F
-#define GL_DRAW_BUFFER11_ARB 0x8830
-#define GL_DRAW_BUFFER12_ARB 0x8831
-#define GL_DRAW_BUFFER13_ARB 0x8832
-#define GL_DRAW_BUFFER14_ARB 0x8833
-#define GL_DRAW_BUFFER15_ARB 0x8834
-#define GL_MAX_UNIFORM_LOCATIONS 0x826E
-#define GL_FRAGMENT_PROGRAM_ARB 0x8804
-#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
-#define GL_PROGRAM_LENGTH_ARB 0x8627
-#define GL_PROGRAM_FORMAT_ARB 0x8876
-#define GL_PROGRAM_BINDING_ARB 0x8677
-#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
-#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
-#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
-#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
-#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
-#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
-#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
-#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
-#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
-#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
-#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
-#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
-#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
-#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
-#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
-#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
-#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
-#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
-#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
-#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
-#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
-#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
-#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
-#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
-#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
-#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
-#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
-#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
-#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
-#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
-#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
-#define GL_PROGRAM_STRING_ARB 0x8628
-#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
-#define GL_CURRENT_MATRIX_ARB 0x8641
-#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
-#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
-#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
-#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
-#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
-#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
-#define GL_MATRIX0_ARB 0x88C0
-#define GL_MATRIX1_ARB 0x88C1
-#define GL_MATRIX2_ARB 0x88C2
-#define GL_MATRIX3_ARB 0x88C3
-#define GL_MATRIX4_ARB 0x88C4
-#define GL_MATRIX5_ARB 0x88C5
-#define GL_MATRIX6_ARB 0x88C6
-#define GL_MATRIX7_ARB 0x88C7
-#define GL_MATRIX8_ARB 0x88C8
-#define GL_MATRIX9_ARB 0x88C9
-#define GL_MATRIX10_ARB 0x88CA
-#define GL_MATRIX11_ARB 0x88CB
-#define GL_MATRIX12_ARB 0x88CC
-#define GL_MATRIX13_ARB 0x88CD
-#define GL_MATRIX14_ARB 0x88CE
-#define GL_MATRIX15_ARB 0x88CF
-#define GL_MATRIX16_ARB 0x88D0
-#define GL_MATRIX17_ARB 0x88D1
-#define GL_MATRIX18_ARB 0x88D2
-#define GL_MATRIX19_ARB 0x88D3
-#define GL_MATRIX20_ARB 0x88D4
-#define GL_MATRIX21_ARB 0x88D5
-#define GL_MATRIX22_ARB 0x88D6
-#define GL_MATRIX23_ARB 0x88D7
-#define GL_MATRIX24_ARB 0x88D8
-#define GL_MATRIX25_ARB 0x88D9
-#define GL_MATRIX26_ARB 0x88DA
-#define GL_MATRIX27_ARB 0x88DB
-#define GL_MATRIX28_ARB 0x88DC
-#define GL_MATRIX29_ARB 0x88DD
-#define GL_MATRIX30_ARB 0x88DE
-#define GL_MATRIX31_ARB 0x88DF
-#define GL_FRAGMENT_SHADER_ARB 0x8B30
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
-#define GL_MULTISAMPLE_ARB 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
-#define GL_SAMPLE_COVERAGE_ARB 0x80A0
-#define GL_SAMPLE_BUFFERS_ARB 0x80A8
-#define GL_SAMPLES_ARB 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
-#define GL_MULTISAMPLE_BIT_ARB 0x20000000
-#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D
-#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E
-#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F
-#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340
-#define GL_SAMPLE_LOCATION_ARB 0x8E50
-#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341
-#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342
-#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343
-#define GL_COMPRESSED_ALPHA_ARB 0x84E9
-#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
-#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
-#define GL_COMPRESSED_RGB_ARB 0x84ED
-#define GL_COMPRESSED_RGBA_ARB 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
-#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
-#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
-#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
-#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
-#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
-#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
-#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
-#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
-#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
-#define GL_RGBA32F_ARB 0x8814
-#define GL_RGB32F_ARB 0x8815
-#define GL_ALPHA32F_ARB 0x8816
-#define GL_INTENSITY32F_ARB 0x8817
-#define GL_LUMINANCE32F_ARB 0x8818
-#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
-#define GL_RGBA16F_ARB 0x881A
-#define GL_RGB16F_ARB 0x881B
-#define GL_ALPHA16F_ARB 0x881C
-#define GL_INTENSITY16F_ARB 0x881D
-#define GL_LUMINANCE16F_ARB 0x881E
-#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
-#define GL_VERTEX_ATTRIB_BINDING 0x82D4
-#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
-#define GL_VERTEX_BINDING_DIVISOR 0x82D6
-#define GL_VERTEX_BINDING_OFFSET 0x82D7
-#define GL_VERTEX_BINDING_STRIDE 0x82D8
-#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
-#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA
-#define GL_BUFFER_SIZE_ARB 0x8764
-#define GL_BUFFER_USAGE_ARB 0x8765
-#define GL_ARRAY_BUFFER_ARB 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
-#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
-#define GL_READ_ONLY_ARB 0x88B8
-#define GL_WRITE_ONLY_ARB 0x88B9
-#define GL_READ_WRITE_ARB 0x88BA
-#define GL_BUFFER_ACCESS_ARB 0x88BB
-#define GL_BUFFER_MAPPED_ARB 0x88BC
-#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
-#define GL_STREAM_DRAW_ARB 0x88E0
-#define GL_STREAM_READ_ARB 0x88E1
-#define GL_STREAM_COPY_ARB 0x88E2
-#define GL_STATIC_DRAW_ARB 0x88E4
-#define GL_STATIC_READ_ARB 0x88E5
-#define GL_STATIC_COPY_ARB 0x88E6
-#define GL_DYNAMIC_DRAW_ARB 0x88E8
-#define GL_DYNAMIC_READ_ARB 0x88E9
-#define GL_DYNAMIC_COPY_ARB 0x88EA
-#define GL_COLOR_SUM_ARB 0x8458
-#define GL_VERTEX_PROGRAM_ARB 0x8620
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
-#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
-#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
-#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
-#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
-#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
-#define GL_VERTEX_SHADER_ARB 0x8B31
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
-#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
-#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
-#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
-#define GL_FLOAT_VEC2_ARB 0x8B50
-#define GL_FLOAT_VEC3_ARB 0x8B51
-#define GL_FLOAT_VEC4_ARB 0x8B52
-#define GL_FLOAT_MAT2_ARB 0x8B5A
-#define GL_FLOAT_MAT3_ARB 0x8B5B
-#define GL_FLOAT_MAT4_ARB 0x8B5C
-#define GL_ELEMENT_ARRAY_ATI 0x8768
-#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
-#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
-#define GL_FRAGMENT_SHADER_ATI 0x8920
-#define GL_REG_0_ATI 0x8921
-#define GL_REG_1_ATI 0x8922
-#define GL_REG_2_ATI 0x8923
-#define GL_REG_3_ATI 0x8924
-#define GL_REG_4_ATI 0x8925
-#define GL_REG_5_ATI 0x8926
-#define GL_REG_6_ATI 0x8927
-#define GL_REG_7_ATI 0x8928
-#define GL_REG_8_ATI 0x8929
-#define GL_REG_9_ATI 0x892A
-#define GL_REG_10_ATI 0x892B
-#define GL_REG_11_ATI 0x892C
-#define GL_REG_12_ATI 0x892D
-#define GL_REG_13_ATI 0x892E
-#define GL_REG_14_ATI 0x892F
-#define GL_REG_15_ATI 0x8930
-#define GL_REG_16_ATI 0x8931
-#define GL_REG_17_ATI 0x8932
-#define GL_REG_18_ATI 0x8933
-#define GL_REG_19_ATI 0x8934
-#define GL_REG_20_ATI 0x8935
-#define GL_REG_21_ATI 0x8936
-#define GL_REG_22_ATI 0x8937
-#define GL_REG_23_ATI 0x8938
-#define GL_REG_24_ATI 0x8939
-#define GL_REG_25_ATI 0x893A
-#define GL_REG_26_ATI 0x893B
-#define GL_REG_27_ATI 0x893C
-#define GL_REG_28_ATI 0x893D
-#define GL_REG_29_ATI 0x893E
-#define GL_REG_30_ATI 0x893F
-#define GL_REG_31_ATI 0x8940
-#define GL_CON_0_ATI 0x8941
-#define GL_CON_1_ATI 0x8942
-#define GL_CON_2_ATI 0x8943
-#define GL_CON_3_ATI 0x8944
-#define GL_CON_4_ATI 0x8945
-#define GL_CON_5_ATI 0x8946
-#define GL_CON_6_ATI 0x8947
-#define GL_CON_7_ATI 0x8948
-#define GL_CON_8_ATI 0x8949
-#define GL_CON_9_ATI 0x894A
-#define GL_CON_10_ATI 0x894B
-#define GL_CON_11_ATI 0x894C
-#define GL_CON_12_ATI 0x894D
-#define GL_CON_13_ATI 0x894E
-#define GL_CON_14_ATI 0x894F
-#define GL_CON_15_ATI 0x8950
-#define GL_CON_16_ATI 0x8951
-#define GL_CON_17_ATI 0x8952
-#define GL_CON_18_ATI 0x8953
-#define GL_CON_19_ATI 0x8954
-#define GL_CON_20_ATI 0x8955
-#define GL_CON_21_ATI 0x8956
-#define GL_CON_22_ATI 0x8957
-#define GL_CON_23_ATI 0x8958
-#define GL_CON_24_ATI 0x8959
-#define GL_CON_25_ATI 0x895A
-#define GL_CON_26_ATI 0x895B
-#define GL_CON_27_ATI 0x895C
-#define GL_CON_28_ATI 0x895D
-#define GL_CON_29_ATI 0x895E
-#define GL_CON_30_ATI 0x895F
-#define GL_CON_31_ATI 0x8960
-#define GL_MOV_ATI 0x8961
-#define GL_ADD_ATI 0x8963
-#define GL_MUL_ATI 0x8964
-#define GL_SUB_ATI 0x8965
-#define GL_DOT3_ATI 0x8966
-#define GL_DOT4_ATI 0x8967
-#define GL_MAD_ATI 0x8968
-#define GL_LERP_ATI 0x8969
-#define GL_CND_ATI 0x896A
-#define GL_CND0_ATI 0x896B
-#define GL_DOT2_ADD_ATI 0x896C
-#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
-#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
-#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
-#define GL_NUM_PASSES_ATI 0x8970
-#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
-#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
-#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
-#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
-#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
-#define GL_SWIZZLE_STR_ATI 0x8976
-#define GL_SWIZZLE_STQ_ATI 0x8977
-#define GL_SWIZZLE_STR_DR_ATI 0x8978
-#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
-#define GL_SWIZZLE_STRQ_ATI 0x897A
-#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
-#define GL_RED_BIT_ATI 0x00000001
-#define GL_GREEN_BIT_ATI 0x00000002
-#define GL_BLUE_BIT_ATI 0x00000004
-#define GL_2X_BIT_ATI 0x00000001
-#define GL_4X_BIT_ATI 0x00000002
-#define GL_8X_BIT_ATI 0x00000004
-#define GL_HALF_BIT_ATI 0x00000008
-#define GL_QUARTER_BIT_ATI 0x00000010
-#define GL_EIGHTH_BIT_ATI 0x00000020
-#define GL_SATURATE_BIT_ATI 0x00000040
-#define GL_COMP_BIT_ATI 0x00000002
-#define GL_NEGATE_BIT_ATI 0x00000004
-#define GL_BIAS_BIT_ATI 0x00000008
-#define GL_STATIC_ATI 0x8760
-#define GL_DYNAMIC_ATI 0x8761
-#define GL_PRESERVE_ATI 0x8762
-#define GL_DISCARD_ATI 0x8763
-#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
-#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
-#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
-#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
-#define GL_CONSTANT_COLOR_EXT 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
-#define GL_CONSTANT_ALPHA_EXT 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
-#define GL_BLEND_COLOR_EXT 0x8005
-#define GL_BLEND_EQUATION_RGB_EXT 0x8009
-#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
-#define GL_BLEND_DST_RGB_EXT 0x80C8
-#define GL_BLEND_SRC_RGB_EXT 0x80C9
-#define GL_BLEND_DST_ALPHA_EXT 0x80CA
-#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
-#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
-#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#define GL_MAX_SAMPLES_EXT 0x8D57
-#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
-#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB
-#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
-#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
-#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
-#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
-#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
-#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
-#define GL_FRAMEBUFFER_EXT 0x8D40
-#define GL_RENDERBUFFER_EXT 0x8D41
-#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
-#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
-#define GL_STENCIL_INDEX1_EXT 0x8D46
-#define GL_STENCIL_INDEX4_EXT 0x8D47
-#define GL_STENCIL_INDEX8_EXT 0x8D48
-#define GL_STENCIL_INDEX16_EXT 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
-#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
-#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
-#define GL_IUI_V2F_EXT 0x81AD
-#define GL_IUI_V3F_EXT 0x81AE
-#define GL_IUI_N3F_V2F_EXT 0x81AF
-#define GL_IUI_N3F_V3F_EXT 0x81B0
-#define GL_T2F_IUI_V2F_EXT 0x81B1
-#define GL_T2F_IUI_V3F_EXT 0x81B2
-#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
-#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
-#define GL_ALPHA4_EXT 0x803B
-#define GL_ALPHA8_EXT 0x803C
-#define GL_ALPHA12_EXT 0x803D
-#define GL_ALPHA16_EXT 0x803E
-#define GL_LUMINANCE4_EXT 0x803F
-#define GL_LUMINANCE8_EXT 0x8040
-#define GL_LUMINANCE12_EXT 0x8041
-#define GL_LUMINANCE16_EXT 0x8042
-#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
-#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
-#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
-#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
-#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
-#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
-#define GL_INTENSITY_EXT 0x8049
-#define GL_INTENSITY4_EXT 0x804A
-#define GL_INTENSITY8_EXT 0x804B
-#define GL_INTENSITY12_EXT 0x804C
-#define GL_INTENSITY16_EXT 0x804D
-#define GL_RGB2_EXT 0x804E
-#define GL_RGB4_EXT 0x804F
-#define GL_RGB5_EXT 0x8050
-#define GL_RGB8_EXT 0x8051
-#define GL_RGB10_EXT 0x8052
-#define GL_RGB12_EXT 0x8053
-#define GL_RGB16_EXT 0x8054
-#define GL_RGBA2_EXT 0x8055
-#define GL_RGBA4_EXT 0x8056
-#define GL_RGB5_A1_EXT 0x8057
-#define GL_RGBA8_EXT 0x8058
-#define GL_RGB10_A2_EXT 0x8059
-#define GL_RGBA12_EXT 0x805A
-#define GL_RGBA16_EXT 0x805B
-#define GL_TEXTURE_RED_SIZE_EXT 0x805C
-#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
-#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
-#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
-#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
-#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
-#define GL_REPLACE_EXT 0x8062
-#define GL_PROXY_TEXTURE_1D_EXT 0x8063
-#define GL_PROXY_TEXTURE_2D_EXT 0x8064
-#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#define GL_SRGB_EXT 0x8C40
-#define GL_SRGB8_EXT 0x8C41
-#define GL_SRGB_ALPHA_EXT 0x8C42
-#define GL_SRGB8_ALPHA8_EXT 0x8C43
-#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
-#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
-#define GL_SLUMINANCE_EXT 0x8C46
-#define GL_SLUMINANCE8_EXT 0x8C47
-#define GL_COMPRESSED_SRGB_EXT 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
-#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
-#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
-#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42
-#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43
-#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44
-#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45
-#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46
-#define GL_VERTEX_ARRAY_EXT 0x8074
-#define GL_NORMAL_ARRAY_EXT 0x8075
-#define GL_COLOR_ARRAY_EXT 0x8076
-#define GL_INDEX_ARRAY_EXT 0x8077
-#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
-#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
-#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
-#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
-#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
-#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
-#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
-#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
-#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
-#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
-#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
-#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
-#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
-#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
-#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
-#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
-#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
-#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
-#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
-#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
-#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
-#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
-#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
-#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
-#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
-#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
-#define GL_VERTEX_SHADER_EXT 0x8780
-#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
-#define GL_OP_INDEX_EXT 0x8782
-#define GL_OP_NEGATE_EXT 0x8783
-#define GL_OP_DOT3_EXT 0x8784
-#define GL_OP_DOT4_EXT 0x8785
-#define GL_OP_MUL_EXT 0x8786
-#define GL_OP_ADD_EXT 0x8787
-#define GL_OP_MADD_EXT 0x8788
-#define GL_OP_FRAC_EXT 0x8789
-#define GL_OP_MAX_EXT 0x878A
-#define GL_OP_MIN_EXT 0x878B
-#define GL_OP_SET_GE_EXT 0x878C
-#define GL_OP_SET_LT_EXT 0x878D
-#define GL_OP_CLAMP_EXT 0x878E
-#define GL_OP_FLOOR_EXT 0x878F
-#define GL_OP_ROUND_EXT 0x8790
-#define GL_OP_EXP_BASE_2_EXT 0x8791
-#define GL_OP_LOG_BASE_2_EXT 0x8792
-#define GL_OP_POWER_EXT 0x8793
-#define GL_OP_RECIP_EXT 0x8794
-#define GL_OP_RECIP_SQRT_EXT 0x8795
-#define GL_OP_SUB_EXT 0x8796
-#define GL_OP_CROSS_PRODUCT_EXT 0x8797
-#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
-#define GL_OP_MOV_EXT 0x8799
-#define GL_OUTPUT_VERTEX_EXT 0x879A
-#define GL_OUTPUT_COLOR0_EXT 0x879B
-#define GL_OUTPUT_COLOR1_EXT 0x879C
-#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
-#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
-#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
-#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
-#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
-#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
-#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
-#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
-#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
-#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
-#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
-#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
-#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
-#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
-#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
-#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
-#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
-#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
-#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
-#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
-#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
-#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
-#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
-#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
-#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
-#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
-#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
-#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
-#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
-#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
-#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
-#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
-#define GL_OUTPUT_FOG_EXT 0x87BD
-#define GL_SCALAR_EXT 0x87BE
-#define GL_VECTOR_EXT 0x87BF
-#define GL_MATRIX_EXT 0x87C0
-#define GL_VARIANT_EXT 0x87C1
-#define GL_INVARIANT_EXT 0x87C2
-#define GL_LOCAL_CONSTANT_EXT 0x87C3
-#define GL_LOCAL_EXT 0x87C4
-#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
-#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
-#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
-#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
-#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
-#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
-#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
-#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
-#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
-#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
-#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
-#define GL_X_EXT 0x87D5
-#define GL_Y_EXT 0x87D6
-#define GL_Z_EXT 0x87D7
-#define GL_W_EXT 0x87D8
-#define GL_NEGATIVE_X_EXT 0x87D9
-#define GL_NEGATIVE_Y_EXT 0x87DA
-#define GL_NEGATIVE_Z_EXT 0x87DB
-#define GL_NEGATIVE_W_EXT 0x87DC
-#define GL_ZERO_EXT 0x87DD
-#define GL_ONE_EXT 0x87DE
-#define GL_NEGATIVE_ONE_EXT 0x87DF
-#define GL_NORMALIZED_RANGE_EXT 0x87E0
-#define GL_FULL_RANGE_EXT 0x87E1
-#define GL_CURRENT_VERTEX_EXT 0x87E2
-#define GL_MVP_MATRIX_EXT 0x87E3
-#define GL_VARIANT_VALUE_EXT 0x87E4
-#define GL_VARIANT_DATATYPE_EXT 0x87E5
-#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
-#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
-#define GL_VARIANT_ARRAY_EXT 0x87E8
-#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
-#define GL_INVARIANT_VALUE_EXT 0x87EA
-#define GL_INVARIANT_DATATYPE_EXT 0x87EB
-#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
-#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
-#ifndef GL_AMD_debug_output
-#define GL_AMD_debug_output 1
-GLAPI int GLAD_GL_AMD_debug_output;
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC)(GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
-GLAPI PFNGLDEBUGMESSAGEENABLEAMDPROC glad_glDebugMessageEnableAMD;
-#define glDebugMessageEnableAMD glad_glDebugMessageEnableAMD
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC)(GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf);
-GLAPI PFNGLDEBUGMESSAGEINSERTAMDPROC glad_glDebugMessageInsertAMD;
-#define glDebugMessageInsertAMD glad_glDebugMessageInsertAMD
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC)(GLDEBUGPROCAMD callback, void* userParam);
-GLAPI PFNGLDEBUGMESSAGECALLBACKAMDPROC glad_glDebugMessageCallbackAMD;
-#define glDebugMessageCallbackAMD glad_glDebugMessageCallbackAMD
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC)(GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message);
-GLAPI PFNGLGETDEBUGMESSAGELOGAMDPROC glad_glGetDebugMessageLogAMD;
-#define glGetDebugMessageLogAMD glad_glGetDebugMessageLogAMD
-#endif
-#ifndef GL_AMD_query_buffer_object
-#define GL_AMD_query_buffer_object 1
-GLAPI int GLAD_GL_AMD_query_buffer_object;
-#endif
-#ifndef GL_ARB_ES2_compatibility
-#define GL_ARB_ES2_compatibility 1
-GLAPI int GLAD_GL_ARB_ES2_compatibility;
-typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)();
-GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
-#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
-typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length);
-GLAPI PFNGLSHADERBINARYPROC glad_glShaderBinary;
-#define glShaderBinary glad_glShaderBinary
-typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-GLAPI PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
-#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
-typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
-GLAPI PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
-#define glDepthRangef glad_glDepthRangef
-typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d);
-GLAPI PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
-#define glClearDepthf glad_glClearDepthf
-#endif
-#ifndef GL_ARB_ES3_compatibility
-#define GL_ARB_ES3_compatibility 1
-GLAPI int GLAD_GL_ARB_ES3_compatibility;
-#endif
-#ifndef GL_ARB_buffer_storage
-#define GL_ARB_buffer_storage 1
-GLAPI int GLAD_GL_ARB_buffer_storage;
-typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void* data, GLbitfield flags);
-GLAPI PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
-#define glBufferStorage glad_glBufferStorage
-#endif
-#ifndef GL_ARB_compatibility
-#define GL_ARB_compatibility 1
-GLAPI int GLAD_GL_ARB_compatibility;
-#endif
-#ifndef GL_ARB_compressed_texture_pixel_storage
-#define GL_ARB_compressed_texture_pixel_storage 1
-GLAPI int GLAD_GL_ARB_compressed_texture_pixel_storage;
-#endif
-#ifndef GL_ARB_debug_output
-#define GL_ARB_debug_output 1
-GLAPI int GLAD_GL_ARB_debug_output;
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled);
-GLAPI PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
-#define glDebugMessageControlARB glad_glDebugMessageControlARB
-typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf);
-GLAPI PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
-#define glDebugMessageInsertARB glad_glDebugMessageInsertARB
-typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC)(GLDEBUGPROCARB callback, const void* userParam);
-GLAPI PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
-#define glDebugMessageCallbackARB glad_glDebugMessageCallbackARB
-typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC)(GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog);
-GLAPI PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
-#define glGetDebugMessageLogARB glad_glGetDebugMessageLogARB
-#endif
-#ifndef GL_ARB_depth_buffer_float
-#define GL_ARB_depth_buffer_float 1
-GLAPI int GLAD_GL_ARB_depth_buffer_float;
-#endif
-#ifndef GL_ARB_depth_clamp
-#define GL_ARB_depth_clamp 1
-GLAPI int GLAD_GL_ARB_depth_clamp;
-#endif
-#ifndef GL_ARB_depth_texture
-#define GL_ARB_depth_texture 1
-GLAPI int GLAD_GL_ARB_depth_texture;
-#endif
-#ifndef GL_ARB_draw_buffers
-#define GL_ARB_draw_buffers 1
-GLAPI int GLAD_GL_ARB_draw_buffers;
-typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC)(GLsizei n, const GLenum* bufs);
-GLAPI PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB;
-#define glDrawBuffersARB glad_glDrawBuffersARB
-#endif
-#ifndef GL_ARB_draw_buffers_blend
-#define GL_ARB_draw_buffers_blend 1
-GLAPI int GLAD_GL_ARB_draw_buffers_blend;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC)(GLuint buf, GLenum mode);
-GLAPI PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB;
-#define glBlendEquationiARB glad_glBlendEquationiARB
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB;
-#define glBlendEquationSeparateiARB glad_glBlendEquationSeparateiARB
-typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC)(GLuint buf, GLenum src, GLenum dst);
-GLAPI PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB;
-#define glBlendFunciARB glad_glBlendFunciARB
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB;
-#define glBlendFuncSeparateiARB glad_glBlendFuncSeparateiARB
-#endif
-#ifndef GL_ARB_explicit_attrib_location
-#define GL_ARB_explicit_attrib_location 1
-GLAPI int GLAD_GL_ARB_explicit_attrib_location;
-#endif
-#ifndef GL_ARB_explicit_uniform_location
-#define GL_ARB_explicit_uniform_location 1
-GLAPI int GLAD_GL_ARB_explicit_uniform_location;
-#endif
-#ifndef GL_ARB_fragment_program
-#define GL_ARB_fragment_program 1
-GLAPI int GLAD_GL_ARB_fragment_program;
-typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC)(GLenum target, GLenum format, GLsizei len, const void* string);
-GLAPI PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB;
-#define glProgramStringARB glad_glProgramStringARB
-typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC)(GLenum target, GLuint program);
-GLAPI PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB;
-#define glBindProgramARB glad_glBindProgramARB
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC)(GLsizei n, const GLuint* programs);
-GLAPI PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB;
-#define glDeleteProgramsARB glad_glDeleteProgramsARB
-typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC)(GLsizei n, GLuint* programs);
-GLAPI PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB;
-#define glGenProgramsARB glad_glGenProgramsARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB;
-#define glProgramEnvParameter4dARB glad_glProgramEnvParameter4dARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble* params);
-GLAPI PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB;
-#define glProgramEnvParameter4dvARB glad_glProgramEnvParameter4dvARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB;
-#define glProgramEnvParameter4fARB glad_glProgramEnvParameter4fARB
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat* params);
-GLAPI PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB;
-#define glProgramEnvParameter4fvARB glad_glProgramEnvParameter4fvARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB;
-#define glProgramLocalParameter4dARB glad_glProgramLocalParameter4dARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)(GLenum target, GLuint index, const GLdouble* params);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB;
-#define glProgramLocalParameter4dvARB glad_glProgramLocalParameter4dvARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB;
-#define glProgramLocalParameter4fARB glad_glProgramLocalParameter4fARB
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)(GLenum target, GLuint index, const GLfloat* params);
-GLAPI PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB;
-#define glProgramLocalParameter4fvARB glad_glProgramLocalParameter4fvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble* params);
-GLAPI PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB;
-#define glGetProgramEnvParameterdvARB glad_glGetProgramEnvParameterdvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat* params);
-GLAPI PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB;
-#define glGetProgramEnvParameterfvARB glad_glGetProgramEnvParameterfvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)(GLenum target, GLuint index, GLdouble* params);
-GLAPI PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB;
-#define glGetProgramLocalParameterdvARB glad_glGetProgramLocalParameterdvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)(GLenum target, GLuint index, GLfloat* params);
-GLAPI PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB;
-#define glGetProgramLocalParameterfvARB glad_glGetProgramLocalParameterfvARB
-typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB;
-#define glGetProgramivARB glad_glGetProgramivARB
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC)(GLenum target, GLenum pname, void* string);
-GLAPI PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB;
-#define glGetProgramStringARB glad_glGetProgramStringARB
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC)(GLuint program);
-GLAPI PFNGLISPROGRAMARBPROC glad_glIsProgramARB;
-#define glIsProgramARB glad_glIsProgramARB
-#endif
-#ifndef GL_ARB_fragment_shader
-#define GL_ARB_fragment_shader 1
-GLAPI int GLAD_GL_ARB_fragment_shader;
-#endif
-#ifndef GL_ARB_framebuffer_object
-#define GL_ARB_framebuffer_object 1
-GLAPI int GLAD_GL_ARB_framebuffer_object;
-#endif
-#ifndef GL_ARB_framebuffer_sRGB
-#define GL_ARB_framebuffer_sRGB 1
-GLAPI int GLAD_GL_ARB_framebuffer_sRGB;
-#endif
-#ifndef GL_ARB_multisample
-#define GL_ARB_multisample 1
-GLAPI int GLAD_GL_ARB_multisample;
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC)(GLfloat value, GLboolean invert);
-GLAPI PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-#define glSampleCoverageARB glad_glSampleCoverageARB
-#endif
-#ifndef GL_ARB_sample_locations
-#define GL_ARB_sample_locations 1
-GLAPI int GLAD_GL_ARB_sample_locations;
-typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLenum target, GLuint start, GLsizei count, const GLfloat* v);
-GLAPI PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB;
-#define glFramebufferSampleLocationsfvARB glad_glFramebufferSampleLocationsfvARB
-typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)(GLuint framebuffer, GLuint start, GLsizei count, const GLfloat* v);
-GLAPI PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB;
-#define glNamedFramebufferSampleLocationsfvARB glad_glNamedFramebufferSampleLocationsfvARB
-typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC)();
-GLAPI PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB;
-#define glEvaluateDepthValuesARB glad_glEvaluateDepthValuesARB
-#endif
-#ifndef GL_ARB_texture_compression
-#define GL_ARB_texture_compression 1
-GLAPI int GLAD_GL_ARB_texture_compression;
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB;
-#define glCompressedTexImage3DARB glad_glCompressedTexImage3DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB;
-#define glCompressedTexImage2DARB glad_glCompressedTexImage2DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB;
-#define glCompressedTexImage1DARB glad_glCompressedTexImage1DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB;
-#define glCompressedTexSubImage3DARB glad_glCompressedTexSubImage3DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB;
-#define glCompressedTexSubImage2DARB glad_glCompressedTexSubImage2DARB
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data);
-GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB;
-#define glCompressedTexSubImage1DARB glad_glCompressedTexSubImage1DARB
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)(GLenum target, GLint level, void* img);
-GLAPI PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB;
-#define glGetCompressedTexImageARB glad_glGetCompressedTexImageARB
-#endif
-#ifndef GL_ARB_texture_float
-#define GL_ARB_texture_float 1
-GLAPI int GLAD_GL_ARB_texture_float;
-#endif
-#ifndef GL_ARB_texture_multisample
-#define GL_ARB_texture_multisample 1
-GLAPI int GLAD_GL_ARB_texture_multisample;
-#endif
-#ifndef GL_ARB_texture_non_power_of_two
-#define GL_ARB_texture_non_power_of_two 1
-GLAPI int GLAD_GL_ARB_texture_non_power_of_two;
-#endif
-#ifndef GL_ARB_texture_rg
-#define GL_ARB_texture_rg 1
-GLAPI int GLAD_GL_ARB_texture_rg;
-#endif
-#ifndef GL_ARB_texture_swizzle
-#define GL_ARB_texture_swizzle 1
-GLAPI int GLAD_GL_ARB_texture_swizzle;
-#endif
-#ifndef GL_ARB_uniform_buffer_object
-#define GL_ARB_uniform_buffer_object 1
-GLAPI int GLAD_GL_ARB_uniform_buffer_object;
-#endif
-#ifndef GL_ARB_vertex_array_object
-#define GL_ARB_vertex_array_object 1
-GLAPI int GLAD_GL_ARB_vertex_array_object;
-#endif
-#ifndef GL_ARB_vertex_attrib_binding
-#define GL_ARB_vertex_attrib_binding 1
-GLAPI int GLAD_GL_ARB_vertex_attrib_binding;
-typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
-GLAPI PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
-#define glBindVertexBuffer glad_glBindVertexBuffer
-typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
-#define glVertexAttribFormat glad_glVertexAttribFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
-#define glVertexAttribIFormat glad_glVertexAttribIFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
-GLAPI PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
-#define glVertexAttribLFormat glad_glVertexAttribLFormat
-typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex);
-GLAPI PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
-#define glVertexAttribBinding glad_glVertexAttribBinding
-typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor);
-GLAPI PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
-#define glVertexBindingDivisor glad_glVertexBindingDivisor
-#endif
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_ARB_vertex_buffer_object 1
-GLAPI int GLAD_GL_ARB_vertex_buffer_object;
-typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC)(GLenum target, GLuint buffer);
-GLAPI PFNGLBINDBUFFERARBPROC glad_glBindBufferARB;
-#define glBindBufferARB glad_glBindBufferARB
-typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC)(GLsizei n, const GLuint* buffers);
-GLAPI PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB;
-#define glDeleteBuffersARB glad_glDeleteBuffersARB
-typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC)(GLsizei n, GLuint* buffers);
-GLAPI PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB;
-#define glGenBuffersARB glad_glGenBuffersARB
-typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC)(GLuint buffer);
-GLAPI PFNGLISBUFFERARBPROC glad_glIsBufferARB;
-#define glIsBufferARB glad_glIsBufferARB
-typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC)(GLenum target, GLsizeiptrARB size, const void* data, GLenum usage);
-GLAPI PFNGLBUFFERDATAARBPROC glad_glBufferDataARB;
-#define glBufferDataARB glad_glBufferDataARB
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void* data);
-GLAPI PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB;
-#define glBufferSubDataARB glad_glBufferSubDataARB
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void* data);
-GLAPI PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB;
-#define glGetBufferSubDataARB glad_glGetBufferSubDataARB
-typedef void* (APIENTRYP PFNGLMAPBUFFERARBPROC)(GLenum target, GLenum access);
-GLAPI PFNGLMAPBUFFERARBPROC glad_glMapBufferARB;
-#define glMapBufferARB glad_glMapBufferARB
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC)(GLenum target);
-GLAPI PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB;
-#define glUnmapBufferARB glad_glUnmapBufferARB
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB;
-#define glGetBufferParameterivARB glad_glGetBufferParameterivARB
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC)(GLenum target, GLenum pname, void** params);
-GLAPI PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB;
-#define glGetBufferPointervARB glad_glGetBufferPointervARB
-#endif
-#ifndef GL_ARB_vertex_program
-#define GL_ARB_vertex_program 1
-GLAPI int GLAD_GL_ARB_vertex_program;
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC)(GLuint index, GLdouble x);
-GLAPI PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB;
-#define glVertexAttrib1dARB glad_glVertexAttrib1dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB;
-#define glVertexAttrib1dvARB glad_glVertexAttrib1dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC)(GLuint index, GLfloat x);
-GLAPI PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB;
-#define glVertexAttrib1fARB glad_glVertexAttrib1fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB;
-#define glVertexAttrib1fvARB glad_glVertexAttrib1fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC)(GLuint index, GLshort x);
-GLAPI PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB;
-#define glVertexAttrib1sARB glad_glVertexAttrib1sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB;
-#define glVertexAttrib1svARB glad_glVertexAttrib1svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC)(GLuint index, GLdouble x, GLdouble y);
-GLAPI PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB;
-#define glVertexAttrib2dARB glad_glVertexAttrib2dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB;
-#define glVertexAttrib2dvARB glad_glVertexAttrib2dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC)(GLuint index, GLfloat x, GLfloat y);
-GLAPI PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB;
-#define glVertexAttrib2fARB glad_glVertexAttrib2fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB;
-#define glVertexAttrib2fvARB glad_glVertexAttrib2fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC)(GLuint index, GLshort x, GLshort y);
-GLAPI PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB;
-#define glVertexAttrib2sARB glad_glVertexAttrib2sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB;
-#define glVertexAttrib2svARB glad_glVertexAttrib2svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
-GLAPI PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB;
-#define glVertexAttrib3dARB glad_glVertexAttrib3dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB;
-#define glVertexAttrib3dvARB glad_glVertexAttrib3dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
-GLAPI PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB;
-#define glVertexAttrib3fARB glad_glVertexAttrib3fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB;
-#define glVertexAttrib3fvARB glad_glVertexAttrib3fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
-GLAPI PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB;
-#define glVertexAttrib3sARB glad_glVertexAttrib3sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB;
-#define glVertexAttrib3svARB glad_glVertexAttrib3svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB;
-#define glVertexAttrib4NbvARB glad_glVertexAttrib4NbvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB;
-#define glVertexAttrib4NivARB glad_glVertexAttrib4NivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB;
-#define glVertexAttrib4NsvARB glad_glVertexAttrib4NsvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-GLAPI PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB;
-#define glVertexAttrib4NubARB glad_glVertexAttrib4NubARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB;
-#define glVertexAttrib4NubvARB glad_glVertexAttrib4NubvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB;
-#define glVertexAttrib4NuivARB glad_glVertexAttrib4NuivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB;
-#define glVertexAttrib4NusvARB glad_glVertexAttrib4NusvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC)(GLuint index, const GLbyte* v);
-GLAPI PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB;
-#define glVertexAttrib4bvARB glad_glVertexAttrib4bvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-GLAPI PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB;
-#define glVertexAttrib4dARB glad_glVertexAttrib4dARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC)(GLuint index, const GLdouble* v);
-GLAPI PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB;
-#define glVertexAttrib4dvARB glad_glVertexAttrib4dvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GLAPI PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB;
-#define glVertexAttrib4fARB glad_glVertexAttrib4fARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC)(GLuint index, const GLfloat* v);
-GLAPI PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB;
-#define glVertexAttrib4fvARB glad_glVertexAttrib4fvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC)(GLuint index, const GLint* v);
-GLAPI PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB;
-#define glVertexAttrib4ivARB glad_glVertexAttrib4ivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-GLAPI PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB;
-#define glVertexAttrib4sARB glad_glVertexAttrib4sARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC)(GLuint index, const GLshort* v);
-GLAPI PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB;
-#define glVertexAttrib4svARB glad_glVertexAttrib4svARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC)(GLuint index, const GLubyte* v);
-GLAPI PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB;
-#define glVertexAttrib4ubvARB glad_glVertexAttrib4ubvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC)(GLuint index, const GLuint* v);
-GLAPI PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB;
-#define glVertexAttrib4uivARB glad_glVertexAttrib4uivARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC)(GLuint index, const GLushort* v);
-GLAPI PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB;
-#define glVertexAttrib4usvARB glad_glVertexAttrib4usvARB
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer);
-GLAPI PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB;
-#define glVertexAttribPointerARB glad_glVertexAttribPointerARB
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
-GLAPI PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB;
-#define glEnableVertexAttribArrayARB glad_glEnableVertexAttribArrayARB
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)(GLuint index);
-GLAPI PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB;
-#define glDisableVertexAttribArrayARB glad_glDisableVertexAttribArrayARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC)(GLuint index, GLenum pname, GLdouble* params);
-GLAPI PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB;
-#define glGetVertexAttribdvARB glad_glGetVertexAttribdvARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC)(GLuint index, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB;
-#define glGetVertexAttribfvARB glad_glGetVertexAttribfvARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC)(GLuint index, GLenum pname, GLint* params);
-GLAPI PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB;
-#define glGetVertexAttribivARB glad_glGetVertexAttribivARB
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC)(GLuint index, GLenum pname, void** pointer);
-GLAPI PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB;
-#define glGetVertexAttribPointervARB glad_glGetVertexAttribPointervARB
-#endif
-#ifndef GL_ARB_vertex_shader
-#define GL_ARB_vertex_shader 1
-GLAPI int GLAD_GL_ARB_vertex_shader;
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC)(GLhandleARB programObj, GLuint index, const GLcharARB* name);
-GLAPI PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB;
-#define glBindAttribLocationARB glad_glBindAttribLocationARB
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLcharARB* name);
-GLAPI PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB;
-#define glGetActiveAttribARB glad_glGetActiveAttribARB
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC)(GLhandleARB programObj, const GLcharARB* name);
-GLAPI PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB;
-#define glGetAttribLocationARB glad_glGetAttribLocationARB
-#endif
-#ifndef GL_ATI_element_array
-#define GL_ATI_element_array 1
-GLAPI int GLAD_GL_ATI_element_array;
-typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC)(GLenum type, const void* pointer);
-GLAPI PFNGLELEMENTPOINTERATIPROC glad_glElementPointerATI;
-#define glElementPointerATI glad_glElementPointerATI
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC)(GLenum mode, GLsizei count);
-GLAPI PFNGLDRAWELEMENTARRAYATIPROC glad_glDrawElementArrayATI;
-#define glDrawElementArrayATI glad_glDrawElementArrayATI
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count);
-GLAPI PFNGLDRAWRANGEELEMENTARRAYATIPROC glad_glDrawRangeElementArrayATI;
-#define glDrawRangeElementArrayATI glad_glDrawRangeElementArrayATI
-#endif
-#ifndef GL_ATI_fragment_shader
-#define GL_ATI_fragment_shader 1
-GLAPI int GLAD_GL_ATI_fragment_shader;
-typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC)(GLuint range);
-GLAPI PFNGLGENFRAGMENTSHADERSATIPROC glad_glGenFragmentShadersATI;
-#define glGenFragmentShadersATI glad_glGenFragmentShadersATI
-typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC)(GLuint id);
-GLAPI PFNGLBINDFRAGMENTSHADERATIPROC glad_glBindFragmentShaderATI;
-#define glBindFragmentShaderATI glad_glBindFragmentShaderATI
-typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC)(GLuint id);
-GLAPI PFNGLDELETEFRAGMENTSHADERATIPROC glad_glDeleteFragmentShaderATI;
-#define glDeleteFragmentShaderATI glad_glDeleteFragmentShaderATI
-typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC)();
-GLAPI PFNGLBEGINFRAGMENTSHADERATIPROC glad_glBeginFragmentShaderATI;
-#define glBeginFragmentShaderATI glad_glBeginFragmentShaderATI
-typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC)();
-GLAPI PFNGLENDFRAGMENTSHADERATIPROC glad_glEndFragmentShaderATI;
-#define glEndFragmentShaderATI glad_glEndFragmentShaderATI
-typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC)(GLuint dst, GLuint coord, GLenum swizzle);
-GLAPI PFNGLPASSTEXCOORDATIPROC glad_glPassTexCoordATI;
-#define glPassTexCoordATI glad_glPassTexCoordATI
-typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC)(GLuint dst, GLuint interp, GLenum swizzle);
-GLAPI PFNGLSAMPLEMAPATIPROC glad_glSampleMapATI;
-#define glSampleMapATI glad_glSampleMapATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI PFNGLCOLORFRAGMENTOP1ATIPROC glad_glColorFragmentOp1ATI;
-#define glColorFragmentOp1ATI glad_glColorFragmentOp1ATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI PFNGLCOLORFRAGMENTOP2ATIPROC glad_glColorFragmentOp2ATI;
-#define glColorFragmentOp2ATI glad_glColorFragmentOp2ATI
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI PFNGLCOLORFRAGMENTOP3ATIPROC glad_glColorFragmentOp3ATI;
-#define glColorFragmentOp3ATI glad_glColorFragmentOp3ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-GLAPI PFNGLALPHAFRAGMENTOP1ATIPROC glad_glAlphaFragmentOp1ATI;
-#define glAlphaFragmentOp1ATI glad_glAlphaFragmentOp1ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-GLAPI PFNGLALPHAFRAGMENTOP2ATIPROC glad_glAlphaFragmentOp2ATI;
-#define glAlphaFragmentOp2ATI glad_glAlphaFragmentOp2ATI
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-GLAPI PFNGLALPHAFRAGMENTOP3ATIPROC glad_glAlphaFragmentOp3ATI;
-#define glAlphaFragmentOp3ATI glad_glAlphaFragmentOp3ATI
-typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)(GLuint dst, const GLfloat* value);
-GLAPI PFNGLSETFRAGMENTSHADERCONSTANTATIPROC glad_glSetFragmentShaderConstantATI;
-#define glSetFragmentShaderConstantATI glad_glSetFragmentShaderConstantATI
-#endif
-#ifndef GL_ATI_vertex_array_object
-#define GL_ATI_vertex_array_object 1
-GLAPI int GLAD_GL_ATI_vertex_array_object;
-typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC)(GLsizei size, const void* pointer, GLenum usage);
-GLAPI PFNGLNEWOBJECTBUFFERATIPROC glad_glNewObjectBufferATI;
-#define glNewObjectBufferATI glad_glNewObjectBufferATI
-typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC)(GLuint buffer);
-GLAPI PFNGLISOBJECTBUFFERATIPROC glad_glIsObjectBufferATI;
-#define glIsObjectBufferATI glad_glIsObjectBufferATI
-typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC)(GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve);
-GLAPI PFNGLUPDATEOBJECTBUFFERATIPROC glad_glUpdateObjectBufferATI;
-#define glUpdateObjectBufferATI glad_glUpdateObjectBufferATI
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC)(GLuint buffer, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETOBJECTBUFFERFVATIPROC glad_glGetObjectBufferfvATI;
-#define glGetObjectBufferfvATI glad_glGetObjectBufferfvATI
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC)(GLuint buffer, GLenum pname, GLint* params);
-GLAPI PFNGLGETOBJECTBUFFERIVATIPROC glad_glGetObjectBufferivATI;
-#define glGetObjectBufferivATI glad_glGetObjectBufferivATI
-typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC)(GLuint buffer);
-GLAPI PFNGLFREEOBJECTBUFFERATIPROC glad_glFreeObjectBufferATI;
-#define glFreeObjectBufferATI glad_glFreeObjectBufferATI
-typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC)(GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI PFNGLARRAYOBJECTATIPROC glad_glArrayObjectATI;
-#define glArrayObjectATI glad_glArrayObjectATI
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC)(GLenum array, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETARRAYOBJECTFVATIPROC glad_glGetArrayObjectfvATI;
-#define glGetArrayObjectfvATI glad_glGetArrayObjectfvATI
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC)(GLenum array, GLenum pname, GLint* params);
-GLAPI PFNGLGETARRAYOBJECTIVATIPROC glad_glGetArrayObjectivATI;
-#define glGetArrayObjectivATI glad_glGetArrayObjectivATI
-typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC)(GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-GLAPI PFNGLVARIANTARRAYOBJECTATIPROC glad_glVariantArrayObjectATI;
-#define glVariantArrayObjectATI glad_glVariantArrayObjectATI
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC)(GLuint id, GLenum pname, GLfloat* params);
-GLAPI PFNGLGETVARIANTARRAYOBJECTFVATIPROC glad_glGetVariantArrayObjectfvATI;
-#define glGetVariantArrayObjectfvATI glad_glGetVariantArrayObjectfvATI
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC)(GLuint id, GLenum pname, GLint* params);
-GLAPI PFNGLGETVARIANTARRAYOBJECTIVATIPROC glad_glGetVariantArrayObjectivATI;
-#define glGetVariantArrayObjectivATI glad_glGetVariantArrayObjectivATI
-#endif
-#ifndef GL_EXT_blend_color
-#define GL_EXT_blend_color 1
-GLAPI int GLAD_GL_EXT_blend_color;
-typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GLAPI PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
-#define glBlendColorEXT glad_glBlendColorEXT
-#endif
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 1
-GLAPI int GLAD_GL_EXT_blend_equation_separate;
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC)(GLenum modeRGB, GLenum modeAlpha);
-GLAPI PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
-#define glBlendEquationSeparateEXT glad_glBlendEquationSeparateEXT
-#endif
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 1
-GLAPI int GLAD_GL_EXT_blend_func_separate;
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-GLAPI PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
-#define glBlendFuncSeparateEXT glad_glBlendFuncSeparateEXT
-#endif
-#ifndef GL_EXT_debug_marker
-#define GL_EXT_debug_marker 1
-GLAPI int GLAD_GL_EXT_debug_marker;
-typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC)(GLsizei length, const GLchar *marker);
-GLAPI PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
-#define glInsertEventMarkerEXT glad_glInsertEventMarkerEXT
-typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC)(GLsizei length, const GLchar *marker);
-GLAPI PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
-#define glPushGroupMarkerEXT glad_glPushGroupMarkerEXT
-typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC)(void);
-GLAPI PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
-#define glPopGroupMarkerEXT glad_glPopGroupMarkerEXT
-#endif
-#ifndef GL_EXT_framebuffer_blit
-#define GL_EXT_framebuffer_blit 1
-GLAPI int GLAD_GL_EXT_framebuffer_blit;
-typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GLAPI PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
-#define glBlitFramebufferEXT glad_glBlitFramebufferEXT
-#endif
-#ifndef GL_EXT_framebuffer_multisample
-#define GL_EXT_framebuffer_multisample 1
-GLAPI int GLAD_GL_EXT_framebuffer_multisample;
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
-#define glRenderbufferStorageMultisampleEXT glad_glRenderbufferStorageMultisampleEXT
-#endif
-#ifndef GL_EXT_framebuffer_multisample_blit_scaled
-#define GL_EXT_framebuffer_multisample_blit_scaled 1
-GLAPI int GLAD_GL_EXT_framebuffer_multisample_blit_scaled;
-#endif
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 1
-GLAPI int GLAD_GL_EXT_framebuffer_object;
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
-GLAPI PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
-#define glIsRenderbufferEXT glad_glIsRenderbufferEXT
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
-GLAPI PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT;
-#define glBindRenderbufferEXT glad_glBindRenderbufferEXT
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint* renderbuffers);
-GLAPI PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT;
-#define glDeleteRenderbuffersEXT glad_glDeleteRenderbuffersEXT
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint* renderbuffers);
-GLAPI PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT;
-#define glGenRenderbuffersEXT glad_glGenRenderbuffersEXT
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GLAPI PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
-#define glRenderbufferStorageEXT glad_glRenderbufferStorageEXT
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint* params);
-GLAPI PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT;
-#define glGetRenderbufferParameterivEXT glad_glGetRenderbufferParameterivEXT
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
-GLAPI PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT;
-#define glIsFramebufferEXT glad_glIsFramebufferEXT
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
-GLAPI PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT;
-#define glBindFramebufferEXT glad_glBindFramebufferEXT
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint* framebuffers);
-GLAPI PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT;
-#define glDeleteFramebuffersEXT glad_glDeleteFramebuffersEXT
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint* framebuffers);
-GLAPI PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT;
-#define glGenFramebuffersEXT glad_glGenFramebuffersEXT
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
-GLAPI PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT;
-#define glCheckFramebufferStatusEXT glad_glCheckFramebufferStatusEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT;
-#define glFramebufferTexture1DEXT glad_glFramebufferTexture1DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GLAPI PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT;
-#define glFramebufferTexture2DEXT glad_glFramebufferTexture2DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-GLAPI PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT;
-#define glFramebufferTexture3DEXT glad_glFramebufferTexture3DEXT
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GLAPI PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT;
-#define glFramebufferRenderbufferEXT glad_glFramebufferRenderbufferEXT
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT;
-#define glGetFramebufferAttachmentParameterivEXT glad_glGetFramebufferAttachmentParameterivEXT
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
-GLAPI PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT;
-#define glGenerateMipmapEXT glad_glGenerateMipmapEXT
-#endif
-#ifndef GL_EXT_framebuffer_sRGB
-#define GL_EXT_framebuffer_sRGB 1
-GLAPI int GLAD_GL_EXT_framebuffer_sRGB;
-#endif
-#ifndef GL_EXT_index_array_formats
-#define GL_EXT_index_array_formats 1
-GLAPI int GLAD_GL_EXT_index_array_formats;
-#endif
-#ifndef GL_EXT_texture
-#define GL_EXT_texture 1
-GLAPI int GLAD_GL_EXT_texture;
-#endif
-#ifndef GL_EXT_texture_compression_s3tc
-#define GL_EXT_texture_compression_s3tc 1
-GLAPI int GLAD_GL_EXT_texture_compression_s3tc;
-#endif
-#ifndef GL_EXT_texture_sRGB
-#define GL_EXT_texture_sRGB 1
-GLAPI int GLAD_GL_EXT_texture_sRGB;
-#endif
-#ifndef GL_EXT_texture_swizzle
-#define GL_EXT_texture_swizzle 1
-GLAPI int GLAD_GL_EXT_texture_swizzle;
-#endif
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 1
-GLAPI int GLAD_GL_EXT_vertex_array;
-typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC)(GLint i);
-GLAPI PFNGLARRAYELEMENTEXTPROC glad_glArrayElementEXT;
-#define glArrayElementEXT glad_glArrayElementEXT
-typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLCOLORPOINTEREXTPROC glad_glColorPointerEXT;
-#define glColorPointerEXT glad_glColorPointerEXT
-typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC)(GLenum mode, GLint first, GLsizei count);
-GLAPI PFNGLDRAWARRAYSEXTPROC glad_glDrawArraysEXT;
-#define glDrawArraysEXT glad_glDrawArraysEXT
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC)(GLsizei stride, GLsizei count, const GLboolean* pointer);
-GLAPI PFNGLEDGEFLAGPOINTEREXTPROC glad_glEdgeFlagPointerEXT;
-#define glEdgeFlagPointerEXT glad_glEdgeFlagPointerEXT
-typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC)(GLenum pname, void** params);
-GLAPI PFNGLGETPOINTERVEXTPROC glad_glGetPointervEXT;
-#define glGetPointervEXT glad_glGetPointervEXT
-typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC)(GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLINDEXPOINTEREXTPROC glad_glIndexPointerEXT;
-#define glIndexPointerEXT glad_glIndexPointerEXT
-typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC)(GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLNORMALPOINTEREXTPROC glad_glNormalPointerEXT;
-#define glNormalPointerEXT glad_glNormalPointerEXT
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLTEXCOORDPOINTEREXTPROC glad_glTexCoordPointerEXT;
-#define glTexCoordPointerEXT glad_glTexCoordPointerEXT
-typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC)(GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer);
-GLAPI PFNGLVERTEXPOINTEREXTPROC glad_glVertexPointerEXT;
-#define glVertexPointerEXT glad_glVertexPointerEXT
-#endif
-#ifndef GL_EXT_vertex_shader
-#define GL_EXT_vertex_shader 1
-GLAPI int GLAD_GL_EXT_vertex_shader;
-typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC)();
-GLAPI PFNGLBEGINVERTEXSHADEREXTPROC glad_glBeginVertexShaderEXT;
-#define glBeginVertexShaderEXT glad_glBeginVertexShaderEXT
-typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC)();
-GLAPI PFNGLENDVERTEXSHADEREXTPROC glad_glEndVertexShaderEXT;
-#define glEndVertexShaderEXT glad_glEndVertexShaderEXT
-typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC)(GLuint id);
-GLAPI PFNGLBINDVERTEXSHADEREXTPROC glad_glBindVertexShaderEXT;
-#define glBindVertexShaderEXT glad_glBindVertexShaderEXT
-typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC)(GLuint range);
-GLAPI PFNGLGENVERTEXSHADERSEXTPROC glad_glGenVertexShadersEXT;
-#define glGenVertexShadersEXT glad_glGenVertexShadersEXT
-typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC)(GLuint id);
-GLAPI PFNGLDELETEVERTEXSHADEREXTPROC glad_glDeleteVertexShaderEXT;
-#define glDeleteVertexShaderEXT glad_glDeleteVertexShaderEXT
-typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC)(GLenum op, GLuint res, GLuint arg1);
-GLAPI PFNGLSHADEROP1EXTPROC glad_glShaderOp1EXT;
-#define glShaderOp1EXT glad_glShaderOp1EXT
-typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC)(GLenum op, GLuint res, GLuint arg1, GLuint arg2);
-GLAPI PFNGLSHADEROP2EXTPROC glad_glShaderOp2EXT;
-#define glShaderOp2EXT glad_glShaderOp2EXT
-typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC)(GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
-GLAPI PFNGLSHADEROP3EXTPROC glad_glShaderOp3EXT;
-#define glShaderOp3EXT glad_glShaderOp3EXT
-typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC)(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI PFNGLSWIZZLEEXTPROC glad_glSwizzleEXT;
-#define glSwizzleEXT glad_glSwizzleEXT
-typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC)(GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-GLAPI PFNGLWRITEMASKEXTPROC glad_glWriteMaskEXT;
-#define glWriteMaskEXT glad_glWriteMaskEXT
-typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC)(GLuint res, GLuint src, GLuint num);
-GLAPI PFNGLINSERTCOMPONENTEXTPROC glad_glInsertComponentEXT;
-#define glInsertComponentEXT glad_glInsertComponentEXT
-typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC)(GLuint res, GLuint src, GLuint num);
-GLAPI PFNGLEXTRACTCOMPONENTEXTPROC glad_glExtractComponentEXT;
-#define glExtractComponentEXT glad_glExtractComponentEXT
-typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC)(GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
-GLAPI PFNGLGENSYMBOLSEXTPROC glad_glGenSymbolsEXT;
-#define glGenSymbolsEXT glad_glGenSymbolsEXT
-typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC)(GLuint id, GLenum type, const void* addr);
-GLAPI PFNGLSETINVARIANTEXTPROC glad_glSetInvariantEXT;
-#define glSetInvariantEXT glad_glSetInvariantEXT
-typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC)(GLuint id, GLenum type, const void* addr);
-GLAPI PFNGLSETLOCALCONSTANTEXTPROC glad_glSetLocalConstantEXT;
-#define glSetLocalConstantEXT glad_glSetLocalConstantEXT
-typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC)(GLuint id, const GLbyte* addr);
-GLAPI PFNGLVARIANTBVEXTPROC glad_glVariantbvEXT;
-#define glVariantbvEXT glad_glVariantbvEXT
-typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC)(GLuint id, const GLshort* addr);
-GLAPI PFNGLVARIANTSVEXTPROC glad_glVariantsvEXT;
-#define glVariantsvEXT glad_glVariantsvEXT
-typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC)(GLuint id, const GLint* addr);
-GLAPI PFNGLVARIANTIVEXTPROC glad_glVariantivEXT;
-#define glVariantivEXT glad_glVariantivEXT
-typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC)(GLuint id, const GLfloat* addr);
-GLAPI PFNGLVARIANTFVEXTPROC glad_glVariantfvEXT;
-#define glVariantfvEXT glad_glVariantfvEXT
-typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC)(GLuint id, const GLdouble* addr);
-GLAPI PFNGLVARIANTDVEXTPROC glad_glVariantdvEXT;
-#define glVariantdvEXT glad_glVariantdvEXT
-typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC)(GLuint id, const GLubyte* addr);
-GLAPI PFNGLVARIANTUBVEXTPROC glad_glVariantubvEXT;
-#define glVariantubvEXT glad_glVariantubvEXT
-typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC)(GLuint id, const GLushort* addr);
-GLAPI PFNGLVARIANTUSVEXTPROC glad_glVariantusvEXT;
-#define glVariantusvEXT glad_glVariantusvEXT
-typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC)(GLuint id, const GLuint* addr);
-GLAPI PFNGLVARIANTUIVEXTPROC glad_glVariantuivEXT;
-#define glVariantuivEXT glad_glVariantuivEXT
-typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC)(GLuint id, GLenum type, GLuint stride, const void* addr);
-GLAPI PFNGLVARIANTPOINTEREXTPROC glad_glVariantPointerEXT;
-#define glVariantPointerEXT glad_glVariantPointerEXT
-typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)(GLuint id);
-GLAPI PFNGLENABLEVARIANTCLIENTSTATEEXTPROC glad_glEnableVariantClientStateEXT;
-#define glEnableVariantClientStateEXT glad_glEnableVariantClientStateEXT
-typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)(GLuint id);
-GLAPI PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC glad_glDisableVariantClientStateEXT;
-#define glDisableVariantClientStateEXT glad_glDisableVariantClientStateEXT
-typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC)(GLenum light, GLenum value);
-GLAPI PFNGLBINDLIGHTPARAMETEREXTPROC glad_glBindLightParameterEXT;
-#define glBindLightParameterEXT glad_glBindLightParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC)(GLenum face, GLenum value);
-GLAPI PFNGLBINDMATERIALPARAMETEREXTPROC glad_glBindMaterialParameterEXT;
-#define glBindMaterialParameterEXT glad_glBindMaterialParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC)(GLenum unit, GLenum coord, GLenum value);
-GLAPI PFNGLBINDTEXGENPARAMETEREXTPROC glad_glBindTexGenParameterEXT;
-#define glBindTexGenParameterEXT glad_glBindTexGenParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)(GLenum unit, GLenum value);
-GLAPI PFNGLBINDTEXTUREUNITPARAMETEREXTPROC glad_glBindTextureUnitParameterEXT;
-#define glBindTextureUnitParameterEXT glad_glBindTextureUnitParameterEXT
-typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC)(GLenum value);
-GLAPI PFNGLBINDPARAMETEREXTPROC glad_glBindParameterEXT;
-#define glBindParameterEXT glad_glBindParameterEXT
-typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC)(GLuint id, GLenum cap);
-GLAPI PFNGLISVARIANTENABLEDEXTPROC glad_glIsVariantEnabledEXT;
-#define glIsVariantEnabledEXT glad_glIsVariantEnabledEXT
-typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETVARIANTBOOLEANVEXTPROC glad_glGetVariantBooleanvEXT;
-#define glGetVariantBooleanvEXT glad_glGetVariantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETVARIANTINTEGERVEXTPROC glad_glGetVariantIntegervEXT;
-#define glGetVariantIntegervEXT glad_glGetVariantIntegervEXT
-typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETVARIANTFLOATVEXTPROC glad_glGetVariantFloatvEXT;
-#define glGetVariantFloatvEXT glad_glGetVariantFloatvEXT
-typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC)(GLuint id, GLenum value, void** data);
-GLAPI PFNGLGETVARIANTPOINTERVEXTPROC glad_glGetVariantPointervEXT;
-#define glGetVariantPointervEXT glad_glGetVariantPointervEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETINVARIANTBOOLEANVEXTPROC glad_glGetInvariantBooleanvEXT;
-#define glGetInvariantBooleanvEXT glad_glGetInvariantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETINVARIANTINTEGERVEXTPROC glad_glGetInvariantIntegervEXT;
-#define glGetInvariantIntegervEXT glad_glGetInvariantIntegervEXT
-typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETINVARIANTFLOATVEXTPROC glad_glGetInvariantFloatvEXT;
-#define glGetInvariantFloatvEXT glad_glGetInvariantFloatvEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)(GLuint id, GLenum value, GLboolean* data);
-GLAPI PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC glad_glGetLocalConstantBooleanvEXT;
-#define glGetLocalConstantBooleanvEXT glad_glGetLocalConstantBooleanvEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)(GLuint id, GLenum value, GLint* data);
-GLAPI PFNGLGETLOCALCONSTANTINTEGERVEXTPROC glad_glGetLocalConstantIntegervEXT;
-#define glGetLocalConstantIntegervEXT glad_glGetLocalConstantIntegervEXT
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC)(GLuint id, GLenum value, GLfloat* data);
-GLAPI PFNGLGETLOCALCONSTANTFLOATVEXTPROC glad_glGetLocalConstantFloatvEXT;
-#define glGetLocalConstantFloatvEXT glad_glGetLocalConstantFloatvEXT
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//     IMPLEMENTATION SECTION
-//
-
-#ifdef GLAD_IMPLEMENTATION
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct gladGLversionStruct GLVersion;
-
-#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
-#define _GLAD_IS_SOME_NEW_VERSION 1
-#endif
-
-static int max_loaded_major;
-static int max_loaded_minor;
-
-static const char *exts = NULL;
-static int num_exts_i = 0;
-static const char **exts_i = NULL;
-
-static int get_exts(void) {
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    if(max_loaded_major < 3) {
-#endif
-        exts = (const char *)glGetString(GL_EXTENSIONS);
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    } else {
-        int index;
-
-        num_exts_i = 0;
-        glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
-        if (num_exts_i > 0) {
-            exts_i = (const char **)GLAD_REALLOC((void *)exts_i, num_exts_i * sizeof *exts_i);
-        }
-
-        if (exts_i == NULL) {
-            return 0;
-        }
-
-        for(index = 0; index < num_exts_i; index++) {
-            exts_i[index] = (const char*)glGetStringi(GL_EXTENSIONS, index);
-        }
-    }
-#endif
-    return 1;
-}
-
-static void free_exts(void) {
-    if (exts_i != NULL) {
-        GLAD_FREE((char **)exts_i);
-        exts_i = NULL;
-    }
-}
-
-static int has_ext(const char *ext) {
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    if(max_loaded_major < 3) {
-#endif
-        const char *extensions;
-        const char *loc;
-        const char *terminator;
-        extensions = exts;
-        if(extensions == NULL || ext == NULL) {
-            return 0;
-        }
-
-        while(1) {
-            loc = strstr(extensions, ext);
-            if(loc == NULL) {
-                return 0;
-            }
-
-            terminator = loc + strlen(ext);
-            if((loc == extensions || *(loc - 1) == ' ') &&
-                (*terminator == ' ' || *terminator == '\0')) {
-                return 1;
-            }
-            extensions = terminator;
-        }
-#ifdef _GLAD_IS_SOME_NEW_VERSION
-    } else {
-        int index;
-
-        for(index = 0; index < num_exts_i; index++) {
-            const char *e = exts_i[index];
-
-            if(strcmp(e, ext) == 0) {
-                return 1;
-            }
-        }
-    }
-#endif
-
-    return 0;
-}
-int GLAD_GL_VERSION_1_0;
-int GLAD_GL_VERSION_1_1;
-int GLAD_GL_VERSION_1_2;
-int GLAD_GL_VERSION_1_3;
-int GLAD_GL_VERSION_1_4;
-int GLAD_GL_VERSION_1_5;
-int GLAD_GL_VERSION_2_0;
-int GLAD_GL_VERSION_2_1;
-int GLAD_GL_VERSION_3_0;
-int GLAD_GL_VERSION_3_1;
-int GLAD_GL_VERSION_3_2;
-int GLAD_GL_VERSION_3_3;
-PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-PFNGLBINDSAMPLERPROC glad_glBindSampler;
-PFNGLLINEWIDTHPROC glad_glLineWidth;
-PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-PFNGLCOMPILESHADERPROC glad_glCompileShader;
-PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-PFNGLENABLEIPROC glad_glEnablei;
-PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-PFNGLCREATESHADERPROC glad_glCreateShader;
-PFNGLISBUFFERPROC glad_glIsBuffer;
-PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-PFNGLHINTPROC glad_glHint;
-PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-PFNGLPOINTSIZEPROC glad_glPointSize;
-PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-PFNGLWAITSYNCPROC glad_glWaitSync;
-PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-PFNGLUNIFORM3IPROC glad_glUniform3i;
-PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-PFNGLUNIFORM3FPROC glad_glUniform3f;
-PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-PFNGLCOLORMASKIPROC glad_glColorMaski;
-PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-PFNGLCLEARPROC glad_glClear;
-PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-PFNGLISENABLEDPROC glad_glIsEnabled;
-PFNGLSTENCILOPPROC glad_glStencilOp;
-PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-PFNGLISSHADERPROC glad_glIsShader;
-PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-PFNGLENABLEPROC glad_glEnable;
-PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-PFNGLFLUSHPROC glad_glFlush;
-PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-PFNGLFENCESYNCPROC glad_glFenceSync;
-PFNGLCOLORP3UIPROC glad_glColorP3ui;
-PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-PFNGLCLAMPCOLORPROC glad_glClampColor;
-PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-PFNGLCLEARSTENCILPROC glad_glClearStencil;
-PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-PFNGLGENTEXTURESPROC glad_glGenTextures;
-PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-PFNGLISSYNCPROC glad_glIsSync;
-PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-PFNGLUNIFORM2IPROC glad_glUniform2i;
-PFNGLUNIFORM2FPROC glad_glUniform2f;
-PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-PFNGLGENQUERIESPROC glad_glGenQueries;
-PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-PFNGLISENABLEDIPROC glad_glIsEnabledi;
-PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-PFNGLDEPTHRANGEPROC glad_glDepthRange;
-PFNGLMAPBUFFERPROC glad_glMapBuffer;
-PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-PFNGLDELETESYNCPROC glad_glDeleteSync;
-PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-PFNGLUSEPROGRAMPROC glad_glUseProgram;
-PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-PFNGLFINISHPROC glad_glFinish;
-PFNGLDELETESHADERPROC glad_glDeleteShader;
-PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-PFNGLVIEWPORTPROC glad_glViewport;
-PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-PFNGLCLEARDEPTHPROC glad_glClearDepth;
-PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-PFNGLTEXBUFFERPROC glad_glTexBuffer;
-PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-PFNGLBINDTEXTUREPROC glad_glBindTexture;
-PFNGLGETSTRINGPROC glad_glGetString;
-PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-PFNGLDETACHSHADERPROC glad_glDetachShader;
-PFNGLENDQUERYPROC glad_glEndQuery;
-PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-PFNGLUNIFORM1FPROC glad_glUniform1f;
-PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-PFNGLUNIFORM1IPROC glad_glUniform1i;
-PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-PFNGLDISABLEPROC glad_glDisable;
-PFNGLLOGICOPPROC glad_glLogicOp;
-PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-PFNGLCULLFACEPROC glad_glCullFace;
-PFNGLGETSTRINGIPROC glad_glGetStringi;
-PFNGLATTACHSHADERPROC glad_glAttachShader;
-PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-PFNGLREADBUFFERPROC glad_glReadBuffer;
-PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-PFNGLBLENDCOLORPROC glad_glBlendColor;
-PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-PFNGLISPROGRAMPROC glad_glIsProgram;
-PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-PFNGLUNIFORM4IPROC glad_glUniform4i;
-PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-PFNGLREADPIXELSPROC glad_glReadPixels;
-PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-PFNGLUNIFORM4FPROC glad_glUniform4f;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-PFNGLCOLORP4UIPROC glad_glColorP4ui;
-PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-PFNGLGENBUFFERSPROC glad_glGenBuffers;
-PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-PFNGLBLENDFUNCPROC glad_glBlendFunc;
-PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-PFNGLSCISSORPROC glad_glScissor;
-PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-PFNGLCLEARCOLORPROC glad_glClearColor;
-PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-PFNGLCOLORMASKPROC glad_glColorMask;
-PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-PFNGLISSAMPLERPROC glad_glIsSampler;
-PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-PFNGLDISABLEIPROC glad_glDisablei;
-PFNGLSHADERSOURCEPROC glad_glShaderSource;
-PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-PFNGLGETSYNCIVPROC glad_glGetSynciv;
-PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-PFNGLBEGINQUERYPROC glad_glBeginQuery;
-PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-PFNGLBINDBUFFERPROC glad_glBindBuffer;
-PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-PFNGLBUFFERDATAPROC glad_glBufferData;
-PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-PFNGLGETERRORPROC glad_glGetError;
-PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-PFNGLGETFLOATVPROC glad_glGetFloatv;
-PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-PFNGLISQUERYPROC glad_glIsQuery;
-PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-PFNGLSTENCILMASKPROC glad_glStencilMask;
-PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-PFNGLISTEXTUREPROC glad_glIsTexture;
-PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-PFNGLDEPTHMASKPROC glad_glDepthMask;
-PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-PFNGLFRONTFACEPROC glad_glFrontFace;
-int GLAD_GL_ARB_texture_compression;
-int GLAD_GL_ARB_texture_swizzle;
-int GLAD_GL_ATI_fragment_shader;
-int GLAD_GL_EXT_texture_sRGB;
-int GLAD_GL_ARB_explicit_attrib_location;
-int GLAD_GL_ARB_ES3_compatibility;
-int GLAD_GL_EXT_blend_color;
-int GLAD_GL_EXT_framebuffer_sRGB;
-int GLAD_GL_EXT_index_array_formats;
-int GLAD_GL_ARB_vertex_shader;
-int GLAD_GL_ARB_vertex_attrib_binding;
-int GLAD_GL_ARB_vertex_program;
-int GLAD_GL_EXT_texture_compression_s3tc;
-int GLAD_GL_EXT_debug_marker;
-int GLAD_GL_EXT_texture_swizzle;
-int GLAD_GL_ARB_texture_multisample;
-int GLAD_GL_ARB_texture_rg;
-int GLAD_GL_ARB_texture_float;
-int GLAD_GL_ARB_compressed_texture_pixel_storage;
-int GLAD_GL_ARB_framebuffer_sRGB;
-int GLAD_GL_ARB_vertex_array_object;
-int GLAD_GL_ARB_depth_clamp;
-int GLAD_GL_ARB_fragment_shader;
-int GLAD_GL_ATI_vertex_array_object;
-int GLAD_GL_ARB_vertex_buffer_object;
-int GLAD_GL_ARB_fragment_program;
-int GLAD_GL_EXT_framebuffer_multisample;
-int GLAD_GL_ARB_framebuffer_object;
-int GLAD_GL_ARB_draw_buffers_blend;
-int GLAD_GL_EXT_vertex_shader;
-int GLAD_GL_EXT_blend_func_separate;
-int GLAD_GL_ARB_texture_non_power_of_two;
-int GLAD_GL_EXT_texture;
-int GLAD_GL_ARB_buffer_storage;
-int GLAD_GL_ARB_explicit_uniform_location;
-int GLAD_GL_EXT_framebuffer_object;
-int GLAD_GL_EXT_framebuffer_multisample_blit_scaled;
-int GLAD_GL_AMD_debug_output;
-int GLAD_GL_ARB_depth_buffer_float;
-int GLAD_GL_ARB_multisample;
-int GLAD_GL_ARB_compatibility;
-int GLAD_GL_ARB_depth_texture;
-int GLAD_GL_ARB_sample_locations;
-int GLAD_GL_ARB_ES2_compatibility;
-int GLAD_GL_AMD_query_buffer_object;
-int GLAD_GL_EXT_framebuffer_blit;
-int GLAD_GL_EXT_vertex_array;
-int GLAD_GL_ARB_draw_buffers;
-int GLAD_GL_EXT_blend_equation_separate;
-int GLAD_GL_ATI_element_array;
-int GLAD_GL_ARB_debug_output;
-int GLAD_GL_ARB_uniform_buffer_object;
-PFNGLDEBUGMESSAGEENABLEAMDPROC glad_glDebugMessageEnableAMD;
-PFNGLDEBUGMESSAGEINSERTAMDPROC glad_glDebugMessageInsertAMD;
-PFNGLDEBUGMESSAGECALLBACKAMDPROC glad_glDebugMessageCallbackAMD;
-PFNGLGETDEBUGMESSAGELOGAMDPROC glad_glGetDebugMessageLogAMD;
-PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
-PFNGLSHADERBINARYPROC glad_glShaderBinary;
-PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
-PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
-PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
-PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
-PFNGLDEBUGMESSAGECONTROLARBPROC glad_glDebugMessageControlARB;
-PFNGLDEBUGMESSAGEINSERTARBPROC glad_glDebugMessageInsertARB;
-PFNGLDEBUGMESSAGECALLBACKARBPROC glad_glDebugMessageCallbackARB;
-PFNGLGETDEBUGMESSAGELOGARBPROC glad_glGetDebugMessageLogARB;
-PFNGLDRAWBUFFERSARBPROC glad_glDrawBuffersARB;
-PFNGLBLENDEQUATIONIARBPROC glad_glBlendEquationiARB;
-PFNGLBLENDEQUATIONSEPARATEIARBPROC glad_glBlendEquationSeparateiARB;
-PFNGLBLENDFUNCIARBPROC glad_glBlendFunciARB;
-PFNGLBLENDFUNCSEPARATEIARBPROC glad_glBlendFuncSeparateiARB;
-PFNGLPROGRAMSTRINGARBPROC glad_glProgramStringARB;
-PFNGLBINDPROGRAMARBPROC glad_glBindProgramARB;
-PFNGLDELETEPROGRAMSARBPROC glad_glDeleteProgramsARB;
-PFNGLGENPROGRAMSARBPROC glad_glGenProgramsARB;
-PFNGLPROGRAMENVPARAMETER4DARBPROC glad_glProgramEnvParameter4dARB;
-PFNGLPROGRAMENVPARAMETER4DVARBPROC glad_glProgramEnvParameter4dvARB;
-PFNGLPROGRAMENVPARAMETER4FARBPROC glad_glProgramEnvParameter4fARB;
-PFNGLPROGRAMENVPARAMETER4FVARBPROC glad_glProgramEnvParameter4fvARB;
-PFNGLPROGRAMLOCALPARAMETER4DARBPROC glad_glProgramLocalParameter4dARB;
-PFNGLPROGRAMLOCALPARAMETER4DVARBPROC glad_glProgramLocalParameter4dvARB;
-PFNGLPROGRAMLOCALPARAMETER4FARBPROC glad_glProgramLocalParameter4fARB;
-PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glad_glProgramLocalParameter4fvARB;
-PFNGLGETPROGRAMENVPARAMETERDVARBPROC glad_glGetProgramEnvParameterdvARB;
-PFNGLGETPROGRAMENVPARAMETERFVARBPROC glad_glGetProgramEnvParameterfvARB;
-PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC glad_glGetProgramLocalParameterdvARB;
-PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC glad_glGetProgramLocalParameterfvARB;
-PFNGLGETPROGRAMIVARBPROC glad_glGetProgramivARB;
-PFNGLGETPROGRAMSTRINGARBPROC glad_glGetProgramStringARB;
-PFNGLISPROGRAMARBPROC glad_glIsProgramARB;
-PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glFramebufferSampleLocationsfvARB;
-PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC glad_glNamedFramebufferSampleLocationsfvARB;
-PFNGLEVALUATEDEPTHVALUESARBPROC glad_glEvaluateDepthValuesARB;
-PFNGLCOMPRESSEDTEXIMAGE3DARBPROC glad_glCompressedTexImage3DARB;
-PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glad_glCompressedTexImage2DARB;
-PFNGLCOMPRESSEDTEXIMAGE1DARBPROC glad_glCompressedTexImage1DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC glad_glCompressedTexSubImage3DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC glad_glCompressedTexSubImage2DARB;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC glad_glCompressedTexSubImage1DARB;
-PFNGLGETCOMPRESSEDTEXIMAGEARBPROC glad_glGetCompressedTexImageARB;
-PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
-PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
-PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
-PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
-PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
-PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
-PFNGLBINDBUFFERARBPROC glad_glBindBufferARB;
-PFNGLDELETEBUFFERSARBPROC glad_glDeleteBuffersARB;
-PFNGLGENBUFFERSARBPROC glad_glGenBuffersARB;
-PFNGLISBUFFERARBPROC glad_glIsBufferARB;
-PFNGLBUFFERDATAARBPROC glad_glBufferDataARB;
-PFNGLBUFFERSUBDATAARBPROC glad_glBufferSubDataARB;
-PFNGLGETBUFFERSUBDATAARBPROC glad_glGetBufferSubDataARB;
-PFNGLMAPBUFFERARBPROC glad_glMapBufferARB;
-PFNGLUNMAPBUFFERARBPROC glad_glUnmapBufferARB;
-PFNGLGETBUFFERPARAMETERIVARBPROC glad_glGetBufferParameterivARB;
-PFNGLGETBUFFERPOINTERVARBPROC glad_glGetBufferPointervARB;
-PFNGLVERTEXATTRIB1DARBPROC glad_glVertexAttrib1dARB;
-PFNGLVERTEXATTRIB1DVARBPROC glad_glVertexAttrib1dvARB;
-PFNGLVERTEXATTRIB1FARBPROC glad_glVertexAttrib1fARB;
-PFNGLVERTEXATTRIB1FVARBPROC glad_glVertexAttrib1fvARB;
-PFNGLVERTEXATTRIB1SARBPROC glad_glVertexAttrib1sARB;
-PFNGLVERTEXATTRIB1SVARBPROC glad_glVertexAttrib1svARB;
-PFNGLVERTEXATTRIB2DARBPROC glad_glVertexAttrib2dARB;
-PFNGLVERTEXATTRIB2DVARBPROC glad_glVertexAttrib2dvARB;
-PFNGLVERTEXATTRIB2FARBPROC glad_glVertexAttrib2fARB;
-PFNGLVERTEXATTRIB2FVARBPROC glad_glVertexAttrib2fvARB;
-PFNGLVERTEXATTRIB2SARBPROC glad_glVertexAttrib2sARB;
-PFNGLVERTEXATTRIB2SVARBPROC glad_glVertexAttrib2svARB;
-PFNGLVERTEXATTRIB3DARBPROC glad_glVertexAttrib3dARB;
-PFNGLVERTEXATTRIB3DVARBPROC glad_glVertexAttrib3dvARB;
-PFNGLVERTEXATTRIB3FARBPROC glad_glVertexAttrib3fARB;
-PFNGLVERTEXATTRIB3FVARBPROC glad_glVertexAttrib3fvARB;
-PFNGLVERTEXATTRIB3SARBPROC glad_glVertexAttrib3sARB;
-PFNGLVERTEXATTRIB3SVARBPROC glad_glVertexAttrib3svARB;
-PFNGLVERTEXATTRIB4NBVARBPROC glad_glVertexAttrib4NbvARB;
-PFNGLVERTEXATTRIB4NIVARBPROC glad_glVertexAttrib4NivARB;
-PFNGLVERTEXATTRIB4NSVARBPROC glad_glVertexAttrib4NsvARB;
-PFNGLVERTEXATTRIB4NUBARBPROC glad_glVertexAttrib4NubARB;
-PFNGLVERTEXATTRIB4NUBVARBPROC glad_glVertexAttrib4NubvARB;
-PFNGLVERTEXATTRIB4NUIVARBPROC glad_glVertexAttrib4NuivARB;
-PFNGLVERTEXATTRIB4NUSVARBPROC glad_glVertexAttrib4NusvARB;
-PFNGLVERTEXATTRIB4BVARBPROC glad_glVertexAttrib4bvARB;
-PFNGLVERTEXATTRIB4DARBPROC glad_glVertexAttrib4dARB;
-PFNGLVERTEXATTRIB4DVARBPROC glad_glVertexAttrib4dvARB;
-PFNGLVERTEXATTRIB4FARBPROC glad_glVertexAttrib4fARB;
-PFNGLVERTEXATTRIB4FVARBPROC glad_glVertexAttrib4fvARB;
-PFNGLVERTEXATTRIB4IVARBPROC glad_glVertexAttrib4ivARB;
-PFNGLVERTEXATTRIB4SARBPROC glad_glVertexAttrib4sARB;
-PFNGLVERTEXATTRIB4SVARBPROC glad_glVertexAttrib4svARB;
-PFNGLVERTEXATTRIB4UBVARBPROC glad_glVertexAttrib4ubvARB;
-PFNGLVERTEXATTRIB4UIVARBPROC glad_glVertexAttrib4uivARB;
-PFNGLVERTEXATTRIB4USVARBPROC glad_glVertexAttrib4usvARB;
-PFNGLVERTEXATTRIBPOINTERARBPROC glad_glVertexAttribPointerARB;
-PFNGLENABLEVERTEXATTRIBARRAYARBPROC glad_glEnableVertexAttribArrayARB;
-PFNGLDISABLEVERTEXATTRIBARRAYARBPROC glad_glDisableVertexAttribArrayARB;
-PFNGLGETVERTEXATTRIBDVARBPROC glad_glGetVertexAttribdvARB;
-PFNGLGETVERTEXATTRIBFVARBPROC glad_glGetVertexAttribfvARB;
-PFNGLGETVERTEXATTRIBIVARBPROC glad_glGetVertexAttribivARB;
-PFNGLGETVERTEXATTRIBPOINTERVARBPROC glad_glGetVertexAttribPointervARB;
-PFNGLBINDATTRIBLOCATIONARBPROC glad_glBindAttribLocationARB;
-PFNGLGETACTIVEATTRIBARBPROC glad_glGetActiveAttribARB;
-PFNGLGETATTRIBLOCATIONARBPROC glad_glGetAttribLocationARB;
-PFNGLELEMENTPOINTERATIPROC glad_glElementPointerATI;
-PFNGLDRAWELEMENTARRAYATIPROC glad_glDrawElementArrayATI;
-PFNGLDRAWRANGEELEMENTARRAYATIPROC glad_glDrawRangeElementArrayATI;
-PFNGLGENFRAGMENTSHADERSATIPROC glad_glGenFragmentShadersATI;
-PFNGLBINDFRAGMENTSHADERATIPROC glad_glBindFragmentShaderATI;
-PFNGLDELETEFRAGMENTSHADERATIPROC glad_glDeleteFragmentShaderATI;
-PFNGLBEGINFRAGMENTSHADERATIPROC glad_glBeginFragmentShaderATI;
-PFNGLENDFRAGMENTSHADERATIPROC glad_glEndFragmentShaderATI;
-PFNGLPASSTEXCOORDATIPROC glad_glPassTexCoordATI;
-PFNGLSAMPLEMAPATIPROC glad_glSampleMapATI;
-PFNGLCOLORFRAGMENTOP1ATIPROC glad_glColorFragmentOp1ATI;
-PFNGLCOLORFRAGMENTOP2ATIPROC glad_glColorFragmentOp2ATI;
-PFNGLCOLORFRAGMENTOP3ATIPROC glad_glColorFragmentOp3ATI;
-PFNGLALPHAFRAGMENTOP1ATIPROC glad_glAlphaFragmentOp1ATI;
-PFNGLALPHAFRAGMENTOP2ATIPROC glad_glAlphaFragmentOp2ATI;
-PFNGLALPHAFRAGMENTOP3ATIPROC glad_glAlphaFragmentOp3ATI;
-PFNGLSETFRAGMENTSHADERCONSTANTATIPROC glad_glSetFragmentShaderConstantATI;
-PFNGLNEWOBJECTBUFFERATIPROC glad_glNewObjectBufferATI;
-PFNGLISOBJECTBUFFERATIPROC glad_glIsObjectBufferATI;
-PFNGLUPDATEOBJECTBUFFERATIPROC glad_glUpdateObjectBufferATI;
-PFNGLGETOBJECTBUFFERFVATIPROC glad_glGetObjectBufferfvATI;
-PFNGLGETOBJECTBUFFERIVATIPROC glad_glGetObjectBufferivATI;
-PFNGLFREEOBJECTBUFFERATIPROC glad_glFreeObjectBufferATI;
-PFNGLARRAYOBJECTATIPROC glad_glArrayObjectATI;
-PFNGLGETARRAYOBJECTFVATIPROC glad_glGetArrayObjectfvATI;
-PFNGLGETARRAYOBJECTIVATIPROC glad_glGetArrayObjectivATI;
-PFNGLVARIANTARRAYOBJECTATIPROC glad_glVariantArrayObjectATI;
-PFNGLGETVARIANTARRAYOBJECTFVATIPROC glad_glGetVariantArrayObjectfvATI;
-PFNGLGETVARIANTARRAYOBJECTIVATIPROC glad_glGetVariantArrayObjectivATI;
-PFNGLBLENDCOLOREXTPROC glad_glBlendColorEXT;
-PFNGLBLENDEQUATIONSEPARATEEXTPROC glad_glBlendEquationSeparateEXT;
-PFNGLBLENDFUNCSEPARATEEXTPROC glad_glBlendFuncSeparateEXT;
-PFNGLINSERTEVENTMARKEREXTPROC glad_glInsertEventMarkerEXT;
-PFNGLPUSHGROUPMARKEREXTPROC glad_glPushGroupMarkerEXT;
-PFNGLPOPGROUPMARKEREXTPROC glad_glPopGroupMarkerEXT;
-PFNGLBLITFRAMEBUFFEREXTPROC glad_glBlitFramebufferEXT;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC glad_glRenderbufferStorageMultisampleEXT;
-PFNGLISRENDERBUFFEREXTPROC glad_glIsRenderbufferEXT;
-PFNGLBINDRENDERBUFFEREXTPROC glad_glBindRenderbufferEXT;
-PFNGLDELETERENDERBUFFERSEXTPROC glad_glDeleteRenderbuffersEXT;
-PFNGLGENRENDERBUFFERSEXTPROC glad_glGenRenderbuffersEXT;
-PFNGLRENDERBUFFERSTORAGEEXTPROC glad_glRenderbufferStorageEXT;
-PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glad_glGetRenderbufferParameterivEXT;
-PFNGLISFRAMEBUFFEREXTPROC glad_glIsFramebufferEXT;
-PFNGLBINDFRAMEBUFFEREXTPROC glad_glBindFramebufferEXT;
-PFNGLDELETEFRAMEBUFFERSEXTPROC glad_glDeleteFramebuffersEXT;
-PFNGLGENFRAMEBUFFERSEXTPROC glad_glGenFramebuffersEXT;
-PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glad_glCheckFramebufferStatusEXT;
-PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glad_glFramebufferTexture1DEXT;
-PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glad_glFramebufferTexture2DEXT;
-PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glad_glFramebufferTexture3DEXT;
-PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glad_glFramebufferRenderbufferEXT;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glad_glGetFramebufferAttachmentParameterivEXT;
-PFNGLGENERATEMIPMAPEXTPROC glad_glGenerateMipmapEXT;
-PFNGLARRAYELEMENTEXTPROC glad_glArrayElementEXT;
-PFNGLCOLORPOINTEREXTPROC glad_glColorPointerEXT;
-PFNGLDRAWARRAYSEXTPROC glad_glDrawArraysEXT;
-PFNGLEDGEFLAGPOINTEREXTPROC glad_glEdgeFlagPointerEXT;
-PFNGLGETPOINTERVEXTPROC glad_glGetPointervEXT;
-PFNGLINDEXPOINTEREXTPROC glad_glIndexPointerEXT;
-PFNGLNORMALPOINTEREXTPROC glad_glNormalPointerEXT;
-PFNGLTEXCOORDPOINTEREXTPROC glad_glTexCoordPointerEXT;
-PFNGLVERTEXPOINTEREXTPROC glad_glVertexPointerEXT;
-PFNGLBEGINVERTEXSHADEREXTPROC glad_glBeginVertexShaderEXT;
-PFNGLENDVERTEXSHADEREXTPROC glad_glEndVertexShaderEXT;
-PFNGLBINDVERTEXSHADEREXTPROC glad_glBindVertexShaderEXT;
-PFNGLGENVERTEXSHADERSEXTPROC glad_glGenVertexShadersEXT;
-PFNGLDELETEVERTEXSHADEREXTPROC glad_glDeleteVertexShaderEXT;
-PFNGLSHADEROP1EXTPROC glad_glShaderOp1EXT;
-PFNGLSHADEROP2EXTPROC glad_glShaderOp2EXT;
-PFNGLSHADEROP3EXTPROC glad_glShaderOp3EXT;
-PFNGLSWIZZLEEXTPROC glad_glSwizzleEXT;
-PFNGLWRITEMASKEXTPROC glad_glWriteMaskEXT;
-PFNGLINSERTCOMPONENTEXTPROC glad_glInsertComponentEXT;
-PFNGLEXTRACTCOMPONENTEXTPROC glad_glExtractComponentEXT;
-PFNGLGENSYMBOLSEXTPROC glad_glGenSymbolsEXT;
-PFNGLSETINVARIANTEXTPROC glad_glSetInvariantEXT;
-PFNGLSETLOCALCONSTANTEXTPROC glad_glSetLocalConstantEXT;
-PFNGLVARIANTBVEXTPROC glad_glVariantbvEXT;
-PFNGLVARIANTSVEXTPROC glad_glVariantsvEXT;
-PFNGLVARIANTIVEXTPROC glad_glVariantivEXT;
-PFNGLVARIANTFVEXTPROC glad_glVariantfvEXT;
-PFNGLVARIANTDVEXTPROC glad_glVariantdvEXT;
-PFNGLVARIANTUBVEXTPROC glad_glVariantubvEXT;
-PFNGLVARIANTUSVEXTPROC glad_glVariantusvEXT;
-PFNGLVARIANTUIVEXTPROC glad_glVariantuivEXT;
-PFNGLVARIANTPOINTEREXTPROC glad_glVariantPointerEXT;
-PFNGLENABLEVARIANTCLIENTSTATEEXTPROC glad_glEnableVariantClientStateEXT;
-PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC glad_glDisableVariantClientStateEXT;
-PFNGLBINDLIGHTPARAMETEREXTPROC glad_glBindLightParameterEXT;
-PFNGLBINDMATERIALPARAMETEREXTPROC glad_glBindMaterialParameterEXT;
-PFNGLBINDTEXGENPARAMETEREXTPROC glad_glBindTexGenParameterEXT;
-PFNGLBINDTEXTUREUNITPARAMETEREXTPROC glad_glBindTextureUnitParameterEXT;
-PFNGLBINDPARAMETEREXTPROC glad_glBindParameterEXT;
-PFNGLISVARIANTENABLEDEXTPROC glad_glIsVariantEnabledEXT;
-PFNGLGETVARIANTBOOLEANVEXTPROC glad_glGetVariantBooleanvEXT;
-PFNGLGETVARIANTINTEGERVEXTPROC glad_glGetVariantIntegervEXT;
-PFNGLGETVARIANTFLOATVEXTPROC glad_glGetVariantFloatvEXT;
-PFNGLGETVARIANTPOINTERVEXTPROC glad_glGetVariantPointervEXT;
-PFNGLGETINVARIANTBOOLEANVEXTPROC glad_glGetInvariantBooleanvEXT;
-PFNGLGETINVARIANTINTEGERVEXTPROC glad_glGetInvariantIntegervEXT;
-PFNGLGETINVARIANTFLOATVEXTPROC glad_glGetInvariantFloatvEXT;
-PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC glad_glGetLocalConstantBooleanvEXT;
-PFNGLGETLOCALCONSTANTINTEGERVEXTPROC glad_glGetLocalConstantIntegervEXT;
-PFNGLGETLOCALCONSTANTFLOATVEXTPROC glad_glGetLocalConstantFloatvEXT;
-static void load_GL_VERSION_1_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_0) return;
-       glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace");
-       glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace");
-       glad_glHint = (PFNGLHINTPROC)load("glHint");
-       glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth");
-       glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize");
-       glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode");
-       glad_glScissor = (PFNGLSCISSORPROC)load("glScissor");
-       glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf");
-       glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv");
-       glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri");
-       glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv");
-       glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D");
-       glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D");
-       glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer");
-       glad_glClear = (PFNGLCLEARPROC)load("glClear");
-       glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor");
-       glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil");
-       glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth");
-       glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
-       glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask");
-       glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask");
-       glad_glDisable = (PFNGLDISABLEPROC)load("glDisable");
-       glad_glEnable = (PFNGLENABLEPROC)load("glEnable");
-       glad_glFinish = (PFNGLFINISHPROC)load("glFinish");
-       glad_glFlush = (PFNGLFLUSHPROC)load("glFlush");
-       glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc");
-       glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp");
-       glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
-       glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
-       glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc");
-       glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref");
-       glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei");
-       glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer");
-       glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels");
-       glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv");
-       glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev");
-       glad_glGetError = (PFNGLGETERRORPROC)load("glGetError");
-       glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv");
-       glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv");
-       glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
-       glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage");
-       glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv");
-       glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv");
-       glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv");
-       glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv");
-       glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled");
-       glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange");
-       glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport");
-}
-static void load_GL_VERSION_1_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_1) return;
-       glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays");
-       glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements");
-       glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset");
-       glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D");
-       glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D");
-       glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D");
-       glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D");
-       glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D");
-       glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D");
-       glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture");
-       glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures");
-       glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures");
-       glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture");
-}
-static void load_GL_VERSION_1_2(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_2) return;
-       glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements");
-       glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D");
-       glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D");
-       glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D");
-}
-static void load_GL_VERSION_1_3(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_3) return;
-       glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture");
-       glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage");
-       glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D");
-       glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D");
-       glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D");
-       glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D");
-       glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D");
-       glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D");
-       glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage");
-}
-static void load_GL_VERSION_1_4(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_4) return;
-       glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate");
-       glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays");
-       glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements");
-       glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf");
-       glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv");
-       glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri");
-       glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv");
-       glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor");
-       glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation");
-}
-static void load_GL_VERSION_1_5(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_1_5) return;
-       glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries");
-       glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries");
-       glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery");
-       glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery");
-       glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery");
-       glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv");
-       glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv");
-       glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv");
-       glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer");
-       glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers");
-       glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers");
-       glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer");
-       glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData");
-       glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData");
-       glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData");
-       glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer");
-       glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer");
-       glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv");
-       glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv");
-}
-static void load_GL_VERSION_2_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_2_0) return;
-       glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate");
-       glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers");
-       glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate");
-       glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate");
-       glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate");
-       glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader");
-       glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation");
-       glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader");
-       glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram");
-       glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader");
-       glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram");
-       glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader");
-       glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader");
-       glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray");
-       glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray");
-       glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib");
-       glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform");
-       glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders");
-       glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation");
-       glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv");
-       glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog");
-       glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv");
-       glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog");
-       glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource");
-       glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation");
-       glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv");
-       glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv");
-       glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv");
-       glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv");
-       glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv");
-       glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv");
-       glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram");
-       glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader");
-       glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram");
-       glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource");
-       glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram");
-       glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f");
-       glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f");
-       glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f");
-       glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f");
-       glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i");
-       glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i");
-       glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i");
-       glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i");
-       glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv");
-       glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv");
-       glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv");
-       glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv");
-       glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv");
-       glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv");
-       glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv");
-       glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv");
-       glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv");
-       glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv");
-       glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv");
-       glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram");
-       glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d");
-       glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv");
-       glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f");
-       glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv");
-       glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s");
-       glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv");
-       glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d");
-       glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv");
-       glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f");
-       glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv");
-       glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s");
-       glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv");
-       glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d");
-       glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv");
-       glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f");
-       glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv");
-       glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s");
-       glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv");
-       glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv");
-       glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv");
-       glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv");
-       glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub");
-       glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv");
-       glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv");
-       glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv");
-       glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv");
-       glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d");
-       glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv");
-       glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f");
-       glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv");
-       glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv");
-       glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s");
-       glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv");
-       glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv");
-       glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv");
-       glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv");
-       glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer");
-}
-static void load_GL_VERSION_2_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_2_1) return;
-       glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv");
-       glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv");
-       glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv");
-       glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv");
-       glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv");
-       glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv");
-}
-static void load_GL_VERSION_3_0(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_0) return;
-       glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski");
-       glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-       glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei");
-       glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei");
-       glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi");
-       glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback");
-       glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings");
-       glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying");
-       glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor");
-       glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender");
-       glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender");
-       glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer");
-       glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv");
-       glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv");
-       glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i");
-       glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i");
-       glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i");
-       glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i");
-       glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui");
-       glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui");
-       glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui");
-       glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui");
-       glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv");
-       glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv");
-       glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv");
-       glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv");
-       glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv");
-       glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv");
-       glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv");
-       glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv");
-       glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv");
-       glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv");
-       glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv");
-       glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv");
-       glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv");
-       glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation");
-       glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation");
-       glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui");
-       glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui");
-       glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui");
-       glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui");
-       glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv");
-       glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv");
-       glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv");
-       glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv");
-       glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv");
-       glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv");
-       glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv");
-       glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv");
-       glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv");
-       glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv");
-       glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv");
-       glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi");
-       glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi");
-       glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
-       glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
-       glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
-       glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
-       glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
-       glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
-       glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
-       glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
-       glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
-       glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
-       glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
-       glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
-       glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
-       glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
-       glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
-       glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
-       glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
-       glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
-       glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
-       glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
-       glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange");
-       glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange");
-       glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
-       glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
-       glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
-       glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
-}
-static void load_GL_VERSION_3_1(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_1) return;
-       glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced");
-       glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced");
-       glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer");
-       glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex");
-       glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData");
-       glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
-       glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
-       glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
-       glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
-       glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
-       glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
-       glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-}
-static void load_GL_VERSION_3_2(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_2) return;
-       glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex");
-       glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex");
-       glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex");
-       glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex");
-       glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex");
-       glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync");
-       glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync");
-       glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync");
-       glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync");
-       glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync");
-       glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v");
-       glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv");
-       glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v");
-       glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v");
-       glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture");
-       glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
-       glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
-       glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
-       glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
-}
-static void load_GL_VERSION_3_3(GLADloadproc load) {
-       if(!GLAD_GL_VERSION_3_3) return;
-       glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed");
-       glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
-       glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
-       glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers");
-       glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler");
-       glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler");
-       glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri");
-       glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv");
-       glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf");
-       glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv");
-       glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv");
-       glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv");
-       glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv");
-       glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv");
-       glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv");
-       glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv");
-       glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter");
-       glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v");
-       glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v");
-       glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor");
-       glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui");
-       glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv");
-       glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui");
-       glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv");
-       glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui");
-       glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv");
-       glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui");
-       glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv");
-       glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui");
-       glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv");
-       glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui");
-       glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv");
-       glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui");
-       glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv");
-       glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui");
-       glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv");
-       glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui");
-       glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv");
-       glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui");
-       glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv");
-       glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui");
-       glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv");
-       glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui");
-       glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv");
-       glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui");
-       glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv");
-       glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui");
-       glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv");
-       glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui");
-       glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv");
-       glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui");
-       glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv");
-       glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui");
-       glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv");
-       glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui");
-       glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv");
-       glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui");
-       glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv");
-}
-static void load_GL_AMD_debug_output(GLADloadproc load) {
-       if(!GLAD_GL_AMD_debug_output) return;
-       glad_glDebugMessageEnableAMD = (PFNGLDEBUGMESSAGEENABLEAMDPROC)load("glDebugMessageEnableAMD");
-       glad_glDebugMessageInsertAMD = (PFNGLDEBUGMESSAGEINSERTAMDPROC)load("glDebugMessageInsertAMD");
-       glad_glDebugMessageCallbackAMD = (PFNGLDEBUGMESSAGECALLBACKAMDPROC)load("glDebugMessageCallbackAMD");
-       glad_glGetDebugMessageLogAMD = (PFNGLGETDEBUGMESSAGELOGAMDPROC)load("glGetDebugMessageLogAMD");
-}
-static void load_GL_ARB_ES2_compatibility(GLADloadproc load) {
-       if(!GLAD_GL_ARB_ES2_compatibility) return;
-       glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load("glReleaseShaderCompiler");
-       glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load("glShaderBinary");
-       glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load("glGetShaderPrecisionFormat");
-       glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load("glDepthRangef");
-       glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf");
-}
-static void load_GL_ARB_buffer_storage(GLADloadproc load) {
-       if(!GLAD_GL_ARB_buffer_storage) return;
-       glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC)load("glBufferStorage");
-}
-static void load_GL_ARB_debug_output(GLADloadproc load) {
-       if(!GLAD_GL_ARB_debug_output) return;
-       glad_glDebugMessageControlARB = (PFNGLDEBUGMESSAGECONTROLARBPROC)load("glDebugMessageControlARB");
-       glad_glDebugMessageInsertARB = (PFNGLDEBUGMESSAGEINSERTARBPROC)load("glDebugMessageInsertARB");
-       glad_glDebugMessageCallbackARB = (PFNGLDEBUGMESSAGECALLBACKARBPROC)load("glDebugMessageCallbackARB");
-       glad_glGetDebugMessageLogARB = (PFNGLGETDEBUGMESSAGELOGARBPROC)load("glGetDebugMessageLogARB");
-}
-static void load_GL_ARB_draw_buffers(GLADloadproc load) {
-       if(!GLAD_GL_ARB_draw_buffers) return;
-       glad_glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)load("glDrawBuffersARB");
-}
-static void load_GL_ARB_draw_buffers_blend(GLADloadproc load) {
-       if(!GLAD_GL_ARB_draw_buffers_blend) return;
-       glad_glBlendEquationiARB = (PFNGLBLENDEQUATIONIARBPROC)load("glBlendEquationiARB");
-       glad_glBlendEquationSeparateiARB = (PFNGLBLENDEQUATIONSEPARATEIARBPROC)load("glBlendEquationSeparateiARB");
-       glad_glBlendFunciARB = (PFNGLBLENDFUNCIARBPROC)load("glBlendFunciARB");
-       glad_glBlendFuncSeparateiARB = (PFNGLBLENDFUNCSEPARATEIARBPROC)load("glBlendFuncSeparateiARB");
-}
-static void load_GL_ARB_fragment_program(GLADloadproc load) {
-       if(!GLAD_GL_ARB_fragment_program) return;
-       glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)load("glProgramStringARB");
-       glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)load("glBindProgramARB");
-       glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)load("glDeleteProgramsARB");
-       glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)load("glGenProgramsARB");
-       glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)load("glProgramEnvParameter4dARB");
-       glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)load("glProgramEnvParameter4dvARB");
-       glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)load("glProgramEnvParameter4fARB");
-       glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)load("glProgramEnvParameter4fvARB");
-       glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)load("glProgramLocalParameter4dARB");
-       glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)load("glProgramLocalParameter4dvARB");
-       glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)load("glProgramLocalParameter4fARB");
-       glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)load("glProgramLocalParameter4fvARB");
-       glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)load("glGetProgramEnvParameterdvARB");
-       glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)load("glGetProgramEnvParameterfvARB");
-       glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)load("glGetProgramLocalParameterdvARB");
-       glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)load("glGetProgramLocalParameterfvARB");
-       glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)load("glGetProgramivARB");
-       glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)load("glGetProgramStringARB");
-       glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC)load("glIsProgramARB");
-}
-static void load_GL_ARB_framebuffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_framebuffer_object) return;
-       glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
-       glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
-       glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
-       glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
-       glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
-       glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
-       glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
-       glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
-       glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
-       glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
-       glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
-       glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
-       glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
-       glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
-       glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
-       glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
-       glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
-       glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
-       glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
-       glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
-}
-static void load_GL_ARB_multisample(GLADloadproc load) {
-       if(!GLAD_GL_ARB_multisample) return;
-       glad_glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)load("glSampleCoverageARB");
-}
-static void load_GL_ARB_sample_locations(GLADloadproc load) {
-       if(!GLAD_GL_ARB_sample_locations) return;
-       glad_glFramebufferSampleLocationsfvARB = (PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)load("glFramebufferSampleLocationsfvARB");
-       glad_glNamedFramebufferSampleLocationsfvARB = (PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC)load("glNamedFramebufferSampleLocationsfvARB");
-       glad_glEvaluateDepthValuesARB = (PFNGLEVALUATEDEPTHVALUESARBPROC)load("glEvaluateDepthValuesARB");
-}
-static void load_GL_ARB_texture_compression(GLADloadproc load) {
-       if(!GLAD_GL_ARB_texture_compression) return;
-       glad_glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)load("glCompressedTexImage3DARB");
-       glad_glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)load("glCompressedTexImage2DARB");
-       glad_glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)load("glCompressedTexImage1DARB");
-       glad_glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)load("glCompressedTexSubImage3DARB");
-       glad_glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)load("glCompressedTexSubImage2DARB");
-       glad_glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)load("glCompressedTexSubImage1DARB");
-       glad_glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)load("glGetCompressedTexImageARB");
-}
-static void load_GL_ARB_texture_multisample(GLADloadproc load) {
-       if(!GLAD_GL_ARB_texture_multisample) return;
-       glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
-       glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
-       glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
-       glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
-}
-static void load_GL_ARB_uniform_buffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_uniform_buffer_object) return;
-       glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
-       glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
-       glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
-       glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
-       glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
-       glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
-       glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
-       glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
-       glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
-       glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
-}
-static void load_GL_ARB_vertex_array_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_array_object) return;
-       glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
-       glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
-       glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
-       glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
-}
-static void load_GL_ARB_vertex_attrib_binding(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_attrib_binding) return;
-       glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load("glBindVertexBuffer");
-       glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load("glVertexAttribFormat");
-       glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load("glVertexAttribIFormat");
-       glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load("glVertexAttribLFormat");
-       glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load("glVertexAttribBinding");
-       glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load("glVertexBindingDivisor");
-}
-static void load_GL_ARB_vertex_buffer_object(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_buffer_object) return;
-       glad_glBindBufferARB = (PFNGLBINDBUFFERARBPROC)load("glBindBufferARB");
-       glad_glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)load("glDeleteBuffersARB");
-       glad_glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)load("glGenBuffersARB");
-       glad_glIsBufferARB = (PFNGLISBUFFERARBPROC)load("glIsBufferARB");
-       glad_glBufferDataARB = (PFNGLBUFFERDATAARBPROC)load("glBufferDataARB");
-       glad_glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)load("glBufferSubDataARB");
-       glad_glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)load("glGetBufferSubDataARB");
-       glad_glMapBufferARB = (PFNGLMAPBUFFERARBPROC)load("glMapBufferARB");
-       glad_glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)load("glUnmapBufferARB");
-       glad_glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)load("glGetBufferParameterivARB");
-       glad_glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)load("glGetBufferPointervARB");
-}
-static void load_GL_ARB_vertex_program(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_program) return;
-       glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)load("glVertexAttrib1dARB");
-       glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)load("glVertexAttrib1dvARB");
-       glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)load("glVertexAttrib1fARB");
-       glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)load("glVertexAttrib1fvARB");
-       glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)load("glVertexAttrib1sARB");
-       glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)load("glVertexAttrib1svARB");
-       glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)load("glVertexAttrib2dARB");
-       glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)load("glVertexAttrib2dvARB");
-       glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)load("glVertexAttrib2fARB");
-       glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)load("glVertexAttrib2fvARB");
-       glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)load("glVertexAttrib2sARB");
-       glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)load("glVertexAttrib2svARB");
-       glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)load("glVertexAttrib3dARB");
-       glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)load("glVertexAttrib3dvARB");
-       glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)load("glVertexAttrib3fARB");
-       glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)load("glVertexAttrib3fvARB");
-       glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)load("glVertexAttrib3sARB");
-       glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)load("glVertexAttrib3svARB");
-       glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)load("glVertexAttrib4NbvARB");
-       glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)load("glVertexAttrib4NivARB");
-       glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)load("glVertexAttrib4NsvARB");
-       glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)load("glVertexAttrib4NubARB");
-       glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)load("glVertexAttrib4NubvARB");
-       glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)load("glVertexAttrib4NuivARB");
-       glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)load("glVertexAttrib4NusvARB");
-       glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)load("glVertexAttrib4bvARB");
-       glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)load("glVertexAttrib4dARB");
-       glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)load("glVertexAttrib4dvARB");
-       glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)load("glVertexAttrib4fARB");
-       glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)load("glVertexAttrib4fvARB");
-       glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)load("glVertexAttrib4ivARB");
-       glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)load("glVertexAttrib4sARB");
-       glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)load("glVertexAttrib4svARB");
-       glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)load("glVertexAttrib4ubvARB");
-       glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)load("glVertexAttrib4uivARB");
-       glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)load("glVertexAttrib4usvARB");
-       glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)load("glVertexAttribPointerARB");
-       glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)load("glEnableVertexAttribArrayARB");
-       glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)load("glDisableVertexAttribArrayARB");
-       glad_glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)load("glProgramStringARB");
-       glad_glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)load("glBindProgramARB");
-       glad_glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)load("glDeleteProgramsARB");
-       glad_glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)load("glGenProgramsARB");
-       glad_glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)load("glProgramEnvParameter4dARB");
-       glad_glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)load("glProgramEnvParameter4dvARB");
-       glad_glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)load("glProgramEnvParameter4fARB");
-       glad_glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)load("glProgramEnvParameter4fvARB");
-       glad_glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)load("glProgramLocalParameter4dARB");
-       glad_glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)load("glProgramLocalParameter4dvARB");
-       glad_glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)load("glProgramLocalParameter4fARB");
-       glad_glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)load("glProgramLocalParameter4fvARB");
-       glad_glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)load("glGetProgramEnvParameterdvARB");
-       glad_glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)load("glGetProgramEnvParameterfvARB");
-       glad_glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)load("glGetProgramLocalParameterdvARB");
-       glad_glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)load("glGetProgramLocalParameterfvARB");
-       glad_glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)load("glGetProgramivARB");
-       glad_glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)load("glGetProgramStringARB");
-       glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)load("glGetVertexAttribdvARB");
-       glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)load("glGetVertexAttribfvARB");
-       glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)load("glGetVertexAttribivARB");
-       glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)load("glGetVertexAttribPointervARB");
-       glad_glIsProgramARB = (PFNGLISPROGRAMARBPROC)load("glIsProgramARB");
-}
-static void load_GL_ARB_vertex_shader(GLADloadproc load) {
-       if(!GLAD_GL_ARB_vertex_shader) return;
-       glad_glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)load("glVertexAttrib1fARB");
-       glad_glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)load("glVertexAttrib1sARB");
-       glad_glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)load("glVertexAttrib1dARB");
-       glad_glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)load("glVertexAttrib2fARB");
-       glad_glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)load("glVertexAttrib2sARB");
-       glad_glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)load("glVertexAttrib2dARB");
-       glad_glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)load("glVertexAttrib3fARB");
-       glad_glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)load("glVertexAttrib3sARB");
-       glad_glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)load("glVertexAttrib3dARB");
-       glad_glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)load("glVertexAttrib4fARB");
-       glad_glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)load("glVertexAttrib4sARB");
-       glad_glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)load("glVertexAttrib4dARB");
-       glad_glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)load("glVertexAttrib4NubARB");
-       glad_glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)load("glVertexAttrib1fvARB");
-       glad_glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)load("glVertexAttrib1svARB");
-       glad_glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)load("glVertexAttrib1dvARB");
-       glad_glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)load("glVertexAttrib2fvARB");
-       glad_glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)load("glVertexAttrib2svARB");
-       glad_glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)load("glVertexAttrib2dvARB");
-       glad_glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)load("glVertexAttrib3fvARB");
-       glad_glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)load("glVertexAttrib3svARB");
-       glad_glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)load("glVertexAttrib3dvARB");
-       glad_glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)load("glVertexAttrib4fvARB");
-       glad_glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)load("glVertexAttrib4svARB");
-       glad_glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)load("glVertexAttrib4dvARB");
-       glad_glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)load("glVertexAttrib4ivARB");
-       glad_glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)load("glVertexAttrib4bvARB");
-       glad_glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)load("glVertexAttrib4ubvARB");
-       glad_glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)load("glVertexAttrib4usvARB");
-       glad_glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)load("glVertexAttrib4uivARB");
-       glad_glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)load("glVertexAttrib4NbvARB");
-       glad_glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)load("glVertexAttrib4NsvARB");
-       glad_glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)load("glVertexAttrib4NivARB");
-       glad_glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)load("glVertexAttrib4NubvARB");
-       glad_glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)load("glVertexAttrib4NusvARB");
-       glad_glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)load("glVertexAttrib4NuivARB");
-       glad_glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)load("glVertexAttribPointerARB");
-       glad_glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)load("glEnableVertexAttribArrayARB");
-       glad_glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)load("glDisableVertexAttribArrayARB");
-       glad_glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)load("glBindAttribLocationARB");
-       glad_glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)load("glGetActiveAttribARB");
-       glad_glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)load("glGetAttribLocationARB");
-       glad_glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)load("glGetVertexAttribdvARB");
-       glad_glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)load("glGetVertexAttribfvARB");
-       glad_glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)load("glGetVertexAttribivARB");
-       glad_glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)load("glGetVertexAttribPointervARB");
-}
-static void load_GL_ATI_element_array(GLADloadproc load) {
-       if(!GLAD_GL_ATI_element_array) return;
-       glad_glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)load("glElementPointerATI");
-       glad_glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)load("glDrawElementArrayATI");
-       glad_glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)load("glDrawRangeElementArrayATI");
-}
-static void load_GL_ATI_fragment_shader(GLADloadproc load) {
-       if(!GLAD_GL_ATI_fragment_shader) return;
-       glad_glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)load("glGenFragmentShadersATI");
-       glad_glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)load("glBindFragmentShaderATI");
-       glad_glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)load("glDeleteFragmentShaderATI");
-       glad_glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)load("glBeginFragmentShaderATI");
-       glad_glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)load("glEndFragmentShaderATI");
-       glad_glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)load("glPassTexCoordATI");
-       glad_glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)load("glSampleMapATI");
-       glad_glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)load("glColorFragmentOp1ATI");
-       glad_glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)load("glColorFragmentOp2ATI");
-       glad_glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)load("glColorFragmentOp3ATI");
-       glad_glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)load("glAlphaFragmentOp1ATI");
-       glad_glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)load("glAlphaFragmentOp2ATI");
-       glad_glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)load("glAlphaFragmentOp3ATI");
-       glad_glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)load("glSetFragmentShaderConstantATI");
-}
-static void load_GL_ATI_vertex_array_object(GLADloadproc load) {
-       if(!GLAD_GL_ATI_vertex_array_object) return;
-       glad_glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)load("glNewObjectBufferATI");
-       glad_glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)load("glIsObjectBufferATI");
-       glad_glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)load("glUpdateObjectBufferATI");
-       glad_glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)load("glGetObjectBufferfvATI");
-       glad_glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)load("glGetObjectBufferivATI");
-       glad_glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)load("glFreeObjectBufferATI");
-       glad_glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)load("glArrayObjectATI");
-       glad_glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)load("glGetArrayObjectfvATI");
-       glad_glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)load("glGetArrayObjectivATI");
-       glad_glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)load("glVariantArrayObjectATI");
-       glad_glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)load("glGetVariantArrayObjectfvATI");
-       glad_glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)load("glGetVariantArrayObjectivATI");
-}
-static void load_GL_EXT_blend_color(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_color) return;
-       glad_glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)load("glBlendColorEXT");
-}
-static void load_GL_EXT_blend_equation_separate(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_equation_separate) return;
-       glad_glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)load("glBlendEquationSeparateEXT");
-}
-static void load_GL_EXT_blend_func_separate(GLADloadproc load) {
-       if(!GLAD_GL_EXT_blend_func_separate) return;
-       glad_glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)load("glBlendFuncSeparateEXT");
-}
-static void load_GL_EXT_debug_marker(GLADloadproc load) {
-       if(!GLAD_GL_EXT_debug_marker) return;
-       glad_glInsertEventMarkerEXT = (PFNGLINSERTEVENTMARKEREXTPROC)load("glInsertEventMarkerEXT");
-       glad_glPushGroupMarkerEXT = (PFNGLPUSHGROUPMARKEREXTPROC)load("glPushGroupMarkerEXT");
-       glad_glPopGroupMarkerEXT = (PFNGLPOPGROUPMARKEREXTPROC)load("glPopGroupMarkerEXT");
-}
-static void load_GL_EXT_framebuffer_blit(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_blit) return;
-       glad_glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)load("glBlitFramebufferEXT");
-}
-static void load_GL_EXT_framebuffer_multisample(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_multisample) return;
-       glad_glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)load("glRenderbufferStorageMultisampleEXT");
-}
-static void load_GL_EXT_framebuffer_object(GLADloadproc load) {
-       if(!GLAD_GL_EXT_framebuffer_object) return;
-       glad_glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)load("glIsRenderbufferEXT");
-       glad_glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)load("glBindRenderbufferEXT");
-       glad_glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)load("glDeleteRenderbuffersEXT");
-       glad_glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)load("glGenRenderbuffersEXT");
-       glad_glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)load("glRenderbufferStorageEXT");
-       glad_glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)load("glGetRenderbufferParameterivEXT");
-       glad_glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)load("glIsFramebufferEXT");
-       glad_glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)load("glBindFramebufferEXT");
-       glad_glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)load("glDeleteFramebuffersEXT");
-       glad_glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)load("glGenFramebuffersEXT");
-       glad_glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)load("glCheckFramebufferStatusEXT");
-       glad_glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)load("glFramebufferTexture1DEXT");
-       glad_glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)load("glFramebufferTexture2DEXT");
-       glad_glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)load("glFramebufferTexture3DEXT");
-       glad_glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)load("glFramebufferRenderbufferEXT");
-       glad_glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)load("glGetFramebufferAttachmentParameterivEXT");
-       glad_glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)load("glGenerateMipmapEXT");
-}
-static void load_GL_EXT_vertex_array(GLADloadproc load) {
-       if(!GLAD_GL_EXT_vertex_array) return;
-       glad_glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)load("glArrayElementEXT");
-       glad_glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)load("glColorPointerEXT");
-       glad_glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)load("glDrawArraysEXT");
-       glad_glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)load("glEdgeFlagPointerEXT");
-       glad_glGetPointervEXT = (PFNGLGETPOINTERVEXTPROC)load("glGetPointervEXT");
-       glad_glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)load("glIndexPointerEXT");
-       glad_glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)load("glNormalPointerEXT");
-       glad_glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)load("glTexCoordPointerEXT");
-       glad_glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)load("glVertexPointerEXT");
-}
-static void load_GL_EXT_vertex_shader(GLADloadproc load) {
-       if(!GLAD_GL_EXT_vertex_shader) return;
-       glad_glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)load("glBeginVertexShaderEXT");
-       glad_glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)load("glEndVertexShaderEXT");
-       glad_glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)load("glBindVertexShaderEXT");
-       glad_glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)load("glGenVertexShadersEXT");
-       glad_glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)load("glDeleteVertexShaderEXT");
-       glad_glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)load("glShaderOp1EXT");
-       glad_glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)load("glShaderOp2EXT");
-       glad_glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)load("glShaderOp3EXT");
-       glad_glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)load("glSwizzleEXT");
-       glad_glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)load("glWriteMaskEXT");
-       glad_glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)load("glInsertComponentEXT");
-       glad_glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)load("glExtractComponentEXT");
-       glad_glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)load("glGenSymbolsEXT");
-       glad_glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)load("glSetInvariantEXT");
-       glad_glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)load("glSetLocalConstantEXT");
-       glad_glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)load("glVariantbvEXT");
-       glad_glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)load("glVariantsvEXT");
-       glad_glVariantivEXT = (PFNGLVARIANTIVEXTPROC)load("glVariantivEXT");
-       glad_glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)load("glVariantfvEXT");
-       glad_glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)load("glVariantdvEXT");
-       glad_glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)load("glVariantubvEXT");
-       glad_glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)load("glVariantusvEXT");
-       glad_glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)load("glVariantuivEXT");
-       glad_glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)load("glVariantPointerEXT");
-       glad_glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)load("glEnableVariantClientStateEXT");
-       glad_glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)load("glDisableVariantClientStateEXT");
-       glad_glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)load("glBindLightParameterEXT");
-       glad_glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)load("glBindMaterialParameterEXT");
-       glad_glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)load("glBindTexGenParameterEXT");
-       glad_glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)load("glBindTextureUnitParameterEXT");
-       glad_glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)load("glBindParameterEXT");
-       glad_glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)load("glIsVariantEnabledEXT");
-       glad_glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)load("glGetVariantBooleanvEXT");
-       glad_glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)load("glGetVariantIntegervEXT");
-       glad_glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)load("glGetVariantFloatvEXT");
-       glad_glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)load("glGetVariantPointervEXT");
-       glad_glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)load("glGetInvariantBooleanvEXT");
-       glad_glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)load("glGetInvariantIntegervEXT");
-       glad_glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)load("glGetInvariantFloatvEXT");
-       glad_glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)load("glGetLocalConstantBooleanvEXT");
-       glad_glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)load("glGetLocalConstantIntegervEXT");
-       glad_glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)load("glGetLocalConstantFloatvEXT");
-}
-static int find_extensionsGL(void) {
-       if (!get_exts()) return 0;
-       GLAD_GL_AMD_debug_output = has_ext("GL_AMD_debug_output");
-       GLAD_GL_AMD_query_buffer_object = has_ext("GL_AMD_query_buffer_object");
-       GLAD_GL_ARB_ES2_compatibility = has_ext("GL_ARB_ES2_compatibility");
-       GLAD_GL_ARB_ES3_compatibility = has_ext("GL_ARB_ES3_compatibility");
-       GLAD_GL_ARB_buffer_storage = has_ext("GL_ARB_buffer_storage");
-       GLAD_GL_ARB_compatibility = has_ext("GL_ARB_compatibility");
-       GLAD_GL_ARB_compressed_texture_pixel_storage = has_ext("GL_ARB_compressed_texture_pixel_storage");
-       GLAD_GL_ARB_debug_output = has_ext("GL_ARB_debug_output");
-       GLAD_GL_ARB_depth_buffer_float = has_ext("GL_ARB_depth_buffer_float");
-       GLAD_GL_ARB_depth_clamp = has_ext("GL_ARB_depth_clamp");
-       GLAD_GL_ARB_depth_texture = has_ext("GL_ARB_depth_texture");
-       GLAD_GL_ARB_draw_buffers = has_ext("GL_ARB_draw_buffers");
-       GLAD_GL_ARB_draw_buffers_blend = has_ext("GL_ARB_draw_buffers_blend");
-       GLAD_GL_ARB_explicit_attrib_location = has_ext("GL_ARB_explicit_attrib_location");
-       GLAD_GL_ARB_explicit_uniform_location = has_ext("GL_ARB_explicit_uniform_location");
-       GLAD_GL_ARB_fragment_program = has_ext("GL_ARB_fragment_program");
-       GLAD_GL_ARB_fragment_shader = has_ext("GL_ARB_fragment_shader");
-       GLAD_GL_ARB_framebuffer_object = has_ext("GL_ARB_framebuffer_object");
-       GLAD_GL_ARB_framebuffer_sRGB = has_ext("GL_ARB_framebuffer_sRGB");
-       GLAD_GL_ARB_multisample = has_ext("GL_ARB_multisample");
-       GLAD_GL_ARB_sample_locations = has_ext("GL_ARB_sample_locations");
-       GLAD_GL_ARB_texture_compression = has_ext("GL_ARB_texture_compression");
-       GLAD_GL_ARB_texture_float = has_ext("GL_ARB_texture_float");
-       GLAD_GL_ARB_texture_multisample = has_ext("GL_ARB_texture_multisample");
-       GLAD_GL_ARB_texture_non_power_of_two = has_ext("GL_ARB_texture_non_power_of_two");
-       GLAD_GL_ARB_texture_rg = has_ext("GL_ARB_texture_rg");
-       GLAD_GL_ARB_texture_swizzle = has_ext("GL_ARB_texture_swizzle");
-       GLAD_GL_ARB_uniform_buffer_object = has_ext("GL_ARB_uniform_buffer_object");
-       GLAD_GL_ARB_vertex_array_object = has_ext("GL_ARB_vertex_array_object");
-       GLAD_GL_ARB_vertex_attrib_binding = has_ext("GL_ARB_vertex_attrib_binding");
-       GLAD_GL_ARB_vertex_buffer_object = has_ext("GL_ARB_vertex_buffer_object");
-       GLAD_GL_ARB_vertex_program = has_ext("GL_ARB_vertex_program");
-       GLAD_GL_ARB_vertex_shader = has_ext("GL_ARB_vertex_shader");
-       GLAD_GL_ATI_element_array = has_ext("GL_ATI_element_array");
-       GLAD_GL_ATI_fragment_shader = has_ext("GL_ATI_fragment_shader");
-       GLAD_GL_ATI_vertex_array_object = has_ext("GL_ATI_vertex_array_object");
-       GLAD_GL_EXT_blend_color = has_ext("GL_EXT_blend_color");
-       GLAD_GL_EXT_blend_equation_separate = has_ext("GL_EXT_blend_equation_separate");
-       GLAD_GL_EXT_blend_func_separate = has_ext("GL_EXT_blend_func_separate");
-       GLAD_GL_EXT_debug_marker = has_ext("GL_EXT_debug_marker");
-       GLAD_GL_EXT_framebuffer_blit = has_ext("GL_EXT_framebuffer_blit");
-       GLAD_GL_EXT_framebuffer_multisample = has_ext("GL_EXT_framebuffer_multisample");
-       GLAD_GL_EXT_framebuffer_multisample_blit_scaled = has_ext("GL_EXT_framebuffer_multisample_blit_scaled");
-       GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object");
-       GLAD_GL_EXT_framebuffer_sRGB = has_ext("GL_EXT_framebuffer_sRGB");
-       GLAD_GL_EXT_index_array_formats = has_ext("GL_EXT_index_array_formats");
-       GLAD_GL_EXT_texture = has_ext("GL_EXT_texture");
-       GLAD_GL_EXT_texture_compression_s3tc = has_ext("GL_EXT_texture_compression_s3tc");
-       GLAD_GL_EXT_texture_sRGB = has_ext("GL_EXT_texture_sRGB");
-       GLAD_GL_EXT_texture_swizzle = has_ext("GL_EXT_texture_swizzle");
-       GLAD_GL_EXT_vertex_array = has_ext("GL_EXT_vertex_array");
-       GLAD_GL_EXT_vertex_shader = has_ext("GL_EXT_vertex_shader");
-       free_exts();
-       return 1;
-}
-
-static void find_coreGL(void) {
-
-    /* Thank you @elmindreda
-     * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176
-     * https://github.com/glfw/glfw/blob/master/src/context.c#L36
-     */
-    int i, major, minor;
-
-    const char* version;
-    const char* prefixes[] = {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-
-    version = (const char*) glGetString(GL_VERSION);
-    if (!version) return;
-
-    for (i = 0;  prefixes[i];  i++) {
-        const size_t length = strlen(prefixes[i]);
-        if (strncmp(version, prefixes[i], length) == 0) {
-            version += length;
-            break;
-        }
-    }
-
-/* PR #18 */
-#ifdef _MSC_VER
-    sscanf_s(version, "%d.%d", &major, &minor);
-#else
-    sscanf(version, "%d.%d", &major, &minor);
-#endif
-
-    GLVersion.major = major; GLVersion.minor = minor;
-    max_loaded_major = major; max_loaded_minor = minor;
-       GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-       GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-       GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
-       GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
-       GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
-       GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
-       GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
-       GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
-       GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
-       GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
-       GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
-       GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
-       if (GLVersion.major > 3 || (GLVersion.major >= 3 && GLVersion.minor >= 3)) {
-               max_loaded_major = 3;
-               max_loaded_minor = 3;
-       }
-}
-
-int gladLoadGLLoader(GLADloadproc load) {
-       GLVersion.major = 0; GLVersion.minor = 0;
-       glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
-       if(glGetString == NULL) return 0;
-       if(glGetString(GL_VERSION) == NULL) return 0;
-       find_coreGL();
-       load_GL_VERSION_1_0(load);
-       load_GL_VERSION_1_1(load);
-       load_GL_VERSION_1_2(load);
-       load_GL_VERSION_1_3(load);
-       load_GL_VERSION_1_4(load);
-       load_GL_VERSION_1_5(load);
-       load_GL_VERSION_2_0(load);
-       load_GL_VERSION_2_1(load);
-       load_GL_VERSION_3_0(load);
-       load_GL_VERSION_3_1(load);
-       load_GL_VERSION_3_2(load);
-       load_GL_VERSION_3_3(load);
-
-       if (!find_extensionsGL()) return 0;
-       load_GL_AMD_debug_output(load);
-       load_GL_ARB_ES2_compatibility(load);
-       load_GL_ARB_buffer_storage(load);
-       load_GL_ARB_debug_output(load);
-       load_GL_ARB_draw_buffers(load);
-       load_GL_ARB_draw_buffers_blend(load);
-       load_GL_ARB_fragment_program(load);
-       load_GL_ARB_framebuffer_object(load);
-       load_GL_ARB_multisample(load);
-       load_GL_ARB_sample_locations(load);
-       load_GL_ARB_texture_compression(load);
-       load_GL_ARB_texture_multisample(load);
-       load_GL_ARB_uniform_buffer_object(load);
-       load_GL_ARB_vertex_array_object(load);
-       load_GL_ARB_vertex_attrib_binding(load);
-       load_GL_ARB_vertex_buffer_object(load);
-       load_GL_ARB_vertex_program(load);
-       load_GL_ARB_vertex_shader(load);
-       load_GL_ATI_element_array(load);
-       load_GL_ATI_fragment_shader(load);
-       load_GL_ATI_vertex_array_object(load);
-       load_GL_EXT_blend_color(load);
-       load_GL_EXT_blend_equation_separate(load);
-       load_GL_EXT_blend_func_separate(load);
-       load_GL_EXT_debug_marker(load);
-       load_GL_EXT_framebuffer_blit(load);
-       load_GL_EXT_framebuffer_multisample(load);
-       load_GL_EXT_framebuffer_object(load);
-       load_GL_EXT_vertex_array(load);
-       load_GL_EXT_vertex_shader(load);
-       return GLVersion.major != 0 || GLVersion.minor != 0;
-}
-
-#endif  // GLAD_IMPLEMENTATION
diff --git a/raylib_pi4_test/external/glfw/.mailmap b/raylib_pi4_test/external/glfw/.mailmap
deleted file mode 100644 (file)
index 96d8a9b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-Camilla Löwy <elmindreda@glfw.org> <elmindreda@users.sourceforge.net>
-Camilla Löwy <elmindreda@glfw.org> <elmindreda@elmindreda.org>
-Camilla Löwy <elmindreda@glfw.org>
-
-Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
-
-Marcus Geelnard <m@bitsnbites.eu> <marcus256@users.sourceforge.net>
-Marcus Geelnard <m@bitsnbites.eu> <marcus@geelnards-pc.(none)>
-Marcus Geelnard <m@bitsnbites.eu>
-
diff --git a/raylib_pi4_test/external/glfw/CMake/GenerateMappings.cmake b/raylib_pi4_test/external/glfw/CMake/GenerateMappings.cmake
deleted file mode 100644 (file)
index 7a88e3d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-# Usage:
-# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
-
-set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
-set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
-set(template_path "${CMAKE_ARGV3}")
-set(target_path "${CMAKE_ARGV4}")
-
-if (NOT EXISTS "${template_path}")
-    message(FATAL_ERROR "Failed to find template file ${template_path}")
-endif()
-
-file(DOWNLOAD "${source_url}" "${source_path}"
-     STATUS download_status
-     TLS_VERIFY on)
-
-list(GET download_status 0 status_code)
-list(GET download_status 1 status_message)
-
-if (status_code)
-    message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
-endif()
-
-file(STRINGS "${source_path}" lines)
-foreach(line ${lines})
-    if ("${line}" MATCHES "^[0-9a-fA-F].*$")
-        set(GLFW_GAMEPAD_MAPPINGS "${GLFW_GAMEPAD_MAPPINGS}\"${line}\",\n")
-    endif()
-endforeach()
-
-configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
-file(REMOVE "${source_path}")
-
diff --git a/raylib_pi4_test/external/glfw/CMake/Info.plist.in b/raylib_pi4_test/external/glfw/CMake/Info.plist.in
deleted file mode 100644 (file)
index 684ad79..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
-       <key>CFBundleGetInfoString</key>
-       <string>${MACOSX_BUNDLE_INFO_STRING}</string>
-       <key>CFBundleIconFile</key>
-       <string>${MACOSX_BUNDLE_ICON_FILE}</string>
-       <key>CFBundleIdentifier</key>
-       <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundleLongVersionString</key>
-       <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
-       <key>CFBundleName</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
-       <key>CFBundlePackageType</key>
-       <string>APPL</string>
-       <key>CFBundleShortVersionString</key>
-       <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
-       <key>CSResourcesFileMapped</key>
-       <true/>
-       <key>LSRequiresCarbon</key>
-       <true/>
-       <key>NSHumanReadableCopyright</key>
-       <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
-       <key>NSHighResolutionCapable</key>
-       <true/>
-</dict>
-</plist>
diff --git a/raylib_pi4_test/external/glfw/CMake/MacOSXBundleInfo.plist.in b/raylib_pi4_test/external/glfw/CMake/MacOSXBundleInfo.plist.in
deleted file mode 100644 (file)
index 684ad79..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-       <key>CFBundleDevelopmentRegion</key>
-       <string>English</string>
-       <key>CFBundleExecutable</key>
-       <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
-       <key>CFBundleGetInfoString</key>
-       <string>${MACOSX_BUNDLE_INFO_STRING}</string>
-       <key>CFBundleIconFile</key>
-       <string>${MACOSX_BUNDLE_ICON_FILE}</string>
-       <key>CFBundleIdentifier</key>
-       <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
-       <key>CFBundleInfoDictionaryVersion</key>
-       <string>6.0</string>
-       <key>CFBundleLongVersionString</key>
-       <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
-       <key>CFBundleName</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
-       <key>CFBundlePackageType</key>
-       <string>APPL</string>
-       <key>CFBundleShortVersionString</key>
-       <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
-       <key>CFBundleSignature</key>
-       <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
-       <key>CSResourcesFileMapped</key>
-       <true/>
-       <key>LSRequiresCarbon</key>
-       <true/>
-       <key>NSHumanReadableCopyright</key>
-       <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
-       <key>NSHighResolutionCapable</key>
-       <true/>
-</dict>
-</plist>
diff --git a/raylib_pi4_test/external/glfw/CMake/cmake_uninstall.cmake.in b/raylib_pi4_test/external/glfw/CMake/cmake_uninstall.cmake.in
deleted file mode 100644 (file)
index 5ecc476..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-
-if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt")
-    message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"")
-endif()
-
-file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
-
-foreach (file ${files})
-  message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
-  if (EXISTS "$ENV{DESTDIR}${file}")
-    exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
-                 OUTPUT_VARIABLE rm_out
-                 RETURN_VALUE rm_retval)
-    if (NOT "${rm_retval}" STREQUAL 0)
-      MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
-    endif()
-  elseif (IS_SYMLINK "$ENV{DESTDIR}${file}")
-    EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
-                 OUTPUT_VARIABLE rm_out
-                 RETURN_VALUE rm_retval)
-    if (NOT "${rm_retval}" STREQUAL 0)
-      message(FATAL_ERROR "Problem when removing symlink \"$ENV{DESTDIR}${file}\"")
-    endif()
-  else()
-    message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
-  endif()
-endforeach()
-
diff --git a/raylib_pi4_test/external/glfw/CMake/glfw3.pc.in b/raylib_pi4_test/external/glfw/CMake/glfw3.pc.in
deleted file mode 100644 (file)
index f74298d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
-libdir=@CMAKE_INSTALL_FULL_LIBDIR@
-
-Name: GLFW
-Description: A multi-platform library for OpenGL, window and input
-Version: @GLFW_VERSION@
-URL: https://www.glfw.org/
-Requires.private: @GLFW_PKG_DEPS@
-Libs: -L${libdir} -l@GLFW_LIB_NAME@
-Libs.private: @GLFW_PKG_LIBS@
-Cflags: -I${includedir}
diff --git a/raylib_pi4_test/external/glfw/CMake/glfw3Config.cmake.in b/raylib_pi4_test/external/glfw/CMake/glfw3Config.cmake.in
deleted file mode 100644 (file)
index 4a13a88..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-include(CMakeFindDependencyMacro)
-find_dependency(Threads)
-include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")
diff --git a/raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32-clang.cmake b/raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32-clang.cmake
deleted file mode 100644 (file)
index 8726b23..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 32-bit MinGW-w64 Clang
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "i686-w64-mingw32-clang")
-SET(CMAKE_CXX_COMPILER   "i686-w64-mingw32-clang++")
-SET(CMAKE_RC_COMPILER    "i686-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "i686-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32.cmake b/raylib_pi4_test/external/glfw/CMake/i686-w64-mingw32.cmake
deleted file mode 100644 (file)
index 2ca4dcd..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 32-bit MinGW-w64 GCC
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "i686-w64-mingw32-gcc")
-SET(CMAKE_CXX_COMPILER   "i686-w64-mingw32-g++")
-SET(CMAKE_RC_COMPILER    "i686-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "i686-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/i686-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib_pi4_test/external/glfw/CMake/modules/FindEpollShim.cmake b/raylib_pi4_test/external/glfw/CMake/modules/FindEpollShim.cmake
deleted file mode 100644 (file)
index 2facb41..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# Find EpollShim
-# Once done, this will define
-#
-#   EPOLLSHIM_FOUND - System has EpollShim
-#   EPOLLSHIM_INCLUDE_DIRS - The EpollShim include directories
-#   EPOLLSHIM_LIBRARIES - The libraries needed to use EpollShim
-
-find_path(EPOLLSHIM_INCLUDE_DIRS NAMES sys/epoll.h sys/timerfd.h HINTS /usr/local/include/libepoll-shim)
-find_library(EPOLLSHIM_LIBRARIES NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
-
-if (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
-       set(EPOLLSHIM_FOUND TRUE)
-endif (EPOLLSHIM_INCLUDE_DIRS AND EPOLLSHIM_LIBRARIES)
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(EPOLLSHIM DEFAULT_MSG EPOLLSHIM_LIBRARIES EPOLLSHIM_INCLUDE_DIRS)
-mark_as_advanced(EPOLLSHIM_INCLUDE_DIRS EPOLLSHIM_LIBRARIES)
diff --git a/raylib_pi4_test/external/glfw/CMake/modules/FindOSMesa.cmake b/raylib_pi4_test/external/glfw/CMake/modules/FindOSMesa.cmake
deleted file mode 100644 (file)
index 3194bd9..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# Try to find OSMesa on a Unix system
-#
-# This will define:
-#
-#   OSMESA_LIBRARIES   - Link these to use OSMesa
-#   OSMESA_INCLUDE_DIR - Include directory for OSMesa
-#
-# Copyright (c) 2014 Brandon Schaefer <brandon.schaefer@canonical.com>
-
-if (NOT WIN32)
-
-  find_package (PkgConfig)
-  pkg_check_modules (PKG_OSMESA QUIET osmesa)
-
-  set (OSMESA_INCLUDE_DIR ${PKG_OSMESA_INCLUDE_DIRS})
-  set (OSMESA_LIBRARIES   ${PKG_OSMESA_LIBRARIES})
-
-endif ()
diff --git a/raylib_pi4_test/external/glfw/CMake/modules/FindWaylandProtocols.cmake b/raylib_pi4_test/external/glfw/CMake/modules/FindWaylandProtocols.cmake
deleted file mode 100644 (file)
index 8eb83f2..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-find_package(PkgConfig)
-
-pkg_check_modules(WaylandProtocols QUIET wayland-protocols>=${WaylandProtocols_FIND_VERSION})
-
-execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=pkgdatadir wayland-protocols
-                OUTPUT_VARIABLE WaylandProtocols_PKGDATADIR
-                RESULT_VARIABLE _pkgconfig_failed)
-if (_pkgconfig_failed)
-    message(FATAL_ERROR "Missing wayland-protocols pkgdatadir")
-endif()
-
-string(REGEX REPLACE "[\r\n]" "" WaylandProtocols_PKGDATADIR "${WaylandProtocols_PKGDATADIR}")
-
-find_package_handle_standard_args(WaylandProtocols
-    FOUND_VAR
-        WaylandProtocols_FOUND
-    REQUIRED_VARS
-        WaylandProtocols_PKGDATADIR
-    VERSION_VAR
-        WaylandProtocols_VERSION
-    HANDLE_COMPONENTS
-)
-
-set(WAYLAND_PROTOCOLS_FOUND ${WaylandProtocols_FOUND})
-set(WAYLAND_PROTOCOLS_PKGDATADIR ${WaylandProtocols_PKGDATADIR})
-set(WAYLAND_PROTOCOLS_VERSION ${WaylandProtocols_VERSION})
diff --git a/raylib_pi4_test/external/glfw/CMake/modules/FindXKBCommon.cmake b/raylib_pi4_test/external/glfw/CMake/modules/FindXKBCommon.cmake
deleted file mode 100644 (file)
index 0f571ee..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-# - Try to find XKBCommon
-# Once done, this will define
-#
-#   XKBCOMMON_FOUND - System has XKBCommon
-#   XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
-#   XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
-#   XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon
-
-find_package(PkgConfig)
-pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
-set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})
-
-find_path(XKBCOMMON_INCLUDE_DIR
-    NAMES xkbcommon/xkbcommon.h
-    HINTS ${PC_XKBCOMMON_INCLUDE_DIR} ${PC_XKBCOMMON_INCLUDE_DIRS}
-)
-
-find_library(XKBCOMMON_LIBRARY
-    NAMES xkbcommon
-    HINTS ${PC_XKBCOMMON_LIBRARY} ${PC_XKBCOMMON_LIBRARY_DIRS}
-)
-
-set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY})
-set(XKBCOMMON_LIBRARY_DIRS ${XKBCOMMON_LIBRARY_DIRS})
-set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(XKBCommon DEFAULT_MSG
-    XKBCOMMON_LIBRARY
-    XKBCOMMON_INCLUDE_DIR
-)
-
-mark_as_advanced(XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR)
-
diff --git a/raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake b/raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32-clang.cmake
deleted file mode 100644 (file)
index 60f7914..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 64-bit MinGW-w64 Clang
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "x86_64-w64-mingw32-clang")
-SET(CMAKE_CXX_COMPILER   "x86_64-w64-mingw32-clang++")
-SET(CMAKE_RC_COMPILER    "x86_64-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "x86_64-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32.cmake b/raylib_pi4_test/external/glfw/CMake/x86_64-w64-mingw32.cmake
deleted file mode 100644 (file)
index 063e845..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Define the environment for cross-compiling with 64-bit MinGW-w64 GCC
-SET(CMAKE_SYSTEM_NAME    Windows) # Target system name
-SET(CMAKE_SYSTEM_VERSION 1)
-SET(CMAKE_C_COMPILER     "x86_64-w64-mingw32-gcc")
-SET(CMAKE_CXX_COMPILER   "x86_64-w64-mingw32-g++")
-SET(CMAKE_RC_COMPILER    "x86_64-w64-mingw32-windres")
-SET(CMAKE_RANLIB         "x86_64-w64-mingw32-ranlib")
-
-# Configure the behaviour of the find commands
-SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32")
-SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/raylib_pi4_test/external/glfw/CMakeLists.txt b/raylib_pi4_test/external/glfw/CMakeLists.txt
deleted file mode 100644 (file)
index 59ba5a6..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-cmake_minimum_required(VERSION 3.1...3.17 FATAL_ERROR)
-
-project(GLFW VERSION 3.4.0 LANGUAGES C)
-
-set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
-
-if (POLICY CMP0054)
-    cmake_policy(SET CMP0054 NEW)
-endif()
-
-if (POLICY CMP0069)
-    cmake_policy(SET CMP0069 NEW)
-endif()
-
-if (POLICY CMP0077)
-    cmake_policy(SET CMP0077 NEW)
-endif()
-
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-
-if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
-    set(GLFW_STANDALONE TRUE)
-endif()
-
-option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
-option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
-option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
-option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
-option(GLFW_INSTALL "Generate installation target" ON)
-option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
-
-include(GNUInstallDirs)
-include(CMakeDependentOption)
-
-cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
-                       "UNIX" OFF)
-cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
-                       "WIN32" OFF)
-cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
-                       "UNIX;NOT APPLE" OFF)
-cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
-                       "MSVC" OFF)
-
-if (BUILD_SHARED_LIBS)
-    set(_GLFW_BUILD_DLL 1)
-endif()
-
-if (BUILD_SHARED_LIBS AND UNIX)
-    # On Unix-like systems, shared libraries can use the soname system.
-    set(GLFW_LIB_NAME glfw)
-else()
-    set(GLFW_LIB_NAME glfw3)
-endif()
-
-if (GLFW_VULKAN_STATIC)
-    if (BUILD_SHARED_LIBS)
-        # If you absolutely must do this, remove this line and add the Vulkan
-        # loader static library via the CMAKE_SHARED_LINKER_FLAGS
-        message(FATAL_ERROR "You are trying to link the Vulkan loader static library into the GLFW shared library")
-    endif()
-    set(_GLFW_VULKAN_STATIC 1)
-endif()
-
-list(APPEND CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules")
-
-find_package(Threads REQUIRED)
-
-if (GLFW_BUILD_DOCS)
-    set(DOXYGEN_SKIP_DOT TRUE)
-    find_package(Doxygen)
-endif()
-
-#--------------------------------------------------------------------
-# Set compiler specific flags
-#--------------------------------------------------------------------
-if (MSVC)
-    if (MSVC90)
-        # Workaround for VS 2008 not shipping with the DirectX 9 SDK
-        include(CheckIncludeFile)
-        check_include_file(dinput.h DINPUT_H_FOUND)
-        if (NOT DINPUT_H_FOUND)
-            message(FATAL_ERROR "DirectX 9 headers not found; install DirectX 9 SDK")
-        endif()
-        # Workaround for VS 2008 not shipping with stdint.h
-        list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/vs2008")
-    endif()
-
-    if (NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
-        foreach (flag CMAKE_C_FLAGS
-                      CMAKE_C_FLAGS_DEBUG
-                      CMAKE_C_FLAGS_RELEASE
-                      CMAKE_C_FLAGS_MINSIZEREL
-                      CMAKE_C_FLAGS_RELWITHDEBINFO)
-
-            if (${flag} MATCHES "/MD")
-                string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
-            endif()
-            if (${flag} MATCHES "/MDd")
-                string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
-            endif()
-
-        endforeach()
-    endif()
-endif()
-
-if (MINGW)
-    # Workaround for legacy MinGW not providing XInput and DirectInput
-    include(CheckIncludeFile)
-
-    check_include_file(dinput.h DINPUT_H_FOUND)
-    check_include_file(xinput.h XINPUT_H_FOUND)
-    if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND)
-        list(APPEND glfw_INCLUDE_DIRS "${GLFW_SOURCE_DIR}/deps/mingw")
-    endif()
-
-    # Enable link-time exploit mitigation features enabled by default on MSVC
-    include(CheckCCompilerFlag)
-
-    # Compatibility with data execution prevention (DEP)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
-    check_c_compiler_flag("" _GLFW_HAS_DEP)
-    if (_GLFW_HAS_DEP)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-
-    # Compatibility with address space layout randomization (ASLR)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
-    check_c_compiler_flag("" _GLFW_HAS_ASLR)
-    if (_GLFW_HAS_ASLR)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-
-    # Compatibility with 64-bit address space layout randomization (ASLR)
-    set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va")
-    check_c_compiler_flag("" _GLFW_HAS_64ASLR)
-    if (_GLFW_HAS_64ASLR)
-        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--high-entropy-va ${CMAKE_SHARED_LINKER_FLAGS}")
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Detect and select backend APIs
-#--------------------------------------------------------------------
-if (GLFW_USE_WAYLAND)
-    set(_GLFW_WAYLAND 1)
-    message(STATUS "Using Wayland for window creation")
-elseif (GLFW_USE_OSMESA)
-    set(_GLFW_OSMESA 1)
-    message(STATUS "Using OSMesa for headless context creation")
-elseif (WIN32)
-    set(_GLFW_WIN32 1)
-    message(STATUS "Using Win32 for window creation")
-elseif (APPLE)
-    set(_GLFW_COCOA 1)
-    message(STATUS "Using Cocoa for window creation")
-elseif (UNIX)
-    set(_GLFW_X11 1)
-    message(STATUS "Using X11 for window creation")
-else()
-    message(FATAL_ERROR "No supported platform was detected")
-endif()
-
-#--------------------------------------------------------------------
-# Find and add Unix math and time libraries
-#--------------------------------------------------------------------
-if (UNIX AND NOT APPLE)
-    find_library(RT_LIBRARY rt)
-    mark_as_advanced(RT_LIBRARY)
-    if (RT_LIBRARY)
-        list(APPEND glfw_LIBRARIES "${RT_LIBRARY}")
-        list(APPEND glfw_PKG_LIBS "-lrt")
-    endif()
-
-    find_library(MATH_LIBRARY m)
-    mark_as_advanced(MATH_LIBRARY)
-    if (MATH_LIBRARY)
-        list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}")
-        list(APPEND glfw_PKG_LIBS "-lm")
-    endif()
-
-    if (CMAKE_DL_LIBS)
-        list(APPEND glfw_LIBRARIES "${CMAKE_DL_LIBS}")
-        list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}")
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use Win32 for window creation
-#--------------------------------------------------------------------
-if (_GLFW_WIN32)
-
-    list(APPEND glfw_PKG_LIBS "-lgdi32")
-
-    if (GLFW_USE_HYBRID_HPG)
-        set(_GLFW_USE_HYBRID_HPG 1)
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use X11 for window creation
-#--------------------------------------------------------------------
-if (_GLFW_X11)
-
-    find_package(X11 REQUIRED)
-
-    list(APPEND glfw_PKG_DEPS "x11")
-
-    # Set up library and include paths
-    list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
-    list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
-
-    # Check for XRandR (modern resolution switching and gamma control)
-    if (NOT X11_Xrandr_INCLUDE_PATH)
-        message(FATAL_ERROR "RandR headers not found; install libxrandr development package")
-    endif()
-
-    # Check for Xinerama (legacy multi-monitor support)
-    if (NOT X11_Xinerama_INCLUDE_PATH)
-        message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package")
-    endif()
-
-    # Check for Xkb (X keyboard extension)
-    if (NOT X11_Xkb_INCLUDE_PATH)
-        message(FATAL_ERROR "XKB headers not found; install X11 development package")
-    endif()
-
-    # Check for Xcursor (cursor creation from RGBA images)
-    if (NOT X11_Xcursor_INCLUDE_PATH)
-        message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package")
-    endif()
-
-    # Check for XInput (modern HID input)
-    if (NOT X11_Xi_INCLUDE_PATH)
-        message(FATAL_ERROR "XInput headers not found; install libxi development package")
-    endif()
-    
-    # Check for X Shape (custom window input shape)
-    if (NOT X11_Xshape_INCLUDE_PATH)
-        message(FATAL_ERROR "X Shape headers not found; install libxext development package")
-    endif()
-
-    list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
-                                  "${X11_Xinerama_INCLUDE_PATH}"
-                                  "${X11_Xkb_INCLUDE_PATH}"
-                                  "${X11_Xcursor_INCLUDE_PATH}"
-                                  "${X11_Xi_INCLUDE_PATH}")
-endif()
-
-#--------------------------------------------------------------------
-# Use Wayland for window creation
-#--------------------------------------------------------------------
-if (_GLFW_WAYLAND)
-    find_package(ECM REQUIRED NO_MODULE)
-    list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}")
-
-    find_package(Wayland REQUIRED Client Cursor Egl)
-    find_package(WaylandScanner REQUIRED)
-    find_package(WaylandProtocols 1.15 REQUIRED)
-
-    list(APPEND glfw_PKG_DEPS "wayland-egl")
-
-    list(APPEND glfw_INCLUDE_DIRS "${Wayland_INCLUDE_DIRS}")
-    list(APPEND glfw_LIBRARIES "${Wayland_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}")
-
-    find_package(XKBCommon REQUIRED)
-    list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}")
-
-    include(CheckIncludeFiles)
-    include(CheckFunctionExists)
-    check_include_files(xkbcommon/xkbcommon-compose.h HAVE_XKBCOMMON_COMPOSE_H)
-    check_function_exists(memfd_create HAVE_MEMFD_CREATE)
-
-    if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))
-        find_package(EpollShim)
-        if (EPOLLSHIM_FOUND)
-            list(APPEND glfw_INCLUDE_DIRS "${EPOLLSHIM_INCLUDE_DIRS}")
-            list(APPEND glfw_LIBRARIES "${EPOLLSHIM_LIBRARIES}")
-        endif()
-    endif()
-endif()
-
-#--------------------------------------------------------------------
-# Use OSMesa for offscreen context creation
-#--------------------------------------------------------------------
-if (_GLFW_OSMESA)
-    find_package(OSMesa REQUIRED)
-    list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
-endif()
-
-#--------------------------------------------------------------------
-# Use Cocoa for window creation and NSOpenGL for context creation
-#--------------------------------------------------------------------
-if (_GLFW_COCOA)
-
-    list(APPEND glfw_LIBRARIES
-        "-framework Cocoa"
-        "-framework IOKit"
-        "-framework CoreFoundation")
-
-    set(glfw_PKG_DEPS "")
-    set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation")
-endif()
-
-#--------------------------------------------------------------------
-# Add the Vulkan loader as a dependency if necessary
-#--------------------------------------------------------------------
-if (GLFW_VULKAN_STATIC)
-    list(APPEND glfw_PKG_DEPS "vulkan")
-endif()
-
-#--------------------------------------------------------------------
-# Export GLFW library dependencies
-#--------------------------------------------------------------------
-foreach(arg ${glfw_PKG_DEPS})
-    set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}" CACHE INTERNAL
-        "GLFW pkg-config Requires.private")
-endforeach()
-foreach(arg ${glfw_PKG_LIBS})
-    set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}" CACHE INTERNAL
-        "GLFW pkg-config Libs.private")
-endforeach()
-
-#--------------------------------------------------------------------
-# Create generated files
-#--------------------------------------------------------------------
-include(CMakePackageConfigHelpers)
-
-set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
-
-configure_package_config_file(CMake/glfw3Config.cmake.in
-                              src/glfw3Config.cmake
-                              INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
-                              NO_CHECK_REQUIRED_COMPONENTS_MACRO)
-
-write_basic_package_version_file(src/glfw3ConfigVersion.cmake
-                                 VERSION ${GLFW_VERSION}
-                                 COMPATIBILITY SameMajorVersion)
-
-configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
-
-configure_file(CMake/glfw3.pc.in CMake/glfw3.pc @ONLY)
-
-#--------------------------------------------------------------------
-# Add subdirectories
-#--------------------------------------------------------------------
-add_subdirectory(src)
-
-if (GLFW_BUILD_EXAMPLES)
-    add_subdirectory(examples)
-endif()
-
-if (GLFW_BUILD_TESTS)
-    add_subdirectory(tests)
-endif()
-
-if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
-    add_subdirectory(docs)
-endif()
-
-#--------------------------------------------------------------------
-# Install files other than the library
-# The library is installed by src/CMakeLists.txt
-#--------------------------------------------------------------------
-if (GLFW_INSTALL)
-    install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
-            FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
-
-    install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
-                  "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
-            DESTINATION "${GLFW_CONFIG_PATH}")
-
-    install(EXPORT glfwTargets FILE glfw3Targets.cmake
-            EXPORT_LINK_INTERFACE_LIBRARIES
-            DESTINATION "${GLFW_CONFIG_PATH}")
-    install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
-            DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-
-    if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
-        install(DIRECTORY "${GLFW_BINARY_DIR}/docs/html"
-                DESTINATION "${CMAKE_INSTALL_DOCDIR}")
-    endif()
-
-    # Only generate this target if no higher-level project already has
-    if (NOT TARGET uninstall)
-        configure_file(CMake/cmake_uninstall.cmake.in
-                       cmake_uninstall.cmake IMMEDIATE @ONLY)
-
-        add_custom_target(uninstall
-                          "${CMAKE_COMMAND}" -P
-                          "${GLFW_BINARY_DIR}/cmake_uninstall.cmake")
-        set_target_properties(uninstall PROPERTIES FOLDER "GLFW3")
-    endif()
-endif()
-
diff --git a/raylib_pi4_test/external/glfw/LICENSE.md b/raylib_pi4_test/external/glfw/LICENSE.md
deleted file mode 100644 (file)
index 7494a3f..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-Copyright (c) 2002-2006 Marcus Geelnard
-
-Copyright (c) 2006-2019 Camilla Löwy
-
-This software is provided 'as-is', without any express or implied
-warranty. In no event will the authors be held liable for any damages
-arising from the use of this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
-1. The origin of this software must not be misrepresented; you must not
-   claim that you wrote the original software. If you use this software
-   in a product, an acknowledgment in the product documentation would
-   be appreciated but is not required.
-
-2. Altered source versions must be plainly marked as such, and must not
-   be misrepresented as being the original software.
-
-3. This notice may not be removed or altered from any source
-   distribution.
-
diff --git a/raylib_pi4_test/external/glfw/README.md b/raylib_pi4_test/external/glfw/README.md
deleted file mode 100644 (file)
index 7488e6d..0000000
+++ /dev/null
@@ -1,441 +0,0 @@
-# GLFW
-
-[![Build status](https://travis-ci.org/glfw/glfw.svg?branch=master)](https://travis-ci.org/glfw/glfw)
-[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
-[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
-
-## Introduction
-
-GLFW is an Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan
-application development.  It provides a simple, platform-independent API for
-creating windows, contexts and surfaces, reading input, handling events, etc.
-
-GLFW natively supports Windows, macOS and Linux and other Unix-like systems.  On
-Linux both X11 and Wayland are supported.
-
-GLFW is licensed under the [zlib/libpng
-license](http://www.glfw.org/license.html).
-
-You can [download](http://www.glfw.org/download.html) the latest stable release
-as source or Windows binaries, or fetch the `latest` branch from GitHub.  Each
-release starting with 3.0 also has a corresponding [annotated
-tag](https://github.com/glfw/glfw/releases) with source and binary archives.
-
-The [documentation](http://www.glfw.org/docs/latest/) is available online and is
-included in all source and binary archives.  See the [release
-notes](https://www.glfw.org/docs/latest/news.html) for new features, caveats and
-deprecations in the latest release.  For more details see the [version
-history](http://www.glfw.org/changelog.html).
-
-The `master` branch is the stable integration branch and _should_ always compile
-and run on all supported platforms, although details of newly added features may
-change until they have been included in a release.  New features and many bug
-fixes live in [other branches](https://github.com/glfw/glfw/branches/all) until
-they are stable enough to merge.
-
-If you are new to GLFW, you may find the
-[tutorial](http://www.glfw.org/docs/latest/quick.html) for GLFW 3 useful.  If
-you have used GLFW 2 in the past, there is a [transition
-guide](http://www.glfw.org/docs/latest/moving.html) for moving to the GLFW
-3 API.
-
-
-## Compiling GLFW
-
-GLFW itself requires only the headers and libraries for your OS and window
-system.  It does not need the headers for any context creation API (WGL, GLX,
-EGL, NSGL, OSMesa) or rendering API (OpenGL, OpenGL ES, Vulkan) to enable
-support for them.
-
-GLFW supports compilation on Windows with Visual C++ 2010 and later, MinGW and
-MinGW-w64, on macOS with Clang and on Linux and other Unix-like systems with GCC
-and Clang.  It will likely compile in other environments as well, but this is
-not regularly tested.
-
-There are [pre-compiled Windows binaries](http://www.glfw.org/download.html)
-available for all supported compilers.
-
-See the [compilation guide](http://www.glfw.org/docs/latest/compile.html) for
-more information about how to compile GLFW yourself.
-
-
-## Using GLFW
-
-See the [documentation](http://www.glfw.org/docs/latest/) for tutorials, guides
-and the API reference.
-
-
-## Contributing to GLFW
-
-See the [contribution
-guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
-more information.
-
-
-## System requirements
-
-GLFW supports Windows XP and later and macOS 10.8 and later.  Linux and other
-Unix-like systems running the X Window System are supported even without
-a desktop environment or modern extensions, although some features require
-a running window or clipboard manager.  The OSMesa backend requires Mesa 6.3.
-
-See the [compatibility guide](http://www.glfw.org/docs/latest/compat.html)
-in the documentation for more information.
-
-
-## Dependencies
-
-GLFW itself needs only CMake 3.1 or later and the headers and libraries for your
-OS and window system.
-
-The examples and test programs depend on a number of tiny libraries.  These are
-located in the `deps/` directory.
-
- - [getopt\_port](https://github.com/kimgr/getopt_port/) for examples
-   with command-line options
- - [TinyCThread](https://github.com/tinycthread/tinycthread) for threaded
-   examples
- - [glad2](https://github.com/Dav1dde/glad) for loading OpenGL and Vulkan
-   functions
- - [linmath.h](https://github.com/datenwolf/linmath.h) for linear algebra in
-   examples
- - [Nuklear](https://github.com/vurtun/nuklear) for test and example UI
- - [stb\_image\_write](https://github.com/nothings/stb) for writing images to disk
-
-The documentation is generated with [Doxygen](http://doxygen.org/) if CMake can
-find that tool.
-
-
-## Reporting bugs
-
-Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
-Please check the [contribution
-guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
-information on what to include when reporting a bug.
-
-
-## Changelog
-
- - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
-   `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
- - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
- - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
- - Added `GLFW_MOUSE_PASSTHROUGH` window hint for letting mouse input pass
-   through the window (#1236,#1568)
- - Added `GLFW_FEATURE_UNAVAILABLE` error for platform limitations (#1692)
- - Added `GLFW_FEATURE_UNIMPLEMENTED` error for incomplete backends (#1692)
- - Added `GLFW_ANGLE_PLATFORM_TYPE` init hint and `GLFW_ANGLE_PLATFORM_TYPE_*`
-   values to select ANGLE backend (#1380)
- - Made joystick subsystem initialize at first use (#1284,#1646)
- - Updated the minimum required CMake version to 3.1
- - Disabled tests and examples by default when built as a CMake subdirectory
- - Bugfix: The CMake config-file package used an absolute path and was not
-   relocatable (#1470)
- - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
- - Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
- - Bugfix: Built-in mappings failed because some OEMs re-used VID/PID (#1583)
- - Bugfix: Some extension loader headers did not prevent default OpenGL header
-   inclusion (#1695)
- - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
-           to the window menu
- - [Win32] Added a version info resource to the GLFW DLL
- - [Win32] Disabled framebuffer transparency on Windows 7 when DWM windows are
-   opaque (#1512)
- - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
-   symbol redefinition (#1524)
- - [Win32] Bugfix: The cursor position event was emitted before its cursor enter
-   event (#1490)
- - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the
-   window (#1499)
- - [Win32] Bugfix: Disabled cursor mode interfered with some non-client actions
- - [Win32] Bugfix: Super key was not released after Win+V hotkey (#1622)
- - [Win32] Bugfix: `glfwGetKeyName` could access out of bounds and return an
-   invalid pointer
- - [Win32] Bugfix: Some synthetic key events were reported as `GLFW_KEY_UNKNOWN`
-   (#1623)
- - [Win32] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
- - [Win32] Bugfix: Monitor functions could return invalid values after
-   configuration change (#1761)
- - [Win32] Bugfix: Initialization would segfault on Windows 8 (not 8.1) (#1775)
- - [Cocoa] Added support for `VK_EXT_metal_surface` (#1619)
- - [Cocoa] Added locating the Vulkan loader at runtime in an application bundle
- - [Cocoa] Moved main menu creation to GLFW initialization time (#1649)
- - [Cocoa] Changed `EGLNativeWindowType` from `NSView` to `CALayer` (#1169)
- - [Cocoa] Removed dependency on the CoreVideo framework
- - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- - [Cocoa] Bugfix: Window remained on screen after destruction until event poll
-   (#1412)
- - [Cocoa] Bugfix: Event processing before window creation would assert (#1543)
- - [Cocoa] Bugfix: Undecorated windows could not be iconified on recent macOS
- - [Cocoa] Bugfix: Touching event queue from secondary thread before main thread
-   would abort (#1649)
- - [Cocoa] Bugfix: Non-BMP Unicode codepoint input was reported as UTF-16
-   (#1635)
- - [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
-   could leak memory
- - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- - [X11] Bugfix: Key names were not updated when the keyboard layout changed
-   (#1462,#1528)
- - [X11] Bugfix: Decorations could not be enabled after window creation (#1566)
- - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
- - [X11] Bugfix: `glfwMaximizeWindow` had no effect on hidden windows
- - [X11] Bugfix: Clearing `GLFW_FLOATING` on a hidden window caused invalid read
- - [X11] Bugfix: Changing `GLFW_FLOATING` on a hidden window could silently fail
- - [X11] Bugfix: Disabled cursor mode was interrupted by indicator windows
- - [X11] Bugfix: Monitor physical dimensions could be reported as zero mm
- - [X11] Bugfix: Window position events were not emitted during resizing (#1613)
- - [X11] Bugfix: `glfwFocusWindow` could terminate on older WMs or without a WM
- - [X11] Bugfix: Querying a disconnected monitor could segfault (#1602)
- - [X11] Bugfix: IME input of CJK was broken for "C" locale (#1587,#1636)
- - [X11] Bugfix: Termination would segfault if the IM had been destroyed
- - [X11] Bugfix: Any IM started after initialization would not be detected
- - [X11] Bugfix: Xlib errors caused by other parts of the application could be
-   reported as GLFW errors
- - [X11] Bugfix: A handle race condition could cause a `BadWindow` error (#1633)
- - [X11] Bugfix: XKB path used keysyms instead of physical locations for
-   non-printable keys (#1598)
- - [X11] Bugfix: Function keys were mapped to `GLFW_KEY_UNKNOWN` for some layout
-   combinaitons (#1598)
- - [X11] Bugfix: Keys pressed simultaneously with others were not always
-   reported (#1112,#1415,#1472,#1616)
- - [Wayland] Removed support for `wl_shell` (#1443)
- - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- - [Wayland] Bugfix: `CLOCK_MONOTONIC` was not correctly enabled
- - [Wayland] Bugfix: Repeated keys could be reported with `NULL` window (#1704)
- - [Wayland] Bugfix: Retrieving partial framebuffer size would segfault
- - [Wayland] Bugfix: Scrolling offsets were inverted compared to other platforms
-   (#1463)
- - [POSIX] Bugfix: `CLOCK_MONOTONIC` was not correctly tested for or enabled
- - [NSGL] Removed enforcement of forward-compatible flag for core contexts
- - [NSGL] Bugfix: `GLFW_COCOA_RETINA_FRAMEBUFFER` had no effect on newer
-   macOS versions (#1442)
- - [NSGL] Bugfix: Workaround for swap interval on 10.14 broke on 10.12 (#1483)
- - [EGL] Added platform selection via the `EGL_EXT_platform_base` extension
-   (#442)
- - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
-   (#1380)
-
-
-## Contact
-
-On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
-well as news, documentation and other information about the project.
-
-If you have questions related to the use of GLFW, we have a
-[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
-[Freenode](http://freenode.net/).
-
-If you have a bug to report, a patch to submit or a feature you'd like to
-request, please file it in the
-[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
-
-Finally, if you're interested in helping out with the development of GLFW or
-porting it to your favorite platform, join us on the forum, GitHub or IRC.
-
-
-## Acknowledgements
-
-GLFW exists because people around the world donated their time and lent their
-skills.
-
- - Bobyshev Alexander
- - Matt Arsenault
- - David Avedissian
- - Keith Bauer
- - John Bartholomew
- - CoÅŸku BaÅŸ
- - Niklas Behrens
- - Andrew Belt
- - Niklas Bergström
- - Denis Bernard
- - Doug Binks
- - blanco
- - Kyle Brenneman
- - Rok Breulj
- - Kai Burjack
- - Martin Capitanio
- - Nicolas Caramelli
- - David Carlier
- - Arturo Castro
- - Chi-kwan Chan
- - Ian Clarkson
- - MichaÅ‚ CichoÅ„
- - Lambert Clara
- - Anna Clarke
- - Yaron Cohen-Tal
- - Omar Cornut
- - Andrew Corrigan
- - Bailey Cosier
- - Noel Cower
- - Jason Daly
- - Jarrod Davis
- - Olivier Delannoy
- - Paul R. Deppe
- - Michael Dickens
- - Ð Ð¾Ð¼Ð°Ð½ Ð”онченко
- - Mario Dorn
- - Wolfgang Draxinger
- - Jonathan Dummer
- - Ralph Eastwood
- - Fredrik Ehnbom
- - Robin Eklind
- - Siavash Eliasi
- - Felipe Ferreira
- - Michael Fogleman
- - Gerald Franz
- - Mário Freitas
- - GeO4d
- - Marcus Geelnard
- - Charles Giessen
- - Ryan C. Gordon
- - Stephen Gowen
- - Kovid Goyal
- - Eloi Marín Gratacós
- - Stefan Gustavson
- - Jonathan Hale
- - Sylvain Hellegouarch
- - Matthew Henry
- - heromyth
- - Lucas Hinderberger
- - Paul Holden
- - Warren Hu
- - Charles Huber
- - IntellectualKitty
- - Aaron Jacobs
- - Erik S. V. Jansson
- - Toni Jovanoski
- - Arseny Kapoulkine
- - Cem Karan
- - Osman Keskin
- - Josh Kilmer
- - Byunghoon Kim
- - Cameron King
- - Peter Knut
- - Christoph Kubisch
- - Yuri Kunde Schlesner
- - Rokas Kupstys
- - Konstantin Käfer
- - Eric Larson
- - Francis Lecavalier
- - Robin Leffmann
- - Glenn Lewis
- - Shane Liesegang
- - Anders Lindqvist
- - Leon Linhart
- - Eyal Lotem
- - Aaron Loucks
- - Luflosi
- - lukect
- - Tristam MacDonald
- - Hans Mackowiak
- - Ð”митри ÐœÐ°Ð»Ñ‹ÑˆÐµÐ²
- - Zbigniew Mandziejewicz
- - Adam Marcus
- - Célestin Marot
- - Kyle McDonald
- - David Medlock
- - Bryce Mehring
- - Jonathan Mercier
- - Marcel Metz
- - Liam Middlebrook
- - Ave Milia
- - Jonathan Miller
- - Kenneth Miller
- - Bruce Mitchener
- - Jack Moffitt
- - Jeff Molofee
- - Alexander Monakov
- - Pierre Morel
- - Jon Morton
- - Pierre Moulon
- - Martins Mozeiko
- - Julian Møller
- - ndogxj
- - Kristian Nielsen
- - Kamil Nowakowski
- - onox
- - Denis Ovod
- - Ozzy
- - Andri Pálsson
- - Peoro
- - Braden Pellett
- - Christopher Pelloux
- - Arturo J. Pérez
- - Vladimir Perminov
- - Anthony Pesch
- - Orson Peters
- - Emmanuel Gil Peyrot
- - Cyril Pichard
- - Keith Pitt
- - Stanislav Podgorskiy
- - Konstantin Podsvirov
- - Nathan Poirier
- - Alexandre Pretyman
- - Pablo Prietz
- - przemekmirek
- - pthom
- - Guillaume Racicot
- - Philip Rideout
- - Eddie Ringle
- - Max Risuhin
- - Jorge Rodriguez
- - Luca Rood
- - Ed Ropple
- - Aleksey Rybalkin
- - Mikko Rytkönen
- - Riku Salminen
- - Brandon Schaefer
- - Sebastian Schuberth
- - Christian Sdunek
- - Matt Sealey
- - Steve Sexton
- - Arkady Shapkin
- - Ali Sherief
- - Yoshiki Shibukawa
- - Dmitri Shuralyov
- - Daniel Skorupski
- - Bradley Smith
- - Cliff Smolinsky
- - Patrick Snape
- - Erlend Sogge Heggen
- - Julian Squires
- - Johannes Stein
- - Pontus Stenetorp
- - Michael Stocker
- - Justin Stoecker
- - Elviss Strazdins
- - Paul Sultana
- - Nathan Sweet
- - TTK-Bandit
- - Jared Tiala
- - Sergey Tikhomirov
- - Arthur Tombs
- - Ioannis Tsakpinis
- - Samuli Tuomola
- - Matthew Turner
- - urraka
- - Elias Vanderstuyft
- - Stef Velzel
- - Jari Vetoniemi
- - Ricardo Vieira
- - Nicholas Vitovitch
- - Simon Voordouw
- - Corentin Wallez
- - Torsten Walluhn
- - Patrick Walton
- - Xo Wang
- - Waris
- - Jay Weisskopf
- - Frank Wille
- - Tatsuya Yatagawa
- - Ryogo Yoshimura
- - Lukas Zanner
- - Andrey Zholos
- - Aihui Zhu
- - Santi Zupancic
- - Jonas Ã…dahl
- - Lasse Ã–örni
- - All the unmentioned and anonymous contributors in the GLFW community, for bug
-   reports, patches, feedback, testing and encouragement
-
diff --git a/raylib_pi4_test/external/glfw/deps/getopt.c b/raylib_pi4_test/external/glfw/deps/getopt.c
deleted file mode 100644 (file)
index 9743046..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/* Copyright (c) 2012, Kim Gräsman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of Kim Gräsman nor the names of contributors may be used
- *    to endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "getopt.h"
-
-#include <stddef.h>
-#include <string.h>
-
-const int no_argument = 0;
-const int required_argument = 1;
-const int optional_argument = 2;
-
-char* optarg;
-int optopt;
-/* The variable optind [...] shall be initialized to 1 by the system. */
-int optind = 1;
-int opterr;
-
-static char* optcursor = NULL;
-
-/* Implemented based on [1] and [2] for optional arguments.
-   optopt is handled FreeBSD-style, per [3].
-   Other GNU and FreeBSD extensions are purely accidental.
-
-[1] http://pubs.opengroup.org/onlinepubs/000095399/functions/getopt.html
-[2] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
-[3] http://www.freebsd.org/cgi/man.cgi?query=getopt&sektion=3&manpath=FreeBSD+9.0-RELEASE
-*/
-int getopt(int argc, char* const argv[], const char* optstring) {
-  int optchar = -1;
-  const char* optdecl = NULL;
-
-  optarg = NULL;
-  opterr = 0;
-  optopt = 0;
-
-  /* Unspecified, but we need it to avoid overrunning the argv bounds. */
-  if (optind >= argc)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] is a null pointer, getopt()
-     shall return -1 without changing optind. */
-  if (argv[optind] == NULL)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called *argv[optind]  is not the character '-',
-     getopt() shall return -1 without changing optind. */
-  if (*argv[optind] != '-')
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] points to the string "-",
-     getopt() shall return -1 without changing optind. */
-  if (strcmp(argv[optind], "-") == 0)
-    goto no_more_optchars;
-
-  /* If, when getopt() is called argv[optind] points to the string "--",
-     getopt() shall return -1 after incrementing optind. */
-  if (strcmp(argv[optind], "--") == 0) {
-    ++optind;
-    goto no_more_optchars;
-  }
-
-  if (optcursor == NULL || *optcursor == '\0')
-    optcursor = argv[optind] + 1;
-
-  optchar = *optcursor;
-
-  /* FreeBSD: The variable optopt saves the last known option character
-     returned by getopt(). */
-  optopt = optchar;
-
-  /* The getopt() function shall return the next option character (if one is
-     found) from argv that matches a character in optstring, if there is
-     one that matches. */
-  optdecl = strchr(optstring, optchar);
-  if (optdecl) {
-    /* [I]f a character is followed by a colon, the option takes an
-       argument. */
-    if (optdecl[1] == ':') {
-      optarg = ++optcursor;
-      if (*optarg == '\0') {
-        /* GNU extension: Two colons mean an option takes an
-           optional arg; if there is text in the current argv-element
-           (i.e., in the same word as the option name itself, for example,
-           "-oarg"), then it is returned in optarg, otherwise optarg is set
-           to zero. */
-        if (optdecl[2] != ':') {
-          /* If the option was the last character in the string pointed to by
-             an element of argv, then optarg shall contain the next element
-             of argv, and optind shall be incremented by 2. If the resulting
-             value of optind is greater than argc, this indicates a missing
-             option-argument, and getopt() shall return an error indication.
-
-             Otherwise, optarg shall point to the string following the
-             option character in that element of argv, and optind shall be
-             incremented by 1.
-          */
-          if (++optind < argc) {
-            optarg = argv[optind];
-          } else {
-            /* If it detects a missing option-argument, it shall return the
-               colon character ( ':' ) if the first character of optstring
-               was a colon, or a question-mark character ( '?' ) otherwise.
-            */
-            optarg = NULL;
-            optchar = (optstring[0] == ':') ? ':' : '?';
-          }
-        } else {
-          optarg = NULL;
-        }
-      }
-
-      optcursor = NULL;
-    }
-  } else {
-    /* If getopt() encounters an option character that is not contained in
-       optstring, it shall return the question-mark ( '?' ) character. */
-    optchar = '?';
-  }
-
-  if (optcursor == NULL || *++optcursor == '\0')
-    ++optind;
-
-  return optchar;
-
-no_more_optchars:
-  optcursor = NULL;
-  return -1;
-}
-
-/* Implementation based on [1].
-
-[1] http://www.kernel.org/doc/man-pages/online/pages/man3/getopt.3.html
-*/
-int getopt_long(int argc, char* const argv[], const char* optstring,
-  const struct option* longopts, int* longindex) {
-  const struct option* o = longopts;
-  const struct option* match = NULL;
-  int num_matches = 0;
-  size_t argument_name_length = 0;
-  const char* current_argument = NULL;
-  int retval = -1;
-
-  optarg = NULL;
-  optopt = 0;
-
-  if (optind >= argc)
-    return -1;
-
-  if (strlen(argv[optind]) < 3 || strncmp(argv[optind], "--", 2) != 0)
-    return getopt(argc, argv, optstring);
-
-  /* It's an option; starts with -- and is longer than two chars. */
-  current_argument = argv[optind] + 2;
-  argument_name_length = strcspn(current_argument, "=");
-  for (; o->name; ++o) {
-    if (strncmp(o->name, current_argument, argument_name_length) == 0) {
-      match = o;
-      ++num_matches;
-    }
-  }
-
-  if (num_matches == 1) {
-    /* If longindex is not NULL, it points to a variable which is set to the
-       index of the long option relative to longopts. */
-    if (longindex)
-      *longindex = (int) (match - longopts);
-
-    /* If flag is NULL, then getopt_long() shall return val.
-       Otherwise, getopt_long() returns 0, and flag shall point to a variable
-       which shall be set to val if the option is found, but left unchanged if
-       the option is not found. */
-    if (match->flag)
-      *(match->flag) = match->val;
-
-    retval = match->flag ? 0 : match->val;
-
-    if (match->has_arg != no_argument) {
-      optarg = strchr(argv[optind], '=');
-      if (optarg != NULL)
-        ++optarg;
-
-      if (match->has_arg == required_argument) {
-        /* Only scan the next argv for required arguments. Behavior is not
-           specified, but has been observed with Ubuntu and Mac OSX. */
-        if (optarg == NULL && ++optind < argc) {
-          optarg = argv[optind];
-        }
-
-        if (optarg == NULL)
-          retval = ':';
-      }
-    } else if (strchr(argv[optind], '=')) {
-      /* An argument was provided to a non-argument option.
-         I haven't seen this specified explicitly, but both GNU and BSD-based
-         implementations show this behavior.
-      */
-      retval = '?';
-    }
-  } else {
-    /* Unknown option or ambiguous match. */
-    retval = '?';
-  }
-
-  ++optind;
-  return retval;
-}
diff --git a/raylib_pi4_test/external/glfw/deps/getopt.h b/raylib_pi4_test/external/glfw/deps/getopt.h
deleted file mode 100644 (file)
index e1eb540..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2012, Kim Gräsman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of Kim Gräsman nor the names of contributors may be used
- *    to endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL KIM GRÄSMAN BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef INCLUDED_GETOPT_PORT_H
-#define INCLUDED_GETOPT_PORT_H
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-extern const int no_argument;
-extern const int required_argument;
-extern const int optional_argument;
-
-extern char* optarg;
-extern int optind, opterr, optopt;
-
-struct option {
-  const char* name;
-  int has_arg;
-  int* flag;
-  int val;
-};
-
-int getopt(int argc, char* const argv[], const char* optstring);
-
-int getopt_long(int argc, char* const argv[],
-  const char* optstring, const struct option* longopts, int* longindex);
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif // INCLUDED_GETOPT_PORT_H
diff --git a/raylib_pi4_test/external/glfw/deps/glad/gl.h b/raylib_pi4_test/external/glfw/deps/glad/gl.h
deleted file mode 100644 (file)
index 5c7879f..0000000
+++ /dev/null
@@ -1,3840 +0,0 @@
-/**
- * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:32 2019
- *
- * Generator: C/C++
- * Specification: gl
- * Extensions: 3
- *
- * APIs:
- *  - gl:compatibility=3.3
- *
- * Options:
- *  - MX_GLOBAL = False
- *  - LOADER = False
- *  - ALIAS = False
- *  - HEADER_ONLY = False
- *  - DEBUG = False
- *  - MX = False
- *
- * Commandline:
- *    --api='gl:compatibility=3.3' --extensions='GL_ARB_multisample,GL_ARB_robustness,GL_KHR_debug' c
- *
- * Online:
- *    http://glad.sh/#api=gl%3Acompatibility%3D3.3&extensions=GL_ARB_multisample%2CGL_ARB_robustness%2CGL_KHR_debug&generator=c&options=
- *
- */
-
-#ifndef GLAD_GL_H_
-#define GLAD_GL_H_
-
-#ifdef __gl_h_
-    #error OpenGL header already included (API: gl), remove previous include!
-#endif
-#define __gl_h_ 1
-
-
-#define GLAD_GL
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GLAD_PLATFORM_H_
-#define GLAD_PLATFORM_H_
-
-#ifndef GLAD_PLATFORM_WIN32
-  #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
-    #define GLAD_PLATFORM_WIN32 1
-  #else
-    #define GLAD_PLATFORM_WIN32 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_APPLE
-  #ifdef __APPLE__
-    #define GLAD_PLATFORM_APPLE 1
-  #else
-    #define GLAD_PLATFORM_APPLE 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_EMSCRIPTEN
-  #ifdef __EMSCRIPTEN__
-    #define GLAD_PLATFORM_EMSCRIPTEN 1
-  #else
-    #define GLAD_PLATFORM_EMSCRIPTEN 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_UWP
-  #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
-    #ifdef __has_include
-      #if __has_include(<winapifamily.h>)
-        #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-      #endif
-    #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
-      #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-    #endif
-  #endif
-
-  #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
-    #include <winapifamily.h>
-    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
-      #define GLAD_PLATFORM_UWP 1
-    #endif
-  #endif
-
-  #ifndef GLAD_PLATFORM_UWP
-    #define GLAD_PLATFORM_UWP 0
-  #endif
-#endif
-
-#ifdef __GNUC__
-  #define GLAD_GNUC_EXTENSION __extension__
-#else
-  #define GLAD_GNUC_EXTENSION
-#endif
-
-#ifndef GLAD_API_CALL
-  #if defined(GLAD_API_CALL_EXPORT)
-    #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
-      #if defined(GLAD_API_CALL_EXPORT_BUILD)
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllexport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllexport) extern
-        #endif
-      #else
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllimport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllimport) extern
-        #endif
-      #endif
-    #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
-      #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
-    #else
-      #define GLAD_API_CALL extern
-    #endif
-  #else
-    #define GLAD_API_CALL extern
-  #endif
-#endif
-
-#ifdef APIENTRY
-  #define GLAD_API_PTR APIENTRY
-#elif GLAD_PLATFORM_WIN32
-  #define GLAD_API_PTR __stdcall
-#else
-  #define GLAD_API_PTR
-#endif
-
-#ifndef GLAPI
-#define GLAPI GLAD_API_CALL
-#endif
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY GLAD_API_PTR
-#endif
-
-
-#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
-#define GLAD_VERSION_MAJOR(version) (version / 10000)
-#define GLAD_VERSION_MINOR(version) (version % 10000)
-
-typedef void (*GLADapiproc)(void);
-
-typedef GLADapiproc (*GLADloadfunc)(const char *name);
-typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr);
-
-typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
-typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
-
-#endif /* GLAD_PLATFORM_H_ */
-
-#define GL_2D 0x0600
-#define GL_2_BYTES 0x1407
-#define GL_3D 0x0601
-#define GL_3D_COLOR 0x0602
-#define GL_3D_COLOR_TEXTURE 0x0603
-#define GL_3_BYTES 0x1408
-#define GL_4D_COLOR_TEXTURE 0x0604
-#define GL_4_BYTES 0x1409
-#define GL_ACCUM 0x0100
-#define GL_ACCUM_ALPHA_BITS 0x0D5B
-#define GL_ACCUM_BLUE_BITS 0x0D5A
-#define GL_ACCUM_BUFFER_BIT 0x00000200
-#define GL_ACCUM_CLEAR_VALUE 0x0B80
-#define GL_ACCUM_GREEN_BITS 0x0D59
-#define GL_ACCUM_RED_BITS 0x0D58
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ADD 0x0104
-#define GL_ADD_SIGNED 0x8574
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF
-#define GL_ALPHA 0x1906
-#define GL_ALPHA12 0x803D
-#define GL_ALPHA16 0x803E
-#define GL_ALPHA4 0x803B
-#define GL_ALPHA8 0x803C
-#define GL_ALPHA_BIAS 0x0D1D
-#define GL_ALPHA_BITS 0x0D55
-#define GL_ALPHA_INTEGER 0x8D97
-#define GL_ALPHA_SCALE 0x0D1C
-#define GL_ALPHA_TEST 0x0BC0
-#define GL_ALPHA_TEST_FUNC 0x0BC1
-#define GL_ALPHA_TEST_REF 0x0BC2
-#define GL_ALREADY_SIGNALED 0x911A
-#define GL_ALWAYS 0x0207
-#define GL_AMBIENT 0x1200
-#define GL_AMBIENT_AND_DIFFUSE 0x1602
-#define GL_AND 0x1501
-#define GL_AND_INVERTED 0x1504
-#define GL_AND_REVERSE 0x1502
-#define GL_ANY_SAMPLES_PASSED 0x8C2F
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ATTRIB_STACK_DEPTH 0x0BB0
-#define GL_AUTO_NORMAL 0x0D80
-#define GL_AUX0 0x0409
-#define GL_AUX1 0x040A
-#define GL_AUX2 0x040B
-#define GL_AUX3 0x040C
-#define GL_AUX_BUFFERS 0x0C00
-#define GL_BACK 0x0405
-#define GL_BACK_LEFT 0x0402
-#define GL_BACK_RIGHT 0x0403
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_BGRA_INTEGER 0x8D9B
-#define GL_BGR_INTEGER 0x8D9A
-#define GL_BITMAP 0x1A00
-#define GL_BITMAP_TOKEN 0x0704
-#define GL_BLEND 0x0BE2
-#define GL_BLEND_COLOR 0x8005
-#define GL_BLEND_DST 0x0BE0
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_BLEND_EQUATION_RGB 0x8009
-#define GL_BLEND_SRC 0x0BE1
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLUE 0x1905
-#define GL_BLUE_BIAS 0x0D1B
-#define GL_BLUE_BITS 0x0D54
-#define GL_BLUE_INTEGER 0x8D96
-#define GL_BLUE_SCALE 0x0D1A
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_BUFFER 0x82E0
-#define GL_BUFFER_ACCESS 0x88BB
-#define GL_BUFFER_ACCESS_FLAGS 0x911F
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_LENGTH 0x9120
-#define GL_BUFFER_MAP_OFFSET 0x9121
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_BYTE 0x1400
-#define GL_C3F_V3F 0x2A24
-#define GL_C4F_N3F_V3F 0x2A26
-#define GL_C4UB_V2F 0x2A22
-#define GL_C4UB_V3F 0x2A23
-#define GL_CCW 0x0901
-#define GL_CLAMP 0x2900
-#define GL_CLAMP_FRAGMENT_COLOR 0x891B
-#define GL_CLAMP_READ_COLOR 0x891C
-#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_CLAMP_VERTEX_COLOR 0x891A
-#define GL_CLEAR 0x1500
-#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
-#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
-#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
-#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
-#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
-#define GL_CLIP_DISTANCE0 0x3000
-#define GL_CLIP_DISTANCE1 0x3001
-#define GL_CLIP_DISTANCE2 0x3002
-#define GL_CLIP_DISTANCE3 0x3003
-#define GL_CLIP_DISTANCE4 0x3004
-#define GL_CLIP_DISTANCE5 0x3005
-#define GL_CLIP_DISTANCE6 0x3006
-#define GL_CLIP_DISTANCE7 0x3007
-#define GL_CLIP_PLANE0 0x3000
-#define GL_CLIP_PLANE1 0x3001
-#define GL_CLIP_PLANE2 0x3002
-#define GL_CLIP_PLANE3 0x3003
-#define GL_CLIP_PLANE4 0x3004
-#define GL_CLIP_PLANE5 0x3005
-#define GL_COEFF 0x0A00
-#define GL_COLOR 0x1800
-#define GL_COLOR_ARRAY 0x8076
-#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
-#define GL_COLOR_ARRAY_POINTER 0x8090
-#define GL_COLOR_ARRAY_SIZE 0x8081
-#define GL_COLOR_ARRAY_STRIDE 0x8083
-#define GL_COLOR_ARRAY_TYPE 0x8082
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#define GL_COLOR_ATTACHMENT10 0x8CEA
-#define GL_COLOR_ATTACHMENT11 0x8CEB
-#define GL_COLOR_ATTACHMENT12 0x8CEC
-#define GL_COLOR_ATTACHMENT13 0x8CED
-#define GL_COLOR_ATTACHMENT14 0x8CEE
-#define GL_COLOR_ATTACHMENT15 0x8CEF
-#define GL_COLOR_ATTACHMENT16 0x8CF0
-#define GL_COLOR_ATTACHMENT17 0x8CF1
-#define GL_COLOR_ATTACHMENT18 0x8CF2
-#define GL_COLOR_ATTACHMENT19 0x8CF3
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#define GL_COLOR_ATTACHMENT20 0x8CF4
-#define GL_COLOR_ATTACHMENT21 0x8CF5
-#define GL_COLOR_ATTACHMENT22 0x8CF6
-#define GL_COLOR_ATTACHMENT23 0x8CF7
-#define GL_COLOR_ATTACHMENT24 0x8CF8
-#define GL_COLOR_ATTACHMENT25 0x8CF9
-#define GL_COLOR_ATTACHMENT26 0x8CFA
-#define GL_COLOR_ATTACHMENT27 0x8CFB
-#define GL_COLOR_ATTACHMENT28 0x8CFC
-#define GL_COLOR_ATTACHMENT29 0x8CFD
-#define GL_COLOR_ATTACHMENT3 0x8CE3
-#define GL_COLOR_ATTACHMENT30 0x8CFE
-#define GL_COLOR_ATTACHMENT31 0x8CFF
-#define GL_COLOR_ATTACHMENT4 0x8CE4
-#define GL_COLOR_ATTACHMENT5 0x8CE5
-#define GL_COLOR_ATTACHMENT6 0x8CE6
-#define GL_COLOR_ATTACHMENT7 0x8CE7
-#define GL_COLOR_ATTACHMENT8 0x8CE8
-#define GL_COLOR_ATTACHMENT9 0x8CE9
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_INDEX 0x1900
-#define GL_COLOR_INDEXES 0x1603
-#define GL_COLOR_LOGIC_OP 0x0BF2
-#define GL_COLOR_MATERIAL 0x0B57
-#define GL_COLOR_MATERIAL_FACE 0x0B55
-#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
-#define GL_COLOR_SUM 0x8458
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_COMBINE 0x8570
-#define GL_COMBINE_ALPHA 0x8572
-#define GL_COMBINE_RGB 0x8571
-#define GL_COMPARE_REF_TO_TEXTURE 0x884E
-#define GL_COMPARE_R_TO_TEXTURE 0x884E
-#define GL_COMPILE 0x1300
-#define GL_COMPILE_AND_EXECUTE 0x1301
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_COMPRESSED_ALPHA 0x84E9
-#define GL_COMPRESSED_INTENSITY 0x84EC
-#define GL_COMPRESSED_LUMINANCE 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
-#define GL_COMPRESSED_RED 0x8225
-#define GL_COMPRESSED_RED_RGTC1 0x8DBB
-#define GL_COMPRESSED_RG 0x8226
-#define GL_COMPRESSED_RGB 0x84ED
-#define GL_COMPRESSED_RGBA 0x84EE
-#define GL_COMPRESSED_RG_RGTC2 0x8DBD
-#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
-#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
-#define GL_COMPRESSED_SLUMINANCE 0x8C4A
-#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B
-#define GL_COMPRESSED_SRGB 0x8C48
-#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CONDITION_SATISFIED 0x911C
-#define GL_CONSTANT 0x8576
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_CONSTANT_ATTENUATION 0x1207
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_CONTEXT_FLAGS 0x821E
-#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_COORD_REPLACE 0x8862
-#define GL_COPY 0x1503
-#define GL_COPY_INVERTED 0x150C
-#define GL_COPY_PIXEL_TOKEN 0x0706
-#define GL_COPY_READ_BUFFER 0x8F36
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#define GL_CULL_FACE 0x0B44
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_CURRENT_BIT 0x00000001
-#define GL_CURRENT_COLOR 0x0B00
-#define GL_CURRENT_FOG_COORD 0x8453
-#define GL_CURRENT_FOG_COORDINATE 0x8453
-#define GL_CURRENT_INDEX 0x0B01
-#define GL_CURRENT_NORMAL 0x0B02
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_CURRENT_QUERY 0x8865
-#define GL_CURRENT_RASTER_COLOR 0x0B04
-#define GL_CURRENT_RASTER_DISTANCE 0x0B09
-#define GL_CURRENT_RASTER_INDEX 0x0B05
-#define GL_CURRENT_RASTER_POSITION 0x0B07
-#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
-#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
-#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
-#define GL_CURRENT_SECONDARY_COLOR 0x8459
-#define GL_CURRENT_TEXTURE_COORDS 0x0B03
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_CW 0x0900
-#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
-#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
-#define GL_DEBUG_LOGGED_MESSAGES 0x9145
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
-#define GL_DEBUG_OUTPUT 0x92E0
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
-#define GL_DEBUG_SEVERITY_HIGH 0x9146
-#define GL_DEBUG_SEVERITY_LOW 0x9148
-#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
-#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
-#define GL_DEBUG_SOURCE_API 0x8246
-#define GL_DEBUG_SOURCE_APPLICATION 0x824A
-#define GL_DEBUG_SOURCE_OTHER 0x824B
-#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
-#define GL_DEBUG_TYPE_ERROR 0x824C
-#define GL_DEBUG_TYPE_MARKER 0x8268
-#define GL_DEBUG_TYPE_OTHER 0x8251
-#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
-#define GL_DEBUG_TYPE_POP_GROUP 0x826A
-#define GL_DEBUG_TYPE_PORTABILITY 0x824F
-#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
-#define GL_DECAL 0x2101
-#define GL_DECR 0x1E03
-#define GL_DECR_WRAP 0x8508
-#define GL_DELETE_STATUS 0x8B80
-#define GL_DEPTH 0x1801
-#define GL_DEPTH24_STENCIL8 0x88F0
-#define GL_DEPTH32F_STENCIL8 0x8CAD
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_DEPTH_BIAS 0x0D1F
-#define GL_DEPTH_BITS 0x0D56
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_DEPTH_CLAMP 0x864F
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_DEPTH_COMPONENT32 0x81A7
-#define GL_DEPTH_COMPONENT32F 0x8CAC
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_SCALE 0x0D1E
-#define GL_DEPTH_STENCIL 0x84F9
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define GL_DEPTH_TEST 0x0B71
-#define GL_DEPTH_TEXTURE_MODE 0x884B
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DIFFUSE 0x1201
-#define GL_DISPLAY_LIST 0x82E7
-#define GL_DITHER 0x0BD0
-#define GL_DOMAIN 0x0A02
-#define GL_DONT_CARE 0x1100
-#define GL_DOT3_RGB 0x86AE
-#define GL_DOT3_RGBA 0x86AF
-#define GL_DOUBLE 0x140A
-#define GL_DOUBLEBUFFER 0x0C32
-#define GL_DRAW_BUFFER 0x0C01
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_DRAW_PIXEL_TOKEN 0x0705
-#define GL_DST_ALPHA 0x0304
-#define GL_DST_COLOR 0x0306
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_EDGE_FLAG 0x0B43
-#define GL_EDGE_FLAG_ARRAY 0x8079
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
-#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
-#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_EMISSION 0x1600
-#define GL_ENABLE_BIT 0x00002000
-#define GL_EQUAL 0x0202
-#define GL_EQUIV 0x1509
-#define GL_EVAL_BIT 0x00010000
-#define GL_EXP 0x0800
-#define GL_EXP2 0x0801
-#define GL_EXTENSIONS 0x1F03
-#define GL_EYE_LINEAR 0x2400
-#define GL_EYE_PLANE 0x2502
-#define GL_FALSE 0
-#define GL_FASTEST 0x1101
-#define GL_FEEDBACK 0x1C01
-#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
-#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
-#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
-#define GL_FILL 0x1B02
-#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
-#define GL_FIXED_ONLY 0x891D
-#define GL_FLAT 0x1D00
-#define GL_FLOAT 0x1406
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT2x3 0x8B65
-#define GL_FLOAT_MAT2x4 0x8B66
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT3x2 0x8B67
-#define GL_FLOAT_MAT3x4 0x8B68
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_FLOAT_MAT4x2 0x8B69
-#define GL_FLOAT_MAT4x3 0x8B6A
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_FOG 0x0B60
-#define GL_FOG_BIT 0x00000080
-#define GL_FOG_COLOR 0x0B66
-#define GL_FOG_COORD 0x8451
-#define GL_FOG_COORDINATE 0x8451
-#define GL_FOG_COORDINATE_ARRAY 0x8457
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
-#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
-#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
-#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
-#define GL_FOG_COORDINATE_SOURCE 0x8450
-#define GL_FOG_COORD_ARRAY 0x8457
-#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D
-#define GL_FOG_COORD_ARRAY_POINTER 0x8456
-#define GL_FOG_COORD_ARRAY_STRIDE 0x8455
-#define GL_FOG_COORD_ARRAY_TYPE 0x8454
-#define GL_FOG_COORD_SRC 0x8450
-#define GL_FOG_DENSITY 0x0B62
-#define GL_FOG_END 0x0B64
-#define GL_FOG_HINT 0x0C54
-#define GL_FOG_INDEX 0x0B61
-#define GL_FOG_MODE 0x0B65
-#define GL_FOG_START 0x0B63
-#define GL_FRAGMENT_DEPTH 0x8452
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_DEFAULT 0x8218
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
-#define GL_FRAMEBUFFER_SRGB 0x8DB9
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-#define GL_FRONT 0x0404
-#define GL_FRONT_AND_BACK 0x0408
-#define GL_FRONT_FACE 0x0B46
-#define GL_FRONT_LEFT 0x0400
-#define GL_FRONT_RIGHT 0x0401
-#define GL_FUNC_ADD 0x8006
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_GENERATE_MIPMAP 0x8191
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-#define GL_GEOMETRY_INPUT_TYPE 0x8917
-#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
-#define GL_GEOMETRY_SHADER 0x8DD9
-#define GL_GEOMETRY_VERTICES_OUT 0x8916
-#define GL_GEQUAL 0x0206
-#define GL_GREATER 0x0204
-#define GL_GREEN 0x1904
-#define GL_GREEN_BIAS 0x0D19
-#define GL_GREEN_BITS 0x0D53
-#define GL_GREEN_INTEGER 0x8D95
-#define GL_GREEN_SCALE 0x0D18
-#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253
-#define GL_HALF_FLOAT 0x140B
-#define GL_HINT_BIT 0x00008000
-#define GL_INCR 0x1E02
-#define GL_INCR_WRAP 0x8507
-#define GL_INDEX 0x8222
-#define GL_INDEX_ARRAY 0x8077
-#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
-#define GL_INDEX_ARRAY_POINTER 0x8091
-#define GL_INDEX_ARRAY_STRIDE 0x8086
-#define GL_INDEX_ARRAY_TYPE 0x8085
-#define GL_INDEX_BITS 0x0D51
-#define GL_INDEX_CLEAR_VALUE 0x0C20
-#define GL_INDEX_LOGIC_OP 0x0BF1
-#define GL_INDEX_MODE 0x0C30
-#define GL_INDEX_OFFSET 0x0D13
-#define GL_INDEX_SHIFT 0x0D12
-#define GL_INDEX_WRITEMASK 0x0C21
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254
-#define GL_INT 0x1404
-#define GL_INTENSITY 0x8049
-#define GL_INTENSITY12 0x804C
-#define GL_INTENSITY16 0x804D
-#define GL_INTENSITY4 0x804A
-#define GL_INTENSITY8 0x804B
-#define GL_INTERLEAVED_ATTRIBS 0x8C8C
-#define GL_INTERPOLATE 0x8575
-#define GL_INT_2_10_10_10_REV 0x8D9F
-#define GL_INT_SAMPLER_1D 0x8DC9
-#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
-#define GL_INT_SAMPLER_2D 0x8DCA
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
-#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
-#define GL_INT_SAMPLER_2D_RECT 0x8DCD
-#define GL_INT_SAMPLER_3D 0x8DCB
-#define GL_INT_SAMPLER_BUFFER 0x8DD0
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-#define GL_INVALID_INDEX 0xFFFFFFFF
-#define GL_INVALID_OPERATION 0x0502
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVERT 0x150A
-#define GL_KEEP 0x1E00
-#define GL_LAST_VERTEX_CONVENTION 0x8E4E
-#define GL_LEFT 0x0406
-#define GL_LEQUAL 0x0203
-#define GL_LESS 0x0201
-#define GL_LIGHT0 0x4000
-#define GL_LIGHT1 0x4001
-#define GL_LIGHT2 0x4002
-#define GL_LIGHT3 0x4003
-#define GL_LIGHT4 0x4004
-#define GL_LIGHT5 0x4005
-#define GL_LIGHT6 0x4006
-#define GL_LIGHT7 0x4007
-#define GL_LIGHTING 0x0B50
-#define GL_LIGHTING_BIT 0x00000040
-#define GL_LIGHT_MODEL_AMBIENT 0x0B53
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
-#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
-#define GL_LINE 0x1B01
-#define GL_LINEAR 0x2601
-#define GL_LINEAR_ATTENUATION 0x1208
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_LINES 0x0001
-#define GL_LINES_ADJACENCY 0x000A
-#define GL_LINE_BIT 0x00000004
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_RESET_TOKEN 0x0707
-#define GL_LINE_SMOOTH 0x0B20
-#define GL_LINE_SMOOTH_HINT 0x0C52
-#define GL_LINE_STIPPLE 0x0B24
-#define GL_LINE_STIPPLE_PATTERN 0x0B25
-#define GL_LINE_STIPPLE_REPEAT 0x0B26
-#define GL_LINE_STRIP 0x0003
-#define GL_LINE_STRIP_ADJACENCY 0x000B
-#define GL_LINE_TOKEN 0x0702
-#define GL_LINE_WIDTH 0x0B21
-#define GL_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_LINE_WIDTH_RANGE 0x0B22
-#define GL_LINK_STATUS 0x8B82
-#define GL_LIST_BASE 0x0B32
-#define GL_LIST_BIT 0x00020000
-#define GL_LIST_INDEX 0x0B33
-#define GL_LIST_MODE 0x0B30
-#define GL_LOAD 0x0101
-#define GL_LOGIC_OP 0x0BF1
-#define GL_LOGIC_OP_MODE 0x0BF0
-#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GL_LOWER_LEFT 0x8CA1
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE12 0x8041
-#define GL_LUMINANCE12_ALPHA12 0x8047
-#define GL_LUMINANCE12_ALPHA4 0x8046
-#define GL_LUMINANCE16 0x8042
-#define GL_LUMINANCE16_ALPHA16 0x8048
-#define GL_LUMINANCE4 0x803F
-#define GL_LUMINANCE4_ALPHA4 0x8043
-#define GL_LUMINANCE6_ALPHA2 0x8044
-#define GL_LUMINANCE8 0x8040
-#define GL_LUMINANCE8_ALPHA8 0x8045
-#define GL_LUMINANCE_ALPHA 0x190A
-#define GL_MAJOR_VERSION 0x821B
-#define GL_MAP1_COLOR_4 0x0D90
-#define GL_MAP1_GRID_DOMAIN 0x0DD0
-#define GL_MAP1_GRID_SEGMENTS 0x0DD1
-#define GL_MAP1_INDEX 0x0D91
-#define GL_MAP1_NORMAL 0x0D92
-#define GL_MAP1_TEXTURE_COORD_1 0x0D93
-#define GL_MAP1_TEXTURE_COORD_2 0x0D94
-#define GL_MAP1_TEXTURE_COORD_3 0x0D95
-#define GL_MAP1_TEXTURE_COORD_4 0x0D96
-#define GL_MAP1_VERTEX_3 0x0D97
-#define GL_MAP1_VERTEX_4 0x0D98
-#define GL_MAP2_COLOR_4 0x0DB0
-#define GL_MAP2_GRID_DOMAIN 0x0DD2
-#define GL_MAP2_GRID_SEGMENTS 0x0DD3
-#define GL_MAP2_INDEX 0x0DB1
-#define GL_MAP2_NORMAL 0x0DB2
-#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
-#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
-#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
-#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
-#define GL_MAP2_VERTEX_3 0x0DB7
-#define GL_MAP2_VERTEX_4 0x0DB8
-#define GL_MAP_COLOR 0x0D10
-#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
-#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
-#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
-#define GL_MAP_READ_BIT 0x0001
-#define GL_MAP_STENCIL 0x0D11
-#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
-#define GL_MAP_WRITE_BIT 0x0002
-#define GL_MATRIX_MODE 0x0BA0
-#define GL_MAX 0x8008
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
-#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
-#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
-#define GL_MAX_CLIP_DISTANCES 0x0D32
-#define GL_MAX_CLIP_PLANES 0x0D32
-#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
-#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
-#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
-#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
-#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_EVAL_ORDER 0x0D30
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
-#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
-#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
-#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
-#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
-#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
-#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
-#define GL_MAX_INTEGER_SAMPLES 0x9110
-#define GL_MAX_LABEL_LENGTH 0x82E8
-#define GL_MAX_LIGHTS 0x0D31
-#define GL_MAX_LIST_NESTING 0x0B31
-#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
-#define GL_MAX_NAME_STACK_DEPTH 0x0D37
-#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
-#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
-#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-#define GL_MAX_SAMPLES 0x8D57
-#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
-#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
-#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
-#define GL_MAX_TEXTURE_COORDS 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
-#define GL_MAX_TEXTURE_UNITS 0x84E2
-#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
-#define GL_MAX_VARYING_COMPONENTS 0x8B4B
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_MIN 0x8007
-#define GL_MINOR_VERSION 0x821C
-#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_MODELVIEW 0x1700
-#define GL_MODELVIEW_MATRIX 0x0BA6
-#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
-#define GL_MODULATE 0x2100
-#define GL_MULT 0x0103
-#define GL_MULTISAMPLE 0x809D
-#define GL_MULTISAMPLE_ARB 0x809D
-#define GL_MULTISAMPLE_BIT 0x20000000
-#define GL_MULTISAMPLE_BIT_ARB 0x20000000
-#define GL_N3F_V3F 0x2A25
-#define GL_NAME_STACK_DEPTH 0x0D70
-#define GL_NAND 0x150E
-#define GL_NEAREST 0x2600
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_NEVER 0x0200
-#define GL_NICEST 0x1102
-#define GL_NONE 0
-#define GL_NOOP 0x1505
-#define GL_NOR 0x1508
-#define GL_NORMALIZE 0x0BA1
-#define GL_NORMAL_ARRAY 0x8075
-#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
-#define GL_NORMAL_ARRAY_POINTER 0x808F
-#define GL_NORMAL_ARRAY_STRIDE 0x807F
-#define GL_NORMAL_ARRAY_TYPE 0x807E
-#define GL_NORMAL_MAP 0x8511
-#define GL_NOTEQUAL 0x0205
-#define GL_NO_ERROR 0
-#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_OBJECT_LINEAR 0x2401
-#define GL_OBJECT_PLANE 0x2501
-#define GL_OBJECT_TYPE 0x9112
-#define GL_ONE 1
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
-#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_OPERAND0_ALPHA 0x8598
-#define GL_OPERAND0_RGB 0x8590
-#define GL_OPERAND1_ALPHA 0x8599
-#define GL_OPERAND1_RGB 0x8591
-#define GL_OPERAND2_ALPHA 0x859A
-#define GL_OPERAND2_RGB 0x8592
-#define GL_OR 0x1507
-#define GL_ORDER 0x0A01
-#define GL_OR_INVERTED 0x150D
-#define GL_OR_REVERSE 0x150B
-#define GL_OUT_OF_MEMORY 0x0505
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_PACK_LSB_FIRST 0x0D01
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SWAP_BYTES 0x0D00
-#define GL_PASS_THROUGH_TOKEN 0x0700
-#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
-#define GL_PIXEL_MAP_A_TO_A 0x0C79
-#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
-#define GL_PIXEL_MAP_B_TO_B 0x0C78
-#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
-#define GL_PIXEL_MAP_G_TO_G 0x0C77
-#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
-#define GL_PIXEL_MAP_I_TO_A 0x0C75
-#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
-#define GL_PIXEL_MAP_I_TO_B 0x0C74
-#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
-#define GL_PIXEL_MAP_I_TO_G 0x0C73
-#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
-#define GL_PIXEL_MAP_I_TO_I 0x0C70
-#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
-#define GL_PIXEL_MAP_I_TO_R 0x0C72
-#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
-#define GL_PIXEL_MAP_R_TO_R 0x0C76
-#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
-#define GL_PIXEL_MAP_S_TO_S 0x0C71
-#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
-#define GL_PIXEL_MODE_BIT 0x00000020
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
-#define GL_POINT 0x1B00
-#define GL_POINTS 0x0000
-#define GL_POINT_BIT 0x00000002
-#define GL_POINT_DISTANCE_ATTENUATION 0x8129
-#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
-#define GL_POINT_SIZE 0x0B11
-#define GL_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_POINT_SIZE_MAX 0x8127
-#define GL_POINT_SIZE_MIN 0x8126
-#define GL_POINT_SIZE_RANGE 0x0B12
-#define GL_POINT_SMOOTH 0x0B10
-#define GL_POINT_SMOOTH_HINT 0x0C51
-#define GL_POINT_SPRITE 0x8861
-#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
-#define GL_POINT_TOKEN 0x0701
-#define GL_POLYGON 0x0009
-#define GL_POLYGON_BIT 0x00000008
-#define GL_POLYGON_MODE 0x0B40
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_POLYGON_OFFSET_LINE 0x2A02
-#define GL_POLYGON_OFFSET_POINT 0x2A01
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-#define GL_POLYGON_SMOOTH 0x0B41
-#define GL_POLYGON_SMOOTH_HINT 0x0C53
-#define GL_POLYGON_STIPPLE 0x0B42
-#define GL_POLYGON_STIPPLE_BIT 0x00000010
-#define GL_POLYGON_TOKEN 0x0703
-#define GL_POSITION 0x1203
-#define GL_PREVIOUS 0x8578
-#define GL_PRIMARY_COLOR 0x8577
-#define GL_PRIMITIVES_GENERATED 0x8C87
-#define GL_PRIMITIVE_RESTART 0x8F9D
-#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
-#define GL_PROGRAM 0x82E2
-#define GL_PROGRAM_PIPELINE 0x82E4
-#define GL_PROGRAM_POINT_SIZE 0x8642
-#define GL_PROJECTION 0x1701
-#define GL_PROJECTION_MATRIX 0x0BA7
-#define GL_PROJECTION_STACK_DEPTH 0x0BA4
-#define GL_PROVOKING_VERTEX 0x8E4F
-#define GL_PROXY_TEXTURE_1D 0x8063
-#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
-#define GL_PROXY_TEXTURE_2D 0x8064
-#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
-#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
-#define GL_Q 0x2003
-#define GL_QUADRATIC_ATTENUATION 0x1209
-#define GL_QUADS 0x0007
-#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
-#define GL_QUAD_STRIP 0x0008
-#define GL_QUERY 0x82E3
-#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
-#define GL_QUERY_BY_REGION_WAIT 0x8E15
-#define GL_QUERY_COUNTER_BITS 0x8864
-#define GL_QUERY_NO_WAIT 0x8E14
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_QUERY_WAIT 0x8E13
-#define GL_R 0x2002
-#define GL_R11F_G11F_B10F 0x8C3A
-#define GL_R16 0x822A
-#define GL_R16F 0x822D
-#define GL_R16I 0x8233
-#define GL_R16UI 0x8234
-#define GL_R16_SNORM 0x8F98
-#define GL_R32F 0x822E
-#define GL_R32I 0x8235
-#define GL_R32UI 0x8236
-#define GL_R3_G3_B2 0x2A10
-#define GL_R8 0x8229
-#define GL_R8I 0x8231
-#define GL_R8UI 0x8232
-#define GL_R8_SNORM 0x8F94
-#define GL_RASTERIZER_DISCARD 0x8C89
-#define GL_READ_BUFFER 0x0C02
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
-#define GL_READ_ONLY 0x88B8
-#define GL_READ_WRITE 0x88BA
-#define GL_RED 0x1903
-#define GL_RED_BIAS 0x0D15
-#define GL_RED_BITS 0x0D52
-#define GL_RED_INTEGER 0x8D94
-#define GL_RED_SCALE 0x0D14
-#define GL_REFLECTION_MAP 0x8512
-#define GL_RENDER 0x1C00
-#define GL_RENDERBUFFER 0x8D41
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_SAMPLES 0x8CAB
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERER 0x1F01
-#define GL_RENDER_MODE 0x0C40
-#define GL_REPEAT 0x2901
-#define GL_REPLACE 0x1E01
-#define GL_RESCALE_NORMAL 0x803A
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_RETURN 0x0102
-#define GL_RG 0x8227
-#define GL_RG16 0x822C
-#define GL_RG16F 0x822F
-#define GL_RG16I 0x8239
-#define GL_RG16UI 0x823A
-#define GL_RG16_SNORM 0x8F99
-#define GL_RG32F 0x8230
-#define GL_RG32I 0x823B
-#define GL_RG32UI 0x823C
-#define GL_RG8 0x822B
-#define GL_RG8I 0x8237
-#define GL_RG8UI 0x8238
-#define GL_RG8_SNORM 0x8F95
-#define GL_RGB 0x1907
-#define GL_RGB10 0x8052
-#define GL_RGB10_A2 0x8059
-#define GL_RGB10_A2UI 0x906F
-#define GL_RGB12 0x8053
-#define GL_RGB16 0x8054
-#define GL_RGB16F 0x881B
-#define GL_RGB16I 0x8D89
-#define GL_RGB16UI 0x8D77
-#define GL_RGB16_SNORM 0x8F9A
-#define GL_RGB32F 0x8815
-#define GL_RGB32I 0x8D83
-#define GL_RGB32UI 0x8D71
-#define GL_RGB4 0x804F
-#define GL_RGB5 0x8050
-#define GL_RGB5_A1 0x8057
-#define GL_RGB8 0x8051
-#define GL_RGB8I 0x8D8F
-#define GL_RGB8UI 0x8D7D
-#define GL_RGB8_SNORM 0x8F96
-#define GL_RGB9_E5 0x8C3D
-#define GL_RGBA 0x1908
-#define GL_RGBA12 0x805A
-#define GL_RGBA16 0x805B
-#define GL_RGBA16F 0x881A
-#define GL_RGBA16I 0x8D88
-#define GL_RGBA16UI 0x8D76
-#define GL_RGBA16_SNORM 0x8F9B
-#define GL_RGBA2 0x8055
-#define GL_RGBA32F 0x8814
-#define GL_RGBA32I 0x8D82
-#define GL_RGBA32UI 0x8D70
-#define GL_RGBA4 0x8056
-#define GL_RGBA8 0x8058
-#define GL_RGBA8I 0x8D8E
-#define GL_RGBA8UI 0x8D7C
-#define GL_RGBA8_SNORM 0x8F97
-#define GL_RGBA_INTEGER 0x8D99
-#define GL_RGBA_MODE 0x0C31
-#define GL_RGB_INTEGER 0x8D98
-#define GL_RGB_SCALE 0x8573
-#define GL_RG_INTEGER 0x8228
-#define GL_RIGHT 0x0407
-#define GL_S 0x2000
-#define GL_SAMPLER 0x82E6
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_1D_ARRAY 0x8DC0
-#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
-#define GL_SAMPLER_1D_SHADOW 0x8B61
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
-#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
-#define GL_SAMPLER_2D_RECT 0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_BINDING 0x8919
-#define GL_SAMPLER_BUFFER 0x8DC2
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLES_ARB 0x80A9
-#define GL_SAMPLES_PASSED 0x8914
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLE_BUFFERS_ARB 0x80A8
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_COVERAGE_ARB 0x80A0
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
-#define GL_SAMPLE_MASK 0x8E51
-#define GL_SAMPLE_MASK_VALUE 0x8E52
-#define GL_SAMPLE_POSITION 0x8E50
-#define GL_SCISSOR_BIT 0x00080000
-#define GL_SCISSOR_BOX 0x0C10
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_SECONDARY_COLOR_ARRAY 0x845E
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
-#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
-#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
-#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
-#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
-#define GL_SELECT 0x1C02
-#define GL_SELECTION_BUFFER_POINTER 0x0DF3
-#define GL_SELECTION_BUFFER_SIZE 0x0DF4
-#define GL_SEPARATE_ATTRIBS 0x8C8D
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-#define GL_SET 0x150F
-#define GL_SHADER 0x82E1
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_SHADE_MODEL 0x0B54
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_SHININESS 0x1601
-#define GL_SHORT 0x1402
-#define GL_SIGNALED 0x9119
-#define GL_SIGNED_NORMALIZED 0x8F9C
-#define GL_SINGLE_COLOR 0x81F9
-#define GL_SLUMINANCE 0x8C46
-#define GL_SLUMINANCE8 0x8C47
-#define GL_SLUMINANCE8_ALPHA8 0x8C45
-#define GL_SLUMINANCE_ALPHA 0x8C44
-#define GL_SMOOTH 0x1D01
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SOURCE0_ALPHA 0x8588
-#define GL_SOURCE0_RGB 0x8580
-#define GL_SOURCE1_ALPHA 0x8589
-#define GL_SOURCE1_RGB 0x8581
-#define GL_SOURCE2_ALPHA 0x858A
-#define GL_SOURCE2_RGB 0x8582
-#define GL_SPECULAR 0x1202
-#define GL_SPHERE_MAP 0x2402
-#define GL_SPOT_CUTOFF 0x1206
-#define GL_SPOT_DIRECTION 0x1204
-#define GL_SPOT_EXPONENT 0x1205
-#define GL_SRC0_ALPHA 0x8588
-#define GL_SRC0_RGB 0x8580
-#define GL_SRC1_ALPHA 0x8589
-#define GL_SRC1_COLOR 0x88F9
-#define GL_SRC1_RGB 0x8581
-#define GL_SRC2_ALPHA 0x858A
-#define GL_SRC2_RGB 0x8582
-#define GL_SRC_ALPHA 0x0302
-#define GL_SRC_ALPHA_SATURATE 0x0308
-#define GL_SRC_COLOR 0x0300
-#define GL_SRGB 0x8C40
-#define GL_SRGB8 0x8C41
-#define GL_SRGB8_ALPHA8 0x8C43
-#define GL_SRGB_ALPHA 0x8C42
-#define GL_STACK_OVERFLOW 0x0503
-#define GL_STACK_UNDERFLOW 0x0504
-#define GL_STATIC_COPY 0x88E6
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STENCIL 0x1802
-#define GL_STENCIL_ATTACHMENT 0x8D20
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_STENCIL_BITS 0x0D57
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_INDEX 0x1901
-#define GL_STENCIL_INDEX1 0x8D46
-#define GL_STENCIL_INDEX16 0x8D49
-#define GL_STENCIL_INDEX4 0x8D47
-#define GL_STENCIL_INDEX8 0x8D48
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_TEST 0x0B90
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STEREO 0x0C33
-#define GL_STREAM_COPY 0x88E2
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_SUBTRACT 0x84E7
-#define GL_SYNC_CONDITION 0x9113
-#define GL_SYNC_FENCE 0x9116
-#define GL_SYNC_FLAGS 0x9115
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#define GL_SYNC_STATUS 0x9114
-#define GL_T 0x2001
-#define GL_T2F_C3F_V3F 0x2A2A
-#define GL_T2F_C4F_N3F_V3F 0x2A2C
-#define GL_T2F_C4UB_V3F 0x2A29
-#define GL_T2F_N3F_V3F 0x2A2B
-#define GL_T2F_V3F 0x2A27
-#define GL_T4F_C4F_N3F_V4F 0x2A2D
-#define GL_T4F_V4F 0x2A28
-#define GL_TEXTURE 0x1702
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE_1D 0x0DE0
-#define GL_TEXTURE_1D_ARRAY 0x8C18
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_TEXTURE_2D_ARRAY 0x8C1A
-#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
-#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
-#define GL_TEXTURE_3D 0x806F
-#define GL_TEXTURE_ALPHA_SIZE 0x805F
-#define GL_TEXTURE_ALPHA_TYPE 0x8C13
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_BINDING_1D 0x8068
-#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
-#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
-#define GL_TEXTURE_BIT 0x00040000
-#define GL_TEXTURE_BLUE_SIZE 0x805E
-#define GL_TEXTURE_BLUE_TYPE 0x8C12
-#define GL_TEXTURE_BORDER 0x1005
-#define GL_TEXTURE_BORDER_COLOR 0x1004
-#define GL_TEXTURE_BUFFER 0x8C2A
-#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPONENTS 0x1003
-#define GL_TEXTURE_COMPRESSED 0x86A1
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
-#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
-#define GL_TEXTURE_COORD_ARRAY 0x8078
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
-#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
-#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
-#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
-#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_DEPTH_SIZE 0x884A
-#define GL_TEXTURE_DEPTH_TYPE 0x8C16
-#define GL_TEXTURE_ENV 0x2300
-#define GL_TEXTURE_ENV_COLOR 0x2201
-#define GL_TEXTURE_ENV_MODE 0x2200
-#define GL_TEXTURE_FILTER_CONTROL 0x8500
-#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
-#define GL_TEXTURE_GEN_MODE 0x2500
-#define GL_TEXTURE_GEN_Q 0x0C63
-#define GL_TEXTURE_GEN_R 0x0C62
-#define GL_TEXTURE_GEN_S 0x0C60
-#define GL_TEXTURE_GEN_T 0x0C61
-#define GL_TEXTURE_GREEN_SIZE 0x805D
-#define GL_TEXTURE_GREEN_TYPE 0x8C11
-#define GL_TEXTURE_HEIGHT 0x1001
-#define GL_TEXTURE_INTENSITY_SIZE 0x8061
-#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
-#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
-#define GL_TEXTURE_LOD_BIAS 0x8501
-#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
-#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MATRIX 0x0BA8
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_PRIORITY 0x8066
-#define GL_TEXTURE_RECTANGLE 0x84F5
-#define GL_TEXTURE_RED_SIZE 0x805C
-#define GL_TEXTURE_RED_TYPE 0x8C10
-#define GL_TEXTURE_RESIDENT 0x8067
-#define GL_TEXTURE_SAMPLES 0x9106
-#define GL_TEXTURE_SHARED_SIZE 0x8C3F
-#define GL_TEXTURE_STACK_DEPTH 0x0BA5
-#define GL_TEXTURE_STENCIL_SIZE 0x88F1
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
-#define GL_TEXTURE_WIDTH 0x1000
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-#define GL_TIMEOUT_EXPIRED 0x911B
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
-#define GL_TIMESTAMP 0x8E28
-#define GL_TIME_ELAPSED 0x88BF
-#define GL_TRANSFORM_BIT 0x00001000
-#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
-#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
-#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
-#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLES_ADJACENCY 0x000C
-#define GL_TRIANGLE_FAN 0x0006
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
-#define GL_TRUE 1
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BUFFER 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING 0x8A28
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
-#define GL_UNIFORM_BUFFER_START 0x8A29
-#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#define GL_UNIFORM_NAME_LENGTH 0x8A39
-#define GL_UNIFORM_OFFSET 0x8A3B
-#define GL_UNIFORM_SIZE 0x8A38
-#define GL_UNIFORM_TYPE 0x8A37
-#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_UNPACK_LSB_FIRST 0x0CF1
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SWAP_BYTES 0x0CF0
-#define GL_UNSIGNALED 0x9118
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_INT 0x1405
-#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_UNSIGNED_INT_24_8 0x84FA
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
-#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
-#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
-#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#define GL_UNSIGNED_NORMALIZED 0x8C17
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UPPER_LEFT 0x8CA2
-#define GL_V2F 0x2A20
-#define GL_V3F 0x2A21
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_VENDOR 0x1F00
-#define GL_VERSION 0x1F02
-#define GL_VERTEX_ARRAY 0x8074
-#define GL_VERTEX_ARRAY_BINDING 0x85B5
-#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
-#define GL_VERTEX_ARRAY_POINTER 0x808E
-#define GL_VERTEX_ARRAY_SIZE 0x807A
-#define GL_VERTEX_ARRAY_STRIDE 0x807C
-#define GL_VERTEX_ARRAY_TYPE 0x807B
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_VIEWPORT 0x0BA2
-#define GL_VIEWPORT_BIT 0x00000800
-#define GL_WAIT_FAILED 0x911D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
-#define GL_WRITE_ONLY 0x88B9
-#define GL_XOR 0x1506
-#define GL_ZERO 0
-#define GL_ZOOM_X 0x0D16
-#define GL_ZOOM_Y 0x0D17
-
-
-#include <glad/khrplatform.h>
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef void GLvoid;
-typedef khronos_int8_t GLbyte;
-typedef khronos_uint8_t GLubyte;
-typedef khronos_int16_t GLshort;
-typedef khronos_uint16_t GLushort;
-typedef int GLint;
-typedef unsigned int GLuint;
-typedef khronos_int32_t GLclampx;
-typedef int GLsizei;
-typedef khronos_float_t GLfloat;
-typedef khronos_float_t GLclampf;
-typedef double GLdouble;
-typedef double GLclampd;
-typedef void *GLeglClientBufferEXT;
-typedef void *GLeglImageOES;
-typedef char GLchar;
-typedef char GLcharARB;
-#ifdef __APPLE__
-typedef void *GLhandleARB;
-#else
-typedef unsigned int GLhandleARB;
-#endif
-typedef khronos_uint16_t GLhalf;
-typedef khronos_uint16_t GLhalfARB;
-typedef khronos_int32_t GLfixed;
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_intptr_t GLintptr;
-#else
-typedef khronos_intptr_t GLintptr;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_intptr_t GLintptrARB;
-#else
-typedef khronos_intptr_t GLintptrARB;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_ssize_t GLsizeiptr;
-#else
-typedef khronos_ssize_t GLsizeiptr;
-#endif
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
-typedef khronos_ssize_t GLsizeiptrARB;
-#else
-typedef khronos_ssize_t GLsizeiptrARB;
-#endif
-typedef khronos_int64_t GLint64;
-typedef khronos_int64_t GLint64EXT;
-typedef khronos_uint64_t GLuint64;
-typedef khronos_uint64_t GLuint64EXT;
-typedef struct __GLsync *GLsync;
-struct _cl_context;
-struct _cl_event;
-typedef void ( *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
-typedef void ( *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
-typedef unsigned short GLhalfNV;
-typedef GLintptr GLvdpauSurfaceNV;
-typedef void ( *GLVULKANPROCNV)(void);
-
-
-#define GL_VERSION_1_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_0;
-#define GL_VERSION_1_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_1;
-#define GL_VERSION_1_2 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_2;
-#define GL_VERSION_1_3 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_3;
-#define GL_VERSION_1_4 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_4;
-#define GL_VERSION_1_5 1
-GLAD_API_CALL int GLAD_GL_VERSION_1_5;
-#define GL_VERSION_2_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_2_0;
-#define GL_VERSION_2_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_2_1;
-#define GL_VERSION_3_0 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_0;
-#define GL_VERSION_3_1 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_1;
-#define GL_VERSION_3_2 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_2;
-#define GL_VERSION_3_3 1
-GLAD_API_CALL int GLAD_GL_VERSION_3_3;
-#define GL_ARB_multisample 1
-GLAD_API_CALL int GLAD_GL_ARB_multisample;
-#define GL_ARB_robustness 1
-GLAD_API_CALL int GLAD_GL_ARB_robustness;
-#define GL_KHR_debug 1
-GLAD_API_CALL int GLAD_GL_KHR_debug;
-
-
-typedef void (GLAD_API_PTR *PFNGLACCUMPROC)(GLenum   op, GLfloat   value);
-typedef void (GLAD_API_PTR *PFNGLACTIVETEXTUREPROC)(GLenum   texture);
-typedef void (GLAD_API_PTR *PFNGLALPHAFUNCPROC)(GLenum   func, GLfloat   ref);
-typedef GLboolean (GLAD_API_PTR *PFNGLARETEXTURESRESIDENTPROC)(GLsizei   n, const  GLuint  * textures, GLboolean  * residences);
-typedef void (GLAD_API_PTR *PFNGLARRAYELEMENTPROC)(GLint   i);
-typedef void (GLAD_API_PTR *PFNGLATTACHSHADERPROC)(GLuint   program, GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLBEGINPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBEGINCONDITIONALRENDERPROC)(GLuint   id, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBEGINQUERYPROC)(GLenum   target, GLuint   id);
-typedef void (GLAD_API_PTR *PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum   primitiveMode);
-typedef void (GLAD_API_PTR *PFNGLBINDATTRIBLOCATIONPROC)(GLuint   program, GLuint   index, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERPROC)(GLenum   target, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERBASEPROC)(GLenum   target, GLuint   index, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLBINDBUFFERRANGEPROC)(GLenum   target, GLuint   index, GLuint   buffer, GLintptr   offset, GLsizeiptr   size);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONPROC)(GLuint   program, GLuint   color, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint   program, GLuint   colorNumber, GLuint   index, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLBINDFRAMEBUFFERPROC)(GLenum   target, GLuint   framebuffer);
-typedef void (GLAD_API_PTR *PFNGLBINDRENDERBUFFERPROC)(GLenum   target, GLuint   renderbuffer);
-typedef void (GLAD_API_PTR *PFNGLBINDSAMPLERPROC)(GLuint   unit, GLuint   sampler);
-typedef void (GLAD_API_PTR *PFNGLBINDTEXTUREPROC)(GLenum   target, GLuint   texture);
-typedef void (GLAD_API_PTR *PFNGLBINDVERTEXARRAYPROC)(GLuint   array);
-typedef void (GLAD_API_PTR *PFNGLBITMAPPROC)(GLsizei   width, GLsizei   height, GLfloat   xorig, GLfloat   yorig, GLfloat   xmove, GLfloat   ymove, const  GLubyte  * bitmap);
-typedef void (GLAD_API_PTR *PFNGLBLENDCOLORPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum   modeRGB, GLenum   modeAlpha);
-typedef void (GLAD_API_PTR *PFNGLBLENDFUNCPROC)(GLenum   sfactor, GLenum   dfactor);
-typedef void (GLAD_API_PTR *PFNGLBLENDFUNCSEPARATEPROC)(GLenum   sfactorRGB, GLenum   dfactorRGB, GLenum   sfactorAlpha, GLenum   dfactorAlpha);
-typedef void (GLAD_API_PTR *PFNGLBLITFRAMEBUFFERPROC)(GLint   srcX0, GLint   srcY0, GLint   srcX1, GLint   srcY1, GLint   dstX0, GLint   dstY0, GLint   dstX1, GLint   dstY1, GLbitfield   mask, GLenum   filter);
-typedef void (GLAD_API_PTR *PFNGLBUFFERDATAPROC)(GLenum   target, GLsizeiptr   size, const void * data, GLenum   usage);
-typedef void (GLAD_API_PTR *PFNGLBUFFERSUBDATAPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   size, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCALLLISTPROC)(GLuint   list);
-typedef void (GLAD_API_PTR *PFNGLCALLLISTSPROC)(GLsizei   n, GLenum   type, const void * lists);
-typedef GLenum (GLAD_API_PTR *PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLCLAMPCOLORPROC)(GLenum   target, GLenum   clamp);
-typedef void (GLAD_API_PTR *PFNGLCLEARPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLCLEARACCUMPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFIPROC)(GLenum   buffer, GLint   drawbuffer, GLfloat   depth, GLint   stencil);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERFVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERIVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARBUFFERUIVPROC)(GLenum   buffer, GLint   drawbuffer, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLCLEARCOLORPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCLEARDEPTHPROC)(GLdouble   depth);
-typedef void (GLAD_API_PTR *PFNGLCLEARINDEXPROC)(GLfloat   c);
-typedef void (GLAD_API_PTR *PFNGLCLEARSTENCILPROC)(GLint   s);
-typedef void (GLAD_API_PTR *PFNGLCLIENTACTIVETEXTUREPROC)(GLenum   texture);
-typedef GLenum (GLAD_API_PTR *PFNGLCLIENTWAITSYNCPROC)(GLsync   sync, GLbitfield   flags, GLuint64   timeout);
-typedef void (GLAD_API_PTR *PFNGLCLIPPLANEPROC)(GLenum   plane, const  GLdouble  * equation);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3IPROC)(GLint   red, GLint   green, GLint   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3SPROC)(GLshort   red, GLshort   green, GLshort   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UIPROC)(GLuint   red, GLuint   green, GLuint   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3USPROC)(GLushort   red, GLushort   green, GLushort   blue);
-typedef void (GLAD_API_PTR *PFNGLCOLOR3USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue, GLbyte   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue, GLdouble   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue, GLfloat   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4IPROC)(GLint   red, GLint   green, GLint   blue, GLint   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4SPROC)(GLshort   red, GLshort   green, GLshort   blue, GLshort   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue, GLubyte   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UIPROC)(GLuint   red, GLuint   green, GLuint   blue, GLuint   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4USPROC)(GLushort   red, GLushort   green, GLushort   blue, GLushort   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLOR4USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLCOLORMASKPROC)(GLboolean   red, GLboolean   green, GLboolean   blue, GLboolean   alpha);
-typedef void (GLAD_API_PTR *PFNGLCOLORMASKIPROC)(GLuint   index, GLboolean   r, GLboolean   g, GLboolean   b, GLboolean   a);
-typedef void (GLAD_API_PTR *PFNGLCOLORMATERIALPROC)(GLenum   face, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLCOLORP3UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP3UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP4UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLCOLORP4UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLCOLORPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLCOMPILESHADERPROC)(GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLsizei   height, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLint   border, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLsizei   width, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLsizei   width, GLsizei   height, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLsizei   width, GLsizei   height, GLsizei   depth, GLenum   format, GLsizei   imageSize, const void * data);
-typedef void (GLAD_API_PTR *PFNGLCOPYBUFFERSUBDATAPROC)(GLenum   readTarget, GLenum   writeTarget, GLintptr   readOffset, GLintptr   writeOffset, GLsizeiptr   size);
-typedef void (GLAD_API_PTR *PFNGLCOPYPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   type);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLint   x, GLint   y, GLsizei   width, GLint   border);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLenum   internalformat, GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLint   border);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   x, GLint   y, GLsizei   width);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef GLuint (GLAD_API_PTR *PFNGLCREATEPROGRAMPROC)(void);
-typedef GLuint (GLAD_API_PTR *PFNGLCREATESHADERPROC)(GLenum   type);
-typedef void (GLAD_API_PTR *PFNGLCULLFACEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC   callback, const void * userParam);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGECONTROLPROC)(GLenum   source, GLenum   type, GLenum   severity, GLsizei   count, const  GLuint  * ids, GLboolean   enabled);
-typedef void (GLAD_API_PTR *PFNGLDEBUGMESSAGEINSERTPROC)(GLenum   source, GLenum   type, GLuint   id, GLenum   severity, GLsizei   length, const  GLchar  * buf);
-typedef void (GLAD_API_PTR *PFNGLDELETEBUFFERSPROC)(GLsizei   n, const  GLuint  * buffers);
-typedef void (GLAD_API_PTR *PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei   n, const  GLuint  * framebuffers);
-typedef void (GLAD_API_PTR *PFNGLDELETELISTSPROC)(GLuint   list, GLsizei   range);
-typedef void (GLAD_API_PTR *PFNGLDELETEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLDELETEQUERIESPROC)(GLsizei   n, const  GLuint  * ids);
-typedef void (GLAD_API_PTR *PFNGLDELETERENDERBUFFERSPROC)(GLsizei   n, const  GLuint  * renderbuffers);
-typedef void (GLAD_API_PTR *PFNGLDELETESAMPLERSPROC)(GLsizei   count, const  GLuint  * samplers);
-typedef void (GLAD_API_PTR *PFNGLDELETESHADERPROC)(GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLDELETESYNCPROC)(GLsync   sync);
-typedef void (GLAD_API_PTR *PFNGLDELETETEXTURESPROC)(GLsizei   n, const  GLuint  * textures);
-typedef void (GLAD_API_PTR *PFNGLDELETEVERTEXARRAYSPROC)(GLsizei   n, const  GLuint  * arrays);
-typedef void (GLAD_API_PTR *PFNGLDEPTHFUNCPROC)(GLenum   func);
-typedef void (GLAD_API_PTR *PFNGLDEPTHMASKPROC)(GLboolean   flag);
-typedef void (GLAD_API_PTR *PFNGLDEPTHRANGEPROC)(GLdouble   n, GLdouble   f);
-typedef void (GLAD_API_PTR *PFNGLDETACHSHADERPROC)(GLuint   program, GLuint   shader);
-typedef void (GLAD_API_PTR *PFNGLDISABLEPROC)(GLenum   cap);
-typedef void (GLAD_API_PTR *PFNGLDISABLECLIENTSTATEPROC)(GLenum   array);
-typedef void (GLAD_API_PTR *PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLDISABLEIPROC)(GLenum   target, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSPROC)(GLenum   mode, GLint   first, GLsizei   count);
-typedef void (GLAD_API_PTR *PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum   mode, GLint   first, GLsizei   count, GLsizei   instancecount);
-typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERPROC)(GLenum   buf);
-typedef void (GLAD_API_PTR *PFNGLDRAWBUFFERSPROC)(GLsizei   n, const  GLenum  * bufs);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLsizei   instancecount);
-typedef void (GLAD_API_PTR *PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum   mode, GLsizei   count, GLenum   type, const void * indices, GLsizei   instancecount, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLDRAWPIXELSPROC)(GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSPROC)(GLenum   mode, GLuint   start, GLuint   end, GLsizei   count, GLenum   type, const void * indices);
-typedef void (GLAD_API_PTR *PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum   mode, GLuint   start, GLuint   end, GLsizei   count, GLenum   type, const void * indices, GLint   basevertex);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPROC)(GLboolean   flag);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGPOINTERPROC)(GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLEDGEFLAGVPROC)(const  GLboolean  * flag);
-typedef void (GLAD_API_PTR *PFNGLENABLEPROC)(GLenum   cap);
-typedef void (GLAD_API_PTR *PFNGLENABLECLIENTSTATEPROC)(GLenum   array);
-typedef void (GLAD_API_PTR *PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLENABLEIPROC)(GLenum   target, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLENDPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDCONDITIONALRENDERPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDLISTPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLENDQUERYPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLENDTRANSFORMFEEDBACKPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DPROC)(GLdouble   u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1DVPROC)(const  GLdouble  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FPROC)(GLfloat   u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD1FVPROC)(const  GLfloat  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DPROC)(GLdouble   u, GLdouble   v);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2DVPROC)(const  GLdouble  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FPROC)(GLfloat   u, GLfloat   v);
-typedef void (GLAD_API_PTR *PFNGLEVALCOORD2FVPROC)(const  GLfloat  * u);
-typedef void (GLAD_API_PTR *PFNGLEVALMESH1PROC)(GLenum   mode, GLint   i1, GLint   i2);
-typedef void (GLAD_API_PTR *PFNGLEVALMESH2PROC)(GLenum   mode, GLint   i1, GLint   i2, GLint   j1, GLint   j2);
-typedef void (GLAD_API_PTR *PFNGLEVALPOINT1PROC)(GLint   i);
-typedef void (GLAD_API_PTR *PFNGLEVALPOINT2PROC)(GLint   i, GLint   j);
-typedef void (GLAD_API_PTR *PFNGLFEEDBACKBUFFERPROC)(GLsizei   size, GLenum   type, GLfloat  * buffer);
-typedef GLsync (GLAD_API_PTR *PFNGLFENCESYNCPROC)(GLenum   condition, GLbitfield   flags);
-typedef void (GLAD_API_PTR *PFNGLFINISHPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLFLUSHPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   length);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDDPROC)(GLdouble   coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDDVPROC)(const  GLdouble  * coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDFPROC)(GLfloat   coord);
-typedef void (GLAD_API_PTR *PFNGLFOGCOORDFVPROC)(const  GLfloat  * coord);
-typedef void (GLAD_API_PTR *PFNGLFOGFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLFOGFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLFOGIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLFOGIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum   target, GLenum   attachment, GLenum   renderbuffertarget, GLuint   renderbuffer);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum   target, GLenum   attachment, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum   target, GLenum   attachment, GLenum   textarget, GLuint   texture, GLint   level, GLint   zoffset);
-typedef void (GLAD_API_PTR *PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum   target, GLenum   attachment, GLuint   texture, GLint   level, GLint   layer);
-typedef void (GLAD_API_PTR *PFNGLFRONTFACEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLFRUSTUMPROC)(GLdouble   left, GLdouble   right, GLdouble   bottom, GLdouble   top, GLdouble   zNear, GLdouble   zFar);
-typedef void (GLAD_API_PTR *PFNGLGENBUFFERSPROC)(GLsizei   n, GLuint  * buffers);
-typedef void (GLAD_API_PTR *PFNGLGENFRAMEBUFFERSPROC)(GLsizei   n, GLuint  * framebuffers);
-typedef GLuint (GLAD_API_PTR *PFNGLGENLISTSPROC)(GLsizei   range);
-typedef void (GLAD_API_PTR *PFNGLGENQUERIESPROC)(GLsizei   n, GLuint  * ids);
-typedef void (GLAD_API_PTR *PFNGLGENRENDERBUFFERSPROC)(GLsizei   n, GLuint  * renderbuffers);
-typedef void (GLAD_API_PTR *PFNGLGENSAMPLERSPROC)(GLsizei   count, GLuint  * samplers);
-typedef void (GLAD_API_PTR *PFNGLGENTEXTURESPROC)(GLsizei   n, GLuint  * textures);
-typedef void (GLAD_API_PTR *PFNGLGENVERTEXARRAYSPROC)(GLsizei   n, GLuint  * arrays);
-typedef void (GLAD_API_PTR *PFNGLGENERATEMIPMAPPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEATTRIBPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLint  * size, GLenum  * type, GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLint  * size, GLenum  * type, GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint   program, GLuint   uniformBlockIndex, GLsizei   bufSize, GLsizei  * length, GLchar  * uniformBlockName);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint   program, GLuint   uniformBlockIndex, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint   program, GLuint   uniformIndex, GLsizei   bufSize, GLsizei  * length, GLchar  * uniformName);
-typedef void (GLAD_API_PTR *PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint   program, GLsizei   uniformCount, const  GLuint  * uniformIndices, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETATTACHEDSHADERSPROC)(GLuint   program, GLsizei   maxCount, GLsizei  * count, GLuint  * shaders);
-typedef GLint (GLAD_API_PTR *PFNGLGETATTRIBLOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETBOOLEANI_VPROC)(GLenum   target, GLuint   index, GLboolean  * data);
-typedef void (GLAD_API_PTR *PFNGLGETBOOLEANVPROC)(GLenum   pname, GLboolean  * data);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum   target, GLenum   pname, GLint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERPOINTERVPROC)(GLenum   target, GLenum   pname, void ** params);
-typedef void (GLAD_API_PTR *PFNGLGETBUFFERSUBDATAPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   size, void * data);
-typedef void (GLAD_API_PTR *PFNGLGETCLIPPLANEPROC)(GLenum   plane, GLdouble  * equation);
-typedef void (GLAD_API_PTR *PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum   target, GLint   level, void * img);
-typedef GLuint (GLAD_API_PTR *PFNGLGETDEBUGMESSAGELOGPROC)(GLuint   count, GLsizei   bufSize, GLenum  * sources, GLenum  * types, GLuint  * ids, GLenum  * severities, GLsizei  * lengths, GLchar  * messageLog);
-typedef void (GLAD_API_PTR *PFNGLGETDOUBLEVPROC)(GLenum   pname, GLdouble  * data);
-typedef GLenum (GLAD_API_PTR *PFNGLGETERRORPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLGETFLOATVPROC)(GLenum   pname, GLfloat  * data);
-typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATAINDEXPROC)(GLuint   program, const  GLchar  * name);
-typedef GLint (GLAD_API_PTR *PFNGLGETFRAGDATALOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum   target, GLenum   attachment, GLenum   pname, GLint  * params);
-typedef GLenum (GLAD_API_PTR *PFNGLGETGRAPHICSRESETSTATUSARBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGER64I_VPROC)(GLenum   target, GLuint   index, GLint64  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGER64VPROC)(GLenum   pname, GLint64  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGERI_VPROC)(GLenum   target, GLuint   index, GLint  * data);
-typedef void (GLAD_API_PTR *PFNGLGETINTEGERVPROC)(GLenum   pname, GLint  * data);
-typedef void (GLAD_API_PTR *PFNGLGETLIGHTFVPROC)(GLenum   light, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETLIGHTIVPROC)(GLenum   light, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMAPDVPROC)(GLenum   target, GLenum   query, GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMAPFVPROC)(GLenum   target, GLenum   query, GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMAPIVPROC)(GLenum   target, GLenum   query, GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLGETMATERIALFVPROC)(GLenum   face, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMATERIALIVPROC)(GLenum   face, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETMULTISAMPLEFVPROC)(GLenum   pname, GLuint   index, GLfloat  * val);
-typedef void (GLAD_API_PTR *PFNGLGETOBJECTLABELPROC)(GLenum   identifier, GLuint   name, GLsizei   bufSize, GLsizei  * length, GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLGETOBJECTPTRLABELPROC)(const void * ptr, GLsizei   bufSize, GLsizei  * length, GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPFVPROC)(GLenum   map, GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUIVPROC)(GLenum   map, GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPIXELMAPUSVPROC)(GLenum   map, GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLGETPOINTERVPROC)(GLenum   pname, void ** params);
-typedef void (GLAD_API_PTR *PFNGLGETPOLYGONSTIPPLEPROC)(GLubyte  * mask);
-typedef void (GLAD_API_PTR *PFNGLGETPROGRAMINFOLOGPROC)(GLuint   program, GLsizei   bufSize, GLsizei  * length, GLchar  * infoLog);
-typedef void (GLAD_API_PTR *PFNGLGETPROGRAMIVPROC)(GLuint   program, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTI64VPROC)(GLuint   id, GLenum   pname, GLint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTIVPROC)(GLuint   id, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUI64VPROC)(GLuint   id, GLenum   pname, GLuint64  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYOBJECTUIVPROC)(GLuint   id, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETQUERYIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint   sampler, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint   sampler, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint   sampler, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint   sampler, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERINFOLOGPROC)(GLuint   shader, GLsizei   bufSize, GLsizei  * length, GLchar  * infoLog);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERSOURCEPROC)(GLuint   shader, GLsizei   bufSize, GLsizei  * length, GLchar  * source);
-typedef void (GLAD_API_PTR *PFNGLGETSHADERIVPROC)(GLuint   shader, GLenum   pname, GLint  * params);
-typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGPROC)(GLenum   name);
-typedef const GLubyte * (GLAD_API_PTR *PFNGLGETSTRINGIPROC)(GLenum   name, GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLGETSYNCIVPROC)(GLsync   sync, GLenum   pname, GLsizei   bufSize, GLsizei  * length, GLint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETTEXENVFVPROC)(GLenum   target, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXENVIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENDVPROC)(GLenum   coord, GLenum   pname, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENFVPROC)(GLenum   coord, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXGENIVPROC)(GLenum   coord, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXIMAGEPROC)(GLenum   target, GLint   level, GLenum   format, GLenum   type, void * pixels);
-typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum   target, GLint   level, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum   target, GLint   level, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIUIVPROC)(GLenum   target, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERFVPROC)(GLenum   target, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTEXPARAMETERIVPROC)(GLenum   target, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint   program, GLuint   index, GLsizei   bufSize, GLsizei  * length, GLsizei  * size, GLenum  * type, GLchar  * name);
-typedef GLuint (GLAD_API_PTR *PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint   program, const  GLchar  * uniformBlockName);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMINDICESPROC)(GLuint   program, GLsizei   uniformCount, const  GLchar  *const* uniformNames, GLuint  * uniformIndices);
-typedef GLint (GLAD_API_PTR *PFNGLGETUNIFORMLOCATIONPROC)(GLuint   program, const  GLchar  * name);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMFVPROC)(GLuint   program, GLint   location, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMIVPROC)(GLuint   program, GLint   location, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETUNIFORMUIVPROC)(GLuint   program, GLint   location, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIIVPROC)(GLuint   index, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint   index, GLenum   pname, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint   index, GLenum   pname, void ** pointer);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBDVPROC)(GLuint   index, GLenum   pname, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBFVPROC)(GLuint   index, GLenum   pname, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETVERTEXATTRIBIVPROC)(GLuint   index, GLenum   pname, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNCOLORTABLEARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   bufSize, void * table);
-typedef void (GLAD_API_PTR *PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC)(GLenum   target, GLint   lod, GLsizei   bufSize, void * img);
-typedef void (GLAD_API_PTR *PFNGLGETNCONVOLUTIONFILTERARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   bufSize, void * image);
-typedef void (GLAD_API_PTR *PFNGLGETNHISTOGRAMARBPROC)(GLenum   target, GLboolean   reset, GLenum   format, GLenum   type, GLsizei   bufSize, void * values);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPDVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPFVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMAPIVARBPROC)(GLenum   target, GLenum   query, GLsizei   bufSize, GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLGETNMINMAXARBPROC)(GLenum   target, GLboolean   reset, GLenum   format, GLenum   type, GLsizei   bufSize, void * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPFVARBPROC)(GLenum   map, GLsizei   bufSize, GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUIVARBPROC)(GLenum   map, GLsizei   bufSize, GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPIXELMAPUSVARBPROC)(GLenum   map, GLsizei   bufSize, GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLGETNPOLYGONSTIPPLEARBPROC)(GLsizei   bufSize, GLubyte  * pattern);
-typedef void (GLAD_API_PTR *PFNGLGETNSEPARABLEFILTERARBPROC)(GLenum   target, GLenum   format, GLenum   type, GLsizei   rowBufSize, void * row, GLsizei   columnBufSize, void * column, void * span);
-typedef void (GLAD_API_PTR *PFNGLGETNTEXIMAGEARBPROC)(GLenum   target, GLint   level, GLenum   format, GLenum   type, GLsizei   bufSize, void * img);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMDVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMFVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMIVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLGETNUNIFORMUIVARBPROC)(GLuint   program, GLint   location, GLsizei   bufSize, GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLHINTPROC)(GLenum   target, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLINDEXMASKPROC)(GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLINDEXPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLINDEXDPROC)(GLdouble   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXDVPROC)(const  GLdouble  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXFPROC)(GLfloat   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXFVPROC)(const  GLfloat  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXIPROC)(GLint   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXIVPROC)(const  GLint  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXSPROC)(GLshort   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXSVPROC)(const  GLshort  * c);
-typedef void (GLAD_API_PTR *PFNGLINDEXUBPROC)(GLubyte   c);
-typedef void (GLAD_API_PTR *PFNGLINDEXUBVPROC)(const  GLubyte  * c);
-typedef void (GLAD_API_PTR *PFNGLINITNAMESPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLINTERLEAVEDARRAYSPROC)(GLenum   format, GLsizei   stride, const void * pointer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISBUFFERPROC)(GLuint   buffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDPROC)(GLenum   cap);
-typedef GLboolean (GLAD_API_PTR *PFNGLISENABLEDIPROC)(GLenum   target, GLuint   index);
-typedef GLboolean (GLAD_API_PTR *PFNGLISFRAMEBUFFERPROC)(GLuint   framebuffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISLISTPROC)(GLuint   list);
-typedef GLboolean (GLAD_API_PTR *PFNGLISPROGRAMPROC)(GLuint   program);
-typedef GLboolean (GLAD_API_PTR *PFNGLISQUERYPROC)(GLuint   id);
-typedef GLboolean (GLAD_API_PTR *PFNGLISRENDERBUFFERPROC)(GLuint   renderbuffer);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSAMPLERPROC)(GLuint   sampler);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSHADERPROC)(GLuint   shader);
-typedef GLboolean (GLAD_API_PTR *PFNGLISSYNCPROC)(GLsync   sync);
-typedef GLboolean (GLAD_API_PTR *PFNGLISTEXTUREPROC)(GLuint   texture);
-typedef GLboolean (GLAD_API_PTR *PFNGLISVERTEXARRAYPROC)(GLuint   array);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTMODELIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTFPROC)(GLenum   light, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTFVPROC)(GLenum   light, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLLIGHTIPROC)(GLenum   light, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLLIGHTIVPROC)(GLenum   light, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLLINESTIPPLEPROC)(GLint   factor, GLushort   pattern);
-typedef void (GLAD_API_PTR *PFNGLLINEWIDTHPROC)(GLfloat   width);
-typedef void (GLAD_API_PTR *PFNGLLINKPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLLISTBASEPROC)(GLuint   base);
-typedef void (GLAD_API_PTR *PFNGLLOADIDENTITYPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLLOADMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADNAMEPROC)(GLuint   name);
-typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLLOADTRANSPOSEMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLLOGICOPPROC)(GLenum   opcode);
-typedef void (GLAD_API_PTR *PFNGLMAP1DPROC)(GLenum   target, GLdouble   u1, GLdouble   u2, GLint   stride, GLint   order, const  GLdouble  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP1FPROC)(GLenum   target, GLfloat   u1, GLfloat   u2, GLint   stride, GLint   order, const  GLfloat  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP2DPROC)(GLenum   target, GLdouble   u1, GLdouble   u2, GLint   ustride, GLint   uorder, GLdouble   v1, GLdouble   v2, GLint   vstride, GLint   vorder, const  GLdouble  * points);
-typedef void (GLAD_API_PTR *PFNGLMAP2FPROC)(GLenum   target, GLfloat   u1, GLfloat   u2, GLint   ustride, GLint   uorder, GLfloat   v1, GLfloat   v2, GLint   vstride, GLint   vorder, const  GLfloat  * points);
-typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERPROC)(GLenum   target, GLenum   access);
-typedef void * (GLAD_API_PTR *PFNGLMAPBUFFERRANGEPROC)(GLenum   target, GLintptr   offset, GLsizeiptr   length, GLbitfield   access);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID1DPROC)(GLint   un, GLdouble   u1, GLdouble   u2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID1FPROC)(GLint   un, GLfloat   u1, GLfloat   u2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID2DPROC)(GLint   un, GLdouble   u1, GLdouble   u2, GLint   vn, GLdouble   v1, GLdouble   v2);
-typedef void (GLAD_API_PTR *PFNGLMAPGRID2FPROC)(GLint   un, GLfloat   u1, GLfloat   u2, GLint   vn, GLfloat   v1, GLfloat   v2);
-typedef void (GLAD_API_PTR *PFNGLMATERIALFPROC)(GLenum   face, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLMATERIALFVPROC)(GLenum   face, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLMATERIALIPROC)(GLenum   face, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLMATERIALIVPROC)(GLenum   face, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLMATRIXMODEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLMULTMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXDPROC)(const  GLdouble  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTTRANSPOSEMATRIXFPROC)(const  GLfloat  * m);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWARRAYSPROC)(GLenum   mode, const  GLint  * first, const  GLsizei  * count, GLsizei   drawcount);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSPROC)(GLenum   mode, const  GLsizei  * count, GLenum   type, const void *const* indices, GLsizei   drawcount);
-typedef void (GLAD_API_PTR *PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum   mode, const  GLsizei  * count, GLenum   type, const void *const* indices, GLsizei   drawcount, const  GLint  * basevertex);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DPROC)(GLenum   target, GLdouble   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FPROC)(GLenum   target, GLfloat   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IPROC)(GLenum   target, GLint   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SPROC)(GLenum   target, GLshort   s);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD1SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DPROC)(GLenum   target, GLdouble   s, GLdouble   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FPROC)(GLenum   target, GLfloat   s, GLfloat   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IPROC)(GLenum   target, GLint   s, GLint   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SPROC)(GLenum   target, GLshort   s, GLshort   t);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD2SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DPROC)(GLenum   target, GLdouble   s, GLdouble   t, GLdouble   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FPROC)(GLenum   target, GLfloat   s, GLfloat   t, GLfloat   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IPROC)(GLenum   target, GLint   s, GLint   t, GLint   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SPROC)(GLenum   target, GLshort   s, GLshort   t, GLshort   r);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD3SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DPROC)(GLenum   target, GLdouble   s, GLdouble   t, GLdouble   r, GLdouble   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4DVPROC)(GLenum   target, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FPROC)(GLenum   target, GLfloat   s, GLfloat   t, GLfloat   r, GLfloat   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4FVPROC)(GLenum   target, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IPROC)(GLenum   target, GLint   s, GLint   t, GLint   r, GLint   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4IVPROC)(GLenum   target, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SPROC)(GLenum   target, GLshort   s, GLshort   t, GLshort   r, GLshort   q);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORD4SVPROC)(GLenum   target, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP1UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP2UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP3UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIPROC)(GLenum   texture, GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLMULTITEXCOORDP4UIVPROC)(GLenum   texture, GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLNEWLISTPROC)(GLuint   list, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3BPROC)(GLbyte   nx, GLbyte   ny, GLbyte   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3DPROC)(GLdouble   nx, GLdouble   ny, GLdouble   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3FPROC)(GLfloat   nx, GLfloat   ny, GLfloat   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3IPROC)(GLint   nx, GLint   ny, GLint   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3SPROC)(GLshort   nx, GLshort   ny, GLshort   nz);
-typedef void (GLAD_API_PTR *PFNGLNORMAL3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLNORMALP3UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLNORMALP3UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLNORMALPOINTERPROC)(GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLOBJECTLABELPROC)(GLenum   identifier, GLuint   name, GLsizei   length, const  GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLOBJECTPTRLABELPROC)(const void * ptr, GLsizei   length, const  GLchar  * label);
-typedef void (GLAD_API_PTR *PFNGLORTHOPROC)(GLdouble   left, GLdouble   right, GLdouble   bottom, GLdouble   top, GLdouble   zNear, GLdouble   zFar);
-typedef void (GLAD_API_PTR *PFNGLPASSTHROUGHPROC)(GLfloat   token);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPFVPROC)(GLenum   map, GLsizei   mapsize, const  GLfloat  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPUIVPROC)(GLenum   map, GLsizei   mapsize, const  GLuint  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELMAPUSVPROC)(GLenum   map, GLsizei   mapsize, const  GLushort  * values);
-typedef void (GLAD_API_PTR *PFNGLPIXELSTOREFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELSTOREIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELTRANSFERIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPIXELZOOMPROC)(GLfloat   xfactor, GLfloat   yfactor);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFPROC)(GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERFVPROC)(GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIPROC)(GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLPOINTPARAMETERIVPROC)(GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLPOINTSIZEPROC)(GLfloat   size);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONMODEPROC)(GLenum   face, GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONOFFSETPROC)(GLfloat   factor, GLfloat   units);
-typedef void (GLAD_API_PTR *PFNGLPOLYGONSTIPPLEPROC)(const  GLubyte  * mask);
-typedef void (GLAD_API_PTR *PFNGLPOPATTRIBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPCLIENTATTRIBPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPDEBUGGROUPPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPMATRIXPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPOPNAMEPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint   index);
-typedef void (GLAD_API_PTR *PFNGLPRIORITIZETEXTURESPROC)(GLsizei   n, const  GLuint  * textures, const  GLfloat  * priorities);
-typedef void (GLAD_API_PTR *PFNGLPROVOKINGVERTEXPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLPUSHATTRIBPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLPUSHDEBUGGROUPPROC)(GLenum   source, GLuint   id, GLsizei   length, const  GLchar  * message);
-typedef void (GLAD_API_PTR *PFNGLPUSHMATRIXPROC)(void);
-typedef void (GLAD_API_PTR *PFNGLPUSHNAMEPROC)(GLuint   name);
-typedef void (GLAD_API_PTR *PFNGLQUERYCOUNTERPROC)(GLuint   id, GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DPROC)(GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FPROC)(GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IPROC)(GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SPROC)(GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLRASTERPOS4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLREADBUFFERPROC)(GLenum   src);
-typedef void (GLAD_API_PTR *PFNGLREADPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, void * pixels);
-typedef void (GLAD_API_PTR *PFNGLREADNPIXELSPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, GLsizei   bufSize, void * data);
-typedef void (GLAD_API_PTR *PFNGLREADNPIXELSARBPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, GLsizei   bufSize, void * data);
-typedef void (GLAD_API_PTR *PFNGLRECTDPROC)(GLdouble   x1, GLdouble   y1, GLdouble   x2, GLdouble   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTDVPROC)(const  GLdouble  * v1, const  GLdouble  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTFPROC)(GLfloat   x1, GLfloat   y1, GLfloat   x2, GLfloat   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTFVPROC)(const  GLfloat  * v1, const  GLfloat  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTIPROC)(GLint   x1, GLint   y1, GLint   x2, GLint   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTIVPROC)(const  GLint  * v1, const  GLint  * v2);
-typedef void (GLAD_API_PTR *PFNGLRECTSPROC)(GLshort   x1, GLshort   y1, GLshort   x2, GLshort   y2);
-typedef void (GLAD_API_PTR *PFNGLRECTSVPROC)(const  GLshort  * v1, const  GLshort  * v2);
-typedef GLint (GLAD_API_PTR *PFNGLRENDERMODEPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEPROC)(GLenum   target, GLenum   internalformat, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLROTATEDPROC)(GLdouble   angle, GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLROTATEFPROC)(GLfloat   angle, GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEPROC)(GLfloat   value, GLboolean   invert);
-typedef void (GLAD_API_PTR *PFNGLSAMPLECOVERAGEARBPROC)(GLfloat   value, GLboolean   invert);
-typedef void (GLAD_API_PTR *PFNGLSAMPLEMASKIPROC)(GLuint   maskNumber, GLbitfield   mask);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIIVPROC)(GLuint   sampler, GLenum   pname, const  GLint  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint   sampler, GLenum   pname, const  GLuint  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFPROC)(GLuint   sampler, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERFVPROC)(GLuint   sampler, GLenum   pname, const  GLfloat  * param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIPROC)(GLuint   sampler, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLSAMPLERPARAMETERIVPROC)(GLuint   sampler, GLenum   pname, const  GLint  * param);
-typedef void (GLAD_API_PTR *PFNGLSCALEDPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLSCALEFPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLSCISSORPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BPROC)(GLbyte   red, GLbyte   green, GLbyte   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3BVPROC)(const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DPROC)(GLdouble   red, GLdouble   green, GLdouble   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FPROC)(GLfloat   red, GLfloat   green, GLfloat   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IPROC)(GLint   red, GLint   green, GLint   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SPROC)(GLshort   red, GLshort   green, GLshort   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBPROC)(GLubyte   red, GLubyte   green, GLubyte   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UBVPROC)(const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIPROC)(GLuint   red, GLuint   green, GLuint   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3UIVPROC)(const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USPROC)(GLushort   red, GLushort   green, GLushort   blue);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLOR3USVPROC)(const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIPROC)(GLenum   type, GLuint   color);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORP3UIVPROC)(GLenum   type, const  GLuint  * color);
-typedef void (GLAD_API_PTR *PFNGLSECONDARYCOLORPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLSELECTBUFFERPROC)(GLsizei   size, GLuint  * buffer);
-typedef void (GLAD_API_PTR *PFNGLSHADEMODELPROC)(GLenum   mode);
-typedef void (GLAD_API_PTR *PFNGLSHADERSOURCEPROC)(GLuint   shader, GLsizei   count, const  GLchar  *const* string, const  GLint  * length);
-typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCPROC)(GLenum   func, GLint   ref, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILFUNCSEPARATEPROC)(GLenum   face, GLenum   func, GLint   ref, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILMASKPROC)(GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILMASKSEPARATEPROC)(GLenum   face, GLuint   mask);
-typedef void (GLAD_API_PTR *PFNGLSTENCILOPPROC)(GLenum   fail, GLenum   zfail, GLenum   zpass);
-typedef void (GLAD_API_PTR *PFNGLSTENCILOPSEPARATEPROC)(GLenum   face, GLenum   sfail, GLenum   dpfail, GLenum   dppass);
-typedef void (GLAD_API_PTR *PFNGLTEXBUFFERPROC)(GLenum   target, GLenum   internalformat, GLuint   buffer);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DPROC)(GLdouble   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FPROC)(GLfloat   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IPROC)(GLint   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SPROC)(GLshort   s);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD1SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DPROC)(GLdouble   s, GLdouble   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FPROC)(GLfloat   s, GLfloat   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IPROC)(GLint   s, GLint   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SPROC)(GLshort   s, GLshort   t);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DPROC)(GLdouble   s, GLdouble   t, GLdouble   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FPROC)(GLfloat   s, GLfloat   t, GLfloat   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IPROC)(GLint   s, GLint   t, GLint   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SPROC)(GLshort   s, GLshort   t, GLshort   r);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DPROC)(GLdouble   s, GLdouble   t, GLdouble   r, GLdouble   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FPROC)(GLfloat   s, GLfloat   t, GLfloat   r, GLfloat   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IPROC)(GLint   s, GLint   t, GLint   r, GLint   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SPROC)(GLshort   s, GLshort   t, GLshort   r, GLshort   q);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORD4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP1UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP2UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP3UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIPROC)(GLenum   type, GLuint   coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDP4UIVPROC)(GLenum   type, const  GLuint  * coords);
-typedef void (GLAD_API_PTR *PFNGLTEXCOORDPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLTEXENVFPROC)(GLenum   target, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXENVFVPROC)(GLenum   target, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXENVIPROC)(GLenum   target, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXENVIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENDPROC)(GLenum   coord, GLenum   pname, GLdouble   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENDVPROC)(GLenum   coord, GLenum   pname, const  GLdouble  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENFPROC)(GLenum   coord, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENFVPROC)(GLenum   coord, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXGENIPROC)(GLenum   coord, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXGENIVPROC)(GLenum   coord, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE1DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLsizei   height, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height, GLboolean   fixedsamplelocations);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DPROC)(GLenum   target, GLint   level, GLint   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLint   border, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum   target, GLsizei   samples, GLenum   internalformat, GLsizei   width, GLsizei   height, GLsizei   depth, GLboolean   fixedsamplelocations);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIUIVPROC)(GLenum   target, GLenum   pname, const  GLuint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFPROC)(GLenum   target, GLenum   pname, GLfloat   param);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERFVPROC)(GLenum   target, GLenum   pname, const  GLfloat  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIPROC)(GLenum   target, GLenum   pname, GLint   param);
-typedef void (GLAD_API_PTR *PFNGLTEXPARAMETERIVPROC)(GLenum   target, GLenum   pname, const  GLint  * params);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE1DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLsizei   width, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE2DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLsizei   width, GLsizei   height, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTEXSUBIMAGE3DPROC)(GLenum   target, GLint   level, GLint   xoffset, GLint   yoffset, GLint   zoffset, GLsizei   width, GLsizei   height, GLsizei   depth, GLenum   format, GLenum   type, const void * pixels);
-typedef void (GLAD_API_PTR *PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint   program, GLsizei   count, const  GLchar  *const* varyings, GLenum   bufferMode);
-typedef void (GLAD_API_PTR *PFNGLTRANSLATEDPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLTRANSLATEFPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1FPROC)(GLint   location, GLfloat   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1IPROC)(GLint   location, GLint   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIPROC)(GLint   location, GLuint   v0);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM1UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2FPROC)(GLint   location, GLfloat   v0, GLfloat   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2IPROC)(GLint   location, GLint   v0, GLint   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIPROC)(GLint   location, GLuint   v0, GLuint   v1);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM2UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3FPROC)(GLint   location, GLfloat   v0, GLfloat   v1, GLfloat   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3IPROC)(GLint   location, GLint   v0, GLint   v1, GLint   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIPROC)(GLint   location, GLuint   v0, GLuint   v1, GLuint   v2);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM3UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4FPROC)(GLint   location, GLfloat   v0, GLfloat   v1, GLfloat   v2, GLfloat   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4FVPROC)(GLint   location, GLsizei   count, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4IPROC)(GLint   location, GLint   v0, GLint   v1, GLint   v2, GLint   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4IVPROC)(GLint   location, GLsizei   count, const  GLint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIPROC)(GLint   location, GLuint   v0, GLuint   v1, GLuint   v2, GLuint   v3);
-typedef void (GLAD_API_PTR *PFNGLUNIFORM4UIVPROC)(GLint   location, GLsizei   count, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint   program, GLuint   uniformBlockIndex, GLuint   uniformBlockBinding);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX2X4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX3X4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X2FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef void (GLAD_API_PTR *PFNGLUNIFORMMATRIX4X3FVPROC)(GLint   location, GLsizei   count, GLboolean   transpose, const  GLfloat  * value);
-typedef GLboolean (GLAD_API_PTR *PFNGLUNMAPBUFFERPROC)(GLenum   target);
-typedef void (GLAD_API_PTR *PFNGLUSEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLVALIDATEPROGRAMPROC)(GLuint   program);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEX2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEX3SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4DPROC)(GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4FPROC)(GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4IPROC)(GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4SPROC)(GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEX4SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DPROC)(GLuint   index, GLdouble   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FPROC)(GLuint   index, GLfloat   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SPROC)(GLuint   index, GLshort   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB1SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DPROC)(GLuint   index, GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FPROC)(GLuint   index, GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SPROC)(GLuint   index, GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB2SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DPROC)(GLuint   index, GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FPROC)(GLuint   index, GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SPROC)(GLuint   index, GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB3SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NBVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NIVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NSVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBPROC)(GLuint   index, GLubyte   x, GLubyte   y, GLubyte   z, GLubyte   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4NUSVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4BVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DPROC)(GLuint   index, GLdouble   x, GLdouble   y, GLdouble   z, GLdouble   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4DVPROC)(GLuint   index, const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FPROC)(GLuint   index, GLfloat   x, GLfloat   y, GLfloat   z, GLfloat   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4FVPROC)(GLuint   index, const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SPROC)(GLuint   index, GLshort   x, GLshort   y, GLshort   z, GLshort   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIB4USVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBDIVISORPROC)(GLuint   index, GLuint   divisor);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IPROC)(GLuint   index, GLint   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIPROC)(GLuint   index, GLuint   x);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI1UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IPROC)(GLuint   index, GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIPROC)(GLuint   index, GLuint   x, GLuint   y);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI2UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IPROC)(GLuint   index, GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIPROC)(GLuint   index, GLuint   x, GLuint   y, GLuint   z);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI3UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4BVPROC)(GLuint   index, const  GLbyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IPROC)(GLuint   index, GLint   x, GLint   y, GLint   z, GLint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4IVPROC)(GLuint   index, const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4SVPROC)(GLuint   index, const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UBVPROC)(GLuint   index, const  GLubyte  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIPROC)(GLuint   index, GLuint   x, GLuint   y, GLuint   z, GLuint   w);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4UIVPROC)(GLuint   index, const  GLuint  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBI4USVPROC)(GLuint   index, const  GLushort  * v);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint   index, GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP1UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP2UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP3UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIPROC)(GLuint   index, GLenum   type, GLboolean   normalized, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBP4UIVPROC)(GLuint   index, GLenum   type, GLboolean   normalized, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXATTRIBPOINTERPROC)(GLuint   index, GLint   size, GLenum   type, GLboolean   normalized, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP2UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP3UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIPROC)(GLenum   type, GLuint   value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXP4UIVPROC)(GLenum   type, const  GLuint  * value);
-typedef void (GLAD_API_PTR *PFNGLVERTEXPOINTERPROC)(GLint   size, GLenum   type, GLsizei   stride, const void * pointer);
-typedef void (GLAD_API_PTR *PFNGLVIEWPORTPROC)(GLint   x, GLint   y, GLsizei   width, GLsizei   height);
-typedef void (GLAD_API_PTR *PFNGLWAITSYNCPROC)(GLsync   sync, GLbitfield   flags, GLuint64   timeout);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DPROC)(GLdouble   x, GLdouble   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FPROC)(GLfloat   x, GLfloat   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IPROC)(GLint   x, GLint   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SPROC)(GLshort   x, GLshort   y);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS2SVPROC)(const  GLshort  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DPROC)(GLdouble   x, GLdouble   y, GLdouble   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3DVPROC)(const  GLdouble  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FPROC)(GLfloat   x, GLfloat   y, GLfloat   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3FVPROC)(const  GLfloat  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IPROC)(GLint   x, GLint   y, GLint   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3IVPROC)(const  GLint  * v);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SPROC)(GLshort   x, GLshort   y, GLshort   z);
-typedef void (GLAD_API_PTR *PFNGLWINDOWPOS3SVPROC)(const  GLshort  * v);
-
-GLAD_API_CALL PFNGLACCUMPROC glad_glAccum;
-#define glAccum glad_glAccum
-GLAD_API_CALL PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
-#define glActiveTexture glad_glActiveTexture
-GLAD_API_CALL PFNGLALPHAFUNCPROC glad_glAlphaFunc;
-#define glAlphaFunc glad_glAlphaFunc
-GLAD_API_CALL PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident;
-#define glAreTexturesResident glad_glAreTexturesResident
-GLAD_API_CALL PFNGLARRAYELEMENTPROC glad_glArrayElement;
-#define glArrayElement glad_glArrayElement
-GLAD_API_CALL PFNGLATTACHSHADERPROC glad_glAttachShader;
-#define glAttachShader glad_glAttachShader
-GLAD_API_CALL PFNGLBEGINPROC glad_glBegin;
-#define glBegin glad_glBegin
-GLAD_API_CALL PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
-#define glBeginConditionalRender glad_glBeginConditionalRender
-GLAD_API_CALL PFNGLBEGINQUERYPROC glad_glBeginQuery;
-#define glBeginQuery glad_glBeginQuery
-GLAD_API_CALL PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
-#define glBeginTransformFeedback glad_glBeginTransformFeedback
-GLAD_API_CALL PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
-#define glBindAttribLocation glad_glBindAttribLocation
-GLAD_API_CALL PFNGLBINDBUFFERPROC glad_glBindBuffer;
-#define glBindBuffer glad_glBindBuffer
-GLAD_API_CALL PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
-#define glBindBufferBase glad_glBindBufferBase
-GLAD_API_CALL PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
-#define glBindBufferRange glad_glBindBufferRange
-GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
-#define glBindFragDataLocation glad_glBindFragDataLocation
-GLAD_API_CALL PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
-#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
-GLAD_API_CALL PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
-#define glBindFramebuffer glad_glBindFramebuffer
-GLAD_API_CALL PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
-#define glBindRenderbuffer glad_glBindRenderbuffer
-GLAD_API_CALL PFNGLBINDSAMPLERPROC glad_glBindSampler;
-#define glBindSampler glad_glBindSampler
-GLAD_API_CALL PFNGLBINDTEXTUREPROC glad_glBindTexture;
-#define glBindTexture glad_glBindTexture
-GLAD_API_CALL PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
-#define glBindVertexArray glad_glBindVertexArray
-GLAD_API_CALL PFNGLBITMAPPROC glad_glBitmap;
-#define glBitmap glad_glBitmap
-GLAD_API_CALL PFNGLBLENDCOLORPROC glad_glBlendColor;
-#define glBlendColor glad_glBlendColor
-GLAD_API_CALL PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
-#define glBlendEquation glad_glBlendEquation
-GLAD_API_CALL PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
-#define glBlendEquationSeparate glad_glBlendEquationSeparate
-GLAD_API_CALL PFNGLBLENDFUNCPROC glad_glBlendFunc;
-#define glBlendFunc glad_glBlendFunc
-GLAD_API_CALL PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
-#define glBlendFuncSeparate glad_glBlendFuncSeparate
-GLAD_API_CALL PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
-#define glBlitFramebuffer glad_glBlitFramebuffer
-GLAD_API_CALL PFNGLBUFFERDATAPROC glad_glBufferData;
-#define glBufferData glad_glBufferData
-GLAD_API_CALL PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
-#define glBufferSubData glad_glBufferSubData
-GLAD_API_CALL PFNGLCALLLISTPROC glad_glCallList;
-#define glCallList glad_glCallList
-GLAD_API_CALL PFNGLCALLLISTSPROC glad_glCallLists;
-#define glCallLists glad_glCallLists
-GLAD_API_CALL PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
-#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
-GLAD_API_CALL PFNGLCLAMPCOLORPROC glad_glClampColor;
-#define glClampColor glad_glClampColor
-GLAD_API_CALL PFNGLCLEARPROC glad_glClear;
-#define glClear glad_glClear
-GLAD_API_CALL PFNGLCLEARACCUMPROC glad_glClearAccum;
-#define glClearAccum glad_glClearAccum
-GLAD_API_CALL PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
-#define glClearBufferfi glad_glClearBufferfi
-GLAD_API_CALL PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
-#define glClearBufferfv glad_glClearBufferfv
-GLAD_API_CALL PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
-#define glClearBufferiv glad_glClearBufferiv
-GLAD_API_CALL PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
-#define glClearBufferuiv glad_glClearBufferuiv
-GLAD_API_CALL PFNGLCLEARCOLORPROC glad_glClearColor;
-#define glClearColor glad_glClearColor
-GLAD_API_CALL PFNGLCLEARDEPTHPROC glad_glClearDepth;
-#define glClearDepth glad_glClearDepth
-GLAD_API_CALL PFNGLCLEARINDEXPROC glad_glClearIndex;
-#define glClearIndex glad_glClearIndex
-GLAD_API_CALL PFNGLCLEARSTENCILPROC glad_glClearStencil;
-#define glClearStencil glad_glClearStencil
-GLAD_API_CALL PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture;
-#define glClientActiveTexture glad_glClientActiveTexture
-GLAD_API_CALL PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
-#define glClientWaitSync glad_glClientWaitSync
-GLAD_API_CALL PFNGLCLIPPLANEPROC glad_glClipPlane;
-#define glClipPlane glad_glClipPlane
-GLAD_API_CALL PFNGLCOLOR3BPROC glad_glColor3b;
-#define glColor3b glad_glColor3b
-GLAD_API_CALL PFNGLCOLOR3BVPROC glad_glColor3bv;
-#define glColor3bv glad_glColor3bv
-GLAD_API_CALL PFNGLCOLOR3DPROC glad_glColor3d;
-#define glColor3d glad_glColor3d
-GLAD_API_CALL PFNGLCOLOR3DVPROC glad_glColor3dv;
-#define glColor3dv glad_glColor3dv
-GLAD_API_CALL PFNGLCOLOR3FPROC glad_glColor3f;
-#define glColor3f glad_glColor3f
-GLAD_API_CALL PFNGLCOLOR3FVPROC glad_glColor3fv;
-#define glColor3fv glad_glColor3fv
-GLAD_API_CALL PFNGLCOLOR3IPROC glad_glColor3i;
-#define glColor3i glad_glColor3i
-GLAD_API_CALL PFNGLCOLOR3IVPROC glad_glColor3iv;
-#define glColor3iv glad_glColor3iv
-GLAD_API_CALL PFNGLCOLOR3SPROC glad_glColor3s;
-#define glColor3s glad_glColor3s
-GLAD_API_CALL PFNGLCOLOR3SVPROC glad_glColor3sv;
-#define glColor3sv glad_glColor3sv
-GLAD_API_CALL PFNGLCOLOR3UBPROC glad_glColor3ub;
-#define glColor3ub glad_glColor3ub
-GLAD_API_CALL PFNGLCOLOR3UBVPROC glad_glColor3ubv;
-#define glColor3ubv glad_glColor3ubv
-GLAD_API_CALL PFNGLCOLOR3UIPROC glad_glColor3ui;
-#define glColor3ui glad_glColor3ui
-GLAD_API_CALL PFNGLCOLOR3UIVPROC glad_glColor3uiv;
-#define glColor3uiv glad_glColor3uiv
-GLAD_API_CALL PFNGLCOLOR3USPROC glad_glColor3us;
-#define glColor3us glad_glColor3us
-GLAD_API_CALL PFNGLCOLOR3USVPROC glad_glColor3usv;
-#define glColor3usv glad_glColor3usv
-GLAD_API_CALL PFNGLCOLOR4BPROC glad_glColor4b;
-#define glColor4b glad_glColor4b
-GLAD_API_CALL PFNGLCOLOR4BVPROC glad_glColor4bv;
-#define glColor4bv glad_glColor4bv
-GLAD_API_CALL PFNGLCOLOR4DPROC glad_glColor4d;
-#define glColor4d glad_glColor4d
-GLAD_API_CALL PFNGLCOLOR4DVPROC glad_glColor4dv;
-#define glColor4dv glad_glColor4dv
-GLAD_API_CALL PFNGLCOLOR4FPROC glad_glColor4f;
-#define glColor4f glad_glColor4f
-GLAD_API_CALL PFNGLCOLOR4FVPROC glad_glColor4fv;
-#define glColor4fv glad_glColor4fv
-GLAD_API_CALL PFNGLCOLOR4IPROC glad_glColor4i;
-#define glColor4i glad_glColor4i
-GLAD_API_CALL PFNGLCOLOR4IVPROC glad_glColor4iv;
-#define glColor4iv glad_glColor4iv
-GLAD_API_CALL PFNGLCOLOR4SPROC glad_glColor4s;
-#define glColor4s glad_glColor4s
-GLAD_API_CALL PFNGLCOLOR4SVPROC glad_glColor4sv;
-#define glColor4sv glad_glColor4sv
-GLAD_API_CALL PFNGLCOLOR4UBPROC glad_glColor4ub;
-#define glColor4ub glad_glColor4ub
-GLAD_API_CALL PFNGLCOLOR4UBVPROC glad_glColor4ubv;
-#define glColor4ubv glad_glColor4ubv
-GLAD_API_CALL PFNGLCOLOR4UIPROC glad_glColor4ui;
-#define glColor4ui glad_glColor4ui
-GLAD_API_CALL PFNGLCOLOR4UIVPROC glad_glColor4uiv;
-#define glColor4uiv glad_glColor4uiv
-GLAD_API_CALL PFNGLCOLOR4USPROC glad_glColor4us;
-#define glColor4us glad_glColor4us
-GLAD_API_CALL PFNGLCOLOR4USVPROC glad_glColor4usv;
-#define glColor4usv glad_glColor4usv
-GLAD_API_CALL PFNGLCOLORMASKPROC glad_glColorMask;
-#define glColorMask glad_glColorMask
-GLAD_API_CALL PFNGLCOLORMASKIPROC glad_glColorMaski;
-#define glColorMaski glad_glColorMaski
-GLAD_API_CALL PFNGLCOLORMATERIALPROC glad_glColorMaterial;
-#define glColorMaterial glad_glColorMaterial
-GLAD_API_CALL PFNGLCOLORP3UIPROC glad_glColorP3ui;
-#define glColorP3ui glad_glColorP3ui
-GLAD_API_CALL PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
-#define glColorP3uiv glad_glColorP3uiv
-GLAD_API_CALL PFNGLCOLORP4UIPROC glad_glColorP4ui;
-#define glColorP4ui glad_glColorP4ui
-GLAD_API_CALL PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
-#define glColorP4uiv glad_glColorP4uiv
-GLAD_API_CALL PFNGLCOLORPOINTERPROC glad_glColorPointer;
-#define glColorPointer glad_glColorPointer
-GLAD_API_CALL PFNGLCOMPILESHADERPROC glad_glCompileShader;
-#define glCompileShader glad_glCompileShader
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
-#define glCompressedTexImage1D glad_glCompressedTexImage1D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
-#define glCompressedTexImage2D glad_glCompressedTexImage2D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
-#define glCompressedTexImage3D glad_glCompressedTexImage3D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
-#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
-#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
-GLAD_API_CALL PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
-#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
-GLAD_API_CALL PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
-#define glCopyBufferSubData glad_glCopyBufferSubData
-GLAD_API_CALL PFNGLCOPYPIXELSPROC glad_glCopyPixels;
-#define glCopyPixels glad_glCopyPixels
-GLAD_API_CALL PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
-#define glCopyTexImage1D glad_glCopyTexImage1D
-GLAD_API_CALL PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
-#define glCopyTexImage2D glad_glCopyTexImage2D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
-#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
-#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
-GLAD_API_CALL PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
-#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
-GLAD_API_CALL PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
-#define glCreateProgram glad_glCreateProgram
-GLAD_API_CALL PFNGLCREATESHADERPROC glad_glCreateShader;
-#define glCreateShader glad_glCreateShader
-GLAD_API_CALL PFNGLCULLFACEPROC glad_glCullFace;
-#define glCullFace glad_glCullFace
-GLAD_API_CALL PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
-#define glDebugMessageCallback glad_glDebugMessageCallback
-GLAD_API_CALL PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
-#define glDebugMessageControl glad_glDebugMessageControl
-GLAD_API_CALL PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
-#define glDebugMessageInsert glad_glDebugMessageInsert
-GLAD_API_CALL PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
-#define glDeleteBuffers glad_glDeleteBuffers
-GLAD_API_CALL PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
-#define glDeleteFramebuffers glad_glDeleteFramebuffers
-GLAD_API_CALL PFNGLDELETELISTSPROC glad_glDeleteLists;
-#define glDeleteLists glad_glDeleteLists
-GLAD_API_CALL PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
-#define glDeleteProgram glad_glDeleteProgram
-GLAD_API_CALL PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
-#define glDeleteQueries glad_glDeleteQueries
-GLAD_API_CALL PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
-#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
-GLAD_API_CALL PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
-#define glDeleteSamplers glad_glDeleteSamplers
-GLAD_API_CALL PFNGLDELETESHADERPROC glad_glDeleteShader;
-#define glDeleteShader glad_glDeleteShader
-GLAD_API_CALL PFNGLDELETESYNCPROC glad_glDeleteSync;
-#define glDeleteSync glad_glDeleteSync
-GLAD_API_CALL PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
-#define glDeleteTextures glad_glDeleteTextures
-GLAD_API_CALL PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
-#define glDeleteVertexArrays glad_glDeleteVertexArrays
-GLAD_API_CALL PFNGLDEPTHFUNCPROC glad_glDepthFunc;
-#define glDepthFunc glad_glDepthFunc
-GLAD_API_CALL PFNGLDEPTHMASKPROC glad_glDepthMask;
-#define glDepthMask glad_glDepthMask
-GLAD_API_CALL PFNGLDEPTHRANGEPROC glad_glDepthRange;
-#define glDepthRange glad_glDepthRange
-GLAD_API_CALL PFNGLDETACHSHADERPROC glad_glDetachShader;
-#define glDetachShader glad_glDetachShader
-GLAD_API_CALL PFNGLDISABLEPROC glad_glDisable;
-#define glDisable glad_glDisable
-GLAD_API_CALL PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState;
-#define glDisableClientState glad_glDisableClientState
-GLAD_API_CALL PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
-#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
-GLAD_API_CALL PFNGLDISABLEIPROC glad_glDisablei;
-#define glDisablei glad_glDisablei
-GLAD_API_CALL PFNGLDRAWARRAYSPROC glad_glDrawArrays;
-#define glDrawArrays glad_glDrawArrays
-GLAD_API_CALL PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
-#define glDrawArraysInstanced glad_glDrawArraysInstanced
-GLAD_API_CALL PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
-#define glDrawBuffer glad_glDrawBuffer
-GLAD_API_CALL PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
-#define glDrawBuffers glad_glDrawBuffers
-GLAD_API_CALL PFNGLDRAWELEMENTSPROC glad_glDrawElements;
-#define glDrawElements glad_glDrawElements
-GLAD_API_CALL PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
-#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
-GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
-#define glDrawElementsInstanced glad_glDrawElementsInstanced
-GLAD_API_CALL PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
-#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
-GLAD_API_CALL PFNGLDRAWPIXELSPROC glad_glDrawPixels;
-#define glDrawPixels glad_glDrawPixels
-GLAD_API_CALL PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
-#define glDrawRangeElements glad_glDrawRangeElements
-GLAD_API_CALL PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
-#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
-GLAD_API_CALL PFNGLEDGEFLAGPROC glad_glEdgeFlag;
-#define glEdgeFlag glad_glEdgeFlag
-GLAD_API_CALL PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer;
-#define glEdgeFlagPointer glad_glEdgeFlagPointer
-GLAD_API_CALL PFNGLEDGEFLAGVPROC glad_glEdgeFlagv;
-#define glEdgeFlagv glad_glEdgeFlagv
-GLAD_API_CALL PFNGLENABLEPROC glad_glEnable;
-#define glEnable glad_glEnable
-GLAD_API_CALL PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState;
-#define glEnableClientState glad_glEnableClientState
-GLAD_API_CALL PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
-#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
-GLAD_API_CALL PFNGLENABLEIPROC glad_glEnablei;
-#define glEnablei glad_glEnablei
-GLAD_API_CALL PFNGLENDPROC glad_glEnd;
-#define glEnd glad_glEnd
-GLAD_API_CALL PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
-#define glEndConditionalRender glad_glEndConditionalRender
-GLAD_API_CALL PFNGLENDLISTPROC glad_glEndList;
-#define glEndList glad_glEndList
-GLAD_API_CALL PFNGLENDQUERYPROC glad_glEndQuery;
-#define glEndQuery glad_glEndQuery
-GLAD_API_CALL PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
-#define glEndTransformFeedback glad_glEndTransformFeedback
-GLAD_API_CALL PFNGLEVALCOORD1DPROC glad_glEvalCoord1d;
-#define glEvalCoord1d glad_glEvalCoord1d
-GLAD_API_CALL PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv;
-#define glEvalCoord1dv glad_glEvalCoord1dv
-GLAD_API_CALL PFNGLEVALCOORD1FPROC glad_glEvalCoord1f;
-#define glEvalCoord1f glad_glEvalCoord1f
-GLAD_API_CALL PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv;
-#define glEvalCoord1fv glad_glEvalCoord1fv
-GLAD_API_CALL PFNGLEVALCOORD2DPROC glad_glEvalCoord2d;
-#define glEvalCoord2d glad_glEvalCoord2d
-GLAD_API_CALL PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv;
-#define glEvalCoord2dv glad_glEvalCoord2dv
-GLAD_API_CALL PFNGLEVALCOORD2FPROC glad_glEvalCoord2f;
-#define glEvalCoord2f glad_glEvalCoord2f
-GLAD_API_CALL PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv;
-#define glEvalCoord2fv glad_glEvalCoord2fv
-GLAD_API_CALL PFNGLEVALMESH1PROC glad_glEvalMesh1;
-#define glEvalMesh1 glad_glEvalMesh1
-GLAD_API_CALL PFNGLEVALMESH2PROC glad_glEvalMesh2;
-#define glEvalMesh2 glad_glEvalMesh2
-GLAD_API_CALL PFNGLEVALPOINT1PROC glad_glEvalPoint1;
-#define glEvalPoint1 glad_glEvalPoint1
-GLAD_API_CALL PFNGLEVALPOINT2PROC glad_glEvalPoint2;
-#define glEvalPoint2 glad_glEvalPoint2
-GLAD_API_CALL PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer;
-#define glFeedbackBuffer glad_glFeedbackBuffer
-GLAD_API_CALL PFNGLFENCESYNCPROC glad_glFenceSync;
-#define glFenceSync glad_glFenceSync
-GLAD_API_CALL PFNGLFINISHPROC glad_glFinish;
-#define glFinish glad_glFinish
-GLAD_API_CALL PFNGLFLUSHPROC glad_glFlush;
-#define glFlush glad_glFlush
-GLAD_API_CALL PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
-#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
-GLAD_API_CALL PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer;
-#define glFogCoordPointer glad_glFogCoordPointer
-GLAD_API_CALL PFNGLFOGCOORDDPROC glad_glFogCoordd;
-#define glFogCoordd glad_glFogCoordd
-GLAD_API_CALL PFNGLFOGCOORDDVPROC glad_glFogCoorddv;
-#define glFogCoorddv glad_glFogCoorddv
-GLAD_API_CALL PFNGLFOGCOORDFPROC glad_glFogCoordf;
-#define glFogCoordf glad_glFogCoordf
-GLAD_API_CALL PFNGLFOGCOORDFVPROC glad_glFogCoordfv;
-#define glFogCoordfv glad_glFogCoordfv
-GLAD_API_CALL PFNGLFOGFPROC glad_glFogf;
-#define glFogf glad_glFogf
-GLAD_API_CALL PFNGLFOGFVPROC glad_glFogfv;
-#define glFogfv glad_glFogfv
-GLAD_API_CALL PFNGLFOGIPROC glad_glFogi;
-#define glFogi glad_glFogi
-GLAD_API_CALL PFNGLFOGIVPROC glad_glFogiv;
-#define glFogiv glad_glFogiv
-GLAD_API_CALL PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
-#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
-#define glFramebufferTexture glad_glFramebufferTexture
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
-#define glFramebufferTexture1D glad_glFramebufferTexture1D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
-#define glFramebufferTexture2D glad_glFramebufferTexture2D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
-#define glFramebufferTexture3D glad_glFramebufferTexture3D
-GLAD_API_CALL PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
-#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
-GLAD_API_CALL PFNGLFRONTFACEPROC glad_glFrontFace;
-#define glFrontFace glad_glFrontFace
-GLAD_API_CALL PFNGLFRUSTUMPROC glad_glFrustum;
-#define glFrustum glad_glFrustum
-GLAD_API_CALL PFNGLGENBUFFERSPROC glad_glGenBuffers;
-#define glGenBuffers glad_glGenBuffers
-GLAD_API_CALL PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
-#define glGenFramebuffers glad_glGenFramebuffers
-GLAD_API_CALL PFNGLGENLISTSPROC glad_glGenLists;
-#define glGenLists glad_glGenLists
-GLAD_API_CALL PFNGLGENQUERIESPROC glad_glGenQueries;
-#define glGenQueries glad_glGenQueries
-GLAD_API_CALL PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
-#define glGenRenderbuffers glad_glGenRenderbuffers
-GLAD_API_CALL PFNGLGENSAMPLERSPROC glad_glGenSamplers;
-#define glGenSamplers glad_glGenSamplers
-GLAD_API_CALL PFNGLGENTEXTURESPROC glad_glGenTextures;
-#define glGenTextures glad_glGenTextures
-GLAD_API_CALL PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
-#define glGenVertexArrays glad_glGenVertexArrays
-GLAD_API_CALL PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
-#define glGenerateMipmap glad_glGenerateMipmap
-GLAD_API_CALL PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
-#define glGetActiveAttrib glad_glGetActiveAttrib
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
-#define glGetActiveUniform glad_glGetActiveUniform
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
-#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
-#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
-#define glGetActiveUniformName glad_glGetActiveUniformName
-GLAD_API_CALL PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
-#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
-GLAD_API_CALL PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
-#define glGetAttachedShaders glad_glGetAttachedShaders
-GLAD_API_CALL PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
-#define glGetAttribLocation glad_glGetAttribLocation
-GLAD_API_CALL PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
-#define glGetBooleani_v glad_glGetBooleani_v
-GLAD_API_CALL PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
-#define glGetBooleanv glad_glGetBooleanv
-GLAD_API_CALL PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
-#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
-GLAD_API_CALL PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
-#define glGetBufferParameteriv glad_glGetBufferParameteriv
-GLAD_API_CALL PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
-#define glGetBufferPointerv glad_glGetBufferPointerv
-GLAD_API_CALL PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
-#define glGetBufferSubData glad_glGetBufferSubData
-GLAD_API_CALL PFNGLGETCLIPPLANEPROC glad_glGetClipPlane;
-#define glGetClipPlane glad_glGetClipPlane
-GLAD_API_CALL PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
-#define glGetCompressedTexImage glad_glGetCompressedTexImage
-GLAD_API_CALL PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
-#define glGetDebugMessageLog glad_glGetDebugMessageLog
-GLAD_API_CALL PFNGLGETDOUBLEVPROC glad_glGetDoublev;
-#define glGetDoublev glad_glGetDoublev
-GLAD_API_CALL PFNGLGETERRORPROC glad_glGetError;
-#define glGetError glad_glGetError
-GLAD_API_CALL PFNGLGETFLOATVPROC glad_glGetFloatv;
-#define glGetFloatv glad_glGetFloatv
-GLAD_API_CALL PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
-#define glGetFragDataIndex glad_glGetFragDataIndex
-GLAD_API_CALL PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
-#define glGetFragDataLocation glad_glGetFragDataLocation
-GLAD_API_CALL PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
-#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
-GLAD_API_CALL PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB;
-#define glGetGraphicsResetStatusARB glad_glGetGraphicsResetStatusARB
-GLAD_API_CALL PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
-#define glGetInteger64i_v glad_glGetInteger64i_v
-GLAD_API_CALL PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
-#define glGetInteger64v glad_glGetInteger64v
-GLAD_API_CALL PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
-#define glGetIntegeri_v glad_glGetIntegeri_v
-GLAD_API_CALL PFNGLGETINTEGERVPROC glad_glGetIntegerv;
-#define glGetIntegerv glad_glGetIntegerv
-GLAD_API_CALL PFNGLGETLIGHTFVPROC glad_glGetLightfv;
-#define glGetLightfv glad_glGetLightfv
-GLAD_API_CALL PFNGLGETLIGHTIVPROC glad_glGetLightiv;
-#define glGetLightiv glad_glGetLightiv
-GLAD_API_CALL PFNGLGETMAPDVPROC glad_glGetMapdv;
-#define glGetMapdv glad_glGetMapdv
-GLAD_API_CALL PFNGLGETMAPFVPROC glad_glGetMapfv;
-#define glGetMapfv glad_glGetMapfv
-GLAD_API_CALL PFNGLGETMAPIVPROC glad_glGetMapiv;
-#define glGetMapiv glad_glGetMapiv
-GLAD_API_CALL PFNGLGETMATERIALFVPROC glad_glGetMaterialfv;
-#define glGetMaterialfv glad_glGetMaterialfv
-GLAD_API_CALL PFNGLGETMATERIALIVPROC glad_glGetMaterialiv;
-#define glGetMaterialiv glad_glGetMaterialiv
-GLAD_API_CALL PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
-#define glGetMultisamplefv glad_glGetMultisamplefv
-GLAD_API_CALL PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
-#define glGetObjectLabel glad_glGetObjectLabel
-GLAD_API_CALL PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
-#define glGetObjectPtrLabel glad_glGetObjectPtrLabel
-GLAD_API_CALL PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv;
-#define glGetPixelMapfv glad_glGetPixelMapfv
-GLAD_API_CALL PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv;
-#define glGetPixelMapuiv glad_glGetPixelMapuiv
-GLAD_API_CALL PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv;
-#define glGetPixelMapusv glad_glGetPixelMapusv
-GLAD_API_CALL PFNGLGETPOINTERVPROC glad_glGetPointerv;
-#define glGetPointerv glad_glGetPointerv
-GLAD_API_CALL PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple;
-#define glGetPolygonStipple glad_glGetPolygonStipple
-GLAD_API_CALL PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
-#define glGetProgramInfoLog glad_glGetProgramInfoLog
-GLAD_API_CALL PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
-#define glGetProgramiv glad_glGetProgramiv
-GLAD_API_CALL PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
-#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
-GLAD_API_CALL PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
-#define glGetQueryObjectiv glad_glGetQueryObjectiv
-GLAD_API_CALL PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
-#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
-GLAD_API_CALL PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
-#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
-GLAD_API_CALL PFNGLGETQUERYIVPROC glad_glGetQueryiv;
-#define glGetQueryiv glad_glGetQueryiv
-GLAD_API_CALL PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
-#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
-#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
-#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
-#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
-GLAD_API_CALL PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
-#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
-GLAD_API_CALL PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
-#define glGetShaderInfoLog glad_glGetShaderInfoLog
-GLAD_API_CALL PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
-#define glGetShaderSource glad_glGetShaderSource
-GLAD_API_CALL PFNGLGETSHADERIVPROC glad_glGetShaderiv;
-#define glGetShaderiv glad_glGetShaderiv
-GLAD_API_CALL PFNGLGETSTRINGPROC glad_glGetString;
-#define glGetString glad_glGetString
-GLAD_API_CALL PFNGLGETSTRINGIPROC glad_glGetStringi;
-#define glGetStringi glad_glGetStringi
-GLAD_API_CALL PFNGLGETSYNCIVPROC glad_glGetSynciv;
-#define glGetSynciv glad_glGetSynciv
-GLAD_API_CALL PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv;
-#define glGetTexEnvfv glad_glGetTexEnvfv
-GLAD_API_CALL PFNGLGETTEXENVIVPROC glad_glGetTexEnviv;
-#define glGetTexEnviv glad_glGetTexEnviv
-GLAD_API_CALL PFNGLGETTEXGENDVPROC glad_glGetTexGendv;
-#define glGetTexGendv glad_glGetTexGendv
-GLAD_API_CALL PFNGLGETTEXGENFVPROC glad_glGetTexGenfv;
-#define glGetTexGenfv glad_glGetTexGenfv
-GLAD_API_CALL PFNGLGETTEXGENIVPROC glad_glGetTexGeniv;
-#define glGetTexGeniv glad_glGetTexGeniv
-GLAD_API_CALL PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
-#define glGetTexImage glad_glGetTexImage
-GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
-#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
-GLAD_API_CALL PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
-#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
-#define glGetTexParameterIiv glad_glGetTexParameterIiv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
-#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
-GLAD_API_CALL PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
-#define glGetTexParameterfv glad_glGetTexParameterfv
-GLAD_API_CALL PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
-#define glGetTexParameteriv glad_glGetTexParameteriv
-GLAD_API_CALL PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
-#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
-GLAD_API_CALL PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
-#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
-GLAD_API_CALL PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
-#define glGetUniformIndices glad_glGetUniformIndices
-GLAD_API_CALL PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
-#define glGetUniformLocation glad_glGetUniformLocation
-GLAD_API_CALL PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
-#define glGetUniformfv glad_glGetUniformfv
-GLAD_API_CALL PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
-#define glGetUniformiv glad_glGetUniformiv
-GLAD_API_CALL PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
-#define glGetUniformuiv glad_glGetUniformuiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
-#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
-#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
-#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
-#define glGetVertexAttribdv glad_glGetVertexAttribdv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
-#define glGetVertexAttribfv glad_glGetVertexAttribfv
-GLAD_API_CALL PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
-#define glGetVertexAttribiv glad_glGetVertexAttribiv
-GLAD_API_CALL PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB;
-#define glGetnColorTableARB glad_glGetnColorTableARB
-GLAD_API_CALL PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB;
-#define glGetnCompressedTexImageARB glad_glGetnCompressedTexImageARB
-GLAD_API_CALL PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB;
-#define glGetnConvolutionFilterARB glad_glGetnConvolutionFilterARB
-GLAD_API_CALL PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB;
-#define glGetnHistogramARB glad_glGetnHistogramARB
-GLAD_API_CALL PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB;
-#define glGetnMapdvARB glad_glGetnMapdvARB
-GLAD_API_CALL PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB;
-#define glGetnMapfvARB glad_glGetnMapfvARB
-GLAD_API_CALL PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB;
-#define glGetnMapivARB glad_glGetnMapivARB
-GLAD_API_CALL PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB;
-#define glGetnMinmaxARB glad_glGetnMinmaxARB
-GLAD_API_CALL PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB;
-#define glGetnPixelMapfvARB glad_glGetnPixelMapfvARB
-GLAD_API_CALL PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB;
-#define glGetnPixelMapuivARB glad_glGetnPixelMapuivARB
-GLAD_API_CALL PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB;
-#define glGetnPixelMapusvARB glad_glGetnPixelMapusvARB
-GLAD_API_CALL PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB;
-#define glGetnPolygonStippleARB glad_glGetnPolygonStippleARB
-GLAD_API_CALL PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB;
-#define glGetnSeparableFilterARB glad_glGetnSeparableFilterARB
-GLAD_API_CALL PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB;
-#define glGetnTexImageARB glad_glGetnTexImageARB
-GLAD_API_CALL PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB;
-#define glGetnUniformdvARB glad_glGetnUniformdvARB
-GLAD_API_CALL PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB;
-#define glGetnUniformfvARB glad_glGetnUniformfvARB
-GLAD_API_CALL PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB;
-#define glGetnUniformivARB glad_glGetnUniformivARB
-GLAD_API_CALL PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB;
-#define glGetnUniformuivARB glad_glGetnUniformuivARB
-GLAD_API_CALL PFNGLHINTPROC glad_glHint;
-#define glHint glad_glHint
-GLAD_API_CALL PFNGLINDEXMASKPROC glad_glIndexMask;
-#define glIndexMask glad_glIndexMask
-GLAD_API_CALL PFNGLINDEXPOINTERPROC glad_glIndexPointer;
-#define glIndexPointer glad_glIndexPointer
-GLAD_API_CALL PFNGLINDEXDPROC glad_glIndexd;
-#define glIndexd glad_glIndexd
-GLAD_API_CALL PFNGLINDEXDVPROC glad_glIndexdv;
-#define glIndexdv glad_glIndexdv
-GLAD_API_CALL PFNGLINDEXFPROC glad_glIndexf;
-#define glIndexf glad_glIndexf
-GLAD_API_CALL PFNGLINDEXFVPROC glad_glIndexfv;
-#define glIndexfv glad_glIndexfv
-GLAD_API_CALL PFNGLINDEXIPROC glad_glIndexi;
-#define glIndexi glad_glIndexi
-GLAD_API_CALL PFNGLINDEXIVPROC glad_glIndexiv;
-#define glIndexiv glad_glIndexiv
-GLAD_API_CALL PFNGLINDEXSPROC glad_glIndexs;
-#define glIndexs glad_glIndexs
-GLAD_API_CALL PFNGLINDEXSVPROC glad_glIndexsv;
-#define glIndexsv glad_glIndexsv
-GLAD_API_CALL PFNGLINDEXUBPROC glad_glIndexub;
-#define glIndexub glad_glIndexub
-GLAD_API_CALL PFNGLINDEXUBVPROC glad_glIndexubv;
-#define glIndexubv glad_glIndexubv
-GLAD_API_CALL PFNGLINITNAMESPROC glad_glInitNames;
-#define glInitNames glad_glInitNames
-GLAD_API_CALL PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays;
-#define glInterleavedArrays glad_glInterleavedArrays
-GLAD_API_CALL PFNGLISBUFFERPROC glad_glIsBuffer;
-#define glIsBuffer glad_glIsBuffer
-GLAD_API_CALL PFNGLISENABLEDPROC glad_glIsEnabled;
-#define glIsEnabled glad_glIsEnabled
-GLAD_API_CALL PFNGLISENABLEDIPROC glad_glIsEnabledi;
-#define glIsEnabledi glad_glIsEnabledi
-GLAD_API_CALL PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
-#define glIsFramebuffer glad_glIsFramebuffer
-GLAD_API_CALL PFNGLISLISTPROC glad_glIsList;
-#define glIsList glad_glIsList
-GLAD_API_CALL PFNGLISPROGRAMPROC glad_glIsProgram;
-#define glIsProgram glad_glIsProgram
-GLAD_API_CALL PFNGLISQUERYPROC glad_glIsQuery;
-#define glIsQuery glad_glIsQuery
-GLAD_API_CALL PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
-#define glIsRenderbuffer glad_glIsRenderbuffer
-GLAD_API_CALL PFNGLISSAMPLERPROC glad_glIsSampler;
-#define glIsSampler glad_glIsSampler
-GLAD_API_CALL PFNGLISSHADERPROC glad_glIsShader;
-#define glIsShader glad_glIsShader
-GLAD_API_CALL PFNGLISSYNCPROC glad_glIsSync;
-#define glIsSync glad_glIsSync
-GLAD_API_CALL PFNGLISTEXTUREPROC glad_glIsTexture;
-#define glIsTexture glad_glIsTexture
-GLAD_API_CALL PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
-#define glIsVertexArray glad_glIsVertexArray
-GLAD_API_CALL PFNGLLIGHTMODELFPROC glad_glLightModelf;
-#define glLightModelf glad_glLightModelf
-GLAD_API_CALL PFNGLLIGHTMODELFVPROC glad_glLightModelfv;
-#define glLightModelfv glad_glLightModelfv
-GLAD_API_CALL PFNGLLIGHTMODELIPROC glad_glLightModeli;
-#define glLightModeli glad_glLightModeli
-GLAD_API_CALL PFNGLLIGHTMODELIVPROC glad_glLightModeliv;
-#define glLightModeliv glad_glLightModeliv
-GLAD_API_CALL PFNGLLIGHTFPROC glad_glLightf;
-#define glLightf glad_glLightf
-GLAD_API_CALL PFNGLLIGHTFVPROC glad_glLightfv;
-#define glLightfv glad_glLightfv
-GLAD_API_CALL PFNGLLIGHTIPROC glad_glLighti;
-#define glLighti glad_glLighti
-GLAD_API_CALL PFNGLLIGHTIVPROC glad_glLightiv;
-#define glLightiv glad_glLightiv
-GLAD_API_CALL PFNGLLINESTIPPLEPROC glad_glLineStipple;
-#define glLineStipple glad_glLineStipple
-GLAD_API_CALL PFNGLLINEWIDTHPROC glad_glLineWidth;
-#define glLineWidth glad_glLineWidth
-GLAD_API_CALL PFNGLLINKPROGRAMPROC glad_glLinkProgram;
-#define glLinkProgram glad_glLinkProgram
-GLAD_API_CALL PFNGLLISTBASEPROC glad_glListBase;
-#define glListBase glad_glListBase
-GLAD_API_CALL PFNGLLOADIDENTITYPROC glad_glLoadIdentity;
-#define glLoadIdentity glad_glLoadIdentity
-GLAD_API_CALL PFNGLLOADMATRIXDPROC glad_glLoadMatrixd;
-#define glLoadMatrixd glad_glLoadMatrixd
-GLAD_API_CALL PFNGLLOADMATRIXFPROC glad_glLoadMatrixf;
-#define glLoadMatrixf glad_glLoadMatrixf
-GLAD_API_CALL PFNGLLOADNAMEPROC glad_glLoadName;
-#define glLoadName glad_glLoadName
-GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd;
-#define glLoadTransposeMatrixd glad_glLoadTransposeMatrixd
-GLAD_API_CALL PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf;
-#define glLoadTransposeMatrixf glad_glLoadTransposeMatrixf
-GLAD_API_CALL PFNGLLOGICOPPROC glad_glLogicOp;
-#define glLogicOp glad_glLogicOp
-GLAD_API_CALL PFNGLMAP1DPROC glad_glMap1d;
-#define glMap1d glad_glMap1d
-GLAD_API_CALL PFNGLMAP1FPROC glad_glMap1f;
-#define glMap1f glad_glMap1f
-GLAD_API_CALL PFNGLMAP2DPROC glad_glMap2d;
-#define glMap2d glad_glMap2d
-GLAD_API_CALL PFNGLMAP2FPROC glad_glMap2f;
-#define glMap2f glad_glMap2f
-GLAD_API_CALL PFNGLMAPBUFFERPROC glad_glMapBuffer;
-#define glMapBuffer glad_glMapBuffer
-GLAD_API_CALL PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
-#define glMapBufferRange glad_glMapBufferRange
-GLAD_API_CALL PFNGLMAPGRID1DPROC glad_glMapGrid1d;
-#define glMapGrid1d glad_glMapGrid1d
-GLAD_API_CALL PFNGLMAPGRID1FPROC glad_glMapGrid1f;
-#define glMapGrid1f glad_glMapGrid1f
-GLAD_API_CALL PFNGLMAPGRID2DPROC glad_glMapGrid2d;
-#define glMapGrid2d glad_glMapGrid2d
-GLAD_API_CALL PFNGLMAPGRID2FPROC glad_glMapGrid2f;
-#define glMapGrid2f glad_glMapGrid2f
-GLAD_API_CALL PFNGLMATERIALFPROC glad_glMaterialf;
-#define glMaterialf glad_glMaterialf
-GLAD_API_CALL PFNGLMATERIALFVPROC glad_glMaterialfv;
-#define glMaterialfv glad_glMaterialfv
-GLAD_API_CALL PFNGLMATERIALIPROC glad_glMateriali;
-#define glMateriali glad_glMateriali
-GLAD_API_CALL PFNGLMATERIALIVPROC glad_glMaterialiv;
-#define glMaterialiv glad_glMaterialiv
-GLAD_API_CALL PFNGLMATRIXMODEPROC glad_glMatrixMode;
-#define glMatrixMode glad_glMatrixMode
-GLAD_API_CALL PFNGLMULTMATRIXDPROC glad_glMultMatrixd;
-#define glMultMatrixd glad_glMultMatrixd
-GLAD_API_CALL PFNGLMULTMATRIXFPROC glad_glMultMatrixf;
-#define glMultMatrixf glad_glMultMatrixf
-GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd;
-#define glMultTransposeMatrixd glad_glMultTransposeMatrixd
-GLAD_API_CALL PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf;
-#define glMultTransposeMatrixf glad_glMultTransposeMatrixf
-GLAD_API_CALL PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
-#define glMultiDrawArrays glad_glMultiDrawArrays
-GLAD_API_CALL PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
-#define glMultiDrawElements glad_glMultiDrawElements
-GLAD_API_CALL PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
-#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
-GLAD_API_CALL PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d;
-#define glMultiTexCoord1d glad_glMultiTexCoord1d
-GLAD_API_CALL PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv;
-#define glMultiTexCoord1dv glad_glMultiTexCoord1dv
-GLAD_API_CALL PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f;
-#define glMultiTexCoord1f glad_glMultiTexCoord1f
-GLAD_API_CALL PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv;
-#define glMultiTexCoord1fv glad_glMultiTexCoord1fv
-GLAD_API_CALL PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i;
-#define glMultiTexCoord1i glad_glMultiTexCoord1i
-GLAD_API_CALL PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv;
-#define glMultiTexCoord1iv glad_glMultiTexCoord1iv
-GLAD_API_CALL PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s;
-#define glMultiTexCoord1s glad_glMultiTexCoord1s
-GLAD_API_CALL PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv;
-#define glMultiTexCoord1sv glad_glMultiTexCoord1sv
-GLAD_API_CALL PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d;
-#define glMultiTexCoord2d glad_glMultiTexCoord2d
-GLAD_API_CALL PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv;
-#define glMultiTexCoord2dv glad_glMultiTexCoord2dv
-GLAD_API_CALL PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f;
-#define glMultiTexCoord2f glad_glMultiTexCoord2f
-GLAD_API_CALL PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv;
-#define glMultiTexCoord2fv glad_glMultiTexCoord2fv
-GLAD_API_CALL PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i;
-#define glMultiTexCoord2i glad_glMultiTexCoord2i
-GLAD_API_CALL PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv;
-#define glMultiTexCoord2iv glad_glMultiTexCoord2iv
-GLAD_API_CALL PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s;
-#define glMultiTexCoord2s glad_glMultiTexCoord2s
-GLAD_API_CALL PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv;
-#define glMultiTexCoord2sv glad_glMultiTexCoord2sv
-GLAD_API_CALL PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d;
-#define glMultiTexCoord3d glad_glMultiTexCoord3d
-GLAD_API_CALL PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv;
-#define glMultiTexCoord3dv glad_glMultiTexCoord3dv
-GLAD_API_CALL PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f;
-#define glMultiTexCoord3f glad_glMultiTexCoord3f
-GLAD_API_CALL PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv;
-#define glMultiTexCoord3fv glad_glMultiTexCoord3fv
-GLAD_API_CALL PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i;
-#define glMultiTexCoord3i glad_glMultiTexCoord3i
-GLAD_API_CALL PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv;
-#define glMultiTexCoord3iv glad_glMultiTexCoord3iv
-GLAD_API_CALL PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s;
-#define glMultiTexCoord3s glad_glMultiTexCoord3s
-GLAD_API_CALL PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv;
-#define glMultiTexCoord3sv glad_glMultiTexCoord3sv
-GLAD_API_CALL PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d;
-#define glMultiTexCoord4d glad_glMultiTexCoord4d
-GLAD_API_CALL PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv;
-#define glMultiTexCoord4dv glad_glMultiTexCoord4dv
-GLAD_API_CALL PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f;
-#define glMultiTexCoord4f glad_glMultiTexCoord4f
-GLAD_API_CALL PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv;
-#define glMultiTexCoord4fv glad_glMultiTexCoord4fv
-GLAD_API_CALL PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i;
-#define glMultiTexCoord4i glad_glMultiTexCoord4i
-GLAD_API_CALL PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv;
-#define glMultiTexCoord4iv glad_glMultiTexCoord4iv
-GLAD_API_CALL PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s;
-#define glMultiTexCoord4s glad_glMultiTexCoord4s
-GLAD_API_CALL PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv;
-#define glMultiTexCoord4sv glad_glMultiTexCoord4sv
-GLAD_API_CALL PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
-#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
-#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
-#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
-#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
-#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
-#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
-GLAD_API_CALL PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
-#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
-GLAD_API_CALL PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
-#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
-GLAD_API_CALL PFNGLNEWLISTPROC glad_glNewList;
-#define glNewList glad_glNewList
-GLAD_API_CALL PFNGLNORMAL3BPROC glad_glNormal3b;
-#define glNormal3b glad_glNormal3b
-GLAD_API_CALL PFNGLNORMAL3BVPROC glad_glNormal3bv;
-#define glNormal3bv glad_glNormal3bv
-GLAD_API_CALL PFNGLNORMAL3DPROC glad_glNormal3d;
-#define glNormal3d glad_glNormal3d
-GLAD_API_CALL PFNGLNORMAL3DVPROC glad_glNormal3dv;
-#define glNormal3dv glad_glNormal3dv
-GLAD_API_CALL PFNGLNORMAL3FPROC glad_glNormal3f;
-#define glNormal3f glad_glNormal3f
-GLAD_API_CALL PFNGLNORMAL3FVPROC glad_glNormal3fv;
-#define glNormal3fv glad_glNormal3fv
-GLAD_API_CALL PFNGLNORMAL3IPROC glad_glNormal3i;
-#define glNormal3i glad_glNormal3i
-GLAD_API_CALL PFNGLNORMAL3IVPROC glad_glNormal3iv;
-#define glNormal3iv glad_glNormal3iv
-GLAD_API_CALL PFNGLNORMAL3SPROC glad_glNormal3s;
-#define glNormal3s glad_glNormal3s
-GLAD_API_CALL PFNGLNORMAL3SVPROC glad_glNormal3sv;
-#define glNormal3sv glad_glNormal3sv
-GLAD_API_CALL PFNGLNORMALP3UIPROC glad_glNormalP3ui;
-#define glNormalP3ui glad_glNormalP3ui
-GLAD_API_CALL PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
-#define glNormalP3uiv glad_glNormalP3uiv
-GLAD_API_CALL PFNGLNORMALPOINTERPROC glad_glNormalPointer;
-#define glNormalPointer glad_glNormalPointer
-GLAD_API_CALL PFNGLOBJECTLABELPROC glad_glObjectLabel;
-#define glObjectLabel glad_glObjectLabel
-GLAD_API_CALL PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
-#define glObjectPtrLabel glad_glObjectPtrLabel
-GLAD_API_CALL PFNGLORTHOPROC glad_glOrtho;
-#define glOrtho glad_glOrtho
-GLAD_API_CALL PFNGLPASSTHROUGHPROC glad_glPassThrough;
-#define glPassThrough glad_glPassThrough
-GLAD_API_CALL PFNGLPIXELMAPFVPROC glad_glPixelMapfv;
-#define glPixelMapfv glad_glPixelMapfv
-GLAD_API_CALL PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv;
-#define glPixelMapuiv glad_glPixelMapuiv
-GLAD_API_CALL PFNGLPIXELMAPUSVPROC glad_glPixelMapusv;
-#define glPixelMapusv glad_glPixelMapusv
-GLAD_API_CALL PFNGLPIXELSTOREFPROC glad_glPixelStoref;
-#define glPixelStoref glad_glPixelStoref
-GLAD_API_CALL PFNGLPIXELSTOREIPROC glad_glPixelStorei;
-#define glPixelStorei glad_glPixelStorei
-GLAD_API_CALL PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf;
-#define glPixelTransferf glad_glPixelTransferf
-GLAD_API_CALL PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi;
-#define glPixelTransferi glad_glPixelTransferi
-GLAD_API_CALL PFNGLPIXELZOOMPROC glad_glPixelZoom;
-#define glPixelZoom glad_glPixelZoom
-GLAD_API_CALL PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
-#define glPointParameterf glad_glPointParameterf
-GLAD_API_CALL PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
-#define glPointParameterfv glad_glPointParameterfv
-GLAD_API_CALL PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
-#define glPointParameteri glad_glPointParameteri
-GLAD_API_CALL PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
-#define glPointParameteriv glad_glPointParameteriv
-GLAD_API_CALL PFNGLPOINTSIZEPROC glad_glPointSize;
-#define glPointSize glad_glPointSize
-GLAD_API_CALL PFNGLPOLYGONMODEPROC glad_glPolygonMode;
-#define glPolygonMode glad_glPolygonMode
-GLAD_API_CALL PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
-#define glPolygonOffset glad_glPolygonOffset
-GLAD_API_CALL PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple;
-#define glPolygonStipple glad_glPolygonStipple
-GLAD_API_CALL PFNGLPOPATTRIBPROC glad_glPopAttrib;
-#define glPopAttrib glad_glPopAttrib
-GLAD_API_CALL PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib;
-#define glPopClientAttrib glad_glPopClientAttrib
-GLAD_API_CALL PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
-#define glPopDebugGroup glad_glPopDebugGroup
-GLAD_API_CALL PFNGLPOPMATRIXPROC glad_glPopMatrix;
-#define glPopMatrix glad_glPopMatrix
-GLAD_API_CALL PFNGLPOPNAMEPROC glad_glPopName;
-#define glPopName glad_glPopName
-GLAD_API_CALL PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
-#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
-GLAD_API_CALL PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures;
-#define glPrioritizeTextures glad_glPrioritizeTextures
-GLAD_API_CALL PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
-#define glProvokingVertex glad_glProvokingVertex
-GLAD_API_CALL PFNGLPUSHATTRIBPROC glad_glPushAttrib;
-#define glPushAttrib glad_glPushAttrib
-GLAD_API_CALL PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib;
-#define glPushClientAttrib glad_glPushClientAttrib
-GLAD_API_CALL PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
-#define glPushDebugGroup glad_glPushDebugGroup
-GLAD_API_CALL PFNGLPUSHMATRIXPROC glad_glPushMatrix;
-#define glPushMatrix glad_glPushMatrix
-GLAD_API_CALL PFNGLPUSHNAMEPROC glad_glPushName;
-#define glPushName glad_glPushName
-GLAD_API_CALL PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
-#define glQueryCounter glad_glQueryCounter
-GLAD_API_CALL PFNGLRASTERPOS2DPROC glad_glRasterPos2d;
-#define glRasterPos2d glad_glRasterPos2d
-GLAD_API_CALL PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv;
-#define glRasterPos2dv glad_glRasterPos2dv
-GLAD_API_CALL PFNGLRASTERPOS2FPROC glad_glRasterPos2f;
-#define glRasterPos2f glad_glRasterPos2f
-GLAD_API_CALL PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv;
-#define glRasterPos2fv glad_glRasterPos2fv
-GLAD_API_CALL PFNGLRASTERPOS2IPROC glad_glRasterPos2i;
-#define glRasterPos2i glad_glRasterPos2i
-GLAD_API_CALL PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv;
-#define glRasterPos2iv glad_glRasterPos2iv
-GLAD_API_CALL PFNGLRASTERPOS2SPROC glad_glRasterPos2s;
-#define glRasterPos2s glad_glRasterPos2s
-GLAD_API_CALL PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv;
-#define glRasterPos2sv glad_glRasterPos2sv
-GLAD_API_CALL PFNGLRASTERPOS3DPROC glad_glRasterPos3d;
-#define glRasterPos3d glad_glRasterPos3d
-GLAD_API_CALL PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv;
-#define glRasterPos3dv glad_glRasterPos3dv
-GLAD_API_CALL PFNGLRASTERPOS3FPROC glad_glRasterPos3f;
-#define glRasterPos3f glad_glRasterPos3f
-GLAD_API_CALL PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv;
-#define glRasterPos3fv glad_glRasterPos3fv
-GLAD_API_CALL PFNGLRASTERPOS3IPROC glad_glRasterPos3i;
-#define glRasterPos3i glad_glRasterPos3i
-GLAD_API_CALL PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv;
-#define glRasterPos3iv glad_glRasterPos3iv
-GLAD_API_CALL PFNGLRASTERPOS3SPROC glad_glRasterPos3s;
-#define glRasterPos3s glad_glRasterPos3s
-GLAD_API_CALL PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv;
-#define glRasterPos3sv glad_glRasterPos3sv
-GLAD_API_CALL PFNGLRASTERPOS4DPROC glad_glRasterPos4d;
-#define glRasterPos4d glad_glRasterPos4d
-GLAD_API_CALL PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv;
-#define glRasterPos4dv glad_glRasterPos4dv
-GLAD_API_CALL PFNGLRASTERPOS4FPROC glad_glRasterPos4f;
-#define glRasterPos4f glad_glRasterPos4f
-GLAD_API_CALL PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv;
-#define glRasterPos4fv glad_glRasterPos4fv
-GLAD_API_CALL PFNGLRASTERPOS4IPROC glad_glRasterPos4i;
-#define glRasterPos4i glad_glRasterPos4i
-GLAD_API_CALL PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv;
-#define glRasterPos4iv glad_glRasterPos4iv
-GLAD_API_CALL PFNGLRASTERPOS4SPROC glad_glRasterPos4s;
-#define glRasterPos4s glad_glRasterPos4s
-GLAD_API_CALL PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv;
-#define glRasterPos4sv glad_glRasterPos4sv
-GLAD_API_CALL PFNGLREADBUFFERPROC glad_glReadBuffer;
-#define glReadBuffer glad_glReadBuffer
-GLAD_API_CALL PFNGLREADPIXELSPROC glad_glReadPixels;
-#define glReadPixels glad_glReadPixels
-GLAD_API_CALL PFNGLREADNPIXELSPROC glad_glReadnPixels;
-#define glReadnPixels glad_glReadnPixels
-GLAD_API_CALL PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB;
-#define glReadnPixelsARB glad_glReadnPixelsARB
-GLAD_API_CALL PFNGLRECTDPROC glad_glRectd;
-#define glRectd glad_glRectd
-GLAD_API_CALL PFNGLRECTDVPROC glad_glRectdv;
-#define glRectdv glad_glRectdv
-GLAD_API_CALL PFNGLRECTFPROC glad_glRectf;
-#define glRectf glad_glRectf
-GLAD_API_CALL PFNGLRECTFVPROC glad_glRectfv;
-#define glRectfv glad_glRectfv
-GLAD_API_CALL PFNGLRECTIPROC glad_glRecti;
-#define glRecti glad_glRecti
-GLAD_API_CALL PFNGLRECTIVPROC glad_glRectiv;
-#define glRectiv glad_glRectiv
-GLAD_API_CALL PFNGLRECTSPROC glad_glRects;
-#define glRects glad_glRects
-GLAD_API_CALL PFNGLRECTSVPROC glad_glRectsv;
-#define glRectsv glad_glRectsv
-GLAD_API_CALL PFNGLRENDERMODEPROC glad_glRenderMode;
-#define glRenderMode glad_glRenderMode
-GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
-#define glRenderbufferStorage glad_glRenderbufferStorage
-GLAD_API_CALL PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
-#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
-GLAD_API_CALL PFNGLROTATEDPROC glad_glRotated;
-#define glRotated glad_glRotated
-GLAD_API_CALL PFNGLROTATEFPROC glad_glRotatef;
-#define glRotatef glad_glRotatef
-GLAD_API_CALL PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
-#define glSampleCoverage glad_glSampleCoverage
-GLAD_API_CALL PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB;
-#define glSampleCoverageARB glad_glSampleCoverageARB
-GLAD_API_CALL PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
-#define glSampleMaski glad_glSampleMaski
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
-#define glSamplerParameterIiv glad_glSamplerParameterIiv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
-#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
-#define glSamplerParameterf glad_glSamplerParameterf
-GLAD_API_CALL PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
-#define glSamplerParameterfv glad_glSamplerParameterfv
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
-#define glSamplerParameteri glad_glSamplerParameteri
-GLAD_API_CALL PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
-#define glSamplerParameteriv glad_glSamplerParameteriv
-GLAD_API_CALL PFNGLSCALEDPROC glad_glScaled;
-#define glScaled glad_glScaled
-GLAD_API_CALL PFNGLSCALEFPROC glad_glScalef;
-#define glScalef glad_glScalef
-GLAD_API_CALL PFNGLSCISSORPROC glad_glScissor;
-#define glScissor glad_glScissor
-GLAD_API_CALL PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b;
-#define glSecondaryColor3b glad_glSecondaryColor3b
-GLAD_API_CALL PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv;
-#define glSecondaryColor3bv glad_glSecondaryColor3bv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d;
-#define glSecondaryColor3d glad_glSecondaryColor3d
-GLAD_API_CALL PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv;
-#define glSecondaryColor3dv glad_glSecondaryColor3dv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f;
-#define glSecondaryColor3f glad_glSecondaryColor3f
-GLAD_API_CALL PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv;
-#define glSecondaryColor3fv glad_glSecondaryColor3fv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i;
-#define glSecondaryColor3i glad_glSecondaryColor3i
-GLAD_API_CALL PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv;
-#define glSecondaryColor3iv glad_glSecondaryColor3iv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s;
-#define glSecondaryColor3s glad_glSecondaryColor3s
-GLAD_API_CALL PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv;
-#define glSecondaryColor3sv glad_glSecondaryColor3sv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub;
-#define glSecondaryColor3ub glad_glSecondaryColor3ub
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv;
-#define glSecondaryColor3ubv glad_glSecondaryColor3ubv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui;
-#define glSecondaryColor3ui glad_glSecondaryColor3ui
-GLAD_API_CALL PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv;
-#define glSecondaryColor3uiv glad_glSecondaryColor3uiv
-GLAD_API_CALL PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us;
-#define glSecondaryColor3us glad_glSecondaryColor3us
-GLAD_API_CALL PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv;
-#define glSecondaryColor3usv glad_glSecondaryColor3usv
-GLAD_API_CALL PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
-#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
-GLAD_API_CALL PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
-#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
-GLAD_API_CALL PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer;
-#define glSecondaryColorPointer glad_glSecondaryColorPointer
-GLAD_API_CALL PFNGLSELECTBUFFERPROC glad_glSelectBuffer;
-#define glSelectBuffer glad_glSelectBuffer
-GLAD_API_CALL PFNGLSHADEMODELPROC glad_glShadeModel;
-#define glShadeModel glad_glShadeModel
-GLAD_API_CALL PFNGLSHADERSOURCEPROC glad_glShaderSource;
-#define glShaderSource glad_glShaderSource
-GLAD_API_CALL PFNGLSTENCILFUNCPROC glad_glStencilFunc;
-#define glStencilFunc glad_glStencilFunc
-GLAD_API_CALL PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
-#define glStencilFuncSeparate glad_glStencilFuncSeparate
-GLAD_API_CALL PFNGLSTENCILMASKPROC glad_glStencilMask;
-#define glStencilMask glad_glStencilMask
-GLAD_API_CALL PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
-#define glStencilMaskSeparate glad_glStencilMaskSeparate
-GLAD_API_CALL PFNGLSTENCILOPPROC glad_glStencilOp;
-#define glStencilOp glad_glStencilOp
-GLAD_API_CALL PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
-#define glStencilOpSeparate glad_glStencilOpSeparate
-GLAD_API_CALL PFNGLTEXBUFFERPROC glad_glTexBuffer;
-#define glTexBuffer glad_glTexBuffer
-GLAD_API_CALL PFNGLTEXCOORD1DPROC glad_glTexCoord1d;
-#define glTexCoord1d glad_glTexCoord1d
-GLAD_API_CALL PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv;
-#define glTexCoord1dv glad_glTexCoord1dv
-GLAD_API_CALL PFNGLTEXCOORD1FPROC glad_glTexCoord1f;
-#define glTexCoord1f glad_glTexCoord1f
-GLAD_API_CALL PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv;
-#define glTexCoord1fv glad_glTexCoord1fv
-GLAD_API_CALL PFNGLTEXCOORD1IPROC glad_glTexCoord1i;
-#define glTexCoord1i glad_glTexCoord1i
-GLAD_API_CALL PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv;
-#define glTexCoord1iv glad_glTexCoord1iv
-GLAD_API_CALL PFNGLTEXCOORD1SPROC glad_glTexCoord1s;
-#define glTexCoord1s glad_glTexCoord1s
-GLAD_API_CALL PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv;
-#define glTexCoord1sv glad_glTexCoord1sv
-GLAD_API_CALL PFNGLTEXCOORD2DPROC glad_glTexCoord2d;
-#define glTexCoord2d glad_glTexCoord2d
-GLAD_API_CALL PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv;
-#define glTexCoord2dv glad_glTexCoord2dv
-GLAD_API_CALL PFNGLTEXCOORD2FPROC glad_glTexCoord2f;
-#define glTexCoord2f glad_glTexCoord2f
-GLAD_API_CALL PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv;
-#define glTexCoord2fv glad_glTexCoord2fv
-GLAD_API_CALL PFNGLTEXCOORD2IPROC glad_glTexCoord2i;
-#define glTexCoord2i glad_glTexCoord2i
-GLAD_API_CALL PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv;
-#define glTexCoord2iv glad_glTexCoord2iv
-GLAD_API_CALL PFNGLTEXCOORD2SPROC glad_glTexCoord2s;
-#define glTexCoord2s glad_glTexCoord2s
-GLAD_API_CALL PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv;
-#define glTexCoord2sv glad_glTexCoord2sv
-GLAD_API_CALL PFNGLTEXCOORD3DPROC glad_glTexCoord3d;
-#define glTexCoord3d glad_glTexCoord3d
-GLAD_API_CALL PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv;
-#define glTexCoord3dv glad_glTexCoord3dv
-GLAD_API_CALL PFNGLTEXCOORD3FPROC glad_glTexCoord3f;
-#define glTexCoord3f glad_glTexCoord3f
-GLAD_API_CALL PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv;
-#define glTexCoord3fv glad_glTexCoord3fv
-GLAD_API_CALL PFNGLTEXCOORD3IPROC glad_glTexCoord3i;
-#define glTexCoord3i glad_glTexCoord3i
-GLAD_API_CALL PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv;
-#define glTexCoord3iv glad_glTexCoord3iv
-GLAD_API_CALL PFNGLTEXCOORD3SPROC glad_glTexCoord3s;
-#define glTexCoord3s glad_glTexCoord3s
-GLAD_API_CALL PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv;
-#define glTexCoord3sv glad_glTexCoord3sv
-GLAD_API_CALL PFNGLTEXCOORD4DPROC glad_glTexCoord4d;
-#define glTexCoord4d glad_glTexCoord4d
-GLAD_API_CALL PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv;
-#define glTexCoord4dv glad_glTexCoord4dv
-GLAD_API_CALL PFNGLTEXCOORD4FPROC glad_glTexCoord4f;
-#define glTexCoord4f glad_glTexCoord4f
-GLAD_API_CALL PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv;
-#define glTexCoord4fv glad_glTexCoord4fv
-GLAD_API_CALL PFNGLTEXCOORD4IPROC glad_glTexCoord4i;
-#define glTexCoord4i glad_glTexCoord4i
-GLAD_API_CALL PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv;
-#define glTexCoord4iv glad_glTexCoord4iv
-GLAD_API_CALL PFNGLTEXCOORD4SPROC glad_glTexCoord4s;
-#define glTexCoord4s glad_glTexCoord4s
-GLAD_API_CALL PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv;
-#define glTexCoord4sv glad_glTexCoord4sv
-GLAD_API_CALL PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
-#define glTexCoordP1ui glad_glTexCoordP1ui
-GLAD_API_CALL PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
-#define glTexCoordP1uiv glad_glTexCoordP1uiv
-GLAD_API_CALL PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
-#define glTexCoordP2ui glad_glTexCoordP2ui
-GLAD_API_CALL PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
-#define glTexCoordP2uiv glad_glTexCoordP2uiv
-GLAD_API_CALL PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
-#define glTexCoordP3ui glad_glTexCoordP3ui
-GLAD_API_CALL PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
-#define glTexCoordP3uiv glad_glTexCoordP3uiv
-GLAD_API_CALL PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
-#define glTexCoordP4ui glad_glTexCoordP4ui
-GLAD_API_CALL PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
-#define glTexCoordP4uiv glad_glTexCoordP4uiv
-GLAD_API_CALL PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer;
-#define glTexCoordPointer glad_glTexCoordPointer
-GLAD_API_CALL PFNGLTEXENVFPROC glad_glTexEnvf;
-#define glTexEnvf glad_glTexEnvf
-GLAD_API_CALL PFNGLTEXENVFVPROC glad_glTexEnvfv;
-#define glTexEnvfv glad_glTexEnvfv
-GLAD_API_CALL PFNGLTEXENVIPROC glad_glTexEnvi;
-#define glTexEnvi glad_glTexEnvi
-GLAD_API_CALL PFNGLTEXENVIVPROC glad_glTexEnviv;
-#define glTexEnviv glad_glTexEnviv
-GLAD_API_CALL PFNGLTEXGENDPROC glad_glTexGend;
-#define glTexGend glad_glTexGend
-GLAD_API_CALL PFNGLTEXGENDVPROC glad_glTexGendv;
-#define glTexGendv glad_glTexGendv
-GLAD_API_CALL PFNGLTEXGENFPROC glad_glTexGenf;
-#define glTexGenf glad_glTexGenf
-GLAD_API_CALL PFNGLTEXGENFVPROC glad_glTexGenfv;
-#define glTexGenfv glad_glTexGenfv
-GLAD_API_CALL PFNGLTEXGENIPROC glad_glTexGeni;
-#define glTexGeni glad_glTexGeni
-GLAD_API_CALL PFNGLTEXGENIVPROC glad_glTexGeniv;
-#define glTexGeniv glad_glTexGeniv
-GLAD_API_CALL PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
-#define glTexImage1D glad_glTexImage1D
-GLAD_API_CALL PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
-#define glTexImage2D glad_glTexImage2D
-GLAD_API_CALL PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
-#define glTexImage2DMultisample glad_glTexImage2DMultisample
-GLAD_API_CALL PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
-#define glTexImage3D glad_glTexImage3D
-GLAD_API_CALL PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
-#define glTexImage3DMultisample glad_glTexImage3DMultisample
-GLAD_API_CALL PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
-#define glTexParameterIiv glad_glTexParameterIiv
-GLAD_API_CALL PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
-#define glTexParameterIuiv glad_glTexParameterIuiv
-GLAD_API_CALL PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
-#define glTexParameterf glad_glTexParameterf
-GLAD_API_CALL PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
-#define glTexParameterfv glad_glTexParameterfv
-GLAD_API_CALL PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
-#define glTexParameteri glad_glTexParameteri
-GLAD_API_CALL PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
-#define glTexParameteriv glad_glTexParameteriv
-GLAD_API_CALL PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
-#define glTexSubImage1D glad_glTexSubImage1D
-GLAD_API_CALL PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
-#define glTexSubImage2D glad_glTexSubImage2D
-GLAD_API_CALL PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
-#define glTexSubImage3D glad_glTexSubImage3D
-GLAD_API_CALL PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
-#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
-GLAD_API_CALL PFNGLTRANSLATEDPROC glad_glTranslated;
-#define glTranslated glad_glTranslated
-GLAD_API_CALL PFNGLTRANSLATEFPROC glad_glTranslatef;
-#define glTranslatef glad_glTranslatef
-GLAD_API_CALL PFNGLUNIFORM1FPROC glad_glUniform1f;
-#define glUniform1f glad_glUniform1f
-GLAD_API_CALL PFNGLUNIFORM1FVPROC glad_glUniform1fv;
-#define glUniform1fv glad_glUniform1fv
-GLAD_API_CALL PFNGLUNIFORM1IPROC glad_glUniform1i;
-#define glUniform1i glad_glUniform1i
-GLAD_API_CALL PFNGLUNIFORM1IVPROC glad_glUniform1iv;
-#define glUniform1iv glad_glUniform1iv
-GLAD_API_CALL PFNGLUNIFORM1UIPROC glad_glUniform1ui;
-#define glUniform1ui glad_glUniform1ui
-GLAD_API_CALL PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
-#define glUniform1uiv glad_glUniform1uiv
-GLAD_API_CALL PFNGLUNIFORM2FPROC glad_glUniform2f;
-#define glUniform2f glad_glUniform2f
-GLAD_API_CALL PFNGLUNIFORM2FVPROC glad_glUniform2fv;
-#define glUniform2fv glad_glUniform2fv
-GLAD_API_CALL PFNGLUNIFORM2IPROC glad_glUniform2i;
-#define glUniform2i glad_glUniform2i
-GLAD_API_CALL PFNGLUNIFORM2IVPROC glad_glUniform2iv;
-#define glUniform2iv glad_glUniform2iv
-GLAD_API_CALL PFNGLUNIFORM2UIPROC glad_glUniform2ui;
-#define glUniform2ui glad_glUniform2ui
-GLAD_API_CALL PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
-#define glUniform2uiv glad_glUniform2uiv
-GLAD_API_CALL PFNGLUNIFORM3FPROC glad_glUniform3f;
-#define glUniform3f glad_glUniform3f
-GLAD_API_CALL PFNGLUNIFORM3FVPROC glad_glUniform3fv;
-#define glUniform3fv glad_glUniform3fv
-GLAD_API_CALL PFNGLUNIFORM3IPROC glad_glUniform3i;
-#define glUniform3i glad_glUniform3i
-GLAD_API_CALL PFNGLUNIFORM3IVPROC glad_glUniform3iv;
-#define glUniform3iv glad_glUniform3iv
-GLAD_API_CALL PFNGLUNIFORM3UIPROC glad_glUniform3ui;
-#define glUniform3ui glad_glUniform3ui
-GLAD_API_CALL PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
-#define glUniform3uiv glad_glUniform3uiv
-GLAD_API_CALL PFNGLUNIFORM4FPROC glad_glUniform4f;
-#define glUniform4f glad_glUniform4f
-GLAD_API_CALL PFNGLUNIFORM4FVPROC glad_glUniform4fv;
-#define glUniform4fv glad_glUniform4fv
-GLAD_API_CALL PFNGLUNIFORM4IPROC glad_glUniform4i;
-#define glUniform4i glad_glUniform4i
-GLAD_API_CALL PFNGLUNIFORM4IVPROC glad_glUniform4iv;
-#define glUniform4iv glad_glUniform4iv
-GLAD_API_CALL PFNGLUNIFORM4UIPROC glad_glUniform4ui;
-#define glUniform4ui glad_glUniform4ui
-GLAD_API_CALL PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
-#define glUniform4uiv glad_glUniform4uiv
-GLAD_API_CALL PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
-#define glUniformBlockBinding glad_glUniformBlockBinding
-GLAD_API_CALL PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
-#define glUniformMatrix2fv glad_glUniformMatrix2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
-#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
-#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
-#define glUniformMatrix3fv glad_glUniformMatrix3fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
-#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
-#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
-#define glUniformMatrix4fv glad_glUniformMatrix4fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
-#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
-GLAD_API_CALL PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
-#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
-GLAD_API_CALL PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
-#define glUnmapBuffer glad_glUnmapBuffer
-GLAD_API_CALL PFNGLUSEPROGRAMPROC glad_glUseProgram;
-#define glUseProgram glad_glUseProgram
-GLAD_API_CALL PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
-#define glValidateProgram glad_glValidateProgram
-GLAD_API_CALL PFNGLVERTEX2DPROC glad_glVertex2d;
-#define glVertex2d glad_glVertex2d
-GLAD_API_CALL PFNGLVERTEX2DVPROC glad_glVertex2dv;
-#define glVertex2dv glad_glVertex2dv
-GLAD_API_CALL PFNGLVERTEX2FPROC glad_glVertex2f;
-#define glVertex2f glad_glVertex2f
-GLAD_API_CALL PFNGLVERTEX2FVPROC glad_glVertex2fv;
-#define glVertex2fv glad_glVertex2fv
-GLAD_API_CALL PFNGLVERTEX2IPROC glad_glVertex2i;
-#define glVertex2i glad_glVertex2i
-GLAD_API_CALL PFNGLVERTEX2IVPROC glad_glVertex2iv;
-#define glVertex2iv glad_glVertex2iv
-GLAD_API_CALL PFNGLVERTEX2SPROC glad_glVertex2s;
-#define glVertex2s glad_glVertex2s
-GLAD_API_CALL PFNGLVERTEX2SVPROC glad_glVertex2sv;
-#define glVertex2sv glad_glVertex2sv
-GLAD_API_CALL PFNGLVERTEX3DPROC glad_glVertex3d;
-#define glVertex3d glad_glVertex3d
-GLAD_API_CALL PFNGLVERTEX3DVPROC glad_glVertex3dv;
-#define glVertex3dv glad_glVertex3dv
-GLAD_API_CALL PFNGLVERTEX3FPROC glad_glVertex3f;
-#define glVertex3f glad_glVertex3f
-GLAD_API_CALL PFNGLVERTEX3FVPROC glad_glVertex3fv;
-#define glVertex3fv glad_glVertex3fv
-GLAD_API_CALL PFNGLVERTEX3IPROC glad_glVertex3i;
-#define glVertex3i glad_glVertex3i
-GLAD_API_CALL PFNGLVERTEX3IVPROC glad_glVertex3iv;
-#define glVertex3iv glad_glVertex3iv
-GLAD_API_CALL PFNGLVERTEX3SPROC glad_glVertex3s;
-#define glVertex3s glad_glVertex3s
-GLAD_API_CALL PFNGLVERTEX3SVPROC glad_glVertex3sv;
-#define glVertex3sv glad_glVertex3sv
-GLAD_API_CALL PFNGLVERTEX4DPROC glad_glVertex4d;
-#define glVertex4d glad_glVertex4d
-GLAD_API_CALL PFNGLVERTEX4DVPROC glad_glVertex4dv;
-#define glVertex4dv glad_glVertex4dv
-GLAD_API_CALL PFNGLVERTEX4FPROC glad_glVertex4f;
-#define glVertex4f glad_glVertex4f
-GLAD_API_CALL PFNGLVERTEX4FVPROC glad_glVertex4fv;
-#define glVertex4fv glad_glVertex4fv
-GLAD_API_CALL PFNGLVERTEX4IPROC glad_glVertex4i;
-#define glVertex4i glad_glVertex4i
-GLAD_API_CALL PFNGLVERTEX4IVPROC glad_glVertex4iv;
-#define glVertex4iv glad_glVertex4iv
-GLAD_API_CALL PFNGLVERTEX4SPROC glad_glVertex4s;
-#define glVertex4s glad_glVertex4s
-GLAD_API_CALL PFNGLVERTEX4SVPROC glad_glVertex4sv;
-#define glVertex4sv glad_glVertex4sv
-GLAD_API_CALL PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
-#define glVertexAttrib1d glad_glVertexAttrib1d
-GLAD_API_CALL PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
-#define glVertexAttrib1dv glad_glVertexAttrib1dv
-GLAD_API_CALL PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
-#define glVertexAttrib1f glad_glVertexAttrib1f
-GLAD_API_CALL PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
-#define glVertexAttrib1fv glad_glVertexAttrib1fv
-GLAD_API_CALL PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
-#define glVertexAttrib1s glad_glVertexAttrib1s
-GLAD_API_CALL PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
-#define glVertexAttrib1sv glad_glVertexAttrib1sv
-GLAD_API_CALL PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
-#define glVertexAttrib2d glad_glVertexAttrib2d
-GLAD_API_CALL PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
-#define glVertexAttrib2dv glad_glVertexAttrib2dv
-GLAD_API_CALL PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
-#define glVertexAttrib2f glad_glVertexAttrib2f
-GLAD_API_CALL PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
-#define glVertexAttrib2fv glad_glVertexAttrib2fv
-GLAD_API_CALL PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
-#define glVertexAttrib2s glad_glVertexAttrib2s
-GLAD_API_CALL PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
-#define glVertexAttrib2sv glad_glVertexAttrib2sv
-GLAD_API_CALL PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
-#define glVertexAttrib3d glad_glVertexAttrib3d
-GLAD_API_CALL PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
-#define glVertexAttrib3dv glad_glVertexAttrib3dv
-GLAD_API_CALL PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
-#define glVertexAttrib3f glad_glVertexAttrib3f
-GLAD_API_CALL PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
-#define glVertexAttrib3fv glad_glVertexAttrib3fv
-GLAD_API_CALL PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
-#define glVertexAttrib3s glad_glVertexAttrib3s
-GLAD_API_CALL PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
-#define glVertexAttrib3sv glad_glVertexAttrib3sv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
-#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
-#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
-#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
-#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
-#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
-#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
-GLAD_API_CALL PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
-#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
-GLAD_API_CALL PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
-#define glVertexAttrib4bv glad_glVertexAttrib4bv
-GLAD_API_CALL PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
-#define glVertexAttrib4d glad_glVertexAttrib4d
-GLAD_API_CALL PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
-#define glVertexAttrib4dv glad_glVertexAttrib4dv
-GLAD_API_CALL PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
-#define glVertexAttrib4f glad_glVertexAttrib4f
-GLAD_API_CALL PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
-#define glVertexAttrib4fv glad_glVertexAttrib4fv
-GLAD_API_CALL PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
-#define glVertexAttrib4iv glad_glVertexAttrib4iv
-GLAD_API_CALL PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
-#define glVertexAttrib4s glad_glVertexAttrib4s
-GLAD_API_CALL PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
-#define glVertexAttrib4sv glad_glVertexAttrib4sv
-GLAD_API_CALL PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
-#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
-GLAD_API_CALL PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
-#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
-#define glVertexAttrib4usv glad_glVertexAttrib4usv
-GLAD_API_CALL PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
-#define glVertexAttribDivisor glad_glVertexAttribDivisor
-GLAD_API_CALL PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
-#define glVertexAttribI1i glad_glVertexAttribI1i
-GLAD_API_CALL PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
-#define glVertexAttribI1iv glad_glVertexAttribI1iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
-#define glVertexAttribI1ui glad_glVertexAttribI1ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
-#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
-#define glVertexAttribI2i glad_glVertexAttribI2i
-GLAD_API_CALL PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
-#define glVertexAttribI2iv glad_glVertexAttribI2iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
-#define glVertexAttribI2ui glad_glVertexAttribI2ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
-#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
-#define glVertexAttribI3i glad_glVertexAttribI3i
-GLAD_API_CALL PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
-#define glVertexAttribI3iv glad_glVertexAttribI3iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
-#define glVertexAttribI3ui glad_glVertexAttribI3ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
-#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
-#define glVertexAttribI4bv glad_glVertexAttribI4bv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
-#define glVertexAttribI4i glad_glVertexAttribI4i
-GLAD_API_CALL PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
-#define glVertexAttribI4iv glad_glVertexAttribI4iv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
-#define glVertexAttribI4sv glad_glVertexAttribI4sv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
-#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
-#define glVertexAttribI4ui glad_glVertexAttribI4ui
-GLAD_API_CALL PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
-#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
-#define glVertexAttribI4usv glad_glVertexAttribI4usv
-GLAD_API_CALL PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
-#define glVertexAttribIPointer glad_glVertexAttribIPointer
-GLAD_API_CALL PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
-#define glVertexAttribP1ui glad_glVertexAttribP1ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
-#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
-#define glVertexAttribP2ui glad_glVertexAttribP2ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
-#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
-#define glVertexAttribP3ui glad_glVertexAttribP3ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
-#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
-#define glVertexAttribP4ui glad_glVertexAttribP4ui
-GLAD_API_CALL PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
-#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
-GLAD_API_CALL PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
-#define glVertexAttribPointer glad_glVertexAttribPointer
-GLAD_API_CALL PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
-#define glVertexP2ui glad_glVertexP2ui
-GLAD_API_CALL PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
-#define glVertexP2uiv glad_glVertexP2uiv
-GLAD_API_CALL PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
-#define glVertexP3ui glad_glVertexP3ui
-GLAD_API_CALL PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
-#define glVertexP3uiv glad_glVertexP3uiv
-GLAD_API_CALL PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
-#define glVertexP4ui glad_glVertexP4ui
-GLAD_API_CALL PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
-#define glVertexP4uiv glad_glVertexP4uiv
-GLAD_API_CALL PFNGLVERTEXPOINTERPROC glad_glVertexPointer;
-#define glVertexPointer glad_glVertexPointer
-GLAD_API_CALL PFNGLVIEWPORTPROC glad_glViewport;
-#define glViewport glad_glViewport
-GLAD_API_CALL PFNGLWAITSYNCPROC glad_glWaitSync;
-#define glWaitSync glad_glWaitSync
-GLAD_API_CALL PFNGLWINDOWPOS2DPROC glad_glWindowPos2d;
-#define glWindowPos2d glad_glWindowPos2d
-GLAD_API_CALL PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv;
-#define glWindowPos2dv glad_glWindowPos2dv
-GLAD_API_CALL PFNGLWINDOWPOS2FPROC glad_glWindowPos2f;
-#define glWindowPos2f glad_glWindowPos2f
-GLAD_API_CALL PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv;
-#define glWindowPos2fv glad_glWindowPos2fv
-GLAD_API_CALL PFNGLWINDOWPOS2IPROC glad_glWindowPos2i;
-#define glWindowPos2i glad_glWindowPos2i
-GLAD_API_CALL PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv;
-#define glWindowPos2iv glad_glWindowPos2iv
-GLAD_API_CALL PFNGLWINDOWPOS2SPROC glad_glWindowPos2s;
-#define glWindowPos2s glad_glWindowPos2s
-GLAD_API_CALL PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv;
-#define glWindowPos2sv glad_glWindowPos2sv
-GLAD_API_CALL PFNGLWINDOWPOS3DPROC glad_glWindowPos3d;
-#define glWindowPos3d glad_glWindowPos3d
-GLAD_API_CALL PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv;
-#define glWindowPos3dv glad_glWindowPos3dv
-GLAD_API_CALL PFNGLWINDOWPOS3FPROC glad_glWindowPos3f;
-#define glWindowPos3f glad_glWindowPos3f
-GLAD_API_CALL PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv;
-#define glWindowPos3fv glad_glWindowPos3fv
-GLAD_API_CALL PFNGLWINDOWPOS3IPROC glad_glWindowPos3i;
-#define glWindowPos3i glad_glWindowPos3i
-GLAD_API_CALL PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv;
-#define glWindowPos3iv glad_glWindowPos3iv
-GLAD_API_CALL PFNGLWINDOWPOS3SPROC glad_glWindowPos3s;
-#define glWindowPos3s glad_glWindowPos3s
-GLAD_API_CALL PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv;
-#define glWindowPos3sv glad_glWindowPos3sv
-
-
-GLAD_API_CALL int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr);
-GLAD_API_CALL int gladLoadGL( GLADloadfunc load);
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/raylib_pi4_test/external/glfw/deps/glad/khrplatform.h b/raylib_pi4_test/external/glfw/deps/glad/khrplatform.h
deleted file mode 100644 (file)
index 975bbff..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-#ifndef __khrplatform_h_
-#define __khrplatform_h_
-
-/*
-** Copyright (c) 2008-2018 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
-/* Khronos platform-specific types and definitions.
- *
- * The master copy of khrplatform.h is maintained in the Khronos EGL
- * Registry repository at https://github.com/KhronosGroup/EGL-Registry
- * The last semantic modification to khrplatform.h was at commit ID:
- *      67a3e0864c2d75ea5287b9f3d2eb74a745936692
- *
- * Adopters may modify this file to suit their platform. Adopters are
- * encouraged to submit platform specific modifications to the Khronos
- * group so that they can be included in future versions of this file.
- * Please submit changes by filing pull requests or issues on
- * the EGL Registry repository linked above.
- *
- *
- * See the Implementer's Guidelines for information about where this file
- * should be located on your system and for more details of its use:
- *    http://www.khronos.org/registry/implementers_guide.pdf
- *
- * This file should be included as
- *        #include <KHR/khrplatform.h>
- * by Khronos client API header files that use its types and defines.
- *
- * The types in khrplatform.h should only be used to define API-specific types.
- *
- * Types defined in khrplatform.h:
- *    khronos_int8_t              signed   8  bit
- *    khronos_uint8_t             unsigned 8  bit
- *    khronos_int16_t             signed   16 bit
- *    khronos_uint16_t            unsigned 16 bit
- *    khronos_int32_t             signed   32 bit
- *    khronos_uint32_t            unsigned 32 bit
- *    khronos_int64_t             signed   64 bit
- *    khronos_uint64_t            unsigned 64 bit
- *    khronos_intptr_t            signed   same number of bits as a pointer
- *    khronos_uintptr_t           unsigned same number of bits as a pointer
- *    khronos_ssize_t             signed   size
- *    khronos_usize_t             unsigned size
- *    khronos_float_t             signed   32 bit floating point
- *    khronos_time_ns_t           unsigned 64 bit time in nanoseconds
- *    khronos_utime_nanoseconds_t unsigned time interval or absolute time in
- *                                         nanoseconds
- *    khronos_stime_nanoseconds_t signed time interval in nanoseconds
- *    khronos_boolean_enum_t      enumerated boolean type. This should
- *      only be used as a base type when a client API's boolean type is
- *      an enum. Client APIs which use an integer or other type for
- *      booleans cannot use this as the base type for their boolean.
- *
- * Tokens defined in khrplatform.h:
- *
- *    KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
- *
- *    KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
- *    KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
- *
- * Calling convention macros defined in this file:
- *    KHRONOS_APICALL
- *    KHRONOS_APIENTRY
- *    KHRONOS_APIATTRIBUTES
- *
- * These may be used in function prototypes as:
- *
- *      KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
- *                                  int arg1,
- *                                  int arg2) KHRONOS_APIATTRIBUTES;
- */
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APICALL
- *-------------------------------------------------------------------------
- * This precedes the return type of the function in the function prototype.
- */
-#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
-#   define KHRONOS_APICALL __declspec(dllimport)
-#elif defined (__SYMBIAN32__)
-#   define KHRONOS_APICALL IMPORT_C
-#elif defined(__ANDROID__)
-#   define KHRONOS_APICALL __attribute__((visibility("default")))
-#else
-#   define KHRONOS_APICALL
-#endif
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APIENTRY
- *-------------------------------------------------------------------------
- * This follows the return type of the function  and precedes the function
- * name in the function prototype.
- */
-#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
-    /* Win32 but not WinCE */
-#   define KHRONOS_APIENTRY __stdcall
-#else
-#   define KHRONOS_APIENTRY
-#endif
-
-/*-------------------------------------------------------------------------
- * Definition of KHRONOS_APIATTRIBUTES
- *-------------------------------------------------------------------------
- * This follows the closing parenthesis of the function prototype arguments.
- */
-#if defined (__ARMCC_2__)
-#define KHRONOS_APIATTRIBUTES __softfp
-#else
-#define KHRONOS_APIATTRIBUTES
-#endif
-
-/*-------------------------------------------------------------------------
- * basic type definitions
- *-----------------------------------------------------------------------*/
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
-
-
-/*
- * Using <stdint.h>
- */
-#include <stdint.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(__VMS ) || defined(__sgi)
-
-/*
- * Using <inttypes.h>
- */
-#include <inttypes.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
-
-/*
- * Win32
- */
-typedef __int32                 khronos_int32_t;
-typedef unsigned __int32        khronos_uint32_t;
-typedef __int64                 khronos_int64_t;
-typedef unsigned __int64        khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif defined(__sun__) || defined(__digital__)
-
-/*
- * Sun or Digital
- */
-typedef int                     khronos_int32_t;
-typedef unsigned int            khronos_uint32_t;
-#if defined(__arch64__) || defined(_LP64)
-typedef long int                khronos_int64_t;
-typedef unsigned long int       khronos_uint64_t;
-#else
-typedef long long int           khronos_int64_t;
-typedef unsigned long long int  khronos_uint64_t;
-#endif /* __arch64__ */
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#elif 0
-
-/*
- * Hypothetical platform with no float or int64 support
- */
-typedef int                     khronos_int32_t;
-typedef unsigned int            khronos_uint32_t;
-#define KHRONOS_SUPPORT_INT64   0
-#define KHRONOS_SUPPORT_FLOAT   0
-
-#else
-
-/*
- * Generic fallback
- */
-#include <stdint.h>
-typedef int32_t                 khronos_int32_t;
-typedef uint32_t                khronos_uint32_t;
-typedef int64_t                 khronos_int64_t;
-typedef uint64_t                khronos_uint64_t;
-#define KHRONOS_SUPPORT_INT64   1
-#define KHRONOS_SUPPORT_FLOAT   1
-
-#endif
-
-
-/*
- * Types that are (so far) the same on all platforms
- */
-typedef signed   char          khronos_int8_t;
-typedef unsigned char          khronos_uint8_t;
-typedef signed   short int     khronos_int16_t;
-typedef unsigned short int     khronos_uint16_t;
-
-/*
- * Types that differ between LLP64 and LP64 architectures - in LLP64,
- * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
- * to be the only LLP64 architecture in current use.
- */
-#ifdef _WIN64
-typedef signed   long long int khronos_intptr_t;
-typedef unsigned long long int khronos_uintptr_t;
-typedef signed   long long int khronos_ssize_t;
-typedef unsigned long long int khronos_usize_t;
-#else
-typedef signed   long  int     khronos_intptr_t;
-typedef unsigned long  int     khronos_uintptr_t;
-typedef signed   long  int     khronos_ssize_t;
-typedef unsigned long  int     khronos_usize_t;
-#endif
-
-#if KHRONOS_SUPPORT_FLOAT
-/*
- * Float type
- */
-typedef          float         khronos_float_t;
-#endif
-
-#if KHRONOS_SUPPORT_INT64
-/* Time types
- *
- * These types can be used to represent a time interval in nanoseconds or
- * an absolute Unadjusted System Time.  Unadjusted System Time is the number
- * of nanoseconds since some arbitrary system event (e.g. since the last
- * time the system booted).  The Unadjusted System Time is an unsigned
- * 64 bit value that wraps back to 0 every 584 years.  Time intervals
- * may be either signed or unsigned.
- */
-typedef khronos_uint64_t       khronos_utime_nanoseconds_t;
-typedef khronos_int64_t        khronos_stime_nanoseconds_t;
-#endif
-
-/*
- * Dummy value used to pad enum types to 32 bits.
- */
-#ifndef KHRONOS_MAX_ENUM
-#define KHRONOS_MAX_ENUM 0x7FFFFFFF
-#endif
-
-/*
- * Enumerated boolean type
- *
- * Values other than zero should be considered to be true.  Therefore
- * comparisons should not be made against KHRONOS_TRUE.
- */
-typedef enum {
-    KHRONOS_FALSE = 0,
-    KHRONOS_TRUE  = 1,
-    KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
-} khronos_boolean_enum_t;
-
-#endif /* __khrplatform_h_ */
diff --git a/raylib_pi4_test/external/glfw/deps/glad/vk_platform.h b/raylib_pi4_test/external/glfw/deps/glad/vk_platform.h
deleted file mode 100644 (file)
index d7d22e1..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/* */
-/* File: vk_platform.h */
-/* */
-/*
-** Copyright (c) 2014-2017 The Khronos Group Inc.
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-
-#ifndef VK_PLATFORM_H_
-#define VK_PLATFORM_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
-***************************************************************************************************
-*   Platform-specific directives and type declarations
-***************************************************************************************************
-*/
-
-/* Platform-specific calling convention macros.
- *
- * Platforms should define these so that Vulkan clients call Vulkan commands
- * with the same calling conventions that the Vulkan implementation expects.
- *
- * VKAPI_ATTR - Placed before the return type in function declarations.
- *              Useful for C++11 and GCC/Clang-style function attribute syntax.
- * VKAPI_CALL - Placed after the return type in function declarations.
- *              Useful for MSVC-style calling convention syntax.
- * VKAPI_PTR  - Placed between the '(' and '*' in function pointer types.
- *
- * Function declaration:  VKAPI_ATTR void VKAPI_CALL vkCommand(void);
- * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
- */
-#if defined(_WIN32)
-    /* On Windows, Vulkan commands use the stdcall convention */
-    #define VKAPI_ATTR
-    #define VKAPI_CALL __stdcall
-    #define VKAPI_PTR  VKAPI_CALL
-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
-    #error "Vulkan isn't supported for the 'armeabi' NDK ABI"
-#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
-    /* On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" */
-    /* calling convention, i.e. float parameters are passed in registers. This */
-    /* is true even if the rest of the application passes floats on the stack, */
-    /* as it does by default when compiling for the armeabi-v7a NDK ABI. */
-    #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
-    #define VKAPI_CALL
-    #define VKAPI_PTR  VKAPI_ATTR
-#else
-    /* On other platforms, use the default calling convention */
-    #define VKAPI_ATTR
-    #define VKAPI_CALL
-    #define VKAPI_PTR
-#endif
-
-#include <stddef.h>
-
-#if !defined(VK_NO_STDINT_H)
-    #if defined(_MSC_VER) && (_MSC_VER < 1600)
-        typedef signed   __int8  int8_t;
-        typedef unsigned __int8  uint8_t;
-        typedef signed   __int16 int16_t;
-        typedef unsigned __int16 uint16_t;
-        typedef signed   __int32 int32_t;
-        typedef unsigned __int32 uint32_t;
-        typedef signed   __int64 int64_t;
-        typedef unsigned __int64 uint64_t;
-    #else
-        #include <stdint.h>
-    #endif
-#endif /* !defined(VK_NO_STDINT_H) */
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif /* __cplusplus */
-
-#endif
diff --git a/raylib_pi4_test/external/glfw/deps/glad/vulkan.h b/raylib_pi4_test/external/glfw/deps/glad/vulkan.h
deleted file mode 100644 (file)
index 6bace71..0000000
+++ /dev/null
@@ -1,3480 +0,0 @@
-/**
- * Loader generated by glad 2.0.0-beta on Sun Apr 14 17:03:38 2019
- *
- * Generator: C/C++
- * Specification: vk
- * Extensions: 3
- *
- * APIs:
- *  - vulkan=1.1
- *
- * Options:
- *  - MX_GLOBAL = False
- *  - LOADER = False
- *  - ALIAS = False
- *  - HEADER_ONLY = False
- *  - DEBUG = False
- *  - MX = False
- *
- * Commandline:
- *    --api='vulkan=1.1' --extensions='VK_EXT_debug_report,VK_KHR_surface,VK_KHR_swapchain' c
- *
- * Online:
- *    http://glad.sh/#api=vulkan%3D1.1&extensions=VK_EXT_debug_report%2CVK_KHR_surface%2CVK_KHR_swapchain&generator=c&options=
- *
- */
-
-#ifndef GLAD_VULKAN_H_
-#define GLAD_VULKAN_H_
-
-#ifdef VULKAN_H_
-    #error  header already included (API: vulkan), remove previous include!
-#endif
-#define VULKAN_H_ 1
-
-#ifdef VULKAN_CORE_H_
-    #error  header already included (API: vulkan), remove previous include!
-#endif
-#define VULKAN_CORE_H_ 1
-
-
-#define GLAD_VULKAN
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef GLAD_PLATFORM_H_
-#define GLAD_PLATFORM_H_
-
-#ifndef GLAD_PLATFORM_WIN32
-  #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
-    #define GLAD_PLATFORM_WIN32 1
-  #else
-    #define GLAD_PLATFORM_WIN32 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_APPLE
-  #ifdef __APPLE__
-    #define GLAD_PLATFORM_APPLE 1
-  #else
-    #define GLAD_PLATFORM_APPLE 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_EMSCRIPTEN
-  #ifdef __EMSCRIPTEN__
-    #define GLAD_PLATFORM_EMSCRIPTEN 1
-  #else
-    #define GLAD_PLATFORM_EMSCRIPTEN 0
-  #endif
-#endif
-
-#ifndef GLAD_PLATFORM_UWP
-  #if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
-    #ifdef __has_include
-      #if __has_include(<winapifamily.h>)
-        #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-      #endif
-    #elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
-      #define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
-    #endif
-  #endif
-
-  #ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
-    #include <winapifamily.h>
-    #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
-      #define GLAD_PLATFORM_UWP 1
-    #endif
-  #endif
-
-  #ifndef GLAD_PLATFORM_UWP
-    #define GLAD_PLATFORM_UWP 0
-  #endif
-#endif
-
-#ifdef __GNUC__
-  #define GLAD_GNUC_EXTENSION __extension__
-#else
-  #define GLAD_GNUC_EXTENSION
-#endif
-
-#ifndef GLAD_API_CALL
-  #if defined(GLAD_API_CALL_EXPORT)
-    #if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
-      #if defined(GLAD_API_CALL_EXPORT_BUILD)
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllexport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllexport) extern
-        #endif
-      #else
-        #if defined(__GNUC__)
-          #define GLAD_API_CALL __attribute__ ((dllimport)) extern
-        #else
-          #define GLAD_API_CALL __declspec(dllimport) extern
-        #endif
-      #endif
-    #elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
-      #define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
-    #else
-      #define GLAD_API_CALL extern
-    #endif
-  #else
-    #define GLAD_API_CALL extern
-  #endif
-#endif
-
-#ifdef APIENTRY
-  #define GLAD_API_PTR APIENTRY
-#elif GLAD_PLATFORM_WIN32
-  #define GLAD_API_PTR __stdcall
-#else
-  #define GLAD_API_PTR
-#endif
-
-#ifndef GLAPI
-#define GLAPI GLAD_API_CALL
-#endif
-
-#ifndef GLAPIENTRY
-#define GLAPIENTRY GLAD_API_PTR
-#endif
-
-
-#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
-#define GLAD_VERSION_MAJOR(version) (version / 10000)
-#define GLAD_VERSION_MINOR(version) (version % 10000)
-
-typedef void (*GLADapiproc)(void);
-
-typedef GLADapiproc (*GLADloadfunc)(const char *name);
-typedef GLADapiproc (*GLADuserptrloadfunc)(const char *name, void *userptr);
-
-typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
-typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
-
-#endif /* GLAD_PLATFORM_H_ */
-
-#define VK_ATTACHMENT_UNUSED (~0U)
-#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report"
-#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 9
-#define VK_FALSE 0
-#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
-#define VK_KHR_SURFACE_SPEC_VERSION 25
-#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain"
-#define VK_KHR_SWAPCHAIN_SPEC_VERSION 70
-#define VK_LOD_CLAMP_NONE 1000.0f
-#define VK_LUID_SIZE 8
-#define VK_MAX_DESCRIPTION_SIZE 256
-#define VK_MAX_DEVICE_GROUP_SIZE 32
-#define VK_MAX_EXTENSION_NAME_SIZE 256
-#define VK_MAX_MEMORY_HEAPS 16
-#define VK_MAX_MEMORY_TYPES 32
-#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256
-#define VK_QUEUE_FAMILY_EXTERNAL (~0U-1)
-#define VK_QUEUE_FAMILY_IGNORED (~0U)
-#define VK_REMAINING_ARRAY_LAYERS (~0U)
-#define VK_REMAINING_MIP_LEVELS (~0U)
-#define VK_SUBPASS_EXTERNAL (~0U)
-#define VK_TRUE 1
-#define VK_UUID_SIZE 16
-#define VK_WHOLE_SIZE (~0ULL)
-
-
-#include <glad/vk_platform.h>
-#define VK_MAKE_VERSION(major, minor, patch) \
-    (((major) << 22) | ((minor) << 12) | (patch))
-#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
-#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
-#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
-/* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */
-/*#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 */
-/* Vulkan 1.0 version number */
-#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)/* Patch version should always be set to 0 */
-/* Vulkan 1.1 version number */
-#define VK_API_VERSION_1_1 VK_MAKE_VERSION(1, 1, 0)/* Patch version should always be set to 0 */
-/* Version of this file */
-#define VK_HEADER_VERSION 106
-#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
-#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE)
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
-#else
-        #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
-#endif
-#endif
-#define VK_NULL_HANDLE 0
-
-
-
-
-
-
-
-
-VK_DEFINE_HANDLE(VkInstance)
-VK_DEFINE_HANDLE(VkPhysicalDevice)
-VK_DEFINE_HANDLE(VkDevice)
-VK_DEFINE_HANDLE(VkQueue)
-VK_DEFINE_HANDLE(VkCommandBuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR)
-VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT)
-typedef enum VkAttachmentLoadOp {
-    VK_ATTACHMENT_LOAD_OP_LOAD = 0,
-    VK_ATTACHMENT_LOAD_OP_CLEAR = 1,
-    VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2
-} VkAttachmentLoadOp;
-typedef enum VkAttachmentStoreOp {
-    VK_ATTACHMENT_STORE_OP_STORE = 0,
-    VK_ATTACHMENT_STORE_OP_DONT_CARE = 1
-} VkAttachmentStoreOp;
-typedef enum VkBlendFactor {
-    VK_BLEND_FACTOR_ZERO = 0,
-    VK_BLEND_FACTOR_ONE = 1,
-    VK_BLEND_FACTOR_SRC_COLOR = 2,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3,
-    VK_BLEND_FACTOR_DST_COLOR = 4,
-    VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5,
-    VK_BLEND_FACTOR_SRC_ALPHA = 6,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7,
-    VK_BLEND_FACTOR_DST_ALPHA = 8,
-    VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9,
-    VK_BLEND_FACTOR_CONSTANT_COLOR = 10,
-    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
-    VK_BLEND_FACTOR_CONSTANT_ALPHA = 12,
-    VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
-    VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14,
-    VK_BLEND_FACTOR_SRC1_COLOR = 15,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16,
-    VK_BLEND_FACTOR_SRC1_ALPHA = 17,
-    VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18
-} VkBlendFactor;
-typedef enum VkBlendOp {
-    VK_BLEND_OP_ADD = 0,
-    VK_BLEND_OP_SUBTRACT = 1,
-    VK_BLEND_OP_REVERSE_SUBTRACT = 2,
-    VK_BLEND_OP_MIN = 3,
-    VK_BLEND_OP_MAX = 4
-} VkBlendOp;
-typedef enum VkBorderColor {
-    VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0,
-    VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1,
-    VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2,
-    VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3,
-    VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4,
-    VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5
-} VkBorderColor;
-
-typedef enum VkPipelineCacheHeaderVersion {
-    VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1
-} VkPipelineCacheHeaderVersion;
-
-typedef enum VkDeviceQueueCreateFlagBits {
-    VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 1
-} VkDeviceQueueCreateFlagBits;
-typedef enum VkBufferCreateFlagBits {
-    VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 1,
-    VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 2,
-    VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 4,
-    VK_BUFFER_CREATE_PROTECTED_BIT = 8
-} VkBufferCreateFlagBits;
-typedef enum VkBufferUsageFlagBits {
-    VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 1,
-    VK_BUFFER_USAGE_TRANSFER_DST_BIT = 2,
-    VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 4,
-    VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 8,
-    VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 16,
-    VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 32,
-    VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 64,
-    VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 128,
-    VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 256
-} VkBufferUsageFlagBits;
-typedef enum VkColorComponentFlagBits {
-    VK_COLOR_COMPONENT_R_BIT = 1,
-    VK_COLOR_COMPONENT_G_BIT = 2,
-    VK_COLOR_COMPONENT_B_BIT = 4,
-    VK_COLOR_COMPONENT_A_BIT = 8
-} VkColorComponentFlagBits;
-typedef enum VkComponentSwizzle {
-    VK_COMPONENT_SWIZZLE_IDENTITY = 0,
-    VK_COMPONENT_SWIZZLE_ZERO = 1,
-    VK_COMPONENT_SWIZZLE_ONE = 2,
-    VK_COMPONENT_SWIZZLE_R = 3,
-    VK_COMPONENT_SWIZZLE_G = 4,
-    VK_COMPONENT_SWIZZLE_B = 5,
-    VK_COMPONENT_SWIZZLE_A = 6
-} VkComponentSwizzle;
-typedef enum VkCommandPoolCreateFlagBits {
-    VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 1,
-    VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 2,
-    VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 4
-} VkCommandPoolCreateFlagBits;
-typedef enum VkCommandPoolResetFlagBits {
-    VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 1
-} VkCommandPoolResetFlagBits;
-typedef enum VkCommandBufferResetFlagBits {
-    VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 1
-} VkCommandBufferResetFlagBits;
-typedef enum VkCommandBufferLevel {
-    VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0,
-    VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1
-} VkCommandBufferLevel;
-typedef enum VkCommandBufferUsageFlagBits {
-    VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 1,
-    VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 2,
-    VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 4
-} VkCommandBufferUsageFlagBits;
-typedef enum VkCompareOp {
-    VK_COMPARE_OP_NEVER = 0,
-    VK_COMPARE_OP_LESS = 1,
-    VK_COMPARE_OP_EQUAL = 2,
-    VK_COMPARE_OP_LESS_OR_EQUAL = 3,
-    VK_COMPARE_OP_GREATER = 4,
-    VK_COMPARE_OP_NOT_EQUAL = 5,
-    VK_COMPARE_OP_GREATER_OR_EQUAL = 6,
-    VK_COMPARE_OP_ALWAYS = 7
-} VkCompareOp;
-typedef enum VkCullModeFlagBits {
-    VK_CULL_MODE_NONE = 0,
-    VK_CULL_MODE_FRONT_BIT = 1,
-    VK_CULL_MODE_BACK_BIT = 2,
-    VK_CULL_MODE_FRONT_AND_BACK = 0x00000003
-} VkCullModeFlagBits;
-typedef enum VkDescriptorType {
-    VK_DESCRIPTOR_TYPE_SAMPLER = 0,
-    VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
-    VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2,
-    VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3,
-    VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4,
-    VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5,
-    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6,
-    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7,
-    VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8,
-    VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9,
-    VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10
-} VkDescriptorType;
-typedef enum VkDynamicState {
-    VK_DYNAMIC_STATE_VIEWPORT = 0,
-    VK_DYNAMIC_STATE_SCISSOR = 1,
-    VK_DYNAMIC_STATE_LINE_WIDTH = 2,
-    VK_DYNAMIC_STATE_DEPTH_BIAS = 3,
-    VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
-    VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
-    VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
-    VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
-    VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
-    VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1)
-} VkDynamicState;
-typedef enum VkFenceCreateFlagBits {
-    VK_FENCE_CREATE_SIGNALED_BIT = 1
-} VkFenceCreateFlagBits;
-typedef enum VkPolygonMode {
-    VK_POLYGON_MODE_FILL = 0,
-    VK_POLYGON_MODE_LINE = 1,
-    VK_POLYGON_MODE_POINT = 2
-} VkPolygonMode;
-typedef enum VkFormat {
-    VK_FORMAT_UNDEFINED = 0,
-    VK_FORMAT_R4G4_UNORM_PACK8 = 1,
-    VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
-    VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3,
-    VK_FORMAT_R5G6B5_UNORM_PACK16 = 4,
-    VK_FORMAT_B5G6R5_UNORM_PACK16 = 5,
-    VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6,
-    VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7,
-    VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8,
-    VK_FORMAT_R8_UNORM = 9,
-    VK_FORMAT_R8_SNORM = 10,
-    VK_FORMAT_R8_USCALED = 11,
-    VK_FORMAT_R8_SSCALED = 12,
-    VK_FORMAT_R8_UINT = 13,
-    VK_FORMAT_R8_SINT = 14,
-    VK_FORMAT_R8_SRGB = 15,
-    VK_FORMAT_R8G8_UNORM = 16,
-    VK_FORMAT_R8G8_SNORM = 17,
-    VK_FORMAT_R8G8_USCALED = 18,
-    VK_FORMAT_R8G8_SSCALED = 19,
-    VK_FORMAT_R8G8_UINT = 20,
-    VK_FORMAT_R8G8_SINT = 21,
-    VK_FORMAT_R8G8_SRGB = 22,
-    VK_FORMAT_R8G8B8_UNORM = 23,
-    VK_FORMAT_R8G8B8_SNORM = 24,
-    VK_FORMAT_R8G8B8_USCALED = 25,
-    VK_FORMAT_R8G8B8_SSCALED = 26,
-    VK_FORMAT_R8G8B8_UINT = 27,
-    VK_FORMAT_R8G8B8_SINT = 28,
-    VK_FORMAT_R8G8B8_SRGB = 29,
-    VK_FORMAT_B8G8R8_UNORM = 30,
-    VK_FORMAT_B8G8R8_SNORM = 31,
-    VK_FORMAT_B8G8R8_USCALED = 32,
-    VK_FORMAT_B8G8R8_SSCALED = 33,
-    VK_FORMAT_B8G8R8_UINT = 34,
-    VK_FORMAT_B8G8R8_SINT = 35,
-    VK_FORMAT_B8G8R8_SRGB = 36,
-    VK_FORMAT_R8G8B8A8_UNORM = 37,
-    VK_FORMAT_R8G8B8A8_SNORM = 38,
-    VK_FORMAT_R8G8B8A8_USCALED = 39,
-    VK_FORMAT_R8G8B8A8_SSCALED = 40,
-    VK_FORMAT_R8G8B8A8_UINT = 41,
-    VK_FORMAT_R8G8B8A8_SINT = 42,
-    VK_FORMAT_R8G8B8A8_SRGB = 43,
-    VK_FORMAT_B8G8R8A8_UNORM = 44,
-    VK_FORMAT_B8G8R8A8_SNORM = 45,
-    VK_FORMAT_B8G8R8A8_USCALED = 46,
-    VK_FORMAT_B8G8R8A8_SSCALED = 47,
-    VK_FORMAT_B8G8R8A8_UINT = 48,
-    VK_FORMAT_B8G8R8A8_SINT = 49,
-    VK_FORMAT_B8G8R8A8_SRGB = 50,
-    VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51,
-    VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52,
-    VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53,
-    VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54,
-    VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55,
-    VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56,
-    VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57,
-    VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58,
-    VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59,
-    VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60,
-    VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61,
-    VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62,
-    VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63,
-    VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64,
-    VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65,
-    VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66,
-    VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67,
-    VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68,
-    VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69,
-    VK_FORMAT_R16_UNORM = 70,
-    VK_FORMAT_R16_SNORM = 71,
-    VK_FORMAT_R16_USCALED = 72,
-    VK_FORMAT_R16_SSCALED = 73,
-    VK_FORMAT_R16_UINT = 74,
-    VK_FORMAT_R16_SINT = 75,
-    VK_FORMAT_R16_SFLOAT = 76,
-    VK_FORMAT_R16G16_UNORM = 77,
-    VK_FORMAT_R16G16_SNORM = 78,
-    VK_FORMAT_R16G16_USCALED = 79,
-    VK_FORMAT_R16G16_SSCALED = 80,
-    VK_FORMAT_R16G16_UINT = 81,
-    VK_FORMAT_R16G16_SINT = 82,
-    VK_FORMAT_R16G16_SFLOAT = 83,
-    VK_FORMAT_R16G16B16_UNORM = 84,
-    VK_FORMAT_R16G16B16_SNORM = 85,
-    VK_FORMAT_R16G16B16_USCALED = 86,
-    VK_FORMAT_R16G16B16_SSCALED = 87,
-    VK_FORMAT_R16G16B16_UINT = 88,
-    VK_FORMAT_R16G16B16_SINT = 89,
-    VK_FORMAT_R16G16B16_SFLOAT = 90,
-    VK_FORMAT_R16G16B16A16_UNORM = 91,
-    VK_FORMAT_R16G16B16A16_SNORM = 92,
-    VK_FORMAT_R16G16B16A16_USCALED = 93,
-    VK_FORMAT_R16G16B16A16_SSCALED = 94,
-    VK_FORMAT_R16G16B16A16_UINT = 95,
-    VK_FORMAT_R16G16B16A16_SINT = 96,
-    VK_FORMAT_R16G16B16A16_SFLOAT = 97,
-    VK_FORMAT_R32_UINT = 98,
-    VK_FORMAT_R32_SINT = 99,
-    VK_FORMAT_R32_SFLOAT = 100,
-    VK_FORMAT_R32G32_UINT = 101,
-    VK_FORMAT_R32G32_SINT = 102,
-    VK_FORMAT_R32G32_SFLOAT = 103,
-    VK_FORMAT_R32G32B32_UINT = 104,
-    VK_FORMAT_R32G32B32_SINT = 105,
-    VK_FORMAT_R32G32B32_SFLOAT = 106,
-    VK_FORMAT_R32G32B32A32_UINT = 107,
-    VK_FORMAT_R32G32B32A32_SINT = 108,
-    VK_FORMAT_R32G32B32A32_SFLOAT = 109,
-    VK_FORMAT_R64_UINT = 110,
-    VK_FORMAT_R64_SINT = 111,
-    VK_FORMAT_R64_SFLOAT = 112,
-    VK_FORMAT_R64G64_UINT = 113,
-    VK_FORMAT_R64G64_SINT = 114,
-    VK_FORMAT_R64G64_SFLOAT = 115,
-    VK_FORMAT_R64G64B64_UINT = 116,
-    VK_FORMAT_R64G64B64_SINT = 117,
-    VK_FORMAT_R64G64B64_SFLOAT = 118,
-    VK_FORMAT_R64G64B64A64_UINT = 119,
-    VK_FORMAT_R64G64B64A64_SINT = 120,
-    VK_FORMAT_R64G64B64A64_SFLOAT = 121,
-    VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122,
-    VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123,
-    VK_FORMAT_D16_UNORM = 124,
-    VK_FORMAT_X8_D24_UNORM_PACK32 = 125,
-    VK_FORMAT_D32_SFLOAT = 126,
-    VK_FORMAT_S8_UINT = 127,
-    VK_FORMAT_D16_UNORM_S8_UINT = 128,
-    VK_FORMAT_D24_UNORM_S8_UINT = 129,
-    VK_FORMAT_D32_SFLOAT_S8_UINT = 130,
-    VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131,
-    VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132,
-    VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133,
-    VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134,
-    VK_FORMAT_BC2_UNORM_BLOCK = 135,
-    VK_FORMAT_BC2_SRGB_BLOCK = 136,
-    VK_FORMAT_BC3_UNORM_BLOCK = 137,
-    VK_FORMAT_BC3_SRGB_BLOCK = 138,
-    VK_FORMAT_BC4_UNORM_BLOCK = 139,
-    VK_FORMAT_BC4_SNORM_BLOCK = 140,
-    VK_FORMAT_BC5_UNORM_BLOCK = 141,
-    VK_FORMAT_BC5_SNORM_BLOCK = 142,
-    VK_FORMAT_BC6H_UFLOAT_BLOCK = 143,
-    VK_FORMAT_BC6H_SFLOAT_BLOCK = 144,
-    VK_FORMAT_BC7_UNORM_BLOCK = 145,
-    VK_FORMAT_BC7_SRGB_BLOCK = 146,
-    VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147,
-    VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148,
-    VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149,
-    VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150,
-    VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151,
-    VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152,
-    VK_FORMAT_EAC_R11_UNORM_BLOCK = 153,
-    VK_FORMAT_EAC_R11_SNORM_BLOCK = 154,
-    VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155,
-    VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156,
-    VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157,
-    VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158,
-    VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159,
-    VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160,
-    VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161,
-    VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162,
-    VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163,
-    VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164,
-    VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165,
-    VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166,
-    VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167,
-    VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168,
-    VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169,
-    VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170,
-    VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171,
-    VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172,
-    VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173,
-    VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174,
-    VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175,
-    VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176,
-    VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177,
-    VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178,
-    VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179,
-    VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180,
-    VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181,
-    VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182,
-    VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183,
-    VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184,
-    VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000,
-    VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001,
-    VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002,
-    VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003,
-    VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004,
-    VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005,
-    VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006,
-    VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007,
-    VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008,
-    VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009,
-    VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010,
-    VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012,
-    VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014,
-    VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015,
-    VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016,
-    VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017,
-    VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018,
-    VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019,
-    VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020,
-    VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022,
-    VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024,
-    VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025,
-    VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026,
-    VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027,
-    VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028,
-    VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029,
-    VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030,
-    VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031,
-    VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032,
-    VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033
-} VkFormat;
-typedef enum VkFormatFeatureFlagBits {
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 1,
-    VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 2,
-    VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 4,
-    VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 8,
-    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 16,
-    VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 32,
-    VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 64,
-    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 128,
-    VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 256,
-    VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 512,
-    VK_FORMAT_FEATURE_BLIT_SRC_BIT = 1024,
-    VK_FORMAT_FEATURE_BLIT_DST_BIT = 2048,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 4096,
-    VK_FORMAT_FEATURE_TRANSFER_SRC_BIT = 16384,
-    VK_FORMAT_FEATURE_TRANSFER_DST_BIT = 32768,
-    VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT = 131072,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 262144,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 524288,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 1048576,
-    VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 2097152,
-    VK_FORMAT_FEATURE_DISJOINT_BIT = 4194304,
-    VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 8388608
-} VkFormatFeatureFlagBits;
-typedef enum VkFrontFace {
-    VK_FRONT_FACE_COUNTER_CLOCKWISE = 0,
-    VK_FRONT_FACE_CLOCKWISE = 1
-} VkFrontFace;
-typedef enum VkImageAspectFlagBits {
-    VK_IMAGE_ASPECT_COLOR_BIT = 1,
-    VK_IMAGE_ASPECT_DEPTH_BIT = 2,
-    VK_IMAGE_ASPECT_STENCIL_BIT = 4,
-    VK_IMAGE_ASPECT_METADATA_BIT = 8,
-    VK_IMAGE_ASPECT_PLANE_0_BIT = 16,
-    VK_IMAGE_ASPECT_PLANE_1_BIT = 32,
-    VK_IMAGE_ASPECT_PLANE_2_BIT = 64
-} VkImageAspectFlagBits;
-typedef enum VkImageCreateFlagBits {
-    VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 1,
-    VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 2,
-    VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 4,
-    VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 8,
-    VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 16,
-    VK_IMAGE_CREATE_ALIAS_BIT = 1024,
-    VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 64,
-    VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT = 32,
-    VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT = 128,
-    VK_IMAGE_CREATE_EXTENDED_USAGE_BIT = 256,
-    VK_IMAGE_CREATE_PROTECTED_BIT = 2048,
-    VK_IMAGE_CREATE_DISJOINT_BIT = 512
-} VkImageCreateFlagBits;
-typedef enum VkImageLayout {
-    VK_IMAGE_LAYOUT_UNDEFINED = 0,
-    VK_IMAGE_LAYOUT_GENERAL = 1,
-    VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2,
-    VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3,
-    VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4,
-    VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5,
-    VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6,
-    VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7,
-    VK_IMAGE_LAYOUT_PREINITIALIZED = 8,
-    VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000,
-    VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001,
-    VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002
-} VkImageLayout;
-typedef enum VkImageTiling {
-    VK_IMAGE_TILING_OPTIMAL = 0,
-    VK_IMAGE_TILING_LINEAR = 1
-} VkImageTiling;
-typedef enum VkImageType {
-    VK_IMAGE_TYPE_1D = 0,
-    VK_IMAGE_TYPE_2D = 1,
-    VK_IMAGE_TYPE_3D = 2
-} VkImageType;
-typedef enum VkImageUsageFlagBits {
-    VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 1,
-    VK_IMAGE_USAGE_TRANSFER_DST_BIT = 2,
-    VK_IMAGE_USAGE_SAMPLED_BIT = 4,
-    VK_IMAGE_USAGE_STORAGE_BIT = 8,
-    VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 16,
-    VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 32,
-    VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 64,
-    VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 128
-} VkImageUsageFlagBits;
-
-typedef enum VkImageViewType {
-    VK_IMAGE_VIEW_TYPE_1D = 0,
-    VK_IMAGE_VIEW_TYPE_2D = 1,
-    VK_IMAGE_VIEW_TYPE_3D = 2,
-    VK_IMAGE_VIEW_TYPE_CUBE = 3,
-    VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4,
-    VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5,
-    VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6
-} VkImageViewType;
-typedef enum VkSharingMode {
-    VK_SHARING_MODE_EXCLUSIVE = 0,
-    VK_SHARING_MODE_CONCURRENT = 1
-} VkSharingMode;
-typedef enum VkIndexType {
-    VK_INDEX_TYPE_UINT16 = 0,
-    VK_INDEX_TYPE_UINT32 = 1
-} VkIndexType;
-typedef enum VkLogicOp {
-    VK_LOGIC_OP_CLEAR = 0,
-    VK_LOGIC_OP_AND = 1,
-    VK_LOGIC_OP_AND_REVERSE = 2,
-    VK_LOGIC_OP_COPY = 3,
-    VK_LOGIC_OP_AND_INVERTED = 4,
-    VK_LOGIC_OP_NO_OP = 5,
-    VK_LOGIC_OP_XOR = 6,
-    VK_LOGIC_OP_OR = 7,
-    VK_LOGIC_OP_NOR = 8,
-    VK_LOGIC_OP_EQUIVALENT = 9,
-    VK_LOGIC_OP_INVERT = 10,
-    VK_LOGIC_OP_OR_REVERSE = 11,
-    VK_LOGIC_OP_COPY_INVERTED = 12,
-    VK_LOGIC_OP_OR_INVERTED = 13,
-    VK_LOGIC_OP_NAND = 14,
-    VK_LOGIC_OP_SET = 15
-} VkLogicOp;
-typedef enum VkMemoryHeapFlagBits {
-    VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 1,
-    VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 2
-} VkMemoryHeapFlagBits;
-typedef enum VkAccessFlagBits {
-    VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 1,
-    VK_ACCESS_INDEX_READ_BIT = 2,
-    VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 4,
-    VK_ACCESS_UNIFORM_READ_BIT = 8,
-    VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 16,
-    VK_ACCESS_SHADER_READ_BIT = 32,
-    VK_ACCESS_SHADER_WRITE_BIT = 64,
-    VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 128,
-    VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 256,
-    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 512,
-    VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 1024,
-    VK_ACCESS_TRANSFER_READ_BIT = 2048,
-    VK_ACCESS_TRANSFER_WRITE_BIT = 4096,
-    VK_ACCESS_HOST_READ_BIT = 8192,
-    VK_ACCESS_HOST_WRITE_BIT = 16384,
-    VK_ACCESS_MEMORY_READ_BIT = 32768,
-    VK_ACCESS_MEMORY_WRITE_BIT = 65536
-} VkAccessFlagBits;
-typedef enum VkMemoryPropertyFlagBits {
-    VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 1,
-    VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 2,
-    VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 4,
-    VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 8,
-    VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 16,
-    VK_MEMORY_PROPERTY_PROTECTED_BIT = 32
-} VkMemoryPropertyFlagBits;
-typedef enum VkPhysicalDeviceType {
-    VK_PHYSICAL_DEVICE_TYPE_OTHER = 0,
-    VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
-    VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2,
-    VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3,
-    VK_PHYSICAL_DEVICE_TYPE_CPU = 4
-} VkPhysicalDeviceType;
-typedef enum VkPipelineBindPoint {
-    VK_PIPELINE_BIND_POINT_GRAPHICS = 0,
-    VK_PIPELINE_BIND_POINT_COMPUTE = 1
-} VkPipelineBindPoint;
-typedef enum VkPipelineCreateFlagBits {
-    VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 1,
-    VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 2,
-    VK_PIPELINE_CREATE_DERIVATIVE_BIT = 4,
-    VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 8,
-    VK_PIPELINE_CREATE_DISPATCH_BASE = 16
-} VkPipelineCreateFlagBits;
-typedef enum VkPrimitiveTopology {
-    VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
-    VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
-    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5,
-    VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6,
-    VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8,
-    VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9,
-    VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10
-} VkPrimitiveTopology;
-typedef enum VkQueryControlFlagBits {
-    VK_QUERY_CONTROL_PRECISE_BIT = 1
-} VkQueryControlFlagBits;
-typedef enum VkQueryPipelineStatisticFlagBits {
-    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 1,
-    VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 2,
-    VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 4,
-    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 8,
-    VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 16,
-    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 32,
-    VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 64,
-    VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 128,
-    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 256,
-    VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 512,
-    VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 1024
-} VkQueryPipelineStatisticFlagBits;
-typedef enum VkQueryResultFlagBits {
-    VK_QUERY_RESULT_64_BIT = 1,
-    VK_QUERY_RESULT_WAIT_BIT = 2,
-    VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 4,
-    VK_QUERY_RESULT_PARTIAL_BIT = 8
-} VkQueryResultFlagBits;
-typedef enum VkQueryType {
-    VK_QUERY_TYPE_OCCLUSION = 0,
-    VK_QUERY_TYPE_PIPELINE_STATISTICS = 1,
-    VK_QUERY_TYPE_TIMESTAMP = 2
-} VkQueryType;
-typedef enum VkQueueFlagBits {
-    VK_QUEUE_GRAPHICS_BIT = 1,
-    VK_QUEUE_COMPUTE_BIT = 2,
-    VK_QUEUE_TRANSFER_BIT = 4,
-    VK_QUEUE_SPARSE_BINDING_BIT = 8,
-    VK_QUEUE_PROTECTED_BIT = 16
-} VkQueueFlagBits;
-typedef enum VkSubpassContents {
-    VK_SUBPASS_CONTENTS_INLINE = 0,
-    VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1
-} VkSubpassContents;
-typedef enum VkResult {
-    VK_SUCCESS = 0,
-    VK_NOT_READY = 1,
-    VK_TIMEOUT = 2,
-    VK_EVENT_SET = 3,
-    VK_EVENT_RESET = 4,
-    VK_INCOMPLETE = 5,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
-    VK_ERROR_INITIALIZATION_FAILED = -3,
-    VK_ERROR_DEVICE_LOST = -4,
-    VK_ERROR_MEMORY_MAP_FAILED = -5,
-    VK_ERROR_LAYER_NOT_PRESENT = -6,
-    VK_ERROR_EXTENSION_NOT_PRESENT = -7,
-    VK_ERROR_FEATURE_NOT_PRESENT = -8,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -9,
-    VK_ERROR_TOO_MANY_OBJECTS = -10,
-    VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
-    VK_ERROR_FRAGMENTED_POOL = -12,
-    VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000,
-    VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003,
-    VK_ERROR_SURFACE_LOST_KHR = -1000000000,
-    VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
-    VK_SUBOPTIMAL_KHR = 1000001003,
-    VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
-    VK_ERROR_VALIDATION_FAILED_EXT = -1000011001
-} VkResult;
-typedef enum VkShaderStageFlagBits {
-    VK_SHADER_STAGE_VERTEX_BIT = 1,
-    VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 2,
-    VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 4,
-    VK_SHADER_STAGE_GEOMETRY_BIT = 8,
-    VK_SHADER_STAGE_FRAGMENT_BIT = 16,
-    VK_SHADER_STAGE_COMPUTE_BIT = 32,
-    VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
-    VK_SHADER_STAGE_ALL = 0x7FFFFFFF
-} VkShaderStageFlagBits;
-typedef enum VkSparseMemoryBindFlagBits {
-    VK_SPARSE_MEMORY_BIND_METADATA_BIT = 1
-} VkSparseMemoryBindFlagBits;
-typedef enum VkStencilFaceFlagBits {
-    VK_STENCIL_FACE_FRONT_BIT = 1,
-    VK_STENCIL_FACE_BACK_BIT = 2,
-    VK_STENCIL_FRONT_AND_BACK = 0x00000003
-} VkStencilFaceFlagBits;
-typedef enum VkStencilOp {
-    VK_STENCIL_OP_KEEP = 0,
-    VK_STENCIL_OP_ZERO = 1,
-    VK_STENCIL_OP_REPLACE = 2,
-    VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3,
-    VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4,
-    VK_STENCIL_OP_INVERT = 5,
-    VK_STENCIL_OP_INCREMENT_AND_WRAP = 6,
-    VK_STENCIL_OP_DECREMENT_AND_WRAP = 7
-} VkStencilOp;
-typedef enum VkStructureType {
-    VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
-    VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
-    VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2,
-    VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3,
-    VK_STRUCTURE_TYPE_SUBMIT_INFO = 4,
-    VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5,
-    VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6,
-    VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7,
-    VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8,
-    VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9,
-    VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10,
-    VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11,
-    VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12,
-    VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13,
-    VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14,
-    VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15,
-    VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16,
-    VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17,
-    VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18,
-    VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19,
-    VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
-    VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21,
-    VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22,
-    VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23,
-    VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24,
-    VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25,
-    VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26,
-    VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27,
-    VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28,
-    VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29,
-    VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30,
-    VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34,
-    VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35,
-    VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36,
-    VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37,
-    VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38,
-    VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41,
-    VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42,
-    VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43,
-    VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44,
-    VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45,
-    VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46,
-    VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47,
-    VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000,
-    VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO = 1000157001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000,
-    VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS = 1000127000,
-    VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001,
-    VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO = 1000060000,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO = 1000060005,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006,
-    VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001,
-    VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000,
-    VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001,
-    VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002,
-    VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 = 1000146003,
-    VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 = 1000059000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001,
-    VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 = 1000059002,
-    VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 = 1000059003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004,
-    VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2 = 1000059005,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006,
-    VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000,
-    VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001,
-    VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002,
-    VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003,
-    VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES,
-    VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO = 1000145000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002,
-    VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2 = 1000145003,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO = 1000156001,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002,
-    VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004,
-    VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000,
-    VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002,
-    VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES = 1000071003,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004,
-    VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000,
-    VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001,
-    VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO = 1000072002,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000,
-    VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES = 1000112001,
-    VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO = 1000113000,
-    VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO = 1000077000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000,
-    VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000,
-    VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000,
-    VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES,
-    VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000,
-    VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007,
-    VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008,
-    VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009,
-    VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011,
-    VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012,
-    VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
-    VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
-} VkStructureType;
-typedef enum VkSystemAllocationScope {
-    VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
-    VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
-    VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
-    VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
-    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4
-} VkSystemAllocationScope;
-typedef enum VkInternalAllocationType {
-    VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0
-} VkInternalAllocationType;
-typedef enum VkSamplerAddressMode {
-    VK_SAMPLER_ADDRESS_MODE_REPEAT = 0,
-    VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1,
-    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2,
-    VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3
-} VkSamplerAddressMode;
-typedef enum VkFilter {
-    VK_FILTER_NEAREST = 0,
-    VK_FILTER_LINEAR = 1
-} VkFilter;
-typedef enum VkSamplerMipmapMode {
-    VK_SAMPLER_MIPMAP_MODE_NEAREST = 0,
-    VK_SAMPLER_MIPMAP_MODE_LINEAR = 1
-} VkSamplerMipmapMode;
-typedef enum VkVertexInputRate {
-    VK_VERTEX_INPUT_RATE_VERTEX = 0,
-    VK_VERTEX_INPUT_RATE_INSTANCE = 1
-} VkVertexInputRate;
-typedef enum VkPipelineStageFlagBits {
-    VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 1,
-    VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 2,
-    VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 4,
-    VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 8,
-    VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 16,
-    VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 32,
-    VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 64,
-    VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 128,
-    VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 256,
-    VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 512,
-    VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 1024,
-    VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 2048,
-    VK_PIPELINE_STAGE_TRANSFER_BIT = 4096,
-    VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 8192,
-    VK_PIPELINE_STAGE_HOST_BIT = 16384,
-    VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 32768,
-    VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 65536
-} VkPipelineStageFlagBits;
-typedef enum VkSparseImageFormatFlagBits {
-    VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 1,
-    VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 2,
-    VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 4
-} VkSparseImageFormatFlagBits;
-typedef enum VkSampleCountFlagBits {
-    VK_SAMPLE_COUNT_1_BIT = 1,
-    VK_SAMPLE_COUNT_2_BIT = 2,
-    VK_SAMPLE_COUNT_4_BIT = 4,
-    VK_SAMPLE_COUNT_8_BIT = 8,
-    VK_SAMPLE_COUNT_16_BIT = 16,
-    VK_SAMPLE_COUNT_32_BIT = 32,
-    VK_SAMPLE_COUNT_64_BIT = 64
-} VkSampleCountFlagBits;
-typedef enum VkAttachmentDescriptionFlagBits {
-    VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 1
-} VkAttachmentDescriptionFlagBits;
-typedef enum VkDescriptorPoolCreateFlagBits {
-    VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 1
-} VkDescriptorPoolCreateFlagBits;
-typedef enum VkDependencyFlagBits {
-    VK_DEPENDENCY_BY_REGION_BIT = 1,
-    VK_DEPENDENCY_DEVICE_GROUP_BIT = 4,
-    VK_DEPENDENCY_VIEW_LOCAL_BIT = 2
-} VkDependencyFlagBits;
-typedef enum VkObjectType {
-    VK_OBJECT_TYPE_UNKNOWN = 0,
-    VK_OBJECT_TYPE_INSTANCE = 1,
-    VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2,
-    VK_OBJECT_TYPE_DEVICE = 3,
-    VK_OBJECT_TYPE_QUEUE = 4,
-    VK_OBJECT_TYPE_SEMAPHORE = 5,
-    VK_OBJECT_TYPE_COMMAND_BUFFER = 6,
-    VK_OBJECT_TYPE_FENCE = 7,
-    VK_OBJECT_TYPE_DEVICE_MEMORY = 8,
-    VK_OBJECT_TYPE_BUFFER = 9,
-    VK_OBJECT_TYPE_IMAGE = 10,
-    VK_OBJECT_TYPE_EVENT = 11,
-    VK_OBJECT_TYPE_QUERY_POOL = 12,
-    VK_OBJECT_TYPE_BUFFER_VIEW = 13,
-    VK_OBJECT_TYPE_IMAGE_VIEW = 14,
-    VK_OBJECT_TYPE_SHADER_MODULE = 15,
-    VK_OBJECT_TYPE_PIPELINE_CACHE = 16,
-    VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17,
-    VK_OBJECT_TYPE_RENDER_PASS = 18,
-    VK_OBJECT_TYPE_PIPELINE = 19,
-    VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20,
-    VK_OBJECT_TYPE_SAMPLER = 21,
-    VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22,
-    VK_OBJECT_TYPE_DESCRIPTOR_SET = 23,
-    VK_OBJECT_TYPE_FRAMEBUFFER = 24,
-    VK_OBJECT_TYPE_COMMAND_POOL = 25,
-    VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION = 1000156000,
-    VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE = 1000085000,
-    VK_OBJECT_TYPE_SURFACE_KHR = 1000000000,
-    VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000,
-    VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000
-} VkObjectType;
-typedef enum VkDescriptorUpdateTemplateType {
-    VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0
-} VkDescriptorUpdateTemplateType;
-
-typedef enum VkPointClippingBehavior {
-    VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0,
-    VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1
-} VkPointClippingBehavior;
-typedef enum VkColorSpaceKHR {
-    VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
-    VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
-} VkColorSpaceKHR;
-typedef enum VkCompositeAlphaFlagBitsKHR {
-    VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 1,
-    VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 2,
-    VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 4,
-    VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 8
-} VkCompositeAlphaFlagBitsKHR;
-typedef enum VkPresentModeKHR {
-    VK_PRESENT_MODE_IMMEDIATE_KHR = 0,
-    VK_PRESENT_MODE_MAILBOX_KHR = 1,
-    VK_PRESENT_MODE_FIFO_KHR = 2,
-    VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3
-} VkPresentModeKHR;
-typedef enum VkSurfaceTransformFlagBitsKHR {
-    VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 1,
-    VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 2,
-    VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 4,
-    VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 8,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 16,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 32,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 64,
-    VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 128,
-    VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 256
-} VkSurfaceTransformFlagBitsKHR;
-typedef enum VkDebugReportFlagBitsEXT {
-    VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 1,
-    VK_DEBUG_REPORT_WARNING_BIT_EXT = 2,
-    VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 4,
-    VK_DEBUG_REPORT_ERROR_BIT_EXT = 8,
-    VK_DEBUG_REPORT_DEBUG_BIT_EXT = 16
-} VkDebugReportFlagBitsEXT;
-typedef enum VkDebugReportObjectTypeEXT {
-    VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0,
-    VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3,
-    VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5,
-    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6,
-    VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8,
-    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9,
-    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10,
-    VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11,
-    VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12,
-    VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13,
-    VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17,
-    VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18,
-    VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23,
-    VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24,
-    VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30,
-    VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31,
-    VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32,
-    VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33,
-    VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT,
-    VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000,
-    VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000
-} VkDebugReportObjectTypeEXT;
-typedef enum VkExternalMemoryHandleTypeFlagBits {
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT = 8,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT = 16,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 32,
-    VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 64
-} VkExternalMemoryHandleTypeFlagBits;
-typedef enum VkExternalMemoryFeatureFlagBits {
-    VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 1,
-    VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 2,
-    VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 4
-} VkExternalMemoryFeatureFlagBits;
-typedef enum VkExternalSemaphoreHandleTypeFlagBits {
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 8,
-    VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 16
-} VkExternalSemaphoreHandleTypeFlagBits;
-typedef enum VkExternalSemaphoreFeatureFlagBits {
-    VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 1,
-    VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 2
-} VkExternalSemaphoreFeatureFlagBits;
-typedef enum VkSemaphoreImportFlagBits {
-    VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 1
-} VkSemaphoreImportFlagBits;
-typedef enum VkExternalFenceHandleTypeFlagBits {
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 1,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 2,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 4,
-    VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 8
-} VkExternalFenceHandleTypeFlagBits;
-typedef enum VkExternalFenceFeatureFlagBits {
-    VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 1,
-    VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 2
-} VkExternalFenceFeatureFlagBits;
-typedef enum VkFenceImportFlagBits {
-    VK_FENCE_IMPORT_TEMPORARY_BIT = 1
-} VkFenceImportFlagBits;
-typedef enum VkPeerMemoryFeatureFlagBits {
-    VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 1,
-    VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 2,
-    VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 4,
-    VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 8
-} VkPeerMemoryFeatureFlagBits;
-typedef enum VkMemoryAllocateFlagBits {
-    VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 1
-} VkMemoryAllocateFlagBits;
-typedef enum VkDeviceGroupPresentModeFlagBitsKHR {
-    VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 1,
-    VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 2,
-    VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 4,
-    VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 8
-} VkDeviceGroupPresentModeFlagBitsKHR;
-typedef enum VkSwapchainCreateFlagBitsKHR {
-    VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 1,
-    VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 2
-} VkSwapchainCreateFlagBitsKHR;
-typedef enum VkSubgroupFeatureFlagBits {
-    VK_SUBGROUP_FEATURE_BASIC_BIT = 1,
-    VK_SUBGROUP_FEATURE_VOTE_BIT = 2,
-    VK_SUBGROUP_FEATURE_ARITHMETIC_BIT = 4,
-    VK_SUBGROUP_FEATURE_BALLOT_BIT = 8,
-    VK_SUBGROUP_FEATURE_SHUFFLE_BIT = 16,
-    VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 32,
-    VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 64,
-    VK_SUBGROUP_FEATURE_QUAD_BIT = 128
-} VkSubgroupFeatureFlagBits;
-typedef enum VkTessellationDomainOrigin {
-    VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0,
-    VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1
-} VkTessellationDomainOrigin;
-typedef enum VkSamplerYcbcrModelConversion {
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 = 2,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3,
-    VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4
-} VkSamplerYcbcrModelConversion;
-typedef enum VkSamplerYcbcrRange {
-    VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0,
-    VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1
-} VkSamplerYcbcrRange;
-typedef enum VkChromaLocation {
-    VK_CHROMA_LOCATION_COSITED_EVEN = 0,
-    VK_CHROMA_LOCATION_MIDPOINT = 1
-} VkChromaLocation;
-typedef enum VkVendorId {
-    VK_VENDOR_ID_VIV = 0x10001,
-    VK_VENDOR_ID_VSI = 0x10002,
-    VK_VENDOR_ID_KAZAN = 0x10003
-} VkVendorId;
-typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)(
-    void*                                       pUserData,
-    size_t                                      size,
-    VkInternalAllocationType                    allocationType,
-    VkSystemAllocationScope                     allocationScope);
-typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)(
-    void*                                       pUserData,
-    size_t                                      size,
-    VkInternalAllocationType                    allocationType,
-    VkSystemAllocationScope                     allocationScope);
-typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
-    void*                                       pUserData,
-    void*                                       pOriginal,
-    size_t                                      size,
-    size_t                                      alignment,
-    VkSystemAllocationScope                     allocationScope);
-typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
-    void*                                       pUserData,
-    size_t                                      size,
-    size_t                                      alignment,
-    VkSystemAllocationScope                     allocationScope);
-typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
-    void*                                       pUserData,
-    void*                                       pMemory);
-typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);
-typedef struct VkBaseOutStructure {
-    VkStructureType   sType;
-    struct  VkBaseOutStructure *  pNext;
-} VkBaseOutStructure;
-typedef struct VkBaseInStructure {
-    VkStructureType   sType;
-    const struct  VkBaseInStructure *  pNext;
-} VkBaseInStructure;
-typedef struct VkOffset2D {
-    int32_t          x;
-    int32_t          y;
-} VkOffset2D;
-typedef struct VkOffset3D {
-    int32_t          x;
-    int32_t          y;
-    int32_t          z;
-} VkOffset3D;
-typedef struct VkExtent2D {
-    uint32_t          width;
-    uint32_t          height;
-} VkExtent2D;
-typedef struct VkExtent3D {
-    uint32_t          width;
-    uint32_t          height;
-    uint32_t          depth;
-} VkExtent3D;
-typedef struct VkViewport {
-    float   x;
-    float   y;
-    float   width;
-    float   height;
-    float                         minDepth;
-    float                         maxDepth;
-} VkViewport;
-typedef struct VkRect2D {
-    VkOffset2D       offset;
-    VkExtent2D       extent;
-} VkRect2D;
-typedef struct VkClearRect {
-    VkRect2D         rect;
-    uint32_t         baseArrayLayer;
-    uint32_t         layerCount;
-} VkClearRect;
-typedef struct VkComponentMapping {
-    VkComponentSwizzle   r;
-    VkComponentSwizzle   g;
-    VkComponentSwizzle   b;
-    VkComponentSwizzle   a;
-} VkComponentMapping;
-typedef struct VkExtensionProperties {
-    char              extensionName [ VK_MAX_EXTENSION_NAME_SIZE ];
-    uint32_t          specVersion;
-} VkExtensionProperties;
-typedef struct VkLayerProperties {
-    char              layerName [ VK_MAX_EXTENSION_NAME_SIZE ];
-    uint32_t          specVersion;
-    uint32_t          implementationVersion;
-    char              description [ VK_MAX_DESCRIPTION_SIZE ];
-} VkLayerProperties;
-typedef struct VkApplicationInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    const  char *      pApplicationName;
-    uint32_t          applicationVersion;
-    const  char *      pEngineName;
-    uint32_t          engineVersion;
-    uint32_t          apiVersion;
-} VkApplicationInfo;
-typedef struct VkAllocationCallbacks {
-    void *            pUserData;
-    PFN_vkAllocationFunction     pfnAllocation;
-    PFN_vkReallocationFunction   pfnReallocation;
-    PFN_vkFreeFunction      pfnFree;
-    PFN_vkInternalAllocationNotification   pfnInternalAllocation;
-    PFN_vkInternalFreeNotification   pfnInternalFree;
-} VkAllocationCallbacks;
-typedef struct VkDescriptorImageInfo {
-    VkSampler         sampler;
-    VkImageView       imageView;
-    VkImageLayout     imageLayout;
-} VkDescriptorImageInfo;
-typedef struct VkCopyDescriptorSet {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSet          srcSet;
-    uint32_t                 srcBinding;
-    uint32_t                 srcArrayElement;
-    VkDescriptorSet          dstSet;
-    uint32_t                 dstBinding;
-    uint32_t                 dstArrayElement;
-    uint32_t                 descriptorCount;
-} VkCopyDescriptorSet;
-typedef struct VkDescriptorPoolSize {
-    VkDescriptorType         type;
-    uint32_t                 descriptorCount;
-} VkDescriptorPoolSize;
-typedef struct VkDescriptorSetAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorPool         descriptorPool;
-    uint32_t                 descriptorSetCount;
-    const  VkDescriptorSetLayout *  pSetLayouts;
-} VkDescriptorSetAllocateInfo;
-typedef struct VkSpecializationMapEntry {
-    uint32_t                       constantID;
-    uint32_t                       offset;
-    size_t   size;
-} VkSpecializationMapEntry;
-typedef struct VkSpecializationInfo {
-    uint32_t                 mapEntryCount;
-    const  VkSpecializationMapEntry *  pMapEntries;
-    size_t                   dataSize;
-    const  void *             pData;
-} VkSpecializationInfo;
-typedef struct VkVertexInputBindingDescription {
-    uint32_t                 binding;
-    uint32_t                 stride;
-    VkVertexInputRate        inputRate;
-} VkVertexInputBindingDescription;
-typedef struct VkVertexInputAttributeDescription {
-    uint32_t                 location;
-    uint32_t                 binding;
-    VkFormat                 format;
-    uint32_t                 offset;
-} VkVertexInputAttributeDescription;
-typedef struct VkStencilOpState {
-    VkStencilOp              failOp;
-    VkStencilOp              passOp;
-    VkStencilOp              depthFailOp;
-    VkCompareOp              compareOp;
-    uint32_t                 compareMask;
-    uint32_t                 writeMask;
-    uint32_t                 reference;
-} VkStencilOpState;
-typedef struct VkCommandBufferAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandPool            commandPool;
-    VkCommandBufferLevel     level;
-    uint32_t                 commandBufferCount;
-} VkCommandBufferAllocateInfo;
-typedef union VkClearColorValue {
-    float                    float32 [4];
-    int32_t                  int32 [4];
-    uint32_t                 uint32 [4];
-} VkClearColorValue;
-typedef struct VkClearDepthStencilValue {
-    float                    depth;
-    uint32_t                 stencil;
-} VkClearDepthStencilValue;
-typedef union VkClearValue {
-    VkClearColorValue        color;
-    VkClearDepthStencilValue   depthStencil;
-} VkClearValue;
-typedef struct VkAttachmentReference {
-    uint32_t                 attachment;
-    VkImageLayout            layout;
-} VkAttachmentReference;
-typedef struct VkDrawIndirectCommand {
-    uint32_t                         vertexCount;
-    uint32_t                         instanceCount;
-    uint32_t                         firstVertex;
-    uint32_t   firstInstance;
-} VkDrawIndirectCommand;
-typedef struct VkDrawIndexedIndirectCommand {
-    uint32_t                         indexCount;
-    uint32_t                         instanceCount;
-    uint32_t                         firstIndex;
-    int32_t                          vertexOffset;
-    uint32_t   firstInstance;
-} VkDrawIndexedIndirectCommand;
-typedef struct VkDispatchIndirectCommand {
-    uint32_t   x;
-    uint32_t   y;
-    uint32_t   z;
-} VkDispatchIndirectCommand;
-typedef struct VkSurfaceFormatKHR {
-    VkFormat                           format;
-    VkColorSpaceKHR                    colorSpace;
-} VkSurfaceFormatKHR;
-typedef struct VkPresentInfoKHR {
-    VkStructureType   sType;
-    const  void *   pNext;
-    uint32_t           waitSemaphoreCount;
-    const  VkSemaphore *  pWaitSemaphores;
-    uint32_t                           swapchainCount;
-    const  VkSwapchainKHR *  pSwapchains;
-    const  uint32_t *  pImageIndices;
-    VkResult *  pResults;
-} VkPresentInfoKHR;
-typedef struct VkPhysicalDeviceExternalImageFormatInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalImageFormatInfo;
-typedef struct VkPhysicalDeviceExternalSemaphoreInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalSemaphoreHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalSemaphoreInfo;
-typedef struct VkPhysicalDeviceExternalFenceInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalFenceHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalFenceInfo;
-typedef struct VkPhysicalDeviceMultiviewProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           maxMultiviewViewCount;
-    uint32_t                           maxMultiviewInstanceIndex;
-} VkPhysicalDeviceMultiviewProperties;
-typedef struct VkRenderPassMultiviewCreateInfo {
-    VkStructureType          sType;
-    const  void *             pNext;
-    uint32_t                 subpassCount;
-    const  uint32_t *      pViewMasks;
-    uint32_t                 dependencyCount;
-    const  int32_t *    pViewOffsets;
-    uint32_t                 correlationMaskCount;
-    const  uint32_t *  pCorrelationMasks;
-} VkRenderPassMultiviewCreateInfo;
-typedef struct VkBindBufferMemoryDeviceGroupInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           deviceIndexCount;
-    const  uint32_t *   pDeviceIndices;
-} VkBindBufferMemoryDeviceGroupInfo;
-typedef struct VkBindImageMemoryDeviceGroupInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           deviceIndexCount;
-    const  uint32_t *   pDeviceIndices;
-    uint32_t           splitInstanceBindRegionCount;
-    const  VkRect2D *   pSplitInstanceBindRegions;
-} VkBindImageMemoryDeviceGroupInfo;
-typedef struct VkDeviceGroupRenderPassBeginInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           deviceMask;
-    uint32_t           deviceRenderAreaCount;
-    const  VkRect2D *   pDeviceRenderAreas;
-} VkDeviceGroupRenderPassBeginInfo;
-typedef struct VkDeviceGroupCommandBufferBeginInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           deviceMask;
-} VkDeviceGroupCommandBufferBeginInfo;
-typedef struct VkDeviceGroupSubmitInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           waitSemaphoreCount;
-    const  uint32_t *     pWaitSemaphoreDeviceIndices;
-    uint32_t           commandBufferCount;
-    const  uint32_t *     pCommandBufferDeviceMasks;
-    uint32_t           signalSemaphoreCount;
-    const  uint32_t *   pSignalSemaphoreDeviceIndices;
-} VkDeviceGroupSubmitInfo;
-typedef struct VkDeviceGroupBindSparseInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           resourceDeviceIndex;
-    uint32_t                           memoryDeviceIndex;
-} VkDeviceGroupBindSparseInfo;
-typedef struct VkImageSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR     swapchain;
-} VkImageSwapchainCreateInfoKHR;
-typedef struct VkBindImageMemorySwapchainInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR   swapchain;
-    uint32_t                           imageIndex;
-} VkBindImageMemorySwapchainInfoKHR;
-typedef struct VkAcquireNextImageInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainKHR   swapchain;
-    uint64_t                           timeout;
-    VkSemaphore   semaphore;
-    VkFence   fence;
-    uint32_t                           deviceMask;
-} VkAcquireNextImageInfoKHR;
-typedef struct VkDeviceGroupPresentInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t           swapchainCount;
-    const  uint32_t *  pDeviceMasks;
-    VkDeviceGroupPresentModeFlagBitsKHR   mode;
-} VkDeviceGroupPresentInfoKHR;
-typedef struct VkDeviceGroupDeviceCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           physicalDeviceCount;
-    const  VkPhysicalDevice *   pPhysicalDevices;
-} VkDeviceGroupDeviceCreateInfo;
-typedef struct VkDescriptorUpdateTemplateEntry {
-    uint32_t                           dstBinding;
-    uint32_t                           dstArrayElement;
-    uint32_t                           descriptorCount;
-    VkDescriptorType                   descriptorType;
-    size_t                             offset;
-    size_t                             stride;
-} VkDescriptorUpdateTemplateEntry;
-typedef struct VkBufferMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkBuffer                                                               buffer;
-} VkBufferMemoryRequirementsInfo2;
-typedef struct VkImageMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkImage                                                                image;
-} VkImageMemoryRequirementsInfo2;
-typedef struct VkImageSparseMemoryRequirementsInfo2 {
-    VkStructureType   sType;
-    const  void *                                                           pNext;
-    VkImage                                                                image;
-} VkImageSparseMemoryRequirementsInfo2;
-typedef struct VkPhysicalDevicePointClippingProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPointClippingBehavior        pointClippingBehavior;
-} VkPhysicalDevicePointClippingProperties;
-typedef struct VkMemoryDedicatedAllocateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImage            image;
-    VkBuffer           buffer;
-} VkMemoryDedicatedAllocateInfo;
-typedef struct VkPipelineTessellationDomainOriginStateCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkTessellationDomainOrigin      domainOrigin;
-} VkPipelineTessellationDomainOriginStateCreateInfo;
-typedef struct VkSamplerYcbcrConversionInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSamplerYcbcrConversion        conversion;
-} VkSamplerYcbcrConversionInfo;
-typedef struct VkBindImagePlaneMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImageAspectFlagBits              planeAspect;
-} VkBindImagePlaneMemoryInfo;
-typedef struct VkImagePlaneMemoryRequirementsInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImageAspectFlagBits              planeAspect;
-} VkImagePlaneMemoryRequirementsInfo;
-typedef struct VkSamplerYcbcrConversionImageFormatProperties {
-    VkStructureType   sType;
-    void *       pNext;
-    uint32_t                           combinedImageSamplerDescriptorCount;
-} VkSamplerYcbcrConversionImageFormatProperties;
-typedef uint32_t VkSampleMask;
-typedef uint32_t VkBool32;
-typedef uint32_t VkFlags;
-typedef uint64_t VkDeviceSize;
-typedef VkFlags VkFramebufferCreateFlags;
-typedef VkFlags VkQueryPoolCreateFlags;
-typedef VkFlags VkRenderPassCreateFlags;
-typedef VkFlags VkSamplerCreateFlags;
-typedef VkFlags VkPipelineLayoutCreateFlags;
-typedef VkFlags VkPipelineCacheCreateFlags;
-typedef VkFlags VkPipelineDepthStencilStateCreateFlags;
-typedef VkFlags VkPipelineDynamicStateCreateFlags;
-typedef VkFlags VkPipelineColorBlendStateCreateFlags;
-typedef VkFlags VkPipelineMultisampleStateCreateFlags;
-typedef VkFlags VkPipelineRasterizationStateCreateFlags;
-typedef VkFlags VkPipelineViewportStateCreateFlags;
-typedef VkFlags VkPipelineTessellationStateCreateFlags;
-typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;
-typedef VkFlags VkPipelineVertexInputStateCreateFlags;
-typedef VkFlags VkPipelineShaderStageCreateFlags;
-typedef VkFlags VkDescriptorSetLayoutCreateFlags;
-typedef VkFlags VkBufferViewCreateFlags;
-typedef VkFlags VkInstanceCreateFlags;
-typedef VkFlags VkDeviceCreateFlags;
-typedef VkFlags VkDeviceQueueCreateFlags;
-typedef VkFlags VkQueueFlags;
-typedef VkFlags VkMemoryPropertyFlags;
-typedef VkFlags VkMemoryHeapFlags;
-typedef VkFlags VkAccessFlags;
-typedef VkFlags VkBufferUsageFlags;
-typedef VkFlags VkBufferCreateFlags;
-typedef VkFlags VkShaderStageFlags;
-typedef VkFlags VkImageUsageFlags;
-typedef VkFlags VkImageCreateFlags;
-typedef VkFlags VkImageViewCreateFlags;
-typedef VkFlags VkPipelineCreateFlags;
-typedef VkFlags VkColorComponentFlags;
-typedef VkFlags VkFenceCreateFlags;
-typedef VkFlags VkSemaphoreCreateFlags;
-typedef VkFlags VkFormatFeatureFlags;
-typedef VkFlags VkQueryControlFlags;
-typedef VkFlags VkQueryResultFlags;
-typedef VkFlags VkShaderModuleCreateFlags;
-typedef VkFlags VkEventCreateFlags;
-typedef VkFlags VkCommandPoolCreateFlags;
-typedef VkFlags VkCommandPoolResetFlags;
-typedef VkFlags VkCommandBufferResetFlags;
-typedef VkFlags VkCommandBufferUsageFlags;
-typedef VkFlags VkQueryPipelineStatisticFlags;
-typedef VkFlags VkMemoryMapFlags;
-typedef VkFlags VkImageAspectFlags;
-typedef VkFlags VkSparseMemoryBindFlags;
-typedef VkFlags VkSparseImageFormatFlags;
-typedef VkFlags VkSubpassDescriptionFlags;
-typedef VkFlags VkPipelineStageFlags;
-typedef VkFlags VkSampleCountFlags;
-typedef VkFlags VkAttachmentDescriptionFlags;
-typedef VkFlags VkStencilFaceFlags;
-typedef VkFlags VkCullModeFlags;
-typedef VkFlags VkDescriptorPoolCreateFlags;
-typedef VkFlags VkDescriptorPoolResetFlags;
-typedef VkFlags VkDependencyFlags;
-typedef VkFlags VkSubgroupFeatureFlags;
-typedef VkFlags VkDescriptorUpdateTemplateCreateFlags;
-typedef VkFlags VkCompositeAlphaFlagsKHR;
-typedef VkFlags VkSurfaceTransformFlagsKHR;
-typedef VkFlags VkSwapchainCreateFlagsKHR;
-typedef VkFlags VkPeerMemoryFeatureFlags;
-typedef VkFlags VkMemoryAllocateFlags;
-typedef VkFlags VkDeviceGroupPresentModeFlagsKHR;
-typedef VkFlags VkDebugReportFlagsEXT;
-typedef VkFlags VkCommandPoolTrimFlags;
-typedef VkFlags VkExternalMemoryHandleTypeFlags;
-typedef VkFlags VkExternalMemoryFeatureFlags;
-typedef VkFlags VkExternalSemaphoreHandleTypeFlags;
-typedef VkFlags VkExternalSemaphoreFeatureFlags;
-typedef VkFlags VkSemaphoreImportFlags;
-typedef VkFlags VkExternalFenceHandleTypeFlags;
-typedef VkFlags VkExternalFenceFeatureFlags;
-typedef VkFlags VkFenceImportFlags;
-typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)(
-    VkDebugReportFlagsEXT                       flags,
-    VkDebugReportObjectTypeEXT                  objectType,
-    uint64_t                                    object,
-    size_t                                      location,
-    int32_t                                     messageCode,
-    const char*                                 pLayerPrefix,
-    const char*                                 pMessage,
-    void*                                       pUserData);
-typedef struct VkDeviceQueueCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkDeviceQueueCreateFlags      flags;
-    uint32_t          queueFamilyIndex;
-    uint32_t          queueCount;
-    const  float *     pQueuePriorities;
-} VkDeviceQueueCreateInfo;
-typedef struct VkInstanceCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkInstanceCreateFlags    flags;
-    const  VkApplicationInfo *  pApplicationInfo;
-    uint32_t                 enabledLayerCount;
-    const  char * const*       ppEnabledLayerNames;
-    uint32_t                 enabledExtensionCount;
-    const  char * const*       ppEnabledExtensionNames;
-} VkInstanceCreateInfo;
-typedef struct VkQueueFamilyProperties {
-    VkQueueFlags             queueFlags;
-    uint32_t                 queueCount;
-    uint32_t                 timestampValidBits;
-    VkExtent3D               minImageTransferGranularity;
-} VkQueueFamilyProperties;
-typedef struct VkMemoryAllocateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDeviceSize             allocationSize;
-    uint32_t                 memoryTypeIndex;
-} VkMemoryAllocateInfo;
-typedef struct VkMemoryRequirements {
-    VkDeviceSize             size;
-    VkDeviceSize             alignment;
-    uint32_t                 memoryTypeBits;
-} VkMemoryRequirements;
-typedef struct VkSparseImageFormatProperties {
-    VkImageAspectFlags       aspectMask;
-    VkExtent3D               imageGranularity;
-    VkSparseImageFormatFlags   flags;
-} VkSparseImageFormatProperties;
-typedef struct VkSparseImageMemoryRequirements {
-    VkSparseImageFormatProperties   formatProperties;
-    uint32_t                 imageMipTailFirstLod;
-    VkDeviceSize             imageMipTailSize;
-    VkDeviceSize             imageMipTailOffset;
-    VkDeviceSize             imageMipTailStride;
-} VkSparseImageMemoryRequirements;
-typedef struct VkMemoryType {
-    VkMemoryPropertyFlags    propertyFlags;
-    uint32_t                 heapIndex;
-} VkMemoryType;
-typedef struct VkMemoryHeap {
-    VkDeviceSize             size;
-    VkMemoryHeapFlags        flags;
-} VkMemoryHeap;
-typedef struct VkMappedMemoryRange {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDeviceMemory           memory;
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-} VkMappedMemoryRange;
-typedef struct VkFormatProperties {
-    VkFormatFeatureFlags     linearTilingFeatures;
-    VkFormatFeatureFlags     optimalTilingFeatures;
-    VkFormatFeatureFlags     bufferFeatures;
-} VkFormatProperties;
-typedef struct VkImageFormatProperties {
-    VkExtent3D               maxExtent;
-    uint32_t                 maxMipLevels;
-    uint32_t                 maxArrayLayers;
-    VkSampleCountFlags       sampleCounts;
-    VkDeviceSize             maxResourceSize;
-} VkImageFormatProperties;
-typedef struct VkDescriptorBufferInfo {
-    VkBuffer                 buffer;
-    VkDeviceSize             offset;
-    VkDeviceSize             range;
-} VkDescriptorBufferInfo;
-typedef struct VkWriteDescriptorSet {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSet          dstSet;
-    uint32_t                 dstBinding;
-    uint32_t                 dstArrayElement;
-    uint32_t                 descriptorCount;
-    VkDescriptorType         descriptorType;
-    const  VkDescriptorImageInfo *  pImageInfo;
-    const  VkDescriptorBufferInfo *  pBufferInfo;
-    const  VkBufferView *     pTexelBufferView;
-} VkWriteDescriptorSet;
-typedef struct VkBufferCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkBufferCreateFlags      flags;
-    VkDeviceSize             size;
-    VkBufferUsageFlags       usage;
-    VkSharingMode            sharingMode;
-    uint32_t                 queueFamilyIndexCount;
-    const  uint32_t *         pQueueFamilyIndices;
-} VkBufferCreateInfo;
-typedef struct VkBufferViewCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkBufferViewCreateFlags flags;
-    VkBuffer                 buffer;
-    VkFormat                 format;
-    VkDeviceSize             offset;
-    VkDeviceSize             range;
-} VkBufferViewCreateInfo;
-typedef struct VkImageSubresource {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 mipLevel;
-    uint32_t                 arrayLayer;
-} VkImageSubresource;
-typedef struct VkImageSubresourceLayers {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 mipLevel;
-    uint32_t                 baseArrayLayer;
-    uint32_t                 layerCount;
-} VkImageSubresourceLayers;
-typedef struct VkImageSubresourceRange {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 baseMipLevel;
-    uint32_t                 levelCount;
-    uint32_t                 baseArrayLayer;
-    uint32_t                 layerCount;
-} VkImageSubresourceRange;
-typedef struct VkMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-} VkMemoryBarrier;
-typedef struct VkBufferMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    uint32_t                 srcQueueFamilyIndex;
-    uint32_t                 dstQueueFamilyIndex;
-    VkBuffer                 buffer;
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-} VkBufferMemoryBarrier;
-typedef struct VkImageMemoryBarrier {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    VkImageLayout            oldLayout;
-    VkImageLayout            newLayout;
-    uint32_t                 srcQueueFamilyIndex;
-    uint32_t                 dstQueueFamilyIndex;
-    VkImage                  image;
-    VkImageSubresourceRange   subresourceRange;
-} VkImageMemoryBarrier;
-typedef struct VkImageCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkImageCreateFlags       flags;
-    VkImageType              imageType;
-    VkFormat                 format;
-    VkExtent3D               extent;
-    uint32_t                 mipLevels;
-    uint32_t                 arrayLayers;
-    VkSampleCountFlagBits    samples;
-    VkImageTiling            tiling;
-    VkImageUsageFlags        usage;
-    VkSharingMode            sharingMode;
-    uint32_t                 queueFamilyIndexCount;
-    const  uint32_t *         pQueueFamilyIndices;
-    VkImageLayout            initialLayout;
-} VkImageCreateInfo;
-typedef struct VkSubresourceLayout {
-    VkDeviceSize             offset;
-    VkDeviceSize             size;
-    VkDeviceSize             rowPitch;
-    VkDeviceSize             arrayPitch;
-    VkDeviceSize             depthPitch;
-} VkSubresourceLayout;
-typedef struct VkImageViewCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkImageViewCreateFlags   flags;
-    VkImage                  image;
-    VkImageViewType          viewType;
-    VkFormat                 format;
-    VkComponentMapping       components;
-    VkImageSubresourceRange   subresourceRange;
-} VkImageViewCreateInfo;
-typedef struct VkBufferCopy {
-    VkDeviceSize                         srcOffset;
-    VkDeviceSize                         dstOffset;
-    VkDeviceSize   size;
-} VkBufferCopy;
-typedef struct VkSparseMemoryBind {
-    VkDeviceSize             resourceOffset;
-    VkDeviceSize             size;
-    VkDeviceMemory           memory;
-    VkDeviceSize             memoryOffset;
-    VkSparseMemoryBindFlags flags;
-} VkSparseMemoryBind;
-typedef struct VkSparseImageMemoryBind {
-    VkImageSubresource       subresource;
-    VkOffset3D               offset;
-    VkExtent3D               extent;
-    VkDeviceMemory           memory;
-    VkDeviceSize             memoryOffset;
-    VkSparseMemoryBindFlags flags;
-} VkSparseImageMemoryBind;
-typedef struct VkSparseBufferMemoryBindInfo {
-    VkBuffer   buffer;
-    uint32_t                 bindCount;
-    const  VkSparseMemoryBind *  pBinds;
-} VkSparseBufferMemoryBindInfo;
-typedef struct VkSparseImageOpaqueMemoryBindInfo {
-    VkImage   image;
-    uint32_t                 bindCount;
-    const  VkSparseMemoryBind *  pBinds;
-} VkSparseImageOpaqueMemoryBindInfo;
-typedef struct VkSparseImageMemoryBindInfo {
-    VkImage   image;
-    uint32_t                 bindCount;
-    const  VkSparseImageMemoryBind *  pBinds;
-} VkSparseImageMemoryBindInfo;
-typedef struct VkBindSparseInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    uint32_t                 waitSemaphoreCount;
-    const  VkSemaphore *      pWaitSemaphores;
-    uint32_t                 bufferBindCount;
-    const  VkSparseBufferMemoryBindInfo *  pBufferBinds;
-    uint32_t                 imageOpaqueBindCount;
-    const  VkSparseImageOpaqueMemoryBindInfo *  pImageOpaqueBinds;
-    uint32_t                 imageBindCount;
-    const  VkSparseImageMemoryBindInfo *  pImageBinds;
-    uint32_t                 signalSemaphoreCount;
-    const  VkSemaphore *      pSignalSemaphores;
-} VkBindSparseInfo;
-typedef struct VkImageCopy {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffset;
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffset;
-    VkExtent3D               extent;
-} VkImageCopy;
-typedef struct VkImageBlit {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffsets [2];
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffsets [2];
-} VkImageBlit;
-typedef struct VkBufferImageCopy {
-    VkDeviceSize             bufferOffset;
-    uint32_t                 bufferRowLength;
-    uint32_t                 bufferImageHeight;
-    VkImageSubresourceLayers   imageSubresource;
-    VkOffset3D               imageOffset;
-    VkExtent3D               imageExtent;
-} VkBufferImageCopy;
-typedef struct VkImageResolve {
-    VkImageSubresourceLayers   srcSubresource;
-    VkOffset3D               srcOffset;
-    VkImageSubresourceLayers   dstSubresource;
-    VkOffset3D               dstOffset;
-    VkExtent3D               extent;
-} VkImageResolve;
-typedef struct VkShaderModuleCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkShaderModuleCreateFlags   flags;
-    size_t                   codeSize;
-    const  uint32_t *             pCode;
-} VkShaderModuleCreateInfo;
-typedef struct VkDescriptorSetLayoutBinding {
-    uint32_t                 binding;
-    VkDescriptorType         descriptorType;
-    uint32_t   descriptorCount;
-    VkShaderStageFlags       stageFlags;
-    const  VkSampler *        pImmutableSamplers;
-} VkDescriptorSetLayoutBinding;
-typedef struct VkDescriptorSetLayoutCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorSetLayoutCreateFlags      flags;
-    uint32_t                 bindingCount;
-    const  VkDescriptorSetLayoutBinding *  pBindings;
-} VkDescriptorSetLayoutCreateInfo;
-typedef struct VkDescriptorPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkDescriptorPoolCreateFlags    flags;
-    uint32_t                 maxSets;
-    uint32_t                 poolSizeCount;
-    const  VkDescriptorPoolSize *  pPoolSizes;
-} VkDescriptorPoolCreateInfo;
-typedef struct VkPipelineShaderStageCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineShaderStageCreateFlags      flags;
-    VkShaderStageFlagBits    stage;
-    VkShaderModule           module;
-    const  char *             pName;
-    const  VkSpecializationInfo *  pSpecializationInfo;
-} VkPipelineShaderStageCreateInfo;
-typedef struct VkComputePipelineCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCreateFlags    flags;
-    VkPipelineShaderStageCreateInfo   stage;
-    VkPipelineLayout         layout;
-    VkPipeline        basePipelineHandle;
-    int32_t                  basePipelineIndex;
-} VkComputePipelineCreateInfo;
-typedef struct VkPipelineVertexInputStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineVertexInputStateCreateFlags      flags;
-    uint32_t                 vertexBindingDescriptionCount;
-    const  VkVertexInputBindingDescription *  pVertexBindingDescriptions;
-    uint32_t                 vertexAttributeDescriptionCount;
-    const  VkVertexInputAttributeDescription *  pVertexAttributeDescriptions;
-} VkPipelineVertexInputStateCreateInfo;
-typedef struct VkPipelineInputAssemblyStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineInputAssemblyStateCreateFlags      flags;
-    VkPrimitiveTopology      topology;
-    VkBool32                 primitiveRestartEnable;
-} VkPipelineInputAssemblyStateCreateInfo;
-typedef struct VkPipelineTessellationStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineTessellationStateCreateFlags      flags;
-    uint32_t                 patchControlPoints;
-} VkPipelineTessellationStateCreateInfo;
-typedef struct VkPipelineViewportStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineViewportStateCreateFlags      flags;
-    uint32_t                 viewportCount;
-    const  VkViewport *       pViewports;
-    uint32_t                 scissorCount;
-    const  VkRect2D *         pScissors;
-} VkPipelineViewportStateCreateInfo;
-typedef struct VkPipelineRasterizationStateCreateInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkPipelineRasterizationStateCreateFlags      flags;
-    VkBool32                 depthClampEnable;
-    VkBool32                 rasterizerDiscardEnable;
-    VkPolygonMode            polygonMode;
-    VkCullModeFlags          cullMode;
-    VkFrontFace              frontFace;
-    VkBool32                 depthBiasEnable;
-    float                    depthBiasConstantFactor;
-    float                    depthBiasClamp;
-    float                    depthBiasSlopeFactor;
-    float                    lineWidth;
-} VkPipelineRasterizationStateCreateInfo;
-typedef struct VkPipelineMultisampleStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineMultisampleStateCreateFlags      flags;
-    VkSampleCountFlagBits    rasterizationSamples;
-    VkBool32                 sampleShadingEnable;
-    float                    minSampleShading;
-    const  VkSampleMask *     pSampleMask;
-    VkBool32                 alphaToCoverageEnable;
-    VkBool32                 alphaToOneEnable;
-} VkPipelineMultisampleStateCreateInfo;
-typedef struct VkPipelineColorBlendAttachmentState {
-    VkBool32                 blendEnable;
-    VkBlendFactor            srcColorBlendFactor;
-    VkBlendFactor            dstColorBlendFactor;
-    VkBlendOp                colorBlendOp;
-    VkBlendFactor            srcAlphaBlendFactor;
-    VkBlendFactor            dstAlphaBlendFactor;
-    VkBlendOp                alphaBlendOp;
-    VkColorComponentFlags    colorWriteMask;
-} VkPipelineColorBlendAttachmentState;
-typedef struct VkPipelineColorBlendStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineColorBlendStateCreateFlags      flags;
-    VkBool32                 logicOpEnable;
-    VkLogicOp                logicOp;
-    uint32_t                 attachmentCount;
-    const  VkPipelineColorBlendAttachmentState *  pAttachments;
-    float                    blendConstants [4];
-} VkPipelineColorBlendStateCreateInfo;
-typedef struct VkPipelineDynamicStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineDynamicStateCreateFlags      flags;
-    uint32_t                 dynamicStateCount;
-    const  VkDynamicState *   pDynamicStates;
-} VkPipelineDynamicStateCreateInfo;
-typedef struct VkPipelineDepthStencilStateCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineDepthStencilStateCreateFlags      flags;
-    VkBool32                 depthTestEnable;
-    VkBool32                 depthWriteEnable;
-    VkCompareOp              depthCompareOp;
-    VkBool32                 depthBoundsTestEnable;
-    VkBool32                 stencilTestEnable;
-    VkStencilOpState         front;
-    VkStencilOpState         back;
-    float                    minDepthBounds;
-    float                    maxDepthBounds;
-} VkPipelineDepthStencilStateCreateInfo;
-typedef struct VkGraphicsPipelineCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCreateFlags    flags;
-    uint32_t                 stageCount;
-    const  VkPipelineShaderStageCreateInfo *  pStages;
-    const  VkPipelineVertexInputStateCreateInfo *  pVertexInputState;
-    const  VkPipelineInputAssemblyStateCreateInfo *  pInputAssemblyState;
-    const  VkPipelineTessellationStateCreateInfo *  pTessellationState;
-    const  VkPipelineViewportStateCreateInfo *  pViewportState;
-    const  VkPipelineRasterizationStateCreateInfo *  pRasterizationState;
-    const  VkPipelineMultisampleStateCreateInfo *  pMultisampleState;
-    const  VkPipelineDepthStencilStateCreateInfo *  pDepthStencilState;
-    const  VkPipelineColorBlendStateCreateInfo *  pColorBlendState;
-    const  VkPipelineDynamicStateCreateInfo *  pDynamicState;
-    VkPipelineLayout         layout;
-    VkRenderPass             renderPass;
-    uint32_t                 subpass;
-    VkPipeline        basePipelineHandle;
-    int32_t                  basePipelineIndex;
-} VkGraphicsPipelineCreateInfo;
-typedef struct VkPipelineCacheCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineCacheCreateFlags      flags;
-    size_t                   initialDataSize;
-    const  void *             pInitialData;
-} VkPipelineCacheCreateInfo;
-typedef struct VkPushConstantRange {
-    VkShaderStageFlags       stageFlags;
-    uint32_t                 offset;
-    uint32_t                 size;
-} VkPushConstantRange;
-typedef struct VkPipelineLayoutCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkPipelineLayoutCreateFlags      flags;
-    uint32_t                 setLayoutCount;
-    const  VkDescriptorSetLayout *  pSetLayouts;
-    uint32_t                 pushConstantRangeCount;
-    const  VkPushConstantRange *  pPushConstantRanges;
-} VkPipelineLayoutCreateInfo;
-typedef struct VkSamplerCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkSamplerCreateFlags     flags;
-    VkFilter                 magFilter;
-    VkFilter                 minFilter;
-    VkSamplerMipmapMode      mipmapMode;
-    VkSamplerAddressMode     addressModeU;
-    VkSamplerAddressMode     addressModeV;
-    VkSamplerAddressMode     addressModeW;
-    float                    mipLodBias;
-    VkBool32                 anisotropyEnable;
-    float                    maxAnisotropy;
-    VkBool32                 compareEnable;
-    VkCompareOp              compareOp;
-    float                    minLod;
-    float                    maxLod;
-    VkBorderColor            borderColor;
-    VkBool32                 unnormalizedCoordinates;
-} VkSamplerCreateInfo;
-typedef struct VkCommandPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandPoolCreateFlags     flags;
-    uint32_t                 queueFamilyIndex;
-} VkCommandPoolCreateInfo;
-typedef struct VkCommandBufferInheritanceInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPass      renderPass;
-    uint32_t                 subpass;
-    VkFramebuffer     framebuffer;
-    VkBool32                 occlusionQueryEnable;
-    VkQueryControlFlags      queryFlags;
-    VkQueryPipelineStatisticFlags   pipelineStatistics;
-} VkCommandBufferInheritanceInfo;
-typedef struct VkCommandBufferBeginInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkCommandBufferUsageFlags    flags;
-    const  VkCommandBufferInheritanceInfo *        pInheritanceInfo;
-} VkCommandBufferBeginInfo;
-typedef struct VkRenderPassBeginInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPass             renderPass;
-    VkFramebuffer            framebuffer;
-    VkRect2D                 renderArea;
-    uint32_t                 clearValueCount;
-    const  VkClearValue *     pClearValues;
-} VkRenderPassBeginInfo;
-typedef struct VkClearAttachment {
-    VkImageAspectFlags       aspectMask;
-    uint32_t                 colorAttachment;
-    VkClearValue             clearValue;
-} VkClearAttachment;
-typedef struct VkAttachmentDescription {
-    VkAttachmentDescriptionFlags   flags;
-    VkFormat                 format;
-    VkSampleCountFlagBits    samples;
-    VkAttachmentLoadOp       loadOp;
-    VkAttachmentStoreOp      storeOp;
-    VkAttachmentLoadOp       stencilLoadOp;
-    VkAttachmentStoreOp      stencilStoreOp;
-    VkImageLayout            initialLayout;
-    VkImageLayout            finalLayout;
-} VkAttachmentDescription;
-typedef struct VkSubpassDescription {
-    VkSubpassDescriptionFlags   flags;
-    VkPipelineBindPoint      pipelineBindPoint;
-    uint32_t                 inputAttachmentCount;
-    const  VkAttachmentReference *  pInputAttachments;
-    uint32_t                 colorAttachmentCount;
-    const  VkAttachmentReference *  pColorAttachments;
-    const  VkAttachmentReference *  pResolveAttachments;
-    const  VkAttachmentReference *  pDepthStencilAttachment;
-    uint32_t                 preserveAttachmentCount;
-    const  uint32_t *  pPreserveAttachments;
-} VkSubpassDescription;
-typedef struct VkSubpassDependency {
-    uint32_t                 srcSubpass;
-    uint32_t                 dstSubpass;
-    VkPipelineStageFlags     srcStageMask;
-    VkPipelineStageFlags     dstStageMask;
-    VkAccessFlags            srcAccessMask;
-    VkAccessFlags            dstAccessMask;
-    VkDependencyFlags        dependencyFlags;
-} VkSubpassDependency;
-typedef struct VkRenderPassCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkRenderPassCreateFlags      flags;
-    uint32_t     attachmentCount;
-    const  VkAttachmentDescription *  pAttachments;
-    uint32_t                 subpassCount;
-    const  VkSubpassDescription *  pSubpasses;
-    uint32_t         dependencyCount;
-    const  VkSubpassDependency *  pDependencies;
-} VkRenderPassCreateInfo;
-typedef struct VkEventCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkEventCreateFlags       flags;
-} VkEventCreateInfo;
-typedef struct VkFenceCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkFenceCreateFlags       flags;
-} VkFenceCreateInfo;
-typedef struct VkPhysicalDeviceFeatures {
-    VkBool32                 robustBufferAccess;
-    VkBool32                 fullDrawIndexUint32;
-    VkBool32                 imageCubeArray;
-    VkBool32                 independentBlend;
-    VkBool32                 geometryShader;
-    VkBool32                 tessellationShader;
-    VkBool32                 sampleRateShading;
-    VkBool32                 dualSrcBlend;
-    VkBool32                 logicOp;
-    VkBool32                 multiDrawIndirect;
-    VkBool32                 drawIndirectFirstInstance;
-    VkBool32                 depthClamp;
-    VkBool32                 depthBiasClamp;
-    VkBool32                 fillModeNonSolid;
-    VkBool32                 depthBounds;
-    VkBool32                 wideLines;
-    VkBool32                 largePoints;
-    VkBool32                 alphaToOne;
-    VkBool32                 multiViewport;
-    VkBool32                 samplerAnisotropy;
-    VkBool32                 textureCompressionETC2;
-    VkBool32                 textureCompressionASTC_LDR;
-    VkBool32                 textureCompressionBC;
-    VkBool32                 occlusionQueryPrecise;
-    VkBool32                 pipelineStatisticsQuery;
-    VkBool32                 vertexPipelineStoresAndAtomics;
-    VkBool32                 fragmentStoresAndAtomics;
-    VkBool32                 shaderTessellationAndGeometryPointSize;
-    VkBool32                 shaderImageGatherExtended;
-    VkBool32                 shaderStorageImageExtendedFormats;
-    VkBool32                 shaderStorageImageMultisample;
-    VkBool32                 shaderStorageImageReadWithoutFormat;
-    VkBool32                 shaderStorageImageWriteWithoutFormat;
-    VkBool32                 shaderUniformBufferArrayDynamicIndexing;
-    VkBool32                 shaderSampledImageArrayDynamicIndexing;
-    VkBool32                 shaderStorageBufferArrayDynamicIndexing;
-    VkBool32                 shaderStorageImageArrayDynamicIndexing;
-    VkBool32                 shaderClipDistance;
-    VkBool32                 shaderCullDistance;
-    VkBool32                 shaderFloat64;
-    VkBool32                 shaderInt64;
-    VkBool32                 shaderInt16;
-    VkBool32                 shaderResourceResidency;
-    VkBool32                 shaderResourceMinLod;
-    VkBool32                 sparseBinding;
-    VkBool32                 sparseResidencyBuffer;
-    VkBool32                 sparseResidencyImage2D;
-    VkBool32                 sparseResidencyImage3D;
-    VkBool32                 sparseResidency2Samples;
-    VkBool32                 sparseResidency4Samples;
-    VkBool32                 sparseResidency8Samples;
-    VkBool32                 sparseResidency16Samples;
-    VkBool32                 sparseResidencyAliased;
-    VkBool32                 variableMultisampleRate;
-    VkBool32                 inheritedQueries;
-} VkPhysicalDeviceFeatures;
-typedef struct VkPhysicalDeviceSparseProperties {
-    VkBool32                 residencyStandard2DBlockShape;
-    VkBool32                 residencyStandard2DMultisampleBlockShape;
-    VkBool32                 residencyStandard3DBlockShape;
-    VkBool32                 residencyAlignedMipSize;
-    VkBool32                 residencyNonResidentStrict;
-} VkPhysicalDeviceSparseProperties;
-typedef struct VkPhysicalDeviceLimits {
-    uint32_t                 maxImageDimension1D;
-    uint32_t                 maxImageDimension2D;
-    uint32_t                 maxImageDimension3D;
-    uint32_t                 maxImageDimensionCube;
-    uint32_t                 maxImageArrayLayers;
-    uint32_t                 maxTexelBufferElements;
-    uint32_t                 maxUniformBufferRange;
-    uint32_t                 maxStorageBufferRange;
-    uint32_t                 maxPushConstantsSize;
-    uint32_t                 maxMemoryAllocationCount;
-    uint32_t                 maxSamplerAllocationCount;
-    VkDeviceSize             bufferImageGranularity;
-    VkDeviceSize             sparseAddressSpaceSize;
-    uint32_t                 maxBoundDescriptorSets;
-    uint32_t                 maxPerStageDescriptorSamplers;
-    uint32_t                 maxPerStageDescriptorUniformBuffers;
-    uint32_t                 maxPerStageDescriptorStorageBuffers;
-    uint32_t                 maxPerStageDescriptorSampledImages;
-    uint32_t                 maxPerStageDescriptorStorageImages;
-    uint32_t                 maxPerStageDescriptorInputAttachments;
-    uint32_t                 maxPerStageResources;
-    uint32_t                 maxDescriptorSetSamplers;
-    uint32_t                 maxDescriptorSetUniformBuffers;
-    uint32_t                 maxDescriptorSetUniformBuffersDynamic;
-    uint32_t                 maxDescriptorSetStorageBuffers;
-    uint32_t                 maxDescriptorSetStorageBuffersDynamic;
-    uint32_t                 maxDescriptorSetSampledImages;
-    uint32_t                 maxDescriptorSetStorageImages;
-    uint32_t                 maxDescriptorSetInputAttachments;
-    uint32_t                 maxVertexInputAttributes;
-    uint32_t                 maxVertexInputBindings;
-    uint32_t                 maxVertexInputAttributeOffset;
-    uint32_t                 maxVertexInputBindingStride;
-    uint32_t                 maxVertexOutputComponents;
-    uint32_t                 maxTessellationGenerationLevel;
-    uint32_t                 maxTessellationPatchSize;
-    uint32_t                 maxTessellationControlPerVertexInputComponents;
-    uint32_t                 maxTessellationControlPerVertexOutputComponents;
-    uint32_t                 maxTessellationControlPerPatchOutputComponents;
-    uint32_t                 maxTessellationControlTotalOutputComponents;
-    uint32_t                 maxTessellationEvaluationInputComponents;
-    uint32_t                 maxTessellationEvaluationOutputComponents;
-    uint32_t                 maxGeometryShaderInvocations;
-    uint32_t                 maxGeometryInputComponents;
-    uint32_t                 maxGeometryOutputComponents;
-    uint32_t                 maxGeometryOutputVertices;
-    uint32_t                 maxGeometryTotalOutputComponents;
-    uint32_t                 maxFragmentInputComponents;
-    uint32_t                 maxFragmentOutputAttachments;
-    uint32_t                 maxFragmentDualSrcAttachments;
-    uint32_t                 maxFragmentCombinedOutputResources;
-    uint32_t                 maxComputeSharedMemorySize;
-    uint32_t                 maxComputeWorkGroupCount [3];
-    uint32_t                 maxComputeWorkGroupInvocations;
-    uint32_t                 maxComputeWorkGroupSize [3];
-    uint32_t                 subPixelPrecisionBits;
-    uint32_t                 subTexelPrecisionBits;
-    uint32_t                 mipmapPrecisionBits;
-    uint32_t                 maxDrawIndexedIndexValue;
-    uint32_t                 maxDrawIndirectCount;
-    float                    maxSamplerLodBias;
-    float                    maxSamplerAnisotropy;
-    uint32_t                 maxViewports;
-    uint32_t                 maxViewportDimensions [2];
-    float                    viewportBoundsRange [2];
-    uint32_t                 viewportSubPixelBits;
-    size_t                   minMemoryMapAlignment;
-    VkDeviceSize             minTexelBufferOffsetAlignment;
-    VkDeviceSize             minUniformBufferOffsetAlignment;
-    VkDeviceSize             minStorageBufferOffsetAlignment;
-    int32_t                  minTexelOffset;
-    uint32_t                 maxTexelOffset;
-    int32_t                  minTexelGatherOffset;
-    uint32_t                 maxTexelGatherOffset;
-    float                    minInterpolationOffset;
-    float                    maxInterpolationOffset;
-    uint32_t                 subPixelInterpolationOffsetBits;
-    uint32_t                 maxFramebufferWidth;
-    uint32_t                 maxFramebufferHeight;
-    uint32_t                 maxFramebufferLayers;
-    VkSampleCountFlags       framebufferColorSampleCounts;
-    VkSampleCountFlags       framebufferDepthSampleCounts;
-    VkSampleCountFlags       framebufferStencilSampleCounts;
-    VkSampleCountFlags       framebufferNoAttachmentsSampleCounts;
-    uint32_t                 maxColorAttachments;
-    VkSampleCountFlags       sampledImageColorSampleCounts;
-    VkSampleCountFlags       sampledImageIntegerSampleCounts;
-    VkSampleCountFlags       sampledImageDepthSampleCounts;
-    VkSampleCountFlags       sampledImageStencilSampleCounts;
-    VkSampleCountFlags       storageImageSampleCounts;
-    uint32_t                 maxSampleMaskWords;
-    VkBool32                 timestampComputeAndGraphics;
-    float                    timestampPeriod;
-    uint32_t                 maxClipDistances;
-    uint32_t                 maxCullDistances;
-    uint32_t                 maxCombinedClipAndCullDistances;
-    uint32_t                 discreteQueuePriorities;
-    float                    pointSizeRange [2];
-    float                    lineWidthRange [2];
-    float                    pointSizeGranularity;
-    float                    lineWidthGranularity;
-    VkBool32                 strictLines;
-    VkBool32                 standardSampleLocations;
-    VkDeviceSize             optimalBufferCopyOffsetAlignment;
-    VkDeviceSize             optimalBufferCopyRowPitchAlignment;
-    VkDeviceSize             nonCoherentAtomSize;
-} VkPhysicalDeviceLimits;
-typedef struct VkSemaphoreCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkSemaphoreCreateFlags   flags;
-} VkSemaphoreCreateInfo;
-typedef struct VkQueryPoolCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkQueryPoolCreateFlags   flags;
-    VkQueryType              queryType;
-    uint32_t                 queryCount;
-    VkQueryPipelineStatisticFlags   pipelineStatistics;
-} VkQueryPoolCreateInfo;
-typedef struct VkFramebufferCreateInfo {
-    VkStructureType   sType;
-    const  void *             pNext;
-    VkFramebufferCreateFlags      flags;
-    VkRenderPass             renderPass;
-    uint32_t                 attachmentCount;
-    const  VkImageView *      pAttachments;
-    uint32_t                 width;
-    uint32_t                 height;
-    uint32_t                 layers;
-} VkFramebufferCreateInfo;
-typedef struct VkSubmitInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    uint32_t         waitSemaphoreCount;
-    const  VkSemaphore *      pWaitSemaphores;
-    const  VkPipelineStageFlags *            pWaitDstStageMask;
-    uint32_t         commandBufferCount;
-    const  VkCommandBuffer *      pCommandBuffers;
-    uint32_t         signalSemaphoreCount;
-    const  VkSemaphore *      pSignalSemaphores;
-} VkSubmitInfo;
-typedef struct VkSurfaceCapabilitiesKHR {
-    uint32_t                           minImageCount;
-    uint32_t                           maxImageCount;
-    VkExtent2D                         currentExtent;
-    VkExtent2D                         minImageExtent;
-    VkExtent2D                         maxImageExtent;
-    uint32_t                           maxImageArrayLayers;
-    VkSurfaceTransformFlagsKHR         supportedTransforms;
-    VkSurfaceTransformFlagBitsKHR      currentTransform;
-    VkCompositeAlphaFlagsKHR           supportedCompositeAlpha;
-    VkImageUsageFlags                  supportedUsageFlags;
-} VkSurfaceCapabilitiesKHR;
-typedef struct VkSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkSwapchainCreateFlagsKHR          flags;
-    VkSurfaceKHR                       surface;
-    uint32_t                           minImageCount;
-    VkFormat                           imageFormat;
-    VkColorSpaceKHR                    imageColorSpace;
-    VkExtent2D                         imageExtent;
-    uint32_t                           imageArrayLayers;
-    VkImageUsageFlags                  imageUsage;
-    VkSharingMode                      imageSharingMode;
-    uint32_t           queueFamilyIndexCount;
-    const  uint32_t *                   pQueueFamilyIndices;
-    VkSurfaceTransformFlagBitsKHR      preTransform;
-    VkCompositeAlphaFlagBitsKHR        compositeAlpha;
-    VkPresentModeKHR                   presentMode;
-    VkBool32                           clipped;
-    VkSwapchainKHR     oldSwapchain;
-} VkSwapchainCreateInfoKHR;
-typedef struct VkDebugReportCallbackCreateInfoEXT {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkDebugReportFlagsEXT              flags;
-    PFN_vkDebugReportCallbackEXT       pfnCallback;
-    void *             pUserData;
-} VkDebugReportCallbackCreateInfoEXT;
-typedef struct VkPhysicalDeviceFeatures2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceFeatures           features;
-} VkPhysicalDeviceFeatures2;
-typedef struct VkFormatProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkFormatProperties                 formatProperties;
-} VkFormatProperties2;
-typedef struct VkImageFormatProperties2 {
-    VkStructureType   sType;
-    void *  pNext;
-    VkImageFormatProperties            imageFormatProperties;
-} VkImageFormatProperties2;
-typedef struct VkPhysicalDeviceImageFormatInfo2 {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkFormat                           format;
-    VkImageType                        type;
-    VkImageTiling                      tiling;
-    VkImageUsageFlags                  usage;
-    VkImageCreateFlags   flags;
-} VkPhysicalDeviceImageFormatInfo2;
-typedef struct VkQueueFamilyProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkQueueFamilyProperties            queueFamilyProperties;
-} VkQueueFamilyProperties2;
-typedef struct VkSparseImageFormatProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkSparseImageFormatProperties      properties;
-} VkSparseImageFormatProperties2;
-typedef struct VkPhysicalDeviceSparseImageFormatInfo2 {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkFormat                           format;
-    VkImageType                        type;
-    VkSampleCountFlagBits              samples;
-    VkImageUsageFlags                  usage;
-    VkImageTiling                      tiling;
-} VkPhysicalDeviceSparseImageFormatInfo2;
-typedef struct VkPhysicalDeviceVariablePointersFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           variablePointersStorageBuffer;
-    VkBool32                           variablePointers;
-} VkPhysicalDeviceVariablePointersFeatures;
-typedef struct VkPhysicalDeviceVariablePointerFeatures  VkPhysicalDeviceVariablePointerFeatures;
-typedef struct VkExternalMemoryProperties {
-    VkExternalMemoryFeatureFlags    externalMemoryFeatures;
-    VkExternalMemoryHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalMemoryHandleTypeFlags   compatibleHandleTypes;
-} VkExternalMemoryProperties;
-typedef struct VkExternalImageFormatProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalMemoryProperties   externalMemoryProperties;
-} VkExternalImageFormatProperties;
-typedef struct VkPhysicalDeviceExternalBufferInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkBufferCreateFlags   flags;
-    VkBufferUsageFlags                 usage;
-    VkExternalMemoryHandleTypeFlagBits   handleType;
-} VkPhysicalDeviceExternalBufferInfo;
-typedef struct VkExternalBufferProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalMemoryProperties      externalMemoryProperties;
-} VkExternalBufferProperties;
-typedef struct VkPhysicalDeviceIDProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint8_t                            deviceUUID [ VK_UUID_SIZE ];
-    uint8_t                            driverUUID [ VK_UUID_SIZE ];
-    uint8_t                            deviceLUID [ VK_LUID_SIZE ];
-    uint32_t                           deviceNodeMask;
-    VkBool32                           deviceLUIDValid;
-} VkPhysicalDeviceIDProperties;
-typedef struct VkExternalMemoryImageCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExternalMemoryImageCreateInfo;
-typedef struct VkExternalMemoryBufferCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExternalMemoryBufferCreateInfo;
-typedef struct VkExportMemoryAllocateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalMemoryHandleTypeFlags   handleTypes;
-} VkExportMemoryAllocateInfo;
-typedef struct VkExternalSemaphoreProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalSemaphoreHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalSemaphoreHandleTypeFlags   compatibleHandleTypes;
-    VkExternalSemaphoreFeatureFlags   externalSemaphoreFeatures;
-} VkExternalSemaphoreProperties;
-typedef struct VkExportSemaphoreCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalSemaphoreHandleTypeFlags   handleTypes;
-} VkExportSemaphoreCreateInfo;
-typedef struct VkExternalFenceProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkExternalFenceHandleTypeFlags   exportFromImportedHandleTypes;
-    VkExternalFenceHandleTypeFlags   compatibleHandleTypes;
-    VkExternalFenceFeatureFlags   externalFenceFeatures;
-} VkExternalFenceProperties;
-typedef struct VkExportFenceCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkExternalFenceHandleTypeFlags   handleTypes;
-} VkExportFenceCreateInfo;
-typedef struct VkPhysicalDeviceMultiviewFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           multiview;
-    VkBool32                           multiviewGeometryShader;
-    VkBool32                           multiviewTessellationShader;
-} VkPhysicalDeviceMultiviewFeatures;
-typedef struct VkPhysicalDeviceGroupProperties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           physicalDeviceCount;
-    VkPhysicalDevice                   physicalDevices [ VK_MAX_DEVICE_GROUP_SIZE ];
-    VkBool32                           subsetAllocation;
-} VkPhysicalDeviceGroupProperties;
-typedef struct VkMemoryAllocateFlagsInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkMemoryAllocateFlags   flags;
-    uint32_t                           deviceMask;
-} VkMemoryAllocateFlagsInfo;
-typedef struct VkBindBufferMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkBuffer                           buffer;
-    VkDeviceMemory                     memory;
-    VkDeviceSize                       memoryOffset;
-} VkBindBufferMemoryInfo;
-typedef struct VkBindImageMemoryInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkImage                            image;
-    VkDeviceMemory                     memory;
-    VkDeviceSize                       memoryOffset;
-} VkBindImageMemoryInfo;
-typedef struct VkDeviceGroupPresentCapabilitiesKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    uint32_t                           presentMask [ VK_MAX_DEVICE_GROUP_SIZE ];
-    VkDeviceGroupPresentModeFlagsKHR   modes;
-} VkDeviceGroupPresentCapabilitiesKHR;
-typedef struct VkDeviceGroupSwapchainCreateInfoKHR {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkDeviceGroupPresentModeFlagsKHR                           modes;
-} VkDeviceGroupSwapchainCreateInfoKHR;
-typedef struct VkDescriptorUpdateTemplateCreateInfo {
-    VkStructureType   sType;
-    const  void *                                pNext;
-    VkDescriptorUpdateTemplateCreateFlags      flags;
-    uint32_t                   descriptorUpdateEntryCount;
-    const  VkDescriptorUpdateTemplateEntry *  pDescriptorUpdateEntries;
-    VkDescriptorUpdateTemplateType   templateType;
-    VkDescriptorSetLayout   descriptorSetLayout;
-    VkPipelineBindPoint   pipelineBindPoint;
-    VkPipelineLayout pipelineLayout;
-    uint32_t   set;
-} VkDescriptorUpdateTemplateCreateInfo;
-typedef struct VkInputAttachmentAspectReference {
-    uint32_t                          subpass;
-    uint32_t                          inputAttachmentIndex;
-    VkImageAspectFlags                aspectMask;
-} VkInputAttachmentAspectReference;
-typedef struct VkRenderPassInputAttachmentAspectCreateInfo {
-    VkStructureType   sType;
-    const  void *                      pNext;
-    uint32_t                          aspectReferenceCount;
-    const  VkInputAttachmentAspectReference *  pAspectReferences;
-} VkRenderPassInputAttachmentAspectCreateInfo;
-typedef struct VkPhysicalDevice16BitStorageFeatures {
-    VkStructureType   sType;
-    void *       pNext;
-    VkBool32                           storageBuffer16BitAccess;
-    VkBool32                           uniformAndStorageBuffer16BitAccess;
-    VkBool32                           storagePushConstant16;
-    VkBool32                           storageInputOutput16;
-} VkPhysicalDevice16BitStorageFeatures;
-typedef struct VkPhysicalDeviceSubgroupProperties {
-    VkStructureType   sType;
-    void *                    pNext;
-    uint32_t                        subgroupSize;
-    VkShaderStageFlags              supportedStages;
-    VkSubgroupFeatureFlags          supportedOperations;
-    VkBool32   quadOperationsInAllStages;
-} VkPhysicalDeviceSubgroupProperties;
-typedef struct VkMemoryRequirements2 {
-    VkStructureType   sType;
-    void *  pNext;
-    VkMemoryRequirements                                                   memoryRequirements;
-} VkMemoryRequirements2;
-typedef struct VkMemoryRequirements2KHR  VkMemoryRequirements2KHR;
-typedef struct VkSparseImageMemoryRequirements2 {
-    VkStructureType   sType;
-    void *                                        pNext;
-    VkSparseImageMemoryRequirements                                        memoryRequirements;
-} VkSparseImageMemoryRequirements2;
-typedef struct VkMemoryDedicatedRequirements {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           prefersDedicatedAllocation;
-    VkBool32                           requiresDedicatedAllocation;
-} VkMemoryDedicatedRequirements;
-typedef struct VkImageViewUsageCreateInfo {
-    VkStructureType   sType;
-    const  void *  pNext;
-    VkImageUsageFlags   usage;
-} VkImageViewUsageCreateInfo;
-typedef struct VkSamplerYcbcrConversionCreateInfo {
-    VkStructureType   sType;
-    const  void *                       pNext;
-    VkFormat                           format;
-    VkSamplerYcbcrModelConversion   ycbcrModel;
-    VkSamplerYcbcrRange             ycbcrRange;
-    VkComponentMapping                 components;
-    VkChromaLocation                xChromaOffset;
-    VkChromaLocation                yChromaOffset;
-    VkFilter                           chromaFilter;
-    VkBool32                           forceExplicitReconstruction;
-} VkSamplerYcbcrConversionCreateInfo;
-typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures {
-    VkStructureType   sType;
-    void *       pNext;
-    VkBool32                           samplerYcbcrConversion;
-} VkPhysicalDeviceSamplerYcbcrConversionFeatures;
-typedef struct VkProtectedSubmitInfo {
-    VkStructureType   sType;
-    const  void *                      pNext;
-    VkBool32                          protectedSubmit;
-} VkProtectedSubmitInfo;
-typedef struct VkPhysicalDeviceProtectedMemoryFeatures {
-    VkStructureType   sType;
-    void *                                pNext;
-    VkBool32                              protectedMemory;
-} VkPhysicalDeviceProtectedMemoryFeatures;
-typedef struct VkPhysicalDeviceProtectedMemoryProperties {
-    VkStructureType   sType;
-    void *                                pNext;
-    VkBool32                              protectedNoFault;
-} VkPhysicalDeviceProtectedMemoryProperties;
-typedef struct VkDeviceQueueInfo2 {
-    VkStructureType   sType;
-    const  void *                          pNext;
-    VkDeviceQueueCreateFlags              flags;
-    uint32_t                              queueFamilyIndex;
-    uint32_t                              queueIndex;
-} VkDeviceQueueInfo2;
-typedef struct VkPhysicalDeviceMaintenance3Properties {
-    VkStructureType   sType;
-    void *                             pNext;
-    uint32_t                           maxPerSetDescriptors;
-    VkDeviceSize                       maxMemoryAllocationSize;
-} VkPhysicalDeviceMaintenance3Properties;
-typedef struct VkDescriptorSetLayoutSupport {
-    VkStructureType   sType;
-    void *             pNext;
-    VkBool32           supported;
-} VkDescriptorSetLayoutSupport;
-typedef struct VkPhysicalDeviceShaderDrawParametersFeatures {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkBool32                           shaderDrawParameters;
-} VkPhysicalDeviceShaderDrawParametersFeatures;
-typedef struct VkPhysicalDeviceShaderDrawParameterFeatures  VkPhysicalDeviceShaderDrawParameterFeatures;
-typedef struct VkPhysicalDeviceProperties {
-    uint32_t         apiVersion;
-    uint32_t         driverVersion;
-    uint32_t         vendorID;
-    uint32_t         deviceID;
-    VkPhysicalDeviceType   deviceType;
-    char             deviceName [ VK_MAX_PHYSICAL_DEVICE_NAME_SIZE ];
-    uint8_t          pipelineCacheUUID [ VK_UUID_SIZE ];
-    VkPhysicalDeviceLimits   limits;
-    VkPhysicalDeviceSparseProperties   sparseProperties;
-} VkPhysicalDeviceProperties;
-typedef struct VkDeviceCreateInfo {
-    VkStructureType   sType;
-    const  void *      pNext;
-    VkDeviceCreateFlags      flags;
-    uint32_t          queueCreateInfoCount;
-    const  VkDeviceQueueCreateInfo *  pQueueCreateInfos;
-    uint32_t                 enabledLayerCount;
-    const  char * const*       ppEnabledLayerNames;
-    uint32_t                 enabledExtensionCount;
-    const  char * const*       ppEnabledExtensionNames;
-    const  VkPhysicalDeviceFeatures *  pEnabledFeatures;
-} VkDeviceCreateInfo;
-typedef struct VkPhysicalDeviceMemoryProperties {
-    uint32_t                 memoryTypeCount;
-    VkMemoryType             memoryTypes [ VK_MAX_MEMORY_TYPES ];
-    uint32_t                 memoryHeapCount;
-    VkMemoryHeap             memoryHeaps [ VK_MAX_MEMORY_HEAPS ];
-} VkPhysicalDeviceMemoryProperties;
-typedef struct VkPhysicalDeviceProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceProperties         properties;
-} VkPhysicalDeviceProperties2;
-typedef struct VkPhysicalDeviceMemoryProperties2 {
-    VkStructureType   sType;
-    void *                             pNext;
-    VkPhysicalDeviceMemoryProperties   memoryProperties;
-} VkPhysicalDeviceMemoryProperties2;
-
-
-#define VK_VERSION_1_0 1
-GLAD_API_CALL int GLAD_VK_VERSION_1_0;
-#define VK_VERSION_1_1 1
-GLAD_API_CALL int GLAD_VK_VERSION_1_1;
-#define VK_EXT_debug_report 1
-GLAD_API_CALL int GLAD_VK_EXT_debug_report;
-#define VK_KHR_surface 1
-GLAD_API_CALL int GLAD_VK_KHR_surface;
-#define VK_KHR_swapchain 1
-GLAD_API_CALL int GLAD_VK_KHR_swapchain;
-
-
-typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice   device, const  VkAcquireNextImageInfoKHR *  pAcquireInfo, uint32_t *  pImageIndex);
-typedef VkResult (GLAD_API_PTR *PFN_vkAcquireNextImageKHR)(VkDevice   device, VkSwapchainKHR   swapchain, uint64_t   timeout, VkSemaphore   semaphore, VkFence   fence, uint32_t *  pImageIndex);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateCommandBuffers)(VkDevice   device, const  VkCommandBufferAllocateInfo *  pAllocateInfo, VkCommandBuffer *  pCommandBuffers);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateDescriptorSets)(VkDevice   device, const  VkDescriptorSetAllocateInfo *  pAllocateInfo, VkDescriptorSet *  pDescriptorSets);
-typedef VkResult (GLAD_API_PTR *PFN_vkAllocateMemory)(VkDevice   device, const  VkMemoryAllocateInfo *  pAllocateInfo, const  VkAllocationCallbacks *  pAllocator, VkDeviceMemory *  pMemory);
-typedef VkResult (GLAD_API_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer   commandBuffer, const  VkCommandBufferBeginInfo *  pBeginInfo);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory)(VkDevice   device, VkBuffer   buffer, VkDeviceMemory   memory, VkDeviceSize   memoryOffset);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindBufferMemory2)(VkDevice   device, uint32_t   bindInfoCount, const  VkBindBufferMemoryInfo *  pBindInfos);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory)(VkDevice   device, VkImage   image, VkDeviceMemory   memory, VkDeviceSize   memoryOffset);
-typedef VkResult (GLAD_API_PTR *PFN_vkBindImageMemory2)(VkDevice   device, uint32_t   bindInfoCount, const  VkBindImageMemoryInfo *  pBindInfos);
-typedef void (GLAD_API_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   query, VkQueryControlFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer   commandBuffer, const  VkRenderPassBeginInfo *  pRenderPassBegin, VkSubpassContents   contents);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer   commandBuffer, VkPipelineBindPoint   pipelineBindPoint, VkPipelineLayout   layout, uint32_t   firstSet, uint32_t   descriptorSetCount, const  VkDescriptorSet *  pDescriptorSets, uint32_t   dynamicOffsetCount, const  uint32_t *  pDynamicOffsets);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, VkIndexType   indexType);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer   commandBuffer, VkPipelineBindPoint   pipelineBindPoint, VkPipeline   pipeline);
-typedef void (GLAD_API_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer   commandBuffer, uint32_t   firstBinding, uint32_t   bindingCount, const  VkBuffer *  pBuffers, const  VkDeviceSize *  pOffsets);
-typedef void (GLAD_API_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageBlit *  pRegions, VkFilter   filter);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer   commandBuffer, uint32_t   attachmentCount, const  VkClearAttachment *  pAttachments, uint32_t   rectCount, const  VkClearRect *  pRects);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer   commandBuffer, VkImage   image, VkImageLayout   imageLayout, const  VkClearColorValue *  pColor, uint32_t   rangeCount, const  VkImageSubresourceRange *  pRanges);
-typedef void (GLAD_API_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer   commandBuffer, VkImage   image, VkImageLayout   imageLayout, const  VkClearDepthStencilValue *  pDepthStencil, uint32_t   rangeCount, const  VkImageSubresourceRange *  pRanges);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   srcBuffer, VkBuffer   dstBuffer, uint32_t   regionCount, const  VkBufferCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer   commandBuffer, VkBuffer   srcBuffer, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkBufferImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkBuffer   dstBuffer, uint32_t   regionCount, const  VkBufferImageCopy *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   stride, VkQueryResultFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatch)(VkCommandBuffer   commandBuffer, uint32_t   groupCountX, uint32_t   groupCountY, uint32_t   groupCountZ);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer   commandBuffer, uint32_t   baseGroupX, uint32_t   baseGroupY, uint32_t   baseGroupZ, uint32_t   groupCountX, uint32_t   groupCountY, uint32_t   groupCountZ);
-typedef void (GLAD_API_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset);
-typedef void (GLAD_API_PTR *PFN_vkCmdDraw)(VkCommandBuffer   commandBuffer, uint32_t   vertexCount, uint32_t   instanceCount, uint32_t   firstVertex, uint32_t   firstInstance);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer   commandBuffer, uint32_t   indexCount, uint32_t   instanceCount, uint32_t   firstIndex, int32_t   vertexOffset, uint32_t   firstInstance);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, uint32_t   drawCount, uint32_t   stride);
-typedef void (GLAD_API_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer   commandBuffer, VkBuffer   buffer, VkDeviceSize   offset, uint32_t   drawCount, uint32_t   stride);
-typedef void (GLAD_API_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   query);
-typedef void (GLAD_API_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer   commandBuffer);
-typedef void (GLAD_API_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer   commandBuffer, uint32_t   commandBufferCount, const  VkCommandBuffer *  pCommandBuffers);
-typedef void (GLAD_API_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   size, uint32_t   data);
-typedef void (GLAD_API_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer   commandBuffer, VkSubpassContents   contents);
-typedef void (GLAD_API_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer   commandBuffer, VkPipelineStageFlags   srcStageMask, VkPipelineStageFlags   dstStageMask, VkDependencyFlags   dependencyFlags, uint32_t   memoryBarrierCount, const  VkMemoryBarrier *  pMemoryBarriers, uint32_t   bufferMemoryBarrierCount, const  VkBufferMemoryBarrier *  pBufferMemoryBarriers, uint32_t   imageMemoryBarrierCount, const  VkImageMemoryBarrier *  pImageMemoryBarriers);
-typedef void (GLAD_API_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer   commandBuffer, VkPipelineLayout   layout, VkShaderStageFlags   stageFlags, uint32_t   offset, uint32_t   size, const  void *  pValues);
-typedef void (GLAD_API_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer   commandBuffer, VkEvent   event, VkPipelineStageFlags   stageMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer   commandBuffer, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount);
-typedef void (GLAD_API_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer   commandBuffer, VkImage   srcImage, VkImageLayout   srcImageLayout, VkImage   dstImage, VkImageLayout   dstImageLayout, uint32_t   regionCount, const  VkImageResolve *  pRegions);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer   commandBuffer, const  float   blendConstants [4]);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer   commandBuffer, float   depthBiasConstantFactor, float   depthBiasClamp, float   depthBiasSlopeFactor);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer   commandBuffer, float   minDepthBounds, float   maxDepthBounds);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer   commandBuffer, uint32_t   deviceMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer   commandBuffer, VkEvent   event, VkPipelineStageFlags   stageMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer   commandBuffer, float   lineWidth);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer   commandBuffer, uint32_t   firstScissor, uint32_t   scissorCount, const  VkRect2D *  pScissors);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   compareMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   reference);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer   commandBuffer, VkStencilFaceFlags   faceMask, uint32_t   writeMask);
-typedef void (GLAD_API_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer   commandBuffer, uint32_t   firstViewport, uint32_t   viewportCount, const  VkViewport *  pViewports);
-typedef void (GLAD_API_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer   commandBuffer, VkBuffer   dstBuffer, VkDeviceSize   dstOffset, VkDeviceSize   dataSize, const  void *  pData);
-typedef void (GLAD_API_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer   commandBuffer, uint32_t   eventCount, const  VkEvent *  pEvents, VkPipelineStageFlags   srcStageMask, VkPipelineStageFlags   dstStageMask, uint32_t   memoryBarrierCount, const  VkMemoryBarrier *  pMemoryBarriers, uint32_t   bufferMemoryBarrierCount, const  VkBufferMemoryBarrier *  pBufferMemoryBarriers, uint32_t   imageMemoryBarrierCount, const  VkImageMemoryBarrier *  pImageMemoryBarriers);
-typedef void (GLAD_API_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer   commandBuffer, VkPipelineStageFlagBits   pipelineStage, VkQueryPool   queryPool, uint32_t   query);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateBuffer)(VkDevice   device, const  VkBufferCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkBuffer *  pBuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateBufferView)(VkDevice   device, const  VkBufferViewCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkBufferView *  pView);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateCommandPool)(VkDevice   device, const  VkCommandPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkCommandPool *  pCommandPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateComputePipelines)(VkDevice   device, VkPipelineCache   pipelineCache, uint32_t   createInfoCount, const  VkComputePipelineCreateInfo *  pCreateInfos, const  VkAllocationCallbacks *  pAllocator, VkPipeline *  pPipelines);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance   instance, const  VkDebugReportCallbackCreateInfoEXT *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDebugReportCallbackEXT *  pCallback);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorPool)(VkDevice   device, const  VkDescriptorPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorPool *  pDescriptorPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice   device, const  VkDescriptorSetLayoutCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorSetLayout *  pSetLayout);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice   device, const  VkDescriptorUpdateTemplateCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDescriptorUpdateTemplate *  pDescriptorUpdateTemplate);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateDevice)(VkPhysicalDevice   physicalDevice, const  VkDeviceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkDevice *  pDevice);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateEvent)(VkDevice   device, const  VkEventCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkEvent *  pEvent);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateFence)(VkDevice   device, const  VkFenceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkFence *  pFence);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateFramebuffer)(VkDevice   device, const  VkFramebufferCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkFramebuffer *  pFramebuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice   device, VkPipelineCache   pipelineCache, uint32_t   createInfoCount, const  VkGraphicsPipelineCreateInfo *  pCreateInfos, const  VkAllocationCallbacks *  pAllocator, VkPipeline *  pPipelines);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateImage)(VkDevice   device, const  VkImageCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkImage *  pImage);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateImageView)(VkDevice   device, const  VkImageViewCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkImageView *  pView);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateInstance)(const  VkInstanceCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkInstance *  pInstance);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineCache)(VkDevice   device, const  VkPipelineCacheCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkPipelineCache *  pPipelineCache);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreatePipelineLayout)(VkDevice   device, const  VkPipelineLayoutCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkPipelineLayout *  pPipelineLayout);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateQueryPool)(VkDevice   device, const  VkQueryPoolCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkQueryPool *  pQueryPool);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateRenderPass)(VkDevice   device, const  VkRenderPassCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkRenderPass *  pRenderPass);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSampler)(VkDevice   device, const  VkSamplerCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSampler *  pSampler);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice   device, const  VkSamplerYcbcrConversionCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSamplerYcbcrConversion *  pYcbcrConversion);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSemaphore)(VkDevice   device, const  VkSemaphoreCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSemaphore *  pSemaphore);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateShaderModule)(VkDevice   device, const  VkShaderModuleCreateInfo *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkShaderModule *  pShaderModule);
-typedef VkResult (GLAD_API_PTR *PFN_vkCreateSwapchainKHR)(VkDevice   device, const  VkSwapchainCreateInfoKHR *  pCreateInfo, const  VkAllocationCallbacks *  pAllocator, VkSwapchainKHR *  pSwapchain);
-typedef void (GLAD_API_PTR *PFN_vkDebugReportMessageEXT)(VkInstance   instance, VkDebugReportFlagsEXT   flags, VkDebugReportObjectTypeEXT   objectType, uint64_t   object, size_t   location, int32_t   messageCode, const  char *  pLayerPrefix, const  char *  pMessage);
-typedef void (GLAD_API_PTR *PFN_vkDestroyBuffer)(VkDevice   device, VkBuffer   buffer, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyBufferView)(VkDevice   device, VkBufferView   bufferView, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyCommandPool)(VkDevice   device, VkCommandPool   commandPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance   instance, VkDebugReportCallbackEXT   callback, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorPool)(VkDevice   device, VkDescriptorPool   descriptorPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice   device, VkDescriptorSetLayout   descriptorSetLayout, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice   device, VkDescriptorUpdateTemplate   descriptorUpdateTemplate, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyDevice)(VkDevice   device, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyEvent)(VkDevice   device, VkEvent   event, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyFence)(VkDevice   device, VkFence   fence, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyFramebuffer)(VkDevice   device, VkFramebuffer   framebuffer, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyImage)(VkDevice   device, VkImage   image, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyImageView)(VkDevice   device, VkImageView   imageView, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyInstance)(VkInstance   instance, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipeline)(VkDevice   device, VkPipeline   pipeline, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineCache)(VkDevice   device, VkPipelineCache   pipelineCache, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyPipelineLayout)(VkDevice   device, VkPipelineLayout   pipelineLayout, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyQueryPool)(VkDevice   device, VkQueryPool   queryPool, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyRenderPass)(VkDevice   device, VkRenderPass   renderPass, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySampler)(VkDevice   device, VkSampler   sampler, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice   device, VkSamplerYcbcrConversion   ycbcrConversion, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySemaphore)(VkDevice   device, VkSemaphore   semaphore, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroyShaderModule)(VkDevice   device, VkShaderModule   shaderModule, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySurfaceKHR)(VkInstance   instance, VkSurfaceKHR   surface, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkDestroySwapchainKHR)(VkDevice   device, VkSwapchainKHR   swapchain, const  VkAllocationCallbacks *  pAllocator);
-typedef VkResult (GLAD_API_PTR *PFN_vkDeviceWaitIdle)(VkDevice   device);
-typedef VkResult (GLAD_API_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer   commandBuffer);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice   physicalDevice, const  char *  pLayerName, uint32_t *  pPropertyCount, VkExtensionProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice   physicalDevice, uint32_t *  pPropertyCount, VkLayerProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const  char *  pLayerName, uint32_t *  pPropertyCount, VkExtensionProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t *  pPropertyCount, VkLayerProperties *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t *  pApiVersion);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance   instance, uint32_t *  pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *  pPhysicalDeviceGroupProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance   instance, uint32_t *  pPhysicalDeviceCount, VkPhysicalDevice *  pPhysicalDevices);
-typedef VkResult (GLAD_API_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice   device, uint32_t   memoryRangeCount, const  VkMappedMemoryRange *  pMemoryRanges);
-typedef void (GLAD_API_PTR *PFN_vkFreeCommandBuffers)(VkDevice   device, VkCommandPool   commandPool, uint32_t   commandBufferCount, const  VkCommandBuffer *  pCommandBuffers);
-typedef VkResult (GLAD_API_PTR *PFN_vkFreeDescriptorSets)(VkDevice   device, VkDescriptorPool   descriptorPool, uint32_t   descriptorSetCount, const  VkDescriptorSet *  pDescriptorSets);
-typedef void (GLAD_API_PTR *PFN_vkFreeMemory)(VkDevice   device, VkDeviceMemory   memory, const  VkAllocationCallbacks *  pAllocator);
-typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice   device, VkBuffer   buffer, VkMemoryRequirements *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice   device, const  VkBufferMemoryRequirementsInfo2 *  pInfo, VkMemoryRequirements2 *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice   device, const  VkDescriptorSetLayoutCreateInfo *  pCreateInfo, VkDescriptorSetLayoutSupport *  pSupport);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice   device, uint32_t   heapIndex, uint32_t   localDeviceIndex, uint32_t   remoteDeviceIndex, VkPeerMemoryFeatureFlags *  pPeerMemoryFeatures);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice   device, VkDeviceGroupPresentCapabilitiesKHR *  pDeviceGroupPresentCapabilities);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice   device, VkSurfaceKHR   surface, VkDeviceGroupPresentModeFlagsKHR *  pModes);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice   device, VkDeviceMemory   memory, VkDeviceSize *  pCommittedMemoryInBytes);
-typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetDeviceProcAddr)(VkDevice   device, const  char *  pName);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue)(VkDevice   device, uint32_t   queueFamilyIndex, uint32_t   queueIndex, VkQueue *  pQueue);
-typedef void (GLAD_API_PTR *PFN_vkGetDeviceQueue2)(VkDevice   device, const  VkDeviceQueueInfo2 *  pQueueInfo, VkQueue *  pQueue);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetEventStatus)(VkDevice   device, VkEvent   event);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetFenceStatus)(VkDevice   device, VkFence   fence);
-typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice   device, VkImage   image, VkMemoryRequirements *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice   device, const  VkImageMemoryRequirementsInfo2 *  pInfo, VkMemoryRequirements2 *  pMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice   device, VkImage   image, uint32_t *  pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *  pSparseMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice   device, const  VkImageSparseMemoryRequirementsInfo2 *  pInfo, uint32_t *  pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 *  pSparseMemoryRequirements);
-typedef void (GLAD_API_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice   device, VkImage   image, const  VkImageSubresource *  pSubresource, VkSubresourceLayout *  pLayout);
-typedef PFN_vkVoidFunction (GLAD_API_PTR *PFN_vkGetInstanceProcAddr)(VkInstance   instance, const  char *  pName);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalBufferInfo *  pExternalBufferInfo, VkExternalBufferProperties *  pExternalBufferProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalFenceInfo *  pExternalFenceInfo, VkExternalFenceProperties *  pExternalFenceProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceExternalSemaphoreInfo *  pExternalSemaphoreInfo, VkExternalSemaphoreProperties *  pExternalSemaphoreProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceFeatures *  pFeatures);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceFeatures2 *  pFeatures);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkFormatProperties *  pFormatProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkFormatProperties2 *  pFormatProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkImageType   type, VkImageTiling   tiling, VkImageUsageFlags   usage, VkImageCreateFlags   flags, VkImageFormatProperties *  pImageFormatProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceImageFormatInfo2 *  pImageFormatInfo, VkImageFormatProperties2 *  pImageFormatProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceMemoryProperties *  pMemoryProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceMemoryProperties2 *  pMemoryProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pRectCount, VkRect2D *  pRects);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceProperties *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice   physicalDevice, VkPhysicalDeviceProperties2 *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice   physicalDevice, uint32_t *  pQueueFamilyPropertyCount, VkQueueFamilyProperties *  pQueueFamilyProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice   physicalDevice, uint32_t *  pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *  pQueueFamilyProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice   physicalDevice, VkFormat   format, VkImageType   type, VkSampleCountFlagBits   samples, VkImageUsageFlags   usage, VkImageTiling   tiling, uint32_t *  pPropertyCount, VkSparseImageFormatProperties *  pProperties);
-typedef void (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice   physicalDevice, const  VkPhysicalDeviceSparseImageFormatInfo2 *  pFormatInfo, uint32_t *  pPropertyCount, VkSparseImageFormatProperties2 *  pProperties);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, VkSurfaceCapabilitiesKHR *  pSurfaceCapabilities);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pSurfaceFormatCount, VkSurfaceFormatKHR *  pSurfaceFormats);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice   physicalDevice, VkSurfaceKHR   surface, uint32_t *  pPresentModeCount, VkPresentModeKHR *  pPresentModes);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice   physicalDevice, uint32_t   queueFamilyIndex, VkSurfaceKHR   surface, VkBool32 *  pSupported);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetPipelineCacheData)(VkDevice   device, VkPipelineCache   pipelineCache, size_t *  pDataSize, void *  pData);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetQueryPoolResults)(VkDevice   device, VkQueryPool   queryPool, uint32_t   firstQuery, uint32_t   queryCount, size_t   dataSize, void *  pData, VkDeviceSize   stride, VkQueryResultFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice   device, VkRenderPass   renderPass, VkExtent2D *  pGranularity);
-typedef VkResult (GLAD_API_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice   device, VkSwapchainKHR   swapchain, uint32_t *  pSwapchainImageCount, VkImage *  pSwapchainImages);
-typedef VkResult (GLAD_API_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice   device, uint32_t   memoryRangeCount, const  VkMappedMemoryRange *  pMemoryRanges);
-typedef VkResult (GLAD_API_PTR *PFN_vkMapMemory)(VkDevice   device, VkDeviceMemory   memory, VkDeviceSize   offset, VkDeviceSize   size, VkMemoryMapFlags   flags, void **  ppData);
-typedef VkResult (GLAD_API_PTR *PFN_vkMergePipelineCaches)(VkDevice   device, VkPipelineCache   dstCache, uint32_t   srcCacheCount, const  VkPipelineCache *  pSrcCaches);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueBindSparse)(VkQueue   queue, uint32_t   bindInfoCount, const  VkBindSparseInfo *  pBindInfo, VkFence   fence);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueuePresentKHR)(VkQueue   queue, const  VkPresentInfoKHR *  pPresentInfo);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueSubmit)(VkQueue   queue, uint32_t   submitCount, const  VkSubmitInfo *  pSubmits, VkFence   fence);
-typedef VkResult (GLAD_API_PTR *PFN_vkQueueWaitIdle)(VkQueue   queue);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer   commandBuffer, VkCommandBufferResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetCommandPool)(VkDevice   device, VkCommandPool   commandPool, VkCommandPoolResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetDescriptorPool)(VkDevice   device, VkDescriptorPool   descriptorPool, VkDescriptorPoolResetFlags   flags);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetEvent)(VkDevice   device, VkEvent   event);
-typedef VkResult (GLAD_API_PTR *PFN_vkResetFences)(VkDevice   device, uint32_t   fenceCount, const  VkFence *  pFences);
-typedef VkResult (GLAD_API_PTR *PFN_vkSetEvent)(VkDevice   device, VkEvent   event);
-typedef void (GLAD_API_PTR *PFN_vkTrimCommandPool)(VkDevice   device, VkCommandPool   commandPool, VkCommandPoolTrimFlags   flags);
-typedef void (GLAD_API_PTR *PFN_vkUnmapMemory)(VkDevice   device, VkDeviceMemory   memory);
-typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice   device, VkDescriptorSet   descriptorSet, VkDescriptorUpdateTemplate   descriptorUpdateTemplate, const  void *  pData);
-typedef void (GLAD_API_PTR *PFN_vkUpdateDescriptorSets)(VkDevice   device, uint32_t   descriptorWriteCount, const  VkWriteDescriptorSet *  pDescriptorWrites, uint32_t   descriptorCopyCount, const  VkCopyDescriptorSet *  pDescriptorCopies);
-typedef VkResult (GLAD_API_PTR *PFN_vkWaitForFences)(VkDevice   device, uint32_t   fenceCount, const  VkFence *  pFences, VkBool32   waitAll, uint64_t   timeout);
-
-GLAD_API_CALL PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR;
-#define vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR
-GLAD_API_CALL PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR;
-#define vkAcquireNextImageKHR glad_vkAcquireNextImageKHR
-GLAD_API_CALL PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers;
-#define vkAllocateCommandBuffers glad_vkAllocateCommandBuffers
-GLAD_API_CALL PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets;
-#define vkAllocateDescriptorSets glad_vkAllocateDescriptorSets
-GLAD_API_CALL PFN_vkAllocateMemory glad_vkAllocateMemory;
-#define vkAllocateMemory glad_vkAllocateMemory
-GLAD_API_CALL PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer;
-#define vkBeginCommandBuffer glad_vkBeginCommandBuffer
-GLAD_API_CALL PFN_vkBindBufferMemory glad_vkBindBufferMemory;
-#define vkBindBufferMemory glad_vkBindBufferMemory
-GLAD_API_CALL PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2;
-#define vkBindBufferMemory2 glad_vkBindBufferMemory2
-GLAD_API_CALL PFN_vkBindImageMemory glad_vkBindImageMemory;
-#define vkBindImageMemory glad_vkBindImageMemory
-GLAD_API_CALL PFN_vkBindImageMemory2 glad_vkBindImageMemory2;
-#define vkBindImageMemory2 glad_vkBindImageMemory2
-GLAD_API_CALL PFN_vkCmdBeginQuery glad_vkCmdBeginQuery;
-#define vkCmdBeginQuery glad_vkCmdBeginQuery
-GLAD_API_CALL PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass;
-#define vkCmdBeginRenderPass glad_vkCmdBeginRenderPass
-GLAD_API_CALL PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets;
-#define vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets
-GLAD_API_CALL PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer;
-#define vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer
-GLAD_API_CALL PFN_vkCmdBindPipeline glad_vkCmdBindPipeline;
-#define vkCmdBindPipeline glad_vkCmdBindPipeline
-GLAD_API_CALL PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers;
-#define vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers
-GLAD_API_CALL PFN_vkCmdBlitImage glad_vkCmdBlitImage;
-#define vkCmdBlitImage glad_vkCmdBlitImage
-GLAD_API_CALL PFN_vkCmdClearAttachments glad_vkCmdClearAttachments;
-#define vkCmdClearAttachments glad_vkCmdClearAttachments
-GLAD_API_CALL PFN_vkCmdClearColorImage glad_vkCmdClearColorImage;
-#define vkCmdClearColorImage glad_vkCmdClearColorImage
-GLAD_API_CALL PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage;
-#define vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage
-GLAD_API_CALL PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer;
-#define vkCmdCopyBuffer glad_vkCmdCopyBuffer
-GLAD_API_CALL PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage;
-#define vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage
-GLAD_API_CALL PFN_vkCmdCopyImage glad_vkCmdCopyImage;
-#define vkCmdCopyImage glad_vkCmdCopyImage
-GLAD_API_CALL PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer;
-#define vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer
-GLAD_API_CALL PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults;
-#define vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults
-GLAD_API_CALL PFN_vkCmdDispatch glad_vkCmdDispatch;
-#define vkCmdDispatch glad_vkCmdDispatch
-GLAD_API_CALL PFN_vkCmdDispatchBase glad_vkCmdDispatchBase;
-#define vkCmdDispatchBase glad_vkCmdDispatchBase
-GLAD_API_CALL PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect;
-#define vkCmdDispatchIndirect glad_vkCmdDispatchIndirect
-GLAD_API_CALL PFN_vkCmdDraw glad_vkCmdDraw;
-#define vkCmdDraw glad_vkCmdDraw
-GLAD_API_CALL PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed;
-#define vkCmdDrawIndexed glad_vkCmdDrawIndexed
-GLAD_API_CALL PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect;
-#define vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect
-GLAD_API_CALL PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect;
-#define vkCmdDrawIndirect glad_vkCmdDrawIndirect
-GLAD_API_CALL PFN_vkCmdEndQuery glad_vkCmdEndQuery;
-#define vkCmdEndQuery glad_vkCmdEndQuery
-GLAD_API_CALL PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass;
-#define vkCmdEndRenderPass glad_vkCmdEndRenderPass
-GLAD_API_CALL PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands;
-#define vkCmdExecuteCommands glad_vkCmdExecuteCommands
-GLAD_API_CALL PFN_vkCmdFillBuffer glad_vkCmdFillBuffer;
-#define vkCmdFillBuffer glad_vkCmdFillBuffer
-GLAD_API_CALL PFN_vkCmdNextSubpass glad_vkCmdNextSubpass;
-#define vkCmdNextSubpass glad_vkCmdNextSubpass
-GLAD_API_CALL PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier;
-#define vkCmdPipelineBarrier glad_vkCmdPipelineBarrier
-GLAD_API_CALL PFN_vkCmdPushConstants glad_vkCmdPushConstants;
-#define vkCmdPushConstants glad_vkCmdPushConstants
-GLAD_API_CALL PFN_vkCmdResetEvent glad_vkCmdResetEvent;
-#define vkCmdResetEvent glad_vkCmdResetEvent
-GLAD_API_CALL PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool;
-#define vkCmdResetQueryPool glad_vkCmdResetQueryPool
-GLAD_API_CALL PFN_vkCmdResolveImage glad_vkCmdResolveImage;
-#define vkCmdResolveImage glad_vkCmdResolveImage
-GLAD_API_CALL PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants;
-#define vkCmdSetBlendConstants glad_vkCmdSetBlendConstants
-GLAD_API_CALL PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias;
-#define vkCmdSetDepthBias glad_vkCmdSetDepthBias
-GLAD_API_CALL PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds;
-#define vkCmdSetDepthBounds glad_vkCmdSetDepthBounds
-GLAD_API_CALL PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask;
-#define vkCmdSetDeviceMask glad_vkCmdSetDeviceMask
-GLAD_API_CALL PFN_vkCmdSetEvent glad_vkCmdSetEvent;
-#define vkCmdSetEvent glad_vkCmdSetEvent
-GLAD_API_CALL PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth;
-#define vkCmdSetLineWidth glad_vkCmdSetLineWidth
-GLAD_API_CALL PFN_vkCmdSetScissor glad_vkCmdSetScissor;
-#define vkCmdSetScissor glad_vkCmdSetScissor
-GLAD_API_CALL PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask;
-#define vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask
-GLAD_API_CALL PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference;
-#define vkCmdSetStencilReference glad_vkCmdSetStencilReference
-GLAD_API_CALL PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask;
-#define vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask
-GLAD_API_CALL PFN_vkCmdSetViewport glad_vkCmdSetViewport;
-#define vkCmdSetViewport glad_vkCmdSetViewport
-GLAD_API_CALL PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer;
-#define vkCmdUpdateBuffer glad_vkCmdUpdateBuffer
-GLAD_API_CALL PFN_vkCmdWaitEvents glad_vkCmdWaitEvents;
-#define vkCmdWaitEvents glad_vkCmdWaitEvents
-GLAD_API_CALL PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp;
-#define vkCmdWriteTimestamp glad_vkCmdWriteTimestamp
-GLAD_API_CALL PFN_vkCreateBuffer glad_vkCreateBuffer;
-#define vkCreateBuffer glad_vkCreateBuffer
-GLAD_API_CALL PFN_vkCreateBufferView glad_vkCreateBufferView;
-#define vkCreateBufferView glad_vkCreateBufferView
-GLAD_API_CALL PFN_vkCreateCommandPool glad_vkCreateCommandPool;
-#define vkCreateCommandPool glad_vkCreateCommandPool
-GLAD_API_CALL PFN_vkCreateComputePipelines glad_vkCreateComputePipelines;
-#define vkCreateComputePipelines glad_vkCreateComputePipelines
-GLAD_API_CALL PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT;
-#define vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT
-GLAD_API_CALL PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool;
-#define vkCreateDescriptorPool glad_vkCreateDescriptorPool
-GLAD_API_CALL PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout;
-#define vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout
-GLAD_API_CALL PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate;
-#define vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate
-GLAD_API_CALL PFN_vkCreateDevice glad_vkCreateDevice;
-#define vkCreateDevice glad_vkCreateDevice
-GLAD_API_CALL PFN_vkCreateEvent glad_vkCreateEvent;
-#define vkCreateEvent glad_vkCreateEvent
-GLAD_API_CALL PFN_vkCreateFence glad_vkCreateFence;
-#define vkCreateFence glad_vkCreateFence
-GLAD_API_CALL PFN_vkCreateFramebuffer glad_vkCreateFramebuffer;
-#define vkCreateFramebuffer glad_vkCreateFramebuffer
-GLAD_API_CALL PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines;
-#define vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines
-GLAD_API_CALL PFN_vkCreateImage glad_vkCreateImage;
-#define vkCreateImage glad_vkCreateImage
-GLAD_API_CALL PFN_vkCreateImageView glad_vkCreateImageView;
-#define vkCreateImageView glad_vkCreateImageView
-GLAD_API_CALL PFN_vkCreateInstance glad_vkCreateInstance;
-#define vkCreateInstance glad_vkCreateInstance
-GLAD_API_CALL PFN_vkCreatePipelineCache glad_vkCreatePipelineCache;
-#define vkCreatePipelineCache glad_vkCreatePipelineCache
-GLAD_API_CALL PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout;
-#define vkCreatePipelineLayout glad_vkCreatePipelineLayout
-GLAD_API_CALL PFN_vkCreateQueryPool glad_vkCreateQueryPool;
-#define vkCreateQueryPool glad_vkCreateQueryPool
-GLAD_API_CALL PFN_vkCreateRenderPass glad_vkCreateRenderPass;
-#define vkCreateRenderPass glad_vkCreateRenderPass
-GLAD_API_CALL PFN_vkCreateSampler glad_vkCreateSampler;
-#define vkCreateSampler glad_vkCreateSampler
-GLAD_API_CALL PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion;
-#define vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion
-GLAD_API_CALL PFN_vkCreateSemaphore glad_vkCreateSemaphore;
-#define vkCreateSemaphore glad_vkCreateSemaphore
-GLAD_API_CALL PFN_vkCreateShaderModule glad_vkCreateShaderModule;
-#define vkCreateShaderModule glad_vkCreateShaderModule
-GLAD_API_CALL PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR;
-#define vkCreateSwapchainKHR glad_vkCreateSwapchainKHR
-GLAD_API_CALL PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT;
-#define vkDebugReportMessageEXT glad_vkDebugReportMessageEXT
-GLAD_API_CALL PFN_vkDestroyBuffer glad_vkDestroyBuffer;
-#define vkDestroyBuffer glad_vkDestroyBuffer
-GLAD_API_CALL PFN_vkDestroyBufferView glad_vkDestroyBufferView;
-#define vkDestroyBufferView glad_vkDestroyBufferView
-GLAD_API_CALL PFN_vkDestroyCommandPool glad_vkDestroyCommandPool;
-#define vkDestroyCommandPool glad_vkDestroyCommandPool
-GLAD_API_CALL PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT;
-#define vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT
-GLAD_API_CALL PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool;
-#define vkDestroyDescriptorPool glad_vkDestroyDescriptorPool
-GLAD_API_CALL PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout;
-#define vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout
-GLAD_API_CALL PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate;
-#define vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate
-GLAD_API_CALL PFN_vkDestroyDevice glad_vkDestroyDevice;
-#define vkDestroyDevice glad_vkDestroyDevice
-GLAD_API_CALL PFN_vkDestroyEvent glad_vkDestroyEvent;
-#define vkDestroyEvent glad_vkDestroyEvent
-GLAD_API_CALL PFN_vkDestroyFence glad_vkDestroyFence;
-#define vkDestroyFence glad_vkDestroyFence
-GLAD_API_CALL PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer;
-#define vkDestroyFramebuffer glad_vkDestroyFramebuffer
-GLAD_API_CALL PFN_vkDestroyImage glad_vkDestroyImage;
-#define vkDestroyImage glad_vkDestroyImage
-GLAD_API_CALL PFN_vkDestroyImageView glad_vkDestroyImageView;
-#define vkDestroyImageView glad_vkDestroyImageView
-GLAD_API_CALL PFN_vkDestroyInstance glad_vkDestroyInstance;
-#define vkDestroyInstance glad_vkDestroyInstance
-GLAD_API_CALL PFN_vkDestroyPipeline glad_vkDestroyPipeline;
-#define vkDestroyPipeline glad_vkDestroyPipeline
-GLAD_API_CALL PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache;
-#define vkDestroyPipelineCache glad_vkDestroyPipelineCache
-GLAD_API_CALL PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout;
-#define vkDestroyPipelineLayout glad_vkDestroyPipelineLayout
-GLAD_API_CALL PFN_vkDestroyQueryPool glad_vkDestroyQueryPool;
-#define vkDestroyQueryPool glad_vkDestroyQueryPool
-GLAD_API_CALL PFN_vkDestroyRenderPass glad_vkDestroyRenderPass;
-#define vkDestroyRenderPass glad_vkDestroyRenderPass
-GLAD_API_CALL PFN_vkDestroySampler glad_vkDestroySampler;
-#define vkDestroySampler glad_vkDestroySampler
-GLAD_API_CALL PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion;
-#define vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion
-GLAD_API_CALL PFN_vkDestroySemaphore glad_vkDestroySemaphore;
-#define vkDestroySemaphore glad_vkDestroySemaphore
-GLAD_API_CALL PFN_vkDestroyShaderModule glad_vkDestroyShaderModule;
-#define vkDestroyShaderModule glad_vkDestroyShaderModule
-GLAD_API_CALL PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR;
-#define vkDestroySurfaceKHR glad_vkDestroySurfaceKHR
-GLAD_API_CALL PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR;
-#define vkDestroySwapchainKHR glad_vkDestroySwapchainKHR
-GLAD_API_CALL PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle;
-#define vkDeviceWaitIdle glad_vkDeviceWaitIdle
-GLAD_API_CALL PFN_vkEndCommandBuffer glad_vkEndCommandBuffer;
-#define vkEndCommandBuffer glad_vkEndCommandBuffer
-GLAD_API_CALL PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties;
-#define vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties
-GLAD_API_CALL PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties;
-#define vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties;
-#define vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties;
-#define vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties
-GLAD_API_CALL PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion;
-#define vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion
-GLAD_API_CALL PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups;
-#define vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups
-GLAD_API_CALL PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices;
-#define vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices
-GLAD_API_CALL PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges;
-#define vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges
-GLAD_API_CALL PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers;
-#define vkFreeCommandBuffers glad_vkFreeCommandBuffers
-GLAD_API_CALL PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets;
-#define vkFreeDescriptorSets glad_vkFreeDescriptorSets
-GLAD_API_CALL PFN_vkFreeMemory glad_vkFreeMemory;
-#define vkFreeMemory glad_vkFreeMemory
-GLAD_API_CALL PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements;
-#define vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements
-GLAD_API_CALL PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2;
-#define vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2
-GLAD_API_CALL PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport;
-#define vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport
-GLAD_API_CALL PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures;
-#define vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures
-GLAD_API_CALL PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR;
-#define vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR
-GLAD_API_CALL PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR;
-#define vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR
-GLAD_API_CALL PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment;
-#define vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment
-GLAD_API_CALL PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr;
-#define vkGetDeviceProcAddr glad_vkGetDeviceProcAddr
-GLAD_API_CALL PFN_vkGetDeviceQueue glad_vkGetDeviceQueue;
-#define vkGetDeviceQueue glad_vkGetDeviceQueue
-GLAD_API_CALL PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2;
-#define vkGetDeviceQueue2 glad_vkGetDeviceQueue2
-GLAD_API_CALL PFN_vkGetEventStatus glad_vkGetEventStatus;
-#define vkGetEventStatus glad_vkGetEventStatus
-GLAD_API_CALL PFN_vkGetFenceStatus glad_vkGetFenceStatus;
-#define vkGetFenceStatus glad_vkGetFenceStatus
-GLAD_API_CALL PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements;
-#define vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements
-GLAD_API_CALL PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2;
-#define vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2
-GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements;
-#define vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements
-GLAD_API_CALL PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2;
-#define vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2
-GLAD_API_CALL PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout;
-#define vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout
-GLAD_API_CALL PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr;
-#define vkGetInstanceProcAddr glad_vkGetInstanceProcAddr
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties;
-#define vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties;
-#define vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties;
-#define vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures;
-#define vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2;
-#define vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties;
-#define vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2;
-#define vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties;
-#define vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2;
-#define vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties;
-#define vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2;
-#define vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR;
-#define vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties;
-#define vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2;
-#define vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties;
-#define vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2;
-#define vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties;
-#define vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2;
-#define vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR;
-#define vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR;
-#define vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR;
-#define vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR
-GLAD_API_CALL PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR;
-#define vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR
-GLAD_API_CALL PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData;
-#define vkGetPipelineCacheData glad_vkGetPipelineCacheData
-GLAD_API_CALL PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults;
-#define vkGetQueryPoolResults glad_vkGetQueryPoolResults
-GLAD_API_CALL PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity;
-#define vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity
-GLAD_API_CALL PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR;
-#define vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR
-GLAD_API_CALL PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges;
-#define vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges
-GLAD_API_CALL PFN_vkMapMemory glad_vkMapMemory;
-#define vkMapMemory glad_vkMapMemory
-GLAD_API_CALL PFN_vkMergePipelineCaches glad_vkMergePipelineCaches;
-#define vkMergePipelineCaches glad_vkMergePipelineCaches
-GLAD_API_CALL PFN_vkQueueBindSparse glad_vkQueueBindSparse;
-#define vkQueueBindSparse glad_vkQueueBindSparse
-GLAD_API_CALL PFN_vkQueuePresentKHR glad_vkQueuePresentKHR;
-#define vkQueuePresentKHR glad_vkQueuePresentKHR
-GLAD_API_CALL PFN_vkQueueSubmit glad_vkQueueSubmit;
-#define vkQueueSubmit glad_vkQueueSubmit
-GLAD_API_CALL PFN_vkQueueWaitIdle glad_vkQueueWaitIdle;
-#define vkQueueWaitIdle glad_vkQueueWaitIdle
-GLAD_API_CALL PFN_vkResetCommandBuffer glad_vkResetCommandBuffer;
-#define vkResetCommandBuffer glad_vkResetCommandBuffer
-GLAD_API_CALL PFN_vkResetCommandPool glad_vkResetCommandPool;
-#define vkResetCommandPool glad_vkResetCommandPool
-GLAD_API_CALL PFN_vkResetDescriptorPool glad_vkResetDescriptorPool;
-#define vkResetDescriptorPool glad_vkResetDescriptorPool
-GLAD_API_CALL PFN_vkResetEvent glad_vkResetEvent;
-#define vkResetEvent glad_vkResetEvent
-GLAD_API_CALL PFN_vkResetFences glad_vkResetFences;
-#define vkResetFences glad_vkResetFences
-GLAD_API_CALL PFN_vkSetEvent glad_vkSetEvent;
-#define vkSetEvent glad_vkSetEvent
-GLAD_API_CALL PFN_vkTrimCommandPool glad_vkTrimCommandPool;
-#define vkTrimCommandPool glad_vkTrimCommandPool
-GLAD_API_CALL PFN_vkUnmapMemory glad_vkUnmapMemory;
-#define vkUnmapMemory glad_vkUnmapMemory
-GLAD_API_CALL PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate;
-#define vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate
-GLAD_API_CALL PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets;
-#define vkUpdateDescriptorSets glad_vkUpdateDescriptorSets
-GLAD_API_CALL PFN_vkWaitForFences glad_vkWaitForFences;
-#define vkWaitForFences glad_vkWaitForFences
-
-
-GLAD_API_CALL int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr);
-GLAD_API_CALL int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load);
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/raylib_pi4_test/external/glfw/deps/glad_gl.c b/raylib_pi4_test/external/glfw/deps/glad_gl.c
deleted file mode 100644 (file)
index 2d4c87f..0000000
+++ /dev/null
@@ -1,1791 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glad/gl.h>
-
-#ifndef GLAD_IMPL_UTIL_C_
-#define GLAD_IMPL_UTIL_C_
-
-#ifdef _MSC_VER
-#define GLAD_IMPL_UTIL_SSCANF sscanf_s
-#else
-#define GLAD_IMPL_UTIL_SSCANF sscanf
-#endif
-
-#endif /* GLAD_IMPL_UTIL_C_ */
-
-
-int GLAD_GL_VERSION_1_0 = 0;
-int GLAD_GL_VERSION_1_1 = 0;
-int GLAD_GL_VERSION_1_2 = 0;
-int GLAD_GL_VERSION_1_3 = 0;
-int GLAD_GL_VERSION_1_4 = 0;
-int GLAD_GL_VERSION_1_5 = 0;
-int GLAD_GL_VERSION_2_0 = 0;
-int GLAD_GL_VERSION_2_1 = 0;
-int GLAD_GL_VERSION_3_0 = 0;
-int GLAD_GL_VERSION_3_1 = 0;
-int GLAD_GL_VERSION_3_2 = 0;
-int GLAD_GL_VERSION_3_3 = 0;
-int GLAD_GL_ARB_multisample = 0;
-int GLAD_GL_ARB_robustness = 0;
-int GLAD_GL_KHR_debug = 0;
-
-
-
-PFNGLACCUMPROC glad_glAccum = NULL;
-PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
-PFNGLALPHAFUNCPROC glad_glAlphaFunc = NULL;
-PFNGLARETEXTURESRESIDENTPROC glad_glAreTexturesResident = NULL;
-PFNGLARRAYELEMENTPROC glad_glArrayElement = NULL;
-PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
-PFNGLBEGINPROC glad_glBegin = NULL;
-PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
-PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
-PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
-PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
-PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
-PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
-PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
-PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
-PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
-PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
-PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
-PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
-PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
-PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
-PFNGLBITMAPPROC glad_glBitmap = NULL;
-PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
-PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
-PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
-PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
-PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
-PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
-PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
-PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
-PFNGLCALLLISTPROC glad_glCallList = NULL;
-PFNGLCALLLISTSPROC glad_glCallLists = NULL;
-PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
-PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
-PFNGLCLEARPROC glad_glClear = NULL;
-PFNGLCLEARACCUMPROC glad_glClearAccum = NULL;
-PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
-PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
-PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
-PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
-PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
-PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
-PFNGLCLEARINDEXPROC glad_glClearIndex = NULL;
-PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
-PFNGLCLIENTACTIVETEXTUREPROC glad_glClientActiveTexture = NULL;
-PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
-PFNGLCLIPPLANEPROC glad_glClipPlane = NULL;
-PFNGLCOLOR3BPROC glad_glColor3b = NULL;
-PFNGLCOLOR3BVPROC glad_glColor3bv = NULL;
-PFNGLCOLOR3DPROC glad_glColor3d = NULL;
-PFNGLCOLOR3DVPROC glad_glColor3dv = NULL;
-PFNGLCOLOR3FPROC glad_glColor3f = NULL;
-PFNGLCOLOR3FVPROC glad_glColor3fv = NULL;
-PFNGLCOLOR3IPROC glad_glColor3i = NULL;
-PFNGLCOLOR3IVPROC glad_glColor3iv = NULL;
-PFNGLCOLOR3SPROC glad_glColor3s = NULL;
-PFNGLCOLOR3SVPROC glad_glColor3sv = NULL;
-PFNGLCOLOR3UBPROC glad_glColor3ub = NULL;
-PFNGLCOLOR3UBVPROC glad_glColor3ubv = NULL;
-PFNGLCOLOR3UIPROC glad_glColor3ui = NULL;
-PFNGLCOLOR3UIVPROC glad_glColor3uiv = NULL;
-PFNGLCOLOR3USPROC glad_glColor3us = NULL;
-PFNGLCOLOR3USVPROC glad_glColor3usv = NULL;
-PFNGLCOLOR4BPROC glad_glColor4b = NULL;
-PFNGLCOLOR4BVPROC glad_glColor4bv = NULL;
-PFNGLCOLOR4DPROC glad_glColor4d = NULL;
-PFNGLCOLOR4DVPROC glad_glColor4dv = NULL;
-PFNGLCOLOR4FPROC glad_glColor4f = NULL;
-PFNGLCOLOR4FVPROC glad_glColor4fv = NULL;
-PFNGLCOLOR4IPROC glad_glColor4i = NULL;
-PFNGLCOLOR4IVPROC glad_glColor4iv = NULL;
-PFNGLCOLOR4SPROC glad_glColor4s = NULL;
-PFNGLCOLOR4SVPROC glad_glColor4sv = NULL;
-PFNGLCOLOR4UBPROC glad_glColor4ub = NULL;
-PFNGLCOLOR4UBVPROC glad_glColor4ubv = NULL;
-PFNGLCOLOR4UIPROC glad_glColor4ui = NULL;
-PFNGLCOLOR4UIVPROC glad_glColor4uiv = NULL;
-PFNGLCOLOR4USPROC glad_glColor4us = NULL;
-PFNGLCOLOR4USVPROC glad_glColor4usv = NULL;
-PFNGLCOLORMASKPROC glad_glColorMask = NULL;
-PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
-PFNGLCOLORMATERIALPROC glad_glColorMaterial = NULL;
-PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL;
-PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL;
-PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL;
-PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL;
-PFNGLCOLORPOINTERPROC glad_glColorPointer = NULL;
-PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
-PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
-PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
-PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
-PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
-PFNGLCOPYPIXELSPROC glad_glCopyPixels = NULL;
-PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
-PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
-PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
-PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
-PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
-PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
-PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
-PFNGLCULLFACEPROC glad_glCullFace = NULL;
-PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL;
-PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL;
-PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL;
-PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
-PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
-PFNGLDELETELISTSPROC glad_glDeleteLists = NULL;
-PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
-PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
-PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
-PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
-PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
-PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
-PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
-PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
-PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
-PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
-PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
-PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
-PFNGLDISABLEPROC glad_glDisable = NULL;
-PFNGLDISABLECLIENTSTATEPROC glad_glDisableClientState = NULL;
-PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
-PFNGLDISABLEIPROC glad_glDisablei = NULL;
-PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
-PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
-PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
-PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
-PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
-PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
-PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
-PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
-PFNGLDRAWPIXELSPROC glad_glDrawPixels = NULL;
-PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
-PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
-PFNGLEDGEFLAGPROC glad_glEdgeFlag = NULL;
-PFNGLEDGEFLAGPOINTERPROC glad_glEdgeFlagPointer = NULL;
-PFNGLEDGEFLAGVPROC glad_glEdgeFlagv = NULL;
-PFNGLENABLEPROC glad_glEnable = NULL;
-PFNGLENABLECLIENTSTATEPROC glad_glEnableClientState = NULL;
-PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
-PFNGLENABLEIPROC glad_glEnablei = NULL;
-PFNGLENDPROC glad_glEnd = NULL;
-PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
-PFNGLENDLISTPROC glad_glEndList = NULL;
-PFNGLENDQUERYPROC glad_glEndQuery = NULL;
-PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
-PFNGLEVALCOORD1DPROC glad_glEvalCoord1d = NULL;
-PFNGLEVALCOORD1DVPROC glad_glEvalCoord1dv = NULL;
-PFNGLEVALCOORD1FPROC glad_glEvalCoord1f = NULL;
-PFNGLEVALCOORD1FVPROC glad_glEvalCoord1fv = NULL;
-PFNGLEVALCOORD2DPROC glad_glEvalCoord2d = NULL;
-PFNGLEVALCOORD2DVPROC glad_glEvalCoord2dv = NULL;
-PFNGLEVALCOORD2FPROC glad_glEvalCoord2f = NULL;
-PFNGLEVALCOORD2FVPROC glad_glEvalCoord2fv = NULL;
-PFNGLEVALMESH1PROC glad_glEvalMesh1 = NULL;
-PFNGLEVALMESH2PROC glad_glEvalMesh2 = NULL;
-PFNGLEVALPOINT1PROC glad_glEvalPoint1 = NULL;
-PFNGLEVALPOINT2PROC glad_glEvalPoint2 = NULL;
-PFNGLFEEDBACKBUFFERPROC glad_glFeedbackBuffer = NULL;
-PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
-PFNGLFINISHPROC glad_glFinish = NULL;
-PFNGLFLUSHPROC glad_glFlush = NULL;
-PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
-PFNGLFOGCOORDPOINTERPROC glad_glFogCoordPointer = NULL;
-PFNGLFOGCOORDDPROC glad_glFogCoordd = NULL;
-PFNGLFOGCOORDDVPROC glad_glFogCoorddv = NULL;
-PFNGLFOGCOORDFPROC glad_glFogCoordf = NULL;
-PFNGLFOGCOORDFVPROC glad_glFogCoordfv = NULL;
-PFNGLFOGFPROC glad_glFogf = NULL;
-PFNGLFOGFVPROC glad_glFogfv = NULL;
-PFNGLFOGIPROC glad_glFogi = NULL;
-PFNGLFOGIVPROC glad_glFogiv = NULL;
-PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
-PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
-PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
-PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
-PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
-PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
-PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
-PFNGLFRUSTUMPROC glad_glFrustum = NULL;
-PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
-PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
-PFNGLGENLISTSPROC glad_glGenLists = NULL;
-PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
-PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
-PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
-PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
-PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
-PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
-PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
-PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
-PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
-PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
-PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
-PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
-PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
-PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
-PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
-PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
-PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
-PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
-PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
-PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
-PFNGLGETCLIPPLANEPROC glad_glGetClipPlane = NULL;
-PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
-PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL;
-PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
-PFNGLGETERRORPROC glad_glGetError = NULL;
-PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
-PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
-PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
-PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
-PFNGLGETGRAPHICSRESETSTATUSARBPROC glad_glGetGraphicsResetStatusARB = NULL;
-PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
-PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
-PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
-PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
-PFNGLGETLIGHTFVPROC glad_glGetLightfv = NULL;
-PFNGLGETLIGHTIVPROC glad_glGetLightiv = NULL;
-PFNGLGETMAPDVPROC glad_glGetMapdv = NULL;
-PFNGLGETMAPFVPROC glad_glGetMapfv = NULL;
-PFNGLGETMAPIVPROC glad_glGetMapiv = NULL;
-PFNGLGETMATERIALFVPROC glad_glGetMaterialfv = NULL;
-PFNGLGETMATERIALIVPROC glad_glGetMaterialiv = NULL;
-PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
-PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL;
-PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL;
-PFNGLGETPIXELMAPFVPROC glad_glGetPixelMapfv = NULL;
-PFNGLGETPIXELMAPUIVPROC glad_glGetPixelMapuiv = NULL;
-PFNGLGETPIXELMAPUSVPROC glad_glGetPixelMapusv = NULL;
-PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL;
-PFNGLGETPOLYGONSTIPPLEPROC glad_glGetPolygonStipple = NULL;
-PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
-PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
-PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
-PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
-PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
-PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
-PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
-PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
-PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
-PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
-PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
-PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
-PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
-PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
-PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
-PFNGLGETSTRINGPROC glad_glGetString = NULL;
-PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
-PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
-PFNGLGETTEXENVFVPROC glad_glGetTexEnvfv = NULL;
-PFNGLGETTEXENVIVPROC glad_glGetTexEnviv = NULL;
-PFNGLGETTEXGENDVPROC glad_glGetTexGendv = NULL;
-PFNGLGETTEXGENFVPROC glad_glGetTexGenfv = NULL;
-PFNGLGETTEXGENIVPROC glad_glGetTexGeniv = NULL;
-PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
-PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
-PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
-PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
-PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
-PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
-PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
-PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
-PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
-PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
-PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
-PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
-PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
-PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
-PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
-PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
-PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
-PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
-PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
-PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
-PFNGLGETNCOLORTABLEARBPROC glad_glGetnColorTableARB = NULL;
-PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC glad_glGetnCompressedTexImageARB = NULL;
-PFNGLGETNCONVOLUTIONFILTERARBPROC glad_glGetnConvolutionFilterARB = NULL;
-PFNGLGETNHISTOGRAMARBPROC glad_glGetnHistogramARB = NULL;
-PFNGLGETNMAPDVARBPROC glad_glGetnMapdvARB = NULL;
-PFNGLGETNMAPFVARBPROC glad_glGetnMapfvARB = NULL;
-PFNGLGETNMAPIVARBPROC glad_glGetnMapivARB = NULL;
-PFNGLGETNMINMAXARBPROC glad_glGetnMinmaxARB = NULL;
-PFNGLGETNPIXELMAPFVARBPROC glad_glGetnPixelMapfvARB = NULL;
-PFNGLGETNPIXELMAPUIVARBPROC glad_glGetnPixelMapuivARB = NULL;
-PFNGLGETNPIXELMAPUSVARBPROC glad_glGetnPixelMapusvARB = NULL;
-PFNGLGETNPOLYGONSTIPPLEARBPROC glad_glGetnPolygonStippleARB = NULL;
-PFNGLGETNSEPARABLEFILTERARBPROC glad_glGetnSeparableFilterARB = NULL;
-PFNGLGETNTEXIMAGEARBPROC glad_glGetnTexImageARB = NULL;
-PFNGLGETNUNIFORMDVARBPROC glad_glGetnUniformdvARB = NULL;
-PFNGLGETNUNIFORMFVARBPROC glad_glGetnUniformfvARB = NULL;
-PFNGLGETNUNIFORMIVARBPROC glad_glGetnUniformivARB = NULL;
-PFNGLGETNUNIFORMUIVARBPROC glad_glGetnUniformuivARB = NULL;
-PFNGLHINTPROC glad_glHint = NULL;
-PFNGLINDEXMASKPROC glad_glIndexMask = NULL;
-PFNGLINDEXPOINTERPROC glad_glIndexPointer = NULL;
-PFNGLINDEXDPROC glad_glIndexd = NULL;
-PFNGLINDEXDVPROC glad_glIndexdv = NULL;
-PFNGLINDEXFPROC glad_glIndexf = NULL;
-PFNGLINDEXFVPROC glad_glIndexfv = NULL;
-PFNGLINDEXIPROC glad_glIndexi = NULL;
-PFNGLINDEXIVPROC glad_glIndexiv = NULL;
-PFNGLINDEXSPROC glad_glIndexs = NULL;
-PFNGLINDEXSVPROC glad_glIndexsv = NULL;
-PFNGLINDEXUBPROC glad_glIndexub = NULL;
-PFNGLINDEXUBVPROC glad_glIndexubv = NULL;
-PFNGLINITNAMESPROC glad_glInitNames = NULL;
-PFNGLINTERLEAVEDARRAYSPROC glad_glInterleavedArrays = NULL;
-PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
-PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
-PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
-PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
-PFNGLISLISTPROC glad_glIsList = NULL;
-PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
-PFNGLISQUERYPROC glad_glIsQuery = NULL;
-PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
-PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
-PFNGLISSHADERPROC glad_glIsShader = NULL;
-PFNGLISSYNCPROC glad_glIsSync = NULL;
-PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
-PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
-PFNGLLIGHTMODELFPROC glad_glLightModelf = NULL;
-PFNGLLIGHTMODELFVPROC glad_glLightModelfv = NULL;
-PFNGLLIGHTMODELIPROC glad_glLightModeli = NULL;
-PFNGLLIGHTMODELIVPROC glad_glLightModeliv = NULL;
-PFNGLLIGHTFPROC glad_glLightf = NULL;
-PFNGLLIGHTFVPROC glad_glLightfv = NULL;
-PFNGLLIGHTIPROC glad_glLighti = NULL;
-PFNGLLIGHTIVPROC glad_glLightiv = NULL;
-PFNGLLINESTIPPLEPROC glad_glLineStipple = NULL;
-PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
-PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
-PFNGLLISTBASEPROC glad_glListBase = NULL;
-PFNGLLOADIDENTITYPROC glad_glLoadIdentity = NULL;
-PFNGLLOADMATRIXDPROC glad_glLoadMatrixd = NULL;
-PFNGLLOADMATRIXFPROC glad_glLoadMatrixf = NULL;
-PFNGLLOADNAMEPROC glad_glLoadName = NULL;
-PFNGLLOADTRANSPOSEMATRIXDPROC glad_glLoadTransposeMatrixd = NULL;
-PFNGLLOADTRANSPOSEMATRIXFPROC glad_glLoadTransposeMatrixf = NULL;
-PFNGLLOGICOPPROC glad_glLogicOp = NULL;
-PFNGLMAP1DPROC glad_glMap1d = NULL;
-PFNGLMAP1FPROC glad_glMap1f = NULL;
-PFNGLMAP2DPROC glad_glMap2d = NULL;
-PFNGLMAP2FPROC glad_glMap2f = NULL;
-PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
-PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
-PFNGLMAPGRID1DPROC glad_glMapGrid1d = NULL;
-PFNGLMAPGRID1FPROC glad_glMapGrid1f = NULL;
-PFNGLMAPGRID2DPROC glad_glMapGrid2d = NULL;
-PFNGLMAPGRID2FPROC glad_glMapGrid2f = NULL;
-PFNGLMATERIALFPROC glad_glMaterialf = NULL;
-PFNGLMATERIALFVPROC glad_glMaterialfv = NULL;
-PFNGLMATERIALIPROC glad_glMateriali = NULL;
-PFNGLMATERIALIVPROC glad_glMaterialiv = NULL;
-PFNGLMATRIXMODEPROC glad_glMatrixMode = NULL;
-PFNGLMULTMATRIXDPROC glad_glMultMatrixd = NULL;
-PFNGLMULTMATRIXFPROC glad_glMultMatrixf = NULL;
-PFNGLMULTTRANSPOSEMATRIXDPROC glad_glMultTransposeMatrixd = NULL;
-PFNGLMULTTRANSPOSEMATRIXFPROC glad_glMultTransposeMatrixf = NULL;
-PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
-PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
-PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
-PFNGLMULTITEXCOORD1DPROC glad_glMultiTexCoord1d = NULL;
-PFNGLMULTITEXCOORD1DVPROC glad_glMultiTexCoord1dv = NULL;
-PFNGLMULTITEXCOORD1FPROC glad_glMultiTexCoord1f = NULL;
-PFNGLMULTITEXCOORD1FVPROC glad_glMultiTexCoord1fv = NULL;
-PFNGLMULTITEXCOORD1IPROC glad_glMultiTexCoord1i = NULL;
-PFNGLMULTITEXCOORD1IVPROC glad_glMultiTexCoord1iv = NULL;
-PFNGLMULTITEXCOORD1SPROC glad_glMultiTexCoord1s = NULL;
-PFNGLMULTITEXCOORD1SVPROC glad_glMultiTexCoord1sv = NULL;
-PFNGLMULTITEXCOORD2DPROC glad_glMultiTexCoord2d = NULL;
-PFNGLMULTITEXCOORD2DVPROC glad_glMultiTexCoord2dv = NULL;
-PFNGLMULTITEXCOORD2FPROC glad_glMultiTexCoord2f = NULL;
-PFNGLMULTITEXCOORD2FVPROC glad_glMultiTexCoord2fv = NULL;
-PFNGLMULTITEXCOORD2IPROC glad_glMultiTexCoord2i = NULL;
-PFNGLMULTITEXCOORD2IVPROC glad_glMultiTexCoord2iv = NULL;
-PFNGLMULTITEXCOORD2SPROC glad_glMultiTexCoord2s = NULL;
-PFNGLMULTITEXCOORD2SVPROC glad_glMultiTexCoord2sv = NULL;
-PFNGLMULTITEXCOORD3DPROC glad_glMultiTexCoord3d = NULL;
-PFNGLMULTITEXCOORD3DVPROC glad_glMultiTexCoord3dv = NULL;
-PFNGLMULTITEXCOORD3FPROC glad_glMultiTexCoord3f = NULL;
-PFNGLMULTITEXCOORD3FVPROC glad_glMultiTexCoord3fv = NULL;
-PFNGLMULTITEXCOORD3IPROC glad_glMultiTexCoord3i = NULL;
-PFNGLMULTITEXCOORD3IVPROC glad_glMultiTexCoord3iv = NULL;
-PFNGLMULTITEXCOORD3SPROC glad_glMultiTexCoord3s = NULL;
-PFNGLMULTITEXCOORD3SVPROC glad_glMultiTexCoord3sv = NULL;
-PFNGLMULTITEXCOORD4DPROC glad_glMultiTexCoord4d = NULL;
-PFNGLMULTITEXCOORD4DVPROC glad_glMultiTexCoord4dv = NULL;
-PFNGLMULTITEXCOORD4FPROC glad_glMultiTexCoord4f = NULL;
-PFNGLMULTITEXCOORD4FVPROC glad_glMultiTexCoord4fv = NULL;
-PFNGLMULTITEXCOORD4IPROC glad_glMultiTexCoord4i = NULL;
-PFNGLMULTITEXCOORD4IVPROC glad_glMultiTexCoord4iv = NULL;
-PFNGLMULTITEXCOORD4SPROC glad_glMultiTexCoord4s = NULL;
-PFNGLMULTITEXCOORD4SVPROC glad_glMultiTexCoord4sv = NULL;
-PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL;
-PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL;
-PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL;
-PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL;
-PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL;
-PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL;
-PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL;
-PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL;
-PFNGLNEWLISTPROC glad_glNewList = NULL;
-PFNGLNORMAL3BPROC glad_glNormal3b = NULL;
-PFNGLNORMAL3BVPROC glad_glNormal3bv = NULL;
-PFNGLNORMAL3DPROC glad_glNormal3d = NULL;
-PFNGLNORMAL3DVPROC glad_glNormal3dv = NULL;
-PFNGLNORMAL3FPROC glad_glNormal3f = NULL;
-PFNGLNORMAL3FVPROC glad_glNormal3fv = NULL;
-PFNGLNORMAL3IPROC glad_glNormal3i = NULL;
-PFNGLNORMAL3IVPROC glad_glNormal3iv = NULL;
-PFNGLNORMAL3SPROC glad_glNormal3s = NULL;
-PFNGLNORMAL3SVPROC glad_glNormal3sv = NULL;
-PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL;
-PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL;
-PFNGLNORMALPOINTERPROC glad_glNormalPointer = NULL;
-PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL;
-PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL;
-PFNGLORTHOPROC glad_glOrtho = NULL;
-PFNGLPASSTHROUGHPROC glad_glPassThrough = NULL;
-PFNGLPIXELMAPFVPROC glad_glPixelMapfv = NULL;
-PFNGLPIXELMAPUIVPROC glad_glPixelMapuiv = NULL;
-PFNGLPIXELMAPUSVPROC glad_glPixelMapusv = NULL;
-PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
-PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
-PFNGLPIXELTRANSFERFPROC glad_glPixelTransferf = NULL;
-PFNGLPIXELTRANSFERIPROC glad_glPixelTransferi = NULL;
-PFNGLPIXELZOOMPROC glad_glPixelZoom = NULL;
-PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
-PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
-PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
-PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
-PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
-PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
-PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
-PFNGLPOLYGONSTIPPLEPROC glad_glPolygonStipple = NULL;
-PFNGLPOPATTRIBPROC glad_glPopAttrib = NULL;
-PFNGLPOPCLIENTATTRIBPROC glad_glPopClientAttrib = NULL;
-PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL;
-PFNGLPOPMATRIXPROC glad_glPopMatrix = NULL;
-PFNGLPOPNAMEPROC glad_glPopName = NULL;
-PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
-PFNGLPRIORITIZETEXTURESPROC glad_glPrioritizeTextures = NULL;
-PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
-PFNGLPUSHATTRIBPROC glad_glPushAttrib = NULL;
-PFNGLPUSHCLIENTATTRIBPROC glad_glPushClientAttrib = NULL;
-PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL;
-PFNGLPUSHMATRIXPROC glad_glPushMatrix = NULL;
-PFNGLPUSHNAMEPROC glad_glPushName = NULL;
-PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
-PFNGLRASTERPOS2DPROC glad_glRasterPos2d = NULL;
-PFNGLRASTERPOS2DVPROC glad_glRasterPos2dv = NULL;
-PFNGLRASTERPOS2FPROC glad_glRasterPos2f = NULL;
-PFNGLRASTERPOS2FVPROC glad_glRasterPos2fv = NULL;
-PFNGLRASTERPOS2IPROC glad_glRasterPos2i = NULL;
-PFNGLRASTERPOS2IVPROC glad_glRasterPos2iv = NULL;
-PFNGLRASTERPOS2SPROC glad_glRasterPos2s = NULL;
-PFNGLRASTERPOS2SVPROC glad_glRasterPos2sv = NULL;
-PFNGLRASTERPOS3DPROC glad_glRasterPos3d = NULL;
-PFNGLRASTERPOS3DVPROC glad_glRasterPos3dv = NULL;
-PFNGLRASTERPOS3FPROC glad_glRasterPos3f = NULL;
-PFNGLRASTERPOS3FVPROC glad_glRasterPos3fv = NULL;
-PFNGLRASTERPOS3IPROC glad_glRasterPos3i = NULL;
-PFNGLRASTERPOS3IVPROC glad_glRasterPos3iv = NULL;
-PFNGLRASTERPOS3SPROC glad_glRasterPos3s = NULL;
-PFNGLRASTERPOS3SVPROC glad_glRasterPos3sv = NULL;
-PFNGLRASTERPOS4DPROC glad_glRasterPos4d = NULL;
-PFNGLRASTERPOS4DVPROC glad_glRasterPos4dv = NULL;
-PFNGLRASTERPOS4FPROC glad_glRasterPos4f = NULL;
-PFNGLRASTERPOS4FVPROC glad_glRasterPos4fv = NULL;
-PFNGLRASTERPOS4IPROC glad_glRasterPos4i = NULL;
-PFNGLRASTERPOS4IVPROC glad_glRasterPos4iv = NULL;
-PFNGLRASTERPOS4SPROC glad_glRasterPos4s = NULL;
-PFNGLRASTERPOS4SVPROC glad_glRasterPos4sv = NULL;
-PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
-PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
-PFNGLREADNPIXELSPROC glad_glReadnPixels = NULL;
-PFNGLREADNPIXELSARBPROC glad_glReadnPixelsARB = NULL;
-PFNGLRECTDPROC glad_glRectd = NULL;
-PFNGLRECTDVPROC glad_glRectdv = NULL;
-PFNGLRECTFPROC glad_glRectf = NULL;
-PFNGLRECTFVPROC glad_glRectfv = NULL;
-PFNGLRECTIPROC glad_glRecti = NULL;
-PFNGLRECTIVPROC glad_glRectiv = NULL;
-PFNGLRECTSPROC glad_glRects = NULL;
-PFNGLRECTSVPROC glad_glRectsv = NULL;
-PFNGLRENDERMODEPROC glad_glRenderMode = NULL;
-PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
-PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
-PFNGLROTATEDPROC glad_glRotated = NULL;
-PFNGLROTATEFPROC glad_glRotatef = NULL;
-PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
-PFNGLSAMPLECOVERAGEARBPROC glad_glSampleCoverageARB = NULL;
-PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
-PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
-PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
-PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
-PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
-PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
-PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
-PFNGLSCALEDPROC glad_glScaled = NULL;
-PFNGLSCALEFPROC glad_glScalef = NULL;
-PFNGLSCISSORPROC glad_glScissor = NULL;
-PFNGLSECONDARYCOLOR3BPROC glad_glSecondaryColor3b = NULL;
-PFNGLSECONDARYCOLOR3BVPROC glad_glSecondaryColor3bv = NULL;
-PFNGLSECONDARYCOLOR3DPROC glad_glSecondaryColor3d = NULL;
-PFNGLSECONDARYCOLOR3DVPROC glad_glSecondaryColor3dv = NULL;
-PFNGLSECONDARYCOLOR3FPROC glad_glSecondaryColor3f = NULL;
-PFNGLSECONDARYCOLOR3FVPROC glad_glSecondaryColor3fv = NULL;
-PFNGLSECONDARYCOLOR3IPROC glad_glSecondaryColor3i = NULL;
-PFNGLSECONDARYCOLOR3IVPROC glad_glSecondaryColor3iv = NULL;
-PFNGLSECONDARYCOLOR3SPROC glad_glSecondaryColor3s = NULL;
-PFNGLSECONDARYCOLOR3SVPROC glad_glSecondaryColor3sv = NULL;
-PFNGLSECONDARYCOLOR3UBPROC glad_glSecondaryColor3ub = NULL;
-PFNGLSECONDARYCOLOR3UBVPROC glad_glSecondaryColor3ubv = NULL;
-PFNGLSECONDARYCOLOR3UIPROC glad_glSecondaryColor3ui = NULL;
-PFNGLSECONDARYCOLOR3UIVPROC glad_glSecondaryColor3uiv = NULL;
-PFNGLSECONDARYCOLOR3USPROC glad_glSecondaryColor3us = NULL;
-PFNGLSECONDARYCOLOR3USVPROC glad_glSecondaryColor3usv = NULL;
-PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL;
-PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL;
-PFNGLSECONDARYCOLORPOINTERPROC glad_glSecondaryColorPointer = NULL;
-PFNGLSELECTBUFFERPROC glad_glSelectBuffer = NULL;
-PFNGLSHADEMODELPROC glad_glShadeModel = NULL;
-PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
-PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
-PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
-PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
-PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
-PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
-PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
-PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
-PFNGLTEXCOORD1DPROC glad_glTexCoord1d = NULL;
-PFNGLTEXCOORD1DVPROC glad_glTexCoord1dv = NULL;
-PFNGLTEXCOORD1FPROC glad_glTexCoord1f = NULL;
-PFNGLTEXCOORD1FVPROC glad_glTexCoord1fv = NULL;
-PFNGLTEXCOORD1IPROC glad_glTexCoord1i = NULL;
-PFNGLTEXCOORD1IVPROC glad_glTexCoord1iv = NULL;
-PFNGLTEXCOORD1SPROC glad_glTexCoord1s = NULL;
-PFNGLTEXCOORD1SVPROC glad_glTexCoord1sv = NULL;
-PFNGLTEXCOORD2DPROC glad_glTexCoord2d = NULL;
-PFNGLTEXCOORD2DVPROC glad_glTexCoord2dv = NULL;
-PFNGLTEXCOORD2FPROC glad_glTexCoord2f = NULL;
-PFNGLTEXCOORD2FVPROC glad_glTexCoord2fv = NULL;
-PFNGLTEXCOORD2IPROC glad_glTexCoord2i = NULL;
-PFNGLTEXCOORD2IVPROC glad_glTexCoord2iv = NULL;
-PFNGLTEXCOORD2SPROC glad_glTexCoord2s = NULL;
-PFNGLTEXCOORD2SVPROC glad_glTexCoord2sv = NULL;
-PFNGLTEXCOORD3DPROC glad_glTexCoord3d = NULL;
-PFNGLTEXCOORD3DVPROC glad_glTexCoord3dv = NULL;
-PFNGLTEXCOORD3FPROC glad_glTexCoord3f = NULL;
-PFNGLTEXCOORD3FVPROC glad_glTexCoord3fv = NULL;
-PFNGLTEXCOORD3IPROC glad_glTexCoord3i = NULL;
-PFNGLTEXCOORD3IVPROC glad_glTexCoord3iv = NULL;
-PFNGLTEXCOORD3SPROC glad_glTexCoord3s = NULL;
-PFNGLTEXCOORD3SVPROC glad_glTexCoord3sv = NULL;
-PFNGLTEXCOORD4DPROC glad_glTexCoord4d = NULL;
-PFNGLTEXCOORD4DVPROC glad_glTexCoord4dv = NULL;
-PFNGLTEXCOORD4FPROC glad_glTexCoord4f = NULL;
-PFNGLTEXCOORD4FVPROC glad_glTexCoord4fv = NULL;
-PFNGLTEXCOORD4IPROC glad_glTexCoord4i = NULL;
-PFNGLTEXCOORD4IVPROC glad_glTexCoord4iv = NULL;
-PFNGLTEXCOORD4SPROC glad_glTexCoord4s = NULL;
-PFNGLTEXCOORD4SVPROC glad_glTexCoord4sv = NULL;
-PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL;
-PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL;
-PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL;
-PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL;
-PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL;
-PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL;
-PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL;
-PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL;
-PFNGLTEXCOORDPOINTERPROC glad_glTexCoordPointer = NULL;
-PFNGLTEXENVFPROC glad_glTexEnvf = NULL;
-PFNGLTEXENVFVPROC glad_glTexEnvfv = NULL;
-PFNGLTEXENVIPROC glad_glTexEnvi = NULL;
-PFNGLTEXENVIVPROC glad_glTexEnviv = NULL;
-PFNGLTEXGENDPROC glad_glTexGend = NULL;
-PFNGLTEXGENDVPROC glad_glTexGendv = NULL;
-PFNGLTEXGENFPROC glad_glTexGenf = NULL;
-PFNGLTEXGENFVPROC glad_glTexGenfv = NULL;
-PFNGLTEXGENIPROC glad_glTexGeni = NULL;
-PFNGLTEXGENIVPROC glad_glTexGeniv = NULL;
-PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
-PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
-PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
-PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
-PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
-PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
-PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
-PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
-PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
-PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
-PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
-PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
-PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
-PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
-PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
-PFNGLTRANSLATEDPROC glad_glTranslated = NULL;
-PFNGLTRANSLATEFPROC glad_glTranslatef = NULL;
-PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
-PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
-PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
-PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
-PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
-PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
-PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
-PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
-PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
-PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
-PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
-PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
-PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
-PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
-PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
-PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
-PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
-PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
-PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
-PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
-PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
-PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
-PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
-PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
-PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
-PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
-PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
-PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
-PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
-PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
-PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
-PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
-PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
-PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
-PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
-PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
-PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
-PFNGLVERTEX2DPROC glad_glVertex2d = NULL;
-PFNGLVERTEX2DVPROC glad_glVertex2dv = NULL;
-PFNGLVERTEX2FPROC glad_glVertex2f = NULL;
-PFNGLVERTEX2FVPROC glad_glVertex2fv = NULL;
-PFNGLVERTEX2IPROC glad_glVertex2i = NULL;
-PFNGLVERTEX2IVPROC glad_glVertex2iv = NULL;
-PFNGLVERTEX2SPROC glad_glVertex2s = NULL;
-PFNGLVERTEX2SVPROC glad_glVertex2sv = NULL;
-PFNGLVERTEX3DPROC glad_glVertex3d = NULL;
-PFNGLVERTEX3DVPROC glad_glVertex3dv = NULL;
-PFNGLVERTEX3FPROC glad_glVertex3f = NULL;
-PFNGLVERTEX3FVPROC glad_glVertex3fv = NULL;
-PFNGLVERTEX3IPROC glad_glVertex3i = NULL;
-PFNGLVERTEX3IVPROC glad_glVertex3iv = NULL;
-PFNGLVERTEX3SPROC glad_glVertex3s = NULL;
-PFNGLVERTEX3SVPROC glad_glVertex3sv = NULL;
-PFNGLVERTEX4DPROC glad_glVertex4d = NULL;
-PFNGLVERTEX4DVPROC glad_glVertex4dv = NULL;
-PFNGLVERTEX4FPROC glad_glVertex4f = NULL;
-PFNGLVERTEX4FVPROC glad_glVertex4fv = NULL;
-PFNGLVERTEX4IPROC glad_glVertex4i = NULL;
-PFNGLVERTEX4IVPROC glad_glVertex4iv = NULL;
-PFNGLVERTEX4SPROC glad_glVertex4s = NULL;
-PFNGLVERTEX4SVPROC glad_glVertex4sv = NULL;
-PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
-PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
-PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
-PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
-PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
-PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
-PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
-PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
-PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
-PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
-PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
-PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
-PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
-PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
-PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
-PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
-PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
-PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
-PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
-PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
-PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
-PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
-PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
-PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
-PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
-PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
-PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
-PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
-PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
-PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
-PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
-PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
-PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
-PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
-PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
-PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
-PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
-PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
-PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
-PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
-PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
-PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
-PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
-PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
-PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
-PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
-PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
-PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
-PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
-PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
-PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
-PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
-PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
-PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
-PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
-PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
-PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
-PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
-PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
-PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
-PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
-PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
-PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
-PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
-PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
-PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
-PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
-PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL;
-PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL;
-PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL;
-PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL;
-PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL;
-PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL;
-PFNGLVERTEXPOINTERPROC glad_glVertexPointer = NULL;
-PFNGLVIEWPORTPROC glad_glViewport = NULL;
-PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
-PFNGLWINDOWPOS2DPROC glad_glWindowPos2d = NULL;
-PFNGLWINDOWPOS2DVPROC glad_glWindowPos2dv = NULL;
-PFNGLWINDOWPOS2FPROC glad_glWindowPos2f = NULL;
-PFNGLWINDOWPOS2FVPROC glad_glWindowPos2fv = NULL;
-PFNGLWINDOWPOS2IPROC glad_glWindowPos2i = NULL;
-PFNGLWINDOWPOS2IVPROC glad_glWindowPos2iv = NULL;
-PFNGLWINDOWPOS2SPROC glad_glWindowPos2s = NULL;
-PFNGLWINDOWPOS2SVPROC glad_glWindowPos2sv = NULL;
-PFNGLWINDOWPOS3DPROC glad_glWindowPos3d = NULL;
-PFNGLWINDOWPOS3DVPROC glad_glWindowPos3dv = NULL;
-PFNGLWINDOWPOS3FPROC glad_glWindowPos3f = NULL;
-PFNGLWINDOWPOS3FVPROC glad_glWindowPos3fv = NULL;
-PFNGLWINDOWPOS3IPROC glad_glWindowPos3i = NULL;
-PFNGLWINDOWPOS3IVPROC glad_glWindowPos3iv = NULL;
-PFNGLWINDOWPOS3SPROC glad_glWindowPos3s = NULL;
-PFNGLWINDOWPOS3SVPROC glad_glWindowPos3sv = NULL;
-
-
-static void glad_gl_load_GL_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_0) return;
-    glAccum = (PFNGLACCUMPROC) load("glAccum", userptr);
-    glAlphaFunc = (PFNGLALPHAFUNCPROC) load("glAlphaFunc", userptr);
-    glBegin = (PFNGLBEGINPROC) load("glBegin", userptr);
-    glBitmap = (PFNGLBITMAPPROC) load("glBitmap", userptr);
-    glBlendFunc = (PFNGLBLENDFUNCPROC) load("glBlendFunc", userptr);
-    glCallList = (PFNGLCALLLISTPROC) load("glCallList", userptr);
-    glCallLists = (PFNGLCALLLISTSPROC) load("glCallLists", userptr);
-    glClear = (PFNGLCLEARPROC) load("glClear", userptr);
-    glClearAccum = (PFNGLCLEARACCUMPROC) load("glClearAccum", userptr);
-    glClearColor = (PFNGLCLEARCOLORPROC) load("glClearColor", userptr);
-    glClearDepth = (PFNGLCLEARDEPTHPROC) load("glClearDepth", userptr);
-    glClearIndex = (PFNGLCLEARINDEXPROC) load("glClearIndex", userptr);
-    glClearStencil = (PFNGLCLEARSTENCILPROC) load("glClearStencil", userptr);
-    glClipPlane = (PFNGLCLIPPLANEPROC) load("glClipPlane", userptr);
-    glColor3b = (PFNGLCOLOR3BPROC) load("glColor3b", userptr);
-    glColor3bv = (PFNGLCOLOR3BVPROC) load("glColor3bv", userptr);
-    glColor3d = (PFNGLCOLOR3DPROC) load("glColor3d", userptr);
-    glColor3dv = (PFNGLCOLOR3DVPROC) load("glColor3dv", userptr);
-    glColor3f = (PFNGLCOLOR3FPROC) load("glColor3f", userptr);
-    glColor3fv = (PFNGLCOLOR3FVPROC) load("glColor3fv", userptr);
-    glColor3i = (PFNGLCOLOR3IPROC) load("glColor3i", userptr);
-    glColor3iv = (PFNGLCOLOR3IVPROC) load("glColor3iv", userptr);
-    glColor3s = (PFNGLCOLOR3SPROC) load("glColor3s", userptr);
-    glColor3sv = (PFNGLCOLOR3SVPROC) load("glColor3sv", userptr);
-    glColor3ub = (PFNGLCOLOR3UBPROC) load("glColor3ub", userptr);
-    glColor3ubv = (PFNGLCOLOR3UBVPROC) load("glColor3ubv", userptr);
-    glColor3ui = (PFNGLCOLOR3UIPROC) load("glColor3ui", userptr);
-    glColor3uiv = (PFNGLCOLOR3UIVPROC) load("glColor3uiv", userptr);
-    glColor3us = (PFNGLCOLOR3USPROC) load("glColor3us", userptr);
-    glColor3usv = (PFNGLCOLOR3USVPROC) load("glColor3usv", userptr);
-    glColor4b = (PFNGLCOLOR4BPROC) load("glColor4b", userptr);
-    glColor4bv = (PFNGLCOLOR4BVPROC) load("glColor4bv", userptr);
-    glColor4d = (PFNGLCOLOR4DPROC) load("glColor4d", userptr);
-    glColor4dv = (PFNGLCOLOR4DVPROC) load("glColor4dv", userptr);
-    glColor4f = (PFNGLCOLOR4FPROC) load("glColor4f", userptr);
-    glColor4fv = (PFNGLCOLOR4FVPROC) load("glColor4fv", userptr);
-    glColor4i = (PFNGLCOLOR4IPROC) load("glColor4i", userptr);
-    glColor4iv = (PFNGLCOLOR4IVPROC) load("glColor4iv", userptr);
-    glColor4s = (PFNGLCOLOR4SPROC) load("glColor4s", userptr);
-    glColor4sv = (PFNGLCOLOR4SVPROC) load("glColor4sv", userptr);
-    glColor4ub = (PFNGLCOLOR4UBPROC) load("glColor4ub", userptr);
-    glColor4ubv = (PFNGLCOLOR4UBVPROC) load("glColor4ubv", userptr);
-    glColor4ui = (PFNGLCOLOR4UIPROC) load("glColor4ui", userptr);
-    glColor4uiv = (PFNGLCOLOR4UIVPROC) load("glColor4uiv", userptr);
-    glColor4us = (PFNGLCOLOR4USPROC) load("glColor4us", userptr);
-    glColor4usv = (PFNGLCOLOR4USVPROC) load("glColor4usv", userptr);
-    glColorMask = (PFNGLCOLORMASKPROC) load("glColorMask", userptr);
-    glColorMaterial = (PFNGLCOLORMATERIALPROC) load("glColorMaterial", userptr);
-    glCopyPixels = (PFNGLCOPYPIXELSPROC) load("glCopyPixels", userptr);
-    glCullFace = (PFNGLCULLFACEPROC) load("glCullFace", userptr);
-    glDeleteLists = (PFNGLDELETELISTSPROC) load("glDeleteLists", userptr);
-    glDepthFunc = (PFNGLDEPTHFUNCPROC) load("glDepthFunc", userptr);
-    glDepthMask = (PFNGLDEPTHMASKPROC) load("glDepthMask", userptr);
-    glDepthRange = (PFNGLDEPTHRANGEPROC) load("glDepthRange", userptr);
-    glDisable = (PFNGLDISABLEPROC) load("glDisable", userptr);
-    glDrawBuffer = (PFNGLDRAWBUFFERPROC) load("glDrawBuffer", userptr);
-    glDrawPixels = (PFNGLDRAWPIXELSPROC) load("glDrawPixels", userptr);
-    glEdgeFlag = (PFNGLEDGEFLAGPROC) load("glEdgeFlag", userptr);
-    glEdgeFlagv = (PFNGLEDGEFLAGVPROC) load("glEdgeFlagv", userptr);
-    glEnable = (PFNGLENABLEPROC) load("glEnable", userptr);
-    glEnd = (PFNGLENDPROC) load("glEnd", userptr);
-    glEndList = (PFNGLENDLISTPROC) load("glEndList", userptr);
-    glEvalCoord1d = (PFNGLEVALCOORD1DPROC) load("glEvalCoord1d", userptr);
-    glEvalCoord1dv = (PFNGLEVALCOORD1DVPROC) load("glEvalCoord1dv", userptr);
-    glEvalCoord1f = (PFNGLEVALCOORD1FPROC) load("glEvalCoord1f", userptr);
-    glEvalCoord1fv = (PFNGLEVALCOORD1FVPROC) load("glEvalCoord1fv", userptr);
-    glEvalCoord2d = (PFNGLEVALCOORD2DPROC) load("glEvalCoord2d", userptr);
-    glEvalCoord2dv = (PFNGLEVALCOORD2DVPROC) load("glEvalCoord2dv", userptr);
-    glEvalCoord2f = (PFNGLEVALCOORD2FPROC) load("glEvalCoord2f", userptr);
-    glEvalCoord2fv = (PFNGLEVALCOORD2FVPROC) load("glEvalCoord2fv", userptr);
-    glEvalMesh1 = (PFNGLEVALMESH1PROC) load("glEvalMesh1", userptr);
-    glEvalMesh2 = (PFNGLEVALMESH2PROC) load("glEvalMesh2", userptr);
-    glEvalPoint1 = (PFNGLEVALPOINT1PROC) load("glEvalPoint1", userptr);
-    glEvalPoint2 = (PFNGLEVALPOINT2PROC) load("glEvalPoint2", userptr);
-    glFeedbackBuffer = (PFNGLFEEDBACKBUFFERPROC) load("glFeedbackBuffer", userptr);
-    glFinish = (PFNGLFINISHPROC) load("glFinish", userptr);
-    glFlush = (PFNGLFLUSHPROC) load("glFlush", userptr);
-    glFogf = (PFNGLFOGFPROC) load("glFogf", userptr);
-    glFogfv = (PFNGLFOGFVPROC) load("glFogfv", userptr);
-    glFogi = (PFNGLFOGIPROC) load("glFogi", userptr);
-    glFogiv = (PFNGLFOGIVPROC) load("glFogiv", userptr);
-    glFrontFace = (PFNGLFRONTFACEPROC) load("glFrontFace", userptr);
-    glFrustum = (PFNGLFRUSTUMPROC) load("glFrustum", userptr);
-    glGenLists = (PFNGLGENLISTSPROC) load("glGenLists", userptr);
-    glGetBooleanv = (PFNGLGETBOOLEANVPROC) load("glGetBooleanv", userptr);
-    glGetClipPlane = (PFNGLGETCLIPPLANEPROC) load("glGetClipPlane", userptr);
-    glGetDoublev = (PFNGLGETDOUBLEVPROC) load("glGetDoublev", userptr);
-    glGetError = (PFNGLGETERRORPROC) load("glGetError", userptr);
-    glGetFloatv = (PFNGLGETFLOATVPROC) load("glGetFloatv", userptr);
-    glGetIntegerv = (PFNGLGETINTEGERVPROC) load("glGetIntegerv", userptr);
-    glGetLightfv = (PFNGLGETLIGHTFVPROC) load("glGetLightfv", userptr);
-    glGetLightiv = (PFNGLGETLIGHTIVPROC) load("glGetLightiv", userptr);
-    glGetMapdv = (PFNGLGETMAPDVPROC) load("glGetMapdv", userptr);
-    glGetMapfv = (PFNGLGETMAPFVPROC) load("glGetMapfv", userptr);
-    glGetMapiv = (PFNGLGETMAPIVPROC) load("glGetMapiv", userptr);
-    glGetMaterialfv = (PFNGLGETMATERIALFVPROC) load("glGetMaterialfv", userptr);
-    glGetMaterialiv = (PFNGLGETMATERIALIVPROC) load("glGetMaterialiv", userptr);
-    glGetPixelMapfv = (PFNGLGETPIXELMAPFVPROC) load("glGetPixelMapfv", userptr);
-    glGetPixelMapuiv = (PFNGLGETPIXELMAPUIVPROC) load("glGetPixelMapuiv", userptr);
-    glGetPixelMapusv = (PFNGLGETPIXELMAPUSVPROC) load("glGetPixelMapusv", userptr);
-    glGetPolygonStipple = (PFNGLGETPOLYGONSTIPPLEPROC) load("glGetPolygonStipple", userptr);
-    glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr);
-    glGetTexEnvfv = (PFNGLGETTEXENVFVPROC) load("glGetTexEnvfv", userptr);
-    glGetTexEnviv = (PFNGLGETTEXENVIVPROC) load("glGetTexEnviv", userptr);
-    glGetTexGendv = (PFNGLGETTEXGENDVPROC) load("glGetTexGendv", userptr);
-    glGetTexGenfv = (PFNGLGETTEXGENFVPROC) load("glGetTexGenfv", userptr);
-    glGetTexGeniv = (PFNGLGETTEXGENIVPROC) load("glGetTexGeniv", userptr);
-    glGetTexImage = (PFNGLGETTEXIMAGEPROC) load("glGetTexImage", userptr);
-    glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC) load("glGetTexLevelParameterfv", userptr);
-    glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC) load("glGetTexLevelParameteriv", userptr);
-    glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC) load("glGetTexParameterfv", userptr);
-    glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC) load("glGetTexParameteriv", userptr);
-    glHint = (PFNGLHINTPROC) load("glHint", userptr);
-    glIndexMask = (PFNGLINDEXMASKPROC) load("glIndexMask", userptr);
-    glIndexd = (PFNGLINDEXDPROC) load("glIndexd", userptr);
-    glIndexdv = (PFNGLINDEXDVPROC) load("glIndexdv", userptr);
-    glIndexf = (PFNGLINDEXFPROC) load("glIndexf", userptr);
-    glIndexfv = (PFNGLINDEXFVPROC) load("glIndexfv", userptr);
-    glIndexi = (PFNGLINDEXIPROC) load("glIndexi", userptr);
-    glIndexiv = (PFNGLINDEXIVPROC) load("glIndexiv", userptr);
-    glIndexs = (PFNGLINDEXSPROC) load("glIndexs", userptr);
-    glIndexsv = (PFNGLINDEXSVPROC) load("glIndexsv", userptr);
-    glInitNames = (PFNGLINITNAMESPROC) load("glInitNames", userptr);
-    glIsEnabled = (PFNGLISENABLEDPROC) load("glIsEnabled", userptr);
-    glIsList = (PFNGLISLISTPROC) load("glIsList", userptr);
-    glLightModelf = (PFNGLLIGHTMODELFPROC) load("glLightModelf", userptr);
-    glLightModelfv = (PFNGLLIGHTMODELFVPROC) load("glLightModelfv", userptr);
-    glLightModeli = (PFNGLLIGHTMODELIPROC) load("glLightModeli", userptr);
-    glLightModeliv = (PFNGLLIGHTMODELIVPROC) load("glLightModeliv", userptr);
-    glLightf = (PFNGLLIGHTFPROC) load("glLightf", userptr);
-    glLightfv = (PFNGLLIGHTFVPROC) load("glLightfv", userptr);
-    glLighti = (PFNGLLIGHTIPROC) load("glLighti", userptr);
-    glLightiv = (PFNGLLIGHTIVPROC) load("glLightiv", userptr);
-    glLineStipple = (PFNGLLINESTIPPLEPROC) load("glLineStipple", userptr);
-    glLineWidth = (PFNGLLINEWIDTHPROC) load("glLineWidth", userptr);
-    glListBase = (PFNGLLISTBASEPROC) load("glListBase", userptr);
-    glLoadIdentity = (PFNGLLOADIDENTITYPROC) load("glLoadIdentity", userptr);
-    glLoadMatrixd = (PFNGLLOADMATRIXDPROC) load("glLoadMatrixd", userptr);
-    glLoadMatrixf = (PFNGLLOADMATRIXFPROC) load("glLoadMatrixf", userptr);
-    glLoadName = (PFNGLLOADNAMEPROC) load("glLoadName", userptr);
-    glLogicOp = (PFNGLLOGICOPPROC) load("glLogicOp", userptr);
-    glMap1d = (PFNGLMAP1DPROC) load("glMap1d", userptr);
-    glMap1f = (PFNGLMAP1FPROC) load("glMap1f", userptr);
-    glMap2d = (PFNGLMAP2DPROC) load("glMap2d", userptr);
-    glMap2f = (PFNGLMAP2FPROC) load("glMap2f", userptr);
-    glMapGrid1d = (PFNGLMAPGRID1DPROC) load("glMapGrid1d", userptr);
-    glMapGrid1f = (PFNGLMAPGRID1FPROC) load("glMapGrid1f", userptr);
-    glMapGrid2d = (PFNGLMAPGRID2DPROC) load("glMapGrid2d", userptr);
-    glMapGrid2f = (PFNGLMAPGRID2FPROC) load("glMapGrid2f", userptr);
-    glMaterialf = (PFNGLMATERIALFPROC) load("glMaterialf", userptr);
-    glMaterialfv = (PFNGLMATERIALFVPROC) load("glMaterialfv", userptr);
-    glMateriali = (PFNGLMATERIALIPROC) load("glMateriali", userptr);
-    glMaterialiv = (PFNGLMATERIALIVPROC) load("glMaterialiv", userptr);
-    glMatrixMode = (PFNGLMATRIXMODEPROC) load("glMatrixMode", userptr);
-    glMultMatrixd = (PFNGLMULTMATRIXDPROC) load("glMultMatrixd", userptr);
-    glMultMatrixf = (PFNGLMULTMATRIXFPROC) load("glMultMatrixf", userptr);
-    glNewList = (PFNGLNEWLISTPROC) load("glNewList", userptr);
-    glNormal3b = (PFNGLNORMAL3BPROC) load("glNormal3b", userptr);
-    glNormal3bv = (PFNGLNORMAL3BVPROC) load("glNormal3bv", userptr);
-    glNormal3d = (PFNGLNORMAL3DPROC) load("glNormal3d", userptr);
-    glNormal3dv = (PFNGLNORMAL3DVPROC) load("glNormal3dv", userptr);
-    glNormal3f = (PFNGLNORMAL3FPROC) load("glNormal3f", userptr);
-    glNormal3fv = (PFNGLNORMAL3FVPROC) load("glNormal3fv", userptr);
-    glNormal3i = (PFNGLNORMAL3IPROC) load("glNormal3i", userptr);
-    glNormal3iv = (PFNGLNORMAL3IVPROC) load("glNormal3iv", userptr);
-    glNormal3s = (PFNGLNORMAL3SPROC) load("glNormal3s", userptr);
-    glNormal3sv = (PFNGLNORMAL3SVPROC) load("glNormal3sv", userptr);
-    glOrtho = (PFNGLORTHOPROC) load("glOrtho", userptr);
-    glPassThrough = (PFNGLPASSTHROUGHPROC) load("glPassThrough", userptr);
-    glPixelMapfv = (PFNGLPIXELMAPFVPROC) load("glPixelMapfv", userptr);
-    glPixelMapuiv = (PFNGLPIXELMAPUIVPROC) load("glPixelMapuiv", userptr);
-    glPixelMapusv = (PFNGLPIXELMAPUSVPROC) load("glPixelMapusv", userptr);
-    glPixelStoref = (PFNGLPIXELSTOREFPROC) load("glPixelStoref", userptr);
-    glPixelStorei = (PFNGLPIXELSTOREIPROC) load("glPixelStorei", userptr);
-    glPixelTransferf = (PFNGLPIXELTRANSFERFPROC) load("glPixelTransferf", userptr);
-    glPixelTransferi = (PFNGLPIXELTRANSFERIPROC) load("glPixelTransferi", userptr);
-    glPixelZoom = (PFNGLPIXELZOOMPROC) load("glPixelZoom", userptr);
-    glPointSize = (PFNGLPOINTSIZEPROC) load("glPointSize", userptr);
-    glPolygonMode = (PFNGLPOLYGONMODEPROC) load("glPolygonMode", userptr);
-    glPolygonStipple = (PFNGLPOLYGONSTIPPLEPROC) load("glPolygonStipple", userptr);
-    glPopAttrib = (PFNGLPOPATTRIBPROC) load("glPopAttrib", userptr);
-    glPopMatrix = (PFNGLPOPMATRIXPROC) load("glPopMatrix", userptr);
-    glPopName = (PFNGLPOPNAMEPROC) load("glPopName", userptr);
-    glPushAttrib = (PFNGLPUSHATTRIBPROC) load("glPushAttrib", userptr);
-    glPushMatrix = (PFNGLPUSHMATRIXPROC) load("glPushMatrix", userptr);
-    glPushName = (PFNGLPUSHNAMEPROC) load("glPushName", userptr);
-    glRasterPos2d = (PFNGLRASTERPOS2DPROC) load("glRasterPos2d", userptr);
-    glRasterPos2dv = (PFNGLRASTERPOS2DVPROC) load("glRasterPos2dv", userptr);
-    glRasterPos2f = (PFNGLRASTERPOS2FPROC) load("glRasterPos2f", userptr);
-    glRasterPos2fv = (PFNGLRASTERPOS2FVPROC) load("glRasterPos2fv", userptr);
-    glRasterPos2i = (PFNGLRASTERPOS2IPROC) load("glRasterPos2i", userptr);
-    glRasterPos2iv = (PFNGLRASTERPOS2IVPROC) load("glRasterPos2iv", userptr);
-    glRasterPos2s = (PFNGLRASTERPOS2SPROC) load("glRasterPos2s", userptr);
-    glRasterPos2sv = (PFNGLRASTERPOS2SVPROC) load("glRasterPos2sv", userptr);
-    glRasterPos3d = (PFNGLRASTERPOS3DPROC) load("glRasterPos3d", userptr);
-    glRasterPos3dv = (PFNGLRASTERPOS3DVPROC) load("glRasterPos3dv", userptr);
-    glRasterPos3f = (PFNGLRASTERPOS3FPROC) load("glRasterPos3f", userptr);
-    glRasterPos3fv = (PFNGLRASTERPOS3FVPROC) load("glRasterPos3fv", userptr);
-    glRasterPos3i = (PFNGLRASTERPOS3IPROC) load("glRasterPos3i", userptr);
-    glRasterPos3iv = (PFNGLRASTERPOS3IVPROC) load("glRasterPos3iv", userptr);
-    glRasterPos3s = (PFNGLRASTERPOS3SPROC) load("glRasterPos3s", userptr);
-    glRasterPos3sv = (PFNGLRASTERPOS3SVPROC) load("glRasterPos3sv", userptr);
-    glRasterPos4d = (PFNGLRASTERPOS4DPROC) load("glRasterPos4d", userptr);
-    glRasterPos4dv = (PFNGLRASTERPOS4DVPROC) load("glRasterPos4dv", userptr);
-    glRasterPos4f = (PFNGLRASTERPOS4FPROC) load("glRasterPos4f", userptr);
-    glRasterPos4fv = (PFNGLRASTERPOS4FVPROC) load("glRasterPos4fv", userptr);
-    glRasterPos4i = (PFNGLRASTERPOS4IPROC) load("glRasterPos4i", userptr);
-    glRasterPos4iv = (PFNGLRASTERPOS4IVPROC) load("glRasterPos4iv", userptr);
-    glRasterPos4s = (PFNGLRASTERPOS4SPROC) load("glRasterPos4s", userptr);
-    glRasterPos4sv = (PFNGLRASTERPOS4SVPROC) load("glRasterPos4sv", userptr);
-    glReadBuffer = (PFNGLREADBUFFERPROC) load("glReadBuffer", userptr);
-    glReadPixels = (PFNGLREADPIXELSPROC) load("glReadPixels", userptr);
-    glRectd = (PFNGLRECTDPROC) load("glRectd", userptr);
-    glRectdv = (PFNGLRECTDVPROC) load("glRectdv", userptr);
-    glRectf = (PFNGLRECTFPROC) load("glRectf", userptr);
-    glRectfv = (PFNGLRECTFVPROC) load("glRectfv", userptr);
-    glRecti = (PFNGLRECTIPROC) load("glRecti", userptr);
-    glRectiv = (PFNGLRECTIVPROC) load("glRectiv", userptr);
-    glRects = (PFNGLRECTSPROC) load("glRects", userptr);
-    glRectsv = (PFNGLRECTSVPROC) load("glRectsv", userptr);
-    glRenderMode = (PFNGLRENDERMODEPROC) load("glRenderMode", userptr);
-    glRotated = (PFNGLROTATEDPROC) load("glRotated", userptr);
-    glRotatef = (PFNGLROTATEFPROC) load("glRotatef", userptr);
-    glScaled = (PFNGLSCALEDPROC) load("glScaled", userptr);
-    glScalef = (PFNGLSCALEFPROC) load("glScalef", userptr);
-    glScissor = (PFNGLSCISSORPROC) load("glScissor", userptr);
-    glSelectBuffer = (PFNGLSELECTBUFFERPROC) load("glSelectBuffer", userptr);
-    glShadeModel = (PFNGLSHADEMODELPROC) load("glShadeModel", userptr);
-    glStencilFunc = (PFNGLSTENCILFUNCPROC) load("glStencilFunc", userptr);
-    glStencilMask = (PFNGLSTENCILMASKPROC) load("glStencilMask", userptr);
-    glStencilOp = (PFNGLSTENCILOPPROC) load("glStencilOp", userptr);
-    glTexCoord1d = (PFNGLTEXCOORD1DPROC) load("glTexCoord1d", userptr);
-    glTexCoord1dv = (PFNGLTEXCOORD1DVPROC) load("glTexCoord1dv", userptr);
-    glTexCoord1f = (PFNGLTEXCOORD1FPROC) load("glTexCoord1f", userptr);
-    glTexCoord1fv = (PFNGLTEXCOORD1FVPROC) load("glTexCoord1fv", userptr);
-    glTexCoord1i = (PFNGLTEXCOORD1IPROC) load("glTexCoord1i", userptr);
-    glTexCoord1iv = (PFNGLTEXCOORD1IVPROC) load("glTexCoord1iv", userptr);
-    glTexCoord1s = (PFNGLTEXCOORD1SPROC) load("glTexCoord1s", userptr);
-    glTexCoord1sv = (PFNGLTEXCOORD1SVPROC) load("glTexCoord1sv", userptr);
-    glTexCoord2d = (PFNGLTEXCOORD2DPROC) load("glTexCoord2d", userptr);
-    glTexCoord2dv = (PFNGLTEXCOORD2DVPROC) load("glTexCoord2dv", userptr);
-    glTexCoord2f = (PFNGLTEXCOORD2FPROC) load("glTexCoord2f", userptr);
-    glTexCoord2fv = (PFNGLTEXCOORD2FVPROC) load("glTexCoord2fv", userptr);
-    glTexCoord2i = (PFNGLTEXCOORD2IPROC) load("glTexCoord2i", userptr);
-    glTexCoord2iv = (PFNGLTEXCOORD2IVPROC) load("glTexCoord2iv", userptr);
-    glTexCoord2s = (PFNGLTEXCOORD2SPROC) load("glTexCoord2s", userptr);
-    glTexCoord2sv = (PFNGLTEXCOORD2SVPROC) load("glTexCoord2sv", userptr);
-    glTexCoord3d = (PFNGLTEXCOORD3DPROC) load("glTexCoord3d", userptr);
-    glTexCoord3dv = (PFNGLTEXCOORD3DVPROC) load("glTexCoord3dv", userptr);
-    glTexCoord3f = (PFNGLTEXCOORD3FPROC) load("glTexCoord3f", userptr);
-    glTexCoord3fv = (PFNGLTEXCOORD3FVPROC) load("glTexCoord3fv", userptr);
-    glTexCoord3i = (PFNGLTEXCOORD3IPROC) load("glTexCoord3i", userptr);
-    glTexCoord3iv = (PFNGLTEXCOORD3IVPROC) load("glTexCoord3iv", userptr);
-    glTexCoord3s = (PFNGLTEXCOORD3SPROC) load("glTexCoord3s", userptr);
-    glTexCoord3sv = (PFNGLTEXCOORD3SVPROC) load("glTexCoord3sv", userptr);
-    glTexCoord4d = (PFNGLTEXCOORD4DPROC) load("glTexCoord4d", userptr);
-    glTexCoord4dv = (PFNGLTEXCOORD4DVPROC) load("glTexCoord4dv", userptr);
-    glTexCoord4f = (PFNGLTEXCOORD4FPROC) load("glTexCoord4f", userptr);
-    glTexCoord4fv = (PFNGLTEXCOORD4FVPROC) load("glTexCoord4fv", userptr);
-    glTexCoord4i = (PFNGLTEXCOORD4IPROC) load("glTexCoord4i", userptr);
-    glTexCoord4iv = (PFNGLTEXCOORD4IVPROC) load("glTexCoord4iv", userptr);
-    glTexCoord4s = (PFNGLTEXCOORD4SPROC) load("glTexCoord4s", userptr);
-    glTexCoord4sv = (PFNGLTEXCOORD4SVPROC) load("glTexCoord4sv", userptr);
-    glTexEnvf = (PFNGLTEXENVFPROC) load("glTexEnvf", userptr);
-    glTexEnvfv = (PFNGLTEXENVFVPROC) load("glTexEnvfv", userptr);
-    glTexEnvi = (PFNGLTEXENVIPROC) load("glTexEnvi", userptr);
-    glTexEnviv = (PFNGLTEXENVIVPROC) load("glTexEnviv", userptr);
-    glTexGend = (PFNGLTEXGENDPROC) load("glTexGend", userptr);
-    glTexGendv = (PFNGLTEXGENDVPROC) load("glTexGendv", userptr);
-    glTexGenf = (PFNGLTEXGENFPROC) load("glTexGenf", userptr);
-    glTexGenfv = (PFNGLTEXGENFVPROC) load("glTexGenfv", userptr);
-    glTexGeni = (PFNGLTEXGENIPROC) load("glTexGeni", userptr);
-    glTexGeniv = (PFNGLTEXGENIVPROC) load("glTexGeniv", userptr);
-    glTexImage1D = (PFNGLTEXIMAGE1DPROC) load("glTexImage1D", userptr);
-    glTexImage2D = (PFNGLTEXIMAGE2DPROC) load("glTexImage2D", userptr);
-    glTexParameterf = (PFNGLTEXPARAMETERFPROC) load("glTexParameterf", userptr);
-    glTexParameterfv = (PFNGLTEXPARAMETERFVPROC) load("glTexParameterfv", userptr);
-    glTexParameteri = (PFNGLTEXPARAMETERIPROC) load("glTexParameteri", userptr);
-    glTexParameteriv = (PFNGLTEXPARAMETERIVPROC) load("glTexParameteriv", userptr);
-    glTranslated = (PFNGLTRANSLATEDPROC) load("glTranslated", userptr);
-    glTranslatef = (PFNGLTRANSLATEFPROC) load("glTranslatef", userptr);
-    glVertex2d = (PFNGLVERTEX2DPROC) load("glVertex2d", userptr);
-    glVertex2dv = (PFNGLVERTEX2DVPROC) load("glVertex2dv", userptr);
-    glVertex2f = (PFNGLVERTEX2FPROC) load("glVertex2f", userptr);
-    glVertex2fv = (PFNGLVERTEX2FVPROC) load("glVertex2fv", userptr);
-    glVertex2i = (PFNGLVERTEX2IPROC) load("glVertex2i", userptr);
-    glVertex2iv = (PFNGLVERTEX2IVPROC) load("glVertex2iv", userptr);
-    glVertex2s = (PFNGLVERTEX2SPROC) load("glVertex2s", userptr);
-    glVertex2sv = (PFNGLVERTEX2SVPROC) load("glVertex2sv", userptr);
-    glVertex3d = (PFNGLVERTEX3DPROC) load("glVertex3d", userptr);
-    glVertex3dv = (PFNGLVERTEX3DVPROC) load("glVertex3dv", userptr);
-    glVertex3f = (PFNGLVERTEX3FPROC) load("glVertex3f", userptr);
-    glVertex3fv = (PFNGLVERTEX3FVPROC) load("glVertex3fv", userptr);
-    glVertex3i = (PFNGLVERTEX3IPROC) load("glVertex3i", userptr);
-    glVertex3iv = (PFNGLVERTEX3IVPROC) load("glVertex3iv", userptr);
-    glVertex3s = (PFNGLVERTEX3SPROC) load("glVertex3s", userptr);
-    glVertex3sv = (PFNGLVERTEX3SVPROC) load("glVertex3sv", userptr);
-    glVertex4d = (PFNGLVERTEX4DPROC) load("glVertex4d", userptr);
-    glVertex4dv = (PFNGLVERTEX4DVPROC) load("glVertex4dv", userptr);
-    glVertex4f = (PFNGLVERTEX4FPROC) load("glVertex4f", userptr);
-    glVertex4fv = (PFNGLVERTEX4FVPROC) load("glVertex4fv", userptr);
-    glVertex4i = (PFNGLVERTEX4IPROC) load("glVertex4i", userptr);
-    glVertex4iv = (PFNGLVERTEX4IVPROC) load("glVertex4iv", userptr);
-    glVertex4s = (PFNGLVERTEX4SPROC) load("glVertex4s", userptr);
-    glVertex4sv = (PFNGLVERTEX4SVPROC) load("glVertex4sv", userptr);
-    glViewport = (PFNGLVIEWPORTPROC) load("glViewport", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_1) return;
-    glAreTexturesResident = (PFNGLARETEXTURESRESIDENTPROC) load("glAreTexturesResident", userptr);
-    glArrayElement = (PFNGLARRAYELEMENTPROC) load("glArrayElement", userptr);
-    glBindTexture = (PFNGLBINDTEXTUREPROC) load("glBindTexture", userptr);
-    glColorPointer = (PFNGLCOLORPOINTERPROC) load("glColorPointer", userptr);
-    glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC) load("glCopyTexImage1D", userptr);
-    glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC) load("glCopyTexImage2D", userptr);
-    glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC) load("glCopyTexSubImage1D", userptr);
-    glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC) load("glCopyTexSubImage2D", userptr);
-    glDeleteTextures = (PFNGLDELETETEXTURESPROC) load("glDeleteTextures", userptr);
-    glDisableClientState = (PFNGLDISABLECLIENTSTATEPROC) load("glDisableClientState", userptr);
-    glDrawArrays = (PFNGLDRAWARRAYSPROC) load("glDrawArrays", userptr);
-    glDrawElements = (PFNGLDRAWELEMENTSPROC) load("glDrawElements", userptr);
-    glEdgeFlagPointer = (PFNGLEDGEFLAGPOINTERPROC) load("glEdgeFlagPointer", userptr);
-    glEnableClientState = (PFNGLENABLECLIENTSTATEPROC) load("glEnableClientState", userptr);
-    glGenTextures = (PFNGLGENTEXTURESPROC) load("glGenTextures", userptr);
-    glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr);
-    glIndexPointer = (PFNGLINDEXPOINTERPROC) load("glIndexPointer", userptr);
-    glIndexub = (PFNGLINDEXUBPROC) load("glIndexub", userptr);
-    glIndexubv = (PFNGLINDEXUBVPROC) load("glIndexubv", userptr);
-    glInterleavedArrays = (PFNGLINTERLEAVEDARRAYSPROC) load("glInterleavedArrays", userptr);
-    glIsTexture = (PFNGLISTEXTUREPROC) load("glIsTexture", userptr);
-    glNormalPointer = (PFNGLNORMALPOINTERPROC) load("glNormalPointer", userptr);
-    glPolygonOffset = (PFNGLPOLYGONOFFSETPROC) load("glPolygonOffset", userptr);
-    glPopClientAttrib = (PFNGLPOPCLIENTATTRIBPROC) load("glPopClientAttrib", userptr);
-    glPrioritizeTextures = (PFNGLPRIORITIZETEXTURESPROC) load("glPrioritizeTextures", userptr);
-    glPushClientAttrib = (PFNGLPUSHCLIENTATTRIBPROC) load("glPushClientAttrib", userptr);
-    glTexCoordPointer = (PFNGLTEXCOORDPOINTERPROC) load("glTexCoordPointer", userptr);
-    glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC) load("glTexSubImage1D", userptr);
-    glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) load("glTexSubImage2D", userptr);
-    glVertexPointer = (PFNGLVERTEXPOINTERPROC) load("glVertexPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_2( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_2) return;
-    glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC) load("glCopyTexSubImage3D", userptr);
-    glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) load("glDrawRangeElements", userptr);
-    glTexImage3D = (PFNGLTEXIMAGE3DPROC) load("glTexImage3D", userptr);
-    glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC) load("glTexSubImage3D", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_3( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_3) return;
-    glActiveTexture = (PFNGLACTIVETEXTUREPROC) load("glActiveTexture", userptr);
-    glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC) load("glClientActiveTexture", userptr);
-    glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC) load("glCompressedTexImage1D", userptr);
-    glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) load("glCompressedTexImage2D", userptr);
-    glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC) load("glCompressedTexImage3D", userptr);
-    glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) load("glCompressedTexSubImage1D", userptr);
-    glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) load("glCompressedTexSubImage2D", userptr);
-    glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) load("glCompressedTexSubImage3D", userptr);
-    glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC) load("glGetCompressedTexImage", userptr);
-    glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC) load("glLoadTransposeMatrixd", userptr);
-    glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC) load("glLoadTransposeMatrixf", userptr);
-    glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC) load("glMultTransposeMatrixd", userptr);
-    glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC) load("glMultTransposeMatrixf", userptr);
-    glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC) load("glMultiTexCoord1d", userptr);
-    glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC) load("glMultiTexCoord1dv", userptr);
-    glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC) load("glMultiTexCoord1f", userptr);
-    glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC) load("glMultiTexCoord1fv", userptr);
-    glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC) load("glMultiTexCoord1i", userptr);
-    glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC) load("glMultiTexCoord1iv", userptr);
-    glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC) load("glMultiTexCoord1s", userptr);
-    glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC) load("glMultiTexCoord1sv", userptr);
-    glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC) load("glMultiTexCoord2d", userptr);
-    glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC) load("glMultiTexCoord2dv", userptr);
-    glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) load("glMultiTexCoord2f", userptr);
-    glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) load("glMultiTexCoord2fv", userptr);
-    glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC) load("glMultiTexCoord2i", userptr);
-    glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC) load("glMultiTexCoord2iv", userptr);
-    glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC) load("glMultiTexCoord2s", userptr);
-    glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC) load("glMultiTexCoord2sv", userptr);
-    glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC) load("glMultiTexCoord3d", userptr);
-    glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC) load("glMultiTexCoord3dv", userptr);
-    glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) load("glMultiTexCoord3f", userptr);
-    glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC) load("glMultiTexCoord3fv", userptr);
-    glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC) load("glMultiTexCoord3i", userptr);
-    glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC) load("glMultiTexCoord3iv", userptr);
-    glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC) load("glMultiTexCoord3s", userptr);
-    glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC) load("glMultiTexCoord3sv", userptr);
-    glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC) load("glMultiTexCoord4d", userptr);
-    glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC) load("glMultiTexCoord4dv", userptr);
-    glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC) load("glMultiTexCoord4f", userptr);
-    glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC) load("glMultiTexCoord4fv", userptr);
-    glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC) load("glMultiTexCoord4i", userptr);
-    glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC) load("glMultiTexCoord4iv", userptr);
-    glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC) load("glMultiTexCoord4s", userptr);
-    glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC) load("glMultiTexCoord4sv", userptr);
-    glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_4( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_4) return;
-    glBlendColor = (PFNGLBLENDCOLORPROC) load("glBlendColor", userptr);
-    glBlendEquation = (PFNGLBLENDEQUATIONPROC) load("glBlendEquation", userptr);
-    glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) load("glBlendFuncSeparate", userptr);
-    glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC) load("glFogCoordPointer", userptr);
-    glFogCoordd = (PFNGLFOGCOORDDPROC) load("glFogCoordd", userptr);
-    glFogCoorddv = (PFNGLFOGCOORDDVPROC) load("glFogCoorddv", userptr);
-    glFogCoordf = (PFNGLFOGCOORDFPROC) load("glFogCoordf", userptr);
-    glFogCoordfv = (PFNGLFOGCOORDFVPROC) load("glFogCoordfv", userptr);
-    glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC) load("glMultiDrawArrays", userptr);
-    glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC) load("glMultiDrawElements", userptr);
-    glPointParameterf = (PFNGLPOINTPARAMETERFPROC) load("glPointParameterf", userptr);
-    glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC) load("glPointParameterfv", userptr);
-    glPointParameteri = (PFNGLPOINTPARAMETERIPROC) load("glPointParameteri", userptr);
-    glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC) load("glPointParameteriv", userptr);
-    glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC) load("glSecondaryColor3b", userptr);
-    glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC) load("glSecondaryColor3bv", userptr);
-    glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC) load("glSecondaryColor3d", userptr);
-    glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC) load("glSecondaryColor3dv", userptr);
-    glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC) load("glSecondaryColor3f", userptr);
-    glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC) load("glSecondaryColor3fv", userptr);
-    glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC) load("glSecondaryColor3i", userptr);
-    glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC) load("glSecondaryColor3iv", userptr);
-    glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC) load("glSecondaryColor3s", userptr);
-    glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC) load("glSecondaryColor3sv", userptr);
-    glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC) load("glSecondaryColor3ub", userptr);
-    glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC) load("glSecondaryColor3ubv", userptr);
-    glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC) load("glSecondaryColor3ui", userptr);
-    glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC) load("glSecondaryColor3uiv", userptr);
-    glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC) load("glSecondaryColor3us", userptr);
-    glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC) load("glSecondaryColor3usv", userptr);
-    glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC) load("glSecondaryColorPointer", userptr);
-    glWindowPos2d = (PFNGLWINDOWPOS2DPROC) load("glWindowPos2d", userptr);
-    glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC) load("glWindowPos2dv", userptr);
-    glWindowPos2f = (PFNGLWINDOWPOS2FPROC) load("glWindowPos2f", userptr);
-    glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC) load("glWindowPos2fv", userptr);
-    glWindowPos2i = (PFNGLWINDOWPOS2IPROC) load("glWindowPos2i", userptr);
-    glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC) load("glWindowPos2iv", userptr);
-    glWindowPos2s = (PFNGLWINDOWPOS2SPROC) load("glWindowPos2s", userptr);
-    glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC) load("glWindowPos2sv", userptr);
-    glWindowPos3d = (PFNGLWINDOWPOS3DPROC) load("glWindowPos3d", userptr);
-    glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC) load("glWindowPos3dv", userptr);
-    glWindowPos3f = (PFNGLWINDOWPOS3FPROC) load("glWindowPos3f", userptr);
-    glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC) load("glWindowPos3fv", userptr);
-    glWindowPos3i = (PFNGLWINDOWPOS3IPROC) load("glWindowPos3i", userptr);
-    glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC) load("glWindowPos3iv", userptr);
-    glWindowPos3s = (PFNGLWINDOWPOS3SPROC) load("glWindowPos3s", userptr);
-    glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC) load("glWindowPos3sv", userptr);
-}
-static void glad_gl_load_GL_VERSION_1_5( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_1_5) return;
-    glBeginQuery = (PFNGLBEGINQUERYPROC) load("glBeginQuery", userptr);
-    glBindBuffer = (PFNGLBINDBUFFERPROC) load("glBindBuffer", userptr);
-    glBufferData = (PFNGLBUFFERDATAPROC) load("glBufferData", userptr);
-    glBufferSubData = (PFNGLBUFFERSUBDATAPROC) load("glBufferSubData", userptr);
-    glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) load("glDeleteBuffers", userptr);
-    glDeleteQueries = (PFNGLDELETEQUERIESPROC) load("glDeleteQueries", userptr);
-    glEndQuery = (PFNGLENDQUERYPROC) load("glEndQuery", userptr);
-    glGenBuffers = (PFNGLGENBUFFERSPROC) load("glGenBuffers", userptr);
-    glGenQueries = (PFNGLGENQUERIESPROC) load("glGenQueries", userptr);
-    glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC) load("glGetBufferParameteriv", userptr);
-    glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC) load("glGetBufferPointerv", userptr);
-    glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC) load("glGetBufferSubData", userptr);
-    glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) load("glGetQueryObjectiv", userptr);
-    glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) load("glGetQueryObjectuiv", userptr);
-    glGetQueryiv = (PFNGLGETQUERYIVPROC) load("glGetQueryiv", userptr);
-    glIsBuffer = (PFNGLISBUFFERPROC) load("glIsBuffer", userptr);
-    glIsQuery = (PFNGLISQUERYPROC) load("glIsQuery", userptr);
-    glMapBuffer = (PFNGLMAPBUFFERPROC) load("glMapBuffer", userptr);
-    glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) load("glUnmapBuffer", userptr);
-}
-static void glad_gl_load_GL_VERSION_2_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_2_0) return;
-    glAttachShader = (PFNGLATTACHSHADERPROC) load("glAttachShader", userptr);
-    glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) load("glBindAttribLocation", userptr);
-    glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) load("glBlendEquationSeparate", userptr);
-    glCompileShader = (PFNGLCOMPILESHADERPROC) load("glCompileShader", userptr);
-    glCreateProgram = (PFNGLCREATEPROGRAMPROC) load("glCreateProgram", userptr);
-    glCreateShader = (PFNGLCREATESHADERPROC) load("glCreateShader", userptr);
-    glDeleteProgram = (PFNGLDELETEPROGRAMPROC) load("glDeleteProgram", userptr);
-    glDeleteShader = (PFNGLDELETESHADERPROC) load("glDeleteShader", userptr);
-    glDetachShader = (PFNGLDETACHSHADERPROC) load("glDetachShader", userptr);
-    glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) load("glDisableVertexAttribArray", userptr);
-    glDrawBuffers = (PFNGLDRAWBUFFERSPROC) load("glDrawBuffers", userptr);
-    glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) load("glEnableVertexAttribArray", userptr);
-    glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC) load("glGetActiveAttrib", userptr);
-    glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) load("glGetActiveUniform", userptr);
-    glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC) load("glGetAttachedShaders", userptr);
-    glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) load("glGetAttribLocation", userptr);
-    glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) load("glGetProgramInfoLog", userptr);
-    glGetProgramiv = (PFNGLGETPROGRAMIVPROC) load("glGetProgramiv", userptr);
-    glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) load("glGetShaderInfoLog", userptr);
-    glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) load("glGetShaderSource", userptr);
-    glGetShaderiv = (PFNGLGETSHADERIVPROC) load("glGetShaderiv", userptr);
-    glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) load("glGetUniformLocation", userptr);
-    glGetUniformfv = (PFNGLGETUNIFORMFVPROC) load("glGetUniformfv", userptr);
-    glGetUniformiv = (PFNGLGETUNIFORMIVPROC) load("glGetUniformiv", userptr);
-    glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC) load("glGetVertexAttribPointerv", userptr);
-    glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC) load("glGetVertexAttribdv", userptr);
-    glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC) load("glGetVertexAttribfv", userptr);
-    glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC) load("glGetVertexAttribiv", userptr);
-    glIsProgram = (PFNGLISPROGRAMPROC) load("glIsProgram", userptr);
-    glIsShader = (PFNGLISSHADERPROC) load("glIsShader", userptr);
-    glLinkProgram = (PFNGLLINKPROGRAMPROC) load("glLinkProgram", userptr);
-    glShaderSource = (PFNGLSHADERSOURCEPROC) load("glShaderSource", userptr);
-    glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) load("glStencilFuncSeparate", userptr);
-    glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC) load("glStencilMaskSeparate", userptr);
-    glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) load("glStencilOpSeparate", userptr);
-    glUniform1f = (PFNGLUNIFORM1FPROC) load("glUniform1f", userptr);
-    glUniform1fv = (PFNGLUNIFORM1FVPROC) load("glUniform1fv", userptr);
-    glUniform1i = (PFNGLUNIFORM1IPROC) load("glUniform1i", userptr);
-    glUniform1iv = (PFNGLUNIFORM1IVPROC) load("glUniform1iv", userptr);
-    glUniform2f = (PFNGLUNIFORM2FPROC) load("glUniform2f", userptr);
-    glUniform2fv = (PFNGLUNIFORM2FVPROC) load("glUniform2fv", userptr);
-    glUniform2i = (PFNGLUNIFORM2IPROC) load("glUniform2i", userptr);
-    glUniform2iv = (PFNGLUNIFORM2IVPROC) load("glUniform2iv", userptr);
-    glUniform3f = (PFNGLUNIFORM3FPROC) load("glUniform3f", userptr);
-    glUniform3fv = (PFNGLUNIFORM3FVPROC) load("glUniform3fv", userptr);
-    glUniform3i = (PFNGLUNIFORM3IPROC) load("glUniform3i", userptr);
-    glUniform3iv = (PFNGLUNIFORM3IVPROC) load("glUniform3iv", userptr);
-    glUniform4f = (PFNGLUNIFORM4FPROC) load("glUniform4f", userptr);
-    glUniform4fv = (PFNGLUNIFORM4FVPROC) load("glUniform4fv", userptr);
-    glUniform4i = (PFNGLUNIFORM4IPROC) load("glUniform4i", userptr);
-    glUniform4iv = (PFNGLUNIFORM4IVPROC) load("glUniform4iv", userptr);
-    glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC) load("glUniformMatrix2fv", userptr);
-    glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) load("glUniformMatrix3fv", userptr);
-    glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) load("glUniformMatrix4fv", userptr);
-    glUseProgram = (PFNGLUSEPROGRAMPROC) load("glUseProgram", userptr);
-    glValidateProgram = (PFNGLVALIDATEPROGRAMPROC) load("glValidateProgram", userptr);
-    glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC) load("glVertexAttrib1d", userptr);
-    glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC) load("glVertexAttrib1dv", userptr);
-    glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) load("glVertexAttrib1f", userptr);
-    glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) load("glVertexAttrib1fv", userptr);
-    glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC) load("glVertexAttrib1s", userptr);
-    glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC) load("glVertexAttrib1sv", userptr);
-    glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC) load("glVertexAttrib2d", userptr);
-    glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC) load("glVertexAttrib2dv", userptr);
-    glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) load("glVertexAttrib2f", userptr);
-    glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) load("glVertexAttrib2fv", userptr);
-    glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC) load("glVertexAttrib2s", userptr);
-    glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC) load("glVertexAttrib2sv", userptr);
-    glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC) load("glVertexAttrib3d", userptr);
-    glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC) load("glVertexAttrib3dv", userptr);
-    glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) load("glVertexAttrib3f", userptr);
-    glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) load("glVertexAttrib3fv", userptr);
-    glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC) load("glVertexAttrib3s", userptr);
-    glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC) load("glVertexAttrib3sv", userptr);
-    glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC) load("glVertexAttrib4Nbv", userptr);
-    glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC) load("glVertexAttrib4Niv", userptr);
-    glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC) load("glVertexAttrib4Nsv", userptr);
-    glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC) load("glVertexAttrib4Nub", userptr);
-    glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC) load("glVertexAttrib4Nubv", userptr);
-    glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC) load("glVertexAttrib4Nuiv", userptr);
-    glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC) load("glVertexAttrib4Nusv", userptr);
-    glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC) load("glVertexAttrib4bv", userptr);
-    glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC) load("glVertexAttrib4d", userptr);
-    glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC) load("glVertexAttrib4dv", userptr);
-    glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) load("glVertexAttrib4f", userptr);
-    glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) load("glVertexAttrib4fv", userptr);
-    glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC) load("glVertexAttrib4iv", userptr);
-    glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC) load("glVertexAttrib4s", userptr);
-    glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC) load("glVertexAttrib4sv", userptr);
-    glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC) load("glVertexAttrib4ubv", userptr);
-    glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC) load("glVertexAttrib4uiv", userptr);
-    glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC) load("glVertexAttrib4usv", userptr);
-    glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) load("glVertexAttribPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_2_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_2_1) return;
-    glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC) load("glUniformMatrix2x3fv", userptr);
-    glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC) load("glUniformMatrix2x4fv", userptr);
-    glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC) load("glUniformMatrix3x2fv", userptr);
-    glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC) load("glUniformMatrix3x4fv", userptr);
-    glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC) load("glUniformMatrix4x2fv", userptr);
-    glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC) load("glUniformMatrix4x3fv", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_0) return;
-    glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC) load("glBeginConditionalRender", userptr);
-    glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC) load("glBeginTransformFeedback", userptr);
-    glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr);
-    glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr);
-    glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC) load("glBindFragDataLocation", userptr);
-    glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) load("glBindFramebuffer", userptr);
-    glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) load("glBindRenderbuffer", userptr);
-    glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) load("glBindVertexArray", userptr);
-    glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC) load("glBlitFramebuffer", userptr);
-    glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) load("glCheckFramebufferStatus", userptr);
-    glClampColor = (PFNGLCLAMPCOLORPROC) load("glClampColor", userptr);
-    glClearBufferfi = (PFNGLCLEARBUFFERFIPROC) load("glClearBufferfi", userptr);
-    glClearBufferfv = (PFNGLCLEARBUFFERFVPROC) load("glClearBufferfv", userptr);
-    glClearBufferiv = (PFNGLCLEARBUFFERIVPROC) load("glClearBufferiv", userptr);
-    glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC) load("glClearBufferuiv", userptr);
-    glColorMaski = (PFNGLCOLORMASKIPROC) load("glColorMaski", userptr);
-    glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) load("glDeleteFramebuffers", userptr);
-    glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) load("glDeleteRenderbuffers", userptr);
-    glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) load("glDeleteVertexArrays", userptr);
-    glDisablei = (PFNGLDISABLEIPROC) load("glDisablei", userptr);
-    glEnablei = (PFNGLENABLEIPROC) load("glEnablei", userptr);
-    glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC) load("glEndConditionalRender", userptr);
-    glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC) load("glEndTransformFeedback", userptr);
-    glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC) load("glFlushMappedBufferRange", userptr);
-    glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) load("glFramebufferRenderbuffer", userptr);
-    glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) load("glFramebufferTexture1D", userptr);
-    glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) load("glFramebufferTexture2D", userptr);
-    glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) load("glFramebufferTexture3D", userptr);
-    glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) load("glFramebufferTextureLayer", userptr);
-    glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) load("glGenFramebuffers", userptr);
-    glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) load("glGenRenderbuffers", userptr);
-    glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) load("glGenVertexArrays", userptr);
-    glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) load("glGenerateMipmap", userptr);
-    glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC) load("glGetBooleani_v", userptr);
-    glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC) load("glGetFragDataLocation", userptr);
-    glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) load("glGetFramebufferAttachmentParameteriv", userptr);
-    glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr);
-    glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) load("glGetRenderbufferParameteriv", userptr);
-    glGetStringi = (PFNGLGETSTRINGIPROC) load("glGetStringi", userptr);
-    glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC) load("glGetTexParameterIiv", userptr);
-    glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC) load("glGetTexParameterIuiv", userptr);
-    glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) load("glGetTransformFeedbackVarying", userptr);
-    glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC) load("glGetUniformuiv", userptr);
-    glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC) load("glGetVertexAttribIiv", userptr);
-    glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC) load("glGetVertexAttribIuiv", userptr);
-    glIsEnabledi = (PFNGLISENABLEDIPROC) load("glIsEnabledi", userptr);
-    glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) load("glIsFramebuffer", userptr);
-    glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) load("glIsRenderbuffer", userptr);
-    glIsVertexArray = (PFNGLISVERTEXARRAYPROC) load("glIsVertexArray", userptr);
-    glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC) load("glMapBufferRange", userptr);
-    glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) load("glRenderbufferStorage", userptr);
-    glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) load("glRenderbufferStorageMultisample", userptr);
-    glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC) load("glTexParameterIiv", userptr);
-    glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC) load("glTexParameterIuiv", userptr);
-    glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC) load("glTransformFeedbackVaryings", userptr);
-    glUniform1ui = (PFNGLUNIFORM1UIPROC) load("glUniform1ui", userptr);
-    glUniform1uiv = (PFNGLUNIFORM1UIVPROC) load("glUniform1uiv", userptr);
-    glUniform2ui = (PFNGLUNIFORM2UIPROC) load("glUniform2ui", userptr);
-    glUniform2uiv = (PFNGLUNIFORM2UIVPROC) load("glUniform2uiv", userptr);
-    glUniform3ui = (PFNGLUNIFORM3UIPROC) load("glUniform3ui", userptr);
-    glUniform3uiv = (PFNGLUNIFORM3UIVPROC) load("glUniform3uiv", userptr);
-    glUniform4ui = (PFNGLUNIFORM4UIPROC) load("glUniform4ui", userptr);
-    glUniform4uiv = (PFNGLUNIFORM4UIVPROC) load("glUniform4uiv", userptr);
-    glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC) load("glVertexAttribI1i", userptr);
-    glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC) load("glVertexAttribI1iv", userptr);
-    glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC) load("glVertexAttribI1ui", userptr);
-    glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC) load("glVertexAttribI1uiv", userptr);
-    glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC) load("glVertexAttribI2i", userptr);
-    glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC) load("glVertexAttribI2iv", userptr);
-    glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC) load("glVertexAttribI2ui", userptr);
-    glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC) load("glVertexAttribI2uiv", userptr);
-    glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC) load("glVertexAttribI3i", userptr);
-    glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC) load("glVertexAttribI3iv", userptr);
-    glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC) load("glVertexAttribI3ui", userptr);
-    glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC) load("glVertexAttribI3uiv", userptr);
-    glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC) load("glVertexAttribI4bv", userptr);
-    glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC) load("glVertexAttribI4i", userptr);
-    glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC) load("glVertexAttribI4iv", userptr);
-    glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC) load("glVertexAttribI4sv", userptr);
-    glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC) load("glVertexAttribI4ubv", userptr);
-    glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC) load("glVertexAttribI4ui", userptr);
-    glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC) load("glVertexAttribI4uiv", userptr);
-    glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC) load("glVertexAttribI4usv", userptr);
-    glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC) load("glVertexAttribIPointer", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_1) return;
-    glBindBufferBase = (PFNGLBINDBUFFERBASEPROC) load("glBindBufferBase", userptr);
-    glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC) load("glBindBufferRange", userptr);
-    glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC) load("glCopyBufferSubData", userptr);
-    glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC) load("glDrawArraysInstanced", userptr);
-    glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC) load("glDrawElementsInstanced", userptr);
-    glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) load("glGetActiveUniformBlockName", userptr);
-    glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC) load("glGetActiveUniformBlockiv", userptr);
-    glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC) load("glGetActiveUniformName", userptr);
-    glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC) load("glGetActiveUniformsiv", userptr);
-    glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC) load("glGetIntegeri_v", userptr);
-    glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC) load("glGetUniformBlockIndex", userptr);
-    glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC) load("glGetUniformIndices", userptr);
-    glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC) load("glPrimitiveRestartIndex", userptr);
-    glTexBuffer = (PFNGLTEXBUFFERPROC) load("glTexBuffer", userptr);
-    glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC) load("glUniformBlockBinding", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_2( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_2) return;
-    glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC) load("glClientWaitSync", userptr);
-    glDeleteSync = (PFNGLDELETESYNCPROC) load("glDeleteSync", userptr);
-    glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC) load("glDrawElementsBaseVertex", userptr);
-    glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) load("glDrawElementsInstancedBaseVertex", userptr);
-    glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) load("glDrawRangeElementsBaseVertex", userptr);
-    glFenceSync = (PFNGLFENCESYNCPROC) load("glFenceSync", userptr);
-    glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC) load("glFramebufferTexture", userptr);
-    glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC) load("glGetBufferParameteri64v", userptr);
-    glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC) load("glGetInteger64i_v", userptr);
-    glGetInteger64v = (PFNGLGETINTEGER64VPROC) load("glGetInteger64v", userptr);
-    glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC) load("glGetMultisamplefv", userptr);
-    glGetSynciv = (PFNGLGETSYNCIVPROC) load("glGetSynciv", userptr);
-    glIsSync = (PFNGLISSYNCPROC) load("glIsSync", userptr);
-    glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) load("glMultiDrawElementsBaseVertex", userptr);
-    glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC) load("glProvokingVertex", userptr);
-    glSampleMaski = (PFNGLSAMPLEMASKIPROC) load("glSampleMaski", userptr);
-    glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC) load("glTexImage2DMultisample", userptr);
-    glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC) load("glTexImage3DMultisample", userptr);
-    glWaitSync = (PFNGLWAITSYNCPROC) load("glWaitSync", userptr);
-}
-static void glad_gl_load_GL_VERSION_3_3( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_VERSION_3_3) return;
-    glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) load("glBindFragDataLocationIndexed", userptr);
-    glBindSampler = (PFNGLBINDSAMPLERPROC) load("glBindSampler", userptr);
-    glColorP3ui = (PFNGLCOLORP3UIPROC) load("glColorP3ui", userptr);
-    glColorP3uiv = (PFNGLCOLORP3UIVPROC) load("glColorP3uiv", userptr);
-    glColorP4ui = (PFNGLCOLORP4UIPROC) load("glColorP4ui", userptr);
-    glColorP4uiv = (PFNGLCOLORP4UIVPROC) load("glColorP4uiv", userptr);
-    glDeleteSamplers = (PFNGLDELETESAMPLERSPROC) load("glDeleteSamplers", userptr);
-    glGenSamplers = (PFNGLGENSAMPLERSPROC) load("glGenSamplers", userptr);
-    glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC) load("glGetFragDataIndex", userptr);
-    glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC) load("glGetQueryObjecti64v", userptr);
-    glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) load("glGetQueryObjectui64v", userptr);
-    glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC) load("glGetSamplerParameterIiv", userptr);
-    glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC) load("glGetSamplerParameterIuiv", userptr);
-    glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC) load("glGetSamplerParameterfv", userptr);
-    glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC) load("glGetSamplerParameteriv", userptr);
-    glIsSampler = (PFNGLISSAMPLERPROC) load("glIsSampler", userptr);
-    glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC) load("glMultiTexCoordP1ui", userptr);
-    glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC) load("glMultiTexCoordP1uiv", userptr);
-    glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC) load("glMultiTexCoordP2ui", userptr);
-    glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC) load("glMultiTexCoordP2uiv", userptr);
-    glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC) load("glMultiTexCoordP3ui", userptr);
-    glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC) load("glMultiTexCoordP3uiv", userptr);
-    glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC) load("glMultiTexCoordP4ui", userptr);
-    glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC) load("glMultiTexCoordP4uiv", userptr);
-    glNormalP3ui = (PFNGLNORMALP3UIPROC) load("glNormalP3ui", userptr);
-    glNormalP3uiv = (PFNGLNORMALP3UIVPROC) load("glNormalP3uiv", userptr);
-    glQueryCounter = (PFNGLQUERYCOUNTERPROC) load("glQueryCounter", userptr);
-    glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC) load("glSamplerParameterIiv", userptr);
-    glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC) load("glSamplerParameterIuiv", userptr);
-    glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC) load("glSamplerParameterf", userptr);
-    glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC) load("glSamplerParameterfv", userptr);
-    glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC) load("glSamplerParameteri", userptr);
-    glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC) load("glSamplerParameteriv", userptr);
-    glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC) load("glSecondaryColorP3ui", userptr);
-    glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC) load("glSecondaryColorP3uiv", userptr);
-    glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC) load("glTexCoordP1ui", userptr);
-    glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC) load("glTexCoordP1uiv", userptr);
-    glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC) load("glTexCoordP2ui", userptr);
-    glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC) load("glTexCoordP2uiv", userptr);
-    glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC) load("glTexCoordP3ui", userptr);
-    glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC) load("glTexCoordP3uiv", userptr);
-    glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC) load("glTexCoordP4ui", userptr);
-    glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC) load("glTexCoordP4uiv", userptr);
-    glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC) load("glVertexAttribDivisor", userptr);
-    glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC) load("glVertexAttribP1ui", userptr);
-    glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC) load("glVertexAttribP1uiv", userptr);
-    glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC) load("glVertexAttribP2ui", userptr);
-    glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC) load("glVertexAttribP2uiv", userptr);
-    glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC) load("glVertexAttribP3ui", userptr);
-    glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC) load("glVertexAttribP3uiv", userptr);
-    glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC) load("glVertexAttribP4ui", userptr);
-    glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC) load("glVertexAttribP4uiv", userptr);
-    glVertexP2ui = (PFNGLVERTEXP2UIPROC) load("glVertexP2ui", userptr);
-    glVertexP2uiv = (PFNGLVERTEXP2UIVPROC) load("glVertexP2uiv", userptr);
-    glVertexP3ui = (PFNGLVERTEXP3UIPROC) load("glVertexP3ui", userptr);
-    glVertexP3uiv = (PFNGLVERTEXP3UIVPROC) load("glVertexP3uiv", userptr);
-    glVertexP4ui = (PFNGLVERTEXP4UIPROC) load("glVertexP4ui", userptr);
-    glVertexP4uiv = (PFNGLVERTEXP4UIVPROC) load("glVertexP4uiv", userptr);
-}
-static void glad_gl_load_GL_ARB_multisample( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_ARB_multisample) return;
-    glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC) load("glSampleCoverage", userptr);
-    glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC) load("glSampleCoverageARB", userptr);
-}
-static void glad_gl_load_GL_ARB_robustness( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_ARB_robustness) return;
-    glGetGraphicsResetStatusARB = (PFNGLGETGRAPHICSRESETSTATUSARBPROC) load("glGetGraphicsResetStatusARB", userptr);
-    glGetnColorTableARB = (PFNGLGETNCOLORTABLEARBPROC) load("glGetnColorTableARB", userptr);
-    glGetnCompressedTexImageARB = (PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) load("glGetnCompressedTexImageARB", userptr);
-    glGetnConvolutionFilterARB = (PFNGLGETNCONVOLUTIONFILTERARBPROC) load("glGetnConvolutionFilterARB", userptr);
-    glGetnHistogramARB = (PFNGLGETNHISTOGRAMARBPROC) load("glGetnHistogramARB", userptr);
-    glGetnMapdvARB = (PFNGLGETNMAPDVARBPROC) load("glGetnMapdvARB", userptr);
-    glGetnMapfvARB = (PFNGLGETNMAPFVARBPROC) load("glGetnMapfvARB", userptr);
-    glGetnMapivARB = (PFNGLGETNMAPIVARBPROC) load("glGetnMapivARB", userptr);
-    glGetnMinmaxARB = (PFNGLGETNMINMAXARBPROC) load("glGetnMinmaxARB", userptr);
-    glGetnPixelMapfvARB = (PFNGLGETNPIXELMAPFVARBPROC) load("glGetnPixelMapfvARB", userptr);
-    glGetnPixelMapuivARB = (PFNGLGETNPIXELMAPUIVARBPROC) load("glGetnPixelMapuivARB", userptr);
-    glGetnPixelMapusvARB = (PFNGLGETNPIXELMAPUSVARBPROC) load("glGetnPixelMapusvARB", userptr);
-    glGetnPolygonStippleARB = (PFNGLGETNPOLYGONSTIPPLEARBPROC) load("glGetnPolygonStippleARB", userptr);
-    glGetnSeparableFilterARB = (PFNGLGETNSEPARABLEFILTERARBPROC) load("glGetnSeparableFilterARB", userptr);
-    glGetnTexImageARB = (PFNGLGETNTEXIMAGEARBPROC) load("glGetnTexImageARB", userptr);
-    glGetnUniformdvARB = (PFNGLGETNUNIFORMDVARBPROC) load("glGetnUniformdvARB", userptr);
-    glGetnUniformfvARB = (PFNGLGETNUNIFORMFVARBPROC) load("glGetnUniformfvARB", userptr);
-    glGetnUniformivARB = (PFNGLGETNUNIFORMIVARBPROC) load("glGetnUniformivARB", userptr);
-    glGetnUniformuivARB = (PFNGLGETNUNIFORMUIVARBPROC) load("glGetnUniformuivARB", userptr);
-    glReadnPixels = (PFNGLREADNPIXELSPROC) load("glReadnPixels", userptr);
-    glReadnPixelsARB = (PFNGLREADNPIXELSARBPROC) load("glReadnPixelsARB", userptr);
-}
-static void glad_gl_load_GL_KHR_debug( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_GL_KHR_debug) return;
-    glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC) load("glDebugMessageCallback", userptr);
-    glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC) load("glDebugMessageControl", userptr);
-    glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC) load("glDebugMessageInsert", userptr);
-    glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC) load("glGetDebugMessageLog", userptr);
-    glGetObjectLabel = (PFNGLGETOBJECTLABELPROC) load("glGetObjectLabel", userptr);
-    glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC) load("glGetObjectPtrLabel", userptr);
-    glGetPointerv = (PFNGLGETPOINTERVPROC) load("glGetPointerv", userptr);
-    glObjectLabel = (PFNGLOBJECTLABELPROC) load("glObjectLabel", userptr);
-    glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC) load("glObjectPtrLabel", userptr);
-    glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC) load("glPopDebugGroup", userptr);
-    glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC) load("glPushDebugGroup", userptr);
-}
-
-
-
-#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
-#define GLAD_GL_IS_SOME_NEW_VERSION 1
-#else
-#define GLAD_GL_IS_SOME_NEW_VERSION 0
-#endif
-
-static int glad_gl_get_extensions( int version, const char **out_exts, unsigned int *out_num_exts_i, char ***out_exts_i) {
-#if GLAD_GL_IS_SOME_NEW_VERSION
-    if(GLAD_VERSION_MAJOR(version) < 3) {
-#else
-    (void) version;
-    (void) out_num_exts_i;
-    (void) out_exts_i;
-#endif
-        if (glGetString == NULL) {
-            return 0;
-        }
-        *out_exts = (const char *)glGetString(GL_EXTENSIONS);
-#if GLAD_GL_IS_SOME_NEW_VERSION
-    } else {
-        unsigned int index = 0;
-        unsigned int num_exts_i = 0;
-        char **exts_i = NULL;
-        if (glGetStringi == NULL || glGetIntegerv == NULL) {
-            return 0;
-        }
-        glGetIntegerv(GL_NUM_EXTENSIONS, (int*) &num_exts_i);
-        if (num_exts_i > 0) {
-            exts_i = (char **) malloc(num_exts_i * (sizeof *exts_i));
-        }
-        if (exts_i == NULL) {
-            return 0;
-        }
-        for(index = 0; index < num_exts_i; index++) {
-            const char *gl_str_tmp = (const char*) glGetStringi(GL_EXTENSIONS, index);
-            size_t len = strlen(gl_str_tmp) + 1;
-
-            char *local_str = (char*) malloc(len * sizeof(char));
-            if(local_str != NULL) {
-                memcpy(local_str, gl_str_tmp, len * sizeof(char));
-            }
-
-            exts_i[index] = local_str;
-        }
-
-        *out_num_exts_i = num_exts_i;
-        *out_exts_i = exts_i;
-    }
-#endif
-    return 1;
-}
-static void glad_gl_free_extensions(char **exts_i, unsigned int num_exts_i) {
-    if (exts_i != NULL) {
-        unsigned int index;
-        for(index = 0; index < num_exts_i; index++) {
-            free((void *) (exts_i[index]));
-        }
-        free((void *)exts_i);
-        exts_i = NULL;
-    }
-}
-static int glad_gl_has_extension(int version, const char *exts, unsigned int num_exts_i, char **exts_i, const char *ext) {
-    if(GLAD_VERSION_MAJOR(version) < 3 || !GLAD_GL_IS_SOME_NEW_VERSION) {
-        const char *extensions;
-        const char *loc;
-        const char *terminator;
-        extensions = exts;
-        if(extensions == NULL || ext == NULL) {
-            return 0;
-        }
-        while(1) {
-            loc = strstr(extensions, ext);
-            if(loc == NULL) {
-                return 0;
-            }
-            terminator = loc + strlen(ext);
-            if((loc == extensions || *(loc - 1) == ' ') &&
-                (*terminator == ' ' || *terminator == '\0')) {
-                return 1;
-            }
-            extensions = terminator;
-        }
-    } else {
-        unsigned int index;
-        for(index = 0; index < num_exts_i; index++) {
-            const char *e = exts_i[index];
-            if(strcmp(e, ext) == 0) {
-                return 1;
-            }
-        }
-    }
-    return 0;
-}
-
-static GLADapiproc glad_gl_get_proc_from_userptr(const char* name, void *userptr) {
-    return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
-}
-
-static int glad_gl_find_extensions_gl( int version) {
-    const char *exts = NULL;
-    unsigned int num_exts_i = 0;
-    char **exts_i = NULL;
-    if (!glad_gl_get_extensions(version, &exts, &num_exts_i, &exts_i)) return 0;
-
-    GLAD_GL_ARB_multisample = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_multisample");
-    GLAD_GL_ARB_robustness = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_ARB_robustness");
-    GLAD_GL_KHR_debug = glad_gl_has_extension(version, exts, num_exts_i, exts_i, "GL_KHR_debug");
-
-    glad_gl_free_extensions(exts_i, num_exts_i);
-
-    return 1;
-}
-
-static int glad_gl_find_core_gl(void) {
-    int i, major, minor;
-    const char* version;
-    const char* prefixes[] = {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-    version = (const char*) glGetString(GL_VERSION);
-    if (!version) return 0;
-    for (i = 0;  prefixes[i];  i++) {
-        const size_t length = strlen(prefixes[i]);
-        if (strncmp(version, prefixes[i], length) == 0) {
-            version += length;
-            break;
-        }
-    }
-
-    GLAD_IMPL_UTIL_SSCANF(version, "%d.%d", &major, &minor);
-
-    GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-    GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-    GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
-    GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
-    GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
-    GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
-    GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
-    GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
-    GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
-    GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
-    GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
-    GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
-
-    return GLAD_MAKE_VERSION(major, minor);
-}
-
-int gladLoadGLUserPtr( GLADuserptrloadfunc load, void *userptr) {
-    int version;
-
-    glGetString = (PFNGLGETSTRINGPROC) load("glGetString", userptr);
-    if(glGetString == NULL) return 0;
-    if(glGetString(GL_VERSION) == NULL) return 0;
-    version = glad_gl_find_core_gl();
-
-    glad_gl_load_GL_VERSION_1_0(load, userptr);
-    glad_gl_load_GL_VERSION_1_1(load, userptr);
-    glad_gl_load_GL_VERSION_1_2(load, userptr);
-    glad_gl_load_GL_VERSION_1_3(load, userptr);
-    glad_gl_load_GL_VERSION_1_4(load, userptr);
-    glad_gl_load_GL_VERSION_1_5(load, userptr);
-    glad_gl_load_GL_VERSION_2_0(load, userptr);
-    glad_gl_load_GL_VERSION_2_1(load, userptr);
-    glad_gl_load_GL_VERSION_3_0(load, userptr);
-    glad_gl_load_GL_VERSION_3_1(load, userptr);
-    glad_gl_load_GL_VERSION_3_2(load, userptr);
-    glad_gl_load_GL_VERSION_3_3(load, userptr);
-
-    if (!glad_gl_find_extensions_gl(version)) return 0;
-    glad_gl_load_GL_ARB_multisample(load, userptr);
-    glad_gl_load_GL_ARB_robustness(load, userptr);
-    glad_gl_load_GL_KHR_debug(load, userptr);
-
-
-
-    return version;
-}
-
-
-int gladLoadGL( GLADloadfunc load) {
-    return gladLoadGLUserPtr( glad_gl_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
-}
-
-
-
-
diff --git a/raylib_pi4_test/external/glfw/deps/glad_vulkan.c b/raylib_pi4_test/external/glfw/deps/glad_vulkan.c
deleted file mode 100644 (file)
index 5adfbbb..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glad/vulkan.h>
-
-#ifndef GLAD_IMPL_UTIL_C_
-#define GLAD_IMPL_UTIL_C_
-
-#ifdef _MSC_VER
-#define GLAD_IMPL_UTIL_SSCANF sscanf_s
-#else
-#define GLAD_IMPL_UTIL_SSCANF sscanf
-#endif
-
-#endif /* GLAD_IMPL_UTIL_C_ */
-
-
-int GLAD_VK_VERSION_1_0 = 0;
-int GLAD_VK_VERSION_1_1 = 0;
-int GLAD_VK_EXT_debug_report = 0;
-int GLAD_VK_KHR_surface = 0;
-int GLAD_VK_KHR_swapchain = 0;
-
-
-
-PFN_vkAcquireNextImage2KHR glad_vkAcquireNextImage2KHR = NULL;
-PFN_vkAcquireNextImageKHR glad_vkAcquireNextImageKHR = NULL;
-PFN_vkAllocateCommandBuffers glad_vkAllocateCommandBuffers = NULL;
-PFN_vkAllocateDescriptorSets glad_vkAllocateDescriptorSets = NULL;
-PFN_vkAllocateMemory glad_vkAllocateMemory = NULL;
-PFN_vkBeginCommandBuffer glad_vkBeginCommandBuffer = NULL;
-PFN_vkBindBufferMemory glad_vkBindBufferMemory = NULL;
-PFN_vkBindBufferMemory2 glad_vkBindBufferMemory2 = NULL;
-PFN_vkBindImageMemory glad_vkBindImageMemory = NULL;
-PFN_vkBindImageMemory2 glad_vkBindImageMemory2 = NULL;
-PFN_vkCmdBeginQuery glad_vkCmdBeginQuery = NULL;
-PFN_vkCmdBeginRenderPass glad_vkCmdBeginRenderPass = NULL;
-PFN_vkCmdBindDescriptorSets glad_vkCmdBindDescriptorSets = NULL;
-PFN_vkCmdBindIndexBuffer glad_vkCmdBindIndexBuffer = NULL;
-PFN_vkCmdBindPipeline glad_vkCmdBindPipeline = NULL;
-PFN_vkCmdBindVertexBuffers glad_vkCmdBindVertexBuffers = NULL;
-PFN_vkCmdBlitImage glad_vkCmdBlitImage = NULL;
-PFN_vkCmdClearAttachments glad_vkCmdClearAttachments = NULL;
-PFN_vkCmdClearColorImage glad_vkCmdClearColorImage = NULL;
-PFN_vkCmdClearDepthStencilImage glad_vkCmdClearDepthStencilImage = NULL;
-PFN_vkCmdCopyBuffer glad_vkCmdCopyBuffer = NULL;
-PFN_vkCmdCopyBufferToImage glad_vkCmdCopyBufferToImage = NULL;
-PFN_vkCmdCopyImage glad_vkCmdCopyImage = NULL;
-PFN_vkCmdCopyImageToBuffer glad_vkCmdCopyImageToBuffer = NULL;
-PFN_vkCmdCopyQueryPoolResults glad_vkCmdCopyQueryPoolResults = NULL;
-PFN_vkCmdDispatch glad_vkCmdDispatch = NULL;
-PFN_vkCmdDispatchBase glad_vkCmdDispatchBase = NULL;
-PFN_vkCmdDispatchIndirect glad_vkCmdDispatchIndirect = NULL;
-PFN_vkCmdDraw glad_vkCmdDraw = NULL;
-PFN_vkCmdDrawIndexed glad_vkCmdDrawIndexed = NULL;
-PFN_vkCmdDrawIndexedIndirect glad_vkCmdDrawIndexedIndirect = NULL;
-PFN_vkCmdDrawIndirect glad_vkCmdDrawIndirect = NULL;
-PFN_vkCmdEndQuery glad_vkCmdEndQuery = NULL;
-PFN_vkCmdEndRenderPass glad_vkCmdEndRenderPass = NULL;
-PFN_vkCmdExecuteCommands glad_vkCmdExecuteCommands = NULL;
-PFN_vkCmdFillBuffer glad_vkCmdFillBuffer = NULL;
-PFN_vkCmdNextSubpass glad_vkCmdNextSubpass = NULL;
-PFN_vkCmdPipelineBarrier glad_vkCmdPipelineBarrier = NULL;
-PFN_vkCmdPushConstants glad_vkCmdPushConstants = NULL;
-PFN_vkCmdResetEvent glad_vkCmdResetEvent = NULL;
-PFN_vkCmdResetQueryPool glad_vkCmdResetQueryPool = NULL;
-PFN_vkCmdResolveImage glad_vkCmdResolveImage = NULL;
-PFN_vkCmdSetBlendConstants glad_vkCmdSetBlendConstants = NULL;
-PFN_vkCmdSetDepthBias glad_vkCmdSetDepthBias = NULL;
-PFN_vkCmdSetDepthBounds glad_vkCmdSetDepthBounds = NULL;
-PFN_vkCmdSetDeviceMask glad_vkCmdSetDeviceMask = NULL;
-PFN_vkCmdSetEvent glad_vkCmdSetEvent = NULL;
-PFN_vkCmdSetLineWidth glad_vkCmdSetLineWidth = NULL;
-PFN_vkCmdSetScissor glad_vkCmdSetScissor = NULL;
-PFN_vkCmdSetStencilCompareMask glad_vkCmdSetStencilCompareMask = NULL;
-PFN_vkCmdSetStencilReference glad_vkCmdSetStencilReference = NULL;
-PFN_vkCmdSetStencilWriteMask glad_vkCmdSetStencilWriteMask = NULL;
-PFN_vkCmdSetViewport glad_vkCmdSetViewport = NULL;
-PFN_vkCmdUpdateBuffer glad_vkCmdUpdateBuffer = NULL;
-PFN_vkCmdWaitEvents glad_vkCmdWaitEvents = NULL;
-PFN_vkCmdWriteTimestamp glad_vkCmdWriteTimestamp = NULL;
-PFN_vkCreateBuffer glad_vkCreateBuffer = NULL;
-PFN_vkCreateBufferView glad_vkCreateBufferView = NULL;
-PFN_vkCreateCommandPool glad_vkCreateCommandPool = NULL;
-PFN_vkCreateComputePipelines glad_vkCreateComputePipelines = NULL;
-PFN_vkCreateDebugReportCallbackEXT glad_vkCreateDebugReportCallbackEXT = NULL;
-PFN_vkCreateDescriptorPool glad_vkCreateDescriptorPool = NULL;
-PFN_vkCreateDescriptorSetLayout glad_vkCreateDescriptorSetLayout = NULL;
-PFN_vkCreateDescriptorUpdateTemplate glad_vkCreateDescriptorUpdateTemplate = NULL;
-PFN_vkCreateDevice glad_vkCreateDevice = NULL;
-PFN_vkCreateEvent glad_vkCreateEvent = NULL;
-PFN_vkCreateFence glad_vkCreateFence = NULL;
-PFN_vkCreateFramebuffer glad_vkCreateFramebuffer = NULL;
-PFN_vkCreateGraphicsPipelines glad_vkCreateGraphicsPipelines = NULL;
-PFN_vkCreateImage glad_vkCreateImage = NULL;
-PFN_vkCreateImageView glad_vkCreateImageView = NULL;
-PFN_vkCreateInstance glad_vkCreateInstance = NULL;
-PFN_vkCreatePipelineCache glad_vkCreatePipelineCache = NULL;
-PFN_vkCreatePipelineLayout glad_vkCreatePipelineLayout = NULL;
-PFN_vkCreateQueryPool glad_vkCreateQueryPool = NULL;
-PFN_vkCreateRenderPass glad_vkCreateRenderPass = NULL;
-PFN_vkCreateSampler glad_vkCreateSampler = NULL;
-PFN_vkCreateSamplerYcbcrConversion glad_vkCreateSamplerYcbcrConversion = NULL;
-PFN_vkCreateSemaphore glad_vkCreateSemaphore = NULL;
-PFN_vkCreateShaderModule glad_vkCreateShaderModule = NULL;
-PFN_vkCreateSwapchainKHR glad_vkCreateSwapchainKHR = NULL;
-PFN_vkDebugReportMessageEXT glad_vkDebugReportMessageEXT = NULL;
-PFN_vkDestroyBuffer glad_vkDestroyBuffer = NULL;
-PFN_vkDestroyBufferView glad_vkDestroyBufferView = NULL;
-PFN_vkDestroyCommandPool glad_vkDestroyCommandPool = NULL;
-PFN_vkDestroyDebugReportCallbackEXT glad_vkDestroyDebugReportCallbackEXT = NULL;
-PFN_vkDestroyDescriptorPool glad_vkDestroyDescriptorPool = NULL;
-PFN_vkDestroyDescriptorSetLayout glad_vkDestroyDescriptorSetLayout = NULL;
-PFN_vkDestroyDescriptorUpdateTemplate glad_vkDestroyDescriptorUpdateTemplate = NULL;
-PFN_vkDestroyDevice glad_vkDestroyDevice = NULL;
-PFN_vkDestroyEvent glad_vkDestroyEvent = NULL;
-PFN_vkDestroyFence glad_vkDestroyFence = NULL;
-PFN_vkDestroyFramebuffer glad_vkDestroyFramebuffer = NULL;
-PFN_vkDestroyImage glad_vkDestroyImage = NULL;
-PFN_vkDestroyImageView glad_vkDestroyImageView = NULL;
-PFN_vkDestroyInstance glad_vkDestroyInstance = NULL;
-PFN_vkDestroyPipeline glad_vkDestroyPipeline = NULL;
-PFN_vkDestroyPipelineCache glad_vkDestroyPipelineCache = NULL;
-PFN_vkDestroyPipelineLayout glad_vkDestroyPipelineLayout = NULL;
-PFN_vkDestroyQueryPool glad_vkDestroyQueryPool = NULL;
-PFN_vkDestroyRenderPass glad_vkDestroyRenderPass = NULL;
-PFN_vkDestroySampler glad_vkDestroySampler = NULL;
-PFN_vkDestroySamplerYcbcrConversion glad_vkDestroySamplerYcbcrConversion = NULL;
-PFN_vkDestroySemaphore glad_vkDestroySemaphore = NULL;
-PFN_vkDestroyShaderModule glad_vkDestroyShaderModule = NULL;
-PFN_vkDestroySurfaceKHR glad_vkDestroySurfaceKHR = NULL;
-PFN_vkDestroySwapchainKHR glad_vkDestroySwapchainKHR = NULL;
-PFN_vkDeviceWaitIdle glad_vkDeviceWaitIdle = NULL;
-PFN_vkEndCommandBuffer glad_vkEndCommandBuffer = NULL;
-PFN_vkEnumerateDeviceExtensionProperties glad_vkEnumerateDeviceExtensionProperties = NULL;
-PFN_vkEnumerateDeviceLayerProperties glad_vkEnumerateDeviceLayerProperties = NULL;
-PFN_vkEnumerateInstanceExtensionProperties glad_vkEnumerateInstanceExtensionProperties = NULL;
-PFN_vkEnumerateInstanceLayerProperties glad_vkEnumerateInstanceLayerProperties = NULL;
-PFN_vkEnumerateInstanceVersion glad_vkEnumerateInstanceVersion = NULL;
-PFN_vkEnumeratePhysicalDeviceGroups glad_vkEnumeratePhysicalDeviceGroups = NULL;
-PFN_vkEnumeratePhysicalDevices glad_vkEnumeratePhysicalDevices = NULL;
-PFN_vkFlushMappedMemoryRanges glad_vkFlushMappedMemoryRanges = NULL;
-PFN_vkFreeCommandBuffers glad_vkFreeCommandBuffers = NULL;
-PFN_vkFreeDescriptorSets glad_vkFreeDescriptorSets = NULL;
-PFN_vkFreeMemory glad_vkFreeMemory = NULL;
-PFN_vkGetBufferMemoryRequirements glad_vkGetBufferMemoryRequirements = NULL;
-PFN_vkGetBufferMemoryRequirements2 glad_vkGetBufferMemoryRequirements2 = NULL;
-PFN_vkGetDescriptorSetLayoutSupport glad_vkGetDescriptorSetLayoutSupport = NULL;
-PFN_vkGetDeviceGroupPeerMemoryFeatures glad_vkGetDeviceGroupPeerMemoryFeatures = NULL;
-PFN_vkGetDeviceGroupPresentCapabilitiesKHR glad_vkGetDeviceGroupPresentCapabilitiesKHR = NULL;
-PFN_vkGetDeviceGroupSurfacePresentModesKHR glad_vkGetDeviceGroupSurfacePresentModesKHR = NULL;
-PFN_vkGetDeviceMemoryCommitment glad_vkGetDeviceMemoryCommitment = NULL;
-PFN_vkGetDeviceProcAddr glad_vkGetDeviceProcAddr = NULL;
-PFN_vkGetDeviceQueue glad_vkGetDeviceQueue = NULL;
-PFN_vkGetDeviceQueue2 glad_vkGetDeviceQueue2 = NULL;
-PFN_vkGetEventStatus glad_vkGetEventStatus = NULL;
-PFN_vkGetFenceStatus glad_vkGetFenceStatus = NULL;
-PFN_vkGetImageMemoryRequirements glad_vkGetImageMemoryRequirements = NULL;
-PFN_vkGetImageMemoryRequirements2 glad_vkGetImageMemoryRequirements2 = NULL;
-PFN_vkGetImageSparseMemoryRequirements glad_vkGetImageSparseMemoryRequirements = NULL;
-PFN_vkGetImageSparseMemoryRequirements2 glad_vkGetImageSparseMemoryRequirements2 = NULL;
-PFN_vkGetImageSubresourceLayout glad_vkGetImageSubresourceLayout = NULL;
-PFN_vkGetInstanceProcAddr glad_vkGetInstanceProcAddr = NULL;
-PFN_vkGetPhysicalDeviceExternalBufferProperties glad_vkGetPhysicalDeviceExternalBufferProperties = NULL;
-PFN_vkGetPhysicalDeviceExternalFenceProperties glad_vkGetPhysicalDeviceExternalFenceProperties = NULL;
-PFN_vkGetPhysicalDeviceExternalSemaphoreProperties glad_vkGetPhysicalDeviceExternalSemaphoreProperties = NULL;
-PFN_vkGetPhysicalDeviceFeatures glad_vkGetPhysicalDeviceFeatures = NULL;
-PFN_vkGetPhysicalDeviceFeatures2 glad_vkGetPhysicalDeviceFeatures2 = NULL;
-PFN_vkGetPhysicalDeviceFormatProperties glad_vkGetPhysicalDeviceFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceFormatProperties2 glad_vkGetPhysicalDeviceFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceImageFormatProperties glad_vkGetPhysicalDeviceImageFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceImageFormatProperties2 glad_vkGetPhysicalDeviceImageFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceMemoryProperties glad_vkGetPhysicalDeviceMemoryProperties = NULL;
-PFN_vkGetPhysicalDeviceMemoryProperties2 glad_vkGetPhysicalDeviceMemoryProperties2 = NULL;
-PFN_vkGetPhysicalDevicePresentRectanglesKHR glad_vkGetPhysicalDevicePresentRectanglesKHR = NULL;
-PFN_vkGetPhysicalDeviceProperties glad_vkGetPhysicalDeviceProperties = NULL;
-PFN_vkGetPhysicalDeviceProperties2 glad_vkGetPhysicalDeviceProperties2 = NULL;
-PFN_vkGetPhysicalDeviceQueueFamilyProperties glad_vkGetPhysicalDeviceQueueFamilyProperties = NULL;
-PFN_vkGetPhysicalDeviceQueueFamilyProperties2 glad_vkGetPhysicalDeviceQueueFamilyProperties2 = NULL;
-PFN_vkGetPhysicalDeviceSparseImageFormatProperties glad_vkGetPhysicalDeviceSparseImageFormatProperties = NULL;
-PFN_vkGetPhysicalDeviceSparseImageFormatProperties2 glad_vkGetPhysicalDeviceSparseImageFormatProperties2 = NULL;
-PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR glad_vkGetPhysicalDeviceSurfaceCapabilitiesKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfaceFormatsKHR glad_vkGetPhysicalDeviceSurfaceFormatsKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfacePresentModesKHR glad_vkGetPhysicalDeviceSurfacePresentModesKHR = NULL;
-PFN_vkGetPhysicalDeviceSurfaceSupportKHR glad_vkGetPhysicalDeviceSurfaceSupportKHR = NULL;
-PFN_vkGetPipelineCacheData glad_vkGetPipelineCacheData = NULL;
-PFN_vkGetQueryPoolResults glad_vkGetQueryPoolResults = NULL;
-PFN_vkGetRenderAreaGranularity glad_vkGetRenderAreaGranularity = NULL;
-PFN_vkGetSwapchainImagesKHR glad_vkGetSwapchainImagesKHR = NULL;
-PFN_vkInvalidateMappedMemoryRanges glad_vkInvalidateMappedMemoryRanges = NULL;
-PFN_vkMapMemory glad_vkMapMemory = NULL;
-PFN_vkMergePipelineCaches glad_vkMergePipelineCaches = NULL;
-PFN_vkQueueBindSparse glad_vkQueueBindSparse = NULL;
-PFN_vkQueuePresentKHR glad_vkQueuePresentKHR = NULL;
-PFN_vkQueueSubmit glad_vkQueueSubmit = NULL;
-PFN_vkQueueWaitIdle glad_vkQueueWaitIdle = NULL;
-PFN_vkResetCommandBuffer glad_vkResetCommandBuffer = NULL;
-PFN_vkResetCommandPool glad_vkResetCommandPool = NULL;
-PFN_vkResetDescriptorPool glad_vkResetDescriptorPool = NULL;
-PFN_vkResetEvent glad_vkResetEvent = NULL;
-PFN_vkResetFences glad_vkResetFences = NULL;
-PFN_vkSetEvent glad_vkSetEvent = NULL;
-PFN_vkTrimCommandPool glad_vkTrimCommandPool = NULL;
-PFN_vkUnmapMemory glad_vkUnmapMemory = NULL;
-PFN_vkUpdateDescriptorSetWithTemplate glad_vkUpdateDescriptorSetWithTemplate = NULL;
-PFN_vkUpdateDescriptorSets glad_vkUpdateDescriptorSets = NULL;
-PFN_vkWaitForFences glad_vkWaitForFences = NULL;
-
-
-static void glad_vk_load_VK_VERSION_1_0( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_VERSION_1_0) return;
-    vkAllocateCommandBuffers = (PFN_vkAllocateCommandBuffers) load("vkAllocateCommandBuffers", userptr);
-    vkAllocateDescriptorSets = (PFN_vkAllocateDescriptorSets) load("vkAllocateDescriptorSets", userptr);
-    vkAllocateMemory = (PFN_vkAllocateMemory) load("vkAllocateMemory", userptr);
-    vkBeginCommandBuffer = (PFN_vkBeginCommandBuffer) load("vkBeginCommandBuffer", userptr);
-    vkBindBufferMemory = (PFN_vkBindBufferMemory) load("vkBindBufferMemory", userptr);
-    vkBindImageMemory = (PFN_vkBindImageMemory) load("vkBindImageMemory", userptr);
-    vkCmdBeginQuery = (PFN_vkCmdBeginQuery) load("vkCmdBeginQuery", userptr);
-    vkCmdBeginRenderPass = (PFN_vkCmdBeginRenderPass) load("vkCmdBeginRenderPass", userptr);
-    vkCmdBindDescriptorSets = (PFN_vkCmdBindDescriptorSets) load("vkCmdBindDescriptorSets", userptr);
-    vkCmdBindIndexBuffer = (PFN_vkCmdBindIndexBuffer) load("vkCmdBindIndexBuffer", userptr);
-    vkCmdBindPipeline = (PFN_vkCmdBindPipeline) load("vkCmdBindPipeline", userptr);
-    vkCmdBindVertexBuffers = (PFN_vkCmdBindVertexBuffers) load("vkCmdBindVertexBuffers", userptr);
-    vkCmdBlitImage = (PFN_vkCmdBlitImage) load("vkCmdBlitImage", userptr);
-    vkCmdClearAttachments = (PFN_vkCmdClearAttachments) load("vkCmdClearAttachments", userptr);
-    vkCmdClearColorImage = (PFN_vkCmdClearColorImage) load("vkCmdClearColorImage", userptr);
-    vkCmdClearDepthStencilImage = (PFN_vkCmdClearDepthStencilImage) load("vkCmdClearDepthStencilImage", userptr);
-    vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer) load("vkCmdCopyBuffer", userptr);
-    vkCmdCopyBufferToImage = (PFN_vkCmdCopyBufferToImage) load("vkCmdCopyBufferToImage", userptr);
-    vkCmdCopyImage = (PFN_vkCmdCopyImage) load("vkCmdCopyImage", userptr);
-    vkCmdCopyImageToBuffer = (PFN_vkCmdCopyImageToBuffer) load("vkCmdCopyImageToBuffer", userptr);
-    vkCmdCopyQueryPoolResults = (PFN_vkCmdCopyQueryPoolResults) load("vkCmdCopyQueryPoolResults", userptr);
-    vkCmdDispatch = (PFN_vkCmdDispatch) load("vkCmdDispatch", userptr);
-    vkCmdDispatchIndirect = (PFN_vkCmdDispatchIndirect) load("vkCmdDispatchIndirect", userptr);
-    vkCmdDraw = (PFN_vkCmdDraw) load("vkCmdDraw", userptr);
-    vkCmdDrawIndexed = (PFN_vkCmdDrawIndexed) load("vkCmdDrawIndexed", userptr);
-    vkCmdDrawIndexedIndirect = (PFN_vkCmdDrawIndexedIndirect) load("vkCmdDrawIndexedIndirect", userptr);
-    vkCmdDrawIndirect = (PFN_vkCmdDrawIndirect) load("vkCmdDrawIndirect", userptr);
-    vkCmdEndQuery = (PFN_vkCmdEndQuery) load("vkCmdEndQuery", userptr);
-    vkCmdEndRenderPass = (PFN_vkCmdEndRenderPass) load("vkCmdEndRenderPass", userptr);
-    vkCmdExecuteCommands = (PFN_vkCmdExecuteCommands) load("vkCmdExecuteCommands", userptr);
-    vkCmdFillBuffer = (PFN_vkCmdFillBuffer) load("vkCmdFillBuffer", userptr);
-    vkCmdNextSubpass = (PFN_vkCmdNextSubpass) load("vkCmdNextSubpass", userptr);
-    vkCmdPipelineBarrier = (PFN_vkCmdPipelineBarrier) load("vkCmdPipelineBarrier", userptr);
-    vkCmdPushConstants = (PFN_vkCmdPushConstants) load("vkCmdPushConstants", userptr);
-    vkCmdResetEvent = (PFN_vkCmdResetEvent) load("vkCmdResetEvent", userptr);
-    vkCmdResetQueryPool = (PFN_vkCmdResetQueryPool) load("vkCmdResetQueryPool", userptr);
-    vkCmdResolveImage = (PFN_vkCmdResolveImage) load("vkCmdResolveImage", userptr);
-    vkCmdSetBlendConstants = (PFN_vkCmdSetBlendConstants) load("vkCmdSetBlendConstants", userptr);
-    vkCmdSetDepthBias = (PFN_vkCmdSetDepthBias) load("vkCmdSetDepthBias", userptr);
-    vkCmdSetDepthBounds = (PFN_vkCmdSetDepthBounds) load("vkCmdSetDepthBounds", userptr);
-    vkCmdSetEvent = (PFN_vkCmdSetEvent) load("vkCmdSetEvent", userptr);
-    vkCmdSetLineWidth = (PFN_vkCmdSetLineWidth) load("vkCmdSetLineWidth", userptr);
-    vkCmdSetScissor = (PFN_vkCmdSetScissor) load("vkCmdSetScissor", userptr);
-    vkCmdSetStencilCompareMask = (PFN_vkCmdSetStencilCompareMask) load("vkCmdSetStencilCompareMask", userptr);
-    vkCmdSetStencilReference = (PFN_vkCmdSetStencilReference) load("vkCmdSetStencilReference", userptr);
-    vkCmdSetStencilWriteMask = (PFN_vkCmdSetStencilWriteMask) load("vkCmdSetStencilWriteMask", userptr);
-    vkCmdSetViewport = (PFN_vkCmdSetViewport) load("vkCmdSetViewport", userptr);
-    vkCmdUpdateBuffer = (PFN_vkCmdUpdateBuffer) load("vkCmdUpdateBuffer", userptr);
-    vkCmdWaitEvents = (PFN_vkCmdWaitEvents) load("vkCmdWaitEvents", userptr);
-    vkCmdWriteTimestamp = (PFN_vkCmdWriteTimestamp) load("vkCmdWriteTimestamp", userptr);
-    vkCreateBuffer = (PFN_vkCreateBuffer) load("vkCreateBuffer", userptr);
-    vkCreateBufferView = (PFN_vkCreateBufferView) load("vkCreateBufferView", userptr);
-    vkCreateCommandPool = (PFN_vkCreateCommandPool) load("vkCreateCommandPool", userptr);
-    vkCreateComputePipelines = (PFN_vkCreateComputePipelines) load("vkCreateComputePipelines", userptr);
-    vkCreateDescriptorPool = (PFN_vkCreateDescriptorPool) load("vkCreateDescriptorPool", userptr);
-    vkCreateDescriptorSetLayout = (PFN_vkCreateDescriptorSetLayout) load("vkCreateDescriptorSetLayout", userptr);
-    vkCreateDevice = (PFN_vkCreateDevice) load("vkCreateDevice", userptr);
-    vkCreateEvent = (PFN_vkCreateEvent) load("vkCreateEvent", userptr);
-    vkCreateFence = (PFN_vkCreateFence) load("vkCreateFence", userptr);
-    vkCreateFramebuffer = (PFN_vkCreateFramebuffer) load("vkCreateFramebuffer", userptr);
-    vkCreateGraphicsPipelines = (PFN_vkCreateGraphicsPipelines) load("vkCreateGraphicsPipelines", userptr);
-    vkCreateImage = (PFN_vkCreateImage) load("vkCreateImage", userptr);
-    vkCreateImageView = (PFN_vkCreateImageView) load("vkCreateImageView", userptr);
-    vkCreateInstance = (PFN_vkCreateInstance) load("vkCreateInstance", userptr);
-    vkCreatePipelineCache = (PFN_vkCreatePipelineCache) load("vkCreatePipelineCache", userptr);
-    vkCreatePipelineLayout = (PFN_vkCreatePipelineLayout) load("vkCreatePipelineLayout", userptr);
-    vkCreateQueryPool = (PFN_vkCreateQueryPool) load("vkCreateQueryPool", userptr);
-    vkCreateRenderPass = (PFN_vkCreateRenderPass) load("vkCreateRenderPass", userptr);
-    vkCreateSampler = (PFN_vkCreateSampler) load("vkCreateSampler", userptr);
-    vkCreateSemaphore = (PFN_vkCreateSemaphore) load("vkCreateSemaphore", userptr);
-    vkCreateShaderModule = (PFN_vkCreateShaderModule) load("vkCreateShaderModule", userptr);
-    vkDestroyBuffer = (PFN_vkDestroyBuffer) load("vkDestroyBuffer", userptr);
-    vkDestroyBufferView = (PFN_vkDestroyBufferView) load("vkDestroyBufferView", userptr);
-    vkDestroyCommandPool = (PFN_vkDestroyCommandPool) load("vkDestroyCommandPool", userptr);
-    vkDestroyDescriptorPool = (PFN_vkDestroyDescriptorPool) load("vkDestroyDescriptorPool", userptr);
-    vkDestroyDescriptorSetLayout = (PFN_vkDestroyDescriptorSetLayout) load("vkDestroyDescriptorSetLayout", userptr);
-    vkDestroyDevice = (PFN_vkDestroyDevice) load("vkDestroyDevice", userptr);
-    vkDestroyEvent = (PFN_vkDestroyEvent) load("vkDestroyEvent", userptr);
-    vkDestroyFence = (PFN_vkDestroyFence) load("vkDestroyFence", userptr);
-    vkDestroyFramebuffer = (PFN_vkDestroyFramebuffer) load("vkDestroyFramebuffer", userptr);
-    vkDestroyImage = (PFN_vkDestroyImage) load("vkDestroyImage", userptr);
-    vkDestroyImageView = (PFN_vkDestroyImageView) load("vkDestroyImageView", userptr);
-    vkDestroyInstance = (PFN_vkDestroyInstance) load("vkDestroyInstance", userptr);
-    vkDestroyPipeline = (PFN_vkDestroyPipeline) load("vkDestroyPipeline", userptr);
-    vkDestroyPipelineCache = (PFN_vkDestroyPipelineCache) load("vkDestroyPipelineCache", userptr);
-    vkDestroyPipelineLayout = (PFN_vkDestroyPipelineLayout) load("vkDestroyPipelineLayout", userptr);
-    vkDestroyQueryPool = (PFN_vkDestroyQueryPool) load("vkDestroyQueryPool", userptr);
-    vkDestroyRenderPass = (PFN_vkDestroyRenderPass) load("vkDestroyRenderPass", userptr);
-    vkDestroySampler = (PFN_vkDestroySampler) load("vkDestroySampler", userptr);
-    vkDestroySemaphore = (PFN_vkDestroySemaphore) load("vkDestroySemaphore", userptr);
-    vkDestroyShaderModule = (PFN_vkDestroyShaderModule) load("vkDestroyShaderModule", userptr);
-    vkDeviceWaitIdle = (PFN_vkDeviceWaitIdle) load("vkDeviceWaitIdle", userptr);
-    vkEndCommandBuffer = (PFN_vkEndCommandBuffer) load("vkEndCommandBuffer", userptr);
-    vkEnumerateDeviceExtensionProperties = (PFN_vkEnumerateDeviceExtensionProperties) load("vkEnumerateDeviceExtensionProperties", userptr);
-    vkEnumerateDeviceLayerProperties = (PFN_vkEnumerateDeviceLayerProperties) load("vkEnumerateDeviceLayerProperties", userptr);
-    vkEnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties) load("vkEnumerateInstanceExtensionProperties", userptr);
-    vkEnumerateInstanceLayerProperties = (PFN_vkEnumerateInstanceLayerProperties) load("vkEnumerateInstanceLayerProperties", userptr);
-    vkEnumeratePhysicalDevices = (PFN_vkEnumeratePhysicalDevices) load("vkEnumeratePhysicalDevices", userptr);
-    vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges) load("vkFlushMappedMemoryRanges", userptr);
-    vkFreeCommandBuffers = (PFN_vkFreeCommandBuffers) load("vkFreeCommandBuffers", userptr);
-    vkFreeDescriptorSets = (PFN_vkFreeDescriptorSets) load("vkFreeDescriptorSets", userptr);
-    vkFreeMemory = (PFN_vkFreeMemory) load("vkFreeMemory", userptr);
-    vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements) load("vkGetBufferMemoryRequirements", userptr);
-    vkGetDeviceMemoryCommitment = (PFN_vkGetDeviceMemoryCommitment) load("vkGetDeviceMemoryCommitment", userptr);
-    vkGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) load("vkGetDeviceProcAddr", userptr);
-    vkGetDeviceQueue = (PFN_vkGetDeviceQueue) load("vkGetDeviceQueue", userptr);
-    vkGetEventStatus = (PFN_vkGetEventStatus) load("vkGetEventStatus", userptr);
-    vkGetFenceStatus = (PFN_vkGetFenceStatus) load("vkGetFenceStatus", userptr);
-    vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements) load("vkGetImageMemoryRequirements", userptr);
-    vkGetImageSparseMemoryRequirements = (PFN_vkGetImageSparseMemoryRequirements) load("vkGetImageSparseMemoryRequirements", userptr);
-    vkGetImageSubresourceLayout = (PFN_vkGetImageSubresourceLayout) load("vkGetImageSubresourceLayout", userptr);
-    vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr) load("vkGetInstanceProcAddr", userptr);
-    vkGetPhysicalDeviceFeatures = (PFN_vkGetPhysicalDeviceFeatures) load("vkGetPhysicalDeviceFeatures", userptr);
-    vkGetPhysicalDeviceFormatProperties = (PFN_vkGetPhysicalDeviceFormatProperties) load("vkGetPhysicalDeviceFormatProperties", userptr);
-    vkGetPhysicalDeviceImageFormatProperties = (PFN_vkGetPhysicalDeviceImageFormatProperties) load("vkGetPhysicalDeviceImageFormatProperties", userptr);
-    vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties) load("vkGetPhysicalDeviceMemoryProperties", userptr);
-    vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties) load("vkGetPhysicalDeviceProperties", userptr);
-    vkGetPhysicalDeviceQueueFamilyProperties = (PFN_vkGetPhysicalDeviceQueueFamilyProperties) load("vkGetPhysicalDeviceQueueFamilyProperties", userptr);
-    vkGetPhysicalDeviceSparseImageFormatProperties = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties) load("vkGetPhysicalDeviceSparseImageFormatProperties", userptr);
-    vkGetPipelineCacheData = (PFN_vkGetPipelineCacheData) load("vkGetPipelineCacheData", userptr);
-    vkGetQueryPoolResults = (PFN_vkGetQueryPoolResults) load("vkGetQueryPoolResults", userptr);
-    vkGetRenderAreaGranularity = (PFN_vkGetRenderAreaGranularity) load("vkGetRenderAreaGranularity", userptr);
-    vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges) load("vkInvalidateMappedMemoryRanges", userptr);
-    vkMapMemory = (PFN_vkMapMemory) load("vkMapMemory", userptr);
-    vkMergePipelineCaches = (PFN_vkMergePipelineCaches) load("vkMergePipelineCaches", userptr);
-    vkQueueBindSparse = (PFN_vkQueueBindSparse) load("vkQueueBindSparse", userptr);
-    vkQueueSubmit = (PFN_vkQueueSubmit) load("vkQueueSubmit", userptr);
-    vkQueueWaitIdle = (PFN_vkQueueWaitIdle) load("vkQueueWaitIdle", userptr);
-    vkResetCommandBuffer = (PFN_vkResetCommandBuffer) load("vkResetCommandBuffer", userptr);
-    vkResetCommandPool = (PFN_vkResetCommandPool) load("vkResetCommandPool", userptr);
-    vkResetDescriptorPool = (PFN_vkResetDescriptorPool) load("vkResetDescriptorPool", userptr);
-    vkResetEvent = (PFN_vkResetEvent) load("vkResetEvent", userptr);
-    vkResetFences = (PFN_vkResetFences) load("vkResetFences", userptr);
-    vkSetEvent = (PFN_vkSetEvent) load("vkSetEvent", userptr);
-    vkUnmapMemory = (PFN_vkUnmapMemory) load("vkUnmapMemory", userptr);
-    vkUpdateDescriptorSets = (PFN_vkUpdateDescriptorSets) load("vkUpdateDescriptorSets", userptr);
-    vkWaitForFences = (PFN_vkWaitForFences) load("vkWaitForFences", userptr);
-}
-static void glad_vk_load_VK_VERSION_1_1( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_VERSION_1_1) return;
-    vkBindBufferMemory2 = (PFN_vkBindBufferMemory2) load("vkBindBufferMemory2", userptr);
-    vkBindImageMemory2 = (PFN_vkBindImageMemory2) load("vkBindImageMemory2", userptr);
-    vkCmdDispatchBase = (PFN_vkCmdDispatchBase) load("vkCmdDispatchBase", userptr);
-    vkCmdSetDeviceMask = (PFN_vkCmdSetDeviceMask) load("vkCmdSetDeviceMask", userptr);
-    vkCreateDescriptorUpdateTemplate = (PFN_vkCreateDescriptorUpdateTemplate) load("vkCreateDescriptorUpdateTemplate", userptr);
-    vkCreateSamplerYcbcrConversion = (PFN_vkCreateSamplerYcbcrConversion) load("vkCreateSamplerYcbcrConversion", userptr);
-    vkDestroyDescriptorUpdateTemplate = (PFN_vkDestroyDescriptorUpdateTemplate) load("vkDestroyDescriptorUpdateTemplate", userptr);
-    vkDestroySamplerYcbcrConversion = (PFN_vkDestroySamplerYcbcrConversion) load("vkDestroySamplerYcbcrConversion", userptr);
-    vkEnumerateInstanceVersion = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
-    vkEnumeratePhysicalDeviceGroups = (PFN_vkEnumeratePhysicalDeviceGroups) load("vkEnumeratePhysicalDeviceGroups", userptr);
-    vkGetBufferMemoryRequirements2 = (PFN_vkGetBufferMemoryRequirements2) load("vkGetBufferMemoryRequirements2", userptr);
-    vkGetDescriptorSetLayoutSupport = (PFN_vkGetDescriptorSetLayoutSupport) load("vkGetDescriptorSetLayoutSupport", userptr);
-    vkGetDeviceGroupPeerMemoryFeatures = (PFN_vkGetDeviceGroupPeerMemoryFeatures) load("vkGetDeviceGroupPeerMemoryFeatures", userptr);
-    vkGetDeviceQueue2 = (PFN_vkGetDeviceQueue2) load("vkGetDeviceQueue2", userptr);
-    vkGetImageMemoryRequirements2 = (PFN_vkGetImageMemoryRequirements2) load("vkGetImageMemoryRequirements2", userptr);
-    vkGetImageSparseMemoryRequirements2 = (PFN_vkGetImageSparseMemoryRequirements2) load("vkGetImageSparseMemoryRequirements2", userptr);
-    vkGetPhysicalDeviceExternalBufferProperties = (PFN_vkGetPhysicalDeviceExternalBufferProperties) load("vkGetPhysicalDeviceExternalBufferProperties", userptr);
-    vkGetPhysicalDeviceExternalFenceProperties = (PFN_vkGetPhysicalDeviceExternalFenceProperties) load("vkGetPhysicalDeviceExternalFenceProperties", userptr);
-    vkGetPhysicalDeviceExternalSemaphoreProperties = (PFN_vkGetPhysicalDeviceExternalSemaphoreProperties) load("vkGetPhysicalDeviceExternalSemaphoreProperties", userptr);
-    vkGetPhysicalDeviceFeatures2 = (PFN_vkGetPhysicalDeviceFeatures2) load("vkGetPhysicalDeviceFeatures2", userptr);
-    vkGetPhysicalDeviceFormatProperties2 = (PFN_vkGetPhysicalDeviceFormatProperties2) load("vkGetPhysicalDeviceFormatProperties2", userptr);
-    vkGetPhysicalDeviceImageFormatProperties2 = (PFN_vkGetPhysicalDeviceImageFormatProperties2) load("vkGetPhysicalDeviceImageFormatProperties2", userptr);
-    vkGetPhysicalDeviceMemoryProperties2 = (PFN_vkGetPhysicalDeviceMemoryProperties2) load("vkGetPhysicalDeviceMemoryProperties2", userptr);
-    vkGetPhysicalDeviceProperties2 = (PFN_vkGetPhysicalDeviceProperties2) load("vkGetPhysicalDeviceProperties2", userptr);
-    vkGetPhysicalDeviceQueueFamilyProperties2 = (PFN_vkGetPhysicalDeviceQueueFamilyProperties2) load("vkGetPhysicalDeviceQueueFamilyProperties2", userptr);
-    vkGetPhysicalDeviceSparseImageFormatProperties2 = (PFN_vkGetPhysicalDeviceSparseImageFormatProperties2) load("vkGetPhysicalDeviceSparseImageFormatProperties2", userptr);
-    vkTrimCommandPool = (PFN_vkTrimCommandPool) load("vkTrimCommandPool", userptr);
-    vkUpdateDescriptorSetWithTemplate = (PFN_vkUpdateDescriptorSetWithTemplate) load("vkUpdateDescriptorSetWithTemplate", userptr);
-}
-static void glad_vk_load_VK_EXT_debug_report( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_EXT_debug_report) return;
-    vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT) load("vkCreateDebugReportCallbackEXT", userptr);
-    vkDebugReportMessageEXT = (PFN_vkDebugReportMessageEXT) load("vkDebugReportMessageEXT", userptr);
-    vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT) load("vkDestroyDebugReportCallbackEXT", userptr);
-}
-static void glad_vk_load_VK_KHR_surface( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_KHR_surface) return;
-    vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) load("vkDestroySurfaceKHR", userptr);
-    vkGetPhysicalDeviceSurfaceCapabilitiesKHR = (PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR) load("vkGetPhysicalDeviceSurfaceCapabilitiesKHR", userptr);
-    vkGetPhysicalDeviceSurfaceFormatsKHR = (PFN_vkGetPhysicalDeviceSurfaceFormatsKHR) load("vkGetPhysicalDeviceSurfaceFormatsKHR", userptr);
-    vkGetPhysicalDeviceSurfacePresentModesKHR = (PFN_vkGetPhysicalDeviceSurfacePresentModesKHR) load("vkGetPhysicalDeviceSurfacePresentModesKHR", userptr);
-    vkGetPhysicalDeviceSurfaceSupportKHR = (PFN_vkGetPhysicalDeviceSurfaceSupportKHR) load("vkGetPhysicalDeviceSurfaceSupportKHR", userptr);
-}
-static void glad_vk_load_VK_KHR_swapchain( GLADuserptrloadfunc load, void* userptr) {
-    if(!GLAD_VK_KHR_swapchain) return;
-    vkAcquireNextImage2KHR = (PFN_vkAcquireNextImage2KHR) load("vkAcquireNextImage2KHR", userptr);
-    vkAcquireNextImageKHR = (PFN_vkAcquireNextImageKHR) load("vkAcquireNextImageKHR", userptr);
-    vkCreateSwapchainKHR = (PFN_vkCreateSwapchainKHR) load("vkCreateSwapchainKHR", userptr);
-    vkDestroySwapchainKHR = (PFN_vkDestroySwapchainKHR) load("vkDestroySwapchainKHR", userptr);
-    vkGetDeviceGroupPresentCapabilitiesKHR = (PFN_vkGetDeviceGroupPresentCapabilitiesKHR) load("vkGetDeviceGroupPresentCapabilitiesKHR", userptr);
-    vkGetDeviceGroupSurfacePresentModesKHR = (PFN_vkGetDeviceGroupSurfacePresentModesKHR) load("vkGetDeviceGroupSurfacePresentModesKHR", userptr);
-    vkGetPhysicalDevicePresentRectanglesKHR = (PFN_vkGetPhysicalDevicePresentRectanglesKHR) load("vkGetPhysicalDevicePresentRectanglesKHR", userptr);
-    vkGetSwapchainImagesKHR = (PFN_vkGetSwapchainImagesKHR) load("vkGetSwapchainImagesKHR", userptr);
-    vkQueuePresentKHR = (PFN_vkQueuePresentKHR) load("vkQueuePresentKHR", userptr);
-}
-
-
-
-static int glad_vk_get_extensions( VkPhysicalDevice physical_device, uint32_t *out_extension_count, char ***out_extensions) {
-    uint32_t i;
-    uint32_t instance_extension_count = 0;
-    uint32_t device_extension_count = 0;
-    uint32_t max_extension_count;
-    uint32_t total_extension_count;
-    char **extensions;
-    VkExtensionProperties *ext_properties;
-    VkResult result;
-
-    if (vkEnumerateInstanceExtensionProperties == NULL || (physical_device != NULL && vkEnumerateDeviceExtensionProperties == NULL)) {
-        return 0;
-    }
-
-    result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, NULL);
-    if (result != VK_SUCCESS) {
-        return 0;
-    }
-
-    if (physical_device != NULL) {
-        result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, NULL);
-        if (result != VK_SUCCESS) {
-            return 0;
-        }
-    }
-
-    total_extension_count = instance_extension_count + device_extension_count;
-    max_extension_count = instance_extension_count > device_extension_count
-        ? instance_extension_count : device_extension_count;
-
-    ext_properties = (VkExtensionProperties*) malloc(max_extension_count * sizeof(VkExtensionProperties));
-    if (ext_properties == NULL) {
-        return 0;
-    }
-
-    result = vkEnumerateInstanceExtensionProperties(NULL, &instance_extension_count, ext_properties);
-    if (result != VK_SUCCESS) {
-        free((void*) ext_properties);
-        return 0;
-    }
-
-    extensions = (char**) calloc(total_extension_count, sizeof(char*));
-    if (extensions == NULL) {
-        free((void*) ext_properties);
-        return 0;
-    }
-
-    for (i = 0; i < instance_extension_count; ++i) {
-        VkExtensionProperties ext = ext_properties[i];
-
-        size_t extension_name_length = strlen(ext.extensionName) + 1;
-        extensions[i] = (char*) malloc(extension_name_length * sizeof(char));
-        memcpy(extensions[i], ext.extensionName, extension_name_length * sizeof(char));
-    }
-
-    if (physical_device != NULL) {
-        result = vkEnumerateDeviceExtensionProperties(physical_device, NULL, &device_extension_count, ext_properties);
-        if (result != VK_SUCCESS) {
-            for (i = 0; i < instance_extension_count; ++i) {
-                free((void*) extensions[i]);
-            }
-            free(extensions);
-            return 0;
-        }
-
-        for (i = 0; i < device_extension_count; ++i) {
-            VkExtensionProperties ext = ext_properties[i];
-
-            size_t extension_name_length = strlen(ext.extensionName) + 1;
-            extensions[instance_extension_count + i] = (char*) malloc(extension_name_length * sizeof(char));
-            memcpy(extensions[instance_extension_count + i], ext.extensionName, extension_name_length * sizeof(char));
-        }
-    }
-
-    free((void*) ext_properties);
-
-    *out_extension_count = total_extension_count;
-    *out_extensions = extensions;
-
-    return 1;
-}
-
-static void glad_vk_free_extensions(uint32_t extension_count, char **extensions) {
-    uint32_t i;
-
-    for(i = 0; i < extension_count ; ++i) {
-        free((void*) (extensions[i]));
-    }
-
-    free((void*) extensions);
-}
-
-static int glad_vk_has_extension(const char *name, uint32_t extension_count, char **extensions) {
-    uint32_t i;
-
-    for (i = 0; i < extension_count; ++i) {
-        if(strcmp(name, extensions[i]) == 0) {
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-static GLADapiproc glad_vk_get_proc_from_userptr(const char* name, void *userptr) {
-    return (GLAD_GNUC_EXTENSION (GLADapiproc (*)(const char *name)) userptr)(name);
-}
-
-static int glad_vk_find_extensions_vulkan( VkPhysicalDevice physical_device) {
-    uint32_t extension_count = 0;
-    char **extensions = NULL;
-    if (!glad_vk_get_extensions(physical_device, &extension_count, &extensions)) return 0;
-
-    GLAD_VK_EXT_debug_report = glad_vk_has_extension("VK_EXT_debug_report", extension_count, extensions);
-    GLAD_VK_KHR_surface = glad_vk_has_extension("VK_KHR_surface", extension_count, extensions);
-    GLAD_VK_KHR_swapchain = glad_vk_has_extension("VK_KHR_swapchain", extension_count, extensions);
-
-    glad_vk_free_extensions(extension_count, extensions);
-
-    return 1;
-}
-
-static int glad_vk_find_core_vulkan( VkPhysicalDevice physical_device) {
-    int major = 1;
-    int minor = 0;
-
-#ifdef VK_VERSION_1_1
-    if (vkEnumerateInstanceVersion  != NULL) {
-        uint32_t version;
-        VkResult result;
-
-        result = vkEnumerateInstanceVersion(&version);
-        if (result == VK_SUCCESS) {
-            major = (int) VK_VERSION_MAJOR(version);
-            minor = (int) VK_VERSION_MINOR(version);
-        }
-    }
-#endif
-
-    if (physical_device != NULL && vkGetPhysicalDeviceProperties  != NULL) {
-        VkPhysicalDeviceProperties properties;
-        vkGetPhysicalDeviceProperties(physical_device, &properties);
-
-        major = (int) VK_VERSION_MAJOR(properties.apiVersion);
-        minor = (int) VK_VERSION_MINOR(properties.apiVersion);
-    }
-
-    GLAD_VK_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
-    GLAD_VK_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
-
-    return GLAD_MAKE_VERSION(major, minor);
-}
-
-int gladLoadVulkanUserPtr( VkPhysicalDevice physical_device, GLADuserptrloadfunc load, void *userptr) {
-    int version;
-
-#ifdef VK_VERSION_1_1
-    vkEnumerateInstanceVersion  = (PFN_vkEnumerateInstanceVersion) load("vkEnumerateInstanceVersion", userptr);
-#endif
-    version = glad_vk_find_core_vulkan( physical_device);
-    if (!version) {
-        return 0;
-    }
-
-    glad_vk_load_VK_VERSION_1_0(load, userptr);
-    glad_vk_load_VK_VERSION_1_1(load, userptr);
-
-    if (!glad_vk_find_extensions_vulkan( physical_device)) return 0;
-    glad_vk_load_VK_EXT_debug_report(load, userptr);
-    glad_vk_load_VK_KHR_surface(load, userptr);
-    glad_vk_load_VK_KHR_swapchain(load, userptr);
-
-
-    return version;
-}
-
-
-int gladLoadVulkan( VkPhysicalDevice physical_device, GLADloadfunc load) {
-    return gladLoadVulkanUserPtr( physical_device, glad_vk_get_proc_from_userptr, GLAD_GNUC_EXTENSION (void*) load);
-}
-
-
-
-
diff --git a/raylib_pi4_test/external/glfw/deps/mingw/_mingw_dxhelper.h b/raylib_pi4_test/external/glfw/deps/mingw/_mingw_dxhelper.h
deleted file mode 100644 (file)
index 849e291..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER within this package.
- */
-
-#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS)
-#define NONAMELESSUNION                1
-#endif
-#if defined(NONAMELESSSTRUCT) && \
-   !defined(NONAMELESSUNION)
-#define NONAMELESSUNION                1
-#endif
-#if defined(NONAMELESSUNION)  && \
-   !defined(NONAMELESSSTRUCT)
-#define NONAMELESSSTRUCT       1
-#endif
-#if !defined(__GNU_EXTENSION)
-#if defined(__GNUC__) || defined(__GNUG__)
-#define __GNU_EXTENSION                __extension__
-#else
-#define __GNU_EXTENSION
-#endif
-#endif /* __extension__ */
-
-#ifndef __ANONYMOUS_DEFINED
-#define __ANONYMOUS_DEFINED
-#if defined(__GNUC__) || defined(__GNUG__)
-#define _ANONYMOUS_UNION       __extension__
-#define _ANONYMOUS_STRUCT      __extension__
-#else
-#define _ANONYMOUS_UNION
-#define _ANONYMOUS_STRUCT
-#endif
-#ifndef NONAMELESSUNION
-#define _UNION_NAME(x)
-#define _STRUCT_NAME(x)
-#else /* NONAMELESSUNION */
-#define _UNION_NAME(x)  x
-#define _STRUCT_NAME(x) x
-#endif
-#endif /* __ANONYMOUS_DEFINED */
-
-#ifndef DUMMYUNIONNAME
-# ifdef NONAMELESSUNION
-#  define DUMMYUNIONNAME  u
-#  define DUMMYUNIONNAME1 u1   /* Wine uses this variant */
-#  define DUMMYUNIONNAME2 u2
-#  define DUMMYUNIONNAME3 u3
-#  define DUMMYUNIONNAME4 u4
-#  define DUMMYUNIONNAME5 u5
-#  define DUMMYUNIONNAME6 u6
-#  define DUMMYUNIONNAME7 u7
-#  define DUMMYUNIONNAME8 u8
-#  define DUMMYUNIONNAME9 u9
-# else /* NONAMELESSUNION */
-#  define DUMMYUNIONNAME
-#  define DUMMYUNIONNAME1      /* Wine uses this variant */
-#  define DUMMYUNIONNAME2
-#  define DUMMYUNIONNAME3
-#  define DUMMYUNIONNAME4
-#  define DUMMYUNIONNAME5
-#  define DUMMYUNIONNAME6
-#  define DUMMYUNIONNAME7
-#  define DUMMYUNIONNAME8
-#  define DUMMYUNIONNAME9
-# endif
-#endif /* DUMMYUNIONNAME */
-
-#if !defined(DUMMYUNIONNAME1)  /* MinGW does not define this one */
-# ifdef NONAMELESSUNION
-#  define DUMMYUNIONNAME1 u1   /* Wine uses this variant */
-# else
-#  define DUMMYUNIONNAME1      /* Wine uses this variant */
-# endif
-#endif /* DUMMYUNIONNAME1 */
-
-#ifndef DUMMYSTRUCTNAME
-# ifdef NONAMELESSUNION
-#  define DUMMYSTRUCTNAME  s
-#  define DUMMYSTRUCTNAME1 s1  /* Wine uses this variant */
-#  define DUMMYSTRUCTNAME2 s2
-#  define DUMMYSTRUCTNAME3 s3
-#  define DUMMYSTRUCTNAME4 s4
-#  define DUMMYSTRUCTNAME5 s5
-# else
-#  define DUMMYSTRUCTNAME
-#  define DUMMYSTRUCTNAME1     /* Wine uses this variant */
-#  define DUMMYSTRUCTNAME2
-#  define DUMMYSTRUCTNAME3
-#  define DUMMYSTRUCTNAME4
-#  define DUMMYSTRUCTNAME5
-# endif
-#endif /* DUMMYSTRUCTNAME */
-
-/* These are for compatibility with the Wine source tree */
-
-#ifndef WINELIB_NAME_AW
-# ifdef __MINGW_NAME_AW
-#   define WINELIB_NAME_AW  __MINGW_NAME_AW
-# else
-#  ifdef UNICODE
-#   define WINELIB_NAME_AW(func) func##W
-#  else
-#   define WINELIB_NAME_AW(func) func##A
-#  endif
-# endif
-#endif /* WINELIB_NAME_AW */
-
-#ifndef DECL_WINELIB_TYPE_AW
-# ifdef __MINGW_TYPEDEF_AW
-#  define DECL_WINELIB_TYPE_AW  __MINGW_TYPEDEF_AW
-# else
-#  define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
-# endif
-#endif /* DECL_WINELIB_TYPE_AW */
-
diff --git a/raylib_pi4_test/external/glfw/deps/mingw/dinput.h b/raylib_pi4_test/external/glfw/deps/mingw/dinput.h
deleted file mode 100644 (file)
index b575480..0000000
+++ /dev/null
@@ -1,2467 +0,0 @@
-/*
- * Copyright (C) the Wine project
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __DINPUT_INCLUDED__
-#define __DINPUT_INCLUDED__
-
-#define COM_NO_WINDOWS_H
-#include <objbase.h>
-#include <_mingw_dxhelper.h>
-
-#ifndef DIRECTINPUT_VERSION
-#define DIRECTINPUT_VERSION    0x0800
-#endif
-
-/* Classes */
-DEFINE_GUID(CLSID_DirectInput,         0x25E609E0,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(CLSID_DirectInputDevice,   0x25E609E1,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-DEFINE_GUID(CLSID_DirectInput8,                0x25E609E4,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(CLSID_DirectInputDevice8,  0x25E609E5,0xB259,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* Interfaces */
-DEFINE_GUID(IID_IDirectInputA,         0x89521360,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputW,         0x89521361,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput2A,                0x5944E662,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput2W,                0x5944E663,0xAA8A,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInput7A,                0x9A4CB684,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInput7W,                0x9A4CB685,0x236D,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInput8A,                0xBF798030,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
-DEFINE_GUID(IID_IDirectInput8W,                0xBF798031,0x483A,0x4DA2,0xAA,0x99,0x5D,0x64,0xED,0x36,0x97,0x00);
-DEFINE_GUID(IID_IDirectInputDeviceA,   0x5944E680,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDeviceW,   0x5944E681,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice2A,  0x5944E682,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice2W,  0x5944E683,0xC92E,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(IID_IDirectInputDevice7A,  0x57D7C6BC,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInputDevice7W,  0x57D7C6BD,0x2356,0x11D3,0x8E,0x9D,0x00,0xC0,0x4F,0x68,0x44,0xAE);
-DEFINE_GUID(IID_IDirectInputDevice8A,  0x54D41080,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
-DEFINE_GUID(IID_IDirectInputDevice8W,  0x54D41081,0xDC15,0x4833,0xA4,0x1B,0x74,0x8F,0x73,0xA3,0x81,0x79);
-DEFINE_GUID(IID_IDirectInputEffect,    0xE7E1F7C0,0x88D2,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-
-/* Predefined object types */
-DEFINE_GUID(GUID_XAxis,        0xA36D02E0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_YAxis,        0xA36D02E1,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_ZAxis,        0xA36D02E2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RxAxis,0xA36D02F4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RyAxis,0xA36D02F5,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_RzAxis,0xA36D02E3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Slider,0xA36D02E4,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Button,0xA36D02F0,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Key,  0x55728220,0xD33C,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_POV,  0xA36D02F2,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Unknown,0xA36D02F3,0xC9F3,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* Predefined product GUIDs */
-DEFINE_GUID(GUID_SysMouse,     0x6F1D2B60,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboard,  0x6F1D2B61,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_Joystick,     0x6F1D2B70,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysMouseEm,   0x6F1D2B80,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysMouseEm2,  0x6F1D2B81,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboardEm,        0x6F1D2B82,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-DEFINE_GUID(GUID_SysKeyboardEm2,0x6F1D2B83,0xD5A0,0x11CF,0xBF,0xC7,0x44,0x45,0x53,0x54,0x00,0x00);
-
-/* predefined forcefeedback effects */
-DEFINE_GUID(GUID_ConstantForce,        0x13541C20,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_RampForce,    0x13541C21,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Square,       0x13541C22,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Sine,         0x13541C23,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Triangle,     0x13541C24,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_SawtoothUp,   0x13541C25,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_SawtoothDown, 0x13541C26,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Spring,       0x13541C27,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Damper,       0x13541C28,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Inertia,      0x13541C29,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_Friction,     0x13541C2A,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-DEFINE_GUID(GUID_CustomForce,  0x13541C2B,0x8E33,0x11D0,0x9A,0xD0,0x00,0xA0,0xC9,0xA0,0x6E,0x35);
-
-typedef struct IDirectInputA *LPDIRECTINPUTA;
-typedef struct IDirectInputW *LPDIRECTINPUTW;
-typedef struct IDirectInput2A *LPDIRECTINPUT2A;
-typedef struct IDirectInput2W *LPDIRECTINPUT2W;
-typedef struct IDirectInput7A *LPDIRECTINPUT7A;
-typedef struct IDirectInput7W *LPDIRECTINPUT7W;
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct IDirectInput8A *LPDIRECTINPUT8A;
-typedef struct IDirectInput8W *LPDIRECTINPUT8W;
-#endif /* DI8 */
-typedef struct IDirectInputDeviceA *LPDIRECTINPUTDEVICEA;
-typedef struct IDirectInputDeviceW *LPDIRECTINPUTDEVICEW;
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef struct IDirectInputDevice2A *LPDIRECTINPUTDEVICE2A;
-typedef struct IDirectInputDevice2W *LPDIRECTINPUTDEVICE2W;
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x0700
-typedef struct IDirectInputDevice7A *LPDIRECTINPUTDEVICE7A;
-typedef struct IDirectInputDevice7W *LPDIRECTINPUTDEVICE7W;
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct IDirectInputDevice8A *LPDIRECTINPUTDEVICE8A;
-typedef struct IDirectInputDevice8W *LPDIRECTINPUTDEVICE8W;
-#endif /* DI8 */
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef struct IDirectInputEffect *LPDIRECTINPUTEFFECT;
-#endif /* DI5 */
-typedef struct SysKeyboardA *LPSYSKEYBOARDA;
-typedef struct SysMouseA *LPSYSMOUSEA;
-
-#define IID_IDirectInput WINELIB_NAME_AW(IID_IDirectInput)
-#define IDirectInput WINELIB_NAME_AW(IDirectInput)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT)
-#define IID_IDirectInput2 WINELIB_NAME_AW(IID_IDirectInput2)
-#define IDirectInput2 WINELIB_NAME_AW(IDirectInput2)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT2)
-#define IID_IDirectInput7 WINELIB_NAME_AW(IID_IDirectInput7)
-#define IDirectInput7 WINELIB_NAME_AW(IDirectInput7)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT7)
-#if DIRECTINPUT_VERSION >= 0x0800
-#define IID_IDirectInput8 WINELIB_NAME_AW(IID_IDirectInput8)
-#define IDirectInput8 WINELIB_NAME_AW(IDirectInput8)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUT8)
-#endif /* DI8 */
-#define IID_IDirectInputDevice WINELIB_NAME_AW(IID_IDirectInputDevice)
-#define IDirectInputDevice WINELIB_NAME_AW(IDirectInputDevice)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE)
-#if DIRECTINPUT_VERSION >= 0x0500
-#define IID_IDirectInputDevice2 WINELIB_NAME_AW(IID_IDirectInputDevice2)
-#define IDirectInputDevice2 WINELIB_NAME_AW(IDirectInputDevice2)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2)
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x0700
-#define IID_IDirectInputDevice7 WINELIB_NAME_AW(IID_IDirectInputDevice7)
-#define IDirectInputDevice7 WINELIB_NAME_AW(IDirectInputDevice7)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE7)
-#endif /* DI7 */
-#if DIRECTINPUT_VERSION >= 0x0800
-#define IID_IDirectInputDevice8 WINELIB_NAME_AW(IID_IDirectInputDevice8)
-#define IDirectInputDevice8 WINELIB_NAME_AW(IDirectInputDevice8)
-DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE8)
-#endif /* DI8 */
-
-#define DI_OK                           S_OK
-#define DI_NOTATTACHED                  S_FALSE
-#define DI_BUFFEROVERFLOW               S_FALSE
-#define DI_PROPNOEFFECT                 S_FALSE
-#define DI_NOEFFECT                     S_FALSE
-#define DI_POLLEDDEVICE                 ((HRESULT)0x00000002L)
-#define DI_DOWNLOADSKIPPED              ((HRESULT)0x00000003L)
-#define DI_EFFECTRESTARTED              ((HRESULT)0x00000004L)
-#define DI_TRUNCATED                    ((HRESULT)0x00000008L)
-#define DI_SETTINGSNOTSAVED             ((HRESULT)0x0000000BL)
-#define DI_TRUNCATEDANDRESTARTED        ((HRESULT)0x0000000CL)
-#define DI_WRITEPROTECT                 ((HRESULT)0x00000013L)
-
-#define DIERR_OLDDIRECTINPUTVERSION     \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_OLD_WIN_VERSION)
-#define DIERR_BETADIRECTINPUTVERSION    \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_RMODE_APP)
-#define DIERR_BADDRIVERVER              \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BAD_DRIVER_LEVEL)
-#define DIERR_DEVICENOTREG              REGDB_E_CLASSNOTREG
-#define DIERR_NOTFOUND                  \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
-#define DIERR_OBJECTNOTFOUND            \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_FILE_NOT_FOUND)
-#define DIERR_INVALIDPARAM              E_INVALIDARG
-#define DIERR_NOINTERFACE               E_NOINTERFACE
-#define DIERR_GENERIC                   E_FAIL
-#define DIERR_OUTOFMEMORY               E_OUTOFMEMORY
-#define DIERR_UNSUPPORTED               E_NOTIMPL
-#define DIERR_NOTINITIALIZED            \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_NOT_READY)
-#define DIERR_ALREADYINITIALIZED        \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_ALREADY_INITIALIZED)
-#define DIERR_NOAGGREGATION             CLASS_E_NOAGGREGATION
-#define DIERR_OTHERAPPHASPRIO           E_ACCESSDENIED
-#define DIERR_INPUTLOST                 \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_READ_FAULT)
-#define DIERR_ACQUIRED                  \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_BUSY)
-#define DIERR_NOTACQUIRED               \
-    MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, ERROR_INVALID_ACCESS)
-#define DIERR_READONLY                  E_ACCESSDENIED
-#define DIERR_HANDLEEXISTS              E_ACCESSDENIED
-#ifndef E_PENDING
-#define E_PENDING                       0x8000000AL
-#endif
-#define DIERR_INSUFFICIENTPRIVS         0x80040200L
-#define DIERR_DEVICEFULL                0x80040201L
-#define DIERR_MOREDATA                  0x80040202L
-#define DIERR_NOTDOWNLOADED             0x80040203L
-#define DIERR_HASEFFECTS                0x80040204L
-#define DIERR_NOTEXCLUSIVEACQUIRED      0x80040205L
-#define DIERR_INCOMPLETEEFFECT          0x80040206L
-#define DIERR_NOTBUFFERED               0x80040207L
-#define DIERR_EFFECTPLAYING             0x80040208L
-#define DIERR_UNPLUGGED                 0x80040209L
-#define DIERR_REPORTFULL                0x8004020AL
-#define DIERR_MAPFILEFAIL               0x8004020BL
-
-#define DIENUM_STOP                     0
-#define DIENUM_CONTINUE                 1
-
-#define DIEDFL_ALLDEVICES               0x00000000
-#define DIEDFL_ATTACHEDONLY             0x00000001
-#define DIEDFL_FORCEFEEDBACK            0x00000100
-#define DIEDFL_INCLUDEALIASES           0x00010000
-#define DIEDFL_INCLUDEPHANTOMS          0x00020000
-#define DIEDFL_INCLUDEHIDDEN           0x00040000
-
-#define DIDEVTYPE_DEVICE                1
-#define DIDEVTYPE_MOUSE                 2
-#define DIDEVTYPE_KEYBOARD              3
-#define DIDEVTYPE_JOYSTICK              4
-#define DIDEVTYPE_HID                   0x00010000
-
-#define DI8DEVCLASS_ALL             0
-#define DI8DEVCLASS_DEVICE          1
-#define DI8DEVCLASS_POINTER         2
-#define DI8DEVCLASS_KEYBOARD        3
-#define DI8DEVCLASS_GAMECTRL        4
-
-#define DI8DEVTYPE_DEVICE           0x11
-#define DI8DEVTYPE_MOUSE            0x12
-#define DI8DEVTYPE_KEYBOARD         0x13
-#define DI8DEVTYPE_JOYSTICK         0x14
-#define DI8DEVTYPE_GAMEPAD          0x15
-#define DI8DEVTYPE_DRIVING          0x16
-#define DI8DEVTYPE_FLIGHT           0x17
-#define DI8DEVTYPE_1STPERSON        0x18
-#define DI8DEVTYPE_DEVICECTRL       0x19
-#define DI8DEVTYPE_SCREENPOINTER    0x1A
-#define DI8DEVTYPE_REMOTE           0x1B
-#define DI8DEVTYPE_SUPPLEMENTAL     0x1C
-       
-#define DIDEVTYPEMOUSE_UNKNOWN          1
-#define DIDEVTYPEMOUSE_TRADITIONAL      2
-#define DIDEVTYPEMOUSE_FINGERSTICK      3
-#define DIDEVTYPEMOUSE_TOUCHPAD         4
-#define DIDEVTYPEMOUSE_TRACKBALL        5
-
-#define DIDEVTYPEKEYBOARD_UNKNOWN       0
-#define DIDEVTYPEKEYBOARD_PCXT          1
-#define DIDEVTYPEKEYBOARD_OLIVETTI      2
-#define DIDEVTYPEKEYBOARD_PCAT          3
-#define DIDEVTYPEKEYBOARD_PCENH         4
-#define DIDEVTYPEKEYBOARD_NOKIA1050     5
-#define DIDEVTYPEKEYBOARD_NOKIA9140     6
-#define DIDEVTYPEKEYBOARD_NEC98         7
-#define DIDEVTYPEKEYBOARD_NEC98LAPTOP   8
-#define DIDEVTYPEKEYBOARD_NEC98106      9
-#define DIDEVTYPEKEYBOARD_JAPAN106     10
-#define DIDEVTYPEKEYBOARD_JAPANAX      11
-#define DIDEVTYPEKEYBOARD_J3100        12
-
-#define DIDEVTYPEJOYSTICK_UNKNOWN       1
-#define DIDEVTYPEJOYSTICK_TRADITIONAL   2
-#define DIDEVTYPEJOYSTICK_FLIGHTSTICK   3
-#define DIDEVTYPEJOYSTICK_GAMEPAD       4
-#define DIDEVTYPEJOYSTICK_RUDDER        5
-#define DIDEVTYPEJOYSTICK_WHEEL         6
-#define DIDEVTYPEJOYSTICK_HEADTRACKER   7
-
-#define DI8DEVTYPEMOUSE_UNKNOWN                     1
-#define DI8DEVTYPEMOUSE_TRADITIONAL                 2
-#define DI8DEVTYPEMOUSE_FINGERSTICK                 3
-#define DI8DEVTYPEMOUSE_TOUCHPAD                    4
-#define DI8DEVTYPEMOUSE_TRACKBALL                   5
-#define DI8DEVTYPEMOUSE_ABSOLUTE                    6
-
-#define DI8DEVTYPEKEYBOARD_UNKNOWN                  0
-#define DI8DEVTYPEKEYBOARD_PCXT                     1
-#define DI8DEVTYPEKEYBOARD_OLIVETTI                 2
-#define DI8DEVTYPEKEYBOARD_PCAT                     3
-#define DI8DEVTYPEKEYBOARD_PCENH                    4
-#define DI8DEVTYPEKEYBOARD_NOKIA1050                5
-#define DI8DEVTYPEKEYBOARD_NOKIA9140                6
-#define DI8DEVTYPEKEYBOARD_NEC98                    7
-#define DI8DEVTYPEKEYBOARD_NEC98LAPTOP              8
-#define DI8DEVTYPEKEYBOARD_NEC98106                 9
-#define DI8DEVTYPEKEYBOARD_JAPAN106                10
-#define DI8DEVTYPEKEYBOARD_JAPANAX                 11
-#define DI8DEVTYPEKEYBOARD_J3100                   12
-
-#define DI8DEVTYPE_LIMITEDGAMESUBTYPE               1
-
-#define DI8DEVTYPEJOYSTICK_LIMITED                  DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEJOYSTICK_STANDARD                 2
-
-#define DI8DEVTYPEGAMEPAD_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEGAMEPAD_STANDARD                  2
-#define DI8DEVTYPEGAMEPAD_TILT                      3
-
-#define DI8DEVTYPEDRIVING_LIMITED                   DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEDRIVING_COMBINEDPEDALS            2
-#define DI8DEVTYPEDRIVING_DUALPEDALS                3
-#define DI8DEVTYPEDRIVING_THREEPEDALS               4
-#define DI8DEVTYPEDRIVING_HANDHELD                  5
-
-#define DI8DEVTYPEFLIGHT_LIMITED                    DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPEFLIGHT_STICK                      2
-#define DI8DEVTYPEFLIGHT_YOKE                       3
-#define DI8DEVTYPEFLIGHT_RC                         4
-
-#define DI8DEVTYPE1STPERSON_LIMITED                 DI8DEVTYPE_LIMITEDGAMESUBTYPE
-#define DI8DEVTYPE1STPERSON_UNKNOWN                 2
-#define DI8DEVTYPE1STPERSON_SIXDOF                  3
-#define DI8DEVTYPE1STPERSON_SHOOTER                 4
-
-#define DI8DEVTYPESCREENPTR_UNKNOWN                 2
-#define DI8DEVTYPESCREENPTR_LIGHTGUN                3
-#define DI8DEVTYPESCREENPTR_LIGHTPEN                4
-#define DI8DEVTYPESCREENPTR_TOUCH                   5
-
-#define DI8DEVTYPEREMOTE_UNKNOWN                    2
-
-#define DI8DEVTYPEDEVICECTRL_UNKNOWN                2
-#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION         3
-#define DI8DEVTYPEDEVICECTRL_COMMSSELECTION_HARDWIRED 4
-
-#define DI8DEVTYPESUPPLEMENTAL_UNKNOWN              2
-#define DI8DEVTYPESUPPLEMENTAL_2NDHANDCONTROLLER    3
-#define DI8DEVTYPESUPPLEMENTAL_HEADTRACKER          4
-#define DI8DEVTYPESUPPLEMENTAL_HANDTRACKER          5
-#define DI8DEVTYPESUPPLEMENTAL_SHIFTSTICKGATE       6
-#define DI8DEVTYPESUPPLEMENTAL_SHIFTER              7
-#define DI8DEVTYPESUPPLEMENTAL_THROTTLE             8
-#define DI8DEVTYPESUPPLEMENTAL_SPLITTHROTTLE        9
-#define DI8DEVTYPESUPPLEMENTAL_COMBINEDPEDALS      10
-#define DI8DEVTYPESUPPLEMENTAL_DUALPEDALS          11
-#define DI8DEVTYPESUPPLEMENTAL_THREEPEDALS         12
-#define DI8DEVTYPESUPPLEMENTAL_RUDDERPEDALS        13
-       
-#define GET_DIDEVICE_TYPE(dwDevType)     LOBYTE(dwDevType)
-#define GET_DIDEVICE_SUBTYPE(dwDevType)  HIBYTE(dwDevType)
-
-typedef struct DIDEVICEOBJECTINSTANCE_DX3A {
-    DWORD   dwSize;
-    GUID    guidType;
-    DWORD   dwOfs;
-    DWORD   dwType;
-    DWORD   dwFlags;
-    CHAR    tszName[MAX_PATH];
-} DIDEVICEOBJECTINSTANCE_DX3A, *LPDIDEVICEOBJECTINSTANCE_DX3A;
-typedef const DIDEVICEOBJECTINSTANCE_DX3A *LPCDIDEVICEOBJECTINSTANCE_DX3A;
-typedef struct DIDEVICEOBJECTINSTANCE_DX3W {
-    DWORD   dwSize;
-    GUID    guidType;
-    DWORD   dwOfs;
-    DWORD   dwType;
-    DWORD   dwFlags;
-    WCHAR   tszName[MAX_PATH];
-} DIDEVICEOBJECTINSTANCE_DX3W, *LPDIDEVICEOBJECTINSTANCE_DX3W;
-typedef const DIDEVICEOBJECTINSTANCE_DX3W *LPCDIDEVICEOBJECTINSTANCE_DX3W;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE_DX3)
-
-typedef struct DIDEVICEOBJECTINSTANCEA {
-    DWORD      dwSize;
-    GUID       guidType;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-    CHAR       tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFMaxForce;
-    DWORD      dwFFForceResolution;
-    WORD       wCollectionNumber;
-    WORD       wDesignatorIndex;
-    WORD       wUsagePage;
-    WORD       wUsage;
-    DWORD      dwDimension;
-    WORD       wExponent;
-    WORD       wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEOBJECTINSTANCEA, *LPDIDEVICEOBJECTINSTANCEA;
-typedef const DIDEVICEOBJECTINSTANCEA *LPCDIDEVICEOBJECTINSTANCEA;
-
-typedef struct DIDEVICEOBJECTINSTANCEW {
-    DWORD      dwSize;
-    GUID       guidType;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-    WCHAR      tszName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFMaxForce;
-    DWORD      dwFFForceResolution;
-    WORD       wCollectionNumber;
-    WORD       wDesignatorIndex;
-    WORD       wUsagePage;
-    WORD       wUsage;
-    DWORD      dwDimension;
-    WORD       wExponent;
-    WORD       wReserved;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEOBJECTINSTANCEW, *LPDIDEVICEOBJECTINSTANCEW;
-typedef const DIDEVICEOBJECTINSTANCEW *LPCDIDEVICEOBJECTINSTANCEW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEOBJECTINSTANCE)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEOBJECTINSTANCE)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEOBJECTINSTANCE)
-
-typedef struct DIDEVICEINSTANCE_DX3A {
-    DWORD   dwSize;
-    GUID    guidInstance;
-    GUID    guidProduct;
-    DWORD   dwDevType;
-    CHAR    tszInstanceName[MAX_PATH];
-    CHAR    tszProductName[MAX_PATH];
-} DIDEVICEINSTANCE_DX3A, *LPDIDEVICEINSTANCE_DX3A;
-typedef const DIDEVICEINSTANCE_DX3A *LPCDIDEVICEINSTANCE_DX3A;
-typedef struct DIDEVICEINSTANCE_DX3W {
-    DWORD   dwSize;
-    GUID    guidInstance;
-    GUID    guidProduct;
-    DWORD   dwDevType;
-    WCHAR   tszInstanceName[MAX_PATH];
-    WCHAR   tszProductName[MAX_PATH];
-} DIDEVICEINSTANCE_DX3W, *LPDIDEVICEINSTANCE_DX3W;
-typedef const DIDEVICEINSTANCE_DX3W *LPCDIDEVICEINSTANCE_DX3W;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE_DX3)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE_DX3)
-
-typedef struct DIDEVICEINSTANCEA {
-    DWORD      dwSize;
-    GUID       guidInstance;
-    GUID       guidProduct;
-    DWORD      dwDevType;
-    CHAR       tszInstanceName[MAX_PATH];
-    CHAR       tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    GUID       guidFFDriver;
-    WORD       wUsagePage;
-    WORD       wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEINSTANCEA, *LPDIDEVICEINSTANCEA;
-typedef const DIDEVICEINSTANCEA *LPCDIDEVICEINSTANCEA;
-
-typedef struct DIDEVICEINSTANCEW {
-    DWORD      dwSize;
-    GUID       guidInstance;
-    GUID       guidProduct;
-    DWORD      dwDevType;
-    WCHAR      tszInstanceName[MAX_PATH];
-    WCHAR      tszProductName[MAX_PATH];
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    GUID       guidFFDriver;
-    WORD       wUsagePage;
-    WORD       wUsage;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVICEINSTANCEW, *LPDIDEVICEINSTANCEW;
-typedef const DIDEVICEINSTANCEW *LPCDIDEVICEINSTANCEW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEINSTANCE)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEINSTANCE)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEINSTANCE)
-
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKA)(LPCDIDEVICEINSTANCEA,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICESCALLBACKW)(LPCDIDEVICEINSTANCEW,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESCALLBACK)
-
-#define DIEDBS_MAPPEDPRI1              0x00000001
-#define DIEDBS_MAPPEDPRI2              0x00000002
-#define DIEDBS_RECENTDEVICE            0x00000010
-#define DIEDBS_NEWDEVICE               0x00000020
-
-#define DIEDBSFL_ATTACHEDONLY          0x00000000
-#define DIEDBSFL_THISUSER              0x00000010
-#define DIEDBSFL_FORCEFEEDBACK         DIEDFL_FORCEFEEDBACK
-#define DIEDBSFL_AVAILABLEDEVICES      0x00001000
-#define DIEDBSFL_MULTIMICEKEYBOARDS    0x00002000
-#define DIEDBSFL_NONGAMINGDEVICES      0x00004000
-#define DIEDBSFL_VALID                 0x00007110
-
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBA)(LPCDIDEVICEINSTANCEA,LPDIRECTINPUTDEVICE8A,DWORD,DWORD,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICESBYSEMANTICSCBW)(LPCDIDEVICEINSTANCEW,LPDIRECTINPUTDEVICE8W,DWORD,DWORD,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICESBYSEMANTICSCB)
-#endif
-
-typedef BOOL (CALLBACK *LPDICONFIGUREDEVICESCALLBACK)(LPUNKNOWN,LPVOID);
-
-typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKA)(LPCDIDEVICEOBJECTINSTANCEA,LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMDEVICEOBJECTSCALLBACKW)(LPCDIDEVICEOBJECTINSTANCEW,LPVOID);
-DECL_WINELIB_TYPE_AW(LPDIENUMDEVICEOBJECTSCALLBACK)
-
-#if DIRECTINPUT_VERSION >= 0x0500
-typedef BOOL (CALLBACK *LPDIENUMCREATEDEFFECTOBJECTSCALLBACK)(LPDIRECTINPUTEFFECT, LPVOID);
-#endif
-
-#define DIK_ESCAPE          0x01
-#define DIK_1               0x02
-#define DIK_2               0x03
-#define DIK_3               0x04
-#define DIK_4               0x05
-#define DIK_5               0x06
-#define DIK_6               0x07
-#define DIK_7               0x08
-#define DIK_8               0x09
-#define DIK_9               0x0A
-#define DIK_0               0x0B
-#define DIK_MINUS           0x0C    /* - on main keyboard */
-#define DIK_EQUALS          0x0D
-#define DIK_BACK            0x0E    /* backspace */
-#define DIK_TAB             0x0F
-#define DIK_Q               0x10
-#define DIK_W               0x11
-#define DIK_E               0x12
-#define DIK_R               0x13
-#define DIK_T               0x14
-#define DIK_Y               0x15
-#define DIK_U               0x16
-#define DIK_I               0x17
-#define DIK_O               0x18
-#define DIK_P               0x19
-#define DIK_LBRACKET        0x1A
-#define DIK_RBRACKET        0x1B
-#define DIK_RETURN          0x1C    /* Enter on main keyboard */
-#define DIK_LCONTROL        0x1D
-#define DIK_A               0x1E
-#define DIK_S               0x1F
-#define DIK_D               0x20
-#define DIK_F               0x21
-#define DIK_G               0x22
-#define DIK_H               0x23
-#define DIK_J               0x24
-#define DIK_K               0x25
-#define DIK_L               0x26
-#define DIK_SEMICOLON       0x27
-#define DIK_APOSTROPHE      0x28
-#define DIK_GRAVE           0x29    /* accent grave */
-#define DIK_LSHIFT          0x2A
-#define DIK_BACKSLASH       0x2B
-#define DIK_Z               0x2C
-#define DIK_X               0x2D
-#define DIK_C               0x2E
-#define DIK_V               0x2F
-#define DIK_B               0x30
-#define DIK_N               0x31
-#define DIK_M               0x32
-#define DIK_COMMA           0x33
-#define DIK_PERIOD          0x34    /* . on main keyboard */
-#define DIK_SLASH           0x35    /* / on main keyboard */
-#define DIK_RSHIFT          0x36
-#define DIK_MULTIPLY        0x37    /* * on numeric keypad */
-#define DIK_LMENU           0x38    /* left Alt */
-#define DIK_SPACE           0x39
-#define DIK_CAPITAL         0x3A
-#define DIK_F1              0x3B
-#define DIK_F2              0x3C
-#define DIK_F3              0x3D
-#define DIK_F4              0x3E
-#define DIK_F5              0x3F
-#define DIK_F6              0x40
-#define DIK_F7              0x41
-#define DIK_F8              0x42
-#define DIK_F9              0x43
-#define DIK_F10             0x44
-#define DIK_NUMLOCK         0x45
-#define DIK_SCROLL          0x46    /* Scroll Lock */
-#define DIK_NUMPAD7         0x47
-#define DIK_NUMPAD8         0x48
-#define DIK_NUMPAD9         0x49
-#define DIK_SUBTRACT        0x4A    /* - on numeric keypad */
-#define DIK_NUMPAD4         0x4B
-#define DIK_NUMPAD5         0x4C
-#define DIK_NUMPAD6         0x4D
-#define DIK_ADD             0x4E    /* + on numeric keypad */
-#define DIK_NUMPAD1         0x4F
-#define DIK_NUMPAD2         0x50
-#define DIK_NUMPAD3         0x51
-#define DIK_NUMPAD0         0x52
-#define DIK_DECIMAL         0x53    /* . on numeric keypad */
-#define DIK_OEM_102         0x56    /* < > | on UK/Germany keyboards */
-#define DIK_F11             0x57
-#define DIK_F12             0x58
-#define DIK_F13             0x64    /*                     (NEC PC98) */
-#define DIK_F14             0x65    /*                     (NEC PC98) */
-#define DIK_F15             0x66    /*                     (NEC PC98) */
-#define DIK_KANA            0x70    /* (Japanese keyboard)            */
-#define DIK_ABNT_C1         0x73    /* / ? on Portugese (Brazilian) keyboards */
-#define DIK_CONVERT         0x79    /* (Japanese keyboard)            */
-#define DIK_NOCONVERT       0x7B    /* (Japanese keyboard)            */
-#define DIK_YEN             0x7D    /* (Japanese keyboard)            */
-#define DIK_ABNT_C2         0x7E    /* Numpad . on Portugese (Brazilian) keyboards */
-#define DIK_NUMPADEQUALS    0x8D    /* = on numeric keypad (NEC PC98) */
-#define DIK_CIRCUMFLEX      0x90    /* (Japanese keyboard)            */
-#define DIK_AT              0x91    /*                     (NEC PC98) */
-#define DIK_COLON           0x92    /*                     (NEC PC98) */
-#define DIK_UNDERLINE       0x93    /*                     (NEC PC98) */
-#define DIK_KANJI           0x94    /* (Japanese keyboard)            */
-#define DIK_STOP            0x95    /*                     (NEC PC98) */
-#define DIK_AX              0x96    /*                     (Japan AX) */
-#define DIK_UNLABELED       0x97    /*                        (J3100) */
-#define DIK_NEXTTRACK       0x99    /* Next Track */
-#define DIK_NUMPADENTER     0x9C    /* Enter on numeric keypad */
-#define DIK_RCONTROL        0x9D
-#define DIK_MUTE           0xA0    /* Mute */
-#define DIK_CALCULATOR      0xA1    /* Calculator */
-#define DIK_PLAYPAUSE       0xA2    /* Play / Pause */
-#define DIK_MEDIASTOP       0xA4    /* Media Stop */
-#define DIK_VOLUMEDOWN      0xAE    /* Volume - */
-#define DIK_VOLUMEUP        0xB0    /* Volume + */
-#define DIK_WEBHOME         0xB2    /* Web home */
-#define DIK_NUMPADCOMMA     0xB3    /* , on numeric keypad (NEC PC98) */
-#define DIK_DIVIDE          0xB5    /* / on numeric keypad */
-#define DIK_SYSRQ           0xB7
-#define DIK_RMENU           0xB8    /* right Alt */
-#define DIK_PAUSE           0xC5    /* Pause */
-#define DIK_HOME            0xC7    /* Home on arrow keypad */
-#define DIK_UP              0xC8    /* UpArrow on arrow keypad */
-#define DIK_PRIOR           0xC9    /* PgUp on arrow keypad */
-#define DIK_LEFT            0xCB    /* LeftArrow on arrow keypad */
-#define DIK_RIGHT           0xCD    /* RightArrow on arrow keypad */
-#define DIK_END             0xCF    /* End on arrow keypad */
-#define DIK_DOWN            0xD0    /* DownArrow on arrow keypad */
-#define DIK_NEXT            0xD1    /* PgDn on arrow keypad */
-#define DIK_INSERT          0xD2    /* Insert on arrow keypad */
-#define DIK_DELETE          0xD3    /* Delete on arrow keypad */
-#define DIK_LWIN            0xDB    /* Left Windows key */
-#define DIK_RWIN            0xDC    /* Right Windows key */
-#define DIK_APPS            0xDD    /* AppMenu key */
-#define DIK_POWER           0xDE
-#define DIK_SLEEP           0xDF
-#define DIK_WAKE            0xE3    /* System Wake */
-#define DIK_WEBSEARCH       0xE5    /* Web Search */
-#define DIK_WEBFAVORITES    0xE6    /* Web Favorites */
-#define DIK_WEBREFRESH      0xE7    /* Web Refresh */
-#define DIK_WEBSTOP         0xE8    /* Web Stop */
-#define DIK_WEBFORWARD      0xE9    /* Web Forward */
-#define DIK_WEBBACK         0xEA    /* Web Back */
-#define DIK_MYCOMPUTER      0xEB    /* My Computer */
-#define DIK_MAIL            0xEC    /* Mail */
-#define DIK_MEDIASELECT     0xED    /* Media Select */
-
-#define DIK_BACKSPACE       DIK_BACK            /* backspace */
-#define DIK_NUMPADSTAR      DIK_MULTIPLY        /* * on numeric keypad */
-#define DIK_LALT            DIK_LMENU           /* left Alt */
-#define DIK_CAPSLOCK        DIK_CAPITAL         /* CapsLock */
-#define DIK_NUMPADMINUS     DIK_SUBTRACT        /* - on numeric keypad */
-#define DIK_NUMPADPLUS      DIK_ADD             /* + on numeric keypad */
-#define DIK_NUMPADPERIOD    DIK_DECIMAL         /* . on numeric keypad */
-#define DIK_NUMPADSLASH     DIK_DIVIDE          /* / on numeric keypad */
-#define DIK_RALT            DIK_RMENU           /* right Alt */
-#define DIK_UPARROW         DIK_UP              /* UpArrow on arrow keypad */
-#define DIK_PGUP            DIK_PRIOR           /* PgUp on arrow keypad */
-#define DIK_LEFTARROW       DIK_LEFT            /* LeftArrow on arrow keypad */
-#define DIK_RIGHTARROW      DIK_RIGHT           /* RightArrow on arrow keypad */
-#define DIK_DOWNARROW       DIK_DOWN            /* DownArrow on arrow keypad */
-#define DIK_PGDN            DIK_NEXT            /* PgDn on arrow keypad */
-
-#define DIDFT_ALL              0x00000000
-#define DIDFT_RELAXIS          0x00000001
-#define DIDFT_ABSAXIS          0x00000002
-#define DIDFT_AXIS             0x00000003
-#define DIDFT_PSHBUTTON                0x00000004
-#define DIDFT_TGLBUTTON                0x00000008
-#define DIDFT_BUTTON           0x0000000C
-#define DIDFT_POV              0x00000010
-#define DIDFT_COLLECTION       0x00000040
-#define DIDFT_NODATA           0x00000080
-#define DIDFT_ANYINSTANCE      0x00FFFF00
-#define DIDFT_INSTANCEMASK     DIDFT_ANYINSTANCE
-#define DIDFT_MAKEINSTANCE(n)  ((WORD)(n) << 8)
-#define DIDFT_GETTYPE(n)       LOBYTE(n)
-#define DIDFT_GETINSTANCE(n)   LOWORD((n) >> 8)
-#define DIDFT_FFACTUATOR       0x01000000
-#define DIDFT_FFEFFECTTRIGGER  0x02000000
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIDFT_OUTPUT           0x10000000
-#define DIDFT_VENDORDEFINED    0x04000000
-#define DIDFT_ALIAS            0x08000000
-#endif /* DI5a */
-#ifndef DIDFT_OPTIONAL
-#define DIDFT_OPTIONAL         0x80000000
-#endif
-#define DIDFT_ENUMCOLLECTION(n)        ((WORD)(n) << 8)
-#define DIDFT_NOCOLLECTION     0x00FFFF00
-
-#define DIDF_ABSAXIS           0x00000001
-#define DIDF_RELAXIS           0x00000002
-
-#define DIGDD_PEEK             0x00000001
-
-#define DISEQUENCE_COMPARE(dwSq1,cmp,dwSq2) ((int)((dwSq1) - (dwSq2)) cmp 0)
-
-typedef struct DIDEVICEOBJECTDATA_DX3 {
-    DWORD      dwOfs;
-    DWORD      dwData;
-    DWORD      dwTimeStamp;
-    DWORD      dwSequence;
-} DIDEVICEOBJECTDATA_DX3,*LPDIDEVICEOBJECTDATA_DX3;
-typedef const DIDEVICEOBJECTDATA_DX3 *LPCDIDEVICEOBJECTDATA_DX3;
-
-typedef struct DIDEVICEOBJECTDATA {
-    DWORD      dwOfs;
-    DWORD      dwData;
-    DWORD      dwTimeStamp;
-    DWORD      dwSequence;
-#if(DIRECTINPUT_VERSION >= 0x0800)
-    UINT_PTR   uAppData;
-#endif /* DIRECTINPUT_VERSION >= 0x0800 */
-} DIDEVICEOBJECTDATA, *LPDIDEVICEOBJECTDATA;
-typedef const DIDEVICEOBJECTDATA *LPCDIDEVICEOBJECTDATA;
-
-typedef struct _DIOBJECTDATAFORMAT {
-    const GUID *pguid;
-    DWORD      dwOfs;
-    DWORD      dwType;
-    DWORD      dwFlags;
-} DIOBJECTDATAFORMAT, *LPDIOBJECTDATAFORMAT;
-typedef const DIOBJECTDATAFORMAT *LPCDIOBJECTDATAFORMAT;
-
-typedef struct _DIDATAFORMAT {
-    DWORD                      dwSize;
-    DWORD                      dwObjSize;
-    DWORD                      dwFlags;
-    DWORD                      dwDataSize;
-    DWORD                      dwNumObjs;
-    LPDIOBJECTDATAFORMAT       rgodf;
-} DIDATAFORMAT, *LPDIDATAFORMAT;
-typedef const DIDATAFORMAT *LPCDIDATAFORMAT;
-
-#if DIRECTINPUT_VERSION >= 0x0500
-#define DIDOI_FFACTUATOR       0x00000001
-#define DIDOI_FFEFFECTTRIGGER  0x00000002
-#define DIDOI_POLLED           0x00008000
-#define DIDOI_ASPECTPOSITION   0x00000100
-#define DIDOI_ASPECTVELOCITY   0x00000200
-#define DIDOI_ASPECTACCEL      0x00000300
-#define DIDOI_ASPECTFORCE      0x00000400
-#define DIDOI_ASPECTMASK       0x00000F00
-#endif /* DI5 */
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIDOI_GUIDISUSAGE      0x00010000
-#endif /* DI5a */
-
-typedef struct DIPROPHEADER {
-    DWORD      dwSize;
-    DWORD      dwHeaderSize;
-    DWORD      dwObj;
-    DWORD      dwHow;
-} DIPROPHEADER,*LPDIPROPHEADER;
-typedef const DIPROPHEADER *LPCDIPROPHEADER;
-
-#define DIPH_DEVICE    0
-#define DIPH_BYOFFSET  1
-#define DIPH_BYID      2
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIPH_BYUSAGE   3
-
-#define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage)
-#endif /* DI5a */
-
-typedef struct DIPROPDWORD {
-       DIPROPHEADER    diph;
-       DWORD           dwData;
-} DIPROPDWORD, *LPDIPROPDWORD;
-typedef const DIPROPDWORD *LPCDIPROPDWORD;
-
-typedef struct DIPROPRANGE {
-       DIPROPHEADER    diph;
-       LONG            lMin;
-       LONG            lMax;
-} DIPROPRANGE, *LPDIPROPRANGE;
-typedef const DIPROPRANGE *LPCDIPROPRANGE;
-
-#define DIPROPRANGE_NOMIN      ((LONG)0x80000000)
-#define DIPROPRANGE_NOMAX      ((LONG)0x7FFFFFFF)
-
-#if DIRECTINPUT_VERSION >= 0x050a
-typedef struct DIPROPCAL {
-       DIPROPHEADER diph;
-       LONG    lMin;
-       LONG    lCenter;
-       LONG    lMax;
-} DIPROPCAL, *LPDIPROPCAL;
-typedef const DIPROPCAL *LPCDIPROPCAL;
-
-typedef struct DIPROPCALPOV {
-       DIPROPHEADER    diph;
-       LONG            lMin[5];
-       LONG            lMax[5];
-} DIPROPCALPOV, *LPDIPROPCALPOV;
-typedef const DIPROPCALPOV *LPCDIPROPCALPOV;
-
-typedef struct DIPROPGUIDANDPATH {
-       DIPROPHEADER diph;
-       GUID    guidClass;
-       WCHAR   wszPath[MAX_PATH];
-} DIPROPGUIDANDPATH, *LPDIPROPGUIDANDPATH;
-typedef const DIPROPGUIDANDPATH *LPCDIPROPGUIDANDPATH;
-
-typedef struct DIPROPSTRING {
-        DIPROPHEADER diph;
-        WCHAR        wsz[MAX_PATH];
-} DIPROPSTRING, *LPDIPROPSTRING;
-typedef const DIPROPSTRING *LPCDIPROPSTRING;
-#endif /* DI5a */
-
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct DIPROPPOINTER {
-       DIPROPHEADER diph;
-       UINT_PTR     uData;
-} DIPROPPOINTER, *LPDIPROPPOINTER;
-typedef const DIPROPPOINTER *LPCDIPROPPOINTER;
-#endif /* DI8 */
-
-/* special property GUIDs */
-#ifdef __cplusplus
-#define MAKEDIPROP(prop)       (*(const GUID *)(prop))
-#else
-#define MAKEDIPROP(prop)       ((REFGUID)(prop))
-#endif
-#define DIPROP_BUFFERSIZE      MAKEDIPROP(1)
-#define DIPROP_AXISMODE                MAKEDIPROP(2)
-
-#define DIPROPAXISMODE_ABS     0
-#define DIPROPAXISMODE_REL     1
-
-#define DIPROP_GRANULARITY     MAKEDIPROP(3)
-#define DIPROP_RANGE           MAKEDIPROP(4)
-#define DIPROP_DEADZONE                MAKEDIPROP(5)
-#define DIPROP_SATURATION      MAKEDIPROP(6)
-#define DIPROP_FFGAIN          MAKEDIPROP(7)
-#define DIPROP_FFLOAD          MAKEDIPROP(8)
-#define DIPROP_AUTOCENTER      MAKEDIPROP(9)
-
-#define DIPROPAUTOCENTER_OFF   0
-#define DIPROPAUTOCENTER_ON    1
-
-#define DIPROP_CALIBRATIONMODE MAKEDIPROP(10)
-
-#define DIPROPCALIBRATIONMODE_COOKED   0
-#define DIPROPCALIBRATIONMODE_RAW      1
-
-#if DIRECTINPUT_VERSION >= 0x050a
-#define DIPROP_CALIBRATION     MAKEDIPROP(11)
-#define DIPROP_GUIDANDPATH     MAKEDIPROP(12)
-#define DIPROP_INSTANCENAME    MAKEDIPROP(13)
-#define DIPROP_PRODUCTNAME     MAKEDIPROP(14)
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x5B2
-#define DIPROP_JOYSTICKID      MAKEDIPROP(15)
-#define DIPROP_GETPORTDISPLAYNAME      MAKEDIPROP(16)
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x0700
-#define DIPROP_PHYSICALRANGE   MAKEDIPROP(18)
-#define DIPROP_LOGICALRANGE    MAKEDIPROP(19)
-#endif
-
-#if(DIRECTINPUT_VERSION >= 0x0800)
-#define DIPROP_KEYNAME         MAKEDIPROP(20)
-#define DIPROP_CPOINTS         MAKEDIPROP(21)
-#define DIPROP_APPDATA         MAKEDIPROP(22)
-#define DIPROP_SCANCODE                MAKEDIPROP(23)
-#define DIPROP_VIDPID          MAKEDIPROP(24)
-#define DIPROP_USERNAME                MAKEDIPROP(25)
-#define DIPROP_TYPENAME                MAKEDIPROP(26)
-
-#define MAXCPOINTSNUM          8
-
-typedef struct _CPOINT {
-    LONG       lP;
-    DWORD      dwLog;
-} CPOINT, *PCPOINT;
-
-typedef struct DIPROPCPOINTS {
-    DIPROPHEADER diph;
-    DWORD      dwCPointsNum;
-    CPOINT     cp[MAXCPOINTSNUM];
-} DIPROPCPOINTS, *LPDIPROPCPOINTS;
-typedef const DIPROPCPOINTS *LPCDIPROPCPOINTS;
-#endif /* DI8 */
-
-
-typedef struct DIDEVCAPS_DX3 {
-    DWORD      dwSize;
-    DWORD      dwFlags;
-    DWORD      dwDevType;
-    DWORD      dwAxes;
-    DWORD      dwButtons;
-    DWORD      dwPOVs;
-} DIDEVCAPS_DX3, *LPDIDEVCAPS_DX3;
-
-typedef struct DIDEVCAPS {
-    DWORD      dwSize;
-    DWORD      dwFlags;
-    DWORD      dwDevType;
-    DWORD      dwAxes;
-    DWORD      dwButtons;
-    DWORD      dwPOVs;
-#if(DIRECTINPUT_VERSION >= 0x0500)
-    DWORD      dwFFSamplePeriod;
-    DWORD      dwFFMinTimeResolution;
-    DWORD      dwFirmwareRevision;
-    DWORD      dwHardwareRevision;
-    DWORD      dwFFDriverVersion;
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-} DIDEVCAPS,*LPDIDEVCAPS;
-
-#define DIDC_ATTACHED          0x00000001
-#define DIDC_POLLEDDEVICE      0x00000002
-#define DIDC_EMULATED          0x00000004
-#define DIDC_POLLEDDATAFORMAT  0x00000008
-#define DIDC_FORCEFEEDBACK     0x00000100
-#define DIDC_FFATTACK          0x00000200
-#define DIDC_FFFADE            0x00000400
-#define DIDC_SATURATION                0x00000800
-#define DIDC_POSNEGCOEFFICIENTS        0x00001000
-#define DIDC_POSNEGSATURATION  0x00002000
-#define DIDC_DEADBAND          0x00004000
-#define DIDC_STARTDELAY                0x00008000
-#define DIDC_ALIAS             0x00010000
-#define DIDC_PHANTOM           0x00020000
-#define DIDC_HIDDEN            0x00040000
-
-
-/* SetCooperativeLevel dwFlags */
-#define DISCL_EXCLUSIVE                0x00000001
-#define DISCL_NONEXCLUSIVE     0x00000002
-#define DISCL_FOREGROUND       0x00000004
-#define DISCL_BACKGROUND       0x00000008
-#define DISCL_NOWINKEY          0x00000010
-
-#if (DIRECTINPUT_VERSION >= 0x0500)
-/* Device FF flags */
-#define DISFFC_RESET            0x00000001
-#define DISFFC_STOPALL          0x00000002
-#define DISFFC_PAUSE            0x00000004
-#define DISFFC_CONTINUE         0x00000008
-#define DISFFC_SETACTUATORSON   0x00000010
-#define DISFFC_SETACTUATORSOFF  0x00000020
-
-#define DIGFFS_EMPTY            0x00000001
-#define DIGFFS_STOPPED          0x00000002
-#define DIGFFS_PAUSED           0x00000004
-#define DIGFFS_ACTUATORSON      0x00000010
-#define DIGFFS_ACTUATORSOFF     0x00000020
-#define DIGFFS_POWERON          0x00000040
-#define DIGFFS_POWEROFF         0x00000080
-#define DIGFFS_SAFETYSWITCHON   0x00000100
-#define DIGFFS_SAFETYSWITCHOFF  0x00000200
-#define DIGFFS_USERFFSWITCHON   0x00000400
-#define DIGFFS_USERFFSWITCHOFF  0x00000800
-#define DIGFFS_DEVICELOST       0x80000000
-
-/* Effect flags */
-#define DIEFT_ALL              0x00000000
-
-#define DIEFT_CONSTANTFORCE    0x00000001
-#define DIEFT_RAMPFORCE                0x00000002
-#define DIEFT_PERIODIC         0x00000003
-#define DIEFT_CONDITION                0x00000004
-#define DIEFT_CUSTOMFORCE      0x00000005
-#define DIEFT_HARDWARE         0x000000FF
-#define DIEFT_FFATTACK         0x00000200
-#define DIEFT_FFFADE           0x00000400
-#define DIEFT_SATURATION       0x00000800
-#define DIEFT_POSNEGCOEFFICIENTS 0x00001000
-#define DIEFT_POSNEGSATURATION 0x00002000
-#define DIEFT_DEADBAND         0x00004000
-#define DIEFT_STARTDELAY       0x00008000
-#define DIEFT_GETTYPE(n)       LOBYTE(n)
-
-#define DIEFF_OBJECTIDS         0x00000001
-#define DIEFF_OBJECTOFFSETS     0x00000002
-#define DIEFF_CARTESIAN         0x00000010
-#define DIEFF_POLAR             0x00000020
-#define DIEFF_SPHERICAL         0x00000040
-
-#define DIEP_DURATION           0x00000001
-#define DIEP_SAMPLEPERIOD       0x00000002
-#define DIEP_GAIN               0x00000004
-#define DIEP_TRIGGERBUTTON      0x00000008
-#define DIEP_TRIGGERREPEATINTERVAL 0x00000010
-#define DIEP_AXES               0x00000020
-#define DIEP_DIRECTION          0x00000040
-#define DIEP_ENVELOPE           0x00000080
-#define DIEP_TYPESPECIFICPARAMS 0x00000100
-#if(DIRECTINPUT_VERSION >= 0x0600)
-#define DIEP_STARTDELAY         0x00000200
-#define DIEP_ALLPARAMS_DX5      0x000001FF
-#define DIEP_ALLPARAMS          0x000003FF
-#else
-#define DIEP_ALLPARAMS          0x000001FF
-#endif /* DIRECTINPUT_VERSION >= 0x0600 */
-#define DIEP_START              0x20000000
-#define DIEP_NORESTART          0x40000000
-#define DIEP_NODOWNLOAD         0x80000000
-#define DIEB_NOTRIGGER          0xFFFFFFFF
-
-#define DIES_SOLO               0x00000001
-#define DIES_NODOWNLOAD         0x80000000
-
-#define DIEGES_PLAYING          0x00000001
-#define DIEGES_EMULATED         0x00000002
-
-#define DI_DEGREES             100
-#define DI_FFNOMINALMAX                10000
-#define DI_SECONDS             1000000
-
-typedef struct DICONSTANTFORCE {
-       LONG                    lMagnitude;
-} DICONSTANTFORCE, *LPDICONSTANTFORCE;
-typedef const DICONSTANTFORCE *LPCDICONSTANTFORCE;
-
-typedef struct DIRAMPFORCE {
-       LONG                    lStart;
-       LONG                    lEnd;
-} DIRAMPFORCE, *LPDIRAMPFORCE;
-typedef const DIRAMPFORCE *LPCDIRAMPFORCE;
-
-typedef struct DIPERIODIC {
-       DWORD                   dwMagnitude;
-       LONG                    lOffset;
-       DWORD                   dwPhase;
-       DWORD                   dwPeriod;
-} DIPERIODIC, *LPDIPERIODIC;
-typedef const DIPERIODIC *LPCDIPERIODIC;
-
-typedef struct DICONDITION {
-       LONG                    lOffset;
-       LONG                    lPositiveCoefficient;
-       LONG                    lNegativeCoefficient;
-       DWORD                   dwPositiveSaturation;
-       DWORD                   dwNegativeSaturation;
-       LONG                    lDeadBand;
-} DICONDITION, *LPDICONDITION;
-typedef const DICONDITION *LPCDICONDITION;
-
-typedef struct DICUSTOMFORCE {
-       DWORD                   cChannels;
-       DWORD                   dwSamplePeriod;
-       DWORD                   cSamples;
-       LPLONG                  rglForceData;
-} DICUSTOMFORCE, *LPDICUSTOMFORCE;
-typedef const DICUSTOMFORCE *LPCDICUSTOMFORCE;
-
-typedef struct DIENVELOPE {
-       DWORD                   dwSize;
-       DWORD                   dwAttackLevel;
-       DWORD                   dwAttackTime;
-       DWORD                   dwFadeLevel;
-       DWORD                   dwFadeTime;
-} DIENVELOPE, *LPDIENVELOPE;
-typedef const DIENVELOPE *LPCDIENVELOPE;
-
-typedef struct DIEFFECT_DX5 {
-       DWORD                   dwSize;
-       DWORD                   dwFlags;
-       DWORD                   dwDuration;
-       DWORD                   dwSamplePeriod;
-       DWORD                   dwGain;
-       DWORD                   dwTriggerButton;
-       DWORD                   dwTriggerRepeatInterval;
-       DWORD                   cAxes;
-       LPDWORD                 rgdwAxes;
-       LPLONG                  rglDirection;
-       LPDIENVELOPE            lpEnvelope;
-       DWORD                   cbTypeSpecificParams;
-       LPVOID                  lpvTypeSpecificParams;
-} DIEFFECT_DX5, *LPDIEFFECT_DX5;
-typedef const DIEFFECT_DX5 *LPCDIEFFECT_DX5;
-
-typedef struct DIEFFECT {
-       DWORD                   dwSize;
-       DWORD                   dwFlags;
-       DWORD                   dwDuration;
-       DWORD                   dwSamplePeriod;
-       DWORD                   dwGain;
-       DWORD                   dwTriggerButton;
-       DWORD                   dwTriggerRepeatInterval;
-       DWORD                   cAxes;
-       LPDWORD                 rgdwAxes;
-       LPLONG                  rglDirection;
-       LPDIENVELOPE            lpEnvelope;
-       DWORD                   cbTypeSpecificParams;
-       LPVOID                  lpvTypeSpecificParams;
-#if(DIRECTINPUT_VERSION >= 0x0600)
-       DWORD                   dwStartDelay;
-#endif /* DIRECTINPUT_VERSION >= 0x0600 */
-} DIEFFECT, *LPDIEFFECT;
-typedef const DIEFFECT *LPCDIEFFECT;
-typedef DIEFFECT DIEFFECT_DX6;
-typedef LPDIEFFECT LPDIEFFECT_DX6;
-
-typedef struct DIEFFECTINFOA {
-       DWORD                   dwSize;
-       GUID                    guid;
-       DWORD                   dwEffType;
-       DWORD                   dwStaticParams;
-       DWORD                   dwDynamicParams;
-       CHAR                    tszName[MAX_PATH];
-} DIEFFECTINFOA, *LPDIEFFECTINFOA;
-typedef const DIEFFECTINFOA *LPCDIEFFECTINFOA;
-
-typedef struct DIEFFECTINFOW {
-       DWORD                   dwSize;
-       GUID                    guid;
-       DWORD                   dwEffType;
-       DWORD                   dwStaticParams;
-       DWORD                   dwDynamicParams;
-       WCHAR                   tszName[MAX_PATH];
-} DIEFFECTINFOW, *LPDIEFFECTINFOW;
-typedef const DIEFFECTINFOW *LPCDIEFFECTINFOW;
-
-DECL_WINELIB_TYPE_AW(DIEFFECTINFO)
-DECL_WINELIB_TYPE_AW(LPDIEFFECTINFO)
-DECL_WINELIB_TYPE_AW(LPCDIEFFECTINFO)
-
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID);
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID);
-
-typedef struct DIEFFESCAPE {
-       DWORD   dwSize;
-       DWORD   dwCommand;
-       LPVOID  lpvInBuffer;
-       DWORD   cbInBuffer;
-       LPVOID  lpvOutBuffer;
-       DWORD   cbOutBuffer;
-} DIEFFESCAPE, *LPDIEFFESCAPE;
-
-typedef struct DIJOYSTATE {
-       LONG    lX;
-       LONG    lY;
-       LONG    lZ;
-       LONG    lRx;
-       LONG    lRy;
-       LONG    lRz;
-       LONG    rglSlider[2];
-       DWORD   rgdwPOV[4];
-       BYTE    rgbButtons[32];
-} DIJOYSTATE, *LPDIJOYSTATE;
-
-typedef struct DIJOYSTATE2 {
-       LONG    lX;
-       LONG    lY;
-       LONG    lZ;
-       LONG    lRx;
-       LONG    lRy;
-       LONG    lRz;
-       LONG    rglSlider[2];
-       DWORD   rgdwPOV[4];
-       BYTE    rgbButtons[128];
-       LONG    lVX;            /* 'v' as in velocity */
-       LONG    lVY;
-       LONG    lVZ;
-       LONG    lVRx;
-       LONG    lVRy;
-       LONG    lVRz;
-       LONG    rglVSlider[2];
-       LONG    lAX;            /* 'a' as in acceleration */
-       LONG    lAY;
-       LONG    lAZ;
-       LONG    lARx;
-       LONG    lARy;
-       LONG    lARz;
-       LONG    rglASlider[2];
-       LONG    lFX;            /* 'f' as in force */
-       LONG    lFY;
-       LONG    lFZ;
-       LONG    lFRx;           /* 'fr' as in rotational force aka torque */
-       LONG    lFRy;
-       LONG    lFRz;
-       LONG    rglFSlider[2];
-} DIJOYSTATE2, *LPDIJOYSTATE2;
-
-#define DIJOFS_X               FIELD_OFFSET(DIJOYSTATE, lX)
-#define DIJOFS_Y               FIELD_OFFSET(DIJOYSTATE, lY)
-#define DIJOFS_Z               FIELD_OFFSET(DIJOYSTATE, lZ)
-#define DIJOFS_RX              FIELD_OFFSET(DIJOYSTATE, lRx)
-#define DIJOFS_RY              FIELD_OFFSET(DIJOYSTATE, lRy)
-#define DIJOFS_RZ              FIELD_OFFSET(DIJOYSTATE, lRz)
-#define DIJOFS_SLIDER(n)       (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \
-                                                        (n) * sizeof(LONG))
-#define DIJOFS_POV(n)          (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \
-                                                        (n) * sizeof(DWORD))
-#define DIJOFS_BUTTON(n)       (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n))
-#define DIJOFS_BUTTON0         DIJOFS_BUTTON(0)
-#define DIJOFS_BUTTON1         DIJOFS_BUTTON(1)
-#define DIJOFS_BUTTON2         DIJOFS_BUTTON(2)
-#define DIJOFS_BUTTON3         DIJOFS_BUTTON(3)
-#define DIJOFS_BUTTON4         DIJOFS_BUTTON(4)
-#define DIJOFS_BUTTON5         DIJOFS_BUTTON(5)
-#define DIJOFS_BUTTON6         DIJOFS_BUTTON(6)
-#define DIJOFS_BUTTON7         DIJOFS_BUTTON(7)
-#define DIJOFS_BUTTON8         DIJOFS_BUTTON(8)
-#define DIJOFS_BUTTON9         DIJOFS_BUTTON(9)
-#define DIJOFS_BUTTON10                DIJOFS_BUTTON(10)
-#define DIJOFS_BUTTON11                DIJOFS_BUTTON(11)
-#define DIJOFS_BUTTON12                DIJOFS_BUTTON(12)
-#define DIJOFS_BUTTON13                DIJOFS_BUTTON(13)
-#define DIJOFS_BUTTON14                DIJOFS_BUTTON(14)
-#define DIJOFS_BUTTON15                DIJOFS_BUTTON(15)
-#define DIJOFS_BUTTON16                DIJOFS_BUTTON(16)
-#define DIJOFS_BUTTON17                DIJOFS_BUTTON(17)
-#define DIJOFS_BUTTON18                DIJOFS_BUTTON(18)
-#define DIJOFS_BUTTON19                DIJOFS_BUTTON(19)
-#define DIJOFS_BUTTON20                DIJOFS_BUTTON(20)
-#define DIJOFS_BUTTON21                DIJOFS_BUTTON(21)
-#define DIJOFS_BUTTON22                DIJOFS_BUTTON(22)
-#define DIJOFS_BUTTON23                DIJOFS_BUTTON(23)
-#define DIJOFS_BUTTON24                DIJOFS_BUTTON(24)
-#define DIJOFS_BUTTON25                DIJOFS_BUTTON(25)
-#define DIJOFS_BUTTON26                DIJOFS_BUTTON(26)
-#define DIJOFS_BUTTON27                DIJOFS_BUTTON(27)
-#define DIJOFS_BUTTON28                DIJOFS_BUTTON(28)
-#define DIJOFS_BUTTON29                DIJOFS_BUTTON(29)
-#define DIJOFS_BUTTON30                DIJOFS_BUTTON(30)
-#define DIJOFS_BUTTON31                DIJOFS_BUTTON(31)
-#endif /* DIRECTINPUT_VERSION >= 0x0500 */
-
-/* DInput 7 structures, types */
-#if(DIRECTINPUT_VERSION >= 0x0700)
-typedef struct DIFILEEFFECT {
-  DWORD       dwSize;
-  GUID        GuidEffect;
-  LPCDIEFFECT lpDiEffect;
-  CHAR        szFriendlyName[MAX_PATH];
-} DIFILEEFFECT, *LPDIFILEEFFECT;
-
-typedef const DIFILEEFFECT *LPCDIFILEEFFECT;
-typedef BOOL (CALLBACK *LPDIENUMEFFECTSINFILECALLBACK)(LPCDIFILEEFFECT , LPVOID);
-#endif /* DIRECTINPUT_VERSION >= 0x0700 */
-
-/* DInput 8 structures and types */
-#if DIRECTINPUT_VERSION >= 0x0800
-typedef struct _DIACTIONA {
-       UINT_PTR        uAppData;
-       DWORD           dwSemantic;
-       DWORD           dwFlags;
-       __GNU_EXTENSION union {
-               LPCSTR  lptszActionName;
-               UINT    uResIdString;
-       } DUMMYUNIONNAME;
-       GUID            guidInstance;
-       DWORD           dwObjID;
-       DWORD           dwHow;
-} DIACTIONA, *LPDIACTIONA;
-typedef const DIACTIONA *LPCDIACTIONA;
-
-typedef struct _DIACTIONW {
-       UINT_PTR        uAppData;
-       DWORD           dwSemantic;
-       DWORD           dwFlags;
-       __GNU_EXTENSION union {
-               LPCWSTR lptszActionName;
-               UINT    uResIdString;
-       } DUMMYUNIONNAME;
-       GUID            guidInstance;
-       DWORD           dwObjID;
-       DWORD           dwHow;
-} DIACTIONW, *LPDIACTIONW;
-typedef const DIACTIONW *LPCDIACTIONW;
-
-DECL_WINELIB_TYPE_AW(DIACTION)
-DECL_WINELIB_TYPE_AW(LPDIACTION)
-DECL_WINELIB_TYPE_AW(LPCDIACTION)
-
-#define DIA_FORCEFEEDBACK      0x00000001
-#define DIA_APPMAPPED          0x00000002
-#define DIA_APPNOMAP           0x00000004
-#define DIA_NORANGE            0x00000008
-#define DIA_APPFIXED           0x00000010
-
-#define DIAH_UNMAPPED          0x00000000
-#define DIAH_USERCONFIG                0x00000001
-#define DIAH_APPREQUESTED      0x00000002
-#define DIAH_HWAPP             0x00000004
-#define DIAH_HWDEFAULT         0x00000008
-#define DIAH_DEFAULT           0x00000020
-#define DIAH_ERROR             0x80000000
-
-typedef struct _DIACTIONFORMATA {
-       DWORD           dwSize;
-       DWORD           dwActionSize;
-       DWORD           dwDataSize;
-       DWORD           dwNumActions;
-       LPDIACTIONA     rgoAction;
-       GUID            guidActionMap;
-       DWORD           dwGenre;
-       DWORD           dwBufferSize;
-       LONG            lAxisMin;
-       LONG            lAxisMax;
-       HINSTANCE       hInstString;
-       FILETIME        ftTimeStamp;
-       DWORD           dwCRC;
-       CHAR            tszActionMap[MAX_PATH];
-} DIACTIONFORMATA, *LPDIACTIONFORMATA;
-typedef const DIACTIONFORMATA *LPCDIACTIONFORMATA;
-
-typedef struct _DIACTIONFORMATW {
-       DWORD           dwSize;
-       DWORD           dwActionSize;
-       DWORD           dwDataSize;
-       DWORD           dwNumActions;
-       LPDIACTIONW     rgoAction;
-       GUID            guidActionMap;
-       DWORD           dwGenre;
-       DWORD           dwBufferSize;
-       LONG            lAxisMin;
-       LONG            lAxisMax;
-       HINSTANCE       hInstString;
-       FILETIME        ftTimeStamp;
-       DWORD           dwCRC;
-       WCHAR           tszActionMap[MAX_PATH];
-} DIACTIONFORMATW, *LPDIACTIONFORMATW;
-typedef const DIACTIONFORMATW *LPCDIACTIONFORMATW;
-
-DECL_WINELIB_TYPE_AW(DIACTIONFORMAT)
-DECL_WINELIB_TYPE_AW(LPDIACTIONFORMAT)
-DECL_WINELIB_TYPE_AW(LPCDIACTIONFORMAT)
-
-#define DIAFTS_NEWDEVICELOW    0xFFFFFFFF
-#define DIAFTS_NEWDEVICEHIGH   0xFFFFFFFF
-#define DIAFTS_UNUSEDDEVICELOW 0x00000000
-#define DIAFTS_UNUSEDDEVICEHIGH        0x00000000
-
-#define DIDBAM_DEFAULT         0x00000000
-#define DIDBAM_PRESERVE                0x00000001
-#define DIDBAM_INITIALIZE      0x00000002
-#define DIDBAM_HWDEFAULTS      0x00000004
-
-#define DIDSAM_DEFAULT         0x00000000
-#define DIDSAM_NOUSER          0x00000001
-#define DIDSAM_FORCESAVE       0x00000002
-
-#define DICD_DEFAULT           0x00000000
-#define DICD_EDIT              0x00000001
-
-#ifndef D3DCOLOR_DEFINED
-typedef DWORD D3DCOLOR;
-#define D3DCOLOR_DEFINED
-#endif
-
-typedef struct _DICOLORSET {
-       DWORD           dwSize;
-       D3DCOLOR        cTextFore;
-       D3DCOLOR        cTextHighlight;
-       D3DCOLOR        cCalloutLine;
-       D3DCOLOR        cCalloutHighlight;
-       D3DCOLOR        cBorder;
-       D3DCOLOR        cControlFill;
-       D3DCOLOR        cHighlightFill;
-       D3DCOLOR        cAreaFill;
-} DICOLORSET, *LPDICOLORSET;
-typedef const DICOLORSET *LPCDICOLORSET;
-
-typedef struct _DICONFIGUREDEVICESPARAMSA {
-       DWORD                   dwSize;
-       DWORD                   dwcUsers;
-       LPSTR                   lptszUserNames;
-       DWORD                   dwcFormats;
-       LPDIACTIONFORMATA       lprgFormats;
-       HWND                    hwnd;
-       DICOLORSET              dics;
-       LPUNKNOWN               lpUnkDDSTarget;
-} DICONFIGUREDEVICESPARAMSA, *LPDICONFIGUREDEVICESPARAMSA;
-typedef const DICONFIGUREDEVICESPARAMSA *LPCDICONFIGUREDEVICESPARAMSA;
-
-typedef struct _DICONFIGUREDEVICESPARAMSW {
-       DWORD                   dwSize;
-       DWORD                   dwcUsers;
-       LPWSTR                  lptszUserNames;
-       DWORD                   dwcFormats;
-       LPDIACTIONFORMATW       lprgFormats;
-       HWND                    hwnd;
-       DICOLORSET              dics;
-       LPUNKNOWN               lpUnkDDSTarget;
-} DICONFIGUREDEVICESPARAMSW, *LPDICONFIGUREDEVICESPARAMSW;
-typedef const DICONFIGUREDEVICESPARAMSW *LPCDICONFIGUREDEVICESPARAMSW;
-
-DECL_WINELIB_TYPE_AW(DICONFIGUREDEVICESPARAMS)
-DECL_WINELIB_TYPE_AW(LPDICONFIGUREDEVICESPARAMS)
-DECL_WINELIB_TYPE_AW(LPCDICONFIGUREDEVICESPARAMS)
-
-#define DIDIFT_CONFIGURATION   0x00000001
-#define DIDIFT_OVERLAY         0x00000002
-
-#define DIDAL_CENTERED         0x00000000
-#define DIDAL_LEFTALIGNED      0x00000001
-#define DIDAL_RIGHTALIGNED     0x00000002
-#define DIDAL_MIDDLE           0x00000000
-#define DIDAL_TOPALIGNED       0x00000004
-#define DIDAL_BOTTOMALIGNED    0x00000008
-
-typedef struct _DIDEVICEIMAGEINFOA {
-       CHAR    tszImagePath[MAX_PATH];
-       DWORD   dwFlags;
-       DWORD   dwViewID;
-       RECT    rcOverlay;
-       DWORD   dwObjID;
-       DWORD   dwcValidPts;
-       POINT   rgptCalloutLine[5];
-       RECT    rcCalloutRect;
-       DWORD   dwTextAlign;
-} DIDEVICEIMAGEINFOA, *LPDIDEVICEIMAGEINFOA;
-typedef const DIDEVICEIMAGEINFOA *LPCDIDEVICEIMAGEINFOA;
-
-typedef struct _DIDEVICEIMAGEINFOW {
-       WCHAR   tszImagePath[MAX_PATH];
-       DWORD   dwFlags;
-       DWORD   dwViewID;
-       RECT    rcOverlay;
-       DWORD   dwObjID;
-       DWORD   dwcValidPts;
-       POINT   rgptCalloutLine[5];
-       RECT    rcCalloutRect;
-       DWORD   dwTextAlign;
-} DIDEVICEIMAGEINFOW, *LPDIDEVICEIMAGEINFOW;
-typedef const DIDEVICEIMAGEINFOW *LPCDIDEVICEIMAGEINFOW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFO)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFO)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFO)
-
-typedef struct _DIDEVICEIMAGEINFOHEADERA {
-       DWORD   dwSize;
-       DWORD   dwSizeImageInfo;
-       DWORD   dwcViews;
-       DWORD   dwcButtons;
-       DWORD   dwcAxes;
-       DWORD   dwcPOVs;
-       DWORD   dwBufferSize;
-       DWORD   dwBufferUsed;
-       LPDIDEVICEIMAGEINFOA    lprgImageInfoArray;
-} DIDEVICEIMAGEINFOHEADERA, *LPDIDEVICEIMAGEINFOHEADERA;
-typedef const DIDEVICEIMAGEINFOHEADERA *LPCDIDEVICEIMAGEINFOHEADERA;
-
-typedef struct _DIDEVICEIMAGEINFOHEADERW {
-       DWORD   dwSize;
-       DWORD   dwSizeImageInfo;
-       DWORD   dwcViews;
-       DWORD   dwcButtons;
-       DWORD   dwcAxes;
-       DWORD   dwcPOVs;
-       DWORD   dwBufferSize;
-       DWORD   dwBufferUsed;
-       LPDIDEVICEIMAGEINFOW    lprgImageInfoArray;
-} DIDEVICEIMAGEINFOHEADERW, *LPDIDEVICEIMAGEINFOHEADERW;
-typedef const DIDEVICEIMAGEINFOHEADERW *LPCDIDEVICEIMAGEINFOHEADERW;
-
-DECL_WINELIB_TYPE_AW(DIDEVICEIMAGEINFOHEADER)
-DECL_WINELIB_TYPE_AW(LPDIDEVICEIMAGEINFOHEADER)
-DECL_WINELIB_TYPE_AW(LPCDIDEVICEIMAGEINFOHEADER)
-
-#endif /* DI8 */
-
-
-/*****************************************************************************
- * IDirectInputEffect interface
- */
-#if (DIRECTINPUT_VERSION >= 0x0500)
-#undef INTERFACE
-#define INTERFACE IDirectInputEffect
-DECLARE_INTERFACE_(IDirectInputEffect,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputEffect methods ***/
-    STDMETHOD(Initialize)(THIS_ HINSTANCE, DWORD, REFGUID) PURE;
-    STDMETHOD(GetEffectGuid)(THIS_ LPGUID) PURE;
-    STDMETHOD(GetParameters)(THIS_ LPDIEFFECT, DWORD) PURE;
-    STDMETHOD(SetParameters)(THIS_ LPCDIEFFECT, DWORD) PURE;
-    STDMETHOD(Start)(THIS_ DWORD, DWORD) PURE;
-    STDMETHOD(Stop)(THIS) PURE;
-    STDMETHOD(GetEffectStatus)(THIS_ LPDWORD) PURE;
-    STDMETHOD(Download)(THIS) PURE;
-    STDMETHOD(Unload)(THIS) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputEffect_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputEffect_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputEffect_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputEffect methods ***/
-#define IDirectInputEffect_Initialize(p,a,b,c)    (p)->lpVtbl->Initialize(p,a,b,c)
-#define IDirectInputEffect_GetEffectGuid(p,a)     (p)->lpVtbl->GetEffectGuid(p,a)
-#define IDirectInputEffect_GetParameters(p,a,b)   (p)->lpVtbl->GetParameters(p,a,b)
-#define IDirectInputEffect_SetParameters(p,a,b)   (p)->lpVtbl->SetParameters(p,a,b)
-#define IDirectInputEffect_Start(p,a,b)           (p)->lpVtbl->Start(p,a,b)
-#define IDirectInputEffect_Stop(p)                (p)->lpVtbl->Stop(p)
-#define IDirectInputEffect_GetEffectStatus(p,a)   (p)->lpVtbl->GetEffectStatus(p,a)
-#define IDirectInputEffect_Download(p)            (p)->lpVtbl->Download(p)
-#define IDirectInputEffect_Unload(p)              (p)->lpVtbl->Unload(p)
-#define IDirectInputEffect_Escape(p,a)            (p)->lpVtbl->Escape(p,a)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputEffect_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputEffect_AddRef(p)             (p)->AddRef()
-#define IDirectInputEffect_Release(p)            (p)->Release()
-/*** IDirectInputEffect methods ***/
-#define IDirectInputEffect_Initialize(p,a,b,c)    (p)->Initialize(a,b,c)
-#define IDirectInputEffect_GetEffectGuid(p,a)     (p)->GetEffectGuid(a)
-#define IDirectInputEffect_GetParameters(p,a,b)   (p)->GetParameters(a,b)
-#define IDirectInputEffect_SetParameters(p,a,b)   (p)->SetParameters(a,b)
-#define IDirectInputEffect_Start(p,a,b)           (p)->Start(a,b)
-#define IDirectInputEffect_Stop(p)                (p)->Stop()
-#define IDirectInputEffect_GetEffectStatus(p,a)   (p)->GetEffectStatus(a)
-#define IDirectInputEffect_Download(p)            (p)->Download()
-#define IDirectInputEffect_Unload(p)              (p)->Unload()
-#define IDirectInputEffect_Escape(p,a)            (p)->Escape(a)
-#endif
-
-#endif /* DI5 */
-
-
-/*****************************************************************************
- * IDirectInputDeviceA interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDeviceA
-DECLARE_INTERFACE_(IDirectInputDeviceA,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDeviceW interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDeviceW
-DECLARE_INTERFACE_(IDirectInputDeviceW,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-#endif
-
-
-#if (DIRECTINPUT_VERSION >= 0x0500)
-/*****************************************************************************
- * IDirectInputDevice2A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice2A
-DECLARE_INTERFACE_(IDirectInputDevice2A,IDirectInputDeviceA)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice2W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice2W
-DECLARE_INTERFACE_(IDirectInputDevice2W,IDirectInputDeviceW)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice2_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice2_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice2_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice2_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice2_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice2_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice2_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice2_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice2_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice2_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice2_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice2_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice2_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice2_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice2_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice2_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice2_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice2_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice2_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice2_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice2_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice2_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice2_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice2_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice2_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice2_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice2_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice2_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice2_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice2_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice2_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice2_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice2_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice2_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice2_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice2_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice2_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice2_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice2_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice2_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice2_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice2_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice2_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice2_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice2_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice2_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice2_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice2_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-#endif
-#endif /* DI5 */
-
-#if DIRECTINPUT_VERSION >= 0x0700
-/*****************************************************************************
- * IDirectInputDevice7A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice7A
-DECLARE_INTERFACE_(IDirectInputDevice7A,IDirectInputDevice2A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7A methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice7W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice7W
-DECLARE_INTERFACE_(IDirectInputDevice7W,IDirectInputDevice2W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7W methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice7_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice7_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice7_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice7_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice7_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice7_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice7_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice7_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice7_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice7_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice7_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice7_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice7_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice7_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice7_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice7_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice7_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice7_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice7_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice7_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice7_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice7_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
-#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice7_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice7_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice7_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice7_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice7_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice7_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice7_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice7_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice7_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice7_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice7_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice7_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice7_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice7_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice7_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice7_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice7_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice7_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice7_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice7_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice7_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice7_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice7_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice7_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice7_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice7_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice7_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
-#define IDirectInputDevice7_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
-#endif
-
-#endif /* DI7 */
-
-#if DIRECTINPUT_VERSION >= 0x0800
-/*****************************************************************************
- * IDirectInputDevice8A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice8A
-DECLARE_INTERFACE_(IDirectInputDevice8A,IDirectInputDevice7A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceA methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEA pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2A methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKA lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOA pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7A methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-    /*** IDirectInputDevice8A methods ***/
-    STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputDevice8W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputDevice8W
-DECLARE_INTERFACE_(IDirectInputDevice8W,IDirectInputDevice7W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputDeviceW methods ***/
-    STDMETHOD(GetCapabilities)(THIS_ LPDIDEVCAPS lpDIDevCaps) PURE;
-    STDMETHOD(EnumObjects)(THIS_ LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetProperty)(THIS_ REFGUID rguidProp, LPDIPROPHEADER pdiph) PURE;
-    STDMETHOD(SetProperty)(THIS_ REFGUID rguidProp, LPCDIPROPHEADER pdiph) PURE;
-    STDMETHOD(Acquire)(THIS) PURE;
-    STDMETHOD(Unacquire)(THIS) PURE;
-    STDMETHOD(GetDeviceState)(THIS_ DWORD cbData, LPVOID lpvData) PURE;
-    STDMETHOD(GetDeviceData)(THIS_ DWORD cbObjectData, LPDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD dwFlags) PURE;
-    STDMETHOD(SetDataFormat)(THIS_ LPCDIDATAFORMAT lpdf) PURE;
-    STDMETHOD(SetEventNotification)(THIS_ HANDLE hEvent) PURE;
-    STDMETHOD(SetCooperativeLevel)(THIS_ HWND hwnd, DWORD dwFlags) PURE;
-    STDMETHOD(GetObjectInfo)(THIS_ LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) PURE;
-    STDMETHOD(GetDeviceInfo)(THIS_ LPDIDEVICEINSTANCEW pdidi) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion, REFGUID rguid) PURE;
-    /*** IDirectInputDevice2W methods ***/
-    STDMETHOD(CreateEffect)(THIS_ REFGUID rguid, LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdeff, LPUNKNOWN punkOuter) PURE;
-    STDMETHOD(EnumEffects)(THIS_ LPDIENUMEFFECTSCALLBACKW lpCallback, LPVOID pvRef, DWORD dwEffType) PURE;
-    STDMETHOD(GetEffectInfo)(THIS_ LPDIEFFECTINFOW pdei, REFGUID rguid) PURE;
-    STDMETHOD(GetForceFeedbackState)(THIS_ LPDWORD pdwOut) PURE;
-    STDMETHOD(SendForceFeedbackCommand)(THIS_ DWORD dwFlags) PURE;
-    STDMETHOD(EnumCreatedEffectObjects)(THIS_ LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback, LPVOID pvRef, DWORD fl) PURE;
-    STDMETHOD(Escape)(THIS_ LPDIEFFESCAPE pesc) PURE;
-    STDMETHOD(Poll)(THIS) PURE;
-    STDMETHOD(SendDeviceData)(THIS_ DWORD cbObjectData, LPCDIDEVICEOBJECTDATA rgdod, LPDWORD pdwInOut, DWORD fl) PURE;
-    /*** IDirectInputDevice7W methods ***/
-    STDMETHOD(EnumEffectsInFile)(THIS_ LPCWSTR lpszFileName,LPDIENUMEFFECTSINFILECALLBACK pec,LPVOID pvRef,DWORD dwFlags) PURE;
-    STDMETHOD(WriteEffectToFile)(THIS_ LPCWSTR lpszFileName,DWORD dwEntries,LPDIFILEEFFECT rgDiFileEft,DWORD dwFlags) PURE;
-    /*** IDirectInputDevice8W methods ***/
-    STDMETHOD(BuildActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(SetActionMap)(THIS_ LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags) PURE;
-    STDMETHOD(GetImageInfo)(THIS_ LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInputDevice8_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInputDevice8_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice8_GetCapabilities(p,a)       (p)->lpVtbl->GetCapabilities(p,a)
-#define IDirectInputDevice8_EnumObjects(p,a,b,c)       (p)->lpVtbl->EnumObjects(p,a,b,c)
-#define IDirectInputDevice8_GetProperty(p,a,b)         (p)->lpVtbl->GetProperty(p,a,b)
-#define IDirectInputDevice8_SetProperty(p,a,b)         (p)->lpVtbl->SetProperty(p,a,b)
-#define IDirectInputDevice8_Acquire(p)                 (p)->lpVtbl->Acquire(p)
-#define IDirectInputDevice8_Unacquire(p)               (p)->lpVtbl->Unacquire(p)
-#define IDirectInputDevice8_GetDeviceState(p,a,b)      (p)->lpVtbl->GetDeviceState(p,a,b)
-#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d)   (p)->lpVtbl->GetDeviceData(p,a,b,c,d)
-#define IDirectInputDevice8_SetDataFormat(p,a)         (p)->lpVtbl->SetDataFormat(p,a)
-#define IDirectInputDevice8_SetEventNotification(p,a)  (p)->lpVtbl->SetEventNotification(p,a)
-#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->lpVtbl->SetCooperativeLevel(p,a,b)
-#define IDirectInputDevice8_GetObjectInfo(p,a,b,c)     (p)->lpVtbl->GetObjectInfo(p,a,b,c)
-#define IDirectInputDevice8_GetDeviceInfo(p,a)         (p)->lpVtbl->GetDeviceInfo(p,a)
-#define IDirectInputDevice8_RunControlPanel(p,a,b)     (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInputDevice8_Initialize(p,a,b,c)        (p)->lpVtbl->Initialize(p,a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice8_CreateEffect(p,a,b,c,d)           (p)->lpVtbl->CreateEffect(p,a,b,c,d)
-#define IDirectInputDevice8_EnumEffects(p,a,b,c)              (p)->lpVtbl->EnumEffects(p,a,b,c)
-#define IDirectInputDevice8_GetEffectInfo(p,a,b)              (p)->lpVtbl->GetEffectInfo(p,a,b)
-#define IDirectInputDevice8_GetForceFeedbackState(p,a)        (p)->lpVtbl->GetForceFeedbackState(p,a)
-#define IDirectInputDevice8_SendForceFeedbackCommand(p,a)     (p)->lpVtbl->SendForceFeedbackCommand(p,a)
-#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->lpVtbl->EnumCreatedEffectObjects(p,a,b,c)
-#define IDirectInputDevice8_Escape(p,a)                       (p)->lpVtbl->Escape(p,a)
-#define IDirectInputDevice8_Poll(p)                           (p)->lpVtbl->Poll(p)
-#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d)         (p)->lpVtbl->SendDeviceData(p,a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->lpVtbl->EnumEffectsInFile(p,a,b,c,d)
-#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->lpVtbl->WriteEffectToFile(p,a,b,c,d)
-/*** IDirectInputDevice8 methods ***/
-#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->lpVtbl->BuildActionMap(p,a,b,c)
-#define IDirectInputDevice8_SetActionMap(p,a,b,c)   (p)->lpVtbl->SetActionMap(p,a,b,c)
-#define IDirectInputDevice8_GetImageInfo(p,a)       (p)->lpVtbl->GetImageInfo(p,a)
-#else
-/*** IUnknown methods ***/
-#define IDirectInputDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInputDevice8_AddRef(p)             (p)->AddRef()
-#define IDirectInputDevice8_Release(p)            (p)->Release()
-/*** IDirectInputDevice methods ***/
-#define IDirectInputDevice8_GetCapabilities(p,a)       (p)->GetCapabilities(a)
-#define IDirectInputDevice8_EnumObjects(p,a,b,c)       (p)->EnumObjects(a,b,c)
-#define IDirectInputDevice8_GetProperty(p,a,b)         (p)->GetProperty(a,b)
-#define IDirectInputDevice8_SetProperty(p,a,b)         (p)->SetProperty(a,b)
-#define IDirectInputDevice8_Acquire(p)                 (p)->Acquire()
-#define IDirectInputDevice8_Unacquire(p)               (p)->Unacquire()
-#define IDirectInputDevice8_GetDeviceState(p,a,b)      (p)->GetDeviceState(a,b)
-#define IDirectInputDevice8_GetDeviceData(p,a,b,c,d)   (p)->GetDeviceData(a,b,c,d)
-#define IDirectInputDevice8_SetDataFormat(p,a)         (p)->SetDataFormat(a)
-#define IDirectInputDevice8_SetEventNotification(p,a)  (p)->SetEventNotification(a)
-#define IDirectInputDevice8_SetCooperativeLevel(p,a,b) (p)->SetCooperativeLevel(a,b)
-#define IDirectInputDevice8_GetObjectInfo(p,a,b,c)     (p)->GetObjectInfo(a,b,c)
-#define IDirectInputDevice8_GetDeviceInfo(p,a)         (p)->GetDeviceInfo(a)
-#define IDirectInputDevice8_RunControlPanel(p,a,b)     (p)->RunControlPanel(a,b)
-#define IDirectInputDevice8_Initialize(p,a,b,c)        (p)->Initialize(a,b,c)
-/*** IDirectInputDevice2 methods ***/
-#define IDirectInputDevice8_CreateEffect(p,a,b,c,d)           (p)->CreateEffect(a,b,c,d)
-#define IDirectInputDevice8_EnumEffects(p,a,b,c)              (p)->EnumEffects(a,b,c)
-#define IDirectInputDevice8_GetEffectInfo(p,a,b)              (p)->GetEffectInfo(a,b)
-#define IDirectInputDevice8_GetForceFeedbackState(p,a)        (p)->GetForceFeedbackState(a)
-#define IDirectInputDevice8_SendForceFeedbackCommand(p,a)     (p)->SendForceFeedbackCommand(a)
-#define IDirectInputDevice8_EnumCreatedEffectObjects(p,a,b,c) (p)->EnumCreatedEffectObjects(a,b,c)
-#define IDirectInputDevice8_Escape(p,a)                       (p)->Escape(a)
-#define IDirectInputDevice8_Poll(p)                           (p)->Poll()
-#define IDirectInputDevice8_SendDeviceData(p,a,b,c,d)         (p)->SendDeviceData(a,b,c,d)
-/*** IDirectInputDevice7 methods ***/
-#define IDirectInputDevice8_EnumEffectsInFile(p,a,b,c,d) (p)->EnumEffectsInFile(a,b,c,d)
-#define IDirectInputDevice8_WriteEffectToFile(p,a,b,c,d) (p)->WriteEffectToFile(a,b,c,d)
-/*** IDirectInputDevice8 methods ***/
-#define IDirectInputDevice8_BuildActionMap(p,a,b,c) (p)->BuildActionMap(a,b,c)
-#define IDirectInputDevice8_SetActionMap(p,a,b,c)   (p)->SetActionMap(a,b,c)
-#define IDirectInputDevice8_GetImageInfo(p,a)       (p)->GetImageInfo(a)
-#endif
-
-#endif /* DI8 */
-
-/* "Standard" Mouse report... */
-typedef struct DIMOUSESTATE {
-  LONG lX;
-  LONG lY;
-  LONG lZ;
-  BYTE rgbButtons[4];
-} DIMOUSESTATE;
-
-#if DIRECTINPUT_VERSION >= 0x0700
-/* "Standard" Mouse report for DInput 7... */
-typedef struct DIMOUSESTATE2 {
-  LONG lX;
-  LONG lY;
-  LONG lZ;
-  BYTE rgbButtons[8];
-} DIMOUSESTATE2;
-#endif /* DI7 */
-
-#define DIMOFS_X        FIELD_OFFSET(DIMOUSESTATE, lX)
-#define DIMOFS_Y        FIELD_OFFSET(DIMOUSESTATE, lY)
-#define DIMOFS_Z        FIELD_OFFSET(DIMOUSESTATE, lZ)
-#define DIMOFS_BUTTON0 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 0)
-#define DIMOFS_BUTTON1 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 1)
-#define DIMOFS_BUTTON2 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 2)
-#define DIMOFS_BUTTON3 (FIELD_OFFSET(DIMOUSESTATE, rgbButtons) + 3)
-#if DIRECTINPUT_VERSION >= 0x0700
-#define DIMOFS_BUTTON4 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 4)
-#define DIMOFS_BUTTON5 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 5)
-#define DIMOFS_BUTTON6 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 6)
-#define DIMOFS_BUTTON7 (FIELD_OFFSET(DIMOUSESTATE2, rgbButtons) + 7)
-#endif /* DI7 */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern const DIDATAFORMAT c_dfDIMouse;
-#if DIRECTINPUT_VERSION >= 0x0700
-extern const DIDATAFORMAT c_dfDIMouse2; /* DX 7 */
-#endif /* DI7 */
-extern const DIDATAFORMAT c_dfDIKeyboard;
-#if DIRECTINPUT_VERSION >= 0x0500
-extern const DIDATAFORMAT c_dfDIJoystick;
-extern const DIDATAFORMAT c_dfDIJoystick2;
-#endif /* DI5 */
-#ifdef __cplusplus
-};
-#endif
-
-/*****************************************************************************
- * IDirectInputA interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputA
-DECLARE_INTERFACE_(IDirectInputA,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-};
-
-/*****************************************************************************
- * IDirectInputW interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInputW
-DECLARE_INTERFACE_(IDirectInputW,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput_AddRef(p)             (p)->AddRef()
-#define IDirectInput_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput_Initialize(p,a,b)      (p)->Initialize(a,b)
-#endif
-
-/*****************************************************************************
- * IDirectInput2A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput2A
-DECLARE_INTERFACE_(IDirectInput2A,IDirectInputA)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2A methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput2W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput2W
-DECLARE_INTERFACE_(IDirectInput2W,IDirectInputW)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2W methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput2_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput2_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput2_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput2_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput2_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput2_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput2_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput2_FindDevice(p,a,b,c)    (p)->lpVtbl->FindDevice(p,a,b,c)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput2_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput2_AddRef(p)             (p)->AddRef()
-#define IDirectInput2_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput2_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput2_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput2_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput2_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput2_Initialize(p,a,b)      (p)->Initialize(a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput2_FindDevice(p,a,b,c)    (p)->FindDevice(a,b,c)
-#endif
-
-/*****************************************************************************
- * IDirectInput7A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput7A
-DECLARE_INTERFACE_(IDirectInput7A,IDirectInput2A)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputA methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEA *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2A methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-    /*** IDirectInput7A methods ***/
-    STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput7W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput7W
-DECLARE_INTERFACE_(IDirectInput7W,IDirectInput2W)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInputW methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICEW *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    /*** IDirectInput2W methods ***/
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-    /*** IDirectInput7W methods ***/
-    STDMETHOD(CreateDeviceEx)(THIS_ REFGUID rguid, REFIID riid, LPVOID *pvOut, LPUNKNOWN lpUnknownOuter) PURE;
-};
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput7_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput7_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput7_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput methods ***/
-#define IDirectInput7_CreateDevice(p,a,b,c)  (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput7_GetDeviceStatus(p,a)   (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput7_RunControlPanel(p,a,b) (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput7_Initialize(p,a,b)      (p)->lpVtbl->Initialize(p,a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput7_FindDevice(p,a,b,c)    (p)->lpVtbl->FindDevice(p,a,b,c)
-/*** IDirectInput7 methods ***/
-#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->lpVtbl->CreateDeviceEx(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput7_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput7_AddRef(p)             (p)->AddRef()
-#define IDirectInput7_Release(p)            (p)->Release()
-/*** IDirectInput methods ***/
-#define IDirectInput7_CreateDevice(p,a,b,c)  (p)->CreateDevice(a,b,c)
-#define IDirectInput7_EnumDevices(p,a,b,c,d) (p)->EnumDevices(a,b,c,d)
-#define IDirectInput7_GetDeviceStatus(p,a)   (p)->GetDeviceStatus(a)
-#define IDirectInput7_RunControlPanel(p,a,b) (p)->RunControlPanel(a,b)
-#define IDirectInput7_Initialize(p,a,b)      (p)->Initialize(a,b)
-/*** IDirectInput2 methods ***/
-#define IDirectInput7_FindDevice(p,a,b,c)    (p)->FindDevice(a,b,c)
-/*** IDirectInput7 methods ***/
-#define IDirectInput7_CreateDeviceEx(p,a,b,c,d) (p)->CreateDeviceEx(a,b,c,d)
-#endif
-
-
-#if DIRECTINPUT_VERSION >= 0x0800
-/*****************************************************************************
- * IDirectInput8A interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput8A
-DECLARE_INTERFACE_(IDirectInput8A,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInput8A methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8A *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCSTR pszName, LPGUID pguidInstance) PURE;
-    STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBA lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
-};
-
-/*****************************************************************************
- * IDirectInput8W interface
- */
-#undef INTERFACE
-#define INTERFACE IDirectInput8W
-DECLARE_INTERFACE_(IDirectInput8W,IUnknown)
-{
-    /*** IUnknown methods ***/
-    STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
-    STDMETHOD_(ULONG,AddRef)(THIS) PURE;
-    STDMETHOD_(ULONG,Release)(THIS) PURE;
-    /*** IDirectInput8W methods ***/
-    STDMETHOD(CreateDevice)(THIS_ REFGUID rguid, LPDIRECTINPUTDEVICE8W *lplpDirectInputDevice, LPUNKNOWN pUnkOuter) PURE;
-    STDMETHOD(EnumDevices)(THIS_ DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(GetDeviceStatus)(THIS_ REFGUID rguidInstance) PURE;
-    STDMETHOD(RunControlPanel)(THIS_ HWND hwndOwner, DWORD dwFlags) PURE;
-    STDMETHOD(Initialize)(THIS_ HINSTANCE hinst, DWORD dwVersion) PURE;
-    STDMETHOD(FindDevice)(THIS_ REFGUID rguid, LPCWSTR pszName, LPGUID pguidInstance) PURE;
-    STDMETHOD(EnumDevicesBySemantics)(THIS_ LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat, LPDIENUMDEVICESBYSEMANTICSCBW lpCallback, LPVOID pvRef, DWORD dwFlags) PURE;
-    STDMETHOD(ConfigureDevices)(THIS_ LPDICONFIGUREDEVICESCALLBACK lpdiCallback, LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData) PURE;
-};
-#undef INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-/*** IUnknown methods ***/
-#define IDirectInput8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define IDirectInput8_AddRef(p)             (p)->lpVtbl->AddRef(p)
-#define IDirectInput8_Release(p)            (p)->lpVtbl->Release(p)
-/*** IDirectInput8 methods ***/
-#define IDirectInput8_CreateDevice(p,a,b,c)       (p)->lpVtbl->CreateDevice(p,a,b,c)
-#define IDirectInput8_EnumDevices(p,a,b,c,d)      (p)->lpVtbl->EnumDevices(p,a,b,c,d)
-#define IDirectInput8_GetDeviceStatus(p,a)        (p)->lpVtbl->GetDeviceStatus(p,a)
-#define IDirectInput8_RunControlPanel(p,a,b)      (p)->lpVtbl->RunControlPanel(p,a,b)
-#define IDirectInput8_Initialize(p,a,b)           (p)->lpVtbl->Initialize(p,a,b)
-#define IDirectInput8_FindDevice(p,a,b,c)         (p)->lpVtbl->FindDevice(p,a,b,c)
-#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->lpVtbl->EnumDevicesBySemantics(p,a,b,c,d,e)
-#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->lpVtbl->ConfigureDevices(p,a,b,c,d)
-#else
-/*** IUnknown methods ***/
-#define IDirectInput8_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define IDirectInput8_AddRef(p)             (p)->AddRef()
-#define IDirectInput8_Release(p)            (p)->Release()
-/*** IDirectInput8 methods ***/
-#define IDirectInput8_CreateDevice(p,a,b,c)       (p)->CreateDevice(a,b,c)
-#define IDirectInput8_EnumDevices(p,a,b,c,d)      (p)->EnumDevices(a,b,c,d)
-#define IDirectInput8_GetDeviceStatus(p,a)        (p)->GetDeviceStatus(a)
-#define IDirectInput8_RunControlPanel(p,a,b)      (p)->RunControlPanel(a,b)
-#define IDirectInput8_Initialize(p,a,b)           (p)->Initialize(a,b)
-#define IDirectInput8_FindDevice(p,a,b,c)         (p)->FindDevice(a,b,c)
-#define IDirectInput8_EnumDevicesBySemantics(p,a,b,c,d,e) (p)->EnumDevicesBySemantics(a,b,c,d,e)
-#define IDirectInput8_ConfigureDevices(p,a,b,c,d) (p)->ConfigureDevices(a,b,c,d)
-#endif
-
-#endif /* DI8 */
-
-/* Export functions */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if DIRECTINPUT_VERSION >= 0x0800
-HRESULT WINAPI DirectInput8Create(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
-#else /* DI < 8 */
-HRESULT WINAPI DirectInputCreateA(HINSTANCE,DWORD,LPDIRECTINPUTA *,LPUNKNOWN);
-HRESULT WINAPI DirectInputCreateW(HINSTANCE,DWORD,LPDIRECTINPUTW *,LPUNKNOWN);
-#define DirectInputCreate WINELIB_NAME_AW(DirectInputCreate)
-
-HRESULT WINAPI DirectInputCreateEx(HINSTANCE,DWORD,REFIID,LPVOID *,LPUNKNOWN);
-#endif /* DI8 */
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif /* __DINPUT_INCLUDED__ */
diff --git a/raylib_pi4_test/external/glfw/deps/mingw/xinput.h b/raylib_pi4_test/external/glfw/deps/mingw/xinput.h
deleted file mode 100644 (file)
index d3ca726..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * The Wine project - Xinput Joystick Library
- * Copyright 2008 Andrew Fenn
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#ifndef __WINE_XINPUT_H
-#define __WINE_XINPUT_H
-
-#include <windef.h>
-
-/*
- * Bitmasks for the joysticks buttons, determines what has
- * been pressed on the joystick, these need to be mapped
- * to whatever device you're using instead of an xbox 360
- * joystick
- */
-
-#define XINPUT_GAMEPAD_DPAD_UP          0x0001
-#define XINPUT_GAMEPAD_DPAD_DOWN        0x0002
-#define XINPUT_GAMEPAD_DPAD_LEFT        0x0004
-#define XINPUT_GAMEPAD_DPAD_RIGHT       0x0008
-#define XINPUT_GAMEPAD_START            0x0010
-#define XINPUT_GAMEPAD_BACK             0x0020
-#define XINPUT_GAMEPAD_LEFT_THUMB       0x0040
-#define XINPUT_GAMEPAD_RIGHT_THUMB      0x0080
-#define XINPUT_GAMEPAD_LEFT_SHOULDER    0x0100
-#define XINPUT_GAMEPAD_RIGHT_SHOULDER   0x0200
-#define XINPUT_GAMEPAD_A                0x1000
-#define XINPUT_GAMEPAD_B                0x2000
-#define XINPUT_GAMEPAD_X                0x4000
-#define XINPUT_GAMEPAD_Y                0x8000
-
-/*
- * Defines the flags used to determine if the user is pushing
- * down on a button, not holding a button, etc
- */
-
-#define XINPUT_KEYSTROKE_KEYDOWN        0x0001
-#define XINPUT_KEYSTROKE_KEYUP          0x0002
-#define XINPUT_KEYSTROKE_REPEAT         0x0004
-
-/*
- * Defines the codes which are returned by XInputGetKeystroke
- */
-
-#define VK_PAD_A                        0x5800
-#define VK_PAD_B                        0x5801
-#define VK_PAD_X                        0x5802
-#define VK_PAD_Y                        0x5803
-#define VK_PAD_RSHOULDER                0x5804
-#define VK_PAD_LSHOULDER                0x5805
-#define VK_PAD_LTRIGGER                 0x5806
-#define VK_PAD_RTRIGGER                 0x5807
-#define VK_PAD_DPAD_UP                  0x5810
-#define VK_PAD_DPAD_DOWN                0x5811
-#define VK_PAD_DPAD_LEFT                0x5812
-#define VK_PAD_DPAD_RIGHT               0x5813
-#define VK_PAD_START                    0x5814
-#define VK_PAD_BACK                     0x5815
-#define VK_PAD_LTHUMB_PRESS             0x5816
-#define VK_PAD_RTHUMB_PRESS             0x5817
-#define VK_PAD_LTHUMB_UP                0x5820
-#define VK_PAD_LTHUMB_DOWN              0x5821
-#define VK_PAD_LTHUMB_RIGHT             0x5822
-#define VK_PAD_LTHUMB_LEFT              0x5823
-#define VK_PAD_LTHUMB_UPLEFT            0x5824
-#define VK_PAD_LTHUMB_UPRIGHT           0x5825
-#define VK_PAD_LTHUMB_DOWNRIGHT         0x5826
-#define VK_PAD_LTHUMB_DOWNLEFT          0x5827
-#define VK_PAD_RTHUMB_UP                0x5830
-#define VK_PAD_RTHUMB_DOWN              0x5831
-#define VK_PAD_RTHUMB_RIGHT             0x5832
-#define VK_PAD_RTHUMB_LEFT              0x5833
-#define VK_PAD_RTHUMB_UPLEFT            0x5834
-#define VK_PAD_RTHUMB_UPRIGHT           0x5835
-#define VK_PAD_RTHUMB_DOWNRIGHT         0x5836
-#define VK_PAD_RTHUMB_DOWNLEFT          0x5837
-
-/*
- * Deadzones are for analogue joystick controls on the joypad
- * which determine when input should be assumed to be in the
- * middle of the pad. This is a threshold to stop a joypad
- * controlling the game when the player isn't touching the
- * controls.
- */
-
-#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  7849
-#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
-#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD    30
-
-
-/*
- * Defines what type of abilities the type of joystick has
- * DEVTYPE_GAMEPAD is available for all joysticks, however
- * there may be more specific identifiers for other joysticks
- * which are being used.
- */
-
-#define XINPUT_DEVTYPE_GAMEPAD          0x01
-#define XINPUT_DEVSUBTYPE_GAMEPAD       0x01
-#define XINPUT_DEVSUBTYPE_WHEEL         0x02
-#define XINPUT_DEVSUBTYPE_ARCADE_STICK  0x03
-#define XINPUT_DEVSUBTYPE_FLIGHT_SICK   0x04
-#define XINPUT_DEVSUBTYPE_DANCE_PAD     0x05
-#define XINPUT_DEVSUBTYPE_GUITAR        0x06
-#define XINPUT_DEVSUBTYPE_DRUM_KIT      0x08
-
-/*
- * These are used with the XInputGetCapabilities function to
- * determine the abilities to the joystick which has been
- * plugged in.
- */
-
-#define XINPUT_CAPS_VOICE_SUPPORTED     0x0004
-#define XINPUT_FLAG_GAMEPAD             0x00000001
-
-/*
- * Defines the status of the battery if one is used in the
- * attached joystick. The first two define if the joystick
- * supports a battery. Disconnected means that the joystick
- * isn't connected. Wired shows that the joystick is a wired
- * joystick.
- */
-
-#define BATTERY_DEVTYPE_GAMEPAD         0x00
-#define BATTERY_DEVTYPE_HEADSET         0x01
-#define BATTERY_TYPE_DISCONNECTED       0x00
-#define BATTERY_TYPE_WIRED              0x01
-#define BATTERY_TYPE_ALKALINE           0x02
-#define BATTERY_TYPE_NIMH               0x03
-#define BATTERY_TYPE_UNKNOWN            0xFF
-#define BATTERY_LEVEL_EMPTY             0x00
-#define BATTERY_LEVEL_LOW               0x01
-#define BATTERY_LEVEL_MEDIUM            0x02
-#define BATTERY_LEVEL_FULL              0x03
-
-/*
- * How many joysticks can be used with this library. Games that
- * use the xinput library will not go over this number.
- */
-
-#define XUSER_MAX_COUNT                 4
-#define XUSER_INDEX_ANY                 0x000000FF
-
-/*
- * Defines the structure of an xbox 360 joystick.
- */
-
-typedef struct _XINPUT_GAMEPAD {
-    WORD wButtons;
-    BYTE bLeftTrigger;
-    BYTE bRightTrigger;
-    SHORT sThumbLX;
-    SHORT sThumbLY;
-    SHORT sThumbRX;
-    SHORT sThumbRY;
-} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD;
-
-typedef struct _XINPUT_STATE {
-    DWORD dwPacketNumber;
-    XINPUT_GAMEPAD Gamepad;
-} XINPUT_STATE, *PXINPUT_STATE;
-
-/*
- * Defines the structure of how much vibration is set on both the
- * right and left motors in a joystick. If you're not using a 360
- * joystick you will have to map these to your device.
- */
-
-typedef struct _XINPUT_VIBRATION {
-    WORD wLeftMotorSpeed;
-    WORD wRightMotorSpeed;
-} XINPUT_VIBRATION, *PXINPUT_VIBRATION;
-
-/*
- * Defines the structure for what kind of abilities the joystick has
- * such abilities are things such as if the joystick has the ability
- * to send and receive audio, if the joystick is in fact a driving
- * wheel or perhaps if the joystick is some kind of dance pad or
- * guitar.
- */
-
-typedef struct _XINPUT_CAPABILITIES {
-    BYTE Type;
-    BYTE SubType;
-    WORD Flags;
-    XINPUT_GAMEPAD Gamepad;
-    XINPUT_VIBRATION Vibration;
-} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES;
-
-/*
- * Defines the structure for a joystick input event which is
- * retrieved using the function XInputGetKeystroke
- */
-typedef struct _XINPUT_KEYSTROKE {
-    WORD VirtualKey;
-    WCHAR Unicode;
-    WORD Flags;
-    BYTE UserIndex;
-    BYTE HidCode;
-} XINPUT_KEYSTROKE, *PXINPUT_KEYSTROKE;
-
-typedef struct _XINPUT_BATTERY_INFORMATION
-{
-    BYTE BatteryType;
-    BYTE BatteryLevel;
-} XINPUT_BATTERY_INFORMATION, *PXINPUT_BATTERY_INFORMATION;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void WINAPI XInputEnable(WINBOOL);
-DWORD WINAPI XInputSetState(DWORD, XINPUT_VIBRATION*);
-DWORD WINAPI XInputGetState(DWORD, XINPUT_STATE*);
-DWORD WINAPI XInputGetKeystroke(DWORD, DWORD, PXINPUT_KEYSTROKE);
-DWORD WINAPI XInputGetCapabilities(DWORD, DWORD, XINPUT_CAPABILITIES*);
-DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*);
-DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __WINE_XINPUT_H */
diff --git a/raylib_pi4_test/external/glfw/deps/vs2008/stdint.h b/raylib_pi4_test/external/glfw/deps/vs2008/stdint.h
deleted file mode 100644 (file)
index d02608a..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-// ISO C9x  compliant stdint.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
-// 
-//  Copyright (c) 2006-2008 Alexander Chemeris
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// 
-//   1. Redistributions of source code must retain the above copyright notice,
-//      this list of conditions and the following disclaimer.
-// 
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-// 
-//   3. The name of the author may be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_STDINT_H_ // [
-#define _MSC_STDINT_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include <limits.h>
-
-// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
-// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
-// or compiler give many errors like this:
-//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed
-#ifdef __cplusplus
-extern "C" {
-#endif
-#  include <wchar.h>
-#ifdef __cplusplus
-}
-#endif
-
-// Define _W64 macros to mark types changing their size, like intptr_t.
-#ifndef _W64
-#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
-#     define _W64 __w64
-#  else
-#     define _W64
-#  endif
-#endif
-
-
-// 7.18.1 Integer types
-
-// 7.18.1.1 Exact-width integer types
-
-// Visual Studio 6 and Embedded Visual C++ 4 doesn't
-// realize that, e.g. char has the same size as __int8
-// so we give up on __intX for them.
-#if (_MSC_VER < 1300)
-   typedef signed char       int8_t;
-   typedef signed short      int16_t;
-   typedef signed int        int32_t;
-   typedef unsigned char     uint8_t;
-   typedef unsigned short    uint16_t;
-   typedef unsigned int      uint32_t;
-#else
-   typedef signed __int8     int8_t;
-   typedef signed __int16    int16_t;
-   typedef signed __int32    int32_t;
-   typedef unsigned __int8   uint8_t;
-   typedef unsigned __int16  uint16_t;
-   typedef unsigned __int32  uint32_t;
-#endif
-typedef signed __int64       int64_t;
-typedef unsigned __int64     uint64_t;
-
-
-// 7.18.1.2 Minimum-width integer types
-typedef int8_t    int_least8_t;
-typedef int16_t   int_least16_t;
-typedef int32_t   int_least32_t;
-typedef int64_t   int_least64_t;
-typedef uint8_t   uint_least8_t;
-typedef uint16_t  uint_least16_t;
-typedef uint32_t  uint_least32_t;
-typedef uint64_t  uint_least64_t;
-
-// 7.18.1.3 Fastest minimum-width integer types
-typedef int8_t    int_fast8_t;
-typedef int16_t   int_fast16_t;
-typedef int32_t   int_fast32_t;
-typedef int64_t   int_fast64_t;
-typedef uint8_t   uint_fast8_t;
-typedef uint16_t  uint_fast16_t;
-typedef uint32_t  uint_fast32_t;
-typedef uint64_t  uint_fast64_t;
-
-// 7.18.1.4 Integer types capable of holding object pointers
-#ifdef _WIN64 // [
-   typedef signed __int64    intptr_t;
-   typedef unsigned __int64  uintptr_t;
-#else // _WIN64 ][
-   typedef _W64 signed int   intptr_t;
-   typedef _W64 unsigned int uintptr_t;
-#endif // _WIN64 ]
-
-// 7.18.1.5 Greatest-width integer types
-typedef int64_t   intmax_t;
-typedef uint64_t  uintmax_t;
-
-
-// 7.18.2 Limits of specified-width integer types
-
-#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259
-
-// 7.18.2.1 Limits of exact-width integer types
-#define INT8_MIN     ((int8_t)_I8_MIN)
-#define INT8_MAX     _I8_MAX
-#define INT16_MIN    ((int16_t)_I16_MIN)
-#define INT16_MAX    _I16_MAX
-#define INT32_MIN    ((int32_t)_I32_MIN)
-#define INT32_MAX    _I32_MAX
-#define INT64_MIN    ((int64_t)_I64_MIN)
-#define INT64_MAX    _I64_MAX
-#define UINT8_MAX    _UI8_MAX
-#define UINT16_MAX   _UI16_MAX
-#define UINT32_MAX   _UI32_MAX
-#define UINT64_MAX   _UI64_MAX
-
-// 7.18.2.2 Limits of minimum-width integer types
-#define INT_LEAST8_MIN    INT8_MIN
-#define INT_LEAST8_MAX    INT8_MAX
-#define INT_LEAST16_MIN   INT16_MIN
-#define INT_LEAST16_MAX   INT16_MAX
-#define INT_LEAST32_MIN   INT32_MIN
-#define INT_LEAST32_MAX   INT32_MAX
-#define INT_LEAST64_MIN   INT64_MIN
-#define INT_LEAST64_MAX   INT64_MAX
-#define UINT_LEAST8_MAX   UINT8_MAX
-#define UINT_LEAST16_MAX  UINT16_MAX
-#define UINT_LEAST32_MAX  UINT32_MAX
-#define UINT_LEAST64_MAX  UINT64_MAX
-
-// 7.18.2.3 Limits of fastest minimum-width integer types
-#define INT_FAST8_MIN    INT8_MIN
-#define INT_FAST8_MAX    INT8_MAX
-#define INT_FAST16_MIN   INT16_MIN
-#define INT_FAST16_MAX   INT16_MAX
-#define INT_FAST32_MIN   INT32_MIN
-#define INT_FAST32_MAX   INT32_MAX
-#define INT_FAST64_MIN   INT64_MIN
-#define INT_FAST64_MAX   INT64_MAX
-#define UINT_FAST8_MAX   UINT8_MAX
-#define UINT_FAST16_MAX  UINT16_MAX
-#define UINT_FAST32_MAX  UINT32_MAX
-#define UINT_FAST64_MAX  UINT64_MAX
-
-// 7.18.2.4 Limits of integer types capable of holding object pointers
-#ifdef _WIN64 // [
-#  define INTPTR_MIN   INT64_MIN
-#  define INTPTR_MAX   INT64_MAX
-#  define UINTPTR_MAX  UINT64_MAX
-#else // _WIN64 ][
-#  define INTPTR_MIN   INT32_MIN
-#  define INTPTR_MAX   INT32_MAX
-#  define UINTPTR_MAX  UINT32_MAX
-#endif // _WIN64 ]
-
-// 7.18.2.5 Limits of greatest-width integer types
-#define INTMAX_MIN   INT64_MIN
-#define INTMAX_MAX   INT64_MAX
-#define UINTMAX_MAX  UINT64_MAX
-
-// 7.18.3 Limits of other integer types
-
-#ifdef _WIN64 // [
-#  define PTRDIFF_MIN  _I64_MIN
-#  define PTRDIFF_MAX  _I64_MAX
-#else  // _WIN64 ][
-#  define PTRDIFF_MIN  _I32_MIN
-#  define PTRDIFF_MAX  _I32_MAX
-#endif  // _WIN64 ]
-
-#define SIG_ATOMIC_MIN  INT_MIN
-#define SIG_ATOMIC_MAX  INT_MAX
-
-#ifndef SIZE_MAX // [
-#  ifdef _WIN64 // [
-#     define SIZE_MAX  _UI64_MAX
-#  else // _WIN64 ][
-#     define SIZE_MAX  _UI32_MAX
-#  endif // _WIN64 ]
-#endif // SIZE_MAX ]
-
-// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
-#ifndef WCHAR_MIN // [
-#  define WCHAR_MIN  0
-#endif  // WCHAR_MIN ]
-#ifndef WCHAR_MAX // [
-#  define WCHAR_MAX  _UI16_MAX
-#endif  // WCHAR_MAX ]
-
-#define WINT_MIN  0
-#define WINT_MAX  _UI16_MAX
-
-#endif // __STDC_LIMIT_MACROS ]
-
-
-// 7.18.4 Limits of other integer types
-
-#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260
-
-// 7.18.4.1 Macros for minimum-width integer constants
-
-#define INT8_C(val)  val##i8
-#define INT16_C(val) val##i16
-#define INT32_C(val) val##i32
-#define INT64_C(val) val##i64
-
-#define UINT8_C(val)  val##ui8
-#define UINT16_C(val) val##ui16
-#define UINT32_C(val) val##ui32
-#define UINT64_C(val) val##ui64
-
-// 7.18.4.2 Macros for greatest-width integer constants
-#define INTMAX_C   INT64_C
-#define UINTMAX_C  UINT64_C
-
-#endif // __STDC_CONSTANT_MACROS ]
-
-
-#endif // _MSC_STDINT_H_ ]
diff --git a/raylib_pi4_test/external/glfw/include/GLFW/glfw3.h b/raylib_pi4_test/external/glfw/include/GLFW/glfw3.h
deleted file mode 100644 (file)
index 7d9dee0..0000000
+++ /dev/null
@@ -1,6062 +0,0 @@
-/*************************************************************************
- * GLFW 3.4 - www.glfw.org
- * A library for OpenGL, window and input
- *------------------------------------------------------------------------
- * Copyright (c) 2002-2006 Marcus Geelnard
- * Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would
- *    be appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- *    be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- *    distribution.
- *
- *************************************************************************/
-
-#ifndef _glfw3_h_
-#define _glfw3_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*************************************************************************
- * Doxygen documentation
- *************************************************************************/
-
-/*! @file glfw3.h
- *  @brief The header of the GLFW 3 API.
- *
- *  This is the header file of the GLFW 3 API.  It defines all its types and
- *  declares all its functions.
- *
- *  For more information about how to use this file, see @ref build_include.
- */
-/*! @defgroup context Context reference
- *  @brief Functions and types related to OpenGL and OpenGL ES contexts.
- *
- *  This is the reference documentation for OpenGL and OpenGL ES context related
- *  functions.  For more task-oriented information, see the @ref context_guide.
- */
-/*! @defgroup vulkan Vulkan support reference
- *  @brief Functions and types related to Vulkan.
- *
- *  This is the reference documentation for Vulkan related functions and types.
- *  For more task-oriented information, see the @ref vulkan_guide.
- */
-/*! @defgroup init Initialization, version and error reference
- *  @brief Functions and types related to initialization and error handling.
- *
- *  This is the reference documentation for initialization and termination of
- *  the library, version management and error handling.  For more task-oriented
- *  information, see the @ref intro_guide.
- */
-/*! @defgroup input Input reference
- *  @brief Functions and types related to input handling.
- *
- *  This is the reference documentation for input related functions and types.
- *  For more task-oriented information, see the @ref input_guide.
- */
-/*! @defgroup monitor Monitor reference
- *  @brief Functions and types related to monitors.
- *
- *  This is the reference documentation for monitor related functions and types.
- *  For more task-oriented information, see the @ref monitor_guide.
- */
-/*! @defgroup window Window reference
- *  @brief Functions and types related to windows.
- *
- *  This is the reference documentation for window related functions and types,
- *  including creation, deletion and event polling.  For more task-oriented
- *  information, see the @ref window_guide.
- */
-
-
-/*************************************************************************
- * Compiler- and platform-specific preprocessor work
- *************************************************************************/
-
-/* If we are we on Windows, we want a single define for it.
- */
-#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__))
- #define _WIN32
-#endif /* _WIN32 */
-
-/* Include because most Windows GLU headers need wchar_t and
- * the macOS OpenGL header blocks the definition of ptrdiff_t by glext.h.
- * Include it unconditionally to avoid surprising side-effects.
- */
-#include <stddef.h>
-
-/* Include because it is needed by Vulkan and related functions.
- * Include it unconditionally to avoid surprising side-effects.
- */
-#include <stdint.h>
-
-#if defined(GLFW_INCLUDE_VULKAN)
-  #include <vulkan/vulkan.h>
-#endif /* Vulkan header */
-
-/* The Vulkan header may have indirectly included windows.h (because of
- * VK_USE_PLATFORM_WIN32_KHR) so we offer our replacement symbols after it.
- */
-
-/* It is customary to use APIENTRY for OpenGL function pointer declarations on
- * all platforms.  Additionally, the Windows OpenGL header needs APIENTRY.
- */
-#if !defined(APIENTRY)
- #if defined(_WIN32)
-  #define APIENTRY __stdcall
- #else
-  #define APIENTRY
- #endif
- #define GLFW_APIENTRY_DEFINED
-#endif /* APIENTRY */
-
-/* Some Windows OpenGL headers need this.
- */
-#if !defined(WINGDIAPI) && defined(_WIN32)
- #define WINGDIAPI __declspec(dllimport)
- #define GLFW_WINGDIAPI_DEFINED
-#endif /* WINGDIAPI */
-
-/* Some Windows GLU headers need this.
- */
-#if !defined(CALLBACK) && defined(_WIN32)
- #define CALLBACK __stdcall
- #define GLFW_CALLBACK_DEFINED
-#endif /* CALLBACK */
-
-/* Include the chosen OpenGL or OpenGL ES headers.
- */
-#if defined(GLFW_INCLUDE_ES1)
-
- #include <GLES/gl.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES/glext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES2)
-
- #include <GLES2/gl2.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES3)
-
- #include <GLES3/gl3.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES31)
-
- #include <GLES3/gl31.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_ES32)
-
- #include <GLES3/gl32.h>
- #if defined(GLFW_INCLUDE_GLEXT)
-  #include <GLES2/gl2ext.h>
- #endif
-
-#elif defined(GLFW_INCLUDE_GLCOREARB)
-
- #if defined(__APPLE__)
-
-  #include <OpenGL/gl3.h>
-  #if defined(GLFW_INCLUDE_GLEXT)
-   #include <OpenGL/gl3ext.h>
-  #endif /*GLFW_INCLUDE_GLEXT*/
-
- #else /*__APPLE__*/
-
-  #include <GL/glcorearb.h>
-
- #endif /*__APPLE__*/
-
-#elif defined(GLFW_INCLUDE_GLU)
-
- #if defined(__APPLE__)
-
-  #if defined(GLFW_INCLUDE_GLU)
-   #include <OpenGL/glu.h>
-  #endif
-
- #else /*__APPLE__*/
-
-  #if defined(GLFW_INCLUDE_GLU)
-   #include <GL/glu.h>
-  #endif
-
- #endif /*__APPLE__*/
-
-#elif !defined(GLFW_INCLUDE_NONE) && \
-      !defined(__gl_h_) && \
-      !defined(__gles1_gl_h_) && \
-      !defined(__gles2_gl2_h_) && \
-      !defined(__gles2_gl3_h_) && \
-      !defined(__gles2_gl31_h_) && \
-      !defined(__gles2_gl32_h_) && \
-      !defined(__gl_glcorearb_h_) && \
-      !defined(__gl2_h_) /*legacy*/ && \
-      !defined(__gl3_h_) /*legacy*/ && \
-      !defined(__gl31_h_) /*legacy*/ && \
-      !defined(__gl32_h_) /*legacy*/ && \
-      !defined(__glcorearb_h_) /*legacy*/ && \
-      !defined(__GL_H__) /*non-standard*/ && \
-      !defined(__gltypes_h_) /*non-standard*/ && \
-      !defined(__glee_h_) /*non-standard*/
-
- #if defined(__APPLE__)
-
-  #if !defined(GLFW_INCLUDE_GLEXT)
-   #define GL_GLEXT_LEGACY
-  #endif
-  #include <OpenGL/gl.h>
-
- #else /*__APPLE__*/
-
-  #include <GL/gl.h>
-  #if defined(GLFW_INCLUDE_GLEXT)
-   #include <GL/glext.h>
-  #endif
-
- #endif /*__APPLE__*/
-
-#endif /* OpenGL and OpenGL ES headers */
-
-#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL)
- /* GLFW_DLL must be defined by applications that are linking against the DLL
-  * version of the GLFW library.  _GLFW_BUILD_DLL is defined by the GLFW
-  * configuration header when compiling the DLL version of the library.
-  */
- #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined"
-#endif
-
-/* GLFWAPI is used to declare public API functions for export
- * from the DLL / shared library / dynamic library.
- */
-#if defined(_WIN32) && defined(_GLFW_BUILD_DLL)
- /* We are building GLFW as a Win32 DLL */
- #define GLFWAPI __declspec(dllexport)
-#elif defined(_WIN32) && defined(GLFW_DLL)
- /* We are calling GLFW as a Win32 DLL */
- #define GLFWAPI __declspec(dllimport)
-#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL)
- /* We are building GLFW as a shared / dynamic library */
- #define GLFWAPI __attribute__((visibility("default")))
-#else
- /* We are building or calling GLFW as a static library */
- #define GLFWAPI
-#endif
-
-
-/*************************************************************************
- * GLFW API tokens
- *************************************************************************/
-
-/*! @name GLFW version macros
- *  @{ */
-/*! @brief The major version number of the GLFW library.
- *
- *  This is incremented when the API is changed in non-compatible ways.
- *  @ingroup init
- */
-#define GLFW_VERSION_MAJOR          3
-/*! @brief The minor version number of the GLFW library.
- *
- *  This is incremented when features are added to the API but it remains
- *  backward-compatible.
- *  @ingroup init
- */
-#define GLFW_VERSION_MINOR          4
-/*! @brief The revision number of the GLFW library.
- *
- *  This is incremented when a bug fix release is made that does not contain any
- *  API changes.
- *  @ingroup init
- */
-#define GLFW_VERSION_REVISION       0
-/*! @} */
-
-/*! @brief One.
- *
- *  This is only semantic sugar for the number 1.  You can instead use `1` or
- *  `true` or `_True` or `GL_TRUE` or `VK_TRUE` or anything else that is equal
- *  to one.
- *
- *  @ingroup init
- */
-#define GLFW_TRUE                   1
-/*! @brief Zero.
- *
- *  This is only semantic sugar for the number 0.  You can instead use `0` or
- *  `false` or `_False` or `GL_FALSE` or `VK_FALSE` or anything else that is
- *  equal to zero.
- *
- *  @ingroup init
- */
-#define GLFW_FALSE                  0
-
-/*! @name Key and button actions
- *  @{ */
-/*! @brief The key or mouse button was released.
- *
- *  The key or mouse button was released.
- *
- *  @ingroup input
- */
-#define GLFW_RELEASE                0
-/*! @brief The key or mouse button was pressed.
- *
- *  The key or mouse button was pressed.
- *
- *  @ingroup input
- */
-#define GLFW_PRESS                  1
-/*! @brief The key was held down until it repeated.
- *
- *  The key was held down until it repeated.
- *
- *  @ingroup input
- */
-#define GLFW_REPEAT                 2
-/*! @} */
-
-/*! @defgroup hat_state Joystick hat states
- *  @brief Joystick hat states.
- *
- *  See [joystick hat input](@ref joystick_hat) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_HAT_CENTERED           0
-#define GLFW_HAT_UP                 1
-#define GLFW_HAT_RIGHT              2
-#define GLFW_HAT_DOWN               4
-#define GLFW_HAT_LEFT               8
-#define GLFW_HAT_RIGHT_UP           (GLFW_HAT_RIGHT | GLFW_HAT_UP)
-#define GLFW_HAT_RIGHT_DOWN         (GLFW_HAT_RIGHT | GLFW_HAT_DOWN)
-#define GLFW_HAT_LEFT_UP            (GLFW_HAT_LEFT  | GLFW_HAT_UP)
-#define GLFW_HAT_LEFT_DOWN          (GLFW_HAT_LEFT  | GLFW_HAT_DOWN)
-/*! @} */
-
-/*! @defgroup keys Keyboard keys
- *  @brief Keyboard key IDs.
- *
- *  See [key input](@ref input_key) for how these are used.
- *
- *  These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60),
- *  but re-arranged to map to 7-bit ASCII for printable keys (function keys are
- *  put in the 256+ range).
- *
- *  The naming of the key codes follow these rules:
- *   - The US keyboard layout is used
- *   - Names of printable alpha-numeric characters are used (e.g. "A", "R",
- *     "3", etc.)
- *   - For non-alphanumeric characters, Unicode:ish names are used (e.g.
- *     "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not
- *     correspond to the Unicode standard (usually for brevity)
- *   - Keys that lack a clear US mapping are named "WORLD_x"
- *   - For non-printable keys, custom names are used (e.g. "F4",
- *     "BACKSPACE", etc.)
- *
- *  @ingroup input
- *  @{
- */
-
-/* The unknown key */
-#define GLFW_KEY_UNKNOWN            -1
-
-/* Printable keys */
-#define GLFW_KEY_SPACE              32
-#define GLFW_KEY_APOSTROPHE         39  /* ' */
-#define GLFW_KEY_COMMA              44  /* , */
-#define GLFW_KEY_MINUS              45  /* - */
-#define GLFW_KEY_PERIOD             46  /* . */
-#define GLFW_KEY_SLASH              47  /* / */
-#define GLFW_KEY_0                  48
-#define GLFW_KEY_1                  49
-#define GLFW_KEY_2                  50
-#define GLFW_KEY_3                  51
-#define GLFW_KEY_4                  52
-#define GLFW_KEY_5                  53
-#define GLFW_KEY_6                  54
-#define GLFW_KEY_7                  55
-#define GLFW_KEY_8                  56
-#define GLFW_KEY_9                  57
-#define GLFW_KEY_SEMICOLON          59  /* ; */
-#define GLFW_KEY_EQUAL              61  /* = */
-#define GLFW_KEY_A                  65
-#define GLFW_KEY_B                  66
-#define GLFW_KEY_C                  67
-#define GLFW_KEY_D                  68
-#define GLFW_KEY_E                  69
-#define GLFW_KEY_F                  70
-#define GLFW_KEY_G                  71
-#define GLFW_KEY_H                  72
-#define GLFW_KEY_I                  73
-#define GLFW_KEY_J                  74
-#define GLFW_KEY_K                  75
-#define GLFW_KEY_L                  76
-#define GLFW_KEY_M                  77
-#define GLFW_KEY_N                  78
-#define GLFW_KEY_O                  79
-#define GLFW_KEY_P                  80
-#define GLFW_KEY_Q                  81
-#define GLFW_KEY_R                  82
-#define GLFW_KEY_S                  83
-#define GLFW_KEY_T                  84
-#define GLFW_KEY_U                  85
-#define GLFW_KEY_V                  86
-#define GLFW_KEY_W                  87
-#define GLFW_KEY_X                  88
-#define GLFW_KEY_Y                  89
-#define GLFW_KEY_Z                  90
-#define GLFW_KEY_LEFT_BRACKET       91  /* [ */
-#define GLFW_KEY_BACKSLASH          92  /* \ */
-#define GLFW_KEY_RIGHT_BRACKET      93  /* ] */
-#define GLFW_KEY_GRAVE_ACCENT       96  /* ` */
-#define GLFW_KEY_WORLD_1            161 /* non-US #1 */
-#define GLFW_KEY_WORLD_2            162 /* non-US #2 */
-
-/* Function keys */
-#define GLFW_KEY_ESCAPE             256
-#define GLFW_KEY_ENTER              257
-#define GLFW_KEY_TAB                258
-#define GLFW_KEY_BACKSPACE          259
-#define GLFW_KEY_INSERT             260
-#define GLFW_KEY_DELETE             261
-#define GLFW_KEY_RIGHT              262
-#define GLFW_KEY_LEFT               263
-#define GLFW_KEY_DOWN               264
-#define GLFW_KEY_UP                 265
-#define GLFW_KEY_PAGE_UP            266
-#define GLFW_KEY_PAGE_DOWN          267
-#define GLFW_KEY_HOME               268
-#define GLFW_KEY_END                269
-#define GLFW_KEY_CAPS_LOCK          280
-#define GLFW_KEY_SCROLL_LOCK        281
-#define GLFW_KEY_NUM_LOCK           282
-#define GLFW_KEY_PRINT_SCREEN       283
-#define GLFW_KEY_PAUSE              284
-#define GLFW_KEY_F1                 290
-#define GLFW_KEY_F2                 291
-#define GLFW_KEY_F3                 292
-#define GLFW_KEY_F4                 293
-#define GLFW_KEY_F5                 294
-#define GLFW_KEY_F6                 295
-#define GLFW_KEY_F7                 296
-#define GLFW_KEY_F8                 297
-#define GLFW_KEY_F9                 298
-#define GLFW_KEY_F10                299
-#define GLFW_KEY_F11                300
-#define GLFW_KEY_F12                301
-#define GLFW_KEY_F13                302
-#define GLFW_KEY_F14                303
-#define GLFW_KEY_F15                304
-#define GLFW_KEY_F16                305
-#define GLFW_KEY_F17                306
-#define GLFW_KEY_F18                307
-#define GLFW_KEY_F19                308
-#define GLFW_KEY_F20                309
-#define GLFW_KEY_F21                310
-#define GLFW_KEY_F22                311
-#define GLFW_KEY_F23                312
-#define GLFW_KEY_F24                313
-#define GLFW_KEY_F25                314
-#define GLFW_KEY_KP_0               320
-#define GLFW_KEY_KP_1               321
-#define GLFW_KEY_KP_2               322
-#define GLFW_KEY_KP_3               323
-#define GLFW_KEY_KP_4               324
-#define GLFW_KEY_KP_5               325
-#define GLFW_KEY_KP_6               326
-#define GLFW_KEY_KP_7               327
-#define GLFW_KEY_KP_8               328
-#define GLFW_KEY_KP_9               329
-#define GLFW_KEY_KP_DECIMAL         330
-#define GLFW_KEY_KP_DIVIDE          331
-#define GLFW_KEY_KP_MULTIPLY        332
-#define GLFW_KEY_KP_SUBTRACT        333
-#define GLFW_KEY_KP_ADD             334
-#define GLFW_KEY_KP_ENTER           335
-#define GLFW_KEY_KP_EQUAL           336
-#define GLFW_KEY_LEFT_SHIFT         340
-#define GLFW_KEY_LEFT_CONTROL       341
-#define GLFW_KEY_LEFT_ALT           342
-#define GLFW_KEY_LEFT_SUPER         343
-#define GLFW_KEY_RIGHT_SHIFT        344
-#define GLFW_KEY_RIGHT_CONTROL      345
-#define GLFW_KEY_RIGHT_ALT          346
-#define GLFW_KEY_RIGHT_SUPER        347
-#define GLFW_KEY_MENU               348
-
-#define GLFW_KEY_LAST               GLFW_KEY_MENU
-
-/*! @} */
-
-/*! @defgroup mods Modifier key flags
- *  @brief Modifier key flags.
- *
- *  See [key input](@ref input_key) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-
-/*! @brief If this bit is set one or more Shift keys were held down.
- *
- *  If this bit is set one or more Shift keys were held down.
- */
-#define GLFW_MOD_SHIFT           0x0001
-/*! @brief If this bit is set one or more Control keys were held down.
- *
- *  If this bit is set one or more Control keys were held down.
- */
-#define GLFW_MOD_CONTROL         0x0002
-/*! @brief If this bit is set one or more Alt keys were held down.
- *
- *  If this bit is set one or more Alt keys were held down.
- */
-#define GLFW_MOD_ALT             0x0004
-/*! @brief If this bit is set one or more Super keys were held down.
- *
- *  If this bit is set one or more Super keys were held down.
- */
-#define GLFW_MOD_SUPER           0x0008
-/*! @brief If this bit is set the Caps Lock key is enabled.
- *
- *  If this bit is set the Caps Lock key is enabled and the @ref
- *  GLFW_LOCK_KEY_MODS input mode is set.
- */
-#define GLFW_MOD_CAPS_LOCK       0x0010
-/*! @brief If this bit is set the Num Lock key is enabled.
- *
- *  If this bit is set the Num Lock key is enabled and the @ref
- *  GLFW_LOCK_KEY_MODS input mode is set.
- */
-#define GLFW_MOD_NUM_LOCK        0x0020
-
-/*! @} */
-
-/*! @defgroup buttons Mouse buttons
- *  @brief Mouse button IDs.
- *
- *  See [mouse button input](@ref input_mouse_button) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_MOUSE_BUTTON_1         0
-#define GLFW_MOUSE_BUTTON_2         1
-#define GLFW_MOUSE_BUTTON_3         2
-#define GLFW_MOUSE_BUTTON_4         3
-#define GLFW_MOUSE_BUTTON_5         4
-#define GLFW_MOUSE_BUTTON_6         5
-#define GLFW_MOUSE_BUTTON_7         6
-#define GLFW_MOUSE_BUTTON_8         7
-#define GLFW_MOUSE_BUTTON_LAST      GLFW_MOUSE_BUTTON_8
-#define GLFW_MOUSE_BUTTON_LEFT      GLFW_MOUSE_BUTTON_1
-#define GLFW_MOUSE_BUTTON_RIGHT     GLFW_MOUSE_BUTTON_2
-#define GLFW_MOUSE_BUTTON_MIDDLE    GLFW_MOUSE_BUTTON_3
-/*! @} */
-
-/*! @defgroup joysticks Joysticks
- *  @brief Joystick IDs.
- *
- *  See [joystick input](@ref joystick) for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_JOYSTICK_1             0
-#define GLFW_JOYSTICK_2             1
-#define GLFW_JOYSTICK_3             2
-#define GLFW_JOYSTICK_4             3
-#define GLFW_JOYSTICK_5             4
-#define GLFW_JOYSTICK_6             5
-#define GLFW_JOYSTICK_7             6
-#define GLFW_JOYSTICK_8             7
-#define GLFW_JOYSTICK_9             8
-#define GLFW_JOYSTICK_10            9
-#define GLFW_JOYSTICK_11            10
-#define GLFW_JOYSTICK_12            11
-#define GLFW_JOYSTICK_13            12
-#define GLFW_JOYSTICK_14            13
-#define GLFW_JOYSTICK_15            14
-#define GLFW_JOYSTICK_16            15
-#define GLFW_JOYSTICK_LAST          GLFW_JOYSTICK_16
-/*! @} */
-
-/*! @defgroup gamepad_buttons Gamepad buttons
- *  @brief Gamepad buttons.
- *
- *  See @ref gamepad for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_GAMEPAD_BUTTON_A               0
-#define GLFW_GAMEPAD_BUTTON_B               1
-#define GLFW_GAMEPAD_BUTTON_X               2
-#define GLFW_GAMEPAD_BUTTON_Y               3
-#define GLFW_GAMEPAD_BUTTON_LEFT_BUMPER     4
-#define GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER    5
-#define GLFW_GAMEPAD_BUTTON_BACK            6
-#define GLFW_GAMEPAD_BUTTON_START           7
-#define GLFW_GAMEPAD_BUTTON_GUIDE           8
-#define GLFW_GAMEPAD_BUTTON_LEFT_THUMB      9
-#define GLFW_GAMEPAD_BUTTON_RIGHT_THUMB     10
-#define GLFW_GAMEPAD_BUTTON_DPAD_UP         11
-#define GLFW_GAMEPAD_BUTTON_DPAD_RIGHT      12
-#define GLFW_GAMEPAD_BUTTON_DPAD_DOWN       13
-#define GLFW_GAMEPAD_BUTTON_DPAD_LEFT       14
-#define GLFW_GAMEPAD_BUTTON_LAST            GLFW_GAMEPAD_BUTTON_DPAD_LEFT
-
-#define GLFW_GAMEPAD_BUTTON_CROSS       GLFW_GAMEPAD_BUTTON_A
-#define GLFW_GAMEPAD_BUTTON_CIRCLE      GLFW_GAMEPAD_BUTTON_B
-#define GLFW_GAMEPAD_BUTTON_SQUARE      GLFW_GAMEPAD_BUTTON_X
-#define GLFW_GAMEPAD_BUTTON_TRIANGLE    GLFW_GAMEPAD_BUTTON_Y
-/*! @} */
-
-/*! @defgroup gamepad_axes Gamepad axes
- *  @brief Gamepad axes.
- *
- *  See @ref gamepad for how these are used.
- *
- *  @ingroup input
- *  @{ */
-#define GLFW_GAMEPAD_AXIS_LEFT_X        0
-#define GLFW_GAMEPAD_AXIS_LEFT_Y        1
-#define GLFW_GAMEPAD_AXIS_RIGHT_X       2
-#define GLFW_GAMEPAD_AXIS_RIGHT_Y       3
-#define GLFW_GAMEPAD_AXIS_LEFT_TRIGGER  4
-#define GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER 5
-#define GLFW_GAMEPAD_AXIS_LAST          GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
-/*! @} */
-
-/*! @defgroup errors Error codes
- *  @brief Error codes.
- *
- *  See [error handling](@ref error_handling) for how these are used.
- *
- *  @ingroup init
- *  @{ */
-/*! @brief No error has occurred.
- *
- *  No error has occurred.
- *
- *  @analysis Yay.
- */
-#define GLFW_NO_ERROR               0
-/*! @brief GLFW has not been initialized.
- *
- *  This occurs if a GLFW function was called that must not be called unless the
- *  library is [initialized](@ref intro_init).
- *
- *  @analysis Application programmer error.  Initialize GLFW before calling any
- *  function that requires initialization.
- */
-#define GLFW_NOT_INITIALIZED        0x00010001
-/*! @brief No context is current for this thread.
- *
- *  This occurs if a GLFW function was called that needs and operates on the
- *  current OpenGL or OpenGL ES context but no context is current on the calling
- *  thread.  One such function is @ref glfwSwapInterval.
- *
- *  @analysis Application programmer error.  Ensure a context is current before
- *  calling functions that require a current context.
- */
-#define GLFW_NO_CURRENT_CONTEXT     0x00010002
-/*! @brief One of the arguments to the function was an invalid enum value.
- *
- *  One of the arguments to the function was an invalid enum value, for example
- *  requesting @ref GLFW_RED_BITS with @ref glfwGetWindowAttrib.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_INVALID_ENUM           0x00010003
-/*! @brief One of the arguments to the function was an invalid value.
- *
- *  One of the arguments to the function was an invalid value, for example
- *  requesting a non-existent OpenGL or OpenGL ES version like 2.7.
- *
- *  Requesting a valid but unavailable OpenGL or OpenGL ES version will instead
- *  result in a @ref GLFW_VERSION_UNAVAILABLE error.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_INVALID_VALUE          0x00010004
-/*! @brief A memory allocation failed.
- *
- *  A memory allocation failed.
- *
- *  @analysis A bug in GLFW or the underlying operating system.  Report the bug
- *  to our [issue tracker](https://github.com/glfw/glfw/issues).
- */
-#define GLFW_OUT_OF_MEMORY          0x00010005
-/*! @brief GLFW could not find support for the requested API on the system.
- *
- *  GLFW could not find support for the requested API on the system.
- *
- *  @analysis The installed graphics driver does not support the requested
- *  API, or does not support it via the chosen context creation backend.
- *  Below are a few examples.
- *
- *  @par
- *  Some pre-installed Windows graphics drivers do not support OpenGL.  AMD only
- *  supports OpenGL ES via EGL, while Nvidia and Intel only support it via
- *  a WGL or GLX extension.  macOS does not provide OpenGL ES at all.  The Mesa
- *  EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary
- *  driver.  Older graphics drivers do not support Vulkan.
- */
-#define GLFW_API_UNAVAILABLE        0x00010006
-/*! @brief The requested OpenGL or OpenGL ES version is not available.
- *
- *  The requested OpenGL or OpenGL ES version (including any requested context
- *  or framebuffer hints) is not available on this machine.
- *
- *  @analysis The machine does not support your requirements.  If your
- *  application is sufficiently flexible, downgrade your requirements and try
- *  again.  Otherwise, inform the user that their machine does not match your
- *  requirements.
- *
- *  @par
- *  Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0
- *  comes out before the 4.x series gets that far, also fail with this error and
- *  not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions
- *  will exist.
- */
-#define GLFW_VERSION_UNAVAILABLE    0x00010007
-/*! @brief A platform-specific error occurred that does not match any of the
- *  more specific categories.
- *
- *  A platform-specific error occurred that does not match any of the more
- *  specific categories.
- *
- *  @analysis A bug or configuration error in GLFW, the underlying operating
- *  system or its drivers, or a lack of required resources.  Report the issue to
- *  our [issue tracker](https://github.com/glfw/glfw/issues).
- */
-#define GLFW_PLATFORM_ERROR         0x00010008
-/*! @brief The requested format is not supported or available.
- *
- *  If emitted during window creation, the requested pixel format is not
- *  supported.
- *
- *  If emitted when querying the clipboard, the contents of the clipboard could
- *  not be converted to the requested format.
- *
- *  @analysis If emitted during window creation, one or more
- *  [hard constraints](@ref window_hints_hard) did not match any of the
- *  available pixel formats.  If your application is sufficiently flexible,
- *  downgrade your requirements and try again.  Otherwise, inform the user that
- *  their machine does not match your requirements.
- *
- *  @par
- *  If emitted when querying the clipboard, ignore the error or report it to
- *  the user, as appropriate.
- */
-#define GLFW_FORMAT_UNAVAILABLE     0x00010009
-/*! @brief The specified window does not have an OpenGL or OpenGL ES context.
- *
- *  A window that does not have an OpenGL or OpenGL ES context was passed to
- *  a function that requires it to have one.
- *
- *  @analysis Application programmer error.  Fix the offending call.
- */
-#define GLFW_NO_WINDOW_CONTEXT      0x0001000A
-/*! @brief The specified cursor shape is not available.
- *
- *  The specified standard cursor shape is not available, either because the
- *  current system cursor theme does not provide it or because it is not
- *  available on the platform.
- *
- *  @analysis Platform or system settings limitation.  Pick another
- *  [standard cursor shape](@ref shapes) or create a
- *  [custom cursor](@ref cursor_custom).
- */
-#define GLFW_CURSOR_UNAVAILABLE     0x0001000B
-/*! @brief The requested feature is not provided by the platform.
- *
- *  The requested feature is not provided by the platform, so GLFW is unable to
- *  implement it.  The documentation for each function notes if it could emit
- *  this error.
- *
- *  @analysis Platform or platform version limitation.  The error can be ignored
- *  unless the feature is critical to the application.
- *
- *  @par
- *  A function call that emits this error has no effect other than the error and
- *  updating any existing out parameters.
- */
-#define GLFW_FEATURE_UNAVAILABLE    0x0001000C
-/*! @brief The requested feature is not implemented for the platform.
- *
- *  The requested feature has not yet been implemented in GLFW for this platform.
- *
- *  @analysis An incomplete implementation of GLFW for this platform, hopefully
- *  fixed in a future release.  The error can be ignored unless the feature is
- *  critical to the application.
- *
- *  @par
- *  A function call that emits this error has no effect other than the error and
- *  updating any existing out parameters.
- */
-#define GLFW_FEATURE_UNIMPLEMENTED  0x0001000D
-/*! @} */
-
-/*! @addtogroup window
- *  @{ */
-/*! @brief Input focus window hint and attribute
- *
- *  Input focus [window hint](@ref GLFW_FOCUSED_hint) or
- *  [window attribute](@ref GLFW_FOCUSED_attrib).
- */
-#define GLFW_FOCUSED                0x00020001
-/*! @brief Window iconification window attribute
- *
- *  Window iconification [window attribute](@ref GLFW_ICONIFIED_attrib).
- */
-#define GLFW_ICONIFIED              0x00020002
-/*! @brief Window resize-ability window hint and attribute
- *
- *  Window resize-ability [window hint](@ref GLFW_RESIZABLE_hint) and
- *  [window attribute](@ref GLFW_RESIZABLE_attrib).
- */
-#define GLFW_RESIZABLE              0x00020003
-/*! @brief Window visibility window hint and attribute
- *
- *  Window visibility [window hint](@ref GLFW_VISIBLE_hint) and
- *  [window attribute](@ref GLFW_VISIBLE_attrib).
- */
-#define GLFW_VISIBLE                0x00020004
-/*! @brief Window decoration window hint and attribute
- *
- *  Window decoration [window hint](@ref GLFW_DECORATED_hint) and
- *  [window attribute](@ref GLFW_DECORATED_attrib).
- */
-#define GLFW_DECORATED              0x00020005
-/*! @brief Window auto-iconification window hint and attribute
- *
- *  Window auto-iconification [window hint](@ref GLFW_AUTO_ICONIFY_hint) and
- *  [window attribute](@ref GLFW_AUTO_ICONIFY_attrib).
- */
-#define GLFW_AUTO_ICONIFY           0x00020006
-/*! @brief Window decoration window hint and attribute
- *
- *  Window decoration [window hint](@ref GLFW_FLOATING_hint) and
- *  [window attribute](@ref GLFW_FLOATING_attrib).
- */
-#define GLFW_FLOATING               0x00020007
-/*! @brief Window maximization window hint and attribute
- *
- *  Window maximization [window hint](@ref GLFW_MAXIMIZED_hint) and
- *  [window attribute](@ref GLFW_MAXIMIZED_attrib).
- */
-#define GLFW_MAXIMIZED              0x00020008
-/*! @brief Cursor centering window hint
- *
- *  Cursor centering [window hint](@ref GLFW_CENTER_CURSOR_hint).
- */
-#define GLFW_CENTER_CURSOR          0x00020009
-/*! @brief Window framebuffer transparency hint and attribute
- *
- *  Window framebuffer transparency
- *  [window hint](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint) and
- *  [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
- */
-#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
-/*! @brief Mouse cursor hover window attribute.
- *
- *  Mouse cursor hover [window attribute](@ref GLFW_HOVERED_attrib).
- */
-#define GLFW_HOVERED                0x0002000B
-/*! @brief Input focus on calling show window hint and attribute
- *
- *  Input focus [window hint](@ref GLFW_FOCUS_ON_SHOW_hint) or
- *  [window attribute](@ref GLFW_FOCUS_ON_SHOW_attrib).
- */
-#define GLFW_FOCUS_ON_SHOW          0x0002000C
-
-/*! @brief Mouse input transparency window hint and attribute
- *
- *  Mouse input transparency [window hint](@ref GLFW_MOUSE_PASSTHROUGH_hint) or
- *  [window attribute](@ref GLFW_MOUSE_PASSTHROUGH_attrib).
- */
-#define GLFW_MOUSE_PASSTHROUGH      0x0002000D
-
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_RED_BITS).
- */
-#define GLFW_RED_BITS               0x00021001
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_GREEN_BITS).
- */
-#define GLFW_GREEN_BITS             0x00021002
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_BLUE_BITS).
- */
-#define GLFW_BLUE_BITS              0x00021003
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ALPHA_BITS).
- */
-#define GLFW_ALPHA_BITS             0x00021004
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_DEPTH_BITS).
- */
-#define GLFW_DEPTH_BITS             0x00021005
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_STENCIL_BITS).
- */
-#define GLFW_STENCIL_BITS           0x00021006
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_RED_BITS).
- */
-#define GLFW_ACCUM_RED_BITS         0x00021007
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_GREEN_BITS).
- */
-#define GLFW_ACCUM_GREEN_BITS       0x00021008
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_BLUE_BITS).
- */
-#define GLFW_ACCUM_BLUE_BITS        0x00021009
-/*! @brief Framebuffer bit depth hint.
- *
- *  Framebuffer bit depth [hint](@ref GLFW_ACCUM_ALPHA_BITS).
- */
-#define GLFW_ACCUM_ALPHA_BITS       0x0002100A
-/*! @brief Framebuffer auxiliary buffer hint.
- *
- *  Framebuffer auxiliary buffer [hint](@ref GLFW_AUX_BUFFERS).
- */
-#define GLFW_AUX_BUFFERS            0x0002100B
-/*! @brief OpenGL stereoscopic rendering hint.
- *
- *  OpenGL stereoscopic rendering [hint](@ref GLFW_STEREO).
- */
-#define GLFW_STEREO                 0x0002100C
-/*! @brief Framebuffer MSAA samples hint.
- *
- *  Framebuffer MSAA samples [hint](@ref GLFW_SAMPLES).
- */
-#define GLFW_SAMPLES                0x0002100D
-/*! @brief Framebuffer sRGB hint.
- *
- *  Framebuffer sRGB [hint](@ref GLFW_SRGB_CAPABLE).
- */
-#define GLFW_SRGB_CAPABLE           0x0002100E
-/*! @brief Monitor refresh rate hint.
- *
- *  Monitor refresh rate [hint](@ref GLFW_REFRESH_RATE).
- */
-#define GLFW_REFRESH_RATE           0x0002100F
-/*! @brief Framebuffer double buffering hint.
- *
- *  Framebuffer double buffering [hint](@ref GLFW_DOUBLEBUFFER).
- */
-#define GLFW_DOUBLEBUFFER           0x00021010
-
-/*! @brief Context client API hint and attribute.
- *
- *  Context client API [hint](@ref GLFW_CLIENT_API_hint) and
- *  [attribute](@ref GLFW_CLIENT_API_attrib).
- */
-#define GLFW_CLIENT_API             0x00022001
-/*! @brief Context client API major version hint and attribute.
- *
- *  Context client API major version [hint](@ref GLFW_CONTEXT_VERSION_MAJOR_hint)
- *  and [attribute](@ref GLFW_CONTEXT_VERSION_MAJOR_attrib).
- */
-#define GLFW_CONTEXT_VERSION_MAJOR  0x00022002
-/*! @brief Context client API minor version hint and attribute.
- *
- *  Context client API minor version [hint](@ref GLFW_CONTEXT_VERSION_MINOR_hint)
- *  and [attribute](@ref GLFW_CONTEXT_VERSION_MINOR_attrib).
- */
-#define GLFW_CONTEXT_VERSION_MINOR  0x00022003
-/*! @brief Context client API revision number hint and attribute.
- *
- *  Context client API revision number
- *  [attribute](@ref GLFW_CONTEXT_REVISION_attrib).
- */
-#define GLFW_CONTEXT_REVISION       0x00022004
-/*! @brief Context robustness hint and attribute.
- *
- *  Context client API revision number [hint](@ref GLFW_CONTEXT_ROBUSTNESS_hint)
- *  and [attribute](@ref GLFW_CONTEXT_ROBUSTNESS_attrib).
- */
-#define GLFW_CONTEXT_ROBUSTNESS     0x00022005
-/*! @brief OpenGL forward-compatibility hint and attribute.
- *
- *  OpenGL forward-compatibility [hint](@ref GLFW_OPENGL_FORWARD_COMPAT_hint)
- *  and [attribute](@ref GLFW_OPENGL_FORWARD_COMPAT_attrib).
- */
-#define GLFW_OPENGL_FORWARD_COMPAT  0x00022006
-/*! @brief Debug mode context hint and attribute.
- *
- *  Debug mode context [hint](@ref GLFW_CONTEXT_DEBUG_hint) and
- *  [attribute](@ref GLFW_CONTEXT_DEBUG_attrib).
- */
-#define GLFW_CONTEXT_DEBUG          0x00022007
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_OPENGL_DEBUG_CONTEXT   GLFW_CONTEXT_DEBUG
-/*! @brief OpenGL profile hint and attribute.
- *
- *  OpenGL profile [hint](@ref GLFW_OPENGL_PROFILE_hint) and
- *  [attribute](@ref GLFW_OPENGL_PROFILE_attrib).
- */
-#define GLFW_OPENGL_PROFILE         0x00022008
-/*! @brief Context flush-on-release hint and attribute.
- *
- *  Context flush-on-release [hint](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint) and
- *  [attribute](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib).
- */
-#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009
-/*! @brief Context error suppression hint and attribute.
- *
- *  Context error suppression [hint](@ref GLFW_CONTEXT_NO_ERROR_hint) and
- *  [attribute](@ref GLFW_CONTEXT_NO_ERROR_attrib).
- */
-#define GLFW_CONTEXT_NO_ERROR       0x0002200A
-/*! @brief Context creation API hint and attribute.
- *
- *  Context creation API [hint](@ref GLFW_CONTEXT_CREATION_API_hint) and
- *  [attribute](@ref GLFW_CONTEXT_CREATION_API_attrib).
- */
-#define GLFW_CONTEXT_CREATION_API   0x0002200B
-/*! @brief Window content area scaling window
- *  [window hint](@ref GLFW_SCALE_TO_MONITOR).
- */
-#define GLFW_SCALE_TO_MONITOR       0x0002200C
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
- */
-#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_FRAME_NAME_hint).
- */
-#define GLFW_COCOA_FRAME_NAME         0x00023002
-/*! @brief macOS specific
- *  [window hint](@ref GLFW_COCOA_GRAPHICS_SWITCHING_hint).
- */
-#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
-/*! @brief X11 specific
- *  [window hint](@ref GLFW_X11_CLASS_NAME_hint).
- */
-#define GLFW_X11_CLASS_NAME         0x00024001
-/*! @brief X11 specific
- *  [window hint](@ref GLFW_X11_CLASS_NAME_hint).
- */
-#define GLFW_X11_INSTANCE_NAME      0x00024002
-#define GLFW_WIN32_KEYBOARD_MENU    0x00025001
-/*! @} */
-
-#define GLFW_NO_API                          0
-#define GLFW_OPENGL_API             0x00030001
-#define GLFW_OPENGL_ES_API          0x00030002
-
-#define GLFW_NO_ROBUSTNESS                   0
-#define GLFW_NO_RESET_NOTIFICATION  0x00031001
-#define GLFW_LOSE_CONTEXT_ON_RESET  0x00031002
-
-#define GLFW_OPENGL_ANY_PROFILE              0
-#define GLFW_OPENGL_CORE_PROFILE    0x00032001
-#define GLFW_OPENGL_COMPAT_PROFILE  0x00032002
-
-#define GLFW_CURSOR                 0x00033001
-#define GLFW_STICKY_KEYS            0x00033002
-#define GLFW_STICKY_MOUSE_BUTTONS   0x00033003
-#define GLFW_LOCK_KEY_MODS          0x00033004
-#define GLFW_RAW_MOUSE_MOTION       0x00033005
-
-#define GLFW_CURSOR_NORMAL          0x00034001
-#define GLFW_CURSOR_HIDDEN          0x00034002
-#define GLFW_CURSOR_DISABLED        0x00034003
-
-#define GLFW_ANY_RELEASE_BEHAVIOR            0
-#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001
-#define GLFW_RELEASE_BEHAVIOR_NONE  0x00035002
-
-#define GLFW_NATIVE_CONTEXT_API     0x00036001
-#define GLFW_EGL_CONTEXT_API        0x00036002
-#define GLFW_OSMESA_CONTEXT_API     0x00036003
-
-#define GLFW_ANGLE_PLATFORM_TYPE_NONE    0x00037001
-#define GLFW_ANGLE_PLATFORM_TYPE_OPENGL  0x00037002
-#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
-#define GLFW_ANGLE_PLATFORM_TYPE_D3D9    0x00037004
-#define GLFW_ANGLE_PLATFORM_TYPE_D3D11   0x00037005
-#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN  0x00037007
-#define GLFW_ANGLE_PLATFORM_TYPE_METAL   0x00037008
-
-/*! @defgroup shapes Standard cursor shapes
- *  @brief Standard system cursor shapes.
- *
- *  These are the [standard cursor shapes](@ref cursor_standard) that can be
- *  requested from the window system.
- *
- *  @ingroup input
- *  @{ */
-
-/*! @brief The regular arrow cursor shape.
- *
- *  The regular arrow cursor shape.
- */
-#define GLFW_ARROW_CURSOR           0x00036001
-/*! @brief The text input I-beam cursor shape.
- *
- *  The text input I-beam cursor shape.
- */
-#define GLFW_IBEAM_CURSOR           0x00036002
-/*! @brief The crosshair cursor shape.
- *
- *  The crosshair cursor shape.
- */
-#define GLFW_CROSSHAIR_CURSOR       0x00036003
-/*! @brief The pointing hand cursor shape.
- *
- *  The pointing hand cursor shape.
- */
-#define GLFW_POINTING_HAND_CURSOR   0x00036004
-/*! @brief The horizontal resize/move arrow shape.
- *
- *  The horizontal resize/move arrow shape.  This is usually a horizontal
- *  double-headed arrow.
- */
-#define GLFW_RESIZE_EW_CURSOR       0x00036005
-/*! @brief The vertical resize/move arrow shape.
- *
- *  The vertical resize/move shape.  This is usually a vertical double-headed
- *  arrow.
- */
-#define GLFW_RESIZE_NS_CURSOR       0x00036006
-/*! @brief The top-left to bottom-right diagonal resize/move arrow shape.
- *
- *  The top-left to bottom-right diagonal resize/move shape.  This is usually
- *  a diagonal double-headed arrow.
- *
- *  @note @macos This shape is provided by a private system API and may fail
- *  with @ref GLFW_CURSOR_UNAVAILABLE in the future.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_RESIZE_NWSE_CURSOR     0x00036007
-/*! @brief The top-right to bottom-left diagonal resize/move arrow shape.
- *
- *  The top-right to bottom-left diagonal resize/move shape.  This is usually
- *  a diagonal double-headed arrow.
- *
- *  @note @macos This shape is provided by a private system API and may fail
- *  with @ref GLFW_CURSOR_UNAVAILABLE in the future.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_RESIZE_NESW_CURSOR     0x00036008
-/*! @brief The omni-directional resize/move cursor shape.
- *
- *  The omni-directional resize cursor/move shape.  This is usually either
- *  a combined horizontal and vertical double-headed arrow or a grabbing hand.
- */
-#define GLFW_RESIZE_ALL_CURSOR      0x00036009
-/*! @brief The operation-not-allowed shape.
- *
- *  The operation-not-allowed shape.  This is usually a circle with a diagonal
- *  line through it.
- *
- *  @note @x11 This shape is provided by a newer standard not supported by all
- *  cursor themes.
- *
- *  @note @wayland This shape is provided by a newer standard not supported by
- *  all cursor themes.
- */
-#define GLFW_NOT_ALLOWED_CURSOR     0x0003600A
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_HRESIZE_CURSOR         GLFW_RESIZE_EW_CURSOR
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_VRESIZE_CURSOR         GLFW_RESIZE_NS_CURSOR
-/*! @brief Legacy name for compatibility.
- *
- *  This is an alias for compatibility with earlier versions.
- */
-#define GLFW_HAND_CURSOR            GLFW_POINTING_HAND_CURSOR
-/*! @} */
-
-#define GLFW_CONNECTED              0x00040001
-#define GLFW_DISCONNECTED           0x00040002
-
-/*! @addtogroup init
- *  @{ */
-/*! @brief Joystick hat buttons init hint.
- *
- *  Joystick hat buttons [init hint](@ref GLFW_JOYSTICK_HAT_BUTTONS).
- */
-#define GLFW_JOYSTICK_HAT_BUTTONS   0x00050001
-/*! @brief ANGLE rendering backend init hint.
- *
- *  ANGLE rendering backend [init hint](@ref GLFW_ANGLE_PLATFORM_TYPE_hint).
- */
-#define GLFW_ANGLE_PLATFORM_TYPE    0x00050002
-/*! @brief macOS specific init hint.
- *
- *  macOS specific [init hint](@ref GLFW_COCOA_CHDIR_RESOURCES_hint).
- */
-#define GLFW_COCOA_CHDIR_RESOURCES  0x00051001
-/*! @brief macOS specific init hint.
- *
- *  macOS specific [init hint](@ref GLFW_COCOA_MENUBAR_hint).
- */
-#define GLFW_COCOA_MENUBAR          0x00051002
-/*! @} */
-
-#define GLFW_DONT_CARE              -1
-
-
-/*************************************************************************
- * GLFW API types
- *************************************************************************/
-
-/*! @brief Client API function pointer type.
- *
- *  Generic function pointer used for returning client API function pointers
- *  without forcing a cast from a regular pointer.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwGetProcAddress
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-typedef void (*GLFWglproc)(void);
-
-/*! @brief Vulkan API function pointer type.
- *
- *  Generic function pointer used for returning Vulkan API function pointers
- *  without forcing a cast from a regular pointer.
- *
- *  @sa @ref vulkan_proc
- *  @sa @ref glfwGetInstanceProcAddress
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-typedef void (*GLFWvkproc)(void);
-
-/*! @brief Opaque monitor object.
- *
- *  Opaque monitor object.
- *
- *  @see @ref monitor_object
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWmonitor GLFWmonitor;
-
-/*! @brief Opaque window object.
- *
- *  Opaque window object.
- *
- *  @see @ref window_object
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef struct GLFWwindow GLFWwindow;
-
-/*! @brief Opaque cursor object.
- *
- *  Opaque cursor object.
- *
- *  @see @ref cursor_object
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef struct GLFWcursor GLFWcursor;
-
-/*! @brief The function pointer type for error callbacks.
- *
- *  This is the function pointer type for error callbacks.  An error callback
- *  function has the following signature:
- *  @code
- *  void callback_name(int error_code, const char* description)
- *  @endcode
- *
- *  @param[in] error_code An [error code](@ref errors).  Future releases may add
- *  more error codes.
- *  @param[in] description A UTF-8 encoded string describing the error.
- *
- *  @pointer_lifetime The error description string is valid until the callback
- *  function returns.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwSetErrorCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-typedef void (* GLFWerrorfun)(int,const char*);
-
-/*! @brief The function pointer type for window position callbacks.
- *
- *  This is the function pointer type for window position callbacks.  A window
- *  position callback function has the following signature:
- *  @code
- *  void callback_name(GLFWwindow* window, int xpos, int ypos)
- *  @endcode
- *
- *  @param[in] window The window that was moved.
- *  @param[in] xpos The new x-coordinate, in screen coordinates, of the
- *  upper-left corner of the content area of the window.
- *  @param[in] ypos The new y-coordinate, in screen coordinates, of the
- *  upper-left corner of the content area of the window.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwSetWindowPosCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window size callbacks.
- *
- *  This is the function pointer type for window size callbacks.  A window size
- *  callback function has the following signature:
- *  @code
- *  void callback_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *
- *  @param[in] window The window that was resized.
- *  @param[in] width The new width, in screen coordinates, of the window.
- *  @param[in] height The new height, in screen coordinates, of the window.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwSetWindowSizeCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window close callbacks.
- *
- *  This is the function pointer type for window close callbacks.  A window
- *  close callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window)
- *  @endcode
- *
- *  @param[in] window The window that the user attempted to close.
- *
- *  @sa @ref window_close
- *  @sa @ref glfwSetWindowCloseCallback
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowclosefun)(GLFWwindow*);
-
-/*! @brief The function pointer type for window content refresh callbacks.
- *
- *  This is the function pointer type for window content refresh callbacks.
- *  A window content refresh callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window);
- *  @endcode
- *
- *  @param[in] window The window whose content needs to be refreshed.
- *
- *  @sa @ref window_refresh
- *  @sa @ref glfwSetWindowRefreshCallback
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowrefreshfun)(GLFWwindow*);
-
-/*! @brief The function pointer type for window focus callbacks.
- *
- *  This is the function pointer type for window focus callbacks.  A window
- *  focus callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int focused)
- *  @endcode
- *
- *  @param[in] window The window that gained or lost input focus.
- *  @param[in] focused `GLFW_TRUE` if the window was given input focus, or
- *  `GLFW_FALSE` if it lost it.
- *
- *  @sa @ref window_focus
- *  @sa @ref glfwSetWindowFocusCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for window iconify callbacks.
- *
- *  This is the function pointer type for window iconify callbacks.  A window
- *  iconify callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int iconified)
- *  @endcode
- *
- *  @param[in] window The window that was iconified or restored.
- *  @param[in] iconified `GLFW_TRUE` if the window was iconified, or
- *  `GLFW_FALSE` if it was restored.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwSetWindowIconifyCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for window maximize callbacks.
- *
- *  This is the function pointer type for window maximize callbacks.  A window
- *  maximize callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int maximized)
- *  @endcode
- *
- *  @param[in] window The window that was maximized or restored.
- *  @param[in] maximized `GLFW_TRUE` if the window was maximized, or
- *  `GLFW_FALSE` if it was restored.
- *
- *  @sa @ref window_maximize
- *  @sa glfwSetWindowMaximizeCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for framebuffer size callbacks.
- *
- *  This is the function pointer type for framebuffer size callbacks.
- *  A framebuffer size callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *
- *  @param[in] window The window whose framebuffer was resized.
- *  @param[in] width The new width, in pixels, of the framebuffer.
- *  @param[in] height The new height, in pixels, of the framebuffer.
- *
- *  @sa @ref window_fbsize
- *  @sa @ref glfwSetFramebufferSizeCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
-
-/*! @brief The function pointer type for window content scale callbacks.
- *
- *  This is the function pointer type for window content scale callbacks.
- *  A window content scale callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, float xscale, float yscale)
- *  @endcode
- *
- *  @param[in] window The window whose content scale changed.
- *  @param[in] xscale The new x-axis content scale of the window.
- *  @param[in] yscale The new y-axis content scale of the window.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwSetWindowContentScaleCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
-
-/*! @brief The function pointer type for mouse button callbacks.
- *
- *  This is the function pointer type for mouse button callback functions.
- *  A mouse button callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int button, int action, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] button The [mouse button](@ref buttons) that was pressed or
- *  released.
- *  @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`.  Future releases
- *  may add more actions.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_mouse_button
- *  @sa @ref glfwSetMouseButtonCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle and modifier mask parameters.
- *
- *  @ingroup input
- */
-typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int);
-
-/*! @brief The function pointer type for cursor position callbacks.
- *
- *  This is the function pointer type for cursor position callbacks.  A cursor
- *  position callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, double xpos, double ypos);
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] xpos The new cursor x-coordinate, relative to the left edge of
- *  the content area.
- *  @param[in] ypos The new cursor y-coordinate, relative to the top edge of the
- *  content area.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwSetCursorPosCallback
- *
- *  @since Added in version 3.0.  Replaces `GLFWmouseposfun`.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double);
-
-/*! @brief The function pointer type for cursor enter/leave callbacks.
- *
- *  This is the function pointer type for cursor enter/leave callbacks.
- *  A cursor enter/leave callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int entered)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] entered `GLFW_TRUE` if the cursor entered the window's content
- *  area, or `GLFW_FALSE` if it left it.
- *
- *  @sa @ref cursor_enter
- *  @sa @ref glfwSetCursorEnterCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcursorenterfun)(GLFWwindow*,int);
-
-/*! @brief The function pointer type for scroll callbacks.
- *
- *  This is the function pointer type for scroll callbacks.  A scroll callback
- *  function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, double xoffset, double yoffset)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] xoffset The scroll offset along the x-axis.
- *  @param[in] yoffset The scroll offset along the y-axis.
- *
- *  @sa @ref scrolling
- *  @sa @ref glfwSetScrollCallback
- *
- *  @since Added in version 3.0.  Replaces `GLFWmousewheelfun`.
- *
- *  @ingroup input
- */
-typedef void (* GLFWscrollfun)(GLFWwindow*,double,double);
-
-/*! @brief The function pointer type for keyboard key callbacks.
- *
- *  This is the function pointer type for keyboard key callbacks.  A keyboard
- *  key callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] key The [keyboard key](@ref keys) that was pressed or released.
- *  @param[in] scancode The system-specific scancode of the key.
- *  @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.  Future
- *  releases may add more actions.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_key
- *  @sa @ref glfwSetKeyCallback
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle, scancode and modifier mask parameters.
- *
- *  @ingroup input
- */
-typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int);
-
-/*! @brief The function pointer type for Unicode character callbacks.
- *
- *  This is the function pointer type for Unicode character callbacks.
- *  A Unicode character callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] codepoint The Unicode code point of the character.
- *
- *  @sa @ref input_char
- *  @sa @ref glfwSetCharCallback
- *
- *  @since Added in version 2.4.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int);
-
-/*! @brief The function pointer type for Unicode character with modifiers
- *  callbacks.
- *
- *  This is the function pointer type for Unicode character with modifiers
- *  callbacks.  It is called for each input character, regardless of what
- *  modifier keys are held down.  A Unicode character with modifiers callback
- *  function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] codepoint The Unicode code point of the character.
- *  @param[in] mods Bit field describing which [modifier keys](@ref mods) were
- *  held down.
- *
- *  @sa @ref input_char
- *  @sa @ref glfwSetCharModsCallback
- *
- *  @deprecated Scheduled for removal in version 4.0.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int);
-
-/*! @brief The function pointer type for path drop callbacks.
- *
- *  This is the function pointer type for path drop callbacks.  A path drop
- *  callback function has the following signature:
- *  @code
- *  void function_name(GLFWwindow* window, int path_count, const char* paths[])
- *  @endcode
- *
- *  @param[in] window The window that received the event.
- *  @param[in] path_count The number of dropped paths.
- *  @param[in] paths The UTF-8 encoded file and/or directory path names.
- *
- *  @pointer_lifetime The path array and its strings are valid until the
- *  callback function returns.
- *
- *  @sa @ref path_drop
- *  @sa @ref glfwSetDropCallback
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-typedef void (* GLFWdropfun)(GLFWwindow*,int,const char*[]);
-
-/*! @brief The function pointer type for monitor configuration callbacks.
- *
- *  This is the function pointer type for monitor configuration callbacks.
- *  A monitor callback function has the following signature:
- *  @code
- *  void function_name(GLFWmonitor* monitor, int event)
- *  @endcode
- *
- *  @param[in] monitor The monitor that was connected or disconnected.
- *  @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.  Future
- *  releases may add more events.
- *
- *  @sa @ref monitor_event
- *  @sa @ref glfwSetMonitorCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef void (* GLFWmonitorfun)(GLFWmonitor*,int);
-
-/*! @brief The function pointer type for joystick configuration callbacks.
- *
- *  This is the function pointer type for joystick configuration callbacks.
- *  A joystick configuration callback function has the following signature:
- *  @code
- *  void function_name(int jid, int event)
- *  @endcode
- *
- *  @param[in] jid The joystick that was connected or disconnected.
- *  @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`.  Future
- *  releases may add more events.
- *
- *  @sa @ref joystick_event
- *  @sa @ref glfwSetJoystickCallback
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-typedef void (* GLFWjoystickfun)(int,int);
-
-/*! @brief Video mode type.
- *
- *  This describes a single video mode.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoMode
- *  @sa @ref glfwGetVideoModes
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added refresh rate member.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWvidmode
-{
-    /*! The width, in screen coordinates, of the video mode.
-     */
-    int width;
-    /*! The height, in screen coordinates, of the video mode.
-     */
-    int height;
-    /*! The bit depth of the red channel of the video mode.
-     */
-    int redBits;
-    /*! The bit depth of the green channel of the video mode.
-     */
-    int greenBits;
-    /*! The bit depth of the blue channel of the video mode.
-     */
-    int blueBits;
-    /*! The refresh rate, in Hz, of the video mode.
-     */
-    int refreshRate;
-} GLFWvidmode;
-
-/*! @brief Gamma ramp.
- *
- *  This describes the gamma ramp for a monitor.
- *
- *  @sa @ref monitor_gamma
- *  @sa @ref glfwGetGammaRamp
- *  @sa @ref glfwSetGammaRamp
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-typedef struct GLFWgammaramp
-{
-    /*! An array of value describing the response of the red channel.
-     */
-    unsigned short* red;
-    /*! An array of value describing the response of the green channel.
-     */
-    unsigned short* green;
-    /*! An array of value describing the response of the blue channel.
-     */
-    unsigned short* blue;
-    /*! The number of elements in each array.
-     */
-    unsigned int size;
-} GLFWgammaramp;
-
-/*! @brief Image data.
- *
- *  This describes a single 2D image.  See the documentation for each related
- *  function what the expected pixel format is.
- *
- *  @sa @ref cursor_custom
- *  @sa @ref window_icon
- *
- *  @since Added in version 2.1.
- *  @glfw3 Removed format and bytes-per-pixel members.
- *
- *  @ingroup window
- */
-typedef struct GLFWimage
-{
-    /*! The width, in pixels, of this image.
-     */
-    int width;
-    /*! The height, in pixels, of this image.
-     */
-    int height;
-    /*! The pixel data of this image, arranged left-to-right, top-to-bottom.
-     */
-    unsigned char* pixels;
-} GLFWimage;
-
-/*! @brief Gamepad input state
- *
- *  This describes the input state of a gamepad.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwGetGamepadState
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-typedef struct GLFWgamepadstate
-{
-    /*! The states of each [gamepad button](@ref gamepad_buttons), `GLFW_PRESS`
-     *  or `GLFW_RELEASE`.
-     */
-    unsigned char buttons[15];
-    /*! The states of each [gamepad axis](@ref gamepad_axes), in the range -1.0
-     *  to 1.0 inclusive.
-     */
-    float axes[6];
-} GLFWgamepadstate;
-
-
-/*************************************************************************
- * GLFW API functions
- *************************************************************************/
-
-/*! @brief Initializes the GLFW library.
- *
- *  This function initializes the GLFW library.  Before most GLFW functions can
- *  be used, GLFW must be initialized, and before an application terminates GLFW
- *  should be terminated in order to free any resources allocated during or
- *  after initialization.
- *
- *  If this function fails, it calls @ref glfwTerminate before returning.  If it
- *  succeeds, you should call @ref glfwTerminate before the application exits.
- *
- *  Additional calls to this function after successful initialization but before
- *  termination will return `GLFW_TRUE` immediately.
- *
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos This function will change the current directory of the
- *  application to the `Contents/Resources` subdirectory of the application's
- *  bundle, if present.  This can be disabled with the @ref
- *  GLFW_COCOA_CHDIR_RESOURCES init hint.
- *
- *  @remark @macos This function will create the main menu and dock icon for the
- *  application.  If GLFW finds a `MainMenu.nib` it is loaded and assumed to
- *  contain a menu bar.  Otherwise a minimal menu bar is created manually with
- *  common commands like Hide, Quit and About.  The About entry opens a minimal
- *  about dialog with information from the application's bundle.  The menu bar
- *  and dock icon can be disabled entirely with the @ref GLFW_COCOA_MENUBAR init
- *  hint.
- *
- *  @remark @x11 This function will set the `LC_CTYPE` category of the
- *  application locale according to the current environment if that category is
- *  still "C".  This is because the "C" locale breaks Unicode text input.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref intro_init
- *  @sa @ref glfwTerminate
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI int glfwInit(void);
-
-/*! @brief Terminates the GLFW library.
- *
- *  This function destroys all remaining windows and cursors, restores any
- *  modified gamma ramps and frees any other allocated resources.  Once this
- *  function is called, you must again call @ref glfwInit successfully before
- *  you will be able to use most GLFW functions.
- *
- *  If GLFW has been successfully initialized, this function should be called
- *  before the application exits.  If initialization fails, there is no need to
- *  call this function, as it is called by @ref glfwInit before it returns
- *  failure.
- *
- *  This function has no effect if GLFW is not initialized.
- *
- *  @errors Possible errors include @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @warning The contexts of any remaining windows must not be current on any
- *  other thread when this function is called.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref intro_init
- *  @sa @ref glfwInit
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwTerminate(void);
-
-/*! @brief Sets the specified init hint to the desired value.
- *
- *  This function sets hints for the next initialization of GLFW.
- *
- *  The values you set hints to are never reset by GLFW, but they only take
- *  effect during initialization.  Once GLFW has been initialized, any values
- *  you set will be ignored until the library is terminated and initialized
- *  again.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [init hint](@ref init_hints) to set.
- *  @param[in] value The new value of the init hint.
- *
- *  @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @remarks This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa init_hints
- *  @sa glfwInit
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwInitHint(int hint, int value);
-
-/*! @brief Retrieves the version of the GLFW library.
- *
- *  This function retrieves the major, minor and revision numbers of the GLFW
- *  library.  It is intended for when you are using GLFW as a shared library and
- *  want to ensure that you are using the minimum required version.
- *
- *  Any or all of the version arguments may be `NULL`.
- *
- *  @param[out] major Where to store the major version number, or `NULL`.
- *  @param[out] minor Where to store the minor version number, or `NULL`.
- *  @param[out] rev Where to store the revision number, or `NULL`.
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref intro_version
- *  @sa @ref glfwGetVersionString
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup init
- */
-GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
-
-/*! @brief Returns a string describing the compile-time configuration.
- *
- *  This function returns the compile-time generated
- *  [version string](@ref intro_version_string) of the GLFW library binary.  It
- *  describes the version, platform, compiler and any platform-specific
- *  compile-time options.  It should not be confused with the OpenGL or OpenGL
- *  ES version string, queried with `glGetString`.
- *
- *  __Do not use the version string__ to parse the GLFW library version.  The
- *  @ref glfwGetVersion function provides the version of the running library
- *  binary in numerical format.
- *
- *  @return The ASCII encoded GLFW version string.
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @pointer_lifetime The returned string is static and compile-time generated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref intro_version
- *  @sa @ref glfwGetVersion
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-GLFWAPI const char* glfwGetVersionString(void);
-
-/*! @brief Returns and clears the last error for the calling thread.
- *
- *  This function returns and clears the [error code](@ref errors) of the last
- *  error that occurred on the calling thread, and optionally a UTF-8 encoded
- *  human-readable description of it.  If no error has occurred since the last
- *  call, it returns @ref GLFW_NO_ERROR (zero) and the description pointer is
- *  set to `NULL`.
- *
- *  @param[in] description Where to store the error description pointer, or `NULL`.
- *  @return The last error code for the calling thread, or @ref GLFW_NO_ERROR
- *  (zero).
- *
- *  @errors None.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  next error occurs or the library is terminated.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwSetErrorCallback
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup init
- */
-GLFWAPI int glfwGetError(const char** description);
-
-/*! @brief Sets the error callback.
- *
- *  This function sets the error callback, which is called with an error code
- *  and a human-readable description each time a GLFW error occurs.
- *
- *  The error code is set before the callback is called.  Calling @ref
- *  glfwGetError from the error callback will return the same value as the error
- *  code argument.
- *
- *  The error callback is called on the thread where the error occurred.  If you
- *  are using GLFW from multiple threads, your error callback needs to be
- *  written accordingly.
- *
- *  Because the description string may have been generated specifically for that
- *  error, it is not guaranteed to be valid after the callback has returned.  If
- *  you wish to use it after the callback returns, you need to make a copy.
- *
- *  Once set, the error callback remains set even after the library has been
- *  terminated.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set.
- *
- *  @callback_signature
- *  @code
- *  void callback_name(int error_code, const char* description)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [callback pointer type](@ref GLFWerrorfun).
- *
- *  @errors None.
- *
- *  @remark This function may be called before @ref glfwInit.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref error_handling
- *  @sa @ref glfwGetError
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup init
- */
-GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
-
-/*! @brief Returns the currently connected monitors.
- *
- *  This function returns an array of handles for all currently connected
- *  monitors.  The primary monitor is always first in the returned array.  If no
- *  monitors were found, this function returns `NULL`.
- *
- *  @param[out] count Where to store the number of monitors in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of monitor handles, or `NULL` if no monitors were found or
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  monitor configuration changes or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_monitors
- *  @sa @ref monitor_event
- *  @sa @ref glfwGetPrimaryMonitor
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitor** glfwGetMonitors(int* count);
-
-/*! @brief Returns the primary monitor.
- *
- *  This function returns the primary monitor.  This is usually the monitor
- *  where elements like the task bar or global menu bar are located.
- *
- *  @return The primary monitor, or `NULL` if no monitors were found or if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @remark The primary monitor is always first in the array returned by @ref
- *  glfwGetMonitors.
- *
- *  @sa @ref monitor_monitors
- *  @sa @ref glfwGetMonitors
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void);
-
-/*! @brief Returns the position of the monitor's viewport on the virtual screen.
- *
- *  This function returns the position, in screen coordinates, of the upper-left
- *  corner of the specified monitor.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
- *  @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);
-
-/*! @brief Retrieves the work area of the monitor.
- *
- *  This function returns the position, in screen coordinates, of the upper-left
- *  corner of the work area of the specified monitor along with the work area
- *  size in screen coordinates. The work area is defined as the area of the
- *  monitor not occluded by the operating system task bar where present. If no
- *  task bar exists then the work area is the monitor resolution in screen
- *  coordinates.
- *
- *  Any or all of the position and size arguments may be `NULL`.  If an error
- *  occurs, all non-`NULL` position and size arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xpos Where to store the monitor x-coordinate, or `NULL`.
- *  @param[out] ypos Where to store the monitor y-coordinate, or `NULL`.
- *  @param[out] width Where to store the monitor width, or `NULL`.
- *  @param[out] height Where to store the monitor height, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_workarea
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);
-
-/*! @brief Returns the physical size of the monitor.
- *
- *  This function returns the size, in millimetres, of the display area of the
- *  specified monitor.
- *
- *  Some systems do not provide accurate monitor size information, either
- *  because the monitor
- *  [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data)
- *  data is incorrect or because the driver does not report it accurately.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] widthMM Where to store the width, in millimetres, of the
- *  monitor's display area, or `NULL`.
- *  @param[out] heightMM Where to store the height, in millimetres, of the
- *  monitor's display area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @win32 calculates the returned physical size from the
- *  current resolution and system DPI instead of querying the monitor EDID data.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
-
-/*! @brief Retrieves the content scale for the specified monitor.
- *
- *  This function retrieves the content scale for the specified monitor.  The
- *  content scale is the ratio between the current DPI and the platform's
- *  default DPI.  This is especially important for text and any UI elements.  If
- *  the pixel dimensions of your UI scaled by this look appropriate on your
- *  machine then it should appear at a reasonable size on other machines
- *  regardless of their DPI and scaling settings.  This relies on the system DPI
- *  and scaling settings being somewhat correct.
- *
- *  The content scale may depend on both the monitor resolution and pixel
- *  density and on user settings.  It may be very different from the raw DPI
- *  calculated from the physical size and current resolution.
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] xscale Where to store the x-axis content scale, or `NULL`.
- *  @param[out] yscale Where to store the y-axis content scale, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_scale
- *  @sa @ref glfwGetWindowContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, float* yscale);
-
-/*! @brief Returns the name of the specified monitor.
- *
- *  This function returns a human-readable name, encoded as UTF-8, of the
- *  specified monitor.  The name typically reflects the make and model of the
- *  monitor and is not guaranteed to be unique among the connected monitors.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The UTF-8 encoded name of the monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_properties
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
-
-/*! @brief Sets the user pointer of the specified monitor.
- *
- *  This function sets the user-defined pointer of the specified monitor.  The
- *  current value is retained until the monitor is disconnected.  The initial
- *  value is `NULL`.
- *
- *  This function may be called from the monitor callback, even for a monitor
- *  that is being disconnected.
- *
- *  @param[in] monitor The monitor whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref monitor_userptr
- *  @sa @ref glfwGetMonitorUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
-
-/*! @brief Returns the user pointer of the specified monitor.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified monitor.  The initial value is `NULL`.
- *
- *  This function may be called from the monitor callback, even for a monitor
- *  that is being disconnected.
- *
- *  @param[in] monitor The monitor whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref monitor_userptr
- *  @sa @ref glfwSetMonitorUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup monitor
- */
-GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
-
-/*! @brief Sets the monitor configuration callback.
- *
- *  This function sets the monitor configuration callback, or removes the
- *  currently set callback.  This is called when a monitor is connected to or
- *  disconnected from the system.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWmonitor* monitor, int event)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWmonitorfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_event
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
-
-/*! @brief Returns the available video modes for the specified monitor.
- *
- *  This function returns an array of all video modes supported by the specified
- *  monitor.  The returned array is sorted in ascending order, first by color
- *  bit depth (the sum of all channel depths) and then by resolution area (the
- *  product of width and height).
- *
- *  @param[in] monitor The monitor to query.
- *  @param[out] count Where to store the number of video modes in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of video modes, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected, this function is called again for that monitor or the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoMode
- *
- *  @since Added in version 1.0.
- *  @glfw3 Changed to return an array of modes for a specific monitor.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count);
-
-/*! @brief Returns the current mode of the specified monitor.
- *
- *  This function returns the current video mode of the specified monitor.  If
- *  you have created a full screen window for that monitor, the return value
- *  will depend on whether that window is iconified.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The current mode of the monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified monitor is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_modes
- *  @sa @ref glfwGetVideoModes
- *
- *  @since Added in version 3.0.  Replaces `glfwGetDesktopMode`.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor);
-
-/*! @brief Generates a gamma ramp and sets it for the specified monitor.
- *
- *  This function generates an appropriately sized gamma ramp from the specified
- *  exponent and then calls @ref glfwSetGammaRamp with it.  The value must be
- *  a finite number greater than zero.
- *
- *  The software controlled gamma ramp is applied _in addition_ to the hardware
- *  gamma correction, which today is usually an approximation of sRGB gamma.
- *  This means that setting a perfectly linear ramp, or gamma 1.0, will produce
- *  the default (usually sRGB-like) behavior.
- *
- *  For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
- *  GLFW_SRGB_CAPABLE hint.
- *
- *  @param[in] monitor The monitor whose gamma ramp to set.
- *  @param[in] gamma The desired exponent.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma);
-
-/*! @brief Returns the current gamma ramp for the specified monitor.
- *
- *  This function returns the current gamma ramp of the specified monitor.
- *
- *  @param[in] monitor The monitor to query.
- *  @return The current gamma ramp, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR while
- *  returning `NULL`.
- *
- *  @pointer_lifetime The returned structure and its arrays are allocated and
- *  freed by GLFW.  You should not free them yourself.  They are valid until the
- *  specified monitor is disconnected, this function is called again for that
- *  monitor or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor);
-
-/*! @brief Sets the current gamma ramp for the specified monitor.
- *
- *  This function sets the current gamma ramp for the specified monitor.  The
- *  original gamma ramp for that monitor is saved by GLFW the first time this
- *  function is called and is restored by @ref glfwTerminate.
- *
- *  The software controlled gamma ramp is applied _in addition_ to the hardware
- *  gamma correction, which today is usually an approximation of sRGB gamma.
- *  This means that setting a perfectly linear ramp, or gamma 1.0, will produce
- *  the default (usually sRGB-like) behavior.
- *
- *  For gamma correct rendering with OpenGL or OpenGL ES, see the @ref
- *  GLFW_SRGB_CAPABLE hint.
- *
- *  @param[in] monitor The monitor whose gamma ramp to set.
- *  @param[in] ramp The gamma ramp to use.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The size of the specified gamma ramp should match the size of the
- *  current ramp for that monitor.
- *
- *  @remark @win32 The gamma ramp size must be 256.
- *
- *  @remark @wayland Gamma handling is a privileged protocol, this function
- *  will thus never be implemented and emits @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified gamma ramp is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref monitor_gamma
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup monitor
- */
-GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
-
-/*! @brief Resets all window hints to their default values.
- *
- *  This function resets all window hints to their
- *  [default values](@ref window_hints_values).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHint
- *  @sa @ref glfwWindowHintString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwDefaultWindowHints(void);
-
-/*! @brief Sets the specified window hint to the desired value.
- *
- *  This function sets hints for the next call to @ref glfwCreateWindow.  The
- *  hints, once set, retain their values until changed by a call to this
- *  function or @ref glfwDefaultWindowHints, or until the library is terminated.
- *
- *  Only integer value hints can be set with this function.  String value hints
- *  are set with @ref glfwWindowHintString.
- *
- *  This function does not check whether the specified hint values are valid.
- *  If you set hints to invalid values this will instead be reported by the next
- *  call to @ref glfwCreateWindow.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [window hint](@ref window_hints) to set.
- *  @param[in] value The new value of the window hint.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHintString
- *  @sa @ref glfwDefaultWindowHints
- *
- *  @since Added in version 3.0.  Replaces `glfwOpenWindowHint`.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWindowHint(int hint, int value);
-
-/*! @brief Sets the specified window hint to the desired value.
- *
- *  This function sets hints for the next call to @ref glfwCreateWindow.  The
- *  hints, once set, retain their values until changed by a call to this
- *  function or @ref glfwDefaultWindowHints, or until the library is terminated.
- *
- *  Only string type hints can be set with this function.  Integer value hints
- *  are set with @ref glfwWindowHint.
- *
- *  This function does not check whether the specified hint values are valid.
- *  If you set hints to invalid values this will instead be reported by the next
- *  call to @ref glfwCreateWindow.
- *
- *  Some hints are platform specific.  These may be set on any platform but they
- *  will only affect their specific platform.  Other platforms will ignore them.
- *  Setting these hints requires no platform specific headers or functions.
- *
- *  @param[in] hint The [window hint](@ref window_hints) to set.
- *  @param[in] value The new value of the window hint.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hints
- *  @sa @ref glfwWindowHint
- *  @sa @ref glfwDefaultWindowHints
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWindowHintString(int hint, const char* value);
-
-/*! @brief Creates a window and its associated context.
- *
- *  This function creates a window and its associated OpenGL or OpenGL ES
- *  context.  Most of the options controlling how the window and its context
- *  should be created are specified with [window hints](@ref window_hints).
- *
- *  Successful creation does not change which context is current.  Before you
- *  can use the newly created context, you need to
- *  [make it current](@ref context_current).  For information about the `share`
- *  parameter, see @ref context_sharing.
- *
- *  The created window, framebuffer and context may differ from what you
- *  requested, as not all parameters and hints are
- *  [hard constraints](@ref window_hints_hard).  This includes the size of the
- *  window, especially for full screen windows.  To query the actual attributes
- *  of the created window, framebuffer and context, see @ref
- *  glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize.
- *
- *  To create a full screen window, you need to specify the monitor the window
- *  will cover.  If no monitor is specified, the window will be windowed mode.
- *  Unless you have a way for the user to choose a specific monitor, it is
- *  recommended that you pick the primary monitor.  For more information on how
- *  to query connected monitors, see @ref monitor_monitors.
- *
- *  For full screen windows, the specified size becomes the resolution of the
- *  window's _desired video mode_.  As long as a full screen window is not
- *  iconified, the supported video mode most closely matching the desired video
- *  mode is set for the specified monitor.  For more information about full
- *  screen windows, including the creation of so called _windowed full screen_
- *  or _borderless full screen_ windows, see @ref window_windowed_full_screen.
- *
- *  Once you have created the window, you can switch it between windowed and
- *  full screen mode with @ref glfwSetWindowMonitor.  This will not affect its
- *  OpenGL or OpenGL ES context.
- *
- *  By default, newly created windows use the placement recommended by the
- *  window system.  To create the window at a specific position, make it
- *  initially invisible using the [GLFW_VISIBLE](@ref GLFW_VISIBLE_hint) window
- *  hint, set its [position](@ref window_pos) and then [show](@ref window_hide)
- *  it.
- *
- *  As long as at least one full screen window is not iconified, the screensaver
- *  is prohibited from starting.
- *
- *  Window systems put limits on window sizes.  Very large or very small window
- *  dimensions may be overridden by the window system on creation.  Check the
- *  actual [size](@ref window_size) after creation.
- *
- *  The [swap interval](@ref buffer_swap) is not set during window creation and
- *  the initial value may vary depending on driver settings and defaults.
- *
- *  @param[in] width The desired width, in screen coordinates, of the window.
- *  This must be greater than zero.
- *  @param[in] height The desired height, in screen coordinates, of the window.
- *  This must be greater than zero.
- *  @param[in] title The initial, UTF-8 encoded window title.
- *  @param[in] monitor The monitor to use for full screen mode, or `NULL` for
- *  windowed mode.
- *  @param[in] share The window whose context to share resources with, or `NULL`
- *  to not share resources.
- *  @return The handle of the created window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
- *  GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @win32 Window creation will fail if the Microsoft GDI software
- *  OpenGL implementation is the only one available.
- *
- *  @remark @win32 If the executable has an icon resource named `GLFW_ICON,` it
- *  will be set as the initial icon for the window.  If no such icon is present,
- *  the `IDI_APPLICATION` icon will be used instead.  To set a different icon,
- *  see @ref glfwSetWindowIcon.
- *
- *  @remark @win32 The context to share resources with must not be current on
- *  any other thread.
- *
- *  @remark @macos The OS only supports core profile contexts for OpenGL
- *  versions 3.2 and later.  Before creating an OpenGL context of version 3.2 or
- *  later you must set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint)
- *  hint accordingly.  OpenGL 3.0 and 3.1 contexts are not supported at all
- *  on macOS.
- *
- *  @remark @macos The GLFW window has no icon, as it is not a document
- *  window, but the dock icon will be the same as the application bundle's icon.
- *  For more information on bundles, see the
- *  [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
- *  in the Mac Developer Library.
- *
- *  @remark @macos On OS X 10.10 and later the window frame will not be rendered
- *  at full resolution on Retina displays unless the
- *  [GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
- *  hint is `GLFW_TRUE` and the `NSHighResolutionCapable` key is enabled in the
- *  application bundle's `Info.plist`.  For more information, see
- *  [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html)
- *  in the Mac Developer Library.  The GLFW test and example programs use
- *  a custom `Info.plist` template for this, which can be found as
- *  `CMake/Info.plist.in` in the source tree.
- *
- *  @remark @macos When activating frame autosaving with
- *  [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
- *  window size and position may be overridden by previously saved values.
- *
- *  @remark @x11 Some window managers will not respect the placement of
- *  initially hidden windows.
- *
- *  @remark @x11 Due to the asynchronous nature of X11, it may take a moment for
- *  a window to reach its requested state.  This means you may not be able to
- *  query the final size, position or other attributes directly after window
- *  creation.
- *
- *  @remark @x11 The class part of the `WM_CLASS` window property will by
- *  default be set to the window title passed to this function.  The instance
- *  part will use the contents of the `RESOURCE_NAME` environment variable, if
- *  present and not empty, or fall back to the window title.  Set the
- *  [GLFW_X11_CLASS_NAME](@ref GLFW_X11_CLASS_NAME_hint) and
- *  [GLFW_X11_INSTANCE_NAME](@ref GLFW_X11_INSTANCE_NAME_hint) window hints to
- *  override this.
- *
- *  @remark @wayland Compositors should implement the xdg-decoration protocol
- *  for GLFW to decorate the window properly.  If this protocol isn't
- *  supported, or if the compositor prefers client-side decorations, a very
- *  simple fallback frame will be drawn using the wp_viewporter protocol.  A
- *  compositor can still emit close, maximize or fullscreen events, using for
- *  instance a keybind mechanism.  If neither of these protocols is supported,
- *  the window won't be decorated.
- *
- *  @remark @wayland A full screen window will not attempt to change the mode,
- *  no matter what the requested size or refresh rate.
- *
- *  @remark @wayland Screensaver inhibition requires the idle-inhibit protocol
- *  to be implemented in the user's compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_creation
- *  @sa @ref glfwDestroyWindow
- *
- *  @since Added in version 3.0.  Replaces `glfwOpenWindow`.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share);
-
-/*! @brief Destroys the specified window and its context.
- *
- *  This function destroys the specified window and its context.  On calling
- *  this function, no further callbacks will be called for that window.
- *
- *  If the context of the specified window is current on the main thread, it is
- *  detached before being destroyed.
- *
- *  @param[in] window The window to destroy.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @note The context of the specified window must not be current on any other
- *  thread when this function is called.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_creation
- *  @sa @ref glfwCreateWindow
- *
- *  @since Added in version 3.0.  Replaces `glfwCloseWindow`.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
-
-/*! @brief Checks the close flag of the specified window.
- *
- *  This function returns the value of the close flag of the specified window.
- *
- *  @param[in] window The window to query.
- *  @return The value of the close flag.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
-
-/*! @brief Sets the close flag of the specified window.
- *
- *  This function sets the value of the close flag of the specified window.
- *  This can be used to override the user's attempt to close the window, or
- *  to signal that it should be closed.
- *
- *  @param[in] window The window whose flag to change.
- *  @param[in] value The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
-
-/*! @brief Sets the title of the specified window.
- *
- *  This function sets the window title, encoded as UTF-8, of the specified
- *  window.
- *
- *  @param[in] window The window whose title to change.
- *  @param[in] title The UTF-8 encoded window title.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos The window title will not be updated until the next time you
- *  process events.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_title
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title);
-
-/*! @brief Sets the icon for the specified window.
- *
- *  This function sets the icon of the specified window.  If passed an array of
- *  candidate images, those of or closest to the sizes desired by the system are
- *  selected.  If no images are specified, the window reverts to its default
- *  icon.
- *
- *  The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
- *  bits per channel with the red channel first.  They are arranged canonically
- *  as packed sequential rows, starting from the top-left corner.
- *
- *  The desired image sizes varies depending on platform and system settings.
- *  The selected images will be rescaled as needed.  Good sizes include 16x16,
- *  32x32 and 48x48.
- *
- *  @param[in] window The window whose icon to set.
- *  @param[in] count The number of images in the specified array, or zero to
- *  revert to the default window icon.
- *  @param[in] images The images to create the icon from.  This is ignored if
- *  count is zero.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @pointer_lifetime The specified image data is copied before this function
- *  returns.
- *
- *  @remark @macos Regular windows do not have icons on macOS.  This function
- *  will emit @ref GLFW_FEATURE_UNAVAILABLE.  The dock icon will be the same as
- *  the application bundle's icon.  For more information on bundles, see the
- *  [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/)
- *  in the Mac Developer Library.
- *
- *  @remark @wayland There is no existing protocol to change an icon, the
- *  window will thus inherit the one defined in the application's desktop file.
- *  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_icon
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images);
-
-/*! @brief Retrieves the position of the content area of the specified window.
- *
- *  This function retrieves the position, in screen coordinates, of the
- *  upper-left corner of the content area of the specified window.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] window The window to query.
- *  @param[out] xpos Where to store the x-coordinate of the upper-left corner of
- *  the content area, or `NULL`.
- *  @param[out] ypos Where to store the y-coordinate of the upper-left corner of
- *  the content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way for an application to retrieve the global
- *  position of its windows.  This function will emit @ref
- *  GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwSetWindowPos
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos);
-
-/*! @brief Sets the position of the content area of the specified window.
- *
- *  This function sets the position, in screen coordinates, of the upper-left
- *  corner of the content area of the specified windowed mode window.  If the
- *  window is a full screen window, this function does nothing.
- *
- *  __Do not use this function__ to move an already visible window unless you
- *  have very good reasons for doing so, as it will confuse and annoy the user.
- *
- *  The window manager may put limits on what positions are allowed.  GLFW
- *  cannot and should not override these limits.
- *
- *  @param[in] window The window to query.
- *  @param[in] xpos The x-coordinate of the upper-left corner of the content area.
- *  @param[in] ypos The y-coordinate of the upper-left corner of the content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way for an application to set the global
- *  position of its windows.  This function will emit @ref
- *  GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *  @sa @ref glfwGetWindowPos
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos);
-
-/*! @brief Retrieves the size of the content area of the specified window.
- *
- *  This function retrieves the size, in screen coordinates, of the content area
- *  of the specified window.  If you wish to retrieve the size of the
- *  framebuffer of the window in pixels, see @ref glfwGetFramebufferSize.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose size to retrieve.
- *  @param[out] width Where to store the width, in screen coordinates, of the
- *  content area, or `NULL`.
- *  @param[out] height Where to store the height, in screen coordinates, of the
- *  content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwSetWindowSize
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height);
-
-/*! @brief Sets the size limits of the specified window.
- *
- *  This function sets the size limits of the content area of the specified
- *  window.  If the window is full screen, the size limits only take effect
- *  once it is made windowed.  If the window is not resizable, this function
- *  does nothing.
- *
- *  The size limits are applied immediately to a windowed mode window and may
- *  cause it to be resized.
- *
- *  The maximum dimensions must be greater than or equal to the minimum
- *  dimensions and all must be greater than or equal to zero.
- *
- *  @param[in] window The window to set limits for.
- *  @param[in] minwidth The minimum width, in screen coordinates, of the content
- *  area, or `GLFW_DONT_CARE`.
- *  @param[in] minheight The minimum height, in screen coordinates, of the
- *  content area, or `GLFW_DONT_CARE`.
- *  @param[in] maxwidth The maximum width, in screen coordinates, of the content
- *  area, or `GLFW_DONT_CARE`.
- *  @param[in] maxheight The maximum height, in screen coordinates, of the
- *  content area, or `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark If you set size limits and an aspect ratio that conflict, the
- *  results are undefined.
- *
- *  @remark @wayland The size limits will not be applied until the window is
- *  actually resized, either by the user or by the compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_sizelimits
- *  @sa @ref glfwSetWindowAspectRatio
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight);
-
-/*! @brief Sets the aspect ratio of the specified window.
- *
- *  This function sets the required aspect ratio of the content area of the
- *  specified window.  If the window is full screen, the aspect ratio only takes
- *  effect once it is made windowed.  If the window is not resizable, this
- *  function does nothing.
- *
- *  The aspect ratio is specified as a numerator and a denominator and both
- *  values must be greater than zero.  For example, the common 16:9 aspect ratio
- *  is specified as 16 and 9, respectively.
- *
- *  If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect
- *  ratio limit is disabled.
- *
- *  The aspect ratio is applied immediately to a windowed mode window and may
- *  cause it to be resized.
- *
- *  @param[in] window The window to set limits for.
- *  @param[in] numer The numerator of the desired aspect ratio, or
- *  `GLFW_DONT_CARE`.
- *  @param[in] denom The denominator of the desired aspect ratio, or
- *  `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark If you set size limits and an aspect ratio that conflict, the
- *  results are undefined.
- *
- *  @remark @wayland The aspect ratio will not be applied until the window is
- *  actually resized, either by the user or by the compositor.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_sizelimits
- *  @sa @ref glfwSetWindowSizeLimits
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom);
-
-/*! @brief Sets the size of the content area of the specified window.
- *
- *  This function sets the size, in screen coordinates, of the content area of
- *  the specified window.
- *
- *  For full screen windows, this function updates the resolution of its desired
- *  video mode and switches to the video mode closest to it, without affecting
- *  the window's context.  As the context is unaffected, the bit depths of the
- *  framebuffer remain unchanged.
- *
- *  If you wish to update the refresh rate of the desired video mode in addition
- *  to its resolution, see @ref glfwSetWindowMonitor.
- *
- *  The window manager may put limits on what sizes are allowed.  GLFW cannot
- *  and should not override these limits.
- *
- *  @param[in] window The window to resize.
- *  @param[in] width The desired width, in screen coordinates, of the window
- *  content area.
- *  @param[in] height The desired height, in screen coordinates, of the window
- *  content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland A full screen window will not attempt to change the mode,
- *  no matter what the requested size.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *  @sa @ref glfwGetWindowSize
- *  @sa @ref glfwSetWindowMonitor
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height);
-
-/*! @brief Retrieves the size of the framebuffer of the specified window.
- *
- *  This function retrieves the size, in pixels, of the framebuffer of the
- *  specified window.  If you wish to retrieve the size of the window in screen
- *  coordinates, see @ref glfwGetWindowSize.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose framebuffer to query.
- *  @param[out] width Where to store the width, in pixels, of the framebuffer,
- *  or `NULL`.
- *  @param[out] height Where to store the height, in pixels, of the framebuffer,
- *  or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_fbsize
- *  @sa @ref glfwSetFramebufferSizeCallback
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height);
-
-/*! @brief Retrieves the size of the frame of the window.
- *
- *  This function retrieves the size, in screen coordinates, of each edge of the
- *  frame of the specified window.  This size includes the title bar, if the
- *  window has one.  The size of the frame may vary depending on the
- *  [window-related hints](@ref window_hints_wnd) used to create it.
- *
- *  Because this function retrieves the size of each window frame edge and not
- *  the offset along a particular coordinate axis, the retrieved values will
- *  always be zero or positive.
- *
- *  Any or all of the size arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` size arguments will be set to zero.
- *
- *  @param[in] window The window whose frame size to query.
- *  @param[out] left Where to store the size, in screen coordinates, of the left
- *  edge of the window frame, or `NULL`.
- *  @param[out] top Where to store the size, in screen coordinates, of the top
- *  edge of the window frame, or `NULL`.
- *  @param[out] right Where to store the size, in screen coordinates, of the
- *  right edge of the window frame, or `NULL`.
- *  @param[out] bottom Where to store the size, in screen coordinates, of the
- *  bottom edge of the window frame, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom);
-
-/*! @brief Retrieves the content scale for the specified window.
- *
- *  This function retrieves the content scale for the specified window.  The
- *  content scale is the ratio between the current DPI and the platform's
- *  default DPI.  This is especially important for text and any UI elements.  If
- *  the pixel dimensions of your UI scaled by this look appropriate on your
- *  machine then it should appear at a reasonable size on other machines
- *  regardless of their DPI and scaling settings.  This relies on the system DPI
- *  and scaling settings being somewhat correct.
- *
- *  On systems where each monitors can have its own content scale, the window
- *  content scale will depend on which monitor the system considers the window
- *  to be on.
- *
- *  @param[in] window The window to query.
- *  @param[out] xscale Where to store the x-axis content scale, or `NULL`.
- *  @param[out] yscale Where to store the y-axis content scale, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwSetWindowContentScaleCallback
- *  @sa @ref glfwGetMonitorContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwGetWindowContentScale(GLFWwindow* window, float* xscale, float* yscale);
-
-/*! @brief Returns the opacity of the whole window.
- *
- *  This function returns the opacity of the window, including any decorations.
- *
- *  The opacity (or alpha) value is a positive finite number between zero and
- *  one, where zero is fully transparent and one is fully opaque.  If the system
- *  does not support whole window transparency, this function always returns one.
- *
- *  The initial opacity value for newly created windows is one.
- *
- *  @param[in] window The window to query.
- *  @return The opacity value of the specified window.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_transparency
- *  @sa @ref glfwSetWindowOpacity
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI float glfwGetWindowOpacity(GLFWwindow* window);
-
-/*! @brief Sets the opacity of the whole window.
- *
- *  This function sets the opacity of the window, including any decorations.
- *
- *  The opacity (or alpha) value is a positive finite number between zero and
- *  one, where zero is fully transparent and one is fully opaque.
- *
- *  The initial opacity value for newly created windows is one.
- *
- *  A window created with framebuffer transparency may not use whole window
- *  transparency.  The results of doing this are undefined.
- *
- *  @param[in] window The window to set the opacity for.
- *  @param[in] opacity The desired opacity of the specified window.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland There is no way to set an opacity factor for a window.
- *  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_transparency
- *  @sa @ref glfwGetWindowOpacity
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowOpacity(GLFWwindow* window, float opacity);
-
-/*! @brief Iconifies the specified window.
- *
- *  This function iconifies (minimizes) the specified window if it was
- *  previously restored.  If the window is already iconified, this function does
- *  nothing.
- *
- *  If the specified window is a full screen window, the original monitor
- *  resolution is restored until the window is restored.
- *
- *  @param[in] window The window to iconify.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland Once a window is iconified, @ref glfwRestoreWindow won’t
- *  be able to restore it.  This is a design decision of the xdg-shell
- *  protocol.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwRestoreWindow
- *  @sa @ref glfwMaximizeWindow
- *
- *  @since Added in version 2.1.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwIconifyWindow(GLFWwindow* window);
-
-/*! @brief Restores the specified window.
- *
- *  This function restores the specified window if it was previously iconified
- *  (minimized) or maximized.  If the window is already restored, this function
- *  does nothing.
- *
- *  If the specified window is a full screen window, the resolution chosen for
- *  the window is restored on the selected monitor.
- *
- *  @param[in] window The window to restore.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwIconifyWindow
- *  @sa @ref glfwMaximizeWindow
- *
- *  @since Added in version 2.1.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwRestoreWindow(GLFWwindow* window);
-
-/*! @brief Maximizes the specified window.
- *
- *  This function maximizes the specified window if it was previously not
- *  maximized.  If the window is already maximized, this function does nothing.
- *
- *  If the specified window is a full screen window, this function does nothing.
- *
- *  @param[in] window The window to maximize.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @par Thread Safety
- *  This function may only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *  @sa @ref glfwIconifyWindow
- *  @sa @ref glfwRestoreWindow
- *
- *  @since Added in GLFW 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwMaximizeWindow(GLFWwindow* window);
-
-/*! @brief Makes the specified window visible.
- *
- *  This function makes the specified window visible if it was previously
- *  hidden.  If the window is already visible or is in full screen mode, this
- *  function does nothing.
- *
- *  By default, windowed mode windows are focused when shown
- *  Set the [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) window hint
- *  to change this behavior for all newly created windows, or change the
- *  behavior for an existing window with @ref glfwSetWindowAttrib.
- *
- *  @param[in] window The window to make visible.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hide
- *  @sa @ref glfwHideWindow
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwShowWindow(GLFWwindow* window);
-
-/*! @brief Hides the specified window.
- *
- *  This function hides the specified window if it was previously visible.  If
- *  the window is already hidden or is in full screen mode, this function does
- *  nothing.
- *
- *  @param[in] window The window to hide.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_hide
- *  @sa @ref glfwShowWindow
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwHideWindow(GLFWwindow* window);
-
-/*! @brief Brings the specified window to front and sets input focus.
- *
- *  This function brings the specified window to front and sets input focus.
- *  The window should already be visible and not iconified.
- *
- *  By default, both windowed and full screen mode windows are focused when
- *  initially created.  Set the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) to
- *  disable this behavior.
- *
- *  Also by default, windowed mode windows are focused when shown
- *  with @ref glfwShowWindow. Set the
- *  [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_hint) to disable this behavior.
- *
- *  __Do not use this function__ to steal focus from other applications unless
- *  you are certain that is what the user wants.  Focus stealing can be
- *  extremely disruptive.
- *
- *  For a less disruptive way of getting the user's attention, see
- *  [attention requests](@ref window_attention).
- *
- *  @param[in] window The window to give input focus.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_PLATFORM_ERROR and @ref GLFW_FEATURE_UNAVAILABLE (see remarks).
- *
- *  @remark @wayland It is not possible for an application to set the input
- *  focus.  This function will emit @ref GLFW_FEATURE_UNAVAILABLE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_focus
- *  @sa @ref window_attention
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwFocusWindow(GLFWwindow* window);
-
-/*! @brief Requests user attention to the specified window.
- *
- *  This function requests user attention to the specified window.  On
- *  platforms where this is not supported, attention is requested to the
- *  application as a whole.
- *
- *  Once the user has given attention, usually by focusing the window or
- *  application, the system will end the request automatically.
- *
- *  @param[in] window The window to request attention to.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos Attention is requested to the application as a whole, not the
- *  specific window.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attention
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwRequestWindowAttention(GLFWwindow* window);
-
-/*! @brief Returns the monitor that the window uses for full screen mode.
- *
- *  This function returns the handle of the monitor that the specified window is
- *  in full screen on.
- *
- *  @param[in] window The window to query.
- *  @return The monitor, or `NULL` if the window is in windowed mode or an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_monitor
- *  @sa @ref glfwSetWindowMonitor
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window);
-
-/*! @brief Sets the mode, monitor, video mode and placement of a window.
- *
- *  This function sets the monitor that the window uses for full screen mode or,
- *  if the monitor is `NULL`, makes it windowed mode.
- *
- *  When setting a monitor, this function updates the width, height and refresh
- *  rate of the desired video mode and switches to the video mode closest to it.
- *  The window position is ignored when setting a monitor.
- *
- *  When the monitor is `NULL`, the position, width and height are used to
- *  place the window content area.  The refresh rate is ignored when no monitor
- *  is specified.
- *
- *  If you only wish to update the resolution of a full screen window or the
- *  size of a windowed mode window, see @ref glfwSetWindowSize.
- *
- *  When a window transitions from full screen to windowed mode, this function
- *  restores any previous window settings such as whether it is decorated,
- *  floating, resizable, has size or aspect ratio limits, etc.
- *
- *  @param[in] window The window whose monitor, size or video mode to set.
- *  @param[in] monitor The desired monitor, or `NULL` to set windowed mode.
- *  @param[in] xpos The desired x-coordinate of the upper-left corner of the
- *  content area.
- *  @param[in] ypos The desired y-coordinate of the upper-left corner of the
- *  content area.
- *  @param[in] width The desired with, in screen coordinates, of the content
- *  area or video mode.
- *  @param[in] height The desired height, in screen coordinates, of the content
- *  area or video mode.
- *  @param[in] refreshRate The desired refresh rate, in Hz, of the video mode,
- *  or `GLFW_DONT_CARE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The OpenGL or OpenGL ES context will not be destroyed or otherwise
- *  affected by any resizing or mode switching, although you may need to update
- *  your viewport if the framebuffer size has changed.
- *
- *  @remark @wayland The desired window position is ignored, as there is no way
- *  for an application to set this property.
- *
- *  @remark @wayland Setting the window to full screen will not attempt to
- *  change the mode, no matter what the requested size or refresh rate.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_monitor
- *  @sa @ref window_full_screen
- *  @sa @ref glfwGetWindowMonitor
- *  @sa @ref glfwSetWindowSize
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate);
-
-/*! @brief Returns an attribute of the specified window.
- *
- *  This function returns the value of an attribute of the specified window or
- *  its OpenGL or OpenGL ES context.
- *
- *  @param[in] window The window to query.
- *  @param[in] attrib The [window attribute](@ref window_attribs) whose value to
- *  return.
- *  @return The value of the attribute, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark Framebuffer related hints are not window attributes.  See @ref
- *  window_attribs_fb for more information.
- *
- *  @remark Zero is a valid value for many window and context related
- *  attributes so you cannot use a return value of zero as an indication of
- *  errors.  However, this function should not fail as long as it is passed
- *  valid arguments and the library has been [initialized](@ref intro_init).
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attribs
- *  @sa @ref glfwSetWindowAttrib
- *
- *  @since Added in version 3.0.  Replaces `glfwGetWindowParam` and
- *  `glfwGetGLVersion`.
- *
- *  @ingroup window
- */
-GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
-
-/*! @brief Sets an attribute of the specified window.
- *
- *  This function sets the value of an attribute of the specified window.
- *
- *  The supported attributes are [GLFW_DECORATED](@ref GLFW_DECORATED_attrib),
- *  [GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib),
- *  [GLFW_FLOATING](@ref GLFW_FLOATING_attrib),
- *  [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and
- *  [GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib).
- *  [GLFW_MOUSE_PASSTHROUGH](@ref GLFW_MOUSE_PASSTHROUGH_attrib)
- *
- *  Some of these attributes are ignored for full screen windows.  The new
- *  value will take effect if the window is later made windowed.
- *
- *  Some of these attributes are ignored for windowed mode windows.  The new
- *  value will take effect if the window is later made full screen.
- *
- *  @param[in] window The window to set the attribute for.
- *  @param[in] attrib A supported window attribute.
- *  @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark Calling @ref glfwGetWindowAttrib will always return the latest
- *  value, even if that value is ignored by the current mode of the window.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_attribs
- *  @sa @ref glfwGetWindowAttrib
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowAttrib(GLFWwindow* window, int attrib, int value);
-
-/*! @brief Sets the user pointer of the specified window.
- *
- *  This function sets the user-defined pointer of the specified window.  The
- *  current value is retained until the window is destroyed.  The initial value
- *  is `NULL`.
- *
- *  @param[in] window The window whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_userptr
- *  @sa @ref glfwGetWindowUserPointer
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer);
-
-/*! @brief Returns the user pointer of the specified window.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified window.  The initial value is `NULL`.
- *
- *  @param[in] window The window whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref window_userptr
- *  @sa @ref glfwSetWindowUserPointer
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window);
-
-/*! @brief Sets the position callback for the specified window.
- *
- *  This function sets the position callback of the specified window, which is
- *  called when the window is moved.  The callback is provided with the
- *  position, in screen coordinates, of the upper-left corner of the content
- *  area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int xpos, int ypos)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowposfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @wayland This callback will never be called, as there is no way for
- *  an application to know its global position.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_pos
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun callback);
-
-/*! @brief Sets the size callback for the specified window.
- *
- *  This function sets the size callback of the specified window, which is
- *  called when the window is resized.  The callback is provided with the size,
- *  in screen coordinates, of the content area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowsizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_size
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun callback);
-
-/*! @brief Sets the close callback for the specified window.
- *
- *  This function sets the close callback of the specified window, which is
- *  called when the user attempts to close the window, for example by clicking
- *  the close widget in the title bar.
- *
- *  The close flag is set before this callback is called, but you can modify it
- *  at any time with @ref glfwSetWindowShouldClose.
- *
- *  The close callback is not triggered by @ref glfwDestroyWindow.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowclosefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @macos Selecting Quit from the application menu will trigger the
- *  close callback for all windows.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_close
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun callback);
-
-/*! @brief Sets the refresh callback for the specified window.
- *
- *  This function sets the refresh callback of the specified window, which is
- *  called when the content area of the window needs to be redrawn, for example
- *  if the window has been exposed after having been covered by another window.
- *
- *  On compositing window systems such as Aero, Compiz, Aqua or Wayland, where
- *  the window contents are saved off-screen, this callback may be called only
- *  very infrequently or never at all.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window);
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowrefreshfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_refresh
- *
- *  @since Added in version 2.5.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun callback);
-
-/*! @brief Sets the focus callback for the specified window.
- *
- *  This function sets the focus callback of the specified window, which is
- *  called when the window gains or loses input focus.
- *
- *  After the focus callback is called for a window that lost input focus,
- *  synthetic key and mouse button release events will be generated for all such
- *  that had been pressed.  For more information, see @ref glfwSetKeyCallback
- *  and @ref glfwSetMouseButtonCallback.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int focused)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowfocusfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_focus
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun callback);
-
-/*! @brief Sets the iconify callback for the specified window.
- *
- *  This function sets the iconification callback of the specified window, which
- *  is called when the window is iconified or restored.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int iconified)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowiconifyfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_iconify
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun callback);
-
-/*! @brief Sets the maximize callback for the specified window.
- *
- *  This function sets the maximization callback of the specified window, which
- *  is called when the window is maximized or restored.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int maximized)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowmaximizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_maximize
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window, GLFWwindowmaximizefun callback);
-
-/*! @brief Sets the framebuffer resize callback for the specified window.
- *
- *  This function sets the framebuffer resize callback of the specified window,
- *  which is called when the framebuffer of the specified window is resized.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int width, int height)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWframebuffersizefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_fbsize
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun callback);
-
-/*! @brief Sets the window content scale callback for the specified window.
- *
- *  This function sets the window content scale callback of the specified window,
- *  which is called when the content scale of the specified window changes.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, float xscale, float yscale)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWwindowcontentscalefun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref window_scale
- *  @sa @ref glfwGetWindowContentScale
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup window
- */
-GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun callback);
-
-/*! @brief Processes all pending events.
- *
- *  This function processes only those events that are already in the event
- *  queue and then returns immediately.  Processing events will cause the window
- *  and input callbacks associated with those events to be called.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwWaitEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwPollEvents(void);
-
-/*! @brief Waits until events are queued and processes them.
- *
- *  This function puts the calling thread to sleep until at least one event is
- *  available in the event queue.  Once one or more events are available,
- *  it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue
- *  are processed and the function then returns immediately.  Processing events
- *  will cause the window and input callbacks associated with those events to be
- *  called.
- *
- *  Since not all events are associated with callbacks, this function may return
- *  without a callback having been called even if you are monitoring all
- *  callbacks.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwPollEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 2.5.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWaitEvents(void);
-
-/*! @brief Waits with timeout until events are queued and processes them.
- *
- *  This function puts the calling thread to sleep until at least one event is
- *  available in the event queue, or until the specified timeout is reached.  If
- *  one or more events are available, it behaves exactly like @ref
- *  glfwPollEvents, i.e. the events in the queue are processed and the function
- *  then returns immediately.  Processing events will cause the window and input
- *  callbacks associated with those events to be called.
- *
- *  The timeout value must be a positive finite number.
- *
- *  Since not all events are associated with callbacks, this function may return
- *  without a callback having been called even if you are monitoring all
- *  callbacks.
- *
- *  On some platforms, a window move, resize or menu operation will cause event
- *  processing to block.  This is due to how event processing is designed on
- *  those platforms.  You can use the
- *  [window refresh callback](@ref window_refresh) to redraw the contents of
- *  your window when necessary during such operations.
- *
- *  Do not assume that callbacks you set will _only_ be called in response to
- *  event processing functions like this one.  While it is necessary to poll for
- *  events, window systems that require GLFW to register callbacks of its own
- *  can pass events to GLFW in response to many window system function calls.
- *  GLFW will pass those events on to the application callbacks before
- *  returning.
- *
- *  Event processing is not required for joystick input to work.
- *
- *  @param[in] timeout The maximum amount of time, in seconds, to wait.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwPollEvents
- *  @sa @ref glfwWaitEvents
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwWaitEventsTimeout(double timeout);
-
-/*! @brief Posts an empty event to the event queue.
- *
- *  This function posts an empty event from the current thread to the event
- *  queue, causing @ref glfwWaitEvents or @ref glfwWaitEventsTimeout to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref events
- *  @sa @ref glfwWaitEvents
- *  @sa @ref glfwWaitEventsTimeout
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwPostEmptyEvent(void);
-
-/*! @brief Returns the value of an input option for the specified window.
- *
- *  This function returns the value of an input option for the specified window.
- *  The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
- *  @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
- *  @ref GLFW_RAW_MOUSE_MOTION.
- *
- *  @param[in] window The window to query.
- *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
- *  `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
- *  `GLFW_RAW_MOUSE_MOTION`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref glfwSetInputMode
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
-
-/*! @brief Sets an input option for the specified window.
- *
- *  This function sets an input mode option for the specified window.  The mode
- *  must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
- *  @ref GLFW_STICKY_MOUSE_BUTTONS, @ref GLFW_LOCK_KEY_MODS or
- *  @ref GLFW_RAW_MOUSE_MOTION.
- *
- *  If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
- *  modes:
- *  - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally.
- *  - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the
- *    content area of the window but does not restrict the cursor from leaving.
- *  - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual
- *    and unlimited cursor movement.  This is useful for implementing for
- *    example 3D camera controls.
- *
- *  If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to
- *  enable sticky keys, or `GLFW_FALSE` to disable it.  If sticky keys are
- *  enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS`
- *  the next time it is called even if the key had been released before the
- *  call.  This is useful when you are only interested in whether keys have been
- *  pressed but not when or in which order.
- *
- *  If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either
- *  `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it.
- *  If sticky mouse buttons are enabled, a mouse button press will ensure that
- *  @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even
- *  if the mouse button had been released before the call.  This is useful when
- *  you are only interested in whether mouse buttons have been pressed but not
- *  when or in which order.
- *
- *  If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
- *  enable lock key modifier bits, or `GLFW_FALSE` to disable them.  If enabled,
- *  callbacks that receive modifier bits will also have the @ref
- *  GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
- *  and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
- *
- *  If the mode is `GLFW_RAW_MOUSE_MOTION`, the value must be either `GLFW_TRUE`
- *  to enable raw (unscaled and unaccelerated) mouse motion when the cursor is
- *  disabled, or `GLFW_FALSE` to disable it.  If raw motion is not supported,
- *  attempting to set this will emit @ref GLFW_FEATURE_UNAVAILABLE.  Call @ref
- *  glfwRawMouseMotionSupported to check for support.
- *
- *  @param[in] window The window whose input mode to set.
- *  @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
- *  `GLFW_STICKY_MOUSE_BUTTONS`, `GLFW_LOCK_KEY_MODS` or
- *  `GLFW_RAW_MOUSE_MOTION`.
- *  @param[in] value The new value of the specified input mode.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_PLATFORM_ERROR and @ref
- *  GLFW_FEATURE_UNAVAILABLE (see above).
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref glfwGetInputMode
- *
- *  @since Added in version 3.0.  Replaces `glfwEnable` and `glfwDisable`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
-
-/*! @brief Returns whether raw mouse motion is supported.
- *
- *  This function returns whether raw mouse motion is supported on the current
- *  system.  This status does not change after GLFW has been initialized so you
- *  only need to check this once.  If you attempt to enable raw motion on
- *  a system that does not support it, @ref GLFW_PLATFORM_ERROR will be emitted.
- *
- *  Raw mouse motion is closer to the actual motion of the mouse across
- *  a surface.  It is not affected by the scaling and acceleration applied to
- *  the motion of the desktop cursor.  That processing is suitable for a cursor
- *  while raw motion is better for controlling for example a 3D camera.  Because
- *  of this, raw mouse motion is only provided when the cursor is disabled.
- *
- *  @return `GLFW_TRUE` if raw mouse motion is supported on the current machine,
- *  or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref raw_mouse_motion
- *  @sa @ref glfwSetInputMode
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwRawMouseMotionSupported(void);
-
-/*! @brief Returns the layout-specific name of the specified printable key.
- *
- *  This function returns the name of the specified printable key, encoded as
- *  UTF-8.  This is typically the character that key would produce without any
- *  modifier keys, intended for displaying key bindings to the user.  For dead
- *  keys, it is typically the diacritic it would add to a character.
- *
- *  __Do not use this function__ for [text input](@ref input_char).  You will
- *  break text input for many languages even if it happens to work for yours.
- *
- *  If the key is `GLFW_KEY_UNKNOWN`, the scancode is used to identify the key,
- *  otherwise the scancode is ignored.  If you specify a non-printable key, or
- *  `GLFW_KEY_UNKNOWN` and a scancode that maps to a non-printable key, this
- *  function returns `NULL` but does not emit an error.
- *
- *  This behavior allows you to always pass in the arguments in the
- *  [key callback](@ref input_key) without modification.
- *
- *  The printable keys are:
- *  - `GLFW_KEY_APOSTROPHE`
- *  - `GLFW_KEY_COMMA`
- *  - `GLFW_KEY_MINUS`
- *  - `GLFW_KEY_PERIOD`
- *  - `GLFW_KEY_SLASH`
- *  - `GLFW_KEY_SEMICOLON`
- *  - `GLFW_KEY_EQUAL`
- *  - `GLFW_KEY_LEFT_BRACKET`
- *  - `GLFW_KEY_RIGHT_BRACKET`
- *  - `GLFW_KEY_BACKSLASH`
- *  - `GLFW_KEY_WORLD_1`
- *  - `GLFW_KEY_WORLD_2`
- *  - `GLFW_KEY_0` to `GLFW_KEY_9`
- *  - `GLFW_KEY_A` to `GLFW_KEY_Z`
- *  - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9`
- *  - `GLFW_KEY_KP_DECIMAL`
- *  - `GLFW_KEY_KP_DIVIDE`
- *  - `GLFW_KEY_KP_MULTIPLY`
- *  - `GLFW_KEY_KP_SUBTRACT`
- *  - `GLFW_KEY_KP_ADD`
- *  - `GLFW_KEY_KP_EQUAL`
- *
- *  Names for printable keys depend on keyboard layout, while names for
- *  non-printable keys are the same across layouts but depend on the application
- *  language and should be localized along with other user interface text.
- *
- *  @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`.
- *  @param[in] scancode The scancode of the key to query.
- *  @return The UTF-8 encoded, layout-specific name of the key, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark The contents of the returned string may change when a keyboard
- *  layout change event is received.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key_name
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetKeyName(int key, int scancode);
-
-/*! @brief Returns the platform-specific scancode of the specified key.
- *
- *  This function returns the platform-specific scancode of the specified key.
- *
- *  If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
- *  method will return `-1`.
- *
- *  @param[in] key Any [named key](@ref keys).
- *  @return The platform-specific scancode for the key, or `-1` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetKeyScancode(int key);
-
-/*! @brief Returns the last reported state of a keyboard key for the specified
- *  window.
- *
- *  This function returns the last state reported for the specified key to the
- *  specified window.  The returned state is one of `GLFW_PRESS` or
- *  `GLFW_RELEASE`.  The higher-level action `GLFW_REPEAT` is only reported to
- *  the key callback.
- *
- *  If the @ref GLFW_STICKY_KEYS input mode is enabled, this function returns
- *  `GLFW_PRESS` the first time you call it for a key that was pressed, even if
- *  that key has already been released.
- *
- *  The key functions deal with physical keys, with [key tokens](@ref keys)
- *  named after their use on the standard US keyboard layout.  If you want to
- *  input text, use the Unicode character callback instead.
- *
- *  The [modifier key bit masks](@ref mods) are not key tokens and cannot be
- *  used with this function.
- *
- *  __Do not use this function__ to implement [text input](@ref input_char).
- *
- *  @param[in] window The desired window.
- *  @param[in] key The desired [keyboard key](@ref keys).  `GLFW_KEY_UNKNOWN` is
- *  not a valid key for this function.
- *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetKey(GLFWwindow* window, int key);
-
-/*! @brief Returns the last reported state of a mouse button for the specified
- *  window.
- *
- *  This function returns the last state reported for the specified mouse button
- *  to the specified window.  The returned state is one of `GLFW_PRESS` or
- *  `GLFW_RELEASE`.
- *
- *  If the @ref GLFW_STICKY_MOUSE_BUTTONS input mode is enabled, this function
- *  returns `GLFW_PRESS` the first time you call it for a mouse button that was
- *  pressed, even if that mouse button has already been released.
- *
- *  @param[in] window The desired window.
- *  @param[in] button The desired [mouse button](@ref buttons).
- *  @return One of `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_mouse_button
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button);
-
-/*! @brief Retrieves the position of the cursor relative to the content area of
- *  the window.
- *
- *  This function returns the position of the cursor, in screen coordinates,
- *  relative to the upper-left corner of the content area of the specified
- *  window.
- *
- *  If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor
- *  position is unbounded and limited only by the minimum and maximum values of
- *  a `double`.
- *
- *  The coordinate can be converted to their integer equivalents with the
- *  `floor` function.  Casting directly to an integer type works for positive
- *  coordinates, but fails for negative ones.
- *
- *  Any or all of the position arguments may be `NULL`.  If an error occurs, all
- *  non-`NULL` position arguments will be set to zero.
- *
- *  @param[in] window The desired window.
- *  @param[out] xpos Where to store the cursor x-coordinate, relative to the
- *  left edge of the content area, or `NULL`.
- *  @param[out] ypos Where to store the cursor y-coordinate, relative to the to
- *  top edge of the content area, or `NULL`.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwSetCursorPos
- *
- *  @since Added in version 3.0.  Replaces `glfwGetMousePos`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos);
-
-/*! @brief Sets the position of the cursor, relative to the content area of the
- *  window.
- *
- *  This function sets the position, in screen coordinates, of the cursor
- *  relative to the upper-left corner of the content area of the specified
- *  window.  The window must have input focus.  If the window does not have
- *  input focus when this function is called, it fails silently.
- *
- *  __Do not use this function__ to implement things like camera controls.  GLFW
- *  already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the
- *  cursor, transparently re-centers it and provides unconstrained cursor
- *  motion.  See @ref glfwSetInputMode for more information.
- *
- *  If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is
- *  unconstrained and limited only by the minimum and maximum values of
- *  a `double`.
- *
- *  @param[in] window The desired window.
- *  @param[in] xpos The desired x-coordinate, relative to the left edge of the
- *  content area.
- *  @param[in] ypos The desired y-coordinate, relative to the top edge of the
- *  content area.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @remark @wayland This function will only work when the cursor mode is
- *  `GLFW_CURSOR_DISABLED`, otherwise it will do nothing.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *  @sa @ref glfwGetCursorPos
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMousePos`.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);
-
-/*! @brief Creates a custom cursor.
- *
- *  Creates a new custom cursor image that can be set for a window with @ref
- *  glfwSetCursor.  The cursor can be destroyed with @ref glfwDestroyCursor.
- *  Any remaining cursors are destroyed by @ref glfwTerminate.
- *
- *  The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight
- *  bits per channel with the red channel first.  They are arranged canonically
- *  as packed sequential rows, starting from the top-left corner.
- *
- *  The cursor hotspot is specified in pixels, relative to the upper-left corner
- *  of the cursor image.  Like all other coordinate systems in GLFW, the X-axis
- *  points to the right and the Y-axis points down.
- *
- *  @param[in] image The desired cursor image.
- *  @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot.
- *  @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot.
- *  @return The handle of the created cursor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified image data is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *  @sa @ref glfwDestroyCursor
- *  @sa @ref glfwCreateStandardCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
-
-/*! @brief Creates a cursor with a standard shape.
- *
- *  Returns a cursor with a standard shape, that can be set for a window with
- *  @ref glfwSetCursor.  The images for these cursors come from the system
- *  cursor theme and their exact appearance will vary between platforms.
- *
- *  Most of these shapes are guaranteed to exist on every supported platform but
- *  a few may not be present.  See the table below for details.
- *
- *  Cursor shape                   | Windows | macOS | X11    | Wayland
- *  ------------------------------ | ------- | ----- | ------ | -------
- *  @ref GLFW_ARROW_CURSOR         | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_IBEAM_CURSOR         | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_CROSSHAIR_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_POINTING_HAND_CURSOR | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_EW_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_NS_CURSOR     | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_RESIZE_NWSE_CURSOR   | Yes     | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *  @ref GLFW_RESIZE_NESW_CURSOR   | Yes     | Yes<sup>1</sup> | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *  @ref GLFW_RESIZE_ALL_CURSOR    | Yes     | Yes   | Yes    | Yes
- *  @ref GLFW_NOT_ALLOWED_CURSOR   | Yes     | Yes   | Maybe<sup>2</sup> | Maybe<sup>2</sup>
- *
- *  1) This uses a private system API and may fail in the future.
- *
- *  2) This uses a newer standard that not all cursor themes support.
- *
- *  If the requested shape is not available, this function emits a @ref
- *  GLFW_CURSOR_UNAVAILABLE error and returns `NULL`.
- *
- *  @param[in] shape One of the [standard shapes](@ref shapes).
- *  @return A new cursor ready to use or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM, @ref GLFW_CURSOR_UNAVAILABLE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_standard
- *  @sa @ref glfwCreateCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape);
-
-/*! @brief Destroys a cursor.
- *
- *  This function destroys a cursor previously created with @ref
- *  glfwCreateCursor.  Any remaining cursors will be destroyed by @ref
- *  glfwTerminate.
- *
- *  If the specified cursor is current for any window, that window will be
- *  reverted to the default cursor.  This does not affect the cursor mode.
- *
- *  @param[in] cursor The cursor object to destroy.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @reentrancy This function must not be called from a callback.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *  @sa @ref glfwCreateCursor
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor);
-
-/*! @brief Sets the cursor for the window.
- *
- *  This function sets the cursor image to be used when the cursor is over the
- *  content area of the specified window.  The set cursor will only be visible
- *  when the [cursor mode](@ref cursor_mode) of the window is
- *  `GLFW_CURSOR_NORMAL`.
- *
- *  On some platforms, the set cursor may not be visible unless the window also
- *  has input focus.
- *
- *  @param[in] window The window to set the cursor for.
- *  @param[in] cursor The cursor to set, or `NULL` to switch back to the default
- *  arrow cursor.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_object
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor);
-
-/*! @brief Sets the key callback.
- *
- *  This function sets the key callback of the specified window, which is called
- *  when a key is pressed, repeated or released.
- *
- *  The key functions deal with physical keys, with layout independent
- *  [key tokens](@ref keys) named after their values in the standard US keyboard
- *  layout.  If you want to input text, use the
- *  [character callback](@ref glfwSetCharCallback) instead.
- *
- *  When a window loses input focus, it will generate synthetic key release
- *  events for all pressed keys.  You can tell these events from user-generated
- *  events by the fact that the synthetic ones are generated after the focus
- *  loss event has been processed, i.e. after the
- *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
- *
- *  The scancode of a key is specific to that platform or sometimes even to that
- *  machine.  Scancodes are intended to allow users to bind keys that don't have
- *  a GLFW key token.  Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their
- *  state is not saved and so it cannot be queried with @ref glfwGetKey.
- *
- *  Sometimes GLFW needs to generate synthetic key events, in which case the
- *  scancode may be zero.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new key callback, or `NULL` to remove the currently
- *  set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWkeyfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_key
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun callback);
-
-/*! @brief Sets the Unicode character callback.
- *
- *  This function sets the character callback of the specified window, which is
- *  called when a Unicode character is input.
- *
- *  The character callback is intended for Unicode text input.  As it deals with
- *  characters, it is keyboard layout dependent, whereas the
- *  [key callback](@ref glfwSetKeyCallback) is not.  Characters do not map 1:1
- *  to physical keys, as a key may produce zero, one or more characters.  If you
- *  want to know whether a specific physical key was pressed or released, see
- *  the key callback instead.
- *
- *  The character callback behaves as system text input normally does and will
- *  not be called if modifier keys are held down that would prevent normal text
- *  input on that platform, for example a Super (Command) key on macOS or Alt key
- *  on Windows.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcharfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_char
- *
- *  @since Added in version 2.4.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun callback);
-
-/*! @brief Sets the Unicode character with modifiers callback.
- *
- *  This function sets the character with modifiers callback of the specified
- *  window, which is called when a Unicode character is input regardless of what
- *  modifier keys are used.
- *
- *  The character with modifiers callback is intended for implementing custom
- *  Unicode character input.  For regular Unicode text input, see the
- *  [character callback](@ref glfwSetCharCallback).  Like the character
- *  callback, the character with modifiers callback deals with characters and is
- *  keyboard layout dependent.  Characters do not map 1:1 to physical keys, as
- *  a key may produce zero, one or more characters.  If you want to know whether
- *  a specific physical key was pressed or released, see the
- *  [key callback](@ref glfwSetKeyCallback) instead.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or an
- *  [error](@ref error_handling) occurred.
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, unsigned int codepoint, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcharmodsfun).
- *
- *  @deprecated Scheduled for removal in version 4.0.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_char
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun callback);
-
-/*! @brief Sets the mouse button callback.
- *
- *  This function sets the mouse button callback of the specified window, which
- *  is called when a mouse button is pressed or released.
- *
- *  When a window loses input focus, it will generate synthetic mouse button
- *  release events for all pressed mouse buttons.  You can tell these events
- *  from user-generated events by the fact that the synthetic ones are generated
- *  after the focus loss event has been processed, i.e. after the
- *  [window focus callback](@ref glfwSetWindowFocusCallback) has been called.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int button, int action, int mods)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWmousebuttonfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref input_mouse_button
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter and return value.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun callback);
-
-/*! @brief Sets the cursor position callback.
- *
- *  This function sets the cursor position callback of the specified window,
- *  which is called when the cursor is moved.  The callback is provided with the
- *  position, in screen coordinates, relative to the upper-left corner of the
- *  content area of the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, double xpos, double ypos);
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcursorposfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_pos
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMousePosCallback`.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun callback);
-
-/*! @brief Sets the cursor enter/leave callback.
- *
- *  This function sets the cursor boundary crossing callback of the specified
- *  window, which is called when the cursor enters or leaves the content area of
- *  the window.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int entered)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWcursorenterfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref cursor_enter
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun callback);
-
-/*! @brief Sets the scroll callback.
- *
- *  This function sets the scroll callback of the specified window, which is
- *  called when a scrolling device is used, such as a mouse wheel or scrolling
- *  area of a touchpad.
- *
- *  The scroll callback receives all scrolling input, like that from a mouse
- *  wheel or a touchpad scrolling area.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new scroll callback, or `NULL` to remove the
- *  currently set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, double xoffset, double yoffset)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWscrollfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref scrolling
- *
- *  @since Added in version 3.0.  Replaces `glfwSetMouseWheelCallback`.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
-
-/*! @brief Sets the path drop callback.
- *
- *  This function sets the path drop callback of the specified window, which is
- *  called when one or more dragged paths are dropped on the window.
- *
- *  Because the path array and its strings may have been generated specifically
- *  for that event, they are not guaranteed to be valid after the callback has
- *  returned.  If you wish to use them after the callback returns, you need to
- *  make a deep copy.
- *
- *  @param[in] window The window whose callback to set.
- *  @param[in] callback The new file drop callback, or `NULL` to remove the
- *  currently set callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(GLFWwindow* window, int path_count, const char* paths[])
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWdropfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @remark @wayland File drop is currently unimplemented.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref path_drop
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
-
-/*! @brief Returns whether the specified joystick is present.
- *
- *  This function returns whether the specified joystick is present.
- *
- *  There is no need to call this function before other functions that accept
- *  a joystick ID, as they all check for presence before performing any other
- *  work.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick
- *
- *  @since Added in version 3.0.  Replaces `glfwGetJoystickParam`.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwJoystickPresent(int jid);
-
-/*! @brief Returns the values of all axes of the specified joystick.
- *
- *  This function returns the values of all axes of the specified joystick.
- *  Each element in the array is a value between -1.0 and 1.0.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of axis values in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of axis values, or `NULL` if the joystick is not present or
- *  an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_axis
- *
- *  @since Added in version 3.0.  Replaces `glfwGetJoystickPos`.
- *
- *  @ingroup input
- */
-GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count);
-
-/*! @brief Returns the state of all buttons of the specified joystick.
- *
- *  This function returns the state of all buttons of the specified joystick.
- *  Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`.
- *
- *  For backward compatibility with earlier versions that did not have @ref
- *  glfwGetJoystickHats, the button array also includes all hats, each
- *  represented as four buttons.  The hats are in the same order as returned by
- *  __glfwGetJoystickHats__ and are in the order _up_, _right_, _down_ and
- *  _left_.  To disable these extra buttons, set the @ref
- *  GLFW_JOYSTICK_HAT_BUTTONS init hint before initialization.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of button states in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of button states, or `NULL` if the joystick is not present
- *  or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_button
- *
- *  @since Added in version 2.2.
- *  @glfw3 Changed to return a dynamic array.
- *
- *  @ingroup input
- */
-GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count);
-
-/*! @brief Returns the state of all hats of the specified joystick.
- *
- *  This function returns the state of all hats of the specified joystick.
- *  Each element in the array is one of the following values:
- *
- *  Name                  | Value
- *  ----                  | -----
- *  `GLFW_HAT_CENTERED`   | 0
- *  `GLFW_HAT_UP`         | 1
- *  `GLFW_HAT_RIGHT`      | 2
- *  `GLFW_HAT_DOWN`       | 4
- *  `GLFW_HAT_LEFT`       | 8
- *  `GLFW_HAT_RIGHT_UP`   | `GLFW_HAT_RIGHT` \| `GLFW_HAT_UP`
- *  `GLFW_HAT_RIGHT_DOWN` | `GLFW_HAT_RIGHT` \| `GLFW_HAT_DOWN`
- *  `GLFW_HAT_LEFT_UP`    | `GLFW_HAT_LEFT` \| `GLFW_HAT_UP`
- *  `GLFW_HAT_LEFT_DOWN`  | `GLFW_HAT_LEFT` \| `GLFW_HAT_DOWN`
- *
- *  The diagonal directions are bitwise combinations of the primary (up, right,
- *  down and left) directions and you can test for these individually by ANDing
- *  it with the corresponding direction.
- *
- *  @code
- *  if (hats[2] & GLFW_HAT_RIGHT)
- *  {
- *      // State of hat 2 could be right-up, right or right-down
- *  }
- *  @endcode
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] count Where to store the number of hat states in the returned
- *  array.  This is set to zero if the joystick is not present or an error
- *  occurred.
- *  @return An array of hat states, or `NULL` if the joystick is not present
- *  or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected, this function is called again for that joystick or the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_hat
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count);
-
-/*! @brief Returns the name of the specified joystick.
- *
- *  This function returns the name, encoded as UTF-8, of the specified joystick.
- *  The returned string is allocated and freed by GLFW.  You should not free it
- *  yourself.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick
- *  is not present or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_name
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetJoystickName(int jid);
-
-/*! @brief Returns the SDL compatible GUID of the specified joystick.
- *
- *  This function returns the SDL compatible GUID, as a UTF-8 encoded
- *  hexadecimal string, of the specified joystick.  The returned string is
- *  allocated and freed by GLFW.  You should not free it yourself.
- *
- *  The GUID is what connects a joystick to a gamepad mapping.  A connected
- *  joystick will always have a GUID even if there is no gamepad mapping
- *  assigned to it.
- *
- *  If the specified joystick is not present this function will return `NULL`
- *  but will not generate an error.  This can be used instead of first calling
- *  @ref glfwJoystickPresent.
- *
- *  The GUID uses the format introduced in SDL 2.0.5.  This GUID tries to
- *  uniquely identify the make and model of a joystick but does not identify
- *  a specific unit, e.g. all wired Xbox 360 controllers will have the same
- *  GUID on that platform.  The GUID for a unit may vary between platforms
- *  depending on what hardware information the platform specific APIs provide.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded GUID of the joystick, or `NULL` if the joystick
- *  is not present or an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetJoystickGUID(int jid);
-
-/*! @brief Sets the user pointer of the specified joystick.
- *
- *  This function sets the user-defined pointer of the specified joystick.  The
- *  current value is retained until the joystick is disconnected.  The initial
- *  value is `NULL`.
- *
- *  This function may be called from the joystick callback, even for a joystick
- *  that is being disconnected.
- *
- *  @param[in] jid The joystick whose pointer to set.
- *  @param[in] pointer The new value.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref joystick_userptr
- *  @sa @ref glfwGetJoystickUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
-
-/*! @brief Returns the user pointer of the specified joystick.
- *
- *  This function returns the current value of the user-defined pointer of the
- *  specified joystick.  The initial value is `NULL`.
- *
- *  This function may be called from the joystick callback, even for a joystick
- *  that is being disconnected.
- *
- *  @param[in] jid The joystick whose pointer to return.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @sa @ref joystick_userptr
- *  @sa @ref glfwSetJoystickUserPointer
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI void* glfwGetJoystickUserPointer(int jid);
-
-/*! @brief Returns whether the specified joystick has a gamepad mapping.
- *
- *  This function returns whether the specified joystick is both present and has
- *  a gamepad mapping.
- *
- *  If the specified joystick is present but does not have a gamepad mapping
- *  this function will return `GLFW_FALSE` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check if a joystick is present regardless of
- *  whether it has a mapping.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return `GLFW_TRUE` if a joystick is both present and has a gamepad mapping,
- *  or `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwGetGamepadState
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwJoystickIsGamepad(int jid);
-
-/*! @brief Sets the joystick configuration callback.
- *
- *  This function sets the joystick configuration callback, or removes the
- *  currently set callback.  This is called when a joystick is connected to or
- *  disconnected from the system.
- *
- *  For joystick connection and disconnection events to be delivered on all
- *  platforms, you need to call one of the [event processing](@ref events)
- *  functions.  Joystick disconnection may also be detected and the callback
- *  called by joystick functions.  The function will then return whatever it
- *  returns if the joystick is not present.
- *
- *  @param[in] callback The new callback, or `NULL` to remove the currently set
- *  callback.
- *  @return The previously set callback, or `NULL` if no callback was set or the
- *  library had not been [initialized](@ref intro_init).
- *
- *  @callback_signature
- *  @code
- *  void function_name(int jid, int event)
- *  @endcode
- *  For more information about the callback parameters, see the
- *  [function pointer type](@ref GLFWjoystickfun).
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref joystick_event
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
-
-/*! @brief Adds the specified SDL_GameControllerDB gamepad mappings.
- *
- *  This function parses the specified ASCII encoded string and updates the
- *  internal list with any gamepad mappings it finds.  This string may
- *  contain either a single gamepad mapping or many mappings separated by
- *  newlines.  The parser supports the full format of the `gamecontrollerdb.txt`
- *  source file including empty lines and comments.
- *
- *  See @ref gamepad_mapping for a description of the format.
- *
- *  If there is already a gamepad mapping for a given GUID in the internal list,
- *  it will be replaced by the one passed to this function.  If the library is
- *  terminated and re-initialized the internal list will revert to the built-in
- *  default.
- *
- *  @param[in] string The string containing the gamepad mappings.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwJoystickIsGamepad
- *  @sa @ref glfwGetGamepadName
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwUpdateGamepadMappings(const char* string);
-
-/*! @brief Returns the human-readable gamepad name for the specified joystick.
- *
- *  This function returns the human-readable name of the gamepad from the
- *  gamepad mapping assigned to the specified joystick.
- *
- *  If the specified joystick is not present or does not have a gamepad mapping
- *  this function will return `NULL` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check whether it is present regardless of
- *  whether it has a mapping.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @return The UTF-8 encoded name of the gamepad, or `NULL` if the
- *  joystick is not present, does not have a mapping or an
- *  [error](@ref error_handling) occurred.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the specified joystick is
- *  disconnected, the gamepad mappings are updated or the library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwJoystickIsGamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetGamepadName(int jid);
-
-/*! @brief Retrieves the state of the specified joystick remapped as a gamepad.
- *
- *  This function retrieves the state of the specified joystick remapped to
- *  an Xbox-like gamepad.
- *
- *  If the specified joystick is not present or does not have a gamepad mapping
- *  this function will return `GLFW_FALSE` but will not generate an error.  Call
- *  @ref glfwJoystickPresent to check whether it is present regardless of
- *  whether it has a mapping.
- *
- *  The Guide button may not be available for input as it is often hooked by the
- *  system or the Steam client.
- *
- *  Not all devices have all the buttons or axes provided by @ref
- *  GLFWgamepadstate.  Unavailable buttons and axes will always report
- *  `GLFW_RELEASE` and 0.0 respectively.
- *
- *  @param[in] jid The [joystick](@ref joysticks) to query.
- *  @param[out] state The gamepad input state of the joystick.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if no joystick is
- *  connected, it has no gamepad mapping or an [error](@ref error_handling)
- *  occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_ENUM.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref gamepad
- *  @sa @ref glfwUpdateGamepadMappings
- *  @sa @ref glfwJoystickIsGamepad
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup input
- */
-GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
-
-/*! @brief Sets the clipboard to the specified string.
- *
- *  This function sets the system clipboard to the specified, UTF-8 encoded
- *  string.
- *
- *  @param[in] window Deprecated.  Any valid window or `NULL`.
- *  @param[in] string A UTF-8 encoded string.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa @ref glfwGetClipboardString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string);
-
-/*! @brief Returns the contents of the clipboard as a string.
- *
- *  This function returns the contents of the system clipboard, if it contains
- *  or is convertible to a UTF-8 encoded string.  If the clipboard is empty or
- *  if its contents cannot be converted, `NULL` is returned and a @ref
- *  GLFW_FORMAT_UNAVAILABLE error is generated.
- *
- *  @param[in] window Deprecated.  Any valid window or `NULL`.
- *  @return The contents of the clipboard as a UTF-8 encoded string, or `NULL`
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is valid until the next call to @ref
- *  glfwGetClipboardString or @ref glfwSetClipboardString, or until the library
- *  is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa @ref glfwSetClipboardString
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup input
- */
-GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window);
-
-/*! @brief Returns the GLFW time.
- *
- *  This function returns the current GLFW time, in seconds.  Unless the time
- *  has been set using @ref glfwSetTime it measures time elapsed since GLFW was
- *  initialized.
- *
- *  This function and @ref glfwSetTime are helper functions on top of @ref
- *  glfwGetTimerFrequency and @ref glfwGetTimerValue.
- *
- *  The resolution of the timer is system dependent, but is usually on the order
- *  of a few micro- or nanoseconds.  It uses the highest-resolution monotonic
- *  time source on each supported platform.
- *
- *  @return The current time, in seconds, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.  Reading and
- *  writing of the internal base time is not atomic, so it needs to be
- *  externally synchronized with calls to @ref glfwSetTime.
- *
- *  @sa @ref time
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup input
- */
-GLFWAPI double glfwGetTime(void);
-
-/*! @brief Sets the GLFW time.
- *
- *  This function sets the current GLFW time, in seconds.  The value must be
- *  a positive finite number less than or equal to 18446744073.0, which is
- *  approximately 584.5 years.
- *
- *  This function and @ref glfwGetTime are helper functions on top of @ref
- *  glfwGetTimerFrequency and @ref glfwGetTimerValue.
- *
- *  @param[in] time The new value, in seconds.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_INVALID_VALUE.
- *
- *  @remark The upper limit of GLFW time is calculated as
- *  floor((2<sup>64</sup> - 1) / 10<sup>9</sup>) and is due to implementations
- *  storing nanoseconds in 64 bits.  The limit may be increased in the future.
- *
- *  @thread_safety This function may be called from any thread.  Reading and
- *  writing of the internal base time is not atomic, so it needs to be
- *  externally synchronized with calls to @ref glfwGetTime.
- *
- *  @sa @ref time
- *
- *  @since Added in version 2.2.
- *
- *  @ingroup input
- */
-GLFWAPI void glfwSetTime(double time);
-
-/*! @brief Returns the current value of the raw timer.
- *
- *  This function returns the current value of the raw timer, measured in
- *  1&nbsp;/&nbsp;frequency seconds.  To get the frequency, call @ref
- *  glfwGetTimerFrequency.
- *
- *  @return The value of the timer, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref time
- *  @sa @ref glfwGetTimerFrequency
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI uint64_t glfwGetTimerValue(void);
-
-/*! @brief Returns the frequency, in Hz, of the raw timer.
- *
- *  This function returns the frequency, in Hz, of the raw timer.
- *
- *  @return The frequency of the timer, in Hz, or zero if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref time
- *  @sa @ref glfwGetTimerValue
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup input
- */
-GLFWAPI uint64_t glfwGetTimerFrequency(void);
-
-/*! @brief Makes the context of the specified window current for the calling
- *  thread.
- *
- *  This function makes the OpenGL or OpenGL ES context of the specified window
- *  current on the calling thread.  A context must only be made current on
- *  a single thread at a time and each thread can have only a single current
- *  context at a time.
- *
- *  When moving a context between threads, you must make it non-current on the
- *  old thread before making it current on the new one.
- *
- *  By default, making a context non-current implicitly forces a pipeline flush.
- *  On machines that support `GL_KHR_context_flush_control`, you can control
- *  whether a context performs this flush by setting the
- *  [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref GLFW_CONTEXT_RELEASE_BEHAVIOR_hint)
- *  hint.
- *
- *  The specified window must have an OpenGL or OpenGL ES context.  Specifying
- *  a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
- *  error.
- *
- *  @param[in] window The window whose context to make current, or `NULL` to
- *  detach the current context.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_current
- *  @sa @ref glfwGetCurrentContext
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window);
-
-/*! @brief Returns the window whose context is current on the calling thread.
- *
- *  This function returns the window whose OpenGL or OpenGL ES context is
- *  current on the calling thread.
- *
- *  @return The window whose context is current, or `NULL` if no window's
- *  context is current.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_current
- *  @sa @ref glfwMakeContextCurrent
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup context
- */
-GLFWAPI GLFWwindow* glfwGetCurrentContext(void);
-
-/*! @brief Swaps the front and back buffers of the specified window.
- *
- *  This function swaps the front and back buffers of the specified window when
- *  rendering with OpenGL or OpenGL ES.  If the swap interval is greater than
- *  zero, the GPU driver waits the specified number of screen updates before
- *  swapping the buffers.
- *
- *  The specified window must have an OpenGL or OpenGL ES context.  Specifying
- *  a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT
- *  error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see `vkQueuePresentKHR` instead.
- *
- *  @param[in] window The window whose buffers to swap.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark __EGL:__ The context of the specified window must be current on the
- *  calling thread.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref buffer_swap
- *  @sa @ref glfwSwapInterval
- *
- *  @since Added in version 1.0.
- *  @glfw3 Added window handle parameter.
- *
- *  @ingroup window
- */
-GLFWAPI void glfwSwapBuffers(GLFWwindow* window);
-
-/*! @brief Sets the swap interval for the current context.
- *
- *  This function sets the swap interval for the current OpenGL or OpenGL ES
- *  context, i.e. the number of screen updates to wait from the time @ref
- *  glfwSwapBuffers was called before swapping the buffers and returning.  This
- *  is sometimes called _vertical synchronization_, _vertical retrace
- *  synchronization_ or just _vsync_.
- *
- *  A context that supports either of the `WGL_EXT_swap_control_tear` and
- *  `GLX_EXT_swap_control_tear` extensions also accepts _negative_ swap
- *  intervals, which allows the driver to swap immediately even if a frame
- *  arrives a little bit late.  You can check for these extensions with @ref
- *  glfwExtensionSupported.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see the present mode of your swapchain instead.
- *
- *  @param[in] interval The minimum number of screen updates to wait for
- *  until the buffers are swapped by @ref glfwSwapBuffers.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark This function is not called during context creation, leaving the
- *  swap interval set to whatever is the default on that platform.  This is done
- *  because some swap interval extensions used by GLFW do not allow the swap
- *  interval to be reset to zero once it has been set to a non-zero value.
- *
- *  @remark Some GPU drivers do not honor the requested swap interval, either
- *  because of a user setting that overrides the application's request or due to
- *  bugs in the driver.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref buffer_swap
- *  @sa @ref glfwSwapBuffers
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI void glfwSwapInterval(int interval);
-
-/*! @brief Returns whether the specified extension is available.
- *
- *  This function returns whether the specified
- *  [API extension](@ref context_glext) is supported by the current OpenGL or
- *  OpenGL ES context.  It searches both for client API extension and context
- *  creation API extensions.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  As this functions retrieves and searches one or more extension strings each
- *  call, it is recommended that you cache its results if it is going to be used
- *  frequently.  The extension strings will not change during the lifetime of
- *  a context, so there is no danger in doing this.
- *
- *  This function does not apply to Vulkan.  If you are using Vulkan, see @ref
- *  glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties`
- *  and `vkEnumerateDeviceExtensionProperties` instead.
- *
- *  @param[in] extension The ASCII encoded name of the extension.
- *  @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE`
- *  otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwGetProcAddress
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI int glfwExtensionSupported(const char* extension);
-
-/*! @brief Returns the address of the specified function for the current
- *  context.
- *
- *  This function returns the address of the specified OpenGL or OpenGL ES
- *  [core or extension function](@ref context_glext), if it is supported
- *  by the current context.
- *
- *  A context must be current on the calling thread.  Calling this function
- *  without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error.
- *
- *  This function does not apply to Vulkan.  If you are rendering with Vulkan,
- *  see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and
- *  `vkGetDeviceProcAddr` instead.
- *
- *  @param[in] procname The ASCII encoded name of the function.
- *  @return The address of the function, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark The address of a given function is not guaranteed to be the same
- *  between contexts.
- *
- *  @remark This function may return a non-`NULL` address despite the
- *  associated version or extension not being available.  Always check the
- *  context version or extension string first.
- *
- *  @pointer_lifetime The returned function pointer is valid until the context
- *  is destroyed or the library is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref context_glext
- *  @sa @ref glfwExtensionSupported
- *
- *  @since Added in version 1.0.
- *
- *  @ingroup context
- */
-GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
-
-/*! @brief Returns whether the Vulkan loader and an ICD have been found.
- *
- *  This function returns whether the Vulkan loader and any minimally functional
- *  ICD have been found.
- *
- *  The availability of a Vulkan loader and even an ICD does not by itself
- *  guarantee that surface creation or even instance creation is possible.
- *  For example, on Fermi systems Nvidia will install an ICD that provides no
- *  actual Vulkan support.  Call @ref glfwGetRequiredInstanceExtensions to check
- *  whether the extensions necessary for Vulkan surface creation are available
- *  and @ref glfwGetPhysicalDevicePresentationSupport to check whether a queue
- *  family of a physical device supports image presentation.
- *
- *  @return `GLFW_TRUE` if Vulkan is minimally available, or `GLFW_FALSE`
- *  otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_support
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI int glfwVulkanSupported(void);
-
-/*! @brief Returns the Vulkan instance extensions required by GLFW.
- *
- *  This function returns an array of names of Vulkan instance extensions required
- *  by GLFW for creating Vulkan surfaces for GLFW windows.  If successful, the
- *  list will always contain `VK_KHR_surface`, so if you don't require any
- *  additional extensions you can pass this list directly to the
- *  `VkInstanceCreateInfo` struct.
- *
- *  If Vulkan is not available on the machine, this function returns `NULL` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available.
- *
- *  If Vulkan is available but no set of extensions allowing window surface
- *  creation was found, this function returns `NULL`.  You may still use Vulkan
- *  for off-screen rendering and compute work.
- *
- *  @param[out] count Where to store the number of extensions in the returned
- *  array.  This is set to zero if an error occurred.
- *  @return An array of ASCII encoded extension names, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_API_UNAVAILABLE.
- *
- *  @remark Additional extensions may be required by future versions of GLFW.
- *  You should check if any extensions you wish to enable are already in the
- *  returned array, as it is an error to specify an extension more than once in
- *  the `VkInstanceCreateInfo` struct.
- *
- *  @remark @macos This function currently supports either the
- *  `VK_MVK_macos_surface` extension from MoltenVK or `VK_EXT_metal_surface`
- *  extension.
- *
- *  @pointer_lifetime The returned array is allocated and freed by GLFW.  You
- *  should not free it yourself.  It is guaranteed to be valid only until the
- *  library is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_ext
- *  @sa @ref glfwCreateWindowSurface
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count);
-
-#if defined(VK_VERSION_1_0)
-
-/*! @brief Returns the address of the specified Vulkan instance function.
- *
- *  This function returns the address of the specified Vulkan core or extension
- *  function for the specified instance.  If instance is set to `NULL` it can
- *  return any function exported from the Vulkan loader, including at least the
- *  following functions:
- *
- *  - `vkEnumerateInstanceExtensionProperties`
- *  - `vkEnumerateInstanceLayerProperties`
- *  - `vkCreateInstance`
- *  - `vkGetInstanceProcAddr`
- *
- *  If Vulkan is not available on the machine, this function returns `NULL` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available.
- *
- *  This function is equivalent to calling `vkGetInstanceProcAddr` with
- *  a platform-specific query of the Vulkan loader as a fallback.
- *
- *  @param[in] instance The Vulkan instance to query, or `NULL` to retrieve
- *  functions related to instance creation.
- *  @param[in] procname The ASCII encoded name of the function.
- *  @return The address of the function, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_API_UNAVAILABLE.
- *
- *  @pointer_lifetime The returned function pointer is valid until the library
- *  is terminated.
- *
- *  @thread_safety This function may be called from any thread.
- *
- *  @sa @ref vulkan_proc
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname);
-
-/*! @brief Returns whether the specified queue family can present images.
- *
- *  This function returns whether the specified queue family of the specified
- *  physical device supports presentation to the platform GLFW was built for.
- *
- *  If Vulkan or the required window surface creation instance extensions are
- *  not available on the machine, or if the specified instance was not created
- *  with the required extensions, this function returns `GLFW_FALSE` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported
- *  to check whether Vulkan is at least minimally available and @ref
- *  glfwGetRequiredInstanceExtensions to check what instance extensions are
- *  required.
- *
- *  @param[in] instance The instance that the physical device belongs to.
- *  @param[in] device The physical device that the queue family belongs to.
- *  @param[in] queuefamily The index of the queue family to query.
- *  @return `GLFW_TRUE` if the queue family supports presentation, or
- *  `GLFW_FALSE` otherwise.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR.
- *
- *  @remark @macos This function currently always returns `GLFW_TRUE`, as the
- *  `VK_MVK_macos_surface` extension does not provide
- *  a `vkGetPhysicalDevice*PresentationSupport` type function.
- *
- *  @thread_safety This function may be called from any thread.  For
- *  synchronization details of Vulkan objects, see the Vulkan specification.
- *
- *  @sa @ref vulkan_present
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily);
-
-/*! @brief Creates a Vulkan surface for the specified window.
- *
- *  This function creates a Vulkan surface for the specified window.
- *
- *  If the Vulkan loader or at least one minimally functional ICD were not found,
- *  this function returns `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref
- *  GLFW_API_UNAVAILABLE error.  Call @ref glfwVulkanSupported to check whether
- *  Vulkan is at least minimally available.
- *
- *  If the required window surface creation instance extensions are not
- *  available or if the specified instance was not created with these extensions
- *  enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and
- *  generates a @ref GLFW_API_UNAVAILABLE error.  Call @ref
- *  glfwGetRequiredInstanceExtensions to check what instance extensions are
- *  required.
- *
- *  The window surface cannot be shared with another API so the window must
- *  have been created with the [client api hint](@ref GLFW_CLIENT_API_attrib)
- *  set to `GLFW_NO_API` otherwise it generates a @ref GLFW_INVALID_VALUE error
- *  and returns `VK_ERROR_NATIVE_WINDOW_IN_USE_KHR`.
- *
- *  The window surface must be destroyed before the specified Vulkan instance.
- *  It is the responsibility of the caller to destroy the window surface.  GLFW
- *  does not destroy it for you.  Call `vkDestroySurfaceKHR` to destroy the
- *  surface.
- *
- *  @param[in] instance The Vulkan instance to create the surface in.
- *  @param[in] window The window to create the surface for.
- *  @param[in] allocator The allocator to use, or `NULL` to use the default
- *  allocator.
- *  @param[out] surface Where to store the handle of the surface.  This is set
- *  to `VK_NULL_HANDLE` if an error occurred.
- *  @return `VK_SUCCESS` if successful, or a Vulkan error code if an
- *  [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
- *  GLFW_API_UNAVAILABLE, @ref GLFW_PLATFORM_ERROR and @ref GLFW_INVALID_VALUE
- *
- *  @remark If an error occurs before the creation call is made, GLFW returns
- *  the Vulkan error code most appropriate for the error.  Appropriate use of
- *  @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should
- *  eliminate almost all occurrences of these errors.
- *
- *  @remark @macos This function currently only supports the
- *  `VK_MVK_macos_surface` extension from MoltenVK.
- *
- *  @remark @macos This function creates and sets a `CAMetalLayer` instance for
- *  the window content view, which is required for MoltenVK to function.
- *
- *  @thread_safety This function may be called from any thread.  For
- *  synchronization details of Vulkan objects, see the Vulkan specification.
- *
- *  @sa @ref vulkan_surface
- *  @sa @ref glfwGetRequiredInstanceExtensions
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup vulkan
- */
-GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
-
-#endif /*VK_VERSION_1_0*/
-
-
-/*************************************************************************
- * Global definition cleanup
- *************************************************************************/
-
-/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */
-
-#ifdef GLFW_WINGDIAPI_DEFINED
- #undef WINGDIAPI
- #undef GLFW_WINGDIAPI_DEFINED
-#endif
-
-#ifdef GLFW_CALLBACK_DEFINED
- #undef CALLBACK
- #undef GLFW_CALLBACK_DEFINED
-#endif
-
-/* Some OpenGL related headers need GLAPIENTRY, but it is unconditionally
- * defined by some gl.h variants (OpenBSD) so define it after if needed.
- */
-#ifndef GLAPIENTRY
- #define GLAPIENTRY APIENTRY
-#endif
-
-/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _glfw3_h_ */
-
diff --git a/raylib_pi4_test/external/glfw/include/GLFW/glfw3native.h b/raylib_pi4_test/external/glfw/include/GLFW/glfw3native.h
deleted file mode 100644 (file)
index ba6a16b..0000000
+++ /dev/null
@@ -1,531 +0,0 @@
-/*************************************************************************
- * GLFW 3.4 - www.glfw.org
- * A library for OpenGL, window and input
- *------------------------------------------------------------------------
- * Copyright (c) 2002-2006 Marcus Geelnard
- * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would
- *    be appreciated but is not required.
- *
- * 2. Altered source versions must be plainly marked as such, and must not
- *    be misrepresented as being the original software.
- *
- * 3. This notice may not be removed or altered from any source
- *    distribution.
- *
- *************************************************************************/
-
-#ifndef _glfw3_native_h_
-#define _glfw3_native_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/*************************************************************************
- * Doxygen documentation
- *************************************************************************/
-
-/*! @file glfw3native.h
- *  @brief The header of the native access functions.
- *
- *  This is the header file of the native access functions.  See @ref native for
- *  more information.
- */
-/*! @defgroup native Native access
- *  @brief Functions related to accessing native handles.
- *
- *  **By using the native access functions you assert that you know what you're
- *  doing and how to fix problems caused by using them.  If you don't, you
- *  shouldn't be using them.**
- *
- *  Before the inclusion of @ref glfw3native.h, you may define zero or more
- *  window system API macro and zero or more context creation API macros.
- *
- *  The chosen backends must match those the library was compiled for.  Failure
- *  to do this will cause a link-time error.
- *
- *  The available window API macros are:
- *  * `GLFW_EXPOSE_NATIVE_WIN32`
- *  * `GLFW_EXPOSE_NATIVE_COCOA`
- *  * `GLFW_EXPOSE_NATIVE_X11`
- *  * `GLFW_EXPOSE_NATIVE_WAYLAND`
- *
- *  The available context API macros are:
- *  * `GLFW_EXPOSE_NATIVE_WGL`
- *  * `GLFW_EXPOSE_NATIVE_NSGL`
- *  * `GLFW_EXPOSE_NATIVE_GLX`
- *  * `GLFW_EXPOSE_NATIVE_EGL`
- *  * `GLFW_EXPOSE_NATIVE_OSMESA`
- *
- *  These macros select which of the native access functions that are declared
- *  and which platform-specific headers to include.  It is then up your (by
- *  definition platform-specific) code to handle which of these should be
- *  defined.
- */
-
-
-/*************************************************************************
- * System headers and types
- *************************************************************************/
-
-#if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
- // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
- // example to allow applications to correctly declare a GL_ARB_debug_output
- // callback) but windows.h assumes no one will define APIENTRY before it does
- #if defined(GLFW_APIENTRY_DEFINED)
-  #undef APIENTRY
-  #undef GLFW_APIENTRY_DEFINED
- #endif
-// @raysan5: Actually, only HWND handler needs to be defined
-// Including windows.h could suppose symbols re-definition issues (i.e Rectangle type)
-//#include <windows.h>
- typedef void *PVOID;
- typedef PVOID HANDLE;
- typedef HANDLE HWND;
-#elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
- #include <ApplicationServices/ApplicationServices.h>
- #if defined(__OBJC__)
-  #import <Cocoa/Cocoa.h>
- #else
-  #include <ApplicationServices/ApplicationServices.h>
-  typedef void* id;
- #endif
-#elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
- #include <X11/Xlib.h>
- #include <X11/extensions/Xrandr.h>
-#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
- #include <wayland-client.h>
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WGL)
- /* WGL is declared by windows.h */
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_NSGL)
- /* NSGL is declared by Cocoa.h */
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_GLX)
- #include <GL/glx.h>
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_EGL)
- #include <EGL/egl.h>
-#endif
-#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
- #include <GL/osmesa.h>
-#endif
-
-
-/*************************************************************************
- * Functions
- *************************************************************************/
-
-#if defined(GLFW_EXPOSE_NATIVE_WIN32)
-/*! @brief Returns the adapter device name of the specified monitor.
- *
- *  @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
- *  of the specified monitor, or `NULL` if an [error](@ref error_handling)
- *  occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
-
-/*! @brief Returns the display device name of the specified monitor.
- *
- *  @return The UTF-8 encoded display device name (for example
- *  `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `HWND` of the specified window.
- *
- *  @return The `HWND` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WGL)
-/*! @brief Returns the `HGLRC` of the specified window.
- *
- *  @return The `HGLRC` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_COCOA)
-/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
- *
- *  @return The `CGDirectDisplayID` of the specified monitor, or
- *  `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `NSWindow` of the specified window.
- *
- *  @return The `NSWindow` of the specified window, or `nil` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_NSGL)
-/*! @brief Returns the `NSOpenGLContext` of the specified window.
- *
- *  @return The `NSOpenGLContext` of the specified window, or `nil` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_X11)
-/*! @brief Returns the `Display` used by GLFW.
- *
- *  @return The `Display` used by GLFW, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI Display* glfwGetX11Display(void);
-
-/*! @brief Returns the `RRCrtc` of the specified monitor.
- *
- *  @return The `RRCrtc` of the specified monitor, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
-
-/*! @brief Returns the `RROutput` of the specified monitor.
- *
- *  @return The `RROutput` of the specified monitor, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.1.
- *
- *  @ingroup native
- */
-GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the `Window` of the specified window.
- *
- *  @return The `Window` of the specified window, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
-
-/*! @brief Sets the current primary selection to the specified string.
- *
- *  @param[in] string A UTF-8 encoded string.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The specified string is copied before this function
- *  returns.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa glfwGetX11SelectionString
- *  @sa glfwSetClipboardString
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI void glfwSetX11SelectionString(const char* string);
-
-/*! @brief Returns the contents of the current primary selection as a string.
- *
- *  If the selection is empty or if its contents cannot be converted, `NULL`
- *  is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
- *
- *  @return The contents of the selection as a UTF-8 encoded string, or `NULL`
- *  if an [error](@ref error_handling) occurred.
- *
- *  @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
- *  GLFW_PLATFORM_ERROR.
- *
- *  @pointer_lifetime The returned string is allocated and freed by GLFW. You
- *  should not free it yourself. It is valid until the next call to @ref
- *  glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
- *  library is terminated.
- *
- *  @thread_safety This function must only be called from the main thread.
- *
- *  @sa @ref clipboard
- *  @sa glfwSetX11SelectionString
- *  @sa glfwGetClipboardString
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI const char* glfwGetX11SelectionString(void);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_GLX)
-/*! @brief Returns the `GLXContext` of the specified window.
- *
- *  @return The `GLXContext` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
-
-/*! @brief Returns the `GLXWindow` of the specified window.
- *
- *  @return The `GLXWindow` of the specified window, or `None` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
-/*! @brief Returns the `struct wl_display*` used by GLFW.
- *
- *  @return The `struct wl_display*` used by GLFW, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
-
-/*! @brief Returns the `struct wl_output*` of the specified monitor.
- *
- *  @return The `struct wl_output*` of the specified monitor, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
-
-/*! @brief Returns the main `struct wl_surface*` of the specified window.
- *
- *  @return The main `struct wl_surface*` of the specified window, or `NULL` if
- *  an [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.2.
- *
- *  @ingroup native
- */
-GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_EGL)
-/*! @brief Returns the `EGLDisplay` used by GLFW.
- *
- *  @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
-
-/*! @brief Returns the `EGLContext` of the specified window.
- *
- *  @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
-
-/*! @brief Returns the `EGLSurface` of the specified window.
- *
- *  @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.0.
- *
- *  @ingroup native
- */
-GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
-#endif
-
-#if defined(GLFW_EXPOSE_NATIVE_OSMESA)
-/*! @brief Retrieves the color buffer associated with the specified window.
- *
- *  @param[in] window The window whose color buffer to retrieve.
- *  @param[out] width Where to store the width of the color buffer, or `NULL`.
- *  @param[out] height Where to store the height of the color buffer, or `NULL`.
- *  @param[out] format Where to store the OSMesa pixel format of the color
- *  buffer, or `NULL`.
- *  @param[out] buffer Where to store the address of the color buffer, or
- *  `NULL`.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* window, int* width, int* height, int* format, void** buffer);
-
-/*! @brief Retrieves the depth buffer associated with the specified window.
- *
- *  @param[in] window The window whose depth buffer to retrieve.
- *  @param[out] width Where to store the width of the depth buffer, or `NULL`.
- *  @param[out] height Where to store the height of the depth buffer, or `NULL`.
- *  @param[out] bytesPerValue Where to store the number of bytes per depth
- *  buffer element, or `NULL`.
- *  @param[out] buffer Where to store the address of the depth buffer, or
- *  `NULL`.
- *  @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* window, int* width, int* height, int* bytesPerValue, void** buffer);
-
-/*! @brief Returns the `OSMesaContext` of the specified window.
- *
- *  @return The `OSMesaContext` of the specified window, or `NULL` if an
- *  [error](@ref error_handling) occurred.
- *
- *  @thread_safety This function may be called from any thread.  Access is not
- *  synchronized.
- *
- *  @since Added in version 3.3.
- *
- *  @ingroup native
- */
-GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* window);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _glfw3_native_h_ */
-
diff --git a/raylib_pi4_test/external/glfw/src/CMakeLists.txt b/raylib_pi4_test/external/glfw/src/CMakeLists.txt
deleted file mode 100644 (file)
index 8db786e..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-
-set(common_HEADERS internal.h mappings.h
-                   "${GLFW_BINARY_DIR}/src/glfw_config.h"
-                   "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
-                   "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h")
-set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c)
-
-if (_GLFW_COCOA)
-    set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h
-                     posix_thread.h nsgl_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m
-                     cocoa_monitor.m cocoa_window.m cocoa_time.c posix_thread.c
-                     nsgl_context.m egl_context.c osmesa_context.c)
-elseif (_GLFW_WIN32)
-    set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h
-                     wgl_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_joystick.c
-                     win32_monitor.c win32_time.c win32_thread.c win32_window.c
-                     wgl_context.c egl_context.c osmesa_context.c)
-elseif (_GLFW_X11)
-    set(glfw_HEADERS ${common_HEADERS} x11_platform.h xkb_unicode.h posix_time.h
-                     posix_thread.h glx_context.h egl_context.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} x11_init.c x11_monitor.c x11_window.c
-                     xkb_unicode.c posix_time.c posix_thread.c glx_context.c
-                     egl_context.c osmesa_context.c)
-elseif (_GLFW_WAYLAND)
-    set(glfw_HEADERS ${common_HEADERS} wl_platform.h
-                     posix_time.h posix_thread.h xkb_unicode.h egl_context.h
-                     osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c
-                     posix_time.c posix_thread.c xkb_unicode.c
-                     egl_context.c osmesa_context.c)
-
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/xdg-shell/xdg-shell.xml"
-        BASENAME xdg-shell)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
-        BASENAME xdg-decoration)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/stable/viewporter/viewporter.xml"
-        BASENAME viewporter)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml"
-        BASENAME relative-pointer-unstable-v1)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml"
-        BASENAME pointer-constraints-unstable-v1)
-    ecm_add_wayland_client_protocol(glfw_SOURCES
-        PROTOCOL
-        "${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
-        BASENAME idle-inhibit-unstable-v1)
-elseif (_GLFW_OSMESA)
-    set(glfw_HEADERS ${common_HEADERS} null_platform.h null_joystick.h
-                     posix_time.h posix_thread.h osmesa_context.h)
-    set(glfw_SOURCES ${common_SOURCES} null_init.c null_monitor.c null_window.c
-                     null_joystick.c posix_time.c posix_thread.c osmesa_context.c)
-endif()
-
-if (_GLFW_X11 OR _GLFW_WAYLAND)
-    if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
-        set(glfw_HEADERS ${glfw_HEADERS} linux_joystick.h)
-        set(glfw_SOURCES ${glfw_SOURCES} linux_joystick.c)
-    else()
-        set(glfw_HEADERS ${glfw_HEADERS} null_joystick.h)
-        set(glfw_SOURCES ${glfw_SOURCES} null_joystick.c)
-    endif()
-endif()
-
-if (APPLE)
-    # For some reason, CMake doesn't know about .m
-    set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
-endif()
-
-# Make GCC and Clang warn about declarations that VS 2010 and 2012 won't accept
-# for all source files that VS will build
-if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR
-    "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR
-    "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
-
-    if (WIN32)
-        set(windows_SOURCES ${glfw_SOURCES})
-    else()
-        set(windows_SOURCES ${common_SOURCES})
-    endif()
-    set_source_files_properties(${windows_SOURCES} PROPERTIES
-        COMPILE_FLAGS -Wdeclaration-after-statement)
-endif()
-
-add_library(glfw_objlib OBJECT ${glfw_SOURCES} ${glfw_HEADERS})
-add_library(glfw $<TARGET_OBJECTS:glfw_objlib>)
-set_target_properties(glfw_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON)
-set_target_properties(glfw PROPERTIES
-                      OUTPUT_NAME ${GLFW_LIB_NAME}
-                      VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
-                      SOVERSION ${GLFW_VERSION_MAJOR}
-                      FOLDER "GLFW3")
-
-if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
-    ${CMAKE_VERSION} VERSION_GREATER "3.1.0")
-
-    set_target_properties(glfw_objlib PROPERTIES C_STANDARD 99)
-else()
-    # Remove this fallback when removing support for CMake version less than 3.1
-    target_compile_options(glfw_objlib PRIVATE
-                           "$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
-                           "$<$<C_COMPILER_ID:Clang>:-std=c99>"
-                           "$<$<C_COMPILER_ID:GNU>:-std=c99>")
-endif()
-
-target_compile_definitions(glfw_objlib PRIVATE _GLFW_USE_CONFIG_H)
-target_include_directories(glfw_objlib PUBLIC
-                           "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
-                           "$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
-target_include_directories(glfw PUBLIC
-                           "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
-                           "$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
-target_include_directories(glfw_objlib PRIVATE
-                           "${GLFW_SOURCE_DIR}/src"
-                           "${GLFW_BINARY_DIR}/src"
-                           ${glfw_INCLUDE_DIRS})
-
-# HACK: When building on MinGW, WINVER and UNICODE need to be defined before
-# the inclusion of stddef.h (by glfw3.h), which is itself included before
-# win32_platform.h.  We define them here until a saner solution can be found
-# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack.
-target_compile_definitions(glfw_objlib PRIVATE
-                           "$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>")
-
-# Enable a reasonable set of warnings (no, -Wextra is not reasonable)
-target_compile_options(glfw_objlib PRIVATE
-                       "$<$<C_COMPILER_ID:AppleClang>:-Wall>"
-                       "$<$<C_COMPILER_ID:Clang>:-Wall>"
-                       "$<$<C_COMPILER_ID:GNU>:-Wall>")
-
-if (BUILD_SHARED_LIBS)
-    if (WIN32)
-        if (MINGW)
-            # Remove the dependency on the shared version of libgcc
-            # NOTE: MinGW-w64 has the correct default but MinGW needs this
-            target_link_options(glfw PRIVATE "-static-libgcc")
-
-            # Remove the lib prefix on the DLL (but not the import library)
-            set_target_properties(glfw PROPERTIES PREFIX "")
-
-            # Add a suffix to the import library to avoid naming conflicts
-            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a")
-        else()
-            # Add a suffix to the import library to avoid naming conflicts
-            set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
-        endif()
-
-        target_compile_definitions(glfw_objlib INTERFACE GLFW_DLL)
-    elseif (APPLE)
-        # Add -fno-common to work around a bug in Apple's GCC
-        target_compile_options(glfw_objlib PRIVATE "-fno-common")
-
-        set_target_properties(glfw PROPERTIES
-                              INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
-    endif()
-
-    if (UNIX)
-        # Hide symbols not explicitly tagged for export from the shared library
-        target_compile_options(glfw_objlib PRIVATE "-fvisibility=hidden")
-    endif()
-
-    target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
-else()
-    target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
-endif()
-
-if (MSVC)
-    target_compile_definitions(glfw_objlib PRIVATE _CRT_SECURE_NO_WARNINGS)
-endif()
-
-if (GLFW_INSTALL)
-    install(TARGETS glfw
-            EXPORT glfwTargets
-            RUNTIME DESTINATION "bin"
-            ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-            LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
-endif()
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_init.m b/raylib_pi4_test/external/glfw/src/cocoa_init.m
deleted file mode 100644 (file)
index 7cad8b8..0000000
+++ /dev/null
@@ -1,619 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-#include <sys/param.h> // For MAXPATHLEN
-
-// Needed for _NSGetProgname
-#include <crt_externs.h>
-
-// Change to our application bundle's resources directory, if present
-//
-static void changeToResourcesDirectory(void)
-{
-    char resourcesPath[MAXPATHLEN];
-
-    CFBundleRef bundle = CFBundleGetMainBundle();
-    if (!bundle)
-        return;
-
-    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(bundle);
-
-    CFStringRef last = CFURLCopyLastPathComponent(resourcesURL);
-    if (CFStringCompare(CFSTR("Resources"), last, 0) != kCFCompareEqualTo)
-    {
-        CFRelease(last);
-        CFRelease(resourcesURL);
-        return;
-    }
-
-    CFRelease(last);
-
-    if (!CFURLGetFileSystemRepresentation(resourcesURL,
-                                          true,
-                                          (UInt8*) resourcesPath,
-                                          MAXPATHLEN))
-    {
-        CFRelease(resourcesURL);
-        return;
-    }
-
-    CFRelease(resourcesURL);
-
-    chdir(resourcesPath);
-}
-
-// Set up the menu bar (manually)
-// This is nasty, nasty stuff -- calls to undocumented semi-private APIs that
-// could go away at any moment, lots of stuff that really should be
-// localize(d|able), etc.  Add a nib to save us this horror.
-//
-static void createMenuBar(void)
-{
-    size_t i;
-    NSString* appName = nil;
-    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
-    NSString* nameKeys[] =
-    {
-        @"CFBundleDisplayName",
-        @"CFBundleName",
-        @"CFBundleExecutable",
-    };
-
-    // Try to figure out what the calling application is called
-
-    for (i = 0;  i < sizeof(nameKeys) / sizeof(nameKeys[0]);  i++)
-    {
-        id name = bundleInfo[nameKeys[i]];
-        if (name &&
-            [name isKindOfClass:[NSString class]] &&
-            ![name isEqualToString:@""])
-        {
-            appName = name;
-            break;
-        }
-    }
-
-    if (!appName)
-    {
-        char** progname = _NSGetProgname();
-        if (progname && *progname)
-            appName = @(*progname);
-        else
-            appName = @"GLFW Application";
-    }
-
-    NSMenu* bar = [[NSMenu alloc] init];
-    [NSApp setMainMenu:bar];
-
-    NSMenuItem* appMenuItem =
-        [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
-    NSMenu* appMenu = [[NSMenu alloc] init];
-    [appMenuItem setSubmenu:appMenu];
-
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"About %@", appName]
-                       action:@selector(orderFrontStandardAboutPanel:)
-                keyEquivalent:@""];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    NSMenu* servicesMenu = [[NSMenu alloc] init];
-    [NSApp setServicesMenu:servicesMenu];
-    [[appMenu addItemWithTitle:@"Services"
-                       action:NULL
-                keyEquivalent:@""] setSubmenu:servicesMenu];
-    [servicesMenu release];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"Hide %@", appName]
-                       action:@selector(hide:)
-                keyEquivalent:@"h"];
-    [[appMenu addItemWithTitle:@"Hide Others"
-                       action:@selector(hideOtherApplications:)
-                keyEquivalent:@"h"]
-        setKeyEquivalentModifierMask:NSEventModifierFlagOption | NSEventModifierFlagCommand];
-    [appMenu addItemWithTitle:@"Show All"
-                       action:@selector(unhideAllApplications:)
-                keyEquivalent:@""];
-    [appMenu addItem:[NSMenuItem separatorItem]];
-    [appMenu addItemWithTitle:[NSString stringWithFormat:@"Quit %@", appName]
-                       action:@selector(terminate:)
-                keyEquivalent:@"q"];
-
-    NSMenuItem* windowMenuItem =
-        [bar addItemWithTitle:@"" action:NULL keyEquivalent:@""];
-    [bar release];
-    NSMenu* windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-    [NSApp setWindowsMenu:windowMenu];
-    [windowMenuItem setSubmenu:windowMenu];
-
-    [windowMenu addItemWithTitle:@"Minimize"
-                          action:@selector(performMiniaturize:)
-                   keyEquivalent:@"m"];
-    [windowMenu addItemWithTitle:@"Zoom"
-                          action:@selector(performZoom:)
-                   keyEquivalent:@""];
-    [windowMenu addItem:[NSMenuItem separatorItem]];
-    [windowMenu addItemWithTitle:@"Bring All to Front"
-                          action:@selector(arrangeInFront:)
-                   keyEquivalent:@""];
-
-    // TODO: Make this appear at the bottom of the menu (for consistency)
-    [windowMenu addItem:[NSMenuItem separatorItem]];
-    [[windowMenu addItemWithTitle:@"Enter Full Screen"
-                           action:@selector(toggleFullScreen:)
-                    keyEquivalent:@"f"]
-     setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
-
-    // Prior to Snow Leopard, we need to use this oddly-named semi-private API
-    // to get the application menu working properly.
-    SEL setAppleMenuSelector = NSSelectorFromString(@"setAppleMenu:");
-    [NSApp performSelector:setAppleMenuSelector withObject:appMenu];
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.ns.keycodes, -1, sizeof(_glfw.ns.keycodes));
-    memset(_glfw.ns.scancodes, -1, sizeof(_glfw.ns.scancodes));
-
-    _glfw.ns.keycodes[0x1D] = GLFW_KEY_0;
-    _glfw.ns.keycodes[0x12] = GLFW_KEY_1;
-    _glfw.ns.keycodes[0x13] = GLFW_KEY_2;
-    _glfw.ns.keycodes[0x14] = GLFW_KEY_3;
-    _glfw.ns.keycodes[0x15] = GLFW_KEY_4;
-    _glfw.ns.keycodes[0x17] = GLFW_KEY_5;
-    _glfw.ns.keycodes[0x16] = GLFW_KEY_6;
-    _glfw.ns.keycodes[0x1A] = GLFW_KEY_7;
-    _glfw.ns.keycodes[0x1C] = GLFW_KEY_8;
-    _glfw.ns.keycodes[0x19] = GLFW_KEY_9;
-    _glfw.ns.keycodes[0x00] = GLFW_KEY_A;
-    _glfw.ns.keycodes[0x0B] = GLFW_KEY_B;
-    _glfw.ns.keycodes[0x08] = GLFW_KEY_C;
-    _glfw.ns.keycodes[0x02] = GLFW_KEY_D;
-    _glfw.ns.keycodes[0x0E] = GLFW_KEY_E;
-    _glfw.ns.keycodes[0x03] = GLFW_KEY_F;
-    _glfw.ns.keycodes[0x05] = GLFW_KEY_G;
-    _glfw.ns.keycodes[0x04] = GLFW_KEY_H;
-    _glfw.ns.keycodes[0x22] = GLFW_KEY_I;
-    _glfw.ns.keycodes[0x26] = GLFW_KEY_J;
-    _glfw.ns.keycodes[0x28] = GLFW_KEY_K;
-    _glfw.ns.keycodes[0x25] = GLFW_KEY_L;
-    _glfw.ns.keycodes[0x2E] = GLFW_KEY_M;
-    _glfw.ns.keycodes[0x2D] = GLFW_KEY_N;
-    _glfw.ns.keycodes[0x1F] = GLFW_KEY_O;
-    _glfw.ns.keycodes[0x23] = GLFW_KEY_P;
-    _glfw.ns.keycodes[0x0C] = GLFW_KEY_Q;
-    _glfw.ns.keycodes[0x0F] = GLFW_KEY_R;
-    _glfw.ns.keycodes[0x01] = GLFW_KEY_S;
-    _glfw.ns.keycodes[0x11] = GLFW_KEY_T;
-    _glfw.ns.keycodes[0x20] = GLFW_KEY_U;
-    _glfw.ns.keycodes[0x09] = GLFW_KEY_V;
-    _glfw.ns.keycodes[0x0D] = GLFW_KEY_W;
-    _glfw.ns.keycodes[0x07] = GLFW_KEY_X;
-    _glfw.ns.keycodes[0x10] = GLFW_KEY_Y;
-    _glfw.ns.keycodes[0x06] = GLFW_KEY_Z;
-
-    _glfw.ns.keycodes[0x27] = GLFW_KEY_APOSTROPHE;
-    _glfw.ns.keycodes[0x2A] = GLFW_KEY_BACKSLASH;
-    _glfw.ns.keycodes[0x2B] = GLFW_KEY_COMMA;
-    _glfw.ns.keycodes[0x18] = GLFW_KEY_EQUAL;
-    _glfw.ns.keycodes[0x32] = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.ns.keycodes[0x21] = GLFW_KEY_LEFT_BRACKET;
-    _glfw.ns.keycodes[0x1B] = GLFW_KEY_MINUS;
-    _glfw.ns.keycodes[0x2F] = GLFW_KEY_PERIOD;
-    _glfw.ns.keycodes[0x1E] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.ns.keycodes[0x29] = GLFW_KEY_SEMICOLON;
-    _glfw.ns.keycodes[0x2C] = GLFW_KEY_SLASH;
-    _glfw.ns.keycodes[0x0A] = GLFW_KEY_WORLD_1;
-
-    _glfw.ns.keycodes[0x33] = GLFW_KEY_BACKSPACE;
-    _glfw.ns.keycodes[0x39] = GLFW_KEY_CAPS_LOCK;
-    _glfw.ns.keycodes[0x75] = GLFW_KEY_DELETE;
-    _glfw.ns.keycodes[0x7D] = GLFW_KEY_DOWN;
-    _glfw.ns.keycodes[0x77] = GLFW_KEY_END;
-    _glfw.ns.keycodes[0x24] = GLFW_KEY_ENTER;
-    _glfw.ns.keycodes[0x35] = GLFW_KEY_ESCAPE;
-    _glfw.ns.keycodes[0x7A] = GLFW_KEY_F1;
-    _glfw.ns.keycodes[0x78] = GLFW_KEY_F2;
-    _glfw.ns.keycodes[0x63] = GLFW_KEY_F3;
-    _glfw.ns.keycodes[0x76] = GLFW_KEY_F4;
-    _glfw.ns.keycodes[0x60] = GLFW_KEY_F5;
-    _glfw.ns.keycodes[0x61] = GLFW_KEY_F6;
-    _glfw.ns.keycodes[0x62] = GLFW_KEY_F7;
-    _glfw.ns.keycodes[0x64] = GLFW_KEY_F8;
-    _glfw.ns.keycodes[0x65] = GLFW_KEY_F9;
-    _glfw.ns.keycodes[0x6D] = GLFW_KEY_F10;
-    _glfw.ns.keycodes[0x67] = GLFW_KEY_F11;
-    _glfw.ns.keycodes[0x6F] = GLFW_KEY_F12;
-    _glfw.ns.keycodes[0x69] = GLFW_KEY_F13;
-    _glfw.ns.keycodes[0x6B] = GLFW_KEY_F14;
-    _glfw.ns.keycodes[0x71] = GLFW_KEY_F15;
-    _glfw.ns.keycodes[0x6A] = GLFW_KEY_F16;
-    _glfw.ns.keycodes[0x40] = GLFW_KEY_F17;
-    _glfw.ns.keycodes[0x4F] = GLFW_KEY_F18;
-    _glfw.ns.keycodes[0x50] = GLFW_KEY_F19;
-    _glfw.ns.keycodes[0x5A] = GLFW_KEY_F20;
-    _glfw.ns.keycodes[0x73] = GLFW_KEY_HOME;
-    _glfw.ns.keycodes[0x72] = GLFW_KEY_INSERT;
-    _glfw.ns.keycodes[0x7B] = GLFW_KEY_LEFT;
-    _glfw.ns.keycodes[0x3A] = GLFW_KEY_LEFT_ALT;
-    _glfw.ns.keycodes[0x3B] = GLFW_KEY_LEFT_CONTROL;
-    _glfw.ns.keycodes[0x38] = GLFW_KEY_LEFT_SHIFT;
-    _glfw.ns.keycodes[0x37] = GLFW_KEY_LEFT_SUPER;
-    _glfw.ns.keycodes[0x6E] = GLFW_KEY_MENU;
-    _glfw.ns.keycodes[0x47] = GLFW_KEY_NUM_LOCK;
-    _glfw.ns.keycodes[0x79] = GLFW_KEY_PAGE_DOWN;
-    _glfw.ns.keycodes[0x74] = GLFW_KEY_PAGE_UP;
-    _glfw.ns.keycodes[0x7C] = GLFW_KEY_RIGHT;
-    _glfw.ns.keycodes[0x3D] = GLFW_KEY_RIGHT_ALT;
-    _glfw.ns.keycodes[0x3E] = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.ns.keycodes[0x3C] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.ns.keycodes[0x36] = GLFW_KEY_RIGHT_SUPER;
-    _glfw.ns.keycodes[0x31] = GLFW_KEY_SPACE;
-    _glfw.ns.keycodes[0x30] = GLFW_KEY_TAB;
-    _glfw.ns.keycodes[0x7E] = GLFW_KEY_UP;
-
-    _glfw.ns.keycodes[0x52] = GLFW_KEY_KP_0;
-    _glfw.ns.keycodes[0x53] = GLFW_KEY_KP_1;
-    _glfw.ns.keycodes[0x54] = GLFW_KEY_KP_2;
-    _glfw.ns.keycodes[0x55] = GLFW_KEY_KP_3;
-    _glfw.ns.keycodes[0x56] = GLFW_KEY_KP_4;
-    _glfw.ns.keycodes[0x57] = GLFW_KEY_KP_5;
-    _glfw.ns.keycodes[0x58] = GLFW_KEY_KP_6;
-    _glfw.ns.keycodes[0x59] = GLFW_KEY_KP_7;
-    _glfw.ns.keycodes[0x5B] = GLFW_KEY_KP_8;
-    _glfw.ns.keycodes[0x5C] = GLFW_KEY_KP_9;
-    _glfw.ns.keycodes[0x45] = GLFW_KEY_KP_ADD;
-    _glfw.ns.keycodes[0x41] = GLFW_KEY_KP_DECIMAL;
-    _glfw.ns.keycodes[0x4B] = GLFW_KEY_KP_DIVIDE;
-    _glfw.ns.keycodes[0x4C] = GLFW_KEY_KP_ENTER;
-    _glfw.ns.keycodes[0x51] = GLFW_KEY_KP_EQUAL;
-    _glfw.ns.keycodes[0x43] = GLFW_KEY_KP_MULTIPLY;
-    _glfw.ns.keycodes[0x4E] = GLFW_KEY_KP_SUBTRACT;
-
-    for (scancode = 0;  scancode < 256;  scancode++)
-    {
-        // Store the reverse translation for faster key name lookup
-        if (_glfw.ns.keycodes[scancode] >= 0)
-            _glfw.ns.scancodes[_glfw.ns.keycodes[scancode]] = scancode;
-    }
-}
-
-// Retrieve Unicode data for the current keyboard layout
-//
-static GLFWbool updateUnicodeDataNS(void)
-{
-    if (_glfw.ns.inputSource)
-    {
-        CFRelease(_glfw.ns.inputSource);
-        _glfw.ns.inputSource = NULL;
-        _glfw.ns.unicodeData = nil;
-    }
-
-    _glfw.ns.inputSource = TISCopyCurrentKeyboardLayoutInputSource();
-    if (!_glfw.ns.inputSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve keyboard layout input source");
-        return GLFW_FALSE;
-    }
-
-    _glfw.ns.unicodeData =
-        TISGetInputSourceProperty(_glfw.ns.inputSource,
-                                  kTISPropertyUnicodeKeyLayoutData);
-    if (!_glfw.ns.unicodeData)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve keyboard layout Unicode data");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Load HIToolbox.framework and the TIS symbols we need from it
-//
-static GLFWbool initializeTIS(void)
-{
-    // This works only because Cocoa has already loaded it properly
-    _glfw.ns.tis.bundle =
-        CFBundleGetBundleWithIdentifier(CFSTR("com.apple.HIToolbox"));
-    if (!_glfw.ns.tis.bundle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to load HIToolbox.framework");
-        return GLFW_FALSE;
-    }
-
-    CFStringRef* kPropertyUnicodeKeyLayoutData =
-        CFBundleGetDataPointerForName(_glfw.ns.tis.bundle,
-                                      CFSTR("kTISPropertyUnicodeKeyLayoutData"));
-    _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("TISCopyCurrentKeyboardLayoutInputSource"));
-    _glfw.ns.tis.GetInputSourceProperty =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("TISGetInputSourceProperty"));
-    _glfw.ns.tis.GetKbdType =
-        CFBundleGetFunctionPointerForName(_glfw.ns.tis.bundle,
-                                          CFSTR("LMGetKbdType"));
-
-    if (!kPropertyUnicodeKeyLayoutData ||
-        !TISCopyCurrentKeyboardLayoutInputSource ||
-        !TISGetInputSourceProperty ||
-        !LMGetKbdType)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to load TIS API symbols");
-        return GLFW_FALSE;
-    }
-
-    _glfw.ns.tis.kPropertyUnicodeKeyLayoutData =
-        *kPropertyUnicodeKeyLayoutData;
-
-    return updateUnicodeDataNS();
-}
-
-@interface GLFWHelper : NSObject
-@end
-
-@implementation GLFWHelper
-
-- (void)selectedKeyboardInputSourceChanged:(NSObject* )object
-{
-    updateUnicodeDataNS();
-}
-
-- (void)doNothing:(id)object
-{
-}
-
-@end // GLFWHelper
-
-@interface GLFWApplicationDelegate : NSObject <NSApplicationDelegate>
-@end
-
-@implementation GLFWApplicationDelegate
-
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
-{
-    _GLFWwindow* window;
-
-    for (window = _glfw.windowListHead;  window;  window = window->next)
-        _glfwInputWindowCloseRequest(window);
-
-    return NSTerminateCancel;
-}
-
-- (void)applicationDidChangeScreenParameters:(NSNotification *) notification
-{
-    _GLFWwindow* window;
-
-    for (window = _glfw.windowListHead;  window;  window = window->next)
-    {
-        if (window->context.client != GLFW_NO_API)
-            [window->context.nsgl.object update];
-    }
-
-    _glfwPollMonitorsNS();
-}
-
-- (void)applicationWillFinishLaunching:(NSNotification *)notification
-{
-    if (_glfw.hints.init.ns.menubar)
-    {
-        // In case we are unbundled, make us a proper UI application
-        [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
-
-        // Menu bar setup must go between sharedApplication and finishLaunching
-        // in order to properly emulate the behavior of NSApplicationMain
-
-        if ([[NSBundle mainBundle] pathForResource:@"MainMenu" ofType:@"nib"])
-        {
-            [[NSBundle mainBundle] loadNibNamed:@"MainMenu"
-                                          owner:NSApp
-                                topLevelObjects:&_glfw.ns.nibObjects];
-        }
-        else
-            createMenuBar();
-    }
-}
-
-- (void)applicationDidFinishLaunching:(NSNotification *)notification
-{
-    _glfwPlatformPostEmptyEvent();
-    [NSApp stop:nil];
-}
-
-- (void)applicationDidHide:(NSNotification *)notification
-{
-    int i;
-
-    for (i = 0;  i < _glfw.monitorCount;  i++)
-        _glfwRestoreVideoModeNS(_glfw.monitors[i]);
-}
-
-@end // GLFWApplicationDelegate
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void* _glfwLoadLocalVulkanLoaderNS(void)
-{
-    CFBundleRef bundle = CFBundleGetMainBundle();
-    if (!bundle)
-        return NULL;
-
-    CFURLRef url =
-        CFBundleCopyAuxiliaryExecutableURL(bundle, CFSTR("libvulkan.1.dylib"));
-    if (!url)
-        return NULL;
-
-    char path[PATH_MAX];
-    void* handle = NULL;
-
-    if (CFURLGetFileSystemRepresentation(url, true, (UInt8*) path, sizeof(path) - 1))
-        handle = _glfw_dlopen(path);
-
-    CFRelease(url);
-    return handle;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    @autoreleasepool {
-
-    _glfw.ns.helper = [[GLFWHelper alloc] init];
-
-    [NSThread detachNewThreadSelector:@selector(doNothing:)
-                             toTarget:_glfw.ns.helper
-                           withObject:nil];
-
-    [NSApplication sharedApplication];
-
-    _glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
-    if (_glfw.ns.delegate == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create application delegate");
-        return GLFW_FALSE;
-    }
-
-    [NSApp setDelegate:_glfw.ns.delegate];
-
-    NSEvent* (^block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
-    {
-        if ([event modifierFlags] & NSEventModifierFlagCommand)
-            [[NSApp keyWindow] sendEvent:event];
-
-        return event;
-    };
-
-    _glfw.ns.keyUpMonitor =
-        [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyUp
-                                              handler:block];
-
-    if (_glfw.hints.init.ns.chdir)
-        changeToResourcesDirectory();
-
-    // Press and Hold prevents some keys from emitting repeated characters
-    NSDictionary* defaults = @{@"ApplePressAndHoldEnabled":@NO};
-    [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
-
-    [[NSNotificationCenter defaultCenter]
-        addObserver:_glfw.ns.helper
-           selector:@selector(selectedKeyboardInputSourceChanged:)
-               name:NSTextInputContextKeyboardSelectionDidChangeNotification
-             object:nil];
-
-    createKeyTables();
-
-    _glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
-    if (!_glfw.ns.eventSource)
-        return GLFW_FALSE;
-
-    CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
-
-    if (!initializeTIS())
-        return GLFW_FALSE;
-
-    _glfwInitTimerNS();
-
-    _glfwPollMonitorsNS();
-
-    if (![[NSRunningApplication currentApplication] isFinishedLaunching])
-        [NSApp run];
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformTerminate(void)
-{
-    @autoreleasepool {
-
-    if (_glfw.ns.inputSource)
-    {
-        CFRelease(_glfw.ns.inputSource);
-        _glfw.ns.inputSource = NULL;
-        _glfw.ns.unicodeData = nil;
-    }
-
-    if (_glfw.ns.eventSource)
-    {
-        CFRelease(_glfw.ns.eventSource);
-        _glfw.ns.eventSource = NULL;
-    }
-
-    if (_glfw.ns.delegate)
-    {
-        [NSApp setDelegate:nil];
-        [_glfw.ns.delegate release];
-        _glfw.ns.delegate = nil;
-    }
-
-    if (_glfw.ns.helper)
-    {
-        [[NSNotificationCenter defaultCenter]
-            removeObserver:_glfw.ns.helper
-                      name:NSTextInputContextKeyboardSelectionDidChangeNotification
-                    object:nil];
-        [[NSNotificationCenter defaultCenter]
-            removeObserver:_glfw.ns.helper];
-        [_glfw.ns.helper release];
-        _glfw.ns.helper = nil;
-    }
-
-    if (_glfw.ns.keyUpMonitor)
-        [NSEvent removeMonitor:_glfw.ns.keyUpMonitor];
-
-    free(_glfw.ns.clipboardString);
-
-    _glfwTerminateNSGL();
-
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Cocoa NSGL EGL OSMesa"
-#if defined(_GLFW_BUILD_DLL)
-        " dynamic"
-#endif
-        ;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_joystick.h b/raylib_pi4_test/external/glfw/src/cocoa_joystick.h
deleted file mode 100644 (file)
index 23d2b86..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-//========================================================================
-// GLFW 3.4 Cocoa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <IOKit/IOKitLib.h>
-#include <IOKit/IOCFPlugIn.h>
-#include <IOKit/hid/IOHIDLib.h>
-#include <IOKit/hid/IOHIDKeys.h>
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickNS ns
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
-
-// Cocoa-specific per-joystick data
-//
-typedef struct _GLFWjoystickNS
-{
-    IOHIDDeviceRef      device;
-    CFMutableArrayRef   axes;
-    CFMutableArrayRef   buttons;
-    CFMutableArrayRef   hats;
-} _GLFWjoystickNS;
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_joystick.m b/raylib_pi4_test/external/glfw/src/cocoa_joystick.m
deleted file mode 100644 (file)
index 4a64fb0..0000000
+++ /dev/null
@@ -1,483 +0,0 @@
-//========================================================================
-// GLFW 3.4 Cocoa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <ctype.h>
-#include <string.h>
-
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
-
-
-// Joystick element information
-//
-typedef struct _GLFWjoyelementNS
-{
-    IOHIDElementRef native;
-    uint32_t        usage;
-    int             index;
-    long            minimum;
-    long            maximum;
-
-} _GLFWjoyelementNS;
-
-
-// Returns the value of the specified element of the specified joystick
-//
-static long getElementValue(_GLFWjoystick* js, _GLFWjoyelementNS* element)
-{
-    IOHIDValueRef valueRef;
-    long value = 0;
-
-    if (js->ns.device)
-    {
-        if (IOHIDDeviceGetValue(js->ns.device,
-                                element->native,
-                                &valueRef) == kIOReturnSuccess)
-        {
-            value = IOHIDValueGetIntegerValue(valueRef);
-        }
-    }
-
-    return value;
-}
-
-// Comparison function for matching the SDL element order
-//
-static CFComparisonResult compareElements(const void* fp,
-                                          const void* sp,
-                                          void* user)
-{
-    const _GLFWjoyelementNS* fe = fp;
-    const _GLFWjoyelementNS* se = sp;
-    if (fe->usage < se->usage)
-        return kCFCompareLessThan;
-    if (fe->usage > se->usage)
-        return kCFCompareGreaterThan;
-    if (fe->index < se->index)
-        return kCFCompareLessThan;
-    if (fe->index > se->index)
-        return kCFCompareGreaterThan;
-    return kCFCompareEqualTo;
-}
-
-// Removes the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    int i;
-
-    if (!js->present)
-        return;
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.axes);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.axes, i));
-    CFRelease(js->ns.axes);
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.buttons);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.buttons, i));
-    CFRelease(js->ns.buttons);
-
-    for (i = 0;  i < CFArrayGetCount(js->ns.hats);  i++)
-        free((void*) CFArrayGetValueAtIndex(js->ns.hats, i));
-    CFRelease(js->ns.hats);
-
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// Callback for user-initiated joystick addition
-//
-static void matchCallback(void* context,
-                          IOReturn result,
-                          void* sender,
-                          IOHIDDeviceRef device)
-{
-    int jid;
-    char name[256];
-    char guid[33];
-    CFIndex i;
-    CFTypeRef property;
-    uint32_t vendor = 0, product = 0, version = 0;
-    _GLFWjoystick* js;
-    CFMutableArrayRef axes, buttons, hats;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (_glfw.joysticks[jid].ns.device == device)
-            return;
-    }
-
-    axes    = CFArrayCreateMutable(NULL, 0, NULL);
-    buttons = CFArrayCreateMutable(NULL, 0, NULL);
-    hats    = CFArrayCreateMutable(NULL, 0, NULL);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
-    if (property)
-    {
-        CFStringGetCString(property,
-                           name,
-                           sizeof(name),
-                           kCFStringEncodingUTF8);
-    }
-    else
-        strncpy(name, "Unknown", sizeof(name));
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &vendor);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &product);
-
-    property = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVersionNumberKey));
-    if (property)
-        CFNumberGetValue(property, kCFNumberSInt32Type, &version);
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (vendor && product)
-    {
-        sprintf(guid, "03000000%02x%02x0000%02x%02x0000%02x%02x0000",
-                (uint8_t) vendor, (uint8_t) (vendor >> 8),
-                (uint8_t) product, (uint8_t) (product >> 8),
-                (uint8_t) version, (uint8_t) (version >> 8));
-    }
-    else
-    {
-        sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    CFArrayRef elements =
-        IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
-
-    for (i = 0;  i < CFArrayGetCount(elements);  i++)
-    {
-        IOHIDElementRef native = (IOHIDElementRef)
-            CFArrayGetValueAtIndex(elements, i);
-        if (CFGetTypeID(native) != IOHIDElementGetTypeID())
-            continue;
-
-        const IOHIDElementType type = IOHIDElementGetType(native);
-        if ((type != kIOHIDElementTypeInput_Axis) &&
-            (type != kIOHIDElementTypeInput_Button) &&
-            (type != kIOHIDElementTypeInput_Misc))
-        {
-            continue;
-        }
-
-        CFMutableArrayRef target = NULL;
-
-        const uint32_t usage = IOHIDElementGetUsage(native);
-        const uint32_t page = IOHIDElementGetUsagePage(native);
-        if (page == kHIDPage_GenericDesktop)
-        {
-            switch (usage)
-            {
-                case kHIDUsage_GD_X:
-                case kHIDUsage_GD_Y:
-                case kHIDUsage_GD_Z:
-                case kHIDUsage_GD_Rx:
-                case kHIDUsage_GD_Ry:
-                case kHIDUsage_GD_Rz:
-                case kHIDUsage_GD_Slider:
-                case kHIDUsage_GD_Dial:
-                case kHIDUsage_GD_Wheel:
-                    target = axes;
-                    break;
-                case kHIDUsage_GD_Hatswitch:
-                    target = hats;
-                    break;
-                case kHIDUsage_GD_DPadUp:
-                case kHIDUsage_GD_DPadRight:
-                case kHIDUsage_GD_DPadDown:
-                case kHIDUsage_GD_DPadLeft:
-                case kHIDUsage_GD_SystemMainMenu:
-                case kHIDUsage_GD_Select:
-                case kHIDUsage_GD_Start:
-                    target = buttons;
-                    break;
-            }
-        }
-        else if (page == kHIDPage_Simulation)
-        {
-            switch (usage)
-            {
-                case kHIDUsage_Sim_Accelerator:
-                case kHIDUsage_Sim_Brake:
-                case kHIDUsage_Sim_Throttle:
-                case kHIDUsage_Sim_Rudder:
-                case kHIDUsage_Sim_Steering:
-                    target = axes;
-                    break;
-            }
-        }
-        else if (page == kHIDPage_Button || page == kHIDPage_Consumer)
-            target = buttons;
-
-        if (target)
-        {
-            _GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS));
-            element->native  = native;
-            element->usage   = usage;
-            element->index   = (int) CFArrayGetCount(target);
-            element->minimum = IOHIDElementGetLogicalMin(native);
-            element->maximum = IOHIDElementGetLogicalMax(native);
-            CFArrayAppendValue(target, element);
-        }
-    }
-
-    CFRelease(elements);
-
-    CFArraySortValues(axes, CFRangeMake(0, CFArrayGetCount(axes)),
-                      compareElements, NULL);
-    CFArraySortValues(buttons, CFRangeMake(0, CFArrayGetCount(buttons)),
-                      compareElements, NULL);
-    CFArraySortValues(hats, CFRangeMake(0, CFArrayGetCount(hats)),
-                      compareElements, NULL);
-
-    js = _glfwAllocJoystick(name, guid,
-                            (int) CFArrayGetCount(axes),
-                            (int) CFArrayGetCount(buttons),
-                            (int) CFArrayGetCount(hats));
-
-    js->ns.device  = device;
-    js->ns.axes    = axes;
-    js->ns.buttons = buttons;
-    js->ns.hats    = hats;
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-}
-
-// Callback for user-initiated joystick removal
-//
-static void removeCallback(void* context,
-                           IOReturn result,
-                           void* sender,
-                           IOHIDDeviceRef device)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (_glfw.joysticks[jid].ns.device == device)
-        {
-            closeJoystick(_glfw.joysticks + jid);
-            break;
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    CFMutableArrayRef matching;
-    const long usages[] =
-    {
-        kHIDUsage_GD_Joystick,
-        kHIDUsage_GD_GamePad,
-        kHIDUsage_GD_MultiAxisController
-    };
-
-    _glfw.ns.hidManager = IOHIDManagerCreate(kCFAllocatorDefault,
-                                             kIOHIDOptionsTypeNone);
-
-    matching = CFArrayCreateMutable(kCFAllocatorDefault,
-                                    0,
-                                    &kCFTypeArrayCallBacks);
-    if (!matching)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create array");
-        return GLFW_FALSE;
-    }
-
-    for (size_t i = 0;  i < sizeof(usages) / sizeof(long);  i++)
-    {
-        const long page = kHIDPage_GenericDesktop;
-
-        CFMutableDictionaryRef dict =
-            CFDictionaryCreateMutable(kCFAllocatorDefault,
-                                      0,
-                                      &kCFTypeDictionaryKeyCallBacks,
-                                      &kCFTypeDictionaryValueCallBacks);
-        if (!dict)
-            continue;
-
-        CFNumberRef pageRef = CFNumberCreate(kCFAllocatorDefault,
-                                             kCFNumberLongType,
-                                             &page);
-        CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault,
-                                              kCFNumberLongType,
-                                              &usages[i]);
-        if (pageRef && usageRef)
-        {
-            CFDictionarySetValue(dict,
-                                 CFSTR(kIOHIDDeviceUsagePageKey),
-                                 pageRef);
-            CFDictionarySetValue(dict,
-                                 CFSTR(kIOHIDDeviceUsageKey),
-                                 usageRef);
-            CFArrayAppendValue(matching, dict);
-        }
-
-        if (pageRef)
-            CFRelease(pageRef);
-        if (usageRef)
-            CFRelease(usageRef);
-
-        CFRelease(dict);
-    }
-
-    IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns.hidManager, matching);
-    CFRelease(matching);
-
-    IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns.hidManager,
-                                               &matchCallback, NULL);
-    IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns.hidManager,
-                                              &removeCallback, NULL);
-    IOHIDManagerScheduleWithRunLoop(_glfw.ns.hidManager,
-                                    CFRunLoopGetMain(),
-                                    kCFRunLoopDefaultMode);
-    IOHIDManagerOpen(_glfw.ns.hidManager, kIOHIDOptionsTypeNone);
-
-    // Execute the run loop once in order to register any initially-attached
-    // joysticks
-    CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-        closeJoystick(_glfw.joysticks + jid);
-
-    if (_glfw.ns.hidManager)
-    {
-        CFRelease(_glfw.ns.hidManager);
-        _glfw.ns.hidManager = NULL;
-    }
-}
-
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    if (mode & _GLFW_POLL_AXES)
-    {
-        CFIndex i;
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.axes);  i++)
-        {
-            _GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.axes, i);
-
-            const long raw = getElementValue(js, axis);
-            // Perform auto calibration
-            if (raw < axis->minimum)
-                axis->minimum = raw;
-            if (raw > axis->maximum)
-                axis->maximum = raw;
-
-            const long size = axis->maximum - axis->minimum;
-            if (size == 0)
-                _glfwInputJoystickAxis(js, (int) i, 0.f);
-            else
-            {
-                const float value = (2.f * (raw - axis->minimum) / size) - 1.f;
-                _glfwInputJoystickAxis(js, (int) i, value);
-            }
-        }
-    }
-
-    if (mode & _GLFW_POLL_BUTTONS)
-    {
-        CFIndex i;
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.buttons);  i++)
-        {
-            _GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.buttons, i);
-            const char value = getElementValue(js, button) - button->minimum;
-            const int state = (value > 0) ? GLFW_PRESS : GLFW_RELEASE;
-            _glfwInputJoystickButton(js, (int) i, state);
-        }
-
-        for (i = 0;  i < CFArrayGetCount(js->ns.hats);  i++)
-        {
-            const int states[9] =
-            {
-                GLFW_HAT_UP,
-                GLFW_HAT_RIGHT_UP,
-                GLFW_HAT_RIGHT,
-                GLFW_HAT_RIGHT_DOWN,
-                GLFW_HAT_DOWN,
-                GLFW_HAT_LEFT_DOWN,
-                GLFW_HAT_LEFT,
-                GLFW_HAT_LEFT_UP,
-                GLFW_HAT_CENTERED
-            };
-
-            _GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
-                CFArrayGetValueAtIndex(js->ns.hats, i);
-            long state = getElementValue(js, hat) - hat->minimum;
-            if (state < 0 || state > 8)
-                state = 8;
-
-            _glfwInputJoystickHat(js, (int) i, states[state]);
-        }
-    }
-
-    return js->present;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-    if ((strncmp(guid + 4, "000000000000", 12) == 0) &&
-        (strncmp(guid + 20, "000000000000", 12) == 0))
-    {
-        char original[33];
-        strncpy(original, guid, sizeof(original) - 1);
-        sprintf(guid, "03000000%.4s0000%.4s000000000000",
-                original, original + 16);
-    }
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_monitor.m b/raylib_pi4_test/external/glfw/src/cocoa_monitor.m
deleted file mode 100644 (file)
index 2bb8373..0000000
+++ /dev/null
@@ -1,618 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <limits.h>
-#include <math.h>
-
-#include <IOKit/graphics/IOGraphicsLib.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-
-// Get the name of the specified display, or NULL
-//
-static char* getDisplayName(CGDirectDisplayID displayID)
-{
-    io_iterator_t it;
-    io_service_t service;
-    CFDictionaryRef info;
-
-    if (IOServiceGetMatchingServices(kIOMasterPortDefault,
-                                     IOServiceMatching("IODisplayConnect"),
-                                     &it) != 0)
-    {
-        // This may happen if a desktop Mac is running headless
-        return NULL;
-    }
-
-    while ((service = IOIteratorNext(it)) != 0)
-    {
-        info = IODisplayCreateInfoDictionary(service,
-                                             kIODisplayOnlyPreferredName);
-
-        CFNumberRef vendorIDRef =
-            CFDictionaryGetValue(info, CFSTR(kDisplayVendorID));
-        CFNumberRef productIDRef =
-            CFDictionaryGetValue(info, CFSTR(kDisplayProductID));
-        if (!vendorIDRef || !productIDRef)
-        {
-            CFRelease(info);
-            continue;
-        }
-
-        unsigned int vendorID, productID;
-        CFNumberGetValue(vendorIDRef, kCFNumberIntType, &vendorID);
-        CFNumberGetValue(productIDRef, kCFNumberIntType, &productID);
-
-        if (CGDisplayVendorNumber(displayID) == vendorID &&
-            CGDisplayModelNumber(displayID) == productID)
-        {
-            // Info dictionary is used and freed below
-            break;
-        }
-
-        CFRelease(info);
-    }
-
-    IOObjectRelease(it);
-
-    if (!service)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to find service port for display");
-        return NULL;
-    }
-
-    CFDictionaryRef names =
-        CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
-
-    CFStringRef nameRef;
-
-    if (!names || !CFDictionaryGetValueIfPresent(names, CFSTR("en_US"),
-                                                 (const void**) &nameRef))
-    {
-        // This may happen if a desktop Mac is running headless
-        CFRelease(info);
-        return NULL;
-    }
-
-    const CFIndex size =
-        CFStringGetMaximumSizeForEncoding(CFStringGetLength(nameRef),
-                                          kCFStringEncodingUTF8);
-    char* name = calloc(size + 1, 1);
-    CFStringGetCString(nameRef, name, size, kCFStringEncodingUTF8);
-
-    CFRelease(info);
-    return name;
-}
-
-// Check whether the display mode should be included in enumeration
-//
-static GLFWbool modeIsGood(CGDisplayModeRef mode)
-{
-    uint32_t flags = CGDisplayModeGetIOFlags(mode);
-
-    if (!(flags & kDisplayModeValidFlag) || !(flags & kDisplayModeSafeFlag))
-        return GLFW_FALSE;
-    if (flags & kDisplayModeInterlacedFlag)
-        return GLFW_FALSE;
-    if (flags & kDisplayModeStretchedFlag)
-        return GLFW_FALSE;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
-    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) &&
-        CFStringCompare(format, CFSTR(IO32BitDirectPixels), 0))
-    {
-        CFRelease(format);
-        return GLFW_FALSE;
-    }
-
-    CFRelease(format);
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    return GLFW_TRUE;
-}
-
-// Convert Core Graphics display mode to GLFW video mode
-//
-static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
-                                            double fallbackRefreshRate)
-{
-    GLFWvidmode result;
-    result.width = (int) CGDisplayModeGetWidth(mode);
-    result.height = (int) CGDisplayModeGetHeight(mode);
-    result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
-
-    if (result.refreshRate == 0)
-        result.refreshRate = (int) round(fallbackRefreshRate);
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFStringRef format = CGDisplayModeCopyPixelEncoding(mode);
-    if (CFStringCompare(format, CFSTR(IO16BitDirectPixels), 0) == 0)
-    {
-        result.redBits = 5;
-        result.greenBits = 5;
-        result.blueBits = 5;
-    }
-    else
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    {
-        result.redBits = 8;
-        result.greenBits = 8;
-        result.blueBits = 8;
-    }
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
-    CFRelease(format);
-#endif /* MAC_OS_X_VERSION_MAX_ALLOWED */
-    return result;
-}
-
-// Starts reservation for display fading
-//
-static CGDisplayFadeReservationToken beginFadeReservation(void)
-{
-    CGDisplayFadeReservationToken token = kCGDisplayFadeReservationInvalidToken;
-
-    if (CGAcquireDisplayFadeReservation(5, &token) == kCGErrorSuccess)
-    {
-        CGDisplayFade(token, 0.3,
-                      kCGDisplayBlendNormal,
-                      kCGDisplayBlendSolidColor,
-                      0.0, 0.0, 0.0,
-                      TRUE);
-    }
-
-    return token;
-}
-
-// Ends reservation for display fading
-//
-static void endFadeReservation(CGDisplayFadeReservationToken token)
-{
-    if (token != kCGDisplayFadeReservationInvalidToken)
-    {
-        CGDisplayFade(token, 0.5,
-                      kCGDisplayBlendSolidColor,
-                      kCGDisplayBlendNormal,
-                      0.0, 0.0, 0.0,
-                      FALSE);
-        CGReleaseDisplayFadeReservation(token);
-    }
-}
-
-// Finds and caches the NSScreen corresponding to the specified monitor
-//
-static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
-{
-    if (monitor->ns.screen)
-        return GLFW_TRUE;
-
-    for (NSScreen* screen in [NSScreen screens])
-    {
-        NSNumber* displayID = [screen deviceDescription][@"NSScreenNumber"];
-
-        // HACK: Compare unit numbers instead of display IDs to work around
-        //       display replacement on machines with automatic graphics
-        //       switching
-        if (monitor->ns.unitNumber == CGDisplayUnitNumber([displayID unsignedIntValue]))
-        {
-            monitor->ns.screen = screen;
-            return GLFW_TRUE;
-        }
-    }
-
-    _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to find a screen for monitor");
-    return GLFW_FALSE;
-}
-
-// Returns the display refresh rate queried from the I/O registry
-//
-static double getFallbackRefreshRate(CGDirectDisplayID displayID)
-{
-    double refreshRate = 60.0;
-
-    io_iterator_t it;
-    io_service_t service;
-
-    if (IOServiceGetMatchingServices(kIOMasterPortDefault,
-                                     IOServiceMatching("IOFramebuffer"),
-                                     &it) != 0)
-    {
-        return refreshRate;
-    }
-
-    while ((service = IOIteratorNext(it)) != 0)
-    {
-        const CFNumberRef indexRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFramebufferOpenGLIndex"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-        if (!indexRef)
-            continue;
-
-        uint32_t index = 0;
-        CFNumberGetValue(indexRef, kCFNumberIntType, &index);
-        CFRelease(indexRef);
-
-        if (CGOpenGLDisplayMaskToDisplayID(1 << index) != displayID)
-            continue;
-
-        const CFNumberRef clockRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFBCurrentPixelClock"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-        const CFNumberRef countRef =
-            IORegistryEntryCreateCFProperty(service,
-                                            CFSTR("IOFBCurrentPixelCount"),
-                                            kCFAllocatorDefault,
-                                            kNilOptions);
-
-        uint32_t clock = 0, count = 0;
-
-        if (clockRef)
-        {
-            CFNumberGetValue(clockRef, kCFNumberIntType, &clock);
-            CFRelease(clockRef);
-        }
-
-        if (countRef)
-        {
-            CFNumberGetValue(countRef, kCFNumberIntType, &count);
-            CFRelease(countRef);
-        }
-
-        if (clock > 0 && count > 0)
-            refreshRate = clock / (double) count;
-
-        break;
-    }
-
-    IOObjectRelease(it);
-    return refreshRate;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsNS(void)
-{
-    uint32_t displayCount;
-    CGGetOnlineDisplayList(0, NULL, &displayCount);
-    CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
-    CGGetOnlineDisplayList(displayCount, displays, &displayCount);
-
-    for (int i = 0;  i < _glfw.monitorCount;  i++)
-        _glfw.monitors[i]->ns.screen = nil;
-
-    _GLFWmonitor** disconnected = NULL;
-    uint32_t disconnectedCount = _glfw.monitorCount;
-    if (disconnectedCount)
-    {
-        disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-        memcpy(disconnected,
-               _glfw.monitors,
-               _glfw.monitorCount * sizeof(_GLFWmonitor*));
-    }
-
-    for (uint32_t i = 0;  i < displayCount;  i++)
-    {
-        if (CGDisplayIsAsleep(displays[i]))
-            continue;
-
-        // HACK: Compare unit numbers instead of display IDs to work around
-        //       display replacement on machines with automatic graphics
-        //       switching
-        const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
-        for (uint32_t j = 0;  j < disconnectedCount;  j++)
-        {
-            if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
-            {
-                disconnected[j] = NULL;
-                break;
-            }
-        }
-
-        const CGSize size = CGDisplayScreenSize(displays[i]);
-        char* name = getDisplayName(displays[i]);
-        if (!name)
-            name = _glfw_strdup("Unknown");
-
-        _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
-        monitor->ns.displayID  = displays[i];
-        monitor->ns.unitNumber = unitNumber;
-
-        free(name);
-
-        CGDisplayModeRef mode = CGDisplayCopyDisplayMode(displays[i]);
-        if (CGDisplayModeGetRefreshRate(mode) == 0.0)
-            monitor->ns.fallbackRefreshRate = getFallbackRefreshRate(displays[i]);
-        CGDisplayModeRelease(mode);
-
-        _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
-    }
-
-    for (uint32_t i = 0;  i < disconnectedCount;  i++)
-    {
-        if (disconnected[i])
-            _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-    }
-
-    free(disconnected);
-    free(displays);
-}
-
-// Change the current video mode
-//
-void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    GLFWvidmode current;
-    _glfwPlatformGetVideoMode(monitor, &current);
-
-    const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
-    if (_glfwCompareVideoModes(&current, best) == 0)
-        return;
-
-    CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
-    const CFIndex count = CFArrayGetCount(modes);
-    CGDisplayModeRef native = NULL;
-
-    for (CFIndex i = 0;  i < count;  i++)
-    {
-        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-        if (!modeIsGood(dm))
-            continue;
-
-        const GLFWvidmode mode =
-            vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
-        if (_glfwCompareVideoModes(best, &mode) == 0)
-        {
-            native = dm;
-            break;
-        }
-    }
-
-    if (native)
-    {
-        if (monitor->ns.previousMode == NULL)
-            monitor->ns.previousMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
-
-        CGDisplayFadeReservationToken token = beginFadeReservation();
-        CGDisplaySetDisplayMode(monitor->ns.displayID, native, NULL);
-        endFadeReservation(token);
-    }
-
-    CFRelease(modes);
-}
-
-// Restore the previously saved (original) video mode
-//
-void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
-{
-    if (monitor->ns.previousMode)
-    {
-        CGDisplayFadeReservationToken token = beginFadeReservation();
-        CGDisplaySetDisplayMode(monitor->ns.displayID,
-                                monitor->ns.previousMode, NULL);
-        endFadeReservation(token);
-
-        CGDisplayModeRelease(monitor->ns.previousMode);
-        monitor->ns.previousMode = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    @autoreleasepool {
-
-    const CGRect bounds = CGDisplayBounds(monitor->ns.displayID);
-
-    if (xpos)
-        *xpos = (int) bounds.origin.x;
-    if (ypos)
-        *ypos = (int) bounds.origin.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    @autoreleasepool {
-
-    if (!refreshMonitorScreen(monitor))
-        return;
-
-    const NSRect points = [monitor->ns.screen frame];
-    const NSRect pixels = [monitor->ns.screen convertRectToBacking:points];
-
-    if (xscale)
-        *xscale = (float) (pixels.size.width / points.size.width);
-    if (yscale)
-        *yscale = (float) (pixels.size.height / points.size.height);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    @autoreleasepool {
-
-    if (!refreshMonitorScreen(monitor))
-        return;
-
-    const NSRect frameRect = [monitor->ns.screen visibleFrame];
-
-    if (xpos)
-        *xpos = frameRect.origin.x;
-    if (ypos)
-        *ypos = _glfwTransformYNS(frameRect.origin.y + frameRect.size.height - 1);
-    if (width)
-        *width = frameRect.size.width;
-    if (height)
-        *height = frameRect.size.height;
-
-    } // autoreleasepool
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    @autoreleasepool {
-
-    *count = 0;
-
-    CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
-    const CFIndex found = CFArrayGetCount(modes);
-    GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
-
-    for (CFIndex i = 0;  i < found;  i++)
-    {
-        CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-        if (!modeIsGood(dm))
-            continue;
-
-        const GLFWvidmode mode =
-            vidmodeFromCGDisplayMode(dm, monitor->ns.fallbackRefreshRate);
-        CFIndex j;
-
-        for (j = 0;  j < *count;  j++)
-        {
-            if (_glfwCompareVideoModes(result + j, &mode) == 0)
-                break;
-        }
-
-        // Skip duplicate modes
-        if (i < *count)
-            continue;
-
-        (*count)++;
-        result[*count - 1] = mode;
-    }
-
-    CFRelease(modes);
-    return result;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
-{
-    @autoreleasepool {
-
-    CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
-    *mode = vidmodeFromCGDisplayMode(native, monitor->ns.fallbackRefreshRate);
-    CGDisplayModeRelease(native);
-
-    } // autoreleasepool
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    @autoreleasepool {
-
-    uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
-    CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
-
-    CGGetDisplayTransferByTable(monitor->ns.displayID,
-                                size,
-                                values,
-                                values + size,
-                                values + size * 2,
-                                &size);
-
-    _glfwAllocGammaArrays(ramp, size);
-
-    for (uint32_t i = 0; i < size; i++)
-    {
-        ramp->red[i]   = (unsigned short) (values[i] * 65535);
-        ramp->green[i] = (unsigned short) (values[i + size] * 65535);
-        ramp->blue[i]  = (unsigned short) (values[i + size * 2] * 65535);
-    }
-
-    free(values);
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    @autoreleasepool {
-
-    CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
-
-    for (unsigned int i = 0;  i < ramp->size;  i++)
-    {
-        values[i]                  = ramp->red[i] / 65535.f;
-        values[i + ramp->size]     = ramp->green[i] / 65535.f;
-        values[i + ramp->size * 2] = ramp->blue[i] / 65535.f;
-    }
-
-    CGSetDisplayTransferByTable(monitor->ns.displayID,
-                                ramp->size,
-                                values,
-                                values + ramp->size,
-                                values + ramp->size * 2);
-
-    free(values);
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(kCGNullDirectDisplay);
-    return monitor->ns.displayID;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_platform.h b/raylib_pi4_test/external/glfw/src/cocoa_platform.h
deleted file mode 100644 (file)
index 01dcd87..0000000
+++ /dev/null
@@ -1,206 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <stdint.h>
-#include <dlfcn.h>
-
-#include <Carbon/Carbon.h>
-
-// NOTE: All of NSGL was deprecated in the 10.14 SDK
-//       This disables the pointless warnings for every symbol we use
-#define GL_SILENCE_DEPRECATION
-
-#if defined(__OBJC__)
-#import <Cocoa/Cocoa.h>
-#else
-typedef void* id;
-#endif
-
-// NOTE: Many Cocoa enum values have been renamed and we need to build across
-//       SDK versions where one is unavailable or the other deprecated
-//       We use the newer names in code and these macros to handle compatibility
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
- #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
- #define NSEventMaskAny NSAnyEventMask
- #define NSEventMaskKeyUp NSKeyUpMask
- #define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
- #define NSEventModifierFlagCommand NSCommandKeyMask
- #define NSEventModifierFlagControl NSControlKeyMask
- #define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
- #define NSEventModifierFlagOption NSAlternateKeyMask
- #define NSEventModifierFlagShift NSShiftKeyMask
- #define NSEventTypeApplicationDefined NSApplicationDefined
- #define NSWindowStyleMaskBorderless NSBorderlessWindowMask
- #define NSWindowStyleMaskClosable NSClosableWindowMask
- #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
- #define NSWindowStyleMaskResizable NSResizableWindowMask
- #define NSWindowStyleMaskTitled NSTitledWindowMask
-#endif
-
-typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
-typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
-
-typedef struct VkMacOSSurfaceCreateInfoMVK
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkMacOSSurfaceCreateFlagsMVK    flags;
-    const void*                     pView;
-} VkMacOSSurfaceCreateInfoMVK;
-
-typedef struct VkMetalSurfaceCreateInfoEXT
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkMetalSurfaceCreateFlagsEXT    flags;
-    const void*                     pLayer;
-} VkMetalSurfaceCreateInfoEXT;
-
-typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacOSSurfaceCreateInfoMVK*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMetalSurfaceCreateInfoEXT*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-
-#include "posix_thread.h"
-#include "cocoa_joystick.h"
-#include "nsgl_context.h"
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowNS  ns
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE  _GLFWtimerNS   ns
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorNS ns
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorNS  ns
-
-// HIToolbox.framework pointer typedefs
-#define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData
-typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void);
-#define TISCopyCurrentKeyboardLayoutInputSource _glfw.ns.tis.CopyCurrentKeyboardLayoutInputSource
-typedef void* (*PFN_TISGetInputSourceProperty)(TISInputSourceRef,CFStringRef);
-#define TISGetInputSourceProperty _glfw.ns.tis.GetInputSourceProperty
-typedef UInt8 (*PFN_LMGetKbdType)(void);
-#define LMGetKbdType _glfw.ns.tis.GetKbdType
-
-
-// Cocoa-specific per-window data
-//
-typedef struct _GLFWwindowNS
-{
-    id              object;
-    id              delegate;
-    id              view;
-    id              layer;
-
-    GLFWbool        maximized;
-    GLFWbool        occluded;
-    GLFWbool        retina;
-
-    // Cached window properties to filter out duplicate events
-    int             width, height;
-    int             fbWidth, fbHeight;
-    float           xscale, yscale;
-
-    // The total sum of the distances the cursor has been warped
-    // since the last cursor motion event was processed
-    // This is kept to counteract Cocoa doing the same internally
-    double          cursorWarpDeltaX, cursorWarpDeltaY;
-
-} _GLFWwindowNS;
-
-// Cocoa-specific global data
-//
-typedef struct _GLFWlibraryNS
-{
-    CGEventSourceRef    eventSource;
-    id                  delegate;
-    GLFWbool            cursorHidden;
-    TISInputSourceRef   inputSource;
-    IOHIDManagerRef     hidManager;
-    id                  unicodeData;
-    id                  helper;
-    id                  keyUpMonitor;
-    id                  nibObjects;
-
-    char                keynames[GLFW_KEY_LAST + 1][17];
-    short int           keycodes[256];
-    short int           scancodes[GLFW_KEY_LAST + 1];
-    char*               clipboardString;
-    CGPoint             cascadePoint;
-    // Where to place the cursor when re-enabled
-    double              restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*        disabledCursorWindow;
-
-    struct {
-        CFBundleRef     bundle;
-        PFN_TISCopyCurrentKeyboardLayoutInputSource CopyCurrentKeyboardLayoutInputSource;
-        PFN_TISGetInputSourceProperty GetInputSourceProperty;
-        PFN_LMGetKbdType GetKbdType;
-        CFStringRef     kPropertyUnicodeKeyLayoutData;
-    } tis;
-
-} _GLFWlibraryNS;
-
-// Cocoa-specific per-monitor data
-//
-typedef struct _GLFWmonitorNS
-{
-    CGDirectDisplayID   displayID;
-    CGDisplayModeRef    previousMode;
-    uint32_t            unitNumber;
-    id                  screen;
-    double              fallbackRefreshRate;
-
-} _GLFWmonitorNS;
-
-// Cocoa-specific per-cursor data
-//
-typedef struct _GLFWcursorNS
-{
-    id              object;
-
-} _GLFWcursorNS;
-
-// Cocoa-specific global timer data
-//
-typedef struct _GLFWtimerNS
-{
-    uint64_t        frequency;
-
-} _GLFWtimerNS;
-
-
-void _glfwInitTimerNS(void);
-
-void _glfwPollMonitorsNS(void);
-void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
-
-float _glfwTransformYNS(float y);
-
-void* _glfwLoadLocalVulkanLoaderNS(void);
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_time.c b/raylib_pi4_test/external/glfw/src/cocoa_time.c
deleted file mode 100644 (file)
index 4bf646c..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <mach/mach_time.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerNS(void)
-{
-    mach_timebase_info_data_t info;
-    mach_timebase_info(&info);
-
-    _glfw.timer.ns.frequency = (info.denom * 1e9) / info.numer;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-    return mach_absolute_time();
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.ns.frequency;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/cocoa_window.m b/raylib_pi4_test/external/glfw/src/cocoa_window.m
deleted file mode 100644 (file)
index 81b22e2..0000000
+++ /dev/null
@@ -1,1905 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <float.h>
-#include <string.h>
-
-// Returns the style mask corresponding to the window settings
-//
-static NSUInteger getStyleMask(_GLFWwindow* window)
-{
-    NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
-
-    if (window->monitor || !window->decorated)
-        styleMask |= NSWindowStyleMaskBorderless;
-    else
-    {
-        styleMask |= NSWindowStyleMaskTitled |
-                     NSWindowStyleMaskClosable;
-
-        if (window->resizable)
-            styleMask |= NSWindowStyleMaskResizable;
-    }
-
-    return styleMask;
-}
-
-// Returns whether the cursor is in the content area of the specified window
-//
-static GLFWbool cursorInContentArea(_GLFWwindow* window)
-{
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-    return [window->ns.view mouse:pos inRect:[window->ns.view frame]];
-}
-
-// Hides the cursor if not already hidden
-//
-static void hideCursor(_GLFWwindow* window)
-{
-    if (!_glfw.ns.cursorHidden)
-    {
-        [NSCursor hide];
-        _glfw.ns.cursorHidden = GLFW_TRUE;
-    }
-}
-
-// Shows the cursor if not already shown
-//
-static void showCursor(_GLFWwindow* window)
-{
-    if (_glfw.ns.cursorHidden)
-    {
-        [NSCursor unhide];
-        _glfw.ns.cursorHidden = GLFW_FALSE;
-    }
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        showCursor(window);
-
-        if (window->cursor)
-            [(NSCursor*) window->cursor->ns.object set];
-        else
-            [[NSCursor arrowCursor] set];
-    }
-    else
-        hideCursor(window);
-}
-
-// Apply chosen cursor mode to a focused window
-//
-static void updateCursorMode(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        _glfw.ns.disabledCursorWindow = window;
-        _glfwPlatformGetCursorPos(window,
-                                  &_glfw.ns.restoreCursorPosX,
-                                  &_glfw.ns.restoreCursorPosY);
-        _glfwCenterCursorInContentArea(window);
-        CGAssociateMouseAndMouseCursorPosition(false);
-    }
-    else if (_glfw.ns.disabledCursorWindow == window)
-    {
-        _glfw.ns.disabledCursorWindow = NULL;
-        CGAssociateMouseAndMouseCursorPosition(true);
-        _glfwPlatformSetCursorPos(window,
-                                  _glfw.ns.restoreCursorPosX,
-                                  _glfw.ns.restoreCursorPosY);
-    }
-
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    _glfwSetVideoModeNS(window->monitor, &window->videoMode);
-    const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
-    const NSRect frame = NSMakeRect(bounds.origin.x,
-                                    _glfwTransformYNS(bounds.origin.y + bounds.size.height - 1),
-                                    bounds.size.width,
-                                    bounds.size.height);
-
-    [window->ns.object setFrame:frame display:YES];
-
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeNS(window->monitor);
-}
-
-// Translates macOS key modifiers into GLFW ones
-//
-static int translateFlags(NSUInteger flags)
-{
-    int mods = 0;
-
-    if (flags & NSEventModifierFlagShift)
-        mods |= GLFW_MOD_SHIFT;
-    if (flags & NSEventModifierFlagControl)
-        mods |= GLFW_MOD_CONTROL;
-    if (flags & NSEventModifierFlagOption)
-        mods |= GLFW_MOD_ALT;
-    if (flags & NSEventModifierFlagCommand)
-        mods |= GLFW_MOD_SUPER;
-    if (flags & NSEventModifierFlagCapsLock)
-        mods |= GLFW_MOD_CAPS_LOCK;
-
-    return mods;
-}
-
-// Translates a macOS keycode to a GLFW keycode
-//
-static int translateKey(unsigned int key)
-{
-    if (key >= sizeof(_glfw.ns.keycodes) / sizeof(_glfw.ns.keycodes[0]))
-        return GLFW_KEY_UNKNOWN;
-
-    return _glfw.ns.keycodes[key];
-}
-
-// Translate a GLFW keycode to a Cocoa modifier flag
-//
-static NSUInteger translateKeyToModifierFlag(int key)
-{
-    switch (key)
-    {
-        case GLFW_KEY_LEFT_SHIFT:
-        case GLFW_KEY_RIGHT_SHIFT:
-            return NSEventModifierFlagShift;
-        case GLFW_KEY_LEFT_CONTROL:
-        case GLFW_KEY_RIGHT_CONTROL:
-            return NSEventModifierFlagControl;
-        case GLFW_KEY_LEFT_ALT:
-        case GLFW_KEY_RIGHT_ALT:
-            return NSEventModifierFlagOption;
-        case GLFW_KEY_LEFT_SUPER:
-        case GLFW_KEY_RIGHT_SUPER:
-            return NSEventModifierFlagCommand;
-        case GLFW_KEY_CAPS_LOCK:
-            return NSEventModifierFlagCapsLock;
-    }
-
-    return 0;
-}
-
-// Defines a constant for empty ranges in NSTextInputClient
-//
-static const NSRange kEmptyRange = { NSNotFound, 0 };
-
-
-//------------------------------------------------------------------------
-// Delegate for window related notifications
-//------------------------------------------------------------------------
-
-@interface GLFWWindowDelegate : NSObject
-{
-    _GLFWwindow* window;
-}
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
-
-@end
-
-@implementation GLFWWindowDelegate
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
-{
-    self = [super init];
-    if (self != nil)
-        window = initWindow;
-
-    return self;
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
-    _glfwInputWindowCloseRequest(window);
-    return NO;
-}
-
-- (void)windowDidResize:(NSNotification *)notification
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    const int maximized = [window->ns.object isZoomed];
-    if (window->ns.maximized != maximized)
-    {
-        window->ns.maximized = maximized;
-        _glfwInputWindowMaximize(window, maximized);
-    }
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (fbRect.size.width != window->ns.fbWidth ||
-        fbRect.size.height != window->ns.fbHeight)
-    {
-        window->ns.fbWidth  = fbRect.size.width;
-        window->ns.fbHeight = fbRect.size.height;
-        _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
-    }
-
-    if (contentRect.size.width != window->ns.width ||
-        contentRect.size.height != window->ns.height)
-    {
-        window->ns.width  = contentRect.size.width;
-        window->ns.height = contentRect.size.height;
-        _glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
-    }
-}
-
-- (void)windowDidMove:(NSNotification *)notification
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    int x, y;
-    _glfwPlatformGetWindowPos(window, &x, &y);
-    _glfwInputWindowPos(window, x, y);
-}
-
-- (void)windowDidMiniaturize:(NSNotification *)notification
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowIconify(window, GLFW_TRUE);
-}
-
-- (void)windowDidDeminiaturize:(NSNotification *)notification
-{
-    if (window->monitor)
-        acquireMonitor(window);
-
-    _glfwInputWindowIconify(window, GLFW_FALSE);
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfwCenterCursorInContentArea(window);
-
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-    updateCursorMode(window);
-}
-
-- (void)windowDidResignKey:(NSNotification *)notification
-{
-    if (window->monitor && window->autoIconify)
-        _glfwPlatformIconifyWindow(window);
-
-    _glfwInputWindowFocus(window, GLFW_FALSE);
-}
-
-- (void)windowDidChangeOcclusionState:(NSNotification* )notification
-{
-    if ([window->ns.object occlusionState] & NSWindowOcclusionStateVisible)
-        window->ns.occluded = GLFW_FALSE;
-    else
-        window->ns.occluded = GLFW_TRUE;
-}
-
-@end
-
-
-//------------------------------------------------------------------------
-// Content view class for the GLFW window
-//------------------------------------------------------------------------
-
-@interface GLFWContentView : NSView <NSTextInputClient>
-{
-    _GLFWwindow* window;
-    NSTrackingArea* trackingArea;
-    NSMutableAttributedString* markedText;
-}
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow;
-
-@end
-
-@implementation GLFWContentView
-
-- (instancetype)initWithGlfwWindow:(_GLFWwindow *)initWindow
-{
-    self = [super init];
-    if (self != nil)
-    {
-        window = initWindow;
-        trackingArea = nil;
-        markedText = [[NSMutableAttributedString alloc] init];
-
-        [self updateTrackingAreas];
-        // NOTE: kUTTypeURL corresponds to NSPasteboardTypeURL but is available
-        //       on 10.7 without having been deprecated yet
-        [self registerForDraggedTypes:@[(__bridge NSString*) kUTTypeURL]];
-    }
-
-    return self;
-}
-
-- (void)dealloc
-{
-    [trackingArea release];
-    [markedText release];
-    [super dealloc];
-}
-
-- (BOOL)isOpaque
-{
-    return [window->ns.object isOpaque];
-}
-
-- (BOOL)canBecomeKeyView
-{
-    return YES;
-}
-
-- (BOOL)acceptsFirstResponder
-{
-    return YES;
-}
-
-- (BOOL)wantsUpdateLayer
-{
-    return YES;
-}
-
-- (void)updateLayer
-{
-    if (window->context.client != GLFW_NO_API)
-        [window->context.nsgl.object update];
-
-    _glfwInputWindowDamage(window);
-}
-
-- (void)cursorUpdate:(NSEvent *)event
-{
-    updateCursorImage(window);
-}
-
-- (BOOL)acceptsFirstMouse:(NSEvent *)event
-{
-    return YES;
-}
-
-- (void)mouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_LEFT,
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)mouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_LEFT,
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseMoved:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        const double dx = [event deltaX] - window->ns.cursorWarpDeltaX;
-        const double dy = [event deltaY] - window->ns.cursorWarpDeltaY;
-
-        _glfwInputCursorPos(window,
-                            window->virtualCursorPosX + dx,
-                            window->virtualCursorPosY + dy);
-    }
-    else
-    {
-        const NSRect contentRect = [window->ns.view frame];
-        // NOTE: The returned location uses base 0,1 not 0,0
-        const NSPoint pos = [event locationInWindow];
-
-        _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
-    }
-
-    window->ns.cursorWarpDeltaX = 0;
-    window->ns.cursorWarpDeltaY = 0;
-}
-
-- (void)rightMouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_RIGHT,
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)rightMouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)rightMouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         GLFW_MOUSE_BUTTON_RIGHT,
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)otherMouseDown:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         (int) [event buttonNumber],
-                         GLFW_PRESS,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)otherMouseDragged:(NSEvent *)event
-{
-    [self mouseMoved:event];
-}
-
-- (void)otherMouseUp:(NSEvent *)event
-{
-    _glfwInputMouseClick(window,
-                         (int) [event buttonNumber],
-                         GLFW_RELEASE,
-                         translateFlags([event modifierFlags]));
-}
-
-- (void)mouseExited:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-        showCursor(window);
-
-    _glfwInputCursorEnter(window, GLFW_FALSE);
-}
-
-- (void)mouseEntered:(NSEvent *)event
-{
-    if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-        hideCursor(window);
-
-    _glfwInputCursorEnter(window, GLFW_TRUE);
-}
-
-- (void)viewDidChangeBackingProperties
-{
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (fbRect.size.width != window->ns.fbWidth ||
-        fbRect.size.height != window->ns.fbHeight)
-    {
-        window->ns.fbWidth  = fbRect.size.width;
-        window->ns.fbHeight = fbRect.size.height;
-        _glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
-    }
-
-    const float xscale = fbRect.size.width / contentRect.size.width;
-    const float yscale = fbRect.size.height / contentRect.size.height;
-
-    if (xscale != window->ns.xscale || yscale != window->ns.yscale)
-    {
-        window->ns.xscale = xscale;
-        window->ns.yscale = yscale;
-        _glfwInputWindowContentScale(window, xscale, yscale);
-
-        if (window->ns.retina && window->ns.layer)
-            [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
-    }
-}
-
-- (void)drawRect:(NSRect)rect
-{
-    _glfwInputWindowDamage(window);
-}
-
-- (void)updateTrackingAreas
-{
-    if (trackingArea != nil)
-    {
-        [self removeTrackingArea:trackingArea];
-        [trackingArea release];
-    }
-
-    const NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited |
-                                          NSTrackingActiveInKeyWindow |
-                                          NSTrackingEnabledDuringMouseDrag |
-                                          NSTrackingCursorUpdate |
-                                          NSTrackingInVisibleRect |
-                                          NSTrackingAssumeInside;
-
-    trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds]
-                                                options:options
-                                                  owner:self
-                                               userInfo:nil];
-
-    [self addTrackingArea:trackingArea];
-    [super updateTrackingAreas];
-}
-
-- (void)keyDown:(NSEvent *)event
-{
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags([event modifierFlags]);
-
-    _glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
-
-    [self interpretKeyEvents:@[event]];
-}
-
-- (void)flagsChanged:(NSEvent *)event
-{
-    int action;
-    const unsigned int modifierFlags =
-        [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags(modifierFlags);
-    const NSUInteger keyFlag = translateKeyToModifierFlag(key);
-
-    if (keyFlag & modifierFlags)
-    {
-        if (window->keys[key] == GLFW_PRESS)
-            action = GLFW_RELEASE;
-        else
-            action = GLFW_PRESS;
-    }
-    else
-        action = GLFW_RELEASE;
-
-    _glfwInputKey(window, key, [event keyCode], action, mods);
-}
-
-- (void)keyUp:(NSEvent *)event
-{
-    const int key = translateKey([event keyCode]);
-    const int mods = translateFlags([event modifierFlags]);
-    _glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
-}
-
-- (void)scrollWheel:(NSEvent *)event
-{
-    double deltaX = [event scrollingDeltaX];
-    double deltaY = [event scrollingDeltaY];
-
-    if ([event hasPreciseScrollingDeltas])
-    {
-        deltaX *= 0.1;
-        deltaY *= 0.1;
-    }
-
-    if (fabs(deltaX) > 0.0 || fabs(deltaY) > 0.0)
-        _glfwInputScroll(window, deltaX, deltaY);
-}
-
-- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
-{
-    // HACK: We don't know what to say here because we don't know what the
-    //       application wants to do with the paths
-    return NSDragOperationGeneric;
-}
-
-- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
-{
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [sender draggingLocation];
-    _glfwInputCursorPos(window, pos.x, contentRect.size.height - pos.y);
-
-    NSPasteboard* pasteboard = [sender draggingPasteboard];
-    NSDictionary* options = @{NSPasteboardURLReadingFileURLsOnlyKey:@YES};
-    NSArray* urls = [pasteboard readObjectsForClasses:@[[NSURL class]]
-                                              options:options];
-    const NSUInteger count = [urls count];
-    if (count)
-    {
-        char** paths = calloc(count, sizeof(char*));
-
-        for (NSUInteger i = 0;  i < count;  i++)
-            paths[i] = _glfw_strdup([urls[i] fileSystemRepresentation]);
-
-        _glfwInputDrop(window, (int) count, (const char**) paths);
-
-        for (NSUInteger i = 0;  i < count;  i++)
-            free(paths[i]);
-        free(paths);
-    }
-
-    return YES;
-}
-
-- (BOOL)hasMarkedText
-{
-    return [markedText length] > 0;
-}
-
-- (NSRange)markedRange
-{
-    if ([markedText length] > 0)
-        return NSMakeRange(0, [markedText length] - 1);
-    else
-        return kEmptyRange;
-}
-
-- (NSRange)selectedRange
-{
-    return kEmptyRange;
-}
-
-- (void)setMarkedText:(id)string
-        selectedRange:(NSRange)selectedRange
-     replacementRange:(NSRange)replacementRange
-{
-    [markedText release];
-    if ([string isKindOfClass:[NSAttributedString class]])
-        markedText = [[NSMutableAttributedString alloc] initWithAttributedString:string];
-    else
-        markedText = [[NSMutableAttributedString alloc] initWithString:string];
-}
-
-- (void)unmarkText
-{
-    [[markedText mutableString] setString:@""];
-}
-
-- (NSArray*)validAttributesForMarkedText
-{
-    return [NSArray array];
-}
-
-- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
-                                               actualRange:(NSRangePointer)actualRange
-{
-    return nil;
-}
-
-- (NSUInteger)characterIndexForPoint:(NSPoint)point
-{
-    return 0;
-}
-
-- (NSRect)firstRectForCharacterRange:(NSRange)range
-                         actualRange:(NSRangePointer)actualRange
-{
-    const NSRect frame = [window->ns.view frame];
-    return NSMakeRect(frame.origin.x, frame.origin.y, 0.0, 0.0);
-}
-
-- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
-{
-    NSString* characters;
-    NSEvent* event = [NSApp currentEvent];
-    const int mods = translateFlags([event modifierFlags]);
-    const int plain = !(mods & GLFW_MOD_SUPER);
-
-    if ([string isKindOfClass:[NSAttributedString class]])
-        characters = [string string];
-    else
-        characters = (NSString*) string;
-
-    NSRange range = NSMakeRange(0, [characters length]);
-    while (range.length)
-    {
-        uint32_t codepoint = 0;
-
-        if ([characters getBytes:&codepoint
-                       maxLength:sizeof(codepoint)
-                      usedLength:NULL
-                        encoding:NSUTF32StringEncoding
-                         options:0
-                           range:range
-                  remainingRange:&range])
-        {
-            if (codepoint >= 0xf700 && codepoint <= 0xf7ff)
-                continue;
-
-            _glfwInputChar(window, codepoint, mods, plain);
-        }
-    }
-}
-
-- (void)doCommandBySelector:(SEL)selector
-{
-}
-
-@end
-
-
-//------------------------------------------------------------------------
-// GLFW window class
-//------------------------------------------------------------------------
-
-@interface GLFWWindow : NSWindow {}
-@end
-
-@implementation GLFWWindow
-
-- (BOOL)canBecomeKeyWindow
-{
-    // Required for NSWindowStyleMaskBorderless windows
-    return YES;
-}
-
-- (BOOL)canBecomeMainWindow
-{
-    return YES;
-}
-
-@end
-
-
-// Create the Cocoa window
-//
-static GLFWbool createNativeWindow(_GLFWwindow* window,
-                                   const _GLFWwndconfig* wndconfig,
-                                   const _GLFWfbconfig* fbconfig)
-{
-    window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
-    if (window->ns.delegate == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create window delegate");
-        return GLFW_FALSE;
-    }
-
-    NSRect contentRect;
-
-    if (window->monitor)
-    {
-        GLFWvidmode mode;
-        int xpos, ypos;
-
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-
-        contentRect = NSMakeRect(xpos, ypos, mode.width, mode.height);
-    }
-    else
-        contentRect = NSMakeRect(0, 0, wndconfig->width, wndconfig->height);
-
-    window->ns.object = [[GLFWWindow alloc]
-        initWithContentRect:contentRect
-                  styleMask:getStyleMask(window)
-                    backing:NSBackingStoreBuffered
-                      defer:NO];
-
-    if (window->ns.object == nil)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    if (window->monitor)
-        [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
-    else
-    {
-        [(NSWindow*) window->ns.object center];
-        _glfw.ns.cascadePoint =
-            NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
-                              NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
-
-        if (wndconfig->resizable)
-        {
-            const NSWindowCollectionBehavior behavior =
-                NSWindowCollectionBehaviorFullScreenPrimary |
-                NSWindowCollectionBehaviorManaged;
-            [window->ns.object setCollectionBehavior:behavior];
-        }
-
-        if (wndconfig->floating)
-            [window->ns.object setLevel:NSFloatingWindowLevel];
-
-        if (wndconfig->maximized)
-            [window->ns.object zoom:nil];
-    }
-
-    if (strlen(wndconfig->ns.frameName))
-        [window->ns.object setFrameAutosaveName:@(wndconfig->ns.frameName)];
-
-    window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
-    window->ns.retina = wndconfig->ns.retina;
-
-    if (fbconfig->transparent)
-    {
-        [window->ns.object setOpaque:NO];
-        [window->ns.object setHasShadow:NO];
-        [window->ns.object setBackgroundColor:[NSColor clearColor]];
-    }
-
-    [window->ns.object setContentView:window->ns.view];
-    [window->ns.object makeFirstResponder:window->ns.view];
-    [window->ns.object setTitle:@(wndconfig->title)];
-    [window->ns.object setDelegate:window->ns.delegate];
-    [window->ns.object setAcceptsMouseMovedEvents:YES];
-    [window->ns.object setRestorable:NO];
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-    if ([window->ns.object respondsToSelector:@selector(setTabbingMode:)])
-        [window->ns.object setTabbingMode:NSWindowTabbingModeDisallowed];
-#endif
-
-    _glfwPlatformGetWindowSize(window, &window->ns.width, &window->ns.height);
-    _glfwPlatformGetFramebufferSize(window, &window->ns.fbWidth, &window->ns.fbHeight);
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Transforms a y-coordinate between the CG display and NS screen spaces
-//
-float _glfwTransformYNS(float y)
-{
-    return CGDisplayBounds(CGMainDisplayID()).size.height - y - 1;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    @autoreleasepool {
-
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitNSGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            // EGL implementation on macOS use CALayer* EGLNativeWindowType so we
-            // need to get the layer for EGL window surface creation.
-            [window->ns.view setWantsLayer:YES];
-            window->ns.layer = [window->ns.view layer];
-
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-    }
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    if (_glfw.ns.disabledCursorWindow == window)
-        _glfw.ns.disabledCursorWindow = NULL;
-
-    [window->ns.object orderOut:nil];
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    [window->ns.object setDelegate:nil];
-    [window->ns.delegate release];
-    window->ns.delegate = nil;
-
-    [window->ns.view release];
-    window->ns.view = nil;
-
-    [window->ns.object close];
-    window->ns.object = nil;
-
-    // HACK: Allow Cocoa to catch up before returning
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    @autoreleasepool {
-    NSString* string = @(title);
-    [window->ns.object setTitle:string];
-    // HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
-    //       if the window lacks NSWindowStyleMaskTitled
-    [window->ns.object setMiniwindowTitle:string];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Cocoa: Regular windows do not have icons on macOS");
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect =
-        [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
-
-    if (xpos)
-        *xpos = contentRect.origin.x;
-    if (ypos)
-        *ypos = _glfwTransformYNS(contentRect.origin.y + contentRect.size.height - 1);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect dummyRect = NSMakeRect(x, _glfwTransformYNS(y + contentRect.size.height - 1), 0, 0);
-    const NSRect frameRect = [window->ns.object frameRectForContentRect:dummyRect];
-    [window->ns.object setFrameOrigin:frameRect.origin];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-
-    if (width)
-        *width = contentRect.size.width;
-    if (height)
-        *height = contentRect.size.height;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    @autoreleasepool {
-
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-            acquireMonitor(window);
-    }
-    else
-    {
-        NSRect contentRect =
-            [window->ns.object contentRectForFrameRect:[window->ns.object frame]];
-        contentRect.origin.y += contentRect.size.height - height;
-        contentRect.size = NSMakeSize(width, height);
-        [window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
-                            display:YES];
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    @autoreleasepool {
-
-    if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
-        [window->ns.object setContentMinSize:NSMakeSize(0, 0)];
-    else
-        [window->ns.object setContentMinSize:NSMakeSize(minwidth, minheight)];
-
-    if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
-        [window->ns.object setContentMaxSize:NSMakeSize(DBL_MAX, DBL_MAX)];
-    else
-        [window->ns.object setContentMaxSize:NSMakeSize(maxwidth, maxheight)];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    @autoreleasepool {
-    if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
-        [window->ns.object setResizeIncrements:NSMakeSize(1.0, 1.0)];
-    else
-        [window->ns.object setContentAspectRatio:NSMakeSize(numer, denom)];
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect fbRect = [window->ns.view convertRectToBacking:contentRect];
-
-    if (width)
-        *width = (int) fbRect.size.width;
-    if (height)
-        *height = (int) fbRect.size.height;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    const NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect];
-
-    if (left)
-        *left = contentRect.origin.x - frameRect.origin.x;
-    if (top)
-        *top = frameRect.origin.y + frameRect.size.height -
-               contentRect.origin.y - contentRect.size.height;
-    if (right)
-        *right = frameRect.origin.x + frameRect.size.width -
-                 contentRect.origin.x - contentRect.size.width;
-    if (bottom)
-        *bottom = contentRect.origin.y - frameRect.origin.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    @autoreleasepool {
-
-    const NSRect points = [window->ns.view frame];
-    const NSRect pixels = [window->ns.view convertRectToBacking:points];
-
-    if (xscale)
-        *xscale = (float) (pixels.size.width / points.size.width);
-    if (yscale)
-        *yscale = (float) (pixels.size.height / points.size.height);
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object miniaturize:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    if ([window->ns.object isMiniaturized])
-        [window->ns.object deminiaturize:nil];
-    else if ([window->ns.object isZoomed])
-        [window->ns.object zoom:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    if (![window->ns.object isZoomed])
-        [window->ns.object zoom:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object orderFront:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [window->ns.object orderOut:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    [NSApp requestUserAttention:NSInformationalRequest];
-    } // autoreleasepool
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    // Make us the active application
-    // HACK: This is here to prevent applications using only hidden windows from
-    //       being activated, but should probably not be done every time any
-    //       window is shown
-    [NSApp activateIgnoringOtherApps:YES];
-    [window->ns.object makeKeyAndOrderFront:nil];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    @autoreleasepool {
-
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-                acquireMonitor(window);
-        }
-        else
-        {
-            const NSRect contentRect =
-                NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1), width, height);
-            const NSRect frameRect =
-                [window->ns.object frameRectForContentRect:contentRect
-                                                 styleMask:getStyleMask(window)];
-
-            [window->ns.object setFrame:frameRect display:YES];
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    // HACK: Allow the state cached in Cocoa to catch up to reality
-    // TODO: Solve this in a less terrible way
-    _glfwPlatformPollEvents();
-
-    const NSUInteger styleMask = getStyleMask(window);
-    [window->ns.object setStyleMask:styleMask];
-    // HACK: Changing the style mask can cause the first responder to be cleared
-    [window->ns.object makeFirstResponder:window->ns.view];
-
-    if (window->monitor)
-    {
-        [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
-        [window->ns.object setHasShadow:NO];
-
-        acquireMonitor(window);
-    }
-    else
-    {
-        NSRect contentRect = NSMakeRect(xpos, _glfwTransformYNS(ypos + height - 1),
-                                        width, height);
-        NSRect frameRect = [window->ns.object frameRectForContentRect:contentRect
-                                                            styleMask:styleMask];
-        [window->ns.object setFrame:frameRect display:YES];
-
-        if (window->numer != GLFW_DONT_CARE &&
-            window->denom != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentAspectRatio:NSMakeSize(window->numer,
-                                                                window->denom)];
-        }
-
-        if (window->minwidth != GLFW_DONT_CARE &&
-            window->minheight != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentMinSize:NSMakeSize(window->minwidth,
-                                                            window->minheight)];
-        }
-
-        if (window->maxwidth != GLFW_DONT_CARE &&
-            window->maxheight != GLFW_DONT_CARE)
-        {
-            [window->ns.object setContentMaxSize:NSMakeSize(window->maxwidth,
-                                                            window->maxheight)];
-        }
-
-        if (window->floating)
-            [window->ns.object setLevel:NSFloatingWindowLevel];
-        else
-            [window->ns.object setLevel:NSNormalWindowLevel];
-
-        [window->ns.object setHasShadow:YES];
-        // HACK: Clearing NSWindowStyleMaskTitled resets and disables the window
-        //       title property but the miniwindow title property is unaffected
-        [window->ns.object setTitle:[window->ns.object miniwindowTitle]];
-    }
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isKeyWindow];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isMiniaturized];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isVisible];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return [window->ns.object isZoomed];
-    } // autoreleasepool
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    const NSPoint point = [NSEvent mouseLocation];
-
-    if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
-        [window->ns.object windowNumber])
-    {
-        return GLFW_FALSE;
-    }
-
-    return NSMouseInRect(point,
-        [window->ns.object convertRectToScreen:[window->ns.view frame]], NO);
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setStyleMask:getStyleMask(window)];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setStyleMask:getStyleMask(window)];
-    [window->ns.object makeFirstResponder:window->ns.view];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    if (enabled)
-        [window->ns.object setLevel:NSFloatingWindowLevel];
-    else
-        [window->ns.object setLevel:NSNormalWindowLevel];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    @autoreleasepool {
-    [window->ns.object setIgnoresMouseEvents:enabled];
-    }
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    @autoreleasepool {
-    return (float) [window->ns.object alphaValue];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    @autoreleasepool {
-    [window->ns.object setAlphaValue:opacity];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Cocoa: Raw mouse motion not yet implemented");
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    @autoreleasepool {
-
-    for (;;)
-    {
-        NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                            untilDate:[NSDate distantPast]
-                                               inMode:NSDefaultRunLoopMode
-                                              dequeue:YES];
-        if (event == nil)
-            break;
-
-        [NSApp sendEvent:event];
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    @autoreleasepool {
-
-    // I wanted to pass NO to dequeue:, and rely on PollEvents to
-    // dequeue and send.  For reasons not at all clear to me, passing
-    // NO to dequeue: causes this method never to return.
-    NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                        untilDate:[NSDate distantFuture]
-                                           inMode:NSDefaultRunLoopMode
-                                          dequeue:YES];
-    [NSApp sendEvent:event];
-
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    @autoreleasepool {
-
-    NSDate* date = [NSDate dateWithTimeIntervalSinceNow:timeout];
-    NSEvent* event = [NSApp nextEventMatchingMask:NSEventMaskAny
-                                        untilDate:date
-                                           inMode:NSDefaultRunLoopMode
-                                          dequeue:YES];
-    if (event)
-        [NSApp sendEvent:event];
-
-    _glfwPlatformPollEvents();
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    @autoreleasepool {
-
-    NSEvent* event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
-                                        location:NSMakePoint(0, 0)
-                                   modifierFlags:0
-                                       timestamp:0
-                                    windowNumber:0
-                                         context:nil
-                                         subtype:0
-                                           data1:0
-                                           data2:0];
-    [NSApp postEvent:event atStart:YES];
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    @autoreleasepool {
-
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-
-    if (xpos)
-        *xpos = pos.x;
-    if (ypos)
-        *ypos = contentRect.size.height - pos.y;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    @autoreleasepool {
-
-    updateCursorImage(window);
-
-    const NSRect contentRect = [window->ns.view frame];
-    // NOTE: The returned location uses base 0,1 not 0,0
-    const NSPoint pos = [window->ns.object mouseLocationOutsideOfEventStream];
-
-    window->ns.cursorWarpDeltaX += x - pos.x;
-    window->ns.cursorWarpDeltaY += y - contentRect.size.height + pos.y;
-
-    if (window->monitor)
-    {
-        CGDisplayMoveCursorToPoint(window->monitor->ns.displayID,
-                                   CGPointMake(x, y));
-    }
-    else
-    {
-        const NSRect localRect = NSMakeRect(x, contentRect.size.height - y - 1, 0, 0);
-        const NSRect globalRect = [window->ns.object convertRectToScreen:localRect];
-        const NSPoint globalPoint = globalRect.origin;
-
-        CGWarpMouseCursorPosition(CGPointMake(globalPoint.x,
-                                              _glfwTransformYNS(globalPoint.y)));
-    }
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    @autoreleasepool {
-    if (_glfwPlatformWindowFocused(window))
-        updateCursorMode(window);
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    @autoreleasepool {
-
-    if (scancode < 0 || scancode > 0xff ||
-        _glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    const int key = _glfw.ns.keycodes[scancode];
-
-    UInt32 deadKeyState = 0;
-    UniChar characters[4];
-    UniCharCount characterCount = 0;
-
-    if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
-                       scancode,
-                       kUCKeyActionDisplay,
-                       0,
-                       LMGetKbdType(),
-                       kUCKeyTranslateNoDeadKeysBit,
-                       &deadKeyState,
-                       sizeof(characters) / sizeof(characters[0]),
-                       &characterCount,
-                       characters) != noErr)
-    {
-        return NULL;
-    }
-
-    if (!characterCount)
-        return NULL;
-
-    CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault,
-                                                            characters,
-                                                            characterCount,
-                                                            kCFAllocatorNull);
-    CFStringGetCString(string,
-                       _glfw.ns.keynames[key],
-                       sizeof(_glfw.ns.keynames[key]),
-                       kCFStringEncodingUTF8);
-    CFRelease(string);
-
-    return _glfw.ns.keynames[key];
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.ns.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    @autoreleasepool {
-
-    NSImage* native;
-    NSBitmapImageRep* rep;
-
-    rep = [[NSBitmapImageRep alloc]
-        initWithBitmapDataPlanes:NULL
-                      pixelsWide:image->width
-                      pixelsHigh:image->height
-                   bitsPerSample:8
-                 samplesPerPixel:4
-                        hasAlpha:YES
-                        isPlanar:NO
-                  colorSpaceName:NSCalibratedRGBColorSpace
-                    bitmapFormat:NSBitmapFormatAlphaNonpremultiplied
-                     bytesPerRow:image->width * 4
-                    bitsPerPixel:32];
-
-    if (rep == nil)
-        return GLFW_FALSE;
-
-    memcpy([rep bitmapData], image->pixels, image->width * image->height * 4);
-
-    native = [[NSImage alloc] initWithSize:NSMakeSize(image->width, image->height)];
-    [native addRepresentation:rep];
-
-    cursor->ns.object = [[NSCursor alloc] initWithImage:native
-                                                hotSpot:NSMakePoint(xhot, yhot)];
-
-    [native release];
-    [rep release];
-
-    if (cursor->ns.object == nil)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    @autoreleasepool {
-
-    SEL cursorSelector = NULL;
-
-    // HACK: Try to use a private message
-    if (shape == GLFW_RESIZE_EW_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeEastWestCursor");
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthSouthCursor");
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthWestSouthEastCursor");
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        cursorSelector = NSSelectorFromString(@"_windowResizeNorthEastSouthWestCursor");
-
-    if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
-    {
-        id object = [NSCursor performSelector:cursorSelector];
-        if ([object isKindOfClass:[NSCursor class]])
-            cursor->ns.object = object;
-    }
-
-    if (!cursor->ns.object)
-    {
-        if (shape == GLFW_ARROW_CURSOR)
-            cursor->ns.object = [NSCursor arrowCursor];
-        else if (shape == GLFW_IBEAM_CURSOR)
-            cursor->ns.object = [NSCursor IBeamCursor];
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            cursor->ns.object = [NSCursor crosshairCursor];
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            cursor->ns.object = [NSCursor pointingHandCursor];
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            cursor->ns.object = [NSCursor resizeLeftRightCursor];
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            cursor->ns.object = [NSCursor resizeUpDownCursor];
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            cursor->ns.object = [NSCursor closedHandCursor];
-        else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-            cursor->ns.object = [NSCursor operationNotAllowedCursor];
-    }
-
-    if (!cursor->ns.object)
-    {
-        _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                        "Cocoa: Standard cursor shape unavailable");
-        return GLFW_FALSE;
-    }
-
-    [cursor->ns.object retain];
-    return GLFW_TRUE;
-
-    } // autoreleasepool
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    @autoreleasepool {
-    if (cursor->ns.object)
-        [(NSCursor*) cursor->ns.object release];
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    @autoreleasepool {
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-    } // autoreleasepool
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    @autoreleasepool {
-    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
-    [pasteboard declareTypes:@[NSPasteboardTypeString] owner:nil];
-    [pasteboard setString:@(string) forType:NSPasteboardTypeString];
-    } // autoreleasepool
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    @autoreleasepool {
-
-    NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
-
-    if (![[pasteboard types] containsObject:NSPasteboardTypeString])
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "Cocoa: Failed to retrieve string from pasteboard");
-        return NULL;
-    }
-
-    NSString* object = [pasteboard stringForType:NSPasteboardTypeString];
-    if (!object)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to retrieve object from pasteboard");
-        return NULL;
-    }
-
-    free(_glfw.ns.clipboardString);
-    _glfw.ns.clipboardString = _glfw_strdup([object UTF8String]);
-
-    return _glfw.ns.clipboardString;
-
-    } // autoreleasepool
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_metal)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_METAL)
-                type = EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(3, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return EGL_DEFAULT_DISPLAY;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->ns.layer;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface)
-    {
-        extensions[0] = "VK_KHR_surface";
-        extensions[1] = "VK_EXT_metal_surface";
-    }
-    else if (_glfw.vk.KHR_surface && _glfw.vk.MVK_macos_surface)
-    {
-        extensions[0] = "VK_KHR_surface";
-        extensions[1] = "VK_MVK_macos_surface";
-    }
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    return GLFW_TRUE;
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    @autoreleasepool {
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
-    // HACK: Dynamically load Core Animation to avoid adding an extra
-    //       dependency for the majority who don't use MoltenVK
-    NSBundle* bundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/QuartzCore.framework"];
-    if (!bundle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to find QuartzCore.framework");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    // NOTE: Create the layer here as makeBackingLayer should not return nil
-    window->ns.layer = [[bundle classNamed:@"CAMetalLayer"] layer];
-    if (!window->ns.layer)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create layer for view");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    if (window->ns.retina)
-        [window->ns.layer setContentsScale:[window->ns.object backingScaleFactor]];
-
-    [window->ns.view setLayer:window->ns.layer];
-    [window->ns.view setWantsLayer:YES];
-
-    VkResult err;
-
-    if (_glfw.vk.EXT_metal_surface)
-    {
-        VkMetalSurfaceCreateInfoEXT sci;
-
-        PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT;
-        vkCreateMetalSurfaceEXT = (PFN_vkCreateMetalSurfaceEXT)
-            vkGetInstanceProcAddr(instance, "vkCreateMetalSurfaceEXT");
-        if (!vkCreateMetalSurfaceEXT)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Cocoa: Vulkan instance missing VK_EXT_metal_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT;
-        sci.pLayer = window->ns.layer;
-
-        err = vkCreateMetalSurfaceEXT(instance, &sci, allocator, surface);
-    }
-    else
-    {
-        VkMacOSSurfaceCreateInfoMVK sci;
-
-        PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK;
-        vkCreateMacOSSurfaceMVK = (PFN_vkCreateMacOSSurfaceMVK)
-            vkGetInstanceProcAddr(instance, "vkCreateMacOSSurfaceMVK");
-        if (!vkCreateMacOSSurfaceMVK)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Cocoa: Vulkan instance missing VK_MVK_macos_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
-        sci.pView = window->ns.view;
-
-        err = vkCreateMacOSSurfaceMVK(instance, &sci, allocator, surface);
-    }
-
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Cocoa: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-#else
-    return VK_ERROR_EXTENSION_NOT_PRESENT;
-#endif
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI id glfwGetCocoaWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(nil);
-    return window->ns.object;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/context.c b/raylib_pi4_test/external/glfw/src/context.c
deleted file mode 100644 (file)
index 48311e5..0000000
+++ /dev/null
@@ -1,760 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Checks whether the desired context attributes are valid
-//
-// This function checks things like whether the specified client API version
-// exists and whether all relevant options have supported and non-conflicting
-// values
-//
-GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig)
-{
-    if (ctxconfig->share)
-    {
-        if (ctxconfig->client == GLFW_NO_API ||
-            ctxconfig->share->context.client == GLFW_NO_API)
-        {
-            _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->source != GLFW_NATIVE_CONTEXT_API &&
-        ctxconfig->source != GLFW_EGL_CONTEXT_API &&
-        ctxconfig->source != GLFW_OSMESA_CONTEXT_API)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM,
-                        "Invalid context creation API 0x%08X",
-                        ctxconfig->source);
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client != GLFW_NO_API &&
-        ctxconfig->client != GLFW_OPENGL_API &&
-        ctxconfig->client != GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM,
-                        "Invalid client API 0x%08X",
-                        ctxconfig->client);
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_API)
-    {
-        if ((ctxconfig->major < 1 || ctxconfig->minor < 0) ||
-            (ctxconfig->major == 1 && ctxconfig->minor > 5) ||
-            (ctxconfig->major == 2 && ctxconfig->minor > 1) ||
-            (ctxconfig->major == 3 && ctxconfig->minor > 3))
-        {
-            // OpenGL 1.0 is the smallest valid version
-            // OpenGL 1.x series ended with version 1.5
-            // OpenGL 2.x series ended with version 2.1
-            // OpenGL 3.x series ended with version 3.3
-            // For now, let everything else through
-
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid OpenGL version %i.%i",
-                            ctxconfig->major, ctxconfig->minor);
-            return GLFW_FALSE;
-        }
-
-        if (ctxconfig->profile)
-        {
-            if (ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE &&
-                ctxconfig->profile != GLFW_OPENGL_COMPAT_PROFILE)
-            {
-                _glfwInputError(GLFW_INVALID_ENUM,
-                                "Invalid OpenGL profile 0x%08X",
-                                ctxconfig->profile);
-                return GLFW_FALSE;
-            }
-
-            if (ctxconfig->major <= 2 ||
-                (ctxconfig->major == 3 && ctxconfig->minor < 2))
-            {
-                // Desktop OpenGL context profiles are only defined for version 3.2
-                // and above
-
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Context profiles are only defined for OpenGL version 3.2 and above");
-                return GLFW_FALSE;
-            }
-        }
-
-        if (ctxconfig->forward && ctxconfig->major <= 2)
-        {
-            // Forward-compatible contexts are only defined for OpenGL version 3.0 and above
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Forward-compatibility is only defined for OpenGL version 3.0 and above");
-            return GLFW_FALSE;
-        }
-    }
-    else if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (ctxconfig->major < 1 || ctxconfig->minor < 0 ||
-            (ctxconfig->major == 1 && ctxconfig->minor > 1) ||
-            (ctxconfig->major == 2 && ctxconfig->minor > 0))
-        {
-            // OpenGL ES 1.0 is the smallest valid version
-            // OpenGL ES 1.x series ended with version 1.1
-            // OpenGL ES 2.x series ended with version 2.0
-            // For now, let everything else through
-
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid OpenGL ES version %i.%i",
-                            ctxconfig->major, ctxconfig->minor);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->robustness)
-    {
-        if (ctxconfig->robustness != GLFW_NO_RESET_NOTIFICATION &&
-            ctxconfig->robustness != GLFW_LOSE_CONTEXT_ON_RESET)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid context robustness mode 0x%08X",
-                            ctxconfig->robustness);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->release)
-    {
-        if (ctxconfig->release != GLFW_RELEASE_BEHAVIOR_NONE &&
-            ctxconfig->release != GLFW_RELEASE_BEHAVIOR_FLUSH)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid context release behavior 0x%08X",
-                            ctxconfig->release);
-            return GLFW_FALSE;
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-// Chooses the framebuffer config that best matches the desired one
-//
-const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
-                                         const _GLFWfbconfig* alternatives,
-                                         unsigned int count)
-{
-    unsigned int i;
-    unsigned int missing, leastMissing = UINT_MAX;
-    unsigned int colorDiff, leastColorDiff = UINT_MAX;
-    unsigned int extraDiff, leastExtraDiff = UINT_MAX;
-    const _GLFWfbconfig* current;
-    const _GLFWfbconfig* closest = NULL;
-
-    for (i = 0;  i < count;  i++)
-    {
-        current = alternatives + i;
-
-        if (desired->stereo > 0 && current->stereo == 0)
-        {
-            // Stereo is a hard constraint
-            continue;
-        }
-
-        if (desired->doublebuffer != current->doublebuffer)
-        {
-            // Double buffering is a hard constraint
-            continue;
-        }
-
-        // Count number of missing buffers
-        {
-            missing = 0;
-
-            if (desired->alphaBits > 0 && current->alphaBits == 0)
-                missing++;
-
-            if (desired->depthBits > 0 && current->depthBits == 0)
-                missing++;
-
-            if (desired->stencilBits > 0 && current->stencilBits == 0)
-                missing++;
-
-            if (desired->auxBuffers > 0 &&
-                current->auxBuffers < desired->auxBuffers)
-            {
-                missing += desired->auxBuffers - current->auxBuffers;
-            }
-
-            if (desired->samples > 0 && current->samples == 0)
-            {
-                // Technically, several multisampling buffers could be
-                // involved, but that's a lower level implementation detail and
-                // not important to us here, so we count them as one
-                missing++;
-            }
-
-            if (desired->transparent != current->transparent)
-                missing++;
-        }
-
-        // These polynomials make many small channel size differences matter
-        // less than one large channel size difference
-
-        // Calculate color channel size difference value
-        {
-            colorDiff = 0;
-
-            if (desired->redBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->redBits - current->redBits) *
-                             (desired->redBits - current->redBits);
-            }
-
-            if (desired->greenBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->greenBits - current->greenBits) *
-                             (desired->greenBits - current->greenBits);
-            }
-
-            if (desired->blueBits != GLFW_DONT_CARE)
-            {
-                colorDiff += (desired->blueBits - current->blueBits) *
-                             (desired->blueBits - current->blueBits);
-            }
-        }
-
-        // Calculate non-color channel size difference value
-        {
-            extraDiff = 0;
-
-            if (desired->alphaBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->alphaBits - current->alphaBits) *
-                             (desired->alphaBits - current->alphaBits);
-            }
-
-            if (desired->depthBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->depthBits - current->depthBits) *
-                             (desired->depthBits - current->depthBits);
-            }
-
-            if (desired->stencilBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->stencilBits - current->stencilBits) *
-                             (desired->stencilBits - current->stencilBits);
-            }
-
-            if (desired->accumRedBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumRedBits - current->accumRedBits) *
-                             (desired->accumRedBits - current->accumRedBits);
-            }
-
-            if (desired->accumGreenBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
-                             (desired->accumGreenBits - current->accumGreenBits);
-            }
-
-            if (desired->accumBlueBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
-                             (desired->accumBlueBits - current->accumBlueBits);
-            }
-
-            if (desired->accumAlphaBits != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
-                             (desired->accumAlphaBits - current->accumAlphaBits);
-            }
-
-            if (desired->samples != GLFW_DONT_CARE)
-            {
-                extraDiff += (desired->samples - current->samples) *
-                             (desired->samples - current->samples);
-            }
-
-            if (desired->sRGB && !current->sRGB)
-                extraDiff++;
-        }
-
-        // Figure out if the current one is better than the best one found so far
-        // Least number of missing buffers is the most important heuristic,
-        // then color buffer size match and lastly size match for other buffers
-
-        if (missing < leastMissing)
-            closest = current;
-        else if (missing == leastMissing)
-        {
-            if ((colorDiff < leastColorDiff) ||
-                (colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
-            {
-                closest = current;
-            }
-        }
-
-        if (current == closest)
-        {
-            leastMissing = missing;
-            leastColorDiff = colorDiff;
-            leastExtraDiff = extraDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Retrieves the attributes of the current context
-//
-GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
-                                    const _GLFWctxconfig* ctxconfig)
-{
-    int i;
-    _GLFWwindow* previous;
-    const char* version;
-    const char* prefixes[] =
-    {
-        "OpenGL ES-CM ",
-        "OpenGL ES-CL ",
-        "OpenGL ES ",
-        NULL
-    };
-
-    window->context.source = ctxconfig->source;
-    window->context.client = GLFW_OPENGL_API;
-
-    previous = _glfwPlatformGetTls(&_glfw.contextSlot);
-    glfwMakeContextCurrent((GLFWwindow*) window);
-
-    window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
-        window->context.getProcAddress("glGetIntegerv");
-    window->context.GetString = (PFNGLGETSTRINGPROC)
-        window->context.getProcAddress("glGetString");
-    if (!window->context.GetIntegerv || !window->context.GetString)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    version = (const char*) window->context.GetString(GL_VERSION);
-    if (!version)
-    {
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OpenGL version string retrieval is broken");
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OpenGL ES version string retrieval is broken");
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  prefixes[i];  i++)
-    {
-        const size_t length = strlen(prefixes[i]);
-
-        if (strncmp(version, prefixes[i], length) == 0)
-        {
-            version += length;
-            window->context.client = GLFW_OPENGL_ES_API;
-            break;
-        }
-    }
-
-    if (!sscanf(version, "%d.%d.%d",
-                &window->context.major,
-                &window->context.minor,
-                &window->context.revision))
-    {
-        if (window->context.client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "No version found in OpenGL version string");
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "No version found in OpenGL ES version string");
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major < ctxconfig->major ||
-        (window->context.major == ctxconfig->major &&
-         window->context.minor < ctxconfig->minor))
-    {
-        // The desired OpenGL version is greater than the actual version
-        // This only happens if the machine lacks {GLX|WGL}_ARB_create_context
-        // /and/ the user has requested an OpenGL version greater than 1.0
-
-        // For API consistency, we emulate the behavior of the
-        // {GLX|WGL}_ARB_create_context extension and fail here
-
-        if (window->context.client == GLFW_OPENGL_API)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "Requested OpenGL version %i.%i, got version %i.%i",
-                            ctxconfig->major, ctxconfig->minor,
-                            window->context.major, window->context.minor);
-        }
-        else
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "Requested OpenGL ES version %i.%i, got version %i.%i",
-                            ctxconfig->major, ctxconfig->minor,
-                            window->context.major, window->context.minor);
-        }
-
-        glfwMakeContextCurrent((GLFWwindow*) previous);
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major >= 3)
-    {
-        // OpenGL 3.0+ uses a different function for extension string retrieval
-        // We cache it here instead of in glfwExtensionSupported mostly to alert
-        // users as early as possible that their build may be broken
-
-        window->context.GetStringi = (PFNGLGETSTRINGIPROC)
-            window->context.getProcAddress("glGetStringi");
-        if (!window->context.GetStringi)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Entry point retrieval is broken");
-            glfwMakeContextCurrent((GLFWwindow*) previous);
-            return GLFW_FALSE;
-        }
-    }
-
-    if (window->context.client == GLFW_OPENGL_API)
-    {
-        // Read back context flags (OpenGL 3.0 and above)
-        if (window->context.major >= 3)
-        {
-            GLint flags;
-            window->context.GetIntegerv(GL_CONTEXT_FLAGS, &flags);
-
-            if (flags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)
-                window->context.forward = GLFW_TRUE;
-
-            if (flags & GL_CONTEXT_FLAG_DEBUG_BIT)
-                window->context.debug = GLFW_TRUE;
-            else if (glfwExtensionSupported("GL_ARB_debug_output") &&
-                     ctxconfig->debug)
-            {
-                // HACK: This is a workaround for older drivers (pre KHR_debug)
-                //       not setting the debug bit in the context flags for
-                //       debug contexts
-                window->context.debug = GLFW_TRUE;
-            }
-
-            if (flags & GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR)
-                window->context.noerror = GLFW_TRUE;
-        }
-
-        // Read back OpenGL context profile (OpenGL 3.2 and above)
-        if (window->context.major >= 4 ||
-            (window->context.major == 3 && window->context.minor >= 2))
-        {
-            GLint mask;
-            window->context.GetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
-
-            if (mask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT)
-                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
-            else if (mask & GL_CONTEXT_CORE_PROFILE_BIT)
-                window->context.profile = GLFW_OPENGL_CORE_PROFILE;
-            else if (glfwExtensionSupported("GL_ARB_compatibility"))
-            {
-                // HACK: This is a workaround for the compatibility profile bit
-                //       not being set in the context flags if an OpenGL 3.2+
-                //       context was created without having requested a specific
-                //       version
-                window->context.profile = GLFW_OPENGL_COMPAT_PROFILE;
-            }
-        }
-
-        // Read back robustness strategy
-        if (glfwExtensionSupported("GL_ARB_robustness"))
-        {
-            // NOTE: We avoid using the context flags for detection, as they are
-            //       only present from 3.0 while the extension applies from 1.1
-
-            GLint strategy;
-            window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
-                                        &strategy);
-
-            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
-                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
-            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
-                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
-        }
-    }
-    else
-    {
-        // Read back robustness strategy
-        if (glfwExtensionSupported("GL_EXT_robustness"))
-        {
-            // NOTE: The values of these constants match those of the OpenGL ARB
-            //       one, so we can reuse them here
-
-            GLint strategy;
-            window->context.GetIntegerv(GL_RESET_NOTIFICATION_STRATEGY_ARB,
-                                        &strategy);
-
-            if (strategy == GL_LOSE_CONTEXT_ON_RESET_ARB)
-                window->context.robustness = GLFW_LOSE_CONTEXT_ON_RESET;
-            else if (strategy == GL_NO_RESET_NOTIFICATION_ARB)
-                window->context.robustness = GLFW_NO_RESET_NOTIFICATION;
-        }
-    }
-
-    if (glfwExtensionSupported("GL_KHR_context_flush_control"))
-    {
-        GLint behavior;
-        window->context.GetIntegerv(GL_CONTEXT_RELEASE_BEHAVIOR, &behavior);
-
-        if (behavior == GL_NONE)
-            window->context.release = GLFW_RELEASE_BEHAVIOR_NONE;
-        else if (behavior == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH)
-            window->context.release = GLFW_RELEASE_BEHAVIOR_FLUSH;
-    }
-
-    // Clearing the front buffer to black to avoid garbage pixels left over from
-    // previous uses of our bit of VRAM
-    {
-        PFNGLCLEARPROC glClear = (PFNGLCLEARPROC)
-            window->context.getProcAddress("glClear");
-        glClear(GL_COLOR_BUFFER_BIT);
-        window->context.swapBuffers(window);
-    }
-
-    glfwMakeContextCurrent((GLFWwindow*) previous);
-    return GLFW_TRUE;
-}
-
-// Searches an extension string for the specified extension
-//
-GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions)
-{
-    const char* start = extensions;
-
-    for (;;)
-    {
-        const char* where;
-        const char* terminator;
-
-        where = strstr(start, string);
-        if (!where)
-            return GLFW_FALSE;
-
-        terminator = where + strlen(string);
-        if (where == start || *(where - 1) == ' ')
-        {
-            if (*terminator == ' ' || *terminator == '\0')
-                break;
-        }
-
-        start = terminator;
-    }
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFWwindow* previous = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window && window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
-                        "Cannot make current with a window that has no OpenGL or OpenGL ES context");
-        return;
-    }
-
-    if (previous)
-    {
-        if (!window || window->context.source != previous->context.source)
-            previous->context.makeCurrent(NULL);
-    }
-
-    if (window)
-        window->context.makeCurrent(window);
-}
-
-GLFWAPI GLFWwindow* glfwGetCurrentContext(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfwPlatformGetTls(&_glfw.contextSlot);
-}
-
-GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT,
-                        "Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
-        return;
-    }
-
-    window->context.swapBuffers(window);
-}
-
-GLFWAPI void glfwSwapInterval(int interval)
-{
-    _GLFWwindow* window;
-
-    _GLFW_REQUIRE_INIT();
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot set swap interval without a current OpenGL or OpenGL ES context");
-        return;
-    }
-
-    window->context.swapInterval(interval);
-}
-
-GLFWAPI int glfwExtensionSupported(const char* extension)
-{
-    _GLFWwindow* window;
-    assert(extension != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot query extension without a current OpenGL or OpenGL ES context");
-        return GLFW_FALSE;
-    }
-
-    if (*extension == '\0')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Extension name cannot be an empty string");
-        return GLFW_FALSE;
-    }
-
-    if (window->context.major >= 3)
-    {
-        int i;
-        GLint count;
-
-        // Check if extension is in the modern OpenGL extensions string list
-
-        window->context.GetIntegerv(GL_NUM_EXTENSIONS, &count);
-
-        for (i = 0;  i < count;  i++)
-        {
-            const char* en = (const char*)
-                window->context.GetStringi(GL_EXTENSIONS, i);
-            if (!en)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Extension string retrieval is broken");
-                return GLFW_FALSE;
-            }
-
-            if (strcmp(en, extension) == 0)
-                return GLFW_TRUE;
-        }
-    }
-    else
-    {
-        // Check if extension is in the old style OpenGL extensions string
-
-        const char* extensions = (const char*)
-            window->context.GetString(GL_EXTENSIONS);
-        if (!extensions)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Extension string retrieval is broken");
-            return GLFW_FALSE;
-        }
-
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    // Check if extension is in the platform-specific string
-    return window->context.extensionSupported(extension);
-}
-
-GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname)
-{
-    _GLFWwindow* window;
-    assert(procname != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (!window)
-    {
-        _glfwInputError(GLFW_NO_CURRENT_CONTEXT,
-                        "Cannot query entry point without a current OpenGL or OpenGL ES context");
-        return NULL;
-    }
-
-    return window->context.getProcAddress(procname);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/egl_context.c b/raylib_pi4_test/external/glfw/src/egl_context.c
deleted file mode 100644 (file)
index 533ed8e..0000000
+++ /dev/null
@@ -1,843 +0,0 @@
-//========================================================================
-// GLFW 3.4 EGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-// Return a description of the specified EGL error
-//
-static const char* getEGLErrorString(EGLint error)
-{
-    switch (error)
-    {
-        case EGL_SUCCESS:
-            return "Success";
-        case EGL_NOT_INITIALIZED:
-            return "EGL is not or could not be initialized";
-        case EGL_BAD_ACCESS:
-            return "EGL cannot access a requested resource";
-        case EGL_BAD_ALLOC:
-            return "EGL failed to allocate resources for the requested operation";
-        case EGL_BAD_ATTRIBUTE:
-            return "An unrecognized attribute or attribute value was passed in the attribute list";
-        case EGL_BAD_CONTEXT:
-            return "An EGLContext argument does not name a valid EGL rendering context";
-        case EGL_BAD_CONFIG:
-            return "An EGLConfig argument does not name a valid EGL frame buffer configuration";
-        case EGL_BAD_CURRENT_SURFACE:
-            return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid";
-        case EGL_BAD_DISPLAY:
-            return "An EGLDisplay argument does not name a valid EGL display connection";
-        case EGL_BAD_SURFACE:
-            return "An EGLSurface argument does not name a valid surface configured for GL rendering";
-        case EGL_BAD_MATCH:
-            return "Arguments are inconsistent";
-        case EGL_BAD_PARAMETER:
-            return "One or more argument values are invalid";
-        case EGL_BAD_NATIVE_PIXMAP:
-            return "A NativePixmapType argument does not refer to a valid native pixmap";
-        case EGL_BAD_NATIVE_WINDOW:
-            return "A NativeWindowType argument does not refer to a valid native window";
-        case EGL_CONTEXT_LOST:
-            return "The application must destroy all contexts and reinitialise";
-        default:
-            return "ERROR: UNKNOWN EGL ERROR";
-    }
-}
-
-// Returns the specified attribute of the specified EGLConfig
-//
-static int getEGLConfigAttrib(EGLConfig config, int attrib)
-{
-    int value;
-    eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
-    return value;
-}
-
-// Return the EGLConfig most closely matching the specified hints
-//
-static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* desired,
-                                EGLConfig* result)
-{
-    EGLConfig* nativeConfigs;
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, nativeCount, usableCount;
-
-    eglGetConfigs(_glfw.egl.display, NULL, 0, &nativeCount);
-    if (!nativeCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: No EGLConfigs returned");
-        return GLFW_FALSE;
-    }
-
-    nativeConfigs = calloc(nativeCount, sizeof(EGLConfig));
-    eglGetConfigs(_glfw.egl.display, nativeConfigs, nativeCount, &nativeCount);
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-    usableCount = 0;
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        const EGLConfig n = nativeConfigs[i];
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-
-        // Only consider RGB(A) EGLConfigs
-        if (getEGLConfigAttrib(n, EGL_COLOR_BUFFER_TYPE) != EGL_RGB_BUFFER)
-            continue;
-
-        // Only consider window EGLConfigs
-        if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_WINDOW_BIT))
-            continue;
-
-#if defined(_GLFW_X11)
-        {
-            XVisualInfo vi = {0};
-
-            // Only consider EGLConfigs with associated Visuals
-            vi.visualid = getEGLConfigAttrib(n, EGL_NATIVE_VISUAL_ID);
-            if (!vi.visualid)
-                continue;
-
-            if (desired->transparent)
-            {
-                int count;
-                XVisualInfo* vis =
-                    XGetVisualInfo(_glfw.x11.display, VisualIDMask, &vi, &count);
-                if (vis)
-                {
-                    u->transparent = _glfwIsVisualTransparentX11(vis[0].visual);
-                    XFree(vis);
-                }
-            }
-        }
-#endif // _GLFW_X11
-
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-        {
-            if (ctxconfig->major == 1)
-            {
-                if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES_BIT))
-                    continue;
-            }
-            else
-            {
-                if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_ES2_BIT))
-                    continue;
-            }
-        }
-        else if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (!(getEGLConfigAttrib(n, EGL_RENDERABLE_TYPE) & EGL_OPENGL_BIT))
-                continue;
-        }
-
-        u->redBits = getEGLConfigAttrib(n, EGL_RED_SIZE);
-        u->greenBits = getEGLConfigAttrib(n, EGL_GREEN_SIZE);
-        u->blueBits = getEGLConfigAttrib(n, EGL_BLUE_SIZE);
-
-        u->alphaBits = getEGLConfigAttrib(n, EGL_ALPHA_SIZE);
-        u->depthBits = getEGLConfigAttrib(n, EGL_DEPTH_SIZE);
-        u->stencilBits = getEGLConfigAttrib(n, EGL_STENCIL_SIZE);
-
-        u->samples = getEGLConfigAttrib(n, EGL_SAMPLES);
-        u->doublebuffer = GLFW_TRUE;
-
-        u->handle = (uintptr_t) n;
-        usableCount++;
-    }
-
-    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
-    if (closest)
-        *result = (EGLConfig) closest->handle;
-
-    free(nativeConfigs);
-    free(usableConfigs);
-
-    return closest != NULL;
-}
-
-static void makeContextCurrentEGL(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (!eglMakeCurrent(_glfw.egl.display,
-                            window->context.egl.surface,
-                            window->context.egl.surface,
-                            window->context.egl.handle))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "EGL: Failed to make context current: %s",
-                            getEGLErrorString(eglGetError()));
-            return;
-        }
-    }
-    else
-    {
-        if (!eglMakeCurrent(_glfw.egl.display,
-                            EGL_NO_SURFACE,
-                            EGL_NO_SURFACE,
-                            EGL_NO_CONTEXT))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "EGL: Failed to clear current context: %s",
-                            getEGLErrorString(eglGetError()));
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static void swapBuffersEGL(_GLFWwindow* window)
-{
-    if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: The context must be current on the calling thread when swapping buffers");
-        return;
-    }
-
-    eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
-}
-
-static void swapIntervalEGL(int interval)
-{
-    eglSwapInterval(_glfw.egl.display, interval);
-}
-
-static int extensionSupportedEGL(const char* extension)
-{
-    const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
-    if (extensions)
-    {
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressEGL(const char* procname)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    if (window->context.egl.client)
-    {
-        GLFWglproc proc = (GLFWglproc) _glfw_dlsym(window->context.egl.client,
-                                                   procname);
-        if (proc)
-            return proc;
-    }
-
-    return eglGetProcAddress(procname);
-}
-
-static void destroyContextEGL(_GLFWwindow* window)
-{
-#if defined(_GLFW_X11)
-    // NOTE: Do not unload libGL.so.1 while the X11 display is still open,
-    //       as it will make XCloseDisplay segfault
-    if (window->context.client != GLFW_OPENGL_API)
-#endif // _GLFW_X11
-    {
-        if (window->context.egl.client)
-        {
-            _glfw_dlclose(window->context.egl.client);
-            window->context.egl.client = NULL;
-        }
-    }
-
-    if (window->context.egl.surface)
-    {
-        eglDestroySurface(_glfw.egl.display, window->context.egl.surface);
-        window->context.egl.surface = EGL_NO_SURFACE;
-    }
-
-    if (window->context.egl.handle)
-    {
-        eglDestroyContext(_glfw.egl.display, window->context.egl.handle);
-        window->context.egl.handle = EGL_NO_CONTEXT;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize EGL
-//
-GLFWbool _glfwInitEGL(void)
-{
-    int i;
-    EGLint* attribs = NULL;
-    const char* extensions;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_EGL_LIBRARY)
-        _GLFW_EGL_LIBRARY,
-#elif defined(_GLFW_WIN32)
-        "libEGL.dll",
-        "EGL.dll",
-#elif defined(_GLFW_COCOA)
-        "libEGL.dylib",
-#elif defined(__CYGWIN__)
-        "libEGL-1.so",
-#else
-        "libEGL.so.1",
-#endif
-        NULL
-    };
-
-    if (_glfw.egl.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.egl.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.egl.handle)
-            break;
-    }
-
-    if (!_glfw.egl.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Library not found");
-        return GLFW_FALSE;
-    }
-
-    _glfw.egl.prefix = (strncmp(sonames[i], "lib", 3) == 0);
-
-    _glfw.egl.GetConfigAttrib = (PFN_eglGetConfigAttrib)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetConfigAttrib");
-    _glfw.egl.GetConfigs = (PFN_eglGetConfigs)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetConfigs");
-    _glfw.egl.GetDisplay = (PFN_eglGetDisplay)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetDisplay");
-    _glfw.egl.GetError = (PFN_eglGetError)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetError");
-    _glfw.egl.Initialize = (PFN_eglInitialize)
-        _glfw_dlsym(_glfw.egl.handle, "eglInitialize");
-    _glfw.egl.Terminate = (PFN_eglTerminate)
-        _glfw_dlsym(_glfw.egl.handle, "eglTerminate");
-    _glfw.egl.BindAPI = (PFN_eglBindAPI)
-        _glfw_dlsym(_glfw.egl.handle, "eglBindAPI");
-    _glfw.egl.CreateContext = (PFN_eglCreateContext)
-        _glfw_dlsym(_glfw.egl.handle, "eglCreateContext");
-    _glfw.egl.DestroySurface = (PFN_eglDestroySurface)
-        _glfw_dlsym(_glfw.egl.handle, "eglDestroySurface");
-    _glfw.egl.DestroyContext = (PFN_eglDestroyContext)
-        _glfw_dlsym(_glfw.egl.handle, "eglDestroyContext");
-    _glfw.egl.CreateWindowSurface = (PFN_eglCreateWindowSurface)
-        _glfw_dlsym(_glfw.egl.handle, "eglCreateWindowSurface");
-    _glfw.egl.MakeCurrent = (PFN_eglMakeCurrent)
-        _glfw_dlsym(_glfw.egl.handle, "eglMakeCurrent");
-    _glfw.egl.SwapBuffers = (PFN_eglSwapBuffers)
-        _glfw_dlsym(_glfw.egl.handle, "eglSwapBuffers");
-    _glfw.egl.SwapInterval = (PFN_eglSwapInterval)
-        _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
-    _glfw.egl.QueryString = (PFN_eglQueryString)
-        _glfw_dlsym(_glfw.egl.handle, "eglQueryString");
-    _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
-        _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
-
-    if (!_glfw.egl.GetConfigAttrib ||
-        !_glfw.egl.GetConfigs ||
-        !_glfw.egl.GetDisplay ||
-        !_glfw.egl.GetError ||
-        !_glfw.egl.Initialize ||
-        !_glfw.egl.Terminate ||
-        !_glfw.egl.BindAPI ||
-        !_glfw.egl.CreateContext ||
-        !_glfw.egl.DestroySurface ||
-        !_glfw.egl.DestroyContext ||
-        !_glfw.egl.CreateWindowSurface ||
-        !_glfw.egl.MakeCurrent ||
-        !_glfw.egl.SwapBuffers ||
-        !_glfw.egl.SwapInterval ||
-        !_glfw.egl.QueryString ||
-        !_glfw.egl.GetProcAddress)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to load required entry points");
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
-    if (extensions && eglGetError() == EGL_SUCCESS)
-        _glfw.egl.EXT_client_extensions = GLFW_TRUE;
-
-    if (_glfw.egl.EXT_client_extensions)
-    {
-        _glfw.egl.EXT_platform_base =
-            _glfwStringInExtensionString("EGL_EXT_platform_base", extensions);
-        _glfw.egl.EXT_platform_x11 =
-            _glfwStringInExtensionString("EGL_EXT_platform_x11", extensions);
-        _glfw.egl.EXT_platform_wayland =
-            _glfwStringInExtensionString("EGL_EXT_platform_wayland", extensions);
-        _glfw.egl.ANGLE_platform_angle =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle", extensions);
-        _glfw.egl.ANGLE_platform_angle_opengl =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_opengl", extensions);
-        _glfw.egl.ANGLE_platform_angle_d3d =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_d3d", extensions);
-        _glfw.egl.ANGLE_platform_angle_vulkan =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_vulkan", extensions);
-        _glfw.egl.ANGLE_platform_angle_metal =
-            _glfwStringInExtensionString("EGL_ANGLE_platform_angle_metal", extensions);
-    }
-
-    if (_glfw.egl.EXT_platform_base)
-    {
-        _glfw.egl.GetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)
-            eglGetProcAddress("eglGetPlatformDisplayEXT");
-        _glfw.egl.CreatePlatformWindowSurfaceEXT = (PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)
-            eglGetProcAddress("eglCreatePlatformWindowSurfaceEXT");
-    }
-
-    _glfw.egl.platform = _glfwPlatformGetEGLPlatform(&attribs);
-    if (_glfw.egl.platform)
-    {
-        _glfw.egl.display =
-            eglGetPlatformDisplayEXT(_glfw.egl.platform,
-                                     _glfwPlatformGetEGLNativeDisplay(),
-                                     attribs);
-    }
-    else
-        _glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay());
-
-    free(attribs);
-
-    if (_glfw.egl.display == EGL_NO_DISPLAY)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "EGL: Failed to get EGL display: %s",
-                        getEGLErrorString(eglGetError()));
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "EGL: Failed to initialize EGL: %s",
-                        getEGLErrorString(eglGetError()));
-
-        _glfwTerminateEGL();
-        return GLFW_FALSE;
-    }
-
-    _glfw.egl.KHR_create_context =
-        extensionSupportedEGL("EGL_KHR_create_context");
-    _glfw.egl.KHR_create_context_no_error =
-        extensionSupportedEGL("EGL_KHR_create_context_no_error");
-    _glfw.egl.KHR_gl_colorspace =
-        extensionSupportedEGL("EGL_KHR_gl_colorspace");
-    _glfw.egl.KHR_get_all_proc_addresses =
-        extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
-    _glfw.egl.KHR_context_flush_control =
-        extensionSupportedEGL("EGL_KHR_context_flush_control");
-
-    return GLFW_TRUE;
-}
-
-// Terminate EGL
-//
-void _glfwTerminateEGL(void)
-{
-    if (_glfw.egl.display)
-    {
-        eglTerminate(_glfw.egl.display);
-        _glfw.egl.display = EGL_NO_DISPLAY;
-    }
-
-    if (_glfw.egl.handle)
-    {
-        _glfw_dlclose(_glfw.egl.handle);
-        _glfw.egl.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    EGLint attribs[40];
-    EGLConfig config;
-    EGLContext share = NULL;
-    EGLNativeWindowType native;
-    int index = 0;
-
-    if (!_glfw.egl.display)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: API not available");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.egl.handle;
-
-    if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "EGL: Failed to find a suitable EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (!eglBindAPI(EGL_OPENGL_ES_API))
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to bind OpenGL ES: %s",
-                            getEGLErrorString(eglGetError()));
-            return GLFW_FALSE;
-        }
-    }
-    else
-    {
-        if (!eglBindAPI(EGL_OPENGL_API))
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to bind OpenGL: %s",
-                            getEGLErrorString(eglGetError()));
-            return GLFW_FALSE;
-        }
-    }
-
-    if (_glfw.egl.KHR_create_context)
-    {
-        int mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR;
-        }
-
-        if (ctxconfig->debug)
-            flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
-        if (ctxconfig->robustness)
-        {
-            if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-            {
-                setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
-                          EGL_NO_RESET_NOTIFICATION_KHR);
-            }
-            else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-            {
-                setAttrib(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR,
-                          EGL_LOSE_CONTEXT_ON_RESET_KHR);
-            }
-
-            flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.egl.KHR_create_context_no_error)
-                setAttrib(EGL_CONTEXT_OPENGL_NO_ERROR_KHR, GLFW_TRUE);
-        }
-
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(EGL_CONTEXT_MAJOR_VERSION_KHR, ctxconfig->major);
-            setAttrib(EGL_CONTEXT_MINOR_VERSION_KHR, ctxconfig->minor);
-        }
-
-        if (mask)
-            setAttrib(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, mask);
-
-        if (flags)
-            setAttrib(EGL_CONTEXT_FLAGS_KHR, flags);
-    }
-    else
-    {
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-            setAttrib(EGL_CONTEXT_CLIENT_VERSION, ctxconfig->major);
-    }
-
-    if (_glfw.egl.KHR_context_flush_control)
-    {
-        if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-        {
-            setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
-                      EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR);
-        }
-        else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-        {
-            setAttrib(EGL_CONTEXT_RELEASE_BEHAVIOR_KHR,
-                      EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR);
-        }
-    }
-
-    setAttrib(EGL_NONE, EGL_NONE);
-
-    window->context.egl.handle = eglCreateContext(_glfw.egl.display,
-                                                  config, share, attribs);
-
-    if (window->context.egl.handle == EGL_NO_CONTEXT)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "EGL: Failed to create context: %s",
-                        getEGLErrorString(eglGetError()));
-        return GLFW_FALSE;
-    }
-
-    // Set up attributes for surface creation
-    index = 0;
-
-    if (fbconfig->sRGB)
-    {
-        if (_glfw.egl.KHR_gl_colorspace)
-            setAttrib(EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR);
-    }
-
-    setAttrib(EGL_NONE, EGL_NONE);
-
-    native = _glfwPlatformGetEGLNativeWindow(window);
-    // HACK: ANGLE does not implement eglCreatePlatformWindowSurfaceEXT
-    //       despite reporting EGL_EXT_platform_base
-    if (_glfw.egl.platform && _glfw.egl.platform != EGL_PLATFORM_ANGLE_ANGLE)
-    {
-        window->context.egl.surface =
-            eglCreatePlatformWindowSurfaceEXT(_glfw.egl.display, config, native, attribs);
-    }
-    else
-    {
-        window->context.egl.surface =
-            eglCreateWindowSurface(_glfw.egl.display, config, native, attribs);
-    }
-
-    if (window->context.egl.surface == EGL_NO_SURFACE)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to create window surface: %s",
-                        getEGLErrorString(eglGetError()));
-        return GLFW_FALSE;
-    }
-
-    window->context.egl.config = config;
-
-    // Load the appropriate client library
-    if (!_glfw.egl.KHR_get_all_proc_addresses)
-    {
-        int i;
-        const char** sonames;
-        const char* es1sonames[] =
-        {
-#if defined(_GLFW_GLESV1_LIBRARY)
-            _GLFW_GLESV1_LIBRARY,
-#elif defined(_GLFW_WIN32)
-            "GLESv1_CM.dll",
-            "libGLES_CM.dll",
-#elif defined(_GLFW_COCOA)
-            "libGLESv1_CM.dylib",
-#else
-            "libGLESv1_CM.so.1",
-            "libGLES_CM.so.1",
-#endif
-            NULL
-        };
-        const char* es2sonames[] =
-        {
-#if defined(_GLFW_GLESV2_LIBRARY)
-            _GLFW_GLESV2_LIBRARY,
-#elif defined(_GLFW_WIN32)
-            "GLESv2.dll",
-            "libGLESv2.dll",
-#elif defined(_GLFW_COCOA)
-            "libGLESv2.dylib",
-#elif defined(__CYGWIN__)
-            "libGLESv2-2.so",
-#else
-            "libGLESv2.so.2",
-#endif
-            NULL
-        };
-        const char* glsonames[] =
-        {
-#if defined(_GLFW_OPENGL_LIBRARY)
-            _GLFW_OPENGL_LIBRARY,
-#elif defined(_GLFW_WIN32)
-#elif defined(_GLFW_COCOA)
-#else
-            "libGL.so.1",
-#endif
-            NULL
-        };
-
-        if (ctxconfig->client == GLFW_OPENGL_ES_API)
-        {
-            if (ctxconfig->major == 1)
-                sonames = es1sonames;
-            else
-                sonames = es2sonames;
-        }
-        else
-            sonames = glsonames;
-
-        for (i = 0;  sonames[i];  i++)
-        {
-            // HACK: Match presence of lib prefix to increase chance of finding
-            //       a matching pair in the jungle that is Win32 EGL/GLES
-            if (_glfw.egl.prefix != (strncmp(sonames[i], "lib", 3) == 0))
-                continue;
-
-            window->context.egl.client = _glfw_dlopen(sonames[i]);
-            if (window->context.egl.client)
-                break;
-        }
-
-        if (!window->context.egl.client)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "EGL: Failed to load client library");
-            return GLFW_FALSE;
-        }
-    }
-
-    window->context.makeCurrent = makeContextCurrentEGL;
-    window->context.swapBuffers = swapBuffersEGL;
-    window->context.swapInterval = swapIntervalEGL;
-    window->context.extensionSupported = extensionSupportedEGL;
-    window->context.getProcAddress = getProcAddressEGL;
-    window->context.destroy = destroyContextEGL;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-// Returns the Visual and depth of the chosen EGLConfig
-//
-#if defined(_GLFW_X11)
-GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth)
-{
-    XVisualInfo* result;
-    XVisualInfo desired;
-    EGLConfig native;
-    EGLint visualID = 0, count = 0;
-    const long vimask = VisualScreenMask | VisualIDMask;
-
-    if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "EGL: Failed to find a suitable EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    eglGetConfigAttrib(_glfw.egl.display, native,
-                       EGL_NATIVE_VISUAL_ID, &visualID);
-
-    desired.screen = _glfw.x11.screen;
-    desired.visualid = visualID;
-
-    result = XGetVisualInfo(_glfw.x11.display, vimask, &desired, &count);
-    if (!result)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "EGL: Failed to retrieve Visual for EGLConfig");
-        return GLFW_FALSE;
-    }
-
-    *visual = result->visual;
-    *depth = result->depth;
-
-    XFree(result);
-    return GLFW_TRUE;
-}
-#endif // _GLFW_X11
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI EGLDisplay glfwGetEGLDisplay(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_DISPLAY);
-    return _glfw.egl.display;
-}
-
-GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_CONTEXT);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return EGL_NO_CONTEXT;
-    }
-
-    return window->context.egl.handle;
-}
-
-GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return EGL_NO_SURFACE;
-    }
-
-    return window->context.egl.surface;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/egl_context.h b/raylib_pi4_test/external/glfw/src/egl_context.h
deleted file mode 100644 (file)
index 9de424c..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-//========================================================================
-// GLFW 3.4 EGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#if defined(_GLFW_WIN32)
- #define EGLAPIENTRY __stdcall
-#else
- #define EGLAPIENTRY
-#endif
-
-#define EGL_SUCCESS 0x3000
-#define EGL_NOT_INITIALIZED 0x3001
-#define EGL_BAD_ACCESS 0x3002
-#define EGL_BAD_ALLOC 0x3003
-#define EGL_BAD_ATTRIBUTE 0x3004
-#define EGL_BAD_CONFIG 0x3005
-#define EGL_BAD_CONTEXT 0x3006
-#define EGL_BAD_CURRENT_SURFACE 0x3007
-#define EGL_BAD_DISPLAY 0x3008
-#define EGL_BAD_MATCH 0x3009
-#define EGL_BAD_NATIVE_PIXMAP 0x300a
-#define EGL_BAD_NATIVE_WINDOW 0x300b
-#define EGL_BAD_PARAMETER 0x300c
-#define EGL_BAD_SURFACE 0x300d
-#define EGL_CONTEXT_LOST 0x300e
-#define EGL_COLOR_BUFFER_TYPE 0x303f
-#define EGL_RGB_BUFFER 0x308e
-#define EGL_SURFACE_TYPE 0x3033
-#define EGL_WINDOW_BIT 0x0004
-#define EGL_RENDERABLE_TYPE 0x3040
-#define EGL_OPENGL_ES_BIT 0x0001
-#define EGL_OPENGL_ES2_BIT 0x0004
-#define EGL_OPENGL_BIT 0x0008
-#define EGL_ALPHA_SIZE 0x3021
-#define EGL_BLUE_SIZE 0x3022
-#define EGL_GREEN_SIZE 0x3023
-#define EGL_RED_SIZE 0x3024
-#define EGL_DEPTH_SIZE 0x3025
-#define EGL_STENCIL_SIZE 0x3026
-#define EGL_SAMPLES 0x3031
-#define EGL_OPENGL_ES_API 0x30a0
-#define EGL_OPENGL_API 0x30a2
-#define EGL_NONE 0x3038
-#define EGL_EXTENSIONS 0x3055
-#define EGL_CONTEXT_CLIENT_VERSION 0x3098
-#define EGL_NATIVE_VISUAL_ID 0x302e
-#define EGL_NO_SURFACE ((EGLSurface) 0)
-#define EGL_NO_DISPLAY ((EGLDisplay) 0)
-#define EGL_NO_CONTEXT ((EGLContext) 0)
-#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0)
-
-#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
-#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
-#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
-#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
-#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd
-#define EGL_NO_RESET_NOTIFICATION_KHR 0x31be
-#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf
-#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
-#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
-#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb
-#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd
-#define EGL_CONTEXT_FLAGS_KHR 0x30fc
-#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3
-#define EGL_GL_COLORSPACE_KHR 0x309d
-#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
-#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
-#define EGL_PLATFORM_X11_EXT 0x31d5
-#define EGL_PLATFORM_WAYLAND_EXT 0x31d8
-#define EGL_PLATFORM_ANGLE_ANGLE 0x3202
-#define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
-#define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d
-#define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e
-#define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207
-#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
-#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
-#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
-#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
-
-typedef int EGLint;
-typedef unsigned int EGLBoolean;
-typedef unsigned int EGLenum;
-typedef void* EGLConfig;
-typedef void* EGLContext;
-typedef void* EGLDisplay;
-typedef void* EGLSurface;
-
-typedef void* EGLNativeDisplayType;
-typedef void* EGLNativeWindowType;
-
-// EGL function pointer typedefs
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
-typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
-typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
-typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
-typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
-typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
-typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
-typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
-#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
-#define eglGetConfigs _glfw.egl.GetConfigs
-#define eglGetDisplay _glfw.egl.GetDisplay
-#define eglGetError _glfw.egl.GetError
-#define eglInitialize _glfw.egl.Initialize
-#define eglTerminate _glfw.egl.Terminate
-#define eglBindAPI _glfw.egl.BindAPI
-#define eglCreateContext _glfw.egl.CreateContext
-#define eglDestroySurface _glfw.egl.DestroySurface
-#define eglDestroyContext _glfw.egl.DestroyContext
-#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
-#define eglMakeCurrent _glfw.egl.MakeCurrent
-#define eglSwapBuffers _glfw.egl.SwapBuffers
-#define eglSwapInterval _glfw.egl.SwapInterval
-#define eglQueryString _glfw.egl.QueryString
-#define eglGetProcAddress _glfw.egl.GetProcAddress
-
-typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
-typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
-#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
-#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
-
-// EGL-specific per-context data
-//
-typedef struct _GLFWcontextEGL
-{
-   EGLConfig        config;
-   EGLContext       handle;
-   EGLSurface       surface;
-
-   void*            client;
-
-} _GLFWcontextEGL;
-
-// EGL-specific global data
-//
-typedef struct _GLFWlibraryEGL
-{
-    EGLenum         platform;
-    EGLDisplay      display;
-    EGLint          major, minor;
-    GLFWbool        prefix;
-
-    GLFWbool        KHR_create_context;
-    GLFWbool        KHR_create_context_no_error;
-    GLFWbool        KHR_gl_colorspace;
-    GLFWbool        KHR_get_all_proc_addresses;
-    GLFWbool        KHR_context_flush_control;
-    GLFWbool        EXT_client_extensions;
-    GLFWbool        EXT_platform_base;
-    GLFWbool        EXT_platform_x11;
-    GLFWbool        EXT_platform_wayland;
-    GLFWbool        ANGLE_platform_angle;
-    GLFWbool        ANGLE_platform_angle_opengl;
-    GLFWbool        ANGLE_platform_angle_d3d;
-    GLFWbool        ANGLE_platform_angle_vulkan;
-    GLFWbool        ANGLE_platform_angle_metal;
-
-    void*           handle;
-
-    PFN_eglGetConfigAttrib      GetConfigAttrib;
-    PFN_eglGetConfigs           GetConfigs;
-    PFN_eglGetDisplay           GetDisplay;
-    PFN_eglGetError             GetError;
-    PFN_eglInitialize           Initialize;
-    PFN_eglTerminate            Terminate;
-    PFN_eglBindAPI              BindAPI;
-    PFN_eglCreateContext        CreateContext;
-    PFN_eglDestroySurface       DestroySurface;
-    PFN_eglDestroyContext       DestroyContext;
-    PFN_eglCreateWindowSurface  CreateWindowSurface;
-    PFN_eglMakeCurrent          MakeCurrent;
-    PFN_eglSwapBuffers          SwapBuffers;
-    PFN_eglSwapInterval         SwapInterval;
-    PFN_eglQueryString          QueryString;
-    PFN_eglGetProcAddress       GetProcAddress;
-
-    PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
-    PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
-
-} _GLFWlibraryEGL;
-
-
-GLFWbool _glfwInitEGL(void);
-void _glfwTerminateEGL(void);
-GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-#if defined(_GLFW_X11)
-GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth);
-#endif /*_GLFW_X11*/
-
diff --git a/raylib_pi4_test/external/glfw/src/glfw.rc.in b/raylib_pi4_test/external/glfw/src/glfw.rc.in
deleted file mode 100644 (file)
index ac3460a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-
-#include <winver.h>
-
-VS_VERSION_INFO VERSIONINFO
-FILEVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
-PRODUCTVERSION @GLFW_VERSION_MAJOR@,@GLFW_VERSION_MINOR@,@GLFW_VERSION_PATCH@,0
-FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-FILEFLAGS 0
-FILEOS VOS_NT_WINDOWS32
-FILETYPE VFT_DLL
-FILESUBTYPE 0
-{
-    BLOCK "StringFileInfo"
-    {
-        BLOCK "040904B0"
-        {
-            VALUE "CompanyName", "GLFW"
-            VALUE "FileDescription", "GLFW @GLFW_VERSION@ DLL"
-            VALUE "FileVersion", "@GLFW_VERSION@"
-            VALUE "OriginalFilename", "glfw3.dll"
-            VALUE "ProductName", "GLFW"
-            VALUE "ProductVersion", "@GLFW_VERSION@"
-        }
-    }
-    BLOCK "VarFileInfo"
-    {
-        VALUE "Translation", 0x409, 1200
-    }
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/glfw_config.h.in b/raylib_pi4_test/external/glfw/src/glfw_config.h.in
deleted file mode 100644 (file)
index f4876da..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As glfw_config.h.in, this file is used by CMake to produce the
-// glfw_config.h configuration header file.  If you are adding a feature
-// requiring conditional compilation, this is where to add the macro.
-//========================================================================
-// As glfw_config.h, this file defines compile-time option macros for a
-// specific platform and development environment.  If you are using the
-// GLFW CMake files, modify glfw_config.h.in instead of this file.  If you
-// are using your own build system, make this file define the appropriate
-// macros in whatever way is suitable.
-//========================================================================
-
-// Define this to 1 if building GLFW for X11
-#cmakedefine _GLFW_X11
-// Define this to 1 if building GLFW for Win32
-#cmakedefine _GLFW_WIN32
-// Define this to 1 if building GLFW for Cocoa
-#cmakedefine _GLFW_COCOA
-// Define this to 1 if building GLFW for Wayland
-#cmakedefine _GLFW_WAYLAND
-// Define this to 1 if building GLFW for OSMesa
-#cmakedefine _GLFW_OSMESA
-
-// Define this to 1 to use Vulkan loader linked statically into application
-#cmakedefine _GLFW_VULKAN_STATIC
-
-// Define this to 1 to force use of high-performance GPU on hybrid systems
-#cmakedefine _GLFW_USE_HYBRID_HPG
-
-// Define this to 1 if xkbcommon supports the compose key
-#cmakedefine HAVE_XKBCOMMON_COMPOSE_H
-// Define this to 1 if the libc supports memfd_create()
-#cmakedefine HAVE_MEMFD_CREATE
-
diff --git a/raylib_pi4_test/external/glfw/src/glx_context.c b/raylib_pi4_test/external/glfw/src/glx_context.c
deleted file mode 100644 (file)
index 7ccd137..0000000
+++ /dev/null
@@ -1,698 +0,0 @@
-//========================================================================
-// GLFW 3.4 GLX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#ifndef GLXBadProfileARB
- #define GLXBadProfileARB 13
-#endif
-
-
-// Returns the specified attribute of the specified GLXFBConfig
-//
-static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
-{
-    int value;
-    glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
-    return value;
-}
-
-// Return the GLXFBConfig most closely matching the specified hints
-//
-static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
-                                  GLXFBConfig* result)
-{
-    GLXFBConfig* nativeConfigs;
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, nativeCount, usableCount;
-    const char* vendor;
-    GLFWbool trustWindowBit = GLFW_TRUE;
-
-    // HACK: This is a (hopefully temporary) workaround for Chromium
-    //       (VirtualBox GL) not setting the window bit on any GLXFBConfigs
-    vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
-    if (vendor && strcmp(vendor, "Chromium") == 0)
-        trustWindowBit = GLFW_FALSE;
-
-    nativeConfigs =
-        glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
-    if (!nativeConfigs || !nativeCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
-        return GLFW_FALSE;
-    }
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-    usableCount = 0;
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        const GLXFBConfig n = nativeConfigs[i];
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-
-        // Only consider RGBA GLXFBConfigs
-        if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
-            continue;
-
-        // Only consider window GLXFBConfigs
-        if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
-        {
-            if (trustWindowBit)
-                continue;
-        }
-
-        if (desired->transparent)
-        {
-            XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
-            if (vi)
-            {
-                u->transparent = _glfwIsVisualTransparentX11(vi->visual);
-                XFree(vi);
-            }
-        }
-
-        u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
-        u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
-        u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
-
-        u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
-        u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
-        u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
-
-        u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
-        u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
-        u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
-        u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
-
-        u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
-
-        if (getGLXFBConfigAttrib(n, GLX_STEREO))
-            u->stereo = GLFW_TRUE;
-        if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
-            u->doublebuffer = GLFW_TRUE;
-
-        if (_glfw.glx.ARB_multisample)
-            u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
-
-        if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
-            u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
-
-        u->handle = (uintptr_t) n;
-        usableCount++;
-    }
-
-    closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
-    if (closest)
-        *result = (GLXFBConfig) closest->handle;
-
-    XFree(nativeConfigs);
-    free(usableConfigs);
-
-    return closest != NULL;
-}
-
-// Create the OpenGL context using legacy API
-//
-static GLXContext createLegacyContextGLX(_GLFWwindow* window,
-                                         GLXFBConfig fbconfig,
-                                         GLXContext share)
-{
-    return glXCreateNewContext(_glfw.x11.display,
-                               fbconfig,
-                               GLX_RGBA_TYPE,
-                               share,
-                               True);
-}
-
-static void makeContextCurrentGLX(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (!glXMakeCurrent(_glfw.x11.display,
-                            window->context.glx.window,
-                            window->context.glx.handle))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "GLX: Failed to make context current");
-            return;
-        }
-    }
-    else
-    {
-        if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "GLX: Failed to clear current context");
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static void swapBuffersGLX(_GLFWwindow* window)
-{
-    glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
-}
-
-static void swapIntervalGLX(int interval)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    if (_glfw.glx.EXT_swap_control)
-    {
-        _glfw.glx.SwapIntervalEXT(_glfw.x11.display,
-                                  window->context.glx.window,
-                                  interval);
-    }
-    else if (_glfw.glx.MESA_swap_control)
-        _glfw.glx.SwapIntervalMESA(interval);
-    else if (_glfw.glx.SGI_swap_control)
-    {
-        if (interval > 0)
-            _glfw.glx.SwapIntervalSGI(interval);
-    }
-}
-
-static int extensionSupportedGLX(const char* extension)
-{
-    const char* extensions =
-        glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
-    if (extensions)
-    {
-        if (_glfwStringInExtensionString(extension, extensions))
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressGLX(const char* procname)
-{
-    if (_glfw.glx.GetProcAddress)
-        return _glfw.glx.GetProcAddress((const GLubyte*) procname);
-    else if (_glfw.glx.GetProcAddressARB)
-        return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
-    else
-        return _glfw_dlsym(_glfw.glx.handle, procname);
-}
-
-static void destroyContextGLX(_GLFWwindow* window)
-{
-    if (window->context.glx.window)
-    {
-        glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
-        window->context.glx.window = None;
-    }
-
-    if (window->context.glx.handle)
-    {
-        glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
-        window->context.glx.handle = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize GLX
-//
-GLFWbool _glfwInitGLX(void)
-{
-    int i;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_GLX_LIBRARY)
-        _GLFW_GLX_LIBRARY,
-#elif defined(__CYGWIN__)
-        "libGL-1.so",
-#else
-        "libGL.so.1",
-        "libGL.so",
-#endif
-        NULL
-    };
-
-    if (_glfw.glx.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.glx.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.glx.handle)
-            break;
-    }
-
-    if (!_glfw.glx.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
-        return GLFW_FALSE;
-    }
-
-    _glfw.glx.GetFBConfigs =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigs");
-    _glfw.glx.GetFBConfigAttrib =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
-    _glfw.glx.GetClientString =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetClientString");
-    _glfw.glx.QueryExtension =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryExtension");
-    _glfw.glx.QueryVersion =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryVersion");
-    _glfw.glx.DestroyContext =
-        _glfw_dlsym(_glfw.glx.handle, "glXDestroyContext");
-    _glfw.glx.MakeCurrent =
-        _glfw_dlsym(_glfw.glx.handle, "glXMakeCurrent");
-    _glfw.glx.SwapBuffers =
-        _glfw_dlsym(_glfw.glx.handle, "glXSwapBuffers");
-    _glfw.glx.QueryExtensionsString =
-        _glfw_dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
-    _glfw.glx.CreateNewContext =
-        _glfw_dlsym(_glfw.glx.handle, "glXCreateNewContext");
-    _glfw.glx.CreateWindow =
-        _glfw_dlsym(_glfw.glx.handle, "glXCreateWindow");
-    _glfw.glx.DestroyWindow =
-        _glfw_dlsym(_glfw.glx.handle, "glXDestroyWindow");
-    _glfw.glx.GetProcAddress =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddress");
-    _glfw.glx.GetProcAddressARB =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
-    _glfw.glx.GetVisualFromFBConfig =
-        _glfw_dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
-
-    if (!_glfw.glx.GetFBConfigs ||
-        !_glfw.glx.GetFBConfigAttrib ||
-        !_glfw.glx.GetClientString ||
-        !_glfw.glx.QueryExtension ||
-        !_glfw.glx.QueryVersion ||
-        !_glfw.glx.DestroyContext ||
-        !_glfw.glx.MakeCurrent ||
-        !_glfw.glx.SwapBuffers ||
-        !_glfw.glx.QueryExtensionsString ||
-        !_glfw.glx.CreateNewContext ||
-        !_glfw.glx.CreateWindow ||
-        !_glfw.glx.DestroyWindow ||
-        !_glfw.glx.GetProcAddress ||
-        !_glfw.glx.GetProcAddressARB ||
-        !_glfw.glx.GetVisualFromFBConfig)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "GLX: Failed to load required entry points");
-        return GLFW_FALSE;
-    }
-
-    if (!glXQueryExtension(_glfw.x11.display,
-                           &_glfw.glx.errorBase,
-                           &_glfw.glx.eventBase))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
-        return GLFW_FALSE;
-    }
-
-    if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "GLX: Failed to query GLX version");
-        return GLFW_FALSE;
-    }
-
-    if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "GLX: GLX version 1.3 is required");
-        return GLFW_FALSE;
-    }
-
-    if (extensionSupportedGLX("GLX_EXT_swap_control"))
-    {
-        _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
-            getProcAddressGLX("glXSwapIntervalEXT");
-
-        if (_glfw.glx.SwapIntervalEXT)
-            _glfw.glx.EXT_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_SGI_swap_control"))
-    {
-        _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
-            getProcAddressGLX("glXSwapIntervalSGI");
-
-        if (_glfw.glx.SwapIntervalSGI)
-            _glfw.glx.SGI_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_MESA_swap_control"))
-    {
-        _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
-            getProcAddressGLX("glXSwapIntervalMESA");
-
-        if (_glfw.glx.SwapIntervalMESA)
-            _glfw.glx.MESA_swap_control = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_ARB_multisample"))
-        _glfw.glx.ARB_multisample = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
-        _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
-        _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context"))
-    {
-        _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
-            getProcAddressGLX("glXCreateContextAttribsARB");
-
-        if (_glfw.glx.CreateContextAttribsARB)
-            _glfw.glx.ARB_create_context = GLFW_TRUE;
-    }
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
-        _glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
-        _glfw.glx.ARB_create_context_profile = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
-        _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
-        _glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
-
-    if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
-        _glfw.glx.ARB_context_flush_control = GLFW_TRUE;
-
-    return GLFW_TRUE;
-}
-
-// Terminate GLX
-//
-void _glfwTerminateGLX(void)
-{
-    // NOTE: This function must not call any X11 functions, as it is called
-    //       after XCloseDisplay (see _glfwPlatformTerminate for details)
-
-    if (_glfw.glx.handle)
-    {
-        _glfw_dlclose(_glfw.glx.handle);
-        _glfw.glx.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    int attribs[40];
-    GLXFBConfig native = NULL;
-    GLXContext share = NULL;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.glx.handle;
-
-    if (!chooseGLXFBConfig(fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "GLX: Failed to find a suitable GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        if (!_glfw.glx.ARB_create_context ||
-            !_glfw.glx.ARB_create_context_profile ||
-            !_glfw.glx.EXT_create_context_es2_profile)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->forward)
-    {
-        if (!_glfw.glx.ARB_create_context)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (ctxconfig->profile)
-    {
-        if (!_glfw.glx.ARB_create_context ||
-            !_glfw.glx.ARB_create_context_profile)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    _glfwGrabErrorHandlerX11();
-
-    if (_glfw.glx.ARB_create_context)
-    {
-        int index = 0, mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-        }
-        else
-            mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
-
-        if (ctxconfig->debug)
-            flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
-
-        if (ctxconfig->robustness)
-        {
-            if (_glfw.glx.ARB_create_context_robustness)
-            {
-                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-                {
-                    setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              GLX_NO_RESET_NOTIFICATION_ARB);
-                }
-                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                {
-                    setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              GLX_LOSE_CONTEXT_ON_RESET_ARB);
-                }
-
-                flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-            }
-        }
-
-        if (ctxconfig->release)
-        {
-            if (_glfw.glx.ARB_context_flush_control)
-            {
-                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-                {
-                    setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
-                }
-                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-                {
-                    setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
-                }
-            }
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.glx.ARB_create_context_no_error)
-                setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
-        }
-
-        // NOTE: Only request an explicitly versioned context when necessary, as
-        //       explicitly requesting version 1.0 does not always return the
-        //       highest version supported by the driver
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
-            setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
-        }
-
-        if (mask)
-            setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
-
-        if (flags)
-            setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
-
-        setAttrib(None, None);
-
-        window->context.glx.handle =
-            _glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
-                                              native,
-                                              share,
-                                              True,
-                                              attribs);
-
-        // HACK: This is a fallback for broken versions of the Mesa
-        //       implementation of GLX_ARB_create_context_profile that fail
-        //       default 1.0 context creation with a GLXBadProfileARB error in
-        //       violation of the extension spec
-        if (!window->context.glx.handle)
-        {
-            if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
-                ctxconfig->client == GLFW_OPENGL_API &&
-                ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
-                ctxconfig->forward == GLFW_FALSE)
-            {
-                window->context.glx.handle =
-                    createLegacyContextGLX(window, native, share);
-            }
-        }
-    }
-    else
-    {
-        window->context.glx.handle =
-            createLegacyContextGLX(window, native, share);
-    }
-
-    _glfwReleaseErrorHandlerX11();
-
-    if (!window->context.glx.handle)
-    {
-        _glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
-        return GLFW_FALSE;
-    }
-
-    window->context.glx.window =
-        glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
-    if (!window->context.glx.window)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    window->context.makeCurrent = makeContextCurrentGLX;
-    window->context.swapBuffers = swapBuffersGLX;
-    window->context.swapInterval = swapIntervalGLX;
-    window->context.extensionSupported = extensionSupportedGLX;
-    window->context.getProcAddress = getProcAddressGLX;
-    window->context.destroy = destroyContextGLX;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-// Returns the Visual and depth of the chosen GLXFBConfig
-//
-GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth)
-{
-    GLXFBConfig native;
-    XVisualInfo* result;
-
-    if (!chooseGLXFBConfig(fbconfig, &native))
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "GLX: Failed to find a suitable GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
-    if (!result)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "GLX: Failed to retrieve Visual for GLXFBConfig");
-        return GLFW_FALSE;
-    }
-
-    *visual = result->visual;
-    *depth  = result->depth;
-
-    XFree(result);
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.glx.handle;
-}
-
-GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return None;
-    }
-
-    return window->context.glx.window;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/glx_context.h b/raylib_pi4_test/external/glfw/src/glx_context.h
deleted file mode 100644 (file)
index 94f07e2..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-//========================================================================
-// GLFW 3.4 GLX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define GLX_VENDOR 1
-#define GLX_RGBA_BIT 0x00000001
-#define GLX_WINDOW_BIT 0x00000001
-#define GLX_DRAWABLE_TYPE 0x8010
-#define GLX_RENDER_TYPE 0x8011
-#define GLX_RGBA_TYPE 0x8014
-#define GLX_DOUBLEBUFFER 5
-#define GLX_STEREO 6
-#define GLX_AUX_BUFFERS 7
-#define GLX_RED_SIZE 8
-#define GLX_GREEN_SIZE 9
-#define GLX_BLUE_SIZE 10
-#define GLX_ALPHA_SIZE 11
-#define GLX_DEPTH_SIZE 12
-#define GLX_STENCIL_SIZE 13
-#define GLX_ACCUM_RED_SIZE 14
-#define GLX_ACCUM_GREEN_SIZE 15
-#define GLX_ACCUM_BLUE_SIZE 16
-#define GLX_ACCUM_ALPHA_SIZE 17
-#define GLX_SAMPLES 0x186a1
-#define GLX_VISUAL_ID 0x800b
-
-#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
-#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
-#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
-#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define GLX_CONTEXT_FLAGS_ARB 0x2094
-#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
-#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
-#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
-#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
-
-typedef XID GLXWindow;
-typedef XID GLXDrawable;
-typedef struct __GLXFBConfig* GLXFBConfig;
-typedef struct __GLXcontext* GLXContext;
-typedef void (*__GLXextproc)(void);
-
-typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
-typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
-typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
-typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
-typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
-typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
-typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
-typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
-typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
-typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
-typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
-typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
-typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
-typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
-typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
-
-typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
-typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
-typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
-
-// libGL.so function pointer typedefs
-#define glXGetFBConfigs _glfw.glx.GetFBConfigs
-#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
-#define glXGetClientString _glfw.glx.GetClientString
-#define glXQueryExtension _glfw.glx.QueryExtension
-#define glXQueryVersion _glfw.glx.QueryVersion
-#define glXDestroyContext _glfw.glx.DestroyContext
-#define glXMakeCurrent _glfw.glx.MakeCurrent
-#define glXSwapBuffers _glfw.glx.SwapBuffers
-#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
-#define glXCreateNewContext _glfw.glx.CreateNewContext
-#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
-#define glXCreateWindow _glfw.glx.CreateWindow
-#define glXDestroyWindow _glfw.glx.DestroyWindow
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextGLX glx
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryGLX glx
-
-
-// GLX-specific per-context data
-//
-typedef struct _GLFWcontextGLX
-{
-    GLXContext      handle;
-    GLXWindow       window;
-
-} _GLFWcontextGLX;
-
-// GLX-specific global data
-//
-typedef struct _GLFWlibraryGLX
-{
-    int             major, minor;
-    int             eventBase;
-    int             errorBase;
-
-    // dlopen handle for libGL.so.1
-    void*           handle;
-
-    // GLX 1.3 functions
-    PFNGLXGETFBCONFIGSPROC              GetFBConfigs;
-    PFNGLXGETFBCONFIGATTRIBPROC         GetFBConfigAttrib;
-    PFNGLXGETCLIENTSTRINGPROC           GetClientString;
-    PFNGLXQUERYEXTENSIONPROC            QueryExtension;
-    PFNGLXQUERYVERSIONPROC              QueryVersion;
-    PFNGLXDESTROYCONTEXTPROC            DestroyContext;
-    PFNGLXMAKECURRENTPROC               MakeCurrent;
-    PFNGLXSWAPBUFFERSPROC               SwapBuffers;
-    PFNGLXQUERYEXTENSIONSSTRINGPROC     QueryExtensionsString;
-    PFNGLXCREATENEWCONTEXTPROC          CreateNewContext;
-    PFNGLXGETVISUALFROMFBCONFIGPROC     GetVisualFromFBConfig;
-    PFNGLXCREATEWINDOWPROC              CreateWindow;
-    PFNGLXDESTROYWINDOWPROC             DestroyWindow;
-
-    // GLX 1.4 and extension functions
-    PFNGLXGETPROCADDRESSPROC            GetProcAddress;
-    PFNGLXGETPROCADDRESSPROC            GetProcAddressARB;
-    PFNGLXSWAPINTERVALSGIPROC           SwapIntervalSGI;
-    PFNGLXSWAPINTERVALEXTPROC           SwapIntervalEXT;
-    PFNGLXSWAPINTERVALMESAPROC          SwapIntervalMESA;
-    PFNGLXCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;
-    GLFWbool        SGI_swap_control;
-    GLFWbool        EXT_swap_control;
-    GLFWbool        MESA_swap_control;
-    GLFWbool        ARB_multisample;
-    GLFWbool        ARB_framebuffer_sRGB;
-    GLFWbool        EXT_framebuffer_sRGB;
-    GLFWbool        ARB_create_context;
-    GLFWbool        ARB_create_context_profile;
-    GLFWbool        ARB_create_context_robustness;
-    GLFWbool        EXT_create_context_es2_profile;
-    GLFWbool        ARB_create_context_no_error;
-    GLFWbool        ARB_context_flush_control;
-
-} _GLFWlibraryGLX;
-
-GLFWbool _glfwInitGLX(void);
-void _glfwTerminateGLX(void);
-GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-void _glfwDestroyContextGLX(_GLFWwindow* window);
-GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig,
-                              Visual** visual, int* depth);
-
diff --git a/raylib_pi4_test/external/glfw/src/init.c b/raylib_pi4_test/external/glfw/src/init.c
deleted file mode 100644 (file)
index a7b5af6..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-#include "mappings.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <assert.h>
-
-
-// The global variables below comprise all mutable global data in GLFW
-//
-// Any other global variable is a bug
-
-// Global state shared between compilation units of GLFW
-//
-_GLFWlibrary _glfw = { GLFW_FALSE };
-
-// These are outside of _glfw so they can be used before initialization and
-// after termination
-//
-static _GLFWerror _glfwMainThreadError;
-static GLFWerrorfun _glfwErrorCallback;
-static _GLFWinitconfig _glfwInitHints =
-{
-    GLFW_TRUE,      // hat buttons
-    GLFW_ANGLE_PLATFORM_TYPE_NONE, // ANGLE backend
-    {
-        GLFW_TRUE,  // macOS menu bar
-        GLFW_TRUE   // macOS bundle chdir
-    }
-};
-
-// Terminate the library
-//
-static void terminate(void)
-{
-    int i;
-
-    memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
-
-    while (_glfw.windowListHead)
-        glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
-
-    while (_glfw.cursorListHead)
-        glfwDestroyCursor((GLFWcursor*) _glfw.cursorListHead);
-
-    for (i = 0;  i < _glfw.monitorCount;  i++)
-    {
-        _GLFWmonitor* monitor = _glfw.monitors[i];
-        if (monitor->originalRamp.size)
-            _glfwPlatformSetGammaRamp(monitor, &monitor->originalRamp);
-        _glfwFreeMonitor(monitor);
-    }
-
-    free(_glfw.monitors);
-    _glfw.monitors = NULL;
-    _glfw.monitorCount = 0;
-
-    free(_glfw.mappings);
-    _glfw.mappings = NULL;
-    _glfw.mappingCount = 0;
-
-    _glfwTerminateVulkan();
-    _glfwPlatformTerminateJoysticks();
-    _glfwPlatformTerminate();
-
-    _glfw.initialized = GLFW_FALSE;
-
-    while (_glfw.errorListHead)
-    {
-        _GLFWerror* error = _glfw.errorListHead;
-        _glfw.errorListHead = error->next;
-        free(error);
-    }
-
-    _glfwPlatformDestroyTls(&_glfw.contextSlot);
-    _glfwPlatformDestroyTls(&_glfw.errorSlot);
-    _glfwPlatformDestroyMutex(&_glfw.errorLock);
-
-    memset(&_glfw, 0, sizeof(_glfw));
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-char* _glfw_strdup(const char* source)
-{
-    const size_t length = strlen(source);
-    char* result = calloc(length + 1, 1);
-    strcpy(result, source);
-    return result;
-}
-
-float _glfw_fminf(float a, float b)
-{
-    if (a != a)
-        return b;
-    else if (b != b)
-        return a;
-    else if (a < b)
-        return a;
-    else
-        return b;
-}
-
-float _glfw_fmaxf(float a, float b)
-{
-    if (a != a)
-        return b;
-    else if (b != b)
-        return a;
-    else if (a > b)
-        return a;
-    else
-        return b;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of an error
-//
-void _glfwInputError(int code, const char* format, ...)
-{
-    _GLFWerror* error;
-    char description[_GLFW_MESSAGE_SIZE];
-
-    if (format)
-    {
-        va_list vl;
-
-        va_start(vl, format);
-        vsnprintf(description, sizeof(description), format, vl);
-        va_end(vl);
-
-        description[sizeof(description) - 1] = '\0';
-    }
-    else
-    {
-        if (code == GLFW_NOT_INITIALIZED)
-            strcpy(description, "The GLFW library is not initialized");
-        else if (code == GLFW_NO_CURRENT_CONTEXT)
-            strcpy(description, "There is no current context");
-        else if (code == GLFW_INVALID_ENUM)
-            strcpy(description, "Invalid argument for enum parameter");
-        else if (code == GLFW_INVALID_VALUE)
-            strcpy(description, "Invalid value for parameter");
-        else if (code == GLFW_OUT_OF_MEMORY)
-            strcpy(description, "Out of memory");
-        else if (code == GLFW_API_UNAVAILABLE)
-            strcpy(description, "The requested API is unavailable");
-        else if (code == GLFW_VERSION_UNAVAILABLE)
-            strcpy(description, "The requested API version is unavailable");
-        else if (code == GLFW_PLATFORM_ERROR)
-            strcpy(description, "A platform-specific error occurred");
-        else if (code == GLFW_FORMAT_UNAVAILABLE)
-            strcpy(description, "The requested format is unavailable");
-        else if (code == GLFW_NO_WINDOW_CONTEXT)
-            strcpy(description, "The specified window has no context");
-        else if (code == GLFW_CURSOR_UNAVAILABLE)
-            strcpy(description, "The specified cursor shape is unavailable");
-        else if (code == GLFW_FEATURE_UNAVAILABLE)
-            strcpy(description, "The requested feature cannot be implemented for this platform");
-        else if (code == GLFW_FEATURE_UNIMPLEMENTED)
-            strcpy(description, "The requested feature has not yet been implemented for this platform");
-        else
-            strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
-    }
-
-    if (_glfw.initialized)
-    {
-        error = _glfwPlatformGetTls(&_glfw.errorSlot);
-        if (!error)
-        {
-            error = calloc(1, sizeof(_GLFWerror));
-            _glfwPlatformSetTls(&_glfw.errorSlot, error);
-            _glfwPlatformLockMutex(&_glfw.errorLock);
-            error->next = _glfw.errorListHead;
-            _glfw.errorListHead = error;
-            _glfwPlatformUnlockMutex(&_glfw.errorLock);
-        }
-    }
-    else
-        error = &_glfwMainThreadError;
-
-    error->code = code;
-    strcpy(error->description, description);
-
-    if (_glfwErrorCallback)
-        _glfwErrorCallback(code, description);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwInit(void)
-{
-    if (_glfw.initialized)
-        return GLFW_TRUE;
-
-    memset(&_glfw, 0, sizeof(_glfw));
-    _glfw.hints.init = _glfwInitHints;
-
-    if (!_glfwPlatformInit())
-    {
-        terminate();
-        return GLFW_FALSE;
-    }
-
-    if (!_glfwPlatformCreateMutex(&_glfw.errorLock) ||
-        !_glfwPlatformCreateTls(&_glfw.errorSlot) ||
-        !_glfwPlatformCreateTls(&_glfw.contextSlot))
-    {
-        terminate();
-        return GLFW_FALSE;
-    }
-
-    _glfwPlatformSetTls(&_glfw.errorSlot, &_glfwMainThreadError);
-
-    _glfw.initialized = GLFW_TRUE;
-    _glfw.timer.offset = _glfwPlatformGetTimerValue();
-
-    glfwDefaultWindowHints();
-
-    {
-        int i;
-
-        for (i = 0;  _glfwDefaultMappings[i];  i++)
-        {
-            if (!glfwUpdateGamepadMappings(_glfwDefaultMappings[i]))
-            {
-                terminate();
-                return GLFW_FALSE;
-            }
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI void glfwTerminate(void)
-{
-    if (!_glfw.initialized)
-        return;
-
-    terminate();
-}
-
-GLFWAPI void glfwInitHint(int hint, int value)
-{
-    switch (hint)
-    {
-        case GLFW_JOYSTICK_HAT_BUTTONS:
-            _glfwInitHints.hatButtons = value;
-            return;
-        case GLFW_ANGLE_PLATFORM_TYPE:
-            _glfwInitHints.angleType = value;
-            return;
-        case GLFW_COCOA_CHDIR_RESOURCES:
-            _glfwInitHints.ns.chdir = value;
-            return;
-        case GLFW_COCOA_MENUBAR:
-            _glfwInitHints.ns.menubar = value;
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM,
-                    "Invalid init hint 0x%08X", hint);
-}
-
-GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
-{
-    if (major != NULL)
-        *major = GLFW_VERSION_MAJOR;
-    if (minor != NULL)
-        *minor = GLFW_VERSION_MINOR;
-    if (rev != NULL)
-        *rev = GLFW_VERSION_REVISION;
-}
-
-GLFWAPI const char* glfwGetVersionString(void)
-{
-    return _glfwPlatformGetVersionString();
-}
-
-GLFWAPI int glfwGetError(const char** description)
-{
-    _GLFWerror* error;
-    int code = GLFW_NO_ERROR;
-
-    if (description)
-        *description = NULL;
-
-    if (_glfw.initialized)
-        error = _glfwPlatformGetTls(&_glfw.errorSlot);
-    else
-        error = &_glfwMainThreadError;
-
-    if (error)
-    {
-        code = error->code;
-        error->code = GLFW_NO_ERROR;
-        if (description && code)
-            *description = error->description;
-    }
-
-    return code;
-}
-
-GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
-{
-    _GLFW_SWAP_POINTERS(_glfwErrorCallback, cbfun);
-    return cbfun;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/input.c b/raylib_pi4_test/external/glfw/src/input.c
deleted file mode 100644 (file)
index 226f835..0000000
+++ /dev/null
@@ -1,1407 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <float.h>
-#include <math.h>
-#include <stdlib.h>
-#include <string.h>
-
-// Internal key state used for sticky keys
-#define _GLFW_STICK 3
-
-// Internal constants for gamepad mapping source types
-#define _GLFW_JOYSTICK_AXIS     1
-#define _GLFW_JOYSTICK_BUTTON   2
-#define _GLFW_JOYSTICK_HATBIT   3
-
-// Initializes the platform joystick API if it has not been already
-//
-static GLFWbool initJoysticks(void)
-{
-    if (!_glfw.joysticksInitialized)
-    {
-        if (!_glfwPlatformInitJoysticks())
-        {
-            _glfwPlatformTerminateJoysticks();
-            return GLFW_FALSE;
-        }
-    }
-
-    return _glfw.joysticksInitialized = GLFW_TRUE;
-}
-
-// Finds a mapping based on joystick GUID
-//
-static _GLFWmapping* findMapping(const char* guid)
-{
-    int i;
-
-    for (i = 0;  i < _glfw.mappingCount;  i++)
-    {
-        if (strcmp(_glfw.mappings[i].guid, guid) == 0)
-            return _glfw.mappings + i;
-    }
-
-    return NULL;
-}
-
-// Checks whether a gamepad mapping element is present in the hardware
-//
-static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
-                                          const _GLFWjoystick* js)
-{
-    if (e->type == _GLFW_JOYSTICK_HATBIT && (e->index >> 4) >= js->hatCount)
-        return GLFW_FALSE;
-    else if (e->type == _GLFW_JOYSTICK_BUTTON && e->index >= js->buttonCount)
-        return GLFW_FALSE;
-    else if (e->type == _GLFW_JOYSTICK_AXIS && e->index >= js->axisCount)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-// Finds a mapping based on joystick GUID and verifies element indices
-//
-static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
-{
-    _GLFWmapping* mapping = findMapping(js->guid);
-    if (mapping)
-    {
-        int i;
-
-        for (i = 0;  i <= GLFW_GAMEPAD_BUTTON_LAST;  i++)
-        {
-            if (!isValidElementForJoystick(mapping->buttons + i, js))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Invalid button in gamepad mapping %s (%s)",
-                                mapping->guid,
-                                mapping->name);
-                return NULL;
-            }
-        }
-
-        for (i = 0;  i <= GLFW_GAMEPAD_AXIS_LAST;  i++)
-        {
-            if (!isValidElementForJoystick(mapping->axes + i, js))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "Invalid axis in gamepad mapping %s (%s)",
-                                mapping->guid,
-                                mapping->name);
-                return NULL;
-            }
-        }
-    }
-
-    return mapping;
-}
-
-// Parses an SDL_GameControllerDB line and adds it to the mapping list
-//
-static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
-{
-    const char* c = string;
-    size_t i, length;
-    struct
-    {
-        const char* name;
-        _GLFWmapelement* element;
-    } fields[] =
-    {
-        { "platform",      NULL },
-        { "a",             mapping->buttons + GLFW_GAMEPAD_BUTTON_A },
-        { "b",             mapping->buttons + GLFW_GAMEPAD_BUTTON_B },
-        { "x",             mapping->buttons + GLFW_GAMEPAD_BUTTON_X },
-        { "y",             mapping->buttons + GLFW_GAMEPAD_BUTTON_Y },
-        { "back",          mapping->buttons + GLFW_GAMEPAD_BUTTON_BACK },
-        { "start",         mapping->buttons + GLFW_GAMEPAD_BUTTON_START },
-        { "guide",         mapping->buttons + GLFW_GAMEPAD_BUTTON_GUIDE },
-        { "leftshoulder",  mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_BUMPER },
-        { "rightshoulder", mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER },
-        { "leftstick",     mapping->buttons + GLFW_GAMEPAD_BUTTON_LEFT_THUMB },
-        { "rightstick",    mapping->buttons + GLFW_GAMEPAD_BUTTON_RIGHT_THUMB },
-        { "dpup",          mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_UP },
-        { "dpright",       mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_RIGHT },
-        { "dpdown",        mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_DOWN },
-        { "dpleft",        mapping->buttons + GLFW_GAMEPAD_BUTTON_DPAD_LEFT },
-        { "lefttrigger",   mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_TRIGGER },
-        { "righttrigger",  mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER },
-        { "leftx",         mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_X },
-        { "lefty",         mapping->axes + GLFW_GAMEPAD_AXIS_LEFT_Y },
-        { "rightx",        mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_X },
-        { "righty",        mapping->axes + GLFW_GAMEPAD_AXIS_RIGHT_Y }
-    };
-
-    length = strcspn(c, ",");
-    if (length != 32 || c[length] != ',')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, NULL);
-        return GLFW_FALSE;
-    }
-
-    memcpy(mapping->guid, c, length);
-    c += length + 1;
-
-    length = strcspn(c, ",");
-    if (length >= sizeof(mapping->name) || c[length] != ',')
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, NULL);
-        return GLFW_FALSE;
-    }
-
-    memcpy(mapping->name, c, length);
-    c += length + 1;
-
-    while (*c)
-    {
-        // TODO: Implement output modifiers
-        if (*c == '+' || *c == '-')
-            return GLFW_FALSE;
-
-        for (i = 0;  i < sizeof(fields) / sizeof(fields[0]);  i++)
-        {
-            length = strlen(fields[i].name);
-            if (strncmp(c, fields[i].name, length) != 0 || c[length] != ':')
-                continue;
-
-            c += length + 1;
-
-            if (fields[i].element)
-            {
-                _GLFWmapelement* e = fields[i].element;
-                int8_t minimum = -1;
-                int8_t maximum = 1;
-
-                if (*c == '+')
-                {
-                    minimum = 0;
-                    c += 1;
-                }
-                else if (*c == '-')
-                {
-                    maximum = 0;
-                    c += 1;
-                }
-
-                if (*c == 'a')
-                    e->type = _GLFW_JOYSTICK_AXIS;
-                else if (*c == 'b')
-                    e->type = _GLFW_JOYSTICK_BUTTON;
-                else if (*c == 'h')
-                    e->type = _GLFW_JOYSTICK_HATBIT;
-                else
-                    break;
-
-                if (e->type == _GLFW_JOYSTICK_HATBIT)
-                {
-                    const unsigned long hat = strtoul(c + 1, (char**) &c, 10);
-                    const unsigned long bit = strtoul(c + 1, (char**) &c, 10);
-                    e->index = (uint8_t) ((hat << 4) | bit);
-                }
-                else
-                    e->index = (uint8_t) strtoul(c + 1, (char**) &c, 10);
-
-                if (e->type == _GLFW_JOYSTICK_AXIS)
-                {
-                    e->axisScale = 2 / (maximum - minimum);
-                    e->axisOffset = -(maximum + minimum);
-
-                    if (*c == '~')
-                    {
-                        e->axisScale = -e->axisScale;
-                        e->axisOffset = -e->axisOffset;
-                    }
-                }
-            }
-            else
-            {
-                length = strlen(_GLFW_PLATFORM_MAPPING_NAME);
-                if (strncmp(c, _GLFW_PLATFORM_MAPPING_NAME, length) != 0)
-                    return GLFW_FALSE;
-            }
-
-            break;
-        }
-
-        c += strcspn(c, ",");
-        c += strspn(c, ",");
-    }
-
-    for (i = 0;  i < 32;  i++)
-    {
-        if (mapping->guid[i] >= 'A' && mapping->guid[i] <= 'F')
-            mapping->guid[i] += 'a' - 'A';
-    }
-
-    _glfwPlatformUpdateGamepadGUID(mapping->guid);
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of a physical key event
-//
-void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
-{
-    if (key >= 0 && key <= GLFW_KEY_LAST)
-    {
-        GLFWbool repeated = GLFW_FALSE;
-
-        if (action == GLFW_RELEASE && window->keys[key] == GLFW_RELEASE)
-            return;
-
-        if (action == GLFW_PRESS && window->keys[key] == GLFW_PRESS)
-            repeated = GLFW_TRUE;
-
-        if (action == GLFW_RELEASE && window->stickyKeys)
-            window->keys[key] = _GLFW_STICK;
-        else
-            window->keys[key] = (char) action;
-
-        if (repeated)
-            action = GLFW_REPEAT;
-    }
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (window->callbacks.key)
-        window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
-}
-
-// Notifies shared code of a Unicode codepoint input event
-// The 'plain' parameter determines whether to emit a regular character event
-//
-void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain)
-{
-    if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
-        return;
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (window->callbacks.charmods)
-        window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
-
-    if (plain)
-    {
-        if (window->callbacks.character)
-            window->callbacks.character((GLFWwindow*) window, codepoint);
-    }
-}
-
-// Notifies shared code of a scroll event
-//
-void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
-{
-    if (window->callbacks.scroll)
-        window->callbacks.scroll((GLFWwindow*) window, xoffset, yoffset);
-}
-
-// Notifies shared code of a mouse button click event
-//
-void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
-{
-    if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
-        return;
-
-    if (!window->lockKeyMods)
-        mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
-
-    if (action == GLFW_RELEASE && window->stickyMouseButtons)
-        window->mouseButtons[button] = _GLFW_STICK;
-    else
-        window->mouseButtons[button] = (char) action;
-
-    if (window->callbacks.mouseButton)
-        window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
-}
-
-// Notifies shared code of a cursor motion event
-// The position is specified in content area relative screen coordinates
-//
-void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
-{
-    if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
-        return;
-
-    window->virtualCursorPosX = xpos;
-    window->virtualCursorPosY = ypos;
-
-    if (window->callbacks.cursorPos)
-        window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
-}
-
-// Notifies shared code of a cursor enter/leave event
-//
-void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
-{
-    if (window->callbacks.cursorEnter)
-        window->callbacks.cursorEnter((GLFWwindow*) window, entered);
-}
-
-// Notifies shared code of files or directories dropped on a window
-//
-void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
-{
-    if (window->callbacks.drop)
-        window->callbacks.drop((GLFWwindow*) window, count, paths);
-}
-
-// Notifies shared code of a joystick connection or disconnection
-//
-void _glfwInputJoystick(_GLFWjoystick* js, int event)
-{
-    const int jid = (int) (js - _glfw.joysticks);
-
-    if (_glfw.callbacks.joystick)
-        _glfw.callbacks.joystick(jid, event);
-}
-
-// Notifies shared code of the new value of a joystick axis
-//
-void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value)
-{
-    js->axes[axis] = value;
-}
-
-// Notifies shared code of the new value of a joystick button
-//
-void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value)
-{
-    js->buttons[button] = value;
-}
-
-// Notifies shared code of the new value of a joystick hat
-//
-void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value)
-{
-    const int base = js->buttonCount + hat * 4;
-
-    js->buttons[base + 0] = (value & 0x01) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 1] = (value & 0x02) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 2] = (value & 0x04) ? GLFW_PRESS : GLFW_RELEASE;
-    js->buttons[base + 3] = (value & 0x08) ? GLFW_PRESS : GLFW_RELEASE;
-
-    js->hats[hat] = value;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Returns an available joystick object with arrays and name allocated
-//
-_GLFWjoystick* _glfwAllocJoystick(const char* name,
-                                  const char* guid,
-                                  int axisCount,
-                                  int buttonCount,
-                                  int hatCount)
-{
-    int jid;
-    _GLFWjoystick* js;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (!_glfw.joysticks[jid].present)
-            break;
-    }
-
-    if (jid > GLFW_JOYSTICK_LAST)
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    js->present     = GLFW_TRUE;
-    js->name        = _glfw_strdup(name);
-    js->axes        = calloc(axisCount, sizeof(float));
-    js->buttons     = calloc(buttonCount + (size_t) hatCount * 4, 1);
-    js->hats        = calloc(hatCount, 1);
-    js->axisCount   = axisCount;
-    js->buttonCount = buttonCount;
-    js->hatCount    = hatCount;
-
-    strncpy(js->guid, guid, sizeof(js->guid) - 1);
-    js->mapping = findValidMapping(js);
-
-    return js;
-}
-
-// Frees arrays and name and flags the joystick object as unused
-//
-void _glfwFreeJoystick(_GLFWjoystick* js)
-{
-    free(js->name);
-    free(js->axes);
-    free(js->buttons);
-    free(js->hats);
-    memset(js, 0, sizeof(_GLFWjoystick));
-}
-
-// Center the cursor in the content area of the specified window
-//
-void _glfwCenterCursorInContentArea(_GLFWwindow* window)
-{
-    int width, height;
-
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-
-    switch (mode)
-    {
-        case GLFW_CURSOR:
-            return window->cursorMode;
-        case GLFW_STICKY_KEYS:
-            return window->stickyKeys;
-        case GLFW_STICKY_MOUSE_BUTTONS:
-            return window->stickyMouseButtons;
-        case GLFW_LOCK_KEY_MODS:
-            return window->lockKeyMods;
-        case GLFW_RAW_MOUSE_MOTION:
-            return window->rawMouseMotion;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
-    return 0;
-}
-
-GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (mode == GLFW_CURSOR)
-    {
-        if (value != GLFW_CURSOR_NORMAL &&
-            value != GLFW_CURSOR_HIDDEN &&
-            value != GLFW_CURSOR_DISABLED)
-        {
-            _glfwInputError(GLFW_INVALID_ENUM,
-                            "Invalid cursor mode 0x%08X",
-                            value);
-            return;
-        }
-
-        if (window->cursorMode == value)
-            return;
-
-        window->cursorMode = value;
-
-        _glfwPlatformGetCursorPos(window,
-                                  &window->virtualCursorPosX,
-                                  &window->virtualCursorPosY);
-        _glfwPlatformSetCursorMode(window, value);
-    }
-    else if (mode == GLFW_STICKY_KEYS)
-    {
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->stickyKeys == value)
-            return;
-
-        if (!value)
-        {
-            int i;
-
-            // Release all sticky keys
-            for (i = 0;  i <= GLFW_KEY_LAST;  i++)
-            {
-                if (window->keys[i] == _GLFW_STICK)
-                    window->keys[i] = GLFW_RELEASE;
-            }
-        }
-
-        window->stickyKeys = value;
-    }
-    else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
-    {
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->stickyMouseButtons == value)
-            return;
-
-        if (!value)
-        {
-            int i;
-
-            // Release all sticky mouse buttons
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == _GLFW_STICK)
-                    window->mouseButtons[i] = GLFW_RELEASE;
-            }
-        }
-
-        window->stickyMouseButtons = value;
-    }
-    else if (mode == GLFW_LOCK_KEY_MODS)
-    {
-        window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
-    }
-    else if (mode == GLFW_RAW_MOUSE_MOTION)
-    {
-        if (!_glfwPlatformRawMouseMotionSupported())
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Raw mouse motion is not supported on this system");
-            return;
-        }
-
-        value = value ? GLFW_TRUE : GLFW_FALSE;
-        if (window->rawMouseMotion == value)
-            return;
-
-        window->rawMouseMotion = value;
-        _glfwPlatformSetRawMouseMotion(window, value);
-    }
-    else
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
-}
-
-GLFWAPI int glfwRawMouseMotionSupported(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-    return _glfwPlatformRawMouseMotionSupported();
-}
-
-GLFWAPI const char* glfwGetKeyName(int key, int scancode)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (key != GLFW_KEY_UNKNOWN)
-    {
-        if (key != GLFW_KEY_KP_EQUAL &&
-            (key < GLFW_KEY_KP_0 || key > GLFW_KEY_KP_ADD) &&
-            (key < GLFW_KEY_APOSTROPHE || key > GLFW_KEY_WORLD_2))
-        {
-            return NULL;
-        }
-
-        scancode = _glfwPlatformGetKeyScancode(key);
-    }
-
-    return _glfwPlatformGetScancodeName(scancode);
-}
-
-GLFWAPI int glfwGetKeyScancode(int key)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(-1);
-
-    if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
-        return GLFW_RELEASE;
-    }
-
-    return _glfwPlatformGetKeyScancode(key);
-}
-
-GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
-
-    if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid key %i", key);
-        return GLFW_RELEASE;
-    }
-
-    if (window->keys[key] == _GLFW_STICK)
-    {
-        // Sticky mode: release key now
-        window->keys[key] = GLFW_RELEASE;
-        return GLFW_PRESS;
-    }
-
-    return (int) window->keys[key];
-}
-
-GLFWAPI int glfwGetMouseButton(GLFWwindow* handle, int button)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_RELEASE);
-
-    if (button < GLFW_MOUSE_BUTTON_1 || button > GLFW_MOUSE_BUTTON_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid mouse button %i", button);
-        return GLFW_RELEASE;
-    }
-
-    if (window->mouseButtons[button] == _GLFW_STICK)
-    {
-        // Sticky mode: release mouse button now
-        window->mouseButtons[button] = GLFW_RELEASE;
-        return GLFW_PRESS;
-    }
-
-    return (int) window->mouseButtons[button];
-}
-
-GLFWAPI void glfwGetCursorPos(GLFWwindow* handle, double* xpos, double* ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        if (xpos)
-            *xpos = window->virtualCursorPosX;
-        if (ypos)
-            *ypos = window->virtualCursorPosY;
-    }
-    else
-        _glfwPlatformGetCursorPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwSetCursorPos(GLFWwindow* handle, double xpos, double ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (xpos != xpos || xpos < -DBL_MAX || xpos > DBL_MAX ||
-        ypos != ypos || ypos < -DBL_MAX || ypos > DBL_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid cursor position %f %f",
-                        xpos, ypos);
-        return;
-    }
-
-    if (!_glfwPlatformWindowFocused(window))
-        return;
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        // Only update the accumulated position if the cursor is disabled
-        window->virtualCursorPosX = xpos;
-        window->virtualCursorPosY = ypos;
-    }
-    else
-    {
-        // Update system cursor position
-        _glfwPlatformSetCursorPos(window, xpos, ypos);
-    }
-}
-
-GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
-{
-    _GLFWcursor* cursor;
-
-    assert(image != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    cursor = calloc(1, sizeof(_GLFWcursor));
-    cursor->next = _glfw.cursorListHead;
-    _glfw.cursorListHead = cursor;
-
-    if (!_glfwPlatformCreateCursor(cursor, image, xhot, yhot))
-    {
-        glfwDestroyCursor((GLFWcursor*) cursor);
-        return NULL;
-    }
-
-    return (GLFWcursor*) cursor;
-}
-
-GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
-{
-    _GLFWcursor* cursor;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (shape != GLFW_ARROW_CURSOR &&
-        shape != GLFW_IBEAM_CURSOR &&
-        shape != GLFW_CROSSHAIR_CURSOR &&
-        shape != GLFW_POINTING_HAND_CURSOR &&
-        shape != GLFW_RESIZE_EW_CURSOR &&
-        shape != GLFW_RESIZE_NS_CURSOR &&
-        shape != GLFW_RESIZE_NWSE_CURSOR &&
-        shape != GLFW_RESIZE_NESW_CURSOR &&
-        shape != GLFW_RESIZE_ALL_CURSOR &&
-        shape != GLFW_NOT_ALLOWED_CURSOR)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape);
-        return NULL;
-    }
-
-    cursor = calloc(1, sizeof(_GLFWcursor));
-    cursor->next = _glfw.cursorListHead;
-    _glfw.cursorListHead = cursor;
-
-    if (!_glfwPlatformCreateStandardCursor(cursor, shape))
-    {
-        glfwDestroyCursor((GLFWcursor*) cursor);
-        return NULL;
-    }
-
-    return (GLFWcursor*) cursor;
-}
-
-GLFWAPI void glfwDestroyCursor(GLFWcursor* handle)
-{
-    _GLFWcursor* cursor = (_GLFWcursor*) handle;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (cursor == NULL)
-        return;
-
-    // Make sure the cursor is not being used by any window
-    {
-        _GLFWwindow* window;
-
-        for (window = _glfw.windowListHead;  window;  window = window->next)
-        {
-            if (window->cursor == cursor)
-                glfwSetCursor((GLFWwindow*) window, NULL);
-        }
-    }
-
-    _glfwPlatformDestroyCursor(cursor);
-
-    // Unlink cursor from global linked list
-    {
-        _GLFWcursor** prev = &_glfw.cursorListHead;
-
-        while (*prev != cursor)
-            prev = &((*prev)->next);
-
-        *prev = cursor->next;
-    }
-
-    free(cursor);
-}
-
-GLFWAPI void glfwSetCursor(GLFWwindow* windowHandle, GLFWcursor* cursorHandle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) windowHandle;
-    _GLFWcursor* cursor = (_GLFWcursor*) cursorHandle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    window->cursor = cursor;
-
-    _glfwPlatformSetCursor(window, cursor);
-}
-
-GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* handle, GLFWkeyfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.key, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* handle, GLFWcharfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.character, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* handle, GLFWcharmodsfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.charmods, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* handle,
-                                                      GLFWmousebuttonfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.mouseButton, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* handle,
-                                                  GLFWcursorposfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.cursorPos, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* handle,
-                                                      GLFWcursorenterfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.cursorEnter, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
-                                            GLFWscrollfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.scroll, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.drop, cbfun);
-    return cbfun;
-}
-
-GLFWAPI int glfwJoystickPresent(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    return _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
-}
-
-GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_AXES))
-        return NULL;
-
-    *count = js->axisCount;
-    return js->axes;
-}
-
-GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
-        return NULL;
-
-    if (_glfw.hints.init.hatButtons)
-        *count = js->buttonCount + js->hatCount * 4;
-    else
-        *count = js->buttonCount;
-
-    return js->buttons;
-}
-
-GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_BUTTONS))
-        return NULL;
-
-    *count = js->hatCount;
-    return js->hats;
-}
-
-GLFWAPI const char* glfwGetJoystickName(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    return js->name;
-}
-
-GLFWAPI const char* glfwGetJoystickGUID(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    return js->guid;
-}
-
-GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT();
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return;
-
-    js->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetJoystickUserPointer(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    return js->userPointer;
-}
-
-GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!initJoysticks())
-        return NULL;
-
-    _GLFW_SWAP_POINTERS(_glfw.callbacks.joystick, cbfun);
-    return cbfun;
-}
-
-GLFWAPI int glfwUpdateGamepadMappings(const char* string)
-{
-    int jid;
-    const char* c = string;
-
-    assert(string != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    while (*c)
-    {
-        if ((*c >= '0' && *c <= '9') ||
-            (*c >= 'a' && *c <= 'f') ||
-            (*c >= 'A' && *c <= 'F'))
-        {
-            char line[1024];
-
-            const size_t length = strcspn(c, "\r\n");
-            if (length < sizeof(line))
-            {
-                _GLFWmapping mapping = {{0}};
-
-                memcpy(line, c, length);
-                line[length] = '\0';
-
-                if (parseMapping(&mapping, line))
-                {
-                    _GLFWmapping* previous = findMapping(mapping.guid);
-                    if (previous)
-                        *previous = mapping;
-                    else
-                    {
-                        _glfw.mappingCount++;
-                        _glfw.mappings =
-                            realloc(_glfw.mappings,
-                                    sizeof(_GLFWmapping) * _glfw.mappingCount);
-                        _glfw.mappings[_glfw.mappingCount - 1] = mapping;
-                    }
-                }
-            }
-
-            c += length;
-        }
-        else
-        {
-            c += strcspn(c, "\r\n");
-            c += strspn(c, "\r\n");
-        }
-    }
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            js->mapping = findValidMapping(js);
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI int glfwJoystickIsGamepad(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return GLFW_FALSE;
-
-    return js->mapping != NULL;
-}
-
-GLFWAPI const char* glfwGetGamepadName(int jid)
-{
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return NULL;
-    }
-
-    if (!initJoysticks())
-        return NULL;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return NULL;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE))
-        return NULL;
-
-    if (!js->mapping)
-        return NULL;
-
-    return js->mapping->name;
-}
-
-GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
-{
-    int i;
-    _GLFWjoystick* js;
-
-    assert(jid >= GLFW_JOYSTICK_1);
-    assert(jid <= GLFW_JOYSTICK_LAST);
-    assert(state != NULL);
-
-    memset(state, 0, sizeof(GLFWgamepadstate));
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (jid < 0 || jid > GLFW_JOYSTICK_LAST)
-    {
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid joystick ID %i", jid);
-        return GLFW_FALSE;
-    }
-
-    if (!initJoysticks())
-        return GLFW_FALSE;
-
-    js = _glfw.joysticks + jid;
-    if (!js->present)
-        return GLFW_FALSE;
-
-    if (!_glfwPlatformPollJoystick(js, _GLFW_POLL_ALL))
-        return GLFW_FALSE;
-
-    if (!js->mapping)
-        return GLFW_FALSE;
-
-    for (i = 0;  i <= GLFW_GAMEPAD_BUTTON_LAST;  i++)
-    {
-        const _GLFWmapelement* e = js->mapping->buttons + i;
-        if (e->type == _GLFW_JOYSTICK_AXIS)
-        {
-            const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
-            // HACK: This should be baked into the value transform
-            // TODO: Bake into transform when implementing output modifiers
-            if (e->axisOffset < 0 || (e->axisOffset == 0 && e->axisScale > 0))
-            {
-                if (value >= 0.f)
-                    state->buttons[i] = GLFW_PRESS;
-            }
-            else
-            {
-                if (value <= 0.f)
-                    state->buttons[i] = GLFW_PRESS;
-            }
-        }
-        else if (e->type == _GLFW_JOYSTICK_HATBIT)
-        {
-            const unsigned int hat = e->index >> 4;
-            const unsigned int bit = e->index & 0xf;
-            if (js->hats[hat] & bit)
-                state->buttons[i] = GLFW_PRESS;
-        }
-        else if (e->type == _GLFW_JOYSTICK_BUTTON)
-            state->buttons[i] = js->buttons[e->index];
-    }
-
-    for (i = 0;  i <= GLFW_GAMEPAD_AXIS_LAST;  i++)
-    {
-        const _GLFWmapelement* e = js->mapping->axes + i;
-        if (e->type == _GLFW_JOYSTICK_AXIS)
-        {
-            const float value = js->axes[e->index] * e->axisScale + e->axisOffset;
-            state->axes[i] = _glfw_fminf(_glfw_fmaxf(value, -1.f), 1.f);
-        }
-        else if (e->type == _GLFW_JOYSTICK_HATBIT)
-        {
-            const unsigned int hat = e->index >> 4;
-            const unsigned int bit = e->index & 0xf;
-            if (js->hats[hat] & bit)
-                state->axes[i] = 1.f;
-            else
-                state->axes[i] = -1.f;
-        }
-        else if (e->type == _GLFW_JOYSTICK_BUTTON)
-            state->axes[i] = js->buttons[e->index] * 2.f - 1.f;
-    }
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI void glfwSetClipboardString(GLFWwindow* handle, const char* string)
-{
-    assert(string != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetClipboardString(string);
-}
-
-GLFWAPI const char* glfwGetClipboardString(GLFWwindow* handle)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfwPlatformGetClipboardString();
-}
-
-GLFWAPI double glfwGetTime(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0.0);
-    return (double) (_glfwPlatformGetTimerValue() - _glfw.timer.offset) /
-        _glfwPlatformGetTimerFrequency();
-}
-
-GLFWAPI void glfwSetTime(double time)
-{
-    _GLFW_REQUIRE_INIT();
-
-    if (time != time || time < 0.0 || time > 18446744073.0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", time);
-        return;
-    }
-
-    _glfw.timer.offset = _glfwPlatformGetTimerValue() -
-        (uint64_t) (time * _glfwPlatformGetTimerFrequency());
-}
-
-GLFWAPI uint64_t glfwGetTimerValue(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return _glfwPlatformGetTimerValue();
-}
-
-GLFWAPI uint64_t glfwGetTimerFrequency(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return _glfwPlatformGetTimerFrequency();
-}
diff --git a/raylib_pi4_test/external/glfw/src/internal.h b/raylib_pi4_test/external/glfw/src/internal.h
deleted file mode 100644 (file)
index 48053cd..0000000
+++ /dev/null
@@ -1,795 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#pragma once
-
-#if defined(_GLFW_USE_CONFIG_H)
- #include "glfw_config.h"
-#endif
-
-#if defined(GLFW_INCLUDE_GLCOREARB) || \
-    defined(GLFW_INCLUDE_ES1)       || \
-    defined(GLFW_INCLUDE_ES2)       || \
-    defined(GLFW_INCLUDE_ES3)       || \
-    defined(GLFW_INCLUDE_ES31)      || \
-    defined(GLFW_INCLUDE_ES32)      || \
-    defined(GLFW_INCLUDE_NONE)      || \
-    defined(GLFW_INCLUDE_GLEXT)     || \
-    defined(GLFW_INCLUDE_GLU)       || \
-    defined(GLFW_INCLUDE_VULKAN)    || \
-    defined(GLFW_DLL)
- #error "You must not define any header option macros when compiling GLFW"
-#endif
-
-#define GLFW_INCLUDE_NONE
-#include "../include/GLFW/glfw3.h"
-
-#define _GLFW_INSERT_FIRST      0
-#define _GLFW_INSERT_LAST       1
-
-#define _GLFW_POLL_PRESENCE     0
-#define _GLFW_POLL_AXES         1
-#define _GLFW_POLL_BUTTONS      2
-#define _GLFW_POLL_ALL          (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS)
-
-#define _GLFW_MESSAGE_SIZE      1024
-
-typedef int GLFWbool;
-
-typedef struct _GLFWerror       _GLFWerror;
-typedef struct _GLFWinitconfig  _GLFWinitconfig;
-typedef struct _GLFWwndconfig   _GLFWwndconfig;
-typedef struct _GLFWctxconfig   _GLFWctxconfig;
-typedef struct _GLFWfbconfig    _GLFWfbconfig;
-typedef struct _GLFWcontext     _GLFWcontext;
-typedef struct _GLFWwindow      _GLFWwindow;
-typedef struct _GLFWlibrary     _GLFWlibrary;
-typedef struct _GLFWmonitor     _GLFWmonitor;
-typedef struct _GLFWcursor      _GLFWcursor;
-typedef struct _GLFWmapelement  _GLFWmapelement;
-typedef struct _GLFWmapping     _GLFWmapping;
-typedef struct _GLFWjoystick    _GLFWjoystick;
-typedef struct _GLFWtls         _GLFWtls;
-typedef struct _GLFWmutex       _GLFWmutex;
-
-typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
-typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
-typedef void (* _GLFWswapintervalfun)(int);
-typedef int (* _GLFWextensionsupportedfun)(const char*);
-typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
-typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
-
-#define GL_VERSION 0x1f02
-#define GL_NONE 0
-#define GL_COLOR_BUFFER_BIT 0x00004000
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_EXTENSIONS 0x1f03
-#define GL_NUM_EXTENSIONS 0x821d
-#define GL_CONTEXT_FLAGS 0x821e
-#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
-#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
-#define GL_CONTEXT_PROFILE_MASK 0x9126
-#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
-#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
-#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define GL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb
-#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc
-#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
-
-typedef int GLint;
-typedef unsigned int GLuint;
-typedef unsigned int GLenum;
-typedef unsigned int GLbitfield;
-typedef unsigned char GLubyte;
-
-typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
-typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
-typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
-typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
-
-#define VK_NULL_HANDLE 0
-
-typedef void* VkInstance;
-typedef void* VkPhysicalDevice;
-typedef uint64_t VkSurfaceKHR;
-typedef uint32_t VkFlags;
-typedef uint32_t VkBool32;
-
-typedef enum VkStructureType
-{
-    VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
-    VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
-    VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
-    VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
-    VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
-    VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
-    VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
-} VkStructureType;
-
-typedef enum VkResult
-{
-    VK_SUCCESS = 0,
-    VK_NOT_READY = 1,
-    VK_TIMEOUT = 2,
-    VK_EVENT_SET = 3,
-    VK_EVENT_RESET = 4,
-    VK_INCOMPLETE = 5,
-    VK_ERROR_OUT_OF_HOST_MEMORY = -1,
-    VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
-    VK_ERROR_INITIALIZATION_FAILED = -3,
-    VK_ERROR_DEVICE_LOST = -4,
-    VK_ERROR_MEMORY_MAP_FAILED = -5,
-    VK_ERROR_LAYER_NOT_PRESENT = -6,
-    VK_ERROR_EXTENSION_NOT_PRESENT = -7,
-    VK_ERROR_FEATURE_NOT_PRESENT = -8,
-    VK_ERROR_INCOMPATIBLE_DRIVER = -9,
-    VK_ERROR_TOO_MANY_OBJECTS = -10,
-    VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
-    VK_ERROR_SURFACE_LOST_KHR = -1000000000,
-    VK_SUBOPTIMAL_KHR = 1000001003,
-    VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
-    VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
-    VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
-    VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
-    VK_RESULT_MAX_ENUM = 0x7FFFFFFF
-} VkResult;
-
-typedef struct VkAllocationCallbacks VkAllocationCallbacks;
-
-typedef struct VkExtensionProperties
-{
-    char            extensionName[256];
-    uint32_t        specVersion;
-} VkExtensionProperties;
-
-typedef void (APIENTRY * PFN_vkVoidFunction)(void);
-
-#if defined(_GLFW_VULKAN_STATIC)
-  PFN_vkVoidFunction vkGetInstanceProcAddr(VkInstance,const char*);
-  VkResult vkEnumerateInstanceExtensionProperties(const char*,uint32_t*,VkExtensionProperties*);
-#else
-  typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
-  typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
-  #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties
-  #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
-#endif
-
-#if defined(_GLFW_COCOA)
- #include "cocoa_platform.h"
-#elif defined(_GLFW_WIN32)
- #include "win32_platform.h"
-#elif defined(_GLFW_X11)
- #include "x11_platform.h"
-#elif defined(_GLFW_WAYLAND)
- #include "wl_platform.h"
-#elif defined(_GLFW_OSMESA)
- #include "null_platform.h"
-#else
- #error "No supported window creation API selected"
-#endif
-
-#include "egl_context.h"
-#include "osmesa_context.h"
-
-// Constructs a version number string from the public header macros
-#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
-#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
-#define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \
-                                                GLFW_VERSION_MINOR, \
-                                                GLFW_VERSION_REVISION)
-
-// Checks for whether the library has been initialized
-#define _GLFW_REQUIRE_INIT()                         \
-    if (!_glfw.initialized)                          \
-    {                                                \
-        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
-        return;                                      \
-    }
-#define _GLFW_REQUIRE_INIT_OR_RETURN(x)              \
-    if (!_glfw.initialized)                          \
-    {                                                \
-        _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \
-        return x;                                    \
-    }
-
-// Swaps the provided pointers
-#define _GLFW_SWAP_POINTERS(x, y) \
-    {                             \
-        void* t;                  \
-        t = x;                    \
-        x = y;                    \
-        y = t;                    \
-    }
-
-// Per-thread error structure
-//
-struct _GLFWerror
-{
-    _GLFWerror*     next;
-    int             code;
-    char            description[_GLFW_MESSAGE_SIZE];
-};
-
-// Initialization configuration
-//
-// Parameters relating to the initialization of the library
-//
-struct _GLFWinitconfig
-{
-    GLFWbool      hatButtons;
-    int           angleType;
-    struct {
-        GLFWbool  menubar;
-        GLFWbool  chdir;
-    } ns;
-};
-
-// Window configuration
-//
-// Parameters relating to the creation of the window but not directly related
-// to the framebuffer.  This is used to pass window creation parameters from
-// shared code to the platform API.
-//
-struct _GLFWwndconfig
-{
-    int           width;
-    int           height;
-    const char*   title;
-    GLFWbool      resizable;
-    GLFWbool      visible;
-    GLFWbool      decorated;
-    GLFWbool      focused;
-    GLFWbool      autoIconify;
-    GLFWbool      floating;
-    GLFWbool      maximized;
-    GLFWbool      centerCursor;
-    GLFWbool      focusOnShow;
-    GLFWbool      mousePassthrough;
-    GLFWbool      scaleToMonitor;
-    struct {
-        GLFWbool  retina;
-        char      frameName[256];
-    } ns;
-    struct {
-        char      className[256];
-        char      instanceName[256];
-    } x11;
-    struct {
-        GLFWbool  keymenu;
-    } win32;
-};
-
-// Context configuration
-//
-// Parameters relating to the creation of the context but not directly related
-// to the framebuffer.  This is used to pass context creation parameters from
-// shared code to the platform API.
-//
-struct _GLFWctxconfig
-{
-    int           client;
-    int           source;
-    int           major;
-    int           minor;
-    GLFWbool      forward;
-    GLFWbool      debug;
-    GLFWbool      noerror;
-    int           profile;
-    int           robustness;
-    int           release;
-    _GLFWwindow*  share;
-    struct {
-        GLFWbool  offline;
-    } nsgl;
-};
-
-// Framebuffer configuration
-//
-// This describes buffers and their sizes.  It also contains
-// a platform-specific ID used to map back to the backend API object.
-//
-// It is used to pass framebuffer parameters from shared code to the platform
-// API and also to enumerate and select available framebuffer configs.
-//
-struct _GLFWfbconfig
-{
-    int         redBits;
-    int         greenBits;
-    int         blueBits;
-    int         alphaBits;
-    int         depthBits;
-    int         stencilBits;
-    int         accumRedBits;
-    int         accumGreenBits;
-    int         accumBlueBits;
-    int         accumAlphaBits;
-    int         auxBuffers;
-    GLFWbool    stereo;
-    int         samples;
-    GLFWbool    sRGB;
-    GLFWbool    doublebuffer;
-    GLFWbool    transparent;
-    uintptr_t   handle;
-};
-
-// Context structure
-//
-struct _GLFWcontext
-{
-    int                 client;
-    int                 source;
-    int                 major, minor, revision;
-    GLFWbool            forward, debug, noerror;
-    int                 profile;
-    int                 robustness;
-    int                 release;
-
-    PFNGLGETSTRINGIPROC GetStringi;
-    PFNGLGETINTEGERVPROC GetIntegerv;
-    PFNGLGETSTRINGPROC  GetString;
-
-    _GLFWmakecontextcurrentfun  makeCurrent;
-    _GLFWswapbuffersfun         swapBuffers;
-    _GLFWswapintervalfun        swapInterval;
-    _GLFWextensionsupportedfun  extensionSupported;
-    _GLFWgetprocaddressfun      getProcAddress;
-    _GLFWdestroycontextfun      destroy;
-
-    // This is defined in the context API's context.h
-    _GLFW_PLATFORM_CONTEXT_STATE;
-    // This is defined in egl_context.h
-    _GLFWcontextEGL egl;
-    // This is defined in osmesa_context.h
-    _GLFWcontextOSMesa osmesa;
-};
-
-// Window and context structure
-//
-struct _GLFWwindow
-{
-    struct _GLFWwindow* next;
-
-    // Window settings and state
-    GLFWbool            resizable;
-    GLFWbool            decorated;
-    GLFWbool            autoIconify;
-    GLFWbool            floating;
-    GLFWbool            focusOnShow;
-    GLFWbool            mousePassthrough;
-    GLFWbool            shouldClose;
-    void*               userPointer;
-    GLFWvidmode         videoMode;
-    _GLFWmonitor*       monitor;
-    _GLFWcursor*        cursor;
-
-    int                 minwidth, minheight;
-    int                 maxwidth, maxheight;
-    int                 numer, denom;
-
-    GLFWbool            stickyKeys;
-    GLFWbool            stickyMouseButtons;
-    GLFWbool            lockKeyMods;
-    int                 cursorMode;
-    char                mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
-    char                keys[GLFW_KEY_LAST + 1];
-    // Virtual cursor position when cursor is disabled
-    double              virtualCursorPosX, virtualCursorPosY;
-    GLFWbool            rawMouseMotion;
-
-    _GLFWcontext        context;
-
-    struct {
-        GLFWwindowposfun        pos;
-        GLFWwindowsizefun       size;
-        GLFWwindowclosefun      close;
-        GLFWwindowrefreshfun    refresh;
-        GLFWwindowfocusfun      focus;
-        GLFWwindowiconifyfun    iconify;
-        GLFWwindowmaximizefun   maximize;
-        GLFWframebuffersizefun  fbsize;
-        GLFWwindowcontentscalefun scale;
-        GLFWmousebuttonfun      mouseButton;
-        GLFWcursorposfun        cursorPos;
-        GLFWcursorenterfun      cursorEnter;
-        GLFWscrollfun           scroll;
-        GLFWkeyfun              key;
-        GLFWcharfun             character;
-        GLFWcharmodsfun         charmods;
-        GLFWdropfun             drop;
-    } callbacks;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_WINDOW_STATE;
-};
-
-// Monitor structure
-//
-struct _GLFWmonitor
-{
-    char*           name;
-    void*           userPointer;
-
-    // Physical dimensions in millimeters.
-    int             widthMM, heightMM;
-
-    // The window whose video mode is current on this monitor
-    _GLFWwindow*    window;
-
-    GLFWvidmode*    modes;
-    int             modeCount;
-    GLFWvidmode     currentMode;
-
-    GLFWgammaramp   originalRamp;
-    GLFWgammaramp   currentRamp;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_MONITOR_STATE;
-};
-
-// Cursor structure
-//
-struct _GLFWcursor
-{
-    _GLFWcursor*    next;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_CURSOR_STATE;
-};
-
-// Gamepad mapping element structure
-//
-struct _GLFWmapelement
-{
-    uint8_t         type;
-    uint8_t         index;
-    int8_t          axisScale;
-    int8_t          axisOffset;
-};
-
-// Gamepad mapping structure
-//
-struct _GLFWmapping
-{
-    char            name[128];
-    char            guid[33];
-    _GLFWmapelement buttons[15];
-    _GLFWmapelement axes[6];
-};
-
-// Joystick structure
-//
-struct _GLFWjoystick
-{
-    GLFWbool        present;
-    float*          axes;
-    int             axisCount;
-    unsigned char*  buttons;
-    int             buttonCount;
-    unsigned char*  hats;
-    int             hatCount;
-    char*           name;
-    void*           userPointer;
-    char            guid[33];
-    _GLFWmapping*   mapping;
-
-    // This is defined in the joystick API's joystick.h
-    _GLFW_PLATFORM_JOYSTICK_STATE;
-};
-
-// Thread local storage structure
-//
-struct _GLFWtls
-{
-    // This is defined in the platform's thread.h
-    _GLFW_PLATFORM_TLS_STATE;
-};
-
-// Mutex structure
-//
-struct _GLFWmutex
-{
-    // This is defined in the platform's thread.h
-    _GLFW_PLATFORM_MUTEX_STATE;
-};
-
-// Library global data
-//
-struct _GLFWlibrary
-{
-    GLFWbool            initialized;
-
-    struct {
-        _GLFWinitconfig init;
-        _GLFWfbconfig   framebuffer;
-        _GLFWwndconfig  window;
-        _GLFWctxconfig  context;
-        int             refreshRate;
-    } hints;
-
-    _GLFWerror*         errorListHead;
-    _GLFWcursor*        cursorListHead;
-    _GLFWwindow*        windowListHead;
-
-    _GLFWmonitor**      monitors;
-    int                 monitorCount;
-
-    GLFWbool            joysticksInitialized;
-    _GLFWjoystick       joysticks[GLFW_JOYSTICK_LAST + 1];
-    _GLFWmapping*       mappings;
-    int                 mappingCount;
-
-    _GLFWtls            errorSlot;
-    _GLFWtls            contextSlot;
-    _GLFWmutex          errorLock;
-
-    struct {
-        uint64_t        offset;
-        // This is defined in the platform's time.h
-        _GLFW_PLATFORM_LIBRARY_TIMER_STATE;
-    } timer;
-
-    struct {
-        GLFWbool        available;
-        void*           handle;
-        char*           extensions[2];
-#if !defined(_GLFW_VULKAN_STATIC)
-        PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties;
-        PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
-#endif
-        GLFWbool        KHR_surface;
-#if defined(_GLFW_WIN32)
-        GLFWbool        KHR_win32_surface;
-#elif defined(_GLFW_COCOA)
-        GLFWbool        MVK_macos_surface;
-        GLFWbool        EXT_metal_surface;
-#elif defined(_GLFW_X11)
-        GLFWbool        KHR_xlib_surface;
-        GLFWbool        KHR_xcb_surface;
-#elif defined(_GLFW_WAYLAND)
-        GLFWbool        KHR_wayland_surface;
-#endif
-    } vk;
-
-    struct {
-        GLFWmonitorfun  monitor;
-        GLFWjoystickfun joystick;
-    } callbacks;
-
-    // This is defined in the window API's platform.h
-    _GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
-    // This is defined in the context API's context.h
-    _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE;
-    // This is defined in the platform's joystick.h
-    _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE;
-    // This is defined in egl_context.h
-    _GLFWlibraryEGL egl;
-    // This is defined in osmesa_context.h
-    _GLFWlibraryOSMesa osmesa;
-};
-
-// Global state shared between compilation units of GLFW
-//
-extern _GLFWlibrary _glfw;
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void);
-void _glfwPlatformTerminate(void);
-const char* _glfwPlatformGetVersionString(void);
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos);
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos);
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled);
-GLFWbool _glfwPlatformRawMouseMotionSupported(void);
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image, int xhot, int yhot);
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape);
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
-
-const char* _glfwPlatformGetScancodeName(int scancode);
-int _glfwPlatformGetKeyScancode(int key);
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale);
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int *width, int *height);
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count);
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode);
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp);
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp);
-
-void _glfwPlatformSetClipboardString(const char* string);
-const char* _glfwPlatformGetClipboardString(void);
-
-GLFWbool _glfwPlatformInitJoysticks(void);
-void _glfwPlatformTerminateJoysticks(void);
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode);
-void _glfwPlatformUpdateGamepadGUID(char* guid);
-
-uint64_t _glfwPlatformGetTimerValue(void);
-uint64_t _glfwPlatformGetTimerFrequency(void);
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig);
-void _glfwPlatformDestroyWindow(_GLFWwindow* window);
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images);
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos);
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos);
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height);
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight);
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom);
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height);
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom);
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale);
-void _glfwPlatformIconifyWindow(_GLFWwindow* window);
-void _glfwPlatformRestoreWindow(_GLFWwindow* window);
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window);
-void _glfwPlatformShowWindow(_GLFWwindow* window);
-void _glfwPlatformHideWindow(_GLFWwindow* window);
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window);
-void _glfwPlatformFocusWindow(_GLFWwindow* window);
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor,
-                                   int xpos, int ypos, int width, int height,
-                                   int refreshRate);
-int _glfwPlatformWindowFocused(_GLFWwindow* window);
-int _glfwPlatformWindowIconified(_GLFWwindow* window);
-int _glfwPlatformWindowVisible(_GLFWwindow* window);
-int _glfwPlatformWindowMaximized(_GLFWwindow* window);
-int _glfwPlatformWindowHovered(_GLFWwindow* window);
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled);
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity);
-
-void _glfwPlatformPollEvents(void);
-void _glfwPlatformWaitEvents(void);
-void _glfwPlatformWaitEventsTimeout(double timeout);
-void _glfwPlatformPostEmptyEvent(void);
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs);
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void);
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window);
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions);
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily);
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface);
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
-void _glfwPlatformDestroyTls(_GLFWtls* tls);
-void* _glfwPlatformGetTls(_GLFWtls* tls);
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
-void _glfwPlatformLockMutex(_GLFWmutex* mutex);
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
-void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
-void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
-void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
-void _glfwInputWindowContentScale(_GLFWwindow* window,
-                                  float xscale, float yscale);
-void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
-void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
-void _glfwInputWindowDamage(_GLFWwindow* window);
-void _glfwInputWindowCloseRequest(_GLFWwindow* window);
-void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
-
-void _glfwInputKey(_GLFWwindow* window,
-                   int key, int scancode, int action, int mods);
-void _glfwInputChar(_GLFWwindow* window,
-                    unsigned int codepoint, int mods, GLFWbool plain);
-void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
-void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
-void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
-void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
-void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
-void _glfwInputJoystick(_GLFWjoystick* js, int event);
-void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
-void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
-void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);
-
-void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
-void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);
-
-#if defined(__GNUC__)
-void _glfwInputError(int code, const char* format, ...)
-    __attribute__((format(printf, 2, 3)));
-#else
-void _glfwInputError(int code, const char* format, ...);
-#endif
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
-const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
-                                         const _GLFWfbconfig* alternatives,
-                                         unsigned int count);
-GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
-                                    const _GLFWctxconfig* ctxconfig);
-GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
-
-const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
-                                        const GLFWvidmode* desired);
-int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
-_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
-void _glfwFreeMonitor(_GLFWmonitor* monitor);
-void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
-void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
-void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
-
-_GLFWjoystick* _glfwAllocJoystick(const char* name,
-                                  const char* guid,
-                                  int axisCount,
-                                  int buttonCount,
-                                  int hatCount);
-void _glfwFreeJoystick(_GLFWjoystick* js);
-void _glfwCenterCursorInContentArea(_GLFWwindow* window);
-
-GLFWbool _glfwInitVulkan(int mode);
-void _glfwTerminateVulkan(void);
-const char* _glfwGetVulkanResultString(VkResult result);
-
-char* _glfw_strdup(const char* source);
-float _glfw_fminf(float a, float b);
-float _glfw_fmaxf(float a, float b);
-
diff --git a/raylib_pi4_test/external/glfw/src/linux_joystick.c b/raylib_pi4_test/external/glfw/src/linux_joystick.c
deleted file mode 100644 (file)
index 122bc66..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/inotify.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#ifndef SYN_DROPPED // < v2.6.39 kernel headers
-// Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32
-#define SYN_DROPPED 3
-#endif
-
-// Apply an EV_KEY event to the specified joystick
-//
-static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
-{
-    _glfwInputJoystickButton(js,
-                             js->linjs.keyMap[code - BTN_MISC],
-                             value ? GLFW_PRESS : GLFW_RELEASE);
-}
-
-// Apply an EV_ABS event to the specified joystick
-//
-static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
-{
-    const int index = js->linjs.absMap[code];
-
-    if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
-    {
-        static const char stateMap[3][3] =
-        {
-            { GLFW_HAT_CENTERED, GLFW_HAT_UP,       GLFW_HAT_DOWN },
-            { GLFW_HAT_LEFT,     GLFW_HAT_LEFT_UP,  GLFW_HAT_LEFT_DOWN },
-            { GLFW_HAT_RIGHT,    GLFW_HAT_RIGHT_UP, GLFW_HAT_RIGHT_DOWN },
-        };
-
-        const int hat = (code - ABS_HAT0X) / 2;
-        const int axis = (code - ABS_HAT0X) % 2;
-        int* state = js->linjs.hats[hat];
-
-        // NOTE: Looking at several input drivers, it seems all hat events use
-        //       -1 for left / up, 0 for centered and 1 for right / down
-        if (value == 0)
-            state[axis] = 0;
-        else if (value < 0)
-            state[axis] = 1;
-        else if (value > 0)
-            state[axis] = 2;
-
-        _glfwInputJoystickHat(js, index, stateMap[state[0]][state[1]]);
-    }
-    else
-    {
-        const struct input_absinfo* info = &js->linjs.absInfo[code];
-        float normalized = value;
-
-        const int range = info->maximum - info->minimum;
-        if (range)
-        {
-            // Normalize to 0.0 -> 1.0
-            normalized = (normalized - info->minimum) / range;
-            // Normalize to -1.0 -> 1.0
-            normalized = normalized * 2.0f - 1.0f;
-        }
-
-        _glfwInputJoystickAxis(js, index, normalized);
-    }
-}
-
-// Poll state of absolute axes
-//
-static void pollAbsState(_GLFWjoystick* js)
-{
-    for (int code = 0;  code < ABS_CNT;  code++)
-    {
-        if (js->linjs.absMap[code] < 0)
-            continue;
-
-        struct input_absinfo* info = &js->linjs.absInfo[code];
-
-        if (ioctl(js->linjs.fd, EVIOCGABS(code), info) < 0)
-            continue;
-
-        handleAbsEvent(js, code, info->value);
-    }
-}
-
-#define isBitSet(bit, arr) (arr[(bit) / 8] & (1 << ((bit) % 8)))
-
-// Attempt to open the specified joystick device
-//
-static GLFWbool openJoystickDevice(const char* path)
-{
-    for (int jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        if (!_glfw.joysticks[jid].present)
-            continue;
-        if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
-            return GLFW_FALSE;
-    }
-
-    _GLFWjoystickLinux linjs = {0};
-    linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
-    if (linjs.fd == -1)
-        return GLFW_FALSE;
-
-    char evBits[(EV_CNT + 7) / 8] = {0};
-    char keyBits[(KEY_CNT + 7) / 8] = {0};
-    char absBits[(ABS_CNT + 7) / 8] = {0};
-    struct input_id id;
-
-    if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
-        ioctl(linjs.fd, EVIOCGID, &id) < 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Linux: Failed to query input device: %s",
-                        strerror(errno));
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    // Ensure this device supports the events expected of a joystick
-    if (!isBitSet(EV_KEY, evBits) || !isBitSet(EV_ABS, evBits))
-    {
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    char name[256] = "";
-
-    if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
-        strncpy(name, "Unknown", sizeof(name));
-
-    char guid[33] = "";
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (id.vendor && id.product && id.version)
-    {
-        sprintf(guid, "%02x%02x0000%02x%02x0000%02x%02x0000%02x%02x0000",
-                id.bustype & 0xff, id.bustype >> 8,
-                id.vendor & 0xff,  id.vendor >> 8,
-                id.product & 0xff, id.product >> 8,
-                id.version & 0xff, id.version >> 8);
-    }
-    else
-    {
-        sprintf(guid, "%02x%02x0000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                id.bustype & 0xff, id.bustype >> 8,
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    int axisCount = 0, buttonCount = 0, hatCount = 0;
-
-    for (int code = BTN_MISC;  code < KEY_CNT;  code++)
-    {
-        if (!isBitSet(code, keyBits))
-            continue;
-
-        linjs.keyMap[code - BTN_MISC] = buttonCount;
-        buttonCount++;
-    }
-
-    for (int code = 0;  code < ABS_CNT;  code++)
-    {
-        linjs.absMap[code] = -1;
-        if (!isBitSet(code, absBits))
-            continue;
-
-        if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
-        {
-            linjs.absMap[code] = hatCount;
-            hatCount++;
-            // Skip the Y axis
-            code++;
-        }
-        else
-        {
-            if (ioctl(linjs.fd, EVIOCGABS(code), &linjs.absInfo[code]) < 0)
-                continue;
-
-            linjs.absMap[code] = axisCount;
-            axisCount++;
-        }
-    }
-
-    _GLFWjoystick* js =
-        _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
-    if (!js)
-    {
-        close(linjs.fd);
-        return GLFW_FALSE;
-    }
-
-    strncpy(linjs.path, path, sizeof(linjs.path) - 1);
-    memcpy(&js->linjs, &linjs, sizeof(linjs));
-
-    pollAbsState(js);
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-    return GLFW_TRUE;
-}
-
-#undef isBitSet
-
-// Frees all resources associated with the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    close(js->linjs.fd);
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// Lexically compare joysticks by name; used by qsort
-//
-static int compareJoysticks(const void* fp, const void* sp)
-{
-    const _GLFWjoystick* fj = fp;
-    const _GLFWjoystick* sj = sp;
-    return strcmp(fj->linjs.path, sj->linjs.path);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwDetectJoystickConnectionLinux(void)
-{
-    if (_glfw.linjs.inotify <= 0)
-        return;
-
-    ssize_t offset = 0;
-    char buffer[16384];
-    const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
-
-    while (size > offset)
-    {
-        regmatch_t match;
-        const struct inotify_event* e = (struct inotify_event*) (buffer + offset);
-
-        offset += sizeof(struct inotify_event) + e->len;
-
-        if (regexec(&_glfw.linjs.regex, e->name, 1, &match, 0) != 0)
-            continue;
-
-        char path[PATH_MAX];
-        snprintf(path, sizeof(path), "/dev/input/%s", e->name);
-
-        if (e->mask & (IN_CREATE | IN_ATTRIB))
-            openJoystickDevice(path);
-        else if (e->mask & IN_DELETE)
-        {
-            for (int jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-            {
-                if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
-                {
-                    closeJoystick(_glfw.joysticks + jid);
-                    break;
-                }
-            }
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    const char* dirname = "/dev/input";
-
-    _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
-    if (_glfw.linjs.inotify > 0)
-    {
-        // HACK: Register for IN_ATTRIB to get notified when udev is done
-        //       This works well in practice but the true way is libudev
-
-        _glfw.linjs.watch = inotify_add_watch(_glfw.linjs.inotify,
-                                              dirname,
-                                              IN_CREATE | IN_ATTRIB | IN_DELETE);
-    }
-
-    // Continue without device connection notifications if inotify fails
-
-    if (regcomp(&_glfw.linjs.regex, "^event[0-9]\\+$", 0) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Linux: Failed to compile regex");
-        return GLFW_FALSE;
-    }
-
-    int count = 0;
-
-    DIR* dir = opendir(dirname);
-    if (dir)
-    {
-        struct dirent* entry;
-
-        while ((entry = readdir(dir)))
-        {
-            regmatch_t match;
-
-            if (regexec(&_glfw.linjs.regex, entry->d_name, 1, &match, 0) != 0)
-                continue;
-
-            char path[PATH_MAX];
-
-            snprintf(path, sizeof(path), "%s/%s", dirname, entry->d_name);
-
-            if (openJoystickDevice(path))
-                count++;
-        }
-
-        closedir(dir);
-    }
-
-    // Continue with no joysticks if enumeration fails
-
-    qsort(_glfw.joysticks, count, sizeof(_GLFWjoystick), compareJoysticks);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            closeJoystick(js);
-    }
-
-    if (_glfw.linjs.inotify > 0)
-    {
-        if (_glfw.linjs.watch > 0)
-            inotify_rm_watch(_glfw.linjs.inotify, _glfw.linjs.watch);
-
-        close(_glfw.linjs.inotify);
-        regfree(&_glfw.linjs.regex);
-    }
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    // Read all queued events (non-blocking)
-    for (;;)
-    {
-        struct input_event e;
-
-        errno = 0;
-        if (read(js->linjs.fd, &e, sizeof(e)) < 0)
-        {
-            // Reset the joystick slot if the device was disconnected
-            if (errno == ENODEV)
-                closeJoystick(js);
-
-            break;
-        }
-
-        if (e.type == EV_SYN)
-        {
-            if (e.code == SYN_DROPPED)
-                _glfw.linjs.dropped = GLFW_TRUE;
-            else if (e.code == SYN_REPORT)
-            {
-                _glfw.linjs.dropped = GLFW_FALSE;
-                pollAbsState(js);
-            }
-        }
-
-        if (_glfw.linjs.dropped)
-            continue;
-
-        if (e.type == EV_KEY)
-            handleKeyEvent(js, e.code, e.value);
-        else if (e.type == EV_ABS)
-            handleAbsEvent(js, e.code, e.value);
-    }
-
-    return js->present;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/linux_joystick.h b/raylib_pi4_test/external/glfw/src/linux_joystick.h
deleted file mode 100644 (file)
index 05d5488..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <linux/input.h>
-#include <linux/limits.h>
-#include <regex.h>
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickLinux linjs
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWlibraryLinux  linjs
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Linux"
-
-// Linux-specific joystick data
-//
-typedef struct _GLFWjoystickLinux
-{
-    int                     fd;
-    char                    path[PATH_MAX];
-    int                     keyMap[KEY_CNT - BTN_MISC];
-    int                     absMap[ABS_CNT];
-    struct input_absinfo    absInfo[ABS_CNT];
-    int                     hats[4][2];
-} _GLFWjoystickLinux;
-
-// Linux-specific joystick API data
-//
-typedef struct _GLFWlibraryLinux
-{
-    int                     inotify;
-    int                     watch;
-    regex_t                 regex;
-    GLFWbool                dropped;
-} _GLFWlibraryLinux;
-
-void _glfwDetectJoystickConnectionLinux(void);
-
diff --git a/raylib_pi4_test/external/glfw/src/mappings.h b/raylib_pi4_test/external/glfw/src/mappings.h
deleted file mode 100644 (file)
index 4c3f02f..0000000
+++ /dev/null
@@ -1,998 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As mappings.h.in, this file is used by CMake to produce the mappings.h
-// header file.  If you are adding a GLFW specific gamepad mapping, this is
-// where to put it.
-//========================================================================
-// As mappings.h, this provides all pre-defined gamepad mappings, including
-// all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
-// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
-// This file can be re-generated from mappings.h.in and the upstream
-// gamecontrollerdb.txt with the GenerateMappings.cmake script.
-//========================================================================
-
-// All gamepad mappings not labeled GLFW are copied from the
-// SDL_GameControllerDB project under the following license:
-//
-// Simple DirectMedia Layer
-// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the
-// use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-//    misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-
-const char* _glfwDefaultMappings[] =
-{
-"03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,platform:Windows,",
-"03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000011ab000000000000,8BitDo F30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001038000000000000,8BitDo F30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000090000000000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000650000000000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:a4,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00005106000000000000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000310000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00002028000000000000,8BitDo N30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00008010000000000000,8BitDo N30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c82d00000190000000000000,8BitDo N30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001590000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00006528000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00015900000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00065280000000000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000130000000000000,8BitDo SF30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000021ab000000000000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00003028000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000030000000000000,8BitDo SN30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000351000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001290000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d000020ab000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00004028000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00006228000000000000,8BitDo SN30,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000260000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000261000000000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00000031000000000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00001890000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000c82d00003032000000000000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Windows,",
-"03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Windows,",
-"030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006f0e00001413000000000000,Afterglow,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000869800002400000000007801,Astro C40 TR,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,platform:Windows,",
-"030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000002a79000000000000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000006321000000000000,BETOP CONTROLLER,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,platform:Windows,",
-"03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000457500000401000000000000,Cobra,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005e0400008e02000000000000,Controller (XBOX 360 For Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000a102000000000000,Controller (Xbox 360 Wireless Receiver for Windows),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ff02000000000000,Controller (Xbox One For Windows) - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ea02000000000000,Controller (Xbox One For Windows) - Wireless,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000007d0400000840000000000000,Destroyer Tiltpad,+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b1,b:b2,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,x:b0,y:b3,platform:Windows,",
-"03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
-"030000008f0e00000910000000000000,DualShock 2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Windows,",
-"030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000120c0000f61c000000000000,Elite,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000006f0e00008401000000000000,Faceoff Deluxe+ Audio Wired Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00008001000000000000,Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
-"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Windows,",
-"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000004618000000000000,GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000c01100000140000000000000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000102000000007801,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000009b2800003200000000000000,GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
-"030000009b2800006000000000000000,GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:+a5,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:+a2,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Windows,",
-"030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000007d0400000540000000000000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000001008000001e1000000000000,Havit HV-G60,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"030000000d0f00002d00000000000000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00001600000000007803,HORI Real Arcade Pro EX-SE (Xbox 360),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
-"030000000d0f00009c00000000000000,Hori TAC Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005500000000000000,Horipad 4 FPS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,platform:Windows,",
-"030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Windows,",
-"03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000491900000304000000000000,Ipega PG-9087 - Bluetooth Gamepad,+righty:+a5,-righty:-a4,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"030000006e0500000a20000000000000,JC-DUX60 ELECOM MMO Gamepad,a:b2,b:b3,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b14,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b15,righttrigger:b13,rightx:a3,righty:a4,start:b20,x:b0,y:b1,platform:Windows,",
-"030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
-"030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Windows,",
-"030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,platform:Windows,",
-"030000007e0500000620000000000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Windows,",
-"030000007e0500000720000000000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000bd12000003c0000000000000,JY-P70UR,a:b1,b:b0,back:b5,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b11,righttrigger:b9,rightx:a3,righty:a2,start:b4,x:b3,y:b2,platform:Windows,",
-"03000000242f00002d00000000000000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000242f00008a00000000000000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,platform:Windows,",
-"030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d0400001ac2000000000000,Logitech Precision Gamepad,a:b1,b:b2,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006d0400000ac2000000000000,Logitech WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Windows,",
-"03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,platform:Windows,",
-"03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000242f00007300000000000000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"0300000079000000d218000000000000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d620000010a7000000000000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,platform:Windows,",
-"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Windows,",
-"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000002418000000000000,Mega Drive,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b2,start:b9,x:b3,y:b4,platform:Windows,",
-"03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000c62400002a89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400002b89000000000000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400001a89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000c62400001b89000000000000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"030000006b140000010c000000000000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Windows,",
-"03000000550900001472000000000000,NVIDIA Controller v01.04,a:b11,b:b10,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b5,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b4,righttrigger:a5,rightx:a3,righty:a6,start:b3,x:b9,y:b8,platform:Windows,",
-"030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,platform:Windows,",
-"03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,platform:Windows,",
-"03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000901000000000000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000004c050000da0c000000000000,PlayStation Classic Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Windows,",
-"030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,",
-"030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
-"030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004c050000e60c000000000000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,platform:Windows,",
-"03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,platform:Windows,",
-"03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,platform:Windows,",
-"03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000507000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000321500000707000000000000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000321500000011000000000000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000321500000009000000000000,Razer Serval,+lefty:+a2,-lefty:-a1,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,leftx:a0,rightshoulder:b5,rightstick:b9,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000bd12000013d0000000000000,Retrolink USB SEGA Saturn Classic,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,lefttrigger:b6,rightshoulder:b2,righttrigger:b7,start:b8,x:b3,y:b4,platform:Windows,",
-"0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
-"0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Windows,",
-"030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b140000020d000000000000,Revolution Pro Controller 2(1/2),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006b140000130d000000000000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000a30600000701000000000000,Saitek P220,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b5,x:b0,y:b1,platform:Windows,",
-"03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b0,y:b1,platform:Windows,",
-"03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Windows,",
-"03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"03000000730700000401000000000000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Windows,",
-"0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005e0400008e02000000007801,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000d11800000094000000000000,Stadia Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b11,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000381000001214000000000000,SteelSeries Free,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000110100003114000000000000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,platform:Windows,",
-"03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000457500002211000000000000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f0400000ab1000000000000,T.16000M,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b10,x:b2,y:b3,platform:Windows,",
-"03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Windows,",
-"030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
-"030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f0400000ed0000000000000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Windows,",
-"030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Windows,",
-"03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Windows,",
-"03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"030000004f04000087b6000000000000,TWCS Throttle,dpdown:b8,dpleft:b9,dpright:b7,dpup:b6,leftstick:b5,lefttrigger:-a5,leftx:a0,lefty:a1,righttrigger:+a5,platform:Windows,",
-"03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"030000006e0500001320000000000000,U4113,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,platform:Windows,",
-"030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000790000001a18000000000000,Venom,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
-"03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000302000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"030000006f0e00000702000000000000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
-"0300000034120000adbe000000000000,vJoy Device,a:b0,b:b1,back:b15,dpdown:b6,dpleft:b7,dpright:b8,dpup:b5,guide:b16,leftshoulder:b9,leftstick:b13,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b14,righttrigger:b12,rightx:+a3,righty:+a4,start:b4,x:b2,y:b3,platform:Windows,",
-"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:-a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000ff02000000007801,Xbox One Elite Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"030000005e040000130b000000000000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
-"03000000ac0500005b05000000000000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Windows,",
-"03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000786901006e70000000000000,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,",
-"03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,platform:Windows,",
-"03000000120c0000101e000000000000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
-"030000008f0e00000300000009010000,2In1 USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000c82d00000090000001000000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001038000000010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000650000001000000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000c82d00005106000000010000,8BitDo M30 Gamepad,a:b1,b:b0,back:b10,guide:b2,leftshoulder:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001590000001000000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"030000003512000012ab000001000000,8BitDo NES30 Gamepad,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000190000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001290000001000000,8BitDo SN30 Gamepad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000160000001000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a5,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000260000001000000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00000031000001000000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00001890000001000000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a31,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,platform:Mac OS X,",
-"03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000c01100000140000000010000,GameStop PS4 Fun Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006f0e00000102000000000000,GameStop Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000007d0400000540000001010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00002d00000000100000,Hori Fighting Commander 3 Pro,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00009200000000010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000000d0f0000ee00000000010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,platform:Mac OS X,",
-"03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
-"03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Mac OS X,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000242f00002d00000007010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000019c2000005030000,Logitech F710,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000006d04000018c2000000010000,Logitech RumblePad 2 USB,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3~,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000242f00007300000000020000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Mac OS X,",
-"0300000079000000d218000026010000,Mayflash Magic NS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d620000010a7000003010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Mac OS X,",
-"03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,platform:Mac OS X,",
-"03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000005e0400002700000001010000,Microsoft SideWinder Plug & Play Game Pad,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,lefttrigger:b4,leftx:a0,lefty:a1,righttrigger:b5,x:b2,y:b3,platform:Mac OS X,",
-"03000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Mac OS X,",
-"03000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000c62400002b89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000632500007505000000020000,NEOGEO mini PAD Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d620000011a7000000020000,Nintendo Switch Core (Plus) Wired Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"030000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
-"03000000550900001472000025050000,NVIDIA Controller v01.04,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Mac OS X,",
-"030000006f0e00000901000002010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000004c050000da0c000000010000,Playstation Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000d62000006dca000000010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
-"030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,",
-"030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000507000001010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000321500000011000000010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000321500000009000000020000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006b140000130d000000010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000c6240000fefa000000000000,Rock Candy Gamepad for PS3,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000730700000401000000010000,Sanwa PlayOnline Mobile,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Mac OS X,",
-"03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,platform:Mac OS X,",
-"03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Mac OS X,",
-"030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Mac OS X,",
-"0300000000f00000f100000000000000,SNES RetroPort,a:b2,b:b3,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b5,rightshoulder:b7,start:b6,x:b0,y:b1,platform:Mac OS X,",
-"30000004c050000e60c0000000100000,Sony DualSense,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000d11800000094000000010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
-"03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,platform:Mac OS X,",
-"03000000457500002211000000010000,SZMY-POWER PC Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Mac OS X,",
-"030000004f0400000ed0000000020000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Mac OS X,",
-"03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,platform:Mac OS X,",
-"030000006f0e00000302000025040000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"030000006f0e00000702000003060000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000791d00000103000009010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Mac OS X,",
-"050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,platform:Mac OS X,",
-"050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,platform:Mac OS X,",
-"030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e0400000a0b000000000000,Xbox Adaptive Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000050b000003090000,Xbox Elite Wireless Controller Series 2,a:b0,b:b1,back:b31,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b53,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
-"030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Mac OS X,",
-"03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000120c0000101e000000010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Mac OS X,",
-"03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00001038000000010000,8Bitdo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00005106000000010000,8BitDo M30,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000c82d00001590000011010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00006528000000010000,8BitDo N30 Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000310000011010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c82d00008010000000010000,8BitDo NES30,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b9,righttrigger:b8,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000060000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d000021ab000010010000,8BitDo SFC30,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"030000003512000012ab000010010000,8Bitdo SFC30 GamePad,a:b2,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b0,platform:Linux,",
-"05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000160000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000160000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000161000000000000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00001290000011010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000161000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00006228000000010000,8BitDo SN30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00000260000011010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00000261000000010000,8BitDo SN30 Pro+,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000202800000900000000010000,8BitDo SNES30 Gamepad,a:b1,b:b0,back:b10,dpdown:b122,dpleft:b119,dpright:b120,dpup:b117,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"030000005e0400008e02000020010000,8BitDo Wireless Adapter,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c82d00000031000011010000,8BitDo Wireless Adapter,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"03000000c82d00001890000011010000,8BitDo Zero 2,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000c82d00003032000000010000,8BitDo Zero 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,rightx:a2,righty:a3,start:b11,x:b4,y:b3,platform:Linux,",
-"05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,platform:Linux,",
-"030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00003901000013020000,Afterglow Prismatic Wired Controller 048-007-NA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000007c1800000006000010010000,Alienware Dual Compatible Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
-"05000000050b00000045000040000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,platform:Linux,",
-"03000000120c00000500000010010000,AxisPad,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,platform:Linux,",
-"03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000c21100000791000011010000,Be1 GC101 Controller 1.03 mode,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000c31100000791000011010000,Be1 GC101 GAMEPAD 1.03 mode,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000003030000,Be1 GC101 Xbox 360 Controller mode,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,platform:Linux,",
-"03000000ffff0000ffff000000010000,Chinese-made Xbox Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000000b0400003365000000010000,Competition Pro,a:b0,b:b1,back:b2,leftx:a0,lefty:a1,start:b3,platform:Linux,",
-"03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
-"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
-"030000004f04000004b3000010010000,Dual Power 2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008f0e00000800000010010000,Gasia Co. Ltd PS(R) Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000007d0400000540000000010000,Gravis Eliminator GamePad Pro,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,platform:Linux,",
-"030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000f0250000c383000010010000,GT VX2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,platform:Linux,",
-"03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000632500002605000010010000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,platform:Linux,",
-"030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000c100000011010000,HORI CO. LTD. HORIPAD S,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00008500000010010000,HORI Fighting Commander,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00008600000002010000,Hori Fighting Commander,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000000d0f00009200000011010000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000aa00000011010000,HORI Real Arcade Pro,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000000d0f0000d800000072056800,HORI Real Arcade Pro S,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"030000000d0f00001600000000010000,Hori Real Arcade Pro.EX-SE (Xbox 360),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f0000ee00000011010000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000242e00008816000001010000,Hyperkin X91,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
-"050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,platform:Linux,",
-"03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,platform:Linux,",
-"0500000049190000020400001b010000,Ipega PG-9069 - Bluetooth Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b161,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000632500007505000011010000,Ipega PG-9099 - Bluetooth Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,platform:Linux,",
-"03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000300f00000b01000010010000,Jess Tech GGE909 PC Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"030000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
-"050000007e0500000620000001000000,Joy-Con (L),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b13,leftshoulder:b4,leftstick:b10,rightshoulder:b5,start:b8,x:b2,y:b3,platform:Linux,",
-"030000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
-"050000007e0500000720000001000000,Joy-Con (R),+leftx:h0.2,+lefty:h0.4,-leftx:h0.8,-lefty:h0.1,a:b0,b:b1,back:b12,leftshoulder:b4,leftstick:b11,rightshoulder:b5,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000242f00002d00000011010000,JYS Wireless Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000242f00008a00000011010000,JYS Wireless Adapter,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
-"030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400001ec2000019200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d0400000ac2000010010000,Logitech Inc. WingMan RumblePad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b2,rightx:a3,righty:a4,x:b3,y:b4,platform:Linux,",
-"030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,platform:Linux,",
-"05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000120c00000500000000010000,Manta Dualshock 2,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000790000004318000010010000,Mayflash GameCube Controller Adapter,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000242f00007300000011010000,Mayflash Magic NS,a:b1,b:b4,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b0,y:b3,platform:Linux,",
-"0300000079000000d218000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000d620000010a7000011010000,Mayflash Magic NS,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"0300000025090000e803000001010000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:a5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
-"03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000050b000003090000,Microsoft X-Box One Elite 2 pad,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000e302000003020000,Microsoft X-Box One Elite pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000dd02000003020000,Microsoft X-Box One pad (Firmware 2015),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"030000005e040000000b000008040000,Microsoft Xbox One Elite 2 pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000ea02000008040000,Microsoft Xbox One S pad - Wired,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c62400001a53000000010000,Mini PE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000030000000300000002000000,Miroof,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,platform:Linux,",
-"05000000d6200000e589000001000000,Moga 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000d62000007162000001000000,Moga Pro 2 HID,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Linux,",
-"03000000c62400002b89000011010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c62400002a89000000010000,MOGA XP5-A Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b22,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000c62400001a89000000010000,MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0f00000900000010010000,Natec Genesis P44,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Linux,",
-"060000007e0500000820000000000000,Nintendo Combined Joy-Cons (joycond),a:b0,b:b1,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1~,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3~,start:b8,x:b1,y:b3,platform:Linux,",
-"03000000790000004618000010010000,Nintendo GameCube Controller Adapter,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a5~,righty:a2~,start:b9,x:b0,y:b3,platform:Linux,",
-"050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"050000007e0500000920000001800000,Nintendo Switch Pro Controller (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"030000007e0500000920000011810000,Nintendo Switch Pro Controller Wired (joycond),a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b11,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b3,y:b2,platform:Linux,",
-"050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,platform:Linux,",
-"05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,platform:Linux,",
-"03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000550900001472000011010000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
-"05000000550900001472000001000000,NVIDIA Controller v01.04,a:b0,b:b1,back:b14,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Linux,",
-"03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"19000000010000000100000001010000,odroidgo2_joypad,a:b1,b:b0,dpdown:b7,dpleft:b8,dpright:b9,dpup:b6,guide:b10,leftshoulder:b4,leftstick:b12,lefttrigger:b11,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b13,righttrigger:b14,start:b15,x:b2,y:b3,platform:Linux,",
-"19000000010000000200000011000000,odroidgo2_joypad_v11,a:b1,b:b0,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b12,leftshoulder:b4,leftstick:b14,lefttrigger:b13,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:b16,start:b17,x:b2,y:b3,platform:Linux,",
-"030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,platform:Linux,",
-"05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
-"05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,platform:Linux,",
-"03000000830500005020000010010000,Padix Co. Ltd. Rockfire PSX/USB Bridge,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b2,y:b3,platform:Linux,",
-"03000000790000001c18000011010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e0000b802000001010000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e0000b802000013020000,PDP AFTERGLOW Wired Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008001000011010000,PDP CO. LTD. Faceoff Wired Pro Controller for Nintendo Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00003101000000010000,PDP EA Sports Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e0000c802000012010000,PDP Kingdom Hearts Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008701000011010000,PDP Rock Candy Wired Controller for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000006f0e00000901000011010000,PDP Versus Fighting Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e0000a802000023020000,PDP Wired Controller for Xbox One,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000006f0e00008501000011010000,PDP Wired Fight Pad Pro for Nintendo Switch,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"05000000491900000204000000000000,PG-9118,x:b76,a:b73,b:b74,y:b77,back:b83,start:b84,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b79,lefttrigger:b81,rightshoulder:b80,righttrigger:b82,leftstick:b86,rightstick:b87,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Linux,",
-"0500000049190000030400001b010000,PG-9099,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000004c050000da0c000011010000,Playstation Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c62400003a54000001010000,PowerA 1428124-01,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d62000006dca000011010000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000c62400001a58000001010000,PowerA Xbox One Cabled,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006d040000d2ca000011010000,Precision Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,",
-"030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"03000000c01100000140000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000c405000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,platform:Linux,",
-"030000004c050000e60c000011010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"050000004c050000e60c000000010000,PS5 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,platform:Linux,",
-"030000009b2800003200000001010000,Raphnet Technologies GC/N64 to USB v3.4,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
-"030000009b2800006000000001010000,Raphnet Technologies GC/N64 to USB v3.6,a:b0,b:b7,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,rightx:a3,righty:a4,start:b3,x:b1,y:b8,platform:Linux,",
-"030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,platform:Linux,",
-"030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000810000011010000,Razer Panthera Evo Arcade Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000321500000507000000010000,Razer Raiju Mobile,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000321500000011000011010000,Razer Raion Fightpad for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"0300000081170000990a000001010000,Retronic Adapter,a:b0,leftx:a0,lefty:a1,platform:Linux,",
-"0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
-"030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006b140000130d000011010000,Revolution Pro Controller 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b0,y:b1,platform:Linux,",
-"03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,platform:Linux,",
-"03000000300f00001201000010010000,Saitek P380,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,platform:Linux,",
-"03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,platform:Linux,",
-"03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,platform:Linux,",
-"03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a306000020f6000011010000,Saitek PS2700 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000a30600001005000000010000,Saitek Saitek P150,a:b0,b:b1,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b7,lefttrigger:b6,rightshoulder:b2,righttrigger:b5,x:b3,y:b4,platform:Linux,",
-"03000000d81d00000e00000010010000,Savior,a:b0,b:b1,back:b8,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b11,righttrigger:b3,start:b9,x:b4,y:b5,platform:Linux,",
-"03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,platform:Linux,",
-"03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000bc2000000055000010010000,ShanWan PS3/PC Wired GamePad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000d11800000094000011010000,Stadia Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800000211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
-"03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de2800004211000011010000,Steam Controller,a:b2,b:b3,back:b10,dpdown:b18,dpleft:b19,dpright:b20,dpup:b17,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b5,platform:Linux,",
-"03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000381000003014000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000381000003114000075010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000003b07000004a1000000010000,Suncom SFX Plus for USB,a:b0,b:b2,back:b7,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:b5,start:b8,x:b1,y:b3,platform:Linux,",
-"03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,platform:Linux,",
-"0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,platform:Linux,",
-"03000000457500002211000010010000,SZMY-POWER CO. LTD. GAMEPAD,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"030000008f0e00000d31000010010000,SZMY-POWER CO. LTD. GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f0400000ed0000011010000,ThrustMaster eSwap PRO Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000b50700000399000000010000,Thrustmaster Firestorm Digital 2,a:b2,b:b4,back:b11,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b8,rightstick:b0,righttrigger:b9,start:b1,x:b3,y:b5,platform:Linux,",
-"030000004f04000003b3000010010000,Thrustmaster Firestorm Dual Analog 2,a:b0,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b9,rightx:a2,righty:a3,x:b1,y:b3,platform:Linux,",
-"030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,platform:Linux,",
-"030000004f04000026b3000002040000,Thrustmaster Gamepad GP XID,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c6240000025b000002020000,Thrustmaster GPX Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000007d0000000010000,Thrustmaster T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,",
-"030000004f04000012b3000010010000,Thrustmaster vibrating gamepad,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,platform:Linux,",
-"03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,platform:Linux,",
-"030000005e0400008e02000070050000,Torid,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000c01100000591000011010000,Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Linux,",
-"03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,platform:Linux,",
-"030000006f0e00000302000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"030000006f0e00000702000011010000,Victrix Pro Fight Stick for PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000791d00000103000010010000,Wii Classic Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"050000000d0f0000f600000001000000,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Linux,",
-"030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000d102000002010000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000fd02000030110000,Xbox One Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000050b000002090000,Xbox One Elite Series 2,a:b0,b:b1,back:b136,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a6,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000ea02000000000000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e040000ea02000001030000,Xbox One Wireless Controller (Model 1708),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000120b000001050000,Xbox Series Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"030000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"050000005e040000130b000001050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"050000005e040000130b000005050000,Xbox Series Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,platform:Linux,",
-"030000005e0400008e02000000010000,xbox360 Wireless EasySMX,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,",
-"03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,",
-"03000000ac0500005b05000010010000,Xiaoji Gamesir-G3w,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,platform:Linux,",
-"05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,platform:Linux,",
-"03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,platform:Linux,",
-"03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,",
-"05000000c82d000006500000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a4,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000051060000ffff3f00,8BitDo M30 Gamepad,a:b1,b:b0,back:b4,guide:b17,leftshoulder:b9,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000015900000ffff3f00,8BitDo N30 Pro 2,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000065280000ffff3f00,8BitDo N30 Pro 2,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b17,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000000220000000900000ffff3f00,8BitDo NES30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000002038000009000000ffff3f00,8BitDo NES30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000000600000ffff3f00,8BitDo SF30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000000610000ffff3f00,8BitDo SF30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000012900000ffff3f00,8BitDo SN30 Gamepad,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000062280000ffff3f00,8BitDo SN30 Gamepad,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000001600000ffff3f00,8BitDo SN30 Pro,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000002600000ffff0f00,8BitDo SN30 Pro+,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b17,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000002028000009000000ffff3f00,8BitDo SNES30 Gamepad,a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,platform:Android,",
-"050000003512000020ab000000780f00,8BitDo SNES30 Gamepad,a:b21,b:b20,back:b30,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b26,rightshoulder:b27,start:b31,x:b24,y:b23,platform:Android,",
-"05000000c82d000018900000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,platform:Android,",
-"05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"0500000031366332860c44aadfff0f00,GS Gamepad,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"0500000083050000602000000ffe0000,iBuffalo SNES Controller,a:b1,b:b0,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b15,rightshoulder:b16,start:b10,x:b3,y:b2,platform:Android,",
-"64633436313965656664373634323364,Microsoft X-Box 360 pad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,",
-"7573622067616d657061642020202020,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Android,",
-"050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,platform:Android,",
-"37336435666338653565313731303834,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"61363931656135336130663561616264,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005509000014720000df7f3f00,NVIDIA Controller v01.04,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"030000004c050000cc09000000006800,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000cc090000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"35643031303033326130316330353564,PS4 Controller,a:b1,b:b17,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"050000004c050000e60c0000fffe3f00,PS5 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,platform:Android,",
-"62653861643333663663383332396665,Razer Kishi,a:b0,b:b1,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000005070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,platform:Android,",
-"32633532643734376632656664383733,Sony DualSense,a:b1,b:b19,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a5,start:b18,x:b0,y:b2,platform:Android,",
-"61303162353165316365336436343139,Sony DualSense,a:b1,b:b19,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a5,start:b18,x:b0,y:b2,platform:Android,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:Android,",
-"050000004f0400000ed00000fffe3f00,ThrustMaster eSwap PRO Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"5477696e20555342204a6f7973746963,Twin USB Joystick,a:b22,b:b21,back:b28,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b26,leftstick:b30,lefttrigger:b24,leftx:a0,lefty:a1,rightshoulder:b27,rightstick:b31,righttrigger:b25,rightx:a3,righty:a2,start:b29,x:b23,y:b20,platform:Android,",
-"30306539356238653637313730656134,Wireless HORIPAD Switch Pro Controller,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b3,leftstick:b15,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b18,x:b19,y:b2,platform:Android,",
-"050000005e040000fd020000ff7f3f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,platform:Android,",
-"050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e040000130b0000ffff3f00,Xbox Series Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"65633038363832353634653836396239,Xbox Series Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,platform:Android,",
-"050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:Android,",
-"34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,platform:Android,",
-"050000001727000044310000ffff3f00,XiaoMi Game Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a6,rightx:a2,righty:a5,start:b6,x:b2,y:b3,platform:Android,",
-"05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac050000010000004f066d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000cf076d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000df076d01,*,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"05000000ac05000001000000ff076d01,*,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"05000000ac0500000200000000006d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,",
-"05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,platform:iOS,",
-"4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,platform:iOS,",
-"4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"050000004c050000cc090000ff870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,platform:iOS,",
-"05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,",
-"05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,platform:iOS,",
-"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,",
-"05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,platform:iOS,",
-"050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-"050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,platform:iOS,",
-"050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,platform:iOS,",
-
-"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-NULL
-};
-
diff --git a/raylib_pi4_test/external/glfw/src/mappings.h.in b/raylib_pi4_test/external/glfw/src/mappings.h.in
deleted file mode 100644 (file)
index 583e98b..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// As mappings.h.in, this file is used by CMake to produce the mappings.h
-// header file.  If you are adding a GLFW specific gamepad mapping, this is
-// where to put it.
-//========================================================================
-// As mappings.h, this provides all pre-defined gamepad mappings, including
-// all available in SDL_GameControllerDB.  Do not edit this file.  Any gamepad
-// mappings not specific to GLFW should be submitted to SDL_GameControllerDB.
-// This file can be re-generated from mappings.h.in and the upstream
-// gamecontrollerdb.txt with the GenerateMappings.cmake script.
-//========================================================================
-
-// All gamepad mappings not labeled GLFW are copied from the
-// SDL_GameControllerDB project under the following license:
-//
-// Simple DirectMedia Layer
-// Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the
-// use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not be
-//    misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-
-const char* _glfwDefaultMappings[] =
-{
-@GLFW_GAMEPAD_MAPPINGS@
-"78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757402000000000000000000,XInput Wheel (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757403000000000000000000,XInput Arcade Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757404000000000000000000,XInput Flight Stick (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757405000000000000000000,XInput Dance Pad (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757406000000000000000000,XInput Guitar (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-"78696e70757408000000000000000000,XInput Drum Kit (GLFW),platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8,",
-NULL
-};
-
diff --git a/raylib_pi4_test/external/glfw/src/monitor.c b/raylib_pi4_test/external/glfw/src/monitor.c
deleted file mode 100644 (file)
index 394026f..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <math.h>
-#include <float.h>
-#include <string.h>
-#include <stdlib.h>
-#include <limits.h>
-
-
-// Lexically compare video modes, used by qsort
-//
-static int compareVideoModes(const void* fp, const void* sp)
-{
-    const GLFWvidmode* fm = fp;
-    const GLFWvidmode* sm = sp;
-    const int fbpp = fm->redBits + fm->greenBits + fm->blueBits;
-    const int sbpp = sm->redBits + sm->greenBits + sm->blueBits;
-    const int farea = fm->width * fm->height;
-    const int sarea = sm->width * sm->height;
-
-    // First sort on color bits per pixel
-    if (fbpp != sbpp)
-        return fbpp - sbpp;
-
-    // Then sort on screen area
-    if (farea != sarea)
-        return farea - sarea;
-
-    // Then sort on width
-    if (fm->width != sm->width)
-        return fm->width - sm->width;
-
-    // Lastly sort on refresh rate
-    return fm->refreshRate - sm->refreshRate;
-}
-
-// Retrieves the available modes for the specified monitor
-//
-static GLFWbool refreshVideoModes(_GLFWmonitor* monitor)
-{
-    int modeCount;
-    GLFWvidmode* modes;
-
-    if (monitor->modes)
-        return GLFW_TRUE;
-
-    modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
-    if (!modes)
-        return GLFW_FALSE;
-
-    qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);
-
-    free(monitor->modes);
-    monitor->modes = modes;
-    monitor->modeCount = modeCount;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code of a monitor connection or disconnection
-//
-void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement)
-{
-    if (action == GLFW_CONNECTED)
-    {
-        _glfw.monitorCount++;
-        _glfw.monitors =
-            realloc(_glfw.monitors, sizeof(_GLFWmonitor*) * _glfw.monitorCount);
-
-        if (placement == _GLFW_INSERT_FIRST)
-        {
-            memmove(_glfw.monitors + 1,
-                    _glfw.monitors,
-                    ((size_t) _glfw.monitorCount - 1) * sizeof(_GLFWmonitor*));
-            _glfw.monitors[0] = monitor;
-        }
-        else
-            _glfw.monitors[_glfw.monitorCount - 1] = monitor;
-    }
-    else if (action == GLFW_DISCONNECTED)
-    {
-        int i;
-        _GLFWwindow* window;
-
-        for (window = _glfw.windowListHead;  window;  window = window->next)
-        {
-            if (window->monitor == monitor)
-            {
-                int width, height, xoff, yoff;
-                _glfwPlatformGetWindowSize(window, &width, &height);
-                _glfwPlatformSetWindowMonitor(window, NULL, 0, 0, width, height, 0);
-                _glfwPlatformGetWindowFrameSize(window, &xoff, &yoff, NULL, NULL);
-                _glfwPlatformSetWindowPos(window, xoff, yoff);
-            }
-        }
-
-        for (i = 0;  i < _glfw.monitorCount;  i++)
-        {
-            if (_glfw.monitors[i] == monitor)
-            {
-                _glfw.monitorCount--;
-                memmove(_glfw.monitors + i,
-                        _glfw.monitors + i + 1,
-                        ((size_t) _glfw.monitorCount - i) * sizeof(_GLFWmonitor*));
-                break;
-            }
-        }
-    }
-
-    if (_glfw.callbacks.monitor)
-        _glfw.callbacks.monitor((GLFWmonitor*) monitor, action);
-
-    if (action == GLFW_DISCONNECTED)
-        _glfwFreeMonitor(monitor);
-}
-
-// Notifies shared code that a full screen window has acquired or released
-// a monitor
-//
-void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window)
-{
-    monitor->window = window;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Allocates and returns a monitor object with the specified name and dimensions
-//
-_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM)
-{
-    _GLFWmonitor* monitor = calloc(1, sizeof(_GLFWmonitor));
-    monitor->widthMM = widthMM;
-    monitor->heightMM = heightMM;
-
-    if (name)
-        monitor->name = _glfw_strdup(name);
-
-    return monitor;
-}
-
-// Frees a monitor object and any data associated with it
-//
-void _glfwFreeMonitor(_GLFWmonitor* monitor)
-{
-    if (monitor == NULL)
-        return;
-
-    _glfwPlatformFreeMonitor(monitor);
-
-    _glfwFreeGammaArrays(&monitor->originalRamp);
-    _glfwFreeGammaArrays(&monitor->currentRamp);
-
-    free(monitor->modes);
-    free(monitor->name);
-    free(monitor);
-}
-
-// Allocates red, green and blue value arrays of the specified size
-//
-void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size)
-{
-    ramp->red = calloc(size, sizeof(unsigned short));
-    ramp->green = calloc(size, sizeof(unsigned short));
-    ramp->blue = calloc(size, sizeof(unsigned short));
-    ramp->size = size;
-}
-
-// Frees the red, green and blue value arrays and clears the struct
-//
-void _glfwFreeGammaArrays(GLFWgammaramp* ramp)
-{
-    free(ramp->red);
-    free(ramp->green);
-    free(ramp->blue);
-
-    memset(ramp, 0, sizeof(GLFWgammaramp));
-}
-
-// Chooses the video mode most closely matching the desired one
-//
-const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
-                                        const GLFWvidmode* desired)
-{
-    int i;
-    unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
-    unsigned int rateDiff, leastRateDiff = UINT_MAX;
-    unsigned int colorDiff, leastColorDiff = UINT_MAX;
-    const GLFWvidmode* current;
-    const GLFWvidmode* closest = NULL;
-
-    if (!refreshVideoModes(monitor))
-        return NULL;
-
-    for (i = 0;  i < monitor->modeCount;  i++)
-    {
-        current = monitor->modes + i;
-
-        colorDiff = 0;
-
-        if (desired->redBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->redBits - desired->redBits);
-        if (desired->greenBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->greenBits - desired->greenBits);
-        if (desired->blueBits != GLFW_DONT_CARE)
-            colorDiff += abs(current->blueBits - desired->blueBits);
-
-        sizeDiff = abs((current->width - desired->width) *
-                       (current->width - desired->width) +
-                       (current->height - desired->height) *
-                       (current->height - desired->height));
-
-        if (desired->refreshRate != GLFW_DONT_CARE)
-            rateDiff = abs(current->refreshRate - desired->refreshRate);
-        else
-            rateDiff = UINT_MAX - current->refreshRate;
-
-        if ((colorDiff < leastColorDiff) ||
-            (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff) ||
-            (colorDiff == leastColorDiff && sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
-        {
-            closest = current;
-            leastSizeDiff = sizeDiff;
-            leastRateDiff = rateDiff;
-            leastColorDiff = colorDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Performs lexical comparison between two @ref GLFWvidmode structures
-//
-int _glfwCompareVideoModes(const GLFWvidmode* fm, const GLFWvidmode* sm)
-{
-    return compareVideoModes(fm, sm);
-}
-
-// Splits a color depth into red, green and blue bit depths
-//
-void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
-{
-    int delta;
-
-    // We assume that by 32 the user really meant 24
-    if (bpp == 32)
-        bpp = 24;
-
-    // Convert "bits per pixel" to red, green & blue sizes
-
-    *red = *green = *blue = bpp / 3;
-    delta = bpp - (*red * 3);
-    if (delta >= 1)
-        *green = *green + 1;
-
-    if (delta == 2)
-        *red = *red + 1;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLFWmonitor** glfwGetMonitors(int* count)
-{
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    *count = _glfw.monitorCount;
-    return (GLFWmonitor**) _glfw.monitors;
-}
-
-GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfw.monitorCount)
-        return NULL;
-
-    return (GLFWmonitor*) _glfw.monitors[0];
-}
-
-GLFWAPI void glfwGetMonitorPos(GLFWmonitor* handle, int* xpos, int* ypos)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformGetMonitorPos(monitor, xpos, ypos);
-}
-
-GLFWAPI void glfwGetMonitorWorkarea(GLFWmonitor* handle,
-                                    int* xpos, int* ypos,
-                                    int* width, int* height)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformGetMonitorWorkarea(monitor, xpos, ypos, width, height);
-}
-
-GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* handle, int* widthMM, int* heightMM)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (widthMM)
-        *widthMM = 0;
-    if (heightMM)
-        *heightMM = 0;
-
-    _GLFW_REQUIRE_INIT();
-
-    if (widthMM)
-        *widthMM = monitor->widthMM;
-    if (heightMM)
-        *heightMM = monitor->heightMM;
-}
-
-GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* handle,
-                                        float* xscale, float* yscale)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    if (xscale)
-        *xscale = 0.f;
-    if (yscale)
-        *yscale = 0.f;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetMonitorContentScale(monitor, xscale, yscale);
-}
-
-GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->name;
-}
-
-GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    monitor->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->userPointer;
-}
-
-GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
-    return cbfun;
-}
-
-GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!refreshVideoModes(monitor))
-        return NULL;
-
-    *count = monitor->modeCount;
-    return monitor->modes;
-}
-
-GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    _glfwPlatformGetVideoMode(monitor, &monitor->currentMode);
-    return &monitor->currentMode;
-}
-
-GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
-{
-    unsigned int i;
-    unsigned short* values;
-    GLFWgammaramp ramp;
-    const GLFWgammaramp* original;
-    assert(handle != NULL);
-    assert(gamma > 0.f);
-    assert(gamma <= FLT_MAX);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (gamma != gamma || gamma <= 0.f || gamma > FLT_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid gamma value %f", gamma);
-        return;
-    }
-
-    original = glfwGetGammaRamp(handle);
-    if (!original)
-        return;
-
-    values = calloc(original->size, sizeof(unsigned short));
-
-    for (i = 0;  i < original->size;  i++)
-    {
-        float value;
-
-        // Calculate intensity
-        value = i / (float) (original->size - 1);
-        // Apply gamma curve
-        value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
-        // Clamp to value range
-        value = _glfw_fminf(value, 65535.f);
-
-        values[i] = (unsigned short) value;
-    }
-
-    ramp.red = values;
-    ramp.green = values;
-    ramp.blue = values;
-    ramp.size = original->size;
-
-    glfwSetGammaRamp(handle, &ramp);
-    free(values);
-}
-
-GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    _glfwFreeGammaArrays(&monitor->currentRamp);
-    if (!_glfwPlatformGetGammaRamp(monitor, &monitor->currentRamp))
-        return NULL;
-
-    return &monitor->currentRamp;
-}
-
-GLFWAPI void glfwSetGammaRamp(GLFWmonitor* handle, const GLFWgammaramp* ramp)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    assert(monitor != NULL);
-    assert(ramp != NULL);
-    assert(ramp->size > 0);
-    assert(ramp->red != NULL);
-    assert(ramp->green != NULL);
-    assert(ramp->blue != NULL);
-
-    if (ramp->size <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid gamma ramp size %i",
-                        ramp->size);
-        return;
-    }
-
-    _GLFW_REQUIRE_INIT();
-
-    if (!monitor->originalRamp.size)
-    {
-        if (!_glfwPlatformGetGammaRamp(monitor, &monitor->originalRamp))
-            return;
-    }
-
-    _glfwPlatformSetGammaRamp(monitor, ramp);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/nsgl_context.h b/raylib_pi4_test/external/glfw/src/nsgl_context.h
deleted file mode 100644 (file)
index 9c31436..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-// NOTE: Many Cocoa enum values have been renamed and we need to build across
-//       SDK versions where one is unavailable or the other deprecated
-//       We use the newer names in code and these macros to handle compatibility
-#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
- #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
- #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
-#endif
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextNSGL nsgl
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryNSGL nsgl
-
-#include <stdatomic.h>
-
-
-// NSGL-specific per-context data
-//
-typedef struct _GLFWcontextNSGL
-{
-    id                pixelFormat;
-    id                object;
-
-} _GLFWcontextNSGL;
-
-// NSGL-specific global data
-//
-typedef struct _GLFWlibraryNSGL
-{
-    // dlopen handle for OpenGL.framework (for glfwGetProcAddress)
-    CFBundleRef     framework;
-
-} _GLFWlibraryNSGL;
-
-
-GLFWbool _glfwInitNSGL(void);
-void _glfwTerminateNSGL(void);
-GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
-                                const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* fbconfig);
-void _glfwDestroyContextNSGL(_GLFWwindow* window);
-
diff --git a/raylib_pi4_test/external/glfw/src/nsgl_context.m b/raylib_pi4_test/external/glfw/src/nsgl_context.m
deleted file mode 100644 (file)
index 3f73f7a..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-//========================================================================
-// GLFW 3.4 macOS - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <math.h>
-
-static void makeContextCurrentNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    if (window)
-        [window->context.nsgl.object makeCurrentContext];
-    else
-        [NSOpenGLContext clearCurrentContext];
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-
-    } // autoreleasepool
-}
-
-static void swapBuffersNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    // HACK: Simulate vsync with usleep as NSGL swap interval does not apply to
-    //       windows with a non-visible occlusion state
-    if (window->ns.occluded)
-    {
-        int interval = 0;
-        [window->context.nsgl.object getValues:&interval
-                                  forParameter:NSOpenGLContextParameterSwapInterval];
-
-        if (interval > 0)
-        {
-            const double framerate = 60.0;
-            const uint64_t frequency = _glfwPlatformGetTimerFrequency();
-            const uint64_t value = _glfwPlatformGetTimerValue();
-
-            const double elapsed = value / (double) frequency;
-            const double period = 1.0 / framerate;
-            const double delay = period - fmod(elapsed, period);
-
-            usleep(floorl(delay * 1e6));
-        }
-    }
-
-    [window->context.nsgl.object flushBuffer];
-
-    } // autoreleasepool
-}
-
-static void swapIntervalNSGL(int interval)
-{
-    @autoreleasepool {
-
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-    if (window)
-    {
-        [window->context.nsgl.object setValues:&interval
-                                  forParameter:NSOpenGLContextParameterSwapInterval];
-    }
-
-    } // autoreleasepool
-}
-
-static int extensionSupportedNSGL(const char* extension)
-{
-    // There are no NSGL extensions
-    return GLFW_FALSE;
-}
-
-static GLFWglproc getProcAddressNSGL(const char* procname)
-{
-    CFStringRef symbolName = CFStringCreateWithCString(kCFAllocatorDefault,
-                                                       procname,
-                                                       kCFStringEncodingASCII);
-
-    GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
-                                                          symbolName);
-
-    CFRelease(symbolName);
-
-    return symbol;
-}
-
-static void destroyContextNSGL(_GLFWwindow* window)
-{
-    @autoreleasepool {
-
-    [window->context.nsgl.pixelFormat release];
-    window->context.nsgl.pixelFormat = nil;
-
-    [window->context.nsgl.object release];
-    window->context.nsgl.object = nil;
-
-    } // autoreleasepool
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize OpenGL support
-//
-GLFWbool _glfwInitNSGL(void)
-{
-    if (_glfw.nsgl.framework)
-        return GLFW_TRUE;
-
-    _glfw.nsgl.framework =
-        CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
-    if (_glfw.nsgl.framework == NULL)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "NSGL: Failed to locate OpenGL framework");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Terminate OpenGL support
-//
-void _glfwTerminateNSGL(void)
-{
-}
-
-// Create the OpenGL context
-//
-GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
-                                const _GLFWctxconfig* ctxconfig,
-                                const _GLFWfbconfig* fbconfig)
-{
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "NSGL: OpenGL ES is not available on macOS");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->major > 2)
-    {
-        if (ctxconfig->major == 3 && ctxconfig->minor < 2)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
-            return GLFW_FALSE;
-        }
-    }
-
-    // Context robustness modes (GL_KHR_robustness) are not yet supported by
-    // macOS but are not a hard constraint, so ignore and continue
-
-    // Context release behaviors (GL_KHR_context_flush_control) are not yet
-    // supported by macOS but are not a hard constraint, so ignore and continue
-
-    // Debug contexts (GL_KHR_debug) are not yet supported by macOS but are not
-    // a hard constraint, so ignore and continue
-
-    // No-error contexts (GL_KHR_no_error) are not yet supported by macOS but
-    // are not a hard constraint, so ignore and continue
-
-#define addAttrib(a) \
-{ \
-    assert((size_t) index < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-}
-#define setAttrib(a, v) { addAttrib(a); addAttrib(v); }
-
-    NSOpenGLPixelFormatAttribute attribs[40];
-    int index = 0;
-
-    addAttrib(NSOpenGLPFAAccelerated);
-    addAttrib(NSOpenGLPFAClosestPolicy);
-
-    if (ctxconfig->nsgl.offline)
-    {
-        addAttrib(NSOpenGLPFAAllowOfflineRenderers);
-        // NOTE: This replaces the NSSupportsAutomaticGraphicsSwitching key in
-        //       Info.plist for unbundled applications
-        // HACK: This assumes that NSOpenGLPixelFormat will remain
-        //       a straightforward wrapper of its CGL counterpart
-        addAttrib(kCGLPFASupportsAutomaticGraphicsSwitching);
-    }
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
-    if (ctxconfig->major >= 4)
-    {
-        setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core);
-    }
-    else
-#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
-    if (ctxconfig->major >= 3)
-    {
-        setAttrib(NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core);
-    }
-
-    if (ctxconfig->major <= 2)
-    {
-        if (fbconfig->auxBuffers != GLFW_DONT_CARE)
-            setAttrib(NSOpenGLPFAAuxBuffers, fbconfig->auxBuffers);
-
-        if (fbconfig->accumRedBits != GLFW_DONT_CARE &&
-            fbconfig->accumGreenBits != GLFW_DONT_CARE &&
-            fbconfig->accumBlueBits != GLFW_DONT_CARE &&
-            fbconfig->accumAlphaBits != GLFW_DONT_CARE)
-        {
-            const int accumBits = fbconfig->accumRedBits +
-                                  fbconfig->accumGreenBits +
-                                  fbconfig->accumBlueBits +
-                                  fbconfig->accumAlphaBits;
-
-            setAttrib(NSOpenGLPFAAccumSize, accumBits);
-        }
-    }
-
-    if (fbconfig->redBits != GLFW_DONT_CARE &&
-        fbconfig->greenBits != GLFW_DONT_CARE &&
-        fbconfig->blueBits != GLFW_DONT_CARE)
-    {
-        int colorBits = fbconfig->redBits +
-                        fbconfig->greenBits +
-                        fbconfig->blueBits;
-
-        // macOS needs non-zero color size, so set reasonable values
-        if (colorBits == 0)
-            colorBits = 24;
-        else if (colorBits < 15)
-            colorBits = 15;
-
-        setAttrib(NSOpenGLPFAColorSize, colorBits);
-    }
-
-    if (fbconfig->alphaBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFAAlphaSize, fbconfig->alphaBits);
-
-    if (fbconfig->depthBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFADepthSize, fbconfig->depthBits);
-
-    if (fbconfig->stencilBits != GLFW_DONT_CARE)
-        setAttrib(NSOpenGLPFAStencilSize, fbconfig->stencilBits);
-
-    if (fbconfig->stereo)
-    {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "NSGL: Stereo rendering is deprecated");
-        return GLFW_FALSE;
-#else
-        addAttrib(NSOpenGLPFAStereo);
-#endif
-    }
-
-    if (fbconfig->doublebuffer)
-        addAttrib(NSOpenGLPFADoubleBuffer);
-
-    if (fbconfig->samples != GLFW_DONT_CARE)
-    {
-        if (fbconfig->samples == 0)
-        {
-            setAttrib(NSOpenGLPFASampleBuffers, 0);
-        }
-        else
-        {
-            setAttrib(NSOpenGLPFASampleBuffers, 1);
-            setAttrib(NSOpenGLPFASamples, fbconfig->samples);
-        }
-    }
-
-    // NOTE: All NSOpenGLPixelFormats on the relevant cards support sRGB
-    //       framebuffer, so there's no need (and no way) to request it
-
-    addAttrib(0);
-
-#undef addAttrib
-#undef setAttrib
-
-    window->context.nsgl.pixelFormat =
-        [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
-    if (window->context.nsgl.pixelFormat == nil)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "NSGL: Failed to find a suitable pixel format");
-        return GLFW_FALSE;
-    }
-
-    NSOpenGLContext* share = nil;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.nsgl.object;
-
-    window->context.nsgl.object =
-        [[NSOpenGLContext alloc] initWithFormat:window->context.nsgl.pixelFormat
-                                   shareContext:share];
-    if (window->context.nsgl.object == nil)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "NSGL: Failed to create OpenGL context");
-        return GLFW_FALSE;
-    }
-
-    if (fbconfig->transparent)
-    {
-        GLint opaque = 0;
-        [window->context.nsgl.object setValues:&opaque
-                                  forParameter:NSOpenGLContextParameterSurfaceOpacity];
-    }
-
-    [window->ns.view setWantsBestResolutionOpenGLSurface:window->ns.retina];
-
-    [window->context.nsgl.object setView:window->ns.view];
-
-    window->context.makeCurrent = makeContextCurrentNSGL;
-    window->context.swapBuffers = swapBuffersNSGL;
-    window->context.swapInterval = swapIntervalNSGL;
-    window->context.extensionSupported = extensionSupportedNSGL;
-    window->context.getProcAddress = getProcAddressNSGL;
-    window->context.destroy = destroyContextNSGL;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(nil);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return nil;
-    }
-
-    return window->context.nsgl.object;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/null_init.c b/raylib_pi4_test/external/glfw/src/null_init.c
deleted file mode 100644 (file)
index 57aafd5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    _glfwInitTimerPOSIX();
-    _glfwPollMonitorsNull();
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    free(_glfw.null.clipboardString);
-    _glfwTerminateOSMesa();
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " null OSMesa";
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/null_joystick.c b/raylib_pi4_test/external/glfw/src/null_joystick.c
deleted file mode 100644 (file)
index 27756a6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/null_joystick.h b/raylib_pi4_test/external/glfw/src/null_joystick.h
deleted file mode 100644 (file)
index 5d19a45..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         struct { int dummyJoystick; }
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME ""
-
diff --git a/raylib_pi4_test/external/glfw/src/null_monitor.c b/raylib_pi4_test/external/glfw/src/null_monitor.c
deleted file mode 100644 (file)
index 8301eb3..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-// The the sole (fake) video mode of our (sole) fake monitor
-//
-static GLFWvidmode getVideoMode(void)
-{
-    GLFWvidmode mode;
-    mode.width = 1920;
-    mode.height = 1080;
-    mode.redBits = 8;
-    mode.greenBits = 8;
-    mode.blueBits = 8;
-    mode.refreshRate = 60;
-    return mode;
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPollMonitorsNull(void)
-{
-    const float dpi = 141.f;
-    const GLFWvidmode mode = getVideoMode();
-    _GLFWmonitor* monitor = _glfwAllocMonitor("Null SuperNoop 0",
-                                              (int) (mode.width * 25.4f / dpi),
-                                              (int) (mode.height * 25.4f / dpi));
-    _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-    _glfwFreeGammaArrays(&monitor->null.ramp);
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = 1.f;
-    if (yscale)
-        *yscale = 1.f;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    const GLFWvidmode mode = getVideoMode();
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 10;
-    if (width)
-        *width = mode.width;
-    if (height)
-        *height = mode.height - 10;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
-{
-    GLFWvidmode* mode = calloc(1, sizeof(GLFWvidmode));
-    *mode = getVideoMode();
-    *found = 1;
-    return mode;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    *mode = getVideoMode();
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    if (!monitor->null.ramp.size)
-    {
-        _glfwAllocGammaArrays(&monitor->null.ramp, 256);
-
-        for (unsigned int i = 0;  i < monitor->null.ramp.size;  i++)
-        {
-            const float gamma = 2.2f;
-            float value;
-            value = i / (float) (monitor->null.ramp.size - 1);
-            value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
-            value = _glfw_fminf(value, 65535.f);
-
-            monitor->null.ramp.red[i]   = (unsigned short) value;
-            monitor->null.ramp.green[i] = (unsigned short) value;
-            monitor->null.ramp.blue[i]  = (unsigned short) value;
-        }
-    }
-
-    _glfwAllocGammaArrays(ramp, monitor->null.ramp.size);
-    memcpy(ramp->red,   monitor->null.ramp.red,   sizeof(short) * ramp->size);
-    memcpy(ramp->green, monitor->null.ramp.green, sizeof(short) * ramp->size);
-    memcpy(ramp->blue,  monitor->null.ramp.blue,  sizeof(short) * ramp->size);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    if (monitor->null.ramp.size != ramp->size)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Null: Gamma ramp size must match current ramp size");
-        return;
-    }
-
-    memcpy(monitor->null.ramp.red,   ramp->red,   sizeof(short) * ramp->size);
-    memcpy(monitor->null.ramp.green, ramp->green, sizeof(short) * ramp->size);
-    memcpy(monitor->null.ramp.blue,  ramp->blue,  sizeof(short) * ramp->size);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/null_platform.h b/raylib_pi4_test/external/glfw/src/null_platform.h
deleted file mode 100644 (file)
index 49436dc..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <dlfcn.h>
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowNull null
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNull null
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorNull null
-
-#define _GLFW_PLATFORM_CONTEXT_STATE         struct { int dummyContext; }
-#define _GLFW_PLATFORM_CURSOR_STATE          struct { int dummyCursor; }
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
-
-#include "posix_time.h"
-#include "posix_thread.h"
-#include "null_joystick.h"
-
-#if defined(_GLFW_WIN32)
- #define _glfw_dlopen(name) LoadLibraryA(name)
- #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
- #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
-#else
- #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
- #define _glfw_dlclose(handle) dlclose(handle)
- #define _glfw_dlsym(handle, name) dlsym(handle, name)
-#endif
-
-// Null-specific per-window data
-//
-typedef struct _GLFWwindowNull
-{
-    int             xpos;
-    int             ypos;
-    int             width;
-    int             height;
-    char*           title;
-    GLFWbool        visible;
-    GLFWbool        iconified;
-    GLFWbool        maximized;
-    GLFWbool        resizable;
-    GLFWbool        decorated;
-    GLFWbool        floating;
-    GLFWbool        transparent;
-    float           opacity;
-} _GLFWwindowNull;
-
-// Null-specific per-monitor data
-//
-typedef struct _GLFWmonitorNull
-{
-    GLFWgammaramp   ramp;
-} _GLFWmonitorNull;
-
-// Null-specific global data
-//
-typedef struct _GLFWlibraryNull
-{
-    int             xcursor;
-    int             ycursor;
-    char*           clipboardString;
-    _GLFWwindow*    focusedWindow;
-} _GLFWlibraryNull;
-
-void _glfwPollMonitorsNull(void);
-
diff --git a/raylib_pi4_test/external/glfw/src/null_window.c b/raylib_pi4_test/external/glfw/src/null_window.c
deleted file mode 100644 (file)
index 3e44664..0000000
+++ /dev/null
@@ -1,670 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-
-static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
-{
-    if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
-    {
-        const float ratio = (float) window->numer / (float) window->denom;
-        *height = (int) (*width / ratio);
-    }
-
-    if (window->minwidth != GLFW_DONT_CARE && *width < window->minwidth)
-        *width = window->minwidth;
-    else if (window->maxwidth != GLFW_DONT_CARE && *width > window->maxwidth)
-        *width = window->maxwidth;
-
-    if (window->minheight != GLFW_DONT_CARE && *height < window->minheight)
-        *height = window->minheight;
-    else if (window->maxheight != GLFW_DONT_CARE && *height > window->maxheight)
-        *height = window->maxheight;
-}
-
-static void fitToMonitor(_GLFWwindow* window)
-{
-    GLFWvidmode mode;
-    _glfwPlatformGetVideoMode(window->monitor, &mode);
-    _glfwPlatformGetMonitorPos(window->monitor,
-                               &window->null.xpos,
-                               &window->null.ypos);
-    window->null.width = mode.width;
-    window->null.height = mode.height;
-}
-
-static void acquireMonitor(_GLFWwindow* window)
-{
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-}
-
-static int createNativeWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (window->monitor)
-        fitToMonitor(window);
-    else
-    {
-        window->null.xpos = 17;
-        window->null.ypos = 17;
-        window->null.width = wndconfig->width;
-        window->null.height = wndconfig->height;
-    }
-
-    window->null.visible = wndconfig->visible;
-    window->null.decorated = wndconfig->decorated;
-    window->null.maximized = wndconfig->maximized;
-    window->null.floating = wndconfig->floating;
-    window->null.transparent = fbconfig->transparent;
-    window->null.opacity = 1.f;
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
-            ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (_glfw.null.focusedWindow == window)
-        _glfw.null.focusedWindow = NULL;
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count,
-                                const GLFWimage* images)
-{
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (!monitor)
-        {
-            _glfwPlatformSetWindowPos(window, xpos, ypos);
-            _glfwPlatformSetWindowSize(window, width, height);
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    if (window->monitor)
-    {
-        window->null.visible = GLFW_TRUE;
-        acquireMonitor(window);
-        fitToMonitor(window);
-    }
-    else
-    {
-        _glfwPlatformSetWindowPos(window, xpos, ypos);
-        _glfwPlatformSetWindowSize(window, width, height);
-    }
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = window->null.xpos;
-    if (ypos)
-        *ypos = window->null.ypos;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    if (window->monitor)
-        return;
-
-    if (window->null.xpos != xpos || window->null.ypos != ypos)
-    {
-        window->null.xpos = xpos;
-        window->null.ypos = ypos;
-        _glfwInputWindowPos(window, xpos, ypos);
-    }
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->null.width;
-    if (height)
-        *height = window->null.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-        return;
-
-    if (window->null.width != width || window->null.height != height)
-    {
-        window->null.width = width;
-        window->null.height = height;
-        _glfwInputWindowSize(window, width, height);
-        _glfwInputFramebufferSize(window, width, height);
-    }
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    int width = window->null.width;
-    int height = window->null.height;
-    applySizeLimits(window, &width, &height);
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int n, int d)
-{
-    int width = window->null.width;
-    int height = window->null.height;
-    applySizeLimits(window, &width, &height);
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->null.width;
-    if (height)
-        *height = window->null.height;
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    if (window->null.decorated && !window->monitor)
-    {
-        if (left)
-            *left = 1;
-        if (top)
-            *top = 10;
-        if (right)
-            *right = 1;
-        if (bottom)
-            *bottom = 1;
-    }
-    else
-    {
-        if (left)
-            *left = 0;
-        if (top)
-            *top = 0;
-        if (right)
-            *right = 0;
-        if (bottom)
-            *bottom = 0;
-    }
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = 1.f;
-    if (yscale)
-        *yscale = 1.f;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-    {
-        _glfw.null.focusedWindow = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    if (!window->null.iconified)
-    {
-        window->null.iconified = GLFW_TRUE;
-        _glfwInputWindowIconify(window, GLFW_TRUE);
-
-        if (window->monitor)
-            releaseMonitor(window);
-    }
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->null.iconified)
-    {
-        window->null.iconified = GLFW_FALSE;
-        _glfwInputWindowIconify(window, GLFW_FALSE);
-
-        if (window->monitor)
-            acquireMonitor(window);
-    }
-    else if (window->null.maximized)
-    {
-        window->null.maximized = GLFW_FALSE;
-        _glfwInputWindowMaximize(window, GLFW_FALSE);
-    }
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (!window->null.maximized)
-    {
-        window->null.maximized = GLFW_TRUE;
-        _glfwInputWindowMaximize(window, GLFW_TRUE);
-    }
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return window->null.maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return _glfw.null.xcursor >= window->null.xpos &&
-           _glfw.null.ycursor >= window->null.ypos &&
-           _glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
-           _glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    return window->null.transparent;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.resizable = enabled;
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.decorated = enabled;
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    window->null.floating = enabled;
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    return window->null.opacity;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    window->null.opacity = opacity;
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    window->null.visible = GLFW_TRUE;
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-    {
-        _glfw.null.focusedWindow = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    window->null.visible = GLFW_FALSE;
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    if (_glfw.null.focusedWindow == window)
-        return;
-
-    if (!window->null.visible)
-        return;
-
-    _GLFWwindow* previous = _glfw.null.focusedWindow;
-    _glfw.null.focusedWindow = window;
-
-    if (previous)
-    {
-        _glfwInputWindowFocus(previous, GLFW_FALSE);
-        if (previous->monitor && previous->autoIconify)
-            _glfwPlatformIconifyWindow(previous);
-    }
-
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return _glfw.null.focusedWindow == window;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return window->null.iconified;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return window->null.visible;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    if (xpos)
-        *xpos = _glfw.null.xcursor - window->null.xpos;
-    if (ypos)
-        *ypos = _glfw.null.ycursor - window->null.ypos;
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    _glfw.null.xcursor = window->null.xpos + (int) x;
-    _glfw.null.ycursor = window->null.ypos + (int) y;
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    char* copy = _glfw_strdup(string);
-    free(_glfw.null.clipboardString);
-    _glfw.null.clipboardString = copy;
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    return _glfw.null.clipboardString;
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    switch (scancode)
-    {
-        case GLFW_KEY_APOSTROPHE:
-            return "'";
-        case GLFW_KEY_COMMA:
-            return ",";
-        case GLFW_KEY_MINUS:
-        case GLFW_KEY_KP_SUBTRACT:
-            return "-";
-        case GLFW_KEY_PERIOD:
-        case GLFW_KEY_KP_DECIMAL:
-            return ".";
-        case GLFW_KEY_SLASH:
-        case GLFW_KEY_KP_DIVIDE:
-            return "/";
-        case GLFW_KEY_SEMICOLON:
-            return ";";
-        case GLFW_KEY_EQUAL:
-        case GLFW_KEY_KP_EQUAL:
-            return "=";
-        case GLFW_KEY_LEFT_BRACKET:
-            return "[";
-        case GLFW_KEY_RIGHT_BRACKET:
-            return "]";
-        case GLFW_KEY_KP_MULTIPLY:
-            return "*";
-        case GLFW_KEY_KP_ADD:
-            return "+";
-        case GLFW_KEY_BACKSLASH:
-        case GLFW_KEY_WORLD_1:
-        case GLFW_KEY_WORLD_2:
-            return "\\";
-        case GLFW_KEY_0:
-        case GLFW_KEY_KP_0:
-            return "0";
-        case GLFW_KEY_1:
-        case GLFW_KEY_KP_1:
-            return "1";
-        case GLFW_KEY_2:
-        case GLFW_KEY_KP_2:
-            return "2";
-        case GLFW_KEY_3:
-        case GLFW_KEY_KP_3:
-            return "3";
-        case GLFW_KEY_4:
-        case GLFW_KEY_KP_4:
-            return "4";
-        case GLFW_KEY_5:
-        case GLFW_KEY_KP_5:
-            return "5";
-        case GLFW_KEY_6:
-        case GLFW_KEY_KP_6:
-            return "6";
-        case GLFW_KEY_7:
-        case GLFW_KEY_KP_7:
-            return "7";
-        case GLFW_KEY_8:
-        case GLFW_KEY_KP_8:
-            return "8";
-        case GLFW_KEY_9:
-        case GLFW_KEY_KP_9:
-            return "9";
-        case GLFW_KEY_A:
-            return "a";
-        case GLFW_KEY_B:
-            return "b";
-        case GLFW_KEY_C:
-            return "c";
-        case GLFW_KEY_D:
-            return "d";
-        case GLFW_KEY_E:
-            return "e";
-        case GLFW_KEY_F:
-            return "f";
-        case GLFW_KEY_G:
-            return "g";
-        case GLFW_KEY_H:
-            return "h";
-        case GLFW_KEY_I:
-            return "i";
-        case GLFW_KEY_J:
-            return "j";
-        case GLFW_KEY_K:
-            return "k";
-        case GLFW_KEY_L:
-            return "l";
-        case GLFW_KEY_M:
-            return "m";
-        case GLFW_KEY_N:
-            return "n";
-        case GLFW_KEY_O:
-            return "o";
-        case GLFW_KEY_P:
-            return "p";
-        case GLFW_KEY_Q:
-            return "q";
-        case GLFW_KEY_R:
-            return "r";
-        case GLFW_KEY_S:
-            return "s";
-        case GLFW_KEY_T:
-            return "t";
-        case GLFW_KEY_U:
-            return "u";
-        case GLFW_KEY_V:
-            return "v";
-        case GLFW_KEY_W:
-            return "w";
-        case GLFW_KEY_X:
-            return "x";
-        case GLFW_KEY_Y:
-            return "y";
-        case GLFW_KEY_Z:
-            return "z";
-    }
-
-    return NULL;
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return key;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    return GLFW_FALSE;
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    // This seems like the most appropriate error to return here
-    return VK_ERROR_EXTENSION_NOT_PRESENT;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/osmesa_context.c b/raylib_pi4_test/external/glfw/src/osmesa_context.c
deleted file mode 100644 (file)
index 70e8675..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-//========================================================================
-// GLFW 3.4 OSMesa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "internal.h"
-
-
-static void makeContextCurrentOSMesa(_GLFWwindow* window)
-{
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetFramebufferSize(window, &width, &height);
-
-        // Check to see if we need to allocate a new buffer
-        if ((window->context.osmesa.buffer == NULL) ||
-            (width != window->context.osmesa.width) ||
-            (height != window->context.osmesa.height))
-        {
-            free(window->context.osmesa.buffer);
-
-            // Allocate the new buffer (width * height * 8-bit RGBA)
-            window->context.osmesa.buffer = calloc(4, (size_t) width * height);
-            window->context.osmesa.width  = width;
-            window->context.osmesa.height = height;
-        }
-
-        if (!OSMesaMakeCurrent(window->context.osmesa.handle,
-                               window->context.osmesa.buffer,
-                               GL_UNSIGNED_BYTE,
-                               width, height))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "OSMesa: Failed to make context current");
-            return;
-        }
-    }
-
-    _glfwPlatformSetTls(&_glfw.contextSlot, window);
-}
-
-static GLFWglproc getProcAddressOSMesa(const char* procname)
-{
-    return (GLFWglproc) OSMesaGetProcAddress(procname);
-}
-
-static void destroyContextOSMesa(_GLFWwindow* window)
-{
-    if (window->context.osmesa.handle)
-    {
-        OSMesaDestroyContext(window->context.osmesa.handle);
-        window->context.osmesa.handle = NULL;
-    }
-
-    if (window->context.osmesa.buffer)
-    {
-        free(window->context.osmesa.buffer);
-        window->context.osmesa.width = 0;
-        window->context.osmesa.height = 0;
-    }
-}
-
-static void swapBuffersOSMesa(_GLFWwindow* window)
-{
-    // No double buffering on OSMesa
-}
-
-static void swapIntervalOSMesa(int interval)
-{
-    // No swap interval on OSMesa
-}
-
-static int extensionSupportedOSMesa(const char* extension)
-{
-    // OSMesa does not have extensions
-    return GLFW_FALSE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwInitOSMesa(void)
-{
-    int i;
-    const char* sonames[] =
-    {
-#if defined(_GLFW_OSMESA_LIBRARY)
-        _GLFW_OSMESA_LIBRARY,
-#elif defined(_WIN32)
-        "libOSMesa.dll",
-        "OSMesa.dll",
-#elif defined(__APPLE__)
-        "libOSMesa.8.dylib",
-#elif defined(__CYGWIN__)
-        "libOSMesa-8.so",
-#else
-        "libOSMesa.so.8",
-        "libOSMesa.so.6",
-#endif
-        NULL
-    };
-
-    if (_glfw.osmesa.handle)
-        return GLFW_TRUE;
-
-    for (i = 0;  sonames[i];  i++)
-    {
-        _glfw.osmesa.handle = _glfw_dlopen(sonames[i]);
-        if (_glfw.osmesa.handle)
-            break;
-    }
-
-    if (!_glfw.osmesa.handle)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE, "OSMesa: Library not found");
-        return GLFW_FALSE;
-    }
-
-    _glfw.osmesa.CreateContextExt = (PFN_OSMesaCreateContextExt)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextExt");
-    _glfw.osmesa.CreateContextAttribs = (PFN_OSMesaCreateContextAttribs)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaCreateContextAttribs");
-    _glfw.osmesa.DestroyContext = (PFN_OSMesaDestroyContext)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaDestroyContext");
-    _glfw.osmesa.MakeCurrent = (PFN_OSMesaMakeCurrent)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaMakeCurrent");
-    _glfw.osmesa.GetColorBuffer = (PFN_OSMesaGetColorBuffer)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetColorBuffer");
-    _glfw.osmesa.GetDepthBuffer = (PFN_OSMesaGetDepthBuffer)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetDepthBuffer");
-    _glfw.osmesa.GetProcAddress = (PFN_OSMesaGetProcAddress)
-        _glfw_dlsym(_glfw.osmesa.handle, "OSMesaGetProcAddress");
-
-    if (!_glfw.osmesa.CreateContextExt ||
-        !_glfw.osmesa.DestroyContext ||
-        !_glfw.osmesa.MakeCurrent ||
-        !_glfw.osmesa.GetColorBuffer ||
-        !_glfw.osmesa.GetDepthBuffer ||
-        !_glfw.osmesa.GetProcAddress)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to load required entry points");
-
-        _glfwTerminateOSMesa();
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwTerminateOSMesa(void)
-{
-    if (_glfw.osmesa.handle)
-    {
-        _glfw_dlclose(_glfw.osmesa.handle);
-        _glfw.osmesa.handle = NULL;
-    }
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
-                                  const _GLFWctxconfig* ctxconfig,
-                                  const _GLFWfbconfig* fbconfig)
-{
-    OSMesaContext share = NULL;
-    const int accumBits = fbconfig->accumRedBits +
-                          fbconfig->accumGreenBits +
-                          fbconfig->accumBlueBits +
-                          fbconfig->accumAlphaBits;
-
-    if (ctxconfig->client == GLFW_OPENGL_ES_API)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "OSMesa: OpenGL ES is not available on OSMesa");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.osmesa.handle;
-
-    if (OSMesaCreateContextAttribs)
-    {
-        int index = 0, attribs[40];
-
-        setAttrib(OSMESA_FORMAT, OSMESA_RGBA);
-        setAttrib(OSMESA_DEPTH_BITS, fbconfig->depthBits);
-        setAttrib(OSMESA_STENCIL_BITS, fbconfig->stencilBits);
-        setAttrib(OSMESA_ACCUM_BITS, accumBits);
-
-        if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-        {
-            setAttrib(OSMESA_PROFILE, OSMESA_CORE_PROFILE);
-        }
-        else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-        {
-            setAttrib(OSMESA_PROFILE, OSMESA_COMPAT_PROFILE);
-        }
-
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(OSMESA_CONTEXT_MAJOR_VERSION, ctxconfig->major);
-            setAttrib(OSMESA_CONTEXT_MINOR_VERSION, ctxconfig->minor);
-        }
-
-        if (ctxconfig->forward)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "OSMesa: Forward-compatible contexts not supported");
-            return GLFW_FALSE;
-        }
-
-        setAttrib(0, 0);
-
-        window->context.osmesa.handle =
-            OSMesaCreateContextAttribs(attribs, share);
-    }
-    else
-    {
-        if (ctxconfig->profile)
-        {
-            _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                            "OSMesa: OpenGL profiles unavailable");
-            return GLFW_FALSE;
-        }
-
-        window->context.osmesa.handle =
-            OSMesaCreateContextExt(OSMESA_RGBA,
-                                   fbconfig->depthBits,
-                                   fbconfig->stencilBits,
-                                   accumBits,
-                                   share);
-    }
-
-    if (window->context.osmesa.handle == NULL)
-    {
-        _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                        "OSMesa: Failed to create context");
-        return GLFW_FALSE;
-    }
-
-    window->context.makeCurrent = makeContextCurrentOSMesa;
-    window->context.swapBuffers = swapBuffersOSMesa;
-    window->context.swapInterval = swapIntervalOSMesa;
-    window->context.extensionSupported = extensionSupportedOSMesa;
-    window->context.getProcAddress = getProcAddressOSMesa;
-    window->context.destroy = destroyContextOSMesa;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwGetOSMesaColorBuffer(GLFWwindow* handle, int* width,
-                                     int* height, int* format, void** buffer)
-{
-    void* mesaBuffer;
-    GLint mesaWidth, mesaHeight, mesaFormat;
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!OSMesaGetColorBuffer(window->context.osmesa.handle,
-                              &mesaWidth, &mesaHeight,
-                              &mesaFormat, &mesaBuffer))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to retrieve color buffer");
-        return GLFW_FALSE;
-    }
-
-    if (width)
-        *width = mesaWidth;
-    if (height)
-        *height = mesaHeight;
-    if (format)
-        *format = mesaFormat;
-    if (buffer)
-        *buffer = mesaBuffer;
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI int glfwGetOSMesaDepthBuffer(GLFWwindow* handle,
-                                     int* width, int* height,
-                                     int* bytesPerValue,
-                                     void** buffer)
-{
-    void* mesaBuffer;
-    GLint mesaWidth, mesaHeight, mesaBytes;
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!OSMesaGetDepthBuffer(window->context.osmesa.handle,
-                              &mesaWidth, &mesaHeight,
-                              &mesaBytes, &mesaBuffer))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "OSMesa: Failed to retrieve depth buffer");
-        return GLFW_FALSE;
-    }
-
-    if (width)
-        *width = mesaWidth;
-    if (height)
-        *height = mesaHeight;
-    if (bytesPerValue)
-        *bytesPerValue = mesaBytes;
-    if (buffer)
-        *buffer = mesaBuffer;
-
-    return GLFW_TRUE;
-}
-
-GLFWAPI OSMesaContext glfwGetOSMesaContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.osmesa.handle;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/osmesa_context.h b/raylib_pi4_test/external/glfw/src/osmesa_context.h
deleted file mode 100644 (file)
index ce1f1a2..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//========================================================================
-// GLFW 3.4 OSMesa - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2016 Google Inc.
-// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define OSMESA_RGBA 0x1908
-#define OSMESA_FORMAT 0x22
-#define OSMESA_DEPTH_BITS 0x30
-#define OSMESA_STENCIL_BITS 0x31
-#define OSMESA_ACCUM_BITS 0x32
-#define OSMESA_PROFILE 0x33
-#define OSMESA_CORE_PROFILE 0x34
-#define OSMESA_COMPAT_PROFILE 0x35
-#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
-#define OSMESA_CONTEXT_MINOR_VERSION 0x37
-
-typedef void* OSMesaContext;
-typedef void (*OSMESAproc)(void);
-
-typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
-typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
-typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
-typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
-typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
-typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
-typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
-#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
-#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
-#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
-#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
-#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
-#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
-#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
-
-// OSMesa-specific per-context data
-//
-typedef struct _GLFWcontextOSMesa
-{
-    OSMesaContext       handle;
-    int                 width;
-    int                 height;
-    void*               buffer;
-
-} _GLFWcontextOSMesa;
-
-// OSMesa-specific global data
-//
-typedef struct _GLFWlibraryOSMesa
-{
-    void*           handle;
-
-    PFN_OSMesaCreateContextExt      CreateContextExt;
-    PFN_OSMesaCreateContextAttribs  CreateContextAttribs;
-    PFN_OSMesaDestroyContext        DestroyContext;
-    PFN_OSMesaMakeCurrent           MakeCurrent;
-    PFN_OSMesaGetColorBuffer        GetColorBuffer;
-    PFN_OSMesaGetDepthBuffer        GetDepthBuffer;
-    PFN_OSMesaGetProcAddress        GetProcAddress;
-
-} _GLFWlibraryOSMesa;
-
-
-GLFWbool _glfwInitOSMesa(void);
-void _glfwTerminateOSMesa(void);
-GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
-                                  const _GLFWctxconfig* ctxconfig,
-                                  const _GLFWfbconfig* fbconfig);
-
diff --git a/raylib_pi4_test/external/glfw/src/posix_thread.c b/raylib_pi4_test/external/glfw/src/posix_thread.c
deleted file mode 100644 (file)
index 0236145..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
-{
-    assert(tls->posix.allocated == GLFW_FALSE);
-
-    if (pthread_key_create(&tls->posix.key, NULL) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "POSIX: Failed to create context TLS");
-        return GLFW_FALSE;
-    }
-
-    tls->posix.allocated = GLFW_TRUE;
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyTls(_GLFWtls* tls)
-{
-    if (tls->posix.allocated)
-        pthread_key_delete(tls->posix.key);
-    memset(tls, 0, sizeof(_GLFWtls));
-}
-
-void* _glfwPlatformGetTls(_GLFWtls* tls)
-{
-    assert(tls->posix.allocated == GLFW_TRUE);
-    return pthread_getspecific(tls->posix.key);
-}
-
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
-{
-    assert(tls->posix.allocated == GLFW_TRUE);
-    pthread_setspecific(tls->posix.key, value);
-}
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_FALSE);
-
-    if (pthread_mutex_init(&mutex->posix.handle, NULL) != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "POSIX: Failed to create mutex");
-        return GLFW_FALSE;
-    }
-
-    return mutex->posix.allocated = GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
-{
-    if (mutex->posix.allocated)
-        pthread_mutex_destroy(&mutex->posix.handle);
-    memset(mutex, 0, sizeof(_GLFWmutex));
-}
-
-void _glfwPlatformLockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_TRUE);
-    pthread_mutex_lock(&mutex->posix.handle);
-}
-
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->posix.allocated == GLFW_TRUE);
-    pthread_mutex_unlock(&mutex->posix.handle);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/posix_thread.h b/raylib_pi4_test/external/glfw/src/posix_thread.h
deleted file mode 100644 (file)
index 85ce596..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <pthread.h>
-
-#define _GLFW_PLATFORM_TLS_STATE    _GLFWtlsPOSIX   posix
-#define _GLFW_PLATFORM_MUTEX_STATE  _GLFWmutexPOSIX posix
-
-
-// POSIX-specific thread local storage data
-//
-typedef struct _GLFWtlsPOSIX
-{
-    GLFWbool        allocated;
-    pthread_key_t   key;
-
-} _GLFWtlsPOSIX;
-
-// POSIX-specific mutex data
-//
-typedef struct _GLFWmutexPOSIX
-{
-    GLFWbool        allocated;
-    pthread_mutex_t handle;
-
-} _GLFWmutexPOSIX;
-
diff --git a/raylib_pi4_test/external/glfw/src/posix_time.c b/raylib_pi4_test/external/glfw/src/posix_time.c
deleted file mode 100644 (file)
index ae3d5c7..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _POSIX_C_SOURCE 199309L
-
-#include "internal.h"
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <time.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerPOSIX(void)
-{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-    struct timespec ts;
-
-    if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
-    {
-        _glfw.timer.posix.monotonic = GLFW_TRUE;
-        _glfw.timer.posix.frequency = 1000000000;
-    }
-    else
-#endif
-    {
-        _glfw.timer.posix.monotonic = GLFW_FALSE;
-        _glfw.timer.posix.frequency = 1000000;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-    if (_glfw.timer.posix.monotonic)
-    {
-        struct timespec ts;
-        clock_gettime(CLOCK_MONOTONIC, &ts);
-        return (uint64_t) ts.tv_sec * (uint64_t) 1000000000 + (uint64_t) ts.tv_nsec;
-    }
-    else
-#endif
-    {
-        struct timeval tv;
-        gettimeofday(&tv, NULL);
-        return (uint64_t) tv.tv_sec * (uint64_t) 1000000 + (uint64_t) tv.tv_usec;
-    }
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.posix.frequency;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/posix_time.h b/raylib_pi4_test/external/glfw/src/posix_time.h
deleted file mode 100644 (file)
index 9b59a18..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-//========================================================================
-// GLFW 3.4 POSIX - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerPOSIX posix
-
-#include <stdint.h>
-
-
-// POSIX-specific global timer data
-//
-typedef struct _GLFWtimerPOSIX
-{
-    GLFWbool    monotonic;
-    uint64_t    frequency;
-
-} _GLFWtimerPOSIX;
-
-
-void _glfwInitTimerPOSIX(void);
-
diff --git a/raylib_pi4_test/external/glfw/src/vulkan.c b/raylib_pi4_test/external/glfw/src/vulkan.c
deleted file mode 100644 (file)
index b534052..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define _GLFW_FIND_LOADER    1
-#define _GLFW_REQUIRE_LOADER 2
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwInitVulkan(int mode)
-{
-    VkResult err;
-    VkExtensionProperties* ep;
-    uint32_t i, count;
-
-    if (_glfw.vk.available)
-        return GLFW_TRUE;
-
-#if !defined(_GLFW_VULKAN_STATIC)
-#if defined(_GLFW_VULKAN_LIBRARY)
-    _glfw.vk.handle = _glfw_dlopen(_GLFW_VULKAN_LIBRARY);
-#elif defined(_GLFW_WIN32)
-    _glfw.vk.handle = _glfw_dlopen("vulkan-1.dll");
-#elif defined(_GLFW_COCOA)
-    _glfw.vk.handle = _glfw_dlopen("libvulkan.1.dylib");
-    if (!_glfw.vk.handle)
-        _glfw.vk.handle = _glfwLoadLocalVulkanLoaderNS();
-#else
-    _glfw.vk.handle = _glfw_dlopen("libvulkan.so.1");
-#endif
-    if (!_glfw.vk.handle)
-    {
-        if (mode == _GLFW_REQUIRE_LOADER)
-            _glfwInputError(GLFW_API_UNAVAILABLE, "Vulkan: Loader not found");
-
-        return GLFW_FALSE;
-    }
-
-    _glfw.vk.GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)
-        _glfw_dlsym(_glfw.vk.handle, "vkGetInstanceProcAddr");
-    if (!_glfw.vk.GetInstanceProcAddr)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Loader does not export vkGetInstanceProcAddr");
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    _glfw.vk.EnumerateInstanceExtensionProperties = (PFN_vkEnumerateInstanceExtensionProperties)
-        vkGetInstanceProcAddr(NULL, "vkEnumerateInstanceExtensionProperties");
-    if (!_glfw.vk.EnumerateInstanceExtensionProperties)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Failed to retrieve vkEnumerateInstanceExtensionProperties");
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-#endif // _GLFW_VULKAN_STATIC
-
-    err = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL);
-    if (err)
-    {
-        // NOTE: This happens on systems with a loader but without any Vulkan ICD
-        if (mode == _GLFW_REQUIRE_LOADER)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "Vulkan: Failed to query instance extension count: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    ep = calloc(count, sizeof(VkExtensionProperties));
-
-    err = vkEnumerateInstanceExtensionProperties(NULL, &count, ep);
-    if (err)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Failed to query instance extensions: %s",
-                        _glfwGetVulkanResultString(err));
-
-        free(ep);
-        _glfwTerminateVulkan();
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  i < count;  i++)
-    {
-        if (strcmp(ep[i].extensionName, "VK_KHR_surface") == 0)
-            _glfw.vk.KHR_surface = GLFW_TRUE;
-#if defined(_GLFW_WIN32)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_win32_surface") == 0)
-            _glfw.vk.KHR_win32_surface = GLFW_TRUE;
-#elif defined(_GLFW_COCOA)
-        else if (strcmp(ep[i].extensionName, "VK_MVK_macos_surface") == 0)
-            _glfw.vk.MVK_macos_surface = GLFW_TRUE;
-        else if (strcmp(ep[i].extensionName, "VK_EXT_metal_surface") == 0)
-            _glfw.vk.EXT_metal_surface = GLFW_TRUE;
-#elif defined(_GLFW_X11)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_xlib_surface") == 0)
-            _glfw.vk.KHR_xlib_surface = GLFW_TRUE;
-        else if (strcmp(ep[i].extensionName, "VK_KHR_xcb_surface") == 0)
-            _glfw.vk.KHR_xcb_surface = GLFW_TRUE;
-#elif defined(_GLFW_WAYLAND)
-        else if (strcmp(ep[i].extensionName, "VK_KHR_wayland_surface") == 0)
-            _glfw.vk.KHR_wayland_surface = GLFW_TRUE;
-#endif
-    }
-
-    free(ep);
-
-    _glfw.vk.available = GLFW_TRUE;
-
-    _glfwPlatformGetRequiredInstanceExtensions(_glfw.vk.extensions);
-
-    return GLFW_TRUE;
-}
-
-void _glfwTerminateVulkan(void)
-{
-#if !defined(_GLFW_VULKAN_STATIC)
-    if (_glfw.vk.handle)
-        _glfw_dlclose(_glfw.vk.handle);
-#endif
-}
-
-const char* _glfwGetVulkanResultString(VkResult result)
-{
-    switch (result)
-    {
-        case VK_SUCCESS:
-            return "Success";
-        case VK_NOT_READY:
-            return "A fence or query has not yet completed";
-        case VK_TIMEOUT:
-            return "A wait operation has not completed in the specified time";
-        case VK_EVENT_SET:
-            return "An event is signaled";
-        case VK_EVENT_RESET:
-            return "An event is unsignaled";
-        case VK_INCOMPLETE:
-            return "A return array was too small for the result";
-        case VK_ERROR_OUT_OF_HOST_MEMORY:
-            return "A host memory allocation has failed";
-        case VK_ERROR_OUT_OF_DEVICE_MEMORY:
-            return "A device memory allocation has failed";
-        case VK_ERROR_INITIALIZATION_FAILED:
-            return "Initialization of an object could not be completed for implementation-specific reasons";
-        case VK_ERROR_DEVICE_LOST:
-            return "The logical or physical device has been lost";
-        case VK_ERROR_MEMORY_MAP_FAILED:
-            return "Mapping of a memory object has failed";
-        case VK_ERROR_LAYER_NOT_PRESENT:
-            return "A requested layer is not present or could not be loaded";
-        case VK_ERROR_EXTENSION_NOT_PRESENT:
-            return "A requested extension is not supported";
-        case VK_ERROR_FEATURE_NOT_PRESENT:
-            return "A requested feature is not supported";
-        case VK_ERROR_INCOMPATIBLE_DRIVER:
-            return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible";
-        case VK_ERROR_TOO_MANY_OBJECTS:
-            return "Too many objects of the type have already been created";
-        case VK_ERROR_FORMAT_NOT_SUPPORTED:
-            return "A requested format is not supported on this device";
-        case VK_ERROR_SURFACE_LOST_KHR:
-            return "A surface is no longer available";
-        case VK_SUBOPTIMAL_KHR:
-            return "A swapchain no longer matches the surface properties exactly, but can still be used";
-        case VK_ERROR_OUT_OF_DATE_KHR:
-            return "A surface has changed in such a way that it is no longer compatible with the swapchain";
-        case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
-            return "The display used by a swapchain does not use the same presentable image layout";
-        case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
-            return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API";
-        case VK_ERROR_VALIDATION_FAILED_EXT:
-            return "A validation layer found an error";
-        default:
-            return "ERROR: UNKNOWN VULKAN ERROR";
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI int glfwVulkanSupported(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-    return _glfwInitVulkan(_GLFW_FIND_LOADER);
-}
-
-GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count)
-{
-    assert(count != NULL);
-
-    *count = 0;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return NULL;
-
-    if (!_glfw.vk.extensions[0])
-        return NULL;
-
-    *count = 2;
-    return (const char**) _glfw.vk.extensions;
-}
-
-GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance,
-                                              const char* procname)
-{
-    GLFWvkproc proc;
-    assert(procname != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return NULL;
-
-    proc = (GLFWvkproc) vkGetInstanceProcAddr(instance, procname);
-#if defined(_GLFW_VULKAN_STATIC)
-    if (!proc)
-    {
-        if (strcmp(procname, "vkGetInstanceProcAddr") == 0)
-            return (GLFWvkproc) vkGetInstanceProcAddr;
-    }
-#else
-    if (!proc)
-        proc = (GLFWvkproc) _glfw_dlsym(_glfw.vk.handle, procname);
-#endif
-
-    return proc;
-}
-
-GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                     VkPhysicalDevice device,
-                                                     uint32_t queuefamily)
-{
-    assert(instance != VK_NULL_HANDLE);
-    assert(device != VK_NULL_HANDLE);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(GLFW_FALSE);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return GLFW_FALSE;
-
-    if (!_glfw.vk.extensions[0])
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Window surface creation extensions not found");
-        return GLFW_FALSE;
-    }
-
-    return _glfwPlatformGetPhysicalDevicePresentationSupport(instance,
-                                                             device,
-                                                             queuefamily);
-}
-
-GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance,
-                                         GLFWwindow* handle,
-                                         const VkAllocationCallbacks* allocator,
-                                         VkSurfaceKHR* surface)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(instance != VK_NULL_HANDLE);
-    assert(window != NULL);
-    assert(surface != NULL);
-
-    *surface = VK_NULL_HANDLE;
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(VK_ERROR_INITIALIZATION_FAILED);
-
-    if (!_glfwInitVulkan(_GLFW_REQUIRE_LOADER))
-        return VK_ERROR_INITIALIZATION_FAILED;
-
-    if (!_glfw.vk.extensions[0])
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Vulkan: Window surface creation extensions not found");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    if (window->context.client != GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Vulkan: Window surface creation requires the window to have the client API set to GLFW_NO_API");
-        return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
-    }
-
-    return _glfwPlatformCreateWindowSurface(instance, window, allocator, surface);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/wgl_context.c b/raylib_pi4_test/external/glfw/src/wgl_context.c
deleted file mode 100644 (file)
index 4f9a6ff..0000000
+++ /dev/null
@@ -1,796 +0,0 @@
-//========================================================================
-// GLFW 3.4 WGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <malloc.h>
-#include <assert.h>
-
-// Return the value corresponding to the specified attribute
-//
-static int findPixelFormatAttribValue(const int* attribs,
-                                      int attribCount,
-                                      const int* values,
-                                      int attrib)
-{
-    int i;
-
-    for (i = 0;  i < attribCount;  i++)
-    {
-        if (attribs[i] == attrib)
-            return values[i];
-    }
-
-    _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                         "WGL: Unknown pixel format attribute requested");
-    return 0;
-}
-
-#define addAttrib(a) \
-{ \
-    assert((size_t) attribCount < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[attribCount++] = a; \
-}
-#define findAttribValue(a) \
-    findPixelFormatAttribValue(attribs, attribCount, values, a)
-
-// Return a list of available and usable framebuffer configs
-//
-static int choosePixelFormat(_GLFWwindow* window,
-                             const _GLFWctxconfig* ctxconfig,
-                             const _GLFWfbconfig* fbconfig)
-{
-    _GLFWfbconfig* usableConfigs;
-    const _GLFWfbconfig* closest;
-    int i, pixelFormat, nativeCount, usableCount = 0, attribCount = 0;
-    int attribs[40];
-    int values[sizeof(attribs) / sizeof(attribs[0])];
-
-    if (_glfw.wgl.ARB_pixel_format)
-    {
-        const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
-
-        if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
-                                          1, 0, 1, &attrib, &nativeCount))
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to retrieve pixel format attribute");
-            return 0;
-        }
-
-        addAttrib(WGL_SUPPORT_OPENGL_ARB);
-        addAttrib(WGL_DRAW_TO_WINDOW_ARB);
-        addAttrib(WGL_PIXEL_TYPE_ARB);
-        addAttrib(WGL_ACCELERATION_ARB);
-        addAttrib(WGL_RED_BITS_ARB);
-        addAttrib(WGL_RED_SHIFT_ARB);
-        addAttrib(WGL_GREEN_BITS_ARB);
-        addAttrib(WGL_GREEN_SHIFT_ARB);
-        addAttrib(WGL_BLUE_BITS_ARB);
-        addAttrib(WGL_BLUE_SHIFT_ARB);
-        addAttrib(WGL_ALPHA_BITS_ARB);
-        addAttrib(WGL_ALPHA_SHIFT_ARB);
-        addAttrib(WGL_DEPTH_BITS_ARB);
-        addAttrib(WGL_STENCIL_BITS_ARB);
-        addAttrib(WGL_ACCUM_BITS_ARB);
-        addAttrib(WGL_ACCUM_RED_BITS_ARB);
-        addAttrib(WGL_ACCUM_GREEN_BITS_ARB);
-        addAttrib(WGL_ACCUM_BLUE_BITS_ARB);
-        addAttrib(WGL_ACCUM_ALPHA_BITS_ARB);
-        addAttrib(WGL_AUX_BUFFERS_ARB);
-        addAttrib(WGL_STEREO_ARB);
-        addAttrib(WGL_DOUBLE_BUFFER_ARB);
-
-        if (_glfw.wgl.ARB_multisample)
-            addAttrib(WGL_SAMPLES_ARB);
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (_glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB)
-                addAttrib(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
-        }
-        else
-        {
-            if (_glfw.wgl.EXT_colorspace)
-                addAttrib(WGL_COLORSPACE_EXT);
-        }
-    }
-    else
-    {
-        nativeCount = DescribePixelFormat(window->context.wgl.dc,
-                                          1,
-                                          sizeof(PIXELFORMATDESCRIPTOR),
-                                          NULL);
-    }
-
-    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
-
-    for (i = 0;  i < nativeCount;  i++)
-    {
-        _GLFWfbconfig* u = usableConfigs + usableCount;
-        pixelFormat = i + 1;
-
-        if (_glfw.wgl.ARB_pixel_format)
-        {
-            // Get pixel format attributes through "modern" extension
-
-            if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
-                                              pixelFormat, 0,
-                                              attribCount,
-                                              attribs, values))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                    "WGL: Failed to retrieve pixel format attributes");
-
-                free(usableConfigs);
-                return 0;
-            }
-
-            if (!findAttribValue(WGL_SUPPORT_OPENGL_ARB) ||
-                !findAttribValue(WGL_DRAW_TO_WINDOW_ARB))
-            {
-                continue;
-            }
-
-            if (findAttribValue(WGL_PIXEL_TYPE_ARB) != WGL_TYPE_RGBA_ARB)
-                continue;
-
-            if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
-                continue;
-
-            u->redBits = findAttribValue(WGL_RED_BITS_ARB);
-            u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
-            u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
-            u->alphaBits = findAttribValue(WGL_ALPHA_BITS_ARB);
-
-            u->depthBits = findAttribValue(WGL_DEPTH_BITS_ARB);
-            u->stencilBits = findAttribValue(WGL_STENCIL_BITS_ARB);
-
-            u->accumRedBits = findAttribValue(WGL_ACCUM_RED_BITS_ARB);
-            u->accumGreenBits = findAttribValue(WGL_ACCUM_GREEN_BITS_ARB);
-            u->accumBlueBits = findAttribValue(WGL_ACCUM_BLUE_BITS_ARB);
-            u->accumAlphaBits = findAttribValue(WGL_ACCUM_ALPHA_BITS_ARB);
-
-            u->auxBuffers = findAttribValue(WGL_AUX_BUFFERS_ARB);
-
-            if (findAttribValue(WGL_STEREO_ARB))
-                u->stereo = GLFW_TRUE;
-            if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
-                u->doublebuffer = GLFW_TRUE;
-
-            if (_glfw.wgl.ARB_multisample)
-                u->samples = findAttribValue(WGL_SAMPLES_ARB);
-
-            if (ctxconfig->client == GLFW_OPENGL_API)
-            {
-                if (_glfw.wgl.ARB_framebuffer_sRGB ||
-                    _glfw.wgl.EXT_framebuffer_sRGB)
-                {
-                    if (findAttribValue(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
-                        u->sRGB = GLFW_TRUE;
-                }
-            }
-            else
-            {
-                if (_glfw.wgl.EXT_colorspace)
-                {
-                    if (findAttribValue(WGL_COLORSPACE_EXT) == WGL_COLORSPACE_SRGB_EXT)
-                        u->sRGB = GLFW_TRUE;
-                }
-            }
-        }
-        else
-        {
-            // Get pixel format attributes through legacy PFDs
-
-            PIXELFORMATDESCRIPTOR pfd;
-
-            if (!DescribePixelFormat(window->context.wgl.dc,
-                                     pixelFormat,
-                                     sizeof(PIXELFORMATDESCRIPTOR),
-                                     &pfd))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                    "WGL: Failed to describe pixel format");
-
-                free(usableConfigs);
-                return 0;
-            }
-
-            if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
-                !(pfd.dwFlags & PFD_SUPPORT_OPENGL))
-            {
-                continue;
-            }
-
-            if (!(pfd.dwFlags & PFD_GENERIC_ACCELERATED) &&
-                (pfd.dwFlags & PFD_GENERIC_FORMAT))
-            {
-                continue;
-            }
-
-            if (pfd.iPixelType != PFD_TYPE_RGBA)
-                continue;
-
-            u->redBits = pfd.cRedBits;
-            u->greenBits = pfd.cGreenBits;
-            u->blueBits = pfd.cBlueBits;
-            u->alphaBits = pfd.cAlphaBits;
-
-            u->depthBits = pfd.cDepthBits;
-            u->stencilBits = pfd.cStencilBits;
-
-            u->accumRedBits = pfd.cAccumRedBits;
-            u->accumGreenBits = pfd.cAccumGreenBits;
-            u->accumBlueBits = pfd.cAccumBlueBits;
-            u->accumAlphaBits = pfd.cAccumAlphaBits;
-
-            u->auxBuffers = pfd.cAuxBuffers;
-
-            if (pfd.dwFlags & PFD_STEREO)
-                u->stereo = GLFW_TRUE;
-            if (pfd.dwFlags & PFD_DOUBLEBUFFER)
-                u->doublebuffer = GLFW_TRUE;
-        }
-
-        u->handle = pixelFormat;
-        usableCount++;
-    }
-
-    if (!usableCount)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "WGL: The driver does not appear to support OpenGL");
-
-        free(usableConfigs);
-        return 0;
-    }
-
-    closest = _glfwChooseFBConfig(fbconfig, usableConfigs, usableCount);
-    if (!closest)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "WGL: Failed to find a suitable pixel format");
-
-        free(usableConfigs);
-        return 0;
-    }
-
-    pixelFormat = (int) closest->handle;
-    free(usableConfigs);
-
-    return pixelFormat;
-}
-
-#undef addAttrib
-#undef findAttribValue
-
-static void makeContextCurrentWGL(_GLFWwindow* window)
-{
-    if (window)
-    {
-        if (wglMakeCurrent(window->context.wgl.dc, window->context.wgl.handle))
-            _glfwPlatformSetTls(&_glfw.contextSlot, window);
-        else
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to make context current");
-            _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
-        }
-    }
-    else
-    {
-        if (!wglMakeCurrent(NULL, NULL))
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "WGL: Failed to clear current context");
-        }
-
-        _glfwPlatformSetTls(&_glfw.contextSlot, NULL);
-    }
-}
-
-static void swapBuffersWGL(_GLFWwindow* window)
-{
-    if (!window->monitor)
-    {
-        if (IsWindowsVistaOrGreater())
-        {
-            // DWM Composition is always enabled on Win8+
-            BOOL enabled = IsWindows8OrGreater();
-
-            // HACK: Use DwmFlush when desktop composition is enabled
-            if (enabled ||
-                (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
-            {
-                int count = abs(window->context.wgl.interval);
-                while (count--)
-                    DwmFlush();
-            }
-        }
-    }
-
-    SwapBuffers(window->context.wgl.dc);
-}
-
-static void swapIntervalWGL(int interval)
-{
-    _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
-
-    window->context.wgl.interval = interval;
-
-    if (!window->monitor)
-    {
-        if (IsWindowsVistaOrGreater())
-        {
-            // DWM Composition is always enabled on Win8+
-            BOOL enabled = IsWindows8OrGreater();
-
-            // HACK: Disable WGL swap interval when desktop composition is enabled to
-            //       avoid interfering with DWM vsync
-            if (enabled ||
-                (SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled))
-                interval = 0;
-        }
-    }
-
-    if (_glfw.wgl.EXT_swap_control)
-        wglSwapIntervalEXT(interval);
-}
-
-static int extensionSupportedWGL(const char* extension)
-{
-    const char* extensions = NULL;
-
-    if (_glfw.wgl.GetExtensionsStringARB)
-        extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
-    else if (_glfw.wgl.GetExtensionsStringEXT)
-        extensions = wglGetExtensionsStringEXT();
-
-    if (!extensions)
-        return GLFW_FALSE;
-
-    return _glfwStringInExtensionString(extension, extensions);
-}
-
-static GLFWglproc getProcAddressWGL(const char* procname)
-{
-    const GLFWglproc proc = (GLFWglproc) wglGetProcAddress(procname);
-    if (proc)
-        return proc;
-
-    return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
-}
-
-static void destroyContextWGL(_GLFWwindow* window)
-{
-    if (window->context.wgl.handle)
-    {
-        wglDeleteContext(window->context.wgl.handle);
-        window->context.wgl.handle = NULL;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialize WGL
-//
-GLFWbool _glfwInitWGL(void)
-{
-    PIXELFORMATDESCRIPTOR pfd;
-    HGLRC prc, rc;
-    HDC pdc, dc;
-
-    if (_glfw.wgl.instance)
-        return GLFW_TRUE;
-
-    _glfw.wgl.instance = LoadLibraryA("opengl32.dll");
-    if (!_glfw.wgl.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to load opengl32.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wgl.CreateContext = (PFN_wglCreateContext)
-        GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
-    _glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
-        GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
-    _glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
-        GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
-    _glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
-        GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
-    _glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
-        GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
-    _glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
-        GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
-    _glfw.wgl.ShareLists = (PFN_wglShareLists)
-        GetProcAddress(_glfw.wgl.instance, "wglShareLists");
-
-    // NOTE: A dummy context has to be created for opengl32.dll to load the
-    //       OpenGL ICD, from which we can then query WGL extensions
-    // NOTE: This code will accept the Microsoft GDI ICD; accelerated context
-    //       creation failure occurs during manual pixel format enumeration
-
-    dc = GetDC(_glfw.win32.helperWindowHandle);
-
-    ZeroMemory(&pfd, sizeof(pfd));
-    pfd.nSize = sizeof(pfd);
-    pfd.nVersion = 1;
-    pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
-    pfd.iPixelType = PFD_TYPE_RGBA;
-    pfd.cColorBits = 24;
-
-    if (!SetPixelFormat(dc, ChoosePixelFormat(dc, &pfd), &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to set pixel format for dummy context");
-        return GLFW_FALSE;
-    }
-
-    rc = wglCreateContext(dc);
-    if (!rc)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to create dummy context");
-        return GLFW_FALSE;
-    }
-
-    pdc = wglGetCurrentDC();
-    prc = wglGetCurrentContext();
-
-    if (!wglMakeCurrent(dc, rc))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to make dummy context current");
-        wglMakeCurrent(pdc, prc);
-        wglDeleteContext(rc);
-        return GLFW_FALSE;
-    }
-
-    // NOTE: Functions must be loaded first as they're needed to retrieve the
-    //       extension string that tells us whether the functions are supported
-    _glfw.wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
-        wglGetProcAddress("wglGetExtensionsStringEXT");
-    _glfw.wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
-        wglGetProcAddress("wglGetExtensionsStringARB");
-    _glfw.wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
-        wglGetProcAddress("wglCreateContextAttribsARB");
-    _glfw.wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
-        wglGetProcAddress("wglSwapIntervalEXT");
-    _glfw.wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
-        wglGetProcAddress("wglGetPixelFormatAttribivARB");
-
-    // NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
-    //       checked below as we are already using them
-    _glfw.wgl.ARB_multisample =
-        extensionSupportedWGL("WGL_ARB_multisample");
-    _glfw.wgl.ARB_framebuffer_sRGB =
-        extensionSupportedWGL("WGL_ARB_framebuffer_sRGB");
-    _glfw.wgl.EXT_framebuffer_sRGB =
-        extensionSupportedWGL("WGL_EXT_framebuffer_sRGB");
-    _glfw.wgl.ARB_create_context =
-        extensionSupportedWGL("WGL_ARB_create_context");
-    _glfw.wgl.ARB_create_context_profile =
-        extensionSupportedWGL("WGL_ARB_create_context_profile");
-    _glfw.wgl.EXT_create_context_es2_profile =
-        extensionSupportedWGL("WGL_EXT_create_context_es2_profile");
-    _glfw.wgl.ARB_create_context_robustness =
-        extensionSupportedWGL("WGL_ARB_create_context_robustness");
-    _glfw.wgl.ARB_create_context_no_error =
-        extensionSupportedWGL("WGL_ARB_create_context_no_error");
-    _glfw.wgl.EXT_swap_control =
-        extensionSupportedWGL("WGL_EXT_swap_control");
-    _glfw.wgl.EXT_colorspace =
-        extensionSupportedWGL("WGL_EXT_colorspace");
-    _glfw.wgl.ARB_pixel_format =
-        extensionSupportedWGL("WGL_ARB_pixel_format");
-    _glfw.wgl.ARB_context_flush_control =
-        extensionSupportedWGL("WGL_ARB_context_flush_control");
-
-    wglMakeCurrent(pdc, prc);
-    wglDeleteContext(rc);
-    return GLFW_TRUE;
-}
-
-// Terminate WGL
-//
-void _glfwTerminateWGL(void)
-{
-    if (_glfw.wgl.instance)
-        FreeLibrary(_glfw.wgl.instance);
-}
-
-#define setAttrib(a, v) \
-{ \
-    assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
-    attribs[index++] = a; \
-    attribs[index++] = v; \
-}
-
-// Create the OpenGL or OpenGL ES context
-//
-GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig)
-{
-    int attribs[40];
-    int pixelFormat;
-    PIXELFORMATDESCRIPTOR pfd;
-    HGLRC share = NULL;
-
-    if (ctxconfig->share)
-        share = ctxconfig->share->context.wgl.handle;
-
-    window->context.wgl.dc = GetDC(window->win32.handle);
-    if (!window->context.wgl.dc)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "WGL: Failed to retrieve DC for window");
-        return GLFW_FALSE;
-    }
-
-    pixelFormat = choosePixelFormat(window, ctxconfig, fbconfig);
-    if (!pixelFormat)
-        return GLFW_FALSE;
-
-    if (!DescribePixelFormat(window->context.wgl.dc,
-                             pixelFormat, sizeof(pfd), &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to retrieve PFD for selected pixel format");
-        return GLFW_FALSE;
-    }
-
-    if (!SetPixelFormat(window->context.wgl.dc, pixelFormat, &pfd))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "WGL: Failed to set selected pixel format");
-        return GLFW_FALSE;
-    }
-
-    if (ctxconfig->client == GLFW_OPENGL_API)
-    {
-        if (ctxconfig->forward)
-        {
-            if (!_glfw.wgl.ARB_create_context)
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: A forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable");
-                return GLFW_FALSE;
-            }
-        }
-
-        if (ctxconfig->profile)
-        {
-            if (!_glfw.wgl.ARB_create_context_profile)
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
-                return GLFW_FALSE;
-            }
-        }
-    }
-    else
-    {
-        if (!_glfw.wgl.ARB_create_context ||
-            !_glfw.wgl.ARB_create_context_profile ||
-            !_glfw.wgl.EXT_create_context_es2_profile)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "WGL: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable");
-            return GLFW_FALSE;
-        }
-    }
-
-    if (_glfw.wgl.ARB_create_context)
-    {
-        int index = 0, mask = 0, flags = 0;
-
-        if (ctxconfig->client == GLFW_OPENGL_API)
-        {
-            if (ctxconfig->forward)
-                flags |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
-
-            if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
-                mask |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
-            else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
-                mask |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
-        }
-        else
-            mask |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT;
-
-        if (ctxconfig->debug)
-            flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
-
-        if (ctxconfig->robustness)
-        {
-            if (_glfw.wgl.ARB_create_context_robustness)
-            {
-                if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
-                {
-                    setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              WGL_NO_RESET_NOTIFICATION_ARB);
-                }
-                else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
-                {
-                    setAttrib(WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
-                              WGL_LOSE_CONTEXT_ON_RESET_ARB);
-                }
-
-                flags |= WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB;
-            }
-        }
-
-        if (ctxconfig->release)
-        {
-            if (_glfw.wgl.ARB_context_flush_control)
-            {
-                if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
-                {
-                    setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
-                }
-                else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
-                {
-                    setAttrib(WGL_CONTEXT_RELEASE_BEHAVIOR_ARB,
-                              WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
-                }
-            }
-        }
-
-        if (ctxconfig->noerror)
-        {
-            if (_glfw.wgl.ARB_create_context_no_error)
-                setAttrib(WGL_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
-        }
-
-        // NOTE: Only request an explicitly versioned context when necessary, as
-        //       explicitly requesting version 1.0 does not always return the
-        //       highest version supported by the driver
-        if (ctxconfig->major != 1 || ctxconfig->minor != 0)
-        {
-            setAttrib(WGL_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
-            setAttrib(WGL_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
-        }
-
-        if (flags)
-            setAttrib(WGL_CONTEXT_FLAGS_ARB, flags);
-
-        if (mask)
-            setAttrib(WGL_CONTEXT_PROFILE_MASK_ARB, mask);
-
-        setAttrib(0, 0);
-
-        window->context.wgl.handle =
-            wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
-        if (!window->context.wgl.handle)
-        {
-            const DWORD error = GetLastError();
-
-            if (error == (0xc0070000 | ERROR_INVALID_VERSION_ARB))
-            {
-                if (ctxconfig->client == GLFW_OPENGL_API)
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Driver does not support OpenGL version %i.%i",
-                                    ctxconfig->major,
-                                    ctxconfig->minor);
-                }
-                else
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Driver does not support OpenGL ES version %i.%i",
-                                    ctxconfig->major,
-                                    ctxconfig->minor);
-                }
-            }
-            else if (error == (0xc0070000 | ERROR_INVALID_PROFILE_ARB))
-            {
-                _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                "WGL: Driver does not support the requested OpenGL profile");
-            }
-            else if (error == (0xc0070000 | ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB))
-            {
-                _glfwInputError(GLFW_INVALID_VALUE,
-                                "WGL: The share context is not compatible with the requested context");
-            }
-            else
-            {
-                if (ctxconfig->client == GLFW_OPENGL_API)
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Failed to create OpenGL context");
-                }
-                else
-                {
-                    _glfwInputError(GLFW_VERSION_UNAVAILABLE,
-                                    "WGL: Failed to create OpenGL ES context");
-                }
-            }
-
-            return GLFW_FALSE;
-        }
-    }
-    else
-    {
-        window->context.wgl.handle = wglCreateContext(window->context.wgl.dc);
-        if (!window->context.wgl.handle)
-        {
-            _glfwInputErrorWin32(GLFW_VERSION_UNAVAILABLE,
-                                 "WGL: Failed to create OpenGL context");
-            return GLFW_FALSE;
-        }
-
-        if (share)
-        {
-            if (!wglShareLists(share, window->context.wgl.handle))
-            {
-                _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                     "WGL: Failed to enable sharing with specified OpenGL context");
-                return GLFW_FALSE;
-            }
-        }
-    }
-
-    window->context.makeCurrent = makeContextCurrentWGL;
-    window->context.swapBuffers = swapBuffersWGL;
-    window->context.swapInterval = swapIntervalWGL;
-    window->context.extensionSupported = extensionSupportedWGL;
-    window->context.getProcAddress = getProcAddressWGL;
-    window->context.destroy = destroyContextWGL;
-
-    return GLFW_TRUE;
-}
-
-#undef setAttrib
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (window->context.client == GLFW_NO_API)
-    {
-        _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
-        return NULL;
-    }
-
-    return window->context.wgl.handle;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/wgl_context.h b/raylib_pi4_test/external/glfw/src/wgl_context.h
deleted file mode 100644 (file)
index 2cf7e4e..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-//========================================================================
-// GLFW 3.4 WGL - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
-#define WGL_SUPPORT_OPENGL_ARB 0x2010
-#define WGL_DRAW_TO_WINDOW_ARB 0x2001
-#define WGL_PIXEL_TYPE_ARB 0x2013
-#define WGL_TYPE_RGBA_ARB 0x202b
-#define WGL_ACCELERATION_ARB 0x2003
-#define WGL_NO_ACCELERATION_ARB 0x2025
-#define WGL_RED_BITS_ARB 0x2015
-#define WGL_RED_SHIFT_ARB 0x2016
-#define WGL_GREEN_BITS_ARB 0x2017
-#define WGL_GREEN_SHIFT_ARB 0x2018
-#define WGL_BLUE_BITS_ARB 0x2019
-#define WGL_BLUE_SHIFT_ARB 0x201a
-#define WGL_ALPHA_BITS_ARB 0x201b
-#define WGL_ALPHA_SHIFT_ARB 0x201c
-#define WGL_ACCUM_BITS_ARB 0x201d
-#define WGL_ACCUM_RED_BITS_ARB 0x201e
-#define WGL_ACCUM_GREEN_BITS_ARB 0x201f
-#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
-#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
-#define WGL_DEPTH_BITS_ARB 0x2022
-#define WGL_STENCIL_BITS_ARB 0x2023
-#define WGL_AUX_BUFFERS_ARB 0x2024
-#define WGL_STEREO_ARB 0x2012
-#define WGL_DOUBLE_BUFFER_ARB 0x2011
-#define WGL_SAMPLES_ARB 0x2042
-#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20a9
-#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
-#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
-#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
-#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
-#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
-#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
-#define WGL_CONTEXT_FLAGS_ARB 0x2094
-#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
-#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
-#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
-#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
-#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
-#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
-#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
-#define WGL_COLORSPACE_EXT 0x309d
-#define WGL_COLORSPACE_SRGB_EXT 0x3089
-
-#define ERROR_INVALID_VERSION_ARB 0x2095
-#define ERROR_INVALID_PROFILE_ARB 0x2096
-#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
-
-// WGL extension pointer typedefs
-typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
-typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
-typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
-typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
-typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
-#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
-#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
-#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
-#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
-#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
-
-// opengl32.dll function pointer typedefs
-typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
-typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
-typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
-typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
-typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
-typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
-typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
-#define wglCreateContext _glfw.wgl.CreateContext
-#define wglDeleteContext _glfw.wgl.DeleteContext
-#define wglGetProcAddress _glfw.wgl.GetProcAddress
-#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
-#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
-#define wglMakeCurrent _glfw.wgl.MakeCurrent
-#define wglShareLists _glfw.wgl.ShareLists
-
-#define _GLFW_PLATFORM_CONTEXT_STATE            _GLFWcontextWGL wgl
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE    _GLFWlibraryWGL wgl
-
-
-// WGL-specific per-context data
-//
-typedef struct _GLFWcontextWGL
-{
-    HDC       dc;
-    HGLRC     handle;
-    int       interval;
-
-} _GLFWcontextWGL;
-
-// WGL-specific global data
-//
-typedef struct _GLFWlibraryWGL
-{
-    HINSTANCE                           instance;
-    PFN_wglCreateContext                CreateContext;
-    PFN_wglDeleteContext                DeleteContext;
-    PFN_wglGetProcAddress               GetProcAddress;
-    PFN_wglGetCurrentDC                 GetCurrentDC;
-    PFN_wglGetCurrentContext            GetCurrentContext;
-    PFN_wglMakeCurrent                  MakeCurrent;
-    PFN_wglShareLists                   ShareLists;
-
-    PFNWGLSWAPINTERVALEXTPROC           SwapIntervalEXT;
-    PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
-    PFNWGLGETEXTENSIONSSTRINGEXTPROC    GetExtensionsStringEXT;
-    PFNWGLGETEXTENSIONSSTRINGARBPROC    GetExtensionsStringARB;
-    PFNWGLCREATECONTEXTATTRIBSARBPROC   CreateContextAttribsARB;
-    GLFWbool                            EXT_swap_control;
-    GLFWbool                            EXT_colorspace;
-    GLFWbool                            ARB_multisample;
-    GLFWbool                            ARB_framebuffer_sRGB;
-    GLFWbool                            EXT_framebuffer_sRGB;
-    GLFWbool                            ARB_pixel_format;
-    GLFWbool                            ARB_create_context;
-    GLFWbool                            ARB_create_context_profile;
-    GLFWbool                            EXT_create_context_es2_profile;
-    GLFWbool                            ARB_create_context_robustness;
-    GLFWbool                            ARB_create_context_no_error;
-    GLFWbool                            ARB_context_flush_control;
-
-} _GLFWlibraryWGL;
-
-
-GLFWbool _glfwInitWGL(void);
-void _glfwTerminateWGL(void);
-GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
-                               const _GLFWctxconfig* ctxconfig,
-                               const _GLFWfbconfig* fbconfig);
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_init.c b/raylib_pi4_test/external/glfw/src/win32_init.c
deleted file mode 100644 (file)
index f6995e5..0000000
+++ /dev/null
@@ -1,630 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <malloc.h>
-
-static const GUID _glfw_GUID_DEVINTERFACE_HID =
-    {0x4d1e55b2,0xf16f,0x11cf,{0x88,0xcb,0x00,0x11,0x11,0x00,0x00,0x30}};
-
-#define GUID_DEVINTERFACE_HID _glfw_GUID_DEVINTERFACE_HID
-
-#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
-
-// Executables (but not DLLs) exporting this symbol with this value will be
-// automatically directed to the high-performance GPU on Nvidia Optimus systems
-// with up-to-date drivers
-//
-__declspec(dllexport) DWORD NvOptimusEnablement = 1;
-
-// Executables (but not DLLs) exporting this symbol with this value will be
-// automatically directed to the high-performance GPU on AMD PowerXpress systems
-// with up-to-date drivers
-//
-__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
-
-#endif // _GLFW_USE_HYBRID_HPG
-
-#if defined(_GLFW_BUILD_DLL)
-
-// GLFW DLL entry point
-//
-BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
-{
-    return TRUE;
-}
-
-#endif // _GLFW_BUILD_DLL
-
-// Load necessary libraries (DLLs)
-//
-static GLFWbool loadLibraries(void)
-{
-    _glfw.win32.winmm.instance = LoadLibraryA("winmm.dll");
-    if (!_glfw.win32.winmm.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to load winmm.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.win32.winmm.GetTime = (PFN_timeGetTime)
-        GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
-
-    _glfw.win32.user32.instance = LoadLibraryA("user32.dll");
-    if (!_glfw.win32.user32.instance)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to load user32.dll");
-        return GLFW_FALSE;
-    }
-
-    _glfw.win32.user32.SetProcessDPIAware_ = (PFN_SetProcessDPIAware)
-        GetProcAddress(_glfw.win32.user32.instance, "SetProcessDPIAware");
-    _glfw.win32.user32.ChangeWindowMessageFilterEx_ = (PFN_ChangeWindowMessageFilterEx)
-        GetProcAddress(_glfw.win32.user32.instance, "ChangeWindowMessageFilterEx");
-    _glfw.win32.user32.EnableNonClientDpiScaling_ = (PFN_EnableNonClientDpiScaling)
-        GetProcAddress(_glfw.win32.user32.instance, "EnableNonClientDpiScaling");
-    _glfw.win32.user32.SetProcessDpiAwarenessContext_ = (PFN_SetProcessDpiAwarenessContext)
-        GetProcAddress(_glfw.win32.user32.instance, "SetProcessDpiAwarenessContext");
-    _glfw.win32.user32.GetDpiForWindow_ = (PFN_GetDpiForWindow)
-        GetProcAddress(_glfw.win32.user32.instance, "GetDpiForWindow");
-    _glfw.win32.user32.AdjustWindowRectExForDpi_ = (PFN_AdjustWindowRectExForDpi)
-        GetProcAddress(_glfw.win32.user32.instance, "AdjustWindowRectExForDpi");
-
-    _glfw.win32.dinput8.instance = LoadLibraryA("dinput8.dll");
-    if (_glfw.win32.dinput8.instance)
-    {
-        _glfw.win32.dinput8.Create = (PFN_DirectInput8Create)
-            GetProcAddress(_glfw.win32.dinput8.instance, "DirectInput8Create");
-    }
-
-    {
-        int i;
-        const char* names[] =
-        {
-            "xinput1_4.dll",
-            "xinput1_3.dll",
-            "xinput9_1_0.dll",
-            "xinput1_2.dll",
-            "xinput1_1.dll",
-            NULL
-        };
-
-        for (i = 0;  names[i];  i++)
-        {
-            _glfw.win32.xinput.instance = LoadLibraryA(names[i]);
-            if (_glfw.win32.xinput.instance)
-            {
-                _glfw.win32.xinput.GetCapabilities = (PFN_XInputGetCapabilities)
-                    GetProcAddress(_glfw.win32.xinput.instance, "XInputGetCapabilities");
-                _glfw.win32.xinput.GetState = (PFN_XInputGetState)
-                    GetProcAddress(_glfw.win32.xinput.instance, "XInputGetState");
-
-                break;
-            }
-        }
-    }
-
-    _glfw.win32.dwmapi.instance = LoadLibraryA("dwmapi.dll");
-    if (_glfw.win32.dwmapi.instance)
-    {
-        _glfw.win32.dwmapi.IsCompositionEnabled = (PFN_DwmIsCompositionEnabled)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmIsCompositionEnabled");
-        _glfw.win32.dwmapi.Flush = (PFN_DwmFlush)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmFlush");
-        _glfw.win32.dwmapi.EnableBlurBehindWindow = (PFN_DwmEnableBlurBehindWindow)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmEnableBlurBehindWindow");
-        _glfw.win32.dwmapi.GetColorizationColor = (PFN_DwmGetColorizationColor)
-            GetProcAddress(_glfw.win32.dwmapi.instance, "DwmGetColorizationColor");
-    }
-
-    _glfw.win32.shcore.instance = LoadLibraryA("shcore.dll");
-    if (_glfw.win32.shcore.instance)
-    {
-        _glfw.win32.shcore.SetProcessDpiAwareness_ = (PFN_SetProcessDpiAwareness)
-            GetProcAddress(_glfw.win32.shcore.instance, "SetProcessDpiAwareness");
-        _glfw.win32.shcore.GetDpiForMonitor_ = (PFN_GetDpiForMonitor)
-            GetProcAddress(_glfw.win32.shcore.instance, "GetDpiForMonitor");
-    }
-
-    _glfw.win32.ntdll.instance = LoadLibraryA("ntdll.dll");
-    if (_glfw.win32.ntdll.instance)
-    {
-        _glfw.win32.ntdll.RtlVerifyVersionInfo_ = (PFN_RtlVerifyVersionInfo)
-            GetProcAddress(_glfw.win32.ntdll.instance, "RtlVerifyVersionInfo");
-    }
-
-    return GLFW_TRUE;
-}
-
-// Unload used libraries (DLLs)
-//
-static void freeLibraries(void)
-{
-    if (_glfw.win32.xinput.instance)
-        FreeLibrary(_glfw.win32.xinput.instance);
-
-    if (_glfw.win32.dinput8.instance)
-        FreeLibrary(_glfw.win32.dinput8.instance);
-
-    if (_glfw.win32.winmm.instance)
-        FreeLibrary(_glfw.win32.winmm.instance);
-
-    if (_glfw.win32.user32.instance)
-        FreeLibrary(_glfw.win32.user32.instance);
-
-    if (_glfw.win32.dwmapi.instance)
-        FreeLibrary(_glfw.win32.dwmapi.instance);
-
-    if (_glfw.win32.shcore.instance)
-        FreeLibrary(_glfw.win32.shcore.instance);
-
-    if (_glfw.win32.ntdll.instance)
-        FreeLibrary(_glfw.win32.ntdll.instance);
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.win32.keycodes, -1, sizeof(_glfw.win32.keycodes));
-    memset(_glfw.win32.scancodes, -1, sizeof(_glfw.win32.scancodes));
-
-    _glfw.win32.keycodes[0x00B] = GLFW_KEY_0;
-    _glfw.win32.keycodes[0x002] = GLFW_KEY_1;
-    _glfw.win32.keycodes[0x003] = GLFW_KEY_2;
-    _glfw.win32.keycodes[0x004] = GLFW_KEY_3;
-    _glfw.win32.keycodes[0x005] = GLFW_KEY_4;
-    _glfw.win32.keycodes[0x006] = GLFW_KEY_5;
-    _glfw.win32.keycodes[0x007] = GLFW_KEY_6;
-    _glfw.win32.keycodes[0x008] = GLFW_KEY_7;
-    _glfw.win32.keycodes[0x009] = GLFW_KEY_8;
-    _glfw.win32.keycodes[0x00A] = GLFW_KEY_9;
-    _glfw.win32.keycodes[0x01E] = GLFW_KEY_A;
-    _glfw.win32.keycodes[0x030] = GLFW_KEY_B;
-    _glfw.win32.keycodes[0x02E] = GLFW_KEY_C;
-    _glfw.win32.keycodes[0x020] = GLFW_KEY_D;
-    _glfw.win32.keycodes[0x012] = GLFW_KEY_E;
-    _glfw.win32.keycodes[0x021] = GLFW_KEY_F;
-    _glfw.win32.keycodes[0x022] = GLFW_KEY_G;
-    _glfw.win32.keycodes[0x023] = GLFW_KEY_H;
-    _glfw.win32.keycodes[0x017] = GLFW_KEY_I;
-    _glfw.win32.keycodes[0x024] = GLFW_KEY_J;
-    _glfw.win32.keycodes[0x025] = GLFW_KEY_K;
-    _glfw.win32.keycodes[0x026] = GLFW_KEY_L;
-    _glfw.win32.keycodes[0x032] = GLFW_KEY_M;
-    _glfw.win32.keycodes[0x031] = GLFW_KEY_N;
-    _glfw.win32.keycodes[0x018] = GLFW_KEY_O;
-    _glfw.win32.keycodes[0x019] = GLFW_KEY_P;
-    _glfw.win32.keycodes[0x010] = GLFW_KEY_Q;
-    _glfw.win32.keycodes[0x013] = GLFW_KEY_R;
-    _glfw.win32.keycodes[0x01F] = GLFW_KEY_S;
-    _glfw.win32.keycodes[0x014] = GLFW_KEY_T;
-    _glfw.win32.keycodes[0x016] = GLFW_KEY_U;
-    _glfw.win32.keycodes[0x02F] = GLFW_KEY_V;
-    _glfw.win32.keycodes[0x011] = GLFW_KEY_W;
-    _glfw.win32.keycodes[0x02D] = GLFW_KEY_X;
-    _glfw.win32.keycodes[0x015] = GLFW_KEY_Y;
-    _glfw.win32.keycodes[0x02C] = GLFW_KEY_Z;
-
-    _glfw.win32.keycodes[0x028] = GLFW_KEY_APOSTROPHE;
-    _glfw.win32.keycodes[0x02B] = GLFW_KEY_BACKSLASH;
-    _glfw.win32.keycodes[0x033] = GLFW_KEY_COMMA;
-    _glfw.win32.keycodes[0x00D] = GLFW_KEY_EQUAL;
-    _glfw.win32.keycodes[0x029] = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.win32.keycodes[0x01A] = GLFW_KEY_LEFT_BRACKET;
-    _glfw.win32.keycodes[0x00C] = GLFW_KEY_MINUS;
-    _glfw.win32.keycodes[0x034] = GLFW_KEY_PERIOD;
-    _glfw.win32.keycodes[0x01B] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.win32.keycodes[0x027] = GLFW_KEY_SEMICOLON;
-    _glfw.win32.keycodes[0x035] = GLFW_KEY_SLASH;
-    _glfw.win32.keycodes[0x056] = GLFW_KEY_WORLD_2;
-
-    _glfw.win32.keycodes[0x00E] = GLFW_KEY_BACKSPACE;
-    _glfw.win32.keycodes[0x153] = GLFW_KEY_DELETE;
-    _glfw.win32.keycodes[0x14F] = GLFW_KEY_END;
-    _glfw.win32.keycodes[0x01C] = GLFW_KEY_ENTER;
-    _glfw.win32.keycodes[0x001] = GLFW_KEY_ESCAPE;
-    _glfw.win32.keycodes[0x147] = GLFW_KEY_HOME;
-    _glfw.win32.keycodes[0x152] = GLFW_KEY_INSERT;
-    _glfw.win32.keycodes[0x15D] = GLFW_KEY_MENU;
-    _glfw.win32.keycodes[0x151] = GLFW_KEY_PAGE_DOWN;
-    _glfw.win32.keycodes[0x149] = GLFW_KEY_PAGE_UP;
-    _glfw.win32.keycodes[0x045] = GLFW_KEY_PAUSE;
-    _glfw.win32.keycodes[0x146] = GLFW_KEY_PAUSE;
-    _glfw.win32.keycodes[0x039] = GLFW_KEY_SPACE;
-    _glfw.win32.keycodes[0x00F] = GLFW_KEY_TAB;
-    _glfw.win32.keycodes[0x03A] = GLFW_KEY_CAPS_LOCK;
-    _glfw.win32.keycodes[0x145] = GLFW_KEY_NUM_LOCK;
-    _glfw.win32.keycodes[0x046] = GLFW_KEY_SCROLL_LOCK;
-    _glfw.win32.keycodes[0x03B] = GLFW_KEY_F1;
-    _glfw.win32.keycodes[0x03C] = GLFW_KEY_F2;
-    _glfw.win32.keycodes[0x03D] = GLFW_KEY_F3;
-    _glfw.win32.keycodes[0x03E] = GLFW_KEY_F4;
-    _glfw.win32.keycodes[0x03F] = GLFW_KEY_F5;
-    _glfw.win32.keycodes[0x040] = GLFW_KEY_F6;
-    _glfw.win32.keycodes[0x041] = GLFW_KEY_F7;
-    _glfw.win32.keycodes[0x042] = GLFW_KEY_F8;
-    _glfw.win32.keycodes[0x043] = GLFW_KEY_F9;
-    _glfw.win32.keycodes[0x044] = GLFW_KEY_F10;
-    _glfw.win32.keycodes[0x057] = GLFW_KEY_F11;
-    _glfw.win32.keycodes[0x058] = GLFW_KEY_F12;
-    _glfw.win32.keycodes[0x064] = GLFW_KEY_F13;
-    _glfw.win32.keycodes[0x065] = GLFW_KEY_F14;
-    _glfw.win32.keycodes[0x066] = GLFW_KEY_F15;
-    _glfw.win32.keycodes[0x067] = GLFW_KEY_F16;
-    _glfw.win32.keycodes[0x068] = GLFW_KEY_F17;
-    _glfw.win32.keycodes[0x069] = GLFW_KEY_F18;
-    _glfw.win32.keycodes[0x06A] = GLFW_KEY_F19;
-    _glfw.win32.keycodes[0x06B] = GLFW_KEY_F20;
-    _glfw.win32.keycodes[0x06C] = GLFW_KEY_F21;
-    _glfw.win32.keycodes[0x06D] = GLFW_KEY_F22;
-    _glfw.win32.keycodes[0x06E] = GLFW_KEY_F23;
-    _glfw.win32.keycodes[0x076] = GLFW_KEY_F24;
-    _glfw.win32.keycodes[0x038] = GLFW_KEY_LEFT_ALT;
-    _glfw.win32.keycodes[0x01D] = GLFW_KEY_LEFT_CONTROL;
-    _glfw.win32.keycodes[0x02A] = GLFW_KEY_LEFT_SHIFT;
-    _glfw.win32.keycodes[0x15B] = GLFW_KEY_LEFT_SUPER;
-    _glfw.win32.keycodes[0x137] = GLFW_KEY_PRINT_SCREEN;
-    _glfw.win32.keycodes[0x138] = GLFW_KEY_RIGHT_ALT;
-    _glfw.win32.keycodes[0x11D] = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.win32.keycodes[0x036] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.win32.keycodes[0x15C] = GLFW_KEY_RIGHT_SUPER;
-    _glfw.win32.keycodes[0x150] = GLFW_KEY_DOWN;
-    _glfw.win32.keycodes[0x14B] = GLFW_KEY_LEFT;
-    _glfw.win32.keycodes[0x14D] = GLFW_KEY_RIGHT;
-    _glfw.win32.keycodes[0x148] = GLFW_KEY_UP;
-
-    _glfw.win32.keycodes[0x052] = GLFW_KEY_KP_0;
-    _glfw.win32.keycodes[0x04F] = GLFW_KEY_KP_1;
-    _glfw.win32.keycodes[0x050] = GLFW_KEY_KP_2;
-    _glfw.win32.keycodes[0x051] = GLFW_KEY_KP_3;
-    _glfw.win32.keycodes[0x04B] = GLFW_KEY_KP_4;
-    _glfw.win32.keycodes[0x04C] = GLFW_KEY_KP_5;
-    _glfw.win32.keycodes[0x04D] = GLFW_KEY_KP_6;
-    _glfw.win32.keycodes[0x047] = GLFW_KEY_KP_7;
-    _glfw.win32.keycodes[0x048] = GLFW_KEY_KP_8;
-    _glfw.win32.keycodes[0x049] = GLFW_KEY_KP_9;
-    _glfw.win32.keycodes[0x04E] = GLFW_KEY_KP_ADD;
-    _glfw.win32.keycodes[0x053] = GLFW_KEY_KP_DECIMAL;
-    _glfw.win32.keycodes[0x135] = GLFW_KEY_KP_DIVIDE;
-    _glfw.win32.keycodes[0x11C] = GLFW_KEY_KP_ENTER;
-    _glfw.win32.keycodes[0x059] = GLFW_KEY_KP_EQUAL;
-    _glfw.win32.keycodes[0x037] = GLFW_KEY_KP_MULTIPLY;
-    _glfw.win32.keycodes[0x04A] = GLFW_KEY_KP_SUBTRACT;
-
-    for (scancode = 0;  scancode < 512;  scancode++)
-    {
-        if (_glfw.win32.keycodes[scancode] > 0)
-            _glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode;
-    }
-}
-
-// Creates a dummy window for behind-the-scenes work
-//
-static GLFWbool createHelperWindow(void)
-{
-    MSG msg;
-
-    _glfw.win32.helperWindowHandle =
-        CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
-                        _GLFW_WNDCLASSNAME,
-                        L"GLFW message window",
-                        WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
-                        0, 0, 1, 1,
-                        NULL, NULL,
-                        GetModuleHandleW(NULL),
-                        NULL);
-
-    if (!_glfw.win32.helperWindowHandle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create helper window");
-        return GLFW_FALSE;
-    }
-
-    // HACK: The command to the first ShowWindow call is ignored if the parent
-    //       process passed along a STARTUPINFO, so clear that with a no-op call
-    ShowWindow(_glfw.win32.helperWindowHandle, SW_HIDE);
-
-    // Register for HID device notifications
-    {
-        DEV_BROADCAST_DEVICEINTERFACE_W dbi;
-        ZeroMemory(&dbi, sizeof(dbi));
-        dbi.dbcc_size = sizeof(dbi);
-        dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
-        dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
-
-        _glfw.win32.deviceNotificationHandle =
-            RegisterDeviceNotificationW(_glfw.win32.helperWindowHandle,
-                                        (DEV_BROADCAST_HDR*) &dbi,
-                                        DEVICE_NOTIFY_WINDOW_HANDLE);
-    }
-
-    while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
-    {
-        TranslateMessage(&msg);
-        DispatchMessageW(&msg);
-    }
-
-   return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Returns a wide string version of the specified UTF-8 string
-//
-WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
-{
-    WCHAR* target;
-    int count;
-
-    count = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0);
-    if (!count)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string from UTF-8");
-        return NULL;
-    }
-
-    target = calloc(count, sizeof(WCHAR));
-
-    if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, count))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string from UTF-8");
-        free(target);
-        return NULL;
-    }
-
-    return target;
-}
-
-// Returns a UTF-8 string version of the specified wide string
-//
-char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
-{
-    char* target;
-    int size;
-
-    size = WideCharToMultiByte(CP_UTF8, 0, source, -1, NULL, 0, NULL, NULL);
-    if (!size)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string to UTF-8");
-        return NULL;
-    }
-
-    target = calloc(size, 1);
-
-    if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, size, NULL, NULL))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to convert string to UTF-8");
-        free(target);
-        return NULL;
-    }
-
-    return target;
-}
-
-// Reports the specified error, appending information about the last Win32 error
-//
-void _glfwInputErrorWin32(int error, const char* description)
-{
-    WCHAR buffer[_GLFW_MESSAGE_SIZE] = L"";
-    char message[_GLFW_MESSAGE_SIZE] = "";
-
-    FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM |
-                       FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_MAX_WIDTH_MASK,
-                   NULL,
-                   GetLastError() & 0xffff,
-                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                   buffer,
-                   sizeof(buffer) / sizeof(WCHAR),
-                   NULL);
-    WideCharToMultiByte(CP_UTF8, 0, buffer, -1, message, sizeof(message), NULL, NULL);
-
-    _glfwInputError(error, "%s: %s", description, message);
-}
-
-// Updates key names according to the current keyboard layout
-//
-void _glfwUpdateKeyNamesWin32(void)
-{
-    int key;
-    BYTE state[256] = {0};
-
-    memset(_glfw.win32.keynames, 0, sizeof(_glfw.win32.keynames));
-
-    for (key = GLFW_KEY_SPACE;  key <= GLFW_KEY_LAST;  key++)
-    {
-        UINT vk;
-        int scancode, length;
-        WCHAR chars[16];
-
-        scancode = _glfw.win32.scancodes[key];
-        if (scancode == -1)
-            continue;
-
-        if (key >= GLFW_KEY_KP_0 && key <= GLFW_KEY_KP_ADD)
-        {
-            const UINT vks[] = {
-                VK_NUMPAD0,  VK_NUMPAD1,  VK_NUMPAD2, VK_NUMPAD3,
-                VK_NUMPAD4,  VK_NUMPAD5,  VK_NUMPAD6, VK_NUMPAD7,
-                VK_NUMPAD8,  VK_NUMPAD9,  VK_DECIMAL, VK_DIVIDE,
-                VK_MULTIPLY, VK_SUBTRACT, VK_ADD
-            };
-
-            vk = vks[key - GLFW_KEY_KP_0];
-        }
-        else
-            vk = MapVirtualKey(scancode, MAPVK_VSC_TO_VK);
-
-        length = ToUnicode(vk, scancode, state,
-                           chars, sizeof(chars) / sizeof(WCHAR),
-                           0);
-
-        if (length == -1)
-        {
-            length = ToUnicode(vk, scancode, state,
-                               chars, sizeof(chars) / sizeof(WCHAR),
-                               0);
-        }
-
-        if (length < 1)
-            continue;
-
-        WideCharToMultiByte(CP_UTF8, 0, chars, 1,
-                            _glfw.win32.keynames[key],
-                            sizeof(_glfw.win32.keynames[key]),
-                            NULL, NULL);
-    }
-}
-
-// Replacement for IsWindowsVersionOrGreater as MinGW lacks versionhelpers.h
-//
-BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
-{
-    OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, {0}, sp };
-    DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
-    ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
-    // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
-    //       latter lies unless the user knew to embed a non-default manifest
-    //       announcing support for Windows 10 via supportedOS GUID
-    return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
-}
-
-// Checks whether we are on at least the specified build of Windows 10
-//
-BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
-{
-    OSVERSIONINFOEXW osvi = { sizeof(osvi), 10, 0, build };
-    DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER;
-    ULONGLONG cond = VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
-    cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
-    // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
-    //       latter lies unless the user knew to embed a non-default manifest
-    //       announcing support for Windows 10 via supportedOS GUID
-    return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    // To make SetForegroundWindow work as we want, we need to fiddle
-    // with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
-    // as possible in the hope of still being the foreground process)
-    SystemParametersInfoW(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
-                          &_glfw.win32.foregroundLockTimeout, 0);
-    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
-                          SPIF_SENDCHANGE);
-
-    if (!loadLibraries())
-        return GLFW_FALSE;
-
-    createKeyTables();
-    _glfwUpdateKeyNamesWin32();
-
-    if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-        SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
-    else if (IsWindows8Point1OrGreater())
-        SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE);
-    else if (IsWindowsVistaOrGreater())
-        SetProcessDPIAware();
-
-    if (!_glfwRegisterWindowClassWin32())
-        return GLFW_FALSE;
-
-    if (!createHelperWindow())
-        return GLFW_FALSE;
-
-    _glfwInitTimerWin32();
-
-    _glfwPollMonitorsWin32();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    if (_glfw.win32.deviceNotificationHandle)
-        UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
-
-    if (_glfw.win32.helperWindowHandle)
-        DestroyWindow(_glfw.win32.helperWindowHandle);
-
-    _glfwUnregisterWindowClassWin32();
-
-    // Restore previous foreground lock timeout system setting
-    SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
-                          UIntToPtr(_glfw.win32.foregroundLockTimeout),
-                          SPIF_SENDCHANGE);
-
-    free(_glfw.win32.clipboardString);
-    free(_glfw.win32.rawInput);
-
-    _glfwTerminateWGL();
-    _glfwTerminateEGL();
-
-    freeLibraries();
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Win32 WGL EGL OSMesa"
-#if defined(__MINGW32__)
-        " MinGW"
-#elif defined(_MSC_VER)
-        " VisualC"
-#endif
-#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG)
-        " hybrid-GPU"
-#endif
-#if defined(_GLFW_BUILD_DLL)
-        " DLL"
-#endif
-        ;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_joystick.c b/raylib_pi4_test/external/glfw/src/win32_joystick.c
deleted file mode 100644 (file)
index 9c71d11..0000000
+++ /dev/null
@@ -1,753 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <math.h>
-
-#define _GLFW_TYPE_AXIS     0
-#define _GLFW_TYPE_SLIDER   1
-#define _GLFW_TYPE_BUTTON   2
-#define _GLFW_TYPE_POV      3
-
-// Data produced with DirectInput device object enumeration
-//
-typedef struct _GLFWobjenumWin32
-{
-    IDirectInputDevice8W*   device;
-    _GLFWjoyobjectWin32*    objects;
-    int                     objectCount;
-    int                     axisCount;
-    int                     sliderCount;
-    int                     buttonCount;
-    int                     povCount;
-} _GLFWobjenumWin32;
-
-// Define local copies of the necessary GUIDs
-//
-static const GUID _glfw_IID_IDirectInput8W =
-    {0xbf798031,0x483a,0x4da2,{0xaa,0x99,0x5d,0x64,0xed,0x36,0x97,0x00}};
-static const GUID _glfw_GUID_XAxis =
-    {0xa36d02e0,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_YAxis =
-    {0xa36d02e1,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_ZAxis =
-    {0xa36d02e2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RxAxis =
-    {0xa36d02f4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RyAxis =
-    {0xa36d02f5,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_RzAxis =
-    {0xa36d02e3,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_Slider =
-    {0xa36d02e4,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-static const GUID _glfw_GUID_POV =
-    {0xa36d02f2,0xc9f3,0x11cf,{0xbf,0xc7,0x44,0x45,0x53,0x54,0x00,0x00}};
-
-#define IID_IDirectInput8W _glfw_IID_IDirectInput8W
-#define GUID_XAxis _glfw_GUID_XAxis
-#define GUID_YAxis _glfw_GUID_YAxis
-#define GUID_ZAxis _glfw_GUID_ZAxis
-#define GUID_RxAxis _glfw_GUID_RxAxis
-#define GUID_RyAxis _glfw_GUID_RyAxis
-#define GUID_RzAxis _glfw_GUID_RzAxis
-#define GUID_Slider _glfw_GUID_Slider
-#define GUID_POV _glfw_GUID_POV
-
-// Object data array for our clone of c_dfDIJoystick
-// Generated with https://github.com/elmindreda/c_dfDIJoystick2
-//
-static DIOBJECTDATAFORMAT _glfwObjectDataFormats[] =
-{
-    { &GUID_XAxis,DIJOFS_X,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_YAxis,DIJOFS_Y,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_ZAxis,DIJOFS_Z,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RxAxis,DIJOFS_RX,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RyAxis,DIJOFS_RY,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_RzAxis,DIJOFS_RZ,DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_Slider,DIJOFS_SLIDER(0),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_Slider,DIJOFS_SLIDER(1),DIDFT_AXIS|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,DIDOI_ASPECTPOSITION },
-    { &GUID_POV,DIJOFS_POV(0),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(1),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(2),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { &GUID_POV,DIJOFS_POV(3),DIDFT_POV|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(0),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(1),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(2),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(3),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(4),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(5),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(6),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(7),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(8),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(9),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(10),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(11),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(12),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(13),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(14),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(15),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(16),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(17),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(18),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(19),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(20),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(21),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(22),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(23),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(24),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(25),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(26),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(27),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(28),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(29),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(30),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-    { NULL,DIJOFS_BUTTON(31),DIDFT_BUTTON|DIDFT_OPTIONAL|DIDFT_ANYINSTANCE,0 },
-};
-
-// Our clone of c_dfDIJoystick
-//
-static const DIDATAFORMAT _glfwDataFormat =
-{
-    sizeof(DIDATAFORMAT),
-    sizeof(DIOBJECTDATAFORMAT),
-    DIDFT_ABSAXIS,
-    sizeof(DIJOYSTATE),
-    sizeof(_glfwObjectDataFormats) / sizeof(DIOBJECTDATAFORMAT),
-    _glfwObjectDataFormats
-};
-
-// Returns a description fitting the specified XInput capabilities
-//
-static const char* getDeviceDescription(const XINPUT_CAPABILITIES* xic)
-{
-    switch (xic->SubType)
-    {
-        case XINPUT_DEVSUBTYPE_WHEEL:
-            return "XInput Wheel";
-        case XINPUT_DEVSUBTYPE_ARCADE_STICK:
-            return "XInput Arcade Stick";
-        case XINPUT_DEVSUBTYPE_FLIGHT_STICK:
-            return "XInput Flight Stick";
-        case XINPUT_DEVSUBTYPE_DANCE_PAD:
-            return "XInput Dance Pad";
-        case XINPUT_DEVSUBTYPE_GUITAR:
-            return "XInput Guitar";
-        case XINPUT_DEVSUBTYPE_DRUM_KIT:
-            return "XInput Drum Kit";
-        case XINPUT_DEVSUBTYPE_GAMEPAD:
-        {
-            if (xic->Flags & XINPUT_CAPS_WIRELESS)
-                return "Wireless Xbox Controller";
-            else
-                return "Xbox Controller";
-        }
-    }
-
-    return "Unknown XInput Device";
-}
-
-// Lexically compare device objects
-//
-static int compareJoystickObjects(const void* first, const void* second)
-{
-    const _GLFWjoyobjectWin32* fo = first;
-    const _GLFWjoyobjectWin32* so = second;
-
-    if (fo->type != so->type)
-        return fo->type - so->type;
-
-    return fo->offset - so->offset;
-}
-
-// Checks whether the specified device supports XInput
-// Technique from FDInputJoystickManager::IsXInputDeviceFast in ZDoom
-//
-static GLFWbool supportsXInput(const GUID* guid)
-{
-    UINT i, count = 0;
-    RAWINPUTDEVICELIST* ridl;
-    GLFWbool result = GLFW_FALSE;
-
-    if (GetRawInputDeviceList(NULL, &count, sizeof(RAWINPUTDEVICELIST)) != 0)
-        return GLFW_FALSE;
-
-    ridl = calloc(count, sizeof(RAWINPUTDEVICELIST));
-
-    if (GetRawInputDeviceList(ridl, &count, sizeof(RAWINPUTDEVICELIST)) == (UINT) -1)
-    {
-        free(ridl);
-        return GLFW_FALSE;
-    }
-
-    for (i = 0;  i < count;  i++)
-    {
-        RID_DEVICE_INFO rdi;
-        char name[256];
-        UINT size;
-
-        if (ridl[i].dwType != RIM_TYPEHID)
-            continue;
-
-        ZeroMemory(&rdi, sizeof(rdi));
-        rdi.cbSize = sizeof(rdi);
-        size = sizeof(rdi);
-
-        if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
-                                         RIDI_DEVICEINFO,
-                                         &rdi, &size) == -1)
-        {
-            continue;
-        }
-
-        if (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) != (LONG) guid->Data1)
-            continue;
-
-        memset(name, 0, sizeof(name));
-        size = sizeof(name);
-
-        if ((INT) GetRawInputDeviceInfoA(ridl[i].hDevice,
-                                         RIDI_DEVICENAME,
-                                         name, &size) == -1)
-        {
-            break;
-        }
-
-        name[sizeof(name) - 1] = '\0';
-        if (strstr(name, "IG_"))
-        {
-            result = GLFW_TRUE;
-            break;
-        }
-    }
-
-    free(ridl);
-    return result;
-}
-
-// Frees all resources associated with the specified joystick
-//
-static void closeJoystick(_GLFWjoystick* js)
-{
-    if (js->win32.device)
-    {
-        IDirectInputDevice8_Unacquire(js->win32.device);
-        IDirectInputDevice8_Release(js->win32.device);
-    }
-
-    free(js->win32.objects);
-
-    _glfwFreeJoystick(js);
-    _glfwInputJoystick(js, GLFW_DISCONNECTED);
-}
-
-// DirectInput device object enumeration callback
-// Insights gleaned from SDL
-//
-static BOOL CALLBACK deviceObjectCallback(const DIDEVICEOBJECTINSTANCEW* doi,
-                                          void* user)
-{
-    _GLFWobjenumWin32* data = user;
-    _GLFWjoyobjectWin32* object = data->objects + data->objectCount;
-
-    if (DIDFT_GETTYPE(doi->dwType) & DIDFT_AXIS)
-    {
-        DIPROPRANGE dipr;
-
-        if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_SLIDER(data->sliderCount);
-        else if (memcmp(&doi->guidType, &GUID_XAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_X;
-        else if (memcmp(&doi->guidType, &GUID_YAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_Y;
-        else if (memcmp(&doi->guidType, &GUID_ZAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_Z;
-        else if (memcmp(&doi->guidType, &GUID_RxAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RX;
-        else if (memcmp(&doi->guidType, &GUID_RyAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RY;
-        else if (memcmp(&doi->guidType, &GUID_RzAxis, sizeof(GUID)) == 0)
-            object->offset = DIJOFS_RZ;
-        else
-            return DIENUM_CONTINUE;
-
-        ZeroMemory(&dipr, sizeof(dipr));
-        dipr.diph.dwSize = sizeof(dipr);
-        dipr.diph.dwHeaderSize = sizeof(dipr.diph);
-        dipr.diph.dwObj = doi->dwType;
-        dipr.diph.dwHow = DIPH_BYID;
-        dipr.lMin = -32768;
-        dipr.lMax =  32767;
-
-        if (FAILED(IDirectInputDevice8_SetProperty(data->device,
-                                                   DIPROP_RANGE,
-                                                   &dipr.diph)))
-        {
-            return DIENUM_CONTINUE;
-        }
-
-        if (memcmp(&doi->guidType, &GUID_Slider, sizeof(GUID)) == 0)
-        {
-            object->type = _GLFW_TYPE_SLIDER;
-            data->sliderCount++;
-        }
-        else
-        {
-            object->type = _GLFW_TYPE_AXIS;
-            data->axisCount++;
-        }
-    }
-    else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_BUTTON)
-    {
-        object->offset = DIJOFS_BUTTON(data->buttonCount);
-        object->type = _GLFW_TYPE_BUTTON;
-        data->buttonCount++;
-    }
-    else if (DIDFT_GETTYPE(doi->dwType) & DIDFT_POV)
-    {
-        object->offset = DIJOFS_POV(data->povCount);
-        object->type = _GLFW_TYPE_POV;
-        data->povCount++;
-    }
-
-    data->objectCount++;
-    return DIENUM_CONTINUE;
-}
-
-// DirectInput device enumeration callback
-//
-static BOOL CALLBACK deviceCallback(const DIDEVICEINSTANCE* di, void* user)
-{
-    int jid = 0;
-    DIDEVCAPS dc;
-    DIPROPDWORD dipd;
-    IDirectInputDevice8* device;
-    _GLFWobjenumWin32 data;
-    _GLFWjoystick* js;
-    char guid[33];
-    char name[256];
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        js = _glfw.joysticks + jid;
-        if (js->present)
-        {
-            if (memcmp(&js->win32.guid, &di->guidInstance, sizeof(GUID)) == 0)
-                return DIENUM_CONTINUE;
-        }
-    }
-
-    if (supportsXInput(&di->guidProduct))
-        return DIENUM_CONTINUE;
-
-    if (FAILED(IDirectInput8_CreateDevice(_glfw.win32.dinput8.api,
-                                          &di->guidInstance,
-                                          &device,
-                                          NULL)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create device");
-        return DIENUM_CONTINUE;
-    }
-
-    if (FAILED(IDirectInputDevice8_SetDataFormat(device, &_glfwDataFormat)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set device data format");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    ZeroMemory(&dc, sizeof(dc));
-    dc.dwSize = sizeof(dc);
-
-    if (FAILED(IDirectInputDevice8_GetCapabilities(device, &dc)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to query device capabilities");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    ZeroMemory(&dipd, sizeof(dipd));
-    dipd.diph.dwSize = sizeof(dipd);
-    dipd.diph.dwHeaderSize = sizeof(dipd.diph);
-    dipd.diph.dwHow = DIPH_DEVICE;
-    dipd.dwData = DIPROPAXISMODE_ABS;
-
-    if (FAILED(IDirectInputDevice8_SetProperty(device,
-                                               DIPROP_AXISMODE,
-                                               &dipd.diph)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set device axis mode");
-
-        IDirectInputDevice8_Release(device);
-        return DIENUM_CONTINUE;
-    }
-
-    memset(&data, 0, sizeof(data));
-    data.device = device;
-    data.objects = calloc(dc.dwAxes + (size_t) dc.dwButtons + dc.dwPOVs,
-                          sizeof(_GLFWjoyobjectWin32));
-
-    if (FAILED(IDirectInputDevice8_EnumObjects(device,
-                                               deviceObjectCallback,
-                                               &data,
-                                               DIDFT_AXIS | DIDFT_BUTTON | DIDFT_POV)))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to enumerate device objects");
-
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_CONTINUE;
-    }
-
-    qsort(data.objects, data.objectCount,
-          sizeof(_GLFWjoyobjectWin32),
-          compareJoystickObjects);
-
-    if (!WideCharToMultiByte(CP_UTF8, 0,
-                             di->tszInstanceName, -1,
-                             name, sizeof(name),
-                             NULL, NULL))
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to convert joystick name to UTF-8");
-
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_STOP;
-    }
-
-    // Generate a joystick GUID that matches the SDL 2.0.5+ one
-    if (memcmp(&di->guidProduct.Data4[2], "PIDVID", 6) == 0)
-    {
-        sprintf(guid, "03000000%02x%02x0000%02x%02x000000000000",
-                (uint8_t) di->guidProduct.Data1,
-                (uint8_t) (di->guidProduct.Data1 >> 8),
-                (uint8_t) (di->guidProduct.Data1 >> 16),
-                (uint8_t) (di->guidProduct.Data1 >> 24));
-    }
-    else
-    {
-        sprintf(guid, "05000000%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x00",
-                name[0], name[1], name[2], name[3],
-                name[4], name[5], name[6], name[7],
-                name[8], name[9], name[10]);
-    }
-
-    js = _glfwAllocJoystick(name, guid,
-                            data.axisCount + data.sliderCount,
-                            data.buttonCount,
-                            data.povCount);
-    if (!js)
-    {
-        IDirectInputDevice8_Release(device);
-        free(data.objects);
-        return DIENUM_STOP;
-    }
-
-    js->win32.device = device;
-    js->win32.guid = di->guidInstance;
-    js->win32.objects = data.objects;
-    js->win32.objectCount = data.objectCount;
-
-    _glfwInputJoystick(js, GLFW_CONNECTED);
-    return DIENUM_CONTINUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Checks for new joysticks after DBT_DEVICEARRIVAL
-//
-void _glfwDetectJoystickConnectionWin32(void)
-{
-    if (_glfw.win32.xinput.instance)
-    {
-        DWORD index;
-
-        for (index = 0;  index < XUSER_MAX_COUNT;  index++)
-        {
-            int jid;
-            char guid[33];
-            XINPUT_CAPABILITIES xic;
-            _GLFWjoystick* js;
-
-            for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-            {
-                if (_glfw.joysticks[jid].present &&
-                    _glfw.joysticks[jid].win32.device == NULL &&
-                    _glfw.joysticks[jid].win32.index == index)
-                {
-                    break;
-                }
-            }
-
-            if (jid <= GLFW_JOYSTICK_LAST)
-                continue;
-
-            if (XInputGetCapabilities(index, 0, &xic) != ERROR_SUCCESS)
-                continue;
-
-            // Generate a joystick GUID that matches the SDL 2.0.5+ one
-            sprintf(guid, "78696e707574%02x000000000000000000",
-                    xic.SubType & 0xff);
-
-            js = _glfwAllocJoystick(getDeviceDescription(&xic), guid, 6, 10, 1);
-            if (!js)
-                continue;
-
-            js->win32.index = index;
-
-            _glfwInputJoystick(js, GLFW_CONNECTED);
-        }
-    }
-
-    if (_glfw.win32.dinput8.api)
-    {
-        if (FAILED(IDirectInput8_EnumDevices(_glfw.win32.dinput8.api,
-                                             DI8DEVCLASS_GAMECTRL,
-                                             deviceCallback,
-                                             NULL,
-                                             DIEDFL_ALLDEVICES)))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Failed to enumerate DirectInput8 devices");
-            return;
-        }
-    }
-}
-
-// Checks for joystick disconnection after DBT_DEVICEREMOVECOMPLETE
-//
-void _glfwDetectJoystickDisconnectionWin32(void)
-{
-    int jid;
-
-    for (jid = 0;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-    {
-        _GLFWjoystick* js = _glfw.joysticks + jid;
-        if (js->present)
-            _glfwPlatformPollJoystick(js, _GLFW_POLL_PRESENCE);
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformInitJoysticks(void)
-{
-    if (_glfw.win32.dinput8.instance)
-    {
-        if (FAILED(DirectInput8Create(GetModuleHandle(NULL),
-                                      DIRECTINPUT_VERSION,
-                                      &IID_IDirectInput8W,
-                                      (void**) &_glfw.win32.dinput8.api,
-                                      NULL)))
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Win32: Failed to create interface");
-            return GLFW_FALSE;
-        }
-    }
-
-    _glfwDetectJoystickConnectionWin32();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminateJoysticks(void)
-{
-    int jid;
-
-    for (jid = GLFW_JOYSTICK_1;  jid <= GLFW_JOYSTICK_LAST;  jid++)
-        closeJoystick(_glfw.joysticks + jid);
-
-    if (_glfw.win32.dinput8.api)
-        IDirectInput8_Release(_glfw.win32.dinput8.api);
-}
-
-int _glfwPlatformPollJoystick(_GLFWjoystick* js, int mode)
-{
-    if (js->win32.device)
-    {
-        int i, ai = 0, bi = 0, pi = 0;
-        HRESULT result;
-        DIJOYSTATE state;
-
-        IDirectInputDevice8_Poll(js->win32.device);
-        result = IDirectInputDevice8_GetDeviceState(js->win32.device,
-                                                    sizeof(state),
-                                                    &state);
-        if (result == DIERR_NOTACQUIRED || result == DIERR_INPUTLOST)
-        {
-            IDirectInputDevice8_Acquire(js->win32.device);
-            IDirectInputDevice8_Poll(js->win32.device);
-            result = IDirectInputDevice8_GetDeviceState(js->win32.device,
-                                                        sizeof(state),
-                                                        &state);
-        }
-
-        if (FAILED(result))
-        {
-            closeJoystick(js);
-            return GLFW_FALSE;
-        }
-
-        if (mode == _GLFW_POLL_PRESENCE)
-            return GLFW_TRUE;
-
-        for (i = 0;  i < js->win32.objectCount;  i++)
-        {
-            const void* data = (char*) &state + js->win32.objects[i].offset;
-
-            switch (js->win32.objects[i].type)
-            {
-                case _GLFW_TYPE_AXIS:
-                case _GLFW_TYPE_SLIDER:
-                {
-                    const float value = (*((LONG*) data) + 0.5f) / 32767.5f;
-                    _glfwInputJoystickAxis(js, ai, value);
-                    ai++;
-                    break;
-                }
-
-                case _GLFW_TYPE_BUTTON:
-                {
-                    const char value = (*((BYTE*) data) & 0x80) != 0;
-                    _glfwInputJoystickButton(js, bi, value);
-                    bi++;
-                    break;
-                }
-
-                case _GLFW_TYPE_POV:
-                {
-                    const int states[9] =
-                    {
-                        GLFW_HAT_UP,
-                        GLFW_HAT_RIGHT_UP,
-                        GLFW_HAT_RIGHT,
-                        GLFW_HAT_RIGHT_DOWN,
-                        GLFW_HAT_DOWN,
-                        GLFW_HAT_LEFT_DOWN,
-                        GLFW_HAT_LEFT,
-                        GLFW_HAT_LEFT_UP,
-                        GLFW_HAT_CENTERED
-                    };
-
-                    // Screams of horror are appropriate at this point
-                    int stateIndex = LOWORD(*(DWORD*) data) / (45 * DI_DEGREES);
-                    if (stateIndex < 0 || stateIndex > 8)
-                        stateIndex = 8;
-
-                    _glfwInputJoystickHat(js, pi, states[stateIndex]);
-                    pi++;
-                    break;
-                }
-            }
-        }
-    }
-    else
-    {
-        int i, dpad = 0;
-        DWORD result;
-        XINPUT_STATE xis;
-        const WORD buttons[10] =
-        {
-            XINPUT_GAMEPAD_A,
-            XINPUT_GAMEPAD_B,
-            XINPUT_GAMEPAD_X,
-            XINPUT_GAMEPAD_Y,
-            XINPUT_GAMEPAD_LEFT_SHOULDER,
-            XINPUT_GAMEPAD_RIGHT_SHOULDER,
-            XINPUT_GAMEPAD_BACK,
-            XINPUT_GAMEPAD_START,
-            XINPUT_GAMEPAD_LEFT_THUMB,
-            XINPUT_GAMEPAD_RIGHT_THUMB
-        };
-
-        result = XInputGetState(js->win32.index, &xis);
-        if (result != ERROR_SUCCESS)
-        {
-            if (result == ERROR_DEVICE_NOT_CONNECTED)
-                closeJoystick(js);
-
-            return GLFW_FALSE;
-        }
-
-        if (mode == _GLFW_POLL_PRESENCE)
-            return GLFW_TRUE;
-
-        _glfwInputJoystickAxis(js, 0, (xis.Gamepad.sThumbLX + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 1, -(xis.Gamepad.sThumbLY + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 2, (xis.Gamepad.sThumbRX + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 3, -(xis.Gamepad.sThumbRY + 0.5f) / 32767.5f);
-        _glfwInputJoystickAxis(js, 4, xis.Gamepad.bLeftTrigger / 127.5f - 1.f);
-        _glfwInputJoystickAxis(js, 5, xis.Gamepad.bRightTrigger / 127.5f - 1.f);
-
-        for (i = 0;  i < 10;  i++)
-        {
-            const char value = (xis.Gamepad.wButtons & buttons[i]) ? 1 : 0;
-            _glfwInputJoystickButton(js, i, value);
-        }
-
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
-            dpad |= GLFW_HAT_UP;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT)
-            dpad |= GLFW_HAT_RIGHT;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN)
-            dpad |= GLFW_HAT_DOWN;
-        if (xis.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT)
-            dpad |= GLFW_HAT_LEFT;
-
-        _glfwInputJoystickHat(js, 0, dpad);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformUpdateGamepadGUID(char* guid)
-{
-    if (strcmp(guid + 20, "504944564944") == 0)
-    {
-        char original[33];
-        strncpy(original, guid, sizeof(original) - 1);
-        sprintf(guid, "03000000%.4s0000%.4s000000000000",
-                original, original + 4);
-    }
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_joystick.h b/raylib_pi4_test/external/glfw/src/win32_joystick.h
deleted file mode 100644 (file)
index b6a7adc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#define _GLFW_PLATFORM_JOYSTICK_STATE         _GLFWjoystickWin32 win32
-#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
-
-#define _GLFW_PLATFORM_MAPPING_NAME "Windows"
-
-// Joystick element (axis, button or slider)
-//
-typedef struct _GLFWjoyobjectWin32
-{
-    int                     offset;
-    int                     type;
-} _GLFWjoyobjectWin32;
-
-// Win32-specific per-joystick data
-//
-typedef struct _GLFWjoystickWin32
-{
-    _GLFWjoyobjectWin32*    objects;
-    int                     objectCount;
-    IDirectInputDevice8W*   device;
-    DWORD                   index;
-    GUID                    guid;
-} _GLFWjoystickWin32;
-
-void _glfwDetectJoystickConnectionWin32(void);
-void _glfwDetectJoystickDisconnectionWin32(void);
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_monitor.c b/raylib_pi4_test/external/glfw/src/win32_monitor.c
deleted file mode 100644 (file)
index b4c53e4..0000000
+++ /dev/null
@@ -1,537 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <malloc.h>
-#include <wchar.h>
-
-
-// Callback for EnumDisplayMonitors in createMonitor
-//
-static BOOL CALLBACK monitorCallback(HMONITOR handle,
-                                     HDC dc,
-                                     RECT* rect,
-                                     LPARAM data)
-{
-    MONITORINFOEXW mi;
-    ZeroMemory(&mi, sizeof(mi));
-    mi.cbSize = sizeof(mi);
-
-    if (GetMonitorInfoW(handle, (MONITORINFO*) &mi))
-    {
-        _GLFWmonitor* monitor = (_GLFWmonitor*) data;
-        if (wcscmp(mi.szDevice, monitor->win32.adapterName) == 0)
-            monitor->win32.handle = handle;
-    }
-
-    return TRUE;
-}
-
-// Create monitor from an adapter and (optionally) a display
-//
-static _GLFWmonitor* createMonitor(DISPLAY_DEVICEW* adapter,
-                                   DISPLAY_DEVICEW* display)
-{
-    _GLFWmonitor* monitor;
-    int widthMM, heightMM;
-    char* name;
-    HDC dc;
-    DEVMODEW dm;
-    RECT rect;
-
-    if (display)
-        name = _glfwCreateUTF8FromWideStringWin32(display->DeviceString);
-    else
-        name = _glfwCreateUTF8FromWideStringWin32(adapter->DeviceString);
-    if (!name)
-        return NULL;
-
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-    EnumDisplaySettingsW(adapter->DeviceName, ENUM_CURRENT_SETTINGS, &dm);
-
-    dc = CreateDCW(L"DISPLAY", adapter->DeviceName, NULL, NULL);
-
-    if (IsWindows8Point1OrGreater())
-    {
-        widthMM  = GetDeviceCaps(dc, HORZSIZE);
-        heightMM = GetDeviceCaps(dc, VERTSIZE);
-    }
-    else
-    {
-        widthMM  = (int) (dm.dmPelsWidth * 25.4f / GetDeviceCaps(dc, LOGPIXELSX));
-        heightMM = (int) (dm.dmPelsHeight * 25.4f / GetDeviceCaps(dc, LOGPIXELSY));
-    }
-
-    DeleteDC(dc);
-
-    monitor = _glfwAllocMonitor(name, widthMM, heightMM);
-    free(name);
-
-    if (adapter->StateFlags & DISPLAY_DEVICE_MODESPRUNED)
-        monitor->win32.modesPruned = GLFW_TRUE;
-
-    wcscpy(monitor->win32.adapterName, adapter->DeviceName);
-    WideCharToMultiByte(CP_UTF8, 0,
-                        adapter->DeviceName, -1,
-                        monitor->win32.publicAdapterName,
-                        sizeof(monitor->win32.publicAdapterName),
-                        NULL, NULL);
-
-    if (display)
-    {
-        wcscpy(monitor->win32.displayName, display->DeviceName);
-        WideCharToMultiByte(CP_UTF8, 0,
-                            display->DeviceName, -1,
-                            monitor->win32.publicDisplayName,
-                            sizeof(monitor->win32.publicDisplayName),
-                            NULL, NULL);
-    }
-
-    rect.left   = dm.dmPosition.x;
-    rect.top    = dm.dmPosition.y;
-    rect.right  = dm.dmPosition.x + dm.dmPelsWidth;
-    rect.bottom = dm.dmPosition.y + dm.dmPelsHeight;
-
-    EnumDisplayMonitors(NULL, &rect, monitorCallback, (LPARAM) monitor);
-    return monitor;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsWin32(void)
-{
-    int i, disconnectedCount;
-    _GLFWmonitor** disconnected = NULL;
-    DWORD adapterIndex, displayIndex;
-    DISPLAY_DEVICEW adapter, display;
-    _GLFWmonitor* monitor;
-
-    disconnectedCount = _glfw.monitorCount;
-    if (disconnectedCount)
-    {
-        disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-        memcpy(disconnected,
-               _glfw.monitors,
-               _glfw.monitorCount * sizeof(_GLFWmonitor*));
-    }
-
-    for (adapterIndex = 0;  ;  adapterIndex++)
-    {
-        int type = _GLFW_INSERT_LAST;
-
-        ZeroMemory(&adapter, sizeof(adapter));
-        adapter.cb = sizeof(adapter);
-
-        if (!EnumDisplayDevicesW(NULL, adapterIndex, &adapter, 0))
-            break;
-
-        if (!(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE))
-            continue;
-
-        if (adapter.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)
-            type = _GLFW_INSERT_FIRST;
-
-        for (displayIndex = 0;  ;  displayIndex++)
-        {
-            ZeroMemory(&display, sizeof(display));
-            display.cb = sizeof(display);
-
-            if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
-                break;
-
-            if (!(display.StateFlags & DISPLAY_DEVICE_ACTIVE))
-                continue;
-
-            for (i = 0;  i < disconnectedCount;  i++)
-            {
-                if (disconnected[i] &&
-                    wcscmp(disconnected[i]->win32.displayName,
-                           display.DeviceName) == 0)
-                {
-                    disconnected[i] = NULL;
-                    // handle may have changed, update
-                    EnumDisplayMonitors(NULL, NULL, monitorCallback, (LPARAM) _glfw.monitors[i]);
-                    break;
-                }
-            }
-
-            if (i < disconnectedCount)
-                continue;
-
-            monitor = createMonitor(&adapter, &display);
-            if (!monitor)
-            {
-                free(disconnected);
-                return;
-            }
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-
-            type = _GLFW_INSERT_LAST;
-        }
-
-        // HACK: If an active adapter does not have any display devices
-        //       (as sometimes happens), add it directly as a monitor
-        if (displayIndex == 0)
-        {
-            for (i = 0;  i < disconnectedCount;  i++)
-            {
-                if (disconnected[i] &&
-                    wcscmp(disconnected[i]->win32.adapterName,
-                           adapter.DeviceName) == 0)
-                {
-                    disconnected[i] = NULL;
-                    break;
-                }
-            }
-
-            if (i < disconnectedCount)
-                continue;
-
-            monitor = createMonitor(&adapter, NULL);
-            if (!monitor)
-            {
-                free(disconnected);
-                return;
-            }
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-        }
-    }
-
-    for (i = 0;  i < disconnectedCount;  i++)
-    {
-        if (disconnected[i])
-            _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-    }
-
-    free(disconnected);
-}
-
-// Change the current video mode
-//
-void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    GLFWvidmode current;
-    const GLFWvidmode* best;
-    DEVMODEW dm;
-    LONG result;
-
-    best = _glfwChooseVideoMode(monitor, desired);
-    _glfwPlatformGetVideoMode(monitor, &current);
-    if (_glfwCompareVideoModes(&current, best) == 0)
-        return;
-
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-    dm.dmFields           = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL |
-                            DM_DISPLAYFREQUENCY;
-    dm.dmPelsWidth        = best->width;
-    dm.dmPelsHeight       = best->height;
-    dm.dmBitsPerPel       = best->redBits + best->greenBits + best->blueBits;
-    dm.dmDisplayFrequency = best->refreshRate;
-
-    if (dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24)
-        dm.dmBitsPerPel = 32;
-
-    result = ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                      &dm,
-                                      NULL,
-                                      CDS_FULLSCREEN,
-                                      NULL);
-    if (result == DISP_CHANGE_SUCCESSFUL)
-        monitor->win32.modeChanged = GLFW_TRUE;
-    else
-    {
-        const char* description = "Unknown error";
-
-        if (result == DISP_CHANGE_BADDUALVIEW)
-            description = "The system uses DualView";
-        else if (result == DISP_CHANGE_BADFLAGS)
-            description = "Invalid flags";
-        else if (result == DISP_CHANGE_BADMODE)
-            description = "Graphics mode not supported";
-        else if (result == DISP_CHANGE_BADPARAM)
-            description = "Invalid parameter";
-        else if (result == DISP_CHANGE_FAILED)
-            description = "Graphics mode failed";
-        else if (result == DISP_CHANGE_NOTUPDATED)
-            description = "Failed to write to registry";
-        else if (result == DISP_CHANGE_RESTART)
-            description = "Computer restart required";
-
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to set video mode: %s",
-                        description);
-    }
-}
-
-// Restore the previously saved (original) video mode
-//
-void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
-{
-    if (monitor->win32.modeChanged)
-    {
-        ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                 NULL, NULL, CDS_FULLSCREEN, NULL);
-        monitor->win32.modeChanged = GLFW_FALSE;
-    }
-}
-
-void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale)
-{
-    UINT xdpi, ydpi;
-
-    if (IsWindows8Point1OrGreater())
-        GetDpiForMonitor(handle, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
-    else
-    {
-        const HDC dc = GetDC(NULL);
-        xdpi = GetDeviceCaps(dc, LOGPIXELSX);
-        ydpi = GetDeviceCaps(dc, LOGPIXELSY);
-        ReleaseDC(NULL, dc);
-    }
-
-    if (xscale)
-        *xscale = xdpi / (float) USER_DEFAULT_SCREEN_DPI;
-    if (yscale)
-        *yscale = ydpi / (float) USER_DEFAULT_SCREEN_DPI;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    DEVMODEW dm;
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-
-    EnumDisplaySettingsExW(monitor->win32.adapterName,
-                           ENUM_CURRENT_SETTINGS,
-                           &dm,
-                           EDS_ROTATEDMODE);
-
-    if (xpos)
-        *xpos = dm.dmPosition.x;
-    if (ypos)
-        *ypos = dm.dmPosition.y;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    _glfwGetMonitorContentScaleWin32(monitor->win32.handle, xscale, yscale);
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    MONITORINFO mi = { sizeof(mi) };
-    GetMonitorInfo(monitor->win32.handle, &mi);
-
-    if (xpos)
-        *xpos = mi.rcWork.left;
-    if (ypos)
-        *ypos = mi.rcWork.top;
-    if (width)
-        *width = mi.rcWork.right - mi.rcWork.left;
-    if (height)
-        *height = mi.rcWork.bottom - mi.rcWork.top;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    int modeIndex = 0, size = 0;
-    GLFWvidmode* result = NULL;
-
-    *count = 0;
-
-    for (;;)
-    {
-        int i;
-        GLFWvidmode mode;
-        DEVMODEW dm;
-
-        ZeroMemory(&dm, sizeof(dm));
-        dm.dmSize = sizeof(dm);
-
-        if (!EnumDisplaySettingsW(monitor->win32.adapterName, modeIndex, &dm))
-            break;
-
-        modeIndex++;
-
-        // Skip modes with less than 15 BPP
-        if (dm.dmBitsPerPel < 15)
-            continue;
-
-        mode.width  = dm.dmPelsWidth;
-        mode.height = dm.dmPelsHeight;
-        mode.refreshRate = dm.dmDisplayFrequency;
-        _glfwSplitBPP(dm.dmBitsPerPel,
-                      &mode.redBits,
-                      &mode.greenBits,
-                      &mode.blueBits);
-
-        for (i = 0;  i < *count;  i++)
-        {
-            if (_glfwCompareVideoModes(result + i, &mode) == 0)
-                break;
-        }
-
-        // Skip duplicate modes
-        if (i < *count)
-            continue;
-
-        if (monitor->win32.modesPruned)
-        {
-            // Skip modes not supported by the connected displays
-            if (ChangeDisplaySettingsExW(monitor->win32.adapterName,
-                                         &dm,
-                                         NULL,
-                                         CDS_TEST,
-                                         NULL) != DISP_CHANGE_SUCCESSFUL)
-            {
-                continue;
-            }
-        }
-
-        if (*count == size)
-        {
-            size += 128;
-            result = (GLFWvidmode*) realloc(result, size * sizeof(GLFWvidmode));
-        }
-
-        (*count)++;
-        result[*count - 1] = mode;
-    }
-
-    if (!*count)
-    {
-        // HACK: Report the current mode if no valid modes were found
-        result = calloc(1, sizeof(GLFWvidmode));
-        _glfwPlatformGetVideoMode(monitor, result);
-        *count = 1;
-    }
-
-    return result;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    DEVMODEW dm;
-    ZeroMemory(&dm, sizeof(dm));
-    dm.dmSize = sizeof(dm);
-
-    EnumDisplaySettingsW(monitor->win32.adapterName, ENUM_CURRENT_SETTINGS, &dm);
-
-    mode->width  = dm.dmPelsWidth;
-    mode->height = dm.dmPelsHeight;
-    mode->refreshRate = dm.dmDisplayFrequency;
-    _glfwSplitBPP(dm.dmBitsPerPel,
-                  &mode->redBits,
-                  &mode->greenBits,
-                  &mode->blueBits);
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    HDC dc;
-    WORD values[3][256];
-
-    dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
-    GetDeviceGammaRamp(dc, values);
-    DeleteDC(dc);
-
-    _glfwAllocGammaArrays(ramp, 256);
-
-    memcpy(ramp->red,   values[0], sizeof(values[0]));
-    memcpy(ramp->green, values[1], sizeof(values[1]));
-    memcpy(ramp->blue,  values[2], sizeof(values[2]));
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    HDC dc;
-    WORD values[3][256];
-
-    if (ramp->size != 256)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Gamma ramp size must be 256");
-        return;
-    }
-
-    memcpy(values[0], ramp->red,   sizeof(values[0]));
-    memcpy(values[1], ramp->green, sizeof(values[1]));
-    memcpy(values[2], ramp->blue,  sizeof(values[2]));
-
-    dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
-    SetDeviceGammaRamp(dc, values);
-    DeleteDC(dc);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->win32.publicAdapterName;
-}
-
-GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->win32.publicDisplayName;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_platform.h b/raylib_pi4_test/external/glfw/src/win32_platform.h
deleted file mode 100644 (file)
index 4f52051..0000000
+++ /dev/null
@@ -1,459 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-// We don't need all the fancy stuff
-#ifndef NOMINMAX
- #define NOMINMAX
-#endif
-
-#ifndef VC_EXTRALEAN
- #define VC_EXTRALEAN
-#endif
-
-#ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
-#endif
-
-// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
-// example to allow applications to correctly declare a GL_ARB_debug_output
-// callback) but windows.h assumes no one will define APIENTRY before it does
-#undef APIENTRY
-
-// GLFW on Windows is Unicode only and does not work in MBCS mode
-#ifndef UNICODE
- #define UNICODE
-#endif
-
-// GLFW requires Windows XP or later
-#if WINVER < 0x0501
- #undef WINVER
- #define WINVER 0x0501
-#endif
-#if _WIN32_WINNT < 0x0501
- #undef _WIN32_WINNT
- #define _WIN32_WINNT 0x0501
-#endif
-
-// GLFW uses DirectInput8 interfaces
-#define DIRECTINPUT_VERSION 0x0800
-
-// GLFW uses OEM cursor resources
-#define OEMRESOURCE
-
-#include <wctype.h>
-#include <windows.h>
-#include <dinput.h>
-#include <xinput.h>
-#include <dbt.h>
-
-// HACK: Define macros that some windows.h variants don't
-#ifndef WM_MOUSEHWHEEL
- #define WM_MOUSEHWHEEL 0x020E
-#endif
-#ifndef WM_DWMCOMPOSITIONCHANGED
- #define WM_DWMCOMPOSITIONCHANGED 0x031E
-#endif
-#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
- #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
-#endif
-#ifndef WM_COPYGLOBALDATA
- #define WM_COPYGLOBALDATA 0x0049
-#endif
-#ifndef WM_UNICHAR
- #define WM_UNICHAR 0x0109
-#endif
-#ifndef UNICODE_NOCHAR
- #define UNICODE_NOCHAR 0xFFFF
-#endif
-#ifndef WM_DPICHANGED
- #define WM_DPICHANGED 0x02E0
-#endif
-#ifndef GET_XBUTTON_WPARAM
- #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
-#endif
-#ifndef EDS_ROTATEDMODE
- #define EDS_ROTATEDMODE 0x00000004
-#endif
-#ifndef DISPLAY_DEVICE_ACTIVE
- #define DISPLAY_DEVICE_ACTIVE 0x00000001
-#endif
-#ifndef _WIN32_WINNT_WINBLUE
- #define _WIN32_WINNT_WINBLUE 0x0603
-#endif
-#ifndef _WIN32_WINNT_WIN8
- #define _WIN32_WINNT_WIN8 0x0602
-#endif
-#ifndef WM_GETDPISCALEDSIZE
- #define WM_GETDPISCALEDSIZE 0x02e4
-#endif
-#ifndef USER_DEFAULT_SCREEN_DPI
- #define USER_DEFAULT_SCREEN_DPI 96
-#endif
-#ifndef OCR_HAND
- #define OCR_HAND 32649
-#endif
-
-#if WINVER < 0x0601
-typedef struct
-{
-    DWORD cbSize;
-    DWORD ExtStatus;
-} CHANGEFILTERSTRUCT;
-#ifndef MSGFLT_ALLOW
- #define MSGFLT_ALLOW 1
-#endif
-#endif /*Windows 7*/
-
-#if WINVER < 0x0600
-#define DWM_BB_ENABLE 0x00000001
-#define DWM_BB_BLURREGION 0x00000002
-typedef struct
-{
-    DWORD dwFlags;
-    BOOL fEnable;
-    HRGN hRgnBlur;
-    BOOL fTransitionOnMaximized;
-} DWM_BLURBEHIND;
-#else
- #include <dwmapi.h>
-#endif /*Windows Vista*/
-
-#ifndef DPI_ENUMS_DECLARED
-typedef enum
-{
-    PROCESS_DPI_UNAWARE = 0,
-    PROCESS_SYSTEM_DPI_AWARE = 1,
-    PROCESS_PER_MONITOR_DPI_AWARE = 2
-} PROCESS_DPI_AWARENESS;
-typedef enum
-{
-    MDT_EFFECTIVE_DPI = 0,
-    MDT_ANGULAR_DPI = 1,
-    MDT_RAW_DPI = 2,
-    MDT_DEFAULT = MDT_EFFECTIVE_DPI
-} MONITOR_DPI_TYPE;
-#endif /*DPI_ENUMS_DECLARED*/
-
-#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
-#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
-#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
-
-// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
-#define IsWindowsVistaOrGreater()                                     \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA),   \
-                                        LOBYTE(_WIN32_WINNT_VISTA), 0)
-#define IsWindows7OrGreater()                                         \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7),    \
-                                        LOBYTE(_WIN32_WINNT_WIN7), 0)
-#define IsWindows8OrGreater()                                         \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8),    \
-                                        LOBYTE(_WIN32_WINNT_WIN8), 0)
-#define IsWindows8Point1OrGreater()                                   \
-    _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
-                                        LOBYTE(_WIN32_WINNT_WINBLUE), 0)
-
-#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
-    _glfwIsWindows10BuildOrGreaterWin32(14393)
-#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
-    _glfwIsWindows10BuildOrGreaterWin32(15063)
-
-// HACK: Define macros that some xinput.h variants don't
-#ifndef XINPUT_CAPS_WIRELESS
- #define XINPUT_CAPS_WIRELESS 0x0002
-#endif
-#ifndef XINPUT_DEVSUBTYPE_WHEEL
- #define XINPUT_DEVSUBTYPE_WHEEL 0x02
-#endif
-#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
- #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
-#endif
-#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
- #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
-#endif
-#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
- #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
-#endif
-#ifndef XINPUT_DEVSUBTYPE_GUITAR
- #define XINPUT_DEVSUBTYPE_GUITAR 0x06
-#endif
-#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
- #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
-#endif
-#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
- #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
-#endif
-#ifndef XUSER_MAX_COUNT
- #define XUSER_MAX_COUNT 4
-#endif
-
-// HACK: Define macros that some dinput.h variants don't
-#ifndef DIDFT_OPTIONAL
- #define DIDFT_OPTIONAL 0x80000000
-#endif
-
-// winmm.dll function pointer typedefs
-typedef DWORD (WINAPI * PFN_timeGetTime)(void);
-#define timeGetTime _glfw.win32.winmm.GetTime
-
-// xinput.dll function pointer typedefs
-typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
-typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
-#define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
-#define XInputGetState _glfw.win32.xinput.GetState
-
-// dinput8.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
-#define DirectInput8Create _glfw.win32.dinput8.Create
-
-// user32.dll function pointer typedefs
-typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
-typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
-typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
-typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
-typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
-typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
-#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
-#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
-#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
-#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
-#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
-#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
-
-// dwmapi.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
-typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
-typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
-typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
-#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
-#define DwmFlush _glfw.win32.dwmapi.Flush
-#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
-#define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
-
-// shcore.dll function pointer typedefs
-typedef HRESULT (WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
-typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
-#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
-#define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
-
-// ntdll.dll function pointer typedefs
-typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
-#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
-
-typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
-
-typedef struct VkWin32SurfaceCreateInfoKHR
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkWin32SurfaceCreateFlagsKHR    flags;
-    HINSTANCE                       hinstance;
-    HWND                            hwnd;
-} VkWin32SurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateWin32SurfaceKHR)(VkInstance,const VkWin32SurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice,uint32_t);
-
-#include "win32_joystick.h"
-#include "wgl_context.h"
-
-#if !defined(_GLFW_WNDCLASSNAME)
- #define _GLFW_WNDCLASSNAME L"GLFW30"
-#endif
-
-#define _glfw_dlopen(name) LoadLibraryA(name)
-#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
-#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWin32  win32
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
-#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE  _GLFWtimerWin32   win32
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWin32 win32
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWin32  win32
-#define _GLFW_PLATFORM_TLS_STATE            _GLFWtlsWin32     win32
-#define _GLFW_PLATFORM_MUTEX_STATE          _GLFWmutexWin32   win32
-
-
-// Win32-specific per-window data
-//
-typedef struct _GLFWwindowWin32
-{
-    HWND                handle;
-    HICON               bigIcon;
-    HICON               smallIcon;
-
-    GLFWbool            cursorTracked;
-    GLFWbool            frameAction;
-    GLFWbool            iconified;
-    GLFWbool            maximized;
-    // Whether to enable framebuffer transparency on DWM
-    GLFWbool            transparent;
-    GLFWbool            scaleToMonitor;
-    GLFWbool            keymenu;
-
-    // The last received cursor position, regardless of source
-    int                 lastCursorPosX, lastCursorPosY;
-    // The last recevied high surrogate when decoding pairs of UTF-16 messages
-    WCHAR               highSurrogate;
-
-} _GLFWwindowWin32;
-
-// Win32-specific global data
-//
-typedef struct _GLFWlibraryWin32
-{
-    HWND                helperWindowHandle;
-    HDEVNOTIFY          deviceNotificationHandle;
-    DWORD               foregroundLockTimeout;
-    int                 acquiredMonitorCount;
-    char*               clipboardString;
-    short int           keycodes[512];
-    short int           scancodes[GLFW_KEY_LAST + 1];
-    char                keynames[GLFW_KEY_LAST + 1][5];
-    // Where to place the cursor when re-enabled
-    double              restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*        disabledCursorWindow;
-    RAWINPUT*           rawInput;
-    int                 rawInputSize;
-    UINT                mouseTrailSize;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_timeGetTime                 GetTime;
-    } winmm;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_DirectInput8Create          Create;
-        IDirectInput8W*                 api;
-    } dinput8;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_XInputGetCapabilities       GetCapabilities;
-        PFN_XInputGetState              GetState;
-    } xinput;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_SetProcessDPIAware          SetProcessDPIAware_;
-        PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_;
-        PFN_EnableNonClientDpiScaling   EnableNonClientDpiScaling_;
-        PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_;
-        PFN_GetDpiForWindow             GetDpiForWindow_;
-        PFN_AdjustWindowRectExForDpi    AdjustWindowRectExForDpi_;
-    } user32;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_DwmIsCompositionEnabled     IsCompositionEnabled;
-        PFN_DwmFlush                    Flush;
-        PFN_DwmEnableBlurBehindWindow   EnableBlurBehindWindow;
-        PFN_DwmGetColorizationColor     GetColorizationColor;
-    } dwmapi;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_SetProcessDpiAwareness      SetProcessDpiAwareness_;
-        PFN_GetDpiForMonitor            GetDpiForMonitor_;
-    } shcore;
-
-    struct {
-        HINSTANCE                       instance;
-        PFN_RtlVerifyVersionInfo        RtlVerifyVersionInfo_;
-    } ntdll;
-
-} _GLFWlibraryWin32;
-
-// Win32-specific per-monitor data
-//
-typedef struct _GLFWmonitorWin32
-{
-    HMONITOR            handle;
-    // This size matches the static size of DISPLAY_DEVICE.DeviceName
-    WCHAR               adapterName[32];
-    WCHAR               displayName[32];
-    char                publicAdapterName[32];
-    char                publicDisplayName[32];
-    GLFWbool            modesPruned;
-    GLFWbool            modeChanged;
-
-} _GLFWmonitorWin32;
-
-// Win32-specific per-cursor data
-//
-typedef struct _GLFWcursorWin32
-{
-    HCURSOR             handle;
-
-} _GLFWcursorWin32;
-
-// Win32-specific global timer data
-//
-typedef struct _GLFWtimerWin32
-{
-    GLFWbool            hasPC;
-    uint64_t            frequency;
-
-} _GLFWtimerWin32;
-
-// Win32-specific thread local storage data
-//
-typedef struct _GLFWtlsWin32
-{
-    GLFWbool            allocated;
-    DWORD               index;
-
-} _GLFWtlsWin32;
-
-// Win32-specific mutex data
-//
-typedef struct _GLFWmutexWin32
-{
-    GLFWbool            allocated;
-    CRITICAL_SECTION    section;
-
-} _GLFWmutexWin32;
-
-
-GLFWbool _glfwRegisterWindowClassWin32(void);
-void _glfwUnregisterWindowClassWin32(void);
-
-WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
-char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
-BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
-BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build);
-void _glfwInputErrorWin32(int error, const char* description);
-void _glfwUpdateKeyNamesWin32(void);
-
-void _glfwInitTimerWin32(void);
-
-void _glfwPollMonitorsWin32(void);
-void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
-void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_thread.c b/raylib_pi4_test/external/glfw/src/win32_thread.c
deleted file mode 100644 (file)
index 53b34af..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
-{
-    assert(tls->win32.allocated == GLFW_FALSE);
-
-    tls->win32.index = TlsAlloc();
-    if (tls->win32.index == TLS_OUT_OF_INDEXES)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to allocate TLS index");
-        return GLFW_FALSE;
-    }
-
-    tls->win32.allocated = GLFW_TRUE;
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyTls(_GLFWtls* tls)
-{
-    if (tls->win32.allocated)
-        TlsFree(tls->win32.index);
-    memset(tls, 0, sizeof(_GLFWtls));
-}
-
-void* _glfwPlatformGetTls(_GLFWtls* tls)
-{
-    assert(tls->win32.allocated == GLFW_TRUE);
-    return TlsGetValue(tls->win32.index);
-}
-
-void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
-{
-    assert(tls->win32.allocated == GLFW_TRUE);
-    TlsSetValue(tls->win32.index, value);
-}
-
-GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_FALSE);
-    InitializeCriticalSection(&mutex->win32.section);
-    return mutex->win32.allocated = GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
-{
-    if (mutex->win32.allocated)
-        DeleteCriticalSection(&mutex->win32.section);
-    memset(mutex, 0, sizeof(_GLFWmutex));
-}
-
-void _glfwPlatformLockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_TRUE);
-    EnterCriticalSection(&mutex->win32.section);
-}
-
-void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
-{
-    assert(mutex->win32.allocated == GLFW_TRUE);
-    LeaveCriticalSection(&mutex->win32.section);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_time.c b/raylib_pi4_test/external/glfw/src/win32_time.c
deleted file mode 100644 (file)
index 721b0d0..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Initialise timer
-//
-void _glfwInitTimerWin32(void)
-{
-    uint64_t frequency;
-
-    if (QueryPerformanceFrequency((LARGE_INTEGER*) &frequency))
-    {
-        _glfw.timer.win32.hasPC = GLFW_TRUE;
-        _glfw.timer.win32.frequency = frequency;
-    }
-    else
-    {
-        _glfw.timer.win32.hasPC = GLFW_FALSE;
-        _glfw.timer.win32.frequency = 1000;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-uint64_t _glfwPlatformGetTimerValue(void)
-{
-    if (_glfw.timer.win32.hasPC)
-    {
-        uint64_t value;
-        QueryPerformanceCounter((LARGE_INTEGER*) &value);
-        return value;
-    }
-    else
-        return (uint64_t) timeGetTime();
-}
-
-uint64_t _glfwPlatformGetTimerFrequency(void)
-{
-    return _glfw.timer.win32.frequency;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/win32_window.c b/raylib_pi4_test/external/glfw/src/win32_window.c
deleted file mode 100644 (file)
index 8cb5050..0000000
+++ /dev/null
@@ -1,2372 +0,0 @@
-//========================================================================
-// GLFW 3.4 Win32 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <malloc.h>
-#include <string.h>
-#include <windowsx.h>
-#include <shellapi.h>
-
-// Returns the window style for the specified window
-//
-static DWORD getWindowStyle(const _GLFWwindow* window)
-{
-    DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
-
-    if (window->monitor)
-        style |= WS_POPUP;
-    else
-    {
-        style |= WS_SYSMENU | WS_MINIMIZEBOX;
-
-        if (window->decorated)
-        {
-            style |= WS_CAPTION;
-
-            if (window->resizable)
-                style |= WS_MAXIMIZEBOX | WS_THICKFRAME;
-        }
-        else
-            style |= WS_POPUP;
-    }
-
-    return style;
-}
-
-// Returns the extended window style for the specified window
-//
-static DWORD getWindowExStyle(const _GLFWwindow* window)
-{
-    DWORD style = WS_EX_APPWINDOW;
-
-    if (window->monitor || window->floating)
-        style |= WS_EX_TOPMOST;
-
-    return style;
-}
-
-// Returns the image whose area most closely matches the desired one
-//
-static const GLFWimage* chooseImage(int count, const GLFWimage* images,
-                                    int width, int height)
-{
-    int i, leastDiff = INT_MAX;
-    const GLFWimage* closest = NULL;
-
-    for (i = 0;  i < count;  i++)
-    {
-        const int currDiff = abs(images[i].width * images[i].height -
-                                 width * height);
-        if (currDiff < leastDiff)
-        {
-            closest = images + i;
-            leastDiff = currDiff;
-        }
-    }
-
-    return closest;
-}
-
-// Creates an RGBA icon or cursor
-//
-static HICON createIcon(const GLFWimage* image,
-                        int xhot, int yhot, GLFWbool icon)
-{
-    int i;
-    HDC dc;
-    HICON handle;
-    HBITMAP color, mask;
-    BITMAPV5HEADER bi;
-    ICONINFO ii;
-    unsigned char* target = NULL;
-    unsigned char* source = image->pixels;
-
-    ZeroMemory(&bi, sizeof(bi));
-    bi.bV5Size        = sizeof(bi);
-    bi.bV5Width       = image->width;
-    bi.bV5Height      = -image->height;
-    bi.bV5Planes      = 1;
-    bi.bV5BitCount    = 32;
-    bi.bV5Compression = BI_BITFIELDS;
-    bi.bV5RedMask     = 0x00ff0000;
-    bi.bV5GreenMask   = 0x0000ff00;
-    bi.bV5BlueMask    = 0x000000ff;
-    bi.bV5AlphaMask   = 0xff000000;
-
-    dc = GetDC(NULL);
-    color = CreateDIBSection(dc,
-                             (BITMAPINFO*) &bi,
-                             DIB_RGB_COLORS,
-                             (void**) &target,
-                             NULL,
-                             (DWORD) 0);
-    ReleaseDC(NULL, dc);
-
-    if (!color)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create RGBA bitmap");
-        return NULL;
-    }
-
-    mask = CreateBitmap(image->width, image->height, 1, 1, NULL);
-    if (!mask)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create mask bitmap");
-        DeleteObject(color);
-        return NULL;
-    }
-
-    for (i = 0;  i < image->width * image->height;  i++)
-    {
-        target[0] = source[2];
-        target[1] = source[1];
-        target[2] = source[0];
-        target[3] = source[3];
-        target += 4;
-        source += 4;
-    }
-
-    ZeroMemory(&ii, sizeof(ii));
-    ii.fIcon    = icon;
-    ii.xHotspot = xhot;
-    ii.yHotspot = yhot;
-    ii.hbmMask  = mask;
-    ii.hbmColor = color;
-
-    handle = CreateIconIndirect(&ii);
-
-    DeleteObject(color);
-    DeleteObject(mask);
-
-    if (!handle)
-    {
-        if (icon)
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "Win32: Failed to create icon");
-        }
-        else
-        {
-            _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                                 "Win32: Failed to create cursor");
-        }
-    }
-
-    return handle;
-}
-
-// Translate content area size to full window size according to styles and DPI
-//
-static void getFullWindowSize(DWORD style, DWORD exStyle,
-                              int contentWidth, int contentHeight,
-                              int* fullWidth, int* fullHeight,
-                              UINT dpi)
-{
-    RECT rect = { 0, 0, contentWidth, contentHeight };
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle, dpi);
-    else
-        AdjustWindowRectEx(&rect, style, FALSE, exStyle);
-
-    *fullWidth = rect.right - rect.left;
-    *fullHeight = rect.bottom - rect.top;
-}
-
-// Enforce the content area aspect ratio based on which edge is being dragged
-//
-static void applyAspectRatio(_GLFWwindow* window, int edge, RECT* area)
-{
-    int xoff, yoff;
-    UINT dpi = USER_DEFAULT_SCREEN_DPI;
-    const float ratio = (float) window->numer / (float) window->denom;
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        dpi = GetDpiForWindow(window->win32.handle);
-
-    getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
-                      0, 0, &xoff, &yoff, dpi);
-
-    if (edge == WMSZ_LEFT  || edge == WMSZ_BOTTOMLEFT ||
-        edge == WMSZ_RIGHT || edge == WMSZ_BOTTOMRIGHT)
-    {
-        area->bottom = area->top + yoff +
-            (int) ((area->right - area->left - xoff) / ratio);
-    }
-    else if (edge == WMSZ_TOPLEFT || edge == WMSZ_TOPRIGHT)
-    {
-        area->top = area->bottom - yoff -
-            (int) ((area->right - area->left - xoff) / ratio);
-    }
-    else if (edge == WMSZ_TOP || edge == WMSZ_BOTTOM)
-    {
-        area->right = area->left + xoff +
-            (int) ((area->bottom - area->top - yoff) * ratio);
-    }
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (window->cursor)
-            SetCursor(window->cursor->win32.handle);
-        else
-            SetCursor(LoadCursorW(NULL, IDC_ARROW));
-    }
-    else
-        SetCursor(NULL);
-}
-
-// Updates the cursor clip rect
-//
-static void updateClipRect(_GLFWwindow* window)
-{
-    if (window)
-    {
-        RECT clipRect;
-        GetClientRect(window->win32.handle, &clipRect);
-        ClientToScreen(window->win32.handle, (POINT*) &clipRect.left);
-        ClientToScreen(window->win32.handle, (POINT*) &clipRect.right);
-        ClipCursor(&clipRect);
-    }
-    else
-        ClipCursor(NULL);
-}
-
-// Enables WM_INPUT messages for the mouse for the specified window
-//
-static void enableRawMouseMotion(_GLFWwindow* window)
-{
-    const RAWINPUTDEVICE rid = { 0x01, 0x02, 0, window->win32.handle };
-
-    if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to register raw input device");
-    }
-}
-
-// Disables WM_INPUT messages for the mouse
-//
-static void disableRawMouseMotion(_GLFWwindow* window)
-{
-    const RAWINPUTDEVICE rid = { 0x01, 0x02, RIDEV_REMOVE, NULL };
-
-    if (!RegisterRawInputDevices(&rid, 1, sizeof(rid)))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to remove raw input device");
-    }
-}
-
-// Apply disabled cursor mode to a focused window
-//
-static void disableCursor(_GLFWwindow* window)
-{
-    _glfw.win32.disabledCursorWindow = window;
-    _glfwPlatformGetCursorPos(window,
-                              &_glfw.win32.restoreCursorPosX,
-                              &_glfw.win32.restoreCursorPosY);
-    updateCursorImage(window);
-    _glfwCenterCursorInContentArea(window);
-    updateClipRect(window);
-
-    if (window->rawMouseMotion)
-        enableRawMouseMotion(window);
-}
-
-// Exit disabled cursor mode for the specified window
-//
-static void enableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        disableRawMouseMotion(window);
-
-    _glfw.win32.disabledCursorWindow = NULL;
-    updateClipRect(NULL);
-    _glfwPlatformSetCursorPos(window,
-                              _glfw.win32.restoreCursorPosX,
-                              _glfw.win32.restoreCursorPosY);
-    updateCursorImage(window);
-}
-
-// Returns whether the cursor is in the content area of the specified window
-//
-static GLFWbool cursorInContentArea(_GLFWwindow* window)
-{
-    RECT area;
-    POINT pos;
-
-    if (!GetCursorPos(&pos))
-        return GLFW_FALSE;
-
-    if (WindowFromPoint(pos) != window->win32.handle)
-        return GLFW_FALSE;
-
-    GetClientRect(window->win32.handle, &area);
-    ClientToScreen(window->win32.handle, (POINT*) &area.left);
-    ClientToScreen(window->win32.handle, (POINT*) &area.right);
-
-    return PtInRect(&area, pos);
-}
-
-// Update native window styles to match attributes
-//
-static void updateWindowStyles(const _GLFWwindow* window)
-{
-    RECT rect;
-    DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-    style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP);
-    style |= getWindowStyle(window);
-
-    GetClientRect(window->win32.handle, &rect);
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, style, FALSE,
-                                 getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-        AdjustWindowRectEx(&rect, style, FALSE, getWindowExStyle(window));
-
-    ClientToScreen(window->win32.handle, (POINT*) &rect.left);
-    ClientToScreen(window->win32.handle, (POINT*) &rect.right);
-    SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-    SetWindowPos(window->win32.handle, HWND_TOP,
-                 rect.left, rect.top,
-                 rect.right - rect.left, rect.bottom - rect.top,
-                 SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER);
-}
-
-// Update window framebuffer transparency
-//
-static void updateFramebufferTransparency(const _GLFWwindow* window)
-{
-    BOOL composition, opaque;
-    DWORD color;
-
-    if (!IsWindowsVistaOrGreater())
-        return;
-
-    if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
-       return;
-
-    if (IsWindows8OrGreater() ||
-        (SUCCEEDED(DwmGetColorizationColor(&color, &opaque)) && !opaque))
-    {
-        HRGN region = CreateRectRgn(0, 0, -1, -1);
-        DWM_BLURBEHIND bb = {0};
-        bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
-        bb.hRgnBlur = region;
-        bb.fEnable = TRUE;
-
-        DwmEnableBlurBehindWindow(window->win32.handle, &bb);
-        DeleteObject(region);
-    }
-    else
-    {
-        // HACK: Disable framebuffer transparency on Windows 7 when the
-        //       colorization color is opaque, because otherwise the window
-        //       contents is blended additively with the previous frame instead
-        //       of replacing it
-        DWM_BLURBEHIND bb = {0};
-        bb.dwFlags = DWM_BB_ENABLE;
-        DwmEnableBlurBehindWindow(window->win32.handle, &bb);
-    }
-}
-
-// Retrieves and translates modifier keys
-//
-static int getKeyMods(void)
-{
-    int mods = 0;
-
-    if (GetKeyState(VK_SHIFT) & 0x8000)
-        mods |= GLFW_MOD_SHIFT;
-    if (GetKeyState(VK_CONTROL) & 0x8000)
-        mods |= GLFW_MOD_CONTROL;
-    if (GetKeyState(VK_MENU) & 0x8000)
-        mods |= GLFW_MOD_ALT;
-    if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
-        mods |= GLFW_MOD_SUPER;
-    if (GetKeyState(VK_CAPITAL) & 1)
-        mods |= GLFW_MOD_CAPS_LOCK;
-    if (GetKeyState(VK_NUMLOCK) & 1)
-        mods |= GLFW_MOD_NUM_LOCK;
-
-    return mods;
-}
-
-static void fitToMonitor(_GLFWwindow* window)
-{
-    MONITORINFO mi = { sizeof(mi) };
-    GetMonitorInfo(window->monitor->win32.handle, &mi);
-    SetWindowPos(window->win32.handle, HWND_TOPMOST,
-                 mi.rcMonitor.left,
-                 mi.rcMonitor.top,
-                 mi.rcMonitor.right - mi.rcMonitor.left,
-                 mi.rcMonitor.bottom - mi.rcMonitor.top,
-                 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    if (!_glfw.win32.acquiredMonitorCount)
-    {
-        SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
-
-        // HACK: When mouse trails are enabled the cursor becomes invisible when
-        //       the OpenGL ICD switches to page flipping
-        SystemParametersInfo(SPI_GETMOUSETRAILS, 0, &_glfw.win32.mouseTrailSize, 0);
-        SystemParametersInfo(SPI_SETMOUSETRAILS, 0, 0, 0);
-    }
-
-    if (!window->monitor->window)
-        _glfw.win32.acquiredMonitorCount++;
-
-    _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfw.win32.acquiredMonitorCount--;
-    if (!_glfw.win32.acquiredMonitorCount)
-    {
-        SetThreadExecutionState(ES_CONTINUOUS);
-
-        // HACK: Restore mouse trail length saved in acquireMonitor
-        SystemParametersInfo(SPI_SETMOUSETRAILS, _glfw.win32.mouseTrailSize, 0, 0);
-    }
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeWin32(window->monitor);
-}
-
-// Window callback function (handles window messages)
-//
-static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
-                                   WPARAM wParam, LPARAM lParam)
-{
-    _GLFWwindow* window = GetPropW(hWnd, L"GLFW");
-    if (!window)
-    {
-        // This is the message handling for the hidden helper window
-        // and for a regular window during its initial creation
-
-        switch (uMsg)
-        {
-            case WM_NCCREATE:
-            {
-                if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-                    EnableNonClientDpiScaling(hWnd);
-
-                break;
-            }
-
-            case WM_DISPLAYCHANGE:
-                _glfwPollMonitorsWin32();
-                break;
-
-            case WM_DEVICECHANGE:
-            {
-                if (!_glfw.joysticksInitialized)
-                    break;
-
-                if (wParam == DBT_DEVICEARRIVAL)
-                {
-                    DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
-                    if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
-                        _glfwDetectJoystickConnectionWin32();
-                }
-                else if (wParam == DBT_DEVICEREMOVECOMPLETE)
-                {
-                    DEV_BROADCAST_HDR* dbh = (DEV_BROADCAST_HDR*) lParam;
-                    if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
-                        _glfwDetectJoystickDisconnectionWin32();
-                }
-
-                break;
-            }
-        }
-
-        return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-    }
-
-    switch (uMsg)
-    {
-        case WM_MOUSEACTIVATE:
-        {
-            // HACK: Postpone cursor disabling when the window was activated by
-            //       clicking a caption button
-            if (HIWORD(lParam) == WM_LBUTTONDOWN)
-            {
-                if (LOWORD(lParam) != HTCLIENT)
-                    window->win32.frameAction = GLFW_TRUE;
-            }
-
-            break;
-        }
-
-        case WM_CAPTURECHANGED:
-        {
-            // HACK: Disable the cursor once the caption button action has been
-            //       completed or cancelled
-            if (lParam == 0 && window->win32.frameAction)
-            {
-                if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                    disableCursor(window);
-
-                window->win32.frameAction = GLFW_FALSE;
-            }
-
-            break;
-        }
-
-        case WM_SETFOCUS:
-        {
-            _glfwInputWindowFocus(window, GLFW_TRUE);
-
-            // HACK: Do not disable cursor while the user is interacting with
-            //       a caption button
-            if (window->win32.frameAction)
-                break;
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            return 0;
-        }
-
-        case WM_KILLFOCUS:
-        {
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            if (window->monitor && window->autoIconify)
-                _glfwPlatformIconifyWindow(window);
-
-            _glfwInputWindowFocus(window, GLFW_FALSE);
-            return 0;
-        }
-
-        case WM_SYSCOMMAND:
-        {
-            switch (wParam & 0xfff0)
-            {
-                case SC_SCREENSAVE:
-                case SC_MONITORPOWER:
-                {
-                    if (window->monitor)
-                    {
-                        // We are running in full screen mode, so disallow
-                        // screen saver and screen blanking
-                        return 0;
-                    }
-                    else
-                        break;
-                }
-
-                // User trying to access application menu using ALT?
-                case SC_KEYMENU:
-                {
-                    if (!window->win32.keymenu)
-                        return 0;
-
-                    break;
-                }
-            }
-            break;
-        }
-
-        case WM_CLOSE:
-        {
-            _glfwInputWindowCloseRequest(window);
-            return 0;
-        }
-
-        case WM_INPUTLANGCHANGE:
-        {
-            _glfwUpdateKeyNamesWin32();
-            break;
-        }
-
-        case WM_CHAR:
-        case WM_SYSCHAR:
-        {
-            if (wParam >= 0xd800 && wParam <= 0xdbff)
-                window->win32.highSurrogate = (WCHAR) wParam;
-            else
-            {
-                unsigned int codepoint = 0;
-
-                if (wParam >= 0xdc00 && wParam <= 0xdfff)
-                {
-                    if (window->win32.highSurrogate)
-                    {
-                        codepoint += (window->win32.highSurrogate - 0xd800) << 10;
-                        codepoint += (WCHAR) wParam - 0xdc00;
-                        codepoint += 0x10000;
-                    }
-                }
-                else
-                    codepoint = (WCHAR) wParam;
-
-                window->win32.highSurrogate = 0;
-                _glfwInputChar(window, codepoint, getKeyMods(), uMsg != WM_SYSCHAR);
-            }
-
-            if (uMsg == WM_SYSCHAR && window->win32.keymenu)
-                break;
-
-            return 0;
-        }
-
-        case WM_UNICHAR:
-        {
-            if (wParam == UNICODE_NOCHAR)
-            {
-                // WM_UNICHAR is not sent by Windows, but is sent by some
-                // third-party input method engine
-                // Returning TRUE here announces support for this message
-                return TRUE;
-            }
-
-            _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), GLFW_TRUE);
-            return 0;
-        }
-
-        case WM_KEYDOWN:
-        case WM_SYSKEYDOWN:
-        case WM_KEYUP:
-        case WM_SYSKEYUP:
-        {
-            int key, scancode;
-            const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS;
-            const int mods = getKeyMods();
-
-            scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff));
-            if (!scancode)
-            {
-                // NOTE: Some synthetic key messages have a scancode of zero
-                // HACK: Map the virtual key back to a usable scancode
-                scancode = MapVirtualKeyW((UINT) wParam, MAPVK_VK_TO_VSC);
-            }
-
-            key = _glfw.win32.keycodes[scancode];
-
-            // The Ctrl keys require special handling
-            if (wParam == VK_CONTROL)
-            {
-                if (HIWORD(lParam) & KF_EXTENDED)
-                {
-                    // Right side keys have the extended key bit set
-                    key = GLFW_KEY_RIGHT_CONTROL;
-                }
-                else
-                {
-                    // NOTE: Alt Gr sends Left Ctrl followed by Right Alt
-                    // HACK: We only want one event for Alt Gr, so if we detect
-                    //       this sequence we discard this Left Ctrl message now
-                    //       and later report Right Alt normally
-                    MSG next;
-                    const DWORD time = GetMessageTime();
-
-                    if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE))
-                    {
-                        if (next.message == WM_KEYDOWN ||
-                            next.message == WM_SYSKEYDOWN ||
-                            next.message == WM_KEYUP ||
-                            next.message == WM_SYSKEYUP)
-                        {
-                            if (next.wParam == VK_MENU &&
-                                (HIWORD(next.lParam) & KF_EXTENDED) &&
-                                next.time == time)
-                            {
-                                // Next message is Right Alt down so discard this
-                                break;
-                            }
-                        }
-                    }
-
-                    // This is a regular Left Ctrl message
-                    key = GLFW_KEY_LEFT_CONTROL;
-                }
-            }
-            else if (wParam == VK_PROCESSKEY)
-            {
-                // IME notifies that keys have been filtered by setting the
-                // virtual key-code to VK_PROCESSKEY
-                break;
-            }
-
-            if (action == GLFW_RELEASE && wParam == VK_SHIFT)
-            {
-                // HACK: Release both Shift keys on Shift up event, as when both
-                //       are pressed the first release does not emit any event
-                // NOTE: The other half of this is in _glfwPlatformPollEvents
-                _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
-                _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
-            }
-            else if (wParam == VK_SNAPSHOT)
-            {
-                // HACK: Key down is not reported for the Print Screen key
-                _glfwInputKey(window, key, scancode, GLFW_PRESS, mods);
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, mods);
-            }
-            else
-                _glfwInputKey(window, key, scancode, action, mods);
-
-            break;
-        }
-
-        case WM_LBUTTONDOWN:
-        case WM_RBUTTONDOWN:
-        case WM_MBUTTONDOWN:
-        case WM_XBUTTONDOWN:
-        case WM_LBUTTONUP:
-        case WM_RBUTTONUP:
-        case WM_MBUTTONUP:
-        case WM_XBUTTONUP:
-        {
-            int i, button, action;
-
-            if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_LEFT;
-            else if (uMsg == WM_RBUTTONDOWN || uMsg == WM_RBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_RIGHT;
-            else if (uMsg == WM_MBUTTONDOWN || uMsg == WM_MBUTTONUP)
-                button = GLFW_MOUSE_BUTTON_MIDDLE;
-            else if (GET_XBUTTON_WPARAM(wParam) == XBUTTON1)
-                button = GLFW_MOUSE_BUTTON_4;
-            else
-                button = GLFW_MOUSE_BUTTON_5;
-
-            if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN ||
-                uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN)
-            {
-                action = GLFW_PRESS;
-            }
-            else
-                action = GLFW_RELEASE;
-
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == GLFW_PRESS)
-                    break;
-            }
-
-            if (i > GLFW_MOUSE_BUTTON_LAST)
-                SetCapture(hWnd);
-
-            _glfwInputMouseClick(window, button, action, getKeyMods());
-
-            for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
-            {
-                if (window->mouseButtons[i] == GLFW_PRESS)
-                    break;
-            }
-
-            if (i > GLFW_MOUSE_BUTTON_LAST)
-                ReleaseCapture();
-
-            if (uMsg == WM_XBUTTONDOWN || uMsg == WM_XBUTTONUP)
-                return TRUE;
-
-            return 0;
-        }
-
-        case WM_MOUSEMOVE:
-        {
-            const int x = GET_X_LPARAM(lParam);
-            const int y = GET_Y_LPARAM(lParam);
-
-            if (!window->win32.cursorTracked)
-            {
-                TRACKMOUSEEVENT tme;
-                ZeroMemory(&tme, sizeof(tme));
-                tme.cbSize = sizeof(tme);
-                tme.dwFlags = TME_LEAVE;
-                tme.hwndTrack = window->win32.handle;
-                TrackMouseEvent(&tme);
-
-                window->win32.cursorTracked = GLFW_TRUE;
-                _glfwInputCursorEnter(window, GLFW_TRUE);
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-            {
-                const int dx = x - window->win32.lastCursorPosX;
-                const int dy = y - window->win32.lastCursorPosY;
-
-                if (_glfw.win32.disabledCursorWindow != window)
-                    break;
-                if (window->rawMouseMotion)
-                    break;
-
-                _glfwInputCursorPos(window,
-                                    window->virtualCursorPosX + dx,
-                                    window->virtualCursorPosY + dy);
-            }
-            else
-                _glfwInputCursorPos(window, x, y);
-
-            window->win32.lastCursorPosX = x;
-            window->win32.lastCursorPosY = y;
-
-            return 0;
-        }
-
-        case WM_INPUT:
-        {
-            UINT size = 0;
-            HRAWINPUT ri = (HRAWINPUT) lParam;
-            RAWINPUT* data = NULL;
-            int dx, dy;
-
-            if (_glfw.win32.disabledCursorWindow != window)
-                break;
-            if (!window->rawMouseMotion)
-                break;
-
-            GetRawInputData(ri, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
-            if (size > (UINT) _glfw.win32.rawInputSize)
-            {
-                free(_glfw.win32.rawInput);
-                _glfw.win32.rawInput = calloc(size, 1);
-                _glfw.win32.rawInputSize = size;
-            }
-
-            size = _glfw.win32.rawInputSize;
-            if (GetRawInputData(ri, RID_INPUT,
-                                _glfw.win32.rawInput, &size,
-                                sizeof(RAWINPUTHEADER)) == (UINT) -1)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Win32: Failed to retrieve raw input data");
-                break;
-            }
-
-            data = _glfw.win32.rawInput;
-            if (data->data.mouse.usFlags & MOUSE_MOVE_ABSOLUTE)
-            {
-                dx = data->data.mouse.lLastX - window->win32.lastCursorPosX;
-                dy = data->data.mouse.lLastY - window->win32.lastCursorPosY;
-            }
-            else
-            {
-                dx = data->data.mouse.lLastX;
-                dy = data->data.mouse.lLastY;
-            }
-
-            _glfwInputCursorPos(window,
-                                window->virtualCursorPosX + dx,
-                                window->virtualCursorPosY + dy);
-
-            window->win32.lastCursorPosX += dx;
-            window->win32.lastCursorPosY += dy;
-            break;
-        }
-
-        case WM_MOUSELEAVE:
-        {
-            window->win32.cursorTracked = GLFW_FALSE;
-            _glfwInputCursorEnter(window, GLFW_FALSE);
-            return 0;
-        }
-
-        case WM_MOUSEWHEEL:
-        {
-            _glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
-            return 0;
-        }
-
-        case WM_MOUSEHWHEEL:
-        {
-            // This message is only sent on Windows Vista and later
-            // NOTE: The X-axis is inverted for consistency with macOS and X11
-            _glfwInputScroll(window, -((SHORT) HIWORD(wParam) / (double) WHEEL_DELTA), 0.0);
-            return 0;
-        }
-
-        case WM_ENTERSIZEMOVE:
-        case WM_ENTERMENULOOP:
-        {
-            if (window->win32.frameAction)
-                break;
-
-            // HACK: Enable the cursor while the user is moving or
-            //       resizing the window or using the window menu
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            break;
-        }
-
-        case WM_EXITSIZEMOVE:
-        case WM_EXITMENULOOP:
-        {
-            if (window->win32.frameAction)
-                break;
-
-            // HACK: Disable the cursor once the user is done moving or
-            //       resizing the window or using the menu
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            break;
-        }
-
-        case WM_SIZE:
-        {
-            const GLFWbool iconified = wParam == SIZE_MINIMIZED;
-            const GLFWbool maximized = wParam == SIZE_MAXIMIZED ||
-                                       (window->win32.maximized &&
-                                        wParam != SIZE_RESTORED);
-
-            if (_glfw.win32.disabledCursorWindow == window)
-                updateClipRect(window);
-
-            if (window->win32.iconified != iconified)
-                _glfwInputWindowIconify(window, iconified);
-
-            if (window->win32.maximized != maximized)
-                _glfwInputWindowMaximize(window, maximized);
-
-            _glfwInputFramebufferSize(window, LOWORD(lParam), HIWORD(lParam));
-            _glfwInputWindowSize(window, LOWORD(lParam), HIWORD(lParam));
-
-            if (window->monitor && window->win32.iconified != iconified)
-            {
-                if (iconified)
-                    releaseMonitor(window);
-                else
-                {
-                    acquireMonitor(window);
-                    fitToMonitor(window);
-                }
-            }
-
-            window->win32.iconified = iconified;
-            window->win32.maximized = maximized;
-            return 0;
-        }
-
-        case WM_MOVE:
-        {
-            if (_glfw.win32.disabledCursorWindow == window)
-                updateClipRect(window);
-
-            // NOTE: This cannot use LOWORD/HIWORD recommended by MSDN, as
-            // those macros do not handle negative window positions correctly
-            _glfwInputWindowPos(window,
-                                GET_X_LPARAM(lParam),
-                                GET_Y_LPARAM(lParam));
-            return 0;
-        }
-
-        case WM_SIZING:
-        {
-            if (window->numer == GLFW_DONT_CARE ||
-                window->denom == GLFW_DONT_CARE)
-            {
-                break;
-            }
-
-            applyAspectRatio(window, (int) wParam, (RECT*) lParam);
-            return TRUE;
-        }
-
-        case WM_GETMINMAXINFO:
-        {
-            int xoff, yoff;
-            UINT dpi = USER_DEFAULT_SCREEN_DPI;
-            MINMAXINFO* mmi = (MINMAXINFO*) lParam;
-
-            if (window->monitor)
-                break;
-
-            if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-                dpi = GetDpiForWindow(window->win32.handle);
-
-            getFullWindowSize(getWindowStyle(window), getWindowExStyle(window),
-                              0, 0, &xoff, &yoff, dpi);
-
-            if (window->minwidth != GLFW_DONT_CARE &&
-                window->minheight != GLFW_DONT_CARE)
-            {
-                mmi->ptMinTrackSize.x = window->minwidth + xoff;
-                mmi->ptMinTrackSize.y = window->minheight + yoff;
-            }
-
-            if (window->maxwidth != GLFW_DONT_CARE &&
-                window->maxheight != GLFW_DONT_CARE)
-            {
-                mmi->ptMaxTrackSize.x = window->maxwidth + xoff;
-                mmi->ptMaxTrackSize.y = window->maxheight + yoff;
-            }
-
-            if (!window->decorated)
-            {
-                MONITORINFO mi;
-                const HMONITOR mh = MonitorFromWindow(window->win32.handle,
-                                                      MONITOR_DEFAULTTONEAREST);
-
-                ZeroMemory(&mi, sizeof(mi));
-                mi.cbSize = sizeof(mi);
-                GetMonitorInfo(mh, &mi);
-
-                mmi->ptMaxPosition.x = mi.rcWork.left - mi.rcMonitor.left;
-                mmi->ptMaxPosition.y = mi.rcWork.top - mi.rcMonitor.top;
-                mmi->ptMaxSize.x = mi.rcWork.right - mi.rcWork.left;
-                mmi->ptMaxSize.y = mi.rcWork.bottom - mi.rcWork.top;
-            }
-
-            return 0;
-        }
-
-        case WM_PAINT:
-        {
-            _glfwInputWindowDamage(window);
-            break;
-        }
-
-        case WM_ERASEBKGND:
-        {
-            return TRUE;
-        }
-
-        case WM_NCACTIVATE:
-        case WM_NCPAINT:
-        {
-            // Prevent title bar from being drawn after restoring a minimized
-            // undecorated window
-            if (!window->decorated)
-                return TRUE;
-
-            break;
-        }
-
-        case WM_DWMCOMPOSITIONCHANGED:
-        case WM_DWMCOLORIZATIONCOLORCHANGED:
-        {
-            if (window->win32.transparent)
-                updateFramebufferTransparency(window);
-            return 0;
-        }
-
-        case WM_GETDPISCALEDSIZE:
-        {
-            if (window->win32.scaleToMonitor)
-                break;
-
-            // Adjust the window size to keep the content area size constant
-            if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-            {
-                RECT source = {0}, target = {0};
-                SIZE* size = (SIZE*) lParam;
-
-                AdjustWindowRectExForDpi(&source, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         GetDpiForWindow(window->win32.handle));
-                AdjustWindowRectExForDpi(&target, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         LOWORD(wParam));
-
-                size->cx += (target.right - target.left) -
-                            (source.right - source.left);
-                size->cy += (target.bottom - target.top) -
-                            (source.bottom - source.top);
-                return TRUE;
-            }
-
-            break;
-        }
-
-        case WM_DPICHANGED:
-        {
-            const float xscale = HIWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
-            const float yscale = LOWORD(wParam) / (float) USER_DEFAULT_SCREEN_DPI;
-
-            // Only apply the suggested size if the OS is new enough to have
-            // sent a WM_GETDPISCALEDSIZE before this
-            if (_glfwIsWindows10CreatorsUpdateOrGreaterWin32())
-            {
-                RECT* suggested = (RECT*) lParam;
-                SetWindowPos(window->win32.handle, HWND_TOP,
-                             suggested->left,
-                             suggested->top,
-                             suggested->right - suggested->left,
-                             suggested->bottom - suggested->top,
-                             SWP_NOACTIVATE | SWP_NOZORDER);
-            }
-
-            _glfwInputWindowContentScale(window, xscale, yscale);
-            break;
-        }
-
-        case WM_SETCURSOR:
-        {
-            if (LOWORD(lParam) == HTCLIENT)
-            {
-                updateCursorImage(window);
-                return TRUE;
-            }
-
-            break;
-        }
-
-        case WM_DROPFILES:
-        {
-            HDROP drop = (HDROP) wParam;
-            POINT pt;
-            int i;
-
-            const int count = DragQueryFileW(drop, 0xffffffff, NULL, 0);
-            char** paths = calloc(count, sizeof(char*));
-
-            // Move the mouse to the position of the drop
-            DragQueryPoint(drop, &pt);
-            _glfwInputCursorPos(window, pt.x, pt.y);
-
-            for (i = 0;  i < count;  i++)
-            {
-                const UINT length = DragQueryFileW(drop, i, NULL, 0);
-                WCHAR* buffer = calloc((size_t) length + 1, sizeof(WCHAR));
-
-                DragQueryFileW(drop, i, buffer, length + 1);
-                paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
-
-                free(buffer);
-            }
-
-            _glfwInputDrop(window, count, (const char**) paths);
-
-            for (i = 0;  i < count;  i++)
-                free(paths[i]);
-            free(paths);
-
-            DragFinish(drop);
-            return 0;
-        }
-    }
-
-    return DefWindowProcW(hWnd, uMsg, wParam, lParam);
-}
-
-// Creates the GLFW window
-//
-static int createNativeWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    int xpos, ypos, fullWidth, fullHeight;
-    WCHAR* wideTitle;
-    DWORD style = getWindowStyle(window);
-    DWORD exStyle = getWindowExStyle(window);
-
-    if (window->monitor)
-    {
-        GLFWvidmode mode;
-
-        // NOTE: This window placement is temporary and approximate, as the
-        //       correct position and size cannot be known until the monitor
-        //       video mode has been picked in _glfwSetVideoModeWin32
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-        fullWidth  = mode.width;
-        fullHeight = mode.height;
-    }
-    else
-    {
-        xpos = CW_USEDEFAULT;
-        ypos = CW_USEDEFAULT;
-
-        window->win32.maximized = wndconfig->maximized;
-        if (wndconfig->maximized)
-            style |= WS_MAXIMIZE;
-
-        getFullWindowSize(style, exStyle,
-                          wndconfig->width, wndconfig->height,
-                          &fullWidth, &fullHeight,
-                          USER_DEFAULT_SCREEN_DPI);
-    }
-
-    wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
-    if (!wideTitle)
-        return GLFW_FALSE;
-
-    window->win32.handle = CreateWindowExW(exStyle,
-                                           _GLFW_WNDCLASSNAME,
-                                           wideTitle,
-                                           style,
-                                           xpos, ypos,
-                                           fullWidth, fullHeight,
-                                           NULL, // No parent window
-                                           NULL, // No window menu
-                                           GetModuleHandleW(NULL),
-                                           NULL);
-
-    free(wideTitle);
-
-    if (!window->win32.handle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    SetPropW(window->win32.handle, L"GLFW", window);
-
-    if (IsWindows7OrGreater())
-    {
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_DROPFILES, MSGFLT_ALLOW, NULL);
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_COPYDATA, MSGFLT_ALLOW, NULL);
-        ChangeWindowMessageFilterEx(window->win32.handle,
-                                    WM_COPYGLOBALDATA, MSGFLT_ALLOW, NULL);
-    }
-
-    window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
-    window->win32.keymenu = wndconfig->win32.keymenu;
-
-    // Adjust window rect to account for DPI scaling of the window frame and
-    // (if enabled) DPI scaling of the content area
-    // This cannot be done until we know what monitor the window was placed on
-    if (!window->monitor)
-    {
-        RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
-        WINDOWPLACEMENT wp = { sizeof(wp) };
-
-        if (wndconfig->scaleToMonitor)
-        {
-            float xscale, yscale;
-            _glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
-            rect.right = (int) (rect.right * xscale);
-            rect.bottom = (int) (rect.bottom * yscale);
-        }
-
-        ClientToScreen(window->win32.handle, (POINT*) &rect.left);
-        ClientToScreen(window->win32.handle, (POINT*) &rect.right);
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, style, FALSE, exStyle,
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-            AdjustWindowRectEx(&rect, style, FALSE, exStyle);
-
-        // Only update the restored window rect as the window may be maximized
-        GetWindowPlacement(window->win32.handle, &wp);
-        wp.rcNormalPosition = rect;
-        wp.showCmd = SW_HIDE;
-        SetWindowPlacement(window->win32.handle, &wp);
-    }
-
-    DragAcceptFiles(window->win32.handle, TRUE);
-
-    if (fbconfig->transparent)
-    {
-        updateFramebufferTransparency(window);
-        window->win32.transparent = GLFW_TRUE;
-    }
-
-    return GLFW_TRUE;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Registers the GLFW window class
-//
-GLFWbool _glfwRegisterWindowClassWin32(void)
-{
-    WNDCLASSEXW wc;
-
-    ZeroMemory(&wc, sizeof(wc));
-    wc.cbSize        = sizeof(wc);
-    wc.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
-    wc.lpfnWndProc   = (WNDPROC) windowProc;
-    wc.hInstance     = GetModuleHandleW(NULL);
-    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
-    wc.lpszClassName = _GLFW_WNDCLASSNAME;
-
-    // Load user-provided icon if available
-    wc.hIcon = LoadImageW(GetModuleHandleW(NULL),
-                          L"GLFW_ICON", IMAGE_ICON,
-                          0, 0, LR_DEFAULTSIZE | LR_SHARED);
-    if (!wc.hIcon)
-    {
-        // No user-provided icon found, load default icon
-        wc.hIcon = LoadImageW(NULL,
-                              IDI_APPLICATION, IMAGE_ICON,
-                              0, 0, LR_DEFAULTSIZE | LR_SHARED);
-    }
-
-    if (!RegisterClassExW(&wc))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to register window class");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Unregisters the GLFW window class
-//
-void _glfwUnregisterWindowClassWin32(void)
-{
-    UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    if (!createNativeWindow(window, wndconfig, fbconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitWGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        _glfwPlatformFocusWindow(window);
-        acquireMonitor(window);
-        fitToMonitor(window);
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    if (_glfw.win32.disabledCursorWindow == window)
-        _glfw.win32.disabledCursorWindow = NULL;
-
-    if (window->win32.handle)
-    {
-        RemovePropW(window->win32.handle, L"GLFW");
-        DestroyWindow(window->win32.handle);
-        window->win32.handle = NULL;
-    }
-
-    if (window->win32.bigIcon)
-        DestroyIcon(window->win32.bigIcon);
-
-    if (window->win32.smallIcon)
-        DestroyIcon(window->win32.smallIcon);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
-    if (!wideTitle)
-        return;
-
-    SetWindowTextW(window->win32.handle, wideTitle);
-    free(wideTitle);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    HICON bigIcon = NULL, smallIcon = NULL;
-
-    if (count)
-    {
-        const GLFWimage* bigImage = chooseImage(count, images,
-                                                GetSystemMetrics(SM_CXICON),
-                                                GetSystemMetrics(SM_CYICON));
-        const GLFWimage* smallImage = chooseImage(count, images,
-                                                  GetSystemMetrics(SM_CXSMICON),
-                                                  GetSystemMetrics(SM_CYSMICON));
-
-        bigIcon = createIcon(bigImage, 0, 0, GLFW_TRUE);
-        smallIcon = createIcon(smallImage, 0, 0, GLFW_TRUE);
-    }
-    else
-    {
-        bigIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICON);
-        smallIcon = (HICON) GetClassLongPtrW(window->win32.handle, GCLP_HICONSM);
-    }
-
-    SendMessage(window->win32.handle, WM_SETICON, ICON_BIG, (LPARAM) bigIcon);
-    SendMessage(window->win32.handle, WM_SETICON, ICON_SMALL, (LPARAM) smallIcon);
-
-    if (window->win32.bigIcon)
-        DestroyIcon(window->win32.bigIcon);
-
-    if (window->win32.smallIcon)
-        DestroyIcon(window->win32.smallIcon);
-
-    if (count)
-    {
-        window->win32.bigIcon = bigIcon;
-        window->win32.smallIcon = smallIcon;
-    }
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    POINT pos = { 0, 0 };
-    ClientToScreen(window->win32.handle, &pos);
-
-    if (xpos)
-        *xpos = pos.x;
-    if (ypos)
-        *ypos = pos.y;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    RECT rect = { xpos, ypos, xpos, ypos };
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                 FALSE, getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-    {
-        AdjustWindowRectEx(&rect, getWindowStyle(window),
-                           FALSE, getWindowExStyle(window));
-    }
-
-    SetWindowPos(window->win32.handle, NULL, rect.left, rect.top, 0, 0,
-                 SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    RECT area;
-    GetClientRect(window->win32.handle, &area);
-
-    if (width)
-        *width = area.right;
-    if (height)
-        *height = area.bottom;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-        {
-            acquireMonitor(window);
-            fitToMonitor(window);
-        }
-    }
-    else
-    {
-        RECT rect = { 0, 0, width, height };
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                     FALSE, getWindowExStyle(window),
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-        {
-            AdjustWindowRectEx(&rect, getWindowStyle(window),
-                               FALSE, getWindowExStyle(window));
-        }
-
-        SetWindowPos(window->win32.handle, HWND_TOP,
-                     0, 0, rect.right - rect.left, rect.bottom - rect.top,
-                     SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
-    }
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    RECT area;
-
-    if ((minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE) &&
-        (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE))
-    {
-        return;
-    }
-
-    GetWindowRect(window->win32.handle, &area);
-    MoveWindow(window->win32.handle,
-               area.left, area.top,
-               area.right - area.left,
-               area.bottom - area.top, TRUE);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    RECT area;
-
-    if (numer == GLFW_DONT_CARE || denom == GLFW_DONT_CARE)
-        return;
-
-    GetWindowRect(window->win32.handle, &area);
-    applyAspectRatio(window, WMSZ_BOTTOMRIGHT, &area);
-    MoveWindow(window->win32.handle,
-               area.left, area.top,
-               area.right - area.left,
-               area.bottom - area.top, TRUE);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    RECT rect;
-    int width, height;
-
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    SetRect(&rect, 0, 0, width, height);
-
-    if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-    {
-        AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                 FALSE, getWindowExStyle(window),
-                                 GetDpiForWindow(window->win32.handle));
-    }
-    else
-    {
-        AdjustWindowRectEx(&rect, getWindowStyle(window),
-                           FALSE, getWindowExStyle(window));
-    }
-
-    if (left)
-        *left = -rect.left;
-    if (top)
-        *top = -rect.top;
-    if (right)
-        *right = rect.right - width;
-    if (bottom)
-        *bottom = rect.bottom - height;
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    const HANDLE handle = MonitorFromWindow(window->win32.handle,
-                                            MONITOR_DEFAULTTONEAREST);
-    _glfwGetMonitorContentScaleWin32(handle, xscale, yscale);
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_MINIMIZE);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_RESTORE);
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_MAXIMIZE);
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_SHOWNA);
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    ShowWindow(window->win32.handle, SW_HIDE);
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    FlashWindow(window->win32.handle, TRUE);
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    BringWindowToTop(window->win32.handle);
-    SetForegroundWindow(window->win32.handle);
-    SetFocus(window->win32.handle);
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-            {
-                acquireMonitor(window);
-                fitToMonitor(window);
-            }
-        }
-        else
-        {
-            RECT rect = { xpos, ypos, xpos + width, ypos + height };
-
-            if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-            {
-                AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                         FALSE, getWindowExStyle(window),
-                                         GetDpiForWindow(window->win32.handle));
-            }
-            else
-            {
-                AdjustWindowRectEx(&rect, getWindowStyle(window),
-                                   FALSE, getWindowExStyle(window));
-            }
-
-            SetWindowPos(window->win32.handle, HWND_TOP,
-                         rect.left, rect.top,
-                         rect.right - rect.left, rect.bottom - rect.top,
-                         SWP_NOCOPYBITS | SWP_NOACTIVATE | SWP_NOZORDER);
-        }
-
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-
-    if (window->monitor)
-    {
-        MONITORINFO mi = { sizeof(mi) };
-        UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
-
-        if (window->decorated)
-        {
-            DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-            style &= ~WS_OVERLAPPEDWINDOW;
-            style |= getWindowStyle(window);
-            SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-            flags |= SWP_FRAMECHANGED;
-        }
-
-        acquireMonitor(window);
-
-        GetMonitorInfo(window->monitor->win32.handle, &mi);
-        SetWindowPos(window->win32.handle, HWND_TOPMOST,
-                     mi.rcMonitor.left,
-                     mi.rcMonitor.top,
-                     mi.rcMonitor.right - mi.rcMonitor.left,
-                     mi.rcMonitor.bottom - mi.rcMonitor.top,
-                     flags);
-    }
-    else
-    {
-        HWND after;
-        RECT rect = { xpos, ypos, xpos + width, ypos + height };
-        DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
-        UINT flags = SWP_NOACTIVATE | SWP_NOCOPYBITS;
-
-        if (window->decorated)
-        {
-            style &= ~WS_POPUP;
-            style |= getWindowStyle(window);
-            SetWindowLongW(window->win32.handle, GWL_STYLE, style);
-
-            flags |= SWP_FRAMECHANGED;
-        }
-
-        if (window->floating)
-            after = HWND_TOPMOST;
-        else
-            after = HWND_NOTOPMOST;
-
-        if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
-        {
-            AdjustWindowRectExForDpi(&rect, getWindowStyle(window),
-                                     FALSE, getWindowExStyle(window),
-                                     GetDpiForWindow(window->win32.handle));
-        }
-        else
-        {
-            AdjustWindowRectEx(&rect, getWindowStyle(window),
-                               FALSE, getWindowExStyle(window));
-        }
-
-        SetWindowPos(window->win32.handle, after,
-                     rect.left, rect.top,
-                     rect.right - rect.left, rect.bottom - rect.top,
-                     flags);
-    }
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return window->win32.handle == GetActiveWindow();
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return IsIconic(window->win32.handle);
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return IsWindowVisible(window->win32.handle);
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return IsZoomed(window->win32.handle);
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return cursorInContentArea(window);
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    BOOL composition, opaque;
-    DWORD color;
-
-    if (!window->win32.transparent)
-        return GLFW_FALSE;
-
-    if (!IsWindowsVistaOrGreater())
-        return GLFW_FALSE;
-
-    if (FAILED(DwmIsCompositionEnabled(&composition)) || !composition)
-        return GLFW_FALSE;
-
-    if (!IsWindows8OrGreater())
-    {
-        // HACK: Disable framebuffer transparency on Windows 7 when the
-        //       colorization color is opaque, because otherwise the window
-        //       contents is blended additively with the previous frame instead
-        //       of replacing it
-        if (FAILED(DwmGetColorizationColor(&color, &opaque)) || opaque)
-            return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    updateWindowStyles(window);
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    updateWindowStyles(window);
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
-    SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
-                 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    COLORREF key = 0;
-    BYTE alpha = 0;
-    DWORD flags = 0;
-    DWORD exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
-
-    if (exStyle & WS_EX_LAYERED)
-        GetLayeredWindowAttributes(window->win32.handle, &key, &alpha, &flags);
-
-    if (enabled)
-        exStyle |= (WS_EX_TRANSPARENT | WS_EX_LAYERED);
-    else
-    {
-        exStyle &= ~WS_EX_TRANSPARENT;
-        // NOTE: Window opacity also needs the layered window style so do not
-        //       remove it if the window is alpha blended
-        if (exStyle & WS_EX_LAYERED)
-        {
-            if (!(flags & LWA_ALPHA))
-                exStyle &= ~WS_EX_LAYERED;
-        }
-    }
-
-    SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-
-    if (enabled)
-        SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    BYTE alpha;
-    DWORD flags;
-
-    if ((GetWindowLongW(window->win32.handle, GWL_EXSTYLE) & WS_EX_LAYERED) &&
-        GetLayeredWindowAttributes(window->win32.handle, NULL, &alpha, &flags))
-    {
-        if (flags & LWA_ALPHA)
-            return alpha / 255.f;
-    }
-
-    return 1.f;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
-    if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
-    {
-        const BYTE alpha = (BYTE) (255 * opacity);
-        exStyle |= WS_EX_LAYERED;
-        SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-        SetLayeredWindowAttributes(window->win32.handle, 0, alpha, LWA_ALPHA);
-    }
-    else if (exStyle & WS_EX_TRANSPARENT)
-    {
-        SetLayeredWindowAttributes(window->win32.handle, 0, 0, 0);
-    }
-    else
-    {
-        exStyle &= ~WS_EX_LAYERED;
-        SetWindowLongW(window->win32.handle, GWL_EXSTYLE, exStyle);
-    }
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    if (_glfw.win32.disabledCursorWindow != window)
-        return;
-
-    if (enabled)
-        enableRawMouseMotion(window);
-    else
-        disableRawMouseMotion(window);
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    MSG msg;
-    HWND handle;
-    _GLFWwindow* window;
-
-    while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
-    {
-        if (msg.message == WM_QUIT)
-        {
-            // NOTE: While GLFW does not itself post WM_QUIT, other processes
-            //       may post it to this one, for example Task Manager
-            // HACK: Treat WM_QUIT as a close on all windows
-
-            window = _glfw.windowListHead;
-            while (window)
-            {
-                _glfwInputWindowCloseRequest(window);
-                window = window->next;
-            }
-        }
-        else
-        {
-            TranslateMessage(&msg);
-            DispatchMessageW(&msg);
-        }
-    }
-
-    // HACK: Release modifier keys that the system did not emit KEYUP for
-    // NOTE: Shift keys on Windows tend to "stick" when both are pressed as
-    //       no key up message is generated by the first key release
-    // NOTE: Windows key is not reported as released by the Win+V hotkey
-    //       Other Win hotkeys are handled implicitly by _glfwInputWindowFocus
-    //       because they change the input focus
-    // NOTE: The other half of this is in the WM_*KEY* handler in windowProc
-    handle = GetActiveWindow();
-    if (handle)
-    {
-        window = GetPropW(handle, L"GLFW");
-        if (window)
-        {
-            int i;
-            const int keys[4][2] =
-            {
-                { VK_LSHIFT, GLFW_KEY_LEFT_SHIFT },
-                { VK_RSHIFT, GLFW_KEY_RIGHT_SHIFT },
-                { VK_LWIN, GLFW_KEY_LEFT_SUPER },
-                { VK_RWIN, GLFW_KEY_RIGHT_SUPER }
-            };
-
-            for (i = 0;  i < 4;  i++)
-            {
-                const int vk = keys[i][0];
-                const int key = keys[i][1];
-                const int scancode = _glfw.win32.scancodes[key];
-
-                if ((GetKeyState(vk) & 0x8000))
-                    continue;
-                if (window->keys[key] != GLFW_PRESS)
-                    continue;
-
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, getKeyMods());
-            }
-        }
-    }
-
-    window = _glfw.win32.disabledCursorWindow;
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetWindowSize(window, &width, &height);
-
-        // NOTE: Re-center the cursor only if it has moved since the last call,
-        //       to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
-        if (window->win32.lastCursorPosX != width / 2 ||
-            window->win32.lastCursorPosY != height / 2)
-        {
-            _glfwPlatformSetCursorPos(window, width / 2, height / 2);
-        }
-    }
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    WaitMessage();
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    POINT pos;
-
-    if (GetCursorPos(&pos))
-    {
-        ScreenToClient(window->win32.handle, &pos);
-
-        if (xpos)
-            *xpos = pos.x;
-        if (ypos)
-            *ypos = pos.y;
-    }
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
-{
-    POINT pos = { (int) xpos, (int) ypos };
-
-    // Store the new position so it can be recognized later
-    window->win32.lastCursorPosX = pos.x;
-    window->win32.lastCursorPosY = pos.y;
-
-    ClientToScreen(window->win32.handle, &pos);
-    SetCursorPos(pos.x, pos.y);
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    if (mode == GLFW_CURSOR_DISABLED)
-    {
-        if (_glfwPlatformWindowFocused(window))
-            disableCursor(window);
-    }
-    else if (_glfw.win32.disabledCursorWindow == window)
-        enableCursor(window);
-    else if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
-        _glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.win32.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
-    if (!cursor->win32.handle)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    int id = 0;
-
-    if (shape == GLFW_ARROW_CURSOR)
-        id = OCR_NORMAL;
-    else if (shape == GLFW_IBEAM_CURSOR)
-        id = OCR_IBEAM;
-    else if (shape == GLFW_CROSSHAIR_CURSOR)
-        id = OCR_CROSS;
-    else if (shape == GLFW_POINTING_HAND_CURSOR)
-        id = OCR_HAND;
-    else if (shape == GLFW_RESIZE_EW_CURSOR)
-        id = OCR_SIZEWE;
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        id = OCR_SIZENS;
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        id = OCR_SIZENWSE;
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        id = OCR_SIZENESW;
-    else if (shape == GLFW_RESIZE_ALL_CURSOR)
-        id = OCR_SIZEALL;
-    else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-        id = OCR_NO;
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
-        return GLFW_FALSE;
-    }
-
-    cursor->win32.handle = LoadImageW(NULL,
-                                      MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
-                                      LR_DEFAULTSIZE | LR_SHARED);
-    if (!cursor->win32.handle)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to create standard cursor");
-        return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    if (cursor->win32.handle)
-        DestroyIcon((HICON) cursor->win32.handle);
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    if (cursorInContentArea(window))
-        updateCursorImage(window);
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    int characterCount;
-    HANDLE object;
-    WCHAR* buffer;
-
-    characterCount = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0);
-    if (!characterCount)
-        return;
-
-    object = GlobalAlloc(GMEM_MOVEABLE, characterCount * sizeof(WCHAR));
-    if (!object)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to allocate global handle for clipboard");
-        return;
-    }
-
-    buffer = GlobalLock(object);
-    if (!buffer)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to lock global handle");
-        GlobalFree(object);
-        return;
-    }
-
-    MultiByteToWideChar(CP_UTF8, 0, string, -1, buffer, characterCount);
-    GlobalUnlock(object);
-
-    if (!OpenClipboard(_glfw.win32.helperWindowHandle))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to open clipboard");
-        GlobalFree(object);
-        return;
-    }
-
-    EmptyClipboard();
-    SetClipboardData(CF_UNICODETEXT, object);
-    CloseClipboard();
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    HANDLE object;
-    WCHAR* buffer;
-
-    if (!OpenClipboard(_glfw.win32.helperWindowHandle))
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to open clipboard");
-        return NULL;
-    }
-
-    object = GetClipboardData(CF_UNICODETEXT);
-    if (!object)
-    {
-        _glfwInputErrorWin32(GLFW_FORMAT_UNAVAILABLE,
-                             "Win32: Failed to convert clipboard to string");
-        CloseClipboard();
-        return NULL;
-    }
-
-    buffer = GlobalLock(object);
-    if (!buffer)
-    {
-        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
-                             "Win32: Failed to lock global handle");
-        CloseClipboard();
-        return NULL;
-    }
-
-    free(_glfw.win32.clipboardString);
-    _glfw.win32.clipboardString = _glfwCreateUTF8FromWideStringWin32(buffer);
-
-    GlobalUnlock(object);
-    CloseClipboard();
-
-    return _glfw.win32.clipboardString;
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-            else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGLES)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_d3d)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D9)
-                type = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE;
-            else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11)
-                type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_vulkan)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
-                type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(3, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return GetDC(_glfw.win32.helperWindowHandle);
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->win32.handle;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
-        return;
-
-    extensions[0] = "VK_KHR_surface";
-    extensions[1] = "VK_KHR_win32_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
-        vkGetPhysicalDeviceWin32PresentationSupportKHR =
-        (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)
-        vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWin32PresentationSupportKHR");
-    if (!vkGetPhysicalDeviceWin32PresentationSupportKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
-        return GLFW_FALSE;
-    }
-
-    return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    VkResult err;
-    VkWin32SurfaceCreateInfoKHR sci;
-    PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR;
-
-    vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)
-        vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR");
-    if (!vkCreateWin32SurfaceKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Win32: Vulkan instance missing VK_KHR_win32_surface extension");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    memset(&sci, 0, sizeof(sci));
-    sci.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
-    sci.hinstance = GetModuleHandle(NULL);
-    sci.hwnd = window->win32.handle;
-
-    err = vkCreateWin32SurfaceKHR(instance, &sci, allocator, surface);
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Win32: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->win32.handle;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/window.c b/raylib_pi4_test/external/glfw/src/window.c
deleted file mode 100644 (file)
index efcb412..0000000
+++ /dev/null
@@ -1,1122 +0,0 @@
-//========================================================================
-// GLFW 3.4 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// Please use C89 style variable declarations in this file because VS 2010
-//========================================================================
-
-#include "internal.h"
-
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <float.h>
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                         GLFW event API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-// Notifies shared code that a window has lost or received input focus
-//
-void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
-{
-    if (window->callbacks.focus)
-        window->callbacks.focus((GLFWwindow*) window, focused);
-
-    if (!focused)
-    {
-        int key, button;
-
-        for (key = 0;  key <= GLFW_KEY_LAST;  key++)
-        {
-            if (window->keys[key] == GLFW_PRESS)
-            {
-                const int scancode = _glfwPlatformGetKeyScancode(key);
-                _glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
-            }
-        }
-
-        for (button = 0;  button <= GLFW_MOUSE_BUTTON_LAST;  button++)
-        {
-            if (window->mouseButtons[button] == GLFW_PRESS)
-                _glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
-        }
-    }
-}
-
-// Notifies shared code that a window has moved
-// The position is specified in content area relative screen coordinates
-//
-void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
-{
-    if (window->callbacks.pos)
-        window->callbacks.pos((GLFWwindow*) window, x, y);
-}
-
-// Notifies shared code that a window has been resized
-// The size is specified in screen coordinates
-//
-void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->callbacks.size)
-        window->callbacks.size((GLFWwindow*) window, width, height);
-}
-
-// Notifies shared code that a window has been iconified or restored
-//
-void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
-{
-    if (window->callbacks.iconify)
-        window->callbacks.iconify((GLFWwindow*) window, iconified);
-}
-
-// Notifies shared code that a window has been maximized or restored
-//
-void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
-{
-    if (window->callbacks.maximize)
-        window->callbacks.maximize((GLFWwindow*) window, maximized);
-}
-
-// Notifies shared code that a window framebuffer has been resized
-// The size is specified in pixels
-//
-void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->callbacks.fbsize)
-        window->callbacks.fbsize((GLFWwindow*) window, width, height);
-}
-
-// Notifies shared code that a window content scale has changed
-// The scale is specified as the ratio between the current and default DPI
-//
-void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
-{
-    if (window->callbacks.scale)
-        window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
-}
-
-// Notifies shared code that the window contents needs updating
-//
-void _glfwInputWindowDamage(_GLFWwindow* window)
-{
-    if (window->callbacks.refresh)
-        window->callbacks.refresh((GLFWwindow*) window);
-}
-
-// Notifies shared code that the user wishes to close a window
-//
-void _glfwInputWindowCloseRequest(_GLFWwindow* window)
-{
-    window->shouldClose = GLFW_TRUE;
-
-    if (window->callbacks.close)
-        window->callbacks.close((GLFWwindow*) window);
-}
-
-// Notifies shared code that a window has changed its desired monitor
-//
-void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor)
-{
-    window->monitor = monitor;
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW public API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
-                                     const char* title,
-                                     GLFWmonitor* monitor,
-                                     GLFWwindow* share)
-{
-    _GLFWfbconfig fbconfig;
-    _GLFWctxconfig ctxconfig;
-    _GLFWwndconfig wndconfig;
-    _GLFWwindow* window;
-
-    assert(title != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-
-    if (width <= 0 || height <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid window size %ix%i",
-                        width, height);
-
-        return NULL;
-    }
-
-    fbconfig  = _glfw.hints.framebuffer;
-    ctxconfig = _glfw.hints.context;
-    wndconfig = _glfw.hints.window;
-
-    wndconfig.width   = width;
-    wndconfig.height  = height;
-    wndconfig.title   = title;
-    ctxconfig.share   = (_GLFWwindow*) share;
-
-    if (!_glfwIsValidContextConfig(&ctxconfig))
-        return NULL;
-
-    window = calloc(1, sizeof(_GLFWwindow));
-    window->next = _glfw.windowListHead;
-    _glfw.windowListHead = window;
-
-    window->videoMode.width       = width;
-    window->videoMode.height      = height;
-    window->videoMode.redBits     = fbconfig.redBits;
-    window->videoMode.greenBits   = fbconfig.greenBits;
-    window->videoMode.blueBits    = fbconfig.blueBits;
-    window->videoMode.refreshRate = _glfw.hints.refreshRate;
-
-    window->monitor          = (_GLFWmonitor*) monitor;
-    window->resizable        = wndconfig.resizable;
-    window->decorated        = wndconfig.decorated;
-    window->autoIconify      = wndconfig.autoIconify;
-    window->floating         = wndconfig.floating;
-    window->focusOnShow      = wndconfig.focusOnShow;
-    window->mousePassthrough = wndconfig.mousePassthrough;
-    window->cursorMode       = GLFW_CURSOR_NORMAL;
-
-    window->minwidth    = GLFW_DONT_CARE;
-    window->minheight   = GLFW_DONT_CARE;
-    window->maxwidth    = GLFW_DONT_CARE;
-    window->maxheight   = GLFW_DONT_CARE;
-    window->numer       = GLFW_DONT_CARE;
-    window->denom       = GLFW_DONT_CARE;
-
-    // Open the actual window and create its context
-    if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
-    {
-        glfwDestroyWindow((GLFWwindow*) window);
-        return NULL;
-    }
-
-    if (ctxconfig.client != GLFW_NO_API)
-    {
-        if (!_glfwRefreshContextAttribs(window, &ctxconfig))
-        {
-            glfwDestroyWindow((GLFWwindow*) window);
-            return NULL;
-        }
-    }
-
-    if (wndconfig.mousePassthrough)
-        _glfwPlatformSetWindowMousePassthrough(window, GLFW_TRUE);
-
-    if (window->monitor)
-    {
-        if (wndconfig.centerCursor)
-            _glfwCenterCursorInContentArea(window);
-    }
-    else
-    {
-        if (wndconfig.visible)
-        {
-            _glfwPlatformShowWindow(window);
-            if (wndconfig.focused)
-                _glfwPlatformFocusWindow(window);
-        }
-    }
-
-    return (GLFWwindow*) window;
-}
-
-void glfwDefaultWindowHints(void)
-{
-    _GLFW_REQUIRE_INIT();
-
-    // The default is OpenGL with minimum version 1.0
-    memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
-    _glfw.hints.context.client = GLFW_OPENGL_API;
-    _glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
-    _glfw.hints.context.major  = 1;
-    _glfw.hints.context.minor  = 0;
-
-    // The default is a focused, visible, resizable window with decorations
-    memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
-    _glfw.hints.window.resizable    = GLFW_TRUE;
-    _glfw.hints.window.visible      = GLFW_TRUE;
-    _glfw.hints.window.decorated    = GLFW_TRUE;
-    _glfw.hints.window.focused      = GLFW_TRUE;
-    _glfw.hints.window.autoIconify  = GLFW_TRUE;
-    _glfw.hints.window.centerCursor = GLFW_TRUE;
-    _glfw.hints.window.focusOnShow  = GLFW_TRUE;
-
-    // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
-    // double buffered
-    memset(&_glfw.hints.framebuffer, 0, sizeof(_glfw.hints.framebuffer));
-    _glfw.hints.framebuffer.redBits      = 8;
-    _glfw.hints.framebuffer.greenBits    = 8;
-    _glfw.hints.framebuffer.blueBits     = 8;
-    _glfw.hints.framebuffer.alphaBits    = 8;
-    _glfw.hints.framebuffer.depthBits    = 24;
-    _glfw.hints.framebuffer.stencilBits  = 8;
-    _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
-
-    // The default is to select the highest available refresh rate
-    _glfw.hints.refreshRate = GLFW_DONT_CARE;
-
-    // The default is to use full Retina resolution framebuffers
-    _glfw.hints.window.ns.retina = GLFW_TRUE;
-}
-
-GLFWAPI void glfwWindowHint(int hint, int value)
-{
-    _GLFW_REQUIRE_INIT();
-
-    switch (hint)
-    {
-        case GLFW_RED_BITS:
-            _glfw.hints.framebuffer.redBits = value;
-            return;
-        case GLFW_GREEN_BITS:
-            _glfw.hints.framebuffer.greenBits = value;
-            return;
-        case GLFW_BLUE_BITS:
-            _glfw.hints.framebuffer.blueBits = value;
-            return;
-        case GLFW_ALPHA_BITS:
-            _glfw.hints.framebuffer.alphaBits = value;
-            return;
-        case GLFW_DEPTH_BITS:
-            _glfw.hints.framebuffer.depthBits = value;
-            return;
-        case GLFW_STENCIL_BITS:
-            _glfw.hints.framebuffer.stencilBits = value;
-            return;
-        case GLFW_ACCUM_RED_BITS:
-            _glfw.hints.framebuffer.accumRedBits = value;
-            return;
-        case GLFW_ACCUM_GREEN_BITS:
-            _glfw.hints.framebuffer.accumGreenBits = value;
-            return;
-        case GLFW_ACCUM_BLUE_BITS:
-            _glfw.hints.framebuffer.accumBlueBits = value;
-            return;
-        case GLFW_ACCUM_ALPHA_BITS:
-            _glfw.hints.framebuffer.accumAlphaBits = value;
-            return;
-        case GLFW_AUX_BUFFERS:
-            _glfw.hints.framebuffer.auxBuffers = value;
-            return;
-        case GLFW_STEREO:
-            _glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_DOUBLEBUFFER:
-            _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_TRANSPARENT_FRAMEBUFFER:
-            _glfw.hints.framebuffer.transparent = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_SAMPLES:
-            _glfw.hints.framebuffer.samples = value;
-            return;
-        case GLFW_SRGB_CAPABLE:
-            _glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_RESIZABLE:
-            _glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_DECORATED:
-            _glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FOCUSED:
-            _glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_AUTO_ICONIFY:
-            _glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FLOATING:
-            _glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_MAXIMIZED:
-            _glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_VISIBLE:
-            _glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_COCOA_RETINA_FRAMEBUFFER:
-            _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_WIN32_KEYBOARD_MENU:
-            _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_COCOA_GRAPHICS_SWITCHING:
-            _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_SCALE_TO_MONITOR:
-            _glfw.hints.window.scaleToMonitor = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CENTER_CURSOR:
-            _glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_FOCUS_ON_SHOW:
-            _glfw.hints.window.focusOnShow = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_MOUSE_PASSTHROUGH:
-            _glfw.hints.window.mousePassthrough = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CLIENT_API:
-            _glfw.hints.context.client = value;
-            return;
-        case GLFW_CONTEXT_CREATION_API:
-            _glfw.hints.context.source = value;
-            return;
-        case GLFW_CONTEXT_VERSION_MAJOR:
-            _glfw.hints.context.major = value;
-            return;
-        case GLFW_CONTEXT_VERSION_MINOR:
-            _glfw.hints.context.minor = value;
-            return;
-        case GLFW_CONTEXT_ROBUSTNESS:
-            _glfw.hints.context.robustness = value;
-            return;
-        case GLFW_OPENGL_FORWARD_COMPAT:
-            _glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CONTEXT_DEBUG:
-            _glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_CONTEXT_NO_ERROR:
-            _glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE;
-            return;
-        case GLFW_OPENGL_PROFILE:
-            _glfw.hints.context.profile = value;
-            return;
-        case GLFW_CONTEXT_RELEASE_BEHAVIOR:
-            _glfw.hints.context.release = value;
-            return;
-        case GLFW_REFRESH_RATE:
-            _glfw.hints.refreshRate = value;
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
-}
-
-GLFWAPI void glfwWindowHintString(int hint, const char* value)
-{
-    assert(value != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    switch (hint)
-    {
-        case GLFW_COCOA_FRAME_NAME:
-            strncpy(_glfw.hints.window.ns.frameName, value,
-                    sizeof(_glfw.hints.window.ns.frameName) - 1);
-            return;
-        case GLFW_X11_CLASS_NAME:
-            strncpy(_glfw.hints.window.x11.className, value,
-                    sizeof(_glfw.hints.window.x11.className) - 1);
-            return;
-        case GLFW_X11_INSTANCE_NAME:
-            strncpy(_glfw.hints.window.x11.instanceName, value,
-                    sizeof(_glfw.hints.window.x11.instanceName) - 1);
-            return;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
-}
-
-GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-
-    _GLFW_REQUIRE_INIT();
-
-    // Allow closing of NULL (to match the behavior of free)
-    if (window == NULL)
-        return;
-
-    // Clear all callbacks to avoid exposing a half torn-down window object
-    memset(&window->callbacks, 0, sizeof(window->callbacks));
-
-    // The window's context must not be current on another thread when the
-    // window is destroyed
-    if (window == _glfwPlatformGetTls(&_glfw.contextSlot))
-        glfwMakeContextCurrent(NULL);
-
-    _glfwPlatformDestroyWindow(window);
-
-    // Unlink window from global linked list
-    {
-        _GLFWwindow** prev = &_glfw.windowListHead;
-
-        while (*prev != window)
-            prev = &((*prev)->next);
-
-        *prev = window->next;
-    }
-
-    free(window);
-}
-
-GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-    return window->shouldClose;
-}
-
-GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    window->shouldClose = value;
-}
-
-GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(title != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetWindowTitle(window, title);
-}
-
-GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
-                               int count, const GLFWimage* images)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(count >= 0);
-    assert(count == 0 || images != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformSetWindowIcon(window, count, images);
-}
-
-GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xpos)
-        *xpos = 0;
-    if (ypos)
-        *ypos = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformSetWindowPos(window, xpos, ypos);
-}
-
-GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    window->videoMode.width  = width;
-    window->videoMode.height = height;
-
-    _glfwPlatformSetWindowSize(window, width, height);
-}
-
-GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
-                                     int minwidth, int minheight,
-                                     int maxwidth, int maxheight)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
-    {
-        if (minwidth < 0 || minheight < 0)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window minimum size %ix%i",
-                            minwidth, minheight);
-            return;
-        }
-    }
-
-    if (maxwidth != GLFW_DONT_CARE && maxheight != GLFW_DONT_CARE)
-    {
-        if (maxwidth < 0 || maxheight < 0 ||
-            maxwidth < minwidth || maxheight < minheight)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window maximum size %ix%i",
-                            maxwidth, maxheight);
-            return;
-        }
-    }
-
-    window->minwidth  = minwidth;
-    window->minheight = minheight;
-    window->maxwidth  = maxwidth;
-    window->maxheight = maxheight;
-
-    if (window->monitor || !window->resizable)
-        return;
-
-    _glfwPlatformSetWindowSizeLimits(window,
-                                     minwidth, minheight,
-                                     maxwidth, maxheight);
-}
-
-GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(numer != 0);
-    assert(denom != 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
-    {
-        if (numer <= 0 || denom <= 0)
-        {
-            _glfwInputError(GLFW_INVALID_VALUE,
-                            "Invalid window aspect ratio %i:%i",
-                            numer, denom);
-            return;
-        }
-    }
-
-    window->numer = numer;
-    window->denom = denom;
-
-    if (window->monitor || !window->resizable)
-        return;
-
-    _glfwPlatformSetWindowAspectRatio(window, numer, denom);
-}
-
-GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (width)
-        *width = 0;
-    if (height)
-        *height = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetFramebufferSize(window, width, height);
-}
-
-GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
-                                    int* left, int* top,
-                                    int* right, int* bottom)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (left)
-        *left = 0;
-    if (top)
-        *top = 0;
-    if (right)
-        *right = 0;
-    if (bottom)
-        *bottom = 0;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
-}
-
-GLFWAPI void glfwGetWindowContentScale(GLFWwindow* handle,
-                                       float* xscale, float* yscale)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    if (xscale)
-        *xscale = 0.f;
-    if (yscale)
-        *yscale = 0.f;
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformGetWindowContentScale(window, xscale, yscale);
-}
-
-GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(1.f);
-    return _glfwPlatformGetWindowOpacity(window);
-}
-
-GLFWAPI void glfwSetWindowOpacity(GLFWwindow* handle, float opacity)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-    assert(opacity == opacity);
-    assert(opacity >= 0.f);
-    assert(opacity <= 1.f);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (opacity != opacity || opacity < 0.f || opacity > 1.f)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid window opacity %f", opacity);
-        return;
-    }
-
-    _glfwPlatformSetWindowOpacity(window, opacity);
-}
-
-GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformIconifyWindow(window);
-}
-
-GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformRestoreWindow(window);
-}
-
-GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformMaximizeWindow(window);
-}
-
-GLFWAPI void glfwShowWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformShowWindow(window);
-
-    if (window->focusOnShow)
-        _glfwPlatformFocusWindow(window);
-}
-
-GLFWAPI void glfwRequestWindowAttention(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformRequestWindowAttention(window);
-}
-
-GLFWAPI void glfwHideWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (window->monitor)
-        return;
-
-    _glfwPlatformHideWindow(window);
-}
-
-GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    _glfwPlatformFocusWindow(window);
-}
-
-GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(0);
-
-    switch (attrib)
-    {
-        case GLFW_FOCUSED:
-            return _glfwPlatformWindowFocused(window);
-        case GLFW_ICONIFIED:
-            return _glfwPlatformWindowIconified(window);
-        case GLFW_VISIBLE:
-            return _glfwPlatformWindowVisible(window);
-        case GLFW_MAXIMIZED:
-            return _glfwPlatformWindowMaximized(window);
-        case GLFW_HOVERED:
-            return _glfwPlatformWindowHovered(window);
-        case GLFW_FOCUS_ON_SHOW:
-            return window->focusOnShow;
-        case GLFW_MOUSE_PASSTHROUGH:
-            return window->mousePassthrough;
-        case GLFW_TRANSPARENT_FRAMEBUFFER:
-            return _glfwPlatformFramebufferTransparent(window);
-        case GLFW_RESIZABLE:
-            return window->resizable;
-        case GLFW_DECORATED:
-            return window->decorated;
-        case GLFW_FLOATING:
-            return window->floating;
-        case GLFW_AUTO_ICONIFY:
-            return window->autoIconify;
-        case GLFW_CLIENT_API:
-            return window->context.client;
-        case GLFW_CONTEXT_CREATION_API:
-            return window->context.source;
-        case GLFW_CONTEXT_VERSION_MAJOR:
-            return window->context.major;
-        case GLFW_CONTEXT_VERSION_MINOR:
-            return window->context.minor;
-        case GLFW_CONTEXT_REVISION:
-            return window->context.revision;
-        case GLFW_CONTEXT_ROBUSTNESS:
-            return window->context.robustness;
-        case GLFW_OPENGL_FORWARD_COMPAT:
-            return window->context.forward;
-        case GLFW_CONTEXT_DEBUG:
-            return window->context.debug;
-        case GLFW_OPENGL_PROFILE:
-            return window->context.profile;
-        case GLFW_CONTEXT_RELEASE_BEHAVIOR:
-            return window->context.release;
-        case GLFW_CONTEXT_NO_ERROR:
-            return window->context.noerror;
-    }
-
-    _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
-    return 0;
-}
-
-GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-
-    value = value ? GLFW_TRUE : GLFW_FALSE;
-
-    if (attrib == GLFW_AUTO_ICONIFY)
-        window->autoIconify = value;
-    else if (attrib == GLFW_RESIZABLE)
-    {
-        if (window->resizable == value)
-            return;
-
-        window->resizable = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowResizable(window, value);
-    }
-    else if (attrib == GLFW_DECORATED)
-    {
-        if (window->decorated == value)
-            return;
-
-        window->decorated = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowDecorated(window, value);
-    }
-    else if (attrib == GLFW_FLOATING)
-    {
-        if (window->floating == value)
-            return;
-
-        window->floating = value;
-        if (!window->monitor)
-            _glfwPlatformSetWindowFloating(window, value);
-    }
-    else if (attrib == GLFW_FOCUS_ON_SHOW)
-        window->focusOnShow = value;
-    else if (attrib == GLFW_MOUSE_PASSTHROUGH)
-    {
-        if (window->mousePassthrough == value)
-            return;
-
-        window->mousePassthrough = value;
-        _glfwPlatformSetWindowMousePassthrough(window, value);
-    }
-    else
-        _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute 0x%08X", attrib);
-}
-
-GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return (GLFWmonitor*) window->monitor;
-}
-
-GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
-                                  GLFWmonitor* mh,
-                                  int xpos, int ypos,
-                                  int width, int height,
-                                  int refreshRate)
-{
-    _GLFWwindow* window = (_GLFWwindow*) wh;
-    _GLFWmonitor* monitor = (_GLFWmonitor*) mh;
-    assert(window != NULL);
-    assert(width >= 0);
-    assert(height >= 0);
-
-    _GLFW_REQUIRE_INIT();
-
-    if (width <= 0 || height <= 0)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid window size %ix%i",
-                        width, height);
-        return;
-    }
-
-    if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE,
-                        "Invalid refresh rate %i",
-                        refreshRate);
-        return;
-    }
-
-    window->videoMode.width       = width;
-    window->videoMode.height      = height;
-    window->videoMode.refreshRate = refreshRate;
-
-    _glfwPlatformSetWindowMonitor(window, monitor,
-                                  xpos, ypos, width, height,
-                                  refreshRate);
-}
-
-GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT();
-    window->userPointer = pointer;
-}
-
-GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->userPointer;
-}
-
-GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
-                                                  GLFWwindowposfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
-                                                    GLFWwindowsizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
-                                                      GLFWwindowclosefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
-                                                          GLFWwindowrefreshfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
-                                                      GLFWwindowfocusfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
-                                                          GLFWwindowiconifyfun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
-                                                            GLFWwindowmaximizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
-                                                              GLFWframebuffersizefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
-    return cbfun;
-}
-
-GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
-                                                                    GLFWwindowcontentscalefun cbfun)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    assert(window != NULL);
-
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    _GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
-    return cbfun;
-}
-
-GLFWAPI void glfwPollEvents(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformPollEvents();
-}
-
-GLFWAPI void glfwWaitEvents(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformWaitEvents();
-}
-
-GLFWAPI void glfwWaitEventsTimeout(double timeout)
-{
-    _GLFW_REQUIRE_INIT();
-    assert(timeout == timeout);
-    assert(timeout >= 0.0);
-    assert(timeout <= DBL_MAX);
-
-    if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
-        return;
-    }
-
-    _glfwPlatformWaitEventsTimeout(timeout);
-}
-
-GLFWAPI void glfwPostEmptyEvent(void)
-{
-    _GLFW_REQUIRE_INIT();
-    _glfwPlatformPostEmptyEvent();
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/wl_init.c b/raylib_pi4_test/external/glfw/src/wl_init.c
deleted file mode 100644 (file)
index d3e777d..0000000
+++ /dev/null
@@ -1,1323 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _POSIX_C_SOURCE 199309L
-
-#include "internal.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <limits.h>
-#include <linux/input.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/timerfd.h>
-#include <unistd.h>
-#include <time.h>
-#include <wayland-client.h>
-
-
-static inline int min(int n1, int n2)
-{
-    return n1 < n2 ? n1 : n2;
-}
-
-static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
-                                                    int* which)
-{
-    int focus;
-    _GLFWwindow* window = _glfw.windowListHead;
-    if (!which)
-        which = &focus;
-    while (window)
-    {
-        if (surface == window->wl.decorations.top.surface)
-        {
-            *which = topDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.left.surface)
-        {
-            *which = leftDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.right.surface)
-        {
-            *which = rightDecoration;
-            break;
-        }
-        if (surface == window->wl.decorations.bottom.surface)
-        {
-            *which = bottomDecoration;
-            break;
-        }
-        window = window->next;
-    }
-    return window;
-}
-
-static void pointerHandleEnter(void* data,
-                               struct wl_pointer* pointer,
-                               uint32_t serial,
-                               struct wl_surface* surface,
-                               wl_fixed_t sx,
-                               wl_fixed_t sy)
-{
-    // Happens in the case we just destroyed the surface.
-    if (!surface)
-        return;
-
-    int focus = 0;
-    _GLFWwindow* window = wl_surface_get_user_data(surface);
-    if (!window)
-    {
-        window = findWindowFromDecorationSurface(surface, &focus);
-        if (!window)
-            return;
-    }
-
-    window->wl.decorations.focus = focus;
-    _glfw.wl.serial = serial;
-    _glfw.wl.pointerFocus = window;
-
-    window->wl.hovered = GLFW_TRUE;
-
-    _glfwPlatformSetCursor(window, window->wl.currentCursor);
-    _glfwInputCursorEnter(window, GLFW_TRUE);
-}
-
-static void pointerHandleLeave(void* data,
-                               struct wl_pointer* pointer,
-                               uint32_t serial,
-                               struct wl_surface* surface)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-
-    if (!window)
-        return;
-
-    window->wl.hovered = GLFW_FALSE;
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.pointerFocus = NULL;
-    _glfwInputCursorEnter(window, GLFW_FALSE);
-    _glfw.wl.cursorPreviousName = NULL;
-}
-
-static void setCursor(_GLFWwindow* window, const char* name)
-{
-    struct wl_buffer* buffer;
-    struct wl_cursor* cursor;
-    struct wl_cursor_image* image;
-    struct wl_surface* surface = _glfw.wl.cursorSurface;
-    struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
-    int scale = 1;
-
-    if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI)
-    {
-        // We only support up to scale=2 for now, since libwayland-cursor
-        // requires us to load a different theme for each size.
-        scale = 2;
-        theme = _glfw.wl.cursorThemeHiDPI;
-    }
-
-    cursor = wl_cursor_theme_get_cursor(theme, name);
-    if (!cursor)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Standard cursor not found");
-        return;
-    }
-    // TODO: handle animated cursors too.
-    image = cursor->images[0];
-
-    if (!image)
-        return;
-
-    buffer = wl_cursor_image_get_buffer(image);
-    if (!buffer)
-        return;
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          surface,
-                          image->hotspot_x / scale,
-                          image->hotspot_y / scale);
-    wl_surface_set_buffer_scale(surface, scale);
-    wl_surface_attach(surface, buffer, 0, 0);
-    wl_surface_damage(surface, 0, 0,
-                      image->width, image->height);
-    wl_surface_commit(surface);
-    _glfw.wl.cursorPreviousName = name;
-}
-
-static void pointerHandleMotion(void* data,
-                                struct wl_pointer* pointer,
-                                uint32_t time,
-                                wl_fixed_t sx,
-                                wl_fixed_t sy)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    const char* cursorName = NULL;
-    double x, y;
-
-    if (!window)
-        return;
-
-    if (window->cursorMode == GLFW_CURSOR_DISABLED)
-        return;
-    x = wl_fixed_to_double(sx);
-    y = wl_fixed_to_double(sy);
-
-    switch (window->wl.decorations.focus)
-    {
-        case mainWindow:
-            window->wl.cursorPosX = x;
-            window->wl.cursorPosY = y;
-            _glfwInputCursorPos(window, x, y);
-            _glfw.wl.cursorPreviousName = NULL;
-            return;
-        case topDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "n-resize";
-            else
-                cursorName = "left_ptr";
-            break;
-        case leftDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "nw-resize";
-            else
-                cursorName = "w-resize";
-            break;
-        case rightDecoration:
-            if (y < _GLFW_DECORATION_WIDTH)
-                cursorName = "ne-resize";
-            else
-                cursorName = "e-resize";
-            break;
-        case bottomDecoration:
-            if (x < _GLFW_DECORATION_WIDTH)
-                cursorName = "sw-resize";
-            else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
-                cursorName = "se-resize";
-            else
-                cursorName = "s-resize";
-            break;
-        default:
-            assert(0);
-    }
-    if (_glfw.wl.cursorPreviousName != cursorName)
-        setCursor(window, cursorName);
-}
-
-static void pointerHandleButton(void* data,
-                                struct wl_pointer* pointer,
-                                uint32_t serial,
-                                uint32_t time,
-                                uint32_t button,
-                                uint32_t state)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    int glfwButton;
-    uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
-
-    if (!window)
-        return;
-    if (button == BTN_LEFT)
-    {
-        switch (window->wl.decorations.focus)
-        {
-            case mainWindow:
-                break;
-            case topDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
-                else
-                {
-                    xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
-                }
-                break;
-            case leftDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
-                break;
-            case rightDecoration:
-                if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
-                break;
-            case bottomDecoration:
-                if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
-                else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
-                else
-                    edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
-                break;
-            default:
-                assert(0);
-        }
-        if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
-        {
-            xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
-                                serial, edges);
-        }
-    }
-    else if (button == BTN_RIGHT)
-    {
-        if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
-        {
-            xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
-                                          _glfw.wl.seat, serial,
-                                          window->wl.cursorPosX,
-                                          window->wl.cursorPosY);
-            return;
-        }
-    }
-
-    // Don’t pass the button to the user if it was related to a decoration.
-    if (window->wl.decorations.focus != mainWindow)
-        return;
-
-    _glfw.wl.serial = serial;
-
-    /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
-     * codes. */
-    glfwButton = button - BTN_LEFT;
-
-    _glfwInputMouseClick(window,
-                         glfwButton,
-                         state == WL_POINTER_BUTTON_STATE_PRESSED
-                                ? GLFW_PRESS
-                                : GLFW_RELEASE,
-                         _glfw.wl.xkb.modifiers);
-}
-
-static void pointerHandleAxis(void* data,
-                              struct wl_pointer* pointer,
-                              uint32_t time,
-                              uint32_t axis,
-                              wl_fixed_t value)
-{
-    _GLFWwindow* window = _glfw.wl.pointerFocus;
-    double x = 0.0, y = 0.0;
-    // Wayland scroll events are in pointer motion coordinate space (think two
-    // finger scroll).  The factor 10 is commonly used to convert to "scroll
-    // step means 1.0.
-    const double scrollFactor = 1.0 / 10.0;
-
-    if (!window)
-        return;
-
-    assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
-           axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
-
-    if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
-        x = -wl_fixed_to_double(value) * scrollFactor;
-    else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
-        y = -wl_fixed_to_double(value) * scrollFactor;
-
-    _glfwInputScroll(window, x, y);
-}
-
-static const struct wl_pointer_listener pointerListener = {
-    pointerHandleEnter,
-    pointerHandleLeave,
-    pointerHandleMotion,
-    pointerHandleButton,
-    pointerHandleAxis,
-};
-
-static void keyboardHandleKeymap(void* data,
-                                 struct wl_keyboard* keyboard,
-                                 uint32_t format,
-                                 int fd,
-                                 uint32_t size)
-{
-    struct xkb_keymap* keymap;
-    struct xkb_state* state;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    struct xkb_compose_table* composeTable;
-    struct xkb_compose_state* composeState;
-#endif
-
-    char* mapStr;
-    const char* locale;
-
-    if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
-    {
-        close(fd);
-        return;
-    }
-
-    mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
-    if (mapStr == MAP_FAILED) {
-        close(fd);
-        return;
-    }
-
-    keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
-                                        mapStr,
-                                        XKB_KEYMAP_FORMAT_TEXT_V1,
-                                        0);
-    munmap(mapStr, size);
-    close(fd);
-
-    if (!keymap)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to compile keymap");
-        return;
-    }
-
-    state = xkb_state_new(keymap);
-    if (!state)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create XKB state");
-        xkb_keymap_unref(keymap);
-        return;
-    }
-
-    // Look up the preferred locale, falling back to "C" as default.
-    locale = getenv("LC_ALL");
-    if (!locale)
-        locale = getenv("LC_CTYPE");
-    if (!locale)
-        locale = getenv("LANG");
-    if (!locale)
-        locale = "C";
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    composeTable =
-        xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
-                                          XKB_COMPOSE_COMPILE_NO_FLAGS);
-    if (composeTable)
-    {
-        composeState =
-            xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
-        xkb_compose_table_unref(composeTable);
-        if (composeState)
-            _glfw.wl.xkb.composeState = composeState;
-        else
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Failed to create XKB compose state");
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create XKB compose table");
-    }
-#endif
-
-    xkb_keymap_unref(_glfw.wl.xkb.keymap);
-    xkb_state_unref(_glfw.wl.xkb.state);
-    _glfw.wl.xkb.keymap = keymap;
-    _glfw.wl.xkb.state = state;
-
-    _glfw.wl.xkb.controlMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
-    _glfw.wl.xkb.altMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
-    _glfw.wl.xkb.shiftMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
-    _glfw.wl.xkb.superMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
-    _glfw.wl.xkb.capsLockMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
-    _glfw.wl.xkb.numLockMask =
-        1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
-}
-
-static void keyboardHandleEnter(void* data,
-                                struct wl_keyboard* keyboard,
-                                uint32_t serial,
-                                struct wl_surface* surface,
-                                struct wl_array* keys)
-{
-    // Happens in the case we just destroyed the surface.
-    if (!surface)
-        return;
-
-    _GLFWwindow* window = wl_surface_get_user_data(surface);
-    if (!window)
-    {
-        window = findWindowFromDecorationSurface(surface, NULL);
-        if (!window)
-            return;
-    }
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.keyboardFocus = window;
-    _glfwInputWindowFocus(window, GLFW_TRUE);
-}
-
-static void keyboardHandleLeave(void* data,
-                                struct wl_keyboard* keyboard,
-                                uint32_t serial,
-                                struct wl_surface* surface)
-{
-    _GLFWwindow* window = _glfw.wl.keyboardFocus;
-
-    if (!window)
-        return;
-
-    _glfw.wl.serial = serial;
-    _glfw.wl.keyboardFocus = NULL;
-    _glfwInputWindowFocus(window, GLFW_FALSE);
-}
-
-static int toGLFWKeyCode(uint32_t key)
-{
-    if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
-        return _glfw.wl.keycodes[key];
-
-    return GLFW_KEY_UNKNOWN;
-}
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
-{
-    if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
-        return sym;
-    if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
-            != XKB_COMPOSE_FEED_ACCEPTED)
-        return sym;
-    switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
-    {
-        case XKB_COMPOSE_COMPOSED:
-            return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
-        case XKB_COMPOSE_COMPOSING:
-        case XKB_COMPOSE_CANCELLED:
-            return XKB_KEY_NoSymbol;
-        case XKB_COMPOSE_NOTHING:
-        default:
-            return sym;
-    }
-}
-#endif
-
-static GLFWbool inputChar(_GLFWwindow* window, uint32_t key)
-{
-    uint32_t code, numSyms;
-    long cp;
-    const xkb_keysym_t *syms;
-    xkb_keysym_t sym;
-
-    code = key + 8;
-    numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
-
-    if (numSyms == 1)
-    {
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        sym = composeSymbol(syms[0]);
-#else
-        sym = syms[0];
-#endif
-        cp = _glfwKeySym2Unicode(sym);
-        if (cp != -1)
-        {
-            const int mods = _glfw.wl.xkb.modifiers;
-            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
-            _glfwInputChar(window, cp, mods, plain);
-        }
-    }
-
-    return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
-}
-
-static void keyboardHandleKey(void* data,
-                              struct wl_keyboard* keyboard,
-                              uint32_t serial,
-                              uint32_t time,
-                              uint32_t key,
-                              uint32_t state)
-{
-    int keyCode;
-    int action;
-    _GLFWwindow* window = _glfw.wl.keyboardFocus;
-    GLFWbool shouldRepeat;
-    struct itimerspec timer = {};
-
-    if (!window)
-        return;
-
-    keyCode = toGLFWKeyCode(key);
-    action = state == WL_KEYBOARD_KEY_STATE_PRESSED
-            ? GLFW_PRESS : GLFW_RELEASE;
-
-    _glfw.wl.serial = serial;
-    _glfwInputKey(window, keyCode, key, action,
-                  _glfw.wl.xkb.modifiers);
-
-    if (action == GLFW_PRESS)
-    {
-        shouldRepeat = inputChar(window, key);
-
-        if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
-        {
-            _glfw.wl.keyboardLastKey = keyCode;
-            _glfw.wl.keyboardLastScancode = key;
-            if (_glfw.wl.keyboardRepeatRate > 1)
-                timer.it_interval.tv_nsec = 1000000000 / _glfw.wl.keyboardRepeatRate;
-            else
-                timer.it_interval.tv_sec = 1;
-            timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
-            timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
-        }
-    }
-    timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
-}
-
-static void keyboardHandleModifiers(void* data,
-                                    struct wl_keyboard* keyboard,
-                                    uint32_t serial,
-                                    uint32_t modsDepressed,
-                                    uint32_t modsLatched,
-                                    uint32_t modsLocked,
-                                    uint32_t group)
-{
-    xkb_mod_mask_t mask;
-    unsigned int modifiers = 0;
-
-    _glfw.wl.serial = serial;
-
-    if (!_glfw.wl.xkb.keymap)
-        return;
-
-    xkb_state_update_mask(_glfw.wl.xkb.state,
-                          modsDepressed,
-                          modsLatched,
-                          modsLocked,
-                          0,
-                          0,
-                          group);
-
-    mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
-                                    XKB_STATE_MODS_DEPRESSED |
-                                    XKB_STATE_LAYOUT_DEPRESSED |
-                                    XKB_STATE_MODS_LATCHED |
-                                    XKB_STATE_LAYOUT_LATCHED);
-    if (mask & _glfw.wl.xkb.controlMask)
-        modifiers |= GLFW_MOD_CONTROL;
-    if (mask & _glfw.wl.xkb.altMask)
-        modifiers |= GLFW_MOD_ALT;
-    if (mask & _glfw.wl.xkb.shiftMask)
-        modifiers |= GLFW_MOD_SHIFT;
-    if (mask & _glfw.wl.xkb.superMask)
-        modifiers |= GLFW_MOD_SUPER;
-    if (mask & _glfw.wl.xkb.capsLockMask)
-        modifiers |= GLFW_MOD_CAPS_LOCK;
-    if (mask & _glfw.wl.xkb.numLockMask)
-        modifiers |= GLFW_MOD_NUM_LOCK;
-    _glfw.wl.xkb.modifiers = modifiers;
-}
-
-#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
-static void keyboardHandleRepeatInfo(void* data,
-                                     struct wl_keyboard* keyboard,
-                                     int32_t rate,
-                                     int32_t delay)
-{
-    if (keyboard != _glfw.wl.keyboard)
-        return;
-
-    _glfw.wl.keyboardRepeatRate = rate;
-    _glfw.wl.keyboardRepeatDelay = delay;
-}
-#endif
-
-static const struct wl_keyboard_listener keyboardListener = {
-    keyboardHandleKeymap,
-    keyboardHandleEnter,
-    keyboardHandleLeave,
-    keyboardHandleKey,
-    keyboardHandleModifiers,
-#ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
-    keyboardHandleRepeatInfo,
-#endif
-};
-
-static void seatHandleCapabilities(void* data,
-                                   struct wl_seat* seat,
-                                   enum wl_seat_capability caps)
-{
-    if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
-    {
-        _glfw.wl.pointer = wl_seat_get_pointer(seat);
-        wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
-    }
-    else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
-    {
-        wl_pointer_destroy(_glfw.wl.pointer);
-        _glfw.wl.pointer = NULL;
-    }
-
-    if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
-    {
-        _glfw.wl.keyboard = wl_seat_get_keyboard(seat);
-        wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
-    }
-    else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
-    {
-        wl_keyboard_destroy(_glfw.wl.keyboard);
-        _glfw.wl.keyboard = NULL;
-    }
-}
-
-static void seatHandleName(void* data,
-                           struct wl_seat* seat,
-                           const char* name)
-{
-}
-
-static const struct wl_seat_listener seatListener = {
-    seatHandleCapabilities,
-    seatHandleName,
-};
-
-static void dataOfferHandleOffer(void* data,
-                                 struct wl_data_offer* dataOffer,
-                                 const char* mimeType)
-{
-}
-
-static const struct wl_data_offer_listener dataOfferListener = {
-    dataOfferHandleOffer,
-};
-
-static void dataDeviceHandleDataOffer(void* data,
-                                      struct wl_data_device* dataDevice,
-                                      struct wl_data_offer* id)
-{
-    if (_glfw.wl.dataOffer)
-        wl_data_offer_destroy(_glfw.wl.dataOffer);
-
-    _glfw.wl.dataOffer = id;
-    wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL);
-}
-
-static void dataDeviceHandleEnter(void* data,
-                                  struct wl_data_device* dataDevice,
-                                  uint32_t serial,
-                                  struct wl_surface *surface,
-                                  wl_fixed_t x,
-                                  wl_fixed_t y,
-                                  struct wl_data_offer *id)
-{
-}
-
-static void dataDeviceHandleLeave(void* data,
-                                  struct wl_data_device* dataDevice)
-{
-}
-
-static void dataDeviceHandleMotion(void* data,
-                                   struct wl_data_device* dataDevice,
-                                   uint32_t time,
-                                   wl_fixed_t x,
-                                   wl_fixed_t y)
-{
-}
-
-static void dataDeviceHandleDrop(void* data,
-                                 struct wl_data_device* dataDevice)
-{
-}
-
-static void dataDeviceHandleSelection(void* data,
-                                      struct wl_data_device* dataDevice,
-                                      struct wl_data_offer* id)
-{
-}
-
-static const struct wl_data_device_listener dataDeviceListener = {
-    dataDeviceHandleDataOffer,
-    dataDeviceHandleEnter,
-    dataDeviceHandleLeave,
-    dataDeviceHandleMotion,
-    dataDeviceHandleDrop,
-    dataDeviceHandleSelection,
-};
-
-static void wmBaseHandlePing(void* data,
-                             struct xdg_wm_base* wmBase,
-                             uint32_t serial)
-{
-    xdg_wm_base_pong(wmBase, serial);
-}
-
-static const struct xdg_wm_base_listener wmBaseListener = {
-    wmBaseHandlePing
-};
-
-static void registryHandleGlobal(void* data,
-                                 struct wl_registry* registry,
-                                 uint32_t name,
-                                 const char* interface,
-                                 uint32_t version)
-{
-    if (strcmp(interface, "wl_compositor") == 0)
-    {
-        _glfw.wl.compositorVersion = min(3, version);
-        _glfw.wl.compositor =
-            wl_registry_bind(registry, name, &wl_compositor_interface,
-                             _glfw.wl.compositorVersion);
-    }
-    else if (strcmp(interface, "wl_subcompositor") == 0)
-    {
-        _glfw.wl.subcompositor =
-            wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
-    }
-    else if (strcmp(interface, "wl_shm") == 0)
-    {
-        _glfw.wl.shm =
-            wl_registry_bind(registry, name, &wl_shm_interface, 1);
-    }
-    else if (strcmp(interface, "wl_output") == 0)
-    {
-        _glfwAddOutputWayland(name, version);
-    }
-    else if (strcmp(interface, "wl_seat") == 0)
-    {
-        if (!_glfw.wl.seat)
-        {
-            _glfw.wl.seatVersion = min(4, version);
-            _glfw.wl.seat =
-                wl_registry_bind(registry, name, &wl_seat_interface,
-                                 _glfw.wl.seatVersion);
-            wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);
-        }
-    }
-    else if (strcmp(interface, "wl_data_device_manager") == 0)
-    {
-        if (!_glfw.wl.dataDeviceManager)
-        {
-            _glfw.wl.dataDeviceManager =
-                wl_registry_bind(registry, name,
-                                 &wl_data_device_manager_interface, 1);
-        }
-    }
-    else if (strcmp(interface, "xdg_wm_base") == 0)
-    {
-        _glfw.wl.wmBase =
-            wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
-        xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
-    }
-    else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
-    {
-        _glfw.wl.decorationManager =
-            wl_registry_bind(registry, name,
-                             &zxdg_decoration_manager_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "wp_viewporter") == 0)
-    {
-        _glfw.wl.viewporter =
-            wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
-    }
-    else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
-    {
-        _glfw.wl.relativePointerManager =
-            wl_registry_bind(registry, name,
-                             &zwp_relative_pointer_manager_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
-    {
-        _glfw.wl.pointerConstraints =
-            wl_registry_bind(registry, name,
-                             &zwp_pointer_constraints_v1_interface,
-                             1);
-    }
-    else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
-    {
-        _glfw.wl.idleInhibitManager =
-            wl_registry_bind(registry, name,
-                             &zwp_idle_inhibit_manager_v1_interface,
-                             1);
-    }
-}
-
-static void registryHandleGlobalRemove(void *data,
-                                       struct wl_registry *registry,
-                                       uint32_t name)
-{
-    int i;
-    _GLFWmonitor* monitor;
-
-    for (i = 0; i < _glfw.monitorCount; ++i)
-    {
-        monitor = _glfw.monitors[i];
-        if (monitor->wl.name == name)
-        {
-            _glfwInputMonitor(monitor, GLFW_DISCONNECTED, 0);
-            return;
-        }
-    }
-}
-
-
-static const struct wl_registry_listener registryListener = {
-    registryHandleGlobal,
-    registryHandleGlobalRemove
-};
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode;
-
-    memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
-    memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
-
-    _glfw.wl.keycodes[KEY_GRAVE]      = GLFW_KEY_GRAVE_ACCENT;
-    _glfw.wl.keycodes[KEY_1]          = GLFW_KEY_1;
-    _glfw.wl.keycodes[KEY_2]          = GLFW_KEY_2;
-    _glfw.wl.keycodes[KEY_3]          = GLFW_KEY_3;
-    _glfw.wl.keycodes[KEY_4]          = GLFW_KEY_4;
-    _glfw.wl.keycodes[KEY_5]          = GLFW_KEY_5;
-    _glfw.wl.keycodes[KEY_6]          = GLFW_KEY_6;
-    _glfw.wl.keycodes[KEY_7]          = GLFW_KEY_7;
-    _glfw.wl.keycodes[KEY_8]          = GLFW_KEY_8;
-    _glfw.wl.keycodes[KEY_9]          = GLFW_KEY_9;
-    _glfw.wl.keycodes[KEY_0]          = GLFW_KEY_0;
-    _glfw.wl.keycodes[KEY_SPACE]      = GLFW_KEY_SPACE;
-    _glfw.wl.keycodes[KEY_MINUS]      = GLFW_KEY_MINUS;
-    _glfw.wl.keycodes[KEY_EQUAL]      = GLFW_KEY_EQUAL;
-    _glfw.wl.keycodes[KEY_Q]          = GLFW_KEY_Q;
-    _glfw.wl.keycodes[KEY_W]          = GLFW_KEY_W;
-    _glfw.wl.keycodes[KEY_E]          = GLFW_KEY_E;
-    _glfw.wl.keycodes[KEY_R]          = GLFW_KEY_R;
-    _glfw.wl.keycodes[KEY_T]          = GLFW_KEY_T;
-    _glfw.wl.keycodes[KEY_Y]          = GLFW_KEY_Y;
-    _glfw.wl.keycodes[KEY_U]          = GLFW_KEY_U;
-    _glfw.wl.keycodes[KEY_I]          = GLFW_KEY_I;
-    _glfw.wl.keycodes[KEY_O]          = GLFW_KEY_O;
-    _glfw.wl.keycodes[KEY_P]          = GLFW_KEY_P;
-    _glfw.wl.keycodes[KEY_LEFTBRACE]  = GLFW_KEY_LEFT_BRACKET;
-    _glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
-    _glfw.wl.keycodes[KEY_A]          = GLFW_KEY_A;
-    _glfw.wl.keycodes[KEY_S]          = GLFW_KEY_S;
-    _glfw.wl.keycodes[KEY_D]          = GLFW_KEY_D;
-    _glfw.wl.keycodes[KEY_F]          = GLFW_KEY_F;
-    _glfw.wl.keycodes[KEY_G]          = GLFW_KEY_G;
-    _glfw.wl.keycodes[KEY_H]          = GLFW_KEY_H;
-    _glfw.wl.keycodes[KEY_J]          = GLFW_KEY_J;
-    _glfw.wl.keycodes[KEY_K]          = GLFW_KEY_K;
-    _glfw.wl.keycodes[KEY_L]          = GLFW_KEY_L;
-    _glfw.wl.keycodes[KEY_SEMICOLON]  = GLFW_KEY_SEMICOLON;
-    _glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
-    _glfw.wl.keycodes[KEY_Z]          = GLFW_KEY_Z;
-    _glfw.wl.keycodes[KEY_X]          = GLFW_KEY_X;
-    _glfw.wl.keycodes[KEY_C]          = GLFW_KEY_C;
-    _glfw.wl.keycodes[KEY_V]          = GLFW_KEY_V;
-    _glfw.wl.keycodes[KEY_B]          = GLFW_KEY_B;
-    _glfw.wl.keycodes[KEY_N]          = GLFW_KEY_N;
-    _glfw.wl.keycodes[KEY_M]          = GLFW_KEY_M;
-    _glfw.wl.keycodes[KEY_COMMA]      = GLFW_KEY_COMMA;
-    _glfw.wl.keycodes[KEY_DOT]        = GLFW_KEY_PERIOD;
-    _glfw.wl.keycodes[KEY_SLASH]      = GLFW_KEY_SLASH;
-    _glfw.wl.keycodes[KEY_BACKSLASH]  = GLFW_KEY_BACKSLASH;
-    _glfw.wl.keycodes[KEY_ESC]        = GLFW_KEY_ESCAPE;
-    _glfw.wl.keycodes[KEY_TAB]        = GLFW_KEY_TAB;
-    _glfw.wl.keycodes[KEY_LEFTSHIFT]  = GLFW_KEY_LEFT_SHIFT;
-    _glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
-    _glfw.wl.keycodes[KEY_LEFTCTRL]   = GLFW_KEY_LEFT_CONTROL;
-    _glfw.wl.keycodes[KEY_RIGHTCTRL]  = GLFW_KEY_RIGHT_CONTROL;
-    _glfw.wl.keycodes[KEY_LEFTALT]    = GLFW_KEY_LEFT_ALT;
-    _glfw.wl.keycodes[KEY_RIGHTALT]   = GLFW_KEY_RIGHT_ALT;
-    _glfw.wl.keycodes[KEY_LEFTMETA]   = GLFW_KEY_LEFT_SUPER;
-    _glfw.wl.keycodes[KEY_RIGHTMETA]  = GLFW_KEY_RIGHT_SUPER;
-    _glfw.wl.keycodes[KEY_MENU]       = GLFW_KEY_MENU;
-    _glfw.wl.keycodes[KEY_NUMLOCK]    = GLFW_KEY_NUM_LOCK;
-    _glfw.wl.keycodes[KEY_CAPSLOCK]   = GLFW_KEY_CAPS_LOCK;
-    _glfw.wl.keycodes[KEY_PRINT]      = GLFW_KEY_PRINT_SCREEN;
-    _glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
-    _glfw.wl.keycodes[KEY_PAUSE]      = GLFW_KEY_PAUSE;
-    _glfw.wl.keycodes[KEY_DELETE]     = GLFW_KEY_DELETE;
-    _glfw.wl.keycodes[KEY_BACKSPACE]  = GLFW_KEY_BACKSPACE;
-    _glfw.wl.keycodes[KEY_ENTER]      = GLFW_KEY_ENTER;
-    _glfw.wl.keycodes[KEY_HOME]       = GLFW_KEY_HOME;
-    _glfw.wl.keycodes[KEY_END]        = GLFW_KEY_END;
-    _glfw.wl.keycodes[KEY_PAGEUP]     = GLFW_KEY_PAGE_UP;
-    _glfw.wl.keycodes[KEY_PAGEDOWN]   = GLFW_KEY_PAGE_DOWN;
-    _glfw.wl.keycodes[KEY_INSERT]     = GLFW_KEY_INSERT;
-    _glfw.wl.keycodes[KEY_LEFT]       = GLFW_KEY_LEFT;
-    _glfw.wl.keycodes[KEY_RIGHT]      = GLFW_KEY_RIGHT;
-    _glfw.wl.keycodes[KEY_DOWN]       = GLFW_KEY_DOWN;
-    _glfw.wl.keycodes[KEY_UP]         = GLFW_KEY_UP;
-    _glfw.wl.keycodes[KEY_F1]         = GLFW_KEY_F1;
-    _glfw.wl.keycodes[KEY_F2]         = GLFW_KEY_F2;
-    _glfw.wl.keycodes[KEY_F3]         = GLFW_KEY_F3;
-    _glfw.wl.keycodes[KEY_F4]         = GLFW_KEY_F4;
-    _glfw.wl.keycodes[KEY_F5]         = GLFW_KEY_F5;
-    _glfw.wl.keycodes[KEY_F6]         = GLFW_KEY_F6;
-    _glfw.wl.keycodes[KEY_F7]         = GLFW_KEY_F7;
-    _glfw.wl.keycodes[KEY_F8]         = GLFW_KEY_F8;
-    _glfw.wl.keycodes[KEY_F9]         = GLFW_KEY_F9;
-    _glfw.wl.keycodes[KEY_F10]        = GLFW_KEY_F10;
-    _glfw.wl.keycodes[KEY_F11]        = GLFW_KEY_F11;
-    _glfw.wl.keycodes[KEY_F12]        = GLFW_KEY_F12;
-    _glfw.wl.keycodes[KEY_F13]        = GLFW_KEY_F13;
-    _glfw.wl.keycodes[KEY_F14]        = GLFW_KEY_F14;
-    _glfw.wl.keycodes[KEY_F15]        = GLFW_KEY_F15;
-    _glfw.wl.keycodes[KEY_F16]        = GLFW_KEY_F16;
-    _glfw.wl.keycodes[KEY_F17]        = GLFW_KEY_F17;
-    _glfw.wl.keycodes[KEY_F18]        = GLFW_KEY_F18;
-    _glfw.wl.keycodes[KEY_F19]        = GLFW_KEY_F19;
-    _glfw.wl.keycodes[KEY_F20]        = GLFW_KEY_F20;
-    _glfw.wl.keycodes[KEY_F21]        = GLFW_KEY_F21;
-    _glfw.wl.keycodes[KEY_F22]        = GLFW_KEY_F22;
-    _glfw.wl.keycodes[KEY_F23]        = GLFW_KEY_F23;
-    _glfw.wl.keycodes[KEY_F24]        = GLFW_KEY_F24;
-    _glfw.wl.keycodes[KEY_KPSLASH]    = GLFW_KEY_KP_DIVIDE;
-    _glfw.wl.keycodes[KEY_KPDOT]      = GLFW_KEY_KP_MULTIPLY;
-    _glfw.wl.keycodes[KEY_KPMINUS]    = GLFW_KEY_KP_SUBTRACT;
-    _glfw.wl.keycodes[KEY_KPPLUS]     = GLFW_KEY_KP_ADD;
-    _glfw.wl.keycodes[KEY_KP0]        = GLFW_KEY_KP_0;
-    _glfw.wl.keycodes[KEY_KP1]        = GLFW_KEY_KP_1;
-    _glfw.wl.keycodes[KEY_KP2]        = GLFW_KEY_KP_2;
-    _glfw.wl.keycodes[KEY_KP3]        = GLFW_KEY_KP_3;
-    _glfw.wl.keycodes[KEY_KP4]        = GLFW_KEY_KP_4;
-    _glfw.wl.keycodes[KEY_KP5]        = GLFW_KEY_KP_5;
-    _glfw.wl.keycodes[KEY_KP6]        = GLFW_KEY_KP_6;
-    _glfw.wl.keycodes[KEY_KP7]        = GLFW_KEY_KP_7;
-    _glfw.wl.keycodes[KEY_KP8]        = GLFW_KEY_KP_8;
-    _glfw.wl.keycodes[KEY_KP9]        = GLFW_KEY_KP_9;
-    _glfw.wl.keycodes[KEY_KPCOMMA]    = GLFW_KEY_KP_DECIMAL;
-    _glfw.wl.keycodes[KEY_KPEQUAL]    = GLFW_KEY_KP_EQUAL;
-    _glfw.wl.keycodes[KEY_KPENTER]    = GLFW_KEY_KP_ENTER;
-
-    for (scancode = 0;  scancode < 256;  scancode++)
-    {
-        if (_glfw.wl.keycodes[scancode] > 0)
-            _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    const char *cursorTheme;
-    const char *cursorSizeStr;
-    char *cursorSizeEnd;
-    long cursorSizeLong;
-    int cursorSize;
-    int i;
-    _GLFWmonitor* monitor;
-
-    _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
-    if (!_glfw.wl.cursor.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libwayland-cursor");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
-    _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
-    _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
-    _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
-        _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
-
-    _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
-    if (!_glfw.wl.egl.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libwayland-egl");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
-    _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
-    _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
-        _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
-
-    _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
-    if (!_glfw.wl.xkb.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to open libxkbcommon");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.xkb.context_new = (PFN_xkb_context_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
-    _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
-    _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
-    _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
-    _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
-    _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
-    _glfw.wl.xkb.state_new = (PFN_xkb_state_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
-    _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
-    _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
-    _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
-    _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
-    _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
-    _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
-    _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
-    _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
-    _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
-    _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
-        _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
-#endif
-
-    _glfw.wl.display = wl_display_connect(NULL);
-    if (!_glfw.wl.display)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to connect to display");
-        return GLFW_FALSE;
-    }
-
-    _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
-    wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
-
-    createKeyTables();
-
-    _glfw.wl.xkb.context = xkb_context_new(0);
-    if (!_glfw.wl.xkb.context)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to initialize xkb context");
-        return GLFW_FALSE;
-    }
-
-    // Sync so we got all registry objects
-    wl_display_roundtrip(_glfw.wl.display);
-
-    // Sync so we got all initial output events
-    wl_display_roundtrip(_glfw.wl.display);
-
-    for (i = 0; i < _glfw.monitorCount; ++i)
-    {
-        monitor = _glfw.monitors[i];
-        if (monitor->widthMM <= 0 || monitor->heightMM <= 0)
-        {
-            // If Wayland does not provide a physical size, assume the default 96 DPI
-            monitor->widthMM  = (int) (monitor->modes[monitor->wl.currentMode].width * 25.4f / 96.f);
-            monitor->heightMM = (int) (monitor->modes[monitor->wl.currentMode].height * 25.4f / 96.f);
-        }
-    }
-
-    _glfwInitTimerPOSIX();
-
-    _glfw.wl.timerfd = -1;
-    if (_glfw.wl.seatVersion >= 4)
-        _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
-
-    if (!_glfw.wl.wmBase)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to find xdg-shell in your compositor");
-        return GLFW_FALSE;
-    }
-
-    if (_glfw.wl.pointer && _glfw.wl.shm)
-    {
-        cursorTheme = getenv("XCURSOR_THEME");
-        cursorSizeStr = getenv("XCURSOR_SIZE");
-        cursorSize = 32;
-        if (cursorSizeStr)
-        {
-            errno = 0;
-            cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
-            if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
-                cursorSize = (int)cursorSizeLong;
-        }
-        _glfw.wl.cursorTheme =
-            wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
-        if (!_glfw.wl.cursorTheme)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Unable to load default cursor theme");
-            return GLFW_FALSE;
-        }
-        // If this happens to be NULL, we just fallback to the scale=1 version.
-        _glfw.wl.cursorThemeHiDPI =
-            wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
-        _glfw.wl.cursorSurface =
-            wl_compositor_create_surface(_glfw.wl.compositor);
-        _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
-    }
-
-    if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
-    {
-        _glfw.wl.dataDevice =
-            wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
-                                                   _glfw.wl.seat);
-        wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
-        _glfw.wl.clipboardString = malloc(4096);
-        if (!_glfw.wl.clipboardString)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Unable to allocate clipboard memory");
-            return GLFW_FALSE;
-        }
-        _glfw.wl.clipboardSize = 4096;
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    _glfwTerminateEGL();
-    if (_glfw.wl.egl.handle)
-    {
-        _glfw_dlclose(_glfw.wl.egl.handle);
-        _glfw.wl.egl.handle = NULL;
-    }
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-    if (_glfw.wl.xkb.composeState)
-        xkb_compose_state_unref(_glfw.wl.xkb.composeState);
-#endif
-    if (_glfw.wl.xkb.keymap)
-        xkb_keymap_unref(_glfw.wl.xkb.keymap);
-    if (_glfw.wl.xkb.state)
-        xkb_state_unref(_glfw.wl.xkb.state);
-    if (_glfw.wl.xkb.context)
-        xkb_context_unref(_glfw.wl.xkb.context);
-    if (_glfw.wl.xkb.handle)
-    {
-        _glfw_dlclose(_glfw.wl.xkb.handle);
-        _glfw.wl.xkb.handle = NULL;
-    }
-
-    if (_glfw.wl.cursorTheme)
-        wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
-    if (_glfw.wl.cursorThemeHiDPI)
-        wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
-    if (_glfw.wl.cursor.handle)
-    {
-        _glfw_dlclose(_glfw.wl.cursor.handle);
-        _glfw.wl.cursor.handle = NULL;
-    }
-
-    if (_glfw.wl.cursorSurface)
-        wl_surface_destroy(_glfw.wl.cursorSurface);
-    if (_glfw.wl.subcompositor)
-        wl_subcompositor_destroy(_glfw.wl.subcompositor);
-    if (_glfw.wl.compositor)
-        wl_compositor_destroy(_glfw.wl.compositor);
-    if (_glfw.wl.shm)
-        wl_shm_destroy(_glfw.wl.shm);
-    if (_glfw.wl.viewporter)
-        wp_viewporter_destroy(_glfw.wl.viewporter);
-    if (_glfw.wl.decorationManager)
-        zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
-    if (_glfw.wl.wmBase)
-        xdg_wm_base_destroy(_glfw.wl.wmBase);
-    if (_glfw.wl.dataSource)
-        wl_data_source_destroy(_glfw.wl.dataSource);
-    if (_glfw.wl.dataDevice)
-        wl_data_device_destroy(_glfw.wl.dataDevice);
-    if (_glfw.wl.dataOffer)
-        wl_data_offer_destroy(_glfw.wl.dataOffer);
-    if (_glfw.wl.dataDeviceManager)
-        wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
-    if (_glfw.wl.pointer)
-        wl_pointer_destroy(_glfw.wl.pointer);
-    if (_glfw.wl.keyboard)
-        wl_keyboard_destroy(_glfw.wl.keyboard);
-    if (_glfw.wl.seat)
-        wl_seat_destroy(_glfw.wl.seat);
-    if (_glfw.wl.relativePointerManager)
-        zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
-    if (_glfw.wl.pointerConstraints)
-        zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
-    if (_glfw.wl.idleInhibitManager)
-        zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
-    if (_glfw.wl.registry)
-        wl_registry_destroy(_glfw.wl.registry);
-    if (_glfw.wl.display)
-    {
-        wl_display_flush(_glfw.wl.display);
-        wl_display_disconnect(_glfw.wl.display);
-    }
-
-    if (_glfw.wl.timerfd >= 0)
-        close(_glfw.wl.timerfd);
-    if (_glfw.wl.cursorTimerfd >= 0)
-        close(_glfw.wl.cursorTimerfd);
-
-    if (_glfw.wl.clipboardString)
-        free(_glfw.wl.clipboardString);
-    if (_glfw.wl.clipboardSendString)
-        free(_glfw.wl.clipboardSendString);
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " Wayland EGL OSMesa"
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-        " clock_gettime"
-#else
-        " gettimeofday"
-#endif
-        " evdev"
-#if defined(_GLFW_BUILD_DLL)
-        " shared"
-#endif
-        ;
-}
diff --git a/raylib_pi4_test/external/glfw/src/wl_monitor.c b/raylib_pi4_test/external/glfw/src/wl_monitor.c
deleted file mode 100644 (file)
index a6356de..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-
-
-static void outputHandleGeometry(void* data,
-                                 struct wl_output* output,
-                                 int32_t x,
-                                 int32_t y,
-                                 int32_t physicalWidth,
-                                 int32_t physicalHeight,
-                                 int32_t subpixel,
-                                 const char* make,
-                                 const char* model,
-                                 int32_t transform)
-{
-    struct _GLFWmonitor *monitor = data;
-    char name[1024];
-
-    monitor->wl.x = x;
-    monitor->wl.y = y;
-    monitor->widthMM = physicalWidth;
-    monitor->heightMM = physicalHeight;
-
-    snprintf(name, sizeof(name), "%s %s", make, model);
-    monitor->name = _glfw_strdup(name);
-}
-
-static void outputHandleMode(void* data,
-                             struct wl_output* output,
-                             uint32_t flags,
-                             int32_t width,
-                             int32_t height,
-                             int32_t refresh)
-{
-    struct _GLFWmonitor *monitor = data;
-    GLFWvidmode mode;
-
-    mode.width = width;
-    mode.height = height;
-    mode.redBits = 8;
-    mode.greenBits = 8;
-    mode.blueBits = 8;
-    mode.refreshRate = (int) round(refresh / 1000.0);
-
-    monitor->modeCount++;
-    monitor->modes =
-        realloc(monitor->modes, monitor->modeCount * sizeof(GLFWvidmode));
-    monitor->modes[monitor->modeCount - 1] = mode;
-
-    if (flags & WL_OUTPUT_MODE_CURRENT)
-        monitor->wl.currentMode = monitor->modeCount - 1;
-}
-
-static void outputHandleDone(void* data, struct wl_output* output)
-{
-    struct _GLFWmonitor *monitor = data;
-
-    _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
-}
-
-static void outputHandleScale(void* data,
-                              struct wl_output* output,
-                              int32_t factor)
-{
-    struct _GLFWmonitor *monitor = data;
-
-    monitor->wl.scale = factor;
-}
-
-static const struct wl_output_listener outputListener = {
-    outputHandleGeometry,
-    outputHandleMode,
-    outputHandleDone,
-    outputHandleScale,
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwAddOutputWayland(uint32_t name, uint32_t version)
-{
-    _GLFWmonitor *monitor;
-    struct wl_output *output;
-
-    if (version < 2)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unsupported output interface version");
-        return;
-    }
-
-    // The actual name of this output will be set in the geometry handler.
-    monitor = _glfwAllocMonitor(NULL, 0, 0);
-
-    output = wl_registry_bind(_glfw.wl.registry,
-                              name,
-                              &wl_output_interface,
-                              2);
-    if (!output)
-    {
-        _glfwFreeMonitor(monitor);
-        return;
-    }
-
-    monitor->wl.scale = 1;
-    monitor->wl.output = output;
-    monitor->wl.name = name;
-
-    wl_output_add_listener(output, &outputListener, monitor);
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-    if (monitor->wl.output)
-        wl_output_destroy(monitor->wl.output);
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (xpos)
-        *xpos = monitor->wl.x;
-    if (ypos)
-        *ypos = monitor->wl.y;
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = (float) monitor->wl.scale;
-    if (yscale)
-        *yscale = (float) monitor->wl.scale;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor,
-                                     int* xpos, int* ypos,
-                                     int* width, int* height)
-{
-    if (xpos)
-        *xpos = monitor->wl.x;
-    if (ypos)
-        *ypos = monitor->wl.y;
-    if (width)
-        *width = monitor->modes[monitor->wl.currentMode].width;
-    if (height)
-        *height = monitor->modes[monitor->wl.currentMode].height;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
-{
-    *found = monitor->modeCount;
-    return monitor->modes;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    *mode = monitor->modes[monitor->wl.currentMode];
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: Gamma ramp access is not available");
-    return GLFW_FALSE;
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor,
-                               const GLFWgammaramp* ramp)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: Gamma ramp access is not available");
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return monitor->wl.output;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/wl_platform.h b/raylib_pi4_test/external/glfw/src/wl_platform.h
deleted file mode 100644 (file)
index 966155f..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <wayland-client.h>
-#include <xkbcommon/xkbcommon.h>
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-#include <xkbcommon/xkbcommon-compose.h>
-#endif
-#include <dlfcn.h>
-
-typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
-
-typedef struct VkWaylandSurfaceCreateInfoKHR
-{
-    VkStructureType                 sType;
-    const void*                     pNext;
-    VkWaylandSurfaceCreateFlagsKHR  flags;
-    struct wl_display*              display;
-    struct wl_surface*              surface;
-} VkWaylandSurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*);
-
-#include "posix_thread.h"
-#include "posix_time.h"
-#ifdef __linux__
-#include "linux_joystick.h"
-#else
-#include "null_joystick.h"
-#endif
-#include "xkb_unicode.h"
-
-#include "wayland-xdg-shell-client-protocol.h"
-#include "wayland-xdg-decoration-client-protocol.h"
-#include "wayland-viewporter-client-protocol.h"
-#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
-#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
-#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowWayland  wl
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorWayland wl
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorWayland  wl
-
-#define _GLFW_PLATFORM_CONTEXT_STATE         struct { int dummyContext; }
-#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
-
-struct wl_cursor_image {
-    uint32_t width;
-    uint32_t height;
-    uint32_t hotspot_x;
-    uint32_t hotspot_y;
-    uint32_t delay;
-};
-struct wl_cursor {
-    unsigned int image_count;
-    struct wl_cursor_image** images;
-    char* name;
-};
-typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
-typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
-typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);
-typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*);
-#define wl_cursor_theme_load _glfw.wl.cursor.theme_load
-#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy
-#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor
-#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer
-
-typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int);
-typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*);
-typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int);
-#define wl_egl_window_create _glfw.wl.egl.window_create
-#define wl_egl_window_destroy _glfw.wl.egl.window_destroy
-#define wl_egl_window_resize _glfw.wl.egl.window_resize
-
-typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags);
-typedef void (* PFN_xkb_context_unref)(struct xkb_context*);
-typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
-typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
-typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
-typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
-typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
-typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
-typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
-typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
-typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
-#define xkb_context_new _glfw.wl.xkb.context_new
-#define xkb_context_unref _glfw.wl.xkb.context_unref
-#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
-#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
-#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
-#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
-#define xkb_state_new _glfw.wl.xkb.state_new
-#define xkb_state_unref _glfw.wl.xkb.state_unref
-#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
-#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
-#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
-typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
-typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
-typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*);
-typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t);
-typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*);
-typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*);
-#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale
-#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref
-#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new
-#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref
-#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
-#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
-#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
-#endif
-
-#define _GLFW_DECORATION_WIDTH 4
-#define _GLFW_DECORATION_TOP 24
-#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH)
-#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH)
-
-typedef enum _GLFWdecorationSideWayland
-{
-    mainWindow,
-    topDecoration,
-    leftDecoration,
-    rightDecoration,
-    bottomDecoration,
-
-} _GLFWdecorationSideWayland;
-
-typedef struct _GLFWdecorationWayland
-{
-    struct wl_surface*          surface;
-    struct wl_subsurface*       subsurface;
-    struct wp_viewport*         viewport;
-
-} _GLFWdecorationWayland;
-
-// Wayland-specific per-window data
-//
-typedef struct _GLFWwindowWayland
-{
-    int                         width, height;
-    GLFWbool                    visible;
-    GLFWbool                    maximized;
-    GLFWbool                    hovered;
-    GLFWbool                    transparent;
-    struct wl_surface*          surface;
-    struct wl_egl_window*       native;
-    struct wl_callback*         callback;
-
-    struct {
-        struct xdg_surface*     surface;
-        struct xdg_toplevel*    toplevel;
-        struct zxdg_toplevel_decoration_v1* decoration;
-    } xdg;
-
-    _GLFWcursor*                currentCursor;
-    double                      cursorPosX, cursorPosY;
-
-    char*                       title;
-
-    // We need to track the monitors the window spans on to calculate the
-    // optimal scaling factor.
-    int                         scale;
-    _GLFWmonitor**              monitors;
-    int                         monitorsCount;
-    int                         monitorsSize;
-
-    struct {
-        struct zwp_relative_pointer_v1*    relativePointer;
-        struct zwp_locked_pointer_v1*      lockedPointer;
-    } pointerLock;
-
-    struct zwp_idle_inhibitor_v1*          idleInhibitor;
-
-    GLFWbool                    wasFullscreen;
-
-    struct {
-        GLFWbool                           serverSide;
-        struct wl_buffer*                  buffer;
-        _GLFWdecorationWayland             top, left, right, bottom;
-        int                                focus;
-    } decorations;
-
-} _GLFWwindowWayland;
-
-// Wayland-specific global data
-//
-typedef struct _GLFWlibraryWayland
-{
-    struct wl_display*          display;
-    struct wl_registry*         registry;
-    struct wl_compositor*       compositor;
-    struct wl_subcompositor*    subcompositor;
-    struct wl_shm*              shm;
-    struct wl_seat*             seat;
-    struct wl_pointer*          pointer;
-    struct wl_keyboard*         keyboard;
-    struct wl_data_device_manager*          dataDeviceManager;
-    struct wl_data_device*      dataDevice;
-    struct wl_data_offer*       dataOffer;
-    struct wl_data_source*      dataSource;
-    struct xdg_wm_base*         wmBase;
-    struct zxdg_decoration_manager_v1*      decorationManager;
-    struct wp_viewporter*       viewporter;
-    struct zwp_relative_pointer_manager_v1* relativePointerManager;
-    struct zwp_pointer_constraints_v1*      pointerConstraints;
-    struct zwp_idle_inhibit_manager_v1*     idleInhibitManager;
-
-    int                         compositorVersion;
-    int                         seatVersion;
-
-    struct wl_cursor_theme*     cursorTheme;
-    struct wl_cursor_theme*     cursorThemeHiDPI;
-    struct wl_surface*          cursorSurface;
-    const char*                 cursorPreviousName;
-    int                         cursorTimerfd;
-    uint32_t                    serial;
-
-    int32_t                     keyboardRepeatRate;
-    int32_t                     keyboardRepeatDelay;
-    int                         keyboardLastKey;
-    int                         keyboardLastScancode;
-    char*                       clipboardString;
-    size_t                      clipboardSize;
-    char*                       clipboardSendString;
-    size_t                      clipboardSendSize;
-    int                         timerfd;
-    short int                   keycodes[256];
-    short int                   scancodes[GLFW_KEY_LAST + 1];
-
-    struct {
-        void*                   handle;
-        struct xkb_context*     context;
-        struct xkb_keymap*      keymap;
-        struct xkb_state*       state;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        struct xkb_compose_state* composeState;
-#endif
-
-        xkb_mod_mask_t          controlMask;
-        xkb_mod_mask_t          altMask;
-        xkb_mod_mask_t          shiftMask;
-        xkb_mod_mask_t          superMask;
-        xkb_mod_mask_t          capsLockMask;
-        xkb_mod_mask_t          numLockMask;
-        unsigned int            modifiers;
-
-        PFN_xkb_context_new context_new;
-        PFN_xkb_context_unref context_unref;
-        PFN_xkb_keymap_new_from_string keymap_new_from_string;
-        PFN_xkb_keymap_unref keymap_unref;
-        PFN_xkb_keymap_mod_get_index keymap_mod_get_index;
-        PFN_xkb_keymap_key_repeats keymap_key_repeats;
-        PFN_xkb_state_new state_new;
-        PFN_xkb_state_unref state_unref;
-        PFN_xkb_state_key_get_syms state_key_get_syms;
-        PFN_xkb_state_update_mask state_update_mask;
-        PFN_xkb_state_serialize_mods state_serialize_mods;
-
-#ifdef HAVE_XKBCOMMON_COMPOSE_H
-        PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
-        PFN_xkb_compose_table_unref compose_table_unref;
-        PFN_xkb_compose_state_new compose_state_new;
-        PFN_xkb_compose_state_unref compose_state_unref;
-        PFN_xkb_compose_state_feed compose_state_feed;
-        PFN_xkb_compose_state_get_status compose_state_get_status;
-        PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
-#endif
-    } xkb;
-
-    _GLFWwindow*                pointerFocus;
-    _GLFWwindow*                keyboardFocus;
-
-    struct {
-        void*                   handle;
-
-        PFN_wl_cursor_theme_load theme_load;
-        PFN_wl_cursor_theme_destroy theme_destroy;
-        PFN_wl_cursor_theme_get_cursor theme_get_cursor;
-        PFN_wl_cursor_image_get_buffer image_get_buffer;
-    } cursor;
-
-    struct {
-        void*                   handle;
-
-        PFN_wl_egl_window_create window_create;
-        PFN_wl_egl_window_destroy window_destroy;
-        PFN_wl_egl_window_resize window_resize;
-    } egl;
-
-} _GLFWlibraryWayland;
-
-// Wayland-specific per-monitor data
-//
-typedef struct _GLFWmonitorWayland
-{
-    struct wl_output*           output;
-    uint32_t                    name;
-    int                         currentMode;
-
-    int                         x;
-    int                         y;
-    int                         scale;
-
-} _GLFWmonitorWayland;
-
-// Wayland-specific per-cursor data
-//
-typedef struct _GLFWcursorWayland
-{
-    struct wl_cursor*           cursor;
-    struct wl_cursor*           cursorHiDPI;
-    struct wl_buffer*           buffer;
-    int                         width, height;
-    int                         xhot, yhot;
-    int                         currentImage;
-} _GLFWcursorWayland;
-
-
-void _glfwAddOutputWayland(uint32_t name, uint32_t version);
-
diff --git a/raylib_pi4_test/external/glfw/src/wl_window.c b/raylib_pi4_test/external/glfw/src/wl_window.c
deleted file mode 100644 (file)
index 7b315d7..0000000
+++ /dev/null
@@ -1,1800 +0,0 @@
-//========================================================================
-// GLFW 3.4 Wayland - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#define _GNU_SOURCE
-
-#include "internal.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/timerfd.h>
-#include <poll.h>
-
-
-static int createTmpfileCloexec(char* tmpname)
-{
-    int fd;
-
-    fd = mkostemp(tmpname, O_CLOEXEC);
-    if (fd >= 0)
-        unlink(tmpname);
-
-    return fd;
-}
-
-/*
- * Create a new, unique, anonymous file of the given size, and
- * return the file descriptor for it. The file descriptor is set
- * CLOEXEC. The file is immediately suitable for mmap()'ing
- * the given size at offset zero.
- *
- * The file should not have a permanent backing store like a disk,
- * but may have if XDG_RUNTIME_DIR is not properly implemented in OS.
- *
- * The file name is deleted from the file system.
- *
- * The file is suitable for buffer sharing between processes by
- * transmitting the file descriptor over Unix sockets using the
- * SCM_RIGHTS methods.
- *
- * posix_fallocate() is used to guarantee that disk space is available
- * for the file at the given size. If disk space is insufficient, errno
- * is set to ENOSPC. If posix_fallocate() is not supported, program may
- * receive SIGBUS on accessing mmap()'ed file contents instead.
- */
-static int createAnonymousFile(off_t size)
-{
-    static const char template[] = "/glfw-shared-XXXXXX";
-    const char* path;
-    char* name;
-    int fd;
-    int ret;
-
-#ifdef HAVE_MEMFD_CREATE
-    fd = memfd_create("glfw-shared", MFD_CLOEXEC | MFD_ALLOW_SEALING);
-    if (fd >= 0)
-    {
-        // We can add this seal before calling posix_fallocate(), as the file
-        // is currently zero-sized anyway.
-        //
-        // There is also no need to check for the return value, we couldn’t do
-        // anything with it anyway.
-        fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL);
-    }
-    else
-#elif defined(SHM_ANON)
-    fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
-    if (fd < 0)
-#endif
-    {
-        path = getenv("XDG_RUNTIME_DIR");
-        if (!path)
-        {
-            errno = ENOENT;
-            return -1;
-        }
-
-        name = calloc(strlen(path) + sizeof(template), 1);
-        strcpy(name, path);
-        strcat(name, template);
-
-        fd = createTmpfileCloexec(name);
-        free(name);
-        if (fd < 0)
-            return -1;
-    }
-
-#if defined(SHM_ANON)
-    // posix_fallocate does not work on SHM descriptors
-    ret = ftruncate(fd, size);
-#else
-    ret = posix_fallocate(fd, 0, size);
-#endif
-    if (ret != 0)
-    {
-        close(fd);
-        errno = ret;
-        return -1;
-    }
-    return fd;
-}
-
-static struct wl_buffer* createShmBuffer(const GLFWimage* image)
-{
-    struct wl_shm_pool* pool;
-    struct wl_buffer* buffer;
-    int stride = image->width * 4;
-    int length = image->width * image->height * 4;
-    void* data;
-    int fd, i;
-
-    fd = createAnonymousFile(length);
-    if (fd < 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Creating a buffer file for %d B failed: %s",
-                        length, strerror(errno));
-        return NULL;
-    }
-
-    data = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
-    if (data == MAP_FAILED)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: mmap failed: %s", strerror(errno));
-        close(fd);
-        return NULL;
-    }
-
-    pool = wl_shm_create_pool(_glfw.wl.shm, fd, length);
-
-    close(fd);
-    unsigned char* source = (unsigned char*) image->pixels;
-    unsigned char* target = data;
-    for (i = 0;  i < image->width * image->height;  i++, source += 4)
-    {
-        unsigned int alpha = source[3];
-
-        *target++ = (unsigned char) ((source[2] * alpha) / 255);
-        *target++ = (unsigned char) ((source[1] * alpha) / 255);
-        *target++ = (unsigned char) ((source[0] * alpha) / 255);
-        *target++ = (unsigned char) alpha;
-    }
-
-    buffer =
-        wl_shm_pool_create_buffer(pool, 0,
-                                  image->width,
-                                  image->height,
-                                  stride, WL_SHM_FORMAT_ARGB8888);
-    munmap(data, length);
-    wl_shm_pool_destroy(pool);
-
-    return buffer;
-}
-
-static void createDecoration(_GLFWdecorationWayland* decoration,
-                             struct wl_surface* parent,
-                             struct wl_buffer* buffer, GLFWbool opaque,
-                             int x, int y,
-                             int width, int height)
-{
-    struct wl_region* region;
-
-    decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
-    decoration->subsurface =
-        wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
-                                        decoration->surface, parent);
-    wl_subsurface_set_position(decoration->subsurface, x, y);
-    decoration->viewport = wp_viewporter_get_viewport(_glfw.wl.viewporter,
-                                                      decoration->surface);
-    wp_viewport_set_destination(decoration->viewport, width, height);
-    wl_surface_attach(decoration->surface, buffer, 0, 0);
-
-    if (opaque)
-    {
-        region = wl_compositor_create_region(_glfw.wl.compositor);
-        wl_region_add(region, 0, 0, width, height);
-        wl_surface_set_opaque_region(decoration->surface, region);
-        wl_surface_commit(decoration->surface);
-        wl_region_destroy(region);
-    }
-    else
-        wl_surface_commit(decoration->surface);
-}
-
-static void createDecorations(_GLFWwindow* window)
-{
-    unsigned char data[] = { 224, 224, 224, 255 };
-    const GLFWimage image = { 1, 1, data };
-    GLFWbool opaque = (data[3] == 255);
-
-    if (!_glfw.wl.viewporter || !window->decorated || window->wl.decorations.serverSide)
-        return;
-
-    if (!window->wl.decorations.buffer)
-        window->wl.decorations.buffer = createShmBuffer(&image);
-    if (!window->wl.decorations.buffer)
-        return;
-
-    createDecoration(&window->wl.decorations.top, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     0, -_GLFW_DECORATION_TOP,
-                     window->wl.width, _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.left, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     -_GLFW_DECORATION_WIDTH, -_GLFW_DECORATION_TOP,
-                     _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.right, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     window->wl.width, -_GLFW_DECORATION_TOP,
-                     _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    createDecoration(&window->wl.decorations.bottom, window->wl.surface,
-                     window->wl.decorations.buffer, opaque,
-                     -_GLFW_DECORATION_WIDTH, window->wl.height,
-                     window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
-}
-
-static void destroyDecoration(_GLFWdecorationWayland* decoration)
-{
-    if (decoration->surface)
-        wl_surface_destroy(decoration->surface);
-    if (decoration->subsurface)
-        wl_subsurface_destroy(decoration->subsurface);
-    if (decoration->viewport)
-        wp_viewport_destroy(decoration->viewport);
-    decoration->surface = NULL;
-    decoration->subsurface = NULL;
-    decoration->viewport = NULL;
-}
-
-static void destroyDecorations(_GLFWwindow* window)
-{
-    destroyDecoration(&window->wl.decorations.top);
-    destroyDecoration(&window->wl.decorations.left);
-    destroyDecoration(&window->wl.decorations.right);
-    destroyDecoration(&window->wl.decorations.bottom);
-}
-
-static void xdgDecorationHandleConfigure(void* data,
-                                         struct zxdg_toplevel_decoration_v1* decoration,
-                                         uint32_t mode)
-{
-    _GLFWwindow* window = data;
-
-    window->wl.decorations.serverSide = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
-
-    if (!window->wl.decorations.serverSide)
-        createDecorations(window);
-}
-
-static const struct zxdg_toplevel_decoration_v1_listener xdgDecorationListener = {
-    xdgDecorationHandleConfigure,
-};
-
-// Makes the surface considered as XRGB instead of ARGB.
-static void setOpaqueRegion(_GLFWwindow* window)
-{
-    struct wl_region* region;
-
-    region = wl_compositor_create_region(_glfw.wl.compositor);
-    if (!region)
-        return;
-
-    wl_region_add(region, 0, 0, window->wl.width, window->wl.height);
-    wl_surface_set_opaque_region(window->wl.surface, region);
-    wl_surface_commit(window->wl.surface);
-    wl_region_destroy(region);
-}
-
-
-static void resizeWindow(_GLFWwindow* window)
-{
-    int scale = window->wl.scale;
-    int scaledWidth = window->wl.width * scale;
-    int scaledHeight = window->wl.height * scale;
-    wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
-    if (!window->wl.transparent)
-        setOpaqueRegion(window);
-    _glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
-    _glfwInputWindowContentScale(window, scale, scale);
-
-    if (!window->wl.decorations.top.surface)
-        return;
-
-    // Top decoration.
-    wp_viewport_set_destination(window->wl.decorations.top.viewport,
-                                window->wl.width, _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.top.surface);
-
-    // Left decoration.
-    wp_viewport_set_destination(window->wl.decorations.left.viewport,
-                                _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.left.surface);
-
-    // Right decoration.
-    wl_subsurface_set_position(window->wl.decorations.right.subsurface,
-                               window->wl.width, -_GLFW_DECORATION_TOP);
-    wp_viewport_set_destination(window->wl.decorations.right.viewport,
-                                _GLFW_DECORATION_WIDTH, window->wl.height + _GLFW_DECORATION_TOP);
-    wl_surface_commit(window->wl.decorations.right.surface);
-
-    // Bottom decoration.
-    wl_subsurface_set_position(window->wl.decorations.bottom.subsurface,
-                               -_GLFW_DECORATION_WIDTH, window->wl.height);
-    wp_viewport_set_destination(window->wl.decorations.bottom.viewport,
-                                window->wl.width + _GLFW_DECORATION_HORIZONTAL, _GLFW_DECORATION_WIDTH);
-    wl_surface_commit(window->wl.decorations.bottom.surface);
-}
-
-static void checkScaleChange(_GLFWwindow* window)
-{
-    int scale = 1;
-    int i;
-    int monitorScale;
-
-    // Check if we will be able to set the buffer scale or not.
-    if (_glfw.wl.compositorVersion < 3)
-        return;
-
-    // Get the scale factor from the highest scale monitor.
-    for (i = 0; i < window->wl.monitorsCount; ++i)
-    {
-        monitorScale = window->wl.monitors[i]->wl.scale;
-        if (scale < monitorScale)
-            scale = monitorScale;
-    }
-
-    // Only change the framebuffer size if the scale changed.
-    if (scale != window->wl.scale)
-    {
-        window->wl.scale = scale;
-        wl_surface_set_buffer_scale(window->wl.surface, scale);
-        resizeWindow(window);
-    }
-}
-
-static void surfaceHandleEnter(void *data,
-                               struct wl_surface *surface,
-                               struct wl_output *output)
-{
-    _GLFWwindow* window = data;
-    _GLFWmonitor* monitor = wl_output_get_user_data(output);
-
-    if (window->wl.monitorsCount + 1 > window->wl.monitorsSize)
-    {
-        ++window->wl.monitorsSize;
-        window->wl.monitors =
-            realloc(window->wl.monitors,
-                    window->wl.monitorsSize * sizeof(_GLFWmonitor*));
-    }
-
-    window->wl.monitors[window->wl.monitorsCount++] = monitor;
-
-    checkScaleChange(window);
-}
-
-static void surfaceHandleLeave(void *data,
-                               struct wl_surface *surface,
-                               struct wl_output *output)
-{
-    _GLFWwindow* window = data;
-    _GLFWmonitor* monitor = wl_output_get_user_data(output);
-    GLFWbool found;
-    int i;
-
-    for (i = 0, found = GLFW_FALSE; i < window->wl.monitorsCount - 1; ++i)
-    {
-        if (monitor == window->wl.monitors[i])
-            found = GLFW_TRUE;
-        if (found)
-            window->wl.monitors[i] = window->wl.monitors[i + 1];
-    }
-    window->wl.monitors[--window->wl.monitorsCount] = NULL;
-
-    checkScaleChange(window);
-}
-
-static const struct wl_surface_listener surfaceListener = {
-    surfaceHandleEnter,
-    surfaceHandleLeave
-};
-
-static void setIdleInhibitor(_GLFWwindow* window, GLFWbool enable)
-{
-    if (enable && !window->wl.idleInhibitor && _glfw.wl.idleInhibitManager)
-    {
-        window->wl.idleInhibitor =
-            zwp_idle_inhibit_manager_v1_create_inhibitor(
-                _glfw.wl.idleInhibitManager, window->wl.surface);
-        if (!window->wl.idleInhibitor)
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Idle inhibitor creation failed");
-    }
-    else if (!enable && window->wl.idleInhibitor)
-    {
-        zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
-        window->wl.idleInhibitor = NULL;
-    }
-}
-
-static GLFWbool createSurface(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig)
-{
-    window->wl.surface = wl_compositor_create_surface(_glfw.wl.compositor);
-    if (!window->wl.surface)
-        return GLFW_FALSE;
-
-    wl_surface_add_listener(window->wl.surface,
-                            &surfaceListener,
-                            window);
-
-    wl_surface_set_user_data(window->wl.surface, window);
-
-    window->wl.native = wl_egl_window_create(window->wl.surface,
-                                             wndconfig->width,
-                                             wndconfig->height);
-    if (!window->wl.native)
-        return GLFW_FALSE;
-
-    window->wl.width = wndconfig->width;
-    window->wl.height = wndconfig->height;
-    window->wl.scale = 1;
-
-    if (!window->wl.transparent)
-        setOpaqueRegion(window);
-
-    return GLFW_TRUE;
-}
-
-static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor,
-                          int refreshRate)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_set_fullscreen(
-            window->wl.xdg.toplevel,
-            monitor->wl.output);
-    }
-    setIdleInhibitor(window, GLFW_TRUE);
-    if (!window->wl.decorations.serverSide)
-        destroyDecorations(window);
-}
-
-static void xdgToplevelHandleConfigure(void* data,
-                                       struct xdg_toplevel* toplevel,
-                                       int32_t width,
-                                       int32_t height,
-                                       struct wl_array* states)
-{
-    _GLFWwindow* window = data;
-    float aspectRatio;
-    float targetRatio;
-    uint32_t* state;
-    GLFWbool maximized = GLFW_FALSE;
-    GLFWbool fullscreen = GLFW_FALSE;
-    GLFWbool activated = GLFW_FALSE;
-
-    wl_array_for_each(state, states)
-    {
-        switch (*state)
-        {
-            case XDG_TOPLEVEL_STATE_MAXIMIZED:
-                maximized = GLFW_TRUE;
-                break;
-            case XDG_TOPLEVEL_STATE_FULLSCREEN:
-                fullscreen = GLFW_TRUE;
-                break;
-            case XDG_TOPLEVEL_STATE_RESIZING:
-                break;
-            case XDG_TOPLEVEL_STATE_ACTIVATED:
-                activated = GLFW_TRUE;
-                break;
-        }
-    }
-
-    if (width != 0 && height != 0)
-    {
-        if (!maximized && !fullscreen)
-        {
-            if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
-            {
-                aspectRatio = (float)width / (float)height;
-                targetRatio = (float)window->numer / (float)window->denom;
-                if (aspectRatio < targetRatio)
-                    height = width / targetRatio;
-                else if (aspectRatio > targetRatio)
-                    width = height * targetRatio;
-            }
-        }
-
-        _glfwInputWindowSize(window, width, height);
-        _glfwPlatformSetWindowSize(window, width, height);
-        _glfwInputWindowDamage(window);
-    }
-
-    if (window->wl.wasFullscreen && window->autoIconify)
-    {
-        if (!activated || !fullscreen)
-        {
-            _glfwPlatformIconifyWindow(window);
-            window->wl.wasFullscreen = GLFW_FALSE;
-        }
-    }
-    if (fullscreen && activated)
-        window->wl.wasFullscreen = GLFW_TRUE;
-    _glfwInputWindowFocus(window, activated);
-}
-
-static void xdgToplevelHandleClose(void* data,
-                                   struct xdg_toplevel* toplevel)
-{
-    _GLFWwindow* window = data;
-    _glfwInputWindowCloseRequest(window);
-}
-
-static const struct xdg_toplevel_listener xdgToplevelListener = {
-    xdgToplevelHandleConfigure,
-    xdgToplevelHandleClose
-};
-
-static void xdgSurfaceHandleConfigure(void* data,
-                                      struct xdg_surface* surface,
-                                      uint32_t serial)
-{
-    xdg_surface_ack_configure(surface, serial);
-}
-
-static const struct xdg_surface_listener xdgSurfaceListener = {
-    xdgSurfaceHandleConfigure
-};
-
-static void setXdgDecorations(_GLFWwindow* window)
-{
-    if (_glfw.wl.decorationManager)
-    {
-        window->wl.xdg.decoration =
-            zxdg_decoration_manager_v1_get_toplevel_decoration(
-                _glfw.wl.decorationManager, window->wl.xdg.toplevel);
-        zxdg_toplevel_decoration_v1_add_listener(window->wl.xdg.decoration,
-                                                 &xdgDecorationListener,
-                                                 window);
-        zxdg_toplevel_decoration_v1_set_mode(
-            window->wl.xdg.decoration,
-            ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
-    }
-    else
-    {
-        window->wl.decorations.serverSide = GLFW_FALSE;
-        createDecorations(window);
-    }
-}
-
-static GLFWbool createXdgSurface(_GLFWwindow* window)
-{
-    window->wl.xdg.surface = xdg_wm_base_get_xdg_surface(_glfw.wl.wmBase,
-                                                         window->wl.surface);
-    if (!window->wl.xdg.surface)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: xdg-surface creation failed");
-        return GLFW_FALSE;
-    }
-
-    xdg_surface_add_listener(window->wl.xdg.surface,
-                             &xdgSurfaceListener,
-                             window);
-
-    window->wl.xdg.toplevel = xdg_surface_get_toplevel(window->wl.xdg.surface);
-    if (!window->wl.xdg.toplevel)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: xdg-toplevel creation failed");
-        return GLFW_FALSE;
-    }
-
-    xdg_toplevel_add_listener(window->wl.xdg.toplevel,
-                              &xdgToplevelListener,
-                              window);
-
-    if (window->wl.title)
-        xdg_toplevel_set_title(window->wl.xdg.toplevel, window->wl.title);
-
-    if (window->minwidth != GLFW_DONT_CARE && window->minheight != GLFW_DONT_CARE)
-        xdg_toplevel_set_min_size(window->wl.xdg.toplevel,
-                                  window->minwidth, window->minheight);
-    if (window->maxwidth != GLFW_DONT_CARE && window->maxheight != GLFW_DONT_CARE)
-        xdg_toplevel_set_max_size(window->wl.xdg.toplevel,
-                                  window->maxwidth, window->maxheight);
-
-    if (window->monitor)
-    {
-        xdg_toplevel_set_fullscreen(window->wl.xdg.toplevel,
-                                    window->monitor->wl.output);
-        setIdleInhibitor(window, GLFW_TRUE);
-    }
-    else if (window->wl.maximized)
-    {
-        xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
-        setIdleInhibitor(window, GLFW_FALSE);
-        setXdgDecorations(window);
-    }
-    else
-    {
-        setIdleInhibitor(window, GLFW_FALSE);
-        setXdgDecorations(window);
-    }
-
-    wl_surface_commit(window->wl.surface);
-    wl_display_roundtrip(_glfw.wl.display);
-
-    return GLFW_TRUE;
-}
-
-static void setCursorImage(_GLFWwindow* window,
-                           _GLFWcursorWayland* cursorWayland)
-{
-    struct itimerspec timer = {};
-    struct wl_cursor* wlCursor = cursorWayland->cursor;
-    struct wl_cursor_image* image;
-    struct wl_buffer* buffer;
-    struct wl_surface* surface = _glfw.wl.cursorSurface;
-    int scale = 1;
-
-    if (!wlCursor)
-        buffer = cursorWayland->buffer;
-    else
-    {
-        if (window->wl.scale > 1 && cursorWayland->cursorHiDPI)
-        {
-            wlCursor = cursorWayland->cursorHiDPI;
-            scale = 2;
-        }
-
-        image = wlCursor->images[cursorWayland->currentImage];
-        buffer = wl_cursor_image_get_buffer(image);
-        if (!buffer)
-            return;
-
-        timer.it_value.tv_sec = image->delay / 1000;
-        timer.it_value.tv_nsec = (image->delay % 1000) * 1000000;
-        timerfd_settime(_glfw.wl.cursorTimerfd, 0, &timer, NULL);
-
-        cursorWayland->width = image->width;
-        cursorWayland->height = image->height;
-        cursorWayland->xhot = image->hotspot_x;
-        cursorWayland->yhot = image->hotspot_y;
-    }
-
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          surface,
-                          cursorWayland->xhot / scale,
-                          cursorWayland->yhot / scale);
-    wl_surface_set_buffer_scale(surface, scale);
-    wl_surface_attach(surface, buffer, 0, 0);
-    wl_surface_damage(surface, 0, 0,
-                      cursorWayland->width, cursorWayland->height);
-    wl_surface_commit(surface);
-}
-
-static void incrementCursorImage(_GLFWwindow* window)
-{
-    _GLFWcursor* cursor;
-
-    if (!window || window->wl.decorations.focus != mainWindow)
-        return;
-
-    cursor = window->wl.currentCursor;
-    if (cursor && cursor->wl.cursor)
-    {
-        cursor->wl.currentImage += 1;
-        cursor->wl.currentImage %= cursor->wl.cursor->image_count;
-        setCursorImage(window, &cursor->wl);
-    }
-}
-
-static void handleEvents(int timeout)
-{
-    struct wl_display* display = _glfw.wl.display;
-    struct pollfd fds[] = {
-        { wl_display_get_fd(display), POLLIN },
-        { _glfw.wl.timerfd, POLLIN },
-        { _glfw.wl.cursorTimerfd, POLLIN },
-    };
-    ssize_t read_ret;
-    uint64_t repeats, i;
-
-    while (wl_display_prepare_read(display) != 0)
-        wl_display_dispatch_pending(display);
-
-    // If an error different from EAGAIN happens, we have likely been
-    // disconnected from the Wayland session, try to handle that the best we
-    // can.
-    if (wl_display_flush(display) < 0 && errno != EAGAIN)
-    {
-        _GLFWwindow* window = _glfw.windowListHead;
-        while (window)
-        {
-            _glfwInputWindowCloseRequest(window);
-            window = window->next;
-        }
-        wl_display_cancel_read(display);
-        return;
-    }
-
-    if (poll(fds, 3, timeout) > 0)
-    {
-        if (fds[0].revents & POLLIN)
-        {
-            wl_display_read_events(display);
-            wl_display_dispatch_pending(display);
-        }
-        else
-        {
-            wl_display_cancel_read(display);
-        }
-
-        if (fds[1].revents & POLLIN)
-        {
-            read_ret = read(_glfw.wl.timerfd, &repeats, sizeof(repeats));
-            if (read_ret != 8)
-                return;
-
-            if (_glfw.wl.keyboardFocus)
-            {
-                for (i = 0; i < repeats; ++i)
-                {
-                    _glfwInputKey(_glfw.wl.keyboardFocus,
-                                  _glfw.wl.keyboardLastKey,
-                                  _glfw.wl.keyboardLastScancode,
-                                  GLFW_REPEAT,
-                                  _glfw.wl.xkb.modifiers);
-                }
-            }
-        }
-
-        if (fds[2].revents & POLLIN)
-        {
-            read_ret = read(_glfw.wl.cursorTimerfd, &repeats, sizeof(repeats));
-            if (read_ret != 8)
-                return;
-
-            incrementCursorImage(_glfw.wl.pointerFocus);
-        }
-    }
-    else
-    {
-        wl_display_cancel_read(display);
-    }
-}
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    window->wl.transparent = fbconfig->transparent;
-
-    if (!createSurface(window, wndconfig))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_EGL_CONTEXT_API ||
-            ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (wndconfig->title)
-        window->wl.title = _glfw_strdup(wndconfig->title);
-
-    if (wndconfig->visible)
-    {
-        if (!createXdgSurface(window))
-            return GLFW_FALSE;
-
-        window->wl.visible = GLFW_TRUE;
-    }
-    else
-    {
-        window->wl.xdg.surface = NULL;
-        window->wl.xdg.toplevel = NULL;
-        window->wl.visible = GLFW_FALSE;
-    }
-
-    window->wl.currentCursor = NULL;
-
-    window->wl.monitors = calloc(1, sizeof(_GLFWmonitor*));
-    window->wl.monitorsCount = 0;
-    window->wl.monitorsSize = 1;
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (window == _glfw.wl.pointerFocus)
-    {
-        _glfw.wl.pointerFocus = NULL;
-        _glfwInputCursorEnter(window, GLFW_FALSE);
-    }
-    if (window == _glfw.wl.keyboardFocus)
-    {
-        _glfw.wl.keyboardFocus = NULL;
-        _glfwInputWindowFocus(window, GLFW_FALSE);
-    }
-
-    if (window->wl.idleInhibitor)
-        zwp_idle_inhibitor_v1_destroy(window->wl.idleInhibitor);
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    destroyDecorations(window);
-    if (window->wl.xdg.decoration)
-        zxdg_toplevel_decoration_v1_destroy(window->wl.xdg.decoration);
-
-    if (window->wl.decorations.buffer)
-        wl_buffer_destroy(window->wl.decorations.buffer);
-
-    if (window->wl.native)
-        wl_egl_window_destroy(window->wl.native);
-
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_destroy(window->wl.xdg.toplevel);
-
-    if (window->wl.xdg.surface)
-        xdg_surface_destroy(window->wl.xdg.surface);
-
-    if (window->wl.surface)
-        wl_surface_destroy(window->wl.surface);
-
-    free(window->wl.title);
-    free(window->wl.monitors);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    if (window->wl.title)
-        free(window->wl.title);
-    window->wl.title = _glfw_strdup(title);
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window icon");
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    // A Wayland client is not aware of its position, so just warn and leave it
-    // as (0, 0)
-
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not provide the window position");
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    // A Wayland client can not set its position, so just warn
-
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window position");
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    if (width)
-        *width = window->wl.width;
-    if (height)
-        *height = window->wl.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    window->wl.width = width;
-    window->wl.height = height;
-    resizeWindow(window);
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        if (minwidth == GLFW_DONT_CARE || minheight == GLFW_DONT_CARE)
-            minwidth = minheight = 0;
-        if (maxwidth == GLFW_DONT_CARE || maxheight == GLFW_DONT_CARE)
-            maxwidth = maxheight = 0;
-        xdg_toplevel_set_min_size(window->wl.xdg.toplevel, minwidth, minheight);
-        xdg_toplevel_set_max_size(window->wl.xdg.toplevel, maxwidth, maxheight);
-        wl_surface_commit(window->wl.surface);
-    }
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
-                                       int numer, int denom)
-{
-    // TODO: find out how to trigger a resize.
-    // The actual limits are checked in the xdg_toplevel::configure handler.
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window aspect ratio not yet implemented");
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
-                                     int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-    if (width)
-        *width *= window->wl.scale;
-    if (height)
-        *height *= window->wl.scale;
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    if (window->decorated && !window->monitor && !window->wl.decorations.serverSide)
-    {
-        if (top)
-            *top = _GLFW_DECORATION_TOP;
-        if (left)
-            *left = _GLFW_DECORATION_WIDTH;
-        if (right)
-            *right = _GLFW_DECORATION_WIDTH;
-        if (bottom)
-            *bottom = _GLFW_DECORATION_WIDTH;
-    }
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = (float) window->wl.scale;
-    if (yscale)
-        *yscale = (float) window->wl.scale;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-        xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        if (window->monitor)
-            xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
-        if (window->wl.maximized)
-            xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
-        // There is no way to unset minimized, or even to know if we are
-        // minimized, so there is nothing to do in this case.
-    }
-    _glfwInputWindowMonitor(window, NULL);
-    window->wl.maximized = GLFW_FALSE;
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
-    }
-    window->wl.maximized = GLFW_TRUE;
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    if (!window->wl.visible)
-    {
-        createXdgSurface(window);
-        window->wl.visible = GLFW_TRUE;
-    }
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    if (window->wl.xdg.toplevel)
-    {
-        xdg_toplevel_destroy(window->wl.xdg.toplevel);
-        xdg_surface_destroy(window->wl.xdg.surface);
-        window->wl.xdg.toplevel = NULL;
-        window->wl.xdg.surface = NULL;
-    }
-    window->wl.visible = GLFW_FALSE;
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attention request not implemented yet");
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the input focus");
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (monitor)
-    {
-        setFullscreen(window, monitor, refreshRate);
-    }
-    else
-    {
-        if (window->wl.xdg.toplevel)
-            xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
-        setIdleInhibitor(window, GLFW_FALSE);
-        if (!_glfw.wl.decorationManager)
-            createDecorations(window);
-    }
-    _glfwInputWindowMonitor(window, monitor);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    return _glfw.wl.keyboardFocus == window;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    // xdg-shell doesn’t give any way to request whether a surface is
-    // iconified.
-    return GLFW_FALSE;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    return window->wl.visible;
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    return window->wl.maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    return window->wl.hovered;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    return window->wl.transparent;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attribute setting not implemented yet");
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!window->monitor)
-    {
-        if (enabled)
-            createDecorations(window);
-        else
-            destroyDecorations(window);
-    }
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Window attribute setting not implemented yet");
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (enabled)
-    {
-        struct wl_region* region = wl_compositor_create_region(_glfw.wl.compositor);
-        wl_surface_set_input_region(window->wl.surface, region);
-        wl_region_destroy(region);
-    }
-    else
-        wl_surface_set_input_region(window->wl.surface, 0);
-    wl_surface_commit(window->wl.surface);
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    return 1.f;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
-                    "Wayland: The platform does not support setting the window opacity");
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    // This is handled in relativePointerHandleRelativeMotion
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    handleEvents(0);
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    handleEvents(-1);
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    handleEvents((int) (timeout * 1e3));
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    wl_display_sync(_glfw.wl.display);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    if (xpos)
-        *xpos = window->wl.cursorPosX;
-    if (ypos)
-        *ypos = window->wl.cursorPosY;
-}
-
-static GLFWbool isPointerLocked(_GLFWwindow* window);
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    if (isPointerLocked(window))
-    {
-        zwp_locked_pointer_v1_set_cursor_position_hint(
-            window->wl.pointerLock.lockedPointer,
-            wl_fixed_from_double(x), wl_fixed_from_double(y));
-        wl_surface_commit(window->wl.surface);
-    }
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    _glfwPlatformSetCursor(window, window->wl.currentCursor);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    // TODO
-    _glfwInputError(GLFW_FEATURE_UNIMPLEMENTED,
-                    "Wayland: Key names not yet implemented");
-    return NULL;
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.wl.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->wl.buffer = createShmBuffer(image);
-    if (!cursor->wl.buffer)
-        return GLFW_FALSE;
-
-    cursor->wl.width = image->width;
-    cursor->wl.height = image->height;
-    cursor->wl.xhot = xhot;
-    cursor->wl.yhot = yhot;
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    const char* name = NULL;
-
-    // Try the XDG names first
-    if (shape == GLFW_ARROW_CURSOR)
-        name = "default";
-    else if (shape == GLFW_IBEAM_CURSOR)
-        name = "text";
-    else if (shape == GLFW_CROSSHAIR_CURSOR)
-        name = "crosshair";
-    else if (shape == GLFW_POINTING_HAND_CURSOR)
-        name = "pointer";
-    else if (shape == GLFW_RESIZE_EW_CURSOR)
-        name = "ew-resize";
-    else if (shape == GLFW_RESIZE_NS_CURSOR)
-        name = "ns-resize";
-    else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-        name = "nwse-resize";
-    else if (shape == GLFW_RESIZE_NESW_CURSOR)
-        name = "nesw-resize";
-    else if (shape == GLFW_RESIZE_ALL_CURSOR)
-        name = "all-scroll";
-    else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-        name = "not-allowed";
-
-    cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
-
-    if (_glfw.wl.cursorThemeHiDPI)
-    {
-        cursor->wl.cursorHiDPI =
-            wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
-    }
-
-    if (!cursor->wl.cursor)
-    {
-        // Fall back to the core X11 names
-        if (shape == GLFW_ARROW_CURSOR)
-            name = "left_ptr";
-        else if (shape == GLFW_IBEAM_CURSOR)
-            name = "xterm";
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            name = "crosshair";
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            name = "hand2";
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            name = "sb_h_double_arrow";
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            name = "sb_v_double_arrow";
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            name = "fleur";
-        else
-        {
-            _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                            "Wayland: Standard cursor shape unavailable");
-            return GLFW_FALSE;
-        }
-
-        cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
-        if (!cursor->wl.cursor)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Failed to create standard cursor \"%s\"",
-                            name);
-            return GLFW_FALSE;
-        }
-
-        if (_glfw.wl.cursorThemeHiDPI)
-        {
-            if (!cursor->wl.cursorHiDPI)
-            {
-                cursor->wl.cursorHiDPI =
-                    wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
-            }
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    // If it's a standard cursor we don't need to do anything here
-    if (cursor->wl.cursor)
-        return;
-
-    if (cursor->wl.buffer)
-        wl_buffer_destroy(cursor->wl.buffer);
-}
-
-static void relativePointerHandleRelativeMotion(void* data,
-                                                struct zwp_relative_pointer_v1* pointer,
-                                                uint32_t timeHi,
-                                                uint32_t timeLo,
-                                                wl_fixed_t dx,
-                                                wl_fixed_t dy,
-                                                wl_fixed_t dxUnaccel,
-                                                wl_fixed_t dyUnaccel)
-{
-    _GLFWwindow* window = data;
-    double xpos = window->virtualCursorPosX;
-    double ypos = window->virtualCursorPosY;
-
-    if (window->cursorMode != GLFW_CURSOR_DISABLED)
-        return;
-
-    if (window->rawMouseMotion)
-    {
-        xpos += wl_fixed_to_double(dxUnaccel);
-        ypos += wl_fixed_to_double(dyUnaccel);
-    }
-    else
-    {
-        xpos += wl_fixed_to_double(dx);
-        ypos += wl_fixed_to_double(dy);
-    }
-
-    _glfwInputCursorPos(window, xpos, ypos);
-}
-
-static const struct zwp_relative_pointer_v1_listener relativePointerListener = {
-    relativePointerHandleRelativeMotion
-};
-
-static void lockedPointerHandleLocked(void* data,
-                                      struct zwp_locked_pointer_v1* lockedPointer)
-{
-}
-
-static void unlockPointer(_GLFWwindow* window)
-{
-    struct zwp_relative_pointer_v1* relativePointer =
-        window->wl.pointerLock.relativePointer;
-    struct zwp_locked_pointer_v1* lockedPointer =
-        window->wl.pointerLock.lockedPointer;
-
-    zwp_relative_pointer_v1_destroy(relativePointer);
-    zwp_locked_pointer_v1_destroy(lockedPointer);
-
-    window->wl.pointerLock.relativePointer = NULL;
-    window->wl.pointerLock.lockedPointer = NULL;
-}
-
-static void lockPointer(_GLFWwindow* window);
-
-static void lockedPointerHandleUnlocked(void* data,
-                                        struct zwp_locked_pointer_v1* lockedPointer)
-{
-}
-
-static const struct zwp_locked_pointer_v1_listener lockedPointerListener = {
-    lockedPointerHandleLocked,
-    lockedPointerHandleUnlocked
-};
-
-static void lockPointer(_GLFWwindow* window)
-{
-    struct zwp_relative_pointer_v1* relativePointer;
-    struct zwp_locked_pointer_v1* lockedPointer;
-
-    if (!_glfw.wl.relativePointerManager)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: no relative pointer manager");
-        return;
-    }
-
-    relativePointer =
-        zwp_relative_pointer_manager_v1_get_relative_pointer(
-            _glfw.wl.relativePointerManager,
-            _glfw.wl.pointer);
-    zwp_relative_pointer_v1_add_listener(relativePointer,
-                                         &relativePointerListener,
-                                         window);
-
-    lockedPointer =
-        zwp_pointer_constraints_v1_lock_pointer(
-            _glfw.wl.pointerConstraints,
-            window->wl.surface,
-            _glfw.wl.pointer,
-            NULL,
-            ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
-    zwp_locked_pointer_v1_add_listener(lockedPointer,
-                                       &lockedPointerListener,
-                                       window);
-
-    window->wl.pointerLock.relativePointer = relativePointer;
-    window->wl.pointerLock.lockedPointer = lockedPointer;
-
-    wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
-                          NULL, 0, 0);
-}
-
-static GLFWbool isPointerLocked(_GLFWwindow* window)
-{
-    return window->wl.pointerLock.lockedPointer != NULL;
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    struct wl_cursor* defaultCursor;
-    struct wl_cursor* defaultCursorHiDPI = NULL;
-
-    if (!_glfw.wl.pointer)
-        return;
-
-    window->wl.currentCursor = cursor;
-
-    // If we're not in the correct window just save the cursor
-    // the next time the pointer enters the window the cursor will change
-    if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow)
-        return;
-
-    // Unlock possible pointer lock if no longer disabled.
-    if (window->cursorMode != GLFW_CURSOR_DISABLED && isPointerLocked(window))
-        unlockPointer(window);
-
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (cursor)
-            setCursorImage(window, &cursor->wl);
-        else
-        {
-            defaultCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme,
-                                                       "left_ptr");
-            if (!defaultCursor)
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "Wayland: Standard cursor not found");
-                return;
-            }
-            if (_glfw.wl.cursorThemeHiDPI)
-                defaultCursorHiDPI =
-                    wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI,
-                                               "left_ptr");
-            _GLFWcursorWayland cursorWayland = {
-                defaultCursor,
-                defaultCursorHiDPI,
-                NULL,
-                0, 0,
-                0, 0,
-                0
-            };
-            setCursorImage(window, &cursorWayland);
-        }
-    }
-    else if (window->cursorMode == GLFW_CURSOR_DISABLED)
-    {
-        if (!isPointerLocked(window))
-            lockPointer(window);
-    }
-    else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-    {
-        wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial, NULL, 0, 0);
-    }
-}
-
-static void dataSourceHandleTarget(void* data,
-                                   struct wl_data_source* dataSource,
-                                   const char* mimeType)
-{
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-}
-
-static void dataSourceHandleSend(void* data,
-                                 struct wl_data_source* dataSource,
-                                 const char* mimeType,
-                                 int fd)
-{
-    const char* string = _glfw.wl.clipboardSendString;
-    size_t len = _glfw.wl.clipboardSendSize;
-    int ret;
-
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-
-    if (!string)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Copy requested from an invalid string");
-        return;
-    }
-
-    if (strcmp(mimeType, "text/plain;charset=utf-8") != 0)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Wrong MIME type asked from clipboard");
-        close(fd);
-        return;
-    }
-
-    while (len > 0)
-    {
-        ret = write(fd, string, len);
-        if (ret == -1 && errno == EINTR)
-            continue;
-        if (ret == -1)
-        {
-            // TODO: also report errno maybe.
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Error while writing the clipboard");
-            close(fd);
-            return;
-        }
-        len -= ret;
-    }
-    close(fd);
-}
-
-static void dataSourceHandleCancelled(void* data,
-                                      struct wl_data_source* dataSource)
-{
-    wl_data_source_destroy(dataSource);
-
-    if (_glfw.wl.dataSource != dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Unknown clipboard data source");
-        return;
-    }
-
-    _glfw.wl.dataSource = NULL;
-}
-
-static const struct wl_data_source_listener dataSourceListener = {
-    dataSourceHandleTarget,
-    dataSourceHandleSend,
-    dataSourceHandleCancelled,
-};
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    if (_glfw.wl.dataSource)
-    {
-        wl_data_source_destroy(_glfw.wl.dataSource);
-        _glfw.wl.dataSource = NULL;
-    }
-
-    if (_glfw.wl.clipboardSendString)
-    {
-        free(_glfw.wl.clipboardSendString);
-        _glfw.wl.clipboardSendString = NULL;
-    }
-
-    _glfw.wl.clipboardSendString = strdup(string);
-    if (!_glfw.wl.clipboardSendString)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to allocate clipboard string");
-        return;
-    }
-    _glfw.wl.clipboardSendSize = strlen(string);
-    _glfw.wl.dataSource =
-        wl_data_device_manager_create_data_source(_glfw.wl.dataDeviceManager);
-    if (!_glfw.wl.dataSource)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to create clipboard source");
-        free(_glfw.wl.clipboardSendString);
-        return;
-    }
-    wl_data_source_add_listener(_glfw.wl.dataSource,
-                                &dataSourceListener,
-                                NULL);
-    wl_data_source_offer(_glfw.wl.dataSource, "text/plain;charset=utf-8");
-    wl_data_device_set_selection(_glfw.wl.dataDevice,
-                                 _glfw.wl.dataSource,
-                                 _glfw.wl.serial);
-}
-
-static GLFWbool growClipboardString(void)
-{
-    char* clipboard = _glfw.wl.clipboardString;
-
-    clipboard = realloc(clipboard, _glfw.wl.clipboardSize * 2);
-    if (!clipboard)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to grow clipboard string");
-        return GLFW_FALSE;
-    }
-    _glfw.wl.clipboardString = clipboard;
-    _glfw.wl.clipboardSize = _glfw.wl.clipboardSize * 2;
-    return GLFW_TRUE;
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    int fds[2];
-    int ret;
-    size_t len = 0;
-
-    if (!_glfw.wl.dataOffer)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "No clipboard data has been sent yet");
-        return NULL;
-    }
-
-    ret = pipe2(fds, O_CLOEXEC);
-    if (ret < 0)
-    {
-        // TODO: also report errno maybe?
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Impossible to create clipboard pipe fds");
-        return NULL;
-    }
-
-    wl_data_offer_receive(_glfw.wl.dataOffer, "text/plain;charset=utf-8", fds[1]);
-    close(fds[1]);
-
-    // XXX: this is a huge hack, this function shouldn’t be synchronous!
-    handleEvents(-1);
-
-    while (1)
-    {
-        // Grow the clipboard if we need to paste something bigger, there is no
-        // shrink operation yet.
-        if (len + 4096 > _glfw.wl.clipboardSize)
-        {
-            if (!growClipboardString())
-            {
-                close(fds[0]);
-                return NULL;
-            }
-        }
-
-        // Then read from the fd to the clipboard, handling all known errors.
-        ret = read(fds[0], _glfw.wl.clipboardString + len, 4096);
-        if (ret == 0)
-            break;
-        if (ret == -1 && errno == EINTR)
-            continue;
-        if (ret == -1)
-        {
-            // TODO: also report errno maybe.
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "Wayland: Impossible to read from clipboard fd");
-            close(fds[0]);
-            return NULL;
-        }
-        len += ret;
-    }
-    close(fds[0]);
-    if (len + 1 > _glfw.wl.clipboardSize)
-    {
-        if (!growClipboardString())
-            return NULL;
-    }
-    _glfw.wl.clipboardString[len] = '\0';
-    return _glfw.wl.clipboardString;
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_wayland)
-        return EGL_PLATFORM_WAYLAND_EXT;
-    else
-        return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return _glfw.wl.display;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    return window->wl.native;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface)
-        return;
-
-    extensions[0] = "VK_KHR_surface";
-    extensions[1] = "VK_KHR_wayland_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
-        vkGetPhysicalDeviceWaylandPresentationSupportKHR =
-        (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)
-        vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceWaylandPresentationSupportKHR");
-    if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
-        return VK_NULL_HANDLE;
-    }
-
-    return vkGetPhysicalDeviceWaylandPresentationSupportKHR(device,
-                                                            queuefamily,
-                                                            _glfw.wl.display);
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    VkResult err;
-    VkWaylandSurfaceCreateInfoKHR sci;
-    PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR;
-
-    vkCreateWaylandSurfaceKHR = (PFN_vkCreateWaylandSurfaceKHR)
-        vkGetInstanceProcAddr(instance, "vkCreateWaylandSurfaceKHR");
-    if (!vkCreateWaylandSurfaceKHR)
-    {
-        _glfwInputError(GLFW_API_UNAVAILABLE,
-                        "Wayland: Vulkan instance missing VK_KHR_wayland_surface extension");
-        return VK_ERROR_EXTENSION_NOT_PRESENT;
-    }
-
-    memset(&sci, 0, sizeof(sci));
-    sci.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR;
-    sci.display = _glfw.wl.display;
-    sci.surface = window->wl.surface;
-
-    err = vkCreateWaylandSurfaceKHR(instance, &sci, allocator, surface);
-    if (err)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "Wayland: Failed to create Vulkan surface: %s",
-                        _glfwGetVulkanResultString(err));
-    }
-
-    return err;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI struct wl_display* glfwGetWaylandDisplay(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfw.wl.display;
-}
-
-GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return window->wl.surface;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/x11_init.c b/raylib_pi4_test/external/glfw/src/x11_init.c
deleted file mode 100644 (file)
index dd24f11..0000000
+++ /dev/null
@@ -1,1496 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-#include <locale.h>
-#include <unistd.h>
-
-
-// Translate the X11 KeySyms for a key to a GLFW key code
-// NOTE: This is only used as a fallback, in case the XKB method fails
-//       It is layout-dependent and will fail partially on most non-US layouts
-//
-static int translateKeySyms(const KeySym* keysyms, int width)
-{
-    if (width > 1)
-    {
-        switch (keysyms[1])
-        {
-            case XK_KP_0:           return GLFW_KEY_KP_0;
-            case XK_KP_1:           return GLFW_KEY_KP_1;
-            case XK_KP_2:           return GLFW_KEY_KP_2;
-            case XK_KP_3:           return GLFW_KEY_KP_3;
-            case XK_KP_4:           return GLFW_KEY_KP_4;
-            case XK_KP_5:           return GLFW_KEY_KP_5;
-            case XK_KP_6:           return GLFW_KEY_KP_6;
-            case XK_KP_7:           return GLFW_KEY_KP_7;
-            case XK_KP_8:           return GLFW_KEY_KP_8;
-            case XK_KP_9:           return GLFW_KEY_KP_9;
-            case XK_KP_Separator:
-            case XK_KP_Decimal:     return GLFW_KEY_KP_DECIMAL;
-            case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;
-            case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;
-            default:                break;
-        }
-    }
-
-    switch (keysyms[0])
-    {
-        case XK_Escape:         return GLFW_KEY_ESCAPE;
-        case XK_Tab:            return GLFW_KEY_TAB;
-        case XK_Shift_L:        return GLFW_KEY_LEFT_SHIFT;
-        case XK_Shift_R:        return GLFW_KEY_RIGHT_SHIFT;
-        case XK_Control_L:      return GLFW_KEY_LEFT_CONTROL;
-        case XK_Control_R:      return GLFW_KEY_RIGHT_CONTROL;
-        case XK_Meta_L:
-        case XK_Alt_L:          return GLFW_KEY_LEFT_ALT;
-        case XK_Mode_switch: // Mapped to Alt_R on many keyboards
-        case XK_ISO_Level3_Shift: // AltGr on at least some machines
-        case XK_Meta_R:
-        case XK_Alt_R:          return GLFW_KEY_RIGHT_ALT;
-        case XK_Super_L:        return GLFW_KEY_LEFT_SUPER;
-        case XK_Super_R:        return GLFW_KEY_RIGHT_SUPER;
-        case XK_Menu:           return GLFW_KEY_MENU;
-        case XK_Num_Lock:       return GLFW_KEY_NUM_LOCK;
-        case XK_Caps_Lock:      return GLFW_KEY_CAPS_LOCK;
-        case XK_Print:          return GLFW_KEY_PRINT_SCREEN;
-        case XK_Scroll_Lock:    return GLFW_KEY_SCROLL_LOCK;
-        case XK_Pause:          return GLFW_KEY_PAUSE;
-        case XK_Delete:         return GLFW_KEY_DELETE;
-        case XK_BackSpace:      return GLFW_KEY_BACKSPACE;
-        case XK_Return:         return GLFW_KEY_ENTER;
-        case XK_Home:           return GLFW_KEY_HOME;
-        case XK_End:            return GLFW_KEY_END;
-        case XK_Page_Up:        return GLFW_KEY_PAGE_UP;
-        case XK_Page_Down:      return GLFW_KEY_PAGE_DOWN;
-        case XK_Insert:         return GLFW_KEY_INSERT;
-        case XK_Left:           return GLFW_KEY_LEFT;
-        case XK_Right:          return GLFW_KEY_RIGHT;
-        case XK_Down:           return GLFW_KEY_DOWN;
-        case XK_Up:             return GLFW_KEY_UP;
-        case XK_F1:             return GLFW_KEY_F1;
-        case XK_F2:             return GLFW_KEY_F2;
-        case XK_F3:             return GLFW_KEY_F3;
-        case XK_F4:             return GLFW_KEY_F4;
-        case XK_F5:             return GLFW_KEY_F5;
-        case XK_F6:             return GLFW_KEY_F6;
-        case XK_F7:             return GLFW_KEY_F7;
-        case XK_F8:             return GLFW_KEY_F8;
-        case XK_F9:             return GLFW_KEY_F9;
-        case XK_F10:            return GLFW_KEY_F10;
-        case XK_F11:            return GLFW_KEY_F11;
-        case XK_F12:            return GLFW_KEY_F12;
-        case XK_F13:            return GLFW_KEY_F13;
-        case XK_F14:            return GLFW_KEY_F14;
-        case XK_F15:            return GLFW_KEY_F15;
-        case XK_F16:            return GLFW_KEY_F16;
-        case XK_F17:            return GLFW_KEY_F17;
-        case XK_F18:            return GLFW_KEY_F18;
-        case XK_F19:            return GLFW_KEY_F19;
-        case XK_F20:            return GLFW_KEY_F20;
-        case XK_F21:            return GLFW_KEY_F21;
-        case XK_F22:            return GLFW_KEY_F22;
-        case XK_F23:            return GLFW_KEY_F23;
-        case XK_F24:            return GLFW_KEY_F24;
-        case XK_F25:            return GLFW_KEY_F25;
-
-        // Numeric keypad
-        case XK_KP_Divide:      return GLFW_KEY_KP_DIVIDE;
-        case XK_KP_Multiply:    return GLFW_KEY_KP_MULTIPLY;
-        case XK_KP_Subtract:    return GLFW_KEY_KP_SUBTRACT;
-        case XK_KP_Add:         return GLFW_KEY_KP_ADD;
-
-        // These should have been detected in secondary keysym test above!
-        case XK_KP_Insert:      return GLFW_KEY_KP_0;
-        case XK_KP_End:         return GLFW_KEY_KP_1;
-        case XK_KP_Down:        return GLFW_KEY_KP_2;
-        case XK_KP_Page_Down:   return GLFW_KEY_KP_3;
-        case XK_KP_Left:        return GLFW_KEY_KP_4;
-        case XK_KP_Right:       return GLFW_KEY_KP_6;
-        case XK_KP_Home:        return GLFW_KEY_KP_7;
-        case XK_KP_Up:          return GLFW_KEY_KP_8;
-        case XK_KP_Page_Up:     return GLFW_KEY_KP_9;
-        case XK_KP_Delete:      return GLFW_KEY_KP_DECIMAL;
-        case XK_KP_Equal:       return GLFW_KEY_KP_EQUAL;
-        case XK_KP_Enter:       return GLFW_KEY_KP_ENTER;
-
-        // Last resort: Check for printable keys (should not happen if the XKB
-        // extension is available). This will give a layout dependent mapping
-        // (which is wrong, and we may miss some keys, especially on non-US
-        // keyboards), but it's better than nothing...
-        case XK_a:              return GLFW_KEY_A;
-        case XK_b:              return GLFW_KEY_B;
-        case XK_c:              return GLFW_KEY_C;
-        case XK_d:              return GLFW_KEY_D;
-        case XK_e:              return GLFW_KEY_E;
-        case XK_f:              return GLFW_KEY_F;
-        case XK_g:              return GLFW_KEY_G;
-        case XK_h:              return GLFW_KEY_H;
-        case XK_i:              return GLFW_KEY_I;
-        case XK_j:              return GLFW_KEY_J;
-        case XK_k:              return GLFW_KEY_K;
-        case XK_l:              return GLFW_KEY_L;
-        case XK_m:              return GLFW_KEY_M;
-        case XK_n:              return GLFW_KEY_N;
-        case XK_o:              return GLFW_KEY_O;
-        case XK_p:              return GLFW_KEY_P;
-        case XK_q:              return GLFW_KEY_Q;
-        case XK_r:              return GLFW_KEY_R;
-        case XK_s:              return GLFW_KEY_S;
-        case XK_t:              return GLFW_KEY_T;
-        case XK_u:              return GLFW_KEY_U;
-        case XK_v:              return GLFW_KEY_V;
-        case XK_w:              return GLFW_KEY_W;
-        case XK_x:              return GLFW_KEY_X;
-        case XK_y:              return GLFW_KEY_Y;
-        case XK_z:              return GLFW_KEY_Z;
-        case XK_1:              return GLFW_KEY_1;
-        case XK_2:              return GLFW_KEY_2;
-        case XK_3:              return GLFW_KEY_3;
-        case XK_4:              return GLFW_KEY_4;
-        case XK_5:              return GLFW_KEY_5;
-        case XK_6:              return GLFW_KEY_6;
-        case XK_7:              return GLFW_KEY_7;
-        case XK_8:              return GLFW_KEY_8;
-        case XK_9:              return GLFW_KEY_9;
-        case XK_0:              return GLFW_KEY_0;
-        case XK_space:          return GLFW_KEY_SPACE;
-        case XK_minus:          return GLFW_KEY_MINUS;
-        case XK_equal:          return GLFW_KEY_EQUAL;
-        case XK_bracketleft:    return GLFW_KEY_LEFT_BRACKET;
-        case XK_bracketright:   return GLFW_KEY_RIGHT_BRACKET;
-        case XK_backslash:      return GLFW_KEY_BACKSLASH;
-        case XK_semicolon:      return GLFW_KEY_SEMICOLON;
-        case XK_apostrophe:     return GLFW_KEY_APOSTROPHE;
-        case XK_grave:          return GLFW_KEY_GRAVE_ACCENT;
-        case XK_comma:          return GLFW_KEY_COMMA;
-        case XK_period:         return GLFW_KEY_PERIOD;
-        case XK_slash:          return GLFW_KEY_SLASH;
-        case XK_less:           return GLFW_KEY_WORLD_1; // At least in some layouts...
-        default:                break;
-    }
-
-    // No matching translation was found
-    return GLFW_KEY_UNKNOWN;
-}
-
-// Create key code translation tables
-//
-static void createKeyTables(void)
-{
-    int scancode, scancodeMin, scancodeMax;
-
-    memset(_glfw.x11.keycodes, -1, sizeof(_glfw.x11.keycodes));
-    memset(_glfw.x11.scancodes, -1, sizeof(_glfw.x11.scancodes));
-
-    if (_glfw.x11.xkb.available)
-    {
-        // Use XKB to determine physical key locations independently of the
-        // current keyboard layout
-
-        XkbDescPtr desc = XkbGetMap(_glfw.x11.display, 0, XkbUseCoreKbd);
-        XkbGetNames(_glfw.x11.display, XkbKeyNamesMask | XkbKeyAliasesMask, desc);
-
-        scancodeMin = desc->min_key_code;
-        scancodeMax = desc->max_key_code;
-
-        const struct
-        {
-            int key;
-            char* name;
-        } keymap[] =
-        {
-            { GLFW_KEY_GRAVE_ACCENT, "TLDE" },
-            { GLFW_KEY_1, "AE01" },
-            { GLFW_KEY_2, "AE02" },
-            { GLFW_KEY_3, "AE03" },
-            { GLFW_KEY_4, "AE04" },
-            { GLFW_KEY_5, "AE05" },
-            { GLFW_KEY_6, "AE06" },
-            { GLFW_KEY_7, "AE07" },
-            { GLFW_KEY_8, "AE08" },
-            { GLFW_KEY_9, "AE09" },
-            { GLFW_KEY_0, "AE10" },
-            { GLFW_KEY_MINUS, "AE11" },
-            { GLFW_KEY_EQUAL, "AE12" },
-            { GLFW_KEY_Q, "AD01" },
-            { GLFW_KEY_W, "AD02" },
-            { GLFW_KEY_E, "AD03" },
-            { GLFW_KEY_R, "AD04" },
-            { GLFW_KEY_T, "AD05" },
-            { GLFW_KEY_Y, "AD06" },
-            { GLFW_KEY_U, "AD07" },
-            { GLFW_KEY_I, "AD08" },
-            { GLFW_KEY_O, "AD09" },
-            { GLFW_KEY_P, "AD10" },
-            { GLFW_KEY_LEFT_BRACKET, "AD11" },
-            { GLFW_KEY_RIGHT_BRACKET, "AD12" },
-            { GLFW_KEY_A, "AC01" },
-            { GLFW_KEY_S, "AC02" },
-            { GLFW_KEY_D, "AC03" },
-            { GLFW_KEY_F, "AC04" },
-            { GLFW_KEY_G, "AC05" },
-            { GLFW_KEY_H, "AC06" },
-            { GLFW_KEY_J, "AC07" },
-            { GLFW_KEY_K, "AC08" },
-            { GLFW_KEY_L, "AC09" },
-            { GLFW_KEY_SEMICOLON, "AC10" },
-            { GLFW_KEY_APOSTROPHE, "AC11" },
-            { GLFW_KEY_Z, "AB01" },
-            { GLFW_KEY_X, "AB02" },
-            { GLFW_KEY_C, "AB03" },
-            { GLFW_KEY_V, "AB04" },
-            { GLFW_KEY_B, "AB05" },
-            { GLFW_KEY_N, "AB06" },
-            { GLFW_KEY_M, "AB07" },
-            { GLFW_KEY_COMMA, "AB08" },
-            { GLFW_KEY_PERIOD, "AB09" },
-            { GLFW_KEY_SLASH, "AB10" },
-            { GLFW_KEY_BACKSLASH, "BKSL" },
-            { GLFW_KEY_WORLD_1, "LSGT" },
-            { GLFW_KEY_SPACE, "SPCE" },
-            { GLFW_KEY_ESCAPE, "ESC" },
-            { GLFW_KEY_ENTER, "RTRN" },
-            { GLFW_KEY_TAB, "TAB" },
-            { GLFW_KEY_BACKSPACE, "BKSP" },
-            { GLFW_KEY_INSERT, "INS" },
-            { GLFW_KEY_DELETE, "DELE" },
-            { GLFW_KEY_RIGHT, "RGHT" },
-            { GLFW_KEY_LEFT, "LEFT" },
-            { GLFW_KEY_DOWN, "DOWN" },
-            { GLFW_KEY_UP, "UP" },
-            { GLFW_KEY_PAGE_UP, "PGUP" },
-            { GLFW_KEY_PAGE_DOWN, "PGDN" },
-            { GLFW_KEY_HOME, "HOME" },
-            { GLFW_KEY_END, "END" },
-            { GLFW_KEY_CAPS_LOCK, "CAPS" },
-            { GLFW_KEY_SCROLL_LOCK, "SCLK" },
-            { GLFW_KEY_NUM_LOCK, "NMLK" },
-            { GLFW_KEY_PRINT_SCREEN, "PRSC" },
-            { GLFW_KEY_PAUSE, "PAUS" },
-            { GLFW_KEY_F1, "FK01" },
-            { GLFW_KEY_F2, "FK02" },
-            { GLFW_KEY_F3, "FK03" },
-            { GLFW_KEY_F4, "FK04" },
-            { GLFW_KEY_F5, "FK05" },
-            { GLFW_KEY_F6, "FK06" },
-            { GLFW_KEY_F7, "FK07" },
-            { GLFW_KEY_F8, "FK08" },
-            { GLFW_KEY_F9, "FK09" },
-            { GLFW_KEY_F10, "FK10" },
-            { GLFW_KEY_F11, "FK11" },
-            { GLFW_KEY_F12, "FK12" },
-            { GLFW_KEY_F13, "FK13" },
-            { GLFW_KEY_F14, "FK14" },
-            { GLFW_KEY_F15, "FK15" },
-            { GLFW_KEY_F16, "FK16" },
-            { GLFW_KEY_F17, "FK17" },
-            { GLFW_KEY_F18, "FK18" },
-            { GLFW_KEY_F19, "FK19" },
-            { GLFW_KEY_F20, "FK20" },
-            { GLFW_KEY_F21, "FK21" },
-            { GLFW_KEY_F22, "FK22" },
-            { GLFW_KEY_F23, "FK23" },
-            { GLFW_KEY_F24, "FK24" },
-            { GLFW_KEY_F25, "FK25" },
-            { GLFW_KEY_KP_0, "KP0" },
-            { GLFW_KEY_KP_1, "KP1" },
-            { GLFW_KEY_KP_2, "KP2" },
-            { GLFW_KEY_KP_3, "KP3" },
-            { GLFW_KEY_KP_4, "KP4" },
-            { GLFW_KEY_KP_5, "KP5" },
-            { GLFW_KEY_KP_6, "KP6" },
-            { GLFW_KEY_KP_7, "KP7" },
-            { GLFW_KEY_KP_8, "KP8" },
-            { GLFW_KEY_KP_9, "KP9" },
-            { GLFW_KEY_KP_DECIMAL, "KPDL" },
-            { GLFW_KEY_KP_DIVIDE, "KPDV" },
-            { GLFW_KEY_KP_MULTIPLY, "KPMU" },
-            { GLFW_KEY_KP_SUBTRACT, "KPSU" },
-            { GLFW_KEY_KP_ADD, "KPAD" },
-            { GLFW_KEY_KP_ENTER, "KPEN" },
-            { GLFW_KEY_KP_EQUAL, "KPEQ" },
-            { GLFW_KEY_LEFT_SHIFT, "LFSH" },
-            { GLFW_KEY_LEFT_CONTROL, "LCTL" },
-            { GLFW_KEY_LEFT_ALT, "LALT" },
-            { GLFW_KEY_LEFT_SUPER, "LWIN" },
-            { GLFW_KEY_RIGHT_SHIFT, "RTSH" },
-            { GLFW_KEY_RIGHT_CONTROL, "RCTL" },
-            { GLFW_KEY_RIGHT_ALT, "RALT" },
-            { GLFW_KEY_RIGHT_ALT, "LVL3" },
-            { GLFW_KEY_RIGHT_ALT, "MDSW" },
-            { GLFW_KEY_RIGHT_SUPER, "RWIN" },
-            { GLFW_KEY_MENU, "MENU" }
-        };
-
-        // Find the X11 key code -> GLFW key code mapping
-        for (scancode = scancodeMin;  scancode <= scancodeMax;  scancode++)
-        {
-            int key = GLFW_KEY_UNKNOWN;
-
-            // Map the key name to a GLFW key code. Note: We use the US
-            // keyboard layout. Because function keys aren't mapped correctly
-            // when using traditional KeySym translations, they are mapped
-            // here instead.
-            for (int i = 0;  i < sizeof(keymap) / sizeof(keymap[0]);  i++)
-            {
-                if (strncmp(desc->names->keys[scancode].name,
-                            keymap[i].name,
-                            XkbKeyNameLength) == 0)
-                {
-                    key = keymap[i].key;
-                    break;
-                }
-            }
-
-            // Fall back to key aliases in case the key name did not match
-            for (int i = 0;  i < desc->names->num_key_aliases;  i++)
-            {
-                if (key != GLFW_KEY_UNKNOWN)
-                    break;
-
-                if (strncmp(desc->names->key_aliases[i].real,
-                            desc->names->keys[scancode].name,
-                            XkbKeyNameLength) != 0)
-                {
-                    continue;
-                }
-
-                for (int j = 0;  j < sizeof(keymap) / sizeof(keymap[0]);  j++)
-                {
-                    if (strncmp(desc->names->key_aliases[i].alias,
-                                keymap[j].name,
-                                XkbKeyNameLength) == 0)
-                    {
-                        key = keymap[j].key;
-                        break;
-                    }
-                }
-            }
-
-            _glfw.x11.keycodes[scancode] = key;
-        }
-
-        XkbFreeNames(desc, XkbKeyNamesMask, True);
-        XkbFreeKeyboard(desc, 0, True);
-    }
-    else
-        XDisplayKeycodes(_glfw.x11.display, &scancodeMin, &scancodeMax);
-
-    int width;
-    KeySym* keysyms = XGetKeyboardMapping(_glfw.x11.display,
-                                          scancodeMin,
-                                          scancodeMax - scancodeMin + 1,
-                                          &width);
-
-    for (scancode = scancodeMin;  scancode <= scancodeMax;  scancode++)
-    {
-        // Translate the un-translated key codes using traditional X11 KeySym
-        // lookups
-        if (_glfw.x11.keycodes[scancode] < 0)
-        {
-            const size_t base = (scancode - scancodeMin) * width;
-            _glfw.x11.keycodes[scancode] = translateKeySyms(&keysyms[base], width);
-        }
-
-        // Store the reverse translation for faster key name lookup
-        if (_glfw.x11.keycodes[scancode] > 0)
-            _glfw.x11.scancodes[_glfw.x11.keycodes[scancode]] = scancode;
-    }
-
-    XFree(keysyms);
-}
-
-// Check whether the IM has a usable style
-//
-static GLFWbool hasUsableInputMethodStyle(void)
-{
-    GLFWbool found = GLFW_FALSE;
-    XIMStyles* styles = NULL;
-
-    if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
-        return GLFW_FALSE;
-
-    for (unsigned int i = 0;  i < styles->count_styles;  i++)
-    {
-        if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
-        {
-            found = GLFW_TRUE;
-            break;
-        }
-    }
-
-    XFree(styles);
-    return found;
-}
-
-static void inputMethodDestroyCallback(XIM im, XPointer clientData, XPointer callData)
-{
-    _glfw.x11.im = NULL;
-}
-
-static void inputMethodInstantiateCallback(Display* display,
-                                           XPointer clientData,
-                                           XPointer callData)
-{
-    if (_glfw.x11.im)
-        return;
-
-    _glfw.x11.im = XOpenIM(_glfw.x11.display, 0, NULL, NULL);
-    if (_glfw.x11.im)
-    {
-        if (!hasUsableInputMethodStyle())
-        {
-            XCloseIM(_glfw.x11.im);
-            _glfw.x11.im = NULL;
-        }
-    }
-
-    if (_glfw.x11.im)
-    {
-        XIMCallback callback;
-        callback.callback = (XIMProc) inputMethodDestroyCallback;
-        callback.client_data = NULL;
-        XSetIMValues(_glfw.x11.im, XNDestroyCallback, &callback, NULL);
-
-        for (_GLFWwindow* window = _glfw.windowListHead;  window;  window = window->next)
-            _glfwCreateInputContextX11(window);
-    }
-}
-
-// Return the atom ID only if it is listed in the specified array
-//
-static Atom getAtomIfSupported(Atom* supportedAtoms,
-                               unsigned long atomCount,
-                               const char* atomName)
-{
-    const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
-
-    for (unsigned long i = 0;  i < atomCount;  i++)
-    {
-        if (supportedAtoms[i] == atom)
-            return atom;
-    }
-
-    return None;
-}
-
-// Check whether the running window manager is EWMH-compliant
-//
-static void detectEWMH(void)
-{
-    // First we read the _NET_SUPPORTING_WM_CHECK property on the root window
-
-    Window* windowFromRoot = NULL;
-    if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
-                                   _glfw.x11.NET_SUPPORTING_WM_CHECK,
-                                   XA_WINDOW,
-                                   (unsigned char**) &windowFromRoot))
-    {
-        return;
-    }
-
-    _glfwGrabErrorHandlerX11();
-
-    // If it exists, it should be the XID of a top-level window
-    // Then we look for the same property on that window
-
-    Window* windowFromChild = NULL;
-    if (!_glfwGetWindowPropertyX11(*windowFromRoot,
-                                   _glfw.x11.NET_SUPPORTING_WM_CHECK,
-                                   XA_WINDOW,
-                                   (unsigned char**) &windowFromChild))
-    {
-        XFree(windowFromRoot);
-        return;
-    }
-
-    _glfwReleaseErrorHandlerX11();
-
-    // If the property exists, it should contain the XID of the window
-
-    if (*windowFromRoot != *windowFromChild)
-    {
-        XFree(windowFromRoot);
-        XFree(windowFromChild);
-        return;
-    }
-
-    XFree(windowFromRoot);
-    XFree(windowFromChild);
-
-    // We are now fairly sure that an EWMH-compliant WM is currently running
-    // We can now start querying the WM about what features it supports by
-    // looking in the _NET_SUPPORTED property on the root window
-    // It should contain a list of supported EWMH protocol and state atoms
-
-    Atom* supportedAtoms = NULL;
-    const unsigned long atomCount =
-        _glfwGetWindowPropertyX11(_glfw.x11.root,
-                                  _glfw.x11.NET_SUPPORTED,
-                                  XA_ATOM,
-                                  (unsigned char**) &supportedAtoms);
-
-    // See which of the atoms we support that are supported by the WM
-
-    _glfw.x11.NET_WM_STATE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE");
-    _glfw.x11.NET_WM_STATE_ABOVE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_ABOVE");
-    _glfw.x11.NET_WM_STATE_FULLSCREEN =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
-    _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_VERT");
-    _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_MAXIMIZED_HORZ");
-    _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_STATE_DEMANDS_ATTENTION");
-    _glfw.x11.NET_WM_FULLSCREEN_MONITORS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_FULLSCREEN_MONITORS");
-    _glfw.x11.NET_WM_WINDOW_TYPE =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE");
-    _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WM_WINDOW_TYPE_NORMAL");
-    _glfw.x11.NET_WORKAREA =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_WORKAREA");
-    _glfw.x11.NET_CURRENT_DESKTOP =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_CURRENT_DESKTOP");
-    _glfw.x11.NET_ACTIVE_WINDOW =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
-    _glfw.x11.NET_FRAME_EXTENTS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_FRAME_EXTENTS");
-    _glfw.x11.NET_REQUEST_FRAME_EXTENTS =
-        getAtomIfSupported(supportedAtoms, atomCount, "_NET_REQUEST_FRAME_EXTENTS");
-
-    if (supportedAtoms)
-        XFree(supportedAtoms);
-}
-
-// Look for and initialize supported X11 extensions
-//
-static GLFWbool initExtensions(void)
-{
-    _glfw.x11.vidmode.handle = _glfw_dlopen("libXxf86vm.so.1");
-    if (_glfw.x11.vidmode.handle)
-    {
-        _glfw.x11.vidmode.QueryExtension = (PFN_XF86VidModeQueryExtension)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeQueryExtension");
-        _glfw.x11.vidmode.GetGammaRamp = (PFN_XF86VidModeGetGammaRamp)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRamp");
-        _glfw.x11.vidmode.SetGammaRamp = (PFN_XF86VidModeSetGammaRamp)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeSetGammaRamp");
-        _glfw.x11.vidmode.GetGammaRampSize = (PFN_XF86VidModeGetGammaRampSize)
-            _glfw_dlsym(_glfw.x11.vidmode.handle, "XF86VidModeGetGammaRampSize");
-
-        _glfw.x11.vidmode.available =
-            XF86VidModeQueryExtension(_glfw.x11.display,
-                                      &_glfw.x11.vidmode.eventBase,
-                                      &_glfw.x11.vidmode.errorBase);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xi.handle = _glfw_dlopen("libXi-6.so");
-#else
-    _glfw.x11.xi.handle = _glfw_dlopen("libXi.so.6");
-#endif
-    if (_glfw.x11.xi.handle)
-    {
-        _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion)
-            _glfw_dlsym(_glfw.x11.xi.handle, "XIQueryVersion");
-        _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents)
-            _glfw_dlsym(_glfw.x11.xi.handle, "XISelectEvents");
-
-        if (XQueryExtension(_glfw.x11.display,
-                            "XInputExtension",
-                            &_glfw.x11.xi.majorOpcode,
-                            &_glfw.x11.xi.eventBase,
-                            &_glfw.x11.xi.errorBase))
-        {
-            _glfw.x11.xi.major = 2;
-            _glfw.x11.xi.minor = 0;
-
-            if (XIQueryVersion(_glfw.x11.display,
-                               &_glfw.x11.xi.major,
-                               &_glfw.x11.xi.minor) == Success)
-            {
-                _glfw.x11.xi.available = GLFW_TRUE;
-            }
-        }
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.randr.handle = _glfw_dlopen("libXrandr-2.so");
-#else
-    _glfw.x11.randr.handle = _glfw_dlopen("libXrandr.so.2");
-#endif
-    if (_glfw.x11.randr.handle)
-    {
-        _glfw.x11.randr.AllocGamma = (PFN_XRRAllocGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRAllocGamma");
-        _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
-        _glfw.x11.randr.FreeCrtcInfo = (PFN_XRRFreeCrtcInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeCrtcInfo");
-        _glfw.x11.randr.FreeGamma = (PFN_XRRFreeGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeGamma");
-        _glfw.x11.randr.FreeOutputInfo = (PFN_XRRFreeOutputInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeOutputInfo");
-        _glfw.x11.randr.FreeScreenResources = (PFN_XRRFreeScreenResources)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRFreeScreenResources");
-        _glfw.x11.randr.GetCrtcGamma = (PFN_XRRGetCrtcGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGamma");
-        _glfw.x11.randr.GetCrtcGammaSize = (PFN_XRRGetCrtcGammaSize)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcGammaSize");
-        _glfw.x11.randr.GetCrtcInfo = (PFN_XRRGetCrtcInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetCrtcInfo");
-        _glfw.x11.randr.GetOutputInfo = (PFN_XRRGetOutputInfo)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputInfo");
-        _glfw.x11.randr.GetOutputPrimary = (PFN_XRRGetOutputPrimary)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetOutputPrimary");
-        _glfw.x11.randr.GetScreenResourcesCurrent = (PFN_XRRGetScreenResourcesCurrent)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRGetScreenResourcesCurrent");
-        _glfw.x11.randr.QueryExtension = (PFN_XRRQueryExtension)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryExtension");
-        _glfw.x11.randr.QueryVersion = (PFN_XRRQueryVersion)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRQueryVersion");
-        _glfw.x11.randr.SelectInput = (PFN_XRRSelectInput)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSelectInput");
-        _glfw.x11.randr.SetCrtcConfig = (PFN_XRRSetCrtcConfig)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcConfig");
-        _glfw.x11.randr.SetCrtcGamma = (PFN_XRRSetCrtcGamma)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRSetCrtcGamma");
-        _glfw.x11.randr.UpdateConfiguration = (PFN_XRRUpdateConfiguration)
-            _glfw_dlsym(_glfw.x11.randr.handle, "XRRUpdateConfiguration");
-
-        if (XRRQueryExtension(_glfw.x11.display,
-                              &_glfw.x11.randr.eventBase,
-                              &_glfw.x11.randr.errorBase))
-        {
-            if (XRRQueryVersion(_glfw.x11.display,
-                                &_glfw.x11.randr.major,
-                                &_glfw.x11.randr.minor))
-            {
-                // The GLFW RandR path requires at least version 1.3
-                if (_glfw.x11.randr.major > 1 || _glfw.x11.randr.minor >= 3)
-                    _glfw.x11.randr.available = GLFW_TRUE;
-            }
-            else
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "X11: Failed to query RandR version");
-            }
-        }
-    }
-
-    if (_glfw.x11.randr.available)
-    {
-        XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
-                                                              _glfw.x11.root);
-
-        if (!sr->ncrtc || !XRRGetCrtcGammaSize(_glfw.x11.display, sr->crtcs[0]))
-        {
-            // This is likely an older Nvidia driver with broken gamma support
-            // Flag it as useless and fall back to xf86vm gamma, if available
-            _glfw.x11.randr.gammaBroken = GLFW_TRUE;
-        }
-
-        if (!sr->ncrtc)
-        {
-            // A system without CRTCs is likely a system with broken RandR
-            // Disable the RandR monitor path and fall back to core functions
-            _glfw.x11.randr.monitorBroken = GLFW_TRUE;
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRSelectInput(_glfw.x11.display, _glfw.x11.root,
-                       RROutputChangeNotifyMask);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor-1.so");
-#else
-    _glfw.x11.xcursor.handle = _glfw_dlopen("libXcursor.so.1");
-#endif
-    if (_glfw.x11.xcursor.handle)
-    {
-        _glfw.x11.xcursor.ImageCreate = (PFN_XcursorImageCreate)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageCreate");
-        _glfw.x11.xcursor.ImageDestroy = (PFN_XcursorImageDestroy)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
-        _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
-        _glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme");
-        _glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
-        _glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
-            _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama-1.so");
-#else
-    _glfw.x11.xinerama.handle = _glfw_dlopen("libXinerama.so.1");
-#endif
-    if (_glfw.x11.xinerama.handle)
-    {
-        _glfw.x11.xinerama.IsActive = (PFN_XineramaIsActive)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaIsActive");
-        _glfw.x11.xinerama.QueryExtension = (PFN_XineramaQueryExtension)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryExtension");
-        _glfw.x11.xinerama.QueryScreens = (PFN_XineramaQueryScreens)
-            _glfw_dlsym(_glfw.x11.xinerama.handle, "XineramaQueryScreens");
-
-        if (XineramaQueryExtension(_glfw.x11.display,
-                                   &_glfw.x11.xinerama.major,
-                                   &_glfw.x11.xinerama.minor))
-        {
-            if (XineramaIsActive(_glfw.x11.display))
-                _glfw.x11.xinerama.available = GLFW_TRUE;
-        }
-    }
-
-    _glfw.x11.xkb.major = 1;
-    _glfw.x11.xkb.minor = 0;
-    _glfw.x11.xkb.available =
-        XkbQueryExtension(_glfw.x11.display,
-                          &_glfw.x11.xkb.majorOpcode,
-                          &_glfw.x11.xkb.eventBase,
-                          &_glfw.x11.xkb.errorBase,
-                          &_glfw.x11.xkb.major,
-                          &_glfw.x11.xkb.minor);
-
-    if (_glfw.x11.xkb.available)
-    {
-        Bool supported;
-
-        if (XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
-        {
-            if (supported)
-                _glfw.x11.xkb.detectable = GLFW_TRUE;
-        }
-
-        XkbStateRec state;
-        if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
-            _glfw.x11.xkb.group = (unsigned int)state.group;
-
-        XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify,
-                              XkbGroupStateMask, XkbGroupStateMask);
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb-1.so");
-#else
-    _glfw.x11.x11xcb.handle = _glfw_dlopen("libX11-xcb.so.1");
-#endif
-    if (_glfw.x11.x11xcb.handle)
-    {
-        _glfw.x11.x11xcb.GetXCBConnection = (PFN_XGetXCBConnection)
-            _glfw_dlsym(_glfw.x11.x11xcb.handle, "XGetXCBConnection");
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xrender.handle = _glfw_dlopen("libXrender-1.so");
-#else
-    _glfw.x11.xrender.handle = _glfw_dlopen("libXrender.so.1");
-#endif
-    if (_glfw.x11.xrender.handle)
-    {
-        _glfw.x11.xrender.QueryExtension = (PFN_XRenderQueryExtension)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryExtension");
-        _glfw.x11.xrender.QueryVersion = (PFN_XRenderQueryVersion)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderQueryVersion");
-        _glfw.x11.xrender.FindVisualFormat = (PFN_XRenderFindVisualFormat)
-            _glfw_dlsym(_glfw.x11.xrender.handle, "XRenderFindVisualFormat");
-
-        if (XRenderQueryExtension(_glfw.x11.display,
-                                  &_glfw.x11.xrender.errorBase,
-                                  &_glfw.x11.xrender.eventBase))
-        {
-            if (XRenderQueryVersion(_glfw.x11.display,
-                                    &_glfw.x11.xrender.major,
-                                    &_glfw.x11.xrender.minor))
-            {
-                _glfw.x11.xrender.available = GLFW_TRUE;
-            }
-        }
-    }
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xshape.handle = _glfw_dlopen("libXext-6.so");
-#else
-    _glfw.x11.xshape.handle = _glfw_dlopen("libXext.so.6");
-#endif
-    if (_glfw.x11.xshape.handle)
-    {
-        _glfw.x11.xshape.QueryExtension = (PFN_XShapeQueryExtension)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryExtension");
-        _glfw.x11.xshape.ShapeCombineRegion = (PFN_XShapeCombineRegion)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineRegion");
-        _glfw.x11.xshape.QueryVersion = (PFN_XShapeQueryVersion)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeQueryVersion");
-        _glfw.x11.xshape.ShapeCombineMask = (PFN_XShapeCombineMask)
-            _glfw_dlsym(_glfw.x11.xshape.handle, "XShapeCombineMask");
-
-        if (XShapeQueryExtension(_glfw.x11.display,
-            &_glfw.x11.xshape.errorBase,
-            &_glfw.x11.xshape.eventBase))
-        {
-            if (XShapeQueryVersion(_glfw.x11.display,
-                &_glfw.x11.xshape.major,
-                &_glfw.x11.xshape.minor))
-            {
-                _glfw.x11.xshape.available = GLFW_TRUE;
-            }
-        }
-    }
-
-    // Update the key code LUT
-    // FIXME: We should listen to XkbMapNotify events to track changes to
-    // the keyboard mapping.
-    createKeyTables();
-
-    // String format atoms
-    _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
-    _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
-    _glfw.x11.ATOM_PAIR = XInternAtom(_glfw.x11.display, "ATOM_PAIR", False);
-
-    // Custom selection property atom
-    _glfw.x11.GLFW_SELECTION =
-        XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
-
-    // ICCCM standard clipboard atoms
-    _glfw.x11.TARGETS = XInternAtom(_glfw.x11.display, "TARGETS", False);
-    _glfw.x11.MULTIPLE = XInternAtom(_glfw.x11.display, "MULTIPLE", False);
-    _glfw.x11.PRIMARY = XInternAtom(_glfw.x11.display, "PRIMARY", False);
-    _glfw.x11.INCR = XInternAtom(_glfw.x11.display, "INCR", False);
-    _glfw.x11.CLIPBOARD = XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
-
-    // Clipboard manager atoms
-    _glfw.x11.CLIPBOARD_MANAGER =
-        XInternAtom(_glfw.x11.display, "CLIPBOARD_MANAGER", False);
-    _glfw.x11.SAVE_TARGETS =
-        XInternAtom(_glfw.x11.display, "SAVE_TARGETS", False);
-
-    // Xdnd (drag and drop) atoms
-    _glfw.x11.XdndAware = XInternAtom(_glfw.x11.display, "XdndAware", False);
-    _glfw.x11.XdndEnter = XInternAtom(_glfw.x11.display, "XdndEnter", False);
-    _glfw.x11.XdndPosition = XInternAtom(_glfw.x11.display, "XdndPosition", False);
-    _glfw.x11.XdndStatus = XInternAtom(_glfw.x11.display, "XdndStatus", False);
-    _glfw.x11.XdndActionCopy = XInternAtom(_glfw.x11.display, "XdndActionCopy", False);
-    _glfw.x11.XdndDrop = XInternAtom(_glfw.x11.display, "XdndDrop", False);
-    _glfw.x11.XdndFinished = XInternAtom(_glfw.x11.display, "XdndFinished", False);
-    _glfw.x11.XdndSelection = XInternAtom(_glfw.x11.display, "XdndSelection", False);
-    _glfw.x11.XdndTypeList = XInternAtom(_glfw.x11.display, "XdndTypeList", False);
-    _glfw.x11.text_uri_list = XInternAtom(_glfw.x11.display, "text/uri-list", False);
-
-    // ICCCM, EWMH and Motif window property atoms
-    // These can be set safely even without WM support
-    // The EWMH atoms that require WM support are handled in detectEWMH
-    _glfw.x11.WM_PROTOCOLS =
-        XInternAtom(_glfw.x11.display, "WM_PROTOCOLS", False);
-    _glfw.x11.WM_STATE =
-        XInternAtom(_glfw.x11.display, "WM_STATE", False);
-    _glfw.x11.WM_DELETE_WINDOW =
-        XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
-    _glfw.x11.NET_SUPPORTED =
-        XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
-    _glfw.x11.NET_SUPPORTING_WM_CHECK =
-        XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
-    _glfw.x11.NET_WM_ICON =
-        XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
-    _glfw.x11.NET_WM_PING =
-        XInternAtom(_glfw.x11.display, "_NET_WM_PING", False);
-    _glfw.x11.NET_WM_PID =
-        XInternAtom(_glfw.x11.display, "_NET_WM_PID", False);
-    _glfw.x11.NET_WM_NAME =
-        XInternAtom(_glfw.x11.display, "_NET_WM_NAME", False);
-    _glfw.x11.NET_WM_ICON_NAME =
-        XInternAtom(_glfw.x11.display, "_NET_WM_ICON_NAME", False);
-    _glfw.x11.NET_WM_BYPASS_COMPOSITOR =
-        XInternAtom(_glfw.x11.display, "_NET_WM_BYPASS_COMPOSITOR", False);
-    _glfw.x11.NET_WM_WINDOW_OPACITY =
-        XInternAtom(_glfw.x11.display, "_NET_WM_WINDOW_OPACITY", False);
-    _glfw.x11.MOTIF_WM_HINTS =
-        XInternAtom(_glfw.x11.display, "_MOTIF_WM_HINTS", False);
-
-    // The compositing manager selection name contains the screen number
-    {
-        char name[32];
-        snprintf(name, sizeof(name), "_NET_WM_CM_S%u", _glfw.x11.screen);
-        _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
-    }
-
-    // Detect whether an EWMH-conformant window manager is running
-    detectEWMH();
-
-    return GLFW_TRUE;
-}
-
-// Retrieve system content scale via folklore heuristics
-//
-static void getSystemContentScale(float* xscale, float* yscale)
-{
-    // Start by assuming the default X11 DPI
-    // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
-    //       would be set to 96, so assume that is the case if we cannot find it
-    float xdpi = 96.f, ydpi = 96.f;
-
-    // NOTE: Basing the scale on Xft.dpi where available should provide the most
-    //       consistent user experience (matches Qt, Gtk, etc), although not
-    //       always the most accurate one
-    char* rms = XResourceManagerString(_glfw.x11.display);
-    if (rms)
-    {
-        XrmDatabase db = XrmGetStringDatabase(rms);
-        if (db)
-        {
-            XrmValue value;
-            char* type = NULL;
-
-            if (XrmGetResource(db, "Xft.dpi", "Xft.Dpi", &type, &value))
-            {
-                if (type && strcmp(type, "String") == 0)
-                    xdpi = ydpi = atof(value.addr);
-            }
-
-            XrmDestroyDatabase(db);
-        }
-    }
-
-    *xscale = xdpi / 96.f;
-    *yscale = ydpi / 96.f;
-}
-
-// Create a blank cursor for hidden and disabled cursor modes
-//
-static Cursor createHiddenCursor(void)
-{
-    unsigned char pixels[16 * 16 * 4] = { 0 };
-    GLFWimage image = { 16, 16, pixels };
-    return _glfwCreateCursorX11(&image, 0, 0);
-}
-
-// Create a helper window for IPC
-//
-static Window createHelperWindow(void)
-{
-    XSetWindowAttributes wa;
-    wa.event_mask = PropertyChangeMask;
-
-    return XCreateWindow(_glfw.x11.display, _glfw.x11.root,
-                         0, 0, 1, 1, 0, 0,
-                         InputOnly,
-                         DefaultVisual(_glfw.x11.display, _glfw.x11.screen),
-                         CWEventMask, &wa);
-}
-
-// X error handler
-//
-static int errorHandler(Display *display, XErrorEvent* event)
-{
-    if (_glfw.x11.display != display)
-        return 0;
-
-    _glfw.x11.errorCode = event->error_code;
-    return 0;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Sets the X error handler callback
-//
-void _glfwGrabErrorHandlerX11(void)
-{
-    _glfw.x11.errorCode = Success;
-    XSetErrorHandler(errorHandler);
-}
-
-// Clears the X error handler callback
-//
-void _glfwReleaseErrorHandlerX11(void)
-{
-    // Synchronize to make sure all commands are processed
-    XSync(_glfw.x11.display, False);
-    XSetErrorHandler(NULL);
-}
-
-// Reports the specified error, appending information about the last X error
-//
-void _glfwInputErrorX11(int error, const char* message)
-{
-    char buffer[_GLFW_MESSAGE_SIZE];
-    XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
-                  buffer, sizeof(buffer));
-
-    _glfwInputError(error, "%s: %s", message, buffer);
-}
-
-// Creates a native cursor object from the specified image and hotspot
-//
-Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
-{
-    int i;
-    Cursor cursor;
-
-    if (!_glfw.x11.xcursor.handle)
-        return None;
-
-    XcursorImage* native = XcursorImageCreate(image->width, image->height);
-    if (native == NULL)
-        return None;
-
-    native->xhot = xhot;
-    native->yhot = yhot;
-
-    unsigned char* source = (unsigned char*) image->pixels;
-    XcursorPixel* target = native->pixels;
-
-    for (i = 0;  i < image->width * image->height;  i++, target++, source += 4)
-    {
-        unsigned int alpha = source[3];
-
-        *target = (alpha << 24) |
-                  ((unsigned char) ((source[0] * alpha) / 255) << 16) |
-                  ((unsigned char) ((source[1] * alpha) / 255) <<  8) |
-                  ((unsigned char) ((source[2] * alpha) / 255) <<  0);
-    }
-
-    cursor = XcursorImageLoadCursor(_glfw.x11.display, native);
-    XcursorImageDestroy(native);
-
-    return cursor;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformInit(void)
-{
-    // HACK: If the application has left the locale as "C" then both wide
-    //       character text input and explicit UTF-8 input via XIM will break
-    //       This sets the CTYPE part of the current locale from the environment
-    //       in the hope that it is set to something more sane than "C"
-    if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0)
-        setlocale(LC_CTYPE, "");
-
-#if defined(__CYGWIN__)
-    _glfw.x11.xlib.handle = _glfw_dlopen("libX11-6.so");
-#else
-    _glfw.x11.xlib.handle = _glfw_dlopen("libX11.so.6");
-#endif
-    if (!_glfw.x11.xlib.handle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR, "X11: Failed to load Xlib");
-        return GLFW_FALSE;
-    }
-
-    _glfw.x11.xlib.AllocClassHint = (PFN_XAllocClassHint)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocClassHint");
-    _glfw.x11.xlib.AllocSizeHints = (PFN_XAllocSizeHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocSizeHints");
-    _glfw.x11.xlib.AllocWMHints = (PFN_XAllocWMHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XAllocWMHints");
-    _glfw.x11.xlib.ChangeProperty = (PFN_XChangeProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeProperty");
-    _glfw.x11.xlib.ChangeWindowAttributes = (PFN_XChangeWindowAttributes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XChangeWindowAttributes");
-    _glfw.x11.xlib.CheckIfEvent = (PFN_XCheckIfEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckIfEvent");
-    _glfw.x11.xlib.CheckTypedWindowEvent = (PFN_XCheckTypedWindowEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCheckTypedWindowEvent");
-    _glfw.x11.xlib.CloseDisplay = (PFN_XCloseDisplay)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseDisplay");
-    _glfw.x11.xlib.CloseIM = (PFN_XCloseIM)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCloseIM");
-    _glfw.x11.xlib.ConvertSelection = (PFN_XConvertSelection)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XConvertSelection");
-    _glfw.x11.xlib.CreateColormap = (PFN_XCreateColormap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateColormap");
-    _glfw.x11.xlib.CreateFontCursor = (PFN_XCreateFontCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateFontCursor");
-    _glfw.x11.xlib.CreateIC = (PFN_XCreateIC)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateIC");
-    _glfw.x11.xlib.CreateRegion = (PFN_XCreateRegion)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateRegion");
-    _glfw.x11.xlib.CreateWindow = (PFN_XCreateWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XCreateWindow");
-    _glfw.x11.xlib.DefineCursor = (PFN_XDefineCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDefineCursor");
-    _glfw.x11.xlib.DeleteContext = (PFN_XDeleteContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteContext");
-    _glfw.x11.xlib.DeleteProperty = (PFN_XDeleteProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDeleteProperty");
-    _glfw.x11.xlib.DestroyIC = (PFN_XDestroyIC)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyIC");
-    _glfw.x11.xlib.DestroyRegion = (PFN_XDestroyRegion)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyRegion");
-    _glfw.x11.xlib.DestroyWindow = (PFN_XDestroyWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDestroyWindow");
-    _glfw.x11.xlib.DisplayKeycodes = (PFN_XDisplayKeycodes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XDisplayKeycodes");
-    _glfw.x11.xlib.EventsQueued = (PFN_XEventsQueued)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XEventsQueued");
-    _glfw.x11.xlib.FilterEvent = (PFN_XFilterEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFilterEvent");
-    _glfw.x11.xlib.FindContext = (PFN_XFindContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFindContext");
-    _glfw.x11.xlib.Flush = (PFN_XFlush)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFlush");
-    _glfw.x11.xlib.Free = (PFN_XFree)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFree");
-    _glfw.x11.xlib.FreeColormap = (PFN_XFreeColormap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeColormap");
-    _glfw.x11.xlib.FreeCursor = (PFN_XFreeCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeCursor");
-    _glfw.x11.xlib.FreeEventData = (PFN_XFreeEventData)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XFreeEventData");
-    _glfw.x11.xlib.GetErrorText = (PFN_XGetErrorText)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetErrorText");
-    _glfw.x11.xlib.GetEventData = (PFN_XGetEventData)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetEventData");
-    _glfw.x11.xlib.GetICValues = (PFN_XGetICValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetICValues");
-    _glfw.x11.xlib.GetIMValues = (PFN_XGetIMValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetIMValues");
-    _glfw.x11.xlib.GetInputFocus = (PFN_XGetInputFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetInputFocus");
-    _glfw.x11.xlib.GetKeyboardMapping = (PFN_XGetKeyboardMapping)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetKeyboardMapping");
-    _glfw.x11.xlib.GetScreenSaver = (PFN_XGetScreenSaver)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetScreenSaver");
-    _glfw.x11.xlib.GetSelectionOwner = (PFN_XGetSelectionOwner)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetSelectionOwner");
-    _glfw.x11.xlib.GetVisualInfo = (PFN_XGetVisualInfo)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetVisualInfo");
-    _glfw.x11.xlib.GetWMNormalHints = (PFN_XGetWMNormalHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWMNormalHints");
-    _glfw.x11.xlib.GetWindowAttributes = (PFN_XGetWindowAttributes)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowAttributes");
-    _glfw.x11.xlib.GetWindowProperty = (PFN_XGetWindowProperty)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGetWindowProperty");
-    _glfw.x11.xlib.GrabPointer = (PFN_XGrabPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XGrabPointer");
-    _glfw.x11.xlib.IconifyWindow = (PFN_XIconifyWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XIconifyWindow");
-    _glfw.x11.xlib.InitThreads = (PFN_XInitThreads)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XInitThreads");
-    _glfw.x11.xlib.InternAtom = (PFN_XInternAtom)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XInternAtom");
-    _glfw.x11.xlib.LookupString = (PFN_XLookupString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XLookupString");
-    _glfw.x11.xlib.MapRaised = (PFN_XMapRaised)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMapRaised");
-    _glfw.x11.xlib.MapWindow = (PFN_XMapWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMapWindow");
-    _glfw.x11.xlib.MoveResizeWindow = (PFN_XMoveResizeWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveResizeWindow");
-    _glfw.x11.xlib.MoveWindow = (PFN_XMoveWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XMoveWindow");
-    _glfw.x11.xlib.NextEvent = (PFN_XNextEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XNextEvent");
-    _glfw.x11.xlib.OpenDisplay = (PFN_XOpenDisplay)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenDisplay");
-    _glfw.x11.xlib.OpenIM = (PFN_XOpenIM)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XOpenIM");
-    _glfw.x11.xlib.PeekEvent = (PFN_XPeekEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XPeekEvent");
-    _glfw.x11.xlib.Pending = (PFN_XPending)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XPending");
-    _glfw.x11.xlib.QueryExtension = (PFN_XQueryExtension)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryExtension");
-    _glfw.x11.xlib.QueryPointer = (PFN_XQueryPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XQueryPointer");
-    _glfw.x11.xlib.RaiseWindow = (PFN_XRaiseWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XRaiseWindow");
-    _glfw.x11.xlib.RegisterIMInstantiateCallback = (PFN_XRegisterIMInstantiateCallback)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XRegisterIMInstantiateCallback");
-    _glfw.x11.xlib.ResizeWindow = (PFN_XResizeWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XResizeWindow");
-    _glfw.x11.xlib.ResourceManagerString = (PFN_XResourceManagerString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XResourceManagerString");
-    _glfw.x11.xlib.SaveContext = (PFN_XSaveContext)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSaveContext");
-    _glfw.x11.xlib.SelectInput = (PFN_XSelectInput)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSelectInput");
-    _glfw.x11.xlib.SendEvent = (PFN_XSendEvent)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSendEvent");
-    _glfw.x11.xlib.SetClassHint = (PFN_XSetClassHint)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetClassHint");
-    _glfw.x11.xlib.SetErrorHandler = (PFN_XSetErrorHandler)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetErrorHandler");
-    _glfw.x11.xlib.SetICFocus = (PFN_XSetICFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetICFocus");
-    _glfw.x11.xlib.SetIMValues = (PFN_XSetIMValues)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetIMValues");
-    _glfw.x11.xlib.SetInputFocus = (PFN_XSetInputFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetInputFocus");
-    _glfw.x11.xlib.SetLocaleModifiers = (PFN_XSetLocaleModifiers)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetLocaleModifiers");
-    _glfw.x11.xlib.SetScreenSaver = (PFN_XSetScreenSaver)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetScreenSaver");
-    _glfw.x11.xlib.SetSelectionOwner = (PFN_XSetSelectionOwner)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetSelectionOwner");
-    _glfw.x11.xlib.SetWMHints = (PFN_XSetWMHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMHints");
-    _glfw.x11.xlib.SetWMNormalHints = (PFN_XSetWMNormalHints)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMNormalHints");
-    _glfw.x11.xlib.SetWMProtocols = (PFN_XSetWMProtocols)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSetWMProtocols");
-    _glfw.x11.xlib.SupportsLocale = (PFN_XSupportsLocale)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSupportsLocale");
-    _glfw.x11.xlib.Sync = (PFN_XSync)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XSync");
-    _glfw.x11.xlib.TranslateCoordinates = (PFN_XTranslateCoordinates)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XTranslateCoordinates");
-    _glfw.x11.xlib.UndefineCursor = (PFN_XUndefineCursor)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUndefineCursor");
-    _glfw.x11.xlib.UngrabPointer = (PFN_XUngrabPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUngrabPointer");
-    _glfw.x11.xlib.UnmapWindow = (PFN_XUnmapWindow)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnmapWindow");
-    _glfw.x11.xlib.UnsetICFocus = (PFN_XUnsetICFocus)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnsetICFocus");
-    _glfw.x11.xlib.VisualIDFromVisual = (PFN_XVisualIDFromVisual)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XVisualIDFromVisual");
-    _glfw.x11.xlib.WarpPointer = (PFN_XWarpPointer)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XWarpPointer");
-    _glfw.x11.xkb.FreeKeyboard = (PFN_XkbFreeKeyboard)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeKeyboard");
-    _glfw.x11.xkb.FreeNames = (PFN_XkbFreeNames)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbFreeNames");
-    _glfw.x11.xkb.GetMap = (PFN_XkbGetMap)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetMap");
-    _glfw.x11.xkb.GetNames = (PFN_XkbGetNames)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetNames");
-    _glfw.x11.xkb.GetState = (PFN_XkbGetState)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbGetState");
-    _glfw.x11.xkb.KeycodeToKeysym = (PFN_XkbKeycodeToKeysym)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbKeycodeToKeysym");
-    _glfw.x11.xkb.QueryExtension = (PFN_XkbQueryExtension)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbQueryExtension");
-    _glfw.x11.xkb.SelectEventDetails = (PFN_XkbSelectEventDetails)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSelectEventDetails");
-    _glfw.x11.xkb.SetDetectableAutoRepeat = (PFN_XkbSetDetectableAutoRepeat)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XkbSetDetectableAutoRepeat");
-    _glfw.x11.xrm.DestroyDatabase = (PFN_XrmDestroyDatabase)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmDestroyDatabase");
-    _glfw.x11.xrm.GetResource = (PFN_XrmGetResource)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetResource");
-    _glfw.x11.xrm.GetStringDatabase = (PFN_XrmGetStringDatabase)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmGetStringDatabase");
-    _glfw.x11.xrm.Initialize = (PFN_XrmInitialize)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmInitialize");
-    _glfw.x11.xrm.UniqueQuark = (PFN_XrmUniqueQuark)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XrmUniqueQuark");
-    _glfw.x11.xlib.UnregisterIMInstantiateCallback = (PFN_XUnregisterIMInstantiateCallback)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "XUnregisterIMInstantiateCallback");
-    _glfw.x11.xlib.utf8LookupString = (PFN_Xutf8LookupString)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8LookupString");
-    _glfw.x11.xlib.utf8SetWMProperties = (PFN_Xutf8SetWMProperties)
-        _glfw_dlsym(_glfw.x11.xlib.handle, "Xutf8SetWMProperties");
-
-    if (_glfw.x11.xlib.utf8LookupString && _glfw.x11.xlib.utf8SetWMProperties)
-        _glfw.x11.xlib.utf8 = GLFW_TRUE;
-
-    XInitThreads();
-    XrmInitialize();
-
-    _glfw.x11.display = XOpenDisplay(NULL);
-    if (!_glfw.x11.display)
-    {
-        const char* display = getenv("DISPLAY");
-        if (display)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to open display %s", display);
-        }
-        else
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: The DISPLAY environment variable is missing");
-        }
-
-        return GLFW_FALSE;
-    }
-
-    _glfw.x11.screen = DefaultScreen(_glfw.x11.display);
-    _glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
-    _glfw.x11.context = XUniqueContext();
-
-    getSystemContentScale(&_glfw.x11.contentScaleX, &_glfw.x11.contentScaleY);
-
-    if (!initExtensions())
-        return GLFW_FALSE;
-
-    _glfw.x11.helperWindowHandle = createHelperWindow();
-    _glfw.x11.hiddenCursorHandle = createHiddenCursor();
-
-    if (XSupportsLocale() && _glfw.x11.xlib.utf8)
-    {
-        XSetLocaleModifiers("");
-
-        // If an IM is already present our callback will be called right away
-        XRegisterIMInstantiateCallback(_glfw.x11.display,
-                                       NULL, NULL, NULL,
-                                       inputMethodInstantiateCallback,
-                                       NULL);
-    }
-
-    _glfwInitTimerPOSIX();
-
-    _glfwPollMonitorsX11();
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformTerminate(void)
-{
-    if (_glfw.x11.helperWindowHandle)
-    {
-        if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) ==
-            _glfw.x11.helperWindowHandle)
-        {
-            _glfwPushSelectionToManagerX11();
-        }
-
-        XDestroyWindow(_glfw.x11.display, _glfw.x11.helperWindowHandle);
-        _glfw.x11.helperWindowHandle = None;
-    }
-
-    if (_glfw.x11.hiddenCursorHandle)
-    {
-        XFreeCursor(_glfw.x11.display, _glfw.x11.hiddenCursorHandle);
-        _glfw.x11.hiddenCursorHandle = (Cursor) 0;
-    }
-
-    free(_glfw.x11.primarySelectionString);
-    free(_glfw.x11.clipboardString);
-
-    XUnregisterIMInstantiateCallback(_glfw.x11.display,
-                                     NULL, NULL, NULL,
-                                     inputMethodInstantiateCallback,
-                                     NULL);
-
-    if (_glfw.x11.im)
-    {
-        XCloseIM(_glfw.x11.im);
-        _glfw.x11.im = NULL;
-    }
-
-    if (_glfw.x11.display)
-    {
-        XCloseDisplay(_glfw.x11.display);
-        _glfw.x11.display = NULL;
-    }
-
-    if (_glfw.x11.x11xcb.handle)
-    {
-        _glfw_dlclose(_glfw.x11.x11xcb.handle);
-        _glfw.x11.x11xcb.handle = NULL;
-    }
-
-    if (_glfw.x11.xcursor.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xcursor.handle);
-        _glfw.x11.xcursor.handle = NULL;
-    }
-
-    if (_glfw.x11.randr.handle)
-    {
-        _glfw_dlclose(_glfw.x11.randr.handle);
-        _glfw.x11.randr.handle = NULL;
-    }
-
-    if (_glfw.x11.xinerama.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xinerama.handle);
-        _glfw.x11.xinerama.handle = NULL;
-    }
-
-    if (_glfw.x11.xrender.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xrender.handle);
-        _glfw.x11.xrender.handle = NULL;
-    }
-
-    if (_glfw.x11.vidmode.handle)
-    {
-        _glfw_dlclose(_glfw.x11.vidmode.handle);
-        _glfw.x11.vidmode.handle = NULL;
-    }
-
-    if (_glfw.x11.xi.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xi.handle);
-        _glfw.x11.xi.handle = NULL;
-    }
-
-    // NOTE: These need to be unloaded after XCloseDisplay, as they register
-    //       cleanup callbacks that get called by that function
-    _glfwTerminateEGL();
-    _glfwTerminateGLX();
-
-    if (_glfw.x11.xlib.handle)
-    {
-        _glfw_dlclose(_glfw.x11.xlib.handle);
-        _glfw.x11.xlib.handle = NULL;
-    }
-}
-
-const char* _glfwPlatformGetVersionString(void)
-{
-    return _GLFW_VERSION_NUMBER " X11 GLX EGL OSMesa"
-#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
-        " clock_gettime"
-#else
-        " gettimeofday"
-#endif
-#if defined(__linux__)
-        " evdev"
-#endif
-#if defined(_GLFW_BUILD_DLL)
-        " shared"
-#endif
-        ;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/x11_monitor.c b/raylib_pi4_test/external/glfw/src/x11_monitor.c
deleted file mode 100644 (file)
index 8de8659..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-
-// Check whether the display mode should be included in enumeration
-//
-static GLFWbool modeIsGood(const XRRModeInfo* mi)
-{
-    return (mi->modeFlags & RR_Interlace) == 0;
-}
-
-// Calculates the refresh rate, in Hz, from the specified RandR mode info
-//
-static int calculateRefreshRate(const XRRModeInfo* mi)
-{
-    if (mi->hTotal && mi->vTotal)
-        return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
-    else
-        return 0;
-}
-
-// Returns the mode info for a RandR mode XID
-//
-static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
-{
-    for (int i = 0;  i < sr->nmode;  i++)
-    {
-        if (sr->modes[i].id == id)
-            return sr->modes + i;
-    }
-
-    return NULL;
-}
-
-// Convert RandR mode info to GLFW video mode
-//
-static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
-                                       const XRRCrtcInfo* ci)
-{
-    GLFWvidmode mode;
-
-    if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-    {
-        mode.width  = mi->height;
-        mode.height = mi->width;
-    }
-    else
-    {
-        mode.width  = mi->width;
-        mode.height = mi->height;
-    }
-
-    mode.refreshRate = calculateRefreshRate(mi);
-
-    _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
-                  &mode.redBits, &mode.greenBits, &mode.blueBits);
-
-    return mode;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Poll for changes in the set of connected monitors
-//
-void _glfwPollMonitorsX11(void)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        int disconnectedCount, screenCount = 0;
-        _GLFWmonitor** disconnected = NULL;
-        XineramaScreenInfo* screens = NULL;
-        XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
-                                                              _glfw.x11.root);
-        RROutput primary = XRRGetOutputPrimary(_glfw.x11.display,
-                                               _glfw.x11.root);
-
-        if (_glfw.x11.xinerama.available)
-            screens = XineramaQueryScreens(_glfw.x11.display, &screenCount);
-
-        disconnectedCount = _glfw.monitorCount;
-        if (disconnectedCount)
-        {
-            disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
-            memcpy(disconnected,
-                   _glfw.monitors,
-                   _glfw.monitorCount * sizeof(_GLFWmonitor*));
-        }
-
-        for (int i = 0;  i < sr->noutput;  i++)
-        {
-            int j, type, widthMM, heightMM;
-
-            XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
-            if (oi->connection != RR_Connected || oi->crtc == None)
-            {
-                XRRFreeOutputInfo(oi);
-                continue;
-            }
-
-            for (j = 0;  j < disconnectedCount;  j++)
-            {
-                if (disconnected[j] &&
-                    disconnected[j]->x11.output == sr->outputs[i])
-                {
-                    disconnected[j] = NULL;
-                    break;
-                }
-            }
-
-            if (j < disconnectedCount)
-            {
-                XRRFreeOutputInfo(oi);
-                continue;
-            }
-
-            XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
-            if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-            {
-                widthMM  = oi->mm_height;
-                heightMM = oi->mm_width;
-            }
-            else
-            {
-                widthMM  = oi->mm_width;
-                heightMM = oi->mm_height;
-            }
-
-            if (widthMM <= 0 || heightMM <= 0)
-            {
-                // HACK: If RandR does not provide a physical size, assume the
-                //       X11 default 96 DPI and calculate from the CRTC viewport
-                // NOTE: These members are affected by rotation, unlike the mode
-                //       info and output info members
-                widthMM  = (int) (ci->width * 25.4f / 96.f);
-                heightMM = (int) (ci->height * 25.4f / 96.f);
-            }
-
-            _GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
-            monitor->x11.output = sr->outputs[i];
-            monitor->x11.crtc   = oi->crtc;
-
-            for (j = 0;  j < screenCount;  j++)
-            {
-                if (screens[j].x_org == ci->x &&
-                    screens[j].y_org == ci->y &&
-                    screens[j].width == ci->width &&
-                    screens[j].height == ci->height)
-                {
-                    monitor->x11.index = j;
-                    break;
-                }
-            }
-
-            if (monitor->x11.output == primary)
-                type = _GLFW_INSERT_FIRST;
-            else
-                type = _GLFW_INSERT_LAST;
-
-            _glfwInputMonitor(monitor, GLFW_CONNECTED, type);
-
-            XRRFreeOutputInfo(oi);
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-
-        if (screens)
-            XFree(screens);
-
-        for (int i = 0;  i < disconnectedCount;  i++)
-        {
-            if (disconnected[i])
-                _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
-        }
-
-        free(disconnected);
-    }
-    else
-    {
-        const int widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
-        const int heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
-
-        _glfwInputMonitor(_glfwAllocMonitor("Display", widthMM, heightMM),
-                          GLFW_CONNECTED,
-                          _GLFW_INSERT_FIRST);
-    }
-}
-
-// Set the current video mode for the specified monitor
-//
-void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        GLFWvidmode current;
-        RRMode native = None;
-
-        const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
-        _glfwPlatformGetVideoMode(monitor, &current);
-        if (_glfwCompareVideoModes(&current, best) == 0)
-            return;
-
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-        XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
-
-        for (int i = 0;  i < oi->nmode;  i++)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
-            if (!modeIsGood(mi))
-                continue;
-
-            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
-            if (_glfwCompareVideoModes(best, &mode) == 0)
-            {
-                native = mi->id;
-                break;
-            }
-        }
-
-        if (native)
-        {
-            if (monitor->x11.oldMode == None)
-                monitor->x11.oldMode = ci->mode;
-
-            XRRSetCrtcConfig(_glfw.x11.display,
-                             sr, monitor->x11.crtc,
-                             CurrentTime,
-                             ci->x, ci->y,
-                             native,
-                             ci->rotation,
-                             ci->outputs,
-                             ci->noutput);
-        }
-
-        XRRFreeOutputInfo(oi);
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-}
-
-// Restore the saved (original) video mode for the specified monitor
-//
-void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        if (monitor->x11.oldMode == None)
-            return;
-
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        XRRSetCrtcConfig(_glfw.x11.display,
-                         sr, monitor->x11.crtc,
-                         CurrentTime,
-                         ci->x, ci->y,
-                         monitor->x11.oldMode,
-                         ci->rotation,
-                         ci->outputs,
-                         ci->noutput);
-
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-
-        monitor->x11.oldMode = None;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor)
-{
-}
-
-void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        if (ci)
-        {
-            if (xpos)
-                *xpos = ci->x;
-            if (ypos)
-                *ypos = ci->y;
-
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-}
-
-void _glfwPlatformGetMonitorContentScale(_GLFWmonitor* monitor,
-                                         float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = _glfw.x11.contentScaleX;
-    if (yscale)
-        *yscale = _glfw.x11.contentScaleY;
-}
-
-void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height)
-{
-    int areaX = 0, areaY = 0, areaWidth = 0, areaHeight = 0;
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        areaX = ci->x;
-        areaY = ci->y;
-
-        const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
-
-        if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
-        {
-            areaWidth  = mi->height;
-            areaHeight = mi->width;
-        }
-        else
-        {
-            areaWidth  = mi->width;
-            areaHeight = mi->height;
-        }
-
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        areaWidth  = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
-        areaHeight = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
-    }
-
-    if (_glfw.x11.NET_WORKAREA && _glfw.x11.NET_CURRENT_DESKTOP)
-    {
-        Atom* extents = NULL;
-        Atom* desktop = NULL;
-        const unsigned long extentCount =
-            _glfwGetWindowPropertyX11(_glfw.x11.root,
-                                      _glfw.x11.NET_WORKAREA,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &extents);
-
-        if (_glfwGetWindowPropertyX11(_glfw.x11.root,
-                                      _glfw.x11.NET_CURRENT_DESKTOP,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &desktop) > 0)
-        {
-            if (extentCount >= 4 && *desktop < extentCount / 4)
-            {
-                const int globalX = extents[*desktop * 4 + 0];
-                const int globalY = extents[*desktop * 4 + 1];
-                const int globalWidth  = extents[*desktop * 4 + 2];
-                const int globalHeight = extents[*desktop * 4 + 3];
-
-                if (areaX < globalX)
-                {
-                    areaWidth -= globalX - areaX;
-                    areaX = globalX;
-                }
-
-                if (areaY < globalY)
-                {
-                    areaHeight -= globalY - areaY;
-                    areaY = globalY;
-                }
-
-                if (areaX + areaWidth > globalX + globalWidth)
-                    areaWidth = globalX - areaX + globalWidth;
-                if (areaY + areaHeight > globalY + globalHeight)
-                    areaHeight = globalY - areaY + globalHeight;
-            }
-        }
-
-        if (extents)
-            XFree(extents);
-        if (desktop)
-            XFree(desktop);
-    }
-
-    if (xpos)
-        *xpos = areaX;
-    if (ypos)
-        *ypos = areaY;
-    if (width)
-        *width = areaWidth;
-    if (height)
-        *height = areaHeight;
-}
-
-GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
-{
-    GLFWvidmode* result;
-
-    *count = 0;
-
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-        XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
-
-        result = calloc(oi->nmode, sizeof(GLFWvidmode));
-
-        for (int i = 0;  i < oi->nmode;  i++)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
-            if (!modeIsGood(mi))
-                continue;
-
-            const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
-            int j;
-
-            for (j = 0;  j < *count;  j++)
-            {
-                if (_glfwCompareVideoModes(result + j, &mode) == 0)
-                    break;
-            }
-
-            // Skip duplicate modes
-            if (j < *count)
-                continue;
-
-            (*count)++;
-            result[*count - 1] = mode;
-        }
-
-        XRRFreeOutputInfo(oi);
-        XRRFreeCrtcInfo(ci);
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        *count = 1;
-        result = calloc(1, sizeof(GLFWvidmode));
-        _glfwPlatformGetVideoMode(monitor, result);
-    }
-
-    return result;
-}
-
-void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
-    {
-        XRRScreenResources* sr =
-            XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
-        XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
-
-        if (ci)
-        {
-            const XRRModeInfo* mi = getModeInfo(sr, ci->mode);
-            if (mi)  // mi can be NULL if the monitor has been disconnected
-                *mode = vidmodeFromModeInfo(mi, ci);
-
-            XRRFreeCrtcInfo(ci);
-        }
-
-        XRRFreeScreenResources(sr);
-    }
-    else
-    {
-        mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
-        mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
-        mode->refreshRate = 0;
-
-        _glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
-                      &mode->redBits, &mode->greenBits, &mode->blueBits);
-    }
-}
-
-GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
-    {
-        const size_t size = XRRGetCrtcGammaSize(_glfw.x11.display,
-                                                monitor->x11.crtc);
-        XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
-                                              monitor->x11.crtc);
-
-        _glfwAllocGammaArrays(ramp, size);
-
-        memcpy(ramp->red,   gamma->red,   size * sizeof(unsigned short));
-        memcpy(ramp->green, gamma->green, size * sizeof(unsigned short));
-        memcpy(ramp->blue,  gamma->blue,  size * sizeof(unsigned short));
-
-        XRRFreeGamma(gamma);
-        return GLFW_TRUE;
-    }
-    else if (_glfw.x11.vidmode.available)
-    {
-        int size;
-        XF86VidModeGetGammaRampSize(_glfw.x11.display, _glfw.x11.screen, &size);
-
-        _glfwAllocGammaArrays(ramp, size);
-
-        XF86VidModeGetGammaRamp(_glfw.x11.display,
-                                _glfw.x11.screen,
-                                ramp->size, ramp->red, ramp->green, ramp->blue);
-        return GLFW_TRUE;
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Gamma ramp access not supported by server");
-        return GLFW_FALSE;
-    }
-}
-
-void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
-{
-    if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
-    {
-        if (XRRGetCrtcGammaSize(_glfw.x11.display, monitor->x11.crtc) != ramp->size)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Gamma ramp size must match current ramp size");
-            return;
-        }
-
-        XRRCrtcGamma* gamma = XRRAllocGamma(ramp->size);
-
-        memcpy(gamma->red,   ramp->red,   ramp->size * sizeof(unsigned short));
-        memcpy(gamma->green, ramp->green, ramp->size * sizeof(unsigned short));
-        memcpy(gamma->blue,  ramp->blue,  ramp->size * sizeof(unsigned short));
-
-        XRRSetCrtcGamma(_glfw.x11.display, monitor->x11.crtc, gamma);
-        XRRFreeGamma(gamma);
-    }
-    else if (_glfw.x11.vidmode.available)
-    {
-        XF86VidModeSetGammaRamp(_glfw.x11.display,
-                                _glfw.x11.screen,
-                                ramp->size,
-                                (unsigned short*) ramp->red,
-                                (unsigned short*) ramp->green,
-                                (unsigned short*) ramp->blue);
-    }
-    else
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Gamma ramp access not supported by server");
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return monitor->x11.crtc;
-}
-
-GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* handle)
-{
-    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return monitor->x11.output;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/x11_platform.h b/raylib_pi4_test/external/glfw/src/x11_platform.h
deleted file mode 100644 (file)
index c5137bc..0000000
+++ /dev/null
@@ -1,798 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-#include <unistd.h>
-#include <signal.h>
-#include <stdint.h>
-#include <dlfcn.h>
-
-#include <X11/Xlib.h>
-#include <X11/keysym.h>
-#include <X11/Xatom.h>
-#include <X11/Xresource.h>
-#include <X11/Xcursor/Xcursor.h>
-
-// The XRandR extension provides mode setting and gamma control
-#include <X11/extensions/Xrandr.h>
-
-// The Xkb extension provides improved keyboard support
-#include <X11/XKBlib.h>
-
-// The Xinerama extension provides legacy monitor indices
-#include <X11/extensions/Xinerama.h>
-
-// The XInput extension provides raw mouse motion input
-#include <X11/extensions/XInput2.h>
-
-// The Shape extension provides custom window shapes
-#include <X11/extensions/shape.h>
-
-typedef XClassHint* (* PFN_XAllocClassHint)(void);
-typedef XSizeHints* (* PFN_XAllocSizeHints)(void);
-typedef XWMHints* (* PFN_XAllocWMHints)(void);
-typedef int (* PFN_XChangeProperty)(Display*,Window,Atom,Atom,int,int,const unsigned char*,int);
-typedef int (* PFN_XChangeWindowAttributes)(Display*,Window,unsigned long,XSetWindowAttributes*);
-typedef Bool (* PFN_XCheckIfEvent)(Display*,XEvent*,Bool(*)(Display*,XEvent*,XPointer),XPointer);
-typedef Bool (* PFN_XCheckTypedWindowEvent)(Display*,Window,int,XEvent*);
-typedef int (* PFN_XCloseDisplay)(Display*);
-typedef Status (* PFN_XCloseIM)(XIM);
-typedef int (* PFN_XConvertSelection)(Display*,Atom,Atom,Atom,Window,Time);
-typedef Colormap (* PFN_XCreateColormap)(Display*,Window,Visual*,int);
-typedef Cursor (* PFN_XCreateFontCursor)(Display*,unsigned int);
-typedef XIC (* PFN_XCreateIC)(XIM,...);
-typedef Region (* PFN_XCreateRegion)(void);
-typedef Window (* PFN_XCreateWindow)(Display*,Window,int,int,unsigned int,unsigned int,unsigned int,int,unsigned int,Visual*,unsigned long,XSetWindowAttributes*);
-typedef int (* PFN_XDefineCursor)(Display*,Window,Cursor);
-typedef int (* PFN_XDeleteContext)(Display*,XID,XContext);
-typedef int (* PFN_XDeleteProperty)(Display*,Window,Atom);
-typedef void (* PFN_XDestroyIC)(XIC);
-typedef int (* PFN_XDestroyRegion)(Region);
-typedef int (* PFN_XDestroyWindow)(Display*,Window);
-typedef int (* PFN_XDisplayKeycodes)(Display*,int*,int*);
-typedef int (* PFN_XEventsQueued)(Display*,int);
-typedef Bool (* PFN_XFilterEvent)(XEvent*,Window);
-typedef int (* PFN_XFindContext)(Display*,XID,XContext,XPointer*);
-typedef int (* PFN_XFlush)(Display*);
-typedef int (* PFN_XFree)(void*);
-typedef int (* PFN_XFreeColormap)(Display*,Colormap);
-typedef int (* PFN_XFreeCursor)(Display*,Cursor);
-typedef void (* PFN_XFreeEventData)(Display*,XGenericEventCookie*);
-typedef int (* PFN_XGetErrorText)(Display*,int,char*,int);
-typedef Bool (* PFN_XGetEventData)(Display*,XGenericEventCookie*);
-typedef char* (* PFN_XGetICValues)(XIC,...);
-typedef char* (* PFN_XGetIMValues)(XIM,...);
-typedef int (* PFN_XGetInputFocus)(Display*,Window*,int*);
-typedef KeySym* (* PFN_XGetKeyboardMapping)(Display*,KeyCode,int,int*);
-typedef int (* PFN_XGetScreenSaver)(Display*,int*,int*,int*,int*);
-typedef Window (* PFN_XGetSelectionOwner)(Display*,Atom);
-typedef XVisualInfo* (* PFN_XGetVisualInfo)(Display*,long,XVisualInfo*,int*);
-typedef Status (* PFN_XGetWMNormalHints)(Display*,Window,XSizeHints*,long*);
-typedef Status (* PFN_XGetWindowAttributes)(Display*,Window,XWindowAttributes*);
-typedef int (* PFN_XGetWindowProperty)(Display*,Window,Atom,long,long,Bool,Atom,Atom*,int*,unsigned long*,unsigned long*,unsigned char**);
-typedef int (* PFN_XGrabPointer)(Display*,Window,Bool,unsigned int,int,int,Window,Cursor,Time);
-typedef Status (* PFN_XIconifyWindow)(Display*,Window,int);
-typedef Status (* PFN_XInitThreads)(void);
-typedef Atom (* PFN_XInternAtom)(Display*,const char*,Bool);
-typedef int (* PFN_XLookupString)(XKeyEvent*,char*,int,KeySym*,XComposeStatus*);
-typedef int (* PFN_XMapRaised)(Display*,Window);
-typedef int (* PFN_XMapWindow)(Display*,Window);
-typedef int (* PFN_XMoveResizeWindow)(Display*,Window,int,int,unsigned int,unsigned int);
-typedef int (* PFN_XMoveWindow)(Display*,Window,int,int);
-typedef int (* PFN_XNextEvent)(Display*,XEvent*);
-typedef Display* (* PFN_XOpenDisplay)(const char*);
-typedef XIM (* PFN_XOpenIM)(Display*,XrmDatabase*,char*,char*);
-typedef int (* PFN_XPeekEvent)(Display*,XEvent*);
-typedef int (* PFN_XPending)(Display*);
-typedef Bool (* PFN_XQueryExtension)(Display*,const char*,int*,int*,int*);
-typedef Bool (* PFN_XQueryPointer)(Display*,Window,Window*,Window*,int*,int*,int*,int*,unsigned int*);
-typedef int (* PFN_XRaiseWindow)(Display*,Window);
-typedef Bool (* PFN_XRegisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
-typedef int (* PFN_XResizeWindow)(Display*,Window,unsigned int,unsigned int);
-typedef char* (* PFN_XResourceManagerString)(Display*);
-typedef int (* PFN_XSaveContext)(Display*,XID,XContext,const char*);
-typedef int (* PFN_XSelectInput)(Display*,Window,long);
-typedef Status (* PFN_XSendEvent)(Display*,Window,Bool,long,XEvent*);
-typedef int (* PFN_XSetClassHint)(Display*,Window,XClassHint*);
-typedef XErrorHandler (* PFN_XSetErrorHandler)(XErrorHandler);
-typedef void (* PFN_XSetICFocus)(XIC);
-typedef char* (* PFN_XSetIMValues)(XIM,...);
-typedef int (* PFN_XSetInputFocus)(Display*,Window,int,Time);
-typedef char* (* PFN_XSetLocaleModifiers)(const char*);
-typedef int (* PFN_XSetScreenSaver)(Display*,int,int,int,int);
-typedef int (* PFN_XSetSelectionOwner)(Display*,Atom,Window,Time);
-typedef int (* PFN_XSetWMHints)(Display*,Window,XWMHints*);
-typedef void (* PFN_XSetWMNormalHints)(Display*,Window,XSizeHints*);
-typedef Status (* PFN_XSetWMProtocols)(Display*,Window,Atom*,int);
-typedef Bool (* PFN_XSupportsLocale)(void);
-typedef int (* PFN_XSync)(Display*,Bool);
-typedef Bool (* PFN_XTranslateCoordinates)(Display*,Window,Window,int,int,int*,int*,Window*);
-typedef int (* PFN_XUndefineCursor)(Display*,Window);
-typedef int (* PFN_XUngrabPointer)(Display*,Time);
-typedef int (* PFN_XUnmapWindow)(Display*,Window);
-typedef void (* PFN_XUnsetICFocus)(XIC);
-typedef VisualID (* PFN_XVisualIDFromVisual)(Visual*);
-typedef int (* PFN_XWarpPointer)(Display*,Window,Window,int,int,unsigned int,unsigned int,int,int);
-typedef void (* PFN_XkbFreeKeyboard)(XkbDescPtr,unsigned int,Bool);
-typedef void (* PFN_XkbFreeNames)(XkbDescPtr,unsigned int,Bool);
-typedef XkbDescPtr (* PFN_XkbGetMap)(Display*,unsigned int,unsigned int);
-typedef Status (* PFN_XkbGetNames)(Display*,unsigned int,XkbDescPtr);
-typedef Status (* PFN_XkbGetState)(Display*,unsigned int,XkbStatePtr);
-typedef KeySym (* PFN_XkbKeycodeToKeysym)(Display*,KeyCode,int,int);
-typedef Bool (* PFN_XkbQueryExtension)(Display*,int*,int*,int*,int*,int*);
-typedef Bool (* PFN_XkbSelectEventDetails)(Display*,unsigned int,unsigned int,unsigned long,unsigned long);
-typedef Bool (* PFN_XkbSetDetectableAutoRepeat)(Display*,Bool,Bool*);
-typedef void (* PFN_XrmDestroyDatabase)(XrmDatabase);
-typedef Bool (* PFN_XrmGetResource)(XrmDatabase,const char*,const char*,char**,XrmValue*);
-typedef XrmDatabase (* PFN_XrmGetStringDatabase)(const char*);
-typedef void (* PFN_XrmInitialize)(void);
-typedef XrmQuark (* PFN_XrmUniqueQuark)(void);
-typedef Bool (* PFN_XUnregisterIMInstantiateCallback)(Display*,void*,char*,char*,XIDProc,XPointer);
-typedef int (* PFN_Xutf8LookupString)(XIC,XKeyPressedEvent*,char*,int,KeySym*,Status*);
-typedef void (* PFN_Xutf8SetWMProperties)(Display*,Window,const char*,const char*,char**,int,XSizeHints*,XWMHints*,XClassHint*);
-#define XAllocClassHint _glfw.x11.xlib.AllocClassHint
-#define XAllocSizeHints _glfw.x11.xlib.AllocSizeHints
-#define XAllocWMHints _glfw.x11.xlib.AllocWMHints
-#define XChangeProperty _glfw.x11.xlib.ChangeProperty
-#define XChangeWindowAttributes _glfw.x11.xlib.ChangeWindowAttributes
-#define XCheckIfEvent _glfw.x11.xlib.CheckIfEvent
-#define XCheckTypedWindowEvent _glfw.x11.xlib.CheckTypedWindowEvent
-#define XCloseDisplay _glfw.x11.xlib.CloseDisplay
-#define XCloseIM _glfw.x11.xlib.CloseIM
-#define XConvertSelection _glfw.x11.xlib.ConvertSelection
-#define XCreateColormap _glfw.x11.xlib.CreateColormap
-#define XCreateFontCursor _glfw.x11.xlib.CreateFontCursor
-#define XCreateIC _glfw.x11.xlib.CreateIC
-#define XCreateRegion _glfw.x11.xlib.CreateRegion
-#define XCreateWindow _glfw.x11.xlib.CreateWindow
-#define XDefineCursor _glfw.x11.xlib.DefineCursor
-#define XDeleteContext _glfw.x11.xlib.DeleteContext
-#define XDeleteProperty _glfw.x11.xlib.DeleteProperty
-#define XDestroyIC _glfw.x11.xlib.DestroyIC
-#define XDestroyRegion _glfw.x11.xlib.DestroyRegion
-#define XDestroyWindow _glfw.x11.xlib.DestroyWindow
-#define XDisplayKeycodes _glfw.x11.xlib.DisplayKeycodes
-#define XEventsQueued _glfw.x11.xlib.EventsQueued
-#define XFilterEvent _glfw.x11.xlib.FilterEvent
-#define XFindContext _glfw.x11.xlib.FindContext
-#define XFlush _glfw.x11.xlib.Flush
-#define XFree _glfw.x11.xlib.Free
-#define XFreeColormap _glfw.x11.xlib.FreeColormap
-#define XFreeCursor _glfw.x11.xlib.FreeCursor
-#define XFreeEventData _glfw.x11.xlib.FreeEventData
-#define XGetErrorText _glfw.x11.xlib.GetErrorText
-#define XGetEventData _glfw.x11.xlib.GetEventData
-#define XGetICValues _glfw.x11.xlib.GetICValues
-#define XGetIMValues _glfw.x11.xlib.GetIMValues
-#define XGetInputFocus _glfw.x11.xlib.GetInputFocus
-#define XGetKeyboardMapping _glfw.x11.xlib.GetKeyboardMapping
-#define XGetScreenSaver _glfw.x11.xlib.GetScreenSaver
-#define XGetSelectionOwner _glfw.x11.xlib.GetSelectionOwner
-#define XGetVisualInfo _glfw.x11.xlib.GetVisualInfo
-#define XGetWMNormalHints _glfw.x11.xlib.GetWMNormalHints
-#define XGetWindowAttributes _glfw.x11.xlib.GetWindowAttributes
-#define XGetWindowProperty _glfw.x11.xlib.GetWindowProperty
-#define XGrabPointer _glfw.x11.xlib.GrabPointer
-#define XIconifyWindow _glfw.x11.xlib.IconifyWindow
-#define XInitThreads _glfw.x11.xlib.InitThreads
-#define XInternAtom _glfw.x11.xlib.InternAtom
-#define XLookupString _glfw.x11.xlib.LookupString
-#define XMapRaised _glfw.x11.xlib.MapRaised
-#define XMapWindow _glfw.x11.xlib.MapWindow
-#define XMoveResizeWindow _glfw.x11.xlib.MoveResizeWindow
-#define XMoveWindow _glfw.x11.xlib.MoveWindow
-#define XNextEvent _glfw.x11.xlib.NextEvent
-#define XOpenDisplay _glfw.x11.xlib.OpenDisplay
-#define XOpenIM _glfw.x11.xlib.OpenIM
-#define XPeekEvent _glfw.x11.xlib.PeekEvent
-#define XPending _glfw.x11.xlib.Pending
-#define XQueryExtension _glfw.x11.xlib.QueryExtension
-#define XQueryPointer _glfw.x11.xlib.QueryPointer
-#define XRaiseWindow _glfw.x11.xlib.RaiseWindow
-#define XRegisterIMInstantiateCallback _glfw.x11.xlib.RegisterIMInstantiateCallback
-#define XResizeWindow _glfw.x11.xlib.ResizeWindow
-#define XResourceManagerString _glfw.x11.xlib.ResourceManagerString
-#define XSaveContext _glfw.x11.xlib.SaveContext
-#define XSelectInput _glfw.x11.xlib.SelectInput
-#define XSendEvent _glfw.x11.xlib.SendEvent
-#define XSetClassHint _glfw.x11.xlib.SetClassHint
-#define XSetErrorHandler _glfw.x11.xlib.SetErrorHandler
-#define XSetICFocus _glfw.x11.xlib.SetICFocus
-#define XSetIMValues _glfw.x11.xlib.SetIMValues
-#define XSetInputFocus _glfw.x11.xlib.SetInputFocus
-#define XSetLocaleModifiers _glfw.x11.xlib.SetLocaleModifiers
-#define XSetScreenSaver _glfw.x11.xlib.SetScreenSaver
-#define XSetSelectionOwner _glfw.x11.xlib.SetSelectionOwner
-#define XSetWMHints _glfw.x11.xlib.SetWMHints
-#define XSetWMNormalHints _glfw.x11.xlib.SetWMNormalHints
-#define XSetWMProtocols _glfw.x11.xlib.SetWMProtocols
-#define XSupportsLocale _glfw.x11.xlib.SupportsLocale
-#define XSync _glfw.x11.xlib.Sync
-#define XTranslateCoordinates _glfw.x11.xlib.TranslateCoordinates
-#define XUndefineCursor _glfw.x11.xlib.UndefineCursor
-#define XUngrabPointer _glfw.x11.xlib.UngrabPointer
-#define XUnmapWindow _glfw.x11.xlib.UnmapWindow
-#define XUnsetICFocus _glfw.x11.xlib.UnsetICFocus
-#define XVisualIDFromVisual _glfw.x11.xlib.VisualIDFromVisual
-#define XWarpPointer _glfw.x11.xlib.WarpPointer
-#define XkbFreeKeyboard _glfw.x11.xkb.FreeKeyboard
-#define XkbFreeNames _glfw.x11.xkb.FreeNames
-#define XkbGetMap _glfw.x11.xkb.GetMap
-#define XkbGetNames _glfw.x11.xkb.GetNames
-#define XkbGetState _glfw.x11.xkb.GetState
-#define XkbKeycodeToKeysym _glfw.x11.xkb.KeycodeToKeysym
-#define XkbQueryExtension _glfw.x11.xkb.QueryExtension
-#define XkbSelectEventDetails _glfw.x11.xkb.SelectEventDetails
-#define XkbSetDetectableAutoRepeat _glfw.x11.xkb.SetDetectableAutoRepeat
-#define XrmDestroyDatabase _glfw.x11.xrm.DestroyDatabase
-#define XrmGetResource _glfw.x11.xrm.GetResource
-#define XrmGetStringDatabase _glfw.x11.xrm.GetStringDatabase
-#define XrmInitialize _glfw.x11.xrm.Initialize
-#define XrmUniqueQuark _glfw.x11.xrm.UniqueQuark
-#define XUnregisterIMInstantiateCallback _glfw.x11.xlib.UnregisterIMInstantiateCallback
-#define Xutf8LookupString _glfw.x11.xlib.utf8LookupString
-#define Xutf8SetWMProperties _glfw.x11.xlib.utf8SetWMProperties
-
-typedef XRRCrtcGamma* (* PFN_XRRAllocGamma)(int);
-typedef void (* PFN_XRRFreeCrtcInfo)(XRRCrtcInfo*);
-typedef void (* PFN_XRRFreeGamma)(XRRCrtcGamma*);
-typedef void (* PFN_XRRFreeOutputInfo)(XRROutputInfo*);
-typedef void (* PFN_XRRFreeScreenResources)(XRRScreenResources*);
-typedef XRRCrtcGamma* (* PFN_XRRGetCrtcGamma)(Display*,RRCrtc);
-typedef int (* PFN_XRRGetCrtcGammaSize)(Display*,RRCrtc);
-typedef XRRCrtcInfo* (* PFN_XRRGetCrtcInfo) (Display*,XRRScreenResources*,RRCrtc);
-typedef XRROutputInfo* (* PFN_XRRGetOutputInfo)(Display*,XRRScreenResources*,RROutput);
-typedef RROutput (* PFN_XRRGetOutputPrimary)(Display*,Window);
-typedef XRRScreenResources* (* PFN_XRRGetScreenResourcesCurrent)(Display*,Window);
-typedef Bool (* PFN_XRRQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XRRQueryVersion)(Display*,int*,int*);
-typedef void (* PFN_XRRSelectInput)(Display*,Window,int);
-typedef Status (* PFN_XRRSetCrtcConfig)(Display*,XRRScreenResources*,RRCrtc,Time,int,int,RRMode,Rotation,RROutput*,int);
-typedef void (* PFN_XRRSetCrtcGamma)(Display*,RRCrtc,XRRCrtcGamma*);
-typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
-#define XRRAllocGamma _glfw.x11.randr.AllocGamma
-#define XRRFreeCrtcInfo _glfw.x11.randr.FreeCrtcInfo
-#define XRRFreeGamma _glfw.x11.randr.FreeGamma
-#define XRRFreeOutputInfo _glfw.x11.randr.FreeOutputInfo
-#define XRRFreeScreenResources _glfw.x11.randr.FreeScreenResources
-#define XRRGetCrtcGamma _glfw.x11.randr.GetCrtcGamma
-#define XRRGetCrtcGammaSize _glfw.x11.randr.GetCrtcGammaSize
-#define XRRGetCrtcInfo _glfw.x11.randr.GetCrtcInfo
-#define XRRGetOutputInfo _glfw.x11.randr.GetOutputInfo
-#define XRRGetOutputPrimary _glfw.x11.randr.GetOutputPrimary
-#define XRRGetScreenResourcesCurrent _glfw.x11.randr.GetScreenResourcesCurrent
-#define XRRQueryExtension _glfw.x11.randr.QueryExtension
-#define XRRQueryVersion _glfw.x11.randr.QueryVersion
-#define XRRSelectInput _glfw.x11.randr.SelectInput
-#define XRRSetCrtcConfig _glfw.x11.randr.SetCrtcConfig
-#define XRRSetCrtcGamma _glfw.x11.randr.SetCrtcGamma
-#define XRRUpdateConfiguration _glfw.x11.randr.UpdateConfiguration
-
-typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
-typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
-typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
-typedef char* (* PFN_XcursorGetTheme)(Display*);
-typedef int (* PFN_XcursorGetDefaultSize)(Display*);
-typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int);
-#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
-#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
-#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
-#define XcursorGetTheme _glfw.x11.xcursor.GetTheme
-#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize
-#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage
-
-typedef Bool (* PFN_XineramaIsActive)(Display*);
-typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
-typedef XineramaScreenInfo* (* PFN_XineramaQueryScreens)(Display*,int*);
-#define XineramaIsActive _glfw.x11.xinerama.IsActive
-#define XineramaQueryExtension _glfw.x11.xinerama.QueryExtension
-#define XineramaQueryScreens _glfw.x11.xinerama.QueryScreens
-
-typedef XID xcb_window_t;
-typedef XID xcb_visualid_t;
-typedef struct xcb_connection_t xcb_connection_t;
-typedef xcb_connection_t* (* PFN_XGetXCBConnection)(Display*);
-#define XGetXCBConnection _glfw.x11.x11xcb.GetXCBConnection
-
-typedef Bool (* PFN_XF86VidModeQueryExtension)(Display*,int*,int*);
-typedef Bool (* PFN_XF86VidModeGetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
-typedef Bool (* PFN_XF86VidModeSetGammaRamp)(Display*,int,int,unsigned short*,unsigned short*,unsigned short*);
-typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*);
-#define XF86VidModeQueryExtension _glfw.x11.vidmode.QueryExtension
-#define XF86VidModeGetGammaRamp _glfw.x11.vidmode.GetGammaRamp
-#define XF86VidModeSetGammaRamp _glfw.x11.vidmode.SetGammaRamp
-#define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize
-
-typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*);
-typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int);
-#define XIQueryVersion _glfw.x11.xi.QueryVersion
-#define XISelectEvents _glfw.x11.xi.SelectEvents
-
-typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*);
-typedef XRenderPictFormat* (* PFN_XRenderFindVisualFormat)(Display*,Visual const*);
-#define XRenderQueryExtension _glfw.x11.xrender.QueryExtension
-#define XRenderQueryVersion _glfw.x11.xrender.QueryVersion
-#define XRenderFindVisualFormat _glfw.x11.xrender.FindVisualFormat
-
-typedef Bool (* PFN_XShapeQueryExtension)(Display*,int*,int*);
-typedef Status (* PFN_XShapeQueryVersion)(Display*dpy,int*,int*);
-typedef void (* PFN_XShapeCombineRegion)(Display*,Window,int,int,int,Region,int);
-typedef void (* PFN_XShapeCombineMask)(Display*,Window,int,int,int,Pixmap,int);
-
-#define XShapeQueryExtension _glfw.x11.xshape.QueryExtension
-#define XShapeQueryVersion _glfw.x11.xshape.QueryVersion
-#define XShapeCombineRegion _glfw.x11.xshape.ShapeCombineRegion
-#define XShapeCombineMask _glfw.x11.xshape.ShapeCombineMask
-
-typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
-typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
-
-typedef struct VkXlibSurfaceCreateInfoKHR
-{
-    VkStructureType             sType;
-    const void*                 pNext;
-    VkXlibSurfaceCreateFlagsKHR flags;
-    Display*                    dpy;
-    Window                      window;
-} VkXlibSurfaceCreateInfoKHR;
-
-typedef struct VkXcbSurfaceCreateInfoKHR
-{
-    VkStructureType             sType;
-    const void*                 pNext;
-    VkXcbSurfaceCreateFlagsKHR  flags;
-    xcb_connection_t*           connection;
-    xcb_window_t                window;
-} VkXcbSurfaceCreateInfoKHR;
-
-typedef VkResult (APIENTRY *PFN_vkCreateXlibSurfaceKHR)(VkInstance,const VkXlibSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice,uint32_t,Display*,VisualID);
-typedef VkResult (APIENTRY *PFN_vkCreateXcbSurfaceKHR)(VkInstance,const VkXcbSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*);
-typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice,uint32_t,xcb_connection_t*,xcb_visualid_t);
-
-#include "posix_thread.h"
-#include "posix_time.h"
-#include "xkb_unicode.h"
-#include "glx_context.h"
-#if defined(__linux__)
-#include "linux_joystick.h"
-#else
-#include "null_joystick.h"
-#endif
-
-#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
-#define _glfw_dlclose(handle) dlclose(handle)
-#define _glfw_dlsym(handle, name) dlsym(handle, name)
-
-#define _GLFW_PLATFORM_WINDOW_STATE         _GLFWwindowX11  x11
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
-#define _GLFW_PLATFORM_MONITOR_STATE        _GLFWmonitorX11 x11
-#define _GLFW_PLATFORM_CURSOR_STATE         _GLFWcursorX11  x11
-
-
-// X11-specific per-window data
-//
-typedef struct _GLFWwindowX11
-{
-    Colormap        colormap;
-    Window          handle;
-    Window          parent;
-    XIC             ic;
-
-    GLFWbool        overrideRedirect;
-    GLFWbool        iconified;
-    GLFWbool        maximized;
-
-    // Whether the visual supports framebuffer transparency
-    GLFWbool        transparent;
-
-    // Cached position and size used to filter out duplicate events
-    int             width, height;
-    int             xpos, ypos;
-
-    // The last received cursor position, regardless of source
-    int             lastCursorPosX, lastCursorPosY;
-    // The last position the cursor was warped to by GLFW
-    int             warpCursorPosX, warpCursorPosY;
-
-    // The time of the last KeyPress event per keycode, for discarding
-    // duplicate key events generated for some keys by ibus
-    Time            keyPressTimes[256];
-
-} _GLFWwindowX11;
-
-// X11-specific global data
-//
-typedef struct _GLFWlibraryX11
-{
-    Display*        display;
-    int             screen;
-    Window          root;
-
-    // System content scale
-    float           contentScaleX, contentScaleY;
-    // Helper window for IPC
-    Window          helperWindowHandle;
-    // Invisible cursor for hidden cursor mode
-    Cursor          hiddenCursorHandle;
-    // Context for mapping window XIDs to _GLFWwindow pointers
-    XContext        context;
-    // XIM input method
-    XIM             im;
-    // Most recent error code received by X error handler
-    int             errorCode;
-    // Primary selection string (while the primary selection is owned)
-    char*           primarySelectionString;
-    // Clipboard string (while the selection is owned)
-    char*           clipboardString;
-    // Key name string
-    char            keynames[GLFW_KEY_LAST + 1][5];
-    // X11 keycode to GLFW key LUT
-    short int       keycodes[256];
-    // GLFW key to X11 keycode LUT
-    short int       scancodes[GLFW_KEY_LAST + 1];
-    // Where to place the cursor when re-enabled
-    double          restoreCursorPosX, restoreCursorPosY;
-    // The window whose disabled cursor mode is active
-    _GLFWwindow*    disabledCursorWindow;
-
-    // Window manager atoms
-    Atom            NET_SUPPORTED;
-    Atom            NET_SUPPORTING_WM_CHECK;
-    Atom            WM_PROTOCOLS;
-    Atom            WM_STATE;
-    Atom            WM_DELETE_WINDOW;
-    Atom            NET_WM_NAME;
-    Atom            NET_WM_ICON_NAME;
-    Atom            NET_WM_ICON;
-    Atom            NET_WM_PID;
-    Atom            NET_WM_PING;
-    Atom            NET_WM_WINDOW_TYPE;
-    Atom            NET_WM_WINDOW_TYPE_NORMAL;
-    Atom            NET_WM_STATE;
-    Atom            NET_WM_STATE_ABOVE;
-    Atom            NET_WM_STATE_FULLSCREEN;
-    Atom            NET_WM_STATE_MAXIMIZED_VERT;
-    Atom            NET_WM_STATE_MAXIMIZED_HORZ;
-    Atom            NET_WM_STATE_DEMANDS_ATTENTION;
-    Atom            NET_WM_BYPASS_COMPOSITOR;
-    Atom            NET_WM_FULLSCREEN_MONITORS;
-    Atom            NET_WM_WINDOW_OPACITY;
-    Atom            NET_WM_CM_Sx;
-    Atom            NET_WORKAREA;
-    Atom            NET_CURRENT_DESKTOP;
-    Atom            NET_ACTIVE_WINDOW;
-    Atom            NET_FRAME_EXTENTS;
-    Atom            NET_REQUEST_FRAME_EXTENTS;
-    Atom            MOTIF_WM_HINTS;
-
-    // Xdnd (drag and drop) atoms
-    Atom            XdndAware;
-    Atom            XdndEnter;
-    Atom            XdndPosition;
-    Atom            XdndStatus;
-    Atom            XdndActionCopy;
-    Atom            XdndDrop;
-    Atom            XdndFinished;
-    Atom            XdndSelection;
-    Atom            XdndTypeList;
-    Atom            text_uri_list;
-
-    // Selection (clipboard) atoms
-    Atom            TARGETS;
-    Atom            MULTIPLE;
-    Atom            INCR;
-    Atom            CLIPBOARD;
-    Atom            PRIMARY;
-    Atom            CLIPBOARD_MANAGER;
-    Atom            SAVE_TARGETS;
-    Atom            NULL_;
-    Atom            UTF8_STRING;
-    Atom            COMPOUND_STRING;
-    Atom            ATOM_PAIR;
-    Atom            GLFW_SELECTION;
-
-    struct {
-        void*       handle;
-        GLFWbool    utf8;
-        PFN_XAllocClassHint AllocClassHint;
-        PFN_XAllocSizeHints AllocSizeHints;
-        PFN_XAllocWMHints AllocWMHints;
-        PFN_XChangeProperty ChangeProperty;
-        PFN_XChangeWindowAttributes ChangeWindowAttributes;
-        PFN_XCheckIfEvent CheckIfEvent;
-        PFN_XCheckTypedWindowEvent CheckTypedWindowEvent;
-        PFN_XCloseDisplay CloseDisplay;
-        PFN_XCloseIM CloseIM;
-        PFN_XConvertSelection ConvertSelection;
-        PFN_XCreateColormap CreateColormap;
-        PFN_XCreateFontCursor CreateFontCursor;
-        PFN_XCreateIC CreateIC;
-        PFN_XCreateRegion CreateRegion;
-        PFN_XCreateWindow CreateWindow;
-        PFN_XDefineCursor DefineCursor;
-        PFN_XDeleteContext DeleteContext;
-        PFN_XDeleteProperty DeleteProperty;
-        PFN_XDestroyIC DestroyIC;
-        PFN_XDestroyRegion DestroyRegion;
-        PFN_XDestroyWindow DestroyWindow;
-        PFN_XDisplayKeycodes DisplayKeycodes;
-        PFN_XEventsQueued EventsQueued;
-        PFN_XFilterEvent FilterEvent;
-        PFN_XFindContext FindContext;
-        PFN_XFlush Flush;
-        PFN_XFree Free;
-        PFN_XFreeColormap FreeColormap;
-        PFN_XFreeCursor FreeCursor;
-        PFN_XFreeEventData FreeEventData;
-        PFN_XGetErrorText GetErrorText;
-        PFN_XGetEventData GetEventData;
-        PFN_XGetICValues GetICValues;
-        PFN_XGetIMValues GetIMValues;
-        PFN_XGetInputFocus GetInputFocus;
-        PFN_XGetKeyboardMapping GetKeyboardMapping;
-        PFN_XGetScreenSaver GetScreenSaver;
-        PFN_XGetSelectionOwner GetSelectionOwner;
-        PFN_XGetVisualInfo GetVisualInfo;
-        PFN_XGetWMNormalHints GetWMNormalHints;
-        PFN_XGetWindowAttributes GetWindowAttributes;
-        PFN_XGetWindowProperty GetWindowProperty;
-        PFN_XGrabPointer GrabPointer;
-        PFN_XIconifyWindow IconifyWindow;
-        PFN_XInitThreads InitThreads;
-        PFN_XInternAtom InternAtom;
-        PFN_XLookupString LookupString;
-        PFN_XMapRaised MapRaised;
-        PFN_XMapWindow MapWindow;
-        PFN_XMoveResizeWindow MoveResizeWindow;
-        PFN_XMoveWindow MoveWindow;
-        PFN_XNextEvent NextEvent;
-        PFN_XOpenDisplay OpenDisplay;
-        PFN_XOpenIM OpenIM;
-        PFN_XPeekEvent PeekEvent;
-        PFN_XPending Pending;
-        PFN_XQueryExtension QueryExtension;
-        PFN_XQueryPointer QueryPointer;
-        PFN_XRaiseWindow RaiseWindow;
-        PFN_XRegisterIMInstantiateCallback RegisterIMInstantiateCallback;
-        PFN_XResizeWindow ResizeWindow;
-        PFN_XResourceManagerString ResourceManagerString;
-        PFN_XSaveContext SaveContext;
-        PFN_XSelectInput SelectInput;
-        PFN_XSendEvent SendEvent;
-        PFN_XSetClassHint SetClassHint;
-        PFN_XSetErrorHandler SetErrorHandler;
-        PFN_XSetICFocus SetICFocus;
-        PFN_XSetIMValues SetIMValues;
-        PFN_XSetInputFocus SetInputFocus;
-        PFN_XSetLocaleModifiers SetLocaleModifiers;
-        PFN_XSetScreenSaver SetScreenSaver;
-        PFN_XSetSelectionOwner SetSelectionOwner;
-        PFN_XSetWMHints SetWMHints;
-        PFN_XSetWMNormalHints SetWMNormalHints;
-        PFN_XSetWMProtocols SetWMProtocols;
-        PFN_XSupportsLocale SupportsLocale;
-        PFN_XSync Sync;
-        PFN_XTranslateCoordinates TranslateCoordinates;
-        PFN_XUndefineCursor UndefineCursor;
-        PFN_XUngrabPointer UngrabPointer;
-        PFN_XUnmapWindow UnmapWindow;
-        PFN_XUnsetICFocus UnsetICFocus;
-        PFN_XVisualIDFromVisual VisualIDFromVisual;
-        PFN_XWarpPointer WarpPointer;
-        PFN_XUnregisterIMInstantiateCallback UnregisterIMInstantiateCallback;
-        PFN_Xutf8LookupString utf8LookupString;
-        PFN_Xutf8SetWMProperties utf8SetWMProperties;
-    } xlib;
-
-    struct {
-        PFN_XrmDestroyDatabase DestroyDatabase;
-        PFN_XrmGetResource GetResource;
-        PFN_XrmGetStringDatabase GetStringDatabase;
-        PFN_XrmInitialize Initialize;
-        PFN_XrmUniqueQuark UniqueQuark;
-    } xrm;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         eventBase;
-        int         errorBase;
-        int         major;
-        int         minor;
-        GLFWbool    gammaBroken;
-        GLFWbool    monitorBroken;
-        PFN_XRRAllocGamma AllocGamma;
-        PFN_XRRFreeCrtcInfo FreeCrtcInfo;
-        PFN_XRRFreeGamma FreeGamma;
-        PFN_XRRFreeOutputInfo FreeOutputInfo;
-        PFN_XRRFreeScreenResources FreeScreenResources;
-        PFN_XRRGetCrtcGamma GetCrtcGamma;
-        PFN_XRRGetCrtcGammaSize GetCrtcGammaSize;
-        PFN_XRRGetCrtcInfo GetCrtcInfo;
-        PFN_XRRGetOutputInfo GetOutputInfo;
-        PFN_XRRGetOutputPrimary GetOutputPrimary;
-        PFN_XRRGetScreenResourcesCurrent GetScreenResourcesCurrent;
-        PFN_XRRQueryExtension QueryExtension;
-        PFN_XRRQueryVersion QueryVersion;
-        PFN_XRRSelectInput SelectInput;
-        PFN_XRRSetCrtcConfig SetCrtcConfig;
-        PFN_XRRSetCrtcGamma SetCrtcGamma;
-        PFN_XRRUpdateConfiguration UpdateConfiguration;
-    } randr;
-
-    struct {
-        GLFWbool     available;
-        GLFWbool     detectable;
-        int          majorOpcode;
-        int          eventBase;
-        int          errorBase;
-        int          major;
-        int          minor;
-        unsigned int group;
-        PFN_XkbFreeKeyboard FreeKeyboard;
-        PFN_XkbFreeNames FreeNames;
-        PFN_XkbGetMap GetMap;
-        PFN_XkbGetNames GetNames;
-        PFN_XkbGetState GetState;
-        PFN_XkbKeycodeToKeysym KeycodeToKeysym;
-        PFN_XkbQueryExtension QueryExtension;
-        PFN_XkbSelectEventDetails SelectEventDetails;
-        PFN_XkbSetDetectableAutoRepeat SetDetectableAutoRepeat;
-    } xkb;
-
-    struct {
-        int         count;
-        int         timeout;
-        int         interval;
-        int         blanking;
-        int         exposure;
-    } saver;
-
-    struct {
-        int         version;
-        Window      source;
-        Atom        format;
-    } xdnd;
-
-    struct {
-        void*       handle;
-        PFN_XcursorImageCreate ImageCreate;
-        PFN_XcursorImageDestroy ImageDestroy;
-        PFN_XcursorImageLoadCursor ImageLoadCursor;
-        PFN_XcursorGetTheme GetTheme;
-        PFN_XcursorGetDefaultSize GetDefaultSize;
-        PFN_XcursorLibraryLoadImage LibraryLoadImage;
-    } xcursor;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        PFN_XineramaIsActive IsActive;
-        PFN_XineramaQueryExtension QueryExtension;
-        PFN_XineramaQueryScreens QueryScreens;
-    } xinerama;
-
-    struct {
-        void*       handle;
-        PFN_XGetXCBConnection GetXCBConnection;
-    } x11xcb;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         eventBase;
-        int         errorBase;
-        PFN_XF86VidModeQueryExtension QueryExtension;
-        PFN_XF86VidModeGetGammaRamp GetGammaRamp;
-        PFN_XF86VidModeSetGammaRamp SetGammaRamp;
-        PFN_XF86VidModeGetGammaRampSize GetGammaRampSize;
-    } vidmode;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         majorOpcode;
-        int         eventBase;
-        int         errorBase;
-        int         major;
-        int         minor;
-        PFN_XIQueryVersion QueryVersion;
-        PFN_XISelectEvents SelectEvents;
-    } xi;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        int         eventBase;
-        int         errorBase;
-        PFN_XRenderQueryExtension QueryExtension;
-        PFN_XRenderQueryVersion QueryVersion;
-        PFN_XRenderFindVisualFormat FindVisualFormat;
-    } xrender;
-
-    struct {
-        GLFWbool    available;
-        void*       handle;
-        int         major;
-        int         minor;
-        int         eventBase;
-        int         errorBase;
-        PFN_XShapeQueryExtension QueryExtension;
-        PFN_XShapeCombineRegion ShapeCombineRegion;
-        PFN_XShapeQueryVersion QueryVersion;
-        PFN_XShapeCombineMask ShapeCombineMask;
-    } xshape;
-
-} _GLFWlibraryX11;
-
-// X11-specific per-monitor data
-//
-typedef struct _GLFWmonitorX11
-{
-    RROutput        output;
-    RRCrtc          crtc;
-    RRMode          oldMode;
-
-    // Index of corresponding Xinerama screen,
-    // for EWMH full screen window placement
-    int             index;
-
-} _GLFWmonitorX11;
-
-// X11-specific per-cursor data
-//
-typedef struct _GLFWcursorX11
-{
-    Cursor handle;
-
-} _GLFWcursorX11;
-
-
-void _glfwPollMonitorsX11(void);
-void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
-void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
-
-Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
-
-unsigned long _glfwGetWindowPropertyX11(Window window,
-                                        Atom property,
-                                        Atom type,
-                                        unsigned char** value);
-GLFWbool _glfwIsVisualTransparentX11(Visual* visual);
-
-void _glfwGrabErrorHandlerX11(void);
-void _glfwReleaseErrorHandlerX11(void);
-void _glfwInputErrorX11(int error, const char* message);
-
-void _glfwPushSelectionToManagerX11(void);
-void _glfwCreateInputContextX11(_GLFWwindow* window);
-
diff --git a/raylib_pi4_test/external/glfw/src/x11_window.c b/raylib_pi4_test/external/glfw/src/x11_window.c
deleted file mode 100644 (file)
index 4cd3294..0000000
+++ /dev/null
@@ -1,3285 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-#include <X11/cursorfont.h>
-#include <X11/Xmd.h>
-
-#include <sys/select.h>
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <assert.h>
-
-// Action for EWMH client messages
-#define _NET_WM_STATE_REMOVE        0
-#define _NET_WM_STATE_ADD           1
-#define _NET_WM_STATE_TOGGLE        2
-
-// Additional mouse button names for XButtonEvent
-#define Button6            6
-#define Button7            7
-
-// Motif WM hints flags
-#define MWM_HINTS_DECORATIONS   2
-#define MWM_DECOR_ALL           1
-
-#define _GLFW_XDND_VERSION 5
-
-
-// Wait for data to arrive using select
-// This avoids blocking other threads via the per-display Xlib lock that also
-// covers GLX functions
-//
-static GLFWbool waitForEvent(double* timeout)
-{
-    fd_set fds;
-    const int fd = ConnectionNumber(_glfw.x11.display);
-    int count = fd + 1;
-
-#if defined(__linux__)
-    if (_glfw.linjs.inotify > fd)
-        count = _glfw.linjs.inotify + 1;
-#endif
-    for (;;)
-    {
-        FD_ZERO(&fds);
-        FD_SET(fd, &fds);
-#if defined(__linux__)
-        if (_glfw.linjs.inotify > 0)
-            FD_SET(_glfw.linjs.inotify, &fds);
-#endif
-
-        if (timeout)
-        {
-            const long seconds = (long) *timeout;
-            const long microseconds = (long) ((*timeout - seconds) * 1e6);
-            struct timeval tv = { seconds, microseconds };
-            const uint64_t base = _glfwPlatformGetTimerValue();
-
-            const int result = select(count, &fds, NULL, NULL, &tv);
-            const int error = errno;
-
-            *timeout -= (_glfwPlatformGetTimerValue() - base) /
-                (double) _glfwPlatformGetTimerFrequency();
-
-            if (result > 0)
-                return GLFW_TRUE;
-            if ((result == -1 && error == EINTR) || *timeout <= 0.0)
-                return GLFW_FALSE;
-        }
-        else if (select(count, &fds, NULL, NULL, NULL) != -1 || errno != EINTR)
-            return GLFW_TRUE;
-    }
-}
-
-// Waits until a VisibilityNotify event arrives for the specified window or the
-// timeout period elapses (ICCCM section 4.2.2)
-//
-static GLFWbool waitForVisibilityNotify(_GLFWwindow* window)
-{
-    XEvent dummy;
-    double timeout = 0.1;
-
-    while (!XCheckTypedWindowEvent(_glfw.x11.display,
-                                   window->x11.handle,
-                                   VisibilityNotify,
-                                   &dummy))
-    {
-        if (!waitForEvent(&timeout))
-            return GLFW_FALSE;
-    }
-
-    return GLFW_TRUE;
-}
-
-// Returns whether the window is iconified
-//
-static int getWindowState(_GLFWwindow* window)
-{
-    int result = WithdrawnState;
-    struct {
-        CARD32 state;
-        Window icon;
-    } *state = NULL;
-
-    if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.WM_STATE,
-                                  _glfw.x11.WM_STATE,
-                                  (unsigned char**) &state) >= 2)
-    {
-        result = state->state;
-    }
-
-    if (state)
-        XFree(state);
-
-    return result;
-}
-
-// Returns whether the event is a selection event
-//
-static Bool isSelectionEvent(Display* display, XEvent* event, XPointer pointer)
-{
-    if (event->xany.window != _glfw.x11.helperWindowHandle)
-        return False;
-
-    return event->type == SelectionRequest ||
-           event->type == SelectionNotify ||
-           event->type == SelectionClear;
-}
-
-// Returns whether it is a _NET_FRAME_EXTENTS event for the specified window
-//
-static Bool isFrameExtentsEvent(Display* display, XEvent* event, XPointer pointer)
-{
-    _GLFWwindow* window = (_GLFWwindow*) pointer;
-    return event->type == PropertyNotify &&
-           event->xproperty.state == PropertyNewValue &&
-           event->xproperty.window == window->x11.handle &&
-           event->xproperty.atom == _glfw.x11.NET_FRAME_EXTENTS;
-}
-
-// Returns whether it is a property event for the specified selection transfer
-//
-static Bool isSelPropNewValueNotify(Display* display, XEvent* event, XPointer pointer)
-{
-    XEvent* notification = (XEvent*) pointer;
-    return event->type == PropertyNotify &&
-           event->xproperty.state == PropertyNewValue &&
-           event->xproperty.window == notification->xselection.requestor &&
-           event->xproperty.atom == notification->xselection.property;
-}
-
-// Translates an X event modifier state mask
-//
-static int translateState(int state)
-{
-    int mods = 0;
-
-    if (state & ShiftMask)
-        mods |= GLFW_MOD_SHIFT;
-    if (state & ControlMask)
-        mods |= GLFW_MOD_CONTROL;
-    if (state & Mod1Mask)
-        mods |= GLFW_MOD_ALT;
-    if (state & Mod4Mask)
-        mods |= GLFW_MOD_SUPER;
-    if (state & LockMask)
-        mods |= GLFW_MOD_CAPS_LOCK;
-    if (state & Mod2Mask)
-        mods |= GLFW_MOD_NUM_LOCK;
-
-    return mods;
-}
-
-// Translates an X11 key code to a GLFW key token
-//
-static int translateKey(int scancode)
-{
-    // Use the pre-filled LUT (see createKeyTables() in x11_init.c)
-    if (scancode < 0 || scancode > 255)
-        return GLFW_KEY_UNKNOWN;
-
-    return _glfw.x11.keycodes[scancode];
-}
-
-// Sends an EWMH or ICCCM event to the window manager
-//
-static void sendEventToWM(_GLFWwindow* window, Atom type,
-                          long a, long b, long c, long d, long e)
-{
-    XEvent event = { ClientMessage };
-    event.xclient.window = window->x11.handle;
-    event.xclient.format = 32; // Data is 32-bit longs
-    event.xclient.message_type = type;
-    event.xclient.data.l[0] = a;
-    event.xclient.data.l[1] = b;
-    event.xclient.data.l[2] = c;
-    event.xclient.data.l[3] = d;
-    event.xclient.data.l[4] = e;
-
-    XSendEvent(_glfw.x11.display, _glfw.x11.root,
-               False,
-               SubstructureNotifyMask | SubstructureRedirectMask,
-               &event);
-}
-
-// Updates the normal hints according to the window settings
-//
-static void updateNormalHints(_GLFWwindow* window, int width, int height)
-{
-    XSizeHints* hints = XAllocSizeHints();
-
-    if (!window->monitor)
-    {
-        if (window->resizable)
-        {
-            if (window->minwidth != GLFW_DONT_CARE &&
-                window->minheight != GLFW_DONT_CARE)
-            {
-                hints->flags |= PMinSize;
-                hints->min_width = window->minwidth;
-                hints->min_height = window->minheight;
-            }
-
-            if (window->maxwidth != GLFW_DONT_CARE &&
-                window->maxheight != GLFW_DONT_CARE)
-            {
-                hints->flags |= PMaxSize;
-                hints->max_width = window->maxwidth;
-                hints->max_height = window->maxheight;
-            }
-
-            if (window->numer != GLFW_DONT_CARE &&
-                window->denom != GLFW_DONT_CARE)
-            {
-                hints->flags |= PAspect;
-                hints->min_aspect.x = hints->max_aspect.x = window->numer;
-                hints->min_aspect.y = hints->max_aspect.y = window->denom;
-            }
-        }
-        else
-        {
-            hints->flags |= (PMinSize | PMaxSize);
-            hints->min_width  = hints->max_width  = width;
-            hints->min_height = hints->max_height = height;
-        }
-    }
-
-    hints->flags |= PWinGravity;
-    hints->win_gravity = StaticGravity;
-
-    XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
-    XFree(hints);
-}
-
-// Updates the full screen status of the window
-//
-static void updateWindowMode(_GLFWwindow* window)
-{
-    if (window->monitor)
-    {
-        if (_glfw.x11.xinerama.available &&
-            _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_FULLSCREEN_MONITORS,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          window->monitor->x11.index,
-                          0);
-        }
-
-        if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_ADD,
-                          _glfw.x11.NET_WM_STATE_FULLSCREEN,
-                          0, 1, 0);
-        }
-        else
-        {
-            // This is the butcher's way of removing window decorations
-            // Setting the override-redirect attribute on a window makes the
-            // window manager ignore the window completely (ICCCM, section 4)
-            // The good thing is that this makes undecorated full screen windows
-            // easy to do; the bad thing is that we have to do everything
-            // manually and some things (like iconify/restore) won't work at
-            // all, as those are tasks usually performed by the window manager
-
-            XSetWindowAttributes attributes;
-            attributes.override_redirect = True;
-            XChangeWindowAttributes(_glfw.x11.display,
-                                    window->x11.handle,
-                                    CWOverrideRedirect,
-                                    &attributes);
-
-            window->x11.overrideRedirect = GLFW_TRUE;
-        }
-
-        // Enable compositor bypass
-        if (!window->x11.transparent)
-        {
-            const unsigned long value = 1;
-
-            XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                            _glfw.x11.NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32,
-                            PropModeReplace, (unsigned char*) &value, 1);
-        }
-    }
-    else
-    {
-        if (_glfw.x11.xinerama.available &&
-            _glfw.x11.NET_WM_FULLSCREEN_MONITORS)
-        {
-            XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_FULLSCREEN_MONITORS);
-        }
-
-        if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_REMOVE,
-                          _glfw.x11.NET_WM_STATE_FULLSCREEN,
-                          0, 1, 0);
-        }
-        else
-        {
-            XSetWindowAttributes attributes;
-            attributes.override_redirect = False;
-            XChangeWindowAttributes(_glfw.x11.display,
-                                    window->x11.handle,
-                                    CWOverrideRedirect,
-                                    &attributes);
-
-            window->x11.overrideRedirect = GLFW_FALSE;
-        }
-
-        // Disable compositor bypass
-        if (!window->x11.transparent)
-        {
-            XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_BYPASS_COMPOSITOR);
-        }
-    }
-}
-
-// Splits and translates a text/uri-list into separate file paths
-// NOTE: This function destroys the provided string
-//
-static char** parseUriList(char* text, int* count)
-{
-    const char* prefix = "file://";
-    char** paths = NULL;
-    char* line;
-
-    *count = 0;
-
-    while ((line = strtok(text, "\r\n")))
-    {
-        text = NULL;
-
-        if (line[0] == '#')
-            continue;
-
-        if (strncmp(line, prefix, strlen(prefix)) == 0)
-        {
-            line += strlen(prefix);
-            // TODO: Validate hostname
-            while (*line != '/')
-                line++;
-        }
-
-        (*count)++;
-
-        char* path = calloc(strlen(line) + 1, 1);
-        paths = realloc(paths, *count * sizeof(char*));
-        paths[*count - 1] = path;
-
-        while (*line)
-        {
-            if (line[0] == '%' && line[1] && line[2])
-            {
-                const char digits[3] = { line[1], line[2], '\0' };
-                *path = strtol(digits, NULL, 16);
-                line += 2;
-            }
-            else
-                *path = *line;
-
-            path++;
-            line++;
-        }
-    }
-
-    return paths;
-}
-
-// Encode a Unicode code point to a UTF-8 stream
-// Based on cutef8 by Jeff Bezanson (Public Domain)
-//
-static size_t encodeUTF8(char* s, unsigned int ch)
-{
-    size_t count = 0;
-
-    if (ch < 0x80)
-        s[count++] = (char) ch;
-    else if (ch < 0x800)
-    {
-        s[count++] = (ch >> 6) | 0xc0;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-    else if (ch < 0x10000)
-    {
-        s[count++] = (ch >> 12) | 0xe0;
-        s[count++] = ((ch >> 6) & 0x3f) | 0x80;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-    else if (ch < 0x110000)
-    {
-        s[count++] = (ch >> 18) | 0xf0;
-        s[count++] = ((ch >> 12) & 0x3f) | 0x80;
-        s[count++] = ((ch >> 6) & 0x3f) | 0x80;
-        s[count++] = (ch & 0x3f) | 0x80;
-    }
-
-    return count;
-}
-
-// Decode a Unicode code point from a UTF-8 stream
-// Based on cutef8 by Jeff Bezanson (Public Domain)
-//
-static unsigned int decodeUTF8(const char** s)
-{
-    unsigned int ch = 0, count = 0;
-    static const unsigned int offsets[] =
-    {
-        0x00000000u, 0x00003080u, 0x000e2080u,
-        0x03c82080u, 0xfa082080u, 0x82082080u
-    };
-
-    do
-    {
-        ch = (ch << 6) + (unsigned char) **s;
-        (*s)++;
-        count++;
-    } while ((**s & 0xc0) == 0x80);
-
-    assert(count <= 6);
-    return ch - offsets[count - 1];
-}
-
-// Convert the specified Latin-1 string to UTF-8
-//
-static char* convertLatin1toUTF8(const char* source)
-{
-    size_t size = 1;
-    const char* sp;
-
-    for (sp = source;  *sp;  sp++)
-        size += (*sp & 0x80) ? 2 : 1;
-
-    char* target = calloc(size, 1);
-    char* tp = target;
-
-    for (sp = source;  *sp;  sp++)
-        tp += encodeUTF8(tp, *sp);
-
-    return target;
-}
-
-// Updates the cursor image according to its cursor mode
-//
-static void updateCursorImage(_GLFWwindow* window)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        if (window->cursor)
-        {
-            XDefineCursor(_glfw.x11.display, window->x11.handle,
-                          window->cursor->x11.handle);
-        }
-        else
-            XUndefineCursor(_glfw.x11.display, window->x11.handle);
-    }
-    else
-    {
-        XDefineCursor(_glfw.x11.display, window->x11.handle,
-                      _glfw.x11.hiddenCursorHandle);
-    }
-}
-
-// Enable XI2 raw mouse motion events
-//
-static void enableRawMouseMotion(_GLFWwindow* window)
-{
-    XIEventMask em;
-    unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
-
-    em.deviceid = XIAllMasterDevices;
-    em.mask_len = sizeof(mask);
-    em.mask = mask;
-    XISetMask(mask, XI_RawMotion);
-
-    XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
-}
-
-// Disable XI2 raw mouse motion events
-//
-static void disableRawMouseMotion(_GLFWwindow* window)
-{
-    XIEventMask em;
-    unsigned char mask[] = { 0 };
-
-    em.deviceid = XIAllMasterDevices;
-    em.mask_len = sizeof(mask);
-    em.mask = mask;
-
-    XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1);
-}
-
-// Apply disabled cursor mode to a focused window
-//
-static void disableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        enableRawMouseMotion(window);
-
-    _glfw.x11.disabledCursorWindow = window;
-    _glfwPlatformGetCursorPos(window,
-                              &_glfw.x11.restoreCursorPosX,
-                              &_glfw.x11.restoreCursorPosY);
-    updateCursorImage(window);
-    _glfwCenterCursorInContentArea(window);
-    XGrabPointer(_glfw.x11.display, window->x11.handle, True,
-                 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
-                 GrabModeAsync, GrabModeAsync,
-                 window->x11.handle,
-                 _glfw.x11.hiddenCursorHandle,
-                 CurrentTime);
-}
-
-// Exit disabled cursor mode for the specified window
-//
-static void enableCursor(_GLFWwindow* window)
-{
-    if (window->rawMouseMotion)
-        disableRawMouseMotion(window);
-
-    _glfw.x11.disabledCursorWindow = NULL;
-    XUngrabPointer(_glfw.x11.display, CurrentTime);
-    _glfwPlatformSetCursorPos(window,
-                              _glfw.x11.restoreCursorPosX,
-                              _glfw.x11.restoreCursorPosY);
-    updateCursorImage(window);
-}
-
-// Clear its handle when the input context has been destroyed
-//
-static void inputContextDestroyCallback(XIC ic, XPointer clientData, XPointer callData)
-{
-    _GLFWwindow* window = (_GLFWwindow*) clientData;
-    window->x11.ic = NULL;
-}
-
-// Create the X11 window (and its colormap)
-//
-static GLFWbool createNativeWindow(_GLFWwindow* window,
-                                   const _GLFWwndconfig* wndconfig,
-                                   Visual* visual, int depth)
-{
-    int width = wndconfig->width;
-    int height = wndconfig->height;
-
-    if (wndconfig->scaleToMonitor)
-    {
-        width *= _glfw.x11.contentScaleX;
-        height *= _glfw.x11.contentScaleY;
-    }
-
-    // Create a colormap based on the visual used by the current context
-    window->x11.colormap = XCreateColormap(_glfw.x11.display,
-                                           _glfw.x11.root,
-                                           visual,
-                                           AllocNone);
-
-    window->x11.transparent = _glfwIsVisualTransparentX11(visual);
-
-    XSetWindowAttributes wa = { 0 };
-    wa.colormap = window->x11.colormap;
-    wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
-                    PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
-                    ExposureMask | FocusChangeMask | VisibilityChangeMask |
-                    EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
-
-    _glfwGrabErrorHandlerX11();
-
-    window->x11.parent = _glfw.x11.root;
-    window->x11.handle = XCreateWindow(_glfw.x11.display,
-                                       _glfw.x11.root,
-                                       0, 0,   // Position
-                                       width, height,
-                                       0,      // Border width
-                                       depth,  // Color depth
-                                       InputOutput,
-                                       visual,
-                                       CWBorderPixel | CWColormap | CWEventMask,
-                                       &wa);
-
-    _glfwReleaseErrorHandlerX11();
-
-    if (!window->x11.handle)
-    {
-        _glfwInputErrorX11(GLFW_PLATFORM_ERROR,
-                           "X11: Failed to create window");
-        return GLFW_FALSE;
-    }
-
-    XSaveContext(_glfw.x11.display,
-                 window->x11.handle,
-                 _glfw.x11.context,
-                 (XPointer) window);
-
-    if (!wndconfig->decorated)
-        _glfwPlatformSetWindowDecorated(window, GLFW_FALSE);
-
-    if (_glfw.x11.NET_WM_STATE && !window->monitor)
-    {
-        Atom states[3];
-        int count = 0;
-
-        if (wndconfig->floating)
-        {
-            if (_glfw.x11.NET_WM_STATE_ABOVE)
-                states[count++] = _glfw.x11.NET_WM_STATE_ABOVE;
-        }
-
-        if (wndconfig->maximized)
-        {
-            if (_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
-                _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-            {
-                states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT;
-                states[count++] = _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ;
-                window->x11.maximized = GLFW_TRUE;
-            }
-        }
-
-        if (count)
-        {
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeReplace, (unsigned char*) states, count);
-        }
-    }
-
-    // Declare the WM protocols supported by GLFW
-    {
-        Atom protocols[] =
-        {
-            _glfw.x11.WM_DELETE_WINDOW,
-            _glfw.x11.NET_WM_PING
-        };
-
-        XSetWMProtocols(_glfw.x11.display, window->x11.handle,
-                        protocols, sizeof(protocols) / sizeof(Atom));
-    }
-
-    // Declare our PID
-    {
-        const long pid = getpid();
-
-        XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                        _glfw.x11.NET_WM_PID, XA_CARDINAL, 32,
-                        PropModeReplace,
-                        (unsigned char*) &pid, 1);
-    }
-
-    if (_glfw.x11.NET_WM_WINDOW_TYPE && _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL)
-    {
-        Atom type = _glfw.x11.NET_WM_WINDOW_TYPE_NORMAL;
-        XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                        _glfw.x11.NET_WM_WINDOW_TYPE, XA_ATOM, 32,
-                        PropModeReplace, (unsigned char*) &type, 1);
-    }
-
-    // Set ICCCM WM_HINTS property
-    {
-        XWMHints* hints = XAllocWMHints();
-        if (!hints)
-        {
-            _glfwInputError(GLFW_OUT_OF_MEMORY,
-                            "X11: Failed to allocate WM hints");
-            return GLFW_FALSE;
-        }
-
-        hints->flags = StateHint;
-        hints->initial_state = NormalState;
-
-        XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
-        XFree(hints);
-    }
-
-    updateNormalHints(window, width, height);
-
-    // Set ICCCM WM_CLASS property
-    {
-        XClassHint* hint = XAllocClassHint();
-
-        if (strlen(wndconfig->x11.instanceName) &&
-            strlen(wndconfig->x11.className))
-        {
-            hint->res_name = (char*) wndconfig->x11.instanceName;
-            hint->res_class = (char*) wndconfig->x11.className;
-        }
-        else
-        {
-            const char* resourceName = getenv("RESOURCE_NAME");
-            if (resourceName && strlen(resourceName))
-                hint->res_name = (char*) resourceName;
-            else if (strlen(wndconfig->title))
-                hint->res_name = (char*) wndconfig->title;
-            else
-                hint->res_name = (char*) "glfw-application";
-
-            if (strlen(wndconfig->title))
-                hint->res_class = (char*) wndconfig->title;
-            else
-                hint->res_class = (char*) "GLFW-Application";
-        }
-
-        XSetClassHint(_glfw.x11.display, window->x11.handle, hint);
-        XFree(hint);
-    }
-
-    // Announce support for Xdnd (drag and drop)
-    {
-        const Atom version = _GLFW_XDND_VERSION;
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.XdndAware, XA_ATOM, 32,
-                        PropModeReplace, (unsigned char*) &version, 1);
-    }
-
-    if (_glfw.x11.im)
-        _glfwCreateInputContextX11(window);
-
-    _glfwPlatformSetWindowTitle(window, wndconfig->title);
-    _glfwPlatformGetWindowPos(window, &window->x11.xpos, &window->x11.ypos);
-    _glfwPlatformGetWindowSize(window, &window->x11.width, &window->x11.height);
-
-    return GLFW_TRUE;
-}
-
-// Set the specified property to the selection converted to the requested target
-//
-static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
-{
-    int i;
-    char* selectionString = NULL;
-    const Atom formats[] = { _glfw.x11.UTF8_STRING, XA_STRING };
-    const int formatCount = sizeof(formats) / sizeof(formats[0]);
-
-    if (request->selection == _glfw.x11.PRIMARY)
-        selectionString = _glfw.x11.primarySelectionString;
-    else
-        selectionString = _glfw.x11.clipboardString;
-
-    if (request->property == None)
-    {
-        // The requester is a legacy client (ICCCM section 2.2)
-        // We don't support legacy clients, so fail here
-        return None;
-    }
-
-    if (request->target == _glfw.x11.TARGETS)
-    {
-        // The list of supported targets was requested
-
-        const Atom targets[] = { _glfw.x11.TARGETS,
-                                 _glfw.x11.MULTIPLE,
-                                 _glfw.x11.UTF8_STRING,
-                                 XA_STRING };
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        XA_ATOM,
-                        32,
-                        PropModeReplace,
-                        (unsigned char*) targets,
-                        sizeof(targets) / sizeof(targets[0]));
-
-        return request->property;
-    }
-
-    if (request->target == _glfw.x11.MULTIPLE)
-    {
-        // Multiple conversions were requested
-
-        Atom* targets;
-        unsigned long i, count;
-
-        count = _glfwGetWindowPropertyX11(request->requestor,
-                                          request->property,
-                                          _glfw.x11.ATOM_PAIR,
-                                          (unsigned char**) &targets);
-
-        for (i = 0;  i < count;  i += 2)
-        {
-            int j;
-
-            for (j = 0;  j < formatCount;  j++)
-            {
-                if (targets[i] == formats[j])
-                    break;
-            }
-
-            if (j < formatCount)
-            {
-                XChangeProperty(_glfw.x11.display,
-                                request->requestor,
-                                targets[i + 1],
-                                targets[i],
-                                8,
-                                PropModeReplace,
-                                (unsigned char *) selectionString,
-                                strlen(selectionString));
-            }
-            else
-                targets[i + 1] = None;
-        }
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        _glfw.x11.ATOM_PAIR,
-                        32,
-                        PropModeReplace,
-                        (unsigned char*) targets,
-                        count);
-
-        XFree(targets);
-
-        return request->property;
-    }
-
-    if (request->target == _glfw.x11.SAVE_TARGETS)
-    {
-        // The request is a check whether we support SAVE_TARGETS
-        // It should be handled as a no-op side effect target
-
-        XChangeProperty(_glfw.x11.display,
-                        request->requestor,
-                        request->property,
-                        _glfw.x11.NULL_,
-                        32,
-                        PropModeReplace,
-                        NULL,
-                        0);
-
-        return request->property;
-    }
-
-    // Conversion to a data target was requested
-
-    for (i = 0;  i < formatCount;  i++)
-    {
-        if (request->target == formats[i])
-        {
-            // The requested target is one we support
-
-            XChangeProperty(_glfw.x11.display,
-                            request->requestor,
-                            request->property,
-                            request->target,
-                            8,
-                            PropModeReplace,
-                            (unsigned char *) selectionString,
-                            strlen(selectionString));
-
-            return request->property;
-        }
-    }
-
-    // The requested target is not supported
-
-    return None;
-}
-
-static void handleSelectionClear(XEvent* event)
-{
-    if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
-    {
-        free(_glfw.x11.primarySelectionString);
-        _glfw.x11.primarySelectionString = NULL;
-    }
-    else
-    {
-        free(_glfw.x11.clipboardString);
-        _glfw.x11.clipboardString = NULL;
-    }
-}
-
-static void handleSelectionRequest(XEvent* event)
-{
-    const XSelectionRequestEvent* request = &event->xselectionrequest;
-
-    XEvent reply = { SelectionNotify };
-    reply.xselection.property = writeTargetToProperty(request);
-    reply.xselection.display = request->display;
-    reply.xselection.requestor = request->requestor;
-    reply.xselection.selection = request->selection;
-    reply.xselection.target = request->target;
-    reply.xselection.time = request->time;
-
-    XSendEvent(_glfw.x11.display, request->requestor, False, 0, &reply);
-}
-
-static const char* getSelectionString(Atom selection)
-{
-    char** selectionString = NULL;
-    const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
-    const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
-
-    if (selection == _glfw.x11.PRIMARY)
-        selectionString = &_glfw.x11.primarySelectionString;
-    else
-        selectionString = &_glfw.x11.clipboardString;
-
-    if (XGetSelectionOwner(_glfw.x11.display, selection) ==
-        _glfw.x11.helperWindowHandle)
-    {
-        // Instead of doing a large number of X round-trips just to put this
-        // string into a window property and then read it back, just return it
-        return *selectionString;
-    }
-
-    free(*selectionString);
-    *selectionString = NULL;
-
-    for (size_t i = 0;  i < targetCount;  i++)
-    {
-        char* data;
-        Atom actualType;
-        int actualFormat;
-        unsigned long itemCount, bytesAfter;
-        XEvent notification, dummy;
-
-        XConvertSelection(_glfw.x11.display,
-                          selection,
-                          targets[i],
-                          _glfw.x11.GLFW_SELECTION,
-                          _glfw.x11.helperWindowHandle,
-                          CurrentTime);
-
-        while (!XCheckTypedWindowEvent(_glfw.x11.display,
-                                       _glfw.x11.helperWindowHandle,
-                                       SelectionNotify,
-                                       &notification))
-        {
-            waitForEvent(NULL);
-        }
-
-        if (notification.xselection.property == None)
-            continue;
-
-        XCheckIfEvent(_glfw.x11.display,
-                      &dummy,
-                      isSelPropNewValueNotify,
-                      (XPointer) &notification);
-
-        XGetWindowProperty(_glfw.x11.display,
-                           notification.xselection.requestor,
-                           notification.xselection.property,
-                           0,
-                           LONG_MAX,
-                           True,
-                           AnyPropertyType,
-                           &actualType,
-                           &actualFormat,
-                           &itemCount,
-                           &bytesAfter,
-                           (unsigned char**) &data);
-
-        if (actualType == _glfw.x11.INCR)
-        {
-            size_t size = 1;
-            char* string = NULL;
-
-            for (;;)
-            {
-                while (!XCheckIfEvent(_glfw.x11.display,
-                                      &dummy,
-                                      isSelPropNewValueNotify,
-                                      (XPointer) &notification))
-                {
-                    waitForEvent(NULL);
-                }
-
-                XFree(data);
-                XGetWindowProperty(_glfw.x11.display,
-                                   notification.xselection.requestor,
-                                   notification.xselection.property,
-                                   0,
-                                   LONG_MAX,
-                                   True,
-                                   AnyPropertyType,
-                                   &actualType,
-                                   &actualFormat,
-                                   &itemCount,
-                                   &bytesAfter,
-                                   (unsigned char**) &data);
-
-                if (itemCount)
-                {
-                    size += itemCount;
-                    string = realloc(string, size);
-                    string[size - itemCount - 1] = '\0';
-                    strcat(string, data);
-                }
-
-                if (!itemCount)
-                {
-                    if (targets[i] == XA_STRING)
-                    {
-                        *selectionString = convertLatin1toUTF8(string);
-                        free(string);
-                    }
-                    else
-                        *selectionString = string;
-
-                    break;
-                }
-            }
-        }
-        else if (actualType == targets[i])
-        {
-            if (targets[i] == XA_STRING)
-                *selectionString = convertLatin1toUTF8(data);
-            else
-                *selectionString = _glfw_strdup(data);
-        }
-
-        XFree(data);
-
-        if (*selectionString)
-            break;
-    }
-
-    if (!*selectionString)
-    {
-        _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
-                        "X11: Failed to convert selection to string");
-    }
-
-    return *selectionString;
-}
-
-// Make the specified window and its video mode active on its monitor
-//
-static void acquireMonitor(_GLFWwindow* window)
-{
-    if (_glfw.x11.saver.count == 0)
-    {
-        // Remember old screen saver settings
-        XGetScreenSaver(_glfw.x11.display,
-                        &_glfw.x11.saver.timeout,
-                        &_glfw.x11.saver.interval,
-                        &_glfw.x11.saver.blanking,
-                        &_glfw.x11.saver.exposure);
-
-        // Disable screen saver
-        XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
-                        DefaultExposures);
-    }
-
-    if (!window->monitor->window)
-        _glfw.x11.saver.count++;
-
-    _glfwSetVideoModeX11(window->monitor, &window->videoMode);
-
-    if (window->x11.overrideRedirect)
-    {
-        int xpos, ypos;
-        GLFWvidmode mode;
-
-        // Manually position the window over its monitor
-        _glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
-        _glfwPlatformGetVideoMode(window->monitor, &mode);
-
-        XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                          xpos, ypos, mode.width, mode.height);
-    }
-
-    _glfwInputMonitorWindow(window->monitor, window);
-}
-
-// Remove the window and restore the original video mode
-//
-static void releaseMonitor(_GLFWwindow* window)
-{
-    if (window->monitor->window != window)
-        return;
-
-    _glfwInputMonitorWindow(window->monitor, NULL);
-    _glfwRestoreVideoModeX11(window->monitor);
-
-    _glfw.x11.saver.count--;
-
-    if (_glfw.x11.saver.count == 0)
-    {
-        // Restore old screen saver settings
-        XSetScreenSaver(_glfw.x11.display,
-                        _glfw.x11.saver.timeout,
-                        _glfw.x11.saver.interval,
-                        _glfw.x11.saver.blanking,
-                        _glfw.x11.saver.exposure);
-    }
-}
-
-// Process the specified X event
-//
-static void processEvent(XEvent *event)
-{
-    int keycode = 0;
-    Bool filtered = False;
-
-    // HACK: Save scancode as some IMs clear the field in XFilterEvent
-    if (event->type == KeyPress || event->type == KeyRelease)
-        keycode = event->xkey.keycode;
-
-    filtered = XFilterEvent(event, None);
-
-    if (_glfw.x11.randr.available)
-    {
-        if (event->type == _glfw.x11.randr.eventBase + RRNotify)
-        {
-            XRRUpdateConfiguration(event);
-            _glfwPollMonitorsX11();
-            return;
-        }
-    }
-
-    if (_glfw.x11.xkb.available)
-    {
-        if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
-        {
-            if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
-                (((XkbEvent*) event)->state.changed & XkbGroupStateMask))
-            {
-                _glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
-            }
-
-            return;
-        }
-    }
-
-    if (event->type == GenericEvent)
-    {
-        if (_glfw.x11.xi.available)
-        {
-            _GLFWwindow* window = _glfw.x11.disabledCursorWindow;
-
-            if (window &&
-                window->rawMouseMotion &&
-                event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
-                XGetEventData(_glfw.x11.display, &event->xcookie) &&
-                event->xcookie.evtype == XI_RawMotion)
-            {
-                XIRawEvent* re = event->xcookie.data;
-                if (re->valuators.mask_len)
-                {
-                    const double* values = re->raw_values;
-                    double xpos = window->virtualCursorPosX;
-                    double ypos = window->virtualCursorPosY;
-
-                    if (XIMaskIsSet(re->valuators.mask, 0))
-                    {
-                        xpos += *values;
-                        values++;
-                    }
-
-                    if (XIMaskIsSet(re->valuators.mask, 1))
-                        ypos += *values;
-
-                    _glfwInputCursorPos(window, xpos, ypos);
-                }
-            }
-
-            XFreeEventData(_glfw.x11.display, &event->xcookie);
-        }
-
-        return;
-    }
-
-    if (event->type == SelectionClear)
-    {
-        handleSelectionClear(event);
-        return;
-    }
-    else if (event->type == SelectionRequest)
-    {
-        handleSelectionRequest(event);
-        return;
-    }
-
-    _GLFWwindow* window = NULL;
-    if (XFindContext(_glfw.x11.display,
-                     event->xany.window,
-                     _glfw.x11.context,
-                     (XPointer*) &window) != 0)
-    {
-        // This is an event for a window that has already been destroyed
-        return;
-    }
-
-    switch (event->type)
-    {
-        case ReparentNotify:
-        {
-            window->x11.parent = event->xreparent.parent;
-            return;
-        }
-
-        case KeyPress:
-        {
-            const int key = translateKey(keycode);
-            const int mods = translateState(event->xkey.state);
-            const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
-
-            if (window->x11.ic)
-            {
-                // HACK: Do not report the key press events duplicated by XIM
-                //       Duplicate key releases are filtered out implicitly by
-                //       the GLFW key repeat logic in _glfwInputKey
-                //       A timestamp per key is used to handle simultaneous keys
-                // NOTE: Always allow the first event for each key through
-                //       (the server never sends a timestamp of zero)
-                // NOTE: Timestamp difference is compared to handle wrap-around
-                Time diff = event->xkey.time - window->x11.keyPressTimes[keycode];
-                if (diff == event->xkey.time || (diff > 0 && diff < (1 << 31)))
-                {
-                    if (keycode)
-                        _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
-
-                    window->x11.keyPressTimes[keycode] = event->xkey.time;
-                }
-
-                if (!filtered)
-                {
-                    int count;
-                    Status status;
-                    char buffer[100];
-                    char* chars = buffer;
-
-                    count = Xutf8LookupString(window->x11.ic,
-                                              &event->xkey,
-                                              buffer, sizeof(buffer) - 1,
-                                              NULL, &status);
-
-                    if (status == XBufferOverflow)
-                    {
-                        chars = calloc(count + 1, 1);
-                        count = Xutf8LookupString(window->x11.ic,
-                                                  &event->xkey,
-                                                  chars, count,
-                                                  NULL, &status);
-                    }
-
-                    if (status == XLookupChars || status == XLookupBoth)
-                    {
-                        const char* c = chars;
-                        chars[count] = '\0';
-                        while (c - chars < count)
-                            _glfwInputChar(window, decodeUTF8(&c), mods, plain);
-                    }
-
-                    if (chars != buffer)
-                        free(chars);
-                }
-            }
-            else
-            {
-                KeySym keysym;
-                XLookupString(&event->xkey, NULL, 0, &keysym, NULL);
-
-                _glfwInputKey(window, key, keycode, GLFW_PRESS, mods);
-
-                const long character = _glfwKeySym2Unicode(keysym);
-                if (character != -1)
-                    _glfwInputChar(window, character, mods, plain);
-            }
-
-            return;
-        }
-
-        case KeyRelease:
-        {
-            const int key = translateKey(keycode);
-            const int mods = translateState(event->xkey.state);
-
-            if (!_glfw.x11.xkb.detectable)
-            {
-                // HACK: Key repeat events will arrive as KeyRelease/KeyPress
-                //       pairs with similar or identical time stamps
-                //       The key repeat logic in _glfwInputKey expects only key
-                //       presses to repeat, so detect and discard release events
-                if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
-                {
-                    XEvent next;
-                    XPeekEvent(_glfw.x11.display, &next);
-
-                    if (next.type == KeyPress &&
-                        next.xkey.window == event->xkey.window &&
-                        next.xkey.keycode == keycode)
-                    {
-                        // HACK: The time of repeat events sometimes doesn't
-                        //       match that of the press event, so add an
-                        //       epsilon
-                        //       Toshiyuki Takahashi can press a button
-                        //       16 times per second so it's fairly safe to
-                        //       assume that no human is pressing the key 50
-                        //       times per second (value is ms)
-                        if ((next.xkey.time - event->xkey.time) < 20)
-                        {
-                            // This is very likely a server-generated key repeat
-                            // event, so ignore it
-                            return;
-                        }
-                    }
-                }
-            }
-
-            _glfwInputKey(window, key, keycode, GLFW_RELEASE, mods);
-            return;
-        }
-
-        case ButtonPress:
-        {
-            const int mods = translateState(event->xbutton.state);
-
-            if (event->xbutton.button == Button1)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
-            else if (event->xbutton.button == Button2)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
-            else if (event->xbutton.button == Button3)
-                _glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
-
-            // Modern X provides scroll events as mouse button presses
-            else if (event->xbutton.button == Button4)
-                _glfwInputScroll(window, 0.0, 1.0);
-            else if (event->xbutton.button == Button5)
-                _glfwInputScroll(window, 0.0, -1.0);
-            else if (event->xbutton.button == Button6)
-                _glfwInputScroll(window, 1.0, 0.0);
-            else if (event->xbutton.button == Button7)
-                _glfwInputScroll(window, -1.0, 0.0);
-
-            else
-            {
-                // Additional buttons after 7 are treated as regular buttons
-                // We subtract 4 to fill the gap left by scroll input above
-                _glfwInputMouseClick(window,
-                                     event->xbutton.button - Button1 - 4,
-                                     GLFW_PRESS,
-                                     mods);
-            }
-
-            return;
-        }
-
-        case ButtonRelease:
-        {
-            const int mods = translateState(event->xbutton.state);
-
-            if (event->xbutton.button == Button1)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_LEFT,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button == Button2)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_MIDDLE,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button == Button3)
-            {
-                _glfwInputMouseClick(window,
-                                     GLFW_MOUSE_BUTTON_RIGHT,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-            else if (event->xbutton.button > Button7)
-            {
-                // Additional buttons after 7 are treated as regular buttons
-                // We subtract 4 to fill the gap left by scroll input above
-                _glfwInputMouseClick(window,
-                                     event->xbutton.button - Button1 - 4,
-                                     GLFW_RELEASE,
-                                     mods);
-            }
-
-            return;
-        }
-
-        case EnterNotify:
-        {
-            // XEnterWindowEvent is XCrossingEvent
-            const int x = event->xcrossing.x;
-            const int y = event->xcrossing.y;
-
-            // HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
-            //       ignore the defined cursor for hidden cursor mode
-            if (window->cursorMode == GLFW_CURSOR_HIDDEN)
-                updateCursorImage(window);
-
-            _glfwInputCursorEnter(window, GLFW_TRUE);
-            _glfwInputCursorPos(window, x, y);
-
-            window->x11.lastCursorPosX = x;
-            window->x11.lastCursorPosY = y;
-            return;
-        }
-
-        case LeaveNotify:
-        {
-            _glfwInputCursorEnter(window, GLFW_FALSE);
-            return;
-        }
-
-        case MotionNotify:
-        {
-            const int x = event->xmotion.x;
-            const int y = event->xmotion.y;
-
-            if (x != window->x11.warpCursorPosX ||
-                y != window->x11.warpCursorPosY)
-            {
-                // The cursor was moved by something other than GLFW
-
-                if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                {
-                    if (_glfw.x11.disabledCursorWindow != window)
-                        return;
-                    if (window->rawMouseMotion)
-                        return;
-
-                    const int dx = x - window->x11.lastCursorPosX;
-                    const int dy = y - window->x11.lastCursorPosY;
-
-                    _glfwInputCursorPos(window,
-                                        window->virtualCursorPosX + dx,
-                                        window->virtualCursorPosY + dy);
-                }
-                else
-                    _glfwInputCursorPos(window, x, y);
-            }
-
-            window->x11.lastCursorPosX = x;
-            window->x11.lastCursorPosY = y;
-            return;
-        }
-
-        case ConfigureNotify:
-        {
-            if (event->xconfigure.width != window->x11.width ||
-                event->xconfigure.height != window->x11.height)
-            {
-                _glfwInputFramebufferSize(window,
-                                          event->xconfigure.width,
-                                          event->xconfigure.height);
-
-                _glfwInputWindowSize(window,
-                                     event->xconfigure.width,
-                                     event->xconfigure.height);
-
-                window->x11.width = event->xconfigure.width;
-                window->x11.height = event->xconfigure.height;
-            }
-
-            int xpos = event->xconfigure.x;
-            int ypos = event->xconfigure.y;
-
-            // NOTE: ConfigureNotify events from the server are in local
-            //       coordinates, so if we are reparented we need to translate
-            //       the position into root (screen) coordinates
-            if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
-            {
-                _glfwGrabErrorHandlerX11();
-
-                Window dummy;
-                XTranslateCoordinates(_glfw.x11.display,
-                                      window->x11.parent,
-                                      _glfw.x11.root,
-                                      xpos, ypos,
-                                      &xpos, &ypos,
-                                      &dummy);
-
-                _glfwReleaseErrorHandlerX11();
-                if (_glfw.x11.errorCode == BadWindow)
-                    return;
-            }
-
-            if (xpos != window->x11.xpos || ypos != window->x11.ypos)
-            {
-                _glfwInputWindowPos(window, xpos, ypos);
-                window->x11.xpos = xpos;
-                window->x11.ypos = ypos;
-            }
-
-            return;
-        }
-
-        case ClientMessage:
-        {
-            // Custom client message, probably from the window manager
-
-            if (filtered)
-                return;
-
-            if (event->xclient.message_type == None)
-                return;
-
-            if (event->xclient.message_type == _glfw.x11.WM_PROTOCOLS)
-            {
-                const Atom protocol = event->xclient.data.l[0];
-                if (protocol == None)
-                    return;
-
-                if (protocol == _glfw.x11.WM_DELETE_WINDOW)
-                {
-                    // The window manager was asked to close the window, for
-                    // example by the user pressing a 'close' window decoration
-                    // button
-                    _glfwInputWindowCloseRequest(window);
-                }
-                else if (protocol == _glfw.x11.NET_WM_PING)
-                {
-                    // The window manager is pinging the application to ensure
-                    // it's still responding to events
-
-                    XEvent reply = *event;
-                    reply.xclient.window = _glfw.x11.root;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.root,
-                               False,
-                               SubstructureNotifyMask | SubstructureRedirectMask,
-                               &reply);
-                }
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndEnter)
-            {
-                // A drag operation has entered the window
-                unsigned long i, count;
-                Atom* formats = NULL;
-                const GLFWbool list = event->xclient.data.l[1] & 1;
-
-                _glfw.x11.xdnd.source  = event->xclient.data.l[0];
-                _glfw.x11.xdnd.version = event->xclient.data.l[1] >> 24;
-                _glfw.x11.xdnd.format  = None;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                if (list)
-                {
-                    count = _glfwGetWindowPropertyX11(_glfw.x11.xdnd.source,
-                                                      _glfw.x11.XdndTypeList,
-                                                      XA_ATOM,
-                                                      (unsigned char**) &formats);
-                }
-                else
-                {
-                    count = 3;
-                    formats = (Atom*) event->xclient.data.l + 2;
-                }
-
-                for (i = 0;  i < count;  i++)
-                {
-                    if (formats[i] == _glfw.x11.text_uri_list)
-                    {
-                        _glfw.x11.xdnd.format = _glfw.x11.text_uri_list;
-                        break;
-                    }
-                }
-
-                if (list && formats)
-                    XFree(formats);
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndDrop)
-            {
-                // The drag operation has finished by dropping on the window
-                Time time = CurrentTime;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                if (_glfw.x11.xdnd.format)
-                {
-                    if (_glfw.x11.xdnd.version >= 1)
-                        time = event->xclient.data.l[2];
-
-                    // Request the chosen format from the source window
-                    XConvertSelection(_glfw.x11.display,
-                                      _glfw.x11.XdndSelection,
-                                      _glfw.x11.xdnd.format,
-                                      _glfw.x11.XdndSelection,
-                                      window->x11.handle,
-                                      time);
-                }
-                else if (_glfw.x11.xdnd.version >= 2)
-                {
-                    XEvent reply = { ClientMessage };
-                    reply.xclient.window = _glfw.x11.xdnd.source;
-                    reply.xclient.message_type = _glfw.x11.XdndFinished;
-                    reply.xclient.format = 32;
-                    reply.xclient.data.l[0] = window->x11.handle;
-                    reply.xclient.data.l[1] = 0; // The drag was rejected
-                    reply.xclient.data.l[2] = None;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                               False, NoEventMask, &reply);
-                    XFlush(_glfw.x11.display);
-                }
-            }
-            else if (event->xclient.message_type == _glfw.x11.XdndPosition)
-            {
-                // The drag operation has moved over the window
-                const int xabs = (event->xclient.data.l[2] >> 16) & 0xffff;
-                const int yabs = (event->xclient.data.l[2]) & 0xffff;
-                Window dummy;
-                int xpos, ypos;
-
-                if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
-                    return;
-
-                XTranslateCoordinates(_glfw.x11.display,
-                                      _glfw.x11.root,
-                                      window->x11.handle,
-                                      xabs, yabs,
-                                      &xpos, &ypos,
-                                      &dummy);
-
-                _glfwInputCursorPos(window, xpos, ypos);
-
-                XEvent reply = { ClientMessage };
-                reply.xclient.window = _glfw.x11.xdnd.source;
-                reply.xclient.message_type = _glfw.x11.XdndStatus;
-                reply.xclient.format = 32;
-                reply.xclient.data.l[0] = window->x11.handle;
-                reply.xclient.data.l[2] = 0; // Specify an empty rectangle
-                reply.xclient.data.l[3] = 0;
-
-                if (_glfw.x11.xdnd.format)
-                {
-                    // Reply that we are ready to copy the dragged data
-                    reply.xclient.data.l[1] = 1; // Accept with no rectangle
-                    if (_glfw.x11.xdnd.version >= 2)
-                        reply.xclient.data.l[4] = _glfw.x11.XdndActionCopy;
-                }
-
-                XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                           False, NoEventMask, &reply);
-                XFlush(_glfw.x11.display);
-            }
-
-            return;
-        }
-
-        case SelectionNotify:
-        {
-            if (event->xselection.property == _glfw.x11.XdndSelection)
-            {
-                // The converted data from the drag operation has arrived
-                char* data;
-                const unsigned long result =
-                    _glfwGetWindowPropertyX11(event->xselection.requestor,
-                                              event->xselection.property,
-                                              event->xselection.target,
-                                              (unsigned char**) &data);
-
-                if (result)
-                {
-                    int i, count;
-                    char** paths = parseUriList(data, &count);
-
-                    _glfwInputDrop(window, count, (const char**) paths);
-
-                    for (i = 0;  i < count;  i++)
-                        free(paths[i]);
-                    free(paths);
-                }
-
-                if (data)
-                    XFree(data);
-
-                if (_glfw.x11.xdnd.version >= 2)
-                {
-                    XEvent reply = { ClientMessage };
-                    reply.xclient.window = _glfw.x11.xdnd.source;
-                    reply.xclient.message_type = _glfw.x11.XdndFinished;
-                    reply.xclient.format = 32;
-                    reply.xclient.data.l[0] = window->x11.handle;
-                    reply.xclient.data.l[1] = result;
-                    reply.xclient.data.l[2] = _glfw.x11.XdndActionCopy;
-
-                    XSendEvent(_glfw.x11.display, _glfw.x11.xdnd.source,
-                               False, NoEventMask, &reply);
-                    XFlush(_glfw.x11.display);
-                }
-            }
-
-            return;
-        }
-
-        case FocusIn:
-        {
-            if (event->xfocus.mode == NotifyGrab ||
-                event->xfocus.mode == NotifyUngrab)
-            {
-                // Ignore focus events from popup indicator windows, window menu
-                // key chords and window dragging
-                return;
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                disableCursor(window);
-
-            if (window->x11.ic)
-                XSetICFocus(window->x11.ic);
-
-            _glfwInputWindowFocus(window, GLFW_TRUE);
-            return;
-        }
-
-        case FocusOut:
-        {
-            if (event->xfocus.mode == NotifyGrab ||
-                event->xfocus.mode == NotifyUngrab)
-            {
-                // Ignore focus events from popup indicator windows, window menu
-                // key chords and window dragging
-                return;
-            }
-
-            if (window->cursorMode == GLFW_CURSOR_DISABLED)
-                enableCursor(window);
-
-            if (window->x11.ic)
-                XUnsetICFocus(window->x11.ic);
-
-            if (window->monitor && window->autoIconify)
-                _glfwPlatformIconifyWindow(window);
-
-            _glfwInputWindowFocus(window, GLFW_FALSE);
-            return;
-        }
-
-        case Expose:
-        {
-            _glfwInputWindowDamage(window);
-            return;
-        }
-
-        case PropertyNotify:
-        {
-            if (event->xproperty.state != PropertyNewValue)
-                return;
-
-            if (event->xproperty.atom == _glfw.x11.WM_STATE)
-            {
-                const int state = getWindowState(window);
-                if (state != IconicState && state != NormalState)
-                    return;
-
-                const GLFWbool iconified = (state == IconicState);
-                if (window->x11.iconified != iconified)
-                {
-                    if (window->monitor)
-                    {
-                        if (iconified)
-                            releaseMonitor(window);
-                        else
-                            acquireMonitor(window);
-                    }
-
-                    window->x11.iconified = iconified;
-                    _glfwInputWindowIconify(window, iconified);
-                }
-            }
-            else if (event->xproperty.atom == _glfw.x11.NET_WM_STATE)
-            {
-                const GLFWbool maximized = _glfwPlatformWindowMaximized(window);
-                if (window->x11.maximized != maximized)
-                {
-                    window->x11.maximized = maximized;
-                    _glfwInputWindowMaximize(window, maximized);
-                }
-            }
-
-            return;
-        }
-
-        case DestroyNotify:
-            return;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Retrieve a single window property of the specified type
-// Inspired by fghGetWindowProperty from freeglut
-//
-unsigned long _glfwGetWindowPropertyX11(Window window,
-                                        Atom property,
-                                        Atom type,
-                                        unsigned char** value)
-{
-    Atom actualType;
-    int actualFormat;
-    unsigned long itemCount, bytesAfter;
-
-    XGetWindowProperty(_glfw.x11.display,
-                       window,
-                       property,
-                       0,
-                       LONG_MAX,
-                       False,
-                       type,
-                       &actualType,
-                       &actualFormat,
-                       &itemCount,
-                       &bytesAfter,
-                       value);
-
-    return itemCount;
-}
-
-GLFWbool _glfwIsVisualTransparentX11(Visual* visual)
-{
-    if (!_glfw.x11.xrender.available)
-        return GLFW_FALSE;
-
-    XRenderPictFormat* pf = XRenderFindVisualFormat(_glfw.x11.display, visual);
-    return pf && pf->direct.alphaMask;
-}
-
-// Push contents of our selection to clipboard manager
-//
-void _glfwPushSelectionToManagerX11(void)
-{
-    XConvertSelection(_glfw.x11.display,
-                      _glfw.x11.CLIPBOARD_MANAGER,
-                      _glfw.x11.SAVE_TARGETS,
-                      None,
-                      _glfw.x11.helperWindowHandle,
-                      CurrentTime);
-
-    for (;;)
-    {
-        XEvent event;
-
-        while (XCheckIfEvent(_glfw.x11.display, &event, isSelectionEvent, NULL))
-        {
-            switch (event.type)
-            {
-                case SelectionRequest:
-                    handleSelectionRequest(&event);
-                    break;
-
-                case SelectionClear:
-                    handleSelectionClear(&event);
-                    break;
-
-                case SelectionNotify:
-                {
-                    if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
-                    {
-                        // This means one of two things; either the selection
-                        // was not owned, which means there is no clipboard
-                        // manager, or the transfer to the clipboard manager has
-                        // completed
-                        // In either case, it means we are done here
-                        return;
-                    }
-
-                    break;
-                }
-            }
-        }
-
-        waitForEvent(NULL);
-    }
-}
-
-void _glfwCreateInputContextX11(_GLFWwindow* window)
-{
-    XIMCallback callback;
-    callback.callback = (XIMProc) inputContextDestroyCallback;
-    callback.client_data = (XPointer) window;
-
-    window->x11.ic = XCreateIC(_glfw.x11.im,
-                               XNInputStyle,
-                               XIMPreeditNothing | XIMStatusNothing,
-                               XNClientWindow,
-                               window->x11.handle,
-                               XNFocusWindow,
-                               window->x11.handle,
-                               XNDestroyCallback,
-                               &callback,
-                               NULL);
-
-    if (window->x11.ic)
-    {
-        XWindowAttributes attribs;
-        XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
-
-        unsigned long filter = 0;
-        if (XGetICValues(window->x11.ic, XNFilterEvents, &filter, NULL) == NULL)
-        {
-            XSelectInput(_glfw.x11.display,
-                         window->x11.handle,
-                         attribs.your_event_mask | filter);
-        }
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW platform API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-int _glfwPlatformCreateWindow(_GLFWwindow* window,
-                              const _GLFWwndconfig* wndconfig,
-                              const _GLFWctxconfig* ctxconfig,
-                              const _GLFWfbconfig* fbconfig)
-{
-    Visual* visual = NULL;
-    int depth;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwInitGLX())
-                return GLFW_FALSE;
-            if (!_glfwChooseVisualGLX(wndconfig, ctxconfig, fbconfig, &visual, &depth))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwInitEGL())
-                return GLFW_FALSE;
-            if (!_glfwChooseVisualEGL(wndconfig, ctxconfig, fbconfig, &visual, &depth))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwInitOSMesa())
-                return GLFW_FALSE;
-        }
-    }
-
-    if (!visual)
-    {
-        visual = DefaultVisual(_glfw.x11.display, _glfw.x11.screen);
-        depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
-    }
-
-    if (!createNativeWindow(window, wndconfig, visual, depth))
-        return GLFW_FALSE;
-
-    if (ctxconfig->client != GLFW_NO_API)
-    {
-        if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
-        {
-            if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
-        {
-            if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-        else if (ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
-        {
-            if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
-                return GLFW_FALSE;
-        }
-    }
-
-    if (window->monitor)
-    {
-        _glfwPlatformShowWindow(window);
-        updateWindowMode(window);
-        acquireMonitor(window);
-    }
-
-    XFlush(_glfw.x11.display);
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyWindow(_GLFWwindow* window)
-{
-    if (_glfw.x11.disabledCursorWindow == window)
-        _glfw.x11.disabledCursorWindow = NULL;
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    if (window->x11.ic)
-    {
-        XDestroyIC(window->x11.ic);
-        window->x11.ic = NULL;
-    }
-
-    if (window->context.destroy)
-        window->context.destroy(window);
-
-    if (window->x11.handle)
-    {
-        XDeleteContext(_glfw.x11.display, window->x11.handle, _glfw.x11.context);
-        XUnmapWindow(_glfw.x11.display, window->x11.handle);
-        XDestroyWindow(_glfw.x11.display, window->x11.handle);
-        window->x11.handle = (Window) 0;
-    }
-
-    if (window->x11.colormap)
-    {
-        XFreeColormap(_glfw.x11.display, window->x11.colormap);
-        window->x11.colormap = (Colormap) 0;
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
-{
-    if (_glfw.x11.xlib.utf8)
-    {
-        Xutf8SetWMProperties(_glfw.x11.display,
-                             window->x11.handle,
-                             title, title,
-                             NULL, 0,
-                             NULL, NULL, NULL);
-    }
-
-    XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                    _glfw.x11.NET_WM_NAME, _glfw.x11.UTF8_STRING, 8,
-                    PropModeReplace,
-                    (unsigned char*) title, strlen(title));
-
-    XChangeProperty(_glfw.x11.display,  window->x11.handle,
-                    _glfw.x11.NET_WM_ICON_NAME, _glfw.x11.UTF8_STRING, 8,
-                    PropModeReplace,
-                    (unsigned char*) title, strlen(title));
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
-                                int count, const GLFWimage* images)
-{
-    if (count)
-    {
-        int i, j, longCount = 0;
-
-        for (i = 0;  i < count;  i++)
-            longCount += 2 + images[i].width * images[i].height;
-
-        long* icon = calloc(longCount, sizeof(long));
-        long* target = icon;
-
-        for (i = 0;  i < count;  i++)
-        {
-            *target++ = images[i].width;
-            *target++ = images[i].height;
-
-            for (j = 0;  j < images[i].width * images[i].height;  j++)
-            {
-                *target++ = (images[i].pixels[j * 4 + 0] << 16) |
-                            (images[i].pixels[j * 4 + 1] <<  8) |
-                            (images[i].pixels[j * 4 + 2] <<  0) |
-                            (images[i].pixels[j * 4 + 3] << 24);
-            }
-        }
-
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_ICON,
-                        XA_CARDINAL, 32,
-                        PropModeReplace,
-                        (unsigned char*) icon,
-                        longCount);
-
-        free(icon);
-    }
-    else
-    {
-        XDeleteProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_ICON);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
-{
-    Window dummy;
-    int x, y;
-
-    XTranslateCoordinates(_glfw.x11.display, window->x11.handle, _glfw.x11.root,
-                          0, 0, &x, &y, &dummy);
-
-    if (xpos)
-        *xpos = x;
-    if (ypos)
-        *ypos = y;
-}
-
-void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
-{
-    // HACK: Explicitly setting PPosition to any value causes some WMs, notably
-    //       Compiz and Metacity, to honor the position of unmapped windows
-    if (!_glfwPlatformWindowVisible(window))
-    {
-        long supplied;
-        XSizeHints* hints = XAllocSizeHints();
-
-        if (XGetWMNormalHints(_glfw.x11.display, window->x11.handle, hints, &supplied))
-        {
-            hints->flags |= PPosition;
-            hints->x = hints->y = 0;
-
-            XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
-        }
-
-        XFree(hints);
-    }
-
-    XMoveWindow(_glfw.x11.display, window->x11.handle, xpos, ypos);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
-{
-    XWindowAttributes attribs;
-    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &attribs);
-
-    if (width)
-        *width = attribs.width;
-    if (height)
-        *height = attribs.height;
-}
-
-void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
-{
-    if (window->monitor)
-    {
-        if (window->monitor->window == window)
-            acquireMonitor(window);
-    }
-    else
-    {
-        if (!window->resizable)
-            updateNormalHints(window, width, height);
-
-        XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
-                                      int minwidth, int minheight,
-                                      int maxwidth, int maxheight)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
-{
-    _glfwPlatformGetWindowSize(window, width, height);
-}
-
-void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
-                                     int* left, int* top,
-                                     int* right, int* bottom)
-{
-    long* extents = NULL;
-
-    if (window->monitor || !window->decorated)
-        return;
-
-    if (_glfw.x11.NET_FRAME_EXTENTS == None)
-        return;
-
-    if (!_glfwPlatformWindowVisible(window) &&
-        _glfw.x11.NET_REQUEST_FRAME_EXTENTS)
-    {
-        XEvent event;
-        double timeout = 0.5;
-
-        // Ensure _NET_FRAME_EXTENTS is set, allowing glfwGetWindowFrameSize to
-        // function before the window is mapped
-        sendEventToWM(window, _glfw.x11.NET_REQUEST_FRAME_EXTENTS,
-                      0, 0, 0, 0, 0);
-
-        // HACK: Use a timeout because earlier versions of some window managers
-        //       (at least Unity, Fluxbox and Xfwm) failed to send the reply
-        //       They have been fixed but broken versions are still in the wild
-        //       If you are affected by this and your window manager is NOT
-        //       listed above, PLEASE report it to their and our issue trackers
-        while (!XCheckIfEvent(_glfw.x11.display,
-                              &event,
-                              isFrameExtentsEvent,
-                              (XPointer) window))
-        {
-            if (!waitForEvent(&timeout))
-            {
-                _glfwInputError(GLFW_PLATFORM_ERROR,
-                                "X11: The window manager has a broken _NET_REQUEST_FRAME_EXTENTS implementation; please report this issue");
-                return;
-            }
-        }
-    }
-
-    if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.NET_FRAME_EXTENTS,
-                                  XA_CARDINAL,
-                                  (unsigned char**) &extents) == 4)
-    {
-        if (left)
-            *left = extents[0];
-        if (top)
-            *top = extents[2];
-        if (right)
-            *right = extents[1];
-        if (bottom)
-            *bottom = extents[3];
-    }
-
-    if (extents)
-        XFree(extents);
-}
-
-void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
-                                        float* xscale, float* yscale)
-{
-    if (xscale)
-        *xscale = _glfw.x11.contentScaleX;
-    if (yscale)
-        *yscale = _glfw.x11.contentScaleY;
-}
-
-void _glfwPlatformIconifyWindow(_GLFWwindow* window)
-{
-    if (window->x11.overrideRedirect)
-    {
-        // Override-redirect windows cannot be iconified or restored, as those
-        // tasks are performed by the window manager
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
-        return;
-    }
-
-    XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformRestoreWindow(_GLFWwindow* window)
-{
-    if (window->x11.overrideRedirect)
-    {
-        // Override-redirect windows cannot be iconified or restored, as those
-        // tasks are performed by the window manager
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Iconification of full screen windows requires a WM that supports EWMH full screen");
-        return;
-    }
-
-    if (_glfwPlatformWindowIconified(window))
-    {
-        XMapWindow(_glfw.x11.display, window->x11.handle);
-        waitForVisibilityNotify(window);
-    }
-    else if (_glfwPlatformWindowVisible(window))
-    {
-        if (_glfw.x11.NET_WM_STATE &&
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT &&
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-        {
-            sendEventToWM(window,
-                          _glfw.x11.NET_WM_STATE,
-                          _NET_WM_STATE_REMOVE,
-                          _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-                          _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
-                          1, 0);
-        }
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
-{
-    if (!_glfw.x11.NET_WM_STATE ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-    {
-        return;
-    }
-
-    if (_glfwPlatformWindowVisible(window))
-    {
-        sendEventToWM(window,
-                    _glfw.x11.NET_WM_STATE,
-                    _NET_WM_STATE_ADD,
-                    _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-                    _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ,
-                    1, 0);
-    }
-    else
-    {
-        Atom* states = NULL;
-        unsigned long count =
-            _glfwGetWindowPropertyX11(window->x11.handle,
-                                      _glfw.x11.NET_WM_STATE,
-                                      XA_ATOM,
-                                      (unsigned char**) &states);
-
-        // NOTE: We don't check for failure as this property may not exist yet
-        //       and that's fine (and we'll create it implicitly with append)
-
-        Atom missing[2] =
-        {
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
-            _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
-        };
-        unsigned long missingCount = 2;
-
-        for (unsigned long i = 0;  i < count;  i++)
-        {
-            for (unsigned long j = 0;  j < missingCount;  j++)
-            {
-                if (states[i] == missing[j])
-                {
-                    missing[j] = missing[missingCount - 1];
-                    missingCount--;
-                }
-            }
-        }
-
-        if (states)
-            XFree(states);
-
-        if (!missingCount)
-            return;
-
-        XChangeProperty(_glfw.x11.display, window->x11.handle,
-                        _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                        PropModeAppend,
-                        (unsigned char*) missing,
-                        missingCount);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformShowWindow(_GLFWwindow* window)
-{
-    if (_glfwPlatformWindowVisible(window))
-        return;
-
-    XMapWindow(_glfw.x11.display, window->x11.handle);
-    waitForVisibilityNotify(window);
-}
-
-void _glfwPlatformHideWindow(_GLFWwindow* window)
-{
-    XUnmapWindow(_glfw.x11.display, window->x11.handle);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
-{
-    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION)
-        return;
-
-    sendEventToWM(window,
-                  _glfw.x11.NET_WM_STATE,
-                  _NET_WM_STATE_ADD,
-                  _glfw.x11.NET_WM_STATE_DEMANDS_ATTENTION,
-                  0, 1, 0);
-}
-
-void _glfwPlatformFocusWindow(_GLFWwindow* window)
-{
-    if (_glfw.x11.NET_ACTIVE_WINDOW)
-        sendEventToWM(window, _glfw.x11.NET_ACTIVE_WINDOW, 1, 0, 0, 0, 0);
-    else if (_glfwPlatformWindowVisible(window))
-    {
-        XRaiseWindow(_glfw.x11.display, window->x11.handle);
-        XSetInputFocus(_glfw.x11.display, window->x11.handle,
-                       RevertToParent, CurrentTime);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
-                                   _GLFWmonitor* monitor,
-                                   int xpos, int ypos,
-                                   int width, int height,
-                                   int refreshRate)
-{
-    if (window->monitor == monitor)
-    {
-        if (monitor)
-        {
-            if (monitor->window == window)
-                acquireMonitor(window);
-        }
-        else
-        {
-            if (!window->resizable)
-                updateNormalHints(window, width, height);
-
-            XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                              xpos, ypos, width, height);
-        }
-
-        XFlush(_glfw.x11.display);
-        return;
-    }
-
-    if (window->monitor)
-        releaseMonitor(window);
-
-    _glfwInputWindowMonitor(window, monitor);
-    updateNormalHints(window, width, height);
-
-    if (window->monitor)
-    {
-        if (!_glfwPlatformWindowVisible(window))
-        {
-            XMapRaised(_glfw.x11.display, window->x11.handle);
-            waitForVisibilityNotify(window);
-        }
-
-        updateWindowMode(window);
-        acquireMonitor(window);
-    }
-    else
-    {
-        updateWindowMode(window);
-        XMoveResizeWindow(_glfw.x11.display, window->x11.handle,
-                          xpos, ypos, width, height);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-int _glfwPlatformWindowFocused(_GLFWwindow* window)
-{
-    Window focused;
-    int state;
-
-    XGetInputFocus(_glfw.x11.display, &focused, &state);
-    return window->x11.handle == focused;
-}
-
-int _glfwPlatformWindowIconified(_GLFWwindow* window)
-{
-    return getWindowState(window) == IconicState;
-}
-
-int _glfwPlatformWindowVisible(_GLFWwindow* window)
-{
-    XWindowAttributes wa;
-    XGetWindowAttributes(_glfw.x11.display, window->x11.handle, &wa);
-    return wa.map_state == IsViewable;
-}
-
-int _glfwPlatformWindowMaximized(_GLFWwindow* window)
-{
-    Atom* states;
-    unsigned long i;
-    GLFWbool maximized = GLFW_FALSE;
-
-    if (!_glfw.x11.NET_WM_STATE ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-        !_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-    {
-        return maximized;
-    }
-
-    const unsigned long count =
-        _glfwGetWindowPropertyX11(window->x11.handle,
-                                  _glfw.x11.NET_WM_STATE,
-                                  XA_ATOM,
-                                  (unsigned char**) &states);
-
-    for (i = 0;  i < count;  i++)
-    {
-        if (states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_VERT ||
-            states[i] == _glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ)
-        {
-            maximized = GLFW_TRUE;
-            break;
-        }
-    }
-
-    if (states)
-        XFree(states);
-
-    return maximized;
-}
-
-int _glfwPlatformWindowHovered(_GLFWwindow* window)
-{
-    Window w = _glfw.x11.root;
-    while (w)
-    {
-        Window root;
-        int rootX, rootY, childX, childY;
-        unsigned int mask;
-
-        _glfwGrabErrorHandlerX11();
-
-        const Bool result = XQueryPointer(_glfw.x11.display, w,
-                                          &root, &w, &rootX, &rootY,
-                                          &childX, &childY, &mask);
-
-        _glfwReleaseErrorHandlerX11();
-
-        if (_glfw.x11.errorCode == BadWindow)
-            w = _glfw.x11.root;
-        else if (!result)
-            return GLFW_FALSE;
-        else if (w == window->x11.handle)
-            return GLFW_TRUE;
-    }
-
-    return GLFW_FALSE;
-}
-
-int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
-{
-    if (!window->x11.transparent)
-        return GLFW_FALSE;
-
-    return XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx) != None;
-}
-
-void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
-{
-    int width, height;
-    _glfwPlatformGetWindowSize(window, &width, &height);
-    updateNormalHints(window, width, height);
-}
-
-void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
-{
-    struct
-    {
-        unsigned long flags;
-        unsigned long functions;
-        unsigned long decorations;
-        long input_mode;
-        unsigned long status;
-    } hints = {0};
-
-    hints.flags = MWM_HINTS_DECORATIONS;
-    hints.decorations = enabled ? MWM_DECOR_ALL : 0;
-
-    XChangeProperty(_glfw.x11.display, window->x11.handle,
-                    _glfw.x11.MOTIF_WM_HINTS,
-                    _glfw.x11.MOTIF_WM_HINTS, 32,
-                    PropModeReplace,
-                    (unsigned char*) &hints,
-                    sizeof(hints) / sizeof(long));
-}
-
-void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_ABOVE)
-        return;
-
-    if (_glfwPlatformWindowVisible(window))
-    {
-        const long action = enabled ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
-        sendEventToWM(window,
-                      _glfw.x11.NET_WM_STATE,
-                      action,
-                      _glfw.x11.NET_WM_STATE_ABOVE,
-                      0, 1, 0);
-    }
-    else
-    {
-        Atom* states = NULL;
-        unsigned long i, count;
-
-        count = _glfwGetWindowPropertyX11(window->x11.handle,
-                                          _glfw.x11.NET_WM_STATE,
-                                          XA_ATOM,
-                                          (unsigned char**) &states);
-
-        // NOTE: We don't check for failure as this property may not exist yet
-        //       and that's fine (and we'll create it implicitly with append)
-
-        if (enabled)
-        {
-            for (i = 0;  i < count;  i++)
-            {
-                if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
-                    break;
-            }
-
-            if (i < count)
-                return;
-
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeAppend,
-                            (unsigned char*) &_glfw.x11.NET_WM_STATE_ABOVE,
-                            1);
-        }
-        else if (states)
-        {
-            for (i = 0;  i < count;  i++)
-            {
-                if (states[i] == _glfw.x11.NET_WM_STATE_ABOVE)
-                    break;
-            }
-
-            if (i == count)
-                return;
-
-            states[i] = states[count - 1];
-            count--;
-
-            XChangeProperty(_glfw.x11.display, window->x11.handle,
-                            _glfw.x11.NET_WM_STATE, XA_ATOM, 32,
-                            PropModeReplace, (unsigned char*) states, count);
-        }
-
-        if (states)
-            XFree(states);
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
-{
-    if (!_glfw.x11.xshape.available)
-        return;
-
-    if (enabled)
-    {
-        Region region = XCreateRegion();
-        XShapeCombineRegion(_glfw.x11.display, window->x11.handle,
-                            ShapeInput, 0, 0, region, ShapeSet);
-        XDestroyRegion(region);
-    }
-    else
-    {
-        XShapeCombineMask(_glfw.x11.display, window->x11.handle,
-                          ShapeInput, 0, 0, None, ShapeSet);
-    }
-}
-
-float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
-{
-    float opacity = 1.f;
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.NET_WM_CM_Sx))
-    {
-        CARD32* value = NULL;
-
-        if (_glfwGetWindowPropertyX11(window->x11.handle,
-                                      _glfw.x11.NET_WM_WINDOW_OPACITY,
-                                      XA_CARDINAL,
-                                      (unsigned char**) &value))
-        {
-            opacity = (float) (*value / (double) 0xffffffffu);
-        }
-
-        if (value)
-            XFree(value);
-    }
-
-    return opacity;
-}
-
-void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
-{
-    const CARD32 value = (CARD32) (0xffffffffu * (double) opacity);
-    XChangeProperty(_glfw.x11.display, window->x11.handle,
-                    _glfw.x11.NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
-                    PropModeReplace, (unsigned char*) &value, 1);
-}
-
-void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
-{
-    if (!_glfw.x11.xi.available)
-        return;
-
-    if (_glfw.x11.disabledCursorWindow != window)
-        return;
-
-    if (enabled)
-        enableRawMouseMotion(window);
-    else
-        disableRawMouseMotion(window);
-}
-
-GLFWbool _glfwPlatformRawMouseMotionSupported(void)
-{
-    return _glfw.x11.xi.available;
-}
-
-void _glfwPlatformPollEvents(void)
-{
-    _GLFWwindow* window;
-
-#if defined(__linux__)
-    if (_glfw.joysticksInitialized)
-        _glfwDetectJoystickConnectionLinux();
-#endif
-    XPending(_glfw.x11.display);
-
-    while (QLength(_glfw.x11.display))
-    {
-        XEvent event;
-        XNextEvent(_glfw.x11.display, &event);
-        processEvent(&event);
-    }
-
-    window = _glfw.x11.disabledCursorWindow;
-    if (window)
-    {
-        int width, height;
-        _glfwPlatformGetWindowSize(window, &width, &height);
-
-        // NOTE: Re-center the cursor only if it has moved since the last call,
-        //       to avoid breaking glfwWaitEvents with MotionNotify
-        if (window->x11.lastCursorPosX != width / 2 ||
-            window->x11.lastCursorPosY != height / 2)
-        {
-            _glfwPlatformSetCursorPos(window, width / 2, height / 2);
-        }
-    }
-
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformWaitEvents(void)
-{
-    while (!XPending(_glfw.x11.display))
-        waitForEvent(NULL);
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformWaitEventsTimeout(double timeout)
-{
-    while (!XPending(_glfw.x11.display))
-    {
-        if (!waitForEvent(&timeout))
-            break;
-    }
-
-    _glfwPlatformPollEvents();
-}
-
-void _glfwPlatformPostEmptyEvent(void)
-{
-    XEvent event = { ClientMessage };
-    event.xclient.window = _glfw.x11.helperWindowHandle;
-    event.xclient.format = 32; // Data is 32-bit longs
-    event.xclient.message_type = _glfw.x11.NULL_;
-
-    XSendEvent(_glfw.x11.display, _glfw.x11.helperWindowHandle, False, 0, &event);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
-{
-    Window root, child;
-    int rootX, rootY, childX, childY;
-    unsigned int mask;
-
-    XQueryPointer(_glfw.x11.display, window->x11.handle,
-                  &root, &child,
-                  &rootX, &rootY, &childX, &childY,
-                  &mask);
-
-    if (xpos)
-        *xpos = childX;
-    if (ypos)
-        *ypos = childY;
-}
-
-void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y)
-{
-    // Store the new position so it can be recognized later
-    window->x11.warpCursorPosX = (int) x;
-    window->x11.warpCursorPosY = (int) y;
-
-    XWarpPointer(_glfw.x11.display, None, window->x11.handle,
-                 0,0,0,0, (int) x, (int) y);
-    XFlush(_glfw.x11.display);
-}
-
-void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
-{
-    if (mode == GLFW_CURSOR_DISABLED)
-    {
-        if (_glfwPlatformWindowFocused(window))
-            disableCursor(window);
-    }
-    else if (_glfw.x11.disabledCursorWindow == window)
-        enableCursor(window);
-    else
-        updateCursorImage(window);
-
-    XFlush(_glfw.x11.display);
-}
-
-const char* _glfwPlatformGetScancodeName(int scancode)
-{
-    if (!_glfw.x11.xkb.available)
-        return NULL;
-
-    if (scancode < 0 || scancode > 0xff ||
-        _glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
-    {
-        _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode");
-        return NULL;
-    }
-
-    const int key = _glfw.x11.keycodes[scancode];
-    const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
-                                             scancode, _glfw.x11.xkb.group, 0);
-    if (keysym == NoSymbol)
-        return NULL;
-
-    const long ch = _glfwKeySym2Unicode(keysym);
-    if (ch == -1)
-        return NULL;
-
-    const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch);
-    if (count == 0)
-        return NULL;
-
-    _glfw.x11.keynames[key][count] = '\0';
-    return _glfw.x11.keynames[key];
-}
-
-int _glfwPlatformGetKeyScancode(int key)
-{
-    return _glfw.x11.scancodes[key];
-}
-
-int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
-                              const GLFWimage* image,
-                              int xhot, int yhot)
-{
-    cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
-    if (!cursor->x11.handle)
-        return GLFW_FALSE;
-
-    return GLFW_TRUE;
-}
-
-int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
-{
-    if (_glfw.x11.xcursor.handle)
-    {
-        char* theme = XcursorGetTheme(_glfw.x11.display);
-        if (theme)
-        {
-            const int size = XcursorGetDefaultSize(_glfw.x11.display);
-            const char* name = NULL;
-
-            if (shape == GLFW_ARROW_CURSOR)
-                name = "default";
-            else if (shape == GLFW_IBEAM_CURSOR)
-                name = "text";
-            else if (shape == GLFW_CROSSHAIR_CURSOR)
-                name = "crosshair";
-            else if (shape == GLFW_POINTING_HAND_CURSOR)
-                name = "pointer";
-            else if (shape == GLFW_RESIZE_EW_CURSOR)
-                name = "ew-resize";
-            else if (shape == GLFW_RESIZE_NS_CURSOR)
-                name = "ns-resize";
-            else if (shape == GLFW_RESIZE_NWSE_CURSOR)
-                name = "nwse-resize";
-            else if (shape == GLFW_RESIZE_NESW_CURSOR)
-                name = "nesw-resize";
-            else if (shape == GLFW_RESIZE_ALL_CURSOR)
-                name = "all-scroll";
-            else if (shape == GLFW_NOT_ALLOWED_CURSOR)
-                name = "not-allowed";
-
-            XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
-            if (image)
-            {
-                cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image);
-                XcursorImageDestroy(image);
-            }
-        }
-    }
-
-    if (!cursor->x11.handle)
-    {
-        unsigned int native = 0;
-
-        if (shape == GLFW_ARROW_CURSOR)
-            native = XC_left_ptr;
-        else if (shape == GLFW_IBEAM_CURSOR)
-            native = XC_xterm;
-        else if (shape == GLFW_CROSSHAIR_CURSOR)
-            native = XC_crosshair;
-        else if (shape == GLFW_POINTING_HAND_CURSOR)
-            native = XC_hand2;
-        else if (shape == GLFW_RESIZE_EW_CURSOR)
-            native = XC_sb_h_double_arrow;
-        else if (shape == GLFW_RESIZE_NS_CURSOR)
-            native = XC_sb_v_double_arrow;
-        else if (shape == GLFW_RESIZE_ALL_CURSOR)
-            native = XC_fleur;
-        else
-        {
-            _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
-                            "X11: Standard cursor shape unavailable");
-            return GLFW_FALSE;
-        }
-
-        cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
-        if (!cursor->x11.handle)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create standard cursor");
-            return GLFW_FALSE;
-        }
-    }
-
-    return GLFW_TRUE;
-}
-
-void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
-{
-    if (cursor->x11.handle)
-        XFreeCursor(_glfw.x11.display, cursor->x11.handle);
-}
-
-void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
-{
-    if (window->cursorMode == GLFW_CURSOR_NORMAL)
-    {
-        updateCursorImage(window);
-        XFlush(_glfw.x11.display);
-    }
-}
-
-void _glfwPlatformSetClipboardString(const char* string)
-{
-    char* copy = _glfw_strdup(string);
-    free(_glfw.x11.clipboardString);
-    _glfw.x11.clipboardString = copy;
-
-    XSetSelectionOwner(_glfw.x11.display,
-                       _glfw.x11.CLIPBOARD,
-                       _glfw.x11.helperWindowHandle,
-                       CurrentTime);
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.CLIPBOARD) !=
-        _glfw.x11.helperWindowHandle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Failed to become owner of clipboard selection");
-    }
-}
-
-const char* _glfwPlatformGetClipboardString(void)
-{
-    return getSelectionString(_glfw.x11.CLIPBOARD);
-}
-
-EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
-{
-    if (_glfw.egl.ANGLE_platform_angle)
-    {
-        int type = 0;
-
-        if (_glfw.egl.ANGLE_platform_angle_opengl)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_OPENGL)
-                type = EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE;
-        }
-
-        if (_glfw.egl.ANGLE_platform_angle_vulkan)
-        {
-            if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_VULKAN)
-                type = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
-        }
-
-        if (type)
-        {
-            *attribs = calloc(5, sizeof(EGLint));
-            (*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
-            (*attribs)[1] = type;
-            (*attribs)[2] = EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE;
-            (*attribs)[3] = EGL_PLATFORM_X11_EXT;
-            (*attribs)[4] = EGL_NONE;
-            return EGL_PLATFORM_ANGLE_ANGLE;
-        }
-    }
-
-    if (_glfw.egl.EXT_platform_base && _glfw.egl.EXT_platform_x11)
-        return EGL_PLATFORM_X11_EXT;
-
-    return 0;
-}
-
-EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
-{
-    return _glfw.x11.display;
-}
-
-EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
-{
-    if (_glfw.egl.platform)
-        return &window->x11.handle;
-    else
-        return (EGLNativeWindowType) window->x11.handle;
-}
-
-void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
-{
-    if (!_glfw.vk.KHR_surface)
-        return;
-
-    if (!_glfw.vk.KHR_xcb_surface || !_glfw.x11.x11xcb.handle)
-    {
-        if (!_glfw.vk.KHR_xlib_surface)
-            return;
-    }
-
-    extensions[0] = "VK_KHR_surface";
-
-    // NOTE: VK_KHR_xcb_surface is preferred due to some early ICDs exposing but
-    //       not correctly implementing VK_KHR_xlib_surface
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-        extensions[1] = "VK_KHR_xcb_surface";
-    else
-        extensions[1] = "VK_KHR_xlib_surface";
-}
-
-int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
-                                                      VkPhysicalDevice device,
-                                                      uint32_t queuefamily)
-{
-    VisualID visualID = XVisualIDFromVisual(DefaultVisual(_glfw.x11.display,
-                                                          _glfw.x11.screen));
-
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-    {
-        PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR
-            vkGetPhysicalDeviceXcbPresentationSupportKHR =
-            (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)
-            vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXcbPresentationSupportKHR");
-        if (!vkGetPhysicalDeviceXcbPresentationSupportKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
-            return GLFW_FALSE;
-        }
-
-        xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
-        if (!connection)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to retrieve XCB connection");
-            return GLFW_FALSE;
-        }
-
-        return vkGetPhysicalDeviceXcbPresentationSupportKHR(device,
-                                                            queuefamily,
-                                                            connection,
-                                                            visualID);
-    }
-    else
-    {
-        PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR
-            vkGetPhysicalDeviceXlibPresentationSupportKHR =
-            (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)
-            vkGetInstanceProcAddr(instance, "vkGetPhysicalDeviceXlibPresentationSupportKHR");
-        if (!vkGetPhysicalDeviceXlibPresentationSupportKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
-            return GLFW_FALSE;
-        }
-
-        return vkGetPhysicalDeviceXlibPresentationSupportKHR(device,
-                                                             queuefamily,
-                                                             _glfw.x11.display,
-                                                             visualID);
-    }
-}
-
-VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
-                                          _GLFWwindow* window,
-                                          const VkAllocationCallbacks* allocator,
-                                          VkSurfaceKHR* surface)
-{
-    if (_glfw.vk.KHR_xcb_surface && _glfw.x11.x11xcb.handle)
-    {
-        VkResult err;
-        VkXcbSurfaceCreateInfoKHR sci;
-        PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR;
-
-        xcb_connection_t* connection = XGetXCBConnection(_glfw.x11.display);
-        if (!connection)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to retrieve XCB connection");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        vkCreateXcbSurfaceKHR = (PFN_vkCreateXcbSurfaceKHR)
-            vkGetInstanceProcAddr(instance, "vkCreateXcbSurfaceKHR");
-        if (!vkCreateXcbSurfaceKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xcb_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR;
-        sci.connection = connection;
-        sci.window = window->x11.handle;
-
-        err = vkCreateXcbSurfaceKHR(instance, &sci, allocator, surface);
-        if (err)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create Vulkan XCB surface: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        return err;
-    }
-    else
-    {
-        VkResult err;
-        VkXlibSurfaceCreateInfoKHR sci;
-        PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR;
-
-        vkCreateXlibSurfaceKHR = (PFN_vkCreateXlibSurfaceKHR)
-            vkGetInstanceProcAddr(instance, "vkCreateXlibSurfaceKHR");
-        if (!vkCreateXlibSurfaceKHR)
-        {
-            _glfwInputError(GLFW_API_UNAVAILABLE,
-                            "X11: Vulkan instance missing VK_KHR_xlib_surface extension");
-            return VK_ERROR_EXTENSION_NOT_PRESENT;
-        }
-
-        memset(&sci, 0, sizeof(sci));
-        sci.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
-        sci.dpy = _glfw.x11.display;
-        sci.window = window->x11.handle;
-
-        err = vkCreateXlibSurfaceKHR(instance, &sci, allocator, surface);
-        if (err)
-        {
-            _glfwInputError(GLFW_PLATFORM_ERROR,
-                            "X11: Failed to create Vulkan X11 surface: %s",
-                            _glfwGetVulkanResultString(err));
-        }
-
-        return err;
-    }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                        GLFW native API                       //////
-//////////////////////////////////////////////////////////////////////////
-
-GLFWAPI Display* glfwGetX11Display(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return _glfw.x11.display;
-}
-
-GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
-{
-    _GLFWwindow* window = (_GLFWwindow*) handle;
-    _GLFW_REQUIRE_INIT_OR_RETURN(None);
-    return window->x11.handle;
-}
-
-GLFWAPI void glfwSetX11SelectionString(const char* string)
-{
-    _GLFW_REQUIRE_INIT();
-
-    free(_glfw.x11.primarySelectionString);
-    _glfw.x11.primarySelectionString = _glfw_strdup(string);
-
-    XSetSelectionOwner(_glfw.x11.display,
-                       _glfw.x11.PRIMARY,
-                       _glfw.x11.helperWindowHandle,
-                       CurrentTime);
-
-    if (XGetSelectionOwner(_glfw.x11.display, _glfw.x11.PRIMARY) !=
-        _glfw.x11.helperWindowHandle)
-    {
-        _glfwInputError(GLFW_PLATFORM_ERROR,
-                        "X11: Failed to become owner of primary selection");
-    }
-}
-
-GLFWAPI const char* glfwGetX11SelectionString(void)
-{
-    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
-    return getSelectionString(_glfw.x11.PRIMARY);
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/xkb_unicode.c b/raylib_pi4_test/external/glfw/src/xkb_unicode.c
deleted file mode 100644 (file)
index 2772ea0..0000000
+++ /dev/null
@@ -1,942 +0,0 @@
-//========================================================================
-// GLFW 3.4 X11 - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2002-2006 Marcus Geelnard
-// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-// It is fine to use C99 in this file because it will not be built with VS
-//========================================================================
-
-#include "internal.h"
-
-
-/*
- * Marcus: This code was originally written by Markus G. Kuhn.
- * I have made some slight changes (trimmed it down a bit from >60 KB to
- * 20 KB), but the functionality is the same.
- */
-
-/*
- * This module converts keysym values into the corresponding ISO 10646
- * (UCS, Unicode) values.
- *
- * The array keysymtab[] contains pairs of X11 keysym values for graphical
- * characters and the corresponding Unicode value. The function
- * _glfwKeySym2Unicode() maps a keysym onto a Unicode value using a binary
- * search, therefore keysymtab[] must remain SORTED by keysym value.
- *
- * We allow to represent any UCS character in the range U-00000000 to
- * U-00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
- * This admittedly does not cover the entire 31-bit space of UCS, but
- * it does cover all of the characters up to U-10FFFF, which can be
- * represented by UTF-16, and more, and it is very unlikely that higher
- * UCS codes will ever be assigned by ISO. So to get Unicode character
- * U+ABCD you can directly use keysym 0x0100abcd.
- *
- * Original author: Markus G. Kuhn <mkuhn@acm.org>, University of
- *                  Cambridge, April 2001
- *
- * Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
- * an initial draft of the mapping table.
- *
- */
-
-
-//************************************************************************
-//****                KeySym to Unicode mapping table                 ****
-//************************************************************************
-
-static const struct codepair {
-  unsigned short keysym;
-  unsigned short ucs;
-} keysymtab[] = {
-  { 0x01a1, 0x0104 },
-  { 0x01a2, 0x02d8 },
-  { 0x01a3, 0x0141 },
-  { 0x01a5, 0x013d },
-  { 0x01a6, 0x015a },
-  { 0x01a9, 0x0160 },
-  { 0x01aa, 0x015e },
-  { 0x01ab, 0x0164 },
-  { 0x01ac, 0x0179 },
-  { 0x01ae, 0x017d },
-  { 0x01af, 0x017b },
-  { 0x01b1, 0x0105 },
-  { 0x01b2, 0x02db },
-  { 0x01b3, 0x0142 },
-  { 0x01b5, 0x013e },
-  { 0x01b6, 0x015b },
-  { 0x01b7, 0x02c7 },
-  { 0x01b9, 0x0161 },
-  { 0x01ba, 0x015f },
-  { 0x01bb, 0x0165 },
-  { 0x01bc, 0x017a },
-  { 0x01bd, 0x02dd },
-  { 0x01be, 0x017e },
-  { 0x01bf, 0x017c },
-  { 0x01c0, 0x0154 },
-  { 0x01c3, 0x0102 },
-  { 0x01c5, 0x0139 },
-  { 0x01c6, 0x0106 },
-  { 0x01c8, 0x010c },
-  { 0x01ca, 0x0118 },
-  { 0x01cc, 0x011a },
-  { 0x01cf, 0x010e },
-  { 0x01d0, 0x0110 },
-  { 0x01d1, 0x0143 },
-  { 0x01d2, 0x0147 },
-  { 0x01d5, 0x0150 },
-  { 0x01d8, 0x0158 },
-  { 0x01d9, 0x016e },
-  { 0x01db, 0x0170 },
-  { 0x01de, 0x0162 },
-  { 0x01e0, 0x0155 },
-  { 0x01e3, 0x0103 },
-  { 0x01e5, 0x013a },
-  { 0x01e6, 0x0107 },
-  { 0x01e8, 0x010d },
-  { 0x01ea, 0x0119 },
-  { 0x01ec, 0x011b },
-  { 0x01ef, 0x010f },
-  { 0x01f0, 0x0111 },
-  { 0x01f1, 0x0144 },
-  { 0x01f2, 0x0148 },
-  { 0x01f5, 0x0151 },
-  { 0x01f8, 0x0159 },
-  { 0x01f9, 0x016f },
-  { 0x01fb, 0x0171 },
-  { 0x01fe, 0x0163 },
-  { 0x01ff, 0x02d9 },
-  { 0x02a1, 0x0126 },
-  { 0x02a6, 0x0124 },
-  { 0x02a9, 0x0130 },
-  { 0x02ab, 0x011e },
-  { 0x02ac, 0x0134 },
-  { 0x02b1, 0x0127 },
-  { 0x02b6, 0x0125 },
-  { 0x02b9, 0x0131 },
-  { 0x02bb, 0x011f },
-  { 0x02bc, 0x0135 },
-  { 0x02c5, 0x010a },
-  { 0x02c6, 0x0108 },
-  { 0x02d5, 0x0120 },
-  { 0x02d8, 0x011c },
-  { 0x02dd, 0x016c },
-  { 0x02de, 0x015c },
-  { 0x02e5, 0x010b },
-  { 0x02e6, 0x0109 },
-  { 0x02f5, 0x0121 },
-  { 0x02f8, 0x011d },
-  { 0x02fd, 0x016d },
-  { 0x02fe, 0x015d },
-  { 0x03a2, 0x0138 },
-  { 0x03a3, 0x0156 },
-  { 0x03a5, 0x0128 },
-  { 0x03a6, 0x013b },
-  { 0x03aa, 0x0112 },
-  { 0x03ab, 0x0122 },
-  { 0x03ac, 0x0166 },
-  { 0x03b3, 0x0157 },
-  { 0x03b5, 0x0129 },
-  { 0x03b6, 0x013c },
-  { 0x03ba, 0x0113 },
-  { 0x03bb, 0x0123 },
-  { 0x03bc, 0x0167 },
-  { 0x03bd, 0x014a },
-  { 0x03bf, 0x014b },
-  { 0x03c0, 0x0100 },
-  { 0x03c7, 0x012e },
-  { 0x03cc, 0x0116 },
-  { 0x03cf, 0x012a },
-  { 0x03d1, 0x0145 },
-  { 0x03d2, 0x014c },
-  { 0x03d3, 0x0136 },
-  { 0x03d9, 0x0172 },
-  { 0x03dd, 0x0168 },
-  { 0x03de, 0x016a },
-  { 0x03e0, 0x0101 },
-  { 0x03e7, 0x012f },
-  { 0x03ec, 0x0117 },
-  { 0x03ef, 0x012b },
-  { 0x03f1, 0x0146 },
-  { 0x03f2, 0x014d },
-  { 0x03f3, 0x0137 },
-  { 0x03f9, 0x0173 },
-  { 0x03fd, 0x0169 },
-  { 0x03fe, 0x016b },
-  { 0x047e, 0x203e },
-  { 0x04a1, 0x3002 },
-  { 0x04a2, 0x300c },
-  { 0x04a3, 0x300d },
-  { 0x04a4, 0x3001 },
-  { 0x04a5, 0x30fb },
-  { 0x04a6, 0x30f2 },
-  { 0x04a7, 0x30a1 },
-  { 0x04a8, 0x30a3 },
-  { 0x04a9, 0x30a5 },
-  { 0x04aa, 0x30a7 },
-  { 0x04ab, 0x30a9 },
-  { 0x04ac, 0x30e3 },
-  { 0x04ad, 0x30e5 },
-  { 0x04ae, 0x30e7 },
-  { 0x04af, 0x30c3 },
-  { 0x04b0, 0x30fc },
-  { 0x04b1, 0x30a2 },
-  { 0x04b2, 0x30a4 },
-  { 0x04b3, 0x30a6 },
-  { 0x04b4, 0x30a8 },
-  { 0x04b5, 0x30aa },
-  { 0x04b6, 0x30ab },
-  { 0x04b7, 0x30ad },
-  { 0x04b8, 0x30af },
-  { 0x04b9, 0x30b1 },
-  { 0x04ba, 0x30b3 },
-  { 0x04bb, 0x30b5 },
-  { 0x04bc, 0x30b7 },
-  { 0x04bd, 0x30b9 },
-  { 0x04be, 0x30bb },
-  { 0x04bf, 0x30bd },
-  { 0x04c0, 0x30bf },
-  { 0x04c1, 0x30c1 },
-  { 0x04c2, 0x30c4 },
-  { 0x04c3, 0x30c6 },
-  { 0x04c4, 0x30c8 },
-  { 0x04c5, 0x30ca },
-  { 0x04c6, 0x30cb },
-  { 0x04c7, 0x30cc },
-  { 0x04c8, 0x30cd },
-  { 0x04c9, 0x30ce },
-  { 0x04ca, 0x30cf },
-  { 0x04cb, 0x30d2 },
-  { 0x04cc, 0x30d5 },
-  { 0x04cd, 0x30d8 },
-  { 0x04ce, 0x30db },
-  { 0x04cf, 0x30de },
-  { 0x04d0, 0x30df },
-  { 0x04d1, 0x30e0 },
-  { 0x04d2, 0x30e1 },
-  { 0x04d3, 0x30e2 },
-  { 0x04d4, 0x30e4 },
-  { 0x04d5, 0x30e6 },
-  { 0x04d6, 0x30e8 },
-  { 0x04d7, 0x30e9 },
-  { 0x04d8, 0x30ea },
-  { 0x04d9, 0x30eb },
-  { 0x04da, 0x30ec },
-  { 0x04db, 0x30ed },
-  { 0x04dc, 0x30ef },
-  { 0x04dd, 0x30f3 },
-  { 0x04de, 0x309b },
-  { 0x04df, 0x309c },
-  { 0x05ac, 0x060c },
-  { 0x05bb, 0x061b },
-  { 0x05bf, 0x061f },
-  { 0x05c1, 0x0621 },
-  { 0x05c2, 0x0622 },
-  { 0x05c3, 0x0623 },
-  { 0x05c4, 0x0624 },
-  { 0x05c5, 0x0625 },
-  { 0x05c6, 0x0626 },
-  { 0x05c7, 0x0627 },
-  { 0x05c8, 0x0628 },
-  { 0x05c9, 0x0629 },
-  { 0x05ca, 0x062a },
-  { 0x05cb, 0x062b },
-  { 0x05cc, 0x062c },
-  { 0x05cd, 0x062d },
-  { 0x05ce, 0x062e },
-  { 0x05cf, 0x062f },
-  { 0x05d0, 0x0630 },
-  { 0x05d1, 0x0631 },
-  { 0x05d2, 0x0632 },
-  { 0x05d3, 0x0633 },
-  { 0x05d4, 0x0634 },
-  { 0x05d5, 0x0635 },
-  { 0x05d6, 0x0636 },
-  { 0x05d7, 0x0637 },
-  { 0x05d8, 0x0638 },
-  { 0x05d9, 0x0639 },
-  { 0x05da, 0x063a },
-  { 0x05e0, 0x0640 },
-  { 0x05e1, 0x0641 },
-  { 0x05e2, 0x0642 },
-  { 0x05e3, 0x0643 },
-  { 0x05e4, 0x0644 },
-  { 0x05e5, 0x0645 },
-  { 0x05e6, 0x0646 },
-  { 0x05e7, 0x0647 },
-  { 0x05e8, 0x0648 },
-  { 0x05e9, 0x0649 },
-  { 0x05ea, 0x064a },
-  { 0x05eb, 0x064b },
-  { 0x05ec, 0x064c },
-  { 0x05ed, 0x064d },
-  { 0x05ee, 0x064e },
-  { 0x05ef, 0x064f },
-  { 0x05f0, 0x0650 },
-  { 0x05f1, 0x0651 },
-  { 0x05f2, 0x0652 },
-  { 0x06a1, 0x0452 },
-  { 0x06a2, 0x0453 },
-  { 0x06a3, 0x0451 },
-  { 0x06a4, 0x0454 },
-  { 0x06a5, 0x0455 },
-  { 0x06a6, 0x0456 },
-  { 0x06a7, 0x0457 },
-  { 0x06a8, 0x0458 },
-  { 0x06a9, 0x0459 },
-  { 0x06aa, 0x045a },
-  { 0x06ab, 0x045b },
-  { 0x06ac, 0x045c },
-  { 0x06ae, 0x045e },
-  { 0x06af, 0x045f },
-  { 0x06b0, 0x2116 },
-  { 0x06b1, 0x0402 },
-  { 0x06b2, 0x0403 },
-  { 0x06b3, 0x0401 },
-  { 0x06b4, 0x0404 },
-  { 0x06b5, 0x0405 },
-  { 0x06b6, 0x0406 },
-  { 0x06b7, 0x0407 },
-  { 0x06b8, 0x0408 },
-  { 0x06b9, 0x0409 },
-  { 0x06ba, 0x040a },
-  { 0x06bb, 0x040b },
-  { 0x06bc, 0x040c },
-  { 0x06be, 0x040e },
-  { 0x06bf, 0x040f },
-  { 0x06c0, 0x044e },
-  { 0x06c1, 0x0430 },
-  { 0x06c2, 0x0431 },
-  { 0x06c3, 0x0446 },
-  { 0x06c4, 0x0434 },
-  { 0x06c5, 0x0435 },
-  { 0x06c6, 0x0444 },
-  { 0x06c7, 0x0433 },
-  { 0x06c8, 0x0445 },
-  { 0x06c9, 0x0438 },
-  { 0x06ca, 0x0439 },
-  { 0x06cb, 0x043a },
-  { 0x06cc, 0x043b },
-  { 0x06cd, 0x043c },
-  { 0x06ce, 0x043d },
-  { 0x06cf, 0x043e },
-  { 0x06d0, 0x043f },
-  { 0x06d1, 0x044f },
-  { 0x06d2, 0x0440 },
-  { 0x06d3, 0x0441 },
-  { 0x06d4, 0x0442 },
-  { 0x06d5, 0x0443 },
-  { 0x06d6, 0x0436 },
-  { 0x06d7, 0x0432 },
-  { 0x06d8, 0x044c },
-  { 0x06d9, 0x044b },
-  { 0x06da, 0x0437 },
-  { 0x06db, 0x0448 },
-  { 0x06dc, 0x044d },
-  { 0x06dd, 0x0449 },
-  { 0x06de, 0x0447 },
-  { 0x06df, 0x044a },
-  { 0x06e0, 0x042e },
-  { 0x06e1, 0x0410 },
-  { 0x06e2, 0x0411 },
-  { 0x06e3, 0x0426 },
-  { 0x06e4, 0x0414 },
-  { 0x06e5, 0x0415 },
-  { 0x06e6, 0x0424 },
-  { 0x06e7, 0x0413 },
-  { 0x06e8, 0x0425 },
-  { 0x06e9, 0x0418 },
-  { 0x06ea, 0x0419 },
-  { 0x06eb, 0x041a },
-  { 0x06ec, 0x041b },
-  { 0x06ed, 0x041c },
-  { 0x06ee, 0x041d },
-  { 0x06ef, 0x041e },
-  { 0x06f0, 0x041f },
-  { 0x06f1, 0x042f },
-  { 0x06f2, 0x0420 },
-  { 0x06f3, 0x0421 },
-  { 0x06f4, 0x0422 },
-  { 0x06f5, 0x0423 },
-  { 0x06f6, 0x0416 },
-  { 0x06f7, 0x0412 },
-  { 0x06f8, 0x042c },
-  { 0x06f9, 0x042b },
-  { 0x06fa, 0x0417 },
-  { 0x06fb, 0x0428 },
-  { 0x06fc, 0x042d },
-  { 0x06fd, 0x0429 },
-  { 0x06fe, 0x0427 },
-  { 0x06ff, 0x042a },
-  { 0x07a1, 0x0386 },
-  { 0x07a2, 0x0388 },
-  { 0x07a3, 0x0389 },
-  { 0x07a4, 0x038a },
-  { 0x07a5, 0x03aa },
-  { 0x07a7, 0x038c },
-  { 0x07a8, 0x038e },
-  { 0x07a9, 0x03ab },
-  { 0x07ab, 0x038f },
-  { 0x07ae, 0x0385 },
-  { 0x07af, 0x2015 },
-  { 0x07b1, 0x03ac },
-  { 0x07b2, 0x03ad },
-  { 0x07b3, 0x03ae },
-  { 0x07b4, 0x03af },
-  { 0x07b5, 0x03ca },
-  { 0x07b6, 0x0390 },
-  { 0x07b7, 0x03cc },
-  { 0x07b8, 0x03cd },
-  { 0x07b9, 0x03cb },
-  { 0x07ba, 0x03b0 },
-  { 0x07bb, 0x03ce },
-  { 0x07c1, 0x0391 },
-  { 0x07c2, 0x0392 },
-  { 0x07c3, 0x0393 },
-  { 0x07c4, 0x0394 },
-  { 0x07c5, 0x0395 },
-  { 0x07c6, 0x0396 },
-  { 0x07c7, 0x0397 },
-  { 0x07c8, 0x0398 },
-  { 0x07c9, 0x0399 },
-  { 0x07ca, 0x039a },
-  { 0x07cb, 0x039b },
-  { 0x07cc, 0x039c },
-  { 0x07cd, 0x039d },
-  { 0x07ce, 0x039e },
-  { 0x07cf, 0x039f },
-  { 0x07d0, 0x03a0 },
-  { 0x07d1, 0x03a1 },
-  { 0x07d2, 0x03a3 },
-  { 0x07d4, 0x03a4 },
-  { 0x07d5, 0x03a5 },
-  { 0x07d6, 0x03a6 },
-  { 0x07d7, 0x03a7 },
-  { 0x07d8, 0x03a8 },
-  { 0x07d9, 0x03a9 },
-  { 0x07e1, 0x03b1 },
-  { 0x07e2, 0x03b2 },
-  { 0x07e3, 0x03b3 },
-  { 0x07e4, 0x03b4 },
-  { 0x07e5, 0x03b5 },
-  { 0x07e6, 0x03b6 },
-  { 0x07e7, 0x03b7 },
-  { 0x07e8, 0x03b8 },
-  { 0x07e9, 0x03b9 },
-  { 0x07ea, 0x03ba },
-  { 0x07eb, 0x03bb },
-  { 0x07ec, 0x03bc },
-  { 0x07ed, 0x03bd },
-  { 0x07ee, 0x03be },
-  { 0x07ef, 0x03bf },
-  { 0x07f0, 0x03c0 },
-  { 0x07f1, 0x03c1 },
-  { 0x07f2, 0x03c3 },
-  { 0x07f3, 0x03c2 },
-  { 0x07f4, 0x03c4 },
-  { 0x07f5, 0x03c5 },
-  { 0x07f6, 0x03c6 },
-  { 0x07f7, 0x03c7 },
-  { 0x07f8, 0x03c8 },
-  { 0x07f9, 0x03c9 },
-  { 0x08a1, 0x23b7 },
-  { 0x08a2, 0x250c },
-  { 0x08a3, 0x2500 },
-  { 0x08a4, 0x2320 },
-  { 0x08a5, 0x2321 },
-  { 0x08a6, 0x2502 },
-  { 0x08a7, 0x23a1 },
-  { 0x08a8, 0x23a3 },
-  { 0x08a9, 0x23a4 },
-  { 0x08aa, 0x23a6 },
-  { 0x08ab, 0x239b },
-  { 0x08ac, 0x239d },
-  { 0x08ad, 0x239e },
-  { 0x08ae, 0x23a0 },
-  { 0x08af, 0x23a8 },
-  { 0x08b0, 0x23ac },
-  { 0x08bc, 0x2264 },
-  { 0x08bd, 0x2260 },
-  { 0x08be, 0x2265 },
-  { 0x08bf, 0x222b },
-  { 0x08c0, 0x2234 },
-  { 0x08c1, 0x221d },
-  { 0x08c2, 0x221e },
-  { 0x08c5, 0x2207 },
-  { 0x08c8, 0x223c },
-  { 0x08c9, 0x2243 },
-  { 0x08cd, 0x21d4 },
-  { 0x08ce, 0x21d2 },
-  { 0x08cf, 0x2261 },
-  { 0x08d6, 0x221a },
-  { 0x08da, 0x2282 },
-  { 0x08db, 0x2283 },
-  { 0x08dc, 0x2229 },
-  { 0x08dd, 0x222a },
-  { 0x08de, 0x2227 },
-  { 0x08df, 0x2228 },
-  { 0x08ef, 0x2202 },
-  { 0x08f6, 0x0192 },
-  { 0x08fb, 0x2190 },
-  { 0x08fc, 0x2191 },
-  { 0x08fd, 0x2192 },
-  { 0x08fe, 0x2193 },
-  { 0x09e0, 0x25c6 },
-  { 0x09e1, 0x2592 },
-  { 0x09e2, 0x2409 },
-  { 0x09e3, 0x240c },
-  { 0x09e4, 0x240d },
-  { 0x09e5, 0x240a },
-  { 0x09e8, 0x2424 },
-  { 0x09e9, 0x240b },
-  { 0x09ea, 0x2518 },
-  { 0x09eb, 0x2510 },
-  { 0x09ec, 0x250c },
-  { 0x09ed, 0x2514 },
-  { 0x09ee, 0x253c },
-  { 0x09ef, 0x23ba },
-  { 0x09f0, 0x23bb },
-  { 0x09f1, 0x2500 },
-  { 0x09f2, 0x23bc },
-  { 0x09f3, 0x23bd },
-  { 0x09f4, 0x251c },
-  { 0x09f5, 0x2524 },
-  { 0x09f6, 0x2534 },
-  { 0x09f7, 0x252c },
-  { 0x09f8, 0x2502 },
-  { 0x0aa1, 0x2003 },
-  { 0x0aa2, 0x2002 },
-  { 0x0aa3, 0x2004 },
-  { 0x0aa4, 0x2005 },
-  { 0x0aa5, 0x2007 },
-  { 0x0aa6, 0x2008 },
-  { 0x0aa7, 0x2009 },
-  { 0x0aa8, 0x200a },
-  { 0x0aa9, 0x2014 },
-  { 0x0aaa, 0x2013 },
-  { 0x0aae, 0x2026 },
-  { 0x0aaf, 0x2025 },
-  { 0x0ab0, 0x2153 },
-  { 0x0ab1, 0x2154 },
-  { 0x0ab2, 0x2155 },
-  { 0x0ab3, 0x2156 },
-  { 0x0ab4, 0x2157 },
-  { 0x0ab5, 0x2158 },
-  { 0x0ab6, 0x2159 },
-  { 0x0ab7, 0x215a },
-  { 0x0ab8, 0x2105 },
-  { 0x0abb, 0x2012 },
-  { 0x0abc, 0x2329 },
-  { 0x0abe, 0x232a },
-  { 0x0ac3, 0x215b },
-  { 0x0ac4, 0x215c },
-  { 0x0ac5, 0x215d },
-  { 0x0ac6, 0x215e },
-  { 0x0ac9, 0x2122 },
-  { 0x0aca, 0x2613 },
-  { 0x0acc, 0x25c1 },
-  { 0x0acd, 0x25b7 },
-  { 0x0ace, 0x25cb },
-  { 0x0acf, 0x25af },
-  { 0x0ad0, 0x2018 },
-  { 0x0ad1, 0x2019 },
-  { 0x0ad2, 0x201c },
-  { 0x0ad3, 0x201d },
-  { 0x0ad4, 0x211e },
-  { 0x0ad6, 0x2032 },
-  { 0x0ad7, 0x2033 },
-  { 0x0ad9, 0x271d },
-  { 0x0adb, 0x25ac },
-  { 0x0adc, 0x25c0 },
-  { 0x0add, 0x25b6 },
-  { 0x0ade, 0x25cf },
-  { 0x0adf, 0x25ae },
-  { 0x0ae0, 0x25e6 },
-  { 0x0ae1, 0x25ab },
-  { 0x0ae2, 0x25ad },
-  { 0x0ae3, 0x25b3 },
-  { 0x0ae4, 0x25bd },
-  { 0x0ae5, 0x2606 },
-  { 0x0ae6, 0x2022 },
-  { 0x0ae7, 0x25aa },
-  { 0x0ae8, 0x25b2 },
-  { 0x0ae9, 0x25bc },
-  { 0x0aea, 0x261c },
-  { 0x0aeb, 0x261e },
-  { 0x0aec, 0x2663 },
-  { 0x0aed, 0x2666 },
-  { 0x0aee, 0x2665 },
-  { 0x0af0, 0x2720 },
-  { 0x0af1, 0x2020 },
-  { 0x0af2, 0x2021 },
-  { 0x0af3, 0x2713 },
-  { 0x0af4, 0x2717 },
-  { 0x0af5, 0x266f },
-  { 0x0af6, 0x266d },
-  { 0x0af7, 0x2642 },
-  { 0x0af8, 0x2640 },
-  { 0x0af9, 0x260e },
-  { 0x0afa, 0x2315 },
-  { 0x0afb, 0x2117 },
-  { 0x0afc, 0x2038 },
-  { 0x0afd, 0x201a },
-  { 0x0afe, 0x201e },
-  { 0x0ba3, 0x003c },
-  { 0x0ba6, 0x003e },
-  { 0x0ba8, 0x2228 },
-  { 0x0ba9, 0x2227 },
-  { 0x0bc0, 0x00af },
-  { 0x0bc2, 0x22a5 },
-  { 0x0bc3, 0x2229 },
-  { 0x0bc4, 0x230a },
-  { 0x0bc6, 0x005f },
-  { 0x0bca, 0x2218 },
-  { 0x0bcc, 0x2395 },
-  { 0x0bce, 0x22a4 },
-  { 0x0bcf, 0x25cb },
-  { 0x0bd3, 0x2308 },
-  { 0x0bd6, 0x222a },
-  { 0x0bd8, 0x2283 },
-  { 0x0bda, 0x2282 },
-  { 0x0bdc, 0x22a2 },
-  { 0x0bfc, 0x22a3 },
-  { 0x0cdf, 0x2017 },
-  { 0x0ce0, 0x05d0 },
-  { 0x0ce1, 0x05d1 },
-  { 0x0ce2, 0x05d2 },
-  { 0x0ce3, 0x05d3 },
-  { 0x0ce4, 0x05d4 },
-  { 0x0ce5, 0x05d5 },
-  { 0x0ce6, 0x05d6 },
-  { 0x0ce7, 0x05d7 },
-  { 0x0ce8, 0x05d8 },
-  { 0x0ce9, 0x05d9 },
-  { 0x0cea, 0x05da },
-  { 0x0ceb, 0x05db },
-  { 0x0cec, 0x05dc },
-  { 0x0ced, 0x05dd },
-  { 0x0cee, 0x05de },
-  { 0x0cef, 0x05df },
-  { 0x0cf0, 0x05e0 },
-  { 0x0cf1, 0x05e1 },
-  { 0x0cf2, 0x05e2 },
-  { 0x0cf3, 0x05e3 },
-  { 0x0cf4, 0x05e4 },
-  { 0x0cf5, 0x05e5 },
-  { 0x0cf6, 0x05e6 },
-  { 0x0cf7, 0x05e7 },
-  { 0x0cf8, 0x05e8 },
-  { 0x0cf9, 0x05e9 },
-  { 0x0cfa, 0x05ea },
-  { 0x0da1, 0x0e01 },
-  { 0x0da2, 0x0e02 },
-  { 0x0da3, 0x0e03 },
-  { 0x0da4, 0x0e04 },
-  { 0x0da5, 0x0e05 },
-  { 0x0da6, 0x0e06 },
-  { 0x0da7, 0x0e07 },
-  { 0x0da8, 0x0e08 },
-  { 0x0da9, 0x0e09 },
-  { 0x0daa, 0x0e0a },
-  { 0x0dab, 0x0e0b },
-  { 0x0dac, 0x0e0c },
-  { 0x0dad, 0x0e0d },
-  { 0x0dae, 0x0e0e },
-  { 0x0daf, 0x0e0f },
-  { 0x0db0, 0x0e10 },
-  { 0x0db1, 0x0e11 },
-  { 0x0db2, 0x0e12 },
-  { 0x0db3, 0x0e13 },
-  { 0x0db4, 0x0e14 },
-  { 0x0db5, 0x0e15 },
-  { 0x0db6, 0x0e16 },
-  { 0x0db7, 0x0e17 },
-  { 0x0db8, 0x0e18 },
-  { 0x0db9, 0x0e19 },
-  { 0x0dba, 0x0e1a },
-  { 0x0dbb, 0x0e1b },
-  { 0x0dbc, 0x0e1c },
-  { 0x0dbd, 0x0e1d },
-  { 0x0dbe, 0x0e1e },
-  { 0x0dbf, 0x0e1f },
-  { 0x0dc0, 0x0e20 },
-  { 0x0dc1, 0x0e21 },
-  { 0x0dc2, 0x0e22 },
-  { 0x0dc3, 0x0e23 },
-  { 0x0dc4, 0x0e24 },
-  { 0x0dc5, 0x0e25 },
-  { 0x0dc6, 0x0e26 },
-  { 0x0dc7, 0x0e27 },
-  { 0x0dc8, 0x0e28 },
-  { 0x0dc9, 0x0e29 },
-  { 0x0dca, 0x0e2a },
-  { 0x0dcb, 0x0e2b },
-  { 0x0dcc, 0x0e2c },
-  { 0x0dcd, 0x0e2d },
-  { 0x0dce, 0x0e2e },
-  { 0x0dcf, 0x0e2f },
-  { 0x0dd0, 0x0e30 },
-  { 0x0dd1, 0x0e31 },
-  { 0x0dd2, 0x0e32 },
-  { 0x0dd3, 0x0e33 },
-  { 0x0dd4, 0x0e34 },
-  { 0x0dd5, 0x0e35 },
-  { 0x0dd6, 0x0e36 },
-  { 0x0dd7, 0x0e37 },
-  { 0x0dd8, 0x0e38 },
-  { 0x0dd9, 0x0e39 },
-  { 0x0dda, 0x0e3a },
-  { 0x0ddf, 0x0e3f },
-  { 0x0de0, 0x0e40 },
-  { 0x0de1, 0x0e41 },
-  { 0x0de2, 0x0e42 },
-  { 0x0de3, 0x0e43 },
-  { 0x0de4, 0x0e44 },
-  { 0x0de5, 0x0e45 },
-  { 0x0de6, 0x0e46 },
-  { 0x0de7, 0x0e47 },
-  { 0x0de8, 0x0e48 },
-  { 0x0de9, 0x0e49 },
-  { 0x0dea, 0x0e4a },
-  { 0x0deb, 0x0e4b },
-  { 0x0dec, 0x0e4c },
-  { 0x0ded, 0x0e4d },
-  { 0x0df0, 0x0e50 },
-  { 0x0df1, 0x0e51 },
-  { 0x0df2, 0x0e52 },
-  { 0x0df3, 0x0e53 },
-  { 0x0df4, 0x0e54 },
-  { 0x0df5, 0x0e55 },
-  { 0x0df6, 0x0e56 },
-  { 0x0df7, 0x0e57 },
-  { 0x0df8, 0x0e58 },
-  { 0x0df9, 0x0e59 },
-  { 0x0ea1, 0x3131 },
-  { 0x0ea2, 0x3132 },
-  { 0x0ea3, 0x3133 },
-  { 0x0ea4, 0x3134 },
-  { 0x0ea5, 0x3135 },
-  { 0x0ea6, 0x3136 },
-  { 0x0ea7, 0x3137 },
-  { 0x0ea8, 0x3138 },
-  { 0x0ea9, 0x3139 },
-  { 0x0eaa, 0x313a },
-  { 0x0eab, 0x313b },
-  { 0x0eac, 0x313c },
-  { 0x0ead, 0x313d },
-  { 0x0eae, 0x313e },
-  { 0x0eaf, 0x313f },
-  { 0x0eb0, 0x3140 },
-  { 0x0eb1, 0x3141 },
-  { 0x0eb2, 0x3142 },
-  { 0x0eb3, 0x3143 },
-  { 0x0eb4, 0x3144 },
-  { 0x0eb5, 0x3145 },
-  { 0x0eb6, 0x3146 },
-  { 0x0eb7, 0x3147 },
-  { 0x0eb8, 0x3148 },
-  { 0x0eb9, 0x3149 },
-  { 0x0eba, 0x314a },
-  { 0x0ebb, 0x314b },
-  { 0x0ebc, 0x314c },
-  { 0x0ebd, 0x314d },
-  { 0x0ebe, 0x314e },
-  { 0x0ebf, 0x314f },
-  { 0x0ec0, 0x3150 },
-  { 0x0ec1, 0x3151 },
-  { 0x0ec2, 0x3152 },
-  { 0x0ec3, 0x3153 },
-  { 0x0ec4, 0x3154 },
-  { 0x0ec5, 0x3155 },
-  { 0x0ec6, 0x3156 },
-  { 0x0ec7, 0x3157 },
-  { 0x0ec8, 0x3158 },
-  { 0x0ec9, 0x3159 },
-  { 0x0eca, 0x315a },
-  { 0x0ecb, 0x315b },
-  { 0x0ecc, 0x315c },
-  { 0x0ecd, 0x315d },
-  { 0x0ece, 0x315e },
-  { 0x0ecf, 0x315f },
-  { 0x0ed0, 0x3160 },
-  { 0x0ed1, 0x3161 },
-  { 0x0ed2, 0x3162 },
-  { 0x0ed3, 0x3163 },
-  { 0x0ed4, 0x11a8 },
-  { 0x0ed5, 0x11a9 },
-  { 0x0ed6, 0x11aa },
-  { 0x0ed7, 0x11ab },
-  { 0x0ed8, 0x11ac },
-  { 0x0ed9, 0x11ad },
-  { 0x0eda, 0x11ae },
-  { 0x0edb, 0x11af },
-  { 0x0edc, 0x11b0 },
-  { 0x0edd, 0x11b1 },
-  { 0x0ede, 0x11b2 },
-  { 0x0edf, 0x11b3 },
-  { 0x0ee0, 0x11b4 },
-  { 0x0ee1, 0x11b5 },
-  { 0x0ee2, 0x11b6 },
-  { 0x0ee3, 0x11b7 },
-  { 0x0ee4, 0x11b8 },
-  { 0x0ee5, 0x11b9 },
-  { 0x0ee6, 0x11ba },
-  { 0x0ee7, 0x11bb },
-  { 0x0ee8, 0x11bc },
-  { 0x0ee9, 0x11bd },
-  { 0x0eea, 0x11be },
-  { 0x0eeb, 0x11bf },
-  { 0x0eec, 0x11c0 },
-  { 0x0eed, 0x11c1 },
-  { 0x0eee, 0x11c2 },
-  { 0x0eef, 0x316d },
-  { 0x0ef0, 0x3171 },
-  { 0x0ef1, 0x3178 },
-  { 0x0ef2, 0x317f },
-  { 0x0ef3, 0x3181 },
-  { 0x0ef4, 0x3184 },
-  { 0x0ef5, 0x3186 },
-  { 0x0ef6, 0x318d },
-  { 0x0ef7, 0x318e },
-  { 0x0ef8, 0x11eb },
-  { 0x0ef9, 0x11f0 },
-  { 0x0efa, 0x11f9 },
-  { 0x0eff, 0x20a9 },
-  { 0x13a4, 0x20ac },
-  { 0x13bc, 0x0152 },
-  { 0x13bd, 0x0153 },
-  { 0x13be, 0x0178 },
-  { 0x20ac, 0x20ac },
-  { 0xfe50,    '`' },
-  { 0xfe51, 0x00b4 },
-  { 0xfe52,    '^' },
-  { 0xfe53,    '~' },
-  { 0xfe54, 0x00af },
-  { 0xfe55, 0x02d8 },
-  { 0xfe56, 0x02d9 },
-  { 0xfe57, 0x00a8 },
-  { 0xfe58, 0x02da },
-  { 0xfe59, 0x02dd },
-  { 0xfe5a, 0x02c7 },
-  { 0xfe5b, 0x00b8 },
-  { 0xfe5c, 0x02db },
-  { 0xfe5d, 0x037a },
-  { 0xfe5e, 0x309b },
-  { 0xfe5f, 0x309c },
-  { 0xfe63,    '/' },
-  { 0xfe64, 0x02bc },
-  { 0xfe65, 0x02bd },
-  { 0xfe66, 0x02f5 },
-  { 0xfe67, 0x02f3 },
-  { 0xfe68, 0x02cd },
-  { 0xfe69, 0xa788 },
-  { 0xfe6a, 0x02f7 },
-  { 0xfe6e,    ',' },
-  { 0xfe6f, 0x00a4 },
-  { 0xfe80,    'a' }, // XK_dead_a
-  { 0xfe81,    'A' }, // XK_dead_A
-  { 0xfe82,    'e' }, // XK_dead_e
-  { 0xfe83,    'E' }, // XK_dead_E
-  { 0xfe84,    'i' }, // XK_dead_i
-  { 0xfe85,    'I' }, // XK_dead_I
-  { 0xfe86,    'o' }, // XK_dead_o
-  { 0xfe87,    'O' }, // XK_dead_O
-  { 0xfe88,    'u' }, // XK_dead_u
-  { 0xfe89,    'U' }, // XK_dead_U
-  { 0xfe8a, 0x0259 },
-  { 0xfe8b, 0x018f },
-  { 0xfe8c, 0x00b5 },
-  { 0xfe90,    '_' },
-  { 0xfe91, 0x02c8 },
-  { 0xfe92, 0x02cc },
-  { 0xff80 /*XKB_KEY_KP_Space*/,     ' ' },
-  { 0xff95 /*XKB_KEY_KP_7*/, 0x0037 },
-  { 0xff96 /*XKB_KEY_KP_4*/, 0x0034 },
-  { 0xff97 /*XKB_KEY_KP_8*/, 0x0038 },
-  { 0xff98 /*XKB_KEY_KP_6*/, 0x0036 },
-  { 0xff99 /*XKB_KEY_KP_2*/, 0x0032 },
-  { 0xff9a /*XKB_KEY_KP_9*/, 0x0039 },
-  { 0xff9b /*XKB_KEY_KP_3*/, 0x0033 },
-  { 0xff9c /*XKB_KEY_KP_1*/, 0x0031 },
-  { 0xff9d /*XKB_KEY_KP_5*/, 0x0035 },
-  { 0xff9e /*XKB_KEY_KP_0*/, 0x0030 },
-  { 0xffaa /*XKB_KEY_KP_Multiply*/,  '*' },
-  { 0xffab /*XKB_KEY_KP_Add*/,       '+' },
-  { 0xffac /*XKB_KEY_KP_Separator*/, ',' },
-  { 0xffad /*XKB_KEY_KP_Subtract*/,  '-' },
-  { 0xffae /*XKB_KEY_KP_Decimal*/,   '.' },
-  { 0xffaf /*XKB_KEY_KP_Divide*/,    '/' },
-  { 0xffb0 /*XKB_KEY_KP_0*/, 0x0030 },
-  { 0xffb1 /*XKB_KEY_KP_1*/, 0x0031 },
-  { 0xffb2 /*XKB_KEY_KP_2*/, 0x0032 },
-  { 0xffb3 /*XKB_KEY_KP_3*/, 0x0033 },
-  { 0xffb4 /*XKB_KEY_KP_4*/, 0x0034 },
-  { 0xffb5 /*XKB_KEY_KP_5*/, 0x0035 },
-  { 0xffb6 /*XKB_KEY_KP_6*/, 0x0036 },
-  { 0xffb7 /*XKB_KEY_KP_7*/, 0x0037 },
-  { 0xffb8 /*XKB_KEY_KP_8*/, 0x0038 },
-  { 0xffb9 /*XKB_KEY_KP_9*/, 0x0039 },
-  { 0xffbd /*XKB_KEY_KP_Equal*/,     '=' }
-};
-
-
-//////////////////////////////////////////////////////////////////////////
-//////                       GLFW internal API                      //////
-//////////////////////////////////////////////////////////////////////////
-
-// Convert XKB KeySym to Unicode
-//
-long _glfwKeySym2Unicode(unsigned int keysym)
-{
-    int min = 0;
-    int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
-    int mid;
-
-    // First check for Latin-1 characters (1:1 mapping)
-    if ((keysym >= 0x0020 && keysym <= 0x007e) ||
-        (keysym >= 0x00a0 && keysym <= 0x00ff))
-    {
-        return keysym;
-    }
-
-    // Also check for directly encoded 24-bit UCS characters
-    if ((keysym & 0xff000000) == 0x01000000)
-        return keysym & 0x00ffffff;
-
-    // Binary search in table
-    while (max >= min)
-    {
-        mid = (min + max) / 2;
-        if (keysymtab[mid].keysym < keysym)
-            min = mid + 1;
-        else if (keysymtab[mid].keysym > keysym)
-            max = mid - 1;
-        else
-            return keysymtab[mid].ucs;
-    }
-
-    // No matching Unicode value found
-    return -1;
-}
-
diff --git a/raylib_pi4_test/external/glfw/src/xkb_unicode.h b/raylib_pi4_test/external/glfw/src/xkb_unicode.h
deleted file mode 100644 (file)
index 76d83ff..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-//========================================================================
-// GLFW 3.4 Linux - www.glfw.org
-//------------------------------------------------------------------------
-// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
-//
-// This software is provided 'as-is', without any express or implied
-// warranty. In no event will the authors be held liable for any damages
-// arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it
-// freely, subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented; you must not
-//    claim that you wrote the original software. If you use this software
-//    in a product, an acknowledgment in the product documentation would
-//    be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such, and must not
-//    be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source
-//    distribution.
-//
-//========================================================================
-
-long _glfwKeySym2Unicode(unsigned int keysym);
-
diff --git a/raylib_pi4_test/external/jar_mod.h b/raylib_pi4_test/external/jar_mod.h
deleted file mode 100644 (file)
index eacd3b7..0000000
+++ /dev/null
@@ -1,1596 +0,0 @@
-// jar_mod.h - v0.01 - public domain C0 - Joshua Reisenauer
-//
-// HISTORY:
-//
-//   v0.01  2016-03-12  Setup
-//
-//
-// USAGE:
-//
-// In ONE source file, put:
-//
-//    #define JAR_MOD_IMPLEMENTATION
-//    #include "jar_mod.h"
-//
-// Other source files should just include jar_mod.h
-//
-// SAMPLE CODE:
-// jar_mod_context_t modctx;
-// short samplebuff[4096];
-// bool bufferFull = false;
-// int intro_load(void)
-// {
-//     jar_mod_init(&modctx);
-//     jar_mod_load_file(&modctx, "file.mod");
-//     return 1;
-// }
-// int intro_unload(void)
-// {
-//     jar_mod_unload(&modctx);
-//     return 1;
-// }
-// int intro_tick(long counter)
-// {
-//     if(!bufferFull)
-//     {
-//         jar_mod_fillbuffer(&modctx, samplebuff, 4096, 0);
-//         bufferFull=true;
-//     }
-//     if(IsKeyDown(KEY_ENTER))
-//         return 1;
-//     return 0;
-// }
-//
-//
-// LISCENSE:
-//
-// Written by: Jean-François DEL NERO (http://hxc2001.com/) <Email : jeanfrancoisdelnero <> free.fr>
-// Adapted to jar_mod by: Joshua Adam Reisenauer <kd7tck@gmail.com>
-// This program is free software. It comes without any warranty, to the
-// extent permitted by applicable law. You can redistribute it and/or
-// modify it under the terms of the Do What The Fuck You Want To Public
-// License, Version 2, as published by Sam Hocevar. See
-// http://sam.zoy.org/wtfpl/COPYING for more details.
-///////////////////////////////////////////////////////////////////////////////////
-// HxCMOD Core API:
-// -------------------------------------------
-// int  jar_mod_init(jar_mod_context_t * modctx)
-//
-// - Initialize the jar_mod_context_t buffer. Must be called before doing anything else.
-//   Return 1 if success. 0 in case of error.
-// -------------------------------------------
-// mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
-//
-// - "Load" a MOD from file, context must already be initialized.
-//   Return size of file in bytes.
-// -------------------------------------------
-// void jar_mod_fillbuffer( jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf )
-//
-// - Generate and return the next samples chunk to outbuffer.
-//   nbsample specify the number of stereo 16bits samples you want.
-//   The output format is by default signed 48000Hz 16-bit Stereo PCM samples, otherwise it is changed with jar_mod_setcfg().
-//   The output buffer size in bytes must be equal to ( nbsample * 2 * channels ).
-//   The optional trkbuf parameter can be used to get detailed status of the player. Put NULL/0 is unused.
-// -------------------------------------------
-// void jar_mod_unload( jar_mod_context_t * modctx )
-// - "Unload" / clear the player status.
-// -------------------------------------------
-///////////////////////////////////////////////////////////////////////////////////
-
-
-#ifndef INCLUDE_JAR_MOD_H
-#define INCLUDE_JAR_MOD_H
-
-// Allow custom memory allocators
-#ifndef JARMOD_MALLOC
-    #define JARMOD_MALLOC(sz)    malloc(sz)
-#endif
-#ifndef JARMOD_FREE
-    #define JARMOD_FREE(p)       free(p)
-#endif
-
-
-// Basic type
-typedef unsigned char muchar;
-typedef unsigned short muint;
-typedef short mint;
-typedef unsigned long mulong;
-
-#define NUMMAXCHANNELS 32
-#define MAXNOTES 12*12
-#define DEFAULT_SAMPLE_RATE 48000
-//
-// MOD file structures
-//
-
-#pragma pack(1)
-
-typedef struct {
-    muchar  name[22];
-    muint   length;
-    muchar  finetune;
-    muchar  volume;
-    muint   reppnt;
-    muint   replen;
-} sample;
-
-typedef struct {
-    muchar  sampperiod;
-    muchar  period;
-    muchar  sampeffect;
-    muchar  effect;
-} note;
-
-typedef struct {
-    muchar  title[20];
-    sample  samples[31];
-    muchar  length; // length of tablepos
-    muchar  protracker;
-    muchar  patterntable[128];
-    muchar  signature[4];
-    muchar  speed;
-} module;
-
-#pragma pack()
-
-//
-// HxCMod Internal structures
-//
-typedef struct {
-    char*   sampdata;
-    muint   sampnum;
-    muint   length;
-    muint   reppnt;
-    muint   replen;
-    mulong  samppos;
-    muint   period;
-    muchar  volume;
-    mulong  ticks;
-    muchar  effect;
-    muchar  parameffect;
-    muint   effect_code;
-    mint    decalperiod;
-    mint    portaspeed;
-    mint    portaperiod;
-    mint    vibraperiod;
-    mint    Arpperiods[3];
-    muchar  ArpIndex;
-    mint    oldk;
-    muchar  volumeslide;
-    muchar  vibraparam;
-    muchar  vibrapointeur;
-    muchar  finetune;
-    muchar  cut_param;
-    muint   patternloopcnt;
-    muint   patternloopstartpoint;
-} channel;
-
-typedef struct {
-    module  song;
-    char*   sampledata[31];
-    note*   patterndata[128];
-
-    mulong  playrate;
-    muint   tablepos;
-    muint   patternpos;
-    muint   patterndelay;
-    muint   jump_loop_effect;
-    muchar  bpm;
-    mulong  patternticks;
-    mulong  patterntickse;
-    mulong  patternticksaim;
-    mulong  sampleticksconst;
-    mulong  samplenb;
-    channel channels[NUMMAXCHANNELS];
-    muint   number_of_channels;
-    muint   fullperiod[MAXNOTES * 8];
-    muint   mod_loaded;
-    mint    last_r_sample;
-    mint    last_l_sample;
-    mint    stereo;
-    mint    stereo_separation;
-    mint    bits;
-    mint    filter;
-    
-    muchar *modfile; // the raw mod file
-    mulong  modfilesize;
-    muint   loopcount;
-} jar_mod_context_t;
-
-//
-// Player states structures
-//
-typedef struct track_state_
-{
-    unsigned char instrument_number;
-    unsigned short cur_period;
-    unsigned char  cur_volume;
-    unsigned short cur_effect;
-    unsigned short cur_parameffect;
-}track_state;
-
-typedef struct tracker_state_
-{
-    int number_of_tracks;
-    int bpm;
-    int speed;
-    int cur_pattern;
-    int cur_pattern_pos;
-    int cur_pattern_table_pos;
-    unsigned int buf_index;
-    track_state tracks[32];
-}tracker_state;
-
-typedef struct tracker_state_instrument_
-{
-    char name[22];
-    int  active;
-}tracker_state_instrument;
-
-typedef struct jar_mod_tracker_buffer_state_
-{
-    int  nb_max_of_state;
-    int  nb_of_state;
-    int  cur_rd_index;
-    int  sample_step;
-    char name[64];
-    tracker_state_instrument instruments[31];
-    tracker_state * track_state_buf;
-}jar_mod_tracker_buffer_state;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-bool   jar_mod_init(jar_mod_context_t * modctx);
-bool   jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter);
-void   jar_mod_fillbuffer(jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf);
-void   jar_mod_unload(jar_mod_context_t * modctx);
-mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename);
-mulong jar_mod_current_samples(jar_mod_context_t * modctx);
-mulong jar_mod_max_samples(jar_mod_context_t * modctx);
-void   jar_mod_seek_start(jar_mod_context_t * ctx);
-
-#ifdef __cplusplus
-}
-#endif
-//--------------------------------------------------------------------
-
-
-
-//-------------------------------------------------------------------------------
-#ifdef JAR_MOD_IMPLEMENTATION
-
-#include <stdio.h>
-#include <stdlib.h>
-//#include <stdbool.h>
-
-// Effects list
-#define EFFECT_ARPEGGIO              0x0 // Supported
-#define EFFECT_PORTAMENTO_UP         0x1 // Supported
-#define EFFECT_PORTAMENTO_DOWN       0x2 // Supported
-#define EFFECT_TONE_PORTAMENTO       0x3 // Supported
-#define EFFECT_VIBRATO               0x4 // Supported
-#define EFFECT_VOLSLIDE_TONEPORTA    0x5 // Supported
-#define EFFECT_VOLSLIDE_VIBRATO      0x6 // Supported
-#define EFFECT_VOLSLIDE_TREMOLO      0x7 // - TO BE DONE -
-#define EFFECT_SET_PANNING           0x8 // - TO BE DONE -
-#define EFFECT_SET_OFFSET            0x9 // Supported
-#define EFFECT_VOLUME_SLIDE          0xA // Supported
-#define EFFECT_JUMP_POSITION         0xB // Supported
-#define EFFECT_SET_VOLUME            0xC // Supported
-#define EFFECT_PATTERN_BREAK         0xD // Supported
-
-#define EFFECT_EXTENDED              0xE
-#define EFFECT_E_FINE_PORTA_UP       0x1 // Supported
-#define EFFECT_E_FINE_PORTA_DOWN     0x2 // Supported
-#define EFFECT_E_GLISSANDO_CTRL      0x3 // - TO BE DONE -
-#define EFFECT_E_VIBRATO_WAVEFORM    0x4 // - TO BE DONE -
-#define EFFECT_E_SET_FINETUNE        0x5 // - TO BE DONE -
-#define EFFECT_E_PATTERN_LOOP        0x6 // Supported
-#define EFFECT_E_TREMOLO_WAVEFORM    0x7 // - TO BE DONE -
-#define EFFECT_E_SET_PANNING_2       0x8 // - TO BE DONE -
-#define EFFECT_E_RETRIGGER_NOTE      0x9 // - TO BE DONE -
-#define EFFECT_E_FINE_VOLSLIDE_UP    0xA // Supported
-#define EFFECT_E_FINE_VOLSLIDE_DOWN  0xB // Supported
-#define EFFECT_E_NOTE_CUT            0xC // Supported
-#define EFFECT_E_NOTE_DELAY          0xD // - TO BE DONE -
-#define EFFECT_E_PATTERN_DELAY       0xE // Supported
-#define EFFECT_E_INVERT_LOOP         0xF // - TO BE DONE -
-#define EFFECT_SET_SPEED             0xF0 // Supported
-#define EFFECT_SET_TEMPO             0xF2 // Supported
-
-#define PERIOD_TABLE_LENGTH  MAXNOTES
-#define FULL_PERIOD_TABLE_LENGTH  ( PERIOD_TABLE_LENGTH * 8 )
-
-static const short periodtable[]=
-{
-    27392, 25856, 24384, 23040, 21696, 20480, 19328, 18240, 17216, 16256, 15360, 14496,
-    13696, 12928, 12192, 11520, 10848, 10240,  9664,  9120,  8606,  8128,  7680,  7248,
-     6848,  6464,  6096,  5760,  5424,  5120,  4832,  4560,  4304,  4064,  3840,  3624,
-     3424,  3232,  3048,  2880,  2712,  2560,  2416,  2280,  2152,  2032,  1920,  1812,
-     1712,  1616,  1524,  1440,  1356,  1280,  1208,  1140,  1076,  1016,   960,   906,
-      856,   808,   762,   720,   678,   640,   604,   570,   538,   508,   480,   453,
-      428,   404,   381,   360,   339,   320,   302,   285,   269,   254,   240,   226,
-      214,   202,   190,   180,   170,   160,   151,   143,   135,   127,   120,   113,
-      107,   101,    95,    90,    85,    80,    75,    71,    67,    63,    60,    56,
-       53,    50,    47,    45,    42,    40,    37,    35,    33,    31,    30,    28,
-       27,    25,    24,    22,    21,    20,    19,    18,    17,    16,    15,    14,
-       13,    13,    12,    11,    11,    10,     9,     9,     8,     8,     7,     7
-};
-
-static const short sintable[]={
-      0,  24,  49,  74,  97, 120, 141,161,
-    180, 197, 212, 224, 235, 244, 250,253,
-    255, 253, 250, 244, 235, 224, 212,197,
-    180, 161, 141, 120,  97,  74,  49, 24
-};
-
-typedef struct modtype_
-{
-    unsigned char signature[5];
-    int numberofchannels;
-}modtype;
-
-modtype modlist[]=
-{
-    { "M!K!",4},
-    { "M.K.",4},
-    { "FLT4",4},
-    { "FLT8",8},
-    { "4CHN",4},
-    { "6CHN",6},
-    { "8CHN",8},
-    { "10CH",10},
-    { "12CH",12},
-    { "14CH",14},
-    { "16CH",16},
-    { "18CH",18},
-    { "20CH",20},
-    { "22CH",22},
-    { "24CH",24},
-    { "26CH",26},
-    { "28CH",28},
-    { "30CH",30},
-    { "32CH",32},
-    { "",0}
-};
-
-///////////////////////////////////////////////////////////////////////////////////
-
-static void memcopy( void * dest, void *source, unsigned long size )
-{
-    unsigned long i;
-    unsigned char * d,*s;
-
-    d=(unsigned char*)dest;
-    s=(unsigned char*)source;
-    for(i=0;i<size;i++)
-    {
-        d[i]=s[i];
-    }
-}
-
-static void memclear( void * dest, unsigned char value, unsigned long size )
-{
-    unsigned long i;
-    unsigned char * d;
-
-    d=(unsigned char*)dest;
-    for(i=0;i<size;i++)
-    {
-        d[i]=value;
-    }
-}
-
-static int memcompare( unsigned char * buf1, unsigned char * buf2, unsigned int size )
-{
-    unsigned int i;
-
-    i = 0;
-
-    while(i<size)
-    {
-        if(buf1[i] != buf2[i])
-        {
-            return 0;
-        }
-        i++;
-    }
-
-    return 1;
-}
-
-static int getnote( jar_mod_context_t * mod, unsigned short period, int finetune )
-{
-    int i;
-
-    for(i = 0; i < FULL_PERIOD_TABLE_LENGTH; i++)
-    {
-        if(period >= mod->fullperiod[i])
-        {
-            return i;
-        }
-    }
-
-    return MAXNOTES;
-}
-
-static void worknote( note * nptr, channel * cptr, char t, jar_mod_context_t * mod )
-{
-    muint sample, period, effect, operiod;
-    muint curnote, arpnote;
-
-    sample = (nptr->sampperiod & 0xF0) | (nptr->sampeffect >> 4);
-    period = ((nptr->sampperiod & 0xF) << 8) | nptr->period;
-    effect = ((nptr->sampeffect & 0xF) << 8) | nptr->effect;
-
-    operiod = cptr->period;
-
-    if ( period || sample )
-    {
-        if( sample && sample < 32 )
-        {
-            cptr->sampnum = sample - 1;
-        }
-
-        if( period || sample )
-        {
-            cptr->sampdata = (char *) mod->sampledata[cptr->sampnum];
-            cptr->length = mod->song.samples[cptr->sampnum].length;
-            cptr->reppnt = mod->song.samples[cptr->sampnum].reppnt;
-            cptr->replen = mod->song.samples[cptr->sampnum].replen;
-
-            cptr->finetune = (mod->song.samples[cptr->sampnum].finetune)&0xF;
-
-            if(effect>>8!=4 && effect>>8!=6)
-            {
-                cptr->vibraperiod=0;
-                cptr->vibrapointeur=0;
-            }
-        }
-
-        if( (sample != 0) && ( (effect>>8) != EFFECT_VOLSLIDE_TONEPORTA ) )
-        {
-            cptr->volume = mod->song.samples[cptr->sampnum].volume;
-            cptr->volumeslide = 0;
-        }
-
-        if( ( (effect>>8) != EFFECT_TONE_PORTAMENTO && (effect>>8)!=EFFECT_VOLSLIDE_TONEPORTA) )
-        {
-            if (period!=0)
-                cptr->samppos = 0;
-        }
-
-        cptr->decalperiod = 0;
-        if( period )
-        {
-            if(cptr->finetune)
-            {
-                if( cptr->finetune <= 7 )
-                {
-                    period = mod->fullperiod[getnote(mod,period,0) + cptr->finetune];
-                }
-                else
-                {
-                    period = mod->fullperiod[getnote(mod,period,0) - (16 - (cptr->finetune)) ];
-                }
-            }
-
-            cptr->period = period;
-        }
-
-    }
-
-    cptr->effect = 0;
-    cptr->parameffect = 0;
-    cptr->effect_code = effect;
-
-    switch (effect >> 8)
-    {
-        case EFFECT_ARPEGGIO:
-            /*
-            [0]: Arpeggio
-            Where [0][x][y] means "play note, note+x semitones, note+y
-            semitones, then return to original note". The fluctuations are
-            carried out evenly spaced in one pattern division. They are usually
-            used to simulate chords, but this doesn't work too well. They are
-            also used to produce heavy vibrato. A major chord is when x=4, y=7.
-            A minor chord is when x=3, y=7.
-            */
-
-            if(effect&0xff)
-            {
-                cptr->effect = EFFECT_ARPEGGIO;
-                cptr->parameffect = effect&0xff;
-
-                cptr->ArpIndex = 0;
-
-                curnote = getnote(mod,cptr->period,cptr->finetune);
-
-                cptr->Arpperiods[0] = cptr->period;
-
-                arpnote = curnote + (((cptr->parameffect>>4)&0xF)*8);
-                if( arpnote >= FULL_PERIOD_TABLE_LENGTH )
-                    arpnote = FULL_PERIOD_TABLE_LENGTH - 1;
-
-                cptr->Arpperiods[1] = mod->fullperiod[arpnote];
-
-                arpnote = curnote + (((cptr->parameffect)&0xF)*8);
-                if( arpnote >= FULL_PERIOD_TABLE_LENGTH )
-                    arpnote = FULL_PERIOD_TABLE_LENGTH - 1;
-
-                cptr->Arpperiods[2] = mod->fullperiod[arpnote];
-            }
-        break;
-
-        case EFFECT_PORTAMENTO_UP:
-            /*
-            [1]: Slide up
-            Where [1][x][y] means "smoothly decrease the period of current
-            sample by x*16+y after each tick in the division". The
-            ticks/division are set with the 'set speed' effect (see below). If
-            the period of the note being played is z, then the final period
-            will be z - (x*16 + y)*(ticks - 1). As the slide rate depends on
-            the speed, changing the speed will change the slide. You cannot
-            slide beyond the note B3 (period 113).
-            */
-
-            cptr->effect = EFFECT_PORTAMENTO_UP;
-            cptr->parameffect = effect&0xff;
-        break;
-
-        case EFFECT_PORTAMENTO_DOWN:
-            /*
-            [2]: Slide down
-            Where [2][x][y] means "smoothly increase the period of current
-            sample by x*16+y after each tick in the division". Similar to [1],
-            but lowers the pitch. You cannot slide beyond the note C1 (period
-            856).
-            */
-
-            cptr->effect = EFFECT_PORTAMENTO_DOWN;
-            cptr->parameffect = effect&0xff;
-        break;
-
-        case EFFECT_TONE_PORTAMENTO:
-            /*
-            [3]: Slide to note
-            Where [3][x][y] means "smoothly change the period of current sample
-            by x*16+y after each tick in the division, never sliding beyond
-            current period". The period-length in this channel's division is a
-            parameter to this effect, and hence is not played. Sliding to a
-            note is similar to effects [1] and [2], but the slide will not go
-            beyond the given period, and the direction is implied by that
-            period. If x and y are both 0, then the old slide will continue.
-            */
-
-            cptr->effect = EFFECT_TONE_PORTAMENTO;
-            if( (effect&0xff) != 0 )
-            {
-                cptr->portaspeed = (short)(effect&0xff);
-            }
-
-            if(period!=0)
-            {
-                cptr->portaperiod = period;
-                cptr->period = operiod;
-            }
-        break;
-
-        case EFFECT_VIBRATO:
-            /*
-            [4]: Vibrato
-            Where [4][x][y] means "oscillate the sample pitch using a
-            particular waveform with amplitude y/16 semitones, such that (x *
-            ticks)/64 cycles occur in the division". The waveform is set using
-            effect [14][4]. By placing vibrato effects on consecutive
-            divisions, the vibrato effect can be maintained. If either x or y
-            are 0, then the old vibrato values will be used.
-            */
-
-            cptr->effect = EFFECT_VIBRATO;
-            if( ( effect & 0x0F ) != 0 ) // Depth continue or change ?
-                cptr->vibraparam = (cptr->vibraparam & 0xF0) | ( effect & 0x0F );
-            if( ( effect & 0xF0 ) != 0 ) // Speed continue or change ?
-                cptr->vibraparam = (cptr->vibraparam & 0x0F) | ( effect & 0xF0 );
-
-        break;
-
-        case EFFECT_VOLSLIDE_TONEPORTA:
-            /*
-            [5]: Continue 'Slide to note', but also do Volume slide
-            Where [5][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1), at the same time as continuing
-            the last 'Slide to note'". It is illegal for both x and y to be
-            non-zero. You cannot slide outside the volume range 0..64. The
-            period-length in this channel's division is a parameter to this
-            effect, and hence is not played.
-            */
-
-            if( period != 0 )
-            {
-                cptr->portaperiod = period;
-                cptr->period = operiod;
-            }
-
-            cptr->effect = EFFECT_VOLSLIDE_TONEPORTA;
-            if( ( effect & 0xFF ) != 0 )
-                cptr->volumeslide = ( effect & 0xFF );
-
-        break;
-
-        case EFFECT_VOLSLIDE_VIBRATO:
-            /*
-            [6]: Continue 'Vibrato', but also do Volume slide
-            Where [6][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1), at the same time as continuing
-            the last 'Vibrato'". It is illegal for both x and y to be non-zero.
-            You cannot slide outside the volume range 0..64.
-            */
-
-            cptr->effect = EFFECT_VOLSLIDE_VIBRATO;
-            if( (effect & 0xFF) != 0 )
-                cptr->volumeslide = (effect & 0xFF);
-        break;
-
-        case EFFECT_SET_OFFSET:
-            /*
-            [9]: Set sample offset
-            Where [9][x][y] means "play the sample from offset x*4096 + y*256".
-            The offset is measured in words. If no sample is given, yet one is
-            still playing on this channel, it should be retriggered to the new
-            offset using the current volume.
-            */
-
-            cptr->samppos = ((effect>>4) * 4096) + ((effect&0xF)*256);
-
-        break;
-
-        case EFFECT_VOLUME_SLIDE:
-            /*
-            [10]: Volume slide
-            Where [10][x][y] means "either slide the volume up x*(ticks - 1) or
-            slide the volume down y*(ticks - 1)". If both x and y are non-zero,
-            then the y value is ignored (assumed to be 0). You cannot slide
-            outside the volume range 0..64.
-            */
-
-            cptr->effect = EFFECT_VOLUME_SLIDE;
-            cptr->volumeslide = (effect & 0xFF);
-        break;
-
-        case EFFECT_JUMP_POSITION:
-            /*
-            [11]: Position Jump
-            Where [11][x][y] means "stop the pattern after this division, and
-            continue the song at song-position x*16+y". This shifts the
-            'pattern-cursor' in the pattern table (see above). Legal values for
-            x*16+y are from 0 to 127.
-            */
-
-            mod->tablepos = (effect & 0xFF);
-            if(mod->tablepos >= mod->song.length)
-            {
-                mod->tablepos = 0;
-            }
-            mod->patternpos = 0;
-            mod->jump_loop_effect = 1;
-
-        break;
-
-        case EFFECT_SET_VOLUME:
-            /*
-            [12]: Set volume
-            Where [12][x][y] means "set current sample's volume to x*16+y".
-            Legal volumes are 0..64.
-            */
-
-            cptr->volume = (effect & 0xFF);
-        break;
-
-        case EFFECT_PATTERN_BREAK:
-            /*
-            [13]: Pattern Break
-            Where [13][x][y] means "stop the pattern after this division, and
-            continue the song at the next pattern at division x*10+y" (the 10
-            is not a typo). Legal divisions are from 0 to 63 (note Protracker
-            exception above).
-            */
-
-            mod->patternpos = ( ((effect>>4)&0xF)*10 + (effect&0xF) ) * mod->number_of_channels;
-            mod->jump_loop_effect = 1;
-            mod->tablepos++;
-            if(mod->tablepos >= mod->song.length)
-            {
-                mod->tablepos = 0;
-            }
-
-        break;
-
-        case EFFECT_EXTENDED:
-            switch( (effect>>4) & 0xF )
-            {
-                case EFFECT_E_FINE_PORTA_UP:
-                    /*
-                    [14][1]: Fineslide up
-                    Where [14][1][x] means "decrement the period of the current sample
-                    by x". The incrementing takes place at the beginning of the
-                    division, and hence there is no actual sliding. You cannot slide
-                    beyond the note B3 (period 113).
-                    */
-
-                    cptr->period -= (effect & 0xF);
-                    if( cptr->period < 113 )
-                        cptr->period = 113;
-                break;
-
-                case EFFECT_E_FINE_PORTA_DOWN:
-                    /*
-                    [14][2]: Fineslide down
-                    Where [14][2][x] means "increment the period of the current sample
-                    by x". Similar to [14][1] but shifts the pitch down. You cannot
-                    slide beyond the note C1 (period 856).
-                    */
-
-                    cptr->period += (effect & 0xF);
-                    if( cptr->period > 856 )
-                        cptr->period = 856;
-                break;
-
-                case EFFECT_E_FINE_VOLSLIDE_UP:
-                    /*
-                    [14][10]: Fine volume slide up
-                    Where [14][10][x] means "increment the volume of the current sample
-                    by x". The incrementing takes place at the beginning of the
-                    division, and hence there is no sliding. You cannot slide beyond
-                    volume 64.
-                    */
-
-                    cptr->volume += (effect & 0xF);
-                    if( cptr->volume>64 )
-                        cptr->volume = 64;
-                break;
-
-                case EFFECT_E_FINE_VOLSLIDE_DOWN:
-                    /*
-                    [14][11]: Fine volume slide down
-                    Where [14][11][x] means "decrement the volume of the current sample
-                    by x". Similar to [14][10] but lowers volume. You cannot slide
-                    beyond volume 0.
-                    */
-
-                    cptr->volume -= (effect & 0xF);
-                    if( cptr->volume > 200 )
-                        cptr->volume = 0;
-                break;
-
-                case EFFECT_E_PATTERN_LOOP:
-                    /*
-                    [14][6]: Loop pattern
-                    Where [14][6][x] means "set the start of a loop to this division if
-                    x is 0, otherwise after this division, jump back to the start of a
-                    loop and play it another x times before continuing". If the start
-                    of the loop was not set, it will default to the start of the
-                    current pattern. Hence 'loop pattern' cannot be performed across
-                    multiple patterns. Note that loops do not support nesting, and you
-                    may generate an infinite loop if you try to nest 'loop pattern's.
-                    */
-
-                    if( effect & 0xF )
-                    {
-                        if( cptr->patternloopcnt )
-                        {
-                            cptr->patternloopcnt--;
-                            if( cptr->patternloopcnt )
-                            {
-                                mod->patternpos = cptr->patternloopstartpoint;
-                                mod->jump_loop_effect = 1;
-                            }
-                            else
-                            {
-                                cptr->patternloopstartpoint = mod->patternpos ;
-                            }
-                        }
-                        else
-                        {
-                            cptr->patternloopcnt = (effect & 0xF);
-                            mod->patternpos = cptr->patternloopstartpoint;
-                            mod->jump_loop_effect = 1;
-                        }
-                    }
-                    else // Start point
-                    {
-                        cptr->patternloopstartpoint = mod->patternpos;
-                    }
-
-                break;
-
-                case EFFECT_E_PATTERN_DELAY:
-                    /*
-                    [14][14]: Delay pattern
-                    Where [14][14][x] means "after this division there will be a delay
-                    equivalent to the time taken to play x divisions after which the
-                    pattern will be resumed". The delay only relates to the
-                    interpreting of new divisions, and all effects and previous notes
-                    continue during delay.
-                    */
-
-                    mod->patterndelay = (effect & 0xF);
-                break;
-
-                case EFFECT_E_NOTE_CUT:
-                    /*
-                    [14][12]: Cut sample
-                    Where [14][12][x] means "after the current sample has been played
-                    for x ticks in this division, its volume will be set to 0". This
-                    implies that if x is 0, then you will not hear any of the sample.
-                    If you wish to insert "silence" in a pattern, it is better to use a
-                    "silence"-sample (see above) due to the lack of proper support for
-                    this effect.
-                    */
-                    cptr->effect = EFFECT_E_NOTE_CUT;
-                    cptr->cut_param = (effect & 0xF);
-                    if(!cptr->cut_param)
-                        cptr->volume = 0;
-                break;
-
-                default:
-
-                break;
-            }
-        break;
-
-        case 0xF:
-            /*
-            [15]: Set speed
-            Where [15][x][y] means "set speed to x*16+y". Though it is nowhere
-            near that simple. Let z = x*16+y. Depending on what values z takes,
-            different units of speed are set, there being two: ticks/division
-            and beats/minute (though this one is only a label and not strictly
-            true). If z=0, then what should technically happen is that the
-            module stops, but in practice it is treated as if z=1, because
-            there is already a method for stopping the module (running out of
-            patterns). If z<=32, then it means "set ticks/division to z"
-            otherwise it means "set beats/minute to z" (convention says that
-            this should read "If z<32.." but there are some composers out there
-            that defy conventions). Default values are 6 ticks/division, and
-            125 beats/minute (4 divisions = 1 beat). The beats/minute tag is
-            only meaningful for 6 ticks/division. To get a more accurate view
-            of how things work, use the following formula:
-                                     24 * beats/minute
-                  divisions/minute = -----------------
-                                      ticks/division
-            Hence divisions/minute range from 24.75 to 6120, eg. to get a value
-            of 2000 divisions/minute use 3 ticks/division and 250 beats/minute.
-            If multiple "set speed" effects are performed in a single division,
-            the ones on higher-numbered channels take precedence over the ones
-            on lower-numbered channels. This effect has a large number of
-            different implementations, but the one described here has the
-            widest usage.
-            */
-
-            if( (effect&0xFF) < 0x21 )
-            {
-                if( effect&0xFF )
-                {
-                    mod->song.speed = effect&0xFF;
-                    mod->patternticksaim = (long)mod->song.speed * ((mod->playrate * 5 ) / (((long)2 * (long)mod->bpm)));
-                }
-            }
-
-            if( (effect&0xFF) >= 0x21 )
-            {
-                ///  HZ = 2 * BPM / 5
-                mod->bpm = effect&0xFF;
-                mod->patternticksaim = (long)mod->song.speed * ((mod->playrate * 5 ) / (((long)2 * (long)mod->bpm)));
-            }
-
-        break;
-
-        default:
-        // Unsupported effect
-        break;
-
-    }
-
-}
-
-static void workeffect( note * nptr, channel * cptr )
-{
-    switch(cptr->effect)
-    {
-        case EFFECT_ARPEGGIO:
-
-            if( cptr->parameffect )
-            {
-                cptr->decalperiod = cptr->period - cptr->Arpperiods[cptr->ArpIndex];
-
-                cptr->ArpIndex++;
-                if( cptr->ArpIndex>2 )
-                    cptr->ArpIndex = 0;
-            }
-        break;
-
-        case EFFECT_PORTAMENTO_UP:
-
-            if(cptr->period)
-            {
-                cptr->period -= cptr->parameffect;
-
-                if( cptr->period < 113 || cptr->period > 20000 )
-                    cptr->period = 113;
-            }
-
-        break;
-
-        case EFFECT_PORTAMENTO_DOWN:
-
-            if(cptr->period)
-            {
-                cptr->period += cptr->parameffect;
-
-                if( cptr->period > 20000 )
-                    cptr->period = 20000;
-            }
-
-        break;
-
-        case EFFECT_VOLSLIDE_TONEPORTA:
-        case EFFECT_TONE_PORTAMENTO:
-
-            if( cptr->period && ( cptr->period != cptr->portaperiod ) && cptr->portaperiod )
-            {
-                if( cptr->period > cptr->portaperiod )
-                {
-                    if( cptr->period - cptr->portaperiod >= cptr->portaspeed )
-                    {
-                        cptr->period -= cptr->portaspeed;
-                    }
-                    else
-                    {
-                        cptr->period = cptr->portaperiod;
-                    }
-                }
-                else
-                {
-                    if( cptr->portaperiod - cptr->period >= cptr->portaspeed )
-                    {
-                        cptr->period += cptr->portaspeed;
-                    }
-                    else
-                    {
-                        cptr->period = cptr->portaperiod;
-                    }
-                }
-
-                if( cptr->period == cptr->portaperiod )
-                {
-                    // If the slide is over, don't let it to be retriggered.
-                    cptr->portaperiod = 0;
-                }
-            }
-
-            if( cptr->effect == EFFECT_VOLSLIDE_TONEPORTA )
-            {
-                if( cptr->volumeslide > 0x0F )
-                {
-                    cptr->volume = cptr->volume + (cptr->volumeslide>>4);
-
-                    if(cptr->volume>63)
-                        cptr->volume = 63;
-                }
-                else
-                {
-                    cptr->volume = cptr->volume - (cptr->volumeslide);
-
-                    if(cptr->volume>63)
-                        cptr->volume=0;
-                }
-            }
-        break;
-
-        case EFFECT_VOLSLIDE_VIBRATO:
-        case EFFECT_VIBRATO:
-
-            cptr->vibraperiod = ( (cptr->vibraparam&0xF) * sintable[cptr->vibrapointeur&0x1F] )>>7;
-
-            if( cptr->vibrapointeur > 31 )
-                cptr->vibraperiod = -cptr->vibraperiod;
-
-            cptr->vibrapointeur = (cptr->vibrapointeur+(((cptr->vibraparam>>4))&0xf)) & 0x3F;
-
-            if( cptr->effect == EFFECT_VOLSLIDE_VIBRATO )
-            {
-                if( cptr->volumeslide > 0xF )
-                {
-                    cptr->volume = cptr->volume+(cptr->volumeslide>>4);
-
-                    if( cptr->volume > 64 )
-                        cptr->volume = 64;
-                }
-                else
-                {
-                    cptr->volume = cptr->volume - cptr->volumeslide;
-
-                    if( cptr->volume > 64 )
-                        cptr->volume = 0;
-                }
-            }
-
-        break;
-
-        case EFFECT_VOLUME_SLIDE:
-
-            if( cptr->volumeslide > 0xF )
-            {
-                cptr->volume += (cptr->volumeslide>>4);
-
-                if( cptr->volume > 64 )
-                    cptr->volume = 64;
-            }
-            else
-            {
-                cptr->volume -= (cptr->volumeslide&0xf);
-
-                if( cptr->volume > 64 )
-                    cptr->volume = 0;
-            }
-        break;
-
-        case EFFECT_E_NOTE_CUT:
-            if(cptr->cut_param)
-                cptr->cut_param--;
-
-            if(!cptr->cut_param)
-                cptr->volume = 0;
-        break;
-
-        default:
-        break;
-
-    }
-
-}
-
-///////////////////////////////////////////////////////////////////////////////////
-bool jar_mod_init(jar_mod_context_t * modctx)
-{
-    muint i,j;
-
-    if( modctx )
-    {
-        memclear(modctx, 0, sizeof(jar_mod_context_t));
-        modctx->playrate = DEFAULT_SAMPLE_RATE;
-        modctx->stereo = 1;
-        modctx->stereo_separation = 1;
-        modctx->bits = 16;
-        modctx->filter = 1;
-
-        for(i=0; i < PERIOD_TABLE_LENGTH - 1; i++)
-        {
-            for(j=0; j < 8; j++)
-            {
-                modctx->fullperiod[(i*8) + j] = periodtable[i] - ((( periodtable[i] - periodtable[i+1] ) / 8) * j);
-            }
-        }
-
-        return 1;
-    }
-
-    return 0;
-}
-
-bool jar_mod_setcfg(jar_mod_context_t * modctx, int samplerate, int bits, int stereo, int stereo_separation, int filter)
-{
-    if( modctx )
-    {
-        modctx->playrate = samplerate;
-
-        if( stereo )
-            modctx->stereo = 1;
-        else
-            modctx->stereo = 0;
-            
-        if(stereo_separation < 4)
-        {
-            modctx->stereo_separation = stereo_separation;
-        }
-
-        if( bits == 8 || bits == 16 )
-            modctx->bits = bits;
-        else
-            modctx->bits = 16;
-
-        if( filter )
-            modctx->filter = 1;
-        else
-            modctx->filter = 0;
-
-        return 1;
-    }
-
-    return 0;
-}
-
-// make certain that mod_data stays in memory while playing
-static bool jar_mod_load( jar_mod_context_t * modctx, void * mod_data, int mod_data_size )
-{
-    muint i, max;
-    unsigned short t;
-    sample *sptr;
-    unsigned char * modmemory,* endmodmemory;
-
-    modmemory = (unsigned char *)mod_data;
-    endmodmemory = modmemory + mod_data_size;
-    
-    
-
-    if(modmemory)
-    {
-        if( modctx )
-        {
-            memcopy(&(modctx->song.title),modmemory,1084);
-
-            i = 0;
-            modctx->number_of_channels = 0;
-            while(modlist[i].numberofchannels)
-            {
-                if(memcompare(modctx->song.signature,modlist[i].signature,4))
-                {
-                    modctx->number_of_channels = modlist[i].numberofchannels;
-                }
-
-                i++;
-            }
-
-            if( !modctx->number_of_channels )
-            {
-                // 15 Samples modules support
-                // Shift the whole datas to make it look likes a standard 4 channels mod.
-                memcopy(&(modctx->song.signature), "M.K.", 4);
-                memcopy(&(modctx->song.length), &(modctx->song.samples[15]), 130);
-                memclear(&(modctx->song.samples[15]), 0, 480);
-                modmemory += 600;
-                modctx->number_of_channels = 4;
-            }
-            else
-            {
-                modmemory += 1084;
-            }
-
-            if( modmemory >= endmodmemory )
-                return 0; // End passed ? - Probably a bad file !
-
-            // Patterns loading
-            for (i = max = 0; i < 128; i++)
-            {
-                while (max <= modctx->song.patterntable[i])
-                {
-                    modctx->patterndata[max] = (note*)modmemory;
-                    modmemory += (256*modctx->number_of_channels);
-                    max++;
-
-                    if( modmemory >= endmodmemory )
-                        return 0; // End passed ? - Probably a bad file !
-                }
-            }
-
-            for (i = 0; i < 31; i++)
-                modctx->sampledata[i]=0;
-
-            // Samples loading
-            for (i = 0, sptr = modctx->song.samples; i <31; i++, sptr++)
-            {
-                t= (sptr->length &0xFF00)>>8 | (sptr->length &0xFF)<<8;
-                sptr->length = t*2;
-
-                t= (sptr->reppnt &0xFF00)>>8 | (sptr->reppnt &0xFF)<<8;
-                sptr->reppnt = t*2;
-
-                t= (sptr->replen &0xFF00)>>8 | (sptr->replen &0xFF)<<8;
-                sptr->replen = t*2;
-
-
-                if (sptr->length == 0) continue;
-
-                modctx->sampledata[i] = (char*)modmemory;
-                modmemory += sptr->length;
-
-                if (sptr->replen + sptr->reppnt > sptr->length)
-                    sptr->replen = sptr->length - sptr->reppnt;
-
-                if( modmemory > endmodmemory )
-                    return 0; // End passed ? - Probably a bad file !
-            }
-
-            // States init
-
-            modctx->tablepos = 0;
-            modctx->patternpos = 0;
-            modctx->song.speed = 6;
-            modctx->bpm = 125;
-            modctx->samplenb = 0;
-
-            modctx->patternticks = (((long)modctx->song.speed * modctx->playrate * 5)/ (2 * modctx->bpm)) + 1;
-            modctx->patternticksaim = ((long)modctx->song.speed * modctx->playrate * 5) / (2 * modctx->bpm);
-
-            modctx->sampleticksconst = 3546894UL / modctx->playrate; //8448*428/playrate;
-
-            for(i=0; i < modctx->number_of_channels; i++)
-            {
-                modctx->channels[i].volume = 0;
-                modctx->channels[i].period = 0;
-            }
-
-            modctx->mod_loaded = 1;
-
-            return 1;
-        }
-    }
-
-    return 0;
-}
-
-void jar_mod_fillbuffer( jar_mod_context_t * modctx, short * outbuffer, unsigned long nbsample, jar_mod_tracker_buffer_state * trkbuf )
-{
-    unsigned long i, j;
-    unsigned long k;
-    unsigned char c;
-    unsigned int state_remaining_steps;
-    int l,r;
-    int ll,lr;
-    int tl,tr;
-    short finalperiod;
-    note    *nptr;
-    channel *cptr;
-
-    if( modctx && outbuffer )
-    {
-        if(modctx->mod_loaded)
-        {
-            state_remaining_steps = 0;
-
-            if( trkbuf )
-            {
-                trkbuf->cur_rd_index = 0;
-
-                memcopy(trkbuf->name,modctx->song.title,sizeof(modctx->song.title));
-
-                for(i=0;i<31;i++)
-                {
-                    memcopy(trkbuf->instruments[i].name,modctx->song.samples[i].name,sizeof(trkbuf->instruments[i].name));
-                }
-            }
-
-            ll = modctx->last_l_sample;
-            lr = modctx->last_r_sample;
-
-            for (i = 0; i < nbsample; i++)
-            {
-                //---------------------------------------
-                if( modctx->patternticks++ > modctx->patternticksaim )
-                {
-                    if( !modctx->patterndelay )
-                    {
-                        nptr = modctx->patterndata[modctx->song.patterntable[modctx->tablepos]];
-                        nptr = nptr + modctx->patternpos;
-                        cptr = modctx->channels;
-
-                        modctx->patternticks = 0;
-                        modctx->patterntickse = 0;
-
-                        for(c=0;c<modctx->number_of_channels;c++)
-                        {
-                            worknote((note*)(nptr+c), (channel*)(cptr+c),(char)(c+1),modctx);
-                        }
-
-                        if( !modctx->jump_loop_effect )
-                            modctx->patternpos += modctx->number_of_channels;
-                        else
-                            modctx->jump_loop_effect = 0;
-
-                        if( modctx->patternpos == 64*modctx->number_of_channels )
-                        {
-                            modctx->tablepos++;
-                            modctx->patternpos = 0;
-                            if(modctx->tablepos >= modctx->song.length)
-                            {
-                                modctx->tablepos = 0;
-                                modctx->loopcount++; // count next loop
-                            }
-                        }
-                    }
-                    else
-                    {
-                        modctx->patterndelay--;
-                        modctx->patternticks = 0;
-                        modctx->patterntickse = 0;
-                    }
-
-                }
-
-                if( modctx->patterntickse++ > (modctx->patternticksaim/modctx->song.speed) )
-                {
-                    nptr = modctx->patterndata[modctx->song.patterntable[modctx->tablepos]];
-                    nptr = nptr + modctx->patternpos;
-                    cptr = modctx->channels;
-
-                    for(c=0;c<modctx->number_of_channels;c++)
-                    {
-                        workeffect(nptr+c, cptr+c);
-                    }
-
-                    modctx->patterntickse = 0;
-                }
-
-                //---------------------------------------
-
-                if( trkbuf && !state_remaining_steps )
-                {
-                    if( trkbuf->nb_of_state < trkbuf->nb_max_of_state )
-                    {
-                        memclear(&trkbuf->track_state_buf[trkbuf->nb_of_state], 0, sizeof(tracker_state));
-                    }
-                }
-
-                l=0;
-                r=0;
-
-                for(j =0, cptr = modctx->channels; j < modctx->number_of_channels ; j++, cptr++)
-                {
-                    if( cptr->period != 0 )
-                    {
-                        finalperiod = cptr->period - cptr->decalperiod - cptr->vibraperiod;
-                        if( finalperiod )
-                        {
-                            cptr->samppos += ( (modctx->sampleticksconst<<10) / finalperiod );
-                        }
-
-                        cptr->ticks++;
-
-                        if( cptr->replen<=2 )
-                        {
-                            if( (cptr->samppos>>10) >= (cptr->length) )
-                            {
-                                cptr->length = 0;
-                                cptr->reppnt = 0;
-
-                                if( cptr->length )
-                                    cptr->samppos = cptr->samppos % (((unsigned long)cptr->length)<<10);
-                                else
-                                    cptr->samppos = 0;
-                            }
-                        }
-                        else
-                        {
-                            if( (cptr->samppos>>10) >= (unsigned long)(cptr->replen+cptr->reppnt) )
-                            {
-                                cptr->samppos = ((unsigned long)(cptr->reppnt)<<10) + (cptr->samppos % ((unsigned long)(cptr->replen+cptr->reppnt)<<10));
-                            }
-                        }
-
-                        k = cptr->samppos >> 10;
-
-                        if( cptr->sampdata!=0 && ( ((j&3)==1) || ((j&3)==2) ) )
-                        {
-                            r += ( cptr->sampdata[k] *  cptr->volume );
-                        }
-
-                        if( cptr->sampdata!=0 && ( ((j&3)==0) || ((j&3)==3) ) )
-                        {
-                            l += ( cptr->sampdata[k] *  cptr->volume );
-                        }
-
-                        if( trkbuf && !state_remaining_steps )
-                        {
-                            if( trkbuf->nb_of_state < trkbuf->nb_max_of_state )
-                            {
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].number_of_tracks = modctx->number_of_channels;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].buf_index = i;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern = modctx->song.patterntable[modctx->tablepos];
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern_pos = modctx->patternpos / modctx->number_of_channels;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].cur_pattern_table_pos = modctx->tablepos;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].bpm = modctx->bpm;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].speed = modctx->song.speed;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_effect = cptr->effect_code;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_parameffect = cptr->parameffect;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_period = finalperiod;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].cur_volume = cptr->volume;
-                                trkbuf->track_state_buf[trkbuf->nb_of_state].tracks[j].instrument_number = (unsigned char)cptr->sampnum;
-                            }
-                        }
-                    }
-                }
-
-                if( trkbuf && !state_remaining_steps )
-                {
-                    state_remaining_steps = trkbuf->sample_step;
-
-                    if(trkbuf->nb_of_state < trkbuf->nb_max_of_state)
-                        trkbuf->nb_of_state++;
-                }
-                else
-                {
-                    state_remaining_steps--;
-                }
-
-                tl = (short)l;
-                tr = (short)r;
-
-                if ( modctx->filter )
-                {
-                    // Filter
-                    l = (l+ll)>>1;
-                    r = (r+lr)>>1;
-                }
-
-                if ( modctx->stereo_separation == 1 )
-                {
-                    // Left & Right Stereo panning
-                    l = (l+(r>>1));
-                    r = (r+(l>>1));
-                }
-
-                // Level limitation
-                if( l > 32767 ) l = 32767;
-                if( l < -32768 ) l = -32768;
-                if( r > 32767 ) r = 32767;
-                if( r < -32768 ) r = -32768;
-
-                // Store the final sample.
-                outbuffer[(i*2)]   = l;
-                outbuffer[(i*2)+1] = r;
-
-                ll = tl;
-                lr = tr;
-
-            }
-
-            modctx->last_l_sample = ll;
-            modctx->last_r_sample = lr;
-
-            modctx->samplenb = modctx->samplenb+nbsample;
-        }
-        else
-        {
-            for (i = 0; i < nbsample; i++)
-            {
-                // Mod not loaded. Return blank buffer.
-                outbuffer[(i*2)]   = 0;
-                outbuffer[(i*2)+1] = 0;
-            }
-
-            if(trkbuf)
-            {
-                trkbuf->nb_of_state = 0;
-                trkbuf->cur_rd_index = 0;
-                trkbuf->name[0] = 0;
-                memclear(trkbuf->track_state_buf, 0, sizeof(tracker_state) * trkbuf->nb_max_of_state);
-                memclear(trkbuf->instruments, 0, sizeof(trkbuf->instruments));
-            }
-        }
-    }
-}
-
-//resets internals for mod context
-static bool jar_mod_reset( jar_mod_context_t * modctx)
-{
-    if(modctx)
-    {
-        memclear(&modctx->song, 0, sizeof(modctx->song));
-        memclear(&modctx->sampledata, 0, sizeof(modctx->sampledata));
-        memclear(&modctx->patterndata, 0, sizeof(modctx->patterndata));
-        modctx->tablepos = 0;
-        modctx->patternpos = 0;
-        modctx->patterndelay  = 0;
-        modctx->jump_loop_effect = 0;
-        modctx->bpm = 0;
-        modctx->patternticks = 0;
-        modctx->patterntickse = 0;
-        modctx->patternticksaim = 0;
-        modctx->sampleticksconst = 0;
-        modctx->samplenb = 0;
-        memclear(modctx->channels, 0, sizeof(modctx->channels));
-        modctx->number_of_channels = 0;
-        modctx->mod_loaded = 0;
-        modctx->last_r_sample = 0;
-        modctx->last_l_sample = 0;
-        
-        return jar_mod_init(modctx);
-    }
-    return 0;
-}
-
-void jar_mod_unload( jar_mod_context_t * modctx)
-{
-    if(modctx)
-    {
-        if(modctx->modfile)
-        {
-            JARMOD_FREE(modctx->modfile);
-            modctx->modfile = 0;
-            modctx->modfilesize = 0;
-            modctx->loopcount = 0;
-        }
-        jar_mod_reset(modctx);
-    }
-}
-
-mulong jar_mod_load_file(jar_mod_context_t * modctx, const char* filename)
-{
-    mulong fsize = 0;
-    if(modctx->modfile)
-    {
-        JARMOD_FREE(modctx->modfile);
-        modctx->modfile = 0;
-    }
-    
-    FILE *f = fopen(filename, "rb");
-    if(f)
-    {
-        fseek(f,0,SEEK_END);
-        fsize = ftell(f);
-        fseek(f,0,SEEK_SET);
-        
-        if(fsize && fsize < 32*1024*1024)
-        {
-            modctx->modfile = JARMOD_MALLOC(fsize);
-            modctx->modfilesize = fsize;
-            memset(modctx->modfile, 0, fsize);
-            fread(modctx->modfile, fsize, 1, f);
-            fclose(f);
-            
-            if(!jar_mod_load(modctx, (void*)modctx->modfile, fsize)) fsize = 0;
-        } else fsize = 0;
-    }
-    return fsize;
-}
-
-mulong jar_mod_current_samples(jar_mod_context_t * modctx)
-{
-    if(modctx)
-        return modctx->samplenb;
-    
-    return 0;
-}
-
-// Works, however it is very slow, this data should be cached to ensure it is run only once per file
-mulong jar_mod_max_samples(jar_mod_context_t * ctx)
-{
-    mint buff[2];
-    mulong len;
-    mulong lastcount = ctx->loopcount;
-    
-    while(ctx->loopcount <= lastcount)
-        jar_mod_fillbuffer(ctx, buff, 1, 0);
-    
-    len = ctx->samplenb;
-    jar_mod_seek_start(ctx);
-    
-    return len;
-}
-
-// move seek_val to sample index, 0 -> jar_mod_max_samples is the range
-void jar_mod_seek_start(jar_mod_context_t * ctx)
-{
-    if(ctx && ctx->modfile)
-    {
-        muchar* ftmp = ctx->modfile;
-        mulong stmp = ctx->modfilesize;
-        muint lcnt = ctx->loopcount;
-        
-        if(jar_mod_reset(ctx)){
-            jar_mod_load(ctx, ftmp, stmp);
-            ctx->modfile = ftmp;
-            ctx->modfilesize = stmp;
-            ctx->loopcount = lcnt;
-        }
-    }
-}
-
-#endif // end of JAR_MOD_IMPLEMENTATION
-//-------------------------------------------------------------------------------
-
-
-#endif //end of header file
\ No newline at end of file
diff --git a/raylib_pi4_test/external/jar_xm.h b/raylib_pi4_test/external/jar_xm.h
deleted file mode 100644 (file)
index ea7a328..0000000
+++ /dev/null
@@ -1,2470 +0,0 @@
-// jar_xm.h
-//
-// ORIGINAL LICENSE - FOR LIBXM:
-//
-// Author: Romain "Artefact2" Dalmaso <artefact2@gmail.com>
-// Contributor: Dan Spencer <dan@atomicpotato.net>
-// Repackaged into jar_xm.h By: Joshua Adam Reisenauer <kd7tck@gmail.com>
-// This program is free software. It comes without any warranty, to the
-// extent permitted by applicable law. You can redistribute it and/or
-// modify it under the terms of the Do What The Fuck You Want To Public
-// License, Version 2, as published by Sam Hocevar. See
-// http://sam.zoy.org/wtfpl/COPYING for more details.
-//
-// HISTORY:
-//   v0.1.0 2016-02-22  jar_xm.h - development by Joshua Reisenauer, MAR 2016
-//   v0.2.1 2021-03-07  m4ntr0n1c: Fix clipping noise for "bad" xm's (they will always clip), avoid clip noise and just put a ceiling)
-//   v0.2.2 2021-03-09  m4ntr0n1c: Add complete debug solution (raylib.h must be included)
-//   v0.2.3 2021-03-11  m4ntr0n1c: Fix tempo, bpm and volume on song stop / start / restart / loop
-//   v0.2.4 2021-03-17  m4ntr0n1c: Sanitize code for readability
-//   v0.2.5 2021-03-22  m4ntr0n1c: Minor adjustments
-//   v0.2.6 2021-04-01  m4ntr0n1c: Minor fixes and optimisation
-//   v0.3.0 2021-04-03  m4ntr0n1c: Addition of Stereo sample support, Linear Interpolation and Ramping now addressable options in code
-//   v0.3.1 2021-04-04  m4ntr0n1c: Volume effects column adjustments, sample offset handling adjustments
-//
-// USAGE:
-//
-// In ONE source file, put:
-//
-//    #define JAR_XM_IMPLEMENTATION
-//    #include "jar_xm.h"
-//
-// Other source files should just include jar_xm.h
-//
-// SAMPLE CODE:
-//
-// jar_xm_context_t *musicptr;
-// float musicBuffer[48000 / 60];
-// int intro_load(void)
-// {
-//     jar_xm_create_context_from_file(&musicptr, 48000, "Song.XM");
-//     return 1;
-// }
-// int intro_unload(void)
-// {
-//     jar_xm_free_context(musicptr);
-//     return 1;
-// }
-// int intro_tick(long counter)
-// {
-//     jar_xm_generate_samples(musicptr, musicBuffer, (48000 / 60) / 2);
-//     if(IsKeyDown(KEY_ENTER))
-//         return 1;
-//     return 0;
-// }
-//
-#ifndef INCLUDE_JAR_XM_H
-#define INCLUDE_JAR_XM_H
-
-#include <stdint.h>
-
-#define JAR_XM_DEBUG 0
-#define JAR_XM_DEFENSIVE 1
-//#define JAR_XM_RAYLIB 0 // set to 0 to disable the RayLib visualizer extension
-
-// Allow custom memory allocators
-#ifndef JARXM_MALLOC
-    #define JARXM_MALLOC(sz)    malloc(sz)
-#endif
-#ifndef JARXM_FREE
-    #define JARXM_FREE(p)       free(p)
-#endif
-
-//-------------------------------------------------------------------------------
-struct jar_xm_context_s;
-typedef struct jar_xm_context_s jar_xm_context_t;
-
-#ifdef __cplusplus
-extern "C" { 
-#endif
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-// * @returns 3 unable to open input file
-// * @returns 4 fseek() failed
-// * @returns 5 fread() failed
-// * @returns 6 unkown error
-// * @deprecated This function is unsafe!
-// * @see jar_xm_create_context_safe()
-int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const char* filename);
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-// * @deprecated This function is unsafe!
-// * @see jar_xm_create_context_safe()
-int jar_xm_create_context(jar_xm_context_t** ctx, const char* moddata, uint32_t rate);
-
-//** Create a XM context.
-// * @param moddata the contents of the module
-// * @param moddata_length the length of the contents of the module, in bytes
-// * @param rate play rate in Hz, recommended value of 48000
-// * @returns 0 on success
-// * @returns 1 if module data is not sane
-// * @returns 2 if memory allocation failed
-int jar_xm_create_context_safe(jar_xm_context_t** ctx, const char* moddata, size_t moddata_length, uint32_t rate);
-
-//** Free a XM context created by jar_xm_create_context(). */
-void jar_xm_free_context(jar_xm_context_t* ctx);
-
-//** Play the module and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsamples);
-
-//** Play the module, resample from float to 16 bit, and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples_16bit(jar_xm_context_t* ctx, short* output, size_t numsamples) {
-    float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float));
-    jar_xm_generate_samples(ctx, musicBuffer, numsamples);
-
-    if(output){
-        for(int x=0;x<2*numsamples;x++) output[x] = (musicBuffer[x] * 32767.0f); // scale sample to signed small int
-    }
-    JARXM_FREE(musicBuffer);
-}
-
-//** Play the module, resample from float to 8 bit, and put the sound samples in an output buffer.
-// * @param output buffer of 2*numsamples elements (A left and right value for each sample)
-// * @param numsamples number of samples to generate
-void jar_xm_generate_samples_8bit(jar_xm_context_t* ctx, char* output, size_t numsamples) {
-    float* musicBuffer = JARXM_MALLOC((2*numsamples)*sizeof(float));
-    jar_xm_generate_samples(ctx, musicBuffer, numsamples);
-
-    if(output){
-        for(int x=0;x<2*numsamples;x++) output[x] = (musicBuffer[x] * 127.0f); // scale sample to signed 8 bit
-    }
-    JARXM_FREE(musicBuffer);
-}
-
-//** Set the maximum number of times a module can loop. After the specified number of loops, calls to jar_xm_generate_samples will only generate silence. You can control the current number of loops with jar_xm_get_loop_count().
-// * @param loopcnt maximum number of loops. Use 0 to loop indefinitely.
-void jar_xm_set_max_loop_count(jar_xm_context_t* ctx, uint8_t loopcnt);
-
-//** Get the loop count of the currently playing module. This value is 0 when the module is still playing, 1 when the module has looped once, etc.
-uint8_t jar_xm_get_loop_count(jar_xm_context_t* ctx);
-
-//** Mute or unmute a channel.
-// * @note Channel numbers go from 1 to jar_xm_get_number_of_channels(...).
-// * @return whether the channel was muted.
-bool jar_xm_mute_channel(jar_xm_context_t* ctx, uint16_t, bool);
-
-//** Mute or unmute an instrument.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-// * @return whether the instrument was muted.
-bool jar_xm_mute_instrument(jar_xm_context_t* ctx, uint16_t, bool);
-
-//** Get the module name as a NUL-terminated string.
-const char* jar_xm_get_module_name(jar_xm_context_t* ctx);
-
-//** Get the tracker name as a NUL-terminated string.
-const char* jar_xm_get_tracker_name(jar_xm_context_t* ctx);
-
-//** Get the number of channels.
-uint16_t jar_xm_get_number_of_channels(jar_xm_context_t* ctx);
-
-//** Get the module length (in patterns).
-uint16_t jar_xm_get_module_length(jar_xm_context_t*);
-
-//** Get the number of patterns.
-uint16_t jar_xm_get_number_of_patterns(jar_xm_context_t* ctx);
-
-//** Get the number of rows of a pattern.
-// * @note Pattern numbers go from 0 to jar_xm_get_number_of_patterns(...)-1.
-uint16_t jar_xm_get_number_of_rows(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the number of instruments.
-uint16_t jar_xm_get_number_of_instruments(jar_xm_context_t* ctx);
-
-//** Get the number of samples of an instrument.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-uint16_t jar_xm_get_number_of_samples(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the current module speed.
-// * @param bpm will receive the current BPM
-// * @param tempo will receive the current tempo (ticks per line)
-void jar_xm_get_playing_speed(jar_xm_context_t* ctx, uint16_t* bpm, uint16_t* tempo);
-
-//** Get the current position in the module being played.
-// * @param pattern_index if not NULL, will receive the current pattern index in the POT (pattern order table)
-// * @param pattern if not NULL, will receive the current pattern number
-// * @param row if not NULL, will receive the current row
-// * @param samples if not NULL, will receive the total number of
-// * generated samples (divide by sample rate to get seconds of generated audio)
-void jar_xm_get_position(jar_xm_context_t* ctx, uint8_t* pattern_index, uint8_t* pattern, uint8_t* row, uint64_t* samples);
-
-//** Get the latest time (in number of generated samples) when a particular instrument was triggered in any channel.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-uint64_t jar_xm_get_latest_trigger_of_instrument(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the latest time (in number of generated samples) when a particular sample was triggered in any channel.
-// * @note Instrument numbers go from 1 to jar_xm_get_number_of_instruments(...).
-// * @note Sample numbers go from 0 to jar_xm_get_nubmer_of_samples(...,instr)-1.
-uint64_t jar_xm_get_latest_trigger_of_sample(jar_xm_context_t* ctx, uint16_t instr, uint16_t sample);
-
-//** Get the latest time (in number of generated samples) when any instrument was triggered in a given channel.
-// * @note Channel numbers go from 1 to jar_xm_get_number_of_channels(...).
-uint64_t jar_xm_get_latest_trigger_of_channel(jar_xm_context_t* ctx, uint16_t);
-
-//** Get the number of remaining samples. Divide by 2 to get the number of individual LR data samples.
-// * @note This is the remaining number of samples before the loop starts module again, or halts if on last pass.
-// * @note This function is very slow and should only be run once, if at all.
-uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx);
-
-#ifdef __cplusplus
-}
-#endif
-//-------------------------------------------------------------------------------
-
-#ifdef JAR_XM_IMPLEMENTATION
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <string.h>
-
-#if JAR_XM_DEBUG            //JAR_XM_DEBUG defined as 0
-#include <stdio.h>
-#define DEBUG(fmt, ...) do {                                        \
-        fprintf(stderr, "%s(): " fmt "\n", __func__, __VA_ARGS__);    \
-        fflush(stderr);                                                \
-    } while(0)
-#else
-#define DEBUG(...)
-#endif
-
-#if jar_xm_BIG_ENDIAN
-#error "Big endian platforms are not yet supported, sorry"
-/* Make sure the compiler stops, even if #error is ignored */
-extern int __fail[-1];
-#endif
-
-/* ----- XM constants ----- */
-#define SAMPLE_NAME_LENGTH 22
-#define INSTRUMENT_NAME_LENGTH 22
-#define MODULE_NAME_LENGTH 20
-#define TRACKER_NAME_LENGTH 20
-#define PATTERN_ORDER_TABLE_LENGTH 256
-#define NUM_NOTES 96 // from 1 to 96, where 1 = C-0
-#define NUM_ENVELOPE_POINTS 12 // to be verified if 12 is the max
-#define MAX_NUM_ROWS 256
-
-#define jar_xm_SAMPLE_RAMPING_POINTS 8
-
-/* ----- Data types ----- */
-
-enum jar_xm_waveform_type_e {
-    jar_xm_SINE_WAVEFORM = 0,
-    jar_xm_RAMP_DOWN_WAVEFORM = 1,
-    jar_xm_SQUARE_WAVEFORM = 2,
-    jar_xm_RANDOM_WAVEFORM = 3,
-    jar_xm_RAMP_UP_WAVEFORM = 4,
-};
-typedef enum jar_xm_waveform_type_e jar_xm_waveform_type_t;
-
-enum jar_xm_loop_type_e {
-    jar_xm_NO_LOOP,
-    jar_xm_FORWARD_LOOP,
-    jar_xm_PING_PONG_LOOP,
-};
-typedef enum jar_xm_loop_type_e jar_xm_loop_type_t;
-
-enum jar_xm_frequency_type_e {
-    jar_xm_LINEAR_FREQUENCIES,
-    jar_xm_AMIGA_FREQUENCIES,
-};
-typedef enum jar_xm_frequency_type_e jar_xm_frequency_type_t;
-
-struct jar_xm_envelope_point_s {
-    uint16_t frame;
-    uint16_t value;
-};
-typedef struct jar_xm_envelope_point_s jar_xm_envelope_point_t;
-
-struct jar_xm_envelope_s {
-    jar_xm_envelope_point_t points[NUM_ENVELOPE_POINTS];
-    uint8_t num_points;
-    uint8_t sustain_point;
-    uint8_t loop_start_point;
-    uint8_t loop_end_point;
-    bool enabled;
-    bool sustain_enabled;
-    bool loop_enabled;
-};
-typedef struct jar_xm_envelope_s jar_xm_envelope_t;
-
-struct jar_xm_sample_s {
-    char name[SAMPLE_NAME_LENGTH + 1];
-    int8_t bits; /* Either 8 or 16 */
-    int8_t stereo;
-    uint32_t length;
-    uint32_t loop_start;
-    uint32_t loop_length;
-    uint32_t loop_end;
-    float volume;
-    int8_t finetune;
-    jar_xm_loop_type_t loop_type;
-    float panning;
-    int8_t relative_note;
-    uint64_t latest_trigger;
-
-    float* data;
- };
- typedef struct jar_xm_sample_s jar_xm_sample_t;
-
- struct jar_xm_instrument_s {
-     char name[INSTRUMENT_NAME_LENGTH + 1];
-     uint16_t num_samples;
-     uint8_t sample_of_notes[NUM_NOTES];
-     jar_xm_envelope_t volume_envelope;
-     jar_xm_envelope_t panning_envelope;
-     jar_xm_waveform_type_t vibrato_type;
-     uint8_t vibrato_sweep;
-     uint8_t vibrato_depth;
-     uint8_t vibrato_rate;
-     uint16_t volume_fadeout;
-     uint64_t latest_trigger;
-     bool muted;
-
-     jar_xm_sample_t* samples;
- };
- typedef struct jar_xm_instrument_s jar_xm_instrument_t;
-
- struct jar_xm_pattern_slot_s {
-     uint8_t note; /* 1-96, 97 = Key Off note */
-     uint8_t instrument; /* 1-128 */
-     uint8_t volume_column;
-     uint8_t effect_type;
-     uint8_t effect_param;
- };
- typedef struct jar_xm_pattern_slot_s jar_xm_pattern_slot_t;
-
- struct jar_xm_pattern_s {
-     uint16_t num_rows;
-     jar_xm_pattern_slot_t* slots; /* Array of size num_rows * num_channels */
- };
- typedef struct jar_xm_pattern_s jar_xm_pattern_t;
-
- struct jar_xm_module_s {
-     char name[MODULE_NAME_LENGTH + 1];
-     char trackername[TRACKER_NAME_LENGTH + 1];
-     uint16_t length;
-     uint16_t restart_position;
-     uint16_t num_channels;
-     uint16_t num_patterns;
-     uint16_t num_instruments;
-     uint16_t linear_interpolation;
-     uint16_t ramping;     
-     jar_xm_frequency_type_t frequency_type;
-     uint8_t pattern_table[PATTERN_ORDER_TABLE_LENGTH];
-
-     jar_xm_pattern_t* patterns;
-     jar_xm_instrument_t* instruments; /* Instrument 1 has index 0, instrument 2 has index 1, etc. */
- };
- typedef struct jar_xm_module_s jar_xm_module_t;
-
- struct jar_xm_channel_context_s {
-     float note;
-     float orig_note; /* The original note before effect modifications, as read in the pattern. */
-     jar_xm_instrument_t* instrument; /* Could be NULL */
-     jar_xm_sample_t* sample; /* Could be NULL */
-     jar_xm_pattern_slot_t* current;
-
-     float sample_position;
-     float period;
-     float frequency;
-     float step;
-     bool ping; /* For ping-pong samples: true is -->, false is <-- */
-
-     float volume; /* Ideally between 0 (muted) and 1 (loudest) */
-     float panning; /* Between 0 (left) and 1 (right); 0.5 is centered */
-
-     uint16_t autovibrato_ticks;
-
-     bool sustained;
-     float fadeout_volume;
-     float volume_envelope_volume;
-     float panning_envelope_panning;
-     uint16_t volume_envelope_frame_count;
-     uint16_t panning_envelope_frame_count;
-
-     float autovibrato_note_offset;
-
-     bool arp_in_progress;
-     uint8_t arp_note_offset;
-     uint8_t volume_slide_param;
-     uint8_t fine_volume_slide_param;
-     uint8_t global_volume_slide_param;
-     uint8_t panning_slide_param;
-     uint8_t portamento_up_param;
-     uint8_t portamento_down_param;
-     uint8_t fine_portamento_up_param;
-     uint8_t fine_portamento_down_param;
-     uint8_t extra_fine_portamento_up_param;
-     uint8_t extra_fine_portamento_down_param;
-     uint8_t tone_portamento_param;
-     float tone_portamento_target_period;
-     uint8_t multi_retrig_param;
-     uint8_t note_delay_param;
-     uint8_t pattern_loop_origin; /* Where to restart a E6y loop */
-     uint8_t pattern_loop_count; /* How many loop passes have been done */
-     bool vibrato_in_progress;
-     jar_xm_waveform_type_t vibrato_waveform;
-     bool vibrato_waveform_retrigger; /* True if a new note retriggers the waveform */
-     uint8_t vibrato_param;
-     uint16_t vibrato_ticks; /* Position in the waveform */
-     float vibrato_note_offset;
-     jar_xm_waveform_type_t tremolo_waveform;
-     bool tremolo_waveform_retrigger;
-     uint8_t tremolo_param;
-     uint8_t tremolo_ticks;
-     float tremolo_volume;
-     uint8_t tremor_param;
-     bool tremor_on;
-
-     uint64_t latest_trigger;
-     bool muted;
-
-     //* These values are updated at the end of each tick, to save a couple of float operations on every generated sample.
-     float target_panning;
-     float target_volume;
-
-     unsigned long frame_count;
-     float end_of_previous_sample_left[jar_xm_SAMPLE_RAMPING_POINTS];
-     float end_of_previous_sample_right[jar_xm_SAMPLE_RAMPING_POINTS];
-     float curr_left;
-     float curr_right;
-
-     float actual_panning;
-     float actual_volume;
- };
- typedef struct jar_xm_channel_context_s jar_xm_channel_context_t;
-
- struct jar_xm_context_s {
-     void* allocated_memory;
-     jar_xm_module_t module;
-     uint32_t rate;
-
-     uint16_t default_tempo; // Number of ticks per row
-     uint16_t default_bpm;
-     float default_global_volume;
-     
-     uint16_t tempo; // Number of ticks per row
-     uint16_t bpm;
-     float global_volume;
-
-     float volume_ramp; /* How much is a channel final volume allowed to change per sample; this is used to avoid abrubt volume changes which manifest as "clicks" in the generated sound. */
-     float panning_ramp; /* Same for panning. */
-
-     uint8_t current_table_index;
-     uint8_t current_row;
-     uint16_t current_tick; /* Can go below 255, with high tempo and a pattern delay */
-     float remaining_samples_in_tick;
-     uint64_t generated_samples;
-
-     bool position_jump;
-     bool pattern_break;
-     uint8_t jump_dest;
-     uint8_t jump_row;
-
-     uint16_t extra_ticks; /* Extra ticks to be played before going to the next row - Used for EEy effect */
-
-     uint8_t* row_loop_count; /* Array of size MAX_NUM_ROWS * module_length */
-     uint8_t loop_count;
-     uint8_t max_loop_count;
-
-     jar_xm_channel_context_t* channels;
-};
-
-#if JAR_XM_DEFENSIVE
-
-//** Check the module data for errors/inconsistencies.
-// * @returns 0 if everything looks OK. Module should be safe to load.
-int jar_xm_check_sanity_preload(const char*, size_t);
-
-//** Check a loaded module for errors/inconsistencies.
-// * @returns 0 if everything looks OK.
-int jar_xm_check_sanity_postload(jar_xm_context_t*);
-
-#endif
-
-//** Get the number of bytes needed to store the module data in a dynamically allocated blank context.
-// * Things that are dynamically allocated:
-// * - sample data
-// * - sample structures in instruments
-// * - pattern data
-// * - row loop count arrays
-// * - pattern structures in module
-// * - instrument structures in module
-// * - channel contexts
-// * - context structure itself
-// * @returns 0 if everything looks OK.
-size_t jar_xm_get_memory_needed_for_context(const char*, size_t);
-
-//** Populate the context from module data.
-// * @returns pointer to the memory pool
-char* jar_xm_load_module(jar_xm_context_t*, const char*, size_t, char*);
-
-int jar_xm_create_context(jar_xm_context_t** ctxp, const char* moddata, uint32_t rate) {
-    return jar_xm_create_context_safe(ctxp, moddata, SIZE_MAX, rate);
-}
-
-#define ALIGN(x, b) (((x) + ((b) - 1)) & ~((b) - 1))
-#define ALIGN_PTR(x, b) (void*)(((uintptr_t)(x) + ((b) - 1)) & ~((b) - 1))
-int jar_xm_create_context_safe(jar_xm_context_t** ctxp, const char* moddata, size_t moddata_length, uint32_t rate) {
-#if JAR_XM_DEFENSIVE
-    int ret;
-#endif
-    size_t bytes_needed;
-    char* mempool;
-    jar_xm_context_t* ctx;
-
-#if JAR_XM_DEFENSIVE
-    if((ret = jar_xm_check_sanity_preload(moddata, moddata_length))) {
-        DEBUG("jar_xm_check_sanity_preload() returned %i, module is not safe to load", ret);
-        return 1;
-    }
-#endif
-
-    bytes_needed = jar_xm_get_memory_needed_for_context(moddata, moddata_length);
-    mempool = JARXM_MALLOC(bytes_needed);
-    if(mempool == NULL && bytes_needed > 0) { /* JARXM_MALLOC() failed, trouble ahead */
-        DEBUG("call to JARXM_MALLOC() failed, returned %p", (void*)mempool);
-        return 2;
-    }
-
-    /* Initialize most of the fields to 0, 0.f, NULL or false depending on type */
-    memset(mempool, 0, bytes_needed);
-
-    ctx = (*ctxp = (jar_xm_context_t *)mempool);
-    ctx->allocated_memory = mempool; /* Keep original pointer for JARXM_FREE() */
-    mempool += sizeof(jar_xm_context_t);
-
-    ctx->rate = rate;
-    mempool = jar_xm_load_module(ctx, moddata, moddata_length, mempool);
-    mempool = ALIGN_PTR(mempool, 16);
-
-    ctx->channels = (jar_xm_channel_context_t*)mempool;
-    mempool += ctx->module.num_channels * sizeof(jar_xm_channel_context_t);
-    mempool = ALIGN_PTR(mempool, 16);
-
-    ctx->default_global_volume = 1.f;
-    ctx->global_volume = ctx->default_global_volume;
-
-    ctx->volume_ramp = (1.f / 128.f);
-    ctx->panning_ramp = (1.f / 128.f);
-
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t *ch = ctx->channels + i;
-        ch->ping = true;
-        ch->vibrato_waveform = jar_xm_SINE_WAVEFORM;
-        ch->vibrato_waveform_retrigger = true;
-        ch->tremolo_waveform = jar_xm_SINE_WAVEFORM;
-        ch->tremolo_waveform_retrigger = true;
-        ch->volume = ch->volume_envelope_volume = ch->fadeout_volume = 1.0f;
-        ch->panning = ch->panning_envelope_panning = .5f;
-        ch->actual_volume = .0f;
-        ch->actual_panning = .5f;
-    }
-
-    mempool = ALIGN_PTR(mempool, 16);
-    ctx->row_loop_count = (uint8_t *)mempool;
-    mempool += MAX_NUM_ROWS * sizeof(uint8_t);
-
-#if JAR_XM_DEFENSIVE
-    if((ret = jar_xm_check_sanity_postload(ctx))) {   DEBUG("jar_xm_check_sanity_postload() returned %i, module is not safe to play", ret);
-        jar_xm_free_context(ctx);
-        return 1;
-    }
-#endif
-
-    return 0;
-}
-
-void jar_xm_free_context(jar_xm_context_t *ctx) {
-    if (ctx != NULL) {   JARXM_FREE(ctx->allocated_memory); }
-}
-
-void jar_xm_set_max_loop_count(jar_xm_context_t *ctx, uint8_t loopcnt) {
-    ctx->max_loop_count = loopcnt;
-}
-
-uint8_t jar_xm_get_loop_count(jar_xm_context_t *ctx) {
-    return ctx->loop_count;
-}
-
-bool jar_xm_mute_channel(jar_xm_context_t *ctx, uint16_t channel, bool mute) {
-    bool old = ctx->channels[channel - 1].muted;
-    ctx->channels[channel - 1].muted = mute;
-    return old;
-}
-
-bool jar_xm_mute_instrument(jar_xm_context_t *ctx, uint16_t instr, bool mute) {
-    bool old = ctx->module.instruments[instr - 1].muted;
-    ctx->module.instruments[instr - 1].muted = mute;
-    return old;
-}
-
-const char* jar_xm_get_module_name(jar_xm_context_t *ctx) {
-    return ctx->module.name;
-}
-
-const char* jar_xm_get_tracker_name(jar_xm_context_t *ctx) {
-    return ctx->module.trackername;
-}
-
-uint16_t jar_xm_get_number_of_channels(jar_xm_context_t *ctx) {
-    return ctx->module.num_channels;
-}
-
-uint16_t jar_xm_get_module_length(jar_xm_context_t *ctx) {
-    return ctx->module.length;
-}
-
-uint16_t jar_xm_get_number_of_patterns(jar_xm_context_t *ctx) {
-    return ctx->module.num_patterns;
-}
-
-uint16_t jar_xm_get_number_of_rows(jar_xm_context_t *ctx, uint16_t pattern) {
-    return ctx->module.patterns[pattern].num_rows;
-}
-
-uint16_t jar_xm_get_number_of_instruments(jar_xm_context_t *ctx) {
-    return ctx->module.num_instruments;
-}
-
-uint16_t jar_xm_get_number_of_samples(jar_xm_context_t *ctx, uint16_t instrument) {
-    return ctx->module.instruments[instrument - 1].num_samples;
-}
-
-void jar_xm_get_playing_speed(jar_xm_context_t *ctx, uint16_t *bpm, uint16_t *tempo) {
-    if(bpm) *bpm = ctx->bpm;
-    if(tempo) *tempo = ctx->tempo;
-}
-
-void jar_xm_get_position(jar_xm_context_t *ctx, uint8_t *pattern_index, uint8_t *pattern, uint8_t *row, uint64_t *samples) {
-    if(pattern_index) *pattern_index = ctx->current_table_index;
-    if(pattern) *pattern = ctx->module.pattern_table[ctx->current_table_index];
-    if(row) *row = ctx->current_row;
-    if(samples) *samples = ctx->generated_samples;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_instrument(jar_xm_context_t *ctx, uint16_t instr) {
-    return ctx->module.instruments[instr - 1].latest_trigger;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_sample(jar_xm_context_t *ctx, uint16_t instr, uint16_t sample) {
-    return ctx->module.instruments[instr - 1].samples[sample].latest_trigger;
-}
-
-uint64_t jar_xm_get_latest_trigger_of_channel(jar_xm_context_t *ctx, uint16_t chn) {
-    return ctx->channels[chn - 1].latest_trigger;
-}
-
-//* .xm files are little-endian. (XXX: Are they really?)
-
-//* Bound reader macros.
-//* If we attempt to read the buffer out-of-bounds, pretend that the buffer is infinitely padded with zeroes.
-#define READ_U8(offset) (((offset) < moddata_length) ? (*(uint8_t*)(moddata + (offset))) : 0)
-#define READ_U16(offset) ((uint16_t)READ_U8(offset) | ((uint16_t)READ_U8((offset) + 1) << 8))
-#define READ_U32(offset) ((uint32_t)READ_U16(offset) | ((uint32_t)READ_U16((offset) + 2) << 16))
-#define READ_MEMCPY(ptr, offset, length) memcpy_pad(ptr, length, moddata, moddata_length, offset)
-
-static void memcpy_pad(void *dst, size_t dst_len, const void *src, size_t src_len, size_t offset) {
-    uint8_t *dst_c = dst;
-    const uint8_t *src_c = src;
-
-    /* how many bytes can be copied without overrunning `src` */
-    size_t copy_bytes = (src_len >= offset) ? (src_len - offset) : 0;
-    copy_bytes = copy_bytes > dst_len ? dst_len : copy_bytes;
-
-    memcpy(dst_c, src_c + offset, copy_bytes);
-    /* padded bytes */
-    memset(dst_c + copy_bytes, 0, dst_len - copy_bytes);
-}
-
-#if JAR_XM_DEFENSIVE
-
-int jar_xm_check_sanity_preload(const char* module, size_t module_length) {
-    if(module_length < 60) { return 4; }
-    if(memcmp("Extended Module: ", module, 17) != 0) { return 1; }
-    if(module[37] != 0x1A) { return 2; }
-    if(module[59] != 0x01 || module[58] != 0x04) { return 3; }  /* Not XM 1.04 */
-    return 0;
-}
-
-int jar_xm_check_sanity_postload(jar_xm_context_t* ctx) {
-    /* Check the POT */
-    for(uint8_t i = 0; i < ctx->module.length; ++i) {
-        if(ctx->module.pattern_table[i] >= ctx->module.num_patterns) {
-            if(i+1 == ctx->module.length && ctx->module.length > 1) {
-                DEBUG("trimming invalid POT at pos %X", i);
-                --ctx->module.length;             
-            } else {
-                DEBUG("module has invalid POT, pos %X references nonexistent pattern %X", i, ctx->module.pattern_table[i]);
-                return 1;
-            }
-        }
-    }
-
-    return 0;
-}
-
-#endif
-
-size_t jar_xm_get_memory_needed_for_context(const char* moddata, size_t moddata_length) {
-    size_t memory_needed = 0;
-    size_t offset = 60; /* 60 = Skip the first header */
-    uint16_t num_channels;
-    uint16_t num_patterns;
-    uint16_t num_instruments;
-
-    /* Read the module header */
-    num_channels = READ_U16(offset + 8);
-    num_patterns = READ_U16(offset + 10);
-    memory_needed += num_patterns * sizeof(jar_xm_pattern_t);
-    memory_needed  = ALIGN(memory_needed, 16);
-    num_instruments = READ_U16(offset + 12);
-    memory_needed += num_instruments * sizeof(jar_xm_instrument_t);
-    memory_needed  = ALIGN(memory_needed, 16);
-    memory_needed += MAX_NUM_ROWS * READ_U16(offset + 4) * sizeof(uint8_t); /* Module length */
-
-    offset += READ_U32(offset); /* Header size */
-
-    /* Read pattern headers */
-    for(uint16_t i = 0; i < num_patterns; ++i) {
-        uint16_t num_rows;
-        num_rows = READ_U16(offset + 5);
-        memory_needed += num_rows * num_channels * sizeof(jar_xm_pattern_slot_t);
-        offset += READ_U32(offset) + READ_U16(offset + 7); /* Pattern header length + packed pattern data size */
-    }
-    memory_needed  = ALIGN(memory_needed, 16);
-
-    /* Read instrument headers */
-    for(uint16_t i = 0; i < num_instruments; ++i) {
-        uint16_t num_samples;
-        uint32_t sample_header_size = 0;
-        uint32_t sample_size_aggregate = 0;
-        num_samples = READ_U16(offset + 27);
-        memory_needed += num_samples * sizeof(jar_xm_sample_t);
-        if(num_samples > 0) { sample_header_size = READ_U32(offset + 29); }
-
-        offset += READ_U32(offset);  /* Instrument header size */
-        for(uint16_t j = 0; j < num_samples; ++j) {
-            uint32_t sample_size;
-            uint8_t flags;
-            sample_size = READ_U32(offset);
-            flags = READ_U8(offset + 14);
-            sample_size_aggregate += sample_size;
-
-            if(flags & (1 << 4)) {  /* 16 bit sample */
-                memory_needed += sample_size * (sizeof(float) >> 1);
-            } else {  /* 8 bit sample */
-                memory_needed += sample_size * sizeof(float);
-            }
-            offset += sample_header_size;
-        }
-        offset += sample_size_aggregate;
-    }
-
-    memory_needed += num_channels * sizeof(jar_xm_channel_context_t);
-    memory_needed += sizeof(jar_xm_context_t);
-    return memory_needed;
-}
-
-char* jar_xm_load_module(jar_xm_context_t* ctx, const char* moddata, size_t moddata_length, char* mempool) {
-    size_t offset = 0;
-    jar_xm_module_t* mod = &(ctx->module);
-
-    /* Read XM header */
-    READ_MEMCPY(mod->name, offset + 17, MODULE_NAME_LENGTH);
-    READ_MEMCPY(mod->trackername, offset + 38, TRACKER_NAME_LENGTH);
-    offset += 60;
-
-    /* Read module header */
-    uint32_t header_size = READ_U32(offset);
-    mod->length = READ_U16(offset + 4);
-    mod->restart_position = READ_U16(offset + 6);
-    mod->num_channels = READ_U16(offset + 8);
-    mod->num_patterns = READ_U16(offset + 10);
-    mod->num_instruments = READ_U16(offset + 12);
-    mod->patterns = (jar_xm_pattern_t*)mempool;
-    mod->linear_interpolation = 0; // Linear interpolation can be set after loading
-    mod->ramping = 1; // ramping can be set after loading
-    mempool += mod->num_patterns * sizeof(jar_xm_pattern_t);
-    mempool = ALIGN_PTR(mempool, 16);
-    mod->instruments = (jar_xm_instrument_t*)mempool;
-    mempool += mod->num_instruments * sizeof(jar_xm_instrument_t);
-    mempool = ALIGN_PTR(mempool, 16);
-    uint16_t flags = READ_U32(offset + 14);
-    mod->frequency_type = (flags & (1 << 0)) ? jar_xm_LINEAR_FREQUENCIES : jar_xm_AMIGA_FREQUENCIES;
-    ctx->default_tempo = READ_U16(offset + 16);
-    ctx->default_bpm = READ_U16(offset + 18);
-    ctx->tempo =ctx->default_tempo;
-    ctx->bpm = ctx->default_bpm;
-
-    READ_MEMCPY(mod->pattern_table, offset + 20, PATTERN_ORDER_TABLE_LENGTH);
-    offset += header_size;
-
-    /* Read patterns */
-    for(uint16_t i = 0; i < mod->num_patterns; ++i) {
-        uint16_t packed_patterndata_size = READ_U16(offset + 7);
-        jar_xm_pattern_t* pat = mod->patterns + i;
-        pat->num_rows = READ_U16(offset + 5);
-        pat->slots = (jar_xm_pattern_slot_t*)mempool;
-        mempool += mod->num_channels * pat->num_rows * sizeof(jar_xm_pattern_slot_t);
-        offset += READ_U32(offset); /* Pattern header length */
-        
-        if(packed_patterndata_size == 0) {    /* No pattern data is present */
-            memset(pat->slots, 0, sizeof(jar_xm_pattern_slot_t) * pat->num_rows * mod->num_channels);
-        } else {
-            /* This isn't your typical for loop */
-            for(uint16_t j = 0, k = 0; j < packed_patterndata_size; ++k) {
-                uint8_t note = READ_U8(offset + j);
-                jar_xm_pattern_slot_t* slot = pat->slots + k;
-                if(note & (1 << 7)) {
-                    /* MSB is set, this is a compressed packet */
-                    ++j;
-                    if(note & (1 << 0)) {    /* Note follows */
-                        slot->note = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->note = 0;
-                    }
-                    if(note & (1 << 1)) {    /* Instrument follows */
-                        slot->instrument = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->instrument = 0;
-                    }
-                    if(note & (1 << 2)) {    /* Volume column follows */
-                        slot->volume_column = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->volume_column = 0;
-                    }
-                    if(note & (1 << 3)) {    /* Effect follows */
-                        slot->effect_type = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->effect_type = 0;
-                    }
-                    if(note & (1 << 4)) {    /* Effect parameter follows */
-                        slot->effect_param = READ_U8(offset + j);
-                        ++j;
-                    } else {
-                        slot->effect_param = 0;
-                    }
-                } else {    /* Uncompressed packet */
-                    slot->note = note;
-                    slot->instrument = READ_U8(offset + j + 1);
-                    slot->volume_column = READ_U8(offset + j + 2);
-                    slot->effect_type = READ_U8(offset + j + 3);
-                    slot->effect_param = READ_U8(offset + j + 4);
-                    j += 5;
-                }
-            }
-        }
-
-        offset += packed_patterndata_size;
-    }
-    mempool = ALIGN_PTR(mempool, 16);
-
-    /* Read instruments */
-    for(uint16_t i = 0; i < ctx->module.num_instruments; ++i) {
-        uint32_t sample_header_size = 0;
-        jar_xm_instrument_t* instr = mod->instruments + i;
-
-        READ_MEMCPY(instr->name, offset + 4, INSTRUMENT_NAME_LENGTH);
-        instr->num_samples = READ_U16(offset + 27);
-
-        if(instr->num_samples > 0) {
-            /* Read extra header properties */
-            sample_header_size = READ_U32(offset + 29);
-            READ_MEMCPY(instr->sample_of_notes, offset + 33, NUM_NOTES);
-
-            instr->volume_envelope.num_points = READ_U8(offset + 225);
-            instr->panning_envelope.num_points = READ_U8(offset + 226);
-
-            for(uint8_t j = 0; j < instr->volume_envelope.num_points; ++j) {
-                instr->volume_envelope.points[j].frame = READ_U16(offset + 129 + 4 * j);
-                instr->volume_envelope.points[j].value = READ_U16(offset + 129 + 4 * j + 2);
-            }
-
-            for(uint8_t j = 0; j < instr->panning_envelope.num_points; ++j) {
-                instr->panning_envelope.points[j].frame = READ_U16(offset + 177 + 4 * j);
-                instr->panning_envelope.points[j].value = READ_U16(offset + 177 + 4 * j + 2);
-            }
-
-            instr->volume_envelope.sustain_point = READ_U8(offset + 227);
-            instr->volume_envelope.loop_start_point = READ_U8(offset + 228);
-            instr->volume_envelope.loop_end_point = READ_U8(offset + 229);
-            instr->panning_envelope.sustain_point = READ_U8(offset + 230);
-            instr->panning_envelope.loop_start_point = READ_U8(offset + 231);
-            instr->panning_envelope.loop_end_point = READ_U8(offset + 232);
-
-            uint8_t flags = READ_U8(offset + 233);
-            instr->volume_envelope.enabled = flags & (1 << 0);
-            instr->volume_envelope.sustain_enabled = flags & (1 << 1);
-            instr->volume_envelope.loop_enabled = flags & (1 << 2);
-
-            flags = READ_U8(offset + 234);
-            instr->panning_envelope.enabled = flags & (1 << 0);
-            instr->panning_envelope.sustain_enabled = flags & (1 << 1);
-            instr->panning_envelope.loop_enabled = flags & (1 << 2);
-            instr->vibrato_type = READ_U8(offset + 235);
-            if(instr->vibrato_type == 2) {
-                instr->vibrato_type = 1;
-            } else if(instr->vibrato_type == 1) {
-                instr->vibrato_type = 2;
-            }
-            instr->vibrato_sweep = READ_U8(offset + 236);
-            instr->vibrato_depth = READ_U8(offset + 237);
-            instr->vibrato_rate = READ_U8(offset + 238);
-            instr->volume_fadeout = READ_U16(offset + 239);
-            instr->samples = (jar_xm_sample_t*)mempool;
-            mempool += instr->num_samples * sizeof(jar_xm_sample_t);
-        } else {
-            instr->samples = NULL;
-        }
-
-        /* Instrument header size */
-        offset += READ_U32(offset);
-
-        for(int j = 0; j < instr->num_samples; ++j) {
-            /* Read sample header */
-            jar_xm_sample_t* sample = instr->samples + j;
-
-            sample->length = READ_U32(offset);
-            sample->loop_start = READ_U32(offset + 4);
-            sample->loop_length = READ_U32(offset + 8);
-            sample->loop_end = sample->loop_start + sample->loop_length;
-            sample->volume = (float)(READ_U8(offset + 12) << 2) / 256.f;
-            if (sample->volume > 1.0f) {sample->volume = 1.f;};
-            sample->finetune = (int8_t)READ_U8(offset + 13);
-
-            uint8_t flags = READ_U8(offset + 14);
-            switch (flags & 3) {
-            case 2:
-            case 3:
-                sample->loop_type = jar_xm_PING_PONG_LOOP;
-            case 1:
-                sample->loop_type = jar_xm_FORWARD_LOOP;
-                break;
-            default:
-                sample->loop_type = jar_xm_NO_LOOP;
-                break;
-            };
-            sample->bits = (flags & 0x10) ? 16 : 8;
-            sample->stereo = (flags & 0x20) ? 1 : 0;
-            sample->panning = (float)READ_U8(offset + 15) / 255.f;
-            sample->relative_note = (int8_t)READ_U8(offset + 16);
-            READ_MEMCPY(sample->name, 18, SAMPLE_NAME_LENGTH);
-            sample->data = (float*)mempool;
-            if(sample->bits == 16) {
-                /* 16 bit sample */
-                mempool += sample->length * (sizeof(float) >> 1);
-                sample->loop_start >>= 1;
-                sample->loop_length >>= 1;
-                sample->loop_end >>= 1;
-                sample->length >>= 1;
-            } else {
-                /* 8 bit sample */
-                mempool += sample->length * sizeof(float);
-            }
-            // Adjust loop points to reflect half of the reported length (stereo)
-            if (sample->stereo && sample->loop_type != jar_xm_NO_LOOP) {
-                div_t lstart = div(READ_U32(offset + 4), 2);
-                sample->loop_start = lstart.quot;
-                div_t llength = div(READ_U32(offset + 8), 2);
-                sample->loop_length = llength.quot;
-                sample->loop_end = sample->loop_start + sample->loop_length;
-            };
-
-            offset += sample_header_size;
-        }
-
-        // Read all samples and convert them to float values
-        for(int j = 0; j < instr->num_samples; ++j) {
-            /* Read sample data */
-            jar_xm_sample_t* sample = instr->samples + j;
-            int length = sample->length;
-            if (sample->stereo) {
-                // Since it is stereo, we cut the sample in half (treated as single channel)
-                div_t result = div(sample->length, 2);
-                if(sample->bits == 16) {
-                    int16_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        if (k == result.quot) { v = 0;};
-                        v = v + (int16_t)READ_U16(offset + (k << 1));
-                        sample->data[k] = (float) v / 32768.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length << 1;
-                } else {
-                    int8_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        if (k == result.quot) { v = 0;};
-                        v = v + (int8_t)READ_U8(offset + k);
-                        sample->data[k] = (float)v  / 128.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length;
-                };
-                sample->length = result.quot;
-            } else {
-                if(sample->bits == 16) {
-                    int16_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        v = v + (int16_t)READ_U16(offset + (k << 1));
-                        sample->data[k] = (float) v / 32768.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length << 1;
-                } else {
-                    int8_t v = 0;
-                    for(int k = 0; k < length; ++k) {
-                        v = v + (int8_t)READ_U8(offset + k);
-                        sample->data[k] = (float)v  / 128.f ;//* sign;
-                        if(sample->data[k] < -1.0)  {sample->data[k] = -1.0;}  else if(sample->data[k] > 1.0)  {sample->data[k] = 1.0;};
-                    }
-                    offset += sample->length;
-                }
-            }
-        };
-    };
-    return mempool;
-};
-
-//-------------------------------------------------------------------------------
-//THE FOLLOWING IS FOR PLAYING
-static float jar_xm_waveform(jar_xm_waveform_type_t, uint8_t);
-static void jar_xm_autovibrato(jar_xm_context_t*, jar_xm_channel_context_t*);
-static void jar_xm_vibrato(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_tremolo(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_arpeggio(jar_xm_context_t*, jar_xm_channel_context_t*, uint8_t, uint16_t);
-static void jar_xm_tone_portamento(jar_xm_context_t*, jar_xm_channel_context_t*);
-static void jar_xm_pitch_slide(jar_xm_context_t*, jar_xm_channel_context_t*, float);
-static void jar_xm_panning_slide(jar_xm_channel_context_t*, uint8_t);
-static void jar_xm_volume_slide(jar_xm_channel_context_t*, uint8_t);
-
-static float jar_xm_envelope_lerp(jar_xm_envelope_point_t*, jar_xm_envelope_point_t*, uint16_t);
-static void jar_xm_envelope_tick(jar_xm_channel_context_t*, jar_xm_envelope_t*, uint16_t*, float*);
-static void jar_xm_envelopes(jar_xm_channel_context_t*);
-
-static float jar_xm_linear_period(float);
-static float jar_xm_linear_frequency(float);
-static float jar_xm_amiga_period(float);
-static float jar_xm_amiga_frequency(float);
-static float jar_xm_period(jar_xm_context_t*, float);
-static float jar_xm_frequency(jar_xm_context_t*, float, float);
-static void jar_xm_update_frequency(jar_xm_context_t*, jar_xm_channel_context_t*);
-
-static void jar_xm_handle_note_and_instrument(jar_xm_context_t*, jar_xm_channel_context_t*, jar_xm_pattern_slot_t*);
-static void jar_xm_trigger_note(jar_xm_context_t*, jar_xm_channel_context_t*, unsigned int flags);
-static void jar_xm_cut_note(jar_xm_channel_context_t*);
-static void jar_xm_key_off(jar_xm_channel_context_t*);
-
-static void jar_xm_post_pattern_change(jar_xm_context_t*);
-static void jar_xm_row(jar_xm_context_t*);
-static void jar_xm_tick(jar_xm_context_t*);
-
-static void jar_xm_next_of_sample(jar_xm_context_t*, jar_xm_channel_context_t*, int);
-static void jar_xm_mixdown(jar_xm_context_t*, float*, float*);
-
-#define jar_xm_TRIGGER_KEEP_VOLUME (1 << 0)
-#define jar_xm_TRIGGER_KEEP_PERIOD (1 << 1)
-#define jar_xm_TRIGGER_KEEP_SAMPLE_POSITION (1 << 2)
-
-                                            // C-2, C#2, D-2, D#2, E-2, F-2, F#2, G-2, G#2, A-2, A#2, B-2, C-3
-static const uint16_t amiga_frequencies[] = { 1712, 1616, 1525, 1440, 1357, 1281, 1209, 1141, 1077, 1017,  961,  907, 856 };
-
-                                            // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
-static const float multi_retrig_add[] = { 0.f, -1.f, -2.f, -4.f, -8.f, -16.f, 0.f, 0.f, 0.f, 1.f, 2.f, 4.f, 8.f, 16.f, 0.f, 0.f };
-
-                                            // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f
-static const float multi_retrig_multiply[] = { 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, .6666667f, .5f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.5f, 2.f };
-
-#define jar_xm_CLAMP_UP1F(vol, limit) do {            \
-        if((vol) > (limit)) (vol) = (limit);    \
-    } while(0)
-#define jar_xm_CLAMP_UP(vol) jar_xm_CLAMP_UP1F((vol), 1.f)
-
-#define jar_xm_CLAMP_DOWN1F(vol, limit) do {        \
-        if((vol) < (limit)) (vol) = (limit);    \
-    } while(0)
-#define jar_xm_CLAMP_DOWN(vol) jar_xm_CLAMP_DOWN1F((vol), .0f)
-
-#define jar_xm_CLAMP2F(vol, up, down) do {            \
-        if((vol) > (up)) (vol) = (up);            \
-        else if((vol) < (down)) (vol) = (down); \
-    } while(0)
-#define jar_xm_CLAMP(vol) jar_xm_CLAMP2F((vol), 1.f, .0f)
-
-#define jar_xm_SLIDE_TOWARDS(val, goal, incr) do {        \
-        if((val) > (goal)) {                        \
-            (val) -= (incr);                        \
-            jar_xm_CLAMP_DOWN1F((val), (goal));            \
-        } else if((val) < (goal)) {                    \
-            (val) += (incr);                        \
-            jar_xm_CLAMP_UP1F((val), (goal));            \
-        }                                            \
-    } while(0)
-
-#define jar_xm_LERP(u, v, t) ((u) + (t) * ((v) - (u)))
-#define jar_xm_INVERSE_LERP(u, v, lerp) (((lerp) - (u)) / ((v) - (u)))
-
-#define HAS_TONE_PORTAMENTO(s) ((s)->effect_type == 3 \
-                                 || (s)->effect_type == 5 \
-                                 || ((s)->volume_column >> 4) == 0xF)
-#define HAS_ARPEGGIO(s) ((s)->effect_type == 0 \
-                          && (s)->effect_param != 0)
-#define HAS_VIBRATO(s) ((s)->effect_type == 4 \
-                         || (s)->effect_param == 6 \
-                         || ((s)->volume_column >> 4) == 0xB)
-#define NOTE_IS_VALID(n) ((n) > 0 && (n) < 97)
-#define NOTE_OFF 97
-
-static float jar_xm_waveform(jar_xm_waveform_type_t waveform, uint8_t step) {
-    static unsigned int next_rand = 24492;
-    step %= 0x40;
-    switch(waveform) {
-    case jar_xm_SINE_WAVEFORM: /* No SIN() table used, direct calculation. */
-        return -sinf(2.f * 3.141592f * (float)step / (float)0x40);
-    case jar_xm_RAMP_DOWN_WAVEFORM: /* Ramp down: 1.0f when step = 0; -1.0f when step = 0x40 */
-        return (float)(0x20 - step) / 0x20;
-    case jar_xm_SQUARE_WAVEFORM: /* Square with a 50% duty */
-        return (step >= 0x20) ? 1.f : -1.f;
-    case jar_xm_RANDOM_WAVEFORM: /* Use the POSIX.1-2001 example, just to be deterministic across different machines */
-        next_rand = next_rand * 1103515245 + 12345;
-        return (float)((next_rand >> 16) & 0x7FFF) / (float)0x4000 - 1.f;
-    case jar_xm_RAMP_UP_WAVEFORM: /* Ramp up: -1.f when step = 0; 1.f when step = 0x40 */
-        return (float)(step - 0x20) / 0x20;
-    default:
-        break;
-    }
-    return .0f;
-}
-
-static void jar_xm_autovibrato(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    if(ch->instrument == NULL || ch->instrument->vibrato_depth == 0) return;
-    jar_xm_instrument_t* instr = ch->instrument;
-    float sweep = 1.f;
-    if(ch->autovibrato_ticks < instr->vibrato_sweep) { sweep = jar_xm_LERP(0.f, 1.f, (float)ch->autovibrato_ticks / (float)instr->vibrato_sweep); }
-    unsigned int step = ((ch->autovibrato_ticks++) * instr->vibrato_rate) >> 2;
-    ch->autovibrato_note_offset = .25f * jar_xm_waveform(instr->vibrato_type, step) * (float)instr->vibrato_depth / (float)0xF * sweep;
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_vibrato(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t pos) {
-    unsigned int step = pos * (param >> 4);
-    ch->vibrato_note_offset = 2.f * jar_xm_waveform(ch->vibrato_waveform, step) * (float)(param & 0x0F) / (float)0xF;
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_tremolo(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t pos) {
-    unsigned int step = pos * (param >> 4);
-    ch->tremolo_volume = -1.f * jar_xm_waveform(ch->tremolo_waveform, step) * (float)(param & 0x0F) / (float)0xF;
-}
-
-static void jar_xm_arpeggio(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, uint8_t param, uint16_t tick) {
-    switch(tick % 3) {
-    case 0:
-        ch->arp_in_progress = false;
-        ch->arp_note_offset = 0;
-        break;
-    case 2:
-        ch->arp_in_progress = true;
-        ch->arp_note_offset = param >> 4;
-        break;
-    case 1:
-        ch->arp_in_progress = true;
-        ch->arp_note_offset = param & 0x0F;
-        break;
-    }
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_tone_portamento(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    /* 3xx called without a note, wait until we get an actual target note. */
-    if(ch->tone_portamento_target_period == 0.f) return;  /* no value, exit */
-    if(ch->period != ch->tone_portamento_target_period) {
-        jar_xm_SLIDE_TOWARDS(ch->period, ch->tone_portamento_target_period, (ctx->module.frequency_type == jar_xm_LINEAR_FREQUENCIES ? 4.f : 1.f) * ch->tone_portamento_param);
-        jar_xm_update_frequency(ctx, ch);
-    }
-}
-
-static void jar_xm_pitch_slide(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, float period_offset) {
-    /* Don't ask about the 4.f coefficient. I found mention of it nowhere. Found by earâ„¢. */
-    if(ctx->module.frequency_type == jar_xm_LINEAR_FREQUENCIES) {period_offset *= 4.f; }
-    ch->period += period_offset;
-    jar_xm_CLAMP_DOWN(ch->period);
-    /* XXX: upper bound of period ? */
-    jar_xm_update_frequency(ctx, ch);
-}
-
-static void jar_xm_panning_slide(jar_xm_channel_context_t* ch, uint8_t rawval) {
-    if (rawval & 0xF0) {ch->panning += (float)((rawval & 0xF0 )>> 4) / (float)0xFF;};
-    if (rawval & 0x0F) {ch->panning -= (float)(rawval & 0x0F) / (float)0xFF;};
-};
-
-static void jar_xm_volume_slide(jar_xm_channel_context_t* ch, uint8_t rawval) {
-    if (rawval & 0xF0) {ch->volume += (float)((rawval & 0xF0) >> 4) / (float)0x40;};
-    if (rawval & 0x0F) {ch->volume -= (float)(rawval & 0x0F) / (float)0x40;};
-};
-
-static float jar_xm_envelope_lerp(jar_xm_envelope_point_t* a, jar_xm_envelope_point_t* b, uint16_t pos) {
-    /* Linear interpolation between two envelope points */
-    if(pos <= a->frame) return a->value;
-    else if(pos >= b->frame) return b->value;
-    else {
-        float p = (float)(pos - a->frame) / (float)(b->frame - a->frame);
-        return a->value * (1 - p) + b->value * p;
-    }
-}
-
-static void jar_xm_post_pattern_change(jar_xm_context_t* ctx) {
-    /* Loop if necessary */
-    if(ctx->current_table_index >= ctx->module.length) {
-        ctx->current_table_index = ctx->module.restart_position;
-        ctx->tempo =ctx->default_tempo; // reset to file default value 
-        ctx->bpm = ctx->default_bpm; // reset to file default value
-        ctx->global_volume = ctx->default_global_volume; // reset to file default value
-    }
-}
-
-static float jar_xm_linear_period(float note) {
-    return 7680.f - note * 64.f;
-}
-
-static float jar_xm_linear_frequency(float period) {
-    return 8363.f * powf(2.f, (4608.f - period) / 768.f);
-}
-
-static float jar_xm_amiga_period(float note) {
-    unsigned int intnote = note;
-    uint8_t a = intnote % 12;
-    int8_t octave = note / 12.f - 2;
-    uint16_t p1 = amiga_frequencies[a], p2 = amiga_frequencies[a + 1];
-    if(octave > 0) {
-        p1 >>= octave;
-        p2 >>= octave;
-    } else if(octave < 0) {
-        p1 <<= -octave;
-        p2 <<= -octave;
-    }
-    return jar_xm_LERP(p1, p2, note - intnote);
-}
-
-static float jar_xm_amiga_frequency(float period) {
-    if(period == .0f) return .0f;
-    return 7093789.2f / (period * 2.f); /* This is the PAL value. (we could use the NTSC value also) */
-}
-
-static float jar_xm_period(jar_xm_context_t* ctx, float note) {
-    switch(ctx->module.frequency_type) {
-    case jar_xm_LINEAR_FREQUENCIES:
-        return jar_xm_linear_period(note);
-    case jar_xm_AMIGA_FREQUENCIES:
-        return jar_xm_amiga_period(note);
-    }
-    return .0f;
-}
-
-static float jar_xm_frequency(jar_xm_context_t* ctx, float period, float note_offset) {
-    switch(ctx->module.frequency_type) {
-    case jar_xm_LINEAR_FREQUENCIES:
-        return jar_xm_linear_frequency(period - 64.f * note_offset);
-    case jar_xm_AMIGA_FREQUENCIES:
-        if(note_offset == 0) { return jar_xm_amiga_frequency(period); };
-        int8_t octave;
-        float  note;
-        uint16_t p1, p2;
-        uint8_t a = octave = 0;
-
-        /* Find the octave of the current period */
-        if(period > amiga_frequencies[0]) {
-            --octave;
-            while(period > (amiga_frequencies[0] << -octave)) --octave;
-        } else if(period < amiga_frequencies[12]) {
-            ++octave;
-            while(period < (amiga_frequencies[12] >> octave)) ++octave;
-        }
-
-        /* Find the smallest note closest to the current period */
-        for(uint8_t i = 0; i < 12; ++i) {
-            p1 = amiga_frequencies[i], p2 = amiga_frequencies[i + 1];
-            if(octave > 0) {
-                p1 >>= octave;
-                p2 >>= octave;
-            } else if(octave < 0) {
-                p1 <<= (-octave);
-                p2 <<= (-octave);
-            }
-            if(p2 <= period && period <= p1) {
-                a = i;
-                break;
-            }
-        }
-        if(JAR_XM_DEBUG && (p1 < period || p2 > period)) { DEBUG("%i <= %f <= %i should hold but doesn't, this is a bug", p2, period, p1); }
-        note = 12.f * (octave + 2) + a + jar_xm_INVERSE_LERP(p1, p2, period);
-        return jar_xm_amiga_frequency(jar_xm_amiga_period(note + note_offset));
-    }
-
-    return .0f;
-}
-
-static void jar_xm_update_frequency(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch) {
-    ch->frequency = jar_xm_frequency( ctx, ch->period, (ch->arp_note_offset > 0 ? ch->arp_note_offset : (  ch->vibrato_note_offset + ch->autovibrato_note_offset ))  );
-    ch->step = ch->frequency / ctx->rate;
-}
-
-static void jar_xm_handle_note_and_instrument(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, jar_xm_pattern_slot_t* s) {
-    jar_xm_module_t* mod = &(ctx->module);
-    if(s->instrument > 0) {
-        if(HAS_TONE_PORTAMENTO(ch->current) && ch->instrument != NULL && ch->sample != NULL) {  /* Tone portamento in effect */
-            jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_PERIOD | jar_xm_TRIGGER_KEEP_SAMPLE_POSITION);
-        } else if(s->instrument > ctx->module.num_instruments) {    /* Invalid instrument, Cut current note */
-            jar_xm_cut_note(ch);
-            ch->instrument = NULL;
-            ch->sample = NULL;
-        } else {
-            ch->instrument = ctx->module.instruments + (s->instrument - 1);
-            if(s->note == 0 && ch->sample != NULL) {  /* Ghost instrument, trigger note */
-                /* Sample position is kept, but envelopes are reset */
-                jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_SAMPLE_POSITION);
-            }
-        }
-    }
-
-    if(NOTE_IS_VALID(s->note)) {
-        // note value is s->note -1
-        jar_xm_instrument_t* instr = ch->instrument;
-        if(HAS_TONE_PORTAMENTO(ch->current) && instr != NULL && ch->sample != NULL) {
-            /* Tone portamento in effect */
-            ch->note = s->note + ch->sample->relative_note + ch->sample->finetune / 128.f - 1.f;
-            ch->tone_portamento_target_period = jar_xm_period(ctx, ch->note);
-        } else if(instr == NULL || ch->instrument->num_samples == 0) {   /* Issue on instrument */
-            jar_xm_cut_note(ch);
-        } else {
-            if(instr->sample_of_notes[s->note - 1] < instr->num_samples) {
-                if (mod->ramping) {
-                    for(int i = 0; i < jar_xm_SAMPLE_RAMPING_POINTS; ++i) {
-                        jar_xm_next_of_sample(ctx, ch, i);
-                    }
-                    ch->frame_count = 0;
-                };
-                ch->sample = instr->samples + instr->sample_of_notes[s->note - 1];
-                ch->orig_note = ch->note = s->note + ch->sample->relative_note + ch->sample->finetune / 128.f - 1.f;
-                if(s->instrument > 0) {
-                    jar_xm_trigger_note(ctx, ch, 0);
-                } else {  /* Ghost note: keep old volume */
-                    jar_xm_trigger_note(ctx, ch, jar_xm_TRIGGER_KEEP_VOLUME);
-                }
-            } else {
-                jar_xm_cut_note(ch);
-            }
-        }
-    } else if(s->note == NOTE_OFF) {
-        jar_xm_key_off(ch);
-    }
-
-    // Interpret Effect column
-    switch(s->effect_type) {
-    case 1: /* 1xx: Portamento up */
-        if(s->effect_param > 0) {    ch->portamento_up_param = s->effect_param; }
-        break;
-    case 2: /* 2xx: Portamento down */
-        if(s->effect_param > 0) {    ch->portamento_down_param = s->effect_param; }
-        break;
-    case 3: /* 3xx: Tone portamento */
-        if(s->effect_param > 0) {    ch->tone_portamento_param = s->effect_param; }
-        break;
-    case 4: /* 4xy: Vibrato */
-        if(s->effect_param & 0x0F) { ch->vibrato_param = (ch->vibrato_param & 0xF0) | (s->effect_param & 0x0F); }  /* Set vibrato depth */
-        if(s->effect_param >> 4) { ch->vibrato_param = (s->effect_param & 0xF0) | (ch->vibrato_param & 0x0F); }   /* Set vibrato speed */
-        break;
-    case 5: /* 5xy: Tone portamento + Volume slide */
-        if(s->effect_param > 0) {  ch->volume_slide_param = s->effect_param; }
-        break;
-    case 6: /* 6xy: Vibrato + Volume slide */
-        if(s->effect_param > 0) {    ch->volume_slide_param = s->effect_param; }
-        break;
-    case 7: /* 7xy: Tremolo */
-        if(s->effect_param & 0x0F) { ch->tremolo_param = (ch->tremolo_param & 0xF0) | (s->effect_param & 0x0F); } /* Set tremolo depth */
-        if(s->effect_param >> 4) { ch->tremolo_param = (s->effect_param & 0xF0) | (ch->tremolo_param & 0x0F); }  /* Set tremolo speed */
-        break;
-    case 8: /* 8xx: Set panning */
-        ch->panning = (float)s->effect_param / 255.f;
-        break;
-    case 9: /* 9xx: Sample offset */
-        if(ch->sample != 0) { //&& NOTE_IS_VALID(s->note)) {
-            uint32_t final_offset = s->effect_param << (ch->sample->bits == 16 ? 7 : 8);
-            switch (ch->sample->loop_type) {
-            case jar_xm_NO_LOOP:
-                if(final_offset >= ch->sample->length) { /* Pretend the sample dosen't loop and is done playing */
-                    ch->sample_position = -1;
-                } else {
-                    ch->sample_position = final_offset;
-                }
-                break;
-            case jar_xm_FORWARD_LOOP:
-                if (final_offset >= ch->sample->loop_end) {
-                    ch->sample_position -= ch->sample->loop_length;
-                } else if(final_offset >= ch->sample->length) {
-                    ch->sample_position = ch->sample->loop_start;
-                } else {
-                    ch->sample_position = final_offset;
-                }
-                break;
-            case jar_xm_PING_PONG_LOOP:
-                if(final_offset >= ch->sample->loop_end) {
-                    ch->ping = false;
-                    ch->sample_position = (ch->sample->loop_end << 1) - ch->sample_position;
-                } else if(final_offset >= ch->sample->length) {
-                    ch->ping = false;
-                    ch->sample_position -= ch->sample->length - 1;
-                } else {
-                    ch->sample_position = final_offset;
-                };
-                break;
-            }
-        }
-        break;
-    case 0xA: /* Axy: Volume slide */
-        if(s->effect_param > 0) {    ch->volume_slide_param = s->effect_param; }
-        break;
-    case 0xB: /* Bxx: Position jump */
-        if(s->effect_param < ctx->module.length) {
-            ctx->position_jump = true;
-            ctx->jump_dest = s->effect_param;
-        }
-        break;
-    case 0xC: /* Cxx: Set volume */
-        ch->volume = (float)((s->effect_param > 0x40) ? 0x40 : s->effect_param) / (float)0x40;
-        break;
-    case 0xD: /* Dxx: Pattern break */
-        /* Jump after playing this line */
-        ctx->pattern_break = true;
-        ctx->jump_row = (s->effect_param >> 4) * 10 + (s->effect_param & 0x0F);
-        break;
-    case 0xE: /* EXy: Extended command */
-        switch(s->effect_param >> 4) {
-        case 1: /* E1y: Fine portamento up */
-            if(s->effect_param & 0x0F) {    ch->fine_portamento_up_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, -ch->fine_portamento_up_param);
-            break;
-        case 2: /* E2y: Fine portamento down */
-            if(s->effect_param & 0x0F) {    ch->fine_portamento_down_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, ch->fine_portamento_down_param);
-            break;
-        case 4: /* E4y: Set vibrato control */
-            ch->vibrato_waveform = s->effect_param & 3;
-            ch->vibrato_waveform_retrigger = !((s->effect_param >> 2) & 1);
-            break;
-        case 5: /* E5y: Set finetune */
-            if(NOTE_IS_VALID(ch->current->note) && ch->sample != NULL) {
-                ch->note = ch->current->note + ch->sample->relative_note + (float)(((s->effect_param & 0x0F) - 8) << 4) / 128.f - 1.f;
-                ch->period = jar_xm_period(ctx, ch->note);
-                jar_xm_update_frequency(ctx, ch);
-            }
-            break;
-        case 6: /* E6y: Pattern loop */
-            if(s->effect_param & 0x0F) {
-                if((s->effect_param & 0x0F) == ch->pattern_loop_count) {   /* Loop is over */
-                    ch->pattern_loop_count = 0;
-                    ctx->position_jump = false;
-                } else {    /* Jump to the beginning of the loop */
-                    ch->pattern_loop_count++;
-                    ctx->position_jump = true;
-                    ctx->jump_row = ch->pattern_loop_origin;
-                    ctx->jump_dest = ctx->current_table_index;
-                }
-            } else {
-                ch->pattern_loop_origin = ctx->current_row; /* Set loop start point */
-                ctx->jump_row = ch->pattern_loop_origin;    /* Replicate FT2 E60 bug */
-            }
-            break;
-        case 7: /* E7y: Set tremolo control */
-            ch->tremolo_waveform = s->effect_param & 3;
-            ch->tremolo_waveform_retrigger = !((s->effect_param >> 2) & 1);
-            break;
-        case 0xA: /* EAy: Fine volume slide up */
-            if(s->effect_param & 0x0F) {   ch->fine_volume_slide_param = s->effect_param & 0x0F; }
-            jar_xm_volume_slide(ch, ch->fine_volume_slide_param << 4);
-            break;
-        case 0xB: /* EBy: Fine volume slide down */
-            if(s->effect_param & 0x0F) {   ch->fine_volume_slide_param = s->effect_param & 0x0F; }
-            jar_xm_volume_slide(ch, ch->fine_volume_slide_param);
-            break;
-        case 0xD: /* EDy: Note delay */
-            /* XXX: figure this out better. EDx triggers the note even when there no note and no instrument. But ED0 acts like like a ghost note, EDx (x â‰  0) does not. */
-            if(s->note == 0 && s->instrument == 0) {
-                unsigned int flags = jar_xm_TRIGGER_KEEP_VOLUME;
-                if(ch->current->effect_param & 0x0F) {
-                    ch->note = ch->orig_note;
-                    jar_xm_trigger_note(ctx, ch, flags);
-                } else {
-                    jar_xm_trigger_note(ctx, ch, flags | jar_xm_TRIGGER_KEEP_PERIOD | jar_xm_TRIGGER_KEEP_SAMPLE_POSITION );
-                }
-            }
-            break;
-
-        case 0xE: /* EEy: Pattern delay */
-            ctx->extra_ticks = (ch->current->effect_param & 0x0F) * ctx->tempo;
-            break;
-        default:
-            break;
-        }
-        break;
-
-    case 0xF: /* Fxx: Set tempo/BPM */
-        if(s->effect_param > 0) {
-            if(s->effect_param <= 0x1F) {  // First 32 possible values adjust the ticks (goes into tempo)
-                ctx->tempo = s->effect_param;
-            } else {                       //32 and greater values adjust the BPM
-                ctx->bpm = s->effect_param;
-            }
-        }
-        break;
-
-    case 16: /* Gxx: Set global volume */
-        ctx->global_volume = (float)((s->effect_param > 0x40) ? 0x40 : s->effect_param) / (float)0x40;
-        break;
-    case 17: /* Hxy: Global volume slide */
-        if(s->effect_param > 0) {    ch->global_volume_slide_param = s->effect_param; }
-        break;
-    case 21: /* Lxx: Set envelope position */
-        ch->volume_envelope_frame_count = s->effect_param;
-        ch->panning_envelope_frame_count = s->effect_param;
-        break;
-    case 25: /* Pxy: Panning slide */
-        if(s->effect_param > 0) {   ch->panning_slide_param = s->effect_param; }
-        break;
-    case 27: /* Rxy: Multi retrig note */
-        if(s->effect_param > 0) {
-            if((s->effect_param >> 4) == 0) {    /* Keep previous x value */
-                ch->multi_retrig_param = (ch->multi_retrig_param & 0xF0) | (s->effect_param & 0x0F);
-            } else {
-                ch->multi_retrig_param = s->effect_param;
-            }
-        }
-        break;
-    case 29: /* Txy: Tremor */
-        if(s->effect_param > 0) { ch->tremor_param = s->effect_param; }  /* Tremor x and y params are not separately kept in memory, unlike Rxy */
-        break;
-    case 33: /* Xxy: Extra stuff */
-        switch(s->effect_param >> 4) {
-        case 1: /* X1y: Extra fine portamento up */
-            if(s->effect_param & 0x0F) {    ch->extra_fine_portamento_up_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, -1.0f * ch->extra_fine_portamento_up_param);
-            break;
-        case 2: /* X2y: Extra fine portamento down */
-            if(s->effect_param & 0x0F) {   ch->extra_fine_portamento_down_param = s->effect_param & 0x0F; }
-            jar_xm_pitch_slide(ctx, ch, ch->extra_fine_portamento_down_param);
-            break;
-        default:
-            break;
-        }
-        break;
-    default:
-        break;
-    }
-}
-
-static void jar_xm_trigger_note(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, unsigned int flags) {
-    if (!(flags & jar_xm_TRIGGER_KEEP_SAMPLE_POSITION)) {
-        ch->sample_position = 0.f;
-        ch->ping = true;
-    };
-    
-    if (!(flags & jar_xm_TRIGGER_KEEP_VOLUME)) {
-       if(ch->sample != NULL) {
-        ch->volume = ch->sample->volume;
-        };
-    };
-    ch->panning = ch->sample->panning;
-    ch->sustained = true;
-    ch->fadeout_volume = ch->volume_envelope_volume = 1.0f;
-    ch->panning_envelope_panning = .5f;
-    ch->volume_envelope_frame_count = ch->panning_envelope_frame_count = 0;
-    ch->vibrato_note_offset = 0.f;
-    ch->tremolo_volume = 0.f;
-    ch->tremor_on = false;
-    ch->autovibrato_ticks = 0;
-
-    if(ch->vibrato_waveform_retrigger) { ch->vibrato_ticks = 0; } /* XXX: should the waveform itself also be reset to sine? */
-    if(ch->tremolo_waveform_retrigger) { ch->tremolo_ticks = 0; }
-    if(!(flags & jar_xm_TRIGGER_KEEP_PERIOD)) {
-        ch->period = jar_xm_period(ctx, ch->note);
-        jar_xm_update_frequency(ctx, ch);
-    }
-    ch->latest_trigger = ctx->generated_samples;
-    if(ch->instrument != NULL) { ch->instrument->latest_trigger = ctx->generated_samples; }
-    if(ch->sample != NULL) {     ch->sample->latest_trigger = ctx->generated_samples; }
-}
-
-static void jar_xm_cut_note(jar_xm_channel_context_t* ch) {
-    ch->volume = .0f; /* NB: this is not the same as Key Off */
-//    ch->curr_left = .0f;
-//    ch->curr_right = .0f;
-}
-
-static void jar_xm_key_off(jar_xm_channel_context_t* ch) {
-    ch->sustained = false; /* Key Off */
-    if(ch->instrument == NULL || !ch->instrument->volume_envelope.enabled) { jar_xm_cut_note(ch); } /* If no volume envelope is used, also cut the note */
-}
-
-static void jar_xm_row(jar_xm_context_t* ctx) {
-    if(ctx->position_jump) {
-        ctx->current_table_index = ctx->jump_dest;
-        ctx->current_row = ctx->jump_row;
-        ctx->position_jump = false;
-        ctx->pattern_break = false;
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    } else if(ctx->pattern_break) {
-        ctx->current_table_index++;
-        ctx->current_row = ctx->jump_row;
-        ctx->pattern_break = false;
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    }
-    jar_xm_pattern_t* cur = ctx->module.patterns + ctx->module.pattern_table[ctx->current_table_index];
-    bool in_a_loop = false;
-
-    /* Read notes information for all channels into temporary pattern slot */
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_pattern_slot_t* s = cur->slots + ctx->current_row * ctx->module.num_channels + i;
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        ch->current = s;
-        // If there is no note delay effect (0xED) then...
-        if(s->effect_type != 0xE || s->effect_param >> 4 != 0xD) {
-            //********** Process the channel slot information **********
-            jar_xm_handle_note_and_instrument(ctx, ch, s);
-        } else {
-            // read the note delay information
-            ch->note_delay_param = s->effect_param & 0x0F;
-        }
-        if(!in_a_loop && ch->pattern_loop_count > 0) {
-            // clarify if in a loop or not
-            in_a_loop = true;
-        }
-    }
-
-    if(!in_a_loop) {
-        /* No E6y loop is in effect (or we are in the first pass) */
-        ctx->loop_count = (ctx->row_loop_count[MAX_NUM_ROWS * ctx->current_table_index + ctx->current_row]++);
-    }
-    
-    /// Move to next row
-    ctx->current_row++; /* uint8 warning: can increment from 255 to 0, in which case it is still necessary to go the next pattern. */
-    if (!ctx->position_jump && !ctx->pattern_break && (ctx->current_row >= cur->num_rows || ctx->current_row == 0)) {
-        ctx->current_table_index++;
-        ctx->current_row = ctx->jump_row; /* This will be 0 most of the time, except when E60 is used */
-        ctx->jump_row = 0;
-        jar_xm_post_pattern_change(ctx);
-    }
-}
-
-static void jar_xm_envelope_tick(jar_xm_channel_context_t *ch, jar_xm_envelope_t *env, uint16_t *counter, float *outval) {
-    if(env->num_points < 2) {
-        if(env->num_points == 1) {
-            *outval = (float)env->points[0].value / (float)0x40;
-            if(*outval > 1) { *outval = 1; };
-        } else {;
-            return;
-        };
-    } else {
-        if(env->loop_enabled) {
-            uint16_t loop_start = env->points[env->loop_start_point].frame;
-            uint16_t loop_end = env->points[env->loop_end_point].frame;
-            uint16_t loop_length = loop_end - loop_start;
-            if(*counter >= loop_end) { *counter -= loop_length; };
-        };
-        for(uint8_t j = 0; j < (env->num_points - 1); ++j) {
-            if(env->points[j].frame <= *counter && env->points[j+1].frame >= *counter) {
-                *outval = jar_xm_envelope_lerp(env->points + j, env->points + j + 1, *counter) / (float)0x40;
-                break;
-            };
-        };
-        /* Make sure it is safe to increment frame count */
-        if(!ch->sustained || !env->sustain_enabled || *counter != env->points[env->sustain_point].frame) { (*counter)++; };
-    };
-};
-
-static void jar_xm_envelopes(jar_xm_channel_context_t *ch) {
-    if(ch->instrument != NULL) {
-        if(ch->instrument->volume_envelope.enabled) {
-            if(!ch->sustained) {
-                ch->fadeout_volume -= (float)ch->instrument->volume_fadeout / 65536.f;
-                jar_xm_CLAMP_DOWN(ch->fadeout_volume);
-            };
-            jar_xm_envelope_tick(ch, &(ch->instrument->volume_envelope), &(ch->volume_envelope_frame_count), &(ch->volume_envelope_volume));
-        };
-        if(ch->instrument->panning_envelope.enabled) {
-            jar_xm_envelope_tick(ch, &(ch->instrument->panning_envelope), &(ch->panning_envelope_frame_count), &(ch->panning_envelope_panning));
-        };
-    };
-};
-
-static void jar_xm_tick(jar_xm_context_t* ctx) {
-    if(ctx->current_tick == 0) {
-        jar_xm_row(ctx);        // We have processed all ticks and we run the row
-    }
-    
-    jar_xm_module_t* mod = &(ctx->module);
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        jar_xm_envelopes(ch);
-        jar_xm_autovibrato(ctx, ch);
-        if(ch->arp_in_progress && !HAS_ARPEGGIO(ch->current)) {
-            ch->arp_in_progress = false;
-            ch->arp_note_offset = 0;
-            jar_xm_update_frequency(ctx, ch);
-        }
-        if(ch->vibrato_in_progress && !HAS_VIBRATO(ch->current)) {
-            ch->vibrato_in_progress = false;
-            ch->vibrato_note_offset = 0.f;
-            jar_xm_update_frequency(ctx, ch);
-        }
-
-        // Effects in volumne column mostly handled on a per tick basis
-        switch(ch->current->volume_column & 0xF0) {
-        case 0x50: // Checks for volume = 64
-            if(ch->current->volume_column != 0x50) break;
-        case 0x10: // Set volume 0-15
-        case 0x20: // Set volume 16-32
-        case 0x30: // Set volume 32-48
-        case 0x40: // Set volume 48-64
-            ch->volume = (float)(ch->current->volume_column - 16) / 64.0f;
-            break;
-        case 0x60: // Volume slide down
-            jar_xm_volume_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0x70: // Volume slide up
-            jar_xm_volume_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0x80: // Fine volume slide down
-            jar_xm_volume_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0x90: // Fine volume slide up
-            jar_xm_volume_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0xA0: // Set vibrato speed
-            ch->vibrato_param = (ch->vibrato_param & 0x0F) | ((ch->current->volume_column & 0x0F) << 4);
-            break;
-        case 0xB0: // Vibrato
-            ch->vibrato_in_progress = false;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            break;
-        case 0xC0: // Set panning
-            if(!ctx->current_tick ) {
-                ch->panning = (float)(ch->current->volume_column & 0x0F) / 15.0f;
-            }
-            break;
-        case 0xD0: // Panning slide left
-            jar_xm_panning_slide(ch, ch->current->volume_column & 0x0F);
-            break;
-        case 0xE0: // Panning slide right
-            jar_xm_panning_slide(ch, ch->current->volume_column << 4);
-            break;
-        case 0xF0: // Tone portamento
-            if(!ctx->current_tick ) {
-                if(ch->current->volume_column & 0x0F) { ch->tone_portamento_param = ((ch->current->volume_column & 0x0F) << 4) | (ch->current->volume_column & 0x0F); }
-            };
-            jar_xm_tone_portamento(ctx, ch);
-            break;
-        default:
-            break;
-        }
-
-        // Only some standard effects handled on a per tick basis
-        // see jar_xm_handle_note_and_instrument for all effects handling on a per row basis
-        switch(ch->current->effect_type) {
-        case 0: /* 0xy: Arpeggio */
-            if(ch->current->effect_param > 0) {
-                char arp_offset = ctx->tempo % 3;
-                switch(arp_offset) {
-                case 2: /* 0 -> x -> 0 -> y -> x -> â€¦ */
-                    if(ctx->current_tick == 1) {
-                        ch->arp_in_progress = true;
-                        ch->arp_note_offset = ch->current->effect_param >> 4;
-                        jar_xm_update_frequency(ctx, ch);
-                        break;
-                    }
-                    /* No break here, this is intended */
-                case 1: /* 0 -> 0 -> y -> x -> â€¦ */
-                    if(ctx->current_tick == 0) {
-                        ch->arp_in_progress = false;
-                        ch->arp_note_offset = 0;
-                        jar_xm_update_frequency(ctx, ch);
-                        break;
-                    }
-                    /* No break here, this is intended */
-                case 0: /* 0 -> y -> x -> â€¦ */
-                    jar_xm_arpeggio(ctx, ch, ch->current->effect_param, ctx->current_tick - arp_offset);
-                default:
-                    break;
-                }
-            }
-            break;
-
-        case 1: /* 1xx: Portamento up */
-            if(ctx->current_tick == 0) break;
-            jar_xm_pitch_slide(ctx, ch, -ch->portamento_up_param);
-            break;
-        case 2: /* 2xx: Portamento down */
-            if(ctx->current_tick == 0) break;
-            jar_xm_pitch_slide(ctx, ch, ch->portamento_down_param);
-            break;
-        case 3: /* 3xx: Tone portamento */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tone_portamento(ctx, ch);
-            break;
-        case 4: /* 4xy: Vibrato */
-            if(ctx->current_tick == 0) break;
-            ch->vibrato_in_progress = true;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            break;
-        case 5: /* 5xy: Tone portamento + Volume slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tone_portamento(ctx, ch);
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 6: /* 6xy: Vibrato + Volume slide */
-            if(ctx->current_tick == 0) break;
-            ch->vibrato_in_progress = true;
-            jar_xm_vibrato(ctx, ch, ch->vibrato_param, ch->vibrato_ticks++);
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 7: /* 7xy: Tremolo */
-            if(ctx->current_tick == 0) break;
-            jar_xm_tremolo(ctx, ch, ch->tremolo_param, ch->tremolo_ticks++);
-            break;
-        case 8: /* 8xy: Set panning */
-            break;
-        case 9: /* 9xy: Sample offset */
-            break;
-        case 0xA: /* Axy: Volume slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_volume_slide(ch, ch->volume_slide_param);
-            break;
-        case 0xE: /* EXy: Extended command */
-            switch(ch->current->effect_param >> 4) {
-            case 0x9: /* E9y: Retrigger note */
-                if(ctx->current_tick != 0 && ch->current->effect_param & 0x0F) {
-                    if(!(ctx->current_tick % (ch->current->effect_param & 0x0F))) {
-                        jar_xm_trigger_note(ctx, ch, 0);
-                        jar_xm_envelopes(ch);
-                    }
-                }
-                break;
-            case 0xC: /* ECy: Note cut */
-                if((ch->current->effect_param & 0x0F) == ctx->current_tick) {
-                    jar_xm_cut_note(ch);
-                }
-                break;
-            case 0xD: /* EDy: Note delay */
-                if(ch->note_delay_param == ctx->current_tick) {
-                    jar_xm_handle_note_and_instrument(ctx, ch, ch->current);
-                    jar_xm_envelopes(ch);
-                }
-                break;
-            default:
-                break;
-            }
-            break;
-        case 16: /* Fxy: Set tempo/BPM */
-            break;        
-        case 17: /* Hxy: Global volume slide */
-            if(ctx->current_tick == 0) break;
-            if((ch->global_volume_slide_param & 0xF0) && (ch->global_volume_slide_param & 0x0F)) { break; }; /* Invalid state */
-            if(ch->global_volume_slide_param & 0xF0) {    /* Global slide up */
-                float f = (float)(ch->global_volume_slide_param >> 4) / (float)0x40;
-                ctx->global_volume += f;
-                jar_xm_CLAMP_UP(ctx->global_volume);
-            } else {                                      /* Global slide down */
-                float f = (float)(ch->global_volume_slide_param & 0x0F) / (float)0x40;
-                ctx->global_volume -= f;
-                jar_xm_CLAMP_DOWN(ctx->global_volume);
-            };
-            break;
-
-        case 20: /* Kxx: Key off */
-            if(ctx->current_tick == ch->current->effect_param) {     jar_xm_key_off(ch); };
-            break;
-        case 21: /* Lxx: Set envelope position */
-            break;        
-        case 25: /* Pxy: Panning slide */
-            if(ctx->current_tick == 0) break;
-            jar_xm_panning_slide(ch, ch->panning_slide_param);
-            break;
-        case 27: /* Rxy: Multi retrig note */
-            if(ctx->current_tick == 0) break;
-            if(((ch->multi_retrig_param) & 0x0F) == 0) break;
-            if((ctx->current_tick % (ch->multi_retrig_param & 0x0F)) == 0) {
-                float v = ch->volume * multi_retrig_multiply[ch->multi_retrig_param >> 4]
-                    + multi_retrig_add[ch->multi_retrig_param >> 4];
-                jar_xm_CLAMP(v);
-                jar_xm_trigger_note(ctx, ch, 0);
-                ch->volume = v;
-            };
-            break;
-
-        case 29: /* Txy: Tremor */
-            if(ctx->current_tick == 0) break;
-            ch->tremor_on = ( (ctx->current_tick - 1) % ((ch->tremor_param >> 4) + (ch->tremor_param & 0x0F) + 2) > (ch->tremor_param >> 4)  );
-            break;
-        default:
-            break;
-        };
-
-        float panning, volume;
-        panning = ch->panning + (ch->panning_envelope_panning - .5f) * (.5f - fabs(ch->panning - .5f)) * 2.0f;
-        if(ch->tremor_on) {
-            volume = .0f;
-        } else {
-            volume = ch->volume + ch->tremolo_volume;
-            jar_xm_CLAMP(volume);
-            volume *= ch->fadeout_volume * ch->volume_envelope_volume;
-        };
-
-        if (mod->ramping) {
-            ch->target_panning = panning;
-            ch->target_volume = volume;
-        } else {
-            ch->actual_panning = panning;
-            ch->actual_volume = volume;
-        };
-    };
-
-    ctx->current_tick++; // ok so we understand that ticks increment within the row
-    if(ctx->current_tick >= ctx->tempo + ctx->extra_ticks) {
-        // This means it reached the end of the row and we reset
-        ctx->current_tick = 0;
-        ctx->extra_ticks = 0;
-    };
-
-    // Number of ticks / second = BPM * 0.4
-    ctx->remaining_samples_in_tick += (float)ctx->rate / ((float)ctx->bpm * 0.4f);
-};
-
-static void jar_xm_next_of_sample(jar_xm_context_t* ctx, jar_xm_channel_context_t* ch, int previous) {
-    jar_xm_module_t* mod = &(ctx->module);
-
-//    ch->curr_left = 0.f;
-//    ch->curr_right = 0.f;
-    if(ch->instrument == NULL || ch->sample == NULL || ch->sample_position < 0) {
-        ch->curr_left = 0.f;
-        ch->curr_right = 0.f;
-        if (mod->ramping) {
-            if (ch->frame_count < jar_xm_SAMPLE_RAMPING_POINTS) {
-                if (previous > -1) {
-                    ch->end_of_previous_sample_left[previous] = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], ch->curr_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                    ch->end_of_previous_sample_right[previous] = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], ch->curr_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                } else {
-                    ch->curr_left = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], ch->curr_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                    ch->curr_right = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], ch->curr_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                };
-            };
-        };
-        return;
-    };
-    if(ch->sample->length == 0) {
-        return;
-    };
-
-    float t = 0.f;
-    uint32_t b = 0;
-    if(mod->linear_interpolation) {
-        b = ch->sample_position + 1;
-        t = ch->sample_position - (uint32_t)ch->sample_position; /* Cheaper than fmodf(., 1.f) */
-    };
-
-    float u_left, u_right;
-    u_left = ch->sample->data[(uint32_t)ch->sample_position];
-    if (ch->sample->stereo) {
-        u_right = ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length];
-    } else {
-        u_right = u_left;
-    };
-    float v_left = 0.f, v_right = 0.f;
-    switch(ch->sample->loop_type) {
-    case jar_xm_NO_LOOP:
-        if(mod->linear_interpolation) {
-            v_left = (b < ch->sample->length) ? ch->sample->data[b] : .0f;
-            if (ch->sample->stereo) {
-                v_right = (b < ch->sample->length) ? ch->sample->data[b + ch->sample->length] : .0f;
-            } else {
-                v_right = v_left;
-            };
-        };
-        ch->sample_position += ch->step;
-        if(ch->sample_position >= ch->sample->length) { ch->sample_position = -1; } // stop playing this sample
-        break;
-    case jar_xm_FORWARD_LOOP:
-        if(mod->linear_interpolation) {
-            v_left = ch->sample->data[ (b == ch->sample->loop_end) ? ch->sample->loop_start : b ];
-            if (ch->sample->stereo) {
-                v_right = ch->sample->data[ (b == ch->sample->loop_end) ? ch->sample->loop_start + ch->sample->length : b + ch->sample->length];
-            } else {
-                v_right = v_left;
-            };
-        };
-        ch->sample_position += ch->step;
-        if (ch->sample_position >= ch->sample->loop_end) {
-            ch->sample_position -= ch->sample->loop_length;
-        };
-        if(ch->sample_position >= ch->sample->length) {
-            ch->sample_position = ch->sample->loop_start;
-        };
-        break;
-    case jar_xm_PING_PONG_LOOP:
-        if(ch->ping) {
-            if(mod->linear_interpolation) {
-                v_left = (b >= ch->sample->loop_end) ? ch->sample->data[(uint32_t)ch->sample_position] : ch->sample->data[b];
-                if (ch->sample->stereo) {
-                    v_right = (b >= ch->sample->loop_end) ? ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length] : ch->sample->data[b + ch->sample->length];
-                } else {
-                    v_right = v_left;
-                };
-            };
-            ch->sample_position += ch->step;
-            if(ch->sample_position >= ch->sample->loop_end) {
-                ch->ping = false;
-                ch->sample_position = (ch->sample->loop_end << 1) - ch->sample_position;
-            };
-            if(ch->sample_position >= ch->sample->length) {
-                ch->ping = false;
-                ch->sample_position -= ch->sample->length - 1;
-            };
-        } else {
-            if(mod->linear_interpolation) {
-                v_left = u_left;
-                v_right = u_right;
-                u_left = (b == 1 || b - 2 <= ch->sample->loop_start) ? ch->sample->data[(uint32_t)ch->sample_position] : ch->sample->data[b - 2];
-                if (ch->sample->stereo) {
-                    u_right = (b == 1 || b - 2 <= ch->sample->loop_start) ? ch->sample->data[(uint32_t)ch->sample_position + ch->sample->length] : ch->sample->data[b + ch->sample->length - 2];
-                } else {
-                    u_right = u_left;
-                };
-            };
-            ch->sample_position -= ch->step;
-            if(ch->sample_position <= ch->sample->loop_start) {
-                ch->ping = true;
-                ch->sample_position = (ch->sample->loop_start << 1) - ch->sample_position;
-            };
-            if (ch->sample_position <= .0f) {
-                ch->ping = true;
-                ch->sample_position = .0f;
-            };
-        };
-        break;
-
-    default:
-        v_left = .0f;
-        v_right = .0f;
-        break;
-    };
-
-    float endval_left = mod->linear_interpolation ? jar_xm_LERP(u_left, v_left, t) : u_left;
-    float endval_right = mod->linear_interpolation ? jar_xm_LERP(u_right, v_right, t) : u_right;
-
-    if (mod->ramping) {
-        if(ch->frame_count < jar_xm_SAMPLE_RAMPING_POINTS) {
-            /* Smoothly transition between old and new sample. */
-            if (previous > -1) {
-                ch->end_of_previous_sample_left[previous] = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], endval_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                ch->end_of_previous_sample_right[previous] = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], endval_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-            } else {
-                ch->curr_left = jar_xm_LERP(ch->end_of_previous_sample_left[ch->frame_count], endval_left, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-                ch->curr_right = jar_xm_LERP(ch->end_of_previous_sample_right[ch->frame_count], endval_right, (float)ch->frame_count / (float)jar_xm_SAMPLE_RAMPING_POINTS);
-            };
-        };
-    };
-
-    if (previous > -1) {
-        ch->end_of_previous_sample_left[previous] = endval_left;
-        ch->end_of_previous_sample_right[previous] = endval_right;
-    } else {
-        ch->curr_left = endval_left;
-        ch->curr_right = endval_right;
-    };
-};
-
-// gather all channel audio into stereo float
-static void jar_xm_mixdown(jar_xm_context_t* ctx, float* left, float* right) {
-    jar_xm_module_t* mod = &(ctx->module);
-    
-    if(ctx->remaining_samples_in_tick <= 0) {
-        jar_xm_tick(ctx);
-    };
-    ctx->remaining_samples_in_tick--;
-    *left = 0.f;
-    *right = 0.f;
-    if(ctx->max_loop_count > 0 && ctx->loop_count > ctx->max_loop_count) { return; }
-
-    for(uint8_t i = 0; i < ctx->module.num_channels; ++i) {
-        jar_xm_channel_context_t* ch = ctx->channels + i;
-        if(ch->instrument != NULL && ch->sample != NULL && ch->sample_position >= 0) {
-            jar_xm_next_of_sample(ctx, ch, -1);
-            if(!ch->muted && !ch->instrument->muted) {
-                *left  += ch->curr_left * ch->actual_volume * (1.f - ch->actual_panning);
-                *right += ch->curr_right * ch->actual_volume * ch->actual_panning;
-            };
-
-            if (mod->ramping) {
-                ch->frame_count++;
-                jar_xm_SLIDE_TOWARDS(ch->actual_volume, ch->target_volume, ctx->volume_ramp);
-                jar_xm_SLIDE_TOWARDS(ch->actual_panning, ch->target_panning, ctx->panning_ramp);
-            };
-        };
-    };
-    if (ctx->global_volume != 1.0f) {
-        *left *= ctx->global_volume;
-        *right *= ctx->global_volume;
-    };
-
-    // experimental
-//    float counter = (float)ctx->generated_samples * 0.0001f
-//    *left = tan(&left + sin(counter));
-//    *right = tan(&right + cos(counter));
-
-    // apply brick wall limiter when audio goes beyond bounderies
-    if(*left < -1.0)  {*left = -1.0;}  else if(*left > 1.0)  {*left = 1.0;};
-    if(*right < -1.0) {*right = -1.0;} else if(*right > 1.0) {*right = 1.0;};   
-};
-
-void jar_xm_generate_samples(jar_xm_context_t* ctx, float* output, size_t numsamples) {
-    if(ctx && output) {
-        ctx->generated_samples += numsamples;
-        for(size_t i = 0; i < numsamples; i++) {
-            jar_xm_mixdown(ctx, output + (2 * i), output + (2 * i + 1));
-        };
-    };
-};
-
-uint64_t jar_xm_get_remaining_samples(jar_xm_context_t* ctx) {
-    uint64_t total = 0;
-    uint8_t currentLoopCount = jar_xm_get_loop_count(ctx);
-    jar_xm_set_max_loop_count(ctx, 0);
-    while(jar_xm_get_loop_count(ctx) == currentLoopCount) {
-        total += ctx->remaining_samples_in_tick;
-        ctx->remaining_samples_in_tick = 0;
-        jar_xm_tick(ctx);
-    }
-    ctx->loop_count = currentLoopCount;
-    return total;
-}
-
-//--------------------------------------------
-//FILE LOADER - TODO - NEEDS TO BE CLEANED UP
-//--------------------------------------------
-#undef DEBUG
-#define DEBUG(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-    } while(0)
-
-#define DEBUG_ERR(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-    } while(0)
-
-#define FATAL(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-        exit(1); \
-    } while(0)
-
-#define FATAL_ERR(...) do {      \
-        fprintf(stderr, __VA_ARGS__); \
-        fflush(stderr); \
-        exit(1); \
-    } while(0)
-
-
-int jar_xm_create_context_from_file(jar_xm_context_t** ctx, uint32_t rate, const char* filename) {
-    FILE* xmf;
-    int size;
-    int ret;
-
-    xmf = fopen(filename, "rb");
-    if(xmf == NULL) {
-        DEBUG_ERR("Could not open input file");
-        *ctx = NULL;
-        return 3;
-    }
-
-    fseek(xmf, 0, SEEK_END);
-    size = ftell(xmf);
-    rewind(xmf);
-    if(size == -1) {
-        fclose(xmf);
-        DEBUG_ERR("fseek() failed");
-        *ctx = NULL;
-        return 4;
-    }
-
-    char* data = JARXM_MALLOC(size + 1);
-    if(!data || fread(data, 1, size, xmf) < size) {
-        fclose(xmf);
-        DEBUG_ERR(data ? "fread() failed" : "JARXM_MALLOC() failed");
-        JARXM_FREE(data);
-        *ctx = NULL;
-        return 5;
-    }
-
-    fclose(xmf);
-
-    ret = jar_xm_create_context_safe(ctx, data, size, rate);
-    JARXM_FREE(data);
-
-    switch(ret) {
-    case 0:
-        break;
-    case 1:        DEBUG("could not create context: module is not sane\n");
-        *ctx = NULL;
-        return 1;
-        break;
-    case 2:        FATAL("could not create context: malloc failed\n");
-        return 2;
-        break;
-    default:       FATAL("could not create context: unknown error\n");
-        return 6;
-        break;
-    }
-    
-    return 0;
-}
-
-// not part of the original library
-void jar_xm_reset(jar_xm_context_t* ctx) {
-    for (uint16_t i = 0; i < jar_xm_get_number_of_channels(ctx); i++) {
-        jar_xm_cut_note(&ctx->channels[i]);
-    }
-    ctx->current_row = 0;
-    ctx->current_table_index = 0;
-    ctx->current_tick = 0;
-    ctx->tempo =ctx->default_tempo; // reset to file default value 
-    ctx->bpm = ctx->default_bpm; // reset to file default value
-    ctx->global_volume = ctx->default_global_volume; // reset to file default value
-}
-
-
-void jar_xm_flip_linear_interpolation(jar_xm_context_t* ctx) {
-    if (ctx->module.linear_interpolation) {
-        ctx->module.linear_interpolation = 0;
-    } else {
-        ctx->module.linear_interpolation = 1;
-    }
-}
-
-void jar_xm_table_jump(jar_xm_context_t* ctx, int table_ptr) {
-    for (uint16_t i = 0; i < jar_xm_get_number_of_channels(ctx); i++) {
-        jar_xm_cut_note(&ctx->channels[i]);
-    }
-    ctx->current_row = 0;
-    ctx->current_tick = 0;
-    if(table_ptr > 0 && table_ptr < ctx->module.length) {
-        ctx->current_table_index = table_ptr;
-        ctx->module.restart_position = table_ptr; // The reason to jump is to start a new loop or track
-    } else {
-        ctx->current_table_index = 0;
-        ctx->module.restart_position = 0; // The reason to jump is to start a new loop or track
-        ctx->tempo =ctx->default_tempo; // reset to file default value 
-        ctx->bpm = ctx->default_bpm; // reset to file default value
-        ctx->global_volume = ctx->default_global_volume; // reset to file default value
-    };
-}
-
-
-// TRANSLATE NOTE NUMBER INTO USER VALUE (ie. 1 = C-1, 2 = C#1, 3 = D-1 ... )
-const char* xm_note_chr(int number) {
-    if (number == NOTE_OFF) {
-        return "==";
-    };
-    number = number % 12;
-    switch(number) {
-    case 1: return "C-";
-    case 2: return "C#";
-    case 3: return "D-";
-    case 4: return "D#";
-    case 5: return "E-";
-    case 6: return "F-";
-    case 7: return "F#";
-    case 8: return "G-";
-    case 9: return "G#";
-    case 10: return "A-";
-    case 11: return "A#";
-    case 12: return "B-";
-    };
-    return "??";
-};
-
-const char* xm_octave_chr(int number) {
-    if (number == NOTE_OFF) {
-        return "=";
-    };
-
-    int number2 = number - number % 12;
-    int result = floor(number2 / 12) + 1;
-    switch(result) {
-    case 1: return "1";
-    case 2: return "2";
-    case 3: return "3";
-    case 4: return "4";
-    case 5: return "5";
-    case 6: return "6";
-    case 7: return "7";
-    case 8: return "8";
-    default: return "?"; /* UNKNOWN */
-    };
-
-};
-
-// TRANSLATE NOTE EFFECT CODE INTO USER VALUE
-const char* xm_effect_chr(int fx) {
-    switch(fx) {
-    case 0: return "0";  /* ZERO = NO EFFECT */
-    case 1: return "1";  /* 1xx: Portamento up */
-    case 2: return "2";  /* 2xx: Portamento down */
-    case 3: return "3";  /* 3xx: Tone portamento */
-    case 4: return "4";  /* 4xy: Vibrato */
-    case 5: return "5";  /* 5xy: Tone portamento + Volume slide */
-    case 6: return "6";  /* 6xy: Vibrato + Volume slide */
-    case 7: return "7";  /* 7xy: Tremolo */
-    case 8: return "8";  /* 8xx: Set panning */
-    case 9: return "9";  /* 9xx: Sample offset */
-    case 0xA: return "A";/* Axy: Volume slide */
-    case 0xB: return "B";/* Bxx: Position jump */
-    case 0xC: return "C";/* Cxx: Set volume */
-    case 0xD: return "D";/* Dxx: Pattern break */
-    case 0xE: return "E";/* EXy: Extended command */
-    case 0xF: return "F";/* Fxx: Set tempo/BPM */
-    case 16: return "G"; /* Gxx: Set global volume */
-    case 17: return "H"; /* Hxy: Global volume slide */
-    case 21: return "L"; /* Lxx: Set envelope position */
-    case 25: return "P"; /* Pxy: Panning slide */
-    case 27: return "R"; /* Rxy: Multi retrig note */
-    case 29: return "T"; /* Txy: Tremor */
-    case 33: return "X"; /* Xxy: Extra stuff */
-    default: return "?"; /* UNKNOWN */
-    };
-}
-
-#ifdef JAR_XM_RAYLIB
-
-#include "raylib.h" // Need RayLib API calls for the DEBUG display
-
-void jar_xm_debug(jar_xm_context_t *ctx) {
-    int size=40;
-    int x = 0, y = 0;
-
-    // DEBUG VARIABLES
-    y += size; DrawText(TextFormat("CUR TBL = %i", ctx->current_table_index),       x, y, size, WHITE);
-    y += size; DrawText(TextFormat("CUR PAT = %i", ctx->module.pattern_table[ctx->current_table_index]),   x, y, size, WHITE);
-    y += size; DrawText(TextFormat("POS JMP = %d", ctx->position_jump),             x, y, size, WHITE);
-    y += size; DrawText(TextFormat("JMP DST = %i", ctx->jump_dest),                 x, y, size, WHITE);
-    y += size; DrawText(TextFormat("PTN BRK = %d", ctx->pattern_break),             x, y, size, WHITE);
-    y += size; DrawText(TextFormat("CUR ROW = %i", ctx->current_row),               x, y, size, WHITE);
-    y += size; DrawText(TextFormat("JMP ROW = %i", ctx->jump_row),                  x, y, size, WHITE);
-    y += size; DrawText(TextFormat("ROW LCT = %i", ctx->row_loop_count),            x, y, size, WHITE);
-    y += size; DrawText(TextFormat("LCT     = %i", ctx->loop_count),                x, y, size, WHITE);
-    y += size; DrawText(TextFormat("MAX LCT = %i", ctx->max_loop_count),            x, y, size, WHITE);
-    x = size * 12; y = 0;
-    
-    y += size; DrawText(TextFormat("CUR TCK = %i", ctx->current_tick),              x, y, size, WHITE);
-    y += size; DrawText(TextFormat("XTR TCK = %i", ctx->extra_ticks),               x, y, size, WHITE);
-    y += size; DrawText(TextFormat("TCK/ROW = %i", ctx->tempo),                     x, y, size, ORANGE);
-    y += size; DrawText(TextFormat("SPL TCK = %f", ctx->remaining_samples_in_tick), x, y, size, WHITE);
-    y += size; DrawText(TextFormat("GEN SPL = %i", ctx->generated_samples),         x, y, size, WHITE);
-    y += size * 7;
-    
-    x = 0;
-    size=16;
-    // TIMELINE OF MODULE
-    for (int i=0; i < ctx->module.length; i++) {
-        if (i == ctx->jump_dest) {
-            if (ctx->position_jump) {
-                DrawRectangle(i * size * 2, y - size, size * 2, size, GOLD); 
-            } else {
-                DrawRectangle(i * size * 2, y - size, size * 2, size, BROWN);                 
-            };
-        };
-        if (i == ctx->current_table_index) {
-//            DrawText(TextFormat("%02X", ctx->current_tick), i * size * 2, y - size, size, WHITE);
-            DrawRectangle(i * size * 2, y, size * 2, size, RED); 
-            DrawText(TextFormat("%02X", ctx->current_row), i * size * 2, y - size, size, YELLOW);
-        } else {
-            DrawRectangle(i * size * 2, y, size * 2, size, ORANGE); 
-        };
-        DrawText(TextFormat("%02X", ctx->module.pattern_table[i]), i * size * 2, y, size, WHITE);
-    };
-    y += size;
-
-    jar_xm_pattern_t* cur = ctx->module.patterns + ctx->module.pattern_table[ctx->current_table_index];
-
-    /* DISPLAY CURRENTLY PLAYING PATTERN */
-
-    x += 2 * size;
-    for(uint8_t i = 0; i < ctx->module.num_channels; i++) {
-        DrawRectangle(x, y, 8 * size, size, PURPLE);
-        DrawText("N", x, y, size, YELLOW);
-        DrawText("I", x + size * 2, y, size, YELLOW);
-        DrawText("V", x + size * 4, y, size, YELLOW);
-        DrawText("FX", x + size * 6, y, size, YELLOW);
-        x += 9 * size;
-    };
-    x += size;   
-    for (int j=(ctx->current_row - 14); j<(ctx->current_row + 15); j++) {
-        y += size;
-        x = 0;
-        if (j >=0 && j < (cur->num_rows)) {
-            DrawRectangle(x, y, size * 2, size, BROWN); 
-            DrawText(TextFormat("%02X",j), x, y, size, WHITE);
-            x += 2 * size;
-            for(uint8_t i = 0; i < ctx->module.num_channels; i++) {
-                if (j==(ctx->current_row)) {
-                    DrawRectangle(x, y, 8 * size, size, DARKGREEN); 
-                } else {
-                    DrawRectangle(x, y, 8 * size, size, DARKGRAY); 
-                };
-                jar_xm_pattern_slot_t *s = cur->slots + j * ctx->module.num_channels + i;
-           //     jar_xm_channel_context_t *ch = ctx->channels + i;
-                if (s->note > 0) {DrawText(TextFormat("%s%s", xm_note_chr(s->note), xm_octave_chr(s->note) ), x, y, size, WHITE);} else {DrawText("...", x, y, size, GRAY);};
-                if (s->instrument > 0) {
-                    DrawText(TextFormat("%02X", s->instrument), x + size * 2, y, size, WHITE);
-                    if (s->volume_column == 0) {
-                        DrawText(TextFormat("%02X", 64), x + size * 4, y, size, YELLOW);
-                    };
-                } else {
-                    DrawText("..", x + size * 2, y, size, GRAY);
-                    if (s->volume_column == 0) {
-                        DrawText("..", x + size * 4, y, size, GRAY);
-                    };
-                };
-                if (s->volume_column > 0) {DrawText(TextFormat("%02X", (s->volume_column - 16)), x + size * 4, y, size, WHITE);};
-                if (s->effect_type > 0 || s->effect_param > 0) {DrawText(TextFormat("%s%02X", xm_effect_chr(s->effect_type), s->effect_param), x + size * 6, y, size, WHITE);};
-                x += 9 * size;
-            };
-        };
-    };
-
-}
-#endif // RayLib extension
-
-#endif//end of JAR_XM_IMPLEMENTATION
-//-------------------------------------------------------------------------------
-
-#endif//end of INCLUDE_JAR_XM_H
diff --git a/raylib_pi4_test/external/miniaudio.h b/raylib_pi4_test/external/miniaudio.h
deleted file mode 100644 (file)
index 60522da..0000000
+++ /dev/null
@@ -1,65345 +0,0 @@
-/*
-Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
-miniaudio - v0.10.33 - 2021-04-04
-
-David Reid - mackron@gmail.com
-
-Website:       https://miniaud.io
-Documentation: https://miniaud.io/docs
-GitHub:        https://github.com/mackron/miniaudio
-*/
-
-/*
-1. Introduction
-===============
-miniaudio is a single file library for audio playback and capture. To use it, do the following in one .c file:
-
-    ```c
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-    ```
-
-You can do `#include "miniaudio.h"` in other parts of the program just like any other header.
-
-miniaudio uses the concept of a "device" as the abstraction for physical devices. The idea is that you choose a physical device to emit or capture audio from,
-and then move data to/from the device when miniaudio tells you to. Data is delivered to and from devices asynchronously via a callback which you specify when
-initializing the device.
-
-When initializing the device you first need to configure it. The device configuration allows you to specify things like the format of the data delivered via
-the callback, the size of the internal buffer and the ID of the device you want to emit or capture audio from.
-
-Once you have the device configuration set up you can initialize the device. When initializing a device you need to allocate memory for the device object
-beforehand. This gives the application complete control over how the memory is allocated. In the example below we initialize a playback device on the stack,
-but you could allocate it on the heap if that suits your situation better.
-
-    ```c
-    void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
-    {
-        // In playback mode copy data to pOutput. In capture mode read data from pInput. In full-duplex mode, both
-        // pOutput and pInput will be valid and you can move data from pInput into pOutput. Never process more than
-        // frameCount frames.
-    }
-
-    int main()
-    {
-        ma_device_config config = ma_device_config_init(ma_device_type_playback);
-        config.playback.format   = ma_format_f32;   // Set to ma_format_unknown to use the device's native format.
-        config.playback.channels = 2;               // Set to 0 to use the device's native channel count.
-        config.sampleRate        = 48000;           // Set to 0 to use the device's native sample rate.
-        config.dataCallback      = data_callback;   // This function will be called when miniaudio needs more data.
-        config.pUserData         = pMyCustomData;   // Can be accessed from the device object (device.pUserData).
-
-        ma_device device;
-        if (ma_device_init(NULL, &config, &device) != MA_SUCCESS) {
-            return -1;  // Failed to initialize the device.
-        }
-
-        ma_device_start(&device);     // The device is sleeping by default so you'll need to start it manually.
-
-        // Do something here. Probably your program's main loop.
-
-        ma_device_uninit(&device);    // This will stop the device so no need to do that manually.
-        return 0;
-    }
-    ```
-
-In the example above, `data_callback()` is where audio data is written and read from the device. The idea is in playback mode you cause sound to be emitted
-from the speakers by writing audio data to the output buffer (`pOutput` in the example). In capture mode you read data from the input buffer (`pInput`) to
-extract sound captured by the microphone. The `frameCount` parameter tells you how many frames can be written to the output buffer and read from the input
-buffer. A "frame" is one sample for each channel. For example, in a stereo stream (2 channels), one frame is 2 samples: one for the left, one for the right.
-The channel count is defined by the device config. The size in bytes of an individual sample is defined by the sample format which is also specified in the
-device config. Multi-channel audio data is always interleaved, which means the samples for each frame are stored next to each other in memory. For example, in
-a stereo stream the first pair of samples will be the left and right samples for the first frame, the second pair of samples will be the left and right samples
-for the second frame, etc.
-
-The configuration of the device is defined by the `ma_device_config` structure. The config object is always initialized with `ma_device_config_init()`. It's
-important to always initialize the config with this function as it initializes it with logical defaults and ensures your program doesn't break when new members
-are added to the `ma_device_config` structure. The example above uses a fairly simple and standard device configuration. The call to `ma_device_config_init()`
-takes a single parameter, which is whether or not the device is a playback, capture, duplex or loopback device (loopback devices are not supported on all
-backends). The `config.playback.format` member sets the sample format which can be one of the following (all formats are native-endian):
-
-    +---------------+----------------------------------------+---------------------------+
-    | Symbol        | Description                            | Range                     |
-    +---------------+----------------------------------------+---------------------------+
-    | ma_format_f32 | 32-bit floating point                  | [-1, 1]                   |
-    | ma_format_s16 | 16-bit signed integer                  | [-32768, 32767]           |
-    | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607]       |
-    | ma_format_s32 | 32-bit signed integer                  | [-2147483648, 2147483647] |
-    | ma_format_u8  | 8-bit unsigned integer                 | [0, 255]                  |
-    +---------------+----------------------------------------+---------------------------+
-
-The `config.playback.channels` member sets the number of channels to use with the device. The channel count cannot exceed MA_MAX_CHANNELS. The
-`config.sampleRate` member sets the sample rate (which must be the same for both playback and capture in full-duplex configurations). This is usually set to
-44100 or 48000, but can be set to anything. It's recommended to keep this between 8000 and 384000, however.
-
-Note that leaving the format, channel count and/or sample rate at their default values will result in the internal device's native configuration being used
-which is useful if you want to avoid the overhead of miniaudio's automatic data conversion.
-
-In addition to the sample format, channel count and sample rate, the data callback and user data pointer are also set via the config. The user data pointer is
-not passed into the callback as a parameter, but is instead set to the `pUserData` member of `ma_device` which you can access directly since all miniaudio
-structures are transparent.
-
-Initializing the device is done with `ma_device_init()`. This will return a result code telling you what went wrong, if anything. On success it will return
-`MA_SUCCESS`. After initialization is complete the device will be in a stopped state. To start it, use `ma_device_start()`. Uninitializing the device will stop
-it, which is what the example above does, but you can also stop the device with `ma_device_stop()`. To resume the device simply call `ma_device_start()` again.
-Note that it's important to never stop or start the device from inside the callback. This will result in a deadlock. Instead you set a variable or signal an
-event indicating that the device needs to stop and handle it in a different thread. The following APIs must never be called inside the callback:
-
-    ```c
-    ma_device_init()
-    ma_device_init_ex()
-    ma_device_uninit()
-    ma_device_start()
-    ma_device_stop()
-    ```
-
-You must never try uninitializing and reinitializing a device inside the callback. You must also never try to stop and start it from inside the callback. There
-are a few other things you shouldn't do in the callback depending on your requirements, however this isn't so much a thread-safety thing, but rather a
-real-time processing thing which is beyond the scope of this introduction.
-
-The example above demonstrates the initialization of a playback device, but it works exactly the same for capture. All you need to do is change the device type
-from `ma_device_type_playback` to `ma_device_type_capture` when setting up the config, like so:
-
-    ```c
-    ma_device_config config = ma_device_config_init(ma_device_type_capture);
-    config.capture.format   = MY_FORMAT;
-    config.capture.channels = MY_CHANNEL_COUNT;
-    ```
-
-In the data callback you just read from the input buffer (`pInput` in the example above) and leave the output buffer alone (it will be set to NULL when the
-device type is set to `ma_device_type_capture`).
-
-These are the available device types and how you should handle the buffers in the callback:
-
-    +-------------------------+--------------------------------------------------------+
-    | Device Type             | Callback Behavior                                      |
-    +-------------------------+--------------------------------------------------------+
-    | ma_device_type_playback | Write to output buffer, leave input buffer untouched.  |
-    | ma_device_type_capture  | Read from input buffer, leave output buffer untouched. |
-    | ma_device_type_duplex   | Read from input buffer, write to output buffer.        |
-    | ma_device_type_loopback | Read from input buffer, leave output buffer untouched. |
-    +-------------------------+--------------------------------------------------------+
-
-You will notice in the example above that the sample format and channel count is specified separately for playback and capture. This is to support different
-data formats between the playback and capture devices in a full-duplex system. An example may be that you want to capture audio data as a monaural stream (one
-channel), but output sound to a stereo speaker system. Note that if you use different formats between playback and capture in a full-duplex configuration you
-will need to convert the data yourself. There are functions available to help you do this which will be explained later.
-
-The example above did not specify a physical device to connect to which means it will use the operating system's default device. If you have multiple physical
-devices connected and you want to use a specific one you will need to specify the device ID in the configuration, like so:
-
-    ```c
-    config.playback.pDeviceID = pMyPlaybackDeviceID;    // Only if requesting a playback or duplex device.
-    config.capture.pDeviceID = pMyCaptureDeviceID;      // Only if requesting a capture, duplex or loopback device.
-    ```
-
-To retrieve the device ID you will need to perform device enumeration, however this requires the use of a new concept called the "context". Conceptually
-speaking the context sits above the device. There is one context to many devices. The purpose of the context is to represent the backend at a more global level
-and to perform operations outside the scope of an individual device. Mainly it is used for performing run-time linking against backend libraries, initializing
-backends and enumerating devices. The example below shows how to enumerate devices.
-
-    ```c
-    ma_context context;
-    if (ma_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) {
-        // Error.
-    }
-
-    ma_device_info* pPlaybackInfos;
-    ma_uint32 playbackCount;
-    ma_device_info* pCaptureInfos;
-    ma_uint32 captureCount;
-    if (ma_context_get_devices(&context, &pPlaybackInfos, &playbackCount, &pCaptureInfos, &captureCount) != MA_SUCCESS) {
-        // Error.
-    }
-
-    // Loop over each device info and do something with it. Here we just print the name with their index. You may want
-    // to give the user the opportunity to choose which device they'd prefer.
-    for (ma_uint32 iDevice = 0; iDevice < playbackCount; iDevice += 1) {
-        printf("%d - %s\n", iDevice, pPlaybackInfos[iDevice].name);
-    }
-
-    ma_device_config config = ma_device_config_init(ma_device_type_playback);
-    config.playback.pDeviceID = &pPlaybackInfos[chosenPlaybackDeviceIndex].id;
-    config.playback.format    = MY_FORMAT;
-    config.playback.channels  = MY_CHANNEL_COUNT;
-    config.sampleRate         = MY_SAMPLE_RATE;
-    config.dataCallback       = data_callback;
-    config.pUserData          = pMyCustomData;
-
-    ma_device device;
-    if (ma_device_init(&context, &config, &device) != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_device_uninit(&device);
-    ma_context_uninit(&context);
-    ```
-
-The first thing we do in this example is initialize a `ma_context` object with `ma_context_init()`. The first parameter is a pointer to a list of `ma_backend`
-values which are used to override the default backend priorities. When this is NULL, as in this example, miniaudio's default priorities are used. The second
-parameter is the number of backends listed in the array pointed to by the first parameter. The third parameter is a pointer to a `ma_context_config` object
-which can be NULL, in which case defaults are used. The context configuration is used for setting the logging callback, custom memory allocation callbacks,
-user-defined data and some backend-specific configurations.
-
-Once the context has been initialized you can enumerate devices. In the example above we use the simpler `ma_context_get_devices()`, however you can also use a
-callback for handling devices by using `ma_context_enumerate_devices()`. When using `ma_context_get_devices()` you provide a pointer to a pointer that will,
-upon output, be set to a pointer to a buffer containing a list of `ma_device_info` structures. You also provide a pointer to an unsigned integer that will
-receive the number of items in the returned buffer. Do not free the returned buffers as their memory is managed internally by miniaudio.
-
-The `ma_device_info` structure contains an `id` member which is the ID you pass to the device config. It also contains the name of the device which is useful
-for presenting a list of devices to the user via the UI.
-
-When creating your own context you will want to pass it to `ma_device_init()` when initializing the device. Passing in NULL, like we do in the first example,
-will result in miniaudio creating the context for you, which you don't want to do since you've already created a context. Note that internally the context is
-only tracked by it's pointer which means you must not change the location of the `ma_context` object. If this is an issue, consider using `malloc()` to
-allocate memory for the context.
-
-
-
-2. Building
-===========
-miniaudio should work cleanly out of the box without the need to download or install any dependencies. See below for platform-specific details.
-
-
-2.1. Windows
-------------
-The Windows build should compile cleanly on all popular compilers without the need to configure any include paths nor link to any libraries.
-
-2.2. macOS and iOS
-------------------
-The macOS build should compile cleanly without the need to download any dependencies nor link to any libraries or frameworks. The iOS build needs to be
-compiled as Objective-C and will need to link the relevant frameworks but should compile cleanly out of the box with Xcode. Compiling through the command line
-requires linking to `-lpthread` and `-lm`.
-
-Due to the way miniaudio links to frameworks at runtime, your application may not pass Apple's notarization process. To fix this there are two options. The
-first is to use the `MA_NO_RUNTIME_LINKING` option, like so:
-
-    ```c
-    #ifdef __APPLE__
-        #define MA_NO_RUNTIME_LINKING
-    #endif
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-    ```
-
-This will require linking with `-framework CoreFoundation -framework CoreAudio -framework AudioUnit`. Alternatively, if you would rather keep using runtime
-linking you can add the following to your entitlements.xcent file:
-
-    ```
-    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
-    <true/>
-    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
-    <true/>
-    ```
-
-
-2.3. Linux
-----------
-The Linux build only requires linking to `-ldl`, `-lpthread` and `-lm`. You do not need any development packages.
-
-2.4. BSD
---------
-The BSD build only requires linking to `-lpthread` and `-lm`. NetBSD uses audio(4), OpenBSD uses sndio and FreeBSD uses OSS.
-
-2.5. Android
-------------
-AAudio is the highest priority backend on Android. This should work out of the box without needing any kind of compiler configuration. Support for AAudio
-starts with Android 8 which means older versions will fall back to OpenSL|ES which requires API level 16+.
-
-There have been reports that the OpenSL|ES backend fails to initialize on some Android based devices due to `dlopen()` failing to open "libOpenSLES.so". If
-this happens on your platform you'll need to disable run-time linking with `MA_NO_RUNTIME_LINKING` and link with -lOpenSLES.
-
-2.6. Emscripten
----------------
-The Emscripten build emits Web Audio JavaScript directly and should compile cleanly out of the box. You cannot use -std=c* compiler flags, nor -ansi.
-
-
-2.7. Build Options
-------------------
-`#define` these options before including miniaudio.h.
-
-    +----------------------------------+--------------------------------------------------------------------+
-    | Option                           | Description                                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WASAPI                     | Disables the WASAPI backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DSOUND                     | Disables the DirectSound backend.                                  |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WINMM                      | Disables the WinMM backend.                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_ALSA                       | Disables the ALSA backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_PULSEAUDIO                 | Disables the PulseAudio backend.                                   |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_JACK                       | Disables the JACK backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_COREAUDIO                  | Disables the Core Audio backend.                                   |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_SNDIO                      | Disables the sndio backend.                                        |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AUDIO4                     | Disables the audio(4) backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_OSS                        | Disables the OSS backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AAUDIO                     | Disables the AAudio backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_OPENSL                     | Disables the OpenSL|ES backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WEBAUDIO                   | Disables the Web Audio backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_NULL                       | Disables the null backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_ONLY_SPECIFIC_BACKENDS | Disables all backends by default and requires `MA_ENABLE_*` to     |
-    |                                  | enable specific backends.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WASAPI                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the WASAPI backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_DSOUND                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the DirectSound backend.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WINMM                  | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the WinMM backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_ALSA                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the ALSA backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_PULSEAUDIO             | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the PulseAudio backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_JACK                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the JACK backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_COREAUDIO              | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the Core Audio backend.                                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_SNDIO                  | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the sndio backend.                                          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_AUDIO4                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the audio(4) backend.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_OSS                    | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the OSS backend.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_AAUDIO                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the AAudio backend.                                         |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_OPENSL                 | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the OpenSL|ES backend.                                      |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_WEBAUDIO               | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the Web Audio backend.                                      |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_ENABLE_NULL                   | Used in conjunction with MA_ENABLE_ONLY_SPECIFIC_BACKENDS to       |
-    |                                  | enable the null backend.                                           |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DECODING                   | Disables decoding APIs.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_ENCODING                   | Disables encoding APIs.                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_WAV                        | Disables the built-in WAV decoder and encoder.                     |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_FLAC                       | Disables the built-in FLAC decoder.                                |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_MP3                        | Disables the built-in MP3 decoder.                                 |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_DEVICE_IO                  | Disables playback and recording. This will disable ma_context and  |
-    |                                  | ma_device APIs. This is useful if you only want to use miniaudio's |
-    |                                  | data conversion and/or decoding APIs.                              |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_THREADING                  | Disables the ma_thread, ma_mutex, ma_semaphore and ma_event APIs.  |
-    |                                  | This option is useful if you only need to use miniaudio for data   |
-    |                                  | conversion, decoding and/or encoding. Some families of APIs        |
-    |                                  | require threading which means the following options must also be   |
-    |                                  | set:                                                               |
-    |                                  |                                                                    |
-    |                                  |     ```                                                            |
-    |                                  |     MA_NO_DEVICE_IO                                                |
-    |                                  |     ```                                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_GENERATION                 | Disables generation APIs such a ma_waveform and ma_noise.          |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_SSE2                       | Disables SSE2 optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AVX2                       | Disables AVX2 optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_AVX512                     | Disables AVX-512 optimizations.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_NEON                       | Disables NEON optimizations.                                       |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_NO_RUNTIME_LINKING            | Disables runtime linking. This is useful for passing Apple's       |
-    |                                  | notarization process. When enabling this, you may need to avoid    |
-    |                                  | using `-std=c89` or `-std=c99` on Linux builds or else you may end |
-    |                                  | up with compilation errors due to conflicts with `timespec` and    |
-    |                                  | `timeval` data types.                                              |
-    |                                  |                                                                    |
-    |                                  | You may need to enable this if your target platform does not allow |
-    |                                  | runtime linking via `dlopen()`.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_LOG_LEVEL [level]             | Sets the logging level. Set `level` to one of the following:       |
-    |                                  |                                                                    |
-    |                                  |     ```                                                            |
-    |                                  |     MA_LOG_LEVEL_VERBOSE                                           |
-    |                                  |     MA_LOG_LEVEL_INFO                                              |
-    |                                  |     MA_LOG_LEVEL_WARNING                                           |
-    |                                  |     MA_LOG_LEVEL_ERROR                                             |
-    |                                  |     ```                                                            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_DEBUG_OUTPUT                  | Enable `printf()` debug output.                                    |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_COINIT_VALUE                  | Windows only. The value to pass to internal calls to               |
-    |                                  | `CoInitializeEx()`. Defaults to `COINIT_MULTITHREADED`.            |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_API                           | Controls how public APIs should be decorated. Default is `extern`. |
-    +----------------------------------+--------------------------------------------------------------------+
-    | MA_DLL                           | If set, configures MA_API to either import or export APIs          |
-    |                                  | depending on whether or not the implementation is being defined.   |
-    |                                  | If defining the implementation, MA_API will be configured to       |
-    |                                  | export. Otherwise it will be configured to import. This has no     |
-    |                                  | effect if MA_API is defined externally.                            |
-    +----------------------------------+--------------------------------------------------------------------+
-
-
-3. Definitions
-==============
-This section defines common terms used throughout miniaudio. Unfortunately there is often ambiguity in the use of terms throughout the audio space, so this
-section is intended to clarify how miniaudio uses each term.
-
-3.1. Sample
------------
-A sample is a single unit of audio data. If the sample format is f32, then one sample is one 32-bit floating point number.
-
-3.2. Frame / PCM Frame
-----------------------
-A frame is a group of samples equal to the number of channels. For a stereo stream a frame is 2 samples, a mono frame is 1 sample, a 5.1 surround sound frame
-is 6 samples, etc. The terms "frame" and "PCM frame" are the same thing in miniaudio. Note that this is different to a compressed frame. If ever miniaudio
-needs to refer to a compressed frame, such as a FLAC frame, it will always clarify what it's referring to with something like "FLAC frame".
-
-3.3. Channel
-------------
-A stream of monaural audio that is emitted from an individual speaker in a speaker system, or received from an individual microphone in a microphone system. A
-stereo stream has two channels (a left channel, and a right channel), a 5.1 surround sound system has 6 channels, etc. Some audio systems refer to a channel as
-a complex audio stream that's mixed with other channels to produce the final mix - this is completely different to miniaudio's use of the term "channel" and
-should not be confused.
-
-3.4. Sample Rate
-----------------
-The sample rate in miniaudio is always expressed in Hz, such as 44100, 48000, etc. It's the number of PCM frames that are processed per second.
-
-3.5. Formats
-------------
-Throughout miniaudio you will see references to different sample formats:
-
-    +---------------+----------------------------------------+---------------------------+
-    | Symbol        | Description                            | Range                     |
-    +---------------+----------------------------------------+---------------------------+
-    | ma_format_f32 | 32-bit floating point                  | [-1, 1]                   |
-    | ma_format_s16 | 16-bit signed integer                  | [-32768, 32767]           |
-    | ma_format_s24 | 24-bit signed integer (tightly packed) | [-8388608, 8388607]       |
-    | ma_format_s32 | 32-bit signed integer                  | [-2147483648, 2147483647] |
-    | ma_format_u8  | 8-bit unsigned integer                 | [0, 255]                  |
-    +---------------+----------------------------------------+---------------------------+
-
-All formats are native-endian.
-
-
-
-4. Decoding
-===========
-The `ma_decoder` API is used for reading audio files. Decoders are completely decoupled from devices and can be used independently. The following formats are
-supported:
-
-    +---------+------------------+----------+
-    | Format  | Decoding Backend | Built-In |
-    +---------+------------------+----------+
-    | WAV     | dr_wav           | Yes      |
-    | MP3     | dr_mp3           | Yes      |
-    | FLAC    | dr_flac          | Yes      |
-    | Vorbis  | stb_vorbis       | No       |
-    +---------+------------------+----------+
-
-Vorbis is supported via stb_vorbis which can be enabled by including the header section before the implementation of miniaudio, like the following:
-
-    ```c
-    #define STB_VORBIS_HEADER_ONLY
-    #include "extras/stb_vorbis.c"    // Enables Vorbis decoding.
-
-    #define MINIAUDIO_IMPLEMENTATION
-    #include "miniaudio.h"
-
-    // The stb_vorbis implementation must come after the implementation of miniaudio.
-    #undef STB_VORBIS_HEADER_ONLY
-    #include "extras/stb_vorbis.c"
-    ```
-
-A copy of stb_vorbis is included in the "extras" folder in the miniaudio repository (https://github.com/mackron/miniaudio).
-
-Built-in decoders are amalgamated into the implementation section of miniaudio. You can disable the built-in decoders by specifying one or more of the
-following options before the miniaudio implementation:
-
-    ```c
-    #define MA_NO_WAV
-    #define MA_NO_MP3
-    #define MA_NO_FLAC
-    ```
-
-Disabling built-in decoding libraries is useful if you use these libraries independantly of the `ma_decoder` API.
-
-A decoder can be initialized from a file with `ma_decoder_init_file()`, a block of memory with `ma_decoder_init_memory()`, or from data delivered via callbacks
-with `ma_decoder_init()`. Here is an example for loading a decoder from a file:
-
-    ```c
-    ma_decoder decoder;
-    ma_result result = ma_decoder_init_file("MySong.mp3", NULL, &decoder);
-    if (result != MA_SUCCESS) {
-        return false;   // An error occurred.
-    }
-
-    ...
-
-    ma_decoder_uninit(&decoder);
-    ```
-
-When initializing a decoder, you can optionally pass in a pointer to a `ma_decoder_config` object (the `NULL` argument in the example above) which allows you
-to configure the output format, channel count, sample rate and channel map:
-
-    ```c
-    ma_decoder_config config = ma_decoder_config_init(ma_format_f32, 2, 48000);
-    ```
-
-When passing in `NULL` for decoder config in `ma_decoder_init*()`, the output format will be the same as that defined by the decoding backend.
-
-Data is read from the decoder as PCM frames. This will return the number of PCM frames actually read. If the return value is less than the requested number of
-PCM frames it means you've reached the end:
-
-    ```c
-    ma_uint64 framesRead = ma_decoder_read_pcm_frames(pDecoder, pFrames, framesToRead);
-    if (framesRead < framesToRead) {
-        // Reached the end.
-    }
-    ```
-
-You can also seek to a specific frame like so:
-
-    ```c
-    ma_result result = ma_decoder_seek_to_pcm_frame(pDecoder, targetFrame);
-    if (result != MA_SUCCESS) {
-        return false;   // An error occurred.
-    }
-    ```
-
-If you want to loop back to the start, you can simply seek back to the first PCM frame:
-
-    ```c
-    ma_decoder_seek_to_pcm_frame(pDecoder, 0);
-    ```
-
-When loading a decoder, miniaudio uses a trial and error technique to find the appropriate decoding backend. This can be unnecessarily inefficient if the type
-is already known. In this case you can use the `_wav`, `_mp3`, etc. varients of the aforementioned initialization APIs:
-
-    ```c
-    ma_decoder_init_wav()
-    ma_decoder_init_mp3()
-    ma_decoder_init_memory_wav()
-    ma_decoder_init_memory_mp3()
-    ma_decoder_init_file_wav()
-    ma_decoder_init_file_mp3()
-    etc.
-    ```
-
-The `ma_decoder_init_file()` API will try using the file extension to determine which decoding backend to prefer.
-
-
-
-5. Encoding
-===========
-The `ma_encoding` API is used for writing audio files. The only supported output format is WAV which is achieved via dr_wav which is amalgamated into the
-implementation section of miniaudio. This can be disabled by specifying the following option before the implementation of miniaudio:
-
-    ```c
-    #define MA_NO_WAV
-    ```
-
-An encoder can be initialized to write to a file with `ma_encoder_init_file()` or from data delivered via callbacks with `ma_encoder_init()`. Below is an
-example for initializing an encoder to output to a file.
-
-    ```c
-    ma_encoder_config config = ma_encoder_config_init(ma_resource_format_wav, FORMAT, CHANNELS, SAMPLE_RATE);
-    ma_encoder encoder;
-    ma_result result = ma_encoder_init_file("my_file.wav", &config, &encoder);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_encoder_uninit(&encoder);
-    ```
-
-When initializing an encoder you must specify a config which is initialized with `ma_encoder_config_init()`. Here you must specify the file type, the output
-sample format, output channel count and output sample rate. The following file types are supported:
-
-    +------------------------+-------------+
-    | Enum                   | Description |
-    +------------------------+-------------+
-    | ma_resource_format_wav | WAV         |
-    +------------------------+-------------+
-
-If the format, channel count or sample rate is not supported by the output file type an error will be returned. The encoder will not perform data conversion so
-you will need to convert it before outputting any audio data. To output audio data, use `ma_encoder_write_pcm_frames()`, like in the example below:
-
-    ```c
-    framesWritten = ma_encoder_write_pcm_frames(&encoder, pPCMFramesToWrite, framesToWrite);
-    ```
-
-Encoders must be uninitialized with `ma_encoder_uninit()`.
-
-
-6. Data Conversion
-==================
-A data conversion API is included with miniaudio which supports the majority of data conversion requirements. This supports conversion between sample formats,
-channel counts (with channel mapping) and sample rates.
-
-
-6.1. Sample Format Conversion
------------------------------
-Conversion between sample formats is achieved with the `ma_pcm_*_to_*()`, `ma_pcm_convert()` and `ma_convert_pcm_frames_format()` APIs. Use `ma_pcm_*_to_*()`
-to convert between two specific formats. Use `ma_pcm_convert()` to convert based on a `ma_format` variable. Use `ma_convert_pcm_frames_format()` to convert
-PCM frames where you want to specify the frame count and channel count as a variable instead of the total sample count.
-
-
-6.1.1. Dithering
-----------------
-Dithering can be set using the ditherMode parameter.
-
-The different dithering modes include the following, in order of efficiency:
-
-    +-----------+--------------------------+
-    | Type      | Enum Token               |
-    +-----------+--------------------------+
-    | None      | ma_dither_mode_none      |
-    | Rectangle | ma_dither_mode_rectangle |
-    | Triangle  | ma_dither_mode_triangle  |
-    +-----------+--------------------------+
-
-Note that even if the dither mode is set to something other than `ma_dither_mode_none`, it will be ignored for conversions where dithering is not needed.
-Dithering is available for the following conversions:
-
-    ```
-    s16 -> u8
-    s24 -> u8
-    s32 -> u8
-    f32 -> u8
-    s24 -> s16
-    s32 -> s16
-    f32 -> s16
-    ```
-
-Note that it is not an error to pass something other than ma_dither_mode_none for conversions where dither is not used. It will just be ignored.
-
-
-
-6.2. Channel Conversion
------------------------
-Channel conversion is used for channel rearrangement and conversion from one channel count to another. The `ma_channel_converter` API is used for channel
-conversion. Below is an example of initializing a simple channel converter which converts from mono to stereo.
-
-    ```c
-    ma_channel_converter_config config = ma_channel_converter_config_init(
-        ma_format,                      // Sample format
-        1,                              // Input channels
-        NULL,                           // Input channel map
-        2,                              // Output channels
-        NULL,                           // Output channel map
-        ma_channel_mix_mode_default);   // The mixing algorithm to use when combining channels.
-
-    result = ma_channel_converter_init(&config, &converter);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-    ```
-
-To perform the conversion simply call `ma_channel_converter_process_pcm_frames()` like so:
-
-    ```c
-    ma_result result = ma_channel_converter_process_pcm_frames(&converter, pFramesOut, pFramesIn, frameCount);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-    ```
-
-It is up to the caller to ensure the output buffer is large enough to accomodate the new PCM frames.
-
-Input and output PCM frames are always interleaved. Deinterleaved layouts are not supported.
-
-
-6.2.1. Channel Mapping
-----------------------
-In addition to converting from one channel count to another, like the example above, the channel converter can also be used to rearrange channels. When
-initializing the channel converter, you can optionally pass in channel maps for both the input and output frames. If the channel counts are the same, and each
-channel map contains the same channel positions with the exception that they're in a different order, a simple shuffling of the channels will be performed. If,
-however, there is not a 1:1 mapping of channel positions, or the channel counts differ, the input channels will be mixed based on a mixing mode which is
-specified when initializing the `ma_channel_converter_config` object.
-
-When converting from mono to multi-channel, the mono channel is simply copied to each output channel. When going the other way around, the audio of each output
-channel is simply averaged and copied to the mono channel.
-
-In more complicated cases blending is used. The `ma_channel_mix_mode_simple` mode will drop excess channels and silence extra channels. For example, converting
-from 4 to 2 channels, the 3rd and 4th channels will be dropped, whereas converting from 2 to 4 channels will put silence into the 3rd and 4th channels.
-
-The `ma_channel_mix_mode_rectangle` mode uses spacial locality based on a rectangle to compute a simple distribution between input and output. Imagine sitting
-in the middle of a room, with speakers on the walls representing channel positions. The MA_CHANNEL_FRONT_LEFT position can be thought of as being in the corner
-of the front and left walls.
-
-Finally, the `ma_channel_mix_mode_custom_weights` mode can be used to use custom user-defined weights. Custom weights can be passed in as the last parameter of
-`ma_channel_converter_config_init()`.
-
-Predefined channel maps can be retrieved with `ma_get_standard_channel_map()`. This takes a `ma_standard_channel_map` enum as it's first parameter, which can
-be one of the following:
-
-    +-----------------------------------+-----------------------------------------------------------+
-    | Name                              | Description                                               |
-    +-----------------------------------+-----------------------------------------------------------+
-    | ma_standard_channel_map_default   | Default channel map used by miniaudio. See below.         |
-    | ma_standard_channel_map_microsoft | Channel map used by Microsoft's bitfield channel maps.    |
-    | ma_standard_channel_map_alsa      | Default ALSA channel map.                                 |
-    | ma_standard_channel_map_rfc3551   | RFC 3551. Based on AIFF.                                  |
-    | ma_standard_channel_map_flac      | FLAC channel map.                                         |
-    | ma_standard_channel_map_vorbis    | Vorbis channel map.                                       |
-    | ma_standard_channel_map_sound4    | FreeBSD's sound(4).                                       |
-    | ma_standard_channel_map_sndio     | sndio channel map. http://www.sndio.org/tips.html.        |
-    | ma_standard_channel_map_webaudio  | https://webaudio.github.io/web-audio-api/#ChannelOrdering |
-    +-----------------------------------+-----------------------------------------------------------+
-
-Below are the channel maps used by default in miniaudio (`ma_standard_channel_map_default`):
-
-    +---------------+---------------------------------+
-    | Channel Count | Mapping                         |
-    +---------------+---------------------------------+
-    | 1 (Mono)      | 0: MA_CHANNEL_MONO              |
-    +---------------+---------------------------------+
-    | 2 (Stereo)    | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT       |
-    +---------------+---------------------------------+
-    | 3             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER      |
-    +---------------+---------------------------------+
-    | 4 (Surround)  | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_BACK_CENTER       |
-    +---------------+---------------------------------+
-    | 5             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_BACK_LEFT    <br> |
-    |               | 4: MA_CHANNEL_BACK_RIGHT        |
-    +---------------+---------------------------------+
-    | 6 (5.1)       | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 5: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | 7             | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_BACK_CENTER  <br> |
-    |               | 4: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 5: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | 8 (7.1)       | 0: MA_CHANNEL_FRONT_LEFT   <br> |
-    |               | 1: MA_CHANNEL_FRONT_RIGHT  <br> |
-    |               | 2: MA_CHANNEL_FRONT_CENTER <br> |
-    |               | 3: MA_CHANNEL_LFE          <br> |
-    |               | 4: MA_CHANNEL_BACK_LEFT    <br> |
-    |               | 5: MA_CHANNEL_BACK_RIGHT   <br> |
-    |               | 6: MA_CHANNEL_SIDE_LEFT    <br> |
-    |               | 7: MA_CHANNEL_SIDE_RIGHT        |
-    +---------------+---------------------------------+
-    | Other         | All channels set to 0. This     |
-    |               | is equivalent to the same       |
-    |               | mapping as the device.          |
-    +---------------+---------------------------------+
-
-
-
-6.3. Resampling
----------------
-Resampling is achieved with the `ma_resampler` object. To create a resampler object, do something like the following:
-
-    ```c
-    ma_resampler_config config = ma_resampler_config_init(
-        ma_format_s16,
-        channels,
-        sampleRateIn,
-        sampleRateOut,
-        ma_resample_algorithm_linear);
-
-    ma_resampler resampler;
-    ma_result result = ma_resampler_init(&config, &resampler);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-    ```
-
-Do the following to uninitialize the resampler:
-
-    ```c
-    ma_resampler_uninit(&resampler);
-    ```
-
-The following example shows how data can be processed
-
-    ```c
-    ma_uint64 frameCountIn  = 1000;
-    ma_uint64 frameCountOut = 2000;
-    ma_result result = ma_resampler_process_pcm_frames(&resampler, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-
-    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the
-    // number of output frames written.
-    ```
-
-To initialize the resampler you first need to set up a config (`ma_resampler_config`) with `ma_resampler_config_init()`. You need to specify the sample format
-you want to use, the number of channels, the input and output sample rate, and the algorithm.
-
-The sample format can be either `ma_format_s16` or `ma_format_f32`. If you need a different format you will need to perform pre- and post-conversions yourself
-where necessary. Note that the format is the same for both input and output. The format cannot be changed after initialization.
-
-The resampler supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.
-
-The sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the
-only configuration property that can be changed after initialization.
-
-The miniaudio resampler supports multiple algorithms:
-
-    +-----------+------------------------------+
-    | Algorithm | Enum Token                   |
-    +-----------+------------------------------+
-    | Linear    | ma_resample_algorithm_linear |
-    | Speex     | ma_resample_algorithm_speex  |
-    +-----------+------------------------------+
-
-Because Speex is not public domain it is strictly opt-in and the code is stored in separate files. if you opt-in to the Speex backend you will need to consider
-it's license, the text of which can be found in it's source files in "extras/speex_resampler". Details on how to opt-in to the Speex resampler is explained in
-the Speex Resampler section below.
-
-The algorithm cannot be changed after initialization.
-
-Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process
-frames, use `ma_resampler_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number of
-input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the
-number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large
-buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.
-
-The sample rate can be changed dynamically on the fly. You can change this with explicit sample rates with `ma_resampler_set_rate()` and also with a decimal
-ratio with `ma_resampler_set_rate_ratio()`. The ratio is in/out.
-
-Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with
-`ma_resampler_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of
-input frames. You can do this with `ma_resampler_get_expected_output_frame_count()`.
-
-Due to the nature of how resampling works, the resampler introduces some latency. This can be retrieved in terms of both the input rate and the output rate
-with `ma_resampler_get_input_latency()` and `ma_resampler_get_output_latency()`.
-
-
-6.3.1. Resampling Algorithms
-----------------------------
-The choice of resampling algorithm depends on your situation and requirements. The linear resampler is the most efficient and has the least amount of latency,
-but at the expense of poorer quality. The Speex resampler is higher quality, but slower with more latency. It also performs several heap allocations internally
-for memory management.
-
-
-6.3.1.1. Linear Resampling
---------------------------
-The linear resampler is the fastest, but comes at the expense of poorer quality. There is, however, some control over the quality of the linear resampler which
-may make it a suitable option depending on your requirements.
-
-The linear resampler performs low-pass filtering before or after downsampling or upsampling, depending on the sample rates you're converting between. When
-decreasing the sample rate, the low-pass filter will be applied before downsampling. When increasing the rate it will be performed after upsampling. By default
-a fourth order low-pass filter will be applied. This can be configured via the `lpfOrder` configuration variable. Setting this to 0 will disable filtering.
-
-The low-pass filter has a cutoff frequency which defaults to half the sample rate of the lowest of the input and output sample rates (Nyquist Frequency). This
-can be controlled with the `lpfNyquistFactor` config variable. This defaults to 1, and should be in the range of 0..1, although a value of 0 does not make
-sense and should be avoided. A value of 1 will use the Nyquist Frequency as the cutoff. A value of 0.5 will use half the Nyquist Frequency as the cutoff, etc.
-Values less than 1 will result in more washed out sound due to more of the higher frequencies being removed. This config variable has no impact on performance
-and is a purely perceptual configuration.
-
-The API for the linear resampler is the same as the main resampler API, only it's called `ma_linear_resampler`.
-
-
-6.3.1.2. Speex Resampling
--------------------------
-The Speex resampler is made up of third party code which is released under the BSD license. Because it is licensed differently to miniaudio, which is public
-domain, it is strictly opt-in and all of it's code is stored in separate files. If you opt-in to the Speex resampler you must consider the license text in it's
-source files. To opt-in, you must first `#include` the following file before the implementation of miniaudio.h:
-
-    ```c
-    #include "extras/speex_resampler/ma_speex_resampler.h"
-    ```
-
-Both the header and implementation is contained within the same file. The implementation can be included in your program like so:
-
-    ```c
-    #define MINIAUDIO_SPEEX_RESAMPLER_IMPLEMENTATION
-    #include "extras/speex_resampler/ma_speex_resampler.h"
-    ```
-
-Note that even if you opt-in to the Speex backend, miniaudio won't use it unless you explicitly ask for it in the respective config of the object you are
-initializing. If you try to use the Speex resampler without opting in, initialization of the `ma_resampler` object will fail with `MA_NO_BACKEND`.
-
-The only configuration option to consider with the Speex resampler is the `speex.quality` config variable. This is a value between 0 and 10, with 0 being
-the fastest with the poorest quality and 10 being the slowest with the highest quality. The default value is 3.
-
-
-
-6.4. General Data Conversion
-----------------------------
-The `ma_data_converter` API can be used to wrap sample format conversion, channel conversion and resampling into one operation. This is what miniaudio uses
-internally to convert between the format requested when the device was initialized and the format of the backend's native device. The API for general data
-conversion is very similar to the resampling API. Create a `ma_data_converter` object like this:
-
-    ```c
-    ma_data_converter_config config = ma_data_converter_config_init(
-        inputFormat,
-        outputFormat,
-        inputChannels,
-        outputChannels,
-        inputSampleRate,
-        outputSampleRate
-    );
-
-    ma_data_converter converter;
-    ma_result result = ma_data_converter_init(&config, &converter);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-    ```
-
-In the example above we use `ma_data_converter_config_init()` to initialize the config, however there's many more properties that can be configured, such as
-channel maps and resampling quality. Something like the following may be more suitable depending on your requirements:
-
-    ```c
-    ma_data_converter_config config = ma_data_converter_config_init_default();
-    config.formatIn = inputFormat;
-    config.formatOut = outputFormat;
-    config.channelsIn = inputChannels;
-    config.channelsOut = outputChannels;
-    config.sampleRateIn = inputSampleRate;
-    config.sampleRateOut = outputSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_flac, config.channelCountIn, config.channelMapIn);
-    config.resampling.linear.lpfOrder = MA_MAX_FILTER_ORDER;
-    ```
-
-Do the following to uninitialize the data converter:
-
-    ```c
-    ma_data_converter_uninit(&converter);
-    ```
-
-The following example shows how data can be processed
-
-    ```c
-    ma_uint64 frameCountIn  = 1000;
-    ma_uint64 frameCountOut = 2000;
-    ma_result result = ma_data_converter_process_pcm_frames(&converter, pFramesIn, &frameCountIn, pFramesOut, &frameCountOut);
-    if (result != MA_SUCCESS) {
-        // An error occurred...
-    }
-
-    // At this point, frameCountIn contains the number of input frames that were consumed and frameCountOut contains the number
-    // of output frames written.
-    ```
-
-The data converter supports multiple channels and is always interleaved (both input and output). The channel count cannot be changed after initialization.
-
-Sample rates can be anything other than zero, and are always specified in hertz. They should be set to something like 44100, etc. The sample rate is the only
-configuration property that can be changed after initialization, but only if the `resampling.allowDynamicSampleRate` member of `ma_data_converter_config` is
-set to `MA_TRUE`. To change the sample rate, use `ma_data_converter_set_rate()` or `ma_data_converter_set_rate_ratio()`. The ratio must be in/out. The
-resampling algorithm cannot be changed after initialization.
-
-Processing always happens on a per PCM frame basis and always assumes interleaved input and output. De-interleaved processing is not supported. To process
-frames, use `ma_data_converter_process_pcm_frames()`. On input, this function takes the number of output frames you can fit in the output buffer and the number
-of input frames contained in the input buffer. On output these variables contain the number of output frames that were written to the output buffer and the
-number of input frames that were consumed in the process. You can pass in NULL for the input buffer in which case it will be treated as an infinitely large
-buffer of zeros. The output buffer can also be NULL, in which case the processing will be treated as seek.
-
-Sometimes it's useful to know exactly how many input frames will be required to output a specific number of frames. You can calculate this with
-`ma_data_converter_get_required_input_frame_count()`. Likewise, it's sometimes useful to know exactly how many frames would be output given a certain number of
-input frames. You can do this with `ma_data_converter_get_expected_output_frame_count()`.
-
-Due to the nature of how resampling works, the data converter introduces some latency if resampling is required. This can be retrieved in terms of both the
-input rate and the output rate with `ma_data_converter_get_input_latency()` and `ma_data_converter_get_output_latency()`.
-
-
-
-7. Filtering
-============
-
-7.1. Biquad Filtering
----------------------
-Biquad filtering is achieved with the `ma_biquad` API. Example:
-
-    ```c
-    ma_biquad_config config = ma_biquad_config_init(ma_format_f32, channels, b0, b1, b2, a0, a1, a2);
-    ma_result result = ma_biquad_init(&config, &biquad);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_biquad_process_pcm_frames(&biquad, pFramesOut, pFramesIn, frameCount);
-    ```
-
-Biquad filtering is implemented using transposed direct form 2. The numerator coefficients are b0, b1 and b2, and the denominator coefficients are a0, a1 and
-a2. The a0 coefficient is required and coefficients must not be pre-normalized.
-
-Supported formats are `ma_format_s16` and `ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. When using
-`ma_format_s16` the biquad filter will use fixed point arithmetic. When using `ma_format_f32`, floating point arithmetic will be used.
-
-Input and output frames are always interleaved.
-
-Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:
-
-    ```c
-    ma_biquad_process_pcm_frames(&biquad, pMyData, pMyData, frameCount);
-    ```
-
-If you need to change the values of the coefficients, but maintain the values in the registers you can do so with `ma_biquad_reinit()`. This is useful if you
-need to change the properties of the filter while keeping the values of registers valid to avoid glitching. Do not use `ma_biquad_init()` for this as it will
-do a full initialization which involves clearing the registers to 0. Note that changing the format or channel count after initialization is invalid and will
-result in an error.
-
-
-7.2. Low-Pass Filtering
------------------------
-Low-pass filtering is achieved with the following APIs:
-
-    +---------+------------------------------------------+
-    | API     | Description                              |
-    +---------+------------------------------------------+
-    | ma_lpf1 | First order low-pass filter              |
-    | ma_lpf2 | Second order low-pass filter             |
-    | ma_lpf  | High order low-pass filter (Butterworth) |
-    +---------+------------------------------------------+
-
-Low-pass filter example:
-
-    ```c
-    ma_lpf_config config = ma_lpf_config_init(ma_format_f32, channels, sampleRate, cutoffFrequency, order);
-    ma_result result = ma_lpf_init(&config, &lpf);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_lpf_process_pcm_frames(&lpf, pFramesOut, pFramesIn, frameCount);
-    ```
-
-Supported formats are `ma_format_s16` and` ma_format_f32`. If you need to use a different format you need to convert it yourself beforehand. Input and output
-frames are always interleaved.
-
-Filtering can be applied in-place by passing in the same pointer for both the input and output buffers, like so:
-
-    ```c
-    ma_lpf_process_pcm_frames(&lpf, pMyData, pMyData, frameCount);
-    ```
-
-The maximum filter order is limited to `MA_MAX_FILTER_ORDER` which is set to 8. If you need more, you can chain first and second order filters together.
-
-    ```c
-    for (iFilter = 0; iFilter < filterCount; iFilter += 1) {
-        ma_lpf2_process_pcm_frames(&lpf2[iFilter], pMyData, pMyData, frameCount);
-    }
-    ```
-
-If you need to change the configuration of the filter, but need to maintain the state of internal registers you can do so with `ma_lpf_reinit()`. This may be
-useful if you need to change the sample rate and/or cutoff frequency dynamically while maintaing smooth transitions. Note that changing the format or channel
-count after initialization is invalid and will result in an error.
-
-The `ma_lpf` object supports a configurable order, but if you only need a first order filter you may want to consider using `ma_lpf1`. Likewise, if you only
-need a second order filter you can use `ma_lpf2`. The advantage of this is that they're lighter weight and a bit more efficient.
-
-If an even filter order is specified, a series of second order filters will be processed in a chain. If an odd filter order is specified, a first order filter
-will be applied, followed by a series of second order filters in a chain.
-
-
-7.3. High-Pass Filtering
-------------------------
-High-pass filtering is achieved with the following APIs:
-
-    +---------+-------------------------------------------+
-    | API     | Description                               |
-    +---------+-------------------------------------------+
-    | ma_hpf1 | First order high-pass filter              |
-    | ma_hpf2 | Second order high-pass filter             |
-    | ma_hpf  | High order high-pass filter (Butterworth) |
-    +---------+-------------------------------------------+
-
-High-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_hpf1`, `ma_hpf2` and `ma_hpf`. See example code for low-pass filters
-for example usage.
-
-
-7.4. Band-Pass Filtering
-------------------------
-Band-pass filtering is achieved with the following APIs:
-
-    +---------+-------------------------------+
-    | API     | Description                   |
-    +---------+-------------------------------+
-    | ma_bpf2 | Second order band-pass filter |
-    | ma_bpf  | High order band-pass filter   |
-    +---------+-------------------------------+
-
-Band-pass filters work exactly the same as low-pass filters, only the APIs are called `ma_bpf2` and `ma_hpf`. See example code for low-pass filters for example
-usage. Note that the order for band-pass filters must be an even number which means there is no first order band-pass filter, unlike low-pass and high-pass
-filters.
-
-
-7.5. Notch Filtering
---------------------
-Notch filtering is achieved with the following APIs:
-
-    +-----------+------------------------------------------+
-    | API       | Description                              |
-    +-----------+------------------------------------------+
-    | ma_notch2 | Second order notching filter             |
-    +-----------+------------------------------------------+
-
-
-7.6. Peaking EQ Filtering
--------------------------
-Peaking filtering is achieved with the following APIs:
-
-    +----------+------------------------------------------+
-    | API      | Description                              |
-    +----------+------------------------------------------+
-    | ma_peak2 | Second order peaking filter              |
-    +----------+------------------------------------------+
-
-
-7.7. Low Shelf Filtering
-------------------------
-Low shelf filtering is achieved with the following APIs:
-
-    +-------------+------------------------------------------+
-    | API         | Description                              |
-    +-------------+------------------------------------------+
-    | ma_loshelf2 | Second order low shelf filter            |
-    +-------------+------------------------------------------+
-
-Where a high-pass filter is used to eliminate lower frequencies, a low shelf filter can be used to just turn them down rather than eliminate them entirely.
-
-
-7.8. High Shelf Filtering
--------------------------
-High shelf filtering is achieved with the following APIs:
-
-    +-------------+------------------------------------------+
-    | API         | Description                              |
-    +-------------+------------------------------------------+
-    | ma_hishelf2 | Second order high shelf filter           |
-    +-------------+------------------------------------------+
-
-The high shelf filter has the same API as the low shelf filter, only you would use `ma_hishelf` instead of `ma_loshelf`. Where a low shelf filter is used to
-adjust the volume of low frequencies, the high shelf filter does the same thing for high frequencies.
-
-
-
-
-8. Waveform and Noise Generation
-================================
-
-8.1. Waveforms
---------------
-miniaudio supports generation of sine, square, triangle and sawtooth waveforms. This is achieved with the `ma_waveform` API. Example:
-
-    ```c
-    ma_waveform_config config = ma_waveform_config_init(
-        FORMAT,
-        CHANNELS,
-        SAMPLE_RATE,
-        ma_waveform_type_sine,
-        amplitude,
-        frequency);
-
-    ma_waveform waveform;
-    ma_result result = ma_waveform_init(&config, &waveform);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_waveform_read_pcm_frames(&waveform, pOutput, frameCount);
-    ```
-
-The amplitude, frequency, type, and sample rate can be changed dynamically with `ma_waveform_set_amplitude()`, `ma_waveform_set_frequency()`,
-`ma_waveform_set_type()`, and `ma_waveform_set_sample_rate()` respectively.
-
-You can invert the waveform by setting the amplitude to a negative value. You can use this to control whether or not a sawtooth has a positive or negative
-ramp, for example.
-
-Below are the supported waveform types:
-
-    +---------------------------+
-    | Enum Name                 |
-    +---------------------------+
-    | ma_waveform_type_sine     |
-    | ma_waveform_type_square   |
-    | ma_waveform_type_triangle |
-    | ma_waveform_type_sawtooth |
-    +---------------------------+
-
-
-
-8.2. Noise
-----------
-miniaudio supports generation of white, pink and Brownian noise via the `ma_noise` API. Example:
-
-    ```c
-    ma_noise_config config = ma_noise_config_init(
-        FORMAT,
-        CHANNELS,
-        ma_noise_type_white,
-        SEED,
-        amplitude);
-
-    ma_noise noise;
-    ma_result result = ma_noise_init(&config, &noise);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_noise_read_pcm_frames(&noise, pOutput, frameCount);
-    ```
-
-The noise API uses simple LCG random number generation. It supports a custom seed which is useful for things like automated testing requiring reproducibility.
-Setting the seed to zero will default to `MA_DEFAULT_LCG_SEED`.
-
-The amplitude, seed, and type can be changed dynamically with `ma_noise_set_amplitude()`, `ma_noise_set_seed()`, and `ma_noise_set_type()` respectively.
-
-By default, the noise API will use different values for different channels. So, for example, the left side in a stereo stream will be different to the right
-side. To instead have each channel use the same random value, set the `duplicateChannels` member of the noise config to true, like so:
-
-    ```c
-    config.duplicateChannels = MA_TRUE;
-    ```
-
-Below are the supported noise types.
-
-    +------------------------+
-    | Enum Name              |
-    +------------------------+
-    | ma_noise_type_white    |
-    | ma_noise_type_pink     |
-    | ma_noise_type_brownian |
-    +------------------------+
-
-
-
-9. Audio Buffers
-================
-miniaudio supports reading from a buffer of raw audio data via the `ma_audio_buffer` API. This can read from memory that's managed by the application, but
-can also handle the memory management for you internally. Memory management is flexible and should support most use cases.
-
-Audio buffers are initialised using the standard configuration system used everywhere in miniaudio:
-
-    ```c
-    ma_audio_buffer_config config = ma_audio_buffer_config_init(
-        format,
-        channels,
-        sizeInFrames,
-        pExistingData,
-        &allocationCallbacks);
-
-    ma_audio_buffer buffer;
-    result = ma_audio_buffer_init(&config, &buffer);
-    if (result != MA_SUCCESS) {
-        // Error.
-    }
-
-    ...
-
-    ma_audio_buffer_uninit(&buffer);
-    ```
-
-In the example above, the memory pointed to by `pExistingData` will *not* be copied and is how an application can do self-managed memory allocation. If you
-would rather make a copy of the data, use `ma_audio_buffer_init_copy()`. To uninitialize the buffer, use `ma_audio_buffer_uninit()`.
-
-Sometimes it can be convenient to allocate the memory for the `ma_audio_buffer` structure and the raw audio data in a contiguous block of memory. That is,
-the raw audio data will be located immediately after the `ma_audio_buffer` structure. To do this, use `ma_audio_buffer_alloc_and_init()`:
-
-    ```c
-    ma_audio_buffer_config config = ma_audio_buffer_config_init(
-        format,
-        channels,
-        sizeInFrames,
-        pExistingData,
-        &allocationCallbacks);
-
-    ma_audio_buffer* pBuffer
-    result = ma_audio_buffer_alloc_and_init(&config, &pBuffer);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-
-    ...
-
-    ma_audio_buffer_uninit_and_free(&buffer);
-    ```
-
-If you initialize the buffer with `ma_audio_buffer_alloc_and_init()` you should uninitialize it with `ma_audio_buffer_uninit_and_free()`. In the example above,
-the memory pointed to by `pExistingData` will be copied into the buffer, which is contrary to the behavior of `ma_audio_buffer_init()`.
-
-An audio buffer has a playback cursor just like a decoder. As you read frames from the buffer, the cursor moves forward. The last parameter (`loop`) can be
-used to determine if the buffer should loop. The return value is the number of frames actually read. If this is less than the number of frames requested it
-means the end has been reached. This should never happen if the `loop` parameter is set to true. If you want to manually loop back to the start, you can do so
-with with `ma_audio_buffer_seek_to_pcm_frame(pAudioBuffer, 0)`. Below is an example for reading data from an audio buffer.
-
-    ```c
-    ma_uint64 framesRead = ma_audio_buffer_read_pcm_frames(pAudioBuffer, pFramesOut, desiredFrameCount, isLooping);
-    if (framesRead < desiredFrameCount) {
-        // If not looping, this means the end has been reached. This should never happen in looping mode with valid input.
-    }
-    ```
-
-Sometimes you may want to avoid the cost of data movement between the internal buffer and the output buffer. Instead you can use memory mapping to retrieve a
-pointer to a segment of data:
-
-    ```c
-    void* pMappedFrames;
-    ma_uint64 frameCount = frameCountToTryMapping;
-    ma_result result = ma_audio_buffer_map(pAudioBuffer, &pMappedFrames, &frameCount);
-    if (result == MA_SUCCESS) {
-        // Map was successful. The value in frameCount will be how many frames were _actually_ mapped, which may be
-        // less due to the end of the buffer being reached.
-        ma_copy_pcm_frames(pFramesOut, pMappedFrames, frameCount, pAudioBuffer->format, pAudioBuffer->channels);
-
-        // You must unmap the buffer.
-        ma_audio_buffer_unmap(pAudioBuffer, frameCount);
-    }
-    ```
-
-When you use memory mapping, the read cursor is increment by the frame count passed in to `ma_audio_buffer_unmap()`. If you decide not to process every frame
-you can pass in a value smaller than the value returned by `ma_audio_buffer_map()`. The disadvantage to using memory mapping is that it does not handle looping
-for you. You can determine if the buffer is at the end for the purpose of looping with `ma_audio_buffer_at_end()` or by inspecting the return value of
-`ma_audio_buffer_unmap()` and checking if it equals `MA_AT_END`. You should not treat `MA_AT_END` as an error when returned by `ma_audio_buffer_unmap()`.
-
-
-
-10. Ring Buffers
-================
-miniaudio supports lock free (single producer, single consumer) ring buffers which are exposed via the `ma_rb` and `ma_pcm_rb` APIs. The `ma_rb` API operates
-on bytes, whereas the `ma_pcm_rb` operates on PCM frames. They are otherwise identical as `ma_pcm_rb` is just a wrapper around `ma_rb`.
-
-Unlike most other APIs in miniaudio, ring buffers support both interleaved and deinterleaved streams. The caller can also allocate their own backing memory for
-the ring buffer to use internally for added flexibility. Otherwise the ring buffer will manage it's internal memory for you.
-
-The examples below use the PCM frame variant of the ring buffer since that's most likely the one you will want to use. To initialize a ring buffer, do
-something like the following:
-
-    ```c
-    ma_pcm_rb rb;
-    ma_result result = ma_pcm_rb_init(FORMAT, CHANNELS, BUFFER_SIZE_IN_FRAMES, NULL, NULL, &rb);
-    if (result != MA_SUCCESS) {
-        // Error
-    }
-    ```
-
-The `ma_pcm_rb_init()` function takes the sample format and channel count as parameters because it's the PCM varient of the ring buffer API. For the regular
-ring buffer that operates on bytes you would call `ma_rb_init()` which leaves these out and just takes the size of the buffer in bytes instead of frames. The
-fourth parameter is an optional pre-allocated buffer and the fifth parameter is a pointer to a `ma_allocation_callbacks` structure for custom memory allocation
-routines. Passing in `NULL` for this results in `MA_MALLOC()` and `MA_FREE()` being used.
-
-Use `ma_pcm_rb_init_ex()` if you need a deinterleaved buffer. The data for each sub-buffer is offset from each other based on the stride. To manage your
-sub-buffers you can use `ma_pcm_rb_get_subbuffer_stride()`, `ma_pcm_rb_get_subbuffer_offset()` and `ma_pcm_rb_get_subbuffer_ptr()`.
-
-Use `ma_pcm_rb_acquire_read()` and `ma_pcm_rb_acquire_write()` to retrieve a pointer to a section of the ring buffer. You specify the number of frames you
-need, and on output it will set to what was actually acquired. If the read or write pointer is positioned such that the number of frames requested will require
-a loop, it will be clamped to the end of the buffer. Therefore, the number of frames you're given may be less than the number you requested.
-
-After calling `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()`, you do your work on the buffer and then "commit" it with `ma_pcm_rb_commit_read()` or
-`ma_pcm_rb_commit_write()`. This is where the read/write pointers are updated. When you commit you need to pass in the buffer that was returned by the earlier
-call to `ma_pcm_rb_acquire_read()` or `ma_pcm_rb_acquire_write()` and is only used for validation. The number of frames passed to `ma_pcm_rb_commit_read()` and
-`ma_pcm_rb_commit_write()` is what's used to increment the pointers, and can be less that what was originally requested.
-
-If you want to correct for drift between the write pointer and the read pointer you can use a combination of `ma_pcm_rb_pointer_distance()`,
-`ma_pcm_rb_seek_read()` and `ma_pcm_rb_seek_write()`. Note that you can only move the pointers forward, and you should only move the read pointer forward via
-the consumer thread, and the write pointer forward by the producer thread. If there is too much space between the pointers, move the read pointer forward. If
-there is too little space between the pointers, move the write pointer forward.
-
-You can use a ring buffer at the byte level instead of the PCM frame level by using the `ma_rb` API. This is exactly the same, only you will use the `ma_rb`
-functions instead of `ma_pcm_rb` and instead of frame counts you will pass around byte counts.
-
-The maximum size of the buffer in bytes is `0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1)` due to the most significant bit being used to encode a loop flag and the internally
-managed buffers always being aligned to MA_SIMD_ALIGNMENT.
-
-Note that the ring buffer is only thread safe when used by a single consumer thread and single producer thread.
-
-
-
-11. Backends
-============
-The following backends are supported by miniaudio.
-
-    +-------------+-----------------------+--------------------------------------------------------+
-    | Name        | Enum Name             | Supported Operating Systems                            |
-    +-------------+-----------------------+--------------------------------------------------------+
-    | WASAPI      | ma_backend_wasapi     | Windows Vista+                                         |
-    | DirectSound | ma_backend_dsound     | Windows XP+                                            |
-    | WinMM       | ma_backend_winmm      | Windows XP+ (may work on older versions, but untested) |
-    | Core Audio  | ma_backend_coreaudio  | macOS, iOS                                             |
-    | ALSA        | ma_backend_alsa       | Linux                                                  |
-    | PulseAudio  | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android)  |
-    | JACK        | ma_backend_jack       | Cross Platform (disabled on BSD and Android)           |
-    | sndio       | ma_backend_sndio      | OpenBSD                                                |
-    | audio(4)    | ma_backend_audio4     | NetBSD, OpenBSD                                        |
-    | OSS         | ma_backend_oss        | FreeBSD                                                |
-    | AAudio      | ma_backend_aaudio     | Android 8+                                             |
-    | OpenSL ES   | ma_backend_opensl     | Android (API level 16+)                                |
-    | Web Audio   | ma_backend_webaudio   | Web (via Emscripten)                                   |
-    | Custom      | ma_backend_custom     | Cross Platform                                         |
-    | Null        | ma_backend_null       | Cross Platform (not used on Web)                       |
-    +-------------+-----------------------+--------------------------------------------------------+
-
-Some backends have some nuance details you may want to be aware of.
-
-11.1. WASAPI
-------------
-- Low-latency shared mode will be disabled when using an application-defined sample rate which is different to the device's native sample rate. To work around
-  this, set `wasapi.noAutoConvertSRC` to true in the device config. This is due to IAudioClient3_InitializeSharedAudioStream() failing when the
-  `AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM` flag is specified. Setting wasapi.noAutoConvertSRC will result in miniaudio's internal resampler being used instead
-  which will in turn enable the use of low-latency shared mode.
-
-11.2. PulseAudio
-----------------
-- If you experience bad glitching/noise on Arch Linux, consider this fix from the Arch wiki:
-  https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Glitches,_skips_or_crackling. Alternatively, consider using a different backend such as ALSA.
-
-11.3. Android
--------------
-- To capture audio on Android, remember to add the RECORD_AUDIO permission to your manifest: `<uses-permission android:name="android.permission.RECORD_AUDIO" />`
-- With OpenSL|ES, only a single ma_context can be active at any given time. This is due to a limitation with OpenSL|ES.
-- With AAudio, only default devices are enumerated. This is due to AAudio not having an enumeration API (devices are enumerated through Java). You can however
-  perform your own device enumeration through Java and then set the ID in the ma_device_id structure (ma_device_id.aaudio) and pass it to ma_device_init().
-- The backend API will perform resampling where possible. The reason for this as opposed to using miniaudio's built-in resampler is to take advantage of any
-  potential device-specific optimizations the driver may implement.
-
-11.4. UWP
----------
-- UWP only supports default playback and capture devices.
-- UWP requires the Microphone capability to be enabled in the application's manifest (Package.appxmanifest):
-
-    ```
-    <Package ...>
-        ...
-        <Capabilities>
-            <DeviceCapability Name="microphone" />
-        </Capabilities>
-    </Package>
-    ```
-
-11.5. Web Audio / Emscripten
-----------------------------
-- You cannot use `-std=c*` compiler flags, nor `-ansi`. This only applies to the Emscripten build.
-- The first time a context is initialized it will create a global object called "miniaudio" whose primary purpose is to act as a factory for device objects.
-- Currently the Web Audio backend uses ScriptProcessorNode's, but this may need to change later as they've been deprecated.
-- Google has implemented a policy in their browsers that prevent automatic media output without first receiving some kind of user input. The following web page
-  has additional details: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes. Starting the device may fail if you try to start playback
-  without first handling some kind of user input.
-
-
-
-12. Miscellaneous Notes
-=======================
-- Automatic stream routing is enabled on a per-backend basis. Support is explicitly enabled for WASAPI and Core Audio, however other backends such as
-  PulseAudio may naturally support it, though not all have been tested.
-- The contents of the output buffer passed into the data callback will always be pre-initialized to silence unless the `noPreZeroedOutputBuffer` config variable
-  in `ma_device_config` is set to true, in which case it'll be undefined which will require you to write something to the entire buffer.
-- By default miniaudio will automatically clip samples. This only applies when the playback sample format is configured as `ma_format_f32`. If you are doing
-  clipping yourself, you can disable this overhead by setting `noClip` to true in the device config.
-- The sndio backend is currently only enabled on OpenBSD builds.
-- The audio(4) backend is supported on OpenBSD, but you may need to disable sndiod before you can use it.
-- Note that GCC and Clang requires `-msse2`, `-mavx2`, etc. for SIMD optimizations.
-- When compiling with VC6 and earlier, decoding is restricted to files less than 2GB in size. This is due to 64-bit file APIs not being available.
-*/
-
-#ifndef miniaudio_h
-#define miniaudio_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MA_STRINGIFY(x)     #x
-#define MA_XSTRINGIFY(x)    MA_STRINGIFY(x)
-
-#define MA_VERSION_MAJOR    0
-#define MA_VERSION_MINOR    10
-#define MA_VERSION_REVISION 33
-#define MA_VERSION_STRING   MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
-
-#if defined(_MSC_VER) && !defined(__clang__)
-    #pragma warning(push)
-    #pragma warning(disable:4201)   /* nonstandard extension used: nameless struct/union */
-    #pragma warning(disable:4214)   /* nonstandard extension used: bit field types other than int */
-    #pragma warning(disable:4324)   /* structure was padded due to alignment specifier */
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wpedantic" /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
-    #if defined(__clang__)
-        #pragma GCC diagnostic ignored "-Wc11-extensions"   /* anonymous unions are a C11 extension */
-    #endif
-#endif
-
-/* Platform/backend detection. */
-#ifdef _WIN32
-    #define MA_WIN32
-    #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
-        #define MA_WIN32_UWP
-    #else
-        #define MA_WIN32_DESKTOP
-    #endif
-#else
-    #define MA_POSIX
-    #include <pthread.h>    /* Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. */
-
-    #ifdef __unix__
-        #define MA_UNIX
-        #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
-            #define MA_BSD
-        #endif
-    #endif
-    #ifdef __linux__
-        #define MA_LINUX
-    #endif
-    #ifdef __APPLE__
-        #define MA_APPLE
-    #endif
-    #ifdef __ANDROID__
-        #define MA_ANDROID
-    #endif
-    #ifdef __EMSCRIPTEN__
-        #define MA_EMSCRIPTEN
-    #endif
-#endif
-
-#include <stddef.h> /* For size_t. */
-
-/* Sized types. */
-typedef   signed char           ma_int8;
-typedef unsigned char           ma_uint8;
-typedef   signed short          ma_int16;
-typedef unsigned short          ma_uint16;
-typedef   signed int            ma_int32;
-typedef unsigned int            ma_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    ma_int64;
-    typedef unsigned __int64    ma_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  ma_int64;
-    typedef unsigned long long  ma_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef ma_uint64           ma_uintptr;
-#else
-    typedef ma_uint32           ma_uintptr;
-#endif
-
-typedef ma_uint8    ma_bool8;
-typedef ma_uint32   ma_bool32;
-#define MA_TRUE     1
-#define MA_FALSE    0
-
-typedef void* ma_handle;
-typedef void* ma_ptr;
-typedef void (* ma_proc)(void);
-
-#if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED)
-typedef ma_uint16 wchar_t;
-#endif
-
-/* Define NULL for some compilers. */
-#ifndef NULL
-#define NULL 0
-#endif
-
-#if defined(SIZE_MAX)
-    #define MA_SIZE_MAX    SIZE_MAX
-#else
-    #define MA_SIZE_MAX    0xFFFFFFFF  /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */
-#endif
-
-
-#ifdef _MSC_VER
-    #define MA_INLINE __forceinline
-#elif defined(__GNUC__)
-    /*
-    I've had a bug report where GCC is emitting warnings about functions possibly not being inlineable. This warning happens when
-    the __attribute__((always_inline)) attribute is defined without an "inline" statement. I think therefore there must be some
-    case where "__inline__" is not always defined, thus the compiler emitting these warnings. When using -std=c89 or -ansi on the
-    command line, we cannot use the "inline" keyword and instead need to use "__inline__". In an attempt to work around this issue
-    I am using "__inline__" only when we're compiling in strict ANSI mode.
-    */
-    #if defined(__STRICT_ANSI__)
-        #define MA_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define MA_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define MA_INLINE __inline
-#else
-    #define MA_INLINE
-#endif
-
-#if !defined(MA_API)
-    #if defined(MA_DLL)
-        #if defined(_WIN32)
-            #define MA_DLL_IMPORT  __declspec(dllimport)
-            #define MA_DLL_EXPORT  __declspec(dllexport)
-            #define MA_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define MA_DLL_IMPORT  __attribute__((visibility("default")))
-                #define MA_DLL_EXPORT  __attribute__((visibility("default")))
-                #define MA_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define MA_DLL_IMPORT
-                #define MA_DLL_EXPORT
-                #define MA_DLL_PRIVATE static
-            #endif
-        #endif
-
-        #if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION)
-            #define MA_API  MA_DLL_EXPORT
-        #else
-            #define MA_API  MA_DLL_IMPORT
-        #endif
-        #define MA_PRIVATE MA_DLL_PRIVATE
-    #else
-        #define MA_API extern
-        #define MA_PRIVATE static
-    #endif
-#endif
-
-/* SIMD alignment in bytes. Currently set to 64 bytes in preparation for future AVX-512 optimizations. */
-#define MA_SIMD_ALIGNMENT  64
-
-
-/*
-Logging Levels
-==============
-A log level will automatically include the lower levels. For example, verbose logging will enable everything. The warning log level will only include warnings
-and errors, but will ignore informational and verbose logging. If you only want to handle a specific log level, implement a custom log callback (see
-ma_context_init() for details) and interrogate the `logLevel` parameter.
-
-By default the log level will be set to MA_LOG_LEVEL_ERROR, but you can change this by defining MA_LOG_LEVEL before the implementation of miniaudio.
-
-MA_LOG_LEVEL_VERBOSE
-    Mainly intended for debugging. This will enable all log levels and can be triggered from within the data callback so care must be taken when enabling this
-    in production environments.
-
-MA_LOG_LEVEL_INFO
-    Informational logging. Useful for debugging. This will also enable warning and error logs. This will never be called from within the data callback.
-
-MA_LOG_LEVEL_WARNING
-    Warnings. You should enable this in you development builds and action them when encounted. This will also enable error logs. These logs usually indicate a
-    potential problem or misconfiguration, but still allow you to keep running. This will never be called from within the data callback.
-
-MA_LOG_LEVEL_ERROR
-    Error logging. This will be fired when an operation fails and is subsequently aborted. This can be fired from within the data callback, in which case the
-    device will be stopped. You should always have this log level enabled.
-*/
-#define MA_LOG_LEVEL_VERBOSE   4
-#define MA_LOG_LEVEL_INFO      3
-#define MA_LOG_LEVEL_WARNING   2
-#define MA_LOG_LEVEL_ERROR     1
-
-#ifndef MA_LOG_LEVEL
-#define MA_LOG_LEVEL           MA_LOG_LEVEL_ERROR
-#endif
-
-/*
-An annotation for variables which must be used atomically. This doesn't actually do anything - it's
-just used as a way for humans to identify variables that should be used atomically.
-*/
-#define MA_ATOMIC
-
-typedef struct ma_context ma_context;
-typedef struct ma_device ma_device;
-
-typedef ma_uint8 ma_channel;
-#define MA_CHANNEL_NONE                                0
-#define MA_CHANNEL_MONO                                1
-#define MA_CHANNEL_FRONT_LEFT                          2
-#define MA_CHANNEL_FRONT_RIGHT                         3
-#define MA_CHANNEL_FRONT_CENTER                        4
-#define MA_CHANNEL_LFE                                 5
-#define MA_CHANNEL_BACK_LEFT                           6
-#define MA_CHANNEL_BACK_RIGHT                          7
-#define MA_CHANNEL_FRONT_LEFT_CENTER                   8
-#define MA_CHANNEL_FRONT_RIGHT_CENTER                  9
-#define MA_CHANNEL_BACK_CENTER                         10
-#define MA_CHANNEL_SIDE_LEFT                           11
-#define MA_CHANNEL_SIDE_RIGHT                          12
-#define MA_CHANNEL_TOP_CENTER                          13
-#define MA_CHANNEL_TOP_FRONT_LEFT                      14
-#define MA_CHANNEL_TOP_FRONT_CENTER                    15
-#define MA_CHANNEL_TOP_FRONT_RIGHT                     16
-#define MA_CHANNEL_TOP_BACK_LEFT                       17
-#define MA_CHANNEL_TOP_BACK_CENTER                     18
-#define MA_CHANNEL_TOP_BACK_RIGHT                      19
-#define MA_CHANNEL_AUX_0                               20
-#define MA_CHANNEL_AUX_1                               21
-#define MA_CHANNEL_AUX_2                               22
-#define MA_CHANNEL_AUX_3                               23
-#define MA_CHANNEL_AUX_4                               24
-#define MA_CHANNEL_AUX_5                               25
-#define MA_CHANNEL_AUX_6                               26
-#define MA_CHANNEL_AUX_7                               27
-#define MA_CHANNEL_AUX_8                               28
-#define MA_CHANNEL_AUX_9                               29
-#define MA_CHANNEL_AUX_10                              30
-#define MA_CHANNEL_AUX_11                              31
-#define MA_CHANNEL_AUX_12                              32
-#define MA_CHANNEL_AUX_13                              33
-#define MA_CHANNEL_AUX_14                              34
-#define MA_CHANNEL_AUX_15                              35
-#define MA_CHANNEL_AUX_16                              36
-#define MA_CHANNEL_AUX_17                              37
-#define MA_CHANNEL_AUX_18                              38
-#define MA_CHANNEL_AUX_19                              39
-#define MA_CHANNEL_AUX_20                              40
-#define MA_CHANNEL_AUX_21                              41
-#define MA_CHANNEL_AUX_22                              42
-#define MA_CHANNEL_AUX_23                              43
-#define MA_CHANNEL_AUX_24                              44
-#define MA_CHANNEL_AUX_25                              45
-#define MA_CHANNEL_AUX_26                              46
-#define MA_CHANNEL_AUX_27                              47
-#define MA_CHANNEL_AUX_28                              48
-#define MA_CHANNEL_AUX_29                              49
-#define MA_CHANNEL_AUX_30                              50
-#define MA_CHANNEL_AUX_31                              51
-#define MA_CHANNEL_LEFT                                MA_CHANNEL_FRONT_LEFT
-#define MA_CHANNEL_RIGHT                               MA_CHANNEL_FRONT_RIGHT
-#define MA_CHANNEL_POSITION_COUNT                      (MA_CHANNEL_AUX_31 + 1)
-
-
-typedef int ma_result;
-#define MA_SUCCESS                                      0
-#define MA_ERROR                                       -1   /* A generic error. */
-#define MA_INVALID_ARGS                                -2
-#define MA_INVALID_OPERATION                           -3
-#define MA_OUT_OF_MEMORY                               -4
-#define MA_OUT_OF_RANGE                                -5
-#define MA_ACCESS_DENIED                               -6
-#define MA_DOES_NOT_EXIST                              -7
-#define MA_ALREADY_EXISTS                              -8
-#define MA_TOO_MANY_OPEN_FILES                         -9
-#define MA_INVALID_FILE                                -10
-#define MA_TOO_BIG                                     -11
-#define MA_PATH_TOO_LONG                               -12
-#define MA_NAME_TOO_LONG                               -13
-#define MA_NOT_DIRECTORY                               -14
-#define MA_IS_DIRECTORY                                -15
-#define MA_DIRECTORY_NOT_EMPTY                         -16
-#define MA_END_OF_FILE                                 -17
-#define MA_NO_SPACE                                    -18
-#define MA_BUSY                                        -19
-#define MA_IO_ERROR                                    -20
-#define MA_INTERRUPT                                   -21
-#define MA_UNAVAILABLE                                 -22
-#define MA_ALREADY_IN_USE                              -23
-#define MA_BAD_ADDRESS                                 -24
-#define MA_BAD_SEEK                                    -25
-#define MA_BAD_PIPE                                    -26
-#define MA_DEADLOCK                                    -27
-#define MA_TOO_MANY_LINKS                              -28
-#define MA_NOT_IMPLEMENTED                             -29
-#define MA_NO_MESSAGE                                  -30
-#define MA_BAD_MESSAGE                                 -31
-#define MA_NO_DATA_AVAILABLE                           -32
-#define MA_INVALID_DATA                                -33
-#define MA_TIMEOUT                                     -34
-#define MA_NO_NETWORK                                  -35
-#define MA_NOT_UNIQUE                                  -36
-#define MA_NOT_SOCKET                                  -37
-#define MA_NO_ADDRESS                                  -38
-#define MA_BAD_PROTOCOL                                -39
-#define MA_PROTOCOL_UNAVAILABLE                        -40
-#define MA_PROTOCOL_NOT_SUPPORTED                      -41
-#define MA_PROTOCOL_FAMILY_NOT_SUPPORTED               -42
-#define MA_ADDRESS_FAMILY_NOT_SUPPORTED                -43
-#define MA_SOCKET_NOT_SUPPORTED                        -44
-#define MA_CONNECTION_RESET                            -45
-#define MA_ALREADY_CONNECTED                           -46
-#define MA_NOT_CONNECTED                               -47
-#define MA_CONNECTION_REFUSED                          -48
-#define MA_NO_HOST                                     -49
-#define MA_IN_PROGRESS                                 -50
-#define MA_CANCELLED                                   -51
-#define MA_MEMORY_ALREADY_MAPPED                       -52
-#define MA_AT_END                                      -53
-
-/* General miniaudio-specific errors. */
-#define MA_FORMAT_NOT_SUPPORTED                        -100
-#define MA_DEVICE_TYPE_NOT_SUPPORTED                   -101
-#define MA_SHARE_MODE_NOT_SUPPORTED                    -102
-#define MA_NO_BACKEND                                  -103
-#define MA_NO_DEVICE                                   -104
-#define MA_API_NOT_FOUND                               -105
-#define MA_INVALID_DEVICE_CONFIG                       -106
-#define MA_LOOP                                        -107
-
-/* State errors. */
-#define MA_DEVICE_NOT_INITIALIZED                      -200
-#define MA_DEVICE_ALREADY_INITIALIZED                  -201
-#define MA_DEVICE_NOT_STARTED                          -202
-#define MA_DEVICE_NOT_STOPPED                          -203
-
-/* Operation errors. */
-#define MA_FAILED_TO_INIT_BACKEND                      -300
-#define MA_FAILED_TO_OPEN_BACKEND_DEVICE               -301
-#define MA_FAILED_TO_START_BACKEND_DEVICE              -302
-#define MA_FAILED_TO_STOP_BACKEND_DEVICE               -303
-
-
-#define MA_MIN_CHANNELS                                1
-#ifndef MA_MAX_CHANNELS
-#define MA_MAX_CHANNELS                                32
-#endif
-
-
-#ifndef MA_MAX_FILTER_ORDER
-#define MA_MAX_FILTER_ORDER                            8
-#endif
-
-typedef enum
-{
-    ma_stream_format_pcm = 0
-} ma_stream_format;
-
-typedef enum
-{
-    ma_stream_layout_interleaved = 0,
-    ma_stream_layout_deinterleaved
-} ma_stream_layout;
-
-typedef enum
-{
-    ma_dither_mode_none = 0,
-    ma_dither_mode_rectangle,
-    ma_dither_mode_triangle
-} ma_dither_mode;
-
-typedef enum
-{
-    /*
-    I like to keep these explicitly defined because they're used as a key into a lookup table. When items are
-    added to this, make sure there are no gaps and that they're added to the lookup table in ma_get_bytes_per_sample().
-    */
-    ma_format_unknown = 0,     /* Mainly used for indicating an error, but also used as the default for the output format for decoders. */
-    ma_format_u8      = 1,
-    ma_format_s16     = 2,     /* Seems to be the most widely supported format. */
-    ma_format_s24     = 3,     /* Tightly packed. 3 bytes per sample. */
-    ma_format_s32     = 4,
-    ma_format_f32     = 5,
-    ma_format_count
-} ma_format;
-
-typedef enum
-{
-    /* Standard rates need to be in priority order. */
-    ma_standard_sample_rate_48000  = 48000,     /* Most common */
-    ma_standard_sample_rate_44100  = 44100,
-
-    ma_standard_sample_rate_32000  = 32000,     /* Lows */
-    ma_standard_sample_rate_24000  = 24000,
-    ma_standard_sample_rate_22050  = 22050,
-    
-    ma_standard_sample_rate_88200  = 88200,     /* Highs */
-    ma_standard_sample_rate_96000  = 96000,
-    ma_standard_sample_rate_176400 = 176400,
-    ma_standard_sample_rate_192000 = 192000,
-
-    ma_standard_sample_rate_16000  = 16000,     /* Extreme lows */
-    ma_standard_sample_rate_11025  = 11250,
-    ma_standard_sample_rate_8000   = 8000,
-
-    ma_standard_sample_rate_352800 = 352800,    /* Extreme highs */
-    ma_standard_sample_rate_384000 = 384000,
-
-    ma_standard_sample_rate_min    = ma_standard_sample_rate_8000,
-    ma_standard_sample_rate_max    = ma_standard_sample_rate_384000,
-    ma_standard_sample_rate_count  = 14         /* Need to maintain the count manually. Make sure this is updated if items are added to enum. */
-} ma_standard_sample_rate;
-
-/* These are deprecated. Use ma_standard_sample_rate_min and ma_standard_sample_rate_max. */
-#define MA_MIN_SAMPLE_RATE  (ma_uint32)ma_standard_sample_rate_min
-#define MA_MAX_SAMPLE_RATE  (ma_uint32)ma_standard_sample_rate_max
-
-
-typedef enum
-{
-    ma_channel_mix_mode_rectangular = 0,   /* Simple averaging based on the plane(s) the channel is sitting on. */
-    ma_channel_mix_mode_simple,            /* Drop excess channels; zeroed out extra channels. */
-    ma_channel_mix_mode_custom_weights,    /* Use custom weights specified in ma_channel_router_config. */
-    ma_channel_mix_mode_planar_blend = ma_channel_mix_mode_rectangular,
-    ma_channel_mix_mode_default = ma_channel_mix_mode_planar_blend
-} ma_channel_mix_mode;
-
-typedef enum
-{
-    ma_standard_channel_map_microsoft,
-    ma_standard_channel_map_alsa,
-    ma_standard_channel_map_rfc3551,   /* Based off AIFF. */
-    ma_standard_channel_map_flac,
-    ma_standard_channel_map_vorbis,
-    ma_standard_channel_map_sound4,    /* FreeBSD's sound(4). */
-    ma_standard_channel_map_sndio,     /* www.sndio.org/tips.html */
-    ma_standard_channel_map_webaudio = ma_standard_channel_map_flac, /* https://webaudio.github.io/web-audio-api/#ChannelOrdering. Only 1, 2, 4 and 6 channels are defined, but can fill in the gaps with logical assumptions. */
-    ma_standard_channel_map_default = ma_standard_channel_map_microsoft
-} ma_standard_channel_map;
-
-typedef enum
-{
-    ma_performance_profile_low_latency = 0,
-    ma_performance_profile_conservative
-} ma_performance_profile;
-
-
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} ma_allocation_callbacks;
-
-typedef struct
-{
-    ma_int32 state;
-} ma_lcg;
-
-
-#ifndef MA_NO_THREADING
-/* Thread priorities should be ordered such that the default priority of the worker thread is 0. */
-typedef enum
-{
-    ma_thread_priority_idle     = -5,
-    ma_thread_priority_lowest   = -4,
-    ma_thread_priority_low      = -3,
-    ma_thread_priority_normal   = -2,
-    ma_thread_priority_high     = -1,
-    ma_thread_priority_highest  =  0,
-    ma_thread_priority_realtime =  1,
-    ma_thread_priority_default  =  0
-} ma_thread_priority;
-
-/* Spinlocks are 32-bit for compatibility reasons. */
-typedef ma_uint32 ma_spinlock;
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_thread;
-#endif
-#if defined(MA_POSIX)
-typedef pthread_t ma_thread;
-#endif
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_mutex;
-#endif
-#if defined(MA_POSIX)
-typedef pthread_mutex_t ma_mutex;
-#endif
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_event;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
-    ma_uint32 value;
-    pthread_mutex_t lock;
-    pthread_cond_t cond;
-} ma_event;
-#endif  /* MA_POSIX */
-
-#if defined(MA_WIN32)
-typedef ma_handle ma_semaphore;
-#endif
-#if defined(MA_POSIX)
-typedef struct
-{
-    int value;
-    pthread_mutex_t lock;
-    pthread_cond_t cond;
-} ma_semaphore;
-#endif  /* MA_POSIX */
-#else
-/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
-#ifndef MA_NO_DEVICE_IO
-#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
-#endif
-#endif  /* MA_NO_THREADING */
-
-
-/*
-Retrieves the version of miniaudio as separated integers. Each component can be NULL if it's not required.
-*/
-MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision);
-
-/*
-Retrieves the version of miniaudio as a string which can be useful for logging purposes.
-*/
-MA_API const char* ma_version_string(void);
-
-
-/**************************************************************************************************************************************************************
-
-Biquad Filtering
-
-**************************************************************************************************************************************************************/
-typedef union
-{
-    float    f32;
-    ma_int32 s32;
-} ma_biquad_coefficient;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    double b0;
-    double b1;
-    double b2;
-    double a0;
-    double a1;
-    double a2;
-} ma_biquad_config;
-
-MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient b0;
-    ma_biquad_coefficient b1;
-    ma_biquad_coefficient b2;
-    ma_biquad_coefficient a1;
-    ma_biquad_coefficient a2;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-    ma_biquad_coefficient r2[MA_MAX_CHANNELS];
-} ma_biquad;
-
-MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, ma_biquad* pBQ);
-MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ);
-MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ);
-
-
-/**************************************************************************************************************************************************************
-
-Low-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_lpf1_config, ma_lpf2_config;
-
-MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency);
-MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient a;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-} ma_lpf1;
-
-MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, ma_lpf1* pLPF);
-MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF);
-MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order low-pass filter is implemented as a biquad filter. */
-} ma_lpf2;
-
-MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, ma_lpf2* pLPF);
-MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF);
-MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_lpf_config;
-
-MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 lpf1Count;
-    ma_uint32 lpf2Count;
-    ma_lpf1 lpf1[1];
-    ma_lpf2 lpf2[MA_MAX_FILTER_ORDER/2];
-} ma_lpf;
-
-MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, ma_lpf* pLPF);
-MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF);
-MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF);
-
-
-/**************************************************************************************************************************************************************
-
-High-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_hpf1_config, ma_hpf2_config;
-
-MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency);
-MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_biquad_coefficient a;
-    ma_biquad_coefficient r1[MA_MAX_CHANNELS];
-} ma_hpf1;
-
-MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, ma_hpf1* pHPF);
-MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF);
-MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order high-pass filter is implemented as a biquad filter. */
-} ma_hpf2;
-
-MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, ma_hpf2* pHPF);
-MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF);
-MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_hpf_config;
-
-MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 hpf1Count;
-    ma_uint32 hpf2Count;
-    ma_hpf1 hpf1[1];
-    ma_hpf2 hpf2[MA_MAX_FILTER_ORDER/2];
-} ma_hpf;
-
-MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, ma_hpf* pHPF);
-MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF);
-MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF);
-
-
-/**************************************************************************************************************************************************************
-
-Band-Pass Filtering
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    double q;
-} ma_bpf2_config;
-
-MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q);
-
-typedef struct
-{
-    ma_biquad bq;   /* The second order band-pass filter is implemented as a biquad filter. */
-} ma_bpf2;
-
-MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, ma_bpf2* pBPF);
-MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF);
-MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF);
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double cutoffFrequency;
-    ma_uint32 order;    /* If set to 0, will be treated as a passthrough (no filtering will be applied). */
-} ma_bpf_config;
-
-MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 bpf2Count;
-    ma_bpf2 bpf2[MA_MAX_FILTER_ORDER/2];
-} ma_bpf;
-
-MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, ma_bpf* pBPF);
-MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF);
-MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF);
-
-
-/**************************************************************************************************************************************************************
-
-Notching Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double q;
-    double frequency;
-} ma_notch2_config;
-
-MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_notch2;
-
-MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter);
-MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter);
-MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-Peaking EQ Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double q;
-    double frequency;
-} ma_peak2_config;
-
-MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_peak2;
-
-MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter);
-MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter);
-MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-Low Shelf Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double shelfSlope;
-    double frequency;
-} ma_loshelf2_config;
-
-MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_loshelf2;
-
-MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter);
-MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter);
-MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter);
-
-
-/**************************************************************************************************************************************************************
-
-High Shelf Filter
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    double gainDB;
-    double shelfSlope;
-    double frequency;
-} ma_hishelf2_config;
-
-MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency);
-
-typedef struct
-{
-    ma_biquad bq;
-} ma_hishelf2;
-
-MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter);
-MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter);
-MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter);
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DATA CONVERSION
-===============
-
-This section contains the APIs for data conversion. You will find everything here for channel mapping, sample format conversion, resampling, etc.
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-
-/**************************************************************************************************************************************************************
-
-Resampling
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_uint32 lpfOrder;         /* The low-pass filter order. Setting this to 0 will disable low-pass filtering. */
-    double    lpfNyquistFactor; /* 0..1. Defaults to 1. 1 = Half the sampling frequency (Nyquist Frequency), 0.5 = Quarter the sampling frequency (half Nyquest Frequency), etc. */
-} ma_linear_resampler_config;
-
-MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-typedef struct
-{
-    ma_linear_resampler_config config;
-    ma_uint32 inAdvanceInt;
-    ma_uint32 inAdvanceFrac;
-    ma_uint32 inTimeInt;
-    ma_uint32 inTimeFrac;
-    union
-    {
-        float    f32[MA_MAX_CHANNELS];
-        ma_int16 s16[MA_MAX_CHANNELS];
-    } x0; /* The previous input frame. */
-    union
-    {
-        float    f32[MA_MAX_CHANNELS];
-        ma_int16 s16[MA_MAX_CHANNELS];
-    } x1; /* The next input frame. */
-    ma_lpf lpf;
-} ma_linear_resampler;
-
-MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, ma_linear_resampler* pResampler);
-MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler);
-MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut);
-MA_API ma_uint64 ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount);
-MA_API ma_uint64 ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount);
-MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler);
-MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler);
-
-typedef enum
-{
-    ma_resample_algorithm_linear = 0,   /* Fastest, lowest quality. Optional low-pass filtering. Default. */
-    ma_resample_algorithm_speex
-} ma_resample_algorithm;
-
-typedef struct
-{
-    ma_format format;   /* Must be either ma_format_f32 or ma_format_s16. */
-    ma_uint32 channels;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_resample_algorithm algorithm;
-    struct
-    {
-        ma_uint32 lpfOrder;
-        double lpfNyquistFactor;
-    } linear;
-    struct
-    {
-        int quality;    /* 0 to 10. Defaults to 3. */
-    } speex;
-} ma_resampler_config;
-
-MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm);
-
-typedef struct
-{
-    ma_resampler_config config;
-    union
-    {
-        ma_linear_resampler linear;
-        struct
-        {
-            void* pSpeexResamplerState;   /* SpeexResamplerState* */
-        } speex;
-    } state;
-} ma_resampler;
-
-/*
-Initializes a new resampler object from a config.
-*/
-MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, ma_resampler* pResampler);
-
-/*
-Uninitializes a resampler.
-*/
-MA_API void ma_resampler_uninit(ma_resampler* pResampler);
-
-/*
-Converts the given input data.
-
-Both the input and output frames must be in the format specified in the config when the resampler was initilized.
-
-On input, [pFrameCountOut] contains the number of output frames to process. On output it contains the number of output frames that
-were actually processed, which may be less than the requested amount which will happen if there's not enough input data. You can use
-ma_resampler_get_expected_output_frame_count() to know how many output frames will be processed for a given number of input frames.
-
-On input, [pFrameCountIn] contains the number of input frames contained in [pFramesIn]. On output it contains the number of whole
-input frames that were actually processed. You can use ma_resampler_get_required_input_frame_count() to know how many input frames
-you should provide for a given number of output frames. [pFramesIn] can be NULL, in which case zeroes will be used instead.
-
-If [pFramesOut] is NULL, a seek is performed. In this case, if [pFrameCountOut] is not NULL it will seek by the specified number of
-output frames. Otherwise, if [pFramesCountOut] is NULL and [pFrameCountIn] is not NULL, it will seek by the specified number of input
-frames. When seeking, [pFramesIn] is allowed to NULL, in which case the internal timing state will be updated, but no input will be
-processed. In this case, any internal filter state will be updated as if zeroes were passed in.
-
-It is an error for [pFramesOut] to be non-NULL and [pFrameCountOut] to be NULL.
-
-It is an error for both [pFrameCountOut] and [pFrameCountIn] to be NULL.
-*/
-MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-
-
-/*
-Sets the input and output sample sample rate.
-*/
-MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-/*
-Sets the input and output sample rate as a ratio.
-
-The ration is in/out.
-*/
-MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio);
-
-
-/*
-Calculates the number of whole input frames that would need to be read from the client in order to output the specified
-number of output frames.
-
-The returned value does not include cached input frames. It only returns the number of extra frames that would need to be
-read from the input buffer in order to output the specified number of output frames.
-*/
-MA_API ma_uint64 ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount);
-
-/*
-Calculates the number of whole output frames that would be output after fully reading and consuming the specified number of
-input frames.
-*/
-MA_API ma_uint64 ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount);
-
-
-/*
-Retrieves the latency introduced by the resampler in input frames.
-*/
-MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler);
-
-/*
-Retrieves the latency introduced by the resampler in output frames.
-*/
-MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler);
-
-
-
-/**************************************************************************************************************************************************************
-
-Channel Conversion
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_channel_mix_mode mixingMode;
-    float weights[MA_MAX_CHANNELS][MA_MAX_CHANNELS];  /* [in][out]. Only used when mixingMode is set to ma_channel_mix_mode_custom_weights. */
-} ma_channel_converter_config;
-
-MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode);
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_channel_mix_mode mixingMode;
-    union
-    {
-        float    f32[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
-        ma_int32 s16[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
-    } weights;
-    ma_bool8 isPassthrough;
-    ma_bool8 isSimpleShuffle;
-    ma_bool8 isSimpleMonoExpansion;
-    ma_bool8 isStereoToMono;
-    ma_uint8 shuffleTable[MA_MAX_CHANNELS];
-} ma_channel_converter;
-
-MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter);
-MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter);
-MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount);
-
-
-/**************************************************************************************************************************************************************
-
-Data Conversion
-
-**************************************************************************************************************************************************************/
-typedef struct
-{
-    ma_format formatIn;
-    ma_format formatOut;
-    ma_uint32 channelsIn;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateIn;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_dither_mode ditherMode;
-    ma_channel_mix_mode channelMixMode;
-    float channelWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS];  /* [in][out]. Only used when channelMixMode is set to ma_channel_mix_mode_custom_weights. */
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        ma_bool32 allowDynamicSampleRate;
-        struct
-        {
-            ma_uint32 lpfOrder;
-            double lpfNyquistFactor;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-} ma_data_converter_config;
-
-MA_API ma_data_converter_config ma_data_converter_config_init_default(void);
-MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-
-typedef struct
-{
-    ma_data_converter_config config;
-    ma_channel_converter channelConverter;
-    ma_resampler resampler;
-    ma_bool8 hasPreFormatConversion;
-    ma_bool8 hasPostFormatConversion;
-    ma_bool8 hasChannelConverter;
-    ma_bool8 hasResampler;
-    ma_bool8 isPassthrough;
-} ma_data_converter;
-
-MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter);
-MA_API void ma_data_converter_uninit(ma_data_converter* pConverter);
-MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut);
-MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut);
-MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut);
-MA_API ma_uint64 ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount);
-MA_API ma_uint64 ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount);
-MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter);
-MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter);
-
-
-/************************************************************************************************************************************************************
-
-Format Conversion
-
-************************************************************************************************************************************************************/
-MA_API void ma_pcm_u8_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_u8_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s16_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s24_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_s32_to_f32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_u8(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s16(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s24(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_f32_to_s32(void* pOut, const void* pIn, ma_uint64 count, ma_dither_mode ditherMode);
-MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode);
-MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode);
-
-/*
-Deinterleaves an interleaved buffer.
-*/
-MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames);
-
-/*
-Interleaves a group of deinterleaved buffers.
-*/
-MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames);
-
-
-/************************************************************************************************************************************************************
-
-Channel Maps
-
-************************************************************************************************************************************************************/
-
-/*
-Initializes a blank channel map.
-
-When a blank channel map is specified anywhere it indicates that the native channel map should be used.
-*/
-MA_API void ma_channel_map_init_blank(ma_uint32 channels, ma_channel* pChannelMap);
-
-/*
-Helper for retrieving a standard channel map.
-
-The output channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API void ma_get_standard_channel_map(ma_standard_channel_map standardChannelMap, ma_uint32 channels, ma_channel* pChannelMap);
-
-/*
-Copies a channel map.
-
-Both input and output channel map buffers must have a capacity of at at least `channels`.
-*/
-MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels);
-
-/*
-Copies a channel map if one is specified, otherwise copies the default channel map.
-
-The output buffer must have a capacity of at least `channels`. If not NULL, the input channel map must also have a capacity of at least `channels`.
-*/
-MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels);
-
-
-/*
-Determines whether or not a channel map is valid.
-
-A blank channel map is valid (all channels set to MA_CHANNEL_NONE). The way a blank channel map is handled is context specific, but
-is usually treated as a passthrough.
-
-Invalid channel maps:
-  - A channel map with no channels
-  - A channel map with more than one channel and a mono channel
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_valid(ma_uint32 channels, const ma_channel* pChannelMap);
-
-/*
-Helper for comparing two channel maps for equality.
-
-This assumes the channel count is the same between the two.
-
-Both channels map buffers must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_equal(ma_uint32 channels, const ma_channel* pChannelMapA, const ma_channel* pChannelMapB);
-
-/*
-Helper for determining if a channel map is blank (all channels set to MA_CHANNEL_NONE).
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_blank(ma_uint32 channels, const ma_channel* pChannelMap);
-
-/*
-Helper for determining whether or not a channel is present in the given channel map.
-
-The channel map buffer must have a capacity of at least `channels`.
-*/
-MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition);
-
-
-/************************************************************************************************************************************************************
-
-Conversion Helpers
-
-************************************************************************************************************************************************************/
-
-/*
-High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to
-determine the required size of the output buffer. frameCountOut should be set to the capacity of pOut. If pOut is NULL, frameCountOut is
-ignored.
-
-A return value of 0 indicates an error.
-
-This function is useful for one-off bulk conversions, but if you're streaming data you should use the ma_data_converter APIs instead.
-*/
-MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn);
-MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig);
-
-
-/************************************************************************************************************************************************************
-
-Ring Buffer
-
-************************************************************************************************************************************************************/
-typedef struct
-{
-    void* pBuffer;
-    ma_uint32 subbufferSizeInBytes;
-    ma_uint32 subbufferCount;
-    ma_uint32 subbufferStrideInBytes;
-    MA_ATOMIC ma_uint32 encodedReadOffset;  /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */
-    MA_ATOMIC ma_uint32 encodedWriteOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. Must be used atomically. */
-    ma_bool8 ownsBuffer;                    /* Used to know whether or not miniaudio is responsible for free()-ing the buffer. */
-    ma_bool8 clearOnWriteAcquire;           /* When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). */
-    ma_allocation_callbacks allocationCallbacks;
-} ma_rb;
-
-MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB);
-MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB);
-MA_API void ma_rb_uninit(ma_rb* pRB);
-MA_API void ma_rb_reset(ma_rb* pRB);
-MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut);
-MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut);
-MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut);
-MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut);
-MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes);
-MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes);
-MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB);    /* Returns the distance between the write pointer and the read pointer. Should never be negative for a correct program. Will return the number of bytes that can be read before the read pointer hits the write pointer. */
-MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB);
-MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB);
-MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex);
-MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer);
-
-
-typedef struct
-{
-    ma_rb rb;
-    ma_format format;
-    ma_uint32 channels;
-} ma_pcm_rb;
-
-MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB);
-MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB);
-MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB);
-MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB);
-MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut);
-MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut);
-MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut);
-MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut);
-MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames);
-MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames);
-MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB); /* Return value is in frames. */
-MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB);
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex);
-MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer);
-
-
-/*
-The idea of the duplex ring buffer is to act as the intermediary buffer when running two asynchronous devices in a duplex set up. The
-capture device writes to it, and then a playback device reads from it.
-
-At the moment this is just a simple naive implementation, but in the future I want to implement some dynamic resampling to seamlessly
-handle desyncs. Note that the API is work in progress and may change at any time in any version.
-
-The size of the buffer is based on the capture side since that's what'll be written to the buffer. It is based on the capture period size
-in frames. The internal sample rate of the capture device is also needed in order to calculate the size.
-*/
-typedef struct
-{
-    ma_pcm_rb rb;
-} ma_duplex_rb;
-
-MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB);
-MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB);
-
-
-/************************************************************************************************************************************************************
-
-Miscellaneous Helpers
-
-************************************************************************************************************************************************************/
-/*
-Retrieves a human readable description of the given result code.
-*/
-MA_API const char* ma_result_description(ma_result result);
-
-/*
-malloc(). Calls MA_MALLOC().
-*/
-MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-realloc(). Calls MA_REALLOC().
-*/
-MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-free(). Calls MA_FREE().
-*/
-MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Performs an aligned malloc, with the assumption that the alignment is a power of 2.
-*/
-MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Free's an aligned malloc'd buffer.
-*/
-MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks);
-
-/*
-Retrieves a friendly name for a format.
-*/
-MA_API const char* ma_get_format_name(ma_format format);
-
-/*
-Blends two frames in floating point format.
-*/
-MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels);
-
-/*
-Retrieves the size of a sample in bytes for the given format.
-
-This API is efficient and is implemented using a lookup table.
-
-Thread Safety: SAFE
-  This API is pure.
-*/
-MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format);
-static MA_INLINE ma_uint32 ma_get_bytes_per_frame(ma_format format, ma_uint32 channels) { return ma_get_bytes_per_sample(format) * channels; }
-
-/*
-Converts a log level to a string.
-*/
-MA_API const char* ma_log_level_to_string(ma_uint32 logLevel);
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DEVICE I/O
-==========
-
-This section contains the APIs for device playback and capture. Here is where you'll find ma_device_init(), etc.
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DEVICE_IO
-/* Some backends are only supported on certain platforms. */
-#if defined(MA_WIN32)
-    #define MA_SUPPORT_WASAPI
-    #if defined(MA_WIN32_DESKTOP)  /* DirectSound and WinMM backends are only supported on desktops. */
-        #define MA_SUPPORT_DSOUND
-        #define MA_SUPPORT_WINMM
-        #define MA_SUPPORT_JACK    /* JACK is technically supported on Windows, but I don't know how many people use it in practice... */
-    #endif
-#endif
-#if defined(MA_UNIX)
-    #if defined(MA_LINUX)
-        #if !defined(MA_ANDROID)   /* ALSA is not supported on Android. */
-            #define MA_SUPPORT_ALSA
-        #endif
-    #endif
-    #if !defined(MA_BSD) && !defined(MA_ANDROID) && !defined(MA_EMSCRIPTEN)
-        #define MA_SUPPORT_PULSEAUDIO
-        #define MA_SUPPORT_JACK
-    #endif
-    #if defined(MA_ANDROID)
-        #define MA_SUPPORT_AAUDIO
-        #define MA_SUPPORT_OPENSL
-    #endif
-    #if defined(__OpenBSD__)        /* <-- Change this to "#if defined(MA_BSD)" to enable sndio on all BSD flavors. */
-        #define MA_SUPPORT_SNDIO    /* sndio is only supported on OpenBSD for now. May be expanded later if there's demand. */
-    #endif
-    #if defined(__NetBSD__) || defined(__OpenBSD__)
-        #define MA_SUPPORT_AUDIO4   /* Only support audio(4) on platforms with known support. */
-    #endif
-    #if defined(__FreeBSD__) || defined(__DragonFly__)
-        #define MA_SUPPORT_OSS      /* Only support OSS on specific platforms with known support. */
-    #endif
-#endif
-#if defined(MA_APPLE)
-    #define MA_SUPPORT_COREAUDIO
-#endif
-#if defined(MA_EMSCRIPTEN)
-    #define MA_SUPPORT_WEBAUDIO
-#endif
-
-/* All platforms should support custom backends. */
-#define MA_SUPPORT_CUSTOM
-
-/* Explicitly disable the Null backend for Emscripten because it uses a background thread which is not properly supported right now. */
-#if !defined(MA_EMSCRIPTEN)
-#define MA_SUPPORT_NULL
-#endif
-
-
-#if defined(MA_SUPPORT_WASAPI) && !defined(MA_NO_WASAPI) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WASAPI))
-    #define MA_HAS_WASAPI
-#endif
-#if defined(MA_SUPPORT_DSOUND) && !defined(MA_NO_DSOUND) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_DSOUND))
-    #define MA_HAS_DSOUND
-#endif
-#if defined(MA_SUPPORT_WINMM) && !defined(MA_NO_WINMM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WINMM))
-    #define MA_HAS_WINMM
-#endif
-#if defined(MA_SUPPORT_ALSA) && !defined(MA_NO_ALSA) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_ALSA))
-    #define MA_HAS_ALSA
-#endif
-#if defined(MA_SUPPORT_PULSEAUDIO) && !defined(MA_NO_PULSEAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_PULSEAUDIO))
-    #define MA_HAS_PULSEAUDIO
-#endif
-#if defined(MA_SUPPORT_JACK) && !defined(MA_NO_JACK) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_JACK))
-    #define MA_HAS_JACK
-#endif
-#if defined(MA_SUPPORT_COREAUDIO) && !defined(MA_NO_COREAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_COREAUDIO))
-    #define MA_HAS_COREAUDIO
-#endif
-#if defined(MA_SUPPORT_SNDIO) && !defined(MA_NO_SNDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_SNDIO))
-    #define MA_HAS_SNDIO
-#endif
-#if defined(MA_SUPPORT_AUDIO4) && !defined(MA_NO_AUDIO4) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AUDIO4))
-    #define MA_HAS_AUDIO4
-#endif
-#if defined(MA_SUPPORT_OSS) && !defined(MA_NO_OSS) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OSS))
-    #define MA_HAS_OSS
-#endif
-#if defined(MA_SUPPORT_AAUDIO) && !defined(MA_NO_AAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_AAUDIO))
-    #define MA_HAS_AAUDIO
-#endif
-#if defined(MA_SUPPORT_OPENSL) && !defined(MA_NO_OPENSL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_OPENSL))
-    #define MA_HAS_OPENSL
-#endif
-#if defined(MA_SUPPORT_WEBAUDIO) && !defined(MA_NO_WEBAUDIO) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_WEBAUDIO))
-    #define MA_HAS_WEBAUDIO
-#endif
-#if defined(MA_SUPPORT_CUSTOM) && !defined(MA_NO_CUSTOM) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_CUSTOM))
-    #define MA_HAS_CUSTOM
-#endif
-#if defined(MA_SUPPORT_NULL) && !defined(MA_NO_NULL) && (!defined(MA_ENABLE_ONLY_SPECIFIC_BACKENDS) || defined(MA_ENABLE_NULL))
-    #define MA_HAS_NULL
-#endif
-
-#define MA_STATE_UNINITIALIZED     0
-#define MA_STATE_STOPPED           1   /* The device's default state after initialization. */
-#define MA_STATE_STARTED           2   /* The device is started and is requesting and/or delivering audio data. */
-#define MA_STATE_STARTING          3   /* Transitioning from a stopped state to started. */
-#define MA_STATE_STOPPING          4   /* Transitioning from a started state to stopped. */
-
-#ifdef MA_SUPPORT_WASAPI
-/* We need a IMMNotificationClient object for WASAPI. */
-typedef struct
-{
-    void* lpVtbl;
-    ma_uint32 counter;
-    ma_device* pDevice;
-} ma_IMMNotificationClient;
-#endif
-
-/* Backend enums must be in priority order. */
-typedef enum
-{
-    ma_backend_wasapi,
-    ma_backend_dsound,
-    ma_backend_winmm,
-    ma_backend_coreaudio,
-    ma_backend_sndio,
-    ma_backend_audio4,
-    ma_backend_oss,
-    ma_backend_pulseaudio,
-    ma_backend_alsa,
-    ma_backend_jack,
-    ma_backend_aaudio,
-    ma_backend_opensl,
-    ma_backend_webaudio,
-    ma_backend_custom,  /* <-- Custom backend, with callbacks defined by the context config. */
-    ma_backend_null     /* <-- Must always be the last item. Lowest priority, and used as the terminator for backend enumeration. */
-} ma_backend;
-
-#define MA_BACKEND_COUNT (ma_backend_null+1)
-
-
-/*
-The callback for processing audio data from the device.
-
-The data callback is fired by miniaudio whenever the device needs to have more data delivered to a playback device, or when a capture device has some data
-available. This is called as soon as the backend asks for more data which means it may be called with inconsistent frame counts. You cannot assume the
-callback will be fired with a consistent frame count.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the relevant device.
-
-pOutput (out)
-    A pointer to the output buffer that will receive audio data that will later be played back through the speakers. This will be non-null for a playback or
-    full-duplex device and null for a capture and loopback device.
-
-pInput (in)
-    A pointer to the buffer containing input data from a recording device. This will be non-null for a capture, full-duplex or loopback device and null for a
-    playback device.
-
-frameCount (in)
-    The number of PCM frames to process. Note that this will not necessarily be equal to what you requested when you initialized the device. The
-    `periodSizeInFrames` and `periodSizeInMilliseconds` members of the device config are just hints, and are not necessarily exactly what you'll get. You must
-    not assume this will always be the same value each time the callback is fired.
-
-
-Remarks
--------
-You cannot stop and start the device from inside the callback or else you'll get a deadlock. You must also not uninitialize the device from inside the
-callback. The following APIs cannot be called from inside the callback:
-
-    ma_device_init()
-    ma_device_init_ex()
-    ma_device_uninit()
-    ma_device_start()
-    ma_device_stop()
-
-The proper way to stop the device is to call `ma_device_stop()` from a different thread, normally the main application thread.
-*/
-typedef void (* ma_device_callback_proc)(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-/*
-The callback for when the device has been stopped.
-
-This will be called when the device is stopped explicitly with `ma_device_stop()` and also called implicitly when the device is stopped through external forces
-such as being unplugged or an internal error occuring.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device that has just stopped.
-
-
-Remarks
--------
-Do not restart or uninitialize the device from the callback.
-*/
-typedef void (* ma_stop_proc)(ma_device* pDevice);
-
-/*
-The callback for handling log messages.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context the log message originated from.
-
-pDevice (in)
-    A pointer to the device the log message originate from, if any. This can be null, in which case the message came from the context.
-
-logLevel (in)
-    The log level. This can be one of the following:
-
-    +----------------------+
-    | Log Level            |
-    +----------------------+
-    | MA_LOG_LEVEL_VERBOSE |
-    | MA_LOG_LEVEL_INFO    |
-    | MA_LOG_LEVEL_WARNING |
-    | MA_LOG_LEVEL_ERROR   |
-    +----------------------+
-
-message (in)
-    The log message.
-
-
-Remarks
--------
-Do not modify the state of the device from inside the callback.
-*/
-typedef void (* ma_log_proc)(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message);
-
-typedef enum
-{
-    ma_device_type_playback = 1,
-    ma_device_type_capture  = 2,
-    ma_device_type_duplex   = ma_device_type_playback | ma_device_type_capture, /* 3 */
-    ma_device_type_loopback = 4
-} ma_device_type;
-
-typedef enum
-{
-    ma_share_mode_shared = 0,
-    ma_share_mode_exclusive
-} ma_share_mode;
-
-/* iOS/tvOS/watchOS session categories. */
-typedef enum
-{
-    ma_ios_session_category_default = 0,        /* AVAudioSessionCategoryPlayAndRecord with AVAudioSessionCategoryOptionDefaultToSpeaker. */
-    ma_ios_session_category_none,               /* Leave the session category unchanged. */
-    ma_ios_session_category_ambient,            /* AVAudioSessionCategoryAmbient */
-    ma_ios_session_category_solo_ambient,       /* AVAudioSessionCategorySoloAmbient */
-    ma_ios_session_category_playback,           /* AVAudioSessionCategoryPlayback */
-    ma_ios_session_category_record,             /* AVAudioSessionCategoryRecord */
-    ma_ios_session_category_play_and_record,    /* AVAudioSessionCategoryPlayAndRecord */
-    ma_ios_session_category_multi_route         /* AVAudioSessionCategoryMultiRoute */
-} ma_ios_session_category;
-
-/* iOS/tvOS/watchOS session category options */
-typedef enum
-{
-    ma_ios_session_category_option_mix_with_others                            = 0x01,   /* AVAudioSessionCategoryOptionMixWithOthers */
-    ma_ios_session_category_option_duck_others                                = 0x02,   /* AVAudioSessionCategoryOptionDuckOthers */
-    ma_ios_session_category_option_allow_bluetooth                            = 0x04,   /* AVAudioSessionCategoryOptionAllowBluetooth */
-    ma_ios_session_category_option_default_to_speaker                         = 0x08,   /* AVAudioSessionCategoryOptionDefaultToSpeaker */
-    ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others = 0x11,   /* AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers */
-    ma_ios_session_category_option_allow_bluetooth_a2dp                       = 0x20,   /* AVAudioSessionCategoryOptionAllowBluetoothA2DP */
-    ma_ios_session_category_option_allow_air_play                             = 0x40,   /* AVAudioSessionCategoryOptionAllowAirPlay */
-} ma_ios_session_category_option;
-
-/* OpenSL stream types. */
-typedef enum
-{
-    ma_opensl_stream_type_default = 0,              /* Leaves the stream type unset. */
-    ma_opensl_stream_type_voice,                    /* SL_ANDROID_STREAM_VOICE */
-    ma_opensl_stream_type_system,                   /* SL_ANDROID_STREAM_SYSTEM */
-    ma_opensl_stream_type_ring,                     /* SL_ANDROID_STREAM_RING */
-    ma_opensl_stream_type_media,                    /* SL_ANDROID_STREAM_MEDIA */
-    ma_opensl_stream_type_alarm,                    /* SL_ANDROID_STREAM_ALARM */
-    ma_opensl_stream_type_notification              /* SL_ANDROID_STREAM_NOTIFICATION */
-} ma_opensl_stream_type;
-
-/* OpenSL recording presets. */
-typedef enum
-{
-    ma_opensl_recording_preset_default = 0,         /* Leaves the input preset unset. */
-    ma_opensl_recording_preset_generic,             /* SL_ANDROID_RECORDING_PRESET_GENERIC */
-    ma_opensl_recording_preset_camcorder,           /* SL_ANDROID_RECORDING_PRESET_CAMCORDER */
-    ma_opensl_recording_preset_voice_recognition,   /* SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION */
-    ma_opensl_recording_preset_voice_communication, /* SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION */
-    ma_opensl_recording_preset_voice_unprocessed    /* SL_ANDROID_RECORDING_PRESET_UNPROCESSED */
-} ma_opensl_recording_preset;
-
-/* AAudio usage types. */
-typedef enum
-{
-    ma_aaudio_usage_default = 0,                    /* Leaves the usage type unset. */
-    ma_aaudio_usage_announcement,                   /* AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT */
-    ma_aaudio_usage_emergency,                      /* AAUDIO_SYSTEM_USAGE_EMERGENCY */
-    ma_aaudio_usage_safety,                         /* AAUDIO_SYSTEM_USAGE_SAFETY */
-    ma_aaudio_usage_vehicle_status,                 /* AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS */
-    ma_aaudio_usage_alarm,                          /* AAUDIO_USAGE_ALARM */
-    ma_aaudio_usage_assistance_accessibility,       /* AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY */
-    ma_aaudio_usage_assistance_navigation_guidance, /* AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE */
-    ma_aaudio_usage_assistance_sonification,        /* AAUDIO_USAGE_ASSISTANCE_SONIFICATION */
-    ma_aaudio_usage_assitant,                       /* AAUDIO_USAGE_ASSISTANT */
-    ma_aaudio_usage_game,                           /* AAUDIO_USAGE_GAME */
-    ma_aaudio_usage_media,                          /* AAUDIO_USAGE_MEDIA */
-    ma_aaudio_usage_notification,                   /* AAUDIO_USAGE_NOTIFICATION */
-    ma_aaudio_usage_notification_event,             /* AAUDIO_USAGE_NOTIFICATION_EVENT */
-    ma_aaudio_usage_notification_ringtone,          /* AAUDIO_USAGE_NOTIFICATION_RINGTONE */
-    ma_aaudio_usage_voice_communication,            /* AAUDIO_USAGE_VOICE_COMMUNICATION */
-    ma_aaudio_usage_voice_communication_signalling  /* AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING */
-} ma_aaudio_usage;
-
-/* AAudio content types. */
-typedef enum
-{
-    ma_aaudio_content_type_default = 0,             /* Leaves the content type unset. */
-    ma_aaudio_content_type_movie,                   /* AAUDIO_CONTENT_TYPE_MOVIE */
-    ma_aaudio_content_type_music,                   /* AAUDIO_CONTENT_TYPE_MUSIC */
-    ma_aaudio_content_type_sonification,            /* AAUDIO_CONTENT_TYPE_SONIFICATION */
-    ma_aaudio_content_type_speech                   /* AAUDIO_CONTENT_TYPE_SPEECH */
-} ma_aaudio_content_type;
-
-/* AAudio input presets. */
-typedef enum
-{
-    ma_aaudio_input_preset_default = 0,             /* Leaves the input preset unset. */
-    ma_aaudio_input_preset_generic,                 /* AAUDIO_INPUT_PRESET_GENERIC */
-    ma_aaudio_input_preset_camcorder,               /* AAUDIO_INPUT_PRESET_CAMCORDER */
-    ma_aaudio_input_preset_unprocessed,             /* AAUDIO_INPUT_PRESET_UNPROCESSED */
-    ma_aaudio_input_preset_voice_recognition,       /* AAUDIO_INPUT_PRESET_VOICE_RECOGNITION */
-    ma_aaudio_input_preset_voice_communication,     /* AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION */
-    ma_aaudio_input_preset_voice_performance        /* AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE */
-} ma_aaudio_input_preset;
-
-
-typedef union
-{
-    ma_int64 counter;
-    double counterD;
-} ma_timer;
-
-typedef union
-{
-    wchar_t wasapi[64];             /* WASAPI uses a wchar_t string for identification. */
-    ma_uint8 dsound[16];            /* DirectSound uses a GUID for identification. */
-    /*UINT_PTR*/ ma_uint32 winmm;   /* When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. */
-    char alsa[256];                 /* ALSA uses a name string for identification. */
-    char pulse[256];                /* PulseAudio uses a name string for identification. */
-    int jack;                       /* JACK always uses default devices. */
-    char coreaudio[256];            /* Core Audio uses a string for identification. */
-    char sndio[256];                /* "snd/0", etc. */
-    char audio4[256];               /* "/dev/audio", etc. */
-    char oss[64];                   /* "dev/dsp0", etc. "dev/dsp" for the default device. */
-    ma_int32 aaudio;                /* AAudio uses a 32-bit integer for identification. */
-    ma_uint32 opensl;               /* OpenSL|ES uses a 32-bit unsigned integer for identification. */
-    char webaudio[32];              /* Web Audio always uses default devices for now, but if this changes it'll be a GUID. */
-    union
-    {
-        int i;
-        char s[256];
-        void* p;
-    } custom;                       /* The custom backend could be anything. Give them a few options. */
-    int nullbackend;                /* The null backend uses an integer for device IDs. */
-} ma_device_id;
-
-
-typedef struct ma_context_config    ma_context_config;
-typedef struct ma_device_config     ma_device_config;
-typedef struct ma_backend_callbacks ma_backend_callbacks;
-
-#define MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE (1U << 1)    /* If set, this is supported in exclusive mode. Otherwise not natively supported by exclusive mode. */
-
-typedef struct
-{
-    /* Basic info. This is the only information guaranteed to be filled in during device enumeration. */
-    ma_device_id id;
-    char name[256];
-    ma_bool32 isDefault;
-
-    /*
-    Detailed info. As much of this is filled as possible with ma_context_get_device_info(). Note that you are allowed to initialize
-    a device with settings outside of this range, but it just means the data will be converted using miniaudio's data conversion
-    pipeline before sending the data to/from the device. Most programs will need to not worry about these values, but it's provided
-    here mainly for informational purposes or in the rare case that someone might find it useful.
-
-    These will be set to 0 when returned by ma_context_enumerate_devices() or ma_context_get_devices().
-    */
-    ma_uint32 formatCount;
-    ma_format formats[ma_format_count];
-    ma_uint32 minChannels;
-    ma_uint32 maxChannels;
-    ma_uint32 minSampleRate;
-    ma_uint32 maxSampleRate;
-
-
-    /* Experimental. Don't use these right now. */
-    ma_uint32 nativeDataFormatCount;
-    struct
-    {
-        ma_format format;       /* Sample format. If set to ma_format_unknown, all sample formats are supported. */
-        ma_uint32 channels;     /* If set to 0, all channels are supported. */
-        ma_uint32 sampleRate;   /* If set to 0, all sample rates are supported. */
-        ma_uint32 flags;        /* A combination of MA_DATA_FORMAT_FLAG_* flags. */
-    } nativeDataFormats[/*ma_format_count * ma_standard_sample_rate_count * MA_MAX_CHANNELS*/ 64];  /* Not sure how big to make this. There can be *many* permutations for virtual devices which can support anything. */
-} ma_device_info;
-
-struct ma_device_config
-{
-    ma_device_type deviceType;
-    ma_uint32 sampleRate;
-    ma_uint32 periodSizeInFrames;
-    ma_uint32 periodSizeInMilliseconds;
-    ma_uint32 periods;
-    ma_performance_profile performanceProfile;
-    ma_bool8 noPreZeroedOutputBuffer;   /* When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to zero. */
-    ma_bool8 noClip;                    /* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */
-    ma_device_callback_proc dataCallback;
-    ma_stop_proc stopCallback;
-    void* pUserData;
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    struct
-    {
-        const ma_device_id* pDeviceID;
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_channel_mix_mode channelMixMode;
-        ma_share_mode shareMode;
-    } playback;
-    struct
-    {
-        const ma_device_id* pDeviceID;
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_channel_mix_mode channelMixMode;
-        ma_share_mode shareMode;
-    } capture;
-
-    struct
-    {
-        ma_bool8 noAutoConvertSRC;     /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
-        ma_bool8 noDefaultQualitySRC;  /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
-        ma_bool8 noAutoStreamRouting;  /* Disables automatic stream routing. */
-        ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */
-    } wasapi;
-    struct
-    {
-        ma_bool32 noMMap;           /* Disables MMap mode. */
-        ma_bool32 noAutoFormat;     /* Opens the ALSA device with SND_PCM_NO_AUTO_FORMAT. */
-        ma_bool32 noAutoChannels;   /* Opens the ALSA device with SND_PCM_NO_AUTO_CHANNELS. */
-        ma_bool32 noAutoResample;   /* Opens the ALSA device with SND_PCM_NO_AUTO_RESAMPLE. */
-    } alsa;
-    struct
-    {
-        const char* pStreamNamePlayback;
-        const char* pStreamNameCapture;
-    } pulse;
-    struct
-    {
-        ma_bool32 allowNominalSampleRateChange; /* Desktop only. When enabled, allows changing of the sample rate at the operating system level. */
-    } coreaudio;
-    struct
-    {
-        ma_opensl_stream_type streamType;
-        ma_opensl_recording_preset recordingPreset;
-    } opensl;
-    struct
-    {
-        ma_aaudio_usage usage;
-        ma_aaudio_content_type contentType;
-        ma_aaudio_input_preset inputPreset;
-    } aaudio;
-};
-
-
-/*
-The callback for handling device enumeration. This is fired from `ma_context_enumerated_devices()`.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-deviceType (in)
-    The type of the device being enumerated. This will always be either `ma_device_type_playback` or `ma_device_type_capture`.
-
-pInfo (in)
-    A pointer to a `ma_device_info` containing the ID and name of the enumerated device. Note that this will not include detailed information about the device,
-    only basic information (ID and name). The reason for this is that it would otherwise require opening the backend device to probe for the information which
-    is too inefficient.
-
-pUserData (in)
-    The user data pointer passed into `ma_context_enumerate_devices()`.
-*/
-typedef ma_bool32 (* ma_enum_devices_callback_proc)(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData);
-
-
-/*
-Describes some basic details about a playback or capture device.
-*/
-typedef struct
-{
-    const ma_device_id* pDeviceID;
-    ma_share_mode shareMode;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_channel channelMap[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFrames;
-    ma_uint32 periodSizeInMilliseconds;
-    ma_uint32 periodCount;
-} ma_device_descriptor;
-
-/*
-These are the callbacks required to be implemented for a backend. These callbacks are grouped into two parts: context and device. There is one context
-to many devices. A device is created from a context.
-
-The general flow goes like this:
-
-  1) A context is created with `onContextInit()`
-     1a) Available devices can be enumerated with `onContextEnumerateDevices()` if required.
-     1b) Detailed information about a device can be queried with `onContextGetDeviceInfo()` if required.
-  2) A device is created from the context that was created in the first step using `onDeviceInit()`, and optionally a device ID that was
-     selected from device enumeration via `onContextEnumerateDevices()`.
-  3) A device is started or stopped with `onDeviceStart()` / `onDeviceStop()`
-  4) Data is delivered to and from the device by the backend. This is always done based on the native format returned by the prior call
-     to `onDeviceInit()`. Conversion between the device's native format and the format requested by the application will be handled by
-     miniaudio internally.
-
-Initialization of the context is quite simple. You need to do any necessary initialization of internal objects and then output the
-callbacks defined in this structure.
-
-Once the context has been initialized you can initialize a device. Before doing so, however, the application may want to know which
-physical devices are available. This is where `onContextEnumerateDevices()` comes in. This is fairly simple. For each device, fire the
-given callback with, at a minimum, the basic information filled out in `ma_device_info`. When the callback returns `MA_FALSE`, enumeration
-needs to stop and the `onContextEnumerateDevices()` function return with a success code.
-
-Detailed device information can be retrieved from a device ID using `onContextGetDeviceInfo()`. This takes as input the device type and ID,
-and on output returns detailed information about the device in `ma_device_info`. The `onContextGetDeviceInfo()` callback must handle the
-case when the device ID is NULL, in which case information about the default device needs to be retrieved.
-
-Once the context has been created and the device ID retrieved (if using anything other than the default device), the device can be created.
-This is a little bit more complicated than initialization of the context due to it's more complicated configuration. When initializing a
-device, a duplex device may be requested. This means a separate data format needs to be specified for both playback and capture. On input,
-the data format is set to what the application wants. On output it's set to the native format which should match as closely as possible to
-the requested format. The conversion between the format requested by the application and the device's native format will be handled
-internally by miniaudio.
-
-On input, if the sample format is set to `ma_format_unknown`, the backend is free to use whatever sample format it desires, so long as it's
-supported by miniaudio. When the channel count is set to 0, the backend should use the device's native channel count. The same applies for
-sample rate. For the channel map, the default should be used when `ma_channel_map_blank()` returns true (all channels set to
-`MA_CHANNEL_NONE`). On input, the `periodSizeInFrames` or `periodSizeInMilliseconds` option should always be set. The backend should
-inspect both of these variables. If `periodSizeInFrames` is set, it should take priority, otherwise it needs to be derived from the period
-size in milliseconds (`periodSizeInMilliseconds`) and the sample rate, keeping in mind that the sample rate may be 0, in which case the
-sample rate will need to be determined before calculating the period size in frames. On output, all members of the `ma_device_data_format`
-object should be set to a valid value, except for `periodSizeInMilliseconds` which is optional (`periodSizeInFrames` *must* be set).
-
-Starting and stopping of the device is done with `onDeviceStart()` and `onDeviceStop()` and should be self-explanatory. If the backend uses
-asynchronous reading and writing, `onDeviceStart()` and `onDeviceStop()` should always be implemented.
-
-The handling of data delivery between the application and the device is the most complicated part of the process. To make this a bit
-easier, some helper callbacks are available. If the backend uses a blocking read/write style of API, the `onDeviceRead()` and
-`onDeviceWrite()` callbacks can optionally be implemented. These are blocking and work just like reading and writing from a file. If the
-backend uses a callback for data delivery, that callback must call `ma_device_handle_backend_data_callback()` from within it's callback.
-This allows miniaudio to then process any necessary data conversion and then pass it to the miniaudio data callback.
-
-If the backend requires absolute flexibility with it's data delivery, it can optionally implement the `onDeviceWorkerThread()` callback
-which will allow it to implement the logic that will run on the audio thread. This is much more advanced and is completely optional.
-
-The audio thread should run data delivery logic in a loop while `ma_device_get_state() == MA_STATE_STARTED` and no errors have been
-encounted. Do not start or stop the device here. That will be handled from outside the `onDeviceDataLoop()` callback.
-
-The invocation of the `onDeviceDataLoop()` callback will be handled by miniaudio. When you start the device, miniaudio will fire this
-callback. When the device is stopped, the `ma_device_get_state() == MA_STATE_STARTED` condition will fail and the loop will be terminated
-which will then fall through to the part that stops the device. For an example on how to implement the `onDeviceDataLoop()` callback,
-look at `ma_device_audio_thread__default_read_write()`. Implement the `onDeviceDataLoopWakeup()` callback if you need a mechanism to
-wake up the audio thread.
-*/
-struct ma_backend_callbacks
-{
-    ma_result (* onContextInit)(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks);
-    ma_result (* onContextUninit)(ma_context* pContext);
-    ma_result (* onContextEnumerateDevices)(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData);
-    ma_result (* onContextGetDeviceInfo)(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo);
-    ma_result (* onDeviceInit)(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture);
-    ma_result (* onDeviceUninit)(ma_device* pDevice);
-    ma_result (* onDeviceStart)(ma_device* pDevice);
-    ma_result (* onDeviceStop)(ma_device* pDevice);
-    ma_result (* onDeviceRead)(ma_device* pDevice, void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesRead);
-    ma_result (* onDeviceWrite)(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten);
-    ma_result (* onDeviceDataLoop)(ma_device* pDevice);
-    ma_result (* onDeviceDataLoopWakeup)(ma_device* pDevice);
-};
-
-struct ma_context_config
-{
-    ma_log_proc logCallback;
-    ma_thread_priority threadPriority;
-    size_t threadStackSize;
-    void* pUserData;
-    ma_allocation_callbacks allocationCallbacks;
-    struct
-    {
-        ma_bool32 useVerboseDeviceEnumeration;
-    } alsa;
-    struct
-    {
-        const char* pApplicationName;
-        const char* pServerName;
-        ma_bool32 tryAutoSpawn; /* Enables autospawning of the PulseAudio daemon if necessary. */
-    } pulse;
-    struct
-    {
-        ma_ios_session_category sessionCategory;
-        ma_uint32 sessionCategoryOptions;
-        ma_bool32 noAudioSessionActivate;   /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:true] on initialization. */
-        ma_bool32 noAudioSessionDeactivate; /* iOS only. When set to true, does not perform an explicit [[AVAudioSession sharedInstace] setActive:false] on uninitialization. */
-    } coreaudio;
-    struct
-    {
-        const char* pClientName;
-        ma_bool32 tryStartServer;
-    } jack;
-    ma_backend_callbacks custom;
-};
-
-/* WASAPI specific structure for some commands which must run on a common thread due to bugs in WASAPI. */
-typedef struct
-{
-    int code;
-    ma_event* pEvent;   /* This will be signalled when the event is complete. */
-    union
-    {
-        struct
-        {
-            int _unused;
-        } quit;
-        struct
-        {
-            ma_device_type deviceType;
-            void* pAudioClient;
-            void** ppAudioClientService;
-            ma_result result;   /* The result from creating the audio client service. */
-        } createAudioClient;
-        struct
-        {
-            ma_device* pDevice;
-            ma_device_type deviceType;
-        } releaseAudioClient;
-    } data;
-} ma_context_command__wasapi;
-
-struct ma_context
-{
-    ma_backend_callbacks callbacks;
-    ma_backend backend;                 /* DirectSound, ALSA, etc. */
-    ma_log_proc logCallback;
-    ma_thread_priority threadPriority;
-    size_t threadStackSize;
-    void* pUserData;
-    ma_allocation_callbacks allocationCallbacks;
-    ma_mutex deviceEnumLock;            /* Used to make ma_context_get_devices() thread safe. */
-    ma_mutex deviceInfoLock;            /* Used to make ma_context_get_device_info() thread safe. */
-    ma_uint32 deviceInfoCapacity;       /* Total capacity of pDeviceInfos. */
-    ma_uint32 playbackDeviceInfoCount;
-    ma_uint32 captureDeviceInfoCount;
-    ma_device_info* pDeviceInfos;       /* Playback devices first, then capture. */
-
-    union
-    {
-#ifdef MA_SUPPORT_WASAPI
-        struct
-        {
-            ma_thread commandThread;
-            ma_mutex commandLock;
-            ma_semaphore commandSem;
-            ma_uint32 commandIndex;
-            ma_uint32 commandCount;
-            ma_context_command__wasapi commands[4];
-        } wasapi;
-#endif
-#ifdef MA_SUPPORT_DSOUND
-        struct
-        {
-            ma_handle hDSoundDLL;
-            ma_proc DirectSoundCreate;
-            ma_proc DirectSoundEnumerateA;
-            ma_proc DirectSoundCaptureCreate;
-            ma_proc DirectSoundCaptureEnumerateA;
-        } dsound;
-#endif
-#ifdef MA_SUPPORT_WINMM
-        struct
-        {
-            ma_handle hWinMM;
-            ma_proc waveOutGetNumDevs;
-            ma_proc waveOutGetDevCapsA;
-            ma_proc waveOutOpen;
-            ma_proc waveOutClose;
-            ma_proc waveOutPrepareHeader;
-            ma_proc waveOutUnprepareHeader;
-            ma_proc waveOutWrite;
-            ma_proc waveOutReset;
-            ma_proc waveInGetNumDevs;
-            ma_proc waveInGetDevCapsA;
-            ma_proc waveInOpen;
-            ma_proc waveInClose;
-            ma_proc waveInPrepareHeader;
-            ma_proc waveInUnprepareHeader;
-            ma_proc waveInAddBuffer;
-            ma_proc waveInStart;
-            ma_proc waveInReset;
-        } winmm;
-#endif
-#ifdef MA_SUPPORT_ALSA
-        struct
-        {
-            ma_handle asoundSO;
-            ma_proc snd_pcm_open;
-            ma_proc snd_pcm_close;
-            ma_proc snd_pcm_hw_params_sizeof;
-            ma_proc snd_pcm_hw_params_any;
-            ma_proc snd_pcm_hw_params_set_format;
-            ma_proc snd_pcm_hw_params_set_format_first;
-            ma_proc snd_pcm_hw_params_get_format_mask;
-            ma_proc snd_pcm_hw_params_set_channels;
-            ma_proc snd_pcm_hw_params_set_channels_near;
-            ma_proc snd_pcm_hw_params_set_channels_minmax;
-            ma_proc snd_pcm_hw_params_set_rate_resample;
-            ma_proc snd_pcm_hw_params_set_rate;
-            ma_proc snd_pcm_hw_params_set_rate_near;
-            ma_proc snd_pcm_hw_params_set_buffer_size_near;
-            ma_proc snd_pcm_hw_params_set_periods_near;
-            ma_proc snd_pcm_hw_params_set_access;
-            ma_proc snd_pcm_hw_params_get_format;
-            ma_proc snd_pcm_hw_params_get_channels;
-            ma_proc snd_pcm_hw_params_get_channels_min;
-            ma_proc snd_pcm_hw_params_get_channels_max;
-            ma_proc snd_pcm_hw_params_get_rate;
-            ma_proc snd_pcm_hw_params_get_rate_min;
-            ma_proc snd_pcm_hw_params_get_rate_max;
-            ma_proc snd_pcm_hw_params_get_buffer_size;
-            ma_proc snd_pcm_hw_params_get_periods;
-            ma_proc snd_pcm_hw_params_get_access;
-            ma_proc snd_pcm_hw_params_test_format;
-            ma_proc snd_pcm_hw_params_test_channels;
-            ma_proc snd_pcm_hw_params_test_rate;
-            ma_proc snd_pcm_hw_params;
-            ma_proc snd_pcm_sw_params_sizeof;
-            ma_proc snd_pcm_sw_params_current;
-            ma_proc snd_pcm_sw_params_get_boundary;
-            ma_proc snd_pcm_sw_params_set_avail_min;
-            ma_proc snd_pcm_sw_params_set_start_threshold;
-            ma_proc snd_pcm_sw_params_set_stop_threshold;
-            ma_proc snd_pcm_sw_params;
-            ma_proc snd_pcm_format_mask_sizeof;
-            ma_proc snd_pcm_format_mask_test;
-            ma_proc snd_pcm_get_chmap;
-            ma_proc snd_pcm_state;
-            ma_proc snd_pcm_prepare;
-            ma_proc snd_pcm_start;
-            ma_proc snd_pcm_drop;
-            ma_proc snd_pcm_drain;
-            ma_proc snd_device_name_hint;
-            ma_proc snd_device_name_get_hint;
-            ma_proc snd_card_get_index;
-            ma_proc snd_device_name_free_hint;
-            ma_proc snd_pcm_mmap_begin;
-            ma_proc snd_pcm_mmap_commit;
-            ma_proc snd_pcm_recover;
-            ma_proc snd_pcm_readi;
-            ma_proc snd_pcm_writei;
-            ma_proc snd_pcm_avail;
-            ma_proc snd_pcm_avail_update;
-            ma_proc snd_pcm_wait;
-            ma_proc snd_pcm_info;
-            ma_proc snd_pcm_info_sizeof;
-            ma_proc snd_pcm_info_get_name;
-            ma_proc snd_config_update_free_global;
-
-            ma_mutex internalDeviceEnumLock;
-            ma_bool32 useVerboseDeviceEnumeration;
-        } alsa;
-#endif
-#ifdef MA_SUPPORT_PULSEAUDIO
-        struct
-        {
-            ma_handle pulseSO;
-            ma_proc pa_mainloop_new;
-            ma_proc pa_mainloop_free;
-            ma_proc pa_mainloop_quit;
-            ma_proc pa_mainloop_get_api;
-            ma_proc pa_mainloop_iterate;
-            ma_proc pa_mainloop_wakeup;
-            ma_proc pa_threaded_mainloop_new;
-            ma_proc pa_threaded_mainloop_free;
-            ma_proc pa_threaded_mainloop_start;
-            ma_proc pa_threaded_mainloop_stop;
-            ma_proc pa_threaded_mainloop_lock;
-            ma_proc pa_threaded_mainloop_unlock;
-            ma_proc pa_threaded_mainloop_wait;
-            ma_proc pa_threaded_mainloop_signal;
-            ma_proc pa_threaded_mainloop_accept;
-            ma_proc pa_threaded_mainloop_get_retval;
-            ma_proc pa_threaded_mainloop_get_api;
-            ma_proc pa_threaded_mainloop_in_thread;
-            ma_proc pa_threaded_mainloop_set_name;
-            ma_proc pa_context_new;
-            ma_proc pa_context_unref;
-            ma_proc pa_context_connect;
-            ma_proc pa_context_disconnect;
-            ma_proc pa_context_set_state_callback;
-            ma_proc pa_context_get_state;
-            ma_proc pa_context_get_sink_info_list;
-            ma_proc pa_context_get_source_info_list;
-            ma_proc pa_context_get_sink_info_by_name;
-            ma_proc pa_context_get_source_info_by_name;
-            ma_proc pa_operation_unref;
-            ma_proc pa_operation_get_state;
-            ma_proc pa_channel_map_init_extend;
-            ma_proc pa_channel_map_valid;
-            ma_proc pa_channel_map_compatible;
-            ma_proc pa_stream_new;
-            ma_proc pa_stream_unref;
-            ma_proc pa_stream_connect_playback;
-            ma_proc pa_stream_connect_record;
-            ma_proc pa_stream_disconnect;
-            ma_proc pa_stream_get_state;
-            ma_proc pa_stream_get_sample_spec;
-            ma_proc pa_stream_get_channel_map;
-            ma_proc pa_stream_get_buffer_attr;
-            ma_proc pa_stream_set_buffer_attr;
-            ma_proc pa_stream_get_device_name;
-            ma_proc pa_stream_set_write_callback;
-            ma_proc pa_stream_set_read_callback;
-            ma_proc pa_stream_flush;
-            ma_proc pa_stream_drain;
-            ma_proc pa_stream_is_corked;
-            ma_proc pa_stream_cork;
-            ma_proc pa_stream_trigger;
-            ma_proc pa_stream_begin_write;
-            ma_proc pa_stream_write;
-            ma_proc pa_stream_peek;
-            ma_proc pa_stream_drop;
-            ma_proc pa_stream_writable_size;
-            ma_proc pa_stream_readable_size;
-
-            /*pa_mainloop**/ ma_ptr pMainLoop;
-            /*pa_context**/ ma_ptr pPulseContext;
-        } pulse;
-#endif
-#ifdef MA_SUPPORT_JACK
-        struct
-        {
-            ma_handle jackSO;
-            ma_proc jack_client_open;
-            ma_proc jack_client_close;
-            ma_proc jack_client_name_size;
-            ma_proc jack_set_process_callback;
-            ma_proc jack_set_buffer_size_callback;
-            ma_proc jack_on_shutdown;
-            ma_proc jack_get_sample_rate;
-            ma_proc jack_get_buffer_size;
-            ma_proc jack_get_ports;
-            ma_proc jack_activate;
-            ma_proc jack_deactivate;
-            ma_proc jack_connect;
-            ma_proc jack_port_register;
-            ma_proc jack_port_name;
-            ma_proc jack_port_get_buffer;
-            ma_proc jack_free;
-
-            char* pClientName;
-            ma_bool32 tryStartServer;
-        } jack;
-#endif
-#ifdef MA_SUPPORT_COREAUDIO
-        struct
-        {
-            ma_handle hCoreFoundation;
-            ma_proc CFStringGetCString;
-            ma_proc CFRelease;
-
-            ma_handle hCoreAudio;
-            ma_proc AudioObjectGetPropertyData;
-            ma_proc AudioObjectGetPropertyDataSize;
-            ma_proc AudioObjectSetPropertyData;
-            ma_proc AudioObjectAddPropertyListener;
-            ma_proc AudioObjectRemovePropertyListener;
-
-            ma_handle hAudioUnit;  /* Could possibly be set to AudioToolbox on later versions of macOS. */
-            ma_proc AudioComponentFindNext;
-            ma_proc AudioComponentInstanceDispose;
-            ma_proc AudioComponentInstanceNew;
-            ma_proc AudioOutputUnitStart;
-            ma_proc AudioOutputUnitStop;
-            ma_proc AudioUnitAddPropertyListener;
-            ma_proc AudioUnitGetPropertyInfo;
-            ma_proc AudioUnitGetProperty;
-            ma_proc AudioUnitSetProperty;
-            ma_proc AudioUnitInitialize;
-            ma_proc AudioUnitRender;
-
-            /*AudioComponent*/ ma_ptr component;
-            ma_bool32 noAudioSessionDeactivate; /* For tracking whether or not the iOS audio session should be explicitly deactivated. Set from the config in ma_context_init__coreaudio(). */
-        } coreaudio;
-#endif
-#ifdef MA_SUPPORT_SNDIO
-        struct
-        {
-            ma_handle sndioSO;
-            ma_proc sio_open;
-            ma_proc sio_close;
-            ma_proc sio_setpar;
-            ma_proc sio_getpar;
-            ma_proc sio_getcap;
-            ma_proc sio_start;
-            ma_proc sio_stop;
-            ma_proc sio_read;
-            ma_proc sio_write;
-            ma_proc sio_onmove;
-            ma_proc sio_nfds;
-            ma_proc sio_pollfd;
-            ma_proc sio_revents;
-            ma_proc sio_eof;
-            ma_proc sio_setvol;
-            ma_proc sio_onvol;
-            ma_proc sio_initpar;
-        } sndio;
-#endif
-#ifdef MA_SUPPORT_AUDIO4
-        struct
-        {
-            int _unused;
-        } audio4;
-#endif
-#ifdef MA_SUPPORT_OSS
-        struct
-        {
-            int versionMajor;
-            int versionMinor;
-        } oss;
-#endif
-#ifdef MA_SUPPORT_AAUDIO
-        struct
-        {
-            ma_handle hAAudio; /* libaaudio.so */
-            ma_proc AAudio_createStreamBuilder;
-            ma_proc AAudioStreamBuilder_delete;
-            ma_proc AAudioStreamBuilder_setDeviceId;
-            ma_proc AAudioStreamBuilder_setDirection;
-            ma_proc AAudioStreamBuilder_setSharingMode;
-            ma_proc AAudioStreamBuilder_setFormat;
-            ma_proc AAudioStreamBuilder_setChannelCount;
-            ma_proc AAudioStreamBuilder_setSampleRate;
-            ma_proc AAudioStreamBuilder_setBufferCapacityInFrames;
-            ma_proc AAudioStreamBuilder_setFramesPerDataCallback;
-            ma_proc AAudioStreamBuilder_setDataCallback;
-            ma_proc AAudioStreamBuilder_setErrorCallback;
-            ma_proc AAudioStreamBuilder_setPerformanceMode;
-            ma_proc AAudioStreamBuilder_setUsage;
-            ma_proc AAudioStreamBuilder_setContentType;
-            ma_proc AAudioStreamBuilder_setInputPreset;
-            ma_proc AAudioStreamBuilder_openStream;
-            ma_proc AAudioStream_close;
-            ma_proc AAudioStream_getState;
-            ma_proc AAudioStream_waitForStateChange;
-            ma_proc AAudioStream_getFormat;
-            ma_proc AAudioStream_getChannelCount;
-            ma_proc AAudioStream_getSampleRate;
-            ma_proc AAudioStream_getBufferCapacityInFrames;
-            ma_proc AAudioStream_getFramesPerDataCallback;
-            ma_proc AAudioStream_getFramesPerBurst;
-            ma_proc AAudioStream_requestStart;
-            ma_proc AAudioStream_requestStop;
-        } aaudio;
-#endif
-#ifdef MA_SUPPORT_OPENSL
-        struct
-        {
-            ma_handle libOpenSLES;
-            ma_handle SL_IID_ENGINE;
-            ma_handle SL_IID_AUDIOIODEVICECAPABILITIES;
-            ma_handle SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-            ma_handle SL_IID_RECORD;
-            ma_handle SL_IID_PLAY;
-            ma_handle SL_IID_OUTPUTMIX;
-            ma_handle SL_IID_ANDROIDCONFIGURATION;
-            ma_proc   slCreateEngine;
-        } opensl;
-#endif
-#ifdef MA_SUPPORT_WEBAUDIO
-        struct
-        {
-            int _unused;
-        } webaudio;
-#endif
-#ifdef MA_SUPPORT_NULL
-        struct
-        {
-            int _unused;
-        } null_backend;
-#endif
-    };
-
-    union
-    {
-#ifdef MA_WIN32
-        struct
-        {
-            /*HMODULE*/ ma_handle hOle32DLL;
-            ma_proc CoInitializeEx;
-            ma_proc CoUninitialize;
-            ma_proc CoCreateInstance;
-            ma_proc CoTaskMemFree;
-            ma_proc PropVariantClear;
-            ma_proc StringFromGUID2;
-
-            /*HMODULE*/ ma_handle hUser32DLL;
-            ma_proc GetForegroundWindow;
-            ma_proc GetDesktopWindow;
-
-            /*HMODULE*/ ma_handle hAdvapi32DLL;
-            ma_proc RegOpenKeyExA;
-            ma_proc RegCloseKey;
-            ma_proc RegQueryValueExA;
-        } win32;
-#endif
-#ifdef MA_POSIX
-        struct
-        {
-            ma_handle pthreadSO;
-            ma_proc pthread_create;
-            ma_proc pthread_join;
-            ma_proc pthread_mutex_init;
-            ma_proc pthread_mutex_destroy;
-            ma_proc pthread_mutex_lock;
-            ma_proc pthread_mutex_unlock;
-            ma_proc pthread_cond_init;
-            ma_proc pthread_cond_destroy;
-            ma_proc pthread_cond_wait;
-            ma_proc pthread_cond_signal;
-            ma_proc pthread_attr_init;
-            ma_proc pthread_attr_destroy;
-            ma_proc pthread_attr_setschedpolicy;
-            ma_proc pthread_attr_getschedparam;
-            ma_proc pthread_attr_setschedparam;
-        } posix;
-#endif
-        int _unused;
-    };
-};
-
-struct ma_device
-{
-    ma_context* pContext;
-    ma_device_type type;
-    ma_uint32 sampleRate;
-    MA_ATOMIC ma_uint32 state;              /* The state of the device is variable and can change at any time on any thread. Must be used atomically. */
-    ma_device_callback_proc onData;         /* Set once at initialization time and should not be changed after. */
-    ma_stop_proc onStop;                    /* Set once at initialization time and should not be changed after. */
-    void* pUserData;                        /* Application defined data. */
-    ma_mutex startStopLock;
-    ma_event wakeupEvent;
-    ma_event startEvent;
-    ma_event stopEvent;
-    ma_thread thread;
-    ma_result workResult;                   /* This is set by the worker thread after it's finished doing a job. */
-    ma_bool8 isOwnerOfContext;              /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
-    ma_bool8 noPreZeroedOutputBuffer;
-    ma_bool8 noClip;
-    MA_ATOMIC float masterVolumeFactor;     /* Linear 0..1. Can be read and written simultaneously by different threads. Must be used atomically. */
-    ma_duplex_rb duplexRB;                  /* Intermediary buffer for duplex device on asynchronous backends. */
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    struct
-    {
-        ma_device_id id;                    /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
-        char name[256];                     /* Maybe temporary. Likely to be replaced with a query API. */
-        ma_share_mode shareMode;            /* Set to whatever was passed in when the device was initialized. */
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_format internalFormat;
-        ma_uint32 internalChannels;
-        ma_uint32 internalSampleRate;
-        ma_channel internalChannelMap[MA_MAX_CHANNELS];
-        ma_uint32 internalPeriodSizeInFrames;
-        ma_uint32 internalPeriods;
-        ma_channel_mix_mode channelMixMode;
-        ma_data_converter converter;
-    } playback;
-    struct
-    {
-        ma_device_id id;                    /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
-        char name[256];                     /* Maybe temporary. Likely to be replaced with a query API. */
-        ma_share_mode shareMode;            /* Set to whatever was passed in when the device was initialized. */
-        ma_format format;
-        ma_uint32 channels;
-        ma_channel channelMap[MA_MAX_CHANNELS];
-        ma_format internalFormat;
-        ma_uint32 internalChannels;
-        ma_uint32 internalSampleRate;
-        ma_channel internalChannelMap[MA_MAX_CHANNELS];
-        ma_uint32 internalPeriodSizeInFrames;
-        ma_uint32 internalPeriods;
-        ma_channel_mix_mode channelMixMode;
-        ma_data_converter converter;
-    } capture;
-
-    union
-    {
-#ifdef MA_SUPPORT_WASAPI
-        struct
-        {
-            /*IAudioClient**/ ma_ptr pAudioClientPlayback;
-            /*IAudioClient**/ ma_ptr pAudioClientCapture;
-            /*IAudioRenderClient**/ ma_ptr pRenderClient;
-            /*IAudioCaptureClient**/ ma_ptr pCaptureClient;
-            /*IMMDeviceEnumerator**/ ma_ptr pDeviceEnumerator;      /* Used for IMMNotificationClient notifications. Required for detecting default device changes. */
-            ma_IMMNotificationClient notificationClient;
-            /*HANDLE*/ ma_handle hEventPlayback;                    /* Auto reset. Initialized to signaled. */
-            /*HANDLE*/ ma_handle hEventCapture;                     /* Auto reset. Initialized to unsignaled. */
-            ma_uint32 actualPeriodSizeInFramesPlayback;             /* Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. */
-            ma_uint32 actualPeriodSizeInFramesCapture;
-            ma_uint32 originalPeriodSizeInFrames;
-            ma_uint32 originalPeriodSizeInMilliseconds;
-            ma_uint32 originalPeriods;
-            ma_performance_profile originalPerformanceProfile;
-            ma_uint32 periodSizeInFramesPlayback;
-            ma_uint32 periodSizeInFramesCapture;
-            MA_ATOMIC ma_bool32 isStartedCapture;                   /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
-            MA_ATOMIC ma_bool32 isStartedPlayback;                  /* Can be read and written simultaneously across different threads. Must be used atomically, and must be 32-bit. */
-            ma_bool8 noAutoConvertSRC;                              /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
-            ma_bool8 noDefaultQualitySRC;                           /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
-            ma_bool8 noHardwareOffloading;
-            ma_bool8 allowCaptureAutoStreamRouting;
-            ma_bool8 allowPlaybackAutoStreamRouting;
-            ma_bool8 isDetachedPlayback;
-            ma_bool8 isDetachedCapture;
-        } wasapi;
-#endif
-#ifdef MA_SUPPORT_DSOUND
-        struct
-        {
-            /*LPDIRECTSOUND*/ ma_ptr pPlayback;
-            /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackPrimaryBuffer;
-            /*LPDIRECTSOUNDBUFFER*/ ma_ptr pPlaybackBuffer;
-            /*LPDIRECTSOUNDCAPTURE*/ ma_ptr pCapture;
-            /*LPDIRECTSOUNDCAPTUREBUFFER*/ ma_ptr pCaptureBuffer;
-        } dsound;
-#endif
-#ifdef MA_SUPPORT_WINMM
-        struct
-        {
-            /*HWAVEOUT*/ ma_handle hDevicePlayback;
-            /*HWAVEIN*/ ma_handle hDeviceCapture;
-            /*HANDLE*/ ma_handle hEventPlayback;
-            /*HANDLE*/ ma_handle hEventCapture;
-            ma_uint32 fragmentSizeInFrames;
-            ma_uint32 iNextHeaderPlayback;             /* [0,periods). Used as an index into pWAVEHDRPlayback. */
-            ma_uint32 iNextHeaderCapture;              /* [0,periods). Used as an index into pWAVEHDRCapture. */
-            ma_uint32 headerFramesConsumedPlayback;    /* The number of PCM frames consumed in the buffer in pWAVEHEADER[iNextHeader]. */
-            ma_uint32 headerFramesConsumedCapture;     /* ^^^ */
-            /*WAVEHDR**/ ma_uint8* pWAVEHDRPlayback;   /* One instantiation for each period. */
-            /*WAVEHDR**/ ma_uint8* pWAVEHDRCapture;    /* One instantiation for each period. */
-            ma_uint8* pIntermediaryBufferPlayback;
-            ma_uint8* pIntermediaryBufferCapture;
-            ma_uint8* _pHeapData;                      /* Used internally and is used for the heap allocated data for the intermediary buffer and the WAVEHDR structures. */
-        } winmm;
-#endif
-#ifdef MA_SUPPORT_ALSA
-        struct
-        {
-            /*snd_pcm_t**/ ma_ptr pPCMPlayback;
-            /*snd_pcm_t**/ ma_ptr pPCMCapture;
-            ma_bool8 isUsingMMapPlayback;
-            ma_bool8 isUsingMMapCapture;
-        } alsa;
-#endif
-#ifdef MA_SUPPORT_PULSEAUDIO
-        struct
-        {
-            /*pa_stream**/ ma_ptr pStreamPlayback;
-            /*pa_stream**/ ma_ptr pStreamCapture;
-        } pulse;
-#endif
-#ifdef MA_SUPPORT_JACK
-        struct
-        {
-            /*jack_client_t**/ ma_ptr pClient;
-            /*jack_port_t**/ ma_ptr pPortsPlayback[MA_MAX_CHANNELS];
-            /*jack_port_t**/ ma_ptr pPortsCapture[MA_MAX_CHANNELS];
-            float* pIntermediaryBufferPlayback; /* Typed as a float because JACK is always floating point. */
-            float* pIntermediaryBufferCapture;
-        } jack;
-#endif
-#ifdef MA_SUPPORT_COREAUDIO
-        struct
-        {
-            ma_uint32 deviceObjectIDPlayback;
-            ma_uint32 deviceObjectIDCapture;
-            /*AudioUnit*/ ma_ptr audioUnitPlayback;
-            /*AudioUnit*/ ma_ptr audioUnitCapture;
-            /*AudioBufferList**/ ma_ptr pAudioBufferList;   /* Only used for input devices. */
-            ma_uint32 audioBufferCapInFrames;               /* Only used for input devices. The capacity in frames of each buffer in pAudioBufferList. */
-            ma_event stopEvent;
-            ma_uint32 originalPeriodSizeInFrames;
-            ma_uint32 originalPeriodSizeInMilliseconds;
-            ma_uint32 originalPeriods;
-            ma_performance_profile originalPerformanceProfile;
-            ma_bool32 isDefaultPlaybackDevice;
-            ma_bool32 isDefaultCaptureDevice;
-            ma_bool32 isSwitchingPlaybackDevice;   /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
-            ma_bool32 isSwitchingCaptureDevice;    /* <-- Set to true when the default device has changed and miniaudio is in the process of switching. */
-            void* pRouteChangeHandler;             /* Only used on mobile platforms. Obj-C object for handling route changes. */
-        } coreaudio;
-#endif
-#ifdef MA_SUPPORT_SNDIO
-        struct
-        {
-            ma_ptr handlePlayback;
-            ma_ptr handleCapture;
-            ma_bool32 isStartedPlayback;
-            ma_bool32 isStartedCapture;
-        } sndio;
-#endif
-#ifdef MA_SUPPORT_AUDIO4
-        struct
-        {
-            int fdPlayback;
-            int fdCapture;
-        } audio4;
-#endif
-#ifdef MA_SUPPORT_OSS
-        struct
-        {
-            int fdPlayback;
-            int fdCapture;
-        } oss;
-#endif
-#ifdef MA_SUPPORT_AAUDIO
-        struct
-        {
-            /*AAudioStream**/ ma_ptr pStreamPlayback;
-            /*AAudioStream**/ ma_ptr pStreamCapture;
-        } aaudio;
-#endif
-#ifdef MA_SUPPORT_OPENSL
-        struct
-        {
-            /*SLObjectItf*/ ma_ptr pOutputMixObj;
-            /*SLOutputMixItf*/ ma_ptr pOutputMix;
-            /*SLObjectItf*/ ma_ptr pAudioPlayerObj;
-            /*SLPlayItf*/ ma_ptr pAudioPlayer;
-            /*SLObjectItf*/ ma_ptr pAudioRecorderObj;
-            /*SLRecordItf*/ ma_ptr pAudioRecorder;
-            /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueuePlayback;
-            /*SLAndroidSimpleBufferQueueItf*/ ma_ptr pBufferQueueCapture;
-            ma_bool32 isDrainingCapture;
-            ma_bool32 isDrainingPlayback;
-            ma_uint32 currentBufferIndexPlayback;
-            ma_uint32 currentBufferIndexCapture;
-            ma_uint8* pBufferPlayback;      /* This is malloc()'d and is used for storing audio data. Typed as ma_uint8 for easy offsetting. */
-            ma_uint8* pBufferCapture;
-        } opensl;
-#endif
-#ifdef MA_SUPPORT_WEBAUDIO
-        struct
-        {
-            int indexPlayback;              /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */
-            int indexCapture;
-        } webaudio;
-#endif
-#ifdef MA_SUPPORT_NULL
-        struct
-        {
-            ma_thread deviceThread;
-            ma_event operationEvent;
-            ma_event operationCompletionEvent;
-            ma_semaphore operationSemaphore;
-            ma_uint32 operation;
-            ma_result operationResult;
-            ma_timer timer;
-            double priorRunTime;
-            ma_uint32 currentPeriodFramesRemainingPlayback;
-            ma_uint32 currentPeriodFramesRemainingCapture;
-            ma_uint64 lastProcessedFramePlayback;
-            ma_uint64 lastProcessedFrameCapture;
-            MA_ATOMIC ma_bool32 isStarted;   /* Read and written by multiple threads. Must be used atomically, and must be 32-bit for compiler compatibility. */
-        } null_device;
-#endif
-    };
-};
-#if defined(_MSC_VER) && !defined(__clang__)
-    #pragma warning(pop)
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
-    #pragma GCC diagnostic pop  /* For ISO C99 doesn't support unnamed structs/unions [-Wpedantic] */
-#endif
-
-/*
-Initializes a `ma_context_config` object.
-
-
-Return Value
-------------
-A `ma_context_config` initialized to defaults.
-
-
-Remarks
--------
-You must always use this to initialize the default state of the `ma_context_config` object. Not using this will result in your program breaking when miniaudio
-is updated and new members are added to `ma_context_config`. It also sets logical defaults.
-
-You can override members of the returned object by changing it's members directly.
-
-
-See Also
---------
-ma_context_init()
-*/
-MA_API ma_context_config ma_context_config_init(void);
-
-/*
-Initializes a context.
-
-The context is used for selecting and initializing an appropriate backend and to represent the backend at a more global level than that of an individual
-device. There is one context to many devices, and a device is created from a context. A context is required to enumerate devices.
-
-
-Parameters
-----------
-backends (in, optional)
-    A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
-
-backendCount (in, optional)
-    The number of items in `backend`. Ignored if `backend` is NULL.
-
-pConfig (in, optional)
-    The context configuration.
-
-pContext (in)
-    A pointer to the context object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Do not call this function across multiple threads as some backends read and write to global state.
-
-
-Remarks
--------
-When `backends` is NULL, the default priority order will be used. Below is a list of backends in priority order:
-
-    |-------------|-----------------------|--------------------------------------------------------|
-    | Name        | Enum Name             | Supported Operating Systems                            |
-    |-------------|-----------------------|--------------------------------------------------------|
-    | WASAPI      | ma_backend_wasapi     | Windows Vista+                                         |
-    | DirectSound | ma_backend_dsound     | Windows XP+                                            |
-    | WinMM       | ma_backend_winmm      | Windows XP+ (may work on older versions, but untested) |
-    | Core Audio  | ma_backend_coreaudio  | macOS, iOS                                             |
-    | ALSA        | ma_backend_alsa       | Linux                                                  |
-    | PulseAudio  | ma_backend_pulseaudio | Cross Platform (disabled on Windows, BSD and Android)  |
-    | JACK        | ma_backend_jack       | Cross Platform (disabled on BSD and Android)           |
-    | sndio       | ma_backend_sndio      | OpenBSD                                                |
-    | audio(4)    | ma_backend_audio4     | NetBSD, OpenBSD                                        |
-    | OSS         | ma_backend_oss        | FreeBSD                                                |
-    | AAudio      | ma_backend_aaudio     | Android 8+                                             |
-    | OpenSL|ES   | ma_backend_opensl     | Android (API level 16+)                                |
-    | Web Audio   | ma_backend_webaudio   | Web (via Emscripten)                                   |
-    | Null        | ma_backend_null       | Cross Platform (not used on Web)                       |
-    |-------------|-----------------------|--------------------------------------------------------|
-
-The context can be configured via the `pConfig` argument. The config object is initialized with `ma_context_config_init()`. Individual configuration settings
-can then be set directly on the structure. Below are the members of the `ma_context_config` object.
-
-    logCallback
-        Callback for handling log messages from miniaudio.
-
-    threadPriority
-        The desired priority to use for the audio thread. Allowable values include the following:
-
-        |--------------------------------------|
-        | Thread Priority                      |
-        |--------------------------------------|
-        | ma_thread_priority_idle              |
-        | ma_thread_priority_lowest            |
-        | ma_thread_priority_low               |
-        | ma_thread_priority_normal            |
-        | ma_thread_priority_high              |
-        | ma_thread_priority_highest (default) |
-        | ma_thread_priority_realtime          |
-        | ma_thread_priority_default           |
-        |--------------------------------------|
-
-    pUserData
-        A pointer to application-defined data. This can be accessed from the context object directly such as `context.pUserData`.
-
-    allocationCallbacks
-        Structure containing custom allocation callbacks. Leaving this at defaults will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. These allocation
-        callbacks will be used for anything tied to the context, including devices.
-
-    alsa.useVerboseDeviceEnumeration
-        ALSA will typically enumerate many different devices which can be intrusive and not user-friendly. To combat this, miniaudio will enumerate only unique
-        card/device pairs by default. The problem with this is that you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes
-        it so the ALSA backend includes all devices. Defaults to false.
-
-    pulse.pApplicationName
-        PulseAudio only. The application name to use when initializing the PulseAudio context with `pa_context_new()`.
-
-    pulse.pServerName
-        PulseAudio only. The name of the server to connect to with `pa_context_connect()`.
-
-    pulse.tryAutoSpawn
-        PulseAudio only. Whether or not to try automatically starting the PulseAudio daemon. Defaults to false. If you set this to true, keep in mind that
-        miniaudio uses a trial and error method to find the most appropriate backend, and this will result in the PulseAudio daemon starting which may be
-        intrusive for the end user.
-
-    coreaudio.sessionCategory
-        iOS only. The session category to use for the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
-
-        |-----------------------------------------|-------------------------------------|
-        | miniaudio Token                         | Core Audio Token                    |
-        |-----------------------------------------|-------------------------------------|
-        | ma_ios_session_category_ambient         | AVAudioSessionCategoryAmbient       |
-        | ma_ios_session_category_solo_ambient    | AVAudioSessionCategorySoloAmbient   |
-        | ma_ios_session_category_playback        | AVAudioSessionCategoryPlayback      |
-        | ma_ios_session_category_record          | AVAudioSessionCategoryRecord        |
-        | ma_ios_session_category_play_and_record | AVAudioSessionCategoryPlayAndRecord |
-        | ma_ios_session_category_multi_route     | AVAudioSessionCategoryMultiRoute    |
-        | ma_ios_session_category_none            | AVAudioSessionCategoryAmbient       |
-        | ma_ios_session_category_default         | AVAudioSessionCategoryAmbient       |
-        |-----------------------------------------|-------------------------------------|
-
-    coreaudio.sessionCategoryOptions
-        iOS only. Session category options to use with the shared AudioSession instance. Below is a list of allowable values and their Core Audio equivalents.
-
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-        | miniaudio Token                                                           | Core Audio Token                                                 |
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-        | ma_ios_session_category_option_mix_with_others                            | AVAudioSessionCategoryOptionMixWithOthers                        |
-        | ma_ios_session_category_option_duck_others                                | AVAudioSessionCategoryOptionDuckOthers                           |
-        | ma_ios_session_category_option_allow_bluetooth                            | AVAudioSessionCategoryOptionAllowBluetooth                       |
-        | ma_ios_session_category_option_default_to_speaker                         | AVAudioSessionCategoryOptionDefaultToSpeaker                     |
-        | ma_ios_session_category_option_interrupt_spoken_audio_and_mix_with_others | AVAudioSessionCategoryOptionInterruptSpokenAudioAndMixWithOthers |
-        | ma_ios_session_category_option_allow_bluetooth_a2dp                       | AVAudioSessionCategoryOptionAllowBluetoothA2DP                   |
-        | ma_ios_session_category_option_allow_air_play                             | AVAudioSessionCategoryOptionAllowAirPlay                         |
-        |---------------------------------------------------------------------------|------------------------------------------------------------------|
-
-    jack.pClientName
-        The name of the client to pass to `jack_client_open()`.
-
-    jack.tryStartServer
-        Whether or not to try auto-starting the JACK server. Defaults to false.
-
-
-It is recommended that only a single context is active at any given time because it's a bulky data structure which performs run-time linking for the
-relevant backends every time it's initialized.
-
-The location of the context cannot change throughout it's lifetime. Consider allocating the `ma_context` object with `malloc()` if this is an issue. The
-reason for this is that a pointer to the context is stored in the `ma_device` structure.
-
-
-Example 1 - Default Initialization
-----------------------------------
-The example below shows how to initialize the context using the default configuration.
-
-```c
-ma_context context;
-ma_result result = ma_context_init(NULL, 0, NULL, &context);
-if (result != MA_SUCCESS) {
-    // Error.
-}
-```
-
-
-Example 2 - Custom Configuration
---------------------------------
-The example below shows how to initialize the context using custom backend priorities and a custom configuration. In this hypothetical example, the program
-wants to prioritize ALSA over PulseAudio on Linux. They also want to avoid using the WinMM backend on Windows because it's latency is too high. They also
-want an error to be returned if no valid backend is available which they achieve by excluding the Null backend.
-
-For the configuration, the program wants to capture any log messages so they can, for example, route it to a log file and user interface.
-
-```c
-ma_backend backends[] = {
-    ma_backend_alsa,
-    ma_backend_pulseaudio,
-    ma_backend_wasapi,
-    ma_backend_dsound
-};
-
-ma_context_config config = ma_context_config_init();
-config.logCallback = my_log_callback;
-config.pUserData   = pMyUserData;
-
-ma_context context;
-ma_result result = ma_context_init(backends, sizeof(backends)/sizeof(backends[0]), &config, &context);
-if (result != MA_SUCCESS) {
-    // Error.
-    if (result == MA_NO_BACKEND) {
-        // Couldn't find an appropriate backend.
-    }
-}
-```
-
-
-See Also
---------
-ma_context_config_init()
-ma_context_uninit()
-*/
-MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext);
-
-/*
-Uninitializes a context.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Do not call this function across multiple threads as some backends read and write to global state.
-
-
-Remarks
--------
-Results are undefined if you call this while any device created by this context is still active.
-
-
-See Also
---------
-ma_context_init()
-*/
-MA_API ma_result ma_context_uninit(ma_context* pContext);
-
-/*
-Retrieves the size of the ma_context object.
-
-This is mainly for the purpose of bindings to know how much memory to allocate.
-*/
-MA_API size_t ma_context_sizeof(void);
-
-/*
-Enumerates over every device (both playback and capture).
-
-This is a lower-level enumeration function to the easier to use `ma_context_get_devices()`. Use `ma_context_enumerate_devices()` if you would rather not incur
-an internal heap allocation, or it simply suits your code better.
-
-Note that this only retrieves the ID and name/description of the device. The reason for only retrieving basic information is that it would otherwise require
-opening the backend device in order to probe it for more detailed information which can be inefficient. Consider using `ma_context_get_device_info()` for this,
-but don't call it from within the enumeration callback.
-
-Returning false from the callback will stop enumeration. Returning true will continue enumeration.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-callback (in)
-    The callback to fire for each enumerated device.
-
-pUserData (in)
-    A pointer to application-defined data passed to the callback.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. This is guarded using a simple mutex lock.
-
-
-Remarks
--------
-Do _not_ assume the first enumerated device of a given type is the default device.
-
-Some backends and platforms may only support default playback and capture devices.
-
-In general, you should not do anything complicated from within the callback. In particular, do not try initializing a device from within the callback. Also,
-do not try to call `ma_context_get_device_info()` from within the callback.
-
-Consider using `ma_context_get_devices()` for a simpler and safer API, albeit at the expense of an internal heap allocation.
-
-
-Example 1 - Simple Enumeration
-------------------------------
-ma_bool32 ma_device_enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData)
-{
-    printf("Device Name: %s\n", pInfo->name);
-    return MA_TRUE;
-}
-
-ma_result result = ma_context_enumerate_devices(&context, my_device_enum_callback, pMyUserData);
-if (result != MA_SUCCESS) {
-    // Error.
-}
-
-
-See Also
---------
-ma_context_get_devices()
-*/
-MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData);
-
-/*
-Retrieves basic information about every active playback and/or capture device.
-
-This function will allocate memory internally for the device lists and return a pointer to them through the `ppPlaybackDeviceInfos` and `ppCaptureDeviceInfos`
-parameters. If you do not want to incur the overhead of these allocations consider using `ma_context_enumerate_devices()` which will instead use a callback.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the enumeration.
-
-ppPlaybackDeviceInfos (out)
-    A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for playback devices.
-
-pPlaybackDeviceCount (out)
-    A pointer to an unsigned integer that will receive the number of playback devices.
-
-ppCaptureDeviceInfos (out)
-    A pointer to a pointer that will receive the address of a buffer containing the list of `ma_device_info` structures for capture devices.
-
-pCaptureDeviceCount (out)
-    A pointer to an unsigned integer that will receive the number of capture devices.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. Since each call to this function invalidates the pointers from the previous call, you should not be calling this simultaneously across multiple
-threads. Instead, you need to make a copy of the returned data with your own higher level synchronization.
-
-
-Remarks
--------
-It is _not_ safe to assume the first device in the list is the default device.
-
-You can pass in NULL for the playback or capture lists in which case they'll be ignored.
-
-The returned pointers will become invalid upon the next call this this function, or when the context is uninitialized. Do not free the returned pointers.
-
-
-See Also
---------
-ma_context_get_devices()
-*/
-MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount);
-
-/*
-Retrieves information about a device of the given type, with the specified ID and share mode.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context performing the query.
-
-deviceType (in)
-    The type of the device being queried. Must be either `ma_device_type_playback` or `ma_device_type_capture`.
-
-pDeviceID (in)
-    The ID of the device being queried.
-
-shareMode (in)
-    The share mode to query for device capabilities. This should be set to whatever you're intending on using when initializing the device. If you're unsure,
-    set this to `ma_share_mode_shared`.
-
-pDeviceInfo (out)
-    A pointer to the `ma_device_info` structure that will receive the device information.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. This is guarded using a simple mutex lock.
-
-
-Remarks
--------
-Do _not_ call this from within the `ma_context_enumerate_devices()` callback.
-
-It's possible for a device to have different information and capabilities depending on whether or not it's opened in shared or exclusive mode. For example, in
-shared mode, WASAPI always uses floating point samples for mixing, but in exclusive mode it can be anything. Therefore, this function allows you to specify
-which share mode you want information for. Note that not all backends and devices support shared or exclusive mode, in which case this function will fail if
-the requested share mode is unsupported.
-
-This leaves pDeviceInfo unmodified in the result of an error.
-*/
-MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, ma_device_info* pDeviceInfo);
-
-/*
-Determines if the given context supports loopback mode.
-
-
-Parameters
-----------
-pContext (in)
-    A pointer to the context getting queried.
-
-
-Return Value
-------------
-MA_TRUE if the context supports loopback mode; MA_FALSE otherwise.
-*/
-MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext);
-
-
-
-/*
-Initializes a device config with default settings.
-
-
-Parameters
-----------
-deviceType (in)
-    The type of the device this config is being initialized for. This must set to one of the following:
-
-    |-------------------------|
-    | Device Type             |
-    |-------------------------|
-    | ma_device_type_playback |
-    | ma_device_type_capture  |
-    | ma_device_type_duplex   |
-    | ma_device_type_loopback |
-    |-------------------------|
-
-
-Return Value
-------------
-A new device config object with default settings. You will typically want to adjust the config after this function returns. See remarks.
-
-
-Thread Safety
--------------
-Safe.
-
-
-Callback Safety
----------------
-Safe, but don't try initializing a device in a callback.
-
-
-Remarks
--------
-The returned config will be initialized to defaults. You will normally want to customize a few variables before initializing the device. See Example 1 for a
-typical configuration which sets the sample format, channel count, sample rate, data callback and user data. These are usually things you will want to change
-before initializing the device.
-
-See `ma_device_init()` for details on specific configuration options.
-
-
-Example 1 - Simple Configuration
---------------------------------
-The example below is what a program will typically want to configure for each device at a minimum. Notice how `ma_device_config_init()` is called first, and
-then the returned object is modified directly. This is important because it ensures that your program continues to work as new configuration options are added
-to the `ma_device_config` structure.
-
-```c
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.format   = ma_format_f32;
-config.playback.channels = 2;
-config.sampleRate        = 48000;
-config.dataCallback      = ma_data_callback;
-config.pUserData         = pMyUserData;
-```
-
-
-See Also
---------
-ma_device_init()
-ma_device_init_ex()
-*/
-MA_API ma_device_config ma_device_config_init(ma_device_type deviceType);
-
-
-/*
-Initializes a device.
-
-A device represents a physical audio device. The idea is you send or receive audio data from the device to either play it back through a speaker, or capture it
-from a microphone. Whether or not you should send or receive data from the device (or both) depends on the type of device you are initializing which can be
-playback, capture, full-duplex or loopback. (Note that loopback mode is only supported on select backends.) Sending and receiving audio data to and from the
-device is done via a callback which is fired by miniaudio at periodic time intervals.
-
-The frequency at which data is delivered to and from a device depends on the size of it's period. The size of the period can be defined in terms of PCM frames
-or milliseconds, whichever is more convenient. Generally speaking, the smaller the period, the lower the latency at the expense of higher CPU usage and
-increased risk of glitching due to the more frequent and granular data deliver intervals. The size of a period will depend on your requirements, but
-miniaudio's defaults should work fine for most scenarios. If you're building a game you should leave this fairly small, whereas if you're building a simple
-media player you can make it larger. Note that the period size you request is actually just a hint - miniaudio will tell the backend what you want, but the
-backend is ultimately responsible for what it gives you. You cannot assume you will get exactly what you ask for.
-
-When delivering data to and from a device you need to make sure it's in the correct format which you can set through the device configuration. You just set the
-format that you want to use and miniaudio will perform all of the necessary conversion for you internally. When delivering data to and from the callback you
-can assume the format is the same as what you requested when you initialized the device. See Remarks for more details on miniaudio's data conversion pipeline.
-
-
-Parameters
-----------
-pContext (in, optional)
-    A pointer to the context that owns the device. This can be null, in which case it creates a default context internally.
-
-pConfig (in)
-    A pointer to the device configuration. Cannot be null. See remarks for details.
-
-pDevice (out)
-    A pointer to the device object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to
-calling this at the same time as `ma_device_uninit()`.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-Setting `pContext` to NULL will result in miniaudio creating a default context internally and is equivalent to passing in a context initialized like so:
-
-    ```c
-    ma_context_init(NULL, 0, NULL, &context);
-    ```
-
-Do not set `pContext` to NULL if you are needing to open multiple devices. You can, however, use NULL when initializing the first device, and then use
-device.pContext for the initialization of other devices.
-
-The device can be configured via the `pConfig` argument. The config object is initialized with `ma_device_config_init()`. Individual configuration settings can
-then be set directly on the structure. Below are the members of the `ma_device_config` object.
-
-    deviceType
-        Must be `ma_device_type_playback`, `ma_device_type_capture`, `ma_device_type_duplex` of `ma_device_type_loopback`.
-
-    sampleRate
-        The sample rate, in hertz. The most common sample rates are 48000 and 44100. Setting this to 0 will use the device's native sample rate.
-
-    periodSizeInFrames
-        The desired size of a period in PCM frames. If this is 0, `periodSizeInMilliseconds` will be used instead. If both are 0 the default buffer size will
-        be used depending on the selected performance profile. This value affects latency. See below for details.
-
-    periodSizeInMilliseconds
-        The desired size of a period in milliseconds. If this is 0, `periodSizeInFrames` will be used instead. If both are 0 the default buffer size will be
-        used depending on the selected performance profile. The value affects latency. See below for details.
-
-    periods
-        The number of periods making up the device's entire buffer. The total buffer size is `periodSizeInFrames` or `periodSizeInMilliseconds` multiplied by
-        this value. This is just a hint as backends will be the ones who ultimately decide how your periods will be configured.
-
-    performanceProfile
-        A hint to miniaudio as to the performance requirements of your program. Can be either `ma_performance_profile_low_latency` (default) or
-        `ma_performance_profile_conservative`. This mainly affects the size of default buffers and can usually be left at it's default value.
-
-    noPreZeroedOutputBuffer
-        When set to true, the contents of the output buffer passed into the data callback will be left undefined. When set to false (default), the contents of
-        the output buffer will be cleared the zero. You can use this to avoid the overhead of zeroing out the buffer if you can guarantee that your data
-        callback will write to every sample in the output buffer, or if you are doing your own clearing.
-
-    noClip
-        When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. When set to false (default), the
-        contents of the output buffer are left alone after returning and it will be left up to the backend itself to decide whether or not the clip. This only
-        applies when the playback sample format is f32.
-
-    dataCallback
-        The callback to fire whenever data is ready to be delivered to or from the device.
-
-    stopCallback
-        The callback to fire whenever the device has stopped, either explicitly via `ma_device_stop()`, or implicitly due to things like the device being
-        disconnected.
-
-    pUserData
-        The user data pointer to use with the device. You can access this directly from the device object like `device.pUserData`.
-
-    resampling.algorithm
-        The resampling algorithm to use when miniaudio needs to perform resampling between the rate specified by `sampleRate` and the device's native rate. The
-        default value is `ma_resample_algorithm_linear`, and the quality can be configured with `resampling.linear.lpfOrder`.
-
-    resampling.linear.lpfOrder
-        The linear resampler applies a low-pass filter as part of it's procesing for anti-aliasing. This setting controls the order of the filter. The higher
-        the value, the better the quality, in general. Setting this to 0 will disable low-pass filtering altogether. The maximum value is
-        `MA_MAX_FILTER_ORDER`. The default value is `min(4, MA_MAX_FILTER_ORDER)`.
-
-    playback.pDeviceID
-        A pointer to a `ma_device_id` structure containing the ID of the playback device to initialize. Setting this NULL (default) will use the system's
-        default playback device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
-
-    playback.format
-        The sample format to use for playback. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
-        initialization from the device object directly with `device.playback.format`.
-
-    playback.channels
-        The number of channels to use for playback. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
-        from the device object directly with `device.playback.channels`.
-
-    playback.channelMap
-        The channel map to use for playback. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
-        device object direct with `device.playback.channelMap`.
-
-    playback.shareMode
-        The preferred share mode to use for playback. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
-        exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
-        ma_share_mode_shared and reinitializing.
-
-    capture.pDeviceID
-        A pointer to a `ma_device_id` structure containing the ID of the capture device to initialize. Setting this NULL (default) will use the system's
-        default capture device. Retrieve the device ID from the `ma_device_info` structure, which can be retrieved using device enumeration.
-
-    capture.format
-        The sample format to use for capture. When set to `ma_format_unknown` the device's native format will be used. This can be retrieved after
-        initialization from the device object directly with `device.capture.format`.
-
-    capture.channels
-        The number of channels to use for capture. When set to 0 the device's native channel count will be used. This can be retrieved after initialization
-        from the device object directly with `device.capture.channels`.
-
-    capture.channelMap
-        The channel map to use for capture. When left empty, the device's native channel map will be used. This can be retrieved after initialization from the
-        device object direct with `device.capture.channelMap`.
-
-    capture.shareMode
-        The preferred share mode to use for capture. Can be either `ma_share_mode_shared` (default) or `ma_share_mode_exclusive`. Note that if you specify
-        exclusive mode, but it's not supported by the backend, initialization will fail. You can then fall back to shared mode if desired by changing this to
-        ma_share_mode_shared and reinitializing.
-
-    wasapi.noAutoConvertSRC
-        WASAPI only. When set to true, disables WASAPI's automatic resampling and forces the use of miniaudio's resampler. Defaults to false.
-
-    wasapi.noDefaultQualitySRC
-        WASAPI only. Only used when `wasapi.noAutoConvertSRC` is set to false. When set to true, disables the use of `AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY`.
-        You should usually leave this set to false, which is the default.
-
-    wasapi.noAutoStreamRouting
-        WASAPI only. When set to true, disables automatic stream routing on the WASAPI backend. Defaults to false.
-
-    wasapi.noHardwareOffloading
-        WASAPI only. When set to true, disables the use of WASAPI's hardware offloading feature. Defaults to false.
-
-    alsa.noMMap
-        ALSA only. When set to true, disables MMap mode. Defaults to false.
-
-    alsa.noAutoFormat
-        ALSA only. When set to true, disables ALSA's automatic format conversion by including the SND_PCM_NO_AUTO_FORMAT flag. Defaults to false.
-
-    alsa.noAutoChannels
-        ALSA only. When set to true, disables ALSA's automatic channel conversion by including the SND_PCM_NO_AUTO_CHANNELS flag. Defaults to false.
-
-    alsa.noAutoResample
-        ALSA only. When set to true, disables ALSA's automatic resampling by including the SND_PCM_NO_AUTO_RESAMPLE flag. Defaults to false.
-
-    pulse.pStreamNamePlayback
-        PulseAudio only. Sets the stream name for playback.
-
-    pulse.pStreamNameCapture
-        PulseAudio only. Sets the stream name for capture.
-
-    coreaudio.allowNominalSampleRateChange
-        Core Audio only. Desktop only. When enabled, allows the sample rate of the device to be changed at the operating system level. This
-        is disabled by default in order to prevent intrusive changes to the user's system. This is useful if you want to use a sample rate
-        that is known to be natively supported by the hardware thereby avoiding the cost of resampling. When set to true, miniaudio will
-        find the closest match between the sample rate requested in the device config and the sample rates natively supported by the
-        hardware. When set to false, the sample rate currently set by the operating system will always be used.
-
-
-Once initialized, the device's config is immutable. If you need to change the config you will need to initialize a new device.
-
-After initializing the device it will be in a stopped state. To start it, use `ma_device_start()`.
-
-If both `periodSizeInFrames` and `periodSizeInMilliseconds` are set to zero, it will default to `MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY` or
-`MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE`, depending on whether or not `performanceProfile` is set to `ma_performance_profile_low_latency` or
-`ma_performance_profile_conservative`.
-
-If you request exclusive mode and the backend does not support it an error will be returned. For robustness, you may want to first try initializing the device
-in exclusive mode, and then fall back to shared mode if required. Alternatively you can just request shared mode (the default if you leave it unset in the
-config) which is the most reliable option. Some backends do not have a practical way of choosing whether or not the device should be exclusive or not (ALSA,
-for example) in which case it just acts as a hint. Unless you have special requirements you should try avoiding exclusive mode as it's intrusive to the user.
-Starting with Windows 10, miniaudio will use low-latency shared mode where possible which may make exclusive mode unnecessary.
-
-When sending or receiving data to/from a device, miniaudio will internally perform a format conversion to convert between the format specified by the config
-and the format used internally by the backend. If you pass in 0 for the sample format, channel count, sample rate _and_ channel map, data transmission will run
-on an optimized pass-through fast path. You can retrieve the format, channel count and sample rate by inspecting the `playback/capture.format`,
-`playback/capture.channels` and `sampleRate` members of the device object.
-
-When compiling for UWP you must ensure you call this function on the main UI thread because the operating system may need to present the user with a message
-asking for permissions. Please refer to the official documentation for ActivateAudioInterfaceAsync() for more information.
-
-ALSA Specific: When initializing the default device, requesting shared mode will try using the "dmix" device for playback and the "dsnoop" device for capture.
-If these fail it will try falling back to the "hw" device.
-
-
-Example 1 - Simple Initialization
----------------------------------
-This example shows how to initialize a simple playback device using a standard configuration. If you are just needing to do simple playback from the default
-playback device this is usually all you need.
-
-```c
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.format   = ma_format_f32;
-config.playback.channels = 2;
-config.sampleRate        = 48000;
-config.dataCallback      = ma_data_callback;
-config.pMyUserData       = pMyUserData;
-
-ma_device device;
-ma_result result = ma_device_init(NULL, &config, &device);
-if (result != MA_SUCCESS) {
-    // Error
-}
-```
-
-
-Example 2 - Advanced Initialization
------------------------------------
-This example shows how you might do some more advanced initialization. In this hypothetical example we want to control the latency by setting the buffer size
-and period count. We also want to allow the user to be able to choose which device to output from which means we need a context so we can perform device
-enumeration.
-
-```c
-ma_context context;
-ma_result result = ma_context_init(NULL, 0, NULL, &context);
-if (result != MA_SUCCESS) {
-    // Error
-}
-
-ma_device_info* pPlaybackDeviceInfos;
-ma_uint32 playbackDeviceCount;
-result = ma_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, NULL, NULL);
-if (result != MA_SUCCESS) {
-    // Error
-}
-
-// ... choose a device from pPlaybackDeviceInfos ...
-
-ma_device_config config = ma_device_config_init(ma_device_type_playback);
-config.playback.pDeviceID       = pMyChosenDeviceID;    // <-- Get this from the `id` member of one of the `ma_device_info` objects returned by ma_context_get_devices().
-config.playback.format          = ma_format_f32;
-config.playback.channels        = 2;
-config.sampleRate               = 48000;
-config.dataCallback             = ma_data_callback;
-config.pUserData                = pMyUserData;
-config.periodSizeInMilliseconds = 10;
-config.periods                  = 3;
-
-ma_device device;
-result = ma_device_init(&context, &config, &device);
-if (result != MA_SUCCESS) {
-    // Error
-}
-```
-
-
-See Also
---------
-ma_device_config_init()
-ma_device_uninit()
-ma_device_start()
-ma_context_init()
-ma_context_get_devices()
-ma_context_enumerate_devices()
-*/
-MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice);
-
-/*
-Initializes a device without a context, with extra parameters for controlling the configuration of the internal self-managed context.
-
-This is the same as `ma_device_init()`, only instead of a context being passed in, the parameters from `ma_context_init()` are passed in instead. This function
-allows you to configure the internally created context.
-
-
-Parameters
-----------
-backends (in, optional)
-    A list of backends to try initializing, in priority order. Can be NULL, in which case it uses default priority order.
-
-backendCount (in, optional)
-    The number of items in `backend`. Ignored if `backend` is NULL.
-
-pContextConfig (in, optional)
-    The context configuration.
-
-pConfig (in)
-    A pointer to the device configuration. Cannot be null. See remarks for details.
-
-pDevice (out)
-    A pointer to the device object being initialized.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Unsafe. It is not safe to call this function simultaneously for different devices because some backends depend on and mutate global state. The same applies to
-calling this at the same time as `ma_device_uninit()`.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-You only need to use this function if you want to configure the context differently to it's defaults. You should never use this function if you want to manage
-your own context.
-
-See the documentation for `ma_context_init()` for information on the different context configuration options.
-
-
-See Also
---------
-ma_device_init()
-ma_device_uninit()
-ma_device_config_init()
-ma_context_init()
-*/
-MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice);
-
-/*
-Uninitializes a device.
-
-This will explicitly stop the device. You do not need to call `ma_device_stop()` beforehand, but it's harmless if you do.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to stop.
-
-
-Return Value
-------------
-Nothing
-
-
-Thread Safety
--------------
-Unsafe. As soon as this API is called the device should be considered undefined.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.
-
-
-See Also
---------
-ma_device_init()
-ma_device_stop()
-*/
-MA_API void ma_device_uninit(ma_device* pDevice);
-
-/*
-Starts the device. For playback devices this begins playback. For capture devices it begins recording.
-
-Use `ma_device_stop()` to stop the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to start.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. It's safe to call this from any thread with the exception of the callback thread.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback.
-
-
-Remarks
--------
-For a playback device, this will retrieve an initial chunk of audio data from the client before returning. The reason for this is to ensure there is valid
-audio data in the buffer, which needs to be done before the device begins playback.
-
-This API waits until the backend device has been started for real by the worker thread. It also waits on a mutex for thread-safety.
-
-Do not call this in any callback.
-
-
-See Also
---------
-ma_device_stop()
-*/
-MA_API ma_result ma_device_start(ma_device* pDevice);
-
-/*
-Stops the device. For playback devices this stops playback. For capture devices it stops recording.
-
-Use `ma_device_start()` to start the device again.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device to stop.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other error code otherwise.
-
-
-Thread Safety
--------------
-Safe. It's safe to call this from any thread with the exception of the callback thread.
-
-
-Callback Safety
----------------
-Unsafe. It is not safe to call this inside any callback. Doing this will result in a deadlock.
-
-
-Remarks
--------
-This API needs to wait on the worker thread to stop the backend device properly before returning. It also waits on a mutex for thread-safety. In addition, some
-backends need to wait for the device to finish playback/recording of the current fragment which can take some time (usually proportionate to the buffer size
-that was specified at initialization time).
-
-Backends are required to either pause the stream in-place or drain the buffer if pausing is not possible. The reason for this is that stopping the device and
-the resuming it with ma_device_start() (which you might do when your program loses focus) may result in a situation where those samples are never output to the
-speakers or received from the microphone which can in turn result in de-syncs.
-
-Do not call this in any callback.
-
-This will be called implicitly by `ma_device_uninit()`.
-
-
-See Also
---------
-ma_device_start()
-*/
-MA_API ma_result ma_device_stop(ma_device* pDevice);
-
-/*
-Determines whether or not the device is started.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose start state is being retrieved.
-
-
-Return Value
-------------
-True if the device is started, false otherwise.
-
-
-Thread Safety
--------------
-Safe. If another thread calls `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, there's a very small chance the return
-value will be out of sync.
-
-
-Callback Safety
----------------
-Safe. This is implemented as a simple accessor.
-
-
-See Also
---------
-ma_device_start()
-ma_device_stop()
-*/
-MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice);
-
-
-/*
-Retrieves the state of the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose state is being retrieved.
-
-
-Return Value
-------------
-The current state of the device. The return value will be one of the following:
-
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_UNINITIALIZED | Will only be returned if the device is in the middle of initialization.      |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STOPPED       | The device is stopped. The initial state of the device after initialization. |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STARTED       | The device started and requesting and/or delivering audio data.              |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STARTING      | The device is in the process of starting.                                    |
-    +------------------------+------------------------------------------------------------------------------+
-    | MA_STATE_STOPPING      | The device is in the process of stopping.                                    |
-    +------------------------+------------------------------------------------------------------------------+
-
-
-Thread Safety
--------------
-Safe. This is implemented as a simple accessor. Note that if the device is started or stopped at the same time as this function is called,
-there's a possibility the return value could be out of sync. See remarks.
-
-
-Callback Safety
----------------
-Safe. This is implemented as a simple accessor.
-
-
-Remarks
--------
-The general flow of a devices state goes like this:
-
-    ```
-    ma_device_init()  -> MA_STATE_UNINITIALIZED -> MA_STATE_STOPPED
-    ma_device_start() -> MA_STATE_STARTING      -> MA_STATE_STARTED
-    ma_device_stop()  -> MA_STATE_STOPPING      -> MA_STATE_STOPPED
-    ```
-
-When the state of the device is changed with `ma_device_start()` or `ma_device_stop()` at this same time as this function is called, the
-value returned by this function could potentially be out of sync. If this is significant to your program you need to implement your own
-synchronization.
-*/
-MA_API ma_uint32 ma_device_get_state(const ma_device* pDevice);
-
-
-/*
-Sets the master volume factor for the device.
-
-The volume factor must be between 0 (silence) and 1 (full volume). Use `ma_device_set_master_gain_db()` to use decibel notation, where 0 is full volume and
-values less than 0 decreases the volume.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose volume is being set.
-
-volume (in)
-    The new volume factor. Must be within the range of [0, 1].
-
-
-Return Value
-------------
-MA_SUCCESS if the volume was set successfully.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if the volume factor is not within the range of [0, 1].
-
-
-Thread Safety
--------------
-Safe. This just sets a local member of the device object.
-
-
-Callback Safety
----------------
-Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
-
-
-Remarks
--------
-This applies the volume factor across all channels.
-
-This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream.
-
-
-See Also
---------
-ma_device_get_master_volume()
-ma_device_set_master_volume_gain_db()
-ma_device_get_master_volume_gain_db()
-*/
-MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume);
-
-/*
-Retrieves the master volume factor for the device.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose volume factor is being retrieved.
-
-pVolume (in)
-    A pointer to the variable that will receive the volume factor. The returned value will be in the range of [0, 1].
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if pVolume is NULL.
-
-
-Thread Safety
--------------
-Safe. This just a simple member retrieval.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If an error occurs, `*pVolume` will be set to 0.
-
-
-See Also
---------
-ma_device_set_master_volume()
-ma_device_set_master_volume_gain_db()
-ma_device_get_master_volume_gain_db()
-*/
-MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume);
-
-/*
-Sets the master volume for the device as gain in decibels.
-
-A gain of 0 is full volume, whereas a gain of < 0 will decrease the volume.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose gain is being set.
-
-gainDB (in)
-    The new volume as gain in decibels. Must be less than or equal to 0, where 0 is full volume and anything less than 0 decreases the volume.
-
-
-Return Value
-------------
-MA_SUCCESS if the volume was set successfully.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if the gain is > 0.
-
-
-Thread Safety
--------------
-Safe. This just sets a local member of the device object.
-
-
-Callback Safety
----------------
-Safe. If you set the volume in the data callback, that data written to the output buffer will have the new volume applied.
-
-
-Remarks
--------
-This applies the gain across all channels.
-
-This does not change the operating system's volume. It only affects the volume for the given `ma_device` object's audio stream.
-
-
-See Also
---------
-ma_device_get_master_volume_gain_db()
-ma_device_set_master_volume()
-ma_device_get_master_volume()
-*/
-MA_API ma_result ma_device_set_master_gain_db(ma_device* pDevice, float gainDB);
-
-/*
-Retrieves the master gain in decibels.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to the device whose gain is being retrieved.
-
-pGainDB (in)
-    A pointer to the variable that will receive the gain in decibels. The returned value will be <= 0.
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if pDevice is NULL.
-MA_INVALID_ARGS if pGainDB is NULL.
-
-
-Thread Safety
--------------
-Safe. This just a simple member retrieval.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If an error occurs, `*pGainDB` will be set to 0.
-
-
-See Also
---------
-ma_device_set_master_volume_gain_db()
-ma_device_set_master_volume()
-ma_device_get_master_volume()
-*/
-MA_API ma_result ma_device_get_master_gain_db(ma_device* pDevice, float* pGainDB);
-
-
-/*
-Called from the data callback of asynchronous backends to allow miniaudio to process the data and fire the miniaudio data callback.
-
-
-Parameters
-----------
-pDevice (in)
-    A pointer to device whose processing the data callback.
-
-pOutput (out)
-    A pointer to the buffer that will receive the output PCM frame data. On a playback device this must not be NULL. On a duplex device
-    this can be NULL, in which case pInput must not be NULL.
-
-pInput (in)
-    A pointer to the buffer containing input PCM frame data. On a capture device this must not be NULL. On a duplex device this can be
-    NULL, in which case `pOutput` must not be NULL.
-
-frameCount (in)
-    The number of frames being processed.
-
-
-Return Value
-------------
-MA_SUCCESS if successful; any other result code otherwise.
-
-
-Thread Safety
--------------
-This function should only ever be called from the internal data callback of the backend. It is safe to call this simultaneously between a
-playback and capture device in duplex setups.
-
-
-Callback Safety
----------------
-Do not call this from the miniaudio data callback. It should only ever be called from the internal data callback of the backend.
-
-
-Remarks
--------
-If both `pOutput` and `pInput` are NULL, and error will be returned. In duplex scenarios, both `pOutput` and `pInput` can be non-NULL, in
-which case `pInput` will be processed first, followed by `pOutput`.
-
-If you are implementing a custom backend, and that backend uses a callback for data delivery, you'll need to call this from inside that
-callback.
-*/
-MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-
-/*
-Calculates an appropriate buffer size from a descriptor, native sample rate and performance profile.
-
-This function is used by backends for helping determine an appropriately sized buffer to use with
-the device depending on the values of `periodSizeInFrames` and `periodSizeInMilliseconds` in the
-`pDescriptor` object. Since buffer size calculations based on time depends on the sample rate, a
-best guess at the device's native sample rate is also required which is where `nativeSampleRate`
-comes in. In addition, the performance profile is also needed for cases where both the period size
-in frames and milliseconds are both zero.
-
-
-Parameters
-----------
-pDescriptor (in)
-    A pointer to device descriptor whose `periodSizeInFrames` and `periodSizeInMilliseconds` members
-    will be used for the calculation of the buffer size.
-
-nativeSampleRate (in)
-    The device's native sample rate. This is only ever used when the `periodSizeInFrames` member of
-    `pDescriptor` is zero. In this case, `periodSizeInMilliseconds` will be used instead, in which
-    case a sample rate is required to convert to a size in frames.
-
-performanceProfile (in)
-    When both the `periodSizeInFrames` and `periodSizeInMilliseconds` members of `pDescriptor` are
-    zero, miniaudio will fall back to a buffer size based on the performance profile. The profile
-    to use for this calculation is determine by this parameter.
-
-
-Return Value
-------------
-The calculated buffer size in frames.
-
-
-Thread Safety
--------------
-This is safe so long as nothing modifies `pDescriptor` at the same time. However, this function
-should only ever be called from within the backend's device initialization routine and therefore
-shouldn't have any multithreading concerns.
-
-
-Callback Safety
----------------
-This is safe to call within the data callback, but there is no reason to ever do this.
-
-
-Remarks
--------
-If `nativeSampleRate` is zero, this function will fall back to `pDescriptor->sampleRate`. If that
-is also zero, `MA_DEFAULT_SAMPLE_RATE` will be used instead.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile);
-
-
-
-/*
-Retrieves a friendly name for a backend.
-*/
-MA_API const char* ma_get_backend_name(ma_backend backend);
-
-/*
-Determines whether or not the given backend is available by the compilation environment.
-*/
-MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend);
-
-/*
-Retrieves compile-time enabled backends.
-
-
-Parameters
-----------
-pBackends (out, optional)
-    A pointer to the buffer that will receive the enabled backends. Set to NULL to retrieve the backend count. Setting
-    the capacity of the buffer to `MA_BUFFER_COUNT` will guarantee it's large enough for all backends.
-
-backendCap (in)
-    The capacity of the `pBackends` buffer.
-
-pBackendCount (out)
-    A pointer to the variable that will receive the enabled backend count.
-
-
-Return Value
-------------
-MA_SUCCESS if successful.
-MA_INVALID_ARGS if `pBackendCount` is NULL.
-MA_NO_SPACE if the capacity of `pBackends` is not large enough.
-
-If `MA_NO_SPACE` is returned, the `pBackends` buffer will be filled with `*pBackendCount` values.
-
-
-Thread Safety
--------------
-Safe.
-
-
-Callback Safety
----------------
-Safe.
-
-
-Remarks
--------
-If you want to retrieve the number of backends so you can determine the capacity of `pBackends` buffer, you can call
-this function with `pBackends` set to NULL.
-
-This will also enumerate the null backend. If you don't want to include this you need to check for `ma_backend_null`
-when you enumerate over the returned backends and handle it appropriately. Alternatively, you can disable it at
-compile time with `MA_NO_NULL`.
-
-The returned backends are determined based on compile time settings, not the platform it's currently running on. For
-example, PulseAudio will be returned if it was enabled at compile time, even when the user doesn't actually have
-PulseAudio installed.
-
-
-Example 1
----------
-The example below retrieves the enabled backend count using a fixed sized buffer allocated on the stack. The buffer is
-given a capacity of `MA_BACKEND_COUNT` which will guarantee it'll be large enough to store all available backends.
-Since `MA_BACKEND_COUNT` is always a relatively small value, this should be suitable for most scenarios.
-
-```
-ma_backend enabledBackends[MA_BACKEND_COUNT];
-size_t enabledBackendCount;
-
-result = ma_get_enabled_backends(enabledBackends, MA_BACKEND_COUNT, &enabledBackendCount);
-if (result != MA_SUCCESS) {
-    // Failed to retrieve enabled backends. Should never happen in this example since all inputs are valid.
-}
-```
-
-
-See Also
---------
-ma_is_backend_enabled()
-*/
-MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount);
-
-/*
-Determines whether or not loopback mode is support by a backend.
-*/
-MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend);
-
-#endif  /* MA_NO_DEVICE_IO */
-
-
-#ifndef MA_NO_THREADING
-
-/*
-Locks a spinlock.
-*/
-MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock);
-
-/*
-Locks a spinlock, but does not yield() when looping.
-*/
-MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock);
-
-/*
-Unlocks a spinlock.
-*/
-MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock);
-
-
-/*
-Creates a mutex.
-
-A mutex must be created from a valid context. A mutex is initially unlocked.
-*/
-MA_API ma_result ma_mutex_init(ma_mutex* pMutex);
-
-/*
-Deletes a mutex.
-*/
-MA_API void ma_mutex_uninit(ma_mutex* pMutex);
-
-/*
-Locks a mutex with an infinite timeout.
-*/
-MA_API void ma_mutex_lock(ma_mutex* pMutex);
-
-/*
-Unlocks a mutex.
-*/
-MA_API void ma_mutex_unlock(ma_mutex* pMutex);
-
-
-/*
-Initializes an auto-reset event.
-*/
-MA_API ma_result ma_event_init(ma_event* pEvent);
-
-/*
-Uninitializes an auto-reset event.
-*/
-MA_API void ma_event_uninit(ma_event* pEvent);
-
-/*
-Waits for the specified auto-reset event to become signalled.
-*/
-MA_API ma_result ma_event_wait(ma_event* pEvent);
-
-/*
-Signals the specified auto-reset event.
-*/
-MA_API ma_result ma_event_signal(ma_event* pEvent);
-#endif  /* MA_NO_THREADING */
-
-
-/************************************************************************************************************************************************************
-
-Utiltities
-
-************************************************************************************************************************************************************/
-
-/*
-Adjust buffer size based on a scaling factor.
-
-This just multiplies the base size by the scaling factor, making sure it's a size of at least 1.
-*/
-MA_API ma_uint32 ma_scale_buffer_size(ma_uint32 baseBufferSize, float scale);
-
-/*
-Calculates a buffer size in milliseconds from the specified number of frames and sample rate.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate);
-
-/*
-Calculates a buffer size in frames from the specified number of milliseconds and sample rate.
-*/
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate);
-
-/*
-Copies PCM frames from one buffer to another.
-*/
-MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels);
-
-/*
-Copies silent frames into the given buffer.
-
-Remarks
--------
-For all formats except `ma_format_u8`, the output buffer will be filled with 0. For `ma_format_u8` it will be filled with 128. The reason for this is that it
-makes more sense for the purpose of mixing to initialize it to the center point.
-*/
-MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels);
-static MA_INLINE void ma_zero_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { ma_silence_pcm_frames(p, frameCount, format, channels); }
-
-
-/*
-Offsets a pointer by the specified number of PCM frames.
-*/
-MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels);
-MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels);
-static MA_INLINE float* ma_offset_pcm_frames_ptr_f32(float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (float*)ma_offset_pcm_frames_ptr((void*)p, offsetInFrames, ma_format_f32, channels); }
-static MA_INLINE const float* ma_offset_pcm_frames_const_ptr_f32(const float* p, ma_uint64 offsetInFrames, ma_uint32 channels) { return (const float*)ma_offset_pcm_frames_const_ptr((const void*)p, offsetInFrames, ma_format_f32, channels); }
-
-
-/*
-Clips f32 samples.
-*/
-MA_API void ma_clip_samples_f32(float* p, ma_uint64 sampleCount);
-static MA_INLINE void ma_clip_pcm_frames_f32(float* p, ma_uint64 frameCount, ma_uint32 channels) { ma_clip_samples_f32(p, frameCount*channels); }
-
-/*
-Helper for applying a volume factor to samples.
-
-Note that the source and destination buffers can be the same, in which case it'll perform the operation in-place.
-*/
-MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor);
-MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor);
-
-MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor);
-MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor);
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFramesOut, const ma_uint8* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFramesOut, const ma_int16* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFramesOut, const ma_int32* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pPCMFramesOut, const float* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor);
-
-MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pFrames, ma_uint64 frameCount, ma_uint32 channels, float factor);
-MA_API void ma_apply_volume_factor_pcm_frames(void* pFrames, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor);
-
-
-/*
-Helper for converting a linear factor to gain in decibels.
-*/
-MA_API float ma_factor_to_gain_db(float factor);
-
-/*
-Helper for converting gain in decibels to a linear factor.
-*/
-MA_API float ma_gain_db_to_factor(float gain);
-
-
-typedef void ma_data_source;
-
-typedef struct
-{
-    ma_result (* onRead)(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead);
-    ma_result (* onSeek)(ma_data_source* pDataSource, ma_uint64 frameIndex);
-    ma_result (* onMap)(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount);   /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-    ma_result (* onUnmap)(ma_data_source* pDataSource, ma_uint64 frameCount);
-    ma_result (* onGetDataFormat)(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
-    ma_result (* onGetCursor)(ma_data_source* pDataSource, ma_uint64* pCursor);
-    ma_result (* onGetLength)(ma_data_source* pDataSource, ma_uint64* pLength);
-} ma_data_source_callbacks;
-
-MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop);   /* Must support pFramesOut = NULL in which case a forward seek should be performed. */
-MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked, ma_bool32 loop); /* Can only seek forward. Equivalent to ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount); */
-MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex);
-MA_API ma_result ma_data_source_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_data_source_unmap(ma_data_source* pDataSource, ma_uint64 frameCount);       /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate);
-MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor);
-MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength);    /* Returns MA_NOT_IMPLEMENTED if the length is unknown or cannot be determined. Decoders can return this. */
-
-
-
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint64 cursor;
-    ma_uint64 sizeInFrames;
-    const void* pData;
-} ma_audio_buffer_ref;
-
-MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames);
-MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount);    /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_audio_buffer_ref_at_end(ma_audio_buffer_ref* pAudioBufferRef);
-MA_API ma_result ma_audio_buffer_ref_get_available_frames(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames);
-
-
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint64 sizeInFrames;
-    const void* pData;  /* If set to NULL, will allocate a block of memory for you. */
-    ma_allocation_callbacks allocationCallbacks;
-} ma_audio_buffer_config;
-
-MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks);
-
-typedef struct
-{
-    ma_audio_buffer_ref ref;
-    ma_allocation_callbacks allocationCallbacks;
-    ma_bool32 ownsData;             /* Used to control whether or not miniaudio owns the data buffer. If set to true, pData will be freed in ma_audio_buffer_uninit(). */
-    ma_uint8 _pExtraData[1];        /* For allocating a buffer with the memory located directly after the other memory of the structure. */
-} ma_audio_buffer;
-
-MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer);  /* Always copies the data. Doesn't make sense to use this otherwise. Use ma_audio_buffer_uninit_and_free() to uninit. */
-MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer);
-MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer);
-MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop);
-MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex);
-MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount);
-MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount);    /* Returns MA_AT_END if the end has been reached. This should be considered successful. */
-MA_API ma_result ma_audio_buffer_at_end(ma_audio_buffer* pAudioBuffer);
-MA_API ma_result ma_audio_buffer_get_available_frames(ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames);
-
-
-
-/************************************************************************************************************************************************************
-
-VFS
-===
-
-The VFS object (virtual file system) is what's used to customize file access. This is useful in cases where stdio FILE* based APIs may not be entirely
-appropriate for a given situation.
-
-************************************************************************************************************************************************************/
-typedef void      ma_vfs;
-typedef ma_handle ma_vfs_file;
-
-#define MA_OPEN_MODE_READ   0x00000001
-#define MA_OPEN_MODE_WRITE  0x00000002
-
-typedef enum
-{
-    ma_seek_origin_start,
-    ma_seek_origin_current,
-    ma_seek_origin_end  /* Not used by decoders. */
-} ma_seek_origin;
-
-typedef struct
-{
-    ma_uint64 sizeInBytes;
-} ma_file_info;
-
-typedef struct
-{
-    ma_result (* onOpen) (ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-    ma_result (* onOpenW)(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-    ma_result (* onClose)(ma_vfs* pVFS, ma_vfs_file file);
-    ma_result (* onRead) (ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead);
-    ma_result (* onWrite)(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten);
-    ma_result (* onSeek) (ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin);
-    ma_result (* onTell) (ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor);
-    ma_result (* onInfo) (ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo);
-} ma_vfs_callbacks;
-
-MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile);
-MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file);
-MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead);
-MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten);
-MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin);
-MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor);
-MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo);
-MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks);
-
-typedef struct
-{
-    ma_vfs_callbacks cb;
-    ma_allocation_callbacks allocationCallbacks;    /* Only used for the wchar_t version of open() on non-Windows platforms. */
-} ma_default_vfs;
-
-MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks);
-
-
-
-
-#if !defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING)
-typedef enum
-{
-    ma_resource_format_wav
-} ma_resource_format;
-#endif
-
-/************************************************************************************************************************************************************
-
-Decoding
-========
-
-Decoders are independent of the main device API. Decoding APIs can be called freely inside the device's data callback, but they are not thread safe unless
-you do your own synchronization.
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DECODING
-typedef struct ma_decoder ma_decoder;
-
-typedef size_t    (* ma_decoder_read_proc)                    (ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead);     /* Returns the number of bytes read. */
-typedef ma_bool32 (* ma_decoder_seek_proc)                    (ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin);    /* Origin will never be ma_seek_origin_end. */
-typedef ma_uint64 (* ma_decoder_read_pcm_frames_proc)         (ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount);   /* Returns the number of frames read. Output data is in internal format. */
-typedef ma_result (* ma_decoder_seek_to_pcm_frame_proc)       (ma_decoder* pDecoder, ma_uint64 frameIndex);
-typedef ma_result (* ma_decoder_uninit_proc)                  (ma_decoder* pDecoder);
-typedef ma_uint64 (* ma_decoder_get_length_in_pcm_frames_proc)(ma_decoder* pDecoder);
-
-typedef struct
-{
-    ma_format format;      /* Set to 0 or ma_format_unknown to use the stream's internal format. */
-    ma_uint32 channels;    /* Set to 0 to use the stream's internal channels. */
-    ma_uint32 sampleRate;  /* Set to 0 to use the stream's internal sample rate. */
-    ma_channel channelMap[MA_MAX_CHANNELS];
-    ma_channel_mix_mode channelMixMode;
-    ma_dither_mode ditherMode;
-    struct
-    {
-        ma_resample_algorithm algorithm;
-        struct
-        {
-            ma_uint32 lpfOrder;
-        } linear;
-        struct
-        {
-            int quality;
-        } speex;
-    } resampling;
-    ma_allocation_callbacks allocationCallbacks;
-} ma_decoder_config;
-
-struct ma_decoder
-{
-    ma_data_source_callbacks ds;
-    ma_decoder_read_proc onRead;
-    ma_decoder_seek_proc onSeek;
-    void* pUserData;
-    ma_uint64  readPointerInBytes;          /* In internal encoded data. */
-    ma_uint64  readPointerInPCMFrames;      /* In output sample rate. Used for keeping track of how many frames are available for decoding. */
-    ma_format  internalFormat;
-    ma_uint32  internalChannels;
-    ma_uint32  internalSampleRate;
-    ma_channel internalChannelMap[MA_MAX_CHANNELS];
-    ma_format  outputFormat;
-    ma_uint32  outputChannels;
-    ma_uint32  outputSampleRate;
-    ma_channel outputChannelMap[MA_MAX_CHANNELS];
-    ma_data_converter converter;   /* <-- Data conversion is achieved by running frames through this. */
-    ma_allocation_callbacks allocationCallbacks;
-    ma_decoder_read_pcm_frames_proc onReadPCMFrames;
-    ma_decoder_seek_to_pcm_frame_proc onSeekToPCMFrame;
-    ma_decoder_uninit_proc onUninit;
-    ma_decoder_get_length_in_pcm_frames_proc onGetLengthInPCMFrames;
-    void* pInternalDecoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
-    union
-    {
-        struct
-        {
-            ma_vfs* pVFS;
-            ma_vfs_file file;
-        } vfs;
-        struct
-        {
-            const ma_uint8* pData;
-            size_t dataSize;
-            size_t currentReadPos;
-        } memory;               /* Only used for decoders that were opened against a block of memory. */
-    } backend;
-};
-
-MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate);
-
-MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_wav(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_flac(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_mp3(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vorbis(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_raw(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_wav(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_flac(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_mp3(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_vorbis(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_memory_raw(const void* pData, size_t dataSize, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_wav(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_flac(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_mp3(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_vorbis(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_wav_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_flac_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_mp3_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_vfs_vorbis_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_wav(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_flac(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_mp3(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_vorbis(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_wav_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_flac_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_mp3_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-MA_API ma_result ma_decoder_init_file_vorbis_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder);
-
-MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder);
-
-/*
-Retrieves the current position of the read cursor in PCM frames.
-*/
-MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor);
-
-/*
-Retrieves the length of the decoder in PCM frames.
-
-Do not call this on streams of an undefined length, such as internet radio.
-
-If the length is unknown or an error occurs, 0 will be returned.
-
-This will always return 0 for Vorbis decoders. This is due to a limitation with stb_vorbis in push mode which is what miniaudio
-uses internally.
-
-For MP3's, this will decode the entire file. Do not call this in time critical scenarios.
-
-This function is not thread safe without your own synchronization.
-*/
-MA_API ma_uint64 ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder);
-
-/*
-Reads PCM frames from the given decoder.
-
-This is not thread safe without your own synchronization.
-*/
-MA_API ma_uint64 ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount);
-
-/*
-Seeks to a PCM frame based on it's absolute index.
-
-This is not thread safe without your own synchronization.
-*/
-MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex);
-
-/*
-Retrieves the number of frames that can be read before reaching the end.
-
-This calls `ma_decoder_get_length_in_pcm_frames()` so you need to be aware of the rules for that function, in
-particular ensuring you do not call it on streams of an undefined length, such as internet radio.
-
-If the total length of the decoder cannot be retrieved, such as with Vorbis decoders, `MA_NOT_IMPLEMENTED` will be
-returned.
-*/
-MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames);
-
-/*
-Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with ma_free(). On input,
-pConfig should be set to what you want. On output it will be set to what you got.
-*/
-MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut);
-
-#endif  /* MA_NO_DECODING */
-
-
-/************************************************************************************************************************************************************
-
-Encoding
-========
-
-Encoders do not perform any format conversion for you. If your target format does not support the format, and error will be returned.
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_ENCODING
-typedef struct ma_encoder ma_encoder;
-
-typedef size_t    (* ma_encoder_write_proc)           (ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite);     /* Returns the number of bytes written. */
-typedef ma_bool32 (* ma_encoder_seek_proc)            (ma_encoder* pEncoder, int byteOffset, ma_seek_origin origin);
-typedef ma_result (* ma_encoder_init_proc)            (ma_encoder* pEncoder);
-typedef void      (* ma_encoder_uninit_proc)          (ma_encoder* pEncoder);
-typedef ma_uint64 (* ma_encoder_write_pcm_frames_proc)(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount);
-
-typedef struct
-{
-    ma_resource_format resourceFormat;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_allocation_callbacks allocationCallbacks;
-} ma_encoder_config;
-
-MA_API ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate);
-
-struct ma_encoder
-{
-    ma_encoder_config config;
-    ma_encoder_write_proc onWrite;
-    ma_encoder_seek_proc onSeek;
-    ma_encoder_init_proc onInit;
-    ma_encoder_uninit_proc onUninit;
-    ma_encoder_write_pcm_frames_proc onWritePCMFrames;
-    void* pUserData;
-    void* pInternalEncoder; /* <-- The drwav/drflac/stb_vorbis/etc. objects. */
-    void* pFile;    /* FILE*. Only used when initialized with ma_encoder_init_file(). */
-};
-
-MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder);
-MA_API void ma_encoder_uninit(ma_encoder* pEncoder);
-MA_API ma_uint64 ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount);
-
-#endif /* MA_NO_ENCODING */
-
-
-/************************************************************************************************************************************************************
-
-Generation
-
-************************************************************************************************************************************************************/
-#ifndef MA_NO_GENERATION
-typedef enum
-{
-    ma_waveform_type_sine,
-    ma_waveform_type_square,
-    ma_waveform_type_triangle,
-    ma_waveform_type_sawtooth
-} ma_waveform_type;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_waveform_type type;
-    double amplitude;
-    double frequency;
-} ma_waveform_config;
-
-MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency);
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_waveform_config config;
-    double advance;
-    double time;
-} ma_waveform;
-
-MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform);
-MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount);
-MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex);
-MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude);
-MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency);
-MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type);
-MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate);
-
-typedef enum
-{
-    ma_noise_type_white,
-    ma_noise_type_pink,
-    ma_noise_type_brownian
-} ma_noise_type;
-
-typedef struct
-{
-    ma_format format;
-    ma_uint32 channels;
-    ma_noise_type type;
-    ma_int32 seed;
-    double amplitude;
-    ma_bool32 duplicateChannels;
-} ma_noise_config;
-
-MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude);
-
-typedef struct
-{
-    ma_data_source_callbacks ds;
-    ma_noise_config config;
-    ma_lcg lcg;
-    union
-    {
-        struct
-        {
-            double bin[MA_MAX_CHANNELS][16];
-            double accumulation[MA_MAX_CHANNELS];
-            ma_uint32 counter[MA_MAX_CHANNELS];
-        } pink;
-        struct
-        {
-            double accumulation[MA_MAX_CHANNELS];
-        } brownian;
-    } state;
-} ma_noise;
-
-MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, ma_noise* pNoise);
-MA_API ma_uint64 ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount);
-MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude);
-MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed);
-MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type);
-
-#endif  /* MA_NO_GENERATION */
-
-#ifdef __cplusplus
-}
-#endif
-#endif  /* miniaudio_h */
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-IMPLEMENTATION
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#if defined(MINIAUDIO_IMPLEMENTATION) || defined(MA_IMPLEMENTATION)
-#ifndef miniaudio_c
-#define miniaudio_c
-
-#include <assert.h>
-#include <limits.h> /* For INT_MAX */
-#include <math.h>   /* sin(), etc. */
-
-#include <stdarg.h>
-#include <stdio.h>
-#if !defined(_MSC_VER) && !defined(__DMC__)
-    #include <strings.h>    /* For strcasecmp(). */
-    #include <wchar.h>      /* For wcslen(), wcsrtombs() */
-#endif
-
-#ifdef MA_WIN32
-#include <windows.h>
-#else
-#include <stdlib.h>     /* For malloc(), free(), wcstombs(). */
-#include <string.h>     /* For memset() */
-#include <sched.h>
-#include <sys/time.h>   /* select() (used for ma_sleep()). */
-#endif
-
-#include <sys/stat.h>   /* For fstat(), etc. */
-
-#ifdef MA_EMSCRIPTEN
-#include <emscripten/emscripten.h>
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#ifdef _WIN32
-#ifdef _WIN64
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#ifdef __GNUC__
-#ifdef __LP64__
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-#endif
-
-#if !defined(MA_64BIT) && !defined(MA_32BIT)
-#include <stdint.h>
-#if INTPTR_MAX == INT64_MAX
-#define MA_64BIT
-#else
-#define MA_32BIT
-#endif
-#endif
-
-/* Architecture Detection */
-#if defined(__x86_64__) || defined(_M_X64)
-#define MA_X64
-#elif defined(__i386) || defined(_M_IX86)
-#define MA_X86
-#elif defined(__arm__) || defined(_M_ARM)
-#define MA_ARM
-#endif
-
-/* Cannot currently support AVX-512 if AVX is disabled. */
-#if !defined(MA_NO_AVX512) && defined(MA_NO_AVX2)
-#define MA_NO_AVX512
-#endif
-
-/* Intrinsics Support */
-#if defined(MA_X64) || defined(MA_X86)
-    #if defined(_MSC_VER) && !defined(__clang__)
-        /* MSVC. */
-        #if _MSC_VER >= 1400 && !defined(MA_NO_SSE2)   /* 2005 */
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if _MSC_VER >= 1600 && !defined(MA_NO_AVX)*/    /* 2010 */
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if _MSC_VER >= 1700 && !defined(MA_NO_AVX2)   /* 2012 */
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if _MSC_VER >= 1910 && !defined(MA_NO_AVX512) /* 2017 */
-            #define MA_SUPPORT_AVX512
-        #endif
-    #else
-        /* Assume GNUC-style. */
-        #if defined(__SSE2__) && !defined(MA_NO_SSE2)
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if defined(__AVX__) && !defined(MA_NO_AVX)*/
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if defined(__AVX2__) && !defined(MA_NO_AVX2)
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if defined(__AVX512F__) && !defined(MA_NO_AVX512)
-            #define MA_SUPPORT_AVX512
-        #endif
-    #endif
-
-    /* If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. */
-    #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-        #if !defined(MA_SUPPORT_SSE2)   && !defined(MA_NO_SSE2)   && __has_include(<emmintrin.h>)
-            #define MA_SUPPORT_SSE2
-        #endif
-        /*#if !defined(MA_SUPPORT_AVX)    && !defined(MA_NO_AVX)    && __has_include(<immintrin.h>)*/
-        /*    #define MA_SUPPORT_AVX*/
-        /*#endif*/
-        #if !defined(MA_SUPPORT_AVX2)   && !defined(MA_NO_AVX2)   && __has_include(<immintrin.h>)
-            #define MA_SUPPORT_AVX2
-        #endif
-        #if !defined(MA_SUPPORT_AVX512) && !defined(MA_NO_AVX512) && __has_include(<zmmintrin.h>)
-            #define MA_SUPPORT_AVX512
-        #endif
-    #endif
-
-    #if defined(MA_SUPPORT_AVX512)
-        #include <immintrin.h>  /* Not a mistake. Intentionally including <immintrin.h> instead of <zmmintrin.h> because otherwise the compiler will complain. */
-    #elif defined(MA_SUPPORT_AVX2) || defined(MA_SUPPORT_AVX)
-        #include <immintrin.h>
-    #elif defined(MA_SUPPORT_SSE2)
-        #include <emmintrin.h>
-    #endif
-#endif
-
-#if defined(MA_ARM)
-    #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-        #define MA_SUPPORT_NEON
-    #endif
-
-    /* Fall back to looking for the #include file. */
-    #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-        #if !defined(MA_SUPPORT_NEON) && !defined(MA_NO_NEON) && __has_include(<arm_neon.h>)
-            #define MA_SUPPORT_NEON
-        #endif
-    #endif
-
-    #if defined(MA_SUPPORT_NEON)
-        #include <arm_neon.h>
-    #endif
-#endif
-
-/* Begin globally disabled warnings. */
-#if defined(_MSC_VER)
-    #pragma warning(push)
-    #pragma warning(disable:4752)   /* found Intel(R) Advanced Vector Extensions; consider using /arch:AVX */
-#endif
-
-#if defined(MA_X64) || defined(MA_X86)
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static MA_INLINE void ma_cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define MA_NO_CPUID
-        #endif
-
-        #if _MSC_VER >= 1600 && (defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 160040219)
-            static MA_INLINE unsigned __int64 ma_xgetbv(int reg)
-            {
-                return _xgetbv(reg);
-            }
-        #else
-            #define MA_NO_XGETBV
-        #endif
-    #elif (defined(__GNUC__) || defined(__clang__)) && !defined(MA_ANDROID)
-        static MA_INLINE void ma_cpuid(int info[4], int fid)
-        {
-            /*
-            It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the
-            specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for
-            supporting different assembly dialects.
-
-            What's basically happening is that we're saving and restoring the ebx register manually.
-            */
-            #if defined(DRFLAC_X86) && defined(__PIC__)
-                __asm__ __volatile__ (
-                    "xchg{l} {%%}ebx, %k1;"
-                    "cpuid;"
-                    "xchg{l} {%%}ebx, %k1;"
-                    : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                );
-            #else
-                __asm__ __volatile__ (
-                    "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                );
-            #endif
-        }
-
-        static MA_INLINE ma_uint64 ma_xgetbv(int reg)
-        {
-            unsigned int hi;
-            unsigned int lo;
-
-            __asm__ __volatile__ (
-                "xgetbv" : "=a"(lo), "=d"(hi) : "c"(reg)
-            );
-
-            return ((ma_uint64)hi << 32) | (ma_uint64)lo;
-        }
-    #else
-        #define MA_NO_CPUID
-        #define MA_NO_XGETBV
-    #endif
-#else
-    #define MA_NO_CPUID
-    #define MA_NO_XGETBV
-#endif
-
-static MA_INLINE ma_bool32 ma_has_sse2(void)
-{
-#if defined(MA_SUPPORT_SSE2)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_SSE2)
-        #if defined(MA_X64)
-            return MA_TRUE;    /* 64-bit targets always support SSE2. */
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate SSE2 code we can assume support. */
-        #else
-            #if defined(MA_NO_CPUID)
-                return MA_FALSE;
-            #else
-                int info[4];
-                ma_cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* SSE2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-#if 0
-static MA_INLINE ma_bool32 ma_has_avx()
-{
-#if defined(MA_SUPPORT_AVX)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX)
-        #if defined(_AVX_) || defined(__AVX__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX code we can assume support. */
-        #else
-            /* AVX requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info[4];
-                ma_cpuid(info, 1);
-                if (((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0x06) == 0x06) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-#endif
-
-static MA_INLINE ma_bool32 ma_has_avx2(void)
-{
-#if defined(MA_SUPPORT_AVX2)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX2)
-        #if defined(_AVX2_) || defined(__AVX2__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX2 code we can assume support. */
-        #else
-            /* AVX2 requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info1[4];
-                int info7[4];
-                ma_cpuid(info1, 1);
-                ma_cpuid(info7, 7);
-                if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 5)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0x06) == 0x06) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX2 is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_has_avx512f(void)
-{
-#if defined(MA_SUPPORT_AVX512)
-    #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX512)
-        #if defined(__AVX512F__)
-            return MA_TRUE;    /* If the compiler is allowed to freely generate AVX-512F code we can assume support. */
-        #else
-            /* AVX-512 requires both CPU and OS support. */
-            #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV)
-                return MA_FALSE;
-            #else
-                int info1[4];
-                int info7[4];
-                ma_cpuid(info1, 1);
-                ma_cpuid(info7, 7);
-                if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 16)) != 0)) {
-                    ma_uint64 xrc = ma_xgetbv(0);
-                    if ((xrc & 0xE6) == 0xE6) {
-                        return MA_TRUE;
-                    } else {
-                        return MA_FALSE;
-                    }
-                } else {
-                    return MA_FALSE;
-                }
-            #endif
-        #endif
-    #else
-        return MA_FALSE;       /* AVX-512F is only supported on x86 and x64 architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_has_neon(void)
-{
-#if defined(MA_SUPPORT_NEON)
-    #if defined(MA_ARM) && !defined(MA_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return MA_TRUE;    /* If the compiler is allowed to freely generate NEON code we can assume support. */
-        #else
-            /* TODO: Runtime check. */
-            return MA_FALSE;
-        #endif
-    #else
-        return MA_FALSE;       /* NEON is only supported on ARM architectures. */
-    #endif
-#else
-    return MA_FALSE;           /* No compiler support. */
-#endif
-}
-
-#define MA_SIMD_NONE    0
-#define MA_SIMD_SSE2    1
-#define MA_SIMD_AVX2    2
-#define MA_SIMD_NEON    3
-
-#ifndef MA_PREFERRED_SIMD
-    #  if defined(MA_SUPPORT_SSE2) && defined(MA_PREFER_SSE2)
-        #define MA_PREFERRED_SIMD MA_SIMD_SSE2
-    #elif defined(MA_SUPPORT_AVX2) && defined(MA_PREFER_AVX2)
-        #define MA_PREFERRED_SIMD MA_SIMD_AVX2
-    #elif defined(MA_SUPPORT_NEON) && defined(MA_PREFER_NEON)
-        #define MA_PREFERRED_SIMD MA_SIMD_NEON
-    #else
-        #define MA_PREFERRED_SIMD MA_SIMD_NONE
-    #endif
-#endif
-
-#if defined(__has_builtin)
-    #define MA_COMPILER_HAS_BUILTIN(x) __has_builtin(x)
-#else
-    #define MA_COMPILER_HAS_BUILTIN(x) 0
-#endif
-
-#ifndef MA_ASSUME
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_assume)
-        #define MA_ASSUME(x) __builtin_assume(x)
-    #elif MA_COMPILER_HAS_BUILTIN(__builtin_unreachable)
-        #define MA_ASSUME(x) do { if (!(x)) __builtin_unreachable(); } while (0)
-    #elif defined(_MSC_VER)
-        #define MA_ASSUME(x) __assume(x)
-    #else
-        #define MA_ASSUME(x) while(0)
-    #endif
-#endif
-
-#ifndef MA_RESTRICT
-    #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER)
-        #define MA_RESTRICT __restrict
-    #else
-        #define MA_RESTRICT
-    #endif
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define MA_HAS_BYTESWAP16_INTRINSIC
-    #define MA_HAS_BYTESWAP32_INTRINSIC
-    #define MA_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap16)
-        #define MA_HAS_BYTESWAP16_INTRINSIC
-    #endif
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap32)
-        #define MA_HAS_BYTESWAP32_INTRINSIC
-    #endif
-    #if MA_COMPILER_HAS_BUILTIN(__builtin_bswap64)
-        #define MA_HAS_BYTESWAP64_INTRINSIC
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define MA_HAS_BYTESWAP32_INTRINSIC
-        #define MA_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define MA_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-
-
-static MA_INLINE ma_bool32 ma_is_little_endian(void)
-{
-#if defined(MA_X86) || defined(MA_X64)
-    return MA_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-
-static MA_INLINE ma_bool32 ma_is_big_endian(void)
-{
-    return !ma_is_little_endian();
-}
-
-
-static MA_INLINE ma_uint32 ma_swap_endian_uint32(ma_uint32 n)
-{
-#ifdef MA_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(MA_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(MA_64BIT)   /* <-- 64-bit inline assembly has not been tested, so disabling for now. */
-            /* Inline assembly optimized implementation for ARM. In my testing, GCC does not generate optimized code with __builtin_bswap32(). */
-            ma_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(MA_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)   /* <-- This is untested. If someone in the community could test this, that would be appreciated! */
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-
-
-#if !defined(MA_EMSCRIPTEN)
-#ifdef MA_WIN32
-static void ma_sleep__win32(ma_uint32 milliseconds)
-{
-    Sleep((DWORD)milliseconds);
-}
-#endif
-#ifdef MA_POSIX
-static void ma_sleep__posix(ma_uint32 milliseconds)
-{
-#ifdef MA_EMSCRIPTEN
-    (void)milliseconds;
-    MA_ASSERT(MA_FALSE);  /* The Emscripten build should never sleep. */
-#else
-    #if _POSIX_C_SOURCE >= 199309L
-        struct timespec ts;
-        ts.tv_sec  = milliseconds / 1000;
-        ts.tv_nsec = milliseconds % 1000 * 1000000;
-        nanosleep(&ts, NULL);
-    #else
-        struct timeval tv;
-        tv.tv_sec  = milliseconds / 1000;
-        tv.tv_usec = milliseconds % 1000 * 1000;
-        select(0, NULL, NULL, NULL, &tv);
-    #endif
-#endif
-}
-#endif
-
-static void ma_sleep(ma_uint32 milliseconds)
-{
-#ifdef MA_WIN32
-    ma_sleep__win32(milliseconds);
-#endif
-#ifdef MA_POSIX
-    ma_sleep__posix(milliseconds);
-#endif
-}
-#endif
-
-static MA_INLINE void ma_yield()
-{
-#if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
-    /* x86/x64 */
-    #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            _mm_pause();
-        #else
-            #if defined(__DMC__)
-                /* Digital Mars does not recognize the PAUSE opcode. Fall back to NOP. */
-                __asm nop;  
-            #else
-                __asm pause;
-            #endif
-        #endif
-    #else
-        __asm__ __volatile__ ("pause");
-    #endif
-#elif (defined(__arm__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7) || (defined(_M_ARM) && _M_ARM >= 7) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)
-    /* ARM */
-    #if defined(_MSC_VER)
-        /* Apparently there is a __yield() intrinsic that's compatible with ARM, but I cannot find documentation for it nor can I find where it's declared. */
-        __yield();
-    #else
-        __asm__ __volatile__ ("yield"); /* ARMv6K/ARMv6T2 and above. */
-    #endif
-#else
-    /* Unknown or unsupported architecture. No-op. */
-#endif
-}
-
-
-
-#ifndef MA_COINIT_VALUE
-#define MA_COINIT_VALUE    0   /* 0 = COINIT_MULTITHREADED */
-#endif
-
-
-#ifndef MA_FLT_MAX
-    #ifdef FLT_MAX
-        #define MA_FLT_MAX FLT_MAX
-    #else
-        #define MA_FLT_MAX 3.402823466e+38F
-    #endif
-#endif
-
-
-#ifndef MA_PI
-#define MA_PI      3.14159265358979323846264f
-#endif
-#ifndef MA_PI_D
-#define MA_PI_D    3.14159265358979323846264
-#endif
-#ifndef MA_TAU
-#define MA_TAU     6.28318530717958647693f
-#endif
-#ifndef MA_TAU_D
-#define MA_TAU_D   6.28318530717958647693
-#endif
-
-
-/* The default format when ma_format_unknown (0) is requested when initializing a device. */
-#ifndef MA_DEFAULT_FORMAT
-#define MA_DEFAULT_FORMAT                                   ma_format_f32
-#endif
-
-/* The default channel count to use when 0 is used when initializing a device. */
-#ifndef MA_DEFAULT_CHANNELS
-#define MA_DEFAULT_CHANNELS                                 2
-#endif
-
-/* The default sample rate to use when 0 is used when initializing a device. */
-#ifndef MA_DEFAULT_SAMPLE_RATE
-#define MA_DEFAULT_SAMPLE_RATE                              48000
-#endif
-
-/* Default periods when none is specified in ma_device_init(). More periods means more work on the CPU. */
-#ifndef MA_DEFAULT_PERIODS
-#define MA_DEFAULT_PERIODS                                  3
-#endif
-
-/* The default period size in milliseconds for low latency mode. */
-#ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY
-#define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY  10
-#endif
-
-/* The default buffer size in milliseconds for conservative mode. */
-#ifndef MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE
-#define MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE 100
-#endif
-
-/* The default LPF filter order for linear resampling. Note that this is clamped to MA_MAX_FILTER_ORDER. */
-#ifndef MA_DEFAULT_RESAMPLER_LPF_ORDER
-    #if MA_MAX_FILTER_ORDER >= 4
-        #define MA_DEFAULT_RESAMPLER_LPF_ORDER  4
-    #else
-        #define MA_DEFAULT_RESAMPLER_LPF_ORDER  MA_MAX_FILTER_ORDER
-    #endif
-#endif
-
-
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wunused-variable"
-#endif
-
-/* Standard sample rates, in order of priority. */
-static ma_uint32 g_maStandardSampleRatePriorities[] = {
-    (ma_uint32)ma_standard_sample_rate_48000,
-    (ma_uint32)ma_standard_sample_rate_44100,
-
-    (ma_uint32)ma_standard_sample_rate_32000,
-    (ma_uint32)ma_standard_sample_rate_24000,
-    (ma_uint32)ma_standard_sample_rate_22050,
-
-    (ma_uint32)ma_standard_sample_rate_88200,
-    (ma_uint32)ma_standard_sample_rate_96000,
-    (ma_uint32)ma_standard_sample_rate_176400,
-    (ma_uint32)ma_standard_sample_rate_192000,
-
-    (ma_uint32)ma_standard_sample_rate_16000,
-    (ma_uint32)ma_standard_sample_rate_11025,
-    (ma_uint32)ma_standard_sample_rate_8000,
-
-    (ma_uint32)ma_standard_sample_rate_352800,
-    (ma_uint32)ma_standard_sample_rate_384000
-};
-
-static MA_INLINE ma_bool32 ma_is_standard_sample_rate(ma_uint32 sampleRate)
-{
-    ma_uint32 iSampleRate;
-
-    for (iSampleRate = 0; iSampleRate < sizeof(g_maStandardSampleRatePriorities) / sizeof(g_maStandardSampleRatePriorities[0]); iSampleRate += 1) {
-        if (g_maStandardSampleRatePriorities[iSampleRate] == sampleRate) {
-            return MA_TRUE;
-        }
-    }
-
-    /* Getting here means the sample rate is not supported. */
-    return MA_FALSE;
-}
-
-
-static ma_format g_maFormatPriorities[] = {
-    ma_format_s16,         /* Most common */
-    ma_format_f32,
-
-    /*ma_format_s24_32,*/    /* Clean alignment */
-    ma_format_s32,
-
-    ma_format_s24,         /* Unclean alignment */
-
-    ma_format_u8           /* Low quality */
-};
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-
-
-MA_API void ma_version(ma_uint32* pMajor, ma_uint32* pMinor, ma_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = MA_VERSION_MAJOR;
-    }
-
-    if (pMinor) {
-        *pMinor = MA_VERSION_MINOR;
-    }
-
-    if (pRevision) {
-        *pRevision = MA_VERSION_REVISION;
-    }
-}
-
-MA_API const char* ma_version_string(void)
-{
-    return MA_VERSION_STRING;
-}
-
-
-/******************************************************************************
-
-Standard Library Stuff
-
-******************************************************************************/
-#ifndef MA_MALLOC
-#ifdef MA_WIN32
-#define MA_MALLOC(sz) HeapAlloc(GetProcessHeap(), 0, (sz))
-#else
-#define MA_MALLOC(sz) malloc((sz))
-#endif
-#endif
-
-#ifndef MA_REALLOC
-#ifdef MA_WIN32
-#define MA_REALLOC(p, sz) (((sz) > 0) ? ((p) ? HeapReAlloc(GetProcessHeap(), 0, (p), (sz)) : HeapAlloc(GetProcessHeap(), 0, (sz))) : ((VOID*)(size_t)(HeapFree(GetProcessHeap(), 0, (p)) & 0)))
-#else
-#define MA_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#endif
-
-#ifndef MA_FREE
-#ifdef MA_WIN32
-#define MA_FREE(p) HeapFree(GetProcessHeap(), 0, (p))
-#else
-#define MA_FREE(p) free((p))
-#endif
-#endif
-
-#ifndef MA_ZERO_MEMORY
-#ifdef MA_WIN32
-#define MA_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz))
-#else
-#define MA_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#endif
-
-#ifndef MA_COPY_MEMORY
-#ifdef MA_WIN32
-#define MA_COPY_MEMORY(dst, src, sz) CopyMemory((dst), (src), (sz))
-#else
-#define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#endif
-
-#ifndef MA_ASSERT
-#ifdef MA_WIN32
-#define MA_ASSERT(condition) assert(condition)
-#else
-#define MA_ASSERT(condition) assert(condition)
-#endif
-#endif
-
-#define MA_ZERO_OBJECT(p) MA_ZERO_MEMORY((p), sizeof(*(p)))
-
-#define ma_countof(x)               (sizeof(x) / sizeof(x[0]))
-#define ma_max(x, y)                (((x) > (y)) ? (x) : (y))
-#define ma_min(x, y)                (((x) < (y)) ? (x) : (y))
-#define ma_abs(x)                   (((x) > 0) ? (x) : -(x))
-#define ma_clamp(x, lo, hi)         (ma_max(lo, ma_min(x, hi)))
-#define ma_offset_ptr(p, offset)    (((ma_uint8*)(p)) + (offset))
-
-#define ma_buffer_frame_capacity(buffer, channels, format) (sizeof(buffer) / ma_get_bytes_per_sample(format) / (channels))
-
-static MA_INLINE double ma_sin(double x)
-{
-    /* TODO: Implement custom sin(x). */
-    return sin(x);
-}
-
-static MA_INLINE double ma_exp(double x)
-{
-    /* TODO: Implement custom exp(x). */
-    return exp(x);
-}
-
-static MA_INLINE double ma_log(double x)
-{
-    /* TODO: Implement custom log(x). */
-    return log(x);
-}
-
-static MA_INLINE double ma_pow(double x, double y)
-{
-    /* TODO: Implement custom pow(x, y). */
-    return pow(x, y);
-}
-
-static MA_INLINE double ma_sqrt(double x)
-{
-    /* TODO: Implement custom sqrt(x). */
-    return sqrt(x);
-}
-
-
-static MA_INLINE double ma_cos(double x)
-{
-    return ma_sin((MA_PI_D*0.5) - x);
-}
-
-static MA_INLINE double ma_log10(double x)
-{
-    return ma_log(x) * 0.43429448190325182765;
-}
-
-static MA_INLINE float ma_powf(float x, float y)
-{
-    return (float)ma_pow((double)x, (double)y);
-}
-
-static MA_INLINE float ma_log10f(float x)
-{
-    return (float)ma_log10((double)x);
-}
-
-
-static MA_INLINE double ma_degrees_to_radians(double degrees)
-{
-    return degrees * 0.01745329252;
-}
-
-static MA_INLINE double ma_radians_to_degrees(double radians)
-{
-    return radians * 57.295779512896;
-}
-
-static MA_INLINE float ma_degrees_to_radians_f(float degrees)
-{
-    return degrees * 0.01745329252f;
-}
-
-static MA_INLINE float ma_radians_to_degrees_f(float radians)
-{
-    return radians * 57.295779512896f;
-}
-
-
-/*
-Return Values:
-  0:  Success
-  22: EINVAL
-  34: ERANGE
-
-Not using symbolic constants for errors because I want to avoid #including errno.h
-*/
-MA_API int ma_strcpy_s(char* dst, size_t dstSizeInBytes, const char* src)
-{
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    for (i = 0; i < dstSizeInBytes && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (i < dstSizeInBytes) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-MA_API int ma_wcscpy_s(wchar_t* dst, size_t dstCap, const wchar_t* src)
-{
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstCap == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    for (i = 0; i < dstCap && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (i < dstCap) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-
-MA_API int ma_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
-{
-    size_t maxcount;
-    size_t i;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    maxcount = count;
-    if (count == ((size_t)-1) || count >= dstSizeInBytes) {        /* -1 = _TRUNCATE */
-        maxcount = dstSizeInBytes - 1;
-    }
-
-    for (i = 0; i < maxcount && src[i] != '\0'; ++i) {
-        dst[i] = src[i];
-    }
-
-    if (src[i] == '\0' || i == count || count == ((size_t)-1)) {
-        dst[i] = '\0';
-        return 0;
-    }
-
-    dst[0] = '\0';
-    return 34;
-}
-
-MA_API int ma_strcat_s(char* dst, size_t dstSizeInBytes, const char* src)
-{
-    char* dstorig;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    dstorig = dst;
-
-    while (dstSizeInBytes > 0 && dst[0] != '\0') {
-        dst += 1;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        return 22;  /* Unterminated. */
-    }
-
-
-    while (dstSizeInBytes > 0 && src[0] != '\0') {
-        *dst++ = *src++;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes > 0) {
-        dst[0] = '\0';
-    } else {
-        dstorig[0] = '\0';
-        return 34;
-    }
-
-    return 0;
-}
-
-MA_API int ma_strncat_s(char* dst, size_t dstSizeInBytes, const char* src, size_t count)
-{
-    char* dstorig;
-
-    if (dst == 0) {
-        return 22;
-    }
-    if (dstSizeInBytes == 0) {
-        return 34;
-    }
-    if (src == 0) {
-        return 22;
-    }
-
-    dstorig = dst;
-
-    while (dstSizeInBytes > 0 && dst[0] != '\0') {
-        dst += 1;
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        return 22;  /* Unterminated. */
-    }
-
-
-    if (count == ((size_t)-1)) {        /* _TRUNCATE */
-        count = dstSizeInBytes - 1;
-    }
-
-    while (dstSizeInBytes > 0 && src[0] != '\0' && count > 0) {
-        *dst++ = *src++;
-        dstSizeInBytes -= 1;
-        count -= 1;
-    }
-
-    if (dstSizeInBytes > 0) {
-        dst[0] = '\0';
-    } else {
-        dstorig[0] = '\0';
-        return 34;
-    }
-
-    return 0;
-}
-
-MA_API int ma_itoa_s(int value, char* dst, size_t dstSizeInBytes, int radix)
-{
-    int sign;
-    unsigned int valueU;
-    char* dstEnd;
-
-    if (dst == NULL || dstSizeInBytes == 0) {
-        return 22;
-    }
-    if (radix < 2 || radix > 36) {
-        dst[0] = '\0';
-        return 22;
-    }
-
-    sign = (value < 0 && radix == 10) ? -1 : 1;     /* The negative sign is only used when the base is 10. */
-
-    if (value < 0) {
-        valueU = -value;
-    } else {
-        valueU = value;
-    }
-
-    dstEnd = dst;
-    do
-    {
-        int remainder = valueU % radix;
-        if (remainder > 9) {
-            *dstEnd = (char)((remainder - 10) + 'a');
-        } else {
-            *dstEnd = (char)(remainder + '0');
-        }
-
-        dstEnd += 1;
-        dstSizeInBytes -= 1;
-        valueU /= radix;
-    } while (dstSizeInBytes > 0 && valueU > 0);
-
-    if (dstSizeInBytes == 0) {
-        dst[0] = '\0';
-        return 22;  /* Ran out of room in the output buffer. */
-    }
-
-    if (sign < 0) {
-        *dstEnd++ = '-';
-        dstSizeInBytes -= 1;
-    }
-
-    if (dstSizeInBytes == 0) {
-        dst[0] = '\0';
-        return 22;  /* Ran out of room in the output buffer. */
-    }
-
-    *dstEnd = '\0';
-
-
-    /* At this point the string will be reversed. */
-    dstEnd -= 1;
-    while (dst < dstEnd) {
-        char temp = *dst;
-        *dst = *dstEnd;
-        *dstEnd = temp;
-
-        dst += 1;
-        dstEnd -= 1;
-    }
-
-    return 0;
-}
-
-MA_API int ma_strcmp(const char* str1, const char* str2)
-{
-    if (str1 == str2) return  0;
-
-    /* These checks differ from the standard implementation. It's not important, but I prefer it just for sanity. */
-    if (str1 == NULL) return -1;
-    if (str2 == NULL) return  1;
-
-    for (;;) {
-        if (str1[0] == '\0') {
-            break;
-        }
-        if (str1[0] != str2[0]) {
-            break;
-        }
-
-        str1 += 1;
-        str2 += 1;
-    }
-
-    return ((unsigned char*)str1)[0] - ((unsigned char*)str2)[0];
-}
-
-MA_API int ma_strappend(char* dst, size_t dstSize, const char* srcA, const char* srcB)
-{
-    int result;
-
-    result = ma_strncpy_s(dst, dstSize, srcA, (size_t)-1);
-    if (result != 0) {
-        return result;
-    }
-
-    result = ma_strncat_s(dst, dstSize, srcB, (size_t)-1);
-    if (result != 0) {
-        return result;
-    }
-
-    return result;
-}
-
-MA_API char* ma_copy_string(const char* src, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t sz = strlen(src)+1;
-    char* dst = (char*)ma_malloc(sz, pAllocationCallbacks);
-    if (dst == NULL) {
-        return NULL;
-    }
-
-    ma_strcpy_s(dst, sz, src);
-
-    return dst;
-}
-
-MA_API wchar_t* ma_copy_string_w(const wchar_t* src, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t sz = wcslen(src)+1;
-    wchar_t* dst = (wchar_t*)ma_malloc(sz * sizeof(*dst), pAllocationCallbacks);
-    if (dst == NULL) {
-        return NULL;
-    }
-
-    ma_wcscpy_s(dst, sz, src);
-
-    return dst;
-}
-
-
-#include <errno.h>
-static ma_result ma_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return MA_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return MA_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return MA_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return MA_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return MA_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return MA_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return MA_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return MA_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return MA_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return MA_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return MA_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return MA_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return MA_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return MA_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return MA_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return MA_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return MA_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return MA_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return MA_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return MA_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return MA_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return MA_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return MA_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return MA_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return MA_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return MA_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return MA_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return MA_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return MA_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return MA_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return MA_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return MA_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return MA_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return MA_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return MA_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return MA_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return MA_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return MA_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return MA_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return MA_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return MA_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return MA_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return MA_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return MA_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return MA_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return MA_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return MA_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return MA_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return MA_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return MA_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return MA_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return MA_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return MA_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return MA_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return MA_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return MA_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return MA_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return MA_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return MA_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return MA_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return MA_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return MA_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return MA_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return MA_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return MA_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return MA_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return MA_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return MA_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return MA_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return MA_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return MA_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return MA_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return MA_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return MA_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return MA_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return MA_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return MA_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return MA_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return MA_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return MA_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return MA_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return MA_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return MA_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return MA_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return MA_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return MA_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return MA_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return MA_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return MA_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return MA_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return MA_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return MA_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return MA_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return MA_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return MA_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return MA_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return MA_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return MA_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return MA_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return MA_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return MA_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return MA_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return MA_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return MA_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return MA_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return MA_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return MA_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return MA_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return MA_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return MA_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return MA_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return MA_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return MA_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return MA_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return MA_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return MA_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return MA_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return MA_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return MA_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return MA_ERROR;
-    #endif
-        default: return MA_ERROR;
-    }
-}
-
-MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return ma_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        ma_result result = ma_result_from_errno(errno);
-        if (result == MA_SUCCESS) {
-            result = MA_ERROR;   /* Just a safety check to make sure we never ever return success when pFile == NULL. */
-        }
-
-        return result;
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-
-/*
-_wfopen() isn't always available in all compilation environments.
-
-    * Windows only.
-    * MSVC seems to support it universally as far back as VC6 from what I can tell (haven't checked further back).
-    * MinGW-64 (both 32- and 64-bit) seems to support it.
-    * MinGW wraps it in !defined(__STRICT_ANSI__).
-    * OpenWatcom wraps it in !defined(_NO_EXT_KEYS).
-
-This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
-fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
-*/
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define MA_HAS_WFOPEN
-    #endif
-#endif
-
-MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;  /* Safety. */
-    }
-
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_HAS_WFOPEN)
-    {
-        /* Use _wfopen() on Windows. */
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return ma_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return ma_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    /*
-    Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
-    think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
-    maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
-    */
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-
-        /* Get the length first. */
-        MA_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return ma_result_from_errno(errno);
-        }
-
-        pFilePathMB = (char*)ma_malloc(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pFilePathTemp = pFilePath;
-        MA_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-
-        /* The open mode should always consist of ASCII characters so we should be able to do a trivial conversion. */
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-
-        ma_free(pFilePathMB, pAllocationCallbacks);
-    }
-
-    if (*ppFile == NULL) {
-        return MA_ERROR;
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-
-static MA_INLINE void ma_copy_memory_64(void* dst, const void* src, ma_uint64 sizeInBytes)
-{
-#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX
-    MA_COPY_MEMORY(dst, src, (size_t)sizeInBytes);
-#else
-    while (sizeInBytes > 0) {
-        ma_uint64 bytesToCopyNow = sizeInBytes;
-        if (bytesToCopyNow > MA_SIZE_MAX) {
-            bytesToCopyNow = MA_SIZE_MAX;
-        }
-
-        MA_COPY_MEMORY(dst, src, (size_t)bytesToCopyNow);  /* Safe cast to size_t. */
-
-        sizeInBytes -= bytesToCopyNow;
-        dst = (      void*)((      ma_uint8*)dst + bytesToCopyNow);
-        src = (const void*)((const ma_uint8*)src + bytesToCopyNow);
-    }
-#endif
-}
-
-static MA_INLINE void ma_zero_memory_64(void* dst, ma_uint64 sizeInBytes)
-{
-#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX
-    MA_ZERO_MEMORY(dst, (size_t)sizeInBytes);
-#else
-    while (sizeInBytes > 0) {
-        ma_uint64 bytesToZeroNow = sizeInBytes;
-        if (bytesToZeroNow > MA_SIZE_MAX) {
-            bytesToZeroNow = MA_SIZE_MAX;
-        }
-
-        MA_ZERO_MEMORY(dst, (size_t)bytesToZeroNow);  /* Safe cast to size_t. */
-
-        sizeInBytes -= bytesToZeroNow;
-        dst = (void*)((ma_uint8*)dst + bytesToZeroNow);
-    }
-#endif
-}
-
-
-/* Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 */
-static MA_INLINE unsigned int ma_next_power_of_2(unsigned int x)
-{
-    x--;
-    x |= x >> 1;
-    x |= x >> 2;
-    x |= x >> 4;
-    x |= x >> 8;
-    x |= x >> 16;
-    x++;
-
-    return x;
-}
-
-static MA_INLINE unsigned int ma_prev_power_of_2(unsigned int x)
-{
-    return ma_next_power_of_2(x) >> 1;
-}
-
-static MA_INLINE unsigned int ma_round_to_power_of_2(unsigned int x)
-{
-    unsigned int prev = ma_prev_power_of_2(x);
-    unsigned int next = ma_next_power_of_2(x);
-    if ((next - x) > (x - prev)) {
-        return prev;
-    } else {
-        return next;
-    }
-}
-
-static MA_INLINE unsigned int ma_count_set_bits(unsigned int x)
-{
-    unsigned int count = 0;
-    while (x != 0) {
-        if (x & 1) {
-            count += 1;
-        }
-
-        x = x >> 1;
-    }
-
-    return count;
-}
-
-
-
-/* Clamps an f32 sample to -1..1 */
-static MA_INLINE float ma_clip_f32(float x)
-{
-    if (x < -1) return -1;
-    if (x > +1) return +1;
-    return x;
-}
-
-static MA_INLINE float ma_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static MA_INLINE float ma_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-    /*return x + (y - x)*a;*/
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE __m128 ma_mix_f32_fast__sse2(__m128 x, __m128 y, __m128 a)
-{
-    return _mm_add_ps(x, _mm_mul_ps(_mm_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE __m256 ma_mix_f32_fast__avx2(__m256 x, __m256 y, __m256 a)
-{
-    return _mm256_add_ps(x, _mm256_mul_ps(_mm256_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_AVX512)
-static MA_INLINE __m512 ma_mix_f32_fast__avx512(__m512 x, __m512 y, __m512 a)
-{
-    return _mm512_add_ps(x, _mm512_mul_ps(_mm512_sub_ps(y, x), a));
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE float32x4_t ma_mix_f32_fast__neon(float32x4_t x, float32x4_t y, float32x4_t a)
-{
-    return vaddq_f32(x, vmulq_f32(vsubq_f32(y, x), a));
-}
-#endif
-
-
-static MA_INLINE double ma_mix_f64(double x, double y, double a)
-{
-    return x*(1-a) + y*a;
-}
-static MA_INLINE double ma_mix_f64_fast(double x, double y, double a)
-{
-    return x + (y - x)*a;
-}
-
-static MA_INLINE float ma_scale_to_range_f32(float x, float lo, float hi)
-{
-    return lo + x*(hi-lo);
-}
-
-
-/*
-Greatest common factor using Euclid's algorithm iteratively.
-*/
-static MA_INLINE ma_uint32 ma_gcf_u32(ma_uint32 a, ma_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            ma_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-
-    return a;
-}
-
-
-/*
-Random Number Generation
-
-miniaudio uses the LCG random number generation algorithm. This is good enough for audio.
-
-Note that miniaudio's global LCG implementation uses global state which is _not_ thread-local. When this is called across
-multiple threads, results will be unpredictable. However, it won't crash and results will still be random enough for
-miniaudio's purposes.
-*/
-#ifndef MA_DEFAULT_LCG_SEED
-#define MA_DEFAULT_LCG_SEED 4321
-#endif
-
-#define MA_LCG_M   2147483647
-#define MA_LCG_A   48271
-#define MA_LCG_C   0
-
-static ma_lcg g_maLCG = {MA_DEFAULT_LCG_SEED}; /* Non-zero initial seed. Use ma_seed() to use an explicit seed. */
-
-static MA_INLINE void ma_lcg_seed(ma_lcg* pLCG, ma_int32 seed)
-{
-    MA_ASSERT(pLCG != NULL);
-    pLCG->state = seed;
-}
-
-static MA_INLINE ma_int32 ma_lcg_rand_s32(ma_lcg* pLCG)
-{
-    pLCG->state = (MA_LCG_A * pLCG->state + MA_LCG_C) % MA_LCG_M;
-    return pLCG->state;
-}
-
-static MA_INLINE ma_uint32 ma_lcg_rand_u32(ma_lcg* pLCG)
-{
-    return (ma_uint32)ma_lcg_rand_s32(pLCG);
-}
-
-static MA_INLINE ma_int16 ma_lcg_rand_s16(ma_lcg* pLCG)
-{
-    return (ma_int16)(ma_lcg_rand_s32(pLCG) & 0xFFFF);
-}
-
-static MA_INLINE double ma_lcg_rand_f64(ma_lcg* pLCG)
-{
-    return ma_lcg_rand_s32(pLCG) / (double)0x7FFFFFFF;
-}
-
-static MA_INLINE float ma_lcg_rand_f32(ma_lcg* pLCG)
-{
-    return (float)ma_lcg_rand_f64(pLCG);
-}
-
-static MA_INLINE float ma_lcg_rand_range_f32(ma_lcg* pLCG, float lo, float hi)
-{
-    return ma_scale_to_range_f32(ma_lcg_rand_f32(pLCG), lo, hi);
-}
-
-static MA_INLINE ma_int32 ma_lcg_rand_range_s32(ma_lcg* pLCG, ma_int32 lo, ma_int32 hi)
-{
-    if (lo == hi) {
-        return lo;
-    }
-
-    return lo + ma_lcg_rand_u32(pLCG) / (0xFFFFFFFF / (hi - lo + 1) + 1);
-}
-
-
-
-static MA_INLINE void ma_seed(ma_int32 seed)
-{
-    ma_lcg_seed(&g_maLCG, seed);
-}
-
-static MA_INLINE ma_int32 ma_rand_s32(void)
-{
-    return ma_lcg_rand_s32(&g_maLCG);
-}
-
-static MA_INLINE ma_uint32 ma_rand_u32(void)
-{
-    return ma_lcg_rand_u32(&g_maLCG);
-}
-
-static MA_INLINE double ma_rand_f64(void)
-{
-    return ma_lcg_rand_f64(&g_maLCG);
-}
-
-static MA_INLINE float ma_rand_f32(void)
-{
-    return ma_lcg_rand_f32(&g_maLCG);
-}
-
-static MA_INLINE float ma_rand_range_f32(float lo, float hi)
-{
-    return ma_lcg_rand_range_f32(&g_maLCG, lo, hi);
-}
-
-static MA_INLINE ma_int32 ma_rand_range_s32(ma_int32 lo, ma_int32 hi)
-{
-    return ma_lcg_rand_range_s32(&g_maLCG, lo, hi);
-}
-
-
-static MA_INLINE float ma_dither_f32_rectangle(float ditherMin, float ditherMax)
-{
-    return ma_rand_range_f32(ditherMin, ditherMax);
-}
-
-static MA_INLINE float ma_dither_f32_triangle(float ditherMin, float ditherMax)
-{
-    float a = ma_rand_range_f32(ditherMin, 0);
-    float b = ma_rand_range_f32(0, ditherMax);
-    return a + b;
-}
-
-static MA_INLINE float ma_dither_f32(ma_dither_mode ditherMode, float ditherMin, float ditherMax)
-{
-    if (ditherMode == ma_dither_mode_rectangle) {
-        return ma_dither_f32_rectangle(ditherMin, ditherMax);
-    }
-    if (ditherMode == ma_dither_mode_triangle) {
-        return ma_dither_f32_triangle(ditherMin, ditherMax);
-    }
-
-    return 0;
-}
-
-static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 ditherMin, ma_int32 ditherMax)
-{
-    if (ditherMode == ma_dither_mode_rectangle) {
-        ma_int32 a = ma_rand_range_s32(ditherMin, ditherMax);
-        return a;
-    }
-    if (ditherMode == ma_dither_mode_triangle) {
-        ma_int32 a = ma_rand_range_s32(ditherMin, 0);
-        ma_int32 b = ma_rand_range_s32(0, ditherMax);
-        return a + b;
-    }
-
-    return 0;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Atomics
-
-**************************************************************************************************************************************************************/
-/* c89atomic.h begin */
-#ifndef c89atomic_h
-#define c89atomic_h
-#if defined(__cplusplus)
-extern "C" {
-#endif
-typedef   signed char           c89atomic_int8;
-typedef unsigned char           c89atomic_uint8;
-typedef   signed short          c89atomic_int16;
-typedef unsigned short          c89atomic_uint16;
-typedef   signed int            c89atomic_int32;
-typedef unsigned int            c89atomic_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    c89atomic_int64;
-    typedef unsigned __int64    c89atomic_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  c89atomic_int64;
-    typedef unsigned long long  c89atomic_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-typedef int                     c89atomic_memory_order;
-typedef unsigned char           c89atomic_bool;
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#ifdef _WIN32
-#ifdef _WIN64
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#endif
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#ifdef __GNUC__
-#ifdef __LP64__
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#endif
-#if !defined(C89ATOMIC_64BIT) && !defined(C89ATOMIC_32BIT)
-#include <stdint.h>
-#if INTPTR_MAX == INT64_MAX
-#define C89ATOMIC_64BIT
-#else
-#define C89ATOMIC_32BIT
-#endif
-#endif
-#if defined(__x86_64__) || defined(_M_X64)
-#define C89ATOMIC_X64
-#elif defined(__i386) || defined(_M_IX86)
-#define C89ATOMIC_X86
-#elif defined(__arm__) || defined(_M_ARM)
-#define C89ATOMIC_ARM
-#endif
-#if defined(_MSC_VER)
-    #define C89ATOMIC_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define C89ATOMIC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define C89ATOMIC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__) || defined(__DMC__)
-    #define C89ATOMIC_INLINE __inline
-#else
-    #define C89ATOMIC_INLINE
-#endif
-#define C89ATOMIC_HAS_8
-#define C89ATOMIC_HAS_16
-#define C89ATOMIC_HAS_32
-#define C89ATOMIC_HAS_64
-#if (defined(_MSC_VER) ) || defined(__WATCOMC__) || defined(__DMC__)
-    #define c89atomic_memory_order_relaxed  0
-    #define c89atomic_memory_order_consume  1
-    #define c89atomic_memory_order_acquire  2
-    #define c89atomic_memory_order_release  3
-    #define c89atomic_memory_order_acq_rel  4
-    #define c89atomic_memory_order_seq_cst  5
-    #if _MSC_VER < 1600 && defined(C89ATOMIC_32BIT)
-        #define C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY
-    #endif
-    #if _MSC_VER < 1600
-        #undef C89ATOMIC_HAS_8
-        #undef C89ATOMIC_HAS_16
-    #endif
-    #if !defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #include <intrin.h>
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
-            {
-                c89atomic_uint8 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov al,  expected
-                    mov dl,  desired
-                    lock cmpxchg [ecx], dl
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
-            {
-                c89atomic_uint16 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  expected
-                    mov dx,  desired
-                    lock cmpxchg [ecx], dx
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
-            {
-                c89atomic_uint32 result = 0;
-                __asm {
-                    mov ecx, dst
-                    mov eax, expected
-                    mov edx, desired
-                    lock cmpxchg [ecx], edx
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
-            {
-                c89atomic_uint32 resultEAX = 0;
-                c89atomic_uint32 resultEDX = 0;
-                __asm {
-                    mov esi, dst
-                    mov eax, dword ptr expected
-                    mov edx, dword ptr expected + 4
-                    mov ebx, dword ptr desired
-                    mov ecx, dword ptr desired + 4
-                    lock cmpxchg8b qword ptr [esi]
-                    mov resultEAX, eax
-                    mov resultEDX, edx
-                }
-                return ((c89atomic_uint64)resultEDX << 32) | resultEAX;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            #define c89atomic_compare_and_swap_8( dst, expected, desired) (c89atomic_uint8 )_InterlockedCompareExchange8((volatile char*)dst, (char)desired, (char)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            #define c89atomic_compare_and_swap_16(dst, expected, desired) (c89atomic_uint16)_InterlockedCompareExchange16((volatile short*)dst, (short)desired, (short)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            #define c89atomic_compare_and_swap_32(dst, expected, desired) (c89atomic_uint32)_InterlockedCompareExchange((volatile long*)dst, (long)desired, (long)expected)
-        #endif
-        #if defined(C89ATOMIC_HAS_64)
-            #define c89atomic_compare_and_swap_64(dst, expected, desired) (c89atomic_uint64)_InterlockedCompareExchange64((volatile long long*)dst, (long long)desired, (long long)expected)
-        #endif
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint8 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov al,  src
-                    lock xchg [ecx], al
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint16 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  src
-                    lock xchg [ecx], ax
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint32 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov eax, src
-                    lock xchg [ecx], eax
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint8)_InterlockedExchange8((volatile char*)dst, (char)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint16)_InterlockedExchange16((volatile short*)dst, (short)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint32)_InterlockedExchange((volatile long*)dst, (long)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint64)_InterlockedExchange64((volatile long long*)dst, (long long)src);
-            }
-        #else
-        #endif
-    #endif
-    #if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            do {
-                oldValue = *dst;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint8 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov al,  src
-                    lock xadd [ecx], al
-                    mov result, al
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint16 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov ax,  src
-                    lock xadd [ecx], ax
-                    mov result, ax
-                }
-                return result;
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                c89atomic_uint32 result = 0;
-                (void)order;
-                __asm {
-                    mov ecx, dst
-                    mov eax, src
-                    lock xadd [ecx], eax
-                    mov result, eax
-                }
-                return result;
-            }
-        #endif
-    #else
-        #if defined(C89ATOMIC_HAS_8)
-            static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint8)_InterlockedExchangeAdd8((volatile char*)dst, (char)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_16)
-            static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint16)_InterlockedExchangeAdd16((volatile short*)dst, (short)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_32)
-            static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint32)_InterlockedExchangeAdd((volatile long*)dst, (long)src);
-            }
-        #endif
-        #if defined(C89ATOMIC_HAS_64) && defined(C89ATOMIC_64BIT)
-            static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-            {
-                (void)order;
-                return (c89atomic_uint64)_InterlockedExchangeAdd64((volatile long long*)dst, (long long)src);
-            }
-        #else
-        #endif
-    #endif
-    #if defined(C89ATOMIC_HAS_64) && !defined(C89ATOMIC_64BIT)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue + src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_MSVC_USE_INLINED_ASSEMBLY)
-        static C89ATOMIC_INLINE void __stdcall c89atomic_thread_fence(c89atomic_memory_order order)
-        {
-            (void)order;
-            __asm {
-                lock add [esp], 0
-            }
-        }
-    #else
-        #if defined(C89ATOMIC_X64)
-            #define c89atomic_thread_fence(order)   __faststorefence(), (void)order
-        #else
-            static C89ATOMIC_INLINE void c89atomic_thread_fence(c89atomic_memory_order order)
-            {
-                volatile c89atomic_uint32 barrier = 0;
-                c89atomic_fetch_add_explicit_32(&barrier, 0, order);
-            }
-        #endif
-    #endif
-    #define c89atomic_compiler_fence()      c89atomic_thread_fence(c89atomic_memory_order_seq_cst)
-    #define c89atomic_signal_fence(order)   c89atomic_thread_fence(order)
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile const c89atomic_uint8* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_8((c89atomic_uint8*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile const c89atomic_uint16* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_16((c89atomic_uint16*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile const c89atomic_uint32* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_32((c89atomic_uint32*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile const c89atomic_uint64* ptr, c89atomic_memory_order order)
-        {
-            (void)order;
-            return c89atomic_compare_and_swap_64((c89atomic_uint64*)ptr, 0, 0);
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_store_explicit_8( dst, src, order) (void)c89atomic_exchange_explicit_8 (dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_store_explicit_16(dst, src, order) (void)c89atomic_exchange_explicit_16(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_store_explicit_32(dst, src, order) (void)c89atomic_exchange_explicit_32(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_store_explicit_64(dst, src, order) (void)c89atomic_exchange_explicit_64(dst, src, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue - src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue - src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue & src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue & src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        static C89ATOMIC_INLINE c89atomic_uint8 __stdcall c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue | src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        static C89ATOMIC_INLINE c89atomic_uint16 __stdcall c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue | src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        static C89ATOMIC_INLINE c89atomic_uint32 __stdcall c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        static C89ATOMIC_INLINE c89atomic_uint64 __stdcall c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_test_and_set_explicit_8( dst, order) c89atomic_exchange_explicit_8 (dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_test_and_set_explicit_16(dst, order) c89atomic_exchange_explicit_16(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_test_and_set_explicit_32(dst, order) c89atomic_exchange_explicit_32(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_test_and_set_explicit_64(dst, order) c89atomic_exchange_explicit_64(dst, 1, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        #define c89atomic_clear_explicit_8( dst, order) c89atomic_store_explicit_8 (dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        #define c89atomic_clear_explicit_16(dst, order) c89atomic_store_explicit_16(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        #define c89atomic_clear_explicit_32(dst, order) c89atomic_store_explicit_32(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        #define c89atomic_clear_explicit_64(dst, order) c89atomic_store_explicit_64(dst, 0, order)
-    #endif
-    #if defined(C89ATOMIC_HAS_8)
-        typedef c89atomic_uint8 c89atomic_flag;
-        #define c89atomic_flag_test_and_set_explicit(ptr, order)    (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
-        #define c89atomic_flag_clear_explicit(ptr, order)           c89atomic_clear_explicit_8(ptr, order)
-        #define c89atoimc_flag_load_explicit(ptr, order)            c89atomic_load_explicit_8(ptr, order)
-    #else
-        typedef c89atomic_uint32 c89atomic_flag;
-        #define c89atomic_flag_test_and_set_explicit(ptr, order)    (c89atomic_bool)c89atomic_test_and_set_explicit_32(ptr, order)
-        #define c89atomic_flag_clear_explicit(ptr, order)           c89atomic_clear_explicit_32(ptr, order)
-        #define c89atoimc_flag_load_explicit(ptr, order)            c89atomic_load_explicit_32(ptr, order)
-    #endif
-#elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE
-    #define C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE
-    #define c89atomic_memory_order_relaxed                          __ATOMIC_RELAXED
-    #define c89atomic_memory_order_consume                          __ATOMIC_CONSUME
-    #define c89atomic_memory_order_acquire                          __ATOMIC_ACQUIRE
-    #define c89atomic_memory_order_release                          __ATOMIC_RELEASE
-    #define c89atomic_memory_order_acq_rel                          __ATOMIC_ACQ_REL
-    #define c89atomic_memory_order_seq_cst                          __ATOMIC_SEQ_CST
-    #define c89atomic_compiler_fence()                              __asm__ __volatile__("":::"memory")
-    #define c89atomic_thread_fence(order)                           __atomic_thread_fence(order)
-    #define c89atomic_signal_fence(order)                           __atomic_signal_fence(order)
-    #define c89atomic_is_lock_free_8(ptr)                           __atomic_is_lock_free(1, ptr)
-    #define c89atomic_is_lock_free_16(ptr)                          __atomic_is_lock_free(2, ptr)
-    #define c89atomic_is_lock_free_32(ptr)                          __atomic_is_lock_free(4, ptr)
-    #define c89atomic_is_lock_free_64(ptr)                          __atomic_is_lock_free(8, ptr)
-    #define c89atomic_test_and_set_explicit_8( dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_16(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_32(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_64(dst, order)          __atomic_exchange_n(dst, 1, order)
-    #define c89atomic_clear_explicit_8( dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_16(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_32(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_clear_explicit_64(dst, order)                 __atomic_store_n(dst, 0, order)
-    #define c89atomic_store_explicit_8( dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_16(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_32(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_store_explicit_64(dst, src, order)            __atomic_store_n(dst, src, order)
-    #define c89atomic_load_explicit_8( dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_16(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_32(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_load_explicit_64(dst, order)                  __atomic_load_n(dst, order)
-    #define c89atomic_exchange_explicit_8( dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_16(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_32(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_exchange_explicit_64(dst, src, order)         __atomic_exchange_n(dst, src, order)
-    #define c89atomic_compare_exchange_strong_explicit_8( dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)   __atomic_compare_exchange_n(dst, expected, desired, 0, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder)     __atomic_compare_exchange_n(dst, expected, desired, 1, successOrder, failureOrder)
-    #define c89atomic_fetch_add_explicit_8( dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_16(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_32(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_add_explicit_64(dst, src, order)        __atomic_fetch_add(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_8( dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_16(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_32(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_sub_explicit_64(dst, src, order)        __atomic_fetch_sub(dst, src, order)
-    #define c89atomic_fetch_or_explicit_8( dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_16(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_32(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_or_explicit_64(dst, src, order)         __atomic_fetch_or(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_8( dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_16(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_32(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_xor_explicit_64(dst, src, order)        __atomic_fetch_xor(dst, src, order)
-    #define c89atomic_fetch_and_explicit_8( dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_16(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_32(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_fetch_and_explicit_64(dst, src, order)        __atomic_fetch_and(dst, src, order)
-    #define c89atomic_compare_and_swap_8 (dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_16(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_32(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #define c89atomic_compare_and_swap_64(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    typedef c89atomic_uint8 c89atomic_flag;
-    #define c89atomic_flag_test_and_set_explicit(dst, order)        (c89atomic_bool)__atomic_test_and_set(dst, order)
-    #define c89atomic_flag_clear_explicit(dst, order)               __atomic_clear(dst, order)
-    #define c89atoimc_flag_load_explicit(ptr, order)                c89atomic_load_explicit_8(ptr, order)
-#else
-    #define c89atomic_memory_order_relaxed  1
-    #define c89atomic_memory_order_consume  2
-    #define c89atomic_memory_order_acquire  3
-    #define c89atomic_memory_order_release  4
-    #define c89atomic_memory_order_acq_rel  5
-    #define c89atomic_memory_order_seq_cst  6
-    #define c89atomic_compiler_fence() __asm__ __volatile__("":::"memory")
-    #if defined(__GNUC__)
-        #define c89atomic_thread_fence(order) __sync_synchronize(), (void)order
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            if (order > c89atomic_memory_order_acquire) {
-                __sync_synchronize();
-            }
-            return __sync_lock_test_and_set(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            do {
-                oldValue = *dst;
-            } while (__sync_val_compare_and_swap(dst, oldValue, src) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_add(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_sub(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_or(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_xor(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            (void)order;
-            return __sync_fetch_and_and(dst, src);
-        }
-        #define c89atomic_compare_and_swap_8( dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_16(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_32(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-        #define c89atomic_compare_and_swap_64(dst, expected, desired)   __sync_val_compare_and_swap(dst, expected, desired)
-    #else
-        #if defined(C89ATOMIC_X86)
-            #define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addl $0, (%%esp)" ::: "memory", "cc")
-        #elif defined(C89ATOMIC_X64)
-            #define c89atomic_thread_fence(order) __asm__ __volatile__("lock; addq $0, (%%rsp)" ::: "memory", "cc")
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_compare_and_swap_8(volatile c89atomic_uint8* dst, c89atomic_uint8 expected, c89atomic_uint8 desired)
-        {
-            c89atomic_uint8 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_compare_and_swap_16(volatile c89atomic_uint16* dst, c89atomic_uint16 expected, c89atomic_uint16 desired)
-        {
-            c89atomic_uint16 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_compare_and_swap_32(volatile c89atomic_uint32* dst, c89atomic_uint32 expected, c89atomic_uint32 desired)
-        {
-            c89atomic_uint32 result;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_compare_and_swap_64(volatile c89atomic_uint64* dst, c89atomic_uint64 expected, c89atomic_uint64 desired)
-        {
-            volatile c89atomic_uint64 result;
-        #if defined(C89ATOMIC_X86)
-            c89atomic_uint32 resultEAX;
-            c89atomic_uint32 resultEDX;
-            __asm__ __volatile__("push %%ebx; xchg %5, %%ebx; lock; cmpxchg8b %0; pop %%ebx" : "+m"(*dst), "=a"(resultEAX), "=d"(resultEDX) : "a"(expected & 0xFFFFFFFF), "d"(expected >> 32), "r"(desired & 0xFFFFFFFF), "c"(desired >> 32) : "cc");
-            result = ((c89atomic_uint64)resultEDX << 32) | resultEAX;
-        #elif defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; cmpxchg %3, %0" : "+m"(*dst), "=a"(result) : "a"(expected), "d"(desired) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_exchange_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 result = 0;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_exchange_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 result = 0;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_exchange_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_exchange_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86)
-            do {
-                result = *dst;
-            } while (c89atomic_compare_and_swap_64(dst, result, src) != result);
-        #elif defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xchg %1, %0" : "+m"(*dst), "=a"(result) : "a"(src));
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_add_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_add_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_add_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 result;
-            (void)order;
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-        #else
-            #error Unsupported architecture. Please submit a feature request.
-        #endif
-            return result;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_add_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-        #if defined(C89ATOMIC_X86)
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            (void)order;
-            do {
-                oldValue = *dst;
-                newValue = oldValue + src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            return oldValue;
-        #elif defined(C89ATOMIC_X64)
-            c89atomic_uint64 result;
-            (void)order;
-            __asm__ __volatile__("lock; xadd %1, %0" : "+m"(*dst), "=a"(result) : "a"(src) : "cc");
-            return result;
-        #endif
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_sub_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue - src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_sub_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue - src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_sub_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_sub_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue - src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_and_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue & src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_and_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue & src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_and_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_and_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue & src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_xor_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_xor_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue ^ src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_xor_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_xor_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue ^ src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_fetch_or_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint8 oldValue;
-            c89atomic_uint8 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint8)(oldValue | src);
-            } while (c89atomic_compare_and_swap_8(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_fetch_or_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint16 oldValue;
-            c89atomic_uint16 newValue;
-            do {
-                oldValue = *dst;
-                newValue = (c89atomic_uint16)(oldValue | src);
-            } while (c89atomic_compare_and_swap_16(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_fetch_or_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint32 oldValue;
-            c89atomic_uint32 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_32(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-        static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_fetch_or_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64 src, c89atomic_memory_order order)
-        {
-            c89atomic_uint64 oldValue;
-            c89atomic_uint64 newValue;
-            do {
-                oldValue = *dst;
-                newValue = oldValue | src;
-            } while (c89atomic_compare_and_swap_64(dst, oldValue, newValue) != oldValue);
-            (void)order;
-            return oldValue;
-        }
-    #endif
-    #define c89atomic_signal_fence(order)                           c89atomic_thread_fence(order)
-    static C89ATOMIC_INLINE c89atomic_uint8 c89atomic_load_explicit_8(volatile const c89atomic_uint8* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_8((c89atomic_uint8*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint16 c89atomic_load_explicit_16(volatile const c89atomic_uint16* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_16((c89atomic_uint16*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint32 c89atomic_load_explicit_32(volatile const c89atomic_uint32* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_32((c89atomic_uint32*)ptr, 0, 0);
-    }
-    static C89ATOMIC_INLINE c89atomic_uint64 c89atomic_load_explicit_64(volatile const c89atomic_uint64* ptr, c89atomic_memory_order order)
-    {
-        (void)order;
-        return c89atomic_compare_and_swap_64((c89atomic_uint64*)ptr, 0, 0);
-    }
-    #define c89atomic_store_explicit_8( dst, src, order)            (void)c89atomic_exchange_explicit_8 (dst, src, order)
-    #define c89atomic_store_explicit_16(dst, src, order)            (void)c89atomic_exchange_explicit_16(dst, src, order)
-    #define c89atomic_store_explicit_32(dst, src, order)            (void)c89atomic_exchange_explicit_32(dst, src, order)
-    #define c89atomic_store_explicit_64(dst, src, order)            (void)c89atomic_exchange_explicit_64(dst, src, order)
-    #define c89atomic_test_and_set_explicit_8( dst, order)          c89atomic_exchange_explicit_8 (dst, 1, order)
-    #define c89atomic_test_and_set_explicit_16(dst, order)          c89atomic_exchange_explicit_16(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_32(dst, order)          c89atomic_exchange_explicit_32(dst, 1, order)
-    #define c89atomic_test_and_set_explicit_64(dst, order)          c89atomic_exchange_explicit_64(dst, 1, order)
-    #define c89atomic_clear_explicit_8( dst, order)                 c89atomic_store_explicit_8 (dst, 0, order)
-    #define c89atomic_clear_explicit_16(dst, order)                 c89atomic_store_explicit_16(dst, 0, order)
-    #define c89atomic_clear_explicit_32(dst, order)                 c89atomic_store_explicit_32(dst, 0, order)
-    #define c89atomic_clear_explicit_64(dst, order)                 c89atomic_store_explicit_64(dst, 0, order)
-    typedef c89atomic_uint8 c89atomic_flag;
-    #define c89atomic_flag_test_and_set_explicit(ptr, order)        (c89atomic_bool)c89atomic_test_and_set_explicit_8(ptr, order)
-    #define c89atomic_flag_clear_explicit(ptr, order)               c89atomic_clear_explicit_8(ptr, order)
-    #define c89atoimc_flag_load_explicit(ptr, order)                c89atomic_load_explicit_8(ptr, order)
-#endif
-#if !defined(C89ATOMIC_HAS_NATIVE_COMPARE_EXCHANGE)
-    #if defined(C89ATOMIC_HAS_8)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_8(volatile c89atomic_uint8* dst, c89atomic_uint8* expected, c89atomic_uint8 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint8 expectedValue;
-            c89atomic_uint8 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_8(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_8(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_8(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_16)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_16(volatile c89atomic_uint16* dst, c89atomic_uint16* expected, c89atomic_uint16 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint16 expectedValue;
-            c89atomic_uint16 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_16(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_16(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_16(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_32)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_32(volatile c89atomic_uint32* dst, c89atomic_uint32* expected, c89atomic_uint32 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint32 expectedValue;
-            c89atomic_uint32 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_32(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_32(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_32(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #if defined(C89ATOMIC_HAS_64)
-        c89atomic_bool c89atomic_compare_exchange_strong_explicit_64(volatile c89atomic_uint64* dst, c89atomic_uint64* expected, c89atomic_uint64 desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-        {
-            c89atomic_uint64 expectedValue;
-            c89atomic_uint64 result;
-            (void)successOrder;
-            (void)failureOrder;
-            expectedValue = c89atomic_load_explicit_64(expected, c89atomic_memory_order_seq_cst);
-            result = c89atomic_compare_and_swap_64(dst, expectedValue, desired);
-            if (result == expectedValue) {
-                return 1;
-            } else {
-                c89atomic_store_explicit_64(expected, result, failureOrder);
-                return 0;
-            }
-        }
-    #endif
-    #define c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_8 (dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, successOrder, failureOrder)
-    #define c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, successOrder, failureOrder) c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, successOrder, failureOrder)
-#endif
-#if !defined(C89ATOMIC_HAS_NATIVE_IS_LOCK_FREE)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_8(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_16(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_32(volatile void* ptr)
-    {
-        (void)ptr;
-        return 1;
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_64(volatile void* ptr)
-    {
-        (void)ptr;
-    #if defined(C89ATOMIC_64BIT)
-        return 1;
-    #else
-        #if defined(C89ATOMIC_X86) || defined(C89ATOMIC_X64)
-            return 1;
-        #else
-            return 0;
-        #endif
-    #endif
-    }
-#endif
-#if defined(C89ATOMIC_64BIT)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_ptr(volatile void** ptr)
-    {
-        return c89atomic_is_lock_free_64((volatile c89atomic_uint64*)ptr);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_load_explicit_ptr(volatile void** ptr, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_load_explicit_64((volatile c89atomic_uint64*)ptr, order);
-    }
-    static C89ATOMIC_INLINE void c89atomic_store_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        c89atomic_store_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)src, order);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_exchange_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_exchange_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)src, order);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_strong_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, volatile void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_weak_explicit_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired)
-    {
-        return (void*)c89atomic_compare_and_swap_64((volatile c89atomic_uint64*)dst, (c89atomic_uint64)expected, (c89atomic_uint64)desired);
-    }
-#elif defined(C89ATOMIC_32BIT)
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_is_lock_free_ptr(volatile void** ptr)
-    {
-        return c89atomic_is_lock_free_32((volatile c89atomic_uint32*)ptr);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_load_explicit_ptr(volatile void** ptr, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_load_explicit_32((volatile c89atomic_uint32*)ptr, order);
-    }
-    static C89ATOMIC_INLINE void c89atomic_store_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        c89atomic_store_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)src, order);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_exchange_explicit_ptr(volatile void** dst, void* src, c89atomic_memory_order order)
-    {
-        return (void*)c89atomic_exchange_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)src, order);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_strong_explicit_ptr(volatile void** dst, void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_strong_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE c89atomic_bool c89atomic_compare_exchange_weak_explicit_ptr(volatile void** dst, volatile void** expected, void* desired, c89atomic_memory_order successOrder, c89atomic_memory_order failureOrder)
-    {
-        return c89atomic_compare_exchange_weak_explicit_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder);
-    }
-    static C89ATOMIC_INLINE void* c89atomic_compare_and_swap_ptr(volatile void** dst, void* expected, void* desired)
-    {
-        return (void*)c89atomic_compare_and_swap_32((volatile c89atomic_uint32*)dst, (c89atomic_uint32)expected, (c89atomic_uint32)desired);
-    }
-#else
-    #error Unsupported architecture.
-#endif
-#define c89atomic_flag_test_and_set(ptr)                                c89atomic_flag_test_and_set_explicit(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_flag_clear(ptr)                                       c89atomic_flag_clear_explicit(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_ptr(dst, src)                                   c89atomic_store_explicit_ptr((volatile void**)dst, (void*)src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_ptr(ptr)                                         c89atomic_load_explicit_ptr((volatile void**)ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_ptr(dst, src)                                c89atomic_exchange_explicit_ptr((volatile void**)dst, (void*)src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_ptr(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_ptr((volatile void**)dst, (void*)expected, (void*)desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_ptr(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_ptr((volatile void**)dst, (void*)expected, (void*)desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_8( ptr)                                  c89atomic_test_and_set_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_16(ptr)                                  c89atomic_test_and_set_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_32(ptr)                                  c89atomic_test_and_set_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_64(ptr)                                  c89atomic_test_and_set_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_8( ptr)                                         c89atomic_clear_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_16(ptr)                                         c89atomic_clear_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_32(ptr)                                         c89atomic_clear_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_64(ptr)                                         c89atomic_clear_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_8( dst, src)                                    c89atomic_store_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_16(dst, src)                                    c89atomic_store_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_32(dst, src)                                    c89atomic_store_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_64(dst, src)                                    c89atomic_store_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_8( ptr)                                          c89atomic_load_explicit_8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_16(ptr)                                          c89atomic_load_explicit_16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_32(ptr)                                          c89atomic_load_explicit_32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_64(ptr)                                          c89atomic_load_explicit_64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_8( dst, src)                                 c89atomic_exchange_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_16(dst, src)                                 c89atomic_exchange_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_32(dst, src)                                 c89atomic_exchange_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_64(dst, src)                                 c89atomic_exchange_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_8( dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_16(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_32(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_64(dst, expected, desired)    c89atomic_compare_exchange_strong_explicit_64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_8(  dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_16( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_32( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_64( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_8( dst, src)                                c89atomic_fetch_add_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_16(dst, src)                                c89atomic_fetch_add_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_32(dst, src)                                c89atomic_fetch_add_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_64(dst, src)                                c89atomic_fetch_add_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_8( dst, src)                                c89atomic_fetch_sub_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_16(dst, src)                                c89atomic_fetch_sub_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_32(dst, src)                                c89atomic_fetch_sub_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_64(dst, src)                                c89atomic_fetch_sub_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_8( dst, src)                                 c89atomic_fetch_or_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_16(dst, src)                                 c89atomic_fetch_or_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_32(dst, src)                                 c89atomic_fetch_or_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_64(dst, src)                                 c89atomic_fetch_or_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_8( dst, src)                                c89atomic_fetch_xor_explicit_8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_16(dst, src)                                c89atomic_fetch_xor_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_32(dst, src)                                c89atomic_fetch_xor_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_64(dst, src)                                c89atomic_fetch_xor_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_8( dst, src)                                c89atomic_fetch_and_explicit_8 (dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_16(dst, src)                                c89atomic_fetch_and_explicit_16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_32(dst, src)                                c89atomic_fetch_and_explicit_32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_64(dst, src)                                c89atomic_fetch_and_explicit_64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_explicit_i8( ptr, order)                 (c89atomic_int8 )c89atomic_test_and_set_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_test_and_set_explicit_i16(ptr, order)                 (c89atomic_int16)c89atomic_test_and_set_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_test_and_set_explicit_i32(ptr, order)                 (c89atomic_int32)c89atomic_test_and_set_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_test_and_set_explicit_i64(ptr, order)                 (c89atomic_int64)c89atomic_test_and_set_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_clear_explicit_i8( ptr, order)                        c89atomic_clear_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_clear_explicit_i16(ptr, order)                        c89atomic_clear_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_clear_explicit_i32(ptr, order)                        c89atomic_clear_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_clear_explicit_i64(ptr, order)                        c89atomic_clear_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_store_explicit_i8( dst, src, order)                   (c89atomic_int8 )c89atomic_store_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_store_explicit_i16(dst, src, order)                   (c89atomic_int16)c89atomic_store_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_store_explicit_i32(dst, src, order)                   (c89atomic_int32)c89atomic_store_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_store_explicit_i64(dst, src, order)                   (c89atomic_int64)c89atomic_store_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_load_explicit_i8( ptr, order)                         (c89atomic_int8 )c89atomic_load_explicit_8( (c89atomic_uint8* )ptr, order)
-#define c89atomic_load_explicit_i16(ptr, order)                         (c89atomic_int16)c89atomic_load_explicit_16((c89atomic_uint16*)ptr, order)
-#define c89atomic_load_explicit_i32(ptr, order)                         (c89atomic_int32)c89atomic_load_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_load_explicit_i64(ptr, order)                         (c89atomic_int64)c89atomic_load_explicit_64((c89atomic_uint64*)ptr, order)
-#define c89atomic_exchange_explicit_i8( dst, src, order)                (c89atomic_int8 )c89atomic_exchange_explicit_8 ((c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_exchange_explicit_i16(dst, src, order)                (c89atomic_int16)c89atomic_exchange_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_exchange_explicit_i32(dst, src, order)                (c89atomic_int32)c89atomic_exchange_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_exchange_explicit_i64(dst, src, order)                (c89atomic_int64)c89atomic_exchange_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8* )expected, (c89atomic_uint8 )desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16*)expected, (c89atomic_uint16)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, successOrder, failureOrder)  c89atomic_compare_exchange_strong_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8* )expected, (c89atomic_uint8 )desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16*)expected, (c89atomic_uint16)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32*)expected, (c89atomic_uint32)desired, successOrder, failureOrder)
-#define c89atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, successOrder, failureOrder)    c89atomic_compare_exchange_weak_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64*)expected, (c89atomic_uint64)desired, successOrder, failureOrder)
-#define c89atomic_fetch_add_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_add_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_add_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_add_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_add_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_add_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_add_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_add_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_sub_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_sub_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_sub_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_sub_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_sub_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_sub_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_sub_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_sub_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_or_explicit_i8( dst, src, order)                (c89atomic_int8 )c89atomic_fetch_or_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_or_explicit_i16(dst, src, order)                (c89atomic_int16)c89atomic_fetch_or_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_or_explicit_i32(dst, src, order)                (c89atomic_int32)c89atomic_fetch_or_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_or_explicit_i64(dst, src, order)                (c89atomic_int64)c89atomic_fetch_or_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_xor_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_xor_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_xor_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_xor_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_xor_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_xor_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_xor_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_xor_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_fetch_and_explicit_i8( dst, src, order)               (c89atomic_int8 )c89atomic_fetch_and_explicit_8( (c89atomic_uint8* )dst, (c89atomic_uint8 )src, order)
-#define c89atomic_fetch_and_explicit_i16(dst, src, order)               (c89atomic_int16)c89atomic_fetch_and_explicit_16((c89atomic_uint16*)dst, (c89atomic_uint16)src, order)
-#define c89atomic_fetch_and_explicit_i32(dst, src, order)               (c89atomic_int32)c89atomic_fetch_and_explicit_32((c89atomic_uint32*)dst, (c89atomic_uint32)src, order)
-#define c89atomic_fetch_and_explicit_i64(dst, src, order)               (c89atomic_int64)c89atomic_fetch_and_explicit_64((c89atomic_uint64*)dst, (c89atomic_uint64)src, order)
-#define c89atomic_test_and_set_i8( ptr)                                 c89atomic_test_and_set_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i16(ptr)                                 c89atomic_test_and_set_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i32(ptr)                                 c89atomic_test_and_set_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_test_and_set_i64(ptr)                                 c89atomic_test_and_set_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i8( ptr)                                        c89atomic_clear_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i16(ptr)                                        c89atomic_clear_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i32(ptr)                                        c89atomic_clear_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_i64(ptr)                                        c89atomic_clear_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i8( dst, src)                                   c89atomic_store_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i16(dst, src)                                   c89atomic_store_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i32(dst, src)                                   c89atomic_store_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_i64(dst, src)                                   c89atomic_store_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i8( ptr)                                         c89atomic_load_explicit_i8( ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i16(ptr)                                         c89atomic_load_explicit_i16(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i32(ptr)                                         c89atomic_load_explicit_i32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_i64(ptr)                                         c89atomic_load_explicit_i64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i8( dst, src)                                c89atomic_exchange_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i16(dst, src)                                c89atomic_exchange_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i32(dst, src)                                c89atomic_exchange_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_i64(dst, src)                                c89atomic_exchange_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i8( dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i16(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i32(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_strong_i64(dst, expected, desired)   c89atomic_compare_exchange_strong_explicit_i64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i8( dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i8( dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i16(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i16(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i32(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i32(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_compare_exchange_weak_i64(dst, expected, desired)     c89atomic_compare_exchange_weak_explicit_i64(dst, expected, desired, c89atomic_memory_order_seq_cst, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i8( dst, src)                               c89atomic_fetch_add_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i16(dst, src)                               c89atomic_fetch_add_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i32(dst, src)                               c89atomic_fetch_add_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_add_i64(dst, src)                               c89atomic_fetch_add_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i8( dst, src)                               c89atomic_fetch_sub_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i16(dst, src)                               c89atomic_fetch_sub_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i32(dst, src)                               c89atomic_fetch_sub_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_sub_i64(dst, src)                               c89atomic_fetch_sub_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i8( dst, src)                                c89atomic_fetch_or_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i16(dst, src)                                c89atomic_fetch_or_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i32(dst, src)                                c89atomic_fetch_or_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_or_i64(dst, src)                                c89atomic_fetch_or_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i8( dst, src)                               c89atomic_fetch_xor_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i16(dst, src)                               c89atomic_fetch_xor_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i32(dst, src)                               c89atomic_fetch_xor_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_xor_i64(dst, src)                               c89atomic_fetch_xor_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i8( dst, src)                               c89atomic_fetch_and_explicit_i8( dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i16(dst, src)                               c89atomic_fetch_and_explicit_i16(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i32(dst, src)                               c89atomic_fetch_and_explicit_i32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_fetch_and_i64(dst, src)                               c89atomic_fetch_and_explicit_i64(dst, src, c89atomic_memory_order_seq_cst)
-typedef union
-{
-    c89atomic_uint32 i;
-    float f;
-} c89atomic_if32;
-typedef union
-{
-    c89atomic_uint64 i;
-    double f;
-} c89atomic_if64;
-#define c89atomic_clear_explicit_f32(ptr, order)                        c89atomic_clear_explicit_32((c89atomic_uint32*)ptr, order)
-#define c89atomic_clear_explicit_f64(ptr, order)                        c89atomic_clear_explicit_64((c89atomic_uint64*)ptr, order)
-static C89ATOMIC_INLINE void c89atomic_store_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if32 x;
-    x.f = src;
-    c89atomic_store_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
-}
-static C89ATOMIC_INLINE void c89atomic_store_explicit_f64(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if64 x;
-    x.f = src;
-    c89atomic_store_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
-}
-static C89ATOMIC_INLINE float c89atomic_load_explicit_f32(volatile float* ptr, c89atomic_memory_order order)
-{
-    c89atomic_if32 r;
-    r.i = c89atomic_load_explicit_32((volatile c89atomic_uint32*)ptr, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE double c89atomic_load_explicit_f64(volatile double* ptr, c89atomic_memory_order order)
-{
-    c89atomic_if64 r;
-    r.i = c89atomic_load_explicit_64((volatile c89atomic_uint64*)ptr, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE float c89atomic_exchange_explicit_f32(volatile float* dst, float src, c89atomic_memory_order order)
-{
-    c89atomic_if32 r;
-    c89atomic_if32 x;
-    x.f = src;
-    r.i = c89atomic_exchange_explicit_32((volatile c89atomic_uint32*)dst, x.i, order);
-    return r.f;
-}
-static C89ATOMIC_INLINE double c89atomic_exchange_explicit_f64(volatile double* dst, double src, c89atomic_memory_order order)
-{
-    c89atomic_if64 r;
-    c89atomic_if64 x;
-    x.f = src;
-    r.i = c89atomic_exchange_explicit_64((volatile c89atomic_uint64*)dst, x.i, order);
-    return r.f;
-}
-#define c89atomic_clear_f32(ptr)                                        (float )c89atomic_clear_explicit_f32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_clear_f64(ptr)                                        (double)c89atomic_clear_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_f32(dst, src)                                   c89atomic_store_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_store_f64(dst, src)                                   c89atomic_store_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_f32(ptr)                                         (float )c89atomic_load_explicit_f32(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_load_f64(ptr)                                         (double)c89atomic_load_explicit_f64(ptr, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_f32(dst, src)                                (float )c89atomic_exchange_explicit_f32(dst, src, c89atomic_memory_order_seq_cst)
-#define c89atomic_exchange_f64(dst, src)                                (double)c89atomic_exchange_explicit_f64(dst, src, c89atomic_memory_order_seq_cst)
-typedef c89atomic_flag c89atomic_spinlock;
-static C89ATOMIC_INLINE void c89atomic_spinlock_lock(volatile c89atomic_spinlock* pSpinlock)
-{
-    for (;;) {
-        if (c89atomic_flag_test_and_set_explicit(pSpinlock, c89atomic_memory_order_acquire) == 0) {
-            break;
-        }
-        while (c89atoimc_flag_load_explicit(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
-        }
-    }
-}
-static C89ATOMIC_INLINE void c89atomic_spinlock_unlock(volatile c89atomic_spinlock* pSpinlock)
-{
-    c89atomic_flag_clear_explicit(pSpinlock, c89atomic_memory_order_release);
-}
-#if defined(__cplusplus)
-}
-#endif
-#endif
-/* c89atomic.h end */
-
-
-
-static void* ma__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return MA_MALLOC(sz);
-}
-
-static void* ma__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return MA_REALLOC(p, sz);
-}
-
-static void ma__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    MA_FREE(p);
-}
-
-
-static void* ma__malloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try using realloc(). */
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-
-    return NULL;
-}
-
-static void* ma__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-
-    /* Try emulating realloc() in terms of malloc()/free(). */
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-
-        if (p != NULL) {
-            MA_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-
-        return p2;
-    }
-
-    return NULL;
-}
-
-static MA_INLINE void* ma__calloc_from_callbacks(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    void* p = ma__malloc_from_callbacks(sz, pAllocationCallbacks);
-    if (p != NULL) {
-        MA_ZERO_MEMORY(p, sz);
-    }
-
-    return p;
-}
-
-static void ma__free_from_callbacks(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-
-static ma_allocation_callbacks ma_allocation_callbacks_init_default(void)
-{
-    ma_allocation_callbacks callbacks;
-    callbacks.pUserData = NULL;
-    callbacks.onMalloc  = ma__malloc_default;
-    callbacks.onRealloc = ma__realloc_default;
-    callbacks.onFree    = ma__free_default;
-
-    return callbacks;
-}
-
-static ma_result ma_allocation_callbacks_init_copy(ma_allocation_callbacks* pDst, const ma_allocation_callbacks* pSrc)
-{
-    if (pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pSrc == NULL) {
-        *pDst = ma_allocation_callbacks_init_default();
-    } else {
-        if (pSrc->pUserData == NULL && pSrc->onFree == NULL && pSrc->onMalloc == NULL && pSrc->onRealloc == NULL) {
-            *pDst = ma_allocation_callbacks_init_default();
-        } else {
-            if (pSrc->onFree == NULL || (pSrc->onMalloc == NULL && pSrc->onRealloc == NULL)) {
-                return MA_INVALID_ARGS;    /* Invalid allocation callbacks. */
-            } else {
-                *pDst = *pSrc;
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_uint64 ma_calculate_frame_count_after_resampling(ma_uint32 sampleRateOut, ma_uint32 sampleRateIn, ma_uint64 frameCountIn)
-{
-    /* For robustness we're going to use a resampler object to calculate this since that already has a way of calculating this. */
-    ma_result result;
-    ma_uint64 frameCountOut;
-    ma_resampler_config config;
-    ma_resampler resampler;
-
-    if (sampleRateOut == sampleRateIn) {
-        return frameCountIn;
-    }
-
-    config = ma_resampler_config_init(ma_format_s16, 1, sampleRateIn, sampleRateOut, ma_resample_algorithm_linear);
-    result = ma_resampler_init(&config, &resampler);
-    if (result != MA_SUCCESS) {
-        return 0;
-    }
-
-    frameCountOut = ma_resampler_get_expected_output_frame_count(&resampler, frameCountIn);
-
-    ma_resampler_uninit(&resampler);
-    return frameCountOut;
-}
-
-#ifndef MA_DATA_CONVERTER_STACK_BUFFER_SIZE
-#define MA_DATA_CONVERTER_STACK_BUFFER_SIZE     4096
-#endif
-
-
-
-#if defined(MA_WIN32)
-static ma_result ma_result_from_GetLastError(DWORD error)
-{
-    switch (error)
-    {
-        case ERROR_SUCCESS:             return MA_SUCCESS;
-        case ERROR_PATH_NOT_FOUND:      return MA_DOES_NOT_EXIST;
-        case ERROR_TOO_MANY_OPEN_FILES: return MA_TOO_MANY_OPEN_FILES;
-        case ERROR_NOT_ENOUGH_MEMORY:   return MA_OUT_OF_MEMORY;
-        case ERROR_DISK_FULL:           return MA_NO_SPACE;
-        case ERROR_HANDLE_EOF:          return MA_END_OF_FILE;
-        case ERROR_NEGATIVE_SEEK:       return MA_BAD_SEEK;
-        case ERROR_INVALID_PARAMETER:   return MA_INVALID_ARGS;
-        case ERROR_ACCESS_DENIED:       return MA_ACCESS_DENIED;
-        case ERROR_SEM_TIMEOUT:         return MA_TIMEOUT;
-        case ERROR_FILE_NOT_FOUND:      return MA_DOES_NOT_EXIST;
-        default: break;
-    }
-
-    return MA_ERROR;
-}
-#endif  /* MA_WIN32 */
-
-
-/*******************************************************************************
-
-Threading
-
-*******************************************************************************/
-#ifndef MA_NO_THREADING
-#ifdef MA_WIN32
-    #define MA_THREADCALL WINAPI
-    typedef unsigned long ma_thread_result;
-#else
-    #define MA_THREADCALL
-    typedef void* ma_thread_result;
-#endif
-typedef ma_thread_result (MA_THREADCALL * ma_thread_entry_proc)(void* pData);
-
-static MA_INLINE ma_result ma_spinlock_lock_ex(volatile ma_spinlock* pSpinlock, ma_bool32 yield)
-{
-    if (pSpinlock == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    for (;;) {
-        if (c89atomic_exchange_explicit_32(pSpinlock, 1, c89atomic_memory_order_acquire) == 0) {
-            break;
-        }
-
-        while (c89atomic_load_explicit_32(pSpinlock, c89atomic_memory_order_relaxed) == 1) {
-            if (yield) {
-                ma_yield();
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_spinlock_lock(volatile ma_spinlock* pSpinlock)
-{
-    return ma_spinlock_lock_ex(pSpinlock, MA_TRUE);
-}
-
-MA_API ma_result ma_spinlock_lock_noyield(volatile ma_spinlock* pSpinlock)
-{
-    return ma_spinlock_lock_ex(pSpinlock, MA_FALSE);
-}
-
-MA_API ma_result ma_spinlock_unlock(volatile ma_spinlock* pSpinlock)
-{
-    if (pSpinlock == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    c89atomic_store_explicit_32(pSpinlock, 0, c89atomic_memory_order_release);
-    return MA_SUCCESS;
-}
-
-#ifdef MA_WIN32
-static int ma_thread_priority_to_win32(ma_thread_priority priority)
-{
-    switch (priority) {
-        case ma_thread_priority_idle:     return THREAD_PRIORITY_IDLE;
-        case ma_thread_priority_lowest:   return THREAD_PRIORITY_LOWEST;
-        case ma_thread_priority_low:      return THREAD_PRIORITY_BELOW_NORMAL;
-        case ma_thread_priority_normal:   return THREAD_PRIORITY_NORMAL;
-        case ma_thread_priority_high:     return THREAD_PRIORITY_ABOVE_NORMAL;
-        case ma_thread_priority_highest:  return THREAD_PRIORITY_HIGHEST;
-        case ma_thread_priority_realtime: return THREAD_PRIORITY_TIME_CRITICAL;
-        default:                          return THREAD_PRIORITY_NORMAL;
-    }
-}
-
-static ma_result ma_thread_create__win32(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    *pThread = CreateThread(NULL, stackSize, entryProc, pData, 0, NULL);
-    if (*pThread == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    SetThreadPriority((HANDLE)*pThread, ma_thread_priority_to_win32(priority));
-
-    return MA_SUCCESS;
-}
-
-static void ma_thread_wait__win32(ma_thread* pThread)
-{
-    WaitForSingleObject((HANDLE)*pThread, INFINITE);
-    CloseHandle((HANDLE)*pThread);
-}
-
-
-static ma_result ma_mutex_init__win32(ma_mutex* pMutex)
-{
-    *pMutex = CreateEventW(NULL, FALSE, TRUE, NULL);
-    if (*pMutex == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_mutex_uninit__win32(ma_mutex* pMutex)
-{
-    CloseHandle((HANDLE)*pMutex);
-}
-
-static void ma_mutex_lock__win32(ma_mutex* pMutex)
-{
-    WaitForSingleObject((HANDLE)*pMutex, INFINITE);
-}
-
-static void ma_mutex_unlock__win32(ma_mutex* pMutex)
-{
-    SetEvent((HANDLE)*pMutex);
-}
-
-
-static ma_result ma_event_init__win32(ma_event* pEvent)
-{
-    *pEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-    if (*pEvent == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_event_uninit__win32(ma_event* pEvent)
-{
-    CloseHandle((HANDLE)*pEvent);
-}
-
-static ma_result ma_event_wait__win32(ma_event* pEvent)
-{
-    DWORD result = WaitForSingleObject((HANDLE)*pEvent, INFINITE);
-    if (result == WAIT_OBJECT_0) {
-        return MA_SUCCESS;
-    }
-
-    if (result == WAIT_TIMEOUT) {
-        return MA_TIMEOUT;
-    }
-
-    return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_event_signal__win32(ma_event* pEvent)
-{
-    BOOL result = SetEvent((HANDLE)*pEvent);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_semaphore_init__win32(int initialValue, ma_semaphore* pSemaphore)
-{
-    *pSemaphore = CreateSemaphoreW(NULL, (LONG)initialValue, LONG_MAX, NULL);
-    if (*pSemaphore == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_semaphore_uninit__win32(ma_semaphore* pSemaphore)
-{
-    CloseHandle((HANDLE)*pSemaphore);
-}
-
-static ma_result ma_semaphore_wait__win32(ma_semaphore* pSemaphore)
-{
-    DWORD result = WaitForSingleObject((HANDLE)*pSemaphore, INFINITE);
-    if (result == WAIT_OBJECT_0) {
-        return MA_SUCCESS;
-    }
-
-    if (result == WAIT_TIMEOUT) {
-        return MA_TIMEOUT;
-    }
-
-    return ma_result_from_GetLastError(GetLastError());
-}
-
-static ma_result ma_semaphore_release__win32(ma_semaphore* pSemaphore)
-{
-    BOOL result = ReleaseSemaphore((HANDLE)*pSemaphore, 1, NULL);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-#ifdef MA_POSIX
-static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    int result;
-    pthread_attr_t* pAttr = NULL;
-
-#if !defined(__EMSCRIPTEN__)
-    /* Try setting the thread priority. It's not critical if anything fails here. */
-    pthread_attr_t attr;
-    if (pthread_attr_init(&attr) == 0) {
-        int scheduler = -1;
-        if (priority == ma_thread_priority_idle) {
-#ifdef SCHED_IDLE
-            if (pthread_attr_setschedpolicy(&attr, SCHED_IDLE) == 0) {
-                scheduler = SCHED_IDLE;
-            }
-#endif
-        } else if (priority == ma_thread_priority_realtime) {
-#ifdef SCHED_FIFO
-            if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO) == 0) {
-                scheduler = SCHED_FIFO;
-            }
-#endif
-#ifdef MA_LINUX
-        } else {
-            scheduler = sched_getscheduler(0);
-#endif
-        }
-
-        if (stackSize > 0) {
-            pthread_attr_setstacksize(&attr, stackSize);
-        }
-
-        if (scheduler != -1) {
-            int priorityMin = sched_get_priority_min(scheduler);
-            int priorityMax = sched_get_priority_max(scheduler);
-            int priorityStep = (priorityMax - priorityMin) / 7;  /* 7 = number of priorities supported by miniaudio. */
-
-            struct sched_param sched;
-            if (pthread_attr_getschedparam(&attr, &sched) == 0) {
-                if (priority == ma_thread_priority_idle) {
-                    sched.sched_priority = priorityMin;
-                } else if (priority == ma_thread_priority_realtime) {
-                    sched.sched_priority = priorityMax;
-                } else {
-                    sched.sched_priority += ((int)priority + 5) * priorityStep;  /* +5 because the lowest priority is -5. */
-                    if (sched.sched_priority < priorityMin) {
-                        sched.sched_priority = priorityMin;
-                    }
-                    if (sched.sched_priority > priorityMax) {
-                        sched.sched_priority = priorityMax;
-                    }
-                }
-
-                if (pthread_attr_setschedparam(&attr, &sched) == 0) {
-                    pAttr = &attr;
-                }
-            }
-        }
-    }
-#else
-    /* It's the emscripten build. We'll have a few unused parameters. */
-    (void)priority;
-    (void)stackSize;
-#endif
-
-    result = pthread_create(pThread, pAttr, entryProc, pData);
-
-    /* The thread attributes object is no longer required. */
-    if (pAttr != NULL) {
-        pthread_attr_destroy(pAttr);
-    }
-
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_thread_wait__posix(ma_thread* pThread)
-{
-    pthread_join(*pThread, NULL);
-    pthread_detach(*pThread);
-}
-
-
-static ma_result ma_mutex_init__posix(ma_mutex* pMutex)
-{
-    int result = pthread_mutex_init((pthread_mutex_t*)pMutex, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_mutex_uninit__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_destroy((pthread_mutex_t*)pMutex);
-}
-
-static void ma_mutex_lock__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_lock((pthread_mutex_t*)pMutex);
-}
-
-static void ma_mutex_unlock__posix(ma_mutex* pMutex)
-{
-    pthread_mutex_unlock((pthread_mutex_t*)pMutex);
-}
-
-
-static ma_result ma_event_init__posix(ma_event* pEvent)
-{
-    int result;
-
-    result = pthread_mutex_init(&pEvent->lock, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);
-    }
-
-    result = pthread_cond_init(&pEvent->cond, NULL);
-    if (result != 0) {
-        pthread_mutex_destroy(&pEvent->lock);
-        return ma_result_from_errno(result);
-    }
-
-    pEvent->value = 0;
-    return MA_SUCCESS;
-}
-
-static void ma_event_uninit__posix(ma_event* pEvent)
-{
-    pthread_cond_destroy(&pEvent->cond);
-    pthread_mutex_destroy(&pEvent->lock);
-}
-
-static ma_result ma_event_wait__posix(ma_event* pEvent)
-{
-    pthread_mutex_lock(&pEvent->lock);
-    {
-        while (pEvent->value == 0) {
-            pthread_cond_wait(&pEvent->cond, &pEvent->lock);
-        }
-        pEvent->value = 0;  /* Auto-reset. */
-    }
-    pthread_mutex_unlock(&pEvent->lock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_event_signal__posix(ma_event* pEvent)
-{
-    pthread_mutex_lock(&pEvent->lock);
-    {
-        pEvent->value = 1;
-        pthread_cond_signal(&pEvent->cond);
-    }
-    pthread_mutex_unlock(&pEvent->lock);
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_semaphore_init__posix(int initialValue, ma_semaphore* pSemaphore)
-{
-    int result;
-
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pSemaphore->value = initialValue;
-
-    result = pthread_mutex_init(&pSemaphore->lock, NULL);
-    if (result != 0) {
-        return ma_result_from_errno(result);  /* Failed to create mutex. */
-    }
-
-    result = pthread_cond_init(&pSemaphore->cond, NULL);
-    if (result != 0) {
-        pthread_mutex_destroy(&pSemaphore->lock);
-        return ma_result_from_errno(result);  /* Failed to create condition variable. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_semaphore_uninit__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return;
-    }
-
-    pthread_cond_destroy(&pSemaphore->cond);
-    pthread_mutex_destroy(&pSemaphore->lock);
-}
-
-static ma_result ma_semaphore_wait__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pthread_mutex_lock(&pSemaphore->lock);
-    {
-        /* We need to wait on a condition variable before escaping. We can't return from this function until the semaphore has been signaled. */
-        while (pSemaphore->value == 0) {
-            pthread_cond_wait(&pSemaphore->cond, &pSemaphore->lock);
-        }
-
-        pSemaphore->value -= 1;
-    }
-    pthread_mutex_unlock(&pSemaphore->lock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_semaphore_release__posix(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pthread_mutex_lock(&pSemaphore->lock);
-    {
-        pSemaphore->value += 1;
-        pthread_cond_signal(&pSemaphore->cond);
-    }
-    pthread_mutex_unlock(&pSemaphore->lock);
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_thread_create(ma_thread* pThread, ma_thread_priority priority, size_t stackSize, ma_thread_entry_proc entryProc, void* pData)
-{
-    if (pThread == NULL || entryProc == NULL) {
-        return MA_FALSE;
-    }
-
-#ifdef MA_WIN32
-    return ma_thread_create__win32(pThread, priority, stackSize, entryProc, pData);
-#endif
-#ifdef MA_POSIX
-    return ma_thread_create__posix(pThread, priority, stackSize, entryProc, pData);
-#endif
-}
-
-static void ma_thread_wait(ma_thread* pThread)
-{
-    if (pThread == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_thread_wait__win32(pThread);
-#endif
-#ifdef MA_POSIX
-    ma_thread_wait__posix(pThread);
-#endif
-}
-
-
-MA_API ma_result ma_mutex_init(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_mutex_init__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    return ma_mutex_init__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_uninit(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_mutex_uninit__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_uninit__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_lock(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_mutex_lock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_lock__posix(pMutex);
-#endif
-}
-
-MA_API void ma_mutex_unlock(ma_mutex* pMutex)
-{
-    if (pMutex == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return;
-}
-
-#ifdef MA_WIN32
-    ma_mutex_unlock__win32(pMutex);
-#endif
-#ifdef MA_POSIX
-    ma_mutex_unlock__posix(pMutex);
-#endif
-}
-
-
-MA_API ma_result ma_event_init(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_init__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_init__posix(pEvent);
-#endif
-}
-
-#if 0
-static ma_result ma_event_alloc_and_init(ma_event** ppEvent, ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_result result;
-    ma_event* pEvent;
-
-    if (ppEvent == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *ppEvent = NULL;
-
-    pEvent = ma_malloc(sizeof(*pEvent), pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-    if (pEvent == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    result = ma_event_init(pEvent);
-    if (result != MA_SUCCESS) {
-        ma_free(pEvent, pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-        return result;
-    }
-
-    *ppEvent = pEvent;
-    return result;
-}
-#endif
-
-MA_API void ma_event_uninit(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_event_uninit__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    ma_event_uninit__posix(pEvent);
-#endif
-}
-
-#if 0
-static void ma_event_uninit_and_free(ma_event* pEvent, ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pEvent == NULL) {
-        return;
-    }
-
-    ma_event_uninit(pEvent);
-    ma_free(pEvent, pAllocationCallbacks/*, MA_ALLOCATION_TYPE_EVENT*/);
-}
-#endif
-
-MA_API ma_result ma_event_wait(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_wait__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_wait__posix(pEvent);
-#endif
-}
-
-MA_API ma_result ma_event_signal(ma_event* pEvent)
-{
-    if (pEvent == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert to the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_event_signal__win32(pEvent);
-#endif
-#ifdef MA_POSIX
-    return ma_event_signal__posix(pEvent);
-#endif
-}
-
-
-MA_API ma_result ma_semaphore_init(int initialValue, ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_init__win32(initialValue, pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_init__posix(initialValue, pSemaphore);
-#endif
-}
-
-MA_API void ma_semaphore_uninit(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return;
-    }
-
-#ifdef MA_WIN32
-    ma_semaphore_uninit__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    ma_semaphore_uninit__posix(pSemaphore);
-#endif
-}
-
-MA_API ma_result ma_semaphore_wait(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_wait__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_wait__posix(pSemaphore);
-#endif
-}
-
-MA_API ma_result ma_semaphore_release(ma_semaphore* pSemaphore)
-{
-    if (pSemaphore == NULL) {
-        MA_ASSERT(MA_FALSE);    /* Fire an assert so the caller is aware of this bug. */
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_WIN32
-    return ma_semaphore_release__win32(pSemaphore);
-#endif
-#ifdef MA_POSIX
-    return ma_semaphore_release__posix(pSemaphore);
-#endif
-}
-#else
-/* MA_NO_THREADING is set which means threading is disabled. Threading is required by some API families. If any of these are enabled we need to throw an error. */
-#ifndef MA_NO_DEVICE_IO
-#error "MA_NO_THREADING cannot be used without MA_NO_DEVICE_IO";
-#endif
-#endif  /* MA_NO_THREADING */
-
-
-
-/************************************************************************************************************************************************************
-*************************************************************************************************************************************************************
-
-DEVICE I/O
-==========
-
-*************************************************************************************************************************************************************
-************************************************************************************************************************************************************/
-#ifndef MA_NO_DEVICE_IO
-#ifdef MA_WIN32
-    #include <objbase.h>
-    #include <mmreg.h>
-    #include <mmsystem.h>
-#endif
-
-#if defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
-    #include <mach/mach_time.h> /* For mach_absolute_time() */
-#endif
-
-#ifdef MA_POSIX
-    #include <sys/types.h>
-    #include <unistd.h>
-    #include <dlfcn.h>
-#endif
-
-/*
-Unfortunately using runtime linking for pthreads causes problems. This has occurred for me when testing on FreeBSD. When
-using runtime linking, deadlocks can occur (for me it happens when loading data from fread()). It turns out that doing
-compile-time linking fixes this. I'm not sure why this happens, but the safest way I can think of to fix this is to simply
-disable runtime linking by default. To enable runtime linking, #define this before the implementation of this file. I am
-not officially supporting this, but I'm leaving it here in case it's useful for somebody, somewhere.
-*/
-/*#define MA_USE_RUNTIME_LINKING_FOR_PTHREAD*/
-
-/* Disable run-time linking on certain backends. */
-#ifndef MA_NO_RUNTIME_LINKING
-    #if defined(MA_EMSCRIPTEN)
-        #define MA_NO_RUNTIME_LINKING
-    #endif
-#endif
-
-
-MA_API void ma_device_info_add_native_data_format(ma_device_info* pDeviceInfo, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags)
-{
-    if (pDeviceInfo == NULL) {
-        return;
-    }
-
-    if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats)) {
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-        pDeviceInfo->nativeDataFormatCount += 1;
-    }
-}
-
-
-MA_API const char* ma_get_backend_name(ma_backend backend)
-{
-    switch (backend)
-    {
-        case ma_backend_wasapi:     return "WASAPI";
-        case ma_backend_dsound:     return "DirectSound";
-        case ma_backend_winmm:      return "WinMM";
-        case ma_backend_coreaudio:  return "Core Audio";
-        case ma_backend_sndio:      return "sndio";
-        case ma_backend_audio4:     return "audio(4)";
-        case ma_backend_oss:        return "OSS";
-        case ma_backend_pulseaudio: return "PulseAudio";
-        case ma_backend_alsa:       return "ALSA";
-        case ma_backend_jack:       return "JACK";
-        case ma_backend_aaudio:     return "AAudio";
-        case ma_backend_opensl:     return "OpenSL|ES";
-        case ma_backend_webaudio:   return "Web Audio";
-        case ma_backend_custom:     return "Custom";
-        case ma_backend_null:       return "Null";
-        default:                    return "Unknown";
-    }
-}
-
-MA_API ma_bool32 ma_is_backend_enabled(ma_backend backend)
-{
-    /*
-    This looks a little bit gross, but we want all backends to be included in the switch to avoid warnings on some compilers
-    about some enums not being handled by the switch statement.
-    */
-    switch (backend)
-    {
-        case ma_backend_wasapi:
-        #if defined(MA_HAS_WASAPI)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_dsound:
-        #if defined(MA_HAS_DSOUND)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_winmm:
-        #if defined(MA_HAS_WINMM)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_coreaudio:
-        #if defined(MA_HAS_COREAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_sndio:
-        #if defined(MA_HAS_SNDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_audio4:
-        #if defined(MA_HAS_AUDIO4)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_oss:
-        #if defined(MA_HAS_OSS)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_pulseaudio:
-        #if defined(MA_HAS_PULSEAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_alsa:
-        #if defined(MA_HAS_ALSA)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_jack:
-        #if defined(MA_HAS_JACK)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_aaudio:
-        #if defined(MA_HAS_AAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_opensl:
-        #if defined(MA_HAS_OPENSL)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_webaudio:
-        #if defined(MA_HAS_WEBAUDIO)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_custom:
-        #if defined(MA_HAS_CUSTOM)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-        case ma_backend_null:
-        #if defined(MA_HAS_NULL)
-            return MA_TRUE;
-        #else
-            return MA_FALSE;
-        #endif
-
-        default: return MA_FALSE;
-    }
-}
-
-MA_API ma_result ma_get_enabled_backends(ma_backend* pBackends, size_t backendCap, size_t* pBackendCount)
-{
-    size_t backendCount;
-    size_t iBackend;
-    ma_result result = MA_SUCCESS;
-
-    if (pBackendCount == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    backendCount = 0;
-
-    for (iBackend = 0; iBackend <= ma_backend_null; iBackend += 1) {
-        ma_backend backend = (ma_backend)iBackend;
-
-        if (ma_is_backend_enabled(backend)) {
-            /* The backend is enabled. Try adding it to the list. If there's no room, MA_NO_SPACE needs to be returned. */
-            if (backendCount == backendCap) {
-                result = MA_NO_SPACE;
-                break;
-            } else {
-                pBackends[backendCount] = backend;
-                backendCount += 1;
-            }
-        }
-    }
-
-    if (pBackendCount != NULL) {
-        *pBackendCount = backendCount;
-    }
-
-    return result;
-}
-
-MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend)
-{
-    switch (backend)
-    {
-        case ma_backend_wasapi:     return MA_TRUE;
-        case ma_backend_dsound:     return MA_FALSE;
-        case ma_backend_winmm:      return MA_FALSE;
-        case ma_backend_coreaudio:  return MA_FALSE;
-        case ma_backend_sndio:      return MA_FALSE;
-        case ma_backend_audio4:     return MA_FALSE;
-        case ma_backend_oss:        return MA_FALSE;
-        case ma_backend_pulseaudio: return MA_FALSE;
-        case ma_backend_alsa:       return MA_FALSE;
-        case ma_backend_jack:       return MA_FALSE;
-        case ma_backend_aaudio:     return MA_FALSE;
-        case ma_backend_opensl:     return MA_FALSE;
-        case ma_backend_webaudio:   return MA_FALSE;
-        case ma_backend_custom:     return MA_FALSE;    /* <-- Will depend on the implementation of the backend. */
-        case ma_backend_null:       return MA_FALSE;
-        default:                    return MA_FALSE;
-    }
-}
-
-
-
-#ifdef MA_WIN32
-/* WASAPI error codes. */
-#define MA_AUDCLNT_E_NOT_INITIALIZED              ((HRESULT)0x88890001)
-#define MA_AUDCLNT_E_ALREADY_INITIALIZED          ((HRESULT)0x88890002)
-#define MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE          ((HRESULT)0x88890003)
-#define MA_AUDCLNT_E_DEVICE_INVALIDATED           ((HRESULT)0x88890004)
-#define MA_AUDCLNT_E_NOT_STOPPED                  ((HRESULT)0x88890005)
-#define MA_AUDCLNT_E_BUFFER_TOO_LARGE             ((HRESULT)0x88890006)
-#define MA_AUDCLNT_E_OUT_OF_ORDER                 ((HRESULT)0x88890007)
-#define MA_AUDCLNT_E_UNSUPPORTED_FORMAT           ((HRESULT)0x88890008)
-#define MA_AUDCLNT_E_INVALID_SIZE                 ((HRESULT)0x88890009)
-#define MA_AUDCLNT_E_DEVICE_IN_USE                ((HRESULT)0x8889000A)
-#define MA_AUDCLNT_E_BUFFER_OPERATION_PENDING     ((HRESULT)0x8889000B)
-#define MA_AUDCLNT_E_THREAD_NOT_REGISTERED        ((HRESULT)0x8889000C)
-#define MA_AUDCLNT_E_NO_SINGLE_PROCESS            ((HRESULT)0x8889000D)
-#define MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED   ((HRESULT)0x8889000E)
-#define MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED       ((HRESULT)0x8889000F)
-#define MA_AUDCLNT_E_SERVICE_NOT_RUNNING          ((HRESULT)0x88890010)
-#define MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED     ((HRESULT)0x88890011)
-#define MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY          ((HRESULT)0x88890012)
-#define MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL ((HRESULT)0x88890013)
-#define MA_AUDCLNT_E_EVENTHANDLE_NOT_SET          ((HRESULT)0x88890014)
-#define MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE        ((HRESULT)0x88890015)
-#define MA_AUDCLNT_E_BUFFER_SIZE_ERROR            ((HRESULT)0x88890016)
-#define MA_AUDCLNT_E_CPUUSAGE_EXCEEDED            ((HRESULT)0x88890017)
-#define MA_AUDCLNT_E_BUFFER_ERROR                 ((HRESULT)0x88890018)
-#define MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED      ((HRESULT)0x88890019)
-#define MA_AUDCLNT_E_INVALID_DEVICE_PERIOD        ((HRESULT)0x88890020)
-#define MA_AUDCLNT_E_INVALID_STREAM_FLAG          ((HRESULT)0x88890021)
-#define MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE ((HRESULT)0x88890022)
-#define MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES     ((HRESULT)0x88890023)
-#define MA_AUDCLNT_E_OFFLOAD_MODE_ONLY            ((HRESULT)0x88890024)
-#define MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY         ((HRESULT)0x88890025)
-#define MA_AUDCLNT_E_RESOURCES_INVALIDATED        ((HRESULT)0x88890026)
-#define MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED         ((HRESULT)0x88890027)
-#define MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED    ((HRESULT)0x88890028)
-#define MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED         ((HRESULT)0x88890029)
-#define MA_AUDCLNT_E_HEADTRACKING_ENABLED         ((HRESULT)0x88890030)
-#define MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED     ((HRESULT)0x88890040)
-#define MA_AUDCLNT_S_BUFFER_EMPTY                 ((HRESULT)0x08890001)
-#define MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED    ((HRESULT)0x08890002)
-#define MA_AUDCLNT_S_POSITION_STALLED             ((HRESULT)0x08890003)
-
-#define MA_DS_OK                                  ((HRESULT)0)
-#define MA_DS_NO_VIRTUALIZATION                   ((HRESULT)0x0878000A)
-#define MA_DSERR_ALLOCATED                        ((HRESULT)0x8878000A)
-#define MA_DSERR_CONTROLUNAVAIL                   ((HRESULT)0x8878001E)
-#define MA_DSERR_INVALIDPARAM                     ((HRESULT)0x80070057) /*E_INVALIDARG*/
-#define MA_DSERR_INVALIDCALL                      ((HRESULT)0x88780032)
-#define MA_DSERR_GENERIC                          ((HRESULT)0x80004005) /*E_FAIL*/
-#define MA_DSERR_PRIOLEVELNEEDED                  ((HRESULT)0x88780046)
-#define MA_DSERR_OUTOFMEMORY                      ((HRESULT)0x8007000E) /*E_OUTOFMEMORY*/
-#define MA_DSERR_BADFORMAT                        ((HRESULT)0x88780064)
-#define MA_DSERR_UNSUPPORTED                      ((HRESULT)0x80004001) /*E_NOTIMPL*/
-#define MA_DSERR_NODRIVER                         ((HRESULT)0x88780078)
-#define MA_DSERR_ALREADYINITIALIZED               ((HRESULT)0x88780082)
-#define MA_DSERR_NOAGGREGATION                    ((HRESULT)0x80040110) /*CLASS_E_NOAGGREGATION*/
-#define MA_DSERR_BUFFERLOST                       ((HRESULT)0x88780096)
-#define MA_DSERR_OTHERAPPHASPRIO                  ((HRESULT)0x887800A0)
-#define MA_DSERR_UNINITIALIZED                    ((HRESULT)0x887800AA)
-#define MA_DSERR_NOINTERFACE                      ((HRESULT)0x80004002) /*E_NOINTERFACE*/
-#define MA_DSERR_ACCESSDENIED                     ((HRESULT)0x80070005) /*E_ACCESSDENIED*/
-#define MA_DSERR_BUFFERTOOSMALL                   ((HRESULT)0x887800B4)
-#define MA_DSERR_DS8_REQUIRED                     ((HRESULT)0x887800BE)
-#define MA_DSERR_SENDLOOP                         ((HRESULT)0x887800C8)
-#define MA_DSERR_BADSENDBUFFERGUID                ((HRESULT)0x887800D2)
-#define MA_DSERR_OBJECTNOTFOUND                   ((HRESULT)0x88781161)
-#define MA_DSERR_FXUNAVAILABLE                    ((HRESULT)0x887800DC)
-
-static ma_result ma_result_from_HRESULT(HRESULT hr)
-{
-    switch (hr)
-    {
-        case NOERROR:                                   return MA_SUCCESS;
-        /*case S_OK:                                      return MA_SUCCESS;*/
-
-        case E_POINTER:                                 return MA_INVALID_ARGS;
-        case E_UNEXPECTED:                              return MA_ERROR;
-        case E_NOTIMPL:                                 return MA_NOT_IMPLEMENTED;
-        case E_OUTOFMEMORY:                             return MA_OUT_OF_MEMORY;
-        case E_INVALIDARG:                              return MA_INVALID_ARGS;
-        case E_NOINTERFACE:                             return MA_API_NOT_FOUND;
-        case E_HANDLE:                                  return MA_INVALID_ARGS;
-        case E_ABORT:                                   return MA_ERROR;
-        case E_FAIL:                                    return MA_ERROR;
-        case E_ACCESSDENIED:                            return MA_ACCESS_DENIED;
-
-        /* WASAPI */
-        case MA_AUDCLNT_E_NOT_INITIALIZED:              return MA_DEVICE_NOT_INITIALIZED;
-        case MA_AUDCLNT_E_ALREADY_INITIALIZED:          return MA_DEVICE_ALREADY_INITIALIZED;
-        case MA_AUDCLNT_E_WRONG_ENDPOINT_TYPE:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_DEVICE_INVALIDATED:           return MA_UNAVAILABLE;
-        case MA_AUDCLNT_E_NOT_STOPPED:                  return MA_DEVICE_NOT_STOPPED;
-        case MA_AUDCLNT_E_BUFFER_TOO_LARGE:             return MA_TOO_BIG;
-        case MA_AUDCLNT_E_OUT_OF_ORDER:                 return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_UNSUPPORTED_FORMAT:           return MA_FORMAT_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_INVALID_SIZE:                 return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_DEVICE_IN_USE:                return MA_BUSY;
-        case MA_AUDCLNT_E_BUFFER_OPERATION_PENDING:     return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_THREAD_NOT_REGISTERED:        return MA_DOES_NOT_EXIST;
-        case MA_AUDCLNT_E_NO_SINGLE_PROCESS:            return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED:   return MA_SHARE_MODE_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_ENDPOINT_CREATE_FAILED:       return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-        case MA_AUDCLNT_E_SERVICE_NOT_RUNNING:          return MA_NOT_CONNECTED;
-        case MA_AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED:     return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_EXCLUSIVE_MODE_ONLY:          return MA_SHARE_MODE_NOT_SUPPORTED;
-        case MA_AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL: return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_EVENTHANDLE_NOT_SET:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INCORRECT_BUFFER_SIZE:        return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_BUFFER_SIZE_ERROR:            return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_CPUUSAGE_EXCEEDED:            return MA_ERROR;
-        case MA_AUDCLNT_E_BUFFER_ERROR:                 return MA_ERROR;
-        case MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED:      return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INVALID_DEVICE_PERIOD:        return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_INVALID_STREAM_FLAG:          return MA_INVALID_ARGS;
-        case MA_AUDCLNT_E_ENDPOINT_OFFLOAD_NOT_CAPABLE: return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_OUT_OF_OFFLOAD_RESOURCES:     return MA_OUT_OF_MEMORY;
-        case MA_AUDCLNT_E_OFFLOAD_MODE_ONLY:            return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_NONOFFLOAD_MODE_ONLY:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_RESOURCES_INVALIDATED:        return MA_INVALID_DATA;
-        case MA_AUDCLNT_E_RAW_MODE_UNSUPPORTED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_ENGINE_PERIODICITY_LOCKED:    return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_ENGINE_FORMAT_LOCKED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_HEADTRACKING_ENABLED:         return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_E_HEADTRACKING_UNSUPPORTED:     return MA_INVALID_OPERATION;
-        case MA_AUDCLNT_S_BUFFER_EMPTY:                 return MA_NO_SPACE;
-        case MA_AUDCLNT_S_THREAD_ALREADY_REGISTERED:    return MA_ALREADY_EXISTS;
-        case MA_AUDCLNT_S_POSITION_STALLED:             return MA_ERROR;
-
-        /* DirectSound */
-        /*case MA_DS_OK:                                  return MA_SUCCESS;*/          /* S_OK */
-        case MA_DS_NO_VIRTUALIZATION:                   return MA_SUCCESS;
-        case MA_DSERR_ALLOCATED:                        return MA_ALREADY_IN_USE;
-        case MA_DSERR_CONTROLUNAVAIL:                   return MA_INVALID_OPERATION;
-        /*case MA_DSERR_INVALIDPARAM:                    return MA_INVALID_ARGS;*/      /* E_INVALIDARG */
-        case MA_DSERR_INVALIDCALL:                      return MA_INVALID_OPERATION;
-        /*case MA_DSERR_GENERIC:                          return MA_ERROR;*/            /* E_FAIL */
-        case MA_DSERR_PRIOLEVELNEEDED:                  return MA_INVALID_OPERATION;
-        /*case MA_DSERR_OUTOFMEMORY:                      return MA_OUT_OF_MEMORY;*/    /* E_OUTOFMEMORY */
-        case MA_DSERR_BADFORMAT:                        return MA_FORMAT_NOT_SUPPORTED;
-        /*case MA_DSERR_UNSUPPORTED:                      return MA_NOT_IMPLEMENTED;*/  /* E_NOTIMPL */
-        case MA_DSERR_NODRIVER:                         return MA_FAILED_TO_INIT_BACKEND;
-        case MA_DSERR_ALREADYINITIALIZED:               return MA_DEVICE_ALREADY_INITIALIZED;
-        case MA_DSERR_NOAGGREGATION:                    return MA_ERROR;
-        case MA_DSERR_BUFFERLOST:                       return MA_UNAVAILABLE;
-        case MA_DSERR_OTHERAPPHASPRIO:                  return MA_ACCESS_DENIED;
-        case MA_DSERR_UNINITIALIZED:                    return MA_DEVICE_NOT_INITIALIZED;
-        /*case MA_DSERR_NOINTERFACE:                      return MA_API_NOT_FOUND;*/    /* E_NOINTERFACE */
-        /*case MA_DSERR_ACCESSDENIED:                     return MA_ACCESS_DENIED;*/    /* E_ACCESSDENIED */
-        case MA_DSERR_BUFFERTOOSMALL:                   return MA_NO_SPACE;
-        case MA_DSERR_DS8_REQUIRED:                     return MA_INVALID_OPERATION;
-        case MA_DSERR_SENDLOOP:                         return MA_DEADLOCK;
-        case MA_DSERR_BADSENDBUFFERGUID:                return MA_INVALID_ARGS;
-        case MA_DSERR_OBJECTNOTFOUND:                   return MA_NO_DEVICE;
-        case MA_DSERR_FXUNAVAILABLE:                    return MA_UNAVAILABLE;
-
-        default:                                        return MA_ERROR;
-    }
-}
-
-typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(LPVOID pvReserved, DWORD  dwCoInit);
-typedef void    (WINAPI * MA_PFN_CoUninitialize)(void);
-typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv);
-typedef void    (WINAPI * MA_PFN_CoTaskMemFree)(LPVOID pv);
-typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(PROPVARIANT *pvar);
-typedef int     (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, LPOLESTR lpsz, int cchMax);
-
-typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(void);
-typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(void);
-
-/* Microsoft documents these APIs as returning LSTATUS, but the Win32 API shipping with some compilers do not define it. It's just a LONG. */
-typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
-typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey);
-typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
-#endif
-
-
-#define MA_DEFAULT_PLAYBACK_DEVICE_NAME    "Default Playback Device"
-#define MA_DEFAULT_CAPTURE_DEVICE_NAME     "Default Capture Device"
-
-
-MA_API const char* ma_log_level_to_string(ma_uint32 logLevel)
-{
-    switch (logLevel)
-    {
-        case MA_LOG_LEVEL_VERBOSE: return "";
-        case MA_LOG_LEVEL_INFO:    return "INFO";
-        case MA_LOG_LEVEL_WARNING: return "WARNING";
-        case MA_LOG_LEVEL_ERROR:   return "ERROR";
-        default:                   return "ERROR";
-    }
-}
-
-/* Posts a log message. */
-static void ma_post_log_message(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-{
-    if (pContext == NULL) {
-        if (pDevice != NULL) {
-            pContext = pDevice->pContext;
-        }
-    }
-
-    /* All logs must be output when debug output is enabled. */
-#if defined(MA_DEBUG_OUTPUT)
-    printf("%s: %s\n", ma_log_level_to_string(logLevel), message);
-#endif
-
-    if (pContext == NULL) {
-        return;
-    }
-
-#if defined(MA_LOG_LEVEL)
-    if (logLevel <= MA_LOG_LEVEL) {
-        ma_log_proc onLog;
-
-        onLog = pContext->logCallback;
-        if (onLog) {
-            onLog(pContext, pDevice, logLevel, message);
-        }
-    }
-#endif
-}
-
-/*
-We need to emulate _vscprintf() for the VC6 build. This can be more efficient, but since it's only VC6, and it's just a
-logging function, I'm happy to keep this simple. In the VC6 build we can implement this in terms of _vsnprintf().
-*/
-#if defined(_MSC_VER) && _MSC_VER < 1900
-int ma_vscprintf(const char* format, va_list args)
-{
-#if _MSC_VER > 1200
-    return _vscprintf(format, args);
-#else
-    int result;
-    char* pTempBuffer = NULL;
-    size_t tempBufferCap = 1024;
-
-    if (format == NULL) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    for (;;) {
-        char* pNewTempBuffer = (char*)ma_realloc(pTempBuffer, tempBufferCap, NULL);    /* TODO: Add support for custom memory allocators? */
-        if (pNewTempBuffer == NULL) {
-            ma_free(pTempBuffer, NULL);
-            errno = ENOMEM;
-            return -1;  /* Out of memory. */
-        }
-
-        pTempBuffer = pNewTempBuffer;
-
-        result = _vsnprintf(pTempBuffer, tempBufferCap, format, args);
-        ma_free(pTempBuffer, NULL);
-
-        if (result != -1) {
-            break;  /* Got it. */
-        }
-
-        /* Buffer wasn't big enough. Ideally it'd be nice to use an error code to know the reason for sure, but this is reliable enough. */
-        tempBufferCap *= 2;
-    }
-
-    return result;
-#endif
-}
-#endif
-
-/* Posts a formatted log message. */
-static void ma_post_log_messagev(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* pFormat, va_list args)
-{
-#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || ((!defined(_MSC_VER) || _MSC_VER >= 1900) && !defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-    {
-        char pFormattedMessage[1024];
-        vsnprintf(pFormattedMessage, sizeof(pFormattedMessage), pFormat, args);
-        ma_post_log_message(pContext, pDevice, logLevel, pFormattedMessage);
-    }
-#else
-    {
-        /*
-        Without snprintf() we need to first measure the string and then heap allocate it. I'm only aware of Visual Studio having support for this without snprintf(), so we'll
-        need to restrict this branch to Visual Studio. For other compilers we need to just not support formatted logging because I don't want the security risk of overflowing
-        a fixed sized stack allocated buffer.
-        */
-    #if defined(_MSC_VER) && _MSC_VER >= 1200   /* 1200 = VC6 */
-        int formattedLen;
-        va_list args2;
-
-    #if _MSC_VER >= 1800
-        va_copy(args2, args);
-    #else
-        args2 = args;
-    #endif
-        formattedLen = ma_vscprintf(pFormat, args2);
-        va_end(args2);
-
-        if (formattedLen > 0) {
-            char* pFormattedMessage = NULL;
-            ma_allocation_callbacks* pAllocationCallbacks = NULL;
-
-            /* Make sure we have a context so we can allocate memory. */
-            if (pContext == NULL) {
-                if (pDevice != NULL) {
-                    pContext = pDevice->pContext;
-                }
-            }
-
-            if (pContext != NULL) {
-                pAllocationCallbacks = &pContext->allocationCallbacks;
-            }
-
-            pFormattedMessage = (char*)ma_malloc(formattedLen + 1, pAllocationCallbacks);
-            if (pFormattedMessage != NULL) {
-                /* We'll get errors on newer versions of Visual Studio if we try to use vsprintf().  */
-            #if _MSC_VER >= 1400    /* 1400 = Visual Studio 2005 */
-                vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args);
-            #else
-                vsprintf(pFormattedMessage, pFormat, args);
-            #endif
-
-                ma_post_log_message(pContext, pDevice, logLevel, pFormattedMessage);
-                ma_free(pFormattedMessage, pAllocationCallbacks);
-            }
-        }
-    #else
-        /* Can't do anything because we don't have a safe way of to emulate vsnprintf() without a manual solution. */
-        (void)pContext;
-        (void)pDevice;
-        (void)logLevel;
-        (void)pFormat;
-        (void)args;
-    #endif
-    }
-#endif
-}
-
-MA_API void ma_post_log_messagef(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* pFormat, ...)
-{
-    va_list args;
-    va_start(args, pFormat);
-    {
-        ma_post_log_messagev(pContext, pDevice, logLevel, pFormat, args);
-    }
-    va_end(args);
-}
-
-/* Posts an log message. Throw a breakpoint in here if you're needing to debug. The return value is always "resultCode". */
-static ma_result ma_context_post_error(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message, ma_result resultCode)
-{
-    ma_post_log_message(pContext, pDevice, logLevel, message);
-    return resultCode;
-}
-
-static ma_result ma_post_error(ma_device* pDevice, ma_uint32 logLevel, const char* message, ma_result resultCode)
-{
-    return ma_context_post_error(NULL, pDevice, logLevel, message, resultCode);
-}
-
-
-/*******************************************************************************
-
-Timing
-
-*******************************************************************************/
-#ifdef MA_WIN32
-    static LARGE_INTEGER g_ma_TimerFrequency;   /* <-- Initialized to zero since it's static. */
-    static void ma_timer_init(ma_timer* pTimer)
-    {
-        LARGE_INTEGER counter;
-
-        if (g_ma_TimerFrequency.QuadPart == 0) {
-            QueryPerformanceFrequency(&g_ma_TimerFrequency);
-        }
-
-        QueryPerformanceCounter(&counter);
-        pTimer->counter = counter.QuadPart;
-    }
-
-    static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        LARGE_INTEGER counter;
-        if (!QueryPerformanceCounter(&counter)) {
-            return 0;
-        }
-
-        return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart;
-    }
-#elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
-    static ma_uint64 g_ma_TimerFrequency = 0;
-    static void ma_timer_init(ma_timer* pTimer)
-    {
-        mach_timebase_info_data_t baseTime;
-        mach_timebase_info(&baseTime);
-        g_ma_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer;
-
-        pTimer->counter = mach_absolute_time();
-    }
-
-    static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        ma_uint64 newTimeCounter = mach_absolute_time();
-        ma_uint64 oldTimeCounter = pTimer->counter;
-
-        return (newTimeCounter - oldTimeCounter) / g_ma_TimerFrequency;
-    }
-#elif defined(MA_EMSCRIPTEN)
-    static MA_INLINE void ma_timer_init(ma_timer* pTimer)
-    {
-        pTimer->counterD = emscripten_get_now();
-    }
-
-    static MA_INLINE double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-    {
-        return (emscripten_get_now() - pTimer->counterD) / 1000;    /* Emscripten is in milliseconds. */
-    }
-#else
-    #if _POSIX_C_SOURCE >= 199309L
-        #if defined(CLOCK_MONOTONIC)
-            #define MA_CLOCK_ID CLOCK_MONOTONIC
-        #else
-            #define MA_CLOCK_ID CLOCK_REALTIME
-        #endif
-
-        static void ma_timer_init(ma_timer* pTimer)
-        {
-            struct timespec newTime;
-            clock_gettime(MA_CLOCK_ID, &newTime);
-
-            pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
-        }
-
-        static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-        {
-            ma_uint64 newTimeCounter;
-            ma_uint64 oldTimeCounter;
-
-            struct timespec newTime;
-            clock_gettime(MA_CLOCK_ID, &newTime);
-
-            newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
-            oldTimeCounter = pTimer->counter;
-
-            return (newTimeCounter - oldTimeCounter) / 1000000000.0;
-        }
-    #else
-        static void ma_timer_init(ma_timer* pTimer)
-        {
-            struct timeval newTime;
-            gettimeofday(&newTime, NULL);
-
-            pTimer->counter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
-        }
-
-        static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
-        {
-            ma_uint64 newTimeCounter;
-            ma_uint64 oldTimeCounter;
-
-            struct timeval newTime;
-            gettimeofday(&newTime, NULL);
-
-            newTimeCounter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
-            oldTimeCounter = pTimer->counter;
-
-            return (newTimeCounter - oldTimeCounter) / 1000000.0;
-        }
-    #endif
-#endif
-
-
-/*******************************************************************************
-
-Dynamic Linking
-
-*******************************************************************************/
-MA_API ma_handle ma_dlopen(ma_context* pContext, const char* filename)
-{
-    ma_handle handle;
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_VERBOSE
-    if (pContext != NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Loading library: ", filename);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_VERBOSE, message);
-    }
-#endif
-
-#ifdef _WIN32
-#ifdef MA_WIN32_DESKTOP
-    handle = (ma_handle)LoadLibraryA(filename);
-#else
-    /* *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... */
-    WCHAR filenameW[4096];
-    if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, sizeof(filenameW)) == 0) {
-        handle = NULL;
-    } else {
-        handle = (ma_handle)LoadPackagedLibrary(filenameW, 0);
-    }
-#endif
-#else
-    handle = (ma_handle)dlopen(filename, RTLD_NOW);
-#endif
-
-    /*
-    I'm not considering failure to load a library an error nor a warning because seamlessly falling through to a lower-priority
-    backend is a deliberate design choice. Instead I'm logging it as an informational message.
-    */
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_INFO
-    if (handle == NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Failed to load library: ", filename);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, message);
-    }
-#endif
-
-    (void)pContext; /* It's possible for pContext to be unused. */
-    return handle;
-}
-
-MA_API void ma_dlclose(ma_context* pContext, ma_handle handle)
-{
-#ifdef _WIN32
-    FreeLibrary((HMODULE)handle);
-#else
-    dlclose((void*)handle);
-#endif
-
-    (void)pContext;
-}
-
-MA_API ma_proc ma_dlsym(ma_context* pContext, ma_handle handle, const char* symbol)
-{
-    ma_proc proc;
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_VERBOSE
-    if (pContext != NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Loading symbol: ", symbol);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_VERBOSE, message);
-    }
-#endif
-
-#ifdef _WIN32
-    proc = (ma_proc)GetProcAddress((HMODULE)handle, symbol);
-#else
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-    #pragma GCC diagnostic push
-    #pragma GCC diagnostic ignored "-Wpedantic"
-#endif
-    proc = (ma_proc)dlsym((void*)handle, symbol);
-#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-    #pragma GCC diagnostic pop
-#endif
-#endif
-
-#if MA_LOG_LEVEL >= MA_LOG_LEVEL_WARNING
-    if (handle == NULL) {
-        char message[256];
-        ma_strappend(message, sizeof(message), "Failed to load symbol: ", symbol);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_WARNING, message);
-    }
-#endif
-
-    (void)pContext; /* It's possible for pContext to be unused. */
-    return proc;
-}
-
-
-#if 0
-static ma_uint32 ma_get_closest_standard_sample_rate(ma_uint32 sampleRateIn)
-{
-    ma_uint32 closestRate = 0;
-    ma_uint32 closestDiff = 0xFFFFFFFF;
-    size_t iStandardRate;
-
-    for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) {
-        ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate];
-        ma_uint32 diff;
-
-        if (sampleRateIn > standardRate) {
-            diff = sampleRateIn - standardRate;
-        } else {
-            diff = standardRate - sampleRateIn;
-        }
-
-        if (diff == 0) {
-            return standardRate;    /* The input sample rate is a standard rate. */
-        }
-
-        if (closestDiff > diff) {
-            closestDiff = diff;
-            closestRate = standardRate;
-        }
-    }
-
-    return closestRate;
-}
-#endif
-
-
-static void ma_device__on_data(ma_device* pDevice, void* pFramesOut, const void* pFramesIn, ma_uint32 frameCount)
-{
-    float masterVolumeFactor;
-
-    ma_device_get_master_volume(pDevice, &masterVolumeFactor);  /* Use ma_device_get_master_volume() to ensure the volume is loaded atomically. */
-
-    if (pDevice->onData) {
-        if (!pDevice->noPreZeroedOutputBuffer && pFramesOut != NULL) {
-            ma_silence_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels);
-        }
-
-        /* Volume control of input makes things a bit awkward because the input buffer is read-only. We'll need to use a temp buffer and loop in this case. */
-        if (pFramesIn != NULL && masterVolumeFactor < 1) {
-            ma_uint8 tempFramesIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            ma_uint32 bpfCapture  = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-            ma_uint32 bpfPlayback = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-            ma_uint32 totalFramesProcessed = 0;
-            while (totalFramesProcessed < frameCount) {
-                ma_uint32 framesToProcessThisIteration = frameCount - totalFramesProcessed;
-                if (framesToProcessThisIteration > sizeof(tempFramesIn)/bpfCapture) {
-                    framesToProcessThisIteration = sizeof(tempFramesIn)/bpfCapture;
-                }
-
-                ma_copy_and_apply_volume_factor_pcm_frames(tempFramesIn, ma_offset_ptr(pFramesIn, totalFramesProcessed*bpfCapture), framesToProcessThisIteration, pDevice->capture.format, pDevice->capture.channels, masterVolumeFactor);
-
-                pDevice->onData(pDevice, ma_offset_ptr(pFramesOut, totalFramesProcessed*bpfPlayback), tempFramesIn, framesToProcessThisIteration);
-
-                totalFramesProcessed += framesToProcessThisIteration;
-            }
-        } else {
-            pDevice->onData(pDevice, pFramesOut, pFramesIn, frameCount);
-        }
-
-        /* Volume control and clipping for playback devices. */
-        if (pFramesOut != NULL) {
-            if (masterVolumeFactor < 1) {
-                if (pFramesIn == NULL) {    /* <-- In full-duplex situations, the volume will have been applied to the input samples before the data callback. Applying it again post-callback will incorrectly compound it. */
-                    ma_apply_volume_factor_pcm_frames(pFramesOut, frameCount, pDevice->playback.format, pDevice->playback.channels, masterVolumeFactor);
-                }
-            }
-
-            if (!pDevice->noClip && pDevice->playback.format == ma_format_f32) {
-                ma_clip_pcm_frames_f32((float*)pFramesOut, frameCount, pDevice->playback.channels);
-            }
-        }
-    }
-}
-
-
-
-/* A helper function for reading sample data from the client. */
-static void ma_device__read_frames_from_client(ma_device* pDevice, ma_uint32 frameCount, void* pFramesOut)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCount > 0);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pDevice->playback.converter.isPassthrough) {
-        ma_device__on_data(pDevice, pFramesOut, NULL, frameCount);
-    } else {
-        ma_result result;
-        ma_uint64 totalFramesReadOut;
-        ma_uint64 totalFramesReadIn;
-        void* pRunningFramesOut;
-
-        totalFramesReadOut = 0;
-        totalFramesReadIn  = 0;
-        pRunningFramesOut  = pFramesOut;
-
-        while (totalFramesReadOut < frameCount) {
-            ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In client format. */
-            ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-            ma_uint64 framesToReadThisIterationIn;
-            ma_uint64 framesReadThisIterationIn;
-            ma_uint64 framesToReadThisIterationOut;
-            ma_uint64 framesReadThisIterationOut;
-            ma_uint64 requiredInputFrameCount;
-
-            framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
-            framesToReadThisIterationIn = framesToReadThisIterationOut;
-            if (framesToReadThisIterationIn > intermediaryBufferCap) {
-                framesToReadThisIterationIn = intermediaryBufferCap;
-            }
-
-            requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, framesToReadThisIterationOut);
-            if (framesToReadThisIterationIn > requiredInputFrameCount) {
-                framesToReadThisIterationIn = requiredInputFrameCount;
-            }
-
-            if (framesToReadThisIterationIn > 0) {
-                ma_device__on_data(pDevice, pIntermediaryBuffer, NULL, (ma_uint32)framesToReadThisIterationIn);
-                totalFramesReadIn += framesToReadThisIterationIn;
-            }
-
-            /*
-            At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
-            input frames, we still want to try processing frames because there may some output frames generated from cached input data.
-            */
-            framesReadThisIterationIn  = framesToReadThisIterationIn;
-            framesReadThisIterationOut = framesToReadThisIterationOut;
-            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-
-            totalFramesReadOut += framesReadThisIterationOut;
-            pRunningFramesOut   = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-
-            if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) {
-                break;  /* We're done. */
-            }
-        }
-    }
-}
-
-/* A helper for sending sample data to the client. */
-static void ma_device__send_frames_to_client(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCountInDeviceFormat > 0);
-    MA_ASSERT(pFramesInDeviceFormat != NULL);
-
-    if (pDevice->capture.converter.isPassthrough) {
-        ma_device__on_data(pDevice, NULL, pFramesInDeviceFormat, frameCountInDeviceFormat);
-    } else {
-        ma_result result;
-        ma_uint8 pFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-        ma_uint64 framesInClientFormatCap = sizeof(pFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-        ma_uint64 totalDeviceFramesProcessed = 0;
-        ma_uint64 totalClientFramesProcessed = 0;
-        const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
-
-        /* We just keep going until we've exhaused all of our input frames and cannot generate any more output frames. */
-        for (;;) {
-            ma_uint64 deviceFramesProcessedThisIteration;
-            ma_uint64 clientFramesProcessedThisIteration;
-
-            deviceFramesProcessedThisIteration = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
-            clientFramesProcessedThisIteration = framesInClientFormatCap;
-
-            result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &deviceFramesProcessedThisIteration, pFramesInClientFormat, &clientFramesProcessedThisIteration);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-
-            if (clientFramesProcessedThisIteration > 0) {
-                ma_device__on_data(pDevice, NULL, pFramesInClientFormat, (ma_uint32)clientFramesProcessedThisIteration);    /* Safe cast. */
-            }
-
-            pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, deviceFramesProcessedThisIteration * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-            totalDeviceFramesProcessed  += deviceFramesProcessedThisIteration;
-            totalClientFramesProcessed  += clientFramesProcessedThisIteration;
-
-            if (deviceFramesProcessedThisIteration == 0 && clientFramesProcessedThisIteration == 0) {
-                break;  /* We're done. */
-            }
-        }
-    }
-}
-
-static ma_result ma_device__handle_duplex_callback_capture(ma_device* pDevice, ma_uint32 frameCountInDeviceFormat, const void* pFramesInDeviceFormat, ma_pcm_rb* pRB)
-{
-    ma_result result;
-    ma_uint32 totalDeviceFramesProcessed = 0;
-    const void* pRunningFramesInDeviceFormat = pFramesInDeviceFormat;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCountInDeviceFormat > 0);
-    MA_ASSERT(pFramesInDeviceFormat != NULL);
-    MA_ASSERT(pRB != NULL);
-
-    /* Write to the ring buffer. The ring buffer is in the client format which means we need to convert. */
-    for (;;) {
-        ma_uint32 framesToProcessInDeviceFormat = (frameCountInDeviceFormat - totalDeviceFramesProcessed);
-        ma_uint32 framesToProcessInClientFormat = MA_DATA_CONVERTER_STACK_BUFFER_SIZE / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-        ma_uint64 framesProcessedInDeviceFormat;
-        ma_uint64 framesProcessedInClientFormat;
-        void* pFramesInClientFormat;
-
-        result = ma_pcm_rb_acquire_write(pRB, &framesToProcessInClientFormat, &pFramesInClientFormat);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to acquire capture PCM frames from ring buffer.", result);
-            break;
-        }
-
-        if (framesToProcessInClientFormat == 0) {
-            if (ma_pcm_rb_pointer_distance(pRB) == (ma_int32)ma_pcm_rb_get_subbuffer_size(pRB)) {
-                break;  /* Overrun. Not enough room in the ring buffer for input frame. Excess frames are dropped. */
-            }
-        }
-
-        /* Convert. */
-        framesProcessedInDeviceFormat = framesToProcessInDeviceFormat;
-        framesProcessedInClientFormat = framesToProcessInClientFormat;
-        result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningFramesInDeviceFormat, &framesProcessedInDeviceFormat, pFramesInClientFormat, &framesProcessedInClientFormat);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        result = ma_pcm_rb_commit_write(pRB, (ma_uint32)framesProcessedInClientFormat, pFramesInClientFormat);  /* Safe cast. */
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to commit capture PCM frames to ring buffer.", result);
-            break;
-        }
-
-        pRunningFramesInDeviceFormat = ma_offset_ptr(pRunningFramesInDeviceFormat, framesProcessedInDeviceFormat * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-        totalDeviceFramesProcessed += (ma_uint32)framesProcessedInDeviceFormat; /* Safe cast. */
-
-        /* We're done when we're unable to process any client nor device frames. */
-        if (framesProcessedInClientFormat == 0 && framesProcessedInDeviceFormat == 0) {
-            break;  /* Done. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__handle_duplex_callback_playback(ma_device* pDevice, ma_uint32 frameCount, void* pFramesInInternalFormat, ma_pcm_rb* pRB)
-{
-    ma_result result;
-    ma_uint8 playbackFramesInExternalFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint8 silentInputFrames[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 totalFramesToReadFromClient;
-    ma_uint32 totalFramesReadFromClient;
-    ma_uint32 totalFramesReadOut = 0;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(frameCount > 0);
-    MA_ASSERT(pFramesInInternalFormat != NULL);
-    MA_ASSERT(pRB != NULL);
-
-    /*
-    Sitting in the ring buffer should be captured data from the capture callback in external format. If there's not enough data in there for
-    the whole frameCount frames we just use silence instead for the input data.
-    */
-    MA_ZERO_MEMORY(silentInputFrames, sizeof(silentInputFrames));
-
-    /* We need to calculate how many output frames are required to be read from the client to completely fill frameCount internal frames. */
-    totalFramesToReadFromClient = (ma_uint32)ma_data_converter_get_required_input_frame_count(&pDevice->playback.converter, frameCount);
-    totalFramesReadFromClient = 0;
-    while (totalFramesReadFromClient < totalFramesToReadFromClient && ma_device_is_started(pDevice)) {
-        ma_uint32 framesRemainingFromClient;
-        ma_uint32 framesToProcessFromClient;
-        ma_uint32 inputFrameCount;
-        void* pInputFrames;
-
-        framesRemainingFromClient = (totalFramesToReadFromClient - totalFramesReadFromClient);
-        framesToProcessFromClient = sizeof(playbackFramesInExternalFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-        if (framesToProcessFromClient > framesRemainingFromClient) {
-            framesToProcessFromClient = framesRemainingFromClient;
-        }
-
-        /* We need to grab captured samples before firing the callback. If there's not enough input samples we just pass silence. */
-        inputFrameCount = framesToProcessFromClient;
-        result = ma_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames);
-        if (result == MA_SUCCESS) {
-            if (inputFrameCount > 0) {
-                /* Use actual input frames. */
-                ma_device__on_data(pDevice, playbackFramesInExternalFormat, pInputFrames, inputFrameCount);
-            } else {
-                if (ma_pcm_rb_pointer_distance(pRB) == 0) {
-                    break;  /* Underrun. */
-                }
-            }
-
-            /* We're done with the captured samples. */
-            result = ma_pcm_rb_commit_read(pRB, inputFrameCount, pInputFrames);
-            if (result != MA_SUCCESS) {
-                break; /* Don't know what to do here... Just abandon ship. */
-            }
-        } else {
-            /* Use silent input frames. */
-            inputFrameCount = ma_min(
-                sizeof(playbackFramesInExternalFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels),
-                sizeof(silentInputFrames)              / ma_get_bytes_per_frame(pDevice->capture.format,  pDevice->capture.channels)
-            );
-
-            ma_device__on_data(pDevice, playbackFramesInExternalFormat, silentInputFrames, inputFrameCount);
-        }
-
-        /* We have samples in external format so now we need to convert to internal format and output to the device. */
-        {
-            ma_uint64 framesConvertedIn  = inputFrameCount;
-            ma_uint64 framesConvertedOut = (frameCount - totalFramesReadOut);
-            ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackFramesInExternalFormat, &framesConvertedIn, pFramesInInternalFormat, &framesConvertedOut);
-
-            totalFramesReadFromClient += (ma_uint32)framesConvertedIn;  /* Safe cast. */
-            totalFramesReadOut        += (ma_uint32)framesConvertedOut; /* Safe cast. */
-            pFramesInInternalFormat    = ma_offset_ptr(pFramesInInternalFormat, framesConvertedOut * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-/* A helper for changing the state of the device. */
-static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_uint32 newState)
-{
-    c89atomic_exchange_32(&pDevice->state, newState);
-}
-
-
-#ifdef MA_WIN32
-    GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM        = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-    GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-    /*GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW       = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
-    /*GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW      = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
-#endif
-
-
-
-MA_API ma_uint32 ma_get_format_priority_index(ma_format format) /* Lower = better. */
-{
-    ma_uint32 i;
-    for (i = 0; i < ma_countof(g_maFormatPriorities); ++i) {
-        if (g_maFormatPriorities[i] == format) {
-            return i;
-        }
-    }
-
-    /* Getting here means the format could not be found or is equal to ma_format_unknown. */
-    return (ma_uint32)-1;
-}
-
-static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType);
-
-
-static ma_bool32 ma_device_descriptor_is_valid(const ma_device_descriptor* pDeviceDescriptor)
-{
-    if (pDeviceDescriptor == NULL) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->format == ma_format_unknown) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->channels < MA_MIN_CHANNELS || pDeviceDescriptor->channels > MA_MAX_CHANNELS) {
-        return MA_FALSE;
-    }
-
-    if (pDeviceDescriptor->sampleRate == 0) {
-        return MA_FALSE;
-    }
-
-    return MA_TRUE;
-}
-
-
-static ma_result ma_device_audio_thread__default_read_write(ma_device* pDevice)
-{
-    ma_result result = MA_SUCCESS;
-    ma_bool32 exitLoop = MA_FALSE;
-    ma_uint8  capturedDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint8  playbackDeviceData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 capturedDeviceDataCapInFrames = 0;
-    ma_uint32 playbackDeviceDataCapInFrames = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* Just some quick validation on the device type and the available callbacks. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        if (pDevice->pContext->callbacks.onDeviceRead == NULL) {
-            return MA_NOT_IMPLEMENTED;
-        }
-
-        capturedDeviceDataCapInFrames = sizeof(capturedDeviceData) / ma_get_bytes_per_frame(pDevice->capture.internalFormat,  pDevice->capture.internalChannels);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->pContext->callbacks.onDeviceWrite == NULL) {
-            return MA_NOT_IMPLEMENTED;
-        }
-
-        playbackDeviceDataCapInFrames = sizeof(playbackDeviceData) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    /* NOTE: The device was started outside of this function, in the worker thread. */
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && !exitLoop) {
-        switch (pDevice->type) {
-            case ma_device_type_duplex:
-            {
-                /* The process is: onDeviceRead() -> convert -> callback -> convert -> onDeviceWrite() */
-                ma_uint32 totalCapturedDeviceFramesProcessed = 0;
-                ma_uint32 capturedDevicePeriodSizeInFrames = ma_min(pDevice->capture.internalPeriodSizeInFrames, pDevice->playback.internalPeriodSizeInFrames);
-
-                while (totalCapturedDeviceFramesProcessed < capturedDevicePeriodSizeInFrames) {
-                    ma_uint32 capturedDeviceFramesRemaining;
-                    ma_uint32 capturedDeviceFramesProcessed;
-                    ma_uint32 capturedDeviceFramesToProcess;
-                    ma_uint32 capturedDeviceFramesToTryProcessing = capturedDevicePeriodSizeInFrames - totalCapturedDeviceFramesProcessed;
-                    if (capturedDeviceFramesToTryProcessing > capturedDeviceDataCapInFrames) {
-                        capturedDeviceFramesToTryProcessing = capturedDeviceDataCapInFrames;
-                    }
-
-                    result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, capturedDeviceFramesToTryProcessing, &capturedDeviceFramesToProcess);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    capturedDeviceFramesRemaining = capturedDeviceFramesToProcess;
-                    capturedDeviceFramesProcessed = 0;
-
-                    /* At this point we have our captured data in device format and we now need to convert it to client format. */
-                    for (;;) {
-                        ma_uint8  capturedClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                        ma_uint8  playbackClientData[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                        ma_uint32 capturedClientDataCapInFrames = sizeof(capturedClientData) / ma_get_bytes_per_frame(pDevice->capture.format,  pDevice->capture.channels);
-                        ma_uint32 playbackClientDataCapInFrames = sizeof(playbackClientData) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-                        ma_uint64 capturedClientFramesToProcessThisIteration = ma_min(capturedClientDataCapInFrames, playbackClientDataCapInFrames);
-                        ma_uint64 capturedDeviceFramesToProcessThisIteration = capturedDeviceFramesRemaining;
-                        ma_uint8* pRunningCapturedDeviceFrames = ma_offset_ptr(capturedDeviceData, capturedDeviceFramesProcessed * ma_get_bytes_per_frame(pDevice->capture.internalFormat,  pDevice->capture.internalChannels));
-
-                        /* Convert capture data from device format to client format. */
-                        result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningCapturedDeviceFrames, &capturedDeviceFramesToProcessThisIteration, capturedClientData, &capturedClientFramesToProcessThisIteration);
-                        if (result != MA_SUCCESS) {
-                            break;
-                        }
-
-                        /*
-                        If we weren't able to generate any output frames it must mean we've exhaused all of our input. The only time this would not be the case is if capturedClientData was too small
-                        which should never be the case when it's of the size MA_DATA_CONVERTER_STACK_BUFFER_SIZE.
-                        */
-                        if (capturedClientFramesToProcessThisIteration == 0) {
-                            break;
-                        }
-
-                        ma_device__on_data(pDevice, playbackClientData, capturedClientData, (ma_uint32)capturedClientFramesToProcessThisIteration);    /* Safe cast .*/
-
-                        capturedDeviceFramesProcessed += (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
-                        capturedDeviceFramesRemaining -= (ma_uint32)capturedDeviceFramesToProcessThisIteration; /* Safe cast. */
-
-                        /* At this point the playbackClientData buffer should be holding data that needs to be written to the device. */
-                        for (;;) {
-                            ma_uint64 convertedClientFrameCount = capturedClientFramesToProcessThisIteration;
-                            ma_uint64 convertedDeviceFrameCount = playbackDeviceDataCapInFrames;
-                            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, playbackClientData, &convertedClientFrameCount, playbackDeviceData, &convertedDeviceFrameCount);
-                            if (result != MA_SUCCESS) {
-                                break;
-                            }
-
-                            result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, (ma_uint32)convertedDeviceFrameCount, NULL);   /* Safe cast. */
-                            if (result != MA_SUCCESS) {
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            capturedClientFramesToProcessThisIteration -= (ma_uint32)convertedClientFrameCount;  /* Safe cast. */
-                            if (capturedClientFramesToProcessThisIteration == 0) {
-                                break;
-                            }
-                        }
-
-                        /* In case an error happened from ma_device_write__null()... */
-                        if (result != MA_SUCCESS) {
-                            exitLoop = MA_TRUE;
-                            break;
-                        }
-                    }
-
-                    totalCapturedDeviceFramesProcessed += capturedDeviceFramesProcessed;
-                }
-            } break;
-
-            case ma_device_type_capture:
-            case ma_device_type_loopback:
-            {
-                ma_uint32 periodSizeInFrames = pDevice->capture.internalPeriodSizeInFrames;
-                ma_uint32 framesReadThisPeriod = 0;
-                while (framesReadThisPeriod < periodSizeInFrames) {
-                    ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesReadThisPeriod;
-                    ma_uint32 framesProcessed;
-                    ma_uint32 framesToReadThisIteration = framesRemainingInPeriod;
-                    if (framesToReadThisIteration > capturedDeviceDataCapInFrames) {
-                        framesToReadThisIteration = capturedDeviceDataCapInFrames;
-                    }
-
-                    result = pDevice->pContext->callbacks.onDeviceRead(pDevice, capturedDeviceData, framesToReadThisIteration, &framesProcessed);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    ma_device__send_frames_to_client(pDevice, framesProcessed, capturedDeviceData);
-
-                    framesReadThisPeriod += framesProcessed;
-                }
-            } break;
-
-            case ma_device_type_playback:
-            {
-                /* We write in chunks of the period size, but use a stack allocated buffer for the intermediary. */
-                ma_uint32 periodSizeInFrames = pDevice->playback.internalPeriodSizeInFrames;
-                ma_uint32 framesWrittenThisPeriod = 0;
-                while (framesWrittenThisPeriod < periodSizeInFrames) {
-                    ma_uint32 framesRemainingInPeriod = periodSizeInFrames - framesWrittenThisPeriod;
-                    ma_uint32 framesProcessed;
-                    ma_uint32 framesToWriteThisIteration = framesRemainingInPeriod;
-                    if (framesToWriteThisIteration > playbackDeviceDataCapInFrames) {
-                        framesToWriteThisIteration = playbackDeviceDataCapInFrames;
-                    }
-
-                    ma_device__read_frames_from_client(pDevice, framesToWriteThisIteration, playbackDeviceData);
-
-                    result = pDevice->pContext->callbacks.onDeviceWrite(pDevice, playbackDeviceData, framesToWriteThisIteration, &framesProcessed);
-                    if (result != MA_SUCCESS) {
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    framesWrittenThisPeriod += framesProcessed;
-                }
-            } break;
-
-            /* Should never get here. */
-            default: break;
-        }
-    }
-
-    return result;
-}
-
-
-
-/*******************************************************************************
-
-Null Backend
-
-*******************************************************************************/
-#ifdef MA_HAS_NULL
-
-#define MA_DEVICE_OP_NONE__NULL    0
-#define MA_DEVICE_OP_START__NULL   1
-#define MA_DEVICE_OP_SUSPEND__NULL 2
-#define MA_DEVICE_OP_KILL__NULL    3
-
-static ma_thread_result MA_THREADCALL ma_device_thread__null(void* pData)
-{
-    ma_device* pDevice = (ma_device*)pData;
-    MA_ASSERT(pDevice != NULL);
-
-    for (;;) {  /* Keep the thread alive until the device is uninitialized. */
-        ma_uint32 operation;
-
-        /* Wait for an operation to be requested. */
-        ma_event_wait(&pDevice->null_device.operationEvent);
-
-        /* At this point an event should have been triggered. */
-        operation = pDevice->null_device.operation;
-
-        /* Starting the device needs to put the thread into a loop. */
-        if (operation == MA_DEVICE_OP_START__NULL) {
-            /* Reset the timer just in case. */
-            ma_timer_init(&pDevice->null_device.timer);
-
-            /* Getting here means a suspend or kill operation has been requested. */
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;
-        }
-
-        /* Suspending the device means we need to stop the timer and just continue the loop. */
-        if (operation == MA_DEVICE_OP_SUSPEND__NULL) {
-            /* We need to add the current run time to the prior run time, then reset the timer. */
-            pDevice->null_device.priorRunTime += ma_timer_get_time_in_seconds(&pDevice->null_device.timer);
-            ma_timer_init(&pDevice->null_device.timer);
-
-            /* We're done. */
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;
-        }
-
-        /* Killing the device means we need to get out of this loop so that this thread can terminate. */
-        if (operation == MA_DEVICE_OP_KILL__NULL) {
-            pDevice->null_device.operationResult = MA_SUCCESS;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            break;
-        }
-
-        /* Getting a signal on a "none" operation probably means an error. Return invalid operation. */
-        if (operation == MA_DEVICE_OP_NONE__NULL) {
-            MA_ASSERT(MA_FALSE);  /* <-- Trigger this in debug mode to ensure developers are aware they're doing something wrong (or there's a bug in a miniaudio). */
-            pDevice->null_device.operationResult = MA_INVALID_OPERATION;
-            ma_event_signal(&pDevice->null_device.operationCompletionEvent);
-            ma_semaphore_release(&pDevice->null_device.operationSemaphore);
-            continue;   /* Continue the loop. Don't terminate. */
-        }
-    }
-
-    return (ma_thread_result)0;
-}
-
-static ma_result ma_device_do_operation__null(ma_device* pDevice, ma_uint32 operation)
-{
-    ma_result result;
-
-    /*
-    TODO: Need to review this and consider just using mutual exclusion. I think the original motivation
-    for this was to just post the event to a queue and return immediately, but that has since changed
-    and now this function is synchronous. I think this can be simplified to just use a mutex.
-    */
-
-    /*
-    The first thing to do is wait for an operation slot to become available. We only have a single slot for this, but we could extend this later
-    to support queing of operations.
-    */
-    result = ma_semaphore_wait(&pDevice->null_device.operationSemaphore);
-    if (result != MA_SUCCESS) {
-        return result;  /* Failed to wait for the event. */
-    }
-
-    /*
-    When we get here it means the background thread is not referencing the operation code and it can be changed. After changing this we need to
-    signal an event to the worker thread to let it know that it can start work.
-    */
-    pDevice->null_device.operation = operation;
-
-    /* Once the operation code has been set, the worker thread can start work. */
-    if (ma_event_signal(&pDevice->null_device.operationEvent) != MA_SUCCESS) {
-        return MA_ERROR;
-    }
-
-    /* We want everything to be synchronous so we're going to wait for the worker thread to complete it's operation. */
-    if (ma_event_wait(&pDevice->null_device.operationCompletionEvent) != MA_SUCCESS) {
-        return MA_ERROR;
-    }
-
-    return pDevice->null_device.operationResult;
-}
-
-static ma_uint64 ma_device_get_total_run_time_in_frames__null(ma_device* pDevice)
-{
-    ma_uint32 internalSampleRate;
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        internalSampleRate = pDevice->capture.internalSampleRate;
-    } else {
-        internalSampleRate = pDevice->playback.internalSampleRate;
-    }
-
-    return (ma_uint64)((pDevice->null_device.priorRunTime + ma_timer_get_time_in_seconds(&pDevice->null_device.timer)) * internalSampleRate);
-}
-
-static ma_result ma_context_enumerate_devices__null(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Playback Device", (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), "NULL Capture Device", (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    (void)cbResult; /* Silence a static analysis warning. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__null(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (pDeviceID != NULL && pDeviceID->nullbackend != 0) {
-        return MA_NO_DEVICE;   /* Don't know the device. */
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Playback Device", (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), "NULL Capture Device", (size_t)-1);
-    }
-
-    /* Support everything on the null backend. */
-    pDeviceInfo->nativeDataFormats[0].format     = ma_format_unknown;
-    pDeviceInfo->nativeDataFormats[0].channels   = 0;
-    pDeviceInfo->nativeDataFormats[0].sampleRate = 0;
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* Keep it clean and wait for the device thread to finish before returning. */
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_KILL__NULL);
-
-    /* Wait for the thread to finish before continuing. */
-    ma_thread_wait(&pDevice->null_device.deviceThread);
-
-    /* At this point the loop in the device thread is as good as terminated so we can uninitialize our events. */
-    ma_semaphore_uninit(&pDevice->null_device.operationSemaphore);
-    ma_event_uninit(&pDevice->null_device.operationCompletionEvent);
-    ma_event_uninit(&pDevice->null_device.operationEvent);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__null(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->null_device);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* The null backend supports everything exactly as we specify it. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        pDescriptorCapture->format     = (pDescriptorCapture->format     != ma_format_unknown) ? pDescriptorCapture->format     : MA_DEFAULT_FORMAT;
-        pDescriptorCapture->channels   = (pDescriptorCapture->channels   != 0)                 ? pDescriptorCapture->channels   : MA_DEFAULT_CHANNELS;
-        pDescriptorCapture->sampleRate = (pDescriptorCapture->sampleRate != 0)                 ? pDescriptorCapture->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-        if (pDescriptorCapture->channelMap[0] == MA_CHANNEL_NONE) {
-            ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        }
-
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        pDescriptorPlayback->format     = (pDescriptorPlayback->format     != ma_format_unknown) ? pDescriptorPlayback->format     : MA_DEFAULT_FORMAT;
-        pDescriptorPlayback->channels   = (pDescriptorPlayback->channels   != 0)                 ? pDescriptorPlayback->channels   : MA_DEFAULT_CHANNELS;
-        pDescriptorPlayback->sampleRate = (pDescriptorPlayback->sampleRate != 0)                 ? pDescriptorPlayback->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-        if (pDescriptorPlayback->channelMap[0] == MA_CHANNEL_NONE) {
-            ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        }
-
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-    }
-
-    /*
-    In order to get timing right, we need to create a thread that does nothing but keeps track of the timer. This timer is started when the
-    first period is "written" to it, and then stopped in ma_device_stop__null().
-    */
-    result = ma_event_init(&pDevice->null_device.operationEvent);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_event_init(&pDevice->null_device.operationCompletionEvent);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_semaphore_init(1, &pDevice->null_device.operationSemaphore);    /* <-- It's important that the initial value is set to 1. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_thread_create(&pDevice->null_device.deviceThread, pDevice->pContext->threadPriority, 0, ma_device_thread__null, pDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL);
-
-    c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_TRUE);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__null(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL);
-
-    c89atomic_exchange_32(&pDevice->null_device.isStarted, MA_FALSE);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__null(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 totalPCMFramesProcessed;
-    ma_bool32 wasStartedOnEntry;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    wasStartedOnEntry = c89atomic_load_32(&pDevice->null_device.isStarted);
-
-    /* Keep going until everything has been read. */
-    totalPCMFramesProcessed = 0;
-    while (totalPCMFramesProcessed < frameCount) {
-        ma_uint64 targetFrame;
-
-        /* If there are any frames remaining in the current period, consume those first. */
-        if (pDevice->null_device.currentPeriodFramesRemainingPlayback > 0) {
-            ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed);
-            ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingPlayback;
-            if (framesToProcess > framesRemaining) {
-                framesToProcess = framesRemaining;
-            }
-
-            /* We don't actually do anything with pPCMFrames, so just mark it as unused to prevent a warning. */
-            (void)pPCMFrames;
-
-            pDevice->null_device.currentPeriodFramesRemainingPlayback -= framesToProcess;
-            totalPCMFramesProcessed += framesToProcess;
-        }
-
-        /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */
-        if (pDevice->null_device.currentPeriodFramesRemainingPlayback == 0) {
-            pDevice->null_device.currentPeriodFramesRemainingPlayback = 0;
-
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted) && !wasStartedOnEntry) {
-                result = ma_device_start__null(pDevice);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            }
-        }
-
-        /* If we've consumed the whole buffer we can return now. */
-        MA_ASSERT(totalPCMFramesProcessed <= frameCount);
-        if (totalPCMFramesProcessed == frameCount) {
-            break;
-        }
-
-        /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
-        targetFrame = pDevice->null_device.lastProcessedFramePlayback;
-        for (;;) {
-            ma_uint64 currentFrame;
-
-            /* Stop waiting if the device has been stopped. */
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
-                break;
-            }
-
-            currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice);
-            if (currentFrame >= targetFrame) {
-                break;
-            }
-
-            /* Getting here means we haven't yet reached the target sample, so continue waiting. */
-            ma_sleep(10);
-        }
-
-        pDevice->null_device.lastProcessedFramePlayback          += pDevice->playback.internalPeriodSizeInFrames;
-        pDevice->null_device.currentPeriodFramesRemainingPlayback = pDevice->playback.internalPeriodSizeInFrames;
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = totalPCMFramesProcessed;
-    }
-
-    return result;
-}
-
-static ma_result ma_device_read__null(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 totalPCMFramesProcessed;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    /* Keep going until everything has been read. */
-    totalPCMFramesProcessed = 0;
-    while (totalPCMFramesProcessed < frameCount) {
-        ma_uint64 targetFrame;
-
-        /* If there are any frames remaining in the current period, consume those first. */
-        if (pDevice->null_device.currentPeriodFramesRemainingCapture > 0) {
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-            ma_uint32 framesRemaining = (frameCount - totalPCMFramesProcessed);
-            ma_uint32 framesToProcess = pDevice->null_device.currentPeriodFramesRemainingCapture;
-            if (framesToProcess > framesRemaining) {
-                framesToProcess = framesRemaining;
-            }
-
-            /* We need to ensure the output buffer is zeroed. */
-            MA_ZERO_MEMORY(ma_offset_ptr(pPCMFrames, totalPCMFramesProcessed*bpf), framesToProcess*bpf);
-
-            pDevice->null_device.currentPeriodFramesRemainingCapture -= framesToProcess;
-            totalPCMFramesProcessed += framesToProcess;
-        }
-
-        /* If we've consumed the current period we'll need to mark it as such an ensure the device is started if it's not already. */
-        if (pDevice->null_device.currentPeriodFramesRemainingCapture == 0) {
-            pDevice->null_device.currentPeriodFramesRemainingCapture = 0;
-        }
-
-        /* If we've consumed the whole buffer we can return now. */
-        MA_ASSERT(totalPCMFramesProcessed <= frameCount);
-        if (totalPCMFramesProcessed == frameCount) {
-            break;
-        }
-
-        /* Getting here means we've still got more frames to consume, we but need to wait for it to become available. */
-        targetFrame = pDevice->null_device.lastProcessedFrameCapture + pDevice->capture.internalPeriodSizeInFrames;
-        for (;;) {
-            ma_uint64 currentFrame;
-
-            /* Stop waiting if the device has been stopped. */
-            if (!c89atomic_load_32(&pDevice->null_device.isStarted)) {
-                break;
-            }
-
-            currentFrame = ma_device_get_total_run_time_in_frames__null(pDevice);
-            if (currentFrame >= targetFrame) {
-                break;
-            }
-
-            /* Getting here means we haven't yet reached the target sample, so continue waiting. */
-            ma_sleep(10);
-        }
-
-        pDevice->null_device.lastProcessedFrameCapture          += pDevice->capture.internalPeriodSizeInFrames;
-        pDevice->null_device.currentPeriodFramesRemainingCapture = pDevice->capture.internalPeriodSizeInFrames;
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = totalPCMFramesProcessed;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_uninit__null(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_null);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__null(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-    (void)pContext;
-
-    pCallbacks->onContextInit             = ma_context_init__null;
-    pCallbacks->onContextUninit           = ma_context_uninit__null;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__null;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__null;
-    pCallbacks->onDeviceInit              = ma_device_init__null;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__null;
-    pCallbacks->onDeviceStart             = ma_device_start__null;
-    pCallbacks->onDeviceStop              = ma_device_stop__null;
-    pCallbacks->onDeviceRead              = ma_device_read__null;
-    pCallbacks->onDeviceWrite             = ma_device_write__null;
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Our backend is asynchronous with a blocking read-write API which means we can get miniaudio to deal with the audio thread. */
-
-    /* The null backend always works. */
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-/*******************************************************************************
-
-WIN32 COMMON
-
-*******************************************************************************/
-#if defined(MA_WIN32)
-#if defined(MA_WIN32_DESKTOP)
-    #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit)                          ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit)
-    #define ma_CoUninitialize(pContext)                                                ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)()
-    #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv)  ((MA_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv)
-    #define ma_CoTaskMemFree(pContext, pv)                                             ((MA_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv)
-    #define ma_PropVariantClear(pContext, pvar)                                        ((MA_PFN_PropVariantClear)pContext->win32.PropVariantClear)(pvar)
-#else
-    #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit)                          CoInitializeEx(pvReserved, dwCoInit)
-    #define ma_CoUninitialize(pContext)                                                CoUninitialize()
-    #define ma_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv)  CoCreateInstance(rclsid, pUnkOuter, dwClsContext, riid, ppv)
-    #define ma_CoTaskMemFree(pContext, pv)                                             CoTaskMemFree(pv)
-    #define ma_PropVariantClear(pContext, pvar)                                        PropVariantClear(pvar)
-#endif
-
-#if !defined(MAXULONG_PTR) && !defined(__WATCOMC__)
-typedef size_t DWORD_PTR;
-#endif
-
-#if !defined(WAVE_FORMAT_44M08)
-#define WAVE_FORMAT_44M08 0x00000100
-#define WAVE_FORMAT_44S08 0x00000200
-#define WAVE_FORMAT_44M16 0x00000400
-#define WAVE_FORMAT_44S16 0x00000800
-#define WAVE_FORMAT_48M08 0x00001000
-#define WAVE_FORMAT_48S08 0x00002000
-#define WAVE_FORMAT_48M16 0x00004000
-#define WAVE_FORMAT_48S16 0x00008000
-#define WAVE_FORMAT_96M08 0x00010000
-#define WAVE_FORMAT_96S08 0x00020000
-#define WAVE_FORMAT_96M16 0x00040000
-#define WAVE_FORMAT_96S16 0x00080000
-#endif
-
-#ifndef SPEAKER_FRONT_LEFT
-#define SPEAKER_FRONT_LEFT            0x1
-#define SPEAKER_FRONT_RIGHT           0x2
-#define SPEAKER_FRONT_CENTER          0x4
-#define SPEAKER_LOW_FREQUENCY         0x8
-#define SPEAKER_BACK_LEFT             0x10
-#define SPEAKER_BACK_RIGHT            0x20
-#define SPEAKER_FRONT_LEFT_OF_CENTER  0x40
-#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
-#define SPEAKER_BACK_CENTER           0x100
-#define SPEAKER_SIDE_LEFT             0x200
-#define SPEAKER_SIDE_RIGHT            0x400
-#define SPEAKER_TOP_CENTER            0x800
-#define SPEAKER_TOP_FRONT_LEFT        0x1000
-#define SPEAKER_TOP_FRONT_CENTER      0x2000
-#define SPEAKER_TOP_FRONT_RIGHT       0x4000
-#define SPEAKER_TOP_BACK_LEFT         0x8000
-#define SPEAKER_TOP_BACK_CENTER       0x10000
-#define SPEAKER_TOP_BACK_RIGHT        0x20000
-#endif
-
-/*
-The SDK that comes with old versions of MSVC (VC6, for example) does not appear to define WAVEFORMATEXTENSIBLE. We
-define our own implementation in this case.
-*/
-#if (defined(_MSC_VER) && !defined(_WAVEFORMATEXTENSIBLE_)) || defined(__DMC__)
-typedef struct
-{
-    WAVEFORMATEX Format;
-    union
-    {
-        WORD wValidBitsPerSample;
-        WORD wSamplesPerBlock;
-        WORD wReserved;
-    } Samples;
-    DWORD dwChannelMask;
-    GUID SubFormat;
-} WAVEFORMATEXTENSIBLE;
-#endif
-
-#ifndef WAVE_FORMAT_EXTENSIBLE
-#define WAVE_FORMAT_EXTENSIBLE  0xFFFE
-#endif
-
-#ifndef WAVE_FORMAT_IEEE_FLOAT
-#define WAVE_FORMAT_IEEE_FLOAT  0x0003
-#endif
-
-/* Converts an individual Win32-style channel identifier (SPEAKER_FRONT_LEFT, etc.) to miniaudio. */
-static ma_uint8 ma_channel_id_to_ma__win32(DWORD id)
-{
-    switch (id)
-    {
-        case SPEAKER_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case SPEAKER_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case SPEAKER_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case SPEAKER_LOW_FREQUENCY:         return MA_CHANNEL_LFE;
-        case SPEAKER_BACK_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case SPEAKER_BACK_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case SPEAKER_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case SPEAKER_BACK_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case SPEAKER_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case SPEAKER_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case SPEAKER_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case SPEAKER_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case SPEAKER_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case SPEAKER_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case SPEAKER_TOP_BACK_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case SPEAKER_TOP_BACK_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        case SPEAKER_TOP_BACK_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to Win32-style. */
-static DWORD ma_channel_id_to_win32(DWORD id)
-{
-    switch (id)
-    {
-        case MA_CHANNEL_MONO:               return SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_FRONT_LEFT:         return SPEAKER_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return SPEAKER_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return SPEAKER_LOW_FREQUENCY;
-        case MA_CHANNEL_BACK_LEFT:          return SPEAKER_BACK_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return SPEAKER_BACK_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return SPEAKER_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return SPEAKER_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return SPEAKER_BACK_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return SPEAKER_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return SPEAKER_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return SPEAKER_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return SPEAKER_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return SPEAKER_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return SPEAKER_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return SPEAKER_TOP_BACK_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return SPEAKER_TOP_BACK_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return SPEAKER_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts a channel mapping to a Win32-style channel mask. */
-static DWORD ma_channel_map_to_channel_mask__win32(const ma_channel* pChannelMap, ma_uint32 channels)
-{
-    DWORD dwChannelMask = 0;
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        dwChannelMask |= ma_channel_id_to_win32(pChannelMap[iChannel]);
-    }
-
-    return dwChannelMask;
-}
-
-/* Converts a Win32-style channel mask to a miniaudio channel map. */
-static void ma_channel_mask_to_channel_map__win32(DWORD dwChannelMask, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (channels == 1 && dwChannelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_MONO;
-    } else if (channels == 2 && dwChannelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-        pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-    } else {
-        if (channels == 1 && (dwChannelMask & SPEAKER_FRONT_CENTER) != 0) {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } else {
-            /* Just iterate over each bit. */
-            ma_uint32 iChannel = 0;
-            ma_uint32 iBit;
-
-            for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) {
-                DWORD bitValue = (dwChannelMask & (1UL << iBit));
-                if (bitValue != 0) {
-                    /* The bit is set. */
-                    pChannelMap[iChannel] = ma_channel_id_to_ma__win32(bitValue);
-                    iChannel += 1;
-                }
-            }
-        }
-    }
-}
-
-#ifdef __cplusplus
-static ma_bool32 ma_is_guid_equal(const void* a, const void* b)
-{
-    return IsEqualGUID(*(const GUID*)a, *(const GUID*)b);
-}
-#else
-#define ma_is_guid_equal(a, b) IsEqualGUID((const GUID*)a, (const GUID*)b)
-#endif
-
-static MA_INLINE ma_bool32 ma_is_guid_null(const void* guid)
-{
-    static GUID nullguid = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
-    return ma_is_guid_equal(guid, &nullguid);
-}
-
-static ma_format ma_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF)
-{
-    MA_ASSERT(pWF != NULL);
-
-    if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-        const WAVEFORMATEXTENSIBLE* pWFEX = (const WAVEFORMATEXTENSIBLE*)pWF;
-        if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_PCM)) {
-            if (pWFEX->Samples.wValidBitsPerSample == 32) {
-                return ma_format_s32;
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 24) {
-                if (pWFEX->Format.wBitsPerSample == 32) {
-                    /*return ma_format_s24_32;*/
-                }
-                if (pWFEX->Format.wBitsPerSample == 24) {
-                    return ma_format_s24;
-                }
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 16) {
-                return ma_format_s16;
-            }
-            if (pWFEX->Samples.wValidBitsPerSample == 8) {
-                return ma_format_u8;
-            }
-        }
-        if (ma_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) {
-            if (pWFEX->Samples.wValidBitsPerSample == 32) {
-                return ma_format_f32;
-            }
-            /*
-            if (pWFEX->Samples.wValidBitsPerSample == 64) {
-                return ma_format_f64;
-            }
-            */
-        }
-    } else {
-        if (pWF->wFormatTag == WAVE_FORMAT_PCM) {
-            if (pWF->wBitsPerSample == 32) {
-                return ma_format_s32;
-            }
-            if (pWF->wBitsPerSample == 24) {
-                return ma_format_s24;
-            }
-            if (pWF->wBitsPerSample == 16) {
-                return ma_format_s16;
-            }
-            if (pWF->wBitsPerSample == 8) {
-                return ma_format_u8;
-            }
-        }
-        if (pWF->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) {
-            if (pWF->wBitsPerSample == 32) {
-                return ma_format_f32;
-            }
-            if (pWF->wBitsPerSample == 64) {
-                /*return ma_format_f64;*/
-            }
-        }
-    }
-
-    return ma_format_unknown;
-}
-#endif
-
-
-/*******************************************************************************
-
-WASAPI Backend
-
-*******************************************************************************/
-#ifdef MA_HAS_WASAPI
-#if 0
-#if defined(_MSC_VER)
-    #pragma warning(push)
-    #pragma warning(disable:4091)   /* 'typedef ': ignored on left of '' when no variable is declared */
-#endif
-#include <audioclient.h>
-#include <mmdeviceapi.h>
-#if defined(_MSC_VER)
-    #pragma warning(pop)
-#endif
-#endif  /* 0 */
-
-static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType);
-
-/* Some compilers don't define VerifyVersionInfoW. Need to write this ourselves. */
-#define MA_WIN32_WINNT_VISTA    0x0600
-#define MA_VER_MINORVERSION     0x01
-#define MA_VER_MAJORVERSION     0x02
-#define MA_VER_SERVICEPACKMAJOR 0x20
-#define MA_VER_GREATER_EQUAL    0x03
-
-typedef struct  {
-    DWORD dwOSVersionInfoSize;
-    DWORD dwMajorVersion;
-    DWORD dwMinorVersion;
-    DWORD dwBuildNumber;
-    DWORD dwPlatformId;
-    WCHAR szCSDVersion[128];
-    WORD  wServicePackMajor;
-    WORD  wServicePackMinor;
-    WORD  wSuiteMask;
-    BYTE  wProductType;
-    BYTE  wReserved;
-} ma_OSVERSIONINFOEXW;
-
-typedef BOOL      (WINAPI * ma_PFNVerifyVersionInfoW) (ma_OSVERSIONINFOEXW* lpVersionInfo, DWORD dwTypeMask, DWORDLONG dwlConditionMask);
-typedef ULONGLONG (WINAPI * ma_PFNVerSetConditionMask)(ULONGLONG dwlConditionMask, DWORD dwTypeBitMask, BYTE dwConditionMask);
-
-
-#ifndef PROPERTYKEY_DEFINED
-#define PROPERTYKEY_DEFINED
-#ifndef __WATCOMC__
-typedef struct
-{
-    GUID fmtid;
-    DWORD pid;
-} PROPERTYKEY;
-#endif
-#endif
-
-/* Some compilers don't define PropVariantInit(). We just do this ourselves since it's just a memset(). */
-static MA_INLINE void ma_PropVariantInit(PROPVARIANT* pProp)
-{
-    MA_ZERO_OBJECT(pProp);
-}
-
-
-static const PROPERTYKEY MA_PKEY_Device_FriendlyName             = {{0xA45C254E, 0xDF1C, 0x4EFD, {0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0}}, 14};
-static const PROPERTYKEY MA_PKEY_AudioEngine_DeviceFormat        = {{0xF19F064D, 0x82C,  0x4E27, {0xBC, 0x73, 0x68, 0x82, 0xA1, 0xBB, 0x8E, 0x4C}},  0};
-
-static const IID MA_IID_IUnknown                                 = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; /* 00000000-0000-0000-C000-000000000046 */
-#ifndef MA_WIN32_DESKTOP
-static const IID MA_IID_IAgileObject                             = {0x94EA2B94, 0xE9CC, 0x49E0, {0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90}}; /* 94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90 */
-#endif
-
-static const IID MA_IID_IAudioClient                             = {0x1CB9AD4C, 0xDBFA, 0x4C32, {0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2}}; /* 1CB9AD4C-DBFA-4C32-B178-C2F568A703B2 = __uuidof(IAudioClient) */
-static const IID MA_IID_IAudioClient2                            = {0x726778CD, 0xF60A, 0x4EDA, {0x82, 0xDE, 0xE4, 0x76, 0x10, 0xCD, 0x78, 0xAA}}; /* 726778CD-F60A-4EDA-82DE-E47610CD78AA = __uuidof(IAudioClient2) */
-static const IID MA_IID_IAudioClient3                            = {0x7ED4EE07, 0x8E67, 0x4CD4, {0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42}}; /* 7ED4EE07-8E67-4CD4-8C1A-2B7A5987AD42 = __uuidof(IAudioClient3) */
-static const IID MA_IID_IAudioRenderClient                       = {0xF294ACFC, 0x3146, 0x4483, {0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2}}; /* F294ACFC-3146-4483-A7BF-ADDCA7C260E2 = __uuidof(IAudioRenderClient) */
-static const IID MA_IID_IAudioCaptureClient                      = {0xC8ADBD64, 0xE71E, 0x48A0, {0xA4, 0xDE, 0x18, 0x5C, 0x39, 0x5C, 0xD3, 0x17}}; /* C8ADBD64-E71E-48A0-A4DE-185C395CD317 = __uuidof(IAudioCaptureClient) */
-static const IID MA_IID_IMMNotificationClient                    = {0x7991EEC9, 0x7E89, 0x4D85, {0x83, 0x90, 0x6C, 0x70, 0x3C, 0xEC, 0x60, 0xC0}}; /* 7991EEC9-7E89-4D85-8390-6C703CEC60C0 = __uuidof(IMMNotificationClient) */
-#ifndef MA_WIN32_DESKTOP
-static const IID MA_IID_DEVINTERFACE_AUDIO_RENDER                = {0xE6327CAD, 0xDCEC, 0x4949, {0xAE, 0x8A, 0x99, 0x1E, 0x97, 0x6A, 0x79, 0xD2}}; /* E6327CAD-DCEC-4949-AE8A-991E976A79D2 */
-static const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE               = {0x2EEF81BE, 0x33FA, 0x4800, {0x96, 0x70, 0x1C, 0xD4, 0x74, 0x97, 0x2C, 0x3F}}; /* 2EEF81BE-33FA-4800-9670-1CD474972C3F */
-static const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; /* 41D949AB-9862-444A-80F6-C261334DA5EB */
-#endif
-
-static const IID MA_CLSID_MMDeviceEnumerator_Instance            = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
-static const IID MA_IID_IMMDeviceEnumerator_Instance             = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
-#ifdef __cplusplus
-#define MA_CLSID_MMDeviceEnumerator MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator  MA_IID_IMMDeviceEnumerator_Instance
-#else
-#define MA_CLSID_MMDeviceEnumerator &MA_CLSID_MMDeviceEnumerator_Instance
-#define MA_IID_IMMDeviceEnumerator  &MA_IID_IMMDeviceEnumerator_Instance
-#endif
-
-typedef struct ma_IUnknown                                 ma_IUnknown;
-#ifdef MA_WIN32_DESKTOP
-#define MA_MM_DEVICE_STATE_ACTIVE                          1
-#define MA_MM_DEVICE_STATE_DISABLED                        2
-#define MA_MM_DEVICE_STATE_NOTPRESENT                      4
-#define MA_MM_DEVICE_STATE_UNPLUGGED                       8
-
-typedef struct ma_IMMDeviceEnumerator                      ma_IMMDeviceEnumerator;
-typedef struct ma_IMMDeviceCollection                      ma_IMMDeviceCollection;
-typedef struct ma_IMMDevice                                ma_IMMDevice;
-#else
-typedef struct ma_IActivateAudioInterfaceCompletionHandler ma_IActivateAudioInterfaceCompletionHandler;
-typedef struct ma_IActivateAudioInterfaceAsyncOperation    ma_IActivateAudioInterfaceAsyncOperation;
-#endif
-typedef struct ma_IPropertyStore                           ma_IPropertyStore;
-typedef struct ma_IAudioClient                             ma_IAudioClient;
-typedef struct ma_IAudioClient2                            ma_IAudioClient2;
-typedef struct ma_IAudioClient3                            ma_IAudioClient3;
-typedef struct ma_IAudioRenderClient                       ma_IAudioRenderClient;
-typedef struct ma_IAudioCaptureClient                      ma_IAudioCaptureClient;
-
-typedef ma_int64                                           MA_REFERENCE_TIME;
-
-#define MA_AUDCLNT_STREAMFLAGS_CROSSPROCESS                0x00010000
-#define MA_AUDCLNT_STREAMFLAGS_LOOPBACK                    0x00020000
-#define MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK               0x00040000
-#define MA_AUDCLNT_STREAMFLAGS_NOPERSIST                   0x00080000
-#define MA_AUDCLNT_STREAMFLAGS_RATEADJUST                  0x00100000
-#define MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY         0x08000000
-#define MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM              0x80000000
-#define MA_AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED          0x10000000
-#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE               0x20000000
-#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED    0x40000000
-
-/* Buffer flags. */
-#define MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY          1
-#define MA_AUDCLNT_BUFFERFLAGS_SILENT                      2
-#define MA_AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR             4
-
-typedef enum
-{
-    ma_eRender  = 0,
-    ma_eCapture = 1,
-    ma_eAll     = 2
-} ma_EDataFlow;
-
-typedef enum
-{
-    ma_eConsole        = 0,
-    ma_eMultimedia     = 1,
-    ma_eCommunications = 2
-} ma_ERole;
-
-typedef enum
-{
-    MA_AUDCLNT_SHAREMODE_SHARED,
-    MA_AUDCLNT_SHAREMODE_EXCLUSIVE
-} MA_AUDCLNT_SHAREMODE;
-
-typedef enum
-{
-    MA_AudioCategory_Other = 0  /* <-- miniaudio is only caring about Other. */
-} MA_AUDIO_STREAM_CATEGORY;
-
-typedef struct
-{
-    ma_uint32 cbSize;
-    BOOL bIsOffload;
-    MA_AUDIO_STREAM_CATEGORY eCategory;
-} ma_AudioClientProperties;
-
-/* IUnknown */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IUnknown* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IUnknown* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IUnknown* pThis);
-} ma_IUnknownVtbl;
-struct ma_IUnknown
-{
-    ma_IUnknownVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IUnknown_QueryInterface(ma_IUnknown* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IUnknown_AddRef(ma_IUnknown* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IUnknown_Release(ma_IUnknown* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-
-#ifdef MA_WIN32_DESKTOP
-    /* IMMNotificationClient */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMNotificationClient* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMNotificationClient* pThis);
-
-        /* IMMNotificationClient */
-        HRESULT (STDMETHODCALLTYPE * OnDeviceStateChanged)  (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState);
-        HRESULT (STDMETHODCALLTYPE * OnDeviceAdded)         (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnDeviceRemoved)       (ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnDefaultDeviceChanged)(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID);
-        HRESULT (STDMETHODCALLTYPE * OnPropertyValueChanged)(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key);
-    } ma_IMMNotificationClientVtbl;
-
-    /* IMMDeviceEnumerator */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDeviceEnumerator* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDeviceEnumerator* pThis);
-
-        /* IMMDeviceEnumerator */
-        HRESULT (STDMETHODCALLTYPE * EnumAudioEndpoints)                    (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices);
-        HRESULT (STDMETHODCALLTYPE * GetDefaultAudioEndpoint)               (ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint);
-        HRESULT (STDMETHODCALLTYPE * GetDevice)                             (ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice);
-        HRESULT (STDMETHODCALLTYPE * RegisterEndpointNotificationCallback)  (ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
-        HRESULT (STDMETHODCALLTYPE * UnregisterEndpointNotificationCallback)(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient);
-    } ma_IMMDeviceEnumeratorVtbl;
-    struct ma_IMMDeviceEnumerator
-    {
-        ma_IMMDeviceEnumeratorVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_QueryInterface(ma_IMMDeviceEnumerator* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDeviceEnumerator_AddRef(ma_IMMDeviceEnumerator* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDeviceEnumerator_Release(ma_IMMDeviceEnumerator* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_EnumAudioEndpoints(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, DWORD dwStateMask, ma_IMMDeviceCollection** ppDevices) { return pThis->lpVtbl->EnumAudioEndpoints(pThis, dataFlow, dwStateMask, ppDevices); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(ma_IMMDeviceEnumerator* pThis, ma_EDataFlow dataFlow, ma_ERole role, ma_IMMDevice** ppEndpoint) { return pThis->lpVtbl->GetDefaultAudioEndpoint(pThis, dataFlow, role, ppEndpoint); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_GetDevice(ma_IMMDeviceEnumerator* pThis, LPCWSTR pID, ma_IMMDevice** ppDevice)        { return pThis->lpVtbl->GetDevice(pThis, pID, ppDevice); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_RegisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->RegisterEndpointNotificationCallback(pThis, pClient); }
-    static MA_INLINE HRESULT ma_IMMDeviceEnumerator_UnregisterEndpointNotificationCallback(ma_IMMDeviceEnumerator* pThis, ma_IMMNotificationClient* pClient) { return pThis->lpVtbl->UnregisterEndpointNotificationCallback(pThis, pClient); }
-
-
-    /* IMMDeviceCollection */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDeviceCollection* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDeviceCollection* pThis);
-
-        /* IMMDeviceCollection */
-        HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IMMDeviceCollection* pThis, UINT* pDevices);
-        HRESULT (STDMETHODCALLTYPE * Item)    (ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice);
-    } ma_IMMDeviceCollectionVtbl;
-    struct ma_IMMDeviceCollection
-    {
-        ma_IMMDeviceCollectionVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_QueryInterface(ma_IMMDeviceCollection* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDeviceCollection_AddRef(ma_IMMDeviceCollection* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDeviceCollection_Release(ma_IMMDeviceCollection* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_GetCount(ma_IMMDeviceCollection* pThis, UINT* pDevices)                               { return pThis->lpVtbl->GetCount(pThis, pDevices); }
-    static MA_INLINE HRESULT ma_IMMDeviceCollection_Item(ma_IMMDeviceCollection* pThis, UINT nDevice, ma_IMMDevice** ppDevice)            { return pThis->lpVtbl->Item(pThis, nDevice, ppDevice); }
-
-
-    /* IMMDevice */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IMMDevice* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IMMDevice* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IMMDevice* pThis);
-
-        /* IMMDevice */
-        HRESULT (STDMETHODCALLTYPE * Activate)         (ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface);
-        HRESULT (STDMETHODCALLTYPE * OpenPropertyStore)(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties);
-        HRESULT (STDMETHODCALLTYPE * GetId)            (ma_IMMDevice* pThis, LPWSTR *pID);
-        HRESULT (STDMETHODCALLTYPE * GetState)         (ma_IMMDevice* pThis, DWORD *pState);
-    } ma_IMMDeviceVtbl;
-    struct ma_IMMDevice
-    {
-        ma_IMMDeviceVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IMMDevice_QueryInterface(ma_IMMDevice* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IMMDevice_AddRef(ma_IMMDevice* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IMMDevice_Release(ma_IMMDevice* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IMMDevice_Activate(ma_IMMDevice* pThis, const IID* const iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface) { return pThis->lpVtbl->Activate(pThis, iid, dwClsCtx, pActivationParams, ppInterface); }
-    static MA_INLINE HRESULT ma_IMMDevice_OpenPropertyStore(ma_IMMDevice* pThis, DWORD stgmAccess, ma_IPropertyStore** ppProperties) { return pThis->lpVtbl->OpenPropertyStore(pThis, stgmAccess, ppProperties); }
-    static MA_INLINE HRESULT ma_IMMDevice_GetId(ma_IMMDevice* pThis, LPWSTR *pID)                                     { return pThis->lpVtbl->GetId(pThis, pID); }
-    static MA_INLINE HRESULT ma_IMMDevice_GetState(ma_IMMDevice* pThis, DWORD *pState)                                { return pThis->lpVtbl->GetState(pThis, pState); }
-#else
-    /* IActivateAudioInterfaceAsyncOperation */
-    typedef struct
-    {
-        /* IUnknown */
-        HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject);
-        ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IActivateAudioInterfaceAsyncOperation* pThis);
-        ULONG   (STDMETHODCALLTYPE * Release)       (ma_IActivateAudioInterfaceAsyncOperation* pThis);
-
-        /* IActivateAudioInterfaceAsyncOperation */
-        HRESULT (STDMETHODCALLTYPE * GetActivateResult)(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface);
-    } ma_IActivateAudioInterfaceAsyncOperationVtbl;
-    struct ma_IActivateAudioInterfaceAsyncOperation
-    {
-        ma_IActivateAudioInterfaceAsyncOperationVtbl* lpVtbl;
-    };
-    static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_QueryInterface(ma_IActivateAudioInterfaceAsyncOperation* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-    static MA_INLINE ULONG   ma_IActivateAudioInterfaceAsyncOperation_AddRef(ma_IActivateAudioInterfaceAsyncOperation* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-    static MA_INLINE ULONG   ma_IActivateAudioInterfaceAsyncOperation_Release(ma_IActivateAudioInterfaceAsyncOperation* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-    static MA_INLINE HRESULT ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(ma_IActivateAudioInterfaceAsyncOperation* pThis, HRESULT *pActivateResult, ma_IUnknown** ppActivatedInterface) { return pThis->lpVtbl->GetActivateResult(pThis, pActivateResult, ppActivatedInterface); }
-#endif
-
-/* IPropertyStore */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IPropertyStore* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IPropertyStore* pThis);
-
-    /* IPropertyStore */
-    HRESULT (STDMETHODCALLTYPE * GetCount)(ma_IPropertyStore* pThis, DWORD* pPropCount);
-    HRESULT (STDMETHODCALLTYPE * GetAt)   (ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey);
-    HRESULT (STDMETHODCALLTYPE * GetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar);
-    HRESULT (STDMETHODCALLTYPE * SetValue)(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar);
-    HRESULT (STDMETHODCALLTYPE * Commit)  (ma_IPropertyStore* pThis);
-} ma_IPropertyStoreVtbl;
-struct ma_IPropertyStore
-{
-    ma_IPropertyStoreVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IPropertyStore_QueryInterface(ma_IPropertyStore* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IPropertyStore_AddRef(ma_IPropertyStore* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IPropertyStore_Release(ma_IPropertyStore* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetCount(ma_IPropertyStore* pThis, DWORD* pPropCount)                            { return pThis->lpVtbl->GetCount(pThis, pPropCount); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetAt(ma_IPropertyStore* pThis, DWORD propIndex, PROPERTYKEY* pPropKey)          { return pThis->lpVtbl->GetAt(pThis, propIndex, pPropKey); }
-static MA_INLINE HRESULT ma_IPropertyStore_GetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, PROPVARIANT* pPropVar) { return pThis->lpVtbl->GetValue(pThis, pKey, pPropVar); }
-static MA_INLINE HRESULT ma_IPropertyStore_SetValue(ma_IPropertyStore* pThis, const PROPERTYKEY* const pKey, const PROPVARIANT* const pPropVar) { return pThis->lpVtbl->SetValue(pThis, pKey, pPropVar); }
-static MA_INLINE HRESULT ma_IPropertyStore_Commit(ma_IPropertyStore* pThis)                                                 { return pThis->lpVtbl->Commit(pThis); }
-
-
-/* IAudioClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient* pThis, const IID* const riid, void** pp);
-} ma_IAudioClientVtbl;
-struct ma_IAudioClient
-{
-    ma_IAudioClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient_QueryInterface(ma_IAudioClient* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient_AddRef(ma_IAudioClient* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient_Release(ma_IAudioClient* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Initialize(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient_GetBufferSize(ma_IAudioClient* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient_GetStreamLatency(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient_GetCurrentPadding(ma_IAudioClient* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient_IsFormatSupported(ma_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient_GetMixFormat(ma_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient_GetDevicePeriod(ma_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient_Start(ma_IAudioClient* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Stop(ma_IAudioClient* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_Reset(ma_IAudioClient* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient_SetEventHandle(ma_IAudioClient* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient_GetService(ma_IAudioClient* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-
-/* IAudioClient2 */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient2* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient2* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient2* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient2* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient2* pThis, const IID* const riid, void** pp);
-
-    /* IAudioClient2 */
-    HRESULT (STDMETHODCALLTYPE * IsOffloadCapable)   (ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
-    HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
-} ma_IAudioClient2Vtbl;
-struct ma_IAudioClient2
-{
-    ma_IAudioClient2Vtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient2_QueryInterface(ma_IAudioClient2* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient2_AddRef(ma_IAudioClient2* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient2_Release(ma_IAudioClient2* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Initialize(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSize(ma_IAudioClient2* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetStreamLatency(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetCurrentPadding(ma_IAudioClient2* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient2_IsFormatSupported(ma_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetMixFormat(ma_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetDevicePeriod(ma_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient2_Start(ma_IAudioClient2* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Stop(ma_IAudioClient2* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_Reset(ma_IAudioClient2* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient2_SetEventHandle(ma_IAudioClient2* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetService(ma_IAudioClient2* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-static MA_INLINE HRESULT ma_IAudioClient2_IsOffloadCapable(ma_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
-static MA_INLINE HRESULT ma_IAudioClient2_SetClientProperties(ma_IAudioClient2* pThis, const ma_AudioClientProperties* pProperties)           { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient2_GetBufferSizeLimits(ma_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
-
-
-/* IAudioClient3 */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioClient3* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioClient3* pThis);
-
-    /* IAudioClient */
-    HRESULT (STDMETHODCALLTYPE * Initialize)       (ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSize)    (ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames);
-    HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames);
-    HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch);
-    HRESULT (STDMETHODCALLTYPE * GetMixFormat)     (ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat);
-    HRESULT (STDMETHODCALLTYPE * GetDevicePeriod)  (ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod);
-    HRESULT (STDMETHODCALLTYPE * Start)            (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * Stop)             (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * Reset)            (ma_IAudioClient3* pThis);
-    HRESULT (STDMETHODCALLTYPE * SetEventHandle)   (ma_IAudioClient3* pThis, HANDLE eventHandle);
-    HRESULT (STDMETHODCALLTYPE * GetService)       (ma_IAudioClient3* pThis, const IID* const riid, void** pp);
-
-    /* IAudioClient2 */
-    HRESULT (STDMETHODCALLTYPE * IsOffloadCapable)   (ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable);
-    HRESULT (STDMETHODCALLTYPE * SetClientProperties)(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties);
-    HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration);
-
-    /* IAudioClient3 */
-    HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod)       (ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentSharedModeEnginePeriod)(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames);
-    HRESULT (STDMETHODCALLTYPE * InitializeSharedAudioStream)     (ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid);
-} ma_IAudioClient3Vtbl;
-struct ma_IAudioClient3
-{
-    ma_IAudioClient3Vtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioClient3_QueryInterface(ma_IAudioClient3* pThis, const IID* const riid, void** ppObject)    { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioClient3_AddRef(ma_IAudioClient3* pThis)                                                    { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioClient3_Release(ma_IAudioClient3* pThis)                                                   { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Initialize(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSize(ma_IAudioClient3* pThis, ma_uint32* pNumBufferFrames)                { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetStreamLatency(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency)             { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentPadding(ma_IAudioClient3* pThis, ma_uint32* pNumPaddingFrames)           { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_IsFormatSupported(ma_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetMixFormat(ma_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat)               { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetDevicePeriod(ma_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); }
-static MA_INLINE HRESULT ma_IAudioClient3_Start(ma_IAudioClient3* pThis)                                                     { return pThis->lpVtbl->Start(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Stop(ma_IAudioClient3* pThis)                                                      { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_Reset(ma_IAudioClient3* pThis)                                                     { return pThis->lpVtbl->Reset(pThis); }
-static MA_INLINE HRESULT ma_IAudioClient3_SetEventHandle(ma_IAudioClient3* pThis, HANDLE eventHandle)                        { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetService(ma_IAudioClient3* pThis, const IID* const riid, void** pp)              { return pThis->lpVtbl->GetService(pThis, riid, pp); }
-static MA_INLINE HRESULT ma_IAudioClient3_IsOffloadCapable(ma_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); }
-static MA_INLINE HRESULT ma_IAudioClient3_SetClientProperties(ma_IAudioClient3* pThis, const ma_AudioClientProperties* pProperties)           { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetBufferSizeLimits(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetSharedModeEnginePeriod(ma_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, ma_uint32* pDefaultPeriodInFrames, ma_uint32* pFundamentalPeriodInFrames, ma_uint32* pMinPeriodInFrames, ma_uint32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_GetCurrentSharedModeEnginePeriod(ma_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, ma_uint32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); }
-static MA_INLINE HRESULT ma_IAudioClient3_InitializeSharedAudioStream(ma_IAudioClient3* pThis, DWORD streamFlags, ma_uint32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); }
-
-
-/* IAudioRenderClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioRenderClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioRenderClient* pThis);
-
-    /* IAudioRenderClient */
-    HRESULT (STDMETHODCALLTYPE * GetBuffer)    (ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData);
-    HRESULT (STDMETHODCALLTYPE * ReleaseBuffer)(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags);
-} ma_IAudioRenderClientVtbl;
-struct ma_IAudioRenderClient
-{
-    ma_IAudioRenderClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioRenderClient_QueryInterface(ma_IAudioRenderClient* pThis, const IID* const riid, void** ppObject)   { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioRenderClient_AddRef(ma_IAudioRenderClient* pThis)                                                   { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioRenderClient_Release(ma_IAudioRenderClient* pThis)                                                  { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioRenderClient_GetBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesRequested, BYTE** ppData)   { return pThis->lpVtbl->GetBuffer(pThis, numFramesRequested, ppData); }
-static MA_INLINE HRESULT ma_IAudioRenderClient_ReleaseBuffer(ma_IAudioRenderClient* pThis, ma_uint32 numFramesWritten, DWORD dwFlags) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesWritten, dwFlags); }
-
-
-/* IAudioCaptureClient */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IAudioCaptureClient* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IAudioCaptureClient* pThis);
-
-    /* IAudioRenderClient */
-    HRESULT (STDMETHODCALLTYPE * GetBuffer)        (ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition);
-    HRESULT (STDMETHODCALLTYPE * ReleaseBuffer)    (ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead);
-    HRESULT (STDMETHODCALLTYPE * GetNextPacketSize)(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket);
-} ma_IAudioCaptureClientVtbl;
-struct ma_IAudioCaptureClient
-{
-    ma_IAudioCaptureClientVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IAudioCaptureClient_QueryInterface(ma_IAudioCaptureClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IAudioCaptureClient_AddRef(ma_IAudioCaptureClient* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IAudioCaptureClient_Release(ma_IAudioCaptureClient* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_GetBuffer(ma_IAudioCaptureClient* pThis, BYTE** ppData, ma_uint32* pNumFramesToRead, DWORD* pFlags, ma_uint64* pDevicePosition, ma_uint64* pQPCPosition) { return pThis->lpVtbl->GetBuffer(pThis, ppData, pNumFramesToRead, pFlags, pDevicePosition, pQPCPosition); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_ReleaseBuffer(ma_IAudioCaptureClient* pThis, ma_uint32 numFramesRead)                 { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesRead); }
-static MA_INLINE HRESULT ma_IAudioCaptureClient_GetNextPacketSize(ma_IAudioCaptureClient* pThis, ma_uint32* pNumFramesInNextPacket)   { return pThis->lpVtbl->GetNextPacketSize(pThis, pNumFramesInNextPacket); }
-
-#ifndef MA_WIN32_DESKTOP
-#include <mmdeviceapi.h>
-typedef struct ma_completion_handler_uwp ma_completion_handler_uwp;
-
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_completion_handler_uwp* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_completion_handler_uwp* pThis);
-
-    /* IActivateAudioInterfaceCompletionHandler */
-    HRESULT (STDMETHODCALLTYPE * ActivateCompleted)(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation);
-} ma_completion_handler_uwp_vtbl;
-struct ma_completion_handler_uwp
-{
-    ma_completion_handler_uwp_vtbl* lpVtbl;
-    MA_ATOMIC ma_uint32 counter;
-    HANDLE hEvent;
-};
-
-static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_QueryInterface(ma_completion_handler_uwp* pThis, const IID* const riid, void** ppObject)
-{
-    /*
-    We need to "implement" IAgileObject which is just an indicator that's used internally by WASAPI for some multithreading management. To
-    "implement" this, we just make sure we return pThis when the IAgileObject is requested.
-    */
-    if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IActivateAudioInterfaceCompletionHandler) && !ma_is_guid_equal(riid, &MA_IID_IAgileObject)) {
-        *ppObject = NULL;
-        return E_NOINTERFACE;
-    }
-
-    /* Getting here means the IID is IUnknown or IMMNotificationClient. */
-    *ppObject = (void*)pThis;
-    ((ma_completion_handler_uwp_vtbl*)pThis->lpVtbl)->AddRef(pThis);
-    return S_OK;
-}
-
-static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_AddRef(ma_completion_handler_uwp* pThis)
-{
-    return (ULONG)c89atomic_fetch_add_32(&pThis->counter, 1) + 1;
-}
-
-static ULONG STDMETHODCALLTYPE ma_completion_handler_uwp_Release(ma_completion_handler_uwp* pThis)
-{
-    ma_uint32 newRefCount = c89atomic_fetch_sub_32(&pThis->counter, 1) - 1;
-    if (newRefCount == 0) {
-        return 0;   /* We don't free anything here because we never allocate the object on the heap. */
-    }
-
-    return (ULONG)newRefCount;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_completion_handler_uwp_ActivateCompleted(ma_completion_handler_uwp* pThis, ma_IActivateAudioInterfaceAsyncOperation* pActivateOperation)
-{
-    (void)pActivateOperation;
-    SetEvent(pThis->hEvent);
-    return S_OK;
-}
-
-
-static ma_completion_handler_uwp_vtbl g_maCompletionHandlerVtblInstance = {
-    ma_completion_handler_uwp_QueryInterface,
-    ma_completion_handler_uwp_AddRef,
-    ma_completion_handler_uwp_Release,
-    ma_completion_handler_uwp_ActivateCompleted
-};
-
-static ma_result ma_completion_handler_uwp_init(ma_completion_handler_uwp* pHandler)
-{
-    MA_ASSERT(pHandler != NULL);
-    MA_ZERO_OBJECT(pHandler);
-
-    pHandler->lpVtbl = &g_maCompletionHandlerVtblInstance;
-    pHandler->counter = 1;
-    pHandler->hEvent = CreateEventW(NULL, FALSE, FALSE, NULL);
-    if (pHandler->hEvent == NULL) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_completion_handler_uwp_uninit(ma_completion_handler_uwp* pHandler)
-{
-    if (pHandler->hEvent != NULL) {
-        CloseHandle(pHandler->hEvent);
-    }
-}
-
-static void ma_completion_handler_uwp_wait(ma_completion_handler_uwp* pHandler)
-{
-    WaitForSingleObject(pHandler->hEvent, INFINITE);
-}
-#endif  /* !MA_WIN32_DESKTOP */
-
-/* We need a virtual table for our notification client object that's used for detecting changes to the default device. */
-#ifdef MA_WIN32_DESKTOP
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_QueryInterface(ma_IMMNotificationClient* pThis, const IID* const riid, void** ppObject)
-{
-    /*
-    We care about two interfaces - IUnknown and IMMNotificationClient. If the requested IID is something else
-    we just return E_NOINTERFACE. Otherwise we need to increment the reference counter and return S_OK.
-    */
-    if (!ma_is_guid_equal(riid, &MA_IID_IUnknown) && !ma_is_guid_equal(riid, &MA_IID_IMMNotificationClient)) {
-        *ppObject = NULL;
-        return E_NOINTERFACE;
-    }
-
-    /* Getting here means the IID is IUnknown or IMMNotificationClient. */
-    *ppObject = (void*)pThis;
-    ((ma_IMMNotificationClientVtbl*)pThis->lpVtbl)->AddRef(pThis);
-    return S_OK;
-}
-
-static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_AddRef(ma_IMMNotificationClient* pThis)
-{
-    return (ULONG)c89atomic_fetch_add_32(&pThis->counter, 1) + 1;
-}
-
-static ULONG STDMETHODCALLTYPE ma_IMMNotificationClient_Release(ma_IMMNotificationClient* pThis)
-{
-    ma_uint32 newRefCount = c89atomic_fetch_sub_32(&pThis->counter, 1) - 1;
-    if (newRefCount == 0) {
-        return 0;   /* We don't free anything here because we never allocate the object on the heap. */
-    }
-
-    return (ULONG)newRefCount;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceStateChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState)
-{
-    ma_bool32 isThisDevice = MA_FALSE;
-    ma_bool32 isCapture    = MA_FALSE;
-    ma_bool32 isPlayback   = MA_FALSE;
-    
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)", (unsigned int)dwNewState);
-#endif
-
-    /*
-    There have been reports of a hang when a playback device is disconnected. The idea with this code is to explicitly stop the device if we detect
-    that the device is disabled or has been unplugged.
-    */
-    if (pThis->pDevice->wasapi.allowCaptureAutoStreamRouting && (pThis->pDevice->type == ma_device_type_capture || pThis->pDevice->type == ma_device_type_duplex || pThis->pDevice->type == ma_device_type_loopback)) {
-        isCapture = MA_TRUE;
-        if (wcscmp(pThis->pDevice->capture.id.wasapi, pDeviceID) == 0) {
-            isThisDevice = MA_TRUE;
-        }
-    }
-
-    if (pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting && (pThis->pDevice->type == ma_device_type_playback || pThis->pDevice->type == ma_device_type_duplex)) {
-        isPlayback = MA_TRUE;
-        if (wcscmp(pThis->pDevice->playback.id.wasapi, pDeviceID) == 0) {
-            isThisDevice = MA_TRUE;
-        }
-    }
-
-
-    /*
-    If the device ID matches our device we need to mark our device as detached and stop it. When a
-    device is added in OnDeviceAdded(), we'll restart it. We only mark it as detached if the device
-    was started at the time of being removed.
-    */
-    if (isThisDevice) {
-        if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) == 0) {
-            /*
-            Unplugged or otherwise unavailable. Mark as detached if we were in a playing state. We'll
-            use this to determine whether or not we need to automatically start the device when it's
-            plugged back in again.
-            */
-            if (ma_device_get_state(pThis->pDevice) == MA_STATE_STARTED) {
-                if (isPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_TRUE;
-                }
-                if (isCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_TRUE;
-                }
-
-                ma_device_stop(pThis->pDevice);
-            }
-        }
-
-        if ((dwNewState & MA_MM_DEVICE_STATE_ACTIVE) != 0) {
-            /* The device was activated. If we were detached, we need to start it again. */
-            ma_bool8 tryRestartingDevice = MA_FALSE;
-
-            if (isPlayback) {
-                if (pThis->pDevice->wasapi.isDetachedPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
-                    ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
-                    tryRestartingDevice = MA_TRUE;
-                }
-            }
-
-            if (isCapture) {
-                if (pThis->pDevice->wasapi.isDetachedCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
-                    ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
-                    tryRestartingDevice = MA_TRUE;
-                }
-            }
-
-            if (tryRestartingDevice) {
-                if (pThis->pDevice->wasapi.isDetachedPlayback == MA_FALSE && pThis->pDevice->wasapi.isDetachedCapture == MA_FALSE) {
-                    ma_device_start(pThis->pDevice);
-                }
-            }
-        }
-    }
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceAdded(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    /*printf("IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
-#endif
-
-    /* We don't need to worry about this event for our purposes. */
-    (void)pThis;
-    (void)pDeviceID;
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDeviceRemoved(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");
-#endif
-
-    /* We don't need to worry about this event for our purposes. */
-    (void)pThis;
-    (void)pDeviceID;
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnDefaultDeviceChanged(ma_IMMNotificationClient* pThis, ma_EDataFlow dataFlow, ma_ERole role, LPCWSTR pDefaultDeviceID)
-{
-#ifdef MA_DEBUG_OUTPUT
-    printf("IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)");
-#endif
-
-    /* We only ever use the eConsole role in miniaudio. */
-    if (role != ma_eConsole) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting: role != eConsole\n");
-    #endif
-        return S_OK;
-    }
-
-    /* We only care about devices with the same data flow and role as the current device. */
-    if ((pThis->pDevice->type == ma_device_type_playback && dataFlow != ma_eRender) ||
-        (pThis->pDevice->type == ma_device_type_capture  && dataFlow != ma_eCapture)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because dataFlow does match device type.\n");
-    #endif
-        return S_OK;
-    }
-
-    /* Don't do automatic stream routing if we're not allowed. */
-    if ((dataFlow == ma_eRender  && pThis->pDevice->wasapi.allowPlaybackAutoStreamRouting == MA_FALSE) ||
-        (dataFlow == ma_eCapture && pThis->pDevice->wasapi.allowCaptureAutoStreamRouting  == MA_FALSE)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because automatic stream routing has been disabled by the device config.\n");
-    #endif
-        return S_OK;
-    }
-
-    /*
-    Not currently supporting automatic stream routing in exclusive mode. This is not working correctly on my machine due to
-    AUDCLNT_E_DEVICE_IN_USE errors when reinitializing the device. If this is a bug in miniaudio, we can try re-enabling this once
-    it's fixed.
-    */
-    if ((dataFlow == ma_eRender  && pThis->pDevice->playback.shareMode == ma_share_mode_exclusive) ||
-        (dataFlow == ma_eCapture && pThis->pDevice->capture.shareMode  == ma_share_mode_exclusive)) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Stream rerouting abandoned because the device shared mode is exclusive.\n");
-    #endif
-        return S_OK;
-    }
-
-
-
-
-    /*
-    Second attempt at device rerouting. We're going to retrieve the device's state at the time of
-    the route change. We're then going to stop the device, reinitialize the device, and then start
-    it again if the state before stopping was MA_STATE_STARTED.
-    */
-    {
-        ma_uint32 previousState = ma_device_get_state(pThis->pDevice);
-        ma_bool8 restartDevice = MA_FALSE;
-
-        if (previousState == MA_STATE_STARTED) {
-            ma_device_stop(pThis->pDevice);
-            restartDevice = MA_TRUE;
-        }
-
-        if (pDefaultDeviceID != NULL) { /* <-- The input device ID will be null if there's no other device available. */
-            if (dataFlow == ma_eRender) {
-                ma_device_reroute__wasapi(pThis->pDevice, ma_device_type_playback);
-
-                if (pThis->pDevice->wasapi.isDetachedPlayback) {
-                    pThis->pDevice->wasapi.isDetachedPlayback = MA_FALSE;
-                    
-                    if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedCapture) {
-                        restartDevice = MA_FALSE;   /* It's a duplex device and the capture side is detached. We cannot be restarting the device just yet. */
-                    } else {
-                        restartDevice = MA_TRUE;    /* It's not a duplex device, or the capture side is also attached so we can go ahead and restart the device. */
-                    }
-                }
-            } else {
-                ma_device_reroute__wasapi(pThis->pDevice, (pThis->pDevice->type == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture);
-
-                if (pThis->pDevice->wasapi.isDetachedCapture) {
-                    pThis->pDevice->wasapi.isDetachedCapture = MA_FALSE;
-                    
-                    if (pThis->pDevice->type == ma_device_type_duplex && pThis->pDevice->wasapi.isDetachedPlayback) {
-                        restartDevice = MA_FALSE;   /* It's a duplex device and the playback side is detached. We cannot be restarting the device just yet. */
-                    } else {
-                        restartDevice = MA_TRUE;    /* It's not a duplex device, or the playback side is also attached so we can go ahead and restart the device. */
-                    }
-                }
-            }
-
-            if (restartDevice) {
-                ma_device_start(pThis->pDevice);
-            }
-        }
-    }
-
-    return S_OK;
-}
-
-static HRESULT STDMETHODCALLTYPE ma_IMMNotificationClient_OnPropertyValueChanged(ma_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key)
-{
-#ifdef MA_DEBUG_OUTPUT
-    /*printf("IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)");*/
-#endif
-
-    (void)pThis;
-    (void)pDeviceID;
-    (void)key;
-    return S_OK;
-}
-
-static ma_IMMNotificationClientVtbl g_maNotificationCientVtbl = {
-    ma_IMMNotificationClient_QueryInterface,
-    ma_IMMNotificationClient_AddRef,
-    ma_IMMNotificationClient_Release,
-    ma_IMMNotificationClient_OnDeviceStateChanged,
-    ma_IMMNotificationClient_OnDeviceAdded,
-    ma_IMMNotificationClient_OnDeviceRemoved,
-    ma_IMMNotificationClient_OnDefaultDeviceChanged,
-    ma_IMMNotificationClient_OnPropertyValueChanged
-};
-#endif  /* MA_WIN32_DESKTOP */
-
-#ifdef MA_WIN32_DESKTOP
-typedef ma_IMMDevice ma_WASAPIDeviceInterface;
-#else
-typedef ma_IUnknown ma_WASAPIDeviceInterface;
-#endif
-
-
-#define MA_CONTEXT_COMMAND_QUIT__WASAPI                 1
-#define MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI  2
-#define MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI 3
-
-static ma_context_command__wasapi ma_context_init_command__wasapi(int code)
-{
-    ma_context_command__wasapi cmd;
-    
-    MA_ZERO_OBJECT(&cmd);
-    cmd.code = code;
-
-    return cmd;
-}
-
-static ma_result ma_context_post_command__wasapi(ma_context* pContext, const ma_context_command__wasapi* pCmd)
-{
-    /* For now we are doing everything synchronously, but I might relax this later if the need arises. */
-    ma_result result;
-    ma_bool32 isUsingLocalEvent = MA_FALSE;
-    ma_event localEvent;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCmd     != NULL);
-
-    if (pCmd->pEvent == NULL) {
-        isUsingLocalEvent = MA_TRUE;
-
-        result = ma_event_init(&localEvent);
-        if (result != MA_SUCCESS) {
-            return result;  /* Failed to create the event for this command. */
-        }
-    }
-
-    /* Here is where we add the command to the list. If there's not enough room we'll spin until there is. */
-    ma_mutex_lock(&pContext->wasapi.commandLock);
-    {
-        ma_uint32 index;
-
-        /* Spin until we've got some space available. */
-        while (pContext->wasapi.commandCount == ma_countof(pContext->wasapi.commands)) {
-            ma_yield();
-        }
-
-        /* Space is now available. Can safely add to the list. */
-        index = (pContext->wasapi.commandIndex + pContext->wasapi.commandCount) % ma_countof(pContext->wasapi.commands);
-        pContext->wasapi.commands[index]        = *pCmd;
-        pContext->wasapi.commands[index].pEvent = &localEvent;
-        pContext->wasapi.commandCount += 1;
-
-        /* Now that the command has been added, release the semaphore so ma_context_next_command__wasapi() can return. */
-        ma_semaphore_release(&pContext->wasapi.commandSem);
-    }
-    ma_mutex_unlock(&pContext->wasapi.commandLock);    
-
-    if (isUsingLocalEvent) {
-        ma_event_wait(&localEvent);
-        ma_event_uninit(&localEvent);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_next_command__wasapi(ma_context* pContext, ma_context_command__wasapi* pCmd)
-{
-    ma_result result = MA_SUCCESS;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCmd     != NULL);
-
-    result = ma_semaphore_wait(&pContext->wasapi.commandSem);
-    if (result == MA_SUCCESS) {
-        ma_mutex_lock(&pContext->wasapi.commandLock);
-        {
-            *pCmd = pContext->wasapi.commands[pContext->wasapi.commandIndex];
-            pContext->wasapi.commandIndex  = (pContext->wasapi.commandIndex + 1) % ma_countof(pContext->wasapi.commands);
-            pContext->wasapi.commandCount -= 1;
-        }
-        ma_mutex_unlock(&pContext->wasapi.commandLock);
-    }    
-
-    return result;
-}
-
-static ma_thread_result MA_THREADCALL ma_context_command_thread__wasapi(void* pUserData)
-{
-    ma_result result;
-    ma_context* pContext = (ma_context*)pUserData;
-    MA_ASSERT(pContext != NULL);
-
-    for (;;) {
-        ma_context_command__wasapi cmd;
-        result = ma_context_next_command__wasapi(pContext, &cmd);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        switch (cmd.code)
-        {
-            case MA_CONTEXT_COMMAND_QUIT__WASAPI:
-            {
-                /* Do nothing. Handled after the switch. */
-            } break;
-
-            case MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI:
-            {
-                if (cmd.data.createAudioClient.deviceType == ma_device_type_playback) {
-                    result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioRenderClient, cmd.data.createAudioClient.ppAudioClientService));
-                } else {
-                    result = ma_result_from_HRESULT(ma_IAudioClient_GetService((ma_IAudioClient*)cmd.data.createAudioClient.pAudioClient, &MA_IID_IAudioCaptureClient, cmd.data.createAudioClient.ppAudioClientService));
-                }
-            } break;
-
-            case MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI:
-            {
-                if (cmd.data.releaseAudioClient.deviceType == ma_device_type_playback) { 
-                    if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback != NULL) {
-                        ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback);
-                        cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientPlayback = NULL;
-                    }
-                }
-
-                if (cmd.data.releaseAudioClient.deviceType == ma_device_type_capture) {
-                    if (cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture != NULL) {
-                        ma_IAudioClient_Release((ma_IAudioClient*)cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture);
-                        cmd.data.releaseAudioClient.pDevice->wasapi.pAudioClientCapture = NULL;
-                    }
-                }
-            } break;
-
-            default:
-            {
-                /* Unknown command. Ignore it, but trigger an assert in debug mode so we're aware of it. */
-                MA_ASSERT(MA_FALSE);
-            } break;
-        }
-
-        if (cmd.pEvent != NULL) {
-            ma_event_signal(cmd.pEvent);
-        }
-
-        if (cmd.code == MA_CONTEXT_COMMAND_QUIT__WASAPI) {
-            break;  /* Received a quit message. Get out of here. */
-        }
-    }
-
-    return (ma_thread_result)0;
-}
-
-static ma_result ma_device_create_IAudioClient_service__wasapi(ma_context* pContext, ma_device_type deviceType, ma_IAudioClient* pAudioClient, void** ppAudioClientService)
-{
-    ma_result result;
-    ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_CREATE_IAUDIOCLIENT__WASAPI);
-    cmd.data.createAudioClient.deviceType           = deviceType;
-    cmd.data.createAudioClient.pAudioClient         = (void*)pAudioClient;
-    cmd.data.createAudioClient.ppAudioClientService = ppAudioClientService;
-    cmd.data.createAudioClient.result               = MA_SUCCESS;
-    
-    result = ma_context_post_command__wasapi(pContext, &cmd);  /* This will not return until the command has actually been run. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return cmd.data.createAudioClient.result;
-}
-
-#if 0   /* Not used at the moment, but leaving here for future use. */
-static ma_result ma_device_release_IAudioClient_service__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-    ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_RELEASE_IAUDIOCLIENT__WASAPI);
-    cmd.data.releaseAudioClient.pDevice    = pDevice;
-    cmd.data.releaseAudioClient.deviceType = deviceType;
-
-    result = ma_context_post_command__wasapi(pDevice->pContext, &cmd);  /* This will not return until the command has actually been run. */
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-static void ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(const WAVEFORMATEX* pWF, ma_share_mode shareMode, ma_device_info* pInfo)
-{
-    MA_ASSERT(pWF != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    if (pInfo->nativeDataFormatCount >= ma_countof(pInfo->nativeDataFormats)) {
-        return; /* Too many data formats. Need to ignore this one. Don't think this should ever happen with WASAPI. */
-    }
-
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].format     = ma_format_from_WAVEFORMATEX(pWF);
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].channels   = pWF->nChannels;
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].sampleRate = pWF->nSamplesPerSec;
-    pInfo->nativeDataFormats[pInfo->nativeDataFormatCount].flags      = (shareMode == ma_share_mode_exclusive) ? MA_DATA_FORMAT_FLAG_EXCLUSIVE_MODE : 0;
-    pInfo->nativeDataFormatCount += 1;
-}
-
-static ma_result ma_context_get_device_info_from_IAudioClient__wasapi(ma_context* pContext, /*ma_IMMDevice**/void* pMMDevice, ma_IAudioClient* pAudioClient, ma_device_info* pInfo)
-{
-    HRESULT hr;
-    WAVEFORMATEX* pWF = NULL;
-
-    MA_ASSERT(pAudioClient != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    /* Shared Mode. We use GetMixFormat() here. */
-    hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pAudioClient, (WAVEFORMATEX**)&pWF);
-    if (SUCCEEDED(hr)) {
-        ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_shared, pInfo);
-    } else {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve mix format for device info retrieval.", ma_result_from_HRESULT(hr));
-    }
-
-    /*
-    Exlcusive Mode. We repeatedly call IsFormatSupported() here. This is not currently supported on
-    UWP. Failure to retrieve the exclusive mode format is not considered an error, so from here on
-    out, MA_SUCCESS is guaranteed to be returned.
-    */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        ma_IPropertyStore *pProperties;
-
-        /*
-        The first thing to do is get the format from PKEY_AudioEngine_DeviceFormat. This should give us a channel count we assume is
-        correct which will simplify our searching.
-        */
-        hr = ma_IMMDevice_OpenPropertyStore((ma_IMMDevice*)pMMDevice, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT var;
-            ma_PropVariantInit(&var);
-
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_AudioEngine_DeviceFormat, &var);
-            if (SUCCEEDED(hr)) {
-                pWF = (WAVEFORMATEX*)var.blob.pBlobData;
-
-                /*
-                In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format
-                first. If this fails, fall back to a search.
-                */
-                hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL);
-                if (SUCCEEDED(hr)) {
-                    /* The format returned by PKEY_AudioEngine_DeviceFormat is supported. */
-                    ma_add_native_data_format_to_device_info_from_WAVEFORMATEX(pWF, ma_share_mode_exclusive, pInfo);
-                } else {
-                    /*
-                    The format returned by PKEY_AudioEngine_DeviceFormat is not supported, so fall back to a search. We assume the channel
-                    count returned by MA_PKEY_AudioEngine_DeviceFormat is valid and correct. For simplicity we're only returning one format.
-                    */
-                    ma_uint32 channels = pInfo->minChannels;
-                    ma_channel defaultChannelMap[MA_MAX_CHANNELS];
-                    WAVEFORMATEXTENSIBLE wf;
-                    ma_bool32 found;
-                    ma_uint32 iFormat;
-
-                    /* Make sure we don't overflow the channel map. */
-                    if (channels > MA_MAX_CHANNELS) {
-                        channels = MA_MAX_CHANNELS;
-                    }
-
-                    ma_get_standard_channel_map(ma_standard_channel_map_microsoft, channels, defaultChannelMap);
-
-                    MA_ZERO_OBJECT(&wf);
-                    wf.Format.cbSize     = sizeof(wf);
-                    wf.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
-                    wf.Format.nChannels  = (WORD)channels;
-                    wf.dwChannelMask     = ma_channel_map_to_channel_mask__win32(defaultChannelMap, channels);
-
-                    found = MA_FALSE;
-                    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) {
-                        ma_format format = g_maFormatPriorities[iFormat];
-                        ma_uint32 iSampleRate;
-
-                        wf.Format.wBitsPerSample       = (WORD)(ma_get_bytes_per_sample(format)*8);
-                        wf.Format.nBlockAlign          = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-                        wf.Format.nAvgBytesPerSec      = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-                        wf.Samples.wValidBitsPerSample = /*(format == ma_format_s24_32) ? 24 :*/ wf.Format.wBitsPerSample;
-                        if (format == ma_format_f32) {
-                            wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
-                        } else {
-                            wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-                        }
-
-                        for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iSampleRate) {
-                            wf.Format.nSamplesPerSec = g_maStandardSampleRatePriorities[iSampleRate];
-
-                            hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (WAVEFORMATEX*)&wf, NULL);
-                            if (SUCCEEDED(hr)) {
-                                ma_add_native_data_format_to_device_info_from_WAVEFORMATEX((WAVEFORMATEX*)&wf, ma_share_mode_exclusive, pInfo);
-                                found = MA_TRUE;
-                                break;
-                            }
-                        }
-
-                        if (found) {
-                            break;
-                        }
-                    }
-
-                    ma_PropVariantClear(pContext, &var);
-
-                    if (!found) {
-                        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to find suitable device format for device info retrieval.", MA_FORMAT_NOT_SUPPORTED);
-                    }
-                }
-            } else {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to retrieve device format for device info retrieval.", ma_result_from_HRESULT(hr));
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        } else {
-            ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "[WASAPI] Failed to open property store for device info retrieval.", ma_result_from_HRESULT(hr));
-        }
-    }
-    #endif
-
-    return MA_SUCCESS;
-}
-
-#ifdef MA_WIN32_DESKTOP
-static ma_EDataFlow ma_device_type_to_EDataFlow(ma_device_type deviceType)
-{
-    if (deviceType == ma_device_type_playback) {
-        return ma_eRender;
-    } else if (deviceType == ma_device_type_capture) {
-        return ma_eCapture;
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return ma_eRender; /* Should never hit this. */
-    }
-}
-
-static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator** ppDeviceEnumerator)
-{
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-
-    MA_ASSERT(pContext           != NULL);
-    MA_ASSERT(ppDeviceEnumerator != NULL);
-
-    *ppDeviceEnumerator = NULL; /* Safety. */
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDeviceEnumerator = pDeviceEnumerator;
-
-    return MA_SUCCESS;
-}
-
-static LPWSTR ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType)
-{
-    HRESULT hr;
-    ma_IMMDevice* pMMDefaultDevice = NULL;
-    LPWSTR pDefaultDeviceID = NULL;
-    ma_EDataFlow dataFlow;
-    ma_ERole role;
-
-    MA_ASSERT(pContext          != NULL);
-    MA_ASSERT(pDeviceEnumerator != NULL);
-
-    (void)pContext;
-
-    /* Grab the EDataFlow type from the device type. */
-    dataFlow = ma_device_type_to_EDataFlow(deviceType);
-
-    /* The role is always eConsole, but we may make this configurable later. */
-    role = ma_eConsole;
-
-    hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, dataFlow, role, &pMMDefaultDevice);
-    if (FAILED(hr)) {
-        return NULL;
-    }
-
-    hr = ma_IMMDevice_GetId(pMMDefaultDevice, &pDefaultDeviceID);
-
-    ma_IMMDevice_Release(pMMDefaultDevice);
-    pMMDefaultDevice = NULL;
-
-    if (FAILED(hr)) {
-        return NULL;
-    }
-
-    return pDefaultDeviceID;
-}
-
-static LPWSTR ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_device_type deviceType)    /* Free the returned pointer with ma_CoTaskMemFree() */
-{
-    ma_result result;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-    LPWSTR pDefaultDeviceID = NULL;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_context_create_IMMDeviceEnumerator__wasapi(pContext, &pDeviceEnumerator);
-    if (result != MA_SUCCESS) {
-        return NULL;
-    }
-
-    pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType);
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    return pDefaultDeviceID;
-}
-
-static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IMMDevice** ppMMDevice)
-{
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppMMDevice != NULL);
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    if (pDeviceID == NULL) {
-        hr = ma_IMMDeviceEnumerator_GetDefaultAudioEndpoint(pDeviceEnumerator, (deviceType == ma_device_type_capture) ? ma_eCapture : ma_eRender, ma_eConsole, ppMMDevice);
-    } else {
-        hr = ma_IMMDeviceEnumerator_GetDevice(pDeviceEnumerator, pDeviceID->wasapi, ppMMDevice);
-    }
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.", ma_result_from_HRESULT(hr));
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID)
-{
-    LPWSTR pDeviceIDString;
-    HRESULT hr;
-
-    MA_ASSERT(pDeviceID != NULL);
-
-    hr = ma_IMMDevice_GetId(pMMDevice, &pDeviceIDString);
-    if (SUCCEEDED(hr)) {
-        size_t idlen = wcslen(pDeviceIDString);
-        if (idlen+1 > ma_countof(pDeviceID->wasapi)) {
-            ma_CoTaskMemFree(pContext, pDeviceIDString);
-            MA_ASSERT(MA_FALSE);  /* NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. */
-            return MA_ERROR;
-        }
-
-        MA_COPY_MEMORY(pDeviceID->wasapi, pDeviceIDString, idlen * sizeof(wchar_t));
-        pDeviceID->wasapi[idlen] = '\0';
-
-        ma_CoTaskMemFree(pContext, pDeviceIDString);
-
-        return MA_SUCCESS;
-    }
-
-    return MA_ERROR;
-}
-
-static ma_result ma_context_get_device_info_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, LPWSTR pDefaultDeviceID, ma_bool32 onlySimpleInfo, ma_device_info* pInfo)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pMMDevice != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    /* ID. */
-    result = ma_context_get_device_id_from_MMDevice__wasapi(pContext, pMMDevice, &pInfo->id);
-    if (result == MA_SUCCESS) {
-        if (pDefaultDeviceID != NULL) {
-            if (wcscmp(pInfo->id.wasapi, pDefaultDeviceID) == 0) {
-                pInfo->isDefault = MA_TRUE;
-            }
-        }
-    }
-
-    /* Description / Friendly Name */
-    {
-        ma_IPropertyStore *pProperties;
-        hr = ma_IMMDevice_OpenPropertyStore(pMMDevice, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT var;
-
-            ma_PropVariantInit(&var);
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &var);
-            if (SUCCEEDED(hr)) {
-                WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, pInfo->name, sizeof(pInfo->name), 0, FALSE);
-                ma_PropVariantClear(pContext, &var);
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        }
-    }
-
-    /* Format */
-    if (!onlySimpleInfo) {
-        ma_IAudioClient* pAudioClient;
-        hr = ma_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient);
-        if (SUCCEEDED(hr)) {
-            result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, pMMDevice, pAudioClient, pInfo);
-
-            ma_IAudioClient_Release(pAudioClient);
-            return result;
-        } else {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate audio client for device info retrieval.", ma_result_from_HRESULT(hr));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pContext, ma_IMMDeviceEnumerator* pDeviceEnumerator, ma_device_type deviceType, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result = MA_SUCCESS;
-    UINT deviceCount;
-    HRESULT hr;
-    ma_uint32 iDevice;
-    LPWSTR pDefaultDeviceID = NULL;
-    ma_IMMDeviceCollection* pDeviceCollection = NULL;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Grab the default device. We use this to know whether or not flag the returned device info as being the default. */
-    pDefaultDeviceID = ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(pContext, pDeviceEnumerator, deviceType);
-
-    /* We need to enumerate the devices which returns a device collection. */
-    hr = ma_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, ma_device_type_to_EDataFlow(deviceType), MA_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection);
-    if (SUCCEEDED(hr)) {
-        hr = ma_IMMDeviceCollection_GetCount(pDeviceCollection, &deviceCount);
-        if (FAILED(hr)) {
-            result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get device count.", ma_result_from_HRESULT(hr));
-            goto done;
-        }
-
-        for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            ma_IMMDevice* pMMDevice;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-
-            hr = ma_IMMDeviceCollection_Item(pDeviceCollection, iDevice, &pMMDevice);
-            if (SUCCEEDED(hr)) {
-                result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_TRUE, &deviceInfo);   /* MA_TRUE = onlySimpleInfo. */
-
-                ma_IMMDevice_Release(pMMDevice);
-                if (result == MA_SUCCESS) {
-                    ma_bool32 cbResult = callback(pContext, deviceType, &deviceInfo, pUserData);
-                    if (cbResult == MA_FALSE) {
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
-done:
-    if (pDefaultDeviceID != NULL) {
-        ma_CoTaskMemFree(pContext, pDefaultDeviceID);
-        pDefaultDeviceID = NULL;
-    }
-
-    if (pDeviceCollection != NULL) {
-        ma_IMMDeviceCollection_Release(pDeviceCollection);
-        pDeviceCollection = NULL;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_get_IAudioClient_Desktop__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IMMDevice** ppMMDevice)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppAudioClient != NULL);
-    MA_ASSERT(ppMMDevice != NULL);
-
-    result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, ppMMDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    hr = ma_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)ppAudioClient);
-    if (FAILED(hr)) {
-        return ma_result_from_HRESULT(hr);
-    }
-
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_IUnknown** ppActivatedInterface)
-{
-    ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL;
-    ma_completion_handler_uwp completionHandler;
-    IID iid;
-    LPOLESTR iidStr;
-    HRESULT hr;
-    ma_result result;
-    HRESULT activateResult;
-    ma_IUnknown* pActivatedInterface;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppAudioClient != NULL);
-
-    if (pDeviceID != NULL) {
-        MA_COPY_MEMORY(&iid, pDeviceID->wasapi, sizeof(iid));
-    } else {
-        if (deviceType == ma_device_type_playback) {
-            iid = MA_IID_DEVINTERFACE_AUDIO_RENDER;
-        } else {
-            iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE;
-        }
-    }
-
-#if defined(__cplusplus)
-    hr = StringFromIID(iid, &iidStr);
-#else
-    hr = StringFromIID(&iid, &iidStr);
-#endif
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.", ma_result_from_HRESULT(hr));
-    }
-
-    result = ma_completion_handler_uwp_init(&completionHandler);
-    if (result != MA_SUCCESS) {
-        ma_CoTaskMemFree(pContext, iidStr);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().", result);
-    }
-
-#if defined(__cplusplus)
-    hr = ActivateAudioInterfaceAsync(iidStr, MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#else
-    hr = ActivateAudioInterfaceAsync(iidStr, &MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp);
-#endif
-    if (FAILED(hr)) {
-        ma_completion_handler_uwp_uninit(&completionHandler);
-        ma_CoTaskMemFree(pContext, iidStr);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.", ma_result_from_HRESULT(hr));
-    }
-
-    ma_CoTaskMemFree(pContext, iidStr);
-
-    /* Wait for the async operation for finish. */
-    ma_completion_handler_uwp_wait(&completionHandler);
-    ma_completion_handler_uwp_uninit(&completionHandler);
-
-    hr = ma_IActivateAudioInterfaceAsyncOperation_GetActivateResult(pAsyncOp, &activateResult, &pActivatedInterface);
-    ma_IActivateAudioInterfaceAsyncOperation_Release(pAsyncOp);
-
-    if (FAILED(hr) || FAILED(activateResult)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.", FAILED(hr) ? ma_result_from_HRESULT(hr) : ma_result_from_HRESULT(activateResult));
-    }
-
-    /* Here is where we grab the IAudioClient interface. */
-    hr = ma_IUnknown_QueryInterface(pActivatedInterface, &MA_IID_IAudioClient, (void**)ppAudioClient);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.", ma_result_from_HRESULT(hr));
-    }
-
-    if (ppActivatedInterface) {
-        *ppActivatedInterface = pActivatedInterface;
-    } else {
-        ma_IUnknown_Release(pActivatedInterface);
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_IAudioClient** ppAudioClient, ma_WASAPIDeviceInterface** ppDeviceInterface)
-{
-#ifdef MA_WIN32_DESKTOP
-    return ma_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
-#else
-    return ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface);
-#endif
-}
-
-
-static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    /* Different enumeration for desktop and UWP. */
-#ifdef MA_WIN32_DESKTOP
-    /* Desktop */
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-
-    hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_playback, callback, pUserData);
-    ma_context_enumerate_devices_by_type__wasapi(pContext, pDeviceEnumerator, ma_device_type_capture,  callback, pUserData);
-
-    ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-#else
-    /*
-    UWP
-
-    The MMDevice API is only supported on desktop applications. For now, while I'm still figuring out how to properly enumerate
-    over devices without using MMDevice, I'm restricting devices to defaults.
-
-    Hint: DeviceInformation::FindAllAsync() with DeviceClass.AudioCapture/AudioRender. https://blogs.windows.com/buildingapps/2014/05/15/real-time-audio-in-windows-store-and-windows-phone-apps/
-    */
-    if (callback) {
-        ma_bool32 cbResult = MA_TRUE;
-
-        /* Playback. */
-        if (cbResult) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;
-            cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-        }
-
-        /* Capture. */
-        if (cbResult) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-#ifdef MA_WIN32_DESKTOP
-    ma_result result;
-    ma_IMMDevice* pMMDevice = NULL;
-    LPWSTR pDefaultDeviceID = NULL;
-
-    result = ma_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* We need the default device ID so we can set the isDefault flag in the device info. */
-    pDefaultDeviceID = ma_context_get_default_device_id__wasapi(pContext, deviceType);
-
-    result = ma_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, pDefaultDeviceID, MA_FALSE, pDeviceInfo);   /* MA_FALSE = !onlySimpleInfo. */
-
-    if (pDefaultDeviceID != NULL) {
-        ma_CoTaskMemFree(pContext, pDefaultDeviceID);
-        pDefaultDeviceID = NULL;
-    }
-
-    ma_IMMDevice_Release(pMMDevice);
-
-    return result;
-#else
-    ma_IAudioClient* pAudioClient;
-    ma_result result;
-
-    /* UWP currently only uses default devices. */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    result = ma_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, &pAudioClient, NULL);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_context_get_device_info_from_IAudioClient__wasapi(pContext, NULL, pAudioClient, pDeviceInfo);
-
-    pDeviceInfo->isDefault = MA_TRUE;  /* UWP only supports default devices. */
-
-    ma_IAudioClient_Release(pAudioClient);
-    return result;
-#endif
-}
-
-static ma_result ma_device_uninit__wasapi(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-#ifdef MA_WIN32_DESKTOP
-    if (pDevice->wasapi.pDeviceEnumerator) {
-        ((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator)->lpVtbl->UnregisterEndpointNotificationCallback((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator, &pDevice->wasapi.notificationClient);
-        ma_IMMDeviceEnumerator_Release((ma_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator);
-    }
-#endif
-
-    if (pDevice->wasapi.pRenderClient) {
-        ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-    }
-    if (pDevice->wasapi.pCaptureClient) {
-        ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-    }
-
-    if (pDevice->wasapi.pAudioClientPlayback) {
-        ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-    }
-    if (pDevice->wasapi.pAudioClientCapture) {
-        ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-    }
-
-    if (pDevice->wasapi.hEventPlayback) {
-        CloseHandle(pDevice->wasapi.hEventPlayback);
-    }
-    if (pDevice->wasapi.hEventCapture) {
-        CloseHandle(pDevice->wasapi.hEventCapture);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    /* Input. */
-    ma_format formatIn;
-    ma_uint32 channelsIn;
-    ma_uint32 sampleRateIn;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesIn;
-    ma_uint32 periodSizeInMillisecondsIn;
-    ma_uint32 periodsIn;
-    ma_share_mode shareMode;
-    ma_performance_profile performanceProfile;
-    ma_bool32 noAutoConvertSRC;
-    ma_bool32 noDefaultQualitySRC;
-    ma_bool32 noHardwareOffloading;
-
-    /* Output. */
-    ma_IAudioClient* pAudioClient;
-    ma_IAudioRenderClient* pRenderClient;
-    ma_IAudioCaptureClient* pCaptureClient;
-    ma_format formatOut;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesOut;
-    ma_uint32 periodsOut;
-    ma_bool32 usingAudioClient3;
-    char deviceName[256];
-    ma_device_id id;
-} ma_device_init_internal_data__wasapi;
-
-static ma_result ma_device_init_internal__wasapi(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__wasapi* pData)
-{
-    HRESULT hr;
-    ma_result result = MA_SUCCESS;
-    const char* errorMsg = "";
-    MA_AUDCLNT_SHAREMODE shareMode = MA_AUDCLNT_SHAREMODE_SHARED;
-    DWORD streamFlags = 0;
-    MA_REFERENCE_TIME periodDurationInMicroseconds;
-    ma_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE;
-    WAVEFORMATEXTENSIBLE wf;
-    ma_WASAPIDeviceInterface* pDeviceInterface = NULL;
-    ma_IAudioClient2* pAudioClient2;
-    ma_uint32 nativeSampleRate;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pData != NULL);
-
-    /* This function is only used to initialize one device type: either playback, capture or loopback. Never full-duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    pData->pAudioClient = NULL;
-    pData->pRenderClient = NULL;
-    pData->pCaptureClient = NULL;
-
-    streamFlags = MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
-    if (!pData->noAutoConvertSRC && pData->sampleRateIn != 0 && pData->shareMode != ma_share_mode_exclusive) {    /* <-- Exclusive streams must use the native sample rate. */
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM;
-    }
-    if (!pData->noDefaultQualitySRC && pData->sampleRateIn != 0 && (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) != 0) {
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY;
-    }
-    if (deviceType == ma_device_type_loopback) {
-        streamFlags |= MA_AUDCLNT_STREAMFLAGS_LOOPBACK;
-    }
-
-    result = ma_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, &pData->pAudioClient, &pDeviceInterface);
-    if (result != MA_SUCCESS) {
-        goto done;
-    }
-
-    MA_ZERO_OBJECT(&wf);
-
-    /* Try enabling hardware offloading. */
-    if (!pData->noHardwareOffloading) {
-        hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient2, (void**)&pAudioClient2);
-        if (SUCCEEDED(hr)) {
-            BOOL isHardwareOffloadingSupported = 0;
-            hr = ma_IAudioClient2_IsOffloadCapable(pAudioClient2, MA_AudioCategory_Other, &isHardwareOffloadingSupported);
-            if (SUCCEEDED(hr) && isHardwareOffloadingSupported) {
-                ma_AudioClientProperties clientProperties;
-                MA_ZERO_OBJECT(&clientProperties);
-                clientProperties.cbSize = sizeof(clientProperties);
-                clientProperties.bIsOffload = 1;
-                clientProperties.eCategory = MA_AudioCategory_Other;
-                ma_IAudioClient2_SetClientProperties(pAudioClient2, &clientProperties);
-            }
-
-            pAudioClient2->lpVtbl->Release(pAudioClient2);
-        }
-    }
-
-    /* Here is where we try to determine the best format to use with the device. If the client if wanting exclusive mode, first try finding the best format for that. If this fails, fall back to shared mode. */
-    result = MA_FORMAT_NOT_SUPPORTED;
-    if (pData->shareMode == ma_share_mode_exclusive) {
-    #ifdef MA_WIN32_DESKTOP
-        /* In exclusive mode on desktop we always use the backend's native format. */
-        ma_IPropertyStore* pStore = NULL;
-        hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT prop;
-            ma_PropVariantInit(&prop);
-            hr = ma_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop);
-            if (SUCCEEDED(hr)) {
-                WAVEFORMATEX* pActualFormat = (WAVEFORMATEX*)prop.blob.pBlobData;
-                hr = ma_IAudioClient_IsFormatSupported((ma_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL);
-                if (SUCCEEDED(hr)) {
-                    MA_COPY_MEMORY(&wf, pActualFormat, sizeof(WAVEFORMATEXTENSIBLE));
-                }
-
-                ma_PropVariantClear(pContext, &prop);
-            }
-
-            ma_IPropertyStore_Release(pStore);
-        }
-    #else
-        /*
-        I do not know how to query the device's native format on UWP so for now I'm just disabling support for
-        exclusive mode. The alternative is to enumerate over different formats and check IsFormatSupported()
-        until you find one that works.
-
-        TODO: Add support for exclusive mode to UWP.
-        */
-        hr = S_FALSE;
-    #endif
-
-        if (hr == S_OK) {
-            shareMode = MA_AUDCLNT_SHAREMODE_EXCLUSIVE;
-            result = MA_SUCCESS;
-        } else {
-            result = MA_SHARE_MODE_NOT_SUPPORTED;
-        }
-    } else {
-        /* In shared mode we are always using the format reported by the operating system. */
-        WAVEFORMATEXTENSIBLE* pNativeFormat = NULL;
-        hr = ma_IAudioClient_GetMixFormat((ma_IAudioClient*)pData->pAudioClient, (WAVEFORMATEX**)&pNativeFormat);
-        if (hr != S_OK) {
-            result = MA_FORMAT_NOT_SUPPORTED;
-        } else {
-            MA_COPY_MEMORY(&wf, pNativeFormat, sizeof(wf));
-            result = MA_SUCCESS;
-        }
-
-        ma_CoTaskMemFree(pContext, pNativeFormat);
-
-        shareMode = MA_AUDCLNT_SHAREMODE_SHARED;
-    }
-
-    /* Return an error if we still haven't found a format. */
-    if (result != MA_SUCCESS) {
-        errorMsg = "[WASAPI] Failed to find best device mix format.";
-        goto done;
-    }
-
-    /*
-    Override the native sample rate with the one requested by the caller, but only if we're not using the default sample rate. We'll use
-    WASAPI to perform the sample rate conversion.
-    */
-    nativeSampleRate = wf.Format.nSamplesPerSec;
-    if (streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) {
-        wf.Format.nSamplesPerSec = (pData->sampleRateIn != 0) ? pData->sampleRateIn : MA_DEFAULT_SAMPLE_RATE;
-        wf.Format.nAvgBytesPerSec = wf.Format.nSamplesPerSec * wf.Format.nBlockAlign;
-    }
-
-    pData->formatOut = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)&wf);
-    if (pData->formatOut == ma_format_unknown) {
-        /*
-        The format isn't supported. This is almost certainly because the exclusive mode format isn't supported by miniaudio. We need to return MA_SHARE_MODE_NOT_SUPPORTED
-        in this case so that the caller can detect it and fall back to shared mode if desired. We should never get here if shared mode was requested, but just for
-        completeness we'll check for it and return MA_FORMAT_NOT_SUPPORTED.
-        */
-        if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) {
-            result = MA_SHARE_MODE_NOT_SUPPORTED;
-        } else {
-            result = MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        errorMsg = "[WASAPI] Native format not supported.";
-        goto done;
-    }
-
-    pData->channelsOut = wf.Format.nChannels;
-    pData->sampleRateOut = wf.Format.nSamplesPerSec;
-
-    /* Get the internal channel map based on the channel mask. */
-    ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pData->channelsOut, pData->channelMapOut);
-
-    /* Period size. */
-    pData->periodsOut = (pData->periodsIn != 0) ? pData->periodsIn : MA_DEFAULT_PERIODS;
-    pData->periodSizeInFramesOut = pData->periodSizeInFramesIn;
-    if (pData->periodSizeInFramesOut == 0) {
-        if (pData->periodSizeInMillisecondsIn == 0) {
-            if (pData->performanceProfile == ma_performance_profile_low_latency) {
-                pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, wf.Format.nSamplesPerSec);
-            } else {
-                pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, wf.Format.nSamplesPerSec);
-            }
-        } else {
-            pData->periodSizeInFramesOut = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, wf.Format.nSamplesPerSec);
-        }
-    }
-
-    periodDurationInMicroseconds = ((ma_uint64)pData->periodSizeInFramesOut * 1000 * 1000) / wf.Format.nSamplesPerSec;
-
-
-    /* Slightly different initialization for shared and exclusive modes. We try exclusive mode first, and if it fails, fall back to shared mode. */
-    if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) {
-        MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * 10;
-
-        /*
-        If the periodicy is too small, Initialize() will fail with AUDCLNT_E_INVALID_DEVICE_PERIOD. In this case we should just keep increasing
-        it and trying it again.
-        */
-        hr = E_FAIL;
-        for (;;) {
-            hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
-            if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) {
-                if (bufferDuration > 500*10000) {
-                    break;
-                } else {
-                    if (bufferDuration == 0) {  /* <-- Just a sanity check to prevent an infinit loop. Should never happen, but it makes me feel better. */
-                        break;
-                    }
-
-                    bufferDuration = bufferDuration * 2;
-                    continue;
-                }
-            } else {
-                break;
-            }
-        }
-
-        if (hr == MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) {
-            ma_uint32 bufferSizeInFrames;
-            hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
-            if (SUCCEEDED(hr)) {
-                bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.Format.nSamplesPerSec * bufferSizeInFrames) + 0.5);
-
-                /* Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?! */
-                ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient);
-
-            #ifdef MA_WIN32_DESKTOP
-                hr = ma_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient);
-            #else
-                hr = ma_IUnknown_QueryInterface(pDeviceInterface, &MA_IID_IAudioClient, (void**)&pData->pAudioClient);
-            #endif
-
-                if (SUCCEEDED(hr)) {
-                    hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL);
-                }
-            }
-        }
-
-        if (FAILED(hr)) {
-            /* Failed to initialize in exclusive mode. Don't fall back to shared mode - instead tell the client about it. They can reinitialize in shared mode if they want. */
-            if (hr == E_ACCESSDENIED) {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Access denied.", result = MA_ACCESS_DENIED;
-            } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Device in use.", result = MA_BUSY;
-            } else {
-                errorMsg = "[WASAPI] Failed to initialize device in exclusive mode."; result = ma_result_from_HRESULT(hr);
-            }
-            goto done;
-        }
-    }
-
-    if (shareMode == MA_AUDCLNT_SHAREMODE_SHARED) {
-        /*
-        Low latency shared mode via IAudioClient3.
-
-        NOTE
-        ====
-        Contrary to the documentation on MSDN (https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclient3-initializesharedaudiostream), the
-        use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM and AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY with IAudioClient3_InitializeSharedAudioStream() absolutely does not work. Using
-        any of these flags will result in HRESULT code 0x88890021. The other problem is that calling IAudioClient3_GetSharedModeEnginePeriod() with a sample rate different to
-        that returned by IAudioClient_GetMixFormat() also results in an error. I'm therefore disabling low-latency shared mode with AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM.
-        */
-#ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE
-        if ((streamFlags & MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM) == 0 || nativeSampleRate == wf.Format.nSamplesPerSec) {
-            ma_IAudioClient3* pAudioClient3 = NULL;
-            hr = ma_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3);
-            if (SUCCEEDED(hr)) {
-                ma_uint32 defaultPeriodInFrames;
-                ma_uint32 fundamentalPeriodInFrames;
-                ma_uint32 minPeriodInFrames;
-                ma_uint32 maxPeriodInFrames;
-                hr = ma_IAudioClient3_GetSharedModeEnginePeriod(pAudioClient3, (WAVEFORMATEX*)&wf, &defaultPeriodInFrames, &fundamentalPeriodInFrames, &minPeriodInFrames, &maxPeriodInFrames);
-                if (SUCCEEDED(hr)) {
-                    ma_uint32 desiredPeriodInFrames = pData->periodSizeInFramesOut;
-                    ma_uint32 actualPeriodInFrames  = desiredPeriodInFrames;
-
-                    /* Make sure the period size is a multiple of fundamentalPeriodInFrames. */
-                    actualPeriodInFrames = actualPeriodInFrames / fundamentalPeriodInFrames;
-                    actualPeriodInFrames = actualPeriodInFrames * fundamentalPeriodInFrames;
-
-                    /* The period needs to be clamped between minPeriodInFrames and maxPeriodInFrames. */
-                    actualPeriodInFrames = ma_clamp(actualPeriodInFrames, minPeriodInFrames, maxPeriodInFrames);
-
-                #if defined(MA_DEBUG_OUTPUT)
-                    printf("[WASAPI] Trying IAudioClient3_InitializeSharedAudioStream(actualPeriodInFrames=%d)\n", actualPeriodInFrames);
-                    printf("    defaultPeriodInFrames=%d\n", defaultPeriodInFrames);
-                    printf("    fundamentalPeriodInFrames=%d\n", fundamentalPeriodInFrames);
-                    printf("    minPeriodInFrames=%d\n", minPeriodInFrames);
-                    printf("    maxPeriodInFrames=%d\n", maxPeriodInFrames);
-                #endif
-
-                    /* If the client requested a largish buffer than we don't actually want to use low latency shared mode because it forces small buffers. */
-                    if (actualPeriodInFrames >= desiredPeriodInFrames) {
-                        /*
-                        MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY must not be in the stream flags. If either of these are specified,
-                        IAudioClient3_InitializeSharedAudioStream() will fail.
-                        */
-                        hr = ma_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, streamFlags & ~(MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY), actualPeriodInFrames, (WAVEFORMATEX*)&wf, NULL);
-                        if (SUCCEEDED(hr)) {
-                            wasInitializedUsingIAudioClient3 = MA_TRUE;
-                            pData->periodSizeInFramesOut = actualPeriodInFrames;
-                        #if defined(MA_DEBUG_OUTPUT)
-                            printf("[WASAPI] Using IAudioClient3\n");
-                            printf("    periodSizeInFramesOut=%d\n", pData->periodSizeInFramesOut);
-                        #endif
-                        } else {
-                        #if defined(MA_DEBUG_OUTPUT)
-                            printf("[WASAPI] IAudioClient3_InitializeSharedAudioStream failed. Falling back to IAudioClient.\n");
-                        #endif
-                        }
-                    } else {
-                    #if defined(MA_DEBUG_OUTPUT)
-                        printf("[WASAPI] Not using IAudioClient3 because the desired period size is larger than the maximum supported by IAudioClient3.\n");
-                    #endif
-                    }
-                } else {
-                #if defined(MA_DEBUG_OUTPUT)
-                    printf("[WASAPI] IAudioClient3_GetSharedModeEnginePeriod failed. Falling back to IAudioClient.\n");
-                #endif
-                }
-
-                ma_IAudioClient3_Release(pAudioClient3);
-                pAudioClient3 = NULL;
-            }
-        }
-#else
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("[WASAPI] Not using IAudioClient3 because MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE is enabled.\n");
-    #endif
-#endif
-
-        /* If we don't have an IAudioClient3 then we need to use the normal initialization routine. */
-        if (!wasInitializedUsingIAudioClient3) {
-            MA_REFERENCE_TIME bufferDuration = periodDurationInMicroseconds * pData->periodsOut * 10;   /* <-- Multiply by 10 for microseconds to 100-nanoseconds. */
-            hr = ma_IAudioClient_Initialize((ma_IAudioClient*)pData->pAudioClient, shareMode, streamFlags, bufferDuration, 0, (WAVEFORMATEX*)&wf, NULL);
-            if (FAILED(hr)) {
-                if (hr == E_ACCESSDENIED) {
-                    errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED;
-                } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) {
-                    errorMsg = "[WASAPI] Failed to initialize device. Device in use.", result = MA_BUSY;
-                } else {
-                    errorMsg = "[WASAPI] Failed to initialize device.", result = ma_result_from_HRESULT(hr);
-                }
-
-                goto done;
-            }
-        }
-    }
-
-    if (!wasInitializedUsingIAudioClient3) {
-        ma_uint32 bufferSizeInFrames;
-        hr = ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames);
-        if (FAILED(hr)) {
-            errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = ma_result_from_HRESULT(hr);
-            goto done;
-        }
-
-        pData->periodSizeInFramesOut = bufferSizeInFrames / pData->periodsOut;
-    }
-
-    pData->usingAudioClient3 = wasInitializedUsingIAudioClient3;
-
-    
-    if (deviceType == ma_device_type_playback) {
-        result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pRenderClient);
-    } else {
-        result = ma_device_create_IAudioClient_service__wasapi(pContext, deviceType, (ma_IAudioClient*)pData->pAudioClient, (void**)&pData->pCaptureClient);
-    }
-
-    /*if (FAILED(hr)) {*/
-    if (result != MA_SUCCESS) {
-        errorMsg = "[WASAPI] Failed to get audio client service.";
-        goto done;
-    }
-
-
-    /* Grab the name of the device. */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        ma_IPropertyStore *pProperties;
-        hr = ma_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pProperties);
-        if (SUCCEEDED(hr)) {
-            PROPVARIANT varName;
-            ma_PropVariantInit(&varName);
-            hr = ma_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &varName);
-            if (SUCCEEDED(hr)) {
-                WideCharToMultiByte(CP_UTF8, 0, varName.pwszVal, -1, pData->deviceName, sizeof(pData->deviceName), 0, FALSE);
-                ma_PropVariantClear(pContext, &varName);
-            }
-
-            ma_IPropertyStore_Release(pProperties);
-        }
-    }
-    #endif
-
-    /*
-    For the WASAPI backend we need to know the actual IDs of the device in order to do automatic
-    stream routing so that IDs can be compared and we can determine which device has been detached
-    and whether or not it matches with our ma_device.
-    */
-    #ifdef MA_WIN32_DESKTOP
-    {
-        /* Desktop */
-        ma_context_get_device_id_from_MMDevice__wasapi(pContext, pDeviceInterface, &pData->id);
-    }
-    #else
-    {
-        /* UWP */
-        /* TODO: Implement me. Need to figure out how to get the ID of the default device. */
-    }
-    #endif
-
-done:
-    /* Clean up. */
-#ifdef MA_WIN32_DESKTOP
-    if (pDeviceInterface != NULL) {
-        ma_IMMDevice_Release(pDeviceInterface);
-    }
-#else
-    if (pDeviceInterface != NULL) {
-        ma_IUnknown_Release(pDeviceInterface);
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        if (pData->pRenderClient) {
-            ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pData->pRenderClient);
-            pData->pRenderClient = NULL;
-        }
-        if (pData->pCaptureClient) {
-            ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pData->pCaptureClient);
-            pData->pCaptureClient = NULL;
-        }
-        if (pData->pAudioClient) {
-            ma_IAudioClient_Release((ma_IAudioClient*)pData->pAudioClient);
-            pData->pAudioClient = NULL;
-        }
-
-        if (errorMsg != NULL && errorMsg[0] != '\0') {
-            ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, errorMsg, result);
-        }
-
-        return result;
-    } else {
-        return MA_SUCCESS;
-    }
-}
-
-static ma_result ma_device_reinit__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_device_init_internal_data__wasapi data;
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* We only re-initialize the playback or capture device. Never a full-duplex device. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-
-    /*
-    Before reinitializing the device we need to free the previous audio clients.
-
-    There's a known memory leak here. We will be calling this from the routing change callback that
-    is fired by WASAPI. If we attempt to release the IAudioClient we will deadlock. In my opinion
-    this is a bug. I'm not sure what I need to do to handle this cleanly, but I think we'll probably
-    need some system where we post an event, but delay the execution of it until the callback has
-    returned. I'm not sure how to do this reliably, however. I have set up some infrastructure for
-    a command thread which might be useful for this.
-    */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) {
-        if (pDevice->wasapi.pCaptureClient) {
-            ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-            pDevice->wasapi.pCaptureClient = NULL;
-        }
-
-        if (pDevice->wasapi.pAudioClientCapture) {
-            /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_capture);*/
-            pDevice->wasapi.pAudioClientCapture = NULL;
-        }
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        if (pDevice->wasapi.pRenderClient) {
-            ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-            pDevice->wasapi.pRenderClient = NULL;
-        }
-
-        if (pDevice->wasapi.pAudioClientPlayback) {
-            /*ma_device_release_IAudioClient_service__wasapi(pDevice, ma_device_type_playback);*/
-            pDevice->wasapi.pAudioClientPlayback = NULL;
-        }
-    }
-
-
-    if (deviceType == ma_device_type_playback) {
-        data.formatIn               = pDevice->playback.format;
-        data.channelsIn             = pDevice->playback.channels;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap));
-        data.shareMode              = pDevice->playback.shareMode;
-    } else {
-        data.formatIn               = pDevice->capture.format;
-        data.channelsIn             = pDevice->capture.channels;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap));
-        data.shareMode              = pDevice->capture.shareMode;
-    }
-
-    data.sampleRateIn               = pDevice->sampleRate;
-    data.periodSizeInFramesIn       = pDevice->wasapi.originalPeriodSizeInFrames;
-    data.periodSizeInMillisecondsIn = pDevice->wasapi.originalPeriodSizeInMilliseconds;
-    data.periodsIn                  = pDevice->wasapi.originalPeriods;
-    data.performanceProfile         = pDevice->wasapi.originalPerformanceProfile;
-    data.noAutoConvertSRC           = pDevice->wasapi.noAutoConvertSRC;
-    data.noDefaultQualitySRC        = pDevice->wasapi.noDefaultQualitySRC;
-    data.noHardwareOffloading       = pDevice->wasapi.noHardwareOffloading;
-    result = ma_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* At this point we have some new objects ready to go. We need to uninitialize the previous ones and then set the new ones. */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_loopback) {
-        pDevice->wasapi.pAudioClientCapture         = data.pAudioClient;
-        pDevice->wasapi.pCaptureClient              = data.pCaptureClient;
-
-        pDevice->capture.internalFormat             = data.formatOut;
-        pDevice->capture.internalChannels           = data.channelsOut;
-        pDevice->capture.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->capture.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->capture.internalPeriods            = data.periodsOut;
-        ma_strcpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), data.deviceName);
-
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture,  pDevice->wasapi.hEventCapture);
-
-        pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualPeriodSizeInFramesCapture);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        pDevice->wasapi.pAudioClientPlayback         = data.pAudioClient;
-        pDevice->wasapi.pRenderClient                = data.pRenderClient;
-
-        pDevice->playback.internalFormat             = data.formatOut;
-        pDevice->playback.internalChannels           = data.channelsOut;
-        pDevice->playback.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->playback.internalPeriods            = data.periodsOut;
-        ma_strcpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), data.deviceName);
-
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
-
-        pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualPeriodSizeInFramesPlayback);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result = MA_SUCCESS;
-
-#ifdef MA_WIN32_DESKTOP
-    HRESULT hr;
-    ma_IMMDeviceEnumerator* pDeviceEnumerator;
-#endif
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->wasapi);
-    pDevice->wasapi.noAutoConvertSRC     = pConfig->wasapi.noAutoConvertSRC;
-    pDevice->wasapi.noDefaultQualitySRC  = pConfig->wasapi.noDefaultQualitySRC;
-    pDevice->wasapi.noHardwareOffloading = pConfig->wasapi.noHardwareOffloading;
-
-    /* Exclusive mode is not allowed with loopback. */
-    if (pConfig->deviceType == ma_device_type_loopback && pConfig->playback.shareMode == ma_share_mode_exclusive) {
-        return MA_INVALID_DEVICE_CONFIG;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        ma_device_init_internal_data__wasapi data;
-        data.formatIn                   = pDescriptorCapture->format;
-        data.channelsIn                 = pDescriptorCapture->channels;
-        data.sampleRateIn               = pDescriptorCapture->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap));
-        data.periodSizeInFramesIn       = pDescriptorCapture->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn = pDescriptorCapture->periodSizeInMilliseconds;
-        data.periodsIn                  = pDescriptorCapture->periodCount;
-        data.shareMode                  = pDescriptorCapture->shareMode;
-        data.performanceProfile         = pConfig->performanceProfile;
-        data.noAutoConvertSRC           = pConfig->wasapi.noAutoConvertSRC;
-        data.noDefaultQualitySRC        = pConfig->wasapi.noDefaultQualitySRC;
-        data.noHardwareOffloading       = pConfig->wasapi.noHardwareOffloading;
-
-        result = ma_device_init_internal__wasapi(pDevice->pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_loopback : ma_device_type_capture, pDescriptorCapture->pDeviceID, &data);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pDevice->wasapi.pAudioClientCapture              = data.pAudioClient;
-        pDevice->wasapi.pCaptureClient                   = data.pCaptureClient;
-        pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds;
-        pDevice->wasapi.originalPeriodSizeInFrames       = pDescriptorCapture->periodSizeInFrames;
-        pDevice->wasapi.originalPeriods                  = pDescriptorCapture->periodCount;
-        pDevice->wasapi.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        /*
-        The event for capture needs to be manual reset for the same reason as playback. We keep the initial state set to unsignaled,
-        however, because we want to block until we actually have something for the first call to ma_device_read().
-        */
-        pDevice->wasapi.hEventCapture = CreateEventW(NULL, FALSE, FALSE, NULL);  /* Auto reset, unsignaled by default. */
-        if (pDevice->wasapi.hEventCapture == NULL) {
-            result = ma_result_from_GetLastError(GetLastError());
-
-            if (pDevice->wasapi.pCaptureClient != NULL) {
-                ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                pDevice->wasapi.pCaptureClient = NULL;
-            }
-            if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                pDevice->wasapi.pAudioClientCapture = NULL;
-            }
-
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture.", result);
-        }
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, pDevice->wasapi.hEventCapture);
-
-        pDevice->wasapi.periodSizeInFramesCapture = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &pDevice->wasapi.actualPeriodSizeInFramesCapture);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->capture.id.wasapi, sizeof(pDevice->capture.id.wasapi), data.id.wasapi);
-
-        /* The descriptor needs to be updated with actual values. */
-        pDescriptorCapture->format             = data.formatOut;
-        pDescriptorCapture->channels           = data.channelsOut;
-        pDescriptorCapture->sampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorCapture->periodSizeInFrames = data.periodSizeInFramesOut;
-        pDescriptorCapture->periodCount        = data.periodsOut;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__wasapi data;
-        data.formatIn                   = pDescriptorPlayback->format;
-        data.channelsIn                 = pDescriptorPlayback->channels;
-        data.sampleRateIn               = pDescriptorPlayback->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap));
-        data.periodSizeInFramesIn       = pDescriptorPlayback->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds;
-        data.periodsIn                  = pDescriptorPlayback->periodCount;
-        data.shareMode                  = pDescriptorPlayback->shareMode;
-        data.performanceProfile         = pConfig->performanceProfile;
-        data.noAutoConvertSRC           = pConfig->wasapi.noAutoConvertSRC;
-        data.noDefaultQualitySRC        = pConfig->wasapi.noDefaultQualitySRC;
-        data.noHardwareOffloading       = pConfig->wasapi.noHardwareOffloading;
-
-        result = ma_device_init_internal__wasapi(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                if (pDevice->wasapi.pCaptureClient != NULL) {
-                    ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                    pDevice->wasapi.pCaptureClient = NULL;
-                }
-                if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                    ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                    pDevice->wasapi.pAudioClientCapture = NULL;
-                }
-
-                CloseHandle(pDevice->wasapi.hEventCapture);
-                pDevice->wasapi.hEventCapture = NULL;
-            }
-            return result;
-        }
-
-        pDevice->wasapi.pAudioClientPlayback             = data.pAudioClient;
-        pDevice->wasapi.pRenderClient                    = data.pRenderClient;
-        pDevice->wasapi.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds;
-        pDevice->wasapi.originalPeriodSizeInFrames       = pDescriptorPlayback->periodSizeInFrames;
-        pDevice->wasapi.originalPeriods                  = pDescriptorPlayback->periodCount;
-        pDevice->wasapi.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        /*
-        The event for playback is needs to be manual reset because we want to explicitly control the fact that it becomes signalled
-        only after the whole available space has been filled, never before.
-
-        The playback event also needs to be initially set to a signaled state so that the first call to ma_device_write() is able
-        to get passed WaitForMultipleObjects().
-        */
-        pDevice->wasapi.hEventPlayback = CreateEventW(NULL, FALSE, TRUE, NULL);  /* Auto reset, signaled by default. */
-        if (pDevice->wasapi.hEventPlayback == NULL) {
-            result = ma_result_from_GetLastError(GetLastError());
-
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                if (pDevice->wasapi.pCaptureClient != NULL) {
-                    ma_IAudioCaptureClient_Release((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient);
-                    pDevice->wasapi.pCaptureClient = NULL;
-                }
-                if (pDevice->wasapi.pAudioClientCapture != NULL) {
-                    ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                    pDevice->wasapi.pAudioClientCapture = NULL;
-                }
-
-                CloseHandle(pDevice->wasapi.hEventCapture);
-                pDevice->wasapi.hEventCapture = NULL;
-            }
-
-            if (pDevice->wasapi.pRenderClient != NULL) {
-                ma_IAudioRenderClient_Release((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient);
-                pDevice->wasapi.pRenderClient = NULL;
-            }
-            if (pDevice->wasapi.pAudioClientPlayback != NULL) {
-                ma_IAudioClient_Release((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                pDevice->wasapi.pAudioClientPlayback = NULL;
-            }
-
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback.", result);
-        }
-        ma_IAudioClient_SetEventHandle((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback);
-
-        pDevice->wasapi.periodSizeInFramesPlayback = data.periodSizeInFramesOut;
-        ma_IAudioClient_GetBufferSize((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.actualPeriodSizeInFramesPlayback);
-
-        /* We must always have a valid ID. */
-        ma_wcscpy_s(pDevice->playback.id.wasapi, sizeof(pDevice->playback.id.wasapi), data.id.wasapi);
-
-        /* The descriptor needs to be updated with actual values. */
-        pDescriptorPlayback->format             = data.formatOut;
-        pDescriptorPlayback->channels           = data.channelsOut;
-        pDescriptorPlayback->sampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorPlayback->periodSizeInFrames = data.periodSizeInFramesOut;
-        pDescriptorPlayback->periodCount        = data.periodsOut;
-    }
-
-    /*
-    We need to register a notification client to detect when the device has been disabled, unplugged or re-routed (when the default device changes). When
-    we are connecting to the default device we want to do automatic stream routing when the device is disabled or unplugged. Otherwise we want to just
-    stop the device outright and let the application handle it.
-    */
-#ifdef MA_WIN32_DESKTOP
-    if (pConfig->wasapi.noAutoStreamRouting == MA_FALSE) {
-        if ((pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.pDeviceID == NULL) {
-            pDevice->wasapi.allowCaptureAutoStreamRouting = MA_TRUE;
-        }
-        if ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.pDeviceID == NULL) {
-            pDevice->wasapi.allowPlaybackAutoStreamRouting = MA_TRUE;
-        }
-    }
-
-    hr = ma_CoCreateInstance(pDevice->pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
-    if (FAILED(hr)) {
-        ma_device_uninit__wasapi(pDevice);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", ma_result_from_HRESULT(hr));
-    }
-
-    pDevice->wasapi.notificationClient.lpVtbl  = (void*)&g_maNotificationCientVtbl;
-    pDevice->wasapi.notificationClient.counter = 1;
-    pDevice->wasapi.notificationClient.pDevice = pDevice;
-
-    hr = pDeviceEnumerator->lpVtbl->RegisterEndpointNotificationCallback(pDeviceEnumerator, &pDevice->wasapi.notificationClient);
-    if (SUCCEEDED(hr)) {
-        pDevice->wasapi.pDeviceEnumerator = (ma_ptr)pDeviceEnumerator;
-    } else {
-        /* Not the end of the world if we fail to register the notification callback. We just won't support automatic stream routing. */
-        ma_IMMDeviceEnumerator_Release(pDeviceEnumerator);
-    }
-#endif
-
-    c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture,  MA_FALSE);
-    c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__get_available_frames__wasapi(ma_device* pDevice, ma_IAudioClient* pAudioClient, ma_uint32* pFrameCount)
-{
-    ma_uint32 paddingFramesCount;
-    HRESULT hr;
-    ma_share_mode shareMode;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFrameCount != NULL);
-
-    *pFrameCount = 0;
-
-    if ((ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientPlayback && (ma_ptr)pAudioClient != pDevice->wasapi.pAudioClientCapture) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    I've had a report that GetCurrentPadding() is returning a frame count of 0 which is preventing
-    higher level function calls from doing anything because it thinks nothing is available. I have
-    taken a look at the documentation and it looks like this is unnecessary in exclusive mode.
-
-    From Microsoft's documentation:
-
-        For an exclusive-mode rendering or capture stream that was initialized with the
-        AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag, the client typically has no use for the padding
-        value reported by GetCurrentPadding. Instead, the client accesses an entire buffer during
-        each processing pass.
-
-    Considering this, I'm going to skip GetCurrentPadding() for exclusive mode and just report the
-    entire buffer. This depends on the caller making sure they wait on the event handler.
-    */
-    shareMode = ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) ? pDevice->playback.shareMode : pDevice->capture.shareMode;
-    if (shareMode == ma_share_mode_shared) {
-        /* Shared mode. */
-        hr = ma_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount);
-        if (FAILED(hr)) {
-            return ma_result_from_HRESULT(hr);
-        }
-
-        if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback - paddingFramesCount;
-        } else {
-            *pFrameCount = paddingFramesCount;
-        }
-    } else {
-        /* Exclusive mode. */
-        if ((ma_ptr)pAudioClient == pDevice->wasapi.pAudioClientPlayback) {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesPlayback;
-        } else {
-            *pFrameCount = pDevice->wasapi.actualPeriodSizeInFramesCapture;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_reroute__wasapi(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("=== CHANGING DEVICE ===\n");
-#endif
-
-    result = ma_device_reinit__wasapi(pDevice, deviceType);
-    if (result != MA_SUCCESS) {
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[WASAPI] Reinitializing device after route change failed.\n");
-    #endif
-        return result;
-    }
-
-    ma_device__post_init_setup(pDevice, deviceType);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__wasapi(ma_device* pDevice)
-{
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_TRUE);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* No need to do anything for playback as that'll be started automatically in the data loop. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__wasapi(ma_device* pDevice)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* The audio client needs to be reset otherwise restarting will fail. */
-        hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /*
-        The buffer needs to be drained before stopping the device. Not doing this will result in the last few frames not getting output to
-        the speakers. This is a problem for very short sounds because it'll result in a significant portion of it not getting played.
-        */
-        if (c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-            /* We need to make sure we put a timeout here or else we'll risk getting stuck in a deadlock in some cases. */
-            DWORD waitTime = pDevice->wasapi.actualPeriodSizeInFramesPlayback / pDevice->playback.internalSampleRate;
-
-            if (pDevice->playback.shareMode == ma_share_mode_exclusive) {
-                WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
-            } else {
-                ma_uint32 prevFramesAvaialablePlayback = (ma_uint32)-1;
-                ma_uint32 framesAvailablePlayback;
-                for (;;) {
-                    result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                    if (result != MA_SUCCESS) {
-                        break;
-                    }
-
-                    if (framesAvailablePlayback >= pDevice->wasapi.actualPeriodSizeInFramesPlayback) {
-                        break;
-                    }
-
-                    /*
-                    Just a safety check to avoid an infinite loop. If this iteration results in a situation where the number of available frames
-                    has not changed, get out of the loop. I don't think this should ever happen, but I think it's nice to have just in case.
-                    */
-                    if (framesAvailablePlayback == prevFramesAvaialablePlayback) {
-                        break;
-                    }
-                    prevFramesAvaialablePlayback = framesAvailablePlayback;
-
-                    WaitForSingleObject(pDevice->wasapi.hEventPlayback, waitTime);
-                    ResetEvent(pDevice->wasapi.hEventPlayback); /* Manual reset. */
-                }
-            }
-        }
-
-        hr = ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* The audio client needs to be reset otherwise restarting will fail. */
-        hr = ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-#ifndef MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS
-#define MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS 5000
-#endif
-
-static ma_result ma_device_data_loop__wasapi(ma_device* pDevice)
-{
-    ma_result result;
-    HRESULT hr;
-    ma_bool32 exitLoop = MA_FALSE;
-    ma_uint32 framesWrittenToPlaybackDevice = 0;
-    ma_uint32 mappedDeviceBufferSizeInFramesCapture = 0;
-    ma_uint32 mappedDeviceBufferSizeInFramesPlayback = 0;
-    ma_uint32 mappedDeviceBufferFramesRemainingCapture = 0;
-    ma_uint32 mappedDeviceBufferFramesRemainingPlayback = 0;
-    BYTE* pMappedDeviceBufferCapture = NULL;
-    BYTE* pMappedDeviceBufferPlayback = NULL;
-    ma_uint32 bpfCaptureDevice = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    ma_uint32 bpfPlaybackDevice = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    ma_uint32 bpfCaptureClient = ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-    ma_uint32 bpfPlaybackClient = ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-    ma_uint8  inputDataInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 inputDataInClientFormatCap = 0;
-    ma_uint8  outputDataInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-    ma_uint32 outputDataInClientFormatCap = 0;
-    ma_uint32 outputDataInClientFormatCount = 0;
-    ma_uint32 outputDataInClientFormatConsumed = 0;
-    ma_uint32 periodSizeInFramesCapture = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        periodSizeInFramesCapture  = pDevice->capture.internalPeriodSizeInFrames;
-        inputDataInClientFormatCap = sizeof(inputDataInClientFormat) / bpfCaptureClient;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        outputDataInClientFormatCap = sizeof(outputDataInClientFormat) / bpfPlaybackClient;
-    }
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && !exitLoop) {
-        switch (pDevice->type)
-        {
-            case ma_device_type_duplex:
-            {
-                ma_uint32 framesAvailableCapture;
-                ma_uint32 framesAvailablePlayback;
-                DWORD flagsCapture;    /* Passed to IAudioCaptureClient_GetBuffer(). */
-
-                /* The process is to map the playback buffer and fill it as quickly as possible from input data. */
-                if (pMappedDeviceBufferPlayback == NULL) {
-                    result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                    if (result != MA_SUCCESS) {
-                        return result;
-                    }
-
-                    /*printf("TRACE 1: framesAvailablePlayback=%d\n", framesAvailablePlayback);*/
-
-
-                    /* In exclusive mode, the frame count needs to exactly match the value returned by GetCurrentPadding(). */
-                    if (pDevice->playback.shareMode != ma_share_mode_exclusive) {
-                        if (framesAvailablePlayback > pDevice->wasapi.periodSizeInFramesPlayback) {
-                            framesAvailablePlayback = pDevice->wasapi.periodSizeInFramesPlayback;
-                        }
-                    }
-
-                    /* We're ready to map the playback device's buffer. We don't release this until it's been entirely filled. */
-                    hr = ma_IAudioRenderClient_GetBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedDeviceBufferPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    mappedDeviceBufferSizeInFramesPlayback    = framesAvailablePlayback;
-                    mappedDeviceBufferFramesRemainingPlayback = framesAvailablePlayback;
-                }
-
-                if (mappedDeviceBufferFramesRemainingPlayback > 0) {
-                    /* At this point we should have a buffer available for output. We need to keep writing input samples to it. */
-                    for (;;) {
-                        /* Try grabbing some captured data if we haven't already got a mapped buffer. */
-                        if (pMappedDeviceBufferCapture == NULL) {
-                            if (pDevice->capture.shareMode == ma_share_mode_shared) {
-                                if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                                    return MA_ERROR;   /* Wait failed. */
-                                }
-                            }
-
-                            result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture);
-                            if (result != MA_SUCCESS) {
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            /*printf("TRACE 2: framesAvailableCapture=%d\n", framesAvailableCapture);*/
-
-                            /* Wait for more if nothing is available. */
-                            if (framesAvailableCapture == 0) {
-                                /* In exclusive mode we waited at the top. */
-                                if (pDevice->capture.shareMode != ma_share_mode_shared) {
-                                    if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                                        return MA_ERROR;   /* Wait failed. */
-                                    }
-                                }
-
-                                continue;
-                            }
-
-                            /* Getting here means there's data available for writing to the output device. */
-                            mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                            hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                            if (FAILED(hr)) {
-                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-
-                            /* Overrun detection. */
-                            if ((flagsCapture & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
-                                /* Glitched. Probably due to an overrun. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[WASAPI] Data discontinuity (possible overrun). framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                            #endif
-
-                                /*
-                                Exeriment: If we get an overrun it probably means we're straddling the end of the buffer. In order to prevent a never-ending sequence of glitches let's experiment
-                                by dropping every frame until we're left with only a single period. To do this we just keep retrieving and immediately releasing buffers until we're down to the
-                                last period.
-                                */
-                                if (framesAvailableCapture >= pDevice->wasapi.actualPeriodSizeInFramesCapture) {
-                                #ifdef MA_DEBUG_OUTPUT
-                                    printf("[WASAPI] Synchronizing capture stream. ");
-                                #endif
-                                    do
-                                    {
-                                        hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                                        if (FAILED(hr)) {
-                                            break;
-                                        }
-
-                                        framesAvailableCapture -= mappedDeviceBufferSizeInFramesCapture;
-
-                                        if (framesAvailableCapture > 0) {
-                                            mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                                            hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                                            if (FAILED(hr)) {
-                                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                                exitLoop = MA_TRUE;
-                                                break;
-                                            }
-                                        } else {
-                                            pMappedDeviceBufferCapture = NULL;
-                                            mappedDeviceBufferSizeInFramesCapture = 0;
-                                        }
-                                    } while (framesAvailableCapture > periodSizeInFramesCapture);
-                                #ifdef MA_DEBUG_OUTPUT
-                                    printf("framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                                #endif
-                                }
-                            } else {
-                            #ifdef MA_DEBUG_OUTPUT
-                                if (flagsCapture != 0) {
-                                    printf("[WASAPI] Capture Flags: %ld\n", flagsCapture);
-                                }
-                            #endif
-                            }
-
-                            mappedDeviceBufferFramesRemainingCapture = mappedDeviceBufferSizeInFramesCapture;
-                        }
-
-
-                        /* At this point we should have both input and output data available. We now need to convert the data and post it to the client. */
-                        for (;;) {
-                            BYTE* pRunningDeviceBufferCapture;
-                            BYTE* pRunningDeviceBufferPlayback;
-                            ma_uint32 framesToProcess;
-                            ma_uint32 framesProcessed;
-
-                            pRunningDeviceBufferCapture  = pMappedDeviceBufferCapture  + ((mappedDeviceBufferSizeInFramesCapture  - mappedDeviceBufferFramesRemainingCapture ) * bpfCaptureDevice);
-                            pRunningDeviceBufferPlayback = pMappedDeviceBufferPlayback + ((mappedDeviceBufferSizeInFramesPlayback - mappedDeviceBufferFramesRemainingPlayback) * bpfPlaybackDevice);
-
-                            /* There may be some data sitting in the converter that needs to be processed first. Once this is exhaused, run the data callback again. */
-                            if (!pDevice->playback.converter.isPassthrough && outputDataInClientFormatConsumed < outputDataInClientFormatCount) {
-                                ma_uint64 convertedFrameCountClient = (outputDataInClientFormatCount - outputDataInClientFormatConsumed);
-                                ma_uint64 convertedFrameCountDevice = mappedDeviceBufferFramesRemainingPlayback;
-                                void* pConvertedFramesClient = outputDataInClientFormat + (outputDataInClientFormatConsumed * bpfPlaybackClient);
-                                void* pConvertedFramesDevice = pRunningDeviceBufferPlayback;
-                                result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pConvertedFramesClient, &convertedFrameCountClient, pConvertedFramesDevice, &convertedFrameCountDevice);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                outputDataInClientFormatConsumed          += (ma_uint32)convertedFrameCountClient;  /* Safe cast. */
-                                mappedDeviceBufferFramesRemainingPlayback -= (ma_uint32)convertedFrameCountDevice;  /* Safe cast. */
-
-                                if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                                    break;
-                                }
-                            }
-
-                            /*
-                            Getting here means we need to fire the callback. If format conversion is unnecessary, we can optimize this by passing the pointers to the internal
-                            buffers directly to the callback.
-                            */
-                            if (pDevice->capture.converter.isPassthrough && pDevice->playback.converter.isPassthrough) {
-                                /* Optimal path. We can pass mapped pointers directly to the callback. */
-                                framesToProcess = ma_min(mappedDeviceBufferFramesRemainingCapture, mappedDeviceBufferFramesRemainingPlayback);
-                                framesProcessed = framesToProcess;
-
-                                ma_device__on_data(pDevice, pRunningDeviceBufferPlayback, pRunningDeviceBufferCapture, framesToProcess);
-
-                                mappedDeviceBufferFramesRemainingCapture  -= framesProcessed;
-                                mappedDeviceBufferFramesRemainingPlayback -= framesProcessed;
-
-                                if (mappedDeviceBufferFramesRemainingCapture == 0) {
-                                    break;  /* Exhausted input data. */
-                                }
-                                if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                                    break;  /* Exhausted output data. */
-                                }
-                            } else if (pDevice->capture.converter.isPassthrough) {
-                                /* The input buffer is a passthrough, but the playback buffer requires a conversion. */
-                                framesToProcess = ma_min(mappedDeviceBufferFramesRemainingCapture, outputDataInClientFormatCap);
-                                framesProcessed = framesToProcess;
-
-                                ma_device__on_data(pDevice, outputDataInClientFormat, pRunningDeviceBufferCapture, framesToProcess);
-                                outputDataInClientFormatCount    = framesProcessed;
-                                outputDataInClientFormatConsumed = 0;
-
-                                mappedDeviceBufferFramesRemainingCapture -= framesProcessed;
-                                if (mappedDeviceBufferFramesRemainingCapture == 0) {
-                                    break;  /* Exhausted input data. */
-                                }
-                            } else if (pDevice->playback.converter.isPassthrough) {
-                                /* The input buffer requires conversion, the playback buffer is passthrough. */
-                                ma_uint64 capturedDeviceFramesToProcess = mappedDeviceBufferFramesRemainingCapture;
-                                ma_uint64 capturedClientFramesToProcess = ma_min(inputDataInClientFormatCap, mappedDeviceBufferFramesRemainingPlayback);
-
-                                result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningDeviceBufferCapture, &capturedDeviceFramesToProcess, inputDataInClientFormat, &capturedClientFramesToProcess);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                if (capturedClientFramesToProcess == 0) {
-                                    break;
-                                }
-
-                                ma_device__on_data(pDevice, pRunningDeviceBufferPlayback, inputDataInClientFormat, (ma_uint32)capturedClientFramesToProcess);   /* Safe cast. */
-
-                                mappedDeviceBufferFramesRemainingCapture  -= (ma_uint32)capturedDeviceFramesToProcess;
-                                mappedDeviceBufferFramesRemainingPlayback -= (ma_uint32)capturedClientFramesToProcess;
-                            } else {
-                                ma_uint64 capturedDeviceFramesToProcess = mappedDeviceBufferFramesRemainingCapture;
-                                ma_uint64 capturedClientFramesToProcess = ma_min(inputDataInClientFormatCap, outputDataInClientFormatCap);
-
-                                result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningDeviceBufferCapture, &capturedDeviceFramesToProcess, inputDataInClientFormat, &capturedClientFramesToProcess);
-                                if (result != MA_SUCCESS) {
-                                    break;
-                                }
-
-                                if (capturedClientFramesToProcess == 0) {
-                                    break;
-                                }
-
-                                ma_device__on_data(pDevice, outputDataInClientFormat, inputDataInClientFormat, (ma_uint32)capturedClientFramesToProcess);
-
-                                mappedDeviceBufferFramesRemainingCapture -= (ma_uint32)capturedDeviceFramesToProcess;
-                                outputDataInClientFormatCount             = (ma_uint32)capturedClientFramesToProcess;
-                                outputDataInClientFormatConsumed          = 0;
-                            }
-                        }
-
-
-                        /* If at this point we've run out of capture data we need to release the buffer. */
-                        if (mappedDeviceBufferFramesRemainingCapture == 0 && pMappedDeviceBufferCapture != NULL) {
-                            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                            if (FAILED(hr)) {
-                                ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                                exitLoop = MA_TRUE;
-                                break;
-                            }
-
-                            /*printf("TRACE: Released capture buffer\n");*/
-
-                            pMappedDeviceBufferCapture = NULL;
-                            mappedDeviceBufferFramesRemainingCapture = 0;
-                            mappedDeviceBufferSizeInFramesCapture    = 0;
-                        }
-
-                        /* Get out of this loop if we're run out of room in the playback buffer. */
-                        if (mappedDeviceBufferFramesRemainingPlayback == 0) {
-                            break;
-                        }
-                    }
-                }
-
-
-                /* If at this point we've run out of data we need to release the buffer. */
-                if (mappedDeviceBufferFramesRemainingPlayback == 0 && pMappedDeviceBufferPlayback != NULL) {
-                    hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedDeviceBufferSizeInFramesPlayback, 0);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    /*printf("TRACE: Released playback buffer\n");*/
-                    framesWrittenToPlaybackDevice += mappedDeviceBufferSizeInFramesPlayback;
-
-                    pMappedDeviceBufferPlayback = NULL;
-                    mappedDeviceBufferFramesRemainingPlayback = 0;
-                    mappedDeviceBufferSizeInFramesPlayback    = 0;
-                }
-
-                if (!c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-                    ma_uint32 startThreshold = pDevice->playback.internalPeriodSizeInFrames * 1;
-
-                    /* Prevent a deadlock. If we don't clamp against the actual buffer size we'll never end up starting the playback device which will result in a deadlock. */
-                    if (startThreshold > pDevice->wasapi.actualPeriodSizeInFramesPlayback) {
-                        startThreshold = pDevice->wasapi.actualPeriodSizeInFramesPlayback;
-                    }
-
-                    if (pDevice->playback.shareMode == ma_share_mode_exclusive || framesWrittenToPlaybackDevice >= startThreshold) {
-                        hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                        if (FAILED(hr)) {
-                            ma_IAudioClient_Stop((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                            ma_IAudioClient_Reset((ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture);
-                            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", ma_result_from_HRESULT(hr));
-                        }
-
-                        c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
-                    }
-                }
-
-                /* Make sure the device has started before waiting. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    return MA_ERROR;   /* Wait failed. */
-                }
-            } break;
-
-
-
-            case ma_device_type_capture:
-            case ma_device_type_loopback:
-            {
-                ma_uint32 framesAvailableCapture;
-                DWORD flagsCapture;    /* Passed to IAudioCaptureClient_GetBuffer(). */
-
-                /* Wait for data to become available first. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventCapture, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    exitLoop = MA_TRUE;
-                    break;   /* Wait failed. */
-                }
-
-                /* See how many frames are available. Since we waited at the top, I don't think this should ever return 0. I'm checking for this anyway. */
-                result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture);
-                if (result != MA_SUCCESS) {
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                if (framesAvailableCapture < pDevice->wasapi.periodSizeInFramesCapture) {
-                    continue;   /* Nothing available. Keep waiting. */
-                }
-
-                /* Map the data buffer in preparation for sending to the client. */
-                mappedDeviceBufferSizeInFramesCapture = framesAvailableCapture;
-                hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                if (FAILED(hr)) {
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                /* Overrun detection. */
-                if ((flagsCapture & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) != 0) {
-                    /* Glitched. Probably due to an overrun. */
-                #ifdef MA_DEBUG_OUTPUT
-                    printf("[WASAPI] Data discontinuity (possible overrun). framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                #endif
-
-                    /*
-                    Exeriment: If we get an overrun it probably means we're straddling the end of the buffer. In order to prevent a never-ending sequence of glitches let's experiment
-                    by dropping every frame until we're left with only a single period. To do this we just keep retrieving and immediately releasing buffers until we're down to the
-                    last period.
-                    */
-                    if (framesAvailableCapture >= pDevice->wasapi.actualPeriodSizeInFramesCapture) {
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[WASAPI] Synchronizing capture stream. ");
-                    #endif
-                        do
-                        {
-                            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                            if (FAILED(hr)) {
-                                break;
-                            }
-
-                            framesAvailableCapture -= mappedDeviceBufferSizeInFramesCapture;
-
-                            if (framesAvailableCapture > 0) {
-                                mappedDeviceBufferSizeInFramesCapture = ma_min(framesAvailableCapture, periodSizeInFramesCapture);
-                                hr = ma_IAudioCaptureClient_GetBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedDeviceBufferCapture, &mappedDeviceBufferSizeInFramesCapture, &flagsCapture, NULL, NULL);
-                                if (FAILED(hr)) {
-                                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                                    exitLoop = MA_TRUE;
-                                    break;
-                                }
-                            } else {
-                                pMappedDeviceBufferCapture = NULL;
-                                mappedDeviceBufferSizeInFramesCapture = 0;
-                            }
-                        } while (framesAvailableCapture > periodSizeInFramesCapture);
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("framesAvailableCapture=%d, mappedBufferSizeInFramesCapture=%d\n", framesAvailableCapture, mappedDeviceBufferSizeInFramesCapture);
-                    #endif
-                    }
-                } else {
-                #ifdef MA_DEBUG_OUTPUT
-                    if (flagsCapture != 0) {
-                        printf("[WASAPI] Capture Flags: %ld\n", flagsCapture);
-                    }
-                #endif
-                }
-
-                /* We should have a buffer at this point, but let's just do a sanity check anyway. */
-                if (mappedDeviceBufferSizeInFramesCapture > 0 && pMappedDeviceBufferCapture != NULL) {
-                    ma_device__send_frames_to_client(pDevice, mappedDeviceBufferSizeInFramesCapture, pMappedDeviceBufferCapture);
-
-                    /* At this point we're done with the buffer. */
-                    hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-                    pMappedDeviceBufferCapture = NULL;    /* <-- Important. Not doing this can result in an error once we leave this loop because it will use this to know whether or not a final ReleaseBuffer() needs to be called. */
-                    mappedDeviceBufferSizeInFramesCapture = 0;
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-                }
-            } break;
-
-
-
-            case ma_device_type_playback:
-            {
-                ma_uint32 framesAvailablePlayback;
-
-                /* Check how much space is available. If this returns 0 we just keep waiting. */
-                result = ma_device__get_available_frames__wasapi(pDevice, (ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback);
-                if (result != MA_SUCCESS) {
-                    exitLoop = MA_TRUE;
-                    break;
-                }
-
-                if (framesAvailablePlayback >= pDevice->wasapi.periodSizeInFramesPlayback) {
-                    /* Map a the data buffer in preparation for the callback. */
-                    hr = ma_IAudioRenderClient_GetBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedDeviceBufferPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    /* We should have a buffer at this point. */
-                    ma_device__read_frames_from_client(pDevice, framesAvailablePlayback, pMappedDeviceBufferPlayback);
-
-                    /* At this point we're done writing to the device and we just need to release the buffer. */
-                    hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, 0);
-                    pMappedDeviceBufferPlayback = NULL;    /* <-- Important. Not doing this can result in an error once we leave this loop because it will use this to know whether or not a final ReleaseBuffer() needs to be called. */
-                    mappedDeviceBufferSizeInFramesPlayback = 0;
-
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    framesWrittenToPlaybackDevice += framesAvailablePlayback;
-                }
-
-                if (!c89atomic_load_32(&pDevice->wasapi.isStartedPlayback)) {
-                    hr = ma_IAudioClient_Start((ma_IAudioClient*)pDevice->wasapi.pAudioClientPlayback);
-                    if (FAILED(hr)) {
-                        ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", ma_result_from_HRESULT(hr));
-                        exitLoop = MA_TRUE;
-                        break;
-                    }
-
-                    c89atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE);
-                }
-
-                /* Make sure we don't wait on the event before we've started the device or we may end up deadlocking. */
-                if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
-                    exitLoop = MA_TRUE;
-                    break;   /* Wait failed. Probably timed out. */
-                }
-            } break;
-
-            default: return MA_INVALID_ARGS;
-        }
-    }
-
-    /* Here is where the device needs to be stopped. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        /* Any mapped buffers need to be released. */
-        if (pMappedDeviceBufferCapture != NULL) {
-            hr = ma_IAudioCaptureClient_ReleaseBuffer((ma_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedDeviceBufferSizeInFramesCapture);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Any mapped buffers need to be released. */
-        if (pMappedDeviceBufferPlayback != NULL) {
-            hr = ma_IAudioRenderClient_ReleaseBuffer((ma_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedDeviceBufferSizeInFramesPlayback, 0);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop_wakeup__wasapi(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex || pDevice->type == ma_device_type_loopback) {
-        SetEvent((HANDLE)pDevice->wasapi.hEventCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        SetEvent((HANDLE)pDevice->wasapi.hEventPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__wasapi(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_wasapi);
-    
-    if (pContext->wasapi.commandThread != NULL) {
-        ma_context_command__wasapi cmd = ma_context_init_command__wasapi(MA_CONTEXT_COMMAND_QUIT__WASAPI);
-        ma_context_post_command__wasapi(pContext, &cmd);
-        ma_thread_wait(&pContext->wasapi.commandThread);
-
-        /* Only after the thread has been terminated can we uninitialize the sync objects for the command thread. */
-        ma_semaphore_uninit(&pContext->wasapi.commandSem);
-        ma_mutex_uninit(&pContext->wasapi.commandLock);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__wasapi(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result = MA_SUCCESS;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-#ifdef MA_WIN32_DESKTOP
-    /*
-    WASAPI is only supported in Vista SP1 and newer. The reason for SP1 and not the base version of Vista is that event-driven
-    exclusive mode does not work until SP1.
-
-    Unfortunately older compilers don't define these functions so we need to dynamically load them in order to avoid a link error.
-    */
-    {
-        ma_OSVERSIONINFOEXW osvi;
-        ma_handle kernel32DLL;
-        ma_PFNVerifyVersionInfoW _VerifyVersionInfoW;
-        ma_PFNVerSetConditionMask _VerSetConditionMask;
-
-        kernel32DLL = ma_dlopen(pContext, "kernel32.dll");
-        if (kernel32DLL == NULL) {
-            return MA_NO_BACKEND;
-        }
-
-        _VerifyVersionInfoW  = (ma_PFNVerifyVersionInfoW )ma_dlsym(pContext, kernel32DLL, "VerifyVersionInfoW");
-        _VerSetConditionMask = (ma_PFNVerSetConditionMask)ma_dlsym(pContext, kernel32DLL, "VerSetConditionMask");
-        if (_VerifyVersionInfoW == NULL || _VerSetConditionMask == NULL) {
-            ma_dlclose(pContext, kernel32DLL);
-            return MA_NO_BACKEND;
-        }
-
-        MA_ZERO_OBJECT(&osvi);
-        osvi.dwOSVersionInfoSize = sizeof(osvi);
-        osvi.dwMajorVersion = ((MA_WIN32_WINNT_VISTA >> 8) & 0xFF);
-        osvi.dwMinorVersion = ((MA_WIN32_WINNT_VISTA >> 0) & 0xFF);
-        osvi.wServicePackMajor = 1;
-        if (_VerifyVersionInfoW(&osvi, MA_VER_MAJORVERSION | MA_VER_MINORVERSION | MA_VER_SERVICEPACKMAJOR, _VerSetConditionMask(_VerSetConditionMask(_VerSetConditionMask(0, MA_VER_MAJORVERSION, MA_VER_GREATER_EQUAL), MA_VER_MINORVERSION, MA_VER_GREATER_EQUAL), MA_VER_SERVICEPACKMAJOR, MA_VER_GREATER_EQUAL))) {
-            result = MA_SUCCESS;
-        } else {
-            result = MA_NO_BACKEND;
-        }
-
-        ma_dlclose(pContext, kernel32DLL);
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    MA_ZERO_OBJECT(&pContext->wasapi);
-
-    /*
-    Annoyingly, WASAPI does not allow you to release an IAudioClient object from a different thread
-    than the one that retrieved it with GetService(). This can result in a deadlock in two
-    situations:
-
-        1) When calling ma_device_uninit() from a different thread to ma_device_init(); and
-        2) When uninitializing and reinitializing the internal IAudioClient object in response to
-           automatic stream routing.
-
-    We could define ma_device_uninit() such that it must be called on the same thread as
-    ma_device_init(). We could also just not release the IAudioClient when performing automatic
-    stream routing to avoid the deadlock. Neither of these are acceptable solutions in my view so
-    we're going to have to work around this with a worker thread. This is not ideal, but I can't
-    think of a better way to do this.
-
-    More information about this can be found here:
-
-        https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nn-audioclient-iaudiorenderclient
-
-    Note this section:
-
-        When releasing an IAudioRenderClient interface instance, the client must call the interface's
-        Release method from the same thread as the call to IAudioClient::GetService that created the
-        object.
-    */
-    {
-        result = ma_mutex_init(&pContext->wasapi.commandLock);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_semaphore_init(0, &pContext->wasapi.commandSem);
-        if (result != MA_SUCCESS) {
-            ma_mutex_uninit(&pContext->wasapi.commandLock);
-            return result;
-        }
-
-        result = ma_thread_create(&pContext->wasapi.commandThread, ma_thread_priority_normal, 0, ma_context_command_thread__wasapi, pContext);
-        if (result != MA_SUCCESS) {
-            ma_semaphore_uninit(&pContext->wasapi.commandSem);
-            ma_mutex_uninit(&pContext->wasapi.commandLock);
-            return result;
-        }
-    }
-
-
-    pCallbacks->onContextInit             = ma_context_init__wasapi;
-    pCallbacks->onContextUninit           = ma_context_uninit__wasapi;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__wasapi;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__wasapi;
-    pCallbacks->onDeviceInit              = ma_device_init__wasapi;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__wasapi;
-    pCallbacks->onDeviceStart             = ma_device_start__wasapi;
-    pCallbacks->onDeviceStop              = ma_device_stop__wasapi;
-    pCallbacks->onDeviceRead              = NULL;                   /* Not used. Reading is done manually in the audio thread. */
-    pCallbacks->onDeviceWrite             = NULL;                   /* Not used. Writing is done manually in the audio thread. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__wasapi;
-    pCallbacks->onDeviceDataLoopWakeup    = ma_device_data_loop_wakeup__wasapi;
-
-    return MA_SUCCESS;
-}
-#endif
-
-/******************************************************************************
-
-DirectSound Backend
-
-******************************************************************************/
-#ifdef MA_HAS_DSOUND
-/*#include <dsound.h>*/
-
-/*static const GUID MA_GUID_IID_DirectSoundNotify = {0xb0210783, 0x89cd, 0x11d0, {0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}};*/
-
-/* miniaudio only uses priority or exclusive modes. */
-#define MA_DSSCL_NORMAL                 1
-#define MA_DSSCL_PRIORITY               2
-#define MA_DSSCL_EXCLUSIVE              3
-#define MA_DSSCL_WRITEPRIMARY           4
-
-#define MA_DSCAPS_PRIMARYMONO           0x00000001
-#define MA_DSCAPS_PRIMARYSTEREO         0x00000002
-#define MA_DSCAPS_PRIMARY8BIT           0x00000004
-#define MA_DSCAPS_PRIMARY16BIT          0x00000008
-#define MA_DSCAPS_CONTINUOUSRATE        0x00000010
-#define MA_DSCAPS_EMULDRIVER            0x00000020
-#define MA_DSCAPS_CERTIFIED             0x00000040
-#define MA_DSCAPS_SECONDARYMONO         0x00000100
-#define MA_DSCAPS_SECONDARYSTEREO       0x00000200
-#define MA_DSCAPS_SECONDARY8BIT         0x00000400
-#define MA_DSCAPS_SECONDARY16BIT        0x00000800
-
-#define MA_DSBCAPS_PRIMARYBUFFER        0x00000001
-#define MA_DSBCAPS_STATIC               0x00000002
-#define MA_DSBCAPS_LOCHARDWARE          0x00000004
-#define MA_DSBCAPS_LOCSOFTWARE          0x00000008
-#define MA_DSBCAPS_CTRL3D               0x00000010
-#define MA_DSBCAPS_CTRLFREQUENCY        0x00000020
-#define MA_DSBCAPS_CTRLPAN              0x00000040
-#define MA_DSBCAPS_CTRLVOLUME           0x00000080
-#define MA_DSBCAPS_CTRLPOSITIONNOTIFY   0x00000100
-#define MA_DSBCAPS_CTRLFX               0x00000200
-#define MA_DSBCAPS_STICKYFOCUS          0x00004000
-#define MA_DSBCAPS_GLOBALFOCUS          0x00008000
-#define MA_DSBCAPS_GETCURRENTPOSITION2  0x00010000
-#define MA_DSBCAPS_MUTE3DATMAXDISTANCE  0x00020000
-#define MA_DSBCAPS_LOCDEFER             0x00040000
-#define MA_DSBCAPS_TRUEPLAYPOSITION     0x00080000
-
-#define MA_DSBPLAY_LOOPING              0x00000001
-#define MA_DSBPLAY_LOCHARDWARE          0x00000002
-#define MA_DSBPLAY_LOCSOFTWARE          0x00000004
-#define MA_DSBPLAY_TERMINATEBY_TIME     0x00000008
-#define MA_DSBPLAY_TERMINATEBY_DISTANCE 0x00000010
-#define MA_DSBPLAY_TERMINATEBY_PRIORITY 0x00000020
-
-#define MA_DSCBSTART_LOOPING            0x00000001
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-    WAVEFORMATEX* lpwfxFormat;
-    GUID guid3DAlgorithm;
-} MA_DSBUFFERDESC;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-    WAVEFORMATEX* lpwfxFormat;
-    DWORD dwFXCount;
-    void* lpDSCFXDesc;  /* <-- miniaudio doesn't use this, so set to void*. */
-} MA_DSCBUFFERDESC;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwMinSecondarySampleRate;
-    DWORD dwMaxSecondarySampleRate;
-    DWORD dwPrimaryBuffers;
-    DWORD dwMaxHwMixingAllBuffers;
-    DWORD dwMaxHwMixingStaticBuffers;
-    DWORD dwMaxHwMixingStreamingBuffers;
-    DWORD dwFreeHwMixingAllBuffers;
-    DWORD dwFreeHwMixingStaticBuffers;
-    DWORD dwFreeHwMixingStreamingBuffers;
-    DWORD dwMaxHw3DAllBuffers;
-    DWORD dwMaxHw3DStaticBuffers;
-    DWORD dwMaxHw3DStreamingBuffers;
-    DWORD dwFreeHw3DAllBuffers;
-    DWORD dwFreeHw3DStaticBuffers;
-    DWORD dwFreeHw3DStreamingBuffers;
-    DWORD dwTotalHwMemBytes;
-    DWORD dwFreeHwMemBytes;
-    DWORD dwMaxContigFreeHwMemBytes;
-    DWORD dwUnlockTransferRateHwBuffers;
-    DWORD dwPlayCpuOverheadSwBuffers;
-    DWORD dwReserved1;
-    DWORD dwReserved2;
-} MA_DSCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwUnlockTransferRate;
-    DWORD dwPlayCpuOverhead;
-} MA_DSBCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwFormats;
-    DWORD dwChannels;
-} MA_DSCCAPS;
-
-typedef struct
-{
-    DWORD dwSize;
-    DWORD dwFlags;
-    DWORD dwBufferBytes;
-    DWORD dwReserved;
-} MA_DSCBCAPS;
-
-typedef struct
-{
-    DWORD  dwOffset;
-    HANDLE hEventNotify;
-} MA_DSBPOSITIONNOTIFY;
-
-typedef struct ma_IDirectSound              ma_IDirectSound;
-typedef struct ma_IDirectSoundBuffer        ma_IDirectSoundBuffer;
-typedef struct ma_IDirectSoundCapture       ma_IDirectSoundCapture;
-typedef struct ma_IDirectSoundCaptureBuffer ma_IDirectSoundCaptureBuffer;
-typedef struct ma_IDirectSoundNotify        ma_IDirectSoundNotify;
-
-
-/*
-COM objects. The way these work is that you have a vtable (a list of function pointers, kind of
-like how C++ works internally), and then you have a structure with a single member, which is a
-pointer to the vtable. The vtable is where the methods of the object are defined. Methods need
-to be in a specific order, and parent classes need to have their methods declared first.
-*/
-
-/* IDirectSound */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSound* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSound* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSound* pThis);
-
-    /* IDirectSound */
-    HRESULT (STDMETHODCALLTYPE * CreateSoundBuffer)   (ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter);
-    HRESULT (STDMETHODCALLTYPE * GetCaps)             (ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps);
-    HRESULT (STDMETHODCALLTYPE * DuplicateSoundBuffer)(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate);
-    HRESULT (STDMETHODCALLTYPE * SetCooperativeLevel) (ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel);
-    HRESULT (STDMETHODCALLTYPE * Compact)             (ma_IDirectSound* pThis);
-    HRESULT (STDMETHODCALLTYPE * GetSpeakerConfig)    (ma_IDirectSound* pThis, DWORD* pSpeakerConfig);
-    HRESULT (STDMETHODCALLTYPE * SetSpeakerConfig)    (ma_IDirectSound* pThis, DWORD dwSpeakerConfig);
-    HRESULT (STDMETHODCALLTYPE * Initialize)          (ma_IDirectSound* pThis, const GUID* pGuidDevice);
-} ma_IDirectSoundVtbl;
-struct ma_IDirectSound
-{
-    ma_IDirectSoundVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSound_QueryInterface(ma_IDirectSound* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSound_AddRef(ma_IDirectSound* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSound_Release(ma_IDirectSound* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSound_CreateSoundBuffer(ma_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, ma_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateSoundBuffer(pThis, pDSBufferDesc, ppDSBuffer, pUnkOuter); }
-static MA_INLINE HRESULT ma_IDirectSound_GetCaps(ma_IDirectSound* pThis, MA_DSCAPS* pDSCaps)                            { return pThis->lpVtbl->GetCaps(pThis, pDSCaps); }
-static MA_INLINE HRESULT ma_IDirectSound_DuplicateSoundBuffer(ma_IDirectSound* pThis, ma_IDirectSoundBuffer* pDSBufferOriginal, ma_IDirectSoundBuffer** ppDSBufferDuplicate) { return pThis->lpVtbl->DuplicateSoundBuffer(pThis, pDSBufferOriginal, ppDSBufferDuplicate); }
-static MA_INLINE HRESULT ma_IDirectSound_SetCooperativeLevel(ma_IDirectSound* pThis, HWND hwnd, DWORD dwLevel)          { return pThis->lpVtbl->SetCooperativeLevel(pThis, hwnd, dwLevel); }
-static MA_INLINE HRESULT ma_IDirectSound_Compact(ma_IDirectSound* pThis)                                                { return pThis->lpVtbl->Compact(pThis); }
-static MA_INLINE HRESULT ma_IDirectSound_GetSpeakerConfig(ma_IDirectSound* pThis, DWORD* pSpeakerConfig)                { return pThis->lpVtbl->GetSpeakerConfig(pThis, pSpeakerConfig); }
-static MA_INLINE HRESULT ma_IDirectSound_SetSpeakerConfig(ma_IDirectSound* pThis, DWORD dwSpeakerConfig)                { return pThis->lpVtbl->SetSpeakerConfig(pThis, dwSpeakerConfig); }
-static MA_INLINE HRESULT ma_IDirectSound_Initialize(ma_IDirectSound* pThis, const GUID* pGuidDevice)                    { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); }
-
-
-/* IDirectSoundBuffer */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundBuffer* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundBuffer* pThis);
-
-    /* IDirectSoundBuffer */
-    HRESULT (STDMETHODCALLTYPE * GetCaps)           (ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor);
-    HRESULT (STDMETHODCALLTYPE * GetFormat)         (ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
-    HRESULT (STDMETHODCALLTYPE * GetVolume)         (ma_IDirectSoundBuffer* pThis, LONG* pVolume);
-    HRESULT (STDMETHODCALLTYPE * GetPan)            (ma_IDirectSoundBuffer* pThis, LONG* pPan);
-    HRESULT (STDMETHODCALLTYPE * GetFrequency)      (ma_IDirectSoundBuffer* pThis, DWORD* pFrequency);
-    HRESULT (STDMETHODCALLTYPE * GetStatus)         (ma_IDirectSoundBuffer* pThis, DWORD* pStatus);
-    HRESULT (STDMETHODCALLTYPE * Initialize)        (ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc);
-    HRESULT (STDMETHODCALLTYPE * Lock)              (ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Play)              (ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * SetCurrentPosition)(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition);
-    HRESULT (STDMETHODCALLTYPE * SetFormat)         (ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat);
-    HRESULT (STDMETHODCALLTYPE * SetVolume)         (ma_IDirectSoundBuffer* pThis, LONG volume);
-    HRESULT (STDMETHODCALLTYPE * SetPan)            (ma_IDirectSoundBuffer* pThis, LONG pan);
-    HRESULT (STDMETHODCALLTYPE * SetFrequency)      (ma_IDirectSoundBuffer* pThis, DWORD dwFrequency);
-    HRESULT (STDMETHODCALLTYPE * Stop)              (ma_IDirectSoundBuffer* pThis);
-    HRESULT (STDMETHODCALLTYPE * Unlock)            (ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2);
-    HRESULT (STDMETHODCALLTYPE * Restore)           (ma_IDirectSoundBuffer* pThis);
-} ma_IDirectSoundBufferVtbl;
-struct ma_IDirectSoundBuffer
-{
-    ma_IDirectSoundBufferVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_QueryInterface(ma_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundBuffer_AddRef(ma_IDirectSoundBuffer* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundBuffer_Release(ma_IDirectSoundBuffer* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCaps(ma_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps)                     { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCurrentPlayCursor, pCurrentWriteCursor); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFormat(ma_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetVolume(ma_IDirectSoundBuffer* pThis, LONG* pVolume)                               { return pThis->lpVtbl->GetVolume(pThis, pVolume); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetPan(ma_IDirectSoundBuffer* pThis, LONG* pPan)                                     { return pThis->lpVtbl->GetPan(pThis, pPan); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetFrequency(ma_IDirectSoundBuffer* pThis, DWORD* pFrequency)                        { return pThis->lpVtbl->GetFrequency(pThis, pFrequency); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_GetStatus(ma_IDirectSoundBuffer* pThis, DWORD* pStatus)                              { return pThis->lpVtbl->GetStatus(pThis, pStatus); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Initialize(ma_IDirectSoundBuffer* pThis, ma_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSound, pDSBufferDesc); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Lock(ma_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Play(ma_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) { return pThis->lpVtbl->Play(pThis, dwReserved1, dwPriority, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetCurrentPosition(ma_IDirectSoundBuffer* pThis, DWORD dwNewPosition)                { return pThis->lpVtbl->SetCurrentPosition(pThis, dwNewPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFormat(ma_IDirectSoundBuffer* pThis, const WAVEFORMATEX* pFormat)                 { return pThis->lpVtbl->SetFormat(pThis, pFormat); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetVolume(ma_IDirectSoundBuffer* pThis, LONG volume)                                 { return pThis->lpVtbl->SetVolume(pThis, volume); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetPan(ma_IDirectSoundBuffer* pThis, LONG pan)                                       { return pThis->lpVtbl->SetPan(pThis, pan); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_SetFrequency(ma_IDirectSoundBuffer* pThis, DWORD dwFrequency)                        { return pThis->lpVtbl->SetFrequency(pThis, dwFrequency); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Stop(ma_IDirectSoundBuffer* pThis)                                                   { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Unlock(ma_IDirectSoundBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); }
-static MA_INLINE HRESULT ma_IDirectSoundBuffer_Restore(ma_IDirectSoundBuffer* pThis)                                                { return pThis->lpVtbl->Restore(pThis); }
-
-
-/* IDirectSoundCapture */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundCapture* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundCapture* pThis);
-
-    /* IDirectSoundCapture */
-    HRESULT (STDMETHODCALLTYPE * CreateCaptureBuffer)(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter);
-    HRESULT (STDMETHODCALLTYPE * GetCaps)            (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps);
-    HRESULT (STDMETHODCALLTYPE * Initialize)         (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice);
-} ma_IDirectSoundCaptureVtbl;
-struct ma_IDirectSoundCapture
-{
-    ma_IDirectSoundCaptureVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundCapture_QueryInterface(ma_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundCapture_AddRef(ma_IDirectSoundCapture* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundCapture_Release(ma_IDirectSoundCapture* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_CreateCaptureBuffer(ma_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, ma_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateCaptureBuffer(pThis, pDSCBufferDesc, ppDSCBuffer, pUnkOuter); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_GetCaps            (ma_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps)              { return pThis->lpVtbl->GetCaps(pThis, pDSCCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundCapture_Initialize         (ma_IDirectSoundCapture* pThis, const GUID* pGuidDevice)           { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); }
-
-
-/* IDirectSoundCaptureBuffer */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundCaptureBuffer* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundCaptureBuffer* pThis);
-
-    /* IDirectSoundCaptureBuffer */
-    HRESULT (STDMETHODCALLTYPE * GetCaps)           (ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps);
-    HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition);
-    HRESULT (STDMETHODCALLTYPE * GetFormat)         (ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten);
-    HRESULT (STDMETHODCALLTYPE * GetStatus)         (ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus);
-    HRESULT (STDMETHODCALLTYPE * Initialize)        (ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc);
-    HRESULT (STDMETHODCALLTYPE * Lock)              (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Start)             (ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags);
-    HRESULT (STDMETHODCALLTYPE * Stop)              (ma_IDirectSoundCaptureBuffer* pThis);
-    HRESULT (STDMETHODCALLTYPE * Unlock)            (ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2);
-} ma_IDirectSoundCaptureBufferVtbl;
-struct ma_IDirectSoundCaptureBuffer
-{
-    ma_IDirectSoundCaptureBufferVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_QueryInterface(ma_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundCaptureBuffer_AddRef(ma_IDirectSoundCaptureBuffer* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundCaptureBuffer_Release(ma_IDirectSoundCaptureBuffer* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCaps(ma_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps)                        { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetCurrentPosition(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCapturePosition, pReadPosition); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetFormat(ma_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_GetStatus(ma_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus)                              { return pThis->lpVtbl->GetStatus(pThis, pStatus); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Initialize(ma_IDirectSoundCaptureBuffer* pThis, ma_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Lock(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Start(ma_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags)                                   { return pThis->lpVtbl->Start(pThis, dwFlags); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Stop(ma_IDirectSoundCaptureBuffer* pThis)                                                   { return pThis->lpVtbl->Stop(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundCaptureBuffer_Unlock(ma_IDirectSoundCaptureBuffer* pThis, void* pAudioPtr1, DWORD dwAudioBytes1, void* pAudioPtr2, DWORD dwAudioBytes2) { return pThis->lpVtbl->Unlock(pThis, pAudioPtr1, dwAudioBytes1, pAudioPtr2, dwAudioBytes2); }
-
-
-/* IDirectSoundNotify */
-typedef struct
-{
-    /* IUnknown */
-    HRESULT (STDMETHODCALLTYPE * QueryInterface)(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject);
-    ULONG   (STDMETHODCALLTYPE * AddRef)        (ma_IDirectSoundNotify* pThis);
-    ULONG   (STDMETHODCALLTYPE * Release)       (ma_IDirectSoundNotify* pThis);
-
-    /* IDirectSoundNotify */
-    HRESULT (STDMETHODCALLTYPE * SetNotificationPositions)(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies);
-} ma_IDirectSoundNotifyVtbl;
-struct ma_IDirectSoundNotify
-{
-    ma_IDirectSoundNotifyVtbl* lpVtbl;
-};
-static MA_INLINE HRESULT ma_IDirectSoundNotify_QueryInterface(ma_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); }
-static MA_INLINE ULONG   ma_IDirectSoundNotify_AddRef(ma_IDirectSoundNotify* pThis)                                                 { return pThis->lpVtbl->AddRef(pThis); }
-static MA_INLINE ULONG   ma_IDirectSoundNotify_Release(ma_IDirectSoundNotify* pThis)                                                { return pThis->lpVtbl->Release(pThis); }
-static MA_INLINE HRESULT ma_IDirectSoundNotify_SetNotificationPositions(ma_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); }
-
-
-typedef BOOL    (CALLBACK * ma_DSEnumCallbackAProc)             (LPGUID pDeviceGUID, LPCSTR pDeviceDescription, LPCSTR pModule, LPVOID pContext);
-typedef HRESULT (WINAPI   * ma_DirectSoundCreateProc)           (const GUID* pcGuidDevice, ma_IDirectSound** ppDS8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI   * ma_DirectSoundEnumerateAProc)       (ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
-typedef HRESULT (WINAPI   * ma_DirectSoundCaptureCreateProc)    (const GUID* pcGuidDevice, ma_IDirectSoundCapture** ppDSC8, LPUNKNOWN pUnkOuter);
-typedef HRESULT (WINAPI   * ma_DirectSoundCaptureEnumerateAProc)(ma_DSEnumCallbackAProc pDSEnumCallback, LPVOID pContext);
-
-static ma_uint32 ma_get_best_sample_rate_within_range(ma_uint32 sampleRateMin, ma_uint32 sampleRateMax)
-{
-    /* Normalize the range in case we were given something stupid. */
-    if (sampleRateMin < (ma_uint32)ma_standard_sample_rate_min) {
-        sampleRateMin = (ma_uint32)ma_standard_sample_rate_min;
-    }
-    if (sampleRateMax > (ma_uint32)ma_standard_sample_rate_max) {
-        sampleRateMax = (ma_uint32)ma_standard_sample_rate_max;
-    }
-    if (sampleRateMin > sampleRateMax) {
-        sampleRateMin = sampleRateMax;
-    }
-
-    if (sampleRateMin == sampleRateMax) {
-        return sampleRateMax;
-    } else {
-        size_t iStandardRate;
-        for (iStandardRate = 0; iStandardRate < ma_countof(g_maStandardSampleRatePriorities); ++iStandardRate) {
-            ma_uint32 standardRate = g_maStandardSampleRatePriorities[iStandardRate];
-            if (standardRate >= sampleRateMin && standardRate <= sampleRateMax) {
-                return standardRate;
-            }
-        }
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-/*
-Retrieves the channel count and channel map for the given speaker configuration. If the speaker configuration is unknown,
-the channel count and channel map will be left unmodified.
-*/
-static void ma_get_channels_from_speaker_config__dsound(DWORD speakerConfig, WORD* pChannelsOut, DWORD* pChannelMapOut)
-{
-    WORD  channels;
-    DWORD channelMap;
-
-    channels = 0;
-    if (pChannelsOut != NULL) {
-        channels = *pChannelsOut;
-    }
-
-    channelMap = 0;
-    if (pChannelMapOut != NULL) {
-        channelMap = *pChannelMapOut;
-    }
-
-    /*
-    The speaker configuration is a combination of speaker config and speaker geometry. The lower 8 bits is what we care about. The upper
-    16 bits is for the geometry.
-    */
-    switch ((BYTE)(speakerConfig)) {
-        case 1 /*DSSPEAKER_HEADPHONE*/:                          channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break;
-        case 2 /*DSSPEAKER_MONO*/:                               channels = 1; channelMap = SPEAKER_FRONT_CENTER; break;
-        case 3 /*DSSPEAKER_QUAD*/:                               channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break;
-        case 4 /*DSSPEAKER_STEREO*/:                             channels = 2; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT; break;
-        case 5 /*DSSPEAKER_SURROUND*/:                           channels = 4; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_BACK_CENTER; break;
-        case 6 /*DSSPEAKER_5POINT1_BACK*/ /*DSSPEAKER_5POINT1*/: channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT; break;
-        case 7 /*DSSPEAKER_7POINT1_WIDE*/ /*DSSPEAKER_7POINT1*/: channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_FRONT_LEFT_OF_CENTER | SPEAKER_FRONT_RIGHT_OF_CENTER; break;
-        case 8 /*DSSPEAKER_7POINT1_SURROUND*/:                   channels = 8; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break;
-        case 9 /*DSSPEAKER_5POINT1_SURROUND*/:                   channels = 6; channelMap = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | SPEAKER_LOW_FREQUENCY | SPEAKER_SIDE_LEFT | SPEAKER_SIDE_RIGHT; break;
-        default: break;
-    }
-
-    if (pChannelsOut != NULL) {
-        *pChannelsOut = channels;
-    }
-
-    if (pChannelMapOut != NULL) {
-        *pChannelMapOut = channelMap;
-    }
-}
-
-
-static ma_result ma_context_create_IDirectSound__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSound** ppDirectSound)
-{
-    ma_IDirectSound* pDirectSound;
-    HWND hWnd;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppDirectSound != NULL);
-
-    *ppDirectSound = NULL;
-    pDirectSound = NULL;
-
-    if (FAILED(((ma_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSound, NULL))) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    /* The cooperative level must be set before doing anything else. */
-    hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)();
-    if (hWnd == NULL) {
-        hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)();
-    }
-
-    hr = ma_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == ma_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_SetCooperateiveLevel() failed for playback device.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDirectSound = pDirectSound;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_create_IDirectSoundCapture__dsound(ma_context* pContext, ma_share_mode shareMode, const ma_device_id* pDeviceID, ma_IDirectSoundCapture** ppDirectSoundCapture)
-{
-    ma_IDirectSoundCapture* pDirectSoundCapture;
-    HRESULT hr;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppDirectSoundCapture != NULL);
-
-    /* DirectSound does not support exclusive mode for capture. */
-    if (shareMode == ma_share_mode_exclusive) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    *ppDirectSoundCapture = NULL;
-    pDirectSoundCapture = NULL;
-
-    hr = ((ma_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, NULL);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device.", ma_result_from_HRESULT(hr));
-    }
-
-    *ppDirectSoundCapture = pDirectSoundCapture;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_format_info_for_IDirectSoundCapture__dsound(ma_context* pContext, ma_IDirectSoundCapture* pDirectSoundCapture, WORD* pChannels, WORD* pBitsPerSample, DWORD* pSampleRate)
-{
-    HRESULT hr;
-    MA_DSCCAPS caps;
-    WORD bitsPerSample;
-    DWORD sampleRate;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDirectSoundCapture != NULL);
-
-    if (pChannels) {
-        *pChannels = 0;
-    }
-    if (pBitsPerSample) {
-        *pBitsPerSample = 0;
-    }
-    if (pSampleRate) {
-        *pSampleRate = 0;
-    }
-
-    MA_ZERO_OBJECT(&caps);
-    caps.dwSize = sizeof(caps);
-    hr = ma_IDirectSoundCapture_GetCaps(pDirectSoundCapture, &caps);
-    if (FAILED(hr)) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_GetCaps() failed for capture device.", ma_result_from_HRESULT(hr));
-    }
-
-    if (pChannels) {
-        *pChannels = (WORD)caps.dwChannels;
-    }
-
-    /* The device can support multiple formats. We just go through the different formats in order of priority and pick the first one. This the same type of system as the WinMM backend. */
-    bitsPerSample = 16;
-    sampleRate = 48000;
-
-    if (caps.dwChannels == 1) {
-        if ((caps.dwFormats & WAVE_FORMAT_48M16) != 0) {
-            sampleRate = 48000;
-        } else if ((caps.dwFormats & WAVE_FORMAT_44M16) != 0) {
-            sampleRate = 44100;
-        } else if ((caps.dwFormats & WAVE_FORMAT_2M16) != 0) {
-            sampleRate = 22050;
-        } else if ((caps.dwFormats & WAVE_FORMAT_1M16) != 0) {
-            sampleRate = 11025;
-        } else if ((caps.dwFormats & WAVE_FORMAT_96M16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((caps.dwFormats & WAVE_FORMAT_48M08) != 0) {
-                sampleRate = 48000;
-            } else if ((caps.dwFormats & WAVE_FORMAT_44M08) != 0) {
-                sampleRate = 44100;
-            } else if ((caps.dwFormats & WAVE_FORMAT_2M08) != 0) {
-                sampleRate = 22050;
-            } else if ((caps.dwFormats & WAVE_FORMAT_1M08) != 0) {
-                sampleRate = 11025;
-            } else if ((caps.dwFormats & WAVE_FORMAT_96M08) != 0) {
-                sampleRate = 96000;
-            } else {
-                bitsPerSample = 16;  /* Didn't find it. Just fall back to 16-bit. */
-            }
-        }
-    } else if (caps.dwChannels == 2) {
-        if ((caps.dwFormats & WAVE_FORMAT_48S16) != 0) {
-            sampleRate = 48000;
-        } else if ((caps.dwFormats & WAVE_FORMAT_44S16) != 0) {
-            sampleRate = 44100;
-        } else if ((caps.dwFormats & WAVE_FORMAT_2S16) != 0) {
-            sampleRate = 22050;
-        } else if ((caps.dwFormats & WAVE_FORMAT_1S16) != 0) {
-            sampleRate = 11025;
-        } else if ((caps.dwFormats & WAVE_FORMAT_96S16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((caps.dwFormats & WAVE_FORMAT_48S08) != 0) {
-                sampleRate = 48000;
-            } else if ((caps.dwFormats & WAVE_FORMAT_44S08) != 0) {
-                sampleRate = 44100;
-            } else if ((caps.dwFormats & WAVE_FORMAT_2S08) != 0) {
-                sampleRate = 22050;
-            } else if ((caps.dwFormats & WAVE_FORMAT_1S08) != 0) {
-                sampleRate = 11025;
-            } else if ((caps.dwFormats & WAVE_FORMAT_96S08) != 0) {
-                sampleRate = 96000;
-            } else {
-                bitsPerSample = 16;  /* Didn't find it. Just fall back to 16-bit. */
-            }
-        }
-    }
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = bitsPerSample;
-    }
-    if (pSampleRate) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_context* pContext;
-    ma_device_type deviceType;
-    ma_enum_devices_callback_proc callback;
-    void* pUserData;
-    ma_bool32 terminated;
-} ma_context_enumerate_devices_callback_data__dsound;
-
-static BOOL CALLBACK ma_context_enumerate_devices_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
-    ma_context_enumerate_devices_callback_data__dsound* pData = (ma_context_enumerate_devices_callback_data__dsound*)lpContext;
-    ma_device_info deviceInfo;
-
-    (void)lpcstrModule;
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* ID. */
-    if (lpGuid != NULL) {
-        MA_COPY_MEMORY(deviceInfo.id.dsound, lpGuid, 16);
-    } else {
-        MA_ZERO_MEMORY(deviceInfo.id.dsound, 16);
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    /* Name / Description */
-    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), lpcstrDescription, (size_t)-1);
-
-
-    /* Call the callback function, but make sure we stop enumerating if the callee requested so. */
-    MA_ASSERT(pData != NULL);
-    pData->terminated = !pData->callback(pData->pContext, pData->deviceType, &deviceInfo, pData->pUserData);
-    if (pData->terminated) {
-        return FALSE;   /* Stop enumeration. */
-    } else {
-        return TRUE;    /* Continue enumeration. */
-    }
-}
-
-static ma_result ma_context_enumerate_devices__dsound(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__dsound data;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    data.pContext = pContext;
-    data.callback = callback;
-    data.pUserData = pUserData;
-    data.terminated = MA_FALSE;
-
-    /* Playback. */
-    if (!data.terminated) {
-        data.deviceType = ma_device_type_playback;
-        ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data);
-    }
-
-    /* Capture. */
-    if (!data.terminated) {
-        data.deviceType = ma_device_type_capture;
-        ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_enumerate_devices_callback__dsound, &data);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    const ma_device_id* pDeviceID;
-    ma_device_info* pDeviceInfo;
-    ma_bool32 found;
-} ma_context_get_device_info_callback_data__dsound;
-
-static BOOL CALLBACK ma_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext)
-{
-    ma_context_get_device_info_callback_data__dsound* pData = (ma_context_get_device_info_callback_data__dsound*)lpContext;
-    MA_ASSERT(pData != NULL);
-
-    if ((pData->pDeviceID == NULL || ma_is_guid_null(pData->pDeviceID->dsound)) && (lpGuid == NULL || ma_is_guid_null(lpGuid))) {
-        /* Default device. */
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1);
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-        pData->found = MA_TRUE;
-        return FALSE;   /* Stop enumeration. */
-    } else {
-        /* Not the default device. */
-        if (lpGuid != NULL && pData->pDeviceID != NULL) {
-            if (memcmp(pData->pDeviceID->dsound, lpGuid, sizeof(pData->pDeviceID->dsound)) == 0) {
-                ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1);
-                pData->found = MA_TRUE;
-                return FALSE;   /* Stop enumeration. */
-            }
-        }
-    }
-
-    (void)lpcstrModule;
-    return TRUE;
-}
-
-static ma_result ma_context_get_device_info__dsound(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-    HRESULT hr;
-
-    if (pDeviceID != NULL) {
-        ma_context_get_device_info_callback_data__dsound data;
-
-        /* ID. */
-        MA_COPY_MEMORY(pDeviceInfo->id.dsound, pDeviceID->dsound, 16);
-
-        /* Name / Description. This is retrieved by enumerating over each device until we find that one that matches the input ID. */
-        data.pDeviceID = pDeviceID;
-        data.pDeviceInfo = pDeviceInfo;
-        data.found = MA_FALSE;
-        if (deviceType == ma_device_type_playback) {
-            ((ma_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(ma_context_get_device_info_callback__dsound, &data);
-        } else {
-            ((ma_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(ma_context_get_device_info_callback__dsound, &data);
-        }
-
-        if (!data.found) {
-            return MA_NO_DEVICE;
-        }
-    } else {
-        /* I don't think there's a way to get the name of the default device with DirectSound. In this case we just need to use defaults. */
-
-        /* ID */
-        MA_ZERO_MEMORY(pDeviceInfo->id.dsound, 16);
-
-        /* Name / Description */
-        if (deviceType == ma_device_type_playback) {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        } else {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        }
-
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    /* Retrieving detailed information is slightly different depending on the device type. */
-    if (deviceType == ma_device_type_playback) {
-        /* Playback. */
-        ma_IDirectSound* pDirectSound;
-        MA_DSCAPS caps;
-        WORD channels;
-
-        result = ma_context_create_IDirectSound__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSound);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        MA_ZERO_OBJECT(&caps);
-        caps.dwSize = sizeof(caps);
-        hr = ma_IDirectSound_GetCaps(pDirectSound, &caps);
-        if (FAILED(hr)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", ma_result_from_HRESULT(hr));
-        }
-
-
-        /* Channels. Only a single channel count is reported for DirectSound. */
-        if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
-            /* It supports at least stereo, but could support more. */
-            DWORD speakerConfig;
-
-            channels = 2;
-
-            /* Look at the speaker configuration to get a better idea on the channel count. */
-            hr = ma_IDirectSound_GetSpeakerConfig(pDirectSound, &speakerConfig);
-            if (SUCCEEDED(hr)) {
-                ma_get_channels_from_speaker_config__dsound(speakerConfig, &channels, NULL);
-            }
-        } else {
-            /* It does not support stereo, which means we are stuck with mono. */
-            channels = 1;
-        }
-
-
-        /*
-        In DirectSound, our native formats are centered around sample rates. All formats are supported, and we're only reporting a single channel
-        count. However, DirectSound can report a range of supported sample rates. We're only going to include standard rates known by miniaudio
-        in order to keep the size of this within reason.
-        */
-        if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) {
-            /* Multiple sample rates are supported. We'll report in order of our preferred sample rates. */
-            size_t iStandardSampleRate;
-            for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) {
-                ma_uint32 sampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate];
-                if (sampleRate >= caps.dwMinSecondarySampleRate && sampleRate <= caps.dwMaxSecondarySampleRate) {
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = ma_format_unknown;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-                    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-                    pDeviceInfo->nativeDataFormatCount += 1;
-                }
-            }
-        } else {
-            /* Only a single sample rate is supported. */
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = ma_format_unknown;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = caps.dwMaxSecondarySampleRate;
-            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-            pDeviceInfo->nativeDataFormatCount += 1;
-        }
-
-        ma_IDirectSound_Release(pDirectSound);
-    } else {
-        /*
-        Capture. This is a little different to playback due to the say the supported formats are reported. Technically capture
-        devices can support a number of different formats, but for simplicity and consistency with ma_device_init() I'm just
-        reporting the best format.
-        */
-        ma_IDirectSoundCapture* pDirectSoundCapture;
-        WORD channels;
-        WORD bitsPerSample;
-        DWORD sampleRate;
-
-        result = ma_context_create_IDirectSoundCapture__dsound(pContext, ma_share_mode_shared, pDeviceID, &pDirectSoundCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pContext, pDirectSoundCapture, &channels, &bitsPerSample, &sampleRate);
-        if (result != MA_SUCCESS) {
-            ma_IDirectSoundCapture_Release(pDirectSoundCapture);
-            return result;
-        }
-
-        ma_IDirectSoundCapture_Release(pDirectSoundCapture);
-
-        /* The format is always an integer format and is based on the bits per sample. */
-        if (bitsPerSample == 8) {
-            pDeviceInfo->formats[0] = ma_format_u8;
-        } else if (bitsPerSample == 16) {
-            pDeviceInfo->formats[0] = ma_format_s16;
-        } else if (bitsPerSample == 24) {
-            pDeviceInfo->formats[0] = ma_format_s24;
-        } else if (bitsPerSample == 32) {
-            pDeviceInfo->formats[0] = ma_format_s32;
-        } else {
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        pDeviceInfo->nativeDataFormats[0].channels   = channels;
-        pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[0].flags      = 0;
-        pDeviceInfo->nativeDataFormatCount = 1;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-
-static ma_result ma_device_uninit__dsound(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->dsound.pCaptureBuffer != NULL) {
-        ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-    }
-    if (pDevice->dsound.pCapture != NULL) {
-        ma_IDirectSoundCapture_Release((ma_IDirectSoundCapture*)pDevice->dsound.pCapture);
-    }
-
-    if (pDevice->dsound.pPlaybackBuffer != NULL) {
-        ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer);
-    }
-    if (pDevice->dsound.pPlaybackPrimaryBuffer != NULL) {
-        ma_IDirectSoundBuffer_Release((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer);
-    }
-    if (pDevice->dsound.pPlayback != NULL) {
-        ma_IDirectSound_Release((ma_IDirectSound*)pDevice->dsound.pPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_config_to_WAVEFORMATEXTENSIBLE(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* pChannelMap, WAVEFORMATEXTENSIBLE* pWF)
-{
-    GUID subformat;
-
-    if (format == ma_format_unknown) {
-        format = MA_DEFAULT_FORMAT;
-    }
-
-    if (channels == 0) {
-        channels = MA_DEFAULT_CHANNELS;
-    }
-
-    if (sampleRate == 0) {
-        sampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-    switch (format)
-    {
-        case ma_format_u8:
-        case ma_format_s16:
-        case ma_format_s24:
-        /*case ma_format_s24_32:*/
-        case ma_format_s32:
-        {
-            subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-        } break;
-
-        case ma_format_f32:
-        {
-            subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
-        } break;
-
-        default:
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    MA_ZERO_OBJECT(pWF);
-    pWF->Format.cbSize               = sizeof(*pWF);
-    pWF->Format.wFormatTag           = WAVE_FORMAT_EXTENSIBLE;
-    pWF->Format.nChannels            = (WORD)channels;
-    pWF->Format.nSamplesPerSec       = (DWORD)sampleRate;
-    pWF->Format.wBitsPerSample       = (WORD)(ma_get_bytes_per_sample(format)*8);
-    pWF->Format.nBlockAlign          = (WORD)(pWF->Format.nChannels * pWF->Format.wBitsPerSample / 8);
-    pWF->Format.nAvgBytesPerSec      = pWF->Format.nBlockAlign * pWF->Format.nSamplesPerSec;
-    pWF->Samples.wValidBitsPerSample = pWF->Format.wBitsPerSample;
-    pWF->dwChannelMask               = ma_channel_map_to_channel_mask__win32(pChannelMap, channels);
-    pWF->SubFormat                   = subformat;
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__dsound(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /* DirectSound has a minimum period size of 20ms. */
-    ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(20, nativeSampleRate);
-    ma_uint32 periodSizeInFrames;
-
-    periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile);
-    if (periodSizeInFrames < minPeriodSizeInFrames) {
-        periodSizeInFrames = minPeriodSizeInFrames;
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init__dsound(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-    HRESULT hr;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->dsound);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /*
-    Unfortunately DirectSound uses different APIs and data structures for playback and catpure devices. We need to initialize
-    the capture device first because we'll want to match it's buffer size and period count on the playback side if we're using
-    full-duplex mode.
-    */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEFORMATEXTENSIBLE wf;
-        MA_DSCBUFFERDESC descDS;
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodCount;
-        char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
-        WAVEFORMATEXTENSIBLE* pActualFormat;
-
-        result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &wf);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_create_IDirectSoundCapture__dsound(pDevice->pContext, pDescriptorCapture->shareMode, pDescriptorCapture->pDeviceID, (ma_IDirectSoundCapture**)&pDevice->dsound.pCapture);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        result = ma_context_get_format_info_for_IDirectSoundCapture__dsound(pDevice->pContext, (ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.Format.nChannels, &wf.Format.wBitsPerSample, &wf.Format.nSamplesPerSec);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        wf.Format.nBlockAlign          = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-        wf.Format.nAvgBytesPerSec      = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-        wf.Samples.wValidBitsPerSample = wf.Format.wBitsPerSample;
-        wf.SubFormat                   = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM;
-
-        /* The size of the buffer must be a clean multiple of the period count. */
-        periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorCapture, wf.Format.nSamplesPerSec, pConfig->performanceProfile);
-        periodCount = (pDescriptorCapture->periodCount > 0) ? pDescriptorCapture->periodCount : MA_DEFAULT_PERIODS;
-
-        MA_ZERO_OBJECT(&descDS);
-        descDS.dwSize        = sizeof(descDS);
-        descDS.dwFlags       = 0;
-        descDS.dwBufferBytes = periodSizeInFrames * periodCount * wf.Format.nBlockAlign;
-        descDS.lpwfxFormat   = (WAVEFORMATEX*)&wf;
-        hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", ma_result_from_HRESULT(hr));
-        }
-
-        /* Get the _actual_ properties of the buffer. */
-        pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
-        hr = ma_IDirectSoundCaptureBuffer_GetFormat((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* We can now start setting the output data formats. */
-        pDescriptorCapture->format     = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
-        pDescriptorCapture->channels   = pActualFormat->Format.nChannels;
-        pDescriptorCapture->sampleRate = pActualFormat->Format.nSamplesPerSec;
-
-        /* Get the native channel map based on the channel mask. */
-        if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-            ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        } else {
-            ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        }
-
-        /*
-        After getting the actual format the size of the buffer in frames may have actually changed. However, we want this to be as close to what the
-        user has asked for as possible, so let's go ahead and release the old capture buffer and create a new one in this case.
-        */
-        if (periodSizeInFrames != (descDS.dwBufferBytes / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / periodCount)) {
-            descDS.dwBufferBytes = periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * periodCount;
-            ma_IDirectSoundCaptureBuffer_Release((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-
-            hr = ma_IDirectSoundCapture_CreateCaptureBuffer((ma_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (ma_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL);
-            if (FAILED(hr)) {
-                ma_device_uninit__dsound(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", ma_result_from_HRESULT(hr));
-            }
-        }
-
-        /* DirectSound should give us a buffer exactly the size we asked for. */
-        pDescriptorCapture->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorCapture->periodCount        = periodCount;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEFORMATEXTENSIBLE wf;
-        MA_DSBUFFERDESC descDSPrimary;
-        MA_DSCAPS caps;
-        char rawdata[1024]; /* <-- Ugly hack to avoid a malloc() due to a crappy DirectSound API. */
-        WAVEFORMATEXTENSIBLE* pActualFormat;
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodCount;
-        MA_DSBUFFERDESC descDS;
-
-        result = ma_config_to_WAVEFORMATEXTENSIBLE(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &wf);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_context_create_IDirectSound__dsound(pDevice->pContext, pDescriptorPlayback->shareMode, pDescriptorPlayback->pDeviceID, (ma_IDirectSound**)&pDevice->dsound.pPlayback);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit__dsound(pDevice);
-            return result;
-        }
-
-        MA_ZERO_OBJECT(&descDSPrimary);
-        descDSPrimary.dwSize  = sizeof(MA_DSBUFFERDESC);
-        descDSPrimary.dwFlags = MA_DSBCAPS_PRIMARYBUFFER | MA_DSBCAPS_CTRLVOLUME;
-        hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-
-        /* We may want to make some adjustments to the format if we are using defaults. */
-        MA_ZERO_OBJECT(&caps);
-        caps.dwSize = sizeof(caps);
-        hr = ma_IDirectSound_GetCaps((ma_IDirectSound*)pDevice->dsound.pPlayback, &caps);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", ma_result_from_HRESULT(hr));
-        }
-
-        if (pDescriptorPlayback->channels == 0) {
-            if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) {
-                DWORD speakerConfig;
-
-                /* It supports at least stereo, but could support more. */
-                wf.Format.nChannels = 2;
-
-                /* Look at the speaker configuration to get a better idea on the channel count. */
-                if (SUCCEEDED(ma_IDirectSound_GetSpeakerConfig((ma_IDirectSound*)pDevice->dsound.pPlayback, &speakerConfig))) {
-                    ma_get_channels_from_speaker_config__dsound(speakerConfig, &wf.Format.nChannels, &wf.dwChannelMask);
-                }
-            } else {
-                /* It does not support stereo, which means we are stuck with mono. */
-                wf.Format.nChannels = 1;
-            }
-        }
-
-        if (pDescriptorPlayback->sampleRate == 0) {
-            /* We base the sample rate on the values returned by GetCaps(). */
-            if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) {
-                wf.Format.nSamplesPerSec = ma_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate);
-            } else {
-                wf.Format.nSamplesPerSec = caps.dwMaxSecondarySampleRate;
-            }
-        }
-
-        wf.Format.nBlockAlign     = (WORD)(wf.Format.nChannels * wf.Format.wBitsPerSample / 8);
-        wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec;
-
-        /*
-        From MSDN:
-
-        The method succeeds even if the hardware does not support the requested format; DirectSound sets the buffer to the closest
-        supported format. To determine whether this has happened, an application can call the GetFormat method for the primary buffer
-        and compare the result with the format that was requested with the SetFormat method.
-        */
-        hr = ma_IDirectSoundBuffer_SetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)&wf);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* Get the _actual_ properties of the buffer. */
-        pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata;
-        hr = ma_IDirectSoundBuffer_GetFormat((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* We now have enough information to start setting some output properties. */
-        pDescriptorPlayback->format     = ma_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat);
-        pDescriptorPlayback->channels   = pActualFormat->Format.nChannels;
-        pDescriptorPlayback->sampleRate = pActualFormat->Format.nSamplesPerSec;
-
-        /* Get the internal channel map based on the channel mask. */
-        if (pActualFormat->Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
-            ma_channel_mask_to_channel_map__win32(pActualFormat->dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        } else {
-            ma_channel_mask_to_channel_map__win32(wf.dwChannelMask, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        }
-
-        /* The size of the buffer must be a clean multiple of the period count. */
-        periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__dsound(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-        periodCount = (pDescriptorPlayback->periodCount > 0) ? pDescriptorPlayback->periodCount : MA_DEFAULT_PERIODS;
-
-        /*
-        Meaning of dwFlags (from MSDN):
-
-        DSBCAPS_CTRLPOSITIONNOTIFY
-          The buffer has position notification capability.
-
-        DSBCAPS_GLOBALFOCUS
-          With this flag set, an application using DirectSound can continue to play its buffers if the user switches focus to
-          another application, even if the new application uses DirectSound.
-
-        DSBCAPS_GETCURRENTPOSITION2
-          In the first version of DirectSound, the play cursor was significantly ahead of the actual playing sound on emulated
-          sound cards; it was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag is specified, the
-          application can get a more accurate play cursor.
-        */
-        MA_ZERO_OBJECT(&descDS);
-        descDS.dwSize = sizeof(descDS);
-        descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2;
-        descDS.dwBufferBytes = periodSizeInFrames * periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels);
-        descDS.lpwfxFormat = (WAVEFORMATEX*)&wf;
-        hr = ma_IDirectSound_CreateSoundBuffer((ma_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (ma_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL);
-        if (FAILED(hr)) {
-            ma_device_uninit__dsound(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer.", ma_result_from_HRESULT(hr));
-        }
-
-        /* DirectSound should give us a buffer exactly the size we asked for. */
-        pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorPlayback->periodCount        = periodCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_data_loop__dsound(ma_device* pDevice)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint32 bpfDeviceCapture  = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    ma_uint32 bpfDevicePlayback = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    HRESULT hr;
-    DWORD lockOffsetInBytesCapture;
-    DWORD lockSizeInBytesCapture;
-    DWORD mappedSizeInBytesCapture;
-    DWORD mappedDeviceFramesProcessedCapture;
-    void* pMappedDeviceBufferCapture;
-    DWORD lockOffsetInBytesPlayback;
-    DWORD lockSizeInBytesPlayback;
-    DWORD mappedSizeInBytesPlayback;
-    void* pMappedDeviceBufferPlayback;
-    DWORD prevReadCursorInBytesCapture = 0;
-    DWORD prevPlayCursorInBytesPlayback = 0;
-    ma_bool32 physicalPlayCursorLoopFlagPlayback = 0;
-    DWORD virtualWriteCursorInBytesPlayback = 0;
-    ma_bool32 virtualWriteCursorLoopFlagPlayback = 0;
-    ma_bool32 isPlaybackDeviceStarted = MA_FALSE;
-    ma_uint32 framesWrittenToPlaybackDevice = 0;   /* For knowing whether or not the playback device needs to be started. */
-    ma_uint32 waitTimeInMilliseconds = 1;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* The first thing to do is start the capture device. The playback device is only started after the first period is written. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (FAILED(ma_IDirectSoundCaptureBuffer_Start((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, MA_DSCBSTART_LOOPING))) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Start() failed.", MA_FAILED_TO_START_BACKEND_DEVICE);
-        }
-    }
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        switch (pDevice->type)
-        {
-            case ma_device_type_duplex:
-            {
-                DWORD physicalCaptureCursorInBytes;
-                DWORD physicalReadCursorInBytes;
-                hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes);
-                if (FAILED(hr)) {
-                    return ma_result_from_HRESULT(hr);
-                }
-
-                /* If nothing is available we just sleep for a bit and return from this iteration. */
-                if (physicalReadCursorInBytes == prevReadCursorInBytesCapture) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                /*
-                The current position has moved. We need to map all of the captured samples and write them to the playback device, making sure
-                we don't return until every frame has been copied over.
-                */
-                if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) {
-                    /* The capture position has not looped. This is the simple case. */
-                    lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                    lockSizeInBytesCapture   = (physicalReadCursorInBytes - prevReadCursorInBytesCapture);
-                } else {
-                    /*
-                    The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything,
-                    do it again from the start.
-                    */
-                    if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) {
-                        /* Lock up to the end of the buffer. */
-                        lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                        lockSizeInBytesCapture   = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture;
-                    } else {
-                        /* Lock starting from the start of the buffer. */
-                        lockOffsetInBytesCapture = 0;
-                        lockSizeInBytesCapture   = physicalReadCursorInBytes;
-                    }
-                }
-
-                if (lockSizeInBytesCapture == 0) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                }
-
-
-                /* At this point we have some input data that we need to output. We do not return until every mapped frame of the input data is written to the playback device. */
-                mappedDeviceFramesProcessedCapture = 0;
-
-                for (;;) {  /* Keep writing to the playback device. */
-                    ma_uint8  inputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                    ma_uint32 inputFramesInClientFormatCap = sizeof(inputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->capture.format, pDevice->capture.channels);
-                    ma_uint8  outputFramesInClientFormat[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                    ma_uint32 outputFramesInClientFormatCap = sizeof(outputFramesInClientFormat) / ma_get_bytes_per_frame(pDevice->playback.format, pDevice->playback.channels);
-                    ma_uint32 outputFramesInClientFormatCount;
-                    ma_uint32 outputFramesInClientFormatConsumed = 0;
-                    ma_uint64 clientCapturedFramesToProcess = ma_min(inputFramesInClientFormatCap, outputFramesInClientFormatCap);
-                    ma_uint64 deviceCapturedFramesToProcess = (mappedSizeInBytesCapture / bpfDeviceCapture) - mappedDeviceFramesProcessedCapture;
-                    void* pRunningMappedDeviceBufferCapture = ma_offset_ptr(pMappedDeviceBufferCapture, mappedDeviceFramesProcessedCapture * bpfDeviceCapture);
-
-                    result = ma_data_converter_process_pcm_frames(&pDevice->capture.converter, pRunningMappedDeviceBufferCapture, &deviceCapturedFramesToProcess, inputFramesInClientFormat, &clientCapturedFramesToProcess);
-                    if (result != MA_SUCCESS) {
-                        break;
-                    }
-
-                    outputFramesInClientFormatCount     = (ma_uint32)clientCapturedFramesToProcess;
-                    mappedDeviceFramesProcessedCapture += (ma_uint32)deviceCapturedFramesToProcess;
-
-                    ma_device__on_data(pDevice, outputFramesInClientFormat, inputFramesInClientFormat, (ma_uint32)clientCapturedFramesToProcess);
-
-                    /* At this point we have input and output data in client format. All we need to do now is convert it to the output device format. This may take a few passes. */
-                    for (;;) {
-                        ma_uint32 framesWrittenThisIteration;
-                        DWORD physicalPlayCursorInBytes;
-                        DWORD physicalWriteCursorInBytes;
-                        DWORD availableBytesPlayback;
-                        DWORD silentPaddingInBytes = 0; /* <-- Must be initialized to 0. */
-
-                        /* We need the physical play and write cursors. */
-                        if (FAILED(ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) {
-                            break;
-                        }
-
-                        if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                            physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                        }
-                        prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                        /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */
-                        if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                            /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                            if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                                availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                                availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                            } else {
-                                /* This is an error. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                            #endif
-                                availableBytesPlayback = 0;
-                            }
-                        } else {
-                            /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                            if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                                availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                            } else {
-                                /* This is an error. */
-                            #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                            #endif
-                                availableBytesPlayback = 0;
-                            }
-                        }
-
-                    #ifdef MA_DEBUG_OUTPUT
-                        /*printf("[DirectSound] (Duplex/Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback);*/
-                    #endif
-
-                        /* If there's no room available for writing we need to wait for more. */
-                        if (availableBytesPlayback == 0) {
-                            /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */
-                            if (!isPlaybackDeviceStarted) {
-                                hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                                if (FAILED(hr)) {
-                                    ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-                                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                                }
-                                isPlaybackDeviceStarted = MA_TRUE;
-                            } else {
-                                ma_sleep(waitTimeInMilliseconds);
-                                continue;
-                            }
-                        }
-
-
-                        /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */
-                        lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback;
-                        if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                            /* Same loop iteration. Go up to the end of the buffer. */
-                            lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        } else {
-                            /* Different loop iterations. Go up to the physical play cursor. */
-                            lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                        }
-
-                        hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0);
-                        if (FAILED(hr)) {
-                            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                            break;
-                        }
-
-                        /*
-                        Experiment: If the playback buffer is being starved, pad it with some silence to get it back in sync. This will cause a glitch, but it may prevent
-                        endless glitching due to it constantly running out of data.
-                        */
-                        if (isPlaybackDeviceStarted) {
-                            DWORD bytesQueuedForPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - availableBytesPlayback;
-                            if (bytesQueuedForPlayback < (pDevice->playback.internalPeriodSizeInFrames*bpfDevicePlayback)) {
-                                silentPaddingInBytes   = (pDevice->playback.internalPeriodSizeInFrames*2*bpfDevicePlayback) - bytesQueuedForPlayback;
-                                if (silentPaddingInBytes > lockSizeInBytesPlayback) {
-                                    silentPaddingInBytes = lockSizeInBytesPlayback;
-                                }
-
-                        #ifdef MA_DEBUG_OUTPUT
-                                printf("[DirectSound] (Duplex/Playback) Playback buffer starved. availableBytesPlayback=%ld, silentPaddingInBytes=%ld\n", availableBytesPlayback, silentPaddingInBytes);
-                        #endif
-                            }
-                        }
-
-                        /* At this point we have a buffer for output. */
-                        if (silentPaddingInBytes > 0) {
-                            MA_ZERO_MEMORY(pMappedDeviceBufferPlayback, silentPaddingInBytes);
-                            framesWrittenThisIteration = silentPaddingInBytes/bpfDevicePlayback;
-                        } else {
-                            ma_uint64 convertedFrameCountIn  = (outputFramesInClientFormatCount - outputFramesInClientFormatConsumed);
-                            ma_uint64 convertedFrameCountOut = mappedSizeInBytesPlayback/bpfDevicePlayback;
-                            void* pConvertedFramesIn  = ma_offset_ptr(outputFramesInClientFormat, outputFramesInClientFormatConsumed * bpfDevicePlayback);
-                            void* pConvertedFramesOut = pMappedDeviceBufferPlayback;
-
-                            result = ma_data_converter_process_pcm_frames(&pDevice->playback.converter, pConvertedFramesIn, &convertedFrameCountIn, pConvertedFramesOut, &convertedFrameCountOut);
-                            if (result != MA_SUCCESS) {
-                                break;
-                            }
-
-                            outputFramesInClientFormatConsumed += (ma_uint32)convertedFrameCountOut;
-                            framesWrittenThisIteration          = (ma_uint32)convertedFrameCountOut;
-                        }
-
-
-                        hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, framesWrittenThisIteration*bpfDevicePlayback, NULL, 0);
-                        if (FAILED(hr)) {
-                            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                            break;
-                        }
-
-                        virtualWriteCursorInBytesPlayback += framesWrittenThisIteration*bpfDevicePlayback;
-                        if ((virtualWriteCursorInBytesPlayback/bpfDevicePlayback) == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods) {
-                            virtualWriteCursorInBytesPlayback  = 0;
-                            virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback;
-                        }
-
-                        /*
-                        We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds
-                        a bit of a buffer to prevent the playback buffer from getting starved.
-                        */
-                        framesWrittenToPlaybackDevice += framesWrittenThisIteration;
-                        if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= (pDevice->playback.internalPeriodSizeInFrames*2)) {
-                            hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                            if (FAILED(hr)) {
-                                ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-                                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                            }
-                            isPlaybackDeviceStarted = MA_TRUE;
-                        }
-
-                        if (framesWrittenThisIteration < mappedSizeInBytesPlayback/bpfDevicePlayback) {
-                            break;  /* We're finished with the output data.*/
-                        }
-                    }
-
-                    if (clientCapturedFramesToProcess == 0) {
-                        break;  /* We just consumed every input sample. */
-                    }
-                }
-
-
-                /* At this point we're done with the mapped portion of the capture buffer. */
-                hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                }
-                prevReadCursorInBytesCapture = (lockOffsetInBytesCapture + mappedSizeInBytesCapture);
-            } break;
-
-
-
-            case ma_device_type_capture:
-            {
-                DWORD physicalCaptureCursorInBytes;
-                DWORD physicalReadCursorInBytes;
-                hr = ma_IDirectSoundCaptureBuffer_GetCurrentPosition((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes);
-                if (FAILED(hr)) {
-                    return MA_ERROR;
-                }
-
-                /* If the previous capture position is the same as the current position we need to wait a bit longer. */
-                if (prevReadCursorInBytesCapture == physicalReadCursorInBytes) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue;
-                }
-
-                /* Getting here means we have capture data available. */
-                if (prevReadCursorInBytesCapture < physicalReadCursorInBytes) {
-                    /* The capture position has not looped. This is the simple case. */
-                    lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                    lockSizeInBytesCapture   = (physicalReadCursorInBytes - prevReadCursorInBytesCapture);
-                } else {
-                    /*
-                    The capture position has looped. This is the more complex case. Map to the end of the buffer. If this does not return anything,
-                    do it again from the start.
-                    */
-                    if (prevReadCursorInBytesCapture < pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) {
-                        /* Lock up to the end of the buffer. */
-                        lockOffsetInBytesCapture = prevReadCursorInBytesCapture;
-                        lockSizeInBytesCapture   = (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture) - prevReadCursorInBytesCapture;
-                    } else {
-                        /* Lock starting from the start of the buffer. */
-                        lockOffsetInBytesCapture = 0;
-                        lockSizeInBytesCapture   = physicalReadCursorInBytes;
-                    }
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                /*printf("[DirectSound] (Capture) physicalCaptureCursorInBytes=%d, physicalReadCursorInBytes=%d\n", physicalCaptureCursorInBytes, physicalReadCursorInBytes);*/
-                /*printf("[DirectSound] (Capture) lockOffsetInBytesCapture=%d, lockSizeInBytesCapture=%d\n", lockOffsetInBytesCapture, lockSizeInBytesCapture);*/
-            #endif
-
-                if (lockSizeInBytesCapture < pDevice->capture.internalPeriodSizeInFrames) {
-                    ma_sleep(waitTimeInMilliseconds);
-                    continue; /* Nothing is available in the capture buffer. */
-                }
-
-                hr = ma_IDirectSoundCaptureBuffer_Lock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedDeviceBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                if (lockSizeInBytesCapture != mappedSizeInBytesCapture) {
-                    printf("[DirectSound] (Capture) lockSizeInBytesCapture=%ld != mappedSizeInBytesCapture=%ld\n", lockSizeInBytesCapture, mappedSizeInBytesCapture);
-                }
-            #endif
-
-                ma_device__send_frames_to_client(pDevice, mappedSizeInBytesCapture/bpfDeviceCapture, pMappedDeviceBufferCapture);
-
-                hr = ma_IDirectSoundCaptureBuffer_Unlock((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedDeviceBufferCapture, mappedSizeInBytesCapture, NULL, 0);
-                if (FAILED(hr)) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", ma_result_from_HRESULT(hr));
-                }
-                prevReadCursorInBytesCapture = lockOffsetInBytesCapture + mappedSizeInBytesCapture;
-
-                if (prevReadCursorInBytesCapture == (pDevice->capture.internalPeriodSizeInFrames*pDevice->capture.internalPeriods*bpfDeviceCapture)) {
-                    prevReadCursorInBytesCapture = 0;
-                }
-            } break;
-
-
-
-            case ma_device_type_playback:
-            {
-                DWORD availableBytesPlayback;
-                DWORD physicalPlayCursorInBytes;
-                DWORD physicalWriteCursorInBytes;
-                hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes);
-                if (FAILED(hr)) {
-                    break;
-                }
-
-                if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                    physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                }
-                prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                /* If there's any bytes available for writing we can do that now. The space between the virtual cursor position and play cursor. */
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                    } else {
-                        /* This is an error. */
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[DirectSound] (Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                    #endif
-                        availableBytesPlayback = 0;
-                    }
-                } else {
-                    /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                    } else {
-                        /* This is an error. */
-                    #ifdef MA_DEBUG_OUTPUT
-                        printf("[DirectSound] (Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%ld, virtualWriteCursorInBytes=%ld.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback);
-                    #endif
-                        availableBytesPlayback = 0;
-                    }
-                }
-
-            #ifdef MA_DEBUG_OUTPUT
-                /*printf("[DirectSound] (Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback);*/
-            #endif
-
-                /* If there's no room available for writing we need to wait for more. */
-                if (availableBytesPlayback < pDevice->playback.internalPeriodSizeInFrames) {
-                    /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */
-                    if (availableBytesPlayback == 0 && !isPlaybackDeviceStarted) {
-                        hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                        if (FAILED(hr)) {
-                            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                        }
-                        isPlaybackDeviceStarted = MA_TRUE;
-                    } else {
-                        ma_sleep(waitTimeInMilliseconds);
-                        continue;
-                    }
-                }
-
-                /* Getting here means there room available somewhere. We limit this to either the end of the buffer or the physical play cursor, whichever is closest. */
-                lockOffsetInBytesPlayback = virtualWriteCursorInBytesPlayback;
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. Go up to the end of the buffer. */
-                    lockSizeInBytesPlayback = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                } else {
-                    /* Different loop iterations. Go up to the physical play cursor. */
-                    lockSizeInBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                }
-
-                hr = ma_IDirectSoundBuffer_Lock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedDeviceBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0);
-                if (FAILED(hr)) {
-                    result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", ma_result_from_HRESULT(hr));
-                    break;
-                }
-
-                /* At this point we have a buffer for output. */
-                ma_device__read_frames_from_client(pDevice, (mappedSizeInBytesPlayback/bpfDevicePlayback), pMappedDeviceBufferPlayback);
-
-                hr = ma_IDirectSoundBuffer_Unlock((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedDeviceBufferPlayback, mappedSizeInBytesPlayback, NULL, 0);
-                if (FAILED(hr)) {
-                    result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", ma_result_from_HRESULT(hr));
-                    break;
-                }
-
-                virtualWriteCursorInBytesPlayback += mappedSizeInBytesPlayback;
-                if (virtualWriteCursorInBytesPlayback == pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) {
-                    virtualWriteCursorInBytesPlayback  = 0;
-                    virtualWriteCursorLoopFlagPlayback = !virtualWriteCursorLoopFlagPlayback;
-                }
-
-                /*
-                We may need to start the device. We want two full periods to be written before starting the playback device. Having an extra period adds
-                a bit of a buffer to prevent the playback buffer from getting starved.
-                */
-                framesWrittenToPlaybackDevice += mappedSizeInBytesPlayback/bpfDevicePlayback;
-                if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= pDevice->playback.internalPeriodSizeInFrames) {
-                    hr = ma_IDirectSoundBuffer_Play((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING);
-                    if (FAILED(hr)) {
-                        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", ma_result_from_HRESULT(hr));
-                    }
-                    isPlaybackDeviceStarted = MA_TRUE;
-                }
-            } break;
-
-
-            default: return MA_INVALID_ARGS;   /* Invalid device type. */
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    /* Getting here means the device is being stopped. */
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        hr = ma_IDirectSoundCaptureBuffer_Stop((ma_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Stop() failed.", ma_result_from_HRESULT(hr));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
-        if (isPlaybackDeviceStarted) {
-            for (;;) {
-                DWORD availableBytesPlayback = 0;
-                DWORD physicalPlayCursorInBytes;
-                DWORD physicalWriteCursorInBytes;
-                hr = ma_IDirectSoundBuffer_GetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes);
-                if (FAILED(hr)) {
-                    break;
-                }
-
-                if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
-                    physicalPlayCursorLoopFlagPlayback = !physicalPlayCursorLoopFlagPlayback;
-                }
-                prevPlayCursorInBytesPlayback  = physicalPlayCursorInBytes;
-
-                if (physicalPlayCursorLoopFlagPlayback == virtualWriteCursorLoopFlagPlayback) {
-                    /* Same loop iteration. The available bytes wraps all the way around from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes <= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback  = (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback) - virtualWriteCursorInBytesPlayback;
-                        availableBytesPlayback += physicalPlayCursorInBytes;    /* Wrap around. */
-                    } else {
-                        break;
-                    }
-                } else {
-                    /* Different loop iterations. The available bytes only goes from the virtual write cursor to the physical play cursor. */
-                    if (physicalPlayCursorInBytes >= virtualWriteCursorInBytesPlayback) {
-                        availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback;
-                    } else {
-                        break;
-                    }
-                }
-
-                if (availableBytesPlayback >= (pDevice->playback.internalPeriodSizeInFrames*pDevice->playback.internalPeriods*bpfDevicePlayback)) {
-                    break;
-                }
-
-                ma_sleep(waitTimeInMilliseconds);
-            }
-        }
-
-        hr = ma_IDirectSoundBuffer_Stop((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer);
-        if (FAILED(hr)) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Stop() failed.", ma_result_from_HRESULT(hr));
-        }
-
-        ma_IDirectSoundBuffer_SetCurrentPosition((ma_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__dsound(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_dsound);
-
-    ma_dlclose(pContext, pContext->dsound.hDSoundDLL);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__dsound(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pContext->dsound.hDSoundDLL = ma_dlopen(pContext, "dsound.dll");
-    if (pContext->dsound.hDSoundDLL == NULL) {
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->dsound.DirectSoundCreate            = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCreate");
-    pContext->dsound.DirectSoundEnumerateA        = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundEnumerateA");
-    pContext->dsound.DirectSoundCaptureCreate     = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureCreate");
-    pContext->dsound.DirectSoundCaptureEnumerateA = ma_dlsym(pContext, pContext->dsound.hDSoundDLL, "DirectSoundCaptureEnumerateA");
-
-    pCallbacks->onContextInit             = ma_context_init__dsound;
-    pCallbacks->onContextUninit           = ma_context_uninit__dsound;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__dsound;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__dsound;
-    pCallbacks->onDeviceInit              = ma_device_init__dsound;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__dsound;
-    pCallbacks->onDeviceStart             = NULL;   /* Not used. Started in onDeviceDataLoop. */
-    pCallbacks->onDeviceStop              = NULL;   /* Not used. Stopped in onDeviceDataLoop. */
-    pCallbacks->onDeviceRead              = NULL;   /* Not used. Data is read directly in onDeviceDataLoop. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used. Data is written directly in onDeviceDataLoop. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__dsound;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-/******************************************************************************
-
-WinMM Backend
-
-******************************************************************************/
-#ifdef MA_HAS_WINMM
-
-/*
-Some older compilers don't have WAVEOUTCAPS2A and WAVEINCAPS2A, so we'll need to write this ourselves. These structures
-are exactly the same as the older ones but they have a few GUIDs for manufacturer/product/name identification. I'm keeping
-the names the same as the Win32 library for consistency, but namespaced to avoid naming conflicts with the Win32 version.
-*/
-typedef struct
-{
-    WORD wMid;
-    WORD wPid;
-    MMVERSION vDriverVersion;
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    WORD wReserved1;
-    DWORD dwSupport;
-    GUID ManufacturerGuid;
-    GUID ProductGuid;
-    GUID NameGuid;
-} MA_WAVEOUTCAPS2A;
-typedef struct
-{
-    WORD wMid;
-    WORD wPid;
-    MMVERSION vDriverVersion;
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    WORD wReserved1;
-    GUID ManufacturerGuid;
-    GUID ProductGuid;
-    GUID NameGuid;
-} MA_WAVEINCAPS2A;
-
-typedef UINT     (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutOpen)(LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutClose)(HWAVEOUT hwo);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutWrite)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveOutReset)(HWAVEOUT hwo);
-typedef UINT     (WINAPI * MA_PFN_waveInGetNumDevs)(void);
-typedef MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic);
-typedef MMRESULT (WINAPI * MA_PFN_waveInOpen)(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
-typedef MMRESULT (WINAPI * MA_PFN_waveInClose)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
-typedef MMRESULT (WINAPI * MA_PFN_waveInStart)(HWAVEIN hwi);
-typedef MMRESULT (WINAPI * MA_PFN_waveInReset)(HWAVEIN hwi);
-
-static ma_result ma_result_from_MMRESULT(MMRESULT resultMM)
-{
-    switch (resultMM) {
-        case MMSYSERR_NOERROR:      return MA_SUCCESS;
-        case MMSYSERR_BADDEVICEID:  return MA_INVALID_ARGS;
-        case MMSYSERR_INVALHANDLE:  return MA_INVALID_ARGS;
-        case MMSYSERR_NOMEM:        return MA_OUT_OF_MEMORY;
-        case MMSYSERR_INVALFLAG:    return MA_INVALID_ARGS;
-        case MMSYSERR_INVALPARAM:   return MA_INVALID_ARGS;
-        case MMSYSERR_HANDLEBUSY:   return MA_BUSY;
-        case MMSYSERR_ERROR:        return MA_ERROR;
-        default:                    return MA_ERROR;
-    }
-}
-
-static char* ma_find_last_character(char* str, char ch)
-{
-    char* last;
-
-    if (str == NULL) {
-        return NULL;
-    }
-
-    last = NULL;
-    while (*str != '\0') {
-        if (*str == ch) {
-            last = str;
-        }
-
-        str += 1;
-    }
-
-    return last;
-}
-
-static ma_uint32 ma_get_period_size_in_bytes(ma_uint32 periodSizeInFrames, ma_format format, ma_uint32 channels)
-{
-    return periodSizeInFrames * ma_get_bytes_per_frame(format, channels);
-}
-
-
-/*
-Our own "WAVECAPS" structure that contains generic information shared between WAVEOUTCAPS2 and WAVEINCAPS2 so
-we can do things generically and typesafely. Names are being kept the same for consistency.
-*/
-typedef struct
-{
-    CHAR szPname[MAXPNAMELEN];
-    DWORD dwFormats;
-    WORD wChannels;
-    GUID NameGuid;
-} MA_WAVECAPSA;
-
-static ma_result ma_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD channels, WORD* pBitsPerSample, DWORD* pSampleRate)
-{
-    WORD bitsPerSample = 0;
-    DWORD sampleRate = 0;
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = 0;
-    }
-    if (pSampleRate) {
-        *pSampleRate = 0;
-    }
-
-    if (channels == 1) {
-        bitsPerSample = 16;
-        if ((dwFormats & WAVE_FORMAT_48M16) != 0) {
-            sampleRate = 48000;
-        } else if ((dwFormats & WAVE_FORMAT_44M16) != 0) {
-            sampleRate = 44100;
-        } else if ((dwFormats & WAVE_FORMAT_2M16) != 0) {
-            sampleRate = 22050;
-        } else if ((dwFormats & WAVE_FORMAT_1M16) != 0) {
-            sampleRate = 11025;
-        } else if ((dwFormats & WAVE_FORMAT_96M16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((dwFormats & WAVE_FORMAT_48M08) != 0) {
-                sampleRate = 48000;
-            } else if ((dwFormats & WAVE_FORMAT_44M08) != 0) {
-                sampleRate = 44100;
-            } else if ((dwFormats & WAVE_FORMAT_2M08) != 0) {
-                sampleRate = 22050;
-            } else if ((dwFormats & WAVE_FORMAT_1M08) != 0) {
-                sampleRate = 11025;
-            } else if ((dwFormats & WAVE_FORMAT_96M08) != 0) {
-                sampleRate = 96000;
-            } else {
-                return MA_FORMAT_NOT_SUPPORTED;
-            }
-        }
-    } else {
-        bitsPerSample = 16;
-        if ((dwFormats & WAVE_FORMAT_48S16) != 0) {
-            sampleRate = 48000;
-        } else if ((dwFormats & WAVE_FORMAT_44S16) != 0) {
-            sampleRate = 44100;
-        } else if ((dwFormats & WAVE_FORMAT_2S16) != 0) {
-            sampleRate = 22050;
-        } else if ((dwFormats & WAVE_FORMAT_1S16) != 0) {
-            sampleRate = 11025;
-        } else if ((dwFormats & WAVE_FORMAT_96S16) != 0) {
-            sampleRate = 96000;
-        } else {
-            bitsPerSample = 8;
-            if ((dwFormats & WAVE_FORMAT_48S08) != 0) {
-                sampleRate = 48000;
-            } else if ((dwFormats & WAVE_FORMAT_44S08) != 0) {
-                sampleRate = 44100;
-            } else if ((dwFormats & WAVE_FORMAT_2S08) != 0) {
-                sampleRate = 22050;
-            } else if ((dwFormats & WAVE_FORMAT_1S08) != 0) {
-                sampleRate = 11025;
-            } else if ((dwFormats & WAVE_FORMAT_96S08) != 0) {
-                sampleRate = 96000;
-            } else {
-                return MA_FORMAT_NOT_SUPPORTED;
-            }
-        }
-    }
-
-    if (pBitsPerSample) {
-        *pBitsPerSample = bitsPerSample;
-    }
-    if (pSampleRate) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, WAVEFORMATEX* pWF)
-{
-    ma_result result;
-
-    MA_ASSERT(pWF != NULL);
-
-    MA_ZERO_OBJECT(pWF);
-    pWF->cbSize     = sizeof(*pWF);
-    pWF->wFormatTag = WAVE_FORMAT_PCM;
-    pWF->nChannels  = (WORD)channels;
-    if (pWF->nChannels > 2) {
-        pWF->nChannels = 2;
-    }
-
-    result = ma_get_best_info_from_formats_flags__winmm(dwFormats, channels, &pWF->wBitsPerSample, &pWF->nSamplesPerSec);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pWF->nBlockAlign     = (WORD)(pWF->nChannels * pWF->wBitsPerSample / 8);
-    pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info_from_WAVECAPS(ma_context* pContext, MA_WAVECAPSA* pCaps, ma_device_info* pDeviceInfo)
-{
-    WORD bitsPerSample;
-    DWORD sampleRate;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /*
-    Name / Description
-
-    Unfortunately the name specified in WAVE(OUT/IN)CAPS2 is limited to 31 characters. This results in an unprofessional looking
-    situation where the names of the devices are truncated. To help work around this, we need to look at the name GUID and try
-    looking in the registry for the full name. If we can't find it there, we need to just fall back to the default name.
-    */
-
-    /* Set the default to begin with. */
-    ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), pCaps->szPname, (size_t)-1);
-
-    /*
-    Now try the registry. There's a few things to consider here:
-    - The name GUID can be null, in which we case we just need to stick to the original 31 characters.
-    - If the name GUID is not present in the registry we'll also need to stick to the original 31 characters.
-    - I like consistency, so I want the returned device names to be consistent with those returned by WASAPI and DirectSound. The
-      problem, however is that WASAPI and DirectSound use "<component> (<name>)" format (such as "Speakers (High Definition Audio)"),
-      but WinMM does not specificy the component name. From my admittedly limited testing, I've notice the component name seems to
-      usually fit within the 31 characters of the fixed sized buffer, so what I'm going to do is parse that string for the component
-      name, and then concatenate the name from the registry.
-    */
-    if (!ma_is_guid_null(&pCaps->NameGuid)) {
-        wchar_t guidStrW[256];
-        if (((MA_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, ma_countof(guidStrW)) > 0) {
-            char guidStr[256];
-            char keyStr[1024];
-            HKEY hKey;
-
-            WideCharToMultiByte(CP_UTF8, 0, guidStrW, -1, guidStr, sizeof(guidStr), 0, FALSE);
-
-            ma_strcpy_s(keyStr, sizeof(keyStr), "SYSTEM\\CurrentControlSet\\Control\\MediaCategories\\");
-            ma_strcat_s(keyStr, sizeof(keyStr), guidStr);
-
-            if (((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
-                BYTE nameFromReg[512];
-                DWORD nameFromRegSize = sizeof(nameFromReg);
-                result = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize);
-                ((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey);
-
-                if (result == ERROR_SUCCESS) {
-                    /* We have the value from the registry, so now we need to construct the name string. */
-                    char name[1024];
-                    if (ma_strcpy_s(name, sizeof(name), pDeviceInfo->name) == 0) {
-                        char* nameBeg = ma_find_last_character(name, '(');
-                        if (nameBeg != NULL) {
-                            size_t leadingLen = (nameBeg - name);
-                            ma_strncpy_s(nameBeg + 1, sizeof(name) - leadingLen, (const char*)nameFromReg, (size_t)-1);
-
-                            /* The closing ")", if it can fit. */
-                            if (leadingLen + nameFromRegSize < sizeof(name)-1) {
-                                ma_strcat_s(name, sizeof(name), ")");
-                            }
-
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), name, (size_t)-1);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    result = ma_get_best_info_from_formats_flags__winmm(pCaps->dwFormats, pCaps->wChannels, &bitsPerSample, &sampleRate);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (bitsPerSample == 8) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_u8;
-    } else if (bitsPerSample == 16) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s16;
-    } else if (bitsPerSample == 24) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s24;
-    } else if (bitsPerSample == 32) {
-        pDeviceInfo->nativeDataFormats[0].format = ma_format_s32;
-    } else {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-    pDeviceInfo->nativeDataFormats[0].channels   = pCaps->wChannels;
-    pDeviceInfo->nativeDataFormats[0].sampleRate = sampleRate;
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info_from_WAVEOUTCAPS2(ma_context* pContext, MA_WAVEOUTCAPS2A* pCaps, ma_device_info* pDeviceInfo)
-{
-    MA_WAVECAPSA caps;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname));
-    caps.dwFormats = pCaps->dwFormats;
-    caps.wChannels = pCaps->wChannels;
-    caps.NameGuid  = pCaps->NameGuid;
-    return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo);
-}
-
-static ma_result ma_context_get_device_info_from_WAVEINCAPS2(ma_context* pContext, MA_WAVEINCAPS2A* pCaps, ma_device_info* pDeviceInfo)
-{
-    MA_WAVECAPSA caps;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pCaps != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    MA_COPY_MEMORY(caps.szPname, pCaps->szPname, sizeof(caps.szPname));
-    caps.dwFormats = pCaps->dwFormats;
-    caps.wChannels = pCaps->wChannels;
-    caps.NameGuid  = pCaps->NameGuid;
-    return ma_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo);
-}
-
-
-static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    UINT playbackDeviceCount;
-    UINT captureDeviceCount;
-    UINT iPlaybackDevice;
-    UINT iCaptureDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)();
-    for (iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) {
-        MMRESULT result;
-        MA_WAVEOUTCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            ma_device_info deviceInfo;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.winmm = iPlaybackDevice;
-
-            /* The first enumerated device is the default device. */
-            if (iPlaybackDevice == 0) {
-                deviceInfo.isDefault = MA_TRUE;
-            }
-
-            if (ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) {
-                ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    return MA_SUCCESS; /* Enumeration was stopped. */
-                }
-            }
-        }
-    }
-
-    /* Capture. */
-    captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)();
-    for (iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) {
-        MMRESULT result;
-        MA_WAVEINCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            ma_device_info deviceInfo;
-
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.winmm = iCaptureDevice;
-
-            /* The first enumerated device is the default device. */
-            if (iCaptureDevice == 0) {
-                deviceInfo.isDefault = MA_TRUE;
-            }
-
-            if (ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) {
-                ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    return MA_SUCCESS; /* Enumeration was stopped. */
-                }
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    UINT winMMDeviceID;
-
-    MA_ASSERT(pContext != NULL);
-
-    winMMDeviceID = 0;
-    if (pDeviceID != NULL) {
-        winMMDeviceID = (UINT)pDeviceID->winmm;
-    }
-
-    pDeviceInfo->id.winmm = winMMDeviceID;
-
-    /* The first ID is the default device. */
-    if (winMMDeviceID == 0) {
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        MMRESULT result;
-        MA_WAVEOUTCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            return ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo);
-        }
-    } else {
-        MMRESULT result;
-        MA_WAVEINCAPS2A caps;
-
-        MA_ZERO_OBJECT(&caps);
-
-        result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps));
-        if (result == MMSYSERR_NOERROR) {
-            return ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo);
-        }
-    }
-
-    return MA_NO_DEVICE;
-}
-
-
-static ma_result ma_device_uninit__winmm(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        CloseHandle((HANDLE)pDevice->winmm.hEventCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        CloseHandle((HANDLE)pDevice->winmm.hEventPlayback);
-    }
-
-    ma__free_from_callbacks(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
-
-    MA_ZERO_OBJECT(&pDevice->winmm);   /* Safety. */
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__winmm(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /* WinMM has a minimum period size of 40ms. */
-    ma_uint32 minPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(40, nativeSampleRate);
-    ma_uint32 periodSizeInFrames;
-
-    periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, nativeSampleRate, performanceProfile);
-    if (periodSizeInFrames < minPeriodSizeInFrames) {
-        periodSizeInFrames = minPeriodSizeInFrames;
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    const char* errorMsg = "";
-    ma_result errorCode = MA_ERROR;
-    ma_result result = MA_SUCCESS;
-    ma_uint32 heapSize;
-    UINT winMMDeviceIDPlayback = 0;
-    UINT winMMDeviceIDCapture  = 0;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->winmm);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exlusive mode with WinMM. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pDescriptorPlayback->pDeviceID != NULL) {
-        winMMDeviceIDPlayback = (UINT)pDescriptorPlayback->pDeviceID->winmm;
-    }
-    if (pDescriptorCapture->pDeviceID != NULL) {
-        winMMDeviceIDCapture = (UINT)pDescriptorCapture->pDeviceID->winmm;
-    }
-
-    /* The capture device needs to be initialized first. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEINCAPSA caps;
-        WAVEFORMATEX wf;
-        MMRESULT resultMM;
-
-        /* We use an event to know when a new fragment needs to be enqueued. */
-        pDevice->winmm.hEventCapture = (ma_handle)CreateEventW(NULL, TRUE, TRUE, NULL);
-        if (pDevice->winmm.hEventCapture == NULL) {
-            errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = ma_result_from_GetLastError(GetLastError());
-            goto on_error;
-        }
-
-        /* The format should be based on the device's actual format. */
-        if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
-            goto on_error;
-        }
-
-        result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf);
-        if (result != MA_SUCCESS) {
-            errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result;
-            goto on_error;
-        }
-
-        resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
-        if (resultMM != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-            goto on_error;
-        }
-
-        pDescriptorCapture->format             = ma_format_from_WAVEFORMATEX(&wf);
-        pDescriptorCapture->channels           = wf.nChannels;
-        pDescriptorCapture->sampleRate         = wf.nSamplesPerSec;
-        ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-        pDescriptorCapture->periodCount        = pDescriptorCapture->periodCount;
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        WAVEOUTCAPSA caps;
-        WAVEFORMATEX wf;
-        MMRESULT resultMM;
-
-        /* We use an event to know when a new fragment needs to be enqueued. */
-        pDevice->winmm.hEventPlayback = (ma_handle)CreateEvent(NULL, TRUE, TRUE, NULL);
-        if (pDevice->winmm.hEventPlayback == NULL) {
-            errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = ma_result_from_GetLastError(GetLastError());
-            goto on_error;
-        }
-
-        /* The format should be based on the device's actual format. */
-        if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
-            goto on_error;
-        }
-
-        result = ma_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf);
-        if (result != MA_SUCCESS) {
-            errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result;
-            goto on_error;
-        }
-
-        resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
-        if (resultMM != MMSYSERR_NOERROR) {
-            errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-            goto on_error;
-        }
-
-        pDescriptorPlayback->format             = ma_format_from_WAVEFORMATEX(&wf);
-        pDescriptorPlayback->channels           = wf.nChannels;
-        pDescriptorPlayback->sampleRate         = wf.nSamplesPerSec;
-        ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-        pDescriptorPlayback->periodCount        = pDescriptorPlayback->periodCount;
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__winmm(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-    }
-
-    /*
-    The heap allocated data is allocated like so:
-
-    [Capture WAVEHDRs][Playback WAVEHDRs][Capture Intermediary Buffer][Playback Intermediary Buffer]
-    */
-    heapSize = 0;
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        heapSize += sizeof(WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
-    }
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        heapSize += sizeof(WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
-    }
-
-    pDevice->winmm._pHeapData = (ma_uint8*)ma__calloc_from_callbacks(heapSize, &pDevice->pContext->allocationCallbacks);
-    if (pDevice->winmm._pHeapData == NULL) {
-        errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MA_OUT_OF_MEMORY;
-        goto on_error;
-    }
-
-    MA_ZERO_MEMORY(pDevice->winmm._pHeapData, heapSize);
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-
-        if (pConfig->deviceType == ma_device_type_capture) {
-            pDevice->winmm.pWAVEHDRCapture            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
-        } else {
-            pDevice->winmm.pWAVEHDRCapture            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
-        }
-
-        /* Prepare headers. */
-        for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
-            ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->format, pDescriptorCapture->channels);
-
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData         = (LPSTR)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags        = 0L;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops        = 0L;
-            ((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-
-            /*
-            The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
-            it's unlocked and available for writing. A value of 1 means it's locked.
-            */
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-
-        if (pConfig->deviceType == ma_device_type_playback) {
-            pDevice->winmm.pWAVEHDRPlayback            = pDevice->winmm._pHeapData;
-            pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*pDescriptorPlayback->periodCount);
-        } else {
-            pDevice->winmm.pWAVEHDRPlayback            = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
-            pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
-        }
-
-        /* Prepare headers. */
-        for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
-            ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->format, pDescriptorPlayback->channels);
-
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData         = (LPSTR)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags        = 0L;
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops        = 0L;
-            ((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
-
-            /*
-            The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
-            it's unlocked and available for writing. A value of 1 means it's locked.
-            */
-            ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
-        }
-    }
-
-    return MA_SUCCESS;
-
-on_error:
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.pWAVEHDRCapture != NULL) {
-            ma_uint32 iPeriod;
-            for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
-                ((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-            }
-        }
-
-        ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.pWAVEHDRCapture != NULL) {
-            ma_uint32 iPeriod;
-            for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
-                ((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
-            }
-        }
-
-        ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-    }
-
-    ma__free_from_callbacks(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
-    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, errorMsg, errorCode);
-}
-
-static ma_result ma_device_start__winmm(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        MMRESULT resultMM;
-        WAVEHDR* pWAVEHDR;
-        ma_uint32 iPeriod;
-
-        pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
-
-        /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-        ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
-
-        /* To start the device we attach all of the buffers and then start it. As the buffers are filled with data we will get notifications. */
-        for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
-            resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
-            if (resultMM != MMSYSERR_NOERROR) {
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.", ma_result_from_MMRESULT(resultMM));
-            }
-
-            /* Make sure all of the buffers start out locked. We don't want to access them until the backend tells us we can. */
-            pWAVEHDR[iPeriod].dwUser = 1;   /* 1 = locked. */
-        }
-
-        /* Capture devices need to be explicitly started, unlike playback devices. */
-        resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        if (resultMM != MMSYSERR_NOERROR) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Don't need to do anything for playback. It'll be started automatically in ma_device_start__winmm(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__winmm(ma_device* pDevice)
-{
-    MMRESULT resultMM;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->winmm.hDeviceCapture == NULL) {
-            return MA_INVALID_ARGS;
-        }
-
-        resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture);
-        if (resultMM != MMSYSERR_NOERROR) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset capture device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_uint32 iPeriod;
-        WAVEHDR* pWAVEHDR;
-
-        if (pDevice->winmm.hDevicePlayback == NULL) {
-            return MA_INVALID_ARGS;
-        }
-
-        /* We need to drain the device. To do this we just loop over each header and if it's locked just wait for the event. */
-        pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
-        for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; iPeriod += 1) {
-            if (pWAVEHDR[iPeriod].dwUser == 1) { /* 1 = locked. */
-                if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
-                    break;  /* An error occurred so just abandon ship and stop the device without draining. */
-                }
-
-                pWAVEHDR[iPeriod].dwUser = 0;
-            }
-        }
-
-        resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
-        if (resultMM != MMSYSERR_NOERROR) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset playback device.", ma_result_from_MMRESULT(resultMM));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    MMRESULT resultMM;
-    ma_uint32 totalFramesWritten;
-    WAVEHDR* pWAVEHDR;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pPCMFrames != NULL);
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
-
-    /* Keep processing as much data as possible. */
-    totalFramesWritten = 0;
-    while (totalFramesWritten < frameCount) {
-        /* If the current header has some space available we need to write part of it. */
-        if (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser == 0) { /* 0 = unlocked. */
-            /*
-            This header has room in it. We copy as much of it as we can. If we end up fully consuming the buffer we need to
-            write it out and move on to the next iteration.
-            */
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-            ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedPlayback;
-
-            ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesWritten));
-            const void* pSrc = ma_offset_ptr(pPCMFrames, totalFramesWritten*bpf);
-            void* pDst = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].lpData, pDevice->winmm.headerFramesConsumedPlayback*bpf);
-            MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf);
-
-            pDevice->winmm.headerFramesConsumedPlayback += framesToCopy;
-            totalFramesWritten += framesToCopy;
-
-            /* If we've consumed the buffer entirely we need to write it out to the device. */
-            if (pDevice->winmm.headerFramesConsumedPlayback == (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf)) {
-                pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 1;            /* 1 = locked. */
-                pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
-
-                /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-                ResetEvent((HANDLE)pDevice->winmm.hEventPlayback);
-
-                /* The device will be started here. */
-                resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR));
-                if (resultMM != MMSYSERR_NOERROR) {
-                    result = ma_result_from_MMRESULT(resultMM);
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.", result);
-                    break;
-                }
-
-                /* Make sure we move to the next header. */
-                pDevice->winmm.iNextHeaderPlayback = (pDevice->winmm.iNextHeaderPlayback + 1) % pDevice->playback.internalPeriods;
-                pDevice->winmm.headerFramesConsumedPlayback = 0;
-            }
-
-            /* If at this point we have consumed the entire input buffer we can return. */
-            MA_ASSERT(totalFramesWritten <= frameCount);
-            if (totalFramesWritten == frameCount) {
-                break;
-            }
-
-            /* Getting here means there's more to process. */
-            continue;
-        }
-
-        /* Getting here means there isn't enough room in the buffer and we need to wait for one to become available. */
-        if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
-            result = MA_ERROR;
-            break;
-        }
-
-        /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
-        if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & WHDR_DONE) != 0) {
-            pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 0;    /* 0 = unlocked (make it available for writing). */
-            pDevice->winmm.headerFramesConsumedPlayback = 0;
-        }
-
-        /* If the device has been stopped we need to break. */
-        if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-            break;
-        }
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = totalFramesWritten;
-    }
-
-    return result;
-}
-
-static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_result result = MA_SUCCESS;
-    MMRESULT resultMM;
-    ma_uint32 totalFramesRead;
-    WAVEHDR* pWAVEHDR;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pPCMFrames != NULL);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
-
-    /* Keep processing as much data as possible. */
-    totalFramesRead = 0;
-    while (totalFramesRead < frameCount) {
-        /* If the current header has some space available we need to write part of it. */
-        if (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser == 0) { /* 0 = unlocked. */
-            /* The buffer is available for reading. If we fully consume it we need to add it back to the buffer. */
-            ma_uint32 bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-            ma_uint32 framesRemainingInHeader = (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf) - pDevice->winmm.headerFramesConsumedCapture;
-
-            ma_uint32 framesToCopy = ma_min(framesRemainingInHeader, (frameCount - totalFramesRead));
-            const void* pSrc = ma_offset_ptr(pWAVEHDR[pDevice->winmm.iNextHeaderCapture].lpData, pDevice->winmm.headerFramesConsumedCapture*bpf);
-            void* pDst = ma_offset_ptr(pPCMFrames, totalFramesRead*bpf);
-            MA_COPY_MEMORY(pDst, pSrc, framesToCopy*bpf);
-
-            pDevice->winmm.headerFramesConsumedCapture += framesToCopy;
-            totalFramesRead += framesToCopy;
-
-            /* If we've consumed the buffer entirely we need to add it back to the device. */
-            if (pDevice->winmm.headerFramesConsumedCapture == (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf)) {
-                pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 1;            /* 1 = locked. */
-                pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
-
-                /* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
-                ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
-
-                /* The device will be started here. */
-                resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR));
-                if (resultMM != MMSYSERR_NOERROR) {
-                    result = ma_result_from_MMRESULT(resultMM);
-                    ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.", result);
-                    break;
-                }
-
-                /* Make sure we move to the next header. */
-                pDevice->winmm.iNextHeaderCapture = (pDevice->winmm.iNextHeaderCapture + 1) % pDevice->capture.internalPeriods;
-                pDevice->winmm.headerFramesConsumedCapture = 0;
-            }
-
-            /* If at this point we have filled the entire input buffer we can return. */
-            MA_ASSERT(totalFramesRead <= frameCount);
-            if (totalFramesRead == frameCount) {
-                break;
-            }
-
-            /* Getting here means there's more to process. */
-            continue;
-        }
-
-        /* Getting here means there isn't enough any data left to send to the client which means we need to wait for more. */
-        if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventCapture, INFINITE) != WAIT_OBJECT_0) {
-            result = MA_ERROR;
-            break;
-        }
-
-        /* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
-        if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & WHDR_DONE) != 0) {
-            pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 0;    /* 0 = unlocked (make it available for reading). */
-            pDevice->winmm.headerFramesConsumedCapture = 0;
-        }
-
-        /* If the device has been stopped we need to break. */
-        if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-            break;
-        }
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = totalFramesRead;
-    }
-
-    return result;
-}
-
-static ma_result ma_context_uninit__winmm(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_winmm);
-
-    ma_dlclose(pContext, pContext->winmm.hWinMM);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__winmm(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pContext->winmm.hWinMM = ma_dlopen(pContext, "winmm.dll");
-    if (pContext->winmm.hWinMM == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->winmm.waveOutGetNumDevs      = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutGetNumDevs");
-    pContext->winmm.waveOutGetDevCapsA     = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutGetDevCapsA");
-    pContext->winmm.waveOutOpen            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutOpen");
-    pContext->winmm.waveOutClose           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutClose");
-    pContext->winmm.waveOutPrepareHeader   = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutPrepareHeader");
-    pContext->winmm.waveOutUnprepareHeader = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutUnprepareHeader");
-    pContext->winmm.waveOutWrite           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutWrite");
-    pContext->winmm.waveOutReset           = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveOutReset");
-    pContext->winmm.waveInGetNumDevs       = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInGetNumDevs");
-    pContext->winmm.waveInGetDevCapsA      = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInGetDevCapsA");
-    pContext->winmm.waveInOpen             = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInOpen");
-    pContext->winmm.waveInClose            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInClose");
-    pContext->winmm.waveInPrepareHeader    = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInPrepareHeader");
-    pContext->winmm.waveInUnprepareHeader  = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInUnprepareHeader");
-    pContext->winmm.waveInAddBuffer        = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInAddBuffer");
-    pContext->winmm.waveInStart            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInStart");
-    pContext->winmm.waveInReset            = ma_dlsym(pContext, pContext->winmm.hWinMM, "waveInReset");
-
-    pCallbacks->onContextInit             = ma_context_init__winmm;
-    pCallbacks->onContextUninit           = ma_context_uninit__winmm;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__winmm;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__winmm;
-    pCallbacks->onDeviceInit              = ma_device_init__winmm;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__winmm;
-    pCallbacks->onDeviceStart             = ma_device_start__winmm;
-    pCallbacks->onDeviceStop              = ma_device_stop__winmm;
-    pCallbacks->onDeviceRead              = ma_device_read__winmm;
-    pCallbacks->onDeviceWrite             = ma_device_write__winmm;
-    pCallbacks->onDeviceDataLoop          = NULL;   /* This is a blocking read-write API, so this can be NULL since miniaudio will manage the audio thread for us. */
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-
-
-/******************************************************************************
-
-ALSA Backend
-
-******************************************************************************/
-#ifdef MA_HAS_ALSA
-
-#ifdef MA_NO_RUNTIME_LINKING
-
-/* asoundlib.h marks some functions with "inline" which isn't always supported. Need to emulate it. */
-#if !defined(__cplusplus)
-    #if defined(__STRICT_ANSI__)
-        #if !defined(inline)
-            #define inline __inline__ __attribute__((always_inline))
-            #define MA_INLINE_DEFINED
-        #endif
-    #endif
-#endif
-#include <alsa/asoundlib.h>
-#if defined(MA_INLINE_DEFINED)
-    #undef inline
-    #undef MA_INLINE_DEFINED
-#endif
-
-typedef snd_pcm_uframes_t                       ma_snd_pcm_uframes_t;
-typedef snd_pcm_sframes_t                       ma_snd_pcm_sframes_t;
-typedef snd_pcm_stream_t                        ma_snd_pcm_stream_t;
-typedef snd_pcm_format_t                        ma_snd_pcm_format_t;
-typedef snd_pcm_access_t                        ma_snd_pcm_access_t;
-typedef snd_pcm_t                               ma_snd_pcm_t;
-typedef snd_pcm_hw_params_t                     ma_snd_pcm_hw_params_t;
-typedef snd_pcm_sw_params_t                     ma_snd_pcm_sw_params_t;
-typedef snd_pcm_format_mask_t                   ma_snd_pcm_format_mask_t;
-typedef snd_pcm_info_t                          ma_snd_pcm_info_t;
-typedef snd_pcm_channel_area_t                  ma_snd_pcm_channel_area_t;
-typedef snd_pcm_chmap_t                         ma_snd_pcm_chmap_t;
-typedef snd_pcm_state_t                         ma_snd_pcm_state_t;
-
-/* snd_pcm_stream_t */
-#define MA_SND_PCM_STREAM_PLAYBACK              SND_PCM_STREAM_PLAYBACK
-#define MA_SND_PCM_STREAM_CAPTURE               SND_PCM_STREAM_CAPTURE
-
-/* snd_pcm_format_t */
-#define MA_SND_PCM_FORMAT_UNKNOWN               SND_PCM_FORMAT_UNKNOWN
-#define MA_SND_PCM_FORMAT_U8                    SND_PCM_FORMAT_U8
-#define MA_SND_PCM_FORMAT_S16_LE                SND_PCM_FORMAT_S16_LE
-#define MA_SND_PCM_FORMAT_S16_BE                SND_PCM_FORMAT_S16_BE
-#define MA_SND_PCM_FORMAT_S24_LE                SND_PCM_FORMAT_S24_LE
-#define MA_SND_PCM_FORMAT_S24_BE                SND_PCM_FORMAT_S24_BE
-#define MA_SND_PCM_FORMAT_S32_LE                SND_PCM_FORMAT_S32_LE
-#define MA_SND_PCM_FORMAT_S32_BE                SND_PCM_FORMAT_S32_BE
-#define MA_SND_PCM_FORMAT_FLOAT_LE              SND_PCM_FORMAT_FLOAT_LE
-#define MA_SND_PCM_FORMAT_FLOAT_BE              SND_PCM_FORMAT_FLOAT_BE
-#define MA_SND_PCM_FORMAT_FLOAT64_LE            SND_PCM_FORMAT_FLOAT64_LE
-#define MA_SND_PCM_FORMAT_FLOAT64_BE            SND_PCM_FORMAT_FLOAT64_BE
-#define MA_SND_PCM_FORMAT_MU_LAW                SND_PCM_FORMAT_MU_LAW
-#define MA_SND_PCM_FORMAT_A_LAW                 SND_PCM_FORMAT_A_LAW
-#define MA_SND_PCM_FORMAT_S24_3LE               SND_PCM_FORMAT_S24_3LE
-#define MA_SND_PCM_FORMAT_S24_3BE               SND_PCM_FORMAT_S24_3BE
-
-/* ma_snd_pcm_access_t */
-#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED      SND_PCM_ACCESS_MMAP_INTERLEAVED
-#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED   SND_PCM_ACCESS_MMAP_NONINTERLEAVED
-#define MA_SND_PCM_ACCESS_MMAP_COMPLEX          SND_PCM_ACCESS_MMAP_COMPLEX
-#define MA_SND_PCM_ACCESS_RW_INTERLEAVED        SND_PCM_ACCESS_RW_INTERLEAVED
-#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED     SND_PCM_ACCESS_RW_NONINTERLEAVED
-
-/* Channel positions. */
-#define MA_SND_CHMAP_UNKNOWN                    SND_CHMAP_UNKNOWN
-#define MA_SND_CHMAP_NA                         SND_CHMAP_NA
-#define MA_SND_CHMAP_MONO                       SND_CHMAP_MONO
-#define MA_SND_CHMAP_FL                         SND_CHMAP_FL
-#define MA_SND_CHMAP_FR                         SND_CHMAP_FR
-#define MA_SND_CHMAP_RL                         SND_CHMAP_RL
-#define MA_SND_CHMAP_RR                         SND_CHMAP_RR
-#define MA_SND_CHMAP_FC                         SND_CHMAP_FC
-#define MA_SND_CHMAP_LFE                        SND_CHMAP_LFE
-#define MA_SND_CHMAP_SL                         SND_CHMAP_SL
-#define MA_SND_CHMAP_SR                         SND_CHMAP_SR
-#define MA_SND_CHMAP_RC                         SND_CHMAP_RC
-#define MA_SND_CHMAP_FLC                        SND_CHMAP_FLC
-#define MA_SND_CHMAP_FRC                        SND_CHMAP_FRC
-#define MA_SND_CHMAP_RLC                        SND_CHMAP_RLC
-#define MA_SND_CHMAP_RRC                        SND_CHMAP_RRC
-#define MA_SND_CHMAP_FLW                        SND_CHMAP_FLW
-#define MA_SND_CHMAP_FRW                        SND_CHMAP_FRW
-#define MA_SND_CHMAP_FLH                        SND_CHMAP_FLH
-#define MA_SND_CHMAP_FCH                        SND_CHMAP_FCH
-#define MA_SND_CHMAP_FRH                        SND_CHMAP_FRH
-#define MA_SND_CHMAP_TC                         SND_CHMAP_TC
-#define MA_SND_CHMAP_TFL                        SND_CHMAP_TFL
-#define MA_SND_CHMAP_TFR                        SND_CHMAP_TFR
-#define MA_SND_CHMAP_TFC                        SND_CHMAP_TFC
-#define MA_SND_CHMAP_TRL                        SND_CHMAP_TRL
-#define MA_SND_CHMAP_TRR                        SND_CHMAP_TRR
-#define MA_SND_CHMAP_TRC                        SND_CHMAP_TRC
-#define MA_SND_CHMAP_TFLC                       SND_CHMAP_TFLC
-#define MA_SND_CHMAP_TFRC                       SND_CHMAP_TFRC
-#define MA_SND_CHMAP_TSL                        SND_CHMAP_TSL
-#define MA_SND_CHMAP_TSR                        SND_CHMAP_TSR
-#define MA_SND_CHMAP_LLFE                       SND_CHMAP_LLFE
-#define MA_SND_CHMAP_RLFE                       SND_CHMAP_RLFE
-#define MA_SND_CHMAP_BC                         SND_CHMAP_BC
-#define MA_SND_CHMAP_BLC                        SND_CHMAP_BLC
-#define MA_SND_CHMAP_BRC                        SND_CHMAP_BRC
-
-/* Open mode flags. */
-#define MA_SND_PCM_NO_AUTO_RESAMPLE             SND_PCM_NO_AUTO_RESAMPLE
-#define MA_SND_PCM_NO_AUTO_CHANNELS             SND_PCM_NO_AUTO_CHANNELS
-#define MA_SND_PCM_NO_AUTO_FORMAT               SND_PCM_NO_AUTO_FORMAT
-#else
-#include <errno.h>  /* For EPIPE, etc. */
-typedef unsigned long                           ma_snd_pcm_uframes_t;
-typedef long                                    ma_snd_pcm_sframes_t;
-typedef int                                     ma_snd_pcm_stream_t;
-typedef int                                     ma_snd_pcm_format_t;
-typedef int                                     ma_snd_pcm_access_t;
-typedef int                                     ma_snd_pcm_state_t;
-typedef struct ma_snd_pcm_t                     ma_snd_pcm_t;
-typedef struct ma_snd_pcm_hw_params_t           ma_snd_pcm_hw_params_t;
-typedef struct ma_snd_pcm_sw_params_t           ma_snd_pcm_sw_params_t;
-typedef struct ma_snd_pcm_format_mask_t         ma_snd_pcm_format_mask_t;
-typedef struct ma_snd_pcm_info_t                ma_snd_pcm_info_t;
-typedef struct
-{
-    void* addr;
-    unsigned int first;
-    unsigned int step;
-} ma_snd_pcm_channel_area_t;
-typedef struct
-{
-    unsigned int channels;
-    unsigned int pos[1];
-} ma_snd_pcm_chmap_t;
-
-/* snd_pcm_state_t */
-#define MA_SND_PCM_STATE_OPEN                  0
-#define MA_SND_PCM_STATE_SETUP                 1
-#define MA_SND_PCM_STATE_PREPARED              2
-#define MA_SND_PCM_STATE_RUNNING               3
-#define MA_SND_PCM_STATE_XRUN                  4
-#define MA_SND_PCM_STATE_DRAINING              5
-#define MA_SND_PCM_STATE_PAUSED                6
-#define MA_SND_PCM_STATE_SUSPENDED             7
-#define MA_SND_PCM_STATE_DISCONNECTED          8
-
-/* snd_pcm_stream_t */
-#define MA_SND_PCM_STREAM_PLAYBACK             0
-#define MA_SND_PCM_STREAM_CAPTURE              1
-
-/* snd_pcm_format_t */
-#define MA_SND_PCM_FORMAT_UNKNOWN              -1
-#define MA_SND_PCM_FORMAT_U8                   1
-#define MA_SND_PCM_FORMAT_S16_LE               2
-#define MA_SND_PCM_FORMAT_S16_BE               3
-#define MA_SND_PCM_FORMAT_S24_LE               6
-#define MA_SND_PCM_FORMAT_S24_BE               7
-#define MA_SND_PCM_FORMAT_S32_LE               10
-#define MA_SND_PCM_FORMAT_S32_BE               11
-#define MA_SND_PCM_FORMAT_FLOAT_LE             14
-#define MA_SND_PCM_FORMAT_FLOAT_BE             15
-#define MA_SND_PCM_FORMAT_FLOAT64_LE           16
-#define MA_SND_PCM_FORMAT_FLOAT64_BE           17
-#define MA_SND_PCM_FORMAT_MU_LAW               20
-#define MA_SND_PCM_FORMAT_A_LAW                21
-#define MA_SND_PCM_FORMAT_S24_3LE              32
-#define MA_SND_PCM_FORMAT_S24_3BE              33
-
-/* snd_pcm_access_t */
-#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED     0
-#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED  1
-#define MA_SND_PCM_ACCESS_MMAP_COMPLEX         2
-#define MA_SND_PCM_ACCESS_RW_INTERLEAVED       3
-#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED    4
-
-/* Channel positions. */
-#define MA_SND_CHMAP_UNKNOWN                   0
-#define MA_SND_CHMAP_NA                        1
-#define MA_SND_CHMAP_MONO                      2
-#define MA_SND_CHMAP_FL                        3
-#define MA_SND_CHMAP_FR                        4
-#define MA_SND_CHMAP_RL                        5
-#define MA_SND_CHMAP_RR                        6
-#define MA_SND_CHMAP_FC                        7
-#define MA_SND_CHMAP_LFE                       8
-#define MA_SND_CHMAP_SL                        9
-#define MA_SND_CHMAP_SR                        10
-#define MA_SND_CHMAP_RC                        11
-#define MA_SND_CHMAP_FLC                       12
-#define MA_SND_CHMAP_FRC                       13
-#define MA_SND_CHMAP_RLC                       14
-#define MA_SND_CHMAP_RRC                       15
-#define MA_SND_CHMAP_FLW                       16
-#define MA_SND_CHMAP_FRW                       17
-#define MA_SND_CHMAP_FLH                       18
-#define MA_SND_CHMAP_FCH                       19
-#define MA_SND_CHMAP_FRH                       20
-#define MA_SND_CHMAP_TC                        21
-#define MA_SND_CHMAP_TFL                       22
-#define MA_SND_CHMAP_TFR                       23
-#define MA_SND_CHMAP_TFC                       24
-#define MA_SND_CHMAP_TRL                       25
-#define MA_SND_CHMAP_TRR                       26
-#define MA_SND_CHMAP_TRC                       27
-#define MA_SND_CHMAP_TFLC                      28
-#define MA_SND_CHMAP_TFRC                      29
-#define MA_SND_CHMAP_TSL                       30
-#define MA_SND_CHMAP_TSR                       31
-#define MA_SND_CHMAP_LLFE                      32
-#define MA_SND_CHMAP_RLFE                      33
-#define MA_SND_CHMAP_BC                        34
-#define MA_SND_CHMAP_BLC                       35
-#define MA_SND_CHMAP_BRC                       36
-
-/* Open mode flags. */
-#define MA_SND_PCM_NO_AUTO_RESAMPLE            0x00010000
-#define MA_SND_PCM_NO_AUTO_CHANNELS            0x00020000
-#define MA_SND_PCM_NO_AUTO_FORMAT              0x00040000
-#endif
-
-typedef int                  (* ma_snd_pcm_open_proc)                          (ma_snd_pcm_t **pcm, const char *name, ma_snd_pcm_stream_t stream, int mode);
-typedef int                  (* ma_snd_pcm_close_proc)                         (ma_snd_pcm_t *pcm);
-typedef size_t               (* ma_snd_pcm_hw_params_sizeof_proc)              (void);
-typedef int                  (* ma_snd_pcm_hw_params_any_proc)                 (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params);
-typedef int                  (* ma_snd_pcm_hw_params_set_format_proc)          (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val);
-typedef int                  (* ma_snd_pcm_hw_params_set_format_first_proc)    (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format);
-typedef void                 (* ma_snd_pcm_hw_params_get_format_mask_proc)     (ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_mask_t *mask);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_proc)        (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_near_proc)   (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_set_channels_minmax_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *minimum, unsigned int *maximum);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_resample_proc)   (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_proc)            (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_rate_near_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_buffer_size_near_proc)(ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val);
-typedef int                  (* ma_snd_pcm_hw_params_set_periods_near_proc)    (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_set_access_proc)          (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t _access);
-typedef int                  (* ma_snd_pcm_hw_params_get_format_proc)          (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t *format);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_min_proc)    (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_channels_max_proc)    (const ma_snd_pcm_hw_params_t *params, unsigned int *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_proc)            (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_min_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_rate_max_proc)        (const ma_snd_pcm_hw_params_t *params, unsigned int *rate, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_buffer_size_proc)     (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_uframes_t *val);
-typedef int                  (* ma_snd_pcm_hw_params_get_periods_proc)         (const ma_snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
-typedef int                  (* ma_snd_pcm_hw_params_get_access_proc)          (const ma_snd_pcm_hw_params_t *params, ma_snd_pcm_access_t *_access);
-typedef int                  (* ma_snd_pcm_hw_params_test_format_proc)         (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, ma_snd_pcm_format_t val);
-typedef int                  (* ma_snd_pcm_hw_params_test_channels_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val);
-typedef int                  (* ma_snd_pcm_hw_params_test_rate_proc)           (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params, unsigned int val, int dir);
-typedef int                  (* ma_snd_pcm_hw_params_proc)                     (ma_snd_pcm_t *pcm, ma_snd_pcm_hw_params_t *params);
-typedef size_t               (* ma_snd_pcm_sw_params_sizeof_proc)              (void);
-typedef int                  (* ma_snd_pcm_sw_params_current_proc)             (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params);
-typedef int                  (* ma_snd_pcm_sw_params_get_boundary_proc)        (const ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t* val);
-typedef int                  (* ma_snd_pcm_sw_params_set_avail_min_proc)       (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_set_start_threshold_proc) (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_set_stop_threshold_proc)  (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params, ma_snd_pcm_uframes_t val);
-typedef int                  (* ma_snd_pcm_sw_params_proc)                     (ma_snd_pcm_t *pcm, ma_snd_pcm_sw_params_t *params);
-typedef size_t               (* ma_snd_pcm_format_mask_sizeof_proc)            (void);
-typedef int                  (* ma_snd_pcm_format_mask_test_proc)              (const ma_snd_pcm_format_mask_t *mask, ma_snd_pcm_format_t val);
-typedef ma_snd_pcm_chmap_t * (* ma_snd_pcm_get_chmap_proc)                     (ma_snd_pcm_t *pcm);
-typedef ma_snd_pcm_state_t   (* ma_snd_pcm_state_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_prepare_proc)                       (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_start_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_drop_proc)                          (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_drain_proc)                         (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_device_name_hint_proc)                  (int card, const char *iface, void ***hints);
-typedef char *               (* ma_snd_device_name_get_hint_proc)              (const void *hint, const char *id);
-typedef int                  (* ma_snd_card_get_index_proc)                    (const char *name);
-typedef int                  (* ma_snd_device_name_free_hint_proc)             (void **hints);
-typedef int                  (* ma_snd_pcm_mmap_begin_proc)                    (ma_snd_pcm_t *pcm, const ma_snd_pcm_channel_area_t **areas, ma_snd_pcm_uframes_t *offset, ma_snd_pcm_uframes_t *frames);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_mmap_commit_proc)                   (ma_snd_pcm_t *pcm, ma_snd_pcm_uframes_t offset, ma_snd_pcm_uframes_t frames);
-typedef int                  (* ma_snd_pcm_recover_proc)                       (ma_snd_pcm_t *pcm, int err, int silent);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_readi_proc)                         (ma_snd_pcm_t *pcm, void *buffer, ma_snd_pcm_uframes_t size);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_writei_proc)                        (ma_snd_pcm_t *pcm, const void *buffer, ma_snd_pcm_uframes_t size);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_proc)                         (ma_snd_pcm_t *pcm);
-typedef ma_snd_pcm_sframes_t (* ma_snd_pcm_avail_update_proc)                  (ma_snd_pcm_t *pcm);
-typedef int                  (* ma_snd_pcm_wait_proc)                          (ma_snd_pcm_t *pcm, int timeout);
-typedef int                  (* ma_snd_pcm_info_proc)                          (ma_snd_pcm_t *pcm, ma_snd_pcm_info_t* info);
-typedef size_t               (* ma_snd_pcm_info_sizeof_proc)                   (void);
-typedef const char*          (* ma_snd_pcm_info_get_name_proc)                 (const ma_snd_pcm_info_t* info);
-typedef int                  (* ma_snd_config_update_free_global_proc)         (void);
-
-/* This array specifies each of the common devices that can be used for both playback and capture. */
-static const char* g_maCommonDeviceNamesALSA[] = {
-    "default",
-    "null",
-    "pulse",
-    "jack"
-};
-
-/* This array allows us to blacklist specific playback devices. */
-static const char* g_maBlacklistedPlaybackDeviceNamesALSA[] = {
-    ""
-};
-
-/* This array allows us to blacklist specific capture devices. */
-static const char* g_maBlacklistedCaptureDeviceNamesALSA[] = {
-    ""
-};
-
-
-static ma_snd_pcm_format_t ma_convert_ma_format_to_alsa_format(ma_format format)
-{
-    ma_snd_pcm_format_t ALSAFormats[] = {
-        MA_SND_PCM_FORMAT_UNKNOWN,     /* ma_format_unknown */
-        MA_SND_PCM_FORMAT_U8,          /* ma_format_u8 */
-        MA_SND_PCM_FORMAT_S16_LE,      /* ma_format_s16 */
-        MA_SND_PCM_FORMAT_S24_3LE,     /* ma_format_s24 */
-        MA_SND_PCM_FORMAT_S32_LE,      /* ma_format_s32 */
-        MA_SND_PCM_FORMAT_FLOAT_LE     /* ma_format_f32 */
-    };
-
-    if (ma_is_big_endian()) {
-        ALSAFormats[0] = MA_SND_PCM_FORMAT_UNKNOWN;
-        ALSAFormats[1] = MA_SND_PCM_FORMAT_U8;
-        ALSAFormats[2] = MA_SND_PCM_FORMAT_S16_BE;
-        ALSAFormats[3] = MA_SND_PCM_FORMAT_S24_3BE;
-        ALSAFormats[4] = MA_SND_PCM_FORMAT_S32_BE;
-        ALSAFormats[5] = MA_SND_PCM_FORMAT_FLOAT_BE;
-    }
-
-    return ALSAFormats[format];
-}
-
-static ma_format ma_format_from_alsa(ma_snd_pcm_format_t formatALSA)
-{
-    if (ma_is_little_endian()) {
-        switch (formatALSA) {
-            case MA_SND_PCM_FORMAT_S16_LE:   return ma_format_s16;
-            case MA_SND_PCM_FORMAT_S24_3LE:  return ma_format_s24;
-            case MA_SND_PCM_FORMAT_S32_LE:   return ma_format_s32;
-            case MA_SND_PCM_FORMAT_FLOAT_LE: return ma_format_f32;
-            default: break;
-        }
-    } else {
-        switch (formatALSA) {
-            case MA_SND_PCM_FORMAT_S16_BE:   return ma_format_s16;
-            case MA_SND_PCM_FORMAT_S24_3BE:  return ma_format_s24;
-            case MA_SND_PCM_FORMAT_S32_BE:   return ma_format_s32;
-            case MA_SND_PCM_FORMAT_FLOAT_BE: return ma_format_f32;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (formatALSA) {
-        case MA_SND_PCM_FORMAT_U8: return ma_format_u8;
-        default: return ma_format_unknown;
-    }
-}
-
-static ma_channel ma_convert_alsa_channel_position_to_ma_channel(unsigned int alsaChannelPos)
-{
-    switch (alsaChannelPos)
-    {
-        case MA_SND_CHMAP_MONO: return MA_CHANNEL_MONO;
-        case MA_SND_CHMAP_FL:   return MA_CHANNEL_FRONT_LEFT;
-        case MA_SND_CHMAP_FR:   return MA_CHANNEL_FRONT_RIGHT;
-        case MA_SND_CHMAP_RL:   return MA_CHANNEL_BACK_LEFT;
-        case MA_SND_CHMAP_RR:   return MA_CHANNEL_BACK_RIGHT;
-        case MA_SND_CHMAP_FC:   return MA_CHANNEL_FRONT_CENTER;
-        case MA_SND_CHMAP_LFE:  return MA_CHANNEL_LFE;
-        case MA_SND_CHMAP_SL:   return MA_CHANNEL_SIDE_LEFT;
-        case MA_SND_CHMAP_SR:   return MA_CHANNEL_SIDE_RIGHT;
-        case MA_SND_CHMAP_RC:   return MA_CHANNEL_BACK_CENTER;
-        case MA_SND_CHMAP_FLC:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case MA_SND_CHMAP_FRC:  return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case MA_SND_CHMAP_RLC:  return 0;
-        case MA_SND_CHMAP_RRC:  return 0;
-        case MA_SND_CHMAP_FLW:  return 0;
-        case MA_SND_CHMAP_FRW:  return 0;
-        case MA_SND_CHMAP_FLH:  return 0;
-        case MA_SND_CHMAP_FCH:  return 0;
-        case MA_SND_CHMAP_FRH:  return 0;
-        case MA_SND_CHMAP_TC:   return MA_CHANNEL_TOP_CENTER;
-        case MA_SND_CHMAP_TFL:  return MA_CHANNEL_TOP_FRONT_LEFT;
-        case MA_SND_CHMAP_TFR:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case MA_SND_CHMAP_TFC:  return MA_CHANNEL_TOP_FRONT_CENTER;
-        case MA_SND_CHMAP_TRL:  return MA_CHANNEL_TOP_BACK_LEFT;
-        case MA_SND_CHMAP_TRR:  return MA_CHANNEL_TOP_BACK_RIGHT;
-        case MA_SND_CHMAP_TRC:  return MA_CHANNEL_TOP_BACK_CENTER;
-        default: break;
-    }
-
-    return 0;
-}
-
-static ma_bool32 ma_is_common_device_name__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maCommonDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maCommonDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-static ma_bool32 ma_is_playback_device_blacklisted__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maBlacklistedPlaybackDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maBlacklistedPlaybackDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-static ma_bool32 ma_is_capture_device_blacklisted__alsa(const char* name)
-{
-    size_t iName;
-    for (iName = 0; iName < ma_countof(g_maBlacklistedCaptureDeviceNamesALSA); ++iName) {
-        if (ma_strcmp(name, g_maBlacklistedCaptureDeviceNamesALSA[iName]) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-static ma_bool32 ma_is_device_blacklisted__alsa(ma_device_type deviceType, const char* name)
-{
-    if (deviceType == ma_device_type_playback) {
-        return ma_is_playback_device_blacklisted__alsa(name);
-    } else {
-        return ma_is_capture_device_blacklisted__alsa(name);
-    }
-}
-
-
-static const char* ma_find_char(const char* str, char c, int* index)
-{
-    int i = 0;
-    for (;;) {
-        if (str[i] == '\0') {
-            if (index) *index = -1;
-            return NULL;
-        }
-
-        if (str[i] == c) {
-            if (index) *index = i;
-            return str + i;
-        }
-
-        i += 1;
-    }
-
-    /* Should never get here, but treat it as though the character was not found to make me feel better inside. */
-    if (index) *index = -1;
-    return NULL;
-}
-
-static ma_bool32 ma_is_device_name_in_hw_format__alsa(const char* hwid)
-{
-    /* This function is just checking whether or not hwid is in "hw:%d,%d" format. */
-
-    int commaPos;
-    const char* dev;
-    int i;
-
-    if (hwid == NULL) {
-        return MA_FALSE;
-    }
-
-    if (hwid[0] != 'h' || hwid[1] != 'w' || hwid[2] != ':') {
-        return MA_FALSE;
-    }
-
-    hwid += 3;
-
-    dev = ma_find_char(hwid, ',', &commaPos);
-    if (dev == NULL) {
-        return MA_FALSE;
-    } else {
-        dev += 1;   /* Skip past the ",". */
-    }
-
-    /* Check if the part between the ":" and the "," contains only numbers. If not, return false. */
-    for (i = 0; i < commaPos; ++i) {
-        if (hwid[i] < '0' || hwid[i] > '9') {
-            return MA_FALSE;
-        }
-    }
-
-    /* Check if everything after the "," is numeric. If not, return false. */
-    i = 0;
-    while (dev[i] != '\0') {
-        if (dev[i] < '0' || dev[i] > '9') {
-            return MA_FALSE;
-        }
-        i += 1;
-    }
-
-    return MA_TRUE;
-}
-
-static int ma_convert_device_name_to_hw_format__alsa(ma_context* pContext, char* dst, size_t dstSize, const char* src)  /* Returns 0 on success, non-0 on error. */
-{
-    /* src should look something like this: "hw:CARD=I82801AAICH,DEV=0" */
-
-    int colonPos;
-    int commaPos;
-    char card[256];
-    const char* dev;
-    int cardIndex;
-
-    if (dst == NULL) {
-        return -1;
-    }
-    if (dstSize < 7) {
-        return -1;     /* Absolute minimum size of the output buffer is 7 bytes. */
-    }
-
-    *dst = '\0';    /* Safety. */
-    if (src == NULL) {
-        return -1;
-    }
-
-    /* If the input name is already in "hw:%d,%d" format, just return that verbatim. */
-    if (ma_is_device_name_in_hw_format__alsa(src)) {
-        return ma_strcpy_s(dst, dstSize, src);
-    }
-
-    src = ma_find_char(src, ':', &colonPos);
-    if (src == NULL) {
-        return -1;  /* Couldn't find a colon */
-    }
-
-    dev = ma_find_char(src, ',', &commaPos);
-    if (dev == NULL) {
-        dev = "0";
-        ma_strncpy_s(card, sizeof(card), src+6, (size_t)-1);   /* +6 = ":CARD=" */
-    } else {
-        dev = dev + 5;  /* +5 = ",DEV=" */
-        ma_strncpy_s(card, sizeof(card), src+6, commaPos-6);   /* +6 = ":CARD=" */
-    }
-
-    cardIndex = ((ma_snd_card_get_index_proc)pContext->alsa.snd_card_get_index)(card);
-    if (cardIndex < 0) {
-        return -2;  /* Failed to retrieve the card index. */
-    }
-
-    /*printf("TESTING: CARD=%s,DEV=%s\n", card, dev); */
-
-
-    /* Construction. */
-    dst[0] = 'h'; dst[1] = 'w'; dst[2] = ':';
-    if (ma_itoa_s(cardIndex, dst+3, dstSize-3, 10) != 0) {
-        return -3;
-    }
-    if (ma_strcat_s(dst, dstSize, ",") != 0) {
-        return -3;
-    }
-    if (ma_strcat_s(dst, dstSize, dev) != 0) {
-        return -3;
-    }
-
-    return 0;
-}
-
-static ma_bool32 ma_does_id_exist_in_list__alsa(ma_device_id* pUniqueIDs, ma_uint32 count, const char* pHWID)
-{
-    ma_uint32 i;
-
-    MA_ASSERT(pHWID != NULL);
-
-    for (i = 0; i < count; ++i) {
-        if (ma_strcmp(pUniqueIDs[i].alsa, pHWID) == 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-static ma_result ma_context_open_pcm__alsa(ma_context* pContext, ma_share_mode shareMode, ma_device_type deviceType, const ma_device_id* pDeviceID, int openMode, ma_snd_pcm_t** ppPCM)
-{
-    ma_snd_pcm_t* pPCM;
-    ma_snd_pcm_stream_t stream;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppPCM != NULL);
-
-    *ppPCM = NULL;
-    pPCM = NULL;
-
-    stream = (deviceType == ma_device_type_playback) ? MA_SND_PCM_STREAM_PLAYBACK : MA_SND_PCM_STREAM_CAPTURE;
-
-    if (pDeviceID == NULL) {
-        ma_bool32 isDeviceOpen;
-        size_t i;
-
-        /*
-        We're opening the default device. I don't know if trying anything other than "default" is necessary, but it makes
-        me feel better to try as hard as we can get to get _something_ working.
-        */
-        const char* defaultDeviceNames[] = {
-            "default",
-            NULL,
-            NULL,
-            NULL,
-            NULL,
-            NULL,
-            NULL
-        };
-
-        if (shareMode == ma_share_mode_exclusive) {
-            defaultDeviceNames[1] = "hw";
-            defaultDeviceNames[2] = "hw:0";
-            defaultDeviceNames[3] = "hw:0,0";
-        } else {
-            if (deviceType == ma_device_type_playback) {
-                defaultDeviceNames[1] = "dmix";
-                defaultDeviceNames[2] = "dmix:0";
-                defaultDeviceNames[3] = "dmix:0,0";
-            } else {
-                defaultDeviceNames[1] = "dsnoop";
-                defaultDeviceNames[2] = "dsnoop:0";
-                defaultDeviceNames[3] = "dsnoop:0,0";
-            }
-            defaultDeviceNames[4] = "hw";
-            defaultDeviceNames[5] = "hw:0";
-            defaultDeviceNames[6] = "hw:0,0";
-        }
-
-        isDeviceOpen = MA_FALSE;
-        for (i = 0; i < ma_countof(defaultDeviceNames); ++i) {
-            if (defaultDeviceNames[i] != NULL && defaultDeviceNames[i][0] != '\0') {
-                if (((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, defaultDeviceNames[i], stream, openMode) == 0) {
-                    isDeviceOpen = MA_TRUE;
-                    break;
-                }
-            }
-        }
-
-        if (!isDeviceOpen) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed when trying to open an appropriate default device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-    } else {
-        /*
-        We're trying to open a specific device. There's a few things to consider here:
-
-        miniaudio recongnizes a special format of device id that excludes the "hw", "dmix", etc. prefix. It looks like this: ":0,0", ":0,1", etc. When
-        an ID of this format is specified, it indicates to miniaudio that it can try different combinations of plugins ("hw", "dmix", etc.) until it
-        finds an appropriate one that works. This comes in very handy when trying to open a device in shared mode ("dmix"), vs exclusive mode ("hw").
-        */
-
-        /* May end up needing to make small adjustments to the ID, so make a copy. */
-        ma_device_id deviceID = *pDeviceID;
-        int resultALSA = -ENODEV;
-
-        if (deviceID.alsa[0] != ':') {
-            /* The ID is not in ":0,0" format. Use the ID exactly as-is. */
-            resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, deviceID.alsa, stream, openMode);
-        } else {
-            char hwid[256];
-
-            /* The ID is in ":0,0" format. Try different plugins depending on the shared mode. */
-            if (deviceID.alsa[1] == '\0') {
-                deviceID.alsa[0] = '\0';  /* An ID of ":" should be converted to "". */
-            }
-
-            if (shareMode == ma_share_mode_shared) {
-                if (deviceType == ma_device_type_playback) {
-                    ma_strcpy_s(hwid, sizeof(hwid), "dmix");
-                } else {
-                    ma_strcpy_s(hwid, sizeof(hwid), "dsnoop");
-                }
-
-                if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) {
-                    resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode);
-                }
-            }
-
-            /* If at this point we still don't have an open device it means we're either preferencing exclusive mode or opening with "dmix"/"dsnoop" failed. */
-            if (resultALSA != 0) {
-                ma_strcpy_s(hwid, sizeof(hwid), "hw");
-                if (ma_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) {
-                    resultALSA = ((ma_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode);
-                }
-            }
-        }
-
-        if (resultALSA < 0) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    *ppPCM = pPCM;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__alsa(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    int resultALSA;
-    ma_bool32 cbResult = MA_TRUE;
-    char** ppDeviceHints;
-    ma_device_id* pUniqueIDs = NULL;
-    ma_uint32 uniqueIDCount = 0;
-    char** ppNextDeviceHint;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    ma_mutex_lock(&pContext->alsa.internalDeviceEnumLock);
-
-    resultALSA = ((ma_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints);
-    if (resultALSA < 0) {
-        ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
-        return ma_result_from_errno(-resultALSA);
-    }
-
-    ppNextDeviceHint = ppDeviceHints;
-    while (*ppNextDeviceHint != NULL) {
-        char* NAME = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "NAME");
-        char* DESC = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "DESC");
-        char* IOID = ((ma_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "IOID");
-        ma_device_type deviceType = ma_device_type_playback;
-        ma_bool32 stopEnumeration = MA_FALSE;
-        char hwid[sizeof(pUniqueIDs->alsa)];
-        ma_device_info deviceInfo;
-
-        if ((IOID == NULL || ma_strcmp(IOID, "Output") == 0)) {
-            deviceType = ma_device_type_playback;
-        }
-        if ((IOID != NULL && ma_strcmp(IOID, "Input" ) == 0)) {
-            deviceType = ma_device_type_capture;
-        }
-
-        if (NAME != NULL) {
-            if (pContext->alsa.useVerboseDeviceEnumeration) {
-                /* Verbose mode. Use the name exactly as-is. */
-                ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1);
-            } else {
-                /* Simplified mode. Use ":%d,%d" format. */
-                if (ma_convert_device_name_to_hw_format__alsa(pContext, hwid, sizeof(hwid), NAME) == 0) {
-                    /*
-                    At this point, hwid looks like "hw:0,0". In simplified enumeration mode, we actually want to strip off the
-                    plugin name so it looks like ":0,0". The reason for this is that this special format is detected at device
-                    initialization time and is used as an indicator to try and use the most appropriate plugin depending on the
-                    device type and sharing mode.
-                    */
-                    char* dst = hwid;
-                    char* src = hwid+2;
-                    while ((*dst++ = *src++));
-                } else {
-                    /* Conversion to "hw:%d,%d" failed. Just use the name as-is. */
-                    ma_strncpy_s(hwid, sizeof(hwid), NAME, (size_t)-1);
-                }
-
-                if (ma_does_id_exist_in_list__alsa(pUniqueIDs, uniqueIDCount, hwid)) {
-                    goto next_device;   /* The device has already been enumerated. Move on to the next one. */
-                } else {
-                    /* The device has not yet been enumerated. Make sure it's added to our list so that it's not enumerated again. */
-                    size_t oldCapacity = sizeof(*pUniqueIDs) *  uniqueIDCount;
-                    size_t newCapacity = sizeof(*pUniqueIDs) * (uniqueIDCount + 1);
-                    ma_device_id* pNewUniqueIDs = (ma_device_id*)ma__realloc_from_callbacks(pUniqueIDs, newCapacity, oldCapacity, &pContext->allocationCallbacks);
-                    if (pNewUniqueIDs == NULL) {
-                        goto next_device;   /* Failed to allocate memory. */
-                    }
-
-                    pUniqueIDs = pNewUniqueIDs;
-                    MA_COPY_MEMORY(pUniqueIDs[uniqueIDCount].alsa, hwid, sizeof(hwid));
-                    uniqueIDCount += 1;
-                }
-            }
-        } else {
-            MA_ZERO_MEMORY(hwid, sizeof(hwid));
-        }
-
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.id.alsa, sizeof(deviceInfo.id.alsa), hwid, (size_t)-1);
-
-        /*
-        There's no good way to determine whether or not a device is the default on Linux. We're just going to do something simple and
-        just use the name of "default" as the indicator.
-        */
-        if (ma_strcmp(deviceInfo.id.alsa, "default") == 0) {
-            deviceInfo.isDefault = MA_TRUE;
-        }
-
-
-        /*
-        DESC is the friendly name. We treat this slightly differently depending on whether or not we are using verbose
-        device enumeration. In verbose mode we want to take the entire description so that the end-user can distinguish
-        between the subdevices of each card/dev pair. In simplified mode, however, we only want the first part of the
-        description.
-
-        The value in DESC seems to be split into two lines, with the first line being the name of the device and the
-        second line being a description of the device. I don't like having the description be across two lines because
-        it makes formatting ugly and annoying. I'm therefore deciding to put it all on a single line with the second line
-        being put into parentheses. In simplified mode I'm just stripping the second line entirely.
-        */
-        if (DESC != NULL) {
-            int lfPos;
-            const char* line2 = ma_find_char(DESC, '\n', &lfPos);
-            if (line2 != NULL) {
-                line2 += 1; /* Skip past the new-line character. */
-
-                if (pContext->alsa.useVerboseDeviceEnumeration) {
-                    /* Verbose mode. Put the second line in brackets. */
-                    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos);
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), " (");
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), line2);
-                    ma_strcat_s (deviceInfo.name, sizeof(deviceInfo.name), ")");
-                } else {
-                    /* Simplified mode. Strip the second line entirely. */
-                    ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, lfPos);
-                }
-            } else {
-                /* There's no second line. Just copy the whole description. */
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), DESC, (size_t)-1);
-            }
-        }
-
-        if (!ma_is_device_blacklisted__alsa(deviceType, NAME)) {
-            cbResult = callback(pContext, deviceType, &deviceInfo, pUserData);
-        }
-
-        /*
-        Some devices are both playback and capture, but they are only enumerated by ALSA once. We need to fire the callback
-        again for the other device type in this case. We do this for known devices.
-        */
-        if (cbResult) {
-            if (ma_is_common_device_name__alsa(NAME)) {
-                if (deviceType == ma_device_type_playback) {
-                    if (!ma_is_capture_device_blacklisted__alsa(NAME)) {
-                        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                    }
-                } else {
-                    if (!ma_is_playback_device_blacklisted__alsa(NAME)) {
-                        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                    }
-                }
-            }
-        }
-
-        if (cbResult == MA_FALSE) {
-            stopEnumeration = MA_TRUE;
-        }
-
-    next_device:
-        free(NAME);
-        free(DESC);
-        free(IOID);
-        ppNextDeviceHint += 1;
-
-        /* We need to stop enumeration if the callback returned false. */
-        if (stopEnumeration) {
-            break;
-        }
-    }
-
-    ma__free_from_callbacks(pUniqueIDs, &pContext->allocationCallbacks);
-    ((ma_snd_device_name_free_hint_proc)pContext->alsa.snd_device_name_free_hint)((void**)ppDeviceHints);
-
-    ma_mutex_unlock(&pContext->alsa.internalDeviceEnumLock);
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_device_type deviceType;
-    const ma_device_id* pDeviceID;
-    ma_share_mode shareMode;
-    ma_device_info* pDeviceInfo;
-    ma_bool32 foundDevice;
-} ma_context_get_device_info_enum_callback_data__alsa;
-
-static ma_bool32 ma_context_get_device_info_enum_callback__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pDeviceInfo, void* pUserData)
-{
-    ma_context_get_device_info_enum_callback_data__alsa* pData = (ma_context_get_device_info_enum_callback_data__alsa*)pUserData;
-    MA_ASSERT(pData != NULL);
-
-    (void)pContext;
-
-    if (pData->pDeviceID == NULL && ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1);
-        pData->foundDevice = MA_TRUE;
-    } else {
-        if (pData->deviceType == deviceType && (pData->pDeviceID != NULL && ma_strcmp(pData->pDeviceID->alsa, pDeviceInfo->id.alsa) == 0)) {
-            ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1);
-            pData->foundDevice = MA_TRUE;
-        }
-    }
-
-    /* Keep enumerating until we have found the device. */
-    return !pData->foundDevice;
-}
-
-static void ma_context_test_rate_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pPCM        != NULL);
-    MA_ASSERT(pHWParams   != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    if (pDeviceInfo->nativeDataFormatCount < ma_countof(pDeviceInfo->nativeDataFormats) && ((ma_snd_pcm_hw_params_test_rate_proc)pContext->alsa.snd_pcm_hw_params_test_rate)(pPCM, pHWParams, sampleRate, 0) == 0) {
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-        pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-        pDeviceInfo->nativeDataFormatCount += 1;
-    }
-}
-
-static void ma_context_iterate_rates_and_add_native_data_format__alsa(ma_context* pContext, ma_snd_pcm_t* pPCM, ma_snd_pcm_hw_params_t* pHWParams, ma_format format, ma_uint32 channels, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    ma_uint32 iSampleRate;
-    unsigned int minSampleRate;
-    unsigned int maxSampleRate;
-    int sampleRateDir;  /* Not used. Just passed into snd_pcm_hw_params_get_rate_min/max(). */
-
-    /* There could be a range. */
-    ((ma_snd_pcm_hw_params_get_rate_min_proc)pContext->alsa.snd_pcm_hw_params_get_rate_min)(pHWParams, &minSampleRate, &sampleRateDir);
-    ((ma_snd_pcm_hw_params_get_rate_max_proc)pContext->alsa.snd_pcm_hw_params_get_rate_max)(pHWParams, &maxSampleRate, &sampleRateDir);
-
-    /* Make sure our sample rates are clamped to sane values. Stupid devices like "pulse" will reports rates like "1" which is ridiculus. */
-    minSampleRate = ma_clamp(minSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max);
-    maxSampleRate = ma_clamp(maxSampleRate, (unsigned int)ma_standard_sample_rate_min, (unsigned int)ma_standard_sample_rate_max);
-
-    for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) {
-        ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate];
-
-        if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) {
-            ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, standardSampleRate, flags, pDeviceInfo);
-        }
-    }
-
-    /* Now make sure our min and max rates are included just in case they aren't in the range of our standard rates. */
-    if (!ma_is_standard_sample_rate(minSampleRate)) {
-        ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, minSampleRate, flags, pDeviceInfo);
-    }
-
-    if (!ma_is_standard_sample_rate(maxSampleRate) && maxSampleRate != minSampleRate) {
-        ma_context_test_rate_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, maxSampleRate, flags, pDeviceInfo);
-    }
-}
-
-static ma_result ma_context_get_device_info__alsa(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_context_get_device_info_enum_callback_data__alsa data;
-    ma_result result;
-    int resultALSA;
-    ma_snd_pcm_t* pPCM;
-    ma_snd_pcm_hw_params_t* pHWParams;
-    ma_uint32 iFormat;
-    ma_uint32 iChannel;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* We just enumerate to find basic information about the device. */
-    data.deviceType  = deviceType;
-    data.pDeviceID   = pDeviceID;
-    data.pDeviceInfo = pDeviceInfo;
-    data.foundDevice = MA_FALSE;
-    result = ma_context_enumerate_devices__alsa(pContext, ma_context_get_device_info_enum_callback__alsa, &data);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (!data.foundDevice) {
-        return MA_NO_DEVICE;
-    }
-
-    if (ma_strcmp(pDeviceInfo->id.alsa, "default") == 0) {
-        pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    /* For detailed info we need to open the device. */
-    result = ma_context_open_pcm__alsa(pContext, ma_share_mode_shared, deviceType, pDeviceID, 0, &pPCM);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* We need to initialize a HW parameters object in order to know what formats are supported. */
-    pHWParams = (ma_snd_pcm_hw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_hw_params_sizeof_proc)pContext->alsa.snd_pcm_hw_params_sizeof)(), &pContext->allocationCallbacks);
-    if (pHWParams == NULL) {
-        ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    /*
-    Some ALSA devices can support many permutations of formats, channels and rates. We only support
-    a fixed number of permutations which means we need to employ some strategies to ensure the best
-    combinations are returned. An example is the "pulse" device which can do it's own data conversion
-    in software and as a result can support any combination of format, channels and rate.
-
-    We want to ensure the the first data formats are the best. We have a list of favored sample
-    formats and sample rates, so these will be the basis of our iteration.
-    */
-    
-    /* Formats. We just iterate over our standard formats and test them, making sure we reset the configuration space each iteration. */
-    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) {
-        ma_format format = g_maFormatPriorities[iFormat];
-
-        /*
-        For each format we need to make sure we reset the configuration space so we don't return
-        channel counts and rates that aren't compatible with a format.
-        */
-        ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-
-        /* Test the format first. If this fails it means the format is not supported and we can skip it. */
-        if (((ma_snd_pcm_hw_params_test_format_proc)pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format)) == 0) {
-            /* The format is supported. */
-            unsigned int minChannels;
-            unsigned int maxChannels;
-
-            /*
-            The configuration space needs to be restricted to this format so we can get an accurate
-            picture of which sample rates and channel counts are support with this format.
-            */
-            ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format));
-
-            /* Now we need to check for supported channels. */
-            ((ma_snd_pcm_hw_params_get_channels_min_proc)pContext->alsa.snd_pcm_hw_params_get_channels_min)(pHWParams, &minChannels);
-            ((ma_snd_pcm_hw_params_get_channels_max_proc)pContext->alsa.snd_pcm_hw_params_get_channels_max)(pHWParams, &maxChannels);
-
-            if (minChannels > MA_MAX_CHANNELS) {
-                continue;   /* Too many channels. */
-            }
-            if (maxChannels < MA_MIN_CHANNELS) {
-                continue;   /* Not enough channels. */
-            }
-
-            /*
-            Make sure the channel count is clamped. This is mainly intended for the max channels
-            because some devices can report an unbound maximum.
-            */
-            minChannels = ma_clamp(minChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-            maxChannels = ma_clamp(maxChannels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-
-            if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                /* The device supports all channels. Don't iterate over every single one. Instead just set the channels to 0 which means all channels are supported. */
-                ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, 0, 0, pDeviceInfo);    /* Intentionally setting the channel count to 0 as that means all channels are supported. */
-            } else {
-                /* The device only supports a specific set of channels. We need to iterate over all of them. */
-                for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                    /* Test the channel before applying it to the configuration space. */
-                    unsigned int channels = iChannel;
-
-                    /* Make sure our channel range is reset before testing again or else we'll always fail the test. */
-                    ((ma_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-                    ((ma_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(format));
-
-                    if (((ma_snd_pcm_hw_params_test_channels_proc)pContext->alsa.snd_pcm_hw_params_test_channels)(pPCM, pHWParams, channels) == 0) {
-                        /* The channel count is supported. */
-
-                        /* The configuration space now needs to be restricted to the channel count before extracting the sample rate. */
-                        ((ma_snd_pcm_hw_params_set_channels_proc)pContext->alsa.snd_pcm_hw_params_set_channels)(pPCM, pHWParams, channels);
-
-                        /* Only after the configuration space has been restricted to the specific channel count should we iterate over our sample rates. */
-                        ma_context_iterate_rates_and_add_native_data_format__alsa(pContext, pPCM, pHWParams, format, channels, 0, pDeviceInfo);
-                    } else {
-                        /* The channel count is not supported. Skip. */
-                    }
-                }
-            }
-        } else {
-            /* The format is not supported. Skip. */
-        }
-    }
-
-    ma__free_from_callbacks(pHWParams, &pContext->allocationCallbacks);
-
-    ((ma_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__alsa(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if ((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-    }
-
-    if ((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_by_type__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    ma_result result;
-    int resultALSA;
-    ma_snd_pcm_t* pPCM;
-    ma_bool32 isUsingMMap;
-    ma_snd_pcm_format_t formatALSA;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_channel internalChannelMap[MA_MAX_CHANNELS];
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-    int openMode;
-    ma_snd_pcm_hw_params_t* pHWParams;
-    ma_snd_pcm_sw_params_t* pSWParams;
-    ma_snd_pcm_uframes_t bufferBoundary;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex); /* This function should only be called for playback _or_ capture, never duplex. */
-    MA_ASSERT(pDevice != NULL);
-
-    formatALSA = ma_convert_ma_format_to_alsa_format(pDescriptor->format);
-
-    openMode = 0;
-    if (pConfig->alsa.noAutoResample) {
-        openMode |= MA_SND_PCM_NO_AUTO_RESAMPLE;
-    }
-    if (pConfig->alsa.noAutoChannels) {
-        openMode |= MA_SND_PCM_NO_AUTO_CHANNELS;
-    }
-    if (pConfig->alsa.noAutoFormat) {
-        openMode |= MA_SND_PCM_NO_AUTO_FORMAT;
-    }
-
-    result = ma_context_open_pcm__alsa(pDevice->pContext, pDescriptor->shareMode, deviceType, pDescriptor->pDeviceID, openMode, &pPCM);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-
-    /* Hardware parameters. */
-    pHWParams = (ma_snd_pcm_hw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_hw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_hw_params_sizeof)(), &pDevice->pContext->allocationCallbacks);
-    if (pHWParams == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_hw_params_any_proc)pDevice->pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    /* MMAP Mode. Try using interleaved MMAP access. If this fails, fall back to standard readi/writei. */
-    isUsingMMap = MA_FALSE;
-#if 0   /* NOTE: MMAP mode temporarily disabled. */
-    if (deviceType != ma_device_type_capture) {    /* <-- Disabling MMAP mode for capture devices because I apparently do not have a device that supports it which means I can't test it... Contributions welcome. */
-        if (!pConfig->alsa.noMMap && ma_device__is_async(pDevice)) {
-            if (((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) {
-                pDevice->alsa.isUsingMMap = MA_TRUE;
-            }
-        }
-    }
-#endif
-
-    if (!isUsingMMap) {
-        resultALSA = ((ma_snd_pcm_hw_params_set_access_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_RW_INTERLEAVED);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    /*
-    Most important properties first. The documentation for OSS (yes, I know this is ALSA!) recommends format, channels, then sample rate. I can't
-    find any documentation for ALSA specifically, so I'm going to copy the recommendation for OSS.
-    */
-
-    /* Format. */
-    {
-        /*
-        At this point we should have a list of supported formats, so now we need to find the best one. We first check if the requested format is
-        supported, and if so, use that one. If it's not supported, we just run though a list of formats and try to find the best one.
-        */
-        if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN || ((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, formatALSA) != 0) {
-            /* We're either requesting the native format or the specified format is not supported. */
-            size_t iFormat;
-
-            formatALSA = MA_SND_PCM_FORMAT_UNKNOWN;
-            for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); ++iFormat) {
-                if (((ma_snd_pcm_hw_params_test_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_test_format)(pPCM, pHWParams, ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat])) == 0) {
-                    formatALSA = ma_convert_ma_format_to_alsa_format(g_maFormatPriorities[iFormat]);
-                    break;
-                }
-            }
-
-            if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN) {
-                ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-                ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. The device does not support any miniaudio formats.", MA_FORMAT_NOT_SUPPORTED);
-            }
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_format_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, formatALSA);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. snd_pcm_hw_params_set_format() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalFormat = ma_format_from_alsa(formatALSA);
-        if (internalFormat == ma_format_unknown) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] The chosen format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED);
-        }
-    }
-
-    /* Channels. */
-    {
-        unsigned int channels = pDescriptor->channels;
-        if (channels == 0) {
-            channels = MA_DEFAULT_CHANNELS;
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_channels_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_channels_near)(pPCM, pHWParams, &channels);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set channel count. snd_pcm_hw_params_set_channels_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalChannels = (ma_uint32)channels;
-    }
-
-    /* Sample Rate */
-    {
-        unsigned int sampleRate;
-
-        /*
-        It appears there's either a bug in ALSA, a bug in some drivers, or I'm doing something silly; but having resampling enabled causes
-        problems with some device configurations when used in conjunction with MMAP access mode. To fix this problem we need to disable
-        resampling.
-
-        To reproduce this problem, open the "plug:dmix" device, and set the sample rate to 44100. Internally, it looks like dmix uses a
-        sample rate of 48000. The hardware parameters will get set correctly with no errors, but it looks like the 44100 -> 48000 resampling
-        doesn't work properly - but only with MMAP access mode. You will notice skipping/crackling in the audio, and it'll run at a slightly
-        faster rate.
-
-        miniaudio has built-in support for sample rate conversion (albeit low quality at the moment), so disabling resampling should be fine
-        for us. The only problem is that it won't be taking advantage of any kind of hardware-accelerated resampling and it won't be very
-        good quality until I get a chance to improve the quality of miniaudio's software sample rate conversion.
-
-        I don't currently know if the dmix plugin is the only one with this error. Indeed, this is the only one I've been able to reproduce
-        this error with. In the future, we may want to restrict the disabling of resampling to only known bad plugins.
-        */
-        ((ma_snd_pcm_hw_params_set_rate_resample_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_resample)(pPCM, pHWParams, 0);
-
-        sampleRate = pDescriptor->sampleRate;
-        if (sampleRate == 0) {
-            sampleRate = MA_DEFAULT_SAMPLE_RATE;
-        }
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_rate_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_rate_near)(pPCM, pHWParams, &sampleRate, 0);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Sample rate not supported. snd_pcm_hw_params_set_rate_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalSampleRate = (ma_uint32)sampleRate;
-    }
-
-    /* Periods. */
-    {
-        ma_uint32 periods = pDescriptor->periodCount;
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_periods_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, NULL);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set period count. snd_pcm_hw_params_set_periods_near() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalPeriods = periods;
-    }
-
-    /* Buffer Size */
-    {
-        ma_snd_pcm_uframes_t actualBufferSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile) * internalPeriods;
-
-        resultALSA = ((ma_snd_pcm_hw_params_set_buffer_size_near_proc)pDevice->pContext->alsa.snd_pcm_hw_params_set_buffer_size_near)(pPCM, pHWParams, &actualBufferSizeInFrames);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set buffer size for device. snd_pcm_hw_params_set_buffer_size() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        internalPeriodSizeInFrames = actualBufferSizeInFrames / internalPeriods;
-    }
-
-    /* Apply hardware parameters. */
-    resultALSA = ((ma_snd_pcm_hw_params_proc)pDevice->pContext->alsa.snd_pcm_hw_params)(pPCM, pHWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    ma__free_from_callbacks(pHWParams, &pDevice->pContext->allocationCallbacks);
-    pHWParams = NULL;
-
-
-    /* Software parameters. */
-    pSWParams = (ma_snd_pcm_sw_params_t*)ma__calloc_from_callbacks(((ma_snd_pcm_sw_params_sizeof_proc)pDevice->pContext->alsa.snd_pcm_sw_params_sizeof)(), &pDevice->pContext->allocationCallbacks);
-    if (pSWParams == NULL) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_current_proc)pDevice->pContext->alsa.snd_pcm_sw_params_current)(pPCM, pSWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize software parameters. snd_pcm_sw_params_current() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_set_avail_min_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_avail_min)(pPCM, pSWParams, ma_prev_power_of_2(internalPeriodSizeInFrames));
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_get_boundary_proc)pDevice->pContext->alsa.snd_pcm_sw_params_get_boundary)(pSWParams, &bufferBoundary);
-    if (resultALSA < 0) {
-        bufferBoundary = internalPeriodSizeInFrames * internalPeriods;
-    }
-
-    /*printf("TRACE: bufferBoundary=%ld\n", bufferBoundary);*/
-
-    if (deviceType == ma_device_type_playback && !isUsingMMap) {   /* Only playback devices in writei/readi mode need a start threshold. */
-        /*
-        Subtle detail here with the start threshold. When in playback-only mode (no full-duplex) we can set the start threshold to
-        the size of a period. But for full-duplex we need to set it such that it is at least two periods.
-        */
-        resultALSA = ((ma_snd_pcm_sw_params_set_start_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_start_threshold)(pPCM, pSWParams, internalPeriodSizeInFrames*2);
-        if (resultALSA < 0) {
-            ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.", ma_result_from_errno(-resultALSA));
-        }
-
-        resultALSA = ((ma_snd_pcm_sw_params_set_stop_threshold_proc)pDevice->pContext->alsa.snd_pcm_sw_params_set_stop_threshold)(pPCM, pSWParams, bufferBoundary);
-        if (resultALSA < 0) { /* Set to boundary to loop instead of stop in the event of an xrun. */
-            ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-            ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set stop threshold for playback device. snd_pcm_sw_params_set_stop_threshold() failed.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    resultALSA = ((ma_snd_pcm_sw_params_proc)pDevice->pContext->alsa.snd_pcm_sw_params)(pPCM, pSWParams);
-    if (resultALSA < 0) {
-        ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", ma_result_from_errno(-resultALSA));
-    }
-
-    ma__free_from_callbacks(pSWParams, &pDevice->pContext->allocationCallbacks);
-    pSWParams = NULL;
-
-
-    /* Grab the internal channel map. For now we're not going to bother trying to change the channel map and instead just do it ourselves. */
-    {
-        ma_snd_pcm_chmap_t* pChmap = ((ma_snd_pcm_get_chmap_proc)pDevice->pContext->alsa.snd_pcm_get_chmap)(pPCM);
-        if (pChmap != NULL) {
-            ma_uint32 iChannel;
-
-            /* There are cases where the returned channel map can have a different channel count than was returned by snd_pcm_hw_params_set_channels_near(). */
-            if (pChmap->channels >= internalChannels) {
-                /* Drop excess channels. */
-                for (iChannel = 0; iChannel < internalChannels; ++iChannel) {
-                    internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]);
-                }
-            } else {
-                ma_uint32 i;
-
-                /*
-                Excess channels use defaults. Do an initial fill with defaults, overwrite the first pChmap->channels, validate to ensure there are no duplicate
-                channels. If validation fails, fall back to defaults.
-                */
-                ma_bool32 isValid = MA_TRUE;
-
-                /* Fill with defaults. */
-                ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-
-                /* Overwrite first pChmap->channels channels. */
-                for (iChannel = 0; iChannel < pChmap->channels; ++iChannel) {
-                    internalChannelMap[iChannel] = ma_convert_alsa_channel_position_to_ma_channel(pChmap->pos[iChannel]);
-                }
-
-                /* Validate. */
-                for (i = 0; i < internalChannels && isValid; ++i) {
-                    ma_uint32 j;
-                    for (j = i+1; j < internalChannels; ++j) {
-                        if (internalChannelMap[i] == internalChannelMap[j]) {
-                            isValid = MA_FALSE;
-                            break;
-                        }
-                    }
-                }
-
-                /* If our channel map is invalid, fall back to defaults. */
-                if (!isValid) {
-                    ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-                }
-            }
-
-            free(pChmap);
-            pChmap = NULL;
-        } else {
-            /* Could not retrieve the channel map. Fall back to a hard-coded assumption. */
-            ma_get_standard_channel_map(ma_standard_channel_map_alsa, internalChannels, internalChannelMap);
-        }
-    }
-
-
-    /* We're done. Prepare the device. */
-    resultALSA = ((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)(pPCM);
-    if (resultALSA < 0) {
-        ((ma_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", ma_result_from_errno(-resultALSA));
-    }
-
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->alsa.pPCMCapture         = (ma_ptr)pPCM;
-        pDevice->alsa.isUsingMMapCapture  = isUsingMMap;
-    } else {
-        pDevice->alsa.pPCMPlayback        = (ma_ptr)pPCM;
-        pDevice->alsa.isUsingMMapPlayback = isUsingMMap;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_channel_map_copy(pDescriptor->channelMap, internalChannelMap, ma_min(internalChannels, MA_MAX_CHANNELS));
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-    /*printf("format=%d; channels=%d; sampleRate=%d; periodSizeInFrames=%d; periodCount=%d\n", internalFormat, internalChannels, internalSampleRate, internalPeriodSizeInFrames, internalPeriods);*/
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__alsa(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->alsa);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_by_type__alsa(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__alsa(ma_device* pDevice)
-{
-    int resultALSA;
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-        if (resultALSA < 0) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", ma_result_from_errno(-resultALSA));
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* Don't need to do anything for playback because it'll be started automatically when enough data has been written. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__alsa(ma_device* pDevice)
-{
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_snd_pcm_drain_proc)pDevice->pContext->alsa.snd_pcm_drain)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-
-        /* We need to prepare the device again, otherwise we won't be able to restart the device. */
-        if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture) < 0) {
-    #ifdef MA_DEBUG_OUTPUT
-            printf("[ALSA] Failed to prepare capture device after stopping.\n");
-    #endif
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_snd_pcm_drain_proc)pDevice->pContext->alsa.snd_pcm_drain)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-
-        /* We need to prepare the device again, otherwise we won't be able to restart the device. */
-        if (((ma_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback) < 0) {
-    #ifdef MA_DEBUG_OUTPUT
-            printf("[ALSA] Failed to prepare playback device after stopping.\n");
-    #endif
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__alsa(ma_device* pDevice, void* pFramesOut, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    ma_snd_pcm_sframes_t resultALSA;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    for (;;) {
-        resultALSA = ((ma_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, pFramesOut, frameCount);
-        if (resultALSA >= 0) {
-            break;  /* Success. */
-        } else {
-            if (resultALSA == -EAGAIN) {
-                /*printf("TRACE: EGAIN (read)\n");*/
-                continue;   /* Try again. */
-            } else if (resultALSA == -EPIPE) {
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("TRACE: EPIPE (read)\n");
-            #endif
-
-                /* Overrun. Recover and try again. If this fails we need to return an error. */
-                resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, resultALSA, MA_TRUE);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((ma_snd_pcm_t*)pDevice->alsa.pPCMCapture, pFramesOut, frameCount);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", ma_result_from_errno((int)-resultALSA));
-                }
-            }
-        }
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = resultALSA;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__alsa(ma_device* pDevice, const void* pFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    ma_snd_pcm_sframes_t resultALSA;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pFrames != NULL);
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    for (;;) {
-        resultALSA = ((ma_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pFrames, frameCount);
-        if (resultALSA >= 0) {
-            break;  /* Success. */
-        } else {
-            if (resultALSA == -EAGAIN) {
-                /*printf("TRACE: EGAIN (write)\n");*/
-                continue;   /* Try again. */
-            } else if (resultALSA == -EPIPE) {
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("TRACE: EPIPE (write)\n");
-            #endif
-
-                /* Underrun. Recover and try again. If this fails we need to return an error. */
-                resultALSA = ((ma_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, resultALSA, MA_TRUE);
-                if (resultALSA < 0) { /* MA_TRUE=silent (don't print anything on error). */
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                /*
-                In my testing I have had a situation where writei() does not automatically restart the device even though I've set it
-                up as such in the software parameters. What will happen is writei() will block indefinitely even though the number of
-                frames is well beyond the auto-start threshold. To work around this I've needed to add an explicit start here. Not sure
-                if this is me just being stupid and not recovering the device properly, but this definitely feels like something isn't
-                quite right here.
-                */
-                resultALSA = ((ma_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-
-                resultALSA = ((ma_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((ma_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pFrames, frameCount);
-                if (resultALSA < 0) {
-                    return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to device after underrun.", ma_result_from_errno((int)-resultALSA));
-                }
-            }
-        }
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = resultALSA;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__alsa(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_alsa);
-
-    /* Clean up memory for memory leak checkers. */
-    ((ma_snd_config_update_free_global_proc)pContext->alsa.snd_config_update_free_global)();
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->alsa.asoundSO);
-#endif
-
-    ma_mutex_uninit(&pContext->alsa.internalDeviceEnumLock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__alsa(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libasoundNames[] = {
-        "libasound.so.2",
-        "libasound.so"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libasoundNames); ++i) {
-        pContext->alsa.asoundSO = ma_dlopen(pContext, libasoundNames[i]);
-        if (pContext->alsa.asoundSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->alsa.asoundSO == NULL) {
-#ifdef MA_DEBUG_OUTPUT
-        printf("[ALSA] Failed to open shared object.\n");
-#endif
-        return MA_NO_BACKEND;
-    }
-
-    pContext->alsa.snd_pcm_open                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_open");
-    pContext->alsa.snd_pcm_close                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_close");
-    pContext->alsa.snd_pcm_hw_params_sizeof               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_sizeof");
-    pContext->alsa.snd_pcm_hw_params_any                  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_any");
-    pContext->alsa.snd_pcm_hw_params_set_format           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format");
-    pContext->alsa.snd_pcm_hw_params_set_format_first     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_format_first");
-    pContext->alsa.snd_pcm_hw_params_get_format_mask      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format_mask");
-    pContext->alsa.snd_pcm_hw_params_set_channels         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels");
-    pContext->alsa.snd_pcm_hw_params_set_channels_near    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_near");
-    pContext->alsa.snd_pcm_hw_params_set_channels_minmax  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_channels_minmax");
-    pContext->alsa.snd_pcm_hw_params_set_rate_resample    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_resample");
-    pContext->alsa.snd_pcm_hw_params_set_rate             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate");
-    pContext->alsa.snd_pcm_hw_params_set_rate_near        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_rate_near");
-    pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_buffer_size_near");
-    pContext->alsa.snd_pcm_hw_params_set_periods_near     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_periods_near");
-    pContext->alsa.snd_pcm_hw_params_set_access           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_set_access");
-    pContext->alsa.snd_pcm_hw_params_get_format           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_format");
-    pContext->alsa.snd_pcm_hw_params_get_channels         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels");
-    pContext->alsa.snd_pcm_hw_params_get_channels_min     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_min");
-    pContext->alsa.snd_pcm_hw_params_get_channels_max     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_channels_max");
-    pContext->alsa.snd_pcm_hw_params_get_rate             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate");
-    pContext->alsa.snd_pcm_hw_params_get_rate_min         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_min");
-    pContext->alsa.snd_pcm_hw_params_get_rate_max         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_rate_max");
-    pContext->alsa.snd_pcm_hw_params_get_buffer_size      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_buffer_size");
-    pContext->alsa.snd_pcm_hw_params_get_periods          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_periods");
-    pContext->alsa.snd_pcm_hw_params_get_access           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_get_access");
-    pContext->alsa.snd_pcm_hw_params_test_format          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_format");
-    pContext->alsa.snd_pcm_hw_params_test_channels        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_channels");
-    pContext->alsa.snd_pcm_hw_params_test_rate            = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params_test_rate");
-    pContext->alsa.snd_pcm_hw_params                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_hw_params");
-    pContext->alsa.snd_pcm_sw_params_sizeof               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_sizeof");
-    pContext->alsa.snd_pcm_sw_params_current              = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_current");
-    pContext->alsa.snd_pcm_sw_params_get_boundary         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_get_boundary");
-    pContext->alsa.snd_pcm_sw_params_set_avail_min        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_avail_min");
-    pContext->alsa.snd_pcm_sw_params_set_start_threshold  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_start_threshold");
-    pContext->alsa.snd_pcm_sw_params_set_stop_threshold   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params_set_stop_threshold");
-    pContext->alsa.snd_pcm_sw_params                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_sw_params");
-    pContext->alsa.snd_pcm_format_mask_sizeof             = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_format_mask_sizeof");
-    pContext->alsa.snd_pcm_format_mask_test               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_format_mask_test");
-    pContext->alsa.snd_pcm_get_chmap                      = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_get_chmap");
-    pContext->alsa.snd_pcm_state                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_state");
-    pContext->alsa.snd_pcm_prepare                        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_prepare");
-    pContext->alsa.snd_pcm_start                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_start");
-    pContext->alsa.snd_pcm_drop                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_drop");
-    pContext->alsa.snd_pcm_drain                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_drain");
-    pContext->alsa.snd_device_name_hint                   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_hint");
-    pContext->alsa.snd_device_name_get_hint               = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_get_hint");
-    pContext->alsa.snd_card_get_index                     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_card_get_index");
-    pContext->alsa.snd_device_name_free_hint              = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_device_name_free_hint");
-    pContext->alsa.snd_pcm_mmap_begin                     = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_mmap_begin");
-    pContext->alsa.snd_pcm_mmap_commit                    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_mmap_commit");
-    pContext->alsa.snd_pcm_recover                        = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_recover");
-    pContext->alsa.snd_pcm_readi                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_readi");
-    pContext->alsa.snd_pcm_writei                         = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_writei");
-    pContext->alsa.snd_pcm_avail                          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_avail");
-    pContext->alsa.snd_pcm_avail_update                   = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_avail_update");
-    pContext->alsa.snd_pcm_wait                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_wait");
-    pContext->alsa.snd_pcm_info                           = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info");
-    pContext->alsa.snd_pcm_info_sizeof                    = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info_sizeof");
-    pContext->alsa.snd_pcm_info_get_name                  = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_pcm_info_get_name");
-    pContext->alsa.snd_config_update_free_global          = (ma_proc)ma_dlsym(pContext, pContext->alsa.asoundSO, "snd_config_update_free_global");
-#else
-    /* The system below is just for type safety. */
-    ma_snd_pcm_open_proc                           _snd_pcm_open                           = snd_pcm_open;
-    ma_snd_pcm_close_proc                          _snd_pcm_close                          = snd_pcm_close;
-    ma_snd_pcm_hw_params_sizeof_proc               _snd_pcm_hw_params_sizeof               = snd_pcm_hw_params_sizeof;
-    ma_snd_pcm_hw_params_any_proc                  _snd_pcm_hw_params_any                  = snd_pcm_hw_params_any;
-    ma_snd_pcm_hw_params_set_format_proc           _snd_pcm_hw_params_set_format           = snd_pcm_hw_params_set_format;
-    ma_snd_pcm_hw_params_set_format_first_proc     _snd_pcm_hw_params_set_format_first     = snd_pcm_hw_params_set_format_first;
-    ma_snd_pcm_hw_params_get_format_mask_proc      _snd_pcm_hw_params_get_format_mask      = snd_pcm_hw_params_get_format_mask;
-    ma_snd_pcm_hw_params_set_channels_proc         _snd_pcm_hw_params_set_channels         = snd_pcm_hw_params_set_channels;
-    ma_snd_pcm_hw_params_set_channels_near_proc    _snd_pcm_hw_params_set_channels_near    = snd_pcm_hw_params_set_channels_near;
-    ma_snd_pcm_hw_params_set_rate_resample_proc    _snd_pcm_hw_params_set_rate_resample    = snd_pcm_hw_params_set_rate_resample;
-    ma_snd_pcm_hw_params_set_rate_near             _snd_pcm_hw_params_set_rate             = snd_pcm_hw_params_set_rate;
-    ma_snd_pcm_hw_params_set_rate_near_proc        _snd_pcm_hw_params_set_rate_near        = snd_pcm_hw_params_set_rate_near;
-    ma_snd_pcm_hw_params_set_rate_minmax_proc      _snd_pcm_hw_params_set_rate_minmax      = snd_pcm_hw_params_set_rate_minmax;
-    ma_snd_pcm_hw_params_set_buffer_size_near_proc _snd_pcm_hw_params_set_buffer_size_near = snd_pcm_hw_params_set_buffer_size_near;
-    ma_snd_pcm_hw_params_set_periods_near_proc     _snd_pcm_hw_params_set_periods_near     = snd_pcm_hw_params_set_periods_near;
-    ma_snd_pcm_hw_params_set_access_proc           _snd_pcm_hw_params_set_access           = snd_pcm_hw_params_set_access;
-    ma_snd_pcm_hw_params_get_format_proc           _snd_pcm_hw_params_get_format           = snd_pcm_hw_params_get_format;
-    ma_snd_pcm_hw_params_get_channels_proc         _snd_pcm_hw_params_get_channels         = snd_pcm_hw_params_get_channels;
-    ma_snd_pcm_hw_params_get_channels_min_proc     _snd_pcm_hw_params_get_channels_min     = snd_pcm_hw_params_get_channels_min;
-    ma_snd_pcm_hw_params_get_channels_max_proc     _snd_pcm_hw_params_get_channels_max     = snd_pcm_hw_params_get_channels_max;
-    ma_snd_pcm_hw_params_get_rate_proc             _snd_pcm_hw_params_get_rate             = snd_pcm_hw_params_get_rate;
-    ma_snd_pcm_hw_params_get_rate_min_proc         _snd_pcm_hw_params_get_rate_min         = snd_pcm_hw_params_get_rate_min;
-    ma_snd_pcm_hw_params_get_rate_max_proc         _snd_pcm_hw_params_get_rate_max         = snd_pcm_hw_params_get_rate_max;
-    ma_snd_pcm_hw_params_get_buffer_size_proc      _snd_pcm_hw_params_get_buffer_size      = snd_pcm_hw_params_get_buffer_size;
-    ma_snd_pcm_hw_params_get_periods_proc          _snd_pcm_hw_params_get_periods          = snd_pcm_hw_params_get_periods;
-    ma_snd_pcm_hw_params_get_access_proc           _snd_pcm_hw_params_get_access           = snd_pcm_hw_params_get_access;
-    ma_snd_pcm_hw_params_test_format_proc          _snd_pcm_hw_params_test_format          = snd_pcm_hw_params_test_format;
-    ma_snd_pcm_hw_params_test_channels_proc        _snd_pcm_hw_params_test_channels        = snd_pcm_hw_params_test_channels;
-    ma_snd_pcm_hw_params_test_rate_proc            _snd_pcm_hw_params_test_rate            = snd_pcm_hw_params_test_rate;
-    ma_snd_pcm_hw_params_proc                      _snd_pcm_hw_params                      = snd_pcm_hw_params;
-    ma_snd_pcm_sw_params_sizeof_proc               _snd_pcm_sw_params_sizeof               = snd_pcm_sw_params_sizeof;
-    ma_snd_pcm_sw_params_current_proc              _snd_pcm_sw_params_current              = snd_pcm_sw_params_current;
-    ma_snd_pcm_sw_params_get_boundary_proc         _snd_pcm_sw_params_get_boundary         = snd_pcm_sw_params_get_boundary;
-    ma_snd_pcm_sw_params_set_avail_min_proc        _snd_pcm_sw_params_set_avail_min        = snd_pcm_sw_params_set_avail_min;
-    ma_snd_pcm_sw_params_set_start_threshold_proc  _snd_pcm_sw_params_set_start_threshold  = snd_pcm_sw_params_set_start_threshold;
-    ma_snd_pcm_sw_params_set_stop_threshold_proc   _snd_pcm_sw_params_set_stop_threshold   = snd_pcm_sw_params_set_stop_threshold;
-    ma_snd_pcm_sw_params_proc                      _snd_pcm_sw_params                      = snd_pcm_sw_params;
-    ma_snd_pcm_format_mask_sizeof_proc             _snd_pcm_format_mask_sizeof             = snd_pcm_format_mask_sizeof;
-    ma_snd_pcm_format_mask_test_proc               _snd_pcm_format_mask_test               = snd_pcm_format_mask_test;
-    ma_snd_pcm_get_chmap_proc                      _snd_pcm_get_chmap                      = snd_pcm_get_chmap;
-    ma_snd_pcm_state_proc                          _snd_pcm_state                          = snd_pcm_state;
-    ma_snd_pcm_prepare_proc                        _snd_pcm_prepare                        = snd_pcm_prepare;
-    ma_snd_pcm_start_proc                          _snd_pcm_start                          = snd_pcm_start;
-    ma_snd_pcm_drop_proc                           _snd_pcm_drop                           = snd_pcm_drop;
-    ma_snd_pcm_drain_proc                          _snd_pcm_drain                          = snd_pcm_drain;
-    ma_snd_device_name_hint_proc                   _snd_device_name_hint                   = snd_device_name_hint;
-    ma_snd_device_name_get_hint_proc               _snd_device_name_get_hint               = snd_device_name_get_hint;
-    ma_snd_card_get_index_proc                     _snd_card_get_index                     = snd_card_get_index;
-    ma_snd_device_name_free_hint_proc              _snd_device_name_free_hint              = snd_device_name_free_hint;
-    ma_snd_pcm_mmap_begin_proc                     _snd_pcm_mmap_begin                     = snd_pcm_mmap_begin;
-    ma_snd_pcm_mmap_commit_proc                    _snd_pcm_mmap_commit                    = snd_pcm_mmap_commit;
-    ma_snd_pcm_recover_proc                        _snd_pcm_recover                        = snd_pcm_recover;
-    ma_snd_pcm_readi_proc                          _snd_pcm_readi                          = snd_pcm_readi;
-    ma_snd_pcm_writei_proc                         _snd_pcm_writei                         = snd_pcm_writei;
-    ma_snd_pcm_avail_proc                          _snd_pcm_avail                          = snd_pcm_avail;
-    ma_snd_pcm_avail_update_proc                   _snd_pcm_avail_update                   = snd_pcm_avail_update;
-    ma_snd_pcm_wait_proc                           _snd_pcm_wait                           = snd_pcm_wait;
-    ma_snd_pcm_info_proc                           _snd_pcm_info                           = snd_pcm_info;
-    ma_snd_pcm_info_sizeof_proc                    _snd_pcm_info_sizeof                    = snd_pcm_info_sizeof;
-    ma_snd_pcm_info_get_name_proc                  _snd_pcm_info_get_name                  = snd_pcm_info_get_name;
-    ma_snd_config_update_free_global_proc          _snd_config_update_free_global          = snd_config_update_free_global;
-
-    pContext->alsa.snd_pcm_open                           = (ma_proc)_snd_pcm_open;
-    pContext->alsa.snd_pcm_close                          = (ma_proc)_snd_pcm_close;
-    pContext->alsa.snd_pcm_hw_params_sizeof               = (ma_proc)_snd_pcm_hw_params_sizeof;
-    pContext->alsa.snd_pcm_hw_params_any                  = (ma_proc)_snd_pcm_hw_params_any;
-    pContext->alsa.snd_pcm_hw_params_set_format           = (ma_proc)_snd_pcm_hw_params_set_format;
-    pContext->alsa.snd_pcm_hw_params_set_format_first     = (ma_proc)_snd_pcm_hw_params_set_format_first;
-    pContext->alsa.snd_pcm_hw_params_get_format_mask      = (ma_proc)_snd_pcm_hw_params_get_format_mask;
-    pContext->alsa.snd_pcm_hw_params_set_channels         = (ma_proc)_snd_pcm_hw_params_set_channels;
-    pContext->alsa.snd_pcm_hw_params_set_channels_near    = (ma_proc)_snd_pcm_hw_params_set_channels_near;
-    pContext->alsa.snd_pcm_hw_params_set_channels_minmax  = (ma_proc)_snd_pcm_hw_params_set_channels_minmax;
-    pContext->alsa.snd_pcm_hw_params_set_rate_resample    = (ma_proc)_snd_pcm_hw_params_set_rate_resample;
-    pContext->alsa.snd_pcm_hw_params_set_rate             = (ma_proc)_snd_pcm_hw_params_set_rate;
-    pContext->alsa.snd_pcm_hw_params_set_rate_near        = (ma_proc)_snd_pcm_hw_params_set_rate_near;
-    pContext->alsa.snd_pcm_hw_params_set_buffer_size_near = (ma_proc)_snd_pcm_hw_params_set_buffer_size_near;
-    pContext->alsa.snd_pcm_hw_params_set_periods_near     = (ma_proc)_snd_pcm_hw_params_set_periods_near;
-    pContext->alsa.snd_pcm_hw_params_set_access           = (ma_proc)_snd_pcm_hw_params_set_access;
-    pContext->alsa.snd_pcm_hw_params_get_format           = (ma_proc)_snd_pcm_hw_params_get_format;
-    pContext->alsa.snd_pcm_hw_params_get_channels         = (ma_proc)_snd_pcm_hw_params_get_channels;
-    pContext->alsa.snd_pcm_hw_params_get_channels_min     = (ma_proc)_snd_pcm_hw_params_get_channels_min;
-    pContext->alsa.snd_pcm_hw_params_get_channels_max     = (ma_proc)_snd_pcm_hw_params_get_channels_max;
-    pContext->alsa.snd_pcm_hw_params_get_rate             = (ma_proc)_snd_pcm_hw_params_get_rate;
-    pContext->alsa.snd_pcm_hw_params_get_rate_min         = (ma_proc)_snd_pcm_hw_params_get_rate_min;
-    pContext->alsa.snd_pcm_hw_params_get_rate_max         = (ma_proc)_snd_pcm_hw_params_get_rate_max;
-    pContext->alsa.snd_pcm_hw_params_get_buffer_size      = (ma_proc)_snd_pcm_hw_params_get_buffer_size;
-    pContext->alsa.snd_pcm_hw_params_get_periods          = (ma_proc)_snd_pcm_hw_params_get_periods;
-    pContext->alsa.snd_pcm_hw_params_get_access           = (ma_proc)_snd_pcm_hw_params_get_access;
-    pContext->alsa.snd_pcm_hw_params_test_format          = (ma_proc)_snd_pcm_hw_params_test_format;
-    pContext->alsa.snd_pcm_hw_params_test_channels        = (ma_proc)_snd_pcm_hw_params_test_channels;
-    pContext->alsa.snd_pcm_hw_params_test_rate            = (ma_proc)_snd_pcm_hw_params_test_rate;
-    pContext->alsa.snd_pcm_hw_params                      = (ma_proc)_snd_pcm_hw_params;
-    pContext->alsa.snd_pcm_sw_params_sizeof               = (ma_proc)_snd_pcm_sw_params_sizeof;
-    pContext->alsa.snd_pcm_sw_params_current              = (ma_proc)_snd_pcm_sw_params_current;
-    pContext->alsa.snd_pcm_sw_params_get_boundary         = (ma_proc)_snd_pcm_sw_params_get_boundary;
-    pContext->alsa.snd_pcm_sw_params_set_avail_min        = (ma_proc)_snd_pcm_sw_params_set_avail_min;
-    pContext->alsa.snd_pcm_sw_params_set_start_threshold  = (ma_proc)_snd_pcm_sw_params_set_start_threshold;
-    pContext->alsa.snd_pcm_sw_params_set_stop_threshold   = (ma_proc)_snd_pcm_sw_params_set_stop_threshold;
-    pContext->alsa.snd_pcm_sw_params                      = (ma_proc)_snd_pcm_sw_params;
-    pContext->alsa.snd_pcm_format_mask_sizeof             = (ma_proc)_snd_pcm_format_mask_sizeof;
-    pContext->alsa.snd_pcm_format_mask_test               = (ma_proc)_snd_pcm_format_mask_test;
-    pContext->alsa.snd_pcm_get_chmap                      = (ma_proc)_snd_pcm_get_chmap;
-    pContext->alsa.snd_pcm_state                          = (ma_proc)_snd_pcm_state;
-    pContext->alsa.snd_pcm_prepare                        = (ma_proc)_snd_pcm_prepare;
-    pContext->alsa.snd_pcm_start                          = (ma_proc)_snd_pcm_start;
-    pContext->alsa.snd_pcm_drop                           = (ma_proc)_snd_pcm_drop;
-    pContext->alsa.snd_pcm_drain                          = (ma_proc)_snd_pcm_drain;
-    pContext->alsa.snd_device_name_hint                   = (ma_proc)_snd_device_name_hint;
-    pContext->alsa.snd_device_name_get_hint               = (ma_proc)_snd_device_name_get_hint;
-    pContext->alsa.snd_card_get_index                     = (ma_proc)_snd_card_get_index;
-    pContext->alsa.snd_device_name_free_hint              = (ma_proc)_snd_device_name_free_hint;
-    pContext->alsa.snd_pcm_mmap_begin                     = (ma_proc)_snd_pcm_mmap_begin;
-    pContext->alsa.snd_pcm_mmap_commit                    = (ma_proc)_snd_pcm_mmap_commit;
-    pContext->alsa.snd_pcm_recover                        = (ma_proc)_snd_pcm_recover;
-    pContext->alsa.snd_pcm_readi                          = (ma_proc)_snd_pcm_readi;
-    pContext->alsa.snd_pcm_writei                         = (ma_proc)_snd_pcm_writei;
-    pContext->alsa.snd_pcm_avail                          = (ma_proc)_snd_pcm_avail;
-    pContext->alsa.snd_pcm_avail_update                   = (ma_proc)_snd_pcm_avail_update;
-    pContext->alsa.snd_pcm_wait                           = (ma_proc)_snd_pcm_wait;
-    pContext->alsa.snd_pcm_info                           = (ma_proc)_snd_pcm_info;
-    pContext->alsa.snd_pcm_info_sizeof                    = (ma_proc)_snd_pcm_info_sizeof;
-    pContext->alsa.snd_pcm_info_get_name                  = (ma_proc)_snd_pcm_info_get_name;
-    pContext->alsa.snd_config_update_free_global          = (ma_proc)_snd_config_update_free_global;
-#endif
-
-    pContext->alsa.useVerboseDeviceEnumeration = pConfig->alsa.useVerboseDeviceEnumeration;
-
-    if (ma_mutex_init(&pContext->alsa.internalDeviceEnumLock) != MA_SUCCESS) {
-        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration.", MA_ERROR);
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__alsa;
-    pCallbacks->onContextUninit           = ma_context_uninit__alsa;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__alsa;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__alsa;
-    pCallbacks->onDeviceInit              = ma_device_init__alsa;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__alsa;
-    pCallbacks->onDeviceStart             = ma_device_start__alsa;
-    pCallbacks->onDeviceStop              = ma_device_stop__alsa;
-    pCallbacks->onDeviceRead              = ma_device_read__alsa;
-    pCallbacks->onDeviceWrite             = ma_device_write__alsa;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* ALSA */
-
-
-
-/******************************************************************************
-
-PulseAudio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_PULSEAUDIO
-/*
-The PulseAudio API, along with Apple's Core Audio, is the worst of the maintream audio APIs. This is a brief description of what's going on
-in the PulseAudio backend. I apologize if this gets a bit ranty for your liking - you might want to skip this discussion.
-
-PulseAudio has something they call the "Simple API", which unfortunately isn't suitable for miniaudio. I've not seen anywhere where it
-allows you to enumerate over devices, nor does it seem to support the ability to stop and start streams. Looking at the documentation, it
-appears as though the stream is constantly running and you prevent sound from being emitted or captured by simply not calling the read or
-write functions. This is not a professional solution as it would be much better to *actually* stop the underlying stream. Perhaps the
-simple API has some smarts to do this automatically, but I'm not sure. Another limitation with the simple API is that it seems inefficient
-when you want to have multiple streams to a single context. For these reasons, miniaudio is not using the simple API.
-
-Since we're not using the simple API, we're left with the asynchronous API as our only other option. And boy, is this where it starts to
-get fun, and I don't mean that in a good way...
-
-The problems start with the very name of the API - "asynchronous". Yes, this is an asynchronous oriented API which means your commands
-don't immediately take effect. You instead need to issue your commands, and then wait for them to complete. The waiting mechanism is
-enabled through the use of a "main loop". In the asychronous API you cannot get away from the main loop, and the main loop is where almost
-all of PulseAudio's problems stem from.
-
-When you first initialize PulseAudio you need an object referred to as "main loop". You can implement this yourself by defining your own
-vtable, but it's much easier to just use one of the built-in main loop implementations. There's two generic implementations called
-pa_mainloop and pa_threaded_mainloop, and another implementation specific to GLib called pa_glib_mainloop. We're using pa_threaded_mainloop
-because it simplifies management of the worker thread. The idea of the main loop object is pretty self explanatory - you're supposed to use
-it to implement a worker thread which runs in a loop. The main loop is where operations are actually executed.
-
-To initialize the main loop, you just use `pa_threaded_mainloop_new()`. This is the first function you'll call. You can then get a pointer
-to the vtable with `pa_threaded_mainloop_get_api()` (the main loop vtable is called `pa_mainloop_api`). Again, you can bypass the threaded
-main loop object entirely and just implement `pa_mainloop_api` directly, but there's no need for it unless you're doing something extremely
-specialized such as if you want to integrate it into your application's existing main loop infrastructure.
-
-(EDIT 2021-01-26: miniaudio is no longer using `pa_threaded_mainloop` due to this issue: https://github.com/mackron/miniaudio/issues/262.
-It is now using `pa_mainloop` which turns out to be a simpler solution anyway. The rest of this rant still applies, however.)
-
-Once you have your main loop vtable (the `pa_mainloop_api` object) you can create the PulseAudio context. This is very similar to
-miniaudio's context and they map to each other quite well. You have one context to many streams, which is basically the same as miniaudio's
-one `ma_context` to many `ma_device`s. Here's where it starts to get annoying, however. When you first create the PulseAudio context, which
-is done with `pa_context_new()`, it's not actually connected to anything. When you connect, you call `pa_context_connect()`. However, if
-you remember, PulseAudio is an asynchronous API. That means you cannot just assume the context is connected after `pa_context_context()`
-has returned. You instead need to wait for it to connect. To do this, you need to either wait for a callback to get fired, which you can
-set with `pa_context_set_state_callback()`, or you can continuously poll the context's state. Either way, you need to run this in a loop.
-All objects from here out are created from the context, and, I believe, you can't be creating these objects until the context is connected.
-This waiting loop is therefore unavoidable. In order for the waiting to ever complete, however, the main loop needs to be running. Before
-attempting to connect the context, the main loop needs to be started with `pa_threaded_mainloop_start()`.
-
-The reason for this asynchronous design is to support cases where you're connecting to a remote server, say through a local network or an
-internet connection. However, the *VAST* majority of cases don't involve this at all - they just connect to a local "server" running on the
-host machine. The fact that this would be the default rather than making `pa_context_connect()` synchronous tends to boggle the mind.
-
-Once the context has been created and connected you can start creating a stream. A PulseAudio stream is analogous to miniaudio's device.
-The initialization of a stream is fairly standard - you configure some attributes (analogous to miniaudio's device config) and then call
-`pa_stream_new()` to actually create it. Here is where we start to get into "operations". When configuring the stream, you can get
-information about the source (such as sample format, sample rate, etc.), however it's not synchronous. Instead, a `pa_operation` object
-is returned from `pa_context_get_source_info_by_name()` (capture) or `pa_context_get_sink_info_by_name()` (playback). Then, you need to
-run a loop (again!) to wait for the operation to complete which you can determine via a callback or polling, just like we did with the
-context. Then, as an added bonus, you need to decrement the reference counter of the `pa_operation` object to ensure memory is cleaned up.
-All of that just to retrieve basic information about a device!
-
-Once the basic information about the device has been retrieved, miniaudio can now create the stream with `ma_stream_new()`. Like the
-context, this needs to be connected. But we need to be careful here, because we're now about to introduce one of the most horrific design
-choices in PulseAudio.
-
-PulseAudio allows you to specify a callback that is fired when data can be written to or read from a stream. The language is important here
-because PulseAudio takes it literally, specifically the "can be". You would think these callbacks would be appropriate as the place for
-writing and reading data to and from the stream, and that would be right, except when it's not. When you initialize the stream, you can
-set a flag that tells PulseAudio to not start the stream automatically. This is required because miniaudio does not auto-start devices
-straight after initialization - you need to call `ma_device_start()` manually. The problem is that even when this flag is specified,
-PulseAudio will immediately fire it's write or read callback. This is *technically* correct (based on the wording in the documentation)
-because indeed, data *can* be written at this point. The problem is that it's not *practical*. It makes sense that the write/read callback
-would be where a program will want to write or read data to or from the stream, but when it's called before the application has even
-requested that the stream be started, it's just not practical because the program probably isn't ready for any kind of data delivery at
-that point (it may still need to load files or whatnot). Instead, this callback should only be fired when the application requests the
-stream be started which is how it works with literally *every* other callback-based audio API. Since miniaudio forbids firing of the data
-callback until the device has been started (as it should be with *all* callback based APIs), logic needs to be added to ensure miniaudio
-doesn't just blindly fire the application-defined data callback from within the PulseAudio callback before the stream has actually been
-started. The device state is used for this - if the state is anything other than `MA_STATE_STARTING` or `MA_STATE_STARTED`, the main data
-callback is not fired.
-
-This, unfortunately, is not the end of the problems with the PulseAudio write callback. Any normal callback based audio API will
-continuously fire the callback at regular intervals based on the size of the internal buffer. This will only ever be fired when the device
-is running, and will be fired regardless of whether or not the user actually wrote anything to the device/stream. This not the case in
-PulseAudio. In PulseAudio, the data callback will *only* be called if you wrote something to it previously. That means, if you don't call
-`pa_stream_write()`, the callback will not get fired. On the surface you wouldn't think this would matter because you should be always
-writing data, and if you don't have anything to write, just write silence. That's fine until you want to drain the stream. You see, if
-you're continuously writing data to the stream, the stream will never get drained! That means in order to drain the stream, you need to
-*not* write data to it! But remember, when you don't write data to the stream, the callback won't get fired again! Why is draining
-important? Because that's how we've defined stopping to work in miniaudio. In miniaudio, stopping the device requires it to be drained
-before returning from ma_device_stop(). So we've stopped the device, which requires us to drain, but draining requires us to *not* write
-data to the stream (or else it won't ever complete draining), but not writing to the stream means the callback won't get fired again!
-
-This becomes a problem when stopping and then restarting the device. When the device is stopped, it's drained, which requires us to *not*
-write anything to the stream. But then, since we didn't write anything to it, the write callback will *never* get called again if we just
-resume the stream naively. This means that starting the stream requires us to write data to the stream from outside the callback. This
-disconnect is something PulseAudio has got seriously wrong - there should only ever be a single source of data delivery, that being the
-callback. (I have tried using `pa_stream_flush()` to trigger the write callback to fire, but this just doesn't work for some reason.)
-
-Once you've created the stream, you need to connect it which involves the whole waiting procedure. This is the same process as the context,
-only this time you'll poll for the state with `pa_stream_get_status()`. The starting and stopping of a streaming is referred to as
-"corking" in PulseAudio. The analogy is corking a barrel. To start the stream, you uncork it, to stop it you cork it. Personally I think
-it's silly - why would you not just call it "starting" and "stopping" like any other normal audio API? Anyway, the act of corking is, you
-guessed it, asynchronous. This means you'll need our waiting loop as usual. Again, why this asynchronous design is the default is
-absolutely beyond me. Would it really be that hard to just make it run synchronously?
-
-Teardown is pretty simple (what?!). It's just a matter of calling the relevant `_unref()` function on each object in reverse order that
-they were initialized in.
-
-That's about it from the PulseAudio side. A bit ranty, I know, but they really need to fix that main loop and callback system. They're
-embarrassingly unpractical. The main loop thing is an easy fix - have synchronous versions of all APIs. If an application wants these to
-run asynchronously, they can execute them in a separate thread themselves. The desire to run these asynchronously is such a niche
-requirement - it makes no sense to make it the default. The stream write callback needs to be change, or an alternative provided, that is
-constantly fired, regardless of whether or not `pa_stream_write()` has been called, and it needs to take a pointer to a buffer as a
-parameter which the program just writes to directly rather than having to call `pa_stream_writable_size()` and `pa_stream_write()`. These
-changes alone will change PulseAudio from one of the worst audio APIs to one of the best.
-*/
-
-
-/*
-It is assumed pulseaudio.h is available when linking at compile time. When linking at compile time, we use the declarations in the header
-to check for type safety. We cannot do this when linking at run time because the header might not be available.
-*/
-#ifdef MA_NO_RUNTIME_LINKING
-
-/* pulseaudio.h marks some functions with "inline" which isn't always supported. Need to emulate it. */
-#if !defined(__cplusplus)
-    #if defined(__STRICT_ANSI__)
-        #if !defined(inline)
-            #define inline __inline__ __attribute__((always_inline))
-            #define MA_INLINE_DEFINED
-        #endif
-    #endif
-#endif
-#include <pulse/pulseaudio.h>
-#if defined(MA_INLINE_DEFINED)
-    #undef inline
-    #undef MA_INLINE_DEFINED
-#endif
-
-#define MA_PA_OK                                       PA_OK
-#define MA_PA_ERR_ACCESS                               PA_ERR_ACCESS
-#define MA_PA_ERR_INVALID                              PA_ERR_INVALID
-#define MA_PA_ERR_NOENTITY                             PA_ERR_NOENTITY
-
-#define MA_PA_CHANNELS_MAX                             PA_CHANNELS_MAX
-#define MA_PA_RATE_MAX                                 PA_RATE_MAX
-
-typedef pa_context_flags_t ma_pa_context_flags_t;
-#define MA_PA_CONTEXT_NOFLAGS                          PA_CONTEXT_NOFLAGS
-#define MA_PA_CONTEXT_NOAUTOSPAWN                      PA_CONTEXT_NOAUTOSPAWN
-#define MA_PA_CONTEXT_NOFAIL                           PA_CONTEXT_NOFAIL
-
-typedef pa_stream_flags_t ma_pa_stream_flags_t;
-#define MA_PA_STREAM_NOFLAGS                           PA_STREAM_NOFLAGS
-#define MA_PA_STREAM_START_CORKED                      PA_STREAM_START_CORKED
-#define MA_PA_STREAM_INTERPOLATE_TIMING                PA_STREAM_INTERPOLATE_TIMING
-#define MA_PA_STREAM_NOT_MONOTONIC                     PA_STREAM_NOT_MONOTONIC
-#define MA_PA_STREAM_AUTO_TIMING_UPDATE                PA_STREAM_AUTO_TIMING_UPDATE
-#define MA_PA_STREAM_NO_REMAP_CHANNELS                 PA_STREAM_NO_REMAP_CHANNELS
-#define MA_PA_STREAM_NO_REMIX_CHANNELS                 PA_STREAM_NO_REMIX_CHANNELS
-#define MA_PA_STREAM_FIX_FORMAT                        PA_STREAM_FIX_FORMAT
-#define MA_PA_STREAM_FIX_RATE                          PA_STREAM_FIX_RATE
-#define MA_PA_STREAM_FIX_CHANNELS                      PA_STREAM_FIX_CHANNELS
-#define MA_PA_STREAM_DONT_MOVE                         PA_STREAM_DONT_MOVE
-#define MA_PA_STREAM_VARIABLE_RATE                     PA_STREAM_VARIABLE_RATE
-#define MA_PA_STREAM_PEAK_DETECT                       PA_STREAM_PEAK_DETECT
-#define MA_PA_STREAM_START_MUTED                       PA_STREAM_START_MUTED
-#define MA_PA_STREAM_ADJUST_LATENCY                    PA_STREAM_ADJUST_LATENCY
-#define MA_PA_STREAM_EARLY_REQUESTS                    PA_STREAM_EARLY_REQUESTS
-#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND         PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
-#define MA_PA_STREAM_START_UNMUTED                     PA_STREAM_START_UNMUTED
-#define MA_PA_STREAM_FAIL_ON_SUSPEND                   PA_STREAM_FAIL_ON_SUSPEND
-#define MA_PA_STREAM_RELATIVE_VOLUME                   PA_STREAM_RELATIVE_VOLUME
-#define MA_PA_STREAM_PASSTHROUGH                       PA_STREAM_PASSTHROUGH
-
-typedef pa_sink_flags_t ma_pa_sink_flags_t;
-#define MA_PA_SINK_NOFLAGS                             PA_SINK_NOFLAGS
-#define MA_PA_SINK_HW_VOLUME_CTRL                      PA_SINK_HW_VOLUME_CTRL
-#define MA_PA_SINK_LATENCY                             PA_SINK_LATENCY
-#define MA_PA_SINK_HARDWARE                            PA_SINK_HARDWARE
-#define MA_PA_SINK_NETWORK                             PA_SINK_NETWORK
-#define MA_PA_SINK_HW_MUTE_CTRL                        PA_SINK_HW_MUTE_CTRL
-#define MA_PA_SINK_DECIBEL_VOLUME                      PA_SINK_DECIBEL_VOLUME
-#define MA_PA_SINK_FLAT_VOLUME                         PA_SINK_FLAT_VOLUME
-#define MA_PA_SINK_DYNAMIC_LATENCY                     PA_SINK_DYNAMIC_LATENCY
-#define MA_PA_SINK_SET_FORMATS                         PA_SINK_SET_FORMATS
-
-typedef pa_source_flags_t ma_pa_source_flags_t;
-#define MA_PA_SOURCE_NOFLAGS                           PA_SOURCE_NOFLAGS
-#define MA_PA_SOURCE_HW_VOLUME_CTRL                    PA_SOURCE_HW_VOLUME_CTRL
-#define MA_PA_SOURCE_LATENCY                           PA_SOURCE_LATENCY
-#define MA_PA_SOURCE_HARDWARE                          PA_SOURCE_HARDWARE
-#define MA_PA_SOURCE_NETWORK                           PA_SOURCE_NETWORK
-#define MA_PA_SOURCE_HW_MUTE_CTRL                      PA_SOURCE_HW_MUTE_CTRL
-#define MA_PA_SOURCE_DECIBEL_VOLUME                    PA_SOURCE_DECIBEL_VOLUME
-#define MA_PA_SOURCE_DYNAMIC_LATENCY                   PA_SOURCE_DYNAMIC_LATENCY
-#define MA_PA_SOURCE_FLAT_VOLUME                       PA_SOURCE_FLAT_VOLUME
-
-typedef pa_context_state_t ma_pa_context_state_t;
-#define MA_PA_CONTEXT_UNCONNECTED                      PA_CONTEXT_UNCONNECTED
-#define MA_PA_CONTEXT_CONNECTING                       PA_CONTEXT_CONNECTING
-#define MA_PA_CONTEXT_AUTHORIZING                      PA_CONTEXT_AUTHORIZING
-#define MA_PA_CONTEXT_SETTING_NAME                     PA_CONTEXT_SETTING_NAME
-#define MA_PA_CONTEXT_READY                            PA_CONTEXT_READY
-#define MA_PA_CONTEXT_FAILED                           PA_CONTEXT_FAILED
-#define MA_PA_CONTEXT_TERMINATED                       PA_CONTEXT_TERMINATED
-
-typedef pa_stream_state_t ma_pa_stream_state_t;
-#define MA_PA_STREAM_UNCONNECTED                       PA_STREAM_UNCONNECTED
-#define MA_PA_STREAM_CREATING                          PA_STREAM_CREATING
-#define MA_PA_STREAM_READY                             PA_STREAM_READY
-#define MA_PA_STREAM_FAILED                            PA_STREAM_FAILED
-#define MA_PA_STREAM_TERMINATED                        PA_STREAM_TERMINATED
-
-typedef pa_operation_state_t ma_pa_operation_state_t;
-#define MA_PA_OPERATION_RUNNING                        PA_OPERATION_RUNNING
-#define MA_PA_OPERATION_DONE                           PA_OPERATION_DONE
-#define MA_PA_OPERATION_CANCELLED                      PA_OPERATION_CANCELLED
-
-typedef pa_sink_state_t ma_pa_sink_state_t;
-#define MA_PA_SINK_INVALID_STATE                       PA_SINK_INVALID_STATE
-#define MA_PA_SINK_RUNNING                             PA_SINK_RUNNING
-#define MA_PA_SINK_IDLE                                PA_SINK_IDLE
-#define MA_PA_SINK_SUSPENDED                           PA_SINK_SUSPENDED
-
-typedef pa_source_state_t ma_pa_source_state_t;
-#define MA_PA_SOURCE_INVALID_STATE                     PA_SOURCE_INVALID_STATE
-#define MA_PA_SOURCE_RUNNING                           PA_SOURCE_RUNNING
-#define MA_PA_SOURCE_IDLE                              PA_SOURCE_IDLE
-#define MA_PA_SOURCE_SUSPENDED                         PA_SOURCE_SUSPENDED
-
-typedef pa_seek_mode_t ma_pa_seek_mode_t;
-#define MA_PA_SEEK_RELATIVE                            PA_SEEK_RELATIVE
-#define MA_PA_SEEK_ABSOLUTE                            PA_SEEK_ABSOLUTE
-#define MA_PA_SEEK_RELATIVE_ON_READ                    PA_SEEK_RELATIVE_ON_READ
-#define MA_PA_SEEK_RELATIVE_END                        PA_SEEK_RELATIVE_END
-
-typedef pa_channel_position_t ma_pa_channel_position_t;
-#define MA_PA_CHANNEL_POSITION_INVALID                 PA_CHANNEL_POSITION_INVALID
-#define MA_PA_CHANNEL_POSITION_MONO                    PA_CHANNEL_POSITION_MONO
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT              PA_CHANNEL_POSITION_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT             PA_CHANNEL_POSITION_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_FRONT_CENTER            PA_CHANNEL_POSITION_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_REAR_CENTER             PA_CHANNEL_POSITION_REAR_CENTER
-#define MA_PA_CHANNEL_POSITION_REAR_LEFT               PA_CHANNEL_POSITION_REAR_LEFT
-#define MA_PA_CHANNEL_POSITION_REAR_RIGHT              PA_CHANNEL_POSITION_REAR_RIGHT
-#define MA_PA_CHANNEL_POSITION_LFE                     PA_CHANNEL_POSITION_LFE
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER    PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER   PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER
-#define MA_PA_CHANNEL_POSITION_SIDE_LEFT               PA_CHANNEL_POSITION_SIDE_LEFT
-#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT              PA_CHANNEL_POSITION_SIDE_RIGHT
-#define MA_PA_CHANNEL_POSITION_AUX0                    PA_CHANNEL_POSITION_AUX0
-#define MA_PA_CHANNEL_POSITION_AUX1                    PA_CHANNEL_POSITION_AUX1
-#define MA_PA_CHANNEL_POSITION_AUX2                    PA_CHANNEL_POSITION_AUX2
-#define MA_PA_CHANNEL_POSITION_AUX3                    PA_CHANNEL_POSITION_AUX3
-#define MA_PA_CHANNEL_POSITION_AUX4                    PA_CHANNEL_POSITION_AUX4
-#define MA_PA_CHANNEL_POSITION_AUX5                    PA_CHANNEL_POSITION_AUX5
-#define MA_PA_CHANNEL_POSITION_AUX6                    PA_CHANNEL_POSITION_AUX6
-#define MA_PA_CHANNEL_POSITION_AUX7                    PA_CHANNEL_POSITION_AUX7
-#define MA_PA_CHANNEL_POSITION_AUX8                    PA_CHANNEL_POSITION_AUX8
-#define MA_PA_CHANNEL_POSITION_AUX9                    PA_CHANNEL_POSITION_AUX9
-#define MA_PA_CHANNEL_POSITION_AUX10                   PA_CHANNEL_POSITION_AUX10
-#define MA_PA_CHANNEL_POSITION_AUX11                   PA_CHANNEL_POSITION_AUX11
-#define MA_PA_CHANNEL_POSITION_AUX12                   PA_CHANNEL_POSITION_AUX12
-#define MA_PA_CHANNEL_POSITION_AUX13                   PA_CHANNEL_POSITION_AUX13
-#define MA_PA_CHANNEL_POSITION_AUX14                   PA_CHANNEL_POSITION_AUX14
-#define MA_PA_CHANNEL_POSITION_AUX15                   PA_CHANNEL_POSITION_AUX15
-#define MA_PA_CHANNEL_POSITION_AUX16                   PA_CHANNEL_POSITION_AUX16
-#define MA_PA_CHANNEL_POSITION_AUX17                   PA_CHANNEL_POSITION_AUX17
-#define MA_PA_CHANNEL_POSITION_AUX18                   PA_CHANNEL_POSITION_AUX18
-#define MA_PA_CHANNEL_POSITION_AUX19                   PA_CHANNEL_POSITION_AUX19
-#define MA_PA_CHANNEL_POSITION_AUX20                   PA_CHANNEL_POSITION_AUX20
-#define MA_PA_CHANNEL_POSITION_AUX21                   PA_CHANNEL_POSITION_AUX21
-#define MA_PA_CHANNEL_POSITION_AUX22                   PA_CHANNEL_POSITION_AUX22
-#define MA_PA_CHANNEL_POSITION_AUX23                   PA_CHANNEL_POSITION_AUX23
-#define MA_PA_CHANNEL_POSITION_AUX24                   PA_CHANNEL_POSITION_AUX24
-#define MA_PA_CHANNEL_POSITION_AUX25                   PA_CHANNEL_POSITION_AUX25
-#define MA_PA_CHANNEL_POSITION_AUX26                   PA_CHANNEL_POSITION_AUX26
-#define MA_PA_CHANNEL_POSITION_AUX27                   PA_CHANNEL_POSITION_AUX27
-#define MA_PA_CHANNEL_POSITION_AUX28                   PA_CHANNEL_POSITION_AUX28
-#define MA_PA_CHANNEL_POSITION_AUX29                   PA_CHANNEL_POSITION_AUX29
-#define MA_PA_CHANNEL_POSITION_AUX30                   PA_CHANNEL_POSITION_AUX30
-#define MA_PA_CHANNEL_POSITION_AUX31                   PA_CHANNEL_POSITION_AUX31
-#define MA_PA_CHANNEL_POSITION_TOP_CENTER              PA_CHANNEL_POSITION_TOP_CENTER
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT          PA_CHANNEL_POSITION_TOP_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT         PA_CHANNEL_POSITION_TOP_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER        PA_CHANNEL_POSITION_TOP_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT           PA_CHANNEL_POSITION_TOP_REAR_LEFT
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT          PA_CHANNEL_POSITION_TOP_REAR_RIGHT
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER         PA_CHANNEL_POSITION_TOP_REAR_CENTER
-#define MA_PA_CHANNEL_POSITION_LEFT                    PA_CHANNEL_POSITION_LEFT
-#define MA_PA_CHANNEL_POSITION_RIGHT                   PA_CHANNEL_POSITION_RIGHT
-#define MA_PA_CHANNEL_POSITION_CENTER                  PA_CHANNEL_POSITION_CENTER
-#define MA_PA_CHANNEL_POSITION_SUBWOOFER               PA_CHANNEL_POSITION_SUBWOOFER
-
-typedef pa_channel_map_def_t ma_pa_channel_map_def_t;
-#define MA_PA_CHANNEL_MAP_AIFF                         PA_CHANNEL_MAP_AIFF
-#define MA_PA_CHANNEL_MAP_ALSA                         PA_CHANNEL_MAP_ALSA
-#define MA_PA_CHANNEL_MAP_AUX                          PA_CHANNEL_MAP_AUX
-#define MA_PA_CHANNEL_MAP_WAVEEX                       PA_CHANNEL_MAP_WAVEEX
-#define MA_PA_CHANNEL_MAP_OSS                          PA_CHANNEL_MAP_OSS
-#define MA_PA_CHANNEL_MAP_DEFAULT                      PA_CHANNEL_MAP_DEFAULT
-
-typedef pa_sample_format_t ma_pa_sample_format_t;
-#define MA_PA_SAMPLE_INVALID                           PA_SAMPLE_INVALID
-#define MA_PA_SAMPLE_U8                                PA_SAMPLE_U8
-#define MA_PA_SAMPLE_ALAW                              PA_SAMPLE_ALAW
-#define MA_PA_SAMPLE_ULAW                              PA_SAMPLE_ULAW
-#define MA_PA_SAMPLE_S16LE                             PA_SAMPLE_S16LE
-#define MA_PA_SAMPLE_S16BE                             PA_SAMPLE_S16BE
-#define MA_PA_SAMPLE_FLOAT32LE                         PA_SAMPLE_FLOAT32LE
-#define MA_PA_SAMPLE_FLOAT32BE                         PA_SAMPLE_FLOAT32BE
-#define MA_PA_SAMPLE_S32LE                             PA_SAMPLE_S32LE
-#define MA_PA_SAMPLE_S32BE                             PA_SAMPLE_S32BE
-#define MA_PA_SAMPLE_S24LE                             PA_SAMPLE_S24LE
-#define MA_PA_SAMPLE_S24BE                             PA_SAMPLE_S24BE
-#define MA_PA_SAMPLE_S24_32LE                          PA_SAMPLE_S24_32LE
-#define MA_PA_SAMPLE_S24_32BE                          PA_SAMPLE_S24_32BE
-
-typedef pa_mainloop             ma_pa_mainloop;
-typedef pa_threaded_mainloop    ma_pa_threaded_mainloop;
-typedef pa_mainloop_api         ma_pa_mainloop_api;
-typedef pa_context              ma_pa_context;
-typedef pa_operation            ma_pa_operation;
-typedef pa_stream               ma_pa_stream;
-typedef pa_spawn_api            ma_pa_spawn_api;
-typedef pa_buffer_attr          ma_pa_buffer_attr;
-typedef pa_channel_map          ma_pa_channel_map;
-typedef pa_cvolume              ma_pa_cvolume;
-typedef pa_sample_spec          ma_pa_sample_spec;
-typedef pa_sink_info            ma_pa_sink_info;
-typedef pa_source_info          ma_pa_source_info;
-
-typedef pa_context_notify_cb_t  ma_pa_context_notify_cb_t;
-typedef pa_sink_info_cb_t       ma_pa_sink_info_cb_t;
-typedef pa_source_info_cb_t     ma_pa_source_info_cb_t;
-typedef pa_stream_success_cb_t  ma_pa_stream_success_cb_t;
-typedef pa_stream_request_cb_t  ma_pa_stream_request_cb_t;
-typedef pa_free_cb_t            ma_pa_free_cb_t;
-#else
-#define MA_PA_OK                                       0
-#define MA_PA_ERR_ACCESS                               1
-#define MA_PA_ERR_INVALID                              2
-#define MA_PA_ERR_NOENTITY                             5
-
-#define MA_PA_CHANNELS_MAX                             32
-#define MA_PA_RATE_MAX                                 384000
-
-typedef int ma_pa_context_flags_t;
-#define MA_PA_CONTEXT_NOFLAGS                          0x00000000
-#define MA_PA_CONTEXT_NOAUTOSPAWN                      0x00000001
-#define MA_PA_CONTEXT_NOFAIL                           0x00000002
-
-typedef int ma_pa_stream_flags_t;
-#define MA_PA_STREAM_NOFLAGS                           0x00000000
-#define MA_PA_STREAM_START_CORKED                      0x00000001
-#define MA_PA_STREAM_INTERPOLATE_TIMING                0x00000002
-#define MA_PA_STREAM_NOT_MONOTONIC                     0x00000004
-#define MA_PA_STREAM_AUTO_TIMING_UPDATE                0x00000008
-#define MA_PA_STREAM_NO_REMAP_CHANNELS                 0x00000010
-#define MA_PA_STREAM_NO_REMIX_CHANNELS                 0x00000020
-#define MA_PA_STREAM_FIX_FORMAT                        0x00000040
-#define MA_PA_STREAM_FIX_RATE                          0x00000080
-#define MA_PA_STREAM_FIX_CHANNELS                      0x00000100
-#define MA_PA_STREAM_DONT_MOVE                         0x00000200
-#define MA_PA_STREAM_VARIABLE_RATE                     0x00000400
-#define MA_PA_STREAM_PEAK_DETECT                       0x00000800
-#define MA_PA_STREAM_START_MUTED                       0x00001000
-#define MA_PA_STREAM_ADJUST_LATENCY                    0x00002000
-#define MA_PA_STREAM_EARLY_REQUESTS                    0x00004000
-#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND         0x00008000
-#define MA_PA_STREAM_START_UNMUTED                     0x00010000
-#define MA_PA_STREAM_FAIL_ON_SUSPEND                   0x00020000
-#define MA_PA_STREAM_RELATIVE_VOLUME                   0x00040000
-#define MA_PA_STREAM_PASSTHROUGH                       0x00080000
-
-typedef int ma_pa_sink_flags_t;
-#define MA_PA_SINK_NOFLAGS                             0x00000000
-#define MA_PA_SINK_HW_VOLUME_CTRL                      0x00000001
-#define MA_PA_SINK_LATENCY                             0x00000002
-#define MA_PA_SINK_HARDWARE                            0x00000004
-#define MA_PA_SINK_NETWORK                             0x00000008
-#define MA_PA_SINK_HW_MUTE_CTRL                        0x00000010
-#define MA_PA_SINK_DECIBEL_VOLUME                      0x00000020
-#define MA_PA_SINK_FLAT_VOLUME                         0x00000040
-#define MA_PA_SINK_DYNAMIC_LATENCY                     0x00000080
-#define MA_PA_SINK_SET_FORMATS                         0x00000100
-
-typedef int ma_pa_source_flags_t;
-#define MA_PA_SOURCE_NOFLAGS                           0x00000000
-#define MA_PA_SOURCE_HW_VOLUME_CTRL                    0x00000001
-#define MA_PA_SOURCE_LATENCY                           0x00000002
-#define MA_PA_SOURCE_HARDWARE                          0x00000004
-#define MA_PA_SOURCE_NETWORK                           0x00000008
-#define MA_PA_SOURCE_HW_MUTE_CTRL                      0x00000010
-#define MA_PA_SOURCE_DECIBEL_VOLUME                    0x00000020
-#define MA_PA_SOURCE_DYNAMIC_LATENCY                   0x00000040
-#define MA_PA_SOURCE_FLAT_VOLUME                       0x00000080
-
-typedef int ma_pa_context_state_t;
-#define MA_PA_CONTEXT_UNCONNECTED                      0
-#define MA_PA_CONTEXT_CONNECTING                       1
-#define MA_PA_CONTEXT_AUTHORIZING                      2
-#define MA_PA_CONTEXT_SETTING_NAME                     3
-#define MA_PA_CONTEXT_READY                            4
-#define MA_PA_CONTEXT_FAILED                           5
-#define MA_PA_CONTEXT_TERMINATED                       6
-
-typedef int ma_pa_stream_state_t;
-#define MA_PA_STREAM_UNCONNECTED                       0
-#define MA_PA_STREAM_CREATING                          1
-#define MA_PA_STREAM_READY                             2
-#define MA_PA_STREAM_FAILED                            3
-#define MA_PA_STREAM_TERMINATED                        4
-
-typedef int ma_pa_operation_state_t;
-#define MA_PA_OPERATION_RUNNING                        0
-#define MA_PA_OPERATION_DONE                           1
-#define MA_PA_OPERATION_CANCELLED                      2
-
-typedef int ma_pa_sink_state_t;
-#define MA_PA_SINK_INVALID_STATE                       -1
-#define MA_PA_SINK_RUNNING                             0
-#define MA_PA_SINK_IDLE                                1
-#define MA_PA_SINK_SUSPENDED                           2
-
-typedef int ma_pa_source_state_t;
-#define MA_PA_SOURCE_INVALID_STATE                     -1
-#define MA_PA_SOURCE_RUNNING                           0
-#define MA_PA_SOURCE_IDLE                              1
-#define MA_PA_SOURCE_SUSPENDED                         2
-
-typedef int ma_pa_seek_mode_t;
-#define MA_PA_SEEK_RELATIVE                            0
-#define MA_PA_SEEK_ABSOLUTE                            1
-#define MA_PA_SEEK_RELATIVE_ON_READ                    2
-#define MA_PA_SEEK_RELATIVE_END                        3
-
-typedef int ma_pa_channel_position_t;
-#define MA_PA_CHANNEL_POSITION_INVALID                 -1
-#define MA_PA_CHANNEL_POSITION_MONO                    0
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT              1
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT             2
-#define MA_PA_CHANNEL_POSITION_FRONT_CENTER            3
-#define MA_PA_CHANNEL_POSITION_REAR_CENTER             4
-#define MA_PA_CHANNEL_POSITION_REAR_LEFT               5
-#define MA_PA_CHANNEL_POSITION_REAR_RIGHT              6
-#define MA_PA_CHANNEL_POSITION_LFE                     7
-#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER    8
-#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER   9
-#define MA_PA_CHANNEL_POSITION_SIDE_LEFT               10
-#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT              11
-#define MA_PA_CHANNEL_POSITION_AUX0                    12
-#define MA_PA_CHANNEL_POSITION_AUX1                    13
-#define MA_PA_CHANNEL_POSITION_AUX2                    14
-#define MA_PA_CHANNEL_POSITION_AUX3                    15
-#define MA_PA_CHANNEL_POSITION_AUX4                    16
-#define MA_PA_CHANNEL_POSITION_AUX5                    17
-#define MA_PA_CHANNEL_POSITION_AUX6                    18
-#define MA_PA_CHANNEL_POSITION_AUX7                    19
-#define MA_PA_CHANNEL_POSITION_AUX8                    20
-#define MA_PA_CHANNEL_POSITION_AUX9                    21
-#define MA_PA_CHANNEL_POSITION_AUX10                   22
-#define MA_PA_CHANNEL_POSITION_AUX11                   23
-#define MA_PA_CHANNEL_POSITION_AUX12                   24
-#define MA_PA_CHANNEL_POSITION_AUX13                   25
-#define MA_PA_CHANNEL_POSITION_AUX14                   26
-#define MA_PA_CHANNEL_POSITION_AUX15                   27
-#define MA_PA_CHANNEL_POSITION_AUX16                   28
-#define MA_PA_CHANNEL_POSITION_AUX17                   29
-#define MA_PA_CHANNEL_POSITION_AUX18                   30
-#define MA_PA_CHANNEL_POSITION_AUX19                   31
-#define MA_PA_CHANNEL_POSITION_AUX20                   32
-#define MA_PA_CHANNEL_POSITION_AUX21                   33
-#define MA_PA_CHANNEL_POSITION_AUX22                   34
-#define MA_PA_CHANNEL_POSITION_AUX23                   35
-#define MA_PA_CHANNEL_POSITION_AUX24                   36
-#define MA_PA_CHANNEL_POSITION_AUX25                   37
-#define MA_PA_CHANNEL_POSITION_AUX26                   38
-#define MA_PA_CHANNEL_POSITION_AUX27                   39
-#define MA_PA_CHANNEL_POSITION_AUX28                   40
-#define MA_PA_CHANNEL_POSITION_AUX29                   41
-#define MA_PA_CHANNEL_POSITION_AUX30                   42
-#define MA_PA_CHANNEL_POSITION_AUX31                   43
-#define MA_PA_CHANNEL_POSITION_TOP_CENTER              44
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT          45
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT         46
-#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER        47
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT           48
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT          49
-#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER         50
-#define MA_PA_CHANNEL_POSITION_LEFT                    MA_PA_CHANNEL_POSITION_FRONT_LEFT
-#define MA_PA_CHANNEL_POSITION_RIGHT                   MA_PA_CHANNEL_POSITION_FRONT_RIGHT
-#define MA_PA_CHANNEL_POSITION_CENTER                  MA_PA_CHANNEL_POSITION_FRONT_CENTER
-#define MA_PA_CHANNEL_POSITION_SUBWOOFER               MA_PA_CHANNEL_POSITION_LFE
-
-typedef int ma_pa_channel_map_def_t;
-#define MA_PA_CHANNEL_MAP_AIFF                         0
-#define MA_PA_CHANNEL_MAP_ALSA                         1
-#define MA_PA_CHANNEL_MAP_AUX                          2
-#define MA_PA_CHANNEL_MAP_WAVEEX                       3
-#define MA_PA_CHANNEL_MAP_OSS                          4
-#define MA_PA_CHANNEL_MAP_DEFAULT                      MA_PA_CHANNEL_MAP_AIFF
-
-typedef int ma_pa_sample_format_t;
-#define MA_PA_SAMPLE_INVALID                           -1
-#define MA_PA_SAMPLE_U8                                0
-#define MA_PA_SAMPLE_ALAW                              1
-#define MA_PA_SAMPLE_ULAW                              2
-#define MA_PA_SAMPLE_S16LE                             3
-#define MA_PA_SAMPLE_S16BE                             4
-#define MA_PA_SAMPLE_FLOAT32LE                         5
-#define MA_PA_SAMPLE_FLOAT32BE                         6
-#define MA_PA_SAMPLE_S32LE                             7
-#define MA_PA_SAMPLE_S32BE                             8
-#define MA_PA_SAMPLE_S24LE                             9
-#define MA_PA_SAMPLE_S24BE                             10
-#define MA_PA_SAMPLE_S24_32LE                          11
-#define MA_PA_SAMPLE_S24_32BE                          12
-
-typedef struct ma_pa_mainloop           ma_pa_mainloop;
-typedef struct ma_pa_threaded_mainloop  ma_pa_threaded_mainloop;
-typedef struct ma_pa_mainloop_api       ma_pa_mainloop_api;
-typedef struct ma_pa_context            ma_pa_context;
-typedef struct ma_pa_operation          ma_pa_operation;
-typedef struct ma_pa_stream             ma_pa_stream;
-typedef struct ma_pa_spawn_api          ma_pa_spawn_api;
-
-typedef struct
-{
-    ma_uint32 maxlength;
-    ma_uint32 tlength;
-    ma_uint32 prebuf;
-    ma_uint32 minreq;
-    ma_uint32 fragsize;
-} ma_pa_buffer_attr;
-
-typedef struct
-{
-    ma_uint8 channels;
-    ma_pa_channel_position_t map[MA_PA_CHANNELS_MAX];
-} ma_pa_channel_map;
-
-typedef struct
-{
-    ma_uint8 channels;
-    ma_uint32 values[MA_PA_CHANNELS_MAX];
-} ma_pa_cvolume;
-
-typedef struct
-{
-    ma_pa_sample_format_t format;
-    ma_uint32 rate;
-    ma_uint8 channels;
-} ma_pa_sample_spec;
-
-typedef struct
-{
-    const char* name;
-    ma_uint32 index;
-    const char* description;
-    ma_pa_sample_spec sample_spec;
-    ma_pa_channel_map channel_map;
-    ma_uint32 owner_module;
-    ma_pa_cvolume volume;
-    int mute;
-    ma_uint32 monitor_source;
-    const char* monitor_source_name;
-    ma_uint64 latency;
-    const char* driver;
-    ma_pa_sink_flags_t flags;
-    void* proplist;
-    ma_uint64 configured_latency;
-    ma_uint32 base_volume;
-    ma_pa_sink_state_t state;
-    ma_uint32 n_volume_steps;
-    ma_uint32 card;
-    ma_uint32 n_ports;
-    void** ports;
-    void* active_port;
-    ma_uint8 n_formats;
-    void** formats;
-} ma_pa_sink_info;
-
-typedef struct
-{
-    const char *name;
-    ma_uint32 index;
-    const char *description;
-    ma_pa_sample_spec sample_spec;
-    ma_pa_channel_map channel_map;
-    ma_uint32 owner_module;
-    ma_pa_cvolume volume;
-    int mute;
-    ma_uint32 monitor_of_sink;
-    const char *monitor_of_sink_name;
-    ma_uint64 latency;
-    const char *driver;
-    ma_pa_source_flags_t flags;
-    void* proplist;
-    ma_uint64 configured_latency;
-    ma_uint32 base_volume;
-    ma_pa_source_state_t state;
-    ma_uint32 n_volume_steps;
-    ma_uint32 card;
-    ma_uint32 n_ports;
-    void** ports;
-    void* active_port;
-    ma_uint8 n_formats;
-    void** formats;
-} ma_pa_source_info;
-
-typedef void (* ma_pa_context_notify_cb_t)(ma_pa_context* c, void* userdata);
-typedef void (* ma_pa_sink_info_cb_t)     (ma_pa_context* c, const ma_pa_sink_info* i, int eol, void* userdata);
-typedef void (* ma_pa_source_info_cb_t)   (ma_pa_context* c, const ma_pa_source_info* i, int eol, void* userdata);
-typedef void (* ma_pa_stream_success_cb_t)(ma_pa_stream* s, int success, void* userdata);
-typedef void (* ma_pa_stream_request_cb_t)(ma_pa_stream* s, size_t nbytes, void* userdata);
-typedef void (* ma_pa_free_cb_t)          (void* p);
-#endif
-
-
-typedef ma_pa_mainloop*          (* ma_pa_mainloop_new_proc)                   (void);
-typedef void                     (* ma_pa_mainloop_free_proc)                  (ma_pa_mainloop* m);
-typedef void                     (* ma_pa_mainloop_quit_proc)                  (ma_pa_mainloop* m, int retval);
-typedef ma_pa_mainloop_api*      (* ma_pa_mainloop_get_api_proc)               (ma_pa_mainloop* m);
-typedef int                      (* ma_pa_mainloop_iterate_proc)               (ma_pa_mainloop* m, int block, int* retval);
-typedef void                     (* ma_pa_mainloop_wakeup_proc)                (ma_pa_mainloop* m);
-typedef ma_pa_threaded_mainloop* (* ma_pa_threaded_mainloop_new_proc)          (void);
-typedef void                     (* ma_pa_threaded_mainloop_free_proc)         (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_start_proc)        (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_stop_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_lock_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_unlock_proc)       (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_wait_proc)         (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_signal_proc)       (ma_pa_threaded_mainloop* m, int wait_for_accept);
-typedef void                     (* ma_pa_threaded_mainloop_accept_proc)       (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_get_retval_proc)   (ma_pa_threaded_mainloop* m);
-typedef ma_pa_mainloop_api*      (* ma_pa_threaded_mainloop_get_api_proc)      (ma_pa_threaded_mainloop* m);
-typedef int                      (* ma_pa_threaded_mainloop_in_thread_proc)    (ma_pa_threaded_mainloop* m);
-typedef void                     (* ma_pa_threaded_mainloop_set_name_proc)     (ma_pa_threaded_mainloop* m, const char* name);
-typedef ma_pa_context*           (* ma_pa_context_new_proc)                    (ma_pa_mainloop_api* mainloop, const char* name);
-typedef void                     (* ma_pa_context_unref_proc)                  (ma_pa_context* c);
-typedef int                      (* ma_pa_context_connect_proc)                (ma_pa_context* c, const char* server, ma_pa_context_flags_t flags, const ma_pa_spawn_api* api);
-typedef void                     (* ma_pa_context_disconnect_proc)             (ma_pa_context* c);
-typedef void                     (* ma_pa_context_set_state_callback_proc)     (ma_pa_context* c, ma_pa_context_notify_cb_t cb, void* userdata);
-typedef ma_pa_context_state_t    (* ma_pa_context_get_state_proc)              (ma_pa_context* c);
-typedef ma_pa_operation*         (* ma_pa_context_get_sink_info_list_proc)     (ma_pa_context* c, ma_pa_sink_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_source_info_list_proc)   (ma_pa_context* c, ma_pa_source_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_sink_info_by_name_proc)  (ma_pa_context* c, const char* name, ma_pa_sink_info_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_context_get_source_info_by_name_proc)(ma_pa_context* c, const char* name, ma_pa_source_info_cb_t cb, void* userdata);
-typedef void                     (* ma_pa_operation_unref_proc)                (ma_pa_operation* o);
-typedef ma_pa_operation_state_t  (* ma_pa_operation_get_state_proc)            (ma_pa_operation* o);
-typedef ma_pa_channel_map*       (* ma_pa_channel_map_init_extend_proc)        (ma_pa_channel_map* m, unsigned channels, ma_pa_channel_map_def_t def);
-typedef int                      (* ma_pa_channel_map_valid_proc)              (const ma_pa_channel_map* m);
-typedef int                      (* ma_pa_channel_map_compatible_proc)         (const ma_pa_channel_map* m, const ma_pa_sample_spec* ss);
-typedef ma_pa_stream*            (* ma_pa_stream_new_proc)                     (ma_pa_context* c, const char* name, const ma_pa_sample_spec* ss, const ma_pa_channel_map* map);
-typedef void                     (* ma_pa_stream_unref_proc)                   (ma_pa_stream* s);
-typedef int                      (* ma_pa_stream_connect_playback_proc)        (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags, const ma_pa_cvolume* volume, ma_pa_stream* sync_stream);
-typedef int                      (* ma_pa_stream_connect_record_proc)          (ma_pa_stream* s, const char* dev, const ma_pa_buffer_attr* attr, ma_pa_stream_flags_t flags);
-typedef int                      (* ma_pa_stream_disconnect_proc)              (ma_pa_stream* s);
-typedef ma_pa_stream_state_t     (* ma_pa_stream_get_state_proc)               (ma_pa_stream* s);
-typedef const ma_pa_sample_spec* (* ma_pa_stream_get_sample_spec_proc)         (ma_pa_stream* s);
-typedef const ma_pa_channel_map* (* ma_pa_stream_get_channel_map_proc)         (ma_pa_stream* s);
-typedef const ma_pa_buffer_attr* (* ma_pa_stream_get_buffer_attr_proc)         (ma_pa_stream* s);
-typedef ma_pa_operation*         (* ma_pa_stream_set_buffer_attr_proc)         (ma_pa_stream* s, const ma_pa_buffer_attr* attr, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef const char*              (* ma_pa_stream_get_device_name_proc)         (ma_pa_stream* s);
-typedef void                     (* ma_pa_stream_set_write_callback_proc)      (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata);
-typedef void                     (* ma_pa_stream_set_read_callback_proc)       (ma_pa_stream* s, ma_pa_stream_request_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_flush_proc)                   (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_drain_proc)                   (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef int                      (* ma_pa_stream_is_corked_proc)               (ma_pa_stream* s);
-typedef ma_pa_operation*         (* ma_pa_stream_cork_proc)                    (ma_pa_stream* s, int b, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef ma_pa_operation*         (* ma_pa_stream_trigger_proc)                 (ma_pa_stream* s, ma_pa_stream_success_cb_t cb, void* userdata);
-typedef int                      (* ma_pa_stream_begin_write_proc)             (ma_pa_stream* s, void** data, size_t* nbytes);
-typedef int                      (* ma_pa_stream_write_proc)                   (ma_pa_stream* s, const void* data, size_t nbytes, ma_pa_free_cb_t free_cb, int64_t offset, ma_pa_seek_mode_t seek);
-typedef int                      (* ma_pa_stream_peek_proc)                    (ma_pa_stream* s, const void** data, size_t* nbytes);
-typedef int                      (* ma_pa_stream_drop_proc)                    (ma_pa_stream* s);
-typedef size_t                   (* ma_pa_stream_writable_size_proc)           (ma_pa_stream* s);
-typedef size_t                   (* ma_pa_stream_readable_size_proc)           (ma_pa_stream* s);
-
-typedef struct
-{
-    ma_uint32 count;
-    ma_uint32 capacity;
-    ma_device_info* pInfo;
-} ma_pulse_device_enum_data;
-
-static ma_result ma_result_from_pulse(int result)
-{
-    if (result < 0) {
-        return MA_ERROR;
-    }
-
-    switch (result) {
-        case MA_PA_OK:           return MA_SUCCESS;
-        case MA_PA_ERR_ACCESS:   return MA_ACCESS_DENIED;
-        case MA_PA_ERR_INVALID:  return MA_INVALID_ARGS;
-        case MA_PA_ERR_NOENTITY: return MA_NO_DEVICE;
-        default:                 return MA_ERROR;
-    }
-}
-
-#if 0
-static ma_pa_sample_format_t ma_format_to_pulse(ma_format format)
-{
-    if (ma_is_little_endian()) {
-        switch (format) {
-            case ma_format_s16: return MA_PA_SAMPLE_S16LE;
-            case ma_format_s24: return MA_PA_SAMPLE_S24LE;
-            case ma_format_s32: return MA_PA_SAMPLE_S32LE;
-            case ma_format_f32: return MA_PA_SAMPLE_FLOAT32LE;
-            default: break;
-        }
-    } else {
-        switch (format) {
-            case ma_format_s16: return MA_PA_SAMPLE_S16BE;
-            case ma_format_s24: return MA_PA_SAMPLE_S24BE;
-            case ma_format_s32: return MA_PA_SAMPLE_S32BE;
-            case ma_format_f32: return MA_PA_SAMPLE_FLOAT32BE;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (format) {
-        case ma_format_u8: return MA_PA_SAMPLE_U8;
-        default: return MA_PA_SAMPLE_INVALID;
-    }
-}
-#endif
-
-static ma_format ma_format_from_pulse(ma_pa_sample_format_t format)
-{
-    if (ma_is_little_endian()) {
-        switch (format) {
-            case MA_PA_SAMPLE_S16LE:     return ma_format_s16;
-            case MA_PA_SAMPLE_S24LE:     return ma_format_s24;
-            case MA_PA_SAMPLE_S32LE:     return ma_format_s32;
-            case MA_PA_SAMPLE_FLOAT32LE: return ma_format_f32;
-            default: break;
-        }
-    } else {
-        switch (format) {
-            case MA_PA_SAMPLE_S16BE:     return ma_format_s16;
-            case MA_PA_SAMPLE_S24BE:     return ma_format_s24;
-            case MA_PA_SAMPLE_S32BE:     return ma_format_s32;
-            case MA_PA_SAMPLE_FLOAT32BE: return ma_format_f32;
-            default: break;
-        }
-    }
-
-    /* Endian agnostic. */
-    switch (format) {
-        case MA_PA_SAMPLE_U8: return ma_format_u8;
-        default: return ma_format_unknown;
-    }
-}
-
-static ma_channel ma_channel_position_from_pulse(ma_pa_channel_position_t position)
-{
-    switch (position)
-    {
-        case MA_PA_CHANNEL_POSITION_INVALID:               return MA_CHANNEL_NONE;
-        case MA_PA_CHANNEL_POSITION_MONO:                  return MA_CHANNEL_MONO;
-        case MA_PA_CHANNEL_POSITION_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case MA_PA_CHANNEL_POSITION_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case MA_PA_CHANNEL_POSITION_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case MA_PA_CHANNEL_POSITION_REAR_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case MA_PA_CHANNEL_POSITION_REAR_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case MA_PA_CHANNEL_POSITION_REAR_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case MA_PA_CHANNEL_POSITION_LFE:                   return MA_CHANNEL_LFE;
-        case MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case MA_PA_CHANNEL_POSITION_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case MA_PA_CHANNEL_POSITION_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case MA_PA_CHANNEL_POSITION_AUX0:                  return MA_CHANNEL_AUX_0;
-        case MA_PA_CHANNEL_POSITION_AUX1:                  return MA_CHANNEL_AUX_1;
-        case MA_PA_CHANNEL_POSITION_AUX2:                  return MA_CHANNEL_AUX_2;
-        case MA_PA_CHANNEL_POSITION_AUX3:                  return MA_CHANNEL_AUX_3;
-        case MA_PA_CHANNEL_POSITION_AUX4:                  return MA_CHANNEL_AUX_4;
-        case MA_PA_CHANNEL_POSITION_AUX5:                  return MA_CHANNEL_AUX_5;
-        case MA_PA_CHANNEL_POSITION_AUX6:                  return MA_CHANNEL_AUX_6;
-        case MA_PA_CHANNEL_POSITION_AUX7:                  return MA_CHANNEL_AUX_7;
-        case MA_PA_CHANNEL_POSITION_AUX8:                  return MA_CHANNEL_AUX_8;
-        case MA_PA_CHANNEL_POSITION_AUX9:                  return MA_CHANNEL_AUX_9;
-        case MA_PA_CHANNEL_POSITION_AUX10:                 return MA_CHANNEL_AUX_10;
-        case MA_PA_CHANNEL_POSITION_AUX11:                 return MA_CHANNEL_AUX_11;
-        case MA_PA_CHANNEL_POSITION_AUX12:                 return MA_CHANNEL_AUX_12;
-        case MA_PA_CHANNEL_POSITION_AUX13:                 return MA_CHANNEL_AUX_13;
-        case MA_PA_CHANNEL_POSITION_AUX14:                 return MA_CHANNEL_AUX_14;
-        case MA_PA_CHANNEL_POSITION_AUX15:                 return MA_CHANNEL_AUX_15;
-        case MA_PA_CHANNEL_POSITION_AUX16:                 return MA_CHANNEL_AUX_16;
-        case MA_PA_CHANNEL_POSITION_AUX17:                 return MA_CHANNEL_AUX_17;
-        case MA_PA_CHANNEL_POSITION_AUX18:                 return MA_CHANNEL_AUX_18;
-        case MA_PA_CHANNEL_POSITION_AUX19:                 return MA_CHANNEL_AUX_19;
-        case MA_PA_CHANNEL_POSITION_AUX20:                 return MA_CHANNEL_AUX_20;
-        case MA_PA_CHANNEL_POSITION_AUX21:                 return MA_CHANNEL_AUX_21;
-        case MA_PA_CHANNEL_POSITION_AUX22:                 return MA_CHANNEL_AUX_22;
-        case MA_PA_CHANNEL_POSITION_AUX23:                 return MA_CHANNEL_AUX_23;
-        case MA_PA_CHANNEL_POSITION_AUX24:                 return MA_CHANNEL_AUX_24;
-        case MA_PA_CHANNEL_POSITION_AUX25:                 return MA_CHANNEL_AUX_25;
-        case MA_PA_CHANNEL_POSITION_AUX26:                 return MA_CHANNEL_AUX_26;
-        case MA_PA_CHANNEL_POSITION_AUX27:                 return MA_CHANNEL_AUX_27;
-        case MA_PA_CHANNEL_POSITION_AUX28:                 return MA_CHANNEL_AUX_28;
-        case MA_PA_CHANNEL_POSITION_AUX29:                 return MA_CHANNEL_AUX_29;
-        case MA_PA_CHANNEL_POSITION_AUX30:                 return MA_CHANNEL_AUX_30;
-        case MA_PA_CHANNEL_POSITION_AUX31:                 return MA_CHANNEL_AUX_31;
-        case MA_PA_CHANNEL_POSITION_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        case MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        default: return MA_CHANNEL_NONE;
-    }
-}
-
-#if 0
-static ma_pa_channel_position_t ma_channel_position_to_pulse(ma_channel position)
-{
-    switch (position)
-    {
-        case MA_CHANNEL_NONE:               return MA_PA_CHANNEL_POSITION_INVALID;
-        case MA_CHANNEL_FRONT_LEFT:         return MA_PA_CHANNEL_POSITION_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return MA_PA_CHANNEL_POSITION_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return MA_PA_CHANNEL_POSITION_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return MA_PA_CHANNEL_POSITION_LFE;
-        case MA_CHANNEL_BACK_LEFT:          return MA_PA_CHANNEL_POSITION_REAR_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return MA_PA_CHANNEL_POSITION_REAR_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return MA_PA_CHANNEL_POSITION_REAR_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return MA_PA_CHANNEL_POSITION_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return MA_PA_CHANNEL_POSITION_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return MA_PA_CHANNEL_POSITION_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT;
-        case MA_CHANNEL_19:                 return MA_PA_CHANNEL_POSITION_AUX18;
-        case MA_CHANNEL_20:                 return MA_PA_CHANNEL_POSITION_AUX19;
-        case MA_CHANNEL_21:                 return MA_PA_CHANNEL_POSITION_AUX20;
-        case MA_CHANNEL_22:                 return MA_PA_CHANNEL_POSITION_AUX21;
-        case MA_CHANNEL_23:                 return MA_PA_CHANNEL_POSITION_AUX22;
-        case MA_CHANNEL_24:                 return MA_PA_CHANNEL_POSITION_AUX23;
-        case MA_CHANNEL_25:                 return MA_PA_CHANNEL_POSITION_AUX24;
-        case MA_CHANNEL_26:                 return MA_PA_CHANNEL_POSITION_AUX25;
-        case MA_CHANNEL_27:                 return MA_PA_CHANNEL_POSITION_AUX26;
-        case MA_CHANNEL_28:                 return MA_PA_CHANNEL_POSITION_AUX27;
-        case MA_CHANNEL_29:                 return MA_PA_CHANNEL_POSITION_AUX28;
-        case MA_CHANNEL_30:                 return MA_PA_CHANNEL_POSITION_AUX29;
-        case MA_CHANNEL_31:                 return MA_PA_CHANNEL_POSITION_AUX30;
-        case MA_CHANNEL_32:                 return MA_PA_CHANNEL_POSITION_AUX31;
-        default: return (ma_pa_channel_position_t)position;
-    }
-}
-#endif
-
-static ma_result ma_wait_for_operation__pulse(ma_context* pContext, ma_pa_operation* pOP)
-{
-    int resultPA;
-    ma_pa_operation_state_t state;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pOP != NULL);
-
-    for (;;) {
-        state = ((ma_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP);
-        if (state != MA_PA_OPERATION_RUNNING) {
-            break;  /* Done. */
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_wait_for_operation_and_unref__pulse(ma_context* pContext, ma_pa_operation* pOP)
-{
-    ma_result result;
-
-    if (pOP == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_wait_for_operation__pulse(pContext, pOP);
-    ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-    return result;
-}
-
-static ma_result ma_context_wait_for_pa_context_to_connect__pulse(ma_context* pContext)
-{
-    int resultPA;
-    ma_pa_context_state_t state;
-
-    for (;;) {
-        state = ((ma_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)((ma_pa_context*)pContext->pulse.pPulseContext);
-        if (state == MA_PA_CONTEXT_READY) {
-            break;  /* Done. */
-        }
-
-        if (state == MA_PA_CONTEXT_FAILED || state == MA_PA_CONTEXT_TERMINATED) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio context.", MA_ERROR);
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    /* Should never get here. */
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_wait_for_pa_stream_to_connect__pulse(ma_context* pContext, ma_pa_stream* pStream)
-{
-    int resultPA;
-    ma_pa_stream_state_t state;
-
-    for (;;) {
-        state = ((ma_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)(pStream);
-        if (state == MA_PA_STREAM_READY) {
-            break;  /* Done. */
-        }
-
-        if (state == MA_PA_STREAM_FAILED || state == MA_PA_STREAM_TERMINATED) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio stream.", MA_ERROR);
-        }
-
-        resultPA = ((ma_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            return ma_result_from_pulse(resultPA);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static void ma_device_sink_info_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_pa_sink_info* pInfoOut;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pInfoOut = (ma_pa_sink_info*)pUserData;
-    MA_ASSERT(pInfoOut != NULL);
-
-    *pInfoOut = *pInfo;
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_source_info_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_pa_source_info* pInfoOut;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pInfoOut = (ma_pa_source_info*)pUserData;
-    MA_ASSERT(pInfoOut != NULL);
-
-    *pInfoOut = *pInfo;
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_sink_name_callback(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_device* pDevice;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), pInfo->description, (size_t)-1);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_device_source_name_callback(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_device* pDevice;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), pInfo->description, (size_t)-1);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-
-static ma_result ma_context_get_sink_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_sink_info* pSinkInfo)
-{
-    ma_pa_operation* pOP;
-
-    pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_sink_info_callback, pSinkInfo);
-    if (pOP == NULL) {
-        return MA_ERROR;
-    }
-
-    return ma_wait_for_operation_and_unref__pulse(pContext, pOP);
-}
-
-static ma_result ma_context_get_source_info__pulse(ma_context* pContext, const char* pDeviceName, ma_pa_source_info* pSourceInfo)
-{
-    ma_pa_operation* pOP;
-
-    pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pContext->pulse.pPulseContext, pDeviceName, ma_device_source_info_callback, pSourceInfo);
-    if (pOP == NULL) {
-        return MA_ERROR;
-    }
-
-    return ma_wait_for_operation_and_unref__pulse(pContext, pOP);;
-}
-
-static ma_result ma_context_get_default_device_index__pulse(ma_context* pContext, ma_device_type deviceType, ma_uint32* pIndex)
-{
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pIndex   != NULL);
-
-    if (pIndex != NULL) {
-        *pIndex = (ma_uint32)-1;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        ma_pa_sink_info sinkInfo;
-        result = ma_context_get_sink_info__pulse(pContext, NULL, &sinkInfo);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (pIndex != NULL) {
-            *pIndex = sinkInfo.index;
-        }
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        ma_pa_source_info sourceInfo;
-        result = ma_context_get_source_info__pulse(pContext, NULL, &sourceInfo);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (pIndex != NULL) {
-            *pIndex = sourceInfo.index;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-typedef struct
-{
-    ma_context* pContext;
-    ma_enum_devices_callback_proc callback;
-    void* pUserData;
-    ma_bool32 isTerminated;
-    ma_uint32 defaultDeviceIndexPlayback;
-    ma_uint32 defaultDeviceIndexCapture;
-} ma_context_enumerate_devices_callback_data__pulse;
-
-static void ma_context_enumerate_devices_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pSinkInfo, int endOfList, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData;
-    ma_device_info deviceInfo;
-
-    MA_ASSERT(pData != NULL);
-
-    if (endOfList || pData->isTerminated) {
-        return;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* The name from PulseAudio is the ID for miniaudio. */
-    if (pSinkInfo->name != NULL) {
-        ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSinkInfo->name, (size_t)-1);
-    }
-
-    /* The description from PulseAudio is the name for miniaudio. */
-    if (pSinkInfo->description != NULL) {
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSinkInfo->description, (size_t)-1);
-    }
-
-    if (pSinkInfo->index == pData->defaultDeviceIndexPlayback) {
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_playback, &deviceInfo, pData->pUserData);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_context_enumerate_devices_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pSourceInfo, int endOfList, void* pUserData)
-{
-    ma_context_enumerate_devices_callback_data__pulse* pData = (ma_context_enumerate_devices_callback_data__pulse*)pUserData;
-    ma_device_info deviceInfo;
-
-    MA_ASSERT(pData != NULL);
-
-    if (endOfList || pData->isTerminated) {
-        return;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* The name from PulseAudio is the ID for miniaudio. */
-    if (pSourceInfo->name != NULL) {
-        ma_strncpy_s(deviceInfo.id.pulse, sizeof(deviceInfo.id.pulse), pSourceInfo->name, (size_t)-1);
-    }
-
-    /* The description from PulseAudio is the name for miniaudio. */
-    if (pSourceInfo->description != NULL) {
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), pSourceInfo->description, (size_t)-1);
-    }
-
-    if (pSourceInfo->index == pData->defaultDeviceIndexCapture) {
-        deviceInfo.isDefault = MA_TRUE;
-    }
-
-    pData->isTerminated = !pData->callback(pData->pContext, ma_device_type_capture, &deviceInfo, pData->pUserData);
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static ma_result ma_context_enumerate_devices__pulse(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result = MA_SUCCESS;
-    ma_context_enumerate_devices_callback_data__pulse callbackData;
-    ma_pa_operation* pOP = NULL;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    callbackData.pContext = pContext;
-    callbackData.callback = callback;
-    callbackData.pUserData = pUserData;
-    callbackData.isTerminated = MA_FALSE;
-    callbackData.defaultDeviceIndexPlayback = (ma_uint32)-1;
-    callbackData.defaultDeviceIndexCapture  = (ma_uint32)-1;
-
-    /* We need to get the index of the default devices. */
-    ma_context_get_default_device_index__pulse(pContext, ma_device_type_playback, &callbackData.defaultDeviceIndexPlayback);
-    ma_context_get_default_device_index__pulse(pContext, ma_device_type_capture,  &callbackData.defaultDeviceIndexCapture);
-
-    /* Playback. */
-    if (!callbackData.isTerminated) {
-        pOP = ((ma_pa_context_get_sink_info_list_proc)pContext->pulse.pa_context_get_sink_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_sink_callback__pulse, &callbackData);
-        if (pOP == NULL) {
-            result = MA_ERROR;
-            goto done;
-        }
-
-        result = ma_wait_for_operation__pulse(pContext, pOP);
-        ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-        if (result != MA_SUCCESS) {
-            goto done;
-        }
-    }
-
-
-    /* Capture. */
-    if (!callbackData.isTerminated) {
-        pOP = ((ma_pa_context_get_source_info_list_proc)pContext->pulse.pa_context_get_source_info_list)((ma_pa_context*)(pContext->pulse.pPulseContext), ma_context_enumerate_devices_source_callback__pulse, &callbackData);
-        if (pOP == NULL) {
-            result = MA_ERROR;
-            goto done;
-        }
-
-        result = ma_wait_for_operation__pulse(pContext, pOP);
-        ((ma_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP);
-
-        if (result != MA_SUCCESS) {
-            goto done;
-        }
-    }
-
-done:
-    return result;
-}
-
-
-typedef struct
-{
-    ma_device_info* pDeviceInfo;
-    ma_uint32 defaultDeviceIndex;
-    ma_bool32 foundDevice;
-} ma_context_get_device_info_callback_data__pulse;
-
-static void ma_context_get_device_info_sink_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_sink_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    MA_ASSERT(pData != NULL);
-    pData->foundDevice = MA_TRUE;
-
-    if (pInfo->name != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1);
-    }
-
-    if (pInfo->description != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1);
-    }
-
-    /*
-    We're just reporting a single data format here. I think technically PulseAudio might support
-    all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to
-    report the "native" device format.
-    */
-    pData->pDeviceInfo->nativeDataFormats[0].format     = ma_format_from_pulse(pInfo->sample_spec.format);
-    pData->pDeviceInfo->nativeDataFormats[0].channels   = pInfo->sample_spec.channels;
-    pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate;
-    pData->pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pData->pDeviceInfo->nativeDataFormatCount = 1;
-
-    if (pData->defaultDeviceIndex == pInfo->index) {
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static void ma_context_get_device_info_source_callback__pulse(ma_pa_context* pPulseContext, const ma_pa_source_info* pInfo, int endOfList, void* pUserData)
-{
-    ma_context_get_device_info_callback_data__pulse* pData = (ma_context_get_device_info_callback_data__pulse*)pUserData;
-
-    if (endOfList > 0) {
-        return;
-    }
-
-    MA_ASSERT(pData != NULL);
-    pData->foundDevice = MA_TRUE;
-
-    if (pInfo->name != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1);
-    }
-
-    if (pInfo->description != NULL) {
-        ma_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pInfo->description, (size_t)-1);
-    }
-
-    /*
-    We're just reporting a single data format here. I think technically PulseAudio might support
-    all formats, but I don't trust that PulseAudio will do *anything* right, so I'm just going to
-    report the "native" device format.
-    */
-    pData->pDeviceInfo->nativeDataFormats[0].format     = ma_format_from_pulse(pInfo->sample_spec.format);
-    pData->pDeviceInfo->nativeDataFormats[0].channels   = pInfo->sample_spec.channels;
-    pData->pDeviceInfo->nativeDataFormats[0].sampleRate = pInfo->sample_spec.rate;
-    pData->pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pData->pDeviceInfo->nativeDataFormatCount = 1;
-
-    if (pData->defaultDeviceIndex == pInfo->index) {
-        pData->pDeviceInfo->isDefault = MA_TRUE;
-    }
-
-    (void)pPulseContext; /* Unused. */
-}
-
-static ma_result ma_context_get_device_info__pulse(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result = MA_SUCCESS;
-    ma_context_get_device_info_callback_data__pulse callbackData;
-    ma_pa_operation* pOP = NULL;
-
-    MA_ASSERT(pContext != NULL);
-
-    callbackData.pDeviceInfo = pDeviceInfo;
-    callbackData.foundDevice = MA_FALSE;
-
-    result = ma_context_get_default_device_index__pulse(pContext, deviceType, &callbackData.defaultDeviceIndex);
-
-    if (deviceType == ma_device_type_playback) {
-        pOP = ((ma_pa_context_get_sink_info_by_name_proc)pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_sink_callback__pulse, &callbackData);
-    } else {
-        pOP = ((ma_pa_context_get_source_info_by_name_proc)pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)(pContext->pulse.pPulseContext), pDeviceID->pulse, ma_context_get_device_info_source_callback__pulse, &callbackData);
-    }
-
-    if (pOP != NULL) {
-        ma_wait_for_operation_and_unref__pulse(pContext, pOP);
-    } else {
-        result = MA_ERROR;
-        goto done;
-    }
-
-    if (!callbackData.foundDevice) {
-        result = MA_NO_DEVICE;
-        goto done;
-    }
-
-done:
-    return result;
-}
-
-static ma_result ma_device_uninit__pulse(ma_device* pDevice)
-{
-    ma_context* pContext;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        ((ma_pa_stream_unref_proc)pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-
-    if (pDevice->type == ma_device_type_duplex) {
-        ma_duplex_rb_uninit(&pDevice->duplexRB);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_pa_buffer_attr ma_device__pa_buffer_attr_new(ma_uint32 periodSizeInFrames, ma_uint32 periods, const ma_pa_sample_spec* ss)
-{
-    ma_pa_buffer_attr attr;
-    attr.maxlength = periodSizeInFrames * periods * ma_get_bytes_per_frame(ma_format_from_pulse(ss->format), ss->channels);
-    attr.tlength   = attr.maxlength / periods;
-    attr.prebuf    = (ma_uint32)-1;
-    attr.minreq    = (ma_uint32)-1;
-    attr.fragsize  = attr.maxlength / periods;
-
-    return attr;
-}
-
-static ma_pa_stream* ma_context__pa_stream_new__pulse(ma_context* pContext, const char* pStreamName, const ma_pa_sample_spec* ss, const ma_pa_channel_map* cmap)
-{
-    static int g_StreamCounter = 0;
-    char actualStreamName[256];
-
-    if (pStreamName != NULL) {
-        ma_strncpy_s(actualStreamName, sizeof(actualStreamName), pStreamName, (size_t)-1);
-    } else {
-        ma_strcpy_s(actualStreamName, sizeof(actualStreamName), "miniaudio:");
-        ma_itoa_s(g_StreamCounter, actualStreamName + 8, sizeof(actualStreamName)-8, 10);  /* 8 = strlen("miniaudio:") */
-    }
-    g_StreamCounter += 1;
-
-    return ((ma_pa_stream_new_proc)pContext->pulse.pa_stream_new)((ma_pa_context*)pContext->pulse.pPulseContext, actualStreamName, ss, cmap);
-}
-
-
-static void ma_device_on_read__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_uint32 bpf;
-    ma_uint64 frameCount;
-    ma_uint64 framesProcessed;
-
-    MA_ASSERT(pDevice != NULL);
-
-    bpf = ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    frameCount = byteCount / bpf;
-    framesProcessed = 0;
-
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED && framesProcessed < frameCount) {
-        const void* pMappedPCMFrames;
-        size_t bytesMapped;
-        ma_uint64 framesMapped;
-
-        int pulseResult = ((ma_pa_stream_peek_proc)pDevice->pContext->pulse.pa_stream_peek)(pStream, &pMappedPCMFrames, &bytesMapped);
-        if (pulseResult < 0) {
-            break; /* Failed to map. Abort. */
-        }
-
-        framesMapped = bytesMapped / bpf;
-        if (framesMapped > 0) {
-            if (pMappedPCMFrames != NULL) {
-                ma_device_handle_backend_data_callback(pDevice, NULL, pMappedPCMFrames, framesMapped);
-            } else {
-                /* It's a hole. */
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("[PulseAudio] ma_device_on_read__pulse: Hole.\n");
-            #endif
-            }
-
-            pulseResult = ((ma_pa_stream_drop_proc)pDevice->pContext->pulse.pa_stream_drop)(pStream);
-            if (pulseResult < 0) {
-                break;  /* Failed to drop the buffer. */
-            }
-
-            framesProcessed += framesMapped;
-
-        } else {
-            /* Nothing was mapped. Just abort. */
-            break;
-        }
-    }
-}
-
-static ma_result ma_device_write_to_stream__pulse(ma_device* pDevice, ma_pa_stream* pStream, ma_uint64* pFramesProcessed)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint64 framesProcessed = 0;
-    size_t bytesMapped;
-    ma_uint32 bpf;
-    ma_uint32 deviceState;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pStream != NULL);
-
-    bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    deviceState = ma_device_get_state(pDevice);
-
-    bytesMapped = ((ma_pa_stream_writable_size_proc)pDevice->pContext->pulse.pa_stream_writable_size)(pStream);
-    if (bytesMapped != (size_t)-1) {
-        if (bytesMapped > 0) {
-            ma_uint64 framesMapped;
-            void* pMappedPCMFrames;
-            int pulseResult = ((ma_pa_stream_begin_write_proc)pDevice->pContext->pulse.pa_stream_begin_write)(pStream, &pMappedPCMFrames, &bytesMapped);
-            if (pulseResult < 0) {
-                result = ma_result_from_pulse(pulseResult);
-                goto done;
-            }
-
-            framesMapped = bytesMapped / bpf;
-
-            if (deviceState == MA_STATE_STARTED) {
-                ma_device_handle_backend_data_callback(pDevice, pMappedPCMFrames, NULL, framesMapped);
-            } else {
-                /* Device is not started. Don't write anything to it. */
-            }
-
-            pulseResult = ((ma_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)(pStream, pMappedPCMFrames, bytesMapped, NULL, 0, MA_PA_SEEK_RELATIVE);
-            if (pulseResult < 0) {
-                result = ma_result_from_pulse(pulseResult);
-                goto done;  /* Failed to write data to stream. */
-            }
-
-            framesProcessed += framesMapped;
-        } else {
-            result = MA_ERROR;  /* No data available. Abort. */
-            goto done;
-        }
-    } else {
-        result = MA_ERROR;  /* Failed to retrieve the writable size. Abort. */
-        goto done;
-    }
-
-done:
-    if (pFramesProcessed != NULL) {
-        *pFramesProcessed = framesProcessed;
-    }
-
-    return result;
-}
-
-static void ma_device_on_write__pulse(ma_pa_stream* pStream, size_t byteCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_uint32 bpf;
-    ma_uint64 frameCount;
-    ma_uint64 framesProcessed;
-    ma_uint32 deviceState;
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    Don't do anything if the device isn't initialized yet. Yes, this can happen because PulseAudio
-    can fire this callback before the stream has even started. Ridiculous.
-    */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTING && deviceState != MA_STATE_STARTED) {
-        return;
-    }
-
-    bpf = ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    MA_ASSERT(bpf > 0);
-
-    frameCount = byteCount / bpf;
-    framesProcessed = 0;
-
-    while (framesProcessed < frameCount) {
-        ma_uint64 framesProcessedThisIteration;
-
-        /* Don't keep trying to process frames if the device isn't started. */
-        deviceState = ma_device_get_state(pDevice);
-        if (deviceState != MA_STATE_STARTING && deviceState != MA_STATE_STARTED) {
-            break;
-        }
-
-        result = ma_device_write_to_stream__pulse(pDevice, pStream, &framesProcessedThisIteration);
-        if (result != MA_SUCCESS) {
-            break;
-        }
-
-        framesProcessed += framesProcessedThisIteration;
-    }
-}
-
-static ma_result ma_device_init__pulse(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    /*
-    Notes for PulseAudio:
-
-      - We're always using native format/channels/rate regardless of whether or not PulseAudio
-        supports the format directly through their own data conversion system. I'm doing this to
-        reduce as much variability from the PulseAudio side as possible because it's seems to be
-        extremely unreliable at everything it does.
-
-      - When both the period size in frames and milliseconds are 0, we default to miniaudio's
-        default buffer sizes rather than leaving it up to PulseAudio because I don't trust
-        PulseAudio to give us any kind of reasonable latency by default.
-
-      - Do not ever, *ever* forget to use MA_PA_STREAM_ADJUST_LATENCY. If you don't specify this
-        flag, capture mode will just not work properly until you open another PulseAudio app.
-    */
-
-    ma_result result = MA_SUCCESS;
-    int error = 0;
-    const char* devPlayback = NULL;
-    const char* devCapture  = NULL;
-    ma_format format = ma_format_unknown;
-    ma_uint32 channels = 0;
-    ma_uint32 sampleRate = 0;
-    ma_pa_sink_info sinkInfo;
-    ma_pa_source_info sourceInfo;
-    ma_pa_sample_spec ss;
-    ma_pa_channel_map cmap;
-    ma_pa_buffer_attr attr;
-    const ma_pa_sample_spec* pActualSS   = NULL;
-    const ma_pa_channel_map* pActualCMap = NULL;
-    const ma_pa_buffer_attr* pActualAttr = NULL;
-    ma_uint32 iChannel;
-    ma_pa_stream_flags_t streamFlags;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ZERO_OBJECT(&pDevice->pulse);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with the PulseAudio backend. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pConfig->playback.shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pConfig->capture.shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        if (pDescriptorPlayback->pDeviceID != NULL) {
-            devPlayback = pDescriptorPlayback->pDeviceID->pulse;
-        }
-
-        format     = pDescriptorPlayback->format;
-        channels   = pDescriptorPlayback->channels;
-        sampleRate = pDescriptorPlayback->sampleRate;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) {
-        if (pDescriptorCapture->pDeviceID != NULL) {
-            devCapture = pDescriptorCapture->pDeviceID->pulse;
-        }
-        
-        format     = pDescriptorCapture->format;
-        channels   = pDescriptorCapture->channels;
-        sampleRate = pDescriptorCapture->sampleRate;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_context_get_source_info__pulse(pDevice->pContext, devCapture, &sourceInfo);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve source info for capture device.", result);
-            goto on_error0;
-        }
-
-        ss   = sourceInfo.sample_spec;
-        cmap = sourceInfo.channel_map;
-
-        /* We now have enough information to calculate our actual period size in frames. */
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, ss.rate, pConfig->performanceProfile);
-
-        attr = ma_device__pa_buffer_attr_new(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->periodCount, &ss);
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
-    #endif
-
-        pDevice->pulse.pStreamCapture = ma_context__pa_stream_new__pulse(pDevice->pContext, pConfig->pulse.pStreamNameCapture, &ss, &cmap);
-        if (pDevice->pulse.pStreamCapture == NULL) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            goto on_error0;
-        }
-
-
-        /* The callback needs to be set before connecting the stream. */
-        ((ma_pa_stream_set_read_callback_proc)pDevice->pContext->pulse.pa_stream_set_read_callback)((ma_pa_stream*)pDevice->pulse.pStreamCapture, ma_device_on_read__pulse, pDevice);
-
-
-        /* Connect after we've got all of our internal state set up. */
-        streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS;
-        if (devCapture != NULL) {
-            streamFlags |= MA_PA_STREAM_DONT_MOVE;
-        }
-
-        error = ((ma_pa_stream_connect_record_proc)pDevice->pContext->pulse.pa_stream_connect_record)((ma_pa_stream*)pDevice->pulse.pStreamCapture, devCapture, &attr, streamFlags);
-        if (error != MA_PA_OK) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio capture stream.", ma_result_from_pulse(error));
-            goto on_error1;
-        }
-
-        result = ma_context_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, (ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            goto on_error2;
-        }
-
-        /* Internal format. */
-        pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualSS != NULL) {
-            ss = *pActualSS;
-        }
-
-        pDescriptorCapture->format     = ma_format_from_pulse(ss.format);
-        pDescriptorCapture->channels   = ss.channels;
-        pDescriptorCapture->sampleRate = ss.rate;
-
-        /* Internal channel map. */
-        pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualCMap != NULL) {
-            cmap = *pActualCMap;
-        }
-
-        for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-            pDescriptorCapture->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
-        }
-
-
-        /* Buffer. */
-        pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (pActualAttr != NULL) {
-            attr = *pActualAttr;
-        }
-
-        pDescriptorCapture->periodCount        = attr.maxlength / attr.fragsize;
-        pDescriptorCapture->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) / pDescriptorCapture->periodCount;
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Capture actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorCapture->periodSizeInFrames);
-    #endif
-
-
-        /* Name. */
-        devCapture = ((ma_pa_stream_get_device_name_proc)pDevice->pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-        if (devCapture != NULL) {
-            ma_pa_operation* pOP = ((ma_pa_context_get_source_info_by_name_proc)pDevice->pContext->pulse.pa_context_get_source_info_by_name)((ma_pa_context*)pDevice->pContext->pulse.pPulseContext, devCapture, ma_device_source_name_callback, pDevice);
-            ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_context_get_sink_info__pulse(pDevice->pContext, devPlayback, &sinkInfo);
-        if (result != MA_SUCCESS) {
-            ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve sink info for playback device.", result);
-            goto on_error2;
-        }
-
-        ss   = sinkInfo.sample_spec;
-        cmap = sinkInfo.channel_map;
-
-        /* We now have enough information to calculate the actual buffer size in frames. */
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, ss.rate, pConfig->performanceProfile);
-
-        attr = ma_device__pa_buffer_attr_new(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->periodCount, &ss);
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Playback attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; periodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDescriptorPlayback->periodSizeInFrames);
-    #endif
-
-        pDevice->pulse.pStreamPlayback = ma_context__pa_stream_new__pulse(pDevice->pContext, pConfig->pulse.pStreamNamePlayback, &ss, &cmap);
-        if (pDevice->pulse.pStreamPlayback == NULL) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            goto on_error2;
-        }
-
-
-        /*
-        Note that this callback will be fired as soon as the stream is connected, even though it's started as corked. The callback needs to handle a
-        device state of MA_STATE_UNINITIALIZED.
-        */
-        ((ma_pa_stream_set_write_callback_proc)pDevice->pContext->pulse.pa_stream_set_write_callback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_device_on_write__pulse, pDevice);
-
-
-        /* Connect after we've got all of our internal state set up. */
-        streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_ADJUST_LATENCY | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS;
-        if (devPlayback != NULL) {
-            streamFlags |= MA_PA_STREAM_DONT_MOVE;
-        }
-
-        error = ((ma_pa_stream_connect_playback_proc)pDevice->pContext->pulse.pa_stream_connect_playback)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, streamFlags, NULL, NULL);
-        if (error != MA_PA_OK) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream.", ma_result_from_pulse(error));
-            goto on_error3;
-        }
-
-        result = ma_context_wait_for_pa_stream_to_connect__pulse(pDevice->pContext, (ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            goto on_error3;
-        }
-
-
-        /* Internal format. */
-        pActualSS = ((ma_pa_stream_get_sample_spec_proc)pDevice->pContext->pulse.pa_stream_get_sample_spec)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualSS != NULL) {
-            ss = *pActualSS;
-        }
-
-        pDescriptorPlayback->format     = ma_format_from_pulse(ss.format);
-        pDescriptorPlayback->channels   = ss.channels;
-        pDescriptorPlayback->sampleRate = ss.rate;
-
-        /* Internal channel map. */
-        pActualCMap = ((ma_pa_stream_get_channel_map_proc)pDevice->pContext->pulse.pa_stream_get_channel_map)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualCMap != NULL) {
-            cmap = *pActualCMap;
-        }
-
-        for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-            pDescriptorPlayback->channelMap[iChannel] = ma_channel_position_from_pulse(cmap.map[iChannel]);
-        }
-
-
-        /* Buffer. */
-        pActualAttr = ((ma_pa_stream_get_buffer_attr_proc)pDevice->pContext->pulse.pa_stream_get_buffer_attr)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (pActualAttr != NULL) {
-            attr = *pActualAttr;
-        }
-
-        pDescriptorPlayback->periodCount        = attr.maxlength / attr.tlength;
-        pDescriptorPlayback->periodSizeInFrames = attr.maxlength / ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) / pDescriptorPlayback->periodCount;
-    #ifdef MA_DEBUG_OUTPUT
-        printf("[PulseAudio] Playback actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalPeriodSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->playback.internalPeriodSizeInFrames);
-    #endif
-
-
-        /* Name. */
-        devPlayback = ((ma_pa_stream_get_device_name_proc)pDevice->pContext->pulse.pa_stream_get_device_name)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-        if (devPlayback != NULL) {
-            ma_pa_operation* pOP = ((ma_pa_context_get_sink_info_by_name_proc)pDevice->pContext->pulse.pa_context_get_sink_info_by_name)((ma_pa_context*)pDevice->pContext->pulse.pPulseContext, devPlayback, ma_device_sink_name_callback, pDevice);
-            ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-        }
-    }
-
-
-    /*
-    We need a ring buffer for handling duplex mode. We can use the main duplex ring buffer in the main
-    part of the ma_device struct. We cannot, however, depend on ma_device_init() initializing this for
-    us later on because that will only do it if it's a fully asynchronous backend - i.e. the
-    onDeviceDataLoop callback is NULL, which is not the case for PulseAudio.
-    */
-    if (pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_duplex_rb_init(format, channels, sampleRate, pDescriptorCapture->sampleRate, pDescriptorCapture->periodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
-        if (result != MA_SUCCESS) {
-            result = ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to initialize ring buffer.", result);
-            goto on_error4;
-        }
-    }
-
-    return MA_SUCCESS;
-
-
-on_error4:
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-on_error3:
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamPlayback);
-    }
-on_error2:
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_disconnect_proc)pDevice->pContext->pulse.pa_stream_disconnect)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-on_error1:
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ((ma_pa_stream_unref_proc)pDevice->pContext->pulse.pa_stream_unref)((ma_pa_stream*)pDevice->pulse.pStreamCapture);
-    }
-on_error0:
-    return result;
-}
-
-
-static void ma_pulse_operation_complete_callback(ma_pa_stream* pStream, int success, void* pUserData)
-{
-    ma_bool32* pIsSuccessful = (ma_bool32*)pUserData;
-    MA_ASSERT(pIsSuccessful != NULL);
-
-    *pIsSuccessful = (ma_bool32)success;
-
-    (void)pStream; /* Unused. */
-}
-
-static ma_result ma_device__cork_stream__pulse(ma_device* pDevice, ma_device_type deviceType, int cork)
-{
-    ma_context* pContext = pDevice->pContext;
-    ma_bool32 wasSuccessful;
-    ma_pa_stream* pStream;
-    ma_pa_operation* pOP;
-    ma_result result;
-
-    /* This should not be called with a duplex device type. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    wasSuccessful = MA_FALSE;
-
-    pStream = (ma_pa_stream*)((deviceType == ma_device_type_capture) ? pDevice->pulse.pStreamCapture : pDevice->pulse.pStreamPlayback);
-    MA_ASSERT(pStream != NULL);
-
-    pOP = ((ma_pa_stream_cork_proc)pContext->pulse.pa_stream_cork)(pStream, cork, ma_pulse_operation_complete_callback, &wasSuccessful);
-    if (pOP == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream.", (cork == 0) ? MA_FAILED_TO_START_BACKEND_DEVICE : MA_FAILED_TO_STOP_BACKEND_DEVICE);
-    }
-
-    result = ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while waiting for the PulseAudio stream to cork.", result);
-    }
-
-    if (!wasSuccessful) {
-        if (cork) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to stop PulseAudio stream.", MA_FAILED_TO_STOP_BACKEND_DEVICE);
-        } else {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to start PulseAudio stream.", MA_FAILED_TO_START_BACKEND_DEVICE);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__pulse(ma_device* pDevice)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 0);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* We need to fill some data before uncorking. Not doing this will result in the write callback never getting fired. */
-        result = ma_device_write_to_stream__pulse(pDevice, (ma_pa_stream*)(pDevice->pulse.pStreamPlayback), NULL);
-        if (result != MA_SUCCESS) {
-            return result; /* Failed to write data. Not sure what to do here... Just aborting. */
-        }
-
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 0);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__pulse(ma_device* pDevice)
-{
-    ma_result result;
-    ma_bool32 wasSuccessful;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_capture, 1);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        /* The stream needs to be drained if it's a playback device. */
-        ma_pa_operation* pOP = ((ma_pa_stream_drain_proc)pDevice->pContext->pulse.pa_stream_drain)((ma_pa_stream*)pDevice->pulse.pStreamPlayback, ma_pulse_operation_complete_callback, &wasSuccessful);
-        ma_wait_for_operation_and_unref__pulse(pDevice->pContext, pOP);
-
-        result = ma_device__cork_stream__pulse(pDevice, ma_device_type_playback, 1);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop__pulse(ma_device* pDevice)
-{
-    int resultPA;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /* NOTE: Don't start the device here. It'll be done at a higher level. */
-
-    /*
-    All data is handled through callbacks. All we need to do is iterate over the main loop and let
-    the callbacks deal with it.
-    */
-    while (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        resultPA = ((ma_pa_mainloop_iterate_proc)pDevice->pContext->pulse.pa_mainloop_iterate)((ma_pa_mainloop*)pDevice->pContext->pulse.pMainLoop, 1, NULL);
-        if (resultPA < 0) {
-            break;
-        }
-    }
-
-    /* NOTE: Don't stop the device here. It'll be done at a higher level. */
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_data_loop_wakeup__pulse(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ((ma_pa_mainloop_wakeup_proc)pDevice->pContext->pulse.pa_mainloop_wakeup)((ma_pa_mainloop*)pDevice->pContext->pulse.pMainLoop);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__pulse(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_pulseaudio);
-
-    ((ma_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)((ma_pa_context*)pContext->pulse.pPulseContext);
-    ((ma_pa_context_unref_proc)pContext->pulse.pa_context_unref)((ma_pa_context*)pContext->pulse.pPulseContext);
-    ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)pContext->pulse.pMainLoop);
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->pulse.pulseSO);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__pulse(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result;
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libpulseNames[] = {
-        "libpulse.so",
-        "libpulse.so.0"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libpulseNames); ++i) {
-        pContext->pulse.pulseSO = ma_dlopen(pContext, libpulseNames[i]);
-        if (pContext->pulse.pulseSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->pulse.pulseSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->pulse.pa_mainloop_new                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_new");
-    pContext->pulse.pa_mainloop_free                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_free");
-    pContext->pulse.pa_mainloop_quit                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_quit");
-    pContext->pulse.pa_mainloop_get_api                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_get_api");
-    pContext->pulse.pa_mainloop_iterate                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_iterate");
-    pContext->pulse.pa_mainloop_wakeup                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_mainloop_wakeup");
-    pContext->pulse.pa_threaded_mainloop_new           = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_new");
-    pContext->pulse.pa_threaded_mainloop_free          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_free");
-    pContext->pulse.pa_threaded_mainloop_start         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_start");
-    pContext->pulse.pa_threaded_mainloop_stop          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_stop");
-    pContext->pulse.pa_threaded_mainloop_lock          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_lock");
-    pContext->pulse.pa_threaded_mainloop_unlock        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_unlock");
-    pContext->pulse.pa_threaded_mainloop_wait          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_wait");
-    pContext->pulse.pa_threaded_mainloop_signal        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_signal");
-    pContext->pulse.pa_threaded_mainloop_accept        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_accept");
-    pContext->pulse.pa_threaded_mainloop_get_retval    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_get_retval");
-    pContext->pulse.pa_threaded_mainloop_get_api       = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_get_api");
-    pContext->pulse.pa_threaded_mainloop_in_thread     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_in_thread");
-    pContext->pulse.pa_threaded_mainloop_set_name      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_threaded_mainloop_set_name");
-    pContext->pulse.pa_context_new                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_new");
-    pContext->pulse.pa_context_unref                   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_unref");
-    pContext->pulse.pa_context_connect                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_connect");
-    pContext->pulse.pa_context_disconnect              = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_disconnect");
-    pContext->pulse.pa_context_set_state_callback      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_set_state_callback");
-    pContext->pulse.pa_context_get_state               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_state");
-    pContext->pulse.pa_context_get_sink_info_list      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_sink_info_list");
-    pContext->pulse.pa_context_get_source_info_list    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_source_info_list");
-    pContext->pulse.pa_context_get_sink_info_by_name   = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_sink_info_by_name");
-    pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_context_get_source_info_by_name");
-    pContext->pulse.pa_operation_unref                 = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_operation_unref");
-    pContext->pulse.pa_operation_get_state             = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_operation_get_state");
-    pContext->pulse.pa_channel_map_init_extend         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_init_extend");
-    pContext->pulse.pa_channel_map_valid               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_valid");
-    pContext->pulse.pa_channel_map_compatible          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_channel_map_compatible");
-    pContext->pulse.pa_stream_new                      = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_new");
-    pContext->pulse.pa_stream_unref                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_unref");
-    pContext->pulse.pa_stream_connect_playback         = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_connect_playback");
-    pContext->pulse.pa_stream_connect_record           = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_connect_record");
-    pContext->pulse.pa_stream_disconnect               = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_disconnect");
-    pContext->pulse.pa_stream_get_state                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_state");
-    pContext->pulse.pa_stream_get_sample_spec          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_sample_spec");
-    pContext->pulse.pa_stream_get_channel_map          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_channel_map");
-    pContext->pulse.pa_stream_get_buffer_attr          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_buffer_attr");
-    pContext->pulse.pa_stream_set_buffer_attr          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_buffer_attr");
-    pContext->pulse.pa_stream_get_device_name          = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_get_device_name");
-    pContext->pulse.pa_stream_set_write_callback       = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_write_callback");
-    pContext->pulse.pa_stream_set_read_callback        = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_set_read_callback");
-    pContext->pulse.pa_stream_flush                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_flush");
-    pContext->pulse.pa_stream_drain                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_drain");
-    pContext->pulse.pa_stream_is_corked                = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_is_corked");
-    pContext->pulse.pa_stream_cork                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_cork");
-    pContext->pulse.pa_stream_trigger                  = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_trigger");
-    pContext->pulse.pa_stream_begin_write              = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_begin_write");
-    pContext->pulse.pa_stream_write                    = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_write");
-    pContext->pulse.pa_stream_peek                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_peek");
-    pContext->pulse.pa_stream_drop                     = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_drop");
-    pContext->pulse.pa_stream_writable_size            = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_writable_size");
-    pContext->pulse.pa_stream_readable_size            = (ma_proc)ma_dlsym(pContext, pContext->pulse.pulseSO, "pa_stream_readable_size");
-#else
-    /* This strange assignment system is just for type safety. */
-    ma_pa_mainloop_new_proc                    _pa_mainloop_new                   = pa_mainloop_new;
-    ma_pa_mainloop_free_proc                   _pa_mainloop_free                  = pa_mainloop_free;
-    ma_pa_mainloop_quit_proc                   _pa_mainloop_quit                  = pa_mainloop_quit;
-    ma_pa_mainloop_get_api_proc                _pa_mainloop_get_api               = pa_mainloop_get_api;
-    ma_pa_mainloop_iterate_proc                _pa_mainloop_iterate               = pa_mainloop_iterate;
-    ma_pa_mainloop_wakeup_proc                 _pa_mainloop_wakeup                = pa_mainloop_wakeup;
-    ma_pa_threaded_mainloop_new_proc           _pa_threaded_mainloop_new          = pa_threaded_mainloop_new;
-    ma_pa_threaded_mainloop_free_proc          _pa_threaded_mainloop_free         = pa_threaded_mainloop_free;
-    ma_pa_threaded_mainloop_start_proc         _pa_threaded_mainloop_start        = pa_threaded_mainloop_start;
-    ma_pa_threaded_mainloop_stop_proc          _pa_threaded_mainloop_stop         = pa_threaded_mainloop_stop;
-    ma_pa_threaded_mainloop_lock_proc          _pa_threaded_mainloop_lock         = pa_threaded_mainloop_lock;
-    ma_pa_threaded_mainloop_unlock_proc        _pa_threaded_mainloop_unlock       = pa_threaded_mainloop_unlock;
-    ma_pa_threaded_mainloop_wait_proc          _pa_threaded_mainloop_wait         = pa_threaded_mainloop_wait;
-    ma_pa_threaded_mainloop_signal_proc        _pa_threaded_mainloop_signal       = pa_threaded_mainloop_signal;
-    ma_pa_threaded_mainloop_accept_proc        _pa_threaded_mainloop_accept       = pa_threaded_mainloop_accept;
-    ma_pa_threaded_mainloop_get_retval_proc    _pa_threaded_mainloop_get_retval   = pa_threaded_mainloop_get_retval;
-    ma_pa_threaded_mainloop_get_api_proc       _pa_threaded_mainloop_get_api      = pa_threaded_mainloop_get_api;
-    ma_pa_threaded_mainloop_in_thread_proc     _pa_threaded_mainloop_in_thread    = pa_threaded_mainloop_in_thread;
-    ma_pa_threaded_mainloop_set_name_proc      _pa_threaded_mainloop_set_name     = pa_threaded_mainloop_set_name;
-    ma_pa_context_new_proc                     _pa_context_new                    = pa_context_new;
-    ma_pa_context_unref_proc                   _pa_context_unref                  = pa_context_unref;
-    ma_pa_context_connect_proc                 _pa_context_connect                = pa_context_connect;
-    ma_pa_context_disconnect_proc              _pa_context_disconnect             = pa_context_disconnect;
-    ma_pa_context_set_state_callback_proc      _pa_context_set_state_callback     = pa_context_set_state_callback;
-    ma_pa_context_get_state_proc               _pa_context_get_state              = pa_context_get_state;
-    ma_pa_context_get_sink_info_list_proc      _pa_context_get_sink_info_list     = pa_context_get_sink_info_list;
-    ma_pa_context_get_source_info_list_proc    _pa_context_get_source_info_list   = pa_context_get_source_info_list;
-    ma_pa_context_get_sink_info_by_name_proc   _pa_context_get_sink_info_by_name  = pa_context_get_sink_info_by_name;
-    ma_pa_context_get_source_info_by_name_proc _pa_context_get_source_info_by_name= pa_context_get_source_info_by_name;
-    ma_pa_operation_unref_proc                 _pa_operation_unref                = pa_operation_unref;
-    ma_pa_operation_get_state_proc             _pa_operation_get_state            = pa_operation_get_state;
-    ma_pa_channel_map_init_extend_proc         _pa_channel_map_init_extend        = pa_channel_map_init_extend;
-    ma_pa_channel_map_valid_proc               _pa_channel_map_valid              = pa_channel_map_valid;
-    ma_pa_channel_map_compatible_proc          _pa_channel_map_compatible         = pa_channel_map_compatible;
-    ma_pa_stream_new_proc                      _pa_stream_new                     = pa_stream_new;
-    ma_pa_stream_unref_proc                    _pa_stream_unref                   = pa_stream_unref;
-    ma_pa_stream_connect_playback_proc         _pa_stream_connect_playback        = pa_stream_connect_playback;
-    ma_pa_stream_connect_record_proc           _pa_stream_connect_record          = pa_stream_connect_record;
-    ma_pa_stream_disconnect_proc               _pa_stream_disconnect              = pa_stream_disconnect;
-    ma_pa_stream_get_state_proc                _pa_stream_get_state               = pa_stream_get_state;
-    ma_pa_stream_get_sample_spec_proc          _pa_stream_get_sample_spec         = pa_stream_get_sample_spec;
-    ma_pa_stream_get_channel_map_proc          _pa_stream_get_channel_map         = pa_stream_get_channel_map;
-    ma_pa_stream_get_buffer_attr_proc          _pa_stream_get_buffer_attr         = pa_stream_get_buffer_attr;
-    ma_pa_stream_set_buffer_attr_proc          _pa_stream_set_buffer_attr         = pa_stream_set_buffer_attr;
-    ma_pa_stream_get_device_name_proc          _pa_stream_get_device_name         = pa_stream_get_device_name;
-    ma_pa_stream_set_write_callback_proc       _pa_stream_set_write_callback      = pa_stream_set_write_callback;
-    ma_pa_stream_set_read_callback_proc        _pa_stream_set_read_callback       = pa_stream_set_read_callback;
-    ma_pa_stream_flush_proc                    _pa_stream_flush                   = pa_stream_flush;
-    ma_pa_stream_drain_proc                    _pa_stream_drain                   = pa_stream_drain;
-    ma_pa_stream_is_corked_proc                _pa_stream_is_corked               = pa_stream_is_corked;
-    ma_pa_stream_cork_proc                     _pa_stream_cork                    = pa_stream_cork;
-    ma_pa_stream_trigger_proc                  _pa_stream_trigger                 = pa_stream_trigger;
-    ma_pa_stream_begin_write_proc              _pa_stream_begin_write             = pa_stream_begin_write;
-    ma_pa_stream_write_proc                    _pa_stream_write                   = pa_stream_write;
-    ma_pa_stream_peek_proc                     _pa_stream_peek                    = pa_stream_peek;
-    ma_pa_stream_drop_proc                     _pa_stream_drop                    = pa_stream_drop;
-    ma_pa_stream_writable_size_proc            _pa_stream_writable_size           = pa_stream_writable_size;
-    ma_pa_stream_readable_size_proc            _pa_stream_readable_size           = pa_stream_readable_size;
-
-    pContext->pulse.pa_mainloop_new                    = (ma_proc)_pa_mainloop_new;
-    pContext->pulse.pa_mainloop_free                   = (ma_proc)_pa_mainloop_free;
-    pContext->pulse.pa_mainloop_quit                   = (ma_proc)_pa_mainloop_quit;
-    pContext->pulse.pa_mainloop_get_api                = (ma_proc)_pa_mainloop_get_api;
-    pContext->pulse.pa_mainloop_iterate                = (ma_proc)_pa_mainloop_iterate;
-    pContext->pulse.pa_mainloop_wakeup                 = (ma_proc)_pa_mainloop_wakeup;
-    pContext->pulse.pa_threaded_mainloop_new           = (ma_proc)_pa_threaded_mainloop_new;
-    pContext->pulse.pa_threaded_mainloop_free          = (ma_proc)_pa_threaded_mainloop_free;
-    pContext->pulse.pa_threaded_mainloop_start         = (ma_proc)_pa_threaded_mainloop_start;
-    pContext->pulse.pa_threaded_mainloop_stop          = (ma_proc)_pa_threaded_mainloop_stop;
-    pContext->pulse.pa_threaded_mainloop_lock          = (ma_proc)_pa_threaded_mainloop_lock;
-    pContext->pulse.pa_threaded_mainloop_unlock        = (ma_proc)_pa_threaded_mainloop_unlock;
-    pContext->pulse.pa_threaded_mainloop_wait          = (ma_proc)_pa_threaded_mainloop_wait;
-    pContext->pulse.pa_threaded_mainloop_signal        = (ma_proc)_pa_threaded_mainloop_signal;
-    pContext->pulse.pa_threaded_mainloop_accept        = (ma_proc)_pa_threaded_mainloop_accept;
-    pContext->pulse.pa_threaded_mainloop_get_retval    = (ma_proc)_pa_threaded_mainloop_get_retval;
-    pContext->pulse.pa_threaded_mainloop_get_api       = (ma_proc)_pa_threaded_mainloop_get_api;
-    pContext->pulse.pa_threaded_mainloop_in_thread     = (ma_proc)_pa_threaded_mainloop_in_thread;
-    pContext->pulse.pa_threaded_mainloop_set_name      = (ma_proc)_pa_threaded_mainloop_set_name;
-    pContext->pulse.pa_context_new                     = (ma_proc)_pa_context_new;
-    pContext->pulse.pa_context_unref                   = (ma_proc)_pa_context_unref;
-    pContext->pulse.pa_context_connect                 = (ma_proc)_pa_context_connect;
-    pContext->pulse.pa_context_disconnect              = (ma_proc)_pa_context_disconnect;
-    pContext->pulse.pa_context_set_state_callback      = (ma_proc)_pa_context_set_state_callback;
-    pContext->pulse.pa_context_get_state               = (ma_proc)_pa_context_get_state;
-    pContext->pulse.pa_context_get_sink_info_list      = (ma_proc)_pa_context_get_sink_info_list;
-    pContext->pulse.pa_context_get_source_info_list    = (ma_proc)_pa_context_get_source_info_list;
-    pContext->pulse.pa_context_get_sink_info_by_name   = (ma_proc)_pa_context_get_sink_info_by_name;
-    pContext->pulse.pa_context_get_source_info_by_name = (ma_proc)_pa_context_get_source_info_by_name;
-    pContext->pulse.pa_operation_unref                 = (ma_proc)_pa_operation_unref;
-    pContext->pulse.pa_operation_get_state             = (ma_proc)_pa_operation_get_state;
-    pContext->pulse.pa_channel_map_init_extend         = (ma_proc)_pa_channel_map_init_extend;
-    pContext->pulse.pa_channel_map_valid               = (ma_proc)_pa_channel_map_valid;
-    pContext->pulse.pa_channel_map_compatible          = (ma_proc)_pa_channel_map_compatible;
-    pContext->pulse.pa_stream_new                      = (ma_proc)_pa_stream_new;
-    pContext->pulse.pa_stream_unref                    = (ma_proc)_pa_stream_unref;
-    pContext->pulse.pa_stream_connect_playback         = (ma_proc)_pa_stream_connect_playback;
-    pContext->pulse.pa_stream_connect_record           = (ma_proc)_pa_stream_connect_record;
-    pContext->pulse.pa_stream_disconnect               = (ma_proc)_pa_stream_disconnect;
-    pContext->pulse.pa_stream_get_state                = (ma_proc)_pa_stream_get_state;
-    pContext->pulse.pa_stream_get_sample_spec          = (ma_proc)_pa_stream_get_sample_spec;
-    pContext->pulse.pa_stream_get_channel_map          = (ma_proc)_pa_stream_get_channel_map;
-    pContext->pulse.pa_stream_get_buffer_attr          = (ma_proc)_pa_stream_get_buffer_attr;
-    pContext->pulse.pa_stream_set_buffer_attr          = (ma_proc)_pa_stream_set_buffer_attr;
-    pContext->pulse.pa_stream_get_device_name          = (ma_proc)_pa_stream_get_device_name;
-    pContext->pulse.pa_stream_set_write_callback       = (ma_proc)_pa_stream_set_write_callback;
-    pContext->pulse.pa_stream_set_read_callback        = (ma_proc)_pa_stream_set_read_callback;
-    pContext->pulse.pa_stream_flush                    = (ma_proc)_pa_stream_flush;
-    pContext->pulse.pa_stream_drain                    = (ma_proc)_pa_stream_drain;
-    pContext->pulse.pa_stream_is_corked                = (ma_proc)_pa_stream_is_corked;
-    pContext->pulse.pa_stream_cork                     = (ma_proc)_pa_stream_cork;
-    pContext->pulse.pa_stream_trigger                  = (ma_proc)_pa_stream_trigger;
-    pContext->pulse.pa_stream_begin_write              = (ma_proc)_pa_stream_begin_write;
-    pContext->pulse.pa_stream_write                    = (ma_proc)_pa_stream_write;
-    pContext->pulse.pa_stream_peek                     = (ma_proc)_pa_stream_peek;
-    pContext->pulse.pa_stream_drop                     = (ma_proc)_pa_stream_drop;
-    pContext->pulse.pa_stream_writable_size            = (ma_proc)_pa_stream_writable_size;
-    pContext->pulse.pa_stream_readable_size            = (ma_proc)_pa_stream_readable_size;
-#endif
-
-    /* The PulseAudio context maps well to miniaudio's notion of a context. The pa_context object will be initialized as part of the ma_context. */
-    pContext->pulse.pMainLoop = ((ma_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)();
-    if (pContext->pulse.pMainLoop == NULL) {
-        result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create mainloop.", MA_FAILED_TO_INIT_BACKEND);
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    pContext->pulse.pPulseContext = ((ma_pa_context_new_proc)pContext->pulse.pa_context_new)(((ma_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)((ma_pa_mainloop*)pContext->pulse.pMainLoop), pConfig->pulse.pApplicationName);
-    if (pContext->pulse.pPulseContext == NULL) {
-        result = ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context.", MA_FAILED_TO_INIT_BACKEND);
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    /* Now we need to connect to the context. Everything is asynchronous so we need to wait for it to connect before returning. */
-    result = ma_result_from_pulse(((ma_pa_context_connect_proc)pContext->pulse.pa_context_connect)((ma_pa_context*)pContext->pulse.pPulseContext, pConfig->pulse.pServerName, (pConfig->pulse.tryAutoSpawn) ? 0 : MA_PA_CONTEXT_NOAUTOSPAWN, NULL));
-    if (result != MA_SUCCESS) {
-        ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context.", result);
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-    /* Since ma_context_init() runs synchronously we need to wait for the PulseAudio context to connect before we return. */
-    result = ma_context_wait_for_pa_context_to_connect__pulse(pContext);
-    if (result != MA_SUCCESS) {
-        ((ma_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)((ma_pa_mainloop*)(pContext->pulse.pMainLoop));
-    #ifndef MA_NO_RUNTIME_LINKING
-        ma_dlclose(pContext, pContext->pulse.pulseSO);
-    #endif
-        return result;
-    }
-
-
-    /* With pa_mainloop we run a synchronous backend, but we implement our own main loop. */
-    pCallbacks->onContextInit             = ma_context_init__pulse;
-    pCallbacks->onContextUninit           = ma_context_uninit__pulse;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__pulse;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__pulse;
-    pCallbacks->onDeviceInit              = ma_device_init__pulse;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__pulse;
-    pCallbacks->onDeviceStart             = ma_device_start__pulse;
-    pCallbacks->onDeviceStop              = ma_device_stop__pulse;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because we're implementing onDeviceDataLoop. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because we're implementing onDeviceDataLoop. */
-    pCallbacks->onDeviceDataLoop          = ma_device_data_loop__pulse;
-    pCallbacks->onDeviceDataLoopWakeup    = ma_device_data_loop_wakeup__pulse;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-/******************************************************************************
-
-JACK Backend
-
-******************************************************************************/
-#ifdef MA_HAS_JACK
-
-/* It is assumed jack.h is available when compile-time linking is being used. */
-#ifdef MA_NO_RUNTIME_LINKING
-#include <jack/jack.h>
-
-typedef jack_nframes_t              ma_jack_nframes_t;
-typedef jack_options_t              ma_jack_options_t;
-typedef jack_status_t               ma_jack_status_t;
-typedef jack_client_t               ma_jack_client_t;
-typedef jack_port_t                 ma_jack_port_t;
-typedef JackProcessCallback         ma_JackProcessCallback;
-typedef JackBufferSizeCallback      ma_JackBufferSizeCallback;
-typedef JackShutdownCallback        ma_JackShutdownCallback;
-#define MA_JACK_DEFAULT_AUDIO_TYPE  JACK_DEFAULT_AUDIO_TYPE
-#define ma_JackNoStartServer        JackNoStartServer
-#define ma_JackPortIsInput          JackPortIsInput
-#define ma_JackPortIsOutput         JackPortIsOutput
-#define ma_JackPortIsPhysical       JackPortIsPhysical
-#else
-typedef ma_uint32               ma_jack_nframes_t;
-typedef int                     ma_jack_options_t;
-typedef int                     ma_jack_status_t;
-typedef struct ma_jack_client_t ma_jack_client_t;
-typedef struct ma_jack_port_t   ma_jack_port_t;
-typedef int  (* ma_JackProcessCallback)   (ma_jack_nframes_t nframes, void* arg);
-typedef int  (* ma_JackBufferSizeCallback)(ma_jack_nframes_t nframes, void* arg);
-typedef void (* ma_JackShutdownCallback)  (void* arg);
-#define MA_JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio"
-#define ma_JackNoStartServer       1
-#define ma_JackPortIsInput         1
-#define ma_JackPortIsOutput        2
-#define ma_JackPortIsPhysical      4
-#endif
-
-typedef ma_jack_client_t* (* ma_jack_client_open_proc)             (const char* client_name, ma_jack_options_t options, ma_jack_status_t* status, ...);
-typedef int               (* ma_jack_client_close_proc)            (ma_jack_client_t* client);
-typedef int               (* ma_jack_client_name_size_proc)        (void);
-typedef int               (* ma_jack_set_process_callback_proc)    (ma_jack_client_t* client, ma_JackProcessCallback process_callback, void* arg);
-typedef int               (* ma_jack_set_buffer_size_callback_proc)(ma_jack_client_t* client, ma_JackBufferSizeCallback bufsize_callback, void* arg);
-typedef void              (* ma_jack_on_shutdown_proc)             (ma_jack_client_t* client, ma_JackShutdownCallback function, void* arg);
-typedef ma_jack_nframes_t (* ma_jack_get_sample_rate_proc)         (ma_jack_client_t* client);
-typedef ma_jack_nframes_t (* ma_jack_get_buffer_size_proc)         (ma_jack_client_t* client);
-typedef const char**      (* ma_jack_get_ports_proc)               (ma_jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
-typedef int               (* ma_jack_activate_proc)                (ma_jack_client_t* client);
-typedef int               (* ma_jack_deactivate_proc)              (ma_jack_client_t* client);
-typedef int               (* ma_jack_connect_proc)                 (ma_jack_client_t* client, const char* source_port, const char* destination_port);
-typedef ma_jack_port_t*   (* ma_jack_port_register_proc)           (ma_jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
-typedef const char*       (* ma_jack_port_name_proc)               (const ma_jack_port_t* port);
-typedef void*             (* ma_jack_port_get_buffer_proc)         (ma_jack_port_t* port, ma_jack_nframes_t nframes);
-typedef void              (* ma_jack_free_proc)                    (void* ptr);
-
-static ma_result ma_context_open_client__jack(ma_context* pContext, ma_jack_client_t** ppClient)
-{
-    size_t maxClientNameSize;
-    char clientName[256];
-    ma_jack_status_t status;
-    ma_jack_client_t* pClient;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppClient != NULL);
-
-    if (ppClient) {
-        *ppClient = NULL;
-    }
-
-    maxClientNameSize = ((ma_jack_client_name_size_proc)pContext->jack.jack_client_name_size)(); /* Includes null terminator. */
-    ma_strncpy_s(clientName, ma_min(sizeof(clientName), maxClientNameSize), (pContext->jack.pClientName != NULL) ? pContext->jack.pClientName : "miniaudio", (size_t)-1);
-
-    pClient = ((ma_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->jack.tryStartServer) ? 0 : ma_JackNoStartServer, &status, NULL);
-    if (pClient == NULL) {
-        return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-    }
-
-    if (ppClient) {
-        *ppClient = pClient;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__jack(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* JACK only uses default devices. */
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* JACK only uses default devices. */
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    (void)cbResult; /* For silencing a static analysis warning. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__jack(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_jack_client_t* pClient;
-    ma_result result;
-    const char** ppPorts;
-
-    MA_ASSERT(pContext != NULL);
-
-    if (pDeviceID != NULL && pDeviceID->jack != 0) {
-        return MA_NO_DEVICE;   /* Don't know the device. */
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    /* Jack only uses default devices. */
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    /* Jack only supports f32 and has a specific channel count and sample rate. */
-    pDeviceInfo->nativeDataFormats[0].format = ma_format_f32;
-
-    /* The channel count and sample rate can only be determined by opening the device. */
-    result = ma_context_open_client__jack(pContext, &pClient);
-    if (result != MA_SUCCESS) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", result);
-    }
-
-    pDeviceInfo->nativeDataFormats[0].sampleRate = ((ma_jack_get_sample_rate_proc)pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pClient);
-    pDeviceInfo->nativeDataFormats[0].channels   = 0;
-
-    ppPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ((deviceType == ma_device_type_playback) ? ma_JackPortIsInput : ma_JackPortIsOutput));
-    if (ppPorts == NULL) {
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    while (ppPorts[pDeviceInfo->nativeDataFormats[0].channels] != NULL) {
-        pDeviceInfo->nativeDataFormats[0].channels += 1;
-    }
-
-    pDeviceInfo->nativeDataFormats[0].flags = 0;
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts);
-    ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pClient);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__jack(ma_device* pDevice)
-{
-    ma_context* pContext;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->jack.pClient != NULL) {
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDevice->jack.pClient);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_device__jack_shutdown_callback(void* pUserData)
-{
-    /* JACK died. Stop the device. */
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_stop(pDevice);
-}
-
-static int ma_device__jack_buffer_size_callback(ma_jack_nframes_t frameCount, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        size_t newBufferSize = frameCount * (pDevice->capture.internalChannels * ma_get_bytes_per_sample(pDevice->capture.internalFormat));
-        float* pNewBuffer = (float*)ma__calloc_from_callbacks(newBufferSize, &pDevice->pContext->allocationCallbacks);
-        if (pNewBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferCapture, &pDevice->pContext->allocationCallbacks);
-
-        pDevice->jack.pIntermediaryBufferCapture = pNewBuffer;
-        pDevice->playback.internalPeriodSizeInFrames = frameCount;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        size_t newBufferSize = frameCount * (pDevice->playback.internalChannels * ma_get_bytes_per_sample(pDevice->playback.internalFormat));
-        float* pNewBuffer = (float*)ma__calloc_from_callbacks(newBufferSize, &pDevice->pContext->allocationCallbacks);
-        if (pNewBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        ma__free_from_callbacks(pDevice->jack.pIntermediaryBufferPlayback, &pDevice->pContext->allocationCallbacks);
-
-        pDevice->jack.pIntermediaryBufferPlayback = pNewBuffer;
-        pDevice->playback.internalPeriodSizeInFrames = frameCount;
-    }
-
-    return 0;
-}
-
-static int ma_device__jack_process_callback(ma_jack_nframes_t frameCount, void* pUserData)
-{
-    ma_device* pDevice;
-    ma_context* pContext;
-    ma_uint32 iChannel;
-
-    pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    pContext = pDevice->pContext;
-    MA_ASSERT(pContext != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        /* Channels need to be interleaved. */
-        for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-            const float* pSrc = (const float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.pPortsCapture[iChannel], frameCount);
-            if (pSrc != NULL) {
-                float* pDst = pDevice->jack.pIntermediaryBufferCapture + iChannel;
-                ma_jack_nframes_t iFrame;
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    *pDst = *pSrc;
-
-                    pDst += pDevice->capture.internalChannels;
-                    pSrc += 1;
-                }
-            }
-        }
-
-        ma_device_handle_backend_data_callback(pDevice, NULL, pDevice->jack.pIntermediaryBufferCapture, frameCount);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_handle_backend_data_callback(pDevice, pDevice->jack.pIntermediaryBufferPlayback, NULL, frameCount);
-
-        /* Channels need to be deinterleaved. */
-        for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-            float* pDst = (float*)((ma_jack_port_get_buffer_proc)pContext->jack.jack_port_get_buffer)((ma_jack_port_t*)pDevice->jack.pPortsPlayback[iChannel], frameCount);
-            if (pDst != NULL) {
-                const float* pSrc = pDevice->jack.pIntermediaryBufferPlayback + iChannel;
-                ma_jack_nframes_t iFrame;
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    *pDst = *pSrc;
-
-                    pDst += 1;
-                    pSrc += pDevice->playback.internalChannels;
-                }
-            }
-        }
-    }
-
-    return 0;
-}
-
-static ma_result ma_device_init__jack(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-    ma_uint32 periodSizeInFrames;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDevice != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* Only supporting default devices with JACK. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->pDeviceID != NULL && pDescriptorPlayback->pDeviceID->jack != 0) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->pDeviceID  != NULL && pDescriptorCapture->pDeviceID->jack  != 0)) {
-        return MA_NO_DEVICE;
-    }
-
-    /* No exclusive mode with the JACK backend. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Open the client. */
-    result = ma_context_open_client__jack(pDevice->pContext, (ma_jack_client_t**)&pDevice->jack.pClient);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", result);
-    }
-
-    /* Callbacks. */
-    if (((ma_jack_set_process_callback_proc)pDevice->pContext->jack.jack_set_process_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_process_callback, pDevice) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set process callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-    if (((ma_jack_set_buffer_size_callback_proc)pDevice->pContext->jack.jack_set_buffer_size_callback)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_buffer_size_callback, pDevice) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set buffer size callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    ((ma_jack_on_shutdown_proc)pDevice->pContext->jack.jack_on_shutdown)((ma_jack_client_t*)pDevice->jack.pClient, ma_device__jack_shutdown_callback, pDevice);
-
-
-    /* The buffer size in frames can change. */
-    periodSizeInFrames = ((ma_jack_get_buffer_size_proc)pDevice->pContext->jack.jack_get_buffer_size)((ma_jack_client_t*)pDevice->jack.pClient);
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        const char** ppPorts;
-
-        pDescriptorCapture->format     = ma_format_f32;
-        pDescriptorCapture->channels   = 0;
-        pDescriptorCapture->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient);
-        ma_get_standard_channel_map(ma_standard_channel_map_alsa, pDescriptorCapture->channels, pDescriptorCapture->channelMap);
-
-        ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput);
-        if (ppPorts == NULL) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-
-        while (ppPorts[pDescriptorCapture->channels] != NULL) {
-            char name[64];
-            ma_strcpy_s(name, sizeof(name), "capture");
-            ma_itoa_s((int)pDescriptorCapture->channels, name+7, sizeof(name)-7, 10); /* 7 = length of "capture" */
-
-            pDevice->jack.pPortsCapture[pDescriptorCapture->channels] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsInput, 0);
-            if (pDevice->jack.pPortsCapture[pDescriptorCapture->channels] == NULL) {
-                ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-                ma_device_uninit__jack(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            }
-
-            pDescriptorCapture->channels += 1;
-        }
-
-        ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-
-        pDescriptorCapture->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorCapture->periodCount        = 1; /* There's no notion of a period in JACK. Just set to 1. */
-
-        pDevice->jack.pIntermediaryBufferCapture = (float*)ma__calloc_from_callbacks(pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels), &pDevice->pContext->allocationCallbacks);
-        if (pDevice->jack.pIntermediaryBufferCapture == NULL) {
-            ma_device_uninit__jack(pDevice);
-            return MA_OUT_OF_MEMORY;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        const char** ppPorts;
-
-        pDescriptorPlayback->format     = ma_format_f32;
-        pDescriptorPlayback->channels   = 0;
-        pDescriptorPlayback->sampleRate = ((ma_jack_get_sample_rate_proc)pDevice->pContext->jack.jack_get_sample_rate)((ma_jack_client_t*)pDevice->jack.pClient);
-        ma_get_standard_channel_map(ma_standard_channel_map_alsa, pDescriptorPlayback->channels, pDescriptorPlayback->channelMap);
-
-        ppPorts = ((ma_jack_get_ports_proc)pDevice->pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput);
-        if (ppPorts == NULL) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-        }
-
-        while (ppPorts[pDescriptorPlayback->channels] != NULL) {
-            char name[64];
-            ma_strcpy_s(name, sizeof(name), "playback");
-            ma_itoa_s((int)pDescriptorPlayback->channels, name+8, sizeof(name)-8, 10); /* 8 = length of "playback" */
-
-            pDevice->jack.pPortsPlayback[pDescriptorPlayback->channels] = ((ma_jack_port_register_proc)pDevice->pContext->jack.jack_port_register)((ma_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsOutput, 0);
-            if (pDevice->jack.pPortsPlayback[pDescriptorPlayback->channels] == NULL) {
-                ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-                ma_device_uninit__jack(pDevice);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-            }
-
-            pDescriptorPlayback->channels += 1;
-        }
-
-        ((ma_jack_free_proc)pDevice->pContext->jack.jack_free)((void*)ppPorts);
-
-        pDescriptorPlayback->periodSizeInFrames = periodSizeInFrames;
-        pDescriptorPlayback->periodCount        = 1;   /* There's no notion of a period in JACK. Just set to 1. */
-
-        pDevice->jack.pIntermediaryBufferPlayback = (float*)ma__calloc_from_callbacks(pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels), &pDevice->pContext->allocationCallbacks);
-        if (pDevice->jack.pIntermediaryBufferPlayback == NULL) {
-            ma_device_uninit__jack(pDevice);
-            return MA_OUT_OF_MEMORY;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_start__jack(ma_device* pDevice)
-{
-    ma_context* pContext = pDevice->pContext;
-    int resultJACK;
-    size_t i;
-
-    resultJACK = ((ma_jack_activate_proc)pContext->jack.jack_activate)((ma_jack_client_t*)pDevice->jack.pClient);
-    if (resultJACK != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to activate the JACK client.", MA_FAILED_TO_START_BACKEND_DEVICE);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsOutput);
-        if (ppServerPorts == NULL) {
-            ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR);
-        }
-
-        for (i = 0; ppServerPorts[i] != NULL; ++i) {
-            const char* pServerPort = ppServerPorts[i];
-            const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.pPortsCapture[i]);
-
-            resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pServerPort, pClientPort);
-            if (resultJACK != 0) {
-                ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-                ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR);
-            }
-        }
-
-        ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        const char** ppServerPorts = ((ma_jack_get_ports_proc)pContext->jack.jack_get_ports)((ma_jack_client_t*)pDevice->jack.pClient, NULL, MA_JACK_DEFAULT_AUDIO_TYPE, ma_JackPortIsPhysical | ma_JackPortIsInput);
-        if (ppServerPorts == NULL) {
-            ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR);
-        }
-
-        for (i = 0; ppServerPorts[i] != NULL; ++i) {
-            const char* pServerPort = ppServerPorts[i];
-            const char* pClientPort = ((ma_jack_port_name_proc)pContext->jack.jack_port_name)((ma_jack_port_t*)pDevice->jack.pPortsPlayback[i]);
-
-            resultJACK = ((ma_jack_connect_proc)pContext->jack.jack_connect)((ma_jack_client_t*)pDevice->jack.pClient, pClientPort, pServerPort);
-            if (resultJACK != 0) {
-                ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-                ((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR);
-            }
-        }
-
-        ((ma_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__jack(ma_device* pDevice)
-{
-    ma_context* pContext = pDevice->pContext;
-    ma_stop_proc onStop;
-
-    if (((ma_jack_deactivate_proc)pContext->jack.jack_deactivate)((ma_jack_client_t*)pDevice->jack.pClient) != 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] An error occurred when deactivating the JACK client.", MA_ERROR);
-    }
-
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__jack(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_jack);
-
-    ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks);
-    pContext->jack.pClientName = NULL;
-
-#ifndef MA_NO_RUNTIME_LINKING
-    ma_dlclose(pContext, pContext->jack.jackSO);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__jack(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libjackNames[] = {
-#ifdef MA_WIN32
-        "libjack.dll",
-        "libjack64.dll"
-#else
-        "libjack.so",
-        "libjack.so.0"
-#endif
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libjackNames); ++i) {
-        pContext->jack.jackSO = ma_dlopen(pContext, libjackNames[i]);
-        if (pContext->jack.jackSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->jack.jackSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->jack.jack_client_open              = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_open");
-    pContext->jack.jack_client_close             = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_close");
-    pContext->jack.jack_client_name_size         = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_client_name_size");
-    pContext->jack.jack_set_process_callback     = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_set_process_callback");
-    pContext->jack.jack_set_buffer_size_callback = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_set_buffer_size_callback");
-    pContext->jack.jack_on_shutdown              = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_on_shutdown");
-    pContext->jack.jack_get_sample_rate          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_sample_rate");
-    pContext->jack.jack_get_buffer_size          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_buffer_size");
-    pContext->jack.jack_get_ports                = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_get_ports");
-    pContext->jack.jack_activate                 = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_activate");
-    pContext->jack.jack_deactivate               = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_deactivate");
-    pContext->jack.jack_connect                  = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_connect");
-    pContext->jack.jack_port_register            = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_register");
-    pContext->jack.jack_port_name                = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_name");
-    pContext->jack.jack_port_get_buffer          = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_port_get_buffer");
-    pContext->jack.jack_free                     = (ma_proc)ma_dlsym(pContext, pContext->jack.jackSO, "jack_free");
-#else
-    /*
-    This strange assignment system is here just to ensure type safety of miniaudio's function pointer
-    types. If anything differs slightly the compiler should throw a warning.
-    */
-    ma_jack_client_open_proc              _jack_client_open              = jack_client_open;
-    ma_jack_client_close_proc             _jack_client_close             = jack_client_close;
-    ma_jack_client_name_size_proc         _jack_client_name_size         = jack_client_name_size;
-    ma_jack_set_process_callback_proc     _jack_set_process_callback     = jack_set_process_callback;
-    ma_jack_set_buffer_size_callback_proc _jack_set_buffer_size_callback = jack_set_buffer_size_callback;
-    ma_jack_on_shutdown_proc              _jack_on_shutdown              = jack_on_shutdown;
-    ma_jack_get_sample_rate_proc          _jack_get_sample_rate          = jack_get_sample_rate;
-    ma_jack_get_buffer_size_proc          _jack_get_buffer_size          = jack_get_buffer_size;
-    ma_jack_get_ports_proc                _jack_get_ports                = jack_get_ports;
-    ma_jack_activate_proc                 _jack_activate                 = jack_activate;
-    ma_jack_deactivate_proc               _jack_deactivate               = jack_deactivate;
-    ma_jack_connect_proc                  _jack_connect                  = jack_connect;
-    ma_jack_port_register_proc            _jack_port_register            = jack_port_register;
-    ma_jack_port_name_proc                _jack_port_name                = jack_port_name;
-    ma_jack_port_get_buffer_proc          _jack_port_get_buffer          = jack_port_get_buffer;
-    ma_jack_free_proc                     _jack_free                     = jack_free;
-
-    pContext->jack.jack_client_open              = (ma_proc)_jack_client_open;
-    pContext->jack.jack_client_close             = (ma_proc)_jack_client_close;
-    pContext->jack.jack_client_name_size         = (ma_proc)_jack_client_name_size;
-    pContext->jack.jack_set_process_callback     = (ma_proc)_jack_set_process_callback;
-    pContext->jack.jack_set_buffer_size_callback = (ma_proc)_jack_set_buffer_size_callback;
-    pContext->jack.jack_on_shutdown              = (ma_proc)_jack_on_shutdown;
-    pContext->jack.jack_get_sample_rate          = (ma_proc)_jack_get_sample_rate;
-    pContext->jack.jack_get_buffer_size          = (ma_proc)_jack_get_buffer_size;
-    pContext->jack.jack_get_ports                = (ma_proc)_jack_get_ports;
-    pContext->jack.jack_activate                 = (ma_proc)_jack_activate;
-    pContext->jack.jack_deactivate               = (ma_proc)_jack_deactivate;
-    pContext->jack.jack_connect                  = (ma_proc)_jack_connect;
-    pContext->jack.jack_port_register            = (ma_proc)_jack_port_register;
-    pContext->jack.jack_port_name                = (ma_proc)_jack_port_name;
-    pContext->jack.jack_port_get_buffer          = (ma_proc)_jack_port_get_buffer;
-    pContext->jack.jack_free                     = (ma_proc)_jack_free;
-#endif
-
-    if (pConfig->jack.pClientName != NULL) {
-        pContext->jack.pClientName = ma_copy_string(pConfig->jack.pClientName, &pContext->allocationCallbacks);
-    }
-    pContext->jack.tryStartServer = pConfig->jack.tryStartServer;
-
-    /*
-    Getting here means the JACK library is installed, but it doesn't necessarily mean it's usable. We need to quickly test this by connecting
-    a temporary client.
-    */
-    {
-        ma_jack_client_t* pDummyClient;
-        ma_result result = ma_context_open_client__jack(pContext, &pDummyClient);
-        if (result != MA_SUCCESS) {
-            ma_free(pContext->jack.pClientName, &pContext->allocationCallbacks);
-        #ifndef MA_NO_RUNTIME_LINKING
-            ma_dlclose(pContext, pContext->jack.jackSO);
-        #endif
-            return MA_NO_BACKEND;
-        }
-
-        ((ma_jack_client_close_proc)pContext->jack.jack_client_close)((ma_jack_client_t*)pDummyClient);
-    }
-
-
-    pCallbacks->onContextInit             = ma_context_init__jack;
-    pCallbacks->onContextUninit           = ma_context_uninit__jack;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__jack;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__jack;
-    pCallbacks->onDeviceInit              = ma_device_init__jack;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__jack;
-    pCallbacks->onDeviceStart             = ma_device_start__jack;
-    pCallbacks->onDeviceStop              = ma_device_stop__jack;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because JACK is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because JACK is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not used because JACK is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* JACK */
-
-
-
-/******************************************************************************
-
-Core Audio Backend
-
-References
-==========
-- Technical Note TN2091: Device input using the HAL Output Audio Unit
-    https://developer.apple.com/library/archive/technotes/tn2091/_index.html
-
-******************************************************************************/
-#ifdef MA_HAS_COREAUDIO
-#include <TargetConditionals.h>
-
-#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1
-    #define MA_APPLE_MOBILE
-    #if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
-        #define MA_APPLE_TV
-    #endif
-    #if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
-        #define MA_APPLE_WATCH
-    #endif
-#else
-    #define MA_APPLE_DESKTOP
-#endif
-
-#if defined(MA_APPLE_DESKTOP)
-#include <CoreAudio/CoreAudio.h>
-#else
-#include <AVFoundation/AVFoundation.h>
-#endif
-
-#include <AudioToolbox/AudioToolbox.h>
-
-/* CoreFoundation */
-typedef Boolean (* ma_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding);
-typedef void (* ma_CFRelease_proc)(CFTypeRef cf);
-
-/* CoreAudio */
-#if defined(MA_APPLE_DESKTOP)
-typedef OSStatus (* ma_AudioObjectGetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* ioDataSize, void* outData);
-typedef OSStatus (* ma_AudioObjectGetPropertyDataSize_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize);
-typedef OSStatus (* ma_AudioObjectSetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData);
-typedef OSStatus (* ma_AudioObjectAddPropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData);
-typedef OSStatus (* ma_AudioObjectRemovePropertyListener_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, AudioObjectPropertyListenerProc inListener, void* inClientData);
-#endif
-
-/* AudioToolbox */
-typedef AudioComponent (* ma_AudioComponentFindNext_proc)(AudioComponent inComponent, const AudioComponentDescription* inDesc);
-typedef OSStatus (* ma_AudioComponentInstanceDispose_proc)(AudioComponentInstance inInstance);
-typedef OSStatus (* ma_AudioComponentInstanceNew_proc)(AudioComponent inComponent, AudioComponentInstance* outInstance);
-typedef OSStatus (* ma_AudioOutputUnitStart_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioOutputUnitStop_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioUnitAddPropertyListener_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitPropertyListenerProc inProc, void* inProcUserData);
-typedef OSStatus (* ma_AudioUnitGetPropertyInfo_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, UInt32* outDataSize, Boolean* outWriteable);
-typedef OSStatus (* ma_AudioUnitGetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void* outData, UInt32* ioDataSize);
-typedef OSStatus (* ma_AudioUnitSetProperty_proc)(AudioUnit inUnit, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void* inData, UInt32 inDataSize);
-typedef OSStatus (* ma_AudioUnitInitialize_proc)(AudioUnit inUnit);
-typedef OSStatus (* ma_AudioUnitRender_proc)(AudioUnit inUnit, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData);
-
-
-#define MA_COREAUDIO_OUTPUT_BUS    0
-#define MA_COREAUDIO_INPUT_BUS     1
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit);
-#endif
-
-/*
-Core Audio
-
-So far, Core Audio has been the worst backend to work with due to being both unintuitive and having almost no documentation
-apart from comments in the headers (which admittedly are quite good). For my own purposes, and for anybody out there whose
-needing to figure out how this darn thing works, I'm going to outline a few things here.
-
-Since miniaudio is a fairly low-level API, one of the things it needs is control over specific devices, and it needs to be
-able to identify whether or not it can be used as playback and/or capture. The AudioObject API is the only one I've seen
-that supports this level of detail. There was some public domain sample code I stumbled across that used the AudioComponent
-and AudioUnit APIs, but I couldn't see anything that gave low-level control over device selection and capabilities (the
-distinction between playback and capture in particular). Therefore, miniaudio is using the AudioObject API.
-
-Most (all?) functions in the AudioObject API take a AudioObjectID as it's input. This is the device identifier. When
-retrieving global information, such as the device list, you use kAudioObjectSystemObject. When retrieving device-specific
-data, you pass in the ID for that device. In order to retrieve device-specific IDs you need to enumerate over each of the
-devices. This is done using the AudioObjectGetPropertyDataSize() and AudioObjectGetPropertyData() APIs which seem to be
-the central APIs for retrieving information about the system and specific devices.
-
-To use the AudioObjectGetPropertyData() API you need to use the notion of a property address. A property address is a
-structure with three variables and is used to identify which property you are getting or setting. The first is the "selector"
-which is basically the specific property that you're wanting to retrieve or set. The second is the "scope", which is
-typically set to kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyScopeInput for input-specific properties and
-kAudioObjectPropertyScopeOutput for output-specific properties. The last is the "element" which is always set to
-kAudioObjectPropertyElementMaster in miniaudio's case. I don't know of any cases where this would be set to anything different.
-
-Back to the earlier issue of device retrieval, you first use the AudioObjectGetPropertyDataSize() API to retrieve the size
-of the raw data which is just a list of AudioDeviceID's. You use the kAudioObjectSystemObject AudioObjectID, and a property
-address with the kAudioHardwarePropertyDevices selector and the kAudioObjectPropertyScopeGlobal scope. Once you have the
-size, allocate a block of memory of that size and then call AudioObjectGetPropertyData(). The data is just a list of
-AudioDeviceID's so just do "dataSize/sizeof(AudioDeviceID)" to know the device count.
-*/
-
-static ma_result ma_result_from_OSStatus(OSStatus status)
-{
-    switch (status)
-    {
-        case noErr:                                   return MA_SUCCESS;
-    #if defined(MA_APPLE_DESKTOP)
-        case kAudioHardwareNotRunningError:           return MA_DEVICE_NOT_STARTED;
-        case kAudioHardwareUnspecifiedError:          return MA_ERROR;
-        case kAudioHardwareUnknownPropertyError:      return MA_INVALID_ARGS;
-        case kAudioHardwareBadPropertySizeError:      return MA_INVALID_OPERATION;
-        case kAudioHardwareIllegalOperationError:     return MA_INVALID_OPERATION;
-        case kAudioHardwareBadObjectError:            return MA_INVALID_ARGS;
-        case kAudioHardwareBadDeviceError:            return MA_INVALID_ARGS;
-        case kAudioHardwareBadStreamError:            return MA_INVALID_ARGS;
-        case kAudioHardwareUnsupportedOperationError: return MA_INVALID_OPERATION;
-        case kAudioDeviceUnsupportedFormatError:      return MA_FORMAT_NOT_SUPPORTED;
-        case kAudioDevicePermissionsError:            return MA_ACCESS_DENIED;
-    #endif
-        default:                                      return MA_ERROR;
-    }
-}
-
-#if 0
-static ma_channel ma_channel_from_AudioChannelBitmap(AudioChannelBitmap bit)
-{
-    switch (bit)
-    {
-        case kAudioChannelBit_Left:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelBit_Right:                return MA_CHANNEL_RIGHT;
-        case kAudioChannelBit_Center:               return MA_CHANNEL_FRONT_CENTER;
-        case kAudioChannelBit_LFEScreen:            return MA_CHANNEL_LFE;
-        case kAudioChannelBit_LeftSurround:         return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelBit_RightSurround:        return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelBit_LeftCenter:           return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case kAudioChannelBit_RightCenter:          return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case kAudioChannelBit_CenterSurround:       return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelBit_LeftSurroundDirect:   return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelBit_RightSurroundDirect:  return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelBit_TopCenterSurround:    return MA_CHANNEL_TOP_CENTER;
-        case kAudioChannelBit_VerticalHeightLeft:   return MA_CHANNEL_TOP_FRONT_LEFT;
-        case kAudioChannelBit_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER;
-        case kAudioChannelBit_VerticalHeightRight:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case kAudioChannelBit_TopBackLeft:          return MA_CHANNEL_TOP_BACK_LEFT;
-        case kAudioChannelBit_TopBackCenter:        return MA_CHANNEL_TOP_BACK_CENTER;
-        case kAudioChannelBit_TopBackRight:         return MA_CHANNEL_TOP_BACK_RIGHT;
-        default:                                    return MA_CHANNEL_NONE;
-    }
-}
-#endif
-
-static ma_result ma_format_from_AudioStreamBasicDescription(const AudioStreamBasicDescription* pDescription, ma_format* pFormatOut)
-{
-    MA_ASSERT(pDescription != NULL);
-    MA_ASSERT(pFormatOut != NULL);
-
-    *pFormatOut = ma_format_unknown;   /* Safety. */
-
-    /* There's a few things miniaudio doesn't support. */
-    if (pDescription->mFormatID != kAudioFormatLinearPCM) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* We don't support any non-packed formats that are aligned high. */
-    if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsAlignedHigh) != 0) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* Only supporting native-endian. */
-    if ((ma_is_little_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) != 0) || (ma_is_big_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) == 0)) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-    /* We are not currently supporting non-interleaved formats (this will be added in a future version of miniaudio). */
-    /*if ((pDescription->mFormatFlags & kAudioFormatFlagIsNonInterleaved) != 0) {
-        return MA_FORMAT_NOT_SUPPORTED;
-    }*/
-
-    if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) {
-        if (pDescription->mBitsPerChannel == 32) {
-            *pFormatOut = ma_format_f32;
-            return MA_SUCCESS;
-        }
-    } else {
-        if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) {
-            if (pDescription->mBitsPerChannel == 16) {
-                *pFormatOut = ma_format_s16;
-                return MA_SUCCESS;
-            } else if (pDescription->mBitsPerChannel == 24) {
-                if (pDescription->mBytesPerFrame == (pDescription->mBitsPerChannel/8 * pDescription->mChannelsPerFrame)) {
-                    *pFormatOut = ma_format_s24;
-                    return MA_SUCCESS;
-                } else {
-                    if (pDescription->mBytesPerFrame/pDescription->mChannelsPerFrame == sizeof(ma_int32)) {
-                        /* TODO: Implement ma_format_s24_32. */
-                        /**pFormatOut = ma_format_s24_32;*/
-                        /*return MA_SUCCESS;*/
-                        return MA_FORMAT_NOT_SUPPORTED;
-                    }
-                }
-            } else if (pDescription->mBitsPerChannel == 32) {
-                *pFormatOut = ma_format_s32;
-                return MA_SUCCESS;
-            }
-        } else {
-            if (pDescription->mBitsPerChannel == 8) {
-                *pFormatOut = ma_format_u8;
-                return MA_SUCCESS;
-            }
-        }
-    }
-
-    /* Getting here means the format is not supported. */
-    return MA_FORMAT_NOT_SUPPORTED;
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_channel ma_channel_from_AudioChannelLabel(AudioChannelLabel label)
-{
-    switch (label)
-    {
-        case kAudioChannelLabel_Unknown:              return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Unused:               return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_UseCoordinates:       return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Left:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_Right:                return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_Center:               return MA_CHANNEL_FRONT_CENTER;
-        case kAudioChannelLabel_LFEScreen:            return MA_CHANNEL_LFE;
-        case kAudioChannelLabel_LeftSurround:         return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelLabel_RightSurround:        return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelLabel_LeftCenter:           return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case kAudioChannelLabel_RightCenter:          return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case kAudioChannelLabel_CenterSurround:       return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelLabel_LeftSurroundDirect:   return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelLabel_RightSurroundDirect:  return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelLabel_TopCenterSurround:    return MA_CHANNEL_TOP_CENTER;
-        case kAudioChannelLabel_VerticalHeightLeft:   return MA_CHANNEL_TOP_FRONT_LEFT;
-        case kAudioChannelLabel_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER;
-        case kAudioChannelLabel_VerticalHeightRight:  return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case kAudioChannelLabel_TopBackLeft:          return MA_CHANNEL_TOP_BACK_LEFT;
-        case kAudioChannelLabel_TopBackCenter:        return MA_CHANNEL_TOP_BACK_CENTER;
-        case kAudioChannelLabel_TopBackRight:         return MA_CHANNEL_TOP_BACK_RIGHT;
-        case kAudioChannelLabel_RearSurroundLeft:     return MA_CHANNEL_BACK_LEFT;
-        case kAudioChannelLabel_RearSurroundRight:    return MA_CHANNEL_BACK_RIGHT;
-        case kAudioChannelLabel_LeftWide:             return MA_CHANNEL_SIDE_LEFT;
-        case kAudioChannelLabel_RightWide:            return MA_CHANNEL_SIDE_RIGHT;
-        case kAudioChannelLabel_LFE2:                 return MA_CHANNEL_LFE;
-        case kAudioChannelLabel_LeftTotal:            return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_RightTotal:           return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_HearingImpaired:      return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Narration:            return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_Mono:                 return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_DialogCentricMix:     return MA_CHANNEL_MONO;
-        case kAudioChannelLabel_CenterSurroundDirect: return MA_CHANNEL_BACK_CENTER;
-        case kAudioChannelLabel_Haptic:               return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_W:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_X:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_Y:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Ambisonic_Z:          return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_MS_Mid:               return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_MS_Side:              return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_XY_X:                 return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_XY_Y:                 return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_HeadphonesLeft:       return MA_CHANNEL_LEFT;
-        case kAudioChannelLabel_HeadphonesRight:      return MA_CHANNEL_RIGHT;
-        case kAudioChannelLabel_ClickTrack:           return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_ForeignLanguage:      return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Discrete:             return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_Discrete_0:           return MA_CHANNEL_AUX_0;
-        case kAudioChannelLabel_Discrete_1:           return MA_CHANNEL_AUX_1;
-        case kAudioChannelLabel_Discrete_2:           return MA_CHANNEL_AUX_2;
-        case kAudioChannelLabel_Discrete_3:           return MA_CHANNEL_AUX_3;
-        case kAudioChannelLabel_Discrete_4:           return MA_CHANNEL_AUX_4;
-        case kAudioChannelLabel_Discrete_5:           return MA_CHANNEL_AUX_5;
-        case kAudioChannelLabel_Discrete_6:           return MA_CHANNEL_AUX_6;
-        case kAudioChannelLabel_Discrete_7:           return MA_CHANNEL_AUX_7;
-        case kAudioChannelLabel_Discrete_8:           return MA_CHANNEL_AUX_8;
-        case kAudioChannelLabel_Discrete_9:           return MA_CHANNEL_AUX_9;
-        case kAudioChannelLabel_Discrete_10:          return MA_CHANNEL_AUX_10;
-        case kAudioChannelLabel_Discrete_11:          return MA_CHANNEL_AUX_11;
-        case kAudioChannelLabel_Discrete_12:          return MA_CHANNEL_AUX_12;
-        case kAudioChannelLabel_Discrete_13:          return MA_CHANNEL_AUX_13;
-        case kAudioChannelLabel_Discrete_14:          return MA_CHANNEL_AUX_14;
-        case kAudioChannelLabel_Discrete_15:          return MA_CHANNEL_AUX_15;
-        case kAudioChannelLabel_Discrete_65535:       return MA_CHANNEL_NONE;
-
-    #if 0   /* Introduced in a later version of macOS. */
-        case kAudioChannelLabel_HOA_ACN:              return MA_CHANNEL_NONE;
-        case kAudioChannelLabel_HOA_ACN_0:            return MA_CHANNEL_AUX_0;
-        case kAudioChannelLabel_HOA_ACN_1:            return MA_CHANNEL_AUX_1;
-        case kAudioChannelLabel_HOA_ACN_2:            return MA_CHANNEL_AUX_2;
-        case kAudioChannelLabel_HOA_ACN_3:            return MA_CHANNEL_AUX_3;
-        case kAudioChannelLabel_HOA_ACN_4:            return MA_CHANNEL_AUX_4;
-        case kAudioChannelLabel_HOA_ACN_5:            return MA_CHANNEL_AUX_5;
-        case kAudioChannelLabel_HOA_ACN_6:            return MA_CHANNEL_AUX_6;
-        case kAudioChannelLabel_HOA_ACN_7:            return MA_CHANNEL_AUX_7;
-        case kAudioChannelLabel_HOA_ACN_8:            return MA_CHANNEL_AUX_8;
-        case kAudioChannelLabel_HOA_ACN_9:            return MA_CHANNEL_AUX_9;
-        case kAudioChannelLabel_HOA_ACN_10:           return MA_CHANNEL_AUX_10;
-        case kAudioChannelLabel_HOA_ACN_11:           return MA_CHANNEL_AUX_11;
-        case kAudioChannelLabel_HOA_ACN_12:           return MA_CHANNEL_AUX_12;
-        case kAudioChannelLabel_HOA_ACN_13:           return MA_CHANNEL_AUX_13;
-        case kAudioChannelLabel_HOA_ACN_14:           return MA_CHANNEL_AUX_14;
-        case kAudioChannelLabel_HOA_ACN_15:           return MA_CHANNEL_AUX_15;
-        case kAudioChannelLabel_HOA_ACN_65024:        return MA_CHANNEL_NONE;
-    #endif
-
-        default:                                      return MA_CHANNEL_NONE;
-    }
-}
-
-static ma_result ma_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    MA_ASSERT(pChannelLayout != NULL);
-
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) {
-        UInt32 iChannel;
-        for (iChannel = 0; iChannel < pChannelLayout->mNumberChannelDescriptions && iChannel < channelMapCap; ++iChannel) {
-            pChannelMap[iChannel] = ma_channel_from_AudioChannelLabel(pChannelLayout->mChannelDescriptions[iChannel].mChannelLabel);
-        }
-    } else
-#if 0
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) {
-        /* This is the same kind of system that's used by Windows audio APIs. */
-        UInt32 iChannel = 0;
-        UInt32 iBit;
-        AudioChannelBitmap bitmap = pChannelLayout->mChannelBitmap;
-        for (iBit = 0; iBit < 32 && iChannel < channelMapCap; ++iBit) {
-            AudioChannelBitmap bit = bitmap & (1 << iBit);
-            if (bit != 0) {
-                pChannelMap[iChannel++] = ma_channel_from_AudioChannelBit(bit);
-            }
-        }
-    } else
-#endif
-    {
-        /*
-        Need to use the tag to determine the channel map. For now I'm just assuming a default channel map, but later on this should
-        be updated to determine the mapping based on the tag.
-        */
-        UInt32 channelCount;
-
-        /* Our channel map retrieval APIs below take 32-bit integers, so we'll want to clamp the channel map capacity. */
-        if (channelMapCap > 0xFFFFFFFF) {
-            channelMapCap = 0xFFFFFFFF;
-        }
-
-        channelCount = ma_min(AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag), (UInt32)channelMapCap);
-
-        switch (pChannelLayout->mChannelLayoutTag)
-        {
-            case kAudioChannelLayoutTag_Mono:
-            case kAudioChannelLayoutTag_Stereo:
-            case kAudioChannelLayoutTag_StereoHeadphones:
-            case kAudioChannelLayoutTag_MatrixStereo:
-            case kAudioChannelLayoutTag_MidSide:
-            case kAudioChannelLayoutTag_XY:
-            case kAudioChannelLayoutTag_Binaural:
-            case kAudioChannelLayoutTag_Ambisonic_B_Format:
-            {
-                ma_get_standard_channel_map(ma_standard_channel_map_default, channelCount, pChannelMap);
-            } break;
-
-            case kAudioChannelLayoutTag_Octagonal:
-            {
-                pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-                pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            } /* Intentional fallthrough. */
-            case kAudioChannelLayoutTag_Hexagonal:
-            {
-                pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            } /* Intentional fallthrough. */
-            case kAudioChannelLayoutTag_Pentagonal:
-            {
-                pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            } /* Intentional fallghrough. */
-            case kAudioChannelLayoutTag_Quadraphonic:
-            {
-                pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-                pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-                pChannelMap[1] = MA_CHANNEL_RIGHT;
-                pChannelMap[0] = MA_CHANNEL_LEFT;
-            } break;
-
-            /* TODO: Add support for more tags here. */
-
-            default:
-            {
-                ma_get_standard_channel_map(ma_standard_channel_map_default, channelCount, pChannelMap);
-            } break;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_device_object_ids__coreaudio(ma_context* pContext, UInt32* pDeviceCount, AudioObjectID** ppDeviceObjectIDs) /* NOTE: Free the returned buffer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddressDevices;
-    UInt32 deviceObjectsDataSize;
-    OSStatus status;
-    AudioObjectID* pDeviceObjectIDs;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceCount != NULL);
-    MA_ASSERT(ppDeviceObjectIDs != NULL);
-
-    /* Safety. */
-    *pDeviceCount = 0;
-    *ppDeviceObjectIDs = NULL;
-
-    propAddressDevices.mSelector = kAudioHardwarePropertyDevices;
-    propAddressDevices.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddressDevices.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pDeviceObjectIDs = (AudioObjectID*)ma_malloc(deviceObjectsDataSize, &pContext->allocationCallbacks);
-    if (pDeviceObjectIDs == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize, pDeviceObjectIDs);
-    if (status != noErr) {
-        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pDeviceCount = deviceObjectsDataSize / sizeof(AudioObjectID);
-    *ppDeviceObjectIDs = pDeviceObjectIDs;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_uid_as_CFStringRef(ma_context* pContext, AudioObjectID objectID, CFStringRef* pUID)
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    propAddress.mSelector = kAudioDevicePropertyDeviceUID;
-    propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(*pUID);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, pUID);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_uid(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut)
-{
-    CFStringRef uid;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_uid_as_CFStringRef(pContext, objectID, &uid);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(uid, bufferOut, bufferSize, kCFStringEncodingUTF8)) {
-        return MA_ERROR;
-    }
-
-    ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(uid);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_name(ma_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut)
-{
-    AudioObjectPropertyAddress propAddress;
-    CFStringRef deviceName = NULL;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    propAddress.mSelector = kAudioDevicePropertyDeviceNameCFString;
-    propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(deviceName);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(objectID, &propAddress, 0, NULL, &dataSize, &deviceName);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    if (!((ma_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(deviceName, bufferOut, bufferSize, kCFStringEncodingUTF8)) {
-        return MA_ERROR;
-    }
-
-    ((ma_CFRelease_proc)pContext->coreaudio.CFRelease)(deviceName);
-    return MA_SUCCESS;
-}
-
-static ma_bool32 ma_does_AudioObject_support_scope(ma_context* pContext, AudioObjectID deviceObjectID, AudioObjectPropertyScope scope)
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioBufferList* pBufferList;
-    ma_bool32 isSupported;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* To know whether or not a device is an input device we need ot look at the stream configuration. If it has an output channel it's a playback device. */
-    propAddress.mSelector = kAudioDevicePropertyStreamConfiguration;
-    propAddress.mScope    = scope;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return MA_FALSE;
-    }
-
-    pBufferList = (AudioBufferList*)ma__malloc_from_callbacks(dataSize, &pContext->allocationCallbacks);
-    if (pBufferList == NULL) {
-        return MA_FALSE;   /* Out of memory. */
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferList);
-    if (status != noErr) {
-        ma__free_from_callbacks(pBufferList, &pContext->allocationCallbacks);
-        return MA_FALSE;
-    }
-
-    isSupported = MA_FALSE;
-    if (pBufferList->mNumberBuffers > 0) {
-        isSupported = MA_TRUE;
-    }
-
-    ma__free_from_callbacks(pBufferList, &pContext->allocationCallbacks);
-    return isSupported;
-}
-
-static ma_bool32 ma_does_AudioObject_support_playback(ma_context* pContext, AudioObjectID deviceObjectID)
-{
-    return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeOutput);
-}
-
-static ma_bool32 ma_does_AudioObject_support_capture(ma_context* pContext, AudioObjectID deviceObjectID)
-{
-    return ma_does_AudioObject_support_scope(pContext, deviceObjectID, kAudioObjectPropertyScopeInput);
-}
-
-
-static ma_result ma_get_AudioObject_stream_descriptions(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pDescriptionCount, AudioStreamRangedDescription** ppDescriptions) /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioStreamRangedDescription* pDescriptions;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDescriptionCount != NULL);
-    MA_ASSERT(ppDescriptions != NULL);
-
-    /*
-    TODO: Experiment with kAudioStreamPropertyAvailablePhysicalFormats instead of (or in addition to) kAudioStreamPropertyAvailableVirtualFormats. My
-          MacBook Pro uses s24/32 format, however, which miniaudio does not currently support.
-    */
-    propAddress.mSelector = kAudioStreamPropertyAvailableVirtualFormats; /*kAudioStreamPropertyAvailablePhysicalFormats;*/
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pDescriptions = (AudioStreamRangedDescription*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pDescriptions == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pDescriptions);
-    if (status != noErr) {
-        ma_free(pDescriptions, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pDescriptionCount = dataSize / sizeof(*pDescriptions);
-    *ppDescriptions = pDescriptions;
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_get_AudioObject_channel_layout(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, AudioChannelLayout** ppChannelLayout)   /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioChannelLayout* pChannelLayout;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(ppChannelLayout != NULL);
-
-    *ppChannelLayout = NULL;    /* Safety. */
-
-    propAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pChannelLayout = (AudioChannelLayout*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pChannelLayout == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pChannelLayout);
-    if (status != noErr) {
-        ma_free(pChannelLayout, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *ppChannelLayout = pChannelLayout;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioObject_channel_count(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pChannelCount)
-{
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pChannelCount != NULL);
-
-    *pChannelCount = 0; /* Safety. */
-
-    result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelDescriptions) {
-        *pChannelCount = pChannelLayout->mNumberChannelDescriptions;
-    } else if (pChannelLayout->mChannelLayoutTag == kAudioChannelLayoutTag_UseChannelBitmap) {
-        *pChannelCount = ma_count_set_bits(pChannelLayout->mChannelBitmap);
-    } else {
-        *pChannelCount = AudioChannelLayoutTag_GetNumberOfChannels(pChannelLayout->mChannelLayoutTag);
-    }
-
-    ma_free(pChannelLayout, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-#if 0
-static ma_result ma_get_AudioObject_channel_map(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout);
-    if (result != MA_SUCCESS) {
-        return result;  /* Rather than always failing here, would it be more robust to simply assume a default? */
-    }
-
-    result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap);
-    if (result != MA_SUCCESS) {
-        ma_free(pChannelLayout, &pContext->allocationCallbacks);
-        return result;
-    }
-
-    ma_free(pChannelLayout, &pContext->allocationCallbacks);
-    return result;
-}
-#endif
-
-static ma_result ma_get_AudioObject_sample_rates(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, UInt32* pSampleRateRangesCount, AudioValueRange** ppSampleRateRanges)   /* NOTE: Free the returned pointer with ma_free(). */
-{
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-    AudioValueRange* pSampleRateRanges;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pSampleRateRangesCount != NULL);
-    MA_ASSERT(ppSampleRateRanges != NULL);
-
-    /* Safety. */
-    *pSampleRateRangesCount = 0;
-    *ppSampleRateRanges = NULL;
-
-    propAddress.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    status = ((ma_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pSampleRateRanges = (AudioValueRange*)ma_malloc(dataSize, &pContext->allocationCallbacks);
-    if (pSampleRateRanges == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pSampleRateRanges);
-    if (status != noErr) {
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pSampleRateRangesCount = dataSize / sizeof(*pSampleRateRanges);
-    *ppSampleRateRanges = pSampleRateRanges;
-    return MA_SUCCESS;
-}
-
-#if 0
-static ma_result ma_get_AudioObject_get_closest_sample_rate(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 sampleRateIn, ma_uint32* pSampleRateOut)
-{
-    UInt32 sampleRateRangeCount;
-    AudioValueRange* pSampleRateRanges;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pSampleRateOut != NULL);
-
-    *pSampleRateOut = 0;    /* Safety. */
-
-    result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (sampleRateRangeCount == 0) {
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_ERROR;   /* Should never hit this case should we? */
-    }
-
-    if (sampleRateIn == 0) {
-        /* Search in order of miniaudio's preferred priority. */
-        UInt32 iMALSampleRate;
-        for (iMALSampleRate = 0; iMALSampleRate < ma_countof(g_maStandardSampleRatePriorities); ++iMALSampleRate) {
-            ma_uint32 malSampleRate = g_maStandardSampleRatePriorities[iMALSampleRate];
-            UInt32 iCASampleRate;
-            for (iCASampleRate = 0; iCASampleRate < sampleRateRangeCount; ++iCASampleRate) {
-                AudioValueRange caSampleRate = pSampleRateRanges[iCASampleRate];
-                if (caSampleRate.mMinimum <= malSampleRate && caSampleRate.mMaximum >= malSampleRate) {
-                    *pSampleRateOut = malSampleRate;
-                    ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-                    return MA_SUCCESS;
-                }
-            }
-        }
-
-        /*
-        If we get here it means none of miniaudio's standard sample rates matched any of the supported sample rates from the device. In this
-        case we just fall back to the first one reported by Core Audio.
-        */
-        MA_ASSERT(sampleRateRangeCount > 0);
-
-        *pSampleRateOut = pSampleRateRanges[0].mMinimum;
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_SUCCESS;
-    } else {
-        /* Find the closest match to this sample rate. */
-        UInt32 currentAbsoluteDifference = INT32_MAX;
-        UInt32 iCurrentClosestRange = (UInt32)-1;
-        UInt32 iRange;
-        for (iRange = 0; iRange < sampleRateRangeCount; ++iRange) {
-            if (pSampleRateRanges[iRange].mMinimum <= sampleRateIn && pSampleRateRanges[iRange].mMaximum >= sampleRateIn) {
-                *pSampleRateOut = sampleRateIn;
-                ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-                return MA_SUCCESS;
-            } else {
-                UInt32 absoluteDifference;
-                if (pSampleRateRanges[iRange].mMinimum > sampleRateIn) {
-                    absoluteDifference = pSampleRateRanges[iRange].mMinimum - sampleRateIn;
-                } else {
-                    absoluteDifference = sampleRateIn - pSampleRateRanges[iRange].mMaximum;
-                }
-
-                if (currentAbsoluteDifference > absoluteDifference) {
-                    currentAbsoluteDifference = absoluteDifference;
-                    iCurrentClosestRange = iRange;
-                }
-            }
-        }
-
-        MA_ASSERT(iCurrentClosestRange != (UInt32)-1);
-
-        *pSampleRateOut = pSampleRateRanges[iCurrentClosestRange].mMinimum;
-        ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-        return MA_SUCCESS;
-    }
-
-    /* Should never get here, but it would mean we weren't able to find any suitable sample rates. */
-    /*ma_free(pSampleRateRanges, &pContext->allocationCallbacks);*/
-    /*return MA_ERROR;*/
-}
-#endif
-
-static ma_result ma_get_AudioObject_closest_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32 bufferSizeInFramesIn, ma_uint32* pBufferSizeInFramesOut)
-{
-    AudioObjectPropertyAddress propAddress;
-    AudioValueRange bufferSizeRange;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pBufferSizeInFramesOut != NULL);
-
-    *pBufferSizeInFramesOut = 0;    /* Safety. */
-
-    propAddress.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    dataSize = sizeof(bufferSizeRange);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &bufferSizeRange);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    /* This is just a clamp. */
-    if (bufferSizeInFramesIn < bufferSizeRange.mMinimum) {
-        *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMinimum;
-    } else if (bufferSizeInFramesIn > bufferSizeRange.mMaximum) {
-        *pBufferSizeInFramesOut = (ma_uint32)bufferSizeRange.mMaximum;
-    } else {
-        *pBufferSizeInFramesOut = bufferSizeInFramesIn;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_set_AudioObject_buffer_size_in_frames(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_uint32* pPeriodSizeInOut)
-{
-    ma_result result;
-    ma_uint32 chosenBufferSizeInFrames;
-    AudioObjectPropertyAddress propAddress;
-    UInt32 dataSize;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-
-    result = ma_get_AudioObject_closest_buffer_size_in_frames(pContext, deviceObjectID, deviceType, *pPeriodSizeInOut, &chosenBufferSizeInFrames);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Try setting the size of the buffer... If this fails we just use whatever is currently set. */
-    propAddress.mSelector = kAudioDevicePropertyBufferFrameSize;
-    propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-    propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-    ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(chosenBufferSizeInFrames), &chosenBufferSizeInFrames);
-
-    /* Get the actual size of the buffer. */
-    dataSize = sizeof(*pPeriodSizeInOut);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, &chosenBufferSizeInFrames);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    *pPeriodSizeInOut = chosenBufferSizeInFrames;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_find_default_AudioObjectID(ma_context* pContext, ma_device_type deviceType, AudioObjectID* pDeviceObjectID)
-{
-    AudioObjectPropertyAddress propAddressDefaultDevice;
-    UInt32 defaultDeviceObjectIDSize = sizeof(AudioObjectID);
-    AudioObjectID defaultDeviceObjectID;
-    OSStatus status;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceObjectID != NULL);
-
-    /* Safety. */
-    *pDeviceObjectID = 0;
-
-    propAddressDefaultDevice.mScope = kAudioObjectPropertyScopeGlobal;
-    propAddressDefaultDevice.mElement = kAudioObjectPropertyElementMaster;
-    if (deviceType == ma_device_type_playback) {
-        propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-    } else {
-        propAddressDefaultDevice.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-    }
-
-    defaultDeviceObjectIDSize = sizeof(AudioObjectID);
-    status = ((ma_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, NULL, &defaultDeviceObjectIDSize, &defaultDeviceObjectID);
-    if (status == noErr) {
-        *pDeviceObjectID = defaultDeviceObjectID;
-        return MA_SUCCESS;
-    }
-
-    /* If we get here it means we couldn't find the device. */
-    return MA_NO_DEVICE;
-}
-
-static ma_result ma_find_AudioObjectID(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, AudioObjectID* pDeviceObjectID)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pDeviceObjectID != NULL);
-
-    /* Safety. */
-    *pDeviceObjectID = 0;
-
-    if (pDeviceID == NULL) {
-        /* Default device. */
-        return ma_find_default_AudioObjectID(pContext, deviceType, pDeviceObjectID);
-    } else {
-        /* Explicit device. */
-        UInt32 deviceCount;
-        AudioObjectID* pDeviceObjectIDs;
-        ma_result result;
-        UInt32 iDevice;
-
-        result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice];
-
-            char uid[256];
-            if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(uid), uid) != MA_SUCCESS) {
-                continue;
-            }
-
-            if (deviceType == ma_device_type_playback) {
-                if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
-                    if (strcmp(uid, pDeviceID->coreaudio) == 0) {
-                        *pDeviceObjectID = deviceObjectID;
-                        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-                        return MA_SUCCESS;
-                    }
-                }
-            } else {
-                if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
-                    if (strcmp(uid, pDeviceID->coreaudio) == 0) {
-                        *pDeviceObjectID = deviceObjectID;
-                        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-                        return MA_SUCCESS;
-                    }
-                }
-            }
-        }
-
-        ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-    }
-
-    /* If we get here it means we couldn't find the device. */
-    return MA_NO_DEVICE;
-}
-
-
-static ma_result ma_find_best_format__coreaudio(ma_context* pContext, AudioObjectID deviceObjectID, ma_device_type deviceType, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const AudioStreamBasicDescription* pOrigFormat, AudioStreamBasicDescription* pFormat)
-{
-    UInt32 deviceFormatDescriptionCount;
-    AudioStreamRangedDescription* pDeviceFormatDescriptions;
-    ma_result result;
-    ma_uint32 desiredSampleRate;
-    ma_uint32 desiredChannelCount;
-    ma_format desiredFormat;
-    AudioStreamBasicDescription bestDeviceFormatSoFar;
-    ma_bool32 hasSupportedFormat;
-    UInt32 iFormat;
-
-    result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &deviceFormatDescriptionCount, &pDeviceFormatDescriptions);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    desiredSampleRate = sampleRate;
-    if (desiredSampleRate == 0) {
-        desiredSampleRate = pOrigFormat->mSampleRate;
-    }
-
-    desiredChannelCount = channels;
-    if (desiredChannelCount == 0) {
-        desiredChannelCount = pOrigFormat->mChannelsPerFrame;
-    }
-
-    desiredFormat = format;
-    if (desiredFormat == ma_format_unknown) {
-        result = ma_format_from_AudioStreamBasicDescription(pOrigFormat, &desiredFormat);
-        if (result != MA_SUCCESS || desiredFormat == ma_format_unknown) {
-            desiredFormat = g_maFormatPriorities[0];
-        }
-    }
-
-    /*
-    If we get here it means we don't have an exact match to what the client is asking for. We'll need to find the closest one. The next
-    loop will check for formats that have the same sample rate to what we're asking for. If there is, we prefer that one in all cases.
-    */
-    MA_ZERO_OBJECT(&bestDeviceFormatSoFar);
-
-    hasSupportedFormat = MA_FALSE;
-    for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
-        ma_format format;
-        ma_result formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format);
-        if (formatResult == MA_SUCCESS && format != ma_format_unknown) {
-            hasSupportedFormat = MA_TRUE;
-            bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat;
-            break;
-        }
-    }
-
-    if (!hasSupportedFormat) {
-        ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks);
-        return MA_FORMAT_NOT_SUPPORTED;
-    }
-
-
-    for (iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) {
-        AudioStreamBasicDescription thisDeviceFormat = pDeviceFormatDescriptions[iFormat].mFormat;
-        ma_format thisSampleFormat;
-        ma_result formatResult;
-        ma_format bestSampleFormatSoFar;
-
-        /* If the format is not supported by miniaudio we need to skip this one entirely. */
-        formatResult = ma_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &thisSampleFormat);
-        if (formatResult != MA_SUCCESS || thisSampleFormat == ma_format_unknown) {
-            continue;   /* The format is not supported by miniaudio. Skip. */
-        }
-
-        ma_format_from_AudioStreamBasicDescription(&bestDeviceFormatSoFar, &bestSampleFormatSoFar);
-
-        /* Getting here means the format is supported by miniaudio which makes this format a candidate. */
-        if (thisDeviceFormat.mSampleRate != desiredSampleRate) {
-            /*
-            The sample rate does not match, but this format could still be usable, although it's a very low priority. If the best format
-            so far has an equal sample rate we can just ignore this one.
-            */
-            if (bestDeviceFormatSoFar.mSampleRate == desiredSampleRate) {
-                continue;   /* The best sample rate so far has the same sample rate as what we requested which means it's still the best so far. Skip this format. */
-            } else {
-                /* In this case, neither the best format so far nor this one have the same sample rate. Check the channel count next. */
-                if (thisDeviceFormat.mChannelsPerFrame != desiredChannelCount) {
-                    /* This format has a different sample rate _and_ a different channel count. */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        continue;   /* No change to the best format. */
-                    } else {
-                        /*
-                        Both this format and the best so far have different sample rates and different channel counts. Whichever has the
-                        best format is the new best.
-                        */
-                        if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            continue;
-                        } else {
-                            continue;   /* No change to the best format. */
-                        }
-                    }
-                } else {
-                    /* This format has a different sample rate but the desired channel count. */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        /* Both this format and the best so far have the desired channel count. Whichever has the best format is the new best. */
-                        if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            continue;
-                        } else {
-                            continue;   /* No change to the best format for now. */
-                        }
-                    } else {
-                        /* This format has the desired channel count, but the best so far does not. We have a new best. */
-                        bestDeviceFormatSoFar = thisDeviceFormat;
-                        continue;
-                    }
-                }
-            }
-        } else {
-            /*
-            The sample rates match which makes this format a very high priority contender. If the best format so far has a different
-            sample rate it needs to be replaced with this one.
-            */
-            if (bestDeviceFormatSoFar.mSampleRate != desiredSampleRate) {
-                bestDeviceFormatSoFar = thisDeviceFormat;
-                continue;
-            } else {
-                /* In this case both this format and the best format so far have the same sample rate. Check the channel count next. */
-                if (thisDeviceFormat.mChannelsPerFrame == desiredChannelCount) {
-                    /*
-                    In this case this format has the same channel count as what the client is requesting. If the best format so far has
-                    a different count, this one becomes the new best.
-                    */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame != desiredChannelCount) {
-                        bestDeviceFormatSoFar = thisDeviceFormat;
-                        continue;
-                    } else {
-                        /* In this case both this format and the best so far have the ideal sample rate and channel count. Check the format. */
-                        if (thisSampleFormat == desiredFormat) {
-                            bestDeviceFormatSoFar = thisDeviceFormat;
-                            break;  /* Found the exact match. */
-                        } else {
-                            /* The formats are different. The new best format is the one with the highest priority format according to miniaudio. */
-                            if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                                bestDeviceFormatSoFar = thisDeviceFormat;
-                                continue;
-                            } else {
-                                continue;   /* No change to the best format for now. */
-                            }
-                        }
-                    }
-                } else {
-                    /*
-                    In this case the channel count is different to what the client has requested. If the best so far has the same channel
-                    count as the requested count then it remains the best.
-                    */
-                    if (bestDeviceFormatSoFar.mChannelsPerFrame == desiredChannelCount) {
-                        continue;
-                    } else {
-                        /*
-                        This is the case where both have the same sample rate (good) but different channel counts. Right now both have about
-                        the same priority, but we need to compare the format now.
-                        */
-                        if (thisSampleFormat == bestSampleFormatSoFar) {
-                            if (ma_get_format_priority_index(thisSampleFormat) < ma_get_format_priority_index(bestSampleFormatSoFar)) {
-                                bestDeviceFormatSoFar = thisDeviceFormat;
-                                continue;
-                            } else {
-                                continue;   /* No change to the best format for now. */
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    *pFormat = bestDeviceFormatSoFar;
-
-    ma_free(pDeviceFormatDescriptions, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_get_AudioUnit_channel_map(ma_context* pContext, AudioUnit audioUnit, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    AudioUnitScope deviceScope;
-    AudioUnitElement deviceBus;
-    UInt32 channelLayoutSize;
-    OSStatus status;
-    AudioChannelLayout* pChannelLayout;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    if (deviceType == ma_device_type_playback) {
-        deviceScope = kAudioUnitScope_Input;
-        deviceBus = MA_COREAUDIO_OUTPUT_BUS;
-    } else {
-        deviceScope = kAudioUnitScope_Output;
-        deviceBus = MA_COREAUDIO_INPUT_BUS;
-    }
-
-    status = ((ma_AudioUnitGetPropertyInfo_proc)pContext->coreaudio.AudioUnitGetPropertyInfo)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, &channelLayoutSize, NULL);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-    pChannelLayout = (AudioChannelLayout*)ma__malloc_from_callbacks(channelLayoutSize, &pContext->allocationCallbacks);
-    if (pChannelLayout == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, pChannelLayout, &channelLayoutSize);
-    if (status != noErr) {
-        ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-        return ma_result_from_OSStatus(status);
-    }
-
-    result = ma_get_channel_map_from_AudioChannelLayout(pChannelLayout, pChannelMap, channelMapCap);
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-        return result;
-    }
-
-    ma__free_from_callbacks(pChannelLayout, &pContext->allocationCallbacks);
-    return MA_SUCCESS;
-}
-#endif /* MA_APPLE_DESKTOP */
-
-
-#if !defined(MA_APPLE_DESKTOP)
-static void ma_AVAudioSessionPortDescription_to_device_info(AVAudioSessionPortDescription* pPortDesc, ma_device_info* pInfo)
-{
-    MA_ZERO_OBJECT(pInfo);
-    ma_strncpy_s(pInfo->name,         sizeof(pInfo->name),         [pPortDesc.portName UTF8String], (size_t)-1);
-    ma_strncpy_s(pInfo->id.coreaudio, sizeof(pInfo->id.coreaudio), [pPortDesc.UID      UTF8String], (size_t)-1);
-}
-#endif
-
-static ma_result ma_context_enumerate_devices__coreaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-#if defined(MA_APPLE_DESKTOP)
-    UInt32 deviceCount;
-    AudioObjectID* pDeviceObjectIDs;
-    AudioObjectID defaultDeviceObjectIDPlayback;
-    AudioObjectID defaultDeviceObjectIDCapture;
-    ma_result result;
-    UInt32 iDevice;
-
-    ma_find_default_AudioObjectID(pContext, ma_device_type_playback, &defaultDeviceObjectIDPlayback);   /* OK if this fails. */
-    ma_find_default_AudioObjectID(pContext, ma_device_type_capture,  &defaultDeviceObjectIDCapture);    /* OK if this fails. */
-
-    result = ma_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    for (iDevice = 0; iDevice < deviceCount; ++iDevice) {
-        AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice];
-        ma_device_info info;
-
-        MA_ZERO_OBJECT(&info);
-        if (ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(info.id.coreaudio), info.id.coreaudio) != MA_SUCCESS) {
-            continue;
-        }
-        if (ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(info.name), info.name) != MA_SUCCESS) {
-            continue;
-        }
-
-        if (ma_does_AudioObject_support_playback(pContext, deviceObjectID)) {
-            if (deviceObjectID == defaultDeviceObjectIDPlayback) {
-                info.isDefault = MA_TRUE;
-            }
-
-            if (!callback(pContext, ma_device_type_playback, &info, pUserData)) {
-                break;
-            }
-        }
-        if (ma_does_AudioObject_support_capture(pContext, deviceObjectID)) {
-            if (deviceObjectID == defaultDeviceObjectIDCapture) {
-                info.isDefault = MA_TRUE;
-            }
-
-            if (!callback(pContext, ma_device_type_capture, &info, pUserData)) {
-                break;
-            }
-        }
-    }
-
-    ma_free(pDeviceObjectIDs, &pContext->allocationCallbacks);
-#else
-    ma_device_info info;
-    NSArray *pInputs  = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-    NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs];
-
-    for (AVAudioSessionPortDescription* pPortDesc in pOutputs) {
-        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info);
-        if (!callback(pContext, ma_device_type_playback, &info, pUserData)) {
-            return MA_SUCCESS;
-        }
-    }
-
-    for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, &info);
-        if (!callback(pContext, ma_device_type_capture, &info, pUserData)) {
-            return MA_SUCCESS;
-        }
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-#if defined(MA_APPLE_DESKTOP)
-    /* Desktop */
-    {
-        AudioObjectID deviceObjectID;
-        AudioObjectID defaultDeviceObjectID;
-        UInt32 streamDescriptionCount;
-        AudioStreamRangedDescription* pStreamDescriptions;
-        UInt32 iStreamDescription;
-        UInt32 sampleRateRangeCount;
-        AudioValueRange* pSampleRateRanges;
-
-        ma_find_default_AudioObjectID(pContext, deviceType, &defaultDeviceObjectID);     /* OK if this fails. */
-
-        result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_get_AudioObject_uid(pContext, deviceObjectID, sizeof(pDeviceInfo->id.coreaudio), pDeviceInfo->id.coreaudio);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        result = ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pDeviceInfo->name), pDeviceInfo->name);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        if (deviceObjectID == defaultDeviceObjectID) {
-            pDeviceInfo->isDefault = MA_TRUE;
-        }
-        
-        /*
-        There could be a large number of permutations here. Fortunately there is only a single channel count
-        being reported which reduces this quite a bit. For sample rates we're only reporting those that are
-        one of miniaudio's recognized "standard" rates. If there are still more formats than can fit into
-        our fixed sized array we'll just need to truncate them. This is unlikely and will probably only happen
-        if some driver performs software data conversion and therefore reports every possible format and
-        sample rate.
-        */
-        pDeviceInfo->nativeDataFormatCount = 0;
-        
-        /* Formats. */
-        {
-            ma_format uniqueFormats[ma_format_count];
-            ma_uint32 uniqueFormatCount = 0;
-            ma_uint32 channels;
-            
-            /* Channels. */
-            result = ma_get_AudioObject_channel_count(pContext, deviceObjectID, deviceType, &channels);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-            
-            /* Formats. */
-            result = ma_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &streamDescriptionCount, &pStreamDescriptions);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            for (iStreamDescription = 0; iStreamDescription < streamDescriptionCount; ++iStreamDescription) {
-                ma_format format;
-                ma_bool32 hasFormatBeenHandled = MA_FALSE;
-                ma_uint32 iOutputFormat;
-                ma_uint32 iSampleRate;
-
-                result = ma_format_from_AudioStreamBasicDescription(&pStreamDescriptions[iStreamDescription].mFormat, &format);
-                if (result != MA_SUCCESS) {
-                    continue;
-                }
-
-                MA_ASSERT(format != ma_format_unknown);
-
-                /* Make sure the format isn't already in the output list. */
-                for (iOutputFormat = 0; iOutputFormat < uniqueFormatCount; ++iOutputFormat) {
-                    if (uniqueFormats[iOutputFormat] == format) {
-                        hasFormatBeenHandled = MA_TRUE;
-                        break;
-                    }
-                }
-                
-                /* If we've already handled this format just skip it. */
-                if (hasFormatBeenHandled) {
-                    continue;
-                }
-                
-                uniqueFormatCount += 1;
-                
-
-                /* Sample Rates */
-                result = ma_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges);
-                if (result != MA_SUCCESS) {
-                    return result;
-                }
-                
-                /*
-                Annoyingly Core Audio reports a sample rate range. We just get all the standard rates that are
-                between this range.
-                */
-                for (iSampleRate = 0; iSampleRate < sampleRateRangeCount; ++iSampleRate) {
-                    ma_uint32 iStandardSampleRate;
-                    for (iStandardSampleRate = 0; iStandardSampleRate < ma_countof(g_maStandardSampleRatePriorities); iStandardSampleRate += 1) {
-                        ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iStandardSampleRate];
-                        if (standardSampleRate >= pSampleRateRanges[iSampleRate].mMinimum && standardSampleRate <= pSampleRateRanges[iSampleRate].mMaximum) {
-                            /* We have a new data format. Add it to the list. */
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = standardSampleRate;
-                            pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-                            pDeviceInfo->nativeDataFormatCount += 1;
-                            
-                            if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) {
-                                break;  /* No more room for any more formats. */
-                            }
-                        }
-                    }
-                }
-                
-                ma_free(pSampleRateRanges, &pContext->allocationCallbacks);
-
-                if (pDeviceInfo->nativeDataFormatCount >= ma_countof(pDeviceInfo->nativeDataFormats)) {
-                    break;  /* No more room for any more formats. */
-                }
-            }
-
-            ma_free(pStreamDescriptions, &pContext->allocationCallbacks);
-        }
-    }
-#else
-    /* Mobile */
-    {
-        AudioComponentDescription desc;
-        AudioComponent component;
-        AudioUnit audioUnit;
-        OSStatus status;
-        AudioUnitScope formatScope;
-        AudioUnitElement formatElement;
-        AudioStreamBasicDescription bestFormat;
-        UInt32 propSize;
-
-        /* We want to ensure we use a consistent device name to device enumeration. */
-        if (pDeviceID != NULL) {
-            ma_bool32 found = MA_FALSE;
-            if (deviceType == ma_device_type_playback) {
-                NSArray *pOutputs = [[[AVAudioSession sharedInstance] currentRoute] outputs];
-                for (AVAudioSessionPortDescription* pPortDesc in pOutputs) {
-                    if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo);
-                        found = MA_TRUE;
-                        break;
-                    }
-                }
-            } else {
-                NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-                for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-                    if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                        ma_AVAudioSessionPortDescription_to_device_info(pPortDesc, pDeviceInfo);
-                        found = MA_TRUE;
-                        break;
-                    }
-                }
-            }
-
-            if (!found) {
-                return MA_DOES_NOT_EXIST;
-            }
-        } else {
-            if (deviceType == ma_device_type_playback) {
-                ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-            } else {
-                ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            }
-        }
-
-
-        /*
-        Retrieving device information is more annoying on mobile than desktop. For simplicity I'm locking this down to whatever format is
-        reported on a temporary I/O unit. The problem, however, is that this doesn't return a value for the sample rate which we need to
-        retrieve from the AVAudioSession shared instance.
-        */
-        desc.componentType = kAudioUnitType_Output;
-        desc.componentSubType = kAudioUnitSubType_RemoteIO;
-        desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-        desc.componentFlags = 0;
-        desc.componentFlagsMask = 0;
-
-        component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc);
-        if (component == NULL) {
-            return MA_FAILED_TO_INIT_BACKEND;
-        }
-
-        status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)(component, &audioUnit);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-
-        formatScope   = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output;
-        formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS;
-
-        propSize = sizeof(bestFormat);
-        status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, &propSize);
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(audioUnit);
-        audioUnit = NULL;
-
-        /* Only a single format is being reported for iOS. */
-        pDeviceInfo->nativeDataFormatCount = 1;
-        
-        result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pDeviceInfo->nativeDataFormats[0].format);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-        
-        pDeviceInfo->nativeDataFormats[0].channels = bestFormat.mChannelsPerFrame;
-
-        /*
-        It looks like Apple are wanting to push the whole AVAudioSession thing. Thus, we need to use that to determine device settings. To do
-        this we just get the shared instance and inspect.
-        */
-        @autoreleasepool {
-            AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-            MA_ASSERT(pAudioSession != NULL);
-
-            pDeviceInfo->nativeDataFormats[0].sampleRate = (ma_uint32)pAudioSession.sampleRate;
-        }
-    }
-#endif
-
-    (void)pDeviceInfo; /* Unused. */
-    return MA_SUCCESS;
-}
-
-static AudioBufferList* ma_allocate_AudioBufferList__coreaudio(ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    AudioBufferList* pBufferList;
-    UInt32 audioBufferSizeInBytes;
-    size_t allocationSize;
-
-    MA_ASSERT(sizeInFrames > 0);
-    MA_ASSERT(format != ma_format_unknown);
-    MA_ASSERT(channels > 0);
-
-    allocationSize = sizeof(AudioBufferList) - sizeof(AudioBuffer);  /* Subtract sizeof(AudioBuffer) because that part is dynamically sized. */
-    if (layout == ma_stream_layout_interleaved) {
-        /* Interleaved case. This is the simple case because we just have one buffer. */
-        allocationSize += sizeof(AudioBuffer) * 1;
-    } else {
-        /* Non-interleaved case. This is the more complex case because there's more than one buffer. */
-        allocationSize += sizeof(AudioBuffer) * channels;
-    }
-
-    allocationSize += sizeInFrames * ma_get_bytes_per_frame(format, channels);
-
-    pBufferList = (AudioBufferList*)ma__malloc_from_callbacks(allocationSize, pAllocationCallbacks);
-    if (pBufferList == NULL) {
-        return NULL;
-    }
-
-    audioBufferSizeInBytes = (UInt32)(sizeInFrames * ma_get_bytes_per_sample(format));
-
-    if (layout == ma_stream_layout_interleaved) {
-        pBufferList->mNumberBuffers = 1;
-        pBufferList->mBuffers[0].mNumberChannels = channels;
-        pBufferList->mBuffers[0].mDataByteSize   = audioBufferSizeInBytes * channels;
-        pBufferList->mBuffers[0].mData           = (ma_uint8*)pBufferList + sizeof(AudioBufferList);
-    } else {
-        ma_uint32 iBuffer;
-        pBufferList->mNumberBuffers = channels;
-        for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) {
-            pBufferList->mBuffers[iBuffer].mNumberChannels = 1;
-            pBufferList->mBuffers[iBuffer].mDataByteSize   = audioBufferSizeInBytes;
-            pBufferList->mBuffers[iBuffer].mData           = (ma_uint8*)pBufferList + ((sizeof(AudioBufferList) - sizeof(AudioBuffer)) + (sizeof(AudioBuffer) * channels)) + (audioBufferSizeInBytes * iBuffer);
-        }
-    }
-
-    return pBufferList;
-}
-
-static ma_result ma_device_realloc_AudioBufferList__coreaudio(ma_device* pDevice, ma_uint32 sizeInFrames, ma_format format, ma_uint32 channels, ma_stream_layout layout)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(format != ma_format_unknown);
-    MA_ASSERT(channels > 0);
-
-    /* Only resize the buffer if necessary. */
-    if (pDevice->coreaudio.audioBufferCapInFrames < sizeInFrames) {
-        AudioBufferList* pNewAudioBufferList;
-
-        pNewAudioBufferList = ma_allocate_AudioBufferList__coreaudio(sizeInFrames, format, channels, layout, &pDevice->pContext->allocationCallbacks);
-        if (pNewAudioBufferList != NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        /* At this point we'll have a new AudioBufferList and we can free the old one. */
-        ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-        pDevice->coreaudio.pAudioBufferList = pNewAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames = sizeInFrames;
-    }
-
-    /* Getting here means the capacity of the audio is fine. */
-    return MA_SUCCESS;
-}
-
-
-static OSStatus ma_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pBufferList)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    ma_stream_layout layout;
-
-    MA_ASSERT(pDevice != NULL);
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pBufferList->mNumberBuffers);
-#endif
-
-    /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */
-    layout = ma_stream_layout_interleaved;
-    if (pBufferList->mBuffers[0].mNumberChannels != pDevice->playback.internalChannels) {
-        layout = ma_stream_layout_deinterleaved;
-    }
-
-    if (layout == ma_stream_layout_interleaved) {
-        /* For now we can assume everything is interleaved. */
-        UInt32 iBuffer;
-        for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; ++iBuffer) {
-            if (pBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->playback.internalChannels) {
-                ma_uint32 frameCountForThisBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-                if (frameCountForThisBuffer > 0) {
-                    ma_device_handle_backend_data_callback(pDevice, pBufferList->mBuffers[iBuffer].mData, NULL, frameCountForThisBuffer);
-                }
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            } else {
-                /*
-                This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
-                not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams. We just
-                output silence here.
-                */
-                MA_ZERO_MEMORY(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize);
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            }
-        }
-    } else {
-        /* This is the deinterleaved case. We need to update each buffer in groups of internalChannels. This assumes each buffer is the same size. */
-        MA_ASSERT(pDevice->playback.internalChannels <= MA_MAX_CHANNELS);   /* This should heve been validated at initialization time. */
-
-        /*
-        For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something
-        very strange has happened and we're not going to support it.
-        */
-        if ((pBufferList->mNumberBuffers % pDevice->playback.internalChannels) == 0) {
-            ma_uint8 tempBuffer[4096];
-            UInt32 iBuffer;
-
-            for (iBuffer = 0; iBuffer < pBufferList->mNumberBuffers; iBuffer += pDevice->playback.internalChannels) {
-                ma_uint32 frameCountPerBuffer = pBufferList->mBuffers[iBuffer].mDataByteSize / ma_get_bytes_per_sample(pDevice->playback.internalFormat);
-                ma_uint32 framesRemaining = frameCountPerBuffer;
-
-                while (framesRemaining > 0) {
-                    void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
-                    ma_uint32 iChannel;
-                    ma_uint32 framesToRead = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-                    if (framesToRead > framesRemaining) {
-                        framesToRead = framesRemaining;
-                    }
-                    
-                    ma_device_handle_backend_data_callback(pDevice, tempBuffer, NULL, framesToRead);
-
-                    for (iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) {
-                        ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pBufferList->mBuffers[iBuffer+iChannel].mData, (frameCountPerBuffer - framesRemaining) * ma_get_bytes_per_sample(pDevice->playback.internalFormat));
-                    }
-
-                    ma_deinterleave_pcm_frames(pDevice->playback.internalFormat, pDevice->playback.internalChannels, framesToRead, tempBuffer, ppDeinterleavedBuffers);
-
-                    framesRemaining -= framesToRead;
-                }
-            }
-        }
-    }
-
-    (void)pActionFlags;
-    (void)pTimeStamp;
-    (void)busNumber;
-    (void)frameCount;
-
-    return noErr;
-}
-
-static OSStatus ma_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pActionFlags, const AudioTimeStamp* pTimeStamp, UInt32 busNumber, UInt32 frameCount, AudioBufferList* pUnusedBufferList)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    AudioBufferList* pRenderedBufferList;
-    ma_result result;
-    ma_stream_layout layout;
-    ma_uint32 iBuffer;
-    OSStatus status;
-
-    MA_ASSERT(pDevice != NULL);
-
-    pRenderedBufferList = (AudioBufferList*)pDevice->coreaudio.pAudioBufferList;
-    MA_ASSERT(pRenderedBufferList);
-
-    /* We need to check whether or not we are outputting interleaved or non-interleaved samples. The way we do this is slightly different for each type. */
-    layout = ma_stream_layout_interleaved;
-    if (pRenderedBufferList->mBuffers[0].mNumberChannels != pDevice->capture.internalChannels) {
-        layout = ma_stream_layout_deinterleaved;
-    }
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pRenderedBufferList->mNumberBuffers);
-#endif
-
-    /*
-    There has been a situation reported where frame count passed into this function is greater than the capacity of
-    our capture buffer. There doesn't seem to be a reliable way to determine what the maximum frame count will be,
-    so we need to instead resort to dynamically reallocating our buffer to ensure it's large enough to capture the
-    number of frames requested by this callback.
-    */
-    result = ma_device_realloc_AudioBufferList__coreaudio(pDevice, frameCount, pDevice->capture.internalFormat, pDevice->capture.internalChannels, layout);
-    if (result != MA_SUCCESS) {
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("Failed to allocate AudioBufferList for capture.");
-    #endif
-        return noErr;
-    }
-
-    /*
-    When you call AudioUnitRender(), Core Audio tries to be helpful by setting the mDataByteSize to the number of bytes
-    that were actually rendered. The problem with this is that the next call can fail with -50 due to the size no longer
-    being set to the capacity of the buffer, but instead the size in bytes of the previous render. This will cause a
-    problem when a future call to this callback specifies a larger number of frames.
-
-    To work around this we need to explicitly set the size of each buffer to their respective size in bytes.
-    */
-    for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) {
-        pRenderedBufferList->mBuffers[iBuffer].mDataByteSize = pDevice->coreaudio.audioBufferCapInFrames * ma_get_bytes_per_sample(pDevice->capture.internalFormat) * pRenderedBufferList->mBuffers[iBuffer].mNumberChannels;
-    }
-
-    status = ((ma_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList);
-    if (status != noErr) {
-    #if defined(MA_DEBUG_OUTPUT)
-        printf("  ERROR: AudioUnitRender() failed with %d\n", status);
-    #endif
-        return status;
-    }
-
-    if (layout == ma_stream_layout_interleaved) {
-        for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; ++iBuffer) {
-            if (pRenderedBufferList->mBuffers[iBuffer].mNumberChannels == pDevice->capture.internalChannels) {
-                ma_device_handle_backend_data_callback(pDevice, NULL, pRenderedBufferList->mBuffers[iBuffer].mData, frameCount);
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  mDataByteSize=%d\n", pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            } else {
-                /*
-                This case is where the number of channels in the output buffer do not match our internal channels. It could mean that it's
-                not interleaved, in which case we can't handle right now since miniaudio does not yet support non-interleaved streams.
-                */
-                ma_uint8 silentBuffer[4096];
-                ma_uint32 framesRemaining;
-
-                MA_ZERO_MEMORY(silentBuffer, sizeof(silentBuffer));
-
-                framesRemaining = frameCount;
-                while (framesRemaining > 0) {
-                    ma_uint32 framesToSend = sizeof(silentBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-                    if (framesToSend > framesRemaining) {
-                        framesToSend = framesRemaining;
-                    }
-                    
-                    ma_device_handle_backend_data_callback(pDevice, NULL, silentBuffer, framesToSend);
-
-                    framesRemaining -= framesToSend;
-                }
-
-            #if defined(MA_DEBUG_OUTPUT)
-                printf("  WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, pRenderedBufferList->mBuffers[iBuffer].mDataByteSize);
-            #endif
-            }
-        }
-    } else {
-        /* This is the deinterleaved case. We need to interleave the audio data before sending it to the client. This assumes each buffer is the same size. */
-        MA_ASSERT(pDevice->capture.internalChannels <= MA_MAX_CHANNELS);    /* This should have been validated at initialization time. */
-
-        /*
-        For safety we'll check that the internal channels is a multiple of the buffer count. If it's not it means something
-        very strange has happened and we're not going to support it.
-        */
-        if ((pRenderedBufferList->mNumberBuffers % pDevice->capture.internalChannels) == 0) {
-            ma_uint8 tempBuffer[4096];
-            for (iBuffer = 0; iBuffer < pRenderedBufferList->mNumberBuffers; iBuffer += pDevice->capture.internalChannels) {
-                ma_uint32 framesRemaining = frameCount;
-                while (framesRemaining > 0) {
-                    void* ppDeinterleavedBuffers[MA_MAX_CHANNELS];
-                    ma_uint32 iChannel;
-                    ma_uint32 framesToSend = sizeof(tempBuffer) / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-                    if (framesToSend > framesRemaining) {
-                        framesToSend = framesRemaining;
-                    }
-
-                    for (iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) {
-                        ppDeinterleavedBuffers[iChannel] = (void*)ma_offset_ptr(pRenderedBufferList->mBuffers[iBuffer+iChannel].mData, (frameCount - framesRemaining) * ma_get_bytes_per_sample(pDevice->capture.internalFormat));
-                    }
-
-                    ma_interleave_pcm_frames(pDevice->capture.internalFormat, pDevice->capture.internalChannels, framesToSend, (const void**)ppDeinterleavedBuffers, tempBuffer);
-                    ma_device_handle_backend_data_callback(pDevice, NULL, tempBuffer, framesToSend);
-
-                    framesRemaining -= framesToSend;
-                }
-            }
-        }
-    }
-
-    (void)pActionFlags;
-    (void)pTimeStamp;
-    (void)busNumber;
-    (void)frameCount;
-    (void)pUnusedBufferList;
-
-    return noErr;
-}
-
-static void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPropertyID propertyID, AudioUnitScope scope, AudioUnitElement element)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    There's been a report of a deadlock here when triggered by ma_device_uninit(). It looks like
-    AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in ma_device_uninit)
-    can try waiting on the same lock. I'm going to try working around this by not calling any Core
-    Audio APIs in the callback when the device has been stopped or uninitialized.
-    */
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED || ma_device_get_state(pDevice) == MA_STATE_STOPPING || ma_device_get_state(pDevice) == MA_STATE_STOPPED) {
-        ma_stop_proc onStop = pDevice->onStop;
-        if (onStop) {
-            onStop(pDevice);
-        }
-
-        ma_event_signal(&pDevice->coreaudio.stopEvent);
-    } else {
-        UInt32 isRunning;
-        UInt32 isRunningSize = sizeof(isRunning);
-        OSStatus status = ((ma_AudioUnitGetProperty_proc)pDevice->pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioOutputUnitProperty_IsRunning, scope, element, &isRunning, &isRunningSize);
-        if (status != noErr) {
-            return; /* Don't really know what to do in this case... just ignore it, I suppose... */
-        }
-
-        if (!isRunning) {
-            ma_stop_proc onStop;
-
-            /*
-            The stop event is a bit annoying in Core Audio because it will be called when we automatically switch the default device. Some scenarios to consider:
-
-            1) When the device is unplugged, this will be called _before_ the default device change notification.
-            2) When the device is changed via the default device change notification, this will be called _after_ the switch.
-
-            For case #1, we just check if there's a new default device available. If so, we just ignore the stop event. For case #2 we check a flag.
-            */
-            if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isDefaultPlaybackDevice) ||
-                ((audioUnit == pDevice->coreaudio.audioUnitCapture)  && pDevice->coreaudio.isDefaultCaptureDevice)) {
-                /*
-                It looks like the device is switching through an external event, such as the user unplugging the device or changing the default device
-                via the operating system's sound settings. If we're re-initializing the device, we just terminate because we want the stopping of the
-                device to be seamless to the client (we don't want them receiving the onStop event and thinking that the device has stopped when it
-                hasn't!).
-                */
-                if (((audioUnit == pDevice->coreaudio.audioUnitPlayback) && pDevice->coreaudio.isSwitchingPlaybackDevice) ||
-                    ((audioUnit == pDevice->coreaudio.audioUnitCapture)  && pDevice->coreaudio.isSwitchingCaptureDevice)) {
-                    return;
-                }
-
-                /*
-                Getting here means the device is not reinitializing which means it may have been unplugged. From what I can see, it looks like Core Audio
-                will try switching to the new default device seamlessly. We need to somehow find a way to determine whether or not Core Audio will most
-                likely be successful in switching to the new device.
-
-                TODO: Try to predict if Core Audio will switch devices. If not, the onStop callback needs to be posted.
-                */
-                return;
-            }
-
-            /* Getting here means we need to stop the device. */
-            onStop = pDevice->onStop;
-            if (onStop) {
-                onStop(pDevice);
-            }
-        }
-    }
-
-    (void)propertyID; /* Unused. */
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_spinlock g_DeviceTrackingInitLock_CoreAudio = 0;  /* A spinlock for mutal exclusion of the init/uninit of the global tracking data. Initialization to 0 is what we need. */
-static ma_uint32   g_DeviceTrackingInitCounter_CoreAudio = 0;
-static ma_mutex    g_DeviceTrackingMutex_CoreAudio;
-static ma_device** g_ppTrackedDevices_CoreAudio = NULL;
-static ma_uint32   g_TrackedDeviceCap_CoreAudio = 0;
-static ma_uint32   g_TrackedDeviceCount_CoreAudio = 0;
-
-static OSStatus ma_default_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData)
-{
-    ma_device_type deviceType;
-
-    /* Not sure if I really need to check this, but it makes me feel better. */
-    if (addressCount == 0) {
-        return noErr;
-    }
-
-    if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultOutputDevice) {
-        deviceType = ma_device_type_playback;
-    } else if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultInputDevice) {
-        deviceType = ma_device_type_capture;
-    } else {
-        return noErr;   /* Should never hit this. */
-    }
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        ma_uint32 iDevice;
-        for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) {
-            ma_result reinitResult;
-            ma_device* pDevice;
-
-            pDevice = g_ppTrackedDevices_CoreAudio[iDevice];
-            if (pDevice->type == deviceType || pDevice->type == ma_device_type_duplex) {
-                if (deviceType == ma_device_type_playback) {
-                    pDevice->coreaudio.isSwitchingPlaybackDevice = MA_TRUE;
-                    reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE);
-                    pDevice->coreaudio.isSwitchingPlaybackDevice = MA_FALSE;
-                } else {
-                    pDevice->coreaudio.isSwitchingCaptureDevice = MA_TRUE;
-                    reinitResult = ma_device_reinit_internal__coreaudio(pDevice, deviceType, MA_TRUE);
-                    pDevice->coreaudio.isSwitchingCaptureDevice = MA_FALSE;
-                }
-
-                if (reinitResult == MA_SUCCESS) {
-                    ma_device__post_init_setup(pDevice, deviceType);
-
-                    /* Restart the device if required. If this fails we need to stop the device entirely. */
-                    if (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-                        OSStatus status;
-                        if (deviceType == ma_device_type_playback) {
-                            status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-                            if (status != noErr) {
-                                if (pDevice->type == ma_device_type_duplex) {
-                                    ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                                }
-                                ma_device__set_state(pDevice, MA_STATE_STOPPED);
-                            }
-                        } else if (deviceType == ma_device_type_capture) {
-                            status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                            if (status != noErr) {
-                                if (pDevice->type == ma_device_type_duplex) {
-                                    ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-                                }
-                                ma_device__set_state(pDevice, MA_STATE_STOPPED);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    /* Unused parameters. */
-    (void)objectID;
-    (void)pUserData;
-
-    return noErr;
-}
-
-static ma_result ma_context__init_device_tracking__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio);
-    {
-        /* Don't do anything if we've already initializd device tracking. */
-        if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
-            AudioObjectPropertyAddress propAddress;
-            propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            ma_mutex_init(&g_DeviceTrackingMutex_CoreAudio);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-            ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-            ((ma_AudioObjectAddPropertyListener_proc)pContext->coreaudio.AudioObjectAddPropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            g_DeviceTrackingInitCounter_CoreAudio += 1;
-        }
-    }
-    ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context__uninit_device_tracking__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    ma_spinlock_lock(&g_DeviceTrackingInitLock_CoreAudio);
-    {
-        g_DeviceTrackingInitCounter_CoreAudio -= 1;
-
-        if (g_DeviceTrackingInitCounter_CoreAudio == 0) {
-            AudioObjectPropertyAddress propAddress;
-            propAddress.mScope    = kAudioObjectPropertyScopeGlobal;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultInputDevice;
-            ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            propAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
-            ((ma_AudioObjectRemovePropertyListener_proc)pContext->coreaudio.AudioObjectRemovePropertyListener)(kAudioObjectSystemObject, &propAddress, &ma_default_device_changed__coreaudio, NULL);
-
-            /* At this point there should be no tracked devices. If not there's an error somewhere. */
-            if (g_ppTrackedDevices_CoreAudio != NULL) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "You have uninitialized all contexts while an associated device is still active.", MA_INVALID_OPERATION);
-            }
-
-            ma_mutex_uninit(&g_DeviceTrackingMutex_CoreAudio);
-        }
-    }
-    ma_spinlock_unlock(&g_DeviceTrackingInitLock_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__track__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        /* Allocate memory if required. */
-        if (g_TrackedDeviceCap_CoreAudio <= g_TrackedDeviceCount_CoreAudio) {
-            ma_uint32 oldCap;
-            ma_uint32 newCap;
-            ma_device** ppNewDevices;
-
-            oldCap = g_TrackedDeviceCap_CoreAudio;
-            newCap = g_TrackedDeviceCap_CoreAudio * 2;
-            if (newCap == 0) {
-                newCap = 1;
-            }
-
-            ppNewDevices = (ma_device**)ma__realloc_from_callbacks(g_ppTrackedDevices_CoreAudio, sizeof(*g_ppTrackedDevices_CoreAudio)*newCap, sizeof(*g_ppTrackedDevices_CoreAudio)*oldCap, &pDevice->pContext->allocationCallbacks);
-            if (ppNewDevices == NULL) {
-                ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-                return MA_OUT_OF_MEMORY;
-            }
-
-            g_ppTrackedDevices_CoreAudio = ppNewDevices;
-            g_TrackedDeviceCap_CoreAudio = newCap;
-        }
-
-        g_ppTrackedDevices_CoreAudio[g_TrackedDeviceCount_CoreAudio] = pDevice;
-        g_TrackedDeviceCount_CoreAudio += 1;
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device__untrack__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    ma_mutex_lock(&g_DeviceTrackingMutex_CoreAudio);
-    {
-        ma_uint32 iDevice;
-        for (iDevice = 0; iDevice < g_TrackedDeviceCount_CoreAudio; iDevice += 1) {
-            if (g_ppTrackedDevices_CoreAudio[iDevice] == pDevice) {
-                /* We've found the device. We now need to remove it from the list. */
-                ma_uint32 jDevice;
-                for (jDevice = iDevice; jDevice < g_TrackedDeviceCount_CoreAudio-1; jDevice += 1) {
-                    g_ppTrackedDevices_CoreAudio[jDevice] = g_ppTrackedDevices_CoreAudio[jDevice+1];
-                }
-
-                g_TrackedDeviceCount_CoreAudio -= 1;
-
-                /* If there's nothing else in the list we need to free memory. */
-                if (g_TrackedDeviceCount_CoreAudio == 0) {
-                    ma__free_from_callbacks(g_ppTrackedDevices_CoreAudio, &pDevice->pContext->allocationCallbacks);
-                    g_ppTrackedDevices_CoreAudio = NULL;
-                    g_TrackedDeviceCap_CoreAudio = 0;
-                }
-
-                break;
-            }
-        }
-    }
-    ma_mutex_unlock(&g_DeviceTrackingMutex_CoreAudio);
-
-    return MA_SUCCESS;
-}
-#endif
-
-#if defined(MA_APPLE_MOBILE)
-@interface ma_router_change_handler:NSObject {
-    ma_device* m_pDevice;
-}
-@end
-
-@implementation ma_router_change_handler
--(id)init:(ma_device*)pDevice
-{
-    self = [super init];
-    m_pDevice = pDevice;
-
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handle_route_change:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
-
-    return self;
-}
-
--(void)dealloc
-{
-    [self remove_handler];
-}
-
--(void)remove_handler
-{
-    [[NSNotificationCenter defaultCenter] removeObserver:self name:AVAudioSessionRouteChangeNotification object:nil];
-}
-
--(void)handle_route_change:(NSNotification*)pNotification
-{
-    AVAudioSession* pSession = [AVAudioSession sharedInstance];
-
-    NSInteger reason = [[[pNotification userInfo] objectForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
-    switch (reason)
-    {
-        case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOldDeviceUnavailable\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNewDeviceAvailable\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonNoSuitableRouteForCategory\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonWakeFromSleep:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonWakeFromSleep\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonOverride:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonOverride\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonCategoryChange:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonCategoryChange\n");
-        #endif
-        } break;
-
-        case AVAudioSessionRouteChangeReasonUnknown:
-        default:
-        {
-        #if defined(MA_DEBUG_OUTPUT)
-            printf("[Core Audio] Route Changed: AVAudioSessionRouteChangeReasonUnknown\n");
-        #endif
-        } break;
-    }
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("[Core Audio] Changing Route. inputNumberChannels=%d; outputNumberOfChannels=%d\n", (int)pSession.inputNumberOfChannels, (int)pSession.outputNumberOfChannels);
-#endif
-
-    ma_uint32 previousState = ma_device_get_state(m_pDevice);
-
-    if (previousState == MA_STATE_STARTED) {
-        ma_device_stop(m_pDevice);
-    }
-
-    if (m_pDevice->type == ma_device_type_capture || m_pDevice->type == ma_device_type_duplex) {
-        m_pDevice->capture.internalChannels   = (ma_uint32)pSession.inputNumberOfChannels;
-        m_pDevice->capture.internalSampleRate = (ma_uint32)pSession.sampleRate;
-        ma_device__post_init_setup(m_pDevice, ma_device_type_capture);
-    }
-    if (m_pDevice->type == ma_device_type_playback || m_pDevice->type == ma_device_type_duplex) {
-        m_pDevice->playback.internalChannels   = (ma_uint32)pSession.outputNumberOfChannels;
-        m_pDevice->playback.internalSampleRate = (ma_uint32)pSession.sampleRate;
-        ma_device__post_init_setup(m_pDevice, ma_device_type_playback);
-    }
-
-    if (previousState == MA_STATE_STARTED) {
-        ma_device_start(m_pDevice);
-    }
-}
-@end
-#endif
-
-static ma_result ma_device_uninit__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED);
-
-#if defined(MA_APPLE_DESKTOP)
-    /*
-    Make sure we're no longer tracking the device. It doesn't matter if we call this for a non-default device because it'll
-    just gracefully ignore it.
-    */
-    ma_device__untrack__coreaudio(pDevice);
-#endif
-#if defined(MA_APPLE_MOBILE)
-    if (pDevice->coreaudio.pRouteChangeHandler != NULL) {
-        ma_router_change_handler* pRouteChangeHandler = (__bridge_transfer ma_router_change_handler*)pDevice->coreaudio.pRouteChangeHandler;
-        [pRouteChangeHandler remove_handler];
-    }
-#endif
-
-    if (pDevice->coreaudio.audioUnitCapture != NULL) {
-        ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-    }
-    if (pDevice->coreaudio.audioUnitPlayback != NULL) {
-        ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-    }
-
-    if (pDevice->coreaudio.pAudioBufferList) {
-        ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-typedef struct
-{
-    ma_bool32 allowNominalSampleRateChange;
-
-    /* Input. */
-    ma_format formatIn;
-    ma_uint32 channelsIn;
-    ma_uint32 sampleRateIn;
-    ma_channel channelMapIn[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesIn;
-    ma_uint32 periodSizeInMillisecondsIn;
-    ma_uint32 periodsIn;
-    ma_share_mode shareMode;
-    ma_performance_profile performanceProfile;
-    ma_bool32 registerStopEvent;
-
-    /* Output. */
-#if defined(MA_APPLE_DESKTOP)
-    AudioObjectID deviceObjectID;
-#endif
-    AudioComponent component;
-    AudioUnit audioUnit;
-    AudioBufferList* pAudioBufferList;  /* Only used for input devices. */
-    ma_format formatOut;
-    ma_uint32 channelsOut;
-    ma_uint32 sampleRateOut;
-    ma_channel channelMapOut[MA_MAX_CHANNELS];
-    ma_uint32 periodSizeInFramesOut;
-    ma_uint32 periodsOut;
-    char deviceName[256];
-} ma_device_init_internal_data__coreaudio;
-
-static ma_result ma_device_init_internal__coreaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_init_internal_data__coreaudio* pData, void* pDevice_DoNotReference)   /* <-- pDevice is typed as void* intentionally so as to avoid accidentally referencing it. */
-{
-    ma_result result;
-    OSStatus status;
-    UInt32 enableIOFlag;
-    AudioStreamBasicDescription bestFormat;
-    UInt32 actualPeriodSizeInFrames;
-    AURenderCallbackStruct callbackInfo;
-#if defined(MA_APPLE_DESKTOP)
-    AudioObjectID deviceObjectID;
-#else
-    UInt32 actualPeriodSizeInFramesSize = sizeof(actualPeriodSizeInFrames);
-#endif
-
-    /* This API should only be used for a single device type: playback or capture. No full-duplex mode. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(deviceType == ma_device_type_playback || deviceType == ma_device_type_capture);
-
-#if defined(MA_APPLE_DESKTOP)
-    pData->deviceObjectID = 0;
-#endif
-    pData->component = NULL;
-    pData->audioUnit = NULL;
-    pData->pAudioBufferList = NULL;
-
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pData->deviceObjectID = deviceObjectID;
-#endif
-
-    /* Core audio doesn't really use the notion of a period so we can leave this unmodified, but not too over the top. */
-    pData->periodsOut = pData->periodsIn;
-    if (pData->periodsOut == 0) {
-        pData->periodsOut = MA_DEFAULT_PERIODS;
-    }
-    if (pData->periodsOut > 16) {
-        pData->periodsOut = 16;
-    }
-
-
-    /* Audio unit. */
-    status = ((ma_AudioComponentInstanceNew_proc)pContext->coreaudio.AudioComponentInstanceNew)((AudioComponent)pContext->coreaudio.component, (AudioUnit*)&pData->audioUnit);
-    if (status != noErr) {
-        return ma_result_from_OSStatus(status);
-    }
-
-
-    /* The input/output buses need to be explicitly enabled and disabled. We set the flag based on the output unit first, then we just swap it for input. */
-    enableIOFlag = 1;
-    if (deviceType == ma_device_type_capture) {
-        enableIOFlag = 0;
-    }
-
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &enableIOFlag, sizeof(enableIOFlag));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    enableIOFlag = (enableIOFlag == 0) ? 1 : 0;
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &enableIOFlag, sizeof(enableIOFlag));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-
-    /* Set the device to use with this audio unit. This is only used on desktop since we are using defaults on mobile. */
-#if defined(MA_APPLE_DESKTOP)
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceObjectID, sizeof(deviceObjectID));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(result);
-    }
-#else
-    /*
-    For some reason it looks like Apple is only allowing selection of the input device. There does not appear to be any way to change
-    the default output route. I have no idea why this is like this, but for now we'll only be able to configure capture devices.
-    */
-    if (pDeviceID != NULL) {
-        if (deviceType == ma_device_type_capture) {
-            ma_bool32 found = MA_FALSE;
-            NSArray *pInputs = [[[AVAudioSession sharedInstance] currentRoute] inputs];
-            for (AVAudioSessionPortDescription* pPortDesc in pInputs) {
-                if (strcmp(pDeviceID->coreaudio, [pPortDesc.UID UTF8String]) == 0) {
-                    [[AVAudioSession sharedInstance] setPreferredInput:pPortDesc error:nil];
-                    found = MA_TRUE;
-                    break;
-                }
-            }
-
-            if (found == MA_FALSE) {
-                return MA_DOES_NOT_EXIST;
-            }
-        }
-    }
-#endif
-
-    /*
-    Format. This is the hardest part of initialization because there's a few variables to take into account.
-      1) The format must be supported by the device.
-      2) The format must be supported miniaudio.
-      3) There's a priority that miniaudio prefers.
-
-    Ideally we would like to use a format that's as close to the hardware as possible so we can get as close to a passthrough as possible. The
-    most important property is the sample rate. miniaudio can do format conversion for any sample rate and channel count, but cannot do the same
-    for the sample data format. If the sample data format is not supported by miniaudio it must be ignored completely.
-
-    On mobile platforms this is a bit different. We just force the use of whatever the audio unit's current format is set to.
-    */
-    {
-        AudioStreamBasicDescription origFormat;
-        UInt32 origFormatSize = sizeof(origFormat);
-        AudioUnitScope   formatScope   = (deviceType == ma_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output;
-        AudioUnitElement formatElement = (deviceType == ma_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS;
-
-        if (deviceType == ma_device_type_playback) {
-            status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &origFormat, &origFormatSize);
-        } else {
-            status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &origFormat, &origFormatSize);
-        }
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-
-    #if defined(MA_APPLE_DESKTOP)
-        result = ma_find_best_format__coreaudio(pContext, deviceObjectID, deviceType, pData->formatIn, pData->channelsIn, pData->sampleRateIn, &origFormat, &bestFormat);
-        if (result != MA_SUCCESS) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return result;
-        }
-
-        /*
-        Technical Note TN2091: Device input using the HAL Output Audio Unit
-            https://developer.apple.com/library/archive/technotes/tn2091/_index.html
-
-        This documentation says the following:
-
-            The internal AudioConverter can handle any *simple* conversion. Typically, this means that a client can specify ANY
-            variant of the PCM formats. Consequently, the device's sample rate should match the desired sample rate. If sample rate
-            conversion is needed, it can be accomplished by buffering the input and converting the data on a separate thread with
-            another AudioConverter.
-
-        The important part here is the mention that it can handle *simple* conversions, which does *not* include sample rate. We
-        therefore want to ensure the sample rate stays consistent. This document is specifically for input, but I'm going to play it
-        safe and apply the same rule to output as well.
-
-        I have tried going against the documentation by setting the sample rate anyway, but this just results in AudioUnitRender()
-        returning a result code of -10863. I have also tried changing the format directly on the input scope on the input bus, but
-        this just results in `ca_require: IsStreamFormatWritable(inScope, inElement) NotWritable` when trying to set the format.
-
-        Something that does seem to work, however, has been setting the nominal sample rate on the deivce object. The problem with
-        this, however, is that it actually changes the sample rate at the operating system level and not just the application. This
-        could be intrusive to the user, however, so I don't think it's wise to make this the default. Instead I'm making this a
-        configuration option. When the `coreaudio.allowNominalSampleRateChange` config option is set to true, changing the sample
-        rate will be allowed. Otherwise it'll be fixed to the current sample rate. To check the system-defined sample rate, run
-        the Audio MIDI Setup program that comes installed on macOS and observe how the sample rate changes as the sample rate is
-        changed by miniaudio.
-        */
-        if (pData->allowNominalSampleRateChange) {
-            AudioValueRange sampleRateRange;
-            AudioObjectPropertyAddress propAddress;
-
-            sampleRateRange.mMinimum = bestFormat.mSampleRate;
-            sampleRateRange.mMaximum = bestFormat.mSampleRate;
-
-            propAddress.mSelector = kAudioDevicePropertyNominalSampleRate;
-            propAddress.mScope    = (deviceType == ma_device_type_playback) ? kAudioObjectPropertyScopeOutput : kAudioObjectPropertyScopeInput;
-            propAddress.mElement  = kAudioObjectPropertyElementMaster;
-
-            status = ((ma_AudioObjectSetPropertyData_proc)pContext->coreaudio.AudioObjectSetPropertyData)(deviceObjectID, &propAddress, 0, NULL, sizeof(sampleRateRange), &sampleRateRange);
-            if (status != noErr) {
-                bestFormat.mSampleRate = origFormat.mSampleRate;
-            }
-        } else {
-            bestFormat.mSampleRate = origFormat.mSampleRate;
-        }
-
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
-        if (status != noErr) {
-            /* We failed to set the format, so fall back to the current format of the audio unit. */
-            bestFormat = origFormat;
-        }
-    #else
-        bestFormat = origFormat;
-
-        /*
-        Sample rate is a little different here because for some reason kAudioUnitProperty_StreamFormat returns 0... Oh well. We need to instead try
-        setting the sample rate to what the user has requested and then just see the results of it. Need to use some Objective-C here for this since
-        it depends on Apple's AVAudioSession API. To do this we just get the shared AVAudioSession instance and then set it. Note that from what I
-        can tell, it looks like the sample rate is shared between playback and capture for everything.
-        */
-        @autoreleasepool {
-            AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-            MA_ASSERT(pAudioSession != NULL);
-
-            [pAudioSession setPreferredSampleRate:(double)pData->sampleRateIn error:nil];
-            bestFormat.mSampleRate = pAudioSession.sampleRate;
-
-            /*
-            I've had a report that the channel count returned by AudioUnitGetProperty above is inconsistent with
-            AVAudioSession outputNumberOfChannels. I'm going to try using the AVAudioSession values instead.
-            */
-            if (deviceType == ma_device_type_playback) {
-                bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.outputNumberOfChannels;
-            }
-            if (deviceType == ma_device_type_capture) {
-                bestFormat.mChannelsPerFrame = (UInt32)pAudioSession.inputNumberOfChannels;
-            }
-        }
-
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, formatScope, formatElement, &bestFormat, sizeof(bestFormat));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    #endif
-
-        result = ma_format_from_AudioStreamBasicDescription(&bestFormat, &pData->formatOut);
-        if (result != MA_SUCCESS) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return result;
-        }
-
-        if (pData->formatOut == ma_format_unknown) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        pData->channelsOut   = bestFormat.mChannelsPerFrame;
-        pData->sampleRateOut = bestFormat.mSampleRate;
-    }
-
-    /* Clamp the channel count for safety. */
-    if (pData->channelsOut > MA_MAX_CHANNELS) {
-        pData->channelsOut = MA_MAX_CHANNELS;
-    }
-
-    /*
-    Internal channel map. This is weird in my testing. If I use the AudioObject to get the
-    channel map, the channel descriptions are set to "Unknown" for some reason. To work around
-    this it looks like retrieving it from the AudioUnit will work. However, and this is where
-    it gets weird, it doesn't seem to work with capture devices, nor at all on iOS... Therefore
-    I'm going to fall back to a default assumption in these cases.
-    */
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_get_AudioUnit_channel_map(pContext, pData->audioUnit, deviceType, pData->channelMapOut, pData->channelsOut);
-    if (result != MA_SUCCESS) {
-    #if 0
-        /* Try falling back to the channel map from the AudioObject. */
-        result = ma_get_AudioObject_channel_map(pContext, deviceObjectID, deviceType, pData->channelMapOut, pData->channelsOut);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    #else
-        /* Fall back to default assumptions. */
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pData->channelsOut, pData->channelMapOut);
-    #endif
-    }
-#else
-    /* TODO: Figure out how to get the channel map using AVAudioSession. */
-    ma_get_standard_channel_map(ma_standard_channel_map_default, pData->channelsOut, pData->channelMapOut);
-#endif
-
-
-    /* Buffer size. Not allowing this to be configurable on iOS. */
-    if (pData->periodSizeInFramesIn == 0) {
-        if (pData->periodSizeInMillisecondsIn == 0) {
-            if (pData->performanceProfile == ma_performance_profile_low_latency) {
-                actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, pData->sampleRateOut);
-            } else {
-                actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, pData->sampleRateOut);
-            }
-        } else {
-            actualPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pData->periodSizeInMillisecondsIn, pData->sampleRateOut);
-        }
-    } else {
-        actualPeriodSizeInFrames = pData->periodSizeInFramesIn;
-    }
-
-#if defined(MA_APPLE_DESKTOP)
-    result = ma_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualPeriodSizeInFrames);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-#else
-    /*
-    I don't know how to configure buffer sizes on iOS so for now we're not allowing it to be configured. Instead we're
-    just going to set it to the value of kAudioUnitProperty_MaximumFramesPerSlice.
-    */
-    status = ((ma_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, &actualPeriodSizeInFramesSize);
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-#endif
-
-
-    /*
-    During testing I discovered that the buffer size can be too big. You'll get an error like this:
-
-      kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=4096, mMaxFramesPerSlice=512
-
-    Note how inFramesToProcess is smaller than mMaxFramesPerSlice. To fix, we need to set kAudioUnitProperty_MaximumFramesPerSlice to that
-    of the size of our buffer, or do it the other way around and set our buffer size to the kAudioUnitProperty_MaximumFramesPerSlice.
-    */
-    status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &actualPeriodSizeInFrames, sizeof(actualPeriodSizeInFrames));
-    if (status != noErr) {
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    pData->periodSizeInFramesOut = (ma_uint32)actualPeriodSizeInFrames;
-
-    /* We need a buffer list if this is an input device. We render into this in the input callback. */
-    if (deviceType == ma_device_type_capture) {
-        ma_bool32 isInterleaved = (bestFormat.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0;
-        AudioBufferList* pBufferList;
-
-        pBufferList = ma_allocate_AudioBufferList__coreaudio(pData->periodSizeInFramesOut, pData->formatOut, pData->channelsOut, (isInterleaved) ? ma_stream_layout_interleaved : ma_stream_layout_deinterleaved, &pContext->allocationCallbacks);
-        if (pBufferList == NULL) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pData->pAudioBufferList = pBufferList;
-    }
-
-    /* Callbacks. */
-    callbackInfo.inputProcRefCon = pDevice_DoNotReference;
-    if (deviceType == ma_device_type_playback) {
-        callbackInfo.inputProc = ma_on_output__coreaudio;
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    } else {
-        callbackInfo.inputProc = ma_on_input__coreaudio;
-        status = ((ma_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callbackInfo, sizeof(callbackInfo));
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* We need to listen for stop events. */
-    if (pData->registerStopEvent) {
-        status = ((ma_AudioUnitAddPropertyListener_proc)pContext->coreaudio.AudioUnitAddPropertyListener)(pData->audioUnit, kAudioOutputUnitProperty_IsRunning, on_start_stop__coreaudio, pDevice_DoNotReference);
-        if (status != noErr) {
-            ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* Initialize the audio unit. */
-    status = ((ma_AudioUnitInitialize_proc)pContext->coreaudio.AudioUnitInitialize)(pData->audioUnit);
-    if (status != noErr) {
-        ma__free_from_callbacks(pData->pAudioBufferList, &pContext->allocationCallbacks);
-        pData->pAudioBufferList = NULL;
-        ((ma_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit);
-        return ma_result_from_OSStatus(status);
-    }
-
-    /* Grab the name. */
-#if defined(MA_APPLE_DESKTOP)
-    ma_get_AudioObject_name(pContext, deviceObjectID, sizeof(pData->deviceName), pData->deviceName);
-#else
-    if (deviceType == ma_device_type_playback) {
-        ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_PLAYBACK_DEVICE_NAME);
-    } else {
-        ma_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_CAPTURE_DEVICE_NAME);
-    }
-#endif
-
-    return result;
-}
-
-#if defined(MA_APPLE_DESKTOP)
-static ma_result ma_device_reinit_internal__coreaudio(ma_device* pDevice, ma_device_type deviceType, ma_bool32 disposePreviousAudioUnit)
-{
-    ma_device_init_internal_data__coreaudio data;
-    ma_result result;
-
-    /* This should only be called for playback or capture, not duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    data.allowNominalSampleRateChange = MA_FALSE;   /* Don't change the nominal sample rate when switching devices. */
-
-    if (deviceType == ma_device_type_capture) {
-        data.formatIn               = pDevice->capture.format;
-        data.channelsIn             = pDevice->capture.channels;
-        data.sampleRateIn           = pDevice->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->capture.channelMap, sizeof(pDevice->capture.channelMap));
-        data.shareMode              = pDevice->capture.shareMode;
-        data.performanceProfile     = pDevice->coreaudio.originalPerformanceProfile;
-        data.registerStopEvent      = MA_TRUE;
-
-        if (disposePreviousAudioUnit) {
-            ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-            ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        }
-        if (pDevice->coreaudio.pAudioBufferList) {
-            ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-        }
-    } else if (deviceType == ma_device_type_playback) {
-        data.formatIn               = pDevice->playback.format;
-        data.channelsIn             = pDevice->playback.channels;
-        data.sampleRateIn           = pDevice->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDevice->playback.channelMap, sizeof(pDevice->playback.channelMap));
-        data.shareMode              = pDevice->playback.shareMode;
-        data.performanceProfile     = pDevice->coreaudio.originalPerformanceProfile;
-        data.registerStopEvent      = (pDevice->type != ma_device_type_duplex);
-
-        if (disposePreviousAudioUnit) {
-            ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-            ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        }
-    }
-    data.periodSizeInFramesIn       = pDevice->coreaudio.originalPeriodSizeInFrames;
-    data.periodSizeInMillisecondsIn = pDevice->coreaudio.originalPeriodSizeInMilliseconds;
-    data.periodsIn                  = pDevice->coreaudio.originalPeriods;
-
-    /* Need at least 3 periods for duplex. */
-    if (data.periodsIn < 3 && pDevice->type == ma_device_type_duplex) {
-        data.periodsIn = 3;
-    }
-
-    result = ma_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (deviceType == ma_device_type_capture) {
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDCapture     = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitCapture          = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.pAudioBufferList          = (ma_ptr)data.pAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames    = data.periodSizeInFramesOut;
-
-        pDevice->capture.internalFormat              = data.formatOut;
-        pDevice->capture.internalChannels            = data.channelsOut;
-        pDevice->capture.internalSampleRate          = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->capture.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->capture.internalPeriodSizeInFrames  = data.periodSizeInFramesOut;
-        pDevice->capture.internalPeriods             = data.periodsOut;
-    } else if (deviceType == ma_device_type_playback) {
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDPlayback    = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitPlayback         = (ma_ptr)data.audioUnit;
-
-        pDevice->playback.internalFormat             = data.formatOut;
-        pDevice->playback.internalChannels           = data.channelsOut;
-        pDevice->playback.internalSampleRate         = data.sampleRateOut;
-        MA_COPY_MEMORY(pDevice->playback.internalChannelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDevice->playback.internalPeriodSizeInFrames = data.periodSizeInFramesOut;
-        pDevice->playback.internalPeriods            = data.periodsOut;
-    }
-
-    return MA_SUCCESS;
-}
-#endif /* MA_APPLE_DESKTOP */
-
-static ma_result ma_device_init__coreaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pConfig != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with the Core Audio backend for now. */
-    if (((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Capture needs to be initialized first. */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__coreaudio data;
-        data.allowNominalSampleRateChange = pConfig->coreaudio.allowNominalSampleRateChange;
-        data.formatIn                     = pDescriptorCapture->format;
-        data.channelsIn                   = pDescriptorCapture->channels;
-        data.sampleRateIn                 = pDescriptorCapture->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorCapture->channelMap, sizeof(pDescriptorCapture->channelMap));
-        data.periodSizeInFramesIn         = pDescriptorCapture->periodSizeInFrames;
-        data.periodSizeInMillisecondsIn   = pDescriptorCapture->periodSizeInMilliseconds;
-        data.periodsIn                    = pDescriptorCapture->periodCount;
-        data.shareMode                    = pDescriptorCapture->shareMode;
-        data.performanceProfile           = pConfig->performanceProfile;
-        data.registerStopEvent            = MA_TRUE;
-
-        /* Need at least 3 periods for duplex. */
-        if (data.periodsIn < 3 && pConfig->deviceType == ma_device_type_duplex) {
-            data.periodsIn = 3;
-        }
-
-        result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_capture, pDescriptorCapture->pDeviceID, &data, (void*)pDevice);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pDevice->coreaudio.isDefaultCaptureDevice           = (pConfig->capture.pDeviceID == NULL);
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDCapture            = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitCapture                 = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.pAudioBufferList                 = (ma_ptr)data.pAudioBufferList;
-        pDevice->coreaudio.audioBufferCapInFrames           = data.periodSizeInFramesOut;
-        pDevice->coreaudio.originalPeriodSizeInFrames       = pDescriptorCapture->periodSizeInFrames;
-        pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorCapture->periodSizeInMilliseconds;
-        pDevice->coreaudio.originalPeriods                  = pDescriptorCapture->periodCount;
-        pDevice->coreaudio.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        pDescriptorCapture->format                          = data.formatOut;
-        pDescriptorCapture->channels                        = data.channelsOut;
-        pDescriptorCapture->sampleRate                      = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorCapture->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorCapture->periodSizeInFrames              = data.periodSizeInFramesOut;
-        pDescriptorCapture->periodCount                     = data.periodsOut;
-
-    #if defined(MA_APPLE_DESKTOP)
-        /*
-        If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
-        switch the device in the background.
-        */
-        if (pConfig->capture.pDeviceID == NULL) {
-            ma_device__track__coreaudio(pDevice);
-        }
-    #endif
-    }
-
-    /* Playback. */
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_device_init_internal_data__coreaudio data;
-        data.allowNominalSampleRateChange   = pConfig->coreaudio.allowNominalSampleRateChange;
-        data.formatIn                       = pDescriptorPlayback->format;
-        data.channelsIn                     = pDescriptorPlayback->channels;
-        data.sampleRateIn                   = pDescriptorPlayback->sampleRate;
-        MA_COPY_MEMORY(data.channelMapIn, pDescriptorPlayback->channelMap, sizeof(pDescriptorPlayback->channelMap));
-        data.shareMode                      = pDescriptorPlayback->shareMode;
-        data.performanceProfile             = pConfig->performanceProfile;
-
-        /* In full-duplex mode we want the playback buffer to be the same size as the capture buffer. */
-        if (pConfig->deviceType == ma_device_type_duplex) {
-            data.periodSizeInFramesIn       = pDescriptorCapture->periodSizeInFrames;
-            data.periodsIn                  = pDescriptorCapture->periodCount;
-            data.registerStopEvent          = MA_FALSE;
-        } else {
-            data.periodSizeInFramesIn       = pDescriptorPlayback->periodSizeInFrames;
-            data.periodSizeInMillisecondsIn = pDescriptorPlayback->periodSizeInMilliseconds;
-            data.periodsIn                  = pDescriptorPlayback->periodCount;
-            data.registerStopEvent          = MA_TRUE;
-        }
-
-        result = ma_device_init_internal__coreaudio(pDevice->pContext, ma_device_type_playback, pDescriptorPlayback->pDeviceID, &data, (void*)pDevice);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                ((ma_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-                if (pDevice->coreaudio.pAudioBufferList) {
-                    ma__free_from_callbacks(pDevice->coreaudio.pAudioBufferList, &pDevice->pContext->allocationCallbacks);
-                }
-            }
-            return result;
-        }
-
-        pDevice->coreaudio.isDefaultPlaybackDevice          = (pConfig->playback.pDeviceID == NULL);
-    #if defined(MA_APPLE_DESKTOP)
-        pDevice->coreaudio.deviceObjectIDPlayback           = (ma_uint32)data.deviceObjectID;
-    #endif
-        pDevice->coreaudio.audioUnitPlayback                = (ma_ptr)data.audioUnit;
-        pDevice->coreaudio.originalPeriodSizeInFrames       = pDescriptorPlayback->periodSizeInFrames;
-        pDevice->coreaudio.originalPeriodSizeInMilliseconds = pDescriptorPlayback->periodSizeInMilliseconds;
-        pDevice->coreaudio.originalPeriods                  = pDescriptorPlayback->periodCount;
-        pDevice->coreaudio.originalPerformanceProfile       = pConfig->performanceProfile;
-
-        pDescriptorPlayback->format                         = data.formatOut;
-        pDescriptorPlayback->channels                       = data.channelsOut;
-        pDescriptorPlayback->sampleRate                     = data.sampleRateOut;
-        MA_COPY_MEMORY(pDescriptorPlayback->channelMap, data.channelMapOut, sizeof(data.channelMapOut));
-        pDescriptorPlayback->periodSizeInFrames             = data.periodSizeInFramesOut;
-        pDescriptorPlayback->periodCount                    = data.periodsOut;
-
-    #if defined(MA_APPLE_DESKTOP)
-        /*
-        If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly
-        switch the device in the background.
-        */
-        if (pDescriptorPlayback->pDeviceID == NULL && (pConfig->deviceType != ma_device_type_duplex || pDescriptorCapture->pDeviceID != NULL)) {
-            ma_device__track__coreaudio(pDevice);
-        }
-    #endif
-    }
-
-    
-
-    /*
-    When stopping the device, a callback is called on another thread. We need to wait for this callback
-    before returning from ma_device_stop(). This event is used for this.
-    */
-    ma_event_init(&pDevice->coreaudio.stopEvent);
-
-    /*
-    We need to detect when a route has changed so we can update the data conversion pipeline accordingly. This is done
-    differently on non-Desktop Apple platforms.
-    */
-#if defined(MA_APPLE_MOBILE)
-    pDevice->coreaudio.pRouteChangeHandler = (__bridge_retained void*)[[ma_router_change_handler alloc] init:pDevice];
-#endif
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_start__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        if (status != noErr) {
-            if (pDevice->type == ma_device_type_duplex) {
-                ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-            }
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__coreaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* It's not clear from the documentation whether or not AudioOutputUnitStop() actually drains the device or not. */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        OSStatus status = ((ma_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback);
-        if (status != noErr) {
-            return ma_result_from_OSStatus(status);
-        }
-    }
-
-    /* We need to wait for the callback to finish before returning. */
-    ma_event_wait(&pDevice->coreaudio.stopEvent);
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__coreaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_coreaudio);
-
-#if defined(MA_APPLE_MOBILE)
-    if (!pContext->coreaudio.noAudioSessionDeactivate) {
-        if (![[AVAudioSession sharedInstance] setActive:false error:nil]) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to deactivate audio session.", MA_FAILED_TO_INIT_BACKEND);
-        }
-    }
-#endif
-
-#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-    ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-    ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-    ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-#endif
-
-#if !defined(MA_APPLE_MOBILE)
-    ma_context__uninit_device_tracking__coreaudio(pContext);
-#endif
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-#if defined(MA_APPLE_MOBILE)
-static AVAudioSessionCategory ma_to_AVAudioSessionCategory(ma_ios_session_category category)
-{
-    /* The "default" and "none" categories are treated different and should not be used as an input into this function. */
-    MA_ASSERT(category != ma_ios_session_category_default);
-    MA_ASSERT(category != ma_ios_session_category_none);
-
-    switch (category) {
-        case ma_ios_session_category_ambient:         return AVAudioSessionCategoryAmbient;
-        case ma_ios_session_category_solo_ambient:    return AVAudioSessionCategorySoloAmbient;
-        case ma_ios_session_category_playback:        return AVAudioSessionCategoryPlayback;
-        case ma_ios_session_category_record:          return AVAudioSessionCategoryRecord;
-        case ma_ios_session_category_play_and_record: return AVAudioSessionCategoryPlayAndRecord;
-        case ma_ios_session_category_multi_route:     return AVAudioSessionCategoryMultiRoute;
-        case ma_ios_session_category_none:            return AVAudioSessionCategoryAmbient;
-        case ma_ios_session_category_default:         return AVAudioSessionCategoryAmbient;
-        default:                                      return AVAudioSessionCategoryAmbient;
-    }
-}
-#endif
-
-static ma_result ma_context_init__coreaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#if !defined(MA_APPLE_MOBILE)
-    ma_result result;
-#endif
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pContext != NULL);
-
-#if defined(MA_APPLE_MOBILE)
-    @autoreleasepool {
-        AVAudioSession* pAudioSession = [AVAudioSession sharedInstance];
-        AVAudioSessionCategoryOptions options = pConfig->coreaudio.sessionCategoryOptions;
-
-        MA_ASSERT(pAudioSession != NULL);
-
-        if (pConfig->coreaudio.sessionCategory == ma_ios_session_category_default) {
-            /*
-            I'm going to use trial and error to determine our default session category. First we'll try PlayAndRecord. If that fails
-            we'll try Playback and if that fails we'll try record. If all of these fail we'll just not set the category.
-            */
-        #if !defined(MA_APPLE_TV) && !defined(MA_APPLE_WATCH)
-            options |= AVAudioSessionCategoryOptionDefaultToSpeaker;
-        #endif
-
-            if ([pAudioSession setCategory: AVAudioSessionCategoryPlayAndRecord withOptions:options error:nil]) {
-                /* Using PlayAndRecord */
-            } else if ([pAudioSession setCategory: AVAudioSessionCategoryPlayback withOptions:options error:nil]) {
-                /* Using Playback */
-            } else if ([pAudioSession setCategory: AVAudioSessionCategoryRecord withOptions:options error:nil]) {
-                /* Using Record */
-            } else {
-                /* Leave as default? */
-            }
-        } else {
-            if (pConfig->coreaudio.sessionCategory != ma_ios_session_category_none) {
-                if (![pAudioSession setCategory: ma_to_AVAudioSessionCategory(pConfig->coreaudio.sessionCategory) withOptions:options error:nil]) {
-                    return MA_INVALID_OPERATION;    /* Failed to set session category. */
-                }
-            }
-        }
-
-        if (!pConfig->coreaudio.noAudioSessionActivate) {
-            if (![pAudioSession setActive:true error:nil]) {
-                return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to activate audio session.", MA_FAILED_TO_INIT_BACKEND);
-            }
-        }
-    }
-#endif
-
-#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-    pContext->coreaudio.hCoreFoundation = ma_dlopen(pContext, "CoreFoundation.framework/CoreFoundation");
-    if (pContext->coreaudio.hCoreFoundation == NULL) {
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->coreaudio.CFStringGetCString = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFStringGetCString");
-    pContext->coreaudio.CFRelease          = ma_dlsym(pContext, pContext->coreaudio.hCoreFoundation, "CFRelease");
-
-
-    pContext->coreaudio.hCoreAudio = ma_dlopen(pContext, "CoreAudio.framework/CoreAudio");
-    if (pContext->coreaudio.hCoreAudio == NULL) {
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        return MA_API_NOT_FOUND;
-    }
-
-    pContext->coreaudio.AudioObjectGetPropertyData        = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyData");
-    pContext->coreaudio.AudioObjectGetPropertyDataSize    = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyDataSize");
-    pContext->coreaudio.AudioObjectSetPropertyData        = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectSetPropertyData");
-    pContext->coreaudio.AudioObjectAddPropertyListener    = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectAddPropertyListener");
-    pContext->coreaudio.AudioObjectRemovePropertyListener = ma_dlsym(pContext, pContext->coreaudio.hCoreAudio, "AudioObjectRemovePropertyListener");
-
-    /*
-    It looks like Apple has moved some APIs from AudioUnit into AudioToolbox on more recent versions of macOS. They are still
-    defined in AudioUnit, but just in case they decide to remove them from there entirely I'm going to implement a fallback.
-    The way it'll work is that it'll first try AudioUnit, and if the required symbols are not present there we'll fall back to
-    AudioToolbox.
-    */
-    pContext->coreaudio.hAudioUnit = ma_dlopen(pContext, "AudioUnit.framework/AudioUnit");
-    if (pContext->coreaudio.hAudioUnit == NULL) {
-        ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        return MA_API_NOT_FOUND;
-    }
-
-    if (ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == NULL) {
-        /* Couldn't find the required symbols in AudioUnit, so fall back to AudioToolbox. */
-        ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-        pContext->coreaudio.hAudioUnit = ma_dlopen(pContext, "AudioToolbox.framework/AudioToolbox");
-        if (pContext->coreaudio.hAudioUnit == NULL) {
-            ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-            return MA_API_NOT_FOUND;
-        }
-    }
-
-    pContext->coreaudio.AudioComponentFindNext            = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentFindNext");
-    pContext->coreaudio.AudioComponentInstanceDispose     = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentInstanceDispose");
-    pContext->coreaudio.AudioComponentInstanceNew         = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioComponentInstanceNew");
-    pContext->coreaudio.AudioOutputUnitStart              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioOutputUnitStart");
-    pContext->coreaudio.AudioOutputUnitStop               = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioOutputUnitStop");
-    pContext->coreaudio.AudioUnitAddPropertyListener      = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitAddPropertyListener");
-    pContext->coreaudio.AudioUnitGetPropertyInfo          = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitGetPropertyInfo");
-    pContext->coreaudio.AudioUnitGetProperty              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitGetProperty");
-    pContext->coreaudio.AudioUnitSetProperty              = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitSetProperty");
-    pContext->coreaudio.AudioUnitInitialize               = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitInitialize");
-    pContext->coreaudio.AudioUnitRender                   = ma_dlsym(pContext, pContext->coreaudio.hAudioUnit, "AudioUnitRender");
-#else
-    pContext->coreaudio.CFStringGetCString                = (ma_proc)CFStringGetCString;
-    pContext->coreaudio.CFRelease                         = (ma_proc)CFRelease;
-
-    #if defined(MA_APPLE_DESKTOP)
-    pContext->coreaudio.AudioObjectGetPropertyData        = (ma_proc)AudioObjectGetPropertyData;
-    pContext->coreaudio.AudioObjectGetPropertyDataSize    = (ma_proc)AudioObjectGetPropertyDataSize;
-    pContext->coreaudio.AudioObjectSetPropertyData        = (ma_proc)AudioObjectSetPropertyData;
-    pContext->coreaudio.AudioObjectAddPropertyListener    = (ma_proc)AudioObjectAddPropertyListener;
-    pContext->coreaudio.AudioObjectRemovePropertyListener = (ma_proc)AudioObjectRemovePropertyListener;
-    #endif
-
-    pContext->coreaudio.AudioComponentFindNext            = (ma_proc)AudioComponentFindNext;
-    pContext->coreaudio.AudioComponentInstanceDispose     = (ma_proc)AudioComponentInstanceDispose;
-    pContext->coreaudio.AudioComponentInstanceNew         = (ma_proc)AudioComponentInstanceNew;
-    pContext->coreaudio.AudioOutputUnitStart              = (ma_proc)AudioOutputUnitStart;
-    pContext->coreaudio.AudioOutputUnitStop               = (ma_proc)AudioOutputUnitStop;
-    pContext->coreaudio.AudioUnitAddPropertyListener      = (ma_proc)AudioUnitAddPropertyListener;
-    pContext->coreaudio.AudioUnitGetPropertyInfo          = (ma_proc)AudioUnitGetPropertyInfo;
-    pContext->coreaudio.AudioUnitGetProperty              = (ma_proc)AudioUnitGetProperty;
-    pContext->coreaudio.AudioUnitSetProperty              = (ma_proc)AudioUnitSetProperty;
-    pContext->coreaudio.AudioUnitInitialize               = (ma_proc)AudioUnitInitialize;
-    pContext->coreaudio.AudioUnitRender                   = (ma_proc)AudioUnitRender;
-#endif
-
-    /* Audio component. */
-    {
-        AudioComponentDescription desc;
-        desc.componentType         = kAudioUnitType_Output;
-    #if defined(MA_APPLE_DESKTOP)
-        desc.componentSubType      = kAudioUnitSubType_HALOutput;
-    #else
-        desc.componentSubType      = kAudioUnitSubType_RemoteIO;
-    #endif
-        desc.componentManufacturer = kAudioUnitManufacturer_Apple;
-        desc.componentFlags        = 0;
-        desc.componentFlagsMask    = 0;
-
-        pContext->coreaudio.component = ((ma_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc);
-        if (pContext->coreaudio.component == NULL) {
-        #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-            ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-            ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-        #endif
-            return MA_FAILED_TO_INIT_BACKEND;
-        }
-    }
-
-#if !defined(MA_APPLE_MOBILE)
-    result = ma_context__init_device_tracking__coreaudio(pContext);
-    if (result != MA_SUCCESS) {
-    #if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE)
-        ma_dlclose(pContext, pContext->coreaudio.hAudioUnit);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreAudio);
-        ma_dlclose(pContext, pContext->coreaudio.hCoreFoundation);
-    #endif
-        return result;
-    }
-#endif
-
-    pContext->coreaudio.noAudioSessionDeactivate = pConfig->coreaudio.noAudioSessionDeactivate;
-    
-    pCallbacks->onContextInit             = ma_context_init__coreaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__coreaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__coreaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__coreaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__coreaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__coreaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__coreaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__coreaudio;
-    pCallbacks->onDeviceRead              = NULL;
-    pCallbacks->onDeviceWrite             = NULL;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* Core Audio */
-
-
-
-/******************************************************************************
-
-sndio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_SNDIO
-#include <fcntl.h>
-
-/*
-Only supporting OpenBSD. This did not work very well at all on FreeBSD when I tried it. Not sure if this is due
-to miniaudio's implementation or if it's some kind of system configuration issue, but basically the default device
-just doesn't emit any sound, or at times you'll hear tiny pieces. I will consider enabling this when there's
-demand for it or if I can get it tested and debugged more thoroughly.
-*/
-#if 0
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-#include <sys/audioio.h>
-#endif
-#if defined(__FreeBSD__) || defined(__DragonFly__)
-#include <sys/soundcard.h>
-#endif
-#endif
-
-#define MA_SIO_DEVANY   "default"
-#define MA_SIO_PLAY     1
-#define MA_SIO_REC      2
-#define MA_SIO_NENC     8
-#define MA_SIO_NCHAN    8
-#define MA_SIO_NRATE    16
-#define MA_SIO_NCONF    4
-
-struct ma_sio_hdl; /* <-- Opaque */
-
-struct ma_sio_par
-{
-    unsigned int bits;
-    unsigned int bps;
-    unsigned int sig;
-    unsigned int le;
-    unsigned int msb;
-    unsigned int rchan;
-    unsigned int pchan;
-    unsigned int rate;
-    unsigned int bufsz;
-    unsigned int xrun;
-    unsigned int round;
-    unsigned int appbufsz;
-    int __pad[3];
-    unsigned int __magic;
-};
-
-struct ma_sio_enc
-{
-    unsigned int bits;
-    unsigned int bps;
-    unsigned int sig;
-    unsigned int le;
-    unsigned int msb;
-};
-
-struct ma_sio_conf
-{
-    unsigned int enc;
-    unsigned int rchan;
-    unsigned int pchan;
-    unsigned int rate;
-};
-
-struct ma_sio_cap
-{
-    struct ma_sio_enc enc[MA_SIO_NENC];
-    unsigned int rchan[MA_SIO_NCHAN];
-    unsigned int pchan[MA_SIO_NCHAN];
-    unsigned int rate[MA_SIO_NRATE];
-    int __pad[7];
-    unsigned int nconf;
-    struct ma_sio_conf confs[MA_SIO_NCONF];
-};
-
-typedef struct ma_sio_hdl* (* ma_sio_open_proc)   (const char*, unsigned int, int);
-typedef void               (* ma_sio_close_proc)  (struct ma_sio_hdl*);
-typedef int                (* ma_sio_setpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*);
-typedef int                (* ma_sio_getpar_proc) (struct ma_sio_hdl*, struct ma_sio_par*);
-typedef int                (* ma_sio_getcap_proc) (struct ma_sio_hdl*, struct ma_sio_cap*);
-typedef size_t             (* ma_sio_write_proc)  (struct ma_sio_hdl*, const void*, size_t);
-typedef size_t             (* ma_sio_read_proc)   (struct ma_sio_hdl*, void*, size_t);
-typedef int                (* ma_sio_start_proc)  (struct ma_sio_hdl*);
-typedef int                (* ma_sio_stop_proc)   (struct ma_sio_hdl*);
-typedef int                (* ma_sio_initpar_proc)(struct ma_sio_par*);
-
-static ma_uint32 ma_get_standard_sample_rate_priority_index__sndio(ma_uint32 sampleRate)   /* Lower = higher priority */
-{
-    ma_uint32 i;
-    for (i = 0; i < ma_countof(g_maStandardSampleRatePriorities); ++i) {
-        if (g_maStandardSampleRatePriorities[i] == sampleRate) {
-            return i;
-        }
-    }
-
-    return (ma_uint32)-1;
-}
-
-static ma_format ma_format_from_sio_enc__sndio(unsigned int bits, unsigned int bps, unsigned int sig, unsigned int le, unsigned int msb)
-{
-    /* We only support native-endian right now. */
-    if ((ma_is_little_endian() && le == 0) || (ma_is_big_endian() && le == 1)) {
-        return ma_format_unknown;
-    }
-
-    if (bits ==  8 && bps == 1 && sig == 0) {
-        return ma_format_u8;
-    }
-    if (bits == 16 && bps == 2 && sig == 1) {
-        return ma_format_s16;
-    }
-    if (bits == 24 && bps == 3 && sig == 1) {
-        return ma_format_s24;
-    }
-    if (bits == 24 && bps == 4 && sig == 1 && msb == 0) {
-        /*return ma_format_s24_32;*/
-    }
-    if (bits == 32 && bps == 4 && sig == 1) {
-        return ma_format_s32;
-    }
-
-    return ma_format_unknown;
-}
-
-static ma_format ma_find_best_format_from_sio_cap__sndio(struct ma_sio_cap* caps)
-{
-    ma_format bestFormat;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-
-    bestFormat = ma_format_unknown;
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format == ma_format_unknown) {
-                continue;   /* Format not supported. */
-            }
-
-            if (bestFormat == ma_format_unknown) {
-                bestFormat = format;
-            } else {
-                if (ma_get_format_priority_index(bestFormat) > ma_get_format_priority_index(format)) {    /* <-- Lower = better. */
-                    bestFormat = format;
-                }
-            }
-        }
-    }
-
-    return bestFormat;
-}
-
-static ma_uint32 ma_find_best_channels_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat)
-{
-    ma_uint32 maxChannels;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-    MA_ASSERT(requiredFormat != ma_format_unknown);
-
-    /* Just pick whatever configuration has the most channels. */
-    maxChannels = 0;
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        /* The encoding should be of requiredFormat. */
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int iChannel;
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format != requiredFormat) {
-                continue;
-            }
-
-            /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps->confs[iConfig].pchan;
-                } else {
-                    chan = caps->confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps->pchan[iChannel];
-                } else {
-                    channels = caps->rchan[iChannel];
-                }
-
-                if (maxChannels < channels) {
-                    maxChannels = channels;
-                }
-            }
-        }
-    }
-
-    return maxChannels;
-}
-
-static ma_uint32 ma_find_best_sample_rate_from_sio_cap__sndio(struct ma_sio_cap* caps, ma_device_type deviceType, ma_format requiredFormat, ma_uint32 requiredChannels)
-{
-    ma_uint32 firstSampleRate;
-    ma_uint32 bestSampleRate;
-    unsigned int iConfig;
-
-    MA_ASSERT(caps != NULL);
-    MA_ASSERT(requiredFormat != ma_format_unknown);
-    MA_ASSERT(requiredChannels > 0);
-    MA_ASSERT(requiredChannels <= MA_MAX_CHANNELS);
-
-    firstSampleRate = 0; /* <-- If the device does not support a standard rate we'll fall back to the first one that's found. */
-    bestSampleRate  = 0;
-
-    for (iConfig = 0; iConfig < caps->nconf; iConfig += 1) {
-        /* The encoding should be of requiredFormat. */
-        unsigned int iEncoding;
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int iChannel;
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps->enc[iEncoding].bits;
-            bps  = caps->enc[iEncoding].bps;
-            sig  = caps->enc[iEncoding].sig;
-            le   = caps->enc[iEncoding].le;
-            msb  = caps->enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format != requiredFormat) {
-                continue;
-            }
-
-            /* Getting here means the format is supported. Iterate over each channel count and grab the biggest one. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-                unsigned int iRate;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps->confs[iConfig].pchan;
-                } else {
-                    chan = caps->confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps->pchan[iChannel];
-                } else {
-                    channels = caps->rchan[iChannel];
-                }
-
-                if (channels != requiredChannels) {
-                    continue;
-                }
-
-                /* Getting here means we have found a compatible encoding/channel pair. */
-                for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) {
-                    ma_uint32 rate = (ma_uint32)caps->rate[iRate];
-                    ma_uint32 ratePriority;
-
-                    if (firstSampleRate == 0) {
-                        firstSampleRate = rate;
-                    }
-
-                    /* Disregard this rate if it's not a standard one. */
-                    ratePriority = ma_get_standard_sample_rate_priority_index__sndio(rate);
-                    if (ratePriority == (ma_uint32)-1) {
-                        continue;
-                    }
-
-                    if (ma_get_standard_sample_rate_priority_index__sndio(bestSampleRate) > ratePriority) {   /* Lower = better. */
-                        bestSampleRate = rate;
-                    }
-                }
-            }
-        }
-    }
-
-    /* If a standard sample rate was not found just fall back to the first one that was iterated. */
-    if (bestSampleRate == 0) {
-        bestSampleRate = firstSampleRate;
-    }
-
-    return bestSampleRate;
-}
-
-
-static ma_result ma_context_enumerate_devices__sndio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 isTerminating = MA_FALSE;
-    struct ma_sio_hdl* handle;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* sndio doesn't seem to have a good device enumeration API, so I'm therefore only enumerating over default devices for now. */
-
-    /* Playback. */
-    if (!isTerminating) {
-        handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_PLAY, 0);
-        if (handle != NULL) {
-            /* Supports playback. */
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), MA_SIO_DEVANY);
-            ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME);
-
-            isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-
-            ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-        }
-    }
-
-    /* Capture. */
-    if (!isTerminating) {
-        handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_REC, 0);
-        if (handle != NULL) {
-            /* Supports capture. */
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), "default");
-            ma_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME);
-
-            isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-
-            ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__sndio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    char devid[256];
-    struct ma_sio_hdl* handle;
-    struct ma_sio_cap caps;
-    unsigned int iConfig;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* We need to open the device before we can get information about it. */
-    if (pDeviceID == NULL) {
-        ma_strcpy_s(devid, sizeof(devid), MA_SIO_DEVANY);
-        ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == ma_device_type_playback) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : MA_DEFAULT_CAPTURE_DEVICE_NAME);
-    } else {
-        ma_strcpy_s(devid, sizeof(devid), pDeviceID->sndio);
-        ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), devid);
-    }
-
-    handle = ((ma_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == ma_device_type_playback) ? MA_SIO_PLAY : MA_SIO_REC, 0);
-    if (handle == NULL) {
-        return MA_NO_DEVICE;
-    }
-
-    if (((ma_sio_getcap_proc)pContext->sndio.sio_getcap)(handle, &caps) == 0) {
-        return MA_ERROR;
-    }
-
-    pDeviceInfo->nativeDataFormatCount = 0;
-
-    for (iConfig = 0; iConfig < caps.nconf; iConfig += 1) {
-        /*
-        The main thing we care about is that the encoding is supported by miniaudio. If it is, we want to give
-        preference to some formats over others.
-        */
-        unsigned int iEncoding;
-        unsigned int iChannel;
-        unsigned int iRate;
-
-        for (iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) {
-            unsigned int bits;
-            unsigned int bps;
-            unsigned int sig;
-            unsigned int le;
-            unsigned int msb;
-            ma_format format;
-
-            if ((caps.confs[iConfig].enc & (1UL << iEncoding)) == 0) {
-                continue;
-            }
-
-            bits = caps.enc[iEncoding].bits;
-            bps  = caps.enc[iEncoding].bps;
-            sig  = caps.enc[iEncoding].sig;
-            le   = caps.enc[iEncoding].le;
-            msb  = caps.enc[iEncoding].msb;
-            format = ma_format_from_sio_enc__sndio(bits, bps, sig, le, msb);
-            if (format == ma_format_unknown) {
-                continue;   /* Format not supported. */
-            }
-
-
-            /* Channels. */
-            for (iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) {
-                unsigned int chan = 0;
-                unsigned int channels;
-
-                if (deviceType == ma_device_type_playback) {
-                    chan = caps.confs[iConfig].pchan;
-                } else {
-                    chan = caps.confs[iConfig].rchan;
-                }
-
-                if ((chan & (1UL << iChannel)) == 0) {
-                    continue;
-                }
-
-                if (deviceType == ma_device_type_playback) {
-                    channels = caps.pchan[iChannel];
-                } else {
-                    channels = caps.rchan[iChannel];
-                }
-
-
-                /* Sample Rates. */
-                for (iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) {
-                    if ((caps.confs[iConfig].rate & (1UL << iRate)) != 0) {
-                        ma_device_info_add_native_data_format(pDeviceInfo, format, channels, caps.rate[iRate], 0);
-                    }
-                }
-            }
-        }
-    }
-
-    ((ma_sio_close_proc)pContext->sndio.sio_close)(handle);
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_handle__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    const char* pDeviceName;
-    ma_ptr handle;
-    int openFlags = 0;
-    struct ma_sio_cap caps;
-    struct ma_sio_par par;
-    const ma_device_id* pDeviceID;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    MA_ASSERT(pDevice    != NULL);
-
-    if (deviceType == ma_device_type_capture) {
-        openFlags  = MA_SIO_REC;
-    } else {
-        openFlags = MA_SIO_PLAY;
-    }
-
-    pDeviceID  = pDescriptor->pDeviceID;
-    format     = pDescriptor->format;
-    channels   = pDescriptor->channels;
-    sampleRate = pDescriptor->sampleRate;
-
-    pDeviceName = MA_SIO_DEVANY;
-    if (pDeviceID != NULL) {
-        pDeviceName = pDeviceID->sndio;
-    }
-
-    handle = (ma_ptr)((ma_sio_open_proc)pDevice->pContext->sndio.sio_open)(pDeviceName, openFlags, 0);
-    if (handle == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE);
-    }
-
-    /* We need to retrieve the device caps to determine the most appropriate format to use. */
-    if (((ma_sio_getcap_proc)pDevice->pContext->sndio.sio_getcap)((struct ma_sio_hdl*)handle, &caps) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve device caps.", MA_ERROR);
-    }
-
-    /*
-    Note: sndio reports a huge range of available channels. This is inconvenient for us because there's no real
-    way, as far as I can tell, to get the _actual_ channel count of the device. I'm therefore restricting this
-    to the requested channels, regardless of whether or not the default channel count is requested.
-
-    For hardware devices, I'm suspecting only a single channel count will be reported and we can safely use the
-    value returned by ma_find_best_channels_from_sio_cap__sndio().
-    */
-    if (deviceType == ma_device_type_capture) {
-        if (format == ma_format_unknown) {
-            format = ma_find_best_format_from_sio_cap__sndio(&caps);
-        }
-
-        if (channels == 0) {
-            if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) {
-                channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format);
-            } else {
-                channels = MA_DEFAULT_CHANNELS;
-            }
-        }
-    } else {
-        if (format == ma_format_unknown) {
-            format = ma_find_best_format_from_sio_cap__sndio(&caps);
-        }
-
-        if (channels == 0) {
-            if (strlen(pDeviceName) > strlen("rsnd/") && strncmp(pDeviceName, "rsnd/", strlen("rsnd/")) == 0) {
-                channels = ma_find_best_channels_from_sio_cap__sndio(&caps, deviceType, format);
-            } else {
-                channels = MA_DEFAULT_CHANNELS;
-            }
-        }
-    }
-
-    if (sampleRate == 0) {
-        sampleRate = ma_find_best_sample_rate_from_sio_cap__sndio(&caps, pConfig->deviceType, format, channels);
-    }
-
-
-    ((ma_sio_initpar_proc)pDevice->pContext->sndio.sio_initpar)(&par);
-    par.msb = 0;
-    par.le  = ma_is_little_endian();
-
-    switch (format) {
-        case ma_format_u8:
-        {
-            par.bits = 8;
-            par.bps  = 1;
-            par.sig  = 0;
-        } break;
-
-        case ma_format_s24:
-        {
-            par.bits = 24;
-            par.bps  = 3;
-            par.sig  = 1;
-        } break;
-
-        case ma_format_s32:
-        {
-            par.bits = 32;
-            par.bps  = 4;
-            par.sig  = 1;
-        } break;
-
-        case ma_format_s16:
-        case ma_format_f32:
-        case ma_format_unknown:
-        default:
-        {
-            par.bits = 16;
-            par.bps  = 2;
-            par.sig  = 1;
-        } break;
-    }
-    
-    if (deviceType == ma_device_type_capture) {
-        par.rchan = channels;
-    } else {
-        par.pchan = channels;
-    }
-
-    par.rate = sampleRate;
-
-    internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, par.rate, pConfig->performanceProfile);
-
-    par.round    = internalPeriodSizeInFrames;
-    par.appbufsz = par.round * pDescriptor->periodCount;
-
-    if (((ma_sio_setpar_proc)pDevice->pContext->sndio.sio_setpar)((struct ma_sio_hdl*)handle, &par) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to set buffer size.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    if (((ma_sio_getpar_proc)pDevice->pContext->sndio.sio_getpar)((struct ma_sio_hdl*)handle, &par) == 0) {
-        ((ma_sio_close_proc)pDevice->pContext->sndio.sio_close)((struct ma_sio_hdl*)handle);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve buffer size.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    internalFormat             = ma_format_from_sio_enc__sndio(par.bits, par.bps, par.sig, par.le, par.msb);
-    internalChannels           = (deviceType == ma_device_type_capture) ? par.rchan : par.pchan;
-    internalSampleRate         = par.rate;
-    internalPeriods            = par.appbufsz / par.round;
-    internalPeriodSizeInFrames = par.round;
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->sndio.handleCapture  = handle;
-    } else {
-        pDevice->sndio.handlePlayback = handle;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sndio, pDevice->playback.internalChannels, pDevice->playback.internalChannelMap);
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-#ifdef MA_DEBUG_OUTPUT
-    printf("DEVICE INFO\n");
-    printf("    Format:      %s\n", ma_get_format_name(internalFormat));
-    printf("    Channels:    %d\n", internalChannels);
-    printf("    Sample Rate: %d\n", internalSampleRate);
-    printf("    Period Size: %d\n", internalPeriodSizeInFrames);
-    printf("    Periods:     %d\n", internalPeriods);
-    printf("    appbufsz:    %d\n", par.appbufsz);
-    printf("    round:       %d\n", par.round);
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__sndio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->sndio);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_handle__sndio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);   /* <-- Doesn't actually playback until data is written. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__sndio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the documentation:
-
-        The sio_stop() function puts the audio subsystem in the same state as before sio_start() is called. It stops recording, drains the play buffer and then
-        stops playback. If samples to play are queued but playback hasn't started yet then playback is forced immediately; playback will actually stop once the
-        buffer is drained. In no case are samples in the play buffer discarded.
-
-    Therefore, sio_stop() performs all of the necessary draining for us.
-    */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handleCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ((ma_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__sndio(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int result;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    result = ((ma_sio_write_proc)pDevice->pContext->sndio.sio_write)((struct ma_sio_hdl*)pDevice->sndio.handlePlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (result == 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to send data from the client to the device.", MA_IO_ERROR);
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__sndio(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int result;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    result = ((ma_sio_read_proc)pDevice->pContext->sndio.sio_read)((struct ma_sio_hdl*)pDevice->sndio.handleCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (result == 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to read data from the device to be sent to the device.", MA_IO_ERROR);
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__sndio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_sndio);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__sndio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-#ifndef MA_NO_RUNTIME_LINKING
-    const char* libsndioNames[] = {
-        "libsndio.so"
-    };
-    size_t i;
-
-    for (i = 0; i < ma_countof(libsndioNames); ++i) {
-        pContext->sndio.sndioSO = ma_dlopen(pContext, libsndioNames[i]);
-        if (pContext->sndio.sndioSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->sndio.sndioSO == NULL) {
-        return MA_NO_BACKEND;
-    }
-
-    pContext->sndio.sio_open    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_open");
-    pContext->sndio.sio_close   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_close");
-    pContext->sndio.sio_setpar  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_setpar");
-    pContext->sndio.sio_getpar  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_getpar");
-    pContext->sndio.sio_getcap  = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_getcap");
-    pContext->sndio.sio_write   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_write");
-    pContext->sndio.sio_read    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_read");
-    pContext->sndio.sio_start   = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_start");
-    pContext->sndio.sio_stop    = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_stop");
-    pContext->sndio.sio_initpar = (ma_proc)ma_dlsym(pContext, pContext->sndio.sndioSO, "sio_initpar");
-#else
-    pContext->sndio.sio_open    = sio_open;
-    pContext->sndio.sio_close   = sio_close;
-    pContext->sndio.sio_setpar  = sio_setpar;
-    pContext->sndio.sio_getpar  = sio_getpar;
-    pContext->sndio.sio_getcap  = sio_getcap;
-    pContext->sndio.sio_write   = sio_write;
-    pContext->sndio.sio_read    = sio_read;
-    pContext->sndio.sio_start   = sio_start;
-    pContext->sndio.sio_stop    = sio_stop;
-    pContext->sndio.sio_initpar = sio_initpar;
-#endif
-
-    pCallbacks->onContextInit             = ma_context_init__sndio;
-    pCallbacks->onContextUninit           = ma_context_uninit__sndio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__sndio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__sndio;
-    pCallbacks->onDeviceInit              = ma_device_init__sndio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__sndio;
-    pCallbacks->onDeviceStart             = ma_device_start__sndio;
-    pCallbacks->onDeviceStop              = ma_device_stop__sndio;
-    pCallbacks->onDeviceRead              = ma_device_read__sndio;
-    pCallbacks->onDeviceWrite             = ma_device_write__sndio;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-#endif  /* sndio */
-
-
-
-/******************************************************************************
-
-audio(4) Backend
-
-******************************************************************************/
-#ifdef MA_HAS_AUDIO4
-#include <fcntl.h>
-#include <poll.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/audioio.h>
-
-#if defined(__OpenBSD__)
-    #include <sys/param.h>
-    #if defined(OpenBSD) && OpenBSD >= 201709
-        #define MA_AUDIO4_USE_NEW_API
-    #endif
-#endif
-
-static void ma_construct_device_id__audio4(char* id, size_t idSize, const char* base, int deviceIndex)
-{
-    size_t baseLen;
-
-    MA_ASSERT(id != NULL);
-    MA_ASSERT(idSize > 0);
-    MA_ASSERT(deviceIndex >= 0);
-
-    baseLen = strlen(base);
-    MA_ASSERT(idSize > baseLen);
-
-    ma_strcpy_s(id, idSize, base);
-    ma_itoa_s(deviceIndex, id+baseLen, idSize-baseLen, 10);
-}
-
-static ma_result ma_extract_device_index_from_id__audio4(const char* id, const char* base, int* pIndexOut)
-{
-    size_t idLen;
-    size_t baseLen;
-    const char* deviceIndexStr;
-
-    MA_ASSERT(id != NULL);
-    MA_ASSERT(base != NULL);
-    MA_ASSERT(pIndexOut != NULL);
-
-    idLen = strlen(id);
-    baseLen = strlen(base);
-    if (idLen <= baseLen) {
-        return MA_ERROR;   /* Doesn't look like the id starts with the base. */
-    }
-
-    if (strncmp(id, base, baseLen) != 0) {
-        return MA_ERROR;   /* ID does not begin with base. */
-    }
-
-    deviceIndexStr = id + baseLen;
-    if (deviceIndexStr[0] == '\0') {
-        return MA_ERROR;   /* No index specified in the ID. */
-    }
-
-    if (pIndexOut) {
-        *pIndexOut = atoi(deviceIndexStr);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-#if !defined(MA_AUDIO4_USE_NEW_API)    /* Old API */
-static ma_format ma_format_from_encoding__audio4(unsigned int encoding, unsigned int precision)
-{
-    if (precision == 8 && (encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR_LE || encoding == AUDIO_ENCODING_ULINEAR_BE)) {
-        return ma_format_u8;
-    } else {
-        if (ma_is_little_endian() && encoding == AUDIO_ENCODING_SLINEAR_LE) {
-            if (precision == 16) {
-                return ma_format_s16;
-            } else if (precision == 24) {
-                return ma_format_s24;
-            } else if (precision == 32) {
-                return ma_format_s32;
-            }
-        } else if (ma_is_big_endian() && encoding == AUDIO_ENCODING_SLINEAR_BE) {
-            if (precision == 16) {
-                return ma_format_s16;
-            } else if (precision == 24) {
-                return ma_format_s24;
-            } else if (precision == 32) {
-                return ma_format_s32;
-            }
-        }
-    }
-
-    return ma_format_unknown;  /* Encoding not supported. */
-}
-
-static void ma_encoding_from_format__audio4(ma_format format, unsigned int* pEncoding, unsigned int* pPrecision)
-{
-    MA_ASSERT(pEncoding  != NULL);
-    MA_ASSERT(pPrecision != NULL);
-
-    switch (format)
-    {
-        case ma_format_u8:
-        {
-            *pEncoding = AUDIO_ENCODING_ULINEAR;
-            *pPrecision = 8;
-        } break;
-
-        case ma_format_s24:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 24;
-        } break;
-
-        case ma_format_s32:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 32;
-        } break;
-
-        case ma_format_s16:
-        case ma_format_f32:
-        case ma_format_unknown:
-        default:
-        {
-            *pEncoding = (ma_is_little_endian()) ? AUDIO_ENCODING_SLINEAR_LE : AUDIO_ENCODING_SLINEAR_BE;
-            *pPrecision = 16;
-        } break;
-    }
-}
-
-static ma_format ma_format_from_prinfo__audio4(struct audio_prinfo* prinfo)
-{
-    return ma_format_from_encoding__audio4(prinfo->encoding, prinfo->precision);
-}
-
-static ma_format ma_best_format_from_fd__audio4(int fd, ma_format preferredFormat)
-{
-    audio_encoding_t encoding;
-    ma_uint32 iFormat;
-    int counter = 0;
-
-    /* First check to see if the preferred format is supported. */
-    if (preferredFormat != ma_format_unknown) {
-        counter = 0;
-        for (;;) {
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            if (preferredFormat == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) {
-                return preferredFormat;  /* Found the preferred format. */
-            }
-
-            /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */
-            counter += 1;
-        }
-    }
-
-    /* Getting here means our preferred format is not supported, so fall back to our standard priorities. */
-    for (iFormat = 0; iFormat < ma_countof(g_maFormatPriorities); iFormat += 1) {
-        ma_format format = g_maFormatPriorities[iFormat];
-
-        counter = 0;
-        for (;;) {
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            if (format == ma_format_from_encoding__audio4(encoding.encoding, encoding.precision)) {
-                return format;  /* Found a workable format. */
-            }
-
-            /* Getting here means this encoding does not match our preferred format so we need to more on to the next encoding. */
-            counter += 1;
-        }
-    }
-
-    /* Getting here means not appropriate format was found. */
-    return ma_format_unknown;
-}
-#else
-static ma_format ma_format_from_swpar__audio4(struct audio_swpar* par)
-{
-    if (par->bits == 8 && par->bps == 1 && par->sig == 0) {
-        return ma_format_u8;
-    }
-    if (par->bits == 16 && par->bps == 2 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_s16;
-    }
-    if (par->bits == 24 && par->bps == 3 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_s24;
-    }
-    if (par->bits == 32 && par->bps == 4 && par->sig == 1 && par->le == ma_is_little_endian()) {
-        return ma_format_f32;
-    }
-
-    /* Format not supported. */
-    return ma_format_unknown;
-}
-#endif
-
-static ma_result ma_context_get_device_info_from_fd__audio4(ma_context* pContext, ma_device_type deviceType, int fd, ma_device_info* pDeviceInfo)
-{
-    audio_device_t fdDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(fd >= 0);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    (void)pContext;
-    (void)deviceType;
-
-    if (ioctl(fd, AUDIO_GETDEV, &fdDevice) < 0) {
-        return MA_ERROR;   /* Failed to retrieve device info. */
-    }
-
-    /* Name. */
-    ma_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), fdDevice.name);
-
-    #if !defined(MA_AUDIO4_USE_NEW_API)
-    {
-        audio_info_t fdInfo;
-        int counter = 0;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-
-        if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) {
-            return MA_ERROR;
-        }
-
-        if (deviceType == ma_device_type_playback) {
-            channels   = fdInfo.play.channels;
-            sampleRate = fdInfo.play.sample_rate;
-        } else {
-            channels   = fdInfo.record.channels;
-            sampleRate = fdInfo.record.sample_rate;
-        }
-
-        /* Supported formats. We get this by looking at the encodings. */
-        pDeviceInfo->nativeDataFormatCount = 0;
-        for (;;) {
-            audio_encoding_t encoding;
-            ma_format format;
-
-            MA_ZERO_OBJECT(&encoding);
-            encoding.index = counter;
-            if (ioctl(fd, AUDIO_GETENC, &encoding) < 0) {
-                break;
-            }
-
-            format = ma_format_from_encoding__audio4(encoding.encoding, encoding.precision);
-            if (format != ma_format_unknown) {
-                ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0);
-            }
-
-            counter += 1;
-        }
-    }
-    #else
-    {
-        struct audio_swpar fdPar;
-        ma_format format;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-
-        if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-            return MA_ERROR;
-        }
-
-        format = ma_format_from_swpar__audio4(&fdPar);
-        if (format == ma_format_unknown) {
-            return MA_FORMAT_NOT_SUPPORTED;
-        }
-
-        if (deviceType == ma_device_type_playback) {
-            channels = fdPar.pchan;
-        } else {
-            channels = fdPar.rchan;
-        }
-
-        sampleRate = fdPar.rate;
-
-        pDeviceInfo->nativeDataFormatCount = 0;
-        ma_device_info_add_native_data_format(pDeviceInfo, format, channels, sampleRate, 0);
-    }
-    #endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices__audio4(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    const int maxDevices = 64;
-    char devpath[256];
-    int iDevice;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /*
-    Every device will be named "/dev/audioN", with a "/dev/audioctlN" equivalent. We use the "/dev/audioctlN"
-    version here since we can open it even when another process has control of the "/dev/audioN" device.
-    */
-    for (iDevice = 0; iDevice < maxDevices; ++iDevice) {
-        struct stat st;
-        int fd;
-        ma_bool32 isTerminating = MA_FALSE;
-
-        ma_strcpy_s(devpath, sizeof(devpath), "/dev/audioctl");
-        ma_itoa_s(iDevice, devpath+strlen(devpath), sizeof(devpath)-strlen(devpath), 10);
-
-        if (stat(devpath, &st) < 0) {
-            break;
-        }
-
-        /* The device exists, but we need to check if it's usable as playback and/or capture. */
-
-        /* Playback. */
-        if (!isTerminating) {
-            fd = open(devpath, O_RDONLY, 0);
-            if (fd >= 0) {
-                /* Supports playback. */
-                ma_device_info deviceInfo;
-                MA_ZERO_OBJECT(&deviceInfo);
-                ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice);
-                if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_playback, fd, &deviceInfo) == MA_SUCCESS) {
-                    isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                }
-
-                close(fd);
-            }
-        }
-
-        /* Capture. */
-        if (!isTerminating) {
-            fd = open(devpath, O_WRONLY, 0);
-            if (fd >= 0) {
-                /* Supports capture. */
-                ma_device_info deviceInfo;
-                MA_ZERO_OBJECT(&deviceInfo);
-                ma_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice);
-                if (ma_context_get_device_info_from_fd__audio4(pContext, ma_device_type_capture, fd, &deviceInfo) == MA_SUCCESS) {
-                    isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                }
-
-                close(fd);
-            }
-        }
-
-        if (isTerminating) {
-            break;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__audio4(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    int fd = -1;
-    int deviceIndex = -1;
-    char ctlid[256];
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /*
-    We need to open the "/dev/audioctlN" device to get the info. To do this we need to extract the number
-    from the device ID which will be in "/dev/audioN" format.
-    */
-    if (pDeviceID == NULL) {
-        /* Default device. */
-        ma_strcpy_s(ctlid, sizeof(ctlid), "/dev/audioctl");
-    } else {
-        /* Specific device. We need to convert from "/dev/audioN" to "/dev/audioctlN". */
-        result = ma_extract_device_index_from_id__audio4(pDeviceID->audio4, "/dev/audio", &deviceIndex);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        ma_construct_device_id__audio4(ctlid, sizeof(ctlid), "/dev/audioctl", deviceIndex);
-    }
-
-    fd = open(ctlid, (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY, 0);
-    if (fd == -1) {
-        return MA_NO_DEVICE;
-    }
-
-    if (deviceIndex == -1) {
-        ma_strcpy_s(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio");
-    } else {
-        ma_construct_device_id__audio4(pDeviceInfo->id.audio4, sizeof(pDeviceInfo->id.audio4), "/dev/audio", deviceIndex);
-    }
-
-    result = ma_context_get_device_info_from_fd__audio4(pContext, deviceType, fd, pDeviceInfo);
-
-    close(fd);
-    return result;
-}
-
-static ma_result ma_device_uninit__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->audio4.fdCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->audio4.fdPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_fd__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    const char* pDefaultDeviceNames[] = {
-        "/dev/audio",
-        "/dev/audio0"
-    };
-    int fd;
-    int fdFlags = 0;
-    ma_format internalFormat;
-    ma_uint32 internalChannels;
-    ma_uint32 internalSampleRate;
-    ma_uint32 internalPeriodSizeInFrames;
-    ma_uint32 internalPeriods;
-
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    MA_ASSERT(pDevice    != NULL);
-
-    /* The first thing to do is open the file. */
-    if (deviceType == ma_device_type_capture) {
-        fdFlags = O_RDONLY;
-    } else {
-        fdFlags = O_WRONLY;
-    }
-    /*fdFlags |= O_NONBLOCK;*/
-
-    if (pDescriptor->pDeviceID == NULL) {
-        /* Default device. */
-        size_t iDevice;
-        for (iDevice = 0; iDevice < ma_countof(pDefaultDeviceNames); ++iDevice) {
-            fd = open(pDefaultDeviceNames[iDevice], fdFlags, 0);
-            if (fd != -1) {
-                break;
-            }
-        }
-    } else {
-        /* Specific device. */
-        fd = open(pDescriptor->pDeviceID->audio4, fdFlags, 0);
-    }
-
-    if (fd == -1) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to open device.", ma_result_from_errno(errno));
-    }
-
-    #if !defined(MA_AUDIO4_USE_NEW_API)    /* Old API */
-    {
-        audio_info_t fdInfo;
-
-        /*
-        The documentation is a little bit unclear to me as to how it handles formats. It says the
-        following:
-
-            Regardless of formats supported by underlying driver, the audio driver accepts the
-            following formats.
-
-        By then the next sentence says this:
-
-            `encoding` and `precision` are one of the values obtained by AUDIO_GETENC.
-
-        It sounds like a direct contradiction to me. I'm going to play this safe any only use the
-        best sample format returned by AUDIO_GETENC. If the requested format is supported we'll
-        use that, but otherwise we'll just use our standard format priorities to pick an
-        appropriate one.
-        */
-        AUDIO_INITINFO(&fdInfo);
-
-        /* We get the driver to do as much of the data conversion as possible. */
-        if (deviceType == ma_device_type_capture) {
-            fdInfo.mode = AUMODE_RECORD;
-            ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.record.encoding, &fdInfo.record.precision);
-
-            if (pDescriptor->channels != 0) {
-                fdInfo.record.channels = ma_clamp(pDescriptor->channels, 1, 12);    /* From the documentation: `channels` ranges from 1 to 12. */
-            }
-
-            if (pDescriptor->sampleRate != 0) {
-                fdInfo.record.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000);    /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */
-            }
-        } else {
-            fdInfo.mode = AUMODE_PLAY;
-            ma_encoding_from_format__audio4(ma_best_format_from_fd__audio4(fd, pDescriptor->format), &fdInfo.play.encoding, &fdInfo.play.precision);
-
-            if (pDescriptor->channels != 0) {
-                fdInfo.play.channels = ma_clamp(pDescriptor->channels, 1, 12);    /* From the documentation: `channels` ranges from 1 to 12. */
-            }
-
-            if (pDescriptor->sampleRate != 0) {
-                fdInfo.play.sample_rate = ma_clamp(pDescriptor->sampleRate, 1000, 192000);    /* From the documentation: `frequency` ranges from 1000Hz to 192000Hz. (They mean `sample_rate` instead of `frequency`.) */
-            }
-        }
-
-        if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device format. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        if (deviceType == ma_device_type_capture) {
-            internalFormat     = ma_format_from_prinfo__audio4(&fdInfo.record);
-            internalChannels   = fdInfo.record.channels;
-            internalSampleRate = fdInfo.record.sample_rate;
-        } else {
-            internalFormat     = ma_format_from_prinfo__audio4(&fdInfo.play);
-            internalChannels   = fdInfo.play.channels;
-            internalSampleRate = fdInfo.play.sample_rate;
-        }
-
-        if (internalFormat == ma_format_unknown) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        /* Buffer. */
-        {
-            ma_uint32 internalPeriodSizeInBytes;
-
-            internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile);
-
-            internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels);
-            if (internalPeriodSizeInBytes < 16) {
-                internalPeriodSizeInBytes = 16;
-            }
-
-            internalPeriods = pDescriptor->periodCount;
-            if (internalPeriods < 2) {
-                internalPeriods = 2;
-            }
-
-            /* What miniaudio calls a period, audio4 calls a block. */
-            AUDIO_INITINFO(&fdInfo);
-            fdInfo.hiwat     = internalPeriods;
-            fdInfo.lowat     = internalPeriods-1;
-            fdInfo.blocksize = internalPeriodSizeInBytes;
-            if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set internal buffer size. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED);
-            }
-
-            internalPeriods            = fdInfo.hiwat;
-            internalPeriodSizeInFrames = fdInfo.blocksize / ma_get_bytes_per_frame(internalFormat, internalChannels);
-        }
-    }
-    #else
-    {
-        struct audio_swpar fdPar;
-
-        /* We need to retrieve the format of the device so we can know the channel count and sample rate. Then we can calculate the buffer size. */
-        if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve initial device parameters.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        internalFormat     = ma_format_from_swpar__audio4(&fdPar);
-        internalChannels   = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan;
-        internalSampleRate = fdPar.rate;
-
-        if (internalFormat == ma_format_unknown) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-        }
-
-        /* Buffer. */
-        {
-            ma_uint32 internalPeriodSizeInBytes;
-
-            internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, internalSampleRate, pConfig->performanceProfile);
-
-            /* What miniaudio calls a period, audio4 calls a block. */
-            internalPeriodSizeInBytes = internalPeriodSizeInFrames * ma_get_bytes_per_frame(internalFormat, internalChannels);
-            if (internalPeriodSizeInBytes < 16) {
-                internalPeriodSizeInBytes = 16;
-            }
-
-            fdPar.nblks = pDescriptor->periodCount;
-            fdPar.round = internalPeriodSizeInBytes;
-
-            if (ioctl(fd, AUDIO_SETPAR, &fdPar) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device parameters.", MA_FORMAT_NOT_SUPPORTED);
-            }
-
-            if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) {
-                close(fd);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve actual device parameters.", MA_FORMAT_NOT_SUPPORTED);
-            }
-        }
-
-        internalFormat             = ma_format_from_swpar__audio4(&fdPar);
-        internalChannels           = (deviceType == ma_device_type_capture) ? fdPar.rchan : fdPar.pchan;
-        internalSampleRate         = fdPar.rate;
-        internalPeriods            = fdPar.nblks;
-        internalPeriodSizeInFrames = fdPar.round / ma_get_bytes_per_frame(internalFormat, internalChannels);
-    }
-    #endif
-
-    if (internalFormat == ma_format_unknown) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->audio4.fdCapture  = fd;
-    } else {
-        pDevice->audio4.fdPlayback = fd;
-    }
-
-    pDescriptor->format             = internalFormat;
-    pDescriptor->channels           = internalChannels;
-    pDescriptor->sampleRate         = internalSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sound4, internalChannels, pDescriptor->channelMap);
-    pDescriptor->periodSizeInFrames = internalPeriodSizeInFrames;
-    pDescriptor->periodCount        = internalPeriods;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__audio4(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->audio4);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    pDevice->audio4.fdCapture  = -1;
-    pDevice->audio4.fdPlayback = -1;
-
-    /*
-    The version of the operating system dictates whether or not the device is exclusive or shared. NetBSD
-    introduced in-kernel mixing which means it's shared. All other BSD flavours are exclusive as far as
-    I'm aware.
-    */
-#if defined(__NetBSD_Version__) && __NetBSD_Version__ >= 800000000
-    /* NetBSD 8.0+ */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-#else
-    /* All other flavors. */
-#endif
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__audio4(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                close(pDevice->audio4.fdCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->audio4.fdCapture == -1) {
-            return MA_INVALID_ARGS;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->audio4.fdPlayback == -1) {
-            return MA_INVALID_ARGS;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop_fd__audio4(ma_device* pDevice, int fd)
-{
-    if (fd == -1) {
-        return MA_INVALID_ARGS;
-    }
-
-#if !defined(MA_AUDIO4_USE_NEW_API)
-    if (ioctl(fd, AUDIO_FLUSH, 0) < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed.", ma_result_from_errno(errno));
-    }
-#else
-    if (ioctl(fd, AUDIO_STOP, 0) < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_STOP failed.", ma_result_from_errno(errno));
-    }
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__audio4(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result;
-
-        result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result;
-
-        /* Drain the device first. If this fails we'll just need to flush without draining. Unfortunately draining isn't available on newer version of OpenBSD. */
-    #if !defined(MA_AUDIO4_USE_NEW_API)
-        ioctl(pDevice->audio4.fdPlayback, AUDIO_DRAIN, 0);
-    #endif
-
-        /* Here is where the device is stopped immediately. */
-        result = ma_device_stop_fd__audio4(pDevice, pDevice->audio4.fdPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__audio4(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int result;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    result = write(pDevice->audio4.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (result < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to write data to the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__audio4(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int result;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    result = read(pDevice->audio4.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (result < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to read data from the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = (ma_uint32)result / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__audio4(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_audio4);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__audio4(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    pCallbacks->onContextInit             = ma_context_init__audio4;
-    pCallbacks->onContextUninit           = ma_context_uninit__audio4;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__audio4;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__audio4;
-    pCallbacks->onDeviceInit              = ma_device_init__audio4;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__audio4;
-    pCallbacks->onDeviceStart             = ma_device_start__audio4;
-    pCallbacks->onDeviceStop              = ma_device_stop__audio4;
-    pCallbacks->onDeviceRead              = ma_device_read__audio4;
-    pCallbacks->onDeviceWrite             = ma_device_write__audio4;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* audio4 */
-
-
-/******************************************************************************
-
-OSS Backend
-
-******************************************************************************/
-#ifdef MA_HAS_OSS
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/soundcard.h>
-
-#ifndef SNDCTL_DSP_HALT
-#define SNDCTL_DSP_HALT SNDCTL_DSP_RESET
-#endif
-
-#define MA_OSS_DEFAULT_DEVICE_NAME  "/dev/dsp"
-
-static int ma_open_temp_device__oss()
-{
-    /* The OSS sample code uses "/dev/mixer" as the device for getting system properties so I'm going to do the same. */
-    int fd = open("/dev/mixer", O_RDONLY, 0);
-    if (fd >= 0) {
-        return fd;
-    }
-
-    return -1;
-}
-
-static ma_result ma_context_open_device__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, int* pfd)
-{
-    const char* deviceName;
-    int flags;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pfd != NULL);
-    (void)pContext;
-
-    *pfd = -1;
-
-    /* This function should only be called for playback or capture, not duplex. */
-    if (deviceType == ma_device_type_duplex) {
-        return MA_INVALID_ARGS;
-    }
-
-    deviceName = MA_OSS_DEFAULT_DEVICE_NAME;
-    if (pDeviceID != NULL) {
-        deviceName = pDeviceID->oss;
-    }
-
-    flags = (deviceType == ma_device_type_playback) ? O_WRONLY : O_RDONLY;
-    if (shareMode == ma_share_mode_exclusive) {
-        flags |= O_EXCL;
-    }
-
-    *pfd = open(deviceName, flags, 0);
-    if (*pfd == -1) {
-        return ma_result_from_errno(errno);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_enumerate_devices__oss(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    int fd;
-    oss_sysinfo si;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    fd = ma_open_temp_device__oss();
-    if (fd == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND);
-    }
-
-    result = ioctl(fd, SNDCTL_SYSINFO, &si);
-    if (result != -1) {
-        int iAudioDevice;
-        for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) {
-            oss_audioinfo ai;
-            ai.dev = iAudioDevice;
-            result = ioctl(fd, SNDCTL_AUDIOINFO, &ai);
-            if (result != -1) {
-                if (ai.devnode[0] != '\0') {    /* <-- Can be blank, according to documentation. */
-                    ma_device_info deviceInfo;
-                    ma_bool32 isTerminating = MA_FALSE;
-
-                    MA_ZERO_OBJECT(&deviceInfo);
-
-                    /* ID */
-                    ma_strncpy_s(deviceInfo.id.oss, sizeof(deviceInfo.id.oss), ai.devnode, (size_t)-1);
-
-                    /*
-                    The human readable device name should be in the "ai.handle" variable, but it can
-                    sometimes be empty in which case we just fall back to "ai.name" which is less user
-                    friendly, but usually has a value.
-                    */
-                    if (ai.handle[0] != '\0') {
-                        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.handle, (size_t)-1);
-                    } else {
-                        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), ai.name, (size_t)-1);
-                    }
-
-                    /* The device can be both playback and capture. */
-                    if (!isTerminating && (ai.caps & PCM_CAP_OUTPUT) != 0) {
-                        isTerminating = !callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                    }
-                    if (!isTerminating && (ai.caps & PCM_CAP_INPUT) != 0) {
-                        isTerminating = !callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                    }
-
-                    if (isTerminating) {
-                        break;
-                    }
-                }
-            }
-        }
-    } else {
-        close(fd);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND);
-    }
-
-    close(fd);
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_native_data_format__oss(ma_context* pContext, oss_audioinfo* pAudioInfo, ma_format format, ma_device_info* pDeviceInfo)
-{
-    unsigned int minChannels;
-    unsigned int maxChannels;
-    unsigned int iRate;
-
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pAudioInfo  != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /* If we support all channels we just report 0. */
-    minChannels = ma_clamp(pAudioInfo->min_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-    maxChannels = ma_clamp(pAudioInfo->max_channels, MA_MIN_CHANNELS, MA_MAX_CHANNELS);
-
-    /*
-    OSS has this annoying thing where sample rates can be reported in two ways. We prefer explicitness,
-    which OSS has in the form of nrates/rates, however there are times where nrates can be 0, in which
-    case we'll need to use min_rate and max_rate and report only standard rates.
-    */
-    if (pAudioInfo->nrates > 0) {
-        for (iRate = 0; iRate < pAudioInfo->nrates; iRate += 1) {
-            unsigned int rate = pAudioInfo->rates[iRate];
-
-            if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                ma_device_info_add_native_data_format(pDeviceInfo, format, 0, rate, 0);   /* Set the channel count to 0 to indicate that all channel counts are supported. */
-            } else {
-                unsigned int iChannel;
-                for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                     ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, rate, 0);
-                }
-            }
-        }
-    } else {
-        for (iRate = 0; iRate < ma_countof(g_maStandardSampleRatePriorities); iRate += 1) {
-            ma_uint32 standardRate = g_maStandardSampleRatePriorities[iRate];
-
-            if (standardRate >= (ma_uint32)pAudioInfo->min_rate && standardRate <= (ma_uint32)pAudioInfo->max_rate) {
-                if (minChannels == MA_MIN_CHANNELS && maxChannels == MA_MAX_CHANNELS) {
-                    ma_device_info_add_native_data_format(pDeviceInfo, format, 0, standardRate, 0);   /* Set the channel count to 0 to indicate that all channel counts are supported. */
-                } else {
-                    unsigned int iChannel;
-                    for (iChannel = minChannels; iChannel <= maxChannels; iChannel += 1) {
-                         ma_device_info_add_native_data_format(pDeviceInfo, format, iChannel, standardRate, 0);
-                    }
-                }
-            }
-        }
-    }
-}
-
-static ma_result ma_context_get_device_info__oss(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_bool32 foundDevice;
-    int fdTemp;
-    oss_sysinfo si;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* Handle the default device a little differently. */
-    if (pDeviceID == NULL) {
-        if (deviceType == ma_device_type_playback) {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        } else {
-            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        }
-
-        return MA_SUCCESS;
-    }
-
-
-    /* If we get here it means we are _not_ using the default device. */
-    foundDevice = MA_FALSE;
-
-    fdTemp = ma_open_temp_device__oss();
-    if (fdTemp == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND);
-    }
-
-    result = ioctl(fdTemp, SNDCTL_SYSINFO, &si);
-    if (result != -1) {
-        int iAudioDevice;
-        for (iAudioDevice = 0; iAudioDevice < si.numaudios; ++iAudioDevice) {
-            oss_audioinfo ai;
-            ai.dev = iAudioDevice;
-            result = ioctl(fdTemp, SNDCTL_AUDIOINFO, &ai);
-            if (result != -1) {
-                if (ma_strcmp(ai.devnode, pDeviceID->oss) == 0) {
-                    /* It has the same name, so now just confirm the type. */
-                    if ((deviceType == ma_device_type_playback && ((ai.caps & PCM_CAP_OUTPUT) != 0)) ||
-                        (deviceType == ma_device_type_capture  && ((ai.caps & PCM_CAP_INPUT)  != 0))) {
-                        unsigned int formatMask;
-
-                        /* ID */
-                        ma_strncpy_s(pDeviceInfo->id.oss, sizeof(pDeviceInfo->id.oss), ai.devnode, (size_t)-1);
-
-                        /*
-                        The human readable device name should be in the "ai.handle" variable, but it can
-                        sometimes be empty in which case we just fall back to "ai.name" which is less user
-                        friendly, but usually has a value.
-                        */
-                        if (ai.handle[0] != '\0') {
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.handle, (size_t)-1);
-                        } else {
-                            ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), ai.name, (size_t)-1);
-                        }
-
-
-                        pDeviceInfo->nativeDataFormatCount = 0;
-
-                        if (deviceType == ma_device_type_playback) {
-                            formatMask = ai.oformats;
-                        } else {
-                            formatMask = ai.iformats;
-                        }
-
-                        if (((formatMask & AFMT_S16_LE) != 0 && ma_is_little_endian()) || (AFMT_S16_BE && ma_is_big_endian())) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s16, pDeviceInfo);
-                        }
-                        if (((formatMask & AFMT_S32_LE) != 0 && ma_is_little_endian()) || (AFMT_S32_BE && ma_is_big_endian())) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_s32, pDeviceInfo);
-                        }
-                        if ((formatMask & AFMT_U8) != 0) {
-                            ma_context_add_native_data_format__oss(pContext, &ai, ma_format_u8, pDeviceInfo);
-                        }
-
-                        foundDevice = MA_TRUE;
-                        break;
-                    }
-                }
-            }
-        }
-    } else {
-        close(fdTemp);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND);
-    }
-
-
-    close(fdTemp);
-
-    if (!foundDevice) {
-        return MA_NO_DEVICE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_uninit__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->oss.fdCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        close(pDevice->oss.fdPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static int ma_format_to_oss(ma_format format)
-{
-    int ossFormat = AFMT_U8;
-    switch (format) {
-        case ma_format_s16: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break;
-        case ma_format_s24: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break;
-        case ma_format_s32: ossFormat = (ma_is_little_endian()) ? AFMT_S32_LE : AFMT_S32_BE; break;
-        case ma_format_f32: ossFormat = (ma_is_little_endian()) ? AFMT_S16_LE : AFMT_S16_BE; break;
-        case ma_format_u8:
-        default: ossFormat = AFMT_U8; break;
-    }
-
-    return ossFormat;
-}
-
-static ma_format ma_format_from_oss(int ossFormat)
-{
-    if (ossFormat == AFMT_U8) {
-        return ma_format_u8;
-    } else {
-        if (ma_is_little_endian()) {
-            switch (ossFormat) {
-                case AFMT_S16_LE: return ma_format_s16;
-                case AFMT_S32_LE: return ma_format_s32;
-                default: return ma_format_unknown;
-            }
-        } else {
-            switch (ossFormat) {
-                case AFMT_S16_BE: return ma_format_s16;
-                case AFMT_S32_BE: return ma_format_s32;
-                default: return ma_format_unknown;
-            }
-        }
-    }
-
-    return ma_format_unknown;
-}
-
-static ma_result ma_device_init_fd__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    ma_result result;
-    int ossResult;
-    int fd;
-    const ma_device_id* pDeviceID = NULL;
-    ma_share_mode shareMode;
-    int ossFormat;
-    int ossChannels;
-    int ossSampleRate;
-    int ossFragment;
-
-    MA_ASSERT(pDevice != NULL);
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-    
-    pDeviceID     = pDescriptor->pDeviceID;
-    shareMode     = pDescriptor->shareMode;
-    ossFormat     = ma_format_to_oss((pDescriptor->format != ma_format_unknown) ? pDescriptor->format : ma_format_s16); /* Use s16 by default because OSS doesn't like floating point. */
-    ossChannels   = (int)(pDescriptor->channels   > 0) ? pDescriptor->channels   : MA_DEFAULT_CHANNELS;
-    ossSampleRate = (int)(pDescriptor->sampleRate > 0) ? pDescriptor->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-
-    result = ma_context_open_device__oss(pDevice->pContext, deviceType, pDeviceID, shareMode, &fd);
-    if (result != MA_SUCCESS) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-    }
-
-    /*
-    The OSS documantation is very clear about the order we should be initializing the device's properties:
-      1) Format
-      2) Channels
-      3) Sample rate.
-    */
-
-    /* Format. */
-    ossResult = ioctl(fd, SNDCTL_DSP_SETFMT, &ossFormat);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set format.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /* Channels. */
-    ossResult = ioctl(fd, SNDCTL_DSP_CHANNELS, &ossChannels);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set channel count.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /* Sample Rate. */
-    ossResult = ioctl(fd, SNDCTL_DSP_SPEED, &ossSampleRate);
-    if (ossResult == -1) {
-        close(fd);
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set sample rate.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    /*
-    Buffer.
-
-    The documentation says that the fragment settings should be set as soon as possible, but I'm not sure if
-    it should be done before or after format/channels/rate.
-
-    OSS wants the fragment size in bytes and a power of 2. When setting, we specify the power, not the actual
-    value.
-    */
-    {
-        ma_uint32 periodSizeInFrames;
-        ma_uint32 periodSizeInBytes;
-        ma_uint32 ossFragmentSizePower;
-
-        periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, (ma_uint32)ossSampleRate, pConfig->performanceProfile);
-
-        periodSizeInBytes = ma_round_to_power_of_2(periodSizeInFrames * ma_get_bytes_per_frame(ma_format_from_oss(ossFormat), ossChannels));
-        if (periodSizeInBytes < 16) {
-            periodSizeInBytes = 16;
-        }
-
-        ossFragmentSizePower = 4;
-        periodSizeInBytes >>= 4;
-        while (periodSizeInBytes >>= 1) {
-            ossFragmentSizePower += 1;
-        }
-
-        ossFragment = (int)((pConfig->periods << 16) | ossFragmentSizePower);
-        ossResult = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment);
-        if (ossResult == -1) {
-            close(fd);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count.", MA_FORMAT_NOT_SUPPORTED);
-        }
-    }
-
-    /* Internal settings. */
-    if (deviceType == ma_device_type_capture) {
-        pDevice->oss.fdCapture  = fd;
-    } else {
-        pDevice->oss.fdPlayback = fd;
-    }
-
-    pDescriptor->format             = ma_format_from_oss(ossFormat);
-    pDescriptor->channels           = ossChannels;
-    pDescriptor->sampleRate         = ossSampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_sound4, pDescriptor->channels, pDescriptor->channelMap);
-    pDescriptor->periodCount        = (ma_uint32)(ossFragment >> 16);
-    pDescriptor->periodSizeInFrames = (ma_uint32)(1 << (ossFragment & 0xFFFF)) / ma_get_bytes_per_frame(pDescriptor->format, pDescriptor->channels);
-
-    if (pDescriptor->format == ma_format_unknown) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__oss(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    MA_ASSERT(pDevice  != NULL);
-    MA_ASSERT(pConfig  != NULL);
-
-    MA_ZERO_OBJECT(&pDevice->oss);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_result result = ma_device_init_fd__oss(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", result);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-/*
-Note on Starting and Stopping
-=============================
-In the past I was using SNDCTL_DSP_HALT to stop the device, however this results in issues when
-trying to resume the device again. If we use SNDCTL_DSP_HALT, the next write() or read() will
-fail. Instead what we need to do is just not write or read to and from the device when the
-device is not running.
-
-As a result, both the start and stop functions for OSS are just empty stubs. The starting and
-stopping logic is handled by ma_device_write__oss() and ma_device_read__oss(). These will check
-the device state, and if the device is stopped they will simply not do any kind of processing.
-
-The downside to this technique is that I've noticed a fairly lengthy delay in stopping the
-device, up to a second. This is on a virtual machine, and as such might just be due to the
-virtual drivers, but I'm not fully sure. I am not sure how to work around this problem so for
-the moment that's just how it's going to have to be.
-
-When starting the device, OSS will automatically start it when write() or read() is called.
-*/
-static ma_result ma_device_start__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* The device is automatically started with reading and writing. */
-    (void)pDevice;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__oss(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /* See note above on why this is empty. */
-    (void)pDevice;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_write__oss(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
-{
-    int resultOSS;
-    ma_uint32 deviceState;
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = 0;
-    }
-
-    /* Don't do any processing if the device is stopped. */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTED && deviceState != MA_STATE_STARTING) {
-        return MA_SUCCESS;
-    }
-
-    resultOSS = write(pDevice->oss.fdPlayback, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-    if (resultOSS < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to send data from the client to the device.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesWritten != NULL) {
-        *pFramesWritten = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_read__oss(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
-{
-    int resultOSS;
-    ma_uint32 deviceState;
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    /* Don't do any processing if the device is stopped. */
-    deviceState = ma_device_get_state(pDevice);
-    if (deviceState != MA_STATE_STARTED && deviceState != MA_STATE_STARTING) {
-        return MA_SUCCESS;
-    }
-
-    resultOSS = read(pDevice->oss.fdCapture, pPCMFrames, frameCount * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels));
-    if (resultOSS < 0) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to read data from the device to be sent to the client.", ma_result_from_errno(errno));
-    }
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = (ma_uint32)resultOSS / ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__oss(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_oss);
-
-    (void)pContext;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__oss(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    int fd;
-    int ossVersion;
-    int result;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-    /* Try opening a temporary device first so we can get version information. This is closed at the end. */
-    fd = ma_open_temp_device__oss();
-    if (fd == -1) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open temporary device for retrieving system properties.", MA_NO_BACKEND);   /* Looks liks OSS isn't installed, or there are no available devices. */
-    }
-
-    /* Grab the OSS version. */
-    ossVersion = 0;
-    result = ioctl(fd, OSS_GETVERSION, &ossVersion);
-    if (result == -1) {
-        close(fd);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve OSS version.", MA_NO_BACKEND);
-    }
-
-    /* The file handle to temp device is no longer needed. Close ASAP. */
-    close(fd);
-
-    pContext->oss.versionMajor = ((ossVersion & 0xFF0000) >> 16);
-    pContext->oss.versionMinor = ((ossVersion & 0x00FF00) >> 8);
-
-    pCallbacks->onContextInit             = ma_context_init__oss;
-    pCallbacks->onContextUninit           = ma_context_uninit__oss;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__oss;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__oss;
-    pCallbacks->onDeviceInit              = ma_device_init__oss;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__oss;
-    pCallbacks->onDeviceStart             = ma_device_start__oss;
-    pCallbacks->onDeviceStop              = ma_device_stop__oss;
-    pCallbacks->onDeviceRead              = ma_device_read__oss;
-    pCallbacks->onDeviceWrite             = ma_device_write__oss;
-    pCallbacks->onDeviceDataLoop          = NULL;
-
-    return MA_SUCCESS;
-}
-#endif  /* OSS */
-
-
-/******************************************************************************
-
-AAudio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_AAUDIO
-
-/*#include <AAudio/AAudio.h>*/
-
-typedef int32_t                                         ma_aaudio_result_t;
-typedef int32_t                                         ma_aaudio_direction_t;
-typedef int32_t                                         ma_aaudio_sharing_mode_t;
-typedef int32_t                                         ma_aaudio_format_t;
-typedef int32_t                                         ma_aaudio_stream_state_t;
-typedef int32_t                                         ma_aaudio_performance_mode_t;
-typedef int32_t                                         ma_aaudio_usage_t;
-typedef int32_t                                         ma_aaudio_content_type_t;
-typedef int32_t                                         ma_aaudio_input_preset_t;
-typedef int32_t                                         ma_aaudio_data_callback_result_t;
-typedef struct ma_AAudioStreamBuilder_t*                ma_AAudioStreamBuilder;
-typedef struct ma_AAudioStream_t*                       ma_AAudioStream;
-
-#define MA_AAUDIO_UNSPECIFIED                           0
-
-/* Result codes. miniaudio only cares about the success code. */
-#define MA_AAUDIO_OK                                    0
-
-/* Directions. */
-#define MA_AAUDIO_DIRECTION_OUTPUT                      0
-#define MA_AAUDIO_DIRECTION_INPUT                       1
-
-/* Sharing modes. */
-#define MA_AAUDIO_SHARING_MODE_EXCLUSIVE                0
-#define MA_AAUDIO_SHARING_MODE_SHARED                   1
-
-/* Formats. */
-#define MA_AAUDIO_FORMAT_PCM_I16                        1
-#define MA_AAUDIO_FORMAT_PCM_FLOAT                      2
-
-/* Stream states. */
-#define MA_AAUDIO_STREAM_STATE_UNINITIALIZED            0
-#define MA_AAUDIO_STREAM_STATE_UNKNOWN                  1
-#define MA_AAUDIO_STREAM_STATE_OPEN                     2
-#define MA_AAUDIO_STREAM_STATE_STARTING                 3
-#define MA_AAUDIO_STREAM_STATE_STARTED                  4
-#define MA_AAUDIO_STREAM_STATE_PAUSING                  5
-#define MA_AAUDIO_STREAM_STATE_PAUSED                   6
-#define MA_AAUDIO_STREAM_STATE_FLUSHING                 7
-#define MA_AAUDIO_STREAM_STATE_FLUSHED                  8
-#define MA_AAUDIO_STREAM_STATE_STOPPING                 9
-#define MA_AAUDIO_STREAM_STATE_STOPPED                  10
-#define MA_AAUDIO_STREAM_STATE_CLOSING                  11
-#define MA_AAUDIO_STREAM_STATE_CLOSED                   12
-#define MA_AAUDIO_STREAM_STATE_DISCONNECTED             13
-
-/* Performance modes. */
-#define MA_AAUDIO_PERFORMANCE_MODE_NONE                 10
-#define MA_AAUDIO_PERFORMANCE_MODE_POWER_SAVING         11
-#define MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY          12
-
-/* Usage types. */
-#define MA_AAUDIO_USAGE_MEDIA                           1
-#define MA_AAUDIO_USAGE_VOICE_COMMUNICATION             2
-#define MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING  3
-#define MA_AAUDIO_USAGE_ALARM                           4
-#define MA_AAUDIO_USAGE_NOTIFICATION                    5
-#define MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE           6
-#define MA_AAUDIO_USAGE_NOTIFICATION_EVENT              10
-#define MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY        11
-#define MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE  12
-#define MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION         13
-#define MA_AAUDIO_USAGE_GAME                            14
-#define MA_AAUDIO_USAGE_ASSISTANT                       16
-#define MA_AAUDIO_SYSTEM_USAGE_EMERGENCY                1000
-#define MA_AAUDIO_SYSTEM_USAGE_SAFETY                   1001
-#define MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS           1002
-#define MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT             1003
-
-/* Content types. */
-#define MA_AAUDIO_CONTENT_TYPE_SPEECH                   1
-#define MA_AAUDIO_CONTENT_TYPE_MUSIC                    2
-#define MA_AAUDIO_CONTENT_TYPE_MOVIE                    3
-#define MA_AAUDIO_CONTENT_TYPE_SONIFICATION             4
-
-/* Input presets. */
-#define MA_AAUDIO_INPUT_PRESET_GENERIC                  1
-#define MA_AAUDIO_INPUT_PRESET_CAMCORDER                5
-#define MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION        6
-#define MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION      7
-#define MA_AAUDIO_INPUT_PRESET_UNPROCESSED              9
-#define MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE        10
-
-/* Callback results. */
-#define MA_AAUDIO_CALLBACK_RESULT_CONTINUE              0
-#define MA_AAUDIO_CALLBACK_RESULT_STOP                  1
-
-
-typedef ma_aaudio_data_callback_result_t (* ma_AAudioStream_dataCallback) (ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t numFrames);
-typedef void                             (* ma_AAudioStream_errorCallback)(ma_AAudioStream *pStream, void *pUserData, ma_aaudio_result_t error);
-
-typedef ma_aaudio_result_t       (* MA_PFN_AAudio_createStreamBuilder)                   (ma_AAudioStreamBuilder** ppBuilder);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStreamBuilder_delete)                   (ma_AAudioStreamBuilder* pBuilder);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDeviceId)              (ma_AAudioStreamBuilder* pBuilder, int32_t deviceId);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDirection)             (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_direction_t direction);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setSharingMode)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_sharing_mode_t sharingMode);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setFormat)                (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_format_t format);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setChannelCount)          (ma_AAudioStreamBuilder* pBuilder, int32_t channelCount);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setSampleRate)            (ma_AAudioStreamBuilder* pBuilder, int32_t sampleRate);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)(ma_AAudioStreamBuilder* pBuilder, int32_t numFrames);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback) (ma_AAudioStreamBuilder* pBuilder, int32_t numFrames);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setDataCallback)          (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_dataCallback callback, void* pUserData);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setErrorCallback)         (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream_errorCallback callback, void* pUserData);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setPerformanceMode)       (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_performance_mode_t mode);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setUsage)                 (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_usage_t contentType);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setContentType)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_content_type_t contentType);
-typedef void                     (* MA_PFN_AAudioStreamBuilder_setInputPreset)           (ma_AAudioStreamBuilder* pBuilder, ma_aaudio_input_preset_t inputPreset);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStreamBuilder_openStream)               (ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_close)                           (ma_AAudioStream* pStream);
-typedef ma_aaudio_stream_state_t (* MA_PFN_AAudioStream_getState)                        (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_waitForStateChange)              (ma_AAudioStream* pStream, ma_aaudio_stream_state_t inputState, ma_aaudio_stream_state_t* pNextState, int64_t timeoutInNanoseconds);
-typedef ma_aaudio_format_t       (* MA_PFN_AAudioStream_getFormat)                       (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getChannelCount)                 (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getSampleRate)                   (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getBufferCapacityInFrames)       (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getFramesPerDataCallback)        (ma_AAudioStream* pStream);
-typedef int32_t                  (* MA_PFN_AAudioStream_getFramesPerBurst)               (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_requestStart)                    (ma_AAudioStream* pStream);
-typedef ma_aaudio_result_t       (* MA_PFN_AAudioStream_requestStop)                     (ma_AAudioStream* pStream);
-
-static ma_result ma_result_from_aaudio(ma_aaudio_result_t resultAA)
-{
-    switch (resultAA)
-    {
-        case MA_AAUDIO_OK: return MA_SUCCESS;
-        default: break;
-    }
-
-    return MA_ERROR;
-}
-
-static ma_aaudio_usage_t ma_to_usage__aaudio(ma_aaudio_usage usage)
-{
-    switch (usage) {
-        case ma_aaudio_usage_announcement:                   return MA_AAUDIO_USAGE_MEDIA;
-        case ma_aaudio_usage_emergency:                      return MA_AAUDIO_USAGE_VOICE_COMMUNICATION;
-        case ma_aaudio_usage_safety:                         return MA_AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING;
-        case ma_aaudio_usage_vehicle_status:                 return MA_AAUDIO_USAGE_ALARM;
-        case ma_aaudio_usage_alarm:                          return MA_AAUDIO_USAGE_NOTIFICATION;
-        case ma_aaudio_usage_assistance_accessibility:       return MA_AAUDIO_USAGE_NOTIFICATION_RINGTONE;
-        case ma_aaudio_usage_assistance_navigation_guidance: return MA_AAUDIO_USAGE_NOTIFICATION_EVENT;
-        case ma_aaudio_usage_assistance_sonification:        return MA_AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY;
-        case ma_aaudio_usage_assitant:                       return MA_AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
-        case ma_aaudio_usage_game:                           return MA_AAUDIO_USAGE_ASSISTANCE_SONIFICATION;
-        case ma_aaudio_usage_media:                          return MA_AAUDIO_USAGE_GAME;
-        case ma_aaudio_usage_notification:                   return MA_AAUDIO_USAGE_ASSISTANT;
-        case ma_aaudio_usage_notification_event:             return MA_AAUDIO_SYSTEM_USAGE_EMERGENCY;
-        case ma_aaudio_usage_notification_ringtone:          return MA_AAUDIO_SYSTEM_USAGE_SAFETY;
-        case ma_aaudio_usage_voice_communication:            return MA_AAUDIO_SYSTEM_USAGE_VEHICLE_STATUS;
-        case ma_aaudio_usage_voice_communication_signalling: return MA_AAUDIO_SYSTEM_USAGE_ANNOUNCEMENT;
-        default: break;
-    }
-
-    return MA_AAUDIO_USAGE_MEDIA;
-}
-
-static ma_aaudio_content_type_t ma_to_content_type__aaudio(ma_aaudio_content_type contentType)
-{
-    switch (contentType) {
-        case ma_aaudio_content_type_movie:        return MA_AAUDIO_CONTENT_TYPE_MOVIE;
-        case ma_aaudio_content_type_music:        return MA_AAUDIO_CONTENT_TYPE_MUSIC;
-        case ma_aaudio_content_type_sonification: return MA_AAUDIO_CONTENT_TYPE_SONIFICATION;
-        case ma_aaudio_content_type_speech:       return MA_AAUDIO_CONTENT_TYPE_SPEECH;
-        default: break;
-    }
-
-    return MA_AAUDIO_CONTENT_TYPE_SPEECH;
-}
-
-static ma_aaudio_input_preset_t ma_to_input_preset__aaudio(ma_aaudio_input_preset inputPreset)
-{
-    switch (inputPreset) {
-        case ma_aaudio_input_preset_generic:             return MA_AAUDIO_INPUT_PRESET_GENERIC;
-        case ma_aaudio_input_preset_camcorder:           return MA_AAUDIO_INPUT_PRESET_CAMCORDER;
-        case ma_aaudio_input_preset_unprocessed:         return MA_AAUDIO_INPUT_PRESET_UNPROCESSED;
-        case ma_aaudio_input_preset_voice_recognition:   return MA_AAUDIO_INPUT_PRESET_VOICE_RECOGNITION;
-        case ma_aaudio_input_preset_voice_communication: return MA_AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION;
-        case ma_aaudio_input_preset_voice_performance:   return MA_AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE;
-        default: break;
-    }
-
-    return MA_AAUDIO_INPUT_PRESET_GENERIC;
-}
-
-static void ma_stream_error_callback__aaudio(ma_AAudioStream* pStream, void* pUserData, ma_aaudio_result_t error)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    (void)error;
-
-#if defined(MA_DEBUG_OUTPUT)
-    printf("[AAudio] ERROR CALLBACK: error=%d, AAudioStream_getState()=%d\n", error, ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream));
-#endif
-
-    /*
-    From the documentation for AAudio, when a device is disconnected all we can do is stop it. However, we cannot stop it from the callback - we need
-    to do it from another thread. Therefore we are going to use an event thread for the AAudio backend to do this cleanly and safely.
-    */
-    if (((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream) == MA_AAUDIO_STREAM_STATE_DISCONNECTED) {
-#if defined(MA_DEBUG_OUTPUT)
-        printf("[AAudio] Device Disconnected.\n");
-#endif
-    }
-}
-
-static ma_aaudio_data_callback_result_t ma_stream_data_callback_capture__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_handle_backend_data_callback(pDevice, NULL, pAudioData, frameCount);
-
-    (void)pStream;
-    return MA_AAUDIO_CALLBACK_RESULT_CONTINUE;
-}
-
-static ma_aaudio_data_callback_result_t ma_stream_data_callback_playback__aaudio(ma_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    MA_ASSERT(pDevice != NULL);
-
-    ma_device_handle_backend_data_callback(pDevice, pAudioData, NULL, frameCount);
-
-    (void)pStream;
-    return MA_AAUDIO_CALLBACK_RESULT_CONTINUE;
-}
-
-static ma_result ma_create_and_configure_AAudioStreamBuilder__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, const ma_device_descriptor* pDescriptor, const ma_device_config* pConfig, ma_device* pDevice, ma_AAudioStreamBuilder** ppBuilder)
-{
-    ma_AAudioStreamBuilder* pBuilder;
-    ma_aaudio_result_t resultAA;
-    ma_uint32 bufferCapacityInFrames;
-
-    /* Safety. */
-    *ppBuilder = NULL;
-
-    resultAA = ((MA_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    if (pDeviceID != NULL) {
-        ((MA_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio);
-    }
-
-    ((MA_PFN_AAudioStreamBuilder_setDirection)pContext->aaudio.AAudioStreamBuilder_setDirection)(pBuilder, (deviceType == ma_device_type_playback) ? MA_AAUDIO_DIRECTION_OUTPUT : MA_AAUDIO_DIRECTION_INPUT);
-    ((MA_PFN_AAudioStreamBuilder_setSharingMode)pContext->aaudio.AAudioStreamBuilder_setSharingMode)(pBuilder, (shareMode == ma_share_mode_shared) ? MA_AAUDIO_SHARING_MODE_SHARED : MA_AAUDIO_SHARING_MODE_EXCLUSIVE);
-
-
-    /* If we have a device descriptor make sure we configure the stream builder to take our requested parameters. */
-    if (pDescriptor != NULL) {
-        MA_ASSERT(pConfig != NULL); /* We must have a device config if we also have a descriptor. The config is required for AAudio specific configuration options. */
-
-        if (pDescriptor->sampleRate != 0) {
-            ((MA_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pDescriptor->sampleRate);
-        }
-
-        if (deviceType == ma_device_type_capture) {
-            if (pDescriptor->channels != 0) {
-                ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels);
-            }
-            if (pDescriptor->format != ma_format_unknown) {
-                ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT);
-            }
-        } else {
-            if (pDescriptor->channels != 0) {
-                ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pDescriptor->channels);
-            }
-            if (pDescriptor->format != ma_format_unknown) {
-                ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pDescriptor->format == ma_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT);
-            }
-        }
-
-        /*
-        AAudio is annoying when it comes to it's buffer calculation stuff because it doesn't let you
-        retrieve the actual sample rate until after you've opened the stream. But you need to configure
-        the buffer capacity before you open the stream... :/
-
-        To solve, we're just going to assume MA_DEFAULT_SAMPLE_RATE (48000) and move on.
-        */
-        bufferCapacityInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptor, pDescriptor->sampleRate, pConfig->performanceProfile) * pDescriptor->periodCount;
-
-        ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames);
-        ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pDescriptor->periodCount);
-
-        if (deviceType == ma_device_type_capture) {
-            if (pConfig->aaudio.inputPreset != ma_aaudio_input_preset_default && pContext->aaudio.AAudioStreamBuilder_setInputPreset != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setInputPreset)pContext->aaudio.AAudioStreamBuilder_setInputPreset)(pBuilder, ma_to_input_preset__aaudio(pConfig->aaudio.inputPreset));
-            }
-
-            ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_capture__aaudio, (void*)pDevice);
-        } else {
-            if (pConfig->aaudio.usage != ma_aaudio_usage_default && pContext->aaudio.AAudioStreamBuilder_setUsage != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setUsage)pContext->aaudio.AAudioStreamBuilder_setUsage)(pBuilder, ma_to_usage__aaudio(pConfig->aaudio.usage));
-            }
-
-            if (pConfig->aaudio.contentType != ma_aaudio_content_type_default && pContext->aaudio.AAudioStreamBuilder_setContentType != NULL) {
-                ((MA_PFN_AAudioStreamBuilder_setContentType)pContext->aaudio.AAudioStreamBuilder_setContentType)(pBuilder, ma_to_content_type__aaudio(pConfig->aaudio.contentType));
-            }
-
-            ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, ma_stream_data_callback_playback__aaudio, (void*)pDevice);
-        }
-
-        /* Not sure how this affects things, but since there's a mapping between miniaudio's performance profiles and AAudio's performance modes, let go ahead and set it. */
-        ((MA_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == ma_performance_profile_low_latency) ? MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MA_AAUDIO_PERFORMANCE_MODE_NONE);
-    
-        /* We need to set an error callback to detect device changes. */
-        if (pDevice != NULL) {  /* <-- pDevice should never be null if pDescriptor is not null, which is always the case if we hit this branch. Check anyway for safety. */
-            ((MA_PFN_AAudioStreamBuilder_setErrorCallback)pContext->aaudio.AAudioStreamBuilder_setErrorCallback)(pBuilder, ma_stream_error_callback__aaudio, (void*)pDevice);
-        }
-    }
-
-    *ppBuilder = pBuilder;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_open_stream_and_close_builder__aaudio(ma_context* pContext, ma_AAudioStreamBuilder* pBuilder, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-
-    result = ma_result_from_aaudio(((MA_PFN_AAudioStreamBuilder_openStream)pContext->aaudio.AAudioStreamBuilder_openStream)(pBuilder, ppStream));
-    ((MA_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder);
-
-    return result;
-}
-
-static ma_result ma_open_stream_basic__aaudio(ma_context* pContext, const ma_device_id* pDeviceID, ma_device_type deviceType, ma_share_mode shareMode, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    ma_AAudioStreamBuilder* pBuilder;
-
-    *ppStream = NULL;
-
-    result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pContext, pDeviceID, deviceType, shareMode, NULL, NULL, NULL, &pBuilder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_open_stream_and_close_builder__aaudio(pContext, pBuilder, ppStream);
-}
-
-static ma_result ma_open_stream__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, const ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    ma_AAudioStreamBuilder* pBuilder;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pConfig->deviceType != ma_device_type_duplex);   /* This function should not be called for a full-duplex device type. */
-
-    *ppStream = NULL;
-
-    result = ma_create_and_configure_AAudioStreamBuilder__aaudio(pDevice->pContext, pDescriptor->pDeviceID, deviceType, pDescriptor->shareMode, pDescriptor, pConfig, pDevice, &pBuilder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_open_stream_and_close_builder__aaudio(pDevice->pContext, pBuilder, ppStream);
-}
-
-static ma_result ma_close_stream__aaudio(ma_context* pContext, ma_AAudioStream* pStream)
-{
-    return ma_result_from_aaudio(((MA_PFN_AAudioStream_close)pContext->aaudio.AAudioStream_close)(pStream));
-}
-
-static ma_bool32 ma_has_default_device__aaudio(ma_context* pContext, ma_device_type deviceType)
-{
-    /* The only way to know this is to try creating a stream. */
-    ma_AAudioStream* pStream;
-    ma_result result = ma_open_stream_basic__aaudio(pContext, NULL, deviceType, ma_share_mode_shared, &pStream);
-    if (result != MA_SUCCESS) {
-        return MA_FALSE;
-    }
-
-    ma_close_stream__aaudio(pContext, pStream);
-    return MA_TRUE;
-}
-
-static ma_result ma_wait_for_simple_state_transition__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_aaudio_stream_state_t oldState, ma_aaudio_stream_state_t newState)
-{
-    ma_aaudio_stream_state_t actualNewState;
-    ma_aaudio_result_t resultAA = ((MA_PFN_AAudioStream_waitForStateChange)pContext->aaudio.AAudioStream_waitForStateChange)(pStream, oldState, &actualNewState, 5000000000); /* 5 second timeout. */
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    if (newState != actualNewState) {
-        return MA_ERROR;   /* Failed to transition into the expected state. */
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_enumerate_devices__aaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Unfortunately AAudio does not have an enumeration API. Therefore I'm only going to report default devices, but only if it can instantiate a stream. */
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED;
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-
-        if (ma_has_default_device__aaudio(pContext, ma_device_type_playback)) {
-            cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-        }
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED;
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-
-        if (ma_has_default_device__aaudio(pContext, ma_device_type_capture)) {
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_format format, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pStream     != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream);
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)(pStream);
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = flags;
-    pDeviceInfo->nativeDataFormatCount += 1;
-}
-
-static void ma_context_add_native_data_format_from_AAudioStream__aaudio(ma_context* pContext, ma_AAudioStream* pStream, ma_uint32 flags, ma_device_info* pDeviceInfo)
-{
-    /* AAudio supports s16 and f32. */
-    ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_f32, flags, pDeviceInfo);
-    ma_context_add_native_data_format_from_AAudioStream_ex__aaudio(pContext, pStream, ma_format_s16, flags, pDeviceInfo);
-}
-
-static ma_result ma_context_get_device_info__aaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    ma_AAudioStream* pStream;
-    ma_result result;
-
-    MA_ASSERT(pContext != NULL);
-
-    /* ID */
-    if (pDeviceID != NULL) {
-        pDeviceInfo->id.aaudio = pDeviceID->aaudio;
-    } else {
-        pDeviceInfo->id.aaudio = MA_AAUDIO_UNSPECIFIED;
-    }
-
-    /* Name */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-
-    pDeviceInfo->nativeDataFormatCount = 0;
-
-    /* We'll need to open the device to get accurate sample rate and channel count information. */
-    result = ma_open_stream_basic__aaudio(pContext, pDeviceID, deviceType, ma_share_mode_shared, &pStream);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    ma_context_add_native_data_format_from_AAudioStream__aaudio(pContext, pStream, 0, pDeviceInfo);
-
-    ma_close_stream__aaudio(pContext, pStream);
-    pStream = NULL;
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_device_uninit__aaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        pDevice->aaudio.pStreamCapture = NULL;
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_close_stream__aaudio(pDevice->pContext, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        pDevice->aaudio.pStreamPlayback = NULL;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init_by_type__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_type deviceType, ma_device_descriptor* pDescriptor, ma_AAudioStream** ppStream)
-{
-    ma_result result;
-    int32_t bufferCapacityInFrames;
-    int32_t framesPerDataCallback;
-    ma_AAudioStream* pStream;
-
-    MA_ASSERT(pDevice     != NULL);
-    MA_ASSERT(pConfig     != NULL);
-    MA_ASSERT(pDescriptor != NULL);
-
-    *ppStream = NULL;   /* Safety. */
-
-    /* First step is to open the stream. From there we'll be able to extract the internal configuration. */
-    result = ma_open_stream__aaudio(pDevice, pConfig, deviceType, pDescriptor, &pStream);
-    if (result != MA_SUCCESS) {
-        return result;  /* Failed to open the AAudio stream. */
-    }
-
-    /* Now extract the internal configuration. */
-    pDescriptor->format     = (((MA_PFN_AAudioStream_getFormat)pDevice->pContext->aaudio.AAudioStream_getFormat)(pStream) == MA_AAUDIO_FORMAT_PCM_I16) ? ma_format_s16 : ma_format_f32;
-    pDescriptor->channels   = ((MA_PFN_AAudioStream_getChannelCount)pDevice->pContext->aaudio.AAudioStream_getChannelCount)(pStream);
-    pDescriptor->sampleRate = ((MA_PFN_AAudioStream_getSampleRate)pDevice->pContext->aaudio.AAudioStream_getSampleRate)(pStream);
-
-    /* For the channel map we need to be sure we don't overflow any buffers. */
-    if (pDescriptor->channels <= MA_MAX_CHANNELS) {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pDescriptor->channels, pDescriptor->channelMap); /* <-- Cannot find info on channel order, so assuming a default. */
-    } else {
-        ma_channel_map_init_blank(MA_MAX_CHANNELS, pDescriptor->channelMap); /* Too many channels. Use a blank channel map. */
-    }
-
-    bufferCapacityInFrames = ((MA_PFN_AAudioStream_getBufferCapacityInFrames)pDevice->pContext->aaudio.AAudioStream_getBufferCapacityInFrames)(pStream);
-    framesPerDataCallback = ((MA_PFN_AAudioStream_getFramesPerDataCallback)pDevice->pContext->aaudio.AAudioStream_getFramesPerDataCallback)(pStream);
-
-    if (framesPerDataCallback > 0) {
-        pDescriptor->periodSizeInFrames = framesPerDataCallback;
-        pDescriptor->periodCount        = bufferCapacityInFrames / framesPerDataCallback;
-    } else {
-        pDescriptor->periodSizeInFrames = bufferCapacityInFrames;
-        pDescriptor->periodCount        = 1;
-    }
-
-    *ppStream = pStream;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__aaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with AAudio. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_capture, pDescriptorCapture, (ma_AAudioStream**)&pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__aaudio(pDevice, pConfig, ma_device_type_playback, pDescriptorPlayback, (ma_AAudioStream**)&pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream)
-{
-    ma_aaudio_result_t resultAA;
-    ma_aaudio_stream_state_t currentState;
-
-    MA_ASSERT(pDevice != NULL);
-
-    resultAA = ((MA_PFN_AAudioStream_requestStart)pDevice->pContext->aaudio.AAudioStream_requestStart)(pStream);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    /* Do we actually need to wait for the device to transition into it's started state? */
-
-    /* The device should be in either a starting or started state. If it's not set to started we need to wait for it to transition. It should go from starting to started. */
-    currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream);
-    if (currentState != MA_AAUDIO_STREAM_STATE_STARTED) {
-        ma_result result;
-
-        if (currentState != MA_AAUDIO_STREAM_STATE_STARTING) {
-            return MA_ERROR;   /* Expecting the stream to be a starting or started state. */
-        }
-
-        result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STARTED);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop_stream__aaudio(ma_device* pDevice, ma_AAudioStream* pStream)
-{
-    ma_aaudio_result_t resultAA;
-    ma_aaudio_stream_state_t currentState;
-
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the AAudio documentation:
-
-        The stream will stop after all of the data currently buffered has been played.
-
-    This maps with miniaudio's requirement that device's be drained which means we don't need to implement any draining logic.
-    */
-
-    resultAA = ((MA_PFN_AAudioStream_requestStop)pDevice->pContext->aaudio.AAudioStream_requestStop)(pStream);
-    if (resultAA != MA_AAUDIO_OK) {
-        return ma_result_from_aaudio(resultAA);
-    }
-
-    /* The device should be in either a stopping or stopped state. If it's not set to started we need to wait for it to transition. It should go from stopping to stopped. */
-    currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream);
-    if (currentState != MA_AAUDIO_STREAM_STATE_STOPPED) {
-        ma_result result;
-
-        if (currentState != MA_AAUDIO_STREAM_STATE_STOPPING) {
-            return MA_ERROR;   /* Expecting the stream to be a stopping or stopped state. */
-        }
-
-        result = ma_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STOPPED);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__aaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_start_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            if (pDevice->type == ma_device_type_duplex) {
-                ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__aaudio(ma_device* pDevice)
-{
-    ma_stop_proc onStop;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamCapture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_result result = ma_device_stop_stream__aaudio(pDevice, (ma_AAudioStream*)pDevice->aaudio.pStreamPlayback);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__aaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_aaudio);
-
-    ma_dlclose(pContext, pContext->aaudio.hAAudio);
-    pContext->aaudio.hAAudio = NULL;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__aaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    size_t i;
-    const char* libNames[] = {
-        "libaaudio.so"
-    };
-
-    for (i = 0; i < ma_countof(libNames); ++i) {
-        pContext->aaudio.hAAudio = ma_dlopen(pContext, libNames[i]);
-        if (pContext->aaudio.hAAudio != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->aaudio.hAAudio == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->aaudio.AAudio_createStreamBuilder                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudio_createStreamBuilder");
-    pContext->aaudio.AAudioStreamBuilder_delete                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_delete");
-    pContext->aaudio.AAudioStreamBuilder_setDeviceId               = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDeviceId");
-    pContext->aaudio.AAudioStreamBuilder_setDirection              = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDirection");
-    pContext->aaudio.AAudioStreamBuilder_setSharingMode            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSharingMode");
-    pContext->aaudio.AAudioStreamBuilder_setFormat                 = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFormat");
-    pContext->aaudio.AAudioStreamBuilder_setChannelCount           = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setChannelCount");
-    pContext->aaudio.AAudioStreamBuilder_setSampleRate             = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setSampleRate");
-    pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setBufferCapacityInFrames");
-    pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setFramesPerDataCallback");
-    pContext->aaudio.AAudioStreamBuilder_setDataCallback           = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setDataCallback");
-    pContext->aaudio.AAudioStreamBuilder_setErrorCallback          = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setErrorCallback");
-    pContext->aaudio.AAudioStreamBuilder_setPerformanceMode        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setPerformanceMode");
-    pContext->aaudio.AAudioStreamBuilder_setUsage                  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setUsage");
-    pContext->aaudio.AAudioStreamBuilder_setContentType            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setContentType");
-    pContext->aaudio.AAudioStreamBuilder_setInputPreset            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_setInputPreset");
-    pContext->aaudio.AAudioStreamBuilder_openStream                = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStreamBuilder_openStream");
-    pContext->aaudio.AAudioStream_close                            = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_close");
-    pContext->aaudio.AAudioStream_getState                         = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getState");
-    pContext->aaudio.AAudioStream_waitForStateChange               = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_waitForStateChange");
-    pContext->aaudio.AAudioStream_getFormat                        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFormat");
-    pContext->aaudio.AAudioStream_getChannelCount                  = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getChannelCount");
-    pContext->aaudio.AAudioStream_getSampleRate                    = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getSampleRate");
-    pContext->aaudio.AAudioStream_getBufferCapacityInFrames        = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getBufferCapacityInFrames");
-    pContext->aaudio.AAudioStream_getFramesPerDataCallback         = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFramesPerDataCallback");
-    pContext->aaudio.AAudioStream_getFramesPerBurst                = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_getFramesPerBurst");
-    pContext->aaudio.AAudioStream_requestStart                     = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_requestStart");
-    pContext->aaudio.AAudioStream_requestStop                      = (ma_proc)ma_dlsym(pContext, pContext->aaudio.hAAudio, "AAudioStream_requestStop");
-
-
-    pCallbacks->onContextInit             = ma_context_init__aaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__aaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__aaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__aaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__aaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__aaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__aaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__aaudio;
-    pCallbacks->onDeviceRead              = NULL;   /* Not used because AAudio is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not used because AAudio is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not used because AAudio is asynchronous. */
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-#endif  /* AAudio */
-
-
-/******************************************************************************
-
-OpenSL|ES Backend
-
-******************************************************************************/
-#ifdef MA_HAS_OPENSL
-#include <SLES/OpenSLES.h>
-#ifdef MA_ANDROID
-#include <SLES/OpenSLES_Android.h>
-#endif
-
-typedef SLresult (SLAPIENTRY * ma_slCreateEngine_proc)(SLObjectItf* pEngine, SLuint32 numOptions, SLEngineOption* pEngineOptions, SLuint32 numInterfaces, SLInterfaceID* pInterfaceIds, SLboolean* pInterfaceRequired);
-
-/* OpenSL|ES has one-per-application objects :( */
-static SLObjectItf g_maEngineObjectSL    = NULL;
-static SLEngineItf g_maEngineSL          = NULL;
-static ma_uint32   g_maOpenSLInitCounter = 0;
-static ma_spinlock g_maOpenSLSpinlock    = 0;   /* For init/uninit. */
-
-#define MA_OPENSL_OBJ(p)         (*((SLObjectItf)(p)))
-#define MA_OPENSL_OUTPUTMIX(p)   (*((SLOutputMixItf)(p)))
-#define MA_OPENSL_PLAY(p)        (*((SLPlayItf)(p)))
-#define MA_OPENSL_RECORD(p)      (*((SLRecordItf)(p)))
-
-#ifdef MA_ANDROID
-#define MA_OPENSL_BUFFERQUEUE(p) (*((SLAndroidSimpleBufferQueueItf)(p)))
-#else
-#define MA_OPENSL_BUFFERQUEUE(p) (*((SLBufferQueueItf)(p)))
-#endif
-
-static ma_result ma_result_from_OpenSL(SLuint32 result)
-{
-    switch (result)
-    {
-        case SL_RESULT_SUCCESS:                 return MA_SUCCESS;
-        case SL_RESULT_PRECONDITIONS_VIOLATED:  return MA_ERROR;
-        case SL_RESULT_PARAMETER_INVALID:       return MA_INVALID_ARGS;
-        case SL_RESULT_MEMORY_FAILURE:          return MA_OUT_OF_MEMORY;
-        case SL_RESULT_RESOURCE_ERROR:          return MA_INVALID_DATA;
-        case SL_RESULT_RESOURCE_LOST:           return MA_ERROR;
-        case SL_RESULT_IO_ERROR:                return MA_IO_ERROR;
-        case SL_RESULT_BUFFER_INSUFFICIENT:     return MA_NO_SPACE;
-        case SL_RESULT_CONTENT_CORRUPTED:       return MA_INVALID_DATA;
-        case SL_RESULT_CONTENT_UNSUPPORTED:     return MA_FORMAT_NOT_SUPPORTED;
-        case SL_RESULT_CONTENT_NOT_FOUND:       return MA_ERROR;
-        case SL_RESULT_PERMISSION_DENIED:       return MA_ACCESS_DENIED;
-        case SL_RESULT_FEATURE_UNSUPPORTED:     return MA_NOT_IMPLEMENTED;
-        case SL_RESULT_INTERNAL_ERROR:          return MA_ERROR;
-        case SL_RESULT_UNKNOWN_ERROR:           return MA_ERROR;
-        case SL_RESULT_OPERATION_ABORTED:       return MA_ERROR;
-        case SL_RESULT_CONTROL_LOST:            return MA_ERROR;
-        default:                                return MA_ERROR;
-    }
-}
-
-/* Converts an individual OpenSL-style channel identifier (SL_SPEAKER_FRONT_LEFT, etc.) to miniaudio. */
-static ma_uint8 ma_channel_id_to_ma__opensl(SLuint32 id)
-{
-    switch (id)
-    {
-        case SL_SPEAKER_FRONT_LEFT:            return MA_CHANNEL_FRONT_LEFT;
-        case SL_SPEAKER_FRONT_RIGHT:           return MA_CHANNEL_FRONT_RIGHT;
-        case SL_SPEAKER_FRONT_CENTER:          return MA_CHANNEL_FRONT_CENTER;
-        case SL_SPEAKER_LOW_FREQUENCY:         return MA_CHANNEL_LFE;
-        case SL_SPEAKER_BACK_LEFT:             return MA_CHANNEL_BACK_LEFT;
-        case SL_SPEAKER_BACK_RIGHT:            return MA_CHANNEL_BACK_RIGHT;
-        case SL_SPEAKER_FRONT_LEFT_OF_CENTER:  return MA_CHANNEL_FRONT_LEFT_CENTER;
-        case SL_SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER;
-        case SL_SPEAKER_BACK_CENTER:           return MA_CHANNEL_BACK_CENTER;
-        case SL_SPEAKER_SIDE_LEFT:             return MA_CHANNEL_SIDE_LEFT;
-        case SL_SPEAKER_SIDE_RIGHT:            return MA_CHANNEL_SIDE_RIGHT;
-        case SL_SPEAKER_TOP_CENTER:            return MA_CHANNEL_TOP_CENTER;
-        case SL_SPEAKER_TOP_FRONT_LEFT:        return MA_CHANNEL_TOP_FRONT_LEFT;
-        case SL_SPEAKER_TOP_FRONT_CENTER:      return MA_CHANNEL_TOP_FRONT_CENTER;
-        case SL_SPEAKER_TOP_FRONT_RIGHT:       return MA_CHANNEL_TOP_FRONT_RIGHT;
-        case SL_SPEAKER_TOP_BACK_LEFT:         return MA_CHANNEL_TOP_BACK_LEFT;
-        case SL_SPEAKER_TOP_BACK_CENTER:       return MA_CHANNEL_TOP_BACK_CENTER;
-        case SL_SPEAKER_TOP_BACK_RIGHT:        return MA_CHANNEL_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to OpenSL-style. */
-static SLuint32 ma_channel_id_to_opensl(ma_uint8 id)
-{
-    switch (id)
-    {
-        case MA_CHANNEL_MONO:               return SL_SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_FRONT_LEFT:         return SL_SPEAKER_FRONT_LEFT;
-        case MA_CHANNEL_FRONT_RIGHT:        return SL_SPEAKER_FRONT_RIGHT;
-        case MA_CHANNEL_FRONT_CENTER:       return SL_SPEAKER_FRONT_CENTER;
-        case MA_CHANNEL_LFE:                return SL_SPEAKER_LOW_FREQUENCY;
-        case MA_CHANNEL_BACK_LEFT:          return SL_SPEAKER_BACK_LEFT;
-        case MA_CHANNEL_BACK_RIGHT:         return SL_SPEAKER_BACK_RIGHT;
-        case MA_CHANNEL_FRONT_LEFT_CENTER:  return SL_SPEAKER_FRONT_LEFT_OF_CENTER;
-        case MA_CHANNEL_FRONT_RIGHT_CENTER: return SL_SPEAKER_FRONT_RIGHT_OF_CENTER;
-        case MA_CHANNEL_BACK_CENTER:        return SL_SPEAKER_BACK_CENTER;
-        case MA_CHANNEL_SIDE_LEFT:          return SL_SPEAKER_SIDE_LEFT;
-        case MA_CHANNEL_SIDE_RIGHT:         return SL_SPEAKER_SIDE_RIGHT;
-        case MA_CHANNEL_TOP_CENTER:         return SL_SPEAKER_TOP_CENTER;
-        case MA_CHANNEL_TOP_FRONT_LEFT:     return SL_SPEAKER_TOP_FRONT_LEFT;
-        case MA_CHANNEL_TOP_FRONT_CENTER:   return SL_SPEAKER_TOP_FRONT_CENTER;
-        case MA_CHANNEL_TOP_FRONT_RIGHT:    return SL_SPEAKER_TOP_FRONT_RIGHT;
-        case MA_CHANNEL_TOP_BACK_LEFT:      return SL_SPEAKER_TOP_BACK_LEFT;
-        case MA_CHANNEL_TOP_BACK_CENTER:    return SL_SPEAKER_TOP_BACK_CENTER;
-        case MA_CHANNEL_TOP_BACK_RIGHT:     return SL_SPEAKER_TOP_BACK_RIGHT;
-        default: return 0;
-    }
-}
-
-/* Converts a channel mapping to an OpenSL-style channel mask. */
-static SLuint32 ma_channel_map_to_channel_mask__opensl(const ma_channel* pChannelMap, ma_uint32 channels)
-{
-    SLuint32 channelMask = 0;
-    ma_uint32 iChannel;
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        channelMask |= ma_channel_id_to_opensl(pChannelMap[iChannel]);
-    }
-
-    return channelMask;
-}
-
-/* Converts an OpenSL-style channel mask to a miniaudio channel map. */
-static void ma_channel_mask_to_channel_map__opensl(SLuint32 channelMask, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (channels == 1 && channelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_MONO;
-    } else if (channels == 2 && channelMask == 0) {
-        pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-        pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-    } else {
-        if (channels == 1 && (channelMask & SL_SPEAKER_FRONT_CENTER) != 0) {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } else {
-            /* Just iterate over each bit. */
-            ma_uint32 iChannel = 0;
-            ma_uint32 iBit;
-            for (iBit = 0; iBit < 32 && iChannel < channels; ++iBit) {
-                SLuint32 bitValue = (channelMask & (1UL << iBit));
-                if (bitValue != 0) {
-                    /* The bit is set. */
-                    pChannelMap[iChannel] = ma_channel_id_to_ma__opensl(bitValue);
-                    iChannel += 1;
-                }
-            }
-        }
-    }
-}
-
-static SLuint32 ma_round_to_standard_sample_rate__opensl(SLuint32 samplesPerSec)
-{
-    if (samplesPerSec <= SL_SAMPLINGRATE_8) {
-        return SL_SAMPLINGRATE_8;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_11_025) {
-        return SL_SAMPLINGRATE_11_025;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_12) {
-        return SL_SAMPLINGRATE_12;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_16) {
-        return SL_SAMPLINGRATE_16;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_22_05) {
-        return SL_SAMPLINGRATE_22_05;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_24) {
-        return SL_SAMPLINGRATE_24;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_32) {
-        return SL_SAMPLINGRATE_32;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_44_1) {
-        return SL_SAMPLINGRATE_44_1;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_48) {
-        return SL_SAMPLINGRATE_48;
-    }
-
-    /* Android doesn't support more than 48000. */
-#ifndef MA_ANDROID
-    if (samplesPerSec <= SL_SAMPLINGRATE_64) {
-        return SL_SAMPLINGRATE_64;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_88_2) {
-        return SL_SAMPLINGRATE_88_2;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_96) {
-        return SL_SAMPLINGRATE_96;
-    }
-    if (samplesPerSec <= SL_SAMPLINGRATE_192) {
-        return SL_SAMPLINGRATE_192;
-    }
-#endif
-
-    return SL_SAMPLINGRATE_16;
-}
-
-
-static SLint32 ma_to_stream_type__opensl(ma_opensl_stream_type streamType)
-{
-    switch (streamType) {
-        case ma_opensl_stream_type_voice:        return SL_ANDROID_STREAM_VOICE;
-        case ma_opensl_stream_type_system:       return SL_ANDROID_STREAM_SYSTEM;
-        case ma_opensl_stream_type_ring:         return SL_ANDROID_STREAM_RING;
-        case ma_opensl_stream_type_media:        return SL_ANDROID_STREAM_MEDIA;
-        case ma_opensl_stream_type_alarm:        return SL_ANDROID_STREAM_ALARM;
-        case ma_opensl_stream_type_notification: return SL_ANDROID_STREAM_NOTIFICATION;
-        default: break;
-    }
-
-    return SL_ANDROID_STREAM_VOICE;
-}
-
-static SLint32 ma_to_recording_preset__opensl(ma_opensl_recording_preset recordingPreset)
-{
-    switch (recordingPreset) {
-        case ma_opensl_recording_preset_generic:             return SL_ANDROID_RECORDING_PRESET_GENERIC;
-        case ma_opensl_recording_preset_camcorder:           return SL_ANDROID_RECORDING_PRESET_CAMCORDER;
-        case ma_opensl_recording_preset_voice_recognition:   return SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION;
-        case ma_opensl_recording_preset_voice_communication: return SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
-        case ma_opensl_recording_preset_voice_unprocessed:   return SL_ANDROID_RECORDING_PRESET_UNPROCESSED;
-        default: break;
-    }
-
-    return SL_ANDROID_RECORDING_PRESET_NONE;
-}
-
-
-static ma_result ma_context_enumerate_devices__opensl(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to enumerate devices. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    TODO: Test Me.
-
-    This is currently untested, so for now we are just returning default devices.
-    */
-#if 0 && !defined(MA_ANDROID)
-    ma_bool32 isTerminated = MA_FALSE;
-
-    SLuint32 pDeviceIDs[128];
-    SLint32 deviceCount = sizeof(pDeviceIDs) / sizeof(pDeviceIDs[0]);
-
-    SLAudioIODeviceCapabilitiesItf deviceCaps;
-    SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        /* The interface may not be supported so just report a default device. */
-        goto return_default_device;
-    }
-
-    /* Playback */
-    if (!isTerminated) {
-        resultSL = (*deviceCaps)->GetAvailableAudioOutputs(deviceCaps, &deviceCount, pDeviceIDs);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.opensl = pDeviceIDs[iDevice];
-
-            SLAudioOutputDescriptor desc;
-            resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.pDeviceName, (size_t)-1);
-
-                ma_bool32 cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    isTerminated = MA_TRUE;
-                    break;
-                }
-            }
-        }
-    }
-
-    /* Capture */
-    if (!isTerminated) {
-        resultSL = (*deviceCaps)->GetAvailableAudioInputs(deviceCaps, &deviceCount, pDeviceIDs);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            deviceInfo.id.opensl = pDeviceIDs[iDevice];
-
-            SLAudioInputDescriptor desc;
-            resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, deviceInfo.id.opensl, &desc);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.deviceName, (size_t)-1);
-
-                ma_bool32 cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-                if (cbResult == MA_FALSE) {
-                    isTerminated = MA_TRUE;
-                    break;
-                }
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-#else
-    goto return_default_device;
-#endif
-
-return_default_device:;
-    cbResult = MA_TRUE;
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-        cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_context_add_data_format_ex__opensl(ma_context* pContext, ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].format     = format;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].channels   = channels;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].sampleRate = sampleRate;
-    pDeviceInfo->nativeDataFormats[pDeviceInfo->nativeDataFormatCount].flags      = 0;
-    pDeviceInfo->nativeDataFormatCount += 1;
-}
-
-static void ma_context_add_data_format__opensl(ma_context* pContext, ma_format format, ma_device_info* pDeviceInfo)
-{
-    ma_uint32 minChannels   = 1;
-    ma_uint32 maxChannels   = 2;
-    ma_uint32 minSampleRate = (ma_uint32)ma_standard_sample_rate_8000;
-    ma_uint32 maxSampleRate = (ma_uint32)ma_standard_sample_rate_48000;
-    ma_uint32 iChannel;
-    ma_uint32 iSampleRate;
-
-    MA_ASSERT(pContext    != NULL);
-    MA_ASSERT(pDeviceInfo != NULL);
-
-    /*
-    Each sample format can support mono and stereo, and we'll support a small subset of standard
-    rates (up to 48000). A better solution would be to somehow find a native sample rate.
-    */
-    for (iChannel = minChannels; iChannel < maxChannels; iChannel += 1) {
-        for (iSampleRate = 0; iSampleRate < ma_countof(g_maStandardSampleRatePriorities); iSampleRate += 1) {
-            ma_uint32 standardSampleRate = g_maStandardSampleRatePriorities[iSampleRate];
-            if (standardSampleRate >= minSampleRate && standardSampleRate <= maxSampleRate) {
-                ma_context_add_data_format_ex__opensl(pContext, format, iChannel, standardSampleRate, pDeviceInfo);
-            }
-        }
-    }
-}
-
-static ma_result ma_context_get_device_info__opensl(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to get device info. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /*
-    TODO: Test Me.
-
-    This is currently untested, so for now we are just returning default devices.
-    */
-#if 0 && !defined(MA_ANDROID)
-    SLAudioIODeviceCapabilitiesItf deviceCaps;
-    SLresult resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        /* The interface may not be supported so just report a default device. */
-        goto return_default_device;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        SLAudioOutputDescriptor desc;
-        resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, pDeviceID->opensl, &desc);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.pDeviceName, (size_t)-1);
-    } else {
-        SLAudioInputDescriptor desc;
-        resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, pDeviceID->opensl, &desc);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.deviceName, (size_t)-1);
-    }
-
-    goto return_detailed_info;
-#else
-    goto return_default_device;
-#endif
-
-return_default_device:
-    if (pDeviceID != NULL) {
-        if ((deviceType == ma_device_type_playback && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOOUTPUT) ||
-            (deviceType == ma_device_type_capture  && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOINPUT)) {
-            return MA_NO_DEVICE;   /* Don't know the device. */
-        }
-    }
-
-    /* Name / Description */
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    goto return_detailed_info;
-
-
-return_detailed_info:
-
-    /*
-    For now we're just outputting a set of values that are supported by the API but not necessarily supported
-    by the device natively. Later on we should work on this so that it more closely reflects the device's
-    actual native format.
-    */
-    pDeviceInfo->nativeDataFormatCount = 0;
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    ma_context_add_data_format__opensl(pContext, ma_format_f32, pDeviceInfo);
-#endif
-    ma_context_add_data_format__opensl(pContext, ma_format_s16, pDeviceInfo);
-    ma_context_add_data_format__opensl(pContext, ma_format_u8,  pDeviceInfo);
-
-    return MA_SUCCESS;
-}
-
-
-#ifdef MA_ANDROID
-/*void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, SLuint32 eventFlags, const void* pBuffer, SLuint32 bufferSize, SLuint32 dataUsed, void* pContext)*/
-static void ma_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    size_t periodSizeInBytes;
-    ma_uint8* pBuffer;
-    SLresult resultSL;
-
-    MA_ASSERT(pDevice != NULL);
-
-    (void)pBufferQueue;
-
-    /*
-    For now, don't do anything unless the buffer was fully processed. From what I can tell, it looks like
-    OpenSL|ES 1.1 improves on buffer queues to the point that we could much more intelligently handle this,
-    but unfortunately it looks like Android is only supporting OpenSL|ES 1.0.1 for now :(
-    */
-
-    /* Don't do anything if the device is not started. */
-    if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-        return;
-    }
-
-    /* Don't do anything if the device is being drained. */
-    if (pDevice->opensl.isDrainingCapture) {
-        return;
-    }
-
-    periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-    pBuffer = pDevice->opensl.pBufferCapture + (pDevice->opensl.currentBufferIndexCapture * periodSizeInBytes);
-
-    ma_device_handle_backend_data_callback(pDevice, NULL, pBuffer, pDevice->capture.internalPeriodSizeInFrames);
-
-    resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        return;
-    }
-
-    pDevice->opensl.currentBufferIndexCapture = (pDevice->opensl.currentBufferIndexCapture + 1) % pDevice->capture.internalPeriods;
-}
-
-static void ma_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData)
-{
-    ma_device* pDevice = (ma_device*)pUserData;
-    size_t periodSizeInBytes;
-    ma_uint8* pBuffer;
-    SLresult resultSL;
-
-    MA_ASSERT(pDevice != NULL);
-
-    (void)pBufferQueue;
-
-    /* Don't do anything if the device is not started. */
-    if (ma_device_get_state(pDevice) != MA_STATE_STARTED) {
-        return;
-    }
-
-    /* Don't do anything if the device is being drained. */
-    if (pDevice->opensl.isDrainingPlayback) {
-        return;
-    }
-
-    periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-    pBuffer = pDevice->opensl.pBufferPlayback + (pDevice->opensl.currentBufferIndexPlayback * periodSizeInBytes);
-
-    ma_device_handle_backend_data_callback(pDevice, pBuffer, NULL, pDevice->playback.internalPeriodSizeInFrames);
-
-    resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes);
-    if (resultSL != SL_RESULT_SUCCESS) {
-        return;
-    }
-
-    pDevice->opensl.currentBufferIndexPlayback = (pDevice->opensl.currentBufferIndexPlayback + 1) % pDevice->playback.internalPeriods;
-}
-#endif
-
-static ma_result ma_device_uninit__opensl(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before uninitializing the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->opensl.pAudioRecorderObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioRecorderObj);
-        }
-
-        ma__free_from_callbacks(pDevice->opensl.pBufferCapture, &pDevice->pContext->allocationCallbacks);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        if (pDevice->opensl.pAudioPlayerObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioPlayerObj);
-        }
-        if (pDevice->opensl.pOutputMixObj) {
-            MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Destroy((SLObjectItf)pDevice->opensl.pOutputMixObj);
-        }
-
-        ma__free_from_callbacks(pDevice->opensl.pBufferPlayback, &pDevice->pContext->allocationCallbacks);
-    }
-
-    return MA_SUCCESS;
-}
-
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-typedef SLAndroidDataFormat_PCM_EX  ma_SLDataFormat_PCM;
-#else
-typedef SLDataFormat_PCM            ma_SLDataFormat_PCM;
-#endif
-
-static ma_result ma_SLDataFormat_PCM_init__opensl(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, const ma_channel* channelMap, ma_SLDataFormat_PCM* pDataFormat)
-{
-    /* We need to convert our format/channels/rate so that they aren't set to default. */
-    if (format == ma_format_unknown) {
-        format = MA_DEFAULT_FORMAT;
-    }
-    if (channels == 0) {
-        channels = MA_DEFAULT_CHANNELS;
-    }
-    if (sampleRate == 0) {
-        sampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    if (format == ma_format_f32) {
-        pDataFormat->formatType     = SL_ANDROID_DATAFORMAT_PCM_EX;
-        pDataFormat->representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT;
-    } else {
-        pDataFormat->formatType = SL_DATAFORMAT_PCM;
-    }
-#else
-    pDataFormat->formatType = SL_DATAFORMAT_PCM;
-#endif
-
-    pDataFormat->numChannels   = channels;
-    ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = ma_round_to_standard_sample_rate__opensl(sampleRate) * 1000;  /* In millihertz. Annoyingly, the sample rate variable is named differently between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM */
-    pDataFormat->bitsPerSample = ma_get_bytes_per_sample(format)*8;
-    pDataFormat->channelMask   = ma_channel_map_to_channel_mask__opensl(channelMap, channels);
-    pDataFormat->endianness    = (ma_is_little_endian()) ? SL_BYTEORDER_LITTLEENDIAN : SL_BYTEORDER_BIGENDIAN;
-
-    /*
-    Android has a few restrictions on the format as documented here: https://developer.android.com/ndk/guides/audio/opensl-for-android.html
-     - Only mono and stereo is supported.
-     - Only u8 and s16 formats are supported.
-     - Maximum sample rate of 48000.
-    */
-#ifdef MA_ANDROID
-    if (pDataFormat->numChannels > 2) {
-        pDataFormat->numChannels = 2;
-    }
-#if __ANDROID_API__ >= 21
-    if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) {
-        /* It's floating point. */
-        MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT);
-        if (pDataFormat->bitsPerSample > 32) {
-            pDataFormat->bitsPerSample = 32;
-        }
-    } else {
-        if (pDataFormat->bitsPerSample > 16) {
-            pDataFormat->bitsPerSample = 16;
-        }
-    }
-#else
-    if (pDataFormat->bitsPerSample > 16) {
-        pDataFormat->bitsPerSample = 16;
-    }
-#endif
-    if (((SLDataFormat_PCM*)pDataFormat)->samplesPerSec > SL_SAMPLINGRATE_48) {
-        ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec = SL_SAMPLINGRATE_48;
-    }
-#endif
-
-    pDataFormat->containerSize = pDataFormat->bitsPerSample;  /* Always tightly packed for now. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_deconstruct_SLDataFormat_PCM__opensl(ma_SLDataFormat_PCM* pDataFormat, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate, ma_channel* pChannelMap, size_t channelMapCap)
-{
-    ma_bool32 isFloatingPoint = MA_FALSE;
-#if defined(MA_ANDROID) && __ANDROID_API__ >= 21
-    if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) {
-        MA_ASSERT(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT);
-        isFloatingPoint = MA_TRUE;
-    }
-#endif
-    if (isFloatingPoint) {
-        if (pDataFormat->bitsPerSample == 32) {
-            *pFormat = ma_format_f32;
-        }
-    } else {
-        if (pDataFormat->bitsPerSample == 8) {
-            *pFormat = ma_format_u8;
-        } else if (pDataFormat->bitsPerSample == 16) {
-            *pFormat = ma_format_s16;
-        } else if (pDataFormat->bitsPerSample == 24) {
-            *pFormat = ma_format_s24;
-        } else if (pDataFormat->bitsPerSample == 32) {
-            *pFormat = ma_format_s32;
-        }
-    }
-
-    *pChannels   = pDataFormat->numChannels;
-    *pSampleRate = ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec / 1000;
-    ma_channel_mask_to_channel_map__opensl(pDataFormat->channelMask, ma_min(pDataFormat->numChannels, channelMapCap), pChannelMap);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__opensl(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-#ifdef MA_ANDROID
-    SLDataLocator_AndroidSimpleBufferQueue queue;
-    SLresult resultSL;
-    size_t bufferSizeInBytes;
-    SLInterfaceID itfIDs1[1];
-    const SLboolean itfIDsRequired1[] = {SL_BOOLEAN_TRUE};
-#endif
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to initialize a new device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /*
-    For now, only supporting Android implementations of OpenSL|ES since that's the only one I've
-    been able to test with and I currently depend on Android-specific extensions (simple buffer
-    queues).
-    */
-#ifdef MA_ANDROID
-    itfIDs1[0] = (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-
-    /* No exclusive mode with OpenSL|ES. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    /* Now we can start initializing the device properly. */
-    MA_ASSERT(pDevice != NULL);
-    MA_ZERO_OBJECT(&pDevice->opensl);
-
-    queue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        ma_SLDataFormat_PCM pcm;
-        SLDataLocator_IODevice locatorDevice;
-        SLDataSource source;
-        SLDataSink sink;
-        SLAndroidConfigurationItf pRecorderConfig;
-
-        ma_SLDataFormat_PCM_init__opensl(pDescriptorCapture->format, pDescriptorCapture->channels, pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, &pcm);
-
-        locatorDevice.locatorType = SL_DATALOCATOR_IODEVICE;
-        locatorDevice.deviceType  = SL_IODEVICE_AUDIOINPUT;
-        locatorDevice.deviceID    = (pDescriptorCapture->pDeviceID == NULL) ? SL_DEFAULTDEVICEID_AUDIOINPUT : pDescriptorCapture->pDeviceID->opensl;
-        locatorDevice.device      = NULL;
-
-        source.pLocator = &locatorDevice;
-        source.pFormat  = NULL;
-
-        queue.numBuffers = pDescriptorCapture->periodCount;
-
-        sink.pLocator = &queue;
-        sink.pFormat  = (SLDataFormat_PCM*)&pcm;
-
-        resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED) {
-            /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */
-            pcm.formatType    = SL_DATAFORMAT_PCM;
-            pcm.numChannels   = 1;
-            ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16;  /* The name of the sample rate variable is different between SLAndroidDataFormat_PCM_EX and SLDataFormat_PCM. */
-            pcm.bitsPerSample = 16;
-            pcm.containerSize = pcm.bitsPerSample;  /* Always tightly packed for now. */
-            pcm.channelMask   = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
-            resultSL = (*g_maEngineSL)->CreateAudioRecorder(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioRecorderObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        }
-
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio recorder.", ma_result_from_OpenSL(resultSL));
-        }
-
-
-        /* Set the recording preset before realizing the player. */
-        if (pConfig->opensl.recordingPreset != ma_opensl_recording_preset_default) {
-            resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pRecorderConfig);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                SLint32 recordingPreset = ma_to_recording_preset__opensl(pConfig->opensl.recordingPreset);
-                resultSL = (*pRecorderConfig)->SetConfiguration(pRecorderConfig, SL_ANDROID_KEY_RECORDING_PRESET, &recordingPreset, sizeof(SLint32));
-                if (resultSL != SL_RESULT_SUCCESS) {
-                    /* Failed to set the configuration. Just keep going. */
-                }
-            }
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Realize((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio recorder.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_RECORD, &pDevice->opensl.pAudioRecorder);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_RECORD interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueueCapture);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, ma_buffer_queue_callback_capture__opensl_android, pDevice);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* The internal format is determined by the "pcm" object. */
-        ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorCapture->format, &pDescriptorCapture->channels, &pDescriptorCapture->sampleRate, pDescriptorCapture->channelMap, ma_countof(pDescriptorCapture->channelMap));
-
-        /* Buffer. */
-        pDescriptorCapture->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorCapture, pDescriptorCapture->sampleRate, pConfig->performanceProfile);
-        pDevice->opensl.currentBufferIndexCapture = 0;
-
-        bufferSizeInBytes = pDescriptorCapture->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels) * pDescriptorCapture->periodCount;
-        pDevice->opensl.pBufferCapture = (ma_uint8*)ma__calloc_from_callbacks(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks);
-        if (pDevice->opensl.pBufferCapture == NULL) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY);
-        }
-        MA_ZERO_MEMORY(pDevice->opensl.pBufferCapture, bufferSizeInBytes);
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        ma_SLDataFormat_PCM pcm;
-        SLDataSource source;
-        SLDataLocator_OutputMix outmixLocator;
-        SLDataSink sink;
-        SLAndroidConfigurationItf pPlayerConfig;
-
-        ma_SLDataFormat_PCM_init__opensl(pDescriptorPlayback->format, pDescriptorPlayback->channels, pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, &pcm);
-
-        resultSL = (*g_maEngineSL)->CreateOutputMix(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, NULL, NULL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Realize((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize output mix object.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->GetInterface((SLObjectItf)pDevice->opensl.pOutputMixObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_OUTPUTMIX, &pDevice->opensl.pOutputMix);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_OUTPUTMIX interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* Set the output device. */
-        if (pDescriptorPlayback->pDeviceID != NULL) {
-            SLuint32 deviceID_OpenSL = pDescriptorPlayback->pDeviceID->opensl;
-            MA_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL);
-        }
-
-        queue.numBuffers = pDescriptorPlayback->periodCount;
-
-        source.pLocator = &queue;
-        source.pFormat  = (SLDataFormat_PCM*)&pcm;
-
-        outmixLocator.locatorType = SL_DATALOCATOR_OUTPUTMIX;
-        outmixLocator.outputMix   = (SLObjectItf)pDevice->opensl.pOutputMixObj;
-
-        sink.pLocator = &outmixLocator;
-        sink.pFormat  = NULL;
-
-        resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        if (resultSL == SL_RESULT_CONTENT_UNSUPPORTED) {
-            /* Unsupported format. Fall back to something safer and try again. If this fails, just abort. */
-            pcm.formatType = SL_DATAFORMAT_PCM;
-            pcm.numChannels = 2;
-            ((SLDataFormat_PCM*)&pcm)->samplesPerSec = SL_SAMPLINGRATE_16;
-            pcm.bitsPerSample = 16;
-            pcm.containerSize = pcm.bitsPerSample;  /* Always tightly packed for now. */
-            pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
-            resultSL = (*g_maEngineSL)->CreateAudioPlayer(g_maEngineSL, (SLObjectItf*)&pDevice->opensl.pAudioPlayerObj, &source, &sink, 1, itfIDs1, itfIDsRequired1);
-        }
-
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio player.", ma_result_from_OpenSL(resultSL));
-        }
-
-
-        /* Set the stream type before realizing the player. */
-        if (pConfig->opensl.streamType != ma_opensl_stream_type_default) {
-            resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDCONFIGURATION, &pPlayerConfig);
-            if (resultSL == SL_RESULT_SUCCESS) {
-                SLint32 streamType = ma_to_stream_type__opensl(pConfig->opensl.streamType);
-                resultSL = (*pPlayerConfig)->SetConfiguration(pPlayerConfig, SL_ANDROID_KEY_STREAM_TYPE, &streamType, sizeof(SLint32));
-                if (resultSL != SL_RESULT_SUCCESS) {
-                    /* Failed to set the configuration. Just keep going. */
-                }
-            }
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Realize((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_BOOLEAN_FALSE);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio player.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_PLAY, &pDevice->opensl.pAudioPlayer);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_PLAY interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, (SLInterfaceID)pDevice->pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueuePlayback);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", ma_result_from_OpenSL(resultSL));
-        }
-
-        resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, ma_buffer_queue_callback_playback__opensl_android, pDevice);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* The internal format is determined by the "pcm" object. */
-        ma_deconstruct_SLDataFormat_PCM__opensl(&pcm, &pDescriptorPlayback->format, &pDescriptorPlayback->channels, &pDescriptorPlayback->sampleRate, pDescriptorPlayback->channelMap, ma_countof(pDescriptorPlayback->channelMap));
-
-        /* Buffer. */
-        pDescriptorPlayback->periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_descriptor(pDescriptorPlayback, pDescriptorPlayback->sampleRate, pConfig->performanceProfile);
-        pDevice->opensl.currentBufferIndexPlayback   = 0;
-
-        bufferSizeInBytes = pDescriptorPlayback->periodSizeInFrames * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels) * pDescriptorPlayback->periodCount;
-        pDevice->opensl.pBufferPlayback = (ma_uint8*)ma__calloc_from_callbacks(bufferSizeInBytes, &pDevice->pContext->allocationCallbacks);
-        if (pDevice->opensl.pBufferPlayback == NULL) {
-            ma_device_uninit__opensl(pDevice);
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY);
-        }
-        MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, bufferSizeInBytes);
-    }
-
-    return MA_SUCCESS;
-#else
-    return MA_NO_BACKEND;   /* Non-Android implementations are not supported. */
-#endif
-}
-
-static ma_result ma_device_start__opensl(ma_device* pDevice)
-{
-    SLresult resultSL;
-    size_t periodSizeInBytes;
-    ma_uint32 iPeriod;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to start the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_RECORDING);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal capture device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        periodSizeInBytes = pDevice->capture.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels);
-        for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
-            resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pDevice->opensl.pBufferCapture + (periodSizeInBytes * iPeriod), periodSizeInBytes);
-            if (resultSL != SL_RESULT_SUCCESS) {
-                MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for capture device.", ma_result_from_OpenSL(resultSL));
-            }
-        }
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_PLAYING);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal playback device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        /* In playback mode (no duplex) we need to load some initial buffers. In duplex mode we need to enqueu silent buffers. */
-        if (pDevice->type == ma_device_type_duplex) {
-            MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels));
-        } else {
-            ma_device__read_frames_from_client(pDevice, pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods, pDevice->opensl.pBufferPlayback);
-        }
-
-        periodSizeInBytes = pDevice->playback.internalPeriodSizeInFrames * ma_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels);
-        for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; ++iPeriod) {
-            resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pDevice->opensl.pBufferPlayback + (periodSizeInBytes * iPeriod), periodSizeInBytes);
-            if (resultSL != SL_RESULT_SUCCESS) {
-                MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED);
-                return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for playback device.", ma_result_from_OpenSL(resultSL));
-            }
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_drain__opensl(ma_device* pDevice, ma_device_type deviceType)
-{
-    SLAndroidSimpleBufferQueueItf pBufferQueue;
-
-    MA_ASSERT(deviceType == ma_device_type_capture || deviceType == ma_device_type_playback);
-
-    if (pDevice->type == ma_device_type_capture) {
-        pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture;
-        pDevice->opensl.isDrainingCapture  = MA_TRUE;
-    } else {
-        pBufferQueue = (SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback;
-        pDevice->opensl.isDrainingPlayback = MA_TRUE;
-    }
-
-    for (;;) {
-        SLAndroidSimpleBufferQueueState state;
-
-        MA_OPENSL_BUFFERQUEUE(pBufferQueue)->GetState(pBufferQueue, &state);
-        if (state.count == 0) {
-            break;
-        }
-
-        ma_sleep(10);
-    }
-
-    if (pDevice->type == ma_device_type_capture) {
-        pDevice->opensl.isDrainingCapture  = MA_FALSE;
-    } else {
-        pDevice->opensl.isDrainingPlayback = MA_FALSE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__opensl(ma_device* pDevice)
-{
-    SLresult resultSL;
-    ma_stop_proc onStop;
-
-    MA_ASSERT(pDevice != NULL);
-
-    MA_ASSERT(g_maOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before stopping/uninitializing the device. */
-    if (g_maOpenSLInitCounter == 0) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_device_drain__opensl(pDevice, ma_device_type_capture);
-
-        resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal capture device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_drain__opensl(pDevice, ma_device_type_playback);
-
-        resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal playback device.", ma_result_from_OpenSL(resultSL));
-        }
-
-        MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback);
-    }
-
-    /* Make sure the client is aware that the device has stopped. There may be an OpenSL|ES callback for this, but I haven't found it. */
-    onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_context_uninit__opensl(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_opensl);
-    (void)pContext;
-
-    /* Uninit global data. */
-    ma_spinlock_lock(&g_maOpenSLSpinlock);
-    {
-        MA_ASSERT(g_maOpenSLInitCounter > 0);   /* If you've triggered this, it means you have ma_context_init/uninit mismatch. Each successful call to ma_context_init() must be matched up with a call to ma_context_uninit(). */
-
-        g_maOpenSLInitCounter -= 1;
-        if (g_maOpenSLInitCounter == 0) {
-            (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
-        }
-    }
-    ma_spinlock_unlock(&g_maOpenSLSpinlock);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_dlsym_SLInterfaceID__opensl(ma_context* pContext, const char* pName, ma_handle* pHandle)
-{
-    /* We need to return an error if the symbol cannot be found. This is important because there have been reports that some symbols do not exist. */
-    ma_handle* p = (ma_handle*)ma_dlsym(pContext, pContext->opensl.libOpenSLES, pName);
-    if (p == NULL) {
-        ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Cannot find symbol %s", pName);
-        return MA_NO_BACKEND;
-    }
-
-    *pHandle = *p;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_engine_nolock__opensl(ma_context* pContext)
-{
-    g_maOpenSLInitCounter += 1;
-    if (g_maOpenSLInitCounter == 1) {
-        SLresult resultSL;
-
-        resultSL = ((ma_slCreateEngine_proc)pContext->opensl.slCreateEngine)(&g_maEngineObjectSL, 0, NULL, 0, NULL, NULL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            g_maOpenSLInitCounter -= 1;
-            return ma_result_from_OpenSL(resultSL);
-        }
-
-        (*g_maEngineObjectSL)->Realize(g_maEngineObjectSL, SL_BOOLEAN_FALSE);
-
-        resultSL = (*g_maEngineObjectSL)->GetInterface(g_maEngineObjectSL, (SLInterfaceID)pContext->opensl.SL_IID_ENGINE, &g_maEngineSL);
-        if (resultSL != SL_RESULT_SUCCESS) {
-            (*g_maEngineObjectSL)->Destroy(g_maEngineObjectSL);
-            g_maOpenSLInitCounter -= 1;
-            return ma_result_from_OpenSL(resultSL);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__opensl(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    ma_result result;
-
-#if !defined(MA_NO_RUNTIME_LINKING)
-    size_t i;
-    const char* libOpenSLESNames[] = {
-        "libOpenSLES.so"
-    };
-#endif
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig;
-
-#if !defined(MA_NO_RUNTIME_LINKING)
-    /*
-    Dynamically link against libOpenSLES.so. I have now had multiple reports that SL_IID_ANDROIDSIMPLEBUFFERQUEUE cannot be found. One
-    report was happening at compile time and another at runtime. To try working around this, I'm going to link to libOpenSLES at runtime
-    and extract the symbols rather than reference them directly. This should, hopefully, fix these issues as the compiler won't see any
-    references to the symbols and will hopefully skip the checks.
-    */
-    for (i = 0; i < ma_countof(libOpenSLESNames); i += 1) {
-        pContext->opensl.libOpenSLES = ma_dlopen(pContext, libOpenSLESNames[i]);
-        if (pContext->opensl.libOpenSLES != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->opensl.libOpenSLES == NULL) {
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Could not find libOpenSLES.so");
-        return MA_NO_BACKEND;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ENGINE", &pContext->opensl.SL_IID_ENGINE);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_AUDIOIODEVICECAPABILITIES", &pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDSIMPLEBUFFERQUEUE", &pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_RECORD", &pContext->opensl.SL_IID_RECORD);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_PLAY", &pContext->opensl.SL_IID_PLAY);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_OUTPUTMIX", &pContext->opensl.SL_IID_OUTPUTMIX);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    result = ma_dlsym_SLInterfaceID__opensl(pContext, "SL_IID_ANDROIDCONFIGURATION", &pContext->opensl.SL_IID_ANDROIDCONFIGURATION);
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        return result;
-    }
-
-    pContext->opensl.slCreateEngine = (ma_proc)ma_dlsym(pContext, pContext->opensl.libOpenSLES, "slCreateEngine");
-    if (pContext->opensl.slCreateEngine == NULL) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Cannot find symbol slCreateEngine.");
-        return MA_NO_BACKEND;
-    }
-#else
-    pContext->opensl.SL_IID_ENGINE                    = (ma_handle)SL_IID_ENGINE;
-    pContext->opensl.SL_IID_AUDIOIODEVICECAPABILITIES = (ma_handle)SL_IID_AUDIOIODEVICECAPABILITIES;
-    pContext->opensl.SL_IID_ANDROIDSIMPLEBUFFERQUEUE  = (ma_handle)SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
-    pContext->opensl.SL_IID_RECORD                    = (ma_handle)SL_IID_RECORD;
-    pContext->opensl.SL_IID_PLAY                      = (ma_handle)SL_IID_PLAY;
-    pContext->opensl.SL_IID_OUTPUTMIX                 = (ma_handle)SL_IID_OUTPUTMIX;
-    pContext->opensl.SL_IID_ANDROIDCONFIGURATION      = (ma_handle)SL_IID_ANDROIDCONFIGURATION;
-    pContext->opensl.slCreateEngine                   = (ma_proc)slCreateEngine;
-#endif
-
-
-    /* Initialize global data first if applicable. */
-    ma_spinlock_lock(&g_maOpenSLSpinlock);
-    {
-        result = ma_context_init_engine_nolock__opensl(pContext);
-    }
-    ma_spinlock_unlock(&g_maOpenSLSpinlock);
-
-    if (result != MA_SUCCESS) {
-        ma_dlclose(pContext, pContext->opensl.libOpenSLES);
-        ma_post_log_message(pContext, NULL, MA_LOG_LEVEL_INFO, "[OpenSL|ES] Failed to initialize OpenSL engine.");
-        return result;
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__opensl;
-    pCallbacks->onContextUninit           = ma_context_uninit__opensl;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__opensl;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__opensl;
-    pCallbacks->onDeviceInit              = ma_device_init__opensl;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__opensl;
-    pCallbacks->onDeviceStart             = ma_device_start__opensl;
-    pCallbacks->onDeviceStop              = ma_device_stop__opensl;
-    pCallbacks->onDeviceRead              = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not needed because OpenSL|ES is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* OpenSL|ES */
-
-
-/******************************************************************************
-
-Web Audio Backend
-
-******************************************************************************/
-#ifdef MA_HAS_WEBAUDIO
-#include <emscripten/emscripten.h>
-
-static ma_bool32 ma_is_capture_supported__webaudio()
-{
-    return EM_ASM_INT({
-        return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined);
-    }, 0) != 0; /* Must pass in a dummy argument for C99 compatibility. */
-}
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
-{
-    ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount);
-}
-
-void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_playback__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
-{
-    ma_device_handle_backend_data_callback(pDevice, pFrames, NULL, (ma_uint32)frameCount);
-}
-#ifdef __cplusplus
-}
-#endif
-
-static ma_result ma_context_enumerate_devices__webaudio(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_bool32 cbResult = MA_TRUE;
-
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(callback != NULL);
-
-    /* Only supporting default devices for now. */
-
-    /* Playback. */
-    if (cbResult) {
-        ma_device_info deviceInfo;
-        MA_ZERO_OBJECT(&deviceInfo);
-        ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-        deviceInfo.isDefault = MA_TRUE;    /* Only supporting default devices. */
-        cbResult = callback(pContext, ma_device_type_playback, &deviceInfo, pUserData);
-    }
-
-    /* Capture. */
-    if (cbResult) {
-        if (ma_is_capture_supported__webaudio()) {
-            ma_device_info deviceInfo;
-            MA_ZERO_OBJECT(&deviceInfo);
-            ma_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-            deviceInfo.isDefault = MA_TRUE;    /* Only supporting default devices. */
-            cbResult = callback(pContext, ma_device_type_capture, &deviceInfo, pUserData);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_get_device_info__webaudio(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_device_info* pDeviceInfo)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) {
-        return MA_NO_DEVICE;
-    }
-
-    MA_ZERO_MEMORY(pDeviceInfo->id.webaudio, sizeof(pDeviceInfo->id.webaudio));
-
-    /* Only supporting default devices for now. */
-    (void)pDeviceID;
-    if (deviceType == ma_device_type_playback) {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-    } else {
-        ma_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-    }
-
-    /* Only supporting default devices. */
-    pDeviceInfo->isDefault = MA_TRUE;
-
-    /* Web Audio can support any number of channels and sample rates. It only supports f32 formats, however. */
-    pDeviceInfo->nativeDataFormats[0].flags      = 0;
-    pDeviceInfo->nativeDataFormats[0].format     = ma_format_unknown;
-    pDeviceInfo->nativeDataFormats[0].channels   = 0; /* All channels are supported. */
-    pDeviceInfo->nativeDataFormats[0].sampleRate = EM_ASM_INT({
-        try {
-            var temp = new (window.AudioContext || window.webkitAudioContext)();
-            var sampleRate = temp.sampleRate;
-            temp.close();
-            return sampleRate;
-        } catch(e) {
-            return 0;
-        }
-    }, 0);  /* Must pass in a dummy argument for C99 compatibility. */
-
-    if (pDeviceInfo->nativeDataFormats[0].sampleRate == 0) {
-        return MA_NO_DEVICE;
-    }
-
-    pDeviceInfo->nativeDataFormatCount = 1;
-
-    return MA_SUCCESS;
-}
-
-
-static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type deviceType, int deviceIndex)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    EM_ASM({
-        var device = miniaudio.get_device_by_index($0);
-
-        /* Make sure all nodes are disconnected and marked for collection. */
-        if (device.scriptNode !== undefined) {
-            device.scriptNode.onaudioprocess = function(e) {};  /* We want to reset the callback to ensure it doesn't get called after AudioContext.close() has returned. Shouldn't happen since we're disconnecting, but just to be safe... */
-            device.scriptNode.disconnect();
-            device.scriptNode = undefined;
-        }
-        if (device.streamNode !== undefined) {
-            device.streamNode.disconnect();
-            device.streamNode = undefined;
-        }
-
-        /*
-        Stop the device. I think there is a chance the callback could get fired after calling this, hence why we want
-        to clear the callback before closing.
-        */
-        device.webaudio.close();
-        device.webaudio = undefined;
-
-        /* Can't forget to free the intermediary buffer. This is the buffer that's shared between JavaScript and C. */
-        if (device.intermediaryBuffer !== undefined) {
-            Module._free(device.intermediaryBuffer);
-            device.intermediaryBuffer = undefined;
-            device.intermediaryBufferView = undefined;
-            device.intermediaryBufferSizeInBytes = undefined;
-        }
-
-        /* Make sure the device is untracked so the slot can be reused later. */
-        miniaudio.untrack_device_by_index($0);
-    }, deviceIndex, deviceType);
-}
-
-static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_playback, pDevice->webaudio.indexPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_uint32 ma_calculate_period_size_in_frames_from_descriptor__webaudio(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    /*
-    There have been reports of the default buffer size being too small on some browsers. There have been reports of the default buffer
-    size being too small on some browsers. If we're using default buffer size, we'll make sure the period size is a big biffer than our
-    standard defaults.
-    */
-    ma_uint32 periodSizeInFrames;
-
-    if (pDescriptor->periodSizeInFrames == 0) {
-        if (pDescriptor->periodSizeInMilliseconds == 0) {
-            if (performanceProfile == ma_performance_profile_low_latency) {
-                periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(33, nativeSampleRate);  /* 1 frame @ 30 FPS */
-            } else {
-                periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(333, nativeSampleRate);
-            }
-        } else {
-            periodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate);
-        }
-    } else {
-        periodSizeInFrames = pDescriptor->periodSizeInFrames;
-    }
-
-    /* The size of the buffer must be a power of 2 and between 256 and 16384. */
-    if (periodSizeInFrames < 256) {
-        periodSizeInFrames = 256;
-    } else if (periodSizeInFrames > 16384) {
-        periodSizeInFrames = 16384;
-    } else {
-        periodSizeInFrames = ma_next_power_of_2(periodSizeInFrames);
-    }
-
-    return periodSizeInFrames;
-}
-
-static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptor, ma_device_type deviceType)
-{
-    int deviceIndex;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_uint32 periodSizeInFrames;
-
-    MA_ASSERT(pDevice    != NULL);
-    MA_ASSERT(pConfig    != NULL);
-    MA_ASSERT(deviceType != ma_device_type_duplex);
-
-    if (deviceType == ma_device_type_capture && !ma_is_capture_supported__webaudio()) {
-        return MA_NO_DEVICE;
-    }
-
-    /* We're going to calculate some stuff in C just to simplify the JS code. */
-    channels           = (pDescriptor->channels   > 0) ? pDescriptor->channels   : MA_DEFAULT_CHANNELS;
-    sampleRate         = (pDescriptor->sampleRate > 0) ? pDescriptor->sampleRate : MA_DEFAULT_SAMPLE_RATE;
-    periodSizeInFrames = ma_calculate_period_size_in_frames_from_descriptor__webaudio(pDescriptor, sampleRate, pConfig->performanceProfile);
-
-
-    /* We create the device on the JavaScript side and reference it using an index. We use this to make it possible to reference the device between JavaScript and C. */
-    deviceIndex = EM_ASM_INT({
-        var channels   = $0;
-        var sampleRate = $1;
-        var bufferSize = $2;    /* In PCM frames. */
-        var isCapture  = $3;
-        var pDevice    = $4;
-
-        if (typeof(miniaudio) === 'undefined') {
-            return -1;  /* Context not initialized. */
-        }
-
-        var device = {};
-
-        /* The AudioContext must be created in a suspended state. */
-        device.webaudio = new (window.AudioContext || window.webkitAudioContext)({sampleRate:sampleRate});
-        device.webaudio.suspend();
-        device.state = 1; /* MA_STATE_STOPPED */
-
-        /*
-        We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. Because it's passed between
-        JavaScript and C it needs to be allocated and freed using Module._malloc() and Module._free().
-        */
-        device.intermediaryBufferSizeInBytes = channels * bufferSize * 4;
-        device.intermediaryBuffer = Module._malloc(device.intermediaryBufferSizeInBytes);
-        device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-
-        /*
-        Both playback and capture devices use a ScriptProcessorNode for performing per-sample operations.
-
-        ScriptProcessorNode is actually deprecated so this is likely to be temporary. The way this works for playback is very simple. You just set a callback
-        that's periodically fired, just like a normal audio callback function. But apparently this design is "flawed" and is now deprecated in favour of
-        something called AudioWorklets which _forces_ you to load a _separate_ .js file at run time... nice... Hopefully ScriptProcessorNode will continue to
-        work for years to come, but this may need to change to use AudioSourceBufferNode instead, which I think is what Emscripten uses for it's built-in SDL
-        implementation. I'll be avoiding that insane AudioWorklet API like the plague...
-
-        For capture it is a bit unintuitive. We use the ScriptProccessorNode _only_ to get the raw PCM data. It is connected to an AudioContext just like the
-        playback case, however we just output silence to the AudioContext instead of passing any real data. It would make more sense to me to use the
-        MediaRecorder API, but unfortunately you need to specify a MIME time (Opus, Vorbis, etc.) for the binary blob that's returned to the client, but I've
-        been unable to figure out how to get this as raw PCM. The closest I can think is to use the MIME type for WAV files and just parse it, but I don't know
-        how well this would work. Although ScriptProccessorNode is deprecated, in practice it seems to have pretty good browser support so I'm leaving it like
-        this for now. If anyone knows how I could get raw PCM data using the MediaRecorder API please let me know!
-        */
-        device.scriptNode = device.webaudio.createScriptProcessor(bufferSize, channels, channels);
-
-        if (isCapture) {
-            device.scriptNode.onaudioprocess = function(e) {
-                if (device.intermediaryBuffer === undefined) {
-                    return; /* This means the device has been uninitialized. */
-                }
-
-                if(device.intermediaryBufferView.length == 0) {
-                    /* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
-                    device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-                }
-
-                /* Make sure silence it output to the AudioContext destination. Not doing this will cause sound to come out of the speakers! */
-                for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                    e.outputBuffer.getChannelData(iChannel).fill(0.0);
-                }
-
-                /* There are some situations where we may want to send silence to the client. */
-                var sendSilence = false;
-                if (device.streamNode === undefined) {
-                    sendSilence = true;
-                }
-
-                /* Sanity check. This will never happen, right? */
-                if (e.inputBuffer.numberOfChannels != channels) {
-                    console.log("Capture: Channel count mismatch. " + e.inputBufer.numberOfChannels + " != " + channels + ". Sending silence.");
-                    sendSilence = true;
-                }
-
-                /* This looped design guards against the situation where e.inputBuffer is a different size to the original buffer size. Should never happen in practice. */
-                var totalFramesProcessed = 0;
-                while (totalFramesProcessed < e.inputBuffer.length) {
-                    var framesRemaining = e.inputBuffer.length - totalFramesProcessed;
-                    var framesToProcess = framesRemaining;
-                    if (framesToProcess > (device.intermediaryBufferSizeInBytes/channels/4)) {
-                        framesToProcess = (device.intermediaryBufferSizeInBytes/channels/4);
-                    }
-
-                    /* We need to do the reverse of the playback case. We need to interleave the input data and copy it into the intermediary buffer. Then we send it to the client. */
-                    if (sendSilence) {
-                        device.intermediaryBufferView.fill(0.0);
-                    } else {
-                        for (var iFrame = 0; iFrame < framesToProcess; ++iFrame) {
-                            for (var iChannel = 0; iChannel < e.inputBuffer.numberOfChannels; ++iChannel) {
-                                device.intermediaryBufferView[iFrame*channels + iChannel] = e.inputBuffer.getChannelData(iChannel)[totalFramesProcessed + iFrame];
-                            }
-                        }
-                    }
-
-                    /* Send data to the client from our intermediary buffer. */
-                    ccall("ma_device_process_pcm_frames_capture__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
-
-                    totalFramesProcessed += framesToProcess;
-                }
-            };
-
-            navigator.mediaDevices.getUserMedia({audio:true, video:false})
-                .then(function(stream) {
-                    device.streamNode = device.webaudio.createMediaStreamSource(stream);
-                    device.streamNode.connect(device.scriptNode);
-                    device.scriptNode.connect(device.webaudio.destination);
-                })
-                .catch(function(error) {
-                    /* I think this should output silence... */
-                    device.scriptNode.connect(device.webaudio.destination);
-                });
-        } else {
-            device.scriptNode.onaudioprocess = function(e) {
-                if (device.intermediaryBuffer === undefined) {
-                    return; /* This means the device has been uninitialized. */
-                }
-
-                if(device.intermediaryBufferView.length == 0) {
-                    /* Recreate intermediaryBufferView when losing reference to the underlying buffer, probably due to emscripten resizing heap. */
-                    device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
-                }
-
-                var outputSilence = false;
-
-                /* Sanity check. This will never happen, right? */
-                if (e.outputBuffer.numberOfChannels != channels) {
-                    console.log("Playback: Channel count mismatch. " + e.outputBufer.numberOfChannels + " != " + channels + ". Outputting silence.");
-                    outputSilence = true;
-                    return;
-                }
-
-                /* This looped design guards against the situation where e.outputBuffer is a different size to the original buffer size. Should never happen in practice. */
-                var totalFramesProcessed = 0;
-                while (totalFramesProcessed < e.outputBuffer.length) {
-                    var framesRemaining = e.outputBuffer.length - totalFramesProcessed;
-                    var framesToProcess = framesRemaining;
-                    if (framesToProcess > (device.intermediaryBufferSizeInBytes/channels/4)) {
-                        framesToProcess = (device.intermediaryBufferSizeInBytes/channels/4);
-                    }
-
-                    /* Read data from the client into our intermediary buffer. */
-                    ccall("ma_device_process_pcm_frames_playback__webaudio", "undefined", ["number", "number", "number"], [pDevice, framesToProcess, device.intermediaryBuffer]);
-
-                    /* At this point we'll have data in our intermediary buffer which we now need to deinterleave and copy over to the output buffers. */
-                    if (outputSilence) {
-                        for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                            e.outputBuffer.getChannelData(iChannel).fill(0.0);
-                        }
-                    } else {
-                        for (var iChannel = 0; iChannel < e.outputBuffer.numberOfChannels; ++iChannel) {
-                            for (var iFrame = 0; iFrame < framesToProcess; ++iFrame) {
-                                e.outputBuffer.getChannelData(iChannel)[totalFramesProcessed + iFrame] = device.intermediaryBufferView[iFrame*channels + iChannel];
-                            }
-                        }
-                    }
-
-                    totalFramesProcessed += framesToProcess;
-                }
-            };
-
-            device.scriptNode.connect(device.webaudio.destination);
-        }
-
-        return miniaudio.track_device(device);
-    }, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice);
-
-    if (deviceIndex < 0) {
-        return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
-    }
-
-    if (deviceType == ma_device_type_capture) {
-        pDevice->webaudio.indexCapture  = deviceIndex;
-    } else {
-        pDevice->webaudio.indexPlayback = deviceIndex;
-    }
-
-    pDescriptor->format              = ma_format_f32;
-    pDescriptor->channels            = channels;
-    ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDescriptor->channels, pDescriptor->channelMap);
-    pDescriptor->sampleRate          = EM_ASM_INT({ return miniaudio.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
-    pDescriptor->periodSizeInFrames  = periodSizeInFrames;
-    pDescriptor->periodCount         = 1;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_init__webaudio(ma_device* pDevice, const ma_device_config* pConfig, ma_device_descriptor* pDescriptorPlayback, ma_device_descriptor* pDescriptorCapture)
-{
-    ma_result result;
-
-    if (pConfig->deviceType == ma_device_type_loopback) {
-        return MA_DEVICE_TYPE_NOT_SUPPORTED;
-    }
-
-    /* No exclusive mode with Web Audio. */
-    if (((pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) && pDescriptorPlayback->shareMode == ma_share_mode_exclusive) ||
-        ((pConfig->deviceType == ma_device_type_capture  || pConfig->deviceType == ma_device_type_duplex) && pDescriptorCapture->shareMode  == ma_share_mode_exclusive)) {
-        return MA_SHARE_MODE_NOT_SUPPORTED;
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__webaudio(pDevice, pConfig, pDescriptorCapture, ma_device_type_capture);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        result = ma_device_init_by_type__webaudio(pDevice, pConfig, pDescriptorPlayback, ma_device_type_playback);
-        if (result != MA_SUCCESS) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                ma_device_uninit_by_index__webaudio(pDevice, ma_device_type_capture, pDevice->webaudio.indexCapture);
-            }
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_start__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.resume();
-            device.state = 2; /* MA_STATE_STARTED */
-        }, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.resume();
-            device.state = 2; /* MA_STATE_STARTED */
-        }, pDevice->webaudio.indexPlayback);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_device_stop__webaudio(ma_device* pDevice)
-{
-    MA_ASSERT(pDevice != NULL);
-
-    /*
-    From the WebAudio API documentation for AudioContext.suspend():
-
-        Suspends the progression of AudioContext's currentTime, allows any current context processing blocks that are already processed to be played to the
-        destination, and then allows the system to release its claim on audio hardware.
-
-    I read this to mean that "any current context processing blocks" are processed by suspend() - i.e. They they are drained. We therefore shouldn't need to
-    do any kind of explicit draining.
-    */
-
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.suspend();
-            device.state = 1; /* MA_STATE_STOPPED */
-        }, pDevice->webaudio.indexCapture);
-    }
-
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        EM_ASM({
-            var device = miniaudio.get_device_by_index($0);
-            device.webaudio.suspend();
-            device.state = 1; /* MA_STATE_STOPPED */
-        }, pDevice->webaudio.indexPlayback);
-    }
-
-    ma_stop_proc onStop = pDevice->onStop;
-    if (onStop) {
-        onStop(pDevice);
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_uninit__webaudio(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-    MA_ASSERT(pContext->backend == ma_backend_webaudio);
-
-    /* Nothing needs to be done here. */
-    (void)pContext;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init__webaudio(ma_context* pContext, const ma_context_config* pConfig, ma_backend_callbacks* pCallbacks)
-{
-    int resultFromJS;
-
-    MA_ASSERT(pContext != NULL);
-
-    (void)pConfig; /* Unused. */
-
-    /* Here is where our global JavaScript object is initialized. */
-    resultFromJS = EM_ASM_INT({
-        if ((window.AudioContext || window.webkitAudioContext) === undefined) {
-            return 0;   /* Web Audio not supported. */
-        }
-
-        if (typeof(miniaudio) === 'undefined') {
-            miniaudio = {};
-            miniaudio.devices = [];   /* Device cache for mapping devices to indexes for JavaScript/C interop. */
-
-            miniaudio.track_device = function(device) {
-                /* Try inserting into a free slot first. */
-                for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) {
-                    if (miniaudio.devices[iDevice] == null) {
-                        miniaudio.devices[iDevice] = device;
-                        return iDevice;
-                    }
-                }
-
-                /* Getting here means there is no empty slots in the array so we just push to the end. */
-                miniaudio.devices.push(device);
-                return miniaudio.devices.length - 1;
-            };
-
-            miniaudio.untrack_device_by_index = function(deviceIndex) {
-                /* We just set the device's slot to null. The slot will get reused in the next call to ma_track_device. */
-                miniaudio.devices[deviceIndex] = null;
-
-                /* Trim the array if possible. */
-                while (miniaudio.devices.length > 0) {
-                    if (miniaudio.devices[miniaudio.devices.length-1] == null) {
-                        miniaudio.devices.pop();
-                    } else {
-                        break;
-                    }
-                }
-            };
-
-            miniaudio.untrack_device = function(device) {
-                for (var iDevice = 0; iDevice < miniaudio.devices.length; ++iDevice) {
-                    if (miniaudio.devices[iDevice] == device) {
-                        return miniaudio.untrack_device_by_index(iDevice);
-                    }
-                }
-            };
-
-            miniaudio.get_device_by_index = function(deviceIndex) {
-                return miniaudio.devices[deviceIndex];
-            };
-
-            miniaudio.unlock_event_types = (function(){
-                return ['touchstart', 'touchend', 'click'];
-            })();
-
-            miniaudio.unlock = function() {
-                for(var i = 0; i < miniaudio.devices.length; ++i) {
-                    var device = miniaudio.devices[i];
-                    if (device != null && device.webaudio != null && device.state === 2 /* MA_STATE_STARTED */) {
-                        device.webaudio.resume();
-                    }
-                }
-                miniaudio.unlock_event_types.map(function(event_type) {
-                    document.removeEventListener(event_type, miniaudio.unlock, true);
-                });
-            };
-
-            miniaudio.unlock_event_types.map(function(event_type) {
-                document.addEventListener(event_type, miniaudio.unlock, true);
-            });
-        }
-
-        return 1;
-    }, 0);  /* Must pass in a dummy argument for C99 compatibility. */
-
-    if (resultFromJS != 1) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pCallbacks->onContextInit             = ma_context_init__webaudio;
-    pCallbacks->onContextUninit           = ma_context_uninit__webaudio;
-    pCallbacks->onContextEnumerateDevices = ma_context_enumerate_devices__webaudio;
-    pCallbacks->onContextGetDeviceInfo    = ma_context_get_device_info__webaudio;
-    pCallbacks->onDeviceInit              = ma_device_init__webaudio;
-    pCallbacks->onDeviceUninit            = ma_device_uninit__webaudio;
-    pCallbacks->onDeviceStart             = ma_device_start__webaudio;
-    pCallbacks->onDeviceStop              = ma_device_stop__webaudio;
-    pCallbacks->onDeviceRead              = NULL;   /* Not needed because WebAudio is asynchronous. */
-    pCallbacks->onDeviceWrite             = NULL;   /* Not needed because WebAudio is asynchronous. */
-    pCallbacks->onDeviceDataLoop          = NULL;   /* Not needed because WebAudio is asynchronous. */
-
-    return MA_SUCCESS;
-}
-#endif  /* Web Audio */
-
-
-
-static ma_bool32 ma__is_channel_map_valid(const ma_channel* channelMap, ma_uint32 channels)
-{
-    /* A blank channel map should be allowed, in which case it should use an appropriate default which will depend on context. */
-    if (channelMap[0] != MA_CHANNEL_NONE) {
-        ma_uint32 iChannel;
-
-        if (channels == 0 || channels > MA_MAX_CHANNELS) {
-            return MA_FALSE;   /* Channel count out of range. */
-        }
-
-        /* A channel cannot be present in the channel map more than once. */
-        for (iChannel = 0; iChannel < channels; ++iChannel) {
-            ma_uint32 jChannel;
-            for (jChannel = iChannel + 1; jChannel < channels; ++jChannel) {
-                if (channelMap[iChannel] == channelMap[jChannel]) {
-                    return MA_FALSE;
-                }
-            }
-        }
-    }
-
-    return MA_TRUE;
-}
-
-
-static ma_result ma_device__post_init_setup(ma_device* pDevice, ma_device_type deviceType)
-{
-    ma_result result;
-
-    MA_ASSERT(pDevice != NULL);
-
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex) {
-        if (pDevice->capture.format == ma_format_unknown) {
-            pDevice->capture.format = pDevice->capture.internalFormat;
-        }
-        if (pDevice->capture.channels == 0) {
-            pDevice->capture.channels = pDevice->capture.internalChannels;
-        }
-        if (pDevice->capture.channelMap[0] == MA_CHANNEL_NONE) {
-            MA_ASSERT(pDevice->capture.channels <= MA_MAX_CHANNELS);
-            if (pDevice->capture.internalChannels == pDevice->capture.channels) {
-                ma_channel_map_copy(pDevice->capture.channelMap, pDevice->capture.internalChannelMap, pDevice->capture.channels);
-            } else {
-                if (pDevice->capture.channelMixMode == ma_channel_mix_mode_simple) {
-                    ma_channel_map_init_blank(pDevice->capture.channels, pDevice->capture.channelMap);
-                } else {
-                    ma_get_standard_channel_map(ma_standard_channel_map_default, pDevice->capture.channels, pDevice->capture.channelMap);
-                }
-            }
-        }
-    }
-
-    if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
-        if (pDevice->playback.format == ma_format_unknown) {
-            pDevice->playback.format = pDevice->playback.internalFormat;
-        }
-        if (pDevice->playback.channels == 0) {
-            pDevice->playback.channels = pDevice->playback.internalChannels;
-        }
-        if (pDevice->playback.channelMap[0] == MA_CHANNEL_NONE) {
-            MA_ASSERT(pDevice->playback.channels <= MA_MAX_CHANNELS);
-            if (pDevice->playback.internalChannels == pDevice->playback.channels) {
-                ma_channel_map_copy(pDevice->playback.channelMap, pDevice->playback.internalChannelMap, pDevice->playback.channels);
-            } else {
-                if (pDevice->playback.channelMixMode == ma_channel_mix_mode_simple) {
-                    ma_channel_map_init_blank(pDevice->playback.channels, pDevice->playback.channelMap);
-                } else {
-                    ma_get_standard_channel_map(ma_standard_channel_map_default, pDevice->playback.channels, pDevice->playback.channelMap);
-                }
-            }
-        }
-    }
-
-    if (pDevice->sampleRate == 0) {
-        if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex) {
-            pDevice->sampleRate = pDevice->capture.internalSampleRate;
-        } else {
-            pDevice->sampleRate = pDevice->playback.internalSampleRate;
-        }
-    }
-
-    /* Data converters. */
-    if (deviceType == ma_device_type_capture || deviceType == ma_device_type_duplex || deviceType == ma_device_type_loopback) {
-        /* Converting from internal device format to client format. */
-        ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
-        converterConfig.formatIn                   = pDevice->capture.internalFormat;
-        converterConfig.channelsIn                 = pDevice->capture.internalChannels;
-        converterConfig.sampleRateIn               = pDevice->capture.internalSampleRate;
-        ma_channel_map_copy(converterConfig.channelMapIn, pDevice->capture.internalChannelMap, ma_min(pDevice->capture.internalChannels, MA_MAX_CHANNELS));
-        converterConfig.formatOut                  = pDevice->capture.format;
-        converterConfig.channelsOut                = pDevice->capture.channels;
-        converterConfig.sampleRateOut              = pDevice->sampleRate;
-        ma_channel_map_copy(converterConfig.channelMapOut, pDevice->capture.channelMap, ma_min(pDevice->capture.channels, MA_MAX_CHANNELS));
-        converterConfig.channelMixMode             = pDevice->capture.channelMixMode;
-        converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;
-        converterConfig.resampling.algorithm       = pDevice->resampling.algorithm;
-        converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
-        converterConfig.resampling.speex.quality   = pDevice->resampling.speex.quality;
-
-        result = ma_data_converter_init(&converterConfig, &pDevice->capture.converter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    if (deviceType == ma_device_type_playback || deviceType == ma_device_type_duplex) {
-        /* Converting from client format to device format. */
-        ma_data_converter_config converterConfig = ma_data_converter_config_init_default();
-        converterConfig.formatIn                   = pDevice->playback.format;
-        converterConfig.channelsIn                 = pDevice->playback.channels;
-        converterConfig.sampleRateIn               = pDevice->sampleRate;
-        ma_channel_map_copy(converterConfig.channelMapIn, pDevice->playback.channelMap, ma_min(pDevice->playback.channels, MA_MAX_CHANNELS));
-        converterConfig.formatOut                  = pDevice->playback.internalFormat;
-        converterConfig.channelsOut                = pDevice->playback.internalChannels;
-        converterConfig.sampleRateOut              = pDevice->playback.internalSampleRate;
-        ma_channel_map_copy(converterConfig.channelMapOut, pDevice->playback.internalChannelMap, ma_min(pDevice->playback.internalChannels, MA_MAX_CHANNELS));
-        converterConfig.channelMixMode             = pDevice->playback.channelMixMode;
-        converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;
-        converterConfig.resampling.algorithm       = pDevice->resampling.algorithm;
-        converterConfig.resampling.linear.lpfOrder = pDevice->resampling.linear.lpfOrder;
-        converterConfig.resampling.speex.quality   = pDevice->resampling.speex.quality;
-
-        result = ma_data_converter_init(&converterConfig, &pDevice->playback.converter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
-{
-    ma_device* pDevice = (ma_device*)pData;
-    MA_ASSERT(pDevice != NULL);
-
-#ifdef MA_WIN32
-    ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE);
-#endif
-
-    /*
-    When the device is being initialized it's initial state is set to MA_STATE_UNINITIALIZED. Before returning from
-    ma_device_init(), the state needs to be set to something valid. In miniaudio the device's default state immediately
-    after initialization is stopped, so therefore we need to mark the device as such. miniaudio will wait on the worker
-    thread to signal an event to know when the worker thread is ready for action.
-    */
-    ma_device__set_state(pDevice, MA_STATE_STOPPED);
-    ma_event_signal(&pDevice->stopEvent);
-
-    for (;;) {  /* <-- This loop just keeps the thread alive. The main audio loop is inside. */
-        ma_stop_proc onStop;
-
-        /* We wait on an event to know when something has requested that the device be started and the main loop entered. */
-        ma_event_wait(&pDevice->wakeupEvent);
-
-        /* Default result code. */
-        pDevice->workResult = MA_SUCCESS;
-
-        /* If the reason for the wake up is that we are terminating, just break from the loop. */
-        if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-            break;
-        }
-
-        /*
-        Getting to this point means the device is wanting to get started. The function that has requested that the device
-        be started will be waiting on an event (pDevice->startEvent) which means we need to make sure we signal the event
-        in both the success and error case. It's important that the state of the device is set _before_ signaling the event.
-        */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STARTING);
-
-        /* If the device has a start callback, start it now. */
-        if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
-            ma_result result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
-            if (result != MA_SUCCESS) {
-                pDevice->workResult = result;   /* Failed to start the device. */
-            }
-        }
-
-        /* Make sure the state is set appropriately. */
-        ma_device__set_state(pDevice, MA_STATE_STARTED);
-        ma_event_signal(&pDevice->startEvent);
-
-        if (pDevice->pContext->callbacks.onDeviceDataLoop != NULL) {
-            pDevice->pContext->callbacks.onDeviceDataLoop(pDevice);
-        } else {
-            /* The backend is not using a custom main loop implementation, so now fall back to the blocking read-write implementation. */
-            ma_device_audio_thread__default_read_write(pDevice);
-        }
-
-        /*
-        Getting here means we have broken from the main loop which happens the application has requested that device be stopped. Note that this
-        may have actually already happened above if the device was lost and miniaudio has attempted to re-initialize the device. In this case we
-        don't want to be doing this a second time.
-        */
-        if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
-            if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
-                pDevice->pContext->callbacks.onDeviceStop(pDevice);
-            }
-        }
-
-        /* After the device has stopped, make sure an event is posted. */
-        onStop = pDevice->onStop;
-        if (onStop) {
-            onStop(pDevice);
-        }
-
-        /*
-        A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. Note that
-        it's possible that the device has been uninitialized which means we need to _not_ change the status to stopped. We cannot go from an
-        uninitialized state to stopped state.
-        */
-        if (ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED) {
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-            ma_event_signal(&pDevice->stopEvent);
-        }
-    }
-
-    /* Make sure we aren't continuously waiting on a stop event. */
-    ma_event_signal(&pDevice->stopEvent);  /* <-- Is this still needed? */
-
-#ifdef MA_WIN32
-    ma_CoUninitialize(pDevice->pContext);
-#endif
-
-    return (ma_thread_result)0;
-}
-
-
-/* Helper for determining whether or not the given device is initialized. */
-static ma_bool32 ma_device__is_initialized(ma_device* pDevice)
-{
-    if (pDevice == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_device_get_state(pDevice) != MA_STATE_UNINITIALIZED;
-}
-
-
-#ifdef MA_WIN32
-static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
-{
-    ma_CoUninitialize(pContext);
-    ma_dlclose(pContext, pContext->win32.hUser32DLL);
-    ma_dlclose(pContext, pContext->win32.hOle32DLL);
-    ma_dlclose(pContext, pContext->win32.hAdvapi32DLL);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
-{
-#ifdef MA_WIN32_DESKTOP
-    /* Ole32.dll */
-    pContext->win32.hOle32DLL = ma_dlopen(pContext, "ole32.dll");
-    if (pContext->win32.hOle32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.CoInitializeEx   = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoInitializeEx");
-    pContext->win32.CoUninitialize   = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoUninitialize");
-    pContext->win32.CoCreateInstance = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoCreateInstance");
-    pContext->win32.CoTaskMemFree    = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "CoTaskMemFree");
-    pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "PropVariantClear");
-    pContext->win32.StringFromGUID2  = (ma_proc)ma_dlsym(pContext, pContext->win32.hOle32DLL, "StringFromGUID2");
-
-
-    /* User32.dll */
-    pContext->win32.hUser32DLL = ma_dlopen(pContext, "user32.dll");
-    if (pContext->win32.hUser32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.GetForegroundWindow = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetForegroundWindow");
-    pContext->win32.GetDesktopWindow    = (ma_proc)ma_dlsym(pContext, pContext->win32.hUser32DLL, "GetDesktopWindow");
-
-
-    /* Advapi32.dll */
-    pContext->win32.hAdvapi32DLL = ma_dlopen(pContext, "advapi32.dll");
-    if (pContext->win32.hAdvapi32DLL == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->win32.RegOpenKeyExA    = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
-    pContext->win32.RegCloseKey      = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegCloseKey");
-    pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(pContext, pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
-#endif
-
-    ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE);
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_context_uninit_backend_apis__nix(ma_context* pContext)
-{
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
-    ma_dlclose(pContext, pContext->posix.pthreadSO);
-#else
-    (void)pContext;
-#endif
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_context_init_backend_apis__nix(ma_context* pContext)
-{
-    /* pthread */
-#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING)
-    const char* libpthreadFileNames[] = {
-        "libpthread.so",
-        "libpthread.so.0",
-        "libpthread.dylib"
-    };
-    size_t i;
-
-    for (i = 0; i < sizeof(libpthreadFileNames) / sizeof(libpthreadFileNames[0]); ++i) {
-        pContext->posix.pthreadSO = ma_dlopen(pContext, libpthreadFileNames[i]);
-        if (pContext->posix.pthreadSO != NULL) {
-            break;
-        }
-    }
-
-    if (pContext->posix.pthreadSO == NULL) {
-        return MA_FAILED_TO_INIT_BACKEND;
-    }
-
-    pContext->posix.pthread_create              = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_create");
-    pContext->posix.pthread_join                = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_join");
-    pContext->posix.pthread_mutex_init          = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_init");
-    pContext->posix.pthread_mutex_destroy       = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_destroy");
-    pContext->posix.pthread_mutex_lock          = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_lock");
-    pContext->posix.pthread_mutex_unlock        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_mutex_unlock");
-    pContext->posix.pthread_cond_init           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_init");
-    pContext->posix.pthread_cond_destroy        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_destroy");
-    pContext->posix.pthread_cond_wait           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_wait");
-    pContext->posix.pthread_cond_signal         = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_cond_signal");
-    pContext->posix.pthread_attr_init           = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_init");
-    pContext->posix.pthread_attr_destroy        = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_destroy");
-    pContext->posix.pthread_attr_setschedpolicy = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedpolicy");
-    pContext->posix.pthread_attr_getschedparam  = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_getschedparam");
-    pContext->posix.pthread_attr_setschedparam  = (ma_proc)ma_dlsym(pContext, pContext->posix.pthreadSO, "pthread_attr_setschedparam");
-#else
-    pContext->posix.pthread_create              = (ma_proc)pthread_create;
-    pContext->posix.pthread_join                = (ma_proc)pthread_join;
-    pContext->posix.pthread_mutex_init          = (ma_proc)pthread_mutex_init;
-    pContext->posix.pthread_mutex_destroy       = (ma_proc)pthread_mutex_destroy;
-    pContext->posix.pthread_mutex_lock          = (ma_proc)pthread_mutex_lock;
-    pContext->posix.pthread_mutex_unlock        = (ma_proc)pthread_mutex_unlock;
-    pContext->posix.pthread_cond_init           = (ma_proc)pthread_cond_init;
-    pContext->posix.pthread_cond_destroy        = (ma_proc)pthread_cond_destroy;
-    pContext->posix.pthread_cond_wait           = (ma_proc)pthread_cond_wait;
-    pContext->posix.pthread_cond_signal         = (ma_proc)pthread_cond_signal;
-    pContext->posix.pthread_attr_init           = (ma_proc)pthread_attr_init;
-    pContext->posix.pthread_attr_destroy        = (ma_proc)pthread_attr_destroy;
-#if !defined(__EMSCRIPTEN__)
-    pContext->posix.pthread_attr_setschedpolicy = (ma_proc)pthread_attr_setschedpolicy;
-    pContext->posix.pthread_attr_getschedparam  = (ma_proc)pthread_attr_getschedparam;
-    pContext->posix.pthread_attr_setschedparam  = (ma_proc)pthread_attr_setschedparam;
-#endif
-#endif
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_context_init_backend_apis(ma_context* pContext)
-{
-    ma_result result;
-#ifdef MA_WIN32
-    result = ma_context_init_backend_apis__win32(pContext);
-#else
-    result = ma_context_init_backend_apis__nix(pContext);
-#endif
-
-    return result;
-}
-
-static ma_result ma_context_uninit_backend_apis(ma_context* pContext)
-{
-    ma_result result;
-#ifdef MA_WIN32
-    result = ma_context_uninit_backend_apis__win32(pContext);
-#else
-    result = ma_context_uninit_backend_apis__nix(pContext);
-#endif
-
-    return result;
-}
-
-
-static ma_bool32 ma_context_is_backend_asynchronous(ma_context* pContext)
-{
-    MA_ASSERT(pContext != NULL);
-
-    if (pContext->callbacks.onDeviceRead == NULL && pContext->callbacks.onDeviceWrite == NULL) {
-        if (pContext->callbacks.onDeviceDataLoop == NULL) {
-            return MA_TRUE;
-        } else {
-            return MA_FALSE;
-        }
-    } else {
-        return MA_FALSE;
-    }
-}
-
-
-MA_API ma_context_config ma_context_config_init()
-{
-    ma_context_config config;
-    MA_ZERO_OBJECT(&config);
-
-    return config;
-}
-
-MA_API ma_result ma_context_init(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pConfig, ma_context* pContext)
-{
-    ma_result result;
-    ma_context_config defaultConfig;
-    ma_backend defaultBackends[ma_backend_null+1];
-    ma_uint32 iBackend;
-    ma_backend* pBackendsToIterate;
-    ma_uint32 backendsToIterateCount;
-
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pContext);
-
-    /* Always make sure the config is set first to ensure properties are available as soon as possible. */
-    if (pConfig == NULL) {
-        defaultConfig = ma_context_config_init();
-        pConfig = &defaultConfig;
-    }
-
-    pContext->logCallback     = pConfig->logCallback;
-    pContext->threadPriority  = pConfig->threadPriority;
-    pContext->threadStackSize = pConfig->threadStackSize;
-    pContext->pUserData       = pConfig->pUserData;
-
-    result = ma_allocation_callbacks_init_copy(&pContext->allocationCallbacks, &pConfig->allocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Backend APIs need to be initialized first. This is where external libraries will be loaded and linked. */
-    result = ma_context_init_backend_apis(pContext);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) {
-        defaultBackends[iBackend] = (ma_backend)iBackend;
-    }
-
-    pBackendsToIterate = (ma_backend*)backends;
-    backendsToIterateCount = backendCount;
-    if (pBackendsToIterate == NULL) {
-        pBackendsToIterate = (ma_backend*)defaultBackends;
-        backendsToIterateCount = ma_countof(defaultBackends);
-    }
-
-    MA_ASSERT(pBackendsToIterate != NULL);
-
-    for (iBackend = 0; iBackend < backendsToIterateCount; iBackend += 1) {
-        ma_backend backend = pBackendsToIterate[iBackend];
-
-        /* Make sure all callbacks are reset so we don't accidentally drag in any from previously failed initialization attempts. */
-        MA_ZERO_OBJECT(&pContext->callbacks);
-
-        /* These backends are using the new callback system. */
-        switch (backend) {
-        #ifdef MA_HAS_WASAPI
-            case ma_backend_wasapi:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__wasapi;
-            } break;
-        #endif
-        #ifdef MA_HAS_DSOUND
-            case ma_backend_dsound:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__dsound;
-            } break;
-        #endif
-        #ifdef MA_HAS_WINMM
-            case ma_backend_winmm:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__winmm;
-            } break;
-        #endif
-        #ifdef MA_HAS_COREAUDIO
-            case ma_backend_coreaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__coreaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_SNDIO
-            case ma_backend_sndio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__sndio;
-            } break;
-        #endif
-        #ifdef MA_HAS_AUDIO4
-            case ma_backend_audio4:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__audio4;
-            } break;
-        #endif
-        #ifdef MA_HAS_OSS
-            case ma_backend_oss:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__oss;
-            } break;
-        #endif
-        #ifdef MA_HAS_PULSEAUDIO
-            case ma_backend_pulseaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__pulse;
-            } break;
-        #endif
-        #ifdef MA_HAS_ALSA
-            case ma_backend_alsa:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__alsa;
-            } break;
-        #endif
-        #ifdef MA_HAS_JACK
-            case ma_backend_jack:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__jack;
-            } break;
-        #endif
-        #ifdef MA_HAS_AAUDIO
-            case ma_backend_aaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__aaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_OPENSL
-            case ma_backend_opensl:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__opensl;
-            } break;
-        #endif
-        #ifdef MA_HAS_WEBAUDIO
-            case ma_backend_webaudio:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__webaudio;
-            } break;
-        #endif
-        #ifdef MA_HAS_CUSTOM
-            case ma_backend_custom:
-            {
-                /* Slightly different logic for custom backends. Custom backends can optionally set all of their callbacks in the config. */
-                pContext->callbacks = pConfig->custom;
-            } break;
-        #endif
-        #ifdef MA_HAS_NULL
-            case ma_backend_null:
-            {
-                pContext->callbacks.onContextInit = ma_context_init__null;
-            } break;
-        #endif
-
-            default: break;
-        }
-
-        if (pContext->callbacks.onContextInit != NULL) {
-            ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_VERBOSE, "Attempting to initialize %s backend...", ma_get_backend_name(backend));
-            result = pContext->callbacks.onContextInit(pContext, pConfig, &pContext->callbacks);
-        } else {
-            result = MA_NO_BACKEND;
-        }
-
-        /* If this iteration was successful, return. */
-        if (result == MA_SUCCESS) {
-            result = ma_mutex_init(&pContext->deviceEnumLock);
-            if (result != MA_SUCCESS) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. ma_context_get_devices() is not thread safe.", result);
-            }
-
-            result = ma_mutex_init(&pContext->deviceInfoLock);
-            if (result != MA_SUCCESS) {
-                ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. ma_context_get_device_info() is not thread safe.", result);
-            }
-
-            #ifdef MA_DEBUG_OUTPUT
-            {
-                printf("[miniaudio] Endian:  %s\n", ma_is_little_endian() ? "LE" : "BE");
-                printf("[miniaudio] SSE2:    %s\n", ma_has_sse2()    ? "YES" : "NO");
-                printf("[miniaudio] AVX2:    %s\n", ma_has_avx2()    ? "YES" : "NO");
-                printf("[miniaudio] AVX512F: %s\n", ma_has_avx512f() ? "YES" : "NO");
-                printf("[miniaudio] NEON:    %s\n", ma_has_neon()    ? "YES" : "NO");
-            }
-            #endif
-
-            pContext->backend = backend;
-            return result;
-        } else {
-            ma_post_log_messagef(pContext, NULL, MA_LOG_LEVEL_VERBOSE, "Failed to initialize %s backend.", ma_get_backend_name(backend));
-        }
-    }
-
-    /* If we get here it means an error occurred. */
-    MA_ZERO_OBJECT(pContext);  /* Safety. */
-    return MA_NO_BACKEND;
-}
-
-MA_API ma_result ma_context_uninit(ma_context* pContext)
-{
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextUninit != NULL) {
-        pContext->callbacks.onContextUninit(pContext);
-    }
-
-    ma_mutex_uninit(&pContext->deviceEnumLock);
-    ma_mutex_uninit(&pContext->deviceInfoLock);
-    ma__free_from_callbacks(pContext->pDeviceInfos, &pContext->allocationCallbacks);
-    ma_context_uninit_backend_apis(pContext);
-
-    return MA_SUCCESS;
-}
-
-MA_API size_t ma_context_sizeof()
-{
-    return sizeof(ma_context);
-}
-
-
-MA_API ma_result ma_context_enumerate_devices(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData)
-{
-    ma_result result;
-
-    if (pContext == NULL || callback == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextEnumerateDevices == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    ma_mutex_lock(&pContext->deviceEnumLock);
-    {
-        result = pContext->callbacks.onContextEnumerateDevices(pContext, callback, pUserData);
-    }
-    ma_mutex_unlock(&pContext->deviceEnumLock);
-
-    return result;
-}
-
-
-static ma_bool32 ma_context_get_devices__enum_callback(ma_context* pContext, ma_device_type deviceType, const ma_device_info* pInfo, void* pUserData)
-{
-    /*
-    We need to insert the device info into our main internal buffer. Where it goes depends on the device type. If it's a capture device
-    it's just appended to the end. If it's a playback device it's inserted just before the first capture device.
-    */
-
-    /*
-    First make sure we have room. Since the number of devices we add to the list is usually relatively small I've decided to use a
-    simple fixed size increment for buffer expansion.
-    */
-    const ma_uint32 bufferExpansionCount = 2;
-    const ma_uint32 totalDeviceInfoCount = pContext->playbackDeviceInfoCount + pContext->captureDeviceInfoCount;
-
-    if (totalDeviceInfoCount >= pContext->deviceInfoCapacity) {
-        ma_uint32 oldCapacity = pContext->deviceInfoCapacity;
-        ma_uint32 newCapacity = oldCapacity + bufferExpansionCount;
-        ma_device_info* pNewInfos = (ma_device_info*)ma__realloc_from_callbacks(pContext->pDeviceInfos, sizeof(*pContext->pDeviceInfos)*newCapacity, sizeof(*pContext->pDeviceInfos)*oldCapacity, &pContext->allocationCallbacks);
-        if (pNewInfos == NULL) {
-            return MA_FALSE;   /* Out of memory. */
-        }
-
-        pContext->pDeviceInfos = pNewInfos;
-        pContext->deviceInfoCapacity = newCapacity;
-    }
-
-    if (deviceType == ma_device_type_playback) {
-        /* Playback. Insert just before the first capture device. */
-
-        /* The first thing to do is move all of the capture devices down a slot. */
-        ma_uint32 iFirstCaptureDevice = pContext->playbackDeviceInfoCount;
-        size_t iCaptureDevice;
-        for (iCaptureDevice = totalDeviceInfoCount; iCaptureDevice > iFirstCaptureDevice; --iCaptureDevice) {
-            pContext->pDeviceInfos[iCaptureDevice] = pContext->pDeviceInfos[iCaptureDevice-1];
-        }
-
-        /* Now just insert where the first capture device was before moving it down a slot. */
-        pContext->pDeviceInfos[iFirstCaptureDevice] = *pInfo;
-        pContext->playbackDeviceInfoCount += 1;
-    } else {
-        /* Capture. Insert at the end. */
-        pContext->pDeviceInfos[totalDeviceInfoCount] = *pInfo;
-        pContext->captureDeviceInfoCount += 1;
-    }
-
-    (void)pUserData;
-    return MA_TRUE;
-}
-
-MA_API ma_result ma_context_get_devices(ma_context* pContext, ma_device_info** ppPlaybackDeviceInfos, ma_uint32* pPlaybackDeviceCount, ma_device_info** ppCaptureDeviceInfos, ma_uint32* pCaptureDeviceCount)
-{
-    ma_result result;
-
-    /* Safety. */
-    if (ppPlaybackDeviceInfos != NULL) *ppPlaybackDeviceInfos = NULL;
-    if (pPlaybackDeviceCount  != NULL) *pPlaybackDeviceCount  = 0;
-    if (ppCaptureDeviceInfos  != NULL) *ppCaptureDeviceInfos  = NULL;
-    if (pCaptureDeviceCount   != NULL) *pCaptureDeviceCount   = 0;
-
-    if (pContext == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContext->callbacks.onContextEnumerateDevices == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* Note that we don't use ma_context_enumerate_devices() here because we want to do locking at a higher level. */
-    ma_mutex_lock(&pContext->deviceEnumLock);
-    {
-        /* Reset everything first. */
-        pContext->playbackDeviceInfoCount = 0;
-        pContext->captureDeviceInfoCount = 0;
-
-        /* Now enumerate over available devices. */
-        result = pContext->callbacks.onContextEnumerateDevices(pContext, ma_context_get_devices__enum_callback, NULL);
-        if (result == MA_SUCCESS) {
-            /* Playback devices. */
-            if (ppPlaybackDeviceInfos != NULL) {
-                *ppPlaybackDeviceInfos = pContext->pDeviceInfos;
-            }
-            if (pPlaybackDeviceCount != NULL) {
-                *pPlaybackDeviceCount = pContext->playbackDeviceInfoCount;
-            }
-
-            /* Capture devices. */
-            if (ppCaptureDeviceInfos != NULL) {
-                *ppCaptureDeviceInfos = pContext->pDeviceInfos + pContext->playbackDeviceInfoCount; /* Capture devices come after playback devices. */
-            }
-            if (pCaptureDeviceCount != NULL) {
-                *pCaptureDeviceCount = pContext->captureDeviceInfoCount;
-            }
-        }
-    }
-    ma_mutex_unlock(&pContext->deviceEnumLock);
-
-    return result;
-}
-
-MA_API ma_result ma_context_get_device_info(ma_context* pContext, ma_device_type deviceType, const ma_device_id* pDeviceID, ma_share_mode shareMode, ma_device_info* pDeviceInfo)
-{
-    ma_result result;
-    ma_device_info deviceInfo;
-
-    (void)shareMode;    /* Unused. This parameter will be removed in version 0.11. */
-
-    /* NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. */
-    if (pContext == NULL || pDeviceInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(&deviceInfo);
-
-    /* Help the backend out by copying over the device ID if we have one. */
-    if (pDeviceID != NULL) {
-        MA_COPY_MEMORY(&deviceInfo.id, pDeviceID, sizeof(*pDeviceID));
-    }
-
-    if (pContext->callbacks.onContextGetDeviceInfo == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-    ma_mutex_lock(&pContext->deviceInfoLock);
-    {
-        result = pContext->callbacks.onContextGetDeviceInfo(pContext, deviceType, pDeviceID, &deviceInfo);
-    }
-    ma_mutex_unlock(&pContext->deviceInfoLock);
-
-    /*
-    If the backend is using the new device info system, do a pass to fill out the old settings for backwards compatibility. This will be removed in
-    the future when all backends have implemented the new device info system.
-    */
-    if (deviceInfo.nativeDataFormatCount > 0) {
-        ma_uint32 iNativeFormat;
-        ma_uint32 iSampleFormat;
-
-        deviceInfo.minChannels   = 0xFFFFFFFF;
-        deviceInfo.maxChannels   = 0;
-        deviceInfo.minSampleRate = 0xFFFFFFFF;
-        deviceInfo.maxSampleRate = 0;
-
-        for (iNativeFormat = 0; iNativeFormat < deviceInfo.nativeDataFormatCount; iNativeFormat += 1) {
-            /* Formats. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].format == ma_format_unknown) {
-                /* All formats are supported. */
-                deviceInfo.formats[0] = ma_format_u8;
-                deviceInfo.formats[1] = ma_format_s16;
-                deviceInfo.formats[2] = ma_format_s24;
-                deviceInfo.formats[3] = ma_format_s32;
-                deviceInfo.formats[4] = ma_format_f32;
-                deviceInfo.formatCount = 5;
-            } else {
-                /* Make sure the format isn't already in the list. If so, skip. */
-                ma_bool32 alreadyExists = MA_FALSE;
-                for (iSampleFormat = 0; iSampleFormat < deviceInfo.formatCount; iSampleFormat += 1) {
-                    if (deviceInfo.formats[iSampleFormat] == deviceInfo.nativeDataFormats[iNativeFormat].format) {
-                        alreadyExists = MA_TRUE;
-                        break;
-                    }
-                }
-
-                if (!alreadyExists) {
-                    deviceInfo.formats[deviceInfo.formatCount++] = deviceInfo.nativeDataFormats[iNativeFormat].format;
-                }
-            }
-
-            /* Channels. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].channels == 0) {
-                /* All channels supported. */
-                deviceInfo.minChannels = MA_MIN_CHANNELS;
-                deviceInfo.maxChannels = MA_MAX_CHANNELS;
-            } else {
-                if (deviceInfo.minChannels > deviceInfo.nativeDataFormats[iNativeFormat].channels) {
-                    deviceInfo.minChannels = deviceInfo.nativeDataFormats[iNativeFormat].channels;
-                }
-                if (deviceInfo.maxChannels < deviceInfo.nativeDataFormats[iNativeFormat].channels) {
-                    deviceInfo.maxChannels = deviceInfo.nativeDataFormats[iNativeFormat].channels;
-                }
-            }
-
-            /* Sample rate. */
-            if (deviceInfo.nativeDataFormats[iNativeFormat].sampleRate == 0) {
-                /* All sample rates supported. */
-                deviceInfo.minSampleRate = (ma_uint32)ma_standard_sample_rate_min;
-                deviceInfo.maxSampleRate = (ma_uint32)ma_standard_sample_rate_max;
-            } else {
-                if (deviceInfo.minSampleRate > deviceInfo.nativeDataFormats[iNativeFormat].sampleRate) {
-                    deviceInfo.minSampleRate = deviceInfo.nativeDataFormats[iNativeFormat].sampleRate;
-                }
-                if (deviceInfo.maxSampleRate < deviceInfo.nativeDataFormats[iNativeFormat].sampleRate) {
-                    deviceInfo.maxSampleRate = deviceInfo.nativeDataFormats[iNativeFormat].sampleRate;
-                }
-            }
-        }
-    }
-
-
-    /* Clamp ranges. */
-    deviceInfo.minChannels   = ma_max(deviceInfo.minChannels,   MA_MIN_CHANNELS);
-    deviceInfo.maxChannels   = ma_min(deviceInfo.maxChannels,   MA_MAX_CHANNELS);
-    deviceInfo.minSampleRate = ma_max(deviceInfo.minSampleRate, (ma_uint32)ma_standard_sample_rate_min);
-    deviceInfo.maxSampleRate = ma_min(deviceInfo.maxSampleRate, (ma_uint32)ma_standard_sample_rate_max);
-
-    *pDeviceInfo = deviceInfo;
-    return result;
-}
-
-MA_API ma_bool32 ma_context_is_loopback_supported(ma_context* pContext)
-{
-    if (pContext == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_is_loopback_supported(pContext->backend);
-}
-
-
-MA_API ma_device_config ma_device_config_init(ma_device_type deviceType)
-{
-    ma_device_config config;
-    MA_ZERO_OBJECT(&config);
-    config.deviceType = deviceType;
-
-    /* Resampling defaults. We must never use the Speex backend by default because it uses licensed third party code. */
-    config.resampling.algorithm       = ma_resample_algorithm_linear;
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.resampling.speex.quality   = 3;
-
-    return config;
-}
-
-MA_API ma_result ma_device_init(ma_context* pContext, const ma_device_config* pConfig, ma_device* pDevice)
-{
-    ma_result result;
-    ma_device_descriptor descriptorPlayback;
-    ma_device_descriptor descriptorCapture;
-
-    /* The context can be null, in which case we self-manage it. */
-    if (pContext == NULL) {
-        return ma_device_init_ex(NULL, 0, NULL, pConfig, pDevice);
-    }
-
-    if (pDevice == NULL) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    MA_ZERO_OBJECT(pDevice);
-
-    if (pConfig == NULL) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid arguments (pConfig == NULL).", MA_INVALID_ARGS);
-    }
-
-
-    /* Check that we have our callbacks defined. */
-    if (pContext->callbacks.onDeviceInit == NULL) {
-        return MA_INVALID_OPERATION;
-    }
-
-
-    /* Basic config validation. */
-    if (pConfig->deviceType != ma_device_type_playback && pConfig->deviceType != ma_device_type_capture && pConfig->deviceType != ma_device_type_duplex && pConfig->deviceType != ma_device_type_loopback) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Device type is invalid. Make sure the device type has been set in the config.", MA_INVALID_DEVICE_CONFIG);
-    }
-
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
-        if (pConfig->capture.channels > MA_MAX_CHANNELS) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Capture channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
-        }
-        if (!ma__is_channel_map_valid(pConfig->capture.channelMap, pConfig->capture.channels)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Capture channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        if (pConfig->playback.channels > MA_MAX_CHANNELS) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with an invalid config. Playback channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG);
-        }
-        if (!ma__is_channel_map_valid(pConfig->playback.channelMap, pConfig->playback.channels)) {
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "ma_device_init() called with invalid config. Playback channel map is invalid.", MA_INVALID_DEVICE_CONFIG);
-        }
-    }
-
-    pDevice->pContext = pContext;
-
-    /* Set the user data and log callback ASAP to ensure it is available for the entire initialization process. */
-    pDevice->pUserData = pConfig->pUserData;
-    pDevice->onData    = pConfig->dataCallback;
-    pDevice->onStop    = pConfig->stopCallback;
-
-    if (((ma_uintptr)pDevice % sizeof(pDevice)) != 0) {
-        if (pContext->logCallback) {
-            pContext->logCallback(pContext, pDevice, MA_LOG_LEVEL_WARNING, "WARNING: ma_device_init() called for a device that is not properly aligned. Thread safety is not supported.");
-        }
-    }
-
-    if (pConfig->playback.pDeviceID != NULL) {
-        MA_COPY_MEMORY(&pDevice->playback.id, pConfig->playback.pDeviceID, sizeof(pDevice->playback.id));
-    }
-
-    if (pConfig->capture.pDeviceID != NULL) {
-        MA_COPY_MEMORY(&pDevice->capture.id, pConfig->capture.pDeviceID, sizeof(pDevice->capture.id));
-    }
-
-    pDevice->noPreZeroedOutputBuffer = pConfig->noPreZeroedOutputBuffer;
-    pDevice->noClip = pConfig->noClip;
-    pDevice->masterVolumeFactor = 1;
-
-    pDevice->type                       = pConfig->deviceType;
-    pDevice->sampleRate                 = pConfig->sampleRate;
-    pDevice->resampling.algorithm       = pConfig->resampling.algorithm;
-    pDevice->resampling.linear.lpfOrder = pConfig->resampling.linear.lpfOrder;
-    pDevice->resampling.speex.quality   = pConfig->resampling.speex.quality;
-
-    pDevice->capture.shareMode          = pConfig->capture.shareMode;
-    pDevice->capture.format             = pConfig->capture.format;
-    pDevice->capture.channels           = pConfig->capture.channels;
-    ma_channel_map_copy(pDevice->capture.channelMap, pConfig->capture.channelMap, pConfig->capture.channels);
-    pDevice->capture.channelMixMode     = pConfig->capture.channelMixMode;
-    
-    pDevice->playback.shareMode         = pConfig->playback.shareMode;
-    pDevice->playback.format            = pConfig->playback.format;
-    pDevice->playback.channels          = pConfig->playback.channels;
-    ma_channel_map_copy(pDevice->playback.channelMap, pConfig->playback.channelMap, pConfig->playback.channels);
-    pDevice->playback.channelMixMode    = pConfig->playback.channelMixMode;
-    
-
-    result = ma_mutex_init(&pDevice->startStopLock);
-    if (result != MA_SUCCESS) {
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create mutex.", result);
-    }
-
-    /*
-    When the device is started, the worker thread is the one that does the actual startup of the backend device. We
-    use a semaphore to wait for the background thread to finish the work. The same applies for stopping the device.
-
-    Each of these semaphores is released internally by the worker thread when the work is completed. The start
-    semaphore is also used to wake up the worker thread.
-    */
-    result = ma_event_init(&pDevice->wakeupEvent);
-    if (result != MA_SUCCESS) {
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread wakeup event.", result);
-    }
-
-    result = ma_event_init(&pDevice->startEvent);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread start event.", result);
-    }
-
-    result = ma_event_init(&pDevice->stopEvent);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->startEvent);
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread stop event.", result);
-    }
-
-
-    MA_ZERO_OBJECT(&descriptorPlayback);
-    descriptorPlayback.pDeviceID                = pConfig->playback.pDeviceID;
-    descriptorPlayback.shareMode                = pConfig->playback.shareMode;
-    descriptorPlayback.format                   = pConfig->playback.format;
-    descriptorPlayback.channels                 = pConfig->playback.channels;
-    descriptorPlayback.sampleRate               = pConfig->sampleRate;
-    ma_channel_map_copy(descriptorPlayback.channelMap, pConfig->playback.channelMap, pConfig->playback.channels);
-    descriptorPlayback.periodSizeInFrames       = pConfig->periodSizeInFrames;
-    descriptorPlayback.periodSizeInMilliseconds = pConfig->periodSizeInMilliseconds;
-    descriptorPlayback.periodCount              = pConfig->periods;
-
-    if (descriptorPlayback.periodCount == 0) {
-        descriptorPlayback.periodCount = MA_DEFAULT_PERIODS;
-    }
-
-
-    MA_ZERO_OBJECT(&descriptorCapture);
-    descriptorCapture.pDeviceID                 = pConfig->capture.pDeviceID;
-    descriptorCapture.shareMode                 = pConfig->capture.shareMode;
-    descriptorCapture.format                    = pConfig->capture.format;
-    descriptorCapture.channels                  = pConfig->capture.channels;
-    descriptorCapture.sampleRate                = pConfig->sampleRate;
-    ma_channel_map_copy(descriptorCapture.channelMap, pConfig->capture.channelMap, pConfig->capture.channels);
-    descriptorCapture.periodSizeInFrames        = pConfig->periodSizeInFrames;
-    descriptorCapture.periodSizeInMilliseconds  = pConfig->periodSizeInMilliseconds;
-    descriptorCapture.periodCount               = pConfig->periods;
-
-    if (descriptorCapture.periodCount == 0) {
-        descriptorCapture.periodCount = MA_DEFAULT_PERIODS;
-    }
-
-
-    result = pContext->callbacks.onDeviceInit(pDevice, pConfig, &descriptorPlayback, &descriptorCapture);
-    if (result != MA_SUCCESS) {
-        ma_event_uninit(&pDevice->startEvent);
-        ma_event_uninit(&pDevice->wakeupEvent);
-        ma_mutex_uninit(&pDevice->startStopLock);
-        return result;
-    }
-
-
-    /*
-    On output the descriptors will contain the *actual* data format of the device. We need this to know how to convert the data between
-    the requested format and the internal format.
-    */
-    if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-        if (!ma_device_descriptor_is_valid(&descriptorCapture)) {
-            ma_device_uninit(pDevice);
-            return MA_INVALID_ARGS;
-        }
-
-        pDevice->capture.internalFormat             = descriptorCapture.format;
-        pDevice->capture.internalChannels           = descriptorCapture.channels;
-        pDevice->capture.internalSampleRate         = descriptorCapture.sampleRate;
-        ma_channel_map_copy(pDevice->capture.internalChannelMap, descriptorCapture.channelMap, descriptorCapture.channels);
-        pDevice->capture.internalPeriodSizeInFrames = descriptorCapture.periodSizeInFrames;
-        pDevice->capture.internalPeriods            = descriptorCapture.periodCount;
-
-        if (pDevice->capture.internalPeriodSizeInFrames == 0) {
-            pDevice->capture.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorCapture.periodSizeInMilliseconds, descriptorCapture.sampleRate);
-        }
-    }
-
-    if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-        if (!ma_device_descriptor_is_valid(&descriptorPlayback)) {
-            ma_device_uninit(pDevice);
-            return MA_INVALID_ARGS;
-        }
-
-        pDevice->playback.internalFormat             = descriptorPlayback.format;
-        pDevice->playback.internalChannels           = descriptorPlayback.channels;
-        pDevice->playback.internalSampleRate         = descriptorPlayback.sampleRate;
-        ma_channel_map_copy(pDevice->playback.internalChannelMap, descriptorPlayback.channelMap, descriptorPlayback.channels);
-        pDevice->playback.internalPeriodSizeInFrames = descriptorPlayback.periodSizeInFrames;
-        pDevice->playback.internalPeriods            = descriptorPlayback.periodCount;
-
-        if (pDevice->playback.internalPeriodSizeInFrames == 0) {
-            pDevice->playback.internalPeriodSizeInFrames = ma_calculate_buffer_size_in_frames_from_milliseconds(descriptorPlayback.periodSizeInMilliseconds, descriptorPlayback.sampleRate);
-        }
-    }
-
-
-    /*
-    The name of the device can be retrieved from device info. This may be temporary and replaced with a `ma_device_get_info(pDevice, deviceType)` instead.
-    For loopback devices, we need to retrieve the name of the playback device.
-    */
-    {
-        ma_device_info deviceInfo;
-
-        if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex || pConfig->deviceType == ma_device_type_loopback) {
-            result = ma_context_get_device_info(pContext, (pConfig->deviceType == ma_device_type_loopback) ? ma_device_type_playback : ma_device_type_capture, descriptorCapture.pDeviceID, descriptorCapture.shareMode, &deviceInfo);
-            if (result == MA_SUCCESS) {
-                ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), deviceInfo.name, (size_t)-1);
-            } else {
-                /* We failed to retrieve the device info. Fall back to a default name. */
-                if (descriptorCapture.pDeviceID == NULL) {
-                    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1);
-                } else {
-                    ma_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), "Capture Device", (size_t)-1);
-                }
-            }
-        }
-
-        if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
-            result = ma_context_get_device_info(pContext, ma_device_type_playback, descriptorPlayback.pDeviceID, descriptorPlayback.shareMode, &deviceInfo);
-            if (result == MA_SUCCESS) {
-                ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), deviceInfo.name, (size_t)-1);
-            } else {
-                /* We failed to retrieve the device info. Fall back to a default name. */
-                if (descriptorPlayback.pDeviceID == NULL) {
-                    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1);
-                } else {
-                    ma_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), "Playback Device", (size_t)-1);
-                }
-            }
-        }
-    }
-
-
-    ma_device__post_init_setup(pDevice, pConfig->deviceType);
-
-
-    /* Some backends don't require the worker thread. */
-    if (!ma_context_is_backend_asynchronous(pContext)) {
-        /* The worker thread. */
-        result = ma_thread_create(&pDevice->thread, pContext->threadPriority, pContext->threadStackSize, ma_worker_thread, pDevice);
-        if (result != MA_SUCCESS) {
-            ma_device_uninit(pDevice);
-            return ma_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "Failed to create worker thread.", result);
-        }
-
-        /* Wait for the worker thread to put the device into it's stopped state for real. */
-        ma_event_wait(&pDevice->stopEvent);
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-    } else {
-        /*
-        If the backend is asynchronous and the device is duplex, we'll need an intermediary ring buffer. Note that this needs to be done
-        after ma_device__post_init_setup().
-        */
-        if (ma_context_is_backend_asynchronous(pContext)) {
-            if (pConfig->deviceType == ma_device_type_duplex) {
-                result = ma_duplex_rb_init(pDevice->capture.format, pDevice->capture.channels, pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalPeriodSizeInFrames, &pDevice->pContext->allocationCallbacks, &pDevice->duplexRB);
-                if (result != MA_SUCCESS) {
-                    ma_device_uninit(pDevice);
-                    return result;
-                }
-            }
-        }
-
-        ma_device__set_state(pDevice, MA_STATE_STOPPED);
-    }
-
-
-    ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "[%s]", ma_get_backend_name(pDevice->pContext->backend));
-    if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "  %s (%s)", pDevice->capture.name, "Capture");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Format:      %s -> %s", ma_get_format_name(pDevice->capture.internalFormat), ma_get_format_name(pDevice->capture.format));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Channels:    %d -> %d", pDevice->capture.internalChannels, pDevice->capture.channels);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Sample Rate: %d -> %d", pDevice->capture.internalSampleRate, pDevice->sampleRate);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Buffer Size: %d*%d (%d)", pDevice->capture.internalPeriodSizeInFrames, pDevice->capture.internalPeriods, (pDevice->capture.internalPeriodSizeInFrames * pDevice->capture.internalPeriods));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Conversion:");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Pre Format Conversion:    %s", pDevice->capture.converter.hasPreFormatConversion  ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Post Format Conversion:   %s", pDevice->capture.converter.hasPostFormatConversion ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Channel Routing:          %s", pDevice->capture.converter.hasChannelConverter     ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Resampling:               %s", pDevice->capture.converter.hasResampler            ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Passthrough:              %s", pDevice->capture.converter.isPassthrough           ? "YES" : "NO");
-    }
-    if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "  %s (%s)", pDevice->playback.name, "Playback");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Format:      %s -> %s", ma_get_format_name(pDevice->playback.format), ma_get_format_name(pDevice->playback.internalFormat));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Channels:    %d -> %d", pDevice->playback.channels, pDevice->playback.internalChannels);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Sample Rate: %d -> %d", pDevice->sampleRate, pDevice->playback.internalSampleRate);
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Buffer Size: %d*%d (%d)", pDevice->playback.internalPeriodSizeInFrames, pDevice->playback.internalPeriods, (pDevice->playback.internalPeriodSizeInFrames * pDevice->playback.internalPeriods));
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "    Conversion:");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Pre Format Conversion:    %s", pDevice->playback.converter.hasPreFormatConversion  ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Post Format Conversion:   %s", pDevice->playback.converter.hasPostFormatConversion ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Channel Routing:          %s", pDevice->playback.converter.hasChannelConverter     ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Resampling:               %s", pDevice->playback.converter.hasResampler            ? "YES" : "NO");
-        ma_post_log_messagef(pContext, pDevice, MA_LOG_LEVEL_INFO, "      Passthrough:              %s", pDevice->playback.converter.isPassthrough           ? "YES" : "NO");
-    }
-
-    MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_init_ex(const ma_backend backends[], ma_uint32 backendCount, const ma_context_config* pContextConfig, const ma_device_config* pConfig, ma_device* pDevice)
-{
-    ma_result result;
-    ma_context* pContext;
-    ma_backend defaultBackends[ma_backend_null+1];
-    ma_uint32 iBackend;
-    ma_backend* pBackendsToIterate;
-    ma_uint32 backendsToIterateCount;
-    ma_allocation_callbacks allocationCallbacks;
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pContextConfig != NULL) {
-        result = ma_allocation_callbacks_init_copy(&allocationCallbacks, &pContextConfig->allocationCallbacks);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    } else {
-        allocationCallbacks = ma_allocation_callbacks_init_default();
-    }
-
-
-    pContext = (ma_context*)ma__malloc_from_callbacks(sizeof(*pContext), &allocationCallbacks);
-    if (pContext == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    for (iBackend = 0; iBackend <= ma_backend_null; ++iBackend) {
-        defaultBackends[iBackend] = (ma_backend)iBackend;
-    }
-
-    pBackendsToIterate = (ma_backend*)backends;
-    backendsToIterateCount = backendCount;
-    if (pBackendsToIterate == NULL) {
-        pBackendsToIterate = (ma_backend*)defaultBackends;
-        backendsToIterateCount = ma_countof(defaultBackends);
-    }
-
-    result = MA_NO_BACKEND;
-
-    for (iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) {
-        result = ma_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext);
-        if (result == MA_SUCCESS) {
-            result = ma_device_init(pContext, pConfig, pDevice);
-            if (result == MA_SUCCESS) {
-                break;  /* Success. */
-            } else {
-                ma_context_uninit(pContext);   /* Failure. */
-            }
-        }
-    }
-
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pContext, &allocationCallbacks);
-        return result;
-    }
-
-    pDevice->isOwnerOfContext = MA_TRUE;
-    return result;
-}
-
-MA_API void ma_device_uninit(ma_device* pDevice)
-{
-    if (!ma_device__is_initialized(pDevice)) {
-        return;
-    }
-
-    /* Make sure the device is stopped first. The backends will probably handle this naturally, but I like to do it explicitly for my own sanity. */
-    if (ma_device_is_started(pDevice)) {
-        ma_device_stop(pDevice);
-    }
-
-    /* Putting the device into an uninitialized state will make the worker thread return. */
-    ma_device__set_state(pDevice, MA_STATE_UNINITIALIZED);
-
-    /* Wake up the worker thread and wait for it to properly terminate. */
-    if (!ma_context_is_backend_asynchronous(pDevice->pContext)) {
-        ma_event_signal(&pDevice->wakeupEvent);
-        ma_thread_wait(&pDevice->thread);
-    }
-
-    if (pDevice->pContext->callbacks.onDeviceUninit != NULL) {
-        pDevice->pContext->callbacks.onDeviceUninit(pDevice);
-    }
-
-
-    ma_event_uninit(&pDevice->stopEvent);
-    ma_event_uninit(&pDevice->startEvent);
-    ma_event_uninit(&pDevice->wakeupEvent);
-    ma_mutex_uninit(&pDevice->startStopLock);
-
-    if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-        if (pDevice->type == ma_device_type_duplex) {
-            ma_duplex_rb_uninit(&pDevice->duplexRB);
-        }
-    }
-
-    if (pDevice->isOwnerOfContext) {
-        ma_allocation_callbacks allocationCallbacks = pDevice->pContext->allocationCallbacks;
-
-        ma_context_uninit(pDevice->pContext);
-        ma__free_from_callbacks(pDevice->pContext, &allocationCallbacks);
-    }
-
-    MA_ZERO_OBJECT(pDevice);
-}
-
-MA_API ma_result ma_device_start(ma_device* pDevice)
-{
-    ma_result result;
-
-    if (pDevice == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_start() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_start() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_STARTED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_WARNING, "ma_device_start() called when the device is already started.", MA_INVALID_OPERATION);  /* Already started. Returning an error to let the application know because it probably means they're doing something wrong. */
-    }
-
-    ma_mutex_lock(&pDevice->startStopLock);
-    {
-        /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a stopped or paused state. */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STOPPED);
-
-        ma_device__set_state(pDevice, MA_STATE_STARTING);
-
-        /* Asynchronous backends need to be handled differently. */
-        if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-            if (pDevice->pContext->callbacks.onDeviceStart != NULL) {
-                result = pDevice->pContext->callbacks.onDeviceStart(pDevice);
-            } else {
-                result = MA_INVALID_OPERATION;
-            }
-
-            if (result == MA_SUCCESS) {
-                ma_device__set_state(pDevice, MA_STATE_STARTED);
-            }
-        } else {
-            /*
-            Synchronous backends are started by signaling an event that's being waited on in the worker thread. We first wake up the
-            thread and then wait for the start event.
-            */
-            ma_event_signal(&pDevice->wakeupEvent);
-
-            /*
-            Wait for the worker thread to finish starting the device. Note that the worker thread will be the one who puts the device
-            into the started state. Don't call ma_device__set_state() here.
-            */
-            ma_event_wait(&pDevice->startEvent);
-            result = pDevice->workResult;
-        }
-
-        /* We changed the state from stopped to started, so if we failed, make sure we put the state back to stopped. */
-        if (result != MA_SUCCESS) {
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-        }
-    }
-    ma_mutex_unlock(&pDevice->startStopLock);
-
-    return result;
-}
-
-MA_API ma_result ma_device_stop(ma_device* pDevice)
-{
-    ma_result result;
-
-    if (pDevice == NULL) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_stop() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_UNINITIALIZED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_ERROR, "ma_device_stop() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED);
-    }
-
-    if (ma_device_get_state(pDevice) == MA_STATE_STOPPED) {
-        return ma_post_error(pDevice, MA_LOG_LEVEL_WARNING, "ma_device_stop() called when the device is already stopped.", MA_INVALID_OPERATION);   /* Already stopped. Returning an error to let the application know because it probably means they're doing something wrong. */
-    }
-
-    ma_mutex_lock(&pDevice->startStopLock);
-    {
-        /* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */
-        MA_ASSERT(ma_device_get_state(pDevice) == MA_STATE_STARTED);
-
-        ma_device__set_state(pDevice, MA_STATE_STOPPING);
-
-        /* Asynchronous backends need to be handled differently. */
-        if (ma_context_is_backend_asynchronous(pDevice->pContext)) {
-            /* Asynchronous backends must have a stop operation. */
-            if (pDevice->pContext->callbacks.onDeviceStop != NULL) {
-                result = pDevice->pContext->callbacks.onDeviceStop(pDevice);
-            } else {
-                result = MA_INVALID_OPERATION;
-            }
-
-            ma_device__set_state(pDevice, MA_STATE_STOPPED);
-        } else {
-            /*
-            Synchronous backends. The stop callback is always called from the worker thread. Do not call the stop callback here. If
-            the backend is implementing it's own audio thread loop we'll need to wake it up if required. Note that we need to make
-            sure the state of the device is *not* playing right now, which it shouldn't be since we set it above. This is super
-            important though, so I'm asserting it here as well for extra safety in case we accidentally change something later.
-            */
-            MA_ASSERT(ma_device_get_state(pDevice) != MA_STATE_STARTED);
-
-            if (pDevice->pContext->callbacks.onDeviceDataLoopWakeup != NULL) {
-                pDevice->pContext->callbacks.onDeviceDataLoopWakeup(pDevice);
-            }
-
-            /*
-            We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be
-            the one who puts the device into the stopped state. Don't call ma_device__set_state() here.
-            */
-            ma_event_wait(&pDevice->stopEvent);
-            result = MA_SUCCESS;
-        }
-    }
-    ma_mutex_unlock(&pDevice->startStopLock);
-
-    return result;
-}
-
-MA_API ma_bool32 ma_device_is_started(const ma_device* pDevice)
-{
-    return ma_device_get_state(pDevice) == MA_STATE_STARTED;
-}
-
-MA_API ma_uint32 ma_device_get_state(const ma_device* pDevice)
-{
-    if (pDevice == NULL) {
-        return MA_STATE_UNINITIALIZED;
-    }
-
-    return c89atomic_load_32((ma_uint32*)&pDevice->state);  /* Naughty cast to get rid of a const warning. */
-}
-
-MA_API ma_result ma_device_set_master_volume(ma_device* pDevice, float volume)
-{
-    if (pDevice == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (volume < 0.0f || volume > 1.0f) {
-        return MA_INVALID_ARGS;
-    }
-
-    c89atomic_exchange_f32(&pDevice->masterVolumeFactor, volume);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_get_master_volume(ma_device* pDevice, float* pVolume)
-{
-    if (pVolume == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDevice == NULL) {
-        *pVolume = 0;
-        return MA_INVALID_ARGS;
-    }
-
-    *pVolume = c89atomic_load_f32(&pDevice->masterVolumeFactor);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_device_set_master_gain_db(ma_device* pDevice, float gainDB)
-{
-    if (gainDB > 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_device_set_master_volume(pDevice, ma_gain_db_to_factor(gainDB));
-}
-
-MA_API ma_result ma_device_get_master_gain_db(ma_device* pDevice, float* pGainDB)
-{
-    float factor;
-    ma_result result;
-
-    if (pGainDB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_device_get_master_volume(pDevice, &factor);
-    if (result != MA_SUCCESS) {
-        *pGainDB = 0;
-        return result;
-    }
-
-    *pGainDB = ma_factor_to_gain_db(factor);
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_device_handle_backend_data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount)
-{
-    if (pDevice == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pOutput == NULL && pInput == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDevice->type == ma_device_type_duplex) {
-        if (pInput != NULL) {
-            ma_device__handle_duplex_callback_capture(pDevice, frameCount, pInput, &pDevice->duplexRB.rb);
-        }
-
-        if (pOutput != NULL) {
-            ma_device__handle_duplex_callback_playback(pDevice, frameCount, pOutput, &pDevice->duplexRB.rb);
-        }
-    } else {
-        if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_loopback) {
-            if (pInput == NULL) {
-                return MA_INVALID_ARGS;
-            }
-
-            ma_device__send_frames_to_client(pDevice, frameCount, pInput);
-        }
-
-        if (pDevice->type == ma_device_type_playback) {
-            if (pOutput == NULL) {
-                return MA_INVALID_ARGS;
-            }
-
-            ma_device__read_frames_from_client(pDevice, frameCount, pOutput);
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_descriptor(const ma_device_descriptor* pDescriptor, ma_uint32 nativeSampleRate, ma_performance_profile performanceProfile)
-{
-    if (pDescriptor == NULL) {
-        return 0;
-    }
-
-    /*
-    We must have a non-0 native sample rate, but some backends don't allow retrieval of this at the
-    time when the size of the buffer needs to be determined. In this case we need to just take a best
-    guess and move on. We'll try using the sample rate in pDescriptor first. If that's not set we'll
-    just fall back to MA_DEFAULT_SAMPLE_RATE.
-    */
-    if (nativeSampleRate == 0) {
-        nativeSampleRate = pDescriptor->sampleRate;
-    }
-    if (nativeSampleRate == 0) {
-        nativeSampleRate = MA_DEFAULT_SAMPLE_RATE;
-    }
-
-    MA_ASSERT(nativeSampleRate != 0);
-
-    if (pDescriptor->periodSizeInFrames == 0) {
-        if (pDescriptor->periodSizeInMilliseconds == 0) {
-            if (performanceProfile == ma_performance_profile_low_latency) {
-                return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_LOW_LATENCY, nativeSampleRate);
-            } else {
-                return ma_calculate_buffer_size_in_frames_from_milliseconds(MA_DEFAULT_PERIOD_SIZE_IN_MILLISECONDS_CONSERVATIVE, nativeSampleRate);
-            }
-        } else {
-            return ma_calculate_buffer_size_in_frames_from_milliseconds(pDescriptor->periodSizeInMilliseconds, nativeSampleRate);
-        }
-    } else {
-        return pDescriptor->periodSizeInFrames;
-    }
-}
-#endif  /* MA_NO_DEVICE_IO */
-
-
-MA_API ma_uint32 ma_scale_buffer_size(ma_uint32 baseBufferSize, float scale)
-{
-    return ma_max(1, (ma_uint32)(baseBufferSize*scale));
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_milliseconds_from_frames(ma_uint32 bufferSizeInFrames, ma_uint32 sampleRate)
-{
-    /* Prevent a division by zero. */
-    if (sampleRate == 0) {
-        return 0;
-    }
-
-    return bufferSizeInFrames*1000 / sampleRate;
-}
-
-MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 bufferSizeInMilliseconds, ma_uint32 sampleRate)
-{
-    /* Prevent a division by zero. */
-    if (sampleRate == 0) {
-        return 0;
-    }
-
-    return bufferSizeInMilliseconds*sampleRate / 1000;
-}
-
-MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels)
-{
-    if (dst == src) {
-        return; /* No-op. */
-    }
-
-    ma_copy_memory_64(dst, src, frameCount * ma_get_bytes_per_frame(format, channels));
-}
-
-MA_API void ma_silence_pcm_frames(void* p, ma_uint64 frameCount, ma_format format, ma_uint32 channels)
-{
-    if (format == ma_format_u8) {
-        ma_uint64 sampleCount = frameCount * channels;
-        ma_uint64 iSample;
-        for (iSample = 0; iSample < sampleCount; iSample += 1) {
-            ((ma_uint8*)p)[iSample] = 128;
-        }
-    } else {
-        ma_zero_memory_64(p, frameCount * ma_get_bytes_per_frame(format, channels));
-    }
-}
-
-MA_API void* ma_offset_pcm_frames_ptr(void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels)
-{
-    return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels));
-}
-
-MA_API const void* ma_offset_pcm_frames_const_ptr(const void* p, ma_uint64 offsetInFrames, ma_format format, ma_uint32 channels)
-{
-    return ma_offset_ptr(p, offsetInFrames * ma_get_bytes_per_frame(format, channels));
-}
-
-
-MA_API void ma_clip_samples_f32(float* p, ma_uint64 sampleCount)
-{
-    ma_uint32 iSample;
-
-    /* TODO: Research a branchless SSE implementation. */
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        p[iSample] = ma_clip_f32(p[iSample]);
-    }
-}
-
-
-MA_API void ma_copy_and_apply_volume_factor_u8(ma_uint8* pSamplesOut, const ma_uint8* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_uint8)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s16(ma_int16* pSamplesOut, const ma_int16* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_int16)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s24(void* pSamplesOut, const void* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-    ma_uint8* pSamplesOut8;
-    ma_uint8* pSamplesIn8;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    pSamplesOut8 = (ma_uint8*)pSamplesOut;
-    pSamplesIn8  = (ma_uint8*)pSamplesIn;
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        ma_int32 sampleS32;
-
-        sampleS32 = (ma_int32)(((ma_uint32)(pSamplesIn8[iSample*3+0]) << 8) | ((ma_uint32)(pSamplesIn8[iSample*3+1]) << 16) | ((ma_uint32)(pSamplesIn8[iSample*3+2])) << 24);
-        sampleS32 = (ma_int32)(sampleS32 * factor);
-
-        pSamplesOut8[iSample*3+0] = (ma_uint8)(((ma_uint32)sampleS32 & 0x0000FF00) >>  8);
-        pSamplesOut8[iSample*3+1] = (ma_uint8)(((ma_uint32)sampleS32 & 0x00FF0000) >> 16);
-        pSamplesOut8[iSample*3+2] = (ma_uint8)(((ma_uint32)sampleS32 & 0xFF000000) >> 24);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_s32(ma_int32* pSamplesOut, const ma_int32* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = (ma_int32)(pSamplesIn[iSample] * factor);
-    }
-}
-
-MA_API void ma_copy_and_apply_volume_factor_f32(float* pSamplesOut, const float* pSamplesIn, ma_uint64 sampleCount, float factor)
-{
-    ma_uint64 iSample;
-
-    if (pSamplesOut == NULL || pSamplesIn == NULL) {
-        return;
-    }
-
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamplesOut[iSample] = pSamplesIn[iSample] * factor;
-    }
-}
-
-MA_API void ma_apply_volume_factor_u8(ma_uint8* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_u8(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s16(ma_int16* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s16(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s24(void* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s24(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_s32(ma_int32* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_s32(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_apply_volume_factor_f32(float* pSamples, ma_uint64 sampleCount, float factor)
-{
-    ma_copy_and_apply_volume_factor_f32(pSamples, pSamples, sampleCount, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFramesOut, const ma_uint8* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_u8(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFramesOut, const ma_int16* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s16(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s24(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s24(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFramesOut, const ma_int32* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_s32(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames_f32(float* pPCMFramesOut, const float* pPCMFramesIn, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_f32(pPCMFramesOut, pPCMFramesIn, frameCount*channels, factor);
-}
-
-MA_API void ma_copy_and_apply_volume_factor_pcm_frames(void* pPCMFramesOut, const void* pPCMFramesIn, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor)
-{
-    switch (format)
-    {
-    case ma_format_u8:  ma_copy_and_apply_volume_factor_pcm_frames_u8 ((ma_uint8*)pPCMFramesOut, (const ma_uint8*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s16: ma_copy_and_apply_volume_factor_pcm_frames_s16((ma_int16*)pPCMFramesOut, (const ma_int16*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s24: ma_copy_and_apply_volume_factor_pcm_frames_s24(           pPCMFramesOut,                  pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_s32: ma_copy_and_apply_volume_factor_pcm_frames_s32((ma_int32*)pPCMFramesOut, (const ma_int32*)pPCMFramesIn, frameCount, channels, factor); return;
-    case ma_format_f32: ma_copy_and_apply_volume_factor_pcm_frames_f32(   (float*)pPCMFramesOut,    (const float*)pPCMFramesIn, frameCount, channels, factor); return;
-    default: return;    /* Do nothing. */
-    }
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_u8(ma_uint8* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_u8(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s16(ma_int16* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s16(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s24(void* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s24(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_s32(ma_int32* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_s32(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames_f32(float* pPCMFrames, ma_uint64 frameCount, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames_f32(pPCMFrames, pPCMFrames, frameCount, channels, factor);
-}
-
-MA_API void ma_apply_volume_factor_pcm_frames(void* pPCMFrames, ma_uint64 frameCount, ma_format format, ma_uint32 channels, float factor)
-{
-    ma_copy_and_apply_volume_factor_pcm_frames(pPCMFrames, pPCMFrames, frameCount, format, channels, factor);
-}
-
-
-MA_API float ma_factor_to_gain_db(float factor)
-{
-    return (float)(20*ma_log10f(factor));
-}
-
-MA_API float ma_gain_db_to_factor(float gain)
-{
-    return (float)ma_powf(10, gain/20.0f);
-}
-
-
-/**************************************************************************************************************************************************************
-
-Format Conversion
-
-**************************************************************************************************************************************************************/
-
-static MA_INLINE ma_int16 ma_pcm_sample_f32_to_s16(float x)
-{
-    return (ma_int16)(x * 32767.0f);
-}
-
-static MA_INLINE ma_int16 ma_pcm_sample_u8_to_s16_no_scale(ma_uint8 x)
-{
-    return (ma_int16)((ma_int16)x - 128);
-}
-
-static MA_INLINE ma_int64 ma_pcm_sample_s24_to_s32_no_scale(const ma_uint8* x)
-{
-    return (ma_int64)(((ma_uint64)x[0] << 40) | ((ma_uint64)x[1] << 48) | ((ma_uint64)x[2] << 56)) >> 40;  /* Make sure the sign bits are maintained. */
-}
-
-static MA_INLINE void ma_pcm_sample_s32_to_s24_no_scale(ma_int64 x, ma_uint8* s24)
-{
-    s24[0] = (ma_uint8)((x & 0x000000FF) >>  0);
-    s24[1] = (ma_uint8)((x & 0x0000FF00) >>  8);
-    s24[2] = (ma_uint8)((x & 0x00FF0000) >> 16);
-}
-
-
-static MA_INLINE ma_uint8 ma_clip_u8(ma_int16 x)
-{
-    return (ma_uint8)(ma_clamp(x, -128, 127) + 128);
-}
-
-static MA_INLINE ma_int16 ma_clip_s16(ma_int32 x)
-{
-    return (ma_int16)ma_clamp(x, -32768, 32767);
-}
-
-static MA_INLINE ma_int64 ma_clip_s24(ma_int64 x)
-{
-    return (ma_int64)ma_clamp(x, -8388608, 8388607);
-}
-
-static MA_INLINE ma_int32 ma_clip_s32(ma_int64 x)
-{
-    /* This dance is to silence warnings with -std=c89. A good compiler should be able to optimize this away. */
-    ma_int64 clipMin;
-    ma_int64 clipMax;
-    clipMin = -((ma_int64)2147483647 + 1);
-    clipMax =   (ma_int64)2147483647;
-
-    return (ma_int32)ma_clamp(x, clipMin, clipMax);
-}
-
-
-/* u8 */
-MA_API void ma_pcm_u8_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-    ma_copy_memory_64(dst, src, count * sizeof(ma_uint8));
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int16 x = src_u8[i];
-        x = (ma_int16)(x - 128);
-        x = (ma_int16)(x << 8);
-        dst_s16[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int16 x = src_u8[i];
-        x = (ma_int16)(x - 128);
-
-        dst_s24[i*3+0] = 0;
-        dst_s24[i*3+1] = 0;
-        dst_s24[i*3+2] = (ma_uint8)((ma_int8)x);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int32 x = src_u8[i];
-        x = x - 128;
-        x = x << 24;
-        dst_s32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_u8_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)src_u8[i];
-        x = x * 0.00784313725490196078f;    /* 0..255 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_u8_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_u8_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_u8_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_u8_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_u8_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_u8_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_u8_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_u8_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_u8_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_u8_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-static MA_INLINE void ma_pcm_interleave_u8__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8** src_u8 = (const ma_uint8**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame];
-        }
-    }
-}
-#else
-static MA_INLINE void ma_pcm_interleave_u8__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8** src_u8 = (const ma_uint8**)src;
-
-    if (channels == 1) {
-        ma_copy_memory_64(dst, src[0], frameCount * sizeof(ma_uint8));
-    } else if (channels == 2) {
-        ma_uint64 iFrame;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            dst_u8[iFrame*2 + 0] = src_u8[0][iFrame];
-            dst_u8[iFrame*2 + 1] = src_u8[1][iFrame];
-        }
-    } else {
-        ma_uint64 iFrame;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_uint32 iChannel;
-            for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                dst_u8[iFrame*channels + iChannel] = src_u8[iChannel][iFrame];
-            }
-        }
-    }
-}
-#endif
-
-MA_API void ma_pcm_interleave_u8(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_u8__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_u8__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_u8__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8** dst_u8 = (ma_uint8**)dst;
-    const ma_uint8* src_u8 = (const ma_uint8*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_u8[iChannel][iFrame] = src_u8[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_u8__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_u8(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_u8__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_u8__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* s16 */
-static MA_INLINE void ma_pcm_s16_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int16 x = src_s16[i];
-            x = (ma_int16)(x >> 8);
-            x = (ma_int16)(x + 128);
-            dst_u8[i] = (ma_uint8)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int16 x = src_s16[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x80, 0x7F);
-            if ((x + dither) <= 0x7FFF) {
-                x = (ma_int16)(x + dither);
-            } else {
-                x = 0x7FFF;
-            }
-
-            x = (ma_int16)(x >> 8);
-            x = (ma_int16)(x + 128);
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s16_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s16_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-    ma_copy_memory_64(dst, src, count * sizeof(ma_int16));
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s24[i*3+0] = 0;
-        dst_s24[i*3+1] = (ma_uint8)(src_s16[i] & 0xFF);
-        dst_s24[i*3+2] = (ma_uint8)(src_s16[i] >> 8);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s32[i] = src_s16[i] << 16;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s16_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)src_s16[i];
-
-#if 0
-        /* The accurate way. */
-        x = x + 32768.0f;                   /* -32768..32767 to 0..65535 */
-        x = x * 0.00003051804379339284f;    /* 0..65535 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-#else
-        /* The fast way. */
-        x = x * 0.000030517578125f;         /* -32768..32767 to -1..0.999969482421875 */
-#endif
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s16_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s16_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s16_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s16_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s16_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s16_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s16_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s16_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s16_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s16_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s16__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_int16** src_s16 = (const ma_int16**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s16[iFrame*channels + iChannel] = src_s16[iChannel][iFrame];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s16__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s16__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s16(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s16__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s16__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s16__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int16** dst_s16 = (ma_int16**)dst;
-    const ma_int16* src_s16 = (const ma_int16*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s16[iChannel][iFrame] = src_s16[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s16__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s16(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s16__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s16__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* s24 */
-static MA_INLINE void ma_pcm_s24_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            dst_u8[i] = (ma_uint8)((ma_int8)src_s24[i*3 + 2] + 128);
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s24_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_uint16 dst_lo =            ((ma_uint16)src_s24[i*3 + 1]);
-            ma_uint16 dst_hi = (ma_uint16)((ma_uint16)src_s24[i*3 + 2] << 8);
-            dst_s16[i] = (ma_int16)(dst_lo | dst_hi);
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s24_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s24_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * 3);
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        dst_s32[i] = (ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24);
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s24_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s24_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_uint8* src_s24 = (const ma_uint8*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        float x = (float)(((ma_int32)(((ma_uint32)(src_s24[i*3+0]) << 8) | ((ma_uint32)(src_s24[i*3+1]) << 16) | ((ma_uint32)(src_s24[i*3+2])) << 24)) >> 8);
-
-#if 0
-        /* The accurate way. */
-        x = x + 8388608.0f;                 /* -8388608..8388607 to 0..16777215 */
-        x = x * 0.00000011920929665621f;    /* 0..16777215 to 0..2 */
-        x = x - 1;                          /* 0..2 to -1..1 */
-#else
-        /* The fast way. */
-        x = x * 0.00000011920928955078125f; /* -8388608..8388607 to -1..0.999969482421875 */
-#endif
-
-        dst_f32[i] = x;
-    }
-
-    (void)ditherMode;
-}
-
-static MA_INLINE void ma_pcm_s24_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s24_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s24_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s24_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s24_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s24_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s24_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s24_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s24_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s24_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s24__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8* dst8 = (ma_uint8*)dst;
-    const ma_uint8** src8 = (const ma_uint8**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst8[iFrame*3*channels + iChannel*3 + 0] = src8[iChannel][iFrame*3 + 0];
-            dst8[iFrame*3*channels + iChannel*3 + 1] = src8[iChannel][iFrame*3 + 1];
-            dst8[iFrame*3*channels + iChannel*3 + 2] = src8[iChannel][iFrame*3 + 2];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s24__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s24__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s24(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s24__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s24__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s24__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_uint8** dst8 = (ma_uint8**)dst;
-    const ma_uint8* src8 = (const ma_uint8*)src;
-
-    ma_uint32 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst8[iChannel][iFrame*3 + 0] = src8[iFrame*3*channels + iChannel*3 + 0];
-            dst8[iChannel][iFrame*3 + 1] = src8[iFrame*3*channels + iChannel*3 + 1];
-            dst8[iChannel][iFrame*3 + 2] = src8[iFrame*3*channels + iChannel*3 + 2];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s24__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s24(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s24__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s24__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-
-/* s32 */
-static MA_INLINE void ma_pcm_s32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x800000, 0x7FFFFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 24;
-            x = x + 128;
-            dst_u8[i] = (ma_uint8)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    if (ditherMode == ma_dither_mode_none) {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    } else {
-        ma_uint64 i;
-        for (i = 0; i < count; i += 1) {
-            ma_int32 x = src_s32[i];
-
-            /* Dither. Don't overflow. */
-            ma_int32 dither = ma_dither_s32(ditherMode, -0x8000, 0x7FFF);
-            if ((ma_int64)x + dither <= 0x7FFFFFFF) {
-                x = x + dither;
-            } else {
-                x = 0x7FFFFFFF;
-            }
-
-            x = x >> 16;
-            dst_s16[i] = (ma_int16)x;
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_s32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_uint32 x = (ma_uint32)src_s32[i];
-        dst_s24[i*3+0] = (ma_uint8)((x & 0x0000FF00) >>  8);
-        dst_s24[i*3+1] = (ma_uint8)((x & 0x00FF0000) >> 16);
-        dst_s24[i*3+2] = (ma_uint8)((x & 0xFF000000) >> 24);
-    }
-
-    (void)ditherMode;   /* No dithering for s32 -> s24. */
-}
-
-static MA_INLINE void ma_pcm_s32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_s32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * sizeof(ma_int32));
-}
-
-
-static MA_INLINE void ma_pcm_s32_to_f32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    float* dst_f32 = (float*)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        double x = src_s32[i];
-
-#if 0
-        x = x + 2147483648.0;
-        x = x * 0.0000000004656612873077392578125;
-        x = x - 1;
-#else
-        x = x / 2147483648.0;
-#endif
-
-        dst_f32[i] = (float)x;
-    }
-
-    (void)ditherMode;   /* No dithering for s32 -> f32. */
-}
-
-static MA_INLINE void ma_pcm_s32_to_f32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_s32_to_f32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_s32_to_f32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_s32_to_f32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_s32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_s32_to_f32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_s32_to_f32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_s32_to_f32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_s32_to_f32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_s32_to_f32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_interleave_s32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const ma_int32** src_s32 = (const ma_int32**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s32[iFrame*channels + iChannel] = src_s32[iChannel][iFrame];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_interleave_s32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_s32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_s32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_s32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_s32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_deinterleave_s32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_int32** dst_s32 = (ma_int32**)dst;
-    const ma_int32* src_s32 = (const ma_int32*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_s32[iChannel][iFrame] = src_s32[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static MA_INLINE void ma_pcm_deinterleave_s32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_s32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_s32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_s32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-/* f32 */
-static MA_INLINE void ma_pcm_f32_to_u8__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-
-    ma_uint8* dst_u8 = (ma_uint8*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -128;
-        ditherMax = 1.0f /  127;
-    }
-
-    for (i = 0; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 127.5f;                             /* 0..2 to 0..255 */
-
-        dst_u8[i] = (ma_uint8)x;
-    }
-}
-
-static MA_INLINE void ma_pcm_f32_to_u8__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_u8__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_u8__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_u8__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_u8(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_u8__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_u8__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_u8__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_u8__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_u8__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-static MA_INLINE void ma_pcm_f32_to_s16__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    for (i = 0; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 32767.5f;                           /* 0..2 to 0..65535 */
-        x = x - 32768.0f;                           /* 0...65535 to -32768..32767 */
-#else
-        /* The fast way. */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-#endif
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#else
-static MA_INLINE void ma_pcm_f32_to_s16__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i4;
-    ma_uint64 count4;
-
-    ma_int16* dst_s16 = (ma_int16*)dst;
-    const float* src_f32 = (const float*)src;
-
-    float ditherMin = 0;
-    float ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    /* Unrolled. */
-    i = 0;
-    count4 = count >> 2;
-    for (i4 = 0; i4 < count4; i4 += 1) {
-        float d0 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d1 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d2 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        float d3 = ma_dither_f32(ditherMode, ditherMin, ditherMax);
-
-        float x0 = src_f32[i+0];
-        float x1 = src_f32[i+1];
-        float x2 = src_f32[i+2];
-        float x3 = src_f32[i+3];
-
-        x0 = x0 + d0;
-        x1 = x1 + d1;
-        x2 = x2 + d2;
-        x3 = x3 + d3;
-
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-
-        dst_s16[i+0] = (ma_int16)x0;
-        dst_s16[i+1] = (ma_int16)x1;
-        dst_s16[i+2] = (ma_int16)x2;
-        dst_s16[i+3] = (ma_int16)x3;
-
-        i += 4;
-    }
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s16__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i8;
-    ma_uint64 count8;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    /* Both the input and output buffers need to be aligned to 16 bytes. */
-    if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* SSE2. SSE allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */
-    count8 = count >> 3;
-    for (i8 = 0; i8 < count8; i8 += 1) {
-        __m128 d0;
-        __m128 d1;
-        __m128 x0;
-        __m128 x1;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = _mm_set1_ps(0);
-            d1 = _mm_set1_ps(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            d0 = _mm_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-            d1 = _mm_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-        } else {
-            d0 = _mm_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-            d1 = _mm_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-        }
-
-        x0 = *((__m128*)(src_f32 + i) + 0);
-        x1 = *((__m128*)(src_f32 + i) + 1);
-
-        x0 = _mm_add_ps(x0, d0);
-        x1 = _mm_add_ps(x1, d1);
-
-        x0 = _mm_mul_ps(x0, _mm_set1_ps(32767.0f));
-        x1 = _mm_mul_ps(x1, _mm_set1_ps(32767.0f));
-
-        _mm_stream_si128(((__m128i*)(dst_s16 + i)), _mm_packs_epi32(_mm_cvttps_epi32(x0), _mm_cvttps_epi32(x1)));
-
-        i += 8;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* SSE2 */
-
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s16__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i16;
-    ma_uint64 count16;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    /* Both the input and output buffers need to be aligned to 32 bytes. */
-    if ((((ma_uintptr)dst & 31) != 0) || (((ma_uintptr)src & 31) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* AVX2. AVX2 allows us to output 16 s16's at a time which means our loop is unrolled 16 times. */
-    count16 = count >> 4;
-    for (i16 = 0; i16 < count16; i16 += 1) {
-        __m256 d0;
-        __m256 d1;
-        __m256 x0;
-        __m256 x1;
-        __m256i i0;
-        __m256i i1;
-        __m256i p0;
-        __m256i p1;
-        __m256i r;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = _mm256_set1_ps(0);
-            d1 = _mm256_set1_ps(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            d0 = _mm256_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-            d1 = _mm256_set_ps(
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax),
-                ma_dither_f32_rectangle(ditherMin, ditherMax)
-            );
-        } else {
-            d0 = _mm256_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-            d1 = _mm256_set_ps(
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax),
-                ma_dither_f32_triangle(ditherMin, ditherMax)
-            );
-        }
-
-        x0 = *((__m256*)(src_f32 + i) + 0);
-        x1 = *((__m256*)(src_f32 + i) + 1);
-
-        x0 = _mm256_add_ps(x0, d0);
-        x1 = _mm256_add_ps(x1, d1);
-
-        x0 = _mm256_mul_ps(x0, _mm256_set1_ps(32767.0f));
-        x1 = _mm256_mul_ps(x1, _mm256_set1_ps(32767.0f));
-
-        /* Computing the final result is a little more complicated for AVX2 than SSE2. */
-        i0 = _mm256_cvttps_epi32(x0);
-        i1 = _mm256_cvttps_epi32(x1);
-        p0 = _mm256_permute2x128_si256(i0, i1, 0 | 32);
-        p1 = _mm256_permute2x128_si256(i0, i1, 1 | 48);
-        r  = _mm256_packs_epi32(p0, p1);
-
-        _mm256_stream_si256(((__m256i*)(dst_s16 + i)), r);
-
-        i += 16;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* AVX2 */
-
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s16__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint64 i;
-    ma_uint64 i8;
-    ma_uint64 count8;
-    ma_int16* dst_s16;
-    const float* src_f32;
-    float ditherMin;
-    float ditherMax;
-
-    if (!ma_has_neon()) {
-        return ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-    }
-
-    /* Both the input and output buffers need to be aligned to 16 bytes. */
-    if ((((ma_uintptr)dst & 15) != 0) || (((ma_uintptr)src & 15) != 0)) {
-        ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        return;
-    }
-
-    dst_s16 = (ma_int16*)dst;
-    src_f32 = (const float*)src;
-
-    ditherMin = 0;
-    ditherMax = 0;
-    if (ditherMode != ma_dither_mode_none) {
-        ditherMin = 1.0f / -32768;
-        ditherMax = 1.0f /  32767;
-    }
-
-    i = 0;
-
-    /* NEON. NEON allows us to output 8 s16's at a time which means our loop is unrolled 8 times. */
-    count8 = count >> 3;
-    for (i8 = 0; i8 < count8; i8 += 1) {
-        float32x4_t d0;
-        float32x4_t d1;
-        float32x4_t x0;
-        float32x4_t x1;
-        int32x4_t i0;
-        int32x4_t i1;
-
-        if (ditherMode == ma_dither_mode_none) {
-            d0 = vmovq_n_f32(0);
-            d1 = vmovq_n_f32(0);
-        } else if (ditherMode == ma_dither_mode_rectangle) {
-            float d0v[4];
-            d0v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d0 = vld1q_f32(d0v);
-
-            float d1v[4];
-            d1v[0] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[1] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[2] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1v[3] = ma_dither_f32_rectangle(ditherMin, ditherMax);
-            d1 = vld1q_f32(d1v);
-        } else {
-            float d0v[4];
-            d0v[0] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[1] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[2] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0v[3] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d0 = vld1q_f32(d0v);
-
-            float d1v[4];
-            d1v[0] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[1] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[2] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1v[3] = ma_dither_f32_triangle(ditherMin, ditherMax);
-            d1 = vld1q_f32(d1v);
-        }
-
-        x0 = *((float32x4_t*)(src_f32 + i) + 0);
-        x1 = *((float32x4_t*)(src_f32 + i) + 1);
-
-        x0 = vaddq_f32(x0, d0);
-        x1 = vaddq_f32(x1, d1);
-
-        x0 = vmulq_n_f32(x0, 32767.0f);
-        x1 = vmulq_n_f32(x1, 32767.0f);
-
-        i0 = vcvtq_s32_f32(x0);
-        i1 = vcvtq_s32_f32(x1);
-        *((int16x8_t*)(dst_s16 + i)) = vcombine_s16(vqmovn_s32(i0), vqmovn_s32(i1));
-
-        i += 8;
-    }
-
-
-    /* Leftover. */
-    for (; i < count; i += 1) {
-        float x = src_f32[i];
-        x = x + ma_dither_f32(ditherMode, ditherMin, ditherMax);
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-        x = x * 32767.0f;                           /* -1..1 to -32767..32767 */
-
-        dst_s16[i] = (ma_int16)x;
-    }
-}
-#endif  /* Neon */
-#endif  /* MA_USE_REFERENCE_CONVERSION_APIS */
-
-MA_API void ma_pcm_f32_to_s16(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s16__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s16__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s16__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s16__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s16__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_f32_to_s24__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_uint8* dst_s24 = (ma_uint8*)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint64 i;
-    for (i = 0; i < count; i += 1) {
-        ma_int32 r;
-        float x = src_f32[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 8388607.5f;                         /* 0..2 to 0..16777215 */
-        x = x - 8388608.0f;                         /* 0..16777215 to -8388608..8388607 */
-#else
-        /* The fast way. */
-        x = x * 8388607.0f;                         /* -1..1 to -8388607..8388607 */
-#endif
-
-        r = (ma_int32)x;
-        dst_s24[(i*3)+0] = (ma_uint8)((r & 0x0000FF) >>  0);
-        dst_s24[(i*3)+1] = (ma_uint8)((r & 0x00FF00) >>  8);
-        dst_s24[(i*3)+2] = (ma_uint8)((r & 0xFF0000) >> 16);
-    }
-
-    (void)ditherMode;   /* No dithering for f32 -> s24. */
-}
-
-static MA_INLINE void ma_pcm_f32_to_s24__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s24__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s24__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s24__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_s24(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s24__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s24__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s24__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s24__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s24__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-static MA_INLINE void ma_pcm_f32_to_s32__reference(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_int32* dst_s32 = (ma_int32*)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint32 i;
-    for (i = 0; i < count; i += 1) {
-        double x = src_f32[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));    /* clip */
-
-#if 0
-        /* The accurate way. */
-        x = x + 1;                                  /* -1..1 to 0..2 */
-        x = x * 2147483647.5;                       /* 0..2 to 0..4294967295 */
-        x = x - 2147483648.0;                       /* 0...4294967295 to -2147483648..2147483647 */
-#else
-        /* The fast way. */
-        x = x * 2147483647.0;                       /* -1..1 to -2147483647..2147483647 */
-#endif
-
-        dst_s32[i] = (ma_int32)x;
-    }
-
-    (void)ditherMode;   /* No dithering for f32 -> s32. */
-}
-
-static MA_INLINE void ma_pcm_f32_to_s32__optimized(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode);
-}
-
-#if defined(MA_SUPPORT_SSE2)
-static MA_INLINE void ma_pcm_f32_to_s32__sse2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_AVX2)
-static MA_INLINE void ma_pcm_f32_to_s32__avx2(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-#if defined(MA_SUPPORT_NEON)
-static MA_INLINE void ma_pcm_f32_to_s32__neon(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-}
-#endif
-
-MA_API void ma_pcm_f32_to_s32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_f32_to_s32__reference(dst, src, count, ditherMode);
-#else
-    #  if MA_PREFERRED_SIMD == MA_SIMD_AVX2
-        if (ma_has_avx2()) {
-            ma_pcm_f32_to_s32__avx2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_SSE2
-        if (ma_has_sse2()) {
-            ma_pcm_f32_to_s32__sse2(dst, src, count, ditherMode);
-        } else
-    #elif MA_PREFERRED_SIMD == MA_SIMD_NEON
-        if (ma_has_neon()) {
-            ma_pcm_f32_to_s32__neon(dst, src, count, ditherMode);
-        } else
-    #endif
-        {
-            ma_pcm_f32_to_s32__optimized(dst, src, count, ditherMode);
-        }
-#endif
-}
-
-
-MA_API void ma_pcm_f32_to_f32(void* dst, const void* src, ma_uint64 count, ma_dither_mode ditherMode)
-{
-    (void)ditherMode;
-
-    ma_copy_memory_64(dst, src, count * sizeof(float));
-}
-
-
-static void ma_pcm_interleave_f32__reference(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    float* dst_f32 = (float*)dst;
-    const float** src_f32 = (const float**)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_f32[iFrame*channels + iChannel] = src_f32[iChannel][iFrame];
-        }
-    }
-}
-
-static void ma_pcm_interleave_f32__optimized(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_interleave_f32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_interleave_f32(void* dst, const void** src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_interleave_f32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_interleave_f32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-static void ma_pcm_deinterleave_f32__reference(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    float** dst_f32 = (float**)dst;
-    const float* src_f32 = (const float*)src;
-
-    ma_uint64 iFrame;
-    for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; iChannel += 1) {
-            dst_f32[iChannel][iFrame] = src_f32[iFrame*channels + iChannel];
-        }
-    }
-}
-
-static void ma_pcm_deinterleave_f32__optimized(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-    ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels);
-}
-
-MA_API void ma_pcm_deinterleave_f32(void** dst, const void* src, ma_uint64 frameCount, ma_uint32 channels)
-{
-#ifdef MA_USE_REFERENCE_CONVERSION_APIS
-    ma_pcm_deinterleave_f32__reference(dst, src, frameCount, channels);
-#else
-    ma_pcm_deinterleave_f32__optimized(dst, src, frameCount, channels);
-#endif
-}
-
-
-MA_API void ma_pcm_convert(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 sampleCount, ma_dither_mode ditherMode)
-{
-    if (formatOut == formatIn) {
-        ma_copy_memory_64(pOut, pIn, sampleCount * ma_get_bytes_per_sample(formatOut));
-        return;
-    }
-
-    switch (formatIn)
-    {
-        case ma_format_u8:
-        {
-            switch (formatOut)
-            {
-                case ma_format_s16: ma_pcm_u8_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_u8_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_u8_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_u8_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s16_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_s16_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_s16_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s16_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s24_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_s24_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_s24_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s24_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_s32_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_s32_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_s32_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_f32: ma_pcm_s32_to_f32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            switch (formatOut)
-            {
-                case ma_format_u8:  ma_pcm_f32_to_u8( pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s16: ma_pcm_f32_to_s16(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s24: ma_pcm_f32_to_s24(pOut, pIn, sampleCount, ditherMode); return;
-                case ma_format_s32: ma_pcm_f32_to_s32(pOut, pIn, sampleCount, ditherMode); return;
-                default: break;
-            }
-        } break;
-
-        default: break;
-    }
-}
-
-MA_API void ma_convert_pcm_frames_format(void* pOut, ma_format formatOut, const void* pIn, ma_format formatIn, ma_uint64 frameCount, ma_uint32 channels, ma_dither_mode ditherMode)
-{
-    ma_pcm_convert(pOut, formatOut, pIn, formatIn, frameCount * channels, ditherMode);
-}
-
-MA_API void ma_deinterleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void* pInterleavedPCMFrames, void** ppDeinterleavedPCMFrames)
-{
-    if (pInterleavedPCMFrames == NULL || ppDeinterleavedPCMFrames == NULL) {
-        return; /* Invalid args. */
-    }
-
-    /* For efficiency we do this per format. */
-    switch (format) {
-        case ma_format_s16:
-        {
-            const ma_int16* pSrcS16 = (const ma_int16*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    ma_int16* pDstS16 = (ma_int16*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstS16[iPCMFrame] = pSrcS16[iPCMFrame*channels+iChannel];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            const float* pSrcF32 = (const float*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    float* pDstF32 = (float*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstF32[iPCMFrame] = pSrcF32[iPCMFrame*channels+iChannel];
-                }
-            }
-        } break;
-
-        default:
-        {
-            ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format);
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                          void* pDst = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes);
-                    const void* pSrc = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes);
-                    memcpy(pDst, pSrc, sampleSizeInBytes);
-                }
-            }
-        } break;
-    }
-}
-
-MA_API void ma_interleave_pcm_frames(ma_format format, ma_uint32 channels, ma_uint64 frameCount, const void** ppDeinterleavedPCMFrames, void* pInterleavedPCMFrames)
-{
-    switch (format)
-    {
-        case ma_format_s16:
-        {
-            ma_int16* pDstS16 = (ma_int16*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    const ma_int16* pSrcS16 = (const ma_int16*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstS16[iPCMFrame*channels+iChannel] = pSrcS16[iPCMFrame];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            float* pDstF32 = (float*)pInterleavedPCMFrames;
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                    const float* pSrcF32 = (const float*)ppDeinterleavedPCMFrames[iChannel];
-                    pDstF32[iPCMFrame*channels+iChannel] = pSrcF32[iPCMFrame];
-                }
-            }
-        } break;
-
-        default:
-        {
-            ma_uint32 sampleSizeInBytes = ma_get_bytes_per_sample(format);
-            ma_uint64 iPCMFrame;
-            for (iPCMFrame = 0; iPCMFrame < frameCount; ++iPCMFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < channels; ++iChannel) {
-                          void* pDst = ma_offset_ptr(pInterleavedPCMFrames, (iPCMFrame*channels+iChannel)*sampleSizeInBytes);
-                    const void* pSrc = ma_offset_ptr(ppDeinterleavedPCMFrames[iChannel], iPCMFrame*sampleSizeInBytes);
-                    memcpy(pDst, pSrc, sampleSizeInBytes);
-                }
-            }
-        } break;
-    }
-}
-
-
-/**************************************************************************************************************************************************************
-
-Biquad Filter
-
-**************************************************************************************************************************************************************/
-#ifndef MA_BIQUAD_FIXED_POINT_SHIFT
-#define MA_BIQUAD_FIXED_POINT_SHIFT 14
-#endif
-
-static ma_int32 ma_biquad_float_to_fp(double x)
-{
-    return (ma_int32)(x * (1 << MA_BIQUAD_FIXED_POINT_SHIFT));
-}
-
-MA_API ma_biquad_config ma_biquad_config_init(ma_format format, ma_uint32 channels, double b0, double b1, double b2, double a0, double a1, double a2)
-{
-    ma_biquad_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.b0 = b0;
-    config.b1 = b1;
-    config.b2 = b2;
-    config.a0 = a0;
-    config.a1 = a1;
-    config.a2 = a2;
-
-    return config;
-}
-
-MA_API ma_result ma_biquad_init(const ma_biquad_config* pConfig, ma_biquad* pBQ)
-{
-    if (pBQ == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBQ);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_reinit(pConfig, pBQ);
-}
-
-MA_API ma_result ma_biquad_reinit(const ma_biquad_config* pConfig, ma_biquad* pBQ)
-{
-    if (pBQ == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->a0 == 0) {
-        return MA_INVALID_ARGS; /* Division by zero. */
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pBQ->format != ma_format_unknown && pBQ->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pBQ->channels != 0 && pBQ->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-
-    pBQ->format   = pConfig->format;
-    pBQ->channels = pConfig->channels;
-
-    /* Normalize. */
-    if (pConfig->format == ma_format_f32) {
-        pBQ->b0.f32 = (float)(pConfig->b0 / pConfig->a0);
-        pBQ->b1.f32 = (float)(pConfig->b1 / pConfig->a0);
-        pBQ->b2.f32 = (float)(pConfig->b2 / pConfig->a0);
-        pBQ->a1.f32 = (float)(pConfig->a1 / pConfig->a0);
-        pBQ->a2.f32 = (float)(pConfig->a2 / pConfig->a0);
-    } else {
-        pBQ->b0.s32 = ma_biquad_float_to_fp(pConfig->b0 / pConfig->a0);
-        pBQ->b1.s32 = ma_biquad_float_to_fp(pConfig->b1 / pConfig->a0);
-        pBQ->b2.s32 = ma_biquad_float_to_fp(pConfig->b2 / pConfig->a0);
-        pBQ->a1.s32 = ma_biquad_float_to_fp(pConfig->a1 / pConfig->a0);
-        pBQ->a2.s32 = ma_biquad_float_to_fp(pConfig->a2 / pConfig->a0);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(ma_biquad* pBQ, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pBQ->channels;
-    const float b0 = pBQ->b0.f32;
-    const float b1 = pBQ->b1.f32;
-    const float b2 = pBQ->b2.f32;
-    const float a1 = pBQ->a1.f32;
-    const float a2 = pBQ->a2.f32;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pBQ->r1[c].f32;
-        float r2 = pBQ->r2[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y  = b0*x        + r1;
-        r1 = b1*x - a1*y + r2;
-        r2 = b2*x - a2*y;
-
-        pY[c]          = y;
-        pBQ->r1[c].f32 = r1;
-        pBQ->r2[c].f32 = r2;
-    }
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_f32(ma_biquad* pBQ, float* pY, const float* pX)
-{
-    ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX);
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pBQ->channels;
-    const ma_int32 b0 = pBQ->b0.s32;
-    const ma_int32 b1 = pBQ->b1.s32;
-    const ma_int32 b2 = pBQ->b2.s32;
-    const ma_int32 a1 = pBQ->a1.s32;
-    const ma_int32 a2 = pBQ->a2.s32;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pBQ->r1[c].s32;
-        ma_int32 r2 = pBQ->r2[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y  = (b0*x        + r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-        r1 = (b1*x - a1*y + r2);
-        r2 = (b2*x - a2*y);
-
-        pY[c]          = (ma_int16)ma_clamp(y, -32768, 32767);
-        pBQ->r1[c].s32 = r1;
-        pBQ->r2[c].s32 = r2;
-    }
-}
-
-static MA_INLINE void ma_biquad_process_pcm_frame_s16(ma_biquad* pBQ, ma_int16* pY, const ma_int16* pX)
-{
-    ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX);
-}
-
-MA_API ma_result ma_biquad_process_pcm_frames(ma_biquad* pBQ, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pBQ == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pBQ->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_biquad_process_pcm_frame_f32__direct_form_2_transposed(pBQ, pY, pX);
-            pY += pBQ->channels;
-            pX += pBQ->channels;
-        }
-    } else if (pBQ->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_biquad_process_pcm_frame_s16__direct_form_2_transposed(pBQ, pY, pX);
-            pY += pBQ->channels;
-            pX += pBQ->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_biquad_get_latency(const ma_biquad* pBQ)
-{
-    if (pBQ == NULL) {
-        return 0;
-    }
-
-    return 2;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Low-Pass Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_lpf1_config ma_lpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency)
-{
-    ma_lpf1_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = 0.5;
-
-    return config;
-}
-
-MA_API ma_lpf2_config ma_lpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_lpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-MA_API ma_result ma_lpf1_init(const ma_lpf1_config* pConfig, ma_lpf1* pLPF)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_lpf1_reinit(pConfig, pLPF);
-}
-
-MA_API ma_result ma_lpf1_reinit(const ma_lpf1_config* pConfig, ma_lpf1* pLPF)
-{
-    double a;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    pLPF->format   = pConfig->format;
-    pLPF->channels = pConfig->channels;
-
-    a = ma_exp(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate);
-    if (pConfig->format == ma_format_f32) {
-        pLPF->a.f32 = (float)a;
-    } else {
-        pLPF->a.s32 = ma_biquad_float_to_fp(a);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_lpf1_process_pcm_frame_f32(ma_lpf1* pLPF, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pLPF->channels;
-    const float a = pLPF->a.f32;
-    const float b = 1 - a;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pLPF->r1[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y = b*x + a*r1;
-
-        pY[c]           = y;
-        pLPF->r1[c].f32 = y;
-    }
-}
-
-static MA_INLINE void ma_lpf1_process_pcm_frame_s16(ma_lpf1* pLPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pLPF->channels;
-    const ma_int32 a = pLPF->a.s32;
-    const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a);
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pLPF->r1[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y = (b*x + a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-
-        pY[c]           = (ma_int16)y;
-        pLPF->r1[c].s32 = (ma_int32)y;
-    }
-}
-
-MA_API ma_result ma_lpf1_process_pcm_frames(ma_lpf1* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pLPF == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pLPF->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_lpf1_process_pcm_frame_f32(pLPF, pY, pX);
-            pY += pLPF->channels;
-            pX += pLPF->channels;
-        }
-    } else if (pLPF->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_lpf1_process_pcm_frame_s16(pLPF, pY, pX);
-            pY += pLPF->channels;
-            pX += pLPF->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_lpf1_get_latency(const ma_lpf1* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return 1;
-}
-
-
-static MA_INLINE ma_biquad_config ma_lpf2__get_biquad_config(const ma_lpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 = (1 - c) / 2;
-    bqConfig.b1 =  1 - c;
-    bqConfig.b2 = (1 - c) / 2;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_lpf2_init(const ma_lpf2_config* pConfig, ma_lpf2* pLPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_lpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pLPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_lpf2_reinit(const ma_lpf2_config* pConfig, ma_lpf2* pLPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_lpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pLPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_lpf2_process_pcm_frame_s16(ma_lpf2* pLPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pLPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_lpf2_process_pcm_frame_f32(ma_lpf2* pLPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pLPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_lpf2_process_pcm_frames(ma_lpf2* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pLPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_lpf2_get_latency(const ma_lpf2* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pLPF->bq);
-}
-
-
-MA_API ma_lpf_config ma_lpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_lpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_lpf_reinit__internal(const ma_lpf_config* pConfig, ma_lpf* pLPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 lpf1Count;
-    ma_uint32 lpf2Count;
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    if (pLPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pLPF->format != ma_format_unknown && pLPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pLPF->channels != 0 && pLPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    lpf1Count = pConfig->order % 2;
-    lpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(lpf1Count <= ma_countof(pLPF->lpf1));
-    MA_ASSERT(lpf2Count <= ma_countof(pLPF->lpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pLPF->lpf1Count != lpf1Count || pLPF->lpf2Count != lpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ilpf1 = 0; ilpf1 < lpf1Count; ilpf1 += 1) {
-        ma_lpf1_config lpf1Config = ma_lpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency);
-
-        if (isNew) {
-            result = ma_lpf1_init(&lpf1Config, &pLPF->lpf1[ilpf1]);
-        } else {
-            result = ma_lpf1_reinit(&lpf1Config, &pLPF->lpf1[ilpf1]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    for (ilpf2 = 0; ilpf2 < lpf2Count; ilpf2 += 1) {
-        ma_lpf2_config lpf2Config;
-        double q;
-        double a;
-
-        /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */
-        if (lpf1Count == 1) {
-            a = (1 + ilpf2*1) * (MA_PI_D/(pConfig->order*1));   /* Odd order. */
-        } else {
-            a = (1 + ilpf2*2) * (MA_PI_D/(pConfig->order*2));   /* Even order. */
-        }
-        q = 1 / (2*ma_cos(a));
-
-        lpf2Config = ma_lpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_lpf2_init(&lpf2Config, &pLPF->lpf2[ilpf2]);
-        } else {
-            result = ma_lpf2_reinit(&lpf2Config, &pLPF->lpf2[ilpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pLPF->lpf1Count  = lpf1Count;
-    pLPF->lpf2Count  = lpf2Count;
-    pLPF->format     = pConfig->format;
-    pLPF->channels   = pConfig->channels;
-    pLPF->sampleRate = pConfig->sampleRate;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_lpf_init(const ma_lpf_config* pConfig, ma_lpf* pLPF)
-{
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pLPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_lpf_reinit__internal(pConfig, pLPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_lpf_reinit(const ma_lpf_config* pConfig, ma_lpf* pLPF)
-{
-    return ma_lpf_reinit__internal(pConfig, pLPF, /*isNew*/MA_FALSE);
-}
-
-static MA_INLINE void ma_lpf_process_pcm_frame_f32(ma_lpf* pLPF, float* pY, const void* pX)
-{
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    MA_ASSERT(pLPF->format == ma_format_f32);
-
-    MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
-
-    for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-        ma_lpf1_process_pcm_frame_f32(&pLPF->lpf1[ilpf1], pY, pY);
-    }
-
-    for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-        ma_lpf2_process_pcm_frame_f32(&pLPF->lpf2[ilpf2], pY, pY);
-    }
-}
-
-static MA_INLINE void ma_lpf_process_pcm_frame_s16(ma_lpf* pLPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    MA_ASSERT(pLPF->format == ma_format_s16);
-
-    MA_COPY_MEMORY(pY, pX, ma_get_bytes_per_frame(pLPF->format, pLPF->channels));
-
-    for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-        ma_lpf1_process_pcm_frame_s16(&pLPF->lpf1[ilpf1], pY, pY);
-    }
-
-    for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-        ma_lpf2_process_pcm_frame_s16(&pLPF->lpf2[ilpf2], pY, pY);
-    }
-}
-
-MA_API ma_result ma_lpf_process_pcm_frames(ma_lpf* pLPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ilpf1;
-    ma_uint32 ilpf2;
-
-    if (pLPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ilpf1 = 0; ilpf1 < pLPF->lpf1Count; ilpf1 += 1) {
-            result = ma_lpf1_process_pcm_frames(&pLPF->lpf1[ilpf1], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-
-        for (ilpf2 = 0; ilpf2 < pLPF->lpf2Count; ilpf2 += 1) {
-            result = ma_lpf2_process_pcm_frames(&pLPF->lpf2[ilpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pLPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_lpf_process_pcm_frame_f32(pLPF, pFramesOutF32, pFramesInF32);
-                pFramesOutF32 += pLPF->channels;
-                pFramesInF32  += pLPF->channels;
-            }
-        } else if (pLPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_lpf_process_pcm_frame_s16(pLPF, pFramesOutS16, pFramesInS16);
-                pFramesOutS16 += pLPF->channels;
-                pFramesInS16  += pLPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_lpf_get_latency(const ma_lpf* pLPF)
-{
-    if (pLPF == NULL) {
-        return 0;
-    }
-
-    return pLPF->lpf2Count*2 + pLPF->lpf1Count;
-}
-
-
-/**************************************************************************************************************************************************************
-
-High-Pass Filtering
-
-**************************************************************************************************************************************************************/
-MA_API ma_hpf1_config ma_hpf1_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency)
-{
-    ma_hpf1_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-
-    return config;
-}
-
-MA_API ma_hpf2_config ma_hpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_hpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-MA_API ma_result ma_hpf1_init(const ma_hpf1_config* pConfig, ma_hpf1* pHPF)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_hpf1_reinit(pConfig, pHPF);
-}
-
-MA_API ma_result ma_hpf1_reinit(const ma_hpf1_config* pConfig, ma_hpf1* pHPF)
-{
-    double a;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    pHPF->format   = pConfig->format;
-    pHPF->channels = pConfig->channels;
-
-    a = ma_exp(-2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate);
-    if (pConfig->format == ma_format_f32) {
-        pHPF->a.f32 = (float)a;
-    } else {
-        pHPF->a.s32 = ma_biquad_float_to_fp(a);
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hpf1_process_pcm_frame_f32(ma_hpf1* pHPF, float* pY, const float* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pHPF->channels;
-    const float a = 1 - pHPF->a.f32;
-    const float b = 1 - a;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float r1 = pHPF->r1[c].f32;
-        float x  = pX[c];
-        float y;
-
-        y = b*x - a*r1;
-
-        pY[c]           = y;
-        pHPF->r1[c].f32 = y;
-    }
-}
-
-static MA_INLINE void ma_hpf1_process_pcm_frame_s16(ma_hpf1* pHPF, ma_int16* pY, const ma_int16* pX)
-{
-    ma_uint32 c;
-    const ma_uint32 channels = pHPF->channels;
-    const ma_int32 a = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - pHPF->a.s32);
-    const ma_int32 b = ((1 << MA_BIQUAD_FIXED_POINT_SHIFT) - a);
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int32 r1 = pHPF->r1[c].s32;
-        ma_int32 x  = pX[c];
-        ma_int32 y;
-
-        y = (b*x - a*r1) >> MA_BIQUAD_FIXED_POINT_SHIFT;
-
-        pY[c]           = (ma_int16)y;
-        pHPF->r1[c].s32 = (ma_int32)y;
-    }
-}
-
-MA_API ma_result ma_hpf1_process_pcm_frames(ma_hpf1* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 n;
-
-    if (pHPF == NULL || pFramesOut == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Note that the logic below needs to support in-place filtering. That is, it must support the case where pFramesOut and pFramesIn are the same. */
-
-    if (pHPF->format == ma_format_f32) {
-        /* */ float* pY = (      float*)pFramesOut;
-        const float* pX = (const float*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_hpf1_process_pcm_frame_f32(pHPF, pY, pX);
-            pY += pHPF->channels;
-            pX += pHPF->channels;
-        }
-    } else if (pHPF->format == ma_format_s16) {
-        /* */ ma_int16* pY = (      ma_int16*)pFramesOut;
-        const ma_int16* pX = (const ma_int16*)pFramesIn;
-
-        for (n = 0; n < frameCount; n += 1) {
-            ma_hpf1_process_pcm_frame_s16(pHPF, pY, pX);
-            pY += pHPF->channels;
-            pX += pHPF->channels;
-        }
-    } else {
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS; /* Format not supported. Should never hit this because it's checked in ma_biquad_init() and ma_biquad_reinit(). */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_hpf1_get_latency(const ma_hpf1* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return 1;
-}
-
-
-static MA_INLINE ma_biquad_config ma_hpf2__get_biquad_config(const ma_hpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  (1 + c) / 2;
-    bqConfig.b1 = -(1 + c);
-    bqConfig.b2 =  (1 + c) / 2;
-    bqConfig.a0 =   1 + a;
-    bqConfig.a1 =  -2 * c;
-    bqConfig.a2 =   1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_hpf2_init(const ma_hpf2_config* pConfig, ma_hpf2* pHPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pHPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hpf2_reinit(const ma_hpf2_config* pConfig, ma_hpf2* pHPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pHPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hpf2_process_pcm_frame_s16(ma_hpf2* pHPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pHPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_hpf2_process_pcm_frame_f32(ma_hpf2* pHPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pHPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_hpf2_process_pcm_frames(ma_hpf2* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pHPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_hpf2_get_latency(const ma_hpf2* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pHPF->bq);
-}
-
-
-MA_API ma_hpf_config ma_hpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_hpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_hpf_reinit__internal(const ma_hpf_config* pConfig, ma_hpf* pHPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 hpf1Count;
-    ma_uint32 hpf2Count;
-    ma_uint32 ihpf1;
-    ma_uint32 ihpf2;
-
-    if (pHPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pHPF->format != ma_format_unknown && pHPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pHPF->channels != 0 && pHPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    hpf1Count = pConfig->order % 2;
-    hpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(hpf1Count <= ma_countof(pHPF->hpf1));
-    MA_ASSERT(hpf2Count <= ma_countof(pHPF->hpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pHPF->hpf1Count != hpf1Count || pHPF->hpf2Count != hpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ihpf1 = 0; ihpf1 < hpf1Count; ihpf1 += 1) {
-        ma_hpf1_config hpf1Config = ma_hpf1_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency);
-
-        if (isNew) {
-            result = ma_hpf1_init(&hpf1Config, &pHPF->hpf1[ihpf1]);
-        } else {
-            result = ma_hpf1_reinit(&hpf1Config, &pHPF->hpf1[ihpf1]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    for (ihpf2 = 0; ihpf2 < hpf2Count; ihpf2 += 1) {
-        ma_hpf2_config hpf2Config;
-        double q;
-        double a;
-
-        /* Tempting to use 0.707107, but won't result in a Butterworth filter if the order is > 2. */
-        if (hpf1Count == 1) {
-            a = (1 + ihpf2*1) * (MA_PI_D/(pConfig->order*1));   /* Odd order. */
-        } else {
-            a = (1 + ihpf2*2) * (MA_PI_D/(pConfig->order*2));   /* Even order. */
-        }
-        q = 1 / (2*ma_cos(a));
-
-        hpf2Config = ma_hpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_hpf2_init(&hpf2Config, &pHPF->hpf2[ihpf2]);
-        } else {
-            result = ma_hpf2_reinit(&hpf2Config, &pHPF->hpf2[ihpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pHPF->hpf1Count  = hpf1Count;
-    pHPF->hpf2Count  = hpf2Count;
-    pHPF->format     = pConfig->format;
-    pHPF->channels   = pConfig->channels;
-    pHPF->sampleRate = pConfig->sampleRate;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hpf_init(const ma_hpf_config* pConfig, ma_hpf* pHPF)
-{
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pHPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_hpf_reinit__internal(pConfig, pHPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_hpf_reinit(const ma_hpf_config* pConfig, ma_hpf* pHPF)
-{
-    return ma_hpf_reinit__internal(pConfig, pHPF, /*isNew*/MA_FALSE);
-}
-
-MA_API ma_result ma_hpf_process_pcm_frames(ma_hpf* pHPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ihpf1;
-    ma_uint32 ihpf2;
-
-    if (pHPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-            result = ma_hpf1_process_pcm_frames(&pHPF->hpf1[ihpf1], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-
-        for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-            result = ma_hpf2_process_pcm_frames(&pHPF->hpf2[ihpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pHPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pHPF->format, pHPF->channels));
-
-                for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-                    ma_hpf1_process_pcm_frame_f32(&pHPF->hpf1[ihpf1], pFramesOutF32, pFramesOutF32);
-                }
-
-                for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-                    ma_hpf2_process_pcm_frame_f32(&pHPF->hpf2[ihpf2], pFramesOutF32, pFramesOutF32);
-                }
-
-                pFramesOutF32 += pHPF->channels;
-                pFramesInF32  += pHPF->channels;
-            }
-        } else if (pHPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pHPF->format, pHPF->channels));
-
-                for (ihpf1 = 0; ihpf1 < pHPF->hpf1Count; ihpf1 += 1) {
-                    ma_hpf1_process_pcm_frame_s16(&pHPF->hpf1[ihpf1], pFramesOutS16, pFramesOutS16);
-                }
-
-                for (ihpf2 = 0; ihpf2 < pHPF->hpf2Count; ihpf2 += 1) {
-                    ma_hpf2_process_pcm_frame_s16(&pHPF->hpf2[ihpf2], pFramesOutS16, pFramesOutS16);
-                }
-
-                pFramesOutS16 += pHPF->channels;
-                pFramesInS16  += pHPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_hpf_get_latency(const ma_hpf* pHPF)
-{
-    if (pHPF == NULL) {
-        return 0;
-    }
-
-    return pHPF->hpf2Count*2 + pHPF->hpf1Count;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Band-Pass Filtering
-
-**************************************************************************************************************************************************************/
-MA_API ma_bpf2_config ma_bpf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, double q)
-{
-    ma_bpf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.q = q;
-
-    /* Q cannot be 0 or else it'll result in a division by 0. In this case just default to 0.707107. */
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_bpf2__get_biquad_config(const ma_bpf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->cutoffFrequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  q * a;
-    bqConfig.b1 =  0;
-    bqConfig.b2 = -q * a;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_bpf2_init(const ma_bpf2_config* pConfig, ma_bpf2* pBPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_bpf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pBPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_bpf2_reinit(const ma_bpf2_config* pConfig, ma_bpf2* pBPF)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pBPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_bpf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pBPF->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_bpf2_process_pcm_frame_s16(ma_bpf2* pBPF, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pBPF->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_bpf2_process_pcm_frame_f32(ma_bpf2* pBPF, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pBPF->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_bpf2_process_pcm_frames(ma_bpf2* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pBPF->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_bpf2_get_latency(const ma_bpf2* pBPF)
-{
-    if (pBPF == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pBPF->bq);
-}
-
-
-MA_API ma_bpf_config ma_bpf_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double cutoffFrequency, ma_uint32 order)
-{
-    ma_bpf_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format          = format;
-    config.channels        = channels;
-    config.sampleRate      = sampleRate;
-    config.cutoffFrequency = cutoffFrequency;
-    config.order           = ma_min(order, MA_MAX_FILTER_ORDER);
-
-    return config;
-}
-
-static ma_result ma_bpf_reinit__internal(const ma_bpf_config* pConfig, ma_bpf* pBPF, ma_bool32 isNew)
-{
-    ma_result result;
-    ma_uint32 bpf2Count;
-    ma_uint32 ibpf2;
-
-    if (pBPF == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Only supporting f32 and s16. */
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The format cannot be changed after initialization. */
-    if (pBPF->format != ma_format_unknown && pBPF->format != pConfig->format) {
-        return MA_INVALID_OPERATION;
-    }
-
-    /* The channel count cannot be changed after initialization. */
-    if (pBPF->channels != 0 && pBPF->channels != pConfig->channels) {
-        return MA_INVALID_OPERATION;
-    }
-
-    if (pConfig->order > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* We must have an even number of order. */
-    if ((pConfig->order & 0x1) != 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    bpf2Count = pConfig->order / 2;
-
-    MA_ASSERT(bpf2Count <= ma_countof(pBPF->bpf2));
-
-    /* The filter order can't change between reinits. */
-    if (!isNew) {
-        if (pBPF->bpf2Count != bpf2Count) {
-            return MA_INVALID_OPERATION;
-        }
-    }
-
-    for (ibpf2 = 0; ibpf2 < bpf2Count; ibpf2 += 1) {
-        ma_bpf2_config bpf2Config;
-        double q;
-
-        /* TODO: Calculate Q to make this a proper Butterworth filter. */
-        q = 0.707107;
-
-        bpf2Config = ma_bpf2_config_init(pConfig->format, pConfig->channels, pConfig->sampleRate, pConfig->cutoffFrequency, q);
-
-        if (isNew) {
-            result = ma_bpf2_init(&bpf2Config, &pBPF->bpf2[ibpf2]);
-        } else {
-            result = ma_bpf2_reinit(&bpf2Config, &pBPF->bpf2[ibpf2]);
-        }
-
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    pBPF->bpf2Count = bpf2Count;
-    pBPF->format    = pConfig->format;
-    pBPF->channels  = pConfig->channels;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_bpf_init(const ma_bpf_config* pConfig, ma_bpf* pBPF)
-{
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pBPF);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_bpf_reinit__internal(pConfig, pBPF, /*isNew*/MA_TRUE);
-}
-
-MA_API ma_result ma_bpf_reinit(const ma_bpf_config* pConfig, ma_bpf* pBPF)
-{
-    return ma_bpf_reinit__internal(pConfig, pBPF, /*isNew*/MA_FALSE);
-}
-
-MA_API ma_result ma_bpf_process_pcm_frames(ma_bpf* pBPF, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint32 ibpf2;
-
-    if (pBPF == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Faster path for in-place. */
-    if (pFramesOut == pFramesIn) {
-        for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-            result = ma_bpf2_process_pcm_frames(&pBPF->bpf2[ibpf2], pFramesOut, pFramesOut, frameCount);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        }
-    }
-
-    /* Slightly slower path for copying. */
-    if (pFramesOut != pFramesIn) {
-        ma_uint32 iFrame;
-
-        /*  */ if (pBPF->format == ma_format_f32) {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutF32, pFramesInF32, ma_get_bytes_per_frame(pBPF->format, pBPF->channels));
-
-                for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-                    ma_bpf2_process_pcm_frame_f32(&pBPF->bpf2[ibpf2], pFramesOutF32, pFramesOutF32);
-                }
-
-                pFramesOutF32 += pBPF->channels;
-                pFramesInF32  += pBPF->channels;
-            }
-        } else if (pBPF->format == ma_format_s16) {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                MA_COPY_MEMORY(pFramesOutS16, pFramesInS16, ma_get_bytes_per_frame(pBPF->format, pBPF->channels));
-
-                for (ibpf2 = 0; ibpf2 < pBPF->bpf2Count; ibpf2 += 1) {
-                    ma_bpf2_process_pcm_frame_s16(&pBPF->bpf2[ibpf2], pFramesOutS16, pFramesOutS16);
-                }
-
-                pFramesOutS16 += pBPF->channels;
-                pFramesInS16  += pBPF->channels;
-            }
-        } else {
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;    /* Should never hit this. */
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint32 ma_bpf_get_latency(const ma_bpf* pBPF)
-{
-    if (pBPF == NULL) {
-        return 0;
-    }
-
-    return pBPF->bpf2Count*2;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Notching Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_notch2_config ma_notch2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double q, double frequency)
-{
-    ma_notch2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.q          = q;
-    config.frequency  = frequency;
-
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_notch2__get_biquad_config(const ma_notch2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-
-    bqConfig.b0 =  1;
-    bqConfig.b1 = -2 * c;
-    bqConfig.b2 =  1;
-    bqConfig.a0 =  1 + a;
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - a;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_notch2_init(const ma_notch2_config* pConfig, ma_notch2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_notch2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_notch2_reinit(const ma_notch2_config* pConfig, ma_notch2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_notch2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_notch2_process_pcm_frame_s16(ma_notch2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_notch2_process_pcm_frame_f32(ma_notch2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_notch2_process_pcm_frames(ma_notch2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_notch2_get_latency(const ma_notch2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Peaking EQ Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_peak2_config ma_peak2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double q, double frequency)
-{
-    ma_peak2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.q          = q;
-    config.frequency  = frequency;
-
-    if (config.q == 0) {
-        config.q = 0.707107;
-    }
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_peak2__get_biquad_config(const ma_peak2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double q;
-    double w;
-    double s;
-    double c;
-    double a;
-    double A;
-
-    MA_ASSERT(pConfig != NULL);
-
-    q = pConfig->q;
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    a = s / (2*q);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-
-    bqConfig.b0 =  1 + (a * A);
-    bqConfig.b1 = -2 * c;
-    bqConfig.b2 =  1 - (a * A);
-    bqConfig.a0 =  1 + (a / A);
-    bqConfig.a1 = -2 * c;
-    bqConfig.a2 =  1 - (a / A);
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_peak2_init(const ma_peak2_config* pConfig, ma_peak2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_peak2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_peak2_reinit(const ma_peak2_config* pConfig, ma_peak2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_peak2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_peak2_process_pcm_frame_s16(ma_peak2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_peak2_process_pcm_frame_f32(ma_peak2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_peak2_process_pcm_frames(ma_peak2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_peak2_get_latency(const ma_peak2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-/**************************************************************************************************************************************************************
-
-Low Shelf Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_loshelf2_config ma_loshelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency)
-{
-    ma_loshelf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.shelfSlope = shelfSlope;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_loshelf2__get_biquad_config(const ma_loshelf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double w;
-    double s;
-    double c;
-    double A;
-    double S;
-    double a;
-    double sqrtA;
-
-    MA_ASSERT(pConfig != NULL);
-
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-    S = pConfig->shelfSlope;
-    a = s/2 * ma_sqrt((A + 1/A) * (1/S - 1) + 2);
-    sqrtA = 2*ma_sqrt(A)*a;
-
-    bqConfig.b0 =  A * ((A + 1) - (A - 1)*c + sqrtA);
-    bqConfig.b1 =  2 * A * ((A - 1) - (A + 1)*c);
-    bqConfig.b2 =  A * ((A + 1) - (A - 1)*c - sqrtA);
-    bqConfig.a0 =  (A + 1) + (A - 1)*c + sqrtA;
-    bqConfig.a1 = -2 * ((A - 1) + (A + 1)*c);
-    bqConfig.a2 =  (A + 1) + (A - 1)*c - sqrtA;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_loshelf2_init(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_loshelf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_loshelf2_reinit(const ma_loshelf2_config* pConfig, ma_loshelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_loshelf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_loshelf2_process_pcm_frame_s16(ma_loshelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_loshelf2_process_pcm_frame_f32(ma_loshelf2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_loshelf2_process_pcm_frames(ma_loshelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_loshelf2_get_latency(const ma_loshelf2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-/**************************************************************************************************************************************************************
-
-High Shelf Filter
-
-**************************************************************************************************************************************************************/
-MA_API ma_hishelf2_config ma_hishelf2_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, double gainDB, double shelfSlope, double frequency)
-{
-    ma_hishelf2_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.gainDB     = gainDB;
-    config.shelfSlope = shelfSlope;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-
-static MA_INLINE ma_biquad_config ma_hishelf2__get_biquad_config(const ma_hishelf2_config* pConfig)
-{
-    ma_biquad_config bqConfig;
-    double w;
-    double s;
-    double c;
-    double A;
-    double S;
-    double a;
-    double sqrtA;
-
-    MA_ASSERT(pConfig != NULL);
-
-    w = 2 * MA_PI_D * pConfig->frequency / pConfig->sampleRate;
-    s = ma_sin(w);
-    c = ma_cos(w);
-    A = ma_pow(10, (pConfig->gainDB / 40));
-    S = pConfig->shelfSlope;
-    a = s/2 * ma_sqrt((A + 1/A) * (1/S - 1) + 2);
-    sqrtA = 2*ma_sqrt(A)*a;
-
-    bqConfig.b0 =  A * ((A + 1) + (A - 1)*c + sqrtA);
-    bqConfig.b1 = -2 * A * ((A - 1) + (A + 1)*c);
-    bqConfig.b2 =  A * ((A + 1) + (A - 1)*c - sqrtA);
-    bqConfig.a0 =  (A + 1) - (A - 1)*c + sqrtA;
-    bqConfig.a1 =  2 * ((A - 1) - (A + 1)*c);
-    bqConfig.a2 =  (A + 1) - (A - 1)*c - sqrtA;
-
-    bqConfig.format   = pConfig->format;
-    bqConfig.channels = pConfig->channels;
-
-    return bqConfig;
-}
-
-MA_API ma_result ma_hishelf2_init(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pFilter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hishelf2__get_biquad_config(pConfig);
-    result = ma_biquad_init(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_hishelf2_reinit(const ma_hishelf2_config* pConfig, ma_hishelf2* pFilter)
-{
-    ma_result result;
-    ma_biquad_config bqConfig;
-
-    if (pFilter == NULL || pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    bqConfig = ma_hishelf2__get_biquad_config(pConfig);
-    result = ma_biquad_reinit(&bqConfig, &pFilter->bq);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static MA_INLINE void ma_hishelf2_process_pcm_frame_s16(ma_hishelf2* pFilter, ma_int16* pFrameOut, const ma_int16* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_s16(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-static MA_INLINE void ma_hishelf2_process_pcm_frame_f32(ma_hishelf2* pFilter, float* pFrameOut, const float* pFrameIn)
-{
-    ma_biquad_process_pcm_frame_f32(&pFilter->bq, pFrameOut, pFrameIn);
-}
-
-MA_API ma_result ma_hishelf2_process_pcm_frames(ma_hishelf2* pFilter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pFilter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_biquad_process_pcm_frames(&pFilter->bq, pFramesOut, pFramesIn, frameCount);
-}
-
-MA_API ma_uint32 ma_hishelf2_get_latency(const ma_hishelf2* pFilter)
-{
-    if (pFilter == NULL) {
-        return 0;
-    }
-
-    return ma_biquad_get_latency(&pFilter->bq);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Resampling
-
-**************************************************************************************************************************************************************/
-MA_API ma_linear_resampler_config ma_linear_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    ma_linear_resampler_config config;
-    MA_ZERO_OBJECT(&config);
-    config.format           = format;
-    config.channels         = channels;
-    config.sampleRateIn     = sampleRateIn;
-    config.sampleRateOut    = sampleRateOut;
-    config.lpfOrder         = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.lpfNyquistFactor = 1;
-
-    return config;
-}
-
-static void ma_linear_resampler_adjust_timer_for_new_rate(ma_linear_resampler* pResampler, ma_uint32 oldSampleRateOut, ma_uint32 newSampleRateOut)
-{
-    /*
-    So what's happening here? Basically we need to adjust the fractional component of the time advance based on the new rate. The old time advance will
-    be based on the old sample rate, but we are needing to adjust it to that it's based on the new sample rate.
-    */
-    ma_uint32 oldRateTimeWhole = pResampler->inTimeFrac / oldSampleRateOut;  /* <-- This should almost never be anything other than 0, but leaving it here to make this more general and robust just in case. */
-    ma_uint32 oldRateTimeFract = pResampler->inTimeFrac % oldSampleRateOut;
-
-    pResampler->inTimeFrac =
-         (oldRateTimeWhole * newSampleRateOut) +
-        ((oldRateTimeFract * newSampleRateOut) / oldSampleRateOut);
-
-    /* Make sure the fractional part is less than the output sample rate. */
-    pResampler->inTimeInt += pResampler->inTimeFrac / pResampler->config.sampleRateOut;
-    pResampler->inTimeFrac = pResampler->inTimeFrac % pResampler->config.sampleRateOut;
-}
-
-static ma_result ma_linear_resampler_set_rate_internal(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_bool32 isResamplerAlreadyInitialized)
-{
-    ma_result result;
-    ma_uint32 gcf;
-    ma_uint32 lpfSampleRate;
-    double lpfCutoffFrequency;
-    ma_lpf_config lpfConfig;
-    ma_uint32 oldSampleRateOut; /* Required for adjusting time advance down the bottom. */
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (sampleRateIn == 0 || sampleRateOut == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    oldSampleRateOut = pResampler->config.sampleRateOut;
-
-    pResampler->config.sampleRateIn  = sampleRateIn;
-    pResampler->config.sampleRateOut = sampleRateOut;
-
-    /* Simplify the sample rate. */
-    gcf = ma_gcf_u32(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut);
-    pResampler->config.sampleRateIn  /= gcf;
-    pResampler->config.sampleRateOut /= gcf;
-
-    /* Always initialize the low-pass filter, even when the order is 0. */
-    if (pResampler->config.lpfOrder > MA_MAX_FILTER_ORDER) {
-        return MA_INVALID_ARGS;
-    }
-
-    lpfSampleRate      = (ma_uint32)(ma_max(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut));
-    lpfCutoffFrequency = (   double)(ma_min(pResampler->config.sampleRateIn, pResampler->config.sampleRateOut) * 0.5 * pResampler->config.lpfNyquistFactor);
-
-    lpfConfig = ma_lpf_config_init(pResampler->config.format, pResampler->config.channels, lpfSampleRate, lpfCutoffFrequency, pResampler->config.lpfOrder);
-
-    /*
-    If the resampler is alreay initialized we don't want to do a fresh initialization of the low-pass filter because it will result in the cached frames
-    getting cleared. Instead we re-initialize the filter which will maintain any cached frames.
-    */
-    if (isResamplerAlreadyInitialized) {
-        result = ma_lpf_reinit(&lpfConfig, &pResampler->lpf);
-    } else {
-        result = ma_lpf_init(&lpfConfig, &pResampler->lpf);
-    }
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-
-    pResampler->inAdvanceInt  = pResampler->config.sampleRateIn / pResampler->config.sampleRateOut;
-    pResampler->inAdvanceFrac = pResampler->config.sampleRateIn % pResampler->config.sampleRateOut;
-
-    /* Our timer was based on the old rate. We need to adjust it so that it's based on the new rate. */
-    ma_linear_resampler_adjust_timer_for_new_rate(pResampler, oldSampleRateOut, pResampler->config.sampleRateOut);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_linear_resampler_init(const ma_linear_resampler_config* pConfig, ma_linear_resampler* pResampler)
-{
-    ma_result result;
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pResampler);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config = *pConfig;
-
-    /* Setting the rate will set up the filter and time advances for us. */
-    result = ma_linear_resampler_set_rate_internal(pResampler, pConfig->sampleRateIn, pConfig->sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_FALSE);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pResampler->inTimeInt  = 1;  /* Set this to one to force an input sample to always be loaded for the first output frame. */
-    pResampler->inTimeFrac = 0;
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_linear_resampler_uninit(ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return;
-    }
-}
-
-static MA_INLINE ma_int16 ma_linear_resampler_mix_s16(ma_int16 x, ma_int16 y, ma_int32 a, const ma_int32 shift)
-{
-    ma_int32 b;
-    ma_int32 c;
-    ma_int32 r;
-
-    MA_ASSERT(a <= (1<<shift));
-
-    b = x * ((1<<shift) - a);
-    c = y * a;
-    r = b + c;
-
-    return (ma_int16)(r >> shift);
-}
-
-static void ma_linear_resampler_interpolate_frame_s16(ma_linear_resampler* pResampler, ma_int16* MA_RESTRICT pFrameOut)
-{
-    ma_uint32 c;
-    ma_uint32 a;
-    const ma_uint32 channels = pResampler->config.channels;
-    const ma_uint32 shift = 12;
-
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFrameOut  != NULL);
-
-    a = (pResampler->inTimeFrac << shift) / pResampler->config.sampleRateOut;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        ma_int16 s = ma_linear_resampler_mix_s16(pResampler->x0.s16[c], pResampler->x1.s16[c], a, shift);
-        pFrameOut[c] = s;
-    }
-}
-
-
-static void ma_linear_resampler_interpolate_frame_f32(ma_linear_resampler* pResampler, float* MA_RESTRICT pFrameOut)
-{
-    ma_uint32 c;
-    float a;
-    const ma_uint32 channels = pResampler->config.channels;
-
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFrameOut  != NULL);
-
-    a = (float)pResampler->inTimeFrac / pResampler->config.sampleRateOut;
-
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-    for (c = 0; c < channels; c += 1) {
-        float s = ma_mix_f32_fast(pResampler->x0.f32[c], pResampler->x1.f32[c], a);
-        pFrameOut[c] = s;
-    }
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const ma_int16* pFramesInS16;
-    /* */ ma_int16* pFramesOutS16;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInS16       = (const ma_int16*)pFramesIn;
-    pFramesOutS16      = (      ma_int16*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInS16 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = pFramesInS16[iChannel];
-                }
-                pFramesInS16 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = 0;
-                }
-            }
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pResampler->x1.s16, pResampler->x1.s16);
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */
-        if (pFramesOutS16 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16);
-
-            pFramesOutS16 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const ma_int16* pFramesInS16;
-    /* */ ma_int16* pFramesOutS16;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInS16       = (const ma_int16*)pFramesIn;
-    pFramesOutS16      = (      ma_int16*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInS16 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = pFramesInS16[iChannel];
-                }
-                pFramesInS16 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.s16[iChannel] = pResampler->x1.s16[iChannel];
-                    pResampler->x1.s16[iChannel] = 0;
-                }
-            }
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and we can generate the next output frame. */
-        if (pFramesOutS16 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_s16(pResampler, pFramesOutS16);
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_s16(&pResampler->lpf, pFramesOutS16, pFramesOutS16);
-
-            pFramesOutS16 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_s16(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) {
-        return ma_linear_resampler_process_pcm_frames_s16_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        return ma_linear_resampler_process_pcm_frames_s16_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32_downsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const float* pFramesInF32;
-    /* */ float* pFramesOutF32;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInF32       = (const float*)pFramesIn;
-    pFramesOutF32      = (      float*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. When doing this we need to ensure we run every input sample through the filter. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInF32 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = pFramesInF32[iChannel];
-                }
-                pFramesInF32 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = 0;
-                }
-            }
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pResampler->x1.f32, pResampler->x1.f32);
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and filtered and we can generate the next output frame. */
-        if (pFramesOutF32 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32);
-
-            pFramesOutF32 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32_upsample(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    const float* pFramesInF32;
-    /* */ float* pFramesOutF32;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-
-    pFramesInF32       = (const float*)pFramesIn;
-    pFramesOutF32      = (      float*)pFramesOut;
-    frameCountIn       = *pFrameCountIn;
-    frameCountOut      = *pFrameCountOut;
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        /* Before interpolating we need to load the buffers. */
-        while (pResampler->inTimeInt > 0 && frameCountIn > framesProcessedIn) {
-            ma_uint32 iChannel;
-
-            if (pFramesInF32 != NULL) {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = pFramesInF32[iChannel];
-                }
-                pFramesInF32 += pResampler->config.channels;
-            } else {
-                for (iChannel = 0; iChannel < pResampler->config.channels; iChannel += 1) {
-                    pResampler->x0.f32[iChannel] = pResampler->x1.f32[iChannel];
-                    pResampler->x1.f32[iChannel] = 0;
-                }
-            }
-
-            framesProcessedIn     += 1;
-            pResampler->inTimeInt -= 1;
-        }
-
-        if (pResampler->inTimeInt > 0) {
-            break;  /* Ran out of input data. */
-        }
-
-        /* Getting here means the frames have been loaded and we can generate the next output frame. */
-        if (pFramesOutF32 != NULL) {
-            MA_ASSERT(pResampler->inTimeInt == 0);
-            ma_linear_resampler_interpolate_frame_f32(pResampler, pFramesOutF32);
-
-            /* Filter. */
-            ma_lpf_process_pcm_frame_f32(&pResampler->lpf, pFramesOutF32, pFramesOutF32);
-
-            pFramesOutF32 += pResampler->config.channels;
-        }
-
-        framesProcessedOut += 1;
-
-        /* Advance time forward. */
-        pResampler->inTimeInt  += pResampler->inAdvanceInt;
-        pResampler->inTimeFrac += pResampler->inAdvanceFrac;
-        if (pResampler->inTimeFrac >= pResampler->config.sampleRateOut) {
-            pResampler->inTimeFrac -= pResampler->config.sampleRateOut;
-            pResampler->inTimeInt  += 1;
-        }
-    }
-
-    *pFrameCountIn  = framesProcessedIn;
-    *pFrameCountOut = framesProcessedOut;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_linear_resampler_process_pcm_frames_f32(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    if (pResampler->config.sampleRateIn > pResampler->config.sampleRateOut) {
-        return ma_linear_resampler_process_pcm_frames_f32_downsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        return ma_linear_resampler_process_pcm_frames_f32_upsample(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-
-MA_API ma_result ma_linear_resampler_process_pcm_frames(ma_linear_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /*  */ if (pResampler->config.format == ma_format_s16) {
-        return ma_linear_resampler_process_pcm_frames_s16(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else if (pResampler->config.format == ma_format_f32) {
-        return ma_linear_resampler_process_pcm_frames_f32(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Should never get here. Getting here means the format is not supported and you didn't check the return value of ma_linear_resampler_init(). */
-        MA_ASSERT(MA_FALSE);
-        return MA_INVALID_ARGS;
-    }
-}
-
-
-MA_API ma_result ma_linear_resampler_set_rate(ma_linear_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    return ma_linear_resampler_set_rate_internal(pResampler, sampleRateIn, sampleRateOut, /* isResamplerAlreadyInitialized = */ MA_TRUE);
-}
-
-MA_API ma_result ma_linear_resampler_set_rate_ratio(ma_linear_resampler* pResampler, float ratioInOut)
-{
-    ma_uint32 n;
-    ma_uint32 d;
-
-    d = 1000;
-    n = (ma_uint32)(ratioInOut * d);
-
-    if (n == 0) {
-        return MA_INVALID_ARGS; /* Ratio too small. */
-    }
-
-    MA_ASSERT(n != 0);
-
-    return ma_linear_resampler_set_rate(pResampler, n, d);
-}
-
-
-MA_API ma_uint64 ma_linear_resampler_get_required_input_frame_count(const ma_linear_resampler* pResampler, ma_uint64 outputFrameCount)
-{
-    ma_uint64 inputFrameCount;
-
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    if (outputFrameCount == 0) {
-        return 0;
-    }
-
-    /* Any whole input frames are consumed before the first output frame is generated. */
-    inputFrameCount = pResampler->inTimeInt;
-    outputFrameCount -= 1;
-
-    /* The rest of the output frames can be calculated in constant time. */
-    inputFrameCount += outputFrameCount * pResampler->inAdvanceInt;
-    inputFrameCount += (pResampler->inTimeFrac + (outputFrameCount * pResampler->inAdvanceFrac)) / pResampler->config.sampleRateOut;
-
-    return inputFrameCount;
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_expected_output_frame_count(const ma_linear_resampler* pResampler, ma_uint64 inputFrameCount)
-{
-    ma_uint64 outputFrameCount;
-    ma_uint64 preliminaryInputFrameCountFromFrac;
-    ma_uint64 preliminaryInputFrameCount;
-
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    /*
-    The first step is to get a preliminary output frame count. This will either be exactly equal to what we need, or less by 1. We need to
-    determine how many input frames will be consumed by this value. If it's greater than our original input frame count it means we won't
-    be able to generate an extra frame because we will have run out of input data. Otherwise we will have enough input for the generation
-    of an extra output frame. This add-by-one logic is necessary due to how the data loading logic works when processing frames.
-    */
-    outputFrameCount = (inputFrameCount * pResampler->config.sampleRateOut) / pResampler->config.sampleRateIn;
-
-    /*
-    We need to determine how many *whole* input frames will have been processed to generate our preliminary output frame count. This is
-    used in the logic below to determine whether or not we need to add an extra output frame.
-    */
-    preliminaryInputFrameCountFromFrac = (pResampler->inTimeFrac + outputFrameCount*pResampler->inAdvanceFrac) / pResampler->config.sampleRateOut;
-    preliminaryInputFrameCount         = (pResampler->inTimeInt  + outputFrameCount*pResampler->inAdvanceInt ) + preliminaryInputFrameCountFromFrac;
-
-    /*
-    If the total number of *whole* input frames that would be required to generate our preliminary output frame count is greather than
-    the amount of whole input frames we have available as input we need to *not* add an extra output frame as there won't be enough data
-    to actually process. Otherwise we need to add the extra output frame.
-    */
-    if (preliminaryInputFrameCount <= inputFrameCount) {
-        outputFrameCount += 1;
-    }
-
-    return outputFrameCount;
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_input_latency(const ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    return 1 + ma_lpf_get_latency(&pResampler->lpf);
-}
-
-MA_API ma_uint64 ma_linear_resampler_get_output_latency(const ma_linear_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    return ma_linear_resampler_get_input_latency(pResampler) * pResampler->config.sampleRateOut / pResampler->config.sampleRateIn;
-}
-
-
-#if defined(ma_speex_resampler_h)
-#define MA_HAS_SPEEX_RESAMPLER
-
-static ma_result ma_result_from_speex_err(int err)
-{
-    switch (err)
-    {
-        case RESAMPLER_ERR_SUCCESS:      return MA_SUCCESS;
-        case RESAMPLER_ERR_ALLOC_FAILED: return MA_OUT_OF_MEMORY;
-        case RESAMPLER_ERR_BAD_STATE:    return MA_ERROR;
-        case RESAMPLER_ERR_INVALID_ARG:  return MA_INVALID_ARGS;
-        case RESAMPLER_ERR_PTR_OVERLAP:  return MA_INVALID_ARGS;
-        case RESAMPLER_ERR_OVERFLOW:     return MA_ERROR;
-        default: return MA_ERROR;
-    }
-}
-#endif  /* ma_speex_resampler_h */
-
-MA_API ma_resampler_config ma_resampler_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut, ma_resample_algorithm algorithm)
-{
-    ma_resampler_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sampleRateIn = sampleRateIn;
-    config.sampleRateOut = sampleRateOut;
-    config.algorithm = algorithm;
-
-    /* Linear. */
-    config.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.linear.lpfNyquistFactor = 1;
-
-    /* Speex. */
-    config.speex.quality = 3;   /* Cannot leave this as 0 as that is actually a valid value for Speex resampling quality. */
-
-    return config;
-}
-
-MA_API ma_result ma_resampler_init(const ma_resampler_config* pConfig, ma_resampler* pResampler)
-{
-    ma_result result;
-
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pResampler);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->format != ma_format_f32 && pConfig->format != ma_format_s16) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config = *pConfig;
-
-    switch (pConfig->algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            ma_linear_resampler_config linearConfig;
-            linearConfig = ma_linear_resampler_config_init(pConfig->format, pConfig->channels, pConfig->sampleRateIn, pConfig->sampleRateOut);
-            linearConfig.lpfOrder         = pConfig->linear.lpfOrder;
-            linearConfig.lpfNyquistFactor = pConfig->linear.lpfNyquistFactor;
-
-            result = ma_linear_resampler_init(&linearConfig, &pResampler->state.linear);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            int speexErr;
-            pResampler->state.speex.pSpeexResamplerState = speex_resampler_init(pConfig->channels, pConfig->sampleRateIn, pConfig->sampleRateOut, pConfig->speex.quality, &speexErr);
-            if (pResampler->state.speex.pSpeexResamplerState == NULL) {
-                return ma_result_from_speex_err(speexErr);
-            }
-        #else
-            /* Speex resampler not available. */
-            return MA_NO_BACKEND;
-        #endif
-        } break;
-
-        default: return MA_INVALID_ARGS;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_resampler_uninit(ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return;
-    }
-
-    if (pResampler->config.algorithm == ma_resample_algorithm_linear) {
-        ma_linear_resampler_uninit(&pResampler->state.linear);
-    }
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-    if (pResampler->config.algorithm == ma_resample_algorithm_speex) {
-        speex_resampler_destroy((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-    }
-#endif
-}
-
-static ma_result ma_resampler_process_pcm_frames__read__linear(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    return ma_linear_resampler_process_pcm_frames(&pResampler->state.linear, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-}
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-static ma_result ma_resampler_process_pcm_frames__read__speex(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    int speexErr;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCountIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint64 framesProcessedIn;
-    unsigned int framesPerIteration = UINT_MAX;
-
-    MA_ASSERT(pResampler     != NULL);
-    MA_ASSERT(pFramesOut     != NULL);
-    MA_ASSERT(pFrameCountOut != NULL);
-    MA_ASSERT(pFrameCountIn  != NULL);
-
-    /*
-    Reading from the Speex resampler requires a bit of dancing around for a few reasons. The first thing is that it's frame counts
-    are in unsigned int's whereas ours is in ma_uint64. We therefore need to run the conversion in a loop. The other, more complicated
-    problem, is that we need to keep track of the input time, similar to what we do with the linear resampler. The reason we need to
-    do this is for ma_resampler_get_required_input_frame_count() and ma_resampler_get_expected_output_frame_count().
-    */
-    frameCountOut      = *pFrameCountOut;
-    frameCountIn       = *pFrameCountIn;
-    framesProcessedOut = 0;
-    framesProcessedIn  = 0;
-
-    while (framesProcessedOut < frameCountOut && framesProcessedIn < frameCountIn) {
-        unsigned int frameCountInThisIteration;
-        unsigned int frameCountOutThisIteration;
-        const void* pFramesInThisIteration;
-        void* pFramesOutThisIteration;
-
-        frameCountInThisIteration = framesPerIteration;
-        if ((ma_uint64)frameCountInThisIteration > (frameCountIn - framesProcessedIn)) {
-            frameCountInThisIteration = (unsigned int)(frameCountIn - framesProcessedIn);
-        }
-
-        frameCountOutThisIteration = framesPerIteration;
-        if ((ma_uint64)frameCountOutThisIteration > (frameCountOut - framesProcessedOut)) {
-            frameCountOutThisIteration = (unsigned int)(frameCountOut - framesProcessedOut);
-        }
-
-        pFramesInThisIteration  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels));
-        pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels));
-
-        if (pResampler->config.format == ma_format_f32) {
-            speexErr = speex_resampler_process_interleaved_float((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, (const float*)pFramesInThisIteration, &frameCountInThisIteration, (float*)pFramesOutThisIteration, &frameCountOutThisIteration);
-        } else if (pResampler->config.format == ma_format_s16) {
-            speexErr = speex_resampler_process_interleaved_int((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, (const spx_int16_t*)pFramesInThisIteration, &frameCountInThisIteration, (spx_int16_t*)pFramesOutThisIteration, &frameCountOutThisIteration);
-        } else {
-            /* Format not supported. Should never get here. */
-            MA_ASSERT(MA_FALSE);
-            return MA_INVALID_OPERATION;
-        }
-
-        if (speexErr != RESAMPLER_ERR_SUCCESS) {
-            return ma_result_from_speex_err(speexErr);
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-    }
-
-    *pFrameCountOut = framesProcessedOut;
-    *pFrameCountIn  = framesProcessedIn;
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_resampler_process_pcm_frames__read(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    /* pFramesOut is not NULL, which means we must have a capacity. */
-    if (pFrameCountOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* It doesn't make sense to not have any input frames to process. */
-    if (pFrameCountIn == NULL || pFramesIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_resampler_process_pcm_frames__read__linear(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_resampler_process_pcm_frames__read__speex(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_ARGS;
-}
-
-
-static ma_result ma_resampler_process_pcm_frames__seek__linear(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    /* Seeking is supported natively by the linear resampler. */
-    return ma_linear_resampler_process_pcm_frames(&pResampler->state.linear, pFramesIn, pFrameCountIn, NULL, pFrameCountOut);
-}
-
-#if defined(MA_HAS_SPEEX_RESAMPLER)
-static ma_result ma_resampler_process_pcm_frames__seek__speex(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    /* The generic seek method is implemented in on top of ma_resampler_process_pcm_frames__read() by just processing into a dummy buffer. */
-    float devnull[4096];
-    ma_uint64 totalOutputFramesToProcess;
-    ma_uint64 totalOutputFramesProcessed;
-    ma_uint64 totalInputFramesProcessed;
-    ma_uint32 bpf;
-    ma_result result;
-
-    MA_ASSERT(pResampler != NULL);
-
-    totalOutputFramesProcessed = 0;
-    totalInputFramesProcessed = 0;
-    bpf = ma_get_bytes_per_frame(pResampler->config.format, pResampler->config.channels);
-
-    if (pFrameCountOut != NULL) {
-        /* Seek by output frames. */
-        totalOutputFramesToProcess = *pFrameCountOut;
-    } else {
-        /* Seek by input frames. */
-        MA_ASSERT(pFrameCountIn != NULL);
-        totalOutputFramesToProcess = ma_resampler_get_expected_output_frame_count(pResampler, *pFrameCountIn);
-    }
-
-    if (pFramesIn != NULL) {
-        /* Process input data. */
-        MA_ASSERT(pFrameCountIn != NULL);
-        while (totalOutputFramesProcessed < totalOutputFramesToProcess && totalInputFramesProcessed < *pFrameCountIn) {
-            ma_uint64 inputFramesToProcessThisIteration  = (*pFrameCountIn - totalInputFramesProcessed);
-            ma_uint64 outputFramesToProcessThisIteration = (totalOutputFramesToProcess - totalOutputFramesProcessed);
-            if (outputFramesToProcessThisIteration > sizeof(devnull) / bpf) {
-                outputFramesToProcessThisIteration = sizeof(devnull) / bpf;
-            }
-
-            result = ma_resampler_process_pcm_frames__read(pResampler, ma_offset_ptr(pFramesIn, totalInputFramesProcessed*bpf), &inputFramesToProcessThisIteration, ma_offset_ptr(devnull, totalOutputFramesProcessed*bpf), &outputFramesToProcessThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            totalOutputFramesProcessed += outputFramesToProcessThisIteration;
-            totalInputFramesProcessed  += inputFramesToProcessThisIteration;
-        }
-    } else {
-        /* Don't process input data - just update timing and filter state as if zeroes were passed in. */
-        while (totalOutputFramesProcessed < totalOutputFramesToProcess) {
-            ma_uint64 inputFramesToProcessThisIteration  = 16384;
-            ma_uint64 outputFramesToProcessThisIteration = (totalOutputFramesToProcess - totalOutputFramesProcessed);
-            if (outputFramesToProcessThisIteration > sizeof(devnull) / bpf) {
-                outputFramesToProcessThisIteration = sizeof(devnull) / bpf;
-            }
-
-            result = ma_resampler_process_pcm_frames__read(pResampler, NULL, &inputFramesToProcessThisIteration, ma_offset_ptr(devnull, totalOutputFramesProcessed*bpf), &outputFramesToProcessThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            totalOutputFramesProcessed += outputFramesToProcessThisIteration;
-            totalInputFramesProcessed  += inputFramesToProcessThisIteration;
-        }
-    }
-
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = totalInputFramesProcessed;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = totalOutputFramesProcessed;
-    }
-
-    return MA_SUCCESS;
-}
-#endif
-
-static ma_result ma_resampler_process_pcm_frames__seek(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pResampler != NULL);
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_resampler_process_pcm_frames__seek__linear(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_resampler_process_pcm_frames__seek__speex(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-        #else
-            break;
-        #endif
-        };
-
-        default: break;
-    }
-
-    /* Should never hit this. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_ARGS;
-}
-
-
-MA_API ma_result ma_resampler_process_pcm_frames(ma_resampler* pResampler, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFrameCountOut == NULL && pFrameCountIn == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesOut != NULL) {
-        /* Reading. */
-        return ma_resampler_process_pcm_frames__read(pResampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Seeking. */
-        return ma_resampler_process_pcm_frames__seek(pResampler, pFramesIn, pFrameCountIn, pFrameCountOut);
-    }
-}
-
-MA_API ma_result ma_resampler_set_rate(ma_resampler* pResampler, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (sampleRateIn == 0 || sampleRateOut == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pResampler->config.sampleRateIn  = sampleRateIn;
-    pResampler->config.sampleRateOut = sampleRateOut;
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_set_rate(&pResampler->state.linear, sampleRateIn, sampleRateOut);
-        } break;
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return ma_result_from_speex_err(speex_resampler_set_rate((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, sampleRateIn, sampleRateOut));
-        #else
-            break;
-        #endif
-        };
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return MA_INVALID_OPERATION;
-}
-
-MA_API ma_result ma_resampler_set_rate_ratio(ma_resampler* pResampler, float ratio)
-{
-    if (pResampler == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pResampler->config.algorithm == ma_resample_algorithm_linear) {
-        return ma_linear_resampler_set_rate_ratio(&pResampler->state.linear, ratio);
-    } else {
-        /* Getting here means the backend does not have native support for setting the rate as a ratio so we just do it generically. */
-        ma_uint32 n;
-        ma_uint32 d;
-
-        d = 1000;
-        n = (ma_uint32)(ratio * d);
-
-        if (n == 0) {
-            return MA_INVALID_ARGS; /* Ratio too small. */
-        }
-
-        MA_ASSERT(n != 0);
-
-        return ma_resampler_set_rate(pResampler, n, d);
-    }
-}
-
-MA_API ma_uint64 ma_resampler_get_required_input_frame_count(const ma_resampler* pResampler, ma_uint64 outputFrameCount)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    if (outputFrameCount == 0) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_required_input_frame_count(&pResampler->state.linear, outputFrameCount);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            spx_uint64_t count;
-            int speexErr = ma_speex_resampler_get_required_input_frame_count((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, outputFrameCount, &count);
-            if (speexErr != RESAMPLER_ERR_SUCCESS) {
-                return 0;
-            }
-
-            return (ma_uint64)count;
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_expected_output_frame_count(const ma_resampler* pResampler, ma_uint64 inputFrameCount)
-{
-    if (pResampler == NULL) {
-        return 0;   /* Invalid args. */
-    }
-
-    if (inputFrameCount == 0) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_expected_output_frame_count(&pResampler->state.linear, inputFrameCount);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            spx_uint64_t count;
-            int speexErr = ma_speex_resampler_get_expected_output_frame_count((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState, inputFrameCount, &count);
-            if (speexErr != RESAMPLER_ERR_SUCCESS) {
-                return 0;
-            }
-
-            return (ma_uint64)count;
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_input_latency(const ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_input_latency(&pResampler->state.linear);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return (ma_uint64)ma_speex_resampler_get_input_latency((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-MA_API ma_uint64 ma_resampler_get_output_latency(const ma_resampler* pResampler)
-{
-    if (pResampler == NULL) {
-        return 0;
-    }
-
-    switch (pResampler->config.algorithm)
-    {
-        case ma_resample_algorithm_linear:
-        {
-            return ma_linear_resampler_get_output_latency(&pResampler->state.linear);
-        }
-
-        case ma_resample_algorithm_speex:
-        {
-        #if defined(MA_HAS_SPEEX_RESAMPLER)
-            return (ma_uint64)ma_speex_resampler_get_output_latency((SpeexResamplerState*)pResampler->state.speex.pSpeexResamplerState);
-        #else
-            break;
-        #endif
-        }
-
-        default: break;
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-/**************************************************************************************************************************************************************
-
-Channel Conversion
-
-**************************************************************************************************************************************************************/
-#ifndef MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT
-#define MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT  12
-#endif
-
-#define MA_PLANE_LEFT      0
-#define MA_PLANE_RIGHT     1
-#define MA_PLANE_FRONT     2
-#define MA_PLANE_BACK      3
-#define MA_PLANE_BOTTOM    4
-#define MA_PLANE_TOP       5
-
-static float g_maChannelPlaneRatios[MA_CHANNEL_POSITION_COUNT][6] = {
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_NONE */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_MONO */
-    { 0.5f,  0.0f,  0.5f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_LEFT */
-    { 0.0f,  0.5f,  0.5f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_RIGHT */
-    { 0.0f,  0.0f,  1.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_CENTER */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_LFE */
-    { 0.5f,  0.0f,  0.0f,  0.5f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_LEFT */
-    { 0.0f,  0.5f,  0.0f,  0.5f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_RIGHT */
-    { 0.25f, 0.0f,  0.75f, 0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_LEFT_CENTER */
-    { 0.0f,  0.25f, 0.75f, 0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_FRONT_RIGHT_CENTER */
-    { 0.0f,  0.0f,  0.0f,  1.0f,  0.0f,  0.0f},  /* MA_CHANNEL_BACK_CENTER */
-    { 1.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_SIDE_LEFT */
-    { 0.0f,  1.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_SIDE_RIGHT */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  1.0f},  /* MA_CHANNEL_TOP_CENTER */
-    { 0.33f, 0.0f,  0.33f, 0.0f,  0.0f,  0.34f}, /* MA_CHANNEL_TOP_FRONT_LEFT */
-    { 0.0f,  0.0f,  0.5f,  0.0f,  0.0f,  0.5f},  /* MA_CHANNEL_TOP_FRONT_CENTER */
-    { 0.0f,  0.33f, 0.33f, 0.0f,  0.0f,  0.34f}, /* MA_CHANNEL_TOP_FRONT_RIGHT */
-    { 0.33f, 0.0f,  0.0f,  0.33f, 0.0f,  0.34f}, /* MA_CHANNEL_TOP_BACK_LEFT */
-    { 0.0f,  0.0f,  0.0f,  0.5f,  0.0f,  0.5f},  /* MA_CHANNEL_TOP_BACK_CENTER */
-    { 0.0f,  0.33f, 0.0f,  0.33f, 0.0f,  0.34f}, /* MA_CHANNEL_TOP_BACK_RIGHT */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_0 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_1 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_2 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_3 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_4 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_5 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_6 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_7 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_8 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_9 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_10 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_11 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_12 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_13 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_14 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_15 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_16 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_17 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_18 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_19 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_20 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_21 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_22 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_23 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_24 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_25 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_26 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_27 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_28 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_29 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_30 */
-    { 0.0f,  0.0f,  0.0f,  0.0f,  0.0f,  0.0f},  /* MA_CHANNEL_AUX_31 */
-};
-
-static float ma_calculate_channel_position_rectangular_weight(ma_channel channelPositionA, ma_channel channelPositionB)
-{
-    /*
-    Imagine the following simplified example: You have a single input speaker which is the front/left speaker which you want to convert to
-    the following output configuration:
-
-     - front/left
-     - side/left
-     - back/left
-
-    The front/left output is easy - it the same speaker position so it receives the full contribution of the front/left input. The amount
-    of contribution to apply to the side/left and back/left speakers, however, is a bit more complicated.
-
-    Imagine the front/left speaker as emitting audio from two planes - the front plane and the left plane. You can think of the front/left
-    speaker emitting half of it's total volume from the front, and the other half from the left. Since part of it's volume is being emitted
-    from the left side, and the side/left and back/left channels also emit audio from the left plane, one would expect that they would
-    receive some amount of contribution from front/left speaker. The amount of contribution depends on how many planes are shared between
-    the two speakers. Note that in the examples below I've added a top/front/left speaker as an example just to show how the math works
-    across 3 spatial dimensions.
-
-    The first thing to do is figure out how each speaker's volume is spread over each of plane:
-     - front/left:     2 planes (front and left)      = 1/2 = half it's total volume on each plane
-     - side/left:      1 plane (left only)            = 1/1 = entire volume from left plane
-     - back/left:      2 planes (back and left)       = 1/2 = half it's total volume on each plane
-     - top/front/left: 3 planes (top, front and left) = 1/3 = one third it's total volume on each plane
-
-    The amount of volume each channel contributes to each of it's planes is what controls how much it is willing to given and take to other
-    channels on the same plane. The volume that is willing to the given by one channel is multiplied by the volume that is willing to be
-    taken by the other to produce the final contribution.
-    */
-
-    /* Contribution = Sum(Volume to Give * Volume to Take) */
-    float contribution =
-        g_maChannelPlaneRatios[channelPositionA][0] * g_maChannelPlaneRatios[channelPositionB][0] +
-        g_maChannelPlaneRatios[channelPositionA][1] * g_maChannelPlaneRatios[channelPositionB][1] +
-        g_maChannelPlaneRatios[channelPositionA][2] * g_maChannelPlaneRatios[channelPositionB][2] +
-        g_maChannelPlaneRatios[channelPositionA][3] * g_maChannelPlaneRatios[channelPositionB][3] +
-        g_maChannelPlaneRatios[channelPositionA][4] * g_maChannelPlaneRatios[channelPositionB][4] +
-        g_maChannelPlaneRatios[channelPositionA][5] * g_maChannelPlaneRatios[channelPositionB][5];
-
-    return contribution;
-}
-
-MA_API ma_channel_converter_config ma_channel_converter_config_init(ma_format format, ma_uint32 channelsIn, const ma_channel* pChannelMapIn, ma_uint32 channelsOut, const ma_channel* pChannelMapOut, ma_channel_mix_mode mixingMode)
-{
-    ma_channel_converter_config config;
-
-    /* Channel counts need to be clamped. */
-    channelsIn  = ma_min(channelsIn,  ma_countof(config.channelMapIn));
-    channelsOut = ma_min(channelsOut, ma_countof(config.channelMapOut));
-
-    MA_ZERO_OBJECT(&config);
-    config.format      = format;
-    config.channelsIn  = channelsIn;
-    config.channelsOut = channelsOut;
-    ma_channel_map_copy_or_default(config.channelMapIn,  pChannelMapIn,  channelsIn);
-    ma_channel_map_copy_or_default(config.channelMapOut, pChannelMapOut, channelsOut);
-    config.mixingMode  = mixingMode;
-
-    return config;
-}
-
-static ma_int32 ma_channel_converter_float_to_fixed(float x)
-{
-    return (ma_int32)(x * (1<<MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT));
-}
-
-static ma_bool32 ma_is_spatial_channel_position(ma_channel channelPosition)
-{
-    int i;
-
-    if (channelPosition == MA_CHANNEL_NONE || channelPosition == MA_CHANNEL_MONO || channelPosition == MA_CHANNEL_LFE) {
-        return MA_FALSE;
-    }
-
-    for (i = 0; i < 6; ++i) {   /* Each side of a cube. */
-        if (g_maChannelPlaneRatios[channelPosition][i] != 0) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter)
-{
-    ma_uint32 iChannelIn;
-    ma_uint32 iChannelOut;
-
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pConverter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Basic validation for channel counts. */
-    if (pConfig->channelsIn  < MA_MIN_CHANNELS || pConfig->channelsIn  > MA_MAX_CHANNELS ||
-        pConfig->channelsOut < MA_MIN_CHANNELS || pConfig->channelsOut > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (!ma_channel_map_valid(pConfig->channelsIn, pConfig->channelMapIn)) {
-        return MA_INVALID_ARGS; /* Invalid input channel map. */
-    }
-    if (!ma_channel_map_valid(pConfig->channelsOut, pConfig->channelMapOut)) {
-        return MA_INVALID_ARGS; /* Invalid output channel map. */
-    }
-
-    pConverter->format      = pConfig->format;
-    pConverter->channelsIn  = pConfig->channelsIn;
-    pConverter->channelsOut = pConfig->channelsOut;
-    ma_channel_map_copy(pConverter->channelMapIn,  pConfig->channelMapIn,  pConfig->channelsIn);
-    ma_channel_map_copy(pConverter->channelMapOut, pConfig->channelMapOut, pConfig->channelsOut);
-    pConverter->mixingMode  = pConfig->mixingMode;
-
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; iChannelIn += 1) {
-        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-            if (pConverter->format == ma_format_f32) {
-                pConverter->weights.f32[iChannelIn][iChannelOut] = pConfig->weights[iChannelIn][iChannelOut];
-            } else {
-                pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(pConfig->weights[iChannelIn][iChannelOut]);
-            }
-        }
-    }
-
-
-
-    /* If the input and output channels and channel maps are the same we should use a passthrough. */
-    if (pConverter->channelsIn == pConverter->channelsOut) {
-        if (ma_channel_map_equal(pConverter->channelsIn, pConverter->channelMapIn, pConverter->channelMapOut)) {
-            pConverter->isPassthrough = MA_TRUE;
-        }
-        if (ma_channel_map_blank(pConverter->channelsIn, pConverter->channelMapIn) || ma_channel_map_blank(pConverter->channelsOut, pConverter->channelMapOut)) {
-            pConverter->isPassthrough = MA_TRUE;
-        }
-    }
-
-
-    /*
-    We can use a simple case for expanding the mono channel. This will used when expanding a mono input into any output so long
-    as no LFE is present in the output.
-    */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsIn == 1 && pConverter->channelMapIn[0] == MA_CHANNEL_MONO) {
-            /* Optimal case if no LFE is in the output channel map. */
-            pConverter->isSimpleMonoExpansion = MA_TRUE;
-            if (ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->channelMapOut, MA_CHANNEL_LFE)) {
-                pConverter->isSimpleMonoExpansion = MA_FALSE;
-            }
-        }
-    }
-
-    /* Another optimized case is stereo to mono. */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsOut == 1 && pConverter->channelMapOut[0] == MA_CHANNEL_MONO && pConverter->channelsIn == 2) {
-            /* Optimal case if no LFE is in the input channel map. */
-            pConverter->isStereoToMono = MA_TRUE;
-            if (ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->channelMapIn, MA_CHANNEL_LFE)) {
-                pConverter->isStereoToMono = MA_FALSE;
-            }
-        }
-    }
-
-
-    /*
-    Here is where we do a bit of pre-processing to know how each channel should be combined to make up the output. Rules:
-
-        1) If it's a passthrough, do nothing - it's just a simple memcpy().
-        2) If the channel counts are the same and every channel position in the input map is present in the output map, use a
-           simple shuffle. An example might be different 5.1 channel layouts.
-        3) Otherwise channels are blended based on spatial locality.
-    */
-    if (!pConverter->isPassthrough) {
-        if (pConverter->channelsIn == pConverter->channelsOut) {
-            ma_bool32 areAllChannelPositionsPresent = MA_TRUE;
-            for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                ma_bool32 isInputChannelPositionInOutput = MA_FALSE;
-                for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                    if (pConverter->channelMapIn[iChannelIn] == pConverter->channelMapOut[iChannelOut]) {
-                        isInputChannelPositionInOutput = MA_TRUE;
-                        break;
-                    }
-                }
-
-                if (!isInputChannelPositionInOutput) {
-                    areAllChannelPositionsPresent = MA_FALSE;
-                    break;
-                }
-            }
-
-            if (areAllChannelPositionsPresent) {
-                pConverter->isSimpleShuffle = MA_TRUE;
-
-                /*
-                All the router will be doing is rearranging channels which means all we need to do is use a shuffling table which is just
-                a mapping between the index of the input channel to the index of the output channel.
-                */
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        if (pConverter->channelMapIn[iChannelIn] == pConverter->channelMapOut[iChannelOut]) {
-                            pConverter->shuffleTable[iChannelIn] = (ma_uint8)iChannelOut;
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    /*
-    Here is where weights are calculated. Note that we calculate the weights at all times, even when using a passthrough and simple
-    shuffling. We use different algorithms for calculating weights depending on our mixing mode.
-
-    In simple mode we don't do any blending (except for converting between mono, which is done in a later step). Instead we just
-    map 1:1 matching channels. In this mode, if no channels in the input channel map correspond to anything in the output channel
-    map, nothing will be heard!
-    */
-
-    /* In all cases we need to make sure all channels that are present in both channel maps have a 1:1 mapping. */
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-            ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-            if (channelPosIn == channelPosOut) {
-                if (pConverter->format == ma_format_f32) {
-                    pConverter->weights.f32[iChannelIn][iChannelOut] = 1;
-                } else {
-                    pConverter->weights.s16[iChannelIn][iChannelOut] = (1 << MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT);
-                }
-            }
-        }
-    }
-
-    /*
-    The mono channel is accumulated on all other channels, except LFE. Make sure in this loop we exclude output mono channels since
-    they were handled in the pass above.
-    */
-    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-        if (channelPosIn == MA_CHANNEL_MONO) {
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (channelPosOut != MA_CHANNEL_NONE && channelPosOut != MA_CHANNEL_MONO && channelPosOut != MA_CHANNEL_LFE) {
-                    if (pConverter->format == ma_format_f32) {
-                        pConverter->weights.f32[iChannelIn][iChannelOut] = 1;
-                    } else {
-                        pConverter->weights.s16[iChannelIn][iChannelOut] = (1 << MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT);
-                    }
-                }
-            }
-        }
-    }
-
-    /* The output mono channel is the average of all non-none, non-mono and non-lfe input channels. */
-    {
-        ma_uint32 len = 0;
-        for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-            ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-            if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) {
-                len += 1;
-            }
-        }
-
-        if (len > 0) {
-            float monoWeight = 1.0f / len;
-
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (channelPosOut == MA_CHANNEL_MONO) {
-                    for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                        ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                        if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) {
-                            if (pConverter->format == ma_format_f32) {
-                                pConverter->weights.f32[iChannelIn][iChannelOut] = monoWeight;
-                            } else {
-                                pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(monoWeight);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-    /* Input and output channels that are not present on the other side need to be blended in based on spatial locality. */
-    switch (pConverter->mixingMode)
-    {
-        case ma_channel_mix_mode_rectangular:
-        {
-            /* Unmapped input channels. */
-            for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                if (ma_is_spatial_channel_position(channelPosIn)) {
-                    if (!ma_channel_map_contains_channel_position(pConverter->channelsOut, pConverter->channelMapOut, channelPosIn)) {
-                        for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                            ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                            if (ma_is_spatial_channel_position(channelPosOut)) {
-                                float weight = 0;
-                                if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) {
-                                    weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut);
-                                }
-
-                                /* Only apply the weight if we haven't already got some contribution from the respective channels. */
-                                if (pConverter->format == ma_format_f32) {
-                                    if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.f32[iChannelIn][iChannelOut] = weight;
-                                    }
-                                } else {
-                                    if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            /* Unmapped output channels. */
-            for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                ma_channel channelPosOut = pConverter->channelMapOut[iChannelOut];
-
-                if (ma_is_spatial_channel_position(channelPosOut)) {
-                    if (!ma_channel_map_contains_channel_position(pConverter->channelsIn, pConverter->channelMapIn, channelPosOut)) {
-                        for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                            ma_channel channelPosIn = pConverter->channelMapIn[iChannelIn];
-
-                            if (ma_is_spatial_channel_position(channelPosIn)) {
-                                float weight = 0;
-                                if (pConverter->mixingMode == ma_channel_mix_mode_rectangular) {
-                                    weight = ma_calculate_channel_position_rectangular_weight(channelPosIn, channelPosOut);
-                                }
-
-                                /* Only apply the weight if we haven't already got some contribution from the respective channels. */
-                                if (pConverter->format == ma_format_f32) {
-                                    if (pConverter->weights.f32[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.f32[iChannelIn][iChannelOut] = weight;
-                                    }
-                                } else {
-                                    if (pConverter->weights.s16[iChannelIn][iChannelOut] == 0) {
-                                        pConverter->weights.s16[iChannelIn][iChannelOut] = ma_channel_converter_float_to_fixed(weight);
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } break;
-
-        case ma_channel_mix_mode_simple:
-        {
-            /* In simple mode, excess channels need to be silenced or dropped. */
-            ma_uint32 iChannel;
-            for (iChannel = 0; iChannel < ma_min(pConverter->channelsIn, pConverter->channelsOut); iChannel += 1) {
-                if (pConverter->format == ma_format_f32) {
-                    if (pConverter->weights.f32[iChannel][iChannel] == 0) {
-                        pConverter->weights.f32[iChannel][iChannel] = 1;
-                    }
-                } else {
-                    if (pConverter->weights.s16[iChannel][iChannel] == 0) {
-                        pConverter->weights.s16[iChannel][iChannel] = ma_channel_converter_float_to_fixed(1);
-                    }
-                }
-            }
-        } break;
-
-        case ma_channel_mix_mode_custom_weights:
-        default:
-        {
-            /* Fallthrough. */
-        } break;
-    }
-
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_channel_converter_uninit(ma_channel_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return;
-    }
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__passthrough(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-
-    ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__simple_shuffle(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 iFrame;
-    ma_uint32 iChannelIn;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn == pConverter->channelsOut);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutU8[pConverter->shuffleTable[iChannelIn]] = pFramesInU8[iChannelIn];
-                }
-
-                pFramesOutU8 += pConverter->channelsOut;
-                pFramesInU8  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutS16[pConverter->shuffleTable[iChannelIn]] = pFramesInS16[iChannelIn];
-                }
-
-                pFramesOutS16 += pConverter->channelsOut;
-                pFramesInS16  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    ma_uint32 iChannelOut = pConverter->shuffleTable[iChannelIn];
-                    pFramesOutS24[iChannelOut*3 + 0] = pFramesInS24[iChannelIn*3 + 0];
-                    pFramesOutS24[iChannelOut*3 + 1] = pFramesInS24[iChannelIn*3 + 1];
-                    pFramesOutS24[iChannelOut*3 + 2] = pFramesInS24[iChannelIn*3 + 2];
-                }
-
-                pFramesOutS24 += pConverter->channelsOut*3;
-                pFramesInS24  += pConverter->channelsIn*3;
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutS32[pConverter->shuffleTable[iChannelIn]] = pFramesInS32[iChannelIn];
-                }
-
-                pFramesOutS32 += pConverter->channelsOut;
-                pFramesInS32  += pConverter->channelsIn;
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    pFramesOutF32[pConverter->shuffleTable[iChannelIn]] = pFramesInF32[iChannelIn];
-                }
-
-                pFramesOutF32 += pConverter->channelsOut;
-                pFramesInF32  += pConverter->channelsIn;
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__simple_mono_expansion(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn == 1);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    pFramesOutU8[iFrame*pConverter->channelsOut + iChannel] = pFramesInU8[iFrame];
-                }
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            if (pConverter->channelsOut == 2) {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    pFramesOutS16[iFrame*2 + 0] = pFramesInS16[iFrame];
-                    pFramesOutS16[iFrame*2 + 1] = pFramesInS16[iFrame];
-                }
-            } else {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    ma_uint32 iChannel;
-                    for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                        pFramesOutS16[iFrame*pConverter->channelsOut + iChannel] = pFramesInS16[iFrame];
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    ma_uint64 iSampleOut = iFrame*pConverter->channelsOut + iChannel;
-                    ma_uint64 iSampleIn  = iFrame;
-                    pFramesOutS24[iSampleOut*3 + 0] = pFramesInS24[iSampleIn*3 + 0];
-                    pFramesOutS24[iSampleOut*3 + 1] = pFramesInS24[iSampleIn*3 + 1];
-                    pFramesOutS24[iSampleOut*3 + 2] = pFramesInS24[iSampleIn*3 + 2];
-                }
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                    pFramesOutS32[iFrame*pConverter->channelsOut + iChannel] = pFramesInS32[iFrame];
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            if (pConverter->channelsOut == 2) {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    pFramesOutF32[iFrame*2 + 0] = pFramesInF32[iFrame];
-                    pFramesOutF32[iFrame*2 + 1] = pFramesInF32[iFrame];
-                }
-            } else {
-                for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                    ma_uint32 iChannel;
-                    for (iChannel = 0; iChannel < pConverter->channelsOut; iChannel += 1) {
-                        pFramesOutF32[iFrame*pConverter->channelsOut + iChannel] = pFramesInF32[iFrame];
-                    }
-                }
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__stereo_to_mono(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-    MA_ASSERT(pConverter->channelsIn  == 2);
-    MA_ASSERT(pConverter->channelsOut == 1);
-
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutU8[iFrame] = ma_clip_u8((ma_int16)((ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8[iFrame*2+0]) + ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8[iFrame*2+1])) / 2));
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutS16[iFrame] = (ma_int16)(((ma_int32)pFramesInS16[iFrame*2+0] + (ma_int32)pFramesInS16[iFrame*2+1]) / 2);
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                ma_int64 s24_0 = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24[(iFrame*2+0)*3]);
-                ma_int64 s24_1 = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24[(iFrame*2+1)*3]);
-                ma_pcm_sample_s32_to_s24_no_scale((s24_0 + s24_1) / 2, &pFramesOutS24[iFrame*3]);
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutS32[iFrame] = (ma_int16)(((ma_int32)pFramesInS32[iFrame*2+0] + (ma_int32)pFramesInS32[iFrame*2+1]) / 2);
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; ++iFrame) {
-                pFramesOutF32[iFrame] = (pFramesInF32[iFrame*2+0] + pFramesInF32[iFrame*2+0]) * 0.5f;
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_channel_converter_process_pcm_frames__weights(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    ma_uint32 iFrame;
-    ma_uint32 iChannelIn;
-    ma_uint32 iChannelOut;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pFramesIn  != NULL);
-
-    /* This is the more complicated case. Each of the output channels is accumulated with 0 or more input channels. */
-
-    /* Clear. */
-    ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-
-    /* Accumulate. */
-    switch (pConverter->format)
-    {
-        case ma_format_u8:
-        {
-            /* */ ma_uint8* pFramesOutU8 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInU8  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int16 u8_O = ma_pcm_sample_u8_to_s16_no_scale(pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut]);
-                        ma_int16 u8_I = ma_pcm_sample_u8_to_s16_no_scale(pFramesInU8 [iFrame*pConverter->channelsIn  + iChannelIn ]);
-                        ma_int32 s    = (ma_int32)ma_clamp(u8_O + ((u8_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -128, 127);
-                        pFramesOutU8[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_u8((ma_int16)s);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s16:
-        {
-            /* */ ma_int16* pFramesOutS16 = (      ma_int16*)pFramesOut;
-            const ma_int16* pFramesInS16  = (const ma_int16*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int32 s = pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut];
-                        s += (pFramesInS16[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT;
-
-                        pFramesOutS16[iFrame*pConverter->channelsOut + iChannelOut] = (ma_int16)ma_clamp(s, -32768, 32767);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s24:
-        {
-            /* */ ma_uint8* pFramesOutS24 = (      ma_uint8*)pFramesOut;
-            const ma_uint8* pFramesInS24  = (const ma_uint8*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int64 s24_O = ma_pcm_sample_s24_to_s32_no_scale(&pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]);
-                        ma_int64 s24_I = ma_pcm_sample_s24_to_s32_no_scale(&pFramesInS24 [(iFrame*pConverter->channelsIn  + iChannelIn )*3]);
-                        ma_int64 s24   = (ma_int32)ma_clamp(s24_O + ((s24_I * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT), -8388608, 8388607);
-                        ma_pcm_sample_s32_to_s24_no_scale(s24, &pFramesOutS24[(iFrame*pConverter->channelsOut + iChannelOut)*3]);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_s32:
-        {
-            /* */ ma_int32* pFramesOutS32 = (      ma_int32*)pFramesOut;
-            const ma_int32* pFramesInS32  = (const ma_int32*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        ma_int64 s = pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut];
-                        s += ((ma_int64)pFramesInS32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.s16[iChannelIn][iChannelOut]) >> MA_CHANNEL_CONVERTER_FIXED_POINT_SHIFT;
-
-                        pFramesOutS32[iFrame*pConverter->channelsOut + iChannelOut] = ma_clip_s32(s);
-                    }
-                }
-            }
-        } break;
-
-        case ma_format_f32:
-        {
-            /* */ float* pFramesOutF32 = (      float*)pFramesOut;
-            const float* pFramesInF32  = (const float*)pFramesIn;
-
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannelIn = 0; iChannelIn < pConverter->channelsIn; ++iChannelIn) {
-                    for (iChannelOut = 0; iChannelOut < pConverter->channelsOut; ++iChannelOut) {
-                        pFramesOutF32[iFrame*pConverter->channelsOut + iChannelOut] += pFramesInF32[iFrame*pConverter->channelsIn + iChannelIn] * pConverter->weights.f32[iChannelIn][iChannelOut];
-                    }
-                }
-            }
-        } break;
-
-        default: return MA_INVALID_OPERATION;   /* Unknown format. */
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_channel_converter_process_pcm_frames(ma_channel_converter* pConverter, void* pFramesOut, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFramesIn == NULL) {
-        ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->format, pConverter->channelsOut));
-        return MA_SUCCESS;
-    }
-
-    if (pConverter->isPassthrough) {
-        return ma_channel_converter_process_pcm_frames__passthrough(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isSimpleShuffle) {
-        return ma_channel_converter_process_pcm_frames__simple_shuffle(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isSimpleMonoExpansion) {
-        return ma_channel_converter_process_pcm_frames__simple_mono_expansion(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else if (pConverter->isStereoToMono) {
-        return ma_channel_converter_process_pcm_frames__stereo_to_mono(pConverter, pFramesOut, pFramesIn, frameCount);
-    } else {
-        return ma_channel_converter_process_pcm_frames__weights(pConverter, pFramesOut, pFramesIn, frameCount);
-    }
-}
-
-
-/**************************************************************************************************************************************************************
-
-Data Conversion
-
-**************************************************************************************************************************************************************/
-MA_API ma_data_converter_config ma_data_converter_config_init_default()
-{
-    ma_data_converter_config config;
-    MA_ZERO_OBJECT(&config);
-
-    config.ditherMode = ma_dither_mode_none;
-    config.resampling.algorithm = ma_resample_algorithm_linear;
-    config.resampling.allowDynamicSampleRate = MA_FALSE; /* Disable dynamic sample rates by default because dynamic rate adjustments should be quite rare and it allows an optimization for cases when the in and out sample rates are the same. */
-
-    /* Linear resampling defaults. */
-    config.resampling.linear.lpfOrder = 1;
-    config.resampling.linear.lpfNyquistFactor = 1;
-
-    /* Speex resampling defaults. */
-    config.resampling.speex.quality = 3;
-
-    return config;
-}
-
-MA_API ma_data_converter_config ma_data_converter_config_init(ma_format formatIn, ma_format formatOut, ma_uint32 channelsIn, ma_uint32 channelsOut, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    ma_data_converter_config config = ma_data_converter_config_init_default();
-    config.formatIn      = formatIn;
-    config.formatOut     = formatOut;
-    config.channelsIn    = ma_min(channelsIn,  MA_MAX_CHANNELS);
-    config.channelsOut   = ma_min(channelsOut, MA_MAX_CHANNELS);
-    config.sampleRateIn  = sampleRateIn;
-    config.sampleRateOut = sampleRateOut;
-
-    return config;
-}
-
-MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter)
-{
-    ma_result result;
-    ma_format midFormat;
-
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pConverter);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pConverter->config = *pConfig;
-
-    /* Basic validation. */
-    if (pConfig->channelsIn < MA_MIN_CHANNELS || pConfig->channelsOut < MA_MIN_CHANNELS ||
-        pConfig->channelsIn > MA_MAX_CHANNELS || pConfig->channelsOut > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    /*
-    We want to avoid as much data conversion as possible. The channel converter and resampler both support s16 and f32 natively. We need to decide
-    on the format to use for this stage. We call this the mid format because it's used in the middle stage of the conversion pipeline. If the output
-    format is either s16 or f32 we use that one. If that is not the case it will do the same thing for the input format. If it's neither we just
-    use f32.
-    */
-    /*  */ if (pConverter->config.formatOut == ma_format_s16 || pConverter->config.formatOut == ma_format_f32) {
-        midFormat = pConverter->config.formatOut;
-    } else if (pConverter->config.formatIn  == ma_format_s16 || pConverter->config.formatIn  == ma_format_f32) {
-        midFormat = pConverter->config.formatIn;
-    } else {
-        midFormat = ma_format_f32;
-    }
-
-    /* Channel converter. We always initialize this, but we check if it configures itself as a passthrough to determine whether or not it's needed. */
-    {
-        ma_uint32 iChannelIn;
-        ma_uint32 iChannelOut;
-        ma_channel_converter_config channelConverterConfig;
-
-        channelConverterConfig = ma_channel_converter_config_init(midFormat, pConverter->config.channelsIn, pConverter->config.channelMapIn, pConverter->config.channelsOut, pConverter->config.channelMapOut, pConverter->config.channelMixMode);
-
-        /* Channel weights. */
-        for (iChannelIn = 0; iChannelIn < pConverter->config.channelsIn; iChannelIn += 1) {
-            for (iChannelOut = 0; iChannelOut < pConverter->config.channelsOut; iChannelOut += 1) {
-                channelConverterConfig.weights[iChannelIn][iChannelOut] = pConverter->config.channelWeights[iChannelIn][iChannelOut];
-            }
-        }
-
-        result = ma_channel_converter_init(&channelConverterConfig, &pConverter->channelConverter);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        /* If the channel converter is not a passthrough we need to enable it. Otherwise we can skip it. */
-        if (pConverter->channelConverter.isPassthrough == MA_FALSE) {
-            pConverter->hasChannelConverter = MA_TRUE;
-        }
-    }
-
-
-    /* Always enable dynamic sample rates if the input sample rate is different because we're always going to need a resampler in this case anyway. */
-    if (pConverter->config.resampling.allowDynamicSampleRate == MA_FALSE) {
-        pConverter->config.resampling.allowDynamicSampleRate = pConverter->config.sampleRateIn != pConverter->config.sampleRateOut;
-    }
-
-    /* Resampler. */
-    if (pConverter->config.resampling.allowDynamicSampleRate) {
-        ma_resampler_config resamplerConfig;
-        ma_uint32 resamplerChannels;
-
-        /* The resampler is the most expensive part of the conversion process, so we need to do it at the stage where the channel count is at it's lowest. */
-        if (pConverter->config.channelsIn < pConverter->config.channelsOut) {
-            resamplerChannels = pConverter->config.channelsIn;
-        } else {
-            resamplerChannels = pConverter->config.channelsOut;
-        }
-
-        resamplerConfig = ma_resampler_config_init(midFormat, resamplerChannels, pConverter->config.sampleRateIn, pConverter->config.sampleRateOut, pConverter->config.resampling.algorithm);
-        resamplerConfig.linear.lpfOrder         = pConverter->config.resampling.linear.lpfOrder;
-        resamplerConfig.linear.lpfNyquistFactor = pConverter->config.resampling.linear.lpfNyquistFactor;
-        resamplerConfig.speex.quality           = pConverter->config.resampling.speex.quality;
-
-        result = ma_resampler_init(&resamplerConfig, &pConverter->resampler);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        pConverter->hasResampler = MA_TRUE;
-    }
-
-
-    /* We can simplify pre- and post-format conversion if we have neither channel conversion nor resampling. */
-    if (pConverter->hasChannelConverter == MA_FALSE && pConverter->hasResampler == MA_FALSE) {
-        /* We have neither channel conversion nor resampling so we'll only need one of pre- or post-format conversion, or none if the input and output formats are the same. */
-        if (pConverter->config.formatIn == pConverter->config.formatOut) {
-            /* The formats are the same so we can just pass through. */
-            pConverter->hasPreFormatConversion  = MA_FALSE;
-            pConverter->hasPostFormatConversion = MA_FALSE;
-        } else {
-            /* The formats are different so we need to do either pre- or post-format conversion. It doesn't matter which. */
-            pConverter->hasPreFormatConversion  = MA_FALSE;
-            pConverter->hasPostFormatConversion = MA_TRUE;
-        }
-    } else {
-        /* We have a channel converter and/or resampler so we'll need channel conversion based on the mid format. */
-        if (pConverter->config.formatIn != midFormat) {
-            pConverter->hasPreFormatConversion = MA_TRUE;
-        }
-        if (pConverter->config.formatOut != midFormat) {
-            pConverter->hasPostFormatConversion = MA_TRUE;
-        }
-    }
-
-    /* We can enable passthrough optimizations if applicable. Note that we'll only be able to do this if the sample rate is static. */
-    if (pConverter->hasPreFormatConversion  == MA_FALSE &&
-        pConverter->hasPostFormatConversion == MA_FALSE &&
-        pConverter->hasChannelConverter     == MA_FALSE &&
-        pConverter->hasResampler            == MA_FALSE) {
-        pConverter->isPassthrough = MA_TRUE;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_data_converter_uninit(ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return;
-    }
-
-    if (pConverter->hasResampler) {
-        ma_resampler_uninit(&pConverter->resampler);
-    }
-}
-
-static ma_result ma_data_converter_process_pcm_frames__passthrough(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pFramesOut != NULL) {
-        if (pFramesIn != NULL) {
-            ma_copy_memory_64(pFramesOut, pFramesIn, frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        } else {
-            ma_zero_memory_64(pFramesOut,            frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__format_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pFramesOut != NULL) {
-        if (pFramesIn != NULL) {
-            ma_convert_pcm_frames_format(pFramesOut, pConverter->config.formatOut, pFramesIn, pConverter->config.formatIn, frameCount, pConverter->config.channelsIn, pConverter->config.ditherMode);
-        } else {
-            ma_zero_memory_64(pFramesOut, frameCount * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_data_converter_process_pcm_frames__resample_with_format_conversion(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result = MA_SUCCESS;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-        const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-        const void* pFramesInThisIteration;
-        /* */ void* pFramesOutThisIteration;
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-
-        if (pFramesIn != NULL) {
-            pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessedIn * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        } else {
-            pFramesInThisIteration = NULL;
-        }
-
-        if (pFramesOut != NULL) {
-            pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        } else {
-            pFramesOutThisIteration = NULL;
-        }
-
-        /* Do a pre format conversion if necessary. */
-        if (pConverter->hasPreFormatConversion) {
-            ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-
-            frameCountInThisIteration  = (frameCountIn - framesProcessedIn);
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-
-            if (pConverter->hasPostFormatConversion) {
-               if (frameCountInThisIteration > tempBufferOutCap) {
-                   frameCountInThisIteration = tempBufferOutCap;
-               }
-            }
-
-            if (pFramesInThisIteration != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.config.format, pFramesInThisIteration, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-            } else {
-                MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn));
-            }
-
-            frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-
-            if (pConverter->hasPostFormatConversion) {
-                /* Both input and output conversion required. Output to the temp buffer. */
-                if (frameCountOutThisIteration > tempBufferOutCap) {
-                    frameCountOutThisIteration = tempBufferOutCap;
-                }
-
-                result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration);
-            } else {
-                /* Only pre-format required. Output straight to the output buffer. */
-                result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferIn, &frameCountInThisIteration, pFramesOutThisIteration, &frameCountOutThisIteration);
-            }
-
-            if (result != MA_SUCCESS) {
-                break;
-            }
-        } else {
-            /* No pre-format required. Just read straight from the input buffer. */
-            MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE);
-
-            frameCountInThisIteration  = (frameCountIn  - framesProcessedIn);
-            frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-
-            result = ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesInThisIteration, &frameCountInThisIteration, pTempBufferOut, &frameCountOutThisIteration);
-            if (result != MA_SUCCESS) {
-                break;
-            }
-        }
-
-        /* If we are doing a post format conversion we need to do that now. */
-        if (pConverter->hasPostFormatConversion) {
-            if (pFramesOutThisIteration != NULL) {
-                ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->config.formatOut, pTempBufferOut, pConverter->resampler.config.format, frameCountOutThisIteration, pConverter->resampler.config.channels, pConverter->config.ditherMode);
-            }
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return result;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__resample_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    MA_ASSERT(pConverter != NULL);
-
-    if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) {
-        /* Neither pre- nor post-format required. This is simple case where only resampling is required. */
-        return ma_resampler_process_pcm_frames(&pConverter->resampler, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    } else {
-        /* Format conversion required. */
-        return ma_data_converter_process_pcm_frames__resample_with_format_conversion(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-}
-
-static ma_result ma_data_converter_process_pcm_frames__channels_only(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 frameCount;
-
-    MA_ASSERT(pConverter != NULL);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    frameCount = ma_min(frameCountIn, frameCountOut);
-
-    if (pConverter->hasPreFormatConversion == MA_FALSE && pConverter->hasPostFormatConversion == MA_FALSE) {
-        /* No format conversion required. */
-        result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOut, pFramesIn, frameCount);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    } else {
-        /* Format conversion required. */
-        ma_uint64 framesProcessed = 0;
-
-        while (framesProcessed < frameCount) {
-            ma_uint8 pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-            const ma_uint32 tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-            const void* pFramesInThisIteration;
-            /* */ void* pFramesOutThisIteration;
-            ma_uint64 frameCountThisIteration;
-
-            if (pFramesIn != NULL) {
-                pFramesInThisIteration = ma_offset_ptr(pFramesIn, framesProcessed * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-            } else {
-                pFramesInThisIteration = NULL;
-            }
-
-            if (pFramesOut != NULL) {
-                pFramesOutThisIteration = ma_offset_ptr(pFramesOut, framesProcessed * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-            } else {
-                pFramesOutThisIteration = NULL;
-            }
-
-            /* Do a pre format conversion if necessary. */
-            if (pConverter->hasPreFormatConversion) {
-                ma_uint8 pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                const ma_uint32 tempBufferInCap = sizeof(pTempBufferIn) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn);
-
-                frameCountThisIteration = (frameCount - framesProcessed);
-                if (frameCountThisIteration > tempBufferInCap) {
-                    frameCountThisIteration = tempBufferInCap;
-                }
-
-                if (pConverter->hasPostFormatConversion) {
-                    if (frameCountThisIteration > tempBufferOutCap) {
-                        frameCountThisIteration = tempBufferOutCap;
-                    }
-                }
-
-                if (pFramesInThisIteration != NULL) {
-                    ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pFramesInThisIteration, pConverter->config.formatIn, frameCountThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                } else {
-                    MA_ZERO_MEMORY(pTempBufferIn, sizeof(pTempBufferIn));
-                }
-
-                if (pConverter->hasPostFormatConversion) {
-                    /* Both input and output conversion required. Output to the temp buffer. */
-                    result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pTempBufferIn, frameCountThisIteration);
-                } else {
-                    /* Only pre-format required. Output straight to the output buffer. */
-                    result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pFramesOutThisIteration, pTempBufferIn, frameCountThisIteration);
-                }
-
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            } else {
-                /* No pre-format required. Just read straight from the input buffer. */
-                MA_ASSERT(pConverter->hasPostFormatConversion == MA_TRUE);
-
-                frameCountThisIteration = (frameCount - framesProcessed);
-                if (frameCountThisIteration > tempBufferOutCap) {
-                    frameCountThisIteration = tempBufferOutCap;
-                }
-
-                result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferOut, pFramesInThisIteration, frameCountThisIteration);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-            }
-
-            /* If we are doing a post format conversion we need to do that now. */
-            if (pConverter->hasPostFormatConversion) {
-                if (pFramesOutThisIteration != NULL) {
-                    ma_convert_pcm_frames_format(pFramesOutThisIteration, pConverter->config.formatOut, pTempBufferOut, pConverter->channelConverter.format, frameCountThisIteration, pConverter->channelConverter.channelsOut, pConverter->config.ditherMode);
-                }
-            }
-
-            framesProcessed += frameCountThisIteration;
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = frameCount;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = frameCount;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__resampling_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint8  pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];   /* In resampler format. */
-    ma_uint64 tempBufferInCap;
-    ma_uint8  pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In resampler format, channel converter input format. */
-    ma_uint64 tempBufferMidCap;
-    ma_uint8  pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In channel converter output format. */
-    ma_uint64 tempBufferOutCap;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pConverter->resampler.config.format   == pConverter->channelConverter.format);
-    MA_ASSERT(pConverter->resampler.config.channels == pConverter->channelConverter.channelsIn);
-    MA_ASSERT(pConverter->resampler.config.channels <  pConverter->channelConverter.channelsOut);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    tempBufferInCap  = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-    tempBufferMidCap = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-    tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-        const void* pRunningFramesIn = NULL;
-        void* pRunningFramesOut = NULL;
-        const void* pResampleBufferIn;
-        void* pChannelsBufferOut;
-
-        if (pFramesIn != NULL) {
-            pRunningFramesIn  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        }
-        if (pFramesOut != NULL) {
-            pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-
-        /* Run input data through the resampler and output it to the temporary buffer. */
-        frameCountInThisIteration = (frameCountIn - framesProcessedIn);
-
-        if (pConverter->hasPreFormatConversion) {
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-        }
-
-        frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-        if (frameCountOutThisIteration > tempBufferMidCap) {
-            frameCountOutThisIteration = tempBufferMidCap;
-        }
-
-        /* We can't read more frames than can fit in the output buffer. */
-        if (pConverter->hasPostFormatConversion) {
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-        }
-
-        /* We need to ensure we don't try to process too many input frames that we run out of room in the output buffer. If this happens we'll end up glitching. */
-        {
-            ma_uint64 requiredInputFrameCount = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration);
-            if (frameCountInThisIteration > requiredInputFrameCount) {
-                frameCountInThisIteration = requiredInputFrameCount;
-            }
-        }
-
-        if (pConverter->hasPreFormatConversion) {
-            if (pFramesIn != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->resampler.config.format, pRunningFramesIn, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                pResampleBufferIn = pTempBufferIn;
-            } else {
-                pResampleBufferIn = NULL;
-            }
-        } else {
-            pResampleBufferIn = pRunningFramesIn;
-        }
-
-        result = ma_resampler_process_pcm_frames(&pConverter->resampler, pResampleBufferIn, &frameCountInThisIteration, pTempBufferMid, &frameCountOutThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-
-        /*
-        The input data has been resampled so now we need to run it through the channel converter. The input data is always contained in pTempBufferMid. We only need to do
-        this part if we have an output buffer.
-        */
-        if (pFramesOut != NULL) {
-            if (pConverter->hasPostFormatConversion) {
-                pChannelsBufferOut = pTempBufferOut;
-            } else {
-                pChannelsBufferOut = pRunningFramesOut;
-            }
-
-            result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pChannelsBufferOut, pTempBufferMid, frameCountOutThisIteration);
-            if (result != MA_SUCCESS) {
-                return result;
-            }
-
-            /* Finally we do post format conversion. */
-            if (pConverter->hasPostFormatConversion) {
-                ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->config.formatOut, pChannelsBufferOut, pConverter->channelConverter.format, frameCountOutThisIteration, pConverter->channelConverter.channelsOut, pConverter->config.ditherMode);
-            }
-        }
-
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_data_converter_process_pcm_frames__channels_first(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    ma_result result;
-    ma_uint64 frameCountIn;
-    ma_uint64 frameCountOut;
-    ma_uint64 framesProcessedIn;
-    ma_uint64 framesProcessedOut;
-    ma_uint8  pTempBufferIn[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];   /* In resampler format. */
-    ma_uint64 tempBufferInCap;
-    ma_uint8  pTempBufferMid[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In resampler format, channel converter input format. */
-    ma_uint64 tempBufferMidCap;
-    ma_uint8  pTempBufferOut[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In channel converter output format. */
-    ma_uint64 tempBufferOutCap;
-
-    MA_ASSERT(pConverter != NULL);
-    MA_ASSERT(pConverter->resampler.config.format   == pConverter->channelConverter.format);
-    MA_ASSERT(pConverter->resampler.config.channels == pConverter->channelConverter.channelsOut);
-    MA_ASSERT(pConverter->resampler.config.channels <  pConverter->channelConverter.channelsIn);
-
-    frameCountIn = 0;
-    if (pFrameCountIn != NULL) {
-        frameCountIn = *pFrameCountIn;
-    }
-
-    frameCountOut = 0;
-    if (pFrameCountOut != NULL) {
-        frameCountOut = *pFrameCountOut;
-    }
-
-    framesProcessedIn  = 0;
-    framesProcessedOut = 0;
-
-    tempBufferInCap  = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsIn);
-    tempBufferMidCap = sizeof(pTempBufferIn)  / ma_get_bytes_per_frame(pConverter->channelConverter.format, pConverter->channelConverter.channelsOut);
-    tempBufferOutCap = sizeof(pTempBufferOut) / ma_get_bytes_per_frame(pConverter->resampler.config.format, pConverter->resampler.config.channels);
-
-    while (framesProcessedOut < frameCountOut) {
-        ma_uint64 frameCountInThisIteration;
-        ma_uint64 frameCountOutThisIteration;
-        const void* pRunningFramesIn = NULL;
-        void* pRunningFramesOut = NULL;
-        const void* pChannelsBufferIn;
-        void* pResampleBufferOut;
-
-        if (pFramesIn != NULL) {
-            pRunningFramesIn  = ma_offset_ptr(pFramesIn,  framesProcessedIn  * ma_get_bytes_per_frame(pConverter->config.formatIn, pConverter->config.channelsIn));
-        }
-        if (pFramesOut != NULL) {
-            pRunningFramesOut = ma_offset_ptr(pFramesOut, framesProcessedOut * ma_get_bytes_per_frame(pConverter->config.formatOut, pConverter->config.channelsOut));
-        }
-
-        /* Run input data through the channel converter and output it to the temporary buffer. */
-        frameCountInThisIteration = (frameCountIn - framesProcessedIn);
-
-        if (pConverter->hasPreFormatConversion) {
-            if (frameCountInThisIteration > tempBufferInCap) {
-                frameCountInThisIteration = tempBufferInCap;
-            }
-
-            if (pRunningFramesIn != NULL) {
-                ma_convert_pcm_frames_format(pTempBufferIn, pConverter->channelConverter.format, pRunningFramesIn, pConverter->config.formatIn, frameCountInThisIteration, pConverter->config.channelsIn, pConverter->config.ditherMode);
-                pChannelsBufferIn = pTempBufferIn;
-            } else {
-                pChannelsBufferIn = NULL;
-            }
-        } else {
-            pChannelsBufferIn = pRunningFramesIn;
-        }
-
-        /*
-        We can't convert more frames than will fit in the output buffer. We shouldn't actually need to do this check because the channel count is always reduced
-        in this case which means we should always have capacity, but I'm leaving it here just for safety for future maintenance.
-        */
-        if (frameCountInThisIteration > tempBufferMidCap) {
-            frameCountInThisIteration = tempBufferMidCap;
-        }
-
-        /*
-        Make sure we don't read any more input frames than we need to fill the output frame count. If we do this we will end up in a situation where we lose some
-        input samples and will end up glitching.
-        */
-        frameCountOutThisIteration = (frameCountOut - framesProcessedOut);
-        if (frameCountOutThisIteration > tempBufferMidCap) {
-            frameCountOutThisIteration = tempBufferMidCap;
-        }
-
-        if (pConverter->hasPostFormatConversion) {
-            ma_uint64 requiredInputFrameCount;
-
-            if (frameCountOutThisIteration > tempBufferOutCap) {
-                frameCountOutThisIteration = tempBufferOutCap;
-            }
-
-            requiredInputFrameCount = ma_resampler_get_required_input_frame_count(&pConverter->resampler, frameCountOutThisIteration);
-            if (frameCountInThisIteration > requiredInputFrameCount) {
-                frameCountInThisIteration = requiredInputFrameCount;
-            }
-        }
-
-        result = ma_channel_converter_process_pcm_frames(&pConverter->channelConverter, pTempBufferMid, pChannelsBufferIn, frameCountInThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-
-        /* At this point we have converted the channels to the output channel count which we now need to resample. */
-        if (pConverter->hasPostFormatConversion) {
-            pResampleBufferOut = pTempBufferOut;
-        } else {
-            pResampleBufferOut = pRunningFramesOut;
-        }
-
-        result = ma_resampler_process_pcm_frames(&pConverter->resampler, pTempBufferMid, &frameCountInThisIteration, pResampleBufferOut, &frameCountOutThisIteration);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-
-        /* Finally we can do the post format conversion. */
-        if (pConverter->hasPostFormatConversion) {
-            if (pRunningFramesOut != NULL) {
-                ma_convert_pcm_frames_format(pRunningFramesOut, pConverter->config.formatOut, pResampleBufferOut, pConverter->resampler.config.format, frameCountOutThisIteration, pConverter->config.channelsOut, pConverter->config.ditherMode);
-            }
-        }
-
-        framesProcessedIn  += frameCountInThisIteration;
-        framesProcessedOut += frameCountOutThisIteration;
-
-        MA_ASSERT(framesProcessedIn  <= frameCountIn);
-        MA_ASSERT(framesProcessedOut <= frameCountOut);
-
-        if (frameCountOutThisIteration == 0) {
-            break;  /* Consumed all of our input data. */
-        }
-    }
-
-    if (pFrameCountIn != NULL) {
-        *pFrameCountIn = framesProcessedIn;
-    }
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = framesProcessedOut;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_data_converter_process_pcm_frames(ma_data_converter* pConverter, const void* pFramesIn, ma_uint64* pFrameCountIn, void* pFramesOut, ma_uint64* pFrameCountOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->isPassthrough) {
-        return ma_data_converter_process_pcm_frames__passthrough(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-    }
-
-    /*
-    Here is where the real work is done. Getting here means we're not using a passthrough and we need to move the data through each of the relevant stages. The order
-    of our stages depends on the input and output channel count. If the input channels is less than the output channels we want to do sample rate conversion first so
-    that it has less work (resampling is the most expensive part of format conversion).
-    */
-    if (pConverter->config.channelsIn < pConverter->config.channelsOut) {
-        /* Do resampling first, if necessary. */
-        MA_ASSERT(pConverter->hasChannelConverter == MA_TRUE);
-
-        if (pConverter->hasResampler) {
-            /* Resampling first. */
-            return ma_data_converter_process_pcm_frames__resampling_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        } else {
-            /* Resampling not required. */
-            return ma_data_converter_process_pcm_frames__channels_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-        }
-    } else {
-        /* Do channel conversion first, if necessary. */
-        if (pConverter->hasChannelConverter) {
-            if (pConverter->hasResampler) {
-                /* Channel routing first. */
-                return ma_data_converter_process_pcm_frames__channels_first(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            } else {
-                /* Resampling not required. */
-                return ma_data_converter_process_pcm_frames__channels_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            }
-        } else {
-            /* Channel routing not required. */
-            if (pConverter->hasResampler) {
-                /* Resampling only. */
-                return ma_data_converter_process_pcm_frames__resample_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            } else {
-                /* No channel routing nor resampling required. Just format conversion. */
-                return ma_data_converter_process_pcm_frames__format_only(pConverter, pFramesIn, pFrameCountIn, pFramesOut, pFrameCountOut);
-            }
-        }
-    }
-}
-
-MA_API ma_result ma_data_converter_set_rate(ma_data_converter* pConverter, ma_uint32 sampleRateIn, ma_uint32 sampleRateOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->hasResampler == MA_FALSE) {
-        return MA_INVALID_OPERATION;    /* Dynamic resampling not enabled. */
-    }
-
-    return ma_resampler_set_rate(&pConverter->resampler, sampleRateIn, sampleRateOut);
-}
-
-MA_API ma_result ma_data_converter_set_rate_ratio(ma_data_converter* pConverter, float ratioInOut)
-{
-    if (pConverter == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConverter->hasResampler == MA_FALSE) {
-        return MA_INVALID_OPERATION;    /* Dynamic resampling not enabled. */
-    }
-
-    return ma_resampler_set_rate_ratio(&pConverter->resampler, ratioInOut);
-}
-
-MA_API ma_uint64 ma_data_converter_get_required_input_frame_count(const ma_data_converter* pConverter, ma_uint64 outputFrameCount)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_required_input_frame_count(&pConverter->resampler, outputFrameCount);
-    } else {
-        return outputFrameCount;    /* 1:1 */
-    }
-}
-
-MA_API ma_uint64 ma_data_converter_get_expected_output_frame_count(const ma_data_converter* pConverter, ma_uint64 inputFrameCount)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_expected_output_frame_count(&pConverter->resampler, inputFrameCount);
-    } else {
-        return inputFrameCount;     /* 1:1 */
-    }
-}
-
-MA_API ma_uint64 ma_data_converter_get_input_latency(const ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_input_latency(&pConverter->resampler);
-    }
-
-    return 0;   /* No latency without a resampler. */
-}
-
-MA_API ma_uint64 ma_data_converter_get_output_latency(const ma_data_converter* pConverter)
-{
-    if (pConverter == NULL) {
-        return 0;
-    }
-
-    if (pConverter->hasResampler) {
-        return ma_resampler_get_output_latency(&pConverter->resampler);
-    }
-
-    return 0;   /* No latency without a resampler. */
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Channel Maps
-
-**************************************************************************************************************************************************************/
-MA_API void ma_channel_map_init_blank(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    if (pChannelMap == NULL) {
-        return;
-    }
-
-    MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channels);
-}
-
-static void ma_get_standard_channel_map_microsoft(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    /* Based off the speaker configurations mentioned here: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ksmedia/ns-ksmedia-ksaudio_channel_config */
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-        } break;
-
-        case 3: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-#ifndef MA_USE_QUAD_MICROSOFT_CHANNEL_MAP
-            /* Surround. Using the Surround profile has the advantage of the 3rd channel (MA_CHANNEL_FRONT_CENTER) mapping nicely with higher channel counts. */
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_CENTER;
-#else
-            /* Quad. */
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-#endif
-        } break;
-
-        case 5: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[5] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 7: /* Not defined, but best guess. */
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[5] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_alsa(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_rfc3551(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 6; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-6));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_flac(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[5] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[3] = MA_CHANNEL_LFE;
-            pChannelMap[4] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[5] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_vorbis(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    /* In Vorbis' type 0 channel mapping, the first two channels are not always the standard left/right - it will have the center speaker where the right usually goes. Why?! */
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[4] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[6] = MA_CHANNEL_LFE;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[2] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[3] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[4] = MA_CHANNEL_SIDE_RIGHT;
-            pChannelMap[5] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[6] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[7] = MA_CHANNEL_LFE;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < channels; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_sound4(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-
-        case 7:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_BACK_CENTER;
-            pChannelMap[6] = MA_CHANNEL_LFE;
-        } break;
-
-        case 8:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-            pChannelMap[6] = MA_CHANNEL_SIDE_LEFT;
-            pChannelMap[7] = MA_CHANNEL_SIDE_RIGHT;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 8) {
-        ma_uint32 iChannel;
-        for (iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-8));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-static void ma_get_standard_channel_map_sndio(ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (channels)
-    {
-        case 1:
-        {
-            pChannelMap[0] = MA_CHANNEL_MONO;
-        } break;
-
-        case 2:
-        {
-            pChannelMap[0] = MA_CHANNEL_LEFT;
-            pChannelMap[1] = MA_CHANNEL_RIGHT;
-        } break;
-
-        case 3:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 4:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-        } break;
-
-        case 5:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-        } break;
-
-        case 6:
-        default:
-        {
-            pChannelMap[0] = MA_CHANNEL_FRONT_LEFT;
-            pChannelMap[1] = MA_CHANNEL_FRONT_RIGHT;
-            pChannelMap[2] = MA_CHANNEL_BACK_LEFT;
-            pChannelMap[3] = MA_CHANNEL_BACK_RIGHT;
-            pChannelMap[4] = MA_CHANNEL_FRONT_CENTER;
-            pChannelMap[5] = MA_CHANNEL_LFE;
-        } break;
-    }
-
-    /* Remainder. */
-    if (channels > 6) {
-        ma_uint32 iChannel;
-        for (iChannel = 6; iChannel < channels && iChannel < MA_MAX_CHANNELS; ++iChannel) {
-            if (iChannel < MA_MAX_CHANNELS) {
-                pChannelMap[iChannel] = (ma_channel)(MA_CHANNEL_AUX_0 + (iChannel-6));
-            } else {
-                pChannelMap[iChannel] = MA_CHANNEL_NONE;
-            }
-        }
-    }
-}
-
-MA_API void ma_get_standard_channel_map(ma_standard_channel_map standardChannelMap, ma_uint32 channels, ma_channel* pChannelMap)
-{
-    switch (standardChannelMap)
-    {
-        case ma_standard_channel_map_alsa:
-        {
-            ma_get_standard_channel_map_alsa(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_rfc3551:
-        {
-            ma_get_standard_channel_map_rfc3551(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_flac:
-        {
-            ma_get_standard_channel_map_flac(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_vorbis:
-        {
-            ma_get_standard_channel_map_vorbis(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_sound4:
-        {
-            ma_get_standard_channel_map_sound4(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_sndio:
-        {
-            ma_get_standard_channel_map_sndio(channels, pChannelMap);
-        } break;
-
-        case ma_standard_channel_map_microsoft: /* Also default. */
-        /*case ma_standard_channel_map_default;*/
-        default:
-        {
-            ma_get_standard_channel_map_microsoft(channels, pChannelMap);
-        } break;
-    }
-}
-
-MA_API void ma_channel_map_copy(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels)
-{
-    if (pOut != NULL && pIn != NULL && channels > 0) {
-        MA_COPY_MEMORY(pOut, pIn, sizeof(*pOut) * channels);
-    }
-}
-
-MA_API void ma_channel_map_copy_or_default(ma_channel* pOut, const ma_channel* pIn, ma_uint32 channels)
-{
-    if (pOut == NULL || channels == 0) {
-        return;
-    }
-
-    if (pIn != NULL) {
-        ma_channel_map_copy(pOut, pIn, channels);
-    } else {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, channels, pOut);
-    }
-}
-
-MA_API ma_bool32 ma_channel_map_valid(ma_uint32 channels, const ma_channel* pChannelMap)
-{
-    if (pChannelMap == NULL) {
-        return MA_FALSE;
-    }
-
-    /* A channel count of 0 is invalid. */
-    if (channels == 0) {
-        return MA_FALSE;
-    }
-
-    /* It does not make sense to have a mono channel when there is more than 1 channel. */
-    if (channels > 1) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < channels; ++iChannel) {
-            if (pChannelMap[iChannel] == MA_CHANNEL_MONO) {
-                return MA_FALSE;
-            }
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_equal(ma_uint32 channels, const ma_channel* pChannelMapA, const ma_channel* pChannelMapB)
-{
-    ma_uint32 iChannel;
-
-    if (pChannelMapA == pChannelMapB) {
-        return MA_TRUE;
-    }
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMapA[iChannel] != pChannelMapB[iChannel]) {
-            return MA_FALSE;
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_blank(ma_uint32 channels, const ma_channel* pChannelMap)
-{
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMap[iChannel] != MA_CHANNEL_NONE) {
-            return MA_FALSE;
-        }
-    }
-
-    return MA_TRUE;
-}
-
-MA_API ma_bool32 ma_channel_map_contains_channel_position(ma_uint32 channels, const ma_channel* pChannelMap, ma_channel channelPosition)
-{
-    ma_uint32 iChannel;
-
-    for (iChannel = 0; iChannel < channels; ++iChannel) {
-        if (pChannelMap[iChannel] == channelPosition) {
-            return MA_TRUE;
-        }
-    }
-
-    return MA_FALSE;
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Conversion Helpers
-
-**************************************************************************************************************************************************************/
-MA_API ma_uint64 ma_convert_frames(void* pOut, ma_uint64 frameCountOut, ma_format formatOut, ma_uint32 channelsOut, ma_uint32 sampleRateOut, const void* pIn, ma_uint64 frameCountIn, ma_format formatIn, ma_uint32 channelsIn, ma_uint32 sampleRateIn)
-{
-    ma_data_converter_config config;
-
-    config = ma_data_converter_config_init(formatIn, formatOut, channelsIn, channelsOut, sampleRateIn, sampleRateOut);
-    ma_get_standard_channel_map(ma_standard_channel_map_default, channelsOut, config.channelMapOut);
-    ma_get_standard_channel_map(ma_standard_channel_map_default, channelsIn,  config.channelMapIn);
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-
-    return ma_convert_frames_ex(pOut, frameCountOut, pIn, frameCountIn, &config);
-}
-
-MA_API ma_uint64 ma_convert_frames_ex(void* pOut, ma_uint64 frameCountOut, const void* pIn, ma_uint64 frameCountIn, const ma_data_converter_config* pConfig)
-{
-    ma_result result;
-    ma_data_converter converter;
-
-    if (frameCountIn == 0 || pConfig == NULL) {
-        return 0;
-    }
-
-    result = ma_data_converter_init(pConfig, &converter);
-    if (result != MA_SUCCESS) {
-        return 0;   /* Failed to initialize the data converter. */
-    }
-
-    if (pOut == NULL) {
-        frameCountOut = ma_data_converter_get_expected_output_frame_count(&converter, frameCountIn);
-    } else {
-        result = ma_data_converter_process_pcm_frames(&converter, pIn, &frameCountIn, pOut, &frameCountOut);
-        if (result != MA_SUCCESS) {
-            frameCountOut = 0;
-        }
-    }
-
-    ma_data_converter_uninit(&converter);
-    return frameCountOut;
-}
-
-
-/**************************************************************************************************************************************************************
-
-Ring Buffer
-
-**************************************************************************************************************************************************************/
-static MA_INLINE ma_uint32 ma_rb__extract_offset_in_bytes(ma_uint32 encodedOffset)
-{
-    return encodedOffset & 0x7FFFFFFF;
-}
-
-static MA_INLINE ma_uint32 ma_rb__extract_offset_loop_flag(ma_uint32 encodedOffset)
-{
-    return encodedOffset & 0x80000000;
-}
-
-static MA_INLINE void* ma_rb__get_read_ptr(ma_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-    return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(c89atomic_load_32(&pRB->encodedReadOffset)));
-}
-
-static MA_INLINE void* ma_rb__get_write_ptr(ma_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-    return ma_offset_ptr(pRB->pBuffer, ma_rb__extract_offset_in_bytes(c89atomic_load_32(&pRB->encodedWriteOffset)));
-}
-
-static MA_INLINE ma_uint32 ma_rb__construct_offset(ma_uint32 offsetInBytes, ma_uint32 offsetLoopFlag)
-{
-    return offsetLoopFlag | offsetInBytes;
-}
-
-static MA_INLINE void ma_rb__deconstruct_offset(ma_uint32 encodedOffset, ma_uint32* pOffsetInBytes, ma_uint32* pOffsetLoopFlag)
-{
-    MA_ASSERT(pOffsetInBytes != NULL);
-    MA_ASSERT(pOffsetLoopFlag != NULL);
-
-    *pOffsetInBytes  = ma_rb__extract_offset_in_bytes(encodedOffset);
-    *pOffsetLoopFlag = ma_rb__extract_offset_loop_flag(encodedOffset);
-}
-
-
-MA_API ma_result ma_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB)
-{
-    ma_result result;
-    const ma_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1);
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (subbufferSizeInBytes == 0 || subbufferCount == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (subbufferSizeInBytes > maxSubBufferSize) {
-        return MA_INVALID_ARGS;    /* Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. */
-    }
-
-
-    MA_ZERO_OBJECT(pRB);
-
-    result = ma_allocation_callbacks_init_copy(&pRB->allocationCallbacks, pAllocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pRB->subbufferSizeInBytes = (ma_uint32)subbufferSizeInBytes;
-    pRB->subbufferCount = (ma_uint32)subbufferCount;
-
-    if (pOptionalPreallocatedBuffer != NULL) {
-        pRB->subbufferStrideInBytes = (ma_uint32)subbufferStrideInBytes;
-        pRB->pBuffer = pOptionalPreallocatedBuffer;
-    } else {
-        size_t bufferSizeInBytes;
-
-        /*
-        Here is where we allocate our own buffer. We always want to align this to MA_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this
-        we need to make sure the stride is a multiple of MA_SIMD_ALIGNMENT.
-        */
-        pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MA_SIMD_ALIGNMENT-1)) & ~MA_SIMD_ALIGNMENT;
-
-        bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes;
-        pRB->pBuffer = ma_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT, &pRB->allocationCallbacks);
-        if (pRB->pBuffer == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        MA_ZERO_MEMORY(pRB->pBuffer, bufferSizeInBytes);
-        pRB->ownsBuffer = MA_TRUE;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_rb* pRB)
-{
-    return ma_rb_init_ex(bufferSizeInBytes, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB);
-}
-
-MA_API void ma_rb_uninit(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    if (pRB->ownsBuffer) {
-        ma_aligned_free(pRB->pBuffer, &pRB->allocationCallbacks);
-    }
-}
-
-MA_API void ma_rb_reset(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, 0);
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, 0);
-}
-
-MA_API ma_result ma_rb_acquire_read(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut)
-{
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    size_t bytesAvailable;
-    size_t bytesRequested;
-
-    if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The returned buffer should never move ahead of the write pointer. */
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    /*
-    The number of bytes available depends on whether or not the read and write pointers are on the same loop iteration. If so, we
-    can only read up to the write pointer. If not, we can only read up to the end of the buffer.
-    */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        bytesAvailable = writeOffsetInBytes - readOffsetInBytes;
-    } else {
-        bytesAvailable = pRB->subbufferSizeInBytes - readOffsetInBytes;
-    }
-
-    bytesRequested = *pSizeInBytes;
-    if (bytesRequested > bytesAvailable) {
-        bytesRequested = bytesAvailable;
-    }
-
-    *pSizeInBytes = bytesRequested;
-    (*ppBufferOut) = ma_rb__get_read_ptr(pRB);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_commit_read(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 newReadOffsetInBytes;
-    ma_uint32 newReadOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Validate the buffer. */
-    if (pBufferOut != ma_rb__get_read_ptr(pRB)) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */
-    newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + sizeInBytes);
-    if (newReadOffsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;    /* <-- sizeInBytes will cause the read offset to overflow. */
-    }
-
-    /* Move the read pointer back to the start if necessary. */
-    newReadOffsetLoopFlag = readOffsetLoopFlag;
-    if (newReadOffsetInBytes == pRB->subbufferSizeInBytes) {
-        newReadOffsetInBytes = 0;
-        newReadOffsetLoopFlag ^= 0x80000000;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetLoopFlag, newReadOffsetInBytes));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_acquire_write(ma_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    size_t bytesAvailable;
-    size_t bytesRequested;
-
-    if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The returned buffer should never overtake the read buffer. */
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    /*
-    In the case of writing, if the write pointer and the read pointer are on the same loop iteration we can only
-    write up to the end of the buffer. Otherwise we can only write up to the read pointer. The write pointer should
-    never overtake the read pointer.
-    */
-    if (writeOffsetLoopFlag == readOffsetLoopFlag) {
-        bytesAvailable = pRB->subbufferSizeInBytes - writeOffsetInBytes;
-    } else {
-        bytesAvailable = readOffsetInBytes - writeOffsetInBytes;
-    }
-
-    bytesRequested = *pSizeInBytes;
-    if (bytesRequested > bytesAvailable) {
-        bytesRequested = bytesAvailable;
-    }
-
-    *pSizeInBytes = bytesRequested;
-    *ppBufferOut  = ma_rb__get_write_ptr(pRB);
-
-    /* Clear the buffer if desired. */
-    if (pRB->clearOnWriteAcquire) {
-        MA_ZERO_MEMORY(*ppBufferOut, *pSizeInBytes);
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_commit_write(ma_rb* pRB, size_t sizeInBytes, void* pBufferOut)
-{
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newWriteOffsetInBytes;
-    ma_uint32 newWriteOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* Validate the buffer. */
-    if (pBufferOut != ma_rb__get_write_ptr(pRB)) {
-        return MA_INVALID_ARGS;
-    }
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    /* Check that sizeInBytes is correct. It should never go beyond the end of the buffer. */
-    newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + sizeInBytes);
-    if (newWriteOffsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;    /* <-- sizeInBytes will cause the read offset to overflow. */
-    }
-
-    /* Move the read pointer back to the start if necessary. */
-    newWriteOffsetLoopFlag = writeOffsetLoopFlag;
-    if (newWriteOffsetInBytes == pRB->subbufferSizeInBytes) {
-        newWriteOffsetInBytes = 0;
-        newWriteOffsetLoopFlag ^= 0x80000000;
-    }
-
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetLoopFlag, newWriteOffsetInBytes));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_seek_read(ma_rb* pRB, size_t offsetInBytes)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newReadOffsetInBytes;
-    ma_uint32 newReadOffsetLoopFlag;
-
-    if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    newReadOffsetLoopFlag = readOffsetLoopFlag;
-
-    /* We cannot go past the write buffer. */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        if ((readOffsetInBytes + offsetInBytes) > writeOffsetInBytes) {
-            newReadOffsetInBytes = writeOffsetInBytes;
-        } else {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes);
-        }
-    } else {
-        /* May end up looping. */
-        if ((readOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes;
-            newReadOffsetLoopFlag ^= 0x80000000;    /* <-- Looped. */
-        } else {
-            newReadOffsetInBytes = (ma_uint32)(readOffsetInBytes + offsetInBytes);
-        }
-    }
-
-    c89atomic_exchange_32(&pRB->encodedReadOffset, ma_rb__construct_offset(newReadOffsetInBytes, newReadOffsetLoopFlag));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_rb_seek_write(ma_rb* pRB, size_t offsetInBytes)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-    ma_uint32 newWriteOffsetInBytes;
-    ma_uint32 newWriteOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    newWriteOffsetLoopFlag = writeOffsetLoopFlag;
-
-    /* We cannot go past the write buffer. */
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        /* May end up looping. */
-        if ((writeOffsetInBytes + offsetInBytes) >= pRB->subbufferSizeInBytes) {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes) - pRB->subbufferSizeInBytes;
-            newWriteOffsetLoopFlag ^= 0x80000000;    /* <-- Looped. */
-        } else {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes);
-        }
-    } else {
-        if ((writeOffsetInBytes + offsetInBytes) > readOffsetInBytes) {
-            newWriteOffsetInBytes = readOffsetInBytes;
-        } else {
-            newWriteOffsetInBytes = (ma_uint32)(writeOffsetInBytes + offsetInBytes);
-        }
-    }
-
-    c89atomic_exchange_32(&pRB->encodedWriteOffset, ma_rb__construct_offset(newWriteOffsetInBytes, newWriteOffsetLoopFlag));
-    return MA_SUCCESS;
-}
-
-MA_API ma_int32 ma_rb_pointer_distance(ma_rb* pRB)
-{
-    ma_uint32 readOffset;
-    ma_uint32 readOffsetInBytes;
-    ma_uint32 readOffsetLoopFlag;
-    ma_uint32 writeOffset;
-    ma_uint32 writeOffsetInBytes;
-    ma_uint32 writeOffsetLoopFlag;
-
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    readOffset = c89atomic_load_32(&pRB->encodedReadOffset);
-    ma_rb__deconstruct_offset(readOffset, &readOffsetInBytes, &readOffsetLoopFlag);
-
-    writeOffset = c89atomic_load_32(&pRB->encodedWriteOffset);
-    ma_rb__deconstruct_offset(writeOffset, &writeOffsetInBytes, &writeOffsetLoopFlag);
-
-    if (readOffsetLoopFlag == writeOffsetLoopFlag) {
-        return writeOffsetInBytes - readOffsetInBytes;
-    } else {
-        return writeOffsetInBytes + (pRB->subbufferSizeInBytes - readOffsetInBytes);
-    }
-}
-
-MA_API ma_uint32 ma_rb_available_read(ma_rb* pRB)
-{
-    ma_int32 dist;
-
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    dist = ma_rb_pointer_distance(pRB);
-    if (dist < 0) {
-        return 0;
-    }
-
-    return dist;
-}
-
-MA_API ma_uint32 ma_rb_available_write(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_size(pRB) - ma_rb_pointer_distance(pRB));
-}
-
-MA_API size_t ma_rb_get_subbuffer_size(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return pRB->subbufferSizeInBytes;
-}
-
-MA_API size_t ma_rb_get_subbuffer_stride(ma_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    if (pRB->subbufferStrideInBytes == 0) {
-        return (size_t)pRB->subbufferSizeInBytes;
-    }
-
-    return (size_t)pRB->subbufferStrideInBytes;
-}
-
-MA_API size_t ma_rb_get_subbuffer_offset(ma_rb* pRB, size_t subbufferIndex)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return subbufferIndex * ma_rb_get_subbuffer_stride(pRB);
-}
-
-MA_API void* ma_rb_get_subbuffer_ptr(ma_rb* pRB, size_t subbufferIndex, void* pBuffer)
-{
-    if (pRB == NULL) {
-        return NULL;
-    }
-
-    return ma_offset_ptr(pBuffer, ma_rb_get_subbuffer_offset(pRB, subbufferIndex));
-}
-
-
-
-static MA_INLINE ma_uint32 ma_pcm_rb_get_bpf(ma_pcm_rb* pRB)
-{
-    MA_ASSERT(pRB != NULL);
-
-    return ma_get_bytes_per_frame(pRB->format, pRB->channels);
-}
-
-MA_API ma_result ma_pcm_rb_init_ex(ma_format format, ma_uint32 channels, ma_uint32 subbufferSizeInFrames, ma_uint32 subbufferCount, ma_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB)
-{
-    ma_uint32 bpf;
-    ma_result result;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pRB);
-
-    bpf = ma_get_bytes_per_frame(format, channels);
-    if (bpf == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_rb_init_ex(subbufferSizeInFrames*bpf, subbufferCount, subbufferStrideInFrames*bpf, pOptionalPreallocatedBuffer, pAllocationCallbacks, &pRB->rb);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pRB->format   = format;
-    pRB->channels = channels;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_init(ma_format format, ma_uint32 channels, ma_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, const ma_allocation_callbacks* pAllocationCallbacks, ma_pcm_rb* pRB)
-{
-    return ma_pcm_rb_init_ex(format, channels, bufferSizeInFrames, 1, 0, pOptionalPreallocatedBuffer, pAllocationCallbacks, pRB);
-}
-
-MA_API void ma_pcm_rb_uninit(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    ma_rb_uninit(&pRB->rb);
-}
-
-MA_API void ma_pcm_rb_reset(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return;
-    }
-
-    ma_rb_reset(&pRB->rb);
-}
-
-MA_API ma_result ma_pcm_rb_acquire_read(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut)
-{
-    size_t sizeInBytes;
-    ma_result result;
-
-    if (pRB == NULL || pSizeInFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB);
-
-    result = ma_rb_acquire_read(&pRB->rb, &sizeInBytes, ppBufferOut);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pSizeInFrames = (ma_uint32)(sizeInBytes / (size_t)ma_pcm_rb_get_bpf(pRB));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_commit_read(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_commit_read(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB), pBufferOut);
-}
-
-MA_API ma_result ma_pcm_rb_acquire_write(ma_pcm_rb* pRB, ma_uint32* pSizeInFrames, void** ppBufferOut)
-{
-    size_t sizeInBytes;
-    ma_result result;
-
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    sizeInBytes = *pSizeInFrames * ma_pcm_rb_get_bpf(pRB);
-
-    result = ma_rb_acquire_write(&pRB->rb, &sizeInBytes, ppBufferOut);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pSizeInFrames = (ma_uint32)(sizeInBytes / ma_pcm_rb_get_bpf(pRB));
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_pcm_rb_commit_write(ma_pcm_rb* pRB, ma_uint32 sizeInFrames, void* pBufferOut)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_commit_write(&pRB->rb, sizeInFrames * ma_pcm_rb_get_bpf(pRB), pBufferOut);
-}
-
-MA_API ma_result ma_pcm_rb_seek_read(ma_pcm_rb* pRB, ma_uint32 offsetInFrames)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_seek_read(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_result ma_pcm_rb_seek_write(ma_pcm_rb* pRB, ma_uint32 offsetInFrames)
-{
-    if (pRB == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_rb_seek_write(&pRB->rb, offsetInFrames * ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_int32 ma_pcm_rb_pointer_distance(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_pointer_distance(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_available_read(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_available_read(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_available_write(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return ma_rb_available_write(&pRB->rb) / ma_pcm_rb_get_bpf(pRB);
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_size(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_size(&pRB->rb) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_stride(ma_pcm_rb* pRB)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_stride(&pRB->rb) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API ma_uint32 ma_pcm_rb_get_subbuffer_offset(ma_pcm_rb* pRB, ma_uint32 subbufferIndex)
-{
-    if (pRB == NULL) {
-        return 0;
-    }
-
-    return (ma_uint32)(ma_rb_get_subbuffer_offset(&pRB->rb, subbufferIndex) / ma_pcm_rb_get_bpf(pRB));
-}
-
-MA_API void* ma_pcm_rb_get_subbuffer_ptr(ma_pcm_rb* pRB, ma_uint32 subbufferIndex, void* pBuffer)
-{
-    if (pRB == NULL) {
-        return NULL;
-    }
-
-    return ma_rb_get_subbuffer_ptr(&pRB->rb, subbufferIndex, pBuffer);
-}
-
-
-
-MA_API ma_result ma_duplex_rb_init(ma_format captureFormat, ma_uint32 captureChannels, ma_uint32 sampleRate, ma_uint32 captureInternalSampleRate, ma_uint32 captureInternalPeriodSizeInFrames, const ma_allocation_callbacks* pAllocationCallbacks, ma_duplex_rb* pRB)
-{
-    ma_result result;
-    ma_uint32 sizeInFrames;
-
-    sizeInFrames = (ma_uint32)ma_calculate_frame_count_after_resampling(sampleRate, captureInternalSampleRate, captureInternalPeriodSizeInFrames * 5);
-    if (sizeInFrames == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_pcm_rb_init(captureFormat, captureChannels, sizeInFrames, NULL, pAllocationCallbacks, &pRB->rb);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Seek forward a bit so we have a bit of a buffer in case of desyncs. */
-    ma_pcm_rb_seek_write((ma_pcm_rb*)pRB, captureInternalPeriodSizeInFrames * 2);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_duplex_rb_uninit(ma_duplex_rb* pRB)
-{
-    ma_pcm_rb_uninit((ma_pcm_rb*)pRB);
-    return MA_SUCCESS;
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Miscellaneous Helpers
-
-**************************************************************************************************************************************************************/
-MA_API const char* ma_result_description(ma_result result)
-{
-    switch (result)
-    {
-        case MA_SUCCESS:                       return "No error";
-        case MA_ERROR:                         return "Unknown error";
-        case MA_INVALID_ARGS:                  return "Invalid argument";
-        case MA_INVALID_OPERATION:             return "Invalid operation";
-        case MA_OUT_OF_MEMORY:                 return "Out of memory";
-        case MA_OUT_OF_RANGE:                  return "Out of range";
-        case MA_ACCESS_DENIED:                 return "Permission denied";
-        case MA_DOES_NOT_EXIST:                return "Resource does not exist";
-        case MA_ALREADY_EXISTS:                return "Resource already exists";
-        case MA_TOO_MANY_OPEN_FILES:           return "Too many open files";
-        case MA_INVALID_FILE:                  return "Invalid file";
-        case MA_TOO_BIG:                       return "Too large";
-        case MA_PATH_TOO_LONG:                 return "Path too long";
-        case MA_NAME_TOO_LONG:                 return "Name too long";
-        case MA_NOT_DIRECTORY:                 return "Not a directory";
-        case MA_IS_DIRECTORY:                  return "Is a directory";
-        case MA_DIRECTORY_NOT_EMPTY:           return "Directory not empty";
-        case MA_END_OF_FILE:                   return "End of file";
-        case MA_NO_SPACE:                      return "No space available";
-        case MA_BUSY:                          return "Device or resource busy";
-        case MA_IO_ERROR:                      return "Input/output error";
-        case MA_INTERRUPT:                     return "Interrupted";
-        case MA_UNAVAILABLE:                   return "Resource unavailable";
-        case MA_ALREADY_IN_USE:                return "Resource already in use";
-        case MA_BAD_ADDRESS:                   return "Bad address";
-        case MA_BAD_SEEK:                      return "Illegal seek";
-        case MA_BAD_PIPE:                      return "Broken pipe";
-        case MA_DEADLOCK:                      return "Deadlock";
-        case MA_TOO_MANY_LINKS:                return "Too many links";
-        case MA_NOT_IMPLEMENTED:               return "Not implemented";
-        case MA_NO_MESSAGE:                    return "No message of desired type";
-        case MA_BAD_MESSAGE:                   return "Invalid message";
-        case MA_NO_DATA_AVAILABLE:             return "No data available";
-        case MA_INVALID_DATA:                  return "Invalid data";
-        case MA_TIMEOUT:                       return "Timeout";
-        case MA_NO_NETWORK:                    return "Network unavailable";
-        case MA_NOT_UNIQUE:                    return "Not unique";
-        case MA_NOT_SOCKET:                    return "Socket operation on non-socket";
-        case MA_NO_ADDRESS:                    return "Destination address required";
-        case MA_BAD_PROTOCOL:                  return "Protocol wrong type for socket";
-        case MA_PROTOCOL_UNAVAILABLE:          return "Protocol not available";
-        case MA_PROTOCOL_NOT_SUPPORTED:        return "Protocol not supported";
-        case MA_PROTOCOL_FAMILY_NOT_SUPPORTED: return "Protocol family not supported";
-        case MA_ADDRESS_FAMILY_NOT_SUPPORTED:  return "Address family not supported";
-        case MA_SOCKET_NOT_SUPPORTED:          return "Socket type not supported";
-        case MA_CONNECTION_RESET:              return "Connection reset";
-        case MA_ALREADY_CONNECTED:             return "Already connected";
-        case MA_NOT_CONNECTED:                 return "Not connected";
-        case MA_CONNECTION_REFUSED:            return "Connection refused";
-        case MA_NO_HOST:                       return "No host";
-        case MA_IN_PROGRESS:                   return "Operation in progress";
-        case MA_CANCELLED:                     return "Operation cancelled";
-        case MA_MEMORY_ALREADY_MAPPED:         return "Memory already mapped";
-        case MA_AT_END:                        return "Reached end of collection";
-
-        case MA_FORMAT_NOT_SUPPORTED:          return "Format not supported";
-        case MA_DEVICE_TYPE_NOT_SUPPORTED:     return "Device type not supported";
-        case MA_SHARE_MODE_NOT_SUPPORTED:      return "Share mode not supported";
-        case MA_NO_BACKEND:                    return "No backend";
-        case MA_NO_DEVICE:                     return "No device";
-        case MA_API_NOT_FOUND:                 return "API not found";
-        case MA_INVALID_DEVICE_CONFIG:         return "Invalid device config";
-
-        case MA_DEVICE_NOT_INITIALIZED:        return "Device not initialized";
-        case MA_DEVICE_NOT_STARTED:            return "Device not started";
-
-        case MA_FAILED_TO_INIT_BACKEND:        return "Failed to initialize backend";
-        case MA_FAILED_TO_OPEN_BACKEND_DEVICE: return "Failed to open backend device";
-        case MA_FAILED_TO_START_BACKEND_DEVICE: return "Failed to start backend device";
-        case MA_FAILED_TO_STOP_BACKEND_DEVICE: return "Failed to stop backend device";
-
-        default:                               return "Unknown error";
-    }
-}
-
-MA_API void* ma_malloc(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return ma__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return ma__malloc_default(sz, NULL);
-    }
-}
-
-MA_API void* ma_realloc(void* p, size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        if (pAllocationCallbacks->onRealloc != NULL) {
-            return pAllocationCallbacks->onRealloc(p, sz, pAllocationCallbacks->pUserData);
-        } else {
-            return NULL;    /* This requires a native implementation of realloc(). */
-        }
-    } else {
-        return ma__realloc_default(p, sz, NULL);
-    }
-}
-
-MA_API void ma_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        ma__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        ma__free_default(p, NULL);
-    }
-}
-
-MA_API void* ma_aligned_malloc(size_t sz, size_t alignment, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    size_t extraBytes;
-    void* pUnaligned;
-    void* pAligned;
-
-    if (alignment == 0) {
-        return 0;
-    }
-
-    extraBytes = alignment-1 + sizeof(void*);
-
-    pUnaligned = ma_malloc(sz + extraBytes, pAllocationCallbacks);
-    if (pUnaligned == NULL) {
-        return NULL;
-    }
-
-    pAligned = (void*)(((ma_uintptr)pUnaligned + extraBytes) & ~((ma_uintptr)(alignment-1)));
-    ((void**)pAligned)[-1] = pUnaligned;
-
-    return pAligned;
-}
-
-MA_API void ma_aligned_free(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_free(((void**)p)[-1], pAllocationCallbacks);
-}
-
-MA_API const char* ma_get_format_name(ma_format format)
-{
-    switch (format)
-    {
-        case ma_format_unknown: return "Unknown";
-        case ma_format_u8:      return "8-bit Unsigned Integer";
-        case ma_format_s16:     return "16-bit Signed Integer";
-        case ma_format_s24:     return "24-bit Signed Integer (Tightly Packed)";
-        case ma_format_s32:     return "32-bit Signed Integer";
-        case ma_format_f32:     return "32-bit IEEE Floating Point";
-        default:                return "Invalid";
-    }
-}
-
-MA_API void ma_blend_f32(float* pOut, float* pInA, float* pInB, float factor, ma_uint32 channels)
-{
-    ma_uint32 i;
-    for (i = 0; i < channels; ++i) {
-        pOut[i] = ma_mix_f32(pInA[i], pInB[i], factor);
-    }
-}
-
-
-MA_API ma_uint32 ma_get_bytes_per_sample(ma_format format)
-{
-    ma_uint32 sizes[] = {
-        0,  /* unknown */
-        1,  /* u8 */
-        2,  /* s16 */
-        3,  /* s24 */
-        4,  /* s32 */
-        4,  /* f32 */
-    };
-    return sizes[format];
-}
-
-
-
-MA_API ma_result ma_data_source_read_pcm_frames(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead, ma_bool32 loop)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    /* Safety. */
-    if (pFramesRead != NULL) {
-        *pFramesRead = 0;
-    }
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onRead == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    /* A very small optimization for the non looping case. */
-    if (loop == MA_FALSE) {
-        return pCallbacks->onRead(pDataSource, pFramesOut, frameCount, pFramesRead);
-    } else {
-        ma_format format;
-        ma_uint32 channels;
-        ma_uint32 sampleRate;
-        if (ma_data_source_get_data_format(pDataSource, &format, &channels, &sampleRate) != MA_SUCCESS) {
-            return pCallbacks->onRead(pDataSource, pFramesOut, frameCount, pFramesRead); /* We don't have a way to retrieve the data format which means we don't know how to offset the output buffer. Just read as much as we can. */
-        } else {
-            ma_result result = MA_SUCCESS;
-            ma_uint64 totalFramesProcessed;
-            void* pRunningFramesOut = pFramesOut;
-
-            totalFramesProcessed = 0;
-            while (totalFramesProcessed < frameCount) {
-                ma_uint64 framesProcessed;
-                ma_uint64 framesRemaining = frameCount - totalFramesProcessed;
-
-                result = pCallbacks->onRead(pDataSource, pRunningFramesOut, framesRemaining, &framesProcessed);
-                totalFramesProcessed += framesProcessed;
-
-                /*
-                If we encounted an error from the read callback, make sure it's propagated to the caller. The caller may need to know whether or not MA_BUSY is returned which is
-                not necessarily considered an error.
-                */
-                if (result != MA_SUCCESS && result != MA_AT_END) {
-                    break;
-                }
-
-                /*
-                We can determine if we've reached the end by checking the return value of the onRead() callback. If it's less than what we requested it means
-                we've reached the end. To loop back to the start, all we need to do is seek back to the first frame.
-                */
-                if (framesProcessed < framesRemaining || result == MA_AT_END) {
-                    if (ma_data_source_seek_to_pcm_frame(pDataSource, 0) != MA_SUCCESS) {
-                        break;
-                    }
-                }
-
-                if (pRunningFramesOut != NULL) {
-                    pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesProcessed * ma_get_bytes_per_frame(format, channels));
-                }
-            }
-
-            if (pFramesRead != NULL) {
-                *pFramesRead = totalFramesProcessed;
-            }
-
-            return result;
-        }
-    }
-}
-
-MA_API ma_result ma_data_source_seek_pcm_frames(ma_data_source* pDataSource, ma_uint64 frameCount, ma_uint64* pFramesSeeked, ma_bool32 loop)
-{
-    return ma_data_source_read_pcm_frames(pDataSource, NULL, frameCount, pFramesSeeked, loop);
-}
-
-MA_API ma_result ma_data_source_seek_to_pcm_frame(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onSeek(pDataSource, frameIndex);
-}
-
-MA_API ma_result ma_data_source_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onMap == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onMap(pDataSource, ppFramesOut, pFrameCount);
-}
-
-MA_API ma_result ma_data_source_unmap(ma_data_source* pDataSource, ma_uint64 frameCount)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-    if (pCallbacks == NULL || pCallbacks->onUnmap == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return pCallbacks->onUnmap(pDataSource, frameCount);
-}
-
-MA_API ma_result ma_data_source_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_result result;
-    ma_format format;
-    ma_uint32 channels;
-    ma_uint32 sampleRate;
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pFormat != NULL) {
-        *pFormat = ma_format_unknown;
-    }
-
-    if (pChannels != NULL) {
-        *pChannels = 0;
-    }
-
-    if (pSampleRate != NULL) {
-        *pSampleRate = 0;
-    }
-
-    if (pCallbacks == NULL || pCallbacks->onGetDataFormat == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    result = pCallbacks->onGetDataFormat(pDataSource, &format, &channels, &sampleRate);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFormat != NULL) {
-        *pFormat = format;
-    }
-    if (pChannels != NULL) {
-        *pChannels = channels;
-    }
-    if (pSampleRate != NULL) {
-        *pSampleRate = sampleRate;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_data_source_get_cursor_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onGetCursor == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onGetCursor(pDataSource, pCursor);
-}
-
-MA_API ma_result ma_data_source_get_length_in_pcm_frames(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_data_source_callbacks* pCallbacks = (ma_data_source_callbacks*)pDataSource;
-
-    if (pLength == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pLength = 0;
-
-    if (pCallbacks == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onGetLength == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onGetLength(pDataSource, pLength);
-}
-
-
-
-
-static ma_result ma_audio_buffer_ref__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_audio_buffer_ref_read_pcm_frames((ma_audio_buffer_ref*)pDataSource, pFramesOut, frameCount, MA_FALSE);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_audio_buffer_ref_seek_to_pcm_frame((ma_audio_buffer_ref*)pDataSource, frameIndex);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_map(ma_data_source* pDataSource, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    return ma_audio_buffer_ref_map((ma_audio_buffer_ref*)pDataSource, ppFramesOut, pFrameCount);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_unmap(ma_data_source* pDataSource, ma_uint64 frameCount)
-{
-    return ma_audio_buffer_ref_unmap((ma_audio_buffer_ref*)pDataSource, frameCount);
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pFormat     = pAudioBufferRef->format;
-    *pChannels   = pAudioBufferRef->channels;
-    *pSampleRate = 0;   /* There is no notion of a sample rate with audio buffers. */
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pCursor = pAudioBufferRef->cursor;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_audio_buffer_ref__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_audio_buffer_ref* pAudioBufferRef = (ma_audio_buffer_ref*)pDataSource;
-
-    *pLength = pAudioBufferRef->sizeInFrames;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_init(ma_format format, ma_uint32 channels, const void* pData, ma_uint64 sizeInFrames, ma_audio_buffer_ref* pAudioBufferRef)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pAudioBufferRef);
-
-    pAudioBufferRef->ds.onRead          = ma_audio_buffer_ref__data_source_on_read;
-    pAudioBufferRef->ds.onSeek          = ma_audio_buffer_ref__data_source_on_seek;
-    pAudioBufferRef->ds.onMap           = ma_audio_buffer_ref__data_source_on_map;
-    pAudioBufferRef->ds.onUnmap         = ma_audio_buffer_ref__data_source_on_unmap;
-    pAudioBufferRef->ds.onGetDataFormat = ma_audio_buffer_ref__data_source_on_get_data_format;
-    pAudioBufferRef->ds.onGetCursor     = ma_audio_buffer_ref__data_source_on_get_cursor;
-    pAudioBufferRef->ds.onGetLength     = ma_audio_buffer_ref__data_source_on_get_length;
-    pAudioBufferRef->format             = format;
-    pAudioBufferRef->channels           = channels;
-    pAudioBufferRef->cursor             = 0;
-    pAudioBufferRef->sizeInFrames       = sizeInFrames;
-    pAudioBufferRef->pData              = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_set_data(ma_audio_buffer_ref* pAudioBufferRef, const void* pData, ma_uint64 sizeInFrames)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pAudioBufferRef->cursor       = 0;
-    pAudioBufferRef->sizeInFrames = sizeInFrames;
-    pAudioBufferRef->pData        = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint64 ma_audio_buffer_ref_read_pcm_frames(ma_audio_buffer_ref* pAudioBufferRef, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop)
-{
-    ma_uint64 totalFramesRead = 0;
-
-    if (pAudioBufferRef == NULL) {
-        return 0;
-    }
-
-    if (frameCount == 0) {
-        return 0;
-    }
-
-    while (totalFramesRead < frameCount) {
-        ma_uint64 framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-        ma_uint64 framesRemaining = frameCount - totalFramesRead;
-        ma_uint64 framesToRead;
-
-        framesToRead = framesRemaining;
-        if (framesToRead > framesAvailable) {
-            framesToRead = framesAvailable;
-        }
-
-        if (pFramesOut != NULL) {
-            ma_copy_pcm_frames(pFramesOut, ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels)), framesToRead, pAudioBufferRef->format, pAudioBufferRef->channels);
-        }
-
-        totalFramesRead += framesToRead;
-
-        pAudioBufferRef->cursor += framesToRead;
-        if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) {
-            if (loop) {
-                pAudioBufferRef->cursor = 0;
-            } else {
-                break;  /* We've reached the end and we're not looping. Done. */
-            }
-        }
-
-        MA_ASSERT(pAudioBufferRef->cursor < pAudioBufferRef->sizeInFrames);
-    }
-
-    return totalFramesRead;
-}
-
-MA_API ma_result ma_audio_buffer_ref_seek_to_pcm_frame(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameIndex)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (frameIndex > pAudioBufferRef->sizeInFrames) {
-        return MA_INVALID_ARGS;
-    }
-
-    pAudioBufferRef->cursor = (size_t)frameIndex;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_map(ma_audio_buffer_ref* pAudioBufferRef, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    ma_uint64 framesAvailable;
-    ma_uint64 frameCount = 0;
-
-    if (ppFramesOut != NULL) {
-        *ppFramesOut = NULL;    /* Safety. */
-    }
-
-    if (pFrameCount != NULL) {
-        frameCount = *pFrameCount;
-        *pFrameCount = 0;       /* Safety. */
-    }
-
-    if (pAudioBufferRef == NULL || ppFramesOut == NULL || pFrameCount == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    if (frameCount > framesAvailable) {
-        frameCount = framesAvailable;
-    }
-
-    *ppFramesOut = ma_offset_ptr(pAudioBufferRef->pData, pAudioBufferRef->cursor * ma_get_bytes_per_frame(pAudioBufferRef->format, pAudioBufferRef->channels));
-    *pFrameCount = frameCount;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_audio_buffer_ref_unmap(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64 frameCount)
-{
-    ma_uint64 framesAvailable;
-
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    framesAvailable = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    if (frameCount > framesAvailable) {
-        return MA_INVALID_ARGS;   /* The frame count was too big. This should never happen in an unmapping. Need to make sure the caller is aware of this. */
-    }
-
-    pAudioBufferRef->cursor += frameCount;
-
-    if (pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames) {
-        return MA_AT_END;   /* Successful. Need to tell the caller that the end has been reached so that it can loop if desired. */
-    } else {
-        return MA_SUCCESS;
-    }
-}
-
-MA_API ma_result ma_audio_buffer_ref_at_end(ma_audio_buffer_ref* pAudioBufferRef)
-{
-    if (pAudioBufferRef == NULL) {
-        return MA_FALSE;
-    }
-
-    return pAudioBufferRef->cursor == pAudioBufferRef->sizeInFrames;
-}
-
-MA_API ma_result ma_audio_buffer_ref_get_available_frames(ma_audio_buffer_ref* pAudioBufferRef, ma_uint64* pAvailableFrames)
-{
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pAudioBufferRef == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pAudioBufferRef->sizeInFrames <= pAudioBufferRef->cursor) {
-        *pAvailableFrames = 0;
-    } else {
-        *pAvailableFrames = pAudioBufferRef->sizeInFrames - pAudioBufferRef->cursor;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-
-
-MA_API ma_audio_buffer_config ma_audio_buffer_config_init(ma_format format, ma_uint32 channels, ma_uint64 sizeInFrames, const void* pData, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    ma_audio_buffer_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format = format;
-    config.channels = channels;
-    config.sizeInFrames = sizeInFrames;
-    config.pData = pData;
-    ma_allocation_callbacks_init_copy(&config.allocationCallbacks, pAllocationCallbacks);
-
-    return config;
-}
-
-static ma_result ma_audio_buffer_init_ex(const ma_audio_buffer_config* pConfig, ma_bool32 doCopy, ma_audio_buffer* pAudioBuffer)
-{
-    ma_result result;
-
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_MEMORY(pAudioBuffer, sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData));   /* Safety. Don't overwrite the extra data. */
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->sizeInFrames == 0) {
-        return MA_INVALID_ARGS; /* Not allowing buffer sizes of 0 frames. */
-    }
-
-    result = ma_audio_buffer_ref_init(pConfig->format, pConfig->channels, NULL, 0, &pAudioBuffer->ref);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-    
-    ma_allocation_callbacks_init_copy(&pAudioBuffer->allocationCallbacks, &pConfig->allocationCallbacks);
-
-    if (doCopy) {
-        ma_uint64 allocationSizeInBytes;
-        void* pData;
-
-        allocationSizeInBytes = pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels);
-        if (allocationSizeInBytes > MA_SIZE_MAX) {
-            return MA_OUT_OF_MEMORY;    /* Too big. */
-        }
-
-        pData = ma__malloc_from_callbacks((size_t)allocationSizeInBytes, &pAudioBuffer->allocationCallbacks);   /* Safe cast to size_t. */
-        if (pData == NULL) {
-            return MA_OUT_OF_MEMORY;
-        }
-
-        if (pConfig->pData != NULL) {
-            ma_copy_pcm_frames(pData, pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-        } else {
-            ma_silence_pcm_frames(pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-        }
-
-        ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pData, pConfig->sizeInFrames);
-        pAudioBuffer->ownsData = MA_TRUE;
-    } else {
-        ma_audio_buffer_ref_set_data(&pAudioBuffer->ref, pConfig->pData, pConfig->sizeInFrames);
-        pAudioBuffer->ownsData = MA_FALSE;
-    }
-
-    return MA_SUCCESS;
-}
-
-static void ma_audio_buffer_uninit_ex(ma_audio_buffer* pAudioBuffer, ma_bool32 doFree)
-{
-    if (pAudioBuffer == NULL) {
-        return;
-    }
-
-    if (pAudioBuffer->ownsData && pAudioBuffer->ref.pData != &pAudioBuffer->_pExtraData[0]) {
-        ma__free_from_callbacks((void*)pAudioBuffer->ref.pData, &pAudioBuffer->allocationCallbacks);    /* Naugty const cast, but OK in this case since we've guarded it with the ownsData check. */
-    }
-
-    if (doFree) {
-        ma__free_from_callbacks(pAudioBuffer, &pAudioBuffer->allocationCallbacks);
-    }
-}
-
-MA_API ma_result ma_audio_buffer_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer)
-{
-    return ma_audio_buffer_init_ex(pConfig, MA_FALSE, pAudioBuffer);
-}
-
-MA_API ma_result ma_audio_buffer_init_copy(const ma_audio_buffer_config* pConfig, ma_audio_buffer* pAudioBuffer)
-{
-    return ma_audio_buffer_init_ex(pConfig, MA_TRUE, pAudioBuffer);
-}
-
-MA_API ma_result ma_audio_buffer_alloc_and_init(const ma_audio_buffer_config* pConfig, ma_audio_buffer** ppAudioBuffer)
-{
-    ma_result result;
-    ma_audio_buffer* pAudioBuffer;
-    ma_audio_buffer_config innerConfig; /* We'll be making some changes to the config, so need to make a copy. */
-    ma_uint64 allocationSizeInBytes;
-
-    if (ppAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *ppAudioBuffer = NULL;  /* Safety. */
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    innerConfig = *pConfig;
-    ma_allocation_callbacks_init_copy(&innerConfig.allocationCallbacks, &pConfig->allocationCallbacks);
-
-    allocationSizeInBytes = sizeof(*pAudioBuffer) - sizeof(pAudioBuffer->_pExtraData) + (pConfig->sizeInFrames * ma_get_bytes_per_frame(pConfig->format, pConfig->channels));
-    if (allocationSizeInBytes > MA_SIZE_MAX) {
-        return MA_OUT_OF_MEMORY;    /* Too big. */
-    }
-
-    pAudioBuffer = (ma_audio_buffer*)ma__malloc_from_callbacks((size_t)allocationSizeInBytes, &innerConfig.allocationCallbacks);  /* Safe cast to size_t. */
-    if (pAudioBuffer == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    if (pConfig->pData != NULL) {
-        ma_copy_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->pData, pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-    } else {
-        ma_silence_pcm_frames(&pAudioBuffer->_pExtraData[0], pConfig->sizeInFrames, pConfig->format, pConfig->channels);
-    }
-
-    innerConfig.pData = &pAudioBuffer->_pExtraData[0];
-
-    result = ma_audio_buffer_init_ex(&innerConfig, MA_FALSE, pAudioBuffer);
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pAudioBuffer, &innerConfig.allocationCallbacks);
-        return result;
-    }
-
-    *ppAudioBuffer = pAudioBuffer;
-
-    return MA_SUCCESS;
-}
-
-MA_API void ma_audio_buffer_uninit(ma_audio_buffer* pAudioBuffer)
-{
-    ma_audio_buffer_uninit_ex(pAudioBuffer, MA_FALSE);
-}
-
-MA_API void ma_audio_buffer_uninit_and_free(ma_audio_buffer* pAudioBuffer)
-{
-    ma_audio_buffer_uninit_ex(pAudioBuffer, MA_TRUE);
-}
-
-MA_API ma_uint64 ma_audio_buffer_read_pcm_frames(ma_audio_buffer* pAudioBuffer, void* pFramesOut, ma_uint64 frameCount, ma_bool32 loop)
-{
-    if (pAudioBuffer == NULL) {
-        return 0;
-    }
-
-    return ma_audio_buffer_ref_read_pcm_frames(&pAudioBuffer->ref, pFramesOut, frameCount, loop);
-}
-
-MA_API ma_result ma_audio_buffer_seek_to_pcm_frame(ma_audio_buffer* pAudioBuffer, ma_uint64 frameIndex)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_seek_to_pcm_frame(&pAudioBuffer->ref, frameIndex);
-}
-
-MA_API ma_result ma_audio_buffer_map(ma_audio_buffer* pAudioBuffer, void** ppFramesOut, ma_uint64* pFrameCount)
-{
-    if (ppFramesOut != NULL) {
-        *ppFramesOut = NULL;    /* Safety. */
-    }
-
-    if (pAudioBuffer == NULL) {
-        if (pFrameCount != NULL) {
-            *pFrameCount = 0;
-        }
-
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_map(&pAudioBuffer->ref, ppFramesOut, pFrameCount);
-}
-
-MA_API ma_result ma_audio_buffer_unmap(ma_audio_buffer* pAudioBuffer, ma_uint64 frameCount)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_unmap(&pAudioBuffer->ref, frameCount);
-}
-
-MA_API ma_result ma_audio_buffer_at_end(ma_audio_buffer* pAudioBuffer)
-{
-    if (pAudioBuffer == NULL) {
-        return MA_FALSE;
-    }
-
-    return ma_audio_buffer_ref_at_end(&pAudioBuffer->ref);
-}
-
-MA_API ma_result ma_audio_buffer_get_available_frames(ma_audio_buffer* pAudioBuffer, ma_uint64* pAvailableFrames)
-{
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pAudioBuffer == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    return ma_audio_buffer_ref_get_available_frames(&pAudioBuffer->ref, pAvailableFrames);
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-VFS
-
-**************************************************************************************************************************************************************/
-MA_API ma_result ma_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pVFS == NULL || pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onOpen == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onOpen(pVFS, pFilePath, openMode, pFile);
-}
-
-MA_API ma_result ma_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pVFS == NULL || pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onOpenW == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onOpenW(pVFS, pFilePath, openMode, pFile);
-}
-
-MA_API ma_result ma_vfs_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onClose == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onClose(pVFS, file);
-}
-
-MA_API ma_result ma_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = 0;
-    }
-
-    if (pVFS == NULL || file == NULL || pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onRead == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onRead(pVFS, file, pDst, sizeInBytes, pBytesRead);
-}
-
-MA_API ma_result ma_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = 0;
-    }
-
-    if (pVFS == NULL || file == NULL || pSrc == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onWrite == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onWrite(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-}
-
-MA_API ma_result ma_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onSeek == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onSeek(pVFS, file, offset, origin);
-}
-
-MA_API ma_result ma_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onTell == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onTell(pVFS, file, pCursor);
-}
-
-MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    ma_vfs_callbacks* pCallbacks = (ma_vfs_callbacks*)pVFS;
-
-    if (pInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pInfo);
-
-    if (pVFS == NULL || file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pCallbacks->onInfo == NULL) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return pCallbacks->onInfo(pVFS, file, pInfo);
-}
-
-
-static ma_result ma_vfs_open_and_read_file_ex(ma_vfs* pVFS, const char* pFilePath, const wchar_t* pFilePathW, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks, ma_uint32 allocationType)
-{
-    ma_result result;
-    ma_vfs_file file;
-    ma_file_info info;
-    void* pData;
-    size_t bytesRead;
-
-    (void)allocationType;
-
-    if (ppData != NULL) {
-        *ppData = NULL;
-    }
-    if (pSize != NULL) {
-        *pSize = 0;
-    }
-
-    if (ppData == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pFilePath != NULL) {
-        result = ma_vfs_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    } else {
-        result = ma_vfs_open_w(pVFS, pFilePathW, MA_OPEN_MODE_READ, &file);
-    }
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_vfs_info(pVFS, file, &info);
-    if (result != MA_SUCCESS) {
-        ma_vfs_close(pVFS, file);
-        return result;
-    }
-
-    if (info.sizeInBytes > MA_SIZE_MAX) {
-        ma_vfs_close(pVFS, file);
-        return MA_TOO_BIG;
-    }
-
-    pData = ma__malloc_from_callbacks((size_t)info.sizeInBytes, pAllocationCallbacks);  /* Safe cast. */
-    if (pData == NULL) {
-        ma_vfs_close(pVFS, file);
-        return result;
-    }
-
-    result = ma_vfs_read(pVFS, file, pData, (size_t)info.sizeInBytes, &bytesRead);  /* Safe cast. */
-    ma_vfs_close(pVFS, file);
-
-    if (result != MA_SUCCESS) {
-        ma__free_from_callbacks(pData, pAllocationCallbacks);
-        return result;
-    }
-
-    if (pSize != NULL) {
-        *pSize = bytesRead;
-    }
-
-    MA_ASSERT(ppData != NULL);
-    *ppData = pData;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_vfs_open_and_read_file(ma_vfs* pVFS, const char* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    return ma_vfs_open_and_read_file_ex(pVFS, pFilePath, NULL, ppData, pSize, pAllocationCallbacks, 0 /*MA_ALLOCATION_TYPE_GENERAL*/);
-}
-
-MA_API ma_result ma_vfs_open_and_read_file_w(ma_vfs* pVFS, const wchar_t* pFilePath, void** ppData, size_t* pSize, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    return ma_vfs_open_and_read_file_ex(pVFS, NULL, pFilePath, ppData, pSize, pAllocationCallbacks, 0 /*MA_ALLOCATION_TYPE_GENERAL*/);
-}
-
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-static void ma_default_vfs__get_open_settings_win32(ma_uint32 openMode, DWORD* pDesiredAccess, DWORD* pShareMode, DWORD* pCreationDisposition)
-{
-    *pDesiredAccess = 0;
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        *pDesiredAccess |= GENERIC_READ;
-    }
-    if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-        *pDesiredAccess |= GENERIC_WRITE;
-    }
-
-    *pShareMode = 0;
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        *pShareMode |= FILE_SHARE_READ;
-    }
-
-    if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-        *pCreationDisposition = CREATE_ALWAYS;  /* Opening in write mode. Truncate. */
-    } else {
-        *pCreationDisposition = OPEN_EXISTING;  /* Opening in read mode. File must exist. */
-    }
-}
-
-static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    HANDLE hFile;
-    DWORD dwDesiredAccess;
-    DWORD dwShareMode;
-    DWORD dwCreationDisposition;
-
-    (void)pVFS;
-
-    ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition);
-
-    hFile = CreateFileA(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile == INVALID_HANDLE_VALUE) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    *pFile = hFile;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    HANDLE hFile;
-    DWORD dwDesiredAccess;
-    DWORD dwShareMode;
-    DWORD dwCreationDisposition;
-
-    (void)pVFS;
-
-    ma_default_vfs__get_open_settings_win32(openMode, &dwDesiredAccess, &dwShareMode, &dwCreationDisposition);
-
-    hFile = CreateFileW(pFilePath, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
-    if (hFile == INVALID_HANDLE_VALUE) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    *pFile = hFile;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_close__win32(ma_vfs* pVFS, ma_vfs_file file)
-{
-    (void)pVFS;
-
-    if (CloseHandle((HANDLE)file) == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_default_vfs_read__win32(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    ma_result result = MA_SUCCESS;
-    size_t totalBytesRead;
-
-    (void)pVFS;
-
-    totalBytesRead = 0;
-    while (totalBytesRead < sizeInBytes) {
-        size_t bytesRemaining;
-        DWORD bytesToRead;
-        DWORD bytesRead;
-        BOOL readResult;
-
-        bytesRemaining = sizeInBytes - totalBytesRead;
-        if (bytesRemaining >= 0xFFFFFFFF) {
-            bytesToRead = 0xFFFFFFFF;
-        } else {
-            bytesToRead = (DWORD)bytesRemaining;
-        }
-
-        readResult = ReadFile((HANDLE)file, ma_offset_ptr(pDst, totalBytesRead), bytesToRead, &bytesRead, NULL);
-        if (readResult == 1 && bytesRead == 0) {
-            break;  /* EOF */
-        }
-
-        totalBytesRead += bytesRead;
-
-        if (bytesRead < bytesToRead) {
-            break;  /* EOF */
-        }
-
-        if (readResult == 0) {
-            result = ma_result_from_GetLastError(GetLastError());
-            break;
-        }
-    }
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = totalBytesRead;
-    }
-
-    return result;
-}
-
-static ma_result ma_default_vfs_write__win32(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    ma_result result = MA_SUCCESS;
-    size_t totalBytesWritten;
-
-    (void)pVFS;
-
-    totalBytesWritten = 0;
-    while (totalBytesWritten < sizeInBytes) {
-        size_t bytesRemaining;
-        DWORD bytesToWrite;
-        DWORD bytesWritten;
-        BOOL writeResult;
-
-        bytesRemaining = sizeInBytes - totalBytesWritten;
-        if (bytesRemaining >= 0xFFFFFFFF) {
-            bytesToWrite = 0xFFFFFFFF;
-        } else {
-            bytesToWrite = (DWORD)bytesRemaining;
-        }
-
-        writeResult = WriteFile((HANDLE)file, ma_offset_ptr(pSrc, totalBytesWritten), bytesToWrite, &bytesWritten, NULL);
-        totalBytesWritten += bytesWritten;
-
-        if (writeResult == 0) {
-            result = ma_result_from_GetLastError(GetLastError());
-            break;
-        }
-    }
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = totalBytesWritten;
-    }
-
-    return result;
-}
-
-
-static ma_result ma_default_vfs_seek__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    LARGE_INTEGER liDistanceToMove;
-    DWORD dwMoveMethod;
-    BOOL result;
-
-    (void)pVFS;
-
-    liDistanceToMove.QuadPart = offset;
-
-    /*  */ if (origin == ma_seek_origin_current) {
-        dwMoveMethod = FILE_CURRENT;
-    } else if (origin == ma_seek_origin_end) {
-        dwMoveMethod = FILE_END;
-    } else {
-        dwMoveMethod = FILE_BEGIN;
-    }
-
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    /* No SetFilePointerEx() so restrict to 31 bits. */
-    if (origin > 0x7FFFFFFF) {
-        return MA_OUT_OF_RANGE;
-    }
-
-    result = SetFilePointer((HANDLE)file, (LONG)liDistanceToMove.QuadPart, NULL, dwMoveMethod);
-#else
-    result = SetFilePointerEx((HANDLE)file, liDistanceToMove, NULL, dwMoveMethod);
-#endif
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    LARGE_INTEGER liZero;
-    LARGE_INTEGER liTell;
-    BOOL result;
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    LONG tell;
-#endif
-
-    (void)pVFS;
-
-    liZero.QuadPart = 0;
-
-#if (defined(_MSC_VER) && _MSC_VER <= 1200) || defined(__DMC__)
-    result = SetFilePointer((HANDLE)file, (LONG)liZero.QuadPart, &tell, FILE_CURRENT);
-    liTell.QuadPart = tell;
-#else
-    result = SetFilePointerEx((HANDLE)file, liZero, &liTell, FILE_CURRENT);
-#endif
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    if (pCursor != NULL) {
-        *pCursor = liTell.QuadPart;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    BY_HANDLE_FILE_INFORMATION fi;
-    BOOL result;
-
-    (void)pVFS;
-
-    result = GetFileInformationByHandle((HANDLE)file, &fi);
-    if (result == 0) {
-        return ma_result_from_GetLastError(GetLastError());
-    }
-
-    pInfo->sizeInBytes = ((ma_uint64)fi.nFileSizeHigh << 32) | ((ma_uint64)fi.nFileSizeLow);
-
-    return MA_SUCCESS;
-}
-#else
-static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_result result;
-    FILE* pFileStd;
-    const char* pOpenModeStr;
-
-    MA_ASSERT(pFilePath != NULL);
-    MA_ASSERT(openMode  != 0);
-    MA_ASSERT(pFile     != NULL);
-
-    (void)pVFS;
-
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-            pOpenModeStr = "r+";
-        } else {
-            pOpenModeStr = "rb";
-        }
-    } else {
-        pOpenModeStr = "wb";
-    }
-
-    result = ma_fopen(&pFileStd, pFilePath, pOpenModeStr);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pFile = pFileStd;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_open_w__stdio(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    ma_result result;
-    FILE* pFileStd;
-    const wchar_t* pOpenModeStr;
-
-    MA_ASSERT(pFilePath != NULL);
-    MA_ASSERT(openMode  != 0);
-    MA_ASSERT(pFile     != NULL);
-
-    (void)pVFS;
-
-    if ((openMode & MA_OPEN_MODE_READ) != 0) {
-        if ((openMode & MA_OPEN_MODE_WRITE) != 0) {
-            pOpenModeStr = L"r+";
-        } else {
-            pOpenModeStr = L"rb";
-        }
-    } else {
-        pOpenModeStr = L"wb";
-    }
-
-    result = ma_wfopen(&pFileStd, pFilePath, pOpenModeStr, (pVFS != NULL) ? &((ma_default_vfs*)pVFS)->allocationCallbacks : NULL);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    *pFile = pFileStd;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_close__stdio(ma_vfs* pVFS, ma_vfs_file file)
-{
-    MA_ASSERT(file != NULL);
-
-    (void)pVFS;
-
-    fclose((FILE*)file);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_read__stdio(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    size_t result;
-
-    MA_ASSERT(file != NULL);
-    MA_ASSERT(pDst != NULL);
-
-    (void)pVFS;
-
-    result = fread(pDst, 1, sizeInBytes, (FILE*)file);
-
-    if (pBytesRead != NULL) {
-        *pBytesRead = result;
-    }
-
-    if (result != sizeInBytes) {
-        if (feof((FILE*)file)) {
-            return MA_END_OF_FILE;
-        } else {
-            return ma_result_from_errno(ferror((FILE*)file));
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_write__stdio(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    size_t result;
-
-    MA_ASSERT(file != NULL);
-    MA_ASSERT(pSrc != NULL);
-
-    (void)pVFS;
-
-    result = fwrite(pSrc, 1, sizeInBytes, (FILE*)file);
-
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = result;
-    }
-
-    if (result != sizeInBytes) {
-        return ma_result_from_errno(ferror((FILE*)file));
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_seek__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    int result;
-
-    MA_ASSERT(file != NULL);
-
-    (void)pVFS;
-
-#if defined(_WIN32)
-    #if defined(_MSC_VER) && _MSC_VER > 1200
-        result = _fseeki64((FILE*)file, offset, origin);
-    #else
-        /* No _fseeki64() so restrict to 31 bits. */
-        if (origin > 0x7FFFFFFF) {
-            return MA_OUT_OF_RANGE;
-        }
-
-        result = fseek((FILE*)file, (int)offset, origin);
-    #endif
-#else
-    result = fseek((FILE*)file, (long int)offset, origin);
-#endif
-    if (result != 0) {
-        return MA_ERROR;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_default_vfs_tell__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    ma_int64 result;
-
-    MA_ASSERT(file    != NULL);
-    MA_ASSERT(pCursor != NULL);
-
-    (void)pVFS;
-
-#if defined(_WIN32)
-    #if defined(_MSC_VER) && _MSC_VER > 1200
-        result = _ftelli64((FILE*)file);
-    #else
-        result = ftell((FILE*)file);
-    #endif
-#else
-    result = ftell((FILE*)file);
-#endif
-
-    *pCursor = result;
-
-    return MA_SUCCESS;
-}
-
-#if !defined(_MSC_VER) && !((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 1) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)) && !defined(MA_BSD)
-int fileno(FILE *stream);
-#endif
-
-static ma_result ma_default_vfs_info__stdio(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    int fd;
-    struct stat info;
-
-    MA_ASSERT(file  != NULL);
-    MA_ASSERT(pInfo != NULL);
-
-    (void)pVFS;
-
-#if defined(_MSC_VER)
-    fd = _fileno((FILE*)file);
-#else
-    fd =  fileno((FILE*)file);
-#endif
-
-    if (fstat(fd, &info) != 0) {
-        return ma_result_from_errno(errno);
-    }
-
-    pInfo->sizeInBytes = info.st_size;
-
-    return MA_SUCCESS;
-}
-#endif
-
-
-static ma_result ma_default_vfs_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_open__win32(pVFS, pFilePath, openMode, pFile);
-#else
-    return ma_default_vfs_open__stdio(pVFS, pFilePath, openMode, pFile);
-#endif
-}
-
-static ma_result ma_default_vfs_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pFile == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pFile = NULL;
-
-    if (pFilePath == NULL || openMode == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_open_w__win32(pVFS, pFilePath, openMode, pFile);
-#else
-    return ma_default_vfs_open_w__stdio(pVFS, pFilePath, openMode, pFile);
-#endif
-}
-
-static ma_result ma_default_vfs_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_close__win32(pVFS, file);
-#else
-    return ma_default_vfs_close__stdio(pVFS, file);
-#endif
-}
-
-static ma_result ma_default_vfs_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    if (pBytesRead != NULL) {
-        *pBytesRead = 0;
-    }
-
-    if (file == NULL || pDst == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_read__win32(pVFS, file, pDst, sizeInBytes, pBytesRead);
-#else
-    return ma_default_vfs_read__stdio(pVFS, file, pDst, sizeInBytes, pBytesRead);
-#endif
-}
-
-static ma_result ma_default_vfs_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    if (pBytesWritten != NULL) {
-        *pBytesWritten = 0;
-    }
-
-    if (file == NULL || pSrc == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_write__win32(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-#else
-    return ma_default_vfs_write__stdio(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-#endif
-}
-
-static ma_result ma_default_vfs_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_seek__win32(pVFS, file, offset, origin);
-#else
-    return ma_default_vfs_seek__stdio(pVFS, file, offset, origin);
-#endif
-}
-
-static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_tell__win32(pVFS, file, pCursor);
-#else
-    return ma_default_vfs_tell__stdio(pVFS, file, pCursor);
-#endif
-}
-
-static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    if (pInfo == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pInfo);
-
-    if (file == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-#if defined(MA_WIN32) && defined(MA_WIN32_DESKTOP)
-    return ma_default_vfs_info__win32(pVFS, file, pInfo);
-#else
-    return ma_default_vfs_info__stdio(pVFS, file, pInfo);
-#endif
-}
-
-
-MA_API ma_result ma_default_vfs_init(ma_default_vfs* pVFS, const ma_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pVFS == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pVFS->cb.onOpen  = ma_default_vfs_open;
-    pVFS->cb.onOpenW = ma_default_vfs_open_w;
-    pVFS->cb.onClose = ma_default_vfs_close;
-    pVFS->cb.onRead  = ma_default_vfs_read;
-    pVFS->cb.onWrite = ma_default_vfs_write;
-    pVFS->cb.onSeek  = ma_default_vfs_seek;
-    pVFS->cb.onTell  = ma_default_vfs_tell;
-    pVFS->cb.onInfo  = ma_default_vfs_info;
-    ma_allocation_callbacks_init_copy(&pVFS->allocationCallbacks, pAllocationCallbacks);
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_vfs_or_default_open(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_open(pVFS, pFilePath, openMode, pFile);
-    } else {
-        return ma_default_vfs_open(pVFS, pFilePath, openMode, pFile);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_open_w(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_open_w(pVFS, pFilePath, openMode, pFile);
-    } else {
-        return ma_default_vfs_open_w(pVFS, pFilePath, openMode, pFile);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_close(ma_vfs* pVFS, ma_vfs_file file)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_close(pVFS, file);
-    } else {
-        return ma_default_vfs_close(pVFS, file);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_read(ma_vfs* pVFS, ma_vfs_file file, void* pDst, size_t sizeInBytes, size_t* pBytesRead)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead);
-    } else {
-        return ma_default_vfs_read(pVFS, file, pDst, sizeInBytes, pBytesRead);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_write(ma_vfs* pVFS, ma_vfs_file file, const void* pSrc, size_t sizeInBytes, size_t* pBytesWritten)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-    } else {
-        return ma_default_vfs_write(pVFS, file, pSrc, sizeInBytes, pBytesWritten);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_seek(ma_vfs* pVFS, ma_vfs_file file, ma_int64 offset, ma_seek_origin origin)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_seek(pVFS, file, offset, origin);
-    } else {
-        return ma_default_vfs_seek(pVFS, file, offset, origin);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* pCursor)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_tell(pVFS, file, pCursor);
-    } else {
-        return ma_default_vfs_tell(pVFS, file, pCursor);
-    }
-}
-
-MA_API ma_result ma_vfs_or_default_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
-{
-    if (pVFS != NULL) {
-        return ma_vfs_info(pVFS, file, pInfo);
-    } else {
-        return ma_default_vfs_info(pVFS, file, pInfo);
-    }
-}
-
-
-
-/**************************************************************************************************************************************************************
-
-Decoding and Encoding Headers. These are auto-generated from a tool.
-
-**************************************************************************************************************************************************************/
-#if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING))
-/* dr_wav_h begin */
-#ifndef dr_wav_h
-#define dr_wav_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRWAV_STRINGIFY(x)      #x
-#define DRWAV_XSTRINGIFY(x)     DRWAV_STRINGIFY(x)
-#define DRWAV_VERSION_MAJOR     0
-#define DRWAV_VERSION_MINOR     12
-#define DRWAV_VERSION_REVISION  19
-#define DRWAV_VERSION_STRING    DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drwav_int8;
-typedef unsigned char           drwav_uint8;
-typedef   signed short          drwav_int16;
-typedef unsigned short          drwav_uint16;
-typedef   signed int            drwav_int32;
-typedef unsigned int            drwav_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drwav_int64;
-    typedef unsigned __int64    drwav_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drwav_int64;
-    typedef unsigned long long  drwav_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drwav_uint64        drwav_uintptr;
-#else
-    typedef drwav_uint32        drwav_uintptr;
-#endif
-typedef drwav_uint8             drwav_bool8;
-typedef drwav_uint32            drwav_bool32;
-#define DRWAV_TRUE              1
-#define DRWAV_FALSE             0
-#if !defined(DRWAV_API)
-    #if defined(DRWAV_DLL)
-        #if defined(_WIN32)
-            #define DRWAV_DLL_IMPORT  __declspec(dllimport)
-            #define DRWAV_DLL_EXPORT  __declspec(dllexport)
-            #define DRWAV_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRWAV_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRWAV_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRWAV_DLL_IMPORT
-                #define DRWAV_DLL_EXPORT
-                #define DRWAV_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_WAV_IMPLEMENTATION) || defined(DRWAV_IMPLEMENTATION)
-            #define DRWAV_API  DRWAV_DLL_EXPORT
-        #else
-            #define DRWAV_API  DRWAV_DLL_IMPORT
-        #endif
-        #define DRWAV_PRIVATE DRWAV_DLL_PRIVATE
-    #else
-        #define DRWAV_API extern
-        #define DRWAV_PRIVATE static
-    #endif
-#endif
-typedef drwav_int32 drwav_result;
-#define DRWAV_SUCCESS                        0
-#define DRWAV_ERROR                         -1
-#define DRWAV_INVALID_ARGS                  -2
-#define DRWAV_INVALID_OPERATION             -3
-#define DRWAV_OUT_OF_MEMORY                 -4
-#define DRWAV_OUT_OF_RANGE                  -5
-#define DRWAV_ACCESS_DENIED                 -6
-#define DRWAV_DOES_NOT_EXIST                -7
-#define DRWAV_ALREADY_EXISTS                -8
-#define DRWAV_TOO_MANY_OPEN_FILES           -9
-#define DRWAV_INVALID_FILE                  -10
-#define DRWAV_TOO_BIG                       -11
-#define DRWAV_PATH_TOO_LONG                 -12
-#define DRWAV_NAME_TOO_LONG                 -13
-#define DRWAV_NOT_DIRECTORY                 -14
-#define DRWAV_IS_DIRECTORY                  -15
-#define DRWAV_DIRECTORY_NOT_EMPTY           -16
-#define DRWAV_END_OF_FILE                   -17
-#define DRWAV_NO_SPACE                      -18
-#define DRWAV_BUSY                          -19
-#define DRWAV_IO_ERROR                      -20
-#define DRWAV_INTERRUPT                     -21
-#define DRWAV_UNAVAILABLE                   -22
-#define DRWAV_ALREADY_IN_USE                -23
-#define DRWAV_BAD_ADDRESS                   -24
-#define DRWAV_BAD_SEEK                      -25
-#define DRWAV_BAD_PIPE                      -26
-#define DRWAV_DEADLOCK                      -27
-#define DRWAV_TOO_MANY_LINKS                -28
-#define DRWAV_NOT_IMPLEMENTED               -29
-#define DRWAV_NO_MESSAGE                    -30
-#define DRWAV_BAD_MESSAGE                   -31
-#define DRWAV_NO_DATA_AVAILABLE             -32
-#define DRWAV_INVALID_DATA                  -33
-#define DRWAV_TIMEOUT                       -34
-#define DRWAV_NO_NETWORK                    -35
-#define DRWAV_NOT_UNIQUE                    -36
-#define DRWAV_NOT_SOCKET                    -37
-#define DRWAV_NO_ADDRESS                    -38
-#define DRWAV_BAD_PROTOCOL                  -39
-#define DRWAV_PROTOCOL_UNAVAILABLE          -40
-#define DRWAV_PROTOCOL_NOT_SUPPORTED        -41
-#define DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRWAV_SOCKET_NOT_SUPPORTED          -44
-#define DRWAV_CONNECTION_RESET              -45
-#define DRWAV_ALREADY_CONNECTED             -46
-#define DRWAV_NOT_CONNECTED                 -47
-#define DRWAV_CONNECTION_REFUSED            -48
-#define DRWAV_NO_HOST                       -49
-#define DRWAV_IN_PROGRESS                   -50
-#define DRWAV_CANCELLED                     -51
-#define DRWAV_MEMORY_ALREADY_MAPPED         -52
-#define DRWAV_AT_END                        -53
-#define DR_WAVE_FORMAT_PCM          0x1
-#define DR_WAVE_FORMAT_ADPCM        0x2
-#define DR_WAVE_FORMAT_IEEE_FLOAT   0x3
-#define DR_WAVE_FORMAT_ALAW         0x6
-#define DR_WAVE_FORMAT_MULAW        0x7
-#define DR_WAVE_FORMAT_DVI_ADPCM    0x11
-#define DR_WAVE_FORMAT_EXTENSIBLE   0xFFFE
-#ifndef DRWAV_MAX_SMPL_LOOPS
-#define DRWAV_MAX_SMPL_LOOPS        1
-#endif
-#define DRWAV_SEQUENTIAL            0x00000001
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision);
-DRWAV_API const char* drwav_version_string(void);
-typedef enum
-{
-    drwav_seek_origin_start,
-    drwav_seek_origin_current
-} drwav_seek_origin;
-typedef enum
-{
-    drwav_container_riff,
-    drwav_container_w64,
-    drwav_container_rf64
-} drwav_container;
-typedef struct
-{
-    union
-    {
-        drwav_uint8 fourcc[4];
-        drwav_uint8 guid[16];
-    } id;
-    drwav_uint64 sizeInBytes;
-    unsigned int paddingSize;
-} drwav_chunk_header;
-typedef struct
-{
-    drwav_uint16 formatTag;
-    drwav_uint16 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 avgBytesPerSec;
-    drwav_uint16 blockAlign;
-    drwav_uint16 bitsPerSample;
-    drwav_uint16 extendedSize;
-    drwav_uint16 validBitsPerSample;
-    drwav_uint32 channelMask;
-    drwav_uint8 subFormat[16];
-} drwav_fmt;
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT);
-typedef size_t (* drwav_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef size_t (* drwav_write_proc)(void* pUserData, const void* pData, size_t bytesToWrite);
-typedef drwav_bool32 (* drwav_seek_proc)(void* pUserData, int offset, drwav_seek_origin origin);
-typedef drwav_uint64 (* drwav_chunk_proc)(void* pChunkUserData, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_chunk_header* pChunkHeader, drwav_container container, const drwav_fmt* pFMT);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drwav_allocation_callbacks;
-typedef struct
-{
-    const drwav_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drwav__memory_stream;
-typedef struct
-{
-    void** ppData;
-    size_t* pDataSize;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t currentWritePos;
-} drwav__memory_stream_write;
-typedef struct
-{
-    drwav_container container;
-    drwav_uint32 format;
-    drwav_uint32 channels;
-    drwav_uint32 sampleRate;
-    drwav_uint32 bitsPerSample;
-} drwav_data_format;
-typedef struct
-{
-    drwav_uint32 cuePointId;
-    drwav_uint32 type;
-    drwav_uint32 start;
-    drwav_uint32 end;
-    drwav_uint32 fraction;
-    drwav_uint32 playCount;
-} drwav_smpl_loop;
- typedef struct
-{
-    drwav_uint32 manufacturer;
-    drwav_uint32 product;
-    drwav_uint32 samplePeriod;
-    drwav_uint32 midiUnityNotes;
-    drwav_uint32 midiPitchFraction;
-    drwav_uint32 smpteFormat;
-    drwav_uint32 smpteOffset;
-    drwav_uint32 numSampleLoops;
-    drwav_uint32 samplerData;
-    drwav_smpl_loop loops[DRWAV_MAX_SMPL_LOOPS];
-} drwav_smpl;
-typedef struct
-{
-    drwav_read_proc onRead;
-    drwav_write_proc onWrite;
-    drwav_seek_proc onSeek;
-    void* pUserData;
-    drwav_allocation_callbacks allocationCallbacks;
-    drwav_container container;
-    drwav_fmt fmt;
-    drwav_uint32 sampleRate;
-    drwav_uint16 channels;
-    drwav_uint16 bitsPerSample;
-    drwav_uint16 translatedFormatTag;
-    drwav_uint64 totalPCMFrameCount;
-    drwav_uint64 dataChunkDataSize;
-    drwav_uint64 dataChunkDataPos;
-    drwav_uint64 bytesRemaining;
-    drwav_uint64 dataChunkDataSizeTargetWrite;
-    drwav_bool32 isSequentialWrite;
-    drwav_smpl smpl;
-    drwav__memory_stream memoryStream;
-    drwav__memory_stream_write memoryStreamWrite;
-    struct
-    {
-        drwav_uint64 iCurrentPCMFrame;
-    } compressed;
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_uint16 predictor[2];
-        drwav_int32  delta[2];
-        drwav_int32  cachedFrames[4];
-        drwav_uint32 cachedFrameCount;
-        drwav_int32  prevFrames[2][2];
-    } msadpcm;
-    struct
-    {
-        drwav_uint32 bytesRemainingInBlock;
-        drwav_int32  predictor[2];
-        drwav_int32  stepIndex[2];
-        drwav_int32  cachedFrames[16];
-        drwav_uint32 cachedFrameCount;
-    } ima;
-} drwav;
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-DRWAV_API drwav_result drwav_uninit(drwav* pWav);
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut);
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex);
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData);
-#ifndef DR_WAV_NO_CONVERSION_API
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut);
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount);
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut);
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut);
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount);
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount);
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount);
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount);
-#endif
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_CONVERSION_API
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks);
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data);
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data);
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data);
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data);
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data);
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data);
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16]);
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_wav_h end */
-#endif  /* MA_NO_WAV */
-
-#if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING)
-/* dr_flac_h begin */
-#ifndef dr_flac_h
-#define dr_flac_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRFLAC_STRINGIFY(x)      #x
-#define DRFLAC_XSTRINGIFY(x)     DRFLAC_STRINGIFY(x)
-#define DRFLAC_VERSION_MAJOR     0
-#define DRFLAC_VERSION_MINOR     12
-#define DRFLAC_VERSION_REVISION  29
-#define DRFLAC_VERSION_STRING    DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drflac_int8;
-typedef unsigned char           drflac_uint8;
-typedef   signed short          drflac_int16;
-typedef unsigned short          drflac_uint16;
-typedef   signed int            drflac_int32;
-typedef unsigned int            drflac_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drflac_int64;
-    typedef unsigned __int64    drflac_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drflac_int64;
-    typedef unsigned long long  drflac_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drflac_uint64       drflac_uintptr;
-#else
-    typedef drflac_uint32       drflac_uintptr;
-#endif
-typedef drflac_uint8            drflac_bool8;
-typedef drflac_uint32           drflac_bool32;
-#define DRFLAC_TRUE             1
-#define DRFLAC_FALSE            0
-#if !defined(DRFLAC_API)
-    #if defined(DRFLAC_DLL)
-        #if defined(_WIN32)
-            #define DRFLAC_DLL_IMPORT  __declspec(dllimport)
-            #define DRFLAC_DLL_EXPORT  __declspec(dllexport)
-            #define DRFLAC_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRFLAC_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRFLAC_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRFLAC_DLL_IMPORT
-                #define DRFLAC_DLL_EXPORT
-                #define DRFLAC_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_FLAC_IMPLEMENTATION) || defined(DRFLAC_IMPLEMENTATION)
-            #define DRFLAC_API  DRFLAC_DLL_EXPORT
-        #else
-            #define DRFLAC_API  DRFLAC_DLL_IMPORT
-        #endif
-        #define DRFLAC_PRIVATE DRFLAC_DLL_PRIVATE
-    #else
-        #define DRFLAC_API extern
-        #define DRFLAC_PRIVATE static
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1700
-    #define DRFLAC_DEPRECATED       __declspec(deprecated)
-#elif (defined(__GNUC__) && __GNUC__ >= 4)
-    #define DRFLAC_DEPRECATED       __attribute__((deprecated))
-#elif defined(__has_feature)
-    #if __has_feature(attribute_deprecated)
-        #define DRFLAC_DEPRECATED   __attribute__((deprecated))
-    #else
-        #define DRFLAC_DEPRECATED
-    #endif
-#else
-    #define DRFLAC_DEPRECATED
-#endif
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision);
-DRFLAC_API const char* drflac_version_string(void);
-#ifndef DR_FLAC_BUFFER_SIZE
-#define DR_FLAC_BUFFER_SIZE   4096
-#endif
-#if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-#define DRFLAC_64BIT
-#endif
-#ifdef DRFLAC_64BIT
-typedef drflac_uint64 drflac_cache_t;
-#else
-typedef drflac_uint32 drflac_cache_t;
-#endif
-#define DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO       0
-#define DRFLAC_METADATA_BLOCK_TYPE_PADDING          1
-#define DRFLAC_METADATA_BLOCK_TYPE_APPLICATION      2
-#define DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE        3
-#define DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT   4
-#define DRFLAC_METADATA_BLOCK_TYPE_CUESHEET         5
-#define DRFLAC_METADATA_BLOCK_TYPE_PICTURE          6
-#define DRFLAC_METADATA_BLOCK_TYPE_INVALID          127
-#define DRFLAC_PICTURE_TYPE_OTHER                   0
-#define DRFLAC_PICTURE_TYPE_FILE_ICON               1
-#define DRFLAC_PICTURE_TYPE_OTHER_FILE_ICON         2
-#define DRFLAC_PICTURE_TYPE_COVER_FRONT             3
-#define DRFLAC_PICTURE_TYPE_COVER_BACK              4
-#define DRFLAC_PICTURE_TYPE_LEAFLET_PAGE            5
-#define DRFLAC_PICTURE_TYPE_MEDIA                   6
-#define DRFLAC_PICTURE_TYPE_LEAD_ARTIST             7
-#define DRFLAC_PICTURE_TYPE_ARTIST                  8
-#define DRFLAC_PICTURE_TYPE_CONDUCTOR               9
-#define DRFLAC_PICTURE_TYPE_BAND                    10
-#define DRFLAC_PICTURE_TYPE_COMPOSER                11
-#define DRFLAC_PICTURE_TYPE_LYRICIST                12
-#define DRFLAC_PICTURE_TYPE_RECORDING_LOCATION      13
-#define DRFLAC_PICTURE_TYPE_DURING_RECORDING        14
-#define DRFLAC_PICTURE_TYPE_DURING_PERFORMANCE      15
-#define DRFLAC_PICTURE_TYPE_SCREEN_CAPTURE          16
-#define DRFLAC_PICTURE_TYPE_BRIGHT_COLORED_FISH     17
-#define DRFLAC_PICTURE_TYPE_ILLUSTRATION            18
-#define DRFLAC_PICTURE_TYPE_BAND_LOGOTYPE           19
-#define DRFLAC_PICTURE_TYPE_PUBLISHER_LOGOTYPE      20
-typedef enum
-{
-    drflac_container_native,
-    drflac_container_ogg,
-    drflac_container_unknown
-} drflac_container;
-typedef enum
-{
-    drflac_seek_origin_start,
-    drflac_seek_origin_current
-} drflac_seek_origin;
-#pragma pack(2)
-typedef struct
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 flacFrameOffset;
-    drflac_uint16 pcmFrameCount;
-} drflac_seekpoint;
-#pragma pack()
-typedef struct
-{
-    drflac_uint16 minBlockSizeInPCMFrames;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint32 minFrameSizeInPCMFrames;
-    drflac_uint32 maxFrameSizeInPCMFrames;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint8  md5[16];
-} drflac_streaminfo;
-typedef struct
-{
-    drflac_uint32 type;
-    const void* pRawData;
-    drflac_uint32 rawDataSize;
-    union
-    {
-        drflac_streaminfo streaminfo;
-        struct
-        {
-            int unused;
-        } padding;
-        struct
-        {
-            drflac_uint32 id;
-            const void* pData;
-            drflac_uint32 dataSize;
-        } application;
-        struct
-        {
-            drflac_uint32 seekpointCount;
-            const drflac_seekpoint* pSeekpoints;
-        } seektable;
-        struct
-        {
-            drflac_uint32 vendorLength;
-            const char* vendor;
-            drflac_uint32 commentCount;
-            const void* pComments;
-        } vorbis_comment;
-        struct
-        {
-            char catalog[128];
-            drflac_uint64 leadInSampleCount;
-            drflac_bool32 isCD;
-            drflac_uint8 trackCount;
-            const void* pTrackData;
-        } cuesheet;
-        struct
-        {
-            drflac_uint32 type;
-            drflac_uint32 mimeLength;
-            const char* mime;
-            drflac_uint32 descriptionLength;
-            const char* description;
-            drflac_uint32 width;
-            drflac_uint32 height;
-            drflac_uint32 colorDepth;
-            drflac_uint32 indexColorCount;
-            drflac_uint32 pictureDataSize;
-            const drflac_uint8* pPictureData;
-        } picture;
-    } data;
-} drflac_metadata;
-typedef size_t (* drflac_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef drflac_bool32 (* drflac_seek_proc)(void* pUserData, int offset, drflac_seek_origin origin);
-typedef void (* drflac_meta_proc)(void* pUserData, drflac_metadata* pMetadata);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drflac_allocation_callbacks;
-typedef struct
-{
-    const drflac_uint8* data;
-    size_t dataSize;
-    size_t currentReadPos;
-} drflac__memory_stream;
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    void* pUserData;
-    size_t unalignedByteCount;
-    drflac_cache_t unalignedCache;
-    drflac_uint32 nextL2Line;
-    drflac_uint32 consumedBits;
-    drflac_cache_t cacheL2[DR_FLAC_BUFFER_SIZE/sizeof(drflac_cache_t)];
-    drflac_cache_t cache;
-    drflac_uint16 crc16;
-    drflac_cache_t crc16Cache;
-    drflac_uint32 crc16CacheIgnoredBytes;
-} drflac_bs;
-typedef struct
-{
-    drflac_uint8 subframeType;
-    drflac_uint8 wastedBitsPerSample;
-    drflac_uint8 lpcOrder;
-    drflac_int32* pSamplesS32;
-} drflac_subframe;
-typedef struct
-{
-    drflac_uint64 pcmFrameNumber;
-    drflac_uint32 flacFrameNumber;
-    drflac_uint32 sampleRate;
-    drflac_uint16 blockSizeInPCMFrames;
-    drflac_uint8 channelAssignment;
-    drflac_uint8 bitsPerSample;
-    drflac_uint8 crc8;
-} drflac_frame_header;
-typedef struct
-{
-    drflac_frame_header header;
-    drflac_uint32 pcmFramesRemaining;
-    drflac_subframe subframes[8];
-} drflac_frame;
-typedef struct
-{
-    drflac_meta_proc onMeta;
-    void* pUserDataMD;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac_uint32 sampleRate;
-    drflac_uint8 channels;
-    drflac_uint8 bitsPerSample;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_container container;
-    drflac_uint32 seekpointCount;
-    drflac_frame currentFLACFrame;
-    drflac_uint64 currentPCMFrame;
-    drflac_uint64 firstFLACFramePosInBytes;
-    drflac__memory_stream memoryStream;
-    drflac_int32* pDecodedSamples;
-    drflac_seekpoint* pSeekpoints;
-    void* _oggbs;
-    drflac_bool32 _noSeekTableSeek    : 1;
-    drflac_bool32 _noBinarySearchSeek : 1;
-    drflac_bool32 _noBruteForceSeek   : 1;
-    drflac_bs bs;
-    drflac_uint8 pExtraData[1];
-} drflac;
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API void drflac_close(drflac* pFlac);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut);
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut);
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex);
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks);
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks);
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_vorbis_comment_iterator;
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments);
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut);
-typedef struct
-{
-    drflac_uint32 countRemaining;
-    const char* pRunningData;
-} drflac_cuesheet_track_iterator;
-#pragma pack(4)
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 index;
-    drflac_uint8 reserved[3];
-} drflac_cuesheet_track_index;
-#pragma pack()
-typedef struct
-{
-    drflac_uint64 offset;
-    drflac_uint8 trackNumber;
-    char ISRC[12];
-    drflac_bool8 isAudio;
-    drflac_bool8 preEmphasis;
-    drflac_uint8 indexCount;
-    const drflac_cuesheet_track_index* pIndexPoints;
-} drflac_cuesheet_track;
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData);
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_flac_h end */
-#endif  /* MA_NO_FLAC */
-
-#if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING)
-/* dr_mp3_h begin */
-#ifndef dr_mp3_h
-#define dr_mp3_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define DRMP3_STRINGIFY(x)      #x
-#define DRMP3_XSTRINGIFY(x)     DRMP3_STRINGIFY(x)
-#define DRMP3_VERSION_MAJOR     0
-#define DRMP3_VERSION_MINOR     6
-#define DRMP3_VERSION_REVISION  27
-#define DRMP3_VERSION_STRING    DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
-#include <stddef.h>
-typedef   signed char           drmp3_int8;
-typedef unsigned char           drmp3_uint8;
-typedef   signed short          drmp3_int16;
-typedef unsigned short          drmp3_uint16;
-typedef   signed int            drmp3_int32;
-typedef unsigned int            drmp3_uint32;
-#if defined(_MSC_VER)
-    typedef   signed __int64    drmp3_int64;
-    typedef unsigned __int64    drmp3_uint64;
-#else
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic push
-        #pragma GCC diagnostic ignored "-Wlong-long"
-        #if defined(__clang__)
-            #pragma GCC diagnostic ignored "-Wc++11-long-long"
-        #endif
-    #endif
-    typedef   signed long long  drmp3_int64;
-    typedef unsigned long long  drmp3_uint64;
-    #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-        #pragma GCC diagnostic pop
-    #endif
-#endif
-#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
-    typedef drmp3_uint64        drmp3_uintptr;
-#else
-    typedef drmp3_uint32        drmp3_uintptr;
-#endif
-typedef drmp3_uint8             drmp3_bool8;
-typedef drmp3_uint32            drmp3_bool32;
-#define DRMP3_TRUE              1
-#define DRMP3_FALSE             0
-#if !defined(DRMP3_API)
-    #if defined(DRMP3_DLL)
-        #if defined(_WIN32)
-            #define DRMP3_DLL_IMPORT  __declspec(dllimport)
-            #define DRMP3_DLL_EXPORT  __declspec(dllexport)
-            #define DRMP3_DLL_PRIVATE static
-        #else
-            #if defined(__GNUC__) && __GNUC__ >= 4
-                #define DRMP3_DLL_IMPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_EXPORT  __attribute__((visibility("default")))
-                #define DRMP3_DLL_PRIVATE __attribute__((visibility("hidden")))
-            #else
-                #define DRMP3_DLL_IMPORT
-                #define DRMP3_DLL_EXPORT
-                #define DRMP3_DLL_PRIVATE static
-            #endif
-        #endif
-        #if defined(DR_MP3_IMPLEMENTATION) || defined(DRMP3_IMPLEMENTATION)
-            #define DRMP3_API  DRMP3_DLL_EXPORT
-        #else
-            #define DRMP3_API  DRMP3_DLL_IMPORT
-        #endif
-        #define DRMP3_PRIVATE DRMP3_DLL_PRIVATE
-    #else
-        #define DRMP3_API extern
-        #define DRMP3_PRIVATE static
-    #endif
-#endif
-typedef drmp3_int32 drmp3_result;
-#define DRMP3_SUCCESS                        0
-#define DRMP3_ERROR                         -1
-#define DRMP3_INVALID_ARGS                  -2
-#define DRMP3_INVALID_OPERATION             -3
-#define DRMP3_OUT_OF_MEMORY                 -4
-#define DRMP3_OUT_OF_RANGE                  -5
-#define DRMP3_ACCESS_DENIED                 -6
-#define DRMP3_DOES_NOT_EXIST                -7
-#define DRMP3_ALREADY_EXISTS                -8
-#define DRMP3_TOO_MANY_OPEN_FILES           -9
-#define DRMP3_INVALID_FILE                  -10
-#define DRMP3_TOO_BIG                       -11
-#define DRMP3_PATH_TOO_LONG                 -12
-#define DRMP3_NAME_TOO_LONG                 -13
-#define DRMP3_NOT_DIRECTORY                 -14
-#define DRMP3_IS_DIRECTORY                  -15
-#define DRMP3_DIRECTORY_NOT_EMPTY           -16
-#define DRMP3_END_OF_FILE                   -17
-#define DRMP3_NO_SPACE                      -18
-#define DRMP3_BUSY                          -19
-#define DRMP3_IO_ERROR                      -20
-#define DRMP3_INTERRUPT                     -21
-#define DRMP3_UNAVAILABLE                   -22
-#define DRMP3_ALREADY_IN_USE                -23
-#define DRMP3_BAD_ADDRESS                   -24
-#define DRMP3_BAD_SEEK                      -25
-#define DRMP3_BAD_PIPE                      -26
-#define DRMP3_DEADLOCK                      -27
-#define DRMP3_TOO_MANY_LINKS                -28
-#define DRMP3_NOT_IMPLEMENTED               -29
-#define DRMP3_NO_MESSAGE                    -30
-#define DRMP3_BAD_MESSAGE                   -31
-#define DRMP3_NO_DATA_AVAILABLE             -32
-#define DRMP3_INVALID_DATA                  -33
-#define DRMP3_TIMEOUT                       -34
-#define DRMP3_NO_NETWORK                    -35
-#define DRMP3_NOT_UNIQUE                    -36
-#define DRMP3_NOT_SOCKET                    -37
-#define DRMP3_NO_ADDRESS                    -38
-#define DRMP3_BAD_PROTOCOL                  -39
-#define DRMP3_PROTOCOL_UNAVAILABLE          -40
-#define DRMP3_PROTOCOL_NOT_SUPPORTED        -41
-#define DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED -42
-#define DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED  -43
-#define DRMP3_SOCKET_NOT_SUPPORTED          -44
-#define DRMP3_CONNECTION_RESET              -45
-#define DRMP3_ALREADY_CONNECTED             -46
-#define DRMP3_NOT_CONNECTED                 -47
-#define DRMP3_CONNECTION_REFUSED            -48
-#define DRMP3_NO_HOST                       -49
-#define DRMP3_IN_PROGRESS                   -50
-#define DRMP3_CANCELLED                     -51
-#define DRMP3_MEMORY_ALREADY_MAPPED         -52
-#define DRMP3_AT_END                        -53
-#define DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME  1152
-#define DRMP3_MAX_SAMPLES_PER_FRAME         (DRMP3_MAX_PCM_FRAMES_PER_MP3_FRAME*2)
-#ifdef _MSC_VER
-    #define DRMP3_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRMP3_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRMP3_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRMP3_INLINE __inline
-#else
-    #define DRMP3_INLINE
-#endif
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision);
-DRMP3_API const char* drmp3_version_string(void);
-typedef struct
-{
-    int frame_bytes, channels, hz, layer, bitrate_kbps;
-} drmp3dec_frame_info;
-typedef struct
-{
-    float mdct_overlap[2][9*32], qmf_state[15*2*32];
-    int reserv, free_format_bytes;
-    drmp3_uint8 header[4], reserv_buf[511];
-} drmp3dec;
-DRMP3_API void drmp3dec_init(drmp3dec *dec);
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info);
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples);
-typedef enum
-{
-    drmp3_seek_origin_start,
-    drmp3_seek_origin_current
-} drmp3_seek_origin;
-typedef struct
-{
-    drmp3_uint64 seekPosInBytes;
-    drmp3_uint64 pcmFrameIndex;
-    drmp3_uint16 mp3FramesToDiscard;
-    drmp3_uint16 pcmFramesToDiscard;
-} drmp3_seek_point;
-typedef size_t (* drmp3_read_proc)(void* pUserData, void* pBufferOut, size_t bytesToRead);
-typedef drmp3_bool32 (* drmp3_seek_proc)(void* pUserData, int offset, drmp3_seek_origin origin);
-typedef struct
-{
-    void* pUserData;
-    void* (* onMalloc)(size_t sz, void* pUserData);
-    void* (* onRealloc)(void* p, size_t sz, void* pUserData);
-    void  (* onFree)(void* p, void* pUserData);
-} drmp3_allocation_callbacks;
-typedef struct
-{
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-} drmp3_config;
-typedef struct
-{
-    drmp3dec decoder;
-    drmp3dec_frame_info frameInfo;
-    drmp3_uint32 channels;
-    drmp3_uint32 sampleRate;
-    drmp3_read_proc onRead;
-    drmp3_seek_proc onSeek;
-    void* pUserData;
-    drmp3_allocation_callbacks allocationCallbacks;
-    drmp3_uint32 mp3FrameChannels;
-    drmp3_uint32 mp3FrameSampleRate;
-    drmp3_uint32 pcmFramesConsumedInMP3Frame;
-    drmp3_uint32 pcmFramesRemainingInMP3Frame;
-    drmp3_uint8 pcmFrames[sizeof(float)*DRMP3_MAX_SAMPLES_PER_FRAME];
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 streamCursor;
-    drmp3_seek_point* pSeekPoints;
-    drmp3_uint32 seekPointCount;
-    size_t dataSize;
-    size_t dataCapacity;
-    size_t dataConsumed;
-    drmp3_uint8* pData;
-    drmp3_bool32 atEnd : 1;
-    struct
-    {
-        const drmp3_uint8* pData;
-        size_t dataSize;
-        size_t currentReadPos;
-    } memory;
-} drmp3;
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRMP3_API void drmp3_uninit(drmp3* pMP3);
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut);
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut);
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex);
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3);
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3);
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount);
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints);
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints);
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#endif
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks);
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks);
-#ifdef __cplusplus
-}
-#endif
-#endif
-/* dr_mp3_h end */
-#endif  /* MA_NO_MP3 */
-
-
-/**************************************************************************************************************************************************************
-
-Decoding
-
-**************************************************************************************************************************************************************/
-#ifndef MA_NO_DECODING
-
-static size_t ma_decoder_read_bytes(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead;
-
-    MA_ASSERT(pDecoder != NULL);
-    MA_ASSERT(pBufferOut != NULL);
-
-    bytesRead = pDecoder->onRead(pDecoder, pBufferOut, bytesToRead);
-    pDecoder->readPointerInBytes += bytesRead;
-
-    return bytesRead;
-}
-
-static ma_bool32 ma_decoder_seek_bytes(ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin)
-{
-    ma_bool32 wasSuccessful;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    wasSuccessful = pDecoder->onSeek(pDecoder, byteOffset, origin);
-    if (wasSuccessful) {
-        if (origin == ma_seek_origin_start) {
-            pDecoder->readPointerInBytes = (ma_uint64)byteOffset;
-        } else {
-            pDecoder->readPointerInBytes += byteOffset;
-        }
-    }
-
-    return wasSuccessful;
-}
-
-
-MA_API ma_decoder_config ma_decoder_config_init(ma_format outputFormat, ma_uint32 outputChannels, ma_uint32 outputSampleRate)
-{
-    ma_decoder_config config;
-    MA_ZERO_OBJECT(&config);
-    config.format     = outputFormat;
-    config.channels   = ma_min(outputChannels, ma_countof(config.channelMap));
-    config.sampleRate = outputSampleRate;
-    config.resampling.algorithm = ma_resample_algorithm_linear;
-    config.resampling.linear.lpfOrder = ma_min(MA_DEFAULT_RESAMPLER_LPF_ORDER, MA_MAX_FILTER_ORDER);
-    config.resampling.speex.quality = 3;
-
-    /* Note that we are intentionally leaving the channel map empty here which will cause the default channel map to be used. */
-
-    return config;
-}
-
-MA_API ma_decoder_config ma_decoder_config_init_copy(const ma_decoder_config* pConfig)
-{
-    ma_decoder_config config;
-    if (pConfig != NULL) {
-        config = *pConfig;
-    } else {
-        MA_ZERO_OBJECT(&config);
-    }
-
-    return config;
-}
-
-static ma_result ma_decoder__init_data_converter(ma_decoder* pDecoder, const ma_decoder_config* pConfig)
-{
-    ma_data_converter_config converterConfig;
-
-    MA_ASSERT(pDecoder != NULL);
-    MA_ASSERT(pConfig  != NULL);
-
-    /* Make sure we're not asking for too many channels. */
-    if (pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    /* The internal channels should have already been validated at a higher level, but we'll do it again explicitly here for safety. */
-    if (pDecoder->internalChannels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-
-    /* Output format. */
-    if (pConfig->format == ma_format_unknown) {
-        pDecoder->outputFormat = pDecoder->internalFormat;
-    } else {
-        pDecoder->outputFormat = pConfig->format;
-    }
-
-    if (pConfig->channels == 0) {
-        pDecoder->outputChannels = pDecoder->internalChannels;
-    } else {
-        pDecoder->outputChannels = pConfig->channels;
-    }
-
-    if (pConfig->sampleRate == 0) {
-        pDecoder->outputSampleRate = pDecoder->internalSampleRate;
-    } else {
-        pDecoder->outputSampleRate = pConfig->sampleRate;
-    }
-
-    if (ma_channel_map_blank(pDecoder->outputChannels, pConfig->channelMap)) {
-        ma_get_standard_channel_map(ma_standard_channel_map_default, pDecoder->outputChannels, pDecoder->outputChannelMap);
-    } else {
-        MA_COPY_MEMORY(pDecoder->outputChannelMap, pConfig->channelMap, sizeof(pConfig->channelMap));
-    }
-
-
-    converterConfig = ma_data_converter_config_init(
-        pDecoder->internalFormat,     pDecoder->outputFormat,
-        pDecoder->internalChannels,   pDecoder->outputChannels,
-        pDecoder->internalSampleRate, pDecoder->outputSampleRate
-    );
-    ma_channel_map_copy(converterConfig.channelMapIn,  pDecoder->internalChannelMap, pDecoder->internalChannels);
-    ma_channel_map_copy(converterConfig.channelMapOut, pDecoder->outputChannelMap,   pDecoder->outputChannels);
-    converterConfig.channelMixMode             = pConfig->channelMixMode;
-    converterConfig.ditherMode                 = pConfig->ditherMode;
-    converterConfig.resampling.allowDynamicSampleRate = MA_FALSE;   /* Never allow dynamic sample rate conversion. Setting this to true will disable passthrough optimizations. */
-    converterConfig.resampling.algorithm       = pConfig->resampling.algorithm;
-    converterConfig.resampling.linear.lpfOrder = pConfig->resampling.linear.lpfOrder;
-    converterConfig.resampling.speex.quality   = pConfig->resampling.speex.quality;
-
-    return ma_data_converter_init(&converterConfig, &pDecoder->converter);
-}
-
-/* WAV */
-#ifdef dr_wav_h
-#define MA_HAS_WAV
-
-static size_t ma_decoder_internal_on_read__wav(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drwav_bool32 ma_decoder_internal_on_seek__wav(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drwav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__wav(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pWav = (drwav*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pWav != NULL);
-
-    switch (pDecoder->internalFormat) {
-        case ma_format_s16: return drwav_read_pcm_frames_s16(pWav, frameCount, (drwav_int16*)pFramesOut);
-        case ma_format_s32: return drwav_read_pcm_frames_s32(pWav, frameCount, (drwav_int32*)pFramesOut);
-        case ma_format_f32: return drwav_read_pcm_frames_f32(pWav, frameCount,       (float*)pFramesOut);
-        default: break;
-    }
-
-    /* Should never get here. If we do, it means the internal format was not set correctly at initialization time. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__wav(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drwav* pWav;
-    drwav_bool32 result;
-
-    pWav = (drwav*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pWav != NULL);
-
-    result = drwav_seek_to_pcm_frame(pWav, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__wav(ma_decoder* pDecoder)
-{
-    drwav_uninit((drwav*)pDecoder->pInternalDecoder);
-    ma__free_from_callbacks(pDecoder->pInternalDecoder, &pDecoder->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__wav(ma_decoder* pDecoder)
-{
-    return ((drwav*)pDecoder->pInternalDecoder)->totalPCMFrameCount;
-}
-
-static ma_result ma_decoder_init_wav__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drwav* pWav;
-    drwav_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfig;
-
-    pWav = (drwav*)ma__malloc_from_callbacks(sizeof(*pWav), &pDecoder->allocationCallbacks);
-    if (pWav == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /* Try opening the decoder first. */
-    if (!drwav_init(pWav, ma_decoder_internal_on_read__wav, ma_decoder_internal_on_seek__wav, pDecoder, &allocationCallbacks)) {
-        ma__free_from_callbacks(pWav, &pDecoder->allocationCallbacks);
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the WAV decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__wav;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__wav;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__wav;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__wav;
-    pDecoder->pInternalDecoder       = pWav;
-
-    /* Try to be as optimal as possible for the internal format. If miniaudio does not support a format we will fall back to f32. */
-    pDecoder->internalFormat = ma_format_unknown;
-    switch (pWav->translatedFormatTag) {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            if (pWav->bitsPerSample == 8) {
-                pDecoder->internalFormat = ma_format_s16;
-            } else if (pWav->bitsPerSample == 16) {
-                pDecoder->internalFormat = ma_format_s16;
-            } else if (pWav->bitsPerSample == 32) {
-                pDecoder->internalFormat = ma_format_s32;
-            }
-        } break;
-
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            if (pWav->bitsPerSample == 32) {
-                pDecoder->internalFormat = ma_format_f32;
-            }
-        } break;
-
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        {
-            pDecoder->internalFormat = ma_format_s16;
-        } break;
-    }
-
-    if (pDecoder->internalFormat == ma_format_unknown) {
-        pDecoder->internalFormat = ma_format_f32;
-    }
-
-    pDecoder->internalChannels = pWav->channels;
-    pDecoder->internalSampleRate = pWav->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_microsoft, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_wav_h */
-
-/* FLAC */
-#ifdef dr_flac_h
-#define MA_HAS_FLAC
-
-static size_t ma_decoder_internal_on_read__flac(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drflac_bool32 ma_decoder_internal_on_seek__flac(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drflac_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__flac(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drflac* pFlac;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pFlac = (drflac*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pFlac != NULL);
-
-    switch (pDecoder->internalFormat) {
-        case ma_format_s16: return drflac_read_pcm_frames_s16(pFlac, frameCount, (drflac_int16*)pFramesOut);
-        case ma_format_s32: return drflac_read_pcm_frames_s32(pFlac, frameCount, (drflac_int32*)pFramesOut);
-        case ma_format_f32: return drflac_read_pcm_frames_f32(pFlac, frameCount,        (float*)pFramesOut);
-        default: break;
-    }
-
-    /* Should never get here. If we do, it means the internal format was not set correctly at initialization time. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__flac(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drflac* pFlac;
-    drflac_bool32 result;
-
-    pFlac = (drflac*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pFlac != NULL);
-
-    result = drflac_seek_to_pcm_frame(pFlac, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__flac(ma_decoder* pDecoder)
-{
-    drflac_close((drflac*)pDecoder->pInternalDecoder);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__flac(ma_decoder* pDecoder)
-{
-    return ((drflac*)pDecoder->pInternalDecoder)->totalPCMFrameCount;
-}
-
-static ma_result ma_decoder_init_flac__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drflac* pFlac;
-    drflac_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig  != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /* Try opening the decoder first. */
-    pFlac = drflac_open(ma_decoder_internal_on_read__flac, ma_decoder_internal_on_seek__flac, pDecoder, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the FLAC decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__flac;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__flac;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__flac;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__flac;
-    pDecoder->pInternalDecoder       = pFlac;
-
-    /*
-    dr_flac supports reading as s32, s16 and f32. Try to do a one-to-one mapping if possible, but fall back to s32 if not. s32 is the "native" FLAC format
-    since it's the only one that's truly lossless. If the internal bits per sample is <= 16 we will decode to ma_format_s16 to keep it more efficient.
-    */
-    if (pConfig->format == ma_format_unknown) {
-        if (pFlac->bitsPerSample <= 16) {
-            pDecoder->internalFormat = ma_format_s16;
-        } else {
-            pDecoder->internalFormat = ma_format_s32;
-        }
-    } else {
-        if (pConfig->format == ma_format_s16 || pConfig->format == ma_format_f32) {
-            pDecoder->internalFormat = pConfig->format;
-        } else {
-            pDecoder->internalFormat = ma_format_s32;   /* s32 as the baseline to ensure no loss of precision for 24-bit encoded files. */
-        }
-    }
-
-    pDecoder->internalChannels = pFlac->channels;
-    pDecoder->internalSampleRate = pFlac->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_flac, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_flac_h */
-
-/* MP3 */
-#ifdef dr_mp3_h
-#define MA_HAS_MP3
-
-static size_t ma_decoder_internal_on_read__mp3(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_read_bytes(pDecoder, pBufferOut, bytesToRead);
-}
-
-static drmp3_bool32 ma_decoder_internal_on_seek__mp3(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pUserData;
-    MA_ASSERT(pDecoder != NULL);
-
-    return ma_decoder_seek_bytes(pDecoder, offset, (origin == drmp3_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__mp3(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    drmp3* pMP3;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    pMP3 = (drmp3*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pMP3 != NULL);
-
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    MA_ASSERT(pDecoder->internalFormat == ma_format_f32);
-    return drmp3_read_pcm_frames_f32(pMP3, frameCount, (float*)pFramesOut);
-#else
-    MA_ASSERT(pDecoder->internalFormat == ma_format_s16);
-    return drmp3_read_pcm_frames_s16(pMP3, frameCount, (drmp3_int16*)pFramesOut);
-#endif
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__mp3(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    drmp3* pMP3;
-    drmp3_bool32 result;
-
-    pMP3 = (drmp3*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pMP3 != NULL);
-
-    result = drmp3_seek_to_pcm_frame(pMP3, frameIndex);
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__mp3(ma_decoder* pDecoder)
-{
-    drmp3_uninit((drmp3*)pDecoder->pInternalDecoder);
-    ma__free_from_callbacks(pDecoder->pInternalDecoder, &pDecoder->allocationCallbacks);
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__mp3(ma_decoder* pDecoder)
-{
-    return drmp3_get_pcm_frame_count((drmp3*)pDecoder->pInternalDecoder);
-}
-
-static ma_result ma_decoder_init_mp3__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    drmp3* pMP3;
-    drmp3_allocation_callbacks allocationCallbacks;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfig;
-
-    pMP3 = (drmp3*)ma__malloc_from_callbacks(sizeof(*pMP3), &pDecoder->allocationCallbacks);
-    if (pMP3 == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    allocationCallbacks.pUserData = pDecoder->allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pDecoder->allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pDecoder->allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pDecoder->allocationCallbacks.onFree;
-
-    /*
-    Try opening the decoder first. We always use whatever dr_mp3 reports for channel count and sample rate. The format is determined by
-    the presence of DR_MP3_FLOAT_OUTPUT.
-    */
-    if (!drmp3_init(pMP3, ma_decoder_internal_on_read__mp3, ma_decoder_internal_on_seek__mp3, pDecoder, &allocationCallbacks)) {
-        ma__free_from_callbacks(pMP3, &pDecoder->allocationCallbacks);
-        return MA_ERROR;
-    }
-
-    /* If we get here it means we successfully initialized the MP3 decoder. We can now initialize the rest of the ma_decoder. */
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__mp3;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__mp3;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__mp3;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__mp3;
-    pDecoder->pInternalDecoder       = pMP3;
-
-    /* Internal format. */
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    pDecoder->internalFormat     = ma_format_f32;
-#else
-    pDecoder->internalFormat     = ma_format_s16;
-#endif
-    pDecoder->internalChannels   = pMP3->channels;
-    pDecoder->internalSampleRate = pMP3->sampleRate;
-    ma_get_standard_channel_map(ma_standard_channel_map_default, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* dr_mp3_h */
-
-/* Vorbis */
-#ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H
-#define MA_HAS_VORBIS
-
-/* The size in bytes of each chunk of data to read from the Vorbis stream. */
-#define MA_VORBIS_DATA_CHUNK_SIZE  4096
-
-typedef struct
-{
-    stb_vorbis* pInternalVorbis;
-    ma_uint8* pData;
-    size_t dataSize;
-    size_t dataCapacity;
-    ma_uint32 framesConsumed;  /* The number of frames consumed in ppPacketData. */
-    ma_uint32 framesRemaining; /* The number of frames remaining in ppPacketData. */
-    float** ppPacketData;
-} ma_vorbis_decoder;
-
-static ma_uint64 ma_vorbis_decoder_read_pcm_frames(ma_vorbis_decoder* pVorbis, ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    float* pFramesOutF;
-    ma_uint64 totalFramesRead;
-
-    MA_ASSERT(pVorbis  != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    pFramesOutF = (float*)pFramesOut;
-
-    totalFramesRead = 0;
-    while (frameCount > 0) {
-        /* Read from the in-memory buffer first. */
-        ma_uint32 framesToReadFromCache = (ma_uint32)ma_min(pVorbis->framesRemaining, frameCount);  /* Safe cast because pVorbis->framesRemaining is 32-bit. */
-
-        if (pFramesOut != NULL) {
-            ma_uint64 iFrame;
-            for (iFrame = 0; iFrame < framesToReadFromCache; iFrame += 1) {
-                ma_uint32 iChannel;
-                for (iChannel = 0; iChannel < pDecoder->internalChannels; ++iChannel) {
-                    pFramesOutF[iChannel] = pVorbis->ppPacketData[iChannel][pVorbis->framesConsumed+iFrame];
-                }
-                pFramesOutF += pDecoder->internalChannels;
-            }
-        }
-
-        pVorbis->framesConsumed  += framesToReadFromCache;
-        pVorbis->framesRemaining -= framesToReadFromCache;
-        frameCount               -= framesToReadFromCache;
-        totalFramesRead          += framesToReadFromCache;
-
-        if (frameCount == 0) {
-            break;
-        }
-
-        MA_ASSERT(pVorbis->framesRemaining == 0);
-
-        /* We've run out of cached frames, so decode the next packet and continue iteration. */
-        do
-        {
-            int samplesRead;
-            int consumedDataSize;
-
-            if (pVorbis->dataSize > INT_MAX) {
-                break;  /* Too big. */
-            }
-
-            samplesRead = 0;
-            consumedDataSize = stb_vorbis_decode_frame_pushdata(pVorbis->pInternalVorbis, pVorbis->pData, (int)pVorbis->dataSize, NULL, (float***)&pVorbis->ppPacketData, &samplesRead);
-            if (consumedDataSize != 0) {
-                size_t leftoverDataSize = (pVorbis->dataSize - (size_t)consumedDataSize);
-                size_t i;
-                for (i = 0; i < leftoverDataSize; ++i) {
-                    pVorbis->pData[i] = pVorbis->pData[i + consumedDataSize];
-                }
-
-                pVorbis->dataSize = leftoverDataSize;
-                pVorbis->framesConsumed = 0;
-                pVorbis->framesRemaining = samplesRead;
-                break;
-            } else {
-                /* Need more data. If there's any room in the existing buffer allocation fill that first. Otherwise expand. */
-                size_t bytesRead;
-                if (pVorbis->dataCapacity == pVorbis->dataSize) {
-                    /* No room. Expand. */
-                    size_t oldCap = pVorbis->dataCapacity;
-                    size_t newCap = pVorbis->dataCapacity + MA_VORBIS_DATA_CHUNK_SIZE;
-                    ma_uint8* pNewData;
-
-                    pNewData = (ma_uint8*)ma__realloc_from_callbacks(pVorbis->pData, newCap, oldCap, &pDecoder->allocationCallbacks);
-                    if (pNewData == NULL) {
-                        return totalFramesRead; /* Out of memory. */
-                    }
-
-                    pVorbis->pData = pNewData;
-                    pVorbis->dataCapacity = newCap;
-                }
-
-                /* Fill in a chunk. */
-                bytesRead = ma_decoder_read_bytes(pDecoder, pVorbis->pData + pVorbis->dataSize, (pVorbis->dataCapacity - pVorbis->dataSize));
-                if (bytesRead == 0) {
-                    return totalFramesRead; /* Error reading more data. */
-                }
-
-                pVorbis->dataSize += bytesRead;
-            }
-        } while (MA_TRUE);
-    }
-
-    return totalFramesRead;
-}
-
-static ma_result ma_vorbis_decoder_seek_to_pcm_frame(ma_vorbis_decoder* pVorbis, ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    float buffer[4096];
-
-    MA_ASSERT(pVorbis != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /*
-    This is terribly inefficient because stb_vorbis does not have a good seeking solution with it's push API. Currently this just performs
-    a full decode right from the start of the stream. Later on I'll need to write a layer that goes through all of the Ogg pages until we
-    find the one containing the sample we need. Then we know exactly where to seek for stb_vorbis.
-
-    TODO: Use seeking logic documented for stb_vorbis_flush_pushdata().
-    */
-    if (!ma_decoder_seek_bytes(pDecoder, 0, ma_seek_origin_start)) {
-        return MA_ERROR;
-    }
-
-    stb_vorbis_flush_pushdata(pVorbis->pInternalVorbis);
-    pVorbis->framesConsumed  = 0;
-    pVorbis->framesRemaining = 0;
-    pVorbis->dataSize        = 0;
-
-    while (frameIndex > 0) {
-        ma_uint32 framesRead;
-        ma_uint32 framesToRead = ma_countof(buffer)/pDecoder->internalChannels;
-        if (framesToRead > frameIndex) {
-            framesToRead = (ma_uint32)frameIndex;
-        }
-
-        framesRead = (ma_uint32)ma_vorbis_decoder_read_pcm_frames(pVorbis, pDecoder, buffer, framesToRead);
-        if (framesRead == 0) {
-            return MA_ERROR;
-        }
-
-        frameIndex -= framesRead;
-    }
-
-    return MA_SUCCESS;
-}
-
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__vorbis(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    ma_vorbis_decoder* pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    return ma_vorbis_decoder_seek_to_pcm_frame(pVorbis, pDecoder, frameIndex);
-}
-
-static ma_result ma_decoder_internal_on_uninit__vorbis(ma_decoder* pDecoder)
-{
-    ma_vorbis_decoder* pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    stb_vorbis_close(pVorbis->pInternalVorbis);
-    ma__free_from_callbacks(pVorbis->pData, &pDecoder->allocationCallbacks);
-    ma__free_from_callbacks(pVorbis,        &pDecoder->allocationCallbacks);
-
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__vorbis(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_vorbis_decoder* pVorbis;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-    MA_ASSERT(pDecoder->internalFormat == ma_format_f32);
-
-    pVorbis = (ma_vorbis_decoder*)pDecoder->pInternalDecoder;
-    MA_ASSERT(pVorbis != NULL);
-
-    return ma_vorbis_decoder_read_pcm_frames(pVorbis, pDecoder, pFramesOut, frameCount);
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__vorbis(ma_decoder* pDecoder)
-{
-    /* No good way to do this with Vorbis. */
-    (void)pDecoder;
-    return 0;
-}
-
-static ma_result ma_decoder_init_vorbis__internal(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    stb_vorbis* pInternalVorbis = NULL;
-    size_t dataSize = 0;
-    size_t dataCapacity = 0;
-    ma_uint8* pData = NULL;
-    stb_vorbis_info vorbisInfo;
-    size_t vorbisDataSize;
-    ma_vorbis_decoder* pVorbis;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /* We grow the buffer in chunks. */
-    do
-    {
-        /* Allocate memory for a new chunk. */
-        ma_uint8* pNewData;
-        size_t bytesRead;
-        int vorbisError = 0;
-        int consumedDataSize = 0;
-        size_t oldCapacity = dataCapacity;
-
-        dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE;
-        pNewData = (ma_uint8*)ma__realloc_from_callbacks(pData, dataCapacity, oldCapacity, &pDecoder->allocationCallbacks);
-        if (pNewData == NULL) {
-            ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-            return MA_OUT_OF_MEMORY;
-        }
-
-        pData = pNewData;
-
-        /* Fill in a chunk. */
-        bytesRead = ma_decoder_read_bytes(pDecoder, pData + dataSize, (dataCapacity - dataSize));
-        if (bytesRead == 0) {
-            return MA_ERROR;
-        }
-
-        dataSize += bytesRead;
-        if (dataSize > INT_MAX) {
-            return MA_ERROR;   /* Too big. */
-        }
-
-        pInternalVorbis = stb_vorbis_open_pushdata(pData, (int)dataSize, &consumedDataSize, &vorbisError, NULL);
-        if (pInternalVorbis != NULL) {
-            /*
-            If we get here it means we were able to open the stb_vorbis decoder. There may be some leftover bytes in our buffer, so
-            we need to move those bytes down to the front of the buffer since they'll be needed for future decoding.
-            */
-            size_t leftoverDataSize = (dataSize - (size_t)consumedDataSize);
-            size_t i;
-            for (i = 0; i < leftoverDataSize; ++i) {
-                pData[i] = pData[i + consumedDataSize];
-            }
-
-            dataSize = leftoverDataSize;
-            break;  /* Success. */
-        } else {
-            if (vorbisError == VORBIS_need_more_data) {
-                continue;
-            } else {
-                return MA_ERROR;   /* Failed to open the stb_vorbis decoder. */
-            }
-        }
-    } while (MA_TRUE);
-
-
-    /* If we get here it means we successfully opened the Vorbis decoder. */
-    vorbisInfo = stb_vorbis_get_info(pInternalVorbis);
-
-    /* Don't allow more than MA_MAX_CHANNELS channels. */
-    if (vorbisInfo.channels > MA_MAX_CHANNELS) {
-        stb_vorbis_close(pInternalVorbis);
-        ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-        return MA_ERROR;   /* Too many channels. */
-    }
-
-    vorbisDataSize = sizeof(ma_vorbis_decoder) + sizeof(float)*vorbisInfo.max_frame_size;
-    pVorbis = (ma_vorbis_decoder*)ma__malloc_from_callbacks(vorbisDataSize, &pDecoder->allocationCallbacks);
-    if (pVorbis == NULL) {
-        stb_vorbis_close(pInternalVorbis);
-        ma__free_from_callbacks(pData, &pDecoder->allocationCallbacks);
-        return MA_OUT_OF_MEMORY;
-    }
-
-    MA_ZERO_MEMORY(pVorbis, vorbisDataSize);
-    pVorbis->pInternalVorbis = pInternalVorbis;
-    pVorbis->pData = pData;
-    pVorbis->dataSize = dataSize;
-    pVorbis->dataCapacity = dataCapacity;
-
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__vorbis;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__vorbis;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__vorbis;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__vorbis;
-    pDecoder->pInternalDecoder       = pVorbis;
-
-    /* The internal format is always f32. */
-    pDecoder->internalFormat     = ma_format_f32;
-    pDecoder->internalChannels   = vorbisInfo.channels;
-    pDecoder->internalSampleRate = vorbisInfo.sample_rate;
-    ma_get_standard_channel_map(ma_standard_channel_map_vorbis, pDecoder->internalChannels, pDecoder->internalChannelMap);
-
-    return MA_SUCCESS;
-}
-#endif  /* STB_VORBIS_INCLUDE_STB_VORBIS_H */
-
-/* Raw */
-static ma_uint64 ma_decoder_internal_on_read_pcm_frames__raw(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint32 bpf;
-    ma_uint64 totalFramesRead;
-    void* pRunningFramesOut;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    /* For raw decoding we just read directly from the decoder's callbacks. */
-    bpf = ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-
-    totalFramesRead   = 0;
-    pRunningFramesOut = pFramesOut;
-
-    while (totalFramesRead < frameCount) {
-        ma_uint64 framesReadThisIteration;
-        ma_uint64 framesToReadThisIteration = (frameCount - totalFramesRead);
-        if (framesToReadThisIteration > 0x7FFFFFFF/bpf) {
-            framesToReadThisIteration = 0x7FFFFFFF/bpf;
-        }
-
-        if (pFramesOut != NULL) {
-            framesReadThisIteration = ma_decoder_read_bytes(pDecoder, pRunningFramesOut, (size_t)framesToReadThisIteration * bpf) / bpf;    /* Safe cast to size_t. */
-            pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIteration * bpf);
-        } else {
-            /* We'll first try seeking. If this fails it means the end was reached and we'll to do a read-and-discard slow path to get the exact amount. */
-            if (ma_decoder_seek_bytes(pDecoder, (int)framesToReadThisIteration, ma_seek_origin_current)) {
-                framesReadThisIteration = framesToReadThisIteration;
-            } else {
-                /* Slow path. Need to fall back to a read-and-discard. This is required so we can get the exact number of remaining. */
-                ma_uint8 buffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];
-                ma_uint32 bufferCap = sizeof(buffer) / bpf;
-
-                framesReadThisIteration = 0;
-                while (framesReadThisIteration < framesToReadThisIteration) {
-                    ma_uint64 framesReadNow;
-                    ma_uint64 framesToReadNow = framesToReadThisIteration - framesReadThisIteration;
-                    if (framesToReadNow > bufferCap) {
-                        framesToReadNow = bufferCap;
-                    }
-
-                    framesReadNow = ma_decoder_read_bytes(pDecoder, buffer, (size_t)(framesToReadNow * bpf)) / bpf; /* Safe cast. */
-                    framesReadThisIteration += framesReadNow;
-
-                    if (framesReadNow < framesToReadNow) {
-                        break;  /* The end has been reached. */
-                    }
-                }
-            }
-        }
-
-        totalFramesRead += framesReadThisIteration;
-
-        if (framesReadThisIteration < framesToReadThisIteration) {
-            break;  /* Done. */
-        }
-    }
-
-    return totalFramesRead;
-}
-
-static ma_result ma_decoder_internal_on_seek_to_pcm_frame__raw(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    ma_bool32 result = MA_FALSE;
-    ma_uint64 totalBytesToSeek;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    if (pDecoder->onSeek == NULL) {
-        return MA_ERROR;
-    }
-
-    /* The callback uses a 32 bit integer whereas we use a 64 bit unsigned integer. We just need to continuously seek until we're at the correct position. */
-    totalBytesToSeek = frameIndex * ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-    if (totalBytesToSeek < 0x7FFFFFFF) {
-        /* Simple case. */
-        result = ma_decoder_seek_bytes(pDecoder, (int)(frameIndex * ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels)), ma_seek_origin_start);
-    } else {
-        /* Complex case. Start by doing a seek relative to the start. Then keep looping using offset seeking. */
-        result = ma_decoder_seek_bytes(pDecoder, 0x7FFFFFFF, ma_seek_origin_start);
-        if (result == MA_TRUE) {
-            totalBytesToSeek -= 0x7FFFFFFF;
-
-            while (totalBytesToSeek > 0) {
-                ma_uint64 bytesToSeekThisIteration = totalBytesToSeek;
-                if (bytesToSeekThisIteration > 0x7FFFFFFF) {
-                    bytesToSeekThisIteration = 0x7FFFFFFF;
-                }
-
-                result = ma_decoder_seek_bytes(pDecoder, (int)bytesToSeekThisIteration, ma_seek_origin_current);
-                if (result != MA_TRUE) {
-                    break;
-                }
-
-                totalBytesToSeek -= bytesToSeekThisIteration;
-            }
-        }
-    }
-
-    if (result) {
-        return MA_SUCCESS;
-    } else {
-        return MA_ERROR;
-    }
-}
-
-static ma_result ma_decoder_internal_on_uninit__raw(ma_decoder* pDecoder)
-{
-    (void)pDecoder;
-    return MA_SUCCESS;
-}
-
-static ma_uint64 ma_decoder_internal_on_get_length_in_pcm_frames__raw(ma_decoder* pDecoder)
-{
-    (void)pDecoder;
-    return 0;
-}
-
-static ma_result ma_decoder_init_raw__internal(const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    MA_ASSERT(pConfigIn != NULL);
-    MA_ASSERT(pConfigOut != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    (void)pConfigOut;
-
-    pDecoder->onReadPCMFrames        = ma_decoder_internal_on_read_pcm_frames__raw;
-    pDecoder->onSeekToPCMFrame       = ma_decoder_internal_on_seek_to_pcm_frame__raw;
-    pDecoder->onUninit               = ma_decoder_internal_on_uninit__raw;
-    pDecoder->onGetLengthInPCMFrames = ma_decoder_internal_on_get_length_in_pcm_frames__raw;
-
-    /* Internal format. */
-    pDecoder->internalFormat     = pConfigIn->format;
-    pDecoder->internalChannels   = pConfigIn->channels;
-    pDecoder->internalSampleRate = pConfigIn->sampleRate;
-    ma_channel_map_copy(pDecoder->internalChannelMap, pConfigIn->channelMap, pConfigIn->channels);
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__init_allocation_callbacks(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    MA_ASSERT(pDecoder != NULL);
-
-    if (pConfig != NULL) {
-        return ma_allocation_callbacks_init_copy(&pDecoder->allocationCallbacks, &pConfig->allocationCallbacks);
-    } else {
-        pDecoder->allocationCallbacks = ma_allocation_callbacks_init_default();
-        return MA_SUCCESS;
-    }
-}
-
-static ma_result ma_decoder__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_decoder_read_pcm_frames((ma_decoder*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_decoder_seek_to_pcm_frame((ma_decoder*)pDataSource, frameIndex);
-}
-
-static ma_result ma_decoder__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    *pFormat     = pDecoder->outputFormat;
-    *pChannels   = pDecoder->outputChannels;
-    *pSampleRate = pDecoder->outputSampleRate;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    return ma_decoder_get_cursor_in_pcm_frames(pDecoder, pLength);
-}
-
-static ma_result ma_decoder__data_source_on_get_length(ma_data_source* pDataSource, ma_uint64* pLength)
-{
-    ma_decoder* pDecoder = (ma_decoder*)pDataSource;
-
-    *pLength = ma_decoder_get_length_in_pcm_frames(pDecoder);
-    if (*pLength == 0) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-
-    MA_ASSERT(pConfig != NULL);
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pDecoder);
-
-    if (onRead == NULL || onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pDecoder->ds.onRead          = ma_decoder__data_source_on_read;
-    pDecoder->ds.onSeek          = ma_decoder__data_source_on_seek;
-    pDecoder->ds.onGetDataFormat = ma_decoder__data_source_on_get_data_format;
-    pDecoder->ds.onGetCursor     = ma_decoder__data_source_on_get_cursor;
-    pDecoder->ds.onGetLength     = ma_decoder__data_source_on_get_length;
-
-    pDecoder->onRead    = onRead;
-    pDecoder->onSeek    = onSeek;
-    pDecoder->pUserData = pUserData;
-
-    result = ma_decoder__init_allocation_callbacks(pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_decoder__postinit(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = MA_SUCCESS;
-
-    /* Basic validation in case the internal decoder supports different limits to miniaudio. */
-    if (pDecoder->internalChannels < MA_MIN_CHANNELS || pDecoder->internalChannels > MA_MAX_CHANNELS) {
-        result = MA_INVALID_DATA;
-    }
-
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__init_data_converter(pDecoder, pConfig);
-    }
-
-    /* If we failed post initialization we need to uninitialize the decoder before returning to prevent a memory leak. */
-    if (result != MA_SUCCESS) {
-        ma_decoder_uninit(pDecoder);
-        return result;
-    }
-
-    return result;
-}
-
-MA_API ma_result ma_decoder_init_wav(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_flac(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_mp3(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vorbis(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_raw(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfigOut);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_raw__internal(pConfigIn, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-}
-
-static ma_result ma_decoder_init__internal(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = MA_NO_BACKEND;
-
-    MA_ASSERT(pConfig != NULL);
-    MA_ASSERT(pDecoder != NULL);
-
-    /* Silence some warnings in the case that we don't have any decoder backends enabled. */
-    (void)onRead;
-    (void)onSeek;
-    (void)pUserData;
-    (void)pConfig;
-    (void)pDecoder;
-
-    /* We use trial and error to open a decoder. */
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_wav__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_flac__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_mp3__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_VORBIS
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init_vorbis__internal(pConfig, pDecoder);
-        if (result != MA_SUCCESS) {
-            onSeek(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init(ma_decoder_read_proc onRead, ma_decoder_seek_proc onSeek, void* pUserData, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder_init__internal(onRead, onSeek, pUserData, &config, pDecoder);
-}
-
-
-static size_t ma_decoder__on_read_memory(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRemaining;
-
-    MA_ASSERT(pDecoder->backend.memory.dataSize >= pDecoder->backend.memory.currentReadPos);
-
-    bytesRemaining = pDecoder->backend.memory.dataSize - pDecoder->backend.memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-
-    if (bytesToRead > 0) {
-        MA_COPY_MEMORY(pBufferOut, pDecoder->backend.memory.pData + pDecoder->backend.memory.currentReadPos, bytesToRead);
-        pDecoder->backend.memory.currentReadPos += bytesToRead;
-    }
-
-    return bytesToRead;
-}
-
-static ma_bool32 ma_decoder__on_seek_memory(ma_decoder* pDecoder, int byteOffset, ma_seek_origin origin)
-{
-    if (origin == ma_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pDecoder->backend.memory.currentReadPos + byteOffset > pDecoder->backend.memory.dataSize) {
-                byteOffset = (int)(pDecoder->backend.memory.dataSize - pDecoder->backend.memory.currentReadPos);  /* Trying to seek too far forward. */
-            }
-        } else {
-            if (pDecoder->backend.memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pDecoder->backend.memory.currentReadPos;  /* Trying to seek too far backwards. */
-            }
-        }
-
-        /* This will never underflow thanks to the clamps above. */
-        pDecoder->backend.memory.currentReadPos += byteOffset;
-    } else {
-        if ((ma_uint32)byteOffset <= pDecoder->backend.memory.dataSize) {
-            pDecoder->backend.memory.currentReadPos = byteOffset;
-        } else {
-            pDecoder->backend.memory.currentReadPos = pDecoder->backend.memory.dataSize;  /* Trying to seek too far forward. */
-        }
-    }
-
-    return MA_TRUE;
-}
-
-static ma_result ma_decoder__preinit_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result = ma_decoder__preinit(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pData == NULL || dataSize == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pDecoder->backend.memory.pData = (const ma_uint8*)pData;
-    pDecoder->backend.memory.dataSize = dataSize;
-    pDecoder->backend.memory.currentReadPos = 0;
-
-    (void)pConfig;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_memory(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder_init__internal(ma_decoder__on_read_memory, ma_decoder__on_seek_memory, NULL, &config, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_memory_wav(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_flac(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_mp3(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_vorbis(const void* pData, size_t dataSize, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfig);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-#else
-    (void)pData;
-    (void)dataSize;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_memory_raw(const void* pData, size_t dataSize, const ma_decoder_config* pConfigIn, const ma_decoder_config* pConfigOut, ma_decoder* pDecoder)
-{
-    ma_decoder_config config;
-    ma_result result;
-
-    config = ma_decoder_config_init_copy(pConfigOut);  /* Make sure the config is not NULL. */
-
-    result = ma_decoder__preinit_memory(pData, dataSize, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_raw__internal(pConfigIn, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__postinit(&config, pDecoder);
-}
-
-
-#if defined(MA_HAS_WAV)    || \
-    defined(MA_HAS_MP3)    || \
-    defined(MA_HAS_FLAC)   || \
-    defined(MA_HAS_VORBIS) || \
-    defined(MA_HAS_OPUS)
-#define MA_HAS_PATH_API
-#endif
-
-#if defined(MA_HAS_PATH_API)
-static const char* ma_path_file_name(const char* path)
-{
-    const char* fileName;
-
-    if (path == NULL) {
-        return NULL;
-    }
-
-    fileName = path;
-
-    /* We just loop through the path until we find the last slash. */
-    while (path[0] != '\0') {
-        if (path[0] == '/' || path[0] == '\\') {
-            fileName = path;
-        }
-
-        path += 1;
-    }
-
-    /* At this point the file name is sitting on a slash, so just move forward. */
-    while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) {
-        fileName += 1;
-    }
-
-    return fileName;
-}
-
-static const wchar_t* ma_path_file_name_w(const wchar_t* path)
-{
-    const wchar_t* fileName;
-
-    if (path == NULL) {
-        return NULL;
-    }
-
-    fileName = path;
-
-    /* We just loop through the path until we find the last slash. */
-    while (path[0] != '\0') {
-        if (path[0] == '/' || path[0] == '\\') {
-            fileName = path;
-        }
-
-        path += 1;
-    }
-
-    /* At this point the file name is sitting on a slash, so just move forward. */
-    while (fileName[0] != '\0' && (fileName[0] == '/' || fileName[0] == '\\')) {
-        fileName += 1;
-    }
-
-    return fileName;
-}
-
-
-static const char* ma_path_extension(const char* path)
-{
-    const char* extension;
-    const char* lastOccurance;
-
-    if (path == NULL) {
-        path = "";
-    }
-
-    extension = ma_path_file_name(path);
-    lastOccurance = NULL;
-
-    /* Just find the last '.' and return. */
-    while (extension[0] != '\0') {
-        if (extension[0] == '.') {
-            extension += 1;
-            lastOccurance = extension;
-        }
-
-        extension += 1;
-    }
-
-    return (lastOccurance != NULL) ? lastOccurance : extension;
-}
-
-static const wchar_t* ma_path_extension_w(const wchar_t* path)
-{
-    const wchar_t* extension;
-    const wchar_t* lastOccurance;
-
-    if (path == NULL) {
-        path = L"";
-    }
-
-    extension = ma_path_file_name_w(path);
-    lastOccurance = NULL;
-
-    /* Just find the last '.' and return. */
-    while (extension[0] != '\0') {
-        if (extension[0] == '.') {
-            extension += 1;
-            lastOccurance = extension;
-        }
-
-        extension += 1;
-    }
-
-    return (lastOccurance != NULL) ? lastOccurance : extension;
-}
-
-
-static ma_bool32 ma_path_extension_equal(const char* path, const char* extension)
-{
-    const char* ext1;
-    const char* ext2;
-
-    if (path == NULL || extension == NULL) {
-        return MA_FALSE;
-    }
-
-    ext1 = extension;
-    ext2 = ma_path_extension(path);
-
-#if defined(_MSC_VER) || defined(__DMC__)
-    return _stricmp(ext1, ext2) == 0;
-#else
-    return strcasecmp(ext1, ext2) == 0;
-#endif
-}
-
-static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* extension)
-{
-    const wchar_t* ext1;
-    const wchar_t* ext2;
-
-    if (path == NULL || extension == NULL) {
-        return MA_FALSE;
-    }
-
-    ext1 = extension;
-    ext2 = ma_path_extension_w(path);
-
-#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)
-    return _wcsicmp(ext1, ext2) == 0;
-#else
-    /*
-    I'm not aware of a wide character version of strcasecmp(). I'm therefore converting the extensions to multibyte strings and comparing those. This
-    isn't the most efficient way to do it, but it should work OK.
-    */
-    {
-        char ext1MB[4096];
-        char ext2MB[4096];
-        const wchar_t* pext1 = ext1;
-        const wchar_t* pext2 = ext2;
-        mbstate_t mbs1;
-        mbstate_t mbs2;
-
-        MA_ZERO_OBJECT(&mbs1);
-        MA_ZERO_OBJECT(&mbs2);
-
-        if (wcsrtombs(ext1MB, &pext1, sizeof(ext1MB), &mbs1) == (size_t)-1) {
-            return MA_FALSE;
-        }
-        if (wcsrtombs(ext2MB, &pext2, sizeof(ext2MB), &mbs2) == (size_t)-1) {
-            return MA_FALSE;
-        }
-
-        return strcasecmp(ext1MB, ext2MB) == 0;
-    }
-#endif
-}
-#endif  /* MA_HAS_PATH_API */
-
-
-
-static size_t ma_decoder__on_read_vfs(ma_decoder* pDecoder, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead;
-
-    MA_ASSERT(pDecoder   != NULL);
-    MA_ASSERT(pBufferOut != NULL);
-
-    ma_vfs_or_default_read(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file, pBufferOut, bytesToRead, &bytesRead);
-
-    return bytesRead;
-}
-
-static ma_bool32 ma_decoder__on_seek_vfs(ma_decoder* pDecoder, int offset, ma_seek_origin origin)
-{
-    ma_result result;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    result = ma_vfs_or_default_seek(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file, offset, origin);
-    if (result != MA_SUCCESS) {
-        return MA_FALSE;
-    }
-
-    return MA_TRUE;
-}
-
-static ma_result ma_decoder__preinit_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_vfs_file file;
-
-    result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFilePath == NULL || pFilePath[0] == '\0') {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_vfs_or_default_open(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pDecoder->backend.vfs.pVFS = pVFS;
-    pDecoder->backend.vfs.file = file;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = MA_NO_BACKEND;
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "wav")) {
-        result = ma_decoder_init_wav__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "flac")) {
-        result = ma_decoder_init_flac__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS && ma_path_extension_equal(pFilePath, "mp3")) {
-        result = ma_decoder_init_mp3__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder);
-    } else {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_wav(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_flac(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_mp3(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_vorbis(ma_vfs* pVFS, const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-
-
-static ma_result ma_decoder__preinit_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_vfs_file file;
-
-    result = ma_decoder__preinit(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, pConfig, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    if (pFilePath == NULL || pFilePath[0] == '\0') {
-        return MA_INVALID_ARGS;
-    }
-
-    result = ma_vfs_or_default_open_w(pVFS, pFilePath, MA_OPEN_MODE_READ, &file);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    pDecoder->backend.vfs.pVFS = pVFS;
-    pDecoder->backend.vfs.file = file;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = MA_NO_BACKEND;
-
-#ifdef MA_HAS_WAV
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"wav")) {
-        result = ma_decoder_init_wav__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_FLAC
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"flac")) {
-        result = ma_decoder_init_flac__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-#ifdef MA_HAS_MP3
-    if (result != MA_SUCCESS && ma_path_extension_equal_w(pFilePath, L"mp3")) {
-        result = ma_decoder_init_mp3__internal(&config, pDecoder);
-        if (result != MA_SUCCESS) {
-            ma_decoder__on_seek_vfs(pDecoder, 0, ma_seek_origin_start);
-        }
-    }
-#endif
-
-    /* If we still haven't got a result just use trial and error. Otherwise we can finish up. */
-    if (result != MA_SUCCESS) {
-        result = ma_decoder_init__internal(ma_decoder__on_read_vfs, ma_decoder__on_seek_vfs, NULL, &config, pDecoder);
-    } else {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_init_vfs_wav_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_WAV
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_wav__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_flac_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_FLAC
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_flac__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_mp3_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_MP3
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_mp3__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-MA_API ma_result ma_decoder_init_vfs_vorbis_w(ma_vfs* pVFS, const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-#ifdef MA_HAS_VORBIS
-    ma_result result;
-    ma_decoder_config config;
-
-    config = ma_decoder_config_init_copy(pConfig);
-    result = ma_decoder__preinit_vfs_w(pVFS, pFilePath, &config, pDecoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder_init_vorbis__internal(&config, pDecoder);
-    if (result == MA_SUCCESS) {
-        result = ma_decoder__postinit(&config, pDecoder);
-    }
-
-    if (result != MA_SUCCESS) {
-        ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
-    }
-
-    return result;
-#else
-    (void)pVFS;
-    (void)pFilePath;
-    (void)pConfig;
-    (void)pDecoder;
-    return MA_NO_BACKEND;
-#endif
-}
-
-
-
-MA_API ma_result ma_decoder_init_file(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_wav(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_wav(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_flac(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_flac(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_mp3(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_mp3(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_vorbis(const char* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_vorbis(NULL, pFilePath, pConfig, pDecoder);
-}
-
-
-
-MA_API ma_result ma_decoder_init_file_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_wav_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_wav_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_flac_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_flac_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_mp3_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_mp3_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_init_file_vorbis_w(const wchar_t* pFilePath, const ma_decoder_config* pConfig, ma_decoder* pDecoder)
-{
-    return ma_decoder_init_vfs_vorbis_w(NULL, pFilePath, pConfig, pDecoder);
-}
-
-MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder)
-{
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDecoder->onUninit) {
-        pDecoder->onUninit(pDecoder);
-    }
-
-    if (pDecoder->onRead == ma_decoder__on_read_vfs) {
-        ma_vfs_or_default_close(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file);
-    }
-
-    ma_data_converter_uninit(&pDecoder->converter);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decoder_get_cursor_in_pcm_frames(ma_decoder* pDecoder, ma_uint64* pCursor)
-{
-    if (pCursor == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = 0;
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pCursor = pDecoder->readPointerInPCMFrames;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_uint64 ma_decoder_get_length_in_pcm_frames(ma_decoder* pDecoder)
-{
-    if (pDecoder == NULL) {
-        return 0;
-    }
-
-    if (pDecoder->onGetLengthInPCMFrames) {
-        ma_uint64 nativeLengthInPCMFrames = pDecoder->onGetLengthInPCMFrames(pDecoder);
-        if (pDecoder->internalSampleRate == pDecoder->outputSampleRate) {
-            return nativeLengthInPCMFrames;
-        } else {
-            return ma_calculate_frame_count_after_resampling(pDecoder->outputSampleRate, pDecoder->internalSampleRate, nativeLengthInPCMFrames);
-        }
-    }
-
-    return 0;
-}
-
-MA_API ma_uint64 ma_decoder_read_pcm_frames(ma_decoder* pDecoder, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_result result;
-    ma_uint64 totalFramesReadOut;
-    ma_uint64 totalFramesReadIn;
-    void* pRunningFramesOut;
-
-    if (pDecoder == NULL) {
-        return 0;
-    }
-
-    if (pDecoder->onReadPCMFrames == NULL) {
-        return 0;
-    }
-
-    /* Fast path. */
-    if (pDecoder->converter.isPassthrough) {
-        totalFramesReadOut = pDecoder->onReadPCMFrames(pDecoder, pFramesOut, frameCount);
-    } else {
-        /*
-        Getting here means we need to do data conversion. If we're seeking forward and are _not_ doing resampling we can run this in a fast path. If we're doing resampling we
-        need to run through each sample because we need to ensure it's internal cache is updated.
-        */
-        if (pFramesOut == NULL && pDecoder->converter.hasResampler == MA_FALSE) {
-            totalFramesReadOut = pDecoder->onReadPCMFrames(pDecoder, NULL, frameCount);   /* All decoder backends must support passing in NULL for the output buffer. */
-        } else {
-            /* Slow path. Need to run everything through the data converter. */
-            totalFramesReadOut = 0;
-            totalFramesReadIn  = 0;
-            pRunningFramesOut  = pFramesOut;
-
-            while (totalFramesReadOut < frameCount) {
-                ma_uint8 pIntermediaryBuffer[MA_DATA_CONVERTER_STACK_BUFFER_SIZE];  /* In internal format. */
-                ma_uint64 intermediaryBufferCap = sizeof(pIntermediaryBuffer) / ma_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels);
-                ma_uint64 framesToReadThisIterationIn;
-                ma_uint64 framesReadThisIterationIn;
-                ma_uint64 framesToReadThisIterationOut;
-                ma_uint64 framesReadThisIterationOut;
-                ma_uint64 requiredInputFrameCount;
-
-                framesToReadThisIterationOut = (frameCount - totalFramesReadOut);
-                framesToReadThisIterationIn = framesToReadThisIterationOut;
-                if (framesToReadThisIterationIn > intermediaryBufferCap) {
-                    framesToReadThisIterationIn = intermediaryBufferCap;
-                }
-
-                requiredInputFrameCount = ma_data_converter_get_required_input_frame_count(&pDecoder->converter, framesToReadThisIterationOut);
-                if (framesToReadThisIterationIn > requiredInputFrameCount) {
-                    framesToReadThisIterationIn = requiredInputFrameCount;
-                }
-
-                if (requiredInputFrameCount > 0) {
-                    framesReadThisIterationIn = pDecoder->onReadPCMFrames(pDecoder, pIntermediaryBuffer, framesToReadThisIterationIn);
-                    totalFramesReadIn += framesReadThisIterationIn;
-                } else {
-                    framesReadThisIterationIn = 0;
-                }
-
-                /*
-                At this point we have our decoded data in input format and now we need to convert to output format. Note that even if we didn't read any
-                input frames, we still want to try processing frames because there may some output frames generated from cached input data.
-                */
-                framesReadThisIterationOut = framesToReadThisIterationOut;
-                result = ma_data_converter_process_pcm_frames(&pDecoder->converter, pIntermediaryBuffer, &framesReadThisIterationIn, pRunningFramesOut, &framesReadThisIterationOut);
-                if (result != MA_SUCCESS) {
-                    break;
-                }
-
-                totalFramesReadOut += framesReadThisIterationOut;
-
-                if (pRunningFramesOut != NULL) {
-                    pRunningFramesOut = ma_offset_ptr(pRunningFramesOut, framesReadThisIterationOut * ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels));
-                }
-
-                if (framesReadThisIterationIn == 0 && framesReadThisIterationOut == 0) {
-                    break;  /* We're done. */
-                }
-            }
-        }
-    }
-
-    pDecoder->readPointerInPCMFrames += totalFramesReadOut;
-
-    return totalFramesReadOut;
-}
-
-MA_API ma_result ma_decoder_seek_to_pcm_frame(ma_decoder* pDecoder, ma_uint64 frameIndex)
-{
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pDecoder->onSeekToPCMFrame) {
-        ma_result result;
-        ma_uint64 internalFrameIndex;
-        if (pDecoder->internalSampleRate == pDecoder->outputSampleRate) {
-            internalFrameIndex = frameIndex;
-        } else {
-            internalFrameIndex = ma_calculate_frame_count_after_resampling(pDecoder->internalSampleRate, pDecoder->outputSampleRate, frameIndex);
-        }
-
-        result = pDecoder->onSeekToPCMFrame(pDecoder, internalFrameIndex);
-        if (result == MA_SUCCESS) {
-            pDecoder->readPointerInPCMFrames = frameIndex;
-        }
-
-        return result;
-    }
-
-    /* Should never get here, but if we do it means onSeekToPCMFrame was not set by the backend. */
-    return MA_INVALID_ARGS;
-}
-
-MA_API ma_result ma_decoder_get_available_frames(ma_decoder* pDecoder, ma_uint64* pAvailableFrames)
-{
-    ma_uint64 totalFrameCount;
-
-    if (pAvailableFrames == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    *pAvailableFrames = 0;
-
-    if (pDecoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    totalFrameCount = ma_decoder_get_length_in_pcm_frames(pDecoder);
-    if (totalFrameCount == 0) {
-        return MA_NOT_IMPLEMENTED;
-    }
-
-    if (totalFrameCount <= pDecoder->readPointerInPCMFrames) {
-        *pAvailableFrames = 0;
-    } else {
-        *pAvailableFrames = totalFrameCount - pDecoder->readPointerInPCMFrames;
-    }
-
-    return MA_SUCCESS;   /* No frames available. */
-}
-
-
-static ma_result ma_decoder__full_decode_and_uninit(ma_decoder* pDecoder, ma_decoder_config* pConfigOut, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_uint64 totalFrameCount;
-    ma_uint64 bpf;
-    ma_uint64 dataCapInFrames;
-    void* pPCMFramesOut;
-
-    MA_ASSERT(pDecoder != NULL);
-
-    totalFrameCount = 0;
-    bpf = ma_get_bytes_per_frame(pDecoder->outputFormat, pDecoder->outputChannels);
-
-    /* The frame count is unknown until we try reading. Thus, we just run in a loop. */
-    dataCapInFrames = 0;
-    pPCMFramesOut = NULL;
-    for (;;) {
-        ma_uint64 frameCountToTryReading;
-        ma_uint64 framesJustRead;
-
-        /* Make room if there's not enough. */
-        if (totalFrameCount == dataCapInFrames) {
-            void* pNewPCMFramesOut;
-            ma_uint64 oldDataCapInFrames = dataCapInFrames;
-            ma_uint64 newDataCapInFrames = dataCapInFrames*2;
-            if (newDataCapInFrames == 0) {
-                newDataCapInFrames = 4096;
-            }
-
-            if ((newDataCapInFrames * bpf) > MA_SIZE_MAX) {
-                ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-                return MA_TOO_BIG;
-            }
-
-
-            pNewPCMFramesOut = (void*)ma__realloc_from_callbacks(pPCMFramesOut, (size_t)(newDataCapInFrames * bpf), (size_t)(oldDataCapInFrames * bpf), &pDecoder->allocationCallbacks);
-            if (pNewPCMFramesOut == NULL) {
-                ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-                return MA_OUT_OF_MEMORY;
-            }
-
-            dataCapInFrames = newDataCapInFrames;
-            pPCMFramesOut = pNewPCMFramesOut;
-        }
-
-        frameCountToTryReading = dataCapInFrames - totalFrameCount;
-        MA_ASSERT(frameCountToTryReading > 0);
-
-        framesJustRead = ma_decoder_read_pcm_frames(pDecoder, (ma_uint8*)pPCMFramesOut + (totalFrameCount * bpf), frameCountToTryReading);
-        totalFrameCount += framesJustRead;
-
-        if (framesJustRead < frameCountToTryReading) {
-            break;
-        }
-    }
-
-
-    if (pConfigOut != NULL) {
-        pConfigOut->format = pDecoder->outputFormat;
-        pConfigOut->channels = pDecoder->outputChannels;
-        pConfigOut->sampleRate = pDecoder->outputSampleRate;
-        ma_channel_map_copy(pConfigOut->channelMap, pDecoder->outputChannelMap, pDecoder->outputChannels);
-    }
-
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = pPCMFramesOut;
-    } else {
-        ma__free_from_callbacks(pPCMFramesOut, &pDecoder->allocationCallbacks);
-    }
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = totalFrameCount;
-    }
-
-    ma_decoder_uninit(pDecoder);
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_decode_from_vfs(ma_vfs* pVFS, const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_result result;
-    ma_decoder_config config;
-    ma_decoder decoder;
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = 0;
-    }
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = NULL;
-    }
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder_init_vfs(pVFS, pFilePath, &config, &decoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    result = ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
-
-    return result;
-}
-
-MA_API ma_result ma_decode_file(const char* pFilePath, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    return ma_decode_from_vfs(NULL, pFilePath, pConfig, pFrameCountOut, ppPCMFramesOut);
-}
-
-MA_API ma_result ma_decode_memory(const void* pData, size_t dataSize, ma_decoder_config* pConfig, ma_uint64* pFrameCountOut, void** ppPCMFramesOut)
-{
-    ma_decoder_config config;
-    ma_decoder decoder;
-    ma_result result;
-
-    if (pFrameCountOut != NULL) {
-        *pFrameCountOut = 0;
-    }
-    if (ppPCMFramesOut != NULL) {
-        *ppPCMFramesOut = NULL;
-    }
-
-    if (pData == NULL || dataSize == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    config = ma_decoder_config_init_copy(pConfig);
-
-    result = ma_decoder_init_memory(pData, dataSize, &config, &decoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut);
-}
-#endif  /* MA_NO_DECODING */
-
-
-#ifndef MA_NO_ENCODING
-
-#if defined(MA_HAS_WAV)
-static size_t ma_encoder__internal_on_write_wav(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    ma_encoder* pEncoder = (ma_encoder*)pUserData;
-    MA_ASSERT(pEncoder != NULL);
-
-    return pEncoder->onWrite(pEncoder, pData, bytesToWrite);
-}
-
-static drwav_bool32 ma_encoder__internal_on_seek_wav(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    ma_encoder* pEncoder = (ma_encoder*)pUserData;
-    MA_ASSERT(pEncoder != NULL);
-
-    return pEncoder->onSeek(pEncoder, offset, (origin == drwav_seek_origin_start) ? ma_seek_origin_start : ma_seek_origin_current);
-}
-
-static ma_result ma_encoder__on_init_wav(ma_encoder* pEncoder)
-{
-    drwav_data_format wavFormat;
-    drwav_allocation_callbacks allocationCallbacks;
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)ma__malloc_from_callbacks(sizeof(*pWav), &pEncoder->config.allocationCallbacks);
-    if (pWav == NULL) {
-        return MA_OUT_OF_MEMORY;
-    }
-
-    wavFormat.container     = drwav_container_riff;
-    wavFormat.channels      = pEncoder->config.channels;
-    wavFormat.sampleRate    = pEncoder->config.sampleRate;
-    wavFormat.bitsPerSample = ma_get_bytes_per_sample(pEncoder->config.format) * 8;
-    if (pEncoder->config.format == ma_format_f32) {
-        wavFormat.format    = DR_WAVE_FORMAT_IEEE_FLOAT;
-    } else {
-        wavFormat.format    = DR_WAVE_FORMAT_PCM;
-    }
-
-    allocationCallbacks.pUserData = pEncoder->config.allocationCallbacks.pUserData;
-    allocationCallbacks.onMalloc  = pEncoder->config.allocationCallbacks.onMalloc;
-    allocationCallbacks.onRealloc = pEncoder->config.allocationCallbacks.onRealloc;
-    allocationCallbacks.onFree    = pEncoder->config.allocationCallbacks.onFree;
-
-    if (!drwav_init_write(pWav, &wavFormat, ma_encoder__internal_on_write_wav, ma_encoder__internal_on_seek_wav, pEncoder, &allocationCallbacks)) {
-        return MA_ERROR;
-    }
-
-    pEncoder->pInternalEncoder = pWav;
-
-    return MA_SUCCESS;
-}
-
-static void ma_encoder__on_uninit_wav(ma_encoder* pEncoder)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)pEncoder->pInternalEncoder;
-    MA_ASSERT(pWav != NULL);
-
-    drwav_uninit(pWav);
-    ma__free_from_callbacks(pWav, &pEncoder->config.allocationCallbacks);
-}
-
-static ma_uint64 ma_encoder__on_write_pcm_frames_wav(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount)
-{
-    drwav* pWav;
-
-    MA_ASSERT(pEncoder != NULL);
-
-    pWav = (drwav*)pEncoder->pInternalEncoder;
-    MA_ASSERT(pWav != NULL);
-
-    return drwav_write_pcm_frames(pWav, frameCount, pFramesIn);
-}
-#endif
-
-MA_API ma_encoder_config ma_encoder_config_init(ma_resource_format resourceFormat, ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
-{
-    ma_encoder_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.resourceFormat = resourceFormat;
-    config.format = format;
-    config.channels = channels;
-    config.sampleRate = sampleRate;
-
-    return config;
-}
-
-MA_API ma_result ma_encoder_preinit(const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-
-    if (pEncoder == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pEncoder);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->format == ma_format_unknown || pConfig->channels == 0 || pConfig->sampleRate == 0) {
-        return MA_INVALID_ARGS;
-    }
-
-    pEncoder->config = *pConfig;
-
-    result = ma_allocation_callbacks_init_copy(&pEncoder->config.allocationCallbacks, &pConfig->allocationCallbacks);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_encoder_init__internal(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, ma_encoder* pEncoder)
-{
-    ma_result result = MA_SUCCESS;
-
-    /* This assumes ma_encoder_preinit() has been called prior. */
-    MA_ASSERT(pEncoder != NULL);
-
-    if (onWrite == NULL || onSeek == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pEncoder->onWrite   = onWrite;
-    pEncoder->onSeek    = onSeek;
-    pEncoder->pUserData = pUserData;
-
-    switch (pEncoder->config.resourceFormat)
-    {
-        case ma_resource_format_wav:
-        {
-        #if defined(MA_HAS_WAV)
-            pEncoder->onInit           = ma_encoder__on_init_wav;
-            pEncoder->onUninit         = ma_encoder__on_uninit_wav;
-            pEncoder->onWritePCMFrames = ma_encoder__on_write_pcm_frames_wav;
-        #else
-            result = MA_NO_BACKEND;
-        #endif
-        } break;
-
-        default:
-        {
-            result = MA_INVALID_ARGS;
-        } break;
-    }
-
-    /* Getting here means we should have our backend callbacks set up. */
-    if (result == MA_SUCCESS) {
-        result = pEncoder->onInit(pEncoder);
-        if (result != MA_SUCCESS) {
-            return result;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API size_t ma_encoder__on_write_stdio(ma_encoder* pEncoder, const void* pBufferIn, size_t bytesToWrite)
-{
-    return fwrite(pBufferIn, 1, bytesToWrite, (FILE*)pEncoder->pFile);
-}
-
-MA_API ma_bool32 ma_encoder__on_seek_stdio(ma_encoder* pEncoder, int byteOffset, ma_seek_origin origin)
-{
-    return fseek((FILE*)pEncoder->pFile, byteOffset, (origin == ma_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-
-MA_API ma_result ma_encoder_init_file(const char* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-    FILE* pFile;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Now open the file. If this fails we don't need to uninitialize the encoder. */
-    result = ma_fopen(&pFile, pFilePath, "wb");
-    if (pFile == NULL) {
-        return result;
-    }
-
-    pEncoder->pFile = pFile;
-
-    return ma_encoder_init__internal(ma_encoder__on_write_stdio, ma_encoder__on_seek_stdio, NULL, pEncoder);
-}
-
-MA_API ma_result ma_encoder_init_file_w(const wchar_t* pFilePath, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-    FILE* pFile;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    /* Now open the file. If this fails we don't need to uninitialize the encoder. */
-    result = ma_wfopen(&pFile, pFilePath, L"wb", &pEncoder->config.allocationCallbacks);
-    if (pFile != NULL) {
-        return result;
-    }
-
-    pEncoder->pFile = pFile;
-
-    return ma_encoder_init__internal(ma_encoder__on_write_stdio, ma_encoder__on_seek_stdio, NULL, pEncoder);
-}
-
-MA_API ma_result ma_encoder_init(ma_encoder_write_proc onWrite, ma_encoder_seek_proc onSeek, void* pUserData, const ma_encoder_config* pConfig, ma_encoder* pEncoder)
-{
-    ma_result result;
-
-    result = ma_encoder_preinit(pConfig, pEncoder);
-    if (result != MA_SUCCESS) {
-        return result;
-    }
-
-    return ma_encoder_init__internal(onWrite, onSeek, pUserData, pEncoder);
-}
-
-
-MA_API void ma_encoder_uninit(ma_encoder* pEncoder)
-{
-    if (pEncoder == NULL) {
-        return;
-    }
-
-    if (pEncoder->onUninit) {
-        pEncoder->onUninit(pEncoder);
-    }
-
-    /* If we have a file handle, close it. */
-    if (pEncoder->onWrite == ma_encoder__on_write_stdio) {
-        fclose((FILE*)pEncoder->pFile);
-    }
-}
-
-
-MA_API ma_uint64 ma_encoder_write_pcm_frames(ma_encoder* pEncoder, const void* pFramesIn, ma_uint64 frameCount)
-{
-    if (pEncoder == NULL || pFramesIn == NULL) {
-        return 0;
-    }
-
-    return pEncoder->onWritePCMFrames(pEncoder, pFramesIn, frameCount);
-}
-#endif  /* MA_NO_ENCODING */
-
-
-
-/**************************************************************************************************************************************************************
-
-Generation
-
-**************************************************************************************************************************************************************/
-#ifndef MA_NO_GENERATION
-MA_API ma_waveform_config ma_waveform_config_init(ma_format format, ma_uint32 channels, ma_uint32 sampleRate, ma_waveform_type type, double amplitude, double frequency)
-{
-    ma_waveform_config config;
-
-    MA_ZERO_OBJECT(&config);
-    config.format     = format;
-    config.channels   = channels;
-    config.sampleRate = sampleRate;
-    config.type       = type;
-    config.amplitude  = amplitude;
-    config.frequency  = frequency;
-
-    return config;
-}
-
-static ma_result ma_waveform__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_waveform_read_pcm_frames((ma_waveform*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_waveform__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    return ma_waveform_seek_to_pcm_frame((ma_waveform*)pDataSource, frameIndex);
-}
-
-static ma_result ma_waveform__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_waveform* pWaveform = (ma_waveform*)pDataSource;
-
-    *pFormat     = pWaveform->config.format;
-    *pChannels   = pWaveform->config.channels;
-    *pSampleRate = pWaveform->config.sampleRate;
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_waveform__data_source_on_get_cursor(ma_data_source* pDataSource, ma_uint64* pCursor)
-{
-    ma_waveform* pWaveform = (ma_waveform*)pDataSource;
-
-    *pCursor = (ma_uint64)(pWaveform->time / pWaveform->advance);
-
-    return MA_SUCCESS;
-}
-
-static double ma_waveform__calculate_advance(ma_uint32 sampleRate, double frequency)
-{
-    return (1.0 / (sampleRate / frequency));
-}
-
-static void ma_waveform__update_advance(ma_waveform* pWaveform)
-{
-    pWaveform->advance = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency);
-}
-
-MA_API ma_result ma_waveform_init(const ma_waveform_config* pConfig, ma_waveform* pWaveform)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pWaveform);
-    pWaveform->ds.onRead          = ma_waveform__data_source_on_read;
-    pWaveform->ds.onSeek          = ma_waveform__data_source_on_seek;
-    pWaveform->ds.onGetDataFormat = ma_waveform__data_source_on_get_data_format;
-    pWaveform->ds.onGetCursor     = ma_waveform__data_source_on_get_cursor;
-    pWaveform->ds.onGetLength     = NULL;   /* Intentionally set to NULL since there's no notion of a length in waveforms. */
-    pWaveform->config             = *pConfig;
-    pWaveform->advance            = ma_waveform__calculate_advance(pWaveform->config.sampleRate, pWaveform->config.frequency);
-    pWaveform->time               = 0;
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.amplitude = amplitude;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.frequency = frequency;
-    ma_waveform__update_advance(pWaveform);
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.type = type;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->config.sampleRate = sampleRate;
-    ma_waveform__update_advance(pWaveform);
-
-    return MA_SUCCESS;
-}
-
-static float ma_waveform_sine_f32(double time, double amplitude)
-{
-    return (float)(ma_sin(MA_TAU_D * time) * amplitude);
-}
-
-static ma_int16 ma_waveform_sine_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_sine_f32(time, amplitude));
-}
-
-static float ma_waveform_square_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    if (f < 0.5) {
-        r =  amplitude;
-    } else {
-        r = -amplitude;
-    }
-
-    return (float)r;
-}
-
-static ma_int16 ma_waveform_square_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_square_f32(time, amplitude));
-}
-
-static float ma_waveform_triangle_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    r = 2 * ma_abs(2 * (f - 0.5)) - 1;
-
-    return (float)(r * amplitude);
-}
-
-static ma_int16 ma_waveform_triangle_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_triangle_f32(time, amplitude));
-}
-
-static float ma_waveform_sawtooth_f32(double time, double amplitude)
-{
-    double f = time - (ma_int64)time;
-    double r;
-
-    r = 2 * (f - 0.5);
-
-    return (float)(r * amplitude);
-}
-
-static ma_int16 ma_waveform_sawtooth_s16(double time, double amplitude)
-{
-    return ma_pcm_sample_f32_to_s16(ma_waveform_sawtooth_f32(time, amplitude));
-}
-
-static void ma_waveform_read_pcm_frames__sine(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_sine_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sine_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__square(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_square_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_square_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_square_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__triangle(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_triangle_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_triangle_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-static void ma_waveform_read_pcm_frames__sawtooth(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint64 iChannel;
-    ma_uint32 bps = ma_get_bytes_per_sample(pWaveform->config.format);
-    ma_uint32 bpf = bps * pWaveform->config.channels;
-
-    MA_ASSERT(pWaveform  != NULL);
-    MA_ASSERT(pFramesOut != NULL);
-
-    if (pWaveform->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutF32[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else if (pWaveform->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            ma_int16 s = ma_waveform_sawtooth_s16(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                pFramesOutS16[iFrame*pWaveform->config.channels + iChannel] = s;
-            }
-        }
-    } else {
-        for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-            float s = ma_waveform_sawtooth_f32(pWaveform->time, pWaveform->config.amplitude);
-            pWaveform->time += pWaveform->advance;
-
-            for (iChannel = 0; iChannel < pWaveform->config.channels; iChannel += 1) {
-                ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pWaveform->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-            }
-        }
-    }
-}
-
-MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFramesOut, ma_uint64 frameCount)
-{
-    if (pWaveform == NULL) {
-        return 0;
-    }
-
-    if (pFramesOut != NULL) {
-        switch (pWaveform->config.type)
-        {
-            case ma_waveform_type_sine:
-            {
-                ma_waveform_read_pcm_frames__sine(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_square:
-            {
-                ma_waveform_read_pcm_frames__square(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_triangle:
-            {
-                ma_waveform_read_pcm_frames__triangle(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            case ma_waveform_type_sawtooth:
-            {
-                ma_waveform_read_pcm_frames__sawtooth(pWaveform, pFramesOut, frameCount);
-            } break;
-
-            default: return 0;
-        }
-    } else {
-        pWaveform->time += pWaveform->advance * (ma_int64)frameCount; /* Cast to int64 required for VC6. Won't affect anything in practice. */
-    }
-
-    return frameCount;
-}
-
-MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex)
-{
-    if (pWaveform == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pWaveform->time = pWaveform->advance * (ma_int64)frameIndex;    /* Casting for VC6. Won't be an issue in practice. */
-
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_noise_config ma_noise_config_init(ma_format format, ma_uint32 channels, ma_noise_type type, ma_int32 seed, double amplitude)
-{
-    ma_noise_config config;
-    MA_ZERO_OBJECT(&config);
-
-    config.format    = format;
-    config.channels  = channels;
-    config.type      = type;
-    config.seed      = seed;
-    config.amplitude = amplitude;
-
-    if (config.seed == 0) {
-        config.seed = MA_DEFAULT_LCG_SEED;
-    }
-
-    return config;
-}
-
-
-static ma_result ma_noise__data_source_on_read(ma_data_source* pDataSource, void* pFramesOut, ma_uint64 frameCount, ma_uint64* pFramesRead)
-{
-    ma_uint64 framesRead = ma_noise_read_pcm_frames((ma_noise*)pDataSource, pFramesOut, frameCount);
-
-    if (pFramesRead != NULL) {
-        *pFramesRead = framesRead;
-    }
-
-    if (framesRead < frameCount) {
-        return MA_AT_END;
-    }
-
-    return MA_SUCCESS;
-}
-
-static ma_result ma_noise__data_source_on_seek(ma_data_source* pDataSource, ma_uint64 frameIndex)
-{
-    /* No-op. Just pretend to be successful. */
-    (void)pDataSource;
-    (void)frameIndex;
-    return MA_SUCCESS;
-}
-
-static ma_result ma_noise__data_source_on_get_data_format(ma_data_source* pDataSource, ma_format* pFormat, ma_uint32* pChannels, ma_uint32* pSampleRate)
-{
-    ma_noise* pNoise = (ma_noise*)pDataSource;
-
-    *pFormat     = pNoise->config.format;
-    *pChannels   = pNoise->config.channels;
-    *pSampleRate = 0;   /* There is no notion of sample rate with noise generation. */
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_init(const ma_noise_config* pConfig, ma_noise* pNoise)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    MA_ZERO_OBJECT(pNoise);
-
-    if (pConfig == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    if (pConfig->channels < MA_MIN_CHANNELS || pConfig->channels > MA_MAX_CHANNELS) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->ds.onRead          = ma_noise__data_source_on_read;
-    pNoise->ds.onSeek          = ma_noise__data_source_on_seek;  /* <-- No-op for noise. */
-    pNoise->ds.onGetDataFormat = ma_noise__data_source_on_get_data_format;
-    pNoise->ds.onGetCursor     = NULL;  /* No notion of a cursor for noise. */
-    pNoise->ds.onGetLength     = NULL;  /* No notion of a length for noise. */
-    pNoise->config             = *pConfig;
-    ma_lcg_seed(&pNoise->lcg, pConfig->seed);
-
-    if (pNoise->config.type == ma_noise_type_pink) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) {
-            pNoise->state.pink.accumulation[iChannel] = 0;
-            pNoise->state.pink.counter[iChannel]      = 1;
-        }
-    }
-
-    if (pNoise->config.type == ma_noise_type_brownian) {
-        ma_uint32 iChannel;
-        for (iChannel = 0; iChannel < pConfig->channels; iChannel += 1) {
-            pNoise->state.brownian.accumulation[iChannel] = 0;
-        }
-    }
-
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_set_amplitude(ma_noise* pNoise, double amplitude)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->config.amplitude = amplitude;
-    return MA_SUCCESS;
-}
-
-MA_API ma_result ma_noise_set_seed(ma_noise* pNoise, ma_int32 seed)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->lcg.state = seed;
-    return MA_SUCCESS;
-}
-
-
-MA_API ma_result ma_noise_set_type(ma_noise* pNoise, ma_noise_type type)
-{
-    if (pNoise == NULL) {
-        return MA_INVALID_ARGS;
-    }
-
-    pNoise->config.type = type;
-    return MA_SUCCESS;
-}
-
-static MA_INLINE float ma_noise_f32_white(ma_noise* pNoise)
-{
-    return (float)(ma_lcg_rand_f64(&pNoise->lcg) * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_white(ma_noise* pNoise)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_white(pNoise));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__white(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_white(pNoise);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_white(pNoise);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_white(pNoise);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_white(pNoise);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-
-static MA_INLINE unsigned int ma_tzcnt32(unsigned int x)
-{
-    unsigned int n;
-
-    /* Special case for odd numbers since they should happen about half the time. */
-    if (x & 0x1)  {
-        return 0;
-    }
-
-    if (x == 0) {
-        return sizeof(x) << 3;
-    }
-
-    n = 1;
-    if ((x & 0x0000FFFF) == 0) { x >>= 16; n += 16; }
-    if ((x & 0x000000FF) == 0) { x >>=  8; n +=  8; }
-    if ((x & 0x0000000F) == 0) { x >>=  4; n +=  4; }
-    if ((x & 0x00000003) == 0) { x >>=  2; n +=  2; }
-    n -= x & 0x00000001;
-
-    return n;
-}
-
-/*
-Pink noise generation based on Tonic (public domain) with modifications. https://github.com/TonicAudio/Tonic/blob/master/src/Tonic/Noise.h
-
-This is basically _the_ reference for pink noise from what I've found: http://www.firstpr.com.au/dsp/pink-noise/
-*/
-static MA_INLINE float ma_noise_f32_pink(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    double result;
-    double binPrev;
-    double binNext;
-    unsigned int ibin;
-
-    ibin = ma_tzcnt32(pNoise->state.pink.counter[iChannel]) & (ma_countof(pNoise->state.pink.bin[0]) - 1);
-
-    binPrev = pNoise->state.pink.bin[iChannel][ibin];
-    binNext = ma_lcg_rand_f64(&pNoise->lcg);
-    pNoise->state.pink.bin[iChannel][ibin] = binNext;
-
-    pNoise->state.pink.accumulation[iChannel] += (binNext - binPrev);
-    pNoise->state.pink.counter[iChannel]      += 1;
-
-    result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.pink.accumulation[iChannel]);
-    result /= 10;
-
-    return (float)(result * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_pink(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_pink(pNoise, iChannel));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__pink(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_pink(pNoise, iChannel);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_pink(pNoise, iChannel);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_pink(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_pink(pNoise, iChannel);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-
-static MA_INLINE float ma_noise_f32_brownian(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    double result;
-
-    result = (ma_lcg_rand_f64(&pNoise->lcg) + pNoise->state.brownian.accumulation[iChannel]);
-    result /= 1.005; /* Don't escape the -1..1 range on average. */
-
-    pNoise->state.brownian.accumulation[iChannel] = result;
-    result /= 20;
-
-    return (float)(result * pNoise->config.amplitude);
-}
-
-static MA_INLINE ma_int16 ma_noise_s16_brownian(ma_noise* pNoise, ma_uint32 iChannel)
-{
-    return ma_pcm_sample_f32_to_s16(ma_noise_f32_brownian(pNoise, iChannel));
-}
-
-static MA_INLINE ma_uint64 ma_noise_read_pcm_frames__brownian(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    ma_uint64 iFrame;
-    ma_uint32 iChannel;
-    const ma_uint32 channels = pNoise->config.channels;
-    MA_ASSUME(channels >= MA_MIN_CHANNELS && channels <= MA_MAX_CHANNELS);
-
-    if (pNoise->config.format == ma_format_f32) {
-        float* pFramesOutF32 = (float*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutF32[iFrame*channels + iChannel] = ma_noise_f32_brownian(pNoise, iChannel);
-                }
-            }
-        }
-    } else if (pNoise->config.format == ma_format_s16) {
-        ma_int16* pFramesOutS16 = (ma_int16*)pFramesOut;
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                ma_int16 s = ma_noise_s16_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = s;
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    pFramesOutS16[iFrame*channels + iChannel] = ma_noise_s16_brownian(pNoise, iChannel);
-                }
-            }
-        }
-    } else {
-        const ma_uint32 bps = ma_get_bytes_per_sample(pNoise->config.format);
-        const ma_uint32 bpf = bps * channels;
-
-        if (pNoise->config.duplicateChannels) {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                float s = ma_noise_f32_brownian(pNoise, 0);
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        } else {
-            for (iFrame = 0; iFrame < frameCount; iFrame += 1) {
-                for (iChannel = 0; iChannel < channels; iChannel += 1) {
-                    float s = ma_noise_f32_brownian(pNoise, iChannel);
-                    ma_pcm_convert(ma_offset_ptr(pFramesOut, iFrame*bpf + iChannel*bps), pNoise->config.format, &s, ma_format_f32, 1, ma_dither_mode_none);
-                }
-            }
-        }
-    }
-
-    return frameCount;
-}
-
-MA_API ma_uint64 ma_noise_read_pcm_frames(ma_noise* pNoise, void* pFramesOut, ma_uint64 frameCount)
-{
-    if (pNoise == NULL) {
-        return 0;
-    }
-
-    /* The output buffer is allowed to be NULL. Since we aren't tracking cursors or anything we can just do nothing and pretend to be successful. */
-    if (pFramesOut == NULL) {
-        return frameCount;
-    }
-
-    if (pNoise->config.type == ma_noise_type_white) {
-        return ma_noise_read_pcm_frames__white(pNoise, pFramesOut, frameCount);
-    }
-
-    if (pNoise->config.type == ma_noise_type_pink) {
-        return ma_noise_read_pcm_frames__pink(pNoise, pFramesOut, frameCount);
-    }
-
-    if (pNoise->config.type == ma_noise_type_brownian) {
-        return ma_noise_read_pcm_frames__brownian(pNoise, pFramesOut, frameCount);
-    }
-
-    /* Should never get here. */
-    MA_ASSERT(MA_FALSE);
-    return 0;
-}
-#endif /* MA_NO_GENERATION */
-
-
-
-/**************************************************************************************************************************************************************
-***************************************************************************************************************************************************************
-
-Auto Generated
-==============
-All code below is auto-generated from a tool. This mostly consists of decoding backend implementations such as dr_wav, dr_flac, etc. If you find a bug in the
-code below please report the bug to the respective repository for the relevant project (probably dr_libs).
-
-***************************************************************************************************************************************************************
-**************************************************************************************************************************************************************/
-#if !defined(MA_NO_WAV) && (!defined(MA_NO_DECODING) || !defined(MA_NO_ENCODING))
-#if !defined(DR_WAV_IMPLEMENTATION) && !defined(DRWAV_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_wav_c begin */
-#ifndef dr_wav_c
-#define dr_wav_c
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#ifndef DR_WAV_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#endif
-#ifndef DRWAV_ASSERT
-#include <assert.h>
-#define DRWAV_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRWAV_MALLOC
-#define DRWAV_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRWAV_REALLOC
-#define DRWAV_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRWAV_FREE
-#define DRWAV_FREE(p)                      free((p))
-#endif
-#ifndef DRWAV_COPY_MEMORY
-#define DRWAV_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRWAV_ZERO_MEMORY
-#define DRWAV_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRWAV_ZERO_OBJECT
-#define DRWAV_ZERO_OBJECT(p)               DRWAV_ZERO_MEMORY((p), sizeof(*p))
-#endif
-#define drwav_countof(x)                   (sizeof(x) / sizeof(x[0]))
-#define drwav_align(x, a)                  ((((x) + (a) - 1) / (a)) * (a))
-#define drwav_min(a, b)                    (((a) < (b)) ? (a) : (b))
-#define drwav_max(a, b)                    (((a) > (b)) ? (a) : (b))
-#define drwav_clamp(x, lo, hi)             (drwav_max((lo), drwav_min((hi), (x))))
-#define DRWAV_MAX_SIMD_VECTOR_SIZE         64
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRWAV_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRWAV_X86
-#elif defined(__arm__) || defined(_M_ARM)
-    #define DRWAV_ARM
-#endif
-#ifdef _MSC_VER
-    #define DRWAV_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRWAV_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRWAV_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRWAV_INLINE __inline
-#else
-    #define DRWAV_INLINE
-#endif
-#if defined(SIZE_MAX)
-    #define DRWAV_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRWAV_SIZE_MAX  ((drwav_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRWAV_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRWAV_HAS_BYTESWAP32_INTRINSIC
-        #define DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#endif
-DRWAV_API void drwav_version(drwav_uint32* pMajor, drwav_uint32* pMinor, drwav_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRWAV_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRWAV_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRWAV_VERSION_REVISION;
-    }
-}
-DRWAV_API const char* drwav_version_string(void)
-{
-    return DRWAV_VERSION_STRING;
-}
-#ifndef DRWAV_MAX_SAMPLE_RATE
-#define DRWAV_MAX_SAMPLE_RATE       384000
-#endif
-#ifndef DRWAV_MAX_CHANNELS
-#define DRWAV_MAX_CHANNELS          256
-#endif
-#ifndef DRWAV_MAX_BITS_PER_SAMPLE
-#define DRWAV_MAX_BITS_PER_SAMPLE   64
-#endif
-static const drwav_uint8 drwavGUID_W64_RIFF[16] = {0x72,0x69,0x66,0x66, 0x2E,0x91, 0xCF,0x11, 0xA5,0xD6, 0x28,0xDB,0x04,0xC1,0x00,0x00};
-static const drwav_uint8 drwavGUID_W64_WAVE[16] = {0x77,0x61,0x76,0x65, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_FMT [16] = {0x66,0x6D,0x74,0x20, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_FACT[16] = {0x66,0x61,0x63,0x74, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_DATA[16] = {0x64,0x61,0x74,0x61, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static const drwav_uint8 drwavGUID_W64_SMPL[16] = {0x73,0x6D,0x70,0x6C, 0xF3,0xAC, 0xD3,0x11, 0x8C,0xD1, 0x00,0xC0,0x4F,0x8E,0xDB,0x8A};
-static DRWAV_INLINE int drwav__is_little_endian(void)
-{
-#if defined(DRWAV_X86) || defined(DRWAV_X64)
-    return DRWAV_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRWAV_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-static DRWAV_INLINE void drwav__bytes_to_guid(const drwav_uint8* data, drwav_uint8* guid)
-{
-    int i;
-    for (i = 0; i < 16; ++i) {
-        guid[i] = data[i];
-    }
-}
-static DRWAV_INLINE drwav_uint16 drwav__bswap16(drwav_uint16 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-static DRWAV_INLINE drwav_uint32 drwav__bswap32(drwav_uint32 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRWAV_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRWAV_64BIT)
-            drwav_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRWAV_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-static DRWAV_INLINE drwav_uint64 drwav__bswap64(drwav_uint64 n)
-{
-#ifdef DRWAV_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & ((drwav_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drwav_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drwav_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drwav_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drwav_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drwav_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drwav_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drwav_uint64)0x000000FF      )) << 56);
-#endif
-}
-static DRWAV_INLINE drwav_int16 drwav__bswap_s16(drwav_int16 n)
-{
-    return (drwav_int16)drwav__bswap16((drwav_uint16)n);
-}
-static DRWAV_INLINE void drwav__bswap_samples_s16(drwav_int16* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s16(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE void drwav__bswap_s24(drwav_uint8* p)
-{
-    drwav_uint8 t;
-    t = p[0];
-    p[0] = p[2];
-    p[2] = t;
-}
-static DRWAV_INLINE void drwav__bswap_samples_s24(drwav_uint8* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        drwav_uint8* pSample = pSamples + (iSample*3);
-        drwav__bswap_s24(pSample);
-    }
-}
-static DRWAV_INLINE drwav_int32 drwav__bswap_s32(drwav_int32 n)
-{
-    return (drwav_int32)drwav__bswap32((drwav_uint32)n);
-}
-static DRWAV_INLINE void drwav__bswap_samples_s32(drwav_int32* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_s32(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE float drwav__bswap_f32(float n)
-{
-    union {
-        drwav_uint32 i;
-        float f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap32(x.i);
-    return x.f;
-}
-static DRWAV_INLINE void drwav__bswap_samples_f32(float* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f32(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE double drwav__bswap_f64(double n)
-{
-    union {
-        drwav_uint64 i;
-        double f;
-    } x;
-    x.f = n;
-    x.i = drwav__bswap64(x.i);
-    return x.f;
-}
-static DRWAV_INLINE void drwav__bswap_samples_f64(double* pSamples, drwav_uint64 sampleCount)
-{
-    drwav_uint64 iSample;
-    for (iSample = 0; iSample < sampleCount; iSample += 1) {
-        pSamples[iSample] = drwav__bswap_f64(pSamples[iSample]);
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples_pcm(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-        case 2:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case 3:
-        {
-            drwav__bswap_samples_s24((drwav_uint8*)pSamples, sampleCount);
-        } break;
-        case 4:
-        {
-            drwav__bswap_samples_s32((drwav_int32*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples_ieee(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample)
-{
-    switch (bytesPerSample)
-    {
-    #if 0
-        case 2:
-        {
-            drwav__bswap_samples_f16((drwav_float16*)pSamples, sampleCount);
-        } break;
-    #endif
-        case 4:
-        {
-            drwav__bswap_samples_f32((float*)pSamples, sampleCount);
-        } break;
-        case 8:
-        {
-            drwav__bswap_samples_f64((double*)pSamples, sampleCount);
-        } break;
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-static DRWAV_INLINE void drwav__bswap_samples(void* pSamples, drwav_uint64 sampleCount, drwav_uint32 bytesPerSample, drwav_uint16 format)
-{
-    switch (format)
-    {
-        case DR_WAVE_FORMAT_PCM:
-        {
-            drwav__bswap_samples_pcm(pSamples, sampleCount, bytesPerSample);
-        } break;
-        case DR_WAVE_FORMAT_IEEE_FLOAT:
-        {
-            drwav__bswap_samples_ieee(pSamples, sampleCount, bytesPerSample);
-        } break;
-        case DR_WAVE_FORMAT_ALAW:
-        case DR_WAVE_FORMAT_MULAW:
-        {
-            drwav__bswap_samples_s16((drwav_int16*)pSamples, sampleCount);
-        } break;
-        case DR_WAVE_FORMAT_ADPCM:
-        case DR_WAVE_FORMAT_DVI_ADPCM:
-        default:
-        {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        } break;
-    }
-}
-DRWAV_PRIVATE void* drwav__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_MALLOC(sz);
-}
-DRWAV_PRIVATE void* drwav__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRWAV_REALLOC(p, sz);
-}
-DRWAV_PRIVATE void drwav__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRWAV_FREE(p);
-}
-DRWAV_PRIVATE void* drwav__malloc_from_callbacks(size_t sz, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-DRWAV_PRIVATE void* drwav__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRWAV_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-DRWAV_PRIVATE void drwav__free_from_callbacks(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-DRWAV_PRIVATE drwav_allocation_callbacks drwav_copy_allocation_callbacks_or_defaults(const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return *pAllocationCallbacks;
-    } else {
-        drwav_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drwav__malloc_default;
-        allocationCallbacks.onRealloc = drwav__realloc_default;
-        allocationCallbacks.onFree    = drwav__free_default;
-        return allocationCallbacks;
-    }
-}
-static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
-{
-    return
-        formatTag == DR_WAVE_FORMAT_ADPCM ||
-        formatTag == DR_WAVE_FORMAT_DVI_ADPCM;
-}
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_riff(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 2);
-}
-DRWAV_PRIVATE unsigned int drwav__chunk_padding_size_w64(drwav_uint64 chunkSize)
-{
-    return (unsigned int)(chunkSize % 8);
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 samplesToRead, drwav_int16* pBufferOut);
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount);
-DRWAV_PRIVATE drwav_result drwav__read_chunk_header(drwav_read_proc onRead, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_chunk_header* pHeaderOut)
-{
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        drwav_uint8 sizeInBytes[4];
-        if (onRead(pUserData, pHeaderOut->id.fourcc, 4) != 4) {
-            return DRWAV_AT_END;
-        }
-        if (onRead(pUserData, sizeInBytes, 4) != 4) {
-            return DRWAV_INVALID_FILE;
-        }
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u32(sizeInBytes);
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_riff(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 8;
-    } else {
-        drwav_uint8 sizeInBytes[8];
-        if (onRead(pUserData, pHeaderOut->id.guid, 16) != 16) {
-            return DRWAV_AT_END;
-        }
-        if (onRead(pUserData, sizeInBytes, 8) != 8) {
-            return DRWAV_INVALID_FILE;
-        }
-        pHeaderOut->sizeInBytes = drwav_bytes_to_u64(sizeInBytes) - 24;
-        pHeaderOut->paddingSize = drwav__chunk_padding_size_w64(pHeaderOut->sizeInBytes);
-        *pRunningBytesReadOut += 24;
-    }
-    return DRWAV_SUCCESS;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__seek_forward(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    drwav_uint64 bytesRemainingToSeek = offset;
-    while (bytesRemainingToSeek > 0) {
-        if (bytesRemainingToSeek > 0x7FFFFFFF) {
-            if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek -= 0x7FFFFFFF;
-        } else {
-            if (!onSeek(pUserData, (int)bytesRemainingToSeek, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            bytesRemainingToSeek = 0;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__seek_from_start(drwav_seek_proc onSeek, drwav_uint64 offset, void* pUserData)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return onSeek(pUserData, (int)offset, drwav_seek_origin_start);
-    }
-    if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-    for (;;) {
-        if (offset <= 0x7FFFFFFF) {
-            return onSeek(pUserData, (int)offset, drwav_seek_origin_current);
-        }
-        if (!onSeek(pUserData, 0x7FFFFFFF, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        offset -= 0x7FFFFFFF;
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav__read_fmt(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, drwav_container container, drwav_uint64* pRunningBytesReadOut, drwav_fmt* fmtOut)
-{
-    drwav_chunk_header header;
-    drwav_uint8 fmt[16];
-    if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    while (((container == drwav_container_riff || container == drwav_container_rf64) && !drwav_fourcc_equal(header.id.fourcc, "fmt ")) || (container == drwav_container_w64 && !drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT))) {
-        if (!drwav__seek_forward(onSeek, header.sizeInBytes + header.paddingSize, pUserData)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.sizeInBytes + header.paddingSize;
-        if (drwav__read_chunk_header(onRead, pUserData, container, pRunningBytesReadOut, &header) != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (container == drwav_container_riff || container == drwav_container_rf64) {
-        if (!drwav_fourcc_equal(header.id.fourcc, "fmt ")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        if (!drwav_guid_equal(header.id.guid, drwavGUID_W64_FMT)) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (onRead(pUserData, fmt, sizeof(fmt)) != sizeof(fmt)) {
-        return DRWAV_FALSE;
-    }
-    *pRunningBytesReadOut += sizeof(fmt);
-    fmtOut->formatTag      = drwav_bytes_to_u16(fmt + 0);
-    fmtOut->channels       = drwav_bytes_to_u16(fmt + 2);
-    fmtOut->sampleRate     = drwav_bytes_to_u32(fmt + 4);
-    fmtOut->avgBytesPerSec = drwav_bytes_to_u32(fmt + 8);
-    fmtOut->blockAlign     = drwav_bytes_to_u16(fmt + 12);
-    fmtOut->bitsPerSample  = drwav_bytes_to_u16(fmt + 14);
-    fmtOut->extendedSize       = 0;
-    fmtOut->validBitsPerSample = 0;
-    fmtOut->channelMask        = 0;
-    memset(fmtOut->subFormat, 0, sizeof(fmtOut->subFormat));
-    if (header.sizeInBytes > 16) {
-        drwav_uint8 fmt_cbSize[2];
-        int bytesReadSoFar = 0;
-        if (onRead(pUserData, fmt_cbSize, sizeof(fmt_cbSize)) != sizeof(fmt_cbSize)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += sizeof(fmt_cbSize);
-        bytesReadSoFar = 18;
-        fmtOut->extendedSize = drwav_bytes_to_u16(fmt_cbSize);
-        if (fmtOut->extendedSize > 0) {
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                if (fmtOut->extendedSize != 22) {
-                    return DRWAV_FALSE;
-                }
-            }
-            if (fmtOut->formatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-                drwav_uint8 fmtext[22];
-                if (onRead(pUserData, fmtext, fmtOut->extendedSize) != fmtOut->extendedSize) {
-                    return DRWAV_FALSE;
-                }
-                fmtOut->validBitsPerSample = drwav_bytes_to_u16(fmtext + 0);
-                fmtOut->channelMask        = drwav_bytes_to_u32(fmtext + 2);
-                drwav__bytes_to_guid(fmtext + 6, fmtOut->subFormat);
-            } else {
-                if (!onSeek(pUserData, fmtOut->extendedSize, drwav_seek_origin_current)) {
-                    return DRWAV_FALSE;
-                }
-            }
-            *pRunningBytesReadOut += fmtOut->extendedSize;
-            bytesReadSoFar += fmtOut->extendedSize;
-        }
-        if (!onSeek(pUserData, (int)(header.sizeInBytes - bytesReadSoFar), drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += (header.sizeInBytes - bytesReadSoFar);
-    }
-    if (header.paddingSize > 0) {
-        if (!onSeek(pUserData, header.paddingSize, drwav_seek_origin_current)) {
-            return DRWAV_FALSE;
-        }
-        *pRunningBytesReadOut += header.paddingSize;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE size_t drwav__on_read(drwav_read_proc onRead, void* pUserData, void* pBufferOut, size_t bytesToRead, drwav_uint64* pCursor)
-{
-    size_t bytesRead;
-    DRWAV_ASSERT(onRead != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-    bytesRead = onRead(pUserData, pBufferOut, bytesToRead);
-    *pCursor += bytesRead;
-    return bytesRead;
-}
-#if 0
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek(drwav_seek_proc onSeek, void* pUserData, int offset, drwav_seek_origin origin, drwav_uint64* pCursor)
-{
-    DRWAV_ASSERT(onSeek != NULL);
-    DRWAV_ASSERT(pCursor != NULL);
-    if (!onSeek(pUserData, offset, origin)) {
-        return DRWAV_FALSE;
-    }
-    if (origin == drwav_seek_origin_start) {
-        *pCursor = offset;
-    } else {
-        *pCursor += offset;
-    }
-    return DRWAV_TRUE;
-}
-#endif
-DRWAV_PRIVATE drwav_uint32 drwav_get_bytes_per_pcm_frame(drwav* pWav)
-{
-    if ((pWav->bitsPerSample & 0x7) == 0) {
-        return (pWav->bitsPerSample * pWav->fmt.channels) >> 3;
-    } else {
-        return pWav->fmt.blockAlign;
-    }
-}
-DRWAV_API drwav_uint16 drwav_fmt_get_format(const drwav_fmt* pFMT)
-{
-    if (pFMT == NULL) {
-        return 0;
-    }
-    if (pFMT->formatTag != DR_WAVE_FORMAT_EXTENSIBLE) {
-        return pFMT->formatTag;
-    } else {
-        return drwav_bytes_to_u16(pFMT->subFormat);
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav_preinit(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pReadSeekUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onRead == NULL || onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onRead    = onRead;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pReadSeekUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags)
-{
-    drwav_uint64 cursor;
-    drwav_bool32 sequential;
-    drwav_uint8 riff[4];
-    drwav_fmt fmt;
-    unsigned short translatedFormatTag;
-    drwav_bool32 foundDataChunk;
-    drwav_uint64 dataChunkSize = 0;
-    drwav_uint64 sampleCountFromFactChunk = 0;
-    drwav_uint64 chunkSize;
-    cursor = 0;
-    sequential = (flags & DRWAV_SEQUENTIAL) != 0;
-    if (drwav__on_read(pWav->onRead, pWav->pUserData, riff, sizeof(riff), &cursor) != sizeof(riff)) {
-        return DRWAV_FALSE;
-    }
-    if (drwav_fourcc_equal(riff, "RIFF")) {
-        pWav->container = drwav_container_riff;
-    } else if (drwav_fourcc_equal(riff, "riff")) {
-        int i;
-        drwav_uint8 riff2[12];
-        pWav->container = drwav_container_w64;
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, riff2, sizeof(riff2), &cursor) != sizeof(riff2)) {
-            return DRWAV_FALSE;
-        }
-        for (i = 0; i < 12; ++i) {
-            if (riff2[i] != drwavGUID_W64_RIFF[i+4]) {
-                return DRWAV_FALSE;
-            }
-        }
-    } else if (drwav_fourcc_equal(riff, "RF64")) {
-        pWav->container = drwav_container_rf64;
-    } else {
-        return DRWAV_FALSE;
-    }
-    if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-        drwav_uint8 chunkSizeBytes[4];
-        drwav_uint8 wave[4];
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_bytes_to_u32(chunkSizeBytes) < 36) {
-                return DRWAV_FALSE;
-            }
-        } else {
-            if (drwav_bytes_to_u32(chunkSizeBytes) != 0xFFFFFFFF) {
-                return DRWAV_FALSE;
-            }
-        }
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_fourcc_equal(wave, "WAVE")) {
-            return DRWAV_FALSE;
-        }
-    } else {
-        drwav_uint8 chunkSizeBytes[8];
-        drwav_uint8 wave[16];
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, chunkSizeBytes, sizeof(chunkSizeBytes), &cursor) != sizeof(chunkSizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        if (drwav_bytes_to_u64(chunkSizeBytes) < 80) {
-            return DRWAV_FALSE;
-        }
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, wave, sizeof(wave), &cursor) != sizeof(wave)) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_guid_equal(wave, drwavGUID_W64_WAVE)) {
-            return DRWAV_FALSE;
-        }
-    }
-    if (pWav->container == drwav_container_rf64) {
-        drwav_uint8 sizeBytes[8];
-        drwav_uint64 bytesRemainingInChunk;
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            return DRWAV_FALSE;
-        }
-        if (!drwav_fourcc_equal(header.id.fourcc, "ds64")) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk = header.sizeInBytes + header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, 8, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        cursor += 8;
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        dataChunkSize = drwav_bytes_to_u64(sizeBytes);
-        if (drwav__on_read(pWav->onRead, pWav->pUserData, sizeBytes, sizeof(sizeBytes), &cursor) != sizeof(sizeBytes)) {
-            return DRWAV_FALSE;
-        }
-        bytesRemainingInChunk -= 8;
-        sampleCountFromFactChunk = drwav_bytes_to_u64(sizeBytes);
-        if (!drwav__seek_forward(pWav->onSeek, bytesRemainingInChunk, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor += bytesRemainingInChunk;
-    }
-    if (!drwav__read_fmt(pWav->onRead, pWav->onSeek, pWav->pUserData, pWav->container, &cursor, &fmt)) {
-        return DRWAV_FALSE;
-    }
-    if ((fmt.sampleRate    == 0 || fmt.sampleRate    > DRWAV_MAX_SAMPLE_RATE)     ||
-        (fmt.channels      == 0 || fmt.channels      > DRWAV_MAX_CHANNELS)        ||
-        (fmt.bitsPerSample == 0 || fmt.bitsPerSample > DRWAV_MAX_BITS_PER_SAMPLE) ||
-        fmt.blockAlign == 0) {
-        return DRWAV_FALSE;
-    }
-    translatedFormatTag = fmt.formatTag;
-    if (translatedFormatTag == DR_WAVE_FORMAT_EXTENSIBLE) {
-        translatedFormatTag = drwav_bytes_to_u16(fmt.subFormat + 0);
-    }
-    foundDataChunk = DRWAV_FALSE;
-    for (;;)
-    {
-        drwav_chunk_header header;
-        drwav_result result = drwav__read_chunk_header(pWav->onRead, pWav->pUserData, pWav->container, &cursor, &header);
-        if (result != DRWAV_SUCCESS) {
-            if (!foundDataChunk) {
-                return DRWAV_FALSE;
-            } else {
-                break;
-            }
-        }
-        if (!sequential && onChunk != NULL) {
-            drwav_uint64 callbackBytesRead = onChunk(pChunkUserData, pWav->onRead, pWav->onSeek, pWav->pUserData, &header, pWav->container, &fmt);
-            if (callbackBytesRead > 0) {
-                if (!drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData)) {
-                    return DRWAV_FALSE;
-                }
-            }
-        }
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-        chunkSize = header.sizeInBytes;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "data")) {
-                foundDataChunk = DRWAV_TRUE;
-                if (pWav->container != drwav_container_rf64) {
-                    dataChunkSize = chunkSize;
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_DATA)) {
-                foundDataChunk = DRWAV_TRUE;
-                dataChunkSize = chunkSize;
-            }
-        }
-        if (foundDataChunk && sequential) {
-            break;
-        }
-        if (pWav->container == drwav_container_riff) {
-            if (drwav_fourcc_equal(header.id.fourcc, "fact")) {
-                drwav_uint32 sampleCount;
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCount, 4, &cursor) != 4) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 4;
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    sampleCountFromFactChunk = sampleCount;
-                } else {
-                    sampleCountFromFactChunk = 0;
-                }
-            }
-        } else if (pWav->container == drwav_container_w64) {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_FACT)) {
-                if (drwav__on_read(pWav->onRead, pWav->pUserData, &sampleCountFromFactChunk, 8, &cursor) != 8) {
-                    return DRWAV_FALSE;
-                }
-                chunkSize -= 8;
-                if (!foundDataChunk) {
-                    pWav->dataChunkDataPos = cursor;
-                }
-            }
-        } else if (pWav->container == drwav_container_rf64) {
-        }
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            if (drwav_fourcc_equal(header.id.fourcc, "smpl")) {
-                drwav_uint8 smplHeaderData[36];
-                if (chunkSize >= sizeof(smplHeaderData)) {
-                    drwav_uint64 bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplHeaderData, sizeof(smplHeaderData), &cursor);
-                    chunkSize -= bytesJustRead;
-                    if (bytesJustRead == sizeof(smplHeaderData)) {
-                        drwav_uint32 iLoop;
-                        pWav->smpl.manufacturer      = drwav_bytes_to_u32(smplHeaderData+0);
-                        pWav->smpl.product           = drwav_bytes_to_u32(smplHeaderData+4);
-                        pWav->smpl.samplePeriod      = drwav_bytes_to_u32(smplHeaderData+8);
-                        pWav->smpl.midiUnityNotes    = drwav_bytes_to_u32(smplHeaderData+12);
-                        pWav->smpl.midiPitchFraction = drwav_bytes_to_u32(smplHeaderData+16);
-                        pWav->smpl.smpteFormat       = drwav_bytes_to_u32(smplHeaderData+20);
-                        pWav->smpl.smpteOffset       = drwav_bytes_to_u32(smplHeaderData+24);
-                        pWav->smpl.numSampleLoops    = drwav_bytes_to_u32(smplHeaderData+28);
-                        pWav->smpl.samplerData       = drwav_bytes_to_u32(smplHeaderData+32);
-                        for (iLoop = 0; iLoop < pWav->smpl.numSampleLoops && iLoop < drwav_countof(pWav->smpl.loops); ++iLoop) {
-                            drwav_uint8 smplLoopData[24];
-                            bytesJustRead = drwav__on_read(pWav->onRead, pWav->pUserData, smplLoopData, sizeof(smplLoopData), &cursor);
-                            chunkSize -= bytesJustRead;
-                            if (bytesJustRead == sizeof(smplLoopData)) {
-                                pWav->smpl.loops[iLoop].cuePointId = drwav_bytes_to_u32(smplLoopData+0);
-                                pWav->smpl.loops[iLoop].type       = drwav_bytes_to_u32(smplLoopData+4);
-                                pWav->smpl.loops[iLoop].start      = drwav_bytes_to_u32(smplLoopData+8);
-                                pWav->smpl.loops[iLoop].end        = drwav_bytes_to_u32(smplLoopData+12);
-                                pWav->smpl.loops[iLoop].fraction   = drwav_bytes_to_u32(smplLoopData+16);
-                                pWav->smpl.loops[iLoop].playCount  = drwav_bytes_to_u32(smplLoopData+20);
-                            } else {
-                                break;
-                            }
-                        }
-                    }
-                } else {
-                }
-            }
-        } else {
-            if (drwav_guid_equal(header.id.guid, drwavGUID_W64_SMPL)) {
-            }
-        }
-        chunkSize += header.paddingSize;
-        if (!drwav__seek_forward(pWav->onSeek, chunkSize, pWav->pUserData)) {
-            break;
-        }
-        cursor += chunkSize;
-        if (!foundDataChunk) {
-            pWav->dataChunkDataPos = cursor;
-        }
-    }
-    if (!foundDataChunk) {
-        return DRWAV_FALSE;
-    }
-    if (!sequential) {
-        if (!drwav__seek_from_start(pWav->onSeek, pWav->dataChunkDataPos, pWav->pUserData)) {
-            return DRWAV_FALSE;
-        }
-        cursor = pWav->dataChunkDataPos;
-    }
-    pWav->fmt                 = fmt;
-    pWav->sampleRate          = fmt.sampleRate;
-    pWav->channels            = fmt.channels;
-    pWav->bitsPerSample       = fmt.bitsPerSample;
-    pWav->bytesRemaining      = dataChunkSize;
-    pWav->translatedFormatTag = translatedFormatTag;
-    pWav->dataChunkDataSize   = dataChunkSize;
-    if (sampleCountFromFactChunk != 0) {
-        pWav->totalPCMFrameCount = sampleCountFromFactChunk;
-    } else {
-        pWav->totalPCMFrameCount = dataChunkSize / drwav_get_bytes_per_pcm_frame(pWav);
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-            totalBlockHeaderSizeInBytes = blockCount * (6*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-        }
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            drwav_uint64 totalBlockHeaderSizeInBytes;
-            drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-            if ((blockCount * fmt.blockAlign) < dataChunkSize) {
-                blockCount += 1;
-            }
-            totalBlockHeaderSizeInBytes = blockCount * (4*fmt.channels);
-            pWav->totalPCMFrameCount = ((dataChunkSize - totalBlockHeaderSizeInBytes) * 2) / fmt.channels;
-            pWav->totalPCMFrameCount += blockCount;
-        }
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM || pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        if (pWav->channels > 2) {
-            return DRWAV_FALSE;
-        }
-    }
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (6*pWav->channels))) * 2)) / fmt.channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        drwav_uint64 blockCount = dataChunkSize / fmt.blockAlign;
-        pWav->totalPCMFrameCount = (((blockCount * (fmt.blockAlign - (4*pWav->channels))) * 2) + (blockCount * pWav->channels)) / fmt.channels;
-    }
-#endif
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_ex(pWav, onRead, onSeek, NULL, pUserData, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_ex(drwav* pWav, drwav_read_proc onRead, drwav_seek_proc onSeek, drwav_chunk_proc onChunk, void* pReadSeekUserData, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit(pWav, onRead, onSeek, pReadSeekUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-DRWAV_PRIVATE drwav_uint32 drwav__riff_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize);
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-    return (drwav_uint32)chunkSize;
-}
-DRWAV_PRIVATE drwav_uint32 drwav__data_chunk_size_riff(drwav_uint64 dataChunkSize)
-{
-    if (dataChunkSize <= 0xFFFFFFFFUL) {
-        return (drwav_uint32)dataChunkSize;
-    } else {
-        return 0xFFFFFFFFUL;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 dataSubchunkPaddingSize = drwav__chunk_padding_size_w64(dataChunkSize);
-    return 80 + 24 + dataChunkSize + dataSubchunkPaddingSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_w64(drwav_uint64 dataChunkSize)
-{
-    return 24 + dataChunkSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__riff_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    drwav_uint64 chunkSize = 4 + 36 + 24 + dataChunkSize + drwav__chunk_padding_size_riff(dataChunkSize);
-    if (chunkSize > 0xFFFFFFFFUL) {
-        chunkSize = 0xFFFFFFFFUL;
-    }
-    return chunkSize;
-}
-DRWAV_PRIVATE drwav_uint64 drwav__data_chunk_size_rf64(drwav_uint64 dataChunkSize)
-{
-    return dataChunkSize;
-}
-DRWAV_PRIVATE size_t drwav__write(drwav* pWav, const void* pData, size_t dataSize)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    return pWav->onWrite(pWav->pUserData, pData, dataSize);
-}
-DRWAV_PRIVATE size_t drwav__write_u16ne_to_le(drwav* pWav, drwav_uint16 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap16(value);
-    }
-    return drwav__write(pWav, &value, 2);
-}
-DRWAV_PRIVATE size_t drwav__write_u32ne_to_le(drwav* pWav, drwav_uint32 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap32(value);
-    }
-    return drwav__write(pWav, &value, 4);
-}
-DRWAV_PRIVATE size_t drwav__write_u64ne_to_le(drwav* pWav, drwav_uint64 value)
-{
-    DRWAV_ASSERT(pWav          != NULL);
-    DRWAV_ASSERT(pWav->onWrite != NULL);
-    if (!drwav__is_little_endian()) {
-        value = drwav__bswap64(value);
-    }
-    return drwav__write(pWav, &value, 8);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_preinit_write(drwav* pWav, const drwav_data_format* pFormat, drwav_bool32 isSequential, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pWav == NULL || onWrite == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (!isSequential && onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_EXTENSIBLE) {
-        return DRWAV_FALSE;
-    }
-    if (pFormat->format == DR_WAVE_FORMAT_ADPCM || pFormat->format == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return DRWAV_FALSE;
-    }
-    DRWAV_ZERO_MEMORY(pWav, sizeof(*pWav));
-    pWav->onWrite   = onWrite;
-    pWav->onSeek    = onSeek;
-    pWav->pUserData = pUserData;
-    pWav->allocationCallbacks = drwav_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pWav->allocationCallbacks.onFree == NULL || (pWav->allocationCallbacks.onMalloc == NULL && pWav->allocationCallbacks.onRealloc == NULL)) {
-        return DRWAV_FALSE;
-    }
-    pWav->fmt.formatTag = (drwav_uint16)pFormat->format;
-    pWav->fmt.channels = (drwav_uint16)pFormat->channels;
-    pWav->fmt.sampleRate = pFormat->sampleRate;
-    pWav->fmt.avgBytesPerSec = (drwav_uint32)((pFormat->bitsPerSample * pFormat->sampleRate * pFormat->channels) / 8);
-    pWav->fmt.blockAlign = (drwav_uint16)((pFormat->channels * pFormat->bitsPerSample) / 8);
-    pWav->fmt.bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->fmt.extendedSize = 0;
-    pWav->isSequentialWrite = isSequential;
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    size_t runningPos = 0;
-    drwav_uint64 initialDataChunkSize = 0;
-    drwav_uint64 chunkSizeFMT;
-    if (pWav->isSequentialWrite) {
-        initialDataChunkSize = (totalSampleCount * pWav->fmt.bitsPerSample) / 8;
-        if (pFormat->container == drwav_container_riff) {
-            if (initialDataChunkSize > (0xFFFFFFFFUL - 36)) {
-                return DRWAV_FALSE;
-            }
-        }
-    }
-    pWav->dataChunkDataSizeTargetWrite = initialDataChunkSize;
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeRIFF = 28 + (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "RIFF", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeRIFF = 80 + 24 + initialDataChunkSize;
-        runningPos += drwav__write(pWav, drwavGUID_W64_RIFF, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeRIFF);
-        runningPos += drwav__write(pWav, drwavGUID_W64_WAVE, 16);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "RF64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
-        runningPos += drwav__write(pWav, "WAVE", 4);
-    }
-    if (pFormat->container == drwav_container_rf64) {
-        drwav_uint32 initialds64ChunkSize = 28;
-        drwav_uint64 initialRiffChunkSize = 8 + initialds64ChunkSize + initialDataChunkSize;
-        runningPos += drwav__write(pWav, "ds64", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, initialds64ChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, initialRiffChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, initialDataChunkSize);
-        runningPos += drwav__write_u64ne_to_le(pWav, totalSampleCount);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0);
-    }
-    if (pFormat->container == drwav_container_riff || pFormat->container == drwav_container_rf64) {
-        chunkSizeFMT = 16;
-        runningPos += drwav__write(pWav, "fmt ", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, (drwav_uint32)chunkSizeFMT);
-    } else if (pFormat->container == drwav_container_w64) {
-        chunkSizeFMT = 40;
-        runningPos += drwav__write(pWav, drwavGUID_W64_FMT, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeFMT);
-    }
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.formatTag);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.channels);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.sampleRate);
-    runningPos += drwav__write_u32ne_to_le(pWav, pWav->fmt.avgBytesPerSec);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
-    runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
-    if (pFormat->container == drwav_container_riff) {
-        drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_w64) {
-        drwav_uint64 chunkSizeDATA = 24 + initialDataChunkSize;
-        runningPos += drwav__write(pWav, drwavGUID_W64_DATA, 16);
-        runningPos += drwav__write_u64ne_to_le(pWav, chunkSizeDATA);
-    } else if (pFormat->container == drwav_container_rf64) {
-        runningPos += drwav__write(pWav, "data", 4);
-        runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
-    }
-    pWav->container = pFormat->container;
-    pWav->channels = (drwav_uint16)pFormat->channels;
-    pWav->sampleRate = pFormat->sampleRate;
-    pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
-    pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
-    pWav->dataChunkDataPos = runningPos;
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_write(drwav* pWav, const drwav_data_format* pFormat, drwav_write_proc onWrite, drwav_seek_proc onSeek, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_FALSE, onWrite, onSeek, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write__internal(pWav, pFormat, 0);
-}
-DRWAV_API drwav_bool32 drwav_init_write_sequential(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (!drwav_preinit_write(pWav, pFormat, DRWAV_TRUE, onWrite, NULL, pUserData, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-DRWAV_API drwav_bool32 drwav_init_write_sequential_pcm_frames(drwav* pWav, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, drwav_write_proc onWrite, void* pUserData, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_write_sequential(pWav, pFormat, totalPCMFrameCount*pFormat->channels, onWrite, pUserData, pAllocationCallbacks);
-}
-DRWAV_API drwav_uint64 drwav_target_write_size_bytes(const drwav_data_format* pFormat, drwav_uint64 totalSampleCount)
-{
-    drwav_uint64 targetDataSizeBytes = (drwav_uint64)((drwav_int64)totalSampleCount * pFormat->channels * pFormat->bitsPerSample/8.0);
-    drwav_uint64 riffChunkSizeBytes;
-    drwav_uint64 fileSizeBytes = 0;
-    if (pFormat->container == drwav_container_riff) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_riff(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);
-    } else if (pFormat->container == drwav_container_w64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_w64(targetDataSizeBytes);
-        fileSizeBytes = riffChunkSizeBytes;
-    } else if (pFormat->container == drwav_container_rf64) {
-        riffChunkSizeBytes = drwav__riff_chunk_size_rf64(targetDataSizeBytes);
-        fileSizeBytes = (8 + riffChunkSizeBytes);
-    }
-    return fileSizeBytes;
-}
-#ifndef DR_WAV_NO_STDIO
-#include <errno.h>
-DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRWAV_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRWAV_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRWAV_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRWAV_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRWAV_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRWAV_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRWAV_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRWAV_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRWAV_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRWAV_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRWAV_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRWAV_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRWAV_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRWAV_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRWAV_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRWAV_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRWAV_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRWAV_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRWAV_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRWAV_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRWAV_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRWAV_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRWAV_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRWAV_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRWAV_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRWAV_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRWAV_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRWAV_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRWAV_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRWAV_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRWAV_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRWAV_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRWAV_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRWAV_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRWAV_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRWAV_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRWAV_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRWAV_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRWAV_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRWAV_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRWAV_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRWAV_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRWAV_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRWAV_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRWAV_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRWAV_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRWAV_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRWAV_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRWAV_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRWAV_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRWAV_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRWAV_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRWAV_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRWAV_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRWAV_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRWAV_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRWAV_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRWAV_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRWAV_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRWAV_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRWAV_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRWAV_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRWAV_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRWAV_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRWAV_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRWAV_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRWAV_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRWAV_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRWAV_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRWAV_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRWAV_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRWAV_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRWAV_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRWAV_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRWAV_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRWAV_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRWAV_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRWAV_ERROR;
-    #endif
-        default: return DRWAV_ERROR;
-    }
-}
-DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drwav_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drwav_result result = drwav_result_from_errno(errno);
-        if (result == DRWAV_SUCCESS) {
-            result = DRWAV_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRWAV_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRWAV_HAS_WFOPEN
-    #endif
-#endif
-DRWAV_PRIVATE drwav_result drwav_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-#if defined(DRWAV_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drwav_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drwav_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRWAV_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drwav_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drwav__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRWAV_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRWAV_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drwav__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRWAV_ERROR;
-    }
-#endif
-    return DRWAV_SUCCESS;
-}
-DRWAV_PRIVATE size_t drwav__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-DRWAV_PRIVATE size_t drwav__on_write_stdio(void* pUserData, const void* pData, size_t bytesToWrite)
-{
-    return fwrite(pData, 1, bytesToWrite, (FILE*)pUserData);
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_stdio(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drwav_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRWAV_API drwav_bool32 drwav_init_file(drwav* pWav, const char* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file__internal_FILE(drwav* pWav, FILE* pFile, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-    result = drwav_preinit(pWav, drwav__on_read_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    result = drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_file_ex(drwav* pWav, const char* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "rb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_w(drwav* pWav, const wchar_t* filename, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_ex_w(pWav, filename, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_ex_w(drwav* pWav, const wchar_t* filename, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"rb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file__internal_FILE(pWav, pFile, onChunk, pChunkUserData, flags, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal_FILE(drwav* pWav, FILE* pFile, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav_bool32 result;
-    result = drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_stdio, drwav__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    result = drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-    if (result != DRWAV_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write__internal(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_fopen(&pFile, filename, "wb") != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_file_write_w__internal(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    FILE* pFile;
-    if (drwav_wfopen(&pFile, filename, L"wb", pAllocationCallbacks) != DRWAV_SUCCESS) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write__internal_FILE(pWav, pFile, pFormat, totalSampleCount, isSequential, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write(drwav* pWav, const char* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames(drwav* pWav, const char* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write_sequential(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_file_write_w__internal(pWav, filename, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_file_write_sequential_pcm_frames_w(drwav* pWav, const wchar_t* filename, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_file_write_sequential_w(pWav, filename, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-#endif
-DRWAV_PRIVATE size_t drwav__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStream.dataSize >= pWav->memoryStream.currentReadPos);
-    bytesRemaining = pWav->memoryStream.dataSize - pWav->memoryStream.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRWAV_COPY_MEMORY(pBufferOut, pWav->memoryStream.data + pWav->memoryStream.currentReadPos, bytesToRead);
-        pWav->memoryStream.currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStream.currentReadPos + offset > pWav->memoryStream.dataSize) {
-                return DRWAV_FALSE;
-            }
-        } else {
-            if (pWav->memoryStream.currentReadPos < (size_t)-offset) {
-                return DRWAV_FALSE;
-            }
-        }
-        pWav->memoryStream.currentReadPos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStream.dataSize) {
-            pWav->memoryStream.currentReadPos = offset;
-        } else {
-            return DRWAV_FALSE;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_PRIVATE size_t drwav__on_write_memory(void* pUserData, const void* pDataIn, size_t bytesToWrite)
-{
-    drwav* pWav = (drwav*)pUserData;
-    size_t bytesRemaining;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(pWav->memoryStreamWrite.dataCapacity >= pWav->memoryStreamWrite.currentWritePos);
-    bytesRemaining = pWav->memoryStreamWrite.dataCapacity - pWav->memoryStreamWrite.currentWritePos;
-    if (bytesRemaining < bytesToWrite) {
-        void* pNewData;
-        size_t newDataCapacity = (pWav->memoryStreamWrite.dataCapacity == 0) ? 256 : pWav->memoryStreamWrite.dataCapacity * 2;
-        if ((newDataCapacity - pWav->memoryStreamWrite.currentWritePos) < bytesToWrite) {
-            newDataCapacity = pWav->memoryStreamWrite.currentWritePos + bytesToWrite;
-        }
-        pNewData = drwav__realloc_from_callbacks(*pWav->memoryStreamWrite.ppData, newDataCapacity, pWav->memoryStreamWrite.dataCapacity, &pWav->allocationCallbacks);
-        if (pNewData == NULL) {
-            return 0;
-        }
-        *pWav->memoryStreamWrite.ppData = pNewData;
-        pWav->memoryStreamWrite.dataCapacity = newDataCapacity;
-    }
-    DRWAV_COPY_MEMORY(((drwav_uint8*)(*pWav->memoryStreamWrite.ppData)) + pWav->memoryStreamWrite.currentWritePos, pDataIn, bytesToWrite);
-    pWav->memoryStreamWrite.currentWritePos += bytesToWrite;
-    if (pWav->memoryStreamWrite.dataSize < pWav->memoryStreamWrite.currentWritePos) {
-        pWav->memoryStreamWrite.dataSize = pWav->memoryStreamWrite.currentWritePos;
-    }
-    *pWav->memoryStreamWrite.pDataSize = pWav->memoryStreamWrite.dataSize;
-    return bytesToWrite;
-}
-DRWAV_PRIVATE drwav_bool32 drwav__on_seek_memory_write(void* pUserData, int offset, drwav_seek_origin origin)
-{
-    drwav* pWav = (drwav*)pUserData;
-    DRWAV_ASSERT(pWav != NULL);
-    if (origin == drwav_seek_origin_current) {
-        if (offset > 0) {
-            if (pWav->memoryStreamWrite.currentWritePos + offset > pWav->memoryStreamWrite.dataSize) {
-                offset = (int)(pWav->memoryStreamWrite.dataSize - pWav->memoryStreamWrite.currentWritePos);
-            }
-        } else {
-            if (pWav->memoryStreamWrite.currentWritePos < (size_t)-offset) {
-                offset = -(int)pWav->memoryStreamWrite.currentWritePos;
-            }
-        }
-        pWav->memoryStreamWrite.currentWritePos += offset;
-    } else {
-        if ((drwav_uint32)offset <= pWav->memoryStreamWrite.dataSize) {
-            pWav->memoryStreamWrite.currentWritePos = offset;
-        } else {
-            pWav->memoryStreamWrite.currentWritePos = pWav->memoryStreamWrite.dataSize;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_init_memory(drwav* pWav, const void* data, size_t dataSize, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_ex(pWav, data, dataSize, NULL, NULL, 0, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_ex(drwav* pWav, const void* data, size_t dataSize, drwav_chunk_proc onChunk, void* pChunkUserData, drwav_uint32 flags, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (data == NULL || dataSize == 0) {
-        return DRWAV_FALSE;
-    }
-    if (!drwav_preinit(pWav, drwav__on_read_memory, drwav__on_seek_memory, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    pWav->memoryStream.data = (const drwav_uint8*)data;
-    pWav->memoryStream.dataSize = dataSize;
-    pWav->memoryStream.currentReadPos = 0;
-    return drwav_init__internal(pWav, onChunk, pChunkUserData, flags);
-}
-DRWAV_PRIVATE drwav_bool32 drwav_init_memory_write__internal(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, drwav_bool32 isSequential, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppData == NULL || pDataSize == NULL) {
-        return DRWAV_FALSE;
-    }
-    *ppData = NULL;
-    *pDataSize = 0;
-    if (!drwav_preinit_write(pWav, pFormat, isSequential, drwav__on_write_memory, drwav__on_seek_memory_write, pWav, pAllocationCallbacks)) {
-        return DRWAV_FALSE;
-    }
-    pWav->memoryStreamWrite.ppData = ppData;
-    pWav->memoryStreamWrite.pDataSize = pDataSize;
-    pWav->memoryStreamWrite.dataSize = 0;
-    pWav->memoryStreamWrite.dataCapacity = 0;
-    pWav->memoryStreamWrite.currentWritePos = 0;
-    return drwav_init_write__internal(pWav, pFormat, totalSampleCount);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, 0, DRWAV_FALSE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalSampleCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    return drwav_init_memory_write__internal(pWav, ppData, pDataSize, pFormat, totalSampleCount, DRWAV_TRUE, pAllocationCallbacks);
-}
-DRWAV_API drwav_bool32 drwav_init_memory_write_sequential_pcm_frames(drwav* pWav, void** ppData, size_t* pDataSize, const drwav_data_format* pFormat, drwav_uint64 totalPCMFrameCount, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pFormat == NULL) {
-        return DRWAV_FALSE;
-    }
-    return drwav_init_memory_write_sequential(pWav, ppData, pDataSize, pFormat, totalPCMFrameCount*pFormat->channels, pAllocationCallbacks);
-}
-DRWAV_API drwav_result drwav_uninit(drwav* pWav)
-{
-    drwav_result result = DRWAV_SUCCESS;
-    if (pWav == NULL) {
-        return DRWAV_INVALID_ARGS;
-    }
-    if (pWav->onWrite != NULL) {
-        drwav_uint32 paddingSize = 0;
-        if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rf64) {
-            paddingSize = drwav__chunk_padding_size_riff(pWav->dataChunkDataSize);
-        } else {
-            paddingSize = drwav__chunk_padding_size_w64(pWav->dataChunkDataSize);
-        }
-        if (paddingSize > 0) {
-            drwav_uint64 paddingData = 0;
-            drwav__write(pWav, &paddingData, paddingSize);
-        }
-        if (pWav->onSeek && !pWav->isSequentialWrite) {
-            if (pWav->container == drwav_container_riff) {
-                if (pWav->onSeek(pWav->pUserData, 4, drwav_seek_origin_start)) {
-                    drwav_uint32 riffChunkSize = drwav__riff_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
-                    drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
-                    drwav__write_u32ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_w64) {
-                if (pWav->onSeek(pWav->pUserData, 16, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            } else if (pWav->container == drwav_container_rf64) {
-                int ds64BodyPos = 12 + 8;
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 0, drwav_seek_origin_start)) {
-                    drwav_uint64 riffChunkSize = drwav__riff_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, riffChunkSize);
-                }
-                if (pWav->onSeek(pWav->pUserData, ds64BodyPos + 8, drwav_seek_origin_start)) {
-                    drwav_uint64 dataChunkSize = drwav__data_chunk_size_rf64(pWav->dataChunkDataSize);
-                    drwav__write_u64ne_to_le(pWav, dataChunkSize);
-                }
-            }
-        }
-        if (pWav->isSequentialWrite) {
-            if (pWav->dataChunkDataSize != pWav->dataChunkDataSizeTargetWrite) {
-                result = DRWAV_INVALID_FILE;
-            }
-        }
-    }
-#ifndef DR_WAV_NO_STDIO
-    if (pWav->onRead == drwav__on_read_stdio || pWav->onWrite == drwav__on_write_stdio) {
-        fclose((FILE*)pWav->pUserData);
-    }
-#endif
-    return result;
-}
-DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOut)
-{
-    size_t bytesRead;
-    if (pWav == NULL || bytesToRead == 0) {
-        return 0;
-    }
-    if (bytesToRead > pWav->bytesRemaining) {
-        bytesToRead = (size_t)pWav->bytesRemaining;
-    }
-    if (pBufferOut != NULL) {
-        bytesRead = pWav->onRead(pWav->pUserData, pBufferOut, bytesToRead);
-    } else {
-        bytesRead = 0;
-        while (bytesRead < bytesToRead) {
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > 0x7FFFFFFF) {
-                bytesToSeek = 0x7FFFFFFF;
-            }
-            if (pWav->onSeek(pWav->pUserData, (int)bytesToSeek, drwav_seek_origin_current) == DRWAV_FALSE) {
-                break;
-            }
-            bytesRead += bytesToSeek;
-        }
-        while (bytesRead < bytesToRead) {
-            drwav_uint8 buffer[4096];
-            size_t bytesSeeked;
-            size_t bytesToSeek = (bytesToRead - bytesRead);
-            if (bytesToSeek > sizeof(buffer)) {
-                bytesToSeek = sizeof(buffer);
-            }
-            bytesSeeked = pWav->onRead(pWav->pUserData, buffer, bytesToSeek);
-            bytesRead += bytesSeeked;
-            if (bytesSeeked < bytesToSeek) {
-                break;
-            }
-        }
-    }
-    pWav->bytesRemaining -= bytesRead;
-    return bytesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint32 bytesPerFrame;
-    drwav_uint64 bytesToRead;
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        return 0;
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    bytesToRead = framesToRead * bytesPerFrame;
-    if (bytesToRead > DRWAV_SIZE_MAX) {
-        bytesToRead = (DRWAV_SIZE_MAX / bytesPerFrame) * bytesPerFrame;
-    }
-    if (bytesToRead == 0) {
-        return 0;
-    }
-    return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL) {
-        drwav__bswap_samples(pBufferOut, framesRead*pWav->channels, drwav_get_bytes_per_pcm_frame(pWav)/pWav->channels, pWav->translatedFormatTag);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_read_pcm_frames_le(pWav, framesToRead, pBufferOut);
-    } else {
-        return drwav_read_pcm_frames_be(pWav, framesToRead, pBufferOut);
-    }
-}
-DRWAV_PRIVATE drwav_bool32 drwav_seek_to_first_pcm_frame(drwav* pWav)
-{
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-    if (!pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos, drwav_seek_origin_start)) {
-        return DRWAV_FALSE;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        pWav->compressed.iCurrentPCMFrame = 0;
-        if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->msadpcm);
-        } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-            DRWAV_ZERO_OBJECT(&pWav->ima);
-        } else {
-            DRWAV_ASSERT(DRWAV_FALSE);
-        }
-    }
-    pWav->bytesRemaining = pWav->dataChunkDataSize;
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_seek_to_pcm_frame(drwav* pWav, drwav_uint64 targetFrameIndex)
-{
-    if (pWav == NULL || pWav->onSeek == NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pWav->onWrite != NULL) {
-        return DRWAV_FALSE;
-    }
-    if (pWav->totalPCMFrameCount == 0) {
-        return DRWAV_TRUE;
-    }
-    if (targetFrameIndex >= pWav->totalPCMFrameCount) {
-        targetFrameIndex  = pWav->totalPCMFrameCount - 1;
-    }
-    if (drwav__is_compressed_format_tag(pWav->translatedFormatTag)) {
-        if (targetFrameIndex < pWav->compressed.iCurrentPCMFrame) {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-        }
-        if (targetFrameIndex > pWav->compressed.iCurrentPCMFrame) {
-            drwav_uint64 offsetInFrames = targetFrameIndex - pWav->compressed.iCurrentPCMFrame;
-            drwav_int16 devnull[2048];
-            while (offsetInFrames > 0) {
-                drwav_uint64 framesRead = 0;
-                drwav_uint64 framesToRead = offsetInFrames;
-                if (framesToRead > drwav_countof(devnull)/pWav->channels) {
-                    framesToRead = drwav_countof(devnull)/pWav->channels;
-                }
-                if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, devnull);
-                } else if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-                    framesRead = drwav_read_pcm_frames_s16__ima(pWav, framesToRead, devnull);
-                } else {
-                    DRWAV_ASSERT(DRWAV_FALSE);
-                }
-                if (framesRead != framesToRead) {
-                    return DRWAV_FALSE;
-                }
-                offsetInFrames -= framesRead;
-            }
-        }
-    } else {
-        drwav_uint64 totalSizeInBytes;
-        drwav_uint64 currentBytePos;
-        drwav_uint64 targetBytePos;
-        drwav_uint64 offset;
-        totalSizeInBytes = pWav->totalPCMFrameCount * drwav_get_bytes_per_pcm_frame(pWav);
-        DRWAV_ASSERT(totalSizeInBytes >= pWav->bytesRemaining);
-        currentBytePos = totalSizeInBytes - pWav->bytesRemaining;
-        targetBytePos  = targetFrameIndex * drwav_get_bytes_per_pcm_frame(pWav);
-        if (currentBytePos < targetBytePos) {
-            offset = (targetBytePos - currentBytePos);
-        } else {
-            if (!drwav_seek_to_first_pcm_frame(pWav)) {
-                return DRWAV_FALSE;
-            }
-            offset = targetBytePos;
-        }
-        while (offset > 0) {
-            int offset32 = ((offset > INT_MAX) ? INT_MAX : (int)offset);
-            if (!pWav->onSeek(pWav->pUserData, offset32, drwav_seek_origin_current)) {
-                return DRWAV_FALSE;
-            }
-            pWav->bytesRemaining -= offset32;
-            offset -= offset32;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API size_t drwav_write_raw(drwav* pWav, size_t bytesToWrite, const void* pData)
-{
-    size_t bytesWritten;
-    if (pWav == NULL || bytesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesWritten = pWav->onWrite(pWav->pUserData, pData, bytesToWrite);
-    pWav->dataChunkDataSize += bytesWritten;
-    return bytesWritten;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_le(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    const drwav_uint8* pRunningData;
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-    while (bytesToWrite > 0) {
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, pRunningData);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames_be(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    drwav_uint64 bytesToWrite;
-    drwav_uint64 bytesWritten;
-    drwav_uint32 bytesPerSample;
-    const drwav_uint8* pRunningData;
-    if (pWav == NULL || framesToWrite == 0 || pData == NULL) {
-        return 0;
-    }
-    bytesToWrite = ((framesToWrite * pWav->channels * pWav->bitsPerSample) / 8);
-    if (bytesToWrite > DRWAV_SIZE_MAX) {
-        return 0;
-    }
-    bytesWritten = 0;
-    pRunningData = (const drwav_uint8*)pData;
-    bytesPerSample = drwav_get_bytes_per_pcm_frame(pWav) / pWav->channels;
-    while (bytesToWrite > 0) {
-        drwav_uint8 temp[4096];
-        drwav_uint32 sampleCount;
-        size_t bytesJustWritten;
-        drwav_uint64 bytesToWriteThisIteration;
-        bytesToWriteThisIteration = bytesToWrite;
-        DRWAV_ASSERT(bytesToWriteThisIteration <= DRWAV_SIZE_MAX);
-        sampleCount = sizeof(temp)/bytesPerSample;
-        if (bytesToWriteThisIteration > ((drwav_uint64)sampleCount)*bytesPerSample) {
-            bytesToWriteThisIteration = ((drwav_uint64)sampleCount)*bytesPerSample;
-        }
-        DRWAV_COPY_MEMORY(temp, pRunningData, (size_t)bytesToWriteThisIteration);
-        drwav__bswap_samples(temp, sampleCount, bytesPerSample, pWav->translatedFormatTag);
-        bytesJustWritten = drwav_write_raw(pWav, (size_t)bytesToWriteThisIteration, temp);
-        if (bytesJustWritten == 0) {
-            break;
-        }
-        bytesToWrite -= bytesJustWritten;
-        bytesWritten += bytesJustWritten;
-        pRunningData += bytesJustWritten;
-    }
-    return (bytesWritten * 8) / pWav->bitsPerSample / pWav->channels;
-}
-DRWAV_API drwav_uint64 drwav_write_pcm_frames(drwav* pWav, drwav_uint64 framesToWrite, const void* pData)
-{
-    if (drwav__is_little_endian()) {
-        return drwav_write_pcm_frames_le(pWav, framesToWrite, pData);
-    } else {
-        return drwav_write_pcm_frames_be(pWav, framesToWrite, pData);
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0);
-        if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                drwav_uint8 header[7];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                pWav->msadpcm.predictor[0]     = header[0];
-                pWav->msadpcm.delta[0]         = drwav_bytes_to_s16(header + 1);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 3);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 5);
-                pWav->msadpcm.cachedFrames[2]  = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[3]  = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            } else {
-                drwav_uint8 header[14];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                pWav->msadpcm.predictor[0] = header[0];
-                pWav->msadpcm.predictor[1] = header[1];
-                pWav->msadpcm.delta[0] = drwav_bytes_to_s16(header + 2);
-                pWav->msadpcm.delta[1] = drwav_bytes_to_s16(header + 4);
-                pWav->msadpcm.prevFrames[0][1] = (drwav_int32)drwav_bytes_to_s16(header + 6);
-                pWav->msadpcm.prevFrames[1][1] = (drwav_int32)drwav_bytes_to_s16(header + 8);
-                pWav->msadpcm.prevFrames[0][0] = (drwav_int32)drwav_bytes_to_s16(header + 10);
-                pWav->msadpcm.prevFrames[1][0] = (drwav_int32)drwav_bytes_to_s16(header + 12);
-                pWav->msadpcm.cachedFrames[0] = pWav->msadpcm.prevFrames[0][0];
-                pWav->msadpcm.cachedFrames[1] = pWav->msadpcm.prevFrames[1][0];
-                pWav->msadpcm.cachedFrames[2] = pWav->msadpcm.prevFrames[0][1];
-                pWav->msadpcm.cachedFrames[3] = pWav->msadpcm.prevFrames[1][1];
-                pWav->msadpcm.cachedFrameCount = 2;
-            }
-        }
-        while (framesToRead > 0 && pWav->msadpcm.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample = 0;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->msadpcm.cachedFrames[(drwav_countof(pWav->msadpcm.cachedFrames) - (pWav->msadpcm.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->msadpcm.cachedFrameCount -= 1;
-        }
-        if (framesToRead == 0) {
-            break;
-        }
-        if (pWav->msadpcm.cachedFrameCount == 0) {
-            if (pWav->msadpcm.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                static drwav_int32 adaptationTable[] = {
-                    230, 230, 230, 230, 307, 409, 512, 614,
-                    768, 614, 512, 409, 307, 230, 230, 230
-                };
-                static drwav_int32 coeff1Table[] = { 256, 512, 0, 192, 240, 460,  392 };
-                static drwav_int32 coeff2Table[] = { 0,  -256, 0, 64,  0,  -208, -232 };
-                drwav_uint8 nibbles;
-                drwav_int32 nibble0;
-                drwav_int32 nibble1;
-                if (pWav->onRead(pWav->pUserData, &nibbles, 1) != 1) {
-                    return totalFramesRead;
-                }
-                pWav->msadpcm.bytesRemainingInBlock -= 1;
-                nibble0 = ((nibbles & 0xF0) >> 4); if ((nibbles & 0x80)) { nibble0 |= 0xFFFFFFF0UL; }
-                nibble1 = ((nibbles & 0x0F) >> 0); if ((nibbles & 0x08)) { nibble1 |= 0xFFFFFFF0UL; }
-                if (pWav->channels == 1) {
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-                    newSample1  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[0];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample1;
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 2;
-                } else {
-                    drwav_int32 newSample0;
-                    drwav_int32 newSample1;
-                    newSample0  = ((pWav->msadpcm.prevFrames[0][1] * coeff1Table[pWav->msadpcm.predictor[0]]) + (pWav->msadpcm.prevFrames[0][0] * coeff2Table[pWav->msadpcm.predictor[0]])) >> 8;
-                    newSample0 += nibble0 * pWav->msadpcm.delta[0];
-                    newSample0  = drwav_clamp(newSample0, -32768, 32767);
-                    pWav->msadpcm.delta[0] = (adaptationTable[((nibbles & 0xF0) >> 4)] * pWav->msadpcm.delta[0]) >> 8;
-                    if (pWav->msadpcm.delta[0] < 16) {
-                        pWav->msadpcm.delta[0] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[0][0] = pWav->msadpcm.prevFrames[0][1];
-                    pWav->msadpcm.prevFrames[0][1] = newSample0;
-                    newSample1  = ((pWav->msadpcm.prevFrames[1][1] * coeff1Table[pWav->msadpcm.predictor[1]]) + (pWav->msadpcm.prevFrames[1][0] * coeff2Table[pWav->msadpcm.predictor[1]])) >> 8;
-                    newSample1 += nibble1 * pWav->msadpcm.delta[1];
-                    newSample1  = drwav_clamp(newSample1, -32768, 32767);
-                    pWav->msadpcm.delta[1] = (adaptationTable[((nibbles & 0x0F) >> 0)] * pWav->msadpcm.delta[1]) >> 8;
-                    if (pWav->msadpcm.delta[1] < 16) {
-                        pWav->msadpcm.delta[1] = 16;
-                    }
-                    pWav->msadpcm.prevFrames[1][0] = pWav->msadpcm.prevFrames[1][1];
-                    pWav->msadpcm.prevFrames[1][1] = newSample1;
-                    pWav->msadpcm.cachedFrames[2] = newSample0;
-                    pWav->msadpcm.cachedFrames[3] = newSample1;
-                    pWav->msadpcm.cachedFrameCount = 1;
-                }
-            }
-        }
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_uint32 iChannel;
-    static drwav_int32 indexTable[16] = {
-        -1, -1, -1, -1, 2, 4, 6, 8,
-        -1, -1, -1, -1, 2, 4, 6, 8
-    };
-    static drwav_int32 stepTable[89] = {
-        7,     8,     9,     10,    11,    12,    13,    14,    16,    17,
-        19,    21,    23,    25,    28,    31,    34,    37,    41,    45,
-        50,    55,    60,    66,    73,    80,    88,    97,    107,   118,
-        130,   143,   157,   173,   190,   209,   230,   253,   279,   307,
-        337,   371,   408,   449,   494,   544,   598,   658,   724,   796,
-        876,   963,   1060,  1166,  1282,  1411,  1552,  1707,  1878,  2066,
-        2272,  2499,  2749,  3024,  3327,  3660,  4026,  4428,  4871,  5358,
-        5894,  6484,  7132,  7845,  8630,  9493,  10442, 11487, 12635, 13899,
-        15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-    };
-    DRWAV_ASSERT(pWav != NULL);
-    DRWAV_ASSERT(framesToRead > 0);
-    while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-        DRWAV_ASSERT(framesToRead > 0);
-        if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
-            if (pWav->channels == 1) {
-                drwav_uint8 header[4];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                if (header[2] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead;
-                }
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrameCount = 1;
-            } else {
-                drwav_uint8 header[8];
-                if (pWav->onRead(pWav->pUserData, header, sizeof(header)) != sizeof(header)) {
-                    return totalFramesRead;
-                }
-                pWav->ima.bytesRemainingInBlock = pWav->fmt.blockAlign - sizeof(header);
-                if (header[2] >= drwav_countof(stepTable) || header[6] >= drwav_countof(stepTable)) {
-                    pWav->onSeek(pWav->pUserData, pWav->ima.bytesRemainingInBlock, drwav_seek_origin_current);
-                    pWav->ima.bytesRemainingInBlock = 0;
-                    return totalFramesRead;
-                }
-                pWav->ima.predictor[0] = drwav_bytes_to_s16(header + 0);
-                pWav->ima.stepIndex[0] = header[2];
-                pWav->ima.predictor[1] = drwav_bytes_to_s16(header + 4);
-                pWav->ima.stepIndex[1] = header[6];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 2] = pWav->ima.predictor[0];
-                pWav->ima.cachedFrames[drwav_countof(pWav->ima.cachedFrames) - 1] = pWav->ima.predictor[1];
-                pWav->ima.cachedFrameCount = 1;
-            }
-        }
-        while (framesToRead > 0 && pWav->ima.cachedFrameCount > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
-            if (pBufferOut != NULL) {
-                drwav_uint32 iSample;
-                for (iSample = 0; iSample < pWav->channels; iSample += 1) {
-                    pBufferOut[iSample] = (drwav_int16)pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + iSample];
-                }
-                pBufferOut += pWav->channels;
-            }
-            framesToRead    -= 1;
-            totalFramesRead += 1;
-            pWav->compressed.iCurrentPCMFrame += 1;
-            pWav->ima.cachedFrameCount -= 1;
-        }
-        if (framesToRead == 0) {
-            break;
-        }
-        if (pWav->ima.cachedFrameCount == 0) {
-            if (pWav->ima.bytesRemainingInBlock == 0) {
-                continue;
-            } else {
-                pWav->ima.cachedFrameCount = 8;
-                for (iChannel = 0; iChannel < pWav->channels; ++iChannel) {
-                    drwav_uint32 iByte;
-                    drwav_uint8 nibbles[4];
-                    if (pWav->onRead(pWav->pUserData, &nibbles, 4) != 4) {
-                        pWav->ima.cachedFrameCount = 0;
-                        return totalFramesRead;
-                    }
-                    pWav->ima.bytesRemainingInBlock -= 4;
-                    for (iByte = 0; iByte < 4; ++iByte) {
-                        drwav_uint8 nibble0 = ((nibbles[iByte] & 0x0F) >> 0);
-                        drwav_uint8 nibble1 = ((nibbles[iByte] & 0xF0) >> 4);
-                        drwav_int32 step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        drwav_int32 predictor = pWav->ima.predictor[iChannel];
-                        drwav_int32      diff  = step >> 3;
-                        if (nibble0 & 1) diff += step >> 2;
-                        if (nibble0 & 2) diff += step >> 1;
-                        if (nibble0 & 4) diff += step;
-                        if (nibble0 & 8) diff  = -diff;
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble0], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+0)*pWav->channels + iChannel] = predictor;
-                        step      = stepTable[pWav->ima.stepIndex[iChannel]];
-                        predictor = pWav->ima.predictor[iChannel];
-                                         diff  = step >> 3;
-                        if (nibble1 & 1) diff += step >> 2;
-                        if (nibble1 & 2) diff += step >> 1;
-                        if (nibble1 & 4) diff += step;
-                        if (nibble1 & 8) diff  = -diff;
-                        predictor = drwav_clamp(predictor + diff, -32768, 32767);
-                        pWav->ima.predictor[iChannel] = predictor;
-                        pWav->ima.stepIndex[iChannel] = drwav_clamp(pWav->ima.stepIndex[iChannel] + indexTable[nibble1], 0, (drwav_int32)drwav_countof(stepTable)-1);
-                        pWav->ima.cachedFrames[(drwav_countof(pWav->ima.cachedFrames) - (pWav->ima.cachedFrameCount*pWav->channels)) + (iByte*2+1)*pWav->channels + iChannel] = predictor;
-                    }
-                }
-            }
-        }
-    }
-    return totalFramesRead;
-}
-#ifndef DR_WAV_NO_CONVERSION_API
-static unsigned short g_drwavAlawTable[256] = {
-    0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80, 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
-    0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0, 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
-    0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600, 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
-    0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00, 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
-    0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8, 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
-    0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8, 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
-    0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60, 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
-    0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0, 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
-    0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280, 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
-    0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940, 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
-    0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00, 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
-    0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500, 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
-    0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128, 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
-    0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028, 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
-    0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0, 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
-    0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250, 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
-};
-static unsigned short g_drwavMulawTable[256] = {
-    0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84, 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
-    0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84, 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
-    0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804, 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
-    0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444, 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
-    0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64, 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
-    0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74, 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
-    0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC, 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
-    0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0, 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
-    0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C, 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
-    0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C, 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
-    0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC, 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
-    0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC, 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
-    0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C, 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
-    0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C, 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
-    0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104, 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
-    0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040, 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
-};
-static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavAlawTable[sampleIn];
-}
-static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
-{
-    return (short)g_drwavMulawTable[sampleIn];
-}
-DRWAV_PRIVATE void drwav__pcm_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int16*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s16(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_s16(pOut, (const drwav_int32*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (drwav_int16)((drwav_int64)sample >> 48);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s16(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s16(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if ((pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 16) || pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_s16(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(drwav_int16) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int16) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s16__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s16__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s16__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s16__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s16__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s16__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16le(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s16be(drwav* pWav, drwav_uint64 framesToRead, drwav_int16* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s16(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x << 8;
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_s24_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = ((int)(((unsigned int)(((const drwav_uint8*)pIn)[i*3+0]) << 8) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+1]) << 16) | ((unsigned int)(((const drwav_uint8*)pIn)[i*3+2])) << 24)) >> 8;
-        r = x >> 8;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_s32_to_s16(drwav_int16* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        int x = pIn[i];
-        r = x >> 16;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_f32_to_s16(drwav_int16* pOut, const float* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        float c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5f);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_f64_to_s16(drwav_int16* pOut, const double* pIn, size_t sampleCount)
-{
-    int r;
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        double x = pIn[i];
-        double c;
-        c = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        c = c + 1;
-        r = (int)(c * 32767.5);
-        r = r - 32768;
-        pOut[i] = (short)r;
-    }
-}
-DRWAV_API void drwav_alaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__alaw_to_s16(pIn[i]);
-    }
-}
-DRWAV_API void drwav_mulaw_to_s16(drwav_int16* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    for (i = 0; i < sampleCount; ++i) {
-        pOut[i] = drwav__mulaw_to_s16(pIn[i]);
-    }
-}
-DRWAV_PRIVATE void drwav__pcm_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        drwav_s16_to_f32(pOut, (const drwav_int16*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_f32(pOut, pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        drwav_s32_to_f32(pOut, (const drwav_int32*)pIn, sampleCount);
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (float)((drwav_int64)sample / 9223372036854775807.0);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        unsigned int i;
-        for (i = 0; i < sampleCount; ++i) {
-            *pOut++ = ((const float*)pIn)[i];
-        }
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_f32(pOut, (const double*)pIn, sampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, sampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__pcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_f32(pBufferOut, sampleData, (size_t)framesRead*pWav->channels, bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ima(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_f32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__ieee(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__alaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_f32__mulaw(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_f32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(float) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(float) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_f32__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_f32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_f32__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_f32__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_f32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_f32__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32le(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_f32be(drwav* pWav, drwav_uint64 framesToRead, float* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_f32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_f32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-#ifdef DR_WAV_LIBSNDFILE_COMPAT
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (pIn[i] / 256.0f) * 2 - 1;
-    }
-#else
-    for (i = 0; i < sampleCount; ++i) {
-        float x = pIn[i];
-        x = x * 0.00784313725490196078f;
-        x = x - 1;
-        *pOut++ = x;
-    }
-#endif
-}
-DRWAV_API void drwav_s16_to_f32(float* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] * 0.000030517578125f;
-    }
-}
-DRWAV_API void drwav_s24_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        double x;
-        drwav_uint32 a = ((drwav_uint32)(pIn[i*3+0]) <<  8);
-        drwav_uint32 b = ((drwav_uint32)(pIn[i*3+1]) << 16);
-        drwav_uint32 c = ((drwav_uint32)(pIn[i*3+2]) << 24);
-        x = (double)((drwav_int32)(a | b | c) >> 8);
-        *pOut++ = (float)(x * 0.00000011920928955078125);
-    }
-}
-DRWAV_API void drwav_s32_to_f32(float* pOut, const drwav_int32* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)(pIn[i] / 2147483648.0);
-    }
-}
-DRWAV_API void drwav_f64_to_f32(float* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (float)pIn[i];
-    }
-}
-DRWAV_API void drwav_alaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__alaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-DRWAV_API void drwav_mulaw_to_f32(float* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = drwav__mulaw_to_s16(pIn[i]) / 32768.0f;
-    }
-}
-DRWAV_PRIVATE void drwav__pcm_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    unsigned int i;
-    if (bytesPerSample == 1) {
-        drwav_u8_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 2) {
-        drwav_s16_to_s32(pOut, (const drwav_int16*)pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 3) {
-        drwav_s24_to_s32(pOut, pIn, totalSampleCount);
-        return;
-    }
-    if (bytesPerSample == 4) {
-        for (i = 0; i < totalSampleCount; ++i) {
-           *pOut++ = ((const drwav_int32*)pIn)[i];
-        }
-        return;
-    }
-    if (bytesPerSample > 8) {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-    for (i = 0; i < totalSampleCount; ++i) {
-        drwav_uint64 sample = 0;
-        unsigned int shift  = (8 - bytesPerSample) * 8;
-        unsigned int j;
-        for (j = 0; j < bytesPerSample; j += 1) {
-            DRWAV_ASSERT(j < 8);
-            sample |= (drwav_uint64)(pIn[j]) << shift;
-            shift  += 8;
-        }
-        pIn += j;
-        *pOut++ = (drwav_int32)((drwav_int64)sample >> 32);
-    }
-}
-DRWAV_PRIVATE void drwav__ieee_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t totalSampleCount, unsigned int bytesPerSample)
-{
-    if (bytesPerSample == 4) {
-        drwav_f32_to_s32(pOut, (const float*)pIn, totalSampleCount);
-        return;
-    } else if (bytesPerSample == 8) {
-        drwav_f64_to_s32(pOut, (const double*)pIn, totalSampleCount);
-        return;
-    } else {
-        DRWAV_ZERO_MEMORY(pOut, totalSampleCount * sizeof(*pOut));
-        return;
-    }
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__pcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame;
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM && pWav->bitsPerSample == 32) {
-        return drwav_read_pcm_frames(pWav, framesToRead, pBufferOut);
-    }
-    bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__pcm_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__msadpcm(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ima(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead = 0;
-    drwav_int16 samples16[2048];
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames_s16(pWav, drwav_min(framesToRead, drwav_countof(samples16)/pWav->channels), samples16);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_s16_to_s32(pBufferOut, samples16, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__ieee(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav__ieee_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels), bytesPerFrame/pWav->channels);
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__alaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_alaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s32__mulaw(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 totalFramesRead;
-    drwav_uint8 sampleData[4096];
-    drwav_uint32 bytesPerFrame = drwav_get_bytes_per_pcm_frame(pWav);
-    if (bytesPerFrame == 0) {
-        return 0;
-    }
-    totalFramesRead = 0;
-    while (framesToRead > 0) {
-        drwav_uint64 framesRead = drwav_read_pcm_frames(pWav, drwav_min(framesToRead, sizeof(sampleData)/bytesPerFrame), sampleData);
-        if (framesRead == 0) {
-            break;
-        }
-        drwav_mulaw_to_s32(pBufferOut, sampleData, (size_t)(framesRead*pWav->channels));
-        pBufferOut      += framesRead*pWav->channels;
-        framesToRead    -= framesRead;
-        totalFramesRead += framesRead;
-    }
-    return totalFramesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    if (pWav == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drwav_read_pcm_frames(pWav, framesToRead, NULL);
-    }
-    if (framesToRead * pWav->channels * sizeof(drwav_int32) > DRWAV_SIZE_MAX) {
-        framesToRead = DRWAV_SIZE_MAX / sizeof(drwav_int32) / pWav->channels;
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_PCM) {
-        return drwav_read_pcm_frames_s32__pcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ADPCM) {
-        return drwav_read_pcm_frames_s32__msadpcm(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_IEEE_FLOAT) {
-        return drwav_read_pcm_frames_s32__ieee(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_ALAW) {
-        return drwav_read_pcm_frames_s32__alaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_MULAW) {
-        return drwav_read_pcm_frames_s32__mulaw(pWav, framesToRead, pBufferOut);
-    }
-    if (pWav->translatedFormatTag == DR_WAVE_FORMAT_DVI_ADPCM) {
-        return drwav_read_pcm_frames_s32__ima(pWav, framesToRead, pBufferOut);
-    }
-    return 0;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32le(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_FALSE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API drwav_uint64 drwav_read_pcm_frames_s32be(drwav* pWav, drwav_uint64 framesToRead, drwav_int32* pBufferOut)
-{
-    drwav_uint64 framesRead = drwav_read_pcm_frames_s32(pWav, framesToRead, pBufferOut);
-    if (pBufferOut != NULL && drwav__is_little_endian() == DRWAV_TRUE) {
-        drwav__bswap_samples_s32(pBufferOut, framesRead*pWav->channels);
-    }
-    return framesRead;
-}
-DRWAV_API void drwav_u8_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((int)pIn[i] - 128) << 24;
-    }
-}
-DRWAV_API void drwav_s16_to_s32(drwav_int32* pOut, const drwav_int16* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = pIn[i] << 16;
-    }
-}
-DRWAV_API void drwav_s24_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        unsigned int s0 = pIn[i*3 + 0];
-        unsigned int s1 = pIn[i*3 + 1];
-        unsigned int s2 = pIn[i*3 + 2];
-        drwav_int32 sample32 = (drwav_int32)((s0 << 8) | (s1 << 16) | (s2 << 24));
-        *pOut++ = sample32;
-    }
-}
-DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-DRWAV_API void drwav_f64_to_s32(drwav_int32* pOut, const double* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
-    }
-}
-DRWAV_API void drwav_alaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i = 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__alaw_to_s16(pIn[i])) << 16;
-    }
-}
-DRWAV_API void drwav_mulaw_to_s32(drwav_int32* pOut, const drwav_uint8* pIn, size_t sampleCount)
-{
-    size_t i;
-    if (pOut == NULL || pIn == NULL) {
-        return;
-    }
-    for (i= 0; i < sampleCount; ++i) {
-        *pOut++ = ((drwav_int32)drwav__mulaw_to_s16(pIn[i])) << 16;
-    }
-}
-DRWAV_PRIVATE drwav_int16* drwav__read_pcm_frames_and_close_s16(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int16* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int16);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (drwav_int16*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_s16(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_PRIVATE float* drwav__read_pcm_frames_and_close_f32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    float* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(float);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (float*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_f32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_PRIVATE drwav_int32* drwav__read_pcm_frames_and_close_s32(drwav* pWav, unsigned int* channels, unsigned int* sampleRate, drwav_uint64* totalFrameCount)
-{
-    drwav_uint64 sampleDataSize;
-    drwav_int32* pSampleData;
-    drwav_uint64 framesRead;
-    DRWAV_ASSERT(pWav != NULL);
-    sampleDataSize = pWav->totalPCMFrameCount * pWav->channels * sizeof(drwav_int32);
-    if (sampleDataSize > DRWAV_SIZE_MAX) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    pSampleData = (drwav_int32*)drwav__malloc_from_callbacks((size_t)sampleDataSize, &pWav->allocationCallbacks);
-    if (pSampleData == NULL) {
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    framesRead = drwav_read_pcm_frames_s32(pWav, (size_t)pWav->totalPCMFrameCount, pSampleData);
-    if (framesRead != pWav->totalPCMFrameCount) {
-        drwav__free_from_callbacks(pSampleData, &pWav->allocationCallbacks);
-        drwav_uninit(pWav);
-        return NULL;
-    }
-    drwav_uninit(pWav);
-    if (sampleRate) {
-        *sampleRate = pWav->sampleRate;
-    }
-    if (channels) {
-        *channels = pWav->channels;
-    }
-    if (totalFrameCount) {
-        *totalFrameCount = pWav->totalPCMFrameCount;
-    }
-    return pSampleData;
-}
-DRWAV_API drwav_int16* drwav_open_and_read_pcm_frames_s16(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_and_read_pcm_frames_f32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_and_read_pcm_frames_s32(drwav_read_proc onRead, drwav_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init(&wav, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#ifndef DR_WAV_NO_STDIO
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int16* drwav_open_file_and_read_pcm_frames_s16_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_file_and_read_pcm_frames_f32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_file_and_read_pcm_frames_s32_w(const wchar_t* filename, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_file_w(&wav, filename, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-DRWAV_API drwav_int16* drwav_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s16(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API float* drwav_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_f32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-DRWAV_API drwav_int32* drwav_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channelsOut, unsigned int* sampleRateOut, drwav_uint64* totalFrameCountOut, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    drwav wav;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalFrameCountOut) {
-        *totalFrameCountOut = 0;
-    }
-    if (!drwav_init_memory(&wav, data, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drwav__read_pcm_frames_and_close_s32(&wav, channelsOut, sampleRateOut, totalFrameCountOut);
-}
-#endif
-DRWAV_API void drwav_free(void* p, const drwav_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drwav__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drwav__free_default(p, NULL);
-    }
-}
-DRWAV_API drwav_uint16 drwav_bytes_to_u16(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8);
-}
-DRWAV_API drwav_int16 drwav_bytes_to_s16(const drwav_uint8* data)
-{
-    return (short)drwav_bytes_to_u16(data);
-}
-DRWAV_API drwav_uint32 drwav_bytes_to_u32(const drwav_uint8* data)
-{
-    return (data[0] << 0) | (data[1] << 8) | (data[2] << 16) | (data[3] << 24);
-}
-DRWAV_API drwav_int32 drwav_bytes_to_s32(const drwav_uint8* data)
-{
-    return (drwav_int32)drwav_bytes_to_u32(data);
-}
-DRWAV_API drwav_uint64 drwav_bytes_to_u64(const drwav_uint8* data)
-{
-    return
-        ((drwav_uint64)data[0] <<  0) | ((drwav_uint64)data[1] <<  8) | ((drwav_uint64)data[2] << 16) | ((drwav_uint64)data[3] << 24) |
-        ((drwav_uint64)data[4] << 32) | ((drwav_uint64)data[5] << 40) | ((drwav_uint64)data[6] << 48) | ((drwav_uint64)data[7] << 56);
-}
-DRWAV_API drwav_int64 drwav_bytes_to_s64(const drwav_uint8* data)
-{
-    return (drwav_int64)drwav_bytes_to_u64(data);
-}
-DRWAV_API drwav_bool32 drwav_guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
-{
-    int i;
-    for (i = 0; i < 16; i += 1) {
-        if (a[i] != b[i]) {
-            return DRWAV_FALSE;
-        }
-    }
-    return DRWAV_TRUE;
-}
-DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
-{
-    return
-        a[0] == b[0] &&
-        a[1] == b[1] &&
-        a[2] == b[2] &&
-        a[3] == b[3];
-}
-#endif
-/* dr_wav_c end */
-#endif  /* DRWAV_IMPLEMENTATION */
-#endif  /* MA_NO_WAV */
-
-#if !defined(MA_NO_FLAC) && !defined(MA_NO_DECODING)
-#if !defined(DR_FLAC_IMPLEMENTATION) && !defined(DRFLAC_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_flac_c begin */
-#ifndef dr_flac_c
-#define dr_flac_c
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic push
-    #if __GNUC__ >= 7
-    #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-    #endif
-#endif
-#ifdef __linux__
-    #ifndef _BSD_SOURCE
-        #define _BSD_SOURCE
-    #endif
-    #ifndef _DEFAULT_SOURCE
-        #define _DEFAULT_SOURCE
-    #endif
-    #ifndef __USE_BSD
-        #define __USE_BSD
-    #endif
-    #include <endian.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#ifdef _MSC_VER
-    #define DRFLAC_INLINE __forceinline
-#elif defined(__GNUC__)
-    #if defined(__STRICT_ANSI__)
-        #define DRFLAC_INLINE __inline__ __attribute__((always_inline))
-    #else
-        #define DRFLAC_INLINE inline __attribute__((always_inline))
-    #endif
-#elif defined(__WATCOMC__)
-    #define DRFLAC_INLINE __inline
-#else
-    #define DRFLAC_INLINE
-#endif
-#if defined(__x86_64__) || defined(_M_X64)
-    #define DRFLAC_X64
-#elif defined(__i386) || defined(_M_IX86)
-    #define DRFLAC_X86
-#elif defined(__arm__) || defined(_M_ARM) || defined(_M_ARM64)
-    #define DRFLAC_ARM
-#endif
-#if !defined(DR_FLAC_NO_SIMD)
-    #if defined(DRFLAC_X64) || defined(DRFLAC_X86)
-        #if defined(_MSC_VER) && !defined(__clang__)
-            #if _MSC_VER >= 1400 && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if _MSC_VER >= 1600 && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
-            #if defined(__SSE2__) && !defined(DRFLAC_NO_SSE2)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if defined(__SSE4_1__) && !defined(DRFLAC_NO_SSE41)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_SSE2) && !defined(DRFLAC_NO_SSE2) && __has_include(<emmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE2
-            #endif
-            #if !defined(DRFLAC_SUPPORT_SSE41) && !defined(DRFLAC_NO_SSE41) && __has_include(<smmintrin.h>)
-                #define DRFLAC_SUPPORT_SSE41
-            #endif
-        #endif
-        #if defined(DRFLAC_SUPPORT_SSE41)
-            #include <smmintrin.h>
-        #elif defined(DRFLAC_SUPPORT_SSE2)
-            #include <emmintrin.h>
-        #endif
-    #endif
-    #if defined(DRFLAC_ARM)
-        #if !defined(DRFLAC_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            #define DRFLAC_SUPPORT_NEON
-        #endif
-        #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include)
-            #if !defined(DRFLAC_SUPPORT_NEON) && !defined(DRFLAC_NO_NEON) && __has_include(<arm_neon.h>)
-                #define DRFLAC_SUPPORT_NEON
-            #endif
-        #endif
-        #if defined(DRFLAC_SUPPORT_NEON)
-            #include <arm_neon.h>
-        #endif
-    #endif
-#endif
-#if !defined(DR_FLAC_NO_SIMD) && (defined(DRFLAC_X86) || defined(DRFLAC_X64))
-    #if defined(_MSC_VER) && !defined(__clang__)
-        #if _MSC_VER >= 1400
-            #include <intrin.h>
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                __cpuid(info, fid);
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #else
-        #if defined(__GNUC__) || defined(__clang__)
-            static void drflac__cpuid(int info[4], int fid)
-            {
-                #if defined(DRFLAC_X86) && defined(__PIC__)
-                    __asm__ __volatile__ (
-                        "xchg{l} {%%}ebx, %k1;"
-                        "cpuid;"
-                        "xchg{l} {%%}ebx, %k1;"
-                        : "=a"(info[0]), "=&r"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #else
-                    __asm__ __volatile__ (
-                        "cpuid" : "=a"(info[0]), "=b"(info[1]), "=c"(info[2]), "=d"(info[3]) : "a"(fid), "c"(0)
-                    );
-                #endif
-            }
-        #else
-            #define DRFLAC_NO_CPUID
-        #endif
-    #endif
-#else
-    #define DRFLAC_NO_CPUID
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse2(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE2)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__)
-            return DRFLAC_TRUE;
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[3] & (1 << 26)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-static DRFLAC_INLINE drflac_bool32 drflac_has_sse41(void)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    #if (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(DRFLAC_NO_SSE41)
-        #if defined(DRFLAC_X64)
-            return DRFLAC_TRUE;
-        #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE4_1__)
-            return DRFLAC_TRUE;
-        #else
-            #if defined(DRFLAC_NO_CPUID)
-                return DRFLAC_FALSE;
-            #else
-                int info[4];
-                drflac__cpuid(info, 1);
-                return (info[2] & (1 << 19)) != 0;
-            #endif
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-#if defined(_MSC_VER) && _MSC_VER >= 1500 && (defined(DRFLAC_X86) || defined(DRFLAC_X64)) && !defined(__clang__)
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
-    #define DRFLAC_HAS_LZCNT_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_clzll) || __has_builtin(__builtin_clzl)
-            #define DRFLAC_HAS_LZCNT_INTRINSIC
-        #endif
-    #endif
-#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(__clang__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-#elif defined(__clang__)
-    #if defined(__has_builtin)
-        #if __has_builtin(__builtin_bswap16)
-            #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap32)
-            #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #endif
-        #if __has_builtin(__builtin_bswap64)
-            #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-        #endif
-    #endif
-#elif defined(__GNUC__)
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-        #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-        #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #endif
-    #if ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-        #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #endif
-#elif defined(__WATCOMC__) && defined(__386__)
-    #define DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #define DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    extern __inline drflac_uint16 _watcom_bswap16(drflac_uint16);
-    extern __inline drflac_uint32 _watcom_bswap32(drflac_uint32);
-    extern __inline drflac_uint64 _watcom_bswap64(drflac_uint64);
-#pragma aux _watcom_bswap16 = \
-    "xchg al, ah" \
-    parm   [ax]   \
-    modify [ax];
-#pragma aux _watcom_bswap32 = \
-    "bswap eax"  \
-    parm   [eax] \
-    modify [eax];
-#pragma aux _watcom_bswap64 = \
-    "bswap eax"     \
-    "bswap edx"     \
-    "xchg eax,edx"  \
-    parm [eax edx]  \
-    modify [eax edx];
-#endif
-#ifndef DRFLAC_ASSERT
-#include <assert.h>
-#define DRFLAC_ASSERT(expression)           assert(expression)
-#endif
-#ifndef DRFLAC_MALLOC
-#define DRFLAC_MALLOC(sz)                   malloc((sz))
-#endif
-#ifndef DRFLAC_REALLOC
-#define DRFLAC_REALLOC(p, sz)               realloc((p), (sz))
-#endif
-#ifndef DRFLAC_FREE
-#define DRFLAC_FREE(p)                      free((p))
-#endif
-#ifndef DRFLAC_COPY_MEMORY
-#define DRFLAC_COPY_MEMORY(dst, src, sz)    memcpy((dst), (src), (sz))
-#endif
-#ifndef DRFLAC_ZERO_MEMORY
-#define DRFLAC_ZERO_MEMORY(p, sz)           memset((p), 0, (sz))
-#endif
-#ifndef DRFLAC_ZERO_OBJECT
-#define DRFLAC_ZERO_OBJECT(p)               DRFLAC_ZERO_MEMORY((p), sizeof(*(p)))
-#endif
-#define DRFLAC_MAX_SIMD_VECTOR_SIZE                     64
-typedef drflac_int32 drflac_result;
-#define DRFLAC_SUCCESS                                   0
-#define DRFLAC_ERROR                                    -1
-#define DRFLAC_INVALID_ARGS                             -2
-#define DRFLAC_INVALID_OPERATION                        -3
-#define DRFLAC_OUT_OF_MEMORY                            -4
-#define DRFLAC_OUT_OF_RANGE                             -5
-#define DRFLAC_ACCESS_DENIED                            -6
-#define DRFLAC_DOES_NOT_EXIST                           -7
-#define DRFLAC_ALREADY_EXISTS                           -8
-#define DRFLAC_TOO_MANY_OPEN_FILES                      -9
-#define DRFLAC_INVALID_FILE                             -10
-#define DRFLAC_TOO_BIG                                  -11
-#define DRFLAC_PATH_TOO_LONG                            -12
-#define DRFLAC_NAME_TOO_LONG                            -13
-#define DRFLAC_NOT_DIRECTORY                            -14
-#define DRFLAC_IS_DIRECTORY                             -15
-#define DRFLAC_DIRECTORY_NOT_EMPTY                      -16
-#define DRFLAC_END_OF_FILE                              -17
-#define DRFLAC_NO_SPACE                                 -18
-#define DRFLAC_BUSY                                     -19
-#define DRFLAC_IO_ERROR                                 -20
-#define DRFLAC_INTERRUPT                                -21
-#define DRFLAC_UNAVAILABLE                              -22
-#define DRFLAC_ALREADY_IN_USE                           -23
-#define DRFLAC_BAD_ADDRESS                              -24
-#define DRFLAC_BAD_SEEK                                 -25
-#define DRFLAC_BAD_PIPE                                 -26
-#define DRFLAC_DEADLOCK                                 -27
-#define DRFLAC_TOO_MANY_LINKS                           -28
-#define DRFLAC_NOT_IMPLEMENTED                          -29
-#define DRFLAC_NO_MESSAGE                               -30
-#define DRFLAC_BAD_MESSAGE                              -31
-#define DRFLAC_NO_DATA_AVAILABLE                        -32
-#define DRFLAC_INVALID_DATA                             -33
-#define DRFLAC_TIMEOUT                                  -34
-#define DRFLAC_NO_NETWORK                               -35
-#define DRFLAC_NOT_UNIQUE                               -36
-#define DRFLAC_NOT_SOCKET                               -37
-#define DRFLAC_NO_ADDRESS                               -38
-#define DRFLAC_BAD_PROTOCOL                             -39
-#define DRFLAC_PROTOCOL_UNAVAILABLE                     -40
-#define DRFLAC_PROTOCOL_NOT_SUPPORTED                   -41
-#define DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED            -42
-#define DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED             -43
-#define DRFLAC_SOCKET_NOT_SUPPORTED                     -44
-#define DRFLAC_CONNECTION_RESET                         -45
-#define DRFLAC_ALREADY_CONNECTED                        -46
-#define DRFLAC_NOT_CONNECTED                            -47
-#define DRFLAC_CONNECTION_REFUSED                       -48
-#define DRFLAC_NO_HOST                                  -49
-#define DRFLAC_IN_PROGRESS                              -50
-#define DRFLAC_CANCELLED                                -51
-#define DRFLAC_MEMORY_ALREADY_MAPPED                    -52
-#define DRFLAC_AT_END                                   -53
-#define DRFLAC_CRC_MISMATCH                             -128
-#define DRFLAC_SUBFRAME_CONSTANT                        0
-#define DRFLAC_SUBFRAME_VERBATIM                        1
-#define DRFLAC_SUBFRAME_FIXED                           8
-#define DRFLAC_SUBFRAME_LPC                             32
-#define DRFLAC_SUBFRAME_RESERVED                        255
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE  0
-#define DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2 1
-#define DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT           0
-#define DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE             8
-#define DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE            9
-#define DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE              10
-#define drflac_align(x, a)                              ((((x) + (a) - 1) / (a)) * (a))
-DRFLAC_API void drflac_version(drflac_uint32* pMajor, drflac_uint32* pMinor, drflac_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRFLAC_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRFLAC_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRFLAC_VERSION_REVISION;
-    }
-}
-DRFLAC_API const char* drflac_version_string(void)
-{
-    return DRFLAC_VERSION_STRING;
-}
-#if defined(__has_feature)
-    #if __has_feature(thread_sanitizer)
-        #define DRFLAC_NO_THREAD_SANITIZE __attribute__((no_sanitize("thread")))
-    #else
-        #define DRFLAC_NO_THREAD_SANITIZE
-    #endif
-#else
-    #define DRFLAC_NO_THREAD_SANITIZE
-#endif
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-static drflac_bool32 drflac__gIsLZCNTSupported = DRFLAC_FALSE;
-#endif
-#ifndef DRFLAC_NO_CPUID
-static drflac_bool32 drflac__gIsSSE2Supported  = DRFLAC_FALSE;
-static drflac_bool32 drflac__gIsSSE41Supported = DRFLAC_FALSE;
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    static drflac_bool32 isCPUCapsInitialized = DRFLAC_FALSE;
-    if (!isCPUCapsInitialized) {
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-        int info[4] = {0};
-        drflac__cpuid(info, 0x80000001);
-        drflac__gIsLZCNTSupported = (info[2] & (1 << 5)) != 0;
-#endif
-        drflac__gIsSSE2Supported = drflac_has_sse2();
-        drflac__gIsSSE41Supported = drflac_has_sse41();
-        isCPUCapsInitialized = DRFLAC_TRUE;
-    }
-}
-#else
-static drflac_bool32 drflac__gIsNEONSupported  = DRFLAC_FALSE;
-static DRFLAC_INLINE drflac_bool32 drflac__has_neon(void)
-{
-#if defined(DRFLAC_SUPPORT_NEON)
-    #if defined(DRFLAC_ARM) && !defined(DRFLAC_NO_NEON)
-        #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64))
-            return DRFLAC_TRUE;
-        #else
-            return DRFLAC_FALSE;
-        #endif
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#else
-    return DRFLAC_FALSE;
-#endif
-}
-DRFLAC_NO_THREAD_SANITIZE static void drflac__init_cpu_caps(void)
-{
-    drflac__gIsNEONSupported = drflac__has_neon();
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    drflac__gIsLZCNTSupported = DRFLAC_TRUE;
-#endif
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian(void)
-{
-#if defined(DRFLAC_X86) || defined(DRFLAC_X64)
-    return DRFLAC_TRUE;
-#elif defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN
-    return DRFLAC_TRUE;
-#else
-    int n = 1;
-    return (*(char*)&n) == 1;
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP16_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ushort(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap16(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap16(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF00) >> 8) |
-           ((n & 0x00FF) << 8);
-#endif
-}
-static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP32_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_ulong(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 6) && !defined(DRFLAC_64BIT)
-            drflac_uint32 r;
-            __asm__ __volatile__ (
-            #if defined(DRFLAC_64BIT)
-                "rev %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(n)
-            #else
-                "rev %[out], %[in]" : [out]"=r"(r) : [in]"r"(n)
-            #endif
-            );
-            return r;
-        #else
-            return __builtin_bswap32(n);
-        #endif
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap32(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & 0xFF000000) >> 24) |
-           ((n & 0x00FF0000) >>  8) |
-           ((n & 0x0000FF00) <<  8) |
-           ((n & 0x000000FF) << 24);
-#endif
-}
-static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
-{
-#ifdef DRFLAC_HAS_BYTESWAP64_INTRINSIC
-    #if defined(_MSC_VER) && !defined(__clang__)
-        return _byteswap_uint64(n);
-    #elif defined(__GNUC__) || defined(__clang__)
-        return __builtin_bswap64(n);
-    #elif defined(__WATCOMC__) && defined(__386__)
-        return _watcom_bswap64(n);
-    #else
-        #error "This compiler does not support the byte swap intrinsic."
-    #endif
-#else
-    return ((n & ((drflac_uint64)0xFF000000 << 32)) >> 56) |
-           ((n & ((drflac_uint64)0x00FF0000 << 32)) >> 40) |
-           ((n & ((drflac_uint64)0x0000FF00 << 32)) >> 24) |
-           ((n & ((drflac_uint64)0x000000FF << 32)) >>  8) |
-           ((n & ((drflac_uint64)0xFF000000      )) <<  8) |
-           ((n & ((drflac_uint64)0x00FF0000      )) << 24) |
-           ((n & ((drflac_uint64)0x0000FF00      )) << 40) |
-           ((n & ((drflac_uint64)0x000000FF      )) << 56);
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint16(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
-{
-    if (drflac__is_little_endian()) {
-        return drflac__swap_endian_uint64(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
-{
-    if (!drflac__is_little_endian()) {
-        return drflac__swap_endian_uint32(n);
-    }
-    return n;
-}
-static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
-{
-    drflac_uint32 result = 0;
-    result |= (n & 0x7F000000) >> 3;
-    result |= (n & 0x007F0000) >> 2;
-    result |= (n & 0x00007F00) >> 1;
-    result |= (n & 0x0000007F) >> 0;
-    return result;
-}
-static drflac_uint8 drflac__crc8_table[] = {
-    0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
-    0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
-    0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
-    0x90, 0x97, 0x9E, 0x99, 0x8C, 0x8B, 0x82, 0x85, 0xA8, 0xAF, 0xA6, 0xA1, 0xB4, 0xB3, 0xBA, 0xBD,
-    0xC7, 0xC0, 0xC9, 0xCE, 0xDB, 0xDC, 0xD5, 0xD2, 0xFF, 0xF8, 0xF1, 0xF6, 0xE3, 0xE4, 0xED, 0xEA,
-    0xB7, 0xB0, 0xB9, 0xBE, 0xAB, 0xAC, 0xA5, 0xA2, 0x8F, 0x88, 0x81, 0x86, 0x93, 0x94, 0x9D, 0x9A,
-    0x27, 0x20, 0x29, 0x2E, 0x3B, 0x3C, 0x35, 0x32, 0x1F, 0x18, 0x11, 0x16, 0x03, 0x04, 0x0D, 0x0A,
-    0x57, 0x50, 0x59, 0x5E, 0x4B, 0x4C, 0x45, 0x42, 0x6F, 0x68, 0x61, 0x66, 0x73, 0x74, 0x7D, 0x7A,
-    0x89, 0x8E, 0x87, 0x80, 0x95, 0x92, 0x9B, 0x9C, 0xB1, 0xB6, 0xBF, 0xB8, 0xAD, 0xAA, 0xA3, 0xA4,
-    0xF9, 0xFE, 0xF7, 0xF0, 0xE5, 0xE2, 0xEB, 0xEC, 0xC1, 0xC6, 0xCF, 0xC8, 0xDD, 0xDA, 0xD3, 0xD4,
-    0x69, 0x6E, 0x67, 0x60, 0x75, 0x72, 0x7B, 0x7C, 0x51, 0x56, 0x5F, 0x58, 0x4D, 0x4A, 0x43, 0x44,
-    0x19, 0x1E, 0x17, 0x10, 0x05, 0x02, 0x0B, 0x0C, 0x21, 0x26, 0x2F, 0x28, 0x3D, 0x3A, 0x33, 0x34,
-    0x4E, 0x49, 0x40, 0x47, 0x52, 0x55, 0x5C, 0x5B, 0x76, 0x71, 0x78, 0x7F, 0x6A, 0x6D, 0x64, 0x63,
-    0x3E, 0x39, 0x30, 0x37, 0x22, 0x25, 0x2C, 0x2B, 0x06, 0x01, 0x08, 0x0F, 0x1A, 0x1D, 0x14, 0x13,
-    0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB, 0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
-    0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
-};
-static drflac_uint16 drflac__crc16_table[] = {
-    0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
-    0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
-    0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, 0x8077, 0x0072,
-    0x0050, 0x8055, 0x805F, 0x005A, 0x804B, 0x004E, 0x0044, 0x8041,
-    0x80C3, 0x00C6, 0x00CC, 0x80C9, 0x00D8, 0x80DD, 0x80D7, 0x00D2,
-    0x00F0, 0x80F5, 0x80FF, 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1,
-    0x00A0, 0x80A5, 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1,
-    0x8093, 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082,
-    0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, 0x0192,
-    0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, 0x01A4, 0x81A1,
-    0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, 0x01FE, 0x01F4, 0x81F1,
-    0x81D3, 0x01D6, 0x01DC, 0x81D9, 0x01C8, 0x81CD, 0x81C7, 0x01C2,
-    0x0140, 0x8145, 0x814F, 0x014A, 0x815B, 0x015E, 0x0154, 0x8151,
-    0x8173, 0x0176, 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162,
-    0x8123, 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132,
-    0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, 0x8101,
-    0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, 0x8317, 0x0312,
-    0x0330, 0x8335, 0x833F, 0x033A, 0x832B, 0x032E, 0x0324, 0x8321,
-    0x0360, 0x8365, 0x836F, 0x036A, 0x837B, 0x037E, 0x0374, 0x8371,
-    0x8353, 0x0356, 0x035C, 0x8359, 0x0348, 0x834D, 0x8347, 0x0342,
-    0x03C0, 0x83C5, 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1,
-    0x83F3, 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2,
-    0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, 0x03B2,
-    0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, 0x0384, 0x8381,
-    0x0280, 0x8285, 0x828F, 0x028A, 0x829B, 0x029E, 0x0294, 0x8291,
-    0x82B3, 0x02B6, 0x02BC, 0x82B9, 0x02A8, 0x82AD, 0x82A7, 0x02A2,
-    0x82E3, 0x02E6, 0x02EC, 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2,
-    0x02D0, 0x82D5, 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1,
-    0x8243, 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252,
-    0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, 0x8261,
-    0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, 0x0234, 0x8231,
-    0x8213, 0x0216, 0x021C, 0x8219, 0x0208, 0x820D, 0x8207, 0x0202
-};
-static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
-{
-    return drflac__crc8_table[crc ^ data];
-}
-static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    drflac_uint8 p = 0x07;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint8 bit = (data & (1 << i)) >> i;
-        if (crc & 0x80) {
-            crc = ((crc << 1) | bit) ^ p;
-        } else {
-            crc = ((crc << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 32);
-    wholeBytes = count >> 3;
-    leftoverBits = count - (wholeBytes*8);
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        case 4: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc8_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (drflac_uint8)((crc << leftoverBits) ^ drflac__crc8_table[(crc >> (8 - leftoverBits)) ^ (data & leftoverDataMask)]);
-    }
-    return crc;
-#endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
-{
-    return (crc << 8) ^ drflac__crc16_table[(drflac_uint8)(crc >> 8) ^ data];
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_cache(drflac_uint16 crc, drflac_cache_t data)
-{
-#ifdef DRFLAC_64BIT
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc;
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
-{
-    switch (byteCount)
-    {
-#ifdef DRFLAC_64BIT
-    case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 56) & 0xFF));
-    case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 48) & 0xFF));
-    case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 40) & 0xFF));
-    case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 32) & 0xFF));
-#endif
-    case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 24) & 0xFF));
-    case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >> 16) & 0xFF));
-    case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  8) & 0xFF));
-    case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data >>  0) & 0xFF));
-    }
-    return crc;
-}
-#if 0
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-#if 0
-    drflac_uint16 p = 0x8005;
-    for (int i = count-1; i >= 0; --i) {
-        drflac_uint16 bit = (data & (1ULL << i)) >> i;
-        if (r & 0x8000) {
-            r = ((r << 1) | bit) ^ p;
-        } else {
-            r = ((r << 1) | bit);
-        }
-    }
-    return crc;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 64);
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        default:
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0xFF000000UL << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x00FF0000UL << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x0000FF00UL << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (0x000000FFUL << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
-{
-#ifdef DR_FLAC_NO_CRC
-    (void)crc;
-    (void)data;
-    (void)count;
-    return 0;
-#else
-    drflac_uint32 wholeBytes;
-    drflac_uint32 leftoverBits;
-    drflac_uint64 leftoverDataMask;
-    static drflac_uint64 leftoverDataMaskTable[8] = {
-        0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F
-    };
-    DRFLAC_ASSERT(count <= 64);
-    wholeBytes = count >> 3;
-    leftoverBits = count & 7;
-    leftoverDataMask = leftoverDataMaskTable[leftoverBits];
-    switch (wholeBytes) {
-        default:
-        case 8: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000 << 32) << leftoverBits)) >> (56 + leftoverBits)));
-        case 7: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000 << 32) << leftoverBits)) >> (48 + leftoverBits)));
-        case 6: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00 << 32) << leftoverBits)) >> (40 + leftoverBits)));
-        case 5: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF << 32) << leftoverBits)) >> (32 + leftoverBits)));
-        case 4: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0xFF000000      ) << leftoverBits)) >> (24 + leftoverBits)));
-        case 3: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x00FF0000      ) << leftoverBits)) >> (16 + leftoverBits)));
-        case 2: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x0000FF00      ) << leftoverBits)) >> ( 8 + leftoverBits)));
-        case 1: crc = drflac_crc16_byte(crc, (drflac_uint8)((data & (((drflac_uint64)0x000000FF      ) << leftoverBits)) >> ( 0 + leftoverBits)));
-        case 0: if (leftoverBits > 0) crc = (crc << leftoverBits) ^ drflac__crc16_table[(crc >> (16 - leftoverBits)) ^ (data & leftoverDataMask)];
-    }
-    return crc;
-#endif
-}
-static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
-{
-#ifdef DRFLAC_64BIT
-    return drflac_crc16__64bit(crc, data, count);
-#else
-    return drflac_crc16__32bit(crc, data, count);
-#endif
-}
-#endif
-#ifdef DRFLAC_64BIT
-#define drflac__be2host__cache_line drflac__be2host_64
-#else
-#define drflac__be2host__cache_line drflac__be2host_32
-#endif
-#define DRFLAC_CACHE_L1_SIZE_BYTES(bs)                      (sizeof((bs)->cache))
-#define DRFLAC_CACHE_L1_SIZE_BITS(bs)                       (sizeof((bs)->cache)*8)
-#define DRFLAC_CACHE_L1_BITS_REMAINING(bs)                  (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (bs)->consumedBits)
-#define DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount)           (~((~(drflac_cache_t)0) >> (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, _bitCount)      (DRFLAC_CACHE_L1_SIZE_BITS(bs) - (_bitCount))
-#define DRFLAC_CACHE_L1_SELECT(bs, _bitCount)               (((bs)->cache) & DRFLAC_CACHE_L1_SELECTION_MASK(_bitCount))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, _bitCount)     (DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >>  DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)))
-#define DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, _bitCount)(DRFLAC_CACHE_L1_SELECT((bs), (_bitCount)) >> (DRFLAC_CACHE_L1_SELECTION_SHIFT((bs), (_bitCount)) & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1)))
-#define DRFLAC_CACHE_L2_SIZE_BYTES(bs)                      (sizeof((bs)->cacheL2))
-#define DRFLAC_CACHE_L2_LINE_COUNT(bs)                      (DRFLAC_CACHE_L2_SIZE_BYTES(bs) / sizeof((bs)->cacheL2[0]))
-#define DRFLAC_CACHE_L2_LINES_REMAINING(bs)                 (DRFLAC_CACHE_L2_LINE_COUNT(bs) - (bs)->nextL2Line)
-#ifndef DR_FLAC_NO_CRC
-static DRFLAC_INLINE void drflac__reset_crc16(drflac_bs* bs)
-{
-    bs->crc16 = 0;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-}
-static DRFLAC_INLINE void drflac__update_crc16(drflac_bs* bs)
-{
-    if (bs->crc16CacheIgnoredBytes == 0) {
-        bs->crc16 = drflac_crc16_cache(bs->crc16, bs->crc16Cache);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache, DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = 0;
-    }
-}
-static DRFLAC_INLINE drflac_uint16 drflac__flush_crc16(drflac_bs* bs)
-{
-    DRFLAC_ASSERT((DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7) == 0);
-    if (DRFLAC_CACHE_L1_BITS_REMAINING(bs) == 0) {
-        drflac__update_crc16(bs);
-    } else {
-        bs->crc16 = drflac_crc16_bytes(bs->crc16, bs->crc16Cache >> DRFLAC_CACHE_L1_BITS_REMAINING(bs), (bs->consumedBits >> 3) - bs->crc16CacheIgnoredBytes);
-        bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-    }
-    return bs->crc16;
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
-{
-    size_t bytesRead;
-    size_t alignedL1LineCount;
-    if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-    if (bs->unalignedByteCount > 0) {
-        return DRFLAC_FALSE;
-    }
-    bytesRead = bs->onRead(bs->pUserData, bs->cacheL2, DRFLAC_CACHE_L2_SIZE_BYTES(bs));
-    bs->nextL2Line = 0;
-    if (bytesRead == DRFLAC_CACHE_L2_SIZE_BYTES(bs)) {
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    }
-    alignedL1LineCount = bytesRead / DRFLAC_CACHE_L1_SIZE_BYTES(bs);
-    bs->unalignedByteCount = bytesRead - (alignedL1LineCount * DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    if (bs->unalignedByteCount > 0) {
-        bs->unalignedCache = bs->cacheL2[alignedL1LineCount];
-    }
-    if (alignedL1LineCount > 0) {
-        size_t offset = DRFLAC_CACHE_L2_LINE_COUNT(bs) - alignedL1LineCount;
-        size_t i;
-        for (i = alignedL1LineCount; i > 0; --i) {
-            bs->cacheL2[i-1 + offset] = bs->cacheL2[i-1];
-        }
-        bs->nextL2Line = (drflac_uint32)offset;
-        bs->cache = bs->cacheL2[bs->nextL2Line++];
-        return DRFLAC_TRUE;
-    } else {
-        bs->nextL2Line = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-        return DRFLAC_FALSE;
-    }
-}
-static drflac_bool32 drflac__reload_cache(drflac_bs* bs)
-{
-    size_t bytesRead;
-#ifndef DR_FLAC_NO_CRC
-    drflac__update_crc16(bs);
-#endif
-    if (drflac__reload_l1_cache_from_l2(bs)) {
-        bs->cache = drflac__be2host__cache_line(bs->cache);
-        bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-        bs->crc16Cache = bs->cache;
-#endif
-        return DRFLAC_TRUE;
-    }
-    bytesRead = bs->unalignedByteCount;
-    if (bytesRead == 0) {
-        bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ASSERT(bytesRead < DRFLAC_CACHE_L1_SIZE_BYTES(bs));
-    bs->consumedBits = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BYTES(bs) - bytesRead) * 8;
-    bs->cache = drflac__be2host__cache_line(bs->unalignedCache);
-    bs->cache &= DRFLAC_CACHE_L1_SELECTION_MASK(DRFLAC_CACHE_L1_BITS_REMAINING(bs));
-    bs->unalignedByteCount = 0;
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = bs->cache >> bs->consumedBits;
-    bs->crc16CacheIgnoredBytes = bs->consumedBits >> 3;
-#endif
-    return DRFLAC_TRUE;
-}
-static void drflac__reset_cache(drflac_bs* bs)
-{
-    bs->nextL2Line   = DRFLAC_CACHE_L2_LINE_COUNT(bs);
-    bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-    bs->cache = 0;
-    bs->unalignedByteCount = 0;
-    bs->unalignedCache = 0;
-#ifndef DR_FLAC_NO_CRC
-    bs->crc16Cache = 0;
-    bs->crc16CacheIgnoredBytes = 0;
-#endif
-}
-static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResultOut != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-    if (bs->consumedBits == DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    if (bitCount <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-#ifdef DRFLAC_64BIT
-        *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-        bs->consumedBits += bitCount;
-        bs->cache <<= bitCount;
-#else
-        if (bitCount < DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            *pResultOut = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCount);
-            bs->consumedBits += bitCount;
-            bs->cache <<= bitCount;
-        } else {
-            *pResultOut = (drflac_uint32)bs->cache;
-            bs->consumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs);
-            bs->cache = 0;
-        }
-#endif
-        return DRFLAC_TRUE;
-    } else {
-        drflac_uint32 bitCountHi = DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        drflac_uint32 bitCountLo = bitCount - bitCountHi;
-        drflac_uint32 resultHi;
-        DRFLAC_ASSERT(bitCountHi > 0);
-        DRFLAC_ASSERT(bitCountHi < 32);
-        resultHi = (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountHi);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-        *pResultOut = (resultHi << bitCountLo) | (drflac_uint32)DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, bitCountLo);
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__read_int32(drflac_bs* bs, unsigned int bitCount, drflac_int32* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 32);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    if (bitCount < 32) {
-        drflac_uint32 signbit;
-        signbit = ((result >> (bitCount-1)) & 0x01);
-        result |= (~signbit + 1) << bitCount;
-    }
-    *pResult = (drflac_int32)result;
-    return DRFLAC_TRUE;
-}
-#ifdef DRFLAC_64BIT
-static drflac_bool32 drflac__read_uint64(drflac_bs* bs, unsigned int bitCount, drflac_uint64* pResultOut)
-{
-    drflac_uint32 resultHi;
-    drflac_uint32 resultLo;
-    DRFLAC_ASSERT(bitCount <= 64);
-    DRFLAC_ASSERT(bitCount >  32);
-    if (!drflac__read_uint32(bs, bitCount - 32, &resultHi)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac__read_uint32(bs, 32, &resultLo)) {
-        return DRFLAC_FALSE;
-    }
-    *pResultOut = (((drflac_uint64)resultHi) << 32) | ((drflac_uint64)resultLo);
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static drflac_bool32 drflac__read_int64(drflac_bs* bs, unsigned int bitCount, drflac_int64* pResultOut)
-{
-    drflac_uint64 result;
-    drflac_uint64 signbit;
-    DRFLAC_ASSERT(bitCount <= 64);
-    if (!drflac__read_uint64(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    signbit = ((result >> (bitCount-1)) & 0x01);
-    result |= (~signbit + 1) << bitCount;
-    *pResultOut = (drflac_int64)result;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__read_uint16(drflac_bs* bs, unsigned int bitCount, drflac_uint16* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_uint16)result;
-    return DRFLAC_TRUE;
-}
-#if 0
-static drflac_bool32 drflac__read_int16(drflac_bs* bs, unsigned int bitCount, drflac_int16* pResult)
-{
-    drflac_int32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 16);
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_int16)result;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__read_uint8(drflac_bs* bs, unsigned int bitCount, drflac_uint8* pResult)
-{
-    drflac_uint32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-    if (!drflac__read_uint32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_uint8)result;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_int8(drflac_bs* bs, unsigned int bitCount, drflac_int8* pResult)
-{
-    drflac_int32 result;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pResult != NULL);
-    DRFLAC_ASSERT(bitCount > 0);
-    DRFLAC_ASSERT(bitCount <= 8);
-    if (!drflac__read_int32(bs, bitCount, &result)) {
-        return DRFLAC_FALSE;
-    }
-    *pResult = (drflac_int8)result;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_bits(drflac_bs* bs, size_t bitsToSeek)
-{
-    if (bitsToSeek <= DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        bs->consumedBits += (drflac_uint32)bitsToSeek;
-        bs->cache <<= bitsToSeek;
-        return DRFLAC_TRUE;
-    } else {
-        bitsToSeek       -= DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->consumedBits += DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        bs->cache         = 0;
-#ifdef DRFLAC_64BIT
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint64 bin;
-            if (!drflac__read_uint64(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#else
-        while (bitsToSeek >= DRFLAC_CACHE_L1_SIZE_BITS(bs)) {
-            drflac_uint32 bin;
-            if (!drflac__read_uint32(bs, DRFLAC_CACHE_L1_SIZE_BITS(bs), &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        }
-#endif
-        while (bitsToSeek >= 8) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, 8, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek -= 8;
-        }
-        if (bitsToSeek > 0) {
-            drflac_uint8 bin;
-            if (!drflac__read_uint8(bs, (drflac_uint32)bitsToSeek, &bin)) {
-                return DRFLAC_FALSE;
-            }
-            bitsToSeek = 0;
-        }
-        DRFLAC_ASSERT(bitsToSeek == 0);
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__find_and_seek_to_next_sync_code(drflac_bs* bs)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-        return DRFLAC_FALSE;
-    }
-    for (;;) {
-        drflac_uint8 hi;
-#ifndef DR_FLAC_NO_CRC
-        drflac__reset_crc16(bs);
-#endif
-        if (!drflac__read_uint8(bs, 8, &hi)) {
-            return DRFLAC_FALSE;
-        }
-        if (hi == 0xFF) {
-            drflac_uint8 lo;
-            if (!drflac__read_uint8(bs, 6, &lo)) {
-                return DRFLAC_FALSE;
-            }
-            if (lo == 0x3E) {
-                return DRFLAC_TRUE;
-            } else {
-                if (!drflac__seek_bits(bs, DRFLAC_CACHE_L1_BITS_REMAINING(bs) & 7)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC)
-#define DRFLAC_IMPLEMENT_CLZ_LZCNT
-#endif
-#if  defined(_MSC_VER) && _MSC_VER >= 1400 && (defined(DRFLAC_X64) || defined(DRFLAC_X86)) && !defined(__clang__)
-#define DRFLAC_IMPLEMENT_CLZ_MSVC
-#endif
-#if  defined(__WATCOMC__) && defined(__386__)
-#define DRFLAC_IMPLEMENT_CLZ_WATCOM
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    static drflac_uint32 clz_table_4[] = {
-        0,
-        4,
-        3, 3,
-        2, 2, 2, 2,
-        1, 1, 1, 1, 1, 1, 1, 1
-    };
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-    n = clz_table_4[x >> (sizeof(x)*8 - 4)];
-    if (n == 0) {
-#ifdef DRFLAC_64BIT
-        if ((x & ((drflac_uint64)0xFFFFFFFF << 32)) == 0) { n  = 32; x <<= 32; }
-        if ((x & ((drflac_uint64)0xFFFF0000 << 32)) == 0) { n += 16; x <<= 16; }
-        if ((x & ((drflac_uint64)0xFF000000 << 32)) == 0) { n += 8;  x <<= 8;  }
-        if ((x & ((drflac_uint64)0xF0000000 << 32)) == 0) { n += 4;  x <<= 4;  }
-#else
-        if ((x & 0xFFFF0000) == 0) { n  = 16; x <<= 16; }
-        if ((x & 0xFF000000) == 0) { n += 8;  x <<= 8;  }
-        if ((x & 0xF0000000) == 0) { n += 4;  x <<= 4;  }
-#endif
-        n += clz_table_4[x >> (sizeof(x)*8 - 4)];
-    }
-    return n - 1;
-}
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported(void)
-{
-#if defined(DRFLAC_HAS_LZCNT_INTRINSIC) && defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5)
-    return DRFLAC_TRUE;
-#else
-    #ifdef DRFLAC_HAS_LZCNT_INTRINSIC
-        return drflac__gIsLZCNTSupported;
-    #else
-        return DRFLAC_FALSE;
-    #endif
-#endif
-}
-static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
-{
-#if defined(_MSC_VER)
-    #ifdef DRFLAC_64BIT
-        return (drflac_uint32)__lzcnt64(x);
-    #else
-        return (drflac_uint32)__lzcnt(x);
-    #endif
-#else
-    #if defined(__GNUC__) || defined(__clang__)
-        #if defined(DRFLAC_X64)
-            {
-                drflac_uint64 r;
-                __asm__ __volatile__ (
-                    "lzcnt{ %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-                return (drflac_uint32)r;
-            }
-        #elif defined(DRFLAC_X86)
-            {
-                drflac_uint32 r;
-                __asm__ __volatile__ (
-                    "lzcnt{l %1, %0| %0, %1}" : "=r"(r) : "r"(x) : "cc"
-                );
-                return r;
-            }
-        #elif defined(DRFLAC_ARM) && (defined(__ARM_ARCH) && __ARM_ARCH >= 5) && !defined(DRFLAC_64BIT)
-            {
-                unsigned int r;
-                __asm__ __volatile__ (
-                #if defined(DRFLAC_64BIT)
-                    "clz %w[out], %w[in]" : [out]"=r"(r) : [in]"r"(x)
-                #else
-                    "clz %[out], %[in]" : [out]"=r"(r) : [in]"r"(x)
-                #endif
-                );
-                return r;
-            }
-        #else
-            if (x == 0) {
-                return sizeof(x)*8;
-            }
-            #ifdef DRFLAC_64BIT
-                return (drflac_uint32)__builtin_clzll((drflac_uint64)x);
-            #else
-                return (drflac_uint32)__builtin_clzl((drflac_uint32)x);
-            #endif
-        #endif
-    #else
-        #error "This compiler does not support the lzcnt intrinsic."
-    #endif
-#endif
-}
-#endif
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-#include <intrin.h>
-static DRFLAC_INLINE drflac_uint32 drflac__clz_msvc(drflac_cache_t x)
-{
-    drflac_uint32 n;
-    if (x == 0) {
-        return sizeof(x)*8;
-    }
-#ifdef DRFLAC_64BIT
-    _BitScanReverse64((unsigned long*)&n, x);
-#else
-    _BitScanReverse((unsigned long*)&n, x);
-#endif
-    return sizeof(x)*8 - n - 1;
-}
-#endif
-#ifdef DRFLAC_IMPLEMENT_CLZ_WATCOM
-static __inline drflac_uint32 drflac__clz_watcom (drflac_uint32);
-#pragma aux drflac__clz_watcom = \
-    "bsr eax, eax" \
-    "xor eax, 31" \
-    parm [eax] nomemory \
-    value [eax] \
-    modify exact [eax] nomemory;
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
-{
-#ifdef DRFLAC_IMPLEMENT_CLZ_LZCNT
-    if (drflac__is_lzcnt_supported()) {
-        return drflac__clz_lzcnt(x);
-    } else
-#endif
-    {
-#ifdef DRFLAC_IMPLEMENT_CLZ_MSVC
-        return drflac__clz_msvc(x);
-#elif defined(DRFLAC_IMPLEMENT_CLZ_WATCOM)
-        return (x == 0) ? sizeof(x)*8 : drflac__clz_watcom(x);
-#else
-        return drflac__clz_software(x);
-#endif
-    }
-}
-static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 setBitOffsetPlus1;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    setBitOffsetPlus1 += 1;
-    bs->consumedBits += setBitOffsetPlus1;
-    bs->cache <<= setBitOffsetPlus1;
-    *pOffsetOut = zeroCounter + setBitOffsetPlus1 - 1;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_to_byte(drflac_bs* bs, drflac_uint64 offsetFromStart)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(offsetFromStart > 0);
-    if (offsetFromStart > 0x7FFFFFFF) {
-        drflac_uint64 bytesRemaining = offsetFromStart;
-        if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        bytesRemaining -= 0x7FFFFFFF;
-        while (bytesRemaining > 0x7FFFFFFF) {
-            if (!bs->onSeek(bs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemaining -= 0x7FFFFFFF;
-        }
-        if (bytesRemaining > 0) {
-            if (!bs->onSeek(bs->pUserData, (int)bytesRemaining, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-    } else {
-        if (!bs->onSeek(bs->pUserData, (int)offsetFromStart, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    drflac__reset_cache(bs);
-    return DRFLAC_TRUE;
-}
-static drflac_result drflac__read_utf8_coded_number(drflac_bs* bs, drflac_uint64* pNumberOut, drflac_uint8* pCRCOut)
-{
-    drflac_uint8 crc;
-    drflac_uint64 result;
-    drflac_uint8 utf8[7] = {0};
-    int byteCount;
-    int i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pNumberOut != NULL);
-    DRFLAC_ASSERT(pCRCOut != NULL);
-    crc = *pCRCOut;
-    if (!drflac__read_uint8(bs, 8, utf8)) {
-        *pNumberOut = 0;
-        return DRFLAC_AT_END;
-    }
-    crc = drflac_crc8(crc, utf8[0], 8);
-    if ((utf8[0] & 0x80) == 0) {
-        *pNumberOut = utf8[0];
-        *pCRCOut = crc;
-        return DRFLAC_SUCCESS;
-    }
-    if ((utf8[0] & 0xE0) == 0xC0) {
-        byteCount = 2;
-    } else if ((utf8[0] & 0xF0) == 0xE0) {
-        byteCount = 3;
-    } else if ((utf8[0] & 0xF8) == 0xF0) {
-        byteCount = 4;
-    } else if ((utf8[0] & 0xFC) == 0xF8) {
-        byteCount = 5;
-    } else if ((utf8[0] & 0xFE) == 0xFC) {
-        byteCount = 6;
-    } else if ((utf8[0] & 0xFF) == 0xFE) {
-        byteCount = 7;
-    } else {
-        *pNumberOut = 0;
-        return DRFLAC_CRC_MISMATCH;
-    }
-    DRFLAC_ASSERT(byteCount > 1);
-    result = (drflac_uint64)(utf8[0] & (0xFF >> (byteCount + 1)));
-    for (i = 1; i < byteCount; ++i) {
-        if (!drflac__read_uint8(bs, 8, utf8 + i)) {
-            *pNumberOut = 0;
-            return DRFLAC_AT_END;
-        }
-        crc = drflac_crc8(crc, utf8[i], 8);
-        result = (result << 6) | (utf8[i] & 0x3F);
-    }
-    *pNumberOut = result;
-    *pCRCOut = crc;
-    return DRFLAC_SUCCESS;
-}
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int32 prediction = 0;
-    DRFLAC_ASSERT(order <= 32);
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * pDecodedSamples[- 1];
-    }
-    return (drflac_int32)(prediction >> shift);
-}
-static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_int64 prediction;
-    DRFLAC_ASSERT(order <= 32);
-#ifndef DRFLAC_64BIT
-    if (order == 8)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7] * (drflac_int64)pDecodedSamples[-8];
-    }
-    else if (order == 7)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6] * (drflac_int64)pDecodedSamples[-7];
-    }
-    else if (order == 3)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-    }
-    else if (order == 6)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5] * (drflac_int64)pDecodedSamples[-6];
-    }
-    else if (order == 5)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4] * (drflac_int64)pDecodedSamples[-5];
-    }
-    else if (order == 4)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2] * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3] * (drflac_int64)pDecodedSamples[-4];
-    }
-    else if (order == 12)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-        prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    }
-    else if (order == 2)
-    {
-        prediction  = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1] * (drflac_int64)pDecodedSamples[-2];
-    }
-    else if (order == 1)
-    {
-        prediction = coefficients[0] * (drflac_int64)pDecodedSamples[-1];
-    }
-    else if (order == 10)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-    }
-    else if (order == 9)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-    }
-    else if (order == 11)
-    {
-        prediction  = coefficients[0]  * (drflac_int64)pDecodedSamples[-1];
-        prediction += coefficients[1]  * (drflac_int64)pDecodedSamples[-2];
-        prediction += coefficients[2]  * (drflac_int64)pDecodedSamples[-3];
-        prediction += coefficients[3]  * (drflac_int64)pDecodedSamples[-4];
-        prediction += coefficients[4]  * (drflac_int64)pDecodedSamples[-5];
-        prediction += coefficients[5]  * (drflac_int64)pDecodedSamples[-6];
-        prediction += coefficients[6]  * (drflac_int64)pDecodedSamples[-7];
-        prediction += coefficients[7]  * (drflac_int64)pDecodedSamples[-8];
-        prediction += coefficients[8]  * (drflac_int64)pDecodedSamples[-9];
-        prediction += coefficients[9]  * (drflac_int64)pDecodedSamples[-10];
-        prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    }
-    else
-    {
-        int j;
-        prediction = 0;
-        for (j = 0; j < (int)order; ++j) {
-            prediction += coefficients[j] * (drflac_int64)pDecodedSamples[-j-1];
-        }
-    }
-#endif
-#ifdef DRFLAC_64BIT
-    prediction = 0;
-    switch (order)
-    {
-    case 32: prediction += coefficients[31] * (drflac_int64)pDecodedSamples[-32];
-    case 31: prediction += coefficients[30] * (drflac_int64)pDecodedSamples[-31];
-    case 30: prediction += coefficients[29] * (drflac_int64)pDecodedSamples[-30];
-    case 29: prediction += coefficients[28] * (drflac_int64)pDecodedSamples[-29];
-    case 28: prediction += coefficients[27] * (drflac_int64)pDecodedSamples[-28];
-    case 27: prediction += coefficients[26] * (drflac_int64)pDecodedSamples[-27];
-    case 26: prediction += coefficients[25] * (drflac_int64)pDecodedSamples[-26];
-    case 25: prediction += coefficients[24] * (drflac_int64)pDecodedSamples[-25];
-    case 24: prediction += coefficients[23] * (drflac_int64)pDecodedSamples[-24];
-    case 23: prediction += coefficients[22] * (drflac_int64)pDecodedSamples[-23];
-    case 22: prediction += coefficients[21] * (drflac_int64)pDecodedSamples[-22];
-    case 21: prediction += coefficients[20] * (drflac_int64)pDecodedSamples[-21];
-    case 20: prediction += coefficients[19] * (drflac_int64)pDecodedSamples[-20];
-    case 19: prediction += coefficients[18] * (drflac_int64)pDecodedSamples[-19];
-    case 18: prediction += coefficients[17] * (drflac_int64)pDecodedSamples[-18];
-    case 17: prediction += coefficients[16] * (drflac_int64)pDecodedSamples[-17];
-    case 16: prediction += coefficients[15] * (drflac_int64)pDecodedSamples[-16];
-    case 15: prediction += coefficients[14] * (drflac_int64)pDecodedSamples[-15];
-    case 14: prediction += coefficients[13] * (drflac_int64)pDecodedSamples[-14];
-    case 13: prediction += coefficients[12] * (drflac_int64)pDecodedSamples[-13];
-    case 12: prediction += coefficients[11] * (drflac_int64)pDecodedSamples[-12];
-    case 11: prediction += coefficients[10] * (drflac_int64)pDecodedSamples[-11];
-    case 10: prediction += coefficients[ 9] * (drflac_int64)pDecodedSamples[-10];
-    case  9: prediction += coefficients[ 8] * (drflac_int64)pDecodedSamples[- 9];
-    case  8: prediction += coefficients[ 7] * (drflac_int64)pDecodedSamples[- 8];
-    case  7: prediction += coefficients[ 6] * (drflac_int64)pDecodedSamples[- 7];
-    case  6: prediction += coefficients[ 5] * (drflac_int64)pDecodedSamples[- 6];
-    case  5: prediction += coefficients[ 4] * (drflac_int64)pDecodedSamples[- 5];
-    case  4: prediction += coefficients[ 3] * (drflac_int64)pDecodedSamples[- 4];
-    case  3: prediction += coefficients[ 2] * (drflac_int64)pDecodedSamples[- 3];
-    case  2: prediction += coefficients[ 1] * (drflac_int64)pDecodedSamples[- 2];
-    case  1: prediction += coefficients[ 0] * (drflac_int64)pDecodedSamples[- 1];
-    }
-#endif
-    return (drflac_int32)(prediction >> shift);
-}
-#if 0
-static drflac_bool32 drflac__decode_samples_with_residual__rice__reference(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    for (i = 0; i < count; ++i) {
-        drflac_uint32 zeroCounter = 0;
-        for (;;) {
-            drflac_uint8 bit;
-            if (!drflac__read_uint8(bs, 1, &bit)) {
-                return DRFLAC_FALSE;
-            }
-            if (bit == 0) {
-                zeroCounter += 1;
-            } else {
-                break;
-            }
-        }
-        drflac_uint32 decodedRice;
-        if (riceParam > 0) {
-            if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            decodedRice = 0;
-        }
-        decodedRice |= (zeroCounter << riceParam);
-        if ((decodedRice & 0x01)) {
-            decodedRice = ~(decodedRice >> 1);
-        } else {
-            decodedRice =  (decodedRice >> 1);
-        }
-        if (bitsPerSample+shift >= 32) {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] = decodedRice + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static drflac_bool32 drflac__read_rice_parts__reference(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32 zeroCounter = 0;
-    drflac_uint32 decodedRice;
-    for (;;) {
-        drflac_uint8 bit;
-        if (!drflac__read_uint8(bs, 1, &bit)) {
-            return DRFLAC_FALSE;
-        }
-        if (bit == 0) {
-            zeroCounter += 1;
-        } else {
-            break;
-        }
-    }
-    if (riceParam > 0) {
-        if (!drflac__read_uint32(bs, riceParam, &decodedRice)) {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        decodedRice = 0;
-    }
-    *pZeroCounterOut = zeroCounter;
-    *pRiceParamPartOut = decodedRice;
-    return DRFLAC_TRUE;
-}
-#endif
-#if 0
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_cache_t riceParamMask;
-    drflac_uint32 zeroCounter;
-    drflac_uint32 setBitOffsetPlus1;
-    drflac_uint32 riceParamPart;
-    drflac_uint32 riceLength;
-    DRFLAC_ASSERT(riceParam > 0);
-    riceParamMask = DRFLAC_CACHE_L1_SELECTION_MASK(riceParam);
-    zeroCounter = 0;
-    while (bs->cache == 0) {
-        zeroCounter += (drflac_uint32)DRFLAC_CACHE_L1_BITS_REMAINING(bs);
-        if (!drflac__reload_cache(bs)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    setBitOffsetPlus1 = drflac__clz(bs->cache);
-    zeroCounter += setBitOffsetPlus1;
-    setBitOffsetPlus1 += 1;
-    riceLength = setBitOffsetPlus1 + riceParam;
-    if (riceLength < DRFLAC_CACHE_L1_BITS_REMAINING(bs)) {
-        riceParamPart = (drflac_uint32)((bs->cache & (riceParamMask >> setBitOffsetPlus1)) >> DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceLength));
-        bs->consumedBits += riceLength;
-        bs->cache <<= riceLength;
-    } else {
-        drflac_uint32 bitCountLo;
-        drflac_cache_t resultHi;
-        bs->consumedBits += riceLength;
-        bs->cache <<= setBitOffsetPlus1 & (DRFLAC_CACHE_L1_SIZE_BITS(bs)-1);
-        bitCountLo = bs->consumedBits - DRFLAC_CACHE_L1_SIZE_BITS(bs);
-        resultHi = DRFLAC_CACHE_L1_SELECT_AND_SHIFT(bs, riceParam);
-        if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-#ifndef DR_FLAC_NO_CRC
-            drflac__update_crc16(bs);
-#endif
-            bs->cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-            bs->consumedBits = 0;
-#ifndef DR_FLAC_NO_CRC
-            bs->crc16Cache = bs->cache;
-#endif
-        } else {
-            if (!drflac__reload_cache(bs)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        riceParamPart = (drflac_uint32)(resultHi | DRFLAC_CACHE_L1_SELECT_AND_SHIFT_SAFE(bs, bitCountLo));
-        bs->consumedBits += bitCountLo;
-        bs->cache <<= bitCountLo;
-    }
-    pZeroCounterOut[0] = zeroCounter;
-    pRiceParamPartOut[0] = riceParamPart;
-    return DRFLAC_TRUE;
-}
-#endif
-static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1Shift = DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPlus1);
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-        pZeroCounterOut[0] = lzcount;
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            pRiceParamPartOut[0] = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartHi;
-            drflac_uint32 riceParamPartLo;
-            drflac_uint32 riceParamPartLoBitCount;
-            riceParamPartHi = (drflac_uint32)(bs_cache >> riceParamPlus1Shift);
-            riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-            riceParamPartLo = (drflac_uint32)(bs_cache >> (DRFLAC_CACHE_L1_SELECTION_SHIFT(bs, riceParamPartLoBitCount)));
-            pRiceParamPartOut[0] = riceParamPartHi | riceParamPartLo;
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        drflac_uint32 zeroCounter = (drflac_uint32)(DRFLAC_CACHE_L1_SIZE_BITS(bs) - bs_consumedBits);
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-            lzcount = drflac__clz(bs_cache);
-            zeroCounter += lzcount;
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-        pZeroCounterOut[0] = zeroCounter;
-        goto extract_rice_param_part;
-    }
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-    return DRFLAC_TRUE;
-}
-static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
-{
-    drflac_uint32  riceParamPlus1 = riceParam + 1;
-    drflac_uint32  riceParamPlus1MaxConsumedBits = DRFLAC_CACHE_L1_SIZE_BITS(bs) - riceParamPlus1;
-    drflac_cache_t bs_cache = bs->cache;
-    drflac_uint32  bs_consumedBits = bs->consumedBits;
-    drflac_uint32  lzcount = drflac__clz(bs_cache);
-    if (lzcount < sizeof(bs_cache)*8) {
-    extract_rice_param_part:
-        bs_cache       <<= lzcount;
-        bs_consumedBits += lzcount;
-        if (bs_consumedBits <= riceParamPlus1MaxConsumedBits) {
-            bs_cache       <<= riceParamPlus1;
-            bs_consumedBits += riceParamPlus1;
-        } else {
-            drflac_uint32 riceParamPartLoBitCount = bs_consumedBits - riceParamPlus1MaxConsumedBits;
-            DRFLAC_ASSERT(riceParamPartLoBitCount > 0 && riceParamPartLoBitCount < 32);
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = riceParamPartLoBitCount;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits + riceParamPartLoBitCount;
-            }
-            bs_cache <<= riceParamPartLoBitCount;
-        }
-    } else {
-        for (;;) {
-            if (bs->nextL2Line < DRFLAC_CACHE_L2_LINE_COUNT(bs)) {
-            #ifndef DR_FLAC_NO_CRC
-                drflac__update_crc16(bs);
-            #endif
-                bs_cache = drflac__be2host__cache_line(bs->cacheL2[bs->nextL2Line++]);
-                bs_consumedBits = 0;
-            #ifndef DR_FLAC_NO_CRC
-                bs->crc16Cache = bs_cache;
-            #endif
-            } else {
-                if (!drflac__reload_cache(bs)) {
-                    return DRFLAC_FALSE;
-                }
-                bs_cache = bs->cache;
-                bs_consumedBits = bs->consumedBits;
-            }
-            lzcount = drflac__clz(bs_cache);
-            if (lzcount < sizeof(bs_cache)*8) {
-                break;
-            }
-        }
-        goto extract_rice_param_part;
-    }
-    bs->cache = bs_cache;
-    bs->consumedBits = bs_consumedBits;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar_zeroorder(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0;
-    drflac_uint32 riceParamPart0;
-    drflac_uint32 riceParamMask;
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    (void)bitsPerSample;
-    (void)order;
-    (void)shift;
-    (void)coefficients;
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    i = 0;
-    while (i < count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        pSamplesOut[i] = riceParamPart0;
-        i += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__scalar(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    drflac_uint32 zeroCountPart0 = 0;
-    drflac_uint32 zeroCountPart1 = 0;
-    drflac_uint32 zeroCountPart2 = 0;
-    drflac_uint32 zeroCountPart3 = 0;
-    drflac_uint32 riceParamPart0 = 0;
-    drflac_uint32 riceParamPart1 = 0;
-    drflac_uint32 riceParamPart2 = 0;
-    drflac_uint32 riceParamPart3 = 0;
-    drflac_uint32 riceParamMask;
-    const drflac_int32* pSamplesOutEnd;
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order == 0) {
-        return drflac__decode_samples_with_residual__rice__scalar_zeroorder(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-    riceParamMask  = (drflac_uint32)~((~0UL) << riceParam);
-    pSamplesOutEnd = pSamplesOut + (count & ~3);
-    if (bitsPerSample+shift > 32) {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 3);
-            pSamplesOut += 4;
-        }
-    } else {
-        while (pSamplesOut < pSamplesOutEnd) {
-            if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart1, &riceParamPart1) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart2, &riceParamPart2) ||
-                !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart3, &riceParamPart3)) {
-                return DRFLAC_FALSE;
-            }
-            riceParamPart0 &= riceParamMask;
-            riceParamPart1 &= riceParamMask;
-            riceParamPart2 &= riceParamMask;
-            riceParamPart3 &= riceParamMask;
-            riceParamPart0 |= (zeroCountPart0 << riceParam);
-            riceParamPart1 |= (zeroCountPart1 << riceParam);
-            riceParamPart2 |= (zeroCountPart2 << riceParam);
-            riceParamPart3 |= (zeroCountPart3 << riceParam);
-            riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-            riceParamPart1  = (riceParamPart1 >> 1) ^ t[riceParamPart1 & 0x01];
-            riceParamPart2  = (riceParamPart2 >> 1) ^ t[riceParamPart2 & 0x01];
-            riceParamPart3  = (riceParamPart3 >> 1) ^ t[riceParamPart3 & 0x01];
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-            pSamplesOut[1] = riceParamPart1 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 1);
-            pSamplesOut[2] = riceParamPart2 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 2);
-            pSamplesOut[3] = riceParamPart3 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 3);
-            pSamplesOut += 4;
-        }
-    }
-    i = (count & ~3);
-    while (i < count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountPart0, &riceParamPart0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamPart0 &= riceParamMask;
-        riceParamPart0 |= (zeroCountPart0 << riceParam);
-        riceParamPart0  = (riceParamPart0 >> 1) ^ t[riceParamPart0 & 0x01];
-        if (bitsPerSample+shift > 32) {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + 0);
-        } else {
-            pSamplesOut[0] = riceParamPart0 + drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + 0);
-        }
-        i += 1;
-        pSamplesOut += 1;
-    }
-    return DRFLAC_TRUE;
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
-{
-    __m128i r;
-    r = _mm_packs_epi32(a, b);
-    r = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflehi_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    r = _mm_shufflelo_epi16(r, _MM_SHUFFLE(3, 1, 2, 0));
-    return r;
-}
-#endif
-#if defined(DRFLAC_SUPPORT_SSE41)
-static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
-{
-    return _mm_xor_si128(a, _mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128()));
-}
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
-{
-    __m128i x64 = _mm_add_epi32(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-    __m128i x32 = _mm_shufflelo_epi16(x64, _MM_SHUFFLE(1, 0, 3, 2));
-    return _mm_add_epi32(x64, x32);
-}
-static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
-{
-    return _mm_add_epi64(x, _mm_shuffle_epi32(x, _MM_SHUFFLE(1, 0, 3, 2)));
-}
-static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
-{
-    __m128i lo = _mm_srli_epi64(x, count);
-    __m128i hi = _mm_srai_epi32(x, count);
-    hi = _mm_and_si128(hi, _mm_set_epi32(0xFFFFFFFF, 0, 0xFFFFFFFF, 0));
-    return _mm_or_si128(lo, hi);
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i riceParamMask128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-    coefficients128_0 = _mm_setzero_si128();
-    coefficients128_4 = _mm_setzero_si128();
-    coefficients128_8 = _mm_setzero_si128();
-    samples128_0 = _mm_setzero_si128();
-    samples128_4 = _mm_setzero_si128();
-    samples128_8 = _mm_setzero_si128();
-#if 1
-    {
-        int runningOrder = order;
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i prediction128;
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(0x01))), _mm_set1_epi32(0x01)));
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = _mm_mullo_epi32(coefficients128_0, samples128_0);
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_4, samples128_4);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                              _mm_mullo_epi32(coefficients128_8, samples128_8);
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_4, samples128_4));
-                prediction128 = _mm_add_epi32(prediction128, _mm_mullo_epi32(coefficients128_0, samples128_0));
-                prediction128 = drflac__mm_hadd_epi32(prediction128);
-                prediction128 = _mm_srai_epi32(prediction128, shift);
-                prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-                samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-                samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-                samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-                riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-            }
-        }
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts0 = 0;
-    drflac_uint32 zeroCountParts1 = 0;
-    drflac_uint32 zeroCountParts2 = 0;
-    drflac_uint32 zeroCountParts3 = 0;
-    drflac_uint32 riceParamParts0 = 0;
-    drflac_uint32 riceParamParts1 = 0;
-    drflac_uint32 riceParamParts2 = 0;
-    drflac_uint32 riceParamParts3 = 0;
-    __m128i coefficients128_0;
-    __m128i coefficients128_4;
-    __m128i coefficients128_8;
-    __m128i samples128_0;
-    __m128i samples128_4;
-    __m128i samples128_8;
-    __m128i prediction128;
-    __m128i riceParamMask128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    DRFLAC_ASSERT(order <= 12);
-    riceParamMask    = (drflac_uint32)~((~0UL) << riceParam);
-    riceParamMask128 = _mm_set1_epi32(riceParamMask);
-    prediction128 = _mm_setzero_si128();
-    coefficients128_0  = _mm_setzero_si128();
-    coefficients128_4  = _mm_setzero_si128();
-    coefficients128_8  = _mm_setzero_si128();
-    samples128_0  = _mm_setzero_si128();
-    samples128_4  = _mm_setzero_si128();
-    samples128_8  = _mm_setzero_si128();
-#if 1
-    {
-        int runningOrder = order;
-        if (runningOrder >= 4) {
-            coefficients128_0 = _mm_loadu_si128((const __m128i*)(coefficients + 0));
-            samples128_0      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 4));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_0 = _mm_set_epi32(0, coefficients[2], coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], pSamplesOut[-3], 0); break;
-                case 2: coefficients128_0 = _mm_set_epi32(0, 0,               coefficients[1], coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], pSamplesOut[-2], 0,               0); break;
-                case 1: coefficients128_0 = _mm_set_epi32(0, 0,               0,               coefficients[0]); samples128_0 = _mm_set_epi32(pSamplesOut[-1], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = _mm_loadu_si128((const __m128i*)(coefficients + 4));
-            samples128_4      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 8));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_4 = _mm_set_epi32(0, coefficients[6], coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], pSamplesOut[-7], 0); break;
-                case 2: coefficients128_4 = _mm_set_epi32(0, 0,               coefficients[5], coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], pSamplesOut[-6], 0,               0); break;
-                case 1: coefficients128_4 = _mm_set_epi32(0, 0,               0,               coefficients[4]); samples128_4 = _mm_set_epi32(pSamplesOut[-5], 0,               0,               0); break;
-            }
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = _mm_loadu_si128((const __m128i*)(coefficients + 8));
-            samples128_8      = _mm_loadu_si128((const __m128i*)(pSamplesOut  - 12));
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: coefficients128_8 = _mm_set_epi32(0, coefficients[10], coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], pSamplesOut[-11], 0); break;
-                case 2: coefficients128_8 = _mm_set_epi32(0, 0,                coefficients[9], coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], pSamplesOut[-10], 0,                0); break;
-                case 1: coefficients128_8 = _mm_set_epi32(0, 0,                0,               coefficients[8]); samples128_8 = _mm_set_epi32(pSamplesOut[-9], 0,                0,                0); break;
-            }
-            runningOrder = 0;
-        }
-        coefficients128_0 = _mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_4 = _mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(0, 1, 2, 3));
-        coefficients128_8 = _mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(0, 1, 2, 3));
-    }
-#else
-    switch (order)
-    {
-    case 12: ((drflac_int32*)&coefficients128_8)[0] = coefficients[11]; ((drflac_int32*)&samples128_8)[0] = pDecodedSamples[-12];
-    case 11: ((drflac_int32*)&coefficients128_8)[1] = coefficients[10]; ((drflac_int32*)&samples128_8)[1] = pDecodedSamples[-11];
-    case 10: ((drflac_int32*)&coefficients128_8)[2] = coefficients[ 9]; ((drflac_int32*)&samples128_8)[2] = pDecodedSamples[-10];
-    case 9:  ((drflac_int32*)&coefficients128_8)[3] = coefficients[ 8]; ((drflac_int32*)&samples128_8)[3] = pDecodedSamples[- 9];
-    case 8:  ((drflac_int32*)&coefficients128_4)[0] = coefficients[ 7]; ((drflac_int32*)&samples128_4)[0] = pDecodedSamples[- 8];
-    case 7:  ((drflac_int32*)&coefficients128_4)[1] = coefficients[ 6]; ((drflac_int32*)&samples128_4)[1] = pDecodedSamples[- 7];
-    case 6:  ((drflac_int32*)&coefficients128_4)[2] = coefficients[ 5]; ((drflac_int32*)&samples128_4)[2] = pDecodedSamples[- 6];
-    case 5:  ((drflac_int32*)&coefficients128_4)[3] = coefficients[ 4]; ((drflac_int32*)&samples128_4)[3] = pDecodedSamples[- 5];
-    case 4:  ((drflac_int32*)&coefficients128_0)[0] = coefficients[ 3]; ((drflac_int32*)&samples128_0)[0] = pDecodedSamples[- 4];
-    case 3:  ((drflac_int32*)&coefficients128_0)[1] = coefficients[ 2]; ((drflac_int32*)&samples128_0)[1] = pDecodedSamples[- 3];
-    case 2:  ((drflac_int32*)&coefficients128_0)[2] = coefficients[ 1]; ((drflac_int32*)&samples128_0)[2] = pDecodedSamples[- 2];
-    case 1:  ((drflac_int32*)&coefficients128_0)[3] = coefficients[ 0]; ((drflac_int32*)&samples128_0)[3] = pDecodedSamples[- 1];
-    }
-#endif
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        __m128i zeroCountPart128;
-        __m128i riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts1, &riceParamParts1) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts2, &riceParamParts2) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts3, &riceParamParts3)) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = _mm_set_epi32(zeroCountParts3, zeroCountParts2, zeroCountParts1, zeroCountParts0);
-        riceParamPart128 = _mm_set_epi32(riceParamParts3, riceParamParts2, riceParamParts1, riceParamParts0);
-        riceParamPart128 = _mm_and_si128(riceParamPart128, riceParamMask128);
-        riceParamPart128 = _mm_or_si128(riceParamPart128, _mm_slli_epi32(zeroCountPart128, riceParam));
-        riceParamPart128 = _mm_xor_si128(_mm_srli_epi32(riceParamPart128, 1), _mm_add_epi32(drflac__mm_not_si128(_mm_and_si128(riceParamPart128, _mm_set1_epi32(1))), _mm_set1_epi32(1)));
-        for (i = 0; i < 4; i += 1) {
-            prediction128 = _mm_xor_si128(prediction128, prediction128);
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(1, 1, 0, 0))));
-            case 10:
-            case  9: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_8, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_8, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  8:
-            case  7: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  6:
-            case  5: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_4, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_4, _MM_SHUFFLE(3, 3, 2, 2))));
-            case  4:
-            case  3: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(1, 1, 0, 0)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(1, 1, 0, 0))));
-            case  2:
-            case  1: prediction128 = _mm_add_epi64(prediction128, _mm_mul_epi32(_mm_shuffle_epi32(coefficients128_0, _MM_SHUFFLE(3, 3, 2, 2)), _mm_shuffle_epi32(samples128_0, _MM_SHUFFLE(3, 3, 2, 2))));
-            }
-            prediction128 = drflac__mm_hadd_epi64(prediction128);
-            prediction128 = drflac__mm_srai_epi64(prediction128, shift);
-            prediction128 = _mm_add_epi32(riceParamPart128, prediction128);
-            samples128_8 = _mm_alignr_epi8(samples128_4,  samples128_8, 4);
-            samples128_4 = _mm_alignr_epi8(samples128_0,  samples128_4, 4);
-            samples128_0 = _mm_alignr_epi8(prediction128, samples128_0, 4);
-            riceParamPart128 = _mm_alignr_epi8(_mm_setzero_si128(), riceParamPart128, 4);
-        }
-        _mm_storeu_si128((__m128i*)pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts0, &riceParamParts0)) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts0 &= riceParamMask;
-        riceParamParts0 |= (zeroCountParts0 << riceParam);
-        riceParamParts0  = (riceParamParts0 >> 1) ^ t[riceParamParts0 & 0x01];
-        pDecodedSamples[0] = riceParamParts0 + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__sse41(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__sse41_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__sse41_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac__vst2q_s32(drflac_int32* p, int32x4x2_t x)
-{
-    vst1q_s32(p+0, x.val[0]);
-    vst1q_s32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_u32(drflac_uint32* p, uint32x4x2_t x)
-{
-    vst1q_u32(p+0, x.val[0]);
-    vst1q_u32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_f32(float* p, float32x4x2_t x)
-{
-    vst1q_f32(p+0, x.val[0]);
-    vst1q_f32(p+4, x.val[1]);
-}
-static DRFLAC_INLINE void drflac__vst2q_s16(drflac_int16* p, int16x4x2_t x)
-{
-    vst1q_s16(p, vcombine_s16(x.val[0], x.val[1]));
-}
-static DRFLAC_INLINE void drflac__vst2q_u16(drflac_uint16* p, uint16x4x2_t x)
-{
-    vst1q_u16(p, vcombine_u16(x.val[0], x.val[1]));
-}
-static DRFLAC_INLINE int32x4_t drflac__vdupq_n_s32x4(drflac_int32 x3, drflac_int32 x2, drflac_int32 x1, drflac_int32 x0)
-{
-    drflac_int32 x[4];
-    x[3] = x3;
-    x[2] = x2;
-    x[1] = x1;
-    x[0] = x0;
-    return vld1q_s32(x);
-}
-static DRFLAC_INLINE int32x4_t drflac__valignrq_s32_1(int32x4_t a, int32x4_t b)
-{
-    return vextq_s32(b, a, 1);
-}
-static DRFLAC_INLINE uint32x4_t drflac__valignrq_u32_1(uint32x4_t a, uint32x4_t b)
-{
-    return vextq_u32(b, a, 1);
-}
-static DRFLAC_INLINE int32x2_t drflac__vhaddq_s32(int32x4_t x)
-{
-    int32x2_t r = vadd_s32(vget_high_s32(x), vget_low_s32(x));
-    return vpadd_s32(r, r);
-}
-static DRFLAC_INLINE int64x1_t drflac__vhaddq_s64(int64x2_t x)
-{
-    return vadd_s64(vget_high_s64(x), vget_low_s64(x));
-}
-static DRFLAC_INLINE int32x4_t drflac__vrevq_s32(int32x4_t x)
-{
-    return vrev64q_s32(vcombine_s32(vget_high_s32(x), vget_low_s32(x)));
-}
-static DRFLAC_INLINE int32x4_t drflac__vnotq_s32(int32x4_t x)
-{
-    return veorq_s32(x, vdupq_n_s32(0xFFFFFFFF));
-}
-static DRFLAC_INLINE uint32x4_t drflac__vnotq_u32(uint32x4_t x)
-{
-    return veorq_u32(x, vdupq_n_u32(0xFFFFFFFF));
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_32(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int32x2_t shift64;
-    uint32x4_t one128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s32(-shift);
-    one128 = vdupq_n_u32(1);
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3];
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2];
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1];
-            }
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7];
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6];
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5];
-            }
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11];
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10];
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9];
-            }
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int32x4_t prediction128;
-        int32x2_t prediction64;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-        if (order <= 4) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 = vmulq_s32(coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else if (order <= 8) {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        } else {
-            for (i = 0; i < 4; i += 1) {
-                prediction128 =                vmulq_s32(coefficients128_8, samples128_8);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_4, samples128_4);
-                prediction128 = vmlaq_s32(prediction128, coefficients128_0, samples128_0);
-                prediction64 = drflac__vhaddq_s32(prediction128);
-                prediction64 = vshl_s32(prediction64, shift64);
-                prediction64 = vadd_s32(prediction64, vget_low_s32(vreinterpretq_s32_u32(riceParamPart128)));
-                samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-                samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-                samples128_0 = drflac__valignrq_s32_1(vcombine_s32(prediction64, vdup_n_s32(0)), samples128_0);
-                riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-            }
-        }
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_32(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon_64(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    int i;
-    drflac_uint32 riceParamMask;
-    drflac_int32* pDecodedSamples    = pSamplesOut;
-    drflac_int32* pDecodedSamplesEnd = pSamplesOut + (count & ~3);
-    drflac_uint32 zeroCountParts[4];
-    drflac_uint32 riceParamParts[4];
-    int32x4_t coefficients128_0;
-    int32x4_t coefficients128_4;
-    int32x4_t coefficients128_8;
-    int32x4_t samples128_0;
-    int32x4_t samples128_4;
-    int32x4_t samples128_8;
-    uint32x4_t riceParamMask128;
-    int32x4_t riceParam128;
-    int64x1_t shift64;
-    uint32x4_t one128;
-    const drflac_uint32 t[2] = {0x00000000, 0xFFFFFFFF};
-    riceParamMask    = ~((~0UL) << riceParam);
-    riceParamMask128 = vdupq_n_u32(riceParamMask);
-    riceParam128 = vdupq_n_s32(riceParam);
-    shift64 = vdup_n_s64(-shift);
-    one128 = vdupq_n_u32(1);
-    {
-        int runningOrder = order;
-        drflac_int32 tempC[4] = {0, 0, 0, 0};
-        drflac_int32 tempS[4] = {0, 0, 0, 0};
-        if (runningOrder >= 4) {
-            coefficients128_0 = vld1q_s32(coefficients + 0);
-            samples128_0      = vld1q_s32(pSamplesOut  - 4);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[2]; tempS[1] = pSamplesOut[-3];
-                case 2: tempC[1] = coefficients[1]; tempS[2] = pSamplesOut[-2];
-                case 1: tempC[0] = coefficients[0]; tempS[3] = pSamplesOut[-1];
-            }
-            coefficients128_0 = vld1q_s32(tempC);
-            samples128_0      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder >= 4) {
-            coefficients128_4 = vld1q_s32(coefficients + 4);
-            samples128_4      = vld1q_s32(pSamplesOut  - 8);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[6]; tempS[1] = pSamplesOut[-7];
-                case 2: tempC[1] = coefficients[5]; tempS[2] = pSamplesOut[-6];
-                case 1: tempC[0] = coefficients[4]; tempS[3] = pSamplesOut[-5];
-            }
-            coefficients128_4 = vld1q_s32(tempC);
-            samples128_4      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        if (runningOrder == 4) {
-            coefficients128_8 = vld1q_s32(coefficients + 8);
-            samples128_8      = vld1q_s32(pSamplesOut  - 12);
-            runningOrder -= 4;
-        } else {
-            switch (runningOrder) {
-                case 3: tempC[2] = coefficients[10]; tempS[1] = pSamplesOut[-11];
-                case 2: tempC[1] = coefficients[ 9]; tempS[2] = pSamplesOut[-10];
-                case 1: tempC[0] = coefficients[ 8]; tempS[3] = pSamplesOut[- 9];
-            }
-            coefficients128_8 = vld1q_s32(tempC);
-            samples128_8      = vld1q_s32(tempS);
-            runningOrder = 0;
-        }
-        coefficients128_0 = drflac__vrevq_s32(coefficients128_0);
-        coefficients128_4 = drflac__vrevq_s32(coefficients128_4);
-        coefficients128_8 = drflac__vrevq_s32(coefficients128_8);
-    }
-    while (pDecodedSamples < pDecodedSamplesEnd) {
-        int64x2_t prediction128;
-        uint32x4_t zeroCountPart128;
-        uint32x4_t riceParamPart128;
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[1], &riceParamParts[1]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[2], &riceParamParts[2]) ||
-            !drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[3], &riceParamParts[3])) {
-            return DRFLAC_FALSE;
-        }
-        zeroCountPart128 = vld1q_u32(zeroCountParts);
-        riceParamPart128 = vld1q_u32(riceParamParts);
-        riceParamPart128 = vandq_u32(riceParamPart128, riceParamMask128);
-        riceParamPart128 = vorrq_u32(riceParamPart128, vshlq_u32(zeroCountPart128, riceParam128));
-        riceParamPart128 = veorq_u32(vshrq_n_u32(riceParamPart128, 1), vaddq_u32(drflac__vnotq_u32(vandq_u32(riceParamPart128, one128)), one128));
-        for (i = 0; i < 4; i += 1) {
-            int64x1_t prediction64;
-            prediction128 = veorq_s64(prediction128, prediction128);
-            switch (order)
-            {
-            case 12:
-            case 11: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_8), vget_low_s32(samples128_8)));
-            case 10:
-            case  9: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_8), vget_high_s32(samples128_8)));
-            case  8:
-            case  7: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_4), vget_low_s32(samples128_4)));
-            case  6:
-            case  5: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_4), vget_high_s32(samples128_4)));
-            case  4:
-            case  3: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_low_s32(coefficients128_0), vget_low_s32(samples128_0)));
-            case  2:
-            case  1: prediction128 = vaddq_s64(prediction128, vmull_s32(vget_high_s32(coefficients128_0), vget_high_s32(samples128_0)));
-            }
-            prediction64 = drflac__vhaddq_s64(prediction128);
-            prediction64 = vshl_s64(prediction64, shift64);
-            prediction64 = vadd_s64(prediction64, vdup_n_s64(vgetq_lane_u32(riceParamPart128, 0)));
-            samples128_8 = drflac__valignrq_s32_1(samples128_4, samples128_8);
-            samples128_4 = drflac__valignrq_s32_1(samples128_0, samples128_4);
-            samples128_0 = drflac__valignrq_s32_1(vcombine_s32(vreinterpret_s32_s64(prediction64), vdup_n_s32(0)), samples128_0);
-            riceParamPart128 = drflac__valignrq_u32_1(vdupq_n_u32(0), riceParamPart128);
-        }
-        vst1q_s32(pDecodedSamples, samples128_0);
-        pDecodedSamples += 4;
-    }
-    i = (count & ~3);
-    while (i < (int)count) {
-        if (!drflac__read_rice_parts_x1(bs, riceParam, &zeroCountParts[0], &riceParamParts[0])) {
-            return DRFLAC_FALSE;
-        }
-        riceParamParts[0] &= riceParamMask;
-        riceParamParts[0] |= (zeroCountParts[0] << riceParam);
-        riceParamParts[0]  = (riceParamParts[0] >> 1) ^ t[riceParamParts[0] & 0x01];
-        pDecodedSamples[0] = riceParamParts[0] + drflac__calculate_prediction_64(order, shift, coefficients, pDecodedSamples);
-        i += 1;
-        pDecodedSamples += 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__rice__neon(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    if (order > 0 && order <= 12) {
-        if (bitsPerSample+shift > 32) {
-            return drflac__decode_samples_with_residual__rice__neon_64(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        } else {
-            return drflac__decode_samples_with_residual__rice__neon_32(bs, count, riceParam, order, shift, coefficients, pSamplesOut);
-        }
-    } else {
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    }
-}
-#endif
-static drflac_bool32 drflac__decode_samples_with_residual__rice(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 riceParam, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-#if defined(DRFLAC_SUPPORT_SSE41)
-    if (drflac__gIsSSE41Supported) {
-        return drflac__decode_samples_with_residual__rice__sse41(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported) {
-        return drflac__decode_samples_with_residual__rice__neon(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    } else
-#endif
-    {
-    #if 0
-        return drflac__decode_samples_with_residual__rice__reference(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #else
-        return drflac__decode_samples_with_residual__rice__scalar(bs, bitsPerSample, count, riceParam, order, shift, coefficients, pSamplesOut);
-    #endif
-    }
-}
-static drflac_bool32 drflac__read_and_seek_residual__rice(drflac_bs* bs, drflac_uint32 count, drflac_uint8 riceParam)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    for (i = 0; i < count; ++i) {
-        if (!drflac__seek_rice_parts(bs, riceParam)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual__unencoded(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 count, drflac_uint8 unencodedBitsPerSample, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pSamplesOut)
-{
-    drflac_uint32 i;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(unencodedBitsPerSample <= 31);
-    DRFLAC_ASSERT(pSamplesOut != NULL);
-    for (i = 0; i < count; ++i) {
-        if (unencodedBitsPerSample > 0) {
-            if (!drflac__read_int32(bs, unencodedBitsPerSample, pSamplesOut + i)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            pSamplesOut[i] = 0;
-        }
-        if (bitsPerSample >= 24) {
-            pSamplesOut[i] += drflac__calculate_prediction_64(order, shift, coefficients, pSamplesOut + i);
-        } else {
-            pSamplesOut[i] += drflac__calculate_prediction_32(order, shift, coefficients, pSamplesOut + i);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples_with_residual(drflac_bs* bs, drflac_uint32 bitsPerSample, drflac_uint32 blockSize, drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    DRFLAC_ASSERT(pDecodedSamples != NULL);
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;
-    }
-    pDecodedSamples += order;
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-    if ((blockSize / (1 << partitionOrder)) < order) {
-        return DRFLAC_FALSE;
-    }
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;) {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-        if (riceParam != 0xFF) {
-            if (!drflac__decode_samples_with_residual__rice(bs, bitsPerSample, samplesInPartition, riceParam, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__decode_samples_with_residual__unencoded(bs, bitsPerSample, samplesInPartition, unencodedBitsPerSample, order, shift, coefficients, pDecodedSamples)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        pDecodedSamples += samplesInPartition;
-        if (partitionsRemaining == 1) {
-            break;
-        }
-        partitionsRemaining -= 1;
-        if (partitionOrder != 0) {
-            samplesInPartition = blockSize / (1 << partitionOrder);
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_and_seek_residual(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 order)
-{
-    drflac_uint8 residualMethod;
-    drflac_uint8 partitionOrder;
-    drflac_uint32 samplesInPartition;
-    drflac_uint32 partitionsRemaining;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(blockSize != 0);
-    if (!drflac__read_uint8(bs, 2, &residualMethod)) {
-        return DRFLAC_FALSE;
-    }
-    if (residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE && residualMethod != DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac__read_uint8(bs, 4, &partitionOrder)) {
-        return DRFLAC_FALSE;
-    }
-    if (partitionOrder > 8) {
-        return DRFLAC_FALSE;
-    }
-    if ((blockSize / (1 << partitionOrder)) <= order) {
-        return DRFLAC_FALSE;
-    }
-    samplesInPartition = (blockSize / (1 << partitionOrder)) - order;
-    partitionsRemaining = (1 << partitionOrder);
-    for (;;)
-    {
-        drflac_uint8 riceParam = 0;
-        if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE) {
-            if (!drflac__read_uint8(bs, 4, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 15) {
-                riceParam = 0xFF;
-            }
-        } else if (residualMethod == DRFLAC_RESIDUAL_CODING_METHOD_PARTITIONED_RICE2) {
-            if (!drflac__read_uint8(bs, 5, &riceParam)) {
-                return DRFLAC_FALSE;
-            }
-            if (riceParam == 31) {
-                riceParam = 0xFF;
-            }
-        }
-        if (riceParam != 0xFF) {
-            if (!drflac__read_and_seek_residual__rice(bs, samplesInPartition, riceParam)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            drflac_uint8 unencodedBitsPerSample = 0;
-            if (!drflac__read_uint8(bs, 5, &unencodedBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__seek_bits(bs, unencodedBitsPerSample * samplesInPartition)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        if (partitionsRemaining == 1) {
-            break;
-        }
-        partitionsRemaining -= 1;
-        samplesInPartition = blockSize / (1 << partitionOrder);
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__constant(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    drflac_int32 sample;
-    if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-        return DRFLAC_FALSE;
-    }
-    for (i = 0; i < blockSize; ++i) {
-        pDecodedSamples[i] = sample;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__verbatim(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    for (i = 0; i < blockSize; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__fixed(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 subframeBitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint32 i;
-    static drflac_int32 lpcCoefficientsTable[5][4] = {
-        {0,  0, 0,  0},
-        {1,  0, 0,  0},
-        {2, -1, 0,  0},
-        {3, -3, 1,  0},
-        {4, -6, 4, -1}
-    };
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, subframeBitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    if (!drflac__decode_samples_with_residual(bs, subframeBitsPerSample, blockSize, lpcOrder, 0, lpcCoefficientsTable[lpcOrder], pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_samples__lpc(drflac_bs* bs, drflac_uint32 blockSize, drflac_uint32 bitsPerSample, drflac_uint8 lpcOrder, drflac_int32* pDecodedSamples)
-{
-    drflac_uint8 i;
-    drflac_uint8 lpcPrecision;
-    drflac_int8 lpcShift;
-    drflac_int32 coefficients[32];
-    for (i = 0; i < lpcOrder; ++i) {
-        drflac_int32 sample;
-        if (!drflac__read_int32(bs, bitsPerSample, &sample)) {
-            return DRFLAC_FALSE;
-        }
-        pDecodedSamples[i] = sample;
-    }
-    if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcPrecision == 15) {
-        return DRFLAC_FALSE;
-    }
-    lpcPrecision += 1;
-    if (!drflac__read_int8(bs, 5, &lpcShift)) {
-        return DRFLAC_FALSE;
-    }
-    if (lpcShift < 0) {
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ZERO_MEMORY(coefficients, sizeof(coefficients));
-    for (i = 0; i < lpcOrder; ++i) {
-        if (!drflac__read_int32(bs, lpcPrecision, coefficients + i)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    if (!drflac__decode_samples_with_residual(bs, bitsPerSample, blockSize, lpcOrder, lpcShift, coefficients, pDecodedSamples)) {
-        return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_next_flac_frame_header(drflac_bs* bs, drflac_uint8 streaminfoBitsPerSample, drflac_frame_header* header)
-{
-    const drflac_uint32 sampleRateTable[12]  = {0, 88200, 176400, 192000, 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000};
-    const drflac_uint8 bitsPerSampleTable[8] = {0, 8, 12, (drflac_uint8)-1, 16, 20, 24, (drflac_uint8)-1};
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(header != NULL);
-    for (;;) {
-        drflac_uint8 crc8 = 0xCE;
-        drflac_uint8 reserved = 0;
-        drflac_uint8 blockingStrategy = 0;
-        drflac_uint8 blockSize = 0;
-        drflac_uint8 sampleRate = 0;
-        drflac_uint8 channelAssignment = 0;
-        drflac_uint8 bitsPerSample = 0;
-        drflac_bool32 isVariableBlockSize;
-        if (!drflac__find_and_seek_to_next_sync_code(bs)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-        if (!drflac__read_uint8(bs, 1, &blockingStrategy)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, blockingStrategy, 1);
-        if (!drflac__read_uint8(bs, 4, &blockSize)) {
-            return DRFLAC_FALSE;
-        }
-        if (blockSize == 0) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, blockSize, 4);
-        if (!drflac__read_uint8(bs, 4, &sampleRate)) {
-            return DRFLAC_FALSE;
-        }
-        crc8 = drflac_crc8(crc8, sampleRate, 4);
-        if (!drflac__read_uint8(bs, 4, &channelAssignment)) {
-            return DRFLAC_FALSE;
-        }
-        if (channelAssignment > 10) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, channelAssignment, 4);
-        if (!drflac__read_uint8(bs, 3, &bitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        if (bitsPerSample == 3 || bitsPerSample == 7) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, bitsPerSample, 3);
-        if (!drflac__read_uint8(bs, 1, &reserved)) {
-            return DRFLAC_FALSE;
-        }
-        if (reserved == 1) {
-            continue;
-        }
-        crc8 = drflac_crc8(crc8, reserved, 1);
-        isVariableBlockSize = blockingStrategy == 1;
-        if (isVariableBlockSize) {
-            drflac_uint64 pcmFrameNumber;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &pcmFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = 0;
-            header->pcmFrameNumber = pcmFrameNumber;
-        } else {
-            drflac_uint64 flacFrameNumber = 0;
-            drflac_result result = drflac__read_utf8_coded_number(bs, &flacFrameNumber, &crc8);
-            if (result != DRFLAC_SUCCESS) {
-                if (result == DRFLAC_AT_END) {
-                    return DRFLAC_FALSE;
-                } else {
-                    continue;
-                }
-            }
-            header->flacFrameNumber  = (drflac_uint32)flacFrameNumber;
-            header->pcmFrameNumber = 0;
-        }
-        DRFLAC_ASSERT(blockSize > 0);
-        if (blockSize == 1) {
-            header->blockSizeInPCMFrames = 192;
-        } else if (blockSize <= 5) {
-            DRFLAC_ASSERT(blockSize >= 2);
-            header->blockSizeInPCMFrames = 576 * (1 << (blockSize - 2));
-        } else if (blockSize == 6) {
-            if (!drflac__read_uint16(bs, 8, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 8);
-            header->blockSizeInPCMFrames += 1;
-        } else if (blockSize == 7) {
-            if (!drflac__read_uint16(bs, 16, &header->blockSizeInPCMFrames)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->blockSizeInPCMFrames, 16);
-            header->blockSizeInPCMFrames += 1;
-        } else {
-            DRFLAC_ASSERT(blockSize >= 8);
-            header->blockSizeInPCMFrames = 256 * (1 << (blockSize - 8));
-        }
-        if (sampleRate <= 11) {
-            header->sampleRate = sampleRateTable[sampleRate];
-        } else if (sampleRate == 12) {
-            if (!drflac__read_uint32(bs, 8, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 8);
-            header->sampleRate *= 1000;
-        } else if (sampleRate == 13) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-        } else if (sampleRate == 14) {
-            if (!drflac__read_uint32(bs, 16, &header->sampleRate)) {
-                return DRFLAC_FALSE;
-            }
-            crc8 = drflac_crc8(crc8, header->sampleRate, 16);
-            header->sampleRate *= 10;
-        } else {
-            continue;
-        }
-        header->channelAssignment = channelAssignment;
-        header->bitsPerSample = bitsPerSampleTable[bitsPerSample];
-        if (header->bitsPerSample == 0) {
-            header->bitsPerSample = streaminfoBitsPerSample;
-        }
-        if (!drflac__read_uint8(bs, 8, &header->crc8)) {
-            return DRFLAC_FALSE;
-        }
-#ifndef DR_FLAC_NO_CRC
-        if (header->crc8 != crc8) {
-            continue;
-        }
-#endif
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac__read_subframe_header(drflac_bs* bs, drflac_subframe* pSubframe)
-{
-    drflac_uint8 header;
-    int type;
-    if (!drflac__read_uint8(bs, 8, &header)) {
-        return DRFLAC_FALSE;
-    }
-    if ((header & 0x80) != 0) {
-        return DRFLAC_FALSE;
-    }
-    type = (header & 0x7E) >> 1;
-    if (type == 0) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_CONSTANT;
-    } else if (type == 1) {
-        pSubframe->subframeType = DRFLAC_SUBFRAME_VERBATIM;
-    } else {
-        if ((type & 0x20) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_LPC;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x1F) + 1;
-        } else if ((type & 0x08) != 0) {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_FIXED;
-            pSubframe->lpcOrder = (drflac_uint8)(type & 0x07);
-            if (pSubframe->lpcOrder > 4) {
-                pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-                pSubframe->lpcOrder = 0;
-            }
-        } else {
-            pSubframe->subframeType = DRFLAC_SUBFRAME_RESERVED;
-        }
-    }
-    if (pSubframe->subframeType == DRFLAC_SUBFRAME_RESERVED) {
-        return DRFLAC_FALSE;
-    }
-    pSubframe->wastedBitsPerSample = 0;
-    if ((header & 0x01) == 1) {
-        unsigned int wastedBitsPerSample;
-        if (!drflac__seek_past_next_set_bit(bs, &wastedBitsPerSample)) {
-            return DRFLAC_FALSE;
-        }
-        pSubframe->wastedBitsPerSample = (drflac_uint8)wastedBitsPerSample + 1;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex, drflac_int32* pDecodedSamplesOut)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-    pSubframe->pSamplesS32 = pDecodedSamplesOut;
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            drflac__decode_samples__constant(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            drflac__decode_samples__verbatim(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            drflac__decode_samples__fixed(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac__decode_samples__lpc(bs, frame->header.blockSizeInPCMFrames, subframeBitsPerSample, pSubframe->lpcOrder, pSubframe->pSamplesS32);
-        } break;
-        default: return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__seek_subframe(drflac_bs* bs, drflac_frame* frame, int subframeIndex)
-{
-    drflac_subframe* pSubframe;
-    drflac_uint32 subframeBitsPerSample;
-    DRFLAC_ASSERT(bs != NULL);
-    DRFLAC_ASSERT(frame != NULL);
-    pSubframe = frame->subframes + subframeIndex;
-    if (!drflac__read_subframe_header(bs, pSubframe)) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample = frame->header.bitsPerSample;
-    if ((frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE || frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE) && subframeIndex == 1) {
-        subframeBitsPerSample += 1;
-    } else if (frame->header.channelAssignment == DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE && subframeIndex == 0) {
-        subframeBitsPerSample += 1;
-    }
-    if (pSubframe->wastedBitsPerSample >= subframeBitsPerSample) {
-        return DRFLAC_FALSE;
-    }
-    subframeBitsPerSample -= pSubframe->wastedBitsPerSample;
-    pSubframe->pSamplesS32 = NULL;
-    switch (pSubframe->subframeType)
-    {
-        case DRFLAC_SUBFRAME_CONSTANT:
-        {
-            if (!drflac__seek_bits(bs, subframeBitsPerSample)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_VERBATIM:
-        {
-            unsigned int bitsToSeek = frame->header.blockSizeInPCMFrames * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_FIXED:
-        {
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        case DRFLAC_SUBFRAME_LPC:
-        {
-            drflac_uint8 lpcPrecision;
-            unsigned int bitsToSeek = pSubframe->lpcOrder * subframeBitsPerSample;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_uint8(bs, 4, &lpcPrecision)) {
-                return DRFLAC_FALSE;
-            }
-            if (lpcPrecision == 15) {
-                return DRFLAC_FALSE;
-            }
-            lpcPrecision += 1;
-            bitsToSeek = (pSubframe->lpcOrder * lpcPrecision) + 5;
-            if (!drflac__seek_bits(bs, bitsToSeek)) {
-                return DRFLAC_FALSE;
-            }
-            if (!drflac__read_and_seek_residual(bs, frame->header.blockSizeInPCMFrames, pSubframe->lpcOrder)) {
-                return DRFLAC_FALSE;
-            }
-        } break;
-        default: return DRFLAC_FALSE;
-    }
-    return DRFLAC_TRUE;
-}
-static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
-{
-    drflac_uint8 lookup[] = {1, 2, 3, 4, 5, 6, 7, 8, 2, 2, 2};
-    DRFLAC_ASSERT(channelAssignment <= 10);
-    return lookup[channelAssignment];
-}
-static drflac_result drflac__decode_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint8 paddingSizeInBits;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-    DRFLAC_ZERO_MEMORY(pFlac->currentFLACFrame.subframes, sizeof(pFlac->currentFLACFrame.subframes));
-    if (pFlac->currentFLACFrame.header.blockSizeInPCMFrames > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_ERROR;
-    }
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    if (channelCount != (int)pFlac->channels) {
-        return DRFLAC_ERROR;
-    }
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__decode_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i, pFlac->pDecodedSamples + (pFlac->currentFLACFrame.header.blockSizeInPCMFrames * i))) {
-            return DRFLAC_ERROR;
-        }
-    }
-    paddingSizeInBits = (drflac_uint8)(DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7);
-    if (paddingSizeInBits > 0) {
-        drflac_uint8 padding = 0;
-        if (!drflac__read_uint8(&pFlac->bs, paddingSizeInBits, &padding)) {
-            return DRFLAC_AT_END;
-        }
-    }
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;
-    }
-#endif
-    pFlac->currentFLACFrame.pcmFramesRemaining = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    return DRFLAC_SUCCESS;
-}
-static drflac_result drflac__seek_flac_frame(drflac* pFlac)
-{
-    int channelCount;
-    int i;
-    drflac_uint16 desiredCRC16;
-#ifndef DR_FLAC_NO_CRC
-    drflac_uint16 actualCRC16;
-#endif
-    channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-    for (i = 0; i < channelCount; ++i) {
-        if (!drflac__seek_subframe(&pFlac->bs, &pFlac->currentFLACFrame, i)) {
-            return DRFLAC_ERROR;
-        }
-    }
-    if (!drflac__seek_bits(&pFlac->bs, DRFLAC_CACHE_L1_BITS_REMAINING(&pFlac->bs) & 7)) {
-        return DRFLAC_ERROR;
-    }
-#ifndef DR_FLAC_NO_CRC
-    actualCRC16 = drflac__flush_crc16(&pFlac->bs);
-#endif
-    if (!drflac__read_uint16(&pFlac->bs, 16, &desiredCRC16)) {
-        return DRFLAC_AT_END;
-    }
-#ifndef DR_FLAC_NO_CRC
-    if (actualCRC16 != desiredCRC16) {
-        return DRFLAC_CRC_MISMATCH;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-static drflac_bool32 drflac__read_and_decode_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    for (;;) {
-        drflac_result result;
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-        result = drflac__decode_flac_frame(pFlac);
-        if (result != DRFLAC_SUCCESS) {
-            if (result == DRFLAC_CRC_MISMATCH) {
-                continue;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-        return DRFLAC_TRUE;
-    }
-}
-static void drflac__get_pcm_frame_range_of_current_flac_frame(drflac* pFlac, drflac_uint64* pFirstPCMFrame, drflac_uint64* pLastPCMFrame)
-{
-    drflac_uint64 firstPCMFrame;
-    drflac_uint64 lastPCMFrame;
-    DRFLAC_ASSERT(pFlac != NULL);
-    firstPCMFrame = pFlac->currentFLACFrame.header.pcmFrameNumber;
-    if (firstPCMFrame == 0) {
-        firstPCMFrame = ((drflac_uint64)pFlac->currentFLACFrame.header.flacFrameNumber) * pFlac->maxBlockSizeInPCMFrames;
-    }
-    lastPCMFrame = firstPCMFrame + pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-    if (lastPCMFrame > 0) {
-        lastPCMFrame -= 1;
-    }
-    if (pFirstPCMFrame) {
-        *pFirstPCMFrame = firstPCMFrame;
-    }
-    if (pLastPCMFrame) {
-        *pLastPCMFrame = lastPCMFrame;
-    }
-}
-static drflac_bool32 drflac__seek_to_first_frame(drflac* pFlac)
-{
-    drflac_bool32 result;
-    DRFLAC_ASSERT(pFlac != NULL);
-    result = drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes);
-    DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-    pFlac->currentPCMFrame = 0;
-    return result;
-}
-static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    return drflac__seek_flac_frame(pFlac);
-}
-static drflac_uint64 drflac__seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 pcmFramesToSeek)
-{
-    drflac_uint64 pcmFramesRead = 0;
-    while (pcmFramesToSeek > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            if (pFlac->currentFLACFrame.pcmFramesRemaining > pcmFramesToSeek) {
-                pcmFramesRead   += pcmFramesToSeek;
-                pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)pcmFramesToSeek;
-                pcmFramesToSeek  = 0;
-            } else {
-                pcmFramesRead   += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pcmFramesToSeek -= pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-            }
-        }
-    }
-    pFlac->currentPCMFrame += pcmFramesRead;
-    return pcmFramesRead;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__brute_force(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    DRFLAC_ASSERT(pFlac != NULL);
-    if (pcmFrameIndex >= pFlac->currentPCMFrame) {
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        runningPCMFrameCount = 0;
-        if (!drflac__seek_to_first_frame(pFlac)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-    next_iteration:
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-#if !defined(DR_FLAC_NO_CRC)
-#define DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO 0.6f
-static drflac_bool32 drflac__seek_to_approximate_flac_frame_to_byte(drflac* pFlac, drflac_uint64 targetByte, drflac_uint64 rangeLo, drflac_uint64 rangeHi, drflac_uint64* pLastSuccessfulSeekOffset)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pLastSuccessfulSeekOffset != NULL);
-    DRFLAC_ASSERT(targetByte >= rangeLo);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-    *pLastSuccessfulSeekOffset = pFlac->firstFLACFramePosInBytes;
-    for (;;) {
-        drflac_uint64 lastTargetByte = targetByte;
-        if (!drflac__seek_to_byte(&pFlac->bs, targetByte)) {
-            if (targetByte == 0) {
-                drflac__seek_to_first_frame(pFlac);
-                return DRFLAC_FALSE;
-            }
-            targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-            rangeHi = targetByte;
-        } else {
-            DRFLAC_ZERO_MEMORY(&pFlac->currentFLACFrame, sizeof(pFlac->currentFLACFrame));
-#if 1
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#else
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                targetByte = rangeLo + ((rangeHi - rangeLo)/2);
-                rangeHi = targetByte;
-            } else {
-                break;
-            }
-#endif
-        }
-        if(targetByte == lastTargetByte) {
-            return DRFLAC_FALSE;
-        }
-    }
-    drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-    DRFLAC_ASSERT(targetByte <= rangeHi);
-    *pLastSuccessfulSeekOffset = targetByte;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(drflac* pFlac, drflac_uint64 offset)
-{
-#if 0
-    if (drflac__decode_flac_frame(pFlac) != DRFLAC_SUCCESS) {
-        if (drflac__read_and_decode_next_flac_frame(pFlac) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-    }
-#endif
-    return drflac__seek_forward_by_pcm_frames(pFlac, offset) == offset;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search_internal(drflac* pFlac, drflac_uint64 pcmFrameIndex, drflac_uint64 byteRangeLo, drflac_uint64 byteRangeHi)
-{
-    drflac_uint64 targetByte;
-    drflac_uint64 pcmRangeLo = pFlac->totalPCMFrameCount;
-    drflac_uint64 pcmRangeHi = 0;
-    drflac_uint64 lastSuccessfulSeekOffset = (drflac_uint64)-1;
-    drflac_uint64 closestSeekOffsetBeforeTargetPCMFrame = byteRangeLo;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-    targetByte = byteRangeLo + (drflac_uint64)(((drflac_int64)((pcmFrameIndex - pFlac->currentPCMFrame) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * DRFLAC_BINARY_SEARCH_APPROX_COMPRESSION_RATIO);
-    if (targetByte > byteRangeHi) {
-        targetByte = byteRangeHi;
-    }
-    for (;;) {
-        if (drflac__seek_to_approximate_flac_frame_to_byte(pFlac, targetByte, byteRangeLo, byteRangeHi, &lastSuccessfulSeekOffset)) {
-            drflac_uint64 newPCMRangeLo;
-            drflac_uint64 newPCMRangeHi;
-            drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &newPCMRangeLo, &newPCMRangeHi);
-            if (pcmRangeLo == newPCMRangeLo) {
-                if (!drflac__seek_to_approximate_flac_frame_to_byte(pFlac, closestSeekOffsetBeforeTargetPCMFrame, closestSeekOffsetBeforeTargetPCMFrame, byteRangeHi, &lastSuccessfulSeekOffset)) {
-                    break;
-                }
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;
-                }
-            }
-            pcmRangeLo = newPCMRangeLo;
-            pcmRangeHi = newPCMRangeHi;
-            if (pcmRangeLo <= pcmFrameIndex && pcmRangeHi >= pcmFrameIndex) {
-                if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame) ) {
-                    return DRFLAC_TRUE;
-                } else {
-                    break;
-                }
-            } else {
-                const float approxCompressionRatio = (drflac_int64)(lastSuccessfulSeekOffset - pFlac->firstFLACFramePosInBytes) / ((drflac_int64)(pcmRangeLo * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-                if (pcmRangeLo > pcmFrameIndex) {
-                    byteRangeHi = lastSuccessfulSeekOffset;
-                    if (byteRangeLo > byteRangeHi) {
-                        byteRangeLo = byteRangeHi;
-                    }
-                    targetByte = byteRangeLo + ((byteRangeHi - byteRangeLo) / 2);
-                    if (targetByte < byteRangeLo) {
-                        targetByte = byteRangeLo;
-                    }
-                } else  {
-                    if ((pcmFrameIndex - pcmRangeLo) < seekForwardThreshold) {
-                        if (drflac__decode_flac_frame_and_seek_forward_by_pcm_frames(pFlac, pcmFrameIndex - pFlac->currentPCMFrame)) {
-                            return DRFLAC_TRUE;
-                        } else {
-                            break;
-                        }
-                    } else {
-                        byteRangeLo = lastSuccessfulSeekOffset;
-                        if (byteRangeHi < byteRangeLo) {
-                            byteRangeHi = byteRangeLo;
-                        }
-                        targetByte = lastSuccessfulSeekOffset + (drflac_uint64)(((drflac_int64)((pcmFrameIndex-pcmRangeLo) * pFlac->channels * pFlac->bitsPerSample)/8.0f) * approxCompressionRatio);
-                        if (targetByte > byteRangeHi) {
-                            targetByte = byteRangeHi;
-                        }
-                        if (closestSeekOffsetBeforeTargetPCMFrame < lastSuccessfulSeekOffset) {
-                            closestSeekOffsetBeforeTargetPCMFrame = lastSuccessfulSeekOffset;
-                        }
-                    }
-                }
-            }
-        } else {
-            break;
-        }
-    }
-    drflac__seek_to_first_frame(pFlac);
-    return DRFLAC_FALSE;
-}
-static drflac_bool32 drflac__seek_to_pcm_frame__binary_search(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint64 byteRangeLo;
-    drflac_uint64 byteRangeHi;
-    drflac_uint32 seekForwardThreshold = (pFlac->maxBlockSizeInPCMFrames != 0) ? pFlac->maxBlockSizeInPCMFrames*2 : 4096;
-    if (drflac__seek_to_first_frame(pFlac) == DRFLAC_FALSE) {
-        return DRFLAC_FALSE;
-    }
-    if (pcmFrameIndex < seekForwardThreshold) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, pcmFrameIndex) == pcmFrameIndex;
-    }
-    byteRangeLo = pFlac->firstFLACFramePosInBytes;
-    byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-    return drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi);
-}
-#endif
-static drflac_bool32 drflac__seek_to_pcm_frame__seek_table(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_uint32 iClosestSeekpoint = 0;
-    drflac_bool32 isMidFrame = DRFLAC_FALSE;
-    drflac_uint64 runningPCMFrameCount;
-    drflac_uint32 iSeekpoint;
-    DRFLAC_ASSERT(pFlac != NULL);
-    if (pFlac->pSeekpoints == NULL || pFlac->seekpointCount == 0) {
-        return DRFLAC_FALSE;
-    }
-    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-        if (pFlac->pSeekpoints[iSeekpoint].firstPCMFrame >= pcmFrameIndex) {
-            break;
-        }
-        iClosestSeekpoint = iSeekpoint;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount == 0 || pFlac->pSeekpoints[iClosestSeekpoint].pcmFrameCount > pFlac->maxBlockSizeInPCMFrames) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame > pFlac->totalPCMFrameCount && pFlac->totalPCMFrameCount > 0) {
-        return DRFLAC_FALSE;
-    }
-#if !defined(DR_FLAC_NO_CRC)
-    if (pFlac->totalPCMFrameCount > 0) {
-        drflac_uint64 byteRangeLo;
-        drflac_uint64 byteRangeHi;
-        byteRangeHi = pFlac->firstFLACFramePosInBytes + (drflac_uint64)((drflac_int64)(pFlac->totalPCMFrameCount * pFlac->channels * pFlac->bitsPerSample)/8.0f);
-        byteRangeLo = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset;
-        if (iClosestSeekpoint < pFlac->seekpointCount-1) {
-            drflac_uint32 iNextSeekpoint = iClosestSeekpoint + 1;
-            if (pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset >= pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset || pFlac->pSeekpoints[iNextSeekpoint].pcmFrameCount == 0) {
-                return DRFLAC_FALSE;
-            }
-            if (pFlac->pSeekpoints[iNextSeekpoint].firstPCMFrame != (((drflac_uint64)0xFFFFFFFF << 32) | 0xFFFFFFFF)) {
-                byteRangeHi = pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iNextSeekpoint].flacFrameOffset - 1;
-            }
-        }
-        if (drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            if (drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &pFlac->currentPCMFrame, NULL);
-                if (drflac__seek_to_pcm_frame__binary_search_internal(pFlac, pcmFrameIndex, byteRangeLo, byteRangeHi)) {
-                    return DRFLAC_TRUE;
-                }
-            }
-        }
-    }
-#endif
-    if (pcmFrameIndex >= pFlac->currentPCMFrame && pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame <= pFlac->currentPCMFrame) {
-        runningPCMFrameCount = pFlac->currentPCMFrame;
-        if (pFlac->currentPCMFrame == 0 && pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                return DRFLAC_FALSE;
-            }
-        } else {
-            isMidFrame = DRFLAC_TRUE;
-        }
-    } else {
-        runningPCMFrameCount = pFlac->pSeekpoints[iClosestSeekpoint].firstPCMFrame;
-        if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes + pFlac->pSeekpoints[iClosestSeekpoint].flacFrameOffset)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    for (;;) {
-        drflac_uint64 pcmFrameCountInThisFLACFrame;
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFLACFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFLACFrame)) {
-            drflac_uint64 pcmFramesToDecode = pcmFrameIndex - runningPCMFrameCount;
-            if (!isMidFrame) {
-                drflac_result result = drflac__decode_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            }
-        } else {
-            if (!isMidFrame) {
-                drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-                if (result == DRFLAC_SUCCESS) {
-                    runningPCMFrameCount += pcmFrameCountInThisFLACFrame;
-                } else {
-                    if (result == DRFLAC_CRC_MISMATCH) {
-                        goto next_iteration;
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                runningPCMFrameCount += pFlac->currentFLACFrame.pcmFramesRemaining;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                isMidFrame = DRFLAC_FALSE;
-            }
-            if (pcmFrameIndex == pFlac->totalPCMFrameCount && runningPCMFrameCount == pFlac->totalPCMFrameCount) {
-                return DRFLAC_TRUE;
-            }
-        }
-    next_iteration:
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-    }
-}
-#ifndef DR_FLAC_NO_OGG
-typedef struct
-{
-    drflac_uint8 capturePattern[4];
-    drflac_uint8 structureVersion;
-    drflac_uint8 headerType;
-    drflac_uint64 granulePosition;
-    drflac_uint32 serialNumber;
-    drflac_uint32 sequenceNumber;
-    drflac_uint32 checksum;
-    drflac_uint8 segmentCount;
-    drflac_uint8 segmentTable[255];
-} drflac_ogg_page_header;
-#endif
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    drflac_meta_proc onMeta;
-    drflac_container container;
-    void* pUserData;
-    void* pUserDataMD;
-    drflac_uint32 sampleRate;
-    drflac_uint8  channels;
-    drflac_uint8  bitsPerSample;
-    drflac_uint64 totalPCMFrameCount;
-    drflac_uint16 maxBlockSizeInPCMFrames;
-    drflac_uint64 runningFilePos;
-    drflac_bool32 hasStreamInfoBlock;
-    drflac_bool32 hasMetadataBlocks;
-    drflac_bs bs;
-    drflac_frame_header firstFrameHeader;
-#ifndef DR_FLAC_NO_OGG
-    drflac_uint32 oggSerial;
-    drflac_uint64 oggFirstBytePos;
-    drflac_ogg_page_header oggBosHeader;
-#endif
-} drflac_init_info;
-static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    blockHeader = drflac__be2host_32(blockHeader);
-    *isLastBlock = (drflac_uint8)((blockHeader & 0x80000000UL) >> 31);
-    *blockType   = (drflac_uint8)((blockHeader & 0x7F000000UL) >> 24);
-    *blockSize   =                (blockHeader & 0x00FFFFFFUL);
-}
-static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
-{
-    drflac_uint32 blockHeader;
-    *blockSize = 0;
-    if (onRead(pUserData, &blockHeader, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-    drflac__decode_block_header(blockHeader, isLastBlock, blockType, blockSize);
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__read_streaminfo(drflac_read_proc onRead, void* pUserData, drflac_streaminfo* pStreamInfo)
-{
-    drflac_uint32 blockSizes;
-    drflac_uint64 frameSizes = 0;
-    drflac_uint64 importantProps;
-    drflac_uint8 md5[16];
-    if (onRead(pUserData, &blockSizes, 4) != 4) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, &frameSizes, 6) != 6) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, &importantProps, 8) != 8) {
-        return DRFLAC_FALSE;
-    }
-    if (onRead(pUserData, md5, sizeof(md5)) != sizeof(md5)) {
-        return DRFLAC_FALSE;
-    }
-    blockSizes     = drflac__be2host_32(blockSizes);
-    frameSizes     = drflac__be2host_64(frameSizes);
-    importantProps = drflac__be2host_64(importantProps);
-    pStreamInfo->minBlockSizeInPCMFrames = (drflac_uint16)((blockSizes & 0xFFFF0000) >> 16);
-    pStreamInfo->maxBlockSizeInPCMFrames = (drflac_uint16) (blockSizes & 0x0000FFFF);
-    pStreamInfo->minFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) << 24)) >> 40);
-    pStreamInfo->maxFrameSizeInPCMFrames = (drflac_uint32)((frameSizes     &  (((drflac_uint64)0x00FFFFFF << 16) <<  0)) >> 16);
-    pStreamInfo->sampleRate              = (drflac_uint32)((importantProps &  (((drflac_uint64)0x000FFFFF << 16) << 28)) >> 44);
-    pStreamInfo->channels                = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000000E << 16) << 24)) >> 41) + 1;
-    pStreamInfo->bitsPerSample           = (drflac_uint8 )((importantProps &  (((drflac_uint64)0x0000001F << 16) << 20)) >> 36) + 1;
-    pStreamInfo->totalPCMFrameCount      =                ((importantProps & ((((drflac_uint64)0x0000000F << 16) << 16) | 0xFFFFFFFF)));
-    DRFLAC_COPY_MEMORY(pStreamInfo->md5, md5, sizeof(md5));
-    return DRFLAC_TRUE;
-}
-static void* drflac__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_MALLOC(sz);
-}
-static void* drflac__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRFLAC_REALLOC(p, sz);
-}
-static void drflac__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRFLAC_FREE(p);
-}
-static void* drflac__malloc_from_callbacks(size_t sz, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-static void* drflac__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRFLAC_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-static void drflac__free_from_callbacks(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-static drflac_bool32 drflac__read_and_decode_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_uint64* pFirstFramePos, drflac_uint64* pSeektablePos, drflac_uint32* pSeektableSize, drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_uint64 runningFilePos = 42;
-    drflac_uint64 seektablePos   = 0;
-    drflac_uint32 seektableSize  = 0;
-    for (;;) {
-        drflac_metadata metadata;
-        drflac_uint8 isLastBlock = 0;
-        drflac_uint8 blockType;
-        drflac_uint32 blockSize;
-        if (drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize) == DRFLAC_FALSE) {
-            return DRFLAC_FALSE;
-        }
-        runningFilePos += 4;
-        metadata.type = blockType;
-        metadata.pRawData = NULL;
-        metadata.rawDataSize = 0;
-        switch (blockType)
-        {
-            case DRFLAC_METADATA_BLOCK_TYPE_APPLICATION:
-            {
-                if (blockSize < 4) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.application.id       = drflac__be2host_32(*(drflac_uint32*)pRawData);
-                    metadata.data.application.pData    = (const void*)((drflac_uint8*)pRawData + sizeof(drflac_uint32));
-                    metadata.data.application.dataSize = blockSize - sizeof(drflac_uint32);
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_SEEKTABLE:
-            {
-                seektablePos  = runningFilePos;
-                seektableSize = blockSize;
-                if (onMeta) {
-                    drflac_uint32 iSeekpoint;
-                    void* pRawData;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    metadata.data.seektable.seekpointCount = blockSize/sizeof(drflac_seekpoint);
-                    metadata.data.seektable.pSeekpoints = (const drflac_seekpoint*)pRawData;
-                    for (iSeekpoint = 0; iSeekpoint < metadata.data.seektable.seekpointCount; ++iSeekpoint) {
-                        drflac_seekpoint* pSeekpoint = (drflac_seekpoint*)pRawData + iSeekpoint;
-                        pSeekpoint->firstPCMFrame   = drflac__be2host_64(pSeekpoint->firstPCMFrame);
-                        pSeekpoint->flacFrameOffset = drflac__be2host_64(pSeekpoint->flacFrameOffset);
-                        pSeekpoint->pcmFrameCount   = drflac__be2host_16(pSeekpoint->pcmFrameCount);
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_VORBIS_COMMENT:
-            {
-                if (blockSize < 8) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint32 i;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    metadata.data.vorbis_comment.vendorLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 4 < (drflac_int64)metadata.data.vorbis_comment.vendorLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.vendor       = pRunningData;                                            pRunningData += metadata.data.vorbis_comment.vendorLength;
-                    metadata.data.vorbis_comment.commentCount = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) / sizeof(drflac_uint32) < metadata.data.vorbis_comment.commentCount) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.vorbis_comment.pComments    = pRunningData;
-                    for (i = 0; i < metadata.data.vorbis_comment.commentCount; ++i) {
-                        drflac_uint32 commentLength;
-                        if (pRunningDataEnd - pRunningData < 4) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        commentLength = drflac__le2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)commentLength) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += commentLength;
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_CUESHEET:
-            {
-                if (blockSize < 396) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    drflac_uint8 iTrack;
-                    drflac_uint8 iIndex;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    DRFLAC_COPY_MEMORY(metadata.data.cuesheet.catalog, pRunningData, 128);                              pRunningData += 128;
-                    metadata.data.cuesheet.leadInSampleCount = drflac__be2host_64(*(const drflac_uint64*)pRunningData); pRunningData += 8;
-                    metadata.data.cuesheet.isCD              = (pRunningData[0] & 0x80) != 0;                           pRunningData += 259;
-                    metadata.data.cuesheet.trackCount        = pRunningData[0];                                         pRunningData += 1;
-                    metadata.data.cuesheet.pTrackData        = pRunningData;
-                    for (iTrack = 0; iTrack < metadata.data.cuesheet.trackCount; ++iTrack) {
-                        drflac_uint8 indexCount;
-                        drflac_uint32 indexPointSize;
-                        if (pRunningDataEnd - pRunningData < 36) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        pRunningData += 35;
-                        indexCount = pRunningData[0]; pRunningData += 1;
-                        indexPointSize = indexCount * sizeof(drflac_cuesheet_track_index);
-                        if (pRunningDataEnd - pRunningData < (drflac_int64)indexPointSize) {
-                            drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                            return DRFLAC_FALSE;
-                        }
-                        for (iIndex = 0; iIndex < indexCount; ++iIndex) {
-                            drflac_cuesheet_track_index* pTrack = (drflac_cuesheet_track_index*)pRunningData;
-                            pRunningData += sizeof(drflac_cuesheet_track_index);
-                            pTrack->offset = drflac__be2host_64(pTrack->offset);
-                        }
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_PICTURE:
-            {
-                if (blockSize < 32) {
-                    return DRFLAC_FALSE;
-                }
-                if (onMeta) {
-                    void* pRawData;
-                    const char* pRunningData;
-                    const char* pRunningDataEnd;
-                    pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    pRunningData    = (const char*)pRawData;
-                    pRunningDataEnd = (const char*)pRawData + blockSize;
-                    metadata.data.picture.type       = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.mimeLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 24 < (drflac_int64)metadata.data.picture.mimeLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.mime              = pRunningData;                                            pRunningData += metadata.data.picture.mimeLength;
-                    metadata.data.picture.descriptionLength = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    if ((pRunningDataEnd - pRunningData) - 20 < (drflac_int64)metadata.data.picture.descriptionLength) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.data.picture.description     = pRunningData;                                            pRunningData += metadata.data.picture.descriptionLength;
-                    metadata.data.picture.width           = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.height          = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.colorDepth      = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.indexColorCount = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pictureDataSize = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-                    metadata.data.picture.pPictureData    = (const drflac_uint8*)pRunningData;
-                    if (pRunningDataEnd - pRunningData < (drflac_int64)metadata.data.picture.pictureDataSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_PADDING:
-            {
-                if (onMeta) {
-                    metadata.data.padding.unused = 0;
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;
-                    } else {
-                        onMeta(pUserDataMD, &metadata);
-                    }
-                }
-            } break;
-            case DRFLAC_METADATA_BLOCK_TYPE_INVALID:
-            {
-                if (onMeta) {
-                    if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                        isLastBlock = DRFLAC_TRUE;
-                    }
-                }
-            } break;
-            default:
-            {
-                if (onMeta) {
-                    void* pRawData = drflac__malloc_from_callbacks(blockSize, pAllocationCallbacks);
-                    if (pRawData == NULL) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, pRawData, blockSize) != blockSize) {
-                        drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                        return DRFLAC_FALSE;
-                    }
-                    metadata.pRawData = pRawData;
-                    metadata.rawDataSize = blockSize;
-                    onMeta(pUserDataMD, &metadata);
-                    drflac__free_from_callbacks(pRawData, pAllocationCallbacks);
-                }
-            } break;
-        }
-        if (onMeta == NULL && blockSize > 0) {
-            if (!onSeek(pUserData, blockSize, drflac_seek_origin_current)) {
-                isLastBlock = DRFLAC_TRUE;
-            }
-        }
-        runningFilePos += blockSize;
-        if (isLastBlock) {
-            break;
-        }
-    }
-    *pSeektablePos = seektablePos;
-    *pSeektableSize = seektableSize;
-    *pFirstFramePos = runningFilePos;
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac__init_private__native(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_uint8 isLastBlock;
-    drflac_uint8 blockType;
-    drflac_uint32 blockSize;
-    (void)onSeek;
-    pInit->container = drflac_container_native;
-    if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-        return DRFLAC_FALSE;
-    }
-    if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-        if (!relaxed) {
-            return DRFLAC_FALSE;
-        } else {
-            pInit->hasStreamInfoBlock = DRFLAC_FALSE;
-            pInit->hasMetadataBlocks  = DRFLAC_FALSE;
-            if (!drflac__read_next_flac_frame_header(&pInit->bs, 0, &pInit->firstFrameHeader)) {
-                return DRFLAC_FALSE;
-            }
-            if (pInit->firstFrameHeader.bitsPerSample == 0) {
-                return DRFLAC_FALSE;
-            }
-            pInit->sampleRate              = pInit->firstFrameHeader.sampleRate;
-            pInit->channels                = drflac__get_channel_count_from_channel_assignment(pInit->firstFrameHeader.channelAssignment);
-            pInit->bitsPerSample           = pInit->firstFrameHeader.bitsPerSample;
-            pInit->maxBlockSizeInPCMFrames = 65535;
-            return DRFLAC_TRUE;
-        }
-    } else {
-        drflac_streaminfo streaminfo;
-        if (!drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-            return DRFLAC_FALSE;
-        }
-        pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-        pInit->sampleRate              = streaminfo.sampleRate;
-        pInit->channels                = streaminfo.channels;
-        pInit->bitsPerSample           = streaminfo.bitsPerSample;
-        pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-        pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-        pInit->hasMetadataBlocks       = !isLastBlock;
-        if (onMeta) {
-            drflac_metadata metadata;
-            metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-            metadata.pRawData = NULL;
-            metadata.rawDataSize = 0;
-            metadata.data.streaminfo = streaminfo;
-            onMeta(pUserDataMD, &metadata);
-        }
-        return DRFLAC_TRUE;
-    }
-}
-#ifndef DR_FLAC_NO_OGG
-#define DRFLAC_OGG_MAX_PAGE_SIZE            65307
-#define DRFLAC_OGG_CAPTURE_PATTERN_CRC32    1605413199
-typedef enum
-{
-    drflac_ogg_recover_on_crc_mismatch,
-    drflac_ogg_fail_on_crc_mismatch
-} drflac_ogg_crc_mismatch_recovery;
-#ifndef DR_FLAC_NO_CRC
-static drflac_uint32 drflac__crc32_table[] = {
-    0x00000000L, 0x04C11DB7L, 0x09823B6EL, 0x0D4326D9L,
-    0x130476DCL, 0x17C56B6BL, 0x1A864DB2L, 0x1E475005L,
-    0x2608EDB8L, 0x22C9F00FL, 0x2F8AD6D6L, 0x2B4BCB61L,
-    0x350C9B64L, 0x31CD86D3L, 0x3C8EA00AL, 0x384FBDBDL,
-    0x4C11DB70L, 0x48D0C6C7L, 0x4593E01EL, 0x4152FDA9L,
-    0x5F15ADACL, 0x5BD4B01BL, 0x569796C2L, 0x52568B75L,
-    0x6A1936C8L, 0x6ED82B7FL, 0x639B0DA6L, 0x675A1011L,
-    0x791D4014L, 0x7DDC5DA3L, 0x709F7B7AL, 0x745E66CDL,
-    0x9823B6E0L, 0x9CE2AB57L, 0x91A18D8EL, 0x95609039L,
-    0x8B27C03CL, 0x8FE6DD8BL, 0x82A5FB52L, 0x8664E6E5L,
-    0xBE2B5B58L, 0xBAEA46EFL, 0xB7A96036L, 0xB3687D81L,
-    0xAD2F2D84L, 0xA9EE3033L, 0xA4AD16EAL, 0xA06C0B5DL,
-    0xD4326D90L, 0xD0F37027L, 0xDDB056FEL, 0xD9714B49L,
-    0xC7361B4CL, 0xC3F706FBL, 0xCEB42022L, 0xCA753D95L,
-    0xF23A8028L, 0xF6FB9D9FL, 0xFBB8BB46L, 0xFF79A6F1L,
-    0xE13EF6F4L, 0xE5FFEB43L, 0xE8BCCD9AL, 0xEC7DD02DL,
-    0x34867077L, 0x30476DC0L, 0x3D044B19L, 0x39C556AEL,
-    0x278206ABL, 0x23431B1CL, 0x2E003DC5L, 0x2AC12072L,
-    0x128E9DCFL, 0x164F8078L, 0x1B0CA6A1L, 0x1FCDBB16L,
-    0x018AEB13L, 0x054BF6A4L, 0x0808D07DL, 0x0CC9CDCAL,
-    0x7897AB07L, 0x7C56B6B0L, 0x71159069L, 0x75D48DDEL,
-    0x6B93DDDBL, 0x6F52C06CL, 0x6211E6B5L, 0x66D0FB02L,
-    0x5E9F46BFL, 0x5A5E5B08L, 0x571D7DD1L, 0x53DC6066L,
-    0x4D9B3063L, 0x495A2DD4L, 0x44190B0DL, 0x40D816BAL,
-    0xACA5C697L, 0xA864DB20L, 0xA527FDF9L, 0xA1E6E04EL,
-    0xBFA1B04BL, 0xBB60ADFCL, 0xB6238B25L, 0xB2E29692L,
-    0x8AAD2B2FL, 0x8E6C3698L, 0x832F1041L, 0x87EE0DF6L,
-    0x99A95DF3L, 0x9D684044L, 0x902B669DL, 0x94EA7B2AL,
-    0xE0B41DE7L, 0xE4750050L, 0xE9362689L, 0xEDF73B3EL,
-    0xF3B06B3BL, 0xF771768CL, 0xFA325055L, 0xFEF34DE2L,
-    0xC6BCF05FL, 0xC27DEDE8L, 0xCF3ECB31L, 0xCBFFD686L,
-    0xD5B88683L, 0xD1799B34L, 0xDC3ABDEDL, 0xD8FBA05AL,
-    0x690CE0EEL, 0x6DCDFD59L, 0x608EDB80L, 0x644FC637L,
-    0x7A089632L, 0x7EC98B85L, 0x738AAD5CL, 0x774BB0EBL,
-    0x4F040D56L, 0x4BC510E1L, 0x46863638L, 0x42472B8FL,
-    0x5C007B8AL, 0x58C1663DL, 0x558240E4L, 0x51435D53L,
-    0x251D3B9EL, 0x21DC2629L, 0x2C9F00F0L, 0x285E1D47L,
-    0x36194D42L, 0x32D850F5L, 0x3F9B762CL, 0x3B5A6B9BL,
-    0x0315D626L, 0x07D4CB91L, 0x0A97ED48L, 0x0E56F0FFL,
-    0x1011A0FAL, 0x14D0BD4DL, 0x19939B94L, 0x1D528623L,
-    0xF12F560EL, 0xF5EE4BB9L, 0xF8AD6D60L, 0xFC6C70D7L,
-    0xE22B20D2L, 0xE6EA3D65L, 0xEBA91BBCL, 0xEF68060BL,
-    0xD727BBB6L, 0xD3E6A601L, 0xDEA580D8L, 0xDA649D6FL,
-    0xC423CD6AL, 0xC0E2D0DDL, 0xCDA1F604L, 0xC960EBB3L,
-    0xBD3E8D7EL, 0xB9FF90C9L, 0xB4BCB610L, 0xB07DABA7L,
-    0xAE3AFBA2L, 0xAAFBE615L, 0xA7B8C0CCL, 0xA379DD7BL,
-    0x9B3660C6L, 0x9FF77D71L, 0x92B45BA8L, 0x9675461FL,
-    0x8832161AL, 0x8CF30BADL, 0x81B02D74L, 0x857130C3L,
-    0x5D8A9099L, 0x594B8D2EL, 0x5408ABF7L, 0x50C9B640L,
-    0x4E8EE645L, 0x4A4FFBF2L, 0x470CDD2BL, 0x43CDC09CL,
-    0x7B827D21L, 0x7F436096L, 0x7200464FL, 0x76C15BF8L,
-    0x68860BFDL, 0x6C47164AL, 0x61043093L, 0x65C52D24L,
-    0x119B4BE9L, 0x155A565EL, 0x18197087L, 0x1CD86D30L,
-    0x029F3D35L, 0x065E2082L, 0x0B1D065BL, 0x0FDC1BECL,
-    0x3793A651L, 0x3352BBE6L, 0x3E119D3FL, 0x3AD08088L,
-    0x2497D08DL, 0x2056CD3AL, 0x2D15EBE3L, 0x29D4F654L,
-    0xC5A92679L, 0xC1683BCEL, 0xCC2B1D17L, 0xC8EA00A0L,
-    0xD6AD50A5L, 0xD26C4D12L, 0xDF2F6BCBL, 0xDBEE767CL,
-    0xE3A1CBC1L, 0xE760D676L, 0xEA23F0AFL, 0xEEE2ED18L,
-    0xF0A5BD1DL, 0xF464A0AAL, 0xF9278673L, 0xFDE69BC4L,
-    0x89B8FD09L, 0x8D79E0BEL, 0x803AC667L, 0x84FBDBD0L,
-    0x9ABC8BD5L, 0x9E7D9662L, 0x933EB0BBL, 0x97FFAD0CL,
-    0xAFB010B1L, 0xAB710D06L, 0xA6322BDFL, 0xA2F33668L,
-    0xBCB4666DL, 0xB8757BDAL, 0xB5365D03L, 0xB1F740B4L
-};
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
-{
-#ifndef DR_FLAC_NO_CRC
-    return (crc32 << 8) ^ drflac__crc32_table[(drflac_uint8)((crc32 >> 24) & 0xFF) ^ data];
-#else
-    (void)data;
-    return crc32;
-#endif
-}
-#if 0
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint32(drflac_uint32 crc32, drflac_uint32 data)
-{
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 24) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >> 16) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  8) & 0xFF));
-    crc32 = drflac_crc32_byte(crc32, (drflac_uint8)((data >>  0) & 0xFF));
-    return crc32;
-}
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_uint64(drflac_uint32 crc32, drflac_uint64 data)
-{
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >> 32) & 0xFFFFFFFF));
-    crc32 = drflac_crc32_uint32(crc32, (drflac_uint32)((data >>  0) & 0xFFFFFFFF));
-    return crc32;
-}
-#endif
-static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
-{
-    drflac_uint32 i;
-    for (i = 0; i < dataSize; ++i) {
-        crc32 = drflac_crc32_byte(crc32, pData[i]);
-    }
-    return crc32;
-}
-static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
-{
-    return pattern[0] == 'O' && pattern[1] == 'g' && pattern[2] == 'g' && pattern[3] == 'S';
-}
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
-{
-    return 27 + pHeader->segmentCount;
-}
-static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
-{
-    drflac_uint32 pageBodySize = 0;
-    int i;
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        pageBodySize += pHeader->segmentTable[i];
-    }
-    return pageBodySize;
-}
-static drflac_result drflac_ogg__read_page_header_after_capture_pattern(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 data[23];
-    drflac_uint32 i;
-    DRFLAC_ASSERT(*pCRC32 == DRFLAC_OGG_CAPTURE_PATTERN_CRC32);
-    if (onRead(pUserData, data, 23) != 23) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 23;
-    pHeader->capturePattern[0] = 'O';
-    pHeader->capturePattern[1] = 'g';
-    pHeader->capturePattern[2] = 'g';
-    pHeader->capturePattern[3] = 'S';
-    pHeader->structureVersion = data[0];
-    pHeader->headerType       = data[1];
-    DRFLAC_COPY_MEMORY(&pHeader->granulePosition, &data[ 2], 8);
-    DRFLAC_COPY_MEMORY(&pHeader->serialNumber,    &data[10], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->sequenceNumber,  &data[14], 4);
-    DRFLAC_COPY_MEMORY(&pHeader->checksum,        &data[18], 4);
-    pHeader->segmentCount     = data[22];
-    data[18] = 0;
-    data[19] = 0;
-    data[20] = 0;
-    data[21] = 0;
-    for (i = 0; i < 23; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, data[i]);
-    }
-    if (onRead(pUserData, pHeader->segmentTable, pHeader->segmentCount) != pHeader->segmentCount) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += pHeader->segmentCount;
-    for (i = 0; i < pHeader->segmentCount; ++i) {
-        *pCRC32 = drflac_crc32_byte(*pCRC32, pHeader->segmentTable[i]);
-    }
-    return DRFLAC_SUCCESS;
-}
-static drflac_result drflac_ogg__read_page_header(drflac_read_proc onRead, void* pUserData, drflac_ogg_page_header* pHeader, drflac_uint32* pBytesRead, drflac_uint32* pCRC32)
-{
-    drflac_uint8 id[4];
-    *pBytesRead = 0;
-    if (onRead(pUserData, id, 4) != 4) {
-        return DRFLAC_AT_END;
-    }
-    *pBytesRead += 4;
-    for (;;) {
-        if (drflac_ogg__is_capture_pattern(id)) {
-            drflac_result result;
-            *pCRC32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-            result = drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, pHeader, pBytesRead, pCRC32);
-            if (result == DRFLAC_SUCCESS) {
-                return DRFLAC_SUCCESS;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return result;
-                }
-            }
-        } else {
-            id[0] = id[1];
-            id[1] = id[2];
-            id[2] = id[3];
-            if (onRead(pUserData, &id[3], 1) != 1) {
-                return DRFLAC_AT_END;
-            }
-            *pBytesRead += 1;
-        }
-    }
-}
-typedef struct
-{
-    drflac_read_proc onRead;
-    drflac_seek_proc onSeek;
-    void* pUserData;
-    drflac_uint64 currentBytePos;
-    drflac_uint64 firstBytePos;
-    drflac_uint32 serialNumber;
-    drflac_ogg_page_header bosPageHeader;
-    drflac_ogg_page_header currentPageHeader;
-    drflac_uint32 bytesRemainingInPage;
-    drflac_uint32 pageDataSize;
-    drflac_uint8 pageData[DRFLAC_OGG_MAX_PAGE_SIZE];
-} drflac_oggbs;
-static size_t drflac_oggbs__read_physical(drflac_oggbs* oggbs, void* bufferOut, size_t bytesToRead)
-{
-    size_t bytesActuallyRead = oggbs->onRead(oggbs->pUserData, bufferOut, bytesToRead);
-    oggbs->currentBytePos += bytesActuallyRead;
-    return bytesActuallyRead;
-}
-static drflac_bool32 drflac_oggbs__seek_physical(drflac_oggbs* oggbs, drflac_uint64 offset, drflac_seek_origin origin)
-{
-    if (origin == drflac_seek_origin_start) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-            return DRFLAC_TRUE;
-        } else {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_start)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos = offset;
-            return drflac_oggbs__seek_physical(oggbs, offset - 0x7FFFFFFF, drflac_seek_origin_current);
-        }
-    } else {
-        while (offset > 0x7FFFFFFF) {
-            if (!oggbs->onSeek(oggbs->pUserData, 0x7FFFFFFF, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            oggbs->currentBytePos += 0x7FFFFFFF;
-            offset -= 0x7FFFFFFF;
-        }
-        if (!oggbs->onSeek(oggbs->pUserData, (int)offset, drflac_seek_origin_current)) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += offset;
-        return DRFLAC_TRUE;
-    }
-}
-static drflac_bool32 drflac_oggbs__goto_next_page(drflac_oggbs* oggbs, drflac_ogg_crc_mismatch_recovery recoveryMethod)
-{
-    drflac_ogg_page_header header;
-    for (;;) {
-        drflac_uint32 crc32 = 0;
-        drflac_uint32 bytesRead;
-        drflac_uint32 pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        drflac_uint32 actualCRC32;
-#endif
-        if (drflac_ogg__read_page_header(oggbs->onRead, oggbs->pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->currentBytePos += bytesRead;
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize > DRFLAC_OGG_MAX_PAGE_SIZE) {
-            continue;
-        }
-        if (header.serialNumber != oggbs->serialNumber) {
-            if (pageBodySize > 0 && !drflac_oggbs__seek_physical(oggbs, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            continue;
-        }
-        if (drflac_oggbs__read_physical(oggbs, oggbs->pageData, pageBodySize) != pageBodySize) {
-            return DRFLAC_FALSE;
-        }
-        oggbs->pageDataSize = pageBodySize;
-#ifndef DR_FLAC_NO_CRC
-        actualCRC32 = drflac_crc32_buffer(crc32, oggbs->pageData, oggbs->pageDataSize);
-        if (actualCRC32 != header.checksum) {
-            if (recoveryMethod == drflac_ogg_recover_on_crc_mismatch) {
-                continue;
-            } else {
-                drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch);
-                return DRFLAC_FALSE;
-            }
-        }
-#else
-        (void)recoveryMethod;
-#endif
-        oggbs->currentPageHeader = header;
-        oggbs->bytesRemainingInPage = pageBodySize;
-        return DRFLAC_TRUE;
-    }
-}
-#if 0
-static drflac_uint8 drflac_oggbs__get_current_segment_index(drflac_oggbs* oggbs, drflac_uint8* pBytesRemainingInSeg)
-{
-    drflac_uint32 bytesConsumedInPage = drflac_ogg__get_page_body_size(&oggbs->currentPageHeader) - oggbs->bytesRemainingInPage;
-    drflac_uint8 iSeg = 0;
-    drflac_uint32 iByte = 0;
-    while (iByte < bytesConsumedInPage) {
-        drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-        if (iByte + segmentSize > bytesConsumedInPage) {
-            break;
-        } else {
-            iSeg += 1;
-            iByte += segmentSize;
-        }
-    }
-    *pBytesRemainingInSeg = oggbs->currentPageHeader.segmentTable[iSeg] - (drflac_uint8)(bytesConsumedInPage - iByte);
-    return iSeg;
-}
-static drflac_bool32 drflac_oggbs__seek_to_next_packet(drflac_oggbs* oggbs)
-{
-    for (;;) {
-        drflac_bool32 atEndOfPage = DRFLAC_FALSE;
-        drflac_uint8 bytesRemainingInSeg;
-        drflac_uint8 iFirstSeg = drflac_oggbs__get_current_segment_index(oggbs, &bytesRemainingInSeg);
-        drflac_uint32 bytesToEndOfPacketOrPage = bytesRemainingInSeg;
-        for (drflac_uint8 iSeg = iFirstSeg; iSeg < oggbs->currentPageHeader.segmentCount; ++iSeg) {
-            drflac_uint8 segmentSize = oggbs->currentPageHeader.segmentTable[iSeg];
-            if (segmentSize < 255) {
-                if (iSeg == oggbs->currentPageHeader.segmentCount-1) {
-                    atEndOfPage = DRFLAC_TRUE;
-                }
-                break;
-            }
-            bytesToEndOfPacketOrPage += segmentSize;
-        }
-        drflac_oggbs__seek_physical(oggbs, bytesToEndOfPacketOrPage, drflac_seek_origin_current);
-        oggbs->bytesRemainingInPage -= bytesToEndOfPacketOrPage;
-        if (atEndOfPage) {
-            if (!drflac_oggbs__goto_next_page(oggbs)) {
-                return DRFLAC_FALSE;
-            }
-            if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-                return DRFLAC_TRUE;
-            }
-        } else {
-            return DRFLAC_TRUE;
-        }
-    }
-}
-static drflac_bool32 drflac_oggbs__seek_to_next_frame(drflac_oggbs* oggbs)
-{
-    return drflac_oggbs__seek_to_next_packet(oggbs);
-}
-#endif
-static size_t drflac__on_read_ogg(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    drflac_uint8* pRunningBufferOut = (drflac_uint8*)bufferOut;
-    size_t bytesRead = 0;
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(pRunningBufferOut != NULL);
-    while (bytesRead < bytesToRead) {
-        size_t bytesRemainingToRead = bytesToRead - bytesRead;
-        if (oggbs->bytesRemainingInPage >= bytesRemainingToRead) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), bytesRemainingToRead);
-            bytesRead += bytesRemainingToRead;
-            oggbs->bytesRemainingInPage -= (drflac_uint32)bytesRemainingToRead;
-            break;
-        }
-        if (oggbs->bytesRemainingInPage > 0) {
-            DRFLAC_COPY_MEMORY(pRunningBufferOut, oggbs->pageData + (oggbs->pageDataSize - oggbs->bytesRemainingInPage), oggbs->bytesRemainingInPage);
-            bytesRead += oggbs->bytesRemainingInPage;
-            pRunningBufferOut += oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-        DRFLAC_ASSERT(bytesRemainingToRead > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            break;
-        }
-    }
-    return bytesRead;
-}
-static drflac_bool32 drflac__on_seek_ogg(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pUserData;
-    int bytesSeeked = 0;
-    DRFLAC_ASSERT(oggbs != NULL);
-    DRFLAC_ASSERT(offset >= 0);
-    if (origin == drflac_seek_origin_start) {
-        if (!drflac_oggbs__seek_physical(oggbs, (int)oggbs->firstBytePos, drflac_seek_origin_start)) {
-            return DRFLAC_FALSE;
-        }
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-        return drflac__on_seek_ogg(pUserData, offset, drflac_seek_origin_current);
-    }
-    DRFLAC_ASSERT(origin == drflac_seek_origin_current);
-    while (bytesSeeked < offset) {
-        int bytesRemainingToSeek = offset - bytesSeeked;
-        DRFLAC_ASSERT(bytesRemainingToSeek >= 0);
-        if (oggbs->bytesRemainingInPage >= (size_t)bytesRemainingToSeek) {
-            bytesSeeked += bytesRemainingToSeek;
-            (void)bytesSeeked;
-            oggbs->bytesRemainingInPage -= bytesRemainingToSeek;
-            break;
-        }
-        if (oggbs->bytesRemainingInPage > 0) {
-            bytesSeeked += (int)oggbs->bytesRemainingInPage;
-            oggbs->bytesRemainingInPage = 0;
-        }
-        DRFLAC_ASSERT(bytesRemainingToSeek > 0);
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_fail_on_crc_mismatch)) {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-static drflac_bool32 drflac_ogg__seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-    drflac_uint64 originalBytePos;
-    drflac_uint64 runningGranulePosition;
-    drflac_uint64 runningFrameBytePos;
-    drflac_uint64 runningPCMFrameCount;
-    DRFLAC_ASSERT(oggbs != NULL);
-    originalBytePos = oggbs->currentBytePos;
-    if (!drflac__seek_to_byte(&pFlac->bs, pFlac->firstFLACFramePosInBytes)) {
-        return DRFLAC_FALSE;
-    }
-    oggbs->bytesRemainingInPage = 0;
-    runningGranulePosition = 0;
-    for (;;) {
-        if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-            drflac_oggbs__seek_physical(oggbs, originalBytePos, drflac_seek_origin_start);
-            return DRFLAC_FALSE;
-        }
-        runningFrameBytePos = oggbs->currentBytePos - drflac_ogg__get_page_header_size(&oggbs->currentPageHeader) - oggbs->pageDataSize;
-        if (oggbs->currentPageHeader.granulePosition >= pcmFrameIndex) {
-            break;
-        }
-        if ((oggbs->currentPageHeader.headerType & 0x01) == 0) {
-            if (oggbs->currentPageHeader.segmentTable[0] >= 2) {
-                drflac_uint8 firstBytesInPage[2];
-                firstBytesInPage[0] = oggbs->pageData[0];
-                firstBytesInPage[1] = oggbs->pageData[1];
-                if ((firstBytesInPage[0] == 0xFF) && (firstBytesInPage[1] & 0xFC) == 0xF8) {
-                    runningGranulePosition = oggbs->currentPageHeader.granulePosition;
-                }
-                continue;
-            }
-        }
-    }
-    if (!drflac_oggbs__seek_physical(oggbs, runningFrameBytePos, drflac_seek_origin_start)) {
-        return DRFLAC_FALSE;
-    }
-    if (!drflac_oggbs__goto_next_page(oggbs, drflac_ogg_recover_on_crc_mismatch)) {
-        return DRFLAC_FALSE;
-    }
-    runningPCMFrameCount = runningGranulePosition;
-    for (;;) {
-        drflac_uint64 firstPCMFrameInFLACFrame = 0;
-        drflac_uint64 lastPCMFrameInFLACFrame = 0;
-        drflac_uint64 pcmFrameCountInThisFrame;
-        if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-            return DRFLAC_FALSE;
-        }
-        drflac__get_pcm_frame_range_of_current_flac_frame(pFlac, &firstPCMFrameInFLACFrame, &lastPCMFrameInFLACFrame);
-        pcmFrameCountInThisFrame = (lastPCMFrameInFLACFrame - firstPCMFrameInFLACFrame) + 1;
-        if (pcmFrameIndex == pFlac->totalPCMFrameCount && (runningPCMFrameCount + pcmFrameCountInThisFrame) == pFlac->totalPCMFrameCount) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                pFlac->currentFLACFrame.pcmFramesRemaining = 0;
-                return DRFLAC_TRUE;
-            } else {
-                return DRFLAC_FALSE;
-            }
-        }
-        if (pcmFrameIndex < (runningPCMFrameCount + pcmFrameCountInThisFrame)) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                drflac_uint64 pcmFramesToDecode = (size_t)(pcmFrameIndex - runningPCMFrameCount);
-                if (pcmFramesToDecode == 0) {
-                    return DRFLAC_TRUE;
-                }
-                pFlac->currentPCMFrame = runningPCMFrameCount;
-                return drflac__seek_forward_by_pcm_frames(pFlac, pcmFramesToDecode) == pcmFramesToDecode;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            drflac_result result = drflac__seek_to_next_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                runningPCMFrameCount += pcmFrameCountInThisFrame;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    continue;
-                } else {
-                    return DRFLAC_FALSE;
-                }
-            }
-        }
-    }
-}
-static drflac_bool32 drflac__init_private__ogg(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, void* pUserDataMD, drflac_bool32 relaxed)
-{
-    drflac_ogg_page_header header;
-    drflac_uint32 crc32 = DRFLAC_OGG_CAPTURE_PATTERN_CRC32;
-    drflac_uint32 bytesRead = 0;
-    (void)relaxed;
-    pInit->container = drflac_container_ogg;
-    pInit->oggFirstBytePos = 0;
-    if (drflac_ogg__read_page_header_after_capture_pattern(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-        return DRFLAC_FALSE;
-    }
-    pInit->runningFilePos += bytesRead;
-    for (;;) {
-        int pageBodySize;
-        if ((header.headerType & 0x02) == 0) {
-            return DRFLAC_FALSE;
-        }
-        pageBodySize = drflac_ogg__get_page_body_size(&header);
-        if (pageBodySize == 51) {
-            drflac_uint32 bytesRemainingInPage = pageBodySize;
-            drflac_uint8 packetType;
-            if (onRead(pUserData, &packetType, 1) != 1) {
-                return DRFLAC_FALSE;
-            }
-            bytesRemainingInPage -= 1;
-            if (packetType == 0x7F) {
-                drflac_uint8 sig[4];
-                if (onRead(pUserData, sig, 4) != 4) {
-                    return DRFLAC_FALSE;
-                }
-                bytesRemainingInPage -= 4;
-                if (sig[0] == 'F' && sig[1] == 'L' && sig[2] == 'A' && sig[3] == 'C') {
-                    drflac_uint8 mappingVersion[2];
-                    if (onRead(pUserData, mappingVersion, 2) != 2) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (mappingVersion[0] != 1) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (!onSeek(pUserData, 2, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (onRead(pUserData, sig, 4) != 4) {
-                        return DRFLAC_FALSE;
-                    }
-                    if (sig[0] == 'f' && sig[1] == 'L' && sig[2] == 'a' && sig[3] == 'C') {
-                        drflac_streaminfo streaminfo;
-                        drflac_uint8 isLastBlock;
-                        drflac_uint8 blockType;
-                        drflac_uint32 blockSize;
-                        if (!drflac__read_and_decode_block_header(onRead, pUserData, &isLastBlock, &blockType, &blockSize)) {
-                            return DRFLAC_FALSE;
-                        }
-                        if (blockType != DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO || blockSize != 34) {
-                            return DRFLAC_FALSE;
-                        }
-                        if (drflac__read_streaminfo(onRead, pUserData, &streaminfo)) {
-                            pInit->hasStreamInfoBlock      = DRFLAC_TRUE;
-                            pInit->sampleRate              = streaminfo.sampleRate;
-                            pInit->channels                = streaminfo.channels;
-                            pInit->bitsPerSample           = streaminfo.bitsPerSample;
-                            pInit->totalPCMFrameCount      = streaminfo.totalPCMFrameCount;
-                            pInit->maxBlockSizeInPCMFrames = streaminfo.maxBlockSizeInPCMFrames;
-                            pInit->hasMetadataBlocks       = !isLastBlock;
-                            if (onMeta) {
-                                drflac_metadata metadata;
-                                metadata.type = DRFLAC_METADATA_BLOCK_TYPE_STREAMINFO;
-                                metadata.pRawData = NULL;
-                                metadata.rawDataSize = 0;
-                                metadata.data.streaminfo = streaminfo;
-                                onMeta(pUserDataMD, &metadata);
-                            }
-                            pInit->runningFilePos  += pageBodySize;
-                            pInit->oggFirstBytePos  = pInit->runningFilePos - 79;
-                            pInit->oggSerial        = header.serialNumber;
-                            pInit->oggBosHeader     = header;
-                            break;
-                        } else {
-                            return DRFLAC_FALSE;
-                        }
-                    } else {
-                        return DRFLAC_FALSE;
-                    }
-                } else {
-                    if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                        return DRFLAC_FALSE;
-                    }
-                }
-            } else {
-                if (!onSeek(pUserData, bytesRemainingInPage, drflac_seek_origin_current)) {
-                    return DRFLAC_FALSE;
-                }
-            }
-        } else {
-            if (!onSeek(pUserData, pageBodySize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-        }
-        pInit->runningFilePos += pageBodySize;
-        if (drflac_ogg__read_page_header(onRead, pUserData, &header, &bytesRead, &crc32) != DRFLAC_SUCCESS) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += bytesRead;
-    }
-    pInit->hasMetadataBlocks = DRFLAC_TRUE;
-    return DRFLAC_TRUE;
-}
-#endif
-static drflac_bool32 drflac__init_private(drflac_init_info* pInit, drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD)
-{
-    drflac_bool32 relaxed;
-    drflac_uint8 id[4];
-    if (pInit == NULL || onRead == NULL || onSeek == NULL) {
-        return DRFLAC_FALSE;
-    }
-    DRFLAC_ZERO_MEMORY(pInit, sizeof(*pInit));
-    pInit->onRead       = onRead;
-    pInit->onSeek       = onSeek;
-    pInit->onMeta       = onMeta;
-    pInit->container    = container;
-    pInit->pUserData    = pUserData;
-    pInit->pUserDataMD  = pUserDataMD;
-    pInit->bs.onRead    = onRead;
-    pInit->bs.onSeek    = onSeek;
-    pInit->bs.pUserData = pUserData;
-    drflac__reset_cache(&pInit->bs);
-    relaxed = container != drflac_container_unknown;
-    for (;;) {
-        if (onRead(pUserData, id, 4) != 4) {
-            return DRFLAC_FALSE;
-        }
-        pInit->runningFilePos += 4;
-        if (id[0] == 'I' && id[1] == 'D' && id[2] == '3') {
-            drflac_uint8 header[6];
-            drflac_uint8 flags;
-            drflac_uint32 headerSize;
-            if (onRead(pUserData, header, 6) != 6) {
-                return DRFLAC_FALSE;
-            }
-            pInit->runningFilePos += 6;
-            flags = header[1];
-            DRFLAC_COPY_MEMORY(&headerSize, header+2, 4);
-            headerSize = drflac__unsynchsafe_32(drflac__be2host_32(headerSize));
-            if (flags & 0x10) {
-                headerSize += 10;
-            }
-            if (!onSeek(pUserData, headerSize, drflac_seek_origin_current)) {
-                return DRFLAC_FALSE;
-            }
-            pInit->runningFilePos += headerSize;
-        } else {
-            break;
-        }
-    }
-    if (id[0] == 'f' && id[1] == 'L' && id[2] == 'a' && id[3] == 'C') {
-        return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (id[0] == 'O' && id[1] == 'g' && id[2] == 'g' && id[3] == 'S') {
-        return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-    }
-#endif
-    if (relaxed) {
-        if (container == drflac_container_native) {
-            return drflac__init_private__native(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (container == drflac_container_ogg) {
-            return drflac__init_private__ogg(pInit, onRead, onSeek, onMeta, pUserData, pUserDataMD, relaxed);
-        }
-#endif
-    }
-    return DRFLAC_FALSE;
-}
-static void drflac__init_from_info(drflac* pFlac, const drflac_init_info* pInit)
-{
-    DRFLAC_ASSERT(pFlac != NULL);
-    DRFLAC_ASSERT(pInit != NULL);
-    DRFLAC_ZERO_MEMORY(pFlac, sizeof(*pFlac));
-    pFlac->bs                      = pInit->bs;
-    pFlac->onMeta                  = pInit->onMeta;
-    pFlac->pUserDataMD             = pInit->pUserDataMD;
-    pFlac->maxBlockSizeInPCMFrames = pInit->maxBlockSizeInPCMFrames;
-    pFlac->sampleRate              = pInit->sampleRate;
-    pFlac->channels                = (drflac_uint8)pInit->channels;
-    pFlac->bitsPerSample           = (drflac_uint8)pInit->bitsPerSample;
-    pFlac->totalPCMFrameCount      = pInit->totalPCMFrameCount;
-    pFlac->container               = pInit->container;
-}
-static drflac* drflac_open_with_metadata_private(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, void* pUserDataMD, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac_init_info init;
-    drflac_uint32 allocationSize;
-    drflac_uint32 wholeSIMDVectorCountPerChannel;
-    drflac_uint32 decodedSamplesAllocationSize;
-#ifndef DR_FLAC_NO_OGG
-    drflac_oggbs oggbs;
-#endif
-    drflac_uint64 firstFramePos;
-    drflac_uint64 seektablePos;
-    drflac_uint32 seektableSize;
-    drflac_allocation_callbacks allocationCallbacks;
-    drflac* pFlac;
-    drflac__init_cpu_caps();
-    if (!drflac__init_private(&init, onRead, onSeek, onMeta, container, pUserData, pUserDataMD)) {
-        return NULL;
-    }
-    if (pAllocationCallbacks != NULL) {
-        allocationCallbacks = *pAllocationCallbacks;
-        if (allocationCallbacks.onFree == NULL || (allocationCallbacks.onMalloc == NULL && allocationCallbacks.onRealloc == NULL)) {
-            return NULL;
-        }
-    } else {
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drflac__malloc_default;
-        allocationCallbacks.onRealloc = drflac__realloc_default;
-        allocationCallbacks.onFree    = drflac__free_default;
-    }
-    allocationSize = sizeof(drflac);
-    if ((init.maxBlockSizeInPCMFrames % (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) == 0) {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32)));
-    } else {
-        wholeSIMDVectorCountPerChannel = (init.maxBlockSizeInPCMFrames / (DRFLAC_MAX_SIMD_VECTOR_SIZE / sizeof(drflac_int32))) + 1;
-    }
-    decodedSamplesAllocationSize = wholeSIMDVectorCountPerChannel * DRFLAC_MAX_SIMD_VECTOR_SIZE * init.channels;
-    allocationSize += decodedSamplesAllocationSize;
-    allocationSize += DRFLAC_MAX_SIMD_VECTOR_SIZE;
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        allocationSize += sizeof(drflac_oggbs);
-    }
-    DRFLAC_ZERO_MEMORY(&oggbs, sizeof(oggbs));
-    if (init.container == drflac_container_ogg) {
-        oggbs.onRead = onRead;
-        oggbs.onSeek = onSeek;
-        oggbs.pUserData = pUserData;
-        oggbs.currentBytePos = init.oggFirstBytePos;
-        oggbs.firstBytePos = init.oggFirstBytePos;
-        oggbs.serialNumber = init.oggSerial;
-        oggbs.bosPageHeader = init.oggBosHeader;
-        oggbs.bytesRemainingInPage = 0;
-    }
-#endif
-    firstFramePos = 42;
-    seektablePos  = 0;
-    seektableSize = 0;
-    if (init.hasMetadataBlocks) {
-        drflac_read_proc onReadOverride = onRead;
-        drflac_seek_proc onSeekOverride = onSeek;
-        void* pUserDataOverride = pUserData;
-#ifndef DR_FLAC_NO_OGG
-        if (init.container == drflac_container_ogg) {
-            onReadOverride = drflac__on_read_ogg;
-            onSeekOverride = drflac__on_seek_ogg;
-            pUserDataOverride = (void*)&oggbs;
-        }
-#endif
-        if (!drflac__read_and_decode_metadata(onReadOverride, onSeekOverride, onMeta, pUserDataOverride, pUserDataMD, &firstFramePos, &seektablePos, &seektableSize, &allocationCallbacks)) {
-            return NULL;
-        }
-        allocationSize += seektableSize;
-    }
-    pFlac = (drflac*)drflac__malloc_from_callbacks(allocationSize, &allocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    drflac__init_from_info(pFlac, &init);
-    pFlac->allocationCallbacks = allocationCallbacks;
-    pFlac->pDecodedSamples = (drflac_int32*)drflac_align((size_t)pFlac->pExtraData, DRFLAC_MAX_SIMD_VECTOR_SIZE);
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg) {
-        drflac_oggbs* pInternalOggbs = (drflac_oggbs*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize + seektableSize);
-        *pInternalOggbs = oggbs;
-        pFlac->bs.onRead = drflac__on_read_ogg;
-        pFlac->bs.onSeek = drflac__on_seek_ogg;
-        pFlac->bs.pUserData = (void*)pInternalOggbs;
-        pFlac->_oggbs = (void*)pInternalOggbs;
-    }
-#endif
-    pFlac->firstFLACFramePosInBytes = firstFramePos;
-#ifndef DR_FLAC_NO_OGG
-    if (init.container == drflac_container_ogg)
-    {
-        pFlac->pSeekpoints = NULL;
-        pFlac->seekpointCount = 0;
-    }
-    else
-#endif
-    {
-        if (seektablePos != 0) {
-            pFlac->seekpointCount = seektableSize / sizeof(*pFlac->pSeekpoints);
-            pFlac->pSeekpoints = (drflac_seekpoint*)((drflac_uint8*)pFlac->pDecodedSamples + decodedSamplesAllocationSize);
-            DRFLAC_ASSERT(pFlac->bs.onSeek != NULL);
-            DRFLAC_ASSERT(pFlac->bs.onRead != NULL);
-            if (pFlac->bs.onSeek(pFlac->bs.pUserData, (int)seektablePos, drflac_seek_origin_start)) {
-                if (pFlac->bs.onRead(pFlac->bs.pUserData, pFlac->pSeekpoints, seektableSize) == seektableSize) {
-                    drflac_uint32 iSeekpoint;
-                    for (iSeekpoint = 0; iSeekpoint < pFlac->seekpointCount; ++iSeekpoint) {
-                        pFlac->pSeekpoints[iSeekpoint].firstPCMFrame   = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].firstPCMFrame);
-                        pFlac->pSeekpoints[iSeekpoint].flacFrameOffset = drflac__be2host_64(pFlac->pSeekpoints[iSeekpoint].flacFrameOffset);
-                        pFlac->pSeekpoints[iSeekpoint].pcmFrameCount   = drflac__be2host_16(pFlac->pSeekpoints[iSeekpoint].pcmFrameCount);
-                    }
-                } else {
-                    pFlac->pSeekpoints = NULL;
-                    pFlac->seekpointCount = 0;
-                }
-                if (!pFlac->bs.onSeek(pFlac->bs.pUserData, (int)pFlac->firstFLACFramePosInBytes, drflac_seek_origin_start)) {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            } else {
-                pFlac->pSeekpoints = NULL;
-                pFlac->seekpointCount = 0;
-            }
-        }
-    }
-    if (!init.hasStreamInfoBlock) {
-        pFlac->currentFLACFrame.header = init.firstFrameHeader;
-        for (;;) {
-            drflac_result result = drflac__decode_flac_frame(pFlac);
-            if (result == DRFLAC_SUCCESS) {
-                break;
-            } else {
-                if (result == DRFLAC_CRC_MISMATCH) {
-                    if (!drflac__read_next_flac_frame_header(&pFlac->bs, pFlac->bitsPerSample, &pFlac->currentFLACFrame.header)) {
-                        drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                        return NULL;
-                    }
-                    continue;
-                } else {
-                    drflac__free_from_callbacks(pFlac, &allocationCallbacks);
-                    return NULL;
-                }
-            }
-        }
-    }
-    return pFlac;
-}
-#ifndef DR_FLAC_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#include <errno.h>
-static drflac_result drflac_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRFLAC_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRFLAC_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRFLAC_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRFLAC_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRFLAC_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRFLAC_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRFLAC_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRFLAC_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRFLAC_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRFLAC_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRFLAC_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRFLAC_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRFLAC_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRFLAC_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRFLAC_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRFLAC_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRFLAC_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRFLAC_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRFLAC_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRFLAC_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRFLAC_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRFLAC_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRFLAC_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRFLAC_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRFLAC_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRFLAC_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRFLAC_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRFLAC_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRFLAC_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRFLAC_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRFLAC_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRFLAC_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRFLAC_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRFLAC_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRFLAC_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRFLAC_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRFLAC_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRFLAC_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRFLAC_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRFLAC_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRFLAC_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRFLAC_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRFLAC_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRFLAC_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRFLAC_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRFLAC_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRFLAC_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRFLAC_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRFLAC_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRFLAC_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRFLAC_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRFLAC_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRFLAC_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRFLAC_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRFLAC_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRFLAC_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRFLAC_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRFLAC_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRFLAC_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRFLAC_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRFLAC_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRFLAC_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRFLAC_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRFLAC_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRFLAC_ERROR;
-    #endif
-        default: return DRFLAC_ERROR;
-    }
-}
-static drflac_result drflac_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drflac_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drflac_result result = drflac_result_from_errno(errno);
-        if (result == DRFLAC_SUCCESS) {
-            result = DRFLAC_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRFLAC_HAS_WFOPEN
-    #endif
-#endif
-static drflac_result drflac_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRFLAC_INVALID_ARGS;
-    }
-#if defined(DRFLAC_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drflac_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drflac_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRFLAC_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drflac_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drflac__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRFLAC_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRFLAC_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drflac__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRFLAC_ERROR;
-    }
-#endif
-    return DRFLAC_SUCCESS;
-}
-static size_t drflac__on_read_stdio(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    return fread(bufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-static drflac_bool32 drflac__on_seek_stdio(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    DRFLAC_ASSERT(offset >= 0);
-    return fseek((FILE*)pUserData, offset, (origin == drflac_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRFLAC_API drflac* drflac_open_file(const char* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_w(const wchar_t* pFileName, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return NULL;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_with_metadata(const char* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_fopen(&pFile, pFileName, "rb") != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_file_with_metadata_w(const wchar_t* pFileName, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    FILE* pFile;
-    if (drflac_wfopen(&pFile, pFileName, L"rb", pAllocationCallbacks) != DRFLAC_SUCCESS) {
-        return NULL;
-    }
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_stdio, drflac__on_seek_stdio, onMeta, drflac_container_unknown, (void*)pFile, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        fclose(pFile);
-        return pFlac;
-    }
-    return pFlac;
-}
-#endif
-static size_t drflac__on_read_memory(void* pUserData, void* bufferOut, size_t bytesToRead)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    size_t bytesRemaining;
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(memoryStream->dataSize >= memoryStream->currentReadPos);
-    bytesRemaining = memoryStream->dataSize - memoryStream->currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRFLAC_COPY_MEMORY(bufferOut, memoryStream->data + memoryStream->currentReadPos, bytesToRead);
-        memoryStream->currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-static drflac_bool32 drflac__on_seek_memory(void* pUserData, int offset, drflac_seek_origin origin)
-{
-    drflac__memory_stream* memoryStream = (drflac__memory_stream*)pUserData;
-    DRFLAC_ASSERT(memoryStream != NULL);
-    DRFLAC_ASSERT(offset >= 0);
-    if (offset > (drflac_int64)memoryStream->dataSize) {
-        return DRFLAC_FALSE;
-    }
-    if (origin == drflac_seek_origin_current) {
-        if (memoryStream->currentReadPos + offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos += offset;
-        } else {
-            return DRFLAC_FALSE;
-        }
-    } else {
-        if ((drflac_uint32)offset <= memoryStream->dataSize) {
-            memoryStream->currentReadPos = offset;
-        } else {
-            return DRFLAC_FALSE;
-        }
-    }
-    return DRFLAC_TRUE;
-}
-DRFLAC_API drflac* drflac_open_memory(const void* pData, size_t dataSize, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open(drflac__on_read_memory, drflac__on_seek_memory, &memoryStream, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    pFlac->memoryStream = memoryStream;
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open_memory_with_metadata(const void* pData, size_t dataSize, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac__memory_stream memoryStream;
-    drflac* pFlac;
-    memoryStream.data = (const drflac_uint8*)pData;
-    memoryStream.dataSize = dataSize;
-    memoryStream.currentReadPos = 0;
-    pFlac = drflac_open_with_metadata_private(drflac__on_read_memory, drflac__on_seek_memory, onMeta, drflac_container_unknown, &memoryStream, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    pFlac->memoryStream = memoryStream;
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg)
-    {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        oggbs->pUserData = &pFlac->memoryStream;
-    }
-    else
-#endif
-    {
-        pFlac->bs.pUserData = &pFlac->memoryStream;
-    }
-    return pFlac;
-}
-DRFLAC_API drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, NULL, container, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, drflac_container_unknown, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API drflac* drflac_open_with_metadata_relaxed(drflac_read_proc onRead, drflac_seek_proc onSeek, drflac_meta_proc onMeta, drflac_container container, void* pUserData, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    return drflac_open_with_metadata_private(onRead, onSeek, onMeta, container, pUserData, pUserData, pAllocationCallbacks);
-}
-DRFLAC_API void drflac_close(drflac* pFlac)
-{
-    if (pFlac == NULL) {
-        return;
-    }
-#ifndef DR_FLAC_NO_STDIO
-    if (pFlac->bs.onRead == drflac__on_read_stdio) {
-        fclose((FILE*)pFlac->bs.pUserData);
-    }
-#ifndef DR_FLAC_NO_OGG
-    if (pFlac->container == drflac_container_ogg) {
-        drflac_oggbs* oggbs = (drflac_oggbs*)pFlac->_oggbs;
-        DRFLAC_ASSERT(pFlac->bs.onRead == drflac__on_read_ogg);
-        if (oggbs->onRead == drflac__on_read_stdio) {
-            fclose((FILE*)oggbs->pUserData);
-        }
-    }
-#endif
-#endif
-    drflac__free_from_callbacks(pFlac, &pFlac->allocationCallbacks);
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0;
-        pOutputSamples[i*8+1] = (drflac_int32)right0;
-        pOutputSamples[i*8+2] = (drflac_int32)left1;
-        pOutputSamples[i*8+3] = (drflac_int32)right1;
-        pOutputSamples[i*8+4] = (drflac_int32)left2;
-        pOutputSamples[i*8+5] = (drflac_int32)right2;
-        pOutputSamples[i*8+6] = (drflac_int32)left3;
-        pOutputSamples[i*8+7] = (drflac_int32)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-        drflac__vst2q_u32((drflac_uint32*)pOutputSamples + i*8, vzipq_u32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left;
-        pOutputSamples[i*2+1] = (drflac_int32)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample);
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_int32 shift = unusedBitsPerSample;
-    int32x4_t  wbpsShift0_4;
-    int32x4_t  wbpsShift1_4;
-    uint32x4_t one4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    one4         = vdupq_n_u32(1);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)(mid + side) >> 1;
-            pOutputSamples[i*2+1] = (drflac_int32)(mid - side) >> 1;
-        }
-    } else {
-        int32x4_t shift4;
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, one4));
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift);
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift);
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample));
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample));
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 0), _mm_unpacklo_epi32(left, right));
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8 + 4), _mm_unpackhi_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift4_0 = vdupq_n_s32(shift0);
-    int32x4_t shift4_1 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift4_0));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift4_1));
-        drflac__vst2q_s32(pOutputSamples + i*8, vzipq_s32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0);
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s32(drflac* pFlac, drflac_uint64 framesToRead, drflac_int32* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        pBufferOut[(i*channelCount)+j] = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        left  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right = vsubq_u32(left, side);
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        left0  >>= 16;
-        left1  >>= 16;
-        left2  >>= 16;
-        left3  >>= 16;
-        right0 >>= 16;
-        right1 >>= 16;
-        right2 >>= 16;
-        right3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)left0;
-        pOutputSamples[i*8+1] = (drflac_int16)right0;
-        pOutputSamples[i*8+2] = (drflac_int16)left1;
-        pOutputSamples[i*8+3] = (drflac_int16)right1;
-        pOutputSamples[i*8+4] = (drflac_int16)left2;
-        pOutputSamples[i*8+5] = (drflac_int16)right2;
-        pOutputSamples[i*8+6] = (drflac_int16)left3;
-        pOutputSamples[i*8+7] = (drflac_int16)right3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        side  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left  = vaddq_u32(right, side);
-        left  = vshrq_n_u32(left,  16);
-        right = vshrq_n_u32(right, 16);
-        drflac__vst2q_u16((drflac_uint16*)pOutputSamples + i*8, vzip_u16(vmovn_u32(left), vmovn_u32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        left  >>= 16;
-        right >>= 16;
-        pOutputSamples[i*2+0] = (drflac_int16)left;
-        pOutputSamples[i*2+1] = (drflac_int16)right;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = ((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = ((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = ((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = ((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = ((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = ((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = ((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = ((drflac_int32)(mid3 - side3) >> 1);
-            temp0L >>= 16;
-            temp1L >>= 16;
-            temp2L >>= 16;
-            temp3L >>= 16;
-            temp0R >>= 16;
-            temp1R >>= 16;
-            temp2R >>= 16;
-            temp3R >>= 16;
-            pOutputSamples[i*8+0] = (drflac_int16)temp0L;
-            pOutputSamples[i*8+1] = (drflac_int16)temp0R;
-            pOutputSamples[i*8+2] = (drflac_int16)temp1L;
-            pOutputSamples[i*8+3] = (drflac_int16)temp1R;
-            pOutputSamples[i*8+4] = (drflac_int16)temp2L;
-            pOutputSamples[i*8+5] = (drflac_int16)temp2R;
-            pOutputSamples[i*8+6] = (drflac_int16)temp3L;
-            pOutputSamples[i*8+7] = (drflac_int16)temp3R;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)(((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) >> 16);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            right = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i left;
-            __m128i right;
-            mid   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid   = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            left  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            right = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            left  = _mm_srai_epi32(left,  16);
-            right = _mm_srai_epi32(right, 16);
-            _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    int32x4_t wbpsShift0_4;
-    int32x4_t wbpsShift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    wbpsShift0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbpsShift1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            left  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            right = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((drflac_int32)(mid + side) >> 1) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((drflac_int32)(mid - side) >> 1) >> 16);
-        }
-    } else {
-        int32x4_t shift4;
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t left;
-            int32x4_t right;
-            mid   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbpsShift0_4);
-            side  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbpsShift1_4);
-            mid   = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            left  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            right = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            left  = vshrq_n_s32(left,  16);
-            right = vshrq_n_s32(right, 16);
-            drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int16)(((mid + side) << shift) >> 16);
-            pOutputSamples[i*2+1] = (drflac_int16)(((mid - side) << shift) >> 16);
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        tempL0 >>= 16;
-        tempL1 >>= 16;
-        tempL2 >>= 16;
-        tempL3 >>= 16;
-        tempR0 >>= 16;
-        tempR1 >>= 16;
-        tempR2 >>= 16;
-        tempR3 >>= 16;
-        pOutputSamples[i*8+0] = (drflac_int16)tempL0;
-        pOutputSamples[i*8+1] = (drflac_int16)tempR0;
-        pOutputSamples[i*8+2] = (drflac_int16)tempL1;
-        pOutputSamples[i*8+3] = (drflac_int16)tempR1;
-        pOutputSamples[i*8+4] = (drflac_int16)tempL2;
-        pOutputSamples[i*8+5] = (drflac_int16)tempR2;
-        pOutputSamples[i*8+6] = (drflac_int16)tempL3;
-        pOutputSamples[i*8+7] = (drflac_int16)tempR3;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        left  = _mm_srai_epi32(left,  16);
-        right = _mm_srai_epi32(right, 16);
-        _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    int32x4_t shift0_4 = vdupq_n_s32(shift0);
-    int32x4_t shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t left;
-        int32x4_t right;
-        left  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        right = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-        left  = vshrq_n_s32(left,  16);
-        right = vshrq_n_s32(right, 16);
-        drflac__vst2q_s16(pOutputSamples + i*8, vzip_s16(vmovn_s32(left), vmovn_s32(right)));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int16)((pInputSamples0U32[i] << shift0) >> 16);
-        pOutputSamples[i*2+1] = (drflac_int16)((pInputSamples1U32[i] << shift1) >> 16);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_s16__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_s16__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_s16(drflac* pFlac, drflac_uint64 framesToRead, drflac_int16* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_s16__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_s16__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (drflac_int16)(sampleS32 >> 16);
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (drflac_uint32)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 left  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 side  = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 left0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 left1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 left2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 left3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 side0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 side1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 side2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 side3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 right0 = left0 - side0;
-        drflac_uint32 right1 = left1 - side1;
-        drflac_uint32 right2 = left2 - side2;
-        drflac_uint32 right3 = left3 - side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i left  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i right = _mm_sub_epi32(left, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t left;
-        uint32x4_t side;
-        uint32x4_t right;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        left   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        right  = vsubq_u32(left, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 left  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 side  = pInputSamples1U32[i] << shift1;
-        drflac_uint32 right = left - side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_left_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_left_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_left_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    for (i = 0; i < frameCount; ++i) {
-        drflac_uint32 side  = (drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-        drflac_uint32 right = (drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (float)((drflac_int32)left  / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)right / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 side0  = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 side1  = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 side2  = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 side3  = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 right0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 right1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 right2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 right3 = pInputSamples1U32[i*4+3] << shift1;
-        drflac_uint32 left0 = right0 + side0;
-        drflac_uint32 left1 = right1 + side1;
-        drflac_uint32 left2 = right2 + side2;
-        drflac_uint32 left3 = right3 + side3;
-        pOutputSamples[i*8+0] = (drflac_int32)left0  * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)right0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)left1  * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)right1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)left2  * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)right2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)left3  * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)right3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)right * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    __m128 factor;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = _mm_set1_ps(1.0f / 8388608.0f);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i side  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        __m128i right = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        __m128i left  = _mm_add_epi32(right, side);
-        __m128 leftf  = _mm_mul_ps(_mm_cvtepi32_ps(left),  factor);
-        __m128 rightf = _mm_mul_ps(_mm_cvtepi32_ps(right), factor);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float32x4_t factor4;
-    int32x4_t shift0_4;
-    int32x4_t shift1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor4  = vdupq_n_f32(1.0f / 8388608.0f);
-    shift0_4 = vdupq_n_s32(shift0);
-    shift1_4 = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        uint32x4_t side;
-        uint32x4_t right;
-        uint32x4_t left;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        side   = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4);
-        right  = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4);
-        left   = vaddq_u32(right, side);
-        leftf  = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(left)),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(vreinterpretq_s32_u32(right)), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 side  = pInputSamples0U32[i] << shift0;
-        drflac_uint32 right = pInputSamples1U32[i] << shift1;
-        drflac_uint32 left  = right + side;
-        pOutputSamples[i*2+0] = (drflac_int32)left  / 8388608.0f;
-        pOutputSamples[i*2+1] = (drflac_int32)right / 8388608.0f;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_right_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_right_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_right_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        drflac_uint32 mid  = (drflac_uint32)pInputSamples0[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = (drflac_uint32)pInputSamples1[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (float)((((drflac_int32)(mid + side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((((drflac_int32)(mid - side) >> 1) << (unusedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    if (shift > 0) {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (mid0 + side0) << shift;
-            temp1L = (mid1 + side1) << shift;
-            temp2L = (mid2 + side2) << shift;
-            temp3L = (mid3 + side3) << shift;
-            temp0R = (mid0 - side0) << shift;
-            temp1R = (mid1 - side1) << shift;
-            temp2R = (mid2 - side2) << shift;
-            temp3R = (mid3 - side3) << shift;
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    } else {
-        for (i = 0; i < frameCount4; ++i) {
-            drflac_uint32 temp0L;
-            drflac_uint32 temp1L;
-            drflac_uint32 temp2L;
-            drflac_uint32 temp3L;
-            drflac_uint32 temp0R;
-            drflac_uint32 temp1R;
-            drflac_uint32 temp2R;
-            drflac_uint32 temp3R;
-            drflac_uint32 mid0  = pInputSamples0U32[i*4+0] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid1  = pInputSamples0U32[i*4+1] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid2  = pInputSamples0U32[i*4+2] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 mid3  = pInputSamples0U32[i*4+3] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side0 = pInputSamples1U32[i*4+0] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side1 = pInputSamples1U32[i*4+1] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side2 = pInputSamples1U32[i*4+2] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            drflac_uint32 side3 = pInputSamples1U32[i*4+3] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid0 = (mid0 << 1) | (side0 & 0x01);
-            mid1 = (mid1 << 1) | (side1 & 0x01);
-            mid2 = (mid2 << 1) | (side2 & 0x01);
-            mid3 = (mid3 << 1) | (side3 & 0x01);
-            temp0L = (drflac_uint32)((drflac_int32)(mid0 + side0) >> 1);
-            temp1L = (drflac_uint32)((drflac_int32)(mid1 + side1) >> 1);
-            temp2L = (drflac_uint32)((drflac_int32)(mid2 + side2) >> 1);
-            temp3L = (drflac_uint32)((drflac_int32)(mid3 + side3) >> 1);
-            temp0R = (drflac_uint32)((drflac_int32)(mid0 - side0) >> 1);
-            temp1R = (drflac_uint32)((drflac_int32)(mid1 - side1) >> 1);
-            temp2R = (drflac_uint32)((drflac_int32)(mid2 - side2) >> 1);
-            temp3R = (drflac_uint32)((drflac_int32)(mid3 - side3) >> 1);
-            pOutputSamples[i*8+0] = (drflac_int32)temp0L * factor;
-            pOutputSamples[i*8+1] = (drflac_int32)temp0R * factor;
-            pOutputSamples[i*8+2] = (drflac_int32)temp1L * factor;
-            pOutputSamples[i*8+3] = (drflac_int32)temp1R * factor;
-            pOutputSamples[i*8+4] = (drflac_int32)temp2L * factor;
-            pOutputSamples[i*8+5] = (drflac_int32)temp2R * factor;
-            pOutputSamples[i*8+6] = (drflac_int32)temp3L * factor;
-            pOutputSamples[i*8+7] = (drflac_int32)temp3R * factor;
-        }
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-        drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-        mid = (mid << 1) | (side & 0x01);
-        pOutputSamples[i*2+0] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid + side) >> 1) << unusedBitsPerSample) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)((drflac_uint32)((drflac_int32)(mid - side) >> 1) << unusedBitsPerSample) * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    __m128 factor128;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor = 1.0f / 8388608.0f;
-    factor128 = _mm_set1_ps(factor);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128  leftf;
-            __m128  rightf;
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            tempL  = _mm_srai_epi32(_mm_add_epi32(mid, side), 1);
-            tempR  = _mm_srai_epi32(_mm_sub_epi32(mid, side), 1);
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        for (i = 0; i < frameCount4; ++i) {
-            __m128i mid;
-            __m128i side;
-            __m128i tempL;
-            __m128i tempR;
-            __m128 leftf;
-            __m128 rightf;
-            mid    = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-            side   = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-            mid    = _mm_or_si128(_mm_slli_epi32(mid, 1), _mm_and_si128(side, _mm_set1_epi32(0x01)));
-            tempL  = _mm_slli_epi32(_mm_add_epi32(mid, side), shift);
-            tempR  = _mm_slli_epi32(_mm_sub_epi32(mid, side), shift);
-            leftf  = _mm_mul_ps(_mm_cvtepi32_ps(tempL), factor128);
-            rightf = _mm_mul_ps(_mm_cvtepi32_ps(tempR), factor128);
-            _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-            _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift = unusedBitsPerSample - 8;
-    float factor;
-    float32x4_t factor4;
-    int32x4_t shift4;
-    int32x4_t wbps0_4;
-    int32x4_t wbps1_4;
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 24);
-    factor  = 1.0f / 8388608.0f;
-    factor4 = vdupq_n_f32(factor);
-    wbps0_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample);
-    wbps1_4 = vdupq_n_s32(pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample);
-    if (shift == 0) {
-        for (i = 0; i < frameCount4; ++i) {
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-            uint32x4_t mid  = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            uint32x4_t side = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            lefti  = vshrq_n_s32(vreinterpretq_s32_u32(vaddq_u32(mid, side)), 1);
-            righti = vshrq_n_s32(vreinterpretq_s32_u32(vsubq_u32(mid, side)), 1);
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = ((drflac_int32)(mid + side) >> 1) * factor;
-            pOutputSamples[i*2+1] = ((drflac_int32)(mid - side) >> 1) * factor;
-        }
-    } else {
-        shift -= 1;
-        shift4 = vdupq_n_s32(shift);
-        for (i = 0; i < frameCount4; ++i) {
-            uint32x4_t mid;
-            uint32x4_t side;
-            int32x4_t lefti;
-            int32x4_t righti;
-            float32x4_t leftf;
-            float32x4_t rightf;
-            mid    = vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), wbps0_4);
-            side   = vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), wbps1_4);
-            mid    = vorrq_u32(vshlq_n_u32(mid, 1), vandq_u32(side, vdupq_n_u32(1)));
-            lefti  = vreinterpretq_s32_u32(vshlq_u32(vaddq_u32(mid, side), shift4));
-            righti = vreinterpretq_s32_u32(vshlq_u32(vsubq_u32(mid, side), shift4));
-            leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-            rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-            drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-        }
-        for (i = (frameCount4 << 2); i < frameCount; ++i) {
-            drflac_uint32 mid  = pInputSamples0U32[i] << pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-            drflac_uint32 side = pInputSamples1U32[i] << pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-            mid = (mid << 1) | (side & 0x01);
-            pOutputSamples[i*2+0] = (drflac_int32)((mid + side) << shift) * factor;
-            pOutputSamples[i*2+1] = (drflac_int32)((mid - side) << shift) * factor;
-        }
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_mid_side__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_mid_side__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_mid_side__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-#if 0
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__reference(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    for (drflac_uint64 i = 0; i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (float)((drflac_int32)((drflac_uint32)pInputSamples0[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample)) / 2147483648.0);
-        pOutputSamples[i*2+1] = (float)((drflac_int32)((drflac_uint32)pInputSamples1[i] << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample)) / 2147483648.0);
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample;
-    drflac_uint32 shift1 = unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample;
-    float factor = 1 / 2147483648.0;
-    for (i = 0; i < frameCount4; ++i) {
-        drflac_uint32 tempL0 = pInputSamples0U32[i*4+0] << shift0;
-        drflac_uint32 tempL1 = pInputSamples0U32[i*4+1] << shift0;
-        drflac_uint32 tempL2 = pInputSamples0U32[i*4+2] << shift0;
-        drflac_uint32 tempL3 = pInputSamples0U32[i*4+3] << shift0;
-        drflac_uint32 tempR0 = pInputSamples1U32[i*4+0] << shift1;
-        drflac_uint32 tempR1 = pInputSamples1U32[i*4+1] << shift1;
-        drflac_uint32 tempR2 = pInputSamples1U32[i*4+2] << shift1;
-        drflac_uint32 tempR3 = pInputSamples1U32[i*4+3] << shift1;
-        pOutputSamples[i*8+0] = (drflac_int32)tempL0 * factor;
-        pOutputSamples[i*8+1] = (drflac_int32)tempR0 * factor;
-        pOutputSamples[i*8+2] = (drflac_int32)tempL1 * factor;
-        pOutputSamples[i*8+3] = (drflac_int32)tempR1 * factor;
-        pOutputSamples[i*8+4] = (drflac_int32)tempL2 * factor;
-        pOutputSamples[i*8+5] = (drflac_int32)tempR2 * factor;
-        pOutputSamples[i*8+6] = (drflac_int32)tempL3 * factor;
-        pOutputSamples[i*8+7] = (drflac_int32)tempR3 * factor;
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#if defined(DRFLAC_SUPPORT_SSE2)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float factor = 1.0f / 8388608.0f;
-    __m128 factor128 = _mm_set1_ps(factor);
-    for (i = 0; i < frameCount4; ++i) {
-        __m128i lefti;
-        __m128i righti;
-        __m128 leftf;
-        __m128 rightf;
-        lefti  = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples0 + i), shift0);
-        righti = _mm_slli_epi32(_mm_loadu_si128((const __m128i*)pInputSamples1 + i), shift1);
-        leftf  = _mm_mul_ps(_mm_cvtepi32_ps(lefti),  factor128);
-        rightf = _mm_mul_ps(_mm_cvtepi32_ps(righti), factor128);
-        _mm_storeu_ps(pOutputSamples + i*8 + 0, _mm_unpacklo_ps(leftf, rightf));
-        _mm_storeu_ps(pOutputSamples + i*8 + 4, _mm_unpackhi_ps(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-#if defined(DRFLAC_SUPPORT_NEON)
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__neon(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-    drflac_uint64 i;
-    drflac_uint64 frameCount4 = frameCount >> 2;
-    const drflac_uint32* pInputSamples0U32 = (const drflac_uint32*)pInputSamples0;
-    const drflac_uint32* pInputSamples1U32 = (const drflac_uint32*)pInputSamples1;
-    drflac_uint32 shift0 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[0].wastedBitsPerSample) - 8;
-    drflac_uint32 shift1 = (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[1].wastedBitsPerSample) - 8;
-    float factor = 1.0f / 8388608.0f;
-    float32x4_t factor4 = vdupq_n_f32(factor);
-    int32x4_t shift0_4  = vdupq_n_s32(shift0);
-    int32x4_t shift1_4  = vdupq_n_s32(shift1);
-    for (i = 0; i < frameCount4; ++i) {
-        int32x4_t lefti;
-        int32x4_t righti;
-        float32x4_t leftf;
-        float32x4_t rightf;
-        lefti  = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples0U32 + i*4), shift0_4));
-        righti = vreinterpretq_s32_u32(vshlq_u32(vld1q_u32(pInputSamples1U32 + i*4), shift1_4));
-        leftf  = vmulq_f32(vcvtq_f32_s32(lefti),  factor4);
-        rightf = vmulq_f32(vcvtq_f32_s32(righti), factor4);
-        drflac__vst2q_f32(pOutputSamples + i*8, vzipq_f32(leftf, rightf));
-    }
-    for (i = (frameCount4 << 2); i < frameCount; ++i) {
-        pOutputSamples[i*2+0] = (drflac_int32)(pInputSamples0U32[i] << shift0) * factor;
-        pOutputSamples[i*2+1] = (drflac_int32)(pInputSamples1U32[i] << shift1) * factor;
-    }
-}
-#endif
-static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_uint32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
-{
-#if defined(DRFLAC_SUPPORT_SSE2)
-    if (drflac__gIsSSE2Supported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#elif defined(DRFLAC_SUPPORT_NEON)
-    if (drflac__gIsNEONSupported && pFlac->bitsPerSample <= 24) {
-        drflac_read_pcm_frames_f32__decode_independent_stereo__neon(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-    } else
-#endif
-    {
-#if 0
-        drflac_read_pcm_frames_f32__decode_independent_stereo__reference(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#else
-        drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(pFlac, frameCount, unusedBitsPerSample, pInputSamples0, pInputSamples1, pOutputSamples);
-#endif
-    }
-}
-DRFLAC_API drflac_uint64 drflac_read_pcm_frames_f32(drflac* pFlac, drflac_uint64 framesToRead, float* pBufferOut)
-{
-    drflac_uint64 framesRead;
-    drflac_uint32 unusedBitsPerSample;
-    if (pFlac == NULL || framesToRead == 0) {
-        return 0;
-    }
-    if (pBufferOut == NULL) {
-        return drflac__seek_forward_by_pcm_frames(pFlac, framesToRead);
-    }
-    DRFLAC_ASSERT(pFlac->bitsPerSample <= 32);
-    unusedBitsPerSample = 32 - pFlac->bitsPerSample;
-    framesRead = 0;
-    while (framesToRead > 0) {
-        if (pFlac->currentFLACFrame.pcmFramesRemaining == 0) {
-            if (!drflac__read_and_decode_next_flac_frame(pFlac)) {
-                break;
-            }
-        } else {
-            unsigned int channelCount = drflac__get_channel_count_from_channel_assignment(pFlac->currentFLACFrame.header.channelAssignment);
-            drflac_uint64 iFirstPCMFrame = pFlac->currentFLACFrame.header.blockSizeInPCMFrames - pFlac->currentFLACFrame.pcmFramesRemaining;
-            drflac_uint64 frameCountThisIteration = framesToRead;
-            if (frameCountThisIteration > pFlac->currentFLACFrame.pcmFramesRemaining) {
-                frameCountThisIteration = pFlac->currentFLACFrame.pcmFramesRemaining;
-            }
-            if (channelCount == 2) {
-                const drflac_int32* pDecodedSamples0 = pFlac->currentFLACFrame.subframes[0].pSamplesS32 + iFirstPCMFrame;
-                const drflac_int32* pDecodedSamples1 = pFlac->currentFLACFrame.subframes[1].pSamplesS32 + iFirstPCMFrame;
-                switch (pFlac->currentFLACFrame.header.channelAssignment)
-                {
-                    case DRFLAC_CHANNEL_ASSIGNMENT_LEFT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_left_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_RIGHT_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_right_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_MID_SIDE:
-                    {
-                        drflac_read_pcm_frames_f32__decode_mid_side(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                    case DRFLAC_CHANNEL_ASSIGNMENT_INDEPENDENT:
-                    default:
-                    {
-                        drflac_read_pcm_frames_f32__decode_independent_stereo(pFlac, frameCountThisIteration, unusedBitsPerSample, pDecodedSamples0, pDecodedSamples1, pBufferOut);
-                    } break;
-                }
-            } else {
-                drflac_uint64 i;
-                for (i = 0; i < frameCountThisIteration; ++i) {
-                    unsigned int j;
-                    for (j = 0; j < channelCount; ++j) {
-                        drflac_int32 sampleS32 = (drflac_int32)((drflac_uint32)(pFlac->currentFLACFrame.subframes[j].pSamplesS32[iFirstPCMFrame + i]) << (unusedBitsPerSample + pFlac->currentFLACFrame.subframes[j].wastedBitsPerSample));
-                        pBufferOut[(i*channelCount)+j] = (float)(sampleS32 / 2147483648.0);
-                    }
-                }
-            }
-            framesRead                += frameCountThisIteration;
-            pBufferOut                += frameCountThisIteration * channelCount;
-            framesToRead              -= frameCountThisIteration;
-            pFlac->currentPCMFrame    += frameCountThisIteration;
-            pFlac->currentFLACFrame.pcmFramesRemaining -= (unsigned int)frameCountThisIteration;
-        }
-    }
-    return framesRead;
-}
-DRFLAC_API drflac_bool32 drflac_seek_to_pcm_frame(drflac* pFlac, drflac_uint64 pcmFrameIndex)
-{
-    if (pFlac == NULL) {
-        return DRFLAC_FALSE;
-    }
-    if (pFlac->currentPCMFrame == pcmFrameIndex) {
-        return DRFLAC_TRUE;
-    }
-    if (pFlac->firstFLACFramePosInBytes == 0) {
-        return DRFLAC_FALSE;
-    }
-    if (pcmFrameIndex == 0) {
-        pFlac->currentPCMFrame = 0;
-        return drflac__seek_to_first_frame(pFlac);
-    } else {
-        drflac_bool32 wasSuccessful = DRFLAC_FALSE;
-        drflac_uint64 originalPCMFrame = pFlac->currentPCMFrame;
-        if (pcmFrameIndex > pFlac->totalPCMFrameCount) {
-            pcmFrameIndex = pFlac->totalPCMFrameCount;
-        }
-        if (pcmFrameIndex > pFlac->currentPCMFrame) {
-            drflac_uint32 offset = (drflac_uint32)(pcmFrameIndex - pFlac->currentPCMFrame);
-            if (pFlac->currentFLACFrame.pcmFramesRemaining >  offset) {
-                pFlac->currentFLACFrame.pcmFramesRemaining -= offset;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        } else {
-            drflac_uint32 offsetAbs = (drflac_uint32)(pFlac->currentPCMFrame - pcmFrameIndex);
-            drflac_uint32 currentFLACFramePCMFrameCount = pFlac->currentFLACFrame.header.blockSizeInPCMFrames;
-            drflac_uint32 currentFLACFramePCMFramesConsumed = currentFLACFramePCMFrameCount - pFlac->currentFLACFrame.pcmFramesRemaining;
-            if (currentFLACFramePCMFramesConsumed > offsetAbs) {
-                pFlac->currentFLACFrame.pcmFramesRemaining += offsetAbs;
-                pFlac->currentPCMFrame = pcmFrameIndex;
-                return DRFLAC_TRUE;
-            }
-        }
-#ifndef DR_FLAC_NO_OGG
-        if (pFlac->container == drflac_container_ogg)
-        {
-            wasSuccessful = drflac_ogg__seek_to_pcm_frame(pFlac, pcmFrameIndex);
-        }
-        else
-#endif
-        {
-            if (!pFlac->_noSeekTableSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__seek_table(pFlac, pcmFrameIndex);
-            }
-#if !defined(DR_FLAC_NO_CRC)
-            if (!wasSuccessful && !pFlac->_noBinarySearchSeek && pFlac->totalPCMFrameCount > 0) {
-                wasSuccessful = drflac__seek_to_pcm_frame__binary_search(pFlac, pcmFrameIndex);
-            }
-#endif
-            if (!wasSuccessful && !pFlac->_noBruteForceSeek) {
-                wasSuccessful = drflac__seek_to_pcm_frame__brute_force(pFlac, pcmFrameIndex);
-            }
-        }
-        if (wasSuccessful) {
-            pFlac->currentPCMFrame = pcmFrameIndex;
-        } else {
-            if (drflac_seek_to_pcm_frame(pFlac, originalPCMFrame) == DRFLAC_FALSE) {
-                drflac_seek_to_pcm_frame(pFlac, 0);
-            }
-        }
-        return wasSuccessful;
-    }
-}
-#if defined(SIZE_MAX)
-    #define DRFLAC_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(DRFLAC_64BIT)
-        #define DRFLAC_SIZE_MAX  ((drflac_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRFLAC_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#define DRFLAC_DEFINE_FULL_READ_AND_CLOSE(extension, type) \
-static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut)\
-{                                                                                                                                                                   \
-    type* pSampleData = NULL;                                                                                                                                       \
-    drflac_uint64 totalPCMFrameCount;                                                                                                                               \
-                                                                                                                                                                    \
-    DRFLAC_ASSERT(pFlac != NULL);                                                                                                                                   \
-                                                                                                                                                                    \
-    totalPCMFrameCount = pFlac->totalPCMFrameCount;                                                                                                                 \
-                                                                                                                                                                    \
-    if (totalPCMFrameCount == 0) {                                                                                                                                  \
-        type buffer[4096];                                                                                                                                          \
-        drflac_uint64 pcmFramesRead;                                                                                                                                \
-        size_t sampleDataBufferSize = sizeof(buffer);                                                                                                               \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks(sampleDataBufferSize, &pFlac->allocationCallbacks);                                                      \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        while ((pcmFramesRead = (drflac_uint64)drflac_read_pcm_frames_##extension(pFlac, sizeof(buffer)/sizeof(buffer[0])/pFlac->channels, buffer)) > 0) {          \
-            if (((totalPCMFrameCount + pcmFramesRead) * pFlac->channels * sizeof(type)) > sampleDataBufferSize) {                                                   \
-                type* pNewSampleData;                                                                                                                               \
-                size_t newSampleDataBufferSize;                                                                                                                     \
-                                                                                                                                                                    \
-                newSampleDataBufferSize = sampleDataBufferSize * 2;                                                                                                 \
-                pNewSampleData = (type*)drflac__realloc_from_callbacks(pSampleData, newSampleDataBufferSize, sampleDataBufferSize, &pFlac->allocationCallbacks);    \
-                if (pNewSampleData == NULL) {                                                                                                                       \
-                    drflac__free_from_callbacks(pSampleData, &pFlac->allocationCallbacks);                                                                          \
-                    goto on_error;                                                                                                                                  \
-                }                                                                                                                                                   \
-                                                                                                                                                                    \
-                sampleDataBufferSize = newSampleDataBufferSize;                                                                                                     \
-                pSampleData = pNewSampleData;                                                                                                                       \
-            }                                                                                                                                                       \
-                                                                                                                                                                    \
-            DRFLAC_COPY_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), buffer, (size_t)(pcmFramesRead*pFlac->channels*sizeof(type)));                   \
-            totalPCMFrameCount += pcmFramesRead;                                                                                                                    \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-                                                                                                                         \
-        DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type)));   \
-    } else {                                                                                                                                                        \
-        drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type);                                                                                   \
-        if (dataSize > DRFLAC_SIZE_MAX) {                                                                                                                           \
-            goto on_error;                                                                                                        \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        pSampleData = (type*)drflac__malloc_from_callbacks((size_t)dataSize, &pFlac->allocationCallbacks);               \
-        if (pSampleData == NULL) {                                                                                                                                  \
-            goto on_error;                                                                                                                                          \
-        }                                                                                                                                                           \
-                                                                                                                                                                    \
-        totalPCMFrameCount = drflac_read_pcm_frames_##extension(pFlac, pFlac->totalPCMFrameCount, pSampleData);                                                     \
-    }                                                                                                                                                               \
-                                                                                                                                                                    \
-    if (sampleRateOut) *sampleRateOut = pFlac->sampleRate;                                                                                                          \
-    if (channelsOut) *channelsOut = pFlac->channels;                                                                                                                \
-    if (totalPCMFrameCountOut) *totalPCMFrameCountOut = totalPCMFrameCount;                                                                                         \
-                                                                                                                                                                    \
-    drflac_close(pFlac);                                                                                                                                            \
-    return pSampleData;                                                                                                                                             \
-                                                                                                                                                                    \
-on_error:                                                                                                                                                           \
-    drflac_close(pFlac);                                                                                                                                            \
-    return NULL;                                                                                                                                                    \
-}
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s32, drflac_int32)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(s16, drflac_int16)
-DRFLAC_DEFINE_FULL_READ_AND_CLOSE(f32, float)
-DRFLAC_API drflac_int32* drflac_open_and_read_pcm_frames_s32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-DRFLAC_API drflac_int16* drflac_open_and_read_pcm_frames_s16(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-DRFLAC_API float* drflac_open_and_read_pcm_frames_f32(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData, unsigned int* channelsOut, unsigned int* sampleRateOut, drflac_uint64* totalPCMFrameCountOut, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (channelsOut) {
-        *channelsOut = 0;
-    }
-    if (sampleRateOut) {
-        *sampleRateOut = 0;
-    }
-    if (totalPCMFrameCountOut) {
-        *totalPCMFrameCountOut = 0;
-    }
-    pFlac = drflac_open(onRead, onSeek, pUserData, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channelsOut, sampleRateOut, totalPCMFrameCountOut);
-}
-#ifndef DR_FLAC_NO_STDIO
-DRFLAC_API drflac_int32* drflac_open_file_and_read_pcm_frames_s32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API drflac_int16* drflac_open_file_and_read_pcm_frames_s16(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API float* drflac_open_file_and_read_pcm_frames_f32(const char* filename, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_file(filename, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-#endif
-DRFLAC_API drflac_int32* drflac_open_memory_and_read_pcm_frames_s32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API drflac_int16* drflac_open_memory_and_read_pcm_frames_s16(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_s16(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API float* drflac_open_memory_and_read_pcm_frames_f32(const void* data, size_t dataSize, unsigned int* channels, unsigned int* sampleRate, drflac_uint64* totalPCMFrameCount, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    drflac* pFlac;
-    if (sampleRate) {
-        *sampleRate = 0;
-    }
-    if (channels) {
-        *channels = 0;
-    }
-    if (totalPCMFrameCount) {
-        *totalPCMFrameCount = 0;
-    }
-    pFlac = drflac_open_memory(data, dataSize, pAllocationCallbacks);
-    if (pFlac == NULL) {
-        return NULL;
-    }
-    return drflac__full_read_and_close_f32(pFlac, channels, sampleRate, totalPCMFrameCount);
-}
-DRFLAC_API void drflac_free(void* p, const drflac_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drflac__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drflac__free_default(p, NULL);
-    }
-}
-DRFLAC_API void drflac_init_vorbis_comment_iterator(drflac_vorbis_comment_iterator* pIter, drflac_uint32 commentCount, const void* pComments)
-{
-    if (pIter == NULL) {
-        return;
-    }
-    pIter->countRemaining = commentCount;
-    pIter->pRunningData   = (const char*)pComments;
-}
-DRFLAC_API const char* drflac_next_vorbis_comment(drflac_vorbis_comment_iterator* pIter, drflac_uint32* pCommentLengthOut)
-{
-    drflac_int32 length;
-    const char* pComment;
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = 0;
-    }
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return NULL;
-    }
-    length = drflac__le2host_32(*(const drflac_uint32*)pIter->pRunningData);
-    pIter->pRunningData += 4;
-    pComment = pIter->pRunningData;
-    pIter->pRunningData += length;
-    pIter->countRemaining -= 1;
-    if (pCommentLengthOut) {
-        *pCommentLengthOut = length;
-    }
-    return pComment;
-}
-DRFLAC_API void drflac_init_cuesheet_track_iterator(drflac_cuesheet_track_iterator* pIter, drflac_uint32 trackCount, const void* pTrackData)
-{
-    if (pIter == NULL) {
-        return;
-    }
-    pIter->countRemaining = trackCount;
-    pIter->pRunningData   = (const char*)pTrackData;
-}
-DRFLAC_API drflac_bool32 drflac_next_cuesheet_track(drflac_cuesheet_track_iterator* pIter, drflac_cuesheet_track* pCuesheetTrack)
-{
-    drflac_cuesheet_track cuesheetTrack;
-    const char* pRunningData;
-    drflac_uint64 offsetHi;
-    drflac_uint64 offsetLo;
-    if (pIter == NULL || pIter->countRemaining == 0 || pIter->pRunningData == NULL) {
-        return DRFLAC_FALSE;
-    }
-    pRunningData = pIter->pRunningData;
-    offsetHi                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    offsetLo                   = drflac__be2host_32(*(const drflac_uint32*)pRunningData); pRunningData += 4;
-    cuesheetTrack.offset       = offsetLo | (offsetHi << 32);
-    cuesheetTrack.trackNumber  = pRunningData[0];                                         pRunningData += 1;
-    DRFLAC_COPY_MEMORY(cuesheetTrack.ISRC, pRunningData, sizeof(cuesheetTrack.ISRC));     pRunningData += 12;
-    cuesheetTrack.isAudio      = (pRunningData[0] & 0x80) != 0;
-    cuesheetTrack.preEmphasis  = (pRunningData[0] & 0x40) != 0;                           pRunningData += 14;
-    cuesheetTrack.indexCount   = pRunningData[0];                                         pRunningData += 1;
-    cuesheetTrack.pIndexPoints = (const drflac_cuesheet_track_index*)pRunningData;        pRunningData += cuesheetTrack.indexCount * sizeof(drflac_cuesheet_track_index);
-    pIter->pRunningData = pRunningData;
-    pIter->countRemaining -= 1;
-    if (pCuesheetTrack) {
-        *pCuesheetTrack = cuesheetTrack;
-    }
-    return DRFLAC_TRUE;
-}
-#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
-    #pragma GCC diagnostic pop
-#endif
-#endif
-/* dr_flac_c end */
-#endif  /* DRFLAC_IMPLEMENTATION */
-#endif  /* MA_NO_FLAC */
-
-#if !defined(MA_NO_MP3) && !defined(MA_NO_DECODING)
-#if !defined(DR_MP3_IMPLEMENTATION) && !defined(DRMP3_IMPLEMENTATION) /* For backwards compatibility. Will be removed in version 0.11 for cleanliness. */
-/* dr_mp3_c begin */
-#ifndef dr_mp3_c
-#define dr_mp3_c
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-DRMP3_API void drmp3_version(drmp3_uint32* pMajor, drmp3_uint32* pMinor, drmp3_uint32* pRevision)
-{
-    if (pMajor) {
-        *pMajor = DRMP3_VERSION_MAJOR;
-    }
-    if (pMinor) {
-        *pMinor = DRMP3_VERSION_MINOR;
-    }
-    if (pRevision) {
-        *pRevision = DRMP3_VERSION_REVISION;
-    }
-}
-DRMP3_API const char* drmp3_version_string(void)
-{
-    return DRMP3_VERSION_STRING;
-}
-#if defined(__TINYC__)
-#define DR_MP3_NO_SIMD
-#endif
-#define DRMP3_OFFSET_PTR(p, offset) ((void*)((drmp3_uint8*)(p) + (offset)))
-#define DRMP3_MAX_FREE_FORMAT_FRAME_SIZE  2304
-#ifndef DRMP3_MAX_FRAME_SYNC_MATCHES
-#define DRMP3_MAX_FRAME_SYNC_MATCHES      10
-#endif
-#define DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES  DRMP3_MAX_FREE_FORMAT_FRAME_SIZE
-#define DRMP3_MAX_BITRESERVOIR_BYTES      511
-#define DRMP3_SHORT_BLOCK_TYPE            2
-#define DRMP3_STOP_BLOCK_TYPE             3
-#define DRMP3_MODE_MONO                   3
-#define DRMP3_MODE_JOINT_STEREO           1
-#define DRMP3_HDR_SIZE                    4
-#define DRMP3_HDR_IS_MONO(h)              (((h[3]) & 0xC0) == 0xC0)
-#define DRMP3_HDR_IS_MS_STEREO(h)         (((h[3]) & 0xE0) == 0x60)
-#define DRMP3_HDR_IS_FREE_FORMAT(h)       (((h[2]) & 0xF0) == 0)
-#define DRMP3_HDR_IS_CRC(h)               (!((h[1]) & 1))
-#define DRMP3_HDR_TEST_PADDING(h)         ((h[2]) & 0x2)
-#define DRMP3_HDR_TEST_MPEG1(h)           ((h[1]) & 0x8)
-#define DRMP3_HDR_TEST_NOT_MPEG25(h)      ((h[1]) & 0x10)
-#define DRMP3_HDR_TEST_I_STEREO(h)        ((h[3]) & 0x10)
-#define DRMP3_HDR_TEST_MS_STEREO(h)       ((h[3]) & 0x20)
-#define DRMP3_HDR_GET_STEREO_MODE(h)      (((h[3]) >> 6) & 3)
-#define DRMP3_HDR_GET_STEREO_MODE_EXT(h)  (((h[3]) >> 4) & 3)
-#define DRMP3_HDR_GET_LAYER(h)            (((h[1]) >> 1) & 3)
-#define DRMP3_HDR_GET_BITRATE(h)          ((h[2]) >> 4)
-#define DRMP3_HDR_GET_SAMPLE_RATE(h)      (((h[2]) >> 2) & 3)
-#define DRMP3_HDR_GET_MY_SAMPLE_RATE(h)   (DRMP3_HDR_GET_SAMPLE_RATE(h) + (((h[1] >> 3) & 1) + ((h[1] >> 4) & 1))*3)
-#define DRMP3_HDR_IS_FRAME_576(h)         ((h[1] & 14) == 2)
-#define DRMP3_HDR_IS_LAYER_1(h)           ((h[1] & 6) == 6)
-#define DRMP3_BITS_DEQUANTIZER_OUT        -1
-#define DRMP3_MAX_SCF                     (255 + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210)
-#define DRMP3_MAX_SCFI                    ((DRMP3_MAX_SCF + 3) & ~3)
-#define DRMP3_MIN(a, b)           ((a) > (b) ? (b) : (a))
-#define DRMP3_MAX(a, b)           ((a) < (b) ? (b) : (a))
-#if !defined(DR_MP3_NO_SIMD)
-#if !defined(DR_MP3_ONLY_SIMD) && (defined(_M_X64) || defined(__x86_64__) || defined(__aarch64__) || defined(_M_ARM64))
-#define DR_MP3_ONLY_SIMD
-#endif
-#if ((defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_IX86) || defined(_M_X64))) || ((defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__))
-#if defined(_MSC_VER)
-#include <intrin.h>
-#endif
-#include <emmintrin.h>
-#define DRMP3_HAVE_SSE 1
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE _mm_storeu_ps
-#define DRMP3_VLD _mm_loadu_ps
-#define DRMP3_VSET _mm_set1_ps
-#define DRMP3_VADD _mm_add_ps
-#define DRMP3_VSUB _mm_sub_ps
-#define DRMP3_VMUL _mm_mul_ps
-#define DRMP3_VMAC(a, x, y) _mm_add_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMSB(a, x, y) _mm_sub_ps(a, _mm_mul_ps(x, y))
-#define DRMP3_VMUL_S(x, s)  _mm_mul_ps(x, _mm_set1_ps(s))
-#define DRMP3_VREV(x) _mm_shuffle_ps(x, x, _MM_SHUFFLE(0, 1, 2, 3))
-typedef __m128 drmp3_f4;
-#if defined(_MSC_VER) || defined(DR_MP3_ONLY_SIMD)
-#define drmp3_cpuid __cpuid
-#else
-static __inline__ __attribute__((always_inline)) void drmp3_cpuid(int CPUInfo[], const int InfoType)
-{
-#if defined(__PIC__)
-    __asm__ __volatile__(
-#if defined(__x86_64__)
-        "push %%rbx\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-        "pop  %%rbx\n"
-#else
-        "xchgl %%ebx, %1\n"
-        "cpuid\n"
-        "xchgl %%ebx, %1\n"
-#endif
-        : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#else
-    __asm__ __volatile__(
-        "cpuid"
-        : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3])
-        : "a" (InfoType));
-#endif
-}
-#endif
-static int drmp3_have_simd(void)
-{
-#ifdef DR_MP3_ONLY_SIMD
-    return 1;
-#else
-    static int g_have_simd;
-    int CPUInfo[4];
-#ifdef MINIMP3_TEST
-    static int g_counter;
-    if (g_counter++ > 100)
-        return 0;
-#endif
-    if (g_have_simd)
-        goto end;
-    drmp3_cpuid(CPUInfo, 0);
-    if (CPUInfo[0] > 0)
-    {
-        drmp3_cpuid(CPUInfo, 1);
-        g_have_simd = (CPUInfo[3] & (1 << 26)) + 1;
-        return g_have_simd - 1;
-    }
-end:
-    return g_have_simd - 1;
-#endif
-}
-#elif defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
-#include <arm_neon.h>
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 1
-#define DRMP3_VSTORE vst1q_f32
-#define DRMP3_VLD vld1q_f32
-#define DRMP3_VSET vmovq_n_f32
-#define DRMP3_VADD vaddq_f32
-#define DRMP3_VSUB vsubq_f32
-#define DRMP3_VMUL vmulq_f32
-#define DRMP3_VMAC(a, x, y) vmlaq_f32(a, x, y)
-#define DRMP3_VMSB(a, x, y) vmlsq_f32(a, x, y)
-#define DRMP3_VMUL_S(x, s)  vmulq_f32(x, vmovq_n_f32(s))
-#define DRMP3_VREV(x) vcombine_f32(vget_high_f32(vrev64q_f32(x)), vget_low_f32(vrev64q_f32(x)))
-typedef float32x4_t drmp3_f4;
-static int drmp3_have_simd(void)
-{
-    return 1;
-}
-#else
-#define DRMP3_HAVE_SSE 0
-#define DRMP3_HAVE_SIMD 0
-#ifdef DR_MP3_ONLY_SIMD
-#error DR_MP3_ONLY_SIMD used, but SSE/NEON not enabled
-#endif
-#endif
-#else
-#define DRMP3_HAVE_SIMD 0
-#endif
-#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) && !defined(__aarch64__) && !defined(_M_ARM64)
-#define DRMP3_HAVE_ARMV6 1
-static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_arm(int32_t a)
-{
-    drmp3_int32 x = 0;
-    __asm__ ("ssat %0, #16, %1" : "=r"(x) : "r"(a));
-    return x;
-}
-#else
-#define DRMP3_HAVE_ARMV6 0
-#endif
-typedef struct
-{
-    const drmp3_uint8 *buf;
-    int pos, limit;
-} drmp3_bs;
-typedef struct
-{
-    float scf[3*64];
-    drmp3_uint8 total_bands, stereo_bands, bitalloc[64], scfcod[64];
-} drmp3_L12_scale_info;
-typedef struct
-{
-    drmp3_uint8 tab_offset, code_tab_width, band_count;
-} drmp3_L12_subband_alloc;
-typedef struct
-{
-    const drmp3_uint8 *sfbtab;
-    drmp3_uint16 part_23_length, big_values, scalefac_compress;
-    drmp3_uint8 global_gain, block_type, mixed_block_flag, n_long_sfb, n_short_sfb;
-    drmp3_uint8 table_select[3], region_count[3], subblock_gain[3];
-    drmp3_uint8 preflag, scalefac_scale, count1_table, scfsi;
-} drmp3_L3_gr_info;
-typedef struct
-{
-    drmp3_bs bs;
-    drmp3_uint8 maindata[DRMP3_MAX_BITRESERVOIR_BYTES + DRMP3_MAX_L3_FRAME_PAYLOAD_BYTES];
-    drmp3_L3_gr_info gr_info[4];
-    float grbuf[2][576], scf[40], syn[18 + 15][2*32];
-    drmp3_uint8 ist_pos[2][39];
-} drmp3dec_scratch;
-static void drmp3_bs_init(drmp3_bs *bs, const drmp3_uint8 *data, int bytes)
-{
-    bs->buf   = data;
-    bs->pos   = 0;
-    bs->limit = bytes*8;
-}
-static drmp3_uint32 drmp3_bs_get_bits(drmp3_bs *bs, int n)
-{
-    drmp3_uint32 next, cache = 0, s = bs->pos & 7;
-    int shl = n + s;
-    const drmp3_uint8 *p = bs->buf + (bs->pos >> 3);
-    if ((bs->pos += n) > bs->limit)
-        return 0;
-    next = *p++ & (255 >> s);
-    while ((shl -= 8) > 0)
-    {
-        cache |= next << shl;
-        next = *p++;
-    }
-    return cache | (next >> -shl);
-}
-static int drmp3_hdr_valid(const drmp3_uint8 *h)
-{
-    return h[0] == 0xff &&
-        ((h[1] & 0xF0) == 0xf0 || (h[1] & 0xFE) == 0xe2) &&
-        (DRMP3_HDR_GET_LAYER(h) != 0) &&
-        (DRMP3_HDR_GET_BITRATE(h) != 15) &&
-        (DRMP3_HDR_GET_SAMPLE_RATE(h) != 3);
-}
-static int drmp3_hdr_compare(const drmp3_uint8 *h1, const drmp3_uint8 *h2)
-{
-    return drmp3_hdr_valid(h2) &&
-        ((h1[1] ^ h2[1]) & 0xFE) == 0 &&
-        ((h1[2] ^ h2[2]) & 0x0C) == 0 &&
-        !(DRMP3_HDR_IS_FREE_FORMAT(h1) ^ DRMP3_HDR_IS_FREE_FORMAT(h2));
-}
-static unsigned drmp3_hdr_bitrate_kbps(const drmp3_uint8 *h)
-{
-    static const drmp3_uint8 halfrate[2][3][15] = {
-        { { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,4,8,12,16,20,24,28,32,40,48,56,64,72,80 }, { 0,16,24,28,32,40,48,56,64,72,80,88,96,112,128 } },
-        { { 0,16,20,24,28,32,40,48,56,64,80,96,112,128,160 }, { 0,16,24,28,32,40,48,56,64,80,96,112,128,160,192 }, { 0,16,32,48,64,80,96,112,128,144,160,176,192,208,224 } },
-    };
-    return 2*halfrate[!!DRMP3_HDR_TEST_MPEG1(h)][DRMP3_HDR_GET_LAYER(h) - 1][DRMP3_HDR_GET_BITRATE(h)];
-}
-static unsigned drmp3_hdr_sample_rate_hz(const drmp3_uint8 *h)
-{
-    static const unsigned g_hz[3] = { 44100, 48000, 32000 };
-    return g_hz[DRMP3_HDR_GET_SAMPLE_RATE(h)] >> (int)!DRMP3_HDR_TEST_MPEG1(h) >> (int)!DRMP3_HDR_TEST_NOT_MPEG25(h);
-}
-static unsigned drmp3_hdr_frame_samples(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_IS_LAYER_1(h) ? 384 : (1152 >> (int)DRMP3_HDR_IS_FRAME_576(h));
-}
-static int drmp3_hdr_frame_bytes(const drmp3_uint8 *h, int free_format_size)
-{
-    int frame_bytes = drmp3_hdr_frame_samples(h)*drmp3_hdr_bitrate_kbps(h)*125/drmp3_hdr_sample_rate_hz(h);
-    if (DRMP3_HDR_IS_LAYER_1(h))
-    {
-        frame_bytes &= ~3;
-    }
-    return frame_bytes ? frame_bytes : free_format_size;
-}
-static int drmp3_hdr_padding(const drmp3_uint8 *h)
-{
-    return DRMP3_HDR_TEST_PADDING(h) ? (DRMP3_HDR_IS_LAYER_1(h) ? 4 : 1) : 0;
-}
-#ifndef DR_MP3_ONLY_MP3
-static const drmp3_L12_subband_alloc *drmp3_L12_subband_alloc_table(const drmp3_uint8 *hdr, drmp3_L12_scale_info *sci)
-{
-    const drmp3_L12_subband_alloc *alloc;
-    int mode = DRMP3_HDR_GET_STEREO_MODE(hdr);
-    int nbands, stereo_bands = (mode == DRMP3_MODE_MONO) ? 0 : (mode == DRMP3_MODE_JOINT_STEREO) ? (DRMP3_HDR_GET_STEREO_MODE_EXT(hdr) << 2) + 4 : 32;
-    if (DRMP3_HDR_IS_LAYER_1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L1[] = { { 76, 4, 32 } };
-        alloc = g_alloc_L1;
-        nbands = 32;
-    } else if (!DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M2[] = { { 60, 4, 4 }, { 44, 3, 7 }, { 44, 2, 19 } };
-        alloc = g_alloc_L2M2;
-        nbands = 30;
-    } else
-    {
-        static const drmp3_L12_subband_alloc g_alloc_L2M1[] = { { 0, 4, 3 }, { 16, 4, 8 }, { 32, 3, 12 }, { 40, 2, 7 } };
-        int sample_rate_idx = DRMP3_HDR_GET_SAMPLE_RATE(hdr);
-        unsigned kbps = drmp3_hdr_bitrate_kbps(hdr) >> (int)(mode != DRMP3_MODE_MONO);
-        if (!kbps)
-        {
-            kbps = 192;
-        }
-        alloc = g_alloc_L2M1;
-        nbands = 27;
-        if (kbps < 56)
-        {
-            static const drmp3_L12_subband_alloc g_alloc_L2M1_lowrate[] = { { 44, 4, 2 }, { 44, 3, 10 } };
-            alloc = g_alloc_L2M1_lowrate;
-            nbands = sample_rate_idx == 2 ? 12 : 8;
-        } else if (kbps >= 96 && sample_rate_idx != 1)
-        {
-            nbands = 30;
-        }
-    }
-    sci->total_bands = (drmp3_uint8)nbands;
-    sci->stereo_bands = (drmp3_uint8)DRMP3_MIN(stereo_bands, nbands);
-    return alloc;
-}
-static void drmp3_L12_read_scalefactors(drmp3_bs *bs, drmp3_uint8 *pba, drmp3_uint8 *scfcod, int bands, float *scf)
-{
-    static const float g_deq_L12[18*3] = {
-#define DRMP3_DQ(x) 9.53674316e-07f/x, 7.56931807e-07f/x, 6.00777173e-07f/x
-        DRMP3_DQ(3),DRMP3_DQ(7),DRMP3_DQ(15),DRMP3_DQ(31),DRMP3_DQ(63),DRMP3_DQ(127),DRMP3_DQ(255),DRMP3_DQ(511),DRMP3_DQ(1023),DRMP3_DQ(2047),DRMP3_DQ(4095),DRMP3_DQ(8191),DRMP3_DQ(16383),DRMP3_DQ(32767),DRMP3_DQ(65535),DRMP3_DQ(3),DRMP3_DQ(5),DRMP3_DQ(9)
-    };
-    int i, m;
-    for (i = 0; i < bands; i++)
-    {
-        float s = 0;
-        int ba = *pba++;
-        int mask = ba ? 4 + ((19 >> scfcod[i]) & 3) : 0;
-        for (m = 4; m; m >>= 1)
-        {
-            if (mask & m)
-            {
-                int b = drmp3_bs_get_bits(bs, 6);
-                s = g_deq_L12[ba*3 - 6 + b % 3]*(int)(1 << 21 >> b/3);
-            }
-            *scf++ = s;
-        }
-    }
-}
-static void drmp3_L12_read_scale_info(const drmp3_uint8 *hdr, drmp3_bs *bs, drmp3_L12_scale_info *sci)
-{
-    static const drmp3_uint8 g_bitalloc_code_tab[] = {
-        0,17, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,16,
-        0,17,18, 3,19,4,5,16,
-        0,17,18,16,
-        0,17,18,19, 4,5,6, 7,8, 9,10,11,12,13,14,15,
-        0,17,18, 3,19,4,5, 6,7, 8, 9,10,11,12,13,14,
-        0, 2, 3, 4, 5,6,7, 8,9,10,11,12,13,14,15,16
-    };
-    const drmp3_L12_subband_alloc *subband_alloc = drmp3_L12_subband_alloc_table(hdr, sci);
-    int i, k = 0, ba_bits = 0;
-    const drmp3_uint8 *ba_code_tab = g_bitalloc_code_tab;
-    for (i = 0; i < sci->total_bands; i++)
-    {
-        drmp3_uint8 ba;
-        if (i == k)
-        {
-            k += subband_alloc->band_count;
-            ba_bits = subband_alloc->code_tab_width;
-            ba_code_tab = g_bitalloc_code_tab + subband_alloc->tab_offset;
-            subband_alloc++;
-        }
-        ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        sci->bitalloc[2*i] = ba;
-        if (i < sci->stereo_bands)
-        {
-            ba = ba_code_tab[drmp3_bs_get_bits(bs, ba_bits)];
-        }
-        sci->bitalloc[2*i + 1] = sci->stereo_bands ? ba : 0;
-    }
-    for (i = 0; i < 2*sci->total_bands; i++)
-    {
-        sci->scfcod[i] = (drmp3_uint8)(sci->bitalloc[i] ? DRMP3_HDR_IS_LAYER_1(hdr) ? 2 : drmp3_bs_get_bits(bs, 2) : 6);
-    }
-    drmp3_L12_read_scalefactors(bs, sci->bitalloc, sci->scfcod, sci->total_bands*2, sci->scf);
-    for (i = sci->stereo_bands; i < sci->total_bands; i++)
-    {
-        sci->bitalloc[2*i + 1] = 0;
-    }
-}
-static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_scale_info *sci, int group_size)
-{
-    int i, j, k, choff = 576;
-    for (j = 0; j < 4; j++)
-    {
-        float *dst = grbuf + group_size*j;
-        for (i = 0; i < 2*sci->total_bands; i++)
-        {
-            int ba = sci->bitalloc[i];
-            if (ba != 0)
-            {
-                if (ba < 17)
-                {
-                    int half = (1 << (ba - 1)) - 1;
-                    for (k = 0; k < group_size; k++)
-                    {
-                        dst[k] = (float)((int)drmp3_bs_get_bits(bs, ba) - half);
-                    }
-                } else
-                {
-                    unsigned mod = (2 << (ba - 17)) + 1;
-                    unsigned code = drmp3_bs_get_bits(bs, mod + 2 - (mod >> 3));
-                    for (k = 0; k < group_size; k++, code /= mod)
-                    {
-                        dst[k] = (float)((int)(code % mod - mod/2));
-                    }
-                }
-            }
-            dst += choff;
-            choff = 18 - choff;
-        }
-    }
-    return group_size*4;
-}
-static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
-{
-    int i, k;
-    memcpy(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
-    for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
-    {
-        for (k = 0; k < 12; k++)
-        {
-            dst[k + 0]   *= scf[0];
-            dst[k + 576] *= scf[3];
-        }
-    }
-}
-#endif
-static int drmp3_L3_read_side_info(drmp3_bs *bs, drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    static const drmp3_uint8 g_scf_long[8][23] = {
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,54,62,70,76,36,0 },
-        { 6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54,0 },
-        { 4,4,4,4,4,4,6,6,8,8,10,12,16,20,24,28,34,42,50,54,76,158,0 },
-        { 4,4,4,4,4,4,6,6,6,8,10,12,16,18,22,28,34,40,46,54,54,192,0 },
-        { 4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102,26,0 }
-    };
-    static const drmp3_uint8 g_scf_short[8][40] = {
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 8,8,8,8,8,8,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,4,4,4,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    static const drmp3_uint8 g_scf_mixed[8][40] = {
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 12,12,12,4,4,4,8,8,8,12,12,12,16,16,16,20,20,20,24,24,24,28,28,28,36,36,36,2,2,2,2,2,2,2,2,2,26,26,26,0 },
-        { 6,6,6,6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,14,14,14,18,18,18,26,26,26,32,32,32,42,42,42,18,18,18,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,32,32,32,44,44,44,12,12,12,0 },
-        { 6,6,6,6,6,6,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,24,24,24,30,30,30,40,40,40,18,18,18,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,10,10,10,12,12,12,14,14,14,18,18,18,22,22,22,30,30,30,56,56,56,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,6,6,6,10,10,10,12,12,12,14,14,14,16,16,16,20,20,20,26,26,26,66,66,66,0 },
-        { 4,4,4,4,4,4,6,6,4,4,4,6,6,6,8,8,8,12,12,12,16,16,16,20,20,20,26,26,26,34,34,34,42,42,42,12,12,12,0 }
-    };
-    unsigned tables, scfsi = 0;
-    int main_data_begin, part_23_sum = 0;
-    int gr_count = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    int sr_idx = DRMP3_HDR_GET_MY_SAMPLE_RATE(hdr); sr_idx -= (sr_idx != 0);
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        gr_count *= 2;
-        main_data_begin = drmp3_bs_get_bits(bs, 9);
-        scfsi = drmp3_bs_get_bits(bs, 7 + gr_count);
-    } else
-    {
-        main_data_begin = drmp3_bs_get_bits(bs, 8 + gr_count) >> gr_count;
-    }
-    do
-    {
-        if (DRMP3_HDR_IS_MONO(hdr))
-        {
-            scfsi <<= 4;
-        }
-        gr->part_23_length = (drmp3_uint16)drmp3_bs_get_bits(bs, 12);
-        part_23_sum += gr->part_23_length;
-        gr->big_values = (drmp3_uint16)drmp3_bs_get_bits(bs,  9);
-        if (gr->big_values > 288)
-        {
-            return -1;
-        }
-        gr->global_gain = (drmp3_uint8)drmp3_bs_get_bits(bs, 8);
-        gr->scalefac_compress = (drmp3_uint16)drmp3_bs_get_bits(bs, DRMP3_HDR_TEST_MPEG1(hdr) ? 4 : 9);
-        gr->sfbtab = g_scf_long[sr_idx];
-        gr->n_long_sfb  = 22;
-        gr->n_short_sfb = 0;
-        if (drmp3_bs_get_bits(bs, 1))
-        {
-            gr->block_type = (drmp3_uint8)drmp3_bs_get_bits(bs, 2);
-            if (!gr->block_type)
-            {
-                return -1;
-            }
-            gr->mixed_block_flag = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-            gr->region_count[0] = 7;
-            gr->region_count[1] = 255;
-            if (gr->block_type == DRMP3_SHORT_BLOCK_TYPE)
-            {
-                scfsi &= 0x0F0F;
-                if (!gr->mixed_block_flag)
-                {
-                    gr->region_count[0] = 8;
-                    gr->sfbtab = g_scf_short[sr_idx];
-                    gr->n_long_sfb = 0;
-                    gr->n_short_sfb = 39;
-                } else
-                {
-                    gr->sfbtab = g_scf_mixed[sr_idx];
-                    gr->n_long_sfb = DRMP3_HDR_TEST_MPEG1(hdr) ? 8 : 6;
-                    gr->n_short_sfb = 30;
-                }
-            }
-            tables = drmp3_bs_get_bits(bs, 10);
-            tables <<= 5;
-            gr->subblock_gain[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->subblock_gain[2] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-        } else
-        {
-            gr->block_type = 0;
-            gr->mixed_block_flag = 0;
-            tables = drmp3_bs_get_bits(bs, 15);
-            gr->region_count[0] = (drmp3_uint8)drmp3_bs_get_bits(bs, 4);
-            gr->region_count[1] = (drmp3_uint8)drmp3_bs_get_bits(bs, 3);
-            gr->region_count[2] = 255;
-        }
-        gr->table_select[0] = (drmp3_uint8)(tables >> 10);
-        gr->table_select[1] = (drmp3_uint8)((tables >> 5) & 31);
-        gr->table_select[2] = (drmp3_uint8)((tables) & 31);
-        gr->preflag = (drmp3_uint8)(DRMP3_HDR_TEST_MPEG1(hdr) ? drmp3_bs_get_bits(bs, 1) : (gr->scalefac_compress >= 500));
-        gr->scalefac_scale = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->count1_table = (drmp3_uint8)drmp3_bs_get_bits(bs, 1);
-        gr->scfsi = (drmp3_uint8)((scfsi >> 12) & 15);
-        scfsi <<= 4;
-        gr++;
-    } while(--gr_count);
-    if (part_23_sum + bs->pos > bs->limit + main_data_begin*8)
-    {
-        return -1;
-    }
-    return main_data_begin;
-}
-static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, const drmp3_uint8 *scf_size, const drmp3_uint8 *scf_count, drmp3_bs *bitbuf, int scfsi)
-{
-    int i, k;
-    for (i = 0; i < 4 && scf_count[i]; i++, scfsi *= 2)
-    {
-        int cnt = scf_count[i];
-        if (scfsi & 8)
-        {
-            memcpy(scf, ist_pos, cnt);
-        } else
-        {
-            int bits = scf_size[i];
-            if (!bits)
-            {
-                memset(scf, 0, cnt);
-                memset(ist_pos, 0, cnt);
-            } else
-            {
-                int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
-                for (k = 0; k < cnt; k++)
-                {
-                    int s = drmp3_bs_get_bits(bitbuf, bits);
-                    ist_pos[k] = (drmp3_uint8)(s == max_scf ? -1 : s);
-                    scf[k] = (drmp3_uint8)s;
-                }
-            }
-        }
-        ist_pos += cnt;
-        scf += cnt;
-    }
-    scf[0] = scf[1] = scf[2] = 0;
-}
-static float drmp3_L3_ldexp_q2(float y, int exp_q2)
-{
-    static const float g_expfrac[4] = { 9.31322575e-10f,7.83145814e-10f,6.58544508e-10f,5.53767716e-10f };
-    int e;
-    do
-    {
-        e = DRMP3_MIN(30*4, exp_q2);
-        y *= g_expfrac[e & 3]*(1 << 30 >> (e >> 2));
-    } while ((exp_q2 -= e) > 0);
-    return y;
-}
-static void drmp3_L3_decode_scalefactors(const drmp3_uint8 *hdr, drmp3_uint8 *ist_pos, drmp3_bs *bs, const drmp3_L3_gr_info *gr, float *scf, int ch)
-{
-    static const drmp3_uint8 g_scf_partitions[3][28] = {
-        { 6,5,5, 5,6,5,5,5,6,5, 7,3,11,10,0,0, 7, 7, 7,0, 6, 6,6,3, 8, 8,5,0 },
-        { 8,9,6,12,6,9,9,9,6,9,12,6,15,18,0,0, 6,15,12,0, 6,12,9,6, 6,18,9,0 },
-        { 9,9,6,12,9,9,9,9,9,9,12,6,18,18,0,0,12,12,12,0,12, 9,9,6,15,12,9,0 }
-    };
-    const drmp3_uint8 *scf_partition = g_scf_partitions[!!gr->n_short_sfb + !gr->n_long_sfb];
-    drmp3_uint8 scf_size[4], iscf[40];
-    int i, scf_shift = gr->scalefac_scale + 1, gain_exp, scfsi = gr->scfsi;
-    float gain;
-    if (DRMP3_HDR_TEST_MPEG1(hdr))
-    {
-        static const drmp3_uint8 g_scfc_decode[16] = { 0,1,2,3, 12,5,6,7, 9,10,11,13, 14,15,18,19 };
-        int part = g_scfc_decode[gr->scalefac_compress];
-        scf_size[1] = scf_size[0] = (drmp3_uint8)(part >> 2);
-        scf_size[3] = scf_size[2] = (drmp3_uint8)(part & 3);
-    } else
-    {
-        static const drmp3_uint8 g_mod[6*4] = { 5,5,4,4,5,5,4,1,4,3,1,1,5,6,6,1,4,4,4,1,4,3,1,1 };
-        int k, modprod, sfc, ist = DRMP3_HDR_TEST_I_STEREO(hdr) && ch;
-        sfc = gr->scalefac_compress >> ist;
-        for (k = ist*3*4; sfc >= 0; sfc -= modprod, k += 4)
-        {
-            for (modprod = 1, i = 3; i >= 0; i--)
-            {
-                scf_size[i] = (drmp3_uint8)(sfc / modprod % g_mod[k + i]);
-                modprod *= g_mod[k + i];
-            }
-        }
-        scf_partition += k;
-        scfsi = -16;
-    }
-    drmp3_L3_read_scalefactors(iscf, ist_pos, scf_size, scf_partition, bs, scfsi);
-    if (gr->n_short_sfb)
-    {
-        int sh = 3 - scf_shift;
-        for (i = 0; i < gr->n_short_sfb; i += 3)
-        {
-            iscf[gr->n_long_sfb + i + 0] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 0] + (gr->subblock_gain[0] << sh));
-            iscf[gr->n_long_sfb + i + 1] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 1] + (gr->subblock_gain[1] << sh));
-            iscf[gr->n_long_sfb + i + 2] = (drmp3_uint8)(iscf[gr->n_long_sfb + i + 2] + (gr->subblock_gain[2] << sh));
-        }
-    } else if (gr->preflag)
-    {
-        static const drmp3_uint8 g_preamp[10] = { 1,1,1,1,2,2,3,3,3,2 };
-        for (i = 0; i < 10; i++)
-        {
-            iscf[11 + i] = (drmp3_uint8)(iscf[11 + i] + g_preamp[i]);
-        }
-    }
-    gain_exp = gr->global_gain + DRMP3_BITS_DEQUANTIZER_OUT*4 - 210 - (DRMP3_HDR_IS_MS_STEREO(hdr) ? 2 : 0);
-    gain = drmp3_L3_ldexp_q2(1 << (DRMP3_MAX_SCFI/4),  DRMP3_MAX_SCFI - gain_exp);
-    for (i = 0; i < (int)(gr->n_long_sfb + gr->n_short_sfb); i++)
-    {
-        scf[i] = drmp3_L3_ldexp_q2(gain, iscf[i] << scf_shift);
-    }
-}
-static const float g_drmp3_pow43[129 + 16] = {
-    0,-1,-2.519842f,-4.326749f,-6.349604f,-8.549880f,-10.902724f,-13.390518f,-16.000000f,-18.720754f,-21.544347f,-24.463781f,-27.473142f,-30.567351f,-33.741992f,-36.993181f,
-    0,1,2.519842f,4.326749f,6.349604f,8.549880f,10.902724f,13.390518f,16.000000f,18.720754f,21.544347f,24.463781f,27.473142f,30.567351f,33.741992f,36.993181f,40.317474f,43.711787f,47.173345f,50.699631f,54.288352f,57.937408f,61.644865f,65.408941f,69.227979f,73.100443f,77.024898f,81.000000f,85.024491f,89.097188f,93.216975f,97.382800f,101.593667f,105.848633f,110.146801f,114.487321f,118.869381f,123.292209f,127.755065f,132.257246f,136.798076f,141.376907f,145.993119f,150.646117f,155.335327f,160.060199f,164.820202f,169.614826f,174.443577f,179.305980f,184.201575f,189.129918f,194.090580f,199.083145f,204.107210f,209.162385f,214.248292f,219.364564f,224.510845f,229.686789f,234.892058f,240.126328f,245.389280f,250.680604f,256.000000f,261.347174f,266.721841f,272.123723f,277.552547f,283.008049f,288.489971f,293.998060f,299.532071f,305.091761f,310.676898f,316.287249f,321.922592f,327.582707f,333.267377f,338.976394f,344.709550f,350.466646f,356.247482f,362.051866f,367.879608f,373.730522f,379.604427f,385.501143f,391.420496f,397.362314f,403.326427f,409.312672f,415.320884f,421.350905f,427.402579f,433.475750f,439.570269f,445.685987f,451.822757f,457.980436f,464.158883f,470.357960f,476.577530f,482.817459f,489.077615f,495.357868f,501.658090f,507.978156f,514.317941f,520.677324f,527.056184f,533.454404f,539.871867f,546.308458f,552.764065f,559.238575f,565.731879f,572.243870f,578.774440f,585.323483f,591.890898f,598.476581f,605.080431f,611.702349f,618.342238f,625.000000f,631.675540f,638.368763f,645.079578f
-};
-static float drmp3_L3_pow_43(int x)
-{
-    float frac;
-    int sign, mult = 256;
-    if (x < 129)
-    {
-        return g_drmp3_pow43[16 + x];
-    }
-    if (x < 1024)
-    {
-        mult = 16;
-        x <<= 3;
-    }
-    sign = 2*x & 64;
-    frac = (float)((x & 63) - sign) / ((x & ~63) + sign);
-    return g_drmp3_pow43[16 + ((x + sign) >> 6)]*(1.f + frac*((4.f/3) + frac*(2.f/9)))*mult;
-}
-static void drmp3_L3_huffman(float *dst, drmp3_bs *bs, const drmp3_L3_gr_info *gr_info, const float *scf, int layer3gr_limit)
-{
-    static const drmp3_int16 tabs[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        785,785,785,785,784,784,784,784,513,513,513,513,513,513,513,513,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,
-        -255,1313,1298,1282,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,290,288,
-        -255,1313,1298,1282,769,769,769,769,529,529,529,529,529,529,529,529,528,528,528,528,528,528,528,528,512,512,512,512,512,512,512,512,290,288,
-        -253,-318,-351,-367,785,785,785,785,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,819,818,547,547,275,275,275,275,561,560,515,546,289,274,288,258,
-        -254,-287,1329,1299,1314,1312,1057,1057,1042,1042,1026,1026,784,784,784,784,529,529,529,529,529,529,529,529,769,769,769,769,768,768,768,768,563,560,306,306,291,259,
-        -252,-413,-477,-542,1298,-575,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-383,-399,1107,1092,1106,1061,849,849,789,789,1104,1091,773,773,1076,1075,341,340,325,309,834,804,577,577,532,532,516,516,832,818,803,816,561,561,531,531,515,546,289,289,288,258,
-        -252,-429,-493,-559,1057,1057,1042,1042,529,529,529,529,529,529,529,529,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,-382,1077,-415,1106,1061,1104,849,849,789,789,1091,1076,1029,1075,834,834,597,581,340,340,339,324,804,833,532,532,832,772,818,803,817,787,816,771,290,290,290,290,288,258,
-        -253,-349,-414,-447,-463,1329,1299,-479,1314,1312,1057,1057,1042,1042,1026,1026,785,785,785,785,784,784,784,784,769,769,769,769,768,768,768,768,-319,851,821,-335,836,850,805,849,341,340,325,336,533,533,579,579,564,564,773,832,578,548,563,516,321,276,306,291,304,259,
-        -251,-572,-733,-830,-863,-879,1041,1041,784,784,784,784,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,1396,1351,1381,1366,1395,1335,1380,-559,1334,1138,1138,1063,1063,1350,1392,1031,1031,1062,1062,1364,1363,1120,1120,1333,1348,881,881,881,881,375,374,359,373,343,358,341,325,791,791,1123,1122,-703,1105,1045,-719,865,865,790,790,774,774,1104,1029,338,293,323,308,-799,-815,833,788,772,818,803,816,322,292,307,320,561,531,515,546,289,274,288,258,
-        -251,-525,-605,-685,-765,-831,-846,1298,1057,1057,1312,1282,785,785,785,785,784,784,784,784,769,769,769,769,512,512,512,512,512,512,512,512,1399,1398,1383,1367,1382,1396,1351,-511,1381,1366,1139,1139,1079,1079,1124,1124,1364,1349,1363,1333,882,882,882,882,807,807,807,807,1094,1094,1136,1136,373,341,535,535,881,775,867,822,774,-591,324,338,-671,849,550,550,866,864,609,609,293,336,534,534,789,835,773,-751,834,804,308,307,833,788,832,772,562,562,547,547,305,275,560,515,290,290,
-        -252,-397,-477,-557,-622,-653,-719,-735,-750,1329,1299,1314,1057,1057,1042,1042,1312,1282,1024,1024,785,785,785,785,784,784,784,784,769,769,769,769,-383,1127,1141,1111,1126,1140,1095,1110,869,869,883,883,1079,1109,882,882,375,374,807,868,838,881,791,-463,867,822,368,263,852,837,836,-543,610,610,550,550,352,336,534,534,865,774,851,821,850,805,593,533,579,564,773,832,578,578,548,548,577,577,307,276,306,291,516,560,259,259,
-        -250,-2107,-2507,-2764,-2909,-2974,-3007,-3023,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-767,-1052,-1213,-1277,-1358,-1405,-1469,-1535,-1550,-1582,-1614,-1647,-1662,-1694,-1726,-1759,-1774,-1807,-1822,-1854,-1886,1565,-1919,-1935,-1951,-1967,1731,1730,1580,1717,-1983,1729,1564,-1999,1548,-2015,-2031,1715,1595,-2047,1714,-2063,1610,-2079,1609,-2095,1323,1323,1457,1457,1307,1307,1712,1547,1641,1700,1699,1594,1685,1625,1442,1442,1322,1322,-780,-973,-910,1279,1278,1277,1262,1276,1261,1275,1215,1260,1229,-959,974,974,989,989,-943,735,478,478,495,463,506,414,-1039,1003,958,1017,927,942,987,957,431,476,1272,1167,1228,-1183,1256,-1199,895,895,941,941,1242,1227,1212,1135,1014,1014,490,489,503,487,910,1013,985,925,863,894,970,955,1012,847,-1343,831,755,755,984,909,428,366,754,559,-1391,752,486,457,924,997,698,698,983,893,740,740,908,877,739,739,667,667,953,938,497,287,271,271,683,606,590,712,726,574,302,302,738,736,481,286,526,725,605,711,636,724,696,651,589,681,666,710,364,467,573,695,466,466,301,465,379,379,709,604,665,679,316,316,634,633,436,436,464,269,424,394,452,332,438,363,347,408,393,448,331,422,362,407,392,421,346,406,391,376,375,359,1441,1306,-2367,1290,-2383,1337,-2399,-2415,1426,1321,-2431,1411,1336,-2447,-2463,-2479,1169,1169,1049,1049,1424,1289,1412,1352,1319,-2495,1154,1154,1064,1064,1153,1153,416,390,360,404,403,389,344,374,373,343,358,372,327,357,342,311,356,326,1395,1394,1137,1137,1047,1047,1365,1392,1287,1379,1334,1364,1349,1378,1318,1363,792,792,792,792,1152,1152,1032,1032,1121,1121,1046,1046,1120,1120,1030,1030,-2895,1106,1061,1104,849,849,789,789,1091,1076,1029,1090,1060,1075,833,833,309,324,532,532,832,772,818,803,561,561,531,560,515,546,289,274,288,258,
-        -250,-1179,-1579,-1836,-1996,-2124,-2253,-2333,-2413,-2477,-2542,-2574,-2607,-2622,-2655,1314,1313,1298,1312,1282,785,785,785,785,1040,1040,1025,1025,768,768,768,768,-766,-798,-830,-862,-895,-911,-927,-943,-959,-975,-991,-1007,-1023,-1039,-1055,-1070,1724,1647,-1103,-1119,1631,1767,1662,1738,1708,1723,-1135,1780,1615,1779,1599,1677,1646,1778,1583,-1151,1777,1567,1737,1692,1765,1722,1707,1630,1751,1661,1764,1614,1736,1676,1763,1750,1645,1598,1721,1691,1762,1706,1582,1761,1566,-1167,1749,1629,767,766,751,765,494,494,735,764,719,749,734,763,447,447,748,718,477,506,431,491,446,476,461,505,415,430,475,445,504,399,460,489,414,503,383,474,429,459,502,502,746,752,488,398,501,473,413,472,486,271,480,270,-1439,-1455,1357,-1471,-1487,-1503,1341,1325,-1519,1489,1463,1403,1309,-1535,1372,1448,1418,1476,1356,1462,1387,-1551,1475,1340,1447,1402,1386,-1567,1068,1068,1474,1461,455,380,468,440,395,425,410,454,364,467,466,464,453,269,409,448,268,432,1371,1473,1432,1417,1308,1460,1355,1446,1459,1431,1083,1083,1401,1416,1458,1445,1067,1067,1370,1457,1051,1051,1291,1430,1385,1444,1354,1415,1400,1443,1082,1082,1173,1113,1186,1066,1185,1050,-1967,1158,1128,1172,1097,1171,1081,-1983,1157,1112,416,266,375,400,1170,1142,1127,1065,793,793,1169,1033,1156,1096,1141,1111,1155,1080,1126,1140,898,898,808,808,897,897,792,792,1095,1152,1032,1125,1110,1139,1079,1124,882,807,838,881,853,791,-2319,867,368,263,822,852,837,866,806,865,-2399,851,352,262,534,534,821,836,594,594,549,549,593,593,533,533,848,773,579,579,564,578,548,563,276,276,577,576,306,291,516,560,305,305,275,259,
-        -251,-892,-2058,-2620,-2828,-2957,-3023,-3039,1041,1041,1040,1040,769,769,769,769,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,256,-511,-527,-543,-559,1530,-575,-591,1528,1527,1407,1526,1391,1023,1023,1023,1023,1525,1375,1268,1268,1103,1103,1087,1087,1039,1039,1523,-604,815,815,815,815,510,495,509,479,508,463,507,447,431,505,415,399,-734,-782,1262,-815,1259,1244,-831,1258,1228,-847,-863,1196,-879,1253,987,987,748,-767,493,493,462,477,414,414,686,669,478,446,461,445,474,429,487,458,412,471,1266,1264,1009,1009,799,799,-1019,-1276,-1452,-1581,-1677,-1757,-1821,-1886,-1933,-1997,1257,1257,1483,1468,1512,1422,1497,1406,1467,1496,1421,1510,1134,1134,1225,1225,1466,1451,1374,1405,1252,1252,1358,1480,1164,1164,1251,1251,1238,1238,1389,1465,-1407,1054,1101,-1423,1207,-1439,830,830,1248,1038,1237,1117,1223,1148,1236,1208,411,426,395,410,379,269,1193,1222,1132,1235,1221,1116,976,976,1192,1162,1177,1220,1131,1191,963,963,-1647,961,780,-1663,558,558,994,993,437,408,393,407,829,978,813,797,947,-1743,721,721,377,392,844,950,828,890,706,706,812,859,796,960,948,843,934,874,571,571,-1919,690,555,689,421,346,539,539,944,779,918,873,932,842,903,888,570,570,931,917,674,674,-2575,1562,-2591,1609,-2607,1654,1322,1322,1441,1441,1696,1546,1683,1593,1669,1624,1426,1426,1321,1321,1639,1680,1425,1425,1305,1305,1545,1668,1608,1623,1667,1592,1638,1666,1320,1320,1652,1607,1409,1409,1304,1304,1288,1288,1664,1637,1395,1395,1335,1335,1622,1636,1394,1394,1319,1319,1606,1621,1392,1392,1137,1137,1137,1137,345,390,360,375,404,373,1047,-2751,-2767,-2783,1062,1121,1046,-2799,1077,-2815,1106,1061,789,789,1105,1104,263,355,310,340,325,354,352,262,339,324,1091,1076,1029,1090,1060,1075,833,833,788,788,1088,1028,818,818,803,803,561,561,531,531,816,771,546,546,289,274,288,258,
-        -253,-317,-381,-446,-478,-509,1279,1279,-811,-1179,-1451,-1756,-1900,-2028,-2189,-2253,-2333,-2414,-2445,-2511,-2526,1313,1298,-2559,1041,1041,1040,1040,1025,1025,1024,1024,1022,1007,1021,991,1020,975,1019,959,687,687,1018,1017,671,671,655,655,1016,1015,639,639,758,758,623,623,757,607,756,591,755,575,754,559,543,543,1009,783,-575,-621,-685,-749,496,-590,750,749,734,748,974,989,1003,958,988,973,1002,942,987,957,972,1001,926,986,941,971,956,1000,910,985,925,999,894,970,-1071,-1087,-1102,1390,-1135,1436,1509,1451,1374,-1151,1405,1358,1480,1420,-1167,1507,1494,1389,1342,1465,1435,1450,1326,1505,1310,1493,1373,1479,1404,1492,1464,1419,428,443,472,397,736,526,464,464,486,457,442,471,484,482,1357,1449,1434,1478,1388,1491,1341,1490,1325,1489,1463,1403,1309,1477,1372,1448,1418,1433,1476,1356,1462,1387,-1439,1475,1340,1447,1402,1474,1324,1461,1371,1473,269,448,1432,1417,1308,1460,-1711,1459,-1727,1441,1099,1099,1446,1386,1431,1401,-1743,1289,1083,1083,1160,1160,1458,1445,1067,1067,1370,1457,1307,1430,1129,1129,1098,1098,268,432,267,416,266,400,-1887,1144,1187,1082,1173,1113,1186,1066,1050,1158,1128,1143,1172,1097,1171,1081,420,391,1157,1112,1170,1142,1127,1065,1169,1049,1156,1096,1141,1111,1155,1080,1126,1154,1064,1153,1140,1095,1048,-2159,1125,1110,1137,-2175,823,823,1139,1138,807,807,384,264,368,263,868,838,853,791,867,822,852,837,866,806,865,790,-2319,851,821,836,352,262,850,805,849,-2399,533,533,835,820,336,261,578,548,563,577,532,532,832,772,562,562,547,547,305,275,560,515,290,290,288,258 };
-    static const drmp3_uint8 tab32[] = { 130,162,193,209,44,28,76,140,9,9,9,9,9,9,9,9,190,254,222,238,126,94,157,157,109,61,173,205};
-    static const drmp3_uint8 tab33[] = { 252,236,220,204,188,172,156,140,124,108,92,76,60,44,28,12 };
-    static const drmp3_int16 tabindex[2*16] = { 0,32,64,98,0,132,180,218,292,364,426,538,648,746,0,1126,1460,1460,1460,1460,1460,1460,1460,1460,1842,1842,1842,1842,1842,1842,1842,1842 };
-    static const drmp3_uint8 g_linbits[] =  { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,6,8,10,13,4,5,6,7,8,9,11,13 };
-#define DRMP3_PEEK_BITS(n)    (bs_cache >> (32 - n))
-#define DRMP3_FLUSH_BITS(n)   { bs_cache <<= (n); bs_sh += (n); }
-#define DRMP3_CHECK_BITS      while (bs_sh >= 0) { bs_cache |= (drmp3_uint32)*bs_next_ptr++ << bs_sh; bs_sh -= 8; }
-#define DRMP3_BSPOS           ((bs_next_ptr - bs->buf)*8 - 24 + bs_sh)
-    float one = 0.0f;
-    int ireg = 0, big_val_cnt = gr_info->big_values;
-    const drmp3_uint8 *sfb = gr_info->sfbtab;
-    const drmp3_uint8 *bs_next_ptr = bs->buf + bs->pos/8;
-    drmp3_uint32 bs_cache = (((bs_next_ptr[0]*256u + bs_next_ptr[1])*256u + bs_next_ptr[2])*256u + bs_next_ptr[3]) << (bs->pos & 7);
-    int pairs_to_decode, np, bs_sh = (bs->pos & 7) - 8;
-    bs_next_ptr += 4;
-    while (big_val_cnt > 0)
-    {
-        int tab_num = gr_info->table_select[ireg];
-        int sfb_cnt = gr_info->region_count[ireg++];
-        const drmp3_int16 *codebook = tabs + tabindex[tab_num];
-        int linbits = g_linbits[tab_num];
-        if (linbits)
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        if (lsb == 15)
-                        {
-                            lsb += DRMP3_PEEK_BITS(linbits);
-                            DRMP3_FLUSH_BITS(linbits);
-                            DRMP3_CHECK_BITS;
-                            *dst = one*drmp3_L3_pow_43(lsb)*((drmp3_int32)bs_cache < 0 ? -1: 1);
-                        } else
-                        {
-                            *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        }
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        } else
-        {
-            do
-            {
-                np = *sfb++ / 2;
-                pairs_to_decode = DRMP3_MIN(big_val_cnt, np);
-                one = *scf++;
-                do
-                {
-                    int j, w = 5;
-                    int leaf = codebook[DRMP3_PEEK_BITS(w)];
-                    while (leaf < 0)
-                    {
-                        DRMP3_FLUSH_BITS(w);
-                        w = leaf & 7;
-                        leaf = codebook[DRMP3_PEEK_BITS(w) - (leaf >> 3)];
-                    }
-                    DRMP3_FLUSH_BITS(leaf >> 8);
-                    for (j = 0; j < 2; j++, dst++, leaf >>= 4)
-                    {
-                        int lsb = leaf & 0x0F;
-                        *dst = g_drmp3_pow43[16 + lsb - 16*(bs_cache >> 31)]*one;
-                        DRMP3_FLUSH_BITS(lsb ? 1 : 0);
-                    }
-                    DRMP3_CHECK_BITS;
-                } while (--pairs_to_decode);
-            } while ((big_val_cnt -= np) > 0 && --sfb_cnt >= 0);
-        }
-    }
-    for (np = 1 - big_val_cnt;; dst += 4)
-    {
-        const drmp3_uint8 *codebook_count1 = (gr_info->count1_table) ? tab33 : tab32;
-        int leaf = codebook_count1[DRMP3_PEEK_BITS(4)];
-        if (!(leaf & 8))
-        {
-            leaf = codebook_count1[(leaf >> 3) + (bs_cache << 4 >> (32 - (leaf & 3)))];
-        }
-        DRMP3_FLUSH_BITS(leaf & 7);
-        if (DRMP3_BSPOS > layer3gr_limit)
-        {
-            break;
-        }
-#define DRMP3_RELOAD_SCALEFACTOR  if (!--np) { np = *sfb++/2; if (!np) break; one = *scf++; }
-#define DRMP3_DEQ_COUNT1(s) if (leaf & (128 >> s)) { dst[s] = ((drmp3_int32)bs_cache < 0) ? -one : one; DRMP3_FLUSH_BITS(1) }
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(0);
-        DRMP3_DEQ_COUNT1(1);
-        DRMP3_RELOAD_SCALEFACTOR;
-        DRMP3_DEQ_COUNT1(2);
-        DRMP3_DEQ_COUNT1(3);
-        DRMP3_CHECK_BITS;
-    }
-    bs->pos = layer3gr_limit;
-}
-static void drmp3_L3_midside_stereo(float *left, int n)
-{
-    int i = 0;
-    float *right = left + 576;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; i < n - 3; i += 4)
-    {
-        drmp3_f4 vl = DRMP3_VLD(left + i);
-        drmp3_f4 vr = DRMP3_VLD(right + i);
-        DRMP3_VSTORE(left + i, DRMP3_VADD(vl, vr));
-        DRMP3_VSTORE(right + i, DRMP3_VSUB(vl, vr));
-    }
-#endif
-    for (; i < n; i++)
-    {
-        float a = left[i];
-        float b = right[i];
-        left[i] = a + b;
-        right[i] = a - b;
-    }
-}
-static void drmp3_L3_intensity_stereo_band(float *left, int n, float kl, float kr)
-{
-    int i;
-    for (i = 0; i < n; i++)
-    {
-        left[i + 576] = left[i]*kr;
-        left[i] = left[i]*kl;
-    }
-}
-static void drmp3_L3_stereo_top_band(const float *right, const drmp3_uint8 *sfb, int nbands, int max_band[3])
-{
-    int i, k;
-    max_band[0] = max_band[1] = max_band[2] = -1;
-    for (i = 0; i < nbands; i++)
-    {
-        for (k = 0; k < sfb[i]; k += 2)
-        {
-            if (right[k] != 0 || right[k + 1] != 0)
-            {
-                max_band[i % 3] = i;
-                break;
-            }
-        }
-        right += sfb[i];
-    }
-}
-static void drmp3_L3_stereo_process(float *left, const drmp3_uint8 *ist_pos, const drmp3_uint8 *sfb, const drmp3_uint8 *hdr, int max_band[3], int mpeg2_sh)
-{
-    static const float g_pan[7*2] = { 0,1,0.21132487f,0.78867513f,0.36602540f,0.63397460f,0.5f,0.5f,0.63397460f,0.36602540f,0.78867513f,0.21132487f,1,0 };
-    unsigned i, max_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 7 : 64;
-    for (i = 0; sfb[i]; i++)
-    {
-        unsigned ipos = ist_pos[i];
-        if ((int)i > max_band[i % 3] && ipos < max_pos)
-        {
-            float kl, kr, s = DRMP3_HDR_TEST_MS_STEREO(hdr) ? 1.41421356f : 1;
-            if (DRMP3_HDR_TEST_MPEG1(hdr))
-            {
-                kl = g_pan[2*ipos];
-                kr = g_pan[2*ipos + 1];
-            } else
-            {
-                kl = 1;
-                kr = drmp3_L3_ldexp_q2(1, (ipos + 1) >> 1 << mpeg2_sh);
-                if (ipos & 1)
-                {
-                    kl = kr;
-                    kr = 1;
-                }
-            }
-            drmp3_L3_intensity_stereo_band(left, sfb[i], kl*s, kr*s);
-        } else if (DRMP3_HDR_TEST_MS_STEREO(hdr))
-        {
-            drmp3_L3_midside_stereo(left, sfb[i]);
-        }
-        left += sfb[i];
-    }
-}
-static void drmp3_L3_intensity_stereo(float *left, drmp3_uint8 *ist_pos, const drmp3_L3_gr_info *gr, const drmp3_uint8 *hdr)
-{
-    int max_band[3], n_sfb = gr->n_long_sfb + gr->n_short_sfb;
-    int i, max_blocks = gr->n_short_sfb ? 3 : 1;
-    drmp3_L3_stereo_top_band(left + 576, gr->sfbtab, n_sfb, max_band);
-    if (gr->n_long_sfb)
-    {
-        max_band[0] = max_band[1] = max_band[2] = DRMP3_MAX(DRMP3_MAX(max_band[0], max_band[1]), max_band[2]);
-    }
-    for (i = 0; i < max_blocks; i++)
-    {
-        int default_pos = DRMP3_HDR_TEST_MPEG1(hdr) ? 3 : 0;
-        int itop = n_sfb - max_blocks + i;
-        int prev = itop - max_blocks;
-        ist_pos[itop] = (drmp3_uint8)(max_band[i] >= prev ? default_pos : ist_pos[prev]);
-    }
-    drmp3_L3_stereo_process(left, ist_pos, gr->sfbtab, hdr, max_band, gr[1].scalefac_compress & 1);
-}
-static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sfb)
-{
-    int i, len;
-    float *src = grbuf, *dst = scratch;
-    for (;0 != (len = *sfb); sfb += 3, src += 2*len)
-    {
-        for (i = 0; i < len; i++, src++)
-        {
-            *dst++ = src[0*len];
-            *dst++ = src[1*len];
-            *dst++ = src[2*len];
-        }
-    }
-    memcpy(grbuf, scratch, (dst - scratch)*sizeof(float));
-}
-static void drmp3_L3_antialias(float *grbuf, int nbands)
-{
-    static const float g_aa[2][8] = {
-        {0.85749293f,0.88174200f,0.94962865f,0.98331459f,0.99551782f,0.99916056f,0.99989920f,0.99999316f},
-        {0.51449576f,0.47173197f,0.31337745f,0.18191320f,0.09457419f,0.04096558f,0.01419856f,0.00369997f}
-    };
-    for (; nbands > 0; nbands--, grbuf += 18)
-    {
-        int i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vu = DRMP3_VLD(grbuf + 18 + i);
-            drmp3_f4 vd = DRMP3_VLD(grbuf + 14 - i);
-            drmp3_f4 vc0 = DRMP3_VLD(g_aa[0] + i);
-            drmp3_f4 vc1 = DRMP3_VLD(g_aa[1] + i);
-            vd = DRMP3_VREV(vd);
-            DRMP3_VSTORE(grbuf + 18 + i, DRMP3_VSUB(DRMP3_VMUL(vu, vc0), DRMP3_VMUL(vd, vc1)));
-            vd = DRMP3_VADD(DRMP3_VMUL(vu, vc1), DRMP3_VMUL(vd, vc0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vd));
-        }
-#endif
-#ifndef DR_MP3_ONLY_SIMD
-        for(; i < 8; i++)
-        {
-            float u = grbuf[18 + i];
-            float d = grbuf[17 - i];
-            grbuf[18 + i] = u*g_aa[0][i] - d*g_aa[1][i];
-            grbuf[17 - i] = u*g_aa[1][i] + d*g_aa[0][i];
-        }
-#endif
-    }
-}
-static void drmp3_L3_dct3_9(float *y)
-{
-    float s0, s1, s2, s3, s4, s5, s6, s7, s8, t0, t2, t4;
-    s0 = y[0]; s2 = y[2]; s4 = y[4]; s6 = y[6]; s8 = y[8];
-    t0 = s0 + s6*0.5f;
-    s0 -= s6;
-    t4 = (s4 + s2)*0.93969262f;
-    t2 = (s8 + s2)*0.76604444f;
-    s6 = (s4 - s8)*0.17364818f;
-    s4 += s8 - s2;
-    s2 = s0 - s4*0.5f;
-    y[4] = s4 + s0;
-    s8 = t0 - t2 + s6;
-    s0 = t0 - t4 + t2;
-    s4 = t0 + t4 - s6;
-    s1 = y[1]; s3 = y[3]; s5 = y[5]; s7 = y[7];
-    s3 *= 0.86602540f;
-    t0 = (s5 + s1)*0.98480775f;
-    t4 = (s5 - s7)*0.34202014f;
-    t2 = (s1 + s7)*0.64278761f;
-    s1 = (s1 - s5 - s7)*0.86602540f;
-    s5 = t0 - s3 - t2;
-    s7 = t4 - s3 - t0;
-    s3 = t4 + s3 - t2;
-    y[0] = s4 - s7;
-    y[1] = s2 + s1;
-    y[2] = s0 - s3;
-    y[3] = s8 + s5;
-    y[5] = s8 - s5;
-    y[6] = s0 + s3;
-    y[7] = s2 - s1;
-    y[8] = s4 + s7;
-}
-static void drmp3_L3_imdct36(float *grbuf, float *overlap, const float *window, int nbands)
-{
-    int i, j;
-    static const float g_twid9[18] = {
-        0.73727734f,0.79335334f,0.84339145f,0.88701083f,0.92387953f,0.95371695f,0.97629601f,0.99144486f,0.99904822f,0.67559021f,0.60876143f,0.53729961f,0.46174861f,0.38268343f,0.30070580f,0.21643961f,0.13052619f,0.04361938f
-    };
-    for (j = 0; j < nbands; j++, grbuf += 18, overlap += 9)
-    {
-        float co[9], si[9];
-        co[0] = -grbuf[0];
-        si[0] = grbuf[17];
-        for (i = 0; i < 4; i++)
-        {
-            si[8 - 2*i] =   grbuf[4*i + 1] - grbuf[4*i + 2];
-            co[1 + 2*i] =   grbuf[4*i + 1] + grbuf[4*i + 2];
-            si[7 - 2*i] =   grbuf[4*i + 4] - grbuf[4*i + 3];
-            co[2 + 2*i] = -(grbuf[4*i + 3] + grbuf[4*i + 4]);
-        }
-        drmp3_L3_dct3_9(co);
-        drmp3_L3_dct3_9(si);
-        si[1] = -si[1];
-        si[3] = -si[3];
-        si[5] = -si[5];
-        si[7] = -si[7];
-        i = 0;
-#if DRMP3_HAVE_SIMD
-        if (drmp3_have_simd()) for (; i < 8; i += 4)
-        {
-            drmp3_f4 vovl = DRMP3_VLD(overlap + i);
-            drmp3_f4 vc = DRMP3_VLD(co + i);
-            drmp3_f4 vs = DRMP3_VLD(si + i);
-            drmp3_f4 vr0 = DRMP3_VLD(g_twid9 + i);
-            drmp3_f4 vr1 = DRMP3_VLD(g_twid9 + 9 + i);
-            drmp3_f4 vw0 = DRMP3_VLD(window + i);
-            drmp3_f4 vw1 = DRMP3_VLD(window + 9 + i);
-            drmp3_f4 vsum = DRMP3_VADD(DRMP3_VMUL(vc, vr1), DRMP3_VMUL(vs, vr0));
-            DRMP3_VSTORE(overlap + i, DRMP3_VSUB(DRMP3_VMUL(vc, vr0), DRMP3_VMUL(vs, vr1)));
-            DRMP3_VSTORE(grbuf + i, DRMP3_VSUB(DRMP3_VMUL(vovl, vw0), DRMP3_VMUL(vsum, vw1)));
-            vsum = DRMP3_VADD(DRMP3_VMUL(vovl, vw1), DRMP3_VMUL(vsum, vw0));
-            DRMP3_VSTORE(grbuf + 14 - i, DRMP3_VREV(vsum));
-        }
-#endif
-        for (; i < 9; i++)
-        {
-            float ovl  = overlap[i];
-            float sum  = co[i]*g_twid9[9 + i] + si[i]*g_twid9[0 + i];
-            overlap[i] = co[i]*g_twid9[0 + i] - si[i]*g_twid9[9 + i];
-            grbuf[i]      = ovl*window[0 + i] - sum*window[9 + i];
-            grbuf[17 - i] = ovl*window[9 + i] + sum*window[0 + i];
-        }
-    }
-}
-static void drmp3_L3_idct3(float x0, float x1, float x2, float *dst)
-{
-    float m1 = x1*0.86602540f;
-    float a1 = x0 - x2*0.5f;
-    dst[1] = x0 + x2;
-    dst[0] = a1 + m1;
-    dst[2] = a1 - m1;
-}
-static void drmp3_L3_imdct12(float *x, float *dst, float *overlap)
-{
-    static const float g_twid3[6] = { 0.79335334f,0.92387953f,0.99144486f, 0.60876143f,0.38268343f,0.13052619f };
-    float co[3], si[3];
-    int i;
-    drmp3_L3_idct3(-x[0], x[6] + x[3], x[12] + x[9], co);
-    drmp3_L3_idct3(x[15], x[12] - x[9], x[6] - x[3], si);
-    si[1] = -si[1];
-    for (i = 0; i < 3; i++)
-    {
-        float ovl  = overlap[i];
-        float sum  = co[i]*g_twid3[3 + i] + si[i]*g_twid3[0 + i];
-        overlap[i] = co[i]*g_twid3[0 + i] - si[i]*g_twid3[3 + i];
-        dst[i]     = ovl*g_twid3[2 - i] - sum*g_twid3[5 - i];
-        dst[5 - i] = ovl*g_twid3[5 - i] + sum*g_twid3[2 - i];
-    }
-}
-static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
-{
-    for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
-    {
-        float tmp[18];
-        memcpy(tmp, grbuf, sizeof(tmp));
-        memcpy(grbuf, overlap, 6*sizeof(float));
-        drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
-        drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
-        drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
-    }
-}
-static void drmp3_L3_change_sign(float *grbuf)
-{
-    int b, i;
-    for (b = 0, grbuf += 18; b < 32; b += 2, grbuf += 36)
-        for (i = 1; i < 18; i += 2)
-            grbuf[i] = -grbuf[i];
-}
-static void drmp3_L3_imdct_gr(float *grbuf, float *overlap, unsigned block_type, unsigned n_long_bands)
-{
-    static const float g_mdct_window[2][18] = {
-        { 0.99904822f,0.99144486f,0.97629601f,0.95371695f,0.92387953f,0.88701083f,0.84339145f,0.79335334f,0.73727734f,0.04361938f,0.13052619f,0.21643961f,0.30070580f,0.38268343f,0.46174861f,0.53729961f,0.60876143f,0.67559021f },
-        { 1,1,1,1,1,1,0.99144486f,0.92387953f,0.79335334f,0,0,0,0,0,0,0.13052619f,0.38268343f,0.60876143f }
-    };
-    if (n_long_bands)
-    {
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[0], n_long_bands);
-        grbuf += 18*n_long_bands;
-        overlap += 9*n_long_bands;
-    }
-    if (block_type == DRMP3_SHORT_BLOCK_TYPE)
-        drmp3_L3_imdct_short(grbuf, overlap, 32 - n_long_bands);
-    else
-        drmp3_L3_imdct36(grbuf, overlap, g_mdct_window[block_type == DRMP3_STOP_BLOCK_TYPE], 32 - n_long_bands);
-}
-static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
-{
-    int pos = (s->bs.pos + 7)/8u;
-    int remains = s->bs.limit/8u - pos;
-    if (remains > DRMP3_MAX_BITRESERVOIR_BYTES)
-    {
-        pos += remains - DRMP3_MAX_BITRESERVOIR_BYTES;
-        remains = DRMP3_MAX_BITRESERVOIR_BYTES;
-    }
-    if (remains > 0)
-    {
-        memmove(h->reserv_buf, s->maindata + pos, remains);
-    }
-    h->reserv = remains;
-}
-static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratch *s, int main_data_begin)
-{
-    int frame_bytes = (bs->limit - bs->pos)/8;
-    int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
-    memcpy(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
-    memcpy(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
-    drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
-    return h->reserv >= main_data_begin;
-}
-static void drmp3_L3_decode(drmp3dec *h, drmp3dec_scratch *s, drmp3_L3_gr_info *gr_info, int nch)
-{
-    int ch;
-    for (ch = 0; ch < nch; ch++)
-    {
-        int layer3gr_limit = s->bs.pos + gr_info[ch].part_23_length;
-        drmp3_L3_decode_scalefactors(h->header, s->ist_pos[ch], &s->bs, gr_info + ch, s->scf, ch);
-        drmp3_L3_huffman(s->grbuf[ch], &s->bs, gr_info + ch, s->scf, layer3gr_limit);
-    }
-    if (DRMP3_HDR_TEST_I_STEREO(h->header))
-    {
-        drmp3_L3_intensity_stereo(s->grbuf[0], s->ist_pos[1], gr_info, h->header);
-    } else if (DRMP3_HDR_IS_MS_STEREO(h->header))
-    {
-        drmp3_L3_midside_stereo(s->grbuf[0], 576);
-    }
-    for (ch = 0; ch < nch; ch++, gr_info++)
-    {
-        int aa_bands = 31;
-        int n_long_bands = (gr_info->mixed_block_flag ? 2 : 0) << (int)(DRMP3_HDR_GET_MY_SAMPLE_RATE(h->header) == 2);
-        if (gr_info->n_short_sfb)
-        {
-            aa_bands = n_long_bands - 1;
-            drmp3_L3_reorder(s->grbuf[ch] + n_long_bands*18, s->syn[0], gr_info->sfbtab + gr_info->n_long_sfb);
-        }
-        drmp3_L3_antialias(s->grbuf[ch], aa_bands);
-        drmp3_L3_imdct_gr(s->grbuf[ch], h->mdct_overlap[ch], gr_info->block_type, n_long_bands);
-        drmp3_L3_change_sign(s->grbuf[ch]);
-    }
-}
-static void drmp3d_DCT_II(float *grbuf, int n)
-{
-    static const float g_sec[24] = {
-        10.19000816f,0.50060302f,0.50241929f,3.40760851f,0.50547093f,0.52249861f,2.05778098f,0.51544732f,0.56694406f,1.48416460f,0.53104258f,0.64682180f,1.16943991f,0.55310392f,0.78815460f,0.97256821f,0.58293498f,1.06067765f,0.83934963f,0.62250412f,1.72244716f,0.74453628f,0.67480832f,5.10114861f
-    };
-    int i, k = 0;
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (; k < n; k += 4)
-    {
-        drmp3_f4 t[4][8], *x;
-        float *y = grbuf + k;
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            drmp3_f4 x0 = DRMP3_VLD(&y[i*18]);
-            drmp3_f4 x1 = DRMP3_VLD(&y[(15 - i)*18]);
-            drmp3_f4 x2 = DRMP3_VLD(&y[(16 + i)*18]);
-            drmp3_f4 x3 = DRMP3_VLD(&y[(31 - i)*18]);
-            drmp3_f4 t0 = DRMP3_VADD(x0, x3);
-            drmp3_f4 t1 = DRMP3_VADD(x1, x2);
-            drmp3_f4 t2 = DRMP3_VMUL_S(DRMP3_VSUB(x1, x2), g_sec[3*i + 0]);
-            drmp3_f4 t3 = DRMP3_VMUL_S(DRMP3_VSUB(x0, x3), g_sec[3*i + 1]);
-            x[0] = DRMP3_VADD(t0, t1);
-            x[8] = DRMP3_VMUL_S(DRMP3_VSUB(t0, t1), g_sec[3*i + 2]);
-            x[16] = DRMP3_VADD(t3, t2);
-            x[24] = DRMP3_VMUL_S(DRMP3_VSUB(t3, t2), g_sec[3*i + 2]);
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            drmp3_f4 x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = DRMP3_VSUB(x0, x7); x0 = DRMP3_VADD(x0, x7);
-            x7 = DRMP3_VSUB(x1, x6); x1 = DRMP3_VADD(x1, x6);
-            x6 = DRMP3_VSUB(x2, x5); x2 = DRMP3_VADD(x2, x5);
-            x5 = DRMP3_VSUB(x3, x4); x3 = DRMP3_VADD(x3, x4);
-            x4 = DRMP3_VSUB(x0, x3); x0 = DRMP3_VADD(x0, x3);
-            x3 = DRMP3_VSUB(x1, x2); x1 = DRMP3_VADD(x1, x2);
-            x[0] = DRMP3_VADD(x0, x1);
-            x[4] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x1), 0.70710677f);
-            x5 = DRMP3_VADD(x5, x6);
-            x6 = DRMP3_VMUL_S(DRMP3_VADD(x6, x7), 0.70710677f);
-            x7 = DRMP3_VADD(x7, xt);
-            x3 = DRMP3_VMUL_S(DRMP3_VADD(x3, x4), 0.70710677f);
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x7 = DRMP3_VADD(x7, DRMP3_VMUL_S(x5, 0.382683432f));
-            x5 = DRMP3_VSUB(x5, DRMP3_VMUL_S(x7, 0.198912367f));
-            x0 = DRMP3_VSUB(xt, x6); xt = DRMP3_VADD(xt, x6);
-            x[1] = DRMP3_VMUL_S(DRMP3_VADD(xt, x7), 0.50979561f);
-            x[2] = DRMP3_VMUL_S(DRMP3_VADD(x4, x3), 0.54119611f);
-            x[3] = DRMP3_VMUL_S(DRMP3_VSUB(x0, x5), 0.60134488f);
-            x[5] = DRMP3_VMUL_S(DRMP3_VADD(x0, x5), 0.89997619f);
-            x[6] = DRMP3_VMUL_S(DRMP3_VSUB(x4, x3), 1.30656302f);
-            x[7] = DRMP3_VMUL_S(DRMP3_VSUB(xt, x7), 2.56291556f);
-        }
-        if (k > n - 3)
-        {
-#if DRMP3_HAVE_SSE
-#define DRMP3_VSAVE2(i, v) _mm_storel_pi((__m64 *)(void*)&y[i*18], v)
-#else
-#define DRMP3_VSAVE2(i, v) vst1_f32((float32_t *)&y[i*18],  vget_low_f32(v))
-#endif
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE2(0, t[0][i]);
-                DRMP3_VSAVE2(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE2(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE2(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE2(0, t[0][7]);
-            DRMP3_VSAVE2(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE2(2, t[1][7]);
-            DRMP3_VSAVE2(3, t[3][7]);
-        } else
-        {
-#define DRMP3_VSAVE4(i, v) DRMP3_VSTORE(&y[i*18], v)
-            for (i = 0; i < 7; i++, y += 4*18)
-            {
-                drmp3_f4 s = DRMP3_VADD(t[3][i], t[3][i + 1]);
-                DRMP3_VSAVE4(0, t[0][i]);
-                DRMP3_VSAVE4(1, DRMP3_VADD(t[2][i], s));
-                DRMP3_VSAVE4(2, DRMP3_VADD(t[1][i], t[1][i + 1]));
-                DRMP3_VSAVE4(3, DRMP3_VADD(t[2][1 + i], s));
-            }
-            DRMP3_VSAVE4(0, t[0][7]);
-            DRMP3_VSAVE4(1, DRMP3_VADD(t[2][7], t[3][7]));
-            DRMP3_VSAVE4(2, t[1][7]);
-            DRMP3_VSAVE4(3, t[3][7]);
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {}
-#else
-    for (; k < n; k++)
-    {
-        float t[4][8], *x, *y = grbuf + k;
-        for (x = t[0], i = 0; i < 8; i++, x++)
-        {
-            float x0 = y[i*18];
-            float x1 = y[(15 - i)*18];
-            float x2 = y[(16 + i)*18];
-            float x3 = y[(31 - i)*18];
-            float t0 = x0 + x3;
-            float t1 = x1 + x2;
-            float t2 = (x1 - x2)*g_sec[3*i + 0];
-            float t3 = (x0 - x3)*g_sec[3*i + 1];
-            x[0] = t0 + t1;
-            x[8] = (t0 - t1)*g_sec[3*i + 2];
-            x[16] = t3 + t2;
-            x[24] = (t3 - t2)*g_sec[3*i + 2];
-        }
-        for (x = t[0], i = 0; i < 4; i++, x += 8)
-        {
-            float x0 = x[0], x1 = x[1], x2 = x[2], x3 = x[3], x4 = x[4], x5 = x[5], x6 = x[6], x7 = x[7], xt;
-            xt = x0 - x7; x0 += x7;
-            x7 = x1 - x6; x1 += x6;
-            x6 = x2 - x5; x2 += x5;
-            x5 = x3 - x4; x3 += x4;
-            x4 = x0 - x3; x0 += x3;
-            x3 = x1 - x2; x1 += x2;
-            x[0] = x0 + x1;
-            x[4] = (x0 - x1)*0.70710677f;
-            x5 =  x5 + x6;
-            x6 = (x6 + x7)*0.70710677f;
-            x7 =  x7 + xt;
-            x3 = (x3 + x4)*0.70710677f;
-            x5 -= x7*0.198912367f;
-            x7 += x5*0.382683432f;
-            x5 -= x7*0.198912367f;
-            x0 = xt - x6; xt += x6;
-            x[1] = (xt + x7)*0.50979561f;
-            x[2] = (x4 + x3)*0.54119611f;
-            x[3] = (x0 - x5)*0.60134488f;
-            x[5] = (x0 + x5)*0.89997619f;
-            x[6] = (x4 - x3)*1.30656302f;
-            x[7] = (xt - x7)*2.56291556f;
-        }
-        for (i = 0; i < 7; i++, y += 4*18)
-        {
-            y[0*18] = t[0][i];
-            y[1*18] = t[2][i] + t[3][i] + t[3][i + 1];
-            y[2*18] = t[1][i] + t[1][i + 1];
-            y[3*18] = t[2][i + 1] + t[3][i] + t[3][i + 1];
-        }
-        y[0*18] = t[0][7];
-        y[1*18] = t[2][7] + t[3][7];
-        y[2*18] = t[1][7];
-        y[3*18] = t[3][7];
-    }
-#endif
-}
-#ifndef DR_MP3_FLOAT_OUTPUT
-typedef drmp3_int16 drmp3d_sample_t;
-static drmp3_int16 drmp3d_scale_pcm(float sample)
-{
-    drmp3_int16 s;
-#if DRMP3_HAVE_ARMV6
-    drmp3_int32 s32 = (drmp3_int32)(sample + .5f);
-    s32 -= (s32 < 0);
-    s = (drmp3_int16)drmp3_clip_int16_arm(s32);
-#else
-    if (sample >=  32766.5) return (drmp3_int16) 32767;
-    if (sample <= -32767.5) return (drmp3_int16)-32768;
-    s = (drmp3_int16)(sample + .5f);
-    s -= (s < 0);
-#endif
-    return s;
-}
-#else
-typedef float drmp3d_sample_t;
-static float drmp3d_scale_pcm(float sample)
-{
-    return sample*(1.f/32768.f);
-}
-#endif
-static void drmp3d_synth_pair(drmp3d_sample_t *pcm, int nch, const float *z)
-{
-    float a;
-    a  = (z[14*64] - z[    0]) * 29;
-    a += (z[ 1*64] + z[13*64]) * 213;
-    a += (z[12*64] - z[ 2*64]) * 459;
-    a += (z[ 3*64] + z[11*64]) * 2037;
-    a += (z[10*64] - z[ 4*64]) * 5153;
-    a += (z[ 5*64] + z[ 9*64]) * 6574;
-    a += (z[ 8*64] - z[ 6*64]) * 37489;
-    a +=  z[ 7*64]             * 75038;
-    pcm[0] = drmp3d_scale_pcm(a);
-    z += 2;
-    a  = z[14*64] * 104;
-    a += z[12*64] * 1567;
-    a += z[10*64] * 9727;
-    a += z[ 8*64] * 64019;
-    a += z[ 6*64] * -9975;
-    a += z[ 4*64] * -45;
-    a += z[ 2*64] * 146;
-    a += z[ 0*64] * -5;
-    pcm[16*nch] = drmp3d_scale_pcm(a);
-}
-static void drmp3d_synth(float *xl, drmp3d_sample_t *dstl, int nch, float *lins)
-{
-    int i;
-    float *xr = xl + 576*(nch - 1);
-    drmp3d_sample_t *dstr = dstl + (nch - 1);
-    static const float g_win[] = {
-        -1,26,-31,208,218,401,-519,2063,2000,4788,-5517,7134,5959,35640,-39336,74992,
-        -1,24,-35,202,222,347,-581,2080,1952,4425,-5879,7640,5288,33791,-41176,74856,
-        -1,21,-38,196,225,294,-645,2087,1893,4063,-6237,8092,4561,31947,-43006,74630,
-        -1,19,-41,190,227,244,-711,2085,1822,3705,-6589,8492,3776,30112,-44821,74313,
-        -1,17,-45,183,228,197,-779,2075,1739,3351,-6935,8840,2935,28289,-46617,73908,
-        -1,16,-49,176,228,153,-848,2057,1644,3004,-7271,9139,2037,26482,-48390,73415,
-        -2,14,-53,169,227,111,-919,2032,1535,2663,-7597,9389,1082,24694,-50137,72835,
-        -2,13,-58,161,224,72,-991,2001,1414,2330,-7910,9592,70,22929,-51853,72169,
-        -2,11,-63,154,221,36,-1064,1962,1280,2006,-8209,9750,-998,21189,-53534,71420,
-        -2,10,-68,147,215,2,-1137,1919,1131,1692,-8491,9863,-2122,19478,-55178,70590,
-        -3,9,-73,139,208,-29,-1210,1870,970,1388,-8755,9935,-3300,17799,-56778,69679,
-        -3,8,-79,132,200,-57,-1283,1817,794,1095,-8998,9966,-4533,16155,-58333,68692,
-        -4,7,-85,125,189,-83,-1356,1759,605,814,-9219,9959,-5818,14548,-59838,67629,
-        -4,7,-91,117,177,-106,-1428,1698,402,545,-9416,9916,-7154,12980,-61289,66494,
-        -5,6,-97,111,163,-127,-1498,1634,185,288,-9585,9838,-8540,11455,-62684,65290
-    };
-    float *zlin = lins + 15*64;
-    const float *w = g_win;
-    zlin[4*15]     = xl[18*16];
-    zlin[4*15 + 1] = xr[18*16];
-    zlin[4*15 + 2] = xl[0];
-    zlin[4*15 + 3] = xr[0];
-    zlin[4*31]     = xl[1 + 18*16];
-    zlin[4*31 + 1] = xr[1 + 18*16];
-    zlin[4*31 + 2] = xl[1];
-    zlin[4*31 + 3] = xr[1];
-    drmp3d_synth_pair(dstr, nch, lins + 4*15 + 1);
-    drmp3d_synth_pair(dstr + 32*nch, nch, lins + 4*15 + 64 + 1);
-    drmp3d_synth_pair(dstl, nch, lins + 4*15);
-    drmp3d_synth_pair(dstl + 32*nch, nch, lins + 4*15 + 64);
-#if DRMP3_HAVE_SIMD
-    if (drmp3_have_simd()) for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_VLOAD(k) drmp3_f4 w0 = DRMP3_VSET(*w++); drmp3_f4 w1 = DRMP3_VSET(*w++); drmp3_f4 vz = DRMP3_VLD(&zlin[4*i - 64*k]); drmp3_f4 vy = DRMP3_VLD(&zlin[4*i - 64*(15 - k)]);
-#define DRMP3_V0(k) { DRMP3_VLOAD(k) b =               DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0)) ; a =               DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1));  }
-#define DRMP3_V1(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vz, w0), DRMP3_VMUL(vy, w1))); }
-#define DRMP3_V2(k) { DRMP3_VLOAD(k) b = DRMP3_VADD(b, DRMP3_VADD(DRMP3_VMUL(vz, w1), DRMP3_VMUL(vy, w0))); a = DRMP3_VADD(a, DRMP3_VSUB(DRMP3_VMUL(vy, w1), DRMP3_VMUL(vz, w0))); }
-        drmp3_f4 a, b;
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*i + 64] = xl[1 + 18*(1 + i)];
-        zlin[4*i + 64 + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*i - 64 + 2] = xl[18*(1 + i)];
-        zlin[4*i - 64 + 3] = xr[18*(1 + i)];
-        DRMP3_V0(0) DRMP3_V2(1) DRMP3_V1(2) DRMP3_V2(3) DRMP3_V1(4) DRMP3_V2(5) DRMP3_V1(6) DRMP3_V2(7)
-        {
-#ifndef DR_MP3_FLOAT_OUTPUT
-#if DRMP3_HAVE_SSE
-            static const drmp3_f4 g_max = { 32767.0f, 32767.0f, 32767.0f, 32767.0f };
-            static const drmp3_f4 g_min = { -32768.0f, -32768.0f, -32768.0f, -32768.0f };
-            __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, g_max), g_min)),
-                                           _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, g_max), g_min)));
-            dstr[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-            dstr[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-            dstl[(15 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-            dstl[(17 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-            dstr[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-            dstr[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-            dstl[(47 - i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-            dstl[(49 + i)*nch] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-#else
-            int16x4_t pcma, pcmb;
-            a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-            b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-            pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-            pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-            vst1_lane_s16(dstr + (15 - i)*nch, pcma, 1);
-            vst1_lane_s16(dstr + (17 + i)*nch, pcmb, 1);
-            vst1_lane_s16(dstl + (15 - i)*nch, pcma, 0);
-            vst1_lane_s16(dstl + (17 + i)*nch, pcmb, 0);
-            vst1_lane_s16(dstr + (47 - i)*nch, pcma, 3);
-            vst1_lane_s16(dstr + (49 + i)*nch, pcmb, 3);
-            vst1_lane_s16(dstl + (47 - i)*nch, pcma, 2);
-            vst1_lane_s16(dstl + (49 + i)*nch, pcmb, 2);
-#endif
-#else
-            static const drmp3_f4 g_scale = { 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f, 1.0f/32768.0f };
-            a = DRMP3_VMUL(a, g_scale);
-            b = DRMP3_VMUL(b, g_scale);
-#if DRMP3_HAVE_SSE
-            _mm_store_ss(dstr + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstr + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(1, 1, 1, 1)));
-            _mm_store_ss(dstl + (15 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstl + (17 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(0, 0, 0, 0)));
-            _mm_store_ss(dstr + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstr + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(3, 3, 3, 3)));
-            _mm_store_ss(dstl + (47 - i)*nch, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 2, 2, 2)));
-            _mm_store_ss(dstl + (49 + i)*nch, _mm_shuffle_ps(b, b, _MM_SHUFFLE(2, 2, 2, 2)));
-#else
-            vst1q_lane_f32(dstr + (15 - i)*nch, a, 1);
-            vst1q_lane_f32(dstr + (17 + i)*nch, b, 1);
-            vst1q_lane_f32(dstl + (15 - i)*nch, a, 0);
-            vst1q_lane_f32(dstl + (17 + i)*nch, b, 0);
-            vst1q_lane_f32(dstr + (47 - i)*nch, a, 3);
-            vst1q_lane_f32(dstr + (49 + i)*nch, b, 3);
-            vst1q_lane_f32(dstl + (47 - i)*nch, a, 2);
-            vst1q_lane_f32(dstl + (49 + i)*nch, b, 2);
-#endif
-#endif
-        }
-    } else
-#endif
-#ifdef DR_MP3_ONLY_SIMD
-    {}
-#else
-    for (i = 14; i >= 0; i--)
-    {
-#define DRMP3_LOAD(k) float w0 = *w++; float w1 = *w++; float *vz = &zlin[4*i - k*64]; float *vy = &zlin[4*i - (15 - k)*64];
-#define DRMP3_S0(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j]  = vz[j]*w1 + vy[j]*w0, a[j]  = vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S1(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vz[j]*w0 - vy[j]*w1; }
-#define DRMP3_S2(k) { int j; DRMP3_LOAD(k); for (j = 0; j < 4; j++) b[j] += vz[j]*w1 + vy[j]*w0, a[j] += vy[j]*w1 - vz[j]*w0; }
-        float a[4], b[4];
-        zlin[4*i]     = xl[18*(31 - i)];
-        zlin[4*i + 1] = xr[18*(31 - i)];
-        zlin[4*i + 2] = xl[1 + 18*(31 - i)];
-        zlin[4*i + 3] = xr[1 + 18*(31 - i)];
-        zlin[4*(i + 16)]   = xl[1 + 18*(1 + i)];
-        zlin[4*(i + 16) + 1] = xr[1 + 18*(1 + i)];
-        zlin[4*(i - 16) + 2] = xl[18*(1 + i)];
-        zlin[4*(i - 16) + 3] = xr[18*(1 + i)];
-        DRMP3_S0(0) DRMP3_S2(1) DRMP3_S1(2) DRMP3_S2(3) DRMP3_S1(4) DRMP3_S2(5) DRMP3_S1(6) DRMP3_S2(7)
-        dstr[(15 - i)*nch] = drmp3d_scale_pcm(a[1]);
-        dstr[(17 + i)*nch] = drmp3d_scale_pcm(b[1]);
-        dstl[(15 - i)*nch] = drmp3d_scale_pcm(a[0]);
-        dstl[(17 + i)*nch] = drmp3d_scale_pcm(b[0]);
-        dstr[(47 - i)*nch] = drmp3d_scale_pcm(a[3]);
-        dstr[(49 + i)*nch] = drmp3d_scale_pcm(b[3]);
-        dstl[(47 - i)*nch] = drmp3d_scale_pcm(a[2]);
-        dstl[(49 + i)*nch] = drmp3d_scale_pcm(b[2]);
-    }
-#endif
-}
-static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int nch, drmp3d_sample_t *pcm, float *lins)
-{
-    int i;
-    for (i = 0; i < nch; i++)
-    {
-        drmp3d_DCT_II(grbuf + 576*i, nbands);
-    }
-    memcpy(lins, qmf_state, sizeof(float)*15*64);
-    for (i = 0; i < nbands; i += 2)
-    {
-        drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
-    }
-#ifndef DR_MP3_NONSTANDARD_BUT_LOGICAL
-    if (nch == 1)
-    {
-        for (i = 0; i < 15*64; i += 2)
-        {
-            qmf_state[i] = lins[nbands*64 + i];
-        }
-    } else
-#endif
-    {
-        memcpy(qmf_state, lins + nbands*64, sizeof(float)*15*64);
-    }
-}
-static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
-{
-    int i, nmatch;
-    for (i = 0, nmatch = 0; nmatch < DRMP3_MAX_FRAME_SYNC_MATCHES; nmatch++)
-    {
-        i += drmp3_hdr_frame_bytes(hdr + i, frame_bytes) + drmp3_hdr_padding(hdr + i);
-        if (i + DRMP3_HDR_SIZE > mp3_bytes)
-            return nmatch > 0;
-        if (!drmp3_hdr_compare(hdr, hdr + i))
-            return 0;
-    }
-    return 1;
-}
-static int drmp3d_find_frame(const drmp3_uint8 *mp3, int mp3_bytes, int *free_format_bytes, int *ptr_frame_bytes)
-{
-    int i, k;
-    for (i = 0; i < mp3_bytes - DRMP3_HDR_SIZE; i++, mp3++)
-    {
-        if (drmp3_hdr_valid(mp3))
-        {
-            int frame_bytes = drmp3_hdr_frame_bytes(mp3, *free_format_bytes);
-            int frame_and_padding = frame_bytes + drmp3_hdr_padding(mp3);
-            for (k = DRMP3_HDR_SIZE; !frame_bytes && k < DRMP3_MAX_FREE_FORMAT_FRAME_SIZE && i + 2*k < mp3_bytes - DRMP3_HDR_SIZE; k++)
-            {
-                if (drmp3_hdr_compare(mp3, mp3 + k))
-                {
-                    int fb = k - drmp3_hdr_padding(mp3);
-                    int nextfb = fb + drmp3_hdr_padding(mp3 + k);
-                    if (i + k + nextfb + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + k + nextfb))
-                        continue;
-                    frame_and_padding = k;
-                    frame_bytes = fb;
-                    *free_format_bytes = fb;
-                }
-            }
-            if ((frame_bytes && i + frame_and_padding <= mp3_bytes &&
-                drmp3d_match_frame(mp3, mp3_bytes - i, frame_bytes)) ||
-                (!i && frame_and_padding == mp3_bytes))
-            {
-                *ptr_frame_bytes = frame_and_padding;
-                return i;
-            }
-            *free_format_bytes = 0;
-        }
-    }
-    *ptr_frame_bytes = 0;
-    return mp3_bytes;
-}
-DRMP3_API void drmp3dec_init(drmp3dec *dec)
-{
-    dec->header[0] = 0;
-}
-DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int mp3_bytes, void *pcm, drmp3dec_frame_info *info)
-{
-    int i = 0, igr, frame_size = 0, success = 1;
-    const drmp3_uint8 *hdr;
-    drmp3_bs bs_frame[1];
-    drmp3dec_scratch scratch;
-    if (mp3_bytes > 4 && dec->header[0] == 0xff && drmp3_hdr_compare(dec->header, mp3))
-    {
-        frame_size = drmp3_hdr_frame_bytes(mp3, dec->free_format_bytes) + drmp3_hdr_padding(mp3);
-        if (frame_size != mp3_bytes && (frame_size + DRMP3_HDR_SIZE > mp3_bytes || !drmp3_hdr_compare(mp3, mp3 + frame_size)))
-        {
-            frame_size = 0;
-        }
-    }
-    if (!frame_size)
-    {
-        memset(dec, 0, sizeof(drmp3dec));
-        i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
-        if (!frame_size || i + frame_size > mp3_bytes)
-        {
-            info->frame_bytes = i;
-            return 0;
-        }
-    }
-    hdr = mp3 + i;
-    memcpy(dec->header, hdr, DRMP3_HDR_SIZE);
-    info->frame_bytes = i + frame_size;
-    info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
-    info->hz = drmp3_hdr_sample_rate_hz(hdr);
-    info->layer = 4 - DRMP3_HDR_GET_LAYER(hdr);
-    info->bitrate_kbps = drmp3_hdr_bitrate_kbps(hdr);
-    drmp3_bs_init(bs_frame, hdr + DRMP3_HDR_SIZE, frame_size - DRMP3_HDR_SIZE);
-    if (DRMP3_HDR_IS_CRC(hdr))
-    {
-        drmp3_bs_get_bits(bs_frame, 16);
-    }
-    if (info->layer == 3)
-    {
-        int main_data_begin = drmp3_L3_read_side_info(bs_frame, scratch.gr_info, hdr);
-        if (main_data_begin < 0 || bs_frame->pos > bs_frame->limit)
-        {
-            drmp3dec_init(dec);
-            return 0;
-        }
-        success = drmp3_L3_restore_reservoir(dec, bs_frame, &scratch, main_data_begin);
-        if (success && pcm != NULL)
-        {
-            for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
-            {
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-            }
-        }
-        drmp3_L3_save_reservoir(dec, &scratch);
-    } else
-    {
-#ifdef DR_MP3_ONLY_MP3
-        return 0;
-#else
-        drmp3_L12_scale_info sci[1];
-        if (pcm == NULL) {
-            return drmp3_hdr_frame_samples(hdr);
-        }
-        drmp3_L12_read_scale_info(hdr, bs_frame, sci);
-        memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-        for (i = 0, igr = 0; igr < 3; igr++)
-        {
-            if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
-            {
-                i = 0;
-                drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
-                drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
-                memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
-                pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
-            }
-            if (bs_frame->pos > bs_frame->limit)
-            {
-                drmp3dec_init(dec);
-                return 0;
-            }
-        }
-#endif
-    }
-    return success*drmp3_hdr_frame_samples(dec->header);
-}
-DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num_samples)
-{
-    size_t i = 0;
-#if DRMP3_HAVE_SIMD
-    size_t aligned_count = num_samples & ~7;
-    for(; i < aligned_count; i+=8)
-    {
-        drmp3_f4 scale = DRMP3_VSET(32768.0f);
-        drmp3_f4 a = DRMP3_VMUL(DRMP3_VLD(&in[i  ]), scale);
-        drmp3_f4 b = DRMP3_VMUL(DRMP3_VLD(&in[i+4]), scale);
-#if DRMP3_HAVE_SSE
-        drmp3_f4 s16max = DRMP3_VSET( 32767.0f);
-        drmp3_f4 s16min = DRMP3_VSET(-32768.0f);
-        __m128i pcm8 = _mm_packs_epi32(_mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(a, s16max), s16min)),
-                                        _mm_cvtps_epi32(_mm_max_ps(_mm_min_ps(b, s16max), s16min)));
-        out[i  ] = (drmp3_int16)_mm_extract_epi16(pcm8, 0);
-        out[i+1] = (drmp3_int16)_mm_extract_epi16(pcm8, 1);
-        out[i+2] = (drmp3_int16)_mm_extract_epi16(pcm8, 2);
-        out[i+3] = (drmp3_int16)_mm_extract_epi16(pcm8, 3);
-        out[i+4] = (drmp3_int16)_mm_extract_epi16(pcm8, 4);
-        out[i+5] = (drmp3_int16)_mm_extract_epi16(pcm8, 5);
-        out[i+6] = (drmp3_int16)_mm_extract_epi16(pcm8, 6);
-        out[i+7] = (drmp3_int16)_mm_extract_epi16(pcm8, 7);
-#else
-        int16x4_t pcma, pcmb;
-        a = DRMP3_VADD(a, DRMP3_VSET(0.5f));
-        b = DRMP3_VADD(b, DRMP3_VSET(0.5f));
-        pcma = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(a), vreinterpretq_s32_u32(vcltq_f32(a, DRMP3_VSET(0)))));
-        pcmb = vqmovn_s32(vqaddq_s32(vcvtq_s32_f32(b), vreinterpretq_s32_u32(vcltq_f32(b, DRMP3_VSET(0)))));
-        vst1_lane_s16(out+i  , pcma, 0);
-        vst1_lane_s16(out+i+1, pcma, 1);
-        vst1_lane_s16(out+i+2, pcma, 2);
-        vst1_lane_s16(out+i+3, pcma, 3);
-        vst1_lane_s16(out+i+4, pcmb, 0);
-        vst1_lane_s16(out+i+5, pcmb, 1);
-        vst1_lane_s16(out+i+6, pcmb, 2);
-        vst1_lane_s16(out+i+7, pcmb, 3);
-#endif
-    }
-#endif
-    for(; i < num_samples; i++)
-    {
-        float sample = in[i] * 32768.0f;
-        if (sample >=  32766.5)
-            out[i] = (drmp3_int16) 32767;
-        else if (sample <= -32767.5)
-            out[i] = (drmp3_int16)-32768;
-        else
-        {
-            short s = (drmp3_int16)(sample + .5f);
-            s -= (s < 0);
-            out[i] = s;
-        }
-    }
-}
-#include <math.h>
-#if defined(SIZE_MAX)
-    #define DRMP3_SIZE_MAX  SIZE_MAX
-#else
-    #if defined(_WIN64) || defined(_LP64) || defined(__LP64__)
-        #define DRMP3_SIZE_MAX  ((drmp3_uint64)0xFFFFFFFFFFFFFFFF)
-    #else
-        #define DRMP3_SIZE_MAX  0xFFFFFFFF
-    #endif
-#endif
-#ifndef DRMP3_SEEK_LEADING_MP3_FRAMES
-#define DRMP3_SEEK_LEADING_MP3_FRAMES   2
-#endif
-#define DRMP3_MIN_DATA_CHUNK_SIZE   16384
-#ifndef DRMP3_DATA_CHUNK_SIZE
-#define DRMP3_DATA_CHUNK_SIZE  DRMP3_MIN_DATA_CHUNK_SIZE*4
-#endif
-#ifndef DRMP3_ASSERT
-#include <assert.h>
-#define DRMP3_ASSERT(expression) assert(expression)
-#endif
-#ifndef DRMP3_COPY_MEMORY
-#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
-#endif
-#ifndef DRMP3_ZERO_MEMORY
-#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
-#endif
-#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
-#ifndef DRMP3_MALLOC
-#define DRMP3_MALLOC(sz) malloc((sz))
-#endif
-#ifndef DRMP3_REALLOC
-#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
-#endif
-#ifndef DRMP3_FREE
-#define DRMP3_FREE(p) free((p))
-#endif
-#define DRMP3_COUNTOF(x)        (sizeof(x) / sizeof(x[0]))
-#define DRMP3_CLAMP(x, lo, hi)  (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
-#ifndef DRMP3_PI_D
-#define DRMP3_PI_D    3.14159265358979323846264
-#endif
-#define DRMP3_DEFAULT_RESAMPLER_LPF_ORDER   2
-static DRMP3_INLINE float drmp3_mix_f32(float x, float y, float a)
-{
-    return x*(1-a) + y*a;
-}
-static DRMP3_INLINE float drmp3_mix_f32_fast(float x, float y, float a)
-{
-    float r0 = (y - x);
-    float r1 = r0*a;
-    return x + r1;
-}
-static DRMP3_INLINE drmp3_uint32 drmp3_gcf_u32(drmp3_uint32 a, drmp3_uint32 b)
-{
-    for (;;) {
-        if (b == 0) {
-            break;
-        } else {
-            drmp3_uint32 t = a;
-            a = b;
-            b = t % a;
-        }
-    }
-    return a;
-}
-static DRMP3_INLINE double drmp3_sin(double x)
-{
-    return sin(x);
-}
-static DRMP3_INLINE double drmp3_exp(double x)
-{
-    return exp(x);
-}
-static DRMP3_INLINE double drmp3_cos(double x)
-{
-    return drmp3_sin((DRMP3_PI_D*0.5) - x);
-}
-static void* drmp3__malloc_default(size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_MALLOC(sz);
-}
-static void* drmp3__realloc_default(void* p, size_t sz, void* pUserData)
-{
-    (void)pUserData;
-    return DRMP3_REALLOC(p, sz);
-}
-static void drmp3__free_default(void* p, void* pUserData)
-{
-    (void)pUserData;
-    DRMP3_FREE(p);
-}
-static void* drmp3__malloc_from_callbacks(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onMalloc != NULL) {
-        return pAllocationCallbacks->onMalloc(sz, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(NULL, sz, pAllocationCallbacks->pUserData);
-    }
-    return NULL;
-}
-static void* drmp3__realloc_from_callbacks(void* p, size_t szNew, size_t szOld, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks == NULL) {
-        return NULL;
-    }
-    if (pAllocationCallbacks->onRealloc != NULL) {
-        return pAllocationCallbacks->onRealloc(p, szNew, pAllocationCallbacks->pUserData);
-    }
-    if (pAllocationCallbacks->onMalloc != NULL && pAllocationCallbacks->onFree != NULL) {
-        void* p2;
-        p2 = pAllocationCallbacks->onMalloc(szNew, pAllocationCallbacks->pUserData);
-        if (p2 == NULL) {
-            return NULL;
-        }
-        if (p != NULL) {
-            DRMP3_COPY_MEMORY(p2, p, szOld);
-            pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-        }
-        return p2;
-    }
-    return NULL;
-}
-static void drmp3__free_from_callbacks(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (p == NULL || pAllocationCallbacks == NULL) {
-        return;
-    }
-    if (pAllocationCallbacks->onFree != NULL) {
-        pAllocationCallbacks->onFree(p, pAllocationCallbacks->pUserData);
-    }
-}
-static drmp3_allocation_callbacks drmp3_copy_allocation_callbacks_or_defaults(const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return *pAllocationCallbacks;
-    } else {
-        drmp3_allocation_callbacks allocationCallbacks;
-        allocationCallbacks.pUserData = NULL;
-        allocationCallbacks.onMalloc  = drmp3__malloc_default;
-        allocationCallbacks.onRealloc = drmp3__realloc_default;
-        allocationCallbacks.onFree    = drmp3__free_default;
-        return allocationCallbacks;
-    }
-}
-static size_t drmp3__on_read(drmp3* pMP3, void* pBufferOut, size_t bytesToRead)
-{
-    size_t bytesRead = pMP3->onRead(pMP3->pUserData, pBufferOut, bytesToRead);
-    pMP3->streamCursor += bytesRead;
-    return bytesRead;
-}
-static drmp3_bool32 drmp3__on_seek(drmp3* pMP3, int offset, drmp3_seek_origin origin)
-{
-    DRMP3_ASSERT(offset >= 0);
-    if (!pMP3->onSeek(pMP3->pUserData, offset, origin)) {
-        return DRMP3_FALSE;
-    }
-    if (origin == drmp3_seek_origin_start) {
-        pMP3->streamCursor = (drmp3_uint64)offset;
-    } else {
-        pMP3->streamCursor += offset;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3__on_seek_64(drmp3* pMP3, drmp3_uint64 offset, drmp3_seek_origin origin)
-{
-    if (offset <= 0x7FFFFFFF) {
-        return drmp3__on_seek(pMP3, (int)offset, origin);
-    }
-    if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    offset -= 0x7FFFFFFF;
-    while (offset > 0) {
-        if (offset <= 0x7FFFFFFF) {
-            if (!drmp3__on_seek(pMP3, (int)offset, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset = 0;
-        } else {
-            if (!drmp3__on_seek(pMP3, 0x7FFFFFFF, drmp3_seek_origin_current)) {
-                return DRMP3_FALSE;
-            }
-            offset -= 0x7FFFFFFF;
-        }
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-    if (pMP3->atEnd) {
-        return 0;
-    }
-    for (;;) {
-        drmp3dec_frame_info info;
-        if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
-            size_t bytesRead;
-            if (pMP3->pData != NULL) {
-                memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            }
-            pMP3->dataConsumed = 0;
-            if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-                newDataCap = DRMP3_DATA_CHUNK_SIZE;
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0;
-                }
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                if (pMP3->dataSize == 0) {
-                    pMP3->atEnd = DRMP3_TRUE;
-                    return 0;
-                }
-            }
-            pMP3->dataSize += bytesRead;
-        }
-        if (pMP3->dataSize > INT_MAX) {
-            pMP3->atEnd = DRMP3_TRUE;
-            return 0;
-        }
-        DRMP3_ASSERT(pMP3->pData != NULL);
-        DRMP3_ASSERT(pMP3->dataCapacity > 0);
-        pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);
-        if (info.frame_bytes > 0) {
-            pMP3->dataConsumed += (size_t)info.frame_bytes;
-            pMP3->dataSize     -= (size_t)info.frame_bytes;
-        }
-        if (pcmFramesRead > 0) {
-            pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
-            pMP3->pcmFramesConsumedInMP3Frame = 0;
-            pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-            pMP3->mp3FrameChannels = info.channels;
-            pMP3->mp3FrameSampleRate = info.hz;
-            break;
-        } else if (info.frame_bytes == 0) {
-            size_t bytesRead;
-            memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
-            pMP3->dataConsumed = 0;
-            if (pMP3->dataCapacity == pMP3->dataSize) {
-                drmp3_uint8* pNewData;
-                size_t newDataCap;
-                newDataCap = pMP3->dataCapacity + DRMP3_DATA_CHUNK_SIZE;
-                pNewData = (drmp3_uint8*)drmp3__realloc_from_callbacks(pMP3->pData, newDataCap, pMP3->dataCapacity, &pMP3->allocationCallbacks);
-                if (pNewData == NULL) {
-                    return 0;
-                }
-                pMP3->pData = pNewData;
-                pMP3->dataCapacity = newDataCap;
-            }
-            bytesRead = drmp3__on_read(pMP3, pMP3->pData + pMP3->dataSize, (pMP3->dataCapacity - pMP3->dataSize));
-            if (bytesRead == 0) {
-                pMP3->atEnd = DRMP3_TRUE;
-                return 0;
-            }
-            pMP3->dataSize += bytesRead;
-        }
-    };
-    return pcmFramesRead;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    drmp3_uint32 pcmFramesRead = 0;
-    drmp3dec_frame_info info;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.pData != NULL);
-    if (pMP3->atEnd) {
-        return 0;
-    }
-    pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
-    if (pcmFramesRead > 0) {
-        pMP3->pcmFramesConsumedInMP3Frame  = 0;
-        pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
-        pMP3->mp3FrameChannels             = info.channels;
-        pMP3->mp3FrameSampleRate           = info.hz;
-    }
-    pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
-    return pcmFramesRead;
-}
-static drmp3_uint32 drmp3_decode_next_frame_ex(drmp3* pMP3, drmp3d_sample_t* pPCMFrames)
-{
-    if (pMP3->memory.pData != NULL && pMP3->memory.dataSize > 0) {
-        return drmp3_decode_next_frame_ex__memory(pMP3, pPCMFrames);
-    } else {
-        return drmp3_decode_next_frame_ex__callbacks(pMP3, pPCMFrames);
-    }
-}
-static drmp3_uint32 drmp3_decode_next_frame(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    return drmp3_decode_next_frame_ex(pMP3, (drmp3d_sample_t*)pMP3->pcmFrames);
-}
-#if 0
-static drmp3_uint32 drmp3_seek_next_frame(drmp3* pMP3)
-{
-    drmp3_uint32 pcmFrameCount;
-    DRMP3_ASSERT(pMP3 != NULL);
-    pcmFrameCount = drmp3_decode_next_frame_ex(pMP3, NULL);
-    if (pcmFrameCount == 0) {
-        return 0;
-    }
-    pMP3->currentPCMFrame             += pcmFrameCount;
-    pMP3->pcmFramesConsumedInMP3Frame  = pcmFrameCount;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    return pcmFrameCount;
-}
-#endif
-static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(onRead != NULL);
-    drmp3dec_init(&pMP3->decoder);
-    pMP3->onRead = onRead;
-    pMP3->onSeek = onSeek;
-    pMP3->pUserData = pUserData;
-    pMP3->allocationCallbacks = drmp3_copy_allocation_callbacks_or_defaults(pAllocationCallbacks);
-    if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
-        return DRMP3_FALSE;
-    }
-    if (!drmp3_decode_next_frame(pMP3)) {
-        drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-        return DRMP3_FALSE;
-    }
-    pMP3->channels   = pMP3->mp3FrameChannels;
-    pMP3->sampleRate = pMP3->mp3FrameSampleRate;
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init(drmp3* pMP3, drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL || onRead == NULL) {
-        return DRMP3_FALSE;
-    }
-    DRMP3_ZERO_OBJECT(pMP3);
-    return drmp3_init_internal(pMP3, onRead, onSeek, pUserData, pAllocationCallbacks);
-}
-static size_t drmp3__on_read_memory(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    size_t bytesRemaining;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->memory.dataSize >= pMP3->memory.currentReadPos);
-    bytesRemaining = pMP3->memory.dataSize - pMP3->memory.currentReadPos;
-    if (bytesToRead > bytesRemaining) {
-        bytesToRead = bytesRemaining;
-    }
-    if (bytesToRead > 0) {
-        DRMP3_COPY_MEMORY(pBufferOut, pMP3->memory.pData + pMP3->memory.currentReadPos, bytesToRead);
-        pMP3->memory.currentReadPos += bytesToRead;
-    }
-    return bytesToRead;
-}
-static drmp3_bool32 drmp3__on_seek_memory(void* pUserData, int byteOffset, drmp3_seek_origin origin)
-{
-    drmp3* pMP3 = (drmp3*)pUserData;
-    DRMP3_ASSERT(pMP3 != NULL);
-    if (origin == drmp3_seek_origin_current) {
-        if (byteOffset > 0) {
-            if (pMP3->memory.currentReadPos + byteOffset > pMP3->memory.dataSize) {
-                byteOffset = (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos);
-            }
-        } else {
-            if (pMP3->memory.currentReadPos < (size_t)-byteOffset) {
-                byteOffset = -(int)pMP3->memory.currentReadPos;
-            }
-        }
-        pMP3->memory.currentReadPos += byteOffset;
-    } else {
-        if ((drmp3_uint32)byteOffset <= pMP3->memory.dataSize) {
-            pMP3->memory.currentReadPos = byteOffset;
-        } else {
-            pMP3->memory.currentReadPos = pMP3->memory.dataSize;
-        }
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init_memory(drmp3* pMP3, const void* pData, size_t dataSize, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    DRMP3_ZERO_OBJECT(pMP3);
-    if (pData == NULL || dataSize == 0) {
-        return DRMP3_FALSE;
-    }
-    pMP3->memory.pData = (const drmp3_uint8*)pData;
-    pMP3->memory.dataSize = dataSize;
-    pMP3->memory.currentReadPos = 0;
-    return drmp3_init_internal(pMP3, drmp3__on_read_memory, drmp3__on_seek_memory, pMP3, pAllocationCallbacks);
-}
-#ifndef DR_MP3_NO_STDIO
-#include <stdio.h>
-#include <wchar.h>
-#include <errno.h>
-static drmp3_result drmp3_result_from_errno(int e)
-{
-    switch (e)
-    {
-        case 0: return DRMP3_SUCCESS;
-    #ifdef EPERM
-        case EPERM: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ENOENT
-        case ENOENT: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ESRCH
-        case ESRCH: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EINTR
-        case EINTR: return DRMP3_INTERRUPT;
-    #endif
-    #ifdef EIO
-        case EIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef ENXIO
-        case ENXIO: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef E2BIG
-        case E2BIG: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENOEXEC
-        case ENOEXEC: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EBADF
-        case EBADF: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ECHILD
-        case ECHILD: return DRMP3_ERROR;
-    #endif
-    #ifdef EAGAIN
-        case EAGAIN: return DRMP3_UNAVAILABLE;
-    #endif
-    #ifdef ENOMEM
-        case ENOMEM: return DRMP3_OUT_OF_MEMORY;
-    #endif
-    #ifdef EACCES
-        case EACCES: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EFAULT
-        case EFAULT: return DRMP3_BAD_ADDRESS;
-    #endif
-    #ifdef ENOTBLK
-        case ENOTBLK: return DRMP3_ERROR;
-    #endif
-    #ifdef EBUSY
-        case EBUSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EEXIST
-        case EEXIST: return DRMP3_ALREADY_EXISTS;
-    #endif
-    #ifdef EXDEV
-        case EXDEV: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODEV
-        case ENODEV: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef ENOTDIR
-        case ENOTDIR: return DRMP3_NOT_DIRECTORY;
-    #endif
-    #ifdef EISDIR
-        case EISDIR: return DRMP3_IS_DIRECTORY;
-    #endif
-    #ifdef EINVAL
-        case EINVAL: return DRMP3_INVALID_ARGS;
-    #endif
-    #ifdef ENFILE
-        case ENFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef EMFILE
-        case EMFILE: return DRMP3_TOO_MANY_OPEN_FILES;
-    #endif
-    #ifdef ENOTTY
-        case ENOTTY: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef ETXTBSY
-        case ETXTBSY: return DRMP3_BUSY;
-    #endif
-    #ifdef EFBIG
-        case EFBIG: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOSPC
-        case ENOSPC: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ESPIPE
-        case ESPIPE: return DRMP3_BAD_SEEK;
-    #endif
-    #ifdef EROFS
-        case EROFS: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef EMLINK
-        case EMLINK: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef EPIPE
-        case EPIPE: return DRMP3_BAD_PIPE;
-    #endif
-    #ifdef EDOM
-        case EDOM: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef ERANGE
-        case ERANGE: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EDEADLK
-        case EDEADLK: return DRMP3_DEADLOCK;
-    #endif
-    #ifdef ENAMETOOLONG
-        case ENAMETOOLONG: return DRMP3_PATH_TOO_LONG;
-    #endif
-    #ifdef ENOLCK
-        case ENOLCK: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOSYS
-        case ENOSYS: return DRMP3_NOT_IMPLEMENTED;
-    #endif
-    #ifdef ENOTEMPTY
-        case ENOTEMPTY: return DRMP3_DIRECTORY_NOT_EMPTY;
-    #endif
-    #ifdef ELOOP
-        case ELOOP: return DRMP3_TOO_MANY_LINKS;
-    #endif
-    #ifdef ENOMSG
-        case ENOMSG: return DRMP3_NO_MESSAGE;
-    #endif
-    #ifdef EIDRM
-        case EIDRM: return DRMP3_ERROR;
-    #endif
-    #ifdef ECHRNG
-        case ECHRNG: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2NSYNC
-        case EL2NSYNC: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3HLT
-        case EL3HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EL3RST
-        case EL3RST: return DRMP3_ERROR;
-    #endif
-    #ifdef ELNRNG
-        case ELNRNG: return DRMP3_OUT_OF_RANGE;
-    #endif
-    #ifdef EUNATCH
-        case EUNATCH: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOCSI
-        case ENOCSI: return DRMP3_ERROR;
-    #endif
-    #ifdef EL2HLT
-        case EL2HLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADE
-        case EBADE: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADR
-        case EBADR: return DRMP3_ERROR;
-    #endif
-    #ifdef EXFULL
-        case EXFULL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOANO
-        case ENOANO: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADRQC
-        case EBADRQC: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADSLT
-        case EBADSLT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBFONT
-        case EBFONT: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ENOSTR
-        case ENOSTR: return DRMP3_ERROR;
-    #endif
-    #ifdef ENODATA
-        case ENODATA: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ETIME
-        case ETIME: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ENOSR
-        case ENOSR: return DRMP3_NO_DATA_AVAILABLE;
-    #endif
-    #ifdef ENONET
-        case ENONET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENOPKG
-        case ENOPKG: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTE
-        case EREMOTE: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOLINK
-        case ENOLINK: return DRMP3_ERROR;
-    #endif
-    #ifdef EADV
-        case EADV: return DRMP3_ERROR;
-    #endif
-    #ifdef ESRMNT
-        case ESRMNT: return DRMP3_ERROR;
-    #endif
-    #ifdef ECOMM
-        case ECOMM: return DRMP3_ERROR;
-    #endif
-    #ifdef EPROTO
-        case EPROTO: return DRMP3_ERROR;
-    #endif
-    #ifdef EMULTIHOP
-        case EMULTIHOP: return DRMP3_ERROR;
-    #endif
-    #ifdef EDOTDOT
-        case EDOTDOT: return DRMP3_ERROR;
-    #endif
-    #ifdef EBADMSG
-        case EBADMSG: return DRMP3_BAD_MESSAGE;
-    #endif
-    #ifdef EOVERFLOW
-        case EOVERFLOW: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef ENOTUNIQ
-        case ENOTUNIQ: return DRMP3_NOT_UNIQUE;
-    #endif
-    #ifdef EBADFD
-        case EBADFD: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMCHG
-        case EREMCHG: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBACC
-        case ELIBACC: return DRMP3_ACCESS_DENIED;
-    #endif
-    #ifdef ELIBBAD
-        case ELIBBAD: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBSCN
-        case ELIBSCN: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef ELIBMAX
-        case ELIBMAX: return DRMP3_ERROR;
-    #endif
-    #ifdef ELIBEXEC
-        case ELIBEXEC: return DRMP3_ERROR;
-    #endif
-    #ifdef EILSEQ
-        case EILSEQ: return DRMP3_INVALID_DATA;
-    #endif
-    #ifdef ERESTART
-        case ERESTART: return DRMP3_ERROR;
-    #endif
-    #ifdef ESTRPIPE
-        case ESTRPIPE: return DRMP3_ERROR;
-    #endif
-    #ifdef EUSERS
-        case EUSERS: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTSOCK
-        case ENOTSOCK: return DRMP3_NOT_SOCKET;
-    #endif
-    #ifdef EDESTADDRREQ
-        case EDESTADDRREQ: return DRMP3_NO_ADDRESS;
-    #endif
-    #ifdef EMSGSIZE
-        case EMSGSIZE: return DRMP3_TOO_BIG;
-    #endif
-    #ifdef EPROTOTYPE
-        case EPROTOTYPE: return DRMP3_BAD_PROTOCOL;
-    #endif
-    #ifdef ENOPROTOOPT
-        case ENOPROTOOPT: return DRMP3_PROTOCOL_UNAVAILABLE;
-    #endif
-    #ifdef EPROTONOSUPPORT
-        case EPROTONOSUPPORT: return DRMP3_PROTOCOL_NOT_SUPPORTED;
-    #endif
-    #ifdef ESOCKTNOSUPPORT
-        case ESOCKTNOSUPPORT: return DRMP3_SOCKET_NOT_SUPPORTED;
-    #endif
-    #ifdef EOPNOTSUPP
-        case EOPNOTSUPP: return DRMP3_INVALID_OPERATION;
-    #endif
-    #ifdef EPFNOSUPPORT
-        case EPFNOSUPPORT: return DRMP3_PROTOCOL_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EAFNOSUPPORT
-        case EAFNOSUPPORT: return DRMP3_ADDRESS_FAMILY_NOT_SUPPORTED;
-    #endif
-    #ifdef EADDRINUSE
-        case EADDRINUSE: return DRMP3_ALREADY_IN_USE;
-    #endif
-    #ifdef EADDRNOTAVAIL
-        case EADDRNOTAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef ENETDOWN
-        case ENETDOWN: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETUNREACH
-        case ENETUNREACH: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ENETRESET
-        case ENETRESET: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNABORTED
-        case ECONNABORTED: return DRMP3_NO_NETWORK;
-    #endif
-    #ifdef ECONNRESET
-        case ECONNRESET: return DRMP3_CONNECTION_RESET;
-    #endif
-    #ifdef ENOBUFS
-        case ENOBUFS: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef EISCONN
-        case EISCONN: return DRMP3_ALREADY_CONNECTED;
-    #endif
-    #ifdef ENOTCONN
-        case ENOTCONN: return DRMP3_NOT_CONNECTED;
-    #endif
-    #ifdef ESHUTDOWN
-        case ESHUTDOWN: return DRMP3_ERROR;
-    #endif
-    #ifdef ETOOMANYREFS
-        case ETOOMANYREFS: return DRMP3_ERROR;
-    #endif
-    #ifdef ETIMEDOUT
-        case ETIMEDOUT: return DRMP3_TIMEOUT;
-    #endif
-    #ifdef ECONNREFUSED
-        case ECONNREFUSED: return DRMP3_CONNECTION_REFUSED;
-    #endif
-    #ifdef EHOSTDOWN
-        case EHOSTDOWN: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EHOSTUNREACH
-        case EHOSTUNREACH: return DRMP3_NO_HOST;
-    #endif
-    #ifdef EALREADY
-        case EALREADY: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef EINPROGRESS
-        case EINPROGRESS: return DRMP3_IN_PROGRESS;
-    #endif
-    #ifdef ESTALE
-        case ESTALE: return DRMP3_INVALID_FILE;
-    #endif
-    #ifdef EUCLEAN
-        case EUCLEAN: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTNAM
-        case ENOTNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef ENAVAIL
-        case ENAVAIL: return DRMP3_ERROR;
-    #endif
-    #ifdef EISNAM
-        case EISNAM: return DRMP3_ERROR;
-    #endif
-    #ifdef EREMOTEIO
-        case EREMOTEIO: return DRMP3_IO_ERROR;
-    #endif
-    #ifdef EDQUOT
-        case EDQUOT: return DRMP3_NO_SPACE;
-    #endif
-    #ifdef ENOMEDIUM
-        case ENOMEDIUM: return DRMP3_DOES_NOT_EXIST;
-    #endif
-    #ifdef EMEDIUMTYPE
-        case EMEDIUMTYPE: return DRMP3_ERROR;
-    #endif
-    #ifdef ECANCELED
-        case ECANCELED: return DRMP3_CANCELLED;
-    #endif
-    #ifdef ENOKEY
-        case ENOKEY: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYEXPIRED
-        case EKEYEXPIRED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREVOKED
-        case EKEYREVOKED: return DRMP3_ERROR;
-    #endif
-    #ifdef EKEYREJECTED
-        case EKEYREJECTED: return DRMP3_ERROR;
-    #endif
-    #ifdef EOWNERDEAD
-        case EOWNERDEAD: return DRMP3_ERROR;
-    #endif
-    #ifdef ENOTRECOVERABLE
-        case ENOTRECOVERABLE: return DRMP3_ERROR;
-    #endif
-    #ifdef ERFKILL
-        case ERFKILL: return DRMP3_ERROR;
-    #endif
-    #ifdef EHWPOISON
-        case EHWPOISON: return DRMP3_ERROR;
-    #endif
-        default: return DRMP3_ERROR;
-    }
-}
-static drmp3_result drmp3_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
-{
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    errno_t err;
-#endif
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-    err = fopen_s(ppFile, pFilePath, pOpenMode);
-    if (err != 0) {
-        return drmp3_result_from_errno(err);
-    }
-#else
-#if defined(_WIN32) || defined(__APPLE__)
-    *ppFile = fopen(pFilePath, pOpenMode);
-#else
-    #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(_LARGEFILE64_SOURCE)
-        *ppFile = fopen64(pFilePath, pOpenMode);
-    #else
-        *ppFile = fopen(pFilePath, pOpenMode);
-    #endif
-#endif
-    if (*ppFile == NULL) {
-        drmp3_result result = drmp3_result_from_errno(errno);
-        if (result == DRMP3_SUCCESS) {
-            result = DRMP3_ERROR;
-        }
-        return result;
-    }
-#endif
-    return DRMP3_SUCCESS;
-}
-#if defined(_WIN32)
-    #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
-        #define DRMP3_HAS_WFOPEN
-    #endif
-#endif
-static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_t* pOpenMode, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (ppFile != NULL) {
-        *ppFile = NULL;
-    }
-    if (pFilePath == NULL || pOpenMode == NULL || ppFile == NULL) {
-        return DRMP3_INVALID_ARGS;
-    }
-#if defined(DRMP3_HAS_WFOPEN)
-    {
-    #if defined(_MSC_VER) && _MSC_VER >= 1400
-        errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
-        if (err != 0) {
-            return drmp3_result_from_errno(err);
-        }
-    #else
-        *ppFile = _wfopen(pFilePath, pOpenMode);
-        if (*ppFile == NULL) {
-            return drmp3_result_from_errno(errno);
-        }
-    #endif
-        (void)pAllocationCallbacks;
-    }
-#else
-    {
-        mbstate_t mbs;
-        size_t lenMB;
-        const wchar_t* pFilePathTemp = pFilePath;
-        char* pFilePathMB = NULL;
-        char pOpenModeMB[32] = {0};
-        DRMP3_ZERO_OBJECT(&mbs);
-        lenMB = wcsrtombs(NULL, &pFilePathTemp, 0, &mbs);
-        if (lenMB == (size_t)-1) {
-            return drmp3_result_from_errno(errno);
-        }
-        pFilePathMB = (char*)drmp3__malloc_from_callbacks(lenMB + 1, pAllocationCallbacks);
-        if (pFilePathMB == NULL) {
-            return DRMP3_OUT_OF_MEMORY;
-        }
-        pFilePathTemp = pFilePath;
-        DRMP3_ZERO_OBJECT(&mbs);
-        wcsrtombs(pFilePathMB, &pFilePathTemp, lenMB + 1, &mbs);
-        {
-            size_t i = 0;
-            for (;;) {
-                if (pOpenMode[i] == 0) {
-                    pOpenModeMB[i] = '\0';
-                    break;
-                }
-                pOpenModeMB[i] = (char)pOpenMode[i];
-                i += 1;
-            }
-        }
-        *ppFile = fopen(pFilePathMB, pOpenModeMB);
-        drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks);
-    }
-    if (*ppFile == NULL) {
-        return DRMP3_ERROR;
-    }
-#endif
-    return DRMP3_SUCCESS;
-}
-static size_t drmp3__on_read_stdio(void* pUserData, void* pBufferOut, size_t bytesToRead)
-{
-    return fread(pBufferOut, 1, bytesToRead, (FILE*)pUserData);
-}
-static drmp3_bool32 drmp3__on_seek_stdio(void* pUserData, int offset, drmp3_seek_origin origin)
-{
-    return fseek((FILE*)pUserData, offset, (origin == drmp3_seek_origin_current) ? SEEK_CUR : SEEK_SET) == 0;
-}
-DRMP3_API drmp3_bool32 drmp3_init_file(drmp3* pMP3, const char* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-    if (drmp3_fopen(&pFile, pFilePath, "rb") != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_init_file_w(drmp3* pMP3, const wchar_t* pFilePath, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3_bool32 result;
-    FILE* pFile;
-    if (drmp3_wfopen(&pFile, pFilePath, L"rb", pAllocationCallbacks) != DRMP3_SUCCESS) {
-        return DRMP3_FALSE;
-    }
-    result = drmp3_init(pMP3, drmp3__on_read_stdio, drmp3__on_seek_stdio, (void*)pFile, pAllocationCallbacks);
-    if (result != DRMP3_TRUE) {
-        fclose(pFile);
-        return result;
-    }
-    return DRMP3_TRUE;
-}
-#endif
-DRMP3_API void drmp3_uninit(drmp3* pMP3)
-{
-    if (pMP3 == NULL) {
-        return;
-    }
-#ifndef DR_MP3_NO_STDIO
-    if (pMP3->onRead == drmp3__on_read_stdio) {
-        FILE* pFile = (FILE*)pMP3->pUserData;
-        if (pFile != NULL) {
-            fclose(pFile);
-            pMP3->pUserData = NULL;
-        }
-    }
-#endif
-    drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
-}
-#if defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_f32_to_s16(drmp3_int16* dst, const float* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    drmp3_uint64 i4;
-    drmp3_uint64 sampleCount4;
-    i = 0;
-    sampleCount4 = sampleCount >> 2;
-    for (i4 = 0; i4 < sampleCount4; i4 += 1) {
-        float x0 = src[i+0];
-        float x1 = src[i+1];
-        float x2 = src[i+2];
-        float x3 = src[i+3];
-        x0 = ((x0 < -1) ? -1 : ((x0 > 1) ? 1 : x0));
-        x1 = ((x1 < -1) ? -1 : ((x1 > 1) ? 1 : x1));
-        x2 = ((x2 < -1) ? -1 : ((x2 > 1) ? 1 : x2));
-        x3 = ((x3 < -1) ? -1 : ((x3 > 1) ? 1 : x3));
-        x0 = x0 * 32767.0f;
-        x1 = x1 * 32767.0f;
-        x2 = x2 * 32767.0f;
-        x3 = x3 * 32767.0f;
-        dst[i+0] = (drmp3_int16)x0;
-        dst[i+1] = (drmp3_int16)x1;
-        dst[i+2] = (drmp3_int16)x2;
-        dst[i+3] = (drmp3_int16)x3;
-        i += 4;
-    }
-    for (; i < sampleCount; i += 1) {
-        float x = src[i];
-        x = ((x < -1) ? -1 : ((x > 1) ? 1 : x));
-        x = x * 32767.0f;
-        dst[i] = (drmp3_int16)x;
-    }
-}
-#endif
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-static void drmp3_s16_to_f32(float* dst, const drmp3_int16* src, drmp3_uint64 sampleCount)
-{
-    drmp3_uint64 i;
-    for (i = 0; i < sampleCount; i += 1) {
-        float x = (float)src[i];
-        x = x * 0.000030517578125f;
-        dst[i] = x;
-    }
-}
-#endif
-static drmp3_uint64 drmp3_read_pcm_frames_raw(drmp3* pMP3, drmp3_uint64 framesToRead, void* pBufferOut)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onRead != NULL);
-    while (framesToRead > 0) {
-        drmp3_uint32 framesToConsume = (drmp3_uint32)DRMP3_MIN(pMP3->pcmFramesRemainingInMP3Frame, framesToRead);
-        if (pBufferOut != NULL) {
-        #if defined(DR_MP3_FLOAT_OUTPUT)
-            float* pFramesOutF32 = (float*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(float) * totalFramesRead                   * pMP3->channels);
-            float* pFramesInF32  = (float*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(float) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutF32, pFramesInF32, sizeof(float) * framesToConsume * pMP3->channels);
-        #else
-            drmp3_int16* pFramesOutS16 = (drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut,          sizeof(drmp3_int16) * totalFramesRead                   * pMP3->channels);
-            drmp3_int16* pFramesInS16  = (drmp3_int16*)DRMP3_OFFSET_PTR(&pMP3->pcmFrames[0], sizeof(drmp3_int16) * pMP3->pcmFramesConsumedInMP3Frame * pMP3->mp3FrameChannels);
-            DRMP3_COPY_MEMORY(pFramesOutS16, pFramesInS16, sizeof(drmp3_int16) * framesToConsume * pMP3->channels);
-        #endif
-        }
-        pMP3->currentPCMFrame              += framesToConsume;
-        pMP3->pcmFramesConsumedInMP3Frame  += framesToConsume;
-        pMP3->pcmFramesRemainingInMP3Frame -= framesToConsume;
-        totalFramesRead                    += framesToConsume;
-        framesToRead                       -= framesToConsume;
-        if (framesToRead == 0) {
-            break;
-        }
-        DRMP3_ASSERT(pMP3->pcmFramesRemainingInMP3Frame == 0);
-        if (drmp3_decode_next_frame(pMP3) == 0) {
-            break;
-        }
-    }
-    return totalFramesRead;
-}
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 framesToRead, float* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    {
-        drmp3_int16 pTempS16[8192];
-        drmp3_uint64 totalPCMFramesRead = 0;
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempS16) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempS16);
-            if (framesJustRead == 0) {
-                break;
-            }
-            drmp3_s16_to_f32((float*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(float) * totalPCMFramesRead * pMP3->channels), pTempS16, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-        return totalPCMFramesRead;
-    }
-#endif
-}
-DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 framesToRead, drmp3_int16* pBufferOut)
-{
-    if (pMP3 == NULL || pMP3->onRead == NULL) {
-        return 0;
-    }
-#if !defined(DR_MP3_FLOAT_OUTPUT)
-    return drmp3_read_pcm_frames_raw(pMP3, framesToRead, pBufferOut);
-#else
-    {
-        float pTempF32[4096];
-        drmp3_uint64 totalPCMFramesRead = 0;
-        while (totalPCMFramesRead < framesToRead) {
-            drmp3_uint64 framesJustRead;
-            drmp3_uint64 framesRemaining = framesToRead - totalPCMFramesRead;
-            drmp3_uint64 framesToReadNow = DRMP3_COUNTOF(pTempF32) / pMP3->channels;
-            if (framesToReadNow > framesRemaining) {
-                framesToReadNow = framesRemaining;
-            }
-            framesJustRead = drmp3_read_pcm_frames_raw(pMP3, framesToReadNow, pTempF32);
-            if (framesJustRead == 0) {
-                break;
-            }
-            drmp3_f32_to_s16((drmp3_int16*)DRMP3_OFFSET_PTR(pBufferOut, sizeof(drmp3_int16) * totalPCMFramesRead * pMP3->channels), pTempF32, framesJustRead * pMP3->channels);
-            totalPCMFramesRead += framesJustRead;
-        }
-        return totalPCMFramesRead;
-    }
-#endif
-}
-static void drmp3_reset(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    pMP3->pcmFramesConsumedInMP3Frame = 0;
-    pMP3->pcmFramesRemainingInMP3Frame = 0;
-    pMP3->currentPCMFrame = 0;
-    pMP3->dataSize = 0;
-    pMP3->atEnd = DRMP3_FALSE;
-    drmp3dec_init(&pMP3->decoder);
-}
-static drmp3_bool32 drmp3_seek_to_start_of_stream(drmp3* pMP3)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->onSeek != NULL);
-    if (!drmp3__on_seek(pMP3, 0, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    drmp3_reset(pMP3);
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_forward_by_pcm_frames__brute_force(drmp3* pMP3, drmp3_uint64 frameOffset)
-{
-    drmp3_uint64 framesRead;
-#if defined(DR_MP3_FLOAT_OUTPUT)
-    framesRead = drmp3_read_pcm_frames_f32(pMP3, frameOffset, NULL);
-#else
-    framesRead = drmp3_read_pcm_frames_s16(pMP3, frameOffset, NULL);
-#endif
-    if (framesRead != frameOffset) {
-        return DRMP3_FALSE;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_to_pcm_frame__brute_force(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    DRMP3_ASSERT(pMP3 != NULL);
-    if (frameIndex == pMP3->currentPCMFrame) {
-        return DRMP3_TRUE;
-    }
-    if (frameIndex < pMP3->currentPCMFrame) {
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-    }
-    DRMP3_ASSERT(frameIndex >= pMP3->currentPCMFrame);
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, (frameIndex - pMP3->currentPCMFrame));
-}
-static drmp3_bool32 drmp3_find_closest_seek_point(drmp3* pMP3, drmp3_uint64 frameIndex, drmp3_uint32* pSeekPointIndex)
-{
-    drmp3_uint32 iSeekPoint;
-    DRMP3_ASSERT(pSeekPointIndex != NULL);
-    *pSeekPointIndex = 0;
-    if (frameIndex < pMP3->pSeekPoints[0].pcmFrameIndex) {
-        return DRMP3_FALSE;
-    }
-    for (iSeekPoint = 0; iSeekPoint < pMP3->seekPointCount; ++iSeekPoint) {
-        if (pMP3->pSeekPoints[iSeekPoint].pcmFrameIndex > frameIndex) {
-            break;
-        }
-        *pSeekPointIndex = iSeekPoint;
-    }
-    return DRMP3_TRUE;
-}
-static drmp3_bool32 drmp3_seek_to_pcm_frame__seek_table(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    drmp3_seek_point seekPoint;
-    drmp3_uint32 priorSeekPointIndex;
-    drmp3_uint16 iMP3Frame;
-    drmp3_uint64 leftoverFrames;
-    DRMP3_ASSERT(pMP3 != NULL);
-    DRMP3_ASSERT(pMP3->pSeekPoints != NULL);
-    DRMP3_ASSERT(pMP3->seekPointCount > 0);
-    if (drmp3_find_closest_seek_point(pMP3, frameIndex, &priorSeekPointIndex)) {
-        seekPoint = pMP3->pSeekPoints[priorSeekPointIndex];
-    } else {
-        seekPoint.seekPosInBytes     = 0;
-        seekPoint.pcmFrameIndex      = 0;
-        seekPoint.mp3FramesToDiscard = 0;
-        seekPoint.pcmFramesToDiscard = 0;
-    }
-    if (!drmp3__on_seek_64(pMP3, seekPoint.seekPosInBytes, drmp3_seek_origin_start)) {
-        return DRMP3_FALSE;
-    }
-    drmp3_reset(pMP3);
-    for (iMP3Frame = 0; iMP3Frame < seekPoint.mp3FramesToDiscard; ++iMP3Frame) {
-        drmp3_uint32 pcmFramesRead;
-        drmp3d_sample_t* pPCMFrames;
-        pPCMFrames = NULL;
-        if (iMP3Frame == seekPoint.mp3FramesToDiscard-1) {
-            pPCMFrames = (drmp3d_sample_t*)pMP3->pcmFrames;
-        }
-        pcmFramesRead = drmp3_decode_next_frame_ex(pMP3, pPCMFrames);
-        if (pcmFramesRead == 0) {
-            return DRMP3_FALSE;
-        }
-    }
-    pMP3->currentPCMFrame = seekPoint.pcmFrameIndex - seekPoint.pcmFramesToDiscard;
-    leftoverFrames = frameIndex - pMP3->currentPCMFrame;
-    return drmp3_seek_forward_by_pcm_frames__brute_force(pMP3, leftoverFrames);
-}
-DRMP3_API drmp3_bool32 drmp3_seek_to_pcm_frame(drmp3* pMP3, drmp3_uint64 frameIndex)
-{
-    if (pMP3 == NULL || pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (frameIndex == 0) {
-        return drmp3_seek_to_start_of_stream(pMP3);
-    }
-    if (pMP3->pSeekPoints != NULL && pMP3->seekPointCount > 0) {
-        return drmp3_seek_to_pcm_frame__seek_table(pMP3, frameIndex);
-    } else {
-        return drmp3_seek_to_pcm_frame__brute_force(pMP3, frameIndex);
-    }
-}
-DRMP3_API drmp3_bool32 drmp3_get_mp3_and_pcm_frame_count(drmp3* pMP3, drmp3_uint64* pMP3FrameCount, drmp3_uint64* pPCMFrameCount)
-{
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalPCMFrameCount;
-    drmp3_uint64 totalMP3FrameCount;
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (pMP3->onSeek == NULL) {
-        return DRMP3_FALSE;
-    }
-    currentPCMFrame = pMP3->currentPCMFrame;
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-    totalPCMFrameCount = 0;
-    totalMP3FrameCount = 0;
-    for (;;) {
-        drmp3_uint32 pcmFramesInCurrentMP3Frame;
-        pcmFramesInCurrentMP3Frame = drmp3_decode_next_frame_ex(pMP3, NULL);
-        if (pcmFramesInCurrentMP3Frame == 0) {
-            break;
-        }
-        totalPCMFrameCount += pcmFramesInCurrentMP3Frame;
-        totalMP3FrameCount += 1;
-    }
-    if (!drmp3_seek_to_start_of_stream(pMP3)) {
-        return DRMP3_FALSE;
-    }
-    if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-        return DRMP3_FALSE;
-    }
-    if (pMP3FrameCount != NULL) {
-        *pMP3FrameCount = totalMP3FrameCount;
-    }
-    if (pPCMFrameCount != NULL) {
-        *pPCMFrameCount = totalPCMFrameCount;
-    }
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_uint64 drmp3_get_pcm_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalPCMFrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, NULL, &totalPCMFrameCount)) {
-        return 0;
-    }
-    return totalPCMFrameCount;
-}
-DRMP3_API drmp3_uint64 drmp3_get_mp3_frame_count(drmp3* pMP3)
-{
-    drmp3_uint64 totalMP3FrameCount;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, NULL)) {
-        return 0;
-    }
-    return totalMP3FrameCount;
-}
-static void drmp3__accumulate_running_pcm_frame_count(drmp3* pMP3, drmp3_uint32 pcmFrameCountIn, drmp3_uint64* pRunningPCMFrameCount, float* pRunningPCMFrameCountFractionalPart)
-{
-    float srcRatio;
-    float pcmFrameCountOutF;
-    drmp3_uint32 pcmFrameCountOut;
-    srcRatio = (float)pMP3->mp3FrameSampleRate / (float)pMP3->sampleRate;
-    DRMP3_ASSERT(srcRatio > 0);
-    pcmFrameCountOutF = *pRunningPCMFrameCountFractionalPart + (pcmFrameCountIn / srcRatio);
-    pcmFrameCountOut  = (drmp3_uint32)pcmFrameCountOutF;
-    *pRunningPCMFrameCountFractionalPart = pcmFrameCountOutF - pcmFrameCountOut;
-    *pRunningPCMFrameCount += pcmFrameCountOut;
-}
-typedef struct
-{
-    drmp3_uint64 bytePos;
-    drmp3_uint64 pcmFrameIndex;
-} drmp3__seeking_mp3_frame_info;
-DRMP3_API drmp3_bool32 drmp3_calculate_seek_points(drmp3* pMP3, drmp3_uint32* pSeekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    drmp3_uint32 seekPointCount;
-    drmp3_uint64 currentPCMFrame;
-    drmp3_uint64 totalMP3FrameCount;
-    drmp3_uint64 totalPCMFrameCount;
-    if (pMP3 == NULL || pSeekPointCount == NULL || pSeekPoints == NULL) {
-        return DRMP3_FALSE;
-    }
-    seekPointCount = *pSeekPointCount;
-    if (seekPointCount == 0) {
-        return DRMP3_FALSE;
-    }
-    currentPCMFrame = pMP3->currentPCMFrame;
-    if (!drmp3_get_mp3_and_pcm_frame_count(pMP3, &totalMP3FrameCount, &totalPCMFrameCount)) {
-        return DRMP3_FALSE;
-    }
-    if (totalMP3FrameCount < DRMP3_SEEK_LEADING_MP3_FRAMES+1) {
-        seekPointCount = 1;
-        pSeekPoints[0].seekPosInBytes     = 0;
-        pSeekPoints[0].pcmFrameIndex      = 0;
-        pSeekPoints[0].mp3FramesToDiscard = 0;
-        pSeekPoints[0].pcmFramesToDiscard = 0;
-    } else {
-        drmp3_uint64 pcmFramesBetweenSeekPoints;
-        drmp3__seeking_mp3_frame_info mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES+1];
-        drmp3_uint64 runningPCMFrameCount = 0;
-        float runningPCMFrameCountFractionalPart = 0;
-        drmp3_uint64 nextTargetPCMFrame;
-        drmp3_uint32 iMP3Frame;
-        drmp3_uint32 iSeekPoint;
-        if (seekPointCount > totalMP3FrameCount-1) {
-            seekPointCount = (drmp3_uint32)totalMP3FrameCount-1;
-        }
-        pcmFramesBetweenSeekPoints = totalPCMFrameCount / (seekPointCount+1);
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        for (iMP3Frame = 0; iMP3Frame < DRMP3_SEEK_LEADING_MP3_FRAMES+1; ++iMP3Frame) {
-            drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-            DRMP3_ASSERT(pMP3->streamCursor >= pMP3->dataSize);
-            mp3FrameInfo[iMP3Frame].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-            mp3FrameInfo[iMP3Frame].pcmFrameIndex = runningPCMFrameCount;
-            pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-            if (pcmFramesInCurrentMP3FrameIn == 0) {
-                return DRMP3_FALSE;
-            }
-            drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-        }
-        nextTargetPCMFrame = 0;
-        for (iSeekPoint = 0; iSeekPoint < seekPointCount; ++iSeekPoint) {
-            nextTargetPCMFrame += pcmFramesBetweenSeekPoints;
-            for (;;) {
-                if (nextTargetPCMFrame < runningPCMFrameCount) {
-                    pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                    pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                    pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                    pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                    break;
-                } else {
-                    size_t i;
-                    drmp3_uint32 pcmFramesInCurrentMP3FrameIn;
-                    for (i = 0; i < DRMP3_COUNTOF(mp3FrameInfo)-1; ++i) {
-                        mp3FrameInfo[i] = mp3FrameInfo[i+1];
-                    }
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].bytePos       = pMP3->streamCursor - pMP3->dataSize;
-                    mp3FrameInfo[DRMP3_COUNTOF(mp3FrameInfo)-1].pcmFrameIndex = runningPCMFrameCount;
-                    pcmFramesInCurrentMP3FrameIn = drmp3_decode_next_frame_ex(pMP3, NULL);
-                    if (pcmFramesInCurrentMP3FrameIn == 0) {
-                        pSeekPoints[iSeekPoint].seekPosInBytes     = mp3FrameInfo[0].bytePos;
-                        pSeekPoints[iSeekPoint].pcmFrameIndex      = nextTargetPCMFrame;
-                        pSeekPoints[iSeekPoint].mp3FramesToDiscard = DRMP3_SEEK_LEADING_MP3_FRAMES;
-                        pSeekPoints[iSeekPoint].pcmFramesToDiscard = (drmp3_uint16)(nextTargetPCMFrame - mp3FrameInfo[DRMP3_SEEK_LEADING_MP3_FRAMES-1].pcmFrameIndex);
-                        break;
-                    }
-                    drmp3__accumulate_running_pcm_frame_count(pMP3, pcmFramesInCurrentMP3FrameIn, &runningPCMFrameCount, &runningPCMFrameCountFractionalPart);
-                }
-            }
-        }
-        if (!drmp3_seek_to_start_of_stream(pMP3)) {
-            return DRMP3_FALSE;
-        }
-        if (!drmp3_seek_to_pcm_frame(pMP3, currentPCMFrame)) {
-            return DRMP3_FALSE;
-        }
-    }
-    *pSeekPointCount = seekPointCount;
-    return DRMP3_TRUE;
-}
-DRMP3_API drmp3_bool32 drmp3_bind_seek_table(drmp3* pMP3, drmp3_uint32 seekPointCount, drmp3_seek_point* pSeekPoints)
-{
-    if (pMP3 == NULL) {
-        return DRMP3_FALSE;
-    }
-    if (seekPointCount == 0 || pSeekPoints == NULL) {
-        pMP3->seekPointCount = 0;
-        pMP3->pSeekPoints = NULL;
-    } else {
-        pMP3->seekPointCount = seekPointCount;
-        pMP3->pSeekPoints = pSeekPoints;
-    }
-    return DRMP3_TRUE;
-}
-static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    float* pFrames = NULL;
-    float temp[4096];
-    DRMP3_ASSERT(pMP3 != NULL);
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_f32(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            float* pNewFrames;
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(float);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-            pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(float)));
-        totalFramesRead += framesJustRead;
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-    drmp3_uninit(pMP3);
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-    return pFrames;
-}
-static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount)
-{
-    drmp3_uint64 totalFramesRead = 0;
-    drmp3_uint64 framesCapacity = 0;
-    drmp3_int16* pFrames = NULL;
-    drmp3_int16 temp[4096];
-    DRMP3_ASSERT(pMP3 != NULL);
-    for (;;) {
-        drmp3_uint64 framesToReadRightNow = DRMP3_COUNTOF(temp) / pMP3->channels;
-        drmp3_uint64 framesJustRead = drmp3_read_pcm_frames_s16(pMP3, framesToReadRightNow, temp);
-        if (framesJustRead == 0) {
-            break;
-        }
-        if (framesCapacity < totalFramesRead + framesJustRead) {
-            drmp3_uint64 newFramesBufferSize;
-            drmp3_uint64 oldFramesBufferSize;
-            drmp3_uint64 newFramesCap;
-            drmp3_int16* pNewFrames;
-            newFramesCap = framesCapacity * 2;
-            if (newFramesCap < totalFramesRead + framesJustRead) {
-                newFramesCap = totalFramesRead + framesJustRead;
-            }
-            oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
-            newFramesBufferSize = newFramesCap   * pMP3->channels * sizeof(drmp3_int16);
-            if (newFramesBufferSize > DRMP3_SIZE_MAX) {
-                break;
-            }
-            pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
-            if (pNewFrames == NULL) {
-                drmp3__free_from_callbacks(pFrames, &pMP3->allocationCallbacks);
-                break;
-            }
-            pFrames = pNewFrames;
-            framesCapacity = newFramesCap;
-        }
-        DRMP3_COPY_MEMORY(pFrames + totalFramesRead*pMP3->channels, temp, (size_t)(framesJustRead*pMP3->channels*sizeof(drmp3_int16)));
-        totalFramesRead += framesJustRead;
-        if (framesJustRead != framesToReadRightNow) {
-            break;
-        }
-    }
-    if (pConfig != NULL) {
-        pConfig->channels   = pMP3->channels;
-        pConfig->sampleRate = pMP3->sampleRate;
-    }
-    drmp3_uninit(pMP3);
-    if (pTotalFrameCount) {
-        *pTotalFrameCount = totalFramesRead;
-    }
-    return pFrames;
-}
-DRMP3_API float* drmp3_open_and_read_pcm_frames_f32(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_and_read_pcm_frames_s16(drmp3_read_proc onRead, drmp3_seek_proc onSeek, void* pUserData, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init(&mp3, onRead, onSeek, pUserData, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API float* drmp3_open_memory_and_read_pcm_frames_f32(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_memory_and_read_pcm_frames_s16(const void* pData, size_t dataSize, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_memory(&mp3, pData, dataSize, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#ifndef DR_MP3_NO_STDIO
-DRMP3_API float* drmp3_open_file_and_read_pcm_frames_f32(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_f32(&mp3, pConfig, pTotalFrameCount);
-}
-DRMP3_API drmp3_int16* drmp3_open_file_and_read_pcm_frames_s16(const char* filePath, drmp3_config* pConfig, drmp3_uint64* pTotalFrameCount, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    drmp3 mp3;
-    if (!drmp3_init_file(&mp3, filePath, pAllocationCallbacks)) {
-        return NULL;
-    }
-    return drmp3__full_read_and_close_s16(&mp3, pConfig, pTotalFrameCount);
-}
-#endif
-DRMP3_API void* drmp3_malloc(size_t sz, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        return drmp3__malloc_from_callbacks(sz, pAllocationCallbacks);
-    } else {
-        return drmp3__malloc_default(sz, NULL);
-    }
-}
-DRMP3_API void drmp3_free(void* p, const drmp3_allocation_callbacks* pAllocationCallbacks)
-{
-    if (pAllocationCallbacks != NULL) {
-        drmp3__free_from_callbacks(p, pAllocationCallbacks);
-    } else {
-        drmp3__free_default(p, NULL);
-    }
-}
-#endif
-/* dr_mp3_c end */
-#endif  /* DRMP3_IMPLEMENTATION */
-#endif  /* MA_NO_MP3 */
-
-
-/* End globally disabled warnings. */
-#if defined(_MSC_VER)
-    #pragma warning(pop)
-#endif
-
-#endif  /* miniaudio_c */
-#endif  /* MINIAUDIO_IMPLEMENTATION */
-
-/*
-RELEASE NOTES - VERSION 0.10.x
-==============================
-Version 0.10 includes major API changes and refactoring, mostly concerned with the data conversion system. Data conversion is performed internally to convert
-audio data between the format requested when initializing the `ma_device` object and the format of the internal device used by the backend. The same applies
-to the `ma_decoder` object. The previous design has several design flaws and missing features which necessitated a complete redesign.
-
-
-Changes to Data Conversion
---------------------------
-The previous data conversion system used callbacks to deliver input data for conversion. This design works well in some specific situations, but in other
-situations it has some major readability and maintenance issues. The decision was made to replace this with a more iterative approach where you just pass in a
-pointer to the input data directly rather than dealing with a callback.
-
-The following are the data conversion APIs that have been removed and their replacements:
-
-  - ma_format_converter -> ma_convert_pcm_frames_format()
-  - ma_channel_router   -> ma_channel_converter
-  - ma_src              -> ma_resampler
-  - ma_pcm_converter    -> ma_data_converter
-
-The previous conversion APIs accepted a callback in their configs. There are no longer any callbacks to deal with. Instead you just pass the data into the
-`*_process_pcm_frames()` function as a pointer to a buffer.
-
-The simplest aspect of data conversion is sample format conversion. To convert between two formats, just call `ma_convert_pcm_frames_format()`. Channel
-conversion is also simple which you can do with `ma_channel_converter` via `ma_channel_converter_process_pcm_frames()`.
-
-Resampling is more complicated because the number of output frames that are processed is different to the number of input frames that are consumed. When you
-call `ma_resampler_process_pcm_frames()` you need to pass in the number of input frames available for processing and the number of output frames you want to
-output. Upon returning they will receive the number of input frames that were consumed and the number of output frames that were generated.
-
-The `ma_data_converter` API is a wrapper around format, channel and sample rate conversion and handles all of the data conversion you'll need which probably
-makes it the best option if you need to do data conversion.
-
-In addition to changes to the API design, a few other changes have been made to the data conversion pipeline:
-
-  - The sinc resampler has been removed. This was completely broken and never actually worked properly.
-  - The linear resampler now uses low-pass filtering to remove aliasing. The quality of the low-pass filter can be controlled via the resampler config with the
-    `lpfOrder` option, which has a maximum value of MA_MAX_FILTER_ORDER.
-  - Data conversion now supports s16 natively which runs through a fixed point pipeline. Previously everything needed to be converted to floating point before
-    processing, whereas now both s16 and f32 are natively supported. Other formats still require conversion to either s16 or f32 prior to processing, however
-    `ma_data_converter` will handle this for you.
-
-
-Custom Memory Allocators
-------------------------
-miniaudio has always supported macro level customization for memory allocation via MA_MALLOC, MA_REALLOC and MA_FREE, however some scenarios require more
-flexibility by allowing a user data pointer to be passed to the custom allocation routines. Support for this has been added to version 0.10 via the
-`ma_allocation_callbacks` structure. Anything making use of heap allocations has been updated to accept this new structure.
-
-The `ma_context_config` structure has been updated with a new member called `allocationCallbacks`. Leaving this set to it's defaults returned by
-`ma_context_config_init()` will cause it to use MA_MALLOC, MA_REALLOC and MA_FREE. Likewise, The `ma_decoder_config` structure has been updated in the same
-way, and leaving everything as-is after `ma_decoder_config_init()` will cause it to use the same defaults.
-
-The following APIs have been updated to take a pointer to a `ma_allocation_callbacks` object. Setting this parameter to NULL will cause it to use defaults.
-Otherwise they will use the relevant callback in the structure.
-
-  - ma_malloc()
-  - ma_realloc()
-  - ma_free()
-  - ma_aligned_malloc()
-  - ma_aligned_free()
-  - ma_rb_init() / ma_rb_init_ex()
-  - ma_pcm_rb_init() / ma_pcm_rb_init_ex()
-
-Note that you can continue to use MA_MALLOC, MA_REALLOC and MA_FREE as per normal. These will continue to be used by default if you do not specify custom
-allocation callbacks.
-
-
-Buffer and Period Configuration Changes
----------------------------------------
-The way in which the size of the internal buffer and periods are specified in the device configuration have changed. In previous versions, the config variables
-`bufferSizeInFrames` and `bufferSizeInMilliseconds` defined the size of the entire buffer, with the size of a period being the size of this variable divided by
-the period count. This became confusing because people would expect the value of `bufferSizeInFrames` or `bufferSizeInMilliseconds` to independantly determine
-latency, when in fact it was that value divided by the period count that determined it. These variables have been removed and replaced with new ones called
-`periodSizeInFrames` and `periodSizeInMilliseconds`.
-
-These new configuration variables work in the same way as their predecessors in that if one is set to 0, the other will be used, but the main difference is
-that you now set these to you desired latency rather than the size of the entire buffer. The benefit of this is that it's much easier and less confusing to
-configure latency.
-
-The following unused APIs have been removed:
-
-    ma_get_default_buffer_size_in_milliseconds()
-    ma_get_default_buffer_size_in_frames()
-
-The following macros have been removed:
-
-    MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY
-    MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE
-
-
-Other API Changes
------------------
-Other less major API changes have also been made in version 0.10.
-
-`ma_device_set_stop_callback()` has been removed. If you require a stop callback, you must now set it via the device config just like the data callback.
-
-The `ma_sine_wave` API has been replaced with a more general API called `ma_waveform`. This supports generation of different types of waveforms, including
-sine, square, triangle and sawtooth. Use `ma_waveform_init()` in place of `ma_sine_wave_init()` to initialize the waveform object. This takes a configuration
-object called `ma_waveform_config` which defines the properties of the waveform. Use `ma_waveform_config_init()` to initialize a `ma_waveform_config` object.
-Use `ma_waveform_read_pcm_frames()` in place of `ma_sine_wave_read_f32()` and `ma_sine_wave_read_f32_ex()`.
-
-`ma_convert_frames()` and `ma_convert_frames_ex()` have been changed. Both of these functions now take a new parameter called `frameCountOut` which specifies
-the size of the output buffer in PCM frames. This has been added for safety. In addition to this, the parameters for `ma_convert_frames_ex()` have changed to
-take a pointer to a `ma_data_converter_config` object to specify the input and output formats to convert between. This was done to make it more flexible, to
-prevent the parameter list getting too long, and to prevent API breakage whenever a new conversion property is added.
-
-`ma_calculate_frame_count_after_src()` has been renamed to `ma_calculate_frame_count_after_resampling()` for consistency with the new `ma_resampler` API.
-
-
-Filters
--------
-The following filters have been added:
-
-    |-------------|-------------------------------------------------------------------|
-    | API         | Description                                                       |
-    |-------------|-------------------------------------------------------------------|
-    | ma_biquad   | Biquad filter (transposed direct form 2)                          |
-    | ma_lpf1     | First order low-pass filter                                       |
-    | ma_lpf2     | Second order low-pass filter                                      |
-    | ma_lpf      | High order low-pass filter (Butterworth)                          |
-    | ma_hpf1     | First order high-pass filter                                      |
-    | ma_hpf2     | Second order high-pass filter                                     |
-    | ma_hpf      | High order high-pass filter (Butterworth)                         |
-    | ma_bpf2     | Second order band-pass filter                                     |
-    | ma_bpf      | High order band-pass filter                                       |
-    | ma_peak2    | Second order peaking filter                                       |
-    | ma_notch2   | Second order notching filter                                      |
-    | ma_loshelf2 | Second order low shelf filter                                     |
-    | ma_hishelf2 | Second order high shelf filter                                    |
-    |-------------|-------------------------------------------------------------------|
-
-These filters all support 32-bit floating point and 16-bit signed integer formats natively. Other formats need to be converted beforehand.
-
-
-Sine, Square, Triangle and Sawtooth Waveforms
----------------------------------------------
-Previously miniaudio supported only sine wave generation. This has now been generalized to support sine, square, triangle and sawtooth waveforms. The old
-`ma_sine_wave` API has been removed and replaced with the `ma_waveform` API. Use `ma_waveform_config_init()` to initialize a config object, and then pass it
-into `ma_waveform_init()`. Then use `ma_waveform_read_pcm_frames()` to read PCM data.
-
-
-Noise Generation
-----------------
-A noise generation API has been added. This is used via the `ma_noise` API. Currently white, pink and Brownian noise is supported. The `ma_noise` API is
-similar to the waveform API. Use `ma_noise_config_init()` to initialize a config object, and then pass it into `ma_noise_init()` to initialize a `ma_noise`
-object. Then use `ma_noise_read_pcm_frames()` to read PCM data.
-
-
-Miscellaneous Changes
----------------------
-The MA_NO_STDIO option has been removed. This would disable file I/O APIs, however this has proven to be too hard to maintain for it's perceived value and was
-therefore removed.
-
-Internal functions have all been made static where possible. If you get warnings about unused functions, please submit a bug report.
-
-The `ma_device` structure is no longer defined as being aligned to MA_SIMD_ALIGNMENT. This resulted in a possible crash when allocating a `ma_device` object on
-the heap, but not aligning it to MA_SIMD_ALIGNMENT. This crash would happen due to the compiler seeing the alignment specified on the structure and assuming it
-was always aligned as such and thinking it was safe to emit alignment-dependant SIMD instructions. Since miniaudio's philosophy is for things to just work,
-this has been removed from all structures.
-
-Results codes have been overhauled. Unnecessary result codes have been removed, and some have been renumbered for organisation purposes. If you are are binding
-maintainer you will need to update your result codes. Support has also been added for retrieving a human readable description of a given result code via the
-`ma_result_description()` API.
-
-ALSA: The automatic format conversion, channel conversion and resampling performed by ALSA is now disabled by default as they were causing some compatibility
-issues with certain devices and configurations. These can be individually enabled via the device config:
-
-    ```c
-    deviceConfig.alsa.noAutoFormat   = MA_TRUE;
-    deviceConfig.alsa.noAutoChannels = MA_TRUE;
-    deviceConfig.alsa.noAutoResample = MA_TRUE;
-    ```
-*/
-
-/*
-RELEASE NOTES - VERSION 0.9.x
-=============================
-Version 0.9 includes major API changes, centered mostly around full-duplex and the rebrand to "miniaudio". Before I go into detail about the major changes I
-would like to apologize. I know it's annoying dealing with breaking API changes, but I think it's best to get these changes out of the way now while the
-library is still relatively young and unknown.
-
-There's been a lot of refactoring with this release so there's a good chance a few bugs have been introduced. I apologize in advance for this. You may want to
-hold off on upgrading for the short term if you're worried. If mini_al v0.8.14 works for you, and you don't need full-duplex support, you can avoid upgrading
-(though you won't be getting future bug fixes).
-
-
-Rebranding to "miniaudio"
--------------------------
-The decision was made to rename mini_al to miniaudio. Don't worry, it's the same project. The reason for this is simple:
-
-1) Having the word "audio" in the title makes it immediately clear that the library is related to audio; and
-2) I don't like the look of the underscore.
-
-This rebrand has necessitated a change in namespace from "mal" to "ma". I know this is annoying, and I apologize, but it's better to get this out of the road
-now rather than later. Also, since there are necessary API changes for full-duplex support I think it's better to just get the namespace change over and done
-with at the same time as the full-duplex changes. I'm hoping this will be the last of the major API changes. Fingers crossed!
-
-The implementation define is now "#define MINIAUDIO_IMPLEMENTATION". You can also use "#define MA_IMPLEMENTATION" if that's your preference.
-
-
-Full-Duplex Support
--------------------
-The major feature added to version 0.9 is full-duplex. This has necessitated a few API changes.
-
-1) The data callback has now changed. Previously there was one type of callback for playback and another for capture. I wanted to avoid a third callback just
-   for full-duplex so the decision was made to break this API and unify the callbacks. Now, there is just one callback which is the same for all three modes
-   (playback, capture, duplex). The new callback looks like the following:
-
-       void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-
-   This callback allows you to move data straight out of the input buffer and into the output buffer in full-duplex mode. In playback-only mode, pInput will be
-   null. Likewise, pOutput will be null in capture-only mode. The sample count is no longer returned from the callback since it's not necessary for miniaudio
-   anymore.
-
-2) The device config needed to change in order to support full-duplex. Full-duplex requires the ability to allow the client to choose a different PCM format
-   for the playback and capture sides. The old ma_device_config object simply did not allow this and needed to change. With these changes you now specify the
-   device ID, format, channels, channel map and share mode on a per-playback and per-capture basis (see example below). The sample rate must be the same for
-   playback and capture.
-
-   Since the device config API has changed I have also decided to take the opportunity to simplify device initialization. Now, the device ID, device type and
-   callback user data are set in the config. ma_device_init() is now simplified down to taking just the context, device config and a pointer to the device
-   object being initialized. The rationale for this change is that it just makes more sense to me that these are set as part of the config like everything
-   else.
-
-   Example device initialization:
-
-       ma_device_config config = ma_device_config_init(ma_device_type_duplex);   // Or ma_device_type_playback or ma_device_type_capture.
-       config.playback.pDeviceID = &myPlaybackDeviceID; // Or NULL for the default playback device.
-       config.playback.format    = ma_format_f32;
-       config.playback.channels  = 2;
-       config.capture.pDeviceID  = &myCaptureDeviceID;  // Or NULL for the default capture device.
-       config.capture.format     = ma_format_s16;
-       config.capture.channels   = 1;
-       config.sampleRate         = 44100;
-       config.dataCallback       = data_callback;
-       config.pUserData          = &myUserData;
-
-       result = ma_device_init(&myContext, &config, &device);
-       if (result != MA_SUCCESS) {
-           ... handle error ...
-       }
-
-   Note that the "onDataCallback" member of ma_device_config has been renamed to "dataCallback". Also, "onStopCallback" has been renamed to "stopCallback".
-
-This is the first pass for full-duplex and there is a known bug. You will hear crackling on the following backends when sample rate conversion is required for
-the playback device:
-  - Core Audio
-  - JACK
-  - AAudio
-  - OpenSL
-  - WebAudio
-
-In addition to the above, not all platforms have been absolutely thoroughly tested simply because I lack the hardware for such thorough testing. If you
-experience a bug, an issue report on GitHub or an email would be greatly appreciated (and a sample program that reproduces the issue if possible).
-
-
-Other API Changes
------------------
-In addition to the above, the following API changes have been made:
-
-- The log callback is no longer passed to ma_context_config_init(). Instead you need to set it manually after initialization.
-- The onLogCallback member of ma_context_config has been renamed to "logCallback".
-- The log callback now takes a logLevel parameter. The new callback looks like: void log_callback(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-  - You can use ma_log_level_to_string() to convert the logLevel to human readable text if you want to log it.
-- Some APIs have been renamed:
-  - mal_decoder_read()          -> ma_decoder_read_pcm_frames()
-  - mal_decoder_seek_to_frame() -> ma_decoder_seek_to_pcm_frame()
-  - mal_sine_wave_read()        -> ma_sine_wave_read_f32()
-  - mal_sine_wave_read_ex()     -> ma_sine_wave_read_f32_ex()
-- Some APIs have been removed:
-  - mal_device_get_buffer_size_in_bytes()
-  - mal_device_set_recv_callback()
-  - mal_device_set_send_callback()
-  - mal_src_set_input_sample_rate()
-  - mal_src_set_output_sample_rate()
-- Error codes have been rearranged. If you're a binding maintainer you will need to update.
-- The ma_backend enums have been rearranged to priority order. The rationale for this is to simplify automatic backend selection and to make it easier to see
-  the priority. If you're a binding maintainer you will need to update.
-- ma_dsp has been renamed to ma_pcm_converter. The rationale for this change is that I'm expecting "ma_dsp" to conflict with some future planned high-level
-  APIs.
-- For functions that take a pointer/count combo, such as ma_decoder_read_pcm_frames(), the parameter order has changed so that the pointer comes before the
-  count. The rationale for this is to keep it consistent with things like memcpy().
-
-
-Miscellaneous Changes
----------------------
-The following miscellaneous changes have also been made.
-
-- The AAudio backend has been added for Android 8 and above. This is Android's new "High-Performance Audio" API. (For the record, this is one of the nicest
-  audio APIs out there, just behind the BSD audio APIs).
-- The WebAudio backend has been added. This is based on ScriptProcessorNode. This removes the need for SDL.
-- The SDL and OpenAL backends have been removed. These were originally implemented to add support for platforms for which miniaudio was not explicitly
-  supported. These are no longer needed and have therefore been removed.
-- Device initialization now fails if the requested share mode is not supported. If you ask for exclusive mode, you either get an exclusive mode device, or an
-  error. The rationale for this change is to give the client more control over how to handle cases when the desired shared mode is unavailable.
-- A lock-free ring buffer API has been added. There are two varients of this. "ma_rb" operates on bytes, whereas "ma_pcm_rb" operates on PCM frames.
-- The library is now licensed as a choice of Public Domain (Unlicense) _or_ MIT-0 (No Attribution) which is the same as MIT, but removes the attribution
-  requirement. The rationale for this is to support countries that don't recognize public domain.
-*/
-
-/*
-REVISION HISTORY
-================
-v0.10.33 - 2021-04-04
-  - Core Audio: Fix a memory leak.
-  - Core Audio: Fix a bug where the performance profile is not being used by playback devices.
-  - JACK: Fix loading of 64-bit JACK on Windows.
-  - Fix a calculation error and add a safety check to the following APIs to prevent a division by zero:
-    - ma_calculate_buffer_size_in_milliseconds_from_frames()
-    - ma_calculate_buffer_size_in_frames_from_milliseconds()
-  - Fix compilation errors relating to c89atomic.
-  - Update FLAC decoder.
-
-v0.10.32 - 2021-02-23
-  - WASAPI: Fix a deadlock in exclusive mode.
-  - WASAPI: No longer return an error from ma_context_get_device_info() when an exclusive mode format
-    cannot be retrieved.
-  - WASAPI: Attempt to fix some bugs with device uninitialization.
-  - PulseAudio: Yet another refactor, this time to remove the dependency on `pa_threaded_mainloop`.
-  - Web Audio: Fix a bug on Chrome and any other browser using the same engine.
-  - Web Audio: Automatically start the device on some user input if the device has been started. This
-    is to work around Google's policy of not starting audio if no user input has yet been performed.
-  - Fix a bug where thread handles are not being freed.
-  - Fix some static analysis warnings in FLAC, WAV and MP3 decoders.
-  - Fix a warning due to referencing _MSC_VER when it is undefined.
-  - Update to latest version of c89atomic.
-  - Internal refactoring to migrate over to the new backend callback system for the following backends:
-    - PulseAudio
-    - ALSA
-    - Core Audio
-    - AAudio
-    - OpenSL|ES
-    - OSS
-    - audio(4)
-    - sndio
-
-v0.10.31 - 2021-01-17
-  - Make some functions const correct.
-  - Update ma_data_source_read_pcm_frames() to initialize pFramesRead to 0 for safety.
-  - Add the MA_ATOMIC annotation for use with variables that should be used atomically and remove unnecessary volatile qualifiers.
-  - Add support for enabling only specific backends at compile time. This is the reverse of the pre-existing system. With the new
-    system, all backends are first disabled with `MA_ENABLE_ONLY_SPECIFIC_BACKENDS`, which is then followed with `MA_ENABLE_*`. The
-    old system where you disable backends with `MA_NO_*` still exists and is still the default.
-
-v0.10.30 - 2021-01-10
-  - Fix a crash in ma_audio_buffer_read_pcm_frames().
-  - Update spinlock APIs to take a volatile parameter as input.
-  - Silence some unused parameter warnings.
-  - Fix a warning on GCC when compiling as C++.
-
-v0.10.29 - 2020-12-26
-  - Fix some subtle multi-threading bugs on non-x86 platforms.
-  - Fix a bug resulting in superfluous memory allocations when enumerating devices.
-  - Core Audio: Fix a compilation error when compiling for iOS.
-
-v0.10.28 - 2020-12-16
-  - Fix a crash when initializing a POSIX thread.
-  - OpenSL|ES: Respect the MA_NO_RUNTIME_LINKING option.
-
-v0.10.27 - 2020-12-04
-  - Add support for dynamically configuring some properties of `ma_noise` objects post-initialization.
-  - Add support for configuring the channel mixing mode in the device config.
-  - Fix a bug with simple channel mixing mode (drop or silence excess channels).
-  - Fix some bugs with trying to access uninitialized variables.
-  - Fix some errors with stopping devices for synchronous backends where the backend's stop callback would get fired twice.
-  - Fix a bug in the decoder due to using an uninitialized variable.
-  - Fix some data race errors.
-
-v0.10.26 - 2020-11-24
-  - WASAPI: Fix a bug where the exclusive mode format may not be retrieved correctly due to accessing freed memory.
-  - Fix a bug with ma_waveform where glitching occurs after changing frequency.
-  - Fix compilation with OpenWatcom.
-  - Fix compilation with TCC.
-  - Fix compilation with Digital Mars.
-  - Fix compilation warnings.
-  - Remove bitfields from public structures to aid in binding maintenance.
-
-v0.10.25 - 2020-11-15
-  - PulseAudio: Fix a bug where the stop callback isn't fired.
-  - WebAudio: Fix an error that occurs when Emscripten increases the size of it's heap.
-  - Custom Backends: Change the onContextInit and onDeviceInit callbacks to take a parameter which is a pointer to the config that was
-    passed into ma_context_init() and ma_device_init(). This replaces the deviceType parameter of onDeviceInit.
-  - Fix compilation warnings on older versions of GCC.
-
-v0.10.24 - 2020-11-10
-  - Fix a bug where initialization of a backend can fail due to some bad state being set from a prior failed attempt at initializing a
-    lower priority backend.
-
-v0.10.23 - 2020-11-09
-  - AAudio: Add support for configuring a playback stream's usage.
-  - Fix a compilation error when all built-in asynchronous backends are disabled at compile time.
-  - Fix compilation errors when compiling as C++.
-
-v0.10.22 - 2020-11-08
-  - Add support for custom backends.
-  - Add support for detecting default devices during device enumeration and with `ma_context_get_device_info()`.
-  - Refactor to the PulseAudio backend. This simplifies the implementation and fixes a capture bug.
-  - ALSA: Fix a bug in `ma_context_get_device_info()` where the PCM handle is left open in the event of an error.
-  - Core Audio: Further improvements to sample rate selection.
-  - Core Audio: Fix some bugs with capture mode.
-  - OpenSL: Add support for configuring stream types and recording presets.
-  - AAudio: Add support for configuring content types and input presets.
-  - Fix bugs in `ma_decoder_init_file*()` where the file handle is not closed after a decoding error.
-  - Fix some compilation warnings on GCC and Clang relating to the Speex resampler.
-  - Fix a compilation error for the Linux build when the ALSA and JACK backends are both disabled.
-  - Fix a compilation error for the BSD build.
-  - Fix some compilation errors on older versions of GCC.
-  - Add documentation for `MA_NO_RUNTIME_LINKING`.
-
-v0.10.21 - 2020-10-30
-  - Add ma_is_backend_enabled() and ma_get_enabled_backends() for retrieving enabled backends at run-time.
-  - WASAPI: Fix a copy and paste bug relating to loopback mode.
-  - Core Audio: Fix a bug when using multiple contexts.
-  - Core Audio: Fix a compilation warning.
-  - Core Audio: Improvements to sample rate selection.
-  - Core Audio: Improvements to format/channels/rate selection when requesting defaults.
-  - Core Audio: Add notes regarding the Apple notarization process.
-  - Fix some bugs due to null pointer dereferences.
-
-v0.10.20 - 2020-10-06
-  - Fix build errors with UWP.
-  - Minor documentation updates.
-
-v0.10.19 - 2020-09-22
-  - WASAPI: Return an error when exclusive mode is requested, but the native format is not supported by miniaudio.
-  - Fix a bug where ma_decoder_seek_to_pcm_frames() never returns MA_SUCCESS even though it was successful.
-  - Store the sample rate in the `ma_lpf` and `ma_hpf` structures.
-
-v0.10.18 - 2020-08-30
-  - Fix build errors with VC6.
-  - Fix a bug in channel converter for s32 format.
-  - Change channel converter configs to use the default channel map instead of a blank channel map when no channel map is specified when initializing the
-    config. This fixes an issue where the optimized mono expansion path would never get used.
-  - Use a more appropriate default format for FLAC decoders. This will now use ma_format_s16 when the FLAC is encoded as 16-bit.
-  - Update FLAC decoder.
-  - Update links to point to the new repository location (https://github.com/mackron/miniaudio).
-
-v0.10.17 - 2020-08-28
-  - Fix an error where the WAV codec is incorrectly excluded from the build depending on which compile time options are set.
-  - Fix a bug in ma_audio_buffer_read_pcm_frames() where it isn't returning the correct number of frames processed.
-  - Fix compilation error on Android.
-  - Core Audio: Fix a bug with full-duplex mode.
-  - Add ma_decoder_get_cursor_in_pcm_frames().
-  - Update WAV codec.
-
-v0.10.16 - 2020-08-14
-  - WASAPI: Fix a potential crash due to using an uninitialized variable.
-  - OpenSL: Enable runtime linking.
-  - OpenSL: Fix a multithreading bug when initializing and uninitializing multiple contexts at the same time.
-  - iOS: Improvements to device enumeration.
-  - Fix a crash in ma_data_source_read_pcm_frames() when the output frame count parameter is NULL.
-  - Fix a bug in ma_data_source_read_pcm_frames() where looping doesn't work.
-  - Fix some compilation warnings on Windows when both DirectSound and WinMM are disabled.
-  - Fix some compilation warnings when no decoders are enabled.
-  - Add ma_audio_buffer_get_available_frames().
-  - Add ma_decoder_get_available_frames().
-  - Add sample rate to ma_data_source_get_data_format().
-  - Change volume APIs to take 64-bit frame counts.
-  - Updates to documentation.
-
-v0.10.15 - 2020-07-15
-  - Fix a bug when converting bit-masked channel maps to miniaudio channel maps. This affects the WASAPI and OpenSL backends.
-
-v0.10.14 - 2020-07-14
-  - Fix compilation errors on Android.
-  - Fix compilation errors with -march=armv6.
-  - Updates to the documentation.
-
-v0.10.13 - 2020-07-11
-  - Fix some potential buffer overflow errors with channel maps when channel counts are greater than MA_MAX_CHANNELS.
-  - Fix compilation error on Emscripten.
-  - Silence some unused function warnings.
-  - Increase the default buffer size on the Web Audio backend. This fixes glitching issues on some browsers.
-  - Bring FLAC decoder up-to-date with dr_flac.
-  - Bring MP3 decoder up-to-date with dr_mp3.
-
-v0.10.12 - 2020-07-04
-  - Fix compilation errors on the iOS build.
-
-v0.10.11 - 2020-06-28
-  - Fix some bugs with device tracking on Core Audio.
-  - Updates to documentation.
-
-v0.10.10 - 2020-06-26
-  - Add include guard for the implementation section.
-  - Mark ma_device_sink_info_callback() as static.
-  - Fix compilation errors with MA_NO_DECODING and MA_NO_ENCODING.
-  - Fix compilation errors with MA_NO_DEVICE_IO
-
-v0.10.9 - 2020-06-24
-  - Amalgamation of dr_wav, dr_flac and dr_mp3. With this change, including the header section of these libraries before the implementation of miniaudio is no
-    longer required. Decoding of WAV, FLAC and MP3 should be supported seamlessly without any additional libraries. Decoders can be excluded from the build
-    with the following options:
-    - MA_NO_WAV
-    - MA_NO_FLAC
-    - MA_NO_MP3
-    If you get errors about multiple definitions you need to either enable the options above, move the implementation of dr_wav, dr_flac and/or dr_mp3 to before
-    the implementation of miniaudio, or update dr_wav, dr_flac and/or dr_mp3.
-  - Changes to the internal atomics library. This has been replaced with c89atomic.h which is embedded within this file.
-  - Fix a bug when a decoding backend reports configurations outside the limits of miniaudio's decoder abstraction.
-  - Fix the UWP build.
-  - Fix the Core Audio build.
-  - Fix the -std=c89 build on GCC.
-
-v0.10.8 - 2020-06-22
-  - Remove dependency on ma_context from mutexes.
-  - Change ma_data_source_read_pcm_frames() to return a result code and output the frames read as an output parameter.
-  - Change ma_data_source_seek_pcm_frames() to return a result code and output the frames seeked as an output parameter.
-  - Change ma_audio_buffer_unmap() to return MA_AT_END when the end has been reached. This should be considered successful.
-  - Change playback.pDeviceID and capture.pDeviceID to constant pointers in ma_device_config.
-  - Add support for initializing decoders from a virtual file system object. This is achieved via the ma_vfs API and allows the application to customize file
-    IO for the loading and reading of raw audio data. Passing in NULL for the VFS will use defaults. New APIs:
-    - ma_decoder_init_vfs()
-    - ma_decoder_init_vfs_wav()
-    - ma_decoder_init_vfs_flac()
-    - ma_decoder_init_vfs_mp3()
-    - ma_decoder_init_vfs_vorbis()
-    - ma_decoder_init_vfs_w()
-    - ma_decoder_init_vfs_wav_w()
-    - ma_decoder_init_vfs_flac_w()
-    - ma_decoder_init_vfs_mp3_w()
-    - ma_decoder_init_vfs_vorbis_w()
-  - Add support for memory mapping to ma_data_source.
-    - ma_data_source_map()
-    - ma_data_source_unmap()
-  - Add ma_offset_pcm_frames_ptr() and ma_offset_pcm_frames_const_ptr() which can be used for offsetting a pointer by a specified number of PCM frames.
-  - Add initial implementation of ma_yield() which is useful for spin locks which will be used in some upcoming work.
-  - Add documentation for log levels.
-  - The ma_event API has been made public in preparation for some uncoming work.
-  - Fix a bug in ma_decoder_seek_to_pcm_frame() where the internal sample rate is not being taken into account for determining the seek location.
-  - Fix some bugs with the linear resampler when dynamically changing the sample rate.
-  - Fix compilation errors with MA_NO_DEVICE_IO.
-  - Fix some warnings with GCC and -std=c89.
-  - Fix some formatting warnings with GCC and -Wall and -Wpedantic.
-  - Fix some warnings with VC6.
-  - Minor optimization to ma_copy_pcm_frames(). This is now a no-op when the input and output buffers are the same.
-
-v0.10.7 - 2020-05-25
-  - Fix a compilation error in the C++ build.
-  - Silence a warning.
-
-v0.10.6 - 2020-05-24
-  - Change ma_clip_samples_f32() and ma_clip_pcm_frames_f32() to take a 64-bit sample/frame count.
-  - Change ma_zero_pcm_frames() to clear to 128 for ma_format_u8.
-  - Add ma_silence_pcm_frames() which replaces ma_zero_pcm_frames(). ma_zero_pcm_frames() will be removed in version 0.11.
-  - Add support for u8, s24 and s32 formats to ma_channel_converter.
-  - Add compile-time and run-time version querying.
-    - MA_VERSION_MINOR
-    - MA_VERSION_MAJOR
-    - MA_VERSION_REVISION
-    - MA_VERSION_STRING
-    - ma_version()
-    - ma_version_string()
-  - Add ma_audio_buffer for reading raw audio data directly from memory.
-  - Fix a bug in shuffle mode in ma_channel_converter.
-  - Fix compilation errors in certain configurations for ALSA and PulseAudio.
-  - The data callback now initializes the output buffer to 128 when the playback sample format is ma_format_u8.
-
-v0.10.5 - 2020-05-05
-  - Change ma_zero_pcm_frames() to take a 64-bit frame count.
-  - Add ma_copy_pcm_frames().
-  - Add MA_NO_GENERATION build option to exclude the `ma_waveform` and `ma_noise` APIs from the build.
-  - Add support for formatted logging to the VC6 build.
-  - Fix a crash in the linear resampler when LPF order is 0.
-  - Fix compilation errors and warnings with older versions of Visual Studio.
-  - Minor documentation updates.
-
-v0.10.4 - 2020-04-12
-  - Fix a data conversion bug when converting from the client format to the native device format.
-
-v0.10.3 - 2020-04-07
-  - Bring up to date with breaking changes to dr_mp3.
-  - Remove MA_NO_STDIO. This was causing compilation errors and the maintenance cost versus practical benefit is no longer worthwhile.
-  - Fix a bug with data conversion where it was unnecessarily converting to s16 or f32 and then straight back to the original format.
-  - Fix compilation errors and warnings with Visual Studio 2005.
-  - ALSA: Disable ALSA's automatic data conversion by default and add configuration options to the device config:
-    - alsa.noAutoFormat
-    - alsa.noAutoChannels
-    - alsa.noAutoResample
-  - WASAPI: Add some overrun recovery for ma_device_type_capture devices.
-
-v0.10.2 - 2020-03-22
-  - Decorate some APIs with MA_API which were missed in the previous version.
-  - Fix a bug in ma_linear_resampler_set_rate() and ma_linear_resampler_set_rate_ratio().
-
-v0.10.1 - 2020-03-17
-  - Add MA_API decoration. This can be customized by defining it before including miniaudio.h.
-  - Fix a bug where opening a file would return a success code when in fact it failed.
-  - Fix compilation errors with Visual Studio 6 and 2003.
-  - Fix warnings on macOS.
-
-v0.10.0 - 2020-03-07
-  - API CHANGE: Refactor data conversion APIs
-    - ma_format_converter has been removed. Use ma_convert_pcm_frames_format() instead.
-    - ma_channel_router has been replaced with ma_channel_converter.
-    - ma_src has been replaced with ma_resampler
-    - ma_pcm_converter has been replaced with ma_data_converter
-  - API CHANGE: Add support for custom memory allocation callbacks. The following APIs have been updated to take an extra parameter for the allocation
-    callbacks:
-    - ma_malloc()
-    - ma_realloc()
-    - ma_free()
-    - ma_aligned_malloc()
-    - ma_aligned_free()
-    - ma_rb_init() / ma_rb_init_ex()
-    - ma_pcm_rb_init() / ma_pcm_rb_init_ex()
-  - API CHANGE: Simplify latency specification in device configurations. The bufferSizeInFrames and bufferSizeInMilliseconds parameters have been replaced with
-    periodSizeInFrames and periodSizeInMilliseconds respectively. The previous variables defined the size of the entire buffer, whereas the new ones define the
-    size of a period. The following APIs have been removed since they are no longer relevant:
-    - ma_get_default_buffer_size_in_milliseconds()
-    - ma_get_default_buffer_size_in_frames()
-  - API CHANGE: ma_device_set_stop_callback() has been removed. If you require a stop callback, you must now set it via the device config just like the data
-    callback.
-  - API CHANGE: The ma_sine_wave API has been replaced with ma_waveform. The following APIs have been removed:
-    - ma_sine_wave_init()
-    - ma_sine_wave_read_f32()
-    - ma_sine_wave_read_f32_ex()
-  - API CHANGE: ma_convert_frames() has been updated to take an extra parameter which is the size of the output buffer in PCM frames. Parameters have also been
-    reordered.
-  - API CHANGE: ma_convert_frames_ex() has been changed to take a pointer to a ma_data_converter_config object to specify the input and output formats to
-    convert between.
-  - API CHANGE: ma_calculate_frame_count_after_src() has been renamed to ma_calculate_frame_count_after_resampling().
-  - Add support for the following filters:
-    - Biquad (ma_biquad)
-    - First order low-pass (ma_lpf1)
-    - Second order low-pass (ma_lpf2)
-    - Low-pass with configurable order (ma_lpf)
-    - First order high-pass (ma_hpf1)
-    - Second order high-pass (ma_hpf2)
-    - High-pass with configurable order (ma_hpf)
-    - Second order band-pass (ma_bpf2)
-    - Band-pass with configurable order (ma_bpf)
-    - Second order peaking EQ (ma_peak2)
-    - Second order notching (ma_notch2)
-    - Second order low shelf (ma_loshelf2)
-    - Second order high shelf (ma_hishelf2)
-  - Add waveform generation API (ma_waveform) with support for the following:
-    - Sine
-    - Square
-    - Triangle
-    - Sawtooth
-  - Add noise generation API (ma_noise) with support for the following:
-    - White
-    - Pink
-    - Brownian
-  - Add encoding API (ma_encoder). This only supports outputting to WAV files via dr_wav.
-  - Add ma_result_description() which is used to retrieve a human readable description of a given result code.
-  - Result codes have been changed. Binding maintainers will need to update their result code constants.
-  - More meaningful result codes are now returned when a file fails to open.
-  - Internal functions have all been made static where possible.
-  - Fix potential crash when ma_device object's are not aligned to MA_SIMD_ALIGNMENT.
-  - Fix a bug in ma_decoder_get_length_in_pcm_frames() where it was returning the length based on the internal sample rate rather than the output sample rate.
-  - Fix bugs in some backends where the device is not drained properly in ma_device_stop().
-  - Improvements to documentation.
-
-v0.9.10 - 2020-01-15
-  - Fix compilation errors due to #if/#endif mismatches.
-  - WASAPI: Fix a bug where automatic stream routing is being performed for devices that are initialized with an explicit device ID.
-  - iOS: Fix a crash on device uninitialization.
-
-v0.9.9 - 2020-01-09
-  - Fix compilation errors with MinGW.
-  - Fix compilation errors when compiling on Apple platforms.
-  - WASAPI: Add support for disabling hardware offloading.
-  - WASAPI: Add support for disabling automatic stream routing.
-  - Core Audio: Fix bugs in the case where the internal device uses deinterleaved buffers.
-  - Core Audio: Add support for controlling the session category (AVAudioSessionCategory) and options (AVAudioSessionCategoryOptions).
-  - JACK: Fix bug where incorrect ports are connected.
-
-v0.9.8 - 2019-10-07
-  - WASAPI: Fix a potential deadlock when starting a full-duplex device.
-  - WASAPI: Enable automatic resampling by default. Disable with config.wasapi.noAutoConvertSRC.
-  - Core Audio: Fix bugs with automatic stream routing.
-  - Add support for controlling whether or not the content of the output buffer passed in to the data callback is pre-initialized
-    to zero. By default it will be initialized to zero, but this can be changed by setting noPreZeroedOutputBuffer in the device
-    config. Setting noPreZeroedOutputBuffer to true will leave the contents undefined.
-  - Add support for clipping samples after the data callback has returned. This only applies when the playback sample format is
-    configured as ma_format_f32. If you are doing clipping yourself, you can disable this overhead by setting noClip to true in
-    the device config.
-  - Add support for master volume control for devices.
-    - Use ma_device_set_master_volume() to set the volume to a factor between 0 and 1, where 0 is silence and 1 is full volume.
-    - Use ma_device_set_master_gain_db() to set the volume in decibels where 0 is full volume and < 0 reduces the volume.
-  - Fix warnings emitted by GCC when `__inline__` is undefined or defined as nothing.
-
-v0.9.7 - 2019-08-28
-  - Add support for loopback mode (WASAPI only).
-    - To use this, set the device type to ma_device_type_loopback, and then fill out the capture section of the device config.
-    - If you need to capture from a specific output device, set the capture device ID to that of a playback device.
-  - Fix a crash when an error is posted in ma_device_init().
-  - Fix a compilation error when compiling for ARM architectures.
-  - Fix a bug with the audio(4) backend where the device is incorrectly being opened in non-blocking mode.
-  - Fix memory leaks in the Core Audio backend.
-  - Minor refactoring to the WinMM, ALSA, PulseAudio, OSS, audio(4), sndio and null backends.
-
-v0.9.6 - 2019-08-04
-  - Add support for loading decoders using a wchar_t string for file paths.
-  - Don't trigger an assert when ma_device_start() is called on a device that is already started. This will now log a warning
-    and return MA_INVALID_OPERATION. The same applies for ma_device_stop().
-  - Try fixing an issue with PulseAudio taking a long time to start playback.
-  - Fix a bug in ma_convert_frames() and ma_convert_frames_ex().
-  - Fix memory leaks in the WASAPI backend.
-  - Fix a compilation error with Visual Studio 2010.
-
-v0.9.5 - 2019-05-21
-  - Add logging to ma_dlopen() and ma_dlsym().
-  - Add ma_decoder_get_length_in_pcm_frames().
-  - Fix a bug with capture on the OpenSL|ES backend.
-  - Fix a bug with the ALSA backend where a device would not restart after being stopped.
-
-v0.9.4 - 2019-05-06
-  - Add support for C89. With this change, miniaudio should compile clean with GCC/Clang with "-std=c89 -ansi -pedantic" and
-    Microsoft compilers back to VC6. Other compilers should also work, but have not been tested.
-
-v0.9.3 - 2019-04-19
-  - Fix compiler errors on GCC when compiling with -std=c99.
-
-v0.9.2 - 2019-04-08
-  - Add support for per-context user data.
-  - Fix a potential bug with context configs.
-  - Fix some bugs with PulseAudio.
-
-v0.9.1 - 2019-03-17
-  - Fix a bug where the output buffer is not getting zeroed out before calling the data callback. This happens when
-    the device is running in passthrough mode (not doing any data conversion).
-  - Fix an issue where the data callback is getting called too frequently on the WASAPI and DirectSound backends.
-  - Fix error on the UWP build.
-  - Fix a build error on Apple platforms.
-
-v0.9 - 2019-03-06
-  - Rebranded to "miniaudio". All namespaces have been renamed from "mal" to "ma".
-  - API CHANGE: ma_device_init() and ma_device_config_init() have changed significantly:
-    - The device type, device ID and user data pointer have moved from ma_device_init() to the config.
-    - All variations of ma_device_config_init_*() have been removed in favor of just ma_device_config_init().
-    - ma_device_config_init() now takes only one parameter which is the device type. All other properties need
-      to be set on the returned object directly.
-    - The onDataCallback and onStopCallback members of ma_device_config have been renamed to "dataCallback"
-      and "stopCallback".
-    - The ID of the physical device is now split into two: one for the playback device and the other for the
-      capture device. This is required for full-duplex. These are named "pPlaybackDeviceID" and "pCaptureDeviceID".
-  - API CHANGE: The data callback has changed. It now uses a unified callback for all device types rather than
-    being separate for each. It now takes two pointers - one containing input data and the other output data. This
-    design in required for full-duplex. The return value is now void instead of the number of frames written. The
-    new callback looks like the following:
-        void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
-  - API CHANGE: Remove the log callback parameter from ma_context_config_init(). With this change,
-    ma_context_config_init() now takes no parameters and the log callback is set via the structure directly. The
-    new policy for config initialization is that only mandatory settings are passed in to *_config_init(). The
-    "onLog" member of ma_context_config has been renamed to "logCallback".
-  - API CHANGE: Remove ma_device_get_buffer_size_in_bytes().
-  - API CHANGE: Rename decoding APIs to "pcm_frames" convention.
-    - mal_decoder_read()          -> ma_decoder_read_pcm_frames()
-    - mal_decoder_seek_to_frame() -> ma_decoder_seek_to_pcm_frame()
-  - API CHANGE: Rename sine wave reading APIs to f32 convention.
-    - mal_sine_wave_read()    -> ma_sine_wave_read_f32()
-    - mal_sine_wave_read_ex() -> ma_sine_wave_read_f32_ex()
-  - API CHANGE: Remove some deprecated APIs
-    - mal_device_set_recv_callback()
-    - mal_device_set_send_callback()
-    - mal_src_set_input_sample_rate()
-    - mal_src_set_output_sample_rate()
-  - API CHANGE: Add log level to the log callback. New signature:
-    - void on_log(ma_context* pContext, ma_device* pDevice, ma_uint32 logLevel, const char* message)
-  - API CHANGE: Changes to result codes. Constants have changed and unused codes have been removed. If you're
-    a binding mainainer you will need to update your result code constants.
-  - API CHANGE: Change the order of the ma_backend enums to priority order. If you are a binding maintainer, you
-    will need to update.
-  - API CHANGE: Rename mal_dsp to ma_pcm_converter. All functions have been renamed from mal_dsp_*() to
-    ma_pcm_converter_*(). All structures have been renamed from mal_dsp* to ma_pcm_converter*.
-  - API CHANGE: Reorder parameters of ma_decoder_read_pcm_frames() to be consistent with the new parameter order scheme.
-  - The resampling algorithm has been changed from sinc to linear. The rationale for this is that the sinc implementation
-    is too inefficient right now. This will hopefully be improved at a later date.
-  - Device initialization will no longer fall back to shared mode if exclusive mode is requested but is unusable.
-    With this change, if you request an device in exclusive mode, but exclusive mode is not supported, it will not
-    automatically fall back to shared mode. The client will need to reinitialize the device in shared mode if that's
-    what they want.
-  - Add ring buffer API. This is ma_rb and ma_pcm_rb, the difference being that ma_rb operates on bytes and
-    ma_pcm_rb operates on PCM frames.
-  - Add Web Audio backend. This is used when compiling with Emscripten. The SDL backend, which was previously
-    used for web support, will be removed in a future version.
-  - Add AAudio backend (Android Audio). This is the new priority backend for Android. Support for AAudio starts
-    with Android 8. OpenSL|ES is used as a fallback for older versions of Android.
-  - Remove OpenAL and SDL backends.
-  - Fix a possible deadlock when rapidly stopping the device after it has started.
-  - Update documentation.
-  - Change licensing to a choice of public domain _or_ MIT-0 (No Attribution).
-
-v0.8.14 - 2018-12-16
-  - Core Audio: Fix a bug where the device state is not set correctly after stopping.
-  - Add support for custom weights to the channel router.
-  - Update decoders to use updated APIs in dr_flac, dr_mp3 and dr_wav.
-
-v0.8.13 - 2018-12-04
-  - Core Audio: Fix a bug with channel mapping.
-  - Fix a bug with channel routing where the back/left and back/right channels have the wrong weight.
-
-v0.8.12 - 2018-11-27
-  - Drop support for SDL 1.2. The Emscripten build now requires "-s USE_SDL=2".
-  - Fix a linking error with ALSA.
-  - Fix a bug on iOS where the device name is not set correctly.
-
-v0.8.11 - 2018-11-21
-  - iOS bug fixes.
-  - Minor tweaks to PulseAudio.
-
-v0.8.10 - 2018-10-21
-  - Core Audio: Fix a hang when uninitializing a device.
-  - Fix a bug where an incorrect value is returned from mal_device_stop().
-
-v0.8.9 - 2018-09-28
-  - Fix a bug with the SDL backend where device initialization fails.
-
-v0.8.8 - 2018-09-14
-  - Fix Linux build with the ALSA backend.
-  - Minor documentation fix.
-
-v0.8.7 - 2018-09-12
-  - Fix a bug with UWP detection.
-
-v0.8.6 - 2018-08-26
-  - Automatically switch the internal device when the default device is unplugged. Note that this is still in the
-    early stages and not all backends handle this the same way. As of this version, this will not detect a default
-    device switch when changed from the operating system's audio preferences (unless the backend itself handles
-    this automatically). This is not supported in exclusive mode.
-  - WASAPI and Core Audio: Add support for stream routing. When the application is using a default device and the
-    user switches the default device via the operating system's audio preferences, miniaudio will automatically switch
-    the internal device to the new default. This is not supported in exclusive mode.
-  - WASAPI: Add support for hardware offloading via IAudioClient2. Only supported on Windows 8 and newer.
-  - WASAPI: Add support for low-latency shared mode via IAudioClient3. Only supported on Windows 10 and newer.
-  - Add support for compiling the UWP build as C.
-  - mal_device_set_recv_callback() and mal_device_set_send_callback() have been deprecated. You must now set this
-    when the device is initialized with mal_device_init*(). These will be removed in version 0.9.0.
-
-v0.8.5 - 2018-08-12
-  - Add support for specifying the size of a device's buffer in milliseconds. You can still set the buffer size in
-    frames if that suits you. When bufferSizeInFrames is 0, bufferSizeInMilliseconds will be used. If both are non-0
-    then bufferSizeInFrames will take priority. If both are set to 0 the default buffer size is used.
-  - Add support for the audio(4) backend to OpenBSD.
-  - Fix a bug with the ALSA backend that was causing problems on Raspberry Pi. This significantly improves the
-    Raspberry Pi experience.
-  - Fix a bug where an incorrect number of samples is returned from sinc resampling.
-  - Add support for setting the value to be passed to internal calls to CoInitializeEx().
-  - WASAPI and WinMM: Stop the device when it is unplugged.
-
-v0.8.4 - 2018-08-06
-  - Add sndio backend for OpenBSD.
-  - Add audio(4) backend for NetBSD.
-  - Drop support for the OSS backend on everything except FreeBSD and DragonFly BSD.
-  - Formats are now native-endian (were previously little-endian).
-  - Mark some APIs as deprecated:
-    - mal_src_set_input_sample_rate() and mal_src_set_output_sample_rate() are replaced with mal_src_set_sample_rate().
-    - mal_dsp_set_input_sample_rate() and mal_dsp_set_output_sample_rate() are replaced with mal_dsp_set_sample_rate().
-  - Fix a bug when capturing using the WASAPI backend.
-  - Fix some aliasing issues with resampling, specifically when increasing the sample rate.
-  - Fix warnings.
-
-v0.8.3 - 2018-07-15
-  - Fix a crackling bug when resampling in capture mode.
-  - Core Audio: Fix a bug where capture does not work.
-  - ALSA: Fix a bug where the worker thread can get stuck in an infinite loop.
-  - PulseAudio: Fix a bug where mal_context_init() succeeds when PulseAudio is unusable.
-  - JACK: Fix a bug where mal_context_init() succeeds when JACK is unusable.
-
-v0.8.2 - 2018-07-07
-  - Fix a bug on macOS with Core Audio where the internal callback is not called.
-
-v0.8.1 - 2018-07-06
-  - Fix compilation errors and warnings.
-
-v0.8 - 2018-07-05
-  - Changed MAL_IMPLEMENTATION to MINI_AL_IMPLEMENTATION for consistency with other libraries. The old
-    way is still supported for now, but you should update as it may be removed in the future.
-  - API CHANGE: Replace device enumeration APIs. mal_enumerate_devices() has been replaced with
-    mal_context_get_devices(). An additional low-level device enumration API has been introduced called
-    mal_context_enumerate_devices() which uses a callback to report devices.
-  - API CHANGE: Rename mal_get_sample_size_in_bytes() to mal_get_bytes_per_sample() and add
-    mal_get_bytes_per_frame().
-  - API CHANGE: Replace mal_device_config.preferExclusiveMode with mal_device_config.shareMode.
-    - This new config can be set to mal_share_mode_shared (default) or mal_share_mode_exclusive.
-  - API CHANGE: Remove excludeNullDevice from mal_context_config.alsa.
-  - API CHANGE: Rename MAL_MAX_SAMPLE_SIZE_IN_BYTES to MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES.
-  - API CHANGE: Change the default channel mapping to the standard Microsoft mapping.
-  - API CHANGE: Remove backend-specific result codes.
-  - API CHANGE: Changes to the format conversion APIs (mal_pcm_f32_to_s16(), etc.)
-  - Add support for Core Audio (Apple).
-  - Add support for PulseAudio.
-    - This is the highest priority backend on Linux (higher priority than ALSA) since it is commonly
-      installed by default on many of the popular distros and offer's more seamless integration on
-      platforms where PulseAudio is used. In addition, if PulseAudio is installed and running (which
-      is extremely common), it's better to just use PulseAudio directly rather than going through the
-      "pulse" ALSA plugin (which is what the "default" ALSA device is likely set to).
-  - Add support for JACK.
-  - Remove dependency on asound.h for the ALSA backend. This means the ALSA development packages are no
-    longer required to build miniaudio.
-  - Remove dependency on dsound.h for the DirectSound backend. This fixes build issues with some
-    distributions of MinGW.
-  - Remove dependency on audioclient.h for the WASAPI backend. This fixes build issues with some
-    distributions of MinGW.
-  - Add support for dithering to format conversion.
-  - Add support for configuring the priority of the worker thread.
-  - Add a sine wave generator.
-  - Improve efficiency of sample rate conversion.
-  - Introduce the notion of standard channel maps. Use mal_get_standard_channel_map().
-  - Introduce the notion of default device configurations. A default config uses the same configuration
-    as the backend's internal device, and as such results in a pass-through data transmission pipeline.
-  - Add support for passing in NULL for the device config in mal_device_init(), which uses a default
-    config. This requires manually calling mal_device_set_send/recv_callback().
-  - Add support for decoding from raw PCM data (mal_decoder_init_raw(), etc.)
-  - Make mal_device_init_ex() more robust.
-  - Make some APIs more const-correct.
-  - Fix errors with SDL detection on Apple platforms.
-  - Fix errors with OpenAL detection.
-  - Fix some memory leaks.
-  - Fix a bug with opening decoders from memory.
-  - Early work on SSE2, AVX2 and NEON optimizations.
-  - Miscellaneous bug fixes.
-  - Documentation updates.
-
-v0.7 - 2018-02-25
-  - API CHANGE: Change mal_src_read_frames() and mal_dsp_read_frames() to use 64-bit sample counts.
-  - Add decoder APIs for loading WAV, FLAC, Vorbis and MP3 files.
-  - Allow opening of devices without a context.
-    - In this case the context is created and managed internally by the device.
-  - Change the default channel mapping to the same as that used by FLAC.
-  - Fix build errors with macOS.
-
-v0.6c - 2018-02-12
-  - Fix build errors with BSD/OSS.
-
-v0.6b - 2018-02-03
-  - Fix some warnings when compiling with Visual C++.
-
-v0.6a - 2018-01-26
-  - Fix errors with channel mixing when increasing the channel count.
-  - Improvements to the build system for the OpenAL backend.
-  - Documentation fixes.
-
-v0.6 - 2017-12-08
-  - API CHANGE: Expose and improve mutex APIs. If you were using the mutex APIs before this version you'll
-    need to update.
-  - API CHANGE: SRC and DSP callbacks now take a pointer to a mal_src and mal_dsp object respectively.
-  - API CHANGE: Improvements to event and thread APIs. These changes make these APIs more consistent.
-  - Add support for SDL and Emscripten.
-  - Simplify the build system further for when development packages for various backends are not installed.
-    With this change, when the compiler supports __has_include, backends without the relevant development
-    packages installed will be ignored. This fixes the build for old versions of MinGW.
-  - Fixes to the Android build.
-  - Add mal_convert_frames(). This is a high-level helper API for performing a one-time, bulk conversion of
-    audio data to a different format.
-  - Improvements to f32 -> u8/s16/s24/s32 conversion routines.
-  - Fix a bug where the wrong value is returned from mal_device_start() for the OpenSL backend.
-  - Fixes and improvements for Raspberry Pi.
-  - Warning fixes.
-
-v0.5 - 2017-11-11
-  - API CHANGE: The mal_context_init() function now takes a pointer to a mal_context_config object for
-    configuring the context. The works in the same kind of way as the device config. The rationale for this
-    change is to give applications better control over context-level properties, add support for backend-
-    specific configurations, and support extensibility without breaking the API.
-  - API CHANGE: The alsa.preferPlugHW device config variable has been removed since it's not really useful for
-    anything anymore.
-  - ALSA: By default, device enumeration will now only enumerate over unique card/device pairs. Applications
-    can enable verbose device enumeration by setting the alsa.useVerboseDeviceEnumeration context config
-    variable.
-  - ALSA: When opening a device in shared mode (the default), the dmix/dsnoop plugin will be prioritized. If
-    this fails it will fall back to the hw plugin. With this change the preferExclusiveMode config is now
-    honored. Note that this does not happen when alsa.useVerboseDeviceEnumeration is set to true (see above)
-    which is by design.
-  - ALSA: Add support for excluding the "null" device using the alsa.excludeNullDevice context config variable.
-  - ALSA: Fix a bug with channel mapping which causes an assertion to fail.
-  - Fix errors with enumeration when pInfo is set to NULL.
-  - OSS: Fix a bug when starting a device when the client sends 0 samples for the initial buffer fill.
-
-v0.4 - 2017-11-05
-  - API CHANGE: The log callback is now per-context rather than per-device and as is thus now passed to
-    mal_context_init(). The rationale for this change is that it allows applications to capture diagnostic
-    messages at the context level. Previously this was only available at the device level.
-  - API CHANGE: The device config passed to mal_device_init() is now const.
-  - Added support for OSS which enables support on BSD platforms.
-  - Added support for WinMM (waveOut/waveIn).
-  - Added support for UWP (Universal Windows Platform) applications. Currently C++ only.
-  - Added support for exclusive mode for selected backends. Currently supported on WASAPI.
-  - POSIX builds no longer require explicit linking to libpthread (-lpthread).
-  - ALSA: Explicit linking to libasound (-lasound) is no longer required.
-  - ALSA: Latency improvements.
-  - ALSA: Use MMAP mode where available. This can be disabled with the alsa.noMMap config.
-  - ALSA: Use "hw" devices instead of "plughw" devices by default. This can be disabled with the
-    alsa.preferPlugHW config.
-  - WASAPI is now the highest priority backend on Windows platforms.
-  - Fixed an error with sample rate conversion which was causing crackling when capturing.
-  - Improved error handling.
-  - Improved compiler support.
-  - Miscellaneous bug fixes.
-
-v0.3 - 2017-06-19
-  - API CHANGE: Introduced the notion of a context. The context is the highest level object and is required for
-    enumerating and creating devices. Now, applications must first create a context, and then use that to
-    enumerate and create devices. The reason for this change is to ensure device enumeration and creation is
-    tied to the same backend. In addition, some backends are better suited to this design.
-  - API CHANGE: Removed the rewinding APIs because they're too inconsistent across the different backends, hard
-    to test and maintain, and just generally unreliable.
-  - Added helper APIs for initializing mal_device_config objects.
-  - Null Backend: Fixed a crash when recording.
-  - Fixed build for UWP.
-  - Added support for f32 formats to the OpenSL|ES backend.
-  - Added initial implementation of the WASAPI backend.
-  - Added initial implementation of the OpenAL backend.
-  - Added support for low quality linear sample rate conversion.
-  - Added early support for basic channel mapping.
-
-v0.2 - 2016-10-28
-  - API CHANGE: Add user data pointer as the last parameter to mal_device_init(). The rationale for this
-    change is to ensure the logging callback has access to the user data during initialization.
-  - API CHANGE: Have device configuration properties be passed to mal_device_init() via a structure. Rationale:
-    1) The number of parameters is just getting too much.
-    2) It makes it a bit easier to add new configuration properties in the future. In particular, there's a
-       chance there will be support added for backend-specific properties.
-  - Dropped support for f64, A-law and Mu-law formats since they just aren't common enough to justify the
-    added maintenance cost.
-  - DirectSound: Increased the default buffer size for capture devices.
-  - Added initial implementation of the OpenSL|ES backend.
-
-v0.1 - 2016-10-21
-  - Initial versioned release.
-*/
-
-
-/*
-This software is available as a choice of the following licenses. Choose
-whichever you prefer.
-
-===============================================================================
-ALTERNATIVE 1 - Public Domain (www.unlicense.org)
-===============================================================================
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to <http://unlicense.org/>
-
-===============================================================================
-ALTERNATIVE 2 - MIT No Attribution
-===============================================================================
-Copyright 2020 David Reid
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
diff --git a/raylib_pi4_test/external/msf_gif.h b/raylib_pi4_test/external/msf_gif.h
deleted file mode 100644 (file)
index 348b1b1..0000000
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
-HOW TO USE:
-
-    In exactly one translation unit (.c or .cpp file), #define MSF_GIF_IMPL before including the header, like so:
-
-    #define MSF_GIF_IMPL
-    #include "msf_gif.h"
-
-    Everywhere else, just include the header like normal.
-
-
-USAGE EXAMPLE:
-
-    int width = 480, height = 320, centisecondsPerFrame = 5, bitDepth = 16;
-    MsfGifState gifState = {};
-    msf_gif_begin(&gifState, width, height);
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 1
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 2
-    msf_gif_frame(&gifState, ..., centisecondsPerFrame, bitDepth, width * 4); //frame 3, etc...
-    MsfGifResult result = msf_gif_end(&gifState);
-    FILE * fp = fopen("MyGif.gif", "wb");
-    fwrite(result.data, result.dataSize, 1, fp);
-    fclose(fp);
-    msf_gif_free(result);
-
-Detailed function documentation can be found in the header section below.
-
-
-REPLACING MALLOC:
-
-    This library uses malloc+realloc+free internally for memory allocation.
-    To facilitate integration with custom memory allocators, these calls go through macros, which can be redefined.
-    The expected function signature equivalents of the macros are as follows:
-
-    void * MSF_GIF_MALLOC(void * context, size_t newSize)
-    void * MSF_GIF_REALLOC(void * context, void * oldMemory, size_t oldSize, size_t newSize)
-    void MSF_GIF_FREE(void * context, void * oldMemory, size_t oldSize)
-
-    If your allocator needs a context pointer, you can set the `customAllocatorContext` field of the MsfGifState struct
-    before calling msf_gif_begin(), and it will be passed to all subsequent allocator macro calls.
-
-See end of file for license information.
-*/
-
-//version 2.1
-
-#ifndef MSF_GIF_H
-#define MSF_GIF_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-typedef struct {
-    void * data;
-    size_t dataSize;
-
-    size_t allocSize; //internal use
-    void * contextPointer; //internal use
-} MsfGifResult;
-
-typedef struct { //internal use
-    uint32_t * pixels;
-    int depth, count, rbits, gbits, bbits;
-} MsfCookedFrame;
-
-typedef struct {
-    MsfCookedFrame previousFrame;
-    uint8_t * listHead;
-    uint8_t * listTail;
-    int width, height;
-    void * customAllocatorContext;
-} MsfGifState;
-
-#ifdef __cplusplus
-extern "C" {
-#endif //__cplusplus
-
-/**
- * @param width                Image width in pixels.
- * @param height               Image height in pixels.
- * @return                     Non-zero on success, 0 on error.
- */
-int msf_gif_begin(MsfGifState * handle, int width, int height);
-
-/**
- * @param pixelData            Pointer to raw framebuffer data. Rows must be contiguous in memory, in RGBA8 format.
- *                             Note: This function does NOT free `pixelData`. You must free it yourself afterwards.
- * @param centiSecondsPerFrame How many hundredths of a second this frame should be displayed for.
- *                             Note: This being specified in centiseconds is a limitation of the GIF format.
- * @param maxBitDepth          Limits how many bits per pixel can be used when quantizing the gif.
- *                             The actual bit depth chosen for a given frame will be less than or equal to
- *                             the supplied maximum, depending on the variety of colors used in the frame.
- *                             `maxBitDepth` will be clamped between 1 and 16. The recommended default is 16.
- *                             Lowering this value can result in faster exports and smaller gifs,
- *                             but the quality may suffer.
- *                             Please experiment with this value to find what works best for your application.
- * @param pitchInBytes         The number of bytes from the beginning of one row of pixels to the beginning of the next.
- *                             If you want to flip the image, just pass in a negative pitch.
- * @return                     Non-zero on success, 0 on error.
- */
-int msf_gif_frame(MsfGifState * handle, uint8_t * pixelData, int centiSecondsPerFame, int maxBitDepth, int pitchInBytes);
-
-/**
- * @return                     A block of memory containing the gif file data, or NULL on error.
- *                             You are responsible for freeing this via `msf_gif_free()`.
- */
-MsfGifResult msf_gif_end(MsfGifState * handle);
-
-/**
- * @param result                The MsfGifResult struct, verbatim as it was returned from `msf_gif_end()`.
- */
-void msf_gif_free(MsfGifResult result);
-
-#ifdef __cplusplus
-}
-#endif //__cplusplus
-
-#endif //MSF_GIF_H
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// IMPLEMENTATION                                                                                                   ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#ifdef MSF_GIF_IMPL
-#ifndef MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-#define MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-
-#ifndef MSF_GIF_BUFFER_INIT_SIZE
-#define MSF_GIF_BUFFER_INIT_SIZE 1024 * 1024 * 4 //4MB by default, you can increase this if you want to realloc less
-#endif
-
-//ensure the library user has either defined all of malloc/realloc/free, or none
-#if defined(MSF_GIF_MALLOC) && defined(MSF_GIF_REALLOC) && defined(MSF_GIF_FREE) //ok
-#elif !defined(MSF_GIF_MALLOC) && !defined(MSF_GIF_REALLOC) && !defined(MSF_GIF_FREE) //ok
-#else
-#error "You must either define all of MSF_GIF_MALLOC, MSF_GIF_REALLOC, and MSF_GIF_FREE, or define none of them"
-#endif
-
-//provide default allocator definitions that redirect to the standard global allocator
-#if !defined(MSF_GIF_MALLOC)
-#include <stdlib.h> //malloc, etc.
-#define MSF_GIF_MALLOC(contextPointer, newSize) malloc(newSize)
-#define MSF_GIF_REALLOC(contextPointer, oldMemory, oldSize, newSize) realloc(oldMemory, newSize)
-#define MSF_GIF_FREE(contextPointer, oldMemory, oldSize) free(oldMemory)
-#endif
-
-//instrumentation for capturing profiling traces (useless for the library user, but useful for the library author)
-#ifdef MSF_GIF_ENABLE_TRACING
-#define MsfTimeFunc TimeFunc
-#define MsfTimeLoop TimeLoop
-#define msf_init_profiling_thread init_profiling_thread
-#else
-#define MsfTimeFunc
-#define MsfTimeLoop(name)
-#define msf_init_profiling_thread()
-#endif //MSF_GIF_ENABLE_TRACING
-
-#include <string.h> //memcpy
-
-//TODO: use compiler-specific notation to force-inline functions currently marked inline
-#if defined(__GNUC__) //gcc, clang
-static inline int msf_bit_log(int i) { return 32 - __builtin_clz(i); }
-#elif defined(_MSC_VER) //msvc
-#include <intrin.h>
-static inline int msf_bit_log(int i) { unsigned long idx; _BitScanReverse(&idx, i); return idx + 1; }
-#else //fallback implementation for other compilers
-//from https://stackoverflow.com/a/31718095/3064745 - thanks!
-static inline int msf_bit_log(int i) {
-    static const int MultiplyDeBruijnBitPosition[32] = {
-        0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
-        8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31,
-    };
-    i |= i >> 1;
-    i |= i >> 2;
-    i |= i >> 4;
-    i |= i >> 8;
-    i |= i >> 16;
-    return MultiplyDeBruijnBitPosition[(uint32_t)(i * 0x07C4ACDDU) >> 27] + 1;
-}
-#endif
-static inline int msf_imin(int a, int b) { return a < b? a : b; }
-static inline int msf_imax(int a, int b) { return b < a? a : b; }
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Frame Cooking                                                                                                    ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-#if (defined (__SSE2__) || defined (_M_X64) || _M_IX86_FP == 2) && !defined(MSF_GIF_NO_SSE2)
-#include <emmintrin.h>
-#endif
-
-static MsfCookedFrame msf_cook_frame(void * allocContext, uint8_t * raw, uint8_t * used,
-                                     int width, int height, int pitch, int depth)
-{ MsfTimeFunc
-    //bit depth for each channel
-    const static int rdepths[17] = { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5 };
-    const static int gdepths[17] = { 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6 };
-    const static int bdepths[17] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5 };
-
-    const static int ditherKernel[16] = {
-         0 << 12,  8 << 12,  2 << 12, 10 << 12,
-        12 << 12,  4 << 12, 14 << 12,  6 << 12,
-         3 << 12, 11 << 12,  1 << 12,  9 << 12,
-        15 << 12,  7 << 12, 13 << 12,  5 << 12,
-    };
-
-    uint32_t * cooked = (uint32_t *) MSF_GIF_MALLOC(allocContext, width * height * sizeof(uint32_t));
-    if (!cooked) { MsfCookedFrame blank = {0}; return blank; }
-
-    int count = 0;
-    MsfTimeLoop("do") do {
-        int rbits = rdepths[depth], gbits = gdepths[depth], bbits = bdepths[depth];
-        int paletteSize = 1 << (rbits + gbits + bbits);
-        memset(used, 0, paletteSize * sizeof(uint8_t));
-
-        //TODO: document what this math does and why it's correct
-        int rdiff = (1 << (8 - rbits)) - 1;
-        int gdiff = (1 << (8 - gbits)) - 1;
-        int bdiff = (1 << (8 - bbits)) - 1;
-        short rmul = (short) ((255.0f - rdiff) / 255.0f * 257);
-        short gmul = (short) ((255.0f - gdiff) / 255.0f * 257);
-        short bmul = (short) ((255.0f - bdiff) / 255.0f * 257);
-
-        int gmask = ((1 << gbits) - 1) << rbits;
-        int bmask = ((1 << bbits) - 1) << rbits << gbits;
-
-        MsfTimeLoop("cook") for (int y = 0; y < height; ++y) {
-            int x = 0;
-
-            #if (defined (__SSE2__) || defined (_M_X64) || _M_IX86_FP == 2) && !defined(MSF_GIF_NO_SSE2)
-                __m128i k = _mm_loadu_si128((__m128i *) &ditherKernel[(y & 3) * 4]);
-                __m128i k2 = _mm_or_si128(_mm_srli_epi32(k, rbits), _mm_slli_epi32(_mm_srli_epi32(k, bbits), 16));
-                // MsfTimeLoop("SIMD")
-                for (; x < width - 3; x += 4) {
-                    uint8_t * pixels = &raw[y * pitch + x * 4];
-                    __m128i p = _mm_loadu_si128((__m128i *) pixels);
-
-                    __m128i rb = _mm_and_si128(p, _mm_set1_epi32(0x00FF00FF));
-                    __m128i rb1 = _mm_mullo_epi16(rb, _mm_set_epi16(bmul, rmul, bmul, rmul, bmul, rmul, bmul, rmul));
-                    __m128i rb2 = _mm_adds_epu16(rb1, k2);
-                    __m128i r3 = _mm_srli_epi32(_mm_and_si128(rb2, _mm_set1_epi32(0x0000FFFF)), 16 - rbits);
-                    __m128i b3 = _mm_and_si128(_mm_srli_epi32(rb2, 32 - rbits - gbits - bbits), _mm_set1_epi32(bmask));
-
-                    __m128i g = _mm_and_si128(_mm_srli_epi32(p, 8), _mm_set1_epi32(0x000000FF));
-                    __m128i g1 = _mm_mullo_epi16(g, _mm_set1_epi32(gmul));
-                    __m128i g2 = _mm_adds_epu16(g1, _mm_srli_epi32(k, gbits));
-                    __m128i g3 = _mm_and_si128(_mm_srli_epi32(g2, 16 - rbits - gbits), _mm_set1_epi32(gmask));
-
-                    //TODO: does storing this as a __m128i then reading it back as a uint32_t violate strict aliasing?
-                    uint32_t * c = &cooked[y * width + x];
-                    __m128i out = _mm_or_si128(_mm_or_si128(r3, g3), b3);
-                    _mm_storeu_si128((__m128i *) c, out);
-                }
-            #endif
-
-            //scalar cleanup loop
-            // MsfTimeLoop("scalar")
-            for (; x < width; ++x) {
-                uint8_t * p = &raw[y * pitch + x * 4];
-                int dx = x & 3, dy = y & 3;
-                int k = ditherKernel[dy * 4 + dx];
-                cooked[y * width + x] =
-                    (msf_imin(65535, p[2] * bmul + (k >> bbits)) >> (16 - rbits - gbits - bbits) & bmask) |
-                    (msf_imin(65535, p[1] * gmul + (k >> gbits)) >> (16 - rbits - gbits        ) & gmask) |
-                     msf_imin(65535, p[0] * rmul + (k >> rbits)) >> (16 - rbits                );
-            }
-        }
-
-        count = 0;
-        MsfTimeLoop("mark and count") for (int i = 0; i < width * height; ++i) {
-            used[cooked[i]] = 1;
-        }
-
-        //count used colors
-        MsfTimeLoop("count") for (int j = 0; j < paletteSize; ++j) {
-            count += used[j];
-        }
-    } while (count >= 256 && --depth);
-
-    MsfCookedFrame ret = { cooked, depth, count, rdepths[depth], gdepths[depth], bdepths[depth] };
-    return ret;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Frame Compression                                                                                                ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct {
-    uint8_t * next;
-    size_t size;
-} MsfBufferHeader;
-
-static inline int msf_put_code(uint8_t * * writeHead, uint32_t * blockBits, int len, uint32_t code) {
-    //insert new code into block buffer
-    int idx = *blockBits / 8;
-    int bit = *blockBits % 8;
-    (*writeHead)[idx + 0] |= code <<       bit ;
-    (*writeHead)[idx + 1] |= code >> ( 8 - bit);
-    (*writeHead)[idx + 2] |= code >> (16 - bit);
-    *blockBits += len;
-
-    //prep the next block buffer if the current one is full
-    if (*blockBits >= 256 * 8) {
-        *blockBits -= 255 * 8;
-        (*writeHead) += 256;
-        (*writeHead)[2] = (*writeHead)[1];
-        (*writeHead)[1] = (*writeHead)[0];
-        (*writeHead)[0] = 255;
-        memset((*writeHead) + 4, 0, 256);
-    }
-
-    return 1;
-}
-
-typedef struct {
-    int16_t * data;
-    int len;
-    int stride;
-} MsfStridedList;
-
-static inline void msf_lzw_reset(MsfStridedList * lzw, int tableSize, int stride) { MsfTimeFunc
-    memset(lzw->data, 0xFF, 4096 * stride * sizeof(int16_t));
-    lzw->len = tableSize + 2;
-    lzw->stride = stride;
-}
-
-static uint8_t * msf_compress_frame(void * allocContext, int width, int height, int centiSeconds,
-                                    MsfCookedFrame frame, MsfCookedFrame previous, uint8_t * used)
-{ MsfTimeFunc
-    //NOTE: we reserve enough memory for theoretical the worst case upfront because it's a reasonable amount,
-    //      and prevents us from ever having to check size or realloc during compression
-    int maxBufSize = sizeof(MsfBufferHeader) + 32 + 256 * 3 + width * height * 3 / 2; //headers + color table + data
-    uint8_t * allocation = (uint8_t *) MSF_GIF_MALLOC(allocContext, maxBufSize);
-    if (!allocation) { return NULL; }
-    uint8_t * writeBase = allocation + sizeof(MsfBufferHeader);
-    uint8_t * writeHead = writeBase;
-    int lzwAllocSize = 4096 * (frame.count + 1) * sizeof(int16_t);
-    MsfStridedList lzw = { (int16_t *) MSF_GIF_MALLOC(allocContext, lzwAllocSize) };
-    if (!lzw.data) { MSF_GIF_FREE(allocContext, allocation, maxBufSize); return NULL; }
-
-    //allocate tlb
-    int totalBits = frame.rbits + frame.gbits + frame.bbits;
-    int tlbSize = 1 << totalBits;
-    uint8_t tlb[1 << 16]; //only 64k, so stack allocating is fine
-
-    //generate palette
-    typedef struct { uint8_t r, g, b; } Color3;
-    Color3 table[256] = { {0} };
-    int tableIdx = 1; //we start counting at 1 because 0 is the transparent color
-    MsfTimeLoop("table") for (int i = 0; i < tlbSize; ++i) {
-        if (used[i]) {
-            tlb[i] = tableIdx;
-            int rmask = (1 << frame.rbits) - 1;
-            int gmask = (1 << frame.gbits) - 1;
-            //isolate components
-            int r = i & rmask;
-            int g = i >> frame.rbits & gmask;
-            int b = i >> (frame.rbits + frame.gbits);
-            //shift into highest bits
-            r <<= 8 - frame.rbits;
-            g <<= 8 - frame.gbits;
-            b <<= 8 - frame.bbits;
-            table[tableIdx].r = r | r >> frame.rbits | r >> (frame.rbits * 2) | r >> (frame.rbits * 3);
-            table[tableIdx].g = g | g >> frame.gbits | g >> (frame.gbits * 2) | g >> (frame.gbits * 3);
-            table[tableIdx].b = b | b >> frame.bbits | b >> (frame.bbits * 2) | b >> (frame.bbits * 3);
-            ++tableIdx;
-        }
-    }
-
-    //SPEC: "Because of some algorithmic constraints however, black & white images which have one color bit
-    //       must be indicated as having a code size of 2."
-    int tableBits = msf_imax(2, msf_bit_log(tableIdx - 1));
-    int tableSize = 1 << tableBits;
-    //NOTE: we don't just compare `depth` field here because it will be wrong for the first frame and we will segfault
-    int hasSamePal = frame.rbits == previous.rbits && frame.gbits == previous.gbits && frame.bbits == previous.bbits;
-
-    //NOTE: because __attribute__((__packed__)) is annoyingly compiler-specific, we do this unreadable weirdness
-    char headerBytes[19] = "\x21\xF9\x04\x05\0\0\0\0" "\x2C\0\0\0\0\0\0\0\0\x80";
-    memcpy(&headerBytes[4], &centiSeconds, 2);
-    memcpy(&headerBytes[13], &width, 2);
-    memcpy(&headerBytes[15], &height, 2);
-    headerBytes[17] |= tableBits - 1;
-    memcpy(writeHead, headerBytes, 18);
-    writeHead += 18;
-
-    //local color table
-    memcpy(writeHead, table, tableSize * sizeof(Color3));
-    writeHead += tableSize * sizeof(Color3);
-    *writeHead++ = tableBits;
-
-    //prep block
-    memset(writeHead, 0, 260);
-    writeHead[0] = 255;
-    uint32_t blockBits = 8; //relative to block.head
-
-    //SPEC: "Encoders should output a Clear code as the first code of each image data stream."
-    msf_lzw_reset(&lzw, tableSize, tableIdx);
-    msf_put_code(&writeHead, &blockBits, msf_bit_log(lzw.len - 1), tableSize);
-
-    int lastCode = hasSamePal && frame.pixels[0] == previous.pixels[0]? 0 : tlb[frame.pixels[0]];
-    MsfTimeLoop("compress") for (int i = 1; i < width * height; ++i) {
-        //PERF: branching vs. branchless version of this line is observed to have no discernable impact on speed
-        int color = hasSamePal && frame.pixels[i] == previous.pixels[i]? 0 : tlb[frame.pixels[i]];
-        //PERF: branchless version must use && otherwise it will segfault on frame 1, but it's well-predicted so OK
-        // int color = (!(hasSamePal && frame.pixels[i] == previous.pixels[i])) * tlb[frame.pixels[i]];
-        int code = (&lzw.data[lastCode * lzw.stride])[color];
-        if (code < 0) {
-            //write to code stream
-            int codeBits = msf_bit_log(lzw.len - 1);
-            msf_put_code(&writeHead, &blockBits, codeBits, lastCode);
-
-            if (lzw.len > 4095) {
-                //reset buffer code table
-                msf_put_code(&writeHead, &blockBits, codeBits, tableSize);
-                msf_lzw_reset(&lzw, tableSize, tableIdx);
-            } else {
-                (&lzw.data[lastCode * lzw.stride])[color] = lzw.len;
-                ++lzw.len;
-            }
-
-            lastCode = color;
-        } else {
-            lastCode = code;
-        }
-    }
-
-    MSF_GIF_FREE(allocContext, lzw.data, lzwAllocSize);
-    MSF_GIF_FREE(allocContext, previous.pixels, width * height * sizeof(uint32_t));
-
-    //write code for leftover index buffer contents, then the end code
-    msf_put_code(&writeHead, &blockBits, msf_imin(12, msf_bit_log(lzw.len - 1)), lastCode);
-    msf_put_code(&writeHead, &blockBits, msf_imin(12, msf_bit_log(lzw.len)), tableSize + 1);
-
-    //flush remaining data
-    if (blockBits > 8) {
-        int bytes = (blockBits + 7) / 8; //round up
-        writeHead[0] = bytes - 1;
-        writeHead += bytes;
-    }
-    *writeHead++ = 0; //terminating block
-
-    //filling in buffer header and shrink buffer to fit data
-    MsfBufferHeader * header = (MsfBufferHeader *) allocation;
-    header->next = NULL;
-    header->size = writeHead - writeBase;
-    uint8_t * moved = (uint8_t *) MSF_GIF_REALLOC(allocContext, allocation, maxBufSize, writeHead - allocation);
-    if (!moved) { MSF_GIF_FREE(allocContext, allocation, maxBufSize); return NULL; }
-    return moved;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-/// Incremental API                                                                                                  ///
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-int msf_gif_begin(MsfGifState * handle, int width, int height) { MsfTimeFunc
-    MsfCookedFrame empty = {0}; //god I hate MSVC...
-    handle->previousFrame = empty;
-    handle->width = width;
-    handle->height = height;
-
-    //setup header buffer header (lol)
-    handle->listHead = (uint8_t *) MSF_GIF_MALLOC(handle->customAllocatorContext, sizeof(MsfBufferHeader) + 32);
-    if (!handle->listHead) { return 0; }
-    handle->listTail = handle->listHead;
-    MsfBufferHeader * header = (MsfBufferHeader *) handle->listHead;
-    header->next = NULL;
-    header->size = 32;
-
-    //NOTE: because __attribute__((__packed__)) is annoyingly compiler-specific, we do this unreadable weirdness
-    char headerBytes[33] = "GIF89a\0\0\0\0\x10\0\0" "\x21\xFF\x0BNETSCAPE2.0\x03\x01\0\0\0";
-    memcpy(&headerBytes[6], &width, 2);
-    memcpy(&headerBytes[8], &height, 2);
-    memcpy(handle->listHead + sizeof(MsfBufferHeader), headerBytes, 32);
-    return 1;
-}
-
-int msf_gif_frame(MsfGifState * handle, uint8_t * pixelData, int centiSecondsPerFame, int maxBitDepth, int pitchInBytes)
-{ MsfTimeFunc
-    if (!handle->listHead) { return 0; }
-
-    maxBitDepth = msf_imax(1, msf_imin(16, maxBitDepth));
-    if (pitchInBytes == 0) pitchInBytes = handle->width * 4;
-    if (pitchInBytes < 0) pixelData -= pitchInBytes * (handle->height - 1);
-
-    uint8_t used[1 << 16]; //only 64k, so stack allocating is fine
-    MsfCookedFrame frame =
-        msf_cook_frame(handle->customAllocatorContext, pixelData, used, handle->width, handle->height, pitchInBytes,
-            msf_imin(maxBitDepth, handle->previousFrame.depth + 160 / msf_imax(1, handle->previousFrame.count)));
-    //TODO: de-duplicate cleanup code
-    if (!frame.pixels) {
-        MSF_GIF_FREE(handle->customAllocatorContext,
-                     handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            node = header->next;
-            MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-        }
-        handle->listHead = handle->listTail = NULL;
-        return 0;
-    }
-
-    uint8_t * buffer = msf_compress_frame(handle->customAllocatorContext,
-        handle->width, handle->height, centiSecondsPerFame, frame, handle->previousFrame, used);
-    ((MsfBufferHeader *) handle->listTail)->next = buffer;
-    handle->listTail = buffer;
-    if (!buffer) {
-        MSF_GIF_FREE(handle->customAllocatorContext, frame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        MSF_GIF_FREE(handle->customAllocatorContext,
-                     handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            node = header->next;
-            MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-        }
-        handle->listHead = handle->listTail = NULL;
-        return 0;
-    }
-
-    handle->previousFrame = frame;
-    return 1;
-}
-
-MsfGifResult msf_gif_end(MsfGifState * handle) { MsfTimeFunc
-    if (!handle->listHead) { MsfGifResult empty = {0}; return empty; }
-
-    MSF_GIF_FREE(handle->customAllocatorContext,
-                 handle->previousFrame.pixels, handle->width * handle->height * sizeof(uint32_t));
-
-    //first pass: determine total size
-    size_t total = 1; //1 byte for trailing marker
-    for (uint8_t * node = handle->listHead; node;) {
-        MsfBufferHeader * header = (MsfBufferHeader *) node;
-        node = header->next;
-        total += header->size;
-    }
-
-    //second pass: write data
-    uint8_t * buffer = (uint8_t *) MSF_GIF_MALLOC(handle->customAllocatorContext, total);
-    if (buffer) {
-        uint8_t * writeHead = buffer;
-        for (uint8_t * node = handle->listHead; node;) {
-            MsfBufferHeader * header = (MsfBufferHeader *) node;
-            memcpy(writeHead, node + sizeof(MsfBufferHeader), header->size);
-            writeHead += header->size;
-            node = header->next;
-        }
-        *writeHead++ = 0x3B;
-    }
-
-    //third pass: free buffers
-    for (uint8_t * node = handle->listHead; node;) {
-        MsfBufferHeader * header = (MsfBufferHeader *) node;
-        node = header->next;
-        MSF_GIF_FREE(handle->customAllocatorContext, header, sizeof(MsfBufferHeader) + header->size);
-    }
-
-    MsfGifResult ret = { buffer, total, total, handle->customAllocatorContext };
-    return ret;
-}
-
-void msf_gif_free(MsfGifResult result) {
-    if (result.data) { MSF_GIF_FREE(result.contextPointer, result.data, result.allocSize); }
-}
-
-#endif //MSF_GIF_ALREADY_IMPLEMENTED_IN_THIS_TRANSLATION_UNIT
-#endif //MSF_GIF_IMPL
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Miles Fogle
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/par_shapes.h b/raylib_pi4_test/external/par_shapes.h
deleted file mode 100644 (file)
index 8b65e38..0000000
+++ /dev/null
@@ -1,2051 +0,0 @@
-// SHAPES :: https://github.com/prideout/par
-// Simple C library for creation and manipulation of triangle meshes.
-//
-// The API is divided into three sections:
-//
-//   - Generators.  Create parametric surfaces, platonic solids, etc.
-//   - Queries.     Ask a mesh for its axis-aligned bounding box, etc.
-//   - Transforms.  Rotate a mesh, merge it with another, add normals, etc.
-//
-// In addition to the comment block above each function declaration, the API
-// has informal documentation here:
-//
-//     https://prideout.net/shapes
-//
-// For our purposes, a "mesh" is a list of points and a list of triangles; the
-// former is a flattened list of three-tuples (32-bit floats) and the latter is
-// also a flattened list of three-tuples (16-bit uints).  Triangles are always
-// oriented such that their front face winds counter-clockwise.
-//
-// Optionally, meshes can contain 3D normals (one per vertex), and 2D texture
-// coordinates (one per vertex).  That's it!  If you need something fancier,
-// look elsewhere.
-//
-// The MIT License
-// Copyright (c) 2015 Philip Rideout
-
-#ifndef PAR_SHAPES_H
-#define PAR_SHAPES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-// Ray: commented to avoid conflict with raylib bool
-/*
-#if !defined(_MSC_VER)
-# include <stdbool.h>
-#else // MSVC
-# if _MSC_VER >= 1800
-#  include <stdbool.h>
-# else // stdbool.h missing prior to MSVC++ 12.0 (VS2013)
-//#  define bool int      
-//#  define true 1
-//#  define false 0
-# endif
-#endif
-*/
-
-#ifndef PAR_SHAPES_T
-#define PAR_SHAPES_T uint16_t
-#endif
-
-typedef struct par_shapes_mesh_s {
-    float* points;           // Flat list of 3-tuples (X Y Z X Y Z...)
-    int npoints;             // Number of points
-    PAR_SHAPES_T* triangles; // Flat list of 3-tuples (I J K I J K...)
-    int ntriangles;          // Number of triangles
-    float* normals;          // Optional list of 3-tuples (X Y Z X Y Z...)
-    float* tcoords;          // Optional list of 2-tuples (U V U V U V...)
-} par_shapes_mesh;
-
-void par_shapes_free_mesh(par_shapes_mesh*);
-
-// Generators ------------------------------------------------------------------
-
-// Instance a cylinder that sits on the Z=0 plane using the given tessellation
-// levels across the UV domain.  Think of "slices" like a number of pizza
-// slices, and "stacks" like a number of stacked rings.  Height and radius are
-// both 1.0, but they can easily be changed with par_shapes_scale.
-par_shapes_mesh* par_shapes_create_cylinder(int slices, int stacks);
-
-// Create a donut that sits on the Z=0 plane with the specified inner radius.
-// The outer radius can be controlled with par_shapes_scale.
-par_shapes_mesh* par_shapes_create_torus(int slices, int stacks, float radius);
-
-// Create a sphere with texture coordinates and small triangles near the poles.
-par_shapes_mesh* par_shapes_create_parametric_sphere(int slices, int stacks);
-
-// Approximate a sphere with a subdivided icosahedron, which produces a nice
-// distribution of triangles, but no texture coordinates.  Each subdivision
-// level scales the number of triangles by four, so use a very low number.
-par_shapes_mesh* par_shapes_create_subdivided_sphere(int nsubdivisions);
-
-// More parametric surfaces.
-par_shapes_mesh* par_shapes_create_klein_bottle(int slices, int stacks);
-par_shapes_mesh* par_shapes_create_trefoil_knot(int slices, int stacks,
-    float radius);
-par_shapes_mesh* par_shapes_create_hemisphere(int slices, int stacks);
-par_shapes_mesh* par_shapes_create_plane(int slices, int stacks);
-
-// Create a parametric surface from a callback function that consumes a 2D
-// point in [0,1] and produces a 3D point.
-typedef void (*par_shapes_fn)(float const*, float*, void*);
-par_shapes_mesh* par_shapes_create_parametric(par_shapes_fn, int slices,
-    int stacks, void* userdata);
-
-// Generate points for a 20-sided polyhedron that fits in the unit sphere.
-// Texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_icosahedron();
-
-// Generate points for a 12-sided polyhedron that fits in the unit sphere.
-// Again, texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_dodecahedron();
-
-// More platonic solids.
-par_shapes_mesh* par_shapes_create_octahedron();
-par_shapes_mesh* par_shapes_create_tetrahedron();
-par_shapes_mesh* par_shapes_create_cube();
-
-// Generate an orientable disk shape in 3-space.  Does not include normals or
-// texture coordinates.
-par_shapes_mesh* par_shapes_create_disk(float radius, int slices,
-    float const* center, float const* normal);
-
-// Create an empty shape.  Useful for building scenes with merge_and_free.
-par_shapes_mesh* par_shapes_create_empty();
-
-// Generate a rock shape that sits on the Y=0 plane, and sinks into it a bit.
-// This includes smooth normals but no texture coordinates.  Each subdivision
-// level scales the number of triangles by four, so use a very low number.
-par_shapes_mesh* par_shapes_create_rock(int seed, int nsubdivisions);
-
-// Create trees or vegetation by executing a recursive turtle graphics program.
-// The program is a list of command-argument pairs.  See the unit test for
-// an example.  Texture coordinates and normals are not generated.
-par_shapes_mesh* par_shapes_create_lsystem(char const* program, int slices,
-    int maxdepth);
-
-// Queries ---------------------------------------------------------------------
-
-// Dump out a text file conforming to the venerable OBJ format.
-void par_shapes_export(par_shapes_mesh const*, char const* objfile);
-
-// Take a pointer to 6 floats and set them to min xyz, max xyz.
-void par_shapes_compute_aabb(par_shapes_mesh const* mesh, float* aabb);
-
-// Make a deep copy of a mesh.  To make a brand new copy, pass null to "target".
-// To avoid memory churn, pass an existing mesh to "target".
-par_shapes_mesh* par_shapes_clone(par_shapes_mesh const* mesh,
-    par_shapes_mesh* target);
-
-// Transformations -------------------------------------------------------------
-
-void par_shapes_merge(par_shapes_mesh* dst, par_shapes_mesh const* src);
-void par_shapes_translate(par_shapes_mesh*, float x, float y, float z);
-void par_shapes_rotate(par_shapes_mesh*, float radians, float const* axis);
-void par_shapes_scale(par_shapes_mesh*, float x, float y, float z);
-void par_shapes_merge_and_free(par_shapes_mesh* dst, par_shapes_mesh* src);
-
-// Reverse the winding of a run of faces.  Useful when drawing the inside of
-// a Cornell Box.  Pass 0 for nfaces to reverse every face in the mesh.
-void par_shapes_invert(par_shapes_mesh*, int startface, int nfaces);
-
-// Remove all triangles whose area is less than minarea.
-void par_shapes_remove_degenerate(par_shapes_mesh*, float minarea);
-
-// Dereference the entire index buffer and replace the point list.
-// This creates an inefficient structure, but is useful for drawing facets.
-// If create_indices is true, a trivial "0 1 2 3..." index buffer is generated.
-void par_shapes_unweld(par_shapes_mesh* mesh, bool create_indices);
-
-// Merge colocated verts, build a new index buffer, and return the
-// optimized mesh.  Epsilon is the maximum distance to consider when
-// welding vertices. The mapping argument can be null, or a pointer to
-// npoints integers, which gets filled with the mapping from old vertex
-// indices to new indices.
-par_shapes_mesh* par_shapes_weld(par_shapes_mesh const*, float epsilon,
-    PAR_SHAPES_T* mapping);
-
-// Compute smooth normals by averaging adjacent facet normals.
-void par_shapes_compute_normals(par_shapes_mesh* m);
-
-#ifndef PAR_PI
-#define PAR_PI (3.14159265359)
-#define PAR_MIN(a, b) (a > b ? b : a)
-#define PAR_MAX(a, b) (a > b ? a : b)
-#define PAR_CLAMP(v, lo, hi) PAR_MAX(lo, PAR_MIN(hi, v))
-#define PAR_SWAP(T, A, B) { T tmp = B; B = A; A = tmp; }
-#define PAR_SQR(a) ((a) * (a))
-#endif
-
-#ifndef PAR_MALLOC
-#define PAR_MALLOC(T, N) ((T*) malloc(N * sizeof(T)))
-#define PAR_CALLOC(T, N) ((T*) calloc(N * sizeof(T), 1))
-#define PAR_REALLOC(T, BUF, N) ((T*) realloc(BUF, sizeof(T) * (N)))
-#define PAR_FREE(BUF) free(BUF)
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-// -----------------------------------------------------------------------------
-// END PUBLIC API
-// -----------------------------------------------------------------------------
-
-#ifdef PAR_SHAPES_IMPLEMENTATION
-#include <stdlib.h>
-#include <stdio.h>
-#include <assert.h>
-#include <float.h>
-#include <string.h>
-#include <math.h>
-#include <errno.h>
-
-static void par_shapes__sphere(float const* uv, float* xyz, void*);
-static void par_shapes__hemisphere(float const* uv, float* xyz, void*);
-static void par_shapes__plane(float const* uv, float* xyz, void*);
-static void par_shapes__klein(float const* uv, float* xyz, void*);
-static void par_shapes__cylinder(float const* uv, float* xyz, void*);
-static void par_shapes__torus(float const* uv, float* xyz, void*);
-static void par_shapes__trefoil(float const* uv, float* xyz, void*);
-
-struct osn_context;
-static int par__simplex_noise(int64_t seed, struct osn_context** ctx);
-static void par__simplex_noise_free(struct osn_context* ctx);
-static double par__simplex_noise2(struct osn_context* ctx, double x, double y);
-
-static void par_shapes__copy3(float* result, float const* a)
-{
-    result[0] = a[0];
-    result[1] = a[1];
-    result[2] = a[2];
-}
-
-static float par_shapes__dot3(float const* a, float const* b)
-{
-    return b[0] * a[0] + b[1] * a[1] + b[2] * a[2];
-}
-
-static void par_shapes__transform3(float* p, float const* x, float const* y,
-    float const* z)
-{
-    float px = par_shapes__dot3(p, x);
-    float py = par_shapes__dot3(p, y);
-    float pz = par_shapes__dot3(p, z);
-    p[0] = px;
-    p[1] = py;
-    p[2] = pz;
-}
-
-static void par_shapes__cross3(float* result, float const* a, float const* b)
-{
-    float x = (a[1] * b[2]) - (a[2] * b[1]);
-    float y = (a[2] * b[0]) - (a[0] * b[2]);
-    float z = (a[0] * b[1]) - (a[1] * b[0]);
-    result[0] = x;
-    result[1] = y;
-    result[2] = z;
-}
-
-static void par_shapes__mix3(float* d, float const* a, float const* b, float t)
-{
-    float x = b[0] * t + a[0] * (1 - t);
-    float y = b[1] * t + a[1] * (1 - t);
-    float z = b[2] * t + a[2] * (1 - t);
-    d[0] = x;
-    d[1] = y;
-    d[2] = z;
-}
-
-static void par_shapes__scale3(float* result, float a)
-{
-    result[0] *= a;
-    result[1] *= a;
-    result[2] *= a;
-}
-
-static void par_shapes__normalize3(float* v)
-{
-    float lsqr = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
-    if (lsqr > 0) {
-        par_shapes__scale3(v, 1.0f / lsqr);
-    }
-}
-
-static void par_shapes__subtract3(float* result, float const* a)
-{
-    result[0] -= a[0];
-    result[1] -= a[1];
-    result[2] -= a[2];
-}
-
-static void par_shapes__add3(float* result, float const* a)
-{
-    result[0] += a[0];
-    result[1] += a[1];
-    result[2] += a[2];
-}
-
-static float par_shapes__sqrdist3(float const* a, float const* b)
-{
-    float dx = a[0] - b[0];
-    float dy = a[1] - b[1];
-    float dz = a[2] - b[2];
-    return dx * dx + dy * dy + dz * dz;
-}
-
-static void par_shapes__compute_welded_normals(par_shapes_mesh* m)
-{
-    m->normals = PAR_MALLOC(float, m->npoints * 3);
-    PAR_SHAPES_T* weldmap = PAR_MALLOC(PAR_SHAPES_T, m->npoints);
-    par_shapes_mesh* welded = par_shapes_weld(m, 0.01, weldmap);
-    par_shapes_compute_normals(welded);
-    float* pdst = m->normals;
-    for (int i = 0; i < m->npoints; i++, pdst += 3) {
-        int d = weldmap[i];
-        float const* pnormal = welded->normals + d * 3;
-        pdst[0] = pnormal[0];
-        pdst[1] = pnormal[1];
-        pdst[2] = pnormal[2];
-    }
-    PAR_FREE(weldmap);
-    par_shapes_free_mesh(welded);
-}
-
-par_shapes_mesh* par_shapes_create_cylinder(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 1) {
-        return 0;
-    }
-    return par_shapes_create_parametric(par_shapes__cylinder, slices,
-        stacks, 0);
-}
-
-par_shapes_mesh* par_shapes_create_parametric_sphere(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* m = par_shapes_create_parametric(par_shapes__sphere,
-        slices, stacks, 0);
-    par_shapes_remove_degenerate(m, 0.0001);
-    return m;
-}
-
-par_shapes_mesh* par_shapes_create_hemisphere(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* m = par_shapes_create_parametric(par_shapes__hemisphere,
-        slices, stacks, 0);
-    par_shapes_remove_degenerate(m, 0.0001);
-    return m;
-}
-
-par_shapes_mesh* par_shapes_create_torus(int slices, int stacks, float radius)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    assert(radius <= 1.0 && "Use smaller radius to avoid self-intersection.");
-    assert(radius >= 0.1 && "Use larger radius to avoid self-intersection.");
-    void* userdata = (void*) &radius;
-    return par_shapes_create_parametric(par_shapes__torus, slices,
-        stacks, userdata);
-}
-
-par_shapes_mesh* par_shapes_create_klein_bottle(int slices, int stacks)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    par_shapes_mesh* mesh = par_shapes_create_parametric(
-        par_shapes__klein, slices, stacks, 0);
-    int face = 0;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++, face += 2) {
-            if (stack < 27 * stacks / 32) {
-                par_shapes_invert(mesh, face, 2);
-            }
-        }
-    }
-    par_shapes__compute_welded_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_trefoil_knot(int slices, int stacks,
-    float radius)
-{
-    if (slices < 3 || stacks < 3) {
-        return 0;
-    }
-    assert(radius <= 3.0 && "Use smaller radius to avoid self-intersection.");
-    assert(radius >= 0.5 && "Use larger radius to avoid self-intersection.");
-    void* userdata = (void*) &radius;
-    return par_shapes_create_parametric(par_shapes__trefoil, slices,
-        stacks, userdata);
-}
-
-par_shapes_mesh* par_shapes_create_plane(int slices, int stacks)
-{
-    if (slices < 1 || stacks < 1) {
-        return 0;
-    }
-    return par_shapes_create_parametric(par_shapes__plane, slices,
-        stacks, 0);
-}
-
-par_shapes_mesh* par_shapes_create_parametric(par_shapes_fn fn,
-    int slices, int stacks, void* userdata)
-{
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-
-    // Generate verts.
-    mesh->npoints = (slices + 1) * (stacks + 1);
-    mesh->points = PAR_CALLOC(float, 3 * mesh->npoints);
-    float uv[2];
-    float xyz[3];
-    float* points = mesh->points;
-    for (int stack = 0; stack < stacks + 1; stack++) {
-        uv[0] = (float) stack / stacks;
-        for (int slice = 0; slice < slices + 1; slice++) {
-            uv[1] = (float) slice / slices;
-            fn(uv, xyz, userdata);
-            *points++ = xyz[0];
-            *points++ = xyz[1];
-            *points++ = xyz[2];
-        }
-    }
-
-    // Generate texture coordinates.
-    mesh->tcoords = PAR_CALLOC(float, 2 * mesh->npoints);
-    float* uvs = mesh->tcoords;
-    for (int stack = 0; stack < stacks + 1; stack++) {
-        uv[0] = (float) stack / stacks;
-        for (int slice = 0; slice < slices + 1; slice++) {
-            uv[1] = (float) slice / slices;
-            *uvs++ = uv[0];
-            *uvs++ = uv[1];
-        }
-    }
-
-    // Generate faces.
-    mesh->ntriangles = 2 * slices * stacks;
-    mesh->triangles = PAR_CALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    int v = 0;
-    PAR_SHAPES_T* face = mesh->triangles;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++) {
-            int next = slice + 1;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next;
-            *face++ = v + slice;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next + slices + 1;
-            *face++ = v + next;
-        }
-        v += slices + 1;
-    }
-
-    par_shapes__compute_welded_normals(mesh);
-    return mesh;
-}
-
-void par_shapes_free_mesh(par_shapes_mesh* mesh)
-{
-    PAR_FREE(mesh->points);
-    PAR_FREE(mesh->triangles);
-    PAR_FREE(mesh->normals);
-    PAR_FREE(mesh->tcoords);
-    PAR_FREE(mesh);
-}
-
-void par_shapes_export(par_shapes_mesh const* mesh, char const* filename)
-{
-    FILE* objfile = fopen(filename, "wt");
-    float const* points = mesh->points;
-    float const* tcoords = mesh->tcoords;
-    float const* norms = mesh->normals;
-    PAR_SHAPES_T const* indices = mesh->triangles;
-    if (tcoords && norms) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vt %f %f\n", tcoords[0], tcoords[1]);
-            fprintf(objfile, "vn %f %f %f\n", norms[0], norms[1], norms[2]);
-            points += 3;
-            norms += 3;
-            tcoords += 2;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d/%d/%d %d/%d/%d %d/%d/%d\n",
-                a, a, a, b, b, b, c, c, c);
-        }
-    } else if (norms) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vn %f %f %f\n", norms[0], norms[1], norms[2]);
-            points += 3;
-            norms += 3;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d//%d %d//%d %d//%d\n", a, a, b, b, c, c);
-        }
-    } else if (tcoords) {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            fprintf(objfile, "vt %f %f\n", tcoords[0], tcoords[1]);
-            points += 3;
-            tcoords += 2;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d/%d %d/%d %d/%d\n", a, a, b, b, c, c);
-        }
-    } else {
-        for (int nvert = 0; nvert < mesh->npoints; nvert++) {
-            fprintf(objfile, "v %f %f %f\n", points[0], points[1], points[2]);
-            points += 3;
-        }
-        for (int nface = 0; nface < mesh->ntriangles; nface++) {
-            int a = 1 + *indices++;
-            int b = 1 + *indices++;
-            int c = 1 + *indices++;
-            fprintf(objfile, "f %d %d %d\n", a, b, c);
-        }
-    }
-    fclose(objfile);
-}
-
-static void par_shapes__sphere(float const* uv, float* xyz, void* userdata)
-{
-    float phi = uv[0] * PAR_PI;
-    float theta = uv[1] * 2 * PAR_PI;
-    xyz[0] = cosf(theta) * sinf(phi);
-    xyz[1] = sinf(theta) * sinf(phi);
-    xyz[2] = cosf(phi);
-}
-
-static void par_shapes__hemisphere(float const* uv, float* xyz, void* userdata)
-{
-    float phi = uv[0] * PAR_PI;
-    float theta = uv[1] * PAR_PI;
-    xyz[0] = cosf(theta) * sinf(phi);
-    xyz[1] = sinf(theta) * sinf(phi);
-    xyz[2] = cosf(phi);
-}
-
-static void par_shapes__plane(float const* uv, float* xyz, void* userdata)
-{
-    xyz[0] = uv[0];
-    xyz[1] = uv[1];
-    xyz[2] = 0;
-}
-
-static void par_shapes__klein(float const* uv, float* xyz, void* userdata)
-{
-    float u = uv[0] * PAR_PI;
-    float v = uv[1] * 2 * PAR_PI;
-    u = u * 2;
-    if (u < PAR_PI) {
-        xyz[0] = 3 * cosf(u) * (1 + sinf(u)) + (2 * (1 - cosf(u) / 2)) *
-            cosf(u) * cosf(v);
-        xyz[2] = -8 * sinf(u) - 2 * (1 - cosf(u) / 2) * sinf(u) * cosf(v);
-    } else {
-        xyz[0] = 3 * cosf(u) * (1 + sinf(u)) + (2 * (1 - cosf(u) / 2)) *
-            cosf(v + PAR_PI);
-        xyz[2] = -8 * sinf(u);
-    }
-    xyz[1] = -2 * (1 - cosf(u) / 2) * sinf(v);
-}
-
-static void par_shapes__cylinder(float const* uv, float* xyz, void* userdata)
-{
-    float theta = uv[1] * 2 * PAR_PI;
-    xyz[0] = sinf(theta);
-    xyz[1] = cosf(theta);
-    xyz[2] = uv[0];
-}
-
-static void par_shapes__torus(float const* uv, float* xyz, void* userdata)
-{
-    float major = 1;
-    float minor = *((float*) userdata);
-    float theta = uv[0] * 2 * PAR_PI;
-    float phi = uv[1] * 2 * PAR_PI;
-    float beta = major + minor * cosf(phi);
-    xyz[0] = cosf(theta) * beta;
-    xyz[1] = sinf(theta) * beta;
-    xyz[2] = sinf(phi) * minor;
-}
-
-static void par_shapes__trefoil(float const* uv, float* xyz, void* userdata)
-{
-    float minor = *((float*) userdata);
-    const float a = 0.5f;
-    const float b = 0.3f;
-    const float c = 0.5f;
-    const float d = minor * 0.1f;
-    const float u = (1 - uv[0]) * 4 * PAR_PI;
-    const float v = uv[1] * 2 * PAR_PI;
-    const float r = a + b * cos(1.5f * u);
-    const float x = r * cos(u);
-    const float y = r * sin(u);
-    const float z = c * sin(1.5f * u);
-    float q[3];
-    q[0] =
-        -1.5f * b * sin(1.5f * u) * cos(u) - (a + b * cos(1.5f * u)) * sin(u);
-    q[1] =
-        -1.5f * b * sin(1.5f * u) * sin(u) + (a + b * cos(1.5f * u)) * cos(u);
-    q[2] = 1.5f * c * cos(1.5f * u);
-    par_shapes__normalize3(q);
-    float qvn[3] = {q[1], -q[0], 0};
-    par_shapes__normalize3(qvn);
-    float ww[3];
-    par_shapes__cross3(ww, q, qvn);
-    xyz[0] = x + d * (qvn[0] * cos(v) + ww[0] * sin(v));
-    xyz[1] = y + d * (qvn[1] * cos(v) + ww[1] * sin(v));
-    xyz[2] = z + d * ww[2] * sin(v);
-}
-
-void par_shapes_merge(par_shapes_mesh* dst, par_shapes_mesh const* src)
-{
-    PAR_SHAPES_T offset = dst->npoints;
-    int npoints = dst->npoints + src->npoints;
-    int vecsize = sizeof(float) * 3;
-    dst->points = PAR_REALLOC(float, dst->points, 3 * npoints);
-    memcpy(dst->points + 3 * dst->npoints, src->points, vecsize * src->npoints);
-    dst->npoints = npoints;
-    if (src->normals || dst->normals) {
-        dst->normals = PAR_REALLOC(float, dst->normals, 3 * npoints);
-        if (src->normals) {
-            memcpy(dst->normals + 3 * offset, src->normals,
-                vecsize * src->npoints);
-        }
-    }
-    if (src->tcoords || dst->tcoords) {
-        int uvsize = sizeof(float) * 2;
-        dst->tcoords = PAR_REALLOC(float, dst->tcoords, 2 * npoints);
-        if (src->tcoords) {
-            memcpy(dst->tcoords + 2 * offset, src->tcoords,
-                uvsize * src->npoints);
-        }
-    }
-    int ntriangles = dst->ntriangles + src->ntriangles;
-    dst->triangles = PAR_REALLOC(PAR_SHAPES_T, dst->triangles, 3 * ntriangles);
-    PAR_SHAPES_T* ptriangles = dst->triangles + 3 * dst->ntriangles;
-    PAR_SHAPES_T const* striangles = src->triangles;
-    for (int i = 0; i < src->ntriangles; i++) {
-        *ptriangles++ = offset + *striangles++;
-        *ptriangles++ = offset + *striangles++;
-        *ptriangles++ = offset + *striangles++;
-    }
-    dst->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_disk(float radius, int slices,
-    float const* center, float const* normal)
-{
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    mesh->npoints = slices + 1;
-    mesh->points = PAR_MALLOC(float, 3 * mesh->npoints);
-    float* points = mesh->points;
-    *points++ = 0;
-    *points++ = 0;
-    *points++ = 0;
-    for (int i = 0; i < slices; i++) {
-        float theta = i * PAR_PI * 2 / slices;
-        *points++ = radius * cos(theta);
-        *points++ = radius * sin(theta);
-        *points++ = 0;
-    }
-    float nnormal[3] = {normal[0], normal[1], normal[2]};
-    par_shapes__normalize3(nnormal);
-    mesh->normals = PAR_MALLOC(float, 3 * mesh->npoints);
-    float* norms = mesh->normals;
-    for (int i = 0; i < mesh->npoints; i++) {
-        *norms++ = nnormal[0];
-        *norms++ = nnormal[1];
-        *norms++ = nnormal[2];
-    }
-    mesh->ntriangles = slices;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    PAR_SHAPES_T* triangles = mesh->triangles;
-    for (int i = 0; i < slices; i++) {
-        *triangles++ = 0;
-        *triangles++ = 1 + i;
-        *triangles++ = 1 + (i + 1) % slices;
-    }
-    float k[3] = {0, 0, -1};
-    float axis[3];
-    par_shapes__cross3(axis, nnormal, k);
-    par_shapes__normalize3(axis);
-    par_shapes_rotate(mesh, acos(nnormal[2]), axis);
-    par_shapes_translate(mesh, center[0], center[1], center[2]);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_empty()
-{
-    return PAR_CALLOC(par_shapes_mesh, 1);
-}
-
-void par_shapes_translate(par_shapes_mesh* m, float x, float y, float z)
-{
-    float* points = m->points;
-    for (int i = 0; i < m->npoints; i++) {
-        *points++ += x;
-        *points++ += y;
-        *points++ += z;
-    }
-}
-
-void par_shapes_rotate(par_shapes_mesh* mesh, float radians, float const* axis)
-{
-    float s = sinf(radians);
-    float c = cosf(radians);
-    float x = axis[0];
-    float y = axis[1];
-    float z = axis[2];
-    float xy = x * y;
-    float yz = y * z;
-    float zx = z * x;
-    float oneMinusC = 1.0f - c;
-    float col0[3] = {
-        (((x * x) * oneMinusC) + c),
-        ((xy * oneMinusC) + (z * s)), ((zx * oneMinusC) - (y * s))
-    };
-    float col1[3] = {
-        ((xy * oneMinusC) - (z * s)),
-        (((y * y) * oneMinusC) + c), ((yz * oneMinusC) + (x * s))
-    };
-    float col2[3] = {
-        ((zx * oneMinusC) + (y * s)),
-        ((yz * oneMinusC) - (x * s)), (((z * z) * oneMinusC) + c)
-    };
-    float* p = mesh->points;
-    for (int i = 0; i < mesh->npoints; i++, p += 3) {
-        float x = col0[0] * p[0] + col1[0] * p[1] + col2[0] * p[2];
-        float y = col0[1] * p[0] + col1[1] * p[1] + col2[1] * p[2];
-        float z = col0[2] * p[0] + col1[2] * p[1] + col2[2] * p[2];
-        p[0] = x;
-        p[1] = y;
-        p[2] = z;
-    }
-    p = mesh->normals;
-    if (p) {
-        for (int i = 0; i < mesh->npoints; i++, p += 3) {
-            float x = col0[0] * p[0] + col1[0] * p[1] + col2[0] * p[2];
-            float y = col0[1] * p[0] + col1[1] * p[1] + col2[1] * p[2];
-            float z = col0[2] * p[0] + col1[2] * p[1] + col2[2] * p[2];
-            p[0] = x;
-            p[1] = y;
-            p[2] = z;
-        }
-    }
-}
-
-void par_shapes_scale(par_shapes_mesh* m, float x, float y, float z)
-{
-    float* points = m->points;
-    for (int i = 0; i < m->npoints; i++) {
-        *points++ *= x;
-        *points++ *= y;
-        *points++ *= z;
-    }
-}
-
-void par_shapes_merge_and_free(par_shapes_mesh* dst, par_shapes_mesh* src)
-{
-    par_shapes_merge(dst, src);
-    par_shapes_free_mesh(src);
-}
-
-void par_shapes_compute_aabb(par_shapes_mesh const* m, float* aabb)
-{
-    float* points = m->points;
-    aabb[0] = aabb[3] = points[0];
-    aabb[1] = aabb[4] = points[1];
-    aabb[2] = aabb[5] = points[2];
-    points += 3;
-    for (int i = 1; i < m->npoints; i++, points += 3) {
-        aabb[0] = PAR_MIN(points[0], aabb[0]);
-        aabb[1] = PAR_MIN(points[1], aabb[1]);
-        aabb[2] = PAR_MIN(points[2], aabb[2]);
-        aabb[3] = PAR_MAX(points[0], aabb[3]);
-        aabb[4] = PAR_MAX(points[1], aabb[4]);
-        aabb[5] = PAR_MAX(points[2], aabb[5]);
-    }
-}
-
-void par_shapes_invert(par_shapes_mesh* m, int face, int nfaces)
-{
-    nfaces = nfaces ? nfaces : m->ntriangles;
-    PAR_SHAPES_T* tri = m->triangles + face * 3;
-    for (int i = 0; i < nfaces; i++) {
-        PAR_SWAP(PAR_SHAPES_T, tri[0], tri[2]);
-        tri += 3;
-    }
-}
-
-par_shapes_mesh* par_shapes_create_icosahedron()
-{
-    static float verts[] = {
-        0.000,  0.000,  1.000,
-        0.894,  0.000,  0.447,
-        0.276,  0.851,  0.447,
-        -0.724,  0.526,  0.447,
-        -0.724, -0.526,  0.447,
-        0.276, -0.851,  0.447,
-        0.724,  0.526, -0.447,
-        -0.276,  0.851, -0.447,
-        -0.894,  0.000, -0.447,
-        -0.276, -0.851, -0.447,
-        0.724, -0.526, -0.447,
-        0.000,  0.000, -1.000
-    };
-    static PAR_SHAPES_T faces[] = {
-        0,1,2,
-        0,2,3,
-        0,3,4,
-        0,4,5,
-        0,5,1,
-        7,6,11,
-        8,7,11,
-        9,8,11,
-        10,9,11,
-        6,10,11,
-        6,2,1,
-        7,3,2,
-        8,4,3,
-        9,5,4,
-        10,1,5,
-        6,7,2,
-        7,8,3,
-        8,9,4,
-        9,10,5,
-        10,6,1
-    };
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    mesh->npoints = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->points = PAR_MALLOC(float, sizeof(verts) / 4);
-    memcpy(mesh->points, verts, sizeof(verts));
-    mesh->ntriangles = sizeof(faces) / sizeof(faces[0]) / 3;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, sizeof(faces) / 2);
-    memcpy(mesh->triangles, faces, sizeof(faces));
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_dodecahedron()
-{
-    static float verts[20 * 3] = {
-        0.607, 0.000, 0.795,
-        0.188, 0.577, 0.795,
-        -0.491, 0.357, 0.795,
-        -0.491, -0.357, 0.795,
-        0.188, -0.577, 0.795,
-        0.982, 0.000, 0.188,
-        0.304, 0.934, 0.188,
-        -0.795, 0.577, 0.188,
-        -0.795, -0.577, 0.188,
-        0.304, -0.934, 0.188,
-        0.795, 0.577, -0.188,
-        -0.304, 0.934, -0.188,
-        -0.982, 0.000, -0.188,
-        -0.304, -0.934, -0.188,
-        0.795, -0.577, -0.188,
-        0.491, 0.357, -0.795,
-        -0.188, 0.577, -0.795,
-        -0.607, 0.000, -0.795,
-        -0.188, -0.577, -0.795,
-        0.491, -0.357, -0.795,
-    };
-    static PAR_SHAPES_T pentagons[12 * 5] = {
-        0,1,2,3,4,
-        5,10,6,1,0,
-        6,11,7,2,1,
-        7,12,8,3,2,
-        8,13,9,4,3,
-        9,14,5,0,4,
-        15,16,11,6,10,
-        16,17,12,7,11,
-        17,18,13,8,12,
-        18,19,14,9,13,
-        19,15,10,5,14,
-        19,18,17,16,15
-    };
-    int npentagons = sizeof(pentagons) / sizeof(pentagons[0]) / 5;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* pentagon = pentagons;
-    mesh->ntriangles = npentagons * 3;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < npentagons; p++, pentagon += 5) {
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[1];
-        *tris++ = pentagon[2];
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[2];
-        *tris++ = pentagon[3];
-        *tris++ = pentagon[0];
-        *tris++ = pentagon[3];
-        *tris++ = pentagon[4];
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_octahedron()
-{
-    static float verts[6 * 3] = {
-        0.000, 0.000, 1.000,
-        1.000, 0.000, 0.000,
-        0.000, 1.000, 0.000,
-        -1.000, 0.000, 0.000,
-        0.000, -1.000, 0.000,
-        0.000, 0.000, -1.000
-    };
-    static PAR_SHAPES_T triangles[8 * 3] = {
-        0,1,2,
-        0,2,3,
-        0,3,4,
-        0,4,1,
-        2,1,5,
-        3,2,5,
-        4,3,5,
-        1,4,5,
-    };
-    int ntris = sizeof(triangles) / sizeof(triangles[0]) / 3;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* triangle = triangles;
-    mesh->ntriangles = ntris;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < ntris; p++) {
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_tetrahedron()
-{
-    static float verts[4 * 3] = {
-        0.000, 1.333, 0,
-        0.943, 0, 0,
-        -0.471, 0, 0.816,
-        -0.471, 0, -0.816,
-    };
-    static PAR_SHAPES_T triangles[4 * 3] = {
-        2,1,0,
-        3,2,0,
-        1,3,0,
-        1,2,3,
-    };
-    int ntris = sizeof(triangles) / sizeof(triangles[0]) / 3;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* triangle = triangles;
-    mesh->ntriangles = ntris;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < ntris; p++) {
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-        *tris++ = *triangle++;
-    }
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_cube()
-{
-    static float verts[8 * 3] = {
-        0, 0, 0, // 0
-        0, 1, 0, // 1
-        1, 1, 0, // 2
-        1, 0, 0, // 3
-        0, 0, 1, // 4
-        0, 1, 1, // 5
-        1, 1, 1, // 6
-        1, 0, 1, // 7
-    };
-    static PAR_SHAPES_T quads[6 * 4] = {
-        7,6,5,4, // front
-        0,1,2,3, // back
-        6,7,3,2, // right
-        5,6,2,1, // top
-        4,5,1,0, // left
-        7,4,0,3, // bottom
-    };
-    int nquads = sizeof(quads) / sizeof(quads[0]) / 4;
-    par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
-    int ncorners = sizeof(verts) / sizeof(verts[0]) / 3;
-    mesh->npoints = ncorners;
-    mesh->points = PAR_MALLOC(float, mesh->npoints * 3);
-    memcpy(mesh->points, verts, sizeof(verts));
-    PAR_SHAPES_T const* quad = quads;
-    mesh->ntriangles = nquads * 2;
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* tris = mesh->triangles;
-    for (int p = 0; p < nquads; p++, quad += 4) {
-        *tris++ = quad[0];
-        *tris++ = quad[1];
-        *tris++ = quad[2];
-        *tris++ = quad[2];
-        *tris++ = quad[3];
-        *tris++ = quad[0];
-    }
-    return mesh;
-}
-
-typedef struct {
-    char* cmd;
-    char* arg;
-} par_shapes__command;
-
-typedef struct {
-    char const* name;
-    int weight;
-    int ncommands;
-    par_shapes__command* commands;
-} par_shapes__rule;
-
-typedef struct {
-    int pc;
-    float position[3];
-    float scale[3];
-    par_shapes_mesh* orientation;
-    par_shapes__rule* rule;
-} par_shapes__stackframe;
-
-static par_shapes__rule* par_shapes__pick_rule(const char* name,
-    par_shapes__rule* rules, int nrules)
-{
-    par_shapes__rule* rule = 0;
-    int total = 0;
-    for (int i = 0; i < nrules; i++) {
-        rule = rules + i;
-        if (!strcmp(rule->name, name)) {
-            total += rule->weight;
-        }
-    }
-    float r = (float) rand() / RAND_MAX;
-    float t = 0;
-    for (int i = 0; i < nrules; i++) {
-        rule = rules + i;
-        if (!strcmp(rule->name, name)) {
-            t += (float) rule->weight / total;
-            if (t >= r) {
-                return rule;
-            }
-        }
-    }
-    return rule;
-}
-
-static par_shapes_mesh* par_shapes__create_turtle()
-{
-    const float xaxis[] = {1, 0, 0};
-    const float yaxis[] = {0, 1, 0};
-    const float zaxis[] = {0, 0, 1};
-    par_shapes_mesh* turtle = PAR_CALLOC(par_shapes_mesh, 1);
-    turtle->npoints = 3;
-    turtle->points = PAR_CALLOC(float, turtle->npoints * 3);
-    par_shapes__copy3(turtle->points + 0, xaxis);
-    par_shapes__copy3(turtle->points + 3, yaxis);
-    par_shapes__copy3(turtle->points + 6, zaxis);
-    return turtle;
-}
-
-static par_shapes_mesh* par_shapes__apply_turtle(par_shapes_mesh* mesh,
-    par_shapes_mesh* turtle, float const* pos, float const* scale)
-{
-    par_shapes_mesh* m = par_shapes_clone(mesh, 0);
-    for (int p = 0; p < m->npoints; p++) {
-        float* pt = m->points + p * 3;
-        pt[0] *= scale[0];
-        pt[1] *= scale[1];
-        pt[2] *= scale[2];
-        par_shapes__transform3(pt,
-            turtle->points + 0, turtle->points + 3, turtle->points + 6);
-        pt[0] += pos[0];
-        pt[1] += pos[1];
-        pt[2] += pos[2];
-    }
-    return m;
-}
-
-static void par_shapes__connect(par_shapes_mesh* scene,
-    par_shapes_mesh* cylinder, int slices)
-{
-    int stacks = 1;
-    int npoints = (slices + 1) * (stacks + 1);
-    assert(scene->npoints >= npoints && "Cannot connect to empty scene.");
-
-    // Create the new point list.
-    npoints = scene->npoints + (slices + 1);
-    float* points = PAR_MALLOC(float, npoints * 3);
-    memcpy(points, scene->points, sizeof(float) * scene->npoints * 3);
-    float* newpts = points + scene->npoints * 3;
-    memcpy(newpts, cylinder->points + (slices + 1) * 3,
-        sizeof(float) * (slices + 1) * 3);
-    PAR_FREE(scene->points);
-    scene->points = points;
-
-    // Create the new triangle list.
-    int ntriangles = scene->ntriangles + 2 * slices * stacks;
-    PAR_SHAPES_T* triangles = PAR_MALLOC(PAR_SHAPES_T, ntriangles * 3);
-    memcpy(triangles, scene->triangles, 2 * scene->ntriangles * 3);
-    int v = scene->npoints - (slices + 1);
-    PAR_SHAPES_T* face = triangles + scene->ntriangles * 3;
-    for (int stack = 0; stack < stacks; stack++) {
-        for (int slice = 0; slice < slices; slice++) {
-            int next = slice + 1;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next;
-            *face++ = v + slice;
-            *face++ = v + slice + slices + 1;
-            *face++ = v + next + slices + 1;
-            *face++ = v + next;
-        }
-        v += slices + 1;
-    }
-    PAR_FREE(scene->triangles);
-    scene->triangles = triangles;
-
-    scene->npoints = npoints;
-    scene->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_lsystem(char const* text, int slices,
-    int maxdepth)
-{
-    char* program;
-    program = PAR_MALLOC(char, strlen(text) + 1);
-
-    // The first pass counts the number of rules and commands.
-    strcpy(program, text);
-    char *cmd = strtok(program, " ");
-    int nrules = 1;
-    int ncommands = 0;
-    while (cmd) {
-        char *arg = strtok(0, " ");
-        if (!arg) {
-            //puts("lsystem error: unexpected end of program.");
-            break;
-        }
-        if (!strcmp(cmd, "rule")) {
-            nrules++;
-        } else {
-            ncommands++;
-        }
-        cmd = strtok(0, " ");
-    }
-
-    // Allocate space.
-    par_shapes__rule* rules = PAR_MALLOC(par_shapes__rule, nrules);
-    par_shapes__command* commands = PAR_MALLOC(par_shapes__command, ncommands);
-
-    // Initialize the entry rule.
-    par_shapes__rule* current_rule = &rules[0];
-    par_shapes__command* current_command = &commands[0];
-    current_rule->name = "entry";
-    current_rule->weight = 1;
-    current_rule->ncommands = 0;
-    current_rule->commands = current_command;
-
-    // The second pass fills in the structures.
-    strcpy(program, text);
-    cmd = strtok(program, " ");
-    while (cmd) {
-        char *arg = strtok(0, " ");
-        if (!strcmp(cmd, "rule")) {
-            current_rule++;
-
-            // Split the argument into a rule name and weight.
-            char* dot = strchr(arg, '.');
-            if (dot) {
-                current_rule->weight = atoi(dot + 1);
-                *dot = 0;
-            } else {
-                current_rule->weight = 1;
-            }
-
-            current_rule->name = arg;
-            current_rule->ncommands = 0;
-            current_rule->commands = current_command;
-        } else {
-            current_rule->ncommands++;
-            current_command->cmd = cmd;
-            current_command->arg = arg;
-            current_command++;
-        }
-        cmd = strtok(0, " ");
-    }
-
-    // For testing purposes, dump out the parsed program.
-    #ifdef TEST_PARSE
-    /*
-    for (int i = 0; i < nrules; i++) {
-        par_shapes__rule rule = rules[i];
-        printf("rule %s.%d\n", rule.name, rule.weight);
-        for (int c = 0; c < rule.ncommands; c++) {
-            par_shapes__command cmd = rule.commands[c];
-            printf("\t%s %s\n", cmd.cmd, cmd.arg);
-        }
-    }
-    */
-    #endif
-
-    // Instantiate the aggregated shape and the template shapes.
-    par_shapes_mesh* scene = PAR_CALLOC(par_shapes_mesh, 1);
-    par_shapes_mesh* tube = par_shapes_create_cylinder(slices, 1);
-    par_shapes_mesh* turtle = par_shapes__create_turtle();
-
-    // We're not attempting to support texture coordinates and normals
-    // with L-systems, so remove them from the template shape.
-    PAR_FREE(tube->normals);
-    PAR_FREE(tube->tcoords);
-    tube->normals = 0;
-    tube->tcoords = 0;
-
-    const float xaxis[] = {1, 0, 0};
-    const float yaxis[] = {0, 1, 0};
-    const float zaxis[] = {0, 0, 1};
-    const float units[] = {1, 1, 1};
-
-    // Execute the L-system program until the stack size is 0.
-    par_shapes__stackframe* stack =
-        PAR_CALLOC(par_shapes__stackframe, maxdepth);
-    int stackptr = 0;
-    stack[0].orientation = turtle;
-    stack[0].rule = &rules[0];
-    par_shapes__copy3(stack[0].scale, units);
-    while (stackptr >= 0) {
-        par_shapes__stackframe* frame = &stack[stackptr];
-        par_shapes__rule* rule = frame->rule;
-        par_shapes_mesh* turtle = frame->orientation;
-        float* position = frame->position;
-        float* scale = frame->scale;
-        if (frame->pc >= rule->ncommands) {
-            par_shapes_free_mesh(turtle);
-            stackptr--;
-            continue;
-        }
-
-        par_shapes__command* cmd = rule->commands + (frame->pc++);
-        #ifdef DUMP_TRACE
-        //printf("%5s %5s %5s:%d  %03d\n", cmd->cmd, cmd->arg, rule->name, frame->pc - 1, stackptr);
-        #endif
-
-        float value;
-        if (!strcmp(cmd->cmd, "shape")) {
-            par_shapes_mesh* m = par_shapes__apply_turtle(tube, turtle,
-                position, scale);
-            if (!strcmp(cmd->arg, "connect")) {
-                par_shapes__connect(scene, m, slices);
-            } else {
-                par_shapes_merge(scene, m);
-            }
-            par_shapes_free_mesh(m);
-        } else if (!strcmp(cmd->cmd, "call") && stackptr < maxdepth - 1) {
-            rule = par_shapes__pick_rule(cmd->arg, rules, nrules);
-            frame = &stack[++stackptr];
-            frame->rule = rule;
-            frame->orientation = par_shapes_clone(turtle, 0);
-            frame->pc = 0;
-            par_shapes__copy3(frame->scale, scale);
-            par_shapes__copy3(frame->position, position);
-            continue;
-        } else {
-            value = atof(cmd->arg);
-            if (!strcmp(cmd->cmd, "rx")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, xaxis);
-            } else if (!strcmp(cmd->cmd, "ry")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, yaxis);
-            } else if (!strcmp(cmd->cmd, "rz")) {
-                par_shapes_rotate(turtle, value * PAR_PI / 180.0, zaxis);
-            } else if (!strcmp(cmd->cmd, "tx")) {
-                float vec[3] = {value, 0, 0};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "ty")) {
-                float vec[3] = {0, value, 0};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "tz")) {
-                float vec[3] = {0, 0, value};
-                float t[3] = {
-                    par_shapes__dot3(turtle->points + 0, vec),
-                    par_shapes__dot3(turtle->points + 3, vec),
-                    par_shapes__dot3(turtle->points + 6, vec)
-                };
-                par_shapes__add3(position, t);
-            } else if (!strcmp(cmd->cmd, "sx")) {
-                scale[0] *= value;
-            } else if (!strcmp(cmd->cmd, "sy")) {
-                scale[1] *= value;
-            } else if (!strcmp(cmd->cmd, "sz")) {
-                scale[2] *= value;
-            } else if (!strcmp(cmd->cmd, "sa")) {
-                scale[0] *= value;
-                scale[1] *= value;
-                scale[2] *= value;
-            }
-        }
-    }
-    PAR_FREE(stack);
-    PAR_FREE(program);
-    PAR_FREE(rules);
-    PAR_FREE(commands);
-    return scene;
-}
-
-void par_shapes_unweld(par_shapes_mesh* mesh, bool create_indices)
-{
-    int npoints = mesh->ntriangles * 3;
-    float* points = PAR_MALLOC(float, 3 * npoints);
-    float* dst = points;
-    PAR_SHAPES_T const* index = mesh->triangles;
-    for (int i = 0; i < npoints; i++) {
-        float const* src = mesh->points + 3 * (*index++);
-        *dst++ = src[0];
-        *dst++ = src[1];
-        *dst++ = src[2];
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = points;
-    mesh->npoints = npoints;
-    if (create_indices) {
-        PAR_SHAPES_T* tris = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-        PAR_SHAPES_T* index = tris;
-        for (int i = 0; i < mesh->ntriangles * 3; i++) {
-            *index++ = i;
-        }
-        PAR_FREE(mesh->triangles);
-        mesh->triangles = tris;
-    }
-}
-
-void par_shapes_compute_normals(par_shapes_mesh* m)
-{
-    PAR_FREE(m->normals);
-    m->normals = PAR_CALLOC(float, m->npoints * 3);
-    PAR_SHAPES_T const* triangle = m->triangles;
-    float next[3], prev[3], cp[3];
-    for (int f = 0; f < m->ntriangles; f++, triangle += 3) {
-        float const* pa = m->points + 3 * triangle[0];
-        float const* pb = m->points + 3 * triangle[1];
-        float const* pc = m->points + 3 * triangle[2];
-        par_shapes__copy3(next, pb);
-        par_shapes__subtract3(next, pa);
-        par_shapes__copy3(prev, pc);
-        par_shapes__subtract3(prev, pa);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[0], cp);
-        par_shapes__copy3(next, pc);
-        par_shapes__subtract3(next, pb);
-        par_shapes__copy3(prev, pa);
-        par_shapes__subtract3(prev, pb);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[1], cp);
-        par_shapes__copy3(next, pa);
-        par_shapes__subtract3(next, pc);
-        par_shapes__copy3(prev, pb);
-        par_shapes__subtract3(prev, pc);
-        par_shapes__cross3(cp, next, prev);
-        par_shapes__add3(m->normals + 3 * triangle[2], cp);
-    }
-    float* normal = m->normals;
-    for (int p = 0; p < m->npoints; p++, normal += 3) {
-        par_shapes__normalize3(normal);
-    }
-}
-
-static void par_shapes__subdivide(par_shapes_mesh* mesh)
-{
-    assert(mesh->npoints == mesh->ntriangles * 3 && "Must be unwelded.");
-    int ntriangles = mesh->ntriangles * 4;
-    int npoints = ntriangles * 3;
-    float* points = PAR_CALLOC(float, npoints * 3);
-    float* dpoint = points;
-    float const* spoint = mesh->points;
-    for (int t = 0; t < mesh->ntriangles; t++, spoint += 9, dpoint += 3) {
-        float const* a = spoint;
-        float const* b = spoint + 3;
-        float const* c = spoint + 6;
-        float const* p0 = dpoint;
-        float const* p1 = dpoint + 3;
-        float const* p2 = dpoint + 6;
-        par_shapes__mix3(dpoint, a, b, 0.5);
-        par_shapes__mix3(dpoint += 3, b, c, 0.5);
-        par_shapes__mix3(dpoint += 3, a, c, 0.5);
-        par_shapes__add3(dpoint += 3, a);
-        par_shapes__add3(dpoint += 3, p0);
-        par_shapes__add3(dpoint += 3, p2);
-        par_shapes__add3(dpoint += 3, p0);
-        par_shapes__add3(dpoint += 3, b);
-        par_shapes__add3(dpoint += 3, p1);
-        par_shapes__add3(dpoint += 3, p2);
-        par_shapes__add3(dpoint += 3, p1);
-        par_shapes__add3(dpoint += 3, c);
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = points;
-    mesh->npoints = npoints;
-    mesh->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_create_subdivided_sphere(int nsubd)
-{
-    par_shapes_mesh* mesh = par_shapes_create_icosahedron();
-    par_shapes_unweld(mesh, false);
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = 0;
-    while (nsubd--) {
-        par_shapes__subdivide(mesh);
-    }
-    for (int i = 0; i < mesh->npoints; i++) {
-        par_shapes__normalize3(mesh->points + i * 3);
-    }
-    mesh->triangles = PAR_MALLOC(PAR_SHAPES_T, 3 * mesh->ntriangles);
-    for (int i = 0; i < mesh->ntriangles * 3; i++) {
-        mesh->triangles[i] = i;
-    }
-    par_shapes_mesh* tmp = mesh;
-    mesh = par_shapes_weld(mesh, 0.01, 0);
-    par_shapes_free_mesh(tmp);
-    par_shapes_compute_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_create_rock(int seed, int subd)
-{
-    par_shapes_mesh* mesh = par_shapes_create_subdivided_sphere(subd);
-    struct osn_context* ctx;
-    par__simplex_noise(seed, &ctx);
-    for (int p = 0; p < mesh->npoints; p++) {
-        float* pt = mesh->points + p * 3;
-        float a = 0.25, f = 1.0;
-        double n = a * par__simplex_noise2(ctx, f * pt[0], f * pt[2]);
-        a *= 0.5; f *= 2;
-        n += a * par__simplex_noise2(ctx, f * pt[0], f * pt[2]);
-        pt[0] *= 1 + 2 * n;
-        pt[1] *= 1 + n;
-        pt[2] *= 1 + 2 * n;
-        if (pt[1] < 0) {
-            pt[1] = -pow(-pt[1], 0.5) / 2;
-        }
-    }
-    par__simplex_noise_free(ctx);
-    par_shapes_compute_normals(mesh);
-    return mesh;
-}
-
-par_shapes_mesh* par_shapes_clone(par_shapes_mesh const* mesh,
-    par_shapes_mesh* clone)
-{
-    if (!clone) {
-        clone = PAR_CALLOC(par_shapes_mesh, 1);
-    }
-    clone->npoints = mesh->npoints;
-    clone->points = PAR_REALLOC(float, clone->points, 3 * clone->npoints);
-    memcpy(clone->points, mesh->points, sizeof(float) * 3 * clone->npoints);
-    clone->ntriangles = mesh->ntriangles;
-    clone->triangles = PAR_REALLOC(PAR_SHAPES_T, clone->triangles, 3 *
-        clone->ntriangles);
-    memcpy(clone->triangles, mesh->triangles,
-        sizeof(PAR_SHAPES_T) * 3 * clone->ntriangles);
-    if (mesh->normals) {
-        clone->normals = PAR_REALLOC(float, clone->normals, 3 * clone->npoints);
-        memcpy(clone->normals, mesh->normals,
-            sizeof(float) * 3 * clone->npoints);
-    }
-    if (mesh->tcoords) {
-        clone->tcoords = PAR_REALLOC(float, clone->tcoords, 2 * clone->npoints);
-        memcpy(clone->tcoords, mesh->tcoords,
-            sizeof(float) * 2 * clone->npoints);
-    }
-    return clone;
-}
-
-static struct {
-    float const* points;
-    int gridsize;
-} par_shapes__sort_context;
-
-static int par_shapes__cmp1(const void *arg0, const void *arg1)
-{
-    const int g = par_shapes__sort_context.gridsize;
-
-    // Convert arg0 into a flattened grid index.
-    PAR_SHAPES_T d0 = *(const PAR_SHAPES_T*) arg0;
-    float const* p0 = par_shapes__sort_context.points + d0 * 3;
-    int i0 = (int) p0[0];
-    int j0 = (int) p0[1];
-    int k0 = (int) p0[2];
-    int index0 = i0 + g * j0 + g * g * k0;
-
-    // Convert arg1 into a flattened grid index.
-    PAR_SHAPES_T d1 = *(const PAR_SHAPES_T*) arg1;
-    float const* p1 = par_shapes__sort_context.points + d1 * 3;
-    int i1 = (int) p1[0];
-    int j1 = (int) p1[1];
-    int k1 = (int) p1[2];
-    int index1 = i1 + g * j1 + g * g * k1;
-
-    // Return the ordering.
-    if (index0 < index1) return -1;
-    if (index0 > index1) return 1;
-    return 0;
-}
-
-static void par_shapes__sort_points(par_shapes_mesh* mesh, int gridsize,
-    PAR_SHAPES_T* sortmap)
-{
-    // Run qsort over a list of consecutive integers that get deferenced
-    // within the comparator function; this creates a reorder mapping.
-    for (int i = 0; i < mesh->npoints; i++) {
-        sortmap[i] = i;
-    }
-    par_shapes__sort_context.gridsize = gridsize;
-    par_shapes__sort_context.points = mesh->points;
-    qsort(sortmap, mesh->npoints, sizeof(PAR_SHAPES_T), par_shapes__cmp1);
-
-    // Apply the reorder mapping to the XYZ coordinate data.
-    float* newpts = PAR_MALLOC(float, mesh->npoints * 3);
-    PAR_SHAPES_T* invmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    float* dstpt = newpts;
-    for (int i = 0; i < mesh->npoints; i++) {
-        invmap[sortmap[i]] = i;
-        float const* srcpt = mesh->points + 3 * sortmap[i];
-        *dstpt++ = *srcpt++;
-        *dstpt++ = *srcpt++;
-        *dstpt++ = *srcpt++;
-    }
-    PAR_FREE(mesh->points);
-    mesh->points = newpts;
-
-    // Apply the inverse reorder mapping to the triangle indices.
-    PAR_SHAPES_T* newinds = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* dstind = newinds;
-    PAR_SHAPES_T const* srcind = mesh->triangles;
-    for (int i = 0; i < mesh->ntriangles * 3; i++) {
-        *dstind++ = invmap[*srcind++];
-    }
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = newinds;
-
-    // Cleanup.
-    memcpy(sortmap, invmap, sizeof(PAR_SHAPES_T) * mesh->npoints);
-    PAR_FREE(invmap);
-}
-
-static void par_shapes__weld_points(par_shapes_mesh* mesh, int gridsize,
-    float epsilon, PAR_SHAPES_T* weldmap)
-{
-    // Each bin contains a "pointer" (really an index) to its first point.
-    // We add 1 because 0 is reserved to mean that the bin is empty.
-    // Since the points are spatially sorted, there's no need to store
-    // a point count in each bin.
-    PAR_SHAPES_T* bins = PAR_CALLOC(PAR_SHAPES_T,
-        gridsize * gridsize * gridsize);
-    int prev_binindex = -1;
-    for (int p = 0; p < mesh->npoints; p++) {
-        float const* pt = mesh->points + p * 3;
-        int i = (int) pt[0];
-        int j = (int) pt[1];
-        int k = (int) pt[2];
-        int this_binindex = i + gridsize * j + gridsize * gridsize * k;
-        if (this_binindex != prev_binindex) {
-            bins[this_binindex] = 1 + p;
-        }
-        prev_binindex = this_binindex;
-    }
-
-    // Examine all bins that intersect the epsilon-sized cube centered at each
-    // point, and check for colocated points within those bins.
-    float const* pt = mesh->points;
-    int nremoved = 0;
-    for (int p = 0; p < mesh->npoints; p++, pt += 3) {
-
-        // Skip if this point has already been welded.
-        if (weldmap[p] != p) {
-            continue;
-        }
-
-        // Build a list of bins that intersect the epsilon-sized cube.
-        int nearby[8];
-        int nbins = 0;
-        int minp[3], maxp[3];
-        for (int c = 0; c < 3; c++) {
-            minp[c] = (int) (pt[c] - epsilon);
-            maxp[c] = (int) (pt[c] + epsilon);
-        }
-        for (int i = minp[0]; i <= maxp[0]; i++) {
-            for (int j = minp[1]; j <= maxp[1]; j++) {
-                for (int k = minp[2]; k <= maxp[2]; k++) {
-                    int binindex = i + gridsize * j + gridsize * gridsize * k;
-                    PAR_SHAPES_T binvalue = *(bins + binindex);
-                    if (binvalue > 0) {
-                        if (nbins == 8) {
-                            //printf("Epsilon value is too large.\n");
-                            break;
-                        }
-                        nearby[nbins++] = binindex;
-                    }
-                }
-            }
-        }
-
-        // Check for colocated points in each nearby bin.
-        for (int b = 0; b < nbins; b++) {
-            int binindex = nearby[b];
-            PAR_SHAPES_T binvalue = *(bins + binindex);
-            PAR_SHAPES_T nindex = binvalue - 1;
-            while (true) {
-
-                // If this isn't "self" and it's colocated, then weld it!
-                if (nindex != p && weldmap[nindex] == nindex) {
-                    float const* thatpt = mesh->points + nindex * 3;
-                    float dist2 = par_shapes__sqrdist3(thatpt, pt);
-                    if (dist2 < epsilon) {
-                        weldmap[nindex] = p;
-                        nremoved++;
-                    }
-                }
-
-                // Advance to the next point if possible.
-                if (++nindex >= mesh->npoints) {
-                    break;
-                }
-
-                // If the next point is outside the bin, then we're done.
-                float const* nextpt = mesh->points + nindex * 3;
-                int i = (int) nextpt[0];
-                int j = (int) nextpt[1];
-                int k = (int) nextpt[2];
-                int nextbinindex = i + gridsize * j + gridsize * gridsize * k;
-                if (nextbinindex != binindex) {
-                    break;
-                }
-            }
-        }
-    }
-    PAR_FREE(bins);
-
-    // Apply the weldmap to the vertices.
-    int npoints = mesh->npoints - nremoved;
-    float* newpts = PAR_MALLOC(float, 3 * npoints);
-    float* dst = newpts;
-    PAR_SHAPES_T* condensed_map = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    PAR_SHAPES_T* cmap = condensed_map;
-    float const* src = mesh->points;
-    int ci = 0;
-    for (int p = 0; p < mesh->npoints; p++, src += 3) {
-        if (weldmap[p] == p) {
-            *dst++ = src[0];
-            *dst++ = src[1];
-            *dst++ = src[2];
-            *cmap++ = ci++;
-        } else {
-            *cmap++ = condensed_map[weldmap[p]];
-        }
-    }
-    assert(ci == npoints);
-    PAR_FREE(mesh->points);
-    memcpy(weldmap, condensed_map, mesh->npoints * sizeof(PAR_SHAPES_T));
-    PAR_FREE(condensed_map);
-    mesh->points = newpts;
-    mesh->npoints = npoints;
-
-    // Apply the weldmap to the triangle indices and skip the degenerates.
-    PAR_SHAPES_T const* tsrc = mesh->triangles;
-    PAR_SHAPES_T* tdst = mesh->triangles;
-    int ntriangles = 0;
-    for (int i = 0; i < mesh->ntriangles; i++, tsrc += 3) {
-        PAR_SHAPES_T a = weldmap[tsrc[0]];
-        PAR_SHAPES_T b = weldmap[tsrc[1]];
-        PAR_SHAPES_T c = weldmap[tsrc[2]];
-        if (a != b && a != c && b != c) {
-            *tdst++ = a;
-            *tdst++ = b;
-            *tdst++ = c;
-            ntriangles++;
-        }
-    }
-    mesh->ntriangles = ntriangles;
-}
-
-par_shapes_mesh* par_shapes_weld(par_shapes_mesh const* mesh, float epsilon,
-    PAR_SHAPES_T* weldmap)
-{
-    par_shapes_mesh* clone = par_shapes_clone(mesh, 0);
-    float aabb[6];
-    int gridsize = 20;
-    float maxcell = gridsize - 1;
-    par_shapes_compute_aabb(clone, aabb);
-    float scale[3] = {
-        aabb[3] == aabb[0] ? 1.0f : maxcell / (aabb[3] - aabb[0]),
-        aabb[4] == aabb[1] ? 1.0f : maxcell / (aabb[4] - aabb[1]),
-        aabb[5] == aabb[2] ? 1.0f : maxcell / (aabb[5] - aabb[2]),
-    };
-    par_shapes_translate(clone, -aabb[0], -aabb[1], -aabb[2]);
-    par_shapes_scale(clone, scale[0], scale[1], scale[2]);
-    PAR_SHAPES_T* sortmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    par_shapes__sort_points(clone, gridsize, sortmap);
-    bool owner = false;
-    if (!weldmap) {
-        owner = true;
-        weldmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-    }
-    for (int i = 0; i < mesh->npoints; i++) {
-        weldmap[i] = i;
-    }
-    par_shapes__weld_points(clone, gridsize, epsilon, weldmap);
-    if (owner) {
-        PAR_FREE(weldmap);
-    } else {
-        PAR_SHAPES_T* newmap = PAR_MALLOC(PAR_SHAPES_T, mesh->npoints);
-        for (int i = 0; i < mesh->npoints; i++) {
-            newmap[i] = weldmap[sortmap[i]];
-        }
-        memcpy(weldmap, newmap, sizeof(PAR_SHAPES_T) * mesh->npoints);
-        PAR_FREE(newmap);
-    }
-    PAR_FREE(sortmap);
-    par_shapes_scale(clone, 1.0 / scale[0], 1.0 / scale[1], 1.0 / scale[2]);
-    par_shapes_translate(clone, aabb[0], aabb[1], aabb[2]);
-    return clone;
-}
-
-// -----------------------------------------------------------------------------
-// BEGIN OPEN SIMPLEX NOISE
-// -----------------------------------------------------------------------------
-
-#define STRETCH_CONSTANT_2D (-0.211324865405187)  // (1 / sqrt(2 + 1) - 1 ) / 2;
-#define SQUISH_CONSTANT_2D (0.366025403784439)  // (sqrt(2 + 1) -1) / 2;
-#define STRETCH_CONSTANT_3D (-1.0 / 6.0)  // (1 / sqrt(3 + 1) - 1) / 3;
-#define SQUISH_CONSTANT_3D (1.0 / 3.0)  // (sqrt(3+1)-1)/3;
-#define STRETCH_CONSTANT_4D (-0.138196601125011)  // (1 / sqrt(4 + 1) - 1) / 4;
-#define SQUISH_CONSTANT_4D (0.309016994374947)  // (sqrt(4 + 1) - 1) / 4;
-
-#define NORM_CONSTANT_2D (47.0)
-#define NORM_CONSTANT_3D (103.0)
-#define NORM_CONSTANT_4D (30.0)
-
-#define DEFAULT_SEED (0LL)
-
-struct osn_context {
-    int16_t* perm;
-    int16_t* permGradIndex3D;
-};
-
-#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
-
-/*
- * Gradients for 2D. They approximate the directions to the
- * vertices of an octagon from the center.
- */
-static const int8_t gradients2D[] = {
-    5, 2, 2, 5, -5, 2, -2, 5, 5, -2, 2, -5, -5, -2, -2, -5,
-};
-
-/*
- * Gradients for 3D. They approximate the directions to the
- * vertices of a rhombicuboctahedron from the center, skewed so
- * that the triangular and square facets can be inscribed inside
- * circles of the same radius.
- */
-static const signed char gradients3D[] = {
-    -11, 4, 4, -4, 11, 4, -4, 4, 11, 11, 4, 4, 4, 11, 4, 4, 4, 11, -11, -4, 4,
-    -4, -11, 4, -4, -4, 11, 11, -4, 4, 4, -11, 4, 4, -4, 11, -11, 4, -4, -4, 11,
-    -4, -4, 4, -11, 11, 4, -4, 4, 11, -4, 4, 4, -11, -11, -4, -4, -4, -11, -4,
-    -4, -4, -11, 11, -4, -4, 4, -11, -4, 4, -4, -11,
-};
-
-/*
- * Gradients for 4D. They approximate the directions to the
- * vertices of a disprismatotesseractihexadecachoron from the center,
- * skewed so that the tetrahedral and cubic facets can be inscribed inside
- * spheres of the same radius.
- */
-static const signed char gradients4D[] = {
-    3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, -3, 1, 1, 1, -1, 3, 1, 1,
-    -1, 1, 3, 1, -1, 1, 1, 3, 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1,
-    3, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, 3, 1, -1, 1, 1,
-    3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3,
-    1, -1, 1, -1, 3, 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, -3,
-    -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, 3, 1, 1, -1, 1, 3,
-    1, -1, 1, 1, 3, -1, 1, 1, 1, -3, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1,
-    -1, 1, 1, -3, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, -3,
-    -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, 3, 1, -1, -1, 1, 3,
-    -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3,
-    -1, -1, 1, -1, -3, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1,
-    -3, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3,
-};
-
-static double extrapolate2(
-    struct osn_context* ctx, int xsb, int ysb, double dx, double dy)
-{
-    int16_t* perm = ctx->perm;
-    int index = perm[(perm[xsb & 0xFF] + ysb) & 0xFF] & 0x0E;
-    return gradients2D[index] * dx + gradients2D[index + 1] * dy;
-}
-
-static inline int fastFloor(double x)
-{
-    int xi = (int) x;
-    return x < xi ? xi - 1 : xi;
-}
-
-static int allocate_perm(struct osn_context* ctx, int nperm, int ngrad)
-{
-    PAR_FREE(ctx->perm);
-    PAR_FREE(ctx->permGradIndex3D);
-    ctx->perm = PAR_MALLOC(int16_t, nperm);
-    if (!ctx->perm) {
-        return -ENOMEM;
-    }
-    ctx->permGradIndex3D = PAR_MALLOC(int16_t, ngrad);
-    if (!ctx->permGradIndex3D) {
-        PAR_FREE(ctx->perm);
-        return -ENOMEM;
-    }
-    return 0;
-}
-
-static int par__simplex_noise(int64_t seed, struct osn_context** ctx)
-{
-    int rc;
-    int16_t source[256];
-    int i;
-    int16_t* perm;
-    int16_t* permGradIndex3D;
-    *ctx = PAR_MALLOC(struct osn_context, 1);
-    if (!(*ctx)) {
-        return -ENOMEM;
-    }
-    (*ctx)->perm = NULL;
-    (*ctx)->permGradIndex3D = NULL;
-    rc = allocate_perm(*ctx, 256, 256);
-    if (rc) {
-        PAR_FREE(*ctx);
-        return rc;
-    }
-    perm = (*ctx)->perm;
-    permGradIndex3D = (*ctx)->permGradIndex3D;
-    for (i = 0; i < 256; i++) {
-        source[i] = (int16_t) i;
-    }
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-    for (i = 255; i >= 0; i--) {
-        seed = seed * 6364136223846793005LL + 1442695040888963407LL;
-        int r = (int) ((seed + 31) % (i + 1));
-        if (r < 0)
-            r += (i + 1);
-        perm[i] = source[r];
-        permGradIndex3D[i] =
-            (short) ((perm[i] % (ARRAYSIZE(gradients3D) / 3)) * 3);
-        source[r] = source[i];
-    }
-    return 0;
-}
-
-static void par__simplex_noise_free(struct osn_context* ctx)
-{
-    if (!ctx)
-        return;
-    if (ctx->perm) {
-        PAR_FREE(ctx->perm);
-        ctx->perm = NULL;
-    }
-    if (ctx->permGradIndex3D) {
-        PAR_FREE(ctx->permGradIndex3D);
-        ctx->permGradIndex3D = NULL;
-    }
-    PAR_FREE(ctx);
-}
-
-static double par__simplex_noise2(struct osn_context* ctx, double x, double y)
-{
-    // Place input coordinates onto grid.
-    double stretchOffset = (x + y) * STRETCH_CONSTANT_2D;
-    double xs = x + stretchOffset;
-    double ys = y + stretchOffset;
-
-    // Floor to get grid coordinates of rhombus (stretched square) super-cell
-    // origin.
-    int xsb = fastFloor(xs);
-    int ysb = fastFloor(ys);
-
-    // Skew out to get actual coordinates of rhombus origin. We'll need these
-    // later.
-    double squishOffset = (xsb + ysb) * SQUISH_CONSTANT_2D;
-    double xb = xsb + squishOffset;
-    double yb = ysb + squishOffset;
-
-    // Compute grid coordinates relative to rhombus origin.
-    double xins = xs - xsb;
-    double yins = ys - ysb;
-
-    // Sum those together to get a value that determines which region we're in.
-    double inSum = xins + yins;
-
-    // Positions relative to origin point.
-    double dx0 = x - xb;
-    double dy0 = y - yb;
-
-    // We'll be defining these inside the next block and using them afterwards.
-    double dx_ext, dy_ext;
-    int xsv_ext, ysv_ext;
-
-    double value = 0;
-
-    // Contribution (1,0)
-    double dx1 = dx0 - 1 - SQUISH_CONSTANT_2D;
-    double dy1 = dy0 - 0 - SQUISH_CONSTANT_2D;
-    double attn1 = 2 - dx1 * dx1 - dy1 * dy1;
-    if (attn1 > 0) {
-        attn1 *= attn1;
-        value += attn1 * attn1 * extrapolate2(ctx, xsb + 1, ysb + 0, dx1, dy1);
-    }
-
-    // Contribution (0,1)
-    double dx2 = dx0 - 0 - SQUISH_CONSTANT_2D;
-    double dy2 = dy0 - 1 - SQUISH_CONSTANT_2D;
-    double attn2 = 2 - dx2 * dx2 - dy2 * dy2;
-    if (attn2 > 0) {
-        attn2 *= attn2;
-        value += attn2 * attn2 * extrapolate2(ctx, xsb + 0, ysb + 1, dx2, dy2);
-    }
-
-    if (inSum <= 1) {  // We're inside the triangle (2-Simplex) at (0,0)
-        double zins = 1 - inSum;
-        if (zins > xins || zins > yins) {
-            if (xins > yins) {
-                xsv_ext = xsb + 1;
-                ysv_ext = ysb - 1;
-                dx_ext = dx0 - 1;
-                dy_ext = dy0 + 1;
-            } else {
-                xsv_ext = xsb - 1;
-                ysv_ext = ysb + 1;
-                dx_ext = dx0 + 1;
-                dy_ext = dy0 - 1;
-            }
-        } else {  //(1,0) and (0,1) are the closest two vertices.
-            xsv_ext = xsb + 1;
-            ysv_ext = ysb + 1;
-            dx_ext = dx0 - 1 - 2 * SQUISH_CONSTANT_2D;
-            dy_ext = dy0 - 1 - 2 * SQUISH_CONSTANT_2D;
-        }
-    } else {  // We're inside the triangle (2-Simplex) at (1,1)
-        double zins = 2 - inSum;
-        if (zins < xins || zins < yins) {
-            if (xins > yins) {
-                xsv_ext = xsb + 2;
-                ysv_ext = ysb + 0;
-                dx_ext = dx0 - 2 - 2 * SQUISH_CONSTANT_2D;
-                dy_ext = dy0 + 0 - 2 * SQUISH_CONSTANT_2D;
-            } else {
-                xsv_ext = xsb + 0;
-                ysv_ext = ysb + 2;
-                dx_ext = dx0 + 0 - 2 * SQUISH_CONSTANT_2D;
-                dy_ext = dy0 - 2 - 2 * SQUISH_CONSTANT_2D;
-            }
-        } else {  //(1,0) and (0,1) are the closest two vertices.
-            dx_ext = dx0;
-            dy_ext = dy0;
-            xsv_ext = xsb;
-            ysv_ext = ysb;
-        }
-        xsb += 1;
-        ysb += 1;
-        dx0 = dx0 - 1 - 2 * SQUISH_CONSTANT_2D;
-        dy0 = dy0 - 1 - 2 * SQUISH_CONSTANT_2D;
-    }
-
-    // Contribution (0,0) or (1,1)
-    double attn0 = 2 - dx0 * dx0 - dy0 * dy0;
-    if (attn0 > 0) {
-        attn0 *= attn0;
-        value += attn0 * attn0 * extrapolate2(ctx, xsb, ysb, dx0, dy0);
-    }
-
-    // Extra Vertex
-    double attn_ext = 2 - dx_ext * dx_ext - dy_ext * dy_ext;
-    if (attn_ext > 0) {
-        attn_ext *= attn_ext;
-        value += attn_ext * attn_ext *
-            extrapolate2(ctx, xsv_ext, ysv_ext, dx_ext, dy_ext);
-    }
-
-    return value / NORM_CONSTANT_2D;
-}
-
-void par_shapes_remove_degenerate(par_shapes_mesh* mesh, float mintriarea)
-{
-    int ntriangles = 0;
-    PAR_SHAPES_T* triangles = PAR_MALLOC(PAR_SHAPES_T, mesh->ntriangles * 3);
-    PAR_SHAPES_T* dst = triangles;
-    PAR_SHAPES_T const* src = mesh->triangles;
-    float next[3], prev[3], cp[3];
-    float mincplen2 = (mintriarea * 2) * (mintriarea * 2);
-    for (int f = 0; f < mesh->ntriangles; f++, src += 3) {
-        float const* pa = mesh->points + 3 * src[0];
-        float const* pb = mesh->points + 3 * src[1];
-        float const* pc = mesh->points + 3 * src[2];
-        par_shapes__copy3(next, pb);
-        par_shapes__subtract3(next, pa);
-        par_shapes__copy3(prev, pc);
-        par_shapes__subtract3(prev, pa);
-        par_shapes__cross3(cp, next, prev);
-        float cplen2 = par_shapes__dot3(cp, cp);
-        if (cplen2 >= mincplen2) {
-            *dst++ = src[0];
-            *dst++ = src[1];
-            *dst++ = src[2];
-            ntriangles++;
-        }
-    }
-    mesh->ntriangles = ntriangles;
-    PAR_FREE(mesh->triangles);
-    mesh->triangles = triangles;
-}
-
-#endif // PAR_SHAPES_IMPLEMENTATION
-#endif // PAR_SHAPES_H
diff --git a/raylib_pi4_test/external/sdefl.h b/raylib_pi4_test/external/sdefl.h
deleted file mode 100644 (file)
index 218e754..0000000
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
-# Small Deflate
-`sdefl` is a small bare bone lossless compression library in ANSI C (ISO C90)
-which implements the Deflate (RFC 1951) compressed data format specification standard.
-It is mainly tuned to get as much speed and compression ratio from as little code
-as needed to keep the implementation as concise as possible.
-
-## Features
-- Portable single header and source file duo written in ANSI C (ISO C90)
-- Dual license with either MIT or public domain
-- Small implementation
-    - Deflate: 525 LoC
-    - Inflate: 320 LoC
-- Webassembly:
-    - Deflate ~3.7 KB (~2.2KB compressed)
-    - Inflate ~3.6 KB (~2.2KB compressed)
-
-## Usage:
-This file behaves differently depending on what symbols you define
-before including it.
-
-Header-File mode:
-If you do not define `SDEFL_IMPLEMENTATION` before including this file, it
-will operate in header only mode. In this mode it declares all used structs
-and the API of the library without including the implementation of the library.
-
-Implementation mode:
-If you define `SDEFL_IMPLEMENTATION` before including this file, it will
-compile the implementation . Make sure that you only include
-this file implementation in *one* C or C++ file to prevent collisions.
-
-### Benchmark
-
-| Compressor name         | Compression| Decompress.| Compr. size | Ratio |
-| ------------------------| -----------| -----------| ----------- | ----- |
-| sdefl 1.0 -0            |   127 MB/s |   233 MB/s |    40004116 | 39.88 |
-| sdefl 1.0 -1            |   111 MB/s |   259 MB/s |    38940674 | 38.82 |
-| sdefl 1.0 -5            |    45 MB/s |   275 MB/s |    36577183 | 36.46 |
-| sdefl 1.0 -7            |    38 MB/s |   276 MB/s |    36523781 | 36.41 |
-| zlib 1.2.11 -1          |    72 MB/s |   307 MB/s |    42298774 | 42.30 |
-| zlib 1.2.11 -6          |    24 MB/s |   313 MB/s |    36548921 | 36.55 |
-| zlib 1.2.11 -9          |    20 MB/s |   314 MB/s |    36475792 | 36.48 |
-| miniz 1.0 -1            |   122 MB/s |   208 MB/s |    48510028 | 48.51 |
-| miniz 1.0 -6            |    27 MB/s |   260 MB/s |    36513697 | 36.51 |
-| miniz 1.0 -9            |    23 MB/s |   261 MB/s |    36460101 | 36.46 |
-| libdeflate 1.3 -1       |   147 MB/s |   667 MB/s |    39597378 | 39.60 |
-| libdeflate 1.3 -6       |    69 MB/s |   689 MB/s |    36648318 | 36.65 |
-| libdeflate 1.3 -9       |    13 MB/s |   672 MB/s |    35197141 | 35.20 |
-| libdeflate 1.3 -12      |  8.13 MB/s |   670 MB/s |    35100568 | 35.10 |
-
-### Compression
-Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-
-| File    |   Original | `sdefl 0`     | `sdefl 5`     | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 |  4,260,187|  3,845,261|   3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 |  19,565,867 |
-| mr      |  9.970.564 | 3,860,531 |  3,673,460 |   3,665,627 |
-| nci     | 33.553.445 | 4,030,283 |  3,094,526 |   3,006,075 |
-| ooffice |  6.152.192 | 3,320,063 |  3,186,373 |   3,183,815 |
-| osdb    | 10.085.684 | 3,919,646 |  3,649,510 |   3,649,477 |
-| reymont |  6.627.202 | 2,263,378 |  1,857,588 |   1,827,237 |
-| samba   | 21.606.400 | 6,121,797 |  5,462,670 |   5,450,762 |
-| sao     |  7.251.944 | 5,612,421 |  5,485,380 |   5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 |  11,991,421 |
-| xml     |  5.345.280 | 886,620|    674,009 |     662,141 |
-| x-ray   |  8.474.240 | 6,304,655 |  6,244,779 |   6,244,779 |
-
-## License
-```
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-```
-*/
-#ifndef SDEFL_H_INCLUDED
-#define SDEFL_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SDEFL_MAX_OFF   (1 << 15)
-#define SDEFL_WIN_SIZ   SDEFL_MAX_OFF
-#define SDEFL_WIN_MSK   (SDEFL_WIN_SIZ-1)
-
-#define SDEFL_HASH_BITS 15
-#define SDEFL_HASH_SIZ  (1 << SDEFL_HASH_BITS)
-#define SDEFL_HASH_MSK  (SDEFL_HASH_SIZ-1)
-
-#define SDEFL_MIN_MATCH 4
-#define SDEFL_BLK_MAX   (256*1024)
-#define SDEFL_SEQ_SIZ   ((SDEFL_BLK_MAX + SDEFL_MIN_MATCH)/SDEFL_MIN_MATCH)
-
-#define SDEFL_SYM_MAX   (288)
-#define SDEFL_OFF_MAX   (32)
-#define SDEFL_PRE_MAX   (19)
-
-#define SDEFL_LVL_MIN   0
-#define SDEFL_LVL_DEF   5
-#define SDEFL_LVL_MAX   8
-
-struct sdefl_freq {
-  unsigned lit[SDEFL_SYM_MAX];
-  unsigned off[SDEFL_OFF_MAX];
-};
-struct sdefl_code_words {
-  unsigned lit[SDEFL_SYM_MAX];
-  unsigned off[SDEFL_OFF_MAX];
-};
-struct sdefl_lens {
-  unsigned char lit[SDEFL_SYM_MAX];
-  unsigned char off[SDEFL_OFF_MAX];
-};
-struct sdefl_codes {
-  struct sdefl_code_words word;
-  struct sdefl_lens len;
-};
-struct sdefl_seqt {
-  int off, len;
-};
-struct sdefl {
-  int bits, bitcnt;
-  int tbl[SDEFL_HASH_SIZ];
-  int prv[SDEFL_WIN_SIZ];
-
-  int seq_cnt;
-  struct sdefl_seqt seq[SDEFL_SEQ_SIZ];
-  struct sdefl_freq freq;
-  struct sdefl_codes cod;
-};
-extern int sdefl_bound(int in_len);
-extern int sdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
-extern int zsdeflate(struct sdefl *s, void *o, const void *i, int n, int lvl);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SDEFL_H_INCLUDED */
-
-#ifdef SDEFL_IMPLEMENTATION
-
-#include <assert.h> /* assert */
-#include <string.h> /* memcpy */
-#include <limits.h> /* CHAR_BIT */
-
-#define SDEFL_NIL               (-1)
-#define SDEFL_MAX_MATCH         258
-#define SDEFL_MAX_CODE_LEN      (15)
-#define SDEFL_SYM_BITS          (10u)
-#define SDEFL_SYM_MSK           ((1u << SDEFL_SYM_BITS)-1u)
-#define SDEFL_LIT_LEN_CODES     (14)
-#define SDEFL_OFF_CODES         (15)
-#define SDEFL_PRE_CODES         (7)
-#define SDEFL_CNT_NUM(n)        ((((n)+3u/4u)+3u)&~3u)
-#define SDEFL_EOB               (256)
-
-#define sdefl_npow2(n) (1 << (sdefl_ilog2((n)-1) + 1))
-
-static int
-sdefl_ilog2(int n) {
-  if (!n) return 0;
-#ifdef _MSC_VER
-  unsigned long msbp = 0;
-  _BitScanReverse(&msbp, (unsigned long)n);
-  return (int)msbp;
-#elif defined(__GNUC__) || defined(__clang__)
-  return (int)sizeof(unsigned long) * CHAR_BIT - 1 - __builtin_clzl((unsigned long)n);
-#else
-  #define lt(n) n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n
-  static const char tbl[256] = {
-    0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,lt(4), lt(5), lt(5), lt(6), lt(6), lt(6), lt(6),
-    lt(7), lt(7), lt(7), lt(7), lt(7), lt(7), lt(7), lt(7)};
-  int tt, t;
-  if ((tt = (n >> 16))) {
-    return (t = (tt >> 8)) ? 24 + tbl[t] : 16 + tbl[tt];
-  } else {
-    return (t = (n >> 8)) ? 8 + tbl[t] : tbl[n];
-  }
-  #undef lt
-#endif
-}
-static unsigned
-sdefl_uload32(const void *p) {
-  /* hopefully will be optimized to an unaligned read */
-  unsigned n = 0;
-  memcpy(&n, p, sizeof(n));
-  return n;
-}
-static unsigned
-sdefl_hash32(const void *p) {
-  unsigned n = sdefl_uload32(p);
-  return (n * 0x9E377989) >> (32 - SDEFL_HASH_BITS);
-}
-static void
-sdefl_put(unsigned char **dst, struct sdefl *s, int code, int bitcnt) {
-  s->bits |= (code << s->bitcnt);
-  s->bitcnt += bitcnt;
-  while (s->bitcnt >= 8) {
-    unsigned char *tar = *dst;
-    *tar = (unsigned char)(s->bits & 0xFF);
-    s->bits >>= 8;
-    s->bitcnt -= 8;
-    *dst = *dst + 1;
-  }
-}
-static void
-sdefl_heap_sub(unsigned A[], unsigned len, unsigned sub) {
-  unsigned c, p = sub;
-  unsigned v = A[sub];
-  while ((c = p << 1) <= len) {
-    if (c < len && A[c + 1] > A[c]) c++;
-    if (v >= A[c]) break;
-    A[p] = A[c], p = c;
-  }
-  A[p] = v;
-}
-static void
-sdefl_heap_array(unsigned *A, unsigned len) {
-  unsigned sub;
-  for (sub = len >> 1; sub >= 1; sub--)
-    sdefl_heap_sub(A, len, sub);
-}
-static void
-sdefl_heap_sort(unsigned *A, unsigned n) {
-  A--;
-  sdefl_heap_array(A, n);
-  while (n >= 2) {
-    unsigned tmp = A[n];
-    A[n--] = A[1];
-    A[1] = tmp;
-    sdefl_heap_sub(A, n, 1);
-  }
-}
-static unsigned
-sdefl_sort_sym(unsigned sym_cnt, unsigned *freqs,
-               unsigned char *lens, unsigned *sym_out) {
-  unsigned cnts[SDEFL_CNT_NUM(SDEFL_SYM_MAX)] = {0};
-  unsigned cnt_num = SDEFL_CNT_NUM(sym_cnt);
-  unsigned used_sym = 0;
-  unsigned sym, i;
-  for (sym = 0; sym < sym_cnt; sym++)
-    cnts[freqs[sym] < cnt_num-1 ? freqs[sym]: cnt_num-1]++;
-  for (i = 1; i < cnt_num; i++) {
-    unsigned cnt = cnts[i];
-    cnts[i] = used_sym;
-    used_sym += cnt;
-  }
-  for (sym = 0; sym < sym_cnt; sym++) {
-    unsigned freq = freqs[sym];
-    if (freq) {
-        unsigned idx = freq < cnt_num-1 ? freq : cnt_num-1;
-        sym_out[cnts[idx]++] = sym | (freq << SDEFL_SYM_BITS);
-    } else lens[sym] = 0;
-  }
-  sdefl_heap_sort(sym_out + cnts[cnt_num-2], cnts[cnt_num-1] - cnts[cnt_num-2]);
-  return used_sym;
-}
-static void
-sdefl_build_tree(unsigned *A, unsigned sym_cnt) {
-  unsigned i = 0, b = 0, e = 0;
-  do {
-    unsigned m, n, freq_shift;
-    if (i != sym_cnt && (b == e || (A[i] >> SDEFL_SYM_BITS) <= (A[b] >> SDEFL_SYM_BITS)))
-      m = i++;
-    else m = b++;
-    if (i != sym_cnt && (b == e || (A[i] >> SDEFL_SYM_BITS) <= (A[b] >> SDEFL_SYM_BITS)))
-      n = i++;
-    else n = b++;
-
-    freq_shift = (A[m] & ~SDEFL_SYM_MSK) + (A[n] & ~SDEFL_SYM_MSK);
-    A[m] = (A[m] & SDEFL_SYM_MSK) | (e << SDEFL_SYM_BITS);
-    A[n] = (A[n] & SDEFL_SYM_MSK) | (e << SDEFL_SYM_BITS);
-    A[e] = (A[e] & SDEFL_SYM_MSK) | freq_shift;
-  } while (sym_cnt - ++e > 1);
-}
-static void
-sdefl_gen_len_cnt(unsigned *A, unsigned root, unsigned *len_cnt,
-                  unsigned max_code_len) {
-  int n;
-  unsigned i;
-  for (i = 0; i <= max_code_len; i++)
-    len_cnt[i] = 0;
-  len_cnt[1] = 2;
-
-  A[root] &= SDEFL_SYM_MSK;
-  for (n = (int)root - 1; n >= 0; n--) {
-    unsigned p = A[n] >> SDEFL_SYM_BITS;
-    unsigned pdepth = A[p] >> SDEFL_SYM_BITS;
-    unsigned depth = pdepth + 1;
-    unsigned len = depth;
-
-    A[n] = (A[n] & SDEFL_SYM_MSK) | (depth << SDEFL_SYM_BITS);
-    if (len >= max_code_len) {
-      len = max_code_len;
-      do len--; while (!len_cnt[len]);
-    }
-    len_cnt[len]--;
-    len_cnt[len+1] += 2;
-  }
-}
-static void
-sdefl_gen_codes(unsigned *A, unsigned char *lens, const unsigned *len_cnt,
-                unsigned max_code_word_len, unsigned sym_cnt) {
-  unsigned i, sym, len, nxt[SDEFL_MAX_CODE_LEN + 1];
-  for (i = 0, len = max_code_word_len; len >= 1; len--) {
-    unsigned cnt = len_cnt[len];
-    while (cnt--) lens[A[i++] & SDEFL_SYM_MSK] = (unsigned char)len;
-  }
-  nxt[0] = nxt[1] = 0;
-  for (len = 2; len <= max_code_word_len; len++)
-    nxt[len] = (nxt[len-1] + len_cnt[len-1]) << 1;
-  for (sym = 0; sym < sym_cnt; sym++)
-    A[sym] = nxt[lens[sym]]++;
-}
-static unsigned
-sdefl_rev(unsigned c, unsigned char n) {
-  c = ((c & 0x5555) << 1) | ((c & 0xAAAA) >> 1);
-  c = ((c & 0x3333) << 2) | ((c & 0xCCCC) >> 2);
-  c = ((c & 0x0F0F) << 4) | ((c & 0xF0F0) >> 4);
-  c = ((c & 0x00FF) << 8) | ((c & 0xFF00) >> 8);
-  return c >> (16-n);
-}
-static void
-sdefl_huff(unsigned char *lens, unsigned *codes, unsigned *freqs,
-           unsigned num_syms, unsigned max_code_len) {
-  unsigned c, *A = codes;
-  unsigned len_cnt[SDEFL_MAX_CODE_LEN + 1];
-  unsigned used_syms = sdefl_sort_sym(num_syms, freqs, lens, A);
-  if (!used_syms) return;
-  if (used_syms == 1) {
-    unsigned s = A[0] & SDEFL_SYM_MSK;
-    unsigned i = s ? s : 1;
-    codes[0] = 0, lens[0] = 1;
-    codes[i] = 1, lens[i] = 1;
-    return;
-  }
-  sdefl_build_tree(A, used_syms);
-  sdefl_gen_len_cnt(A, used_syms-2, len_cnt, max_code_len);
-  sdefl_gen_codes(A, lens, len_cnt, max_code_len, num_syms);
-  for (c = 0; c < num_syms; c++) {
-    codes[c] = sdefl_rev(codes[c], lens[c]);
-  }
-}
-struct sdefl_symcnt {
-  int items;
-  int lit;
-  int off;
-};
-static void
-sdefl_precode(struct sdefl_symcnt *cnt, unsigned *freqs, unsigned *items,
-              const unsigned char *litlen, const unsigned char *offlen) {
-  unsigned *at = items;
-  unsigned run_start = 0;
-
-  unsigned total = 0;
-  unsigned char lens[SDEFL_SYM_MAX + SDEFL_OFF_MAX];
-  for (cnt->lit = SDEFL_SYM_MAX; cnt->lit > 257; cnt->lit--)
-    if (litlen[cnt->lit - 1]) break;
-  for (cnt->off = SDEFL_OFF_MAX; cnt->off > 1; cnt->off--)
-    if (offlen[cnt->off - 1]) break;
-
-  total = (unsigned)(cnt->lit + cnt->off);
-  memcpy(lens, litlen, sizeof(unsigned char) * cnt->lit);
-  memcpy(lens + cnt->lit, offlen, sizeof(unsigned char) * cnt->off);
-  do {
-    unsigned len = lens[run_start];
-    unsigned run_end = run_start;
-    do run_end++; while (run_end != total && len == lens[run_end]);
-    if (!len) {
-      while ((run_end - run_start) >= 11) {
-        unsigned n = (run_end - run_start) - 11;
-        unsigned xbits =  n < 0x7f ? n : 0x7f;
-        freqs[18]++;
-        *at++ = 18u | (xbits << 5u);
-        run_start += 11 + xbits;
-      }
-      if ((run_end - run_start) >= 3) {
-        unsigned n = (run_end - run_start) - 3;
-        unsigned xbits =  n < 0x7 ? n : 0x7;
-        freqs[17]++;
-        *at++ = 17u | (xbits << 5u);
-        run_start += 3 + xbits;
-      }
-    } else if ((run_end - run_start) >= 4) {
-      freqs[len]++;
-      *at++ = len;
-      run_start++;
-      do {
-        unsigned xbits = (run_end - run_start) - 3;
-        xbits = xbits < 0x03 ? xbits : 0x03;
-        *at++ = 16 | (xbits << 5);
-        run_start += 3 + xbits;
-        freqs[16]++;
-      } while ((run_end - run_start) >= 3);
-    }
-    while (run_start != run_end) {
-      freqs[len]++;
-      *at++ = len;
-      run_start++;
-    }
-  } while (run_start != total);
-  cnt->items = (int)(at - items);
-}
-struct sdefl_match_codes {
-  int ls, lc;
-  int dc, dx;
-};
-static void
-sdefl_match_codes(struct sdefl_match_codes *cod, int dist, int len) {
-  static const short dxmax[] = {0,6,12,24,48,96,192,384,768,1536,3072,6144,12288,24576};
-  static const unsigned char lslot[258+1] = {
-    0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12,
-    12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16,
-    16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18,
-    18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-    20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
-    21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
-    22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
-    23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-    24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25,
-    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-    25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26,
-    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-    26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-    27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-    27, 27, 28
-  };
-  cod->ls = lslot[len];
-  cod->lc = 257 + cod->ls;
-  cod->dx = sdefl_ilog2(sdefl_npow2(dist) >> 2);
-  cod->dc = cod->dx ? ((cod->dx + 1) << 1) + (dist > dxmax[cod->dx]) : dist-1;
-}
-static void
-sdefl_match(unsigned char **dst, struct sdefl *s, int dist, int len) {
-  static const char lxn[] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-  static const short lmin[] = {3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,
-      51,59,67,83,99,115,131,163,195,227,258};
-  static const short dmin[] = {1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,
-      385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577};
-
-  struct sdefl_match_codes cod;
-  sdefl_match_codes(&cod, dist, len);
-  sdefl_put(dst, s, (int)s->cod.word.lit[cod.lc], s->cod.len.lit[cod.lc]);
-  sdefl_put(dst, s, len - lmin[cod.ls], lxn[cod.ls]);
-  sdefl_put(dst, s, (int)s->cod.word.off[cod.dc], s->cod.len.off[cod.dc]);
-  sdefl_put(dst, s, dist - dmin[cod.dc], cod.dx);
-}
-static void
-sdefl_flush(unsigned char **dst, struct sdefl *s, int is_last,
-            const unsigned char *in) {
-  int j, i = 0, item_cnt = 0;
-  struct sdefl_symcnt symcnt = {0};
-  unsigned codes[SDEFL_PRE_MAX];
-  unsigned char lens[SDEFL_PRE_MAX];
-  unsigned freqs[SDEFL_PRE_MAX] = {0};
-  unsigned items[SDEFL_SYM_MAX + SDEFL_OFF_MAX];
-  static const unsigned char perm[SDEFL_PRE_MAX] = {16,17,18,0,8,7,9,6,10,5,11,
-      4,12,3,13,2,14,1,15};
-
-  /* huffman codes */
-  s->freq.lit[SDEFL_EOB]++;
-  sdefl_huff(s->cod.len.lit, s->cod.word.lit, s->freq.lit, SDEFL_SYM_MAX, SDEFL_LIT_LEN_CODES);
-  sdefl_huff(s->cod.len.off, s->cod.word.off, s->freq.off, SDEFL_OFF_MAX, SDEFL_OFF_CODES);
-  sdefl_precode(&symcnt, freqs, items, s->cod.len.lit, s->cod.len.off);
-  sdefl_huff(lens, codes, freqs, SDEFL_PRE_MAX, SDEFL_PRE_CODES);
-  for (item_cnt = SDEFL_PRE_MAX; item_cnt > 4; item_cnt--) {
-    if (lens[perm[item_cnt - 1]]) break;
-  }
-  /* block header */
-  sdefl_put(dst, s, is_last ? 0x01 : 0x00, 1); /* block */
-  sdefl_put(dst, s, 0x02, 2); /* dynamic huffman */
-  sdefl_put(dst, s, symcnt.lit - 257, 5);
-  sdefl_put(dst, s, symcnt.off - 1, 5);
-  sdefl_put(dst, s, item_cnt - 4, 4);
-  for (i = 0; i < item_cnt; ++i)
-    sdefl_put(dst, s, lens[perm[i]], 3);
-  for (i = 0; i < symcnt.items; ++i) {
-    unsigned sym = items[i] & 0x1F;
-    sdefl_put(dst, s, (int)codes[sym], lens[sym]);
-    if (sym < 16) continue;
-    if (sym == 16) sdefl_put(dst, s, items[i] >> 5, 2);
-    else if(sym == 17) sdefl_put(dst, s, items[i] >> 5, 3);
-    else sdefl_put(dst, s, items[i] >> 5, 7);
-  }
-  /* block sequences */
-  for (i = 0; i < s->seq_cnt; ++i) {
-    if (s->seq[i].off >= 0)
-      for (j = 0; j < s->seq[i].len; ++j) {
-        int c = in[s->seq[i].off + j];
-        sdefl_put(dst, s, (int)s->cod.word.lit[c], s->cod.len.lit[c]);
-      }
-    else sdefl_match(dst, s, -s->seq[i].off, s->seq[i].len);
-  }
-  sdefl_put(dst, s, (int)(s)->cod.word.lit[SDEFL_EOB], (s)->cod.len.lit[SDEFL_EOB]);
-  memset(&s->freq, 0, sizeof(s->freq));
-  s->seq_cnt = 0;
-}
-static void
-sdefl_seq(struct sdefl *s, int off, int len) {
-  assert(s->seq_cnt + 2 < SDEFL_SEQ_SIZ);
-  s->seq[s->seq_cnt].off = off;
-  s->seq[s->seq_cnt].len = len;
-  s->seq_cnt++;
-}
-static void
-sdefl_reg_match(struct sdefl *s, int off, int len) {
-  struct sdefl_match_codes cod;
-  sdefl_match_codes(&cod, off, len);
-  s->freq.lit[cod.lc]++;
-  s->freq.off[cod.dc]++;
-}
-struct sdefl_match {
-  int off;
-  int len;
-};
-static void
-sdefl_fnd(struct sdefl_match *m, const struct sdefl *s,
-          int chain_len, int max_match, const unsigned char *in, int p) {
-  int i = s->tbl[sdefl_hash32(&in[p])];
-  int limit = ((p-SDEFL_WIN_SIZ)<SDEFL_NIL)?SDEFL_NIL:(p-SDEFL_WIN_SIZ);
-  while (i > limit) {
-    if (in[i+m->len] == in[p+m->len] &&
-        (sdefl_uload32(&in[i]) == sdefl_uload32(&in[p]))){
-      int n = SDEFL_MIN_MATCH;
-      while (n < max_match && in[i+n] == in[p+n]) n++;
-      if (n > m->len) {
-        m->len = n, m->off = p - i;
-        if (n == max_match) break;
-      }
-    }
-    if (!(--chain_len)) break;
-    i = s->prv[i&SDEFL_WIN_MSK];
-  }
-}
-static int
-sdefl_compr(struct sdefl *s, unsigned char *out, const unsigned char *in,
-            int in_len, int lvl) {
-  unsigned char *q = out;
-  static const unsigned char pref[] = {8,10,14,24,30,48,65,96,130};
-  int max_chain = (lvl < 8) ? (1 << (lvl + 1)): (1 << 13);
-  int n, i = 0, litlen = 0;
-  for (n = 0; n < SDEFL_HASH_SIZ; ++n) {
-    s->tbl[n] = SDEFL_NIL;
-  }
-  do {int blk_end = i + SDEFL_BLK_MAX < in_len ? i + SDEFL_BLK_MAX : in_len;
-    while (i < blk_end) {
-      struct sdefl_match m = {0};
-      int max_match = ((in_len-i)>SDEFL_MAX_MATCH) ? SDEFL_MAX_MATCH:(in_len-i);
-      int nice_match = pref[lvl] < max_match ? pref[lvl] : max_match;
-      int run = 1, inc = 1, run_inc;
-      if (max_match > SDEFL_MIN_MATCH) {
-        sdefl_fnd(&m, s, max_chain, max_match, in, i);
-      }
-      if (lvl >= 5 && m.len >= SDEFL_MIN_MATCH && m.len < nice_match){
-        struct sdefl_match m2 = {0};
-        sdefl_fnd(&m2, s, max_chain, m.len+1, in, i+1);
-        m.len = (m2.len > m.len) ? 0 : m.len;
-      }
-      if (m.len >= SDEFL_MIN_MATCH) {
-        if (litlen) {
-          sdefl_seq(s, i - litlen, litlen);
-          litlen = 0;
-        }
-        sdefl_seq(s, -m.off, m.len);
-        sdefl_reg_match(s, m.off, m.len);
-        if (lvl < 2 && m.len >= nice_match) {
-          inc = m.len;
-        } else {
-          run = m.len;
-        }
-      } else {
-        s->freq.lit[in[i]]++;
-        litlen++;
-      }
-      run_inc = run * inc;
-      if (in_len - (i + run_inc) > SDEFL_MIN_MATCH) {
-        while (run-- > 0) {
-          unsigned h = sdefl_hash32(&in[i]);
-          s->prv[i&SDEFL_WIN_MSK] = s->tbl[h];
-          s->tbl[h] = i, i += inc;
-        }
-      } else {
-        i += run_inc;
-      }
-    }
-    if (litlen) {
-      sdefl_seq(s, i - litlen, litlen);
-      litlen = 0;
-    }
-    sdefl_flush(&q, s, blk_end == in_len, in);
-  } while (i < in_len);
-
-  if (s->bitcnt)
-    sdefl_put(&q, s, 0x00, 8 - s->bitcnt);
-  return (int)(q - out);
-}
-extern int
-sdeflate(struct sdefl *s, void *out, const void *in, int n, int lvl) {
-  s->bits = s->bitcnt = 0;
-  return sdefl_compr(s, (unsigned char*)out, (const unsigned char*)in, n, lvl);
-}
-static unsigned
-sdefl_adler32(unsigned adler32, const unsigned char *in, int in_len) {
-  #define SDEFL_ADLER_INIT (1)
-  const unsigned ADLER_MOD = 65521;
-  unsigned s1 = adler32 & 0xffff;
-  unsigned s2 = adler32 >> 16;
-  unsigned blk_len, i;
-
-  blk_len = in_len % 5552;
-  while (in_len) {
-    for (i = 0; i + 7 < blk_len; i += 8) {
-      s1 += in[0]; s2 += s1;
-      s1 += in[1]; s2 += s1;
-      s1 += in[2]; s2 += s1;
-      s1 += in[3]; s2 += s1;
-      s1 += in[4]; s2 += s1;
-      s1 += in[5]; s2 += s1;
-      s1 += in[6]; s2 += s1;
-      s1 += in[7]; s2 += s1;
-      in += 8;
-    }
-    for (; i < blk_len; ++i) {
-      s1 += *in++, s2 += s1;
-    }
-    s1 %= ADLER_MOD;
-    s2 %= ADLER_MOD;
-    in_len -= blk_len;
-    blk_len = 5552;
-  }
-  return (unsigned)(s2 << 16) + (unsigned)s1;
-}
-extern int
-zsdeflate(struct sdefl *s, void *out, const void *in, int n, int lvl) {
-  int p = 0;
-  unsigned a = 0;
-  unsigned char *q = (unsigned char*)out;
-
-  s->bits = s->bitcnt = 0;
-  sdefl_put(&q, s, 0x78, 8); /* deflate, 32k window */
-  sdefl_put(&q, s, 0x01, 8); /* fast compression */
-  q += sdefl_compr(s, q, (const unsigned char*)in, n, lvl);
-
-  /* append adler checksum */
-  a = sdefl_adler32(SDEFL_ADLER_INIT, (const unsigned char*)in, n);
-  for (p = 0; p < 4; ++p) {
-    sdefl_put(&q, s, (a >> 24) & 0xFF, 8);
-    a <<= 8;
-  }
-  return (int)(q - (unsigned char*)out);
-}
-extern int
-sdefl_bound(int len) {
-  int a = 128 + (len * 110) / 100;
-  int b = 128 + len + ((len / (31 * 1024)) + 1) * 5;
-  return (a > b) ? a : b;
-}
-#endif /* SDEFL_IMPLEMENTATION */
-
diff --git a/raylib_pi4_test/external/sinfl.h b/raylib_pi4_test/external/sinfl.h
deleted file mode 100644 (file)
index 37c1aae..0000000
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
-# Small Deflate
-`sdefl` is a small bare bone lossless compression library in ANSI C (ISO C90)
-which implements the Deflate (RFC 1951) compressed data format specification standard.
-It is mainly tuned to get as much speed and compression ratio from as little code
-as needed to keep the implementation as concise as possible.
-
-## Features
-- Portable single header and source file duo written in ANSI C (ISO C90)
-- Dual license with either MIT or public domain
-- Small implementation
-    - Deflate: 525 LoC
-    - Inflate: 320 LoC
-- Webassembly:
-    - Deflate ~3.7 KB (~2.2KB compressed)
-    - Inflate ~3.6 KB (~2.2KB compressed)
-
-## Usage:
-This file behaves differently depending on what symbols you define
-before including it.
-
-Header-File mode:
-If you do not define `SINFL_IMPLEMENTATION` before including this file, it
-will operate in header only mode. In this mode it declares all used structs
-and the API of the library without including the implementation of the library.
-
-Implementation mode:
-If you define `SINFL_IMPLEMENTATION` before including this file, it will
-compile the implementation. Make sure that you only include
-this file implementation in *one* C or C++ file to prevent collisions.
-
-### Benchmark
-
-| Compressor name         | Compression| Decompress.| Compr. size | Ratio |
-| ------------------------| -----------| -----------| ----------- | ----- |
-| sdefl 1.0 -0            |   127 MB/s |   233 MB/s |    40004116 | 39.88 |
-| sdefl 1.0 -1            |   111 MB/s |   259 MB/s |    38940674 | 38.82 |
-| sdefl 1.0 -5            |    45 MB/s |   275 MB/s |    36577183 | 36.46 |
-| sdefl 1.0 -7            |    38 MB/s |   276 MB/s |    36523781 | 36.41 |
-| zlib 1.2.11 -1          |    72 MB/s |   307 MB/s |    42298774 | 42.30 |
-| zlib 1.2.11 -6          |    24 MB/s |   313 MB/s |    36548921 | 36.55 |
-| zlib 1.2.11 -9          |    20 MB/s |   314 MB/s |    36475792 | 36.48 |
-| miniz 1.0 -1            |   122 MB/s |   208 MB/s |    48510028 | 48.51 |
-| miniz 1.0 -6            |    27 MB/s |   260 MB/s |    36513697 | 36.51 |
-| miniz 1.0 -9            |    23 MB/s |   261 MB/s |    36460101 | 36.46 |
-| libdeflate 1.3 -1       |   147 MB/s |   667 MB/s |    39597378 | 39.60 |
-| libdeflate 1.3 -6       |    69 MB/s |   689 MB/s |    36648318 | 36.65 |
-| libdeflate 1.3 -9       |    13 MB/s |   672 MB/s |    35197141 | 35.20 |
-| libdeflate 1.3 -12      |  8.13 MB/s |   670 MB/s |    35100568 | 35.10 |
-
-### Compression
-Results on the [Silesia compression corpus](http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia):
-
-| File    |   Original | `sdefl 0`     | `sdefl 5`     | `sdefl 7` |
-| :------ | ---------: | -----------------: | ---------: | ----------: |
-| dickens | 10.192.446 |  4,260,187|  3,845,261|   3,833,657 |
-| mozilla | 51.220.480 | 20,774,706 | 19,607,009 |  19,565,867 |
-| mr      |  9.970.564 | 3,860,531 |  3,673,460 |   3,665,627 |
-| nci     | 33.553.445 | 4,030,283 |  3,094,526 |   3,006,075 |
-| ooffice |  6.152.192 | 3,320,063 |  3,186,373 |   3,183,815 |
-| osdb    | 10.085.684 | 3,919,646 |  3,649,510 |   3,649,477 |
-| reymont |  6.627.202 | 2,263,378 |  1,857,588 |   1,827,237 |
-| samba   | 21.606.400 | 6,121,797 |  5,462,670 |   5,450,762 |
-| sao     |  7.251.944 | 5,612,421 |  5,485,380 |   5,481,765 |
-| webster | 41.458.703 | 13,972,648 | 12,059,432 |  11,991,421 |
-| xml     |  5.345.280 | 886,620|    674,009 |     662,141 |
-| x-ray   |  8.474.240 | 6,304,655 |  6,244,779 |   6,244,779 |
-
-## License
-```
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2020 Micha Mettke
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-```
-*/
-#ifndef SINFL_H_INCLUDED
-#define SINFL_H_INCLUDED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SINFL_PRE_TBL_SIZE 128
-#define SINFL_LIT_TBL_SIZE 1334
-#define SINFL_OFF_TBL_SIZE 402
-
-struct sinfl {
-  int bits, bitcnt;
-  unsigned lits[SINFL_LIT_TBL_SIZE];
-  unsigned dsts[SINFL_OFF_TBL_SIZE];
-};
-extern int sinflate(void *out, const void *in, int size);
-extern int zsinflate(void *out, const void *in, int size);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SINFL_H_INCLUDED */
-
-#ifdef SINFL_IMPLEMENTATION
-
-#include <string.h> /* memcpy, memset */
-
-static int
-sinfl_bsr(unsigned n) {
-#ifdef _MSC_VER
-  _BitScanReverse(&n, n);
-  return n;
-#elif defined(__GNUC__) || defined(__clang__)
-  return 31 - __builtin_clz(n);
-#endif
-}
-static int
-sinfl_get(const unsigned char **src, const unsigned char *end, struct sinfl *s,
-          int n) {
-  const unsigned char *in = *src;
-  int v = s->bits & ((1 << n)-1);
-  s->bits >>= n;
-  s->bitcnt = s->bitcnt - n;
-  s->bitcnt = s->bitcnt < 0 ? 0 : s->bitcnt;
-  while (s->bitcnt < 16 && in < end) {
-    s->bits |= (*in++) << s->bitcnt;
-    s->bitcnt += 8;
-  }
-  *src = in;
-  return v;
-}
-struct sinfl_gen {
-  int len;
-  int cnt;
-  int word;
-  short* sorted;
-};
-static int
-sinfl_build_tbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
-                const int *cnt) {
-  int tbl_end = 0;
-  while (!(gen->cnt = cnt[gen->len])) {
-    ++gen->len;
-  }
-  tbl_end = 1 << gen->len;
-  while (gen->len <= tbl_bits) {
-    do {unsigned bit = 0;
-      tbl[gen->word] = (*gen->sorted++ << 16) | gen->len;
-      if (gen->word == tbl_end - 1) {
-        for (; gen->len < tbl_bits; gen->len++) {
-          memcpy(&tbl[tbl_end], tbl, (size_t)tbl_end * sizeof(tbl[0]));
-          tbl_end <<= 1;
-        }
-        return 1;
-      }
-      bit = 1 << sinfl_bsr((unsigned)(gen->word ^ (tbl_end - 1)));
-      gen->word &= bit - 1;
-      gen->word |= bit;
-    } while (--gen->cnt);
-    do {
-      if (++gen->len <= tbl_bits) {
-        memcpy(&tbl[tbl_end], tbl, (size_t)tbl_end * sizeof(tbl[0]));
-        tbl_end <<= 1;
-      }
-    } while (!(gen->cnt = cnt[gen->len]));
-  }
-  return 0;
-}
-static void
-sinfl_build_subtbl(struct sinfl_gen *gen, unsigned *tbl, int tbl_bits,
-                   const int *cnt) {
-  int sub_bits = 0;
-  int sub_start = 0;
-  int sub_prefix = -1;
-  int tbl_end = 1 << tbl_bits;
-  while (1) {
-    unsigned entry;
-    int bit, stride, i;
-    /* start new subtable */
-    if ((gen->word & ((1 << tbl_bits)-1)) != sub_prefix) {
-      int used = 0;
-      sub_prefix = gen->word & ((1 << tbl_bits)-1);
-      sub_start = tbl_end;
-      sub_bits = gen->len - tbl_bits;
-      used = gen->cnt;
-      while (used < (1 << sub_bits)) {
-        sub_bits++;
-        used = (used << 1) + cnt[tbl_bits + sub_bits];
-      }
-      tbl_end = sub_start + (1 << sub_bits);
-      tbl[sub_prefix] = (sub_start << 16) | 0x10 | (sub_bits & 0xf);
-    }
-    /* fill subtable */
-    entry = (*gen->sorted << 16) | ((gen->len - tbl_bits) & 0xf);
-    gen->sorted++;
-    i = sub_start + (gen->word >> tbl_bits);
-    stride = 1 << (gen->len - tbl_bits);
-    do {
-      tbl[i] = entry;
-      i += stride;
-    } while (i < tbl_end);
-    if (gen->word == (1 << gen->len)-1) {
-      return;
-    }
-    bit = 1 << sinfl_bsr(gen->word ^ ((1 << gen->len) - 1));
-    gen->word &= bit - 1;
-    gen->word |= bit;
-    gen->cnt--;
-    while (!gen->cnt) {
-      gen->cnt = cnt[++gen->len];
-    }
-  }
-}
-static void
-sinfl_build(unsigned *tbl, unsigned char *lens, int tbl_bits, int maxlen,
-            int symcnt) {
-  int i, used = 0;
-  short sort[288];
-  int cnt[16] = {0}, off[16]= {0};
-  struct sinfl_gen gen = {0};
-  gen.sorted = sort;
-  gen.len = 1;
-
-  for (i = 0; i < symcnt; ++i)
-    cnt[lens[i]]++;
-  off[1] = cnt[0];
-  for (i = 1; i < maxlen; ++i) {
-    off[i + 1] = off[i] + cnt[i];
-    used = (used << 1) + cnt[i];
-  }
-  used = (used << 1) + cnt[i];
-  for (i = 0; i < symcnt; ++i)
-    gen.sorted[off[lens[i]]++] = (short)i;
-  gen.sorted += off[0];
-
-  if (used < (1 << maxlen)){
-    for (i = 0; i < 1 << tbl_bits; ++i)
-      tbl[i] = (0 << 16u) | 1;
-    return;
-  }
-  if (!sinfl_build_tbl(&gen, tbl, tbl_bits, cnt)){
-    sinfl_build_subtbl(&gen, tbl, tbl_bits, cnt);
-  }
-}
-static int
-sinfl_decode(const unsigned char **in, const unsigned char *end,
-             struct sinfl *s, const unsigned *tbl, int bit_len) {
-  int idx = s->bits & ((1 << bit_len) - 1);
-  unsigned key = tbl[idx];
-  if (key & 0x10) {
-    /* sub-table lookup */
-    int len = key & 0x0f;
-    sinfl_get(in, end, s, bit_len);
-    idx = s->bits & ((1 << len)-1);
-    key = tbl[((key >> 16) & 0xffff) + (unsigned)idx];
-  }
-  sinfl_get(in, end, s, key & 0x0f);
-  return (key >> 16) & 0x0fff;
-}
-static int
-sinfl_decompress(unsigned char *out, const unsigned char *in, int size) {
-  static const unsigned char order[] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-  static const short dbase[30+2] = {1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,
-      257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577};
-  static const unsigned char dbits[30+2] = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,
-      10,10,11,11,12,12,13,13,0,0};
-  static const short lbase[29+2] = {3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,
-      43,51,59,67,83,99,115,131,163,195,227,258,0,0};
-  static const unsigned char lbits[29+2] = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,
-      4,4,4,5,5,5,5,0,0,0};
-
-  const unsigned char *e = in + size, *o = out;
-  enum sinfl_states {hdr,stored,fixed,dyn,blk};
-  enum sinfl_states state = hdr;
-  struct sinfl s = {0};
-  int last = 0;
-
-  sinfl_get(&in,e,&s,0); /* buffer input */
-  while (in < e || s.bitcnt) {
-    switch (state) {
-    case hdr: {
-      int type = 0; /* block header */
-      last = sinfl_get(&in,e,&s,1);
-      type = sinfl_get(&in,e,&s,2);
-
-      switch (type) {default: return (int)(out-o);
-      case 0x00: state = stored; break;
-      case 0x01: state = fixed; break;
-      case 0x02: state = dyn; break;}
-    } break;
-    case stored: {
-      int len; /* uncompressed block */
-      sinfl_get(&in,e,&s,s.bitcnt & 7);
-      len = sinfl_get(&in,e,&s,16);
-      //int nlen = sinfl_get(&in,e,&s,16);
-      in -= 2; s.bitcnt = 0;
-
-      if (len > (e-in) || !len)
-        return (int)(out-o);
-      memcpy(out, in, (size_t)len);
-      in += len, out += len;
-      state = hdr;
-    } break;
-    case fixed: {
-      /* fixed huffman codes */
-      int n; unsigned char lens[288+32];
-      for (n = 0; n <= 143; n++) lens[n] = 8;
-      for (n = 144; n <= 255; n++) lens[n] = 9;
-      for (n = 256; n <= 279; n++) lens[n] = 7;
-      for (n = 280; n <= 287; n++) lens[n] = 8;
-      for (n = 0; n < 32; n++) lens[288+n] = 5;
-
-      /* build lit/dist tables */
-      sinfl_build(s.lits, lens, 10, 15, 288);
-      sinfl_build(s.dsts, lens + 288, 8, 15, 32);
-      state = blk;
-    } break;
-    case dyn: {
-        /* dynamic huffman codes */
-        int n, i;
-        unsigned hlens[SINFL_PRE_TBL_SIZE];
-        unsigned char nlens[19] = {0}, lens[288+32];
-        int nlit = 257 + sinfl_get(&in,e,&s,5);
-        int ndist = 1 + sinfl_get(&in,e,&s,5);
-        int nlen = 4 + sinfl_get(&in,e,&s,4);
-        for (n = 0; n < nlen; n++)
-          nlens[order[n]] = (unsigned char)sinfl_get(&in,e,&s,3);
-        sinfl_build(hlens, nlens, 7, 7, 19);
-
-        /* decode code lengths */
-        for (n = 0; n < nlit + ndist;) {
-          int sym = sinfl_decode(&in, e, &s, hlens, 7);
-          switch (sym) {default: lens[n++] = (unsigned char)sym; break;
-          case 16: for (i=3+sinfl_get(&in,e,&s,2);i;i--,n++) lens[n]=lens[n-1]; break;
-          case 17: for (i=3+sinfl_get(&in,e,&s,3);i;i--,n++) lens[n]=0; break;
-          case 18: for (i=11+sinfl_get(&in,e,&s,7);i;i--,n++) lens[n]=0; break;}
-        }
-        /* build lit/dist tables */
-        sinfl_build(s.lits, lens, 10, 15, nlit);
-        sinfl_build(s.dsts, lens + nlit, 8, 15, ndist);
-        state = blk;
-    } break;
-    case blk: {
-      /* decompress block */
-      int i, sym = sinfl_decode(&in, e, &s, s.lits, 10);
-      if (sym > 256) {sym -= 257; /* match symbol */
-        {int len = sinfl_get(&in, e, &s, lbits[sym]) + lbase[sym];
-        int dsym = sinfl_decode(&in, e, &s, s.dsts, 8);
-        int offs = sinfl_get(&in, e, &s, dbits[dsym]) + dbase[dsym];
-        if (offs > (int)(out-o)) {
-          return (int)(out-o);
-        } else if (offs == 1) {
-          /* rle match copying */
-          unsigned char c = *(out - offs);
-          unsigned long w = (c << 24) | (c << 16) | (c << 8) | c;
-          for (i = 0; i < len >> 2; ++i) {
-            memcpy(out, &w, 4);
-            out += 4;
-          }
-          len = len & 3;
-        } else if (offs >= 4) {
-          /* copy match */
-          int wcnt = len >> 2;
-          for (i = 0; i < wcnt; ++i) {
-            unsigned long w = 0;
-            memcpy(&w, out - offs, 4);
-            memcpy(out, &w, 4);
-            out += 4;
-          }
-          len = len & 3;
-        }
-        for (i = 0; i < len; ++i)
-          {*out = *(out-offs), out++;}
-        }
-      } else if (sym == 256) {
-        /* end of block */
-        if (last) return (int)(out-o);
-        state = hdr;
-        break;
-        /* literal */
-      } else *out++ = (unsigned char)sym;
-    } break;}
-  }
-  return (int)(out-o);
-}
-extern int
-sinflate(void *out, const void *in, int size) {
-  return sinfl_decompress((unsigned char*)out, (const unsigned char*)in, size);
-}
-static unsigned
-sinfl_adler32(unsigned adler32, const unsigned char *in, int in_len) {
-  const unsigned ADLER_MOD = 65521;
-  unsigned s1 = adler32 & 0xffff;
-  unsigned s2 = adler32 >> 16;
-  unsigned blk_len, i;
-
-  blk_len = in_len % 5552;
-  while (in_len) {
-    for (i=0; i + 7 < blk_len; i += 8) {
-      s1 += in[0]; s2 += s1;
-      s1 += in[1]; s2 += s1;
-      s1 += in[2]; s2 += s1;
-      s1 += in[3]; s2 += s1;
-      s1 += in[4]; s2 += s1;
-      s1 += in[5]; s2 += s1;
-      s1 += in[6]; s2 += s1;
-      s1 += in[7]; s2 += s1;
-      in += 8;
-    }
-    for (; i < blk_len; ++i)
-      s1 += *in++, s2 += s1;
-    s1 %= ADLER_MOD; s2 %= ADLER_MOD;
-    in_len -= blk_len;
-    blk_len = 5552;
-  } return (unsigned)(s2 << 16) + (unsigned)s1;
-}
-extern int
-zsinflate(void *out, const void *mem, int size) {
-  const unsigned char *in = (const unsigned char*)mem;
-  if (size >= 6) {
-    const unsigned char *eob = in + size - 4;
-    int n = sinfl_decompress((unsigned char*)out, in + 2u, size);
-    unsigned a = sinfl_adler32(1u, (unsigned char*)out, n);
-    unsigned h = eob[0] << 24 | eob[1] << 16 | eob[2] << 8 | eob[3] << 0;
-    return a == h ? n : -1;
-  } else {
-    return -1;
-  }
-}
-#endif
-
diff --git a/raylib_pi4_test/external/stb_image.h b/raylib_pi4_test/external/stb_image.h
deleted file mode 100644 (file)
index accef48..0000000
+++ /dev/null
@@ -1,7762 +0,0 @@
-/* stb_image - v2.26 - public domain image loader - http://nothings.org/stb
-                                  no warranty implied; use at your own risk
-
-   Do this:
-      #define STB_IMAGE_IMPLEMENTATION
-   before you include this file in *one* C or C++ file to create the implementation.
-
-   // i.e. it should look like this:
-   #include ...
-   #include ...
-   #include ...
-   #define STB_IMAGE_IMPLEMENTATION
-   #include "stb_image.h"
-
-   You can #define STBI_ASSERT(x) before the #include to avoid using assert.h.
-   And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free
-
-
-   QUICK NOTES:
-      Primarily of interest to game developers and other people who can
-          avoid problematic images and only need the trivial interface
-
-      JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)
-      PNG 1/2/4/8/16-bit-per-channel
-
-      TGA (not sure what subset, if a subset)
-      BMP non-1bpp, non-RLE
-      PSD (composited view only, no extra channels, 8/16 bit-per-channel)
-
-      GIF (*comp always reports as 4-channel)
-      HDR (radiance rgbE format)
-      PIC (Softimage PIC)
-      PNM (PPM and PGM binary only)
-
-      Animated GIF still needs a proper API, but here's one way to do it:
-          http://gist.github.com/urraka/685d9a6340b26b830d49
-
-      - decode from memory or through FILE (define STBI_NO_STDIO to remove code)
-      - decode from arbitrary I/O callbacks
-      - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON)
-
-   Full documentation under "DOCUMENTATION" below.
-
-
-LICENSE
-
-  See end of file for license information.
-
-RECENT REVISION HISTORY:
-
-      2.26  (2020-07-13) many minor fixes
-      2.25  (2020-02-02) fix warnings
-      2.24  (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically
-      2.23  (2019-08-11) fix clang static analysis warning
-      2.22  (2019-03-04) gif fixes, fix warnings
-      2.21  (2019-02-25) fix typo in comment
-      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
-      2.19  (2018-02-11) fix warning
-      2.18  (2018-01-30) fix warnings
-      2.17  (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings
-      2.16  (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes
-      2.15  (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC
-      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
-      2.13  (2016-12-04) experimental 16-bit API, only for PNG so far; fixes
-      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
-      2.11  (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64
-                         RGB-format JPEG; remove white matting in PSD;
-                         allocate large structures on the stack;
-                         correct channel count for PNG & BMP
-      2.10  (2016-01-22) avoid warning introduced in 2.09
-      2.09  (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED
-
-   See end of file for full revision history.
-
-
- ============================    Contributors    =========================
-
- Image formats                          Extensions, features
-    Sean Barrett (jpeg, png, bmp)          Jetro Lauha (stbi_info)
-    Nicolas Schulz (hdr, psd)              Martin "SpartanJ" Golini (stbi_info)
-    Jonathan Dummer (tga)                  James "moose2000" Brown (iPhone PNG)
-    Jean-Marc Lienher (gif)                Ben "Disch" Wenger (io callbacks)
-    Tom Seddon (pic)                       Omar Cornut (1/2/4-bit PNG)
-    Thatcher Ulrich (psd)                  Nicolas Guillemot (vertical flip)
-    Ken Miller (pgm, ppm)                  Richard Mitton (16-bit PSD)
-    github:urraka (animated gif)           Junggon Kim (PNM comments)
-    Christopher Forseth (animated gif)     Daniel Gibson (16-bit TGA)
-                                           socks-the-fox (16-bit PNG)
-                                           Jeremy Sawicki (handle all ImageNet JPGs)
- Optimizations & bugfixes                  Mikhail Morozov (1-bit BMP)
-    Fabian "ryg" Giesen                    Anael Seghezzi (is-16-bit query)
-    Arseny Kapoulkine
-    John-Mark Allen
-    Carmelo J Fdez-Aguera
-
- Bug & warning fixes
-    Marc LeBlanc            David Woo          Guillaume George     Martins Mozeiko
-    Christpher Lloyd        Jerry Jansson      Joseph Thomson       Blazej Dariusz Roszkowski
-    Phil Jordan                                Dave Moore           Roy Eltham
-    Hayaki Saito            Nathan Reed        Won Chun
-    Luke Graham             Johan Duparc       Nick Verigakis       the Horde3D community
-    Thomas Ruf              Ronny Chevalier                         github:rlyeh
-    Janez Zemva             John Bartholomew   Michal Cichon        github:romigrou
-    Jonathan Blow           Ken Hamada         Tero Hanninen        github:svdijk
-                            Laurent Gomila     Cort Stratton        github:snagar
-    Aruelien Pocheville     Sergio Gonzalez    Thibault Reuille     github:Zelex
-    Cass Everitt            Ryamond Barbiero                        github:grim210
-    Paul Du Bois            Engin Manap        Aldo Culquicondor    github:sammyhw
-    Philipp Wiesemann       Dale Weiler        Oriol Ferrer Mesia   github:phprus
-    Josh Tobin                                 Matthew Gregan       github:poppolopoppo
-    Julian Raschke          Gregory Mullen     Christian Floisand   github:darealshinji
-    Baldur Karlsson         Kevin Schmidt      JR Smith             github:Michaelangel007
-                            Brad Weinberger    Matvey Cherevko      [reserved]
-    Luca Sas                Alexander Veselov  Zack Middleton       [reserved]
-    Ryan C. Gordon          [reserved]                              [reserved]
-                     DO NOT ADD YOUR NAME HERE
-
-  To add your name to the credits, pick a random blank space in the middle and fill it.
-  80% of merge conflicts on stb PRs are due to people adding their name at the end
-  of the credits.
-*/
-
-#ifndef STBI_INCLUDE_STB_IMAGE_H
-#define STBI_INCLUDE_STB_IMAGE_H
-
-// DOCUMENTATION
-//
-// Limitations:
-//    - no 12-bit-per-channel JPEG
-//    - no JPEGs with arithmetic coding
-//    - GIF always returns *comp=4
-//
-// Basic usage (see HDR discussion below for HDR usage):
-//    int x,y,n;
-//    unsigned char *data = stbi_load(filename, &x, &y, &n, 0);
-//    // ... process data if not NULL ...
-//    // ... x = width, y = height, n = # 8-bit components per pixel ...
-//    // ... replace '0' with '1'..'4' to force that many components per pixel
-//    // ... but 'n' will always be the number that it would have been if you said 0
-//    stbi_image_free(data)
-//
-// Standard parameters:
-//    int *x                 -- outputs image width in pixels
-//    int *y                 -- outputs image height in pixels
-//    int *channels_in_file  -- outputs # of image components in image file
-//    int desired_channels   -- if non-zero, # of image components requested in result
-//
-// The return value from an image loader is an 'unsigned char *' which points
-// to the pixel data, or NULL on an allocation failure or if the image is
-// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels,
-// with each pixel consisting of N interleaved 8-bit components; the first
-// pixel pointed to is top-left-most in the image. There is no padding between
-// image scanlines or between pixels, regardless of format. The number of
-// components N is 'desired_channels' if desired_channels is non-zero, or
-// *channels_in_file otherwise. If desired_channels is non-zero,
-// *channels_in_file has the number of components that _would_ have been
-// output otherwise. E.g. if you set desired_channels to 4, you will always
-// get RGBA output, but you can check *channels_in_file to see if it's trivially
-// opaque because e.g. there were only 3 channels in the source image.
-//
-// An output image with N components has the following components interleaved
-// in this order in each pixel:
-//
-//     N=#comp     components
-//       1           grey
-//       2           grey, alpha
-//       3           red, green, blue
-//       4           red, green, blue, alpha
-//
-// If image loading fails for any reason, the return value will be NULL,
-// and *x, *y, *channels_in_file will be unchanged. The function
-// stbi_failure_reason() can be queried for an extremely brief, end-user
-// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS
-// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly
-// more user-friendly ones.
-//
-// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.
-//
-// ===========================================================================
-//
-// UNICODE:
-//
-//   If compiling for Windows and you wish to use Unicode filenames, compile
-//   with
-//       #define STBI_WINDOWS_UTF8
-//   and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert
-//   Windows wchar_t filenames to utf8.
-//
-// ===========================================================================
-//
-// Philosophy
-//
-// stb libraries are designed with the following priorities:
-//
-//    1. easy to use
-//    2. easy to maintain
-//    3. good performance
-//
-// Sometimes I let "good performance" creep up in priority over "easy to maintain",
-// and for best performance I may provide less-easy-to-use APIs that give higher
-// performance, in addition to the easy-to-use ones. Nevertheless, it's important
-// to keep in mind that from the standpoint of you, a client of this library,
-// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all.
-//
-// Some secondary priorities arise directly from the first two, some of which
-// provide more explicit reasons why performance can't be emphasized.
-//
-//    - Portable ("ease of use")
-//    - Small source code footprint ("easy to maintain")
-//    - No dependencies ("ease of use")
-//
-// ===========================================================================
-//
-// I/O callbacks
-//
-// I/O callbacks allow you to read from arbitrary sources, like packaged
-// files or some other source. Data read from callbacks are processed
-// through a small internal buffer (currently 128 bytes) to try to reduce
-// overhead.
-//
-// The three functions you must define are "read" (reads some bytes of data),
-// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end).
-//
-// ===========================================================================
-//
-// SIMD support
-//
-// The JPEG decoder will try to automatically use SIMD kernels on x86 when
-// supported by the compiler. For ARM Neon support, you must explicitly
-// request it.
-//
-// (The old do-it-yourself SIMD API is no longer supported in the current
-// code.)
-//
-// On x86, SSE2 will automatically be used when available based on a run-time
-// test; if not, the generic C versions are used as a fall-back. On ARM targets,
-// the typical path is to have separate builds for NEON and non-NEON devices
-// (at least this is true for iOS and Android). Therefore, the NEON support is
-// toggled by a build flag: define STBI_NEON to get NEON loops.
-//
-// If for some reason you do not want to use any of SIMD code, or if
-// you have issues compiling it, you can disable it entirely by
-// defining STBI_NO_SIMD.
-//
-// ===========================================================================
-//
-// HDR image support   (disable by defining STBI_NO_HDR)
-//
-// stb_image supports loading HDR images in general, and currently the Radiance
-// .HDR file format specifically. You can still load any file through the existing
-// interface; if you attempt to load an HDR file, it will be automatically remapped
-// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;
-// both of these constants can be reconfigured through this interface:
-//
-//     stbi_hdr_to_ldr_gamma(2.2f);
-//     stbi_hdr_to_ldr_scale(1.0f);
-//
-// (note, do not use _inverse_ constants; stbi_image will invert them
-// appropriately).
-//
-// Additionally, there is a new, parallel interface for loading files as
-// (linear) floats to preserve the full dynamic range:
-//
-//    float *data = stbi_loadf(filename, &x, &y, &n, 0);
-//
-// If you load LDR images through this interface, those images will
-// be promoted to floating point values, run through the inverse of
-// constants corresponding to the above:
-//
-//     stbi_ldr_to_hdr_scale(1.0f);
-//     stbi_ldr_to_hdr_gamma(2.2f);
-//
-// Finally, given a filename (or an open file or memory block--see header
-// file for details) containing image data, you can query for the "most
-// appropriate" interface to use (that is, whether the image is HDR or
-// not), using:
-//
-//     stbi_is_hdr(char *filename);
-//
-// ===========================================================================
-//
-// iPhone PNG support:
-//
-// By default we convert iphone-formatted PNGs back to RGB, even though
-// they are internally encoded differently. You can disable this conversion
-// by calling stbi_convert_iphone_png_to_rgb(0), in which case
-// you will always just get the native iphone "format" through (which
-// is BGR stored in RGB).
-//
-// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per
-// pixel to remove any premultiplied alpha *only* if the image file explicitly
-// says there's premultiplied data (currently only happens in iPhone images,
-// and only if iPhone convert-to-rgb processing is on).
-//
-// ===========================================================================
-//
-// ADDITIONAL CONFIGURATION
-//
-//  - You can suppress implementation of any of the decoders to reduce
-//    your code footprint by #defining one or more of the following
-//    symbols before creating the implementation.
-//
-//        STBI_NO_JPEG
-//        STBI_NO_PNG
-//        STBI_NO_BMP
-//        STBI_NO_PSD
-//        STBI_NO_TGA
-//        STBI_NO_GIF
-//        STBI_NO_HDR
-//        STBI_NO_PIC
-//        STBI_NO_PNM   (.ppm and .pgm)
-//
-//  - You can request *only* certain decoders and suppress all other ones
-//    (this will be more forward-compatible, as addition of new decoders
-//    doesn't require you to disable them explicitly):
-//
-//        STBI_ONLY_JPEG
-//        STBI_ONLY_PNG
-//        STBI_ONLY_BMP
-//        STBI_ONLY_PSD
-//        STBI_ONLY_TGA
-//        STBI_ONLY_GIF
-//        STBI_ONLY_HDR
-//        STBI_ONLY_PIC
-//        STBI_ONLY_PNM   (.ppm and .pgm)
-//
-//   - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still
-//     want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB
-//
-//  - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater
-//    than that size (in either width or height) without further processing.
-//    This is to let programs in the wild set an upper bound to prevent
-//    denial-of-service attacks on untrusted data, as one could generate a
-//    valid image of gigantic dimensions and force stb_image to allocate a
-//    huge block of memory and spend disproportionate time decoding it. By
-//    default this is set to (1 << 24), which is 16777216, but that's still
-//    very big.
-
-#ifndef STBI_NO_STDIO
-#include <stdio.h>
-#endif // STBI_NO_STDIO
-
-#define STBI_VERSION 1
-
-enum
-{
-   STBI_default = 0, // only used for desired_channels
-
-   STBI_grey       = 1,
-   STBI_grey_alpha = 2,
-   STBI_rgb        = 3,
-   STBI_rgb_alpha  = 4
-};
-
-#include <stdlib.h>
-typedef unsigned char stbi_uc;
-typedef unsigned short stbi_us;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef STBIDEF
-#ifdef STB_IMAGE_STATIC
-#define STBIDEF static
-#else
-#define STBIDEF extern
-#endif
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// PRIMARY API - works on images of any type
-//
-
-//
-// load image by filename, open file, or memory buffer
-//
-
-typedef struct
-{
-   int      (*read)  (void *user,char *data,int size);   // fill 'data' with 'size' bytes.  return number of bytes actually read
-   void     (*skip)  (void *user,int n);                 // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
-   int      (*eof)   (void *user);                       // returns nonzero if we are at end of file/data
-} stbi_io_callbacks;
-
-////////////////////////////////////
-//
-// 8-bits-per-channel interface
-//
-
-STBIDEF stbi_uc *stbi_load_from_memory   (stbi_uc           const *buffer, int len   , int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk  , void *user, int *x, int *y, int *channels_in_file, int desired_channels);
-
-#ifndef STBI_NO_STDIO
-STBIDEF stbi_uc *stbi_load            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_uc *stbi_load_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-// for stbi_load_from_file, file pointer is left pointing immediately after image
-#endif
-
-#ifndef STBI_NO_GIF
-STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
-#endif
-
-#ifdef STBI_WINDOWS_UTF8
-STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
-#endif
-
-////////////////////////////////////
-//
-// 16-bits-per-channel interface
-//
-
-STBIDEF stbi_us *stbi_load_16_from_memory   (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels);
-
-#ifndef STBI_NO_STDIO
-STBIDEF stbi_us *stbi_load_16          (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-#endif
-
-////////////////////////////////////
-//
-// float-per-channel interface
-//
-#ifndef STBI_NO_LINEAR
-   STBIDEF float *stbi_loadf_from_memory     (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);
-   STBIDEF float *stbi_loadf_from_callbacks  (stbi_io_callbacks const *clbk, void *user, int *x, int *y,  int *channels_in_file, int desired_channels);
-
-   #ifndef STBI_NO_STDIO
-   STBIDEF float *stbi_loadf            (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);
-   STBIDEF float *stbi_loadf_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);
-   #endif
-#endif
-
-#ifndef STBI_NO_HDR
-   STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma);
-   STBIDEF void   stbi_hdr_to_ldr_scale(float scale);
-#endif // STBI_NO_HDR
-
-#ifndef STBI_NO_LINEAR
-   STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma);
-   STBIDEF void   stbi_ldr_to_hdr_scale(float scale);
-#endif // STBI_NO_LINEAR
-
-// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
-STBIDEF int    stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);
-STBIDEF int    stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_is_hdr          (char const *filename);
-STBIDEF int      stbi_is_hdr_from_file(FILE *f);
-#endif // STBI_NO_STDIO
-
-
-// get a VERY brief reason for failure
-// on most compilers (and ALL modern mainstream compilers) this is threadsafe
-STBIDEF const char *stbi_failure_reason  (void);
-
-// free the loaded image -- this is just free()
-STBIDEF void     stbi_image_free      (void *retval_from_stbi_load);
-
-// get image dimensions & components without fully decoding
-STBIDEF int      stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);
-STBIDEF int      stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);
-STBIDEF int      stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len);
-STBIDEF int      stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user);
-
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_info               (char const *filename,     int *x, int *y, int *comp);
-STBIDEF int      stbi_info_from_file     (FILE *f,                  int *x, int *y, int *comp);
-STBIDEF int      stbi_is_16_bit          (char const *filename);
-STBIDEF int      stbi_is_16_bit_from_file(FILE *f);
-#endif
-
-
-
-// for image formats that explicitly notate that they have premultiplied alpha,
-// we just return the colors as stored in the file. set this flag to force
-// unpremultiplication. results are undefined if the unpremultiply overflow.
-STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
-
-// indicate whether we should process iphone images back to canonical format,
-// or just pass them through "as-is"
-STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);
-
-// flip the image vertically, so the first pixel in the output array is the bottom left
-STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);
-
-// as above, but only applies to images loaded on the thread that calls the function
-// this function is only available if your compiler supports thread-local variables;
-// calling it will fail to link if your compiler doesn't
-STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
-
-// ZLIB client - used by PNG, available for other purposes
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
-STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);
-STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);
-STBIDEF int   stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
-
-STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);
-STBIDEF int   stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-//
-//
-////   end header file   /////////////////////////////////////////////////////
-#endif // STBI_INCLUDE_STB_IMAGE_H
-
-#ifdef STB_IMAGE_IMPLEMENTATION
-
-#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \
-  || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \
-  || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \
-  || defined(STBI_ONLY_ZLIB)
-   #ifndef STBI_ONLY_JPEG
-   #define STBI_NO_JPEG
-   #endif
-   #ifndef STBI_ONLY_PNG
-   #define STBI_NO_PNG
-   #endif
-   #ifndef STBI_ONLY_BMP
-   #define STBI_NO_BMP
-   #endif
-   #ifndef STBI_ONLY_PSD
-   #define STBI_NO_PSD
-   #endif
-   #ifndef STBI_ONLY_TGA
-   #define STBI_NO_TGA
-   #endif
-   #ifndef STBI_ONLY_GIF
-   #define STBI_NO_GIF
-   #endif
-   #ifndef STBI_ONLY_HDR
-   #define STBI_NO_HDR
-   #endif
-   #ifndef STBI_ONLY_PIC
-   #define STBI_NO_PIC
-   #endif
-   #ifndef STBI_ONLY_PNM
-   #define STBI_NO_PNM
-   #endif
-#endif
-
-#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB)
-#define STBI_NO_ZLIB
-#endif
-
-
-#include <stdarg.h>
-#include <stddef.h> // ptrdiff_t on osx
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-#include <math.h>  // ldexp, pow
-#endif
-
-#ifndef STBI_NO_STDIO
-#include <stdio.h>
-#endif
-
-#ifndef STBI_ASSERT
-#include <assert.h>
-#define STBI_ASSERT(x) assert(x)
-#endif
-
-#ifdef __cplusplus
-#define STBI_EXTERN extern "C"
-#else
-#define STBI_EXTERN extern
-#endif
-
-
-#ifndef _MSC_VER
-   #ifdef __cplusplus
-   #define stbi_inline inline
-   #else
-   #define stbi_inline
-   #endif
-#else
-   #define stbi_inline __forceinline
-#endif
-
-#ifndef STBI_NO_THREAD_LOCALS
-   #if defined(__cplusplus) &&  __cplusplus >= 201103L
-      #define STBI_THREAD_LOCAL       thread_local
-   #elif defined(__GNUC__) && __GNUC__ < 5
-      #define STBI_THREAD_LOCAL       __thread
-   #elif defined(_MSC_VER)
-      #define STBI_THREAD_LOCAL       __declspec(thread)
-   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
-      #define STBI_THREAD_LOCAL       _Thread_local
-   #endif
-
-   #ifndef STBI_THREAD_LOCAL
-      #if defined(__GNUC__)
-        #define STBI_THREAD_LOCAL       __thread
-      #endif
-   #endif
-#endif
-
-#ifdef _MSC_VER
-typedef unsigned short stbi__uint16;
-typedef   signed short stbi__int16;
-typedef unsigned int   stbi__uint32;
-typedef   signed int   stbi__int32;
-#else
-#include <stdint.h>
-typedef uint16_t stbi__uint16;
-typedef int16_t  stbi__int16;
-typedef uint32_t stbi__uint32;
-typedef int32_t  stbi__int32;
-#endif
-
-// should produce compiler error if size is wrong
-typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];
-
-#ifdef _MSC_VER
-#define STBI_NOTUSED(v)  (void)(v)
-#else
-#define STBI_NOTUSED(v)  (void)sizeof(v)
-#endif
-
-#ifdef _MSC_VER
-#define STBI_HAS_LROTL
-#endif
-
-#ifdef STBI_HAS_LROTL
-   #define stbi_lrot(x,y)  _lrotl(x,y)
-#else
-   #define stbi_lrot(x,y)  (((x) << (y)) | ((x) >> (32 - (y))))
-#endif
-
-#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))
-// ok
-#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED)
-// ok
-#else
-#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)."
-#endif
-
-#ifndef STBI_MALLOC
-#define STBI_MALLOC(sz)           malloc(sz)
-#define STBI_REALLOC(p,newsz)     realloc(p,newsz)
-#define STBI_FREE(p)              free(p)
-#endif
-
-#ifndef STBI_REALLOC_SIZED
-#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz)
-#endif
-
-// x86/x64 detection
-#if defined(__x86_64__) || defined(_M_X64)
-#define STBI__X64_TARGET
-#elif defined(__i386) || defined(_M_IX86)
-#define STBI__X86_TARGET
-#endif
-
-#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)
-// gcc doesn't support sse2 intrinsics unless you compile with -msse2,
-// which in turn means it gets to use SSE2 everywhere. This is unfortunate,
-// but previous attempts to provide the SSE2 functions with runtime
-// detection caused numerous issues. The way architecture extensions are
-// exposed in GCC/Clang is, sadly, not really suited for one-file libs.
-// New behavior: if compiled with -msse2, we use SSE2 without any
-// detection; if not, we don't use it at all.
-#define STBI_NO_SIMD
-#endif
-
-#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)
-// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET
-//
-// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the
-// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.
-// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not
-// simultaneously enabling "-mstackrealign".
-//
-// See https://github.com/nothings/stb/issues/81 for more information.
-//
-// So default to no SSE2 on 32-bit MinGW. If you've read this far and added
-// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.
-#define STBI_NO_SIMD
-#endif
-
-#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET))
-#define STBI_SSE2
-#include <emmintrin.h>
-
-#ifdef _MSC_VER
-
-#if _MSC_VER >= 1400  // not VC6
-#include <intrin.h> // __cpuid
-static int stbi__cpuid3(void)
-{
-   int info[4];
-   __cpuid(info,1);
-   return info[3];
-}
-#else
-static int stbi__cpuid3(void)
-{
-   int res;
-   __asm {
-      mov  eax,1
-      cpuid
-      mov  res,edx
-   }
-   return res;
-}
-#endif
-
-#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name
-
-#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
-static int stbi__sse2_available(void)
-{
-   int info3 = stbi__cpuid3();
-   return ((info3 >> 26) & 1) != 0;
-}
-#endif
-
-#else // assume GCC-style if not VC++
-#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
-
-#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2)
-static int stbi__sse2_available(void)
-{
-   // If we're even attempting to compile this on GCC/Clang, that means
-   // -msse2 is on, which means the compiler is allowed to use SSE2
-   // instructions at will, and so are we.
-   return 1;
-}
-#endif
-
-#endif
-#endif
-
-// ARM NEON
-#if defined(STBI_NO_SIMD) && defined(STBI_NEON)
-#undef STBI_NEON
-#endif
-
-#ifdef STBI_NEON
-#include <arm_neon.h>
-// assume GCC or Clang on ARM targets
-#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))
-#endif
-
-#ifndef STBI_SIMD_ALIGN
-#define STBI_SIMD_ALIGN(type, name) type name
-#endif
-
-#ifndef STBI_MAX_DIMENSIONS
-#define STBI_MAX_DIMENSIONS (1 << 24)
-#endif
-
-///////////////////////////////////////////////
-//
-//  stbi__context struct and start_xxx functions
-
-// stbi__context structure is our basic context used by all images, so it
-// contains all the IO context, plus some basic image information
-typedef struct
-{
-   stbi__uint32 img_x, img_y;
-   int img_n, img_out_n;
-
-   stbi_io_callbacks io;
-   void *io_user_data;
-
-   int read_from_callbacks;
-   int buflen;
-   stbi_uc buffer_start[128];
-   int callback_already_read;
-
-   stbi_uc *img_buffer, *img_buffer_end;
-   stbi_uc *img_buffer_original, *img_buffer_original_end;
-} stbi__context;
-
-
-static void stbi__refill_buffer(stbi__context *s);
-
-// initialize a memory-decode context
-static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len)
-{
-   s->io.read = NULL;
-   s->read_from_callbacks = 0;
-   s->callback_already_read = 0;
-   s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer;
-   s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len;
-}
-
-// initialize a callback-based context
-static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user)
-{
-   s->io = *c;
-   s->io_user_data = user;
-   s->buflen = sizeof(s->buffer_start);
-   s->read_from_callbacks = 1;
-   s->callback_already_read = 0;
-   s->img_buffer = s->img_buffer_original = s->buffer_start;
-   stbi__refill_buffer(s);
-   s->img_buffer_original_end = s->img_buffer_end;
-}
-
-#ifndef STBI_NO_STDIO
-
-static int stbi__stdio_read(void *user, char *data, int size)
-{
-   return (int) fread(data,1,size,(FILE*) user);
-}
-
-static void stbi__stdio_skip(void *user, int n)
-{
-   int ch;
-   fseek((FILE*) user, n, SEEK_CUR);
-   ch = fgetc((FILE*) user);  /* have to read a byte to reset feof()'s flag */
-   if (ch != EOF) {
-      ungetc(ch, (FILE *) user);  /* push byte back onto stream if valid. */
-   }
-}
-
-static int stbi__stdio_eof(void *user)
-{
-   return feof((FILE*) user) || ferror((FILE *) user);
-}
-
-static stbi_io_callbacks stbi__stdio_callbacks =
-{
-   stbi__stdio_read,
-   stbi__stdio_skip,
-   stbi__stdio_eof,
-};
-
-static void stbi__start_file(stbi__context *s, FILE *f)
-{
-   stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f);
-}
-
-//static void stop_file(stbi__context *s) { }
-
-#endif // !STBI_NO_STDIO
-
-static void stbi__rewind(stbi__context *s)
-{
-   // conceptually rewind SHOULD rewind to the beginning of the stream,
-   // but we just rewind to the beginning of the initial buffer, because
-   // we only use it after doing 'test', which only ever looks at at most 92 bytes
-   s->img_buffer = s->img_buffer_original;
-   s->img_buffer_end = s->img_buffer_original_end;
-}
-
-enum
-{
-   STBI_ORDER_RGB,
-   STBI_ORDER_BGR
-};
-
-typedef struct
-{
-   int bits_per_channel;
-   int num_channels;
-   int channel_order;
-} stbi__result_info;
-
-#ifndef STBI_NO_JPEG
-static int      stbi__jpeg_test(stbi__context *s);
-static void    *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PNG
-static int      stbi__png_test(stbi__context *s);
-static void    *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__png_info(stbi__context *s, int *x, int *y, int *comp);
-static int      stbi__png_is16(stbi__context *s);
-#endif
-
-#ifndef STBI_NO_BMP
-static int      stbi__bmp_test(stbi__context *s);
-static void    *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_TGA
-static int      stbi__tga_test(stbi__context *s);
-static void    *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__tga_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PSD
-static int      stbi__psd_test(stbi__context *s);
-static void    *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc);
-static int      stbi__psd_info(stbi__context *s, int *x, int *y, int *comp);
-static int      stbi__psd_is16(stbi__context *s);
-#endif
-
-#ifndef STBI_NO_HDR
-static int      stbi__hdr_test(stbi__context *s);
-static float   *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PIC
-static int      stbi__pic_test(stbi__context *s);
-static void    *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__pic_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_GIF
-static int      stbi__gif_test(stbi__context *s);
-static void    *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static void    *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp);
-static int      stbi__gif_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-#ifndef STBI_NO_PNM
-static int      stbi__pnm_test(stbi__context *s);
-static void    *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);
-static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);
-#endif
-
-static
-#ifdef STBI_THREAD_LOCAL
-STBI_THREAD_LOCAL
-#endif
-const char *stbi__g_failure_reason;
-
-STBIDEF const char *stbi_failure_reason(void)
-{
-   return stbi__g_failure_reason;
-}
-
-#ifndef STBI_NO_FAILURE_STRINGS
-static int stbi__err(const char *str)
-{
-   stbi__g_failure_reason = str;
-   return 0;
-}
-#endif
-
-static void *stbi__malloc(size_t size)
-{
-    return STBI_MALLOC(size);
-}
-
-// stb_image uses ints pervasively, including for offset calculations.
-// therefore the largest decoded image size we can support with the
-// current code, even on 64-bit targets, is INT_MAX. this is not a
-// significant limitation for the intended use case.
-//
-// we do, however, need to make sure our size calculations don't
-// overflow. hence a few helper functions for size calculations that
-// multiply integers together, making sure that they're non-negative
-// and no overflow occurs.
-
-// return 1 if the sum is valid, 0 on overflow.
-// negative terms are considered invalid.
-static int stbi__addsizes_valid(int a, int b)
-{
-   if (b < 0) return 0;
-   // now 0 <= b <= INT_MAX, hence also
-   // 0 <= INT_MAX - b <= INTMAX.
-   // And "a + b <= INT_MAX" (which might overflow) is the
-   // same as a <= INT_MAX - b (no overflow)
-   return a <= INT_MAX - b;
-}
-
-// returns 1 if the product is valid, 0 on overflow.
-// negative factors are considered invalid.
-static int stbi__mul2sizes_valid(int a, int b)
-{
-   if (a < 0 || b < 0) return 0;
-   if (b == 0) return 1; // mul-by-0 is always safe
-   // portable way to check for no overflows in a*b
-   return a <= INT_MAX/b;
-}
-
-#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
-// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow
-static int stbi__mad2sizes_valid(int a, int b, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add);
-}
-#endif
-
-// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow
-static int stbi__mad3sizes_valid(int a, int b, int c, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
-      stbi__addsizes_valid(a*b*c, add);
-}
-
-// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)
-{
-   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&
-      stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);
-}
-#endif
-
-#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
-// mallocs with size overflow checking
-static void *stbi__malloc_mad2(int a, int b, int add)
-{
-   if (!stbi__mad2sizes_valid(a, b, add)) return NULL;
-   return stbi__malloc(a*b + add);
-}
-#endif
-
-static void *stbi__malloc_mad3(int a, int b, int c, int add)
-{
-   if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL;
-   return stbi__malloc(a*b*c + add);
-}
-
-#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)
-static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
-{
-   if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;
-   return stbi__malloc(a*b*c*d + add);
-}
-#endif
-
-// stbi__err - error
-// stbi__errpf - error returning pointer to float
-// stbi__errpuc - error returning pointer to unsigned char
-
-#ifdef STBI_NO_FAILURE_STRINGS
-   #define stbi__err(x,y)  0
-#elif defined(STBI_FAILURE_USERMSG)
-   #define stbi__err(x,y)  stbi__err(y)
-#else
-   #define stbi__err(x,y)  stbi__err(x)
-#endif
-
-#define stbi__errpf(x,y)   ((float *)(size_t) (stbi__err(x,y)?NULL:NULL))
-#define stbi__errpuc(x,y)  ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))
-
-STBIDEF void stbi_image_free(void *retval_from_stbi_load)
-{
-   STBI_FREE(retval_from_stbi_load);
-}
-
-#ifndef STBI_NO_LINEAR
-static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp);
-#endif
-
-#ifndef STBI_NO_HDR
-static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp);
-#endif
-
-static int stbi__vertically_flip_on_load_global = 0;
-
-STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip)
-{
-   stbi__vertically_flip_on_load_global = flag_true_if_should_flip;
-}
-
-#ifndef STBI_THREAD_LOCAL
-#define stbi__vertically_flip_on_load  stbi__vertically_flip_on_load_global
-#else
-static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set;
-
-STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip)
-{
-   stbi__vertically_flip_on_load_local = flag_true_if_should_flip;
-   stbi__vertically_flip_on_load_set = 1;
-}
-
-#define stbi__vertically_flip_on_load  (stbi__vertically_flip_on_load_set       \
-                                         ? stbi__vertically_flip_on_load_local  \
-                                         : stbi__vertically_flip_on_load_global)
-#endif // STBI_THREAD_LOCAL
-
-static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
-{
-   memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields
-   ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed
-   ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
-   ri->num_channels = 0;
-
-   #ifndef STBI_NO_JPEG
-   if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PNG
-   if (stbi__png_test(s))  return stbi__png_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_BMP
-   if (stbi__bmp_test(s))  return stbi__bmp_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_GIF
-   if (stbi__gif_test(s))  return stbi__gif_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_test(s))  return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc);
-   #else
-   STBI_NOTUSED(bpc);
-   #endif
-   #ifndef STBI_NO_PIC
-   if (stbi__pic_test(s))  return stbi__pic_load(s,x,y,comp,req_comp, ri);
-   #endif
-   #ifndef STBI_NO_PNM
-   if (stbi__pnm_test(s))  return stbi__pnm_load(s,x,y,comp,req_comp, ri);
-   #endif
-
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_test(s)) {
-      float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri);
-      return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);
-   }
-   #endif
-
-   #ifndef STBI_NO_TGA
-   // test tga last because it's a crappy test!
-   if (stbi__tga_test(s))
-      return stbi__tga_load(s,x,y,comp,req_comp, ri);
-   #endif
-
-   return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt");
-}
-
-static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)
-{
-   int i;
-   int img_len = w * h * channels;
-   stbi_uc *reduced;
-
-   reduced = (stbi_uc *) stbi__malloc(img_len);
-   if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory");
-
-   for (i = 0; i < img_len; ++i)
-      reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling
-
-   STBI_FREE(orig);
-   return reduced;
-}
-
-static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels)
-{
-   int i;
-   int img_len = w * h * channels;
-   stbi__uint16 *enlarged;
-
-   enlarged = (stbi__uint16 *) stbi__malloc(img_len*2);
-   if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
-
-   for (i = 0; i < img_len; ++i)
-      enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff
-
-   STBI_FREE(orig);
-   return enlarged;
-}
-
-static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel)
-{
-   int row;
-   size_t bytes_per_row = (size_t)w * bytes_per_pixel;
-   stbi_uc temp[2048];
-   stbi_uc *bytes = (stbi_uc *)image;
-
-   for (row = 0; row < (h>>1); row++) {
-      stbi_uc *row0 = bytes + row*bytes_per_row;
-      stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row;
-      // swap row0 with row1
-      size_t bytes_left = bytes_per_row;
-      while (bytes_left) {
-         size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp);
-         memcpy(temp, row0, bytes_copy);
-         memcpy(row0, row1, bytes_copy);
-         memcpy(row1, temp, bytes_copy);
-         row0 += bytes_copy;
-         row1 += bytes_copy;
-         bytes_left -= bytes_copy;
-      }
-   }
-}
-
-#ifndef STBI_NO_GIF
-static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel)
-{
-   int slice;
-   int slice_size = w * h * bytes_per_pixel;
-
-   stbi_uc *bytes = (stbi_uc *)image;
-   for (slice = 0; slice < z; ++slice) {
-      stbi__vertical_flip(bytes, w, h, bytes_per_pixel);
-      bytes += slice_size;
-   }
-}
-#endif
-
-static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__result_info ri;
-   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8);
-
-   if (result == NULL)
-      return NULL;
-
-   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
-   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
-
-   if (ri.bits_per_channel != 8) {
-      result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
-      ri.bits_per_channel = 8;
-   }
-
-   // @TODO: move stbi__convert_format to here
-
-   if (stbi__vertically_flip_on_load) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc));
-   }
-
-   return (unsigned char *) result;
-}
-
-static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__result_info ri;
-   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16);
-
-   if (result == NULL)
-      return NULL;
-
-   // it is the responsibility of the loaders to make sure we get either 8 or 16 bit.
-   STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16);
-
-   if (ri.bits_per_channel != 16) {
-      result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);
-      ri.bits_per_channel = 16;
-   }
-
-   // @TODO: move stbi__convert_format16 to here
-   // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision
-
-   if (stbi__vertically_flip_on_load) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16));
-   }
-
-   return (stbi__uint16 *) result;
-}
-
-#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR)
-static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp)
-{
-   if (stbi__vertically_flip_on_load && result != NULL) {
-      int channels = req_comp ? req_comp : *comp;
-      stbi__vertical_flip(result, *x, *y, channels * sizeof(float));
-   }
-}
-#endif
-
-#ifndef STBI_NO_STDIO
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
-STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
-#endif
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
-{
-       return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
-}
-#endif
-
-static FILE *stbi__fopen(char const *filename, char const *mode)
-{
-   FILE *f;
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-   wchar_t wMode[64];
-   wchar_t wFilename[1024];
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
-      return 0;
-
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
-      return 0;
-
-#if _MSC_VER >= 1400
-       if (0 != _wfopen_s(&f, wFilename, wMode))
-               f = 0;
-#else
-   f = _wfopen(wFilename, wMode);
-#endif
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
-   if (0 != fopen_s(&f, filename, mode))
-      f=0;
-#else
-   f = fopen(filename, mode);
-#endif
-   return f;
-}
-
-
-STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   unsigned char *result;
-   if (!f) return stbi__errpuc("can't fopen", "Unable to open file");
-   result = stbi_load_from_file(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   unsigned char *result;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-   if (result) {
-      // need to 'unget' all the characters in the IO buffer
-      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
-   }
-   return result;
-}
-
-STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__uint16 *result;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp);
-   if (result) {
-      // need to 'unget' all the characters in the IO buffer
-      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);
-   }
-   return result;
-}
-
-STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   stbi__uint16 *result;
-   if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file");
-   result = stbi_load_from_file_16(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-
-#endif //!STBI_NO_STDIO
-
-STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
-}
-
-STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user);
-   return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels);
-}
-
-STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-}
-
-STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);
-}
-
-#ifndef STBI_NO_GIF
-STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
-{
-   unsigned char *result;
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-
-   result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);
-   if (stbi__vertically_flip_on_load) {
-      stbi__vertical_flip_slices( result, *x, *y, *z, *comp );
-   }
-
-   return result;
-}
-#endif
-
-#ifndef STBI_NO_LINEAR
-static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp)
-{
-   unsigned char *data;
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_test(s)) {
-      stbi__result_info ri;
-      float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri);
-      if (hdr_data)
-         stbi__float_postprocess(hdr_data,x,y,comp,req_comp);
-      return hdr_data;
-   }
-   #endif
-   data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp);
-   if (data)
-      return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp);
-   return stbi__errpf("unknown image type", "Image not of any known type, or corrupt");
-}
-
-STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-
-STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp)
-{
-   float *result;
-   FILE *f = stbi__fopen(filename, "rb");
-   if (!f) return stbi__errpf("can't fopen", "Unable to open file");
-   result = stbi_loadf_from_file(f,x,y,comp,req_comp);
-   fclose(f);
-   return result;
-}
-
-STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)
-{
-   stbi__context s;
-   stbi__start_file(&s,f);
-   return stbi__loadf_main(&s,x,y,comp,req_comp);
-}
-#endif // !STBI_NO_STDIO
-
-#endif // !STBI_NO_LINEAR
-
-// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is
-// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always
-// reports false!
-
-STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len)
-{
-   #ifndef STBI_NO_HDR
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__hdr_test(&s);
-   #else
-   STBI_NOTUSED(buffer);
-   STBI_NOTUSED(len);
-   return 0;
-   #endif
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF int      stbi_is_hdr          (char const *filename)
-{
-   FILE *f = stbi__fopen(filename, "rb");
-   int result=0;
-   if (f) {
-      result = stbi_is_hdr_from_file(f);
-      fclose(f);
-   }
-   return result;
-}
-
-STBIDEF int stbi_is_hdr_from_file(FILE *f)
-{
-   #ifndef STBI_NO_HDR
-   long pos = ftell(f);
-   int res;
-   stbi__context s;
-   stbi__start_file(&s,f);
-   res = stbi__hdr_test(&s);
-   fseek(f, pos, SEEK_SET);
-   return res;
-   #else
-   STBI_NOTUSED(f);
-   return 0;
-   #endif
-}
-#endif // !STBI_NO_STDIO
-
-STBIDEF int      stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user)
-{
-   #ifndef STBI_NO_HDR
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
-   return stbi__hdr_test(&s);
-   #else
-   STBI_NOTUSED(clbk);
-   STBI_NOTUSED(user);
-   return 0;
-   #endif
-}
-
-#ifndef STBI_NO_LINEAR
-static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f;
-
-STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; }
-STBIDEF void   stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; }
-#endif
-
-static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f;
-
-STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; }
-STBIDEF void   stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; }
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Common code used by all image loaders
-//
-
-enum
-{
-   STBI__SCAN_load=0,
-   STBI__SCAN_type,
-   STBI__SCAN_header
-};
-
-static void stbi__refill_buffer(stbi__context *s)
-{
-   int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen);
-   s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original);
-   if (n == 0) {
-      // at end of file, treat same as if from memory, but need to handle case
-      // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file
-      s->read_from_callbacks = 0;
-      s->img_buffer = s->buffer_start;
-      s->img_buffer_end = s->buffer_start+1;
-      *s->img_buffer = 0;
-   } else {
-      s->img_buffer = s->buffer_start;
-      s->img_buffer_end = s->buffer_start + n;
-   }
-}
-
-stbi_inline static stbi_uc stbi__get8(stbi__context *s)
-{
-   if (s->img_buffer < s->img_buffer_end)
-      return *s->img_buffer++;
-   if (s->read_from_callbacks) {
-      stbi__refill_buffer(s);
-      return *s->img_buffer++;
-   }
-   return 0;
-}
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-stbi_inline static int stbi__at_eof(stbi__context *s)
-{
-   if (s->io.read) {
-      if (!(s->io.eof)(s->io_user_data)) return 0;
-      // if feof() is true, check if buffer = end
-      // special case: we've only got the special 0 character at the end
-      if (s->read_from_callbacks == 0) return 1;
-   }
-
-   return s->img_buffer >= s->img_buffer_end;
-}
-#endif
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC)
-// nothing
-#else
-static void stbi__skip(stbi__context *s, int n)
-{
-   if (n == 0) return;  // already there!
-   if (n < 0) {
-      s->img_buffer = s->img_buffer_end;
-      return;
-   }
-   if (s->io.read) {
-      int blen = (int) (s->img_buffer_end - s->img_buffer);
-      if (blen < n) {
-         s->img_buffer = s->img_buffer_end;
-         (s->io.skip)(s->io_user_data, n - blen);
-         return;
-      }
-   }
-   s->img_buffer += n;
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM)
-// nothing
-#else
-static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)
-{
-   if (s->io.read) {
-      int blen = (int) (s->img_buffer_end - s->img_buffer);
-      if (blen < n) {
-         int res, count;
-
-         memcpy(buffer, s->img_buffer, blen);
-
-         count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen);
-         res = (count == (n-blen));
-         s->img_buffer = s->img_buffer_end;
-         return res;
-      }
-   }
-
-   if (s->img_buffer+n <= s->img_buffer_end) {
-      memcpy(buffer, s->img_buffer, n);
-      s->img_buffer += n;
-      return 1;
-   } else
-      return 0;
-}
-#endif
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
-// nothing
-#else
-static int stbi__get16be(stbi__context *s)
-{
-   int z = stbi__get8(s);
-   return (z << 8) + stbi__get8(s);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC)
-// nothing
-#else
-static stbi__uint32 stbi__get32be(stbi__context *s)
-{
-   stbi__uint32 z = stbi__get16be(s);
-   return (z << 16) + stbi__get16be(s);
-}
-#endif
-
-#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF)
-// nothing
-#else
-static int stbi__get16le(stbi__context *s)
-{
-   int z = stbi__get8(s);
-   return z + (stbi__get8(s) << 8);
-}
-#endif
-
-#ifndef STBI_NO_BMP
-static stbi__uint32 stbi__get32le(stbi__context *s)
-{
-   stbi__uint32 z = stbi__get16le(s);
-   return z + (stbi__get16le(s) << 16);
-}
-#endif
-
-#define STBI__BYTECAST(x)  ((stbi_uc) ((x) & 255))  // truncate int to byte without warnings
-
-#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-//////////////////////////////////////////////////////////////////////////////
-//
-//  generic converter from built-in img_n to req_comp
-//    individual types do this automatically as much as possible (e.g. jpeg
-//    does all cases internally since it needs to colorspace convert anyway,
-//    and it never has alpha, so very few cases ). png can automatically
-//    interleave an alpha=255 channel, but falls back to this for other cases
-//
-//  assume data buffer is malloced, so malloc a new one and free that one
-//  only failure mode is malloc failing
-
-static stbi_uc stbi__compute_y(int r, int g, int b)
-{
-   return (stbi_uc) (((r*77) + (g*150) +  (29*b)) >> 8);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM)
-// nothing
-#else
-static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)
-{
-   int i,j;
-   unsigned char *good;
-
-   if (req_comp == img_n) return data;
-   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
-
-   good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0);
-   if (good == NULL) {
-      STBI_FREE(data);
-      return stbi__errpuc("outofmem", "Out of memory");
-   }
-
-   for (j=0; j < (int) y; ++j) {
-      unsigned char *src  = data + j * x * img_n   ;
-      unsigned char *dest = good + j * x * req_comp;
-
-      #define STBI__COMBO(a,b)  ((a)*8+(b))
-      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
-      // convert source image with img_n components to one with req_comp components;
-      // avoid switch per pixel, so use switch per scanline and massive macros
-      switch (STBI__COMBO(img_n, req_comp)) {
-         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255;                                     } break;
-         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
-         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255;                     } break;
-         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;
-         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;
-         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                  } break;
-         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255;        } break;
-         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255;    } break;
-         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break;
-         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                    } break;
-         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion");
-      }
-      #undef STBI__CASE
-   }
-
-   STBI_FREE(data);
-   return good;
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
-// nothing
-#else
-static stbi__uint16 stbi__compute_y_16(int r, int g, int b)
-{
-   return (stbi__uint16) (((r*77) + (g*150) +  (29*b)) >> 8);
-}
-#endif
-
-#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD)
-// nothing
-#else
-static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)
-{
-   int i,j;
-   stbi__uint16 *good;
-
-   if (req_comp == img_n) return data;
-   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
-
-   good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
-   if (good == NULL) {
-      STBI_FREE(data);
-      return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");
-   }
-
-   for (j=0; j < (int) y; ++j) {
-      stbi__uint16 *src  = data + j * x * img_n   ;
-      stbi__uint16 *dest = good + j * x * req_comp;
-
-      #define STBI__COMBO(a,b)  ((a)*8+(b))
-      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)
-      // convert source image with img_n components to one with req_comp components;
-      // avoid switch per pixel, so use switch per scanline and massive macros
-      switch (STBI__COMBO(img_n, req_comp)) {
-         STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff;                                     } break;
-         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
-         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff;                     } break;
-         STBI__CASE(2,1) { dest[0]=src[0];                                                     } break;
-         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;
-         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1];                     } break;
-         STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff;        } break;
-         STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break;
-         STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;
-         STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break;
-         STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];                       } break;
-         default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion");
-      }
-      #undef STBI__CASE
-   }
-
-   STBI_FREE(data);
-   return good;
-}
-#endif
-
-#ifndef STBI_NO_LINEAR
-static float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp)
-{
-   int i,k,n;
-   float *output;
-   if (!data) return NULL;
-   output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0);
-   if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); }
-   // compute number of non-alpha components
-   if (comp & 1) n = comp; else n = comp-1;
-   for (i=0; i < x*y; ++i) {
-      for (k=0; k < n; ++k) {
-         output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale);
-      }
-   }
-   if (n < comp) {
-      for (i=0; i < x*y; ++i) {
-         output[i*comp + n] = data[i*comp + n]/255.0f;
-      }
-   }
-   STBI_FREE(data);
-   return output;
-}
-#endif
-
-#ifndef STBI_NO_HDR
-#define stbi__float2int(x)   ((int) (x))
-static stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp)
-{
-   int i,k,n;
-   stbi_uc *output;
-   if (!data) return NULL;
-   output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0);
-   if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); }
-   // compute number of non-alpha components
-   if (comp & 1) n = comp; else n = comp-1;
-   for (i=0; i < x*y; ++i) {
-      for (k=0; k < n; ++k) {
-         float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f;
-         if (z < 0) z = 0;
-         if (z > 255) z = 255;
-         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
-      }
-      if (k < comp) {
-         float z = data[i*comp+k] * 255 + 0.5f;
-         if (z < 0) z = 0;
-         if (z > 255) z = 255;
-         output[i*comp + k] = (stbi_uc) stbi__float2int(z);
-      }
-   }
-   STBI_FREE(data);
-   return output;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  "baseline" JPEG/JFIF decoder
-//
-//    simple implementation
-//      - doesn't support delayed output of y-dimension
-//      - simple interface (only one output format: 8-bit interleaved RGB)
-//      - doesn't try to recover corrupt jpegs
-//      - doesn't allow partial loading, loading multiple at once
-//      - still fast on x86 (copying globals into locals doesn't help x86)
-//      - allocates lots of intermediate memory (full size of all components)
-//        - non-interleaved case requires this anyway
-//        - allows good upsampling (see next)
-//    high-quality
-//      - upsampled channels are bilinearly interpolated, even across blocks
-//      - quality integer IDCT derived from IJG's 'slow'
-//    performance
-//      - fast huffman; reasonable integer IDCT
-//      - some SIMD kernels for common paths on targets with SSE2/NEON
-//      - uses a lot of intermediate memory, could cache poorly
-
-#ifndef STBI_NO_JPEG
-
-// huffman decoding acceleration
-#define FAST_BITS   9  // larger handles more cases; smaller stomps less cache
-
-typedef struct
-{
-   stbi_uc  fast[1 << FAST_BITS];
-   // weirdly, repacking this into AoS is a 10% speed loss, instead of a win
-   stbi__uint16 code[256];
-   stbi_uc  values[256];
-   stbi_uc  size[257];
-   unsigned int maxcode[18];
-   int    delta[17];   // old 'firstsymbol' - old 'firstcode'
-} stbi__huffman;
-
-typedef struct
-{
-   stbi__context *s;
-   stbi__huffman huff_dc[4];
-   stbi__huffman huff_ac[4];
-   stbi__uint16 dequant[4][64];
-   stbi__int16 fast_ac[4][1 << FAST_BITS];
-
-// sizes for components, interleaved MCUs
-   int img_h_max, img_v_max;
-   int img_mcu_x, img_mcu_y;
-   int img_mcu_w, img_mcu_h;
-
-// definition of jpeg image component
-   struct
-   {
-      int id;
-      int h,v;
-      int tq;
-      int hd,ha;
-      int dc_pred;
-
-      int x,y,w2,h2;
-      stbi_uc *data;
-      void *raw_data, *raw_coeff;
-      stbi_uc *linebuf;
-      short   *coeff;   // progressive only
-      int      coeff_w, coeff_h; // number of 8x8 coefficient blocks
-   } img_comp[4];
-
-   stbi__uint32   code_buffer; // jpeg entropy-coded buffer
-   int            code_bits;   // number of valid bits
-   unsigned char  marker;      // marker seen while filling entropy buffer
-   int            nomore;      // flag if we saw a marker so must stop
-
-   int            progressive;
-   int            spec_start;
-   int            spec_end;
-   int            succ_high;
-   int            succ_low;
-   int            eob_run;
-   int            jfif;
-   int            app14_color_transform; // Adobe APP14 tag
-   int            rgb;
-
-   int scan_n, order[4];
-   int restart_interval, todo;
-
-// kernels
-   void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]);
-   void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step);
-   stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs);
-} stbi__jpeg;
-
-static int stbi__build_huffman(stbi__huffman *h, int *count)
-{
-   int i,j,k=0;
-   unsigned int code;
-   // build size list for each symbol (from JPEG spec)
-   for (i=0; i < 16; ++i)
-      for (j=0; j < count[i]; ++j)
-         h->size[k++] = (stbi_uc) (i+1);
-   h->size[k] = 0;
-
-   // compute actual symbols (from jpeg spec)
-   code = 0;
-   k = 0;
-   for(j=1; j <= 16; ++j) {
-      // compute delta to add to code to compute symbol id
-      h->delta[j] = k - code;
-      if (h->size[k] == j) {
-         while (h->size[k] == j)
-            h->code[k++] = (stbi__uint16) (code++);
-         if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG");
-      }
-      // compute largest code + 1 for this size, preshifted as needed later
-      h->maxcode[j] = code << (16-j);
-      code <<= 1;
-   }
-   h->maxcode[j] = 0xffffffff;
-
-   // build non-spec acceleration table; 255 is flag for not-accelerated
-   memset(h->fast, 255, 1 << FAST_BITS);
-   for (i=0; i < k; ++i) {
-      int s = h->size[i];
-      if (s <= FAST_BITS) {
-         int c = h->code[i] << (FAST_BITS-s);
-         int m = 1 << (FAST_BITS-s);
-         for (j=0; j < m; ++j) {
-            h->fast[c+j] = (stbi_uc) i;
-         }
-      }
-   }
-   return 1;
-}
-
-// build a table that decodes both magnitude and value of small ACs in
-// one go.
-static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h)
-{
-   int i;
-   for (i=0; i < (1 << FAST_BITS); ++i) {
-      stbi_uc fast = h->fast[i];
-      fast_ac[i] = 0;
-      if (fast < 255) {
-         int rs = h->values[fast];
-         int run = (rs >> 4) & 15;
-         int magbits = rs & 15;
-         int len = h->size[fast];
-
-         if (magbits && len + magbits <= FAST_BITS) {
-            // magnitude code followed by receive_extend code
-            int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits);
-            int m = 1 << (magbits - 1);
-            if (k < m) k += (~0U << magbits) + 1;
-            // if the result is small enough, we can fit it in fast_ac table
-            if (k >= -128 && k <= 127)
-               fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits));
-         }
-      }
-   }
-}
-
-static void stbi__grow_buffer_unsafe(stbi__jpeg *j)
-{
-   do {
-      unsigned int b = j->nomore ? 0 : stbi__get8(j->s);
-      if (b == 0xff) {
-         int c = stbi__get8(j->s);
-         while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes
-         if (c != 0) {
-            j->marker = (unsigned char) c;
-            j->nomore = 1;
-            return;
-         }
-      }
-      j->code_buffer |= b << (24 - j->code_bits);
-      j->code_bits += 8;
-   } while (j->code_bits <= 24);
-}
-
-// (1 << n) - 1
-static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
-
-// decode a jpeg huffman value from the bitstream
-stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)
-{
-   unsigned int temp;
-   int c,k;
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-
-   // look at the top FAST_BITS and determine what symbol ID it is,
-   // if the code is <= FAST_BITS
-   c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-   k = h->fast[c];
-   if (k < 255) {
-      int s = h->size[k];
-      if (s > j->code_bits)
-         return -1;
-      j->code_buffer <<= s;
-      j->code_bits -= s;
-      return h->values[k];
-   }
-
-   // naive test is to shift the code_buffer down so k bits are
-   // valid, then test against maxcode. To speed this up, we've
-   // preshifted maxcode left so that it has (16-k) 0s at the
-   // end; in other words, regardless of the number of bits, it
-   // wants to be compared against something shifted to have 16;
-   // that way we don't need to shift inside the loop.
-   temp = j->code_buffer >> 16;
-   for (k=FAST_BITS+1 ; ; ++k)
-      if (temp < h->maxcode[k])
-         break;
-   if (k == 17) {
-      // error! code not found
-      j->code_bits -= 16;
-      return -1;
-   }
-
-   if (k > j->code_bits)
-      return -1;
-
-   // convert the huffman code to the symbol id
-   c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];
-   STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);
-
-   // convert the id to a symbol
-   j->code_bits -= k;
-   j->code_buffer <<= k;
-   return h->values[c];
-}
-
-// bias[n] = (-1<<n) + 1
-static const int stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767};
-
-// combined JPEG 'receive' and JPEG 'extend', since baseline
-// always extends everything it receives.
-stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
-{
-   unsigned int k;
-   int sgn;
-   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
-
-   sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB
-   k = stbi_lrot(j->code_buffer, n);
-   if (n < 0 || n >= (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))) return 0;
-   j->code_buffer = k & ~stbi__bmask[n];
-   k &= stbi__bmask[n];
-   j->code_bits -= n;
-   return k + (stbi__jbias[n] & ~sgn);
-}
-
-// get some unsigned bits
-stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n)
-{
-   unsigned int k;
-   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
-   k = stbi_lrot(j->code_buffer, n);
-   j->code_buffer = k & ~stbi__bmask[n];
-   k &= stbi__bmask[n];
-   j->code_bits -= n;
-   return k;
-}
-
-stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)
-{
-   unsigned int k;
-   if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);
-   k = j->code_buffer;
-   j->code_buffer <<= 1;
-   --j->code_bits;
-   return k & 0x80000000;
-}
-
-// given a value that's at position X in the zigzag stream,
-// where does it appear in the 8x8 matrix coded as row-major?
-static const stbi_uc stbi__jpeg_dezigzag[64+15] =
-{
-    0,  1,  8, 16,  9,  2,  3, 10,
-   17, 24, 32, 25, 18, 11,  4,  5,
-   12, 19, 26, 33, 40, 48, 41, 34,
-   27, 20, 13,  6,  7, 14, 21, 28,
-   35, 42, 49, 56, 57, 50, 43, 36,
-   29, 22, 15, 23, 30, 37, 44, 51,
-   58, 59, 52, 45, 38, 31, 39, 46,
-   53, 60, 61, 54, 47, 55, 62, 63,
-   // let corrupt input sample past end
-   63, 63, 63, 63, 63, 63, 63, 63,
-   63, 63, 63, 63, 63, 63, 63
-};
-
-// decode one 64-entry block--
-static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant)
-{
-   int diff,dc,k;
-   int t;
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-   t = stbi__jpeg_huff_decode(j, hdc);
-   if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-
-   // 0 all the ac values now so we can do it 32-bits at a time
-   memset(data,0,64*sizeof(data[0]));
-
-   diff = t ? stbi__extend_receive(j, t) : 0;
-   dc = j->img_comp[b].dc_pred + diff;
-   j->img_comp[b].dc_pred = dc;
-   data[0] = (short) (dc * dequant[0]);
-
-   // decode AC components, see JPEG spec
-   k = 1;
-   do {
-      unsigned int zig;
-      int c,r,s;
-      if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-      c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-      r = fac[c];
-      if (r) { // fast-AC path
-         k += (r >> 4) & 15; // run
-         s = r & 15; // combined length
-         j->code_buffer <<= s;
-         j->code_bits -= s;
-         // decode into unzigzag'd location
-         zig = stbi__jpeg_dezigzag[k++];
-         data[zig] = (short) ((r >> 8) * dequant[zig]);
-      } else {
-         int rs = stbi__jpeg_huff_decode(j, hac);
-         if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-         s = rs & 15;
-         r = rs >> 4;
-         if (s == 0) {
-            if (rs != 0xf0) break; // end block
-            k += 16;
-         } else {
-            k += r;
-            // decode into unzigzag'd location
-            zig = stbi__jpeg_dezigzag[k++];
-            data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]);
-         }
-      }
-   } while (k < 64);
-   return 1;
-}
-
-static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b)
-{
-   int diff,dc;
-   int t;
-   if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-
-   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-
-   if (j->succ_high == 0) {
-      // first scan for DC coefficient, must be first
-      memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
-      t = stbi__jpeg_huff_decode(j, hdc);
-      if (t == -1) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-      diff = t ? stbi__extend_receive(j, t) : 0;
-
-      dc = j->img_comp[b].dc_pred + diff;
-      j->img_comp[b].dc_pred = dc;
-      data[0] = (short) (dc << j->succ_low);
-   } else {
-      // refinement scan for DC coefficient
-      if (stbi__jpeg_get_bit(j))
-         data[0] += (short) (1 << j->succ_low);
-   }
-   return 1;
-}
-
-// @OPTIMIZE: store non-zigzagged during the decode passes,
-// and only de-zigzag when dequantizing
-static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac)
-{
-   int k;
-   if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
-
-   if (j->succ_high == 0) {
-      int shift = j->succ_low;
-
-      if (j->eob_run) {
-         --j->eob_run;
-         return 1;
-      }
-
-      k = j->spec_start;
-      do {
-         unsigned int zig;
-         int c,r,s;
-         if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);
-         c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);
-         r = fac[c];
-         if (r) { // fast-AC path
-            k += (r >> 4) & 15; // run
-            s = r & 15; // combined length
-            j->code_buffer <<= s;
-            j->code_bits -= s;
-            zig = stbi__jpeg_dezigzag[k++];
-            data[zig] = (short) ((r >> 8) << shift);
-         } else {
-            int rs = stbi__jpeg_huff_decode(j, hac);
-            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-            s = rs & 15;
-            r = rs >> 4;
-            if (s == 0) {
-               if (r < 15) {
-                  j->eob_run = (1 << r);
-                  if (r)
-                     j->eob_run += stbi__jpeg_get_bits(j, r);
-                  --j->eob_run;
-                  break;
-               }
-               k += 16;
-            } else {
-               k += r;
-               zig = stbi__jpeg_dezigzag[k++];
-               data[zig] = (short) (stbi__extend_receive(j,s) << shift);
-            }
-         }
-      } while (k <= j->spec_end);
-   } else {
-      // refinement scan for these AC coefficients
-
-      short bit = (short) (1 << j->succ_low);
-
-      if (j->eob_run) {
-         --j->eob_run;
-         for (k = j->spec_start; k <= j->spec_end; ++k) {
-            short *p = &data[stbi__jpeg_dezigzag[k]];
-            if (*p != 0)
-               if (stbi__jpeg_get_bit(j))
-                  if ((*p & bit)==0) {
-                     if (*p > 0)
-                        *p += bit;
-                     else
-                        *p -= bit;
-                  }
-         }
-      } else {
-         k = j->spec_start;
-         do {
-            int r,s;
-            int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh
-            if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG");
-            s = rs & 15;
-            r = rs >> 4;
-            if (s == 0) {
-               if (r < 15) {
-                  j->eob_run = (1 << r) - 1;
-                  if (r)
-                     j->eob_run += stbi__jpeg_get_bits(j, r);
-                  r = 64; // force end of block
-               } else {
-                  // r=15 s=0 should write 16 0s, so we just do
-                  // a run of 15 0s and then write s (which is 0),
-                  // so we don't have to do anything special here
-               }
-            } else {
-               if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG");
-               // sign bit
-               if (stbi__jpeg_get_bit(j))
-                  s = bit;
-               else
-                  s = -bit;
-            }
-
-            // advance by r
-            while (k <= j->spec_end) {
-               short *p = &data[stbi__jpeg_dezigzag[k++]];
-               if (*p != 0) {
-                  if (stbi__jpeg_get_bit(j))
-                     if ((*p & bit)==0) {
-                        if (*p > 0)
-                           *p += bit;
-                        else
-                           *p -= bit;
-                     }
-               } else {
-                  if (r == 0) {
-                     *p = (short) s;
-                     break;
-                  }
-                  --r;
-               }
-            }
-         } while (k <= j->spec_end);
-      }
-   }
-   return 1;
-}
-
-// take a -128..127 value and stbi__clamp it and convert to 0..255
-stbi_inline static stbi_uc stbi__clamp(int x)
-{
-   // trick to use a single test to catch both cases
-   if ((unsigned int) x > 255) {
-      if (x < 0) return 0;
-      if (x > 255) return 255;
-   }
-   return (stbi_uc) x;
-}
-
-#define stbi__f2f(x)  ((int) (((x) * 4096 + 0.5)))
-#define stbi__fsh(x)  ((x) * 4096)
-
-// derived from jidctint -- DCT_ISLOW
-#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \
-   int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \
-   p2 = s2;                                    \
-   p3 = s6;                                    \
-   p1 = (p2+p3) * stbi__f2f(0.5411961f);       \
-   t2 = p1 + p3*stbi__f2f(-1.847759065f);      \
-   t3 = p1 + p2*stbi__f2f( 0.765366865f);      \
-   p2 = s0;                                    \
-   p3 = s4;                                    \
-   t0 = stbi__fsh(p2+p3);                      \
-   t1 = stbi__fsh(p2-p3);                      \
-   x0 = t0+t3;                                 \
-   x3 = t0-t3;                                 \
-   x1 = t1+t2;                                 \
-   x2 = t1-t2;                                 \
-   t0 = s7;                                    \
-   t1 = s5;                                    \
-   t2 = s3;                                    \
-   t3 = s1;                                    \
-   p3 = t0+t2;                                 \
-   p4 = t1+t3;                                 \
-   p1 = t0+t3;                                 \
-   p2 = t1+t2;                                 \
-   p5 = (p3+p4)*stbi__f2f( 1.175875602f);      \
-   t0 = t0*stbi__f2f( 0.298631336f);           \
-   t1 = t1*stbi__f2f( 2.053119869f);           \
-   t2 = t2*stbi__f2f( 3.072711026f);           \
-   t3 = t3*stbi__f2f( 1.501321110f);           \
-   p1 = p5 + p1*stbi__f2f(-0.899976223f);      \
-   p2 = p5 + p2*stbi__f2f(-2.562915447f);      \
-   p3 = p3*stbi__f2f(-1.961570560f);           \
-   p4 = p4*stbi__f2f(-0.390180644f);           \
-   t3 += p1+p4;                                \
-   t2 += p2+p3;                                \
-   t1 += p2+p4;                                \
-   t0 += p1+p3;
-
-static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])
-{
-   int i,val[64],*v=val;
-   stbi_uc *o;
-   short *d = data;
-
-   // columns
-   for (i=0; i < 8; ++i,++d, ++v) {
-      // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing
-      if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0
-           && d[40]==0 && d[48]==0 && d[56]==0) {
-         //    no shortcut                 0     seconds
-         //    (1|2|3|4|5|6|7)==0          0     seconds
-         //    all separate               -0.047 seconds
-         //    1 && 2|3 && 4|5 && 6|7:    -0.047 seconds
-         int dcterm = d[0]*4;
-         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;
-      } else {
-         STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56])
-         // constants scaled things up by 1<<12; let's bring them back
-         // down, but keep 2 extra bits of precision
-         x0 += 512; x1 += 512; x2 += 512; x3 += 512;
-         v[ 0] = (x0+t3) >> 10;
-         v[56] = (x0-t3) >> 10;
-         v[ 8] = (x1+t2) >> 10;
-         v[48] = (x1-t2) >> 10;
-         v[16] = (x2+t1) >> 10;
-         v[40] = (x2-t1) >> 10;
-         v[24] = (x3+t0) >> 10;
-         v[32] = (x3-t0) >> 10;
-      }
-   }
-
-   for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) {
-      // no fast case since the first 1D IDCT spread components out
-      STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7])
-      // constants scaled things up by 1<<12, plus we had 1<<2 from first
-      // loop, plus horizontal and vertical each scale by sqrt(8) so together
-      // we've got an extra 1<<3, so 1<<17 total we need to remove.
-      // so we want to round that, which means adding 0.5 * 1<<17,
-      // aka 65536. Also, we'll end up with -128 to 127 that we want
-      // to encode as 0..255 by adding 128, so we'll add that before the shift
-      x0 += 65536 + (128<<17);
-      x1 += 65536 + (128<<17);
-      x2 += 65536 + (128<<17);
-      x3 += 65536 + (128<<17);
-      // tried computing the shifts into temps, or'ing the temps to see
-      // if any were out of range, but that was slower
-      o[0] = stbi__clamp((x0+t3) >> 17);
-      o[7] = stbi__clamp((x0-t3) >> 17);
-      o[1] = stbi__clamp((x1+t2) >> 17);
-      o[6] = stbi__clamp((x1-t2) >> 17);
-      o[2] = stbi__clamp((x2+t1) >> 17);
-      o[5] = stbi__clamp((x2-t1) >> 17);
-      o[3] = stbi__clamp((x3+t0) >> 17);
-      o[4] = stbi__clamp((x3-t0) >> 17);
-   }
-}
-
-#ifdef STBI_SSE2
-// sse2 integer IDCT. not the fastest possible implementation but it
-// produces bit-identical results to the generic C version so it's
-// fully "transparent".
-static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
-{
-   // This is constructed to match our regular (generic) integer IDCT exactly.
-   __m128i row0, row1, row2, row3, row4, row5, row6, row7;
-   __m128i tmp;
-
-   // dot product constant: even elems=x, odd elems=y
-   #define dct_const(x,y)  _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y))
-
-   // out(0) = c0[even]*x + c0[odd]*y   (c0, x, y 16-bit, out 32-bit)
-   // out(1) = c1[even]*x + c1[odd]*y
-   #define dct_rot(out0,out1, x,y,c0,c1) \
-      __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \
-      __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \
-      __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \
-      __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \
-      __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \
-      __m128i out1##_h = _mm_madd_epi16(c0##hi, c1)
-
-   // out = in << 12  (in 16-bit, out 32-bit)
-   #define dct_widen(out, in) \
-      __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \
-      __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4)
-
-   // wide add
-   #define dct_wadd(out, a, b) \
-      __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \
-      __m128i out##_h = _mm_add_epi32(a##_h, b##_h)
-
-   // wide sub
-   #define dct_wsub(out, a, b) \
-      __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \
-      __m128i out##_h = _mm_sub_epi32(a##_h, b##_h)
-
-   // butterfly a/b, add bias, then shift by "s" and pack
-   #define dct_bfly32o(out0, out1, a,b,bias,s) \
-      { \
-         __m128i abiased_l = _mm_add_epi32(a##_l, bias); \
-         __m128i abiased_h = _mm_add_epi32(a##_h, bias); \
-         dct_wadd(sum, abiased, b); \
-         dct_wsub(dif, abiased, b); \
-         out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \
-         out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \
-      }
-
-   // 8-bit interleave step (for transposes)
-   #define dct_interleave8(a, b) \
-      tmp = a; \
-      a = _mm_unpacklo_epi8(a, b); \
-      b = _mm_unpackhi_epi8(tmp, b)
-
-   // 16-bit interleave step (for transposes)
-   #define dct_interleave16(a, b) \
-      tmp = a; \
-      a = _mm_unpacklo_epi16(a, b); \
-      b = _mm_unpackhi_epi16(tmp, b)
-
-   #define dct_pass(bias,shift) \
-      { \
-         /* even part */ \
-         dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \
-         __m128i sum04 = _mm_add_epi16(row0, row4); \
-         __m128i dif04 = _mm_sub_epi16(row0, row4); \
-         dct_widen(t0e, sum04); \
-         dct_widen(t1e, dif04); \
-         dct_wadd(x0, t0e, t3e); \
-         dct_wsub(x3, t0e, t3e); \
-         dct_wadd(x1, t1e, t2e); \
-         dct_wsub(x2, t1e, t2e); \
-         /* odd part */ \
-         dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \
-         dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \
-         __m128i sum17 = _mm_add_epi16(row1, row7); \
-         __m128i sum35 = _mm_add_epi16(row3, row5); \
-         dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \
-         dct_wadd(x4, y0o, y4o); \
-         dct_wadd(x5, y1o, y5o); \
-         dct_wadd(x6, y2o, y5o); \
-         dct_wadd(x7, y3o, y4o); \
-         dct_bfly32o(row0,row7, x0,x7,bias,shift); \
-         dct_bfly32o(row1,row6, x1,x6,bias,shift); \
-         dct_bfly32o(row2,row5, x2,x5,bias,shift); \
-         dct_bfly32o(row3,row4, x3,x4,bias,shift); \
-      }
-
-   __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f));
-   __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f));
-   __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f));
-   __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f));
-   __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f));
-   __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f));
-   __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));
-   __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));
-
-   // rounding biases in column/row passes, see stbi__idct_block for explanation.
-   __m128i bias_0 = _mm_set1_epi32(512);
-   __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17));
-
-   // load
-   row0 = _mm_load_si128((const __m128i *) (data + 0*8));
-   row1 = _mm_load_si128((const __m128i *) (data + 1*8));
-   row2 = _mm_load_si128((const __m128i *) (data + 2*8));
-   row3 = _mm_load_si128((const __m128i *) (data + 3*8));
-   row4 = _mm_load_si128((const __m128i *) (data + 4*8));
-   row5 = _mm_load_si128((const __m128i *) (data + 5*8));
-   row6 = _mm_load_si128((const __m128i *) (data + 6*8));
-   row7 = _mm_load_si128((const __m128i *) (data + 7*8));
-
-   // column pass
-   dct_pass(bias_0, 10);
-
-   {
-      // 16bit 8x8 transpose pass 1
-      dct_interleave16(row0, row4);
-      dct_interleave16(row1, row5);
-      dct_interleave16(row2, row6);
-      dct_interleave16(row3, row7);
-
-      // transpose pass 2
-      dct_interleave16(row0, row2);
-      dct_interleave16(row1, row3);
-      dct_interleave16(row4, row6);
-      dct_interleave16(row5, row7);
-
-      // transpose pass 3
-      dct_interleave16(row0, row1);
-      dct_interleave16(row2, row3);
-      dct_interleave16(row4, row5);
-      dct_interleave16(row6, row7);
-   }
-
-   // row pass
-   dct_pass(bias_1, 17);
-
-   {
-      // pack
-      __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7
-      __m128i p1 = _mm_packus_epi16(row2, row3);
-      __m128i p2 = _mm_packus_epi16(row4, row5);
-      __m128i p3 = _mm_packus_epi16(row6, row7);
-
-      // 8bit 8x8 transpose pass 1
-      dct_interleave8(p0, p2); // a0e0a1e1...
-      dct_interleave8(p1, p3); // c0g0c1g1...
-
-      // transpose pass 2
-      dct_interleave8(p0, p1); // a0c0e0g0...
-      dct_interleave8(p2, p3); // b0d0f0h0...
-
-      // transpose pass 3
-      dct_interleave8(p0, p2); // a0b0c0d0...
-      dct_interleave8(p1, p3); // a4b4c4d4...
-
-      // store
-      _mm_storel_epi64((__m128i *) out, p0); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p2); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p1); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, p3); out += out_stride;
-      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e));
-   }
-
-#undef dct_const
-#undef dct_rot
-#undef dct_widen
-#undef dct_wadd
-#undef dct_wsub
-#undef dct_bfly32o
-#undef dct_interleave8
-#undef dct_interleave16
-#undef dct_pass
-}
-
-#endif // STBI_SSE2
-
-#ifdef STBI_NEON
-
-// NEON integer IDCT. should produce bit-identical
-// results to the generic C version.
-static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])
-{
-   int16x8_t row0, row1, row2, row3, row4, row5, row6, row7;
-
-   int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f));
-   int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f));
-   int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f));
-   int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f));
-   int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f));
-   int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f));
-   int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f));
-   int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f));
-   int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f));
-   int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f));
-   int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f));
-   int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f));
-
-#define dct_long_mul(out, inq, coeff) \
-   int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \
-   int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff)
-
-#define dct_long_mac(out, acc, inq, coeff) \
-   int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \
-   int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff)
-
-#define dct_widen(out, inq) \
-   int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \
-   int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12)
-
-// wide add
-#define dct_wadd(out, a, b) \
-   int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \
-   int32x4_t out##_h = vaddq_s32(a##_h, b##_h)
-
-// wide sub
-#define dct_wsub(out, a, b) \
-   int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \
-   int32x4_t out##_h = vsubq_s32(a##_h, b##_h)
-
-// butterfly a/b, then shift using "shiftop" by "s" and pack
-#define dct_bfly32o(out0,out1, a,b,shiftop,s) \
-   { \
-      dct_wadd(sum, a, b); \
-      dct_wsub(dif, a, b); \
-      out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \
-      out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \
-   }
-
-#define dct_pass(shiftop, shift) \
-   { \
-      /* even part */ \
-      int16x8_t sum26 = vaddq_s16(row2, row6); \
-      dct_long_mul(p1e, sum26, rot0_0); \
-      dct_long_mac(t2e, p1e, row6, rot0_1); \
-      dct_long_mac(t3e, p1e, row2, rot0_2); \
-      int16x8_t sum04 = vaddq_s16(row0, row4); \
-      int16x8_t dif04 = vsubq_s16(row0, row4); \
-      dct_widen(t0e, sum04); \
-      dct_widen(t1e, dif04); \
-      dct_wadd(x0, t0e, t3e); \
-      dct_wsub(x3, t0e, t3e); \
-      dct_wadd(x1, t1e, t2e); \
-      dct_wsub(x2, t1e, t2e); \
-      /* odd part */ \
-      int16x8_t sum15 = vaddq_s16(row1, row5); \
-      int16x8_t sum17 = vaddq_s16(row1, row7); \
-      int16x8_t sum35 = vaddq_s16(row3, row5); \
-      int16x8_t sum37 = vaddq_s16(row3, row7); \
-      int16x8_t sumodd = vaddq_s16(sum17, sum35); \
-      dct_long_mul(p5o, sumodd, rot1_0); \
-      dct_long_mac(p1o, p5o, sum17, rot1_1); \
-      dct_long_mac(p2o, p5o, sum35, rot1_2); \
-      dct_long_mul(p3o, sum37, rot2_0); \
-      dct_long_mul(p4o, sum15, rot2_1); \
-      dct_wadd(sump13o, p1o, p3o); \
-      dct_wadd(sump24o, p2o, p4o); \
-      dct_wadd(sump23o, p2o, p3o); \
-      dct_wadd(sump14o, p1o, p4o); \
-      dct_long_mac(x4, sump13o, row7, rot3_0); \
-      dct_long_mac(x5, sump24o, row5, rot3_1); \
-      dct_long_mac(x6, sump23o, row3, rot3_2); \
-      dct_long_mac(x7, sump14o, row1, rot3_3); \
-      dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \
-      dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \
-      dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \
-      dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \
-   }
-
-   // load
-   row0 = vld1q_s16(data + 0*8);
-   row1 = vld1q_s16(data + 1*8);
-   row2 = vld1q_s16(data + 2*8);
-   row3 = vld1q_s16(data + 3*8);
-   row4 = vld1q_s16(data + 4*8);
-   row5 = vld1q_s16(data + 5*8);
-   row6 = vld1q_s16(data + 6*8);
-   row7 = vld1q_s16(data + 7*8);
-
-   // add DC bias
-   row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0));
-
-   // column pass
-   dct_pass(vrshrn_n_s32, 10);
-
-   // 16bit 8x8 transpose
-   {
-// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively.
-// whether compilers actually get this is another story, sadly.
-#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; }
-#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); }
-#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); }
-
-      // pass 1
-      dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6
-      dct_trn16(row2, row3);
-      dct_trn16(row4, row5);
-      dct_trn16(row6, row7);
-
-      // pass 2
-      dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4
-      dct_trn32(row1, row3);
-      dct_trn32(row4, row6);
-      dct_trn32(row5, row7);
-
-      // pass 3
-      dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0
-      dct_trn64(row1, row5);
-      dct_trn64(row2, row6);
-      dct_trn64(row3, row7);
-
-#undef dct_trn16
-#undef dct_trn32
-#undef dct_trn64
-   }
-
-   // row pass
-   // vrshrn_n_s32 only supports shifts up to 16, we need
-   // 17. so do a non-rounding shift of 16 first then follow
-   // up with a rounding shift by 1.
-   dct_pass(vshrn_n_s32, 16);
-
-   {
-      // pack and round
-      uint8x8_t p0 = vqrshrun_n_s16(row0, 1);
-      uint8x8_t p1 = vqrshrun_n_s16(row1, 1);
-      uint8x8_t p2 = vqrshrun_n_s16(row2, 1);
-      uint8x8_t p3 = vqrshrun_n_s16(row3, 1);
-      uint8x8_t p4 = vqrshrun_n_s16(row4, 1);
-      uint8x8_t p5 = vqrshrun_n_s16(row5, 1);
-      uint8x8_t p6 = vqrshrun_n_s16(row6, 1);
-      uint8x8_t p7 = vqrshrun_n_s16(row7, 1);
-
-      // again, these can translate into one instruction, but often don't.
-#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; }
-#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); }
-#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); }
-
-      // sadly can't use interleaved stores here since we only write
-      // 8 bytes to each scan line!
-
-      // 8x8 8-bit transpose pass 1
-      dct_trn8_8(p0, p1);
-      dct_trn8_8(p2, p3);
-      dct_trn8_8(p4, p5);
-      dct_trn8_8(p6, p7);
-
-      // pass 2
-      dct_trn8_16(p0, p2);
-      dct_trn8_16(p1, p3);
-      dct_trn8_16(p4, p6);
-      dct_trn8_16(p5, p7);
-
-      // pass 3
-      dct_trn8_32(p0, p4);
-      dct_trn8_32(p1, p5);
-      dct_trn8_32(p2, p6);
-      dct_trn8_32(p3, p7);
-
-      // store
-      vst1_u8(out, p0); out += out_stride;
-      vst1_u8(out, p1); out += out_stride;
-      vst1_u8(out, p2); out += out_stride;
-      vst1_u8(out, p3); out += out_stride;
-      vst1_u8(out, p4); out += out_stride;
-      vst1_u8(out, p5); out += out_stride;
-      vst1_u8(out, p6); out += out_stride;
-      vst1_u8(out, p7);
-
-#undef dct_trn8_8
-#undef dct_trn8_16
-#undef dct_trn8_32
-   }
-
-#undef dct_long_mul
-#undef dct_long_mac
-#undef dct_widen
-#undef dct_wadd
-#undef dct_wsub
-#undef dct_bfly32o
-#undef dct_pass
-}
-
-#endif // STBI_NEON
-
-#define STBI__MARKER_none  0xff
-// if there's a pending marker from the entropy stream, return that
-// otherwise, fetch from the stream and get a marker. if there's no
-// marker, return 0xff, which is never a valid marker value
-static stbi_uc stbi__get_marker(stbi__jpeg *j)
-{
-   stbi_uc x;
-   if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; }
-   x = stbi__get8(j->s);
-   if (x != 0xff) return STBI__MARKER_none;
-   while (x == 0xff)
-      x = stbi__get8(j->s); // consume repeated 0xff fill bytes
-   return x;
-}
-
-// in each scan, we'll have scan_n components, and the order
-// of the components is specified by order[]
-#define STBI__RESTART(x)     ((x) >= 0xd0 && (x) <= 0xd7)
-
-// after a restart interval, stbi__jpeg_reset the entropy decoder and
-// the dc prediction
-static void stbi__jpeg_reset(stbi__jpeg *j)
-{
-   j->code_bits = 0;
-   j->code_buffer = 0;
-   j->nomore = 0;
-   j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0;
-   j->marker = STBI__MARKER_none;
-   j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff;
-   j->eob_run = 0;
-   // no more than 1<<31 MCUs if no restart_interal? that's plenty safe,
-   // since we don't even allow 1<<30 pixels
-}
-
-static int stbi__parse_entropy_coded_data(stbi__jpeg *z)
-{
-   stbi__jpeg_reset(z);
-   if (!z->progressive) {
-      if (z->scan_n == 1) {
-         int i,j;
-         STBI_SIMD_ALIGN(short, data[64]);
-         int n = z->order[0];
-         // non-interleaved data, we just need to process one block at a time,
-         // in trivial scanline order
-         // number of blocks to do just depends on how many actual "pixels" this
-         // component has, independent of interleaved MCU blocking and such
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               int ha = z->img_comp[n].ha;
-               if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
-               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
-               // every data block is an MCU, so countdown the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  // if it's NOT a restart, then just bail, so we get corrupt data
-                  // rather than no data
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      } else { // interleaved
-         int i,j,k,x,y;
-         STBI_SIMD_ALIGN(short, data[64]);
-         for (j=0; j < z->img_mcu_y; ++j) {
-            for (i=0; i < z->img_mcu_x; ++i) {
-               // scan an interleaved mcu... process scan_n components in order
-               for (k=0; k < z->scan_n; ++k) {
-                  int n = z->order[k];
-                  // scan out an mcu's worth of this component; that's just determined
-                  // by the basic H and V specified for the component
-                  for (y=0; y < z->img_comp[n].v; ++y) {
-                     for (x=0; x < z->img_comp[n].h; ++x) {
-                        int x2 = (i*z->img_comp[n].h + x)*8;
-                        int y2 = (j*z->img_comp[n].v + y)*8;
-                        int ha = z->img_comp[n].ha;
-                        if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;
-                        z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data);
-                     }
-                  }
-               }
-               // after all interleaved components, that's an interleaved MCU,
-               // so now count down the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      }
-   } else {
-      if (z->scan_n == 1) {
-         int i,j;
-         int n = z->order[0];
-         // non-interleaved data, we just need to process one block at a time,
-         // in trivial scanline order
-         // number of blocks to do just depends on how many actual "pixels" this
-         // component has, independent of interleaved MCU blocking and such
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
-               if (z->spec_start == 0) {
-                  if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
-                     return 0;
-               } else {
-                  int ha = z->img_comp[n].ha;
-                  if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha]))
-                     return 0;
-               }
-               // every data block is an MCU, so countdown the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      } else { // interleaved
-         int i,j,k,x,y;
-         for (j=0; j < z->img_mcu_y; ++j) {
-            for (i=0; i < z->img_mcu_x; ++i) {
-               // scan an interleaved mcu... process scan_n components in order
-               for (k=0; k < z->scan_n; ++k) {
-                  int n = z->order[k];
-                  // scan out an mcu's worth of this component; that's just determined
-                  // by the basic H and V specified for the component
-                  for (y=0; y < z->img_comp[n].v; ++y) {
-                     for (x=0; x < z->img_comp[n].h; ++x) {
-                        int x2 = (i*z->img_comp[n].h + x);
-                        int y2 = (j*z->img_comp[n].v + y);
-                        short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w);
-                        if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))
-                           return 0;
-                     }
-                  }
-               }
-               // after all interleaved components, that's an interleaved MCU,
-               // so now count down the restart interval
-               if (--z->todo <= 0) {
-                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);
-                  if (!STBI__RESTART(z->marker)) return 1;
-                  stbi__jpeg_reset(z);
-               }
-            }
-         }
-         return 1;
-      }
-   }
-}
-
-static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)
-{
-   int i;
-   for (i=0; i < 64; ++i)
-      data[i] *= dequant[i];
-}
-
-static void stbi__jpeg_finish(stbi__jpeg *z)
-{
-   if (z->progressive) {
-      // dequantize and idct the data
-      int i,j,n;
-      for (n=0; n < z->s->img_n; ++n) {
-         int w = (z->img_comp[n].x+7) >> 3;
-         int h = (z->img_comp[n].y+7) >> 3;
-         for (j=0; j < h; ++j) {
-            for (i=0; i < w; ++i) {
-               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);
-               stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]);
-               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);
-            }
-         }
-      }
-   }
-}
-
-static int stbi__process_marker(stbi__jpeg *z, int m)
-{
-   int L;
-   switch (m) {
-      case STBI__MARKER_none: // no marker found
-         return stbi__err("expected marker","Corrupt JPEG");
-
-      case 0xDD: // DRI - specify restart interval
-         if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG");
-         z->restart_interval = stbi__get16be(z->s);
-         return 1;
-
-      case 0xDB: // DQT - define quantization table
-         L = stbi__get16be(z->s)-2;
-         while (L > 0) {
-            int q = stbi__get8(z->s);
-            int p = q >> 4, sixteen = (p != 0);
-            int t = q & 15,i;
-            if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG");
-            if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG");
-
-            for (i=0; i < 64; ++i)
-               z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s));
-            L -= (sixteen ? 129 : 65);
-         }
-         return L==0;
-
-      case 0xC4: // DHT - define huffman table
-         L = stbi__get16be(z->s)-2;
-         while (L > 0) {
-            stbi_uc *v;
-            int sizes[16],i,n=0;
-            int q = stbi__get8(z->s);
-            int tc = q >> 4;
-            int th = q & 15;
-            if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG");
-            for (i=0; i < 16; ++i) {
-               sizes[i] = stbi__get8(z->s);
-               n += sizes[i];
-            }
-            L -= 17;
-            if (tc == 0) {
-               if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
-               v = z->huff_dc[th].values;
-            } else {
-               if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0;
-               v = z->huff_ac[th].values;
-            }
-            for (i=0; i < n; ++i)
-               v[i] = stbi__get8(z->s);
-            if (tc != 0)
-               stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th);
-            L -= n;
-         }
-         return L==0;
-   }
-
-   // check for comment block or APP blocks
-   if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) {
-      L = stbi__get16be(z->s);
-      if (L < 2) {
-         if (m == 0xFE)
-            return stbi__err("bad COM len","Corrupt JPEG");
-         else
-            return stbi__err("bad APP len","Corrupt JPEG");
-      }
-      L -= 2;
-
-      if (m == 0xE0 && L >= 5) { // JFIF APP0 segment
-         static const unsigned char tag[5] = {'J','F','I','F','\0'};
-         int ok = 1;
-         int i;
-         for (i=0; i < 5; ++i)
-            if (stbi__get8(z->s) != tag[i])
-               ok = 0;
-         L -= 5;
-         if (ok)
-            z->jfif = 1;
-      } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment
-         static const unsigned char tag[6] = {'A','d','o','b','e','\0'};
-         int ok = 1;
-         int i;
-         for (i=0; i < 6; ++i)
-            if (stbi__get8(z->s) != tag[i])
-               ok = 0;
-         L -= 6;
-         if (ok) {
-            stbi__get8(z->s); // version
-            stbi__get16be(z->s); // flags0
-            stbi__get16be(z->s); // flags1
-            z->app14_color_transform = stbi__get8(z->s); // color transform
-            L -= 6;
-         }
-      }
-
-      stbi__skip(z->s, L);
-      return 1;
-   }
-
-   return stbi__err("unknown marker","Corrupt JPEG");
-}
-
-// after we see SOS
-static int stbi__process_scan_header(stbi__jpeg *z)
-{
-   int i;
-   int Ls = stbi__get16be(z->s);
-   z->scan_n = stbi__get8(z->s);
-   if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG");
-   if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG");
-   for (i=0; i < z->scan_n; ++i) {
-      int id = stbi__get8(z->s), which;
-      int q = stbi__get8(z->s);
-      for (which = 0; which < z->s->img_n; ++which)
-         if (z->img_comp[which].id == id)
-            break;
-      if (which == z->s->img_n) return 0; // no match
-      z->img_comp[which].hd = q >> 4;   if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG");
-      z->img_comp[which].ha = q & 15;   if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG");
-      z->order[i] = which;
-   }
-
-   {
-      int aa;
-      z->spec_start = stbi__get8(z->s);
-      z->spec_end   = stbi__get8(z->s); // should be 63, but might be 0
-      aa = stbi__get8(z->s);
-      z->succ_high = (aa >> 4);
-      z->succ_low  = (aa & 15);
-      if (z->progressive) {
-         if (z->spec_start > 63 || z->spec_end > 63  || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13)
-            return stbi__err("bad SOS", "Corrupt JPEG");
-      } else {
-         if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG");
-         if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG");
-         z->spec_end = 63;
-      }
-   }
-
-   return 1;
-}
-
-static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why)
-{
-   int i;
-   for (i=0; i < ncomp; ++i) {
-      if (z->img_comp[i].raw_data) {
-         STBI_FREE(z->img_comp[i].raw_data);
-         z->img_comp[i].raw_data = NULL;
-         z->img_comp[i].data = NULL;
-      }
-      if (z->img_comp[i].raw_coeff) {
-         STBI_FREE(z->img_comp[i].raw_coeff);
-         z->img_comp[i].raw_coeff = 0;
-         z->img_comp[i].coeff = 0;
-      }
-      if (z->img_comp[i].linebuf) {
-         STBI_FREE(z->img_comp[i].linebuf);
-         z->img_comp[i].linebuf = NULL;
-      }
-   }
-   return why;
-}
-
-static int stbi__process_frame_header(stbi__jpeg *z, int scan)
-{
-   stbi__context *s = z->s;
-   int Lf,p,i,q, h_max=1,v_max=1,c;
-   Lf = stbi__get16be(s);         if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG
-   p  = stbi__get8(s);            if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline
-   s->img_y = stbi__get16be(s);   if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG
-   s->img_x = stbi__get16be(s);   if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   c = stbi__get8(s);
-   if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG");
-   s->img_n = c;
-   for (i=0; i < c; ++i) {
-      z->img_comp[i].data = NULL;
-      z->img_comp[i].linebuf = NULL;
-   }
-
-   if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG");
-
-   z->rgb = 0;
-   for (i=0; i < s->img_n; ++i) {
-      static const unsigned char rgb[3] = { 'R', 'G', 'B' };
-      z->img_comp[i].id = stbi__get8(s);
-      if (s->img_n == 3 && z->img_comp[i].id == rgb[i])
-         ++z->rgb;
-      q = stbi__get8(s);
-      z->img_comp[i].h = (q >> 4);  if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG");
-      z->img_comp[i].v = q & 15;    if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG");
-      z->img_comp[i].tq = stbi__get8(s);  if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG");
-   }
-
-   if (scan != STBI__SCAN_load) return 1;
-
-   if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode");
-
-   for (i=0; i < s->img_n; ++i) {
-      if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;
-      if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;
-   }
-
-   // compute interleaved mcu info
-   z->img_h_max = h_max;
-   z->img_v_max = v_max;
-   z->img_mcu_w = h_max * 8;
-   z->img_mcu_h = v_max * 8;
-   // these sizes can't be more than 17 bits
-   z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w;
-   z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h;
-
-   for (i=0; i < s->img_n; ++i) {
-      // number of effective pixels (e.g. for non-interleaved MCU)
-      z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;
-      z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;
-      // to simplify generation, we'll allocate enough memory to decode
-      // the bogus oversized data from using interleaved MCUs and their
-      // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't
-      // discard the extra data until colorspace conversion
-      //
-      // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier)
-      // so these muls can't overflow with 32-bit ints (which we require)
-      z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
-      z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;
-      z->img_comp[i].coeff = 0;
-      z->img_comp[i].raw_coeff = 0;
-      z->img_comp[i].linebuf = NULL;
-      z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);
-      if (z->img_comp[i].raw_data == NULL)
-         return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
-      // align blocks for idct using mmx/sse
-      z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);
-      if (z->progressive) {
-         // w2, h2 are multiples of 8 (see above)
-         z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8;
-         z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8;
-         z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15);
-         if (z->img_comp[i].raw_coeff == NULL)
-            return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory"));
-         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);
-      }
-   }
-
-   return 1;
-}
-
-// use comparisons since in some cases we handle more than one case (e.g. SOF)
-#define stbi__DNL(x)         ((x) == 0xdc)
-#define stbi__SOI(x)         ((x) == 0xd8)
-#define stbi__EOI(x)         ((x) == 0xd9)
-#define stbi__SOF(x)         ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2)
-#define stbi__SOS(x)         ((x) == 0xda)
-
-#define stbi__SOF_progressive(x)   ((x) == 0xc2)
-
-static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)
-{
-   int m;
-   z->jfif = 0;
-   z->app14_color_transform = -1; // valid values are 0,1,2
-   z->marker = STBI__MARKER_none; // initialize cached marker to empty
-   m = stbi__get_marker(z);
-   if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG");
-   if (scan == STBI__SCAN_type) return 1;
-   m = stbi__get_marker(z);
-   while (!stbi__SOF(m)) {
-      if (!stbi__process_marker(z,m)) return 0;
-      m = stbi__get_marker(z);
-      while (m == STBI__MARKER_none) {
-         // some files have extra padding after their blocks, so ok, we'll scan
-         if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG");
-         m = stbi__get_marker(z);
-      }
-   }
-   z->progressive = stbi__SOF_progressive(m);
-   if (!stbi__process_frame_header(z, scan)) return 0;
-   return 1;
-}
-
-// decode image to YCbCr format
-static int stbi__decode_jpeg_image(stbi__jpeg *j)
-{
-   int m;
-   for (m = 0; m < 4; m++) {
-      j->img_comp[m].raw_data = NULL;
-      j->img_comp[m].raw_coeff = NULL;
-   }
-   j->restart_interval = 0;
-   if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;
-   m = stbi__get_marker(j);
-   while (!stbi__EOI(m)) {
-      if (stbi__SOS(m)) {
-         if (!stbi__process_scan_header(j)) return 0;
-         if (!stbi__parse_entropy_coded_data(j)) return 0;
-         if (j->marker == STBI__MARKER_none ) {
-            // handle 0s at the end of image data from IP Kamera 9060
-            while (!stbi__at_eof(j->s)) {
-               int x = stbi__get8(j->s);
-               if (x == 255) {
-                  j->marker = stbi__get8(j->s);
-                  break;
-               }
-            }
-            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
-         }
-      } else if (stbi__DNL(m)) {
-         int Ld = stbi__get16be(j->s);
-         stbi__uint32 NL = stbi__get16be(j->s);
-         if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
-         if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
-      } else {
-         if (!stbi__process_marker(j, m)) return 0;
-      }
-      m = stbi__get_marker(j);
-   }
-   if (j->progressive)
-      stbi__jpeg_finish(j);
-   return 1;
-}
-
-// static jfif-centered resampling (across block boundaries)
-
-typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1,
-                                    int w, int hs);
-
-#define stbi__div4(x) ((stbi_uc) ((x) >> 2))
-
-static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   STBI_NOTUSED(out);
-   STBI_NOTUSED(in_far);
-   STBI_NOTUSED(w);
-   STBI_NOTUSED(hs);
-   return in_near;
-}
-
-static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate two samples vertically for every one in input
-   int i;
-   STBI_NOTUSED(hs);
-   for (i=0; i < w; ++i)
-      out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2);
-   return out;
-}
-
-static stbi_uc*  stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate two samples horizontally for every one in input
-   int i;
-   stbi_uc *input = in_near;
-
-   if (w == 1) {
-      // if only one sample, can't do any interpolation
-      out[0] = out[1] = input[0];
-      return out;
-   }
-
-   out[0] = input[0];
-   out[1] = stbi__div4(input[0]*3 + input[1] + 2);
-   for (i=1; i < w-1; ++i) {
-      int n = 3*input[i]+2;
-      out[i*2+0] = stbi__div4(n+input[i-1]);
-      out[i*2+1] = stbi__div4(n+input[i+1]);
-   }
-   out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2);
-   out[i*2+1] = input[w-1];
-
-   STBI_NOTUSED(in_far);
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-
-#define stbi__div16(x) ((stbi_uc) ((x) >> 4))
-
-static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate 2x2 samples for every one in input
-   int i,t0,t1;
-   if (w == 1) {
-      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
-      return out;
-   }
-
-   t1 = 3*in_near[0] + in_far[0];
-   out[0] = stbi__div4(t1+2);
-   for (i=1; i < w; ++i) {
-      t0 = t1;
-      t1 = 3*in_near[i]+in_far[i];
-      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
-      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
-   }
-   out[w*2-1] = stbi__div4(t1+2);
-
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-
-#if defined(STBI_SSE2) || defined(STBI_NEON)
-static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // need to generate 2x2 samples for every one in input
-   int i=0,t0,t1;
-
-   if (w == 1) {
-      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);
-      return out;
-   }
-
-   t1 = 3*in_near[0] + in_far[0];
-   // process groups of 8 pixels for as long as we can.
-   // note we can't handle the last pixel in a row in this loop
-   // because we need to handle the filter boundary conditions.
-   for (; i < ((w-1) & ~7); i += 8) {
-#if defined(STBI_SSE2)
-      // load and perform the vertical filtering pass
-      // this uses 3*x + y = 4*x + (y - x)
-      __m128i zero  = _mm_setzero_si128();
-      __m128i farb  = _mm_loadl_epi64((__m128i *) (in_far + i));
-      __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i));
-      __m128i farw  = _mm_unpacklo_epi8(farb, zero);
-      __m128i nearw = _mm_unpacklo_epi8(nearb, zero);
-      __m128i diff  = _mm_sub_epi16(farw, nearw);
-      __m128i nears = _mm_slli_epi16(nearw, 2);
-      __m128i curr  = _mm_add_epi16(nears, diff); // current row
-
-      // horizontal filter works the same based on shifted vers of current
-      // row. "prev" is current row shifted right by 1 pixel; we need to
-      // insert the previous pixel value (from t1).
-      // "next" is current row shifted left by 1 pixel, with first pixel
-      // of next block of 8 pixels added in.
-      __m128i prv0 = _mm_slli_si128(curr, 2);
-      __m128i nxt0 = _mm_srli_si128(curr, 2);
-      __m128i prev = _mm_insert_epi16(prv0, t1, 0);
-      __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7);
-
-      // horizontal filter, polyphase implementation since it's convenient:
-      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
-      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
-      // note the shared term.
-      __m128i bias  = _mm_set1_epi16(8);
-      __m128i curs = _mm_slli_epi16(curr, 2);
-      __m128i prvd = _mm_sub_epi16(prev, curr);
-      __m128i nxtd = _mm_sub_epi16(next, curr);
-      __m128i curb = _mm_add_epi16(curs, bias);
-      __m128i even = _mm_add_epi16(prvd, curb);
-      __m128i odd  = _mm_add_epi16(nxtd, curb);
-
-      // interleave even and odd pixels, then undo scaling.
-      __m128i int0 = _mm_unpacklo_epi16(even, odd);
-      __m128i int1 = _mm_unpackhi_epi16(even, odd);
-      __m128i de0  = _mm_srli_epi16(int0, 4);
-      __m128i de1  = _mm_srli_epi16(int1, 4);
-
-      // pack and write output
-      __m128i outv = _mm_packus_epi16(de0, de1);
-      _mm_storeu_si128((__m128i *) (out + i*2), outv);
-#elif defined(STBI_NEON)
-      // load and perform the vertical filtering pass
-      // this uses 3*x + y = 4*x + (y - x)
-      uint8x8_t farb  = vld1_u8(in_far + i);
-      uint8x8_t nearb = vld1_u8(in_near + i);
-      int16x8_t diff  = vreinterpretq_s16_u16(vsubl_u8(farb, nearb));
-      int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2));
-      int16x8_t curr  = vaddq_s16(nears, diff); // current row
-
-      // horizontal filter works the same based on shifted vers of current
-      // row. "prev" is current row shifted right by 1 pixel; we need to
-      // insert the previous pixel value (from t1).
-      // "next" is current row shifted left by 1 pixel, with first pixel
-      // of next block of 8 pixels added in.
-      int16x8_t prv0 = vextq_s16(curr, curr, 7);
-      int16x8_t nxt0 = vextq_s16(curr, curr, 1);
-      int16x8_t prev = vsetq_lane_s16(t1, prv0, 0);
-      int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7);
-
-      // horizontal filter, polyphase implementation since it's convenient:
-      // even pixels = 3*cur + prev = cur*4 + (prev - cur)
-      // odd  pixels = 3*cur + next = cur*4 + (next - cur)
-      // note the shared term.
-      int16x8_t curs = vshlq_n_s16(curr, 2);
-      int16x8_t prvd = vsubq_s16(prev, curr);
-      int16x8_t nxtd = vsubq_s16(next, curr);
-      int16x8_t even = vaddq_s16(curs, prvd);
-      int16x8_t odd  = vaddq_s16(curs, nxtd);
-
-      // undo scaling and round, then store with even/odd phases interleaved
-      uint8x8x2_t o;
-      o.val[0] = vqrshrun_n_s16(even, 4);
-      o.val[1] = vqrshrun_n_s16(odd,  4);
-      vst2_u8(out + i*2, o);
-#endif
-
-      // "previous" value for next iter
-      t1 = 3*in_near[i+7] + in_far[i+7];
-   }
-
-   t0 = t1;
-   t1 = 3*in_near[i] + in_far[i];
-   out[i*2] = stbi__div16(3*t1 + t0 + 8);
-
-   for (++i; i < w; ++i) {
-      t0 = t1;
-      t1 = 3*in_near[i]+in_far[i];
-      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);
-      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);
-   }
-   out[w*2-1] = stbi__div4(t1+2);
-
-   STBI_NOTUSED(hs);
-
-   return out;
-}
-#endif
-
-static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)
-{
-   // resample with nearest-neighbor
-   int i,j;
-   STBI_NOTUSED(in_far);
-   for (i=0; i < w; ++i)
-      for (j=0; j < hs; ++j)
-         out[i*hs+j] = in_near[i];
-   return out;
-}
-
-// this is a reduced-precision calculation of YCbCr-to-RGB introduced
-// to make sure the code produces the same results in both SIMD and scalar
-#define stbi__float2fixed(x)  (((int) ((x) * 4096.0f + 0.5f)) << 8)
-static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
-{
-   int i;
-   for (i=0; i < count; ++i) {
-      int y_fixed = (y[i] << 20) + (1<<19); // rounding
-      int r,g,b;
-      int cr = pcr[i] - 128;
-      int cb = pcb[i] - 128;
-      r = y_fixed +  cr* stbi__float2fixed(1.40200f);
-      g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
-      b = y_fixed                                     +   cb* stbi__float2fixed(1.77200f);
-      r >>= 20;
-      g >>= 20;
-      b >>= 20;
-      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
-      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
-      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
-      out[0] = (stbi_uc)r;
-      out[1] = (stbi_uc)g;
-      out[2] = (stbi_uc)b;
-      out[3] = 255;
-      out += step;
-   }
-}
-
-#if defined(STBI_SSE2) || defined(STBI_NEON)
-static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)
-{
-   int i = 0;
-
-#ifdef STBI_SSE2
-   // step == 3 is pretty ugly on the final interleave, and i'm not convinced
-   // it's useful in practice (you wouldn't use it for textures, for example).
-   // so just accelerate step == 4 case.
-   if (step == 4) {
-      // this is a fairly straightforward implementation and not super-optimized.
-      __m128i signflip  = _mm_set1_epi8(-0x80);
-      __m128i cr_const0 = _mm_set1_epi16(   (short) ( 1.40200f*4096.0f+0.5f));
-      __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));
-      __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));
-      __m128i cb_const1 = _mm_set1_epi16(   (short) ( 1.77200f*4096.0f+0.5f));
-      __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);
-      __m128i xw = _mm_set1_epi16(255); // alpha channel
-
-      for (; i+7 < count; i += 8) {
-         // load
-         __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i));
-         __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i));
-         __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i));
-         __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128
-         __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128
-
-         // unpack to short (and left-shift cr, cb by 8)
-         __m128i yw  = _mm_unpacklo_epi8(y_bias, y_bytes);
-         __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased);
-         __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased);
-
-         // color transform
-         __m128i yws = _mm_srli_epi16(yw, 4);
-         __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw);
-         __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw);
-         __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1);
-         __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1);
-         __m128i rws = _mm_add_epi16(cr0, yws);
-         __m128i gwt = _mm_add_epi16(cb0, yws);
-         __m128i bws = _mm_add_epi16(yws, cb1);
-         __m128i gws = _mm_add_epi16(gwt, cr1);
-
-         // descale
-         __m128i rw = _mm_srai_epi16(rws, 4);
-         __m128i bw = _mm_srai_epi16(bws, 4);
-         __m128i gw = _mm_srai_epi16(gws, 4);
-
-         // back to byte, set up for transpose
-         __m128i brb = _mm_packus_epi16(rw, bw);
-         __m128i gxb = _mm_packus_epi16(gw, xw);
-
-         // transpose to interleave channels
-         __m128i t0 = _mm_unpacklo_epi8(brb, gxb);
-         __m128i t1 = _mm_unpackhi_epi8(brb, gxb);
-         __m128i o0 = _mm_unpacklo_epi16(t0, t1);
-         __m128i o1 = _mm_unpackhi_epi16(t0, t1);
-
-         // store
-         _mm_storeu_si128((__m128i *) (out + 0), o0);
-         _mm_storeu_si128((__m128i *) (out + 16), o1);
-         out += 32;
-      }
-   }
-#endif
-
-#ifdef STBI_NEON
-   // in this version, step=3 support would be easy to add. but is there demand?
-   if (step == 4) {
-      // this is a fairly straightforward implementation and not super-optimized.
-      uint8x8_t signflip = vdup_n_u8(0x80);
-      int16x8_t cr_const0 = vdupq_n_s16(   (short) ( 1.40200f*4096.0f+0.5f));
-      int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f));
-      int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f));
-      int16x8_t cb_const1 = vdupq_n_s16(   (short) ( 1.77200f*4096.0f+0.5f));
-
-      for (; i+7 < count; i += 8) {
-         // load
-         uint8x8_t y_bytes  = vld1_u8(y + i);
-         uint8x8_t cr_bytes = vld1_u8(pcr + i);
-         uint8x8_t cb_bytes = vld1_u8(pcb + i);
-         int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip));
-         int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip));
-
-         // expand to s16
-         int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4));
-         int16x8_t crw = vshll_n_s8(cr_biased, 7);
-         int16x8_t cbw = vshll_n_s8(cb_biased, 7);
-
-         // color transform
-         int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0);
-         int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0);
-         int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1);
-         int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1);
-         int16x8_t rws = vaddq_s16(yws, cr0);
-         int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1);
-         int16x8_t bws = vaddq_s16(yws, cb1);
-
-         // undo scaling, round, convert to byte
-         uint8x8x4_t o;
-         o.val[0] = vqrshrun_n_s16(rws, 4);
-         o.val[1] = vqrshrun_n_s16(gws, 4);
-         o.val[2] = vqrshrun_n_s16(bws, 4);
-         o.val[3] = vdup_n_u8(255);
-
-         // store, interleaving r/g/b/a
-         vst4_u8(out, o);
-         out += 8*4;
-      }
-   }
-#endif
-
-   for (; i < count; ++i) {
-      int y_fixed = (y[i] << 20) + (1<<19); // rounding
-      int r,g,b;
-      int cr = pcr[i] - 128;
-      int cb = pcb[i] - 128;
-      r = y_fixed + cr* stbi__float2fixed(1.40200f);
-      g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);
-      b = y_fixed                                   +   cb* stbi__float2fixed(1.77200f);
-      r >>= 20;
-      g >>= 20;
-      b >>= 20;
-      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
-      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
-      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
-      out[0] = (stbi_uc)r;
-      out[1] = (stbi_uc)g;
-      out[2] = (stbi_uc)b;
-      out[3] = 255;
-      out += step;
-   }
-}
-#endif
-
-// set up the kernels
-static void stbi__setup_jpeg(stbi__jpeg *j)
-{
-   j->idct_block_kernel = stbi__idct_block;
-   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row;
-   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2;
-
-#ifdef STBI_SSE2
-   if (stbi__sse2_available()) {
-      j->idct_block_kernel = stbi__idct_simd;
-      j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
-      j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
-   }
-#endif
-
-#ifdef STBI_NEON
-   j->idct_block_kernel = stbi__idct_simd;
-   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;
-   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;
-#endif
-}
-
-// clean up the temporary component buffers
-static void stbi__cleanup_jpeg(stbi__jpeg *j)
-{
-   stbi__free_jpeg_components(j, j->s->img_n, 0);
-}
-
-typedef struct
-{
-   resample_row_func resample;
-   stbi_uc *line0,*line1;
-   int hs,vs;   // expansion factor in each axis
-   int w_lores; // horizontal pixels pre-expansion
-   int ystep;   // how far through vertical expansion we are
-   int ypos;    // which pre-expansion row we're on
-} stbi__resample;
-
-// fast 0..255 * 0..255 => 0..255 rounded multiplication
-static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y)
-{
-   unsigned int t = x*y + 128;
-   return (stbi_uc) ((t + (t >>8)) >> 8);
-}
-
-static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)
-{
-   int n, decode_n, is_rgb;
-   z->s->img_n = 0; // make stbi__cleanup_jpeg safe
-
-   // validate req_comp
-   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
-
-   // load a jpeg image from whichever source, but leave in YCbCr format
-   if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; }
-
-   // determine actual number of components to generate
-   n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1;
-
-   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));
-
-   if (z->s->img_n == 3 && n < 3 && !is_rgb)
-      decode_n = 1;
-   else
-      decode_n = z->s->img_n;
-
-   // resample and color-convert
-   {
-      int k;
-      unsigned int i,j;
-      stbi_uc *output;
-      stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL };
-
-      stbi__resample res_comp[4];
-
-      for (k=0; k < decode_n; ++k) {
-         stbi__resample *r = &res_comp[k];
-
-         // allocate line buffer big enough for upsampling off the edges
-         // with upsample factor of 4
-         z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3);
-         if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
-
-         r->hs      = z->img_h_max / z->img_comp[k].h;
-         r->vs      = z->img_v_max / z->img_comp[k].v;
-         r->ystep   = r->vs >> 1;
-         r->w_lores = (z->s->img_x + r->hs-1) / r->hs;
-         r->ypos    = 0;
-         r->line0   = r->line1 = z->img_comp[k].data;
-
-         if      (r->hs == 1 && r->vs == 1) r->resample = resample_row_1;
-         else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2;
-         else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2;
-         else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel;
-         else                               r->resample = stbi__resample_row_generic;
-      }
-
-      // can't error after this so, this is safe
-      output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1);
-      if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); }
-
-      // now go ahead and resample
-      for (j=0; j < z->s->img_y; ++j) {
-         stbi_uc *out = output + n * z->s->img_x * j;
-         for (k=0; k < decode_n; ++k) {
-            stbi__resample *r = &res_comp[k];
-            int y_bot = r->ystep >= (r->vs >> 1);
-            coutput[k] = r->resample(z->img_comp[k].linebuf,
-                                     y_bot ? r->line1 : r->line0,
-                                     y_bot ? r->line0 : r->line1,
-                                     r->w_lores, r->hs);
-            if (++r->ystep >= r->vs) {
-               r->ystep = 0;
-               r->line0 = r->line1;
-               if (++r->ypos < z->img_comp[k].y)
-                  r->line1 += z->img_comp[k].w2;
-            }
-         }
-         if (n >= 3) {
-            stbi_uc *y = coutput[0];
-            if (z->s->img_n == 3) {
-               if (is_rgb) {
-                  for (i=0; i < z->s->img_x; ++i) {
-                     out[0] = y[i];
-                     out[1] = coutput[1][i];
-                     out[2] = coutput[2][i];
-                     out[3] = 255;
-                     out += n;
-                  }
-               } else {
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-               }
-            } else if (z->s->img_n == 4) {
-               if (z->app14_color_transform == 0) { // CMYK
-                  for (i=0; i < z->s->img_x; ++i) {
-                     stbi_uc m = coutput[3][i];
-                     out[0] = stbi__blinn_8x8(coutput[0][i], m);
-                     out[1] = stbi__blinn_8x8(coutput[1][i], m);
-                     out[2] = stbi__blinn_8x8(coutput[2][i], m);
-                     out[3] = 255;
-                     out += n;
-                  }
-               } else if (z->app14_color_transform == 2) { // YCCK
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-                  for (i=0; i < z->s->img_x; ++i) {
-                     stbi_uc m = coutput[3][i];
-                     out[0] = stbi__blinn_8x8(255 - out[0], m);
-                     out[1] = stbi__blinn_8x8(255 - out[1], m);
-                     out[2] = stbi__blinn_8x8(255 - out[2], m);
-                     out += n;
-                  }
-               } else { // YCbCr + alpha?  Ignore the fourth channel for now
-                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);
-               }
-            } else
-               for (i=0; i < z->s->img_x; ++i) {
-                  out[0] = out[1] = out[2] = y[i];
-                  out[3] = 255; // not used if n==3
-                  out += n;
-               }
-         } else {
-            if (is_rgb) {
-               if (n == 1)
-                  for (i=0; i < z->s->img_x; ++i)
-                     *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
-               else {
-                  for (i=0; i < z->s->img_x; ++i, out += 2) {
-                     out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);
-                     out[1] = 255;
-                  }
-               }
-            } else if (z->s->img_n == 4 && z->app14_color_transform == 0) {
-               for (i=0; i < z->s->img_x; ++i) {
-                  stbi_uc m = coutput[3][i];
-                  stbi_uc r = stbi__blinn_8x8(coutput[0][i], m);
-                  stbi_uc g = stbi__blinn_8x8(coutput[1][i], m);
-                  stbi_uc b = stbi__blinn_8x8(coutput[2][i], m);
-                  out[0] = stbi__compute_y(r, g, b);
-                  out[1] = 255;
-                  out += n;
-               }
-            } else if (z->s->img_n == 4 && z->app14_color_transform == 2) {
-               for (i=0; i < z->s->img_x; ++i) {
-                  out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]);
-                  out[1] = 255;
-                  out += n;
-               }
-            } else {
-               stbi_uc *y = coutput[0];
-               if (n == 1)
-                  for (i=0; i < z->s->img_x; ++i) out[i] = y[i];
-               else
-                  for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; }
-            }
-         }
-      }
-      stbi__cleanup_jpeg(z);
-      *out_x = z->s->img_x;
-      *out_y = z->s->img_y;
-      if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output
-      return output;
-   }
-}
-
-static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   unsigned char* result;
-   stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
-   STBI_NOTUSED(ri);
-   j->s = s;
-   stbi__setup_jpeg(j);
-   result = load_jpeg_image(j, x,y,comp,req_comp);
-   STBI_FREE(j);
-   return result;
-}
-
-static int stbi__jpeg_test(stbi__context *s)
-{
-   int r;
-   stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
-   j->s = s;
-   stbi__setup_jpeg(j);
-   r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
-   stbi__rewind(s);
-   STBI_FREE(j);
-   return r;
-}
-
-static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp)
-{
-   if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) {
-      stbi__rewind( j->s );
-      return 0;
-   }
-   if (x) *x = j->s->img_x;
-   if (y) *y = j->s->img_y;
-   if (comp) *comp = j->s->img_n >= 3 ? 3 : 1;
-   return 1;
-}
-
-static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int result;
-   stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
-   j->s = s;
-   result = stbi__jpeg_info_raw(j, x, y, comp);
-   STBI_FREE(j);
-   return result;
-}
-#endif
-
-// public domain zlib decode    v0.2  Sean Barrett 2006-11-18
-//    simple implementation
-//      - all input must be provided in an upfront buffer
-//      - all output is written to a single output buffer (can malloc/realloc)
-//    performance
-//      - fast huffman
-
-#ifndef STBI_NO_ZLIB
-
-// fast-way is faster to check than jpeg huffman, but slow way is slower
-#define STBI__ZFAST_BITS  9 // accelerate all cases in default tables
-#define STBI__ZFAST_MASK  ((1 << STBI__ZFAST_BITS) - 1)
-
-// zlib-style huffman encoding
-// (jpegs packs from left, zlib from right, so can't share code)
-typedef struct
-{
-   stbi__uint16 fast[1 << STBI__ZFAST_BITS];
-   stbi__uint16 firstcode[16];
-   int maxcode[17];
-   stbi__uint16 firstsymbol[16];
-   stbi_uc  size[288];
-   stbi__uint16 value[288];
-} stbi__zhuffman;
-
-stbi_inline static int stbi__bitreverse16(int n)
-{
-  n = ((n & 0xAAAA) >>  1) | ((n & 0x5555) << 1);
-  n = ((n & 0xCCCC) >>  2) | ((n & 0x3333) << 2);
-  n = ((n & 0xF0F0) >>  4) | ((n & 0x0F0F) << 4);
-  n = ((n & 0xFF00) >>  8) | ((n & 0x00FF) << 8);
-  return n;
-}
-
-stbi_inline static int stbi__bit_reverse(int v, int bits)
-{
-   STBI_ASSERT(bits <= 16);
-   // to bit reverse n bits, reverse 16 and shift
-   // e.g. 11 bits, bit reverse and shift away 5
-   return stbi__bitreverse16(v) >> (16-bits);
-}
-
-static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num)
-{
-   int i,k=0;
-   int code, next_code[16], sizes[17];
-
-   // DEFLATE spec for generating codes
-   memset(sizes, 0, sizeof(sizes));
-   memset(z->fast, 0, sizeof(z->fast));
-   for (i=0; i < num; ++i)
-      ++sizes[sizelist[i]];
-   sizes[0] = 0;
-   for (i=1; i < 16; ++i)
-      if (sizes[i] > (1 << i))
-         return stbi__err("bad sizes", "Corrupt PNG");
-   code = 0;
-   for (i=1; i < 16; ++i) {
-      next_code[i] = code;
-      z->firstcode[i] = (stbi__uint16) code;
-      z->firstsymbol[i] = (stbi__uint16) k;
-      code = (code + sizes[i]);
-      if (sizes[i])
-         if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG");
-      z->maxcode[i] = code << (16-i); // preshift for inner loop
-      code <<= 1;
-      k += sizes[i];
-   }
-   z->maxcode[16] = 0x10000; // sentinel
-   for (i=0; i < num; ++i) {
-      int s = sizelist[i];
-      if (s) {
-         int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];
-         stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i);
-         z->size [c] = (stbi_uc     ) s;
-         z->value[c] = (stbi__uint16) i;
-         if (s <= STBI__ZFAST_BITS) {
-            int j = stbi__bit_reverse(next_code[s],s);
-            while (j < (1 << STBI__ZFAST_BITS)) {
-               z->fast[j] = fastv;
-               j += (1 << s);
-            }
-         }
-         ++next_code[s];
-      }
-   }
-   return 1;
-}
-
-// zlib-from-memory implementation for PNG reading
-//    because PNG allows splitting the zlib stream arbitrarily,
-//    and it's annoying structurally to have PNG call ZLIB call PNG,
-//    we require PNG read all the IDATs and combine them into a single
-//    memory buffer
-
-typedef struct
-{
-   stbi_uc *zbuffer, *zbuffer_end;
-   int num_bits;
-   stbi__uint32 code_buffer;
-
-   char *zout;
-   char *zout_start;
-   char *zout_end;
-   int   z_expandable;
-
-   stbi__zhuffman z_length, z_distance;
-} stbi__zbuf;
-
-stbi_inline static int stbi__zeof(stbi__zbuf *z)
-{
-   return (z->zbuffer >= z->zbuffer_end);
-}
-
-stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z)
-{
-   return stbi__zeof(z) ? 0 : *z->zbuffer++;
-}
-
-static void stbi__fill_bits(stbi__zbuf *z)
-{
-   do {
-      if (z->code_buffer >= (1U << z->num_bits)) {
-        z->zbuffer = z->zbuffer_end;  /* treat this as EOF so we fail. */
-        return;
-      }
-      z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits;
-      z->num_bits += 8;
-   } while (z->num_bits <= 24);
-}
-
-stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n)
-{
-   unsigned int k;
-   if (z->num_bits < n) stbi__fill_bits(z);
-   k = z->code_buffer & ((1 << n) - 1);
-   z->code_buffer >>= n;
-   z->num_bits -= n;
-   return k;
-}
-
-static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)
-{
-   int b,s,k;
-   // not resolved by fast table, so compute it the slow way
-   // use jpeg approach, which requires MSbits at top
-   k = stbi__bit_reverse(a->code_buffer, 16);
-   for (s=STBI__ZFAST_BITS+1; ; ++s)
-      if (k < z->maxcode[s])
-         break;
-   if (s >= 16) return -1; // invalid code!
-   // code size is s, so:
-   b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];
-   if (b >= sizeof (z->size)) return -1; // some data was corrupt somewhere!
-   if (z->size[b] != s) return -1;  // was originally an assert, but report failure instead.
-   a->code_buffer >>= s;
-   a->num_bits -= s;
-   return z->value[b];
-}
-
-stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)
-{
-   int b,s;
-   if (a->num_bits < 16) {
-      if (stbi__zeof(a)) {
-         return -1;   /* report error for unexpected end of data. */
-      }
-      stbi__fill_bits(a);
-   }
-   b = z->fast[a->code_buffer & STBI__ZFAST_MASK];
-   if (b) {
-      s = b >> 9;
-      a->code_buffer >>= s;
-      a->num_bits -= s;
-      return b & 511;
-   }
-   return stbi__zhuffman_decode_slowpath(a, z);
-}
-
-static int stbi__zexpand(stbi__zbuf *z, char *zout, int n)  // need to make room for n bytes
-{
-   char *q;
-   unsigned int cur, limit, old_limit;
-   z->zout = zout;
-   if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG");
-   cur   = (unsigned int) (z->zout - z->zout_start);
-   limit = old_limit = (unsigned) (z->zout_end - z->zout_start);
-   if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory");
-   while (cur + n > limit) {
-      if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory");
-      limit *= 2;
-   }
-   q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);
-   STBI_NOTUSED(old_limit);
-   if (q == NULL) return stbi__err("outofmem", "Out of memory");
-   z->zout_start = q;
-   z->zout       = q + cur;
-   z->zout_end   = q + limit;
-   return 1;
-}
-
-static const int stbi__zlength_base[31] = {
-   3,4,5,6,7,8,9,10,11,13,
-   15,17,19,23,27,31,35,43,51,59,
-   67,83,99,115,131,163,195,227,258,0,0 };
-
-static const int stbi__zlength_extra[31]=
-{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };
-
-static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,
-257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};
-
-static const int stbi__zdist_extra[32] =
-{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-static int stbi__parse_huffman_block(stbi__zbuf *a)
-{
-   char *zout = a->zout;
-   for(;;) {
-      int z = stbi__zhuffman_decode(a, &a->z_length);
-      if (z < 256) {
-         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes
-         if (zout >= a->zout_end) {
-            if (!stbi__zexpand(a, zout, 1)) return 0;
-            zout = a->zout;
-         }
-         *zout++ = (char) z;
-      } else {
-         stbi_uc *p;
-         int len,dist;
-         if (z == 256) {
-            a->zout = zout;
-            return 1;
-         }
-         z -= 257;
-         len = stbi__zlength_base[z];
-         if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);
-         z = stbi__zhuffman_decode(a, &a->z_distance);
-         if (z < 0) return stbi__err("bad huffman code","Corrupt PNG");
-         dist = stbi__zdist_base[z];
-         if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);
-         if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG");
-         if (zout + len > a->zout_end) {
-            if (!stbi__zexpand(a, zout, len)) return 0;
-            zout = a->zout;
-         }
-         p = (stbi_uc *) (zout - dist);
-         if (dist == 1) { // run of one byte; common in images.
-            stbi_uc v = *p;
-            if (len) { do *zout++ = v; while (--len); }
-         } else {
-            if (len) { do *zout++ = *p++; while (--len); }
-         }
-      }
-   }
-}
-
-static int stbi__compute_huffman_codes(stbi__zbuf *a)
-{
-   static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
-   stbi__zhuffman z_codelength;
-   stbi_uc lencodes[286+32+137];//padding for maximum single op
-   stbi_uc codelength_sizes[19];
-   int i,n;
-
-   int hlit  = stbi__zreceive(a,5) + 257;
-   int hdist = stbi__zreceive(a,5) + 1;
-   int hclen = stbi__zreceive(a,4) + 4;
-   int ntot  = hlit + hdist;
-
-   memset(codelength_sizes, 0, sizeof(codelength_sizes));
-   for (i=0; i < hclen; ++i) {
-      int s = stbi__zreceive(a,3);
-      codelength_sizes[length_dezigzag[i]] = (stbi_uc) s;
-   }
-   if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;
-
-   n = 0;
-   while (n < ntot) {
-      int c = stbi__zhuffman_decode(a, &z_codelength);
-      if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG");
-      if (c < 16)
-         lencodes[n++] = (stbi_uc) c;
-      else {
-         stbi_uc fill = 0;
-         if (c == 16) {
-            c = stbi__zreceive(a,2)+3;
-            if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG");
-            fill = lencodes[n-1];
-         } else if (c == 17) {
-            c = stbi__zreceive(a,3)+3;
-         } else if (c == 18) {
-            c = stbi__zreceive(a,7)+11;
-         } else {
-            return stbi__err("bad codelengths", "Corrupt PNG");
-         }
-         if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG");
-         memset(lencodes+n, fill, c);
-         n += c;
-      }
-   }
-   if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG");
-   if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0;
-   if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0;
-   return 1;
-}
-
-static int stbi__parse_uncompressed_block(stbi__zbuf *a)
-{
-   stbi_uc header[4];
-   int len,nlen,k;
-   if (a->num_bits & 7)
-      stbi__zreceive(a, a->num_bits & 7); // discard
-   // drain the bit-packed data into header
-   k = 0;
-   while (a->num_bits > 0) {
-      header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check
-      a->code_buffer >>= 8;
-      a->num_bits -= 8;
-   }
-   if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG");
-   // now fill header the normal way
-   while (k < 4)
-      header[k++] = stbi__zget8(a);
-   len  = header[1] * 256 + header[0];
-   nlen = header[3] * 256 + header[2];
-   if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG");
-   if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG");
-   if (a->zout + len > a->zout_end)
-      if (!stbi__zexpand(a, a->zout, len)) return 0;
-   memcpy(a->zout, a->zbuffer, len);
-   a->zbuffer += len;
-   a->zout += len;
-   return 1;
-}
-
-static int stbi__parse_zlib_header(stbi__zbuf *a)
-{
-   int cmf   = stbi__zget8(a);
-   int cm    = cmf & 15;
-   /* int cinfo = cmf >> 4; */
-   int flg   = stbi__zget8(a);
-   if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
-   if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
-   if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
-   if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
-   // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
-   return 1;
-}
-
-static const stbi_uc stbi__zdefault_length[288] =
-{
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
-   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
-   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8
-};
-static const stbi_uc stbi__zdefault_distance[32] =
-{
-   5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
-};
-/*
-Init algorithm:
-{
-   int i;   // use <= to match clearly with spec
-   for (i=0; i <= 143; ++i)     stbi__zdefault_length[i]   = 8;
-   for (   ; i <= 255; ++i)     stbi__zdefault_length[i]   = 9;
-   for (   ; i <= 279; ++i)     stbi__zdefault_length[i]   = 7;
-   for (   ; i <= 287; ++i)     stbi__zdefault_length[i]   = 8;
-
-   for (i=0; i <=  31; ++i)     stbi__zdefault_distance[i] = 5;
-}
-*/
-
-static int stbi__parse_zlib(stbi__zbuf *a, int parse_header)
-{
-   int final, type;
-   if (parse_header)
-      if (!stbi__parse_zlib_header(a)) return 0;
-   a->num_bits = 0;
-   a->code_buffer = 0;
-   do {
-      final = stbi__zreceive(a,1);
-      type = stbi__zreceive(a,2);
-      if (type == 0) {
-         if (!stbi__parse_uncompressed_block(a)) return 0;
-      } else if (type == 3) {
-         return 0;
-      } else {
-         if (type == 1) {
-            // use fixed code lengths
-            if (!stbi__zbuild_huffman(&a->z_length  , stbi__zdefault_length  , 288)) return 0;
-            if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance,  32)) return 0;
-         } else {
-            if (!stbi__compute_huffman_codes(a)) return 0;
-         }
-         if (!stbi__parse_huffman_block(a)) return 0;
-      }
-   } while (!final);
-   return 1;
-}
-
-static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header)
-{
-   a->zout_start = obuf;
-   a->zout       = obuf;
-   a->zout_end   = obuf + olen;
-   a->z_expandable = exp;
-
-   return stbi__parse_zlib(a, parse_header);
-}
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer + len;
-   if (stbi__do_zlib(&a, p, initial_size, 1, 1)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)
-{
-   return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen);
-}
-
-STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(initial_size);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer + len;
-   if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)
-{
-   stbi__zbuf a;
-   a.zbuffer = (stbi_uc *) ibuffer;
-   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
-   if (stbi__do_zlib(&a, obuffer, olen, 0, 1))
-      return (int) (a.zout - a.zout_start);
-   else
-      return -1;
-}
-
-STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)
-{
-   stbi__zbuf a;
-   char *p = (char *) stbi__malloc(16384);
-   if (p == NULL) return NULL;
-   a.zbuffer = (stbi_uc *) buffer;
-   a.zbuffer_end = (stbi_uc *) buffer+len;
-   if (stbi__do_zlib(&a, p, 16384, 1, 0)) {
-      if (outlen) *outlen = (int) (a.zout - a.zout_start);
-      return a.zout_start;
-   } else {
-      STBI_FREE(a.zout_start);
-      return NULL;
-   }
-}
-
-STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen)
-{
-   stbi__zbuf a;
-   a.zbuffer = (stbi_uc *) ibuffer;
-   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;
-   if (stbi__do_zlib(&a, obuffer, olen, 0, 0))
-      return (int) (a.zout - a.zout_start);
-   else
-      return -1;
-}
-#endif
-
-// public domain "baseline" PNG decoder   v0.10  Sean Barrett 2006-11-18
-//    simple implementation
-//      - only 8-bit samples
-//      - no CRC checking
-//      - allocates lots of intermediate memory
-//        - avoids problem of streaming data between subsystems
-//        - avoids explicit window management
-//    performance
-//      - uses stb_zlib, a PD zlib implementation with fast huffman decoding
-
-#ifndef STBI_NO_PNG
-typedef struct
-{
-   stbi__uint32 length;
-   stbi__uint32 type;
-} stbi__pngchunk;
-
-static stbi__pngchunk stbi__get_chunk_header(stbi__context *s)
-{
-   stbi__pngchunk c;
-   c.length = stbi__get32be(s);
-   c.type   = stbi__get32be(s);
-   return c;
-}
-
-static int stbi__check_png_header(stbi__context *s)
-{
-   static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 };
-   int i;
-   for (i=0; i < 8; ++i)
-      if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG");
-   return 1;
-}
-
-typedef struct
-{
-   stbi__context *s;
-   stbi_uc *idata, *expanded, *out;
-   int depth;
-} stbi__png;
-
-
-enum {
-   STBI__F_none=0,
-   STBI__F_sub=1,
-   STBI__F_up=2,
-   STBI__F_avg=3,
-   STBI__F_paeth=4,
-   // synthetic filters used for first scanline to avoid needing a dummy row of 0s
-   STBI__F_avg_first,
-   STBI__F_paeth_first
-};
-
-static stbi_uc first_row_filter[5] =
-{
-   STBI__F_none,
-   STBI__F_sub,
-   STBI__F_none,
-   STBI__F_avg_first,
-   STBI__F_paeth_first
-};
-
-static int stbi__paeth(int a, int b, int c)
-{
-   int p = a + b - c;
-   int pa = abs(p-a);
-   int pb = abs(p-b);
-   int pc = abs(p-c);
-   if (pa <= pb && pa <= pc) return a;
-   if (pb <= pc) return b;
-   return c;
-}
-
-static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 };
-
-// create the png data from post-deflated data
-static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color)
-{
-   int bytes = (depth == 16? 2 : 1);
-   stbi__context *s = a->s;
-   stbi__uint32 i,j,stride = x*out_n*bytes;
-   stbi__uint32 img_len, img_width_bytes;
-   int k;
-   int img_n = s->img_n; // copy it into a local for later
-
-   int output_bytes = out_n*bytes;
-   int filter_bytes = img_n*bytes;
-   int width = x;
-
-   STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1);
-   a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into
-   if (!a->out) return stbi__err("outofmem", "Out of memory");
-
-   if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG");
-   img_width_bytes = (((img_n * x * depth) + 7) >> 3);
-   img_len = (img_width_bytes + 1) * y;
-
-   // we used to check for exact match between raw_len and img_len on non-interlaced PNGs,
-   // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros),
-   // so just check for raw_len < img_len always.
-   if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG");
-
-   for (j=0; j < y; ++j) {
-      stbi_uc *cur = a->out + stride*j;
-      stbi_uc *prior;
-      int filter = *raw++;
-
-      if (filter > 4)
-         return stbi__err("invalid filter","Corrupt PNG");
-
-      if (depth < 8) {
-         if (img_width_bytes > x) return stbi__err("invalid width","Corrupt PNG");
-         cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place
-         filter_bytes = 1;
-         width = img_width_bytes;
-      }
-      prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above
-
-      // if first row, use special filter that doesn't sample previous row
-      if (j == 0) filter = first_row_filter[filter];
-
-      // handle first byte explicitly
-      for (k=0; k < filter_bytes; ++k) {
-         switch (filter) {
-            case STBI__F_none       : cur[k] = raw[k]; break;
-            case STBI__F_sub        : cur[k] = raw[k]; break;
-            case STBI__F_up         : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;
-            case STBI__F_avg        : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break;
-            case STBI__F_paeth      : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break;
-            case STBI__F_avg_first  : cur[k] = raw[k]; break;
-            case STBI__F_paeth_first: cur[k] = raw[k]; break;
-         }
-      }
-
-      if (depth == 8) {
-         if (img_n != out_n)
-            cur[img_n] = 255; // first pixel
-         raw += img_n;
-         cur += out_n;
-         prior += out_n;
-      } else if (depth == 16) {
-         if (img_n != out_n) {
-            cur[filter_bytes]   = 255; // first pixel top byte
-            cur[filter_bytes+1] = 255; // first pixel bottom byte
-         }
-         raw += filter_bytes;
-         cur += output_bytes;
-         prior += output_bytes;
-      } else {
-         raw += 1;
-         cur += 1;
-         prior += 1;
-      }
-
-      // this is a little gross, so that we don't switch per-pixel or per-component
-      if (depth < 8 || img_n == out_n) {
-         int nk = (width - 1)*filter_bytes;
-         #define STBI__CASE(f) \
-             case f:     \
-                for (k=0; k < nk; ++k)
-         switch (filter) {
-            // "none" filter turns into a memcpy here; make that explicit.
-            case STBI__F_none:         memcpy(cur, raw, nk); break;
-            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break;
-            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
-            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break;
-            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break;
-            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break;
-            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break;
-         }
-         #undef STBI__CASE
-         raw += nk;
-      } else {
-         STBI_ASSERT(img_n+1 == out_n);
-         #define STBI__CASE(f) \
-             case f:     \
-                for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \
-                   for (k=0; k < filter_bytes; ++k)
-         switch (filter) {
-            STBI__CASE(STBI__F_none)         { cur[k] = raw[k]; } break;
-            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break;
-            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;
-            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break;
-            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break;
-            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break;
-            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break;
-         }
-         #undef STBI__CASE
-
-         // the loop above sets the high byte of the pixels' alpha, but for
-         // 16 bit png files we also need the low byte set. we'll do that here.
-         if (depth == 16) {
-            cur = a->out + stride*j; // start at the beginning of the row again
-            for (i=0; i < x; ++i,cur+=output_bytes) {
-               cur[filter_bytes+1] = 255;
-            }
-         }
-      }
-   }
-
-   // we make a separate pass to expand bits to pixels; for performance,
-   // this could run two scanlines behind the above code, so it won't
-   // intefere with filtering but will still be in the cache.
-   if (depth < 8) {
-      for (j=0; j < y; ++j) {
-         stbi_uc *cur = a->out + stride*j;
-         stbi_uc *in  = a->out + stride*j + x*out_n - img_width_bytes;
-         // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit
-         // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop
-         stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range
-
-         // note that the final byte might overshoot and write more data than desired.
-         // we can allocate enough data that this never writes out of memory, but it
-         // could also overwrite the next scanline. can it overwrite non-empty data
-         // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel.
-         // so we need to explicitly clamp the final ones
-
-         if (depth == 4) {
-            for (k=x*img_n; k >= 2; k-=2, ++in) {
-               *cur++ = scale * ((*in >> 4)       );
-               *cur++ = scale * ((*in     ) & 0x0f);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 4)       );
-         } else if (depth == 2) {
-            for (k=x*img_n; k >= 4; k-=4, ++in) {
-               *cur++ = scale * ((*in >> 6)       );
-               *cur++ = scale * ((*in >> 4) & 0x03);
-               *cur++ = scale * ((*in >> 2) & 0x03);
-               *cur++ = scale * ((*in     ) & 0x03);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 6)       );
-            if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03);
-            if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03);
-         } else if (depth == 1) {
-            for (k=x*img_n; k >= 8; k-=8, ++in) {
-               *cur++ = scale * ((*in >> 7)       );
-               *cur++ = scale * ((*in >> 6) & 0x01);
-               *cur++ = scale * ((*in >> 5) & 0x01);
-               *cur++ = scale * ((*in >> 4) & 0x01);
-               *cur++ = scale * ((*in >> 3) & 0x01);
-               *cur++ = scale * ((*in >> 2) & 0x01);
-               *cur++ = scale * ((*in >> 1) & 0x01);
-               *cur++ = scale * ((*in     ) & 0x01);
-            }
-            if (k > 0) *cur++ = scale * ((*in >> 7)       );
-            if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01);
-            if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01);
-            if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01);
-            if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01);
-            if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01);
-            if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01);
-         }
-         if (img_n != out_n) {
-            int q;
-            // insert alpha = 255
-            cur = a->out + stride*j;
-            if (img_n == 1) {
-               for (q=x-1; q >= 0; --q) {
-                  cur[q*2+1] = 255;
-                  cur[q*2+0] = cur[q];
-               }
-            } else {
-               STBI_ASSERT(img_n == 3);
-               for (q=x-1; q >= 0; --q) {
-                  cur[q*4+3] = 255;
-                  cur[q*4+2] = cur[q*3+2];
-                  cur[q*4+1] = cur[q*3+1];
-                  cur[q*4+0] = cur[q*3+0];
-               }
-            }
-         }
-      }
-   } else if (depth == 16) {
-      // force the image data from big-endian to platform-native.
-      // this is done in a separate pass due to the decoding relying
-      // on the data being untouched, but could probably be done
-      // per-line during decode if care is taken.
-      stbi_uc *cur = a->out;
-      stbi__uint16 *cur16 = (stbi__uint16*)cur;
-
-      for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) {
-         *cur16 = (cur[0] << 8) | cur[1];
-      }
-   }
-
-   return 1;
-}
-
-static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced)
-{
-   int bytes = (depth == 16 ? 2 : 1);
-   int out_bytes = out_n * bytes;
-   stbi_uc *final;
-   int p;
-   if (!interlaced)
-      return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color);
-
-   // de-interlacing
-   final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);
-   for (p=0; p < 7; ++p) {
-      int xorig[] = { 0,4,0,2,0,1,0 };
-      int yorig[] = { 0,0,4,0,2,0,1 };
-      int xspc[]  = { 8,8,4,4,2,2,1 };
-      int yspc[]  = { 8,8,8,4,4,2,2 };
-      int i,j,x,y;
-      // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1
-      x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p];
-      y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p];
-      if (x && y) {
-         stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;
-         if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) {
-            STBI_FREE(final);
-            return 0;
-         }
-         for (j=0; j < y; ++j) {
-            for (i=0; i < x; ++i) {
-               int out_y = j*yspc[p]+yorig[p];
-               int out_x = i*xspc[p]+xorig[p];
-               memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes,
-                      a->out + (j*x+i)*out_bytes, out_bytes);
-            }
-         }
-         STBI_FREE(a->out);
-         image_data += img_len;
-         image_data_len -= img_len;
-      }
-   }
-   a->out = final;
-
-   return 1;
-}
-
-static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi_uc *p = z->out;
-
-   // compute color-based transparency, assuming we've
-   // already got 255 as the alpha value in the output
-   STBI_ASSERT(out_n == 2 || out_n == 4);
-
-   if (out_n == 2) {
-      for (i=0; i < pixel_count; ++i) {
-         p[1] = (p[0] == tc[0] ? 0 : 255);
-         p += 2;
-      }
-   } else {
-      for (i=0; i < pixel_count; ++i) {
-         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
-            p[3] = 0;
-         p += 4;
-      }
-   }
-   return 1;
-}
-
-static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi__uint16 *p = (stbi__uint16*) z->out;
-
-   // compute color-based transparency, assuming we've
-   // already got 65535 as the alpha value in the output
-   STBI_ASSERT(out_n == 2 || out_n == 4);
-
-   if (out_n == 2) {
-      for (i = 0; i < pixel_count; ++i) {
-         p[1] = (p[0] == tc[0] ? 0 : 65535);
-         p += 2;
-      }
-   } else {
-      for (i = 0; i < pixel_count; ++i) {
-         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])
-            p[3] = 0;
-         p += 4;
-      }
-   }
-   return 1;
-}
-
-static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n)
-{
-   stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y;
-   stbi_uc *p, *temp_out, *orig = a->out;
-
-   p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0);
-   if (p == NULL) return stbi__err("outofmem", "Out of memory");
-
-   // between here and free(out) below, exitting would leak
-   temp_out = p;
-
-   if (pal_img_n == 3) {
-      for (i=0; i < pixel_count; ++i) {
-         int n = orig[i]*4;
-         p[0] = palette[n  ];
-         p[1] = palette[n+1];
-         p[2] = palette[n+2];
-         p += 3;
-      }
-   } else {
-      for (i=0; i < pixel_count; ++i) {
-         int n = orig[i]*4;
-         p[0] = palette[n  ];
-         p[1] = palette[n+1];
-         p[2] = palette[n+2];
-         p[3] = palette[n+3];
-         p += 4;
-      }
-   }
-   STBI_FREE(a->out);
-   a->out = temp_out;
-
-   STBI_NOTUSED(len);
-
-   return 1;
-}
-
-static int stbi__unpremultiply_on_load = 0;
-static int stbi__de_iphone_flag = 0;
-
-STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)
-{
-   stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply;
-}
-
-STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)
-{
-   stbi__de_iphone_flag = flag_true_if_should_convert;
-}
-
-static void stbi__de_iphone(stbi__png *z)
-{
-   stbi__context *s = z->s;
-   stbi__uint32 i, pixel_count = s->img_x * s->img_y;
-   stbi_uc *p = z->out;
-
-   if (s->img_out_n == 3) {  // convert bgr to rgb
-      for (i=0; i < pixel_count; ++i) {
-         stbi_uc t = p[0];
-         p[0] = p[2];
-         p[2] = t;
-         p += 3;
-      }
-   } else {
-      STBI_ASSERT(s->img_out_n == 4);
-      if (stbi__unpremultiply_on_load) {
-         // convert bgr to rgb and unpremultiply
-         for (i=0; i < pixel_count; ++i) {
-            stbi_uc a = p[3];
-            stbi_uc t = p[0];
-            if (a) {
-               stbi_uc half = a / 2;
-               p[0] = (p[2] * 255 + half) / a;
-               p[1] = (p[1] * 255 + half) / a;
-               p[2] = ( t   * 255 + half) / a;
-            } else {
-               p[0] = p[2];
-               p[2] = t;
-            }
-            p += 4;
-         }
-      } else {
-         // convert bgr to rgb
-         for (i=0; i < pixel_count; ++i) {
-            stbi_uc t = p[0];
-            p[0] = p[2];
-            p[2] = t;
-            p += 4;
-         }
-      }
-   }
-}
-
-#define STBI__PNG_TYPE(a,b,c,d)  (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d))
-
-static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
-{
-   stbi_uc palette[1024], pal_img_n=0;
-   stbi_uc has_trans=0, tc[3]={0};
-   stbi__uint16 tc16[3];
-   stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;
-   int first=1,k,interlace=0, color=0, is_iphone=0;
-   stbi__context *s = z->s;
-
-   z->expanded = NULL;
-   z->idata = NULL;
-   z->out = NULL;
-
-   if (!stbi__check_png_header(s)) return 0;
-
-   if (scan == STBI__SCAN_type) return 1;
-
-   for (;;) {
-      stbi__pngchunk c = stbi__get_chunk_header(s);
-      switch (c.type) {
-         case STBI__PNG_TYPE('C','g','B','I'):
-            is_iphone = 1;
-            stbi__skip(s, c.length);
-            break;
-         case STBI__PNG_TYPE('I','H','D','R'): {
-            int comp,filter;
-            if (!first) return stbi__err("multiple IHDR","Corrupt PNG");
-            first = 0;
-            if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG");
-            s->img_x = stbi__get32be(s);
-            s->img_y = stbi__get32be(s);
-            if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-            if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-            z->depth = stbi__get8(s);  if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16)  return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only");
-            color = stbi__get8(s);  if (color > 6)         return stbi__err("bad ctype","Corrupt PNG");
-            if (color == 3 && z->depth == 16)                  return stbi__err("bad ctype","Corrupt PNG");
-            if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG");
-            comp  = stbi__get8(s);  if (comp) return stbi__err("bad comp method","Corrupt PNG");
-            filter= stbi__get8(s);  if (filter) return stbi__err("bad filter method","Corrupt PNG");
-            interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG");
-            if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG");
-            if (!pal_img_n) {
-               s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);
-               if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode");
-               if (scan == STBI__SCAN_header) return 1;
-            } else {
-               // if paletted, then pal_n is our final components, and
-               // img_n is # components to decompress/filter.
-               s->img_n = 1;
-               if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG");
-               // if SCAN_header, have to scan to see if we have a tRNS
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('P','L','T','E'):  {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG");
-            pal_len = c.length / 3;
-            if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG");
-            for (i=0; i < pal_len; ++i) {
-               palette[i*4+0] = stbi__get8(s);
-               palette[i*4+1] = stbi__get8(s);
-               palette[i*4+2] = stbi__get8(s);
-               palette[i*4+3] = 255;
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('t','R','N','S'): {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG");
-            if (pal_img_n) {
-               if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; }
-               if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG");
-               if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG");
-               pal_img_n = 4;
-               for (i=0; i < c.length; ++i)
-                  palette[i*4+3] = stbi__get8(s);
-            } else {
-               if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG");
-               if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG");
-               has_trans = 1;
-               if (z->depth == 16) {
-                  for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is
-               } else {
-                  for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger
-               }
-            }
-            break;
-         }
-
-         case STBI__PNG_TYPE('I','D','A','T'): {
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG");
-            if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; }
-            if ((int)(ioff + c.length) < (int)ioff) return 0;
-            if (ioff + c.length > idata_limit) {
-               stbi__uint32 idata_limit_old = idata_limit;
-               stbi_uc *p;
-               if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096;
-               while (ioff + c.length > idata_limit)
-                  idata_limit *= 2;
-               STBI_NOTUSED(idata_limit_old);
-               p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory");
-               z->idata = p;
-            }
-            if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG");
-            ioff += c.length;
-            break;
-         }
-
-         case STBI__PNG_TYPE('I','E','N','D'): {
-            stbi__uint32 raw_len, bpl;
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if (scan != STBI__SCAN_load) return 1;
-            if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG");
-            // initial guess for decoded data size to avoid unnecessary reallocs
-            bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component
-            raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */;
-            z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone);
-            if (z->expanded == NULL) return 0; // zlib should set error
-            STBI_FREE(z->idata); z->idata = NULL;
-            if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)
-               s->img_out_n = s->img_n+1;
-            else
-               s->img_out_n = s->img_n;
-            if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0;
-            if (has_trans) {
-               if (z->depth == 16) {
-                  if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0;
-               } else {
-                  if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0;
-               }
-            }
-            if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2)
-               stbi__de_iphone(z);
-            if (pal_img_n) {
-               // pal_img_n == 3 or 4
-               s->img_n = pal_img_n; // record the actual colors we had
-               s->img_out_n = pal_img_n;
-               if (req_comp >= 3) s->img_out_n = req_comp;
-               if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n))
-                  return 0;
-            } else if (has_trans) {
-               // non-paletted image with tRNS -> source image has (constant) alpha
-               ++s->img_n;
-            }
-            STBI_FREE(z->expanded); z->expanded = NULL;
-            // end of PNG chunk, read and skip CRC
-            stbi__get32be(s);
-            return 1;
-         }
-
-         default:
-            // if critical, fail
-            if (first) return stbi__err("first not IHDR", "Corrupt PNG");
-            if ((c.type & (1 << 29)) == 0) {
-               #ifndef STBI_NO_FAILURE_STRINGS
-               // not threadsafe
-               static char invalid_chunk[] = "XXXX PNG chunk not known";
-               invalid_chunk[0] = STBI__BYTECAST(c.type >> 24);
-               invalid_chunk[1] = STBI__BYTECAST(c.type >> 16);
-               invalid_chunk[2] = STBI__BYTECAST(c.type >>  8);
-               invalid_chunk[3] = STBI__BYTECAST(c.type >>  0);
-               #endif
-               return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type");
-            }
-            stbi__skip(s, c.length);
-            break;
-      }
-      // end of PNG chunk, read and skip CRC
-      stbi__get32be(s);
-   }
-}
-
-static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri)
-{
-   void *result=NULL;
-   if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error");
-   if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {
-      if (p->depth <= 8)
-         ri->bits_per_channel = 8;
-      else if (p->depth == 16)
-         ri->bits_per_channel = 16;
-      else
-         return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth");
-      result = p->out;
-      p->out = NULL;
-      if (req_comp && req_comp != p->s->img_out_n) {
-         if (ri->bits_per_channel == 8)
-            result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
-         else
-            result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);
-         p->s->img_out_n = req_comp;
-         if (result == NULL) return result;
-      }
-      *x = p->s->img_x;
-      *y = p->s->img_y;
-      if (n) *n = p->s->img_n;
-   }
-   STBI_FREE(p->out);      p->out      = NULL;
-   STBI_FREE(p->expanded); p->expanded = NULL;
-   STBI_FREE(p->idata);    p->idata    = NULL;
-
-   return result;
-}
-
-static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi__png p;
-   p.s = s;
-   return stbi__do_png(&p, x,y,comp,req_comp, ri);
-}
-
-static int stbi__png_test(stbi__context *s)
-{
-   int r;
-   r = stbi__check_png_header(s);
-   stbi__rewind(s);
-   return r;
-}
-
-static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp)
-{
-   if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) {
-      stbi__rewind( p->s );
-      return 0;
-   }
-   if (x) *x = p->s->img_x;
-   if (y) *y = p->s->img_y;
-   if (comp) *comp = p->s->img_n;
-   return 1;
-}
-
-static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   stbi__png p;
-   p.s = s;
-   return stbi__png_info_raw(&p, x, y, comp);
-}
-
-static int stbi__png_is16(stbi__context *s)
-{
-   stbi__png p;
-   p.s = s;
-   if (!stbi__png_info_raw(&p, NULL, NULL, NULL))
-          return 0;
-   if (p.depth != 16) {
-      stbi__rewind(p.s);
-      return 0;
-   }
-   return 1;
-}
-#endif
-
-// Microsoft/Windows BMP image
-
-#ifndef STBI_NO_BMP
-static int stbi__bmp_test_raw(stbi__context *s)
-{
-   int r;
-   int sz;
-   if (stbi__get8(s) != 'B') return 0;
-   if (stbi__get8(s) != 'M') return 0;
-   stbi__get32le(s); // discard filesize
-   stbi__get16le(s); // discard reserved
-   stbi__get16le(s); // discard reserved
-   stbi__get32le(s); // discard data offset
-   sz = stbi__get32le(s);
-   r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124);
-   return r;
-}
-
-static int stbi__bmp_test(stbi__context *s)
-{
-   int r = stbi__bmp_test_raw(s);
-   stbi__rewind(s);
-   return r;
-}
-
-
-// returns 0..31 for the highest set bit
-static int stbi__high_bit(unsigned int z)
-{
-   int n=0;
-   if (z == 0) return -1;
-   if (z >= 0x10000) { n += 16; z >>= 16; }
-   if (z >= 0x00100) { n +=  8; z >>=  8; }
-   if (z >= 0x00010) { n +=  4; z >>=  4; }
-   if (z >= 0x00004) { n +=  2; z >>=  2; }
-   if (z >= 0x00002) { n +=  1;/* >>=  1;*/ }
-   return n;
-}
-
-static int stbi__bitcount(unsigned int a)
-{
-   a = (a & 0x55555555) + ((a >>  1) & 0x55555555); // max 2
-   a = (a & 0x33333333) + ((a >>  2) & 0x33333333); // max 4
-   a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits
-   a = (a + (a >> 8)); // max 16 per 8 bits
-   a = (a + (a >> 16)); // max 32 per 8 bits
-   return a & 0xff;
-}
-
-// extract an arbitrarily-aligned N-bit value (N=bits)
-// from v, and then make it 8-bits long and fractionally
-// extend it to full full range.
-static int stbi__shiftsigned(unsigned int v, int shift, int bits)
-{
-   static unsigned int mul_table[9] = {
-      0,
-      0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/,
-      0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/,
-   };
-   static unsigned int shift_table[9] = {
-      0, 0,0,1,0,2,4,6,0,
-   };
-   if (shift < 0)
-      v <<= -shift;
-   else
-      v >>= shift;
-   STBI_ASSERT(v < 256);
-   v >>= (8-bits);
-   STBI_ASSERT(bits >= 0 && bits <= 8);
-   return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits];
-}
-
-typedef struct
-{
-   int bpp, offset, hsz;
-   unsigned int mr,mg,mb,ma, all_a;
-   int extra_read;
-} stbi__bmp_data;
-
-static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)
-{
-   int hsz;
-   if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP");
-   stbi__get32le(s); // discard filesize
-   stbi__get16le(s); // discard reserved
-   stbi__get16le(s); // discard reserved
-   info->offset = stbi__get32le(s);
-   info->hsz = hsz = stbi__get32le(s);
-   info->mr = info->mg = info->mb = info->ma = 0;
-   info->extra_read = 14;
-
-   if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP");
-
-   if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown");
-   if (hsz == 12) {
-      s->img_x = stbi__get16le(s);
-      s->img_y = stbi__get16le(s);
-   } else {
-      s->img_x = stbi__get32le(s);
-      s->img_y = stbi__get32le(s);
-   }
-   if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP");
-   info->bpp = stbi__get16le(s);
-   if (hsz != 12) {
-      int compress = stbi__get32le(s);
-      if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE");
-      stbi__get32le(s); // discard sizeof
-      stbi__get32le(s); // discard hres
-      stbi__get32le(s); // discard vres
-      stbi__get32le(s); // discard colorsused
-      stbi__get32le(s); // discard max important
-      if (hsz == 40 || hsz == 56) {
-         if (hsz == 56) {
-            stbi__get32le(s);
-            stbi__get32le(s);
-            stbi__get32le(s);
-            stbi__get32le(s);
-         }
-         if (info->bpp == 16 || info->bpp == 32) {
-            if (compress == 0) {
-               if (info->bpp == 32) {
-                  info->mr = 0xffu << 16;
-                  info->mg = 0xffu <<  8;
-                  info->mb = 0xffu <<  0;
-                  info->ma = 0xffu << 24;
-                  info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0
-               } else {
-                  info->mr = 31u << 10;
-                  info->mg = 31u <<  5;
-                  info->mb = 31u <<  0;
-               }
-            } else if (compress == 3) {
-               info->mr = stbi__get32le(s);
-               info->mg = stbi__get32le(s);
-               info->mb = stbi__get32le(s);
-               info->extra_read += 12;
-               // not documented, but generated by photoshop and handled by mspaint
-               if (info->mr == info->mg && info->mg == info->mb) {
-                  // ?!?!?
-                  return stbi__errpuc("bad BMP", "bad BMP");
-               }
-            } else
-               return stbi__errpuc("bad BMP", "bad BMP");
-         }
-      } else {
-         int i;
-         if (hsz != 108 && hsz != 124)
-            return stbi__errpuc("bad BMP", "bad BMP");
-         info->mr = stbi__get32le(s);
-         info->mg = stbi__get32le(s);
-         info->mb = stbi__get32le(s);
-         info->ma = stbi__get32le(s);
-         stbi__get32le(s); // discard color space
-         for (i=0; i < 12; ++i)
-            stbi__get32le(s); // discard color space parameters
-         if (hsz == 124) {
-            stbi__get32le(s); // discard rendering intent
-            stbi__get32le(s); // discard offset of profile data
-            stbi__get32le(s); // discard size of profile data
-            stbi__get32le(s); // discard reserved
-         }
-      }
-   }
-   return (void *) 1;
-}
-
-
-static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *out;
-   unsigned int mr=0,mg=0,mb=0,ma=0, all_a;
-   stbi_uc pal[256][4];
-   int psize=0,i,j,width;
-   int flip_vertically, pad, target;
-   stbi__bmp_data info;
-   STBI_NOTUSED(ri);
-
-   info.all_a = 255;
-   if (stbi__bmp_parse_header(s, &info) == NULL)
-      return NULL; // error code already set
-
-   flip_vertically = ((int) s->img_y) > 0;
-   s->img_y = abs((int) s->img_y);
-
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   mr = info.mr;
-   mg = info.mg;
-   mb = info.mb;
-   ma = info.ma;
-   all_a = info.all_a;
-
-   if (info.hsz == 12) {
-      if (info.bpp < 24)
-         psize = (info.offset - info.extra_read - 24) / 3;
-   } else {
-      if (info.bpp < 16)
-         psize = (info.offset - info.extra_read - info.hsz) >> 2;
-   }
-   if (psize == 0) {
-      STBI_ASSERT(info.offset == s->callback_already_read + (int) (s->img_buffer - s->img_buffer_original));
-      if (info.offset != s->callback_already_read + (s->img_buffer - s->buffer_start)) {
-        return stbi__errpuc("bad offset", "Corrupt BMP");
-      }
-   }
-
-   if (info.bpp == 24 && ma == 0xff000000)
-      s->img_n = 3;
-   else
-      s->img_n = ma ? 4 : 3;
-   if (req_comp && req_comp >= 3) // we can directly decode 3 or 4
-      target = req_comp;
-   else
-      target = s->img_n; // if they want monochrome, we'll post-convert
-
-   // sanity-check size
-   if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0))
-      return stbi__errpuc("too large", "Corrupt BMP");
-
-   out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0);
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   if (info.bpp < 16) {
-      int z=0;
-      if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); }
-      for (i=0; i < psize; ++i) {
-         pal[i][2] = stbi__get8(s);
-         pal[i][1] = stbi__get8(s);
-         pal[i][0] = stbi__get8(s);
-         if (info.hsz != 12) stbi__get8(s);
-         pal[i][3] = 255;
-      }
-      stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4));
-      if (info.bpp == 1) width = (s->img_x + 7) >> 3;
-      else if (info.bpp == 4) width = (s->img_x + 1) >> 1;
-      else if (info.bpp == 8) width = s->img_x;
-      else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); }
-      pad = (-width)&3;
-      if (info.bpp == 1) {
-         for (j=0; j < (int) s->img_y; ++j) {
-            int bit_offset = 7, v = stbi__get8(s);
-            for (i=0; i < (int) s->img_x; ++i) {
-               int color = (v>>bit_offset)&0x1;
-               out[z++] = pal[color][0];
-               out[z++] = pal[color][1];
-               out[z++] = pal[color][2];
-               if (target == 4) out[z++] = 255;
-               if (i+1 == (int) s->img_x) break;
-               if((--bit_offset) < 0) {
-                  bit_offset = 7;
-                  v = stbi__get8(s);
-               }
-            }
-            stbi__skip(s, pad);
-         }
-      } else {
-         for (j=0; j < (int) s->img_y; ++j) {
-            for (i=0; i < (int) s->img_x; i += 2) {
-               int v=stbi__get8(s),v2=0;
-               if (info.bpp == 4) {
-                  v2 = v & 15;
-                  v >>= 4;
-               }
-               out[z++] = pal[v][0];
-               out[z++] = pal[v][1];
-               out[z++] = pal[v][2];
-               if (target == 4) out[z++] = 255;
-               if (i+1 == (int) s->img_x) break;
-               v = (info.bpp == 8) ? stbi__get8(s) : v2;
-               out[z++] = pal[v][0];
-               out[z++] = pal[v][1];
-               out[z++] = pal[v][2];
-               if (target == 4) out[z++] = 255;
-            }
-            stbi__skip(s, pad);
-         }
-      }
-   } else {
-      int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0;
-      int z = 0;
-      int easy=0;
-      stbi__skip(s, info.offset - info.extra_read - info.hsz);
-      if (info.bpp == 24) width = 3 * s->img_x;
-      else if (info.bpp == 16) width = 2*s->img_x;
-      else /* bpp = 32 and pad = 0 */ width=0;
-      pad = (-width) & 3;
-      if (info.bpp == 24) {
-         easy = 1;
-      } else if (info.bpp == 32) {
-         if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000)
-            easy = 2;
-      }
-      if (!easy) {
-         if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
-         // right shift amt to put high bit in position #7
-         rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr);
-         gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg);
-         bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb);
-         ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma);
-         if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); }
-      }
-      for (j=0; j < (int) s->img_y; ++j) {
-         if (easy) {
-            for (i=0; i < (int) s->img_x; ++i) {
-               unsigned char a;
-               out[z+2] = stbi__get8(s);
-               out[z+1] = stbi__get8(s);
-               out[z+0] = stbi__get8(s);
-               z += 3;
-               a = (easy == 2 ? stbi__get8(s) : 255);
-               all_a |= a;
-               if (target == 4) out[z++] = a;
-            }
-         } else {
-            int bpp = info.bpp;
-            for (i=0; i < (int) s->img_x; ++i) {
-               stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s));
-               unsigned int a;
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount));
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount));
-               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount));
-               a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255);
-               all_a |= a;
-               if (target == 4) out[z++] = STBI__BYTECAST(a);
-            }
-         }
-         stbi__skip(s, pad);
-      }
-   }
-
-   // if alpha channel is all 0s, replace with all 255s
-   if (target == 4 && all_a == 0)
-      for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4)
-         out[i] = 255;
-
-   if (flip_vertically) {
-      stbi_uc t;
-      for (j=0; j < (int) s->img_y>>1; ++j) {
-         stbi_uc *p1 = out +      j     *s->img_x*target;
-         stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target;
-         for (i=0; i < (int) s->img_x*target; ++i) {
-            t = p1[i]; p1[i] = p2[i]; p2[i] = t;
-         }
-      }
-   }
-
-   if (req_comp && req_comp != target) {
-      out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-
-   *x = s->img_x;
-   *y = s->img_y;
-   if (comp) *comp = s->img_n;
-   return out;
-}
-#endif
-
-// Targa Truevision - TGA
-// by Jonathan Dummer
-#ifndef STBI_NO_TGA
-// returns STBI_rgb or whatever, 0 on error
-static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16)
-{
-   // only RGB or RGBA (incl. 16bit) or grey allowed
-   if (is_rgb16) *is_rgb16 = 0;
-   switch(bits_per_pixel) {
-      case 8:  return STBI_grey;
-      case 16: if(is_grey) return STBI_grey_alpha;
-               // fallthrough
-      case 15: if(is_rgb16) *is_rgb16 = 1;
-               return STBI_rgb;
-      case 24: // fallthrough
-      case 32: return bits_per_pixel/8;
-      default: return 0;
-   }
-}
-
-static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp)
-{
-    int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp;
-    int sz, tga_colormap_type;
-    stbi__get8(s);                   // discard Offset
-    tga_colormap_type = stbi__get8(s); // colormap type
-    if( tga_colormap_type > 1 ) {
-        stbi__rewind(s);
-        return 0;      // only RGB or indexed allowed
-    }
-    tga_image_type = stbi__get8(s); // image type
-    if ( tga_colormap_type == 1 ) { // colormapped (paletted) image
-        if (tga_image_type != 1 && tga_image_type != 9) {
-            stbi__rewind(s);
-            return 0;
-        }
-        stbi__skip(s,4);       // skip index of first colormap entry and number of entries
-        sz = stbi__get8(s);    //   check bits per palette color entry
-        if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) {
-            stbi__rewind(s);
-            return 0;
-        }
-        stbi__skip(s,4);       // skip image x and y origin
-        tga_colormap_bpp = sz;
-    } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE
-        if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) {
-            stbi__rewind(s);
-            return 0; // only RGB or grey allowed, +/- RLE
-        }
-        stbi__skip(s,9); // skip colormap specification and image x/y origin
-        tga_colormap_bpp = 0;
-    }
-    tga_w = stbi__get16le(s);
-    if( tga_w < 1 ) {
-        stbi__rewind(s);
-        return 0;   // test width
-    }
-    tga_h = stbi__get16le(s);
-    if( tga_h < 1 ) {
-        stbi__rewind(s);
-        return 0;   // test height
-    }
-    tga_bits_per_pixel = stbi__get8(s); // bits per pixel
-    stbi__get8(s); // ignore alpha bits
-    if (tga_colormap_bpp != 0) {
-        if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) {
-            // when using a colormap, tga_bits_per_pixel is the size of the indexes
-            // I don't think anything but 8 or 16bit indexes makes sense
-            stbi__rewind(s);
-            return 0;
-        }
-        tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL);
-    } else {
-        tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL);
-    }
-    if(!tga_comp) {
-      stbi__rewind(s);
-      return 0;
-    }
-    if (x) *x = tga_w;
-    if (y) *y = tga_h;
-    if (comp) *comp = tga_comp;
-    return 1;                   // seems to have passed everything
-}
-
-static int stbi__tga_test(stbi__context *s)
-{
-   int res = 0;
-   int sz, tga_color_type;
-   stbi__get8(s);      //   discard Offset
-   tga_color_type = stbi__get8(s);   //   color type
-   if ( tga_color_type > 1 ) goto errorEnd;   //   only RGB or indexed allowed
-   sz = stbi__get8(s);   //   image type
-   if ( tga_color_type == 1 ) { // colormapped (paletted) image
-      if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9
-      stbi__skip(s,4);       // skip index of first colormap entry and number of entries
-      sz = stbi__get8(s);    //   check bits per palette color entry
-      if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
-      stbi__skip(s,4);       // skip image x and y origin
-   } else { // "normal" image w/o colormap
-      if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE
-      stbi__skip(s,9); // skip colormap specification and image x/y origin
-   }
-   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test width
-   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test height
-   sz = stbi__get8(s);   //   bits per pixel
-   if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index
-   if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
-
-   res = 1; // if we got this far, everything's good and we can return 1 instead of 0
-
-errorEnd:
-   stbi__rewind(s);
-   return res;
-}
-
-// read 16bit value and convert to 24bit RGB
-static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out)
-{
-   stbi__uint16 px = (stbi__uint16)stbi__get16le(s);
-   stbi__uint16 fiveBitMask = 31;
-   // we have 3 channels with 5bits each
-   int r = (px >> 10) & fiveBitMask;
-   int g = (px >> 5) & fiveBitMask;
-   int b = px & fiveBitMask;
-   // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later
-   out[0] = (stbi_uc)((r * 255)/31);
-   out[1] = (stbi_uc)((g * 255)/31);
-   out[2] = (stbi_uc)((b * 255)/31);
-
-   // some people claim that the most significant bit might be used for alpha
-   // (possibly if an alpha-bit is set in the "image descriptor byte")
-   // but that only made 16bit test images completely translucent..
-   // so let's treat all 15 and 16bit TGAs as RGB with no alpha.
-}
-
-static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   //   read in the TGA header stuff
-   int tga_offset = stbi__get8(s);
-   int tga_indexed = stbi__get8(s);
-   int tga_image_type = stbi__get8(s);
-   int tga_is_RLE = 0;
-   int tga_palette_start = stbi__get16le(s);
-   int tga_palette_len = stbi__get16le(s);
-   int tga_palette_bits = stbi__get8(s);
-   int tga_x_origin = stbi__get16le(s);
-   int tga_y_origin = stbi__get16le(s);
-   int tga_width = stbi__get16le(s);
-   int tga_height = stbi__get16le(s);
-   int tga_bits_per_pixel = stbi__get8(s);
-   int tga_comp, tga_rgb16=0;
-   int tga_inverted = stbi__get8(s);
-   // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?)
-   //   image data
-   unsigned char *tga_data;
-   unsigned char *tga_palette = NULL;
-   int i, j;
-   unsigned char raw_data[4] = {0};
-   int RLE_count = 0;
-   int RLE_repeating = 0;
-   int read_next_pixel = 1;
-   STBI_NOTUSED(ri);
-   STBI_NOTUSED(tga_x_origin); // @TODO
-   STBI_NOTUSED(tga_y_origin); // @TODO
-
-   if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   //   do a tiny bit of precessing
-   if ( tga_image_type >= 8 )
-   {
-      tga_image_type -= 8;
-      tga_is_RLE = 1;
-   }
-   tga_inverted = 1 - ((tga_inverted >> 5) & 1);
-
-   //   If I'm paletted, then I'll use the number of bits from the palette
-   if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16);
-   else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16);
-
-   if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency
-      return stbi__errpuc("bad format", "Can't find out TGA pixelformat");
-
-   //   tga info
-   *x = tga_width;
-   *y = tga_height;
-   if (comp) *comp = tga_comp;
-
-   if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0))
-      return stbi__errpuc("too large", "Corrupt TGA");
-
-   tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0);
-   if (!tga_data) return stbi__errpuc("outofmem", "Out of memory");
-
-   // skip to the data's starting position (offset usually = 0)
-   stbi__skip(s, tga_offset );
-
-   if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) {
-      for (i=0; i < tga_height; ++i) {
-         int row = tga_inverted ? tga_height -i - 1 : i;
-         stbi_uc *tga_row = tga_data + row*tga_width*tga_comp;
-         stbi__getn(s, tga_row, tga_width * tga_comp);
-      }
-   } else  {
-      //   do I need to load a palette?
-      if ( tga_indexed)
-      {
-         if (tga_palette_len == 0) {  /* you have to have at least one entry! */
-            STBI_FREE(tga_data);
-            return stbi__errpuc("bad palette", "Corrupt TGA");
-         }
-
-         //   any data to skip? (offset usually = 0)
-         stbi__skip(s, tga_palette_start );
-         //   load the palette
-         tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0);
-         if (!tga_palette) {
-            STBI_FREE(tga_data);
-            return stbi__errpuc("outofmem", "Out of memory");
-         }
-         if (tga_rgb16) {
-            stbi_uc *pal_entry = tga_palette;
-            STBI_ASSERT(tga_comp == STBI_rgb);
-            for (i=0; i < tga_palette_len; ++i) {
-               stbi__tga_read_rgb16(s, pal_entry);
-               pal_entry += tga_comp;
-            }
-         } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) {
-               STBI_FREE(tga_data);
-               STBI_FREE(tga_palette);
-               return stbi__errpuc("bad palette", "Corrupt TGA");
-         }
-      }
-      //   load the data
-      for (i=0; i < tga_width * tga_height; ++i)
-      {
-         //   if I'm in RLE mode, do I need to get a RLE stbi__pngchunk?
-         if ( tga_is_RLE )
-         {
-            if ( RLE_count == 0 )
-            {
-               //   yep, get the next byte as a RLE command
-               int RLE_cmd = stbi__get8(s);
-               RLE_count = 1 + (RLE_cmd & 127);
-               RLE_repeating = RLE_cmd >> 7;
-               read_next_pixel = 1;
-            } else if ( !RLE_repeating )
-            {
-               read_next_pixel = 1;
-            }
-         } else
-         {
-            read_next_pixel = 1;
-         }
-         //   OK, if I need to read a pixel, do it now
-         if ( read_next_pixel )
-         {
-            //   load however much data we did have
-            if ( tga_indexed )
-            {
-               // read in index, then perform the lookup
-               int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s);
-               if ( pal_idx >= tga_palette_len ) {
-                  // invalid index
-                  pal_idx = 0;
-               }
-               pal_idx *= tga_comp;
-               for (j = 0; j < tga_comp; ++j) {
-                  raw_data[j] = tga_palette[pal_idx+j];
-               }
-            } else if(tga_rgb16) {
-               STBI_ASSERT(tga_comp == STBI_rgb);
-               stbi__tga_read_rgb16(s, raw_data);
-            } else {
-               //   read in the data raw
-               for (j = 0; j < tga_comp; ++j) {
-                  raw_data[j] = stbi__get8(s);
-               }
-            }
-            //   clear the reading flag for the next pixel
-            read_next_pixel = 0;
-         } // end of reading a pixel
-
-         // copy data
-         for (j = 0; j < tga_comp; ++j)
-           tga_data[i*tga_comp+j] = raw_data[j];
-
-         //   in case we're in RLE mode, keep counting down
-         --RLE_count;
-      }
-      //   do I need to invert the image?
-      if ( tga_inverted )
-      {
-         for (j = 0; j*2 < tga_height; ++j)
-         {
-            int index1 = j * tga_width * tga_comp;
-            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;
-            for (i = tga_width * tga_comp; i > 0; --i)
-            {
-               unsigned char temp = tga_data[index1];
-               tga_data[index1] = tga_data[index2];
-               tga_data[index2] = temp;
-               ++index1;
-               ++index2;
-            }
-         }
-      }
-      //   clear my palette, if I had one
-      if ( tga_palette != NULL )
-      {
-         STBI_FREE( tga_palette );
-      }
-   }
-
-   // swap RGB - if the source data was RGB16, it already is in the right order
-   if (tga_comp >= 3 && !tga_rgb16)
-   {
-      unsigned char* tga_pixel = tga_data;
-      for (i=0; i < tga_width * tga_height; ++i)
-      {
-         unsigned char temp = tga_pixel[0];
-         tga_pixel[0] = tga_pixel[2];
-         tga_pixel[2] = temp;
-         tga_pixel += tga_comp;
-      }
-   }
-
-   // convert to target component count
-   if (req_comp && req_comp != tga_comp)
-      tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height);
-
-   //   the things I do to get rid of an error message, and yet keep
-   //   Microsoft's C compilers happy... [8^(
-   tga_palette_start = tga_palette_len = tga_palette_bits =
-         tga_x_origin = tga_y_origin = 0;
-   STBI_NOTUSED(tga_palette_start);
-   //   OK, done
-   return tga_data;
-}
-#endif
-
-// *************************************************************************************************
-// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB
-
-#ifndef STBI_NO_PSD
-static int stbi__psd_test(stbi__context *s)
-{
-   int r = (stbi__get32be(s) == 0x38425053);
-   stbi__rewind(s);
-   return r;
-}
-
-static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount)
-{
-   int count, nleft, len;
-
-   count = 0;
-   while ((nleft = pixelCount - count) > 0) {
-      len = stbi__get8(s);
-      if (len == 128) {
-         // No-op.
-      } else if (len < 128) {
-         // Copy next len+1 bytes literally.
-         len++;
-         if (len > nleft) return 0; // corrupt data
-         count += len;
-         while (len) {
-            *p = stbi__get8(s);
-            p += 4;
-            len--;
-         }
-      } else if (len > 128) {
-         stbi_uc   val;
-         // Next -len+1 bytes in the dest are replicated from next source byte.
-         // (Interpret len as a negative 8-bit int.)
-         len = 257 - len;
-         if (len > nleft) return 0; // corrupt data
-         val = stbi__get8(s);
-         count += len;
-         while (len) {
-            *p = val;
-            p += 4;
-            len--;
-         }
-      }
-   }
-
-   return 1;
-}
-
-static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
-{
-   int pixelCount;
-   int channelCount, compression;
-   int channel, i;
-   int bitdepth;
-   int w,h;
-   stbi_uc *out;
-   STBI_NOTUSED(ri);
-
-   // Check identifier
-   if (stbi__get32be(s) != 0x38425053)   // "8BPS"
-      return stbi__errpuc("not PSD", "Corrupt PSD image");
-
-   // Check file type version.
-   if (stbi__get16be(s) != 1)
-      return stbi__errpuc("wrong version", "Unsupported version of PSD image");
-
-   // Skip 6 reserved bytes.
-   stbi__skip(s, 6 );
-
-   // Read the number of channels (R, G, B, A, etc).
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16)
-      return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image");
-
-   // Read the rows and columns of the image.
-   h = stbi__get32be(s);
-   w = stbi__get32be(s);
-
-   if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   // Make sure the depth is 8 bits.
-   bitdepth = stbi__get16be(s);
-   if (bitdepth != 8 && bitdepth != 16)
-      return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit");
-
-   // Make sure the color mode is RGB.
-   // Valid options are:
-   //   0: Bitmap
-   //   1: Grayscale
-   //   2: Indexed color
-   //   3: RGB color
-   //   4: CMYK color
-   //   7: Multichannel
-   //   8: Duotone
-   //   9: Lab color
-   if (stbi__get16be(s) != 3)
-      return stbi__errpuc("wrong color format", "PSD is not in RGB color format");
-
-   // Skip the Mode Data.  (It's the palette for indexed color; other info for other modes.)
-   stbi__skip(s,stbi__get32be(s) );
-
-   // Skip the image resources.  (resolution, pen tool paths, etc)
-   stbi__skip(s, stbi__get32be(s) );
-
-   // Skip the reserved data.
-   stbi__skip(s, stbi__get32be(s) );
-
-   // Find out if the data is compressed.
-   // Known values:
-   //   0: no compression
-   //   1: RLE compressed
-   compression = stbi__get16be(s);
-   if (compression > 1)
-      return stbi__errpuc("bad compression", "PSD has an unknown compression format");
-
-   // Check size
-   if (!stbi__mad3sizes_valid(4, w, h, 0))
-      return stbi__errpuc("too large", "Corrupt PSD");
-
-   // Create the destination image.
-
-   if (!compression && bitdepth == 16 && bpc == 16) {
-      out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0);
-      ri->bits_per_channel = 16;
-   } else
-      out = (stbi_uc *) stbi__malloc(4 * w*h);
-
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   pixelCount = w*h;
-
-   // Initialize the data to zero.
-   //memset( out, 0, pixelCount * 4 );
-
-   // Finally, the image data.
-   if (compression) {
-      // RLE as used by .PSD and .TIFF
-      // Loop until you get the number of unpacked bytes you are expecting:
-      //     Read the next source byte into n.
-      //     If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
-      //     Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
-      //     Else if n is 128, noop.
-      // Endloop
-
-      // The RLE-compressed data is preceded by a 2-byte data count for each row in the data,
-      // which we're going to just skip.
-      stbi__skip(s, h * channelCount * 2 );
-
-      // Read the RLE data by channel.
-      for (channel = 0; channel < 4; channel++) {
-         stbi_uc *p;
-
-         p = out+channel;
-         if (channel >= channelCount) {
-            // Fill this channel with default data.
-            for (i = 0; i < pixelCount; i++, p += 4)
-               *p = (channel == 3 ? 255 : 0);
-         } else {
-            // Read the RLE data.
-            if (!stbi__psd_decode_rle(s, p, pixelCount)) {
-               STBI_FREE(out);
-               return stbi__errpuc("corrupt", "bad RLE data");
-            }
-         }
-      }
-
-   } else {
-      // We're at the raw image data.  It's each channel in order (Red, Green, Blue, Alpha, ...)
-      // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image.
-
-      // Read the data by channel.
-      for (channel = 0; channel < 4; channel++) {
-         if (channel >= channelCount) {
-            // Fill this channel with default data.
-            if (bitdepth == 16 && bpc == 16) {
-               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
-               stbi__uint16 val = channel == 3 ? 65535 : 0;
-               for (i = 0; i < pixelCount; i++, q += 4)
-                  *q = val;
-            } else {
-               stbi_uc *p = out+channel;
-               stbi_uc val = channel == 3 ? 255 : 0;
-               for (i = 0; i < pixelCount; i++, p += 4)
-                  *p = val;
-            }
-         } else {
-            if (ri->bits_per_channel == 16) {    // output bpc
-               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;
-               for (i = 0; i < pixelCount; i++, q += 4)
-                  *q = (stbi__uint16) stbi__get16be(s);
-            } else {
-               stbi_uc *p = out+channel;
-               if (bitdepth == 16) {  // input bpc
-                  for (i = 0; i < pixelCount; i++, p += 4)
-                     *p = (stbi_uc) (stbi__get16be(s) >> 8);
-               } else {
-                  for (i = 0; i < pixelCount; i++, p += 4)
-                     *p = stbi__get8(s);
-               }
-            }
-         }
-      }
-   }
-
-   // remove weird white matte from PSD
-   if (channelCount >= 4) {
-      if (ri->bits_per_channel == 16) {
-         for (i=0; i < w*h; ++i) {
-            stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i;
-            if (pixel[3] != 0 && pixel[3] != 65535) {
-               float a = pixel[3] / 65535.0f;
-               float ra = 1.0f / a;
-               float inv_a = 65535.0f * (1 - ra);
-               pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a);
-               pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a);
-               pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a);
-            }
-         }
-      } else {
-         for (i=0; i < w*h; ++i) {
-            unsigned char *pixel = out + 4*i;
-            if (pixel[3] != 0 && pixel[3] != 255) {
-               float a = pixel[3] / 255.0f;
-               float ra = 1.0f / a;
-               float inv_a = 255.0f * (1 - ra);
-               pixel[0] = (unsigned char) (pixel[0]*ra + inv_a);
-               pixel[1] = (unsigned char) (pixel[1]*ra + inv_a);
-               pixel[2] = (unsigned char) (pixel[2]*ra + inv_a);
-            }
-         }
-      }
-   }
-
-   // convert to desired output format
-   if (req_comp && req_comp != 4) {
-      if (ri->bits_per_channel == 16)
-         out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h);
-      else
-         out = stbi__convert_format(out, 4, req_comp, w, h);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-
-   if (comp) *comp = 4;
-   *y = h;
-   *x = w;
-
-   return out;
-}
-#endif
-
-// *************************************************************************************************
-// Softimage PIC loader
-// by Tom Seddon
-//
-// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format
-// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/
-
-#ifndef STBI_NO_PIC
-static int stbi__pic_is4(stbi__context *s,const char *str)
-{
-   int i;
-   for (i=0; i<4; ++i)
-      if (stbi__get8(s) != (stbi_uc)str[i])
-         return 0;
-
-   return 1;
-}
-
-static int stbi__pic_test_core(stbi__context *s)
-{
-   int i;
-
-   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34"))
-      return 0;
-
-   for(i=0;i<84;++i)
-      stbi__get8(s);
-
-   if (!stbi__pic_is4(s,"PICT"))
-      return 0;
-
-   return 1;
-}
-
-typedef struct
-{
-   stbi_uc size,type,channel;
-} stbi__pic_packet;
-
-static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest)
-{
-   int mask=0x80, i;
-
-   for (i=0; i<4; ++i, mask>>=1) {
-      if (channel & mask) {
-         if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short");
-         dest[i]=stbi__get8(s);
-      }
-   }
-
-   return dest;
-}
-
-static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src)
-{
-   int mask=0x80,i;
-
-   for (i=0;i<4; ++i, mask>>=1)
-      if (channel&mask)
-         dest[i]=src[i];
-}
-
-static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)
-{
-   int act_comp=0,num_packets=0,y,chained;
-   stbi__pic_packet packets[10];
-
-   // this will (should...) cater for even some bizarre stuff like having data
-    // for the same channel in multiple packets.
-   do {
-      stbi__pic_packet *packet;
-
-      if (num_packets==sizeof(packets)/sizeof(packets[0]))
-         return stbi__errpuc("bad format","too many packets");
-
-      packet = &packets[num_packets++];
-
-      chained = stbi__get8(s);
-      packet->size    = stbi__get8(s);
-      packet->type    = stbi__get8(s);
-      packet->channel = stbi__get8(s);
-
-      act_comp |= packet->channel;
-
-      if (stbi__at_eof(s))          return stbi__errpuc("bad file","file too short (reading packets)");
-      if (packet->size != 8)  return stbi__errpuc("bad format","packet isn't 8bpp");
-   } while (chained);
-
-   *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?
-
-   for(y=0; y<height; ++y) {
-      int packet_idx;
-
-      for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {
-         stbi__pic_packet *packet = &packets[packet_idx];
-         stbi_uc *dest = result+y*width*4;
-
-         switch (packet->type) {
-            default:
-               return stbi__errpuc("bad format","packet has bad compression type");
-
-            case 0: {//uncompressed
-               int x;
-
-               for(x=0;x<width;++x, dest+=4)
-                  if (!stbi__readval(s,packet->channel,dest))
-                     return 0;
-               break;
-            }
-
-            case 1://Pure RLE
-               {
-                  int left=width, i;
-
-                  while (left>0) {
-                     stbi_uc count,value[4];
-
-                     count=stbi__get8(s);
-                     if (stbi__at_eof(s))   return stbi__errpuc("bad file","file too short (pure read count)");
-
-                     if (count > left)
-                        count = (stbi_uc) left;
-
-                     if (!stbi__readval(s,packet->channel,value))  return 0;
-
-                     for(i=0; i<count; ++i,dest+=4)
-                        stbi__copyval(packet->channel,dest,value);
-                     left -= count;
-                  }
-               }
-               break;
-
-            case 2: {//Mixed RLE
-               int left=width;
-               while (left>0) {
-                  int count = stbi__get8(s), i;
-                  if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (mixed read count)");
-
-                  if (count >= 128) { // Repeated
-                     stbi_uc value[4];
-
-                     if (count==128)
-                        count = stbi__get16be(s);
-                     else
-                        count -= 127;
-                     if (count > left)
-                        return stbi__errpuc("bad file","scanline overrun");
-
-                     if (!stbi__readval(s,packet->channel,value))
-                        return 0;
-
-                     for(i=0;i<count;++i, dest += 4)
-                        stbi__copyval(packet->channel,dest,value);
-                  } else { // Raw
-                     ++count;
-                     if (count>left) return stbi__errpuc("bad file","scanline overrun");
-
-                     for(i=0;i<count;++i, dest+=4)
-                        if (!stbi__readval(s,packet->channel,dest))
-                           return 0;
-                  }
-                  left-=count;
-               }
-               break;
-            }
-         }
-      }
-   }
-
-   return result;
-}
-
-static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *result;
-   int i, x,y, internal_comp;
-   STBI_NOTUSED(ri);
-
-   if (!comp) comp = &internal_comp;
-
-   for (i=0; i<92; ++i)
-      stbi__get8(s);
-
-   x = stbi__get16be(s);
-   y = stbi__get16be(s);
-
-   if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   if (stbi__at_eof(s))  return stbi__errpuc("bad file","file too short (pic header)");
-   if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode");
-
-   stbi__get32be(s); //skip `ratio'
-   stbi__get16be(s); //skip `fields'
-   stbi__get16be(s); //skip `pad'
-
-   // intermediate buffer is RGBA
-   result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
-   memset(result, 0xff, x*y*4);
-
-   if (!stbi__pic_load_core(s,x,y,comp, result)) {
-      STBI_FREE(result);
-      result=0;
-   }
-   *px = x;
-   *py = y;
-   if (req_comp == 0) req_comp = *comp;
-   result=stbi__convert_format(result,4,req_comp,x,y);
-
-   return result;
-}
-
-static int stbi__pic_test(stbi__context *s)
-{
-   int r = stbi__pic_test_core(s);
-   stbi__rewind(s);
-   return r;
-}
-#endif
-
-// *************************************************************************************************
-// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb
-
-#ifndef STBI_NO_GIF
-typedef struct
-{
-   stbi__int16 prefix;
-   stbi_uc first;
-   stbi_uc suffix;
-} stbi__gif_lzw;
-
-typedef struct
-{
-   int w,h;
-   stbi_uc *out;                 // output buffer (always 4 components)
-   stbi_uc *background;          // The current "background" as far as a gif is concerned
-   stbi_uc *history;
-   int flags, bgindex, ratio, transparent, eflags;
-   stbi_uc  pal[256][4];
-   stbi_uc lpal[256][4];
-   stbi__gif_lzw codes[8192];
-   stbi_uc *color_table;
-   int parse, step;
-   int lflags;
-   int start_x, start_y;
-   int max_x, max_y;
-   int cur_x, cur_y;
-   int line_size;
-   int delay;
-} stbi__gif;
-
-static int stbi__gif_test_raw(stbi__context *s)
-{
-   int sz;
-   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0;
-   sz = stbi__get8(s);
-   if (sz != '9' && sz != '7') return 0;
-   if (stbi__get8(s) != 'a') return 0;
-   return 1;
-}
-
-static int stbi__gif_test(stbi__context *s)
-{
-   int r = stbi__gif_test_raw(s);
-   stbi__rewind(s);
-   return r;
-}
-
-static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp)
-{
-   int i;
-   for (i=0; i < num_entries; ++i) {
-      pal[i][2] = stbi__get8(s);
-      pal[i][1] = stbi__get8(s);
-      pal[i][0] = stbi__get8(s);
-      pal[i][3] = transp == i ? 0 : 255;
-   }
-}
-
-static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info)
-{
-   stbi_uc version;
-   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8')
-      return stbi__err("not GIF", "Corrupt GIF");
-
-   version = stbi__get8(s);
-   if (version != '7' && version != '9')    return stbi__err("not GIF", "Corrupt GIF");
-   if (stbi__get8(s) != 'a')                return stbi__err("not GIF", "Corrupt GIF");
-
-   stbi__g_failure_reason = "";
-   g->w = stbi__get16le(s);
-   g->h = stbi__get16le(s);
-   g->flags = stbi__get8(s);
-   g->bgindex = stbi__get8(s);
-   g->ratio = stbi__get8(s);
-   g->transparent = -1;
-
-   if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-   if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)");
-
-   if (comp != 0) *comp = 4;  // can't actually tell whether it's 3 or 4 until we parse the comments
-
-   if (is_info) return 1;
-
-   if (g->flags & 0x80)
-      stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1);
-
-   return 1;
-}
-
-static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)
-{
-   stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));
-   if (!stbi__gif_header(s, g, comp, 1)) {
-      STBI_FREE(g);
-      stbi__rewind( s );
-      return 0;
-   }
-   if (x) *x = g->w;
-   if (y) *y = g->h;
-   STBI_FREE(g);
-   return 1;
-}
-
-static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)
-{
-   stbi_uc *p, *c;
-   int idx;
-
-   // recurse to decode the prefixes, since the linked-list is backwards,
-   // and working backwards through an interleaved image would be nasty
-   if (g->codes[code].prefix >= 0)
-      stbi__out_gif_code(g, g->codes[code].prefix);
-
-   if (g->cur_y >= g->max_y) return;
-
-   idx = g->cur_x + g->cur_y;
-   p = &g->out[idx];
-   g->history[idx / 4] = 1;
-
-   c = &g->color_table[g->codes[code].suffix * 4];
-   if (c[3] > 128) { // don't render transparent pixels;
-      p[0] = c[2];
-      p[1] = c[1];
-      p[2] = c[0];
-      p[3] = c[3];
-   }
-   g->cur_x += 4;
-
-   if (g->cur_x >= g->max_x) {
-      g->cur_x = g->start_x;
-      g->cur_y += g->step;
-
-      while (g->cur_y >= g->max_y && g->parse > 0) {
-         g->step = (1 << g->parse) * g->line_size;
-         g->cur_y = g->start_y + (g->step >> 1);
-         --g->parse;
-      }
-   }
-}
-
-static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
-{
-   stbi_uc lzw_cs;
-   stbi__int32 len, init_code;
-   stbi__uint32 first;
-   stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;
-   stbi__gif_lzw *p;
-
-   lzw_cs = stbi__get8(s);
-   if (lzw_cs > 12) return NULL;
-   clear = 1 << lzw_cs;
-   first = 1;
-   codesize = lzw_cs + 1;
-   codemask = (1 << codesize) - 1;
-   bits = 0;
-   valid_bits = 0;
-   for (init_code = 0; init_code < clear; init_code++) {
-      g->codes[init_code].prefix = -1;
-      g->codes[init_code].first = (stbi_uc) init_code;
-      g->codes[init_code].suffix = (stbi_uc) init_code;
-   }
-
-   // support no starting clear code
-   avail = clear+2;
-   oldcode = -1;
-
-   len = 0;
-   for(;;) {
-      if (valid_bits < codesize) {
-         if (len == 0) {
-            len = stbi__get8(s); // start new block
-            if (len == 0)
-               return g->out;
-         }
-         --len;
-         bits |= (stbi__int32) stbi__get8(s) << valid_bits;
-         valid_bits += 8;
-      } else {
-         stbi__int32 code = bits & codemask;
-         bits >>= codesize;
-         valid_bits -= codesize;
-         // @OPTIMIZE: is there some way we can accelerate the non-clear path?
-         if (code == clear) {  // clear code
-            codesize = lzw_cs + 1;
-            codemask = (1 << codesize) - 1;
-            avail = clear + 2;
-            oldcode = -1;
-            first = 0;
-         } else if (code == clear + 1) { // end of stream code
-            stbi__skip(s, len);
-            while ((len = stbi__get8(s)) > 0)
-               stbi__skip(s,len);
-            return g->out;
-         } else if (code <= avail) {
-            if (first) {
-               return stbi__errpuc("no clear code", "Corrupt GIF");
-            }
-
-            if (oldcode >= 0) {
-               p = &g->codes[avail++];
-               if (avail > 8192) {
-                  return stbi__errpuc("too many codes", "Corrupt GIF");
-               }
-
-               p->prefix = (stbi__int16) oldcode;
-               p->first = g->codes[oldcode].first;
-               p->suffix = (code == avail) ? p->first : g->codes[code].first;
-            } else if (code == avail)
-               return stbi__errpuc("illegal code in raster", "Corrupt GIF");
-
-            stbi__out_gif_code(g, (stbi__uint16) code);
-
-            if ((avail & codemask) == 0 && avail <= 0x0FFF) {
-               codesize++;
-               codemask = (1 << codesize) - 1;
-            }
-
-            oldcode = code;
-         } else {
-            return stbi__errpuc("illegal code in raster", "Corrupt GIF");
-         }
-      }
-   }
-}
-
-// this function is designed to support animated gifs, although stb_image doesn't support it
-// two back is the image from two frames ago, used for a very specific disposal format
-static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
-{
-   int dispose;
-   int first_frame;
-   int pi;
-   int pcount;
-   STBI_NOTUSED(req_comp);
-
-   // on first frame, any non-written pixels get the background colour (non-transparent)
-   first_frame = 0;
-   if (g->out == 0) {
-      if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header
-      if (!stbi__mad3sizes_valid(4, g->w, g->h, 0))
-         return stbi__errpuc("too large", "GIF image is too large");
-      pcount = g->w * g->h;
-      g->out = (stbi_uc *) stbi__malloc(4 * pcount);
-      g->background = (stbi_uc *) stbi__malloc(4 * pcount);
-      g->history = (stbi_uc *) stbi__malloc(pcount);
-      if (!g->out || !g->background || !g->history)
-         return stbi__errpuc("outofmem", "Out of memory");
-
-      // image is treated as "transparent" at the start - ie, nothing overwrites the current background;
-      // background colour is only used for pixels that are not rendered first frame, after that "background"
-      // color refers to the color that was there the previous frame.
-      memset(g->out, 0x00, 4 * pcount);
-      memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent)
-      memset(g->history, 0x00, pcount);        // pixels that were affected previous frame
-      first_frame = 1;
-   } else {
-      // second frame - how do we dispose of the previous one?
-      dispose = (g->eflags & 0x1C) >> 2;
-      pcount = g->w * g->h;
-
-      if ((dispose == 3) && (two_back == 0)) {
-         dispose = 2; // if I don't have an image to revert back to, default to the old background
-      }
-
-      if (dispose == 3) { // use previous graphic
-         for (pi = 0; pi < pcount; ++pi) {
-            if (g->history[pi]) {
-               memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 );
-            }
-         }
-      } else if (dispose == 2) {
-         // restore what was changed last frame to background before that frame;
-         for (pi = 0; pi < pcount; ++pi) {
-            if (g->history[pi]) {
-               memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 );
-            }
-         }
-      } else {
-         // This is a non-disposal case eithe way, so just
-         // leave the pixels as is, and they will become the new background
-         // 1: do not dispose
-         // 0:  not specified.
-      }
-
-      // background is what out is after the undoing of the previou frame;
-      memcpy( g->background, g->out, 4 * g->w * g->h );
-   }
-
-   // clear my history;
-   memset( g->history, 0x00, g->w * g->h );        // pixels that were affected previous frame
-
-   for (;;) {
-      int tag = stbi__get8(s);
-      switch (tag) {
-         case 0x2C: /* Image Descriptor */
-         {
-            stbi__int32 x, y, w, h;
-            stbi_uc *o;
-
-            x = stbi__get16le(s);
-            y = stbi__get16le(s);
-            w = stbi__get16le(s);
-            h = stbi__get16le(s);
-            if (((x + w) > (g->w)) || ((y + h) > (g->h)))
-               return stbi__errpuc("bad Image Descriptor", "Corrupt GIF");
-
-            g->line_size = g->w * 4;
-            g->start_x = x * 4;
-            g->start_y = y * g->line_size;
-            g->max_x   = g->start_x + w * 4;
-            g->max_y   = g->start_y + h * g->line_size;
-            g->cur_x   = g->start_x;
-            g->cur_y   = g->start_y;
-
-            // if the width of the specified rectangle is 0, that means
-            // we may not see *any* pixels or the image is malformed;
-            // to make sure this is caught, move the current y down to
-            // max_y (which is what out_gif_code checks).
-            if (w == 0)
-               g->cur_y = g->max_y;
-
-            g->lflags = stbi__get8(s);
-
-            if (g->lflags & 0x40) {
-               g->step = 8 * g->line_size; // first interlaced spacing
-               g->parse = 3;
-            } else {
-               g->step = g->line_size;
-               g->parse = 0;
-            }
-
-            if (g->lflags & 0x80) {
-               stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);
-               g->color_table = (stbi_uc *) g->lpal;
-            } else if (g->flags & 0x80) {
-               g->color_table = (stbi_uc *) g->pal;
-            } else
-               return stbi__errpuc("missing color table", "Corrupt GIF");
-
-            o = stbi__process_gif_raster(s, g);
-            if (!o) return NULL;
-
-            // if this was the first frame,
-            pcount = g->w * g->h;
-            if (first_frame && (g->bgindex > 0)) {
-               // if first frame, any pixel not drawn to gets the background color
-               for (pi = 0; pi < pcount; ++pi) {
-                  if (g->history[pi] == 0) {
-                     g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be;
-                     memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 );
-                  }
-               }
-            }
-
-            return o;
-         }
-
-         case 0x21: // Comment Extension.
-         {
-            int len;
-            int ext = stbi__get8(s);
-            if (ext == 0xF9) { // Graphic Control Extension.
-               len = stbi__get8(s);
-               if (len == 4) {
-                  g->eflags = stbi__get8(s);
-                  g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths.
-
-                  // unset old transparent
-                  if (g->transparent >= 0) {
-                     g->pal[g->transparent][3] = 255;
-                  }
-                  if (g->eflags & 0x01) {
-                     g->transparent = stbi__get8(s);
-                     if (g->transparent >= 0) {
-                        g->pal[g->transparent][3] = 0;
-                     }
-                  } else {
-                     // don't need transparent
-                     stbi__skip(s, 1);
-                     g->transparent = -1;
-                  }
-               } else {
-                  stbi__skip(s, len);
-                  break;
-               }
-            }
-            while ((len = stbi__get8(s)) != 0) {
-               stbi__skip(s, len);
-            }
-            break;
-         }
-
-         case 0x3B: // gif stream termination code
-            return (stbi_uc *) s; // using '1' causes warning on some compilers
-
-         default:
-            return stbi__errpuc("unknown code", "Corrupt GIF");
-      }
-   }
-}
-
-static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)
-{
-   if (stbi__gif_test(s)) {
-      int layers = 0;
-      stbi_uc *u = 0;
-      stbi_uc *out = 0;
-      stbi_uc *two_back = 0;
-      stbi__gif g;
-      int stride;
-      int out_size = 0;
-      int delays_size = 0;
-      memset(&g, 0, sizeof(g));
-      if (delays) {
-         *delays = 0;
-      }
-
-      do {
-         u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);
-         if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
-
-         if (u) {
-            *x = g.w;
-            *y = g.h;
-            ++layers;
-            stride = g.w * g.h * 4;
-
-            if (out) {
-               void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride );
-               if (NULL == tmp) {
-                  STBI_FREE(g.out);
-                  STBI_FREE(g.history);
-                  STBI_FREE(g.background);
-                  return stbi__errpuc("outofmem", "Out of memory");
-               }
-               else {
-                   out = (stbi_uc*) tmp;
-                   out_size = layers * stride;
-               }
-
-               if (delays) {
-                  *delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers );
-                  delays_size = layers * sizeof(int);
-               }
-            } else {
-               out = (stbi_uc*)stbi__malloc( layers * stride );
-               out_size = layers * stride;
-               if (delays) {
-                  *delays = (int*) stbi__malloc( layers * sizeof(int) );
-                  delays_size = layers * sizeof(int);
-               }
-            }
-            memcpy( out + ((layers - 1) * stride), u, stride );
-            if (layers >= 2) {
-               two_back = out - 2 * stride;
-            }
-
-            if (delays) {
-               (*delays)[layers - 1U] = g.delay;
-            }
-         }
-      } while (u != 0);
-
-      // free temp buffer;
-      STBI_FREE(g.out);
-      STBI_FREE(g.history);
-      STBI_FREE(g.background);
-
-      // do the final conversion after loading everything;
-      if (req_comp && req_comp != 4)
-         out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h);
-
-      *z = layers;
-      return out;
-   } else {
-      return stbi__errpuc("not GIF", "Image was not as a gif type.");
-   }
-}
-
-static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *u = 0;
-   stbi__gif g;
-   memset(&g, 0, sizeof(g));
-   STBI_NOTUSED(ri);
-
-   u = stbi__gif_load_next(s, &g, comp, req_comp, 0);
-   if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker
-   if (u) {
-      *x = g.w;
-      *y = g.h;
-
-      // moved conversion to after successful load so that the same
-      // can be done for multiple frames.
-      if (req_comp && req_comp != 4)
-         u = stbi__convert_format(u, 4, req_comp, g.w, g.h);
-   } else if (g.out) {
-      // if there was an error and we allocated an image buffer, free it!
-      STBI_FREE(g.out);
-   }
-
-   // free buffers needed for multiple frame loading;
-   STBI_FREE(g.history);
-   STBI_FREE(g.background);
-
-   return u;
-}
-
-static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   return stbi__gif_info_raw(s,x,y,comp);
-}
-#endif
-
-// *************************************************************************************************
-// Radiance RGBE HDR loader
-// originally by Nicolas Schulz
-#ifndef STBI_NO_HDR
-static int stbi__hdr_test_core(stbi__context *s, const char *signature)
-{
-   int i;
-   for (i=0; signature[i]; ++i)
-      if (stbi__get8(s) != signature[i])
-          return 0;
-   stbi__rewind(s);
-   return 1;
-}
-
-static int stbi__hdr_test(stbi__context* s)
-{
-   int r = stbi__hdr_test_core(s, "#?RADIANCE\n");
-   stbi__rewind(s);
-   if(!r) {
-       r = stbi__hdr_test_core(s, "#?RGBE\n");
-       stbi__rewind(s);
-   }
-   return r;
-}
-
-#define STBI__HDR_BUFLEN  1024
-static char *stbi__hdr_gettoken(stbi__context *z, char *buffer)
-{
-   int len=0;
-   char c = '\0';
-
-   c = (char) stbi__get8(z);
-
-   while (!stbi__at_eof(z) && c != '\n') {
-      buffer[len++] = c;
-      if (len == STBI__HDR_BUFLEN-1) {
-         // flush to end of line
-         while (!stbi__at_eof(z) && stbi__get8(z) != '\n')
-            ;
-         break;
-      }
-      c = (char) stbi__get8(z);
-   }
-
-   buffer[len] = 0;
-   return buffer;
-}
-
-static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)
-{
-   if ( input[3] != 0 ) {
-      float f1;
-      // Exponent
-      f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8));
-      if (req_comp <= 2)
-         output[0] = (input[0] + input[1] + input[2]) * f1 / 3;
-      else {
-         output[0] = input[0] * f1;
-         output[1] = input[1] * f1;
-         output[2] = input[2] * f1;
-      }
-      if (req_comp == 2) output[1] = 1;
-      if (req_comp == 4) output[3] = 1;
-   } else {
-      switch (req_comp) {
-         case 4: output[3] = 1; /* fallthrough */
-         case 3: output[0] = output[1] = output[2] = 0;
-                 break;
-         case 2: output[1] = 1; /* fallthrough */
-         case 1: output[0] = 0;
-                 break;
-      }
-   }
-}
-
-static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   char buffer[STBI__HDR_BUFLEN];
-   char *token;
-   int valid = 0;
-   int width, height;
-   stbi_uc *scanline;
-   float *hdr_data;
-   int len;
-   unsigned char count, value;
-   int i, j, k, c1,c2, z;
-   const char *headerToken;
-   STBI_NOTUSED(ri);
-
-   // Check identifier
-   headerToken = stbi__hdr_gettoken(s,buffer);
-   if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0)
-      return stbi__errpf("not HDR", "Corrupt HDR image");
-
-   // Parse header
-   for(;;) {
-      token = stbi__hdr_gettoken(s,buffer);
-      if (token[0] == 0) break;
-      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
-   }
-
-   if (!valid)    return stbi__errpf("unsupported format", "Unsupported HDR format");
-
-   // Parse width and height
-   // can't use sscanf() if we're not using stdio!
-   token = stbi__hdr_gettoken(s,buffer);
-   if (strncmp(token, "-Y ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
-   token += 3;
-   height = (int) strtol(token, &token, 10);
-   while (*token == ' ') ++token;
-   if (strncmp(token, "+X ", 3))  return stbi__errpf("unsupported data layout", "Unsupported HDR format");
-   token += 3;
-   width = (int) strtol(token, NULL, 10);
-
-   if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
-   if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)");
-
-   *x = width;
-   *y = height;
-
-   if (comp) *comp = 3;
-   if (req_comp == 0) req_comp = 3;
-
-   if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0))
-      return stbi__errpf("too large", "HDR image is too large");
-
-   // Read data
-   hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0);
-   if (!hdr_data)
-      return stbi__errpf("outofmem", "Out of memory");
-
-   // Load image data
-   // image data is stored as some number of sca
-   if ( width < 8 || width >= 32768) {
-      // Read flat data
-      for (j=0; j < height; ++j) {
-         for (i=0; i < width; ++i) {
-            stbi_uc rgbe[4];
-           main_decode_loop:
-            stbi__getn(s, rgbe, 4);
-            stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp);
-         }
-      }
-   } else {
-      // Read RLE-encoded data
-      scanline = NULL;
-
-      for (j = 0; j < height; ++j) {
-         c1 = stbi__get8(s);
-         c2 = stbi__get8(s);
-         len = stbi__get8(s);
-         if (c1 != 2 || c2 != 2 || (len & 0x80)) {
-            // not run-length encoded, so we have to actually use THIS data as a decoded
-            // pixel (note this can't be a valid pixel--one of RGB must be >= 128)
-            stbi_uc rgbe[4];
-            rgbe[0] = (stbi_uc) c1;
-            rgbe[1] = (stbi_uc) c2;
-            rgbe[2] = (stbi_uc) len;
-            rgbe[3] = (stbi_uc) stbi__get8(s);
-            stbi__hdr_convert(hdr_data, rgbe, req_comp);
-            i = 1;
-            j = 0;
-            STBI_FREE(scanline);
-            goto main_decode_loop; // yes, this makes no sense
-         }
-         len <<= 8;
-         len |= stbi__get8(s);
-         if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); }
-         if (scanline == NULL) {
-            scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0);
-            if (!scanline) {
-               STBI_FREE(hdr_data);
-               return stbi__errpf("outofmem", "Out of memory");
-            }
-         }
-
-         for (k = 0; k < 4; ++k) {
-            int nleft;
-            i = 0;
-            while ((nleft = width - i) > 0) {
-               count = stbi__get8(s);
-               if (count > 128) {
-                  // Run
-                  value = stbi__get8(s);
-                  count -= 128;
-                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
-                  for (z = 0; z < count; ++z)
-                     scanline[i++ * 4 + k] = value;
-               } else {
-                  // Dump
-                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
-                  for (z = 0; z < count; ++z)
-                     scanline[i++ * 4 + k] = stbi__get8(s);
-               }
-            }
-         }
-         for (i=0; i < width; ++i)
-            stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp);
-      }
-      if (scanline)
-         STBI_FREE(scanline);
-   }
-
-   return hdr_data;
-}
-
-static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   char buffer[STBI__HDR_BUFLEN];
-   char *token;
-   int valid = 0;
-   int dummy;
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   if (stbi__hdr_test(s) == 0) {
-       stbi__rewind( s );
-       return 0;
-   }
-
-   for(;;) {
-      token = stbi__hdr_gettoken(s,buffer);
-      if (token[0] == 0) break;
-      if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1;
-   }
-
-   if (!valid) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token = stbi__hdr_gettoken(s,buffer);
-   if (strncmp(token, "-Y ", 3)) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token += 3;
-   *y = (int) strtol(token, &token, 10);
-   while (*token == ' ') ++token;
-   if (strncmp(token, "+X ", 3)) {
-       stbi__rewind( s );
-       return 0;
-   }
-   token += 3;
-   *x = (int) strtol(token, NULL, 10);
-   *comp = 3;
-   return 1;
-}
-#endif // STBI_NO_HDR
-
-#ifndef STBI_NO_BMP
-static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   void *p;
-   stbi__bmp_data info;
-
-   info.all_a = 255;
-   p = stbi__bmp_parse_header(s, &info);
-   stbi__rewind( s );
-   if (p == NULL)
-      return 0;
-   if (x) *x = s->img_x;
-   if (y) *y = s->img_y;
-   if (comp) {
-      if (info.bpp == 24 && info.ma == 0xff000000)
-         *comp = 3;
-      else
-         *comp = info.ma ? 4 : 3;
-   }
-   return 1;
-}
-#endif
-
-#ifndef STBI_NO_PSD
-static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int channelCount, dummy, depth;
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-   if (stbi__get32be(s) != 0x38425053) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 1) {
-       stbi__rewind( s );
-       return 0;
-   }
-   stbi__skip(s, 6);
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   *y = stbi__get32be(s);
-   *x = stbi__get32be(s);
-   depth = stbi__get16be(s);
-   if (depth != 8 && depth != 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 3) {
-       stbi__rewind( s );
-       return 0;
-   }
-   *comp = 4;
-   return 1;
-}
-
-static int stbi__psd_is16(stbi__context *s)
-{
-   int channelCount, depth;
-   if (stbi__get32be(s) != 0x38425053) {
-       stbi__rewind( s );
-       return 0;
-   }
-   if (stbi__get16be(s) != 1) {
-       stbi__rewind( s );
-       return 0;
-   }
-   stbi__skip(s, 6);
-   channelCount = stbi__get16be(s);
-   if (channelCount < 0 || channelCount > 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   (void) stbi__get32be(s);
-   (void) stbi__get32be(s);
-   depth = stbi__get16be(s);
-   if (depth != 16) {
-       stbi__rewind( s );
-       return 0;
-   }
-   return 1;
-}
-#endif
-
-#ifndef STBI_NO_PIC
-static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int act_comp=0,num_packets=0,chained,dummy;
-   stbi__pic_packet packets[10];
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) {
-      stbi__rewind(s);
-      return 0;
-   }
-
-   stbi__skip(s, 88);
-
-   *x = stbi__get16be(s);
-   *y = stbi__get16be(s);
-   if (stbi__at_eof(s)) {
-      stbi__rewind( s);
-      return 0;
-   }
-   if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) {
-      stbi__rewind( s );
-      return 0;
-   }
-
-   stbi__skip(s, 8);
-
-   do {
-      stbi__pic_packet *packet;
-
-      if (num_packets==sizeof(packets)/sizeof(packets[0]))
-         return 0;
-
-      packet = &packets[num_packets++];
-      chained = stbi__get8(s);
-      packet->size    = stbi__get8(s);
-      packet->type    = stbi__get8(s);
-      packet->channel = stbi__get8(s);
-      act_comp |= packet->channel;
-
-      if (stbi__at_eof(s)) {
-          stbi__rewind( s );
-          return 0;
-      }
-      if (packet->size != 8) {
-          stbi__rewind( s );
-          return 0;
-      }
-   } while (chained);
-
-   *comp = (act_comp & 0x10 ? 4 : 3);
-
-   return 1;
-}
-#endif
-
-// *************************************************************************************************
-// Portable Gray Map and Portable Pixel Map loader
-// by Ken Miller
-//
-// PGM: http://netpbm.sourceforge.net/doc/pgm.html
-// PPM: http://netpbm.sourceforge.net/doc/ppm.html
-//
-// Known limitations:
-//    Does not support comments in the header section
-//    Does not support ASCII image data (formats P2 and P3)
-//    Does not support 16-bit-per-channel
-
-#ifndef STBI_NO_PNM
-
-static int      stbi__pnm_test(stbi__context *s)
-{
-   char p, t;
-   p = (char) stbi__get8(s);
-   t = (char) stbi__get8(s);
-   if (p != 'P' || (t != '5' && t != '6')) {
-       stbi__rewind( s );
-       return 0;
-   }
-   return 1;
-}
-
-static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
-{
-   stbi_uc *out;
-   STBI_NOTUSED(ri);
-
-   if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n))
-      return 0;
-
-   if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-   if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
-
-   *x = s->img_x;
-   *y = s->img_y;
-   if (comp) *comp = s->img_n;
-
-   if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0))
-      return stbi__errpuc("too large", "PNM too large");
-
-   out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0);
-   if (!out) return stbi__errpuc("outofmem", "Out of memory");
-   stbi__getn(s, out, s->img_n * s->img_x * s->img_y);
-
-   if (req_comp && req_comp != s->img_n) {
-      out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
-      if (out == NULL) return out; // stbi__convert_format frees input on failure
-   }
-   return out;
-}
-
-static int      stbi__pnm_isspace(char c)
-{
-   return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
-}
-
-static void     stbi__pnm_skip_whitespace(stbi__context *s, char *c)
-{
-   for (;;) {
-      while (!stbi__at_eof(s) && stbi__pnm_isspace(*c))
-         *c = (char) stbi__get8(s);
-
-      if (stbi__at_eof(s) || *c != '#')
-         break;
-
-      while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' )
-         *c = (char) stbi__get8(s);
-   }
-}
-
-static int      stbi__pnm_isdigit(char c)
-{
-   return c >= '0' && c <= '9';
-}
-
-static int      stbi__pnm_getinteger(stbi__context *s, char *c)
-{
-   int value = 0;
-
-   while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {
-      value = value*10 + (*c - '0');
-      *c = (char) stbi__get8(s);
-   }
-
-   return value;
-}
-
-static int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
-{
-   int maxv, dummy;
-   char c, p, t;
-
-   if (!x) x = &dummy;
-   if (!y) y = &dummy;
-   if (!comp) comp = &dummy;
-
-   stbi__rewind(s);
-
-   // Get identifier
-   p = (char) stbi__get8(s);
-   t = (char) stbi__get8(s);
-   if (p != 'P' || (t != '5' && t != '6')) {
-       stbi__rewind(s);
-       return 0;
-   }
-
-   *comp = (t == '6') ? 3 : 1;  // '5' is 1-component .pgm; '6' is 3-component .ppm
-
-   c = (char) stbi__get8(s);
-   stbi__pnm_skip_whitespace(s, &c);
-
-   *x = stbi__pnm_getinteger(s, &c); // read width
-   stbi__pnm_skip_whitespace(s, &c);
-
-   *y = stbi__pnm_getinteger(s, &c); // read height
-   stbi__pnm_skip_whitespace(s, &c);
-
-   maxv = stbi__pnm_getinteger(s, &c);  // read max value
-
-   if (maxv > 255)
-      return stbi__err("max value > 255", "PPM image not 8-bit");
-   else
-      return 1;
-}
-#endif
-
-static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp)
-{
-   #ifndef STBI_NO_JPEG
-   if (stbi__jpeg_info(s, x, y, comp)) return 1;
-   #endif
-
-   #ifndef STBI_NO_PNG
-   if (stbi__png_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_GIF
-   if (stbi__gif_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_BMP
-   if (stbi__bmp_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PIC
-   if (stbi__pic_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PNM
-   if (stbi__pnm_info(s, x, y, comp))  return 1;
-   #endif
-
-   #ifndef STBI_NO_HDR
-   if (stbi__hdr_info(s, x, y, comp))  return 1;
-   #endif
-
-   // test tga last because it's a crappy test!
-   #ifndef STBI_NO_TGA
-   if (stbi__tga_info(s, x, y, comp))
-       return 1;
-   #endif
-   return stbi__err("unknown image type", "Image not of any known type, or corrupt");
-}
-
-static int stbi__is_16_main(stbi__context *s)
-{
-   #ifndef STBI_NO_PNG
-   if (stbi__png_is16(s))  return 1;
-   #endif
-
-   #ifndef STBI_NO_PSD
-   if (stbi__psd_is16(s))  return 1;
-   #endif
-
-   return 0;
-}
-
-#ifndef STBI_NO_STDIO
-STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp)
-{
-    FILE *f = stbi__fopen(filename, "rb");
-    int result;
-    if (!f) return stbi__err("can't fopen", "Unable to open file");
-    result = stbi_info_from_file(f, x, y, comp);
-    fclose(f);
-    return result;
-}
-
-STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp)
-{
-   int r;
-   stbi__context s;
-   long pos = ftell(f);
-   stbi__start_file(&s, f);
-   r = stbi__info_main(&s,x,y,comp);
-   fseek(f,pos,SEEK_SET);
-   return r;
-}
-
-STBIDEF int stbi_is_16_bit(char const *filename)
-{
-    FILE *f = stbi__fopen(filename, "rb");
-    int result;
-    if (!f) return stbi__err("can't fopen", "Unable to open file");
-    result = stbi_is_16_bit_from_file(f);
-    fclose(f);
-    return result;
-}
-
-STBIDEF int stbi_is_16_bit_from_file(FILE *f)
-{
-   int r;
-   stbi__context s;
-   long pos = ftell(f);
-   stbi__start_file(&s, f);
-   r = stbi__is_16_main(&s);
-   fseek(f,pos,SEEK_SET);
-   return r;
-}
-#endif // !STBI_NO_STDIO
-
-STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__info_main(&s,x,y,comp);
-}
-
-STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
-   return stbi__info_main(&s,x,y,comp);
-}
-
-STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len)
-{
-   stbi__context s;
-   stbi__start_mem(&s,buffer,len);
-   return stbi__is_16_main(&s);
-}
-
-STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user)
-{
-   stbi__context s;
-   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);
-   return stbi__is_16_main(&s);
-}
-
-#endif // STB_IMAGE_IMPLEMENTATION
-
-/*
-   revision history:
-      2.20  (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs
-      2.19  (2018-02-11) fix warning
-      2.18  (2018-01-30) fix warnings
-      2.17  (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug
-                         1-bit BMP
-                         *_is_16_bit api
-                         avoid warnings
-      2.16  (2017-07-23) all functions have 16-bit variants;
-                         STBI_NO_STDIO works again;
-                         compilation fixes;
-                         fix rounding in unpremultiply;
-                         optimize vertical flip;
-                         disable raw_len validation;
-                         documentation fixes
-      2.15  (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode;
-                         warning fixes; disable run-time SSE detection on gcc;
-                         uniform handling of optional "return" values;
-                         thread-safe initialization of zlib tables
-      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs
-      2.13  (2016-11-29) add 16-bit API, only supported for PNG right now
-      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes
-      2.11  (2016-04-02) allocate large structures on the stack
-                         remove white matting for transparent PSD
-                         fix reported channel count for PNG & BMP
-                         re-enable SSE2 in non-gcc 64-bit
-                         support RGB-formatted JPEG
-                         read 16-bit PNGs (only as 8-bit)
-      2.10  (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED
-      2.09  (2016-01-16) allow comments in PNM files
-                         16-bit-per-pixel TGA (not bit-per-component)
-                         info() for TGA could break due to .hdr handling
-                         info() for BMP to shares code instead of sloppy parse
-                         can use STBI_REALLOC_SIZED if allocator doesn't support realloc
-                         code cleanup
-      2.08  (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA
-      2.07  (2015-09-13) fix compiler warnings
-                         partial animated GIF support
-                         limited 16-bpc PSD support
-                         #ifdef unused functions
-                         bug with < 92 byte PIC,PNM,HDR,TGA
-      2.06  (2015-04-19) fix bug where PSD returns wrong '*comp' value
-      2.05  (2015-04-19) fix bug in progressive JPEG handling, fix warning
-      2.04  (2015-04-15) try to re-enable SIMD on MinGW 64-bit
-      2.03  (2015-04-12) extra corruption checking (mmozeiko)
-                         stbi_set_flip_vertically_on_load (nguillemot)
-                         fix NEON support; fix mingw support
-      2.02  (2015-01-19) fix incorrect assert, fix warning
-      2.01  (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2
-      2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG
-      2.00  (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg)
-                         progressive JPEG (stb)
-                         PGM/PPM support (Ken Miller)
-                         STBI_MALLOC,STBI_REALLOC,STBI_FREE
-                         GIF bugfix -- seemingly never worked
-                         STBI_NO_*, STBI_ONLY_*
-      1.48  (2014-12-14) fix incorrectly-named assert()
-      1.47  (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb)
-                         optimize PNG (ryg)
-                         fix bug in interlaced PNG with user-specified channel count (stb)
-      1.46  (2014-08-26)
-              fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG
-      1.45  (2014-08-16)
-              fix MSVC-ARM internal compiler error by wrapping malloc
-      1.44  (2014-08-07)
-              various warning fixes from Ronny Chevalier
-      1.43  (2014-07-15)
-              fix MSVC-only compiler problem in code changed in 1.42
-      1.42  (2014-07-09)
-              don't define _CRT_SECURE_NO_WARNINGS (affects user code)
-              fixes to stbi__cleanup_jpeg path
-              added STBI_ASSERT to avoid requiring assert.h
-      1.41  (2014-06-25)
-              fix search&replace from 1.36 that messed up comments/error messages
-      1.40  (2014-06-22)
-              fix gcc struct-initialization warning
-      1.39  (2014-06-15)
-              fix to TGA optimization when req_comp != number of components in TGA;
-              fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite)
-              add support for BMP version 5 (more ignored fields)
-      1.38  (2014-06-06)
-              suppress MSVC warnings on integer casts truncating values
-              fix accidental rename of 'skip' field of I/O
-      1.37  (2014-06-04)
-              remove duplicate typedef
-      1.36  (2014-06-03)
-              convert to header file single-file library
-              if de-iphone isn't set, load iphone images color-swapped instead of returning NULL
-      1.35  (2014-05-27)
-              various warnings
-              fix broken STBI_SIMD path
-              fix bug where stbi_load_from_file no longer left file pointer in correct place
-              fix broken non-easy path for 32-bit BMP (possibly never used)
-              TGA optimization by Arseny Kapoulkine
-      1.34  (unknown)
-              use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case
-      1.33  (2011-07-14)
-              make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements
-      1.32  (2011-07-13)
-              support for "info" function for all supported filetypes (SpartanJ)
-      1.31  (2011-06-20)
-              a few more leak fixes, bug in PNG handling (SpartanJ)
-      1.30  (2011-06-11)
-              added ability to load files via callbacks to accomidate custom input streams (Ben Wenger)
-              removed deprecated format-specific test/load functions
-              removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway
-              error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha)
-              fix inefficiency in decoding 32-bit BMP (David Woo)
-      1.29  (2010-08-16)
-              various warning fixes from Aurelien Pocheville
-      1.28  (2010-08-01)
-              fix bug in GIF palette transparency (SpartanJ)
-      1.27  (2010-08-01)
-              cast-to-stbi_uc to fix warnings
-      1.26  (2010-07-24)
-              fix bug in file buffering for PNG reported by SpartanJ
-      1.25  (2010-07-17)
-              refix trans_data warning (Won Chun)
-      1.24  (2010-07-12)
-              perf improvements reading from files on platforms with lock-heavy fgetc()
-              minor perf improvements for jpeg
-              deprecated type-specific functions so we'll get feedback if they're needed
-              attempt to fix trans_data warning (Won Chun)
-      1.23    fixed bug in iPhone support
-      1.22  (2010-07-10)
-              removed image *writing* support
-              stbi_info support from Jetro Lauha
-              GIF support from Jean-Marc Lienher
-              iPhone PNG-extensions from James Brown
-              warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva)
-      1.21    fix use of 'stbi_uc' in header (reported by jon blow)
-      1.20    added support for Softimage PIC, by Tom Seddon
-      1.19    bug in interlaced PNG corruption check (found by ryg)
-      1.18  (2008-08-02)
-              fix a threading bug (local mutable static)
-      1.17    support interlaced PNG
-      1.16    major bugfix - stbi__convert_format converted one too many pixels
-      1.15    initialize some fields for thread safety
-      1.14    fix threadsafe conversion bug
-              header-file-only version (#define STBI_HEADER_FILE_ONLY before including)
-      1.13    threadsafe
-      1.12    const qualifiers in the API
-      1.11    Support installable IDCT, colorspace conversion routines
-      1.10    Fixes for 64-bit (don't use "unsigned long")
-              optimized upsampling by Fabian "ryg" Giesen
-      1.09    Fix format-conversion for PSD code (bad global variables!)
-      1.08    Thatcher Ulrich's PSD code integrated by Nicolas Schulz
-      1.07    attempt to fix C++ warning/errors again
-      1.06    attempt to fix C++ warning/errors again
-      1.05    fix TGA loading to return correct *comp and use good luminance calc
-      1.04    default float alpha is 1, not 255; use 'void *' for stbi_image_free
-      1.03    bugfixes to STBI_NO_STDIO, STBI_NO_HDR
-      1.02    support for (subset of) HDR files, float interface for preferred access to them
-      1.01    fix bug: possible bug in handling right-side up bmps... not sure
-              fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all
-      1.00    interface to zlib that skips zlib header
-      0.99    correct handling of alpha in palette
-      0.98    TGA loader by lonesock; dynamically add loaders (untested)
-      0.97    jpeg errors on too large a file; also catch another malloc failure
-      0.96    fix detection of invalid v value - particleman@mollyrocket forum
-      0.95    during header scan, seek to markers in case of padding
-      0.94    STBI_NO_STDIO to disable stdio usage; rename all #defines the same
-      0.93    handle jpegtran output; verbose errors
-      0.92    read 4,8,16,24,32-bit BMP files of several formats
-      0.91    output 24-bit Windows 3.0 BMP files
-      0.90    fix a few more warnings; bump version number to approach 1.0
-      0.61    bugfixes due to Marc LeBlanc, Christopher Lloyd
-      0.60    fix compiling as c++
-      0.59    fix warnings: merge Dave Moore's -Wall fixes
-      0.58    fix bug: zlib uncompressed mode len/nlen was wrong endian
-      0.57    fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available
-      0.56    fix bug: zlib uncompressed mode len vs. nlen
-      0.55    fix bug: restart_interval not initialized to 0
-      0.54    allow NULL for 'int *comp'
-      0.53    fix bug in png 3->4; speedup png decoding
-      0.52    png handles req_comp=3,4 directly; minor cleanup; jpeg comments
-      0.51    obey req_comp requests, 1-component jpegs return as 1-component,
-              on 'test' only check type, not whether we support this variant
-      0.50  (2006-11-19)
-              first released version
-*/
-
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_image_resize.h b/raylib_pi4_test/external/stb_image_resize.h
deleted file mode 100644 (file)
index 42a8efb..0000000
+++ /dev/null
@@ -1,2631 +0,0 @@
-/* stb_image_resize - v0.96 - public domain image resizing
-   by Jorge L Rodriguez (@VinoBS) - 2014
-   http://github.com/nothings/stb
-
-   Written with emphasis on usability, portability, and efficiency. (No
-   SIMD or threads, so it be easily outperformed by libs that use those.)
-   Only scaling and translation is supported, no rotations or shears.
-   Easy API downsamples w/Mitchell filter, upsamples w/cubic interpolation.
-
-   COMPILING & LINKING
-      In one C/C++ file that #includes this file, do this:
-         #define STB_IMAGE_RESIZE_IMPLEMENTATION
-      before the #include. That will create the implementation in that file.
-
-   QUICKSTART
-      stbir_resize_uint8(      input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0, num_channels)
-      stbir_resize_float(...)
-      stbir_resize_uint8_srgb( input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0,
-                               num_channels , alpha_chan  , 0)
-      stbir_resize_uint8_srgb_edgemode(
-                               input_pixels , in_w , in_h , 0,
-                               output_pixels, out_w, out_h, 0,
-                               num_channels , alpha_chan  , 0, STBIR_EDGE_CLAMP)
-                                                            // WRAP/REFLECT/ZERO
-
-   FULL API
-      See the "header file" section of the source for API documentation.
-
-   ADDITIONAL DOCUMENTATION
-
-      SRGB & FLOATING POINT REPRESENTATION
-         The sRGB functions presume IEEE floating point. If you do not have
-         IEEE floating point, define STBIR_NON_IEEE_FLOAT. This will use
-         a slower implementation.
-
-      MEMORY ALLOCATION
-         The resize functions here perform a single memory allocation using
-         malloc. To control the memory allocation, before the #include that
-         triggers the implementation, do:
-
-            #define STBIR_MALLOC(size,context) ...
-            #define STBIR_FREE(ptr,context)   ...
-
-         Each resize function makes exactly one call to malloc/free, so to use
-         temp memory, store the temp memory in the context and return that.
-
-      ASSERT
-         Define STBIR_ASSERT(boolval) to override assert() and not use assert.h
-
-      OPTIMIZATION
-         Define STBIR_SATURATE_INT to compute clamp values in-range using
-         integer operations instead of float operations. This may be faster
-         on some platforms.
-
-      DEFAULT FILTERS
-         For functions which don't provide explicit control over what filters
-         to use, you can change the compile-time defaults with
-
-            #define STBIR_DEFAULT_FILTER_UPSAMPLE     STBIR_FILTER_something
-            #define STBIR_DEFAULT_FILTER_DOWNSAMPLE   STBIR_FILTER_something
-
-         See stbir_filter in the header-file section for the list of filters.
-
-      NEW FILTERS
-         A number of 1D filter kernels are used. For a list of
-         supported filters see the stbir_filter enum. To add a new filter,
-         write a filter function and add it to stbir__filter_info_table.
-
-      PROGRESS
-         For interactive use with slow resize operations, you can install
-         a progress-report callback:
-
-            #define STBIR_PROGRESS_REPORT(val)   some_func(val)
-
-         The parameter val is a float which goes from 0 to 1 as progress is made.
-
-         For example:
-
-            static void my_progress_report(float progress);
-            #define STBIR_PROGRESS_REPORT(val) my_progress_report(val)
-
-            #define STB_IMAGE_RESIZE_IMPLEMENTATION
-            #include "stb_image_resize.h"
-
-            static void my_progress_report(float progress)
-            {
-               printf("Progress: %f%%\n", progress*100);
-            }
-
-      MAX CHANNELS
-         If your image has more than 64 channels, define STBIR_MAX_CHANNELS
-         to the max you'll have.
-
-      ALPHA CHANNEL
-         Most of the resizing functions provide the ability to control how
-         the alpha channel of an image is processed. The important things
-         to know about this:
-
-         1. The best mathematically-behaved version of alpha to use is
-         called "premultiplied alpha", in which the other color channels
-         have had the alpha value multiplied in. If you use premultiplied
-         alpha, linear filtering (such as image resampling done by this
-         library, or performed in texture units on GPUs) does the "right
-         thing". While premultiplied alpha is standard in the movie CGI
-         industry, it is still uncommon in the videogame/real-time world.
-
-         If you linearly filter non-premultiplied alpha, strange effects
-         occur. (For example, the 50/50 average of 99% transparent bright green
-         and 1% transparent black produces 50% transparent dark green when
-         non-premultiplied, whereas premultiplied it produces 50%
-         transparent near-black. The former introduces green energy
-         that doesn't exist in the source image.)
-
-         2. Artists should not edit premultiplied-alpha images; artists
-         want non-premultiplied alpha images. Thus, art tools generally output
-         non-premultiplied alpha images.
-
-         3. You will get best results in most cases by converting images
-         to premultiplied alpha before processing them mathematically.
-
-         4. If you pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED, the
-         resizer does not do anything special for the alpha channel;
-         it is resampled identically to other channels. This produces
-         the correct results for premultiplied-alpha images, but produces
-         less-than-ideal results for non-premultiplied-alpha images.
-
-         5. If you do not pass the flag STBIR_FLAG_ALPHA_PREMULTIPLIED,
-         then the resizer weights the contribution of input pixels
-         based on their alpha values, or, equivalently, it multiplies
-         the alpha value into the color channels, resamples, then divides
-         by the resultant alpha value. Input pixels which have alpha=0 do
-         not contribute at all to output pixels unless _all_ of the input
-         pixels affecting that output pixel have alpha=0, in which case
-         the result for that pixel is the same as it would be without
-         STBIR_FLAG_ALPHA_PREMULTIPLIED. However, this is only true for
-         input images in integer formats. For input images in float format,
-         input pixels with alpha=0 have no effect, and output pixels
-         which have alpha=0 will be 0 in all channels. (For float images,
-         you can manually achieve the same result by adding a tiny epsilon
-         value to the alpha channel of every image, and then subtracting
-         or clamping it at the end.)
-
-         6. You can suppress the behavior described in #5 and make
-         all-0-alpha pixels have 0 in all channels by #defining
-         STBIR_NO_ALPHA_EPSILON.
-
-         7. You can separately control whether the alpha channel is
-         interpreted as linear or affected by the colorspace. By default
-         it is linear; you almost never want to apply the colorspace.
-         (For example, graphics hardware does not apply sRGB conversion
-         to the alpha channel.)
-
-   CONTRIBUTORS
-      Jorge L Rodriguez: Implementation
-      Sean Barrett: API design, optimizations
-      Aras Pranckevicius: bugfix
-      Nathan Reed: warning fixes
-
-   REVISIONS
-      0.97 (2020-02-02) fixed warning
-      0.96 (2019-03-04) fixed warnings
-      0.95 (2017-07-23) fixed warnings
-      0.94 (2017-03-18) fixed warnings
-      0.93 (2017-03-03) fixed bug with certain combinations of heights
-      0.92 (2017-01-02) fix integer overflow on large (>2GB) images
-      0.91 (2016-04-02) fix warnings; fix handling of subpixel regions
-      0.90 (2014-09-17) first released version
-
-   LICENSE
-     See end of file for license information.
-
-   TODO
-      Don't decode all of the image data when only processing a partial tile
-      Don't use full-width decode buffers when only processing a partial tile
-      When processing wide images, break processing into tiles so data fits in L1 cache
-      Installable filters?
-      Resize that respects alpha test coverage
-         (Reference code: FloatImage::alphaTestCoverage and FloatImage::scaleAlphaToCoverage:
-         https://code.google.com/p/nvidia-texture-tools/source/browse/trunk/src/nvimage/FloatImage.cpp )
-*/
-
-#ifndef STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-#define STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-
-#ifdef _MSC_VER
-typedef unsigned char  stbir_uint8;
-typedef unsigned short stbir_uint16;
-typedef unsigned int   stbir_uint32;
-#else
-#include <stdint.h>
-typedef uint8_t  stbir_uint8;
-typedef uint16_t stbir_uint16;
-typedef uint32_t stbir_uint32;
-#endif
-
-#ifndef STBIRDEF
-#ifdef STB_IMAGE_RESIZE_STATIC
-#define STBIRDEF static
-#else
-#ifdef __cplusplus
-#define STBIRDEF extern "C"
-#else
-#define STBIRDEF extern
-#endif
-#endif
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Easy-to-use API:
-//
-//     * "input pixels" points to an array of image data with 'num_channels' channels (e.g. RGB=3, RGBA=4)
-//     * input_w is input image width (x-axis), input_h is input image height (y-axis)
-//     * stride is the offset between successive rows of image data in memory, in bytes. you can
-//       specify 0 to mean packed continuously in memory
-//     * alpha channel is treated identically to other channels.
-//     * colorspace is linear or sRGB as specified by function name
-//     * returned result is 1 for success or 0 in case of an error.
-//       #define STBIR_ASSERT() to trigger an assert on parameter validation errors.
-//     * Memory required grows approximately linearly with input and output size, but with
-//       discontinuities at input_w == output_w and input_h == output_h.
-//     * These functions use a "default" resampling filter defined at compile time. To change the filter,
-//       you can change the compile-time defaults by #defining STBIR_DEFAULT_FILTER_UPSAMPLE
-//       and STBIR_DEFAULT_FILTER_DOWNSAMPLE, or you can use the medium-complexity API.
-
-STBIRDEF int stbir_resize_uint8(     const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels);
-
-STBIRDEF int stbir_resize_float(     const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           float *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels);
-
-
-// The following functions interpret image data as gamma-corrected sRGB.
-// Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel,
-// or otherwise provide the index of the alpha channel. Flags value
-// of 0 will probably do the right thing if you're not sure what
-// the flags mean.
-
-#define STBIR_ALPHA_CHANNEL_NONE       -1
-
-// Set this flag if your texture has premultiplied alpha. Otherwise, stbir will
-// use alpha-weighted resampling (effectively premultiplying, resampling,
-// then unpremultiplying).
-#define STBIR_FLAG_ALPHA_PREMULTIPLIED    (1 << 0)
-// The specified alpha channel should be handled as gamma-corrected value even
-// when doing sRGB operations.
-#define STBIR_FLAG_ALPHA_USES_COLORSPACE  (1 << 1)
-
-STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels, int alpha_channel, int flags);
-
-
-typedef enum
-{
-    STBIR_EDGE_CLAMP   = 1,
-    STBIR_EDGE_REFLECT = 2,
-    STBIR_EDGE_WRAP    = 3,
-    STBIR_EDGE_ZERO    = 4,
-} stbir_edge;
-
-// This function adds the ability to specify how requests to sample off the edge of the image are handled.
-STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                                    unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                              int num_channels, int alpha_channel, int flags,
-                                              stbir_edge edge_wrap_mode);
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Medium-complexity API
-//
-// This extends the easy-to-use API as follows:
-//
-//     * Alpha-channel can be processed separately
-//       * If alpha_channel is not STBIR_ALPHA_CHANNEL_NONE
-//         * Alpha channel will not be gamma corrected (unless flags&STBIR_FLAG_GAMMA_CORRECT)
-//         * Filters will be weighted by alpha channel (unless flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)
-//     * Filter can be selected explicitly
-//     * uint16 image type
-//     * sRGB colorspace available for all types
-//     * context parameter for passing to STBIR_MALLOC
-
-typedef enum
-{
-    STBIR_FILTER_DEFAULT      = 0,  // use same filter type that easy-to-use API chooses
-    STBIR_FILTER_BOX          = 1,  // A trapezoid w/1-pixel wide ramps, same result as box for integer scale ratios
-    STBIR_FILTER_TRIANGLE     = 2,  // On upsampling, produces same results as bilinear texture filtering
-    STBIR_FILTER_CUBICBSPLINE = 3,  // The cubic b-spline (aka Mitchell-Netrevalli with B=1,C=0), gaussian-esque
-    STBIR_FILTER_CATMULLROM   = 4,  // An interpolating cubic spline
-    STBIR_FILTER_MITCHELL     = 5,  // Mitchell-Netrevalli filter with B=1/3, C=1/3
-} stbir_filter;
-
-typedef enum
-{
-    STBIR_COLORSPACE_LINEAR,
-    STBIR_COLORSPACE_SRGB,
-
-    STBIR_MAX_COLORSPACES,
-} stbir_colorspace;
-
-// The following functions are all identical except for the type of the image data
-
-STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                               unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels  , int input_w , int input_h , int input_stride_in_bytes,
-                                               stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-STBIRDEF int stbir_resize_float_generic( const float *input_pixels         , int input_w , int input_h , int input_stride_in_bytes,
-                                               float *output_pixels        , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context);
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Full-complexity API
-//
-// This extends the medium API as follows:
-//
-//       * uint32 image type
-//     * not typesafe
-//     * separate filter types for each axis
-//     * separate edge modes for each axis
-//     * can specify scale explicitly for subpixel correctness
-//     * can specify image source tile using texture coordinates
-
-typedef enum
-{
-    STBIR_TYPE_UINT8 ,
-    STBIR_TYPE_UINT16,
-    STBIR_TYPE_UINT32,
-    STBIR_TYPE_FLOAT ,
-
-    STBIR_MAX_TYPES
-} stbir_datatype;
-
-STBIRDEF int stbir_resize(         const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context);
-
-STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float x_scale, float y_scale,
-                                   float x_offset, float y_offset);
-
-STBIRDEF int stbir_resize_region(  const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float s0, float t0, float s1, float t1);
-// (s0, t0) & (s1, t1) are the top-left and bottom right corner (uv addressing style: [0, 1]x[0, 1]) of a region of the input image to use.
-
-//
-//
-////   end header file   /////////////////////////////////////////////////////
-#endif // STBIR_INCLUDE_STB_IMAGE_RESIZE_H
-
-
-
-
-
-#ifdef STB_IMAGE_RESIZE_IMPLEMENTATION
-
-#ifndef STBIR_ASSERT
-#include <assert.h>
-#define STBIR_ASSERT(x) assert(x)
-#endif
-
-// For memset
-#include <string.h>
-
-#include <math.h>
-
-#ifndef STBIR_MALLOC
-#include <stdlib.h>
-// use comma operator to evaluate c, to avoid "unused parameter" warnings
-#define STBIR_MALLOC(size,c) ((void)(c), malloc(size))
-#define STBIR_FREE(ptr,c)    ((void)(c), free(ptr))
-#endif
-
-#ifndef _MSC_VER
-#ifdef __cplusplus
-#define stbir__inline inline
-#else
-#define stbir__inline
-#endif
-#else
-#define stbir__inline __forceinline
-#endif
-
-
-// should produce compiler error if size is wrong
-typedef unsigned char stbir__validate_uint32[sizeof(stbir_uint32) == 4 ? 1 : -1];
-
-#ifdef _MSC_VER
-#define STBIR__NOTUSED(v)  (void)(v)
-#else
-#define STBIR__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-#define STBIR__ARRAY_SIZE(a) (sizeof((a))/sizeof((a)[0]))
-
-#ifndef STBIR_DEFAULT_FILTER_UPSAMPLE
-#define STBIR_DEFAULT_FILTER_UPSAMPLE    STBIR_FILTER_CATMULLROM
-#endif
-
-#ifndef STBIR_DEFAULT_FILTER_DOWNSAMPLE
-#define STBIR_DEFAULT_FILTER_DOWNSAMPLE  STBIR_FILTER_MITCHELL
-#endif
-
-#ifndef STBIR_PROGRESS_REPORT
-#define STBIR_PROGRESS_REPORT(float_0_to_1)
-#endif
-
-#ifndef STBIR_MAX_CHANNELS
-#define STBIR_MAX_CHANNELS 64
-#endif
-
-#if STBIR_MAX_CHANNELS > 65536
-#error "Too many channels; STBIR_MAX_CHANNELS must be no more than 65536."
-// because we store the indices in 16-bit variables
-#endif
-
-// This value is added to alpha just before premultiplication to avoid
-// zeroing out color values. It is equivalent to 2^-80. If you don't want
-// that behavior (it may interfere if you have floating point images with
-// very small alpha values) then you can define STBIR_NO_ALPHA_EPSILON to
-// disable it.
-#ifndef STBIR_ALPHA_EPSILON
-#define STBIR_ALPHA_EPSILON ((float)1 / (1 << 20) / (1 << 20) / (1 << 20) / (1 << 20))
-#endif
-
-
-
-#ifdef _MSC_VER
-#define STBIR__UNUSED_PARAM(v)  (void)(v)
-#else
-#define STBIR__UNUSED_PARAM(v)  (void)sizeof(v)
-#endif
-
-// must match stbir_datatype
-static unsigned char stbir__type_size[] = {
-    1, // STBIR_TYPE_UINT8
-    2, // STBIR_TYPE_UINT16
-    4, // STBIR_TYPE_UINT32
-    4, // STBIR_TYPE_FLOAT
-};
-
-// Kernel function centered at 0
-typedef float (stbir__kernel_fn)(float x, float scale);
-typedef float (stbir__support_fn)(float scale);
-
-typedef struct
-{
-    stbir__kernel_fn* kernel;
-    stbir__support_fn* support;
-} stbir__filter_info;
-
-// When upsampling, the contributors are which source pixels contribute.
-// When downsampling, the contributors are which destination pixels are contributed to.
-typedef struct
-{
-    int n0; // First contributing pixel
-    int n1; // Last contributing pixel
-} stbir__contributors;
-
-typedef struct
-{
-    const void* input_data;
-    int input_w;
-    int input_h;
-    int input_stride_bytes;
-
-    void* output_data;
-    int output_w;
-    int output_h;
-    int output_stride_bytes;
-
-    float s0, t0, s1, t1;
-
-    float horizontal_shift; // Units: output pixels
-    float vertical_shift;   // Units: output pixels
-    float horizontal_scale;
-    float vertical_scale;
-
-    int channels;
-    int alpha_channel;
-    stbir_uint32 flags;
-    stbir_datatype type;
-    stbir_filter horizontal_filter;
-    stbir_filter vertical_filter;
-    stbir_edge edge_horizontal;
-    stbir_edge edge_vertical;
-    stbir_colorspace colorspace;
-
-    stbir__contributors* horizontal_contributors;
-    float* horizontal_coefficients;
-
-    stbir__contributors* vertical_contributors;
-    float* vertical_coefficients;
-
-    int decode_buffer_pixels;
-    float* decode_buffer;
-
-    float* horizontal_buffer;
-
-    // cache these because ceil/floor are inexplicably showing up in profile
-    int horizontal_coefficient_width;
-    int vertical_coefficient_width;
-    int horizontal_filter_pixel_width;
-    int vertical_filter_pixel_width;
-    int horizontal_filter_pixel_margin;
-    int vertical_filter_pixel_margin;
-    int horizontal_num_contributors;
-    int vertical_num_contributors;
-
-    int ring_buffer_length_bytes;   // The length of an individual entry in the ring buffer. The total number of ring buffers is stbir__get_filter_pixel_width(filter)
-    int ring_buffer_num_entries;    // Total number of entries in the ring buffer.
-    int ring_buffer_first_scanline;
-    int ring_buffer_last_scanline;
-    int ring_buffer_begin_index;    // first_scanline is at this index in the ring buffer
-    float* ring_buffer;
-
-    float* encode_buffer; // A temporary buffer to store floats so we don't lose precision while we do multiply-adds.
-
-    int horizontal_contributors_size;
-    int horizontal_coefficients_size;
-    int vertical_contributors_size;
-    int vertical_coefficients_size;
-    int decode_buffer_size;
-    int horizontal_buffer_size;
-    int ring_buffer_size;
-    int encode_buffer_size;
-} stbir__info;
-
-
-static const float stbir__max_uint8_as_float  = 255.0f;
-static const float stbir__max_uint16_as_float = 65535.0f;
-static const double stbir__max_uint32_as_float = 4294967295.0;
-
-
-static stbir__inline int stbir__min(int a, int b)
-{
-    return a < b ? a : b;
-}
-
-static stbir__inline float stbir__saturate(float x)
-{
-    if (x < 0)
-        return 0;
-
-    if (x > 1)
-        return 1;
-
-    return x;
-}
-
-#ifdef STBIR_SATURATE_INT
-static stbir__inline stbir_uint8 stbir__saturate8(int x)
-{
-    if ((unsigned int) x <= 255)
-        return x;
-
-    if (x < 0)
-        return 0;
-
-    return 255;
-}
-
-static stbir__inline stbir_uint16 stbir__saturate16(int x)
-{
-    if ((unsigned int) x <= 65535)
-        return x;
-
-    if (x < 0)
-        return 0;
-
-    return 65535;
-}
-#endif
-
-static float stbir__srgb_uchar_to_linear_float[256] = {
-    0.000000f, 0.000304f, 0.000607f, 0.000911f, 0.001214f, 0.001518f, 0.001821f, 0.002125f, 0.002428f, 0.002732f, 0.003035f,
-    0.003347f, 0.003677f, 0.004025f, 0.004391f, 0.004777f, 0.005182f, 0.005605f, 0.006049f, 0.006512f, 0.006995f, 0.007499f,
-    0.008023f, 0.008568f, 0.009134f, 0.009721f, 0.010330f, 0.010960f, 0.011612f, 0.012286f, 0.012983f, 0.013702f, 0.014444f,
-    0.015209f, 0.015996f, 0.016807f, 0.017642f, 0.018500f, 0.019382f, 0.020289f, 0.021219f, 0.022174f, 0.023153f, 0.024158f,
-    0.025187f, 0.026241f, 0.027321f, 0.028426f, 0.029557f, 0.030713f, 0.031896f, 0.033105f, 0.034340f, 0.035601f, 0.036889f,
-    0.038204f, 0.039546f, 0.040915f, 0.042311f, 0.043735f, 0.045186f, 0.046665f, 0.048172f, 0.049707f, 0.051269f, 0.052861f,
-    0.054480f, 0.056128f, 0.057805f, 0.059511f, 0.061246f, 0.063010f, 0.064803f, 0.066626f, 0.068478f, 0.070360f, 0.072272f,
-    0.074214f, 0.076185f, 0.078187f, 0.080220f, 0.082283f, 0.084376f, 0.086500f, 0.088656f, 0.090842f, 0.093059f, 0.095307f,
-    0.097587f, 0.099899f, 0.102242f, 0.104616f, 0.107023f, 0.109462f, 0.111932f, 0.114435f, 0.116971f, 0.119538f, 0.122139f,
-    0.124772f, 0.127438f, 0.130136f, 0.132868f, 0.135633f, 0.138432f, 0.141263f, 0.144128f, 0.147027f, 0.149960f, 0.152926f,
-    0.155926f, 0.158961f, 0.162029f, 0.165132f, 0.168269f, 0.171441f, 0.174647f, 0.177888f, 0.181164f, 0.184475f, 0.187821f,
-    0.191202f, 0.194618f, 0.198069f, 0.201556f, 0.205079f, 0.208637f, 0.212231f, 0.215861f, 0.219526f, 0.223228f, 0.226966f,
-    0.230740f, 0.234551f, 0.238398f, 0.242281f, 0.246201f, 0.250158f, 0.254152f, 0.258183f, 0.262251f, 0.266356f, 0.270498f,
-    0.274677f, 0.278894f, 0.283149f, 0.287441f, 0.291771f, 0.296138f, 0.300544f, 0.304987f, 0.309469f, 0.313989f, 0.318547f,
-    0.323143f, 0.327778f, 0.332452f, 0.337164f, 0.341914f, 0.346704f, 0.351533f, 0.356400f, 0.361307f, 0.366253f, 0.371238f,
-    0.376262f, 0.381326f, 0.386430f, 0.391573f, 0.396755f, 0.401978f, 0.407240f, 0.412543f, 0.417885f, 0.423268f, 0.428691f,
-    0.434154f, 0.439657f, 0.445201f, 0.450786f, 0.456411f, 0.462077f, 0.467784f, 0.473532f, 0.479320f, 0.485150f, 0.491021f,
-    0.496933f, 0.502887f, 0.508881f, 0.514918f, 0.520996f, 0.527115f, 0.533276f, 0.539480f, 0.545725f, 0.552011f, 0.558340f,
-    0.564712f, 0.571125f, 0.577581f, 0.584078f, 0.590619f, 0.597202f, 0.603827f, 0.610496f, 0.617207f, 0.623960f, 0.630757f,
-    0.637597f, 0.644480f, 0.651406f, 0.658375f, 0.665387f, 0.672443f, 0.679543f, 0.686685f, 0.693872f, 0.701102f, 0.708376f,
-    0.715694f, 0.723055f, 0.730461f, 0.737911f, 0.745404f, 0.752942f, 0.760525f, 0.768151f, 0.775822f, 0.783538f, 0.791298f,
-    0.799103f, 0.806952f, 0.814847f, 0.822786f, 0.830770f, 0.838799f, 0.846873f, 0.854993f, 0.863157f, 0.871367f, 0.879622f,
-    0.887923f, 0.896269f, 0.904661f, 0.913099f, 0.921582f, 0.930111f, 0.938686f, 0.947307f, 0.955974f, 0.964686f, 0.973445f,
-    0.982251f, 0.991102f, 1.0f
-};
-
-static float stbir__srgb_to_linear(float f)
-{
-    if (f <= 0.04045f)
-        return f / 12.92f;
-    else
-        return (float)pow((f + 0.055f) / 1.055f, 2.4f);
-}
-
-static float stbir__linear_to_srgb(float f)
-{
-    if (f <= 0.0031308f)
-        return f * 12.92f;
-    else
-        return 1.055f * (float)pow(f, 1 / 2.4f) - 0.055f;
-}
-
-#ifndef STBIR_NON_IEEE_FLOAT
-// From https://gist.github.com/rygorous/2203834
-
-typedef union
-{
-    stbir_uint32 u;
-    float f;
-} stbir__FP32;
-
-static const stbir_uint32 fp32_to_srgb8_tab4[104] = {
-    0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d,
-    0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a,
-    0x010e0033, 0x01280033, 0x01410033, 0x015b0033, 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033,
-    0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067,
-    0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5,
-    0x06970158, 0x07420142, 0x07e30130, 0x087b0120, 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2,
-    0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143,
-    0x11070264, 0x1238023e, 0x1357021d, 0x14660201, 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af,
-    0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240,
-    0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300,
-    0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401,
-    0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559,
-    0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723,
-};
-
-static stbir_uint8 stbir__linear_to_srgb_uchar(float in)
-{
-    static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps
-    static const stbir__FP32 minval = { (127-13) << 23 };
-    stbir_uint32 tab,bias,scale,t;
-    stbir__FP32 f;
-
-    // Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively.
-    // The tests are carefully written so that NaNs map to 0, same as in the reference
-    // implementation.
-    if (!(in > minval.f)) // written this way to catch NaNs
-        in = minval.f;
-    if (in > almostone.f)
-        in = almostone.f;
-
-    // Do the table lookup and unpack bias, scale
-    f.f = in;
-    tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20];
-    bias = (tab >> 16) << 9;
-    scale = tab & 0xffff;
-
-    // Grab next-highest mantissa bits and perform linear interpolation
-    t = (f.u >> 12) & 0xff;
-    return (unsigned char) ((bias + scale*t) >> 16);
-}
-
-#else
-// sRGB transition values, scaled by 1<<28
-static int stbir__srgb_offset_to_linear_scaled[256] =
-{
-            0,     40738,    122216,    203693,    285170,    366648,    448125,    529603,
-       611080,    692557,    774035,    855852,    942009,   1033024,   1128971,   1229926,
-      1335959,   1447142,   1563542,   1685229,   1812268,   1944725,   2082664,   2226148,
-      2375238,   2529996,   2690481,   2856753,   3028870,   3206888,   3390865,   3580856,
-      3776916,   3979100,   4187460,   4402049,   4622919,   4850123,   5083710,   5323731,
-      5570236,   5823273,   6082892,   6349140,   6622065,   6901714,   7188133,   7481369,
-      7781466,   8088471,   8402427,   8723380,   9051372,   9386448,   9728650,  10078021,
-     10434603,  10798439,  11169569,  11548036,  11933879,  12327139,  12727857,  13136073,
-     13551826,  13975156,  14406100,  14844697,  15290987,  15745007,  16206795,  16676389,
-     17153826,  17639142,  18132374,  18633560,  19142734,  19659934,  20185196,  20718552,
-     21260042,  21809696,  22367554,  22933648,  23508010,  24090680,  24681686,  25281066,
-     25888850,  26505076,  27129772,  27762974,  28404716,  29055026,  29713942,  30381490,
-     31057708,  31742624,  32436272,  33138682,  33849884,  34569912,  35298800,  36036568,
-     36783260,  37538896,  38303512,  39077136,  39859796,  40651528,  41452360,  42262316,
-     43081432,  43909732,  44747252,  45594016,  46450052,  47315392,  48190064,  49074096,
-     49967516,  50870356,  51782636,  52704392,  53635648,  54576432,  55526772,  56486700,
-     57456236,  58435408,  59424248,  60422780,  61431036,  62449032,  63476804,  64514376,
-     65561776,  66619028,  67686160,  68763192,  69850160,  70947088,  72053992,  73170912,
-     74297864,  75434880,  76581976,  77739184,  78906536,  80084040,  81271736,  82469648,
-     83677792,  84896192,  86124888,  87363888,  88613232,  89872928,  91143016,  92423512,
-     93714432,  95015816,  96327688,  97650056,  98982952, 100326408, 101680440, 103045072,
-    104420320, 105806224, 107202800, 108610064, 110028048, 111456776, 112896264, 114346544,
-    115807632, 117279552, 118762328, 120255976, 121760536, 123276016, 124802440, 126339832,
-    127888216, 129447616, 131018048, 132599544, 134192112, 135795792, 137410592, 139036528,
-    140673648, 142321952, 143981456, 145652208, 147334208, 149027488, 150732064, 152447968,
-    154175200, 155913792, 157663776, 159425168, 161197984, 162982240, 164777968, 166585184,
-    168403904, 170234160, 172075968, 173929344, 175794320, 177670896, 179559120, 181458992,
-    183370528, 185293776, 187228736, 189175424, 191133888, 193104112, 195086128, 197079968,
-    199085648, 201103184, 203132592, 205173888, 207227120, 209292272, 211369392, 213458480,
-    215559568, 217672656, 219797792, 221934976, 224084240, 226245600, 228419056, 230604656,
-    232802400, 235012320, 237234432, 239468736, 241715280, 243974080, 246245120, 248528464,
-    250824112, 253132064, 255452368, 257785040, 260130080, 262487520, 264857376, 267239664,
-};
-
-static stbir_uint8 stbir__linear_to_srgb_uchar(float f)
-{
-    int x = (int) (f * (1 << 28)); // has headroom so you don't need to clamp
-    int v = 0;
-    int i;
-
-    // Refine the guess with a short binary search.
-    i = v + 128; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  64; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  32; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +  16; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   8; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   4; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   2; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-    i = v +   1; if (x >= stbir__srgb_offset_to_linear_scaled[i]) v = i;
-
-    return (stbir_uint8) v;
-}
-#endif
-
-static float stbir__filter_trapezoid(float x, float scale)
-{
-    float halfscale = scale / 2;
-    float t = 0.5f + halfscale;
-    STBIR_ASSERT(scale <= 1);
-
-    x = (float)fabs(x);
-
-    if (x >= t)
-        return 0;
-    else
-    {
-        float r = 0.5f - halfscale;
-        if (x <= r)
-            return 1;
-        else
-            return (t - x) / scale;
-    }
-}
-
-static float stbir__support_trapezoid(float scale)
-{
-    STBIR_ASSERT(scale <= 1);
-    return 0.5f + scale / 2;
-}
-
-static float stbir__filter_triangle(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x <= 1.0f)
-        return 1 - x;
-    else
-        return 0;
-}
-
-static float stbir__filter_cubic(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return (4 + x*x*(3*x - 6))/6;
-    else if (x < 2.0f)
-        return (8 + x*(-12 + x*(6 - x)))/6;
-
-    return (0.0f);
-}
-
-static float stbir__filter_catmullrom(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return 1 - x*x*(2.5f - 1.5f*x);
-    else if (x < 2.0f)
-        return 2 - x*(4 + x*(0.5f*x - 2.5f));
-
-    return (0.0f);
-}
-
-static float stbir__filter_mitchell(float x, float s)
-{
-    STBIR__UNUSED_PARAM(s);
-
-    x = (float)fabs(x);
-
-    if (x < 1.0f)
-        return (16 + x*x*(21 * x - 36))/18;
-    else if (x < 2.0f)
-        return (32 + x*(-60 + x*(36 - 7*x)))/18;
-
-    return (0.0f);
-}
-
-static float stbir__support_zero(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 0;
-}
-
-static float stbir__support_one(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 1;
-}
-
-static float stbir__support_two(float s)
-{
-    STBIR__UNUSED_PARAM(s);
-    return 2;
-}
-
-static stbir__filter_info stbir__filter_info_table[] = {
-        { NULL,                     stbir__support_zero },
-        { stbir__filter_trapezoid,  stbir__support_trapezoid },
-        { stbir__filter_triangle,   stbir__support_one },
-        { stbir__filter_cubic,      stbir__support_two },
-        { stbir__filter_catmullrom, stbir__support_two },
-        { stbir__filter_mitchell,   stbir__support_two },
-};
-
-stbir__inline static int stbir__use_upsampling(float ratio)
-{
-    return ratio > 1;
-}
-
-stbir__inline static int stbir__use_width_upsampling(stbir__info* stbir_info)
-{
-    return stbir__use_upsampling(stbir_info->horizontal_scale);
-}
-
-stbir__inline static int stbir__use_height_upsampling(stbir__info* stbir_info)
-{
-    return stbir__use_upsampling(stbir_info->vertical_scale);
-}
-
-// This is the maximum number of input samples that can affect an output sample
-// with the given filter
-static int stbir__get_filter_pixel_width(stbir_filter filter, float scale)
-{
-    STBIR_ASSERT(filter != 0);
-    STBIR_ASSERT(filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-
-    if (stbir__use_upsampling(scale))
-        return (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2);
-    else
-        return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2 / scale);
-}
-
-// This is how much to expand buffers to account for filters seeking outside
-// the image boundaries.
-static int stbir__get_filter_pixel_margin(stbir_filter filter, float scale)
-{
-    return stbir__get_filter_pixel_width(filter, scale) / 2;
-}
-
-static int stbir__get_coefficient_width(stbir_filter filter, float scale)
-{
-    if (stbir__use_upsampling(scale))
-        return (int)ceil(stbir__filter_info_table[filter].support(1 / scale) * 2);
-    else
-        return (int)ceil(stbir__filter_info_table[filter].support(scale) * 2);
-}
-
-static int stbir__get_contributors(float scale, stbir_filter filter, int input_size, int output_size)
-{
-    if (stbir__use_upsampling(scale))
-        return output_size;
-    else
-        return (input_size + stbir__get_filter_pixel_margin(filter, scale) * 2);
-}
-
-static int stbir__get_total_horizontal_coefficients(stbir__info* info)
-{
-    return info->horizontal_num_contributors
-         * stbir__get_coefficient_width      (info->horizontal_filter, info->horizontal_scale);
-}
-
-static int stbir__get_total_vertical_coefficients(stbir__info* info)
-{
-    return info->vertical_num_contributors
-         * stbir__get_coefficient_width      (info->vertical_filter, info->vertical_scale);
-}
-
-static stbir__contributors* stbir__get_contributor(stbir__contributors* contributors, int n)
-{
-    return &contributors[n];
-}
-
-// For perf reasons this code is duplicated in stbir__resample_horizontal_upsample/downsample,
-// if you change it here change it there too.
-static float* stbir__get_coefficient(float* coefficients, stbir_filter filter, float scale, int n, int c)
-{
-    int width = stbir__get_coefficient_width(filter, scale);
-    return &coefficients[width*n + c];
-}
-
-static int stbir__edge_wrap_slow(stbir_edge edge, int n, int max)
-{
-    switch (edge)
-    {
-    case STBIR_EDGE_ZERO:
-        return 0; // we'll decode the wrong pixel here, and then overwrite with 0s later
-
-    case STBIR_EDGE_CLAMP:
-        if (n < 0)
-            return 0;
-
-        if (n >= max)
-            return max - 1;
-
-        return n; // NOTREACHED
-
-    case STBIR_EDGE_REFLECT:
-    {
-        if (n < 0)
-        {
-            if (n < max)
-                return -n;
-            else
-                return max - 1;
-        }
-
-        if (n >= max)
-        {
-            int max2 = max * 2;
-            if (n >= max2)
-                return 0;
-            else
-                return max2 - n - 1;
-        }
-
-        return n; // NOTREACHED
-    }
-
-    case STBIR_EDGE_WRAP:
-        if (n >= 0)
-            return (n % max);
-        else
-        {
-            int m = (-n) % max;
-
-            if (m != 0)
-                m = max - m;
-
-            return (m);
-        }
-        // NOTREACHED
-
-    default:
-        STBIR_ASSERT(!"Unimplemented edge type");
-        return 0;
-    }
-}
-
-stbir__inline static int stbir__edge_wrap(stbir_edge edge, int n, int max)
-{
-    // avoid per-pixel switch
-    if (n >= 0 && n < max)
-        return n;
-    return stbir__edge_wrap_slow(edge, n, max);
-}
-
-// What input pixels contribute to this output pixel?
-static void stbir__calculate_sample_range_upsample(int n, float out_filter_radius, float scale_ratio, float out_shift, int* in_first_pixel, int* in_last_pixel, float* in_center_of_out)
-{
-    float out_pixel_center = (float)n + 0.5f;
-    float out_pixel_influence_lowerbound = out_pixel_center - out_filter_radius;
-    float out_pixel_influence_upperbound = out_pixel_center + out_filter_radius;
-
-    float in_pixel_influence_lowerbound = (out_pixel_influence_lowerbound + out_shift) / scale_ratio;
-    float in_pixel_influence_upperbound = (out_pixel_influence_upperbound + out_shift) / scale_ratio;
-
-    *in_center_of_out = (out_pixel_center + out_shift) / scale_ratio;
-    *in_first_pixel = (int)(floor(in_pixel_influence_lowerbound + 0.5));
-    *in_last_pixel = (int)(floor(in_pixel_influence_upperbound - 0.5));
-}
-
-// What output pixels does this input pixel contribute to?
-static void stbir__calculate_sample_range_downsample(int n, float in_pixels_radius, float scale_ratio, float out_shift, int* out_first_pixel, int* out_last_pixel, float* out_center_of_in)
-{
-    float in_pixel_center = (float)n + 0.5f;
-    float in_pixel_influence_lowerbound = in_pixel_center - in_pixels_radius;
-    float in_pixel_influence_upperbound = in_pixel_center + in_pixels_radius;
-
-    float out_pixel_influence_lowerbound = in_pixel_influence_lowerbound * scale_ratio - out_shift;
-    float out_pixel_influence_upperbound = in_pixel_influence_upperbound * scale_ratio - out_shift;
-
-    *out_center_of_in = in_pixel_center * scale_ratio - out_shift;
-    *out_first_pixel = (int)(floor(out_pixel_influence_lowerbound + 0.5));
-    *out_last_pixel = (int)(floor(out_pixel_influence_upperbound - 0.5));
-}
-
-static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group)
-{
-    int i;
-    float total_filter = 0;
-    float filter_scale;
-
-    STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
-
-    contributor->n0 = in_first_pixel;
-    contributor->n1 = in_last_pixel;
-
-    STBIR_ASSERT(contributor->n1 >= contributor->n0);
-
-    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
-    {
-        float in_pixel_center = (float)(i + in_first_pixel) + 0.5f;
-        coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale);
-
-        // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.)
-        if (i == 0 && !coefficient_group[i])
-        {
-            contributor->n0 = ++in_first_pixel;
-            i--;
-            continue;
-        }
-
-        total_filter += coefficient_group[i];
-    }
-
-    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0);
-
-    STBIR_ASSERT(total_filter > 0.9);
-    STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off.
-
-    // Make sure the sum of all coefficients is 1.
-    filter_scale = 1 / total_filter;
-
-    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
-        coefficient_group[i] *= filter_scale;
-
-    for (i = in_last_pixel - in_first_pixel; i >= 0; i--)
-    {
-        if (coefficient_group[i])
-            break;
-
-        // This line has no weight. We can skip it.
-        contributor->n1 = contributor->n0 + i - 1;
-    }
-}
-
-static void stbir__calculate_coefficients_downsample(stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group)
-{
-    int i;
-
-     STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.
-
-    contributor->n0 = out_first_pixel;
-    contributor->n1 = out_last_pixel;
-
-    STBIR_ASSERT(contributor->n1 >= contributor->n0);
-
-    for (i = 0; i <= out_last_pixel - out_first_pixel; i++)
-    {
-        float out_pixel_center = (float)(i + out_first_pixel) + 0.5f;
-        float x = out_pixel_center - out_center_of_in;
-        coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio;
-    }
-
-    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0);
-
-    for (i = out_last_pixel - out_first_pixel; i >= 0; i--)
-    {
-        if (coefficient_group[i])
-            break;
-
-        // This line has no weight. We can skip it.
-        contributor->n1 = contributor->n0 + i - 1;
-    }
-}
-
-static void stbir__normalize_downsample_coefficients(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, int input_size, int output_size)
-{
-    int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size);
-    int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio);
-    int i, j;
-    int skip;
-
-    for (i = 0; i < output_size; i++)
-    {
-        float scale;
-        float total = 0;
-
-        for (j = 0; j < num_contributors; j++)
-        {
-            if (i >= contributors[j].n0 && i <= contributors[j].n1)
-            {
-                float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0);
-                total += coefficient;
-            }
-            else if (i < contributors[j].n0)
-                break;
-        }
-
-        STBIR_ASSERT(total > 0.9f);
-        STBIR_ASSERT(total < 1.1f);
-
-        scale = 1 / total;
-
-        for (j = 0; j < num_contributors; j++)
-        {
-            if (i >= contributors[j].n0 && i <= contributors[j].n1)
-                *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale;
-            else if (i < contributors[j].n0)
-                break;
-        }
-    }
-
-    // Optimize: Skip zero coefficients and contributions outside of image bounds.
-    // Do this after normalizing because normalization depends on the n0/n1 values.
-    for (j = 0; j < num_contributors; j++)
-    {
-        int range, max, width;
-
-        skip = 0;
-        while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0)
-            skip++;
-
-        contributors[j].n0 += skip;
-
-        while (contributors[j].n0 < 0)
-        {
-            contributors[j].n0++;
-            skip++;
-        }
-
-        range = contributors[j].n1 - contributors[j].n0 + 1;
-        max = stbir__min(num_coefficients, range);
-
-        width = stbir__get_coefficient_width(filter, scale_ratio);
-        for (i = 0; i < max; i++)
-        {
-            if (i + skip >= width)
-                break;
-
-            *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip);
-        }
-
-        continue;
-    }
-
-    // Using min to avoid writing into invalid pixels.
-    for (i = 0; i < num_contributors; i++)
-        contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1);
-}
-
-// Each scan line uses the same kernel values so we should calculate the kernel
-// values once and then we can use them for every scan line.
-static void stbir__calculate_filters(stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size)
-{
-    int n;
-    int total_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size);
-
-    if (stbir__use_upsampling(scale_ratio))
-    {
-        float out_pixels_radius = stbir__filter_info_table[filter].support(1 / scale_ratio) * scale_ratio;
-
-        // Looping through out pixels
-        for (n = 0; n < total_contributors; n++)
-        {
-            float in_center_of_out; // Center of the current out pixel in the in pixel space
-            int in_first_pixel, in_last_pixel;
-
-            stbir__calculate_sample_range_upsample(n, out_pixels_radius, scale_ratio, shift, &in_first_pixel, &in_last_pixel, &in_center_of_out);
-
-            stbir__calculate_coefficients_upsample(filter, scale_ratio, in_first_pixel, in_last_pixel, in_center_of_out, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0));
-        }
-    }
-    else
-    {
-        float in_pixels_radius = stbir__filter_info_table[filter].support(scale_ratio) / scale_ratio;
-
-        // Looping through in pixels
-        for (n = 0; n < total_contributors; n++)
-        {
-            float out_center_of_in; // Center of the current out pixel in the in pixel space
-            int out_first_pixel, out_last_pixel;
-            int n_adjusted = n - stbir__get_filter_pixel_margin(filter, scale_ratio);
-
-            stbir__calculate_sample_range_downsample(n_adjusted, in_pixels_radius, scale_ratio, shift, &out_first_pixel, &out_last_pixel, &out_center_of_in);
-
-            stbir__calculate_coefficients_downsample(filter, scale_ratio, out_first_pixel, out_last_pixel, out_center_of_in, stbir__get_contributor(contributors, n), stbir__get_coefficient(coefficients, filter, scale_ratio, n, 0));
-        }
-
-        stbir__normalize_downsample_coefficients(contributors, coefficients, filter, scale_ratio, input_size, output_size);
-    }
-}
-
-static float* stbir__get_decode_buffer(stbir__info* stbir_info)
-{
-    // The 0 index of the decode buffer starts after the margin. This makes
-    // it okay to use negative indexes on the decode buffer.
-    return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels];
-}
-
-#define STBIR__DECODE(type, colorspace) ((int)(type) * (STBIR_MAX_COLORSPACES) + (int)(colorspace))
-
-static void stbir__decode_scanline(stbir__info* stbir_info, int n)
-{
-    int c;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int input_w = stbir_info->input_w;
-    size_t input_stride_bytes = stbir_info->input_stride_bytes;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir_edge edge_horizontal = stbir_info->edge_horizontal;
-    stbir_edge edge_vertical = stbir_info->edge_vertical;
-    size_t in_buffer_row_offset = stbir__edge_wrap(edge_vertical, n, stbir_info->input_h) * input_stride_bytes;
-    const void* input_data = (char *) stbir_info->input_data + in_buffer_row_offset;
-    int max_x = input_w + stbir_info->horizontal_filter_pixel_margin;
-    int decode = STBIR__DECODE(type, colorspace);
-
-    int x = -stbir_info->horizontal_filter_pixel_margin;
-
-    // special handling for STBIR_EDGE_ZERO because it needs to return an item that doesn't appear in the input,
-    // and we want to avoid paying overhead on every pixel if not STBIR_EDGE_ZERO
-    if (edge_vertical == STBIR_EDGE_ZERO && (n < 0 || n >= stbir_info->input_h))
-    {
-        for (; x < max_x; x++)
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        return;
-    }
-
-    switch (decode)
-    {
-    case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((float)((const unsigned char*)input_data)[input_pixel_index + c]) / stbir__max_uint8_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_uchar_to_linear_float[((const unsigned char*)input_data)[input_pixel_index + c]];
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned char*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint8_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((float)((const unsigned short*)input_data)[input_pixel_index + c]) / stbir__max_uint16_as_float);
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((float)((const unsigned short*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint16_as_float;
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float);
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear((float)(((double)((const unsigned int*)input_data)[input_pixel_index + c]) / stbir__max_uint32_as_float));
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = (float)(((double)((const unsigned int*)input_data)[input_pixel_index + alpha_channel]) / stbir__max_uint32_as_float);
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = ((const float*)input_data)[input_pixel_index + c];
-        }
-        break;
-
-    case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB):
-        for (; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-            int input_pixel_index = stbir__edge_wrap(edge_horizontal, x, input_w) * channels;
-            for (c = 0; c < channels; c++)
-                decode_buffer[decode_pixel_index + c] = stbir__srgb_to_linear(((const float*)input_data)[input_pixel_index + c]);
-
-            if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                decode_buffer[decode_pixel_index + alpha_channel] = ((const float*)input_data)[input_pixel_index + alpha_channel];
-        }
-
-        break;
-
-    default:
-        STBIR_ASSERT(!"Unknown type/colorspace/channels combination.");
-        break;
-    }
-
-    if (!(stbir_info->flags & STBIR_FLAG_ALPHA_PREMULTIPLIED))
-    {
-        for (x = -stbir_info->horizontal_filter_pixel_margin; x < max_x; x++)
-        {
-            int decode_pixel_index = x * channels;
-
-            // If the alpha value is 0 it will clobber the color values. Make sure it's not.
-            float alpha = decode_buffer[decode_pixel_index + alpha_channel];
-#ifndef STBIR_NO_ALPHA_EPSILON
-            if (stbir_info->type != STBIR_TYPE_FLOAT) {
-                alpha += STBIR_ALPHA_EPSILON;
-                decode_buffer[decode_pixel_index + alpha_channel] = alpha;
-            }
-#endif
-            for (c = 0; c < channels; c++)
-            {
-                if (c == alpha_channel)
-                    continue;
-
-                decode_buffer[decode_pixel_index + c] *= alpha;
-            }
-        }
-    }
-
-    if (edge_horizontal == STBIR_EDGE_ZERO)
-    {
-        for (x = -stbir_info->horizontal_filter_pixel_margin; x < 0; x++)
-        {
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        }
-        for (x = input_w; x < max_x; x++)
-        {
-            for (c = 0; c < channels; c++)
-                decode_buffer[x*channels + c] = 0;
-        }
-    }
-}
-
-static float* stbir__get_ring_buffer_entry(float* ring_buffer, int index, int ring_buffer_length)
-{
-    return &ring_buffer[index * ring_buffer_length];
-}
-
-static float* stbir__add_empty_ring_buffer_entry(stbir__info* stbir_info, int n)
-{
-    int ring_buffer_index;
-    float* ring_buffer;
-
-    stbir_info->ring_buffer_last_scanline = n;
-
-    if (stbir_info->ring_buffer_begin_index < 0)
-    {
-        ring_buffer_index = stbir_info->ring_buffer_begin_index = 0;
-        stbir_info->ring_buffer_first_scanline = n;
-    }
-    else
-    {
-        ring_buffer_index = (stbir_info->ring_buffer_begin_index + (stbir_info->ring_buffer_last_scanline - stbir_info->ring_buffer_first_scanline)) % stbir_info->ring_buffer_num_entries;
-        STBIR_ASSERT(ring_buffer_index != stbir_info->ring_buffer_begin_index);
-    }
-
-    ring_buffer = stbir__get_ring_buffer_entry(stbir_info->ring_buffer, ring_buffer_index, stbir_info->ring_buffer_length_bytes / sizeof(float));
-    memset(ring_buffer, 0, stbir_info->ring_buffer_length_bytes);
-
-    return ring_buffer;
-}
-
-
-static void stbir__resample_horizontal_upsample(stbir__info* stbir_info, float* output_buffer)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    int channels = stbir_info->channels;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors;
-    float* horizontal_coefficients = stbir_info->horizontal_coefficients;
-    int coefficient_width = stbir_info->horizontal_coefficient_width;
-
-    for (x = 0; x < output_w; x++)
-    {
-        int n0 = horizontal_contributors[x].n0;
-        int n1 = horizontal_contributors[x].n1;
-
-        int out_pixel_index = x * channels;
-        int coefficient_group = coefficient_width * x;
-        int coefficient_counter = 0;
-
-        STBIR_ASSERT(n1 >= n0);
-        STBIR_ASSERT(n0 >= -stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n1 >= -stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n0 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
-        STBIR_ASSERT(n1 < stbir_info->input_w + stbir_info->horizontal_filter_pixel_margin);
-
-        switch (channels) {
-            case 1:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 1;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                }
-                break;
-            case 2:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 2;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                }
-                break;
-            case 3:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 3;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                }
-                break;
-            case 4:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * 4;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                    output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient;
-                }
-                break;
-            default:
-                for (k = n0; k <= n1; k++)
-                {
-                    int in_pixel_index = k * channels;
-                    float coefficient = horizontal_coefficients[coefficient_group + coefficient_counter++];
-                    int c;
-                    STBIR_ASSERT(coefficient != 0);
-                    for (c = 0; c < channels; c++)
-                        output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient;
-                }
-                break;
-        }
-    }
-}
-
-static void stbir__resample_horizontal_downsample(stbir__info* stbir_info, float* output_buffer)
-{
-    int x, k;
-    int input_w = stbir_info->input_w;
-    int channels = stbir_info->channels;
-    float* decode_buffer = stbir__get_decode_buffer(stbir_info);
-    stbir__contributors* horizontal_contributors = stbir_info->horizontal_contributors;
-    float* horizontal_coefficients = stbir_info->horizontal_coefficients;
-    int coefficient_width = stbir_info->horizontal_coefficient_width;
-    int filter_pixel_margin = stbir_info->horizontal_filter_pixel_margin;
-    int max_x = input_w + filter_pixel_margin * 2;
-
-    STBIR_ASSERT(!stbir__use_width_upsampling(stbir_info));
-
-    switch (channels) {
-        case 1:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 1;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 1;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                }
-            }
-            break;
-
-        case 2:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 2;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 2;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                }
-            }
-            break;
-
-        case 3:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 3;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 3;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                }
-            }
-            break;
-
-        case 4:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * 4;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int out_pixel_index = k * 4;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    output_buffer[out_pixel_index + 0] += decode_buffer[in_pixel_index + 0] * coefficient;
-                    output_buffer[out_pixel_index + 1] += decode_buffer[in_pixel_index + 1] * coefficient;
-                    output_buffer[out_pixel_index + 2] += decode_buffer[in_pixel_index + 2] * coefficient;
-                    output_buffer[out_pixel_index + 3] += decode_buffer[in_pixel_index + 3] * coefficient;
-                }
-            }
-            break;
-
-        default:
-            for (x = 0; x < max_x; x++)
-            {
-                int n0 = horizontal_contributors[x].n0;
-                int n1 = horizontal_contributors[x].n1;
-
-                int in_x = x - filter_pixel_margin;
-                int in_pixel_index = in_x * channels;
-                int max_n = n1;
-                int coefficient_group = coefficient_width * x;
-
-                for (k = n0; k <= max_n; k++)
-                {
-                    int c;
-                    int out_pixel_index = k * channels;
-                    float coefficient = horizontal_coefficients[coefficient_group + k - n0];
-                    STBIR_ASSERT(coefficient != 0);
-                    for (c = 0; c < channels; c++)
-                        output_buffer[out_pixel_index + c] += decode_buffer[in_pixel_index + c] * coefficient;
-                }
-            }
-            break;
-    }
-}
-
-static void stbir__decode_and_resample_upsample(stbir__info* stbir_info, int n)
-{
-    // Decode the nth scanline from the source image into the decode buffer.
-    stbir__decode_scanline(stbir_info, n);
-
-    // Now resample it into the ring buffer.
-    if (stbir__use_width_upsampling(stbir_info))
-        stbir__resample_horizontal_upsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n));
-    else
-        stbir__resample_horizontal_downsample(stbir_info, stbir__add_empty_ring_buffer_entry(stbir_info, n));
-
-    // Now it's sitting in the ring buffer ready to be used as source for the vertical sampling.
-}
-
-static void stbir__decode_and_resample_downsample(stbir__info* stbir_info, int n)
-{
-    // Decode the nth scanline from the source image into the decode buffer.
-    stbir__decode_scanline(stbir_info, n);
-
-    memset(stbir_info->horizontal_buffer, 0, stbir_info->output_w * stbir_info->channels * sizeof(float));
-
-    // Now resample it into the horizontal buffer.
-    if (stbir__use_width_upsampling(stbir_info))
-        stbir__resample_horizontal_upsample(stbir_info, stbir_info->horizontal_buffer);
-    else
-        stbir__resample_horizontal_downsample(stbir_info, stbir_info->horizontal_buffer);
-
-    // Now it's sitting in the horizontal buffer ready to be distributed into the ring buffers.
-}
-
-// Get the specified scan line from the ring buffer.
-static float* stbir__get_ring_buffer_scanline(int get_scanline, float* ring_buffer, int begin_index, int first_scanline, int ring_buffer_num_entries, int ring_buffer_length)
-{
-    int ring_buffer_index = (begin_index + (get_scanline - first_scanline)) % ring_buffer_num_entries;
-    return stbir__get_ring_buffer_entry(ring_buffer, ring_buffer_index, ring_buffer_length);
-}
-
-
-static void stbir__encode_scanline(stbir__info* stbir_info, int num_pixels, void *output_buffer, float *encode_buffer, int channels, int alpha_channel, int decode)
-{
-    int x;
-    int n;
-    int num_nonalpha;
-    stbir_uint16 nonalpha[STBIR_MAX_CHANNELS];
-
-    if (!(stbir_info->flags&STBIR_FLAG_ALPHA_PREMULTIPLIED))
-    {
-        for (x=0; x < num_pixels; ++x)
-        {
-            int pixel_index = x*channels;
-
-            float alpha = encode_buffer[pixel_index + alpha_channel];
-            float reciprocal_alpha = alpha ? 1.0f / alpha : 0;
-
-            // unrolling this produced a 1% slowdown upscaling a large RGBA linear-space image on my machine - stb
-            for (n = 0; n < channels; n++)
-                if (n != alpha_channel)
-                    encode_buffer[pixel_index + n] *= reciprocal_alpha;
-
-            // We added in a small epsilon to prevent the color channel from being deleted with zero alpha.
-            // Because we only add it for integer types, it will automatically be discarded on integer
-            // conversion, so we don't need to subtract it back out (which would be problematic for
-            // numeric precision reasons).
-        }
-    }
-
-    // build a table of all channels that need colorspace correction, so
-    // we don't perform colorspace correction on channels that don't need it.
-    for (x = 0, num_nonalpha = 0; x < channels; ++x)
-    {
-        if (x != alpha_channel || (stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE))
-        {
-            nonalpha[num_nonalpha++] = (stbir_uint16)x;
-        }
-    }
-
-    #define STBIR__ROUND_INT(f)    ((int)          ((f)+0.5))
-    #define STBIR__ROUND_UINT(f)   ((stbir_uint32) ((f)+0.5))
-
-    #ifdef STBIR__SATURATE_INT
-    #define STBIR__ENCODE_LINEAR8(f)   stbir__saturate8 (STBIR__ROUND_INT((f) * stbir__max_uint8_as_float ))
-    #define STBIR__ENCODE_LINEAR16(f)  stbir__saturate16(STBIR__ROUND_INT((f) * stbir__max_uint16_as_float))
-    #else
-    #define STBIR__ENCODE_LINEAR8(f)   (unsigned char ) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint8_as_float )
-    #define STBIR__ENCODE_LINEAR16(f)  (unsigned short) STBIR__ROUND_INT(stbir__saturate(f) * stbir__max_uint16_as_float)
-    #endif
-
-    switch (decode)
-    {
-        case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned char*)output_buffer)[index] = STBIR__ENCODE_LINEAR8(encode_buffer[index]);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT8, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned char*)output_buffer)[index] = stbir__linear_to_srgb_uchar(encode_buffer[index]);
-                }
-
-                if (!(stbir_info->flags & STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned char *)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR8(encode_buffer[pixel_index+alpha_channel]);
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned short*)output_buffer)[index] = STBIR__ENCODE_LINEAR16(encode_buffer[index]);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT16, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned short*)output_buffer)[index] = (unsigned short)STBIR__ROUND_INT(stbir__linear_to_srgb(stbir__saturate(encode_buffer[index])) * stbir__max_uint16_as_float);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned short*)output_buffer)[pixel_index + alpha_channel] = STBIR__ENCODE_LINEAR16(encode_buffer[pixel_index + alpha_channel]);
-            }
-
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__saturate(encode_buffer[index])) * stbir__max_uint32_as_float);
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_UINT32, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((unsigned int*)output_buffer)[index] = (unsigned int)STBIR__ROUND_UINT(((double)stbir__linear_to_srgb(stbir__saturate(encode_buffer[index]))) * stbir__max_uint32_as_float);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((unsigned int*)output_buffer)[pixel_index + alpha_channel] = (unsigned int)STBIR__ROUND_INT(((double)stbir__saturate(encode_buffer[pixel_index + alpha_channel])) * stbir__max_uint32_as_float);
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_LINEAR):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < channels; n++)
-                {
-                    int index = pixel_index + n;
-                    ((float*)output_buffer)[index] = encode_buffer[index];
-                }
-            }
-            break;
-
-        case STBIR__DECODE(STBIR_TYPE_FLOAT, STBIR_COLORSPACE_SRGB):
-            for (x=0; x < num_pixels; ++x)
-            {
-                int pixel_index = x*channels;
-
-                for (n = 0; n < num_nonalpha; n++)
-                {
-                    int index = pixel_index + nonalpha[n];
-                    ((float*)output_buffer)[index] = stbir__linear_to_srgb(encode_buffer[index]);
-                }
-
-                if (!(stbir_info->flags&STBIR_FLAG_ALPHA_USES_COLORSPACE))
-                    ((float*)output_buffer)[pixel_index + alpha_channel] = encode_buffer[pixel_index + alpha_channel];
-            }
-            break;
-
-        default:
-            STBIR_ASSERT(!"Unknown type/colorspace/channels combination.");
-            break;
-    }
-}
-
-static void stbir__resample_vertical_upsample(stbir__info* stbir_info, int n)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    stbir__contributors* vertical_contributors = stbir_info->vertical_contributors;
-    float* vertical_coefficients = stbir_info->vertical_coefficients;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int ring_buffer_entries = stbir_info->ring_buffer_num_entries;
-    void* output_data = stbir_info->output_data;
-    float* encode_buffer = stbir_info->encode_buffer;
-    int decode = STBIR__DECODE(type, colorspace);
-    int coefficient_width = stbir_info->vertical_coefficient_width;
-    int coefficient_counter;
-    int contributor = n;
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index;
-    int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-
-    int n0,n1, output_row_start;
-    int coefficient_group = coefficient_width * contributor;
-
-    n0 = vertical_contributors[contributor].n0;
-    n1 = vertical_contributors[contributor].n1;
-
-    output_row_start = n * stbir_info->output_stride_bytes;
-
-    STBIR_ASSERT(stbir__use_height_upsampling(stbir_info));
-
-    memset(encode_buffer, 0, output_w * sizeof(float) * channels);
-
-    // I tried reblocking this for better cache usage of encode_buffer
-    // (using x_outer, k, x_inner), but it lost speed. -- stb
-
-    coefficient_counter = 0;
-    switch (channels) {
-        case 1:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 1;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                }
-            }
-            break;
-        case 2:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 2;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                }
-            }
-            break;
-        case 3:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 3;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                    encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient;
-                }
-            }
-            break;
-        case 4:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * 4;
-                    encode_buffer[in_pixel_index + 0] += ring_buffer_entry[in_pixel_index + 0] * coefficient;
-                    encode_buffer[in_pixel_index + 1] += ring_buffer_entry[in_pixel_index + 1] * coefficient;
-                    encode_buffer[in_pixel_index + 2] += ring_buffer_entry[in_pixel_index + 2] * coefficient;
-                    encode_buffer[in_pixel_index + 3] += ring_buffer_entry[in_pixel_index + 3] * coefficient;
-                }
-            }
-            break;
-        default:
-            for (k = n0; k <= n1; k++)
-            {
-                int coefficient_index = coefficient_counter++;
-                float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-                float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-                for (x = 0; x < output_w; ++x)
-                {
-                    int in_pixel_index = x * channels;
-                    int c;
-                    for (c = 0; c < channels; c++)
-                        encode_buffer[in_pixel_index + c] += ring_buffer_entry[in_pixel_index + c] * coefficient;
-                }
-            }
-            break;
-    }
-    stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, encode_buffer, channels, alpha_channel, decode);
-}
-
-static void stbir__resample_vertical_downsample(stbir__info* stbir_info, int n)
-{
-    int x, k;
-    int output_w = stbir_info->output_w;
-    stbir__contributors* vertical_contributors = stbir_info->vertical_contributors;
-    float* vertical_coefficients = stbir_info->vertical_coefficients;
-    int channels = stbir_info->channels;
-    int ring_buffer_entries = stbir_info->ring_buffer_num_entries;
-    float* horizontal_buffer = stbir_info->horizontal_buffer;
-    int coefficient_width = stbir_info->vertical_coefficient_width;
-    int contributor = n + stbir_info->vertical_filter_pixel_margin;
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_begin_index = stbir_info->ring_buffer_begin_index;
-    int ring_buffer_first_scanline = stbir_info->ring_buffer_first_scanline;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-    int n0,n1;
-
-    n0 = vertical_contributors[contributor].n0;
-    n1 = vertical_contributors[contributor].n1;
-
-    STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info));
-
-    for (k = n0; k <= n1; k++)
-    {
-        int coefficient_index = k - n0;
-        int coefficient_group = coefficient_width * contributor;
-        float coefficient = vertical_coefficients[coefficient_group + coefficient_index];
-
-        float* ring_buffer_entry = stbir__get_ring_buffer_scanline(k, ring_buffer, ring_buffer_begin_index, ring_buffer_first_scanline, ring_buffer_entries, ring_buffer_length);
-
-        switch (channels) {
-            case 1:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 1;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                }
-                break;
-            case 2:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 2;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                }
-                break;
-            case 3:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 3;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient;
-                }
-                break;
-            case 4:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * 4;
-                    ring_buffer_entry[in_pixel_index + 0] += horizontal_buffer[in_pixel_index + 0] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 1] += horizontal_buffer[in_pixel_index + 1] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 2] += horizontal_buffer[in_pixel_index + 2] * coefficient;
-                    ring_buffer_entry[in_pixel_index + 3] += horizontal_buffer[in_pixel_index + 3] * coefficient;
-                }
-                break;
-            default:
-                for (x = 0; x < output_w; x++)
-                {
-                    int in_pixel_index = x * channels;
-
-                    int c;
-                    for (c = 0; c < channels; c++)
-                        ring_buffer_entry[in_pixel_index + c] += horizontal_buffer[in_pixel_index + c] * coefficient;
-                }
-                break;
-        }
-    }
-}
-
-static void stbir__buffer_loop_upsample(stbir__info* stbir_info)
-{
-    int y;
-    float scale_ratio = stbir_info->vertical_scale;
-    float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio;
-
-    STBIR_ASSERT(stbir__use_height_upsampling(stbir_info));
-
-    for (y = 0; y < stbir_info->output_h; y++)
-    {
-        float in_center_of_out = 0; // Center of the current out scanline in the in scanline space
-        int in_first_scanline = 0, in_last_scanline = 0;
-
-        stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out);
-
-        STBIR_ASSERT(in_last_scanline - in_first_scanline + 1 <= stbir_info->ring_buffer_num_entries);
-
-        if (stbir_info->ring_buffer_begin_index >= 0)
-        {
-            // Get rid of whatever we don't need anymore.
-            while (in_first_scanline > stbir_info->ring_buffer_first_scanline)
-            {
-                if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline)
-                {
-                    // We just popped the last scanline off the ring buffer.
-                    // Reset it to the empty state.
-                    stbir_info->ring_buffer_begin_index = -1;
-                    stbir_info->ring_buffer_first_scanline = 0;
-                    stbir_info->ring_buffer_last_scanline = 0;
-                    break;
-                }
-                else
-                {
-                    stbir_info->ring_buffer_first_scanline++;
-                    stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries;
-                }
-            }
-        }
-
-        // Load in new ones.
-        if (stbir_info->ring_buffer_begin_index < 0)
-            stbir__decode_and_resample_upsample(stbir_info, in_first_scanline);
-
-        while (in_last_scanline > stbir_info->ring_buffer_last_scanline)
-            stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1);
-
-        // Now all buffers should be ready to write a row of vertical sampling.
-        stbir__resample_vertical_upsample(stbir_info, y);
-
-        STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h);
-    }
-}
-
-static void stbir__empty_ring_buffer(stbir__info* stbir_info, int first_necessary_scanline)
-{
-    int output_stride_bytes = stbir_info->output_stride_bytes;
-    int channels = stbir_info->channels;
-    int alpha_channel = stbir_info->alpha_channel;
-    int type = stbir_info->type;
-    int colorspace = stbir_info->colorspace;
-    int output_w = stbir_info->output_w;
-    void* output_data = stbir_info->output_data;
-    int decode = STBIR__DECODE(type, colorspace);
-
-    float* ring_buffer = stbir_info->ring_buffer;
-    int ring_buffer_length = stbir_info->ring_buffer_length_bytes/sizeof(float);
-
-    if (stbir_info->ring_buffer_begin_index >= 0)
-    {
-        // Get rid of whatever we don't need anymore.
-        while (first_necessary_scanline > stbir_info->ring_buffer_first_scanline)
-        {
-            if (stbir_info->ring_buffer_first_scanline >= 0 && stbir_info->ring_buffer_first_scanline < stbir_info->output_h)
-            {
-                int output_row_start = stbir_info->ring_buffer_first_scanline * output_stride_bytes;
-                float* ring_buffer_entry = stbir__get_ring_buffer_entry(ring_buffer, stbir_info->ring_buffer_begin_index, ring_buffer_length);
-                stbir__encode_scanline(stbir_info, output_w, (char *) output_data + output_row_start, ring_buffer_entry, channels, alpha_channel, decode);
-                STBIR_PROGRESS_REPORT((float)stbir_info->ring_buffer_first_scanline / stbir_info->output_h);
-            }
-
-            if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline)
-            {
-                // We just popped the last scanline off the ring buffer.
-                // Reset it to the empty state.
-                stbir_info->ring_buffer_begin_index = -1;
-                stbir_info->ring_buffer_first_scanline = 0;
-                stbir_info->ring_buffer_last_scanline = 0;
-                break;
-            }
-            else
-            {
-                stbir_info->ring_buffer_first_scanline++;
-                stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->ring_buffer_num_entries;
-            }
-        }
-    }
-}
-
-static void stbir__buffer_loop_downsample(stbir__info* stbir_info)
-{
-    int y;
-    float scale_ratio = stbir_info->vertical_scale;
-    int output_h = stbir_info->output_h;
-    float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio;
-    int pixel_margin = stbir_info->vertical_filter_pixel_margin;
-    int max_y = stbir_info->input_h + pixel_margin;
-
-    STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info));
-
-    for (y = -pixel_margin; y < max_y; y++)
-    {
-        float out_center_of_in; // Center of the current out scanline in the in scanline space
-        int out_first_scanline, out_last_scanline;
-
-        stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in);
-
-        STBIR_ASSERT(out_last_scanline - out_first_scanline + 1 <= stbir_info->ring_buffer_num_entries);
-
-        if (out_last_scanline < 0 || out_first_scanline >= output_h)
-            continue;
-
-        stbir__empty_ring_buffer(stbir_info, out_first_scanline);
-
-        stbir__decode_and_resample_downsample(stbir_info, y);
-
-        // Load in new ones.
-        if (stbir_info->ring_buffer_begin_index < 0)
-            stbir__add_empty_ring_buffer_entry(stbir_info, out_first_scanline);
-
-        while (out_last_scanline > stbir_info->ring_buffer_last_scanline)
-            stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1);
-
-        // Now the horizontal buffer is ready to write to all ring buffer rows.
-        stbir__resample_vertical_downsample(stbir_info, y);
-    }
-
-    stbir__empty_ring_buffer(stbir_info, stbir_info->output_h);
-}
-
-static void stbir__setup(stbir__info *info, int input_w, int input_h, int output_w, int output_h, int channels)
-{
-    info->input_w = input_w;
-    info->input_h = input_h;
-    info->output_w = output_w;
-    info->output_h = output_h;
-    info->channels = channels;
-}
-
-static void stbir__calculate_transform(stbir__info *info, float s0, float t0, float s1, float t1, float *transform)
-{
-    info->s0 = s0;
-    info->t0 = t0;
-    info->s1 = s1;
-    info->t1 = t1;
-
-    if (transform)
-    {
-        info->horizontal_scale = transform[0];
-        info->vertical_scale   = transform[1];
-        info->horizontal_shift = transform[2];
-        info->vertical_shift   = transform[3];
-    }
-    else
-    {
-        info->horizontal_scale = ((float)info->output_w / info->input_w) / (s1 - s0);
-        info->vertical_scale = ((float)info->output_h / info->input_h) / (t1 - t0);
-
-        info->horizontal_shift = s0 * info->output_w / (s1 - s0);
-        info->vertical_shift = t0 * info->output_h / (t1 - t0);
-    }
-}
-
-static void stbir__choose_filter(stbir__info *info, stbir_filter h_filter, stbir_filter v_filter)
-{
-    if (h_filter == 0)
-        h_filter = stbir__use_upsampling(info->horizontal_scale) ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE;
-    if (v_filter == 0)
-        v_filter = stbir__use_upsampling(info->vertical_scale)   ? STBIR_DEFAULT_FILTER_UPSAMPLE : STBIR_DEFAULT_FILTER_DOWNSAMPLE;
-    info->horizontal_filter = h_filter;
-    info->vertical_filter = v_filter;
-}
-
-static stbir_uint32 stbir__calculate_memory(stbir__info *info)
-{
-    int pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale);
-    int filter_height = stbir__get_filter_pixel_width(info->vertical_filter, info->vertical_scale);
-
-    info->horizontal_num_contributors = stbir__get_contributors(info->horizontal_scale, info->horizontal_filter, info->input_w, info->output_w);
-    info->vertical_num_contributors   = stbir__get_contributors(info->vertical_scale  , info->vertical_filter  , info->input_h, info->output_h);
-
-    // One extra entry because floating point precision problems sometimes cause an extra to be necessary.
-    info->ring_buffer_num_entries = filter_height + 1;
-
-    info->horizontal_contributors_size = info->horizontal_num_contributors * sizeof(stbir__contributors);
-    info->horizontal_coefficients_size = stbir__get_total_horizontal_coefficients(info) * sizeof(float);
-    info->vertical_contributors_size = info->vertical_num_contributors * sizeof(stbir__contributors);
-    info->vertical_coefficients_size = stbir__get_total_vertical_coefficients(info) * sizeof(float);
-    info->decode_buffer_size = (info->input_w + pixel_margin * 2) * info->channels * sizeof(float);
-    info->horizontal_buffer_size = info->output_w * info->channels * sizeof(float);
-    info->ring_buffer_size = info->output_w * info->channels * info->ring_buffer_num_entries * sizeof(float);
-    info->encode_buffer_size = info->output_w * info->channels * sizeof(float);
-
-    STBIR_ASSERT(info->horizontal_filter != 0);
-    STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late
-    STBIR_ASSERT(info->vertical_filter != 0);
-    STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table)); // this now happens too late
-
-    if (stbir__use_height_upsampling(info))
-        // The horizontal buffer is for when we're downsampling the height and we
-        // can't output the result of sampling the decode buffer directly into the
-        // ring buffers.
-        info->horizontal_buffer_size = 0;
-    else
-        // The encode buffer is to retain precision in the height upsampling method
-        // and isn't used when height downsampling.
-        info->encode_buffer_size = 0;
-
-    return info->horizontal_contributors_size + info->horizontal_coefficients_size
-        + info->vertical_contributors_size + info->vertical_coefficients_size
-        + info->decode_buffer_size + info->horizontal_buffer_size
-        + info->ring_buffer_size + info->encode_buffer_size;
-}
-
-static int stbir__resize_allocated(stbir__info *info,
-    const void* input_data, int input_stride_in_bytes,
-    void* output_data, int output_stride_in_bytes,
-    int alpha_channel, stbir_uint32 flags, stbir_datatype type,
-    stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace,
-    void* tempmem, size_t tempmem_size_in_bytes)
-{
-    size_t memory_required = stbir__calculate_memory(info);
-
-    int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type];
-    int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type];
-
-#ifdef STBIR_DEBUG_OVERWRITE_TEST
-#define OVERWRITE_ARRAY_SIZE 8
-    unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE];
-    unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE];
-
-    size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type];
-    memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
-    memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE);
-#endif
-
-    STBIR_ASSERT(info->channels >= 0);
-    STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS);
-
-    if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS)
-        return 0;
-
-    STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-    STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
-
-    if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
-        return 0;
-    if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
-        return 0;
-
-    if (alpha_channel < 0)
-        flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED;
-
-    if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) {
-        STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels);
-    }
-
-    if (alpha_channel >= info->channels)
-        return 0;
-
-    STBIR_ASSERT(tempmem);
-
-    if (!tempmem)
-        return 0;
-
-    STBIR_ASSERT(tempmem_size_in_bytes >= memory_required);
-
-    if (tempmem_size_in_bytes < memory_required)
-        return 0;
-
-    memset(tempmem, 0, tempmem_size_in_bytes);
-
-    info->input_data = input_data;
-    info->input_stride_bytes = width_stride_input;
-
-    info->output_data = output_data;
-    info->output_stride_bytes = width_stride_output;
-
-    info->alpha_channel = alpha_channel;
-    info->flags = flags;
-    info->type = type;
-    info->edge_horizontal = edge_horizontal;
-    info->edge_vertical = edge_vertical;
-    info->colorspace = colorspace;
-
-    info->horizontal_coefficient_width   = stbir__get_coefficient_width  (info->horizontal_filter, info->horizontal_scale);
-    info->vertical_coefficient_width     = stbir__get_coefficient_width  (info->vertical_filter  , info->vertical_scale  );
-    info->horizontal_filter_pixel_width  = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale);
-    info->vertical_filter_pixel_width    = stbir__get_filter_pixel_width (info->vertical_filter  , info->vertical_scale  );
-    info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale);
-    info->vertical_filter_pixel_margin   = stbir__get_filter_pixel_margin(info->vertical_filter  , info->vertical_scale  );
-
-    info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float);
-    info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2;
-
-#define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size)
-
-    info->horizontal_contributors = (stbir__contributors *) tempmem;
-    info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float);
-    info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors);
-    info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float);
-    info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float);
-
-    if (stbir__use_height_upsampling(info))
-    {
-        info->horizontal_buffer = NULL;
-        info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
-        info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float);
-
-        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
-    }
-    else
-    {
-        info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
-        info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float);
-        info->encode_buffer = NULL;
-
-        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
-    }
-
-#undef STBIR__NEXT_MEMPTR
-
-    // This signals that the ring buffer is empty
-    info->ring_buffer_begin_index = -1;
-
-    stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w);
-    stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h);
-
-    STBIR_PROGRESS_REPORT(0);
-
-    if (stbir__use_height_upsampling(info))
-        stbir__buffer_loop_upsample(info);
-    else
-        stbir__buffer_loop_downsample(info);
-
-    STBIR_PROGRESS_REPORT(1);
-
-#ifdef STBIR_DEBUG_OVERWRITE_TEST
-    STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
-    STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0);
-#endif
-
-    return 1;
-}
-
-
-static int stbir__resize_arbitrary(
-    void *alloc_context,
-    const void* input_data, int input_w, int input_h, int input_stride_in_bytes,
-    void* output_data, int output_w, int output_h, int output_stride_in_bytes,
-    float s0, float t0, float s1, float t1, float *transform,
-    int channels, int alpha_channel, stbir_uint32 flags, stbir_datatype type,
-    stbir_filter h_filter, stbir_filter v_filter,
-    stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace)
-{
-    stbir__info info;
-    int result;
-    size_t memory_required;
-    void* extra_memory;
-
-    stbir__setup(&info, input_w, input_h, output_w, output_h, channels);
-    stbir__calculate_transform(&info, s0,t0,s1,t1,transform);
-    stbir__choose_filter(&info, h_filter, v_filter);
-    memory_required = stbir__calculate_memory(&info);
-    extra_memory = STBIR_MALLOC(memory_required, alloc_context);
-
-    if (!extra_memory)
-        return 0;
-
-    result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes,
-                                            output_data, output_stride_in_bytes,
-                                            alpha_channel, flags, type,
-                                            edge_horizontal, edge_vertical,
-                                            colorspace, extra_memory, memory_required);
-
-    STBIR_FREE(extra_memory, alloc_context);
-
-    return result;
-}
-
-STBIRDEF int stbir_resize_uint8(     const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR);
-}
-
-STBIRDEF int stbir_resize_float(     const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           float *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,-1,0, STBIR_TYPE_FLOAT, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_LINEAR);
-}
-
-STBIRDEF int stbir_resize_uint8_srgb(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                           unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                     int num_channels, int alpha_channel, int flags)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        STBIR_EDGE_CLAMP, STBIR_EDGE_CLAMP, STBIR_COLORSPACE_SRGB);
-}
-
-STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                                    unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                              int num_channels, int alpha_channel, int flags,
-                                              stbir_edge edge_wrap_mode)
-{
-    return stbir__resize_arbitrary(NULL, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, STBIR_FILTER_DEFAULT, STBIR_FILTER_DEFAULT,
-        edge_wrap_mode, edge_wrap_mode, STBIR_COLORSPACE_SRGB);
-}
-
-STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                               unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT8, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels  , int input_w , int input_h , int input_stride_in_bytes,
-                                               stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_UINT16, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-
-STBIRDEF int stbir_resize_float_generic( const float *input_pixels         , int input_w , int input_h , int input_stride_in_bytes,
-                                               float *output_pixels        , int output_w, int output_h, int output_stride_in_bytes,
-                                         int num_channels, int alpha_channel, int flags,
-                                         stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
-                                         void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, STBIR_TYPE_FLOAT, filter, filter,
-        edge_wrap_mode, edge_wrap_mode, space);
-}
-
-
-STBIRDEF int stbir_resize(         const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-
-STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float x_scale, float y_scale,
-                                   float x_offset, float y_offset)
-{
-    float transform[4];
-    transform[0] = x_scale;
-    transform[1] = y_scale;
-    transform[2] = x_offset;
-    transform[3] = y_offset;
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        0,0,1,1,transform,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-STBIRDEF int stbir_resize_region(  const void *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
-                                         void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
-                                   stbir_datatype datatype,
-                                   int num_channels, int alpha_channel, int flags,
-                                   stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
-                                   stbir_filter filter_horizontal,  stbir_filter filter_vertical,
-                                   stbir_colorspace space, void *alloc_context,
-                                   float s0, float t0, float s1, float t1)
-{
-    return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
-        output_pixels, output_w, output_h, output_stride_in_bytes,
-        s0,t0,s1,t1,NULL,num_channels,alpha_channel,flags, datatype, filter_horizontal, filter_vertical,
-        edge_mode_horizontal, edge_mode_vertical, space);
-}
-
-#endif // STB_IMAGE_RESIZE_IMPLEMENTATION
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_image_write.h b/raylib_pi4_test/external/stb_image_write.h
deleted file mode 100644 (file)
index 95943eb..0000000
+++ /dev/null
@@ -1,1690 +0,0 @@
-/* stb_image_write - v1.15 - public domain - http://nothings.org/stb
-   writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015
-                                     no warranty implied; use at your own risk
-
-   Before #including,
-
-       #define STB_IMAGE_WRITE_IMPLEMENTATION
-
-   in the file that you want to have the implementation.
-
-   Will probably not work correctly with strict-aliasing optimizations.
-
-ABOUT:
-
-   This header file is a library for writing images to C stdio or a callback.
-
-   The PNG output is not optimal; it is 20-50% larger than the file
-   written by a decent optimizing implementation; though providing a custom
-   zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that.
-   This library is designed for source code compactness and simplicity,
-   not optimal image file size or run-time performance.
-
-BUILDING:
-
-   You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h.
-   You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace
-   malloc,realloc,free.
-   You can #define STBIW_MEMMOVE() to replace memmove()
-   You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function
-   for PNG compression (instead of the builtin one), it must have the following signature:
-   unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality);
-   The returned data will be freed with STBIW_FREE() (free() by default),
-   so it must be heap allocated with STBIW_MALLOC() (malloc() by default),
-
-UNICODE:
-
-   If compiling for Windows and you wish to use Unicode filenames, compile
-   with
-       #define STBIW_WINDOWS_UTF8
-   and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert
-   Windows wchar_t filenames to utf8.
-
-USAGE:
-
-   There are five functions, one for each image file format:
-
-     int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);
-     int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);
-     int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);
-     int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality);
-     int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
-
-     void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically
-
-   There are also five equivalent functions that use an arbitrary write function. You are
-   expected to open/close your file-equivalent before and after calling these:
-
-     int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);
-     int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-     int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-     int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
-     int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);
-
-   where the callback is:
-      void stbi_write_func(void *context, void *data, int size);
-
-   You can configure it with these global variables:
-      int stbi_write_tga_with_rle;             // defaults to true; set to 0 to disable RLE
-      int stbi_write_png_compression_level;    // defaults to 8; set to higher for more compression
-      int stbi_write_force_png_filter;         // defaults to -1; set to 0..5 to force a filter mode
-
-
-   You can define STBI_WRITE_NO_STDIO to disable the file variant of these
-   functions, so the library will not use stdio.h at all. However, this will
-   also disable HDR writing, because it requires stdio for formatted output.
-
-   Each function returns 0 on failure and non-0 on success.
-
-   The functions create an image file defined by the parameters. The image
-   is a rectangle of pixels stored from left-to-right, top-to-bottom.
-   Each pixel contains 'comp' channels of data stored interleaved with 8-bits
-   per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is
-   monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall.
-   The *data pointer points to the first byte of the top-left-most pixel.
-   For PNG, "stride_in_bytes" is the distance in bytes from the first byte of
-   a row of pixels to the first byte of the next row of pixels.
-
-   PNG creates output files with the same number of components as the input.
-   The BMP format expands Y to RGB in the file format and does not
-   output alpha.
-
-   PNG supports writing rectangles of data even when the bytes storing rows of
-   data are not consecutive in memory (e.g. sub-rectangles of a larger image),
-   by supplying the stride between the beginning of adjacent rows. The other
-   formats do not. (Thus you cannot write a native-format BMP through the BMP
-   writer, both because it is in BGR order and because it may have padding
-   at the end of the line.)
-
-   PNG allows you to set the deflate compression level by setting the global
-   variable 'stbi_write_png_compression_level' (it defaults to 8).
-
-   HDR expects linear float data. Since the format is always 32-bit rgb(e)
-   data, alpha (if provided) is discarded, and for monochrome data it is
-   replicated across all three channels.
-
-   TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed
-   data, set the global variable 'stbi_write_tga_with_rle' to 0.
-
-   JPEG does ignore alpha channels in input data; quality is between 1 and 100.
-   Higher quality looks better but results in a bigger image.
-   JPEG baseline (no JPEG progressive).
-
-CREDITS:
-
-
-   Sean Barrett           -    PNG/BMP/TGA
-   Baldur Karlsson        -    HDR
-   Jean-Sebastien Guay    -    TGA monochrome
-   Tim Kelsey             -    misc enhancements
-   Alan Hickman           -    TGA RLE
-   Emmanuel Julien        -    initial file IO callback implementation
-   Jon Olick              -    original jo_jpeg.cpp code
-   Daniel Gibson          -    integrate JPEG, allow external zlib
-   Aarni Koskela          -    allow choosing PNG filter
-
-   bugfixes:
-      github:Chribba
-      Guillaume Chereau
-      github:jry2
-      github:romigrou
-      Sergio Gonzalez
-      Jonas Karlsson
-      Filip Wasil
-      Thatcher Ulrich
-      github:poppolopoppo
-      Patrick Boettcher
-      github:xeekworx
-      Cap Petschulat
-      Simon Rodriguez
-      Ivan Tikhonov
-      github:ignotion
-      Adam Schackart
-
-LICENSE
-
-  See end of file for license information.
-
-*/
-
-#ifndef INCLUDE_STB_IMAGE_WRITE_H
-#define INCLUDE_STB_IMAGE_WRITE_H
-
-#include <stdlib.h>
-
-// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline'
-#ifndef STBIWDEF
-#ifdef STB_IMAGE_WRITE_STATIC
-#define STBIWDEF  static
-#else
-#ifdef __cplusplus
-#define STBIWDEF  extern "C"
-#else
-#define STBIWDEF  extern
-#endif
-#endif
-#endif
-
-#ifndef STB_IMAGE_WRITE_STATIC  // C++ forbids static forward declarations
-extern int stbi_write_tga_with_rle;
-extern int stbi_write_png_compression_level;
-extern int stbi_write_force_png_filter;
-#endif
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void  *data, int stride_in_bytes);
-STBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);
-STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void  *data, int quality);
-
-#ifdef STBI_WINDOWS_UTF8
-STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);
-#endif
-#endif
-
-typedef void stbi_write_func(void *context, void *data, int size);
-
-STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);
-STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);
-STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);
-STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void  *data, int quality);
-
-STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);
-
-#endif//INCLUDE_STB_IMAGE_WRITE_H
-
-#ifdef STB_IMAGE_WRITE_IMPLEMENTATION
-
-#ifdef _WIN32
-   #ifndef _CRT_SECURE_NO_WARNINGS
-   #define _CRT_SECURE_NO_WARNINGS
-   #endif
-   #ifndef _CRT_NONSTDC_NO_DEPRECATE
-   #define _CRT_NONSTDC_NO_DEPRECATE
-   #endif
-#endif
-
-#ifndef STBI_WRITE_NO_STDIO
-#include <stdio.h>
-#endif // STBI_WRITE_NO_STDIO
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED))
-// ok
-#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED)
-// ok
-#else
-#error "Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED)."
-#endif
-
-#ifndef STBIW_MALLOC
-#define STBIW_MALLOC(sz)        malloc(sz)
-#define STBIW_REALLOC(p,newsz)  realloc(p,newsz)
-#define STBIW_FREE(p)           free(p)
-#endif
-
-#ifndef STBIW_REALLOC_SIZED
-#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)
-#endif
-
-
-#ifndef STBIW_MEMMOVE
-#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)
-#endif
-
-
-#ifndef STBIW_ASSERT
-#include <assert.h>
-#define STBIW_ASSERT(x) assert(x)
-#endif
-
-#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)
-
-#ifdef STB_IMAGE_WRITE_STATIC
-static int stbi_write_png_compression_level = 8;
-static int stbi_write_tga_with_rle = 1;
-static int stbi_write_force_png_filter = -1;
-#else
-int stbi_write_png_compression_level = 8;
-int stbi_write_tga_with_rle = 1;
-int stbi_write_force_png_filter = -1;
-#endif
-
-static int stbi__flip_vertically_on_write = 0;
-
-STBIWDEF void stbi_flip_vertically_on_write(int flag)
-{
-   stbi__flip_vertically_on_write = flag;
-}
-
-typedef struct
-{
-   stbi_write_func *func;
-   void *context;
-   unsigned char buffer[64];
-   int buf_used;
-} stbi__write_context;
-
-// initialize a callback-based context
-static void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context)
-{
-   s->func    = c;
-   s->context = context;
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-
-static void stbi__stdio_write(void *context, void *data, int size)
-{
-   fwrite(data,1,size,(FILE*) context);
-}
-
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-#ifdef __cplusplus
-#define STBIW_EXTERN extern "C"
-#else
-#define STBIW_EXTERN extern
-#endif
-STBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);
-STBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);
-
-STBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)
-{
-       return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);
-}
-#endif
-
-static FILE *stbiw__fopen(char const *filename, char const *mode)
-{
-   FILE *f;
-#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)
-   wchar_t wMode[64];
-   wchar_t wFilename[1024];
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))
-      return 0;
-
-       if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))
-      return 0;
-
-#if _MSC_VER >= 1400
-       if (0 != _wfopen_s(&f, wFilename, wMode))
-               f = 0;
-#else
-   f = _wfopen(wFilename, wMode);
-#endif
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
-   if (0 != fopen_s(&f, filename, mode))
-      f=0;
-#else
-   f = fopen(filename, mode);
-#endif
-   return f;
-}
-
-static int stbi__start_write_file(stbi__write_context *s, const char *filename)
-{
-   FILE *f = stbiw__fopen(filename, "wb");
-   stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);
-   return f != NULL;
-}
-
-static void stbi__end_write_file(stbi__write_context *s)
-{
-   fclose((FILE *)s->context);
-}
-
-#endif // !STBI_WRITE_NO_STDIO
-
-typedef unsigned int stbiw_uint32;
-typedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];
-
-static void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v)
-{
-   while (*fmt) {
-      switch (*fmt++) {
-         case ' ': break;
-         case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int));
-                     s->func(s->context,&x,1);
-                     break; }
-         case '2': { int x = va_arg(v,int);
-                     unsigned char b[2];
-                     b[0] = STBIW_UCHAR(x);
-                     b[1] = STBIW_UCHAR(x>>8);
-                     s->func(s->context,b,2);
-                     break; }
-         case '4': { stbiw_uint32 x = va_arg(v,int);
-                     unsigned char b[4];
-                     b[0]=STBIW_UCHAR(x);
-                     b[1]=STBIW_UCHAR(x>>8);
-                     b[2]=STBIW_UCHAR(x>>16);
-                     b[3]=STBIW_UCHAR(x>>24);
-                     s->func(s->context,b,4);
-                     break; }
-         default:
-            STBIW_ASSERT(0);
-            return;
-      }
-   }
-}
-
-static void stbiw__writef(stbi__write_context *s, const char *fmt, ...)
-{
-   va_list v;
-   va_start(v, fmt);
-   stbiw__writefv(s, fmt, v);
-   va_end(v);
-}
-
-static void stbiw__write_flush(stbi__write_context *s)
-{
-   if (s->buf_used) {
-      s->func(s->context, &s->buffer, s->buf_used);
-      s->buf_used = 0;
-   }
-}
-
-static void stbiw__putc(stbi__write_context *s, unsigned char c)
-{
-   s->func(s->context, &c, 1);
-}
-
-static void stbiw__write1(stbi__write_context *s, unsigned char a)
-{
-   if (s->buf_used + 1 > sizeof(s->buffer))
-      stbiw__write_flush(s);
-   s->buffer[s->buf_used++] = a;
-}
-
-static void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)
-{
-   int n;
-   if (s->buf_used + 3 > sizeof(s->buffer))
-      stbiw__write_flush(s);
-   n = s->buf_used;
-   s->buf_used = n+3;
-   s->buffer[n+0] = a;
-   s->buffer[n+1] = b;
-   s->buffer[n+2] = c;
-}
-
-static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)
-{
-   unsigned char bg[3] = { 255, 0, 255}, px[3];
-   int k;
-
-   if (write_alpha < 0)
-      stbiw__write1(s, d[comp - 1]);
-
-   switch (comp) {
-      case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case
-      case 1:
-         if (expand_mono)
-            stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp
-         else
-            stbiw__write1(s, d[0]);  // monochrome TGA
-         break;
-      case 4:
-         if (!write_alpha) {
-            // composite against pink background
-            for (k = 0; k < 3; ++k)
-               px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;
-            stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
-            break;
-         }
-         /* FALLTHROUGH */
-      case 3:
-         stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
-         break;
-   }
-   if (write_alpha > 0)
-      stbiw__write1(s, d[comp - 1]);
-}
-
-static void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)
-{
-   stbiw_uint32 zero = 0;
-   int i,j, j_end;
-
-   if (y <= 0)
-      return;
-
-   if (stbi__flip_vertically_on_write)
-      vdir *= -1;
-
-   if (vdir < 0) {
-      j_end = -1; j = y-1;
-   } else {
-      j_end =  y; j = 0;
-   }
-
-   for (; j != j_end; j += vdir) {
-      for (i=0; i < x; ++i) {
-         unsigned char *d = (unsigned char *) data + (j*x+i)*comp;
-         stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);
-      }
-      stbiw__write_flush(s);
-      s->func(s->context, &zero, scanline_pad);
-   }
-}
-
-static int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...)
-{
-   if (y < 0 || x < 0) {
-      return 0;
-   } else {
-      va_list v;
-      va_start(v, fmt);
-      stbiw__writefv(s, fmt, v);
-      va_end(v);
-      stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono);
-      return 1;
-   }
-}
-
-static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)
-{
-   int pad = (-x*3) & 3;
-   return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,
-           "11 4 22 4" "4 44 22 444444",
-           'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40,  // file header
-            40, x,y, 1,24, 0,0,0,0,0,0);             // bitmap header
-}
-
-STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_bmp_core(&s, x, y, comp, data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_bmp_core(&s, x, y, comp, data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif //!STBI_WRITE_NO_STDIO
-
-static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)
-{
-   int has_alpha = (comp == 2 || comp == 4);
-   int colorbytes = has_alpha ? comp-1 : comp;
-   int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3
-
-   if (y < 0 || x < 0)
-      return 0;
-
-   if (!stbi_write_tga_with_rle) {
-      return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,
-         "111 221 2222 11", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);
-   } else {
-      int i,j,k;
-      int jend, jdir;
-
-      stbiw__writef(s, "111 221 2222 11", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);
-
-      if (stbi__flip_vertically_on_write) {
-         j = 0;
-         jend = y;
-         jdir = 1;
-      } else {
-         j = y-1;
-         jend = -1;
-         jdir = -1;
-      }
-      for (; j != jend; j += jdir) {
-         unsigned char *row = (unsigned char *) data + j * x * comp;
-         int len;
-
-         for (i = 0; i < x; i += len) {
-            unsigned char *begin = row + i * comp;
-            int diff = 1;
-            len = 1;
-
-            if (i < x - 1) {
-               ++len;
-               diff = memcmp(begin, row + (i + 1) * comp, comp);
-               if (diff) {
-                  const unsigned char *prev = begin;
-                  for (k = i + 2; k < x && len < 128; ++k) {
-                     if (memcmp(prev, row + k * comp, comp)) {
-                        prev += comp;
-                        ++len;
-                     } else {
-                        --len;
-                        break;
-                     }
-                  }
-               } else {
-                  for (k = i + 2; k < x && len < 128; ++k) {
-                     if (!memcmp(begin, row + k * comp, comp)) {
-                        ++len;
-                     } else {
-                        break;
-                     }
-                  }
-               }
-            }
-
-            if (diff) {
-               unsigned char header = STBIW_UCHAR(len - 1);
-               stbiw__write1(s, header);
-               for (k = 0; k < len; ++k) {
-                  stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);
-               }
-            } else {
-               unsigned char header = STBIW_UCHAR(len - 129);
-               stbiw__write1(s, header);
-               stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);
-            }
-         }
-      }
-      stbiw__write_flush(s);
-   }
-   return 1;
-}
-
-STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_tga_core(&s, x, y, comp, (void *) data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif
-
-// *************************************************************************************************
-// Radiance RGBE HDR writer
-// by Baldur Karlsson
-
-#define stbiw__max(a, b)  ((a) > (b) ? (a) : (b))
-
-static void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)
-{
-   int exponent;
-   float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2]));
-
-   if (maxcomp < 1e-32f) {
-      rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;
-   } else {
-      float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp;
-
-      rgbe[0] = (unsigned char)(linear[0] * normalize);
-      rgbe[1] = (unsigned char)(linear[1] * normalize);
-      rgbe[2] = (unsigned char)(linear[2] * normalize);
-      rgbe[3] = (unsigned char)(exponent + 128);
-   }
-}
-
-static void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)
-{
-   unsigned char lengthbyte = STBIW_UCHAR(length+128);
-   STBIW_ASSERT(length+128 <= 255);
-   s->func(s->context, &lengthbyte, 1);
-   s->func(s->context, &databyte, 1);
-}
-
-static void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)
-{
-   unsigned char lengthbyte = STBIW_UCHAR(length);
-   STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code
-   s->func(s->context, &lengthbyte, 1);
-   s->func(s->context, data, length);
-}
-
-static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)
-{
-   unsigned char scanlineheader[4] = { 2, 2, 0, 0 };
-   unsigned char rgbe[4];
-   float linear[3];
-   int x;
-
-   scanlineheader[2] = (width&0xff00)>>8;
-   scanlineheader[3] = (width&0x00ff);
-
-   /* skip RLE for images too small or large */
-   if (width < 8 || width >= 32768) {
-      for (x=0; x < width; x++) {
-         switch (ncomp) {
-            case 4: /* fallthrough */
-            case 3: linear[2] = scanline[x*ncomp + 2];
-                    linear[1] = scanline[x*ncomp + 1];
-                    linear[0] = scanline[x*ncomp + 0];
-                    break;
-            default:
-                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
-                    break;
-         }
-         stbiw__linear_to_rgbe(rgbe, linear);
-         s->func(s->context, rgbe, 4);
-      }
-   } else {
-      int c,r;
-      /* encode into scratch buffer */
-      for (x=0; x < width; x++) {
-         switch(ncomp) {
-            case 4: /* fallthrough */
-            case 3: linear[2] = scanline[x*ncomp + 2];
-                    linear[1] = scanline[x*ncomp + 1];
-                    linear[0] = scanline[x*ncomp + 0];
-                    break;
-            default:
-                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];
-                    break;
-         }
-         stbiw__linear_to_rgbe(rgbe, linear);
-         scratch[x + width*0] = rgbe[0];
-         scratch[x + width*1] = rgbe[1];
-         scratch[x + width*2] = rgbe[2];
-         scratch[x + width*3] = rgbe[3];
-      }
-
-      s->func(s->context, scanlineheader, 4);
-
-      /* RLE each component separately */
-      for (c=0; c < 4; c++) {
-         unsigned char *comp = &scratch[width*c];
-
-         x = 0;
-         while (x < width) {
-            // find first run
-            r = x;
-            while (r+2 < width) {
-               if (comp[r] == comp[r+1] && comp[r] == comp[r+2])
-                  break;
-               ++r;
-            }
-            if (r+2 >= width)
-               r = width;
-            // dump up to first run
-            while (x < r) {
-               int len = r-x;
-               if (len > 128) len = 128;
-               stbiw__write_dump_data(s, len, &comp[x]);
-               x += len;
-            }
-            // if there's a run, output it
-            if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd
-               // find next byte after run
-               while (r < width && comp[r] == comp[x])
-                  ++r;
-               // output run up to r
-               while (x < r) {
-                  int len = r-x;
-                  if (len > 127) len = 127;
-                  stbiw__write_run_data(s, len, comp[x]);
-                  x += len;
-               }
-            }
-         }
-      }
-   }
-}
-
-static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)
-{
-   if (y <= 0 || x <= 0 || data == NULL)
-      return 0;
-   else {
-      // Each component is stored separately. Allocate scratch space for full output scanline.
-      unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);
-      int i, len;
-      char buffer[128];
-      char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
-      s->func(s->context, header, sizeof(header)-1);
-
-#ifdef __STDC_WANT_SECURE_LIB__
-      len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
-#else
-      len = sprintf(buffer, "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
-#endif
-      s->func(s->context, buffer, len);
-
-      for(i=0; i < y; i++)
-         stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));
-      STBIW_FREE(scratch);
-      return 1;
-   }
-}
-
-STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_hdr_core(&s, x, y, comp, (float *) data);
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif // STBI_WRITE_NO_STDIO
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// PNG writer
-//
-
-#ifndef STBIW_ZLIB_COMPRESS
-// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size()
-#define stbiw__sbraw(a) ((int *) (void *) (a) - 2)
-#define stbiw__sbm(a)   stbiw__sbraw(a)[0]
-#define stbiw__sbn(a)   stbiw__sbraw(a)[1]
-
-#define stbiw__sbneedgrow(a,n)  ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a))
-#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0)
-#define stbiw__sbgrow(a,n)  stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a)))
-
-#define stbiw__sbpush(a, v)      (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v))
-#define stbiw__sbcount(a)        ((a) ? stbiw__sbn(a) : 0)
-#define stbiw__sbfree(a)         ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0)
-
-static void *stbiw__sbgrowf(void **arr, int increment, int itemsize)
-{
-   int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;
-   void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);
-   STBIW_ASSERT(p);
-   if (p) {
-      if (!*arr) ((int *) p)[1] = 0;
-      *arr = (void *) ((int *) p + 2);
-      stbiw__sbm(*arr) = m;
-   }
-   return *arr;
-}
-
-static unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)
-{
-   while (*bitcount >= 8) {
-      stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer));
-      *bitbuffer >>= 8;
-      *bitcount -= 8;
-   }
-   return data;
-}
-
-static int stbiw__zlib_bitrev(int code, int codebits)
-{
-   int res=0;
-   while (codebits--) {
-      res = (res << 1) | (code & 1);
-      code >>= 1;
-   }
-   return res;
-}
-
-static unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit)
-{
-   int i;
-   for (i=0; i < limit && i < 258; ++i)
-      if (a[i] != b[i]) break;
-   return i;
-}
-
-static unsigned int stbiw__zhash(unsigned char *data)
-{
-   stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16);
-   hash ^= hash << 3;
-   hash += hash >> 5;
-   hash ^= hash << 4;
-   hash += hash >> 17;
-   hash ^= hash << 25;
-   hash += hash >> 6;
-   return hash;
-}
-
-#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount))
-#define stbiw__zlib_add(code,codebits) \
-      (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush())
-#define stbiw__zlib_huffa(b,c)  stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c)
-// default huffman tables
-#define stbiw__zlib_huff1(n)  stbiw__zlib_huffa(0x30 + (n), 8)
-#define stbiw__zlib_huff2(n)  stbiw__zlib_huffa(0x190 + (n)-144, 9)
-#define stbiw__zlib_huff3(n)  stbiw__zlib_huffa(0 + (n)-256,7)
-#define stbiw__zlib_huff4(n)  stbiw__zlib_huffa(0xc0 + (n)-280,8)
-#define stbiw__zlib_huff(n)  ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n))
-#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n))
-
-#define stbiw__ZHASH   16384
-
-#endif // STBIW_ZLIB_COMPRESS
-
-STBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)
-{
-#ifdef STBIW_ZLIB_COMPRESS
-   // user provided a zlib compress implementation, use that
-   return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);
-#else // use builtin
-   static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };
-   static unsigned char  lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5,  0 };
-   static unsigned short distc[]   = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };
-   static unsigned char  disteb[]  = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };
-   unsigned int bitbuf=0;
-   int i,j, bitcount=0;
-   unsigned char *out = NULL;
-   unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**));
-   if (hash_table == NULL)
-      return NULL;
-   if (quality < 5) quality = 5;
-
-   stbiw__sbpush(out, 0x78);   // DEFLATE 32K window
-   stbiw__sbpush(out, 0x5e);   // FLEVEL = 1
-   stbiw__zlib_add(1,1);  // BFINAL = 1
-   stbiw__zlib_add(1,2);  // BTYPE = 1 -- fixed huffman
-
-   for (i=0; i < stbiw__ZHASH; ++i)
-      hash_table[i] = NULL;
-
-   i=0;
-   while (i < data_len-3) {
-      // hash next 3 bytes of data to be compressed
-      int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;
-      unsigned char *bestloc = 0;
-      unsigned char **hlist = hash_table[h];
-      int n = stbiw__sbcount(hlist);
-      for (j=0; j < n; ++j) {
-         if (hlist[j]-data > i-32768) { // if entry lies within window
-            int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);
-            if (d >= best) { best=d; bestloc=hlist[j]; }
-         }
-      }
-      // when hash table entry is too long, delete half the entries
-      if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {
-         STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);
-         stbiw__sbn(hash_table[h]) = quality;
-      }
-      stbiw__sbpush(hash_table[h],data+i);
-
-      if (bestloc) {
-         // "lazy matching" - check match at *next* byte, and if it's better, do cur byte as literal
-         h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);
-         hlist = hash_table[h];
-         n = stbiw__sbcount(hlist);
-         for (j=0; j < n; ++j) {
-            if (hlist[j]-data > i-32767) {
-               int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);
-               if (e > best) { // if next match is better, bail on current match
-                  bestloc = NULL;
-                  break;
-               }
-            }
-         }
-      }
-
-      if (bestloc) {
-         int d = (int) (data+i - bestloc); // distance back
-         STBIW_ASSERT(d <= 32767 && best <= 258);
-         for (j=0; best > lengthc[j+1]-1; ++j);
-         stbiw__zlib_huff(j+257);
-         if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);
-         for (j=0; d > distc[j+1]-1; ++j);
-         stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);
-         if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);
-         i += best;
-      } else {
-         stbiw__zlib_huffb(data[i]);
-         ++i;
-      }
-   }
-   // write out final bytes
-   for (;i < data_len; ++i)
-      stbiw__zlib_huffb(data[i]);
-   stbiw__zlib_huff(256); // end of block
-   // pad with 0 bits to byte boundary
-   while (bitcount)
-      stbiw__zlib_add(0,1);
-
-   for (i=0; i < stbiw__ZHASH; ++i)
-      (void) stbiw__sbfree(hash_table[i]);
-   STBIW_FREE(hash_table);
-
-   {
-      // compute adler32 on input
-      unsigned int s1=1, s2=0;
-      int blocklen = (int) (data_len % 5552);
-      j=0;
-      while (j < data_len) {
-         for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; }
-         s1 %= 65521; s2 %= 65521;
-         j += blocklen;
-         blocklen = 5552;
-      }
-      stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8));
-      stbiw__sbpush(out, STBIW_UCHAR(s2));
-      stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));
-      stbiw__sbpush(out, STBIW_UCHAR(s1));
-   }
-   *out_len = stbiw__sbn(out);
-   // make returned pointer freeable
-   STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);
-   return (unsigned char *) stbiw__sbraw(out);
-#endif // STBIW_ZLIB_COMPRESS
-}
-
-static unsigned int stbiw__crc32(unsigned char *buffer, int len)
-{
-#ifdef STBIW_CRC32
-    return STBIW_CRC32(buffer, len);
-#else
-   static unsigned int crc_table[256] =
-   {
-      0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
-      0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
-      0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
-      0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
-      0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
-      0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
-      0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
-      0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
-      0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
-      0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
-      0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
-      0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
-      0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
-      0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
-      0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
-      0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
-      0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
-      0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
-      0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
-      0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
-      0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
-      0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
-      0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
-      0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
-      0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
-      0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
-      0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
-      0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
-      0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
-      0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
-      0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
-      0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
-   };
-
-   unsigned int crc = ~0u;
-   int i;
-   for (i=0; i < len; ++i)
-      crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)];
-   return ~crc;
-#endif
-}
-
-#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4)
-#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v));
-#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3])
-
-static void stbiw__wpcrc(unsigned char **data, int len)
-{
-   unsigned int crc = stbiw__crc32(*data - len - 4, len+4);
-   stbiw__wp32(*data, crc);
-}
-
-static unsigned char stbiw__paeth(int a, int b, int c)
-{
-   int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c);
-   if (pa <= pb && pa <= pc) return STBIW_UCHAR(a);
-   if (pb <= pc) return STBIW_UCHAR(b);
-   return STBIW_UCHAR(c);
-}
-
-// @OPTIMIZE: provide an option that always forces left-predict or paeth predict
-static void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)
-{
-   static int mapping[] = { 0,1,2,3,4 };
-   static int firstmap[] = { 0,1,0,5,6 };
-   int *mymap = (y != 0) ? mapping : firstmap;
-   int i;
-   int type = mymap[filter_type];
-   unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);
-   int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;
-
-   if (type==0) {
-      memcpy(line_buffer, z, width*n);
-      return;
-   }
-
-   // first loop isn't optimized since it's just one pixel
-   for (i = 0; i < n; ++i) {
-      switch (type) {
-         case 1: line_buffer[i] = z[i]; break;
-         case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break;
-         case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break;
-         case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break;
-         case 5: line_buffer[i] = z[i]; break;
-         case 6: line_buffer[i] = z[i]; break;
-      }
-   }
-   switch (type) {
-      case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break;
-      case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break;
-      case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break;
-      case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break;
-      case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break;
-      case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break;
-   }
-}
-
-STBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)
-{
-   int force_filter = stbi_write_force_png_filter;
-   int ctype[5] = { -1, 0, 4, 2, 6 };
-   unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };
-   unsigned char *out,*o, *filt, *zlib;
-   signed char *line_buffer;
-   int j,zlen;
-
-   if (stride_bytes == 0)
-      stride_bytes = x * n;
-
-   if (force_filter >= 5) {
-      force_filter = -1;
-   }
-
-   filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;
-   line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }
-   for (j=0; j < y; ++j) {
-      int filter_type;
-      if (force_filter > -1) {
-         filter_type = force_filter;
-         stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);
-      } else { // Estimate the best filter by running through all of them:
-         int best_filter = 0, best_filter_val = 0x7fffffff, est, i;
-         for (filter_type = 0; filter_type < 5; filter_type++) {
-            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);
-
-            // Estimate the entropy of the line using this filter; the less, the better.
-            est = 0;
-            for (i = 0; i < x*n; ++i) {
-               est += abs((signed char) line_buffer[i]);
-            }
-            if (est < best_filter_val) {
-               best_filter_val = est;
-               best_filter = filter_type;
-            }
-         }
-         if (filter_type != best_filter) {  // If the last iteration already got us the best filter, don't redo it
-            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);
-            filter_type = best_filter;
-         }
-      }
-      // when we get here, filter_type contains the filter type, and line_buffer contains the data
-      filt[j*(x*n+1)] = (unsigned char) filter_type;
-      STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);
-   }
-   STBIW_FREE(line_buffer);
-   zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);
-   STBIW_FREE(filt);
-   if (!zlib) return 0;
-
-   // each tag requires 12 bytes of overhead
-   out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);
-   if (!out) return 0;
-   *out_len = 8 + 12+13 + 12+zlen + 12;
-
-   o=out;
-   STBIW_MEMMOVE(o,sig,8); o+= 8;
-   stbiw__wp32(o, 13); // header length
-   stbiw__wptag(o, "IHDR");
-   stbiw__wp32(o, x);
-   stbiw__wp32(o, y);
-   *o++ = 8;
-   *o++ = STBIW_UCHAR(ctype[n]);
-   *o++ = 0;
-   *o++ = 0;
-   *o++ = 0;
-   stbiw__wpcrc(&o,13);
-
-   stbiw__wp32(o, zlen);
-   stbiw__wptag(o, "IDAT");
-   STBIW_MEMMOVE(o, zlib, zlen);
-   o += zlen;
-   STBIW_FREE(zlib);
-   stbiw__wpcrc(&o, zlen);
-
-   stbiw__wp32(o,0);
-   stbiw__wptag(o, "IEND");
-   stbiw__wpcrc(&o,0);
-
-   STBIW_ASSERT(o == out + *out_len);
-
-   return out;
-}
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
-{
-   FILE *f;
-   int len;
-   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
-   if (png == NULL) return 0;
-
-   f = stbiw__fopen(filename, "wb");
-   if (!f) { STBIW_FREE(png); return 0; }
-   fwrite(png, 1, len, f);
-   fclose(f);
-   STBIW_FREE(png);
-   return 1;
-}
-#endif
-
-STBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)
-{
-   int len;
-   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);
-   if (png == NULL) return 0;
-   func(context, png, len);
-   STBIW_FREE(png);
-   return 1;
-}
-
-
-/* ***************************************************************************
- *
- * JPEG writer
- *
- * This is based on Jon Olick's jo_jpeg.cpp:
- * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html
- */
-
-static const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,
-      24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };
-
-static void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {
-   int bitBuf = *bitBufP, bitCnt = *bitCntP;
-   bitCnt += bs[1];
-   bitBuf |= bs[0] << (24 - bitCnt);
-   while(bitCnt >= 8) {
-      unsigned char c = (bitBuf >> 16) & 255;
-      stbiw__putc(s, c);
-      if(c == 255) {
-         stbiw__putc(s, 0);
-      }
-      bitBuf <<= 8;
-      bitCnt -= 8;
-   }
-   *bitBufP = bitBuf;
-   *bitCntP = bitCnt;
-}
-
-static void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) {
-   float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;
-   float z1, z2, z3, z4, z5, z11, z13;
-
-   float tmp0 = d0 + d7;
-   float tmp7 = d0 - d7;
-   float tmp1 = d1 + d6;
-   float tmp6 = d1 - d6;
-   float tmp2 = d2 + d5;
-   float tmp5 = d2 - d5;
-   float tmp3 = d3 + d4;
-   float tmp4 = d3 - d4;
-
-   // Even part
-   float tmp10 = tmp0 + tmp3;   // phase 2
-   float tmp13 = tmp0 - tmp3;
-   float tmp11 = tmp1 + tmp2;
-   float tmp12 = tmp1 - tmp2;
-
-   d0 = tmp10 + tmp11;       // phase 3
-   d4 = tmp10 - tmp11;
-
-   z1 = (tmp12 + tmp13) * 0.707106781f; // c4
-   d2 = tmp13 + z1;       // phase 5
-   d6 = tmp13 - z1;
-
-   // Odd part
-   tmp10 = tmp4 + tmp5;       // phase 2
-   tmp11 = tmp5 + tmp6;
-   tmp12 = tmp6 + tmp7;
-
-   // The rotator is modified from fig 4-8 to avoid extra negations.
-   z5 = (tmp10 - tmp12) * 0.382683433f; // c6
-   z2 = tmp10 * 0.541196100f + z5; // c2-c6
-   z4 = tmp12 * 1.306562965f + z5; // c2+c6
-   z3 = tmp11 * 0.707106781f; // c4
-
-   z11 = tmp7 + z3;      // phase 5
-   z13 = tmp7 - z3;
-
-   *d5p = z13 + z2;         // phase 6
-   *d3p = z13 - z2;
-   *d1p = z11 + z4;
-   *d7p = z11 - z4;
-
-   *d0p = d0;  *d2p = d2;  *d4p = d4;  *d6p = d6;
-}
-
-static void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {
-   int tmp1 = val < 0 ? -val : val;
-   val = val < 0 ? val-1 : val;
-   bits[1] = 1;
-   while(tmp1 >>= 1) {
-      ++bits[1];
-   }
-   bits[0] = val & ((1<<bits[1])-1);
-}
-
-static int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, int du_stride, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) {
-   const unsigned short EOB[2] = { HTAC[0x00][0], HTAC[0x00][1] };
-   const unsigned short M16zeroes[2] = { HTAC[0xF0][0], HTAC[0xF0][1] };
-   int dataOff, i, j, n, diff, end0pos, x, y;
-   int DU[64];
-
-   // DCT rows
-   for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) {
-      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]);
-   }
-   // DCT columns
-   for(dataOff=0; dataOff<8; ++dataOff) {
-      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4],
-                     &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]);
-   }
-   // Quantize/descale/zigzag the coefficients
-   for(y = 0, j=0; y < 8; ++y) {
-      for(x = 0; x < 8; ++x,++j) {
-         float v;
-         i = y*du_stride+x;
-         v = CDU[i]*fdtbl[j];
-         // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f));
-         // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway?
-         DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f);
-      }
-   }
-
-   // Encode DC
-   diff = DU[0] - DC;
-   if (diff == 0) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);
-   } else {
-      unsigned short bits[2];
-      stbiw__jpg_calcBits(diff, bits);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
-   }
-   // Encode ACs
-   end0pos = 63;
-   for(; (end0pos>0)&&(DU[end0pos]==0); --end0pos) {
-   }
-   // end0pos = first element in reverse order !=0
-   if(end0pos == 0) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
-      return DU[0];
-   }
-   for(i = 1; i <= end0pos; ++i) {
-      int startpos = i;
-      int nrzeroes;
-      unsigned short bits[2];
-      for (; DU[i]==0 && i<=end0pos; ++i) {
-      }
-      nrzeroes = i-startpos;
-      if ( nrzeroes >= 16 ) {
-         int lng = nrzeroes>>4;
-         int nrmarker;
-         for (nrmarker=1; nrmarker <= lng; ++nrmarker)
-            stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);
-         nrzeroes &= 15;
-      }
-      stbiw__jpg_calcBits(DU[i], bits);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);
-   }
-   if(end0pos != 63) {
-      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);
-   }
-   return DU[0];
-}
-
-static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {
-   // Constants that don't pollute global namespace
-   static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};
-   static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
-   static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};
-   static const unsigned char std_ac_luminance_values[] = {
-      0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,
-      0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,
-      0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,
-      0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,
-      0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,
-      0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,
-      0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
-   };
-   static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};
-   static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};
-   static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};
-   static const unsigned char std_ac_chrominance_values[] = {
-      0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,
-      0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,
-      0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,
-      0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,
-      0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,
-      0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,
-      0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa
-   };
-   // Huffman tables
-   static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};
-   static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};
-   static const unsigned short YAC_HT[256][2] = {
-      {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
-   };
-   static const unsigned short UVAC_HT[256][2] = {
-      {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0},
-      {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}
-   };
-   static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,
-                             37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99};
-   static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,
-                              99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99};
-   static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f,
-                                 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f };
-
-   int row, col, i, k, subsample;
-   float fdtbl_Y[64], fdtbl_UV[64];
-   unsigned char YTable[64], UVTable[64];
-
-   if(!data || !width || !height || comp > 4 || comp < 1) {
-      return 0;
-   }
-
-   quality = quality ? quality : 90;
-   subsample = quality <= 90 ? 1 : 0;
-   quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;
-   quality = quality < 50 ? 5000 / quality : 200 - quality * 2;
-
-   for(i = 0; i < 64; ++i) {
-      int uvti, yti = (YQT[i]*quality+50)/100;
-      YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);
-      uvti = (UVQT[i]*quality+50)/100;
-      UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);
-   }
-
-   for(row = 0, k = 0; row < 8; ++row) {
-      for(col = 0; col < 8; ++col, ++k) {
-         fdtbl_Y[k]  = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
-         fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);
-      }
-   }
-
-   // Write Headers
-   {
-      static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };
-      static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };
-      const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width),
-                                      3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };
-      s->func(s->context, (void*)head0, sizeof(head0));
-      s->func(s->context, (void*)YTable, sizeof(YTable));
-      stbiw__putc(s, 1);
-      s->func(s->context, UVTable, sizeof(UVTable));
-      s->func(s->context, (void*)head1, sizeof(head1));
-      s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1);
-      s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values));
-      stbiw__putc(s, 0x10); // HTYACinfo
-      s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1);
-      s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values));
-      stbiw__putc(s, 1); // HTUDCinfo
-      s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1);
-      s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values));
-      stbiw__putc(s, 0x11); // HTUACinfo
-      s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1);
-      s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values));
-      s->func(s->context, (void*)head2, sizeof(head2));
-   }
-
-   // Encode 8x8 macroblocks
-   {
-      static const unsigned short fillBits[] = {0x7F, 7};
-      int DCY=0, DCU=0, DCV=0;
-      int bitBuf=0, bitCnt=0;
-      // comp == 2 is grey+alpha (alpha is ignored)
-      int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;
-      const unsigned char *dataR = (const unsigned char *)data;
-      const unsigned char *dataG = dataR + ofsG;
-      const unsigned char *dataB = dataR + ofsB;
-      int x, y, pos;
-      if(subsample) {
-         for(y = 0; y < height; y += 16) {
-            for(x = 0; x < width; x += 16) {
-               float Y[256], U[256], V[256];
-               for(row = y, pos = 0; row < y+16; ++row) {
-                  // row >= height => use last input row
-                  int clamped_row = (row < height) ? row : height - 1;
-                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
-                  for(col = x; col < x+16; ++col, ++pos) {
-                     // if col >= width => use pixel from last input column
-                     int p = base_p + ((col < width) ? col : (width-1))*comp;
-                     float r = dataR[p], g = dataG[p], b = dataB[p];
-                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
-                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
-                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
-                  }
-               }
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);
-
-               // subsample U,V
-               {
-                  float subU[64], subV[64];
-                  int yy, xx;
-                  for(yy = 0, pos = 0; yy < 8; ++yy) {
-                     for(xx = 0; xx < 8; ++xx, ++pos) {
-                        int j = yy*32+xx*2;
-                        subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f;
-                        subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f;
-                     }
-                  }
-                  DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
-                  DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
-               }
-            }
-         }
-      } else {
-         for(y = 0; y < height; y += 8) {
-            for(x = 0; x < width; x += 8) {
-               float Y[64], U[64], V[64];
-               for(row = y, pos = 0; row < y+8; ++row) {
-                  // row >= height => use last input row
-                  int clamped_row = (row < height) ? row : height - 1;
-                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;
-                  for(col = x; col < x+8; ++col, ++pos) {
-                     // if col >= width => use pixel from last input column
-                     int p = base_p + ((col < width) ? col : (width-1))*comp;
-                     float r = dataR[p], g = dataG[p], b = dataB[p];
-                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;
-                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;
-                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;
-                  }
-               }
-
-               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y,  DCY, YDC_HT, YAC_HT);
-               DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
-               DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
-            }
-         }
-      }
-
-      // Do the bit alignment of the EOI marker
-      stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits);
-   }
-
-   // EOI
-   stbiw__putc(s, 0xFF);
-   stbiw__putc(s, 0xD9);
-
-   return 1;
-}
-
-STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)
-{
-   stbi__write_context s = { 0 };
-   stbi__start_write_callbacks(&s, func, context);
-   return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);
-}
-
-
-#ifndef STBI_WRITE_NO_STDIO
-STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)
-{
-   stbi__write_context s = { 0 };
-   if (stbi__start_write_file(&s,filename)) {
-      int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);
-      stbi__end_write_file(&s);
-      return r;
-   } else
-      return 0;
-}
-#endif
-
-#endif // STB_IMAGE_WRITE_IMPLEMENTATION
-
-/* Revision history
-      1.14  (2020-02-02) updated JPEG writer to downsample chroma channels
-      1.13
-      1.12
-      1.11  (2019-08-11)
-
-      1.10  (2019-02-07)
-             support utf8 filenames in Windows; fix warnings and platform ifdefs
-      1.09  (2018-02-11)
-             fix typo in zlib quality API, improve STB_I_W_STATIC in C++
-      1.08  (2018-01-29)
-             add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter
-      1.07  (2017-07-24)
-             doc fix
-      1.06 (2017-07-23)
-             writing JPEG (using Jon Olick's code)
-      1.05   ???
-      1.04 (2017-03-03)
-             monochrome BMP expansion
-      1.03   ???
-      1.02 (2016-04-02)
-             avoid allocating large structures on the stack
-      1.01 (2016-01-16)
-             STBIW_REALLOC_SIZED: support allocators with no realloc support
-             avoid race-condition in crc initialization
-             minor compile issues
-      1.00 (2015-09-14)
-             installable file IO function
-      0.99 (2015-09-13)
-             warning fixes; TGA rle support
-      0.98 (2015-04-08)
-             added STBIW_MALLOC, STBIW_ASSERT etc
-      0.97 (2015-01-18)
-             fixed HDR asserts, rewrote HDR rle logic
-      0.96 (2015-01-17)
-             add HDR output
-             fix monochrome BMP
-      0.95 (2014-08-17)
-                      add monochrome TGA output
-      0.94 (2014-05-31)
-             rename private functions to avoid conflicts with stb_image.h
-      0.93 (2014-05-27)
-             warning fixes
-      0.92 (2010-08-01)
-             casts to unsigned char to fix warnings
-      0.91 (2010-07-17)
-             first public release
-      0.90   first internal release
-*/
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_perlin.h b/raylib_pi4_test/external/stb_perlin.h
deleted file mode 100644 (file)
index 47cb9a4..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-// stb_perlin.h - v0.5 - perlin noise
-// public domain single-file C implementation by Sean Barrett
-//
-// LICENSE
-//
-//   See end of file.
-//
-//
-// to create the implementation,
-//     #define STB_PERLIN_IMPLEMENTATION
-// in *one* C/CPP file that includes this file.
-//
-//
-// Documentation:
-//
-// float  stb_perlin_noise3( float x,
-//                           float y,
-//                           float z,
-//                           int   x_wrap=0,
-//                           int   y_wrap=0,
-//                           int   z_wrap=0)
-//
-// This function computes a random value at the coordinate (x,y,z).
-// Adjacent random values are continuous but the noise fluctuates
-// its randomness with period 1, i.e. takes on wholly unrelated values
-// at integer points. Specifically, this implements Ken Perlin's
-// revised noise function from 2002.
-//
-// The "wrap" parameters can be used to create wraparound noise that
-// wraps at powers of two. The numbers MUST be powers of two. Specify
-// 0 to mean "don't care". (The noise always wraps every 256 due
-// details of the implementation, even if you ask for larger or no
-// wrapping.)
-//
-// float  stb_perlin_noise3_seed( float x,
-//                                float y,
-//                                float z,
-//                                int   x_wrap=0,
-//                                int   y_wrap=0,
-//                                int   z_wrap=0,
-//                                int   seed)
-//
-// As above, but 'seed' selects from multiple different variations of the
-// noise function. The current implementation only uses the bottom 8 bits
-// of 'seed', but possibly in the future more bits will be used.
-//
-//
-// Fractal Noise:
-//
-// Three common fractal noise functions are included, which produce
-// a wide variety of nice effects depending on the parameters
-// provided. Note that each function will call stb_perlin_noise3
-// 'octaves' times, so this parameter will affect runtime.
-//
-// float stb_perlin_ridge_noise3(float x, float y, float z,
-//                               float lacunarity, float gain, float offset, int octaves)
-//
-// float stb_perlin_fbm_noise3(float x, float y, float z,
-//                             float lacunarity, float gain, int octaves)
-//
-// float stb_perlin_turbulence_noise3(float x, float y, float z,
-//                                    float lacunarity, float gain, int octaves)
-//
-// Typical values to start playing with:
-//     octaves    =   6     -- number of "octaves" of noise3() to sum
-//     lacunarity = ~ 2.0   -- spacing between successive octaves (use exactly 2.0 for wrapping output)
-//     gain       =   0.5   -- relative weighting applied to each successive octave
-//     offset     =   1.0?  -- used to invert the ridges, may need to be larger, not sure
-//
-//
-// Contributors:
-//    Jack Mott - additional noise functions
-//    Jordan Peck - seeded noise
-//
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap);
-extern float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed);
-extern float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves);
-extern float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
-extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves);
-extern float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed);
-#ifdef __cplusplus
-}
-#endif
-
-#ifdef STB_PERLIN_IMPLEMENTATION
-
-#include <math.h> // fabs()
-
-// not same permutation table as Perlin's reference to avoid copyright issues;
-// Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/
-static unsigned char stb__perlin_randtab[512] =
-{
-   23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
-   152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
-   175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
-   8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
-   225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
-   94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
-   165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
-   65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
-   26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
-   250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
-   132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
-   91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
-   38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
-   131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
-   27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
-   61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
-
-   // and a second copy so we don't need an extra mask or static initializer
-   23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123,
-   152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72,
-   175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240,
-   8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57,
-   225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233,
-   94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172,
-   165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243,
-   65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122,
-   26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76,
-   250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246,
-   132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3,
-   91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231,
-   38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221,
-   131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62,
-   27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135,
-   61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5,
-};
-
-
-// perlin's gradient has 12 cases so some get used 1/16th of the time
-// and some 2/16ths. We reduce bias by changing those fractions
-// to 5/64ths and 6/64ths
-
-// this array is designed to match the previous implementation
-// of gradient hash: indices[stb__perlin_randtab[i]&63]
-static unsigned char stb__perlin_randtab_grad_idx[512] =
-{
-    7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
-    8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
-    7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
-    8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
-    5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
-    2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
-    9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
-    1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
-    10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
-    6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
-    4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
-    11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
-    10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
-    3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
-    11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
-    9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
-
-    // and a second copy so we don't need an extra mask or static initializer
-    7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7,
-    8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8,
-    7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8,
-    8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5,
-    5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1,
-    2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4,
-    9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11,
-    1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6,
-    10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0,
-    6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2,
-    4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3,
-    11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11,
-    10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1,
-    3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10,
-    11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7,
-    9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5,
-};
-
-static float stb__perlin_lerp(float a, float b, float t)
-{
-   return a + (b-a) * t;
-}
-
-static int stb__perlin_fastfloor(float a)
-{
-    int ai = (int) a;
-    return (a < ai) ? ai-1 : ai;
-}
-
-// different grad function from Perlin's, but easy to modify to match reference
-static float stb__perlin_grad(int grad_idx, float x, float y, float z)
-{
-   static float basis[12][4] =
-   {
-      {  1, 1, 0 },
-      { -1, 1, 0 },
-      {  1,-1, 0 },
-      { -1,-1, 0 },
-      {  1, 0, 1 },
-      { -1, 0, 1 },
-      {  1, 0,-1 },
-      { -1, 0,-1 },
-      {  0, 1, 1 },
-      {  0,-1, 1 },
-      {  0, 1,-1 },
-      {  0,-1,-1 },
-   };
-
-   float *grad = basis[grad_idx];
-   return grad[0]*x + grad[1]*y + grad[2]*z;
-}
-
-float stb_perlin_noise3_internal(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
-{
-   float u,v,w;
-   float n000,n001,n010,n011,n100,n101,n110,n111;
-   float n00,n01,n10,n11;
-   float n0,n1;
-
-   unsigned int x_mask = (x_wrap-1) & 255;
-   unsigned int y_mask = (y_wrap-1) & 255;
-   unsigned int z_mask = (z_wrap-1) & 255;
-   int px = stb__perlin_fastfloor(x);
-   int py = stb__perlin_fastfloor(y);
-   int pz = stb__perlin_fastfloor(z);
-   int x0 = px & x_mask, x1 = (px+1) & x_mask;
-   int y0 = py & y_mask, y1 = (py+1) & y_mask;
-   int z0 = pz & z_mask, z1 = (pz+1) & z_mask;
-   int r0,r1, r00,r01,r10,r11;
-
-   #define stb__perlin_ease(a)   (((a*6-15)*a + 10) * a * a * a)
-
-   x -= px; u = stb__perlin_ease(x);
-   y -= py; v = stb__perlin_ease(y);
-   z -= pz; w = stb__perlin_ease(z);
-
-   r0 = stb__perlin_randtab[x0+seed];
-   r1 = stb__perlin_randtab[x1+seed];
-
-   r00 = stb__perlin_randtab[r0+y0];
-   r01 = stb__perlin_randtab[r0+y1];
-   r10 = stb__perlin_randtab[r1+y0];
-   r11 = stb__perlin_randtab[r1+y1];
-
-   n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x  , y  , z   );
-   n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x  , y  , z-1 );
-   n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x  , y-1, z   );
-   n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x  , y-1, z-1 );
-   n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y  , z   );
-   n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y  , z-1 );
-   n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z   );
-   n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
-
-   n00 = stb__perlin_lerp(n000,n001,w);
-   n01 = stb__perlin_lerp(n010,n011,w);
-   n10 = stb__perlin_lerp(n100,n101,w);
-   n11 = stb__perlin_lerp(n110,n111,w);
-
-   n0 = stb__perlin_lerp(n00,n01,v);
-   n1 = stb__perlin_lerp(n10,n11,v);
-
-   return stb__perlin_lerp(n0,n1,u);
-}
-
-float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap)
-{
-    return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap,0);
-}
-
-float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed)
-{
-    return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap, (unsigned char) seed);
-}
-
-float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float prev = 1.0f;
-   float amplitude = 0.5f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i);
-      r = offset - (float) fabs(r);
-      r = r*r;
-      sum += r*amplitude*prev;
-      prev = r;
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float amplitude = 1.0f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      sum += stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves)
-{
-   int i;
-   float frequency = 1.0f;
-   float amplitude = 1.0f;
-   float sum = 0.0f;
-
-   for (i = 0; i < octaves; i++) {
-      float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude;
-      sum += (float) fabs(r);
-      frequency *= lacunarity;
-      amplitude *= gain;
-   }
-   return sum;
-}
-
-float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed)
-{
-   float u,v,w;
-   float n000,n001,n010,n011,n100,n101,n110,n111;
-   float n00,n01,n10,n11;
-   float n0,n1;
-
-   int px = stb__perlin_fastfloor(x);
-   int py = stb__perlin_fastfloor(y);
-   int pz = stb__perlin_fastfloor(z);
-   int x_wrap2 = (x_wrap ? x_wrap : 256);
-   int y_wrap2 = (y_wrap ? y_wrap : 256);
-   int z_wrap2 = (z_wrap ? z_wrap : 256);
-   int x0 = px % x_wrap2, x1;
-   int y0 = py % y_wrap2, y1;
-   int z0 = pz % z_wrap2, z1;
-   int r0,r1, r00,r01,r10,r11;
-
-   if (x0 < 0) x0 += x_wrap2;
-   if (y0 < 0) y0 += y_wrap2;
-   if (z0 < 0) z0 += z_wrap2;
-   x1 = (x0+1) % x_wrap2;
-   y1 = (y0+1) % y_wrap2;
-   z1 = (z0+1) % z_wrap2;
-
-   #define stb__perlin_ease(a)   (((a*6-15)*a + 10) * a * a * a)
-
-   x -= px; u = stb__perlin_ease(x);
-   y -= py; v = stb__perlin_ease(y);
-   z -= pz; w = stb__perlin_ease(z);
-
-   r0 = stb__perlin_randtab[x0];
-   r0 = stb__perlin_randtab[r0+seed];
-   r1 = stb__perlin_randtab[x1];
-   r1 = stb__perlin_randtab[r1+seed];
-
-   r00 = stb__perlin_randtab[r0+y0];
-   r01 = stb__perlin_randtab[r0+y1];
-   r10 = stb__perlin_randtab[r1+y0];
-   r11 = stb__perlin_randtab[r1+y1];
-
-   n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x  , y  , z   );
-   n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x  , y  , z-1 );
-   n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x  , y-1, z   );
-   n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x  , y-1, z-1 );
-   n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y  , z   );
-   n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y  , z-1 );
-   n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z   );
-   n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 );
-
-   n00 = stb__perlin_lerp(n000,n001,w);
-   n01 = stb__perlin_lerp(n010,n011,w);
-   n10 = stb__perlin_lerp(n100,n101,w);
-   n11 = stb__perlin_lerp(n110,n111,w);
-
-   n0 = stb__perlin_lerp(n00,n01,v);
-   n1 = stb__perlin_lerp(n10,n11,v);
-
-   return stb__perlin_lerp(n0,n1,u);
-}
-#endif  // STB_PERLIN_IMPLEMENTATION
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_rect_pack.h b/raylib_pi4_test/external/stb_rect_pack.h
deleted file mode 100644 (file)
index 5c848de..0000000
+++ /dev/null
@@ -1,628 +0,0 @@
-// stb_rect_pack.h - v1.00 - public domain - rectangle packing
-// Sean Barrett 2014
-//
-// Useful for e.g. packing rectangular textures into an atlas.
-// Does not do rotation.
-//
-// Not necessarily the awesomest packing method, but better than
-// the totally naive one in stb_truetype (which is primarily what
-// this is meant to replace).
-//
-// Has only had a few tests run, may have issues.
-//
-// More docs to come.
-//
-// No memory allocations; uses qsort() and assert() from stdlib.
-// Can override those by defining STBRP_SORT and STBRP_ASSERT.
-//
-// This library currently uses the Skyline Bottom-Left algorithm.
-//
-// Please note: better rectangle packers are welcome! Please
-// implement them to the same API, but with a different init
-// function.
-//
-// Credits
-//
-//  Library
-//    Sean Barrett
-//  Minor features
-//    Martins Mozeiko
-//    github:IntellectualKitty
-//
-//  Bugfixes / warning fixes
-//    Jeremy Jaussaud
-//    Fabian Giesen
-//
-// Version history:
-//
-//     1.00  (2019-02-25)  avoid small space waste; gracefully fail too-wide rectangles
-//     0.99  (2019-02-07)  warning fixes
-//     0.11  (2017-03-03)  return packing success/fail result
-//     0.10  (2016-10-25)  remove cast-away-const to avoid warnings
-//     0.09  (2016-08-27)  fix compiler warnings
-//     0.08  (2015-09-13)  really fix bug with empty rects (w=0 or h=0)
-//     0.07  (2015-09-13)  fix bug with empty rects (w=0 or h=0)
-//     0.06  (2015-04-15)  added STBRP_SORT to allow replacing qsort
-//     0.05:  added STBRP_ASSERT to allow replacing assert
-//     0.04:  fixed minor bug in STBRP_LARGE_RECTS support
-//     0.01:  initial release
-//
-// LICENSE
-//
-//   See end of file for license information.
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//       INCLUDE SECTION
-//
-
-#ifndef STB_INCLUDE_STB_RECT_PACK_H
-#define STB_INCLUDE_STB_RECT_PACK_H
-
-#define STB_RECT_PACK_VERSION  1
-
-#ifdef STBRP_STATIC
-#define STBRP_DEF static
-#else
-#define STBRP_DEF extern
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct stbrp_context stbrp_context;
-typedef struct stbrp_node    stbrp_node;
-typedef struct stbrp_rect    stbrp_rect;
-
-#ifdef STBRP_LARGE_RECTS
-typedef int            stbrp_coord;
-#else
-typedef unsigned short stbrp_coord;
-#endif
-
-STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
-// Assign packed locations to rectangles. The rectangles are of type
-// 'stbrp_rect' defined below, stored in the array 'rects', and there
-// are 'num_rects' many of them.
-//
-// Rectangles which are successfully packed have the 'was_packed' flag
-// set to a non-zero value and 'x' and 'y' store the minimum location
-// on each axis (i.e. bottom-left in cartesian coordinates, top-left
-// if you imagine y increasing downwards). Rectangles which do not fit
-// have the 'was_packed' flag set to 0.
-//
-// You should not try to access the 'rects' array from another thread
-// while this function is running, as the function temporarily reorders
-// the array while it executes.
-//
-// To pack into another rectangle, you need to call stbrp_init_target
-// again. To continue packing into the same rectangle, you can call
-// this function again. Calling this multiple times with multiple rect
-// arrays will probably produce worse packing results than calling it
-// a single time with the full rectangle array, but the option is
-// available.
-//
-// The function returns 1 if all of the rectangles were successfully
-// packed and 0 otherwise.
-
-struct stbrp_rect
-{
-   // reserved for your use:
-   int            id;
-
-   // input:
-   stbrp_coord    w, h;
-
-   // output:
-   stbrp_coord    x, y;
-   int            was_packed;  // non-zero if valid packing
-
-}; // 16 bytes, nominally
-
-
-STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
-// Initialize a rectangle packer to:
-//    pack a rectangle that is 'width' by 'height' in dimensions
-//    using temporary storage provided by the array 'nodes', which is 'num_nodes' long
-//
-// You must call this function every time you start packing into a new target.
-//
-// There is no "shutdown" function. The 'nodes' memory must stay valid for
-// the following stbrp_pack_rects() call (or calls), but can be freed after
-// the call (or calls) finish.
-//
-// Note: to guarantee best results, either:
-//       1. make sure 'num_nodes' >= 'width'
-//   or  2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
-//
-// If you don't do either of the above things, widths will be quantized to multiples
-// of small integers to guarantee the algorithm doesn't run out of temporary storage.
-//
-// If you do #2, then the non-quantized algorithm will be used, but the algorithm
-// may run out of temporary storage and be unable to pack some rectangles.
-
-STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
-// Optionally call this function after init but before doing any packing to
-// change the handling of the out-of-temp-memory scenario, described above.
-// If you call init again, this will be reset to the default (false).
-
-
-STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
-// Optionally select which packing heuristic the library should use. Different
-// heuristics will produce better/worse results for different data sets.
-// If you call init again, this will be reset to the default.
-
-enum
-{
-   STBRP_HEURISTIC_Skyline_default=0,
-   STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
-   STBRP_HEURISTIC_Skyline_BF_sortHeight
-};
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// the details of the following structures don't matter to you, but they must
-// be visible so you can handle the memory allocations for them
-
-struct stbrp_node
-{
-   stbrp_coord  x,y;
-   stbrp_node  *next;
-};
-
-struct stbrp_context
-{
-   int width;
-   int height;
-   int align;
-   int init_mode;
-   int heuristic;
-   int num_nodes;
-   stbrp_node *active_head;
-   stbrp_node *free_head;
-   stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//     IMPLEMENTATION SECTION
-//
-
-#ifdef STB_RECT_PACK_IMPLEMENTATION
-#ifndef STBRP_SORT
-#include <stdlib.h>
-#define STBRP_SORT qsort
-#endif
-
-#ifndef STBRP_ASSERT
-#include <assert.h>
-#define STBRP_ASSERT assert
-#endif
-
-#ifdef _MSC_VER
-#define STBRP__NOTUSED(v)  (void)(v)
-#else
-#define STBRP__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-enum
-{
-   STBRP__INIT_skyline = 1
-};
-
-STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
-{
-   switch (context->init_mode) {
-      case STBRP__INIT_skyline:
-         STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
-         context->heuristic = heuristic;
-         break;
-      default:
-         STBRP_ASSERT(0);
-   }
-}
-
-STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
-{
-   if (allow_out_of_mem)
-      // if it's ok to run out of memory, then don't bother aligning them;
-      // this gives better packing, but may fail due to OOM (even though
-      // the rectangles easily fit). @TODO a smarter approach would be to only
-      // quantize once we've hit OOM, then we could get rid of this parameter.
-      context->align = 1;
-   else {
-      // if it's not ok to run out of memory, then quantize the widths
-      // so that num_nodes is always enough nodes.
-      //
-      // I.e. num_nodes * align >= width
-      //                  align >= width / num_nodes
-      //                  align = ceil(width/num_nodes)
-
-      context->align = (context->width + context->num_nodes-1) / context->num_nodes;
-   }
-}
-
-STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
-{
-   int i;
-#ifndef STBRP_LARGE_RECTS
-   STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
-#endif
-
-   for (i=0; i < num_nodes-1; ++i)
-      nodes[i].next = &nodes[i+1];
-   nodes[i].next = NULL;
-   context->init_mode = STBRP__INIT_skyline;
-   context->heuristic = STBRP_HEURISTIC_Skyline_default;
-   context->free_head = &nodes[0];
-   context->active_head = &context->extra[0];
-   context->width = width;
-   context->height = height;
-   context->num_nodes = num_nodes;
-   stbrp_setup_allow_out_of_mem(context, 0);
-
-   // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
-   context->extra[0].x = 0;
-   context->extra[0].y = 0;
-   context->extra[0].next = &context->extra[1];
-   context->extra[1].x = (stbrp_coord) width;
-#ifdef STBRP_LARGE_RECTS
-   context->extra[1].y = (1<<30);
-#else
-   context->extra[1].y = 65535;
-#endif
-   context->extra[1].next = NULL;
-}
-
-// find minimum y position if it starts at x1
-static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
-{
-   stbrp_node *node = first;
-   int x1 = x0 + width;
-   int min_y, visited_width, waste_area;
-
-   STBRP__NOTUSED(c);
-
-   STBRP_ASSERT(first->x <= x0);
-
-   #if 0
-   // skip in case we're past the node
-   while (node->next->x <= x0)
-      ++node;
-   #else
-   STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
-   #endif
-
-   STBRP_ASSERT(node->x <= x0);
-
-   min_y = 0;
-   waste_area = 0;
-   visited_width = 0;
-   while (node->x < x1) {
-      if (node->y > min_y) {
-         // raise min_y higher.
-         // we've accounted for all waste up to min_y,
-         // but we'll now add more waste for everything we've visted
-         waste_area += visited_width * (node->y - min_y);
-         min_y = node->y;
-         // the first time through, visited_width might be reduced
-         if (node->x < x0)
-            visited_width += node->next->x - x0;
-         else
-            visited_width += node->next->x - node->x;
-      } else {
-         // add waste area
-         int under_width = node->next->x - node->x;
-         if (under_width + visited_width > width)
-            under_width = width - visited_width;
-         waste_area += under_width * (min_y - node->y);
-         visited_width += under_width;
-      }
-      node = node->next;
-   }
-
-   *pwaste = waste_area;
-   return min_y;
-}
-
-typedef struct
-{
-   int x,y;
-   stbrp_node **prev_link;
-} stbrp__findresult;
-
-static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
-{
-   int best_waste = (1<<30), best_x, best_y = (1 << 30);
-   stbrp__findresult fr;
-   stbrp_node **prev, *node, *tail, **best = NULL;
-
-   // align to multiple of c->align
-   width = (width + c->align - 1);
-   width -= width % c->align;
-   STBRP_ASSERT(width % c->align == 0);
-
-   // if it can't possibly fit, bail immediately
-   if (width > c->width || height > c->height) {
-      fr.prev_link = NULL;
-      fr.x = fr.y = 0;
-      return fr;
-   }
-
-   node = c->active_head;
-   prev = &c->active_head;
-   while (node->x + width <= c->width) {
-      int y,waste;
-      y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
-      if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
-         // bottom left
-         if (y < best_y) {
-            best_y = y;
-            best = prev;
-         }
-      } else {
-         // best-fit
-         if (y + height <= c->height) {
-            // can only use it if it first vertically
-            if (y < best_y || (y == best_y && waste < best_waste)) {
-               best_y = y;
-               best_waste = waste;
-               best = prev;
-            }
-         }
-      }
-      prev = &node->next;
-      node = node->next;
-   }
-
-   best_x = (best == NULL) ? 0 : (*best)->x;
-
-   // if doing best-fit (BF), we also have to try aligning right edge to each node position
-   //
-   // e.g, if fitting
-   //
-   //     ____________________
-   //    |____________________|
-   //
-   //            into
-   //
-   //   |                         |
-   //   |             ____________|
-   //   |____________|
-   //
-   // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
-   //
-   // This makes BF take about 2x the time
-
-   if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
-      tail = c->active_head;
-      node = c->active_head;
-      prev = &c->active_head;
-      // find first node that's admissible
-      while (tail->x < width)
-         tail = tail->next;
-      while (tail) {
-         int xpos = tail->x - width;
-         int y,waste;
-         STBRP_ASSERT(xpos >= 0);
-         // find the left position that matches this
-         while (node->next->x <= xpos) {
-            prev = &node->next;
-            node = node->next;
-         }
-         STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
-         y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
-         if (y + height <= c->height) {
-            if (y <= best_y) {
-               if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
-                  best_x = xpos;
-                  STBRP_ASSERT(y <= best_y);
-                  best_y = y;
-                  best_waste = waste;
-                  best = prev;
-               }
-            }
-         }
-         tail = tail->next;
-      }
-   }
-
-   fr.prev_link = best;
-   fr.x = best_x;
-   fr.y = best_y;
-   return fr;
-}
-
-static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
-{
-   // find best position according to heuristic
-   stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
-   stbrp_node *node, *cur;
-
-   // bail if:
-   //    1. it failed
-   //    2. the best node doesn't fit (we don't always check this)
-   //    3. we're out of memory
-   if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
-      res.prev_link = NULL;
-      return res;
-   }
-
-   // on success, create new node
-   node = context->free_head;
-   node->x = (stbrp_coord) res.x;
-   node->y = (stbrp_coord) (res.y + height);
-
-   context->free_head = node->next;
-
-   // insert the new node into the right starting point, and
-   // let 'cur' point to the remaining nodes needing to be
-   // stiched back in
-
-   cur = *res.prev_link;
-   if (cur->x < res.x) {
-      // preserve the existing one, so start testing with the next one
-      stbrp_node *next = cur->next;
-      cur->next = node;
-      cur = next;
-   } else {
-      *res.prev_link = node;
-   }
-
-   // from here, traverse cur and free the nodes, until we get to one
-   // that shouldn't be freed
-   while (cur->next && cur->next->x <= res.x + width) {
-      stbrp_node *next = cur->next;
-      // move the current node to the free list
-      cur->next = context->free_head;
-      context->free_head = cur;
-      cur = next;
-   }
-
-   // stitch the list back in
-   node->next = cur;
-
-   if (cur->x < res.x + width)
-      cur->x = (stbrp_coord) (res.x + width);
-
-#ifdef _DEBUG
-   cur = context->active_head;
-   while (cur->x < context->width) {
-      STBRP_ASSERT(cur->x < cur->next->x);
-      cur = cur->next;
-   }
-   STBRP_ASSERT(cur->next == NULL);
-
-   {
-      int count=0;
-      cur = context->active_head;
-      while (cur) {
-         cur = cur->next;
-         ++count;
-      }
-      cur = context->free_head;
-      while (cur) {
-         cur = cur->next;
-         ++count;
-      }
-      STBRP_ASSERT(count == context->num_nodes+2);
-   }
-#endif
-
-   return res;
-}
-
-static int rect_height_compare(const void *a, const void *b)
-{
-   const stbrp_rect *p = (const stbrp_rect *) a;
-   const stbrp_rect *q = (const stbrp_rect *) b;
-   if (p->h > q->h)
-      return -1;
-   if (p->h < q->h)
-      return  1;
-   return (p->w > q->w) ? -1 : (p->w < q->w);
-}
-
-static int rect_original_order(const void *a, const void *b)
-{
-   const stbrp_rect *p = (const stbrp_rect *) a;
-   const stbrp_rect *q = (const stbrp_rect *) b;
-   return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
-}
-
-#ifdef STBRP_LARGE_RECTS
-#define STBRP__MAXVAL  0xffffffff
-#else
-#define STBRP__MAXVAL  0xffff
-#endif
-
-STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
-{
-   int i, all_rects_packed = 1;
-
-   // we use the 'was_packed' field internally to allow sorting/unsorting
-   for (i=0; i < num_rects; ++i) {
-      rects[i].was_packed = i;
-   }
-
-   // sort according to heuristic
-   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
-
-   for (i=0; i < num_rects; ++i) {
-      if (rects[i].w == 0 || rects[i].h == 0) {
-         rects[i].x = rects[i].y = 0;  // empty rect needs no space
-      } else {
-         stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
-         if (fr.prev_link) {
-            rects[i].x = (stbrp_coord) fr.x;
-            rects[i].y = (stbrp_coord) fr.y;
-         } else {
-            rects[i].x = rects[i].y = STBRP__MAXVAL;
-         }
-      }
-   }
-
-   // unsort
-   STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
-
-   // set was_packed flags and all_rects_packed status
-   for (i=0; i < num_rects; ++i) {
-      rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
-      if (!rects[i].was_packed)
-         all_rects_packed = 0;
-   }
-
-   // return the all_rects_packed status
-   return all_rects_packed;
-}
-#endif
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_truetype.h b/raylib_pi4_test/external/stb_truetype.h
deleted file mode 100644 (file)
index 935a6de..0000000
+++ /dev/null
@@ -1,5011 +0,0 @@
-// stb_truetype.h - v1.24 - public domain
-// authored from 2009-2020 by Sean Barrett / RAD Game Tools
-//
-// =======================================================================
-//
-//    NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES
-//
-// This library does no range checking of the offsets found in the file,
-// meaning an attacker can use it to read arbitrary memory.
-//
-// =======================================================================
-//
-//   This library processes TrueType files:
-//        parse files
-//        extract glyph metrics
-//        extract glyph shapes
-//        render glyphs to one-channel bitmaps with antialiasing (box filter)
-//        render glyphs to one-channel SDF bitmaps (signed-distance field/function)
-//
-//   Todo:
-//        non-MS cmaps
-//        crashproof on bad data
-//        hinting? (no longer patented)
-//        cleartype-style AA?
-//        optimize: use simple memory allocator for intermediates
-//        optimize: build edge-list directly from curves
-//        optimize: rasterize directly from curves?
-//
-// ADDITIONAL CONTRIBUTORS
-//
-//   Mikko Mononen: compound shape support, more cmap formats
-//   Tor Andersson: kerning, subpixel rendering
-//   Dougall Johnson: OpenType / Type 2 font handling
-//   Daniel Ribeiro Maciel: basic GPOS-based kerning
-//
-//   Misc other:
-//       Ryan Gordon
-//       Simon Glass
-//       github:IntellectualKitty
-//       Imanol Celaya
-//       Daniel Ribeiro Maciel
-//
-//   Bug/warning reports/fixes:
-//       "Zer" on mollyrocket       Fabian "ryg" Giesen   github:NiLuJe
-//       Cass Everitt               Martins Mozeiko       github:aloucks
-//       stoiko (Haemimont Games)   Cap Petschulat        github:oyvindjam
-//       Brian Hook                 Omar Cornut           github:vassvik
-//       Walter van Niftrik         Ryan Griege
-//       David Gow                  Peter LaValle
-//       David Given                Sergey Popov
-//       Ivan-Assen Ivanov          Giumo X. Clanjor
-//       Anthony Pesch              Higor Euripedes
-//       Johan Duparc               Thomas Fields
-//       Hou Qiming                 Derek Vinyard
-//       Rob Loach                  Cort Stratton
-//       Kenney Phillis Jr.         Brian Costabile            
-//       Ken Voskuil (kaesve)       
-//
-// VERSION HISTORY
-//
-//   1.24 (2020-02-05) fix warning
-//   1.23 (2020-02-02) query SVG data for glyphs; query whole kerning table (but only kern not GPOS)
-//   1.22 (2019-08-11) minimize missing-glyph duplication; fix kerning if both 'GPOS' and 'kern' are defined
-//   1.21 (2019-02-25) fix warning
-//   1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics()
-//   1.19 (2018-02-11) GPOS kerning, STBTT_fmod
-//   1.18 (2018-01-29) add missing function
-//   1.17 (2017-07-23) make more arguments const; doc fix
-//   1.16 (2017-07-12) SDF support
-//   1.15 (2017-03-03) make more arguments const
-//   1.14 (2017-01-16) num-fonts-in-TTC function
-//   1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
-//   1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
-//   1.11 (2016-04-02) fix unused-variable warning
-//   1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef
-//   1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly
-//   1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
-//   1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
-//                     variant PackFontRanges to pack and render in separate phases;
-//                     fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
-//                     fixed an assert() bug in the new rasterizer
-//                     replace assert() with STBTT_assert() in new rasterizer
-//
-//   Full history can be found at the end of this file.
-//
-// LICENSE
-//
-//   See end of file for license information.
-//
-// USAGE
-//
-//   Include this file in whatever places need to refer to it. In ONE C/C++
-//   file, write:
-//      #define STB_TRUETYPE_IMPLEMENTATION
-//   before the #include of this file. This expands out the actual
-//   implementation into that C/C++ file.
-//
-//   To make the implementation private to the file that generates the implementation,
-//      #define STBTT_STATIC
-//
-//   Simple 3D API (don't ship this, but it's fine for tools and quick start)
-//           stbtt_BakeFontBitmap()               -- bake a font to a bitmap for use as texture
-//           stbtt_GetBakedQuad()                 -- compute quad to draw for a given char
-//
-//   Improved 3D API (more shippable):
-//           #include "stb_rect_pack.h"           -- optional, but you really want it
-//           stbtt_PackBegin()
-//           stbtt_PackSetOversampling()          -- for improved quality on small fonts
-//           stbtt_PackFontRanges()               -- pack and renders
-//           stbtt_PackEnd()
-//           stbtt_GetPackedQuad()
-//
-//   "Load" a font file from a memory buffer (you have to keep the buffer loaded)
-//           stbtt_InitFont()
-//           stbtt_GetFontOffsetForIndex()        -- indexing for TTC font collections
-//           stbtt_GetNumberOfFonts()             -- number of fonts for TTC font collections
-//
-//   Render a unicode codepoint to a bitmap
-//           stbtt_GetCodepointBitmap()           -- allocates and returns a bitmap
-//           stbtt_MakeCodepointBitmap()          -- renders into bitmap you provide
-//           stbtt_GetCodepointBitmapBox()        -- how big the bitmap must be
-//
-//   Character advance/positioning
-//           stbtt_GetCodepointHMetrics()
-//           stbtt_GetFontVMetrics()
-//           stbtt_GetFontVMetricsOS2()
-//           stbtt_GetCodepointKernAdvance()
-//
-//   Starting with version 1.06, the rasterizer was replaced with a new,
-//   faster and generally-more-precise rasterizer. The new rasterizer more
-//   accurately measures pixel coverage for anti-aliasing, except in the case
-//   where multiple shapes overlap, in which case it overestimates the AA pixel
-//   coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If
-//   this turns out to be a problem, you can re-enable the old rasterizer with
-//        #define STBTT_RASTERIZER_VERSION 1
-//   which will incur about a 15% speed hit.
-//
-// ADDITIONAL DOCUMENTATION
-//
-//   Immediately after this block comment are a series of sample programs.
-//
-//   After the sample programs is the "header file" section. This section
-//   includes documentation for each API function.
-//
-//   Some important concepts to understand to use this library:
-//
-//      Codepoint
-//         Characters are defined by unicode codepoints, e.g. 65 is
-//         uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is
-//         the hiragana for "ma".
-//
-//      Glyph
-//         A visual character shape (every codepoint is rendered as
-//         some glyph)
-//
-//      Glyph index
-//         A font-specific integer ID representing a glyph
-//
-//      Baseline
-//         Glyph shapes are defined relative to a baseline, which is the
-//         bottom of uppercase characters. Characters extend both above
-//         and below the baseline.
-//
-//      Current Point
-//         As you draw text to the screen, you keep track of a "current point"
-//         which is the origin of each character. The current point's vertical
-//         position is the baseline. Even "baked fonts" use this model.
-//
-//      Vertical Font Metrics
-//         The vertical qualities of the font, used to vertically position
-//         and space the characters. See docs for stbtt_GetFontVMetrics.
-//
-//      Font Size in Pixels or Points
-//         The preferred interface for specifying font sizes in stb_truetype
-//         is to specify how tall the font's vertical extent should be in pixels.
-//         If that sounds good enough, skip the next paragraph.
-//
-//         Most font APIs instead use "points", which are a common typographic
-//         measurement for describing font size, defined as 72 points per inch.
-//         stb_truetype provides a point API for compatibility. However, true
-//         "per inch" conventions don't make much sense on computer displays
-//         since different monitors have different number of pixels per
-//         inch. For example, Windows traditionally uses a convention that
-//         there are 96 pixels per inch, thus making 'inch' measurements have
-//         nothing to do with inches, and thus effectively defining a point to
-//         be 1.333 pixels. Additionally, the TrueType font data provides
-//         an explicit scale factor to scale a given font's glyphs to points,
-//         but the author has observed that this scale factor is often wrong
-//         for non-commercial fonts, thus making fonts scaled in points
-//         according to the TrueType spec incoherently sized in practice.
-//
-// DETAILED USAGE:
-//
-//  Scale:
-//    Select how high you want the font to be, in points or pixels.
-//    Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute
-//    a scale factor SF that will be used by all other functions.
-//
-//  Baseline:
-//    You need to select a y-coordinate that is the baseline of where
-//    your text will appear. Call GetFontBoundingBox to get the baseline-relative
-//    bounding box for all characters. SF*-y0 will be the distance in pixels
-//    that the worst-case character could extend above the baseline, so if
-//    you want the top edge of characters to appear at the top of the
-//    screen where y=0, then you would set the baseline to SF*-y0.
-//
-//  Current point:
-//    Set the current point where the first character will appear. The
-//    first character could extend left of the current point; this is font
-//    dependent. You can either choose a current point that is the leftmost
-//    point and hope, or add some padding, or check the bounding box or
-//    left-side-bearing of the first character to be displayed and set
-//    the current point based on that.
-//
-//  Displaying a character:
-//    Compute the bounding box of the character. It will contain signed values
-//    relative to <current_point, baseline>. I.e. if it returns x0,y0,x1,y1,
-//    then the character should be displayed in the rectangle from
-//    <current_point+SF*x0, baseline+SF*y0> to <current_point+SF*x1,baseline+SF*y1).
-//
-//  Advancing for the next character:
-//    Call GlyphHMetrics, and compute 'current_point += SF * advance'.
-//
-//
-// ADVANCED USAGE
-//
-//   Quality:
-//
-//    - Use the functions with Subpixel at the end to allow your characters
-//      to have subpixel positioning. Since the font is anti-aliased, not
-//      hinted, this is very import for quality. (This is not possible with
-//      baked fonts.)
-//
-//    - Kerning is now supported, and if you're supporting subpixel rendering
-//      then kerning is worth using to give your text a polished look.
-//
-//   Performance:
-//
-//    - Convert Unicode codepoints to glyph indexes and operate on the glyphs;
-//      if you don't do this, stb_truetype is forced to do the conversion on
-//      every call.
-//
-//    - There are a lot of memory allocations. We should modify it to take
-//      a temp buffer and allocate from the temp buffer (without freeing),
-//      should help performance a lot.
-//
-// NOTES
-//
-//   The system uses the raw data found in the .ttf file without changing it
-//   and without building auxiliary data structures. This is a bit inefficient
-//   on little-endian systems (the data is big-endian), but assuming you're
-//   caching the bitmaps or glyph shapes this shouldn't be a big deal.
-//
-//   It appears to be very hard to programmatically determine what font a
-//   given file is in a general way. I provide an API for this, but I don't
-//   recommend it.
-//
-//
-// PERFORMANCE MEASUREMENTS FOR 1.06:
-//
-//                      32-bit     64-bit
-//   Previous release:  8.83 s     7.68 s
-//   Pool allocations:  7.72 s     6.34 s
-//   Inline sort     :  6.54 s     5.65 s
-//   New rasterizer  :  5.63 s     5.00 s
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-////
-////  SAMPLE PROGRAMS
-////
-//
-//  Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless
-//
-#if 0
-#define STB_TRUETYPE_IMPLEMENTATION  // force following include to generate implementation
-#include "stb_truetype.h"
-
-unsigned char ttf_buffer[1<<20];
-unsigned char temp_bitmap[512*512];
-
-stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
-GLuint ftex;
-
-void my_stbtt_initfont(void)
-{
-   fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb"));
-   stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits!
-   // can free ttf_buffer at this point
-   glGenTextures(1, &ftex);
-   glBindTexture(GL_TEXTURE_2D, ftex);
-   glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);
-   // can free temp_bitmap at this point
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-}
-
-void my_stbtt_print(float x, float y, char *text)
-{
-   // assume orthographic projection with units = screen pixels, origin at top left
-   glEnable(GL_TEXTURE_2D);
-   glBindTexture(GL_TEXTURE_2D, ftex);
-   glBegin(GL_QUADS);
-   while (*text) {
-      if (*text >= 32 && *text < 128) {
-         stbtt_aligned_quad q;
-         stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9
-         glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0);
-         glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0);
-         glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1);
-         glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1);
-      }
-      ++text;
-   }
-   glEnd();
-}
-#endif
-//
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// Complete program (this compiles): get a single bitmap, print as ASCII art
-//
-#if 0
-#include <stdio.h>
-#define STB_TRUETYPE_IMPLEMENTATION  // force following include to generate implementation
-#include "stb_truetype.h"
-
-char ttf_buffer[1<<25];
-
-int main(int argc, char **argv)
-{
-   stbtt_fontinfo font;
-   unsigned char *bitmap;
-   int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20);
-
-   fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb"));
-
-   stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
-   bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0);
-
-   for (j=0; j < h; ++j) {
-      for (i=0; i < w; ++i)
-         putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
-      putchar('\n');
-   }
-   return 0;
-}
-#endif
-//
-// Output:
-//
-//     .ii.
-//    @@@@@@.
-//   V@Mio@@o
-//   :i.  V@V
-//     :oM@@M
-//   :@@@MM@M
-//   @@o  o@M
-//  :@@.  M@M
-//   @@@o@@@@
-//   :M@@V:@@.
-//
-//////////////////////////////////////////////////////////////////////////////
-//
-// Complete program: print "Hello World!" banner, with bugs
-//
-#if 0
-char buffer[24<<20];
-unsigned char screen[20][79];
-
-int main(int arg, char **argv)
-{
-   stbtt_fontinfo font;
-   int i,j,ascent,baseline,ch=0;
-   float scale, xpos=2; // leave a little padding in case the character extends left
-   char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness
-
-   fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb"));
-   stbtt_InitFont(&font, buffer, 0);
-
-   scale = stbtt_ScaleForPixelHeight(&font, 15);
-   stbtt_GetFontVMetrics(&font, &ascent,0,0);
-   baseline = (int) (ascent*scale);
-
-   while (text[ch]) {
-      int advance,lsb,x0,y0,x1,y1;
-      float x_shift = xpos - (float) floor(xpos);
-      stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb);
-      stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1);
-      stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]);
-      // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong
-      // because this API is really for baking character bitmaps into textures. if you want to render
-      // a sequence of characters, you really need to render each bitmap to a temp buffer, then
-      // "alpha blend" that into the working buffer
-      xpos += (advance * scale);
-      if (text[ch+1])
-         xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]);
-      ++ch;
-   }
-
-   for (j=0; j < 20; ++j) {
-      for (i=0; i < 78; ++i)
-         putchar(" .:ioVM@"[screen[j][i]>>5]);
-      putchar('\n');
-   }
-
-   return 0;
-}
-#endif
-
-
-//////////////////////////////////////////////////////////////////////////////
-//////////////////////////////////////////////////////////////////////////////
-////
-////   INTEGRATION WITH YOUR CODEBASE
-////
-////   The following sections allow you to supply alternate definitions
-////   of C library functions used by stb_truetype, e.g. if you don't
-////   link with the C runtime library.
-
-#ifdef STB_TRUETYPE_IMPLEMENTATION
-   // #define your own (u)stbtt_int8/16/32 before including to override this
-   #ifndef stbtt_uint8
-   typedef unsigned char   stbtt_uint8;
-   typedef signed   char   stbtt_int8;
-   typedef unsigned short  stbtt_uint16;
-   typedef signed   short  stbtt_int16;
-   typedef unsigned int    stbtt_uint32;
-   typedef signed   int    stbtt_int32;
-   #endif
-
-   typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
-   typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
-
-   // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h
-   #ifndef STBTT_ifloor
-   #include <math.h>
-   #define STBTT_ifloor(x)   ((int) floor(x))
-   #define STBTT_iceil(x)    ((int) ceil(x))
-   #endif
-
-   #ifndef STBTT_sqrt
-   #include <math.h>
-   #define STBTT_sqrt(x)      sqrt(x)
-   #define STBTT_pow(x,y)     pow(x,y)
-   #endif
-
-   #ifndef STBTT_fmod
-   #include <math.h>
-   #define STBTT_fmod(x,y)    fmod(x,y)
-   #endif
-
-   #ifndef STBTT_cos
-   #include <math.h>
-   #define STBTT_cos(x)       cos(x)
-   #define STBTT_acos(x)      acos(x)
-   #endif
-
-   #ifndef STBTT_fabs
-   #include <math.h>
-   #define STBTT_fabs(x)      fabs(x)
-   #endif
-
-   // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h
-   #ifndef STBTT_malloc
-   #include <stdlib.h>
-   #define STBTT_malloc(x,u)  ((void)(u),malloc(x))
-   #define STBTT_free(x,u)    ((void)(u),free(x))
-   #endif
-
-   #ifndef STBTT_assert
-   #include <assert.h>
-   #define STBTT_assert(x)    assert(x)
-   #endif
-
-   #ifndef STBTT_strlen
-   #include <string.h>
-   #define STBTT_strlen(x)    strlen(x)
-   #endif
-
-   #ifndef STBTT_memcpy
-   #include <string.h>
-   #define STBTT_memcpy       memcpy
-   #define STBTT_memset       memset
-   #endif
-#endif
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-////
-////   INTERFACE
-////
-////
-
-#ifndef __STB_INCLUDE_STB_TRUETYPE_H__
-#define __STB_INCLUDE_STB_TRUETYPE_H__
-
-#ifdef STBTT_STATIC
-#define STBTT_DEF static
-#else
-#define STBTT_DEF extern
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// private structure
-typedef struct
-{
-   unsigned char *data;
-   int cursor;
-   int size;
-} stbtt__buf;
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// TEXTURE BAKING API
-//
-// If you use this API, you only have to call two functions ever.
-//
-
-typedef struct
-{
-   unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
-   float xoff,yoff,xadvance;
-} stbtt_bakedchar;
-
-STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
-                                float pixel_height,                     // height of font in pixels
-                                unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
-                                int first_char, int num_chars,          // characters to bake
-                                stbtt_bakedchar *chardata);             // you allocate this, it's num_chars long
-// if return is positive, the first unused row of the bitmap
-// if return is negative, returns the negative of the number of characters that fit
-// if return is 0, no characters fit and no rows were used
-// This uses a very crappy packing.
-
-typedef struct
-{
-   float x0,y0,s0,t0; // top-left
-   float x1,y1,s1,t1; // bottom-right
-} stbtt_aligned_quad;
-
-STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph,  // same data as above
-                               int char_index,             // character to display
-                               float *xpos, float *ypos,   // pointers to current position in screen pixel space
-                               stbtt_aligned_quad *q,      // output: quad to draw
-                               int opengl_fillrule);       // true if opengl fill rule; false if DX9 or earlier
-// Call GetBakedQuad with char_index = 'character - first_char', and it
-// creates the quad you need to draw and advances the current position.
-//
-// The coordinate system used assumes y increases downwards.
-//
-// Characters will extend both above and below the current position;
-// see discussion of "BASELINE" above.
-//
-// It's inefficient; you might want to c&p it and optimize it.
-
-STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap);
-// Query the font vertical metrics without having to create a font first.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// NEW TEXTURE BAKING API
-//
-// This provides options for packing multiple fonts into one atlas, not
-// perfectly but better than nothing.
-
-typedef struct
-{
-   unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap
-   float xoff,yoff,xadvance;
-   float xoff2,yoff2;
-} stbtt_packedchar;
-
-typedef struct stbtt_pack_context stbtt_pack_context;
-typedef struct stbtt_fontinfo stbtt_fontinfo;
-#ifndef STB_RECT_PACK_VERSION
-typedef struct stbrp_rect stbrp_rect;
-#endif
-
-STBTT_DEF int  stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
-// Initializes a packing context stored in the passed-in stbtt_pack_context.
-// Future calls using this context will pack characters into the bitmap passed
-// in here: a 1-channel bitmap that is width * height. stride_in_bytes is
-// the distance from one row to the next (or 0 to mean they are packed tightly
-// together). "padding" is the amount of padding to leave between each
-// character (normally you want '1' for bitmaps you'll use as textures with
-// bilinear filtering).
-//
-// Returns 0 on failure, 1 on success.
-
-STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc);
-// Cleans up the packing context and frees all memory.
-
-#define STBTT_POINT_SIZE(x)   (-(x))
-
-STBTT_DEF int  stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
-                                int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
-// Creates character bitmaps from the font_index'th font found in fontdata (use
-// font_index=0 if you don't know what that is). It creates num_chars_in_range
-// bitmaps for characters with unicode values starting at first_unicode_char_in_range
-// and increasing. Data for how to render them is stored in chardata_for_range;
-// pass these to stbtt_GetPackedQuad to get back renderable quads.
-//
-// font_size is the full height of the character from ascender to descender,
-// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed
-// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE()
-// and pass that result as 'font_size':
-//       ...,                  20 , ... // font max minus min y is 20 pixels tall
-//       ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall
-
-typedef struct
-{
-   float font_size;
-   int first_unicode_codepoint_in_range;  // if non-zero, then the chars are continuous, and this is the first codepoint
-   int *array_of_unicode_codepoints;       // if non-zero, then this is an array of unicode codepoints
-   int num_chars;
-   stbtt_packedchar *chardata_for_range; // output
-   unsigned char h_oversample, v_oversample; // don't set these, they're used internally
-} stbtt_pack_range;
-
-STBTT_DEF int  stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
-// Creates character bitmaps from multiple ranges of characters stored in
-// ranges. This will usually create a better-packed bitmap than multiple
-// calls to stbtt_PackFontRange. Note that you can call this multiple
-// times within a single PackBegin/PackEnd.
-
-STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
-// Oversampling a font increases the quality by allowing higher-quality subpixel
-// positioning, and is especially valuable at smaller text sizes.
-//
-// This function sets the amount of oversampling for all following calls to
-// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given
-// pack context. The default (no oversampling) is achieved by h_oversample=1
-// and v_oversample=1. The total number of pixels required is
-// h_oversample*v_oversample larger than the default; for example, 2x2
-// oversampling requires 4x the storage of 1x1. For best results, render
-// oversampled textures with bilinear filtering. Look at the readme in
-// stb/tests/oversample for information about oversampled fonts
-//
-// To use with PackFontRangesGather etc., you must set it before calls
-// call to PackFontRangesGatherRects.
-
-STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
-// If skip != 0, this tells stb_truetype to skip any codepoints for which
-// there is no corresponding glyph. If skip=0, which is the default, then
-// codepoints without a glyph recived the font's "missing character" glyph,
-// typically an empty box by convention.
-
-STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph,  // same data as above
-                               int char_index,             // character to display
-                               float *xpos, float *ypos,   // pointers to current position in screen pixel space
-                               stbtt_aligned_quad *q,      // output: quad to draw
-                               int align_to_integer);
-
-STBTT_DEF int  stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
-STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects);
-STBTT_DEF int  stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
-// Calling these functions in sequence is roughly equivalent to calling
-// stbtt_PackFontRanges(). If you more control over the packing of multiple
-// fonts, or if you want to pack custom data into a font texture, take a look
-// at the source to of stbtt_PackFontRanges() and create a custom version
-// using these functions, e.g. call GatherRects multiple times,
-// building up a single array of rects, then call PackRects once,
-// then call RenderIntoRects repeatedly. This may result in a
-// better packing than calling PackFontRanges multiple times
-// (or it may not).
-
-// this is an opaque structure that you shouldn't mess with which holds
-// all the context needed from PackBegin to PackEnd.
-struct stbtt_pack_context {
-   void *user_allocator_context;
-   void *pack_info;
-   int   width;
-   int   height;
-   int   stride_in_bytes;
-   int   padding;
-   int   skip_missing;
-   unsigned int   h_oversample, v_oversample;
-   unsigned char *pixels;
-   void  *nodes;
-};
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// FONT LOADING
-//
-//
-
-STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data);
-// This function will determine the number of fonts in a font file.  TrueType
-// collection (.ttc) files may contain multiple fonts, while TrueType font
-// (.ttf) files only contain one font. The number of fonts can be used for
-// indexing with the previous function where the index is between zero and one
-// less than the total fonts. If an error occurs, -1 is returned.
-
-STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
-// Each .ttf/.ttc file may have more than one font. Each font has a sequential
-// index number starting from 0. Call this function to get the font offset for
-// a given index; it returns -1 if the index is out of range. A regular .ttf
-// file will only define one font and it always be at offset 0, so it will
-// return '0' for index 0, and -1 for all other indices.
-
-// The following structure is defined publicly so you can declare one on
-// the stack or as a global or etc, but you should treat it as opaque.
-struct stbtt_fontinfo
-{
-   void           * userdata;
-   unsigned char  * data;              // pointer to .ttf file
-   int              fontstart;         // offset of start of font
-
-   int numGlyphs;                     // number of glyphs, needed for range checking
-
-   int loca,head,glyf,hhea,hmtx,kern,gpos,svg; // table locations as offset from start of .ttf
-   int index_map;                     // a cmap mapping for our chosen character encoding
-   int indexToLocFormat;              // format needed to map from glyph index to glyph
-
-   stbtt__buf cff;                    // cff font data
-   stbtt__buf charstrings;            // the charstring index
-   stbtt__buf gsubrs;                 // global charstring subroutines index
-   stbtt__buf subrs;                  // private charstring subroutines index
-   stbtt__buf fontdicts;              // array of font dicts
-   stbtt__buf fdselect;               // map from glyph to fontdict
-};
-
-STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
-// Given an offset into the file that defines a font, this function builds
-// the necessary cached info for the rest of the system. You must allocate
-// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
-// need to do anything special to free it, because the contents are pure
-// value data with no additional data structures. Returns 0 on failure.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// CHARACTER TO GLYPH-INDEX CONVERSIOn
-
-STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
-// If you're going to perform multiple operations on the same character
-// and you want a speed-up, call this function with the character you're
-// going to process, then use glyph-based functions instead of the
-// codepoint-based functions.
-// Returns 0 if the character codepoint is not defined in the font.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// CHARACTER PROPERTIES
-//
-
-STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
-// computes a scale factor to produce a font whose "height" is 'pixels' tall.
-// Height is measured as the distance from the highest ascender to the lowest
-// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
-// and computing:
-//       scale = pixels / (ascent - descent)
-// so if you prefer to measure height by the ascent only, use a similar calculation.
-
-STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
-// computes a scale factor to produce a font whose EM size is mapped to
-// 'pixels' tall. This is probably what traditional APIs compute, but
-// I'm not positive.
-
-STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
-// ascent is the coordinate above the baseline the font extends; descent
-// is the coordinate below the baseline the font extends (i.e. it is typically negative)
-// lineGap is the spacing between one row's descent and the next row's ascent...
-// so you should advance the vertical position by "*ascent - *descent + *lineGap"
-//   these are expressed in unscaled coordinates, so you must multiply by
-//   the scale factor for a given size
-
-STBTT_DEF int  stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap);
-// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2
-// table (specific to MS/Windows TTF files).
-//
-// Returns 1 on success (table present), 0 on failure.
-
-STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
-// the bounding box around all possible characters
-
-STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
-// leftSideBearing is the offset from the current horizontal position to the left edge of the character
-// advanceWidth is the offset from the current horizontal position to the next horizontal position
-//   these are expressed in unscaled coordinates
-
-STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
-// an additional amount to add to the 'advance' value between ch1 and ch2
-
-STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
-// Gets the bounding box of the visible part of the glyph, in unscaled coordinates
-
-STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
-STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
-STBTT_DEF int  stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
-// as above, but takes one or more glyph indices for greater efficiency
-
-typedef struct stbtt_kerningentry
-{
-   int glyph1; // use stbtt_FindGlyphIndex
-   int glyph2;
-   int advance;
-} stbtt_kerningentry;
-
-STBTT_DEF int  stbtt_GetKerningTableLength(const stbtt_fontinfo *info);
-STBTT_DEF int  stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length);
-// Retrieves a complete list of all of the kerning pairs provided by the font
-// stbtt_GetKerningTable never writes more than table_length entries and returns how many entries it did write.
-// The table will be sorted by (a.glyph1 == b.glyph1)?(a.glyph2 < b.glyph2):(a.glyph1 < b.glyph1)
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// GLYPH SHAPES (you probably don't need these, but they have to go before
-// the bitmaps for C declaration-order reasons)
-//
-
-#ifndef STBTT_vmove // you can predefine these to use different values (but why?)
-   enum {
-      STBTT_vmove=1,
-      STBTT_vline,
-      STBTT_vcurve,
-      STBTT_vcubic
-   };
-#endif
-
-#ifndef stbtt_vertex // you can predefine this to use different values
-                   // (we share this with other code at RAD)
-   #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file
-   typedef struct
-   {
-      stbtt_vertex_type x,y,cx,cy,cx1,cy1;
-      unsigned char type,padding;
-   } stbtt_vertex;
-#endif
-
-STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
-// returns non-zero if nothing is drawn for this glyph
-
-STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
-STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
-// returns # of vertices and fills *vertices with the pointer to them
-//   these are expressed in "unscaled" coordinates
-//
-// The shape is a series of contours. Each one starts with
-// a STBTT_moveto, then consists of a series of mixed
-// STBTT_lineto and STBTT_curveto segments. A lineto
-// draws a line from previous endpoint to its x,y; a curveto
-// draws a quadratic bezier from previous endpoint to
-// its x,y, using cx,cy as the bezier control point.
-
-STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
-// frees the data allocated above
-
-STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg);
-STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg);
-// fills svg with the character's SVG data.
-// returns data size or 0 if SVG not found.
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// BITMAP RENDERING
-//
-
-STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
-// frees the bitmap allocated below
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
-// allocates a large-enough single-channel 8bpp bitmap and renders the
-// specified character/glyph at the specified scale into it, with
-// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
-// *width & *height are filled out with the width & height of the bitmap,
-// which is stored left-to-right, top-to-bottom.
-//
-// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
-// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
-// shift for the character
-
-STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
-// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
-// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
-// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
-// width and height and positioning info for it first.
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
-// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
-// shift for the character
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint);
-// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering
-// is performed (see stbtt_PackSetOversampling)
-
-STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
-// get the bbox of the bitmap centered around the glyph origin; so the
-// bitmap width is ix1-ix0, height is iy1-iy0, and location to place
-// the bitmap top left is (leftSideBearing*scale,iy0).
-// (Note that the bitmap uses y-increases-down, but the shape uses
-// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
-
-STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
-// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
-// shift for the character
-
-// the following functions are equivalent to the above functions, but operate
-// on glyph indices instead of Unicode codepoints (for efficiency)
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph);
-STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
-STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
-
-
-// @TODO: don't expose this structure
-typedef struct
-{
-   int w,h,stride;
-   unsigned char *pixels;
-} stbtt__bitmap;
-
-// rasterize a shape with quadratic beziers into a bitmap
-STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result,        // 1-channel bitmap to draw into
-                               float flatness_in_pixels,     // allowable error of curve in pixels
-                               stbtt_vertex *vertices,       // array of vertices defining shape
-                               int num_verts,                // number of vertices in above array
-                               float scale_x, float scale_y, // scale applied to input vertices
-                               float shift_x, float shift_y, // translation applied to input vertices
-                               int x_off, int y_off,         // another translation applied to input
-                               int invert,                   // if non-zero, vertically flip shape
-                               void *userdata);              // context for to STBTT_MALLOC
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Signed Distance Function (or Field) rendering
-
-STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata);
-// frees the SDF bitmap allocated below
-
-STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
-STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff);
-// These functions compute a discretized SDF field for a single character, suitable for storing
-// in a single-channel texture, sampling with bilinear filtering, and testing against
-// larger than some threshold to produce scalable fonts.
-//        info              --  the font
-//        scale             --  controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap
-//        glyph/codepoint   --  the character to generate the SDF for
-//        padding           --  extra "pixels" around the character which are filled with the distance to the character (not 0),
-//                                 which allows effects like bit outlines
-//        onedge_value      --  value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character)
-//        pixel_dist_scale  --  what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale)
-//                                 if positive, > onedge_value is inside; if negative, < onedge_value is inside
-//        width,height      --  output height & width of the SDF bitmap (including padding)
-//        xoff,yoff         --  output origin of the character
-//        return value      --  a 2D array of bytes 0..255, width*height in size
-//
-// pixel_dist_scale & onedge_value are a scale & bias that allows you to make
-// optimal use of the limited 0..255 for your application, trading off precision
-// and special effects. SDF values outside the range 0..255 are clamped to 0..255.
-//
-// Example:
-//      scale = stbtt_ScaleForPixelHeight(22)
-//      padding = 5
-//      onedge_value = 180
-//      pixel_dist_scale = 180/5.0 = 36.0
-//
-//      This will create an SDF bitmap in which the character is about 22 pixels
-//      high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled
-//      shape, sample the SDF at each pixel and fill the pixel if the SDF value
-//      is greater than or equal to 180/255. (You'll actually want to antialias,
-//      which is beyond the scope of this example.) Additionally, you can compute
-//      offset outlines (e.g. to stroke the character border inside & outside,
-//      or only outside). For example, to fill outside the character up to 3 SDF
-//      pixels, you would compare against (180-36.0*3)/255 = 72/255. The above
-//      choice of variables maps a range from 5 pixels outside the shape to
-//      2 pixels inside the shape to 0..255; this is intended primarily for apply
-//      outside effects only (the interior range is needed to allow proper
-//      antialiasing of the font at *smaller* sizes)
-//
-// The function computes the SDF analytically at each SDF pixel, not by e.g.
-// building a higher-res bitmap and approximating it. In theory the quality
-// should be as high as possible for an SDF of this size & representation, but
-// unclear if this is true in practice (perhaps building a higher-res bitmap
-// and computing from that can allow drop-out prevention).
-//
-// The algorithm has not been optimized at all, so expect it to be slow
-// if computing lots of characters or very large sizes.
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// Finding the right font...
-//
-// You should really just solve this offline, keep your own tables
-// of what font is what, and don't try to get it out of the .ttf file.
-// That's because getting it out of the .ttf file is really hard, because
-// the names in the file can appear in many possible encodings, in many
-// possible languages, and e.g. if you need a case-insensitive comparison,
-// the details of that depend on the encoding & language in a complex way
-// (actually underspecified in truetype, but also gigantic).
-//
-// But you can use the provided functions in two possible ways:
-//     stbtt_FindMatchingFont() will use *case-sensitive* comparisons on
-//             unicode-encoded names to try to find the font you want;
-//             you can run this before calling stbtt_InitFont()
-//
-//     stbtt_GetFontNameString() lets you get any of the various strings
-//             from the file yourself and do your own comparisons on them.
-//             You have to have called stbtt_InitFont() first.
-
-
-STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
-// returns the offset (not index) of the font that matches, or -1 if none
-//   if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
-//   if you use any other flag, use a font name like "Arial"; this checks
-//     the 'macStyle' header field; i don't know if fonts set this consistently
-#define STBTT_MACSTYLE_DONTCARE     0
-#define STBTT_MACSTYLE_BOLD         1
-#define STBTT_MACSTYLE_ITALIC       2
-#define STBTT_MACSTYLE_UNDERSCORE   4
-#define STBTT_MACSTYLE_NONE         8   // <= not same as 0, this makes us check the bitfield is 0
-
-STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
-// returns 1/0 whether the first string interpreted as utf8 is identical to
-// the second string interpreted as big-endian utf16... useful for strings from next func
-
-STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
-// returns the string (which may be big-endian double byte, e.g. for unicode)
-// and puts the length in bytes in *length.
-//
-// some of the values for the IDs are below; for more see the truetype spec:
-//     http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html
-//     http://www.microsoft.com/typography/otspec/name.htm
-
-enum { // platformID
-   STBTT_PLATFORM_ID_UNICODE   =0,
-   STBTT_PLATFORM_ID_MAC       =1,
-   STBTT_PLATFORM_ID_ISO       =2,
-   STBTT_PLATFORM_ID_MICROSOFT =3
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_UNICODE
-   STBTT_UNICODE_EID_UNICODE_1_0    =0,
-   STBTT_UNICODE_EID_UNICODE_1_1    =1,
-   STBTT_UNICODE_EID_ISO_10646      =2,
-   STBTT_UNICODE_EID_UNICODE_2_0_BMP=3,
-   STBTT_UNICODE_EID_UNICODE_2_0_FULL=4
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT
-   STBTT_MS_EID_SYMBOL        =0,
-   STBTT_MS_EID_UNICODE_BMP   =1,
-   STBTT_MS_EID_SHIFTJIS      =2,
-   STBTT_MS_EID_UNICODE_FULL  =10
-};
-
-enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes
-   STBTT_MAC_EID_ROMAN        =0,   STBTT_MAC_EID_ARABIC       =4,
-   STBTT_MAC_EID_JAPANESE     =1,   STBTT_MAC_EID_HEBREW       =5,
-   STBTT_MAC_EID_CHINESE_TRAD =2,   STBTT_MAC_EID_GREEK        =6,
-   STBTT_MAC_EID_KOREAN       =3,   STBTT_MAC_EID_RUSSIAN      =7
-};
-
-enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID...
-       // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs
-   STBTT_MS_LANG_ENGLISH     =0x0409,   STBTT_MS_LANG_ITALIAN     =0x0410,
-   STBTT_MS_LANG_CHINESE     =0x0804,   STBTT_MS_LANG_JAPANESE    =0x0411,
-   STBTT_MS_LANG_DUTCH       =0x0413,   STBTT_MS_LANG_KOREAN      =0x0412,
-   STBTT_MS_LANG_FRENCH      =0x040c,   STBTT_MS_LANG_RUSSIAN     =0x0419,
-   STBTT_MS_LANG_GERMAN      =0x0407,   STBTT_MS_LANG_SPANISH     =0x0409,
-   STBTT_MS_LANG_HEBREW      =0x040d,   STBTT_MS_LANG_SWEDISH     =0x041D
-};
-
-enum { // languageID for STBTT_PLATFORM_ID_MAC
-   STBTT_MAC_LANG_ENGLISH      =0 ,   STBTT_MAC_LANG_JAPANESE     =11,
-   STBTT_MAC_LANG_ARABIC       =12,   STBTT_MAC_LANG_KOREAN       =23,
-   STBTT_MAC_LANG_DUTCH        =4 ,   STBTT_MAC_LANG_RUSSIAN      =32,
-   STBTT_MAC_LANG_FRENCH       =1 ,   STBTT_MAC_LANG_SPANISH      =6 ,
-   STBTT_MAC_LANG_GERMAN       =2 ,   STBTT_MAC_LANG_SWEDISH      =5 ,
-   STBTT_MAC_LANG_HEBREW       =10,   STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33,
-   STBTT_MAC_LANG_ITALIAN      =3 ,   STBTT_MAC_LANG_CHINESE_TRAD =19
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __STB_INCLUDE_STB_TRUETYPE_H__
-
-///////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////
-////
-////   IMPLEMENTATION
-////
-////
-
-#ifdef STB_TRUETYPE_IMPLEMENTATION
-
-#ifndef STBTT_MAX_OVERSAMPLE
-#define STBTT_MAX_OVERSAMPLE   8
-#endif
-
-#if STBTT_MAX_OVERSAMPLE > 255
-#error "STBTT_MAX_OVERSAMPLE cannot be > 255"
-#endif
-
-typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1];
-
-#ifndef STBTT_RASTERIZER_VERSION
-#define STBTT_RASTERIZER_VERSION 2
-#endif
-
-#ifdef _MSC_VER
-#define STBTT__NOTUSED(v)  (void)(v)
-#else
-#define STBTT__NOTUSED(v)  (void)sizeof(v)
-#endif
-
-//////////////////////////////////////////////////////////////////////////
-//
-// stbtt__buf helpers to parse data from file
-//
-
-static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b)
-{
-   if (b->cursor >= b->size)
-      return 0;
-   return b->data[b->cursor++];
-}
-
-static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b)
-{
-   if (b->cursor >= b->size)
-      return 0;
-   return b->data[b->cursor];
-}
-
-static void stbtt__buf_seek(stbtt__buf *b, int o)
-{
-   STBTT_assert(!(o > b->size || o < 0));
-   b->cursor = (o > b->size || o < 0) ? b->size : o;
-}
-
-static void stbtt__buf_skip(stbtt__buf *b, int o)
-{
-   stbtt__buf_seek(b, b->cursor + o);
-}
-
-static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n)
-{
-   stbtt_uint32 v = 0;
-   int i;
-   STBTT_assert(n >= 1 && n <= 4);
-   for (i = 0; i < n; i++)
-      v = (v << 8) | stbtt__buf_get8(b);
-   return v;
-}
-
-static stbtt__buf stbtt__new_buf(const void *p, size_t size)
-{
-   stbtt__buf r;
-   STBTT_assert(size < 0x40000000);
-   r.data = (stbtt_uint8*) p;
-   r.size = (int) size;
-   r.cursor = 0;
-   return r;
-}
-
-#define stbtt__buf_get16(b)  stbtt__buf_get((b), 2)
-#define stbtt__buf_get32(b)  stbtt__buf_get((b), 4)
-
-static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s)
-{
-   stbtt__buf r = stbtt__new_buf(NULL, 0);
-   if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r;
-   r.data = b->data + o;
-   r.size = s;
-   return r;
-}
-
-static stbtt__buf stbtt__cff_get_index(stbtt__buf *b)
-{
-   int count, start, offsize;
-   start = b->cursor;
-   count = stbtt__buf_get16(b);
-   if (count) {
-      offsize = stbtt__buf_get8(b);
-      STBTT_assert(offsize >= 1 && offsize <= 4);
-      stbtt__buf_skip(b, offsize * count);
-      stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1);
-   }
-   return stbtt__buf_range(b, start, b->cursor - start);
-}
-
-static stbtt_uint32 stbtt__cff_int(stbtt__buf *b)
-{
-   int b0 = stbtt__buf_get8(b);
-   if (b0 >= 32 && b0 <= 246)       return b0 - 139;
-   else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108;
-   else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108;
-   else if (b0 == 28)               return stbtt__buf_get16(b);
-   else if (b0 == 29)               return stbtt__buf_get32(b);
-   STBTT_assert(0);
-   return 0;
-}
-
-static void stbtt__cff_skip_operand(stbtt__buf *b) {
-   int v, b0 = stbtt__buf_peek8(b);
-   STBTT_assert(b0 >= 28);
-   if (b0 == 30) {
-      stbtt__buf_skip(b, 1);
-      while (b->cursor < b->size) {
-         v = stbtt__buf_get8(b);
-         if ((v & 0xF) == 0xF || (v >> 4) == 0xF)
-            break;
-      }
-   } else {
-      stbtt__cff_int(b);
-   }
-}
-
-static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key)
-{
-   stbtt__buf_seek(b, 0);
-   while (b->cursor < b->size) {
-      int start = b->cursor, end, op;
-      while (stbtt__buf_peek8(b) >= 28)
-         stbtt__cff_skip_operand(b);
-      end = b->cursor;
-      op = stbtt__buf_get8(b);
-      if (op == 12)  op = stbtt__buf_get8(b) | 0x100;
-      if (op == key) return stbtt__buf_range(b, start, end-start);
-   }
-   return stbtt__buf_range(b, 0, 0);
-}
-
-static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out)
-{
-   int i;
-   stbtt__buf operands = stbtt__dict_get(b, key);
-   for (i = 0; i < outcount && operands.cursor < operands.size; i++)
-      out[i] = stbtt__cff_int(&operands);
-}
-
-static int stbtt__cff_index_count(stbtt__buf *b)
-{
-   stbtt__buf_seek(b, 0);
-   return stbtt__buf_get16(b);
-}
-
-static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i)
-{
-   int count, offsize, start, end;
-   stbtt__buf_seek(&b, 0);
-   count = stbtt__buf_get16(&b);
-   offsize = stbtt__buf_get8(&b);
-   STBTT_assert(i >= 0 && i < count);
-   STBTT_assert(offsize >= 1 && offsize <= 4);
-   stbtt__buf_skip(&b, i*offsize);
-   start = stbtt__buf_get(&b, offsize);
-   end = stbtt__buf_get(&b, offsize);
-   return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start);
-}
-
-//////////////////////////////////////////////////////////////////////////
-//
-// accessors to parse data from file
-//
-
-// on platforms that don't allow misaligned reads, if we want to allow
-// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE
-
-#define ttBYTE(p)     (* (stbtt_uint8 *) (p))
-#define ttCHAR(p)     (* (stbtt_int8 *) (p))
-#define ttFixed(p)    ttLONG(p)
-
-static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; }
-static stbtt_int16 ttSHORT(stbtt_uint8 *p)   { return p[0]*256 + p[1]; }
-static stbtt_uint32 ttULONG(stbtt_uint8 *p)  { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
-static stbtt_int32 ttLONG(stbtt_uint8 *p)    { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
-
-#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3))
-#define stbtt_tag(p,str)           stbtt_tag4(p,str[0],str[1],str[2],str[3])
-
-static int stbtt__isfont(stbtt_uint8 *font)
-{
-   // check the version number
-   if (stbtt_tag4(font, '1',0,0,0))  return 1; // TrueType 1
-   if (stbtt_tag(font, "typ1"))   return 1; // TrueType with type 1 font -- we don't support this!
-   if (stbtt_tag(font, "OTTO"))   return 1; // OpenType with CFF
-   if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0
-   if (stbtt_tag(font, "true"))   return 1; // Apple specification for TrueType fonts
-   return 0;
-}
-
-// @OPTIMIZE: binary search
-static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag)
-{
-   stbtt_int32 num_tables = ttUSHORT(data+fontstart+4);
-   stbtt_uint32 tabledir = fontstart + 12;
-   stbtt_int32 i;
-   for (i=0; i < num_tables; ++i) {
-      stbtt_uint32 loc = tabledir + 16*i;
-      if (stbtt_tag(data+loc+0, tag))
-         return ttULONG(data+loc+8);
-   }
-   return 0;
-}
-
-static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index)
-{
-   // if it's just a font, there's only one valid index
-   if (stbtt__isfont(font_collection))
-      return index == 0 ? 0 : -1;
-
-   // check if it's a TTC
-   if (stbtt_tag(font_collection, "ttcf")) {
-      // version 1?
-      if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
-         stbtt_int32 n = ttLONG(font_collection+8);
-         if (index >= n)
-            return -1;
-         return ttULONG(font_collection+12+index*4);
-      }
-   }
-   return -1;
-}
-
-static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection)
-{
-   // if it's just a font, there's only one valid font
-   if (stbtt__isfont(font_collection))
-      return 1;
-
-   // check if it's a TTC
-   if (stbtt_tag(font_collection, "ttcf")) {
-      // version 1?
-      if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) {
-         return ttLONG(font_collection+8);
-      }
-   }
-   return 0;
-}
-
-static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict)
-{
-   stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 };
-   stbtt__buf pdict;
-   stbtt__dict_get_ints(&fontdict, 18, 2, private_loc);
-   if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0);
-   pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]);
-   stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff);
-   if (!subrsoff) return stbtt__new_buf(NULL, 0);
-   stbtt__buf_seek(&cff, private_loc[1]+subrsoff);
-   return stbtt__cff_get_index(&cff);
-}
-
-// since most people won't use this, find this table the first time it's needed
-static int stbtt__get_svg(stbtt_fontinfo *info)
-{
-   stbtt_uint32 t;
-   if (info->svg < 0) {
-      t = stbtt__find_table(info->data, info->fontstart, "SVG ");
-      if (t) {
-         stbtt_uint32 offset = ttULONG(info->data + t + 2);
-         info->svg = t + offset;
-      } else {
-         info->svg = 0;
-      }
-   }
-   return info->svg;
-}
-
-static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart)
-{
-   stbtt_uint32 cmap, t;
-   stbtt_int32 i,numTables;
-
-   info->data = data;
-   info->fontstart = fontstart;
-   info->cff = stbtt__new_buf(NULL, 0);
-
-   cmap = stbtt__find_table(data, fontstart, "cmap");       // required
-   info->loca = stbtt__find_table(data, fontstart, "loca"); // required
-   info->head = stbtt__find_table(data, fontstart, "head"); // required
-   info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required
-   info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required
-   info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required
-   info->kern = stbtt__find_table(data, fontstart, "kern"); // not required
-   info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required
-
-   if (!cmap || !info->head || !info->hhea || !info->hmtx)
-      return 0;
-   if (info->glyf) {
-      // required for truetype
-      if (!info->loca) return 0;
-   } else {
-      // initialization for CFF / Type2 fonts (OTF)
-      stbtt__buf b, topdict, topdictidx;
-      stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0;
-      stbtt_uint32 cff;
-
-      cff = stbtt__find_table(data, fontstart, "CFF ");
-      if (!cff) return 0;
-
-      info->fontdicts = stbtt__new_buf(NULL, 0);
-      info->fdselect = stbtt__new_buf(NULL, 0);
-
-      // @TODO this should use size from table (not 512MB)
-      info->cff = stbtt__new_buf(data+cff, 512*1024*1024);
-      b = info->cff;
-
-      // read the header
-      stbtt__buf_skip(&b, 2);
-      stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize
-
-      // @TODO the name INDEX could list multiple fonts,
-      // but we just use the first one.
-      stbtt__cff_get_index(&b);  // name INDEX
-      topdictidx = stbtt__cff_get_index(&b);
-      topdict = stbtt__cff_index_get(topdictidx, 0);
-      stbtt__cff_get_index(&b);  // string INDEX
-      info->gsubrs = stbtt__cff_get_index(&b);
-
-      stbtt__dict_get_ints(&topdict, 17, 1, &charstrings);
-      stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype);
-      stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff);
-      stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff);
-      info->subrs = stbtt__get_subrs(b, topdict);
-
-      // we only support Type 2 charstrings
-      if (cstype != 2) return 0;
-      if (charstrings == 0) return 0;
-
-      if (fdarrayoff) {
-         // looks like a CID font
-         if (!fdselectoff) return 0;
-         stbtt__buf_seek(&b, fdarrayoff);
-         info->fontdicts = stbtt__cff_get_index(&b);
-         info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff);
-      }
-
-      stbtt__buf_seek(&b, charstrings);
-      info->charstrings = stbtt__cff_get_index(&b);
-   }
-
-   t = stbtt__find_table(data, fontstart, "maxp");
-   if (t)
-      info->numGlyphs = ttUSHORT(data+t+4);
-   else
-      info->numGlyphs = 0xffff;
-
-   info->svg = -1;
-
-   // find a cmap encoding table we understand *now* to avoid searching
-   // later. (todo: could make this installable)
-   // the same regardless of glyph.
-   numTables = ttUSHORT(data + cmap + 2);
-   info->index_map = 0;
-   for (i=0; i < numTables; ++i) {
-      stbtt_uint32 encoding_record = cmap + 4 + 8 * i;
-      // find an encoding we understand:
-      switch(ttUSHORT(data+encoding_record)) {
-         case STBTT_PLATFORM_ID_MICROSOFT:
-            switch (ttUSHORT(data+encoding_record+2)) {
-               case STBTT_MS_EID_UNICODE_BMP:
-               case STBTT_MS_EID_UNICODE_FULL:
-                  // MS/Unicode
-                  info->index_map = cmap + ttULONG(data+encoding_record+4);
-                  break;
-            }
-            break;
-        case STBTT_PLATFORM_ID_UNICODE:
-            // Mac/iOS has these
-            // all the encodingIDs are unicode, so we don't bother to check it
-            info->index_map = cmap + ttULONG(data+encoding_record+4);
-            break;
-      }
-   }
-   if (info->index_map == 0)
-      return 0;
-
-   info->indexToLocFormat = ttUSHORT(data+info->head + 50);
-   return 1;
-}
-
-STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
-{
-   stbtt_uint8 *data = info->data;
-   stbtt_uint32 index_map = info->index_map;
-
-   stbtt_uint16 format = ttUSHORT(data + index_map + 0);
-   if (format == 0) { // apple byte encoding
-      stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
-      if (unicode_codepoint < bytes-6)
-         return ttBYTE(data + index_map + 6 + unicode_codepoint);
-      return 0;
-   } else if (format == 6) {
-      stbtt_uint32 first = ttUSHORT(data + index_map + 6);
-      stbtt_uint32 count = ttUSHORT(data + index_map + 8);
-      if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count)
-         return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2);
-      return 0;
-   } else if (format == 2) {
-      STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean
-      return 0;
-   } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges
-      stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1;
-      stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1;
-      stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10);
-      stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1;
-
-      // do a binary search of the segments
-      stbtt_uint32 endCount = index_map + 14;
-      stbtt_uint32 search = endCount;
-
-      if (unicode_codepoint > 0xffff)
-         return 0;
-
-      // they lie from endCount .. endCount + segCount
-      // but searchRange is the nearest power of two, so...
-      if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2))
-         search += rangeShift*2;
-
-      // now decrement to bias correctly to find smallest
-      search -= 2;
-      while (entrySelector) {
-         stbtt_uint16 end;
-         searchRange >>= 1;
-         end = ttUSHORT(data + search + searchRange*2);
-         if (unicode_codepoint > end)
-            search += searchRange*2;
-         --entrySelector;
-      }
-      search += 2;
-
-      {
-         stbtt_uint16 offset, start;
-         stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1);
-
-         STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item));
-         start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item);
-         if (unicode_codepoint < start)
-            return 0;
-
-         offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item);
-         if (offset == 0)
-            return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item));
-
-         return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item);
-      }
-   } else if (format == 12 || format == 13) {
-      stbtt_uint32 ngroups = ttULONG(data+index_map+12);
-      stbtt_int32 low,high;
-      low = 0; high = (stbtt_int32)ngroups;
-      // Binary search the right group.
-      while (low < high) {
-         stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high
-         stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12);
-         stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4);
-         if ((stbtt_uint32) unicode_codepoint < start_char)
-            high = mid;
-         else if ((stbtt_uint32) unicode_codepoint > end_char)
-            low = mid+1;
-         else {
-            stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8);
-            if (format == 12)
-               return start_glyph + unicode_codepoint-start_char;
-            else // format == 13
-               return start_glyph;
-         }
-      }
-      return 0; // not found
-   }
-   // @TODO
-   STBTT_assert(0);
-   return 0;
-}
-
-STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
-{
-   return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
-}
-
-static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy)
-{
-   v->type = type;
-   v->x = (stbtt_int16) x;
-   v->y = (stbtt_int16) y;
-   v->cx = (stbtt_int16) cx;
-   v->cy = (stbtt_int16) cy;
-}
-
-static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
-{
-   int g1,g2;
-
-   STBTT_assert(!info->cff.size);
-
-   if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range
-   if (info->indexToLocFormat >= 2)    return -1; // unknown index->glyph map format
-
-   if (info->indexToLocFormat == 0) {
-      g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2;
-      g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2;
-   } else {
-      g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4);
-      g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4);
-   }
-
-   return g1==g2 ? -1 : g1; // if length is 0, return -1
-}
-
-static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
-
-STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
-{
-   if (info->cff.size) {
-      stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1);
-   } else {
-      int g = stbtt__GetGlyfOffset(info, glyph_index);
-      if (g < 0) return 0;
-
-      if (x0) *x0 = ttSHORT(info->data + g + 2);
-      if (y0) *y0 = ttSHORT(info->data + g + 4);
-      if (x1) *x1 = ttSHORT(info->data + g + 6);
-      if (y1) *y1 = ttSHORT(info->data + g + 8);
-   }
-   return 1;
-}
-
-STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
-{
-   return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
-}
-
-STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
-{
-   stbtt_int16 numberOfContours;
-   int g;
-   if (info->cff.size)
-      return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0;
-   g = stbtt__GetGlyfOffset(info, glyph_index);
-   if (g < 0) return 1;
-   numberOfContours = ttSHORT(info->data + g);
-   return numberOfContours == 0;
-}
-
-static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off,
-    stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy)
-{
-   if (start_off) {
-      if (was_off)
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy);
-      stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy);
-   } else {
-      if (was_off)
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy);
-      else
-         stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0);
-   }
-   return num_vertices;
-}
-
-static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   stbtt_int16 numberOfContours;
-   stbtt_uint8 *endPtsOfContours;
-   stbtt_uint8 *data = info->data;
-   stbtt_vertex *vertices=0;
-   int num_vertices=0;
-   int g = stbtt__GetGlyfOffset(info, glyph_index);
-
-   *pvertices = NULL;
-
-   if (g < 0) return 0;
-
-   numberOfContours = ttSHORT(data + g);
-
-   if (numberOfContours > 0) {
-      stbtt_uint8 flags=0,flagcount;
-      stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0;
-      stbtt_int32 x,y,cx,cy,sx,sy, scx,scy;
-      stbtt_uint8 *points;
-      endPtsOfContours = (data + g + 10);
-      ins = ttUSHORT(data + g + 10 + numberOfContours * 2);
-      points = data + g + 10 + numberOfContours * 2 + 2 + ins;
-
-      n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2);
-
-      m = n + 2*numberOfContours;  // a loose bound on how many vertices we might need
-      vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata);
-      if (vertices == 0)
-         return 0;
-
-      next_move = 0;
-      flagcount=0;
-
-      // in first pass, we load uninterpreted data into the allocated array
-      // above, shifted to the end of the array so we won't overwrite it when
-      // we create our final data starting from the front
-
-      off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated
-
-      // first load flags
-
-      for (i=0; i < n; ++i) {
-         if (flagcount == 0) {
-            flags = *points++;
-            if (flags & 8)
-               flagcount = *points++;
-         } else
-            --flagcount;
-         vertices[off+i].type = flags;
-      }
-
-      // now load x coordinates
-      x=0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         if (flags & 2) {
-            stbtt_int16 dx = *points++;
-            x += (flags & 16) ? dx : -dx; // ???
-         } else {
-            if (!(flags & 16)) {
-               x = x + (stbtt_int16) (points[0]*256 + points[1]);
-               points += 2;
-            }
-         }
-         vertices[off+i].x = (stbtt_int16) x;
-      }
-
-      // now load y coordinates
-      y=0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         if (flags & 4) {
-            stbtt_int16 dy = *points++;
-            y += (flags & 32) ? dy : -dy; // ???
-         } else {
-            if (!(flags & 32)) {
-               y = y + (stbtt_int16) (points[0]*256 + points[1]);
-               points += 2;
-            }
-         }
-         vertices[off+i].y = (stbtt_int16) y;
-      }
-
-      // now convert them to our format
-      num_vertices=0;
-      sx = sy = cx = cy = scx = scy = 0;
-      for (i=0; i < n; ++i) {
-         flags = vertices[off+i].type;
-         x     = (stbtt_int16) vertices[off+i].x;
-         y     = (stbtt_int16) vertices[off+i].y;
-
-         if (next_move == i) {
-            if (i != 0)
-               num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
-
-            // now start the new one
-            start_off = !(flags & 1);
-            if (start_off) {
-               // if we start off with an off-curve point, then when we need to find a point on the curve
-               // where we can start, and we need to save some state for when we wraparound.
-               scx = x;
-               scy = y;
-               if (!(vertices[off+i+1].type & 1)) {
-                  // next point is also a curve point, so interpolate an on-point curve
-                  sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1;
-                  sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1;
-               } else {
-                  // otherwise just use the next point as our start point
-                  sx = (stbtt_int32) vertices[off+i+1].x;
-                  sy = (stbtt_int32) vertices[off+i+1].y;
-                  ++i; // we're using point i+1 as the starting point, so skip it
-               }
-            } else {
-               sx = x;
-               sy = y;
-            }
-            stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0);
-            was_off = 0;
-            next_move = 1 + ttUSHORT(endPtsOfContours+j*2);
-            ++j;
-         } else {
-            if (!(flags & 1)) { // if it's a curve
-               if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy);
-               cx = x;
-               cy = y;
-               was_off = 1;
-            } else {
-               if (was_off)
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy);
-               else
-                  stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0);
-               was_off = 0;
-            }
-         }
-      }
-      num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy);
-   } else if (numberOfContours < 0) {
-      // Compound shapes.
-      int more = 1;
-      stbtt_uint8 *comp = data + g + 10;
-      num_vertices = 0;
-      vertices = 0;
-      while (more) {
-         stbtt_uint16 flags, gidx;
-         int comp_num_verts = 0, i;
-         stbtt_vertex *comp_verts = 0, *tmp = 0;
-         float mtx[6] = {1,0,0,1,0,0}, m, n;
-
-         flags = ttSHORT(comp); comp+=2;
-         gidx = ttSHORT(comp); comp+=2;
-
-         if (flags & 2) { // XY values
-            if (flags & 1) { // shorts
-               mtx[4] = ttSHORT(comp); comp+=2;
-               mtx[5] = ttSHORT(comp); comp+=2;
-            } else {
-               mtx[4] = ttCHAR(comp); comp+=1;
-               mtx[5] = ttCHAR(comp); comp+=1;
-            }
-         }
-         else {
-            // @TODO handle matching point
-            STBTT_assert(0);
-         }
-         if (flags & (1<<3)) { // WE_HAVE_A_SCALE
-            mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = mtx[2] = 0;
-         } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE
-            mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = mtx[2] = 0;
-            mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-         } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO
-            mtx[0] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[1] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[2] = ttSHORT(comp)/16384.0f; comp+=2;
-            mtx[3] = ttSHORT(comp)/16384.0f; comp+=2;
-         }
-
-         // Find transformation scales.
-         m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]);
-         n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]);
-
-         // Get indexed glyph.
-         comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts);
-         if (comp_num_verts > 0) {
-            // Transform vertices.
-            for (i = 0; i < comp_num_verts; ++i) {
-               stbtt_vertex* v = &comp_verts[i];
-               stbtt_vertex_type x,y;
-               x=v->x; y=v->y;
-               v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
-               v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
-               x=v->cx; y=v->cy;
-               v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4]));
-               v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5]));
-            }
-            // Append vertices.
-            tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata);
-            if (!tmp) {
-               if (vertices) STBTT_free(vertices, info->userdata);
-               if (comp_verts) STBTT_free(comp_verts, info->userdata);
-               return 0;
-            }
-            if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex));
-            STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex));
-            if (vertices) STBTT_free(vertices, info->userdata);
-            vertices = tmp;
-            STBTT_free(comp_verts, info->userdata);
-            num_vertices += comp_num_verts;
-         }
-         // More components ?
-         more = flags & (1<<5);
-      }
-   } else {
-      // numberOfCounters == 0, do nothing
-   }
-
-   *pvertices = vertices;
-   return num_vertices;
-}
-
-typedef struct
-{
-   int bounds;
-   int started;
-   float first_x, first_y;
-   float x, y;
-   stbtt_int32 min_x, max_x, min_y, max_y;
-
-   stbtt_vertex *pvertices;
-   int num_vertices;
-} stbtt__csctx;
-
-#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0}
-
-static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y)
-{
-   if (x > c->max_x || !c->started) c->max_x = x;
-   if (y > c->max_y || !c->started) c->max_y = y;
-   if (x < c->min_x || !c->started) c->min_x = x;
-   if (y < c->min_y || !c->started) c->min_y = y;
-   c->started = 1;
-}
-
-static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1)
-{
-   if (c->bounds) {
-      stbtt__track_vertex(c, x, y);
-      if (type == STBTT_vcubic) {
-         stbtt__track_vertex(c, cx, cy);
-         stbtt__track_vertex(c, cx1, cy1);
-      }
-   } else {
-      stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy);
-      c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1;
-      c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1;
-   }
-   c->num_vertices++;
-}
-
-static void stbtt__csctx_close_shape(stbtt__csctx *ctx)
-{
-   if (ctx->first_x != ctx->x || ctx->first_y != ctx->y)
-      stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy)
-{
-   stbtt__csctx_close_shape(ctx);
-   ctx->first_x = ctx->x = ctx->x + dx;
-   ctx->first_y = ctx->y = ctx->y + dy;
-   stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy)
-{
-   ctx->x += dx;
-   ctx->y += dy;
-   stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0);
-}
-
-static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)
-{
-   float cx1 = ctx->x + dx1;
-   float cy1 = ctx->y + dy1;
-   float cx2 = cx1 + dx2;
-   float cy2 = cy1 + dy2;
-   ctx->x = cx2 + dx3;
-   ctx->y = cy2 + dy3;
-   stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2);
-}
-
-static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n)
-{
-   int count = stbtt__cff_index_count(&idx);
-   int bias = 107;
-   if (count >= 33900)
-      bias = 32768;
-   else if (count >= 1240)
-      bias = 1131;
-   n += bias;
-   if (n < 0 || n >= count)
-      return stbtt__new_buf(NULL, 0);
-   return stbtt__cff_index_get(idx, n);
-}
-
-static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index)
-{
-   stbtt__buf fdselect = info->fdselect;
-   int nranges, start, end, v, fmt, fdselector = -1, i;
-
-   stbtt__buf_seek(&fdselect, 0);
-   fmt = stbtt__buf_get8(&fdselect);
-   if (fmt == 0) {
-      // untested
-      stbtt__buf_skip(&fdselect, glyph_index);
-      fdselector = stbtt__buf_get8(&fdselect);
-   } else if (fmt == 3) {
-      nranges = stbtt__buf_get16(&fdselect);
-      start = stbtt__buf_get16(&fdselect);
-      for (i = 0; i < nranges; i++) {
-         v = stbtt__buf_get8(&fdselect);
-         end = stbtt__buf_get16(&fdselect);
-         if (glyph_index >= start && glyph_index < end) {
-            fdselector = v;
-            break;
-         }
-         start = end;
-      }
-   }
-   if (fdselector == -1) stbtt__new_buf(NULL, 0);
-   return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector));
-}
-
-static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c)
-{
-   int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0;
-   int has_subrs = 0, clear_stack;
-   float s[48];
-   stbtt__buf subr_stack[10], subrs = info->subrs, b;
-   float f;
-
-#define STBTT__CSERR(s) (0)
-
-   // this currently ignores the initial width value, which isn't needed if we have hmtx
-   b = stbtt__cff_index_get(info->charstrings, glyph_index);
-   while (b.cursor < b.size) {
-      i = 0;
-      clear_stack = 1;
-      b0 = stbtt__buf_get8(&b);
-      switch (b0) {
-      // @TODO implement hinting
-      case 0x13: // hintmask
-      case 0x14: // cntrmask
-         if (in_header)
-            maskbits += (sp / 2); // implicit "vstem"
-         in_header = 0;
-         stbtt__buf_skip(&b, (maskbits + 7) / 8);
-         break;
-
-      case 0x01: // hstem
-      case 0x03: // vstem
-      case 0x12: // hstemhm
-      case 0x17: // vstemhm
-         maskbits += (sp / 2);
-         break;
-
-      case 0x15: // rmoveto
-         in_header = 0;
-         if (sp < 2) return STBTT__CSERR("rmoveto stack");
-         stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]);
-         break;
-      case 0x04: // vmoveto
-         in_header = 0;
-         if (sp < 1) return STBTT__CSERR("vmoveto stack");
-         stbtt__csctx_rmove_to(c, 0, s[sp-1]);
-         break;
-      case 0x16: // hmoveto
-         in_header = 0;
-         if (sp < 1) return STBTT__CSERR("hmoveto stack");
-         stbtt__csctx_rmove_to(c, s[sp-1], 0);
-         break;
-
-      case 0x05: // rlineto
-         if (sp < 2) return STBTT__CSERR("rlineto stack");
-         for (; i + 1 < sp; i += 2)
-            stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         break;
-
-      // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical
-      // starting from a different place.
-
-      case 0x07: // vlineto
-         if (sp < 1) return STBTT__CSERR("vlineto stack");
-         goto vlineto;
-      case 0x06: // hlineto
-         if (sp < 1) return STBTT__CSERR("hlineto stack");
-         for (;;) {
-            if (i >= sp) break;
-            stbtt__csctx_rline_to(c, s[i], 0);
-            i++;
-      vlineto:
-            if (i >= sp) break;
-            stbtt__csctx_rline_to(c, 0, s[i]);
-            i++;
-         }
-         break;
-
-      case 0x1F: // hvcurveto
-         if (sp < 4) return STBTT__CSERR("hvcurveto stack");
-         goto hvcurveto;
-      case 0x1E: // vhcurveto
-         if (sp < 4) return STBTT__CSERR("vhcurveto stack");
-         for (;;) {
-            if (i + 3 >= sp) break;
-            stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f);
-            i += 4;
-      hvcurveto:
-            if (i + 3 >= sp) break;
-            stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]);
-            i += 4;
-         }
-         break;
-
-      case 0x08: // rrcurveto
-         if (sp < 6) return STBTT__CSERR("rcurveline stack");
-         for (; i + 5 < sp; i += 6)
-            stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         break;
-
-      case 0x18: // rcurveline
-         if (sp < 8) return STBTT__CSERR("rcurveline stack");
-         for (; i + 5 < sp - 2; i += 6)
-            stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack");
-         stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         break;
-
-      case 0x19: // rlinecurve
-         if (sp < 8) return STBTT__CSERR("rlinecurve stack");
-         for (; i + 1 < sp - 6; i += 2)
-            stbtt__csctx_rline_to(c, s[i], s[i+1]);
-         if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack");
-         stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]);
-         break;
-
-      case 0x1A: // vvcurveto
-      case 0x1B: // hhcurveto
-         if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack");
-         f = 0.0;
-         if (sp & 1) { f = s[i]; i++; }
-         for (; i + 3 < sp; i += 4) {
-            if (b0 == 0x1B)
-               stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0);
-            else
-               stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]);
-            f = 0.0;
-         }
-         break;
-
-      case 0x0A: // callsubr
-         if (!has_subrs) {
-            if (info->fdselect.size)
-               subrs = stbtt__cid_get_glyph_subrs(info, glyph_index);
-            has_subrs = 1;
-         }
-         // fallthrough
-      case 0x1D: // callgsubr
-         if (sp < 1) return STBTT__CSERR("call(g|)subr stack");
-         v = (int) s[--sp];
-         if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit");
-         subr_stack[subr_stack_height++] = b;
-         b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v);
-         if (b.size == 0) return STBTT__CSERR("subr not found");
-         b.cursor = 0;
-         clear_stack = 0;
-         break;
-
-      case 0x0B: // return
-         if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr");
-         b = subr_stack[--subr_stack_height];
-         clear_stack = 0;
-         break;
-
-      case 0x0E: // endchar
-         stbtt__csctx_close_shape(c);
-         return 1;
-
-      case 0x0C: { // two-byte escape
-         float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6;
-         float dx, dy;
-         int b1 = stbtt__buf_get8(&b);
-         switch (b1) {
-         // @TODO These "flex" implementations ignore the flex-depth and resolution,
-         // and always draw beziers.
-         case 0x22: // hflex
-            if (sp < 7) return STBTT__CSERR("hflex stack");
-            dx1 = s[0];
-            dx2 = s[1];
-            dy2 = s[2];
-            dx3 = s[3];
-            dx4 = s[4];
-            dx5 = s[5];
-            dx6 = s[6];
-            stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0);
-            stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0);
-            break;
-
-         case 0x23: // flex
-            if (sp < 13) return STBTT__CSERR("flex stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dy3 = s[5];
-            dx4 = s[6];
-            dy4 = s[7];
-            dx5 = s[8];
-            dy5 = s[9];
-            dx6 = s[10];
-            dy6 = s[11];
-            //fd is s[12]
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
-            stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
-            break;
-
-         case 0x24: // hflex1
-            if (sp < 9) return STBTT__CSERR("hflex1 stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dx4 = s[5];
-            dx5 = s[6];
-            dy5 = s[7];
-            dx6 = s[8];
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0);
-            stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5));
-            break;
-
-         case 0x25: // flex1
-            if (sp < 11) return STBTT__CSERR("flex1 stack");
-            dx1 = s[0];
-            dy1 = s[1];
-            dx2 = s[2];
-            dy2 = s[3];
-            dx3 = s[4];
-            dy3 = s[5];
-            dx4 = s[6];
-            dy4 = s[7];
-            dx5 = s[8];
-            dy5 = s[9];
-            dx6 = dy6 = s[10];
-            dx = dx1+dx2+dx3+dx4+dx5;
-            dy = dy1+dy2+dy3+dy4+dy5;
-            if (STBTT_fabs(dx) > STBTT_fabs(dy))
-               dy6 = -dy;
-            else
-               dx6 = -dx;
-            stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3);
-            stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6);
-            break;
-
-         default:
-            return STBTT__CSERR("unimplemented");
-         }
-      } break;
-
-      default:
-         if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254))
-            return STBTT__CSERR("reserved operator");
-
-         // push immediate
-         if (b0 == 255) {
-            f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000;
-         } else {
-            stbtt__buf_skip(&b, -1);
-            f = (float)(stbtt_int16)stbtt__cff_int(&b);
-         }
-         if (sp >= 48) return STBTT__CSERR("push stack overflow");
-         s[sp++] = f;
-         clear_stack = 0;
-         break;
-      }
-      if (clear_stack) sp = 0;
-   }
-   return STBTT__CSERR("no endchar");
-
-#undef STBTT__CSERR
-}
-
-static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   // runs the charstring twice, once to count and once to output (to avoid realloc)
-   stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1);
-   stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0);
-   if (stbtt__run_charstring(info, glyph_index, &count_ctx)) {
-      *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata);
-      output_ctx.pvertices = *pvertices;
-      if (stbtt__run_charstring(info, glyph_index, &output_ctx)) {
-         STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices);
-         return output_ctx.num_vertices;
-      }
-   }
-   *pvertices = NULL;
-   return 0;
-}
-
-static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
-{
-   stbtt__csctx c = STBTT__CSCTX_INIT(1);
-   int r = stbtt__run_charstring(info, glyph_index, &c);
-   if (x0)  *x0 = r ? c.min_x : 0;
-   if (y0)  *y0 = r ? c.min_y : 0;
-   if (x1)  *x1 = r ? c.max_x : 0;
-   if (y1)  *y1 = r ? c.max_y : 0;
-   return r ? c.num_vertices : 0;
-}
-
-STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
-{
-   if (!info->cff.size)
-      return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices);
-   else
-      return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices);
-}
-
-STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
-{
-   stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
-   if (glyph_index < numOfLongHorMetrics) {
-      if (advanceWidth)     *advanceWidth    = ttSHORT(info->data + info->hmtx + 4*glyph_index);
-      if (leftSideBearing)  *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2);
-   } else {
-      if (advanceWidth)     *advanceWidth    = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1));
-      if (leftSideBearing)  *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics));
-   }
-}
-
-STBTT_DEF int  stbtt_GetKerningTableLength(const stbtt_fontinfo *info)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   return ttUSHORT(data+10);
-}
-
-STBTT_DEF int stbtt_GetKerningTable(const stbtt_fontinfo *info, stbtt_kerningentry* table, int table_length)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-   int k, length;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   length = ttUSHORT(data+10);
-   if (table_length < length)
-      length = table_length;
-
-   for (k = 0; k < length; k++)
-   {
-      table[k].glyph1 = ttUSHORT(data+18+(k*6));
-      table[k].glyph2 = ttUSHORT(data+20+(k*6));
-      table[k].advance = ttSHORT(data+22+(k*6));
-   }
-
-   return length;
-}
-
-static int  stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
-{
-   stbtt_uint8 *data = info->data + info->kern;
-   stbtt_uint32 needle, straw;
-   int l, r, m;
-
-   // we only look at the first table. it must be 'horizontal' and format 0.
-   if (!info->kern)
-      return 0;
-   if (ttUSHORT(data+2) < 1) // number of tables, need at least 1
-      return 0;
-   if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format
-      return 0;
-
-   l = 0;
-   r = ttUSHORT(data+10) - 1;
-   needle = glyph1 << 16 | glyph2;
-   while (l <= r) {
-      m = (l + r) >> 1;
-      straw = ttULONG(data+18+(m*6)); // note: unaligned read
-      if (needle < straw)
-         r = m - 1;
-      else if (needle > straw)
-         l = m + 1;
-      else
-         return ttSHORT(data+22+(m*6));
-   }
-   return 0;
-}
-
-static stbtt_int32  stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph)
-{
-    stbtt_uint16 coverageFormat = ttUSHORT(coverageTable);
-    switch(coverageFormat) {
-        case 1: {
-            stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2);
-
-            // Binary search.
-            stbtt_int32 l=0, r=glyphCount-1, m;
-            int straw, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *glyphArray = coverageTable + 4;
-                stbtt_uint16 glyphID;
-                m = (l + r) >> 1;
-                glyphID = ttUSHORT(glyphArray + 2 * m);
-                straw = glyphID;
-                if (needle < straw)
-                    r = m - 1;
-                else if (needle > straw)
-                    l = m + 1;
-                else {
-                     return m;
-                }
-            }
-        } break;
-
-        case 2: {
-            stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2);
-            stbtt_uint8 *rangeArray = coverageTable + 4;
-
-            // Binary search.
-            stbtt_int32 l=0, r=rangeCount-1, m;
-            int strawStart, strawEnd, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *rangeRecord;
-                m = (l + r) >> 1;
-                rangeRecord = rangeArray + 6 * m;
-                strawStart = ttUSHORT(rangeRecord);
-                strawEnd = ttUSHORT(rangeRecord + 2);
-                if (needle < strawStart)
-                    r = m - 1;
-                else if (needle > strawEnd)
-                    l = m + 1;
-                else {
-                    stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4);
-                    return startCoverageIndex + glyph - strawStart;
-                }
-            }
-        } break;
-
-        default: {
-            // There are no other cases.
-            STBTT_assert(0);
-        } break;
-    }
-
-    return -1;
-}
-
-static stbtt_int32  stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph)
-{
-    stbtt_uint16 classDefFormat = ttUSHORT(classDefTable);
-    switch(classDefFormat)
-    {
-        case 1: {
-            stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2);
-            stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4);
-            stbtt_uint8 *classDef1ValueArray = classDefTable + 6;
-
-            if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount)
-                return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID));
-
-            classDefTable = classDef1ValueArray + 2 * glyphCount;
-        } break;
-
-        case 2: {
-            stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2);
-            stbtt_uint8 *classRangeRecords = classDefTable + 4;
-
-            // Binary search.
-            stbtt_int32 l=0, r=classRangeCount-1, m;
-            int strawStart, strawEnd, needle=glyph;
-            while (l <= r) {
-                stbtt_uint8 *classRangeRecord;
-                m = (l + r) >> 1;
-                classRangeRecord = classRangeRecords + 6 * m;
-                strawStart = ttUSHORT(classRangeRecord);
-                strawEnd = ttUSHORT(classRangeRecord + 2);
-                if (needle < strawStart)
-                    r = m - 1;
-                else if (needle > strawEnd)
-                    l = m + 1;
-                else
-                    return (stbtt_int32)ttUSHORT(classRangeRecord + 4);
-            }
-
-            classDefTable = classRangeRecords + 6 * classRangeCount;
-        } break;
-
-        default: {
-            // There are no other cases.
-            STBTT_assert(0);
-        } break;
-    }
-
-    return -1;
-}
-
-// Define to STBTT_assert(x) if you want to break on unimplemented formats.
-#define STBTT_GPOS_TODO_assert(x)
-
-static stbtt_int32  stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
-{
-    stbtt_uint16 lookupListOffset;
-    stbtt_uint8 *lookupList;
-    stbtt_uint16 lookupCount;
-    stbtt_uint8 *data;
-    stbtt_int32 i;
-
-    if (!info->gpos) return 0;
-
-    data = info->data + info->gpos;
-
-    if (ttUSHORT(data+0) != 1) return 0; // Major version 1
-    if (ttUSHORT(data+2) != 0) return 0; // Minor version 0
-
-    lookupListOffset = ttUSHORT(data+8);
-    lookupList = data + lookupListOffset;
-    lookupCount = ttUSHORT(lookupList);
-
-    for (i=0; i<lookupCount; ++i) {
-        stbtt_uint16 lookupOffset = ttUSHORT(lookupList + 2 + 2 * i);
-        stbtt_uint8 *lookupTable = lookupList + lookupOffset;
-
-        stbtt_uint16 lookupType = ttUSHORT(lookupTable);
-        stbtt_uint16 subTableCount = ttUSHORT(lookupTable + 4);
-        stbtt_uint8 *subTableOffsets = lookupTable + 6;
-        switch(lookupType) {
-            case 2: { // Pair Adjustment Positioning Subtable
-                stbtt_int32 sti;
-                for (sti=0; sti<subTableCount; sti++) {
-                    stbtt_uint16 subtableOffset = ttUSHORT(subTableOffsets + 2 * sti);
-                    stbtt_uint8 *table = lookupTable + subtableOffset;
-                    stbtt_uint16 posFormat = ttUSHORT(table);
-                    stbtt_uint16 coverageOffset = ttUSHORT(table + 2);
-                    stbtt_int32 coverageIndex = stbtt__GetCoverageIndex(table + coverageOffset, glyph1);
-                    if (coverageIndex == -1) continue;
-
-                    switch (posFormat) {
-                        case 1: {
-                            stbtt_int32 l, r, m;
-                            int straw, needle;
-                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
-                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
-                            stbtt_int32 valueRecordPairSizeInBytes = 2;
-                            stbtt_uint16 pairSetCount = ttUSHORT(table + 8);
-                            stbtt_uint16 pairPosOffset = ttUSHORT(table + 10 + 2 * coverageIndex);
-                            stbtt_uint8 *pairValueTable = table + pairPosOffset;
-                            stbtt_uint16 pairValueCount = ttUSHORT(pairValueTable);
-                            stbtt_uint8 *pairValueArray = pairValueTable + 2;
-                            // TODO: Support more formats.
-                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
-                            if (valueFormat1 != 4) return 0;
-                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
-                            if (valueFormat2 != 0) return 0;
-
-                            STBTT_assert(coverageIndex < pairSetCount);
-                            STBTT__NOTUSED(pairSetCount);
-
-                            needle=glyph2;
-                            r=pairValueCount-1;
-                            l=0;
-
-                            // Binary search.
-                            while (l <= r) {
-                                stbtt_uint16 secondGlyph;
-                                stbtt_uint8 *pairValue;
-                                m = (l + r) >> 1;
-                                pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m;
-                                secondGlyph = ttUSHORT(pairValue);
-                                straw = secondGlyph;
-                                if (needle < straw)
-                                    r = m - 1;
-                                else if (needle > straw)
-                                    l = m + 1;
-                                else {
-                                    stbtt_int16 xAdvance = ttSHORT(pairValue + 2);
-                                    return xAdvance;
-                                }
-                            }
-                        } break;
-
-                        case 2: {
-                            stbtt_uint16 valueFormat1 = ttUSHORT(table + 4);
-                            stbtt_uint16 valueFormat2 = ttUSHORT(table + 6);
-
-                            stbtt_uint16 classDef1Offset = ttUSHORT(table + 8);
-                            stbtt_uint16 classDef2Offset = ttUSHORT(table + 10);
-                            int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1);
-                            int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2);
-
-                            stbtt_uint16 class1Count = ttUSHORT(table + 12);
-                            stbtt_uint16 class2Count = ttUSHORT(table + 14);
-                            STBTT_assert(glyph1class < class1Count);
-                            STBTT_assert(glyph2class < class2Count);
-
-                            // TODO: Support more formats.
-                            STBTT_GPOS_TODO_assert(valueFormat1 == 4);
-                            if (valueFormat1 != 4) return 0;
-                            STBTT_GPOS_TODO_assert(valueFormat2 == 0);
-                            if (valueFormat2 != 0) return 0;
-
-                            if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) {
-                                stbtt_uint8 *class1Records = table + 16;
-                                stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count);
-                                stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class);
-                                return xAdvance;
-                            }
-                        } break;
-
-                        default: {
-                            // There are no other cases.
-                            STBTT_assert(0);
-                            break;
-                        };
-                    }
-                }
-                break;
-            };
-
-            default:
-                // TODO: Implement other stuff.
-                break;
-        }
-    }
-
-    return 0;
-}
-
-STBTT_DEF int  stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2)
-{
-   int xAdvance = 0;
-
-   if (info->gpos)
-      xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2);
-   else if (info->kern)
-      xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2);
-
-   return xAdvance;
-}
-
-STBTT_DEF int  stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
-{
-   if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs
-      return 0;
-   return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
-}
-
-STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
-{
-   stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
-}
-
-STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
-{
-   if (ascent ) *ascent  = ttSHORT(info->data+info->hhea + 4);
-   if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
-   if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
-}
-
-STBTT_DEF int  stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap)
-{
-   int tab = stbtt__find_table(info->data, info->fontstart, "OS/2");
-   if (!tab)
-      return 0;
-   if (typoAscent ) *typoAscent  = ttSHORT(info->data+tab + 68);
-   if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70);
-   if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72);
-   return 1;
-}
-
-STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
-{
-   *x0 = ttSHORT(info->data + info->head + 36);
-   *y0 = ttSHORT(info->data + info->head + 38);
-   *x1 = ttSHORT(info->data + info->head + 40);
-   *y1 = ttSHORT(info->data + info->head + 42);
-}
-
-STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
-{
-   int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
-   return (float) height / fheight;
-}
-
-STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
-{
-   int unitsPerEm = ttUSHORT(info->data + info->head + 18);
-   return pixels / unitsPerEm;
-}
-
-STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
-{
-   STBTT_free(v, info->userdata);
-}
-
-STBTT_DEF stbtt_uint8 *stbtt_FindSVGDoc(const stbtt_fontinfo *info, int gl)
-{
-   int i;
-   stbtt_uint8 *data = info->data;
-   stbtt_uint8 *svg_doc_list = data + stbtt__get_svg((stbtt_fontinfo *) info);
-
-   int numEntries = ttUSHORT(svg_doc_list);
-   stbtt_uint8 *svg_docs = svg_doc_list + 2;
-
-   for(i=0; i<numEntries; i++) {
-      stbtt_uint8 *svg_doc = svg_docs + (12 * i);
-      if ((gl >= ttUSHORT(svg_doc)) && (gl <= ttUSHORT(svg_doc + 2)))
-         return svg_doc;
-   }
-   return 0;
-}
-
-STBTT_DEF int stbtt_GetGlyphSVG(const stbtt_fontinfo *info, int gl, const char **svg)
-{
-   stbtt_uint8 *data = info->data;
-   stbtt_uint8 *svg_doc;
-
-   if (info->svg == 0)
-      return 0;
-
-   svg_doc = stbtt_FindSVGDoc(info, gl);
-   if (svg_doc != NULL) {
-      *svg = (char *) data + info->svg + ttULONG(svg_doc + 4);
-      return ttULONG(svg_doc + 8);
-   } else {
-      return 0;
-   }
-}
-
-STBTT_DEF int stbtt_GetCodepointSVG(const stbtt_fontinfo *info, int unicode_codepoint, const char **svg)
-{
-   return stbtt_GetGlyphSVG(info, stbtt_FindGlyphIndex(info, unicode_codepoint), svg);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// antialiasing software rasterizer
-//
-
-STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning
-   if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
-      // e.g. space character
-      if (ix0) *ix0 = 0;
-      if (iy0) *iy0 = 0;
-      if (ix1) *ix1 = 0;
-      if (iy1) *iy1 = 0;
-   } else {
-      // move to integral bboxes (treating pixels as little squares, what pixels get touched)?
-      if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x);
-      if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y);
-      if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x);
-      if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y);
-   }
-}
-
-STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
-}
-
-STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
-}
-
-STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
-{
-   stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  Rasterizer
-
-typedef struct stbtt__hheap_chunk
-{
-   struct stbtt__hheap_chunk *next;
-} stbtt__hheap_chunk;
-
-typedef struct stbtt__hheap
-{
-   struct stbtt__hheap_chunk *head;
-   void   *first_free;
-   int    num_remaining_in_head_chunk;
-} stbtt__hheap;
-
-static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata)
-{
-   if (hh->first_free) {
-      void *p = hh->first_free;
-      hh->first_free = * (void **) p;
-      return p;
-   } else {
-      if (hh->num_remaining_in_head_chunk == 0) {
-         int count = (size < 32 ? 2000 : size < 128 ? 800 : 100);
-         stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata);
-         if (c == NULL)
-            return NULL;
-         c->next = hh->head;
-         hh->head = c;
-         hh->num_remaining_in_head_chunk = count;
-      }
-      --hh->num_remaining_in_head_chunk;
-      return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk;
-   }
-}
-
-static void stbtt__hheap_free(stbtt__hheap *hh, void *p)
-{
-   *(void **) p = hh->first_free;
-   hh->first_free = p;
-}
-
-static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata)
-{
-   stbtt__hheap_chunk *c = hh->head;
-   while (c) {
-      stbtt__hheap_chunk *n = c->next;
-      STBTT_free(c, userdata);
-      c = n;
-   }
-}
-
-typedef struct stbtt__edge {
-   float x0,y0, x1,y1;
-   int invert;
-} stbtt__edge;
-
-
-typedef struct stbtt__active_edge
-{
-   struct stbtt__active_edge *next;
-   #if STBTT_RASTERIZER_VERSION==1
-   int x,dx;
-   float ey;
-   int direction;
-   #elif STBTT_RASTERIZER_VERSION==2
-   float fx,fdx,fdy;
-   float direction;
-   float sy;
-   float ey;
-   #else
-   #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-   #endif
-} stbtt__active_edge;
-
-#if STBTT_RASTERIZER_VERSION == 1
-#define STBTT_FIXSHIFT   10
-#define STBTT_FIX        (1 << STBTT_FIXSHIFT)
-#define STBTT_FIXMASK    (STBTT_FIX-1)
-
-static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
-{
-   stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
-   float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-   STBTT_assert(z != NULL);
-   if (!z) return z;
-
-   // round dx down to avoid overshooting
-   if (dxdy < 0)
-      z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy);
-   else
-      z->dx = STBTT_ifloor(STBTT_FIX * dxdy);
-
-   z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount
-   z->x -= off_x * STBTT_FIX;
-
-   z->ey = e->y1;
-   z->next = 0;
-   z->direction = e->invert ? 1 : -1;
-   return z;
-}
-#elif STBTT_RASTERIZER_VERSION == 2
-static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata)
-{
-   stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata);
-   float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
-   STBTT_assert(z != NULL);
-   //STBTT_assert(e->y0 <= start_point);
-   if (!z) return z;
-   z->fdx = dxdy;
-   z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f;
-   z->fx = e->x0 + dxdy * (start_point - e->y0);
-   z->fx -= off_x;
-   z->direction = e->invert ? 1.0f : -1.0f;
-   z->sy = e->y0;
-   z->ey = e->y1;
-   z->next = 0;
-   return z;
-}
-#else
-#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-
-#if STBTT_RASTERIZER_VERSION == 1
-// note: this routine clips fills that extend off the edges... ideally this
-// wouldn't happen, but it could happen if the truetype glyph bounding boxes
-// are wrong, or if the user supplies a too-small bitmap
-static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight)
-{
-   // non-zero winding fill
-   int x0=0, w=0;
-
-   while (e) {
-      if (w == 0) {
-         // if we're currently at zero, we need to record the edge start point
-         x0 = e->x; w += e->direction;
-      } else {
-         int x1 = e->x; w += e->direction;
-         // if we went to zero, we need to draw
-         if (w == 0) {
-            int i = x0 >> STBTT_FIXSHIFT;
-            int j = x1 >> STBTT_FIXSHIFT;
-
-            if (i < len && j >= 0) {
-               if (i == j) {
-                  // x0,x1 are the same pixel, so compute combined coverage
-                  scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT);
-               } else {
-                  if (i >= 0) // add antialiasing for x0
-                     scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT);
-                  else
-                     i = -1; // clip
-
-                  if (j < len) // add antialiasing for x1
-                     scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT);
-                  else
-                     j = len; // clip
-
-                  for (++i; i < j; ++i) // fill pixels between x0 and x1
-                     scanline[i] = scanline[i] + (stbtt_uint8) max_weight;
-               }
-            }
-         }
-      }
-
-      e = e->next;
-   }
-}
-
-static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
-{
-   stbtt__hheap hh = { 0, 0, 0 };
-   stbtt__active_edge *active = NULL;
-   int y,j=0;
-   int max_weight = (255 / vsubsample);  // weight per vertical scanline
-   int s; // vertical subsample index
-   unsigned char scanline_data[512], *scanline;
-
-   if (result->w > 512)
-      scanline = (unsigned char *) STBTT_malloc(result->w, userdata);
-   else
-      scanline = scanline_data;
-
-   y = off_y * vsubsample;
-   e[n].y0 = (off_y + result->h) * (float) vsubsample + 1;
-
-   while (j < result->h) {
-      STBTT_memset(scanline, 0, result->w);
-      for (s=0; s < vsubsample; ++s) {
-         // find center of pixel for this scanline
-         float scan_y = y + 0.5f;
-         stbtt__active_edge **step = &active;
-
-         // update all active edges;
-         // remove all active edges that terminate before the center of this scanline
-         while (*step) {
-            stbtt__active_edge * z = *step;
-            if (z->ey <= scan_y) {
-               *step = z->next; // delete from list
-               STBTT_assert(z->direction);
-               z->direction = 0;
-               stbtt__hheap_free(&hh, z);
-            } else {
-               z->x += z->dx; // advance to position for current scanline
-               step = &((*step)->next); // advance through list
-            }
-         }
-
-         // resort the list if needed
-         for(;;) {
-            int changed=0;
-            step = &active;
-            while (*step && (*step)->next) {
-               if ((*step)->x > (*step)->next->x) {
-                  stbtt__active_edge *t = *step;
-                  stbtt__active_edge *q = t->next;
-
-                  t->next = q->next;
-                  q->next = t;
-                  *step = q;
-                  changed = 1;
-               }
-               step = &(*step)->next;
-            }
-            if (!changed) break;
-         }
-
-         // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
-         while (e->y0 <= scan_y) {
-            if (e->y1 > scan_y) {
-               stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata);
-               if (z != NULL) {
-                  // find insertion point
-                  if (active == NULL)
-                     active = z;
-                  else if (z->x < active->x) {
-                     // insert at front
-                     z->next = active;
-                     active = z;
-                  } else {
-                     // find thing to insert AFTER
-                     stbtt__active_edge *p = active;
-                     while (p->next && p->next->x < z->x)
-                        p = p->next;
-                     // at this point, p->next->x is NOT < z->x
-                     z->next = p->next;
-                     p->next = z;
-                  }
-               }
-            }
-            ++e;
-         }
-
-         // now process all active edges in XOR fashion
-         if (active)
-            stbtt__fill_active_edges(scanline, result->w, active, max_weight);
-
-         ++y;
-      }
-      STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w);
-      ++j;
-   }
-
-   stbtt__hheap_cleanup(&hh, userdata);
-
-   if (scanline != scanline_data)
-      STBTT_free(scanline, userdata);
-}
-
-#elif STBTT_RASTERIZER_VERSION == 2
-
-// the edge passed in here does not cross the vertical line at x or the vertical line at x+1
-// (i.e. it has already been clipped to those)
-static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1)
-{
-   if (y0 == y1) return;
-   STBTT_assert(y0 < y1);
-   STBTT_assert(e->sy <= e->ey);
-   if (y0 > e->ey) return;
-   if (y1 < e->sy) return;
-   if (y0 < e->sy) {
-      x0 += (x1-x0) * (e->sy - y0) / (y1-y0);
-      y0 = e->sy;
-   }
-   if (y1 > e->ey) {
-      x1 += (x1-x0) * (e->ey - y1) / (y1-y0);
-      y1 = e->ey;
-   }
-
-   if (x0 == x)
-      STBTT_assert(x1 <= x+1);
-   else if (x0 == x+1)
-      STBTT_assert(x1 >= x);
-   else if (x0 <= x)
-      STBTT_assert(x1 <= x);
-   else if (x0 >= x+1)
-      STBTT_assert(x1 >= x+1);
-   else
-      STBTT_assert(x1 >= x && x1 <= x+1);
-
-   if (x0 <= x && x1 <= x)
-      scanline[x] += e->direction * (y1-y0);
-   else if (x0 >= x+1 && x1 >= x+1)
-      ;
-   else {
-      STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1);
-      scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position
-   }
-}
-
-static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top)
-{
-   float y_bottom = y_top+1;
-
-   while (e) {
-      // brute force every pixel
-
-      // compute intersection points with top & bottom
-      STBTT_assert(e->ey >= y_top);
-
-      if (e->fdx == 0) {
-         float x0 = e->fx;
-         if (x0 < len) {
-            if (x0 >= 0) {
-               stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom);
-               stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom);
-            } else {
-               stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom);
-            }
-         }
-      } else {
-         float x0 = e->fx;
-         float dx = e->fdx;
-         float xb = x0 + dx;
-         float x_top, x_bottom;
-         float sy0,sy1;
-         float dy = e->fdy;
-         STBTT_assert(e->sy <= y_bottom && e->ey >= y_top);
-
-         // compute endpoints of line segment clipped to this scanline (if the
-         // line segment starts on this scanline. x0 is the intersection of the
-         // line with y_top, but that may be off the line segment.
-         if (e->sy > y_top) {
-            x_top = x0 + dx * (e->sy - y_top);
-            sy0 = e->sy;
-         } else {
-            x_top = x0;
-            sy0 = y_top;
-         }
-         if (e->ey < y_bottom) {
-            x_bottom = x0 + dx * (e->ey - y_top);
-            sy1 = e->ey;
-         } else {
-            x_bottom = xb;
-            sy1 = y_bottom;
-         }
-
-         if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) {
-            // from here on, we don't have to range check x values
-
-            if ((int) x_top == (int) x_bottom) {
-               float height;
-               // simple case, only spans one pixel
-               int x = (int) x_top;
-               height = sy1 - sy0;
-               STBTT_assert(x >= 0 && x < len);
-               scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2)  * height;
-               scanline_fill[x] += e->direction * height; // everything right of this pixel is filled
-            } else {
-               int x,x1,x2;
-               float y_crossing, step, sign, area;
-               // covers 2+ pixels
-               if (x_top > x_bottom) {
-                  // flip scanline vertically; signed area is the same
-                  float t;
-                  sy0 = y_bottom - (sy0 - y_top);
-                  sy1 = y_bottom - (sy1 - y_top);
-                  t = sy0, sy0 = sy1, sy1 = t;
-                  t = x_bottom, x_bottom = x_top, x_top = t;
-                  dx = -dx;
-                  dy = -dy;
-                  t = x0, x0 = xb, xb = t;
-               }
-
-               x1 = (int) x_top;
-               x2 = (int) x_bottom;
-               // compute intersection with y axis at x1+1
-               y_crossing = (x1+1 - x0) * dy + y_top;
-
-               sign = e->direction;
-               // area of the rectangle covered from y0..y_crossing
-               area = sign * (y_crossing-sy0);
-               // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing)
-               scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2);
-
-               step = sign * dy;
-               for (x = x1+1; x < x2; ++x) {
-                  scanline[x] += area + step/2;
-                  area += step;
-               }
-               y_crossing += dy * (x2 - (x1+1));
-
-               STBTT_assert(STBTT_fabs(area) <= 1.01f);
-
-               scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing);
-
-               scanline_fill[x2] += sign * (sy1-sy0);
-            }
-         } else {
-            // if edge goes outside of box we're drawing, we require
-            // clipping logic. since this does not match the intended use
-            // of this library, we use a different, very slow brute
-            // force implementation
-            int x;
-            for (x=0; x < len; ++x) {
-               // cases:
-               //
-               // there can be up to two intersections with the pixel. any intersection
-               // with left or right edges can be handled by splitting into two (or three)
-               // regions. intersections with top & bottom do not necessitate case-wise logic.
-               //
-               // the old way of doing this found the intersections with the left & right edges,
-               // then used some simple logic to produce up to three segments in sorted order
-               // from top-to-bottom. however, this had a problem: if an x edge was epsilon
-               // across the x border, then the corresponding y position might not be distinct
-               // from the other y segment, and it might ignored as an empty segment. to avoid
-               // that, we need to explicitly produce segments based on x positions.
-
-               // rename variables to clearly-defined pairs
-               float y0 = y_top;
-               float x1 = (float) (x);
-               float x2 = (float) (x+1);
-               float x3 = xb;
-               float y3 = y_bottom;
-
-               // x = e->x + e->dx * (y-y_top)
-               // (y-y_top) = (x - e->x) / e->dx
-               // y = (x - e->x) / e->dx + y_top
-               float y1 = (x - x0) / dx + y_top;
-               float y2 = (x+1 - x0) / dx + y_top;
-
-               if (x0 < x1 && x3 > x2) {         // three segments descending down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else if (x3 < x1 && x0 > x2) {  // three segments descending down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x0 < x1 && x3 > x1) {  // two segments across x, down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x3 < x1 && x0 > x1) {  // two segments across x, down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1);
-                  stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3);
-               } else if (x0 < x2 && x3 > x2) {  // two segments across x+1, down-right
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else if (x3 < x2 && x0 > x2) {  // two segments across x+1, down-left
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2);
-                  stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3);
-               } else {  // one segment
-                  stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3);
-               }
-            }
-         }
-      }
-      e = e->next;
-   }
-}
-
-// directly AA rasterize edges w/o supersampling
-static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata)
-{
-   stbtt__hheap hh = { 0, 0, 0 };
-   stbtt__active_edge *active = NULL;
-   int y,j=0, i;
-   float scanline_data[129], *scanline, *scanline2;
-
-   STBTT__NOTUSED(vsubsample);
-
-   if (result->w > 64)
-      scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata);
-   else
-      scanline = scanline_data;
-
-   scanline2 = scanline + result->w;
-
-   y = off_y;
-   e[n].y0 = (float) (off_y + result->h) + 1;
-
-   while (j < result->h) {
-      // find center of pixel for this scanline
-      float scan_y_top    = y + 0.0f;
-      float scan_y_bottom = y + 1.0f;
-      stbtt__active_edge **step = &active;
-
-      STBTT_memset(scanline , 0, result->w*sizeof(scanline[0]));
-      STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0]));
-
-      // update all active edges;
-      // remove all active edges that terminate before the top of this scanline
-      while (*step) {
-         stbtt__active_edge * z = *step;
-         if (z->ey <= scan_y_top) {
-            *step = z->next; // delete from list
-            STBTT_assert(z->direction);
-            z->direction = 0;
-            stbtt__hheap_free(&hh, z);
-         } else {
-            step = &((*step)->next); // advance through list
-         }
-      }
-
-      // insert all edges that start before the bottom of this scanline
-      while (e->y0 <= scan_y_bottom) {
-         if (e->y0 != e->y1) {
-            stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata);
-            if (z != NULL) {
-               if (j == 0 && off_y != 0) {
-                  if (z->ey < scan_y_top) {
-                     // this can happen due to subpixel positioning and some kind of fp rounding error i think
-                     z->ey = scan_y_top;
-                  }
-               }
-               STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds
-               // insert at front
-               z->next = active;
-               active = z;
-            }
-         }
-         ++e;
-      }
-
-      // now process all active edges
-      if (active)
-         stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top);
-
-      {
-         float sum = 0;
-         for (i=0; i < result->w; ++i) {
-            float k;
-            int m;
-            sum += scanline2[i];
-            k = scanline[i] + sum;
-            k = (float) STBTT_fabs(k)*255 + 0.5f;
-            m = (int) k;
-            if (m > 255) m = 255;
-            result->pixels[j*result->stride + i] = (unsigned char) m;
-         }
-      }
-      // advance all the edges
-      step = &active;
-      while (*step) {
-         stbtt__active_edge *z = *step;
-         z->fx += z->fdx; // advance to position for current scanline
-         step = &((*step)->next); // advance through list
-      }
-
-      ++y;
-      ++j;
-   }
-
-   stbtt__hheap_cleanup(&hh, userdata);
-
-   if (scanline != scanline_data)
-      STBTT_free(scanline, userdata);
-}
-#else
-#error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-
-#define STBTT__COMPARE(a,b)  ((a)->y0 < (b)->y0)
-
-static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n)
-{
-   int i,j;
-   for (i=1; i < n; ++i) {
-      stbtt__edge t = p[i], *a = &t;
-      j = i;
-      while (j > 0) {
-         stbtt__edge *b = &p[j-1];
-         int c = STBTT__COMPARE(a,b);
-         if (!c) break;
-         p[j] = p[j-1];
-         --j;
-      }
-      if (i != j)
-         p[j] = t;
-   }
-}
-
-static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n)
-{
-   /* threshold for transitioning to insertion sort */
-   while (n > 12) {
-      stbtt__edge t;
-      int c01,c12,c,m,i,j;
-
-      /* compute median of three */
-      m = n >> 1;
-      c01 = STBTT__COMPARE(&p[0],&p[m]);
-      c12 = STBTT__COMPARE(&p[m],&p[n-1]);
-      /* if 0 >= mid >= end, or 0 < mid < end, then use mid */
-      if (c01 != c12) {
-         /* otherwise, we'll need to swap something else to middle */
-         int z;
-         c = STBTT__COMPARE(&p[0],&p[n-1]);
-         /* 0>mid && mid<n:  0>n => n; 0<n => 0 */
-         /* 0<mid && mid>n:  0>n => 0; 0<n => n */
-         z = (c == c12) ? 0 : n-1;
-         t = p[z];
-         p[z] = p[m];
-         p[m] = t;
-      }
-      /* now p[m] is the median-of-three */
-      /* swap it to the beginning so it won't move around */
-      t = p[0];
-      p[0] = p[m];
-      p[m] = t;
-
-      /* partition loop */
-      i=1;
-      j=n-1;
-      for(;;) {
-         /* handling of equality is crucial here */
-         /* for sentinels & efficiency with duplicates */
-         for (;;++i) {
-            if (!STBTT__COMPARE(&p[i], &p[0])) break;
-         }
-         for (;;--j) {
-            if (!STBTT__COMPARE(&p[0], &p[j])) break;
-         }
-         /* make sure we haven't crossed */
-         if (i >= j) break;
-         t = p[i];
-         p[i] = p[j];
-         p[j] = t;
-
-         ++i;
-         --j;
-      }
-      /* recurse on smaller side, iterate on larger */
-      if (j < (n-i)) {
-         stbtt__sort_edges_quicksort(p,j);
-         p = p+i;
-         n = n-i;
-      } else {
-         stbtt__sort_edges_quicksort(p+i, n-i);
-         n = j;
-      }
-   }
-}
-
-static void stbtt__sort_edges(stbtt__edge *p, int n)
-{
-   stbtt__sort_edges_quicksort(p, n);
-   stbtt__sort_edges_ins_sort(p, n);
-}
-
-typedef struct
-{
-   float x,y;
-} stbtt__point;
-
-static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata)
-{
-   float y_scale_inv = invert ? -scale_y : scale_y;
-   stbtt__edge *e;
-   int n,i,j,k,m;
-#if STBTT_RASTERIZER_VERSION == 1
-   int vsubsample = result->h < 8 ? 15 : 5;
-#elif STBTT_RASTERIZER_VERSION == 2
-   int vsubsample = 1;
-#else
-   #error "Unrecognized value of STBTT_RASTERIZER_VERSION"
-#endif
-   // vsubsample should divide 255 evenly; otherwise we won't reach full opacity
-
-   // now we have to blow out the windings into explicit edge lists
-   n = 0;
-   for (i=0; i < windings; ++i)
-      n += wcount[i];
-
-   e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel
-   if (e == 0) return;
-   n = 0;
-
-   m=0;
-   for (i=0; i < windings; ++i) {
-      stbtt__point *p = pts + m;
-      m += wcount[i];
-      j = wcount[i]-1;
-      for (k=0; k < wcount[i]; j=k++) {
-         int a=k,b=j;
-         // skip the edge if horizontal
-         if (p[j].y == p[k].y)
-            continue;
-         // add edge from j to k to the list
-         e[n].invert = 0;
-         if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) {
-            e[n].invert = 1;
-            a=j,b=k;
-         }
-         e[n].x0 = p[a].x * scale_x + shift_x;
-         e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample;
-         e[n].x1 = p[b].x * scale_x + shift_x;
-         e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample;
-         ++n;
-      }
-   }
-
-   // now sort the edges by their highest point (should snap to integer, and then by x)
-   //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare);
-   stbtt__sort_edges(e, n);
-
-   // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule
-   stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata);
-
-   STBTT_free(e, userdata);
-}
-
-static void stbtt__add_point(stbtt__point *points, int n, float x, float y)
-{
-   if (!points) return; // during first pass, it's unallocated
-   points[n].x = x;
-   points[n].y = y;
-}
-
-// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching
-static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n)
-{
-   // midpoint
-   float mx = (x0 + 2*x1 + x2)/4;
-   float my = (y0 + 2*y1 + y2)/4;
-   // versus directly drawn line
-   float dx = (x0+x2)/2 - mx;
-   float dy = (y0+y2)/2 - my;
-   if (n > 16) // 65536 segments on one curve better be enough!
-      return 1;
-   if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA
-      stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1);
-      stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1);
-   } else {
-      stbtt__add_point(points, *num_points,x2,y2);
-      *num_points = *num_points+1;
-   }
-   return 1;
-}
-
-static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n)
-{
-   // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough
-   float dx0 = x1-x0;
-   float dy0 = y1-y0;
-   float dx1 = x2-x1;
-   float dy1 = y2-y1;
-   float dx2 = x3-x2;
-   float dy2 = y3-y2;
-   float dx = x3-x0;
-   float dy = y3-y0;
-   float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2));
-   float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy);
-   float flatness_squared = longlen*longlen-shortlen*shortlen;
-
-   if (n > 16) // 65536 segments on one curve better be enough!
-      return;
-
-   if (flatness_squared > objspace_flatness_squared) {
-      float x01 = (x0+x1)/2;
-      float y01 = (y0+y1)/2;
-      float x12 = (x1+x2)/2;
-      float y12 = (y1+y2)/2;
-      float x23 = (x2+x3)/2;
-      float y23 = (y2+y3)/2;
-
-      float xa = (x01+x12)/2;
-      float ya = (y01+y12)/2;
-      float xb = (x12+x23)/2;
-      float yb = (y12+y23)/2;
-
-      float mx = (xa+xb)/2;
-      float my = (ya+yb)/2;
-
-      stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1);
-      stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1);
-   } else {
-      stbtt__add_point(points, *num_points,x3,y3);
-      *num_points = *num_points+1;
-   }
-}
-
-// returns number of contours
-static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
-{
-   stbtt__point *points=0;
-   int num_points=0;
-
-   float objspace_flatness_squared = objspace_flatness * objspace_flatness;
-   int i,n=0,start=0, pass;
-
-   // count how many "moves" there are to get the contour count
-   for (i=0; i < num_verts; ++i)
-      if (vertices[i].type == STBTT_vmove)
-         ++n;
-
-   *num_contours = n;
-   if (n == 0) return 0;
-
-   *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata);
-
-   if (*contour_lengths == 0) {
-      *num_contours = 0;
-      return 0;
-   }
-
-   // make two passes through the points so we don't need to realloc
-   for (pass=0; pass < 2; ++pass) {
-      float x=0,y=0;
-      if (pass == 1) {
-         points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata);
-         if (points == NULL) goto error;
-      }
-      num_points = 0;
-      n= -1;
-      for (i=0; i < num_verts; ++i) {
-         switch (vertices[i].type) {
-            case STBTT_vmove:
-               // start the next contour
-               if (n >= 0)
-                  (*contour_lengths)[n] = num_points - start;
-               ++n;
-               start = num_points;
-
-               x = vertices[i].x, y = vertices[i].y;
-               stbtt__add_point(points, num_points++, x,y);
-               break;
-            case STBTT_vline:
-               x = vertices[i].x, y = vertices[i].y;
-               stbtt__add_point(points, num_points++, x, y);
-               break;
-            case STBTT_vcurve:
-               stbtt__tesselate_curve(points, &num_points, x,y,
-                                        vertices[i].cx, vertices[i].cy,
-                                        vertices[i].x,  vertices[i].y,
-                                        objspace_flatness_squared, 0);
-               x = vertices[i].x, y = vertices[i].y;
-               break;
-            case STBTT_vcubic:
-               stbtt__tesselate_cubic(points, &num_points, x,y,
-                                        vertices[i].cx, vertices[i].cy,
-                                        vertices[i].cx1, vertices[i].cy1,
-                                        vertices[i].x,  vertices[i].y,
-                                        objspace_flatness_squared, 0);
-               x = vertices[i].x, y = vertices[i].y;
-               break;
-         }
-      }
-      (*contour_lengths)[n] = num_points - start;
-   }
-
-   return points;
-error:
-   STBTT_free(points, userdata);
-   STBTT_free(*contour_lengths, userdata);
-   *contour_lengths = 0;
-   *num_contours = 0;
-   return NULL;
-}
-
-STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
-{
-   float scale            = scale_x > scale_y ? scale_y : scale_x;
-   int winding_count      = 0;
-   int *winding_lengths   = NULL;
-   stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata);
-   if (windings) {
-      stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata);
-      STBTT_free(winding_lengths, userdata);
-      STBTT_free(windings, userdata);
-   }
-}
-
-STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
-{
-   STBTT_free(bitmap, userdata);
-}
-
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
-{
-   int ix0,iy0,ix1,iy1;
-   stbtt__bitmap gbm;
-   stbtt_vertex *vertices;
-   int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
-
-   if (scale_x == 0) scale_x = scale_y;
-   if (scale_y == 0) {
-      if (scale_x == 0) {
-         STBTT_free(vertices, info->userdata);
-         return NULL;
-      }
-      scale_y = scale_x;
-   }
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1);
-
-   // now we get the size
-   gbm.w = (ix1 - ix0);
-   gbm.h = (iy1 - iy0);
-   gbm.pixels = NULL; // in case we error
-
-   if (width ) *width  = gbm.w;
-   if (height) *height = gbm.h;
-   if (xoff  ) *xoff   = ix0;
-   if (yoff  ) *yoff   = iy0;
-
-   if (gbm.w && gbm.h) {
-      gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata);
-      if (gbm.pixels) {
-         gbm.stride = gbm.w;
-
-         stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata);
-      }
-   }
-   STBTT_free(vertices, info->userdata);
-   return gbm.pixels;
-}
-
-STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
-{
-   int ix0,iy0;
-   stbtt_vertex *vertices;
-   int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices);
-   stbtt__bitmap gbm;
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0);
-   gbm.pixels = output;
-   gbm.w = out_w;
-   gbm.h = out_h;
-   gbm.stride = out_stride;
-
-   if (gbm.w && gbm.h)
-      stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata);
-
-   STBTT_free(vertices, info->userdata);
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
-}
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint)
-{
-   stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint));
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
-}
-
-STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
-}
-
-STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
-{
-   stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// bitmap baking
-//
-// This is SUPER-CRAPPY packing to keep source code small
-
-static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset,  // font location (use offset=0 for plain .ttf)
-                                float pixel_height,                     // height of font in pixels
-                                unsigned char *pixels, int pw, int ph,  // bitmap to be filled in
-                                int first_char, int num_chars,          // characters to bake
-                                stbtt_bakedchar *chardata)
-{
-   float scale;
-   int x,y,bottom_y, i;
-   stbtt_fontinfo f;
-   f.userdata = NULL;
-   if (!stbtt_InitFont(&f, data, offset))
-      return -1;
-   STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
-   x=y=1;
-   bottom_y = 1;
-
-   scale = stbtt_ScaleForPixelHeight(&f, pixel_height);
-
-   for (i=0; i < num_chars; ++i) {
-      int advance, lsb, x0,y0,x1,y1,gw,gh;
-      int g = stbtt_FindGlyphIndex(&f, first_char + i);
-      stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb);
-      stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1);
-      gw = x1-x0;
-      gh = y1-y0;
-      if (x + gw + 1 >= pw)
-         y = bottom_y, x = 1; // advance to next row
-      if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row
-         return -i;
-      STBTT_assert(x+gw < pw);
-      STBTT_assert(y+gh < ph);
-      stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g);
-      chardata[i].x0 = (stbtt_int16) x;
-      chardata[i].y0 = (stbtt_int16) y;
-      chardata[i].x1 = (stbtt_int16) (x + gw);
-      chardata[i].y1 = (stbtt_int16) (y + gh);
-      chardata[i].xadvance = scale * advance;
-      chardata[i].xoff     = (float) x0;
-      chardata[i].yoff     = (float) y0;
-      x = x + gw + 1;
-      if (y+gh+1 > bottom_y)
-         bottom_y = y+gh+1;
-   }
-   return bottom_y;
-}
-
-STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
-{
-   float d3d_bias = opengl_fillrule ? 0 : -0.5f;
-   float ipw = 1.0f / pw, iph = 1.0f / ph;
-   const stbtt_bakedchar *b = chardata + char_index;
-   int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f);
-   int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f);
-
-   q->x0 = round_x + d3d_bias;
-   q->y0 = round_y + d3d_bias;
-   q->x1 = round_x + b->x1 - b->x0 + d3d_bias;
-   q->y1 = round_y + b->y1 - b->y0 + d3d_bias;
-
-   q->s0 = b->x0 * ipw;
-   q->t0 = b->y0 * iph;
-   q->s1 = b->x1 * ipw;
-   q->t1 = b->y1 * iph;
-
-   *xpos += b->xadvance;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// rectangle packing replacement routines if you don't have stb_rect_pack.h
-//
-
-#ifndef STB_RECT_PACK_VERSION
-
-typedef int stbrp_coord;
-
-////////////////////////////////////////////////////////////////////////////////////
-//                                                                                //
-//                                                                                //
-// COMPILER WARNING ?!?!?                                                         //
-//                                                                                //
-//                                                                                //
-// if you get a compile warning due to these symbols being defined more than      //
-// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h"         //
-//                                                                                //
-////////////////////////////////////////////////////////////////////////////////////
-
-typedef struct
-{
-   int width,height;
-   int x,y,bottom_y;
-} stbrp_context;
-
-typedef struct
-{
-   unsigned char x;
-} stbrp_node;
-
-struct stbrp_rect
-{
-   stbrp_coord x,y;
-   int id,w,h,was_packed;
-};
-
-static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
-{
-   con->width  = pw;
-   con->height = ph;
-   con->x = 0;
-   con->y = 0;
-   con->bottom_y = 0;
-   STBTT__NOTUSED(nodes);
-   STBTT__NOTUSED(num_nodes);
-}
-
-static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects)
-{
-   int i;
-   for (i=0; i < num_rects; ++i) {
-      if (con->x + rects[i].w > con->width) {
-         con->x = 0;
-         con->y = con->bottom_y;
-      }
-      if (con->y + rects[i].h > con->height)
-         break;
-      rects[i].x = con->x;
-      rects[i].y = con->y;
-      rects[i].was_packed = 1;
-      con->x += rects[i].w;
-      if (con->y + rects[i].h > con->bottom_y)
-         con->bottom_y = con->y + rects[i].h;
-   }
-   for (   ; i < num_rects; ++i)
-      rects[i].was_packed = 0;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// bitmap baking
-//
-// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
-// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
-
-STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
-{
-   stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context)            ,alloc_context);
-   int            num_nodes = pw - padding;
-   stbrp_node    *nodes   = (stbrp_node    *) STBTT_malloc(sizeof(*nodes  ) * num_nodes,alloc_context);
-
-   if (context == NULL || nodes == NULL) {
-      if (context != NULL) STBTT_free(context, alloc_context);
-      if (nodes   != NULL) STBTT_free(nodes  , alloc_context);
-      return 0;
-   }
-
-   spc->user_allocator_context = alloc_context;
-   spc->width = pw;
-   spc->height = ph;
-   spc->pixels = pixels;
-   spc->pack_info = context;
-   spc->nodes = nodes;
-   spc->padding = padding;
-   spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw;
-   spc->h_oversample = 1;
-   spc->v_oversample = 1;
-   spc->skip_missing = 0;
-
-   stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
-
-   if (pixels)
-      STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels
-
-   return 1;
-}
-
-STBTT_DEF void stbtt_PackEnd  (stbtt_pack_context *spc)
-{
-   STBTT_free(spc->nodes    , spc->user_allocator_context);
-   STBTT_free(spc->pack_info, spc->user_allocator_context);
-}
-
-STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
-{
-   STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
-   STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
-   if (h_oversample <= STBTT_MAX_OVERSAMPLE)
-      spc->h_oversample = h_oversample;
-   if (v_oversample <= STBTT_MAX_OVERSAMPLE)
-      spc->v_oversample = v_oversample;
-}
-
-STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
-{
-   spc->skip_missing = skip;
-}
-
-#define STBTT__OVER_MASK  (STBTT_MAX_OVERSAMPLE-1)
-
-static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
-{
-   unsigned char buffer[STBTT_MAX_OVERSAMPLE];
-   int safe_w = w - kernel_width;
-   int j;
-   STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
-   for (j=0; j < h; ++j) {
-      int i;
-      unsigned int total;
-      STBTT_memset(buffer, 0, kernel_width);
-
-      total = 0;
-
-      // make kernel_width a constant in common cases so compiler can optimize out the divide
-      switch (kernel_width) {
-         case 2:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 2);
-            }
-            break;
-         case 3:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 3);
-            }
-            break;
-         case 4:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 4);
-            }
-            break;
-         case 5:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / 5);
-            }
-            break;
-         default:
-            for (i=0; i <= safe_w; ++i) {
-               total += pixels[i] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i];
-               pixels[i] = (unsigned char) (total / kernel_width);
-            }
-            break;
-      }
-
-      for (; i < w; ++i) {
-         STBTT_assert(pixels[i] == 0);
-         total -= buffer[i & STBTT__OVER_MASK];
-         pixels[i] = (unsigned char) (total / kernel_width);
-      }
-
-      pixels += stride_in_bytes;
-   }
-}
-
-static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width)
-{
-   unsigned char buffer[STBTT_MAX_OVERSAMPLE];
-   int safe_h = h - kernel_width;
-   int j;
-   STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze
-   for (j=0; j < w; ++j) {
-      int i;
-      unsigned int total;
-      STBTT_memset(buffer, 0, kernel_width);
-
-      total = 0;
-
-      // make kernel_width a constant in common cases so compiler can optimize out the divide
-      switch (kernel_width) {
-         case 2:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 2);
-            }
-            break;
-         case 3:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 3);
-            }
-            break;
-         case 4:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 4);
-            }
-            break;
-         case 5:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / 5);
-            }
-            break;
-         default:
-            for (i=0; i <= safe_h; ++i) {
-               total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK];
-               buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes];
-               pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
-            }
-            break;
-      }
-
-      for (; i < h; ++i) {
-         STBTT_assert(pixels[i*stride_in_bytes] == 0);
-         total -= buffer[i & STBTT__OVER_MASK];
-         pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width);
-      }
-
-      pixels += 1;
-   }
-}
-
-static float stbtt__oversample_shift(int oversample)
-{
-   if (!oversample)
-      return 0.0f;
-
-   // The prefilter is a box filter of width "oversample",
-   // which shifts phase by (oversample - 1)/2 pixels in
-   // oversampled space. We want to shift in the opposite
-   // direction to counter this.
-   return (float)-(oversample - 1) / (2.0f * (float)oversample);
-}
-
-// rects array must be big enough to accommodate all characters in the given ranges
-STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
-{
-   int i,j,k;
-   int missing_glyph_added = 0;
-
-   k=0;
-   for (i=0; i < num_ranges; ++i) {
-      float fh = ranges[i].font_size;
-      float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
-      ranges[i].h_oversample = (unsigned char) spc->h_oversample;
-      ranges[i].v_oversample = (unsigned char) spc->v_oversample;
-      for (j=0; j < ranges[i].num_chars; ++j) {
-         int x0,y0,x1,y1;
-         int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
-         int glyph = stbtt_FindGlyphIndex(info, codepoint);
-         if (glyph == 0 && (spc->skip_missing || missing_glyph_added)) {
-            rects[k].w = rects[k].h = 0;
-         } else {
-            stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
-                                            scale * spc->h_oversample,
-                                            scale * spc->v_oversample,
-                                            0,0,
-                                            &x0,&y0,&x1,&y1);
-            rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1);
-            rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1);
-            if (glyph == 0)
-               missing_glyph_added = 1;
-         }
-         ++k;
-      }
-   }
-
-   return k;
-}
-
-STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph)
-{
-   stbtt_MakeGlyphBitmapSubpixel(info,
-                                 output,
-                                 out_w - (prefilter_x - 1),
-                                 out_h - (prefilter_y - 1),
-                                 out_stride,
-                                 scale_x,
-                                 scale_y,
-                                 shift_x,
-                                 shift_y,
-                                 glyph);
-
-   if (prefilter_x > 1)
-      stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x);
-
-   if (prefilter_y > 1)
-      stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y);
-
-   *sub_x = stbtt__oversample_shift(prefilter_x);
-   *sub_y = stbtt__oversample_shift(prefilter_y);
-}
-
-// rects array must be big enough to accommodate all characters in the given ranges
-STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
-{
-   int i,j,k, missing_glyph = -1, return_value = 1;
-
-   // save current values
-   int old_h_over = spc->h_oversample;
-   int old_v_over = spc->v_oversample;
-
-   k = 0;
-   for (i=0; i < num_ranges; ++i) {
-      float fh = ranges[i].font_size;
-      float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh);
-      float recip_h,recip_v,sub_x,sub_y;
-      spc->h_oversample = ranges[i].h_oversample;
-      spc->v_oversample = ranges[i].v_oversample;
-      recip_h = 1.0f / spc->h_oversample;
-      recip_v = 1.0f / spc->v_oversample;
-      sub_x = stbtt__oversample_shift(spc->h_oversample);
-      sub_y = stbtt__oversample_shift(spc->v_oversample);
-      for (j=0; j < ranges[i].num_chars; ++j) {
-         stbrp_rect *r = &rects[k];
-         if (r->was_packed && r->w != 0 && r->h != 0) {
-            stbtt_packedchar *bc = &ranges[i].chardata_for_range[j];
-            int advance, lsb, x0,y0,x1,y1;
-            int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
-            int glyph = stbtt_FindGlyphIndex(info, codepoint);
-            stbrp_coord pad = (stbrp_coord) spc->padding;
-
-            // pad on left and top
-            r->x += pad;
-            r->y += pad;
-            r->w -= pad;
-            r->h -= pad;
-            stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb);
-            stbtt_GetGlyphBitmapBox(info, glyph,
-                                    scale * spc->h_oversample,
-                                    scale * spc->v_oversample,
-                                    &x0,&y0,&x1,&y1);
-            stbtt_MakeGlyphBitmapSubpixel(info,
-                                          spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                          r->w - spc->h_oversample+1,
-                                          r->h - spc->v_oversample+1,
-                                          spc->stride_in_bytes,
-                                          scale * spc->h_oversample,
-                                          scale * spc->v_oversample,
-                                          0,0,
-                                          glyph);
-
-            if (spc->h_oversample > 1)
-               stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                  r->w, r->h, spc->stride_in_bytes,
-                                  spc->h_oversample);
-
-            if (spc->v_oversample > 1)
-               stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes,
-                                  r->w, r->h, spc->stride_in_bytes,
-                                  spc->v_oversample);
-
-            bc->x0       = (stbtt_int16)  r->x;
-            bc->y0       = (stbtt_int16)  r->y;
-            bc->x1       = (stbtt_int16) (r->x + r->w);
-            bc->y1       = (stbtt_int16) (r->y + r->h);
-            bc->xadvance =                scale * advance;
-            bc->xoff     =       (float)  x0 * recip_h + sub_x;
-            bc->yoff     =       (float)  y0 * recip_v + sub_y;
-            bc->xoff2    =                (x0 + r->w) * recip_h + sub_x;
-            bc->yoff2    =                (y0 + r->h) * recip_v + sub_y;
-
-            if (glyph == 0)
-               missing_glyph = j;
-         } else if (spc->skip_missing) {
-            return_value = 0;
-         } else if (r->was_packed && r->w == 0 && r->h == 0 && missing_glyph >= 0) {
-            ranges[i].chardata_for_range[j] = ranges[i].chardata_for_range[missing_glyph];
-         } else {
-            return_value = 0; // if any fail, report failure
-         }
-
-         ++k;
-      }
-   }
-
-   // restore original values
-   spc->h_oversample = old_h_over;
-   spc->v_oversample = old_v_over;
-
-   return return_value;
-}
-
-STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects)
-{
-   stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects);
-}
-
-STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
-{
-   stbtt_fontinfo info;
-   int i,j,n, return_value = 1;
-   //stbrp_context *context = (stbrp_context *) spc->pack_info;
-   stbrp_rect    *rects;
-
-   // flag all characters as NOT packed
-   for (i=0; i < num_ranges; ++i)
-      for (j=0; j < ranges[i].num_chars; ++j)
-         ranges[i].chardata_for_range[j].x0 =
-         ranges[i].chardata_for_range[j].y0 =
-         ranges[i].chardata_for_range[j].x1 =
-         ranges[i].chardata_for_range[j].y1 = 0;
-
-   n = 0;
-   for (i=0; i < num_ranges; ++i)
-      n += ranges[i].num_chars;
-
-   rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context);
-   if (rects == NULL)
-      return 0;
-
-   info.userdata = spc->user_allocator_context;
-   stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index));
-
-   n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects);
-
-   stbtt_PackFontRangesPackRects(spc, rects, n);
-
-   return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects);
-
-   STBTT_free(rects, spc->user_allocator_context);
-   return return_value;
-}
-
-STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size,
-            int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
-{
-   stbtt_pack_range range;
-   range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range;
-   range.array_of_unicode_codepoints = NULL;
-   range.num_chars                   = num_chars_in_range;
-   range.chardata_for_range          = chardata_for_range;
-   range.font_size                   = font_size;
-   return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
-}
-
-STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap)
-{
-   int i_ascent, i_descent, i_lineGap;
-   float scale;
-   stbtt_fontinfo info;
-   stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index));
-   scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size);
-   stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap);
-   *ascent  = (float) i_ascent  * scale;
-   *descent = (float) i_descent * scale;
-   *lineGap = (float) i_lineGap * scale;
-}
-
-STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
-{
-   float ipw = 1.0f / pw, iph = 1.0f / ph;
-   const stbtt_packedchar *b = chardata + char_index;
-
-   if (align_to_integer) {
-      float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f);
-      float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f);
-      q->x0 = x;
-      q->y0 = y;
-      q->x1 = x + b->xoff2 - b->xoff;
-      q->y1 = y + b->yoff2 - b->yoff;
-   } else {
-      q->x0 = *xpos + b->xoff;
-      q->y0 = *ypos + b->yoff;
-      q->x1 = *xpos + b->xoff2;
-      q->y1 = *ypos + b->yoff2;
-   }
-
-   q->s0 = b->x0 * ipw;
-   q->t0 = b->y0 * iph;
-   q->s1 = b->x1 * ipw;
-   q->t1 = b->y1 * iph;
-
-   *xpos += b->xadvance;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// sdf computation
-//
-
-#define STBTT_min(a,b)  ((a) < (b) ? (a) : (b))
-#define STBTT_max(a,b)  ((a) < (b) ? (b) : (a))
-
-static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2])
-{
-   float q0perp = q0[1]*ray[0] - q0[0]*ray[1];
-   float q1perp = q1[1]*ray[0] - q1[0]*ray[1];
-   float q2perp = q2[1]*ray[0] - q2[0]*ray[1];
-   float roperp = orig[1]*ray[0] - orig[0]*ray[1];
-
-   float a = q0perp - 2*q1perp + q2perp;
-   float b = q1perp - q0perp;
-   float c = q0perp - roperp;
-
-   float s0 = 0., s1 = 0.;
-   int num_s = 0;
-
-   if (a != 0.0) {
-      float discr = b*b - a*c;
-      if (discr > 0.0) {
-         float rcpna = -1 / a;
-         float d = (float) STBTT_sqrt(discr);
-         s0 = (b+d) * rcpna;
-         s1 = (b-d) * rcpna;
-         if (s0 >= 0.0 && s0 <= 1.0)
-            num_s = 1;
-         if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) {
-            if (num_s == 0) s0 = s1;
-            ++num_s;
-         }
-      }
-   } else {
-      // 2*b*s + c = 0
-      // s = -c / (2*b)
-      s0 = c / (-2 * b);
-      if (s0 >= 0.0 && s0 <= 1.0)
-         num_s = 1;
-   }
-
-   if (num_s == 0)
-      return 0;
-   else {
-      float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]);
-      float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2;
-
-      float q0d =   q0[0]*rayn_x +   q0[1]*rayn_y;
-      float q1d =   q1[0]*rayn_x +   q1[1]*rayn_y;
-      float q2d =   q2[0]*rayn_x +   q2[1]*rayn_y;
-      float rod = orig[0]*rayn_x + orig[1]*rayn_y;
-
-      float q10d = q1d - q0d;
-      float q20d = q2d - q0d;
-      float q0rd = q0d - rod;
-
-      hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d;
-      hits[0][1] = a*s0+b;
-
-      if (num_s > 1) {
-         hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d;
-         hits[1][1] = a*s1+b;
-         return 2;
-      } else {
-         return 1;
-      }
-   }
-}
-
-static int equal(float *a, float *b)
-{
-   return (a[0] == b[0] && a[1] == b[1]);
-}
-
-static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts)
-{
-   int i;
-   float orig[2], ray[2] = { 1, 0 };
-   float y_frac;
-   int winding = 0;
-
-   orig[0] = x;
-   orig[1] = y;
-
-   // make sure y never passes through a vertex of the shape
-   y_frac = (float) STBTT_fmod(y, 1.0f);
-   if (y_frac < 0.01f)
-      y += 0.01f;
-   else if (y_frac > 0.99f)
-      y -= 0.01f;
-   orig[1] = y;
-
-   // test a ray from (-infinity,y) to (x,y)
-   for (i=0; i < nverts; ++i) {
-      if (verts[i].type == STBTT_vline) {
-         int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y;
-         int x1 = (int) verts[i  ].x, y1 = (int) verts[i  ].y;
-         if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
-            float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
-            if (x_inter < x)
-               winding += (y0 < y1) ? 1 : -1;
-         }
-      }
-      if (verts[i].type == STBTT_vcurve) {
-         int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ;
-         int x1 = (int) verts[i  ].cx, y1 = (int) verts[i  ].cy;
-         int x2 = (int) verts[i  ].x , y2 = (int) verts[i  ].y ;
-         int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2));
-         int by = STBTT_max(y0,STBTT_max(y1,y2));
-         if (y > ay && y < by && x > ax) {
-            float q0[2],q1[2],q2[2];
-            float hits[2][2];
-            q0[0] = (float)x0;
-            q0[1] = (float)y0;
-            q1[0] = (float)x1;
-            q1[1] = (float)y1;
-            q2[0] = (float)x2;
-            q2[1] = (float)y2;
-            if (equal(q0,q1) || equal(q1,q2)) {
-               x0 = (int)verts[i-1].x;
-               y0 = (int)verts[i-1].y;
-               x1 = (int)verts[i  ].x;
-               y1 = (int)verts[i  ].y;
-               if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) {
-                  float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0;
-                  if (x_inter < x)
-                     winding += (y0 < y1) ? 1 : -1;
-               }
-            } else {
-               int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits);
-               if (num_hits >= 1)
-                  if (hits[0][0] < 0)
-                     winding += (hits[0][1] < 0 ? -1 : 1);
-               if (num_hits >= 2)
-                  if (hits[1][0] < 0)
-                     winding += (hits[1][1] < 0 ? -1 : 1);
-            }
-         }
-      }
-   }
-   return winding;
-}
-
-static float stbtt__cuberoot( float x )
-{
-   if (x<0)
-      return -(float) STBTT_pow(-x,1.0f/3.0f);
-   else
-      return  (float) STBTT_pow( x,1.0f/3.0f);
-}
-
-// x^3 + c*x^2 + b*x + a = 0
-static int stbtt__solve_cubic(float a, float b, float c, float* r)
-{
-       float s = -a / 3;
-       float p = b - a*a / 3;
-       float q = a * (2*a*a - 9*b) / 27 + c;
-   float p3 = p*p*p;
-       float d = q*q + 4*p3 / 27;
-       if (d >= 0) {
-               float z = (float) STBTT_sqrt(d);
-               float u = (-q + z) / 2;
-               float v = (-q - z) / 2;
-               u = stbtt__cuberoot(u);
-               v = stbtt__cuberoot(v);
-               r[0] = s + u + v;
-               return 1;
-       } else {
-          float u = (float) STBTT_sqrt(-p/3);
-          float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative
-          float m = (float) STBTT_cos(v);
-      float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f;
-          r[0] = s + u * 2 * m;
-          r[1] = s - u * (m + n);
-          r[2] = s - u * (m - n);
-
-      //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f);  // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe?
-      //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f);
-      //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f);
-       return 3;
-   }
-}
-
-STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
-{
-   float scale_x = scale, scale_y = scale;
-   int ix0,iy0,ix1,iy1;
-   int w,h;
-   unsigned char *data;
-
-   if (scale == 0) return NULL;
-
-   stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1);
-
-   // if empty, return NULL
-   if (ix0 == ix1 || iy0 == iy1)
-      return NULL;
-
-   ix0 -= padding;
-   iy0 -= padding;
-   ix1 += padding;
-   iy1 += padding;
-
-   w = (ix1 - ix0);
-   h = (iy1 - iy0);
-
-   if (width ) *width  = w;
-   if (height) *height = h;
-   if (xoff  ) *xoff   = ix0;
-   if (yoff  ) *yoff   = iy0;
-
-   // invert for y-downwards bitmaps
-   scale_y = -scale_y;
-
-   {
-      int x,y,i,j;
-      float *precompute;
-      stbtt_vertex *verts;
-      int num_verts = stbtt_GetGlyphShape(info, glyph, &verts);
-      data = (unsigned char *) STBTT_malloc(w * h, info->userdata);
-      precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata);
-
-      for (i=0,j=num_verts-1; i < num_verts; j=i++) {
-         if (verts[i].type == STBTT_vline) {
-            float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
-            float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y;
-            float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0));
-            precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist;
-         } else if (verts[i].type == STBTT_vcurve) {
-            float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y;
-            float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y;
-            float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y;
-            float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
-            float len2 = bx*bx + by*by;
-            if (len2 != 0.0f)
-               precompute[i] = 1.0f / (bx*bx + by*by);
-            else
-               precompute[i] = 0.0f;
-         } else
-            precompute[i] = 0.0f;
-      }
-
-      for (y=iy0; y < iy1; ++y) {
-         for (x=ix0; x < ix1; ++x) {
-            float val;
-            float min_dist = 999999.0f;
-            float sx = (float) x + 0.5f;
-            float sy = (float) y + 0.5f;
-            float x_gspace = (sx / scale_x);
-            float y_gspace = (sy / scale_y);
-
-            int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path
-
-            for (i=0; i < num_verts; ++i) {
-               float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y;
-
-               // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve
-               float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy);
-               if (dist2 < min_dist*min_dist)
-                  min_dist = (float) STBTT_sqrt(dist2);
-
-               if (verts[i].type == STBTT_vline) {
-                  float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y;
-
-                  // coarse culling against bbox
-                  //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist &&
-                  //    sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist)
-                  float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i];
-                  STBTT_assert(i != 0);
-                  if (dist < min_dist) {
-                     // check position along line
-                     // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0)
-                     // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy)
-                     float dx = x1-x0, dy = y1-y0;
-                     float px = x0-sx, py = y0-sy;
-                     // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy
-                     // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve
-                     float t = -(px*dx + py*dy) / (dx*dx + dy*dy);
-                     if (t >= 0.0f && t <= 1.0f)
-                        min_dist = dist;
-                  }
-               } else if (verts[i].type == STBTT_vcurve) {
-                  float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y;
-                  float x1 = verts[i  ].cx*scale_x, y1 = verts[i  ].cy*scale_y;
-                  float box_x0 = STBTT_min(STBTT_min(x0,x1),x2);
-                  float box_y0 = STBTT_min(STBTT_min(y0,y1),y2);
-                  float box_x1 = STBTT_max(STBTT_max(x0,x1),x2);
-                  float box_y1 = STBTT_max(STBTT_max(y0,y1),y2);
-                  // coarse culling against bbox to avoid computing cubic unnecessarily
-                  if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) {
-                     int num=0;
-                     float ax = x1-x0, ay = y1-y0;
-                     float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2;
-                     float mx = x0 - sx, my = y0 - sy;
-                     float res[3],px,py,t,it;
-                     float a_inv = precompute[i];
-                     if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula
-                        float a = 3*(ax*bx + ay*by);
-                        float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by);
-                        float c = mx*ax+my*ay;
-                        if (a == 0.0) { // if a is 0, it's linear
-                           if (b != 0.0) {
-                              res[num++] = -c/b;
-                           }
-                        } else {
-                           float discriminant = b*b - 4*a*c;
-                           if (discriminant < 0)
-                              num = 0;
-                           else {
-                              float root = (float) STBTT_sqrt(discriminant);
-                              res[0] = (-b - root)/(2*a);
-                              res[1] = (-b + root)/(2*a);
-                              num = 2; // don't bother distinguishing 1-solution case, as code below will still work
-                           }
-                        }
-                     } else {
-                        float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point
-                        float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv;
-                        float d = (mx*ax+my*ay) * a_inv;
-                        num = stbtt__solve_cubic(b, c, d, res);
-                     }
-                     if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) {
-                        t = res[0], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                     if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) {
-                        t = res[1], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                     if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) {
-                        t = res[2], it = 1.0f - t;
-                        px = it*it*x0 + 2*t*it*x1 + t*t*x2;
-                        py = it*it*y0 + 2*t*it*y1 + t*t*y2;
-                        dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy);
-                        if (dist2 < min_dist * min_dist)
-                           min_dist = (float) STBTT_sqrt(dist2);
-                     }
-                  }
-               }
-            }
-            if (winding == 0)
-               min_dist = -min_dist;  // if outside the shape, value is negative
-            val = onedge_value + pixel_dist_scale * min_dist;
-            if (val < 0)
-               val = 0;
-            else if (val > 255)
-               val = 255;
-            data[(y-iy0)*w+(x-ix0)] = (unsigned char) val;
-         }
-      }
-      STBTT_free(precompute, info->userdata);
-      STBTT_free(verts, info->userdata);
-   }
-   return data;
-}
-
-STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff)
-{
-   return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff);
-}
-
-STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata)
-{
-   STBTT_free(bitmap, userdata);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// font name matching -- recommended not to use this
-//
-
-// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string
-static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2)
-{
-   stbtt_int32 i=0;
-
-   // convert utf16 to utf8 and compare the results while converting
-   while (len2) {
-      stbtt_uint16 ch = s2[0]*256 + s2[1];
-      if (ch < 0x80) {
-         if (i >= len1) return -1;
-         if (s1[i++] != ch) return -1;
-      } else if (ch < 0x800) {
-         if (i+1 >= len1) return -1;
-         if (s1[i++] != 0xc0 + (ch >> 6)) return -1;
-         if (s1[i++] != 0x80 + (ch & 0x3f)) return -1;
-      } else if (ch >= 0xd800 && ch < 0xdc00) {
-         stbtt_uint32 c;
-         stbtt_uint16 ch2 = s2[2]*256 + s2[3];
-         if (i+3 >= len1) return -1;
-         c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000;
-         if (s1[i++] != 0xf0 + (c >> 18)) return -1;
-         if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((c >>  6) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((c      ) & 0x3f)) return -1;
-         s2 += 2; // plus another 2 below
-         len2 -= 2;
-      } else if (ch >= 0xdc00 && ch < 0xe000) {
-         return -1;
-      } else {
-         if (i+2 >= len1) return -1;
-         if (s1[i++] != 0xe0 + (ch >> 12)) return -1;
-         if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1;
-         if (s1[i++] != 0x80 + ((ch     ) & 0x3f)) return -1;
-      }
-      s2 += 2;
-      len2 -= 2;
-   }
-   return i;
-}
-
-static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2)
-{
-   return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2);
-}
-
-// returns results in whatever encoding you request... but note that 2-byte encodings
-// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
-STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
-{
-   stbtt_int32 i,count,stringOffset;
-   stbtt_uint8 *fc = font->data;
-   stbtt_uint32 offset = font->fontstart;
-   stbtt_uint32 nm = stbtt__find_table(fc, offset, "name");
-   if (!nm) return NULL;
-
-   count = ttUSHORT(fc+nm+2);
-   stringOffset = nm + ttUSHORT(fc+nm+4);
-   for (i=0; i < count; ++i) {
-      stbtt_uint32 loc = nm + 6 + 12 * i;
-      if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2)
-          && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) {
-         *length = ttUSHORT(fc+loc+8);
-         return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10));
-      }
-   }
-   return NULL;
-}
-
-static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id)
-{
-   stbtt_int32 i;
-   stbtt_int32 count = ttUSHORT(fc+nm+2);
-   stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4);
-
-   for (i=0; i < count; ++i) {
-      stbtt_uint32 loc = nm + 6 + 12 * i;
-      stbtt_int32 id = ttUSHORT(fc+loc+6);
-      if (id == target_id) {
-         // find the encoding
-         stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4);
-
-         // is this a Unicode encoding?
-         if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) {
-            stbtt_int32 slen = ttUSHORT(fc+loc+8);
-            stbtt_int32 off = ttUSHORT(fc+loc+10);
-
-            // check if there's a prefix match
-            stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen);
-            if (matchlen >= 0) {
-               // check for target_id+1 immediately following, with same encoding & language
-               if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) {
-                  slen = ttUSHORT(fc+loc+12+8);
-                  off = ttUSHORT(fc+loc+12+10);
-                  if (slen == 0) {
-                     if (matchlen == nlen)
-                        return 1;
-                  } else if (matchlen < nlen && name[matchlen] == ' ') {
-                     ++matchlen;
-                     if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen))
-                        return 1;
-                  }
-               } else {
-                  // if nothing immediately following
-                  if (matchlen == nlen)
-                     return 1;
-               }
-            }
-         }
-
-         // @TODO handle other encodings
-      }
-   }
-   return 0;
-}
-
-static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags)
-{
-   stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name);
-   stbtt_uint32 nm,hd;
-   if (!stbtt__isfont(fc+offset)) return 0;
-
-   // check italics/bold/underline flags in macStyle...
-   if (flags) {
-      hd = stbtt__find_table(fc, offset, "head");
-      if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0;
-   }
-
-   nm = stbtt__find_table(fc, offset, "name");
-   if (!nm) return 0;
-
-   if (flags) {
-      // if we checked the macStyle flags, then just check the family and ignore the subfamily
-      if (stbtt__matchpair(fc, nm, name, nlen, 16, -1))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  1, -1))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  3, -1))  return 1;
-   } else {
-      if (stbtt__matchpair(fc, nm, name, nlen, 16, 17))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  1,  2))  return 1;
-      if (stbtt__matchpair(fc, nm, name, nlen,  3, -1))  return 1;
-   }
-
-   return 0;
-}
-
-static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags)
-{
-   stbtt_int32 i;
-   for (i=0;;++i) {
-      stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i);
-      if (off < 0) return off;
-      if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags))
-         return off;
-   }
-}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
-
-STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset,
-                                float pixel_height, unsigned char *pixels, int pw, int ph,
-                                int first_char, int num_chars, stbtt_bakedchar *chardata)
-{
-   return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata);
-}
-
-STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
-{
-   return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index);
-}
-
-STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data)
-{
-   return stbtt_GetNumberOfFonts_internal((unsigned char *) data);
-}
-
-STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
-{
-   return stbtt_InitFont_internal(info, (unsigned char *) data, offset);
-}
-
-STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags)
-{
-   return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags);
-}
-
-STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
-{
-   return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2);
-}
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
-#endif // STB_TRUETYPE_IMPLEMENTATION
-
-
-// FULL VERSION HISTORY
-//
-//   1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod
-//   1.18 (2018-01-29) add missing function
-//   1.17 (2017-07-23) make more arguments const; doc fix
-//   1.16 (2017-07-12) SDF support
-//   1.15 (2017-03-03) make more arguments const
-//   1.14 (2017-01-16) num-fonts-in-TTC function
-//   1.13 (2017-01-02) support OpenType fonts, certain Apple fonts
-//   1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual
-//   1.11 (2016-04-02) fix unused-variable warning
-//   1.10 (2016-04-02) allow user-defined fabs() replacement
-//                     fix memory leak if fontsize=0.0
-//                     fix warning from duplicate typedef
-//   1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges
-//   1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges
-//   1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints;
-//                     allow PackFontRanges to pack and render in separate phases;
-//                     fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?);
-//                     fixed an assert() bug in the new rasterizer
-//                     replace assert() with STBTT_assert() in new rasterizer
-//   1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine)
-//                     also more precise AA rasterizer, except if shapes overlap
-//                     remove need for STBTT_sort
-//   1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC
-//   1.04 (2015-04-15) typo in example
-//   1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes
-//   1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++
-//   1.01 (2014-12-08) fix subpixel position when oversampling to exactly match
-//                        non-oversampled; STBTT_POINT_SIZE for packed case only
-//   1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling
-//   0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg)
-//   0.9  (2014-08-07) support certain mac/iOS fonts without an MS platformID
-//   0.8b (2014-07-07) fix a warning
-//   0.8  (2014-05-25) fix a few more warnings
-//   0.7  (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back
-//   0.6c (2012-07-24) improve documentation
-//   0.6b (2012-07-20) fix a few more warnings
-//   0.6  (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels,
-//                        stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty
-//   0.5  (2011-12-09) bugfixes:
-//                        subpixel glyph renderer computed wrong bounding box
-//                        first vertex of shape can be off-curve (FreeSans)
-//   0.4b (2011-12-03) fixed an error in the font baking example
-//   0.4  (2011-12-01) kerning, subpixel rendering (tor)
-//                    bugfixes for:
-//                        codepoint-to-glyph conversion using table fmt=12
-//                        codepoint-to-glyph conversion using table fmt=4
-//                        stbtt_GetBakedQuad with non-square texture (Zer)
-//                    updated Hello World! sample to use kerning and subpixel
-//                    fixed some warnings
-//   0.3  (2009-06-24) cmap fmt=12, compound shapes (MM)
-//                    userdata, malloc-from-userdata, non-zero fill (stb)
-//   0.2  (2009-03-11) Fix unsigned/signed char warnings
-//   0.1  (2009-03-09) First public release
-//
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
-software, either in source code form or as a compiled binary, for any purpose,
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this
-software dedicate any and all copyright interest in the software to the public
-domain. We make this dedication for the benefit of the public at large and to
-the detriment of our heirs and successors. We intend this dedication to be an
-overt act of relinquishment in perpetuity of all present and future rights to
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/stb_vorbis.h b/raylib_pi4_test/external/stb_vorbis.h
deleted file mode 100644 (file)
index c9ee5cc..0000000
+++ /dev/null
@@ -1,5475 +0,0 @@
-// Ogg Vorbis audio decoder - v1.14 - public domain
-// http://nothings.org/stb_vorbis/
-//
-// Original version written by Sean Barrett in 2007.
-//
-// Originally sponsored by RAD Game Tools. Seeking implementation
-// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker,
-// Elias Software, Aras Pranckevicius, and Sean Barrett.
-//
-// LICENSE
-//
-//   See end of file for license information.
-//
-// Limitations:
-//
-//   - floor 0 not supported (used in old ogg vorbis files pre-2004)
-//   - lossless sample-truncation at beginning ignored
-//   - cannot concatenate multiple vorbis streams
-//   - sample positions are 32-bit, limiting seekable 192Khz
-//       files to around 6 hours (Ogg supports 64-bit)
-//
-// Feature contributors:
-//    Dougall Johnson (sample-exact seeking)
-//
-// Bugfix/warning contributors:
-//    Terje Mathisen     Niklas Frykholm     Andy Hill
-//    Casey Muratori     John Bolton         Gargaj
-//    Laurent Gomila     Marc LeBlanc        Ronny Chevalier
-//    Bernhard Wodo      Evan Balster        alxprd@github
-//    Tom Beaumont       Ingo Leitgeb        Nicolas Guillemot
-//    Phillip Bennefall  Rohit               Thiago Goulart
-//    manxorist@github   saga musix          github:infatum
-//    Timur Gagiev       BareRose
-//
-// Partial history:
-//    1.14    - 2018-02-11 - delete bogus dealloca usage
-//    1.13    - 2018-01-29 - fix truncation of last frame (hopefully)
-//    1.12    - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
-//    1.11    - 2017-07-23 - fix MinGW compilation 
-//    1.10    - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
-//    1.09    - 2016-04-04 - back out 'truncation of last frame' fix from previous version
-//    1.08    - 2016-04-02 - warnings; setup memory leaks; truncation of last frame
-//    1.07    - 2015-01-16 - fixes for crashes on invalid files; warning fixes; const
-//    1.06    - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
-//                           some crash fixes when out of memory or with corrupt files
-//                           fix some inappropriately signed shifts
-//    1.05    - 2015-04-19 - don't define __forceinline if it's redundant
-//    1.04    - 2014-08-27 - fix missing const-correct case in API
-//    1.03    - 2014-08-07 - warning fixes
-//    1.02    - 2014-07-09 - declare qsort comparison as explicitly _cdecl in Windows
-//    1.01    - 2014-06-18 - fix stb_vorbis_get_samples_float (interleaved was correct)
-//    1.0     - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in >2-channel;
-//                           (API change) report sample rate for decode-full-file funcs
-//
-// See end of file for full version history.
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-//  HEADER BEGINS HERE
-//
-
-#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H
-#define STB_VORBIS_INCLUDE_STB_VORBIS_H
-
-#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
-#define STB_VORBIS_NO_STDIO
-#endif
-
-#ifndef STB_VORBIS_NO_STDIO
-#include <stdio.h>
-#endif
-
-// NOTE: Added to work with raylib on Android
-#if defined(PLATFORM_ANDROID)
-    #include "utils.h"  // Android fopen function map
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef STB_VORBIS_STATIC
-#define STBVDEF static
-#else
-#define STBVDEF extern
-#endif
-
-///////////   THREAD SAFETY
-
-// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
-// them from multiple threads at the same time. However, you can have multiple
-// stb_vorbis* handles and decode from them independently in multiple thrads.
-
-
-///////////   MEMORY ALLOCATION
-
-// normally stb_vorbis uses malloc() to allocate memory at startup,
-// and alloca() to allocate temporary memory during a frame on the
-// stack. (Memory consumption will depend on the amount of setup
-// data in the file and how you set the compile flags for speed
-// vs. size. In my test files the maximal-size usage is ~150KB.)
-//
-// You can modify the wrapper functions in the source (stbv_setup_malloc,
-// stbv_setup_temp_malloc, temp_malloc) to change this behavior, or you
-// can use a simpler allocation model: you pass in a buffer from
-// which stb_vorbis will allocate _all_ its memory (including the
-// temp memory). "open" may fail with a VORBIS_outofmem if you
-// do not pass in enough data; there is no way to determine how
-// much you do need except to succeed (at which point you can
-// query get_info to find the exact amount required. yes I know
-// this is lame).
-//
-// If you pass in a non-NULL buffer of the type below, allocation
-// will occur from it as described above. Otherwise just pass NULL
-// to use malloc()/alloca()
-
-typedef struct
-{
-   char *alloc_buffer;
-   int   alloc_buffer_length_in_bytes;
-} stb_vorbis_alloc;
-
-
-///////////   FUNCTIONS USEABLE WITH ALL INPUT MODES
-
-typedef struct stb_vorbis stb_vorbis;
-
-typedef struct
-{
-   unsigned int sample_rate;
-   int channels;
-
-   unsigned int setup_memory_required;
-   unsigned int setup_temp_memory_required;
-   unsigned int temp_memory_required;
-
-   int max_frame_size;
-} stb_vorbis_info;
-
-// get general information about the file
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
-
-// get the last error detected (clears it, too)
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f);
-
-// close an ogg vorbis file and free all memory in use
-STBVDEF void stb_vorbis_close(stb_vorbis *f);
-
-// this function returns the offset (in samples) from the beginning of the
-// file that will be returned by the next decode, if it is known, or -1
-// otherwise. after a flush_pushdata() call, this may take a while before
-// it becomes valid again.
-// NOT WORKING YET after a seek with PULLDATA API
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f);
-
-// returns the current seek point within the file, or offset from the beginning
-// of the memory buffer. In pushdata mode it returns 0.
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
-
-///////////   PUSHDATA API
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-
-// this API allows you to get blocks of data from any source and hand
-// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
-// you how much it used, and you have to give it the rest next time;
-// and stb_vorbis may not have enough data to work with and you will
-// need to give it the same data again PLUS more. Note that the Vorbis
-// specification does not bound the size of an individual frame.
-
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
-         const unsigned char * datablock, int datablock_length_in_bytes,
-         int *datablock_memory_consumed_in_bytes,
-         int *error,
-         const stb_vorbis_alloc *alloc_buffer);
-// create a vorbis decoder by passing in the initial data block containing
-//    the ogg&vorbis headers (you don't need to do parse them, just provide
-//    the first N bytes of the file--you're told if it's not enough, see below)
-// on success, returns an stb_vorbis *, does not set error, returns the amount of
-//    data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
-// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
-// if returns NULL and *error is VORBIS_need_more_data, then the input block was
-//       incomplete and you need to pass in a larger block from the start of the file
-
-STBVDEF int stb_vorbis_decode_frame_pushdata(
-         stb_vorbis *f,
-         const unsigned char *datablock, int datablock_length_in_bytes,
-         int *channels,             // place to write number of float * buffers
-         float ***output,           // place to write float ** array of float * buffers
-         int *samples               // place to write number of output samples
-     );
-// decode a frame of audio sample data if possible from the passed-in data block
-//
-// return value: number of bytes we used from datablock
-//
-// possible cases:
-//     0 bytes used, 0 samples output (need more data)
-//     N bytes used, 0 samples output (resynching the stream, keep going)
-//     N bytes used, M samples output (one frame of data)
-// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
-// frame, because Vorbis always "discards" the first frame.
-//
-// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
-// instead only datablock_length_in_bytes-3 or less. This is because it wants
-// to avoid missing parts of a page header if they cross a datablock boundary,
-// without writing state-machiney code to record a partial detection.
-//
-// The number of channels returned are stored in *channels (which can be
-// NULL--it is always the same as the number of channels reported by
-// get_info). *output will contain an array of float* buffers, one per
-// channel. In other words, (*output)[0][0] contains the first sample from
-// the first channel, and (*output)[1][0] contains the first sample from
-// the second channel.
-
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f);
-// inform stb_vorbis that your next datablock will not be contiguous with
-// previous ones (e.g. you've seeked in the data); future attempts to decode
-// frames will cause stb_vorbis to resynchronize (as noted above), and
-// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it
-// will begin decoding the _next_ frame.
-//
-// if you want to seek using pushdata, you need to seek in your file, then
-// call stb_vorbis_flush_pushdata(), then start calling decoding, then once
-// decoding is returning you data, call stb_vorbis_get_sample_offset, and
-// if you don't like the result, seek your file again and repeat.
-#endif
-
-
-//////////   PULLING INPUT API
-
-#ifndef STB_VORBIS_NO_PULLDATA_API
-// This API assumes stb_vorbis is allowed to pull data from a source--
-// either a block of memory containing the _entire_ vorbis stream, or a
-// FILE * that you or it create, or possibly some other reading mechanism
-// if you go modify the source to replace the FILE * case with some kind
-// of callback to your code. (But if you don't support seeking, you may
-// just want to go ahead and use pushdata.)
-
-#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
-#endif
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
-#endif
-// decode an entire file and output the data interleaved into a malloc()ed
-// buffer stored in *output. The return value is the number of samples
-// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
-// When you're done with it, just free() the pointer returned in *output.
-
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from an ogg vorbis stream in memory (note
-// this must be the entire stream!). on failure, returns NULL and sets *error
-
-#ifndef STB_VORBIS_NO_STDIO
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from a filename via fopen(). on failure,
-// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
-
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
-                                  int *error, const stb_vorbis_alloc *alloc_buffer);
-// create an ogg vorbis decoder from an open FILE *, looking for a stream at
-// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
-// note that stb_vorbis must "own" this stream; if you seek it in between
-// calls to stb_vorbis, it will become confused. Morever, if you attempt to
-// perform stb_vorbis_seek_*() operations on this file, it will assume it
-// owns the _entire_ rest of the file after the start point. Use the next
-// function, stb_vorbis_open_file_section(), to limit it.
-
-STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
-                int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len);
-// create an ogg vorbis decoder from an open FILE *, looking for a stream at
-// the _current_ seek point (ftell); the stream will be of length 'len' bytes.
-// on failure, returns NULL and sets *error. note that stb_vorbis must "own"
-// this stream; if you seek it in between calls to stb_vorbis, it will become
-// confused.
-#endif
-
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
-// these functions seek in the Vorbis file to (approximately) 'sample_number'.
-// after calling seek_frame(), the next call to get_frame_*() will include
-// the specified sample. after calling stb_vorbis_seek(), the next call to
-// stb_vorbis_get_samples_* will start with the specified sample. If you
-// do not need to seek to EXACTLY the target sample when using get_samples_*,
-// you can also use seek_frame().
-
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f);
-// this function is equivalent to stb_vorbis_seek(f,0)
-
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
-STBVDEF float        stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
-// these functions return the total length of the vorbis stream
-
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
-// decode the next frame and return the number of samples. the number of
-// channels returned are stored in *channels (which can be NULL--it is always
-// the same as the number of channels reported by get_info). *output will
-// contain an array of float* buffers, one per channel. These outputs will
-// be overwritten on the next call to stb_vorbis_get_frame_*.
-//
-// You generally should not intermix calls to stb_vorbis_get_frame_*()
-// and stb_vorbis_get_samples_*(), since the latter calls the former.
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_frame_short            (stb_vorbis *f, int num_c, short **buffer, int num_samples);
-#endif
-// decode the next frame and return the number of *samples* per channel.
-// Note that for interleaved data, you pass in the number of shorts (the
-// size of your array), but the return value is the number of samples per
-// channel, not the total number of samples.
-//
-// The data is coerced to the number of channels you request according to the
-// channel coercion rules (see below). You must pass in the size of your
-// buffer(s) so that stb_vorbis will not overwrite the end of the buffer.
-// The maximum buffer size needed can be gotten from get_info(); however,
-// the Vorbis I specification implies an absolute maximum of 4096 samples
-// per channel.
-
-// Channel coercion rules:
-//    Let M be the number of channels requested, and N the number of channels present,
-//    and Cn be the nth channel; let stereo L be the sum of all L and center channels,
-//    and stereo R be the sum of all R and center channels (channel assignment from the
-//    vorbis spec).
-//        M    N       output
-//        1    k      sum(Ck) for all k
-//        2    *      stereo L, stereo R
-//        k    l      k > l, the first l channels, then 0s
-//        k    l      k <= l, the first k channels
-//    Note that this is not _good_ surround etc. mixing at all! It's just so
-//    you get something useful.
-
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
-// gets num_samples samples, not necessarily on a frame boundary--this requires
-// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES.
-// Returns the number of samples stored per channel; it may be less than requested
-// at the end of the file. If there are no more samples in the file, returns 0.
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
-#endif
-// gets num_samples samples, not necessarily on a frame boundary--this requires
-// buffering so you have to supply the buffers. Applies the coercion rules above
-// to produce 'channels' channels. Returns the number of samples stored per channel;
-// it may be less than requested at the end of the file. If there are no more
-// samples in the file, returns 0.
-
-#endif
-
-////////   ERROR CODES
-
-enum STBVorbisError
-{
-   VORBIS__no_error,
-
-   VORBIS_need_more_data=1,             // not a real error
-
-   VORBIS_invalid_api_mixing,           // can't mix API modes
-   VORBIS_outofmem,                     // not enough memory
-   VORBIS_feature_not_supported,        // uses floor 0
-   VORBIS_too_many_channels,            // STB_VORBIS_MAX_CHANNELS is too small
-   VORBIS_file_open_failure,            // fopen() failed
-   VORBIS_seek_without_length,          // can't seek in unknown-length file
-
-   VORBIS_unexpected_eof=10,            // file is truncated?
-   VORBIS_seek_invalid,                 // seek past EOF
-
-   // decoding errors (corrupt/invalid stream) -- you probably
-   // don't care about the exact details of these
-
-   // vorbis errors:
-   VORBIS_invalid_setup=20,
-   VORBIS_invalid_stream,
-
-   // ogg errors:
-   VORBIS_missing_capture_pattern=30,
-   VORBIS_invalid_stream_structure_version,
-   VORBIS_continued_packet_flag_invalid,
-   VORBIS_incorrect_stream_serial_number,
-   VORBIS_invalid_first_page,
-   VORBIS_bad_packet_type,
-   VORBIS_cant_find_last_page,
-   VORBIS_seek_failed
-};
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H
-//
-//  HEADER ENDS HERE
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#ifdef STB_VORBIS_IMPLEMENTATION
-
-// global configuration settings (e.g. set these in the project/makefile),
-// or just set them in this file at the top (although ideally the first few
-// should be visible when the header file is compiled too, although it's not
-// crucial)
-
-// STB_VORBIS_NO_PUSHDATA_API
-//     does not compile the code for the various stb_vorbis_*_pushdata()
-//     functions
-// #define STB_VORBIS_NO_PUSHDATA_API
-
-// STB_VORBIS_NO_PULLDATA_API
-//     does not compile the code for the non-pushdata APIs
-// #define STB_VORBIS_NO_PULLDATA_API
-
-// STB_VORBIS_NO_STDIO
-//     does not compile the code for the APIs that use FILE *s internally
-//     or externally (implied by STB_VORBIS_NO_PULLDATA_API)
-// #define STB_VORBIS_NO_STDIO
-
-// STB_VORBIS_NO_INTEGER_CONVERSION
-//     does not compile the code for converting audio sample data from
-//     float to integer (implied by STB_VORBIS_NO_PULLDATA_API)
-// #define STB_VORBIS_NO_INTEGER_CONVERSION
-
-// STB_VORBIS_NO_FAST_SCALED_FLOAT
-//      does not use a fast float-to-int trick to accelerate float-to-int on
-//      most platforms which requires endianness be defined correctly.
-// #define STB_VORBIS_NO_FAST_SCALED_FLOAT
-
-
-// STB_VORBIS_MAX_CHANNELS [number]
-//     globally define this to the maximum number of channels you need.
-//     The spec does not put a restriction on channels except that
-//     the count is stored in a byte, so 255 is the hard limit.
-//     Reducing this saves about 16 bytes per value, so using 16 saves
-//     (255-16)*16 or around 4KB. Plus anything other memory usage
-//     I forgot to account for. Can probably go as low as 8 (7.1 audio),
-//     6 (5.1 audio), or 2 (stereo only).
-#ifndef STB_VORBIS_MAX_CHANNELS
-#define STB_VORBIS_MAX_CHANNELS    16  // enough for anyone?
-#endif
-
-// STB_VORBIS_PUSHDATA_CRC_COUNT [number]
-//     after a flush_pushdata(), stb_vorbis begins scanning for the
-//     next valid page, without backtracking. when it finds something
-//     that looks like a page, it streams through it and verifies its
-//     CRC32. Should that validation fail, it keeps scanning. But it's
-//     possible that _while_ streaming through to check the CRC32 of
-//     one candidate page, it sees another candidate page. This #define
-//     determines how many "overlapping" candidate pages it can search
-//     at once. Note that "real" pages are typically ~4KB to ~8KB, whereas
-//     garbage pages could be as big as 64KB, but probably average ~16KB.
-//     So don't hose ourselves by scanning an apparent 64KB page and
-//     missing a ton of real ones in the interim; so minimum of 2
-#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT
-#define STB_VORBIS_PUSHDATA_CRC_COUNT  4
-#endif
-
-// STB_VORBIS_FAST_HUFFMAN_LENGTH [number]
-//     sets the log size of the huffman-acceleration table.  Maximum
-//     supported value is 24. with larger numbers, more decodings are O(1),
-//     but the table size is larger so worse cache missing, so you'll have
-//     to probe (and try multiple ogg vorbis files) to find the sweet spot.
-#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH
-#define STB_VORBIS_FAST_HUFFMAN_LENGTH   10
-#endif
-
-// STB_VORBIS_FAST_BINARY_LENGTH [number]
-//     sets the log size of the binary-search acceleration table. this
-//     is used in similar fashion to the fast-huffman size to set initial
-//     parameters for the binary search
-
-// STB_VORBIS_FAST_HUFFMAN_INT
-//     The fast huffman tables are much more efficient if they can be
-//     stored as 16-bit results instead of 32-bit results. This restricts
-//     the codebooks to having only 65535 possible outcomes, though.
-//     (At least, accelerated by the huffman table.)
-#ifndef STB_VORBIS_FAST_HUFFMAN_INT
-#define STB_VORBIS_FAST_HUFFMAN_SHORT
-#endif
-
-// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-//     If the 'fast huffman' search doesn't succeed, then stb_vorbis falls
-//     back on binary searching for the correct one. This requires storing
-//     extra tables with the huffman codes in sorted order. Defining this
-//     symbol trades off space for speed by forcing a linear search in the
-//     non-fast case, except for "sparse" codebooks.
-// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-
-// STB_VORBIS_DIVIDES_IN_RESIDUE
-//     stb_vorbis precomputes the result of the scalar residue decoding
-//     that would otherwise require a divide per chunk. you can trade off
-//     space for time by defining this symbol.
-// #define STB_VORBIS_DIVIDES_IN_RESIDUE
-
-// STB_VORBIS_DIVIDES_IN_CODEBOOK
-//     vorbis VQ codebooks can be encoded two ways: with every case explicitly
-//     stored, or with all elements being chosen from a small range of values,
-//     and all values possible in all elements. By default, stb_vorbis expands
-//     this latter kind out to look like the former kind for ease of decoding,
-//     because otherwise an integer divide-per-vector-element is required to
-//     unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can
-//     trade off storage for speed.
-//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
-
-#ifdef STB_VORBIS_CODEBOOK_SHORTS
-#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
-#endif
-
-// STB_VORBIS_DIVIDE_TABLE
-//     this replaces small integer divides in the floor decode loop with
-//     table lookups. made less than 1% difference, so disabled by default.
-
-// STB_VORBIS_NO_INLINE_DECODE
-//     disables the inlining of the scalar codebook fast-huffman decode.
-//     might save a little codespace; useful for debugging
-// #define STB_VORBIS_NO_INLINE_DECODE
-
-// STB_VORBIS_NO_DEFER_FLOOR
-//     Normally we only decode the floor without synthesizing the actual
-//     full curve. We can instead synthesize the curve immediately. This
-//     requires more memory and is very likely slower, so I don't think
-//     you'd ever want to do it except for debugging.
-// #define STB_VORBIS_NO_DEFER_FLOOR
-
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-#ifdef STB_VORBIS_NO_PULLDATA_API
-   #define STB_VORBIS_NO_INTEGER_CONVERSION
-   #define STB_VORBIS_NO_STDIO
-#endif
-
-#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
-   #define STB_VORBIS_NO_STDIO 1
-#endif
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
-
-   // only need endianness for fast-float-to-int, which we don't
-   // use for pushdata
-
-   #ifndef STB_VORBIS_BIG_ENDIAN
-     #define STB_VORBIS_ENDIAN  0
-   #else
-     #define STB_VORBIS_ENDIAN  1
-   #endif
-
-#endif
-#endif
-
-
-#ifndef STB_VORBIS_NO_STDIO
-#include <stdio.h>
-#endif
-
-#ifndef STB_VORBIS_NO_CRT
-   #include <stdlib.h>
-   #include <string.h>
-   #include <assert.h>
-   #include <math.h>
-
-   // find definition of alloca if it's not in stdlib.h:
-   #if defined(_MSC_VER) || defined(__MINGW32__)
-      #include <malloc.h>
-   #endif
-   #if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__) || defined(__APPLE__)
-      #include <alloca.h>
-   #endif
-#else // STB_VORBIS_NO_CRT
-   #define NULL 0
-   #define malloc(s)   0
-   #define free(s)     ((void) 0)
-   #define realloc(s)  0
-#endif // STB_VORBIS_NO_CRT
-
-#include <limits.h>
-
-#ifdef __MINGW32__
-   // eff you mingw:
-   //     "fixed":
-   //         http://sourceforge.net/p/mingw-w64/mailman/message/32882927/
-   //     "no that broke the build, reverted, who cares about C":
-   //         http://sourceforge.net/p/mingw-w64/mailman/message/32890381/
-   #ifdef __forceinline
-   #undef __forceinline
-   #endif
-   #define __forceinline
-   #ifndef alloca
-   #define alloca(s) __builtin_alloca(s)
-   #endif
-#elif !defined(_MSC_VER)
-   #if __GNUC__
-      #define __forceinline inline
-   #else
-      #define __forceinline
-   #endif
-#endif
-
-#if STB_VORBIS_MAX_CHANNELS > 256
-#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range"
-#endif
-
-#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24
-#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range"
-#endif
-
-
-#if 0
-#include <crtdbg.h>
-#define STBV_CHECK(f)   _CrtIsValidHeapPointer(f->channel_buffers[1])
-#else
-#define STBV_CHECK(f)   ((void) 0)
-#endif
-
-#define STBV_MAX_BLOCKSIZE_LOG  13   // from specification
-#define STBV_MAX_BLOCKSIZE      (1 << STBV_MAX_BLOCKSIZE_LOG)
-
-
-typedef unsigned char  stbv_uint8;
-typedef   signed char  stbv_int8;
-typedef unsigned short stbv_uint16;
-typedef   signed short stbv_int16;
-typedef unsigned int   stbv_uint32;
-typedef   signed int   stbv_int32;
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif
-
-typedef float stbv_codetype;
-
-// @NOTE
-//
-// Some arrays below are tagged "//varies", which means it's actually
-// a variable-sized piece of data, but rather than malloc I assume it's
-// small enough it's better to just allocate it all together with the
-// main thing
-//
-// Most of the variables are specified with the smallest size I could pack
-// them into. It might give better performance to make them all full-sized
-// integers. It should be safe to freely rearrange the structures or change
-// the sizes larger--nothing relies on silently truncating etc., nor the
-// order of variables.
-
-#define STBV_FAST_HUFFMAN_TABLE_SIZE   (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
-#define STBV_FAST_HUFFMAN_TABLE_MASK   (STBV_FAST_HUFFMAN_TABLE_SIZE - 1)
-
-typedef struct
-{
-   int dimensions, entries;
-   stbv_uint8 *codeword_lengths;
-   float  minimum_value;
-   float  delta_value;
-   stbv_uint8  value_bits;
-   stbv_uint8  lookup_type;
-   stbv_uint8  sequence_p;
-   stbv_uint8  sparse;
-   stbv_uint32 lookup_values;
-   stbv_codetype *multiplicands;
-   stbv_uint32 *codewords;
-   #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
-    stbv_int16  fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
-   #else
-    stbv_int32  fast_huffman[STBV_FAST_HUFFMAN_TABLE_SIZE];
-   #endif
-   stbv_uint32 *sorted_codewords;
-   int    *sorted_values;
-   int     sorted_entries;
-} StbvCodebook;
-
-typedef struct
-{
-   stbv_uint8 order;
-   stbv_uint16 rate;
-   stbv_uint16 bark_map_size;
-   stbv_uint8 amplitude_bits;
-   stbv_uint8 amplitude_offset;
-   stbv_uint8 number_of_books;
-   stbv_uint8 book_list[16]; // varies
-} StbvFloor0;
-
-typedef struct
-{
-   stbv_uint8 partitions;
-   stbv_uint8 partition_class_list[32]; // varies
-   stbv_uint8 class_dimensions[16]; // varies
-   stbv_uint8 class_subclasses[16]; // varies
-   stbv_uint8 class_masterbooks[16]; // varies
-   stbv_int16 subclass_books[16][8]; // varies
-   stbv_uint16 Xlist[31*8+2]; // varies
-   stbv_uint8 sorted_order[31*8+2];
-   stbv_uint8 stbv_neighbors[31*8+2][2];
-   stbv_uint8 floor1_multiplier;
-   stbv_uint8 rangebits;
-   int values;
-} StbvFloor1;
-
-typedef union
-{
-   StbvFloor0 floor0;
-   StbvFloor1 floor1;
-} StbvFloor;
-
-typedef struct
-{
-   stbv_uint32 begin, end;
-   stbv_uint32 part_size;
-   stbv_uint8 classifications;
-   stbv_uint8 classbook;
-   stbv_uint8 **classdata;
-   stbv_int16 (*residue_books)[8];
-} StbvResidue;
-
-typedef struct
-{
-   stbv_uint8 magnitude;
-   stbv_uint8 angle;
-   stbv_uint8 mux;
-} StbvMappingChannel;
-
-typedef struct
-{
-   stbv_uint16 coupling_steps;
-   StbvMappingChannel *chan;
-   stbv_uint8  submaps;
-   stbv_uint8  submap_floor[15]; // varies
-   stbv_uint8  submap_residue[15]; // varies
-} StbvMapping;
-
-typedef struct
-{
-   stbv_uint8 blockflag;
-   stbv_uint8 mapping;
-   stbv_uint16 windowtype;
-   stbv_uint16 transformtype;
-} StbvMode;
-
-typedef struct
-{
-   stbv_uint32  goal_crc;    // expected crc if match
-   int     bytes_left;  // bytes left in packet
-   stbv_uint32  crc_so_far;  // running crc
-   int     bytes_done;  // bytes processed in _current_ chunk
-   stbv_uint32  sample_loc;  // granule pos encoded in page
-} StbvCRCscan;
-
-typedef struct
-{
-   stbv_uint32 page_start, page_end;
-   stbv_uint32 last_decoded_sample;
-} StbvProbedPage;
-
-struct stb_vorbis
-{
-  // user-accessible info
-   unsigned int sample_rate;
-   int channels;
-
-   unsigned int setup_memory_required;
-   unsigned int temp_memory_required;
-   unsigned int setup_temp_memory_required;
-
-  // input config
-#ifndef STB_VORBIS_NO_STDIO
-   FILE *f;
-   stbv_uint32 f_start;
-   int close_on_free;
-#endif
-
-   stbv_uint8 *stream;
-   stbv_uint8 *stream_start;
-   stbv_uint8 *stream_end;
-
-   stbv_uint32 stream_len;
-
-   stbv_uint8  push_mode;
-
-   stbv_uint32 first_audio_page_offset;
-
-   StbvProbedPage p_first, p_last;
-
-  // memory management
-   stb_vorbis_alloc alloc;
-   int setup_offset;
-   int temp_offset;
-
-  // run-time results
-   int eof;
-   enum STBVorbisError error;
-
-  // user-useful data
-
-  // header info
-   int blocksize[2];
-   int blocksize_0, blocksize_1;
-   int codebook_count;
-   StbvCodebook *codebooks;
-   int floor_count;
-   stbv_uint16 floor_types[64]; // varies
-   StbvFloor *floor_config;
-   int residue_count;
-   stbv_uint16 residue_types[64]; // varies
-   StbvResidue *residue_config;
-   int mapping_count;
-   StbvMapping *mapping;
-   int mode_count;
-   StbvMode mode_config[64];  // varies
-
-   stbv_uint32 total_samples;
-
-  // decode buffer
-   float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
-   float *outputs        [STB_VORBIS_MAX_CHANNELS];
-
-   float *previous_window[STB_VORBIS_MAX_CHANNELS];
-   int previous_length;
-
-   #ifndef STB_VORBIS_NO_DEFER_FLOOR
-   stbv_int16 *finalY[STB_VORBIS_MAX_CHANNELS];
-   #else
-   float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
-   #endif
-
-   stbv_uint32 current_loc; // sample location of next frame to decode
-   int    current_loc_valid;
-
-  // per-blocksize precomputed data
-   
-   // twiddle factors
-   float *A[2],*B[2],*C[2];
-   float *window[2];
-   stbv_uint16 *stbv_bit_reverse[2];
-
-  // current page/packet/segment streaming info
-   stbv_uint32 serial; // stream serial number for verification
-   int last_page;
-   int segment_count;
-   stbv_uint8 segments[255];
-   stbv_uint8 page_flag;
-   stbv_uint8 bytes_in_seg;
-   stbv_uint8 first_decode;
-   int next_seg;
-   int last_seg;  // flag that we're on the last segment
-   int last_seg_which; // what was the segment number of the last seg?
-   stbv_uint32 acc;
-   int valid_bits;
-   int packet_bytes;
-   int end_seg_with_known_loc;
-   stbv_uint32 known_loc_for_packet;
-   int discard_samples_deferred;
-   stbv_uint32 samples_output;
-
-  // push mode scanning
-   int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-   StbvCRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
-#endif
-
-  // sample-access
-   int channel_buffer_start;
-   int channel_buffer_end;
-};
-
-#if defined(STB_VORBIS_NO_PUSHDATA_API)
-   #define STBV_IS_PUSH_MODE(f)   FALSE
-#elif defined(STB_VORBIS_NO_PULLDATA_API)
-   #define STBV_IS_PUSH_MODE(f)   TRUE
-#else
-   #define STBV_IS_PUSH_MODE(f)   ((f)->push_mode)
-#endif
-
-typedef struct stb_vorbis stbv_vorb;
-
-static int stbv_error(stbv_vorb *f, enum STBVorbisError e)
-{
-   f->error = e;
-   if (!f->eof && e != VORBIS_need_more_data) {
-      f->error=e; // breakpoint for debugging
-   }
-   return 0;
-}
-
-
-// these functions are used for allocating temporary memory
-// while decoding. if you can afford the stack space, use
-// alloca(); otherwise, provide a temp buffer and it will
-// allocate out of those.
-
-#define stbv_array_size_required(count,size)  (count*(sizeof(void *)+(size)))
-
-#define stbv_temp_alloc(f,size)              (f->alloc.alloc_buffer ? stbv_setup_temp_malloc(f,size) : alloca(size))
-#define stbv_temp_free(f,p)                  0
-#define stbv_temp_alloc_save(f)              ((f)->temp_offset)
-#define stbv_temp_alloc_restore(f,p)         ((f)->temp_offset = (p))
-
-#define stbv_temp_block_array(f,count,size)  stbv_make_block_array(stbv_temp_alloc(f,stbv_array_size_required(count,size)), count, size)
-
-// given a sufficiently large block of memory, make an array of pointers to subblocks of it
-static void *stbv_make_block_array(void *mem, int count, int size)
-{
-   int i;
-   void ** p = (void **) mem;
-   char *q = (char *) (p + count);
-   for (i=0; i < count; ++i) {
-      p[i] = q;
-      q += size;
-   }
-   return p;
-}
-
-static void *stbv_setup_malloc(stbv_vorb *f, int sz)
-{
-   sz = (sz+3) & ~3;
-   f->setup_memory_required += sz;
-   if (f->alloc.alloc_buffer) {
-      void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
-      if (f->setup_offset + sz > f->temp_offset) return NULL;
-      f->setup_offset += sz;
-      return p;
-   }
-   return sz ? malloc(sz) : NULL;
-}
-
-static void stbv_setup_free(stbv_vorb *f, void *p)
-{
-   if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
-   free(p);
-}
-
-static void *stbv_setup_temp_malloc(stbv_vorb *f, int sz)
-{
-   sz = (sz+3) & ~3;
-   if (f->alloc.alloc_buffer) {
-      if (f->temp_offset - sz < f->setup_offset) return NULL;
-      f->temp_offset -= sz;
-      return (char *) f->alloc.alloc_buffer + f->temp_offset;
-   }
-   return malloc(sz);
-}
-
-static void stbv_setup_temp_free(stbv_vorb *f, void *p, int sz)
-{
-   if (f->alloc.alloc_buffer) {
-      f->temp_offset += (sz+3)&~3;
-      return;
-   }
-   free(p);
-}
-
-#define STBV_CRC32_POLY    0x04c11db7   // from spec
-
-static stbv_uint32 stbv_crc_table[256];
-static void stbv_crc32_init(void)
-{
-   int i,j;
-   stbv_uint32 s;
-   for(i=0; i < 256; i++) {
-      for (s=(stbv_uint32) i << 24, j=0; j < 8; ++j)
-         s = (s << 1) ^ (s >= (1U<<31) ? STBV_CRC32_POLY : 0);
-      stbv_crc_table[i] = s;
-   }
-}
-
-static __forceinline stbv_uint32 stbv_crc32_update(stbv_uint32 crc, stbv_uint8 byte)
-{
-   return (crc << 8) ^ stbv_crc_table[byte ^ (crc >> 24)];
-}
-
-
-// used in setup, and for huffman that doesn't go fast path
-static unsigned int stbv_bit_reverse(unsigned int n)
-{
-  n = ((n & 0xAAAAAAAA) >>  1) | ((n & 0x55555555) << 1);
-  n = ((n & 0xCCCCCCCC) >>  2) | ((n & 0x33333333) << 2);
-  n = ((n & 0xF0F0F0F0) >>  4) | ((n & 0x0F0F0F0F) << 4);
-  n = ((n & 0xFF00FF00) >>  8) | ((n & 0x00FF00FF) << 8);
-  return (n >> 16) | (n << 16);
-}
-
-static float stbv_square(float x)
-{
-   return x*x;
-}
-
-// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3
-// as required by the specification. fast(?) implementation from stb.h
-// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup
-static int stbv_ilog(stbv_int32 n)
-{
-   static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
-
-   if (n < 0) return 0; // signed n returns 0
-
-   // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
-   if (n < (1 << 14))
-        if (n < (1 <<  4))            return  0 + log2_4[n      ];
-        else if (n < (1 <<  9))       return  5 + log2_4[n >>  5];
-             else                     return 10 + log2_4[n >> 10];
-   else if (n < (1 << 24))
-             if (n < (1 << 19))       return 15 + log2_4[n >> 15];
-             else                     return 20 + log2_4[n >> 20];
-        else if (n < (1 << 29))       return 25 + log2_4[n >> 25];
-             else                     return 30 + log2_4[n >> 30];
-}
-
-#ifndef M_PI
-  #define M_PI  3.14159265358979323846264f  // from CRC
-#endif
-
-// code length assigned to a value with no huffman encoding
-#define NO_CODE   255
-
-/////////////////////// LEAF SETUP FUNCTIONS //////////////////////////
-//
-// these functions are only called at setup, and only a few times
-// per file
-
-static float stbv_float32_unpack(stbv_uint32 x)
-{
-   // from the specification
-   stbv_uint32 mantissa = x & 0x1fffff;
-   stbv_uint32 sign = x & 0x80000000;
-   stbv_uint32 exp = (x & 0x7fe00000) >> 21;
-   double res = sign ? -(double)mantissa : (double)mantissa;
-   return (float) ldexp((float)res, exp-788);
-}
-
-
-// zlib & jpeg huffman tables assume that the output symbols
-// can either be arbitrarily arranged, or have monotonically
-// increasing frequencies--they rely on the lengths being sorted;
-// this makes for a very simple generation algorithm.
-// vorbis allows a huffman table with non-sorted lengths. This
-// requires a more sophisticated construction, since symbols in
-// order do not map to huffman codes "in order".
-static void stbv_add_entry(StbvCodebook *c, stbv_uint32 huff_code, int symbol, int count, int len, stbv_uint32 *values)
-{
-   if (!c->sparse) {
-      c->codewords      [symbol] = huff_code;
-   } else {
-      c->codewords       [count] = huff_code;
-      c->codeword_lengths[count] = len;
-      values             [count] = symbol;
-   }
-}
-
-static int stbv_compute_codewords(StbvCodebook *c, stbv_uint8 *len, int n, stbv_uint32 *values)
-{
-   int i,k,m=0;
-   stbv_uint32 available[32];
-
-   memset(available, 0, sizeof(available));
-   // find the first entry
-   for (k=0; k < n; ++k) if (len[k] < NO_CODE) break;
-   if (k == n) { assert(c->sorted_entries == 0); return TRUE; }
-   // add to the list
-   stbv_add_entry(c, 0, k, m++, len[k], values);
-   // add all available leaves
-   for (i=1; i <= len[k]; ++i)
-      available[i] = 1U << (32-i);
-   // note that the above code treats the first case specially,
-   // but it's really the same as the following code, so they
-   // could probably be combined (except the initial code is 0,
-   // and I use 0 in available[] to mean 'empty')
-   for (i=k+1; i < n; ++i) {
-      stbv_uint32 res;
-      int z = len[i], y;
-      if (z == NO_CODE) continue;
-      // find lowest available leaf (should always be earliest,
-      // which is what the specification calls for)
-      // note that this property, and the fact we can never have
-      // more than one free leaf at a given level, isn't totally
-      // trivial to prove, but it seems true and the assert never
-      // fires, so!
-      while (z > 0 && !available[z]) --z;
-      if (z == 0) { return FALSE; }
-      res = available[z];
-      assert(z >= 0 && z < 32);
-      available[z] = 0;
-      stbv_add_entry(c, stbv_bit_reverse(res), i, m++, len[i], values);
-      // propogate availability up the tree
-      if (z != len[i]) {
-         assert(len[i] >= 0 && len[i] < 32);
-         for (y=len[i]; y > z; --y) {
-            assert(available[y] == 0);
-            available[y] = res + (1 << (32-y));
-         }
-      }
-   }
-   return TRUE;
-}
-
-// accelerated huffman table allows fast O(1) match of all symbols
-// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
-static void stbv_compute_accelerated_huffman(StbvCodebook *c)
-{
-   int i, len;
-   for (i=0; i < STBV_FAST_HUFFMAN_TABLE_SIZE; ++i)
-      c->fast_huffman[i] = -1;
-
-   len = c->sparse ? c->sorted_entries : c->entries;
-   #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
-   if (len > 32767) len = 32767; // largest possible value we can encode!
-   #endif
-   for (i=0; i < len; ++i) {
-      if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
-         stbv_uint32 z = c->sparse ? stbv_bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
-         // set table entries for all bit combinations in the higher bits
-         while (z < STBV_FAST_HUFFMAN_TABLE_SIZE) {
-             c->fast_huffman[z] = i;
-             z += 1 << c->codeword_lengths[i];
-         }
-      }
-   }
-}
-
-#ifdef _MSC_VER
-#define STBV_CDECL __cdecl
-#else
-#define STBV_CDECL
-#endif
-
-static int STBV_CDECL stbv_uint32_compare(const void *p, const void *q)
-{
-   stbv_uint32 x = * (stbv_uint32 *) p;
-   stbv_uint32 y = * (stbv_uint32 *) q;
-   return x < y ? -1 : x > y;
-}
-
-static int stbv_include_in_sort(StbvCodebook *c, stbv_uint8 len)
-{
-   if (c->sparse) { assert(len != NO_CODE); return TRUE; }
-   if (len == NO_CODE) return FALSE;
-   if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE;
-   return FALSE;
-}
-
-// if the fast table above doesn't work, we want to binary
-// search them... need to reverse the bits
-static void stbv_compute_sorted_huffman(StbvCodebook *c, stbv_uint8 *lengths, stbv_uint32 *values)
-{
-   int i, len;
-   // build a list of all the entries
-   // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN.
-   // this is kind of a frivolous optimization--I don't see any performance improvement,
-   // but it's like 4 extra lines of code, so.
-   if (!c->sparse) {
-      int k = 0;
-      for (i=0; i < c->entries; ++i)
-         if (stbv_include_in_sort(c, lengths[i])) 
-            c->sorted_codewords[k++] = stbv_bit_reverse(c->codewords[i]);
-      assert(k == c->sorted_entries);
-   } else {
-      for (i=0; i < c->sorted_entries; ++i)
-         c->sorted_codewords[i] = stbv_bit_reverse(c->codewords[i]);
-   }
-
-   qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), stbv_uint32_compare);
-   c->sorted_codewords[c->sorted_entries] = 0xffffffff;
-
-   len = c->sparse ? c->sorted_entries : c->entries;
-   // now we need to indicate how they correspond; we could either
-   //   #1: sort a different data structure that says who they correspond to
-   //   #2: for each sorted entry, search the original list to find who corresponds
-   //   #3: for each original entry, find the sorted entry
-   // #1 requires extra storage, #2 is slow, #3 can use binary search!
-   for (i=0; i < len; ++i) {
-      int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
-      if (stbv_include_in_sort(c,huff_len)) {
-         stbv_uint32 code = stbv_bit_reverse(c->codewords[i]);
-         int x=0, n=c->sorted_entries;
-         while (n > 1) {
-            // invariant: sc[x] <= code < sc[x+n]
-            int m = x + (n >> 1);
-            if (c->sorted_codewords[m] <= code) {
-               x = m;
-               n -= (n>>1);
-            } else {
-               n >>= 1;
-            }
-         }
-         assert(c->sorted_codewords[x] == code);
-         if (c->sparse) {
-            c->sorted_values[x] = values[i];
-            c->codeword_lengths[x] = huff_len;
-         } else {
-            c->sorted_values[x] = i;
-         }
-      }
-   }
-}
-
-// only run while parsing the header (3 times)
-static int stbv_vorbis_validate(stbv_uint8 *data)
-{
-   static stbv_uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
-   return memcmp(data, vorbis, 6) == 0;
-}
-
-// called from setup only, once per code book
-// (formula implied by specification)
-static int stbv_lookup1_values(int entries, int dim)
-{
-   int r = (int) floor(exp((float) log((float) entries) / dim));
-   if ((int) floor(pow((float) r+1, dim)) <= entries)   // (int) cast for MinGW warning;
-      ++r;                                              // floor() to avoid _ftol() when non-CRT
-   assert(pow((float) r+1, dim) > entries);
-   assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above
-   return r;
-}
-
-// called twice per file
-static void stbv_compute_twiddle_factors(int n, float *A, float *B, float *C)
-{
-   int n4 = n >> 2, n8 = n >> 3;
-   int k,k2;
-
-   for (k=k2=0; k < n4; ++k,k2+=2) {
-      A[k2  ] = (float)  cos(4*k*M_PI/n);
-      A[k2+1] = (float) -sin(4*k*M_PI/n);
-      B[k2  ] = (float)  cos((k2+1)*M_PI/n/2) * 0.5f;
-      B[k2+1] = (float)  sin((k2+1)*M_PI/n/2) * 0.5f;
-   }
-   for (k=k2=0; k < n8; ++k,k2+=2) {
-      C[k2  ] = (float)  cos(2*(k2+1)*M_PI/n);
-      C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
-   }
-}
-
-static void stbv_compute_window(int n, float *window)
-{
-   int n2 = n >> 1, i;
-   for (i=0; i < n2; ++i)
-      window[i] = (float) sin(0.5 * M_PI * stbv_square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
-}
-
-static void stbv_compute_bitreverse(int n, stbv_uint16 *rev)
-{
-   int ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-   int i, n8 = n >> 3;
-   for (i=0; i < n8; ++i)
-      rev[i] = (stbv_bit_reverse(i) >> (32-ld+3)) << 2;
-}
-
-static int stbv_init_blocksize(stbv_vorb *f, int b, int n)
-{
-   int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
-   f->A[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   f->B[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   f->C[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n4);
-   if (!f->A[b] || !f->B[b] || !f->C[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
-   f->window[b] = (float *) stbv_setup_malloc(f, sizeof(float) * n2);
-   if (!f->window[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_window(n, f->window[b]);
-   f->stbv_bit_reverse[b] = (stbv_uint16 *) stbv_setup_malloc(f, sizeof(stbv_uint16) * n8);
-   if (!f->stbv_bit_reverse[b]) return stbv_error(f, VORBIS_outofmem);
-   stbv_compute_bitreverse(n, f->stbv_bit_reverse[b]);
-   return TRUE;
-}
-
-static void stbv_neighbors(stbv_uint16 *x, int n, int *plow, int *phigh)
-{
-   int low = -1;
-   int high = 65536;
-   int i;
-   for (i=0; i < n; ++i) {
-      if (x[i] > low  && x[i] < x[n]) { *plow  = i; low = x[i]; }
-      if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; }
-   }
-}
-
-// this has been repurposed so y is now the original index instead of y
-typedef struct
-{
-   stbv_uint16 x,id;
-} stbv_floor_ordering;
-
-static int STBV_CDECL stbv_point_compare(const void *p, const void *q)
-{
-   stbv_floor_ordering *a = (stbv_floor_ordering *) p;
-   stbv_floor_ordering *b = (stbv_floor_ordering *) q;
-   return a->x < b->x ? -1 : a->x > b->x;
-}
-
-//
-/////////////////////// END LEAF SETUP FUNCTIONS //////////////////////////
-
-
-#if defined(STB_VORBIS_NO_STDIO)
-   #define STBV_USE_MEMORY(z)    TRUE
-#else
-   #define STBV_USE_MEMORY(z)    ((z)->stream)
-#endif
-
-static stbv_uint8 stbv_get8(stbv_vorb *z)
-{
-   if (STBV_USE_MEMORY(z)) {
-      if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
-      return *z->stream++;
-   }
-
-   #ifndef STB_VORBIS_NO_STDIO
-   {
-   int c = fgetc(z->f);
-   if (c == EOF) { z->eof = TRUE; return 0; }
-   return c;
-   }
-   #endif
-}
-
-static stbv_uint32 stbv_get32(stbv_vorb *f)
-{
-   stbv_uint32 x;
-   x = stbv_get8(f);
-   x += stbv_get8(f) << 8;
-   x += stbv_get8(f) << 16;
-   x += (stbv_uint32) stbv_get8(f) << 24;
-   return x;
-}
-
-static int stbv_getn(stbv_vorb *z, stbv_uint8 *data, int n)
-{
-   if (STBV_USE_MEMORY(z)) {
-      if (z->stream+n > z->stream_end) { z->eof = 1; return 0; }
-      memcpy(data, z->stream, n);
-      z->stream += n;
-      return 1;
-   }
-
-   #ifndef STB_VORBIS_NO_STDIO   
-   if (fread(data, n, 1, z->f) == 1)
-      return 1;
-   else {
-      z->eof = 1;
-      return 0;
-   }
-   #endif
-}
-
-static void stbv_skip(stbv_vorb *z, int n)
-{
-   if (STBV_USE_MEMORY(z)) {
-      z->stream += n;
-      if (z->stream >= z->stream_end) z->eof = 1;
-      return;
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   {
-      long x = ftell(z->f);
-      fseek(z->f, x+n, SEEK_SET);
-   }
-   #endif
-}
-
-static int stbv_set_file_offset(stb_vorbis *f, unsigned int loc)
-{
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (f->push_mode) return 0;
-   #endif
-   f->eof = 0;
-   if (STBV_USE_MEMORY(f)) {
-      if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
-         f->stream = f->stream_end;
-         f->eof = 1;
-         return 0;
-      } else {
-         f->stream = f->stream_start + loc;
-         return 1;
-      }
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   if (loc + f->f_start < loc || loc >= 0x80000000) {
-      loc = 0x7fffffff;
-      f->eof = 1;
-   } else {
-      loc += f->f_start;
-   }
-   if (!fseek(f->f, loc, SEEK_SET))
-      return 1;
-   f->eof = 1;
-   fseek(f->f, f->f_start, SEEK_END);
-   return 0;
-   #endif
-}
-
-
-static stbv_uint8 stbv_ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
-
-static int stbv_capture_pattern(stbv_vorb *f)
-{
-   if (0x4f != stbv_get8(f)) return FALSE;
-   if (0x67 != stbv_get8(f)) return FALSE;
-   if (0x67 != stbv_get8(f)) return FALSE;
-   if (0x53 != stbv_get8(f)) return FALSE;
-   return TRUE;
-}
-
-#define STBV_PAGEFLAG_continued_packet   1
-#define STBV_PAGEFLAG_first_page         2
-#define STBV_PAGEFLAG_last_page          4
-
-static int stbv_start_page_no_capturepattern(stbv_vorb *f)
-{
-   stbv_uint32 loc0,loc1,n;
-   // stream structure version
-   if (0 != stbv_get8(f)) return stbv_error(f, VORBIS_invalid_stream_structure_version);
-   // header flag
-   f->page_flag = stbv_get8(f);
-   // absolute granule position
-   loc0 = stbv_get32(f); 
-   loc1 = stbv_get32(f);
-   // @TODO: validate loc0,loc1 as valid positions?
-   // stream serial number -- vorbis doesn't interleave, so discard
-   stbv_get32(f);
-   //if (f->serial != stbv_get32(f)) return stbv_error(f, VORBIS_incorrect_stream_serial_number);
-   // page sequence number
-   n = stbv_get32(f);
-   f->last_page = n;
-   // CRC32
-   stbv_get32(f);
-   // page_segments
-   f->segment_count = stbv_get8(f);
-   if (!stbv_getn(f, f->segments, f->segment_count))
-      return stbv_error(f, VORBIS_unexpected_eof);
-   // assume we _don't_ know any the sample position of any segments
-   f->end_seg_with_known_loc = -2;
-   if (loc0 != ~0U || loc1 != ~0U) {
-      int i;
-      // determine which packet is the last one that will complete
-      for (i=f->segment_count-1; i >= 0; --i)
-         if (f->segments[i] < 255)
-            break;
-      // 'i' is now the index of the _last_ segment of a packet that ends
-      if (i >= 0) {
-         f->end_seg_with_known_loc = i;
-         f->known_loc_for_packet   = loc0;
-      }
-   }
-   if (f->first_decode) {
-      int i,len;
-      StbvProbedPage p;
-      len = 0;
-      for (i=0; i < f->segment_count; ++i)
-         len += f->segments[i];
-      len += 27 + f->segment_count;
-      p.page_start = f->first_audio_page_offset;
-      p.page_end = p.page_start + len;
-      p.last_decoded_sample = loc0;
-      f->p_first = p;
-   }
-   f->next_seg = 0;
-   return TRUE;
-}
-
-static int stbv_start_page(stbv_vorb *f)
-{
-   if (!stbv_capture_pattern(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-   return stbv_start_page_no_capturepattern(f);
-}
-
-static int stbv_start_packet(stbv_vorb *f)
-{
-   while (f->next_seg == -1) {
-      if (!stbv_start_page(f)) return FALSE;
-      if (f->page_flag & STBV_PAGEFLAG_continued_packet)
-         return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-   }
-   f->last_seg = FALSE;
-   f->valid_bits = 0;
-   f->packet_bytes = 0;
-   f->bytes_in_seg = 0;
-   // f->next_seg is now valid
-   return TRUE;
-}
-
-static int stbv_maybe_start_packet(stbv_vorb *f)
-{
-   if (f->next_seg == -1) {
-      int x = stbv_get8(f);
-      if (f->eof) return FALSE; // EOF at page boundary is not an error!
-      if (0x4f != x      ) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x67 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (0x53 != stbv_get8(f)) return stbv_error(f, VORBIS_missing_capture_pattern);
-      if (!stbv_start_page_no_capturepattern(f)) return FALSE;
-      if (f->page_flag & STBV_PAGEFLAG_continued_packet) {
-         // set up enough state that we can read this packet if we want,
-         // e.g. during recovery
-         f->last_seg = FALSE;
-         f->bytes_in_seg = 0;
-         return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-      }
-   }
-   return stbv_start_packet(f);
-}
-
-static int stbv_next_segment(stbv_vorb *f)
-{
-   int len;
-   if (f->last_seg) return 0;
-   if (f->next_seg == -1) {
-      f->last_seg_which = f->segment_count-1; // in case stbv_start_page fails
-      if (!stbv_start_page(f)) { f->last_seg = 1; return 0; }
-      if (!(f->page_flag & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_continued_packet_flag_invalid);
-   }
-   len = f->segments[f->next_seg++];
-   if (len < 255) {
-      f->last_seg = TRUE;
-      f->last_seg_which = f->next_seg-1;
-   }
-   if (f->next_seg >= f->segment_count)
-      f->next_seg = -1;
-   assert(f->bytes_in_seg == 0);
-   f->bytes_in_seg = len;
-   return len;
-}
-
-#define STBV_EOP    (-1)
-#define STBV_INVALID_BITS  (-1)
-
-static int stbv_get8_packet_raw(stbv_vorb *f)
-{
-   if (!f->bytes_in_seg) {  // CLANG!
-      if (f->last_seg) return STBV_EOP;
-      else if (!stbv_next_segment(f)) return STBV_EOP;
-   }
-   assert(f->bytes_in_seg > 0);
-   --f->bytes_in_seg;
-   ++f->packet_bytes;
-   return stbv_get8(f);
-}
-
-static int stbv_get8_packet(stbv_vorb *f)
-{
-   int x = stbv_get8_packet_raw(f);
-   f->valid_bits = 0;
-   return x;
-}
-
-static void stbv_flush_packet(stbv_vorb *f)
-{
-   while (stbv_get8_packet_raw(f) != STBV_EOP);
-}
-
-// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important
-// as the huffman decoder?
-static stbv_uint32 stbv_get_bits(stbv_vorb *f, int n)
-{
-   stbv_uint32 z;
-
-   if (f->valid_bits < 0) return 0;
-   if (f->valid_bits < n) {
-      if (n > 24) {
-         // the accumulator technique below would not work correctly in this case
-         z = stbv_get_bits(f, 24);
-         z += stbv_get_bits(f, n-24) << 24;
-         return z;
-      }
-      if (f->valid_bits == 0) f->acc = 0;
-      while (f->valid_bits < n) {
-         int z = stbv_get8_packet_raw(f);
-         if (z == STBV_EOP) {
-            f->valid_bits = STBV_INVALID_BITS;
-            return 0;
-         }
-         f->acc += z << f->valid_bits;
-         f->valid_bits += 8;
-      }
-   }
-   if (f->valid_bits < 0) return 0;
-   z = f->acc & ((1 << n)-1);
-   f->acc >>= n;
-   f->valid_bits -= n;
-   return z;
-}
-
-// @OPTIMIZE: primary accumulator for huffman
-// expand the buffer to as many bits as possible without reading off end of packet
-// it might be nice to allow f->valid_bits and f->acc to be stored in registers,
-// e.g. cache them locally and decode locally
-static __forceinline void stbv_prep_huffman(stbv_vorb *f)
-{
-   if (f->valid_bits <= 24) {
-      if (f->valid_bits == 0) f->acc = 0;
-      do {
-         int z;
-         if (f->last_seg && !f->bytes_in_seg) return;
-         z = stbv_get8_packet_raw(f);
-         if (z == STBV_EOP) return;
-         f->acc += (unsigned) z << f->valid_bits;
-         f->valid_bits += 8;
-      } while (f->valid_bits <= 24);
-   }
-}
-
-enum
-{
-   STBV_VORBIS_packet_id = 1,
-   STBV_VORBIS_packet_comment = 3,
-   STBV_VORBIS_packet_setup = 5
-};
-
-static int stbv_codebook_decode_scalar_raw(stbv_vorb *f, StbvCodebook *c)
-{
-   int i;
-   stbv_prep_huffman(f);
-
-   if (c->codewords == NULL && c->sorted_codewords == NULL)
-      return -1;
-
-   // cases to use binary search: sorted_codewords && !c->codewords
-   //                             sorted_codewords && c->entries > 8
-   if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
-      // binary search
-      stbv_uint32 code = stbv_bit_reverse(f->acc);
-      int x=0, n=c->sorted_entries, len;
-
-      while (n > 1) {
-         // invariant: sc[x] <= code < sc[x+n]
-         int m = x + (n >> 1);
-         if (c->sorted_codewords[m] <= code) {
-            x = m;
-            n -= (n>>1);
-         } else {
-            n >>= 1;
-         }
-      }
-      // x is now the sorted index
-      if (!c->sparse) x = c->sorted_values[x];
-      // x is now sorted index if sparse, or symbol otherwise
-      len = c->codeword_lengths[x];
-      if (f->valid_bits >= len) {
-         f->acc >>= len;
-         f->valid_bits -= len;
-         return x;
-      }
-
-      f->valid_bits = 0;
-      return -1;
-   }
-
-   // if small, linear search
-   assert(!c->sparse);
-   for (i=0; i < c->entries; ++i) {
-      if (c->codeword_lengths[i] == NO_CODE) continue;
-      if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) {
-         if (f->valid_bits >= c->codeword_lengths[i]) {
-            f->acc >>= c->codeword_lengths[i];
-            f->valid_bits -= c->codeword_lengths[i];
-            return i;
-         }
-         f->valid_bits = 0;
-         return -1;
-      }
-   }
-
-   stbv_error(f, VORBIS_invalid_stream);
-   f->valid_bits = 0;
-   return -1;
-}
-
-#ifndef STB_VORBIS_NO_INLINE_DECODE
-
-#define STBV_DECODE_RAW(var, f,c)                                  \
-   if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)        \
-      stbv_prep_huffman(f);                                        \
-   var = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK;                    \
-   var = c->fast_huffman[var];                                \
-   if (var >= 0) {                                            \
-      int n = c->codeword_lengths[var];                       \
-      f->acc >>= n;                                           \
-      f->valid_bits -= n;                                     \
-      if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
-   } else {                                                   \
-      var = stbv_codebook_decode_scalar_raw(f,c);                  \
-   }
-
-#else
-
-static int stbv_codebook_decode_scalar(stbv_vorb *f, StbvCodebook *c)
-{
-   int i;
-   if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
-      stbv_prep_huffman(f);
-   // fast huffman table lookup
-   i = f->acc & STBV_FAST_HUFFMAN_TABLE_MASK;
-   i = c->fast_huffman[i];
-   if (i >= 0) {
-      f->acc >>= c->codeword_lengths[i];
-      f->valid_bits -= c->codeword_lengths[i];
-      if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
-      return i;
-   }
-   return stbv_codebook_decode_scalar_raw(f,c);
-}
-
-#define STBV_DECODE_RAW(var,f,c)    var = stbv_codebook_decode_scalar(f,c);
-
-#endif
-
-#define STBV_DECODE(var,f,c)                                       \
-   STBV_DECODE_RAW(var,f,c)                                        \
-   if (c->sparse) var = c->sorted_values[var];
-
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-  #define DECODE_VQ(var,f,c)   STBV_DECODE_RAW(var,f,c)
-#else
-  #define DECODE_VQ(var,f,c)   STBV_DECODE(var,f,c)
-#endif
-
-
-
-
-
-
-// STBV_CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
-// where we avoid one addition
-#define STBV_CODEBOOK_ELEMENT(c,off)          (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_FAST(c,off)     (c->multiplicands[off])
-#define STBV_CODEBOOK_ELEMENT_BASE(c)         (0)
-
-static int stbv_codebook_decode_start(stbv_vorb *f, StbvCodebook *c)
-{
-   int z = -1;
-
-   // type 0 is only legal in a scalar context
-   if (c->lookup_type == 0)
-      stbv_error(f, VORBIS_invalid_stream);
-   else {
-      DECODE_VQ(z,f,c);
-      if (c->sparse) assert(z < c->sorted_entries);
-      if (z < 0) {  // check for STBV_EOP
-         if (!f->bytes_in_seg)
-            if (f->last_seg)
-               return z;
-         stbv_error(f, VORBIS_invalid_stream);
-      }
-   }
-   return z;
-}
-
-static int stbv_codebook_decode(stbv_vorb *f, StbvCodebook *c, float *output, int len)
-{
-   int i,z = stbv_codebook_decode_start(f,c);
-   if (z < 0) return FALSE;
-   if (len > c->dimensions) len = c->dimensions;
-
-#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-   if (c->lookup_type == 1) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      int div = 1;
-      for (i=0; i < len; ++i) {
-         int off = (z / div) % c->lookup_values;
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-         output[i] += val;
-         if (c->sequence_p) last = val + c->minimum_value;
-         div *= c->lookup_values;
-      }
-      return TRUE;
-   }
-#endif
-
-   z *= c->dimensions;
-   if (c->sequence_p) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      for (i=0; i < len; ++i) {
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-         output[i] += val;
-         last = val + c->minimum_value;
-      }
-   } else {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      for (i=0; i < len; ++i) {
-         output[i] += STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-      }
-   }
-
-   return TRUE;
-}
-
-static int stbv_codebook_decode_step(stbv_vorb *f, StbvCodebook *c, float *output, int len, int step)
-{
-   int i,z = stbv_codebook_decode_start(f,c);
-   float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-   if (z < 0) return FALSE;
-   if (len > c->dimensions) len = c->dimensions;
-
-#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-   if (c->lookup_type == 1) {
-      int div = 1;
-      for (i=0; i < len; ++i) {
-         int off = (z / div) % c->lookup_values;
-         float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-         output[i*step] += val;
-         if (c->sequence_p) last = val;
-         div *= c->lookup_values;
-      }
-      return TRUE;
-   }
-#endif
-
-   z *= c->dimensions;
-   for (i=0; i < len; ++i) {
-      float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-      output[i*step] += val;
-      if (c->sequence_p) last = val;
-   }
-
-   return TRUE;
-}
-
-static int stbv_codebook_decode_deinterleave_repeat(stbv_vorb *f, StbvCodebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
-{
-   int c_inter = *c_inter_p;
-   int p_inter = *p_inter_p;
-   int i,z, effective = c->dimensions;
-
-   // type 0 is only legal in a scalar context
-   if (c->lookup_type == 0)   return stbv_error(f, VORBIS_invalid_stream);
-
-   while (total_decode > 0) {
-      float last = STBV_CODEBOOK_ELEMENT_BASE(c);
-      DECODE_VQ(z,f,c);
-      #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-      assert(!c->sparse || z < c->sorted_entries);
-      #endif
-      if (z < 0) {
-         if (!f->bytes_in_seg)
-            if (f->last_seg) return FALSE;
-         return stbv_error(f, VORBIS_invalid_stream);
-      }
-
-      // if this will take us off the end of the buffers, stop short!
-      // we check by computing the length of the virtual interleaved
-      // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
-      // and the length we'll be using (effective)
-      if (c_inter + p_inter*ch + effective > len * ch) {
-         effective = len*ch - (p_inter*ch - c_inter);
-      }
-
-   #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-      if (c->lookup_type == 1) {
-         int div = 1;
-         for (i=0; i < effective; ++i) {
-            int off = (z / div) % c->lookup_values;
-            float val = STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
-            if (outputs[c_inter])
-               outputs[c_inter][p_inter] += val;
-            if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-            if (c->sequence_p) last = val;
-            div *= c->lookup_values;
-         }
-      } else
-   #endif
-      {
-         z *= c->dimensions;
-         if (c->sequence_p) {
-            for (i=0; i < effective; ++i) {
-               float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-               if (outputs[c_inter])
-                  outputs[c_inter][p_inter] += val;
-               if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-               last = val;
-            }
-         } else {
-            for (i=0; i < effective; ++i) {
-               float val = STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
-               if (outputs[c_inter])
-                  outputs[c_inter][p_inter] += val;
-               if (++c_inter == ch) { c_inter = 0; ++p_inter; }
-            }
-         }
-      }
-
-      total_decode -= effective;
-   }
-   *c_inter_p = c_inter;
-   *p_inter_p = p_inter;
-   return TRUE;
-}
-
-static int stbv_predict_point(int x, int x0, int x1, int y0, int y1)
-{
-   int dy = y1 - y0;
-   int adx = x1 - x0;
-   // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86?
-   int err = abs(dy) * (x - x0);
-   int off = err / adx;
-   return dy < 0 ? y0 - off : y0 + off;
-}
-
-// the following table is block-copied from the specification
-static float stbv_inverse_db_table[256] =
-{
-  1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, 
-  1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, 
-  1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, 
-  2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, 
-  2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, 
-  3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, 
-  4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, 
-  6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, 
-  7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, 
-  1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, 
-  1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, 
-  1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, 
-  2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, 
-  2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, 
-  3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, 
-  4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, 
-  5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, 
-  7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, 
-  9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, 
-  1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, 
-  1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, 
-  2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, 
-  2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, 
-  3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, 
-  4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, 
-  5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, 
-  7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, 
-  9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, 
-  0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, 
-  0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, 
-  0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, 
-  0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, 
-  0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, 
-  0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, 
-  0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, 
-  0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, 
-  0.00092223983f, 0.00098217216f, 0.0010459992f,  0.0011139742f, 
-  0.0011863665f,  0.0012634633f,  0.0013455702f,  0.0014330129f, 
-  0.0015261382f,  0.0016253153f,  0.0017309374f,  0.0018434235f, 
-  0.0019632195f,  0.0020908006f,  0.0022266726f,  0.0023713743f, 
-  0.0025254795f,  0.0026895994f,  0.0028643847f,  0.0030505286f, 
-  0.0032487691f,  0.0034598925f,  0.0036847358f,  0.0039241906f, 
-  0.0041792066f,  0.0044507950f,  0.0047400328f,  0.0050480668f, 
-  0.0053761186f,  0.0057254891f,  0.0060975636f,  0.0064938176f, 
-  0.0069158225f,  0.0073652516f,  0.0078438871f,  0.0083536271f, 
-  0.0088964928f,  0.009474637f,   0.010090352f,   0.010746080f, 
-  0.011444421f,   0.012188144f,   0.012980198f,   0.013823725f, 
-  0.014722068f,   0.015678791f,   0.016697687f,   0.017782797f, 
-  0.018938423f,   0.020169149f,   0.021479854f,   0.022875735f, 
-  0.024362330f,   0.025945531f,   0.027631618f,   0.029427276f, 
-  0.031339626f,   0.033376252f,   0.035545228f,   0.037855157f, 
-  0.040315199f,   0.042935108f,   0.045725273f,   0.048696758f, 
-  0.051861348f,   0.055231591f,   0.058820850f,   0.062643361f, 
-  0.066714279f,   0.071049749f,   0.075666962f,   0.080584227f, 
-  0.085821044f,   0.091398179f,   0.097337747f,   0.10366330f, 
-  0.11039993f,    0.11757434f,    0.12521498f,    0.13335215f, 
-  0.14201813f,    0.15124727f,    0.16107617f,    0.17154380f, 
-  0.18269168f,    0.19456402f,    0.20720788f,    0.22067342f, 
-  0.23501402f,    0.25028656f,    0.26655159f,    0.28387361f, 
-  0.30232132f,    0.32196786f,    0.34289114f,    0.36517414f, 
-  0.38890521f,    0.41417847f,    0.44109412f,    0.46975890f, 
-  0.50028648f,    0.53279791f,    0.56742212f,    0.60429640f, 
-  0.64356699f,    0.68538959f,    0.72993007f,    0.77736504f, 
-  0.82788260f,    0.88168307f,    0.9389798f,     1.0f
-};
-
-
-// @OPTIMIZE: if you want to replace this bresenham line-drawing routine,
-// note that you must produce bit-identical output to decode correctly;
-// this specific sequence of operations is specified in the spec (it's
-// drawing integer-quantized frequency-space lines that the encoder
-// expects to be exactly the same)
-//     ... also, isn't the whole point of Bresenham's algorithm to NOT
-// have to divide in the setup? sigh.
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-#define STBV_LINE_OP(a,b)   a *= b
-#else
-#define STBV_LINE_OP(a,b)   a = b
-#endif
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-#define STBV_DIVTAB_NUMER   32
-#define STBV_DIVTAB_DENOM   64
-stbv_int8 stbv_integer_divide_table[STBV_DIVTAB_NUMER][STBV_DIVTAB_DENOM]; // 2KB
-#endif
-
-static __forceinline void stbv_draw_line(float *output, int x0, int y0, int x1, int y1, int n)
-{
-   int dy = y1 - y0;
-   int adx = x1 - x0;
-   int ady = abs(dy);
-   int base;
-   int x=x0,y=y0;
-   int err = 0;
-   int sy;
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-   if (adx < STBV_DIVTAB_DENOM && ady < STBV_DIVTAB_NUMER) {
-      if (dy < 0) {
-         base = -stbv_integer_divide_table[ady][adx];
-         sy = base-1;
-      } else {
-         base =  stbv_integer_divide_table[ady][adx];
-         sy = base+1;
-      }
-   } else {
-      base = dy / adx;
-      if (dy < 0)
-         sy = base - 1;
-      else
-         sy = base+1;
-   }
-#else
-   base = dy / adx;
-   if (dy < 0)
-      sy = base - 1;
-   else
-      sy = base+1;
-#endif
-   ady -= abs(base) * adx;
-   if (x1 > n) x1 = n;
-   if (x < x1) {
-      STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
-      for (++x; x < x1; ++x) {
-         err += ady;
-         if (err >= adx) {
-            err -= adx;
-            y += sy;
-         } else
-            y += base;
-         STBV_LINE_OP(output[x], stbv_inverse_db_table[y]);
-      }
-   }
-}
-
-static int stbv_residue_decode(stbv_vorb *f, StbvCodebook *book, float *target, int offset, int n, int rtype)
-{
-   int k;
-   if (rtype == 0) {
-      int step = n / book->dimensions;
-      for (k=0; k < step; ++k)
-         if (!stbv_codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
-            return FALSE;
-   } else {
-      for (k=0; k < n; ) {
-         if (!stbv_codebook_decode(f, book, target+offset, n-k))
-            return FALSE;
-         k += book->dimensions;
-         offset += book->dimensions;
-      }
-   }
-   return TRUE;
-}
-
-// n is 1/2 of the blocksize --
-// specification: "Correct per-vector decode length is [n]/2"
-static void stbv_decode_residue(stbv_vorb *f, float *residue_buffers[], int ch, int n, int rn, stbv_uint8 *do_not_decode)
-{
-   int i,j,pass;
-   StbvResidue *r = f->residue_config + rn;
-   int rtype = f->residue_types[rn];
-   int c = r->classbook;
-   int classwords = f->codebooks[c].dimensions;
-   unsigned int actual_size = rtype == 2 ? n*2 : n;
-   unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size);
-   unsigned int limit_r_end   = (r->end   < actual_size ? r->end   : actual_size);
-   int n_read = limit_r_end - limit_r_begin;
-   int part_read = n_read / r->part_size;
-   int temp_alloc_point = stbv_temp_alloc_save(f);
-   #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-   stbv_uint8 ***part_classdata = (stbv_uint8 ***) stbv_temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
-   #else
-   int **classifications = (int **) stbv_temp_block_array(f,f->channels, part_read * sizeof(**classifications));
-   #endif
-
-   STBV_CHECK(f);
-
-   for (i=0; i < ch; ++i)
-      if (!do_not_decode[i])
-         memset(residue_buffers[i], 0, sizeof(float) * n);
-
-   if (rtype == 2 && ch != 1) {
-      for (j=0; j < ch; ++j)
-         if (!do_not_decode[j])
-            break;
-      if (j == ch)
-         goto done;
-
-      for (pass=0; pass < 8; ++pass) {
-         int pcount = 0, class_set = 0;
-         if (ch == 2) {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = (z & 1), p_inter = z>>1;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                     #else
-                     // saves 1%
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                     #endif
-                  } else {
-                     z += r->part_size;
-                     c_inter = z & 1;
-                     p_inter = z >> 1;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         } else if (ch == 1) {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = 0, p_inter = z;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                  } else {
-                     z += r->part_size;
-                     c_inter = 0;
-                     p_inter = z;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         } else {
-            while (pcount < part_read) {
-               int z = r->begin + pcount*r->part_size;
-               int c_inter = z % ch, p_inter = z/ch;
-               if (pass == 0) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int q;
-                  STBV_DECODE(q,f,c);
-                  if (q == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[0][class_set] = r->classdata[q];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[0][i+pcount] = q % r->classifications;
-                     q /= r->classifications;
-                  }
-                  #endif
-               }
-               for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-                  int z = r->begin + pcount*r->part_size;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[0][class_set][i];
-                  #else
-                  int c = classifications[0][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
-                        goto done;
-                  } else {
-                     z += r->part_size;
-                     c_inter = z % ch;
-                     p_inter = z / ch;
-                  }
-               }
-               #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-               ++class_set;
-               #endif
-            }
-         }
-      }
-      goto done;
-   }
-   STBV_CHECK(f);
-
-   for (pass=0; pass < 8; ++pass) {
-      int pcount = 0, class_set=0;
-      while (pcount < part_read) {
-         if (pass == 0) {
-            for (j=0; j < ch; ++j) {
-               if (!do_not_decode[j]) {
-                  StbvCodebook *c = f->codebooks+r->classbook;
-                  int temp;
-                  STBV_DECODE(temp,f,c);
-                  if (temp == STBV_EOP) goto done;
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  part_classdata[j][class_set] = r->classdata[temp];
-                  #else
-                  for (i=classwords-1; i >= 0; --i) {
-                     classifications[j][i+pcount] = temp % r->classifications;
-                     temp /= r->classifications;
-                  }
-                  #endif
-               }
-            }
-         }
-         for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
-            for (j=0; j < ch; ++j) {
-               if (!do_not_decode[j]) {
-                  #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-                  int c = part_classdata[j][class_set][i];
-                  #else
-                  int c = classifications[j][pcount];
-                  #endif
-                  int b = r->residue_books[c][pass];
-                  if (b >= 0) {
-                     float *target = residue_buffers[j];
-                     int offset = r->begin + pcount * r->part_size;
-                     int n = r->part_size;
-                     StbvCodebook *book = f->codebooks + b;
-                     if (!stbv_residue_decode(f, book, target, offset, n, rtype))
-                        goto done;
-                  }
-               }
-            }
-         }
-         #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-         ++class_set;
-         #endif
-      }
-   }
-  done:
-   STBV_CHECK(f);
-   #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-   stbv_temp_free(f,part_classdata);
-   #else
-   stbv_temp_free(f,classifications);
-   #endif
-   stbv_temp_alloc_restore(f,temp_alloc_point);
-}
-
-
-#if 0
-// slow way for debugging
-void inverse_mdct_slow(float *buffer, int n)
-{
-   int i,j;
-   int n2 = n >> 1;
-   float *x = (float *) malloc(sizeof(*x) * n2);
-   memcpy(x, buffer, sizeof(*x) * n2);
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n2; ++j)
-         // formula from paper:
-         //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
-         // formula from wikipedia
-         //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
-         // these are equivalent, except the formula from the paper inverts the multiplier!
-         // however, what actually works is NO MULTIPLIER!?!
-         //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
-         acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
-      buffer[i] = acc;
-   }
-   free(x);
-}
-#elif 0
-// same as above, but just barely able to run in real time on modern machines
-void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   float mcos[16384];
-   int i,j;
-   int n2 = n >> 1, nmask = (n << 2) -1;
-   float *x = (float *) malloc(sizeof(*x) * n2);
-   memcpy(x, buffer, sizeof(*x) * n2);
-   for (i=0; i < 4*n; ++i)
-      mcos[i] = (float) cos(M_PI / 2 * i / n);
-
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n2; ++j)
-         acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask];
-      buffer[i] = acc;
-   }
-   free(x);
-}
-#elif 0
-// transform to use a slow dct-iv; this is STILL basically trivial,
-// but only requires half as many ops
-void dct_iv_slow(float *buffer, int n)
-{
-   float mcos[16384];
-   float x[2048];
-   int i,j;
-   int n2 = n >> 1, nmask = (n << 3) - 1;
-   memcpy(x, buffer, sizeof(*x) * n);
-   for (i=0; i < 8*n; ++i)
-      mcos[i] = (float) cos(M_PI / 4 * i / n);
-   for (i=0; i < n; ++i) {
-      float acc = 0;
-      for (j=0; j < n; ++j)
-         acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask];
-      buffer[i] = acc;
-   }
-}
-
-void inverse_mdct_slow(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4;
-   float temp[4096];
-
-   memcpy(temp, buffer, n2 * sizeof(float));
-   dct_iv_slow(temp, n2);  // returns -c'-d, a-b'
-
-   for (i=0; i < n4  ; ++i) buffer[i] = temp[i+n4];            // a-b'
-   for (   ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1];   // b-a', c+d'
-   for (   ; i < n   ; ++i) buffer[i] = -temp[i - n3_4];       // c'+d
-}
-#endif
-
-#ifndef LIBVORBIS_MDCT
-#define LIBVORBIS_MDCT 0
-#endif
-
-#if LIBVORBIS_MDCT
-// directly call the vorbis MDCT using an interface documented
-// by Jeff Roberts... useful for performance comparison
-typedef struct 
-{
-  int n;
-  int log2n;
-  
-  float *trig;
-  int   *bitrev;
-
-  float scale;
-} mdct_lookup;
-
-extern void mdct_init(mdct_lookup *lookup, int n);
-extern void mdct_clear(mdct_lookup *l);
-extern void mdct_backward(mdct_lookup *init, float *in, float *out);
-
-mdct_lookup M1,M2;
-
-void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   mdct_lookup *M;
-   if (M1.n == n) M = &M1;
-   else if (M2.n == n) M = &M2;
-   else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; }
-   else { 
-      if (M2.n) __asm int 3;
-      mdct_init(&M2, n);
-      M = &M2;
-   }
-
-   mdct_backward(M, buffer, buffer);
-}
-#endif
-
-
-// the following were split out into separate functions while optimizing;
-// they could be pushed back up but eh. __forceinline showed no change;
-// they're probably already being inlined.
-static void stbv_imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
-{
-   float *ee0 = e + i_off;
-   float *ee2 = ee0 + k_off;
-   int i;
-
-   assert((n & 3) == 0);
-   for (i=(n>>2); i > 0; --i) {
-      float k00_20, k01_21;
-      k00_20  = ee0[ 0] - ee2[ 0];
-      k01_21  = ee0[-1] - ee2[-1];
-      ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0];
-      ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1];
-      ee2[ 0] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-1] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-2] - ee2[-2];
-      k01_21  = ee0[-3] - ee2[-3];
-      ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2];
-      ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3];
-      ee2[-2] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-3] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-4] - ee2[-4];
-      k01_21  = ee0[-5] - ee2[-5];
-      ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4];
-      ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5];
-      ee2[-4] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-5] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-
-      k00_20  = ee0[-6] - ee2[-6];
-      k01_21  = ee0[-7] - ee2[-7];
-      ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6];
-      ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7];
-      ee2[-6] = k00_20 * A[0] - k01_21 * A[1];
-      ee2[-7] = k01_21 * A[0] + k00_20 * A[1];
-      A += 8;
-      ee0 -= 8;
-      ee2 -= 8;
-   }
-}
-
-static void stbv_imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
-{
-   int i;
-   float k00_20, k01_21;
-
-   float *e0 = e + d0;
-   float *e2 = e0 + k_off;
-
-   for (i=lim >> 2; i > 0; --i) {
-      k00_20 = e0[-0] - e2[-0];
-      k01_21 = e0[-1] - e2[-1];
-      e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0];
-      e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1];
-      e2[-0] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-1] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-2] - e2[-2];
-      k01_21 = e0[-3] - e2[-3];
-      e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2];
-      e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3];
-      e2[-2] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-3] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-4] - e2[-4];
-      k01_21 = e0[-5] - e2[-5];
-      e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4];
-      e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5];
-      e2[-4] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-5] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      A += k1;
-
-      k00_20 = e0[-6] - e2[-6];
-      k01_21 = e0[-7] - e2[-7];
-      e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6];
-      e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7];
-      e2[-6] = (k00_20)*A[0] - (k01_21) * A[1];
-      e2[-7] = (k01_21)*A[0] + (k00_20) * A[1];
-
-      e0 -= 8;
-      e2 -= 8;
-
-      A += k1;
-   }
-}
-
-static void stbv_imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
-{
-   int i;
-   float A0 = A[0];
-   float A1 = A[0+1];
-   float A2 = A[0+a_off];
-   float A3 = A[0+a_off+1];
-   float A4 = A[0+a_off*2+0];
-   float A5 = A[0+a_off*2+1];
-   float A6 = A[0+a_off*3+0];
-   float A7 = A[0+a_off*3+1];
-
-   float k00,k11;
-
-   float *ee0 = e  +i_off;
-   float *ee2 = ee0+k_off;
-
-   for (i=n; i > 0; --i) {
-      k00     = ee0[ 0] - ee2[ 0];
-      k11     = ee0[-1] - ee2[-1];
-      ee0[ 0] =  ee0[ 0] + ee2[ 0];
-      ee0[-1] =  ee0[-1] + ee2[-1];
-      ee2[ 0] = (k00) * A0 - (k11) * A1;
-      ee2[-1] = (k11) * A0 + (k00) * A1;
-
-      k00     = ee0[-2] - ee2[-2];
-      k11     = ee0[-3] - ee2[-3];
-      ee0[-2] =  ee0[-2] + ee2[-2];
-      ee0[-3] =  ee0[-3] + ee2[-3];
-      ee2[-2] = (k00) * A2 - (k11) * A3;
-      ee2[-3] = (k11) * A2 + (k00) * A3;
-
-      k00     = ee0[-4] - ee2[-4];
-      k11     = ee0[-5] - ee2[-5];
-      ee0[-4] =  ee0[-4] + ee2[-4];
-      ee0[-5] =  ee0[-5] + ee2[-5];
-      ee2[-4] = (k00) * A4 - (k11) * A5;
-      ee2[-5] = (k11) * A4 + (k00) * A5;
-
-      k00     = ee0[-6] - ee2[-6];
-      k11     = ee0[-7] - ee2[-7];
-      ee0[-6] =  ee0[-6] + ee2[-6];
-      ee0[-7] =  ee0[-7] + ee2[-7];
-      ee2[-6] = (k00) * A6 - (k11) * A7;
-      ee2[-7] = (k11) * A6 + (k00) * A7;
-
-      ee0 -= k0;
-      ee2 -= k0;
-   }
-}
-
-static __forceinline void stbv_iter_54(float *z)
-{
-   float k00,k11,k22,k33;
-   float y0,y1,y2,y3;
-
-   k00  = z[ 0] - z[-4];
-   y0   = z[ 0] + z[-4];
-   y2   = z[-2] + z[-6];
-   k22  = z[-2] - z[-6];
-
-   z[-0] = y0 + y2;      // z0 + z4 + z2 + z6
-   z[-2] = y0 - y2;      // z0 + z4 - z2 - z6
-
-   // done with y0,y2
-
-   k33  = z[-3] - z[-7];
-
-   z[-4] = k00 + k33;    // z0 - z4 + z3 - z7
-   z[-6] = k00 - k33;    // z0 - z4 - z3 + z7
-
-   // done with k33
-
-   k11  = z[-1] - z[-5];
-   y1   = z[-1] + z[-5];
-   y3   = z[-3] + z[-7];
-
-   z[-1] = y1 + y3;      // z1 + z5 + z3 + z7
-   z[-3] = y1 - y3;      // z1 + z5 - z3 - z7
-   z[-5] = k11 - k22;    // z1 - z5 + z2 - z6
-   z[-7] = k11 + k22;    // z1 - z5 - z2 + z6
-}
-
-static void stbv_imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
-{
-   int a_off = base_n >> 3;
-   float A2 = A[0+a_off];
-   float *z = e + i_off;
-   float *base = z - 16 * n;
-
-   while (z > base) {
-      float k00,k11;
-
-      k00   = z[-0] - z[-8];
-      k11   = z[-1] - z[-9];
-      z[-0] = z[-0] + z[-8];
-      z[-1] = z[-1] + z[-9];
-      z[-8] =  k00;
-      z[-9] =  k11 ;
-
-      k00    = z[ -2] - z[-10];
-      k11    = z[ -3] - z[-11];
-      z[ -2] = z[ -2] + z[-10];
-      z[ -3] = z[ -3] + z[-11];
-      z[-10] = (k00+k11) * A2;
-      z[-11] = (k11-k00) * A2;
-
-      k00    = z[-12] - z[ -4];  // reverse to avoid a unary negation
-      k11    = z[ -5] - z[-13];
-      z[ -4] = z[ -4] + z[-12];
-      z[ -5] = z[ -5] + z[-13];
-      z[-12] = k11;
-      z[-13] = k00;
-
-      k00    = z[-14] - z[ -6];  // reverse to avoid a unary negation
-      k11    = z[ -7] - z[-15];
-      z[ -6] = z[ -6] + z[-14];
-      z[ -7] = z[ -7] + z[-15];
-      z[-14] = (k00+k11) * A2;
-      z[-15] = (k00-k11) * A2;
-
-      stbv_iter_54(z);
-      stbv_iter_54(z-8);
-      z -= 16;
-   }
-}
-
-static void stbv_inverse_mdct(float *buffer, int n, stbv_vorb *f, int blocktype)
-{
-   int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
-   int ld;
-   // @OPTIMIZE: reduce register pressure by using fewer variables?
-   int save_point = stbv_temp_alloc_save(f);
-   float *buf2 = (float *) stbv_temp_alloc(f, n2 * sizeof(*buf2));
-   float *u=NULL,*v=NULL;
-   // twiddle factors
-   float *A = f->A[blocktype];
-
-   // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
-   // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function.
-
-   // kernel from paper
-
-
-   // merged:
-   //   copy and reflect spectral data
-   //   step 0
-
-   // note that it turns out that the items added together during
-   // this step are, in fact, being added to themselves (as reflected
-   // by step 0). inexplicable inefficiency! this became obvious
-   // once I combined the passes.
-
-   // so there's a missing 'times 2' here (for adding X to itself).
-   // this propogates through linearly to the end, where the numbers
-   // are 1/2 too small, and need to be compensated for.
-
-   {
-      float *d,*e, *AA, *e_stop;
-      d = &buf2[n2-2];
-      AA = A;
-      e = &buffer[0];
-      e_stop = &buffer[n2];
-      while (e != e_stop) {
-         d[1] = (e[0] * AA[0] - e[2]*AA[1]);
-         d[0] = (e[0] * AA[1] + e[2]*AA[0]);
-         d -= 2;
-         AA += 2;
-         e += 4;
-      }
-
-      e = &buffer[n2-3];
-      while (d >= buf2) {
-         d[1] = (-e[2] * AA[0] - -e[0]*AA[1]);
-         d[0] = (-e[2] * AA[1] + -e[0]*AA[0]);
-         d -= 2;
-         AA += 2;
-         e -= 4;
-      }
-   }
-
-   // now we use symbolic names for these, so that we can
-   // possibly swap their meaning as we change which operations
-   // are in place
-
-   u = buffer;
-   v = buf2;
-
-   // step 2    (paper output is w, now u)
-   // this could be in place, but the data ends up in the wrong
-   // place... _somebody_'s got to swap it, so this is nominated
-   {
-      float *AA = &A[n2-8];
-      float *d0,*d1, *e0, *e1;
-
-      e0 = &v[n4];
-      e1 = &v[0];
-
-      d0 = &u[n4];
-      d1 = &u[0];
-
-      while (AA >= A) {
-         float v40_20, v41_21;
-
-         v41_21 = e0[1] - e1[1];
-         v40_20 = e0[0] - e1[0];
-         d0[1]  = e0[1] + e1[1];
-         d0[0]  = e0[0] + e1[0];
-         d1[1]  = v41_21*AA[4] - v40_20*AA[5];
-         d1[0]  = v40_20*AA[4] + v41_21*AA[5];
-
-         v41_21 = e0[3] - e1[3];
-         v40_20 = e0[2] - e1[2];
-         d0[3]  = e0[3] + e1[3];
-         d0[2]  = e0[2] + e1[2];
-         d1[3]  = v41_21*AA[0] - v40_20*AA[1];
-         d1[2]  = v40_20*AA[0] + v41_21*AA[1];
-
-         AA -= 8;
-
-         d0 += 4;
-         d1 += 4;
-         e0 += 4;
-         e1 += 4;
-      }
-   }
-
-   // step 3
-   ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-
-   // optimized step 3:
-
-   // the original step3 loop can be nested r inside s or s inside r;
-   // it's written originally as s inside r, but this is dumb when r
-   // iterates many times, and s few. So I have two copies of it and
-   // switch between them halfway.
-
-   // this is iteration 0 of step 3
-   stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
-   stbv_imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
-
-   // this is iteration 1 of step 3
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
-   stbv_imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
-
-   l=2;
-   for (; l < (ld-3)>>1; ++l) {
-      int k0 = n >> (l+2), k0_2 = k0>>1;
-      int lim = 1 << (l+1);
-      int i;
-      for (i=0; i < lim; ++i)
-         stbv_imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
-   }
-
-   for (; l < ld-6; ++l) {
-      int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1;
-      int rlim = n >> (l+6), r;
-      int lim = 1 << (l+1);
-      int i_off;
-      float *A0 = A;
-      i_off = n2-1;
-      for (r=rlim; r > 0; --r) {
-         stbv_imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
-         A0 += k1*4;
-         i_off -= 8;
-      }
-   }
-
-   // iterations with count:
-   //   ld-6,-5,-4 all interleaved together
-   //       the big win comes from getting rid of needless flops
-   //         due to the constants on pass 5 & 4 being all 1 and 0;
-   //       combining them to be simultaneous to improve cache made little difference
-   stbv_imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
-
-   // output is u
-
-   // step 4, 5, and 6
-   // cannot be in-place because of step 5
-   {
-      stbv_uint16 *bitrev = f->stbv_bit_reverse[blocktype];
-      // weirdly, I'd have thought reading sequentially and writing
-      // erratically would have been better than vice-versa, but in
-      // fact that's not what my testing showed. (That is, with
-      // j = bitreverse(i), do you read i and write j, or read j and write i.)
-
-      float *d0 = &v[n4-4];
-      float *d1 = &v[n2-4];
-      while (d0 >= v) {
-         int k4;
-
-         k4 = bitrev[0];
-         d1[3] = u[k4+0];
-         d1[2] = u[k4+1];
-         d0[3] = u[k4+2];
-         d0[2] = u[k4+3];
-
-         k4 = bitrev[1];
-         d1[1] = u[k4+0];
-         d1[0] = u[k4+1];
-         d0[1] = u[k4+2];
-         d0[0] = u[k4+3];
-         
-         d0 -= 4;
-         d1 -= 4;
-         bitrev += 2;
-      }
-   }
-   // (paper output is u, now v)
-
-
-   // data must be in buf2
-   assert(v == buf2);
-
-   // step 7   (paper output is v, now v)
-   // this is now in place
-   {
-      float *C = f->C[blocktype];
-      float *d, *e;
-
-      d = v;
-      e = v + n2 - 4;
-
-      while (d < e) {
-         float a02,a11,b0,b1,b2,b3;
-
-         a02 = d[0] - e[2];
-         a11 = d[1] + e[3];
-
-         b0 = C[1]*a02 + C[0]*a11;
-         b1 = C[1]*a11 - C[0]*a02;
-
-         b2 = d[0] + e[ 2];
-         b3 = d[1] - e[ 3];
-
-         d[0] = b2 + b0;
-         d[1] = b3 + b1;
-         e[2] = b2 - b0;
-         e[3] = b1 - b3;
-
-         a02 = d[2] - e[0];
-         a11 = d[3] + e[1];
-
-         b0 = C[3]*a02 + C[2]*a11;
-         b1 = C[3]*a11 - C[2]*a02;
-
-         b2 = d[2] + e[ 0];
-         b3 = d[3] - e[ 1];
-
-         d[2] = b2 + b0;
-         d[3] = b3 + b1;
-         e[0] = b2 - b0;
-         e[1] = b1 - b3;
-
-         C += 4;
-         d += 4;
-         e -= 4;
-      }
-   }
-
-   // data must be in buf2
-
-
-   // step 8+decode   (paper output is X, now buffer)
-   // this generates pairs of data a la 8 and pushes them directly through
-   // the decode kernel (pushing rather than pulling) to avoid having
-   // to make another pass later
-
-   // this cannot POSSIBLY be in place, so we refer to the buffers directly
-
-   {
-      float *d0,*d1,*d2,*d3;
-
-      float *B = f->B[blocktype] + n2 - 8;
-      float *e = buf2 + n2 - 8;
-      d0 = &buffer[0];
-      d1 = &buffer[n2-4];
-      d2 = &buffer[n2];
-      d3 = &buffer[n-4];
-      while (e >= v) {
-         float p0,p1,p2,p3;
-
-         p3 =  e[6]*B[7] - e[7]*B[6];
-         p2 = -e[6]*B[6] - e[7]*B[7]; 
-
-         d0[0] =   p3;
-         d1[3] = - p3;
-         d2[0] =   p2;
-         d3[3] =   p2;
-
-         p1 =  e[4]*B[5] - e[5]*B[4];
-         p0 = -e[4]*B[4] - e[5]*B[5]; 
-
-         d0[1] =   p1;
-         d1[2] = - p1;
-         d2[1] =   p0;
-         d3[2] =   p0;
-
-         p3 =  e[2]*B[3] - e[3]*B[2];
-         p2 = -e[2]*B[2] - e[3]*B[3]; 
-
-         d0[2] =   p3;
-         d1[1] = - p3;
-         d2[2] =   p2;
-         d3[1] =   p2;
-
-         p1 =  e[0]*B[1] - e[1]*B[0];
-         p0 = -e[0]*B[0] - e[1]*B[1]; 
-
-         d0[3] =   p1;
-         d1[0] = - p1;
-         d2[3] =   p0;
-         d3[0] =   p0;
-
-         B -= 8;
-         e -= 8;
-         d0 += 4;
-         d2 += 4;
-         d1 -= 4;
-         d3 -= 4;
-      }
-   }
-
-   stbv_temp_free(f,buf2);
-   stbv_temp_alloc_restore(f,save_point);
-}
-
-#if 0
-// this is the original version of the above code, if you want to optimize it from scratch
-void inverse_mdct_naive(float *buffer, int n)
-{
-   float s;
-   float A[1 << 12], B[1 << 12], C[1 << 11];
-   int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
-   int n3_4 = n - n4, ld;
-   // how can they claim this only uses N words?!
-   // oh, because they're only used sparsely, whoops
-   float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13];
-   // set up twiddle factors
-
-   for (k=k2=0; k < n4; ++k,k2+=2) {
-      A[k2  ] = (float)  cos(4*k*M_PI/n);
-      A[k2+1] = (float) -sin(4*k*M_PI/n);
-      B[k2  ] = (float)  cos((k2+1)*M_PI/n/2);
-      B[k2+1] = (float)  sin((k2+1)*M_PI/n/2);
-   }
-   for (k=k2=0; k < n8; ++k,k2+=2) {
-      C[k2  ] = (float)  cos(2*(k2+1)*M_PI/n);
-      C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
-   }
-
-   // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
-   // Note there are bugs in that pseudocode, presumably due to them attempting
-   // to rename the arrays nicely rather than representing the way their actual
-   // implementation bounces buffers back and forth. As a result, even in the
-   // "some formulars corrected" version, a direct implementation fails. These
-   // are noted below as "paper bug".
-
-   // copy and reflect spectral data
-   for (k=0; k < n2; ++k) u[k] = buffer[k];
-   for (   ; k < n ; ++k) u[k] = -buffer[n - k - 1];
-   // kernel from paper
-   // step 1
-   for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) {
-      v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2]   - (u[k4+2] - u[n-k4-3])*A[k2+1];
-      v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2];
-   }
-   // step 2
-   for (k=k4=0; k < n8; k+=1, k4+=4) {
-      w[n2+3+k4] = v[n2+3+k4] + v[k4+3];
-      w[n2+1+k4] = v[n2+1+k4] + v[k4+1];
-      w[k4+3]    = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4];
-      w[k4+1]    = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4];
-   }
-   // step 3
-   ld = stbv_ilog(n) - 1; // stbv_ilog is off-by-one from normal definitions
-   for (l=0; l < ld-3; ++l) {
-      int k0 = n >> (l+2), k1 = 1 << (l+3);
-      int rlim = n >> (l+4), r4, r;
-      int s2lim = 1 << (l+2), s2;
-      for (r=r4=0; r < rlim; r4+=4,++r) {
-         for (s2=0; s2 < s2lim; s2+=2) {
-            u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4];
-            u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4];
-            u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1]
-                                - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1];
-            u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1]
-                                + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1];
-         }
-      }
-      if (l+1 < ld-3) {
-         // paper bug: ping-ponging of u&w here is omitted
-         memcpy(w, u, sizeof(u));
-      }
-   }
-
-   // step 4
-   for (i=0; i < n8; ++i) {
-      int j = stbv_bit_reverse(i) >> (32-ld+3);
-      assert(j < n8);
-      if (i == j) {
-         // paper bug: original code probably swapped in place; if copying,
-         //            need to directly copy in this case
-         int i8 = i << 3;
-         v[i8+1] = u[i8+1];
-         v[i8+3] = u[i8+3];
-         v[i8+5] = u[i8+5];
-         v[i8+7] = u[i8+7];
-      } else if (i < j) {
-         int i8 = i << 3, j8 = j << 3;
-         v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1];
-         v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3];
-         v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5];
-         v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7];
-      }
-   }
-   // step 5
-   for (k=0; k < n2; ++k) {
-      w[k] = v[k*2+1];
-   }
-   // step 6
-   for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) {
-      u[n-1-k2] = w[k4];
-      u[n-2-k2] = w[k4+1];
-      u[n3_4 - 1 - k2] = w[k4+2];
-      u[n3_4 - 2 - k2] = w[k4+3];
-   }
-   // step 7
-   for (k=k2=0; k < n8; ++k, k2 += 2) {
-      v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
-      v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
-      v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
-      v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
-   }
-   // step 8
-   for (k=k2=0; k < n4; ++k,k2 += 2) {
-      X[k]      = v[k2+n2]*B[k2  ] + v[k2+1+n2]*B[k2+1];
-      X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2  ];
-   }
-
-   // decode kernel to output
-   // determined the following value experimentally
-   // (by first figuring out what made inverse_mdct_slow work); then matching that here
-   // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?)
-   s = 0.5; // theoretically would be n4
-
-   // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code,
-   //     so it needs to use the "old" B values to behave correctly, or else
-   //     set s to 1.0 ]]]
-   for (i=0; i < n4  ; ++i) buffer[i] = s * X[i+n4];
-   for (   ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1];
-   for (   ; i < n   ; ++i) buffer[i] = -s * X[i - n3_4];
-}
-#endif
-
-static float *stbv_get_window(stbv_vorb *f, int len)
-{
-   len <<= 1;
-   if (len == f->blocksize_0) return f->window[0];
-   if (len == f->blocksize_1) return f->window[1];
-   assert(0);
-   return NULL;
-}
-
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-typedef stbv_int16 STBV_YTYPE;
-#else
-typedef int STBV_YTYPE;
-#endif
-static int stbv_do_floor(stbv_vorb *f, StbvMapping *map, int i, int n, float *target, STBV_YTYPE *finalY, stbv_uint8 *step2_flag)
-{
-   int n2 = n >> 1;
-   int s = map->chan[i].mux, floor;
-   floor = map->submap_floor[s];
-   if (f->floor_types[floor] == 0) {
-      return stbv_error(f, VORBIS_invalid_stream);
-   } else {
-      StbvFloor1 *g = &f->floor_config[floor].floor1;
-      int j,q;
-      int lx = 0, ly = finalY[0] * g->floor1_multiplier;
-      for (q=1; q < g->values; ++q) {
-         j = g->sorted_order[q];
-         #ifndef STB_VORBIS_NO_DEFER_FLOOR
-         if (finalY[j] >= 0)
-         #else
-         if (step2_flag[j])
-         #endif
-         {
-            int hy = finalY[j] * g->floor1_multiplier;
-            int hx = g->Xlist[j];
-            if (lx != hx)
-               stbv_draw_line(target, lx,ly, hx,hy, n2);
-            STBV_CHECK(f);
-            lx = hx, ly = hy;
-         }
-      }
-      if (lx < n2) {
-         // optimization of: stbv_draw_line(target, lx,ly, n,ly, n2);
-         for (j=lx; j < n2; ++j)
-            STBV_LINE_OP(target[j], stbv_inverse_db_table[ly]);
-         STBV_CHECK(f);
-      }
-   }
-   return TRUE;
-}
-
-// The meaning of "left" and "right"
-//
-// For a given frame:
-//     we compute samples from 0..n
-//     window_center is n/2
-//     we'll window and mix the samples from left_start to left_end with data from the previous frame
-//     all of the samples from left_end to right_start can be output without mixing; however,
-//        this interval is 0-length except when transitioning between short and long frames
-//     all of the samples from right_start to right_end need to be mixed with the next frame,
-//        which we don't have, so those get saved in a buffer
-//     frame N's right_end-right_start, the number of samples to mix with the next frame,
-//        has to be the same as frame N+1's left_end-left_start (which they are by
-//        construction)
-
-static int stbv_vorbis_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
-{
-   StbvMode *m;
-   int i, n, prev, next, window_center;
-   f->channel_buffer_start = f->channel_buffer_end = 0;
-
-  retry:
-   if (f->eof) return FALSE;
-   if (!stbv_maybe_start_packet(f))
-      return FALSE;
-   // check packet type
-   if (stbv_get_bits(f,1) != 0) {
-      if (STBV_IS_PUSH_MODE(f))
-         return stbv_error(f,VORBIS_bad_packet_type);
-      while (STBV_EOP != stbv_get8_packet(f));
-      goto retry;
-   }
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-
-   i = stbv_get_bits(f, stbv_ilog(f->mode_count-1));
-   if (i == STBV_EOP) return FALSE;
-   if (i >= f->mode_count) return FALSE;
-   *mode = i;
-   m = f->mode_config + i;
-   if (m->blockflag) {
-      n = f->blocksize_1;
-      prev = stbv_get_bits(f,1);
-      next = stbv_get_bits(f,1);
-   } else {
-      prev = next = 0;
-      n = f->blocksize_0;
-   }
-
-// WINDOWING
-
-   window_center = n >> 1;
-   if (m->blockflag && !prev) {
-      *p_left_start = (n - f->blocksize_0) >> 2;
-      *p_left_end   = (n + f->blocksize_0) >> 2;
-   } else {
-      *p_left_start = 0;
-      *p_left_end   = window_center;
-   }
-   if (m->blockflag && !next) {
-      *p_right_start = (n*3 - f->blocksize_0) >> 2;
-      *p_right_end   = (n*3 + f->blocksize_0) >> 2;
-   } else {
-      *p_right_start = window_center;
-      *p_right_end   = n;
-   }
-
-   return TRUE;
-}
-
-static int stbv_vorbis_decode_packet_rest(stbv_vorb *f, int *len, StbvMode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
-{
-   StbvMapping *map;
-   int i,j,k,n,n2;
-   int zero_channel[256];
-   int really_zero_channel[256];
-
-// WINDOWING
-
-   n = f->blocksize[m->blockflag];
-   map = &f->mapping[m->mapping];
-
-// FLOORS
-   n2 = n >> 1;
-
-   STBV_CHECK(f);
-
-   for (i=0; i < f->channels; ++i) {
-      int s = map->chan[i].mux, floor;
-      zero_channel[i] = FALSE;
-      floor = map->submap_floor[s];
-      if (f->floor_types[floor] == 0) {
-         return stbv_error(f, VORBIS_invalid_stream);
-      } else {
-         StbvFloor1 *g = &f->floor_config[floor].floor1;
-         if (stbv_get_bits(f, 1)) {
-            short *finalY;
-            stbv_uint8 step2_flag[256];
-            static int range_list[4] = { 256, 128, 86, 64 };
-            int range = range_list[g->floor1_multiplier-1];
-            int offset = 2;
-            finalY = f->finalY[i];
-            finalY[0] = stbv_get_bits(f, stbv_ilog(range)-1);
-            finalY[1] = stbv_get_bits(f, stbv_ilog(range)-1);
-            for (j=0; j < g->partitions; ++j) {
-               int pclass = g->partition_class_list[j];
-               int cdim = g->class_dimensions[pclass];
-               int cbits = g->class_subclasses[pclass];
-               int csub = (1 << cbits)-1;
-               int cval = 0;
-               if (cbits) {
-                  StbvCodebook *c = f->codebooks + g->class_masterbooks[pclass];
-                  STBV_DECODE(cval,f,c);
-               }
-               for (k=0; k < cdim; ++k) {
-                  int book = g->subclass_books[pclass][cval & csub];
-                  cval = cval >> cbits;
-                  if (book >= 0) {
-                     int temp;
-                     StbvCodebook *c = f->codebooks + book;
-                     STBV_DECODE(temp,f,c);
-                     finalY[offset++] = temp;
-                  } else
-                     finalY[offset++] = 0;
-               }
-            }
-            if (f->valid_bits == STBV_INVALID_BITS) goto error; // behavior according to spec
-            step2_flag[0] = step2_flag[1] = 1;
-            for (j=2; j < g->values; ++j) {
-               int low, high, pred, highroom, lowroom, room, val;
-               low = g->stbv_neighbors[j][0];
-               high = g->stbv_neighbors[j][1];
-               //stbv_neighbors(g->Xlist, j, &low, &high);
-               pred = stbv_predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
-               val = finalY[j];
-               highroom = range - pred;
-               lowroom = pred;
-               if (highroom < lowroom)
-                  room = highroom * 2;
-               else
-                  room = lowroom * 2;
-               if (val) {
-                  step2_flag[low] = step2_flag[high] = 1;
-                  step2_flag[j] = 1;
-                  if (val >= room)
-                     if (highroom > lowroom)
-                        finalY[j] = val - lowroom + pred;
-                     else
-                        finalY[j] = pred - val + highroom - 1;
-                  else
-                     if (val & 1)
-                        finalY[j] = pred - ((val+1)>>1);
-                     else
-                        finalY[j] = pred + (val>>1);
-               } else {
-                  step2_flag[j] = 0;
-                  finalY[j] = pred;
-               }
-            }
-
-#ifdef STB_VORBIS_NO_DEFER_FLOOR
-            stbv_do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
-#else
-            // defer final floor computation until _after_ residue
-            for (j=0; j < g->values; ++j) {
-               if (!step2_flag[j])
-                  finalY[j] = -1;
-            }
-#endif
-         } else {
-           error:
-            zero_channel[i] = TRUE;
-         }
-         // So we just defer everything else to later
-
-         // at this point we've decoded the floor into buffer
-      }
-   }
-   STBV_CHECK(f);
-   // at this point we've decoded all floors
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-
-   // re-enable coupled channels if necessary
-   memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels);
-   for (i=0; i < map->coupling_steps; ++i)
-      if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) {
-         zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
-      }
-
-   STBV_CHECK(f);
-// RESIDUE STBV_DECODE
-   for (i=0; i < map->submaps; ++i) {
-      float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
-      int r;
-      stbv_uint8 do_not_decode[256];
-      int ch = 0;
-      for (j=0; j < f->channels; ++j) {
-         if (map->chan[j].mux == i) {
-            if (zero_channel[j]) {
-               do_not_decode[ch] = TRUE;
-               residue_buffers[ch] = NULL;
-            } else {
-               do_not_decode[ch] = FALSE;
-               residue_buffers[ch] = f->channel_buffers[j];
-            }
-            ++ch;
-         }
-      }
-      r = map->submap_residue[i];
-      stbv_decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
-   }
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-   STBV_CHECK(f);
-
-// INVERSE COUPLING
-   for (i = map->coupling_steps-1; i >= 0; --i) {
-      int n2 = n >> 1;
-      float *m = f->channel_buffers[map->chan[i].magnitude];
-      float *a = f->channel_buffers[map->chan[i].angle    ];
-      for (j=0; j < n2; ++j) {
-         float a2,m2;
-         if (m[j] > 0)
-            if (a[j] > 0)
-               m2 = m[j], a2 = m[j] - a[j];
-            else
-               a2 = m[j], m2 = m[j] + a[j];
-         else
-            if (a[j] > 0)
-               m2 = m[j], a2 = m[j] + a[j];
-            else
-               a2 = m[j], m2 = m[j] - a[j];
-         m[j] = m2;
-         a[j] = a2;
-      }
-   }
-   STBV_CHECK(f);
-
-   // finish decoding the floors
-#ifndef STB_VORBIS_NO_DEFER_FLOOR
-   for (i=0; i < f->channels; ++i) {
-      if (really_zero_channel[i]) {
-         memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
-      } else {
-         stbv_do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
-      }
-   }
-#else
-   for (i=0; i < f->channels; ++i) {
-      if (really_zero_channel[i]) {
-         memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
-      } else {
-         for (j=0; j < n2; ++j)
-            f->channel_buffers[i][j] *= f->floor_buffers[i][j];
-      }
-   }
-#endif
-
-// INVERSE MDCT
-   STBV_CHECK(f);
-   for (i=0; i < f->channels; ++i)
-      stbv_inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
-   STBV_CHECK(f);
-
-   // this shouldn't be necessary, unless we exited on an error
-   // and want to flush to get to the next packet
-   stbv_flush_packet(f);
-
-   if (f->first_decode) {
-      // assume we start so first non-discarded sample is sample 0
-      // this isn't to spec, but spec would require us to read ahead
-      // and decode the size of all current frames--could be done,
-      // but presumably it's not a commonly used feature
-      f->current_loc = -n2; // start of first frame is positioned for discard
-      // we might have to discard samples "from" the next frame too,
-      // if we're lapping a large block then a small at the start?
-      f->discard_samples_deferred = n - right_end;
-      f->current_loc_valid = TRUE;
-      f->first_decode = FALSE;
-   } else if (f->discard_samples_deferred) {
-      if (f->discard_samples_deferred >= right_start - left_start) {
-         f->discard_samples_deferred -= (right_start - left_start);
-         left_start = right_start;
-         *p_left = left_start;
-      } else {
-         left_start += f->discard_samples_deferred;
-         *p_left = left_start;
-         f->discard_samples_deferred = 0;
-      }
-   } else if (f->previous_length == 0 && f->current_loc_valid) {
-      // we're recovering from a seek... that means we're going to discard
-      // the samples from this packet even though we know our position from
-      // the last page header, so we need to update the position based on
-      // the discarded samples here
-      // but wait, the code below is going to add this in itself even
-      // on a discard, so we don't need to do it here...
-   }
-
-   // check if we have ogg information about the sample # for this packet
-   if (f->last_seg_which == f->end_seg_with_known_loc) {
-      // if we have a valid current loc, and this is final:
-      if (f->current_loc_valid && (f->page_flag & STBV_PAGEFLAG_last_page)) {
-         stbv_uint32 current_end = f->known_loc_for_packet;
-         // then let's infer the size of the (probably) short final frame
-         if (current_end < f->current_loc + (right_end-left_start)) {
-            if (current_end < f->current_loc) {
-               // negative truncation, that's impossible!
-               *len = 0;
-            } else {
-               *len = current_end - f->current_loc;
-            }
-            *len += left_start; // this doesn't seem right, but has no ill effect on my test files
-            if (*len > right_end) *len = right_end; // this should never happen
-            f->current_loc += *len;
-            return TRUE;
-         }
-      }
-      // otherwise, just set our sample loc
-      // guess that the ogg granule pos refers to the _middle_ of the
-      // last frame?
-      // set f->current_loc to the position of left_start
-      f->current_loc = f->known_loc_for_packet - (n2-left_start);
-      f->current_loc_valid = TRUE;
-   }
-   if (f->current_loc_valid)
-      f->current_loc += (right_start - left_start);
-
-   if (f->alloc.alloc_buffer)
-      assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
-   *len = right_end;  // ignore samples after the window goes to 0
-   STBV_CHECK(f);
-
-   return TRUE;
-}
-
-static int stbv_vorbis_decode_packet(stbv_vorb *f, int *len, int *p_left, int *p_right)
-{
-   int mode, left_end, right_end;
-   if (!stbv_vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
-   return stbv_vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
-}
-
-static int stbv_vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
-{
-   int prev,i,j;
-   // we use right&left (the start of the right- and left-window sin()-regions)
-   // to determine how much to return, rather than inferring from the rules
-   // (same result, clearer code); 'left' indicates where our sin() window
-   // starts, therefore where the previous window's right edge starts, and
-   // therefore where to start mixing from the previous buffer. 'right'
-   // indicates where our sin() ending-window starts, therefore that's where
-   // we start saving, and where our returned-data ends.
-
-   // mixin from previous window
-   if (f->previous_length) {
-      int i,j, n = f->previous_length;
-      float *w = stbv_get_window(f, n);
-      for (i=0; i < f->channels; ++i) {
-         for (j=0; j < n; ++j)
-            f->channel_buffers[i][left+j] =
-               f->channel_buffers[i][left+j]*w[    j] +
-               f->previous_window[i][     j]*w[n-1-j];
-      }
-   }
-
-   prev = f->previous_length;
-
-   // last half of this data becomes previous window
-   f->previous_length = len - right;
-
-   // @OPTIMIZE: could avoid this copy by double-buffering the
-   // output (flipping previous_window with channel_buffers), but
-   // then previous_window would have to be 2x as large, and
-   // channel_buffers couldn't be temp mem (although they're NOT
-   // currently temp mem, they could be (unless we want to level
-   // performance by spreading out the computation))
-   for (i=0; i < f->channels; ++i)
-      for (j=0; right+j < len; ++j)
-         f->previous_window[i][j] = f->channel_buffers[i][right+j];
-
-   if (!prev)
-      // there was no previous packet, so this data isn't valid...
-      // this isn't entirely true, only the would-have-overlapped data
-      // isn't valid, but this seems to be what the spec requires
-      return 0;
-
-   // truncate a short frame
-   if (len < right) right = len;
-
-   f->samples_output += right-left;
-
-   return right - left;
-}
-
-static int stbv_vorbis_pump_first_frame(stb_vorbis *f)
-{
-   int len, right, left, res;
-   res = stbv_vorbis_decode_packet(f, &len, &left, &right);
-   if (res)
-      stbv_vorbis_finish_frame(f, len, left, right);
-   return res;
-}
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-static int stbv_is_whole_packet_present(stb_vorbis *f, int end_page)
-{
-   // make sure that we have the packet available before continuing...
-   // this requires a full ogg parse, but we know we can fetch from f->stream
-
-   // instead of coding this out explicitly, we could save the current read state,
-   // read the next packet with stbv_get8() until end-of-packet, check f->eof, then
-   // reset the state? but that would be slower, esp. since we'd have over 256 bytes
-   // of state to restore (primarily the page segment table)
-
-   int s = f->next_seg, first = TRUE;
-   stbv_uint8 *p = f->stream;
-
-   if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag
-      for (; s < f->segment_count; ++s) {
-         p += f->segments[s];
-         if (f->segments[s] < 255)               // stop at first short segment
-            break;
-      }
-      // either this continues, or it ends it...
-      if (end_page)
-         if (s < f->segment_count-1)             return stbv_error(f, VORBIS_invalid_stream);
-      if (s == f->segment_count)
-         s = -1; // set 'crosses page' flag
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      first = FALSE;
-   }
-   for (; s == -1;) {
-      stbv_uint8 *q; 
-      int n;
-
-      // check that we have the page header ready
-      if (p + 26 >= f->stream_end)               return stbv_error(f, VORBIS_need_more_data);
-      // validate the page
-      if (memcmp(p, stbv_ogg_page_header, 4))         return stbv_error(f, VORBIS_invalid_stream);
-      if (p[4] != 0)                             return stbv_error(f, VORBIS_invalid_stream);
-      if (first) { // the first segment must NOT have 'continued_packet', later ones MUST
-         if (f->previous_length)
-            if ((p[5] & STBV_PAGEFLAG_continued_packet))  return stbv_error(f, VORBIS_invalid_stream);
-         // if no previous length, we're resynching, so we can come in on a continued-packet,
-         // which we'll just drop
-      } else {
-         if (!(p[5] & STBV_PAGEFLAG_continued_packet)) return stbv_error(f, VORBIS_invalid_stream);
-      }
-      n = p[26]; // segment counts
-      q = p+27;  // q points to segment table
-      p = q + n; // advance past header
-      // make sure we've read the segment table
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      for (s=0; s < n; ++s) {
-         p += q[s];
-         if (q[s] < 255)
-            break;
-      }
-      if (end_page)
-         if (s < n-1)                            return stbv_error(f, VORBIS_invalid_stream);
-      if (s == n)
-         s = -1; // set 'crosses page' flag
-      if (p > f->stream_end)                     return stbv_error(f, VORBIS_need_more_data);
-      first = FALSE;
-   }
-   return TRUE;
-}
-#endif // !STB_VORBIS_NO_PUSHDATA_API
-
-static int stbv_start_decoder(stbv_vorb *f)
-{
-   stbv_uint8 header[6], x,y;
-   int len,i,j,k, max_submaps = 0;
-   int longest_floorlist=0;
-
-   // first page, first packet
-
-   if (!stbv_start_page(f))                              return FALSE;
-   // validate page flag
-   if (!(f->page_flag & STBV_PAGEFLAG_first_page))       return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->page_flag & STBV_PAGEFLAG_last_page)           return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->page_flag & STBV_PAGEFLAG_continued_packet)    return stbv_error(f, VORBIS_invalid_first_page);
-   // check for expected packet length
-   if (f->segment_count != 1)                       return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->segments[0] != 30)                        return stbv_error(f, VORBIS_invalid_first_page);
-   // read packet
-   // check packet header
-   if (stbv_get8(f) != STBV_VORBIS_packet_id)                 return stbv_error(f, VORBIS_invalid_first_page);
-   if (!stbv_getn(f, header, 6))                         return stbv_error(f, VORBIS_unexpected_eof);
-   if (!stbv_vorbis_validate(header))                    return stbv_error(f, VORBIS_invalid_first_page);
-   // vorbis_version
-   if (stbv_get32(f) != 0)                               return stbv_error(f, VORBIS_invalid_first_page);
-   f->channels = stbv_get8(f); if (!f->channels)         return stbv_error(f, VORBIS_invalid_first_page);
-   if (f->channels > STB_VORBIS_MAX_CHANNELS)       return stbv_error(f, VORBIS_too_many_channels);
-   f->sample_rate = stbv_get32(f); if (!f->sample_rate)  return stbv_error(f, VORBIS_invalid_first_page);
-   stbv_get32(f); // bitrate_maximum
-   stbv_get32(f); // bitrate_nominal
-   stbv_get32(f); // bitrate_minimum
-   x = stbv_get8(f);
-   {
-      int log0,log1;
-      log0 = x & 15;
-      log1 = x >> 4;
-      f->blocksize_0 = 1 << log0;
-      f->blocksize_1 = 1 << log1;
-      if (log0 < 6 || log0 > 13)                       return stbv_error(f, VORBIS_invalid_setup);
-      if (log1 < 6 || log1 > 13)                       return stbv_error(f, VORBIS_invalid_setup);
-      if (log0 > log1)                                 return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   // framing_flag
-   x = stbv_get8(f);
-   if (!(x & 1))                                    return stbv_error(f, VORBIS_invalid_first_page);
-
-   // second packet!
-   if (!stbv_start_page(f))                              return FALSE;
-
-   if (!stbv_start_packet(f))                            return FALSE;
-   do {
-      len = stbv_next_segment(f);
-      stbv_skip(f, len);
-      f->bytes_in_seg = 0;
-   } while (len);
-
-   // third packet!
-   if (!stbv_start_packet(f))                            return FALSE;
-
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (STBV_IS_PUSH_MODE(f)) {
-      if (!stbv_is_whole_packet_present(f, TRUE)) {
-         // convert error in ogg header to write type
-         if (f->error == VORBIS_invalid_stream)
-            f->error = VORBIS_invalid_setup;
-         return FALSE;
-      }
-   }
-   #endif
-
-   stbv_crc32_init(); // always init it, to avoid multithread race conditions
-
-   if (stbv_get8_packet(f) != STBV_VORBIS_packet_setup)       return stbv_error(f, VORBIS_invalid_setup);
-   for (i=0; i < 6; ++i) header[i] = stbv_get8_packet(f);
-   if (!stbv_vorbis_validate(header))                    return stbv_error(f, VORBIS_invalid_setup);
-
-   // codebooks
-
-   f->codebook_count = stbv_get_bits(f,8) + 1;
-   f->codebooks = (StbvCodebook *) stbv_setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
-   if (f->codebooks == NULL)                        return stbv_error(f, VORBIS_outofmem);
-   memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
-   for (i=0; i < f->codebook_count; ++i) {
-      stbv_uint32 *values;
-      int ordered, sorted_count;
-      int total=0;
-      stbv_uint8 *lengths;
-      StbvCodebook *c = f->codebooks+i;
-      STBV_CHECK(f);
-      x = stbv_get_bits(f, 8); if (x != 0x42)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8); if (x != 0x43)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8); if (x != 0x56)            return stbv_error(f, VORBIS_invalid_setup);
-      x = stbv_get_bits(f, 8);
-      c->dimensions = (stbv_get_bits(f, 8)<<8) + x;
-      x = stbv_get_bits(f, 8);
-      y = stbv_get_bits(f, 8);
-      c->entries = (stbv_get_bits(f, 8)<<16) + (y<<8) + x;
-      ordered = stbv_get_bits(f,1);
-      c->sparse = ordered ? 0 : stbv_get_bits(f,1);
-
-      if (c->dimensions == 0 && c->entries != 0)    return stbv_error(f, VORBIS_invalid_setup);
-
-      if (c->sparse)
-         lengths = (stbv_uint8 *) stbv_setup_temp_malloc(f, c->entries);
-      else
-         lengths = c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
-
-      if (!lengths) return stbv_error(f, VORBIS_outofmem);
-
-      if (ordered) {
-         int current_entry = 0;
-         int current_length = stbv_get_bits(f,5) + 1;
-         while (current_entry < c->entries) {
-            int limit = c->entries - current_entry;
-            int n = stbv_get_bits(f, stbv_ilog(limit));
-            if (current_entry + n > (int) c->entries) { return stbv_error(f, VORBIS_invalid_setup); }
-            memset(lengths + current_entry, current_length, n);
-            current_entry += n;
-            ++current_length;
-         }
-      } else {
-         for (j=0; j < c->entries; ++j) {
-            int present = c->sparse ? stbv_get_bits(f,1) : 1;
-            if (present) {
-               lengths[j] = stbv_get_bits(f, 5) + 1;
-               ++total;
-               if (lengths[j] == 32)
-                  return stbv_error(f, VORBIS_invalid_setup);
-            } else {
-               lengths[j] = NO_CODE;
-            }
-         }
-      }
-
-      if (c->sparse && total >= c->entries >> 2) {
-         // convert sparse items to non-sparse!
-         if (c->entries > (int) f->setup_temp_memory_required)
-            f->setup_temp_memory_required = c->entries;
-
-         c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->entries);
-         if (c->codeword_lengths == NULL) return stbv_error(f, VORBIS_outofmem);
-         memcpy(c->codeword_lengths, lengths, c->entries);
-         stbv_setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
-         lengths = c->codeword_lengths;
-         c->sparse = 0;
-      }
-
-      // compute the size of the sorted tables
-      if (c->sparse) {
-         sorted_count = total;
-      } else {
-         sorted_count = 0;
-         #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
-         for (j=0; j < c->entries; ++j)
-            if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
-               ++sorted_count;
-         #endif
-      }
-
-      c->sorted_entries = sorted_count;
-      values = NULL;
-
-      STBV_CHECK(f);
-      if (!c->sparse) {
-         c->codewords = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
-         if (!c->codewords)                  return stbv_error(f, VORBIS_outofmem);
-      } else {
-         unsigned int size;
-         if (c->sorted_entries) {
-            c->codeword_lengths = (stbv_uint8 *) stbv_setup_malloc(f, c->sorted_entries);
-            if (!c->codeword_lengths)           return stbv_error(f, VORBIS_outofmem);
-            c->codewords = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
-            if (!c->codewords)                  return stbv_error(f, VORBIS_outofmem);
-            values = (stbv_uint32 *) stbv_setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
-            if (!values)                        return stbv_error(f, VORBIS_outofmem);
-         }
-         size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
-         if (size > f->setup_temp_memory_required)
-            f->setup_temp_memory_required = size;
-      }
-
-      if (!stbv_compute_codewords(c, lengths, c->entries, values)) {
-         if (c->sparse) stbv_setup_temp_free(f, values, 0);
-         return stbv_error(f, VORBIS_invalid_setup);
-      }
-
-      if (c->sorted_entries) {
-         // allocate an extra slot for sentinels
-         c->sorted_codewords = (stbv_uint32 *) stbv_setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
-         if (c->sorted_codewords == NULL) return stbv_error(f, VORBIS_outofmem);
-         // allocate an extra slot at the front so that c->sorted_values[-1] is defined
-         // so that we can catch that case without an extra if
-         c->sorted_values    = ( int   *) stbv_setup_malloc(f, sizeof(*c->sorted_values   ) * (c->sorted_entries+1));
-         if (c->sorted_values == NULL) return stbv_error(f, VORBIS_outofmem);
-         ++c->sorted_values;
-         c->sorted_values[-1] = -1;
-         stbv_compute_sorted_huffman(c, lengths, values);
-      }
-
-      if (c->sparse) {
-         stbv_setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
-         stbv_setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
-         stbv_setup_temp_free(f, lengths, c->entries);
-         c->codewords = NULL;
-      }
-
-      stbv_compute_accelerated_huffman(c);
-
-      STBV_CHECK(f);
-      c->lookup_type = stbv_get_bits(f, 4);
-      if (c->lookup_type > 2) return stbv_error(f, VORBIS_invalid_setup);
-      if (c->lookup_type > 0) {
-         stbv_uint16 *mults;
-         c->minimum_value = stbv_float32_unpack(stbv_get_bits(f, 32));
-         c->delta_value = stbv_float32_unpack(stbv_get_bits(f, 32));
-         c->value_bits = stbv_get_bits(f, 4)+1;
-         c->sequence_p = stbv_get_bits(f,1);
-         if (c->lookup_type == 1) {
-            c->lookup_values = stbv_lookup1_values(c->entries, c->dimensions);
-         } else {
-            c->lookup_values = c->entries * c->dimensions;
-         }
-         if (c->lookup_values == 0) return stbv_error(f, VORBIS_invalid_setup);
-         mults = (stbv_uint16 *) stbv_setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
-         if (mults == NULL) return stbv_error(f, VORBIS_outofmem);
-         for (j=0; j < (int) c->lookup_values; ++j) {
-            int q = stbv_get_bits(f, c->value_bits);
-            if (q == STBV_EOP) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_invalid_setup); }
-            mults[j] = q;
-         }
-
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-         if (c->lookup_type == 1) {
-            int len, sparse = c->sparse;
-            float last=0;
-            // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
-            if (sparse) {
-               if (c->sorted_entries == 0) goto stbv_skip;
-               c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
-            } else
-               c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries        * c->dimensions);
-            if (c->multiplicands == NULL) { stbv_setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
-            len = sparse ? c->sorted_entries : c->entries;
-            for (j=0; j < len; ++j) {
-               unsigned int z = sparse ? c->sorted_values[j] : j;
-               unsigned int div=1;
-               for (k=0; k < c->dimensions; ++k) {
-                  int off = (z / div) % c->lookup_values;
-                  float val = mults[off];
-                  val = mults[off]*c->delta_value + c->minimum_value + last;
-                  c->multiplicands[j*c->dimensions + k] = val;
-                  if (c->sequence_p)
-                     last = val;
-                  if (k+1 < c->dimensions) {
-                     if (div > UINT_MAX / (unsigned int) c->lookup_values) {
-                        stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
-                        return stbv_error(f, VORBIS_invalid_setup);
-                     }
-                     div *= c->lookup_values;
-                  }
-               }
-            }
-            c->lookup_type = 2;
-         }
-         else
-#endif
-         {
-            float last=0;
-            STBV_CHECK(f);
-            c->multiplicands = (stbv_codetype *) stbv_setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
-            if (c->multiplicands == NULL) { stbv_setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return stbv_error(f, VORBIS_outofmem); }
-            for (j=0; j < (int) c->lookup_values; ++j) {
-               float val = mults[j] * c->delta_value + c->minimum_value + last;
-               c->multiplicands[j] = val;
-               if (c->sequence_p)
-                  last = val;
-            }
-         }
-#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
-        stbv_skip:;
-#endif
-         stbv_setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
-
-         STBV_CHECK(f);
-      }
-      STBV_CHECK(f);
-   }
-
-   // time domain transfers (notused)
-
-   x = stbv_get_bits(f, 6) + 1;
-   for (i=0; i < x; ++i) {
-      stbv_uint32 z = stbv_get_bits(f, 16);
-      if (z != 0) return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   // Floors
-   f->floor_count = stbv_get_bits(f, 6)+1;
-   f->floor_config = (StbvFloor *)  stbv_setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
-   if (f->floor_config == NULL) return stbv_error(f, VORBIS_outofmem);
-   for (i=0; i < f->floor_count; ++i) {
-      f->floor_types[i] = stbv_get_bits(f, 16);
-      if (f->floor_types[i] > 1) return stbv_error(f, VORBIS_invalid_setup);
-      if (f->floor_types[i] == 0) {
-         StbvFloor0 *g = &f->floor_config[i].floor0;
-         g->order = stbv_get_bits(f,8);
-         g->rate = stbv_get_bits(f,16);
-         g->bark_map_size = stbv_get_bits(f,16);
-         g->amplitude_bits = stbv_get_bits(f,6);
-         g->amplitude_offset = stbv_get_bits(f,8);
-         g->number_of_books = stbv_get_bits(f,4) + 1;
-         for (j=0; j < g->number_of_books; ++j)
-            g->book_list[j] = stbv_get_bits(f,8);
-         return stbv_error(f, VORBIS_feature_not_supported);
-      } else {
-         stbv_floor_ordering p[31*8+2];
-         StbvFloor1 *g = &f->floor_config[i].floor1;
-         int max_class = -1; 
-         g->partitions = stbv_get_bits(f, 5);
-         for (j=0; j < g->partitions; ++j) {
-            g->partition_class_list[j] = stbv_get_bits(f, 4);
-            if (g->partition_class_list[j] > max_class)
-               max_class = g->partition_class_list[j];
-         }
-         for (j=0; j <= max_class; ++j) {
-            g->class_dimensions[j] = stbv_get_bits(f, 3)+1;
-            g->class_subclasses[j] = stbv_get_bits(f, 2);
-            if (g->class_subclasses[j]) {
-               g->class_masterbooks[j] = stbv_get_bits(f, 8);
-               if (g->class_masterbooks[j] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            }
-            for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
-               g->subclass_books[j][k] = stbv_get_bits(f,8)-1;
-               if (g->subclass_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            }
-         }
-         g->floor1_multiplier = stbv_get_bits(f,2)+1;
-         g->rangebits = stbv_get_bits(f,4);
-         g->Xlist[0] = 0;
-         g->Xlist[1] = 1 << g->rangebits;
-         g->values = 2;
-         for (j=0; j < g->partitions; ++j) {
-            int c = g->partition_class_list[j];
-            for (k=0; k < g->class_dimensions[c]; ++k) {
-               g->Xlist[g->values] = stbv_get_bits(f, g->rangebits);
-               ++g->values;
-            }
-         }
-         // precompute the sorting
-         for (j=0; j < g->values; ++j) {
-            p[j].x = g->Xlist[j];
-            p[j].id = j;
-         }
-         qsort(p, g->values, sizeof(p[0]), stbv_point_compare);
-         for (j=0; j < g->values; ++j)
-            g->sorted_order[j] = (stbv_uint8) p[j].id;
-         // precompute the stbv_neighbors
-         for (j=2; j < g->values; ++j) {
-            int low,hi;
-            stbv_neighbors(g->Xlist, j, &low,&hi);
-            g->stbv_neighbors[j][0] = low;
-            g->stbv_neighbors[j][1] = hi;
-         }
-
-         if (g->values > longest_floorlist)
-            longest_floorlist = g->values;
-      }
-   }
-
-   // StbvResidue
-   f->residue_count = stbv_get_bits(f, 6)+1;
-   f->residue_config = (StbvResidue *) stbv_setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
-   if (f->residue_config == NULL) return stbv_error(f, VORBIS_outofmem);
-   memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
-   for (i=0; i < f->residue_count; ++i) {
-      stbv_uint8 residue_cascade[64];
-      StbvResidue *r = f->residue_config+i;
-      f->residue_types[i] = stbv_get_bits(f, 16);
-      if (f->residue_types[i] > 2) return stbv_error(f, VORBIS_invalid_setup);
-      r->begin = stbv_get_bits(f, 24);
-      r->end = stbv_get_bits(f, 24);
-      if (r->end < r->begin) return stbv_error(f, VORBIS_invalid_setup);
-      r->part_size = stbv_get_bits(f,24)+1;
-      r->classifications = stbv_get_bits(f,6)+1;
-      r->classbook = stbv_get_bits(f,8);
-      if (r->classbook >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-      for (j=0; j < r->classifications; ++j) {
-         stbv_uint8 high_bits=0;
-         stbv_uint8 low_bits=stbv_get_bits(f,3);
-         if (stbv_get_bits(f,1))
-            high_bits = stbv_get_bits(f,5);
-         residue_cascade[j] = high_bits*8 + low_bits;
-      }
-      r->residue_books = (short (*)[8]) stbv_setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
-      if (r->residue_books == NULL) return stbv_error(f, VORBIS_outofmem);
-      for (j=0; j < r->classifications; ++j) {
-         for (k=0; k < 8; ++k) {
-            if (residue_cascade[j] & (1 << k)) {
-               r->residue_books[j][k] = stbv_get_bits(f, 8);
-               if (r->residue_books[j][k] >= f->codebook_count) return stbv_error(f, VORBIS_invalid_setup);
-            } else {
-               r->residue_books[j][k] = -1;
-            }
-         }
-      }
-      // precompute the classifications[] array to avoid inner-loop mod/divide
-      // call it 'classdata' since we already have r->classifications
-      r->classdata = (stbv_uint8 **) stbv_setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
-      if (!r->classdata) return stbv_error(f, VORBIS_outofmem);
-      memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
-      for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
-         int classwords = f->codebooks[r->classbook].dimensions;
-         int temp = j;
-         r->classdata[j] = (stbv_uint8 *) stbv_setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
-         if (r->classdata[j] == NULL) return stbv_error(f, VORBIS_outofmem);
-         for (k=classwords-1; k >= 0; --k) {
-            r->classdata[j][k] = temp % r->classifications;
-            temp /= r->classifications;
-         }
-      }
-   }
-
-   f->mapping_count = stbv_get_bits(f,6)+1;
-   f->mapping = (StbvMapping *) stbv_setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
-   if (f->mapping == NULL) return stbv_error(f, VORBIS_outofmem);
-   memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
-   for (i=0; i < f->mapping_count; ++i) {
-      StbvMapping *m = f->mapping + i;      
-      int mapping_type = stbv_get_bits(f,16);
-      if (mapping_type != 0) return stbv_error(f, VORBIS_invalid_setup);
-      m->chan = (StbvMappingChannel *) stbv_setup_malloc(f, f->channels * sizeof(*m->chan));
-      if (m->chan == NULL) return stbv_error(f, VORBIS_outofmem);
-      if (stbv_get_bits(f,1))
-         m->submaps = stbv_get_bits(f,4)+1;
-      else
-         m->submaps = 1;
-      if (m->submaps > max_submaps)
-         max_submaps = m->submaps;
-      if (stbv_get_bits(f,1)) {
-         m->coupling_steps = stbv_get_bits(f,8)+1;
-         for (k=0; k < m->coupling_steps; ++k) {
-            m->chan[k].magnitude = stbv_get_bits(f, stbv_ilog(f->channels-1));
-            m->chan[k].angle = stbv_get_bits(f, stbv_ilog(f->channels-1));
-            if (m->chan[k].magnitude >= f->channels)        return stbv_error(f, VORBIS_invalid_setup);
-            if (m->chan[k].angle     >= f->channels)        return stbv_error(f, VORBIS_invalid_setup);
-            if (m->chan[k].magnitude == m->chan[k].angle)   return stbv_error(f, VORBIS_invalid_setup);
-         }
-      } else
-         m->coupling_steps = 0;
-
-      // reserved field
-      if (stbv_get_bits(f,2)) return stbv_error(f, VORBIS_invalid_setup);
-      if (m->submaps > 1) {
-         for (j=0; j < f->channels; ++j) {
-            m->chan[j].mux = stbv_get_bits(f, 4);
-            if (m->chan[j].mux >= m->submaps)                return stbv_error(f, VORBIS_invalid_setup);
-         }
-      } else
-         // @SPECIFICATION: this case is missing from the spec
-         for (j=0; j < f->channels; ++j)
-            m->chan[j].mux = 0;
-
-      for (j=0; j < m->submaps; ++j) {
-         stbv_get_bits(f,8); // discard
-         m->submap_floor[j] = stbv_get_bits(f,8);
-         m->submap_residue[j] = stbv_get_bits(f,8);
-         if (m->submap_floor[j] >= f->floor_count)      return stbv_error(f, VORBIS_invalid_setup);
-         if (m->submap_residue[j] >= f->residue_count)  return stbv_error(f, VORBIS_invalid_setup);
-      }
-   }
-
-   // Modes
-   f->mode_count = stbv_get_bits(f, 6)+1;
-   for (i=0; i < f->mode_count; ++i) {
-      StbvMode *m = f->mode_config+i;
-      m->blockflag = stbv_get_bits(f,1);
-      m->windowtype = stbv_get_bits(f,16);
-      m->transformtype = stbv_get_bits(f,16);
-      m->mapping = stbv_get_bits(f,8);
-      if (m->windowtype != 0)                 return stbv_error(f, VORBIS_invalid_setup);
-      if (m->transformtype != 0)              return stbv_error(f, VORBIS_invalid_setup);
-      if (m->mapping >= f->mapping_count)     return stbv_error(f, VORBIS_invalid_setup);
-   }
-
-   stbv_flush_packet(f);
-
-   f->previous_length = 0;
-
-   for (i=0; i < f->channels; ++i) {
-      f->channel_buffers[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1);
-      f->previous_window[i] = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
-      f->finalY[i]          = (stbv_int16 *) stbv_setup_malloc(f, sizeof(stbv_int16) * longest_floorlist);
-      if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return stbv_error(f, VORBIS_outofmem);
-      memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1);
-      #ifdef STB_VORBIS_NO_DEFER_FLOOR
-      f->floor_buffers[i]   = (float *) stbv_setup_malloc(f, sizeof(float) * f->blocksize_1/2);
-      if (f->floor_buffers[i] == NULL) return stbv_error(f, VORBIS_outofmem);
-      #endif
-   }
-
-   if (!stbv_init_blocksize(f, 0, f->blocksize_0)) return FALSE;
-   if (!stbv_init_blocksize(f, 1, f->blocksize_1)) return FALSE;
-   f->blocksize[0] = f->blocksize_0;
-   f->blocksize[1] = f->blocksize_1;
-
-#ifdef STB_VORBIS_DIVIDE_TABLE
-   if (stbv_integer_divide_table[1][1]==0)
-      for (i=0; i < STBV_DIVTAB_NUMER; ++i)
-         for (j=1; j < STBV_DIVTAB_DENOM; ++j)
-            stbv_integer_divide_table[i][j] = i / j;
-#endif
-
-   // compute how much temporary memory is needed
-
-   // 1.
-   {
-      stbv_uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
-      stbv_uint32 classify_mem;
-      int i,max_part_read=0;
-      for (i=0; i < f->residue_count; ++i) {
-         StbvResidue *r = f->residue_config + i;
-         unsigned int actual_size = f->blocksize_1 / 2;
-         unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
-         unsigned int limit_r_end   = r->end   < actual_size ? r->end   : actual_size;
-         int n_read = limit_r_end - limit_r_begin;
-         int part_read = n_read / r->part_size;
-         if (part_read > max_part_read)
-            max_part_read = part_read;
-      }
-      #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
-      classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(stbv_uint8 *));
-      #else
-      classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
-      #endif
-
-      // maximum reasonable partition size is f->blocksize_1
-
-      f->temp_memory_required = classify_mem;
-      if (imdct_mem > f->temp_memory_required)
-         f->temp_memory_required = imdct_mem;
-   }
-
-   f->first_decode = TRUE;
-
-   if (f->alloc.alloc_buffer) {
-      assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
-      // check if there's enough temp memory so we don't error later
-      if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
-         return stbv_error(f, VORBIS_outofmem);
-   }
-
-   f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
-
-   return TRUE;
-}
-
-static void stbv_vorbis_deinit(stb_vorbis *p)
-{
-   int i,j;
-   if (p->residue_config) {
-      for (i=0; i < p->residue_count; ++i) {
-         StbvResidue *r = p->residue_config+i;
-         if (r->classdata) {
-            for (j=0; j < p->codebooks[r->classbook].entries; ++j)
-               stbv_setup_free(p, r->classdata[j]);
-            stbv_setup_free(p, r->classdata);
-         }
-         stbv_setup_free(p, r->residue_books);
-      }
-   }
-
-   if (p->codebooks) {
-      STBV_CHECK(p);
-      for (i=0; i < p->codebook_count; ++i) {
-         StbvCodebook *c = p->codebooks + i;
-         stbv_setup_free(p, c->codeword_lengths);
-         stbv_setup_free(p, c->multiplicands);
-         stbv_setup_free(p, c->codewords);
-         stbv_setup_free(p, c->sorted_codewords);
-         // c->sorted_values[-1] is the first entry in the array
-         stbv_setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
-      }
-      stbv_setup_free(p, p->codebooks);
-   }
-   stbv_setup_free(p, p->floor_config);
-   stbv_setup_free(p, p->residue_config);
-   if (p->mapping) {
-      for (i=0; i < p->mapping_count; ++i)
-         stbv_setup_free(p, p->mapping[i].chan);
-      stbv_setup_free(p, p->mapping);
-   }
-   STBV_CHECK(p);
-   for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
-      stbv_setup_free(p, p->channel_buffers[i]);
-      stbv_setup_free(p, p->previous_window[i]);
-      #ifdef STB_VORBIS_NO_DEFER_FLOOR
-      stbv_setup_free(p, p->floor_buffers[i]);
-      #endif
-      stbv_setup_free(p, p->finalY[i]);
-   }
-   for (i=0; i < 2; ++i) {
-      stbv_setup_free(p, p->A[i]);
-      stbv_setup_free(p, p->B[i]);
-      stbv_setup_free(p, p->C[i]);
-      stbv_setup_free(p, p->window[i]);
-      stbv_setup_free(p, p->stbv_bit_reverse[i]);
-   }
-   #ifndef STB_VORBIS_NO_STDIO
-   if (p->close_on_free) fclose(p->f);
-   #endif
-}
-
-STBVDEF void stb_vorbis_close(stb_vorbis *p)
-{
-   if (p == NULL) return;
-   stbv_vorbis_deinit(p);
-   stbv_setup_free(p,p);
-}
-
-static void stbv_vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
-{
-   memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
-   if (z) {
-      p->alloc = *z;
-      p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
-      p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
-   }
-   p->eof = 0;
-   p->error = VORBIS__no_error;
-   p->stream = NULL;
-   p->codebooks = NULL;
-   p->page_crc_tests = -1;
-   #ifndef STB_VORBIS_NO_STDIO
-   p->close_on_free = FALSE;
-   p->f = NULL;
-   #endif
-}
-
-STBVDEF int stb_vorbis_get_sample_offset(stb_vorbis *f)
-{
-   if (f->current_loc_valid)
-      return f->current_loc;
-   else
-      return -1;
-}
-
-STBVDEF stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
-{
-   stb_vorbis_info d;
-   d.channels = f->channels;
-   d.sample_rate = f->sample_rate;
-   d.setup_memory_required = f->setup_memory_required;
-   d.setup_temp_memory_required = f->setup_temp_memory_required;
-   d.temp_memory_required = f->temp_memory_required;
-   d.max_frame_size = f->blocksize_1 >> 1;
-   return d;
-}
-
-STBVDEF int stb_vorbis_get_error(stb_vorbis *f)
-{
-   int e = f->error;
-   f->error = VORBIS__no_error;
-   return e;
-}
-
-static stb_vorbis * stbv_vorbis_alloc(stb_vorbis *f)
-{
-   stb_vorbis *p = (stb_vorbis *) stbv_setup_malloc(f, sizeof(*p));
-   return p;
-}
-
-#ifndef STB_VORBIS_NO_PUSHDATA_API
-
-STBVDEF void stb_vorbis_flush_pushdata(stb_vorbis *f)
-{
-   f->previous_length = 0;
-   f->page_crc_tests  = 0;
-   f->discard_samples_deferred = 0;
-   f->current_loc_valid = FALSE;
-   f->first_decode = FALSE;
-   f->samples_output = 0;
-   f->channel_buffer_start = 0;
-   f->channel_buffer_end = 0;
-}
-
-static int stbv_vorbis_search_for_page_pushdata(stbv_vorb *f, stbv_uint8 *data, int data_len)
-{
-   int i,n;
-   for (i=0; i < f->page_crc_tests; ++i)
-      f->scan[i].bytes_done = 0;
-
-   // if we have room for more scans, search for them first, because
-   // they may cause us to stop early if their header is incomplete
-   if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) {
-      if (data_len < 4) return 0;
-      data_len -= 3; // need to look for 4-byte sequence, so don't miss
-                     // one that straddles a boundary
-      for (i=0; i < data_len; ++i) {
-         if (data[i] == 0x4f) {
-            if (0==memcmp(data+i, stbv_ogg_page_header, 4)) {
-               int j,len;
-               stbv_uint32 crc;
-               // make sure we have the whole page header
-               if (i+26 >= data_len || i+27+data[i+26] >= data_len) {
-                  // only read up to this page start, so hopefully we'll
-                  // have the whole page header start next time
-                  data_len = i;
-                  break;
-               }
-               // ok, we have it all; compute the length of the page
-               len = 27 + data[i+26];
-               for (j=0; j < data[i+26]; ++j)
-                  len += data[i+27+j];
-               // scan everything up to the embedded crc (which we must 0)
-               crc = 0;
-               for (j=0; j < 22; ++j)
-                  crc = stbv_crc32_update(crc, data[i+j]);
-               // now process 4 0-bytes
-               for (   ; j < 26; ++j)
-                  crc = stbv_crc32_update(crc, 0);
-               // len is the total number of bytes we need to scan
-               n = f->page_crc_tests++;
-               f->scan[n].bytes_left = len-j;
-               f->scan[n].crc_so_far = crc;
-               f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24);
-               // if the last frame on a page is continued to the next, then
-               // we can't recover the sample_loc immediately
-               if (data[i+27+data[i+26]-1] == 255)
-                  f->scan[n].sample_loc = ~0;
-               else
-                  f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24);
-               f->scan[n].bytes_done = i+j;
-               if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT)
-                  break;
-               // keep going if we still have room for more
-            }
-         }
-      }
-   }
-
-   for (i=0; i < f->page_crc_tests;) {
-      stbv_uint32 crc;
-      int j;
-      int n = f->scan[i].bytes_done;
-      int m = f->scan[i].bytes_left;
-      if (m > data_len - n) m = data_len - n;
-      // m is the bytes to scan in the current chunk
-      crc = f->scan[i].crc_so_far;
-      for (j=0; j < m; ++j)
-         crc = stbv_crc32_update(crc, data[n+j]);
-      f->scan[i].bytes_left -= m;
-      f->scan[i].crc_so_far = crc;
-      if (f->scan[i].bytes_left == 0) {
-         // does it match?
-         if (f->scan[i].crc_so_far == f->scan[i].goal_crc) {
-            // Houston, we have page
-            data_len = n+m; // consumption amount is wherever that scan ended
-            f->page_crc_tests = -1; // drop out of page scan mode
-            f->previous_length = 0; // decode-but-don't-output one frame
-            f->next_seg = -1;       // start a new page
-            f->current_loc = f->scan[i].sample_loc; // set the current sample location
-                                    // to the amount we'd have decoded had we decoded this page
-            f->current_loc_valid = f->current_loc != ~0U;
-            return data_len;
-         }
-         // delete entry
-         f->scan[i] = f->scan[--f->page_crc_tests];
-      } else {
-         ++i;
-      }
-   }
-
-   return data_len;
-}
-
-// return value: number of bytes we used
-STBVDEF int stb_vorbis_decode_frame_pushdata(
-         stb_vorbis *f,                   // the file we're decoding
-         const stbv_uint8 *data, int data_len, // the memory available for decoding
-         int *channels,                   // place to write number of float * buffers
-         float ***output,                 // place to write float ** array of float * buffers
-         int *samples                     // place to write number of output samples
-     )
-{
-   int i;
-   int len,right,left;
-
-   if (!STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   if (f->page_crc_tests >= 0) {
-      *samples = 0;
-      return stbv_vorbis_search_for_page_pushdata(f, (stbv_uint8 *) data, data_len);
-   }
-
-   f->stream     = (stbv_uint8 *) data;
-   f->stream_end = (stbv_uint8 *) data + data_len;
-   f->error      = VORBIS__no_error;
-
-   // check that we have the entire packet in memory
-   if (!stbv_is_whole_packet_present(f, FALSE)) {
-      *samples = 0;
-      return 0;
-   }
-
-   if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
-      // save the actual error we encountered
-      enum STBVorbisError error = f->error;
-      if (error == VORBIS_bad_packet_type) {
-         // flush and resynch
-         f->error = VORBIS__no_error;
-         while (stbv_get8_packet(f) != STBV_EOP)
-            if (f->eof) break;
-         *samples = 0;
-         return (int) (f->stream - data);
-      }
-      if (error == VORBIS_continued_packet_flag_invalid) {
-         if (f->previous_length == 0) {
-            // we may be resynching, in which case it's ok to hit one
-            // of these; just discard the packet
-            f->error = VORBIS__no_error;
-            while (stbv_get8_packet(f) != STBV_EOP)
-               if (f->eof) break;
-            *samples = 0;
-            return (int) (f->stream - data);
-         }
-      }
-      // if we get an error while parsing, what to do?
-      // well, it DEFINITELY won't work to continue from where we are!
-      stb_vorbis_flush_pushdata(f);
-      // restore the error that actually made us bail
-      f->error = error;
-      *samples = 0;
-      return 1;
-   }
-
-   // success!
-   len = stbv_vorbis_finish_frame(f, len, left, right);
-   for (i=0; i < f->channels; ++i)
-      f->outputs[i] = f->channel_buffers[i] + left;
-
-   if (channels) *channels = f->channels;
-   *samples = len;
-   *output = f->outputs;
-   return (int) (f->stream - data);
-}
-
-STBVDEF stb_vorbis *stb_vorbis_open_pushdata(
-         const unsigned char *data, int data_len, // the memory available for decoding
-         int *data_used,              // only defined if result is not NULL
-         int *error, const stb_vorbis_alloc *alloc)
-{
-   stb_vorbis *f, p;
-   stbv_vorbis_init(&p, alloc);
-   p.stream     = (stbv_uint8 *) data;
-   p.stream_end = (stbv_uint8 *) data + data_len;
-   p.push_mode  = TRUE;
-   if (!stbv_start_decoder(&p)) {
-      if (p.eof)
-         *error = VORBIS_need_more_data;
-      else
-         *error = p.error;
-      return NULL;
-   }
-   f = stbv_vorbis_alloc(&p);
-   if (f) {
-      *f = p;
-      *data_used = (int) (f->stream - data);
-      *error = 0;
-      return f;
-   } else {
-      stbv_vorbis_deinit(&p);
-      return NULL;
-   }
-}
-#endif // STB_VORBIS_NO_PUSHDATA_API
-
-STBVDEF unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
-{
-   #ifndef STB_VORBIS_NO_PUSHDATA_API
-   if (f->push_mode) return 0;
-   #endif
-   if (STBV_USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
-   #ifndef STB_VORBIS_NO_STDIO
-   return (unsigned int) (ftell(f->f) - f->f_start);
-   #endif
-}
-
-#ifndef STB_VORBIS_NO_PULLDATA_API
-//
-// DATA-PULLING API
-//
-
-static stbv_uint32 stbv_vorbis_find_page(stb_vorbis *f, stbv_uint32 *end, stbv_uint32 *last)
-{
-   for(;;) {
-      int n;
-      if (f->eof) return 0;
-      n = stbv_get8(f);
-      if (n == 0x4f) { // page header candidate
-         unsigned int retry_loc = stb_vorbis_get_file_offset(f);
-         int i;
-         // check if we're off the end of a file_section stream
-         if (retry_loc - 25 > f->stream_len)
-            return 0;
-         // check the rest of the header
-         for (i=1; i < 4; ++i)
-            if (stbv_get8(f) != stbv_ogg_page_header[i])
-               break;
-         if (f->eof) return 0;
-         if (i == 4) {
-            stbv_uint8 header[27];
-            stbv_uint32 i, crc, goal, len;
-            for (i=0; i < 4; ++i)
-               header[i] = stbv_ogg_page_header[i];
-            for (; i < 27; ++i)
-               header[i] = stbv_get8(f);
-            if (f->eof) return 0;
-            if (header[4] != 0) goto invalid;
-            goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24);
-            for (i=22; i < 26; ++i)
-               header[i] = 0;
-            crc = 0;
-            for (i=0; i < 27; ++i)
-               crc = stbv_crc32_update(crc, header[i]);
-            len = 0;
-            for (i=0; i < header[26]; ++i) {
-               int s = stbv_get8(f);
-               crc = stbv_crc32_update(crc, s);
-               len += s;
-            }
-            if (len && f->eof) return 0;
-            for (i=0; i < len; ++i)
-               crc = stbv_crc32_update(crc, stbv_get8(f));
-            // finished parsing probable page
-            if (crc == goal) {
-               // we could now check that it's either got the last
-               // page flag set, OR it's followed by the capture
-               // pattern, but I guess TECHNICALLY you could have
-               // a file with garbage between each ogg page and recover
-               // from it automatically? So even though that paranoia
-               // might decrease the chance of an invalid decode by
-               // another 2^32, not worth it since it would hose those
-               // invalid-but-useful files?
-               if (end)
-                  *end = stb_vorbis_get_file_offset(f);
-               if (last) {
-                  if (header[5] & 0x04)
-                     *last = 1;
-                  else
-                     *last = 0;
-               }
-               stbv_set_file_offset(f, retry_loc-1);
-               return 1;
-            }
-         }
-        invalid:
-         // not a valid page, so rewind and look for next one
-         stbv_set_file_offset(f, retry_loc);
-      }
-   }
-}
-
-
-#define STBV_SAMPLE_unknown  0xffffffff
-
-// seeking is implemented with a binary search, which narrows down the range to
-// 64K, before using a linear search (because finding the synchronization
-// pattern can be expensive, and the chance we'd find the end page again is
-// relatively high for small ranges)
-//
-// two initial interpolation-style probes are used at the start of the search
-// to try to bound either side of the binary search sensibly, while still
-// working in O(log n) time if they fail.
-
-static int stbv_get_seek_page_info(stb_vorbis *f, StbvProbedPage *z)
-{
-   stbv_uint8 header[27], lacing[255];
-   int i,len;
-
-   // record where the page starts
-   z->page_start = stb_vorbis_get_file_offset(f);
-
-   // parse the header
-   stbv_getn(f, header, 27);
-   if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
-      return 0;
-   stbv_getn(f, lacing, header[26]);
-
-   // determine the length of the payload
-   len = 0;
-   for (i=0; i < header[26]; ++i)
-      len += lacing[i];
-
-   // this implies where the page ends
-   z->page_end = z->page_start + 27 + header[26] + len;
-
-   // read the last-decoded sample out of the data
-   z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
-
-   // restore file state to where we were
-   stbv_set_file_offset(f, z->page_start);
-   return 1;
-}
-
-// rarely used function to seek back to the preceeding page while finding the
-// start of a packet
-static int stbv_go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
-{
-   unsigned int previous_safe, end;
-
-   // now we want to seek back 64K from the limit
-   if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset)
-      previous_safe = limit_offset - 65536;
-   else
-      previous_safe = f->first_audio_page_offset;
-
-   stbv_set_file_offset(f, previous_safe);
-
-   while (stbv_vorbis_find_page(f, &end, NULL)) {
-      if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
-         return 1;
-      stbv_set_file_offset(f, end);
-   }
-
-   return 0;
-}
-
-// implements the search logic for finding a page and starting decoding. if
-// the function succeeds, current_loc_valid will be true and current_loc will
-// be less than or equal to the provided sample number (the closer the
-// better).
-static int stbv_seek_to_sample_coarse(stb_vorbis *f, stbv_uint32 sample_number)
-{
-   StbvProbedPage left, right, mid;
-   int i, start_seg_with_known_loc, end_pos, page_start;
-   stbv_uint32 delta, stream_length, padding;
-   double offset, bytes_per_sample;
-   int probe = 0;
-
-   // find the last page and validate the target sample
-   stream_length = stb_vorbis_stream_length_in_samples(f);
-   if (stream_length == 0)            return stbv_error(f, VORBIS_seek_without_length);
-   if (sample_number > stream_length) return stbv_error(f, VORBIS_seek_invalid);
-
-   // this is the maximum difference between the window-center (which is the
-   // actual granule position value), and the right-start (which the spec
-   // indicates should be the granule position (give or take one)).
-   padding = ((f->blocksize_1 - f->blocksize_0) >> 2);
-   if (sample_number < padding)
-      sample_number = 0;
-   else
-      sample_number -= padding;
-
-   left = f->p_first;
-   while (left.last_decoded_sample == ~0U) {
-      // (untested) the first page does not have a 'last_decoded_sample'
-      stbv_set_file_offset(f, left.page_end);
-      if (!stbv_get_seek_page_info(f, &left)) goto error;
-   }
-
-   right = f->p_last;
-   assert(right.last_decoded_sample != ~0U);
-
-   // starting from the start is handled differently
-   if (sample_number <= left.last_decoded_sample) {
-      if (stb_vorbis_seek_start(f))
-         return 1;
-      return 0;
-   }
-
-   while (left.page_end != right.page_start) {
-      assert(left.page_end < right.page_start);
-      // search range in bytes
-      delta = right.page_start - left.page_end;
-      if (delta <= 65536) {
-         // there's only 64K left to search - handle it linearly
-         stbv_set_file_offset(f, left.page_end);
-      } else {
-         if (probe < 2) {
-            if (probe == 0) {
-               // first probe (interpolate)
-               double data_bytes = right.page_end - left.page_start;
-               bytes_per_sample = data_bytes / right.last_decoded_sample;
-               offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample);
-            } else {
-               // second probe (try to bound the other side)
-               double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample;
-               if (error >= 0 && error <  8000) error =  8000;
-               if (error <  0 && error > -8000) error = -8000;
-               offset += error * 2;
-            }
-
-            // ensure the offset is valid
-            if (offset < left.page_end)
-               offset = left.page_end;
-            if (offset > right.page_start - 65536)
-               offset = right.page_start - 65536;
-
-            stbv_set_file_offset(f, (unsigned int) offset);
-         } else {
-            // binary search for large ranges (offset by 32K to ensure
-            // we don't hit the right page)
-            stbv_set_file_offset(f, left.page_end + (delta / 2) - 32768);
-         }
-
-         if (!stbv_vorbis_find_page(f, NULL, NULL)) goto error;
-      }
-
-      for (;;) {
-         if (!stbv_get_seek_page_info(f, &mid)) goto error;
-         if (mid.last_decoded_sample != ~0U) break;
-         // (untested) no frames end on this page
-         stbv_set_file_offset(f, mid.page_end);
-         assert(mid.page_start < right.page_start);
-      }
-
-      // if we've just found the last page again then we're in a tricky file,
-      // and we're close enough.
-      if (mid.page_start == right.page_start)
-         break;
-
-      if (sample_number < mid.last_decoded_sample)
-         right = mid;
-      else
-         left = mid;
-
-      ++probe;
-   }
-
-   // seek back to start of the last packet
-   page_start = left.page_start;
-   stbv_set_file_offset(f, page_start);
-   if (!stbv_start_page(f)) return stbv_error(f, VORBIS_seek_failed);
-   end_pos = f->end_seg_with_known_loc;
-   assert(end_pos >= 0);
-
-   for (;;) {
-      for (i = end_pos; i > 0; --i)
-         if (f->segments[i-1] != 255)
-            break;
-
-      start_seg_with_known_loc = i;
-
-      if (start_seg_with_known_loc > 0 || !(f->page_flag & STBV_PAGEFLAG_continued_packet))
-         break;
-
-      // (untested) the final packet begins on an earlier page
-      if (!stbv_go_to_page_before(f, page_start))
-         goto error;
-
-      page_start = stb_vorbis_get_file_offset(f);
-      if (!stbv_start_page(f)) goto error;
-      end_pos = f->segment_count - 1;
-   }
-
-   // prepare to start decoding
-   f->current_loc_valid = FALSE;
-   f->last_seg = FALSE;
-   f->valid_bits = 0;
-   f->packet_bytes = 0;
-   f->bytes_in_seg = 0;
-   f->previous_length = 0;
-   f->next_seg = start_seg_with_known_loc;
-
-   for (i = 0; i < start_seg_with_known_loc; i++)
-      stbv_skip(f, f->segments[i]);
-
-   // start decoding (optimizable - this frame is generally discarded)
-   if (!stbv_vorbis_pump_first_frame(f))
-      return 0;
-   if (f->current_loc > sample_number)
-      return stbv_error(f, VORBIS_seek_failed);
-   return 1;
-
-error:
-   // try to restore the file to a valid state
-   stb_vorbis_seek_start(f);
-   return stbv_error(f, VORBIS_seek_failed);
-}
-
-// the same as stbv_vorbis_decode_initial, but without advancing
-static int stbv_peek_decode_initial(stbv_vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
-{
-   int bits_read, bytes_read;
-
-   if (!stbv_vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
-      return 0;
-
-   // either 1 or 2 bytes were read, figure out which so we can rewind
-   bits_read = 1 + stbv_ilog(f->mode_count-1);
-   if (f->mode_config[*mode].blockflag)
-      bits_read += 2;
-   bytes_read = (bits_read + 7) / 8;
-
-   f->bytes_in_seg += bytes_read;
-   f->packet_bytes -= bytes_read;
-   stbv_skip(f, -bytes_read);
-   if (f->next_seg == -1)
-      f->next_seg = f->segment_count - 1;
-   else
-      f->next_seg--;
-   f->valid_bits = 0;
-
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
-{
-   stbv_uint32 max_frame_samples;
-
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   // fast page-level search
-   if (!stbv_seek_to_sample_coarse(f, sample_number))
-      return 0;
-
-   assert(f->current_loc_valid);
-   assert(f->current_loc <= sample_number);
-
-   // linear search for the relevant packet
-   max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
-   while (f->current_loc < sample_number) {
-      int left_start, left_end, right_start, right_end, mode, frame_samples;
-      if (!stbv_peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
-         return stbv_error(f, VORBIS_seek_failed);
-      // calculate the number of samples returned by the next frame
-      frame_samples = right_start - left_start;
-      if (f->current_loc + frame_samples > sample_number) {
-         return 1; // the next frame will contain the sample
-      } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
-         // there's a chance the frame after this could contain the sample
-         stbv_vorbis_pump_first_frame(f);
-      } else {
-         // this frame is too early to be relevant
-         f->current_loc += frame_samples;
-         f->previous_length = 0;
-         stbv_maybe_start_packet(f);
-         stbv_flush_packet(f);
-      }
-   }
-   // the next frame will start with the sample
-   assert(f->current_loc == sample_number);
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
-{
-   if (!stb_vorbis_seek_frame(f, sample_number))
-      return 0;
-
-   if (sample_number != f->current_loc) {
-      int n;
-      stbv_uint32 frame_start = f->current_loc;
-      stb_vorbis_get_frame_float(f, &n, NULL);
-      assert(sample_number > frame_start);
-      assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end);
-      f->channel_buffer_start += (sample_number - frame_start);
-   }
-
-   return 1;
-}
-
-STBVDEF int stb_vorbis_seek_start(stb_vorbis *f)
-{
-   if (STBV_IS_PUSH_MODE(f)) { return stbv_error(f, VORBIS_invalid_api_mixing); }
-   stbv_set_file_offset(f, f->first_audio_page_offset);
-   f->previous_length = 0;
-   f->first_decode = TRUE;
-   f->next_seg = -1;
-   return stbv_vorbis_pump_first_frame(f);
-}
-
-STBVDEF unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
-{
-   unsigned int restore_offset, previous_safe;
-   unsigned int end, last_page_loc;
-
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-   if (!f->total_samples) {
-      unsigned int last;
-      stbv_uint32 lo,hi;
-      char header[6];
-
-      // first, store the current decode position so we can restore it
-      restore_offset = stb_vorbis_get_file_offset(f);
-
-      // now we want to seek back 64K from the end (the last page must
-      // be at most a little less than 64K, but let's allow a little slop)
-      if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset)
-         previous_safe = f->stream_len - 65536;
-      else
-         previous_safe = f->first_audio_page_offset;
-
-      stbv_set_file_offset(f, previous_safe);
-      // previous_safe is now our candidate 'earliest known place that seeking
-      // to will lead to the final page'
-
-      if (!stbv_vorbis_find_page(f, &end, &last)) {
-         // if we can't find a page, we're hosed!
-         f->error = VORBIS_cant_find_last_page;
-         f->total_samples = 0xffffffff;
-         goto done;
-      }
-
-      // check if there are more pages
-      last_page_loc = stb_vorbis_get_file_offset(f);
-
-      // stop when the last_page flag is set, not when we reach eof;
-      // this allows us to stop short of a 'file_section' end without
-      // explicitly checking the length of the section
-      while (!last) {
-         stbv_set_file_offset(f, end);
-         if (!stbv_vorbis_find_page(f, &end, &last)) {
-            // the last page we found didn't have the 'last page' flag
-            // set. whoops!
-            break;
-         }
-         previous_safe = last_page_loc+1;
-         last_page_loc = stb_vorbis_get_file_offset(f);
-      }
-
-      stbv_set_file_offset(f, last_page_loc);
-
-      // parse the header
-      stbv_getn(f, (unsigned char *)header, 6);
-      // extract the absolute granule position
-      lo = stbv_get32(f);
-      hi = stbv_get32(f);
-      if (lo == 0xffffffff && hi == 0xffffffff) {
-         f->error = VORBIS_cant_find_last_page;
-         f->total_samples = STBV_SAMPLE_unknown;
-         goto done;
-      }
-      if (hi)
-         lo = 0xfffffffe; // saturate
-      f->total_samples = lo;
-
-      f->p_last.page_start = last_page_loc;
-      f->p_last.page_end   = end;
-      f->p_last.last_decoded_sample = lo;
-
-     done:
-      stbv_set_file_offset(f, restore_offset);
-   }
-   return f->total_samples == STBV_SAMPLE_unknown ? 0 : f->total_samples;
-}
-
-STBVDEF float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
-{
-   return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
-}
-
-
-
-STBVDEF int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
-{
-   int len, right,left,i;
-   if (STBV_IS_PUSH_MODE(f)) return stbv_error(f, VORBIS_invalid_api_mixing);
-
-   if (!stbv_vorbis_decode_packet(f, &len, &left, &right)) {
-      f->channel_buffer_start = f->channel_buffer_end = 0;
-      return 0;
-   }
-
-   len = stbv_vorbis_finish_frame(f, len, left, right);
-   for (i=0; i < f->channels; ++i)
-      f->outputs[i] = f->channel_buffers[i] + left;
-
-   f->channel_buffer_start = left;
-   f->channel_buffer_end   = left+len;
-
-   if (channels) *channels = f->channels;
-   if (output)   *output = f->outputs;
-   return len;
-}
-
-#ifndef STB_VORBIS_NO_STDIO
-
-STBVDEF stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length)
-{
-   stb_vorbis *f, p;
-   stbv_vorbis_init(&p, alloc);
-   p.f = file;
-   p.f_start = (stbv_uint32) ftell(file);
-   p.stream_len   = length;
-   p.close_on_free = close_on_free;
-   if (stbv_start_decoder(&p)) {
-      f = stbv_vorbis_alloc(&p);
-      if (f) {
-         *f = p;
-         stbv_vorbis_pump_first_frame(f);
-         return f;
-      }
-   }
-   if (error) *error = p.error;
-   stbv_vorbis_deinit(&p);
-   return NULL;
-}
-
-STBVDEF stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
-{
-   unsigned int len, start;
-   start = (unsigned int) ftell(file);
-   fseek(file, 0, SEEK_END);
-   len = (unsigned int) (ftell(file) - start);
-   fseek(file, start, SEEK_SET);
-   return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
-}
-
-STBVDEF stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
-{
-   FILE *f = fopen(filename, "rb");
-   if (f) 
-      return stb_vorbis_open_file(f, TRUE, error, alloc);
-   if (error) *error = VORBIS_file_open_failure;
-   return NULL;
-}
-#endif // STB_VORBIS_NO_STDIO
-
-STBVDEF stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
-{
-   stb_vorbis *f, p;
-   if (data == NULL) return NULL;
-   stbv_vorbis_init(&p, alloc);
-   p.stream = (stbv_uint8 *) data;
-   p.stream_end = (stbv_uint8 *) data + len;
-   p.stream_start = (stbv_uint8 *) p.stream;
-   p.stream_len = len;
-   p.push_mode = FALSE;
-   if (stbv_start_decoder(&p)) {
-      f = stbv_vorbis_alloc(&p);
-      if (f) {
-         *f = p;
-         stbv_vorbis_pump_first_frame(f);
-         if (error) *error = VORBIS__no_error;
-         return f;
-      }
-   }
-   if (error) *error = p.error;
-   stbv_vorbis_deinit(&p);
-   return NULL;
-}
-
-#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
-#define STBV_PLAYBACK_MONO 1
-#define STBV_PLAYBACK_LEFT 2
-#define STBV_PLAYBACK_RIGHT 4
-
-#define STBV_L  (STBV_PLAYBACK_LEFT  | STBV_PLAYBACK_MONO)
-#define STBV_C  (STBV_PLAYBACK_LEFT  | STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
-#define STBV_R  (STBV_PLAYBACK_RIGHT | STBV_PLAYBACK_MONO)
-
-static stbv_int8 stbv_channel_position[7][6] =
-{
-   { 0 },
-   { STBV_C },
-   { STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R },
-   { STBV_L, STBV_R, STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R },
-   { STBV_L, STBV_C, STBV_R, STBV_L, STBV_R, STBV_C },
-};
-
-
-#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
-   typedef union {
-      float f;
-      int i;
-   } stbv_float_conv;
-   typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
-   #define STBV_FASTDEF(x) stbv_float_conv x
-   // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round
-   #define STBV_MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
-   #define STBV_ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
-   #define STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + STBV_MAGIC(s), temp.i - STBV_ADDEND(s))
-   #define stbv_check_endianness()  
-#else
-   #define STBV_FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
-   #define stbv_check_endianness()
-   #define STBV_FASTDEF(x)
-#endif
-
-static void stbv_copy_samples(short *dest, float *src, int len)
-{
-   int i;
-   stbv_check_endianness();
-   for (i=0; i < len; ++i) {
-      STBV_FASTDEF(temp);
-      int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
-      if ((unsigned int) (v + 32768) > 65535)
-         v = v < 0 ? -32768 : 32767;
-      dest[i] = v;
-   }
-}
-
-static void stbv_compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
-{
-   #define BUFFER_SIZE  32
-   float buffer[BUFFER_SIZE];
-   int i,j,o,n = BUFFER_SIZE;
-   stbv_check_endianness();
-   for (o = 0; o < len; o += BUFFER_SIZE) {
-      memset(buffer, 0, sizeof(buffer));
-      if (o + n > len) n = len - o;
-      for (j=0; j < num_c; ++j) {
-         if (stbv_channel_position[num_c][j] & mask) {
-            for (i=0; i < n; ++i)
-               buffer[i] += data[j][d_offset+o+i];
-         }
-      }
-      for (i=0; i < n; ++i) {
-         STBV_FASTDEF(temp);
-         int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
-         if ((unsigned int) (v + 32768) > 65535)
-            v = v < 0 ? -32768 : 32767;
-         output[o+i] = v;
-      }
-   }
-}
-
-static void stbv_compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
-{
-   #define BUFFER_SIZE  32
-   float buffer[BUFFER_SIZE];
-   int i,j,o,n = BUFFER_SIZE >> 1;
-   // o is the offset in the source data
-   stbv_check_endianness();
-   for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
-      // o2 is the offset in the output data
-      int o2 = o << 1;
-      memset(buffer, 0, sizeof(buffer));
-      if (o + n > len) n = len - o;
-      for (j=0; j < num_c; ++j) {
-         int m = stbv_channel_position[num_c][j] & (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT);
-         if (m == (STBV_PLAYBACK_LEFT | STBV_PLAYBACK_RIGHT)) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+0] += data[j][d_offset+o+i];
-               buffer[i*2+1] += data[j][d_offset+o+i];
-            }
-         } else if (m == STBV_PLAYBACK_LEFT) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+0] += data[j][d_offset+o+i];
-            }
-         } else if (m == STBV_PLAYBACK_RIGHT) {
-            for (i=0; i < n; ++i) {
-               buffer[i*2+1] += data[j][d_offset+o+i];
-            }
-         }
-      }
-      for (i=0; i < (n<<1); ++i) {
-         STBV_FASTDEF(temp);
-         int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
-         if ((unsigned int) (v + 32768) > 65535)
-            v = v < 0 ? -32768 : 32767;
-         output[o2+i] = v;
-      }
-   }
-}
-
-static void stbv_convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
-{
-   int i;
-   if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
-      static int channel_selector[3][2] = { {0}, {STBV_PLAYBACK_MONO}, {STBV_PLAYBACK_LEFT, STBV_PLAYBACK_RIGHT} };
-      for (i=0; i < buf_c; ++i)
-         stbv_compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
-   } else {
-      int limit = buf_c < data_c ? buf_c : data_c;
-      for (i=0; i < limit; ++i)
-         stbv_copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
-      for (   ; i < buf_c; ++i)
-         memset(buffer[i]+b_offset, 0, sizeof(short) * samples);
-   }
-}
-
-STBVDEF int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
-{
-   float **output;
-   int len = stb_vorbis_get_frame_float(f, NULL, &output);
-   if (len > num_samples) len = num_samples;
-   if (len)
-      stbv_convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
-   return len;
-}
-
-static void stbv_convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
-{
-   int i;
-   stbv_check_endianness();
-   if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
-      assert(buf_c == 2);
-      for (i=0; i < buf_c; ++i)
-         stbv_compute_stereo_samples(buffer, data_c, data, d_offset, len);
-   } else {
-      int limit = buf_c < data_c ? buf_c : data_c;
-      int j;
-      for (j=0; j < len; ++j) {
-         for (i=0; i < limit; ++i) {
-            STBV_FASTDEF(temp);
-            float f = data[i][d_offset+j];
-            int v = STBV_FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
-            if ((unsigned int) (v + 32768) > 65535)
-               v = v < 0 ? -32768 : 32767;
-            *buffer++ = v;
-         }
-         for (   ; i < buf_c; ++i)
-            *buffer++ = 0;
-      }
-   }
-}
-
-STBVDEF int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
-{
-   float **output;
-   int len;
-   if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts);
-   len = stb_vorbis_get_frame_float(f, NULL, &output);
-   if (len) {
-      if (len*num_c > num_shorts) len = num_shorts / num_c;
-      stbv_convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
-   }
-   return len;
-}
-
-STBVDEF int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
-{
-   float **outputs;
-   int len = num_shorts / channels;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      if (k)
-         stbv_convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);
-      buffer += k*channels;
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len) break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
-   }
-   return n;
-}
-
-STBVDEF int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
-{
-   float **outputs;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      if (k)
-         stbv_convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k);
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len) break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
-   }
-   return n;
-}
-
-#ifndef STB_VORBIS_NO_STDIO
-STBVDEF int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
-{
-   int data_len, offset, total, limit, error;
-   short *data;
-   stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL);
-   if (v == NULL) return -1;
-   limit = v->channels * 4096;
-   *channels = v->channels;
-   if (sample_rate)
-      *sample_rate = v->sample_rate;
-   offset = data_len = 0;
-   total = limit;
-   data = (short *) malloc(total * sizeof(*data));
-   if (data == NULL) {
-      stb_vorbis_close(v);
-      return -2;
-   }
-   for (;;) {
-      int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
-      if (n == 0) break;
-      data_len += n;
-      offset += n * v->channels;
-      if (offset + limit > total) {
-         short *data2;
-         total *= 2;
-         data2 = (short *) realloc(data, total * sizeof(*data));
-         if (data2 == NULL) {
-            free(data);
-            stb_vorbis_close(v);
-            return -2;
-         }
-         data = data2;
-      }
-   }
-   *output = data;
-   stb_vorbis_close(v);
-   return data_len;
-}
-#endif // NO_STDIO
-
-STBVDEF int stb_vorbis_decode_memory(const stbv_uint8 *mem, int len, int *channels, int *sample_rate, short **output)
-{
-   int data_len, offset, total, limit, error;
-   short *data;
-   stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL);
-   if (v == NULL) return -1;
-   limit = v->channels * 4096;
-   *channels = v->channels;
-   if (sample_rate)
-      *sample_rate = v->sample_rate;
-   offset = data_len = 0;
-   total = limit;
-   data = (short *) malloc(total * sizeof(*data));
-   if (data == NULL) {
-      stb_vorbis_close(v);
-      return -2;
-   }
-   for (;;) {
-      int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
-      if (n == 0) break;
-      data_len += n;
-      offset += n * v->channels;
-      if (offset + limit > total) {
-         short *data2;
-         total *= 2;
-         data2 = (short *) realloc(data, total * sizeof(*data));
-         if (data2 == NULL) {
-            free(data);
-            stb_vorbis_close(v);
-            return -2;
-         }
-         data = data2;
-      }
-   }
-   *output = data;
-   stb_vorbis_close(v);
-   return data_len;
-}
-#endif // STB_VORBIS_NO_INTEGER_CONVERSION
-
-STBVDEF int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
-{
-   float **outputs;
-   int len = num_floats / channels;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < len) {
-      int i,j;
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= len) k = len - n;
-      for (j=0; j < k; ++j) {
-         for (i=0; i < z; ++i)
-            *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j];
-         for (   ; i < channels; ++i)
-            *buffer++ = 0;
-      }
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == len)
-         break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
-         break;
-   }
-   return n;
-}
-
-STBVDEF int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
-{
-   float **outputs;
-   int n=0;
-   int z = f->channels;
-   if (z > channels) z = channels;
-   while (n < num_samples) {
-      int i;
-      int k = f->channel_buffer_end - f->channel_buffer_start;
-      if (n+k >= num_samples) k = num_samples - n;
-      if (k) {
-         for (i=0; i < z; ++i)
-            memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k);
-         for (   ; i < channels; ++i)
-            memset(buffer[i]+n, 0, sizeof(float) * k);
-      }
-      n += k;
-      f->channel_buffer_start += k;
-      if (n == num_samples)
-         break;
-      if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
-         break;
-   }
-   return n;
-}
-#endif // STB_VORBIS_NO_PULLDATA_API
-
-/* Version history
-    1.12    - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
-    1.11    - 2017-07-23 - fix MinGW compilation 
-    1.10    - 2017-03-03 - more robust seeking; fix negative stbv_ilog(); clear error in open_memory
-    1.09    - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version
-    1.08    - 2016-04-02 - fixed multiple warnings; fix setup memory leaks;
-                           avoid discarding last frame of audio data
-    1.07    - 2015-01-16 - fixed some warnings, fix mingw, const-correct API
-                           some more crash fixes when out of memory or with corrupt files 
-    1.06    - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
-                           some crash fixes when out of memory or with corrupt files
-    1.05    - 2015-04-19 - don't define __forceinline if it's redundant
-    1.04    - 2014-08-27 - fix missing const-correct case in API
-    1.03    - 2014-08-07 - Warning fixes
-    1.02    - 2014-07-09 - Declare qsort compare function _cdecl on windows
-    1.01    - 2014-06-18 - fix stb_vorbis_get_samples_float
-    1.0     - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in multichannel
-                           (API change) report sample rate for decode-full-file funcs
-    0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila
-    0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem
-    0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence
-    0.99993 - remove assert that fired on legal files with empty tables
-    0.99992 - rewind-to-start
-    0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo
-    0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++
-    0.9998 - add a full-decode function with a memory source
-    0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition
-    0.9996 - query length of vorbis stream in samples/seconds
-    0.9995 - bugfix to another optimization that only happened in certain files
-    0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors
-    0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation
-    0.9992 - performance improvement of IMDCT; now performs close to reference implementation
-    0.9991 - performance improvement of IMDCT
-    0.999 - (should have been 0.9990) performance improvement of IMDCT
-    0.998 - no-CRT support from Casey Muratori
-    0.997 - bugfixes for bugs found by Terje Mathisen
-    0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen
-    0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen
-    0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen
-    0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen
-    0.992 - fixes for MinGW warning
-    0.991 - turn fast-float-conversion on by default
-    0.990 - fix push-mode seek recovery if you seek into the headers
-    0.98b - fix to bad release of 0.98
-    0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode
-    0.97 - builds under c++ (typecasting, don't use 'class' keyword)
-    0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code
-    0.95 - clamping code for 16-bit functions
-    0.94 - not publically released
-    0.93 - fixed all-zero-floor case (was decoding garbage)
-    0.92 - fixed a memory leak
-    0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION
-    0.90 - first public release
-*/
-
-#endif // STB_VORBIS_IMPLEMENTATION
-
-
-/*
-------------------------------------------------------------------------------
-This software is available under 2 licenses -- choose whichever you prefer.
-------------------------------------------------------------------------------
-ALTERNATIVE A - MIT License
-Copyright (c) 2017 Sean Barrett
-Permission is hereby granted, free of charge, to any person obtaining a copy of 
-this software and associated documentation files (the "Software"), to deal in 
-the Software without restriction, including without limitation the rights to 
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
-of the Software, and to permit persons to whom the Software is furnished to do 
-so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all 
-copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
-SOFTWARE.
-------------------------------------------------------------------------------
-ALTERNATIVE B - Public Domain (www.unlicense.org)
-This is free and unencumbered software released into the public domain.
-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 
-software, either in source code form or as a compiled binary, for any purpose, 
-commercial or non-commercial, and by any means.
-In jurisdictions that recognize copyright laws, the author or authors of this 
-software dedicate any and all copyright interest in the software to the public 
-domain. We make this dedication for the benefit of the public at large and to 
-the detriment of our heirs and successors. We intend this dedication to be an 
-overt act of relinquishment in perpetuity of all present and future rights to 
-this software under copyright law.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-------------------------------------------------------------------------------
-*/
diff --git a/raylib_pi4_test/external/tinyobj_loader_c.h b/raylib_pi4_test/external/tinyobj_loader_c.h
deleted file mode 100644 (file)
index 6bd63fc..0000000
+++ /dev/null
@@ -1,1587 +0,0 @@
-/*
-   The MIT License (MIT)
-
-   Copyright (c) 2016 - 2019 Syoyo Fujita and many contributors.
-
-   Permission is hereby granted, free of charge, to any person obtaining a copy
-   of this software and associated documentation files (the "Software"), to deal
-   in the Software without restriction, including without limitation the rights
-   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-   copies of the Software, and to permit persons to whom the Software is
-   furnished to do so, subject to the following conditions:
-
-   The above copyright notice and this permission notice shall be included in
-   all copies or substantial portions of the Software.
-
-   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-   THE SOFTWARE.
-   */
-#ifndef TINOBJ_LOADER_C_H_
-#define TINOBJ_LOADER_C_H_
-
-/* @todo { Remove stddef dependency. unsigned int? } ---> RAY: DONE. */
-//#include <stddef.h>
-
-typedef struct {
-  char *name;
-
-  float ambient[3];
-  float diffuse[3];
-  float specular[3];
-  float transmittance[3];
-  float emission[3];
-  float shininess;
-  float ior;      /* index of refraction */
-  float dissolve; /* 1 == opaque; 0 == fully transparent */
-  /* illumination model (see http://www.fileformat.info/format/material/) */
-  int illum;
-
-  int pad0;
-
-  char *ambient_texname;            /* map_Ka */
-  char *diffuse_texname;            /* map_Kd */
-  char *specular_texname;           /* map_Ks */
-  char *specular_highlight_texname; /* map_Ns */
-  char *bump_texname;               /* map_bump, bump */
-  char *displacement_texname;       /* disp */
-  char *alpha_texname;              /* map_d */
-} tinyobj_material_t;
-
-typedef struct {
-  char *name; /* group name or object name. */
-  unsigned int face_offset;
-  unsigned int length;
-} tinyobj_shape_t;
-
-typedef struct { int v_idx, vt_idx, vn_idx; } tinyobj_vertex_index_t;
-
-typedef struct {
-  unsigned int num_vertices;
-  unsigned int num_normals;
-  unsigned int num_texcoords;
-  unsigned int num_faces;
-  unsigned int num_face_num_verts;
-
-  int pad0;
-
-  float *vertices;
-  float *normals;
-  float *texcoords;
-  tinyobj_vertex_index_t *faces;
-  int *face_num_verts;
-  int *material_ids;
-} tinyobj_attrib_t;
-
-
-#define TINYOBJ_FLAG_TRIANGULATE (1 << 0)
-
-#define TINYOBJ_INVALID_INDEX (0x80000000)
-
-#define TINYOBJ_SUCCESS (0)
-#define TINYOBJ_ERROR_EMPTY (-1)
-#define TINYOBJ_ERROR_INVALID_PARAMETER (-2)
-#define TINYOBJ_ERROR_FILE_OPERATION (-3)
-
-/* Parse wavefront .obj(.obj string data is expanded to linear char array `buf')
- * flags are combination of TINYOBJ_FLAG_***
- * Returns TINYOBJ_SUCCESS if things goes well.
- * Returns TINYOBJ_ERR_*** when there is an error.
- */
-extern int tinyobj_parse_obj(tinyobj_attrib_t *attrib, tinyobj_shape_t **shapes,
-                             unsigned int *num_shapes, tinyobj_material_t **materials,
-                             unsigned int *num_materials, const char *buf, unsigned int len,
-                             unsigned int flags);
-extern int tinyobj_parse_mtl_file(tinyobj_material_t **materials_out,
-                                  unsigned int *num_materials_out,
-                                  const char *filename);
-
-extern void tinyobj_attrib_init(tinyobj_attrib_t *attrib);
-extern void tinyobj_attrib_free(tinyobj_attrib_t *attrib);
-extern void tinyobj_shapes_free(tinyobj_shape_t *shapes, unsigned int num_shapes);
-extern void tinyobj_materials_free(tinyobj_material_t *materials,
-                                   unsigned int num_materials);
-
-#ifdef TINYOBJ_LOADER_C_IMPLEMENTATION
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-#include <errno.h>
-
-#if defined(TINYOBJ_MALLOC) && defined(TINYOBJ_REALLOC) && defined(TINYOBJ_CALLOC) && defined(TINYOBJ_FREE)
-/* ok */
-#elif !defined(TINYOBJ_MALLOC) && !defined(TINYOBJ_REALLOC) && !defined(TINYOBJ_CALLOC) && !defined(TINYOBJ_FREE)
-/* ok */
-#else
-#error "Must define all or none of TINYOBJ_MALLOC, TINYOBJ_REALLOC, TINYOBJ_CALLOC and TINYOBJ_FREE."
-#endif
-
-#ifndef TINYOBJ_MALLOC
-#include <stdlib.h>
-#define TINYOBJ_MALLOC malloc
-#define TINYOBJ_REALLOC realloc
-#define TINYOBJ_CALLOC calloc
-#define TINYOBJ_FREE free
-#endif
-
-#define TINYOBJ_MAX_FACES_PER_F_LINE (16)
-
-#define IS_SPACE(x) (((x) == ' ') || ((x) == '\t'))
-#define IS_DIGIT(x) ((unsigned int)((x) - '0') < (unsigned int)(10))
-#define IS_NEW_LINE(x) (((x) == '\r') || ((x) == '\n') || ((x) == '\0'))
-
-static void skip_space(const char **token) {
-  while ((*token)[0] == ' ' || (*token)[0] == '\t') {
-    (*token)++;
-  }
-}
-
-static void skip_space_and_cr(const char **token) {
-  while ((*token)[0] == ' ' || (*token)[0] == '\t' || (*token)[0] == '\r') {
-    (*token)++;
-  }
-}
-
-static int until_space(const char *token) {
-  const char *p = token;
-  while (p[0] != '\0' && p[0] != ' ' && p[0] != '\t' && p[0] != '\r') {
-    p++;
-  }
-
-  return (int)(p - token);
-}
-
-static unsigned int length_until_newline(const char *token, unsigned int n) {
-  unsigned int len = 0;
-
-  /* Assume token[n-1] = '\0' */
-  for (len = 0; len < n - 1; len++) {
-    if (token[len] == '\n') {
-      break;
-    }
-    if ((token[len] == '\r') && ((len < (n - 2)) && (token[len + 1] != '\n'))) {
-      break;
-    }
-  }
-
-  return len;
-}
-
-static unsigned int length_until_line_feed(const char *token, unsigned int n) {
-  unsigned int len = 0;
-
-  /* Assume token[n-1] = '\0' */
-  for (len = 0; len < n; len++) {
-    if ((token[len] == '\n') || (token[len] == '\r')) {
-      break;
-    }
-  }
-
-  return len;
-}
-
-/* http://stackoverflow.com/questions/5710091/how-does-atoi-function-in-c-work
-*/
-static int my_atoi(const char *c) {
-  int value = 0;
-  int sign = 1;
-  if (*c == '+' || *c == '-') {
-    if (*c == '-') sign = -1;
-    c++;
-  }
-  while (((*c) >= '0') && ((*c) <= '9')) { /* isdigit(*c) */
-    value *= 10;
-    value += (int)(*c - '0');
-    c++;
-  }
-  return value * sign;
-}
-
-/* Make index zero-base, and also support relative index. */
-static int fixIndex(int idx, unsigned int n) {
-  if (idx > 0) return idx - 1;
-  if (idx == 0) return 0;
-  return (int)n + idx; /* negative value = relative */
-}
-
-/* Parse raw triples: i, i/j/k, i//k, i/j */
-static tinyobj_vertex_index_t parseRawTriple(const char **token) {
-  tinyobj_vertex_index_t vi;
-  /* 0x80000000 = -2147483648 = invalid */
-  vi.v_idx = (int)(0x80000000);
-  vi.vn_idx = (int)(0x80000000);
-  vi.vt_idx = (int)(0x80000000);
-
-  vi.v_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  if ((*token)[0] != '/') {
-    return vi;
-  }
-  (*token)++;
-
-  /* i//k */
-  if ((*token)[0] == '/') {
-    (*token)++;
-    vi.vn_idx = my_atoi((*token));
-    while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-           (*token)[0] != '\t' && (*token)[0] != '\r') {
-      (*token)++;
-    }
-    return vi;
-  }
-
-  /* i/j/k or i/j */
-  vi.vt_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  if ((*token)[0] != '/') {
-    return vi;
-  }
-
-  /* i/j/k */
-  (*token)++; /* skip '/' */
-  vi.vn_idx = my_atoi((*token));
-  while ((*token)[0] != '\0' && (*token)[0] != '/' && (*token)[0] != ' ' &&
-         (*token)[0] != '\t' && (*token)[0] != '\r') {
-    (*token)++;
-  }
-  return vi;
-}
-
-static int parseInt(const char **token) {
-  int i = 0;
-  skip_space(token);
-  i = my_atoi((*token));
-  (*token) += until_space((*token));
-  return i;
-}
-
-/*
- * Tries to parse a floating point number located at s.
- *
- * s_end should be a location in the string where reading should absolutely
- * stop. For example at the end of the string, to prevent buffer overflows.
- *
- * Parses the following EBNF grammar:
- *   sign    = "+" | "-" ;
- *   END     = ? anything not in digit ?
- *   digit   = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
- *   integer = [sign] , digit , {digit} ;
- *   decimal = integer , ["." , integer] ;
- *   float   = ( decimal , END ) | ( decimal , ("E" | "e") , integer , END ) ;
- *
- *  Valid strings are for example:
- *   -0  +3.1417e+2  -0.0E-3  1.0324  -1.41   11e2
- *
- * If the parsing is a success, result is set to the parsed value and true
- * is returned.
- *
- * The function is greedy and will parse until any of the following happens:
- *  - a non-conforming character is encountered.
- *  - s_end is reached.
- *
- * The following situations triggers a failure:
- *  - s >= s_end.
- *  - parse failure.
- */
-static int tryParseDouble(const char *s, const char *s_end, double *result) {
-  double mantissa = 0.0;
-  /* This exponent is base 2 rather than 10.
-   * However the exponent we parse is supposed to be one of ten,
-   * thus we must take care to convert the exponent/and or the
-   * mantissa to a * 2^E, where a is the mantissa and E is the
-   * exponent.
-   * To get the final double we will use ldexp, it requires the
-   * exponent to be in base 2.
-   */
-  int exponent = 0;
-
-  /* NOTE: THESE MUST BE DECLARED HERE SINCE WE ARE NOT ALLOWED
-   * TO JUMP OVER DEFINITIONS.
-   */
-  char sign = '+';
-  char exp_sign = '+';
-  char const *curr = s;
-
-  /* How many characters were read in a loop. */
-  int read = 0;
-  /* Tells whether a loop terminated due to reaching s_end. */
-  int end_not_reached = 0;
-
-  /*
-     BEGIN PARSING.
-     */
-
-  if (s >= s_end) {
-    return 0; /* fail */
-  }
-
-  /* Find out what sign we've got. */
-  if (*curr == '+' || *curr == '-') {
-    sign = *curr;
-    curr++;
-  } else if (IS_DIGIT(*curr)) { /* Pass through. */
-  } else {
-    goto fail;
-  }
-
-  /* Read the integer part. */
-  end_not_reached = (curr != s_end);
-  while (end_not_reached && IS_DIGIT(*curr)) {
-    mantissa *= 10;
-    mantissa += (int)(*curr - 0x30);
-    curr++;
-    read++;
-    end_not_reached = (curr != s_end);
-  }
-
-  /* We must make sure we actually got something. */
-  if (read == 0) goto fail;
-  /* We allow numbers of form "#", "###" etc. */
-  if (!end_not_reached) goto assemble;
-
-  /* Read the decimal part. */
-  if (*curr == '.') {
-    curr++;
-    read = 1;
-    end_not_reached = (curr != s_end);
-    while (end_not_reached && IS_DIGIT(*curr)) {
-      /* pow(10.0, -read) */
-      double frac_value = 1.0;
-      int f;
-      for (f = 0; f < read; f++) {
-        frac_value *= 0.1;
-      }
-      mantissa += (int)(*curr - 0x30) * frac_value;
-      read++;
-      curr++;
-      end_not_reached = (curr != s_end);
-    }
-  } else if (*curr == 'e' || *curr == 'E') {
-  } else {
-    goto assemble;
-  }
-
-  if (!end_not_reached) goto assemble;
-
-  /* Read the exponent part. */
-  if (*curr == 'e' || *curr == 'E') {
-    curr++;
-    /* Figure out if a sign is present and if it is. */
-    end_not_reached = (curr != s_end);
-    if (end_not_reached && (*curr == '+' || *curr == '-')) {
-      exp_sign = *curr;
-      curr++;
-    } else if (IS_DIGIT(*curr)) { /* Pass through. */
-    } else {
-      /* Empty E is not allowed. */
-      goto fail;
-    }
-
-    read = 0;
-    end_not_reached = (curr != s_end);
-    while (end_not_reached && IS_DIGIT(*curr)) {
-      exponent *= 10;
-      exponent += (int)(*curr - 0x30);
-      curr++;
-      read++;
-      end_not_reached = (curr != s_end);
-    }
-    if (read == 0) goto fail;
-  }
-
-assemble :
-
-  {
-    double a = 1.0; /* = pow(5.0, exponent); */
-    double b  = 1.0; /* = 2.0^exponent */
-    int i;
-    for (i = 0; i < exponent; i++) {
-      a = a * 5.0;
-    }
-
-    for (i = 0; i < exponent; i++) {
-      b = b * 2.0;
-    }
-
-    if (exp_sign == '-') {
-      a = 1.0 / a;
-      b = 1.0 / b;
-    }
-
-    *result =
-      /* (sign == '+' ? 1 : -1) * ldexp(mantissa * pow(5.0, exponent),
-         exponent); */
-      (sign == '+' ? 1 : -1) * (mantissa * a * b);
-  }
-
-  return 1;
-fail:
-  return 0;
-}
-
-static float parseFloat(const char **token) {
-  const char *end;
-  double val = 0.0;
-  float f = 0.0f;
-  skip_space(token);
-  end = (*token) + until_space((*token));
-  val = 0.0;
-  tryParseDouble((*token), end, &val);
-  f = (float)(val);
-  (*token) = end;
-  return f;
-}
-
-static void parseFloat2(float *x, float *y, const char **token) {
-  (*x) = parseFloat(token);
-  (*y) = parseFloat(token);
-}
-
-static void parseFloat3(float *x, float *y, float *z, const char **token) {
-  (*x) = parseFloat(token);
-  (*y) = parseFloat(token);
-  (*z) = parseFloat(token);
-}
-
-static unsigned int my_strnlen(const char *s, unsigned int n) {
-    const char *p = memchr(s, 0, n);
-    return p ? (unsigned int)(p - s) : n;
-}
-
-static char *my_strdup(const char *s, unsigned int max_length) {
-  char *d;
-  unsigned int len;
-
-  if (s == NULL) return NULL;
-
-  /* Do not consider CRLF line ending(#19) */
-  len = length_until_line_feed(s, max_length);
-  /* len = strlen(s); */
-
-  /* trim line ending and append '\0' */
-  d = (char *)TINYOBJ_MALLOC(len + 1); /* + '\0' */
-  memcpy(d, s, (unsigned int)(len));
-  d[len] = '\0';
-
-  return d;
-}
-
-static char *my_strndup(const char *s, unsigned int len) {
-  char *d;
-  unsigned int slen;
-
-  if (s == NULL) return NULL;
-  if (len == 0) return NULL;
-
-  slen = my_strnlen(s, len);
-  d = (char *)TINYOBJ_MALLOC(slen + 1); /* + '\0' */
-  if (!d) {
-    return NULL;
-  }
-  memcpy(d, s, slen);
-  d[slen] = '\0';
-
-  return d;
-}
-
-char *dynamic_fgets(char **buf, unsigned int *size, FILE *file) {
-  char *offset;
-  char *ret;
-  unsigned int old_size;
-
-  if (!(ret = fgets(*buf, (int)*size, file))) {
-    return ret;
-  }
-
-  if (NULL != strchr(*buf, '\n')) {
-    return ret;
-  }
-
-  do {
-    old_size = *size;
-    *size *= 2;
-    *buf = (char*)TINYOBJ_REALLOC(*buf, *size);
-    offset = &((*buf)[old_size - 1]);
-
-    ret = fgets(offset, (int)(old_size + 1), file);
-  } while(ret && (NULL == strchr(*buf, '\n')));
-
-  return ret;
-}
-
-static void initMaterial(tinyobj_material_t *material) {
-  int i;
-  material->name = NULL;
-  material->ambient_texname = NULL;
-  material->diffuse_texname = NULL;
-  material->specular_texname = NULL;
-  material->specular_highlight_texname = NULL;
-  material->bump_texname = NULL;
-  material->displacement_texname = NULL;
-  material->alpha_texname = NULL;
-  for (i = 0; i < 3; i++) {
-    material->ambient[i] = 0.f;
-    material->diffuse[i] = 0.f;
-    material->specular[i] = 0.f;
-    material->transmittance[i] = 0.f;
-    material->emission[i] = 0.f;
-  }
-  material->illum = 0;
-  material->dissolve = 1.f;
-  material->shininess = 1.f;
-  material->ior = 1.f;
-}
-
-/* Implementation of string to int hashtable */
-
-#define HASH_TABLE_ERROR 1 
-#define HASH_TABLE_SUCCESS 0
-
-#define HASH_TABLE_DEFAULT_SIZE 10
-
-typedef struct hash_table_entry_t
-{
-  unsigned long hash;
-  int filled;
-  int pad0;
-  long value;
-
-  struct hash_table_entry_t* next;
-} hash_table_entry_t;
-
-typedef struct
-{
-  unsigned long* hashes;
-  hash_table_entry_t* entries;
-  unsigned int capacity;
-  unsigned int n;
-} hash_table_t;
-
-static unsigned long hash_djb2(const unsigned char* str)
-{
-  unsigned long hash = 5381;
-  int c;
-
-  while ((c = *str++)) {
-    hash = ((hash << 5) + hash) + (unsigned long)(c);
-  }
-
-  return hash;
-}
-
-static void create_hash_table(unsigned int start_capacity, hash_table_t* hash_table)
-{
-  if (start_capacity < 1)
-    start_capacity = HASH_TABLE_DEFAULT_SIZE;
-  hash_table->hashes = (unsigned long*) TINYOBJ_MALLOC(start_capacity * sizeof(unsigned long));
-  hash_table->entries = (hash_table_entry_t*) TINYOBJ_CALLOC(start_capacity, sizeof(hash_table_entry_t));
-  hash_table->capacity = start_capacity;
-  hash_table->n = 0;
-}
-
-static void destroy_hash_table(hash_table_t* hash_table)
-{
-  TINYOBJ_FREE(hash_table->entries);
-  TINYOBJ_FREE(hash_table->hashes);
-}
-
-/* Insert with quadratic probing */
-static int hash_table_insert_value(unsigned long hash, long value, hash_table_t* hash_table)
-{
-  /* Insert value */
-  unsigned int start_index = hash % hash_table->capacity;
-  unsigned int index = start_index;
-  hash_table_entry_t* start_entry = hash_table->entries + start_index;
-  unsigned int i;
-  hash_table_entry_t* entry;
-
-  for (i = 1; hash_table->entries[index].filled; i++)
-  {
-    if (i >= hash_table->capacity)
-      return HASH_TABLE_ERROR;
-    index = (start_index + (i * i)) % hash_table->capacity; 
-  }
-
-  entry = hash_table->entries + index;
-  entry->hash = hash;
-  entry->filled = 1;
-  entry->value = value;
-
-  if (index != start_index) {
-    /* This is a new entry, but not the start entry, hence we need to add a next pointer to our entry */
-    entry->next = start_entry->next;
-    start_entry->next = entry;
-  }
-
-  return HASH_TABLE_SUCCESS;
-}
-
-static int hash_table_insert(unsigned long hash, long value, hash_table_t* hash_table)
-{
-  int ret = hash_table_insert_value(hash, value, hash_table);
-  if (ret == HASH_TABLE_SUCCESS)
-  {
-    hash_table->hashes[hash_table->n] = hash;
-    hash_table->n++;
-  }
-  return ret;
-}
-
-static hash_table_entry_t* hash_table_find(unsigned long hash, hash_table_t* hash_table)
-{
-  hash_table_entry_t* entry = hash_table->entries + (hash % hash_table->capacity);
-  while (entry)
-  {
-    if (entry->hash == hash && entry->filled)
-    {
-      return entry;
-    }
-    entry = entry->next;
-  }
-  return NULL;
-}
-
-static void hash_table_maybe_grow(unsigned int new_n, hash_table_t* hash_table)
-{
-  unsigned int new_capacity;
-  hash_table_t new_hash_table;
-  unsigned int i;
-
-  if (new_n <= hash_table->capacity) {
-    return;
-  }
-  new_capacity = 2 * ((2 * hash_table->capacity) > new_n ? hash_table->capacity : new_n);
-  /* Create a new hash table. We're not calling create_hash_table because we want to realloc the hash array */
-  new_hash_table.hashes = hash_table->hashes = (unsigned long*) TINYOBJ_REALLOC((void*) hash_table->hashes, sizeof(unsigned long) * new_capacity);
-  new_hash_table.entries = (hash_table_entry_t*) TINYOBJ_CALLOC(new_capacity, sizeof(hash_table_entry_t));
-  new_hash_table.capacity = new_capacity;
-  new_hash_table.n = hash_table->n;
-
-  /* Rehash */
-  for (i = 0; i < hash_table->capacity; i++)
-  {
-    hash_table_entry_t* entry = hash_table_find(hash_table->hashes[i], hash_table);
-    hash_table_insert_value(hash_table->hashes[i], entry->value, &new_hash_table);
-  }
-
-  TINYOBJ_FREE(hash_table->entries);
-  (*hash_table) = new_hash_table;
-}
-
-static int hash_table_exists(const char* name, hash_table_t* hash_table)
-{
-  return hash_table_find(hash_djb2((const unsigned char*)name), hash_table) != NULL;
-}
-
-static void hash_table_set(const char* name, unsigned int val, hash_table_t* hash_table)
-{
-  /* Hash name */
-  unsigned long hash = hash_djb2((const unsigned char *)name);
-
-  hash_table_entry_t* entry = hash_table_find(hash, hash_table);
-  if (entry)
-  {
-    entry->value = (long)val;
-    return;
-  }
-
-  /* Expand if necessary
-   * Grow until the element has been added
-   */
-  do
-  {
-    hash_table_maybe_grow(hash_table->n + 1, hash_table);
-  }
-  while (hash_table_insert(hash, (long)val, hash_table) != HASH_TABLE_SUCCESS);
-}
-
-static long hash_table_get(const char* name, hash_table_t* hash_table)
-{
-  hash_table_entry_t* ret = hash_table_find(hash_djb2((const unsigned char*)(name)), hash_table);
-  return ret->value;
-}
-
-static tinyobj_material_t *tinyobj_material_add(tinyobj_material_t *prev,
-                                                unsigned int num_materials,
-                                                tinyobj_material_t *new_mat) {
-  tinyobj_material_t *dst;
-  dst = (tinyobj_material_t *)TINYOBJ_REALLOC(
-                                      prev, sizeof(tinyobj_material_t) * (num_materials + 1));
-
-  dst[num_materials] = (*new_mat); /* Just copy pointer for char* members */
-  return dst;
-}
-
-static int tinyobj_parse_and_index_mtl_file(tinyobj_material_t **materials_out,
-                                            unsigned int *num_materials_out,
-                                            const char *filename,
-                                            hash_table_t* material_table) {
-  tinyobj_material_t material;
-  unsigned int buffer_size = 128;
-  char *linebuf;
-  FILE *fp;
-  unsigned int num_materials = 0;
-  tinyobj_material_t *materials = NULL;
-  int has_previous_material = 0;
-  const char *line_end = NULL;
-
-  if (materials_out == NULL) {
-    return TINYOBJ_ERROR_INVALID_PARAMETER;
-  }
-
-  if (num_materials_out == NULL) {
-    return TINYOBJ_ERROR_INVALID_PARAMETER;
-  }
-
-  (*materials_out) = NULL;
-  (*num_materials_out) = 0;
-
-  fp = fopen(filename, "r");
-  if (!fp) {
-    fprintf(stderr, "TINYOBJ: Error reading file '%s': %s (%d)\n", filename, strerror(errno), errno);
-    return TINYOBJ_ERROR_FILE_OPERATION;
-  }
-
-  /* Create a default material */
-  initMaterial(&material);
-
-  linebuf = (char*)TINYOBJ_MALLOC(buffer_size);
-  while (NULL != dynamic_fgets(&linebuf, &buffer_size, fp)) {
-    const char *token = linebuf;
-
-    line_end = token + strlen(token);
-
-    /* Skip leading space. */
-    token += strspn(token, " \t");
-
-    assert(token);
-    if (token[0] == '\0') continue; /* empty line */
-
-    if (token[0] == '#') continue; /* comment line */
-
-    /* new mtl */
-    if ((0 == strncmp(token, "newmtl", 6)) && IS_SPACE((token[6]))) {
-      char namebuf[4096];
-
-      /* flush previous material. */
-      if (has_previous_material) {
-        materials = tinyobj_material_add(materials, num_materials, &material);
-        num_materials++;
-      } else {
-        has_previous_material = 1;
-      }
-
-      /* initial temporary material */
-      initMaterial(&material);
-
-      /* set new mtl name */
-      token += 7;
-#ifdef _MSC_VER
-      sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf));
-#else
-      sscanf(token, "%s", namebuf);
-#endif
-      material.name = my_strdup(namebuf, (unsigned int) (line_end - token));
-
-      /* Add material to material table */
-      if (material_table)
-        hash_table_set(material.name, num_materials, material_table);
-
-      continue;
-    }
-
-    /* ambient */
-    if (token[0] == 'K' && token[1] == 'a' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.ambient[0] = r;
-      material.ambient[1] = g;
-      material.ambient[2] = b;
-      continue;
-    }
-
-    /* diffuse */
-    if (token[0] == 'K' && token[1] == 'd' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.diffuse[0] = r;
-      material.diffuse[1] = g;
-      material.diffuse[2] = b;
-      continue;
-    }
-
-    /* specular */
-    if (token[0] == 'K' && token[1] == 's' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.specular[0] = r;
-      material.specular[1] = g;
-      material.specular[2] = b;
-      continue;
-    }
-
-    /* transmittance */
-    if (token[0] == 'K' && token[1] == 't' && IS_SPACE((token[2]))) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.transmittance[0] = r;
-      material.transmittance[1] = g;
-      material.transmittance[2] = b;
-      continue;
-    }
-
-    /* ior(index of refraction) */
-    if (token[0] == 'N' && token[1] == 'i' && IS_SPACE((token[2]))) {
-      token += 2;
-      material.ior = parseFloat(&token);
-      continue;
-    }
-
-    /* emission */
-    if (token[0] == 'K' && token[1] == 'e' && IS_SPACE(token[2])) {
-      float r, g, b;
-      token += 2;
-      parseFloat3(&r, &g, &b, &token);
-      material.emission[0] = r;
-      material.emission[1] = g;
-      material.emission[2] = b;
-      continue;
-    }
-
-    /* shininess */
-    if (token[0] == 'N' && token[1] == 's' && IS_SPACE(token[2])) {
-      token += 2;
-      material.shininess = parseFloat(&token);
-      continue;
-    }
-
-    /* illum model */
-    if (0 == strncmp(token, "illum", 5) && IS_SPACE(token[5])) {
-      token += 6;
-      material.illum = parseInt(&token);
-      continue;
-    }
-
-    /* dissolve */
-    if ((token[0] == 'd' && IS_SPACE(token[1]))) {
-      token += 1;
-      material.dissolve = parseFloat(&token);
-      continue;
-    }
-    if (token[0] == 'T' && token[1] == 'r' && IS_SPACE(token[2])) {
-      token += 2;
-      /* Invert value of Tr(assume Tr is in range [0, 1]) */
-      material.dissolve = 1.0f - parseFloat(&token);
-      continue;
-    }
-
-    /* ambient texture */
-    if ((0 == strncmp(token, "map_Ka", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.ambient_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* diffuse texture */
-    if ((0 == strncmp(token, "map_Kd", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.diffuse_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* specular texture */
-    if ((0 == strncmp(token, "map_Ks", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.specular_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* specular highlight texture */
-    if ((0 == strncmp(token, "map_Ns", 6)) && IS_SPACE(token[6])) {
-      token += 7;
-      material.specular_highlight_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* bump texture */
-    if ((0 == strncmp(token, "map_bump", 8)) && IS_SPACE(token[8])) {
-      token += 9;
-      material.bump_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* alpha texture */
-    if ((0 == strncmp(token, "map_d", 5)) && IS_SPACE(token[5])) {
-      token += 6;
-      material.alpha_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* bump texture */
-    if ((0 == strncmp(token, "bump", 4)) && IS_SPACE(token[4])) {
-      token += 5;
-      material.bump_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* displacement texture */
-    if ((0 == strncmp(token, "disp", 4)) && IS_SPACE(token[4])) {
-      token += 5;
-      material.displacement_texname = my_strdup(token, (unsigned int) (line_end - token));
-      continue;
-    }
-
-    /* @todo { unknown parameter } */
-  }
-
-  if (material.name) {
-    /* Flush last material element */
-    materials = tinyobj_material_add(materials, num_materials, &material);
-    num_materials++;
-  }
-
-  (*num_materials_out) = num_materials;
-  (*materials_out) = materials;
-
-  if (linebuf) {
-    TINYOBJ_FREE(linebuf);
-  }
-
-  return TINYOBJ_SUCCESS;
-}
-
-int tinyobj_parse_mtl_file(tinyobj_material_t **materials_out,
-                           unsigned int *num_materials_out,
-                           const char *filename) {
-  return tinyobj_parse_and_index_mtl_file(materials_out, num_materials_out, filename, NULL);
-} 
-
-
-typedef enum {
-  COMMAND_EMPTY,
-  COMMAND_V,
-  COMMAND_VN,
-  COMMAND_VT,
-  COMMAND_F,
-  COMMAND_G,
-  COMMAND_O,
-  COMMAND_USEMTL,
-  COMMAND_MTLLIB
-
-} CommandType;
-
-typedef struct {
-  float vx, vy, vz;
-  float nx, ny, nz;
-  float tx, ty;
-
-  /* @todo { Use dynamic array } */
-  tinyobj_vertex_index_t f[TINYOBJ_MAX_FACES_PER_F_LINE];
-  unsigned int num_f;
-
-  int f_num_verts[TINYOBJ_MAX_FACES_PER_F_LINE];
-  unsigned int num_f_num_verts;
-
-  const char *group_name;
-  unsigned int group_name_len;
-  int pad0;
-
-  const char *object_name;
-  unsigned int object_name_len;
-  int pad1;
-
-  const char *material_name;
-  unsigned int material_name_len;
-  int pad2;
-
-  const char *mtllib_name;
-  unsigned int mtllib_name_len;
-
-  CommandType type;
-} Command;
-
-static int parseLine(Command *command, const char *p, unsigned int p_len,
-                     int triangulate) {
-  char linebuf[4096];
-  const char *token;
-  assert(p_len < 4095);
-
-  memcpy(linebuf, p, p_len);
-  linebuf[p_len] = '\0';
-
-  token = linebuf;
-
-  command->type = COMMAND_EMPTY;
-
-  /* Skip leading space. */
-  skip_space(&token);
-
-  assert(token);
-  if (token[0] == '\0') { /* empty line */
-    return 0;
-  }
-
-  if (token[0] == '#') { /* comment line */
-    return 0;
-  }
-
-  /* vertex */
-  if (token[0] == 'v' && IS_SPACE((token[1]))) {
-    float x, y, z;
-    token += 2;
-    parseFloat3(&x, &y, &z, &token);
-    command->vx = x;
-    command->vy = y;
-    command->vz = z;
-    command->type = COMMAND_V;
-    return 1;
-  }
-
-  /* normal */
-  if (token[0] == 'v' && token[1] == 'n' && IS_SPACE((token[2]))) {
-    float x, y, z;
-    token += 3;
-    parseFloat3(&x, &y, &z, &token);
-    command->nx = x;
-    command->ny = y;
-    command->nz = z;
-    command->type = COMMAND_VN;
-    return 1;
-  }
-
-  /* texcoord */
-  if (token[0] == 'v' && token[1] == 't' && IS_SPACE((token[2]))) {
-    float x, y;
-    token += 3;
-    parseFloat2(&x, &y, &token);
-    command->tx = x;
-    command->ty = y;
-    command->type = COMMAND_VT;
-    return 1;
-  }
-
-  /* face */
-  if (token[0] == 'f' && IS_SPACE((token[1]))) {
-    unsigned int num_f = 0;
-
-    tinyobj_vertex_index_t f[TINYOBJ_MAX_FACES_PER_F_LINE];
-    token += 2;
-    skip_space(&token);
-
-    while (!IS_NEW_LINE(token[0])) {
-      tinyobj_vertex_index_t vi = parseRawTriple(&token);
-      skip_space_and_cr(&token);
-
-      f[num_f] = vi;
-      num_f++;
-    }
-
-    command->type = COMMAND_F;
-
-    if (triangulate) {
-      unsigned int k;
-      unsigned int n = 0;
-
-      tinyobj_vertex_index_t i0 = f[0];
-      tinyobj_vertex_index_t i1;
-      tinyobj_vertex_index_t i2 = f[1];
-
-      assert(3 * num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
-
-      for (k = 2; k < num_f; k++) {
-        i1 = i2;
-        i2 = f[k];
-        command->f[3 * n + 0] = i0;
-        command->f[3 * n + 1] = i1;
-        command->f[3 * n + 2] = i2;
-
-        command->f_num_verts[n] = 3;
-        n++;
-      }
-      command->num_f = 3 * n;
-      command->num_f_num_verts = n;
-
-    } else {
-      unsigned int k = 0;
-      assert(num_f < TINYOBJ_MAX_FACES_PER_F_LINE);
-      for (k = 0; k < num_f; k++) {
-        command->f[k] = f[k];
-      }
-
-      command->num_f = num_f;
-      command->f_num_verts[0] = (int)num_f;
-      command->num_f_num_verts = 1;
-    }
-
-    return 1;
-  }
-
-  /* use mtl */
-  if ((0 == strncmp(token, "usemtl", 6)) && IS_SPACE((token[6]))) {
-    token += 7;
-
-    skip_space(&token);
-    command->material_name = p + (token - linebuf);
-    command->material_name_len = (unsigned int)length_until_newline(
-                                                                    token, (p_len - (unsigned int)(token - linebuf)) + 1);
-    command->type = COMMAND_USEMTL;
-
-    return 1;
-  }
-
-  /* load mtl */
-  if ((0 == strncmp(token, "mtllib", 6)) && IS_SPACE((token[6]))) {
-    /* By specification, `mtllib` should be appear only once in .obj */
-    token += 7;
-
-    skip_space(&token);
-    command->mtllib_name = p + (token - linebuf);
-    command->mtllib_name_len = (unsigned int)length_until_newline(
-                                                                  token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_MTLLIB;
-
-    return 1;
-  }
-
-  /* group name */
-  if (token[0] == 'g' && IS_SPACE((token[1]))) {
-    /* @todo { multiple group name. } */
-    token += 2;
-
-    command->group_name = p + (token - linebuf);
-    command->group_name_len = (unsigned int)length_until_newline(
-                                                                 token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_G;
-
-    return 1;
-  }
-
-  /* object name */
-  if (token[0] == 'o' && IS_SPACE((token[1]))) {
-    /* @todo { multiple object name? } */
-    token += 2;
-
-    command->object_name = p + (token - linebuf);
-    command->object_name_len = (unsigned int)length_until_newline(
-                                                                  token, p_len - (unsigned int)(token - linebuf)) +
-      1;
-    command->type = COMMAND_O;
-
-    return 1;
-  }
-
-  return 0;
-}
-
-typedef struct {
-  unsigned int pos;
-  unsigned int len;
-} LineInfo;
-
-static int is_line_ending(const char *p, unsigned int i, unsigned int end_i) {
-  if (p[i] == '\0') return 1;
-  if (p[i] == '\n') return 1; /* this includes \r\n */
-  if (p[i] == '\r') {
-    if (((i + 1) < end_i) && (p[i + 1] != '\n')) { /* detect only \r case */
-      return 1;
-    }
-  }
-  return 0;
-}
-
-int tinyobj_parse_obj(tinyobj_attrib_t *attrib, tinyobj_shape_t **shapes,
-                      unsigned int *num_shapes, tinyobj_material_t **materials_out,
-                      unsigned int *num_materials_out, const char *buf, unsigned int len,
-                      unsigned int flags) {
-  LineInfo *line_infos = NULL;
-  Command *commands = NULL;
-  unsigned int num_lines = 0;
-
-  unsigned int num_v = 0;
-  unsigned int num_vn = 0;
-  unsigned int num_vt = 0;
-  unsigned int num_f = 0;
-  unsigned int num_faces = 0;
-
-  int mtllib_line_index = -1;
-
-  tinyobj_material_t *materials = NULL;
-  unsigned int num_materials = 0;
-
-  hash_table_t material_table;
-
-  if (len < 1) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (attrib == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (shapes == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (num_shapes == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (buf == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (materials_out == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-  if (num_materials_out == NULL) return TINYOBJ_ERROR_INVALID_PARAMETER;
-
-  tinyobj_attrib_init(attrib);
-   /* 1. Find '\n' and create line data. */
-  {
-    unsigned int i;
-    unsigned int end_idx = len;
-    unsigned int prev_pos = 0;
-    unsigned int line_no = 0;
-    unsigned int last_line_ending = 0;
-
-    /* Count # of lines. */
-    for (i = 0; i < end_idx; i++) {
-      if (is_line_ending(buf, i, end_idx)) {
-        num_lines++;
-        last_line_ending = i;
-      }
-    }
-    /* The last char from the input may not be a line
-     * ending character so add an extra line if there
-     * are more characters after the last line ending
-     * that was found. */
-    if (end_idx - last_line_ending > 0) {
-        num_lines++;
-    }
-
-    if (num_lines == 0) return TINYOBJ_ERROR_EMPTY;
-
-    line_infos = (LineInfo *)TINYOBJ_MALLOC(sizeof(LineInfo) * num_lines);
-
-    /* Fill line infos. */
-    for (i = 0; i < end_idx; i++) {
-      if (is_line_ending(buf, i, end_idx)) {
-        line_infos[line_no].pos = prev_pos;
-        line_infos[line_no].len = i - prev_pos;
-        prev_pos = i + 1;
-        line_no++;
-      }
-    }
-    if (end_idx - last_line_ending > 0) {
-      line_infos[line_no].pos = prev_pos;
-      line_infos[line_no].len = end_idx - 1 - last_line_ending;
-    }
-  }
-
-  commands = (Command *)TINYOBJ_MALLOC(sizeof(Command) * num_lines); 
-
-  create_hash_table(HASH_TABLE_DEFAULT_SIZE, &material_table);
-
-  /* 2. parse each line */
-  {
-    unsigned int i = 0;
-    for (i = 0; i < num_lines; i++) {
-      int ret = parseLine(&commands[i], &buf[line_infos[i].pos],
-                          line_infos[i].len, flags & TINYOBJ_FLAG_TRIANGULATE);
-      if (ret) {
-        if (commands[i].type == COMMAND_V) {
-          num_v++;
-        } else if (commands[i].type == COMMAND_VN) {
-          num_vn++;
-        } else if (commands[i].type == COMMAND_VT) {
-          num_vt++;
-        } else if (commands[i].type == COMMAND_F) {
-          num_f += commands[i].num_f;
-          num_faces += commands[i].num_f_num_verts;
-        }
-
-        if (commands[i].type == COMMAND_MTLLIB) {
-          mtllib_line_index = (int)i;
-        }
-      }
-    }
-  }
-
-  /* line_infos are not used anymore. Release memory. */
-  if (line_infos) {
-    TINYOBJ_FREE(line_infos);
-  }
-
-  /* Load material(if exits) */
-  if (mtllib_line_index >= 0 && commands[mtllib_line_index].mtllib_name &&
-      commands[mtllib_line_index].mtllib_name_len > 0) {
-    char *filename = my_strndup(commands[mtllib_line_index].mtllib_name,
-                                commands[mtllib_line_index].mtllib_name_len);
-
-    int ret = tinyobj_parse_and_index_mtl_file(&materials, &num_materials, filename, &material_table);
-
-    if (ret != TINYOBJ_SUCCESS) {
-      /* warning. */
-      fprintf(stderr, "TINYOBJ: Failed to parse material file '%s': %d\n", filename, ret);
-    }
-
-    TINYOBJ_FREE(filename);
-
-  }
-
-  /* Construct attributes */
-
-  {
-    unsigned int v_count = 0;
-    unsigned int n_count = 0;
-    unsigned int t_count = 0;
-    unsigned int f_count = 0;
-    unsigned int face_count = 0;
-    int material_id = -1; /* -1 = default unknown material. */
-    unsigned int i = 0;
-
-    attrib->vertices = (float *)TINYOBJ_MALLOC(sizeof(float) * num_v * 3);
-    attrib->num_vertices = (unsigned int)num_v;
-    attrib->normals = (float *)TINYOBJ_MALLOC(sizeof(float) * num_vn * 3);
-    attrib->num_normals = (unsigned int)num_vn;
-    attrib->texcoords = (float *)TINYOBJ_MALLOC(sizeof(float) * num_vt * 2);
-    attrib->num_texcoords = (unsigned int)num_vt;
-    attrib->faces = (tinyobj_vertex_index_t *)TINYOBJ_MALLOC(sizeof(tinyobj_vertex_index_t) * num_f);
-    attrib->face_num_verts = (int *)TINYOBJ_MALLOC(sizeof(int) * num_faces);
-    
-    attrib->num_faces = (unsigned int)num_faces;
-    attrib->num_face_num_verts = (unsigned int)num_f;
-    
-    attrib->material_ids = (int *)TINYOBJ_MALLOC(sizeof(int) * num_faces);
-
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_EMPTY) {
-        continue;
-      } else if (commands[i].type == COMMAND_USEMTL) {
-        /* @todo
-           if (commands[t][i].material_name &&
-           commands[t][i].material_name_len > 0) {
-           std::string material_name(commands[t][i].material_name,
-           commands[t][i].material_name_len);
-
-           if (material_map.find(material_name) != material_map.end()) {
-           material_id = material_map[material_name];
-           } else {
-        // Assign invalid material ID
-        material_id = -1;
-        }
-        }
-        */
-        if (commands[i].material_name &&
-           commands[i].material_name_len >0) 
-        {
-          /* Create a null terminated string */
-          char* material_name_null_term = (char*) TINYOBJ_MALLOC(commands[i].material_name_len + 1);
-          memcpy((void*) material_name_null_term, (const void*) commands[i].material_name, commands[i].material_name_len);
-          material_name_null_term[commands[i].material_name_len] = 0;
-
-          if (hash_table_exists(material_name_null_term, &material_table))
-            material_id = (int)hash_table_get(material_name_null_term, &material_table);
-          else
-            material_id = -1;
-
-          TINYOBJ_FREE(material_name_null_term);
-        }
-      } else if (commands[i].type == COMMAND_V) {
-        attrib->vertices[3 * v_count + 0] = commands[i].vx;
-        attrib->vertices[3 * v_count + 1] = commands[i].vy;
-        attrib->vertices[3 * v_count + 2] = commands[i].vz;
-        v_count++;
-      } else if (commands[i].type == COMMAND_VN) {
-        attrib->normals[3 * n_count + 0] = commands[i].nx;
-        attrib->normals[3 * n_count + 1] = commands[i].ny;
-        attrib->normals[3 * n_count + 2] = commands[i].nz;
-        n_count++;
-      } else if (commands[i].type == COMMAND_VT) {
-        attrib->texcoords[2 * t_count + 0] = commands[i].tx;
-        attrib->texcoords[2 * t_count + 1] = commands[i].ty;
-        t_count++;
-      } else if (commands[i].type == COMMAND_F) {
-        unsigned int k = 0;
-        for (k = 0; k < commands[i].num_f; k++) {
-          tinyobj_vertex_index_t vi = commands[i].f[k];
-          int v_idx = fixIndex(vi.v_idx, v_count);
-          int vn_idx = fixIndex(vi.vn_idx, n_count);
-          int vt_idx = fixIndex(vi.vt_idx, t_count);
-          attrib->faces[f_count + k].v_idx = v_idx;
-          attrib->faces[f_count + k].vn_idx = vn_idx;
-          attrib->faces[f_count + k].vt_idx = vt_idx;
-        }
-
-        for (k = 0; k < commands[i].num_f_num_verts; k++) {
-          attrib->material_ids[face_count + k] = material_id;
-          attrib->face_num_verts[face_count + k] = commands[i].f_num_verts[k];
-        }
-
-        f_count += commands[i].num_f;
-        face_count += commands[i].num_f_num_verts;
-      }
-    }
-  }
-
-  /* 5. Construct shape information. */
-  {
-    unsigned int face_count = 0;
-    unsigned int i = 0;
-    unsigned int n = 0;
-    unsigned int shape_idx = 0;
-
-    const char *shape_name = NULL;
-    unsigned int shape_name_len = 0;
-    const char *prev_shape_name = NULL;
-    unsigned int prev_shape_name_len = 0;
-    unsigned int prev_shape_face_offset = 0;
-    unsigned int prev_face_offset = 0;
-    tinyobj_shape_t prev_shape = {NULL, 0, 0};
-
-    /* Find the number of shapes in .obj */
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_O || commands[i].type == COMMAND_G) {
-        n++;
-      }
-    }
-
-    /* Allocate array of shapes with maximum possible size(+1 for unnamed
-     * group/object).
-     * Actual # of shapes found in .obj is determined in the later */
-    (*shapes) = (tinyobj_shape_t*)TINYOBJ_MALLOC(sizeof(tinyobj_shape_t) * (n + 1));
-
-    for (i = 0; i < num_lines; i++) {
-      if (commands[i].type == COMMAND_O || commands[i].type == COMMAND_G) {
-        if (commands[i].type == COMMAND_O) {
-          shape_name = commands[i].object_name;
-          shape_name_len = commands[i].object_name_len;
-        } else {
-          shape_name = commands[i].group_name;
-          shape_name_len = commands[i].group_name_len;
-        }
-
-        if (face_count == 0) {
-          /* 'o' or 'g' appears before any 'f' */
-          prev_shape_name = shape_name;
-          prev_shape_name_len = shape_name_len;
-          prev_shape_face_offset = face_count;
-          prev_face_offset = face_count;
-        } else {
-          if (shape_idx == 0) {
-            /* 'o' or 'g' after some 'v' lines. */
-            (*shapes)[shape_idx].name = my_strndup(
-                                                   prev_shape_name, prev_shape_name_len); /* may be NULL */
-            (*shapes)[shape_idx].face_offset = prev_shape.face_offset;
-            (*shapes)[shape_idx].length = face_count - prev_face_offset;
-            shape_idx++;
-
-            prev_face_offset = face_count;
-
-          } else {
-            if ((face_count - prev_face_offset) > 0) {
-              (*shapes)[shape_idx].name =
-                my_strndup(prev_shape_name, prev_shape_name_len);
-              (*shapes)[shape_idx].face_offset = prev_face_offset;
-              (*shapes)[shape_idx].length = face_count - prev_face_offset;
-              shape_idx++;
-              prev_face_offset = face_count;
-            }
-          }
-
-          /* Record shape info for succeeding 'o' or 'g' command. */
-          prev_shape_name = shape_name;
-          prev_shape_name_len = shape_name_len;
-          prev_shape_face_offset = face_count;
-        }
-      }
-      if (commands[i].type == COMMAND_F) {
-        face_count++;
-      }
-    }
-
-    if ((face_count - prev_face_offset) > 0) {
-      unsigned int length = face_count - prev_shape_face_offset;
-      if (length > 0) {
-        (*shapes)[shape_idx].name =
-          my_strndup(prev_shape_name, prev_shape_name_len);
-        (*shapes)[shape_idx].face_offset = prev_face_offset;
-        (*shapes)[shape_idx].length = face_count - prev_face_offset;
-        shape_idx++;
-      }
-    } else {
-      /* Guess no 'v' line occurrence after 'o' or 'g', so discards current
-       * shape information. */
-    }
-
-    (*num_shapes) = shape_idx;
-  }
-
-  if (commands) {
-    TINYOBJ_FREE(commands);
-  }
-
-  destroy_hash_table(&material_table);
-  
-  (*materials_out) = materials;
-  (*num_materials_out) = num_materials;
-
-  return TINYOBJ_SUCCESS;
-}
-
-void tinyobj_attrib_init(tinyobj_attrib_t *attrib) {
-  attrib->vertices = NULL;
-  attrib->num_vertices = 0;
-  attrib->normals = NULL;
-  attrib->num_normals = 0;
-  attrib->texcoords = NULL;
-  attrib->num_texcoords = 0;
-  attrib->faces = NULL;
-  attrib->num_faces = 0;
-  attrib->face_num_verts = NULL;
-  attrib->num_face_num_verts = 0;
-  attrib->material_ids = NULL;
-}
-
-void tinyobj_attrib_free(tinyobj_attrib_t *attrib) {
-  if (attrib->vertices) TINYOBJ_FREE(attrib->vertices);
-  if (attrib->normals) TINYOBJ_FREE(attrib->normals);
-  if (attrib->texcoords) TINYOBJ_FREE(attrib->texcoords);
-  if (attrib->faces) TINYOBJ_FREE(attrib->faces);
-  if (attrib->face_num_verts) TINYOBJ_FREE(attrib->face_num_verts);
-  if (attrib->material_ids) TINYOBJ_FREE(attrib->material_ids);
-}
-
-void tinyobj_shapes_free(tinyobj_shape_t *shapes, unsigned int num_shapes) {
-  unsigned int i;
-  if (shapes == NULL) return;
-
-  for (i = 0; i < num_shapes; i++) {
-    if (shapes[i].name) TINYOBJ_FREE(shapes[i].name);
-  }
-
-  TINYOBJ_FREE(shapes);
-}
-
-void tinyobj_materials_free(tinyobj_material_t *materials,
-                            unsigned int num_materials) {
-  unsigned int i;
-  if (materials == NULL) return;
-
-  for (i = 0; i < num_materials; i++) {
-    if (materials[i].name) TINYOBJ_FREE(materials[i].name);
-    if (materials[i].ambient_texname) TINYOBJ_FREE(materials[i].ambient_texname);
-    if (materials[i].diffuse_texname) TINYOBJ_FREE(materials[i].diffuse_texname);
-    if (materials[i].specular_texname) TINYOBJ_FREE(materials[i].specular_texname);
-    if (materials[i].specular_highlight_texname)
-      TINYOBJ_FREE(materials[i].specular_highlight_texname);
-    if (materials[i].bump_texname) TINYOBJ_FREE(materials[i].bump_texname);
-    if (materials[i].displacement_texname)
-      TINYOBJ_FREE(materials[i].displacement_texname);
-    if (materials[i].alpha_texname) TINYOBJ_FREE(materials[i].alpha_texname);
-  }
-
-  TINYOBJ_FREE(materials);
-}
-#endif /* TINYOBJ_LOADER_C_IMPLEMENTATION */
-
-#endif /* TINOBJ_LOADER_C_H_ */